/*!
|
* shp与geojson互转工具类
|
* 版本信息:v2.0.0, hash值: 059dbd8b804dda881d52
|
* 编译日期:2023-08-02 16:24:45
|
* 版权所有:Copyright by 木遥 https://github.com/muyao1987/shp-geojson
|
*
|
*/
|
(function webpackUniversalModuleDefinition(root, factory) {
|
if(typeof exports === 'object' && typeof module === 'object')
|
module.exports = factory();
|
else if(typeof define === 'function' && define.amd)
|
define("shpUtil", [], factory);
|
else if(typeof exports === 'object')
|
exports["shpUtil"] = factory();
|
else
|
root["shpUtil"] = factory();
|
})(window, function() {
|
return /******/ (function(modules) { // webpackBootstrap
|
/******/ // The module cache
|
/******/ var installedModules = {};
|
/******/
|
/******/ // The require function
|
/******/ function __webpack_require__(moduleId) {
|
/******/
|
/******/ // Check if module is in cache
|
/******/ if(installedModules[moduleId]) {
|
/******/ return installedModules[moduleId].exports;
|
/******/ }
|
/******/ // Create a new module (and put it into the cache)
|
/******/ var module = installedModules[moduleId] = {
|
/******/ i: moduleId,
|
/******/ l: false,
|
/******/ exports: {}
|
/******/ };
|
/******/
|
/******/ // Execute the module function
|
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
/******/
|
/******/ // Flag the module as loaded
|
/******/ module.l = true;
|
/******/
|
/******/ // Return the exports of the module
|
/******/ return module.exports;
|
/******/ }
|
/******/
|
/******/
|
/******/ // expose the modules object (__webpack_modules__)
|
/******/ __webpack_require__.m = modules;
|
/******/
|
/******/ // expose the module cache
|
/******/ __webpack_require__.c = installedModules;
|
/******/
|
/******/ // define getter function for harmony exports
|
/******/ __webpack_require__.d = function(exports, name, getter) {
|
/******/ if(!__webpack_require__.o(exports, name)) {
|
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
/******/ }
|
/******/ };
|
/******/
|
/******/ // define __esModule on exports
|
/******/ __webpack_require__.r = function(exports) {
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
/******/ }
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
/******/ };
|
/******/
|
/******/ // create a fake namespace object
|
/******/ // mode & 1: value is a module id, require it
|
/******/ // mode & 2: merge all properties of value into the ns
|
/******/ // mode & 4: return value when already ns object
|
/******/ // mode & 8|1: behave like require
|
/******/ __webpack_require__.t = function(value, mode) {
|
/******/ if(mode & 1) value = __webpack_require__(value);
|
/******/ if(mode & 8) return value;
|
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
/******/ var ns = Object.create(null);
|
/******/ __webpack_require__.r(ns);
|
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
/******/ return ns;
|
/******/ };
|
/******/
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
/******/ __webpack_require__.n = function(module) {
|
/******/ var getter = module && module.__esModule ?
|
/******/ function getDefault() { return module['default']; } :
|
/******/ function getModuleExports() { return module; };
|
/******/ __webpack_require__.d(getter, 'a', getter);
|
/******/ return getter;
|
/******/ };
|
/******/
|
/******/ // Object.prototype.hasOwnProperty.call
|
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
/******/
|
/******/ // __webpack_public_path__
|
/******/ __webpack_require__.p = "";
|
/******/
|
/******/
|
/******/ // Load entry module and return exports
|
/******/ return __webpack_require__(__webpack_require__.s = 29);
|
/******/ })
|
/************************************************************************/
|
/******/ ([
|
/* 0 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
// TODO(Babel 8): Remove this file.
|
|
var runtime = __webpack_require__(35)();
|
module.exports = runtime;
|
|
// Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
|
try {
|
regeneratorRuntime = runtime;
|
} catch (accidentalStrictMode) {
|
if (typeof globalThis === "object") {
|
globalThis.regeneratorRuntime = runtime;
|
} else {
|
Function("r", "regeneratorRuntime = r")(runtime);
|
}
|
}
|
|
|
/***/ }),
|
/* 1 */
|
/***/ (function(module, exports) {
|
|
var g;
|
|
// This works in non-strict mode
|
g = (function() {
|
return this;
|
})();
|
|
try {
|
// This works if eval is allowed (see CSP)
|
g = g || new Function("return this")();
|
} catch (e) {
|
// This works if the window reference is available
|
if (typeof window === "object") g = window;
|
}
|
|
// g can still be undefined, but nothing to do about it...
|
// We return undefined, instead of nothing here, so it's
|
// easier to handle this case. if(!global) { ...}
|
|
module.exports = g;
|
|
|
/***/ }),
|
/* 2 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
"use strict";
|
/* WEBPACK VAR INJECTION */(function(global) {/*!
|
* The buffer module from node.js, for the browser.
|
*
|
* @author Feross Aboukhadijeh <http://feross.org>
|
* @license MIT
|
*/
|
/* eslint-disable no-proto */
|
|
|
|
var base64 = __webpack_require__(43)
|
var ieee754 = __webpack_require__(44)
|
var isArray = __webpack_require__(13)
|
|
exports.Buffer = Buffer
|
exports.SlowBuffer = SlowBuffer
|
exports.INSPECT_MAX_BYTES = 50
|
|
/**
|
* If `Buffer.TYPED_ARRAY_SUPPORT`:
|
* === true Use Uint8Array implementation (fastest)
|
* === false Use Object implementation (most compatible, even IE6)
|
*
|
* Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
|
* Opera 11.6+, iOS 4.2+.
|
*
|
* Due to various browser bugs, sometimes the Object implementation will be used even
|
* when the browser supports typed arrays.
|
*
|
* Note:
|
*
|
* - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
|
* See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
|
*
|
* - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
|
*
|
* - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
|
* incorrect length in some situations.
|
|
* We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
|
* get the Object implementation, which is slower but behaves correctly.
|
*/
|
Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
|
? global.TYPED_ARRAY_SUPPORT
|
: typedArraySupport()
|
|
/*
|
* Export kMaxLength after typed array support is determined.
|
*/
|
exports.kMaxLength = kMaxLength()
|
|
function typedArraySupport () {
|
try {
|
var arr = new Uint8Array(1)
|
arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
|
return arr.foo() === 42 && // typed array instances can be augmented
|
typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
|
arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
|
} catch (e) {
|
return false
|
}
|
}
|
|
function kMaxLength () {
|
return Buffer.TYPED_ARRAY_SUPPORT
|
? 0x7fffffff
|
: 0x3fffffff
|
}
|
|
function createBuffer (that, length) {
|
if (kMaxLength() < length) {
|
throw new RangeError('Invalid typed array length')
|
}
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
// Return an augmented `Uint8Array` instance, for best performance
|
that = new Uint8Array(length)
|
that.__proto__ = Buffer.prototype
|
} else {
|
// Fallback: Return an object instance of the Buffer class
|
if (that === null) {
|
that = new Buffer(length)
|
}
|
that.length = length
|
}
|
|
return that
|
}
|
|
/**
|
* The Buffer constructor returns instances of `Uint8Array` that have their
|
* prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
|
* `Uint8Array`, so the returned instances will have all the node `Buffer` methods
|
* and the `Uint8Array` methods. Square bracket notation works as expected -- it
|
* returns a single octet.
|
*
|
* The `Uint8Array` prototype remains unmodified.
|
*/
|
|
function Buffer (arg, encodingOrOffset, length) {
|
if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
|
return new Buffer(arg, encodingOrOffset, length)
|
}
|
|
// Common case.
|
if (typeof arg === 'number') {
|
if (typeof encodingOrOffset === 'string') {
|
throw new Error(
|
'If encoding is specified then the first argument must be a string'
|
)
|
}
|
return allocUnsafe(this, arg)
|
}
|
return from(this, arg, encodingOrOffset, length)
|
}
|
|
Buffer.poolSize = 8192 // not used by this implementation
|
|
// TODO: Legacy, not needed anymore. Remove in next major version.
|
Buffer._augment = function (arr) {
|
arr.__proto__ = Buffer.prototype
|
return arr
|
}
|
|
function from (that, value, encodingOrOffset, length) {
|
if (typeof value === 'number') {
|
throw new TypeError('"value" argument must not be a number')
|
}
|
|
if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
|
return fromArrayBuffer(that, value, encodingOrOffset, length)
|
}
|
|
if (typeof value === 'string') {
|
return fromString(that, value, encodingOrOffset)
|
}
|
|
return fromObject(that, value)
|
}
|
|
/**
|
* Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
|
* if value is a number.
|
* Buffer.from(str[, encoding])
|
* Buffer.from(array)
|
* Buffer.from(buffer)
|
* Buffer.from(arrayBuffer[, byteOffset[, length]])
|
**/
|
Buffer.from = function (value, encodingOrOffset, length) {
|
return from(null, value, encodingOrOffset, length)
|
}
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
Buffer.prototype.__proto__ = Uint8Array.prototype
|
Buffer.__proto__ = Uint8Array
|
if (typeof Symbol !== 'undefined' && Symbol.species &&
|
Buffer[Symbol.species] === Buffer) {
|
// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
|
Object.defineProperty(Buffer, Symbol.species, {
|
value: null,
|
configurable: true
|
})
|
}
|
}
|
|
function assertSize (size) {
|
if (typeof size !== 'number') {
|
throw new TypeError('"size" argument must be a number')
|
} else if (size < 0) {
|
throw new RangeError('"size" argument must not be negative')
|
}
|
}
|
|
function alloc (that, size, fill, encoding) {
|
assertSize(size)
|
if (size <= 0) {
|
return createBuffer(that, size)
|
}
|
if (fill !== undefined) {
|
// Only pay attention to encoding if it's a string. This
|
// prevents accidentally sending in a number that would
|
// be interpretted as a start offset.
|
return typeof encoding === 'string'
|
? createBuffer(that, size).fill(fill, encoding)
|
: createBuffer(that, size).fill(fill)
|
}
|
return createBuffer(that, size)
|
}
|
|
/**
|
* Creates a new filled Buffer instance.
|
* alloc(size[, fill[, encoding]])
|
**/
|
Buffer.alloc = function (size, fill, encoding) {
|
return alloc(null, size, fill, encoding)
|
}
|
|
function allocUnsafe (that, size) {
|
assertSize(size)
|
that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
|
if (!Buffer.TYPED_ARRAY_SUPPORT) {
|
for (var i = 0; i < size; ++i) {
|
that[i] = 0
|
}
|
}
|
return that
|
}
|
|
/**
|
* Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
|
* */
|
Buffer.allocUnsafe = function (size) {
|
return allocUnsafe(null, size)
|
}
|
/**
|
* Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
*/
|
Buffer.allocUnsafeSlow = function (size) {
|
return allocUnsafe(null, size)
|
}
|
|
function fromString (that, string, encoding) {
|
if (typeof encoding !== 'string' || encoding === '') {
|
encoding = 'utf8'
|
}
|
|
if (!Buffer.isEncoding(encoding)) {
|
throw new TypeError('"encoding" must be a valid string encoding')
|
}
|
|
var length = byteLength(string, encoding) | 0
|
that = createBuffer(that, length)
|
|
var actual = that.write(string, encoding)
|
|
if (actual !== length) {
|
// Writing a hex string, for example, that contains invalid characters will
|
// cause everything after the first invalid character to be ignored. (e.g.
|
// 'abxxcd' will be treated as 'ab')
|
that = that.slice(0, actual)
|
}
|
|
return that
|
}
|
|
function fromArrayLike (that, array) {
|
var length = array.length < 0 ? 0 : checked(array.length) | 0
|
that = createBuffer(that, length)
|
for (var i = 0; i < length; i += 1) {
|
that[i] = array[i] & 255
|
}
|
return that
|
}
|
|
function fromArrayBuffer (that, array, byteOffset, length) {
|
array.byteLength // this throws if `array` is not a valid ArrayBuffer
|
|
if (byteOffset < 0 || array.byteLength < byteOffset) {
|
throw new RangeError('\'offset\' is out of bounds')
|
}
|
|
if (array.byteLength < byteOffset + (length || 0)) {
|
throw new RangeError('\'length\' is out of bounds')
|
}
|
|
if (byteOffset === undefined && length === undefined) {
|
array = new Uint8Array(array)
|
} else if (length === undefined) {
|
array = new Uint8Array(array, byteOffset)
|
} else {
|
array = new Uint8Array(array, byteOffset, length)
|
}
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
// Return an augmented `Uint8Array` instance, for best performance
|
that = array
|
that.__proto__ = Buffer.prototype
|
} else {
|
// Fallback: Return an object instance of the Buffer class
|
that = fromArrayLike(that, array)
|
}
|
return that
|
}
|
|
function fromObject (that, obj) {
|
if (Buffer.isBuffer(obj)) {
|
var len = checked(obj.length) | 0
|
that = createBuffer(that, len)
|
|
if (that.length === 0) {
|
return that
|
}
|
|
obj.copy(that, 0, 0, len)
|
return that
|
}
|
|
if (obj) {
|
if ((typeof ArrayBuffer !== 'undefined' &&
|
obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
|
if (typeof obj.length !== 'number' || isnan(obj.length)) {
|
return createBuffer(that, 0)
|
}
|
return fromArrayLike(that, obj)
|
}
|
|
if (obj.type === 'Buffer' && isArray(obj.data)) {
|
return fromArrayLike(that, obj.data)
|
}
|
}
|
|
throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
|
}
|
|
function checked (length) {
|
// Note: cannot use `length < kMaxLength()` here because that fails when
|
// length is NaN (which is otherwise coerced to zero.)
|
if (length >= kMaxLength()) {
|
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
|
'size: 0x' + kMaxLength().toString(16) + ' bytes')
|
}
|
return length | 0
|
}
|
|
function SlowBuffer (length) {
|
if (+length != length) { // eslint-disable-line eqeqeq
|
length = 0
|
}
|
return Buffer.alloc(+length)
|
}
|
|
Buffer.isBuffer = function isBuffer (b) {
|
return !!(b != null && b._isBuffer)
|
}
|
|
Buffer.compare = function compare (a, b) {
|
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
throw new TypeError('Arguments must be Buffers')
|
}
|
|
if (a === b) return 0
|
|
var x = a.length
|
var y = b.length
|
|
for (var i = 0, len = Math.min(x, y); i < len; ++i) {
|
if (a[i] !== b[i]) {
|
x = a[i]
|
y = b[i]
|
break
|
}
|
}
|
|
if (x < y) return -1
|
if (y < x) return 1
|
return 0
|
}
|
|
Buffer.isEncoding = function isEncoding (encoding) {
|
switch (String(encoding).toLowerCase()) {
|
case 'hex':
|
case 'utf8':
|
case 'utf-8':
|
case 'ascii':
|
case 'latin1':
|
case 'binary':
|
case 'base64':
|
case 'ucs2':
|
case 'ucs-2':
|
case 'utf16le':
|
case 'utf-16le':
|
return true
|
default:
|
return false
|
}
|
}
|
|
Buffer.concat = function concat (list, length) {
|
if (!isArray(list)) {
|
throw new TypeError('"list" argument must be an Array of Buffers')
|
}
|
|
if (list.length === 0) {
|
return Buffer.alloc(0)
|
}
|
|
var i
|
if (length === undefined) {
|
length = 0
|
for (i = 0; i < list.length; ++i) {
|
length += list[i].length
|
}
|
}
|
|
var buffer = Buffer.allocUnsafe(length)
|
var pos = 0
|
for (i = 0; i < list.length; ++i) {
|
var buf = list[i]
|
if (!Buffer.isBuffer(buf)) {
|
throw new TypeError('"list" argument must be an Array of Buffers')
|
}
|
buf.copy(buffer, pos)
|
pos += buf.length
|
}
|
return buffer
|
}
|
|
function byteLength (string, encoding) {
|
if (Buffer.isBuffer(string)) {
|
return string.length
|
}
|
if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
|
(ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
|
return string.byteLength
|
}
|
if (typeof string !== 'string') {
|
string = '' + string
|
}
|
|
var len = string.length
|
if (len === 0) return 0
|
|
// Use a for loop to avoid recursion
|
var loweredCase = false
|
for (;;) {
|
switch (encoding) {
|
case 'ascii':
|
case 'latin1':
|
case 'binary':
|
return len
|
case 'utf8':
|
case 'utf-8':
|
case undefined:
|
return utf8ToBytes(string).length
|
case 'ucs2':
|
case 'ucs-2':
|
case 'utf16le':
|
case 'utf-16le':
|
return len * 2
|
case 'hex':
|
return len >>> 1
|
case 'base64':
|
return base64ToBytes(string).length
|
default:
|
if (loweredCase) return utf8ToBytes(string).length // assume utf8
|
encoding = ('' + encoding).toLowerCase()
|
loweredCase = true
|
}
|
}
|
}
|
Buffer.byteLength = byteLength
|
|
function slowToString (encoding, start, end) {
|
var loweredCase = false
|
|
// No need to verify that "this.length <= MAX_UINT32" since it's a read-only
|
// property of a typed array.
|
|
// This behaves neither like String nor Uint8Array in that we set start/end
|
// to their upper/lower bounds if the value passed is out of range.
|
// undefined is handled specially as per ECMA-262 6th Edition,
|
// Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
|
if (start === undefined || start < 0) {
|
start = 0
|
}
|
// Return early if start > this.length. Done here to prevent potential uint32
|
// coercion fail below.
|
if (start > this.length) {
|
return ''
|
}
|
|
if (end === undefined || end > this.length) {
|
end = this.length
|
}
|
|
if (end <= 0) {
|
return ''
|
}
|
|
// Force coersion to uint32. This will also coerce falsey/NaN values to 0.
|
end >>>= 0
|
start >>>= 0
|
|
if (end <= start) {
|
return ''
|
}
|
|
if (!encoding) encoding = 'utf8'
|
|
while (true) {
|
switch (encoding) {
|
case 'hex':
|
return hexSlice(this, start, end)
|
|
case 'utf8':
|
case 'utf-8':
|
return utf8Slice(this, start, end)
|
|
case 'ascii':
|
return asciiSlice(this, start, end)
|
|
case 'latin1':
|
case 'binary':
|
return latin1Slice(this, start, end)
|
|
case 'base64':
|
return base64Slice(this, start, end)
|
|
case 'ucs2':
|
case 'ucs-2':
|
case 'utf16le':
|
case 'utf-16le':
|
return utf16leSlice(this, start, end)
|
|
default:
|
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
encoding = (encoding + '').toLowerCase()
|
loweredCase = true
|
}
|
}
|
}
|
|
// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
|
// Buffer instances.
|
Buffer.prototype._isBuffer = true
|
|
function swap (b, n, m) {
|
var i = b[n]
|
b[n] = b[m]
|
b[m] = i
|
}
|
|
Buffer.prototype.swap16 = function swap16 () {
|
var len = this.length
|
if (len % 2 !== 0) {
|
throw new RangeError('Buffer size must be a multiple of 16-bits')
|
}
|
for (var i = 0; i < len; i += 2) {
|
swap(this, i, i + 1)
|
}
|
return this
|
}
|
|
Buffer.prototype.swap32 = function swap32 () {
|
var len = this.length
|
if (len % 4 !== 0) {
|
throw new RangeError('Buffer size must be a multiple of 32-bits')
|
}
|
for (var i = 0; i < len; i += 4) {
|
swap(this, i, i + 3)
|
swap(this, i + 1, i + 2)
|
}
|
return this
|
}
|
|
Buffer.prototype.swap64 = function swap64 () {
|
var len = this.length
|
if (len % 8 !== 0) {
|
throw new RangeError('Buffer size must be a multiple of 64-bits')
|
}
|
for (var i = 0; i < len; i += 8) {
|
swap(this, i, i + 7)
|
swap(this, i + 1, i + 6)
|
swap(this, i + 2, i + 5)
|
swap(this, i + 3, i + 4)
|
}
|
return this
|
}
|
|
Buffer.prototype.toString = function toString () {
|
var length = this.length | 0
|
if (length === 0) return ''
|
if (arguments.length === 0) return utf8Slice(this, 0, length)
|
return slowToString.apply(this, arguments)
|
}
|
|
Buffer.prototype.equals = function equals (b) {
|
if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
|
if (this === b) return true
|
return Buffer.compare(this, b) === 0
|
}
|
|
Buffer.prototype.inspect = function inspect () {
|
var str = ''
|
var max = exports.INSPECT_MAX_BYTES
|
if (this.length > 0) {
|
str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
|
if (this.length > max) str += ' ... '
|
}
|
return '<Buffer ' + str + '>'
|
}
|
|
Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
|
if (!Buffer.isBuffer(target)) {
|
throw new TypeError('Argument must be a Buffer')
|
}
|
|
if (start === undefined) {
|
start = 0
|
}
|
if (end === undefined) {
|
end = target ? target.length : 0
|
}
|
if (thisStart === undefined) {
|
thisStart = 0
|
}
|
if (thisEnd === undefined) {
|
thisEnd = this.length
|
}
|
|
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
|
throw new RangeError('out of range index')
|
}
|
|
if (thisStart >= thisEnd && start >= end) {
|
return 0
|
}
|
if (thisStart >= thisEnd) {
|
return -1
|
}
|
if (start >= end) {
|
return 1
|
}
|
|
start >>>= 0
|
end >>>= 0
|
thisStart >>>= 0
|
thisEnd >>>= 0
|
|
if (this === target) return 0
|
|
var x = thisEnd - thisStart
|
var y = end - start
|
var len = Math.min(x, y)
|
|
var thisCopy = this.slice(thisStart, thisEnd)
|
var targetCopy = target.slice(start, end)
|
|
for (var i = 0; i < len; ++i) {
|
if (thisCopy[i] !== targetCopy[i]) {
|
x = thisCopy[i]
|
y = targetCopy[i]
|
break
|
}
|
}
|
|
if (x < y) return -1
|
if (y < x) return 1
|
return 0
|
}
|
|
// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
|
// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
|
//
|
// Arguments:
|
// - buffer - a Buffer to search
|
// - val - a string, Buffer, or number
|
// - byteOffset - an index into `buffer`; will be clamped to an int32
|
// - encoding - an optional encoding, relevant is val is a string
|
// - dir - true for indexOf, false for lastIndexOf
|
function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
|
// Empty buffer means no match
|
if (buffer.length === 0) return -1
|
|
// Normalize byteOffset
|
if (typeof byteOffset === 'string') {
|
encoding = byteOffset
|
byteOffset = 0
|
} else if (byteOffset > 0x7fffffff) {
|
byteOffset = 0x7fffffff
|
} else if (byteOffset < -0x80000000) {
|
byteOffset = -0x80000000
|
}
|
byteOffset = +byteOffset // Coerce to Number.
|
if (isNaN(byteOffset)) {
|
// byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
|
byteOffset = dir ? 0 : (buffer.length - 1)
|
}
|
|
// Normalize byteOffset: negative offsets start from the end of the buffer
|
if (byteOffset < 0) byteOffset = buffer.length + byteOffset
|
if (byteOffset >= buffer.length) {
|
if (dir) return -1
|
else byteOffset = buffer.length - 1
|
} else if (byteOffset < 0) {
|
if (dir) byteOffset = 0
|
else return -1
|
}
|
|
// Normalize val
|
if (typeof val === 'string') {
|
val = Buffer.from(val, encoding)
|
}
|
|
// Finally, search either indexOf (if dir is true) or lastIndexOf
|
if (Buffer.isBuffer(val)) {
|
// Special case: looking for empty string/buffer always fails
|
if (val.length === 0) {
|
return -1
|
}
|
return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
|
} else if (typeof val === 'number') {
|
val = val & 0xFF // Search for a byte value [0-255]
|
if (Buffer.TYPED_ARRAY_SUPPORT &&
|
typeof Uint8Array.prototype.indexOf === 'function') {
|
if (dir) {
|
return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
|
} else {
|
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
|
}
|
}
|
return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
|
}
|
|
throw new TypeError('val must be string, number or Buffer')
|
}
|
|
function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
|
var indexSize = 1
|
var arrLength = arr.length
|
var valLength = val.length
|
|
if (encoding !== undefined) {
|
encoding = String(encoding).toLowerCase()
|
if (encoding === 'ucs2' || encoding === 'ucs-2' ||
|
encoding === 'utf16le' || encoding === 'utf-16le') {
|
if (arr.length < 2 || val.length < 2) {
|
return -1
|
}
|
indexSize = 2
|
arrLength /= 2
|
valLength /= 2
|
byteOffset /= 2
|
}
|
}
|
|
function read (buf, i) {
|
if (indexSize === 1) {
|
return buf[i]
|
} else {
|
return buf.readUInt16BE(i * indexSize)
|
}
|
}
|
|
var i
|
if (dir) {
|
var foundIndex = -1
|
for (i = byteOffset; i < arrLength; i++) {
|
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
if (foundIndex === -1) foundIndex = i
|
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
|
} else {
|
if (foundIndex !== -1) i -= i - foundIndex
|
foundIndex = -1
|
}
|
}
|
} else {
|
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
|
for (i = byteOffset; i >= 0; i--) {
|
var found = true
|
for (var j = 0; j < valLength; j++) {
|
if (read(arr, i + j) !== read(val, j)) {
|
found = false
|
break
|
}
|
}
|
if (found) return i
|
}
|
}
|
|
return -1
|
}
|
|
Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
|
return this.indexOf(val, byteOffset, encoding) !== -1
|
}
|
|
Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
|
return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
|
}
|
|
Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
|
return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
|
}
|
|
function hexWrite (buf, string, offset, length) {
|
offset = Number(offset) || 0
|
var remaining = buf.length - offset
|
if (!length) {
|
length = remaining
|
} else {
|
length = Number(length)
|
if (length > remaining) {
|
length = remaining
|
}
|
}
|
|
// must be an even number of digits
|
var strLen = string.length
|
if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
|
|
if (length > strLen / 2) {
|
length = strLen / 2
|
}
|
for (var i = 0; i < length; ++i) {
|
var parsed = parseInt(string.substr(i * 2, 2), 16)
|
if (isNaN(parsed)) return i
|
buf[offset + i] = parsed
|
}
|
return i
|
}
|
|
function utf8Write (buf, string, offset, length) {
|
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
|
}
|
|
function asciiWrite (buf, string, offset, length) {
|
return blitBuffer(asciiToBytes(string), buf, offset, length)
|
}
|
|
function latin1Write (buf, string, offset, length) {
|
return asciiWrite(buf, string, offset, length)
|
}
|
|
function base64Write (buf, string, offset, length) {
|
return blitBuffer(base64ToBytes(string), buf, offset, length)
|
}
|
|
function ucs2Write (buf, string, offset, length) {
|
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
|
}
|
|
Buffer.prototype.write = function write (string, offset, length, encoding) {
|
// Buffer#write(string)
|
if (offset === undefined) {
|
encoding = 'utf8'
|
length = this.length
|
offset = 0
|
// Buffer#write(string, encoding)
|
} else if (length === undefined && typeof offset === 'string') {
|
encoding = offset
|
length = this.length
|
offset = 0
|
// Buffer#write(string, offset[, length][, encoding])
|
} else if (isFinite(offset)) {
|
offset = offset | 0
|
if (isFinite(length)) {
|
length = length | 0
|
if (encoding === undefined) encoding = 'utf8'
|
} else {
|
encoding = length
|
length = undefined
|
}
|
// legacy write(string, encoding, offset, length) - remove in v0.13
|
} else {
|
throw new Error(
|
'Buffer.write(string, encoding, offset[, length]) is no longer supported'
|
)
|
}
|
|
var remaining = this.length - offset
|
if (length === undefined || length > remaining) length = remaining
|
|
if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
|
throw new RangeError('Attempt to write outside buffer bounds')
|
}
|
|
if (!encoding) encoding = 'utf8'
|
|
var loweredCase = false
|
for (;;) {
|
switch (encoding) {
|
case 'hex':
|
return hexWrite(this, string, offset, length)
|
|
case 'utf8':
|
case 'utf-8':
|
return utf8Write(this, string, offset, length)
|
|
case 'ascii':
|
return asciiWrite(this, string, offset, length)
|
|
case 'latin1':
|
case 'binary':
|
return latin1Write(this, string, offset, length)
|
|
case 'base64':
|
// Warning: maxLength not taken into account in base64Write
|
return base64Write(this, string, offset, length)
|
|
case 'ucs2':
|
case 'ucs-2':
|
case 'utf16le':
|
case 'utf-16le':
|
return ucs2Write(this, string, offset, length)
|
|
default:
|
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
encoding = ('' + encoding).toLowerCase()
|
loweredCase = true
|
}
|
}
|
}
|
|
Buffer.prototype.toJSON = function toJSON () {
|
return {
|
type: 'Buffer',
|
data: Array.prototype.slice.call(this._arr || this, 0)
|
}
|
}
|
|
function base64Slice (buf, start, end) {
|
if (start === 0 && end === buf.length) {
|
return base64.fromByteArray(buf)
|
} else {
|
return base64.fromByteArray(buf.slice(start, end))
|
}
|
}
|
|
function utf8Slice (buf, start, end) {
|
end = Math.min(buf.length, end)
|
var res = []
|
|
var i = start
|
while (i < end) {
|
var firstByte = buf[i]
|
var codePoint = null
|
var bytesPerSequence = (firstByte > 0xEF) ? 4
|
: (firstByte > 0xDF) ? 3
|
: (firstByte > 0xBF) ? 2
|
: 1
|
|
if (i + bytesPerSequence <= end) {
|
var secondByte, thirdByte, fourthByte, tempCodePoint
|
|
switch (bytesPerSequence) {
|
case 1:
|
if (firstByte < 0x80) {
|
codePoint = firstByte
|
}
|
break
|
case 2:
|
secondByte = buf[i + 1]
|
if ((secondByte & 0xC0) === 0x80) {
|
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
|
if (tempCodePoint > 0x7F) {
|
codePoint = tempCodePoint
|
}
|
}
|
break
|
case 3:
|
secondByte = buf[i + 1]
|
thirdByte = buf[i + 2]
|
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
|
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
|
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
|
codePoint = tempCodePoint
|
}
|
}
|
break
|
case 4:
|
secondByte = buf[i + 1]
|
thirdByte = buf[i + 2]
|
fourthByte = buf[i + 3]
|
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
|
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
|
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
|
codePoint = tempCodePoint
|
}
|
}
|
}
|
}
|
|
if (codePoint === null) {
|
// we did not generate a valid codePoint so insert a
|
// replacement char (U+FFFD) and advance only 1 byte
|
codePoint = 0xFFFD
|
bytesPerSequence = 1
|
} else if (codePoint > 0xFFFF) {
|
// encode to utf16 (surrogate pair dance)
|
codePoint -= 0x10000
|
res.push(codePoint >>> 10 & 0x3FF | 0xD800)
|
codePoint = 0xDC00 | codePoint & 0x3FF
|
}
|
|
res.push(codePoint)
|
i += bytesPerSequence
|
}
|
|
return decodeCodePointsArray(res)
|
}
|
|
// Based on http://stackoverflow.com/a/22747272/680742, the browser with
|
// the lowest limit is Chrome, with 0x10000 args.
|
// We go 1 magnitude less, for safety
|
var MAX_ARGUMENTS_LENGTH = 0x1000
|
|
function decodeCodePointsArray (codePoints) {
|
var len = codePoints.length
|
if (len <= MAX_ARGUMENTS_LENGTH) {
|
return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
|
}
|
|
// Decode in chunks to avoid "call stack size exceeded".
|
var res = ''
|
var i = 0
|
while (i < len) {
|
res += String.fromCharCode.apply(
|
String,
|
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
)
|
}
|
return res
|
}
|
|
function asciiSlice (buf, start, end) {
|
var ret = ''
|
end = Math.min(buf.length, end)
|
|
for (var i = start; i < end; ++i) {
|
ret += String.fromCharCode(buf[i] & 0x7F)
|
}
|
return ret
|
}
|
|
function latin1Slice (buf, start, end) {
|
var ret = ''
|
end = Math.min(buf.length, end)
|
|
for (var i = start; i < end; ++i) {
|
ret += String.fromCharCode(buf[i])
|
}
|
return ret
|
}
|
|
function hexSlice (buf, start, end) {
|
var len = buf.length
|
|
if (!start || start < 0) start = 0
|
if (!end || end < 0 || end > len) end = len
|
|
var out = ''
|
for (var i = start; i < end; ++i) {
|
out += toHex(buf[i])
|
}
|
return out
|
}
|
|
function utf16leSlice (buf, start, end) {
|
var bytes = buf.slice(start, end)
|
var res = ''
|
for (var i = 0; i < bytes.length; i += 2) {
|
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
|
}
|
return res
|
}
|
|
Buffer.prototype.slice = function slice (start, end) {
|
var len = this.length
|
start = ~~start
|
end = end === undefined ? len : ~~end
|
|
if (start < 0) {
|
start += len
|
if (start < 0) start = 0
|
} else if (start > len) {
|
start = len
|
}
|
|
if (end < 0) {
|
end += len
|
if (end < 0) end = 0
|
} else if (end > len) {
|
end = len
|
}
|
|
if (end < start) end = start
|
|
var newBuf
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
newBuf = this.subarray(start, end)
|
newBuf.__proto__ = Buffer.prototype
|
} else {
|
var sliceLen = end - start
|
newBuf = new Buffer(sliceLen, undefined)
|
for (var i = 0; i < sliceLen; ++i) {
|
newBuf[i] = this[i + start]
|
}
|
}
|
|
return newBuf
|
}
|
|
/*
|
* Need to make sure that buffer isn't trying to write out of bounds.
|
*/
|
function checkOffset (offset, ext, length) {
|
if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
|
if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
|
}
|
|
Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
|
offset = offset | 0
|
byteLength = byteLength | 0
|
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
|
var val = this[offset]
|
var mul = 1
|
var i = 0
|
while (++i < byteLength && (mul *= 0x100)) {
|
val += this[offset + i] * mul
|
}
|
|
return val
|
}
|
|
Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
|
offset = offset | 0
|
byteLength = byteLength | 0
|
if (!noAssert) {
|
checkOffset(offset, byteLength, this.length)
|
}
|
|
var val = this[offset + --byteLength]
|
var mul = 1
|
while (byteLength > 0 && (mul *= 0x100)) {
|
val += this[offset + --byteLength] * mul
|
}
|
|
return val
|
}
|
|
Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
|
if (!noAssert) checkOffset(offset, 1, this.length)
|
return this[offset]
|
}
|
|
Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
|
if (!noAssert) checkOffset(offset, 2, this.length)
|
return this[offset] | (this[offset + 1] << 8)
|
}
|
|
Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
|
if (!noAssert) checkOffset(offset, 2, this.length)
|
return (this[offset] << 8) | this[offset + 1]
|
}
|
|
Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
|
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
return ((this[offset]) |
|
(this[offset + 1] << 8) |
|
(this[offset + 2] << 16)) +
|
(this[offset + 3] * 0x1000000)
|
}
|
|
Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
|
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
return (this[offset] * 0x1000000) +
|
((this[offset + 1] << 16) |
|
(this[offset + 2] << 8) |
|
this[offset + 3])
|
}
|
|
Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
|
offset = offset | 0
|
byteLength = byteLength | 0
|
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
|
var val = this[offset]
|
var mul = 1
|
var i = 0
|
while (++i < byteLength && (mul *= 0x100)) {
|
val += this[offset + i] * mul
|
}
|
mul *= 0x80
|
|
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
|
return val
|
}
|
|
Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
|
offset = offset | 0
|
byteLength = byteLength | 0
|
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
|
var i = byteLength
|
var mul = 1
|
var val = this[offset + --i]
|
while (i > 0 && (mul *= 0x100)) {
|
val += this[offset + --i] * mul
|
}
|
mul *= 0x80
|
|
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
|
return val
|
}
|
|
Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
|
if (!noAssert) checkOffset(offset, 1, this.length)
|
if (!(this[offset] & 0x80)) return (this[offset])
|
return ((0xff - this[offset] + 1) * -1)
|
}
|
|
Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
|
if (!noAssert) checkOffset(offset, 2, this.length)
|
var val = this[offset] | (this[offset + 1] << 8)
|
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
}
|
|
Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
|
if (!noAssert) checkOffset(offset, 2, this.length)
|
var val = this[offset + 1] | (this[offset] << 8)
|
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
}
|
|
Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
|
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
return (this[offset]) |
|
(this[offset + 1] << 8) |
|
(this[offset + 2] << 16) |
|
(this[offset + 3] << 24)
|
}
|
|
Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
|
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
return (this[offset] << 24) |
|
(this[offset + 1] << 16) |
|
(this[offset + 2] << 8) |
|
(this[offset + 3])
|
}
|
|
Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
|
if (!noAssert) checkOffset(offset, 4, this.length)
|
return ieee754.read(this, offset, true, 23, 4)
|
}
|
|
Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
|
if (!noAssert) checkOffset(offset, 4, this.length)
|
return ieee754.read(this, offset, false, 23, 4)
|
}
|
|
Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
|
if (!noAssert) checkOffset(offset, 8, this.length)
|
return ieee754.read(this, offset, true, 52, 8)
|
}
|
|
Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
|
if (!noAssert) checkOffset(offset, 8, this.length)
|
return ieee754.read(this, offset, false, 52, 8)
|
}
|
|
function checkInt (buf, value, offset, ext, max, min) {
|
if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
|
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
|
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
}
|
|
Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
|
value = +value
|
offset = offset | 0
|
byteLength = byteLength | 0
|
if (!noAssert) {
|
var maxBytes = Math.pow(2, 8 * byteLength) - 1
|
checkInt(this, value, offset, byteLength, maxBytes, 0)
|
}
|
|
var mul = 1
|
var i = 0
|
this[offset] = value & 0xFF
|
while (++i < byteLength && (mul *= 0x100)) {
|
this[offset + i] = (value / mul) & 0xFF
|
}
|
|
return offset + byteLength
|
}
|
|
Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
|
value = +value
|
offset = offset | 0
|
byteLength = byteLength | 0
|
if (!noAssert) {
|
var maxBytes = Math.pow(2, 8 * byteLength) - 1
|
checkInt(this, value, offset, byteLength, maxBytes, 0)
|
}
|
|
var i = byteLength - 1
|
var mul = 1
|
this[offset + i] = value & 0xFF
|
while (--i >= 0 && (mul *= 0x100)) {
|
this[offset + i] = (value / mul) & 0xFF
|
}
|
|
return offset + byteLength
|
}
|
|
Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
|
value = +value
|
offset = offset | 0
|
if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
|
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
|
this[offset] = (value & 0xff)
|
return offset + 1
|
}
|
|
function objectWriteUInt16 (buf, value, offset, littleEndian) {
|
if (value < 0) value = 0xffff + value + 1
|
for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
|
buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
|
(littleEndian ? i : 1 - i) * 8
|
}
|
}
|
|
Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
|
value = +value
|
offset = offset | 0
|
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
this[offset] = (value & 0xff)
|
this[offset + 1] = (value >>> 8)
|
} else {
|
objectWriteUInt16(this, value, offset, true)
|
}
|
return offset + 2
|
}
|
|
Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
|
value = +value
|
offset = offset | 0
|
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
this[offset] = (value >>> 8)
|
this[offset + 1] = (value & 0xff)
|
} else {
|
objectWriteUInt16(this, value, offset, false)
|
}
|
return offset + 2
|
}
|
|
function objectWriteUInt32 (buf, value, offset, littleEndian) {
|
if (value < 0) value = 0xffffffff + value + 1
|
for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
|
buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
|
}
|
}
|
|
Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
|
value = +value
|
offset = offset | 0
|
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
this[offset + 3] = (value >>> 24)
|
this[offset + 2] = (value >>> 16)
|
this[offset + 1] = (value >>> 8)
|
this[offset] = (value & 0xff)
|
} else {
|
objectWriteUInt32(this, value, offset, true)
|
}
|
return offset + 4
|
}
|
|
Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
|
value = +value
|
offset = offset | 0
|
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
this[offset] = (value >>> 24)
|
this[offset + 1] = (value >>> 16)
|
this[offset + 2] = (value >>> 8)
|
this[offset + 3] = (value & 0xff)
|
} else {
|
objectWriteUInt32(this, value, offset, false)
|
}
|
return offset + 4
|
}
|
|
Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
|
value = +value
|
offset = offset | 0
|
if (!noAssert) {
|
var limit = Math.pow(2, 8 * byteLength - 1)
|
|
checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
}
|
|
var i = 0
|
var mul = 1
|
var sub = 0
|
this[offset] = value & 0xFF
|
while (++i < byteLength && (mul *= 0x100)) {
|
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
sub = 1
|
}
|
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
|
}
|
|
return offset + byteLength
|
}
|
|
Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
|
value = +value
|
offset = offset | 0
|
if (!noAssert) {
|
var limit = Math.pow(2, 8 * byteLength - 1)
|
|
checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
}
|
|
var i = byteLength - 1
|
var mul = 1
|
var sub = 0
|
this[offset + i] = value & 0xFF
|
while (--i >= 0 && (mul *= 0x100)) {
|
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
sub = 1
|
}
|
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
|
}
|
|
return offset + byteLength
|
}
|
|
Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
|
value = +value
|
offset = offset | 0
|
if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
|
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
|
if (value < 0) value = 0xff + value + 1
|
this[offset] = (value & 0xff)
|
return offset + 1
|
}
|
|
Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
|
value = +value
|
offset = offset | 0
|
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
this[offset] = (value & 0xff)
|
this[offset + 1] = (value >>> 8)
|
} else {
|
objectWriteUInt16(this, value, offset, true)
|
}
|
return offset + 2
|
}
|
|
Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
|
value = +value
|
offset = offset | 0
|
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
this[offset] = (value >>> 8)
|
this[offset + 1] = (value & 0xff)
|
} else {
|
objectWriteUInt16(this, value, offset, false)
|
}
|
return offset + 2
|
}
|
|
Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
|
value = +value
|
offset = offset | 0
|
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
this[offset] = (value & 0xff)
|
this[offset + 1] = (value >>> 8)
|
this[offset + 2] = (value >>> 16)
|
this[offset + 3] = (value >>> 24)
|
} else {
|
objectWriteUInt32(this, value, offset, true)
|
}
|
return offset + 4
|
}
|
|
Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
|
value = +value
|
offset = offset | 0
|
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
if (value < 0) value = 0xffffffff + value + 1
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
this[offset] = (value >>> 24)
|
this[offset + 1] = (value >>> 16)
|
this[offset + 2] = (value >>> 8)
|
this[offset + 3] = (value & 0xff)
|
} else {
|
objectWriteUInt32(this, value, offset, false)
|
}
|
return offset + 4
|
}
|
|
function checkIEEE754 (buf, value, offset, ext, max, min) {
|
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
if (offset < 0) throw new RangeError('Index out of range')
|
}
|
|
function writeFloat (buf, value, offset, littleEndian, noAssert) {
|
if (!noAssert) {
|
checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
|
}
|
ieee754.write(buf, value, offset, littleEndian, 23, 4)
|
return offset + 4
|
}
|
|
Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
|
return writeFloat(this, value, offset, true, noAssert)
|
}
|
|
Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
|
return writeFloat(this, value, offset, false, noAssert)
|
}
|
|
function writeDouble (buf, value, offset, littleEndian, noAssert) {
|
if (!noAssert) {
|
checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
|
}
|
ieee754.write(buf, value, offset, littleEndian, 52, 8)
|
return offset + 8
|
}
|
|
Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
|
return writeDouble(this, value, offset, true, noAssert)
|
}
|
|
Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
|
return writeDouble(this, value, offset, false, noAssert)
|
}
|
|
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
|
Buffer.prototype.copy = function copy (target, targetStart, start, end) {
|
if (!start) start = 0
|
if (!end && end !== 0) end = this.length
|
if (targetStart >= target.length) targetStart = target.length
|
if (!targetStart) targetStart = 0
|
if (end > 0 && end < start) end = start
|
|
// Copy 0 bytes; we're done
|
if (end === start) return 0
|
if (target.length === 0 || this.length === 0) return 0
|
|
// Fatal error conditions
|
if (targetStart < 0) {
|
throw new RangeError('targetStart out of bounds')
|
}
|
if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
|
if (end < 0) throw new RangeError('sourceEnd out of bounds')
|
|
// Are we oob?
|
if (end > this.length) end = this.length
|
if (target.length - targetStart < end - start) {
|
end = target.length - targetStart + start
|
}
|
|
var len = end - start
|
var i
|
|
if (this === target && start < targetStart && targetStart < end) {
|
// descending copy from end
|
for (i = len - 1; i >= 0; --i) {
|
target[i + targetStart] = this[i + start]
|
}
|
} else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
|
// ascending copy from start
|
for (i = 0; i < len; ++i) {
|
target[i + targetStart] = this[i + start]
|
}
|
} else {
|
Uint8Array.prototype.set.call(
|
target,
|
this.subarray(start, start + len),
|
targetStart
|
)
|
}
|
|
return len
|
}
|
|
// Usage:
|
// buffer.fill(number[, offset[, end]])
|
// buffer.fill(buffer[, offset[, end]])
|
// buffer.fill(string[, offset[, end]][, encoding])
|
Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
// Handle string cases:
|
if (typeof val === 'string') {
|
if (typeof start === 'string') {
|
encoding = start
|
start = 0
|
end = this.length
|
} else if (typeof end === 'string') {
|
encoding = end
|
end = this.length
|
}
|
if (val.length === 1) {
|
var code = val.charCodeAt(0)
|
if (code < 256) {
|
val = code
|
}
|
}
|
if (encoding !== undefined && typeof encoding !== 'string') {
|
throw new TypeError('encoding must be a string')
|
}
|
if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
|
throw new TypeError('Unknown encoding: ' + encoding)
|
}
|
} else if (typeof val === 'number') {
|
val = val & 255
|
}
|
|
// Invalid ranges are not set to a default, so can range check early.
|
if (start < 0 || this.length < start || this.length < end) {
|
throw new RangeError('Out of range index')
|
}
|
|
if (end <= start) {
|
return this
|
}
|
|
start = start >>> 0
|
end = end === undefined ? this.length : end >>> 0
|
|
if (!val) val = 0
|
|
var i
|
if (typeof val === 'number') {
|
for (i = start; i < end; ++i) {
|
this[i] = val
|
}
|
} else {
|
var bytes = Buffer.isBuffer(val)
|
? val
|
: utf8ToBytes(new Buffer(val, encoding).toString())
|
var len = bytes.length
|
for (i = 0; i < end - start; ++i) {
|
this[i + start] = bytes[i % len]
|
}
|
}
|
|
return this
|
}
|
|
// HELPER FUNCTIONS
|
// ================
|
|
var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
|
|
function base64clean (str) {
|
// Node strips out invalid characters like \n and \t from the string, base64-js does not
|
str = stringtrim(str).replace(INVALID_BASE64_RE, '')
|
// Node converts strings with length < 2 to ''
|
if (str.length < 2) return ''
|
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
|
while (str.length % 4 !== 0) {
|
str = str + '='
|
}
|
return str
|
}
|
|
function stringtrim (str) {
|
if (str.trim) return str.trim()
|
return str.replace(/^\s+|\s+$/g, '')
|
}
|
|
function toHex (n) {
|
if (n < 16) return '0' + n.toString(16)
|
return n.toString(16)
|
}
|
|
function utf8ToBytes (string, units) {
|
units = units || Infinity
|
var codePoint
|
var length = string.length
|
var leadSurrogate = null
|
var bytes = []
|
|
for (var i = 0; i < length; ++i) {
|
codePoint = string.charCodeAt(i)
|
|
// is surrogate component
|
if (codePoint > 0xD7FF && codePoint < 0xE000) {
|
// last char was a lead
|
if (!leadSurrogate) {
|
// no lead yet
|
if (codePoint > 0xDBFF) {
|
// unexpected trail
|
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
continue
|
} else if (i + 1 === length) {
|
// unpaired lead
|
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
continue
|
}
|
|
// valid lead
|
leadSurrogate = codePoint
|
|
continue
|
}
|
|
// 2 leads in a row
|
if (codePoint < 0xDC00) {
|
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
leadSurrogate = codePoint
|
continue
|
}
|
|
// valid surrogate pair
|
codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
|
} else if (leadSurrogate) {
|
// valid bmp char, but last char was a lead
|
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
}
|
|
leadSurrogate = null
|
|
// encode utf8
|
if (codePoint < 0x80) {
|
if ((units -= 1) < 0) break
|
bytes.push(codePoint)
|
} else if (codePoint < 0x800) {
|
if ((units -= 2) < 0) break
|
bytes.push(
|
codePoint >> 0x6 | 0xC0,
|
codePoint & 0x3F | 0x80
|
)
|
} else if (codePoint < 0x10000) {
|
if ((units -= 3) < 0) break
|
bytes.push(
|
codePoint >> 0xC | 0xE0,
|
codePoint >> 0x6 & 0x3F | 0x80,
|
codePoint & 0x3F | 0x80
|
)
|
} else if (codePoint < 0x110000) {
|
if ((units -= 4) < 0) break
|
bytes.push(
|
codePoint >> 0x12 | 0xF0,
|
codePoint >> 0xC & 0x3F | 0x80,
|
codePoint >> 0x6 & 0x3F | 0x80,
|
codePoint & 0x3F | 0x80
|
)
|
} else {
|
throw new Error('Invalid code point')
|
}
|
}
|
|
return bytes
|
}
|
|
function asciiToBytes (str) {
|
var byteArray = []
|
for (var i = 0; i < str.length; ++i) {
|
// Node's code seems to be doing this and not & 0x7F..
|
byteArray.push(str.charCodeAt(i) & 0xFF)
|
}
|
return byteArray
|
}
|
|
function utf16leToBytes (str, units) {
|
var c, hi, lo
|
var byteArray = []
|
for (var i = 0; i < str.length; ++i) {
|
if ((units -= 2) < 0) break
|
|
c = str.charCodeAt(i)
|
hi = c >> 8
|
lo = c % 256
|
byteArray.push(lo)
|
byteArray.push(hi)
|
}
|
|
return byteArray
|
}
|
|
function base64ToBytes (str) {
|
return base64.toByteArray(base64clean(str))
|
}
|
|
function blitBuffer (src, dst, offset, length) {
|
for (var i = 0; i < length; ++i) {
|
if ((i + offset >= dst.length) || (i >= src.length)) break
|
dst[i + offset] = src[i]
|
}
|
return i
|
}
|
|
function isnan (val) {
|
return val !== val // eslint-disable-line no-self-compare
|
}
|
|
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(1)))
|
|
/***/ }),
|
/* 3 */
|
/***/ (function(module, exports) {
|
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
try {
|
var info = gen[key](arg);
|
var value = info.value;
|
} catch (error) {
|
reject(error);
|
return;
|
}
|
|
if (info.done) {
|
resolve(value);
|
} else {
|
Promise.resolve(value).then(_next, _throw);
|
}
|
}
|
|
function _asyncToGenerator(fn) {
|
return function () {
|
var self = this,
|
args = arguments;
|
return new Promise(function (resolve, reject) {
|
var gen = fn.apply(self, args);
|
|
function _next(value) {
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
}
|
|
function _throw(err) {
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
}
|
|
_next(undefined);
|
});
|
};
|
}
|
|
module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
/***/ }),
|
/* 4 */
|
/***/ (function(module, exports) {
|
|
// shim for using process in browser
|
var process = module.exports = {};
|
|
// cached from whatever global is present so that test runners that stub it
|
// don't break things. But we need to wrap it in a try catch in case it is
|
// wrapped in strict mode code which doesn't define any globals. It's inside a
|
// function because try/catches deoptimize in certain engines.
|
|
var cachedSetTimeout;
|
var cachedClearTimeout;
|
|
function defaultSetTimout() {
|
throw new Error('setTimeout has not been defined');
|
}
|
function defaultClearTimeout () {
|
throw new Error('clearTimeout has not been defined');
|
}
|
(function () {
|
try {
|
if (typeof setTimeout === 'function') {
|
cachedSetTimeout = setTimeout;
|
} else {
|
cachedSetTimeout = defaultSetTimout;
|
}
|
} catch (e) {
|
cachedSetTimeout = defaultSetTimout;
|
}
|
try {
|
if (typeof clearTimeout === 'function') {
|
cachedClearTimeout = clearTimeout;
|
} else {
|
cachedClearTimeout = defaultClearTimeout;
|
}
|
} catch (e) {
|
cachedClearTimeout = defaultClearTimeout;
|
}
|
} ())
|
function runTimeout(fun) {
|
if (cachedSetTimeout === setTimeout) {
|
//normal enviroments in sane situations
|
return setTimeout(fun, 0);
|
}
|
// if setTimeout wasn't available but was latter defined
|
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
cachedSetTimeout = setTimeout;
|
return setTimeout(fun, 0);
|
}
|
try {
|
// when when somebody has screwed with setTimeout but no I.E. maddness
|
return cachedSetTimeout(fun, 0);
|
} catch(e){
|
try {
|
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
return cachedSetTimeout.call(null, fun, 0);
|
} catch(e){
|
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
|
return cachedSetTimeout.call(this, fun, 0);
|
}
|
}
|
|
|
}
|
function runClearTimeout(marker) {
|
if (cachedClearTimeout === clearTimeout) {
|
//normal enviroments in sane situations
|
return clearTimeout(marker);
|
}
|
// if clearTimeout wasn't available but was latter defined
|
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
cachedClearTimeout = clearTimeout;
|
return clearTimeout(marker);
|
}
|
try {
|
// when when somebody has screwed with setTimeout but no I.E. maddness
|
return cachedClearTimeout(marker);
|
} catch (e){
|
try {
|
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
return cachedClearTimeout.call(null, marker);
|
} catch (e){
|
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
|
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
|
return cachedClearTimeout.call(this, marker);
|
}
|
}
|
|
|
|
}
|
var queue = [];
|
var draining = false;
|
var currentQueue;
|
var queueIndex = -1;
|
|
function cleanUpNextTick() {
|
if (!draining || !currentQueue) {
|
return;
|
}
|
draining = false;
|
if (currentQueue.length) {
|
queue = currentQueue.concat(queue);
|
} else {
|
queueIndex = -1;
|
}
|
if (queue.length) {
|
drainQueue();
|
}
|
}
|
|
function drainQueue() {
|
if (draining) {
|
return;
|
}
|
var timeout = runTimeout(cleanUpNextTick);
|
draining = true;
|
|
var len = queue.length;
|
while(len) {
|
currentQueue = queue;
|
queue = [];
|
while (++queueIndex < len) {
|
if (currentQueue) {
|
currentQueue[queueIndex].run();
|
}
|
}
|
queueIndex = -1;
|
len = queue.length;
|
}
|
currentQueue = null;
|
draining = false;
|
runClearTimeout(timeout);
|
}
|
|
process.nextTick = function (fun) {
|
var args = new Array(arguments.length - 1);
|
if (arguments.length > 1) {
|
for (var i = 1; i < arguments.length; i++) {
|
args[i - 1] = arguments[i];
|
}
|
}
|
queue.push(new Item(fun, args));
|
if (queue.length === 1 && !draining) {
|
runTimeout(drainQueue);
|
}
|
};
|
|
// v8 likes predictible objects
|
function Item(fun, array) {
|
this.fun = fun;
|
this.array = array;
|
}
|
Item.prototype.run = function () {
|
this.fun.apply(null, this.array);
|
};
|
process.title = 'browser';
|
process.browser = true;
|
process.env = {};
|
process.argv = [];
|
process.version = ''; // empty string to avoid regexp issues
|
process.versions = {};
|
|
function noop() {}
|
|
process.on = noop;
|
process.addListener = noop;
|
process.once = noop;
|
process.off = noop;
|
process.removeListener = noop;
|
process.removeAllListeners = noop;
|
process.emit = noop;
|
process.prependListener = noop;
|
process.prependOnceListener = noop;
|
|
process.listeners = function (name) { return [] }
|
|
process.binding = function (name) {
|
throw new Error('process.binding is not supported');
|
};
|
|
process.cwd = function () { return '/' };
|
process.chdir = function (dir) {
|
throw new Error('process.chdir is not supported');
|
};
|
process.umask = function() { return 0; };
|
|
|
/***/ }),
|
/* 5 */
|
/***/ (function(module, exports) {
|
|
if (typeof Object.create === 'function') {
|
// implementation from standard node.js 'util' module
|
module.exports = function inherits(ctor, superCtor) {
|
if (superCtor) {
|
ctor.super_ = superCtor
|
ctor.prototype = Object.create(superCtor.prototype, {
|
constructor: {
|
value: ctor,
|
enumerable: false,
|
writable: true,
|
configurable: true
|
}
|
})
|
}
|
};
|
} else {
|
// old school shim for old browsers
|
module.exports = function inherits(ctor, superCtor) {
|
if (superCtor) {
|
ctor.super_ = superCtor
|
var TempCtor = function () {}
|
TempCtor.prototype = superCtor.prototype
|
ctor.prototype = new TempCtor()
|
ctor.prototype.constructor = ctor
|
}
|
}
|
}
|
|
|
/***/ }),
|
/* 6 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
"use strict";
|
// Copyright Joyent, Inc. and other Node contributors.
|
//
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
// copy of this software and associated documentation files (the
|
// "Software"), to deal in the Software without restriction, including
|
// without limitation the rights to use, copy, modify, merge, publish,
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
// persons to whom the Software is furnished to do so, subject to the
|
// following conditions:
|
//
|
// The above copyright notice and this permission notice shall be included
|
// in all copies or substantial portions of the Software.
|
//
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
// a duplex stream is just a stream that is both readable and writable.
|
// Since JS doesn't have multiple prototypal inheritance, this class
|
// prototypally inherits from Readable, and then parasitically from
|
// Writable.
|
|
|
|
/*<replacement>*/
|
|
var pna = __webpack_require__(9);
|
/*</replacement>*/
|
|
/*<replacement>*/
|
var objectKeys = Object.keys || function (obj) {
|
var keys = [];
|
for (var key in obj) {
|
keys.push(key);
|
}return keys;
|
};
|
/*</replacement>*/
|
|
module.exports = Duplex;
|
|
/*<replacement>*/
|
var util = Object.create(__webpack_require__(8));
|
util.inherits = __webpack_require__(5);
|
/*</replacement>*/
|
|
var Readable = __webpack_require__(20);
|
var Writable = __webpack_require__(24);
|
|
util.inherits(Duplex, Readable);
|
|
{
|
// avoid scope creep, the keys array can then be collected
|
var keys = objectKeys(Writable.prototype);
|
for (var v = 0; v < keys.length; v++) {
|
var method = keys[v];
|
if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
|
}
|
}
|
|
function Duplex(options) {
|
if (!(this instanceof Duplex)) return new Duplex(options);
|
|
Readable.call(this, options);
|
Writable.call(this, options);
|
|
if (options && options.readable === false) this.readable = false;
|
|
if (options && options.writable === false) this.writable = false;
|
|
this.allowHalfOpen = true;
|
if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
|
|
this.once('end', onend);
|
}
|
|
Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
|
// making it explicit this property is not enumerable
|
// because otherwise some prototype manipulation in
|
// userland will fail
|
enumerable: false,
|
get: function () {
|
return this._writableState.highWaterMark;
|
}
|
});
|
|
// the no-half-open enforcer
|
function onend() {
|
// if we allow half-open state, or if the writable side ended,
|
// then we're ok.
|
if (this.allowHalfOpen || this._writableState.ended) return;
|
|
// no more data can be written.
|
// But allow more writes to happen in this tick.
|
pna.nextTick(onEndNT, this);
|
}
|
|
function onEndNT(self) {
|
self.end();
|
}
|
|
Object.defineProperty(Duplex.prototype, 'destroyed', {
|
get: function () {
|
if (this._readableState === undefined || this._writableState === undefined) {
|
return false;
|
}
|
return this._readableState.destroyed && this._writableState.destroyed;
|
},
|
set: function (value) {
|
// we ignore the value if the stream
|
// has not been initialized yet
|
if (this._readableState === undefined || this._writableState === undefined) {
|
return;
|
}
|
|
// backward compatibility, the user is explicitly
|
// managing destroyed
|
this._readableState.destroyed = value;
|
this._writableState.destroyed = value;
|
}
|
});
|
|
Duplex.prototype._destroy = function (err, cb) {
|
this.push(null);
|
this.end();
|
|
pna.nextTick(cb, err);
|
};
|
|
/***/ }),
|
/* 7 */
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
"use strict";
|
|
// EXPORTS
|
__webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ binaryAjax; });
|
|
// CONCATENATED MODULE: ./src/combine.js
|
function combine(base, type) {
|
if (!type) {
|
return base;
|
}
|
|
var url = new URL(base);
|
url.pathname = "".concat(url.pathname, ".").concat(type);
|
return url.href;
|
}
|
// CONCATENATED MODULE: ./src/binaryajax.js
|
var Promise = __webpack_require__(14);
|
|
var http = __webpack_require__(16);
|
|
var https = __webpack_require__(65);
|
|
var Buffer = __webpack_require__(2).Buffer;
|
|
|
function binaryAjax(_url, type) {
|
return new Promise(function (resolve, reject) {
|
var url = combine(_url, type);
|
var method = http;
|
|
if (url.startsWith('https:')) {
|
method = https;
|
}
|
|
method.get(url, function (res) {
|
var len = 0;
|
var buffers = [];
|
res.on('data', function (d) {
|
len += d.length;
|
buffers.push(d);
|
});
|
res.on('error', function (e) {
|
reject(e);
|
});
|
res.on('end', function () {
|
if (res.statusCode > 399) {
|
if (type === 'prj' || type === 'cpg' || type === 'dbf') {
|
return resolve(false);
|
} else {
|
return reject(new Error(Buffer.concat(buffers, len).toString()));
|
}
|
}
|
|
var buffer = Buffer.concat(buffers, len);
|
|
if (type === 'prj') {
|
resolve(buffer.toString());
|
} else {
|
resolve(buffer);
|
}
|
});
|
}).on('error', function (e) {
|
reject(e);
|
});
|
});
|
}
|
|
/***/ }),
|
/* 8 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
//
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
// copy of this software and associated documentation files (the
|
// "Software"), to deal in the Software without restriction, including
|
// without limitation the rights to use, copy, modify, merge, publish,
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
// persons to whom the Software is furnished to do so, subject to the
|
// following conditions:
|
//
|
// The above copyright notice and this permission notice shall be included
|
// in all copies or substantial portions of the Software.
|
//
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
// NOTE: These type checking functions intentionally don't use `instanceof`
|
// because it is fragile and can be easily faked with `Object.create()`.
|
|
function isArray(arg) {
|
if (Array.isArray) {
|
return Array.isArray(arg);
|
}
|
return objectToString(arg) === '[object Array]';
|
}
|
exports.isArray = isArray;
|
|
function isBoolean(arg) {
|
return typeof arg === 'boolean';
|
}
|
exports.isBoolean = isBoolean;
|
|
function isNull(arg) {
|
return arg === null;
|
}
|
exports.isNull = isNull;
|
|
function isNullOrUndefined(arg) {
|
return arg == null;
|
}
|
exports.isNullOrUndefined = isNullOrUndefined;
|
|
function isNumber(arg) {
|
return typeof arg === 'number';
|
}
|
exports.isNumber = isNumber;
|
|
function isString(arg) {
|
return typeof arg === 'string';
|
}
|
exports.isString = isString;
|
|
function isSymbol(arg) {
|
return typeof arg === 'symbol';
|
}
|
exports.isSymbol = isSymbol;
|
|
function isUndefined(arg) {
|
return arg === void 0;
|
}
|
exports.isUndefined = isUndefined;
|
|
function isRegExp(re) {
|
return objectToString(re) === '[object RegExp]';
|
}
|
exports.isRegExp = isRegExp;
|
|
function isObject(arg) {
|
return typeof arg === 'object' && arg !== null;
|
}
|
exports.isObject = isObject;
|
|
function isDate(d) {
|
return objectToString(d) === '[object Date]';
|
}
|
exports.isDate = isDate;
|
|
function isError(e) {
|
return (objectToString(e) === '[object Error]' || e instanceof Error);
|
}
|
exports.isError = isError;
|
|
function isFunction(arg) {
|
return typeof arg === 'function';
|
}
|
exports.isFunction = isFunction;
|
|
function isPrimitive(arg) {
|
return arg === null ||
|
typeof arg === 'boolean' ||
|
typeof arg === 'number' ||
|
typeof arg === 'string' ||
|
typeof arg === 'symbol' || // ES6 symbol
|
typeof arg === 'undefined';
|
}
|
exports.isPrimitive = isPrimitive;
|
|
exports.isBuffer = __webpack_require__(2).Buffer.isBuffer;
|
|
function objectToString(o) {
|
return Object.prototype.toString.call(o);
|
}
|
|
|
/***/ }),
|
/* 9 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
"use strict";
|
/* WEBPACK VAR INJECTION */(function(process) {
|
|
if (typeof process === 'undefined' ||
|
!process.version ||
|
process.version.indexOf('v0.') === 0 ||
|
process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
|
module.exports = { nextTick: nextTick };
|
} else {
|
module.exports = process
|
}
|
|
function nextTick(fn, arg1, arg2, arg3) {
|
if (typeof fn !== 'function') {
|
throw new TypeError('"callback" argument must be a function');
|
}
|
var len = arguments.length;
|
var args, i;
|
switch (len) {
|
case 0:
|
case 1:
|
return process.nextTick(fn);
|
case 2:
|
return process.nextTick(function afterTickOne() {
|
fn.call(null, arg1);
|
});
|
case 3:
|
return process.nextTick(function afterTickTwo() {
|
fn.call(null, arg1, arg2);
|
});
|
case 4:
|
return process.nextTick(function afterTickThree() {
|
fn.call(null, arg1, arg2, arg3);
|
});
|
default:
|
args = new Array(len - 1);
|
i = 0;
|
while (i < args.length) {
|
args[i++] = arguments[i];
|
}
|
return process.nextTick(function afterTick() {
|
fn.apply(null, args);
|
});
|
}
|
}
|
|
|
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(4)))
|
|
/***/ }),
|
/* 10 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
"use strict";
|
// Copyright Joyent, Inc. and other Node contributors.
|
//
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
// copy of this software and associated documentation files (the
|
// "Software"), to deal in the Software without restriction, including
|
// without limitation the rights to use, copy, modify, merge, publish,
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
// persons to whom the Software is furnished to do so, subject to the
|
// following conditions:
|
//
|
// The above copyright notice and this permission notice shall be included
|
// in all copies or substantial portions of the Software.
|
//
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
/*<replacement>*/
|
|
var Buffer = __webpack_require__(42).Buffer;
|
/*</replacement>*/
|
|
var isEncoding = Buffer.isEncoding || function (encoding) {
|
encoding = '' + encoding;
|
switch (encoding && encoding.toLowerCase()) {
|
case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
|
return true;
|
default:
|
return false;
|
}
|
};
|
|
function _normalizeEncoding(enc) {
|
if (!enc) return 'utf8';
|
var retried;
|
while (true) {
|
switch (enc) {
|
case 'utf8':
|
case 'utf-8':
|
return 'utf8';
|
case 'ucs2':
|
case 'ucs-2':
|
case 'utf16le':
|
case 'utf-16le':
|
return 'utf16le';
|
case 'latin1':
|
case 'binary':
|
return 'latin1';
|
case 'base64':
|
case 'ascii':
|
case 'hex':
|
return enc;
|
default:
|
if (retried) return; // undefined
|
enc = ('' + enc).toLowerCase();
|
retried = true;
|
}
|
}
|
};
|
|
// Do not cache `Buffer.isEncoding` when checking encoding names as some
|
// modules monkey-patch it to support additional encodings
|
function normalizeEncoding(enc) {
|
var nenc = _normalizeEncoding(enc);
|
if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
|
return nenc || enc;
|
}
|
|
// StringDecoder provides an interface for efficiently splitting a series of
|
// buffers into a series of JS strings without breaking apart multi-byte
|
// characters.
|
exports.StringDecoder = StringDecoder;
|
function StringDecoder(encoding) {
|
this.encoding = normalizeEncoding(encoding);
|
var nb;
|
switch (this.encoding) {
|
case 'utf16le':
|
this.text = utf16Text;
|
this.end = utf16End;
|
nb = 4;
|
break;
|
case 'utf8':
|
this.fillLast = utf8FillLast;
|
nb = 4;
|
break;
|
case 'base64':
|
this.text = base64Text;
|
this.end = base64End;
|
nb = 3;
|
break;
|
default:
|
this.write = simpleWrite;
|
this.end = simpleEnd;
|
return;
|
}
|
this.lastNeed = 0;
|
this.lastTotal = 0;
|
this.lastChar = Buffer.allocUnsafe(nb);
|
}
|
|
StringDecoder.prototype.write = function (buf) {
|
if (buf.length === 0) return '';
|
var r;
|
var i;
|
if (this.lastNeed) {
|
r = this.fillLast(buf);
|
if (r === undefined) return '';
|
i = this.lastNeed;
|
this.lastNeed = 0;
|
} else {
|
i = 0;
|
}
|
if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
|
return r || '';
|
};
|
|
StringDecoder.prototype.end = utf8End;
|
|
// Returns only complete characters in a Buffer
|
StringDecoder.prototype.text = utf8Text;
|
|
// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
|
StringDecoder.prototype.fillLast = function (buf) {
|
if (this.lastNeed <= buf.length) {
|
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
|
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
|
}
|
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
|
this.lastNeed -= buf.length;
|
};
|
|
// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
|
// continuation byte. If an invalid byte is detected, -2 is returned.
|
function utf8CheckByte(byte) {
|
if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
|
return byte >> 6 === 0x02 ? -1 : -2;
|
}
|
|
// Checks at most 3 bytes at the end of a Buffer in order to detect an
|
// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
|
// needed to complete the UTF-8 character (if applicable) are returned.
|
function utf8CheckIncomplete(self, buf, i) {
|
var j = buf.length - 1;
|
if (j < i) return 0;
|
var nb = utf8CheckByte(buf[j]);
|
if (nb >= 0) {
|
if (nb > 0) self.lastNeed = nb - 1;
|
return nb;
|
}
|
if (--j < i || nb === -2) return 0;
|
nb = utf8CheckByte(buf[j]);
|
if (nb >= 0) {
|
if (nb > 0) self.lastNeed = nb - 2;
|
return nb;
|
}
|
if (--j < i || nb === -2) return 0;
|
nb = utf8CheckByte(buf[j]);
|
if (nb >= 0) {
|
if (nb > 0) {
|
if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
|
}
|
return nb;
|
}
|
return 0;
|
}
|
|
// Validates as many continuation bytes for a multi-byte UTF-8 character as
|
// needed or are available. If we see a non-continuation byte where we expect
|
// one, we "replace" the validated continuation bytes we've seen so far with
|
// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
|
// behavior. The continuation byte check is included three times in the case
|
// where all of the continuation bytes for a character exist in the same buffer.
|
// It is also done this way as a slight performance increase instead of using a
|
// loop.
|
function utf8CheckExtraBytes(self, buf, p) {
|
if ((buf[0] & 0xC0) !== 0x80) {
|
self.lastNeed = 0;
|
return '\ufffd';
|
}
|
if (self.lastNeed > 1 && buf.length > 1) {
|
if ((buf[1] & 0xC0) !== 0x80) {
|
self.lastNeed = 1;
|
return '\ufffd';
|
}
|
if (self.lastNeed > 2 && buf.length > 2) {
|
if ((buf[2] & 0xC0) !== 0x80) {
|
self.lastNeed = 2;
|
return '\ufffd';
|
}
|
}
|
}
|
}
|
|
// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
|
function utf8FillLast(buf) {
|
var p = this.lastTotal - this.lastNeed;
|
var r = utf8CheckExtraBytes(this, buf, p);
|
if (r !== undefined) return r;
|
if (this.lastNeed <= buf.length) {
|
buf.copy(this.lastChar, p, 0, this.lastNeed);
|
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
|
}
|
buf.copy(this.lastChar, p, 0, buf.length);
|
this.lastNeed -= buf.length;
|
}
|
|
// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
|
// partial character, the character's bytes are buffered until the required
|
// number of bytes are available.
|
function utf8Text(buf, i) {
|
var total = utf8CheckIncomplete(this, buf, i);
|
if (!this.lastNeed) return buf.toString('utf8', i);
|
this.lastTotal = total;
|
var end = buf.length - (total - this.lastNeed);
|
buf.copy(this.lastChar, 0, end);
|
return buf.toString('utf8', i, end);
|
}
|
|
// For UTF-8, a replacement character is added when ending on a partial
|
// character.
|
function utf8End(buf) {
|
var r = buf && buf.length ? this.write(buf) : '';
|
if (this.lastNeed) return r + '\ufffd';
|
return r;
|
}
|
|
// UTF-16LE typically needs two bytes per character, but even if we have an even
|
// number of bytes available, we need to check if we end on a leading/high
|
// surrogate. In that case, we need to wait for the next two bytes in order to
|
// decode the last character properly.
|
function utf16Text(buf, i) {
|
if ((buf.length - i) % 2 === 0) {
|
var r = buf.toString('utf16le', i);
|
if (r) {
|
var c = r.charCodeAt(r.length - 1);
|
if (c >= 0xD800 && c <= 0xDBFF) {
|
this.lastNeed = 2;
|
this.lastTotal = 4;
|
this.lastChar[0] = buf[buf.length - 2];
|
this.lastChar[1] = buf[buf.length - 1];
|
return r.slice(0, -1);
|
}
|
}
|
return r;
|
}
|
this.lastNeed = 1;
|
this.lastTotal = 2;
|
this.lastChar[0] = buf[buf.length - 1];
|
return buf.toString('utf16le', i, buf.length - 1);
|
}
|
|
// For UTF-16LE we do not explicitly append special replacement characters if we
|
// end on a partial character, we simply let v8 handle that.
|
function utf16End(buf) {
|
var r = buf && buf.length ? this.write(buf) : '';
|
if (this.lastNeed) {
|
var end = this.lastTotal - this.lastNeed;
|
return r + this.lastChar.toString('utf16le', 0, end);
|
}
|
return r;
|
}
|
|
function base64Text(buf, i) {
|
var n = (buf.length - i) % 3;
|
if (n === 0) return buf.toString('base64', i);
|
this.lastNeed = 3 - n;
|
this.lastTotal = 3;
|
if (n === 1) {
|
this.lastChar[0] = buf[buf.length - 1];
|
} else {
|
this.lastChar[0] = buf[buf.length - 2];
|
this.lastChar[1] = buf[buf.length - 1];
|
}
|
return buf.toString('base64', i, buf.length - n);
|
}
|
|
function base64End(buf) {
|
var r = buf && buf.length ? this.write(buf) : '';
|
if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
|
return r;
|
}
|
|
// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
|
function simpleWrite(buf) {
|
return buf.toString(this.encoding);
|
}
|
|
function simpleEnd(buf) {
|
return buf && buf.length ? this.write(buf) : '';
|
}
|
|
/***/ }),
|
/* 11 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
/* eslint-disable node/no-deprecated-api */
|
var buffer = __webpack_require__(2)
|
var Buffer = buffer.Buffer
|
|
// alternative to using Object.keys for old browsers
|
function copyProps (src, dst) {
|
for (var key in src) {
|
dst[key] = src[key]
|
}
|
}
|
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
|
module.exports = buffer
|
} else {
|
// Copy properties from require('buffer')
|
copyProps(buffer, exports)
|
exports.Buffer = SafeBuffer
|
}
|
|
function SafeBuffer (arg, encodingOrOffset, length) {
|
return Buffer(arg, encodingOrOffset, length)
|
}
|
|
// Copy static methods from Buffer
|
copyProps(Buffer, SafeBuffer)
|
|
SafeBuffer.from = function (arg, encodingOrOffset, length) {
|
if (typeof arg === 'number') {
|
throw new TypeError('Argument must not be a number')
|
}
|
return Buffer(arg, encodingOrOffset, length)
|
}
|
|
SafeBuffer.alloc = function (size, fill, encoding) {
|
if (typeof size !== 'number') {
|
throw new TypeError('Argument must be a number')
|
}
|
var buf = Buffer(size)
|
if (fill !== undefined) {
|
if (typeof encoding === 'string') {
|
buf.fill(fill, encoding)
|
} else {
|
buf.fill(fill)
|
}
|
} else {
|
buf.fill(0)
|
}
|
return buf
|
}
|
|
SafeBuffer.allocUnsafe = function (size) {
|
if (typeof size !== 'number') {
|
throw new TypeError('Argument must be a number')
|
}
|
return Buffer(size)
|
}
|
|
SafeBuffer.allocUnsafeSlow = function (size) {
|
if (typeof size !== 'number') {
|
throw new TypeError('Argument must be a number')
|
}
|
return buffer.SlowBuffer(size)
|
}
|
|
|
/***/ }),
|
/* 12 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
var arrayWithHoles = __webpack_require__(30);
|
|
var iterableToArrayLimit = __webpack_require__(31);
|
|
var unsupportedIterableToArray = __webpack_require__(32);
|
|
var nonIterableRest = __webpack_require__(34);
|
|
function _slicedToArray(arr, i) {
|
return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();
|
}
|
|
module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
/***/ }),
|
/* 13 */
|
/***/ (function(module, exports) {
|
|
var toString = {}.toString;
|
|
module.exports = Array.isArray || function (arr) {
|
return toString.call(arr) == '[object Array]';
|
};
|
|
|
/***/ }),
|
/* 14 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
"use strict";
|
|
var immediate = __webpack_require__(45);
|
|
/* istanbul ignore next */
|
function INTERNAL() {}
|
|
var handlers = {};
|
|
var REJECTED = ['REJECTED'];
|
var FULFILLED = ['FULFILLED'];
|
var PENDING = ['PENDING'];
|
|
module.exports = Promise;
|
|
function Promise(resolver) {
|
if (typeof resolver !== 'function') {
|
throw new TypeError('resolver must be a function');
|
}
|
this.state = PENDING;
|
this.queue = [];
|
this.outcome = void 0;
|
if (resolver !== INTERNAL) {
|
safelyResolveThenable(this, resolver);
|
}
|
}
|
|
Promise.prototype["finally"] = function (callback) {
|
if (typeof callback !== 'function') {
|
return this;
|
}
|
var p = this.constructor;
|
return this.then(resolve, reject);
|
|
function resolve(value) {
|
function yes () {
|
return value;
|
}
|
return p.resolve(callback()).then(yes);
|
}
|
function reject(reason) {
|
function no () {
|
throw reason;
|
}
|
return p.resolve(callback()).then(no);
|
}
|
};
|
Promise.prototype["catch"] = function (onRejected) {
|
return this.then(null, onRejected);
|
};
|
Promise.prototype.then = function (onFulfilled, onRejected) {
|
if (typeof onFulfilled !== 'function' && this.state === FULFILLED ||
|
typeof onRejected !== 'function' && this.state === REJECTED) {
|
return this;
|
}
|
var promise = new this.constructor(INTERNAL);
|
if (this.state !== PENDING) {
|
var resolver = this.state === FULFILLED ? onFulfilled : onRejected;
|
unwrap(promise, resolver, this.outcome);
|
} else {
|
this.queue.push(new QueueItem(promise, onFulfilled, onRejected));
|
}
|
|
return promise;
|
};
|
function QueueItem(promise, onFulfilled, onRejected) {
|
this.promise = promise;
|
if (typeof onFulfilled === 'function') {
|
this.onFulfilled = onFulfilled;
|
this.callFulfilled = this.otherCallFulfilled;
|
}
|
if (typeof onRejected === 'function') {
|
this.onRejected = onRejected;
|
this.callRejected = this.otherCallRejected;
|
}
|
}
|
QueueItem.prototype.callFulfilled = function (value) {
|
handlers.resolve(this.promise, value);
|
};
|
QueueItem.prototype.otherCallFulfilled = function (value) {
|
unwrap(this.promise, this.onFulfilled, value);
|
};
|
QueueItem.prototype.callRejected = function (value) {
|
handlers.reject(this.promise, value);
|
};
|
QueueItem.prototype.otherCallRejected = function (value) {
|
unwrap(this.promise, this.onRejected, value);
|
};
|
|
function unwrap(promise, func, value) {
|
immediate(function () {
|
var returnValue;
|
try {
|
returnValue = func(value);
|
} catch (e) {
|
return handlers.reject(promise, e);
|
}
|
if (returnValue === promise) {
|
handlers.reject(promise, new TypeError('Cannot resolve promise with itself'));
|
} else {
|
handlers.resolve(promise, returnValue);
|
}
|
});
|
}
|
|
handlers.resolve = function (self, value) {
|
var result = tryCatch(getThen, value);
|
if (result.status === 'error') {
|
return handlers.reject(self, result.value);
|
}
|
var thenable = result.value;
|
|
if (thenable) {
|
safelyResolveThenable(self, thenable);
|
} else {
|
self.state = FULFILLED;
|
self.outcome = value;
|
var i = -1;
|
var len = self.queue.length;
|
while (++i < len) {
|
self.queue[i].callFulfilled(value);
|
}
|
}
|
return self;
|
};
|
handlers.reject = function (self, error) {
|
self.state = REJECTED;
|
self.outcome = error;
|
var i = -1;
|
var len = self.queue.length;
|
while (++i < len) {
|
self.queue[i].callRejected(error);
|
}
|
return self;
|
};
|
|
function getThen(obj) {
|
// Make sure we only access the accessor once as required by the spec
|
var then = obj && obj.then;
|
if (obj && (typeof obj === 'object' || typeof obj === 'function') && typeof then === 'function') {
|
return function appyThen() {
|
then.apply(obj, arguments);
|
};
|
}
|
}
|
|
function safelyResolveThenable(self, thenable) {
|
// Either fulfill, reject or reject with error
|
var called = false;
|
function onError(value) {
|
if (called) {
|
return;
|
}
|
called = true;
|
handlers.reject(self, value);
|
}
|
|
function onSuccess(value) {
|
if (called) {
|
return;
|
}
|
called = true;
|
handlers.resolve(self, value);
|
}
|
|
function tryToUnwrap() {
|
thenable(onSuccess, onError);
|
}
|
|
var result = tryCatch(tryToUnwrap);
|
if (result.status === 'error') {
|
onError(result.value);
|
}
|
}
|
|
function tryCatch(func, value) {
|
var out = {};
|
try {
|
out.value = func(value);
|
out.status = 'success';
|
} catch (e) {
|
out.status = 'error';
|
out.value = e;
|
}
|
return out;
|
}
|
|
Promise.resolve = resolve;
|
function resolve(value) {
|
if (value instanceof this) {
|
return value;
|
}
|
return handlers.resolve(new this(INTERNAL), value);
|
}
|
|
Promise.reject = reject;
|
function reject(reason) {
|
var promise = new this(INTERNAL);
|
return handlers.reject(promise, reason);
|
}
|
|
Promise.all = all;
|
function all(iterable) {
|
var self = this;
|
if (Object.prototype.toString.call(iterable) !== '[object Array]') {
|
return this.reject(new TypeError('must be an array'));
|
}
|
|
var len = iterable.length;
|
var called = false;
|
if (!len) {
|
return this.resolve([]);
|
}
|
|
var values = new Array(len);
|
var resolved = 0;
|
var i = -1;
|
var promise = new this(INTERNAL);
|
|
while (++i < len) {
|
allResolver(iterable[i], i);
|
}
|
return promise;
|
function allResolver(value, i) {
|
self.resolve(value).then(resolveFromAll, function (error) {
|
if (!called) {
|
called = true;
|
handlers.reject(promise, error);
|
}
|
});
|
function resolveFromAll(outValue) {
|
values[i] = outValue;
|
if (++resolved === len && !called) {
|
called = true;
|
handlers.resolve(promise, values);
|
}
|
}
|
}
|
}
|
|
Promise.race = race;
|
function race(iterable) {
|
var self = this;
|
if (Object.prototype.toString.call(iterable) !== '[object Array]') {
|
return this.reject(new TypeError('must be an array'));
|
}
|
|
var len = iterable.length;
|
var called = false;
|
if (!len) {
|
return this.resolve([]);
|
}
|
|
var i = -1;
|
var promise = new this(INTERNAL);
|
|
while (++i < len) {
|
resolver(iterable[i]);
|
}
|
return promise;
|
function resolver(value) {
|
self.resolve(value).then(function (response) {
|
if (!called) {
|
called = true;
|
handlers.resolve(promise, response);
|
}
|
}, function (error) {
|
if (!called) {
|
called = true;
|
handlers.reject(promise, error);
|
}
|
});
|
}
|
}
|
|
|
/***/ }),
|
/* 15 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
/* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) ||
|
(typeof self !== "undefined" && self) ||
|
window;
|
var apply = Function.prototype.apply;
|
|
// DOM APIs, for completeness
|
|
exports.setTimeout = function() {
|
return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
|
};
|
exports.setInterval = function() {
|
return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
|
};
|
exports.clearTimeout =
|
exports.clearInterval = function(timeout) {
|
if (timeout) {
|
timeout.close();
|
}
|
};
|
|
function Timeout(id, clearFn) {
|
this._id = id;
|
this._clearFn = clearFn;
|
}
|
Timeout.prototype.unref = Timeout.prototype.ref = function() {};
|
Timeout.prototype.close = function() {
|
this._clearFn.call(scope, this._id);
|
};
|
|
// Does not start the time, just sets up the members needed.
|
exports.enroll = function(item, msecs) {
|
clearTimeout(item._idleTimeoutId);
|
item._idleTimeout = msecs;
|
};
|
|
exports.unenroll = function(item) {
|
clearTimeout(item._idleTimeoutId);
|
item._idleTimeout = -1;
|
};
|
|
exports._unrefActive = exports.active = function(item) {
|
clearTimeout(item._idleTimeoutId);
|
|
var msecs = item._idleTimeout;
|
if (msecs >= 0) {
|
item._idleTimeoutId = setTimeout(function onTimeout() {
|
if (item._onTimeout)
|
item._onTimeout();
|
}, msecs);
|
}
|
};
|
|
// setimmediate attaches itself to the global object
|
__webpack_require__(48);
|
// On some exotic environments, it's not clear which object `setimmediate` was
|
// able to install onto. Search each possibility in the same order as the
|
// `setimmediate` library.
|
exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) ||
|
(typeof global !== "undefined" && global.setImmediate) ||
|
(this && this.setImmediate);
|
exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
|
(typeof global !== "undefined" && global.clearImmediate) ||
|
(this && this.clearImmediate);
|
|
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(1)))
|
|
/***/ }),
|
/* 16 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
/* WEBPACK VAR INJECTION */(function(global) {var ClientRequest = __webpack_require__(50)
|
var response = __webpack_require__(18)
|
var extend = __webpack_require__(57)
|
var statusCodes = __webpack_require__(58)
|
var url = __webpack_require__(26)
|
|
var http = exports
|
|
http.request = function (opts, cb) {
|
if (typeof opts === 'string')
|
opts = url.parse(opts)
|
else
|
opts = extend(opts)
|
|
// Normally, the page is loaded from http or https, so not specifying a protocol
|
// will result in a (valid) protocol-relative url. However, this won't work if
|
// the protocol is something else, like 'file:'
|
var defaultProtocol = global.location.protocol.search(/^https?:$/) === -1 ? 'http:' : ''
|
|
var protocol = opts.protocol || defaultProtocol
|
var host = opts.hostname || opts.host
|
var port = opts.port
|
var path = opts.path || '/'
|
|
// Necessary for IPv6 addresses
|
if (host && host.indexOf(':') !== -1)
|
host = '[' + host + ']'
|
|
// This may be a relative url. The browser should always be able to interpret it correctly.
|
opts.url = (host ? (protocol + '//' + host) : '') + (port ? ':' + port : '') + path
|
opts.method = (opts.method || 'GET').toUpperCase()
|
opts.headers = opts.headers || {}
|
|
// Also valid opts.auth, opts.mode
|
|
var req = new ClientRequest(opts)
|
if (cb)
|
req.on('response', cb)
|
return req
|
}
|
|
http.get = function get (opts, cb) {
|
var req = http.request(opts, cb)
|
req.end()
|
return req
|
}
|
|
http.ClientRequest = ClientRequest
|
http.IncomingMessage = response.IncomingMessage
|
|
http.Agent = function () {}
|
http.Agent.defaultMaxSockets = 4
|
|
http.globalAgent = new http.Agent()
|
|
http.STATUS_CODES = statusCodes
|
|
http.METHODS = [
|
'CHECKOUT',
|
'CONNECT',
|
'COPY',
|
'DELETE',
|
'GET',
|
'HEAD',
|
'LOCK',
|
'M-SEARCH',
|
'MERGE',
|
'MKACTIVITY',
|
'MKCOL',
|
'MOVE',
|
'NOTIFY',
|
'OPTIONS',
|
'PATCH',
|
'POST',
|
'PROPFIND',
|
'PROPPATCH',
|
'PURGE',
|
'PUT',
|
'REPORT',
|
'SEARCH',
|
'SUBSCRIBE',
|
'TRACE',
|
'UNLOCK',
|
'UNSUBSCRIBE'
|
]
|
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(1)))
|
|
/***/ }),
|
/* 17 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
/* WEBPACK VAR INJECTION */(function(global) {exports.fetch = isFunction(global.fetch) && isFunction(global.ReadableStream)
|
|
exports.writableStream = isFunction(global.WritableStream)
|
|
exports.abortController = isFunction(global.AbortController)
|
|
exports.blobConstructor = false
|
try {
|
new Blob([new ArrayBuffer(1)])
|
exports.blobConstructor = true
|
} catch (e) {}
|
|
// The xhr request to example.com may violate some restrictive CSP configurations,
|
// so if we're running in a browser that supports `fetch`, avoid calling getXHR()
|
// and assume support for certain features below.
|
var xhr
|
function getXHR () {
|
// Cache the xhr value
|
if (xhr !== undefined) return xhr
|
|
if (global.XMLHttpRequest) {
|
xhr = new global.XMLHttpRequest()
|
// If XDomainRequest is available (ie only, where xhr might not work
|
// cross domain), use the page location. Otherwise use example.com
|
// Note: this doesn't actually make an http request.
|
try {
|
xhr.open('GET', global.XDomainRequest ? '/' : 'https://example.com')
|
} catch(e) {
|
xhr = null
|
}
|
} else {
|
// Service workers don't have XHR
|
xhr = null
|
}
|
return xhr
|
}
|
|
function checkTypeSupport (type) {
|
var xhr = getXHR()
|
if (!xhr) return false
|
try {
|
xhr.responseType = type
|
return xhr.responseType === type
|
} catch (e) {}
|
return false
|
}
|
|
// For some strange reason, Safari 7.0 reports typeof global.ArrayBuffer === 'object'.
|
// Safari 7.1 appears to have fixed this bug.
|
var haveArrayBuffer = typeof global.ArrayBuffer !== 'undefined'
|
var haveSlice = haveArrayBuffer && isFunction(global.ArrayBuffer.prototype.slice)
|
|
// If fetch is supported, then arraybuffer will be supported too. Skip calling
|
// checkTypeSupport(), since that calls getXHR().
|
exports.arraybuffer = exports.fetch || (haveArrayBuffer && checkTypeSupport('arraybuffer'))
|
|
// These next two tests unavoidably show warnings in Chrome. Since fetch will always
|
// be used if it's available, just return false for these to avoid the warnings.
|
exports.msstream = !exports.fetch && haveSlice && checkTypeSupport('ms-stream')
|
exports.mozchunkedarraybuffer = !exports.fetch && haveArrayBuffer &&
|
checkTypeSupport('moz-chunked-arraybuffer')
|
|
// If fetch is supported, then overrideMimeType will be supported too. Skip calling
|
// getXHR().
|
exports.overrideMimeType = exports.fetch || (getXHR() ? isFunction(getXHR().overrideMimeType) : false)
|
|
exports.vbArray = isFunction(global.VBArray)
|
|
function isFunction (value) {
|
return typeof value === 'function'
|
}
|
|
xhr = null // Help gc
|
|
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(1)))
|
|
/***/ }),
|
/* 18 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
/* WEBPACK VAR INJECTION */(function(process, Buffer, global) {var capability = __webpack_require__(17)
|
var inherits = __webpack_require__(5)
|
var stream = __webpack_require__(19)
|
|
var rStates = exports.readyStates = {
|
UNSENT: 0,
|
OPENED: 1,
|
HEADERS_RECEIVED: 2,
|
LOADING: 3,
|
DONE: 4
|
}
|
|
var IncomingMessage = exports.IncomingMessage = function (xhr, response, mode, fetchTimer) {
|
var self = this
|
stream.Readable.call(self)
|
|
self._mode = mode
|
self.headers = {}
|
self.rawHeaders = []
|
self.trailers = {}
|
self.rawTrailers = []
|
|
// Fake the 'close' event, but only once 'end' fires
|
self.on('end', function () {
|
// The nextTick is necessary to prevent the 'request' module from causing an infinite loop
|
process.nextTick(function () {
|
self.emit('close')
|
})
|
})
|
|
if (mode === 'fetch') {
|
self._fetchResponse = response
|
|
self.url = response.url
|
self.statusCode = response.status
|
self.statusMessage = response.statusText
|
|
response.headers.forEach(function (header, key){
|
self.headers[key.toLowerCase()] = header
|
self.rawHeaders.push(key, header)
|
})
|
|
if (capability.writableStream) {
|
var writable = new WritableStream({
|
write: function (chunk) {
|
return new Promise(function (resolve, reject) {
|
if (self._destroyed) {
|
reject()
|
} else if(self.push(new Buffer(chunk))) {
|
resolve()
|
} else {
|
self._resumeFetch = resolve
|
}
|
})
|
},
|
close: function () {
|
global.clearTimeout(fetchTimer)
|
if (!self._destroyed)
|
self.push(null)
|
},
|
abort: function (err) {
|
if (!self._destroyed)
|
self.emit('error', err)
|
}
|
})
|
|
try {
|
response.body.pipeTo(writable).catch(function (err) {
|
global.clearTimeout(fetchTimer)
|
if (!self._destroyed)
|
self.emit('error', err)
|
})
|
return
|
} catch (e) {} // pipeTo method isn't defined. Can't find a better way to feature test this
|
}
|
// fallback for when writableStream or pipeTo aren't available
|
var reader = response.body.getReader()
|
function read () {
|
reader.read().then(function (result) {
|
if (self._destroyed)
|
return
|
if (result.done) {
|
global.clearTimeout(fetchTimer)
|
self.push(null)
|
return
|
}
|
self.push(new Buffer(result.value))
|
read()
|
}).catch(function (err) {
|
global.clearTimeout(fetchTimer)
|
if (!self._destroyed)
|
self.emit('error', err)
|
})
|
}
|
read()
|
} else {
|
self._xhr = xhr
|
self._pos = 0
|
|
self.url = xhr.responseURL
|
self.statusCode = xhr.status
|
self.statusMessage = xhr.statusText
|
var headers = xhr.getAllResponseHeaders().split(/\r?\n/)
|
headers.forEach(function (header) {
|
var matches = header.match(/^([^:]+):\s*(.*)/)
|
if (matches) {
|
var key = matches[1].toLowerCase()
|
if (key === 'set-cookie') {
|
if (self.headers[key] === undefined) {
|
self.headers[key] = []
|
}
|
self.headers[key].push(matches[2])
|
} else if (self.headers[key] !== undefined) {
|
self.headers[key] += ', ' + matches[2]
|
} else {
|
self.headers[key] = matches[2]
|
}
|
self.rawHeaders.push(matches[1], matches[2])
|
}
|
})
|
|
self._charset = 'x-user-defined'
|
if (!capability.overrideMimeType) {
|
var mimeType = self.rawHeaders['mime-type']
|
if (mimeType) {
|
var charsetMatch = mimeType.match(/;\s*charset=([^;])(;|$)/)
|
if (charsetMatch) {
|
self._charset = charsetMatch[1].toLowerCase()
|
}
|
}
|
if (!self._charset)
|
self._charset = 'utf-8' // best guess
|
}
|
}
|
}
|
|
inherits(IncomingMessage, stream.Readable)
|
|
IncomingMessage.prototype._read = function () {
|
var self = this
|
|
var resolve = self._resumeFetch
|
if (resolve) {
|
self._resumeFetch = null
|
resolve()
|
}
|
}
|
|
IncomingMessage.prototype._onXHRProgress = function () {
|
var self = this
|
|
var xhr = self._xhr
|
|
var response = null
|
switch (self._mode) {
|
case 'text:vbarray': // For IE9
|
if (xhr.readyState !== rStates.DONE)
|
break
|
try {
|
// This fails in IE8
|
response = new global.VBArray(xhr.responseBody).toArray()
|
} catch (e) {}
|
if (response !== null) {
|
self.push(new Buffer(response))
|
break
|
}
|
// Falls through in IE8
|
case 'text':
|
try { // This will fail when readyState = 3 in IE9. Switch mode and wait for readyState = 4
|
response = xhr.responseText
|
} catch (e) {
|
self._mode = 'text:vbarray'
|
break
|
}
|
if (response.length > self._pos) {
|
var newData = response.substr(self._pos)
|
if (self._charset === 'x-user-defined') {
|
var buffer = new Buffer(newData.length)
|
for (var i = 0; i < newData.length; i++)
|
buffer[i] = newData.charCodeAt(i) & 0xff
|
|
self.push(buffer)
|
} else {
|
self.push(newData, self._charset)
|
}
|
self._pos = response.length
|
}
|
break
|
case 'arraybuffer':
|
if (xhr.readyState !== rStates.DONE || !xhr.response)
|
break
|
response = xhr.response
|
self.push(new Buffer(new Uint8Array(response)))
|
break
|
case 'moz-chunked-arraybuffer': // take whole
|
response = xhr.response
|
if (xhr.readyState !== rStates.LOADING || !response)
|
break
|
self.push(new Buffer(new Uint8Array(response)))
|
break
|
case 'ms-stream':
|
response = xhr.response
|
if (xhr.readyState !== rStates.LOADING)
|
break
|
var reader = new global.MSStreamReader()
|
reader.onprogress = function () {
|
if (reader.result.byteLength > self._pos) {
|
self.push(new Buffer(new Uint8Array(reader.result.slice(self._pos))))
|
self._pos = reader.result.byteLength
|
}
|
}
|
reader.onload = function () {
|
self.push(null)
|
}
|
// reader.onerror = ??? // TODO: this
|
reader.readAsArrayBuffer(response)
|
break
|
}
|
|
// The ms-stream case handles end separately in reader.onload()
|
if (self._xhr.readyState === rStates.DONE && self._mode !== 'ms-stream') {
|
self.push(null)
|
}
|
}
|
|
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(4), __webpack_require__(2).Buffer, __webpack_require__(1)))
|
|
/***/ }),
|
/* 19 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
exports = module.exports = __webpack_require__(20);
|
exports.Stream = exports;
|
exports.Readable = exports;
|
exports.Writable = __webpack_require__(24);
|
exports.Duplex = __webpack_require__(6);
|
exports.Transform = __webpack_require__(25);
|
exports.PassThrough = __webpack_require__(55);
|
|
|
/***/ }),
|
/* 20 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
"use strict";
|
/* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors.
|
//
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
// copy of this software and associated documentation files (the
|
// "Software"), to deal in the Software without restriction, including
|
// without limitation the rights to use, copy, modify, merge, publish,
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
// persons to whom the Software is furnished to do so, subject to the
|
// following conditions:
|
//
|
// The above copyright notice and this permission notice shall be included
|
// in all copies or substantial portions of the Software.
|
//
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
/*<replacement>*/
|
|
var pna = __webpack_require__(9);
|
/*</replacement>*/
|
|
module.exports = Readable;
|
|
/*<replacement>*/
|
var isArray = __webpack_require__(13);
|
/*</replacement>*/
|
|
/*<replacement>*/
|
var Duplex;
|
/*</replacement>*/
|
|
Readable.ReadableState = ReadableState;
|
|
/*<replacement>*/
|
var EE = __webpack_require__(21).EventEmitter;
|
|
var EElistenerCount = function (emitter, type) {
|
return emitter.listeners(type).length;
|
};
|
/*</replacement>*/
|
|
/*<replacement>*/
|
var Stream = __webpack_require__(22);
|
/*</replacement>*/
|
|
/*<replacement>*/
|
|
var Buffer = __webpack_require__(11).Buffer;
|
var OurUint8Array = global.Uint8Array || function () {};
|
function _uint8ArrayToBuffer(chunk) {
|
return Buffer.from(chunk);
|
}
|
function _isUint8Array(obj) {
|
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
}
|
|
/*</replacement>*/
|
|
/*<replacement>*/
|
var util = Object.create(__webpack_require__(8));
|
util.inherits = __webpack_require__(5);
|
/*</replacement>*/
|
|
/*<replacement>*/
|
var debugUtil = __webpack_require__(51);
|
var debug = void 0;
|
if (debugUtil && debugUtil.debuglog) {
|
debug = debugUtil.debuglog('stream');
|
} else {
|
debug = function () {};
|
}
|
/*</replacement>*/
|
|
var BufferList = __webpack_require__(52);
|
var destroyImpl = __webpack_require__(23);
|
var StringDecoder;
|
|
util.inherits(Readable, Stream);
|
|
var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
|
|
function prependListener(emitter, event, fn) {
|
// Sadly this is not cacheable as some libraries bundle their own
|
// event emitter implementation with them.
|
if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
|
|
// This is a hack to make sure that our error handler is attached before any
|
// userland ones. NEVER DO THIS. This is here only because this code needs
|
// to continue to work with older versions of Node.js that do not include
|
// the prependListener() method. The goal is to eventually remove this hack.
|
if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
|
}
|
|
function ReadableState(options, stream) {
|
Duplex = Duplex || __webpack_require__(6);
|
|
options = options || {};
|
|
// Duplex streams are both readable and writable, but share
|
// the same options object.
|
// However, some cases require setting options to different
|
// values for the readable and the writable sides of the duplex stream.
|
// These options can be provided separately as readableXXX and writableXXX.
|
var isDuplex = stream instanceof Duplex;
|
|
// object stream flag. Used to make read(n) ignore n and to
|
// make all the buffer merging and length checks go away
|
this.objectMode = !!options.objectMode;
|
|
if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
|
|
// the point at which it stops calling _read() to fill the buffer
|
// Note: 0 is a valid value, means "don't call _read preemptively ever"
|
var hwm = options.highWaterMark;
|
var readableHwm = options.readableHighWaterMark;
|
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
|
|
if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
|
|
// cast to ints.
|
this.highWaterMark = Math.floor(this.highWaterMark);
|
|
// A linked list is used to store data chunks instead of an array because the
|
// linked list can remove elements from the beginning faster than
|
// array.shift()
|
this.buffer = new BufferList();
|
this.length = 0;
|
this.pipes = null;
|
this.pipesCount = 0;
|
this.flowing = null;
|
this.ended = false;
|
this.endEmitted = false;
|
this.reading = false;
|
|
// a flag to be able to tell if the event 'readable'/'data' is emitted
|
// immediately, or on a later tick. We set this to true at first, because
|
// any actions that shouldn't happen until "later" should generally also
|
// not happen before the first read call.
|
this.sync = true;
|
|
// whenever we return null, then we set a flag to say
|
// that we're awaiting a 'readable' event emission.
|
this.needReadable = false;
|
this.emittedReadable = false;
|
this.readableListening = false;
|
this.resumeScheduled = false;
|
|
// has it been destroyed
|
this.destroyed = false;
|
|
// Crypto is kind of old and crusty. Historically, its default string
|
// encoding is 'binary' so we have to make this configurable.
|
// Everything else in the universe uses 'utf8', though.
|
this.defaultEncoding = options.defaultEncoding || 'utf8';
|
|
// the number of writers that are awaiting a drain event in .pipe()s
|
this.awaitDrain = 0;
|
|
// if true, a maybeReadMore has been scheduled
|
this.readingMore = false;
|
|
this.decoder = null;
|
this.encoding = null;
|
if (options.encoding) {
|
if (!StringDecoder) StringDecoder = __webpack_require__(10).StringDecoder;
|
this.decoder = new StringDecoder(options.encoding);
|
this.encoding = options.encoding;
|
}
|
}
|
|
function Readable(options) {
|
Duplex = Duplex || __webpack_require__(6);
|
|
if (!(this instanceof Readable)) return new Readable(options);
|
|
this._readableState = new ReadableState(options, this);
|
|
// legacy
|
this.readable = true;
|
|
if (options) {
|
if (typeof options.read === 'function') this._read = options.read;
|
|
if (typeof options.destroy === 'function') this._destroy = options.destroy;
|
}
|
|
Stream.call(this);
|
}
|
|
Object.defineProperty(Readable.prototype, 'destroyed', {
|
get: function () {
|
if (this._readableState === undefined) {
|
return false;
|
}
|
return this._readableState.destroyed;
|
},
|
set: function (value) {
|
// we ignore the value if the stream
|
// has not been initialized yet
|
if (!this._readableState) {
|
return;
|
}
|
|
// backward compatibility, the user is explicitly
|
// managing destroyed
|
this._readableState.destroyed = value;
|
}
|
});
|
|
Readable.prototype.destroy = destroyImpl.destroy;
|
Readable.prototype._undestroy = destroyImpl.undestroy;
|
Readable.prototype._destroy = function (err, cb) {
|
this.push(null);
|
cb(err);
|
};
|
|
// Manually shove something into the read() buffer.
|
// This returns true if the highWaterMark has not been hit yet,
|
// similar to how Writable.write() returns true if you should
|
// write() some more.
|
Readable.prototype.push = function (chunk, encoding) {
|
var state = this._readableState;
|
var skipChunkCheck;
|
|
if (!state.objectMode) {
|
if (typeof chunk === 'string') {
|
encoding = encoding || state.defaultEncoding;
|
if (encoding !== state.encoding) {
|
chunk = Buffer.from(chunk, encoding);
|
encoding = '';
|
}
|
skipChunkCheck = true;
|
}
|
} else {
|
skipChunkCheck = true;
|
}
|
|
return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
|
};
|
|
// Unshift should *always* be something directly out of read()
|
Readable.prototype.unshift = function (chunk) {
|
return readableAddChunk(this, chunk, null, true, false);
|
};
|
|
function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
|
var state = stream._readableState;
|
if (chunk === null) {
|
state.reading = false;
|
onEofChunk(stream, state);
|
} else {
|
var er;
|
if (!skipChunkCheck) er = chunkInvalid(state, chunk);
|
if (er) {
|
stream.emit('error', er);
|
} else if (state.objectMode || chunk && chunk.length > 0) {
|
if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
|
chunk = _uint8ArrayToBuffer(chunk);
|
}
|
|
if (addToFront) {
|
if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
|
} else if (state.ended) {
|
stream.emit('error', new Error('stream.push() after EOF'));
|
} else {
|
state.reading = false;
|
if (state.decoder && !encoding) {
|
chunk = state.decoder.write(chunk);
|
if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
|
} else {
|
addChunk(stream, state, chunk, false);
|
}
|
}
|
} else if (!addToFront) {
|
state.reading = false;
|
}
|
}
|
|
return needMoreData(state);
|
}
|
|
function addChunk(stream, state, chunk, addToFront) {
|
if (state.flowing && state.length === 0 && !state.sync) {
|
stream.emit('data', chunk);
|
stream.read(0);
|
} else {
|
// update the buffer info.
|
state.length += state.objectMode ? 1 : chunk.length;
|
if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
|
|
if (state.needReadable) emitReadable(stream);
|
}
|
maybeReadMore(stream, state);
|
}
|
|
function chunkInvalid(state, chunk) {
|
var er;
|
if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
|
er = new TypeError('Invalid non-string/buffer chunk');
|
}
|
return er;
|
}
|
|
// if it's past the high water mark, we can push in some more.
|
// Also, if we have no data yet, we can stand some
|
// more bytes. This is to work around cases where hwm=0,
|
// such as the repl. Also, if the push() triggered a
|
// readable event, and the user called read(largeNumber) such that
|
// needReadable was set, then we ought to push more, so that another
|
// 'readable' event will be triggered.
|
function needMoreData(state) {
|
return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
|
}
|
|
Readable.prototype.isPaused = function () {
|
return this._readableState.flowing === false;
|
};
|
|
// backwards compatibility.
|
Readable.prototype.setEncoding = function (enc) {
|
if (!StringDecoder) StringDecoder = __webpack_require__(10).StringDecoder;
|
this._readableState.decoder = new StringDecoder(enc);
|
this._readableState.encoding = enc;
|
return this;
|
};
|
|
// Don't raise the hwm > 8MB
|
var MAX_HWM = 0x800000;
|
function computeNewHighWaterMark(n) {
|
if (n >= MAX_HWM) {
|
n = MAX_HWM;
|
} else {
|
// Get the next highest power of 2 to prevent increasing hwm excessively in
|
// tiny amounts
|
n--;
|
n |= n >>> 1;
|
n |= n >>> 2;
|
n |= n >>> 4;
|
n |= n >>> 8;
|
n |= n >>> 16;
|
n++;
|
}
|
return n;
|
}
|
|
// This function is designed to be inlinable, so please take care when making
|
// changes to the function body.
|
function howMuchToRead(n, state) {
|
if (n <= 0 || state.length === 0 && state.ended) return 0;
|
if (state.objectMode) return 1;
|
if (n !== n) {
|
// Only flow one buffer at a time
|
if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
|
}
|
// If we're asking for more than the current hwm, then raise the hwm.
|
if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
|
if (n <= state.length) return n;
|
// Don't have enough
|
if (!state.ended) {
|
state.needReadable = true;
|
return 0;
|
}
|
return state.length;
|
}
|
|
// you can override either this method, or the async _read(n) below.
|
Readable.prototype.read = function (n) {
|
debug('read', n);
|
n = parseInt(n, 10);
|
var state = this._readableState;
|
var nOrig = n;
|
|
if (n !== 0) state.emittedReadable = false;
|
|
// if we're doing read(0) to trigger a readable event, but we
|
// already have a bunch of data in the buffer, then just trigger
|
// the 'readable' event and move on.
|
if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
|
debug('read: emitReadable', state.length, state.ended);
|
if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
|
return null;
|
}
|
|
n = howMuchToRead(n, state);
|
|
// if we've ended, and we're now clear, then finish it up.
|
if (n === 0 && state.ended) {
|
if (state.length === 0) endReadable(this);
|
return null;
|
}
|
|
// All the actual chunk generation logic needs to be
|
// *below* the call to _read. The reason is that in certain
|
// synthetic stream cases, such as passthrough streams, _read
|
// may be a completely synchronous operation which may change
|
// the state of the read buffer, providing enough data when
|
// before there was *not* enough.
|
//
|
// So, the steps are:
|
// 1. Figure out what the state of things will be after we do
|
// a read from the buffer.
|
//
|
// 2. If that resulting state will trigger a _read, then call _read.
|
// Note that this may be asynchronous, or synchronous. Yes, it is
|
// deeply ugly to write APIs this way, but that still doesn't mean
|
// that the Readable class should behave improperly, as streams are
|
// designed to be sync/async agnostic.
|
// Take note if the _read call is sync or async (ie, if the read call
|
// has returned yet), so that we know whether or not it's safe to emit
|
// 'readable' etc.
|
//
|
// 3. Actually pull the requested chunks out of the buffer and return.
|
|
// if we need a readable event, then we need to do some reading.
|
var doRead = state.needReadable;
|
debug('need readable', doRead);
|
|
// if we currently have less than the highWaterMark, then also read some
|
if (state.length === 0 || state.length - n < state.highWaterMark) {
|
doRead = true;
|
debug('length less than watermark', doRead);
|
}
|
|
// however, if we've ended, then there's no point, and if we're already
|
// reading, then it's unnecessary.
|
if (state.ended || state.reading) {
|
doRead = false;
|
debug('reading or ended', doRead);
|
} else if (doRead) {
|
debug('do read');
|
state.reading = true;
|
state.sync = true;
|
// if the length is currently zero, then we *need* a readable event.
|
if (state.length === 0) state.needReadable = true;
|
// call internal read method
|
this._read(state.highWaterMark);
|
state.sync = false;
|
// If _read pushed data synchronously, then `reading` will be false,
|
// and we need to re-evaluate how much data we can return to the user.
|
if (!state.reading) n = howMuchToRead(nOrig, state);
|
}
|
|
var ret;
|
if (n > 0) ret = fromList(n, state);else ret = null;
|
|
if (ret === null) {
|
state.needReadable = true;
|
n = 0;
|
} else {
|
state.length -= n;
|
}
|
|
if (state.length === 0) {
|
// If we have nothing in the buffer, then we want to know
|
// as soon as we *do* get something into the buffer.
|
if (!state.ended) state.needReadable = true;
|
|
// If we tried to read() past the EOF, then emit end on the next tick.
|
if (nOrig !== n && state.ended) endReadable(this);
|
}
|
|
if (ret !== null) this.emit('data', ret);
|
|
return ret;
|
};
|
|
function onEofChunk(stream, state) {
|
if (state.ended) return;
|
if (state.decoder) {
|
var chunk = state.decoder.end();
|
if (chunk && chunk.length) {
|
state.buffer.push(chunk);
|
state.length += state.objectMode ? 1 : chunk.length;
|
}
|
}
|
state.ended = true;
|
|
// emit 'readable' now to make sure it gets picked up.
|
emitReadable(stream);
|
}
|
|
// Don't emit readable right away in sync mode, because this can trigger
|
// another read() call => stack overflow. This way, it might trigger
|
// a nextTick recursion warning, but that's not so bad.
|
function emitReadable(stream) {
|
var state = stream._readableState;
|
state.needReadable = false;
|
if (!state.emittedReadable) {
|
debug('emitReadable', state.flowing);
|
state.emittedReadable = true;
|
if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
|
}
|
}
|
|
function emitReadable_(stream) {
|
debug('emit readable');
|
stream.emit('readable');
|
flow(stream);
|
}
|
|
// at this point, the user has presumably seen the 'readable' event,
|
// and called read() to consume some data. that may have triggered
|
// in turn another _read(n) call, in which case reading = true if
|
// it's in progress.
|
// However, if we're not ended, or reading, and the length < hwm,
|
// then go ahead and try to read some more preemptively.
|
function maybeReadMore(stream, state) {
|
if (!state.readingMore) {
|
state.readingMore = true;
|
pna.nextTick(maybeReadMore_, stream, state);
|
}
|
}
|
|
function maybeReadMore_(stream, state) {
|
var len = state.length;
|
while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
|
debug('maybeReadMore read 0');
|
stream.read(0);
|
if (len === state.length)
|
// didn't get any data, stop spinning.
|
break;else len = state.length;
|
}
|
state.readingMore = false;
|
}
|
|
// abstract method. to be overridden in specific implementation classes.
|
// call cb(er, data) where data is <= n in length.
|
// for virtual (non-string, non-buffer) streams, "length" is somewhat
|
// arbitrary, and perhaps not very meaningful.
|
Readable.prototype._read = function (n) {
|
this.emit('error', new Error('_read() is not implemented'));
|
};
|
|
Readable.prototype.pipe = function (dest, pipeOpts) {
|
var src = this;
|
var state = this._readableState;
|
|
switch (state.pipesCount) {
|
case 0:
|
state.pipes = dest;
|
break;
|
case 1:
|
state.pipes = [state.pipes, dest];
|
break;
|
default:
|
state.pipes.push(dest);
|
break;
|
}
|
state.pipesCount += 1;
|
debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
|
|
var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
|
|
var endFn = doEnd ? onend : unpipe;
|
if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
|
|
dest.on('unpipe', onunpipe);
|
function onunpipe(readable, unpipeInfo) {
|
debug('onunpipe');
|
if (readable === src) {
|
if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
|
unpipeInfo.hasUnpiped = true;
|
cleanup();
|
}
|
}
|
}
|
|
function onend() {
|
debug('onend');
|
dest.end();
|
}
|
|
// when the dest drains, it reduces the awaitDrain counter
|
// on the source. This would be more elegant with a .once()
|
// handler in flow(), but adding and removing repeatedly is
|
// too slow.
|
var ondrain = pipeOnDrain(src);
|
dest.on('drain', ondrain);
|
|
var cleanedUp = false;
|
function cleanup() {
|
debug('cleanup');
|
// cleanup event handlers once the pipe is broken
|
dest.removeListener('close', onclose);
|
dest.removeListener('finish', onfinish);
|
dest.removeListener('drain', ondrain);
|
dest.removeListener('error', onerror);
|
dest.removeListener('unpipe', onunpipe);
|
src.removeListener('end', onend);
|
src.removeListener('end', unpipe);
|
src.removeListener('data', ondata);
|
|
cleanedUp = true;
|
|
// if the reader is waiting for a drain event from this
|
// specific writer, then it would cause it to never start
|
// flowing again.
|
// So, if this is awaiting a drain, then we just call it now.
|
// If we don't know, then assume that we are waiting for one.
|
if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
|
}
|
|
// If the user pushes more data while we're writing to dest then we'll end up
|
// in ondata again. However, we only want to increase awaitDrain once because
|
// dest will only emit one 'drain' event for the multiple writes.
|
// => Introduce a guard on increasing awaitDrain.
|
var increasedAwaitDrain = false;
|
src.on('data', ondata);
|
function ondata(chunk) {
|
debug('ondata');
|
increasedAwaitDrain = false;
|
var ret = dest.write(chunk);
|
if (false === ret && !increasedAwaitDrain) {
|
// If the user unpiped during `dest.write()`, it is possible
|
// to get stuck in a permanently paused state if that write
|
// also returned false.
|
// => Check whether `dest` is still a piping destination.
|
if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
|
debug('false write response, pause', src._readableState.awaitDrain);
|
src._readableState.awaitDrain++;
|
increasedAwaitDrain = true;
|
}
|
src.pause();
|
}
|
}
|
|
// if the dest has an error, then stop piping into it.
|
// however, don't suppress the throwing behavior for this.
|
function onerror(er) {
|
debug('onerror', er);
|
unpipe();
|
dest.removeListener('error', onerror);
|
if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
|
}
|
|
// Make sure our error handler is attached before userland ones.
|
prependListener(dest, 'error', onerror);
|
|
// Both close and finish should trigger unpipe, but only once.
|
function onclose() {
|
dest.removeListener('finish', onfinish);
|
unpipe();
|
}
|
dest.once('close', onclose);
|
function onfinish() {
|
debug('onfinish');
|
dest.removeListener('close', onclose);
|
unpipe();
|
}
|
dest.once('finish', onfinish);
|
|
function unpipe() {
|
debug('unpipe');
|
src.unpipe(dest);
|
}
|
|
// tell the dest that it's being piped to
|
dest.emit('pipe', src);
|
|
// start the flow if it hasn't been started already.
|
if (!state.flowing) {
|
debug('pipe resume');
|
src.resume();
|
}
|
|
return dest;
|
};
|
|
function pipeOnDrain(src) {
|
return function () {
|
var state = src._readableState;
|
debug('pipeOnDrain', state.awaitDrain);
|
if (state.awaitDrain) state.awaitDrain--;
|
if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
|
state.flowing = true;
|
flow(src);
|
}
|
};
|
}
|
|
Readable.prototype.unpipe = function (dest) {
|
var state = this._readableState;
|
var unpipeInfo = { hasUnpiped: false };
|
|
// if we're not piping anywhere, then do nothing.
|
if (state.pipesCount === 0) return this;
|
|
// just one destination. most common case.
|
if (state.pipesCount === 1) {
|
// passed in one, but it's not the right one.
|
if (dest && dest !== state.pipes) return this;
|
|
if (!dest) dest = state.pipes;
|
|
// got a match.
|
state.pipes = null;
|
state.pipesCount = 0;
|
state.flowing = false;
|
if (dest) dest.emit('unpipe', this, unpipeInfo);
|
return this;
|
}
|
|
// slow case. multiple pipe destinations.
|
|
if (!dest) {
|
// remove all.
|
var dests = state.pipes;
|
var len = state.pipesCount;
|
state.pipes = null;
|
state.pipesCount = 0;
|
state.flowing = false;
|
|
for (var i = 0; i < len; i++) {
|
dests[i].emit('unpipe', this, unpipeInfo);
|
}return this;
|
}
|
|
// try to find the right one.
|
var index = indexOf(state.pipes, dest);
|
if (index === -1) return this;
|
|
state.pipes.splice(index, 1);
|
state.pipesCount -= 1;
|
if (state.pipesCount === 1) state.pipes = state.pipes[0];
|
|
dest.emit('unpipe', this, unpipeInfo);
|
|
return this;
|
};
|
|
// set up data events if they are asked for
|
// Ensure readable listeners eventually get something
|
Readable.prototype.on = function (ev, fn) {
|
var res = Stream.prototype.on.call(this, ev, fn);
|
|
if (ev === 'data') {
|
// Start flowing on next tick if stream isn't explicitly paused
|
if (this._readableState.flowing !== false) this.resume();
|
} else if (ev === 'readable') {
|
var state = this._readableState;
|
if (!state.endEmitted && !state.readableListening) {
|
state.readableListening = state.needReadable = true;
|
state.emittedReadable = false;
|
if (!state.reading) {
|
pna.nextTick(nReadingNextTick, this);
|
} else if (state.length) {
|
emitReadable(this);
|
}
|
}
|
}
|
|
return res;
|
};
|
Readable.prototype.addListener = Readable.prototype.on;
|
|
function nReadingNextTick(self) {
|
debug('readable nexttick read 0');
|
self.read(0);
|
}
|
|
// pause() and resume() are remnants of the legacy readable stream API
|
// If the user uses them, then switch into old mode.
|
Readable.prototype.resume = function () {
|
var state = this._readableState;
|
if (!state.flowing) {
|
debug('resume');
|
state.flowing = true;
|
resume(this, state);
|
}
|
return this;
|
};
|
|
function resume(stream, state) {
|
if (!state.resumeScheduled) {
|
state.resumeScheduled = true;
|
pna.nextTick(resume_, stream, state);
|
}
|
}
|
|
function resume_(stream, state) {
|
if (!state.reading) {
|
debug('resume read 0');
|
stream.read(0);
|
}
|
|
state.resumeScheduled = false;
|
state.awaitDrain = 0;
|
stream.emit('resume');
|
flow(stream);
|
if (state.flowing && !state.reading) stream.read(0);
|
}
|
|
Readable.prototype.pause = function () {
|
debug('call pause flowing=%j', this._readableState.flowing);
|
if (false !== this._readableState.flowing) {
|
debug('pause');
|
this._readableState.flowing = false;
|
this.emit('pause');
|
}
|
return this;
|
};
|
|
function flow(stream) {
|
var state = stream._readableState;
|
debug('flow', state.flowing);
|
while (state.flowing && stream.read() !== null) {}
|
}
|
|
// wrap an old-style stream as the async data source.
|
// This is *not* part of the readable stream interface.
|
// It is an ugly unfortunate mess of history.
|
Readable.prototype.wrap = function (stream) {
|
var _this = this;
|
|
var state = this._readableState;
|
var paused = false;
|
|
stream.on('end', function () {
|
debug('wrapped end');
|
if (state.decoder && !state.ended) {
|
var chunk = state.decoder.end();
|
if (chunk && chunk.length) _this.push(chunk);
|
}
|
|
_this.push(null);
|
});
|
|
stream.on('data', function (chunk) {
|
debug('wrapped data');
|
if (state.decoder) chunk = state.decoder.write(chunk);
|
|
// don't skip over falsy values in objectMode
|
if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
|
|
var ret = _this.push(chunk);
|
if (!ret) {
|
paused = true;
|
stream.pause();
|
}
|
});
|
|
// proxy all the other methods.
|
// important when wrapping filters and duplexes.
|
for (var i in stream) {
|
if (this[i] === undefined && typeof stream[i] === 'function') {
|
this[i] = function (method) {
|
return function () {
|
return stream[method].apply(stream, arguments);
|
};
|
}(i);
|
}
|
}
|
|
// proxy certain important events.
|
for (var n = 0; n < kProxyEvents.length; n++) {
|
stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
|
}
|
|
// when we try to consume some more bytes, simply unpause the
|
// underlying stream.
|
this._read = function (n) {
|
debug('wrapped _read', n);
|
if (paused) {
|
paused = false;
|
stream.resume();
|
}
|
};
|
|
return this;
|
};
|
|
Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
|
// making it explicit this property is not enumerable
|
// because otherwise some prototype manipulation in
|
// userland will fail
|
enumerable: false,
|
get: function () {
|
return this._readableState.highWaterMark;
|
}
|
});
|
|
// exposed for testing purposes only.
|
Readable._fromList = fromList;
|
|
// Pluck off n bytes from an array of buffers.
|
// Length is the combined lengths of all the buffers in the list.
|
// This function is designed to be inlinable, so please take care when making
|
// changes to the function body.
|
function fromList(n, state) {
|
// nothing buffered
|
if (state.length === 0) return null;
|
|
var ret;
|
if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
|
// read it all, truncate the list
|
if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
|
state.buffer.clear();
|
} else {
|
// read part of list
|
ret = fromListPartial(n, state.buffer, state.decoder);
|
}
|
|
return ret;
|
}
|
|
// Extracts only enough buffered data to satisfy the amount requested.
|
// This function is designed to be inlinable, so please take care when making
|
// changes to the function body.
|
function fromListPartial(n, list, hasStrings) {
|
var ret;
|
if (n < list.head.data.length) {
|
// slice is the same for buffers and strings
|
ret = list.head.data.slice(0, n);
|
list.head.data = list.head.data.slice(n);
|
} else if (n === list.head.data.length) {
|
// first chunk is a perfect match
|
ret = list.shift();
|
} else {
|
// result spans more than one buffer
|
ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
|
}
|
return ret;
|
}
|
|
// Copies a specified amount of characters from the list of buffered data
|
// chunks.
|
// This function is designed to be inlinable, so please take care when making
|
// changes to the function body.
|
function copyFromBufferString(n, list) {
|
var p = list.head;
|
var c = 1;
|
var ret = p.data;
|
n -= ret.length;
|
while (p = p.next) {
|
var str = p.data;
|
var nb = n > str.length ? str.length : n;
|
if (nb === str.length) ret += str;else ret += str.slice(0, n);
|
n -= nb;
|
if (n === 0) {
|
if (nb === str.length) {
|
++c;
|
if (p.next) list.head = p.next;else list.head = list.tail = null;
|
} else {
|
list.head = p;
|
p.data = str.slice(nb);
|
}
|
break;
|
}
|
++c;
|
}
|
list.length -= c;
|
return ret;
|
}
|
|
// Copies a specified amount of bytes from the list of buffered data chunks.
|
// This function is designed to be inlinable, so please take care when making
|
// changes to the function body.
|
function copyFromBuffer(n, list) {
|
var ret = Buffer.allocUnsafe(n);
|
var p = list.head;
|
var c = 1;
|
p.data.copy(ret);
|
n -= p.data.length;
|
while (p = p.next) {
|
var buf = p.data;
|
var nb = n > buf.length ? buf.length : n;
|
buf.copy(ret, ret.length - n, 0, nb);
|
n -= nb;
|
if (n === 0) {
|
if (nb === buf.length) {
|
++c;
|
if (p.next) list.head = p.next;else list.head = list.tail = null;
|
} else {
|
list.head = p;
|
p.data = buf.slice(nb);
|
}
|
break;
|
}
|
++c;
|
}
|
list.length -= c;
|
return ret;
|
}
|
|
function endReadable(stream) {
|
var state = stream._readableState;
|
|
// If we get here before consuming all the bytes, then that is a
|
// bug in node. Should never happen.
|
if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
|
|
if (!state.endEmitted) {
|
state.ended = true;
|
pna.nextTick(endReadableNT, state, stream);
|
}
|
}
|
|
function endReadableNT(state, stream) {
|
// Check that we didn't get one last unshift.
|
if (!state.endEmitted && state.length === 0) {
|
state.endEmitted = true;
|
stream.readable = false;
|
stream.emit('end');
|
}
|
}
|
|
function indexOf(xs, x) {
|
for (var i = 0, l = xs.length; i < l; i++) {
|
if (xs[i] === x) return i;
|
}
|
return -1;
|
}
|
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(1), __webpack_require__(4)))
|
|
/***/ }),
|
/* 21 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
"use strict";
|
// Copyright Joyent, Inc. and other Node contributors.
|
//
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
// copy of this software and associated documentation files (the
|
// "Software"), to deal in the Software without restriction, including
|
// without limitation the rights to use, copy, modify, merge, publish,
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
// persons to whom the Software is furnished to do so, subject to the
|
// following conditions:
|
//
|
// The above copyright notice and this permission notice shall be included
|
// in all copies or substantial portions of the Software.
|
//
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
var R = typeof Reflect === 'object' ? Reflect : null
|
var ReflectApply = R && typeof R.apply === 'function'
|
? R.apply
|
: function ReflectApply(target, receiver, args) {
|
return Function.prototype.apply.call(target, receiver, args);
|
}
|
|
var ReflectOwnKeys
|
if (R && typeof R.ownKeys === 'function') {
|
ReflectOwnKeys = R.ownKeys
|
} else if (Object.getOwnPropertySymbols) {
|
ReflectOwnKeys = function ReflectOwnKeys(target) {
|
return Object.getOwnPropertyNames(target)
|
.concat(Object.getOwnPropertySymbols(target));
|
};
|
} else {
|
ReflectOwnKeys = function ReflectOwnKeys(target) {
|
return Object.getOwnPropertyNames(target);
|
};
|
}
|
|
function ProcessEmitWarning(warning) {
|
if (console && console.warn) console.warn(warning);
|
}
|
|
var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
|
return value !== value;
|
}
|
|
function EventEmitter() {
|
EventEmitter.init.call(this);
|
}
|
module.exports = EventEmitter;
|
module.exports.once = once;
|
|
// Backwards-compat with node 0.10.x
|
EventEmitter.EventEmitter = EventEmitter;
|
|
EventEmitter.prototype._events = undefined;
|
EventEmitter.prototype._eventsCount = 0;
|
EventEmitter.prototype._maxListeners = undefined;
|
|
// By default EventEmitters will print a warning if more than 10 listeners are
|
// added to it. This is a useful default which helps finding memory leaks.
|
var defaultMaxListeners = 10;
|
|
function checkListener(listener) {
|
if (typeof listener !== 'function') {
|
throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
|
}
|
}
|
|
Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
|
enumerable: true,
|
get: function() {
|
return defaultMaxListeners;
|
},
|
set: function(arg) {
|
if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
|
throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
|
}
|
defaultMaxListeners = arg;
|
}
|
});
|
|
EventEmitter.init = function() {
|
|
if (this._events === undefined ||
|
this._events === Object.getPrototypeOf(this)._events) {
|
this._events = Object.create(null);
|
this._eventsCount = 0;
|
}
|
|
this._maxListeners = this._maxListeners || undefined;
|
};
|
|
// Obviously not all Emitters should be limited to 10. This function allows
|
// that to be increased. Set to zero for unlimited.
|
EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
|
if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
|
throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
|
}
|
this._maxListeners = n;
|
return this;
|
};
|
|
function _getMaxListeners(that) {
|
if (that._maxListeners === undefined)
|
return EventEmitter.defaultMaxListeners;
|
return that._maxListeners;
|
}
|
|
EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
|
return _getMaxListeners(this);
|
};
|
|
EventEmitter.prototype.emit = function emit(type) {
|
var args = [];
|
for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
|
var doError = (type === 'error');
|
|
var events = this._events;
|
if (events !== undefined)
|
doError = (doError && events.error === undefined);
|
else if (!doError)
|
return false;
|
|
// If there is no 'error' event listener then throw.
|
if (doError) {
|
var er;
|
if (args.length > 0)
|
er = args[0];
|
if (er instanceof Error) {
|
// Note: The comments on the `throw` lines are intentional, they show
|
// up in Node's output if this results in an unhandled exception.
|
throw er; // Unhandled 'error' event
|
}
|
// At least give some kind of context to the user
|
var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
|
err.context = er;
|
throw err; // Unhandled 'error' event
|
}
|
|
var handler = events[type];
|
|
if (handler === undefined)
|
return false;
|
|
if (typeof handler === 'function') {
|
ReflectApply(handler, this, args);
|
} else {
|
var len = handler.length;
|
var listeners = arrayClone(handler, len);
|
for (var i = 0; i < len; ++i)
|
ReflectApply(listeners[i], this, args);
|
}
|
|
return true;
|
};
|
|
function _addListener(target, type, listener, prepend) {
|
var m;
|
var events;
|
var existing;
|
|
checkListener(listener);
|
|
events = target._events;
|
if (events === undefined) {
|
events = target._events = Object.create(null);
|
target._eventsCount = 0;
|
} else {
|
// To avoid recursion in the case that type === "newListener"! Before
|
// adding it to the listeners, first emit "newListener".
|
if (events.newListener !== undefined) {
|
target.emit('newListener', type,
|
listener.listener ? listener.listener : listener);
|
|
// Re-assign `events` because a newListener handler could have caused the
|
// this._events to be assigned to a new object
|
events = target._events;
|
}
|
existing = events[type];
|
}
|
|
if (existing === undefined) {
|
// Optimize the case of one listener. Don't need the extra array object.
|
existing = events[type] = listener;
|
++target._eventsCount;
|
} else {
|
if (typeof existing === 'function') {
|
// Adding the second element, need to change to array.
|
existing = events[type] =
|
prepend ? [listener, existing] : [existing, listener];
|
// If we've already got an array, just append.
|
} else if (prepend) {
|
existing.unshift(listener);
|
} else {
|
existing.push(listener);
|
}
|
|
// Check for listener leak
|
m = _getMaxListeners(target);
|
if (m > 0 && existing.length > m && !existing.warned) {
|
existing.warned = true;
|
// No error code for this since it is a Warning
|
// eslint-disable-next-line no-restricted-syntax
|
var w = new Error('Possible EventEmitter memory leak detected. ' +
|
existing.length + ' ' + String(type) + ' listeners ' +
|
'added. Use emitter.setMaxListeners() to ' +
|
'increase limit');
|
w.name = 'MaxListenersExceededWarning';
|
w.emitter = target;
|
w.type = type;
|
w.count = existing.length;
|
ProcessEmitWarning(w);
|
}
|
}
|
|
return target;
|
}
|
|
EventEmitter.prototype.addListener = function addListener(type, listener) {
|
return _addListener(this, type, listener, false);
|
};
|
|
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
|
EventEmitter.prototype.prependListener =
|
function prependListener(type, listener) {
|
return _addListener(this, type, listener, true);
|
};
|
|
function onceWrapper() {
|
if (!this.fired) {
|
this.target.removeListener(this.type, this.wrapFn);
|
this.fired = true;
|
if (arguments.length === 0)
|
return this.listener.call(this.target);
|
return this.listener.apply(this.target, arguments);
|
}
|
}
|
|
function _onceWrap(target, type, listener) {
|
var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
|
var wrapped = onceWrapper.bind(state);
|
wrapped.listener = listener;
|
state.wrapFn = wrapped;
|
return wrapped;
|
}
|
|
EventEmitter.prototype.once = function once(type, listener) {
|
checkListener(listener);
|
this.on(type, _onceWrap(this, type, listener));
|
return this;
|
};
|
|
EventEmitter.prototype.prependOnceListener =
|
function prependOnceListener(type, listener) {
|
checkListener(listener);
|
this.prependListener(type, _onceWrap(this, type, listener));
|
return this;
|
};
|
|
// Emits a 'removeListener' event if and only if the listener was removed.
|
EventEmitter.prototype.removeListener =
|
function removeListener(type, listener) {
|
var list, events, position, i, originalListener;
|
|
checkListener(listener);
|
|
events = this._events;
|
if (events === undefined)
|
return this;
|
|
list = events[type];
|
if (list === undefined)
|
return this;
|
|
if (list === listener || list.listener === listener) {
|
if (--this._eventsCount === 0)
|
this._events = Object.create(null);
|
else {
|
delete events[type];
|
if (events.removeListener)
|
this.emit('removeListener', type, list.listener || listener);
|
}
|
} else if (typeof list !== 'function') {
|
position = -1;
|
|
for (i = list.length - 1; i >= 0; i--) {
|
if (list[i] === listener || list[i].listener === listener) {
|
originalListener = list[i].listener;
|
position = i;
|
break;
|
}
|
}
|
|
if (position < 0)
|
return this;
|
|
if (position === 0)
|
list.shift();
|
else {
|
spliceOne(list, position);
|
}
|
|
if (list.length === 1)
|
events[type] = list[0];
|
|
if (events.removeListener !== undefined)
|
this.emit('removeListener', type, originalListener || listener);
|
}
|
|
return this;
|
};
|
|
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
EventEmitter.prototype.removeAllListeners =
|
function removeAllListeners(type) {
|
var listeners, events, i;
|
|
events = this._events;
|
if (events === undefined)
|
return this;
|
|
// not listening for removeListener, no need to emit
|
if (events.removeListener === undefined) {
|
if (arguments.length === 0) {
|
this._events = Object.create(null);
|
this._eventsCount = 0;
|
} else if (events[type] !== undefined) {
|
if (--this._eventsCount === 0)
|
this._events = Object.create(null);
|
else
|
delete events[type];
|
}
|
return this;
|
}
|
|
// emit removeListener for all listeners on all events
|
if (arguments.length === 0) {
|
var keys = Object.keys(events);
|
var key;
|
for (i = 0; i < keys.length; ++i) {
|
key = keys[i];
|
if (key === 'removeListener') continue;
|
this.removeAllListeners(key);
|
}
|
this.removeAllListeners('removeListener');
|
this._events = Object.create(null);
|
this._eventsCount = 0;
|
return this;
|
}
|
|
listeners = events[type];
|
|
if (typeof listeners === 'function') {
|
this.removeListener(type, listeners);
|
} else if (listeners !== undefined) {
|
// LIFO order
|
for (i = listeners.length - 1; i >= 0; i--) {
|
this.removeListener(type, listeners[i]);
|
}
|
}
|
|
return this;
|
};
|
|
function _listeners(target, type, unwrap) {
|
var events = target._events;
|
|
if (events === undefined)
|
return [];
|
|
var evlistener = events[type];
|
if (evlistener === undefined)
|
return [];
|
|
if (typeof evlistener === 'function')
|
return unwrap ? [evlistener.listener || evlistener] : [evlistener];
|
|
return unwrap ?
|
unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
|
}
|
|
EventEmitter.prototype.listeners = function listeners(type) {
|
return _listeners(this, type, true);
|
};
|
|
EventEmitter.prototype.rawListeners = function rawListeners(type) {
|
return _listeners(this, type, false);
|
};
|
|
EventEmitter.listenerCount = function(emitter, type) {
|
if (typeof emitter.listenerCount === 'function') {
|
return emitter.listenerCount(type);
|
} else {
|
return listenerCount.call(emitter, type);
|
}
|
};
|
|
EventEmitter.prototype.listenerCount = listenerCount;
|
function listenerCount(type) {
|
var events = this._events;
|
|
if (events !== undefined) {
|
var evlistener = events[type];
|
|
if (typeof evlistener === 'function') {
|
return 1;
|
} else if (evlistener !== undefined) {
|
return evlistener.length;
|
}
|
}
|
|
return 0;
|
}
|
|
EventEmitter.prototype.eventNames = function eventNames() {
|
return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
|
};
|
|
function arrayClone(arr, n) {
|
var copy = new Array(n);
|
for (var i = 0; i < n; ++i)
|
copy[i] = arr[i];
|
return copy;
|
}
|
|
function spliceOne(list, index) {
|
for (; index + 1 < list.length; index++)
|
list[index] = list[index + 1];
|
list.pop();
|
}
|
|
function unwrapListeners(arr) {
|
var ret = new Array(arr.length);
|
for (var i = 0; i < ret.length; ++i) {
|
ret[i] = arr[i].listener || arr[i];
|
}
|
return ret;
|
}
|
|
function once(emitter, name) {
|
return new Promise(function (resolve, reject) {
|
function errorListener(err) {
|
emitter.removeListener(name, resolver);
|
reject(err);
|
}
|
|
function resolver() {
|
if (typeof emitter.removeListener === 'function') {
|
emitter.removeListener('error', errorListener);
|
}
|
resolve([].slice.call(arguments));
|
};
|
|
eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
|
if (name !== 'error') {
|
addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
|
}
|
});
|
}
|
|
function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
|
if (typeof emitter.on === 'function') {
|
eventTargetAgnosticAddListener(emitter, 'error', handler, flags);
|
}
|
}
|
|
function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
|
if (typeof emitter.on === 'function') {
|
if (flags.once) {
|
emitter.once(name, listener);
|
} else {
|
emitter.on(name, listener);
|
}
|
} else if (typeof emitter.addEventListener === 'function') {
|
// EventTarget does not have `error` event semantics like Node
|
// EventEmitters, we do not listen for `error` events here.
|
emitter.addEventListener(name, function wrapListener(arg) {
|
// IE does not have builtin `{ once: true }` support so we
|
// have to do it manually.
|
if (flags.once) {
|
emitter.removeEventListener(name, wrapListener);
|
}
|
listener(arg);
|
});
|
} else {
|
throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
|
}
|
}
|
|
|
/***/ }),
|
/* 22 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
module.exports = __webpack_require__(21).EventEmitter;
|
|
|
/***/ }),
|
/* 23 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
"use strict";
|
|
|
/*<replacement>*/
|
|
var pna = __webpack_require__(9);
|
/*</replacement>*/
|
|
// undocumented cb() API, needed for core, not for public API
|
function destroy(err, cb) {
|
var _this = this;
|
|
var readableDestroyed = this._readableState && this._readableState.destroyed;
|
var writableDestroyed = this._writableState && this._writableState.destroyed;
|
|
if (readableDestroyed || writableDestroyed) {
|
if (cb) {
|
cb(err);
|
} else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
|
pna.nextTick(emitErrorNT, this, err);
|
}
|
return this;
|
}
|
|
// we set destroyed to true before firing error callbacks in order
|
// to make it re-entrance safe in case destroy() is called within callbacks
|
|
if (this._readableState) {
|
this._readableState.destroyed = true;
|
}
|
|
// if this is a duplex stream mark the writable part as destroyed as well
|
if (this._writableState) {
|
this._writableState.destroyed = true;
|
}
|
|
this._destroy(err || null, function (err) {
|
if (!cb && err) {
|
pna.nextTick(emitErrorNT, _this, err);
|
if (_this._writableState) {
|
_this._writableState.errorEmitted = true;
|
}
|
} else if (cb) {
|
cb(err);
|
}
|
});
|
|
return this;
|
}
|
|
function undestroy() {
|
if (this._readableState) {
|
this._readableState.destroyed = false;
|
this._readableState.reading = false;
|
this._readableState.ended = false;
|
this._readableState.endEmitted = false;
|
}
|
|
if (this._writableState) {
|
this._writableState.destroyed = false;
|
this._writableState.ended = false;
|
this._writableState.ending = false;
|
this._writableState.finished = false;
|
this._writableState.errorEmitted = false;
|
}
|
}
|
|
function emitErrorNT(self, err) {
|
self.emit('error', err);
|
}
|
|
module.exports = {
|
destroy: destroy,
|
undestroy: undestroy
|
};
|
|
/***/ }),
|
/* 24 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
"use strict";
|
/* WEBPACK VAR INJECTION */(function(process, setImmediate, global) {// Copyright Joyent, Inc. and other Node contributors.
|
//
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
// copy of this software and associated documentation files (the
|
// "Software"), to deal in the Software without restriction, including
|
// without limitation the rights to use, copy, modify, merge, publish,
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
// persons to whom the Software is furnished to do so, subject to the
|
// following conditions:
|
//
|
// The above copyright notice and this permission notice shall be included
|
// in all copies or substantial portions of the Software.
|
//
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
// A bit simpler than readable streams.
|
// Implement an async ._write(chunk, encoding, cb), and it'll handle all
|
// the drain event emission and buffering.
|
|
|
|
/*<replacement>*/
|
|
var pna = __webpack_require__(9);
|
/*</replacement>*/
|
|
module.exports = Writable;
|
|
/* <replacement> */
|
function WriteReq(chunk, encoding, cb) {
|
this.chunk = chunk;
|
this.encoding = encoding;
|
this.callback = cb;
|
this.next = null;
|
}
|
|
// It seems a linked list but it is not
|
// there will be only 2 of these for each stream
|
function CorkedRequest(state) {
|
var _this = this;
|
|
this.next = null;
|
this.entry = null;
|
this.finish = function () {
|
onCorkedFinish(_this, state);
|
};
|
}
|
/* </replacement> */
|
|
/*<replacement>*/
|
var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
|
/*</replacement>*/
|
|
/*<replacement>*/
|
var Duplex;
|
/*</replacement>*/
|
|
Writable.WritableState = WritableState;
|
|
/*<replacement>*/
|
var util = Object.create(__webpack_require__(8));
|
util.inherits = __webpack_require__(5);
|
/*</replacement>*/
|
|
/*<replacement>*/
|
var internalUtil = {
|
deprecate: __webpack_require__(54)
|
};
|
/*</replacement>*/
|
|
/*<replacement>*/
|
var Stream = __webpack_require__(22);
|
/*</replacement>*/
|
|
/*<replacement>*/
|
|
var Buffer = __webpack_require__(11).Buffer;
|
var OurUint8Array = global.Uint8Array || function () {};
|
function _uint8ArrayToBuffer(chunk) {
|
return Buffer.from(chunk);
|
}
|
function _isUint8Array(obj) {
|
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
}
|
|
/*</replacement>*/
|
|
var destroyImpl = __webpack_require__(23);
|
|
util.inherits(Writable, Stream);
|
|
function nop() {}
|
|
function WritableState(options, stream) {
|
Duplex = Duplex || __webpack_require__(6);
|
|
options = options || {};
|
|
// Duplex streams are both readable and writable, but share
|
// the same options object.
|
// However, some cases require setting options to different
|
// values for the readable and the writable sides of the duplex stream.
|
// These options can be provided separately as readableXXX and writableXXX.
|
var isDuplex = stream instanceof Duplex;
|
|
// object stream flag to indicate whether or not this stream
|
// contains buffers or objects.
|
this.objectMode = !!options.objectMode;
|
|
if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
|
|
// the point at which write() starts returning false
|
// Note: 0 is a valid value, means that we always return false if
|
// the entire buffer is not flushed immediately on write()
|
var hwm = options.highWaterMark;
|
var writableHwm = options.writableHighWaterMark;
|
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
|
|
if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
|
|
// cast to ints.
|
this.highWaterMark = Math.floor(this.highWaterMark);
|
|
// if _final has been called
|
this.finalCalled = false;
|
|
// drain event flag.
|
this.needDrain = false;
|
// at the start of calling end()
|
this.ending = false;
|
// when end() has been called, and returned
|
this.ended = false;
|
// when 'finish' is emitted
|
this.finished = false;
|
|
// has it been destroyed
|
this.destroyed = false;
|
|
// should we decode strings into buffers before passing to _write?
|
// this is here so that some node-core streams can optimize string
|
// handling at a lower level.
|
var noDecode = options.decodeStrings === false;
|
this.decodeStrings = !noDecode;
|
|
// Crypto is kind of old and crusty. Historically, its default string
|
// encoding is 'binary' so we have to make this configurable.
|
// Everything else in the universe uses 'utf8', though.
|
this.defaultEncoding = options.defaultEncoding || 'utf8';
|
|
// not an actual buffer we keep track of, but a measurement
|
// of how much we're waiting to get pushed to some underlying
|
// socket or file.
|
this.length = 0;
|
|
// a flag to see when we're in the middle of a write.
|
this.writing = false;
|
|
// when true all writes will be buffered until .uncork() call
|
this.corked = 0;
|
|
// a flag to be able to tell if the onwrite cb is called immediately,
|
// or on a later tick. We set this to true at first, because any
|
// actions that shouldn't happen until "later" should generally also
|
// not happen before the first write call.
|
this.sync = true;
|
|
// a flag to know if we're processing previously buffered items, which
|
// may call the _write() callback in the same tick, so that we don't
|
// end up in an overlapped onwrite situation.
|
this.bufferProcessing = false;
|
|
// the callback that's passed to _write(chunk,cb)
|
this.onwrite = function (er) {
|
onwrite(stream, er);
|
};
|
|
// the callback that the user supplies to write(chunk,encoding,cb)
|
this.writecb = null;
|
|
// the amount that is being written when _write is called.
|
this.writelen = 0;
|
|
this.bufferedRequest = null;
|
this.lastBufferedRequest = null;
|
|
// number of pending user-supplied write callbacks
|
// this must be 0 before 'finish' can be emitted
|
this.pendingcb = 0;
|
|
// emit prefinish if the only thing we're waiting for is _write cbs
|
// This is relevant for synchronous Transform streams
|
this.prefinished = false;
|
|
// True if the error was already emitted and should not be thrown again
|
this.errorEmitted = false;
|
|
// count buffered requests
|
this.bufferedRequestCount = 0;
|
|
// allocate the first CorkedRequest, there is always
|
// one allocated and free to use, and we maintain at most two
|
this.corkedRequestsFree = new CorkedRequest(this);
|
}
|
|
WritableState.prototype.getBuffer = function getBuffer() {
|
var current = this.bufferedRequest;
|
var out = [];
|
while (current) {
|
out.push(current);
|
current = current.next;
|
}
|
return out;
|
};
|
|
(function () {
|
try {
|
Object.defineProperty(WritableState.prototype, 'buffer', {
|
get: internalUtil.deprecate(function () {
|
return this.getBuffer();
|
}, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
|
});
|
} catch (_) {}
|
})();
|
|
// Test _writableState for inheritance to account for Duplex streams,
|
// whose prototype chain only points to Readable.
|
var realHasInstance;
|
if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
|
realHasInstance = Function.prototype[Symbol.hasInstance];
|
Object.defineProperty(Writable, Symbol.hasInstance, {
|
value: function (object) {
|
if (realHasInstance.call(this, object)) return true;
|
if (this !== Writable) return false;
|
|
return object && object._writableState instanceof WritableState;
|
}
|
});
|
} else {
|
realHasInstance = function (object) {
|
return object instanceof this;
|
};
|
}
|
|
function Writable(options) {
|
Duplex = Duplex || __webpack_require__(6);
|
|
// Writable ctor is applied to Duplexes, too.
|
// `realHasInstance` is necessary because using plain `instanceof`
|
// would return false, as no `_writableState` property is attached.
|
|
// Trying to use the custom `instanceof` for Writable here will also break the
|
// Node.js LazyTransform implementation, which has a non-trivial getter for
|
// `_writableState` that would lead to infinite recursion.
|
if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
|
return new Writable(options);
|
}
|
|
this._writableState = new WritableState(options, this);
|
|
// legacy.
|
this.writable = true;
|
|
if (options) {
|
if (typeof options.write === 'function') this._write = options.write;
|
|
if (typeof options.writev === 'function') this._writev = options.writev;
|
|
if (typeof options.destroy === 'function') this._destroy = options.destroy;
|
|
if (typeof options.final === 'function') this._final = options.final;
|
}
|
|
Stream.call(this);
|
}
|
|
// Otherwise people can pipe Writable streams, which is just wrong.
|
Writable.prototype.pipe = function () {
|
this.emit('error', new Error('Cannot pipe, not readable'));
|
};
|
|
function writeAfterEnd(stream, cb) {
|
var er = new Error('write after end');
|
// TODO: defer error events consistently everywhere, not just the cb
|
stream.emit('error', er);
|
pna.nextTick(cb, er);
|
}
|
|
// Checks that a user-supplied chunk is valid, especially for the particular
|
// mode the stream is in. Currently this means that `null` is never accepted
|
// and undefined/non-string values are only allowed in object mode.
|
function validChunk(stream, state, chunk, cb) {
|
var valid = true;
|
var er = false;
|
|
if (chunk === null) {
|
er = new TypeError('May not write null values to stream');
|
} else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
|
er = new TypeError('Invalid non-string/buffer chunk');
|
}
|
if (er) {
|
stream.emit('error', er);
|
pna.nextTick(cb, er);
|
valid = false;
|
}
|
return valid;
|
}
|
|
Writable.prototype.write = function (chunk, encoding, cb) {
|
var state = this._writableState;
|
var ret = false;
|
var isBuf = !state.objectMode && _isUint8Array(chunk);
|
|
if (isBuf && !Buffer.isBuffer(chunk)) {
|
chunk = _uint8ArrayToBuffer(chunk);
|
}
|
|
if (typeof encoding === 'function') {
|
cb = encoding;
|
encoding = null;
|
}
|
|
if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
|
|
if (typeof cb !== 'function') cb = nop;
|
|
if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
|
state.pendingcb++;
|
ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
|
}
|
|
return ret;
|
};
|
|
Writable.prototype.cork = function () {
|
var state = this._writableState;
|
|
state.corked++;
|
};
|
|
Writable.prototype.uncork = function () {
|
var state = this._writableState;
|
|
if (state.corked) {
|
state.corked--;
|
|
if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
|
}
|
};
|
|
Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
|
// node::ParseEncoding() requires lower case.
|
if (typeof encoding === 'string') encoding = encoding.toLowerCase();
|
if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
|
this._writableState.defaultEncoding = encoding;
|
return this;
|
};
|
|
function decodeChunk(state, chunk, encoding) {
|
if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
|
chunk = Buffer.from(chunk, encoding);
|
}
|
return chunk;
|
}
|
|
Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
|
// making it explicit this property is not enumerable
|
// because otherwise some prototype manipulation in
|
// userland will fail
|
enumerable: false,
|
get: function () {
|
return this._writableState.highWaterMark;
|
}
|
});
|
|
// if we're already writing something, then just put this
|
// in the queue, and wait our turn. Otherwise, call _write
|
// If we return false, then we need a drain event, so set that flag.
|
function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
|
if (!isBuf) {
|
var newChunk = decodeChunk(state, chunk, encoding);
|
if (chunk !== newChunk) {
|
isBuf = true;
|
encoding = 'buffer';
|
chunk = newChunk;
|
}
|
}
|
var len = state.objectMode ? 1 : chunk.length;
|
|
state.length += len;
|
|
var ret = state.length < state.highWaterMark;
|
// we must ensure that previous needDrain will not be reset to false.
|
if (!ret) state.needDrain = true;
|
|
if (state.writing || state.corked) {
|
var last = state.lastBufferedRequest;
|
state.lastBufferedRequest = {
|
chunk: chunk,
|
encoding: encoding,
|
isBuf: isBuf,
|
callback: cb,
|
next: null
|
};
|
if (last) {
|
last.next = state.lastBufferedRequest;
|
} else {
|
state.bufferedRequest = state.lastBufferedRequest;
|
}
|
state.bufferedRequestCount += 1;
|
} else {
|
doWrite(stream, state, false, len, chunk, encoding, cb);
|
}
|
|
return ret;
|
}
|
|
function doWrite(stream, state, writev, len, chunk, encoding, cb) {
|
state.writelen = len;
|
state.writecb = cb;
|
state.writing = true;
|
state.sync = true;
|
if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
|
state.sync = false;
|
}
|
|
function onwriteError(stream, state, sync, er, cb) {
|
--state.pendingcb;
|
|
if (sync) {
|
// defer the callback if we are being called synchronously
|
// to avoid piling up things on the stack
|
pna.nextTick(cb, er);
|
// this can emit finish, and it will always happen
|
// after error
|
pna.nextTick(finishMaybe, stream, state);
|
stream._writableState.errorEmitted = true;
|
stream.emit('error', er);
|
} else {
|
// the caller expect this to happen before if
|
// it is async
|
cb(er);
|
stream._writableState.errorEmitted = true;
|
stream.emit('error', er);
|
// this can emit finish, but finish must
|
// always follow error
|
finishMaybe(stream, state);
|
}
|
}
|
|
function onwriteStateUpdate(state) {
|
state.writing = false;
|
state.writecb = null;
|
state.length -= state.writelen;
|
state.writelen = 0;
|
}
|
|
function onwrite(stream, er) {
|
var state = stream._writableState;
|
var sync = state.sync;
|
var cb = state.writecb;
|
|
onwriteStateUpdate(state);
|
|
if (er) onwriteError(stream, state, sync, er, cb);else {
|
// Check if we're actually ready to finish, but don't emit yet
|
var finished = needFinish(state);
|
|
if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
|
clearBuffer(stream, state);
|
}
|
|
if (sync) {
|
/*<replacement>*/
|
asyncWrite(afterWrite, stream, state, finished, cb);
|
/*</replacement>*/
|
} else {
|
afterWrite(stream, state, finished, cb);
|
}
|
}
|
}
|
|
function afterWrite(stream, state, finished, cb) {
|
if (!finished) onwriteDrain(stream, state);
|
state.pendingcb--;
|
cb();
|
finishMaybe(stream, state);
|
}
|
|
// Must force callback to be called on nextTick, so that we don't
|
// emit 'drain' before the write() consumer gets the 'false' return
|
// value, and has a chance to attach a 'drain' listener.
|
function onwriteDrain(stream, state) {
|
if (state.length === 0 && state.needDrain) {
|
state.needDrain = false;
|
stream.emit('drain');
|
}
|
}
|
|
// if there's something in the buffer waiting, then process it
|
function clearBuffer(stream, state) {
|
state.bufferProcessing = true;
|
var entry = state.bufferedRequest;
|
|
if (stream._writev && entry && entry.next) {
|
// Fast case, write everything using _writev()
|
var l = state.bufferedRequestCount;
|
var buffer = new Array(l);
|
var holder = state.corkedRequestsFree;
|
holder.entry = entry;
|
|
var count = 0;
|
var allBuffers = true;
|
while (entry) {
|
buffer[count] = entry;
|
if (!entry.isBuf) allBuffers = false;
|
entry = entry.next;
|
count += 1;
|
}
|
buffer.allBuffers = allBuffers;
|
|
doWrite(stream, state, true, state.length, buffer, '', holder.finish);
|
|
// doWrite is almost always async, defer these to save a bit of time
|
// as the hot path ends with doWrite
|
state.pendingcb++;
|
state.lastBufferedRequest = null;
|
if (holder.next) {
|
state.corkedRequestsFree = holder.next;
|
holder.next = null;
|
} else {
|
state.corkedRequestsFree = new CorkedRequest(state);
|
}
|
state.bufferedRequestCount = 0;
|
} else {
|
// Slow case, write chunks one-by-one
|
while (entry) {
|
var chunk = entry.chunk;
|
var encoding = entry.encoding;
|
var cb = entry.callback;
|
var len = state.objectMode ? 1 : chunk.length;
|
|
doWrite(stream, state, false, len, chunk, encoding, cb);
|
entry = entry.next;
|
state.bufferedRequestCount--;
|
// if we didn't call the onwrite immediately, then
|
// it means that we need to wait until it does.
|
// also, that means that the chunk and cb are currently
|
// being processed, so move the buffer counter past them.
|
if (state.writing) {
|
break;
|
}
|
}
|
|
if (entry === null) state.lastBufferedRequest = null;
|
}
|
|
state.bufferedRequest = entry;
|
state.bufferProcessing = false;
|
}
|
|
Writable.prototype._write = function (chunk, encoding, cb) {
|
cb(new Error('_write() is not implemented'));
|
};
|
|
Writable.prototype._writev = null;
|
|
Writable.prototype.end = function (chunk, encoding, cb) {
|
var state = this._writableState;
|
|
if (typeof chunk === 'function') {
|
cb = chunk;
|
chunk = null;
|
encoding = null;
|
} else if (typeof encoding === 'function') {
|
cb = encoding;
|
encoding = null;
|
}
|
|
if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
|
|
// .end() fully uncorks
|
if (state.corked) {
|
state.corked = 1;
|
this.uncork();
|
}
|
|
// ignore unnecessary end() calls.
|
if (!state.ending && !state.finished) endWritable(this, state, cb);
|
};
|
|
function needFinish(state) {
|
return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
|
}
|
function callFinal(stream, state) {
|
stream._final(function (err) {
|
state.pendingcb--;
|
if (err) {
|
stream.emit('error', err);
|
}
|
state.prefinished = true;
|
stream.emit('prefinish');
|
finishMaybe(stream, state);
|
});
|
}
|
function prefinish(stream, state) {
|
if (!state.prefinished && !state.finalCalled) {
|
if (typeof stream._final === 'function') {
|
state.pendingcb++;
|
state.finalCalled = true;
|
pna.nextTick(callFinal, stream, state);
|
} else {
|
state.prefinished = true;
|
stream.emit('prefinish');
|
}
|
}
|
}
|
|
function finishMaybe(stream, state) {
|
var need = needFinish(state);
|
if (need) {
|
prefinish(stream, state);
|
if (state.pendingcb === 0) {
|
state.finished = true;
|
stream.emit('finish');
|
}
|
}
|
return need;
|
}
|
|
function endWritable(stream, state, cb) {
|
state.ending = true;
|
finishMaybe(stream, state);
|
if (cb) {
|
if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
|
}
|
state.ended = true;
|
stream.writable = false;
|
}
|
|
function onCorkedFinish(corkReq, state, err) {
|
var entry = corkReq.entry;
|
corkReq.entry = null;
|
while (entry) {
|
var cb = entry.callback;
|
state.pendingcb--;
|
cb(err);
|
entry = entry.next;
|
}
|
if (state.corkedRequestsFree) {
|
state.corkedRequestsFree.next = corkReq;
|
} else {
|
state.corkedRequestsFree = corkReq;
|
}
|
}
|
|
Object.defineProperty(Writable.prototype, 'destroyed', {
|
get: function () {
|
if (this._writableState === undefined) {
|
return false;
|
}
|
return this._writableState.destroyed;
|
},
|
set: function (value) {
|
// we ignore the value if the stream
|
// has not been initialized yet
|
if (!this._writableState) {
|
return;
|
}
|
|
// backward compatibility, the user is explicitly
|
// managing destroyed
|
this._writableState.destroyed = value;
|
}
|
});
|
|
Writable.prototype.destroy = destroyImpl.destroy;
|
Writable.prototype._undestroy = destroyImpl.undestroy;
|
Writable.prototype._destroy = function (err, cb) {
|
this.end();
|
cb(err);
|
};
|
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(4), __webpack_require__(15).setImmediate, __webpack_require__(1)))
|
|
/***/ }),
|
/* 25 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
"use strict";
|
// Copyright Joyent, Inc. and other Node contributors.
|
//
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
// copy of this software and associated documentation files (the
|
// "Software"), to deal in the Software without restriction, including
|
// without limitation the rights to use, copy, modify, merge, publish,
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
// persons to whom the Software is furnished to do so, subject to the
|
// following conditions:
|
//
|
// The above copyright notice and this permission notice shall be included
|
// in all copies or substantial portions of the Software.
|
//
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
// a transform stream is a readable/writable stream where you do
|
// something with the data. Sometimes it's called a "filter",
|
// but that's not a great name for it, since that implies a thing where
|
// some bits pass through, and others are simply ignored. (That would
|
// be a valid example of a transform, of course.)
|
//
|
// While the output is causally related to the input, it's not a
|
// necessarily symmetric or synchronous transformation. For example,
|
// a zlib stream might take multiple plain-text writes(), and then
|
// emit a single compressed chunk some time in the future.
|
//
|
// Here's how this works:
|
//
|
// The Transform stream has all the aspects of the readable and writable
|
// stream classes. When you write(chunk), that calls _write(chunk,cb)
|
// internally, and returns false if there's a lot of pending writes
|
// buffered up. When you call read(), that calls _read(n) until
|
// there's enough pending readable data buffered up.
|
//
|
// In a transform stream, the written data is placed in a buffer. When
|
// _read(n) is called, it transforms the queued up data, calling the
|
// buffered _write cb's as it consumes chunks. If consuming a single
|
// written chunk would result in multiple output chunks, then the first
|
// outputted bit calls the readcb, and subsequent chunks just go into
|
// the read buffer, and will cause it to emit 'readable' if necessary.
|
//
|
// This way, back-pressure is actually determined by the reading side,
|
// since _read has to be called to start processing a new chunk. However,
|
// a pathological inflate type of transform can cause excessive buffering
|
// here. For example, imagine a stream where every byte of input is
|
// interpreted as an integer from 0-255, and then results in that many
|
// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
|
// 1kb of data being output. In this case, you could write a very small
|
// amount of input, and end up with a very large amount of output. In
|
// such a pathological inflating mechanism, there'd be no way to tell
|
// the system to stop doing the transform. A single 4MB write could
|
// cause the system to run out of memory.
|
//
|
// However, even in such a pathological case, only a single written chunk
|
// would be consumed, and then the rest would wait (un-transformed) until
|
// the results of the previous transformed chunk were consumed.
|
|
|
|
module.exports = Transform;
|
|
var Duplex = __webpack_require__(6);
|
|
/*<replacement>*/
|
var util = Object.create(__webpack_require__(8));
|
util.inherits = __webpack_require__(5);
|
/*</replacement>*/
|
|
util.inherits(Transform, Duplex);
|
|
function afterTransform(er, data) {
|
var ts = this._transformState;
|
ts.transforming = false;
|
|
var cb = ts.writecb;
|
|
if (!cb) {
|
return this.emit('error', new Error('write callback called multiple times'));
|
}
|
|
ts.writechunk = null;
|
ts.writecb = null;
|
|
if (data != null) // single equals check for both `null` and `undefined`
|
this.push(data);
|
|
cb(er);
|
|
var rs = this._readableState;
|
rs.reading = false;
|
if (rs.needReadable || rs.length < rs.highWaterMark) {
|
this._read(rs.highWaterMark);
|
}
|
}
|
|
function Transform(options) {
|
if (!(this instanceof Transform)) return new Transform(options);
|
|
Duplex.call(this, options);
|
|
this._transformState = {
|
afterTransform: afterTransform.bind(this),
|
needTransform: false,
|
transforming: false,
|
writecb: null,
|
writechunk: null,
|
writeencoding: null
|
};
|
|
// start out asking for a readable event once data is transformed.
|
this._readableState.needReadable = true;
|
|
// we have implemented the _read method, and done the other things
|
// that Readable wants before the first _read call, so unset the
|
// sync guard flag.
|
this._readableState.sync = false;
|
|
if (options) {
|
if (typeof options.transform === 'function') this._transform = options.transform;
|
|
if (typeof options.flush === 'function') this._flush = options.flush;
|
}
|
|
// When the writable side finishes, then flush out anything remaining.
|
this.on('prefinish', prefinish);
|
}
|
|
function prefinish() {
|
var _this = this;
|
|
if (typeof this._flush === 'function') {
|
this._flush(function (er, data) {
|
done(_this, er, data);
|
});
|
} else {
|
done(this, null, null);
|
}
|
}
|
|
Transform.prototype.push = function (chunk, encoding) {
|
this._transformState.needTransform = false;
|
return Duplex.prototype.push.call(this, chunk, encoding);
|
};
|
|
// This is the part where you do stuff!
|
// override this function in implementation classes.
|
// 'chunk' is an input chunk.
|
//
|
// Call `push(newChunk)` to pass along transformed output
|
// to the readable side. You may call 'push' zero or more times.
|
//
|
// Call `cb(err)` when you are done with this chunk. If you pass
|
// an error, then that'll put the hurt on the whole operation. If you
|
// never call cb(), then you'll never get another chunk.
|
Transform.prototype._transform = function (chunk, encoding, cb) {
|
throw new Error('_transform() is not implemented');
|
};
|
|
Transform.prototype._write = function (chunk, encoding, cb) {
|
var ts = this._transformState;
|
ts.writecb = cb;
|
ts.writechunk = chunk;
|
ts.writeencoding = encoding;
|
if (!ts.transforming) {
|
var rs = this._readableState;
|
if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
|
}
|
};
|
|
// Doesn't matter what the args are here.
|
// _transform does all the work.
|
// That we got here means that the readable side wants more data.
|
Transform.prototype._read = function (n) {
|
var ts = this._transformState;
|
|
if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
|
ts.transforming = true;
|
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
|
} else {
|
// mark that we need a transform, so that any data that comes in
|
// will get processed, now that we've asked for it.
|
ts.needTransform = true;
|
}
|
};
|
|
Transform.prototype._destroy = function (err, cb) {
|
var _this2 = this;
|
|
Duplex.prototype._destroy.call(this, err, function (err2) {
|
cb(err2);
|
_this2.emit('close');
|
});
|
};
|
|
function done(stream, er, data) {
|
if (er) return stream.emit('error', er);
|
|
if (data != null) // single equals check for both `null` and `undefined`
|
stream.push(data);
|
|
// if there's nothing in the write buffer, then that means
|
// that nothing more will ever be provided
|
if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
|
|
if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
|
|
return stream.push(null);
|
}
|
|
/***/ }),
|
/* 26 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
"use strict";
|
// Copyright Joyent, Inc. and other Node contributors.
|
//
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
// copy of this software and associated documentation files (the
|
// "Software"), to deal in the Software without restriction, including
|
// without limitation the rights to use, copy, modify, merge, publish,
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
// persons to whom the Software is furnished to do so, subject to the
|
// following conditions:
|
//
|
// The above copyright notice and this permission notice shall be included
|
// in all copies or substantial portions of the Software.
|
//
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
var punycode = __webpack_require__(59);
|
var util = __webpack_require__(61);
|
|
exports.parse = urlParse;
|
exports.resolve = urlResolve;
|
exports.resolveObject = urlResolveObject;
|
exports.format = urlFormat;
|
|
exports.Url = Url;
|
|
function Url() {
|
this.protocol = null;
|
this.slashes = null;
|
this.auth = null;
|
this.host = null;
|
this.port = null;
|
this.hostname = null;
|
this.hash = null;
|
this.search = null;
|
this.query = null;
|
this.pathname = null;
|
this.path = null;
|
this.href = null;
|
}
|
|
// Reference: RFC 3986, RFC 1808, RFC 2396
|
|
// define these here so at least they only have to be
|
// compiled once on the first module load.
|
var protocolPattern = /^([a-z0-9.+-]+:)/i,
|
portPattern = /:[0-9]*$/,
|
|
// Special case for a simple path URL
|
simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
|
|
// RFC 2396: characters reserved for delimiting URLs.
|
// We actually just auto-escape these.
|
delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
|
|
// RFC 2396: characters not allowed for various reasons.
|
unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
|
|
// Allowed by RFCs, but cause of XSS attacks. Always escape these.
|
autoEscape = ['\''].concat(unwise),
|
// Characters that are never ever allowed in a hostname.
|
// Note that any invalid chars are also handled, but these
|
// are the ones that are *expected* to be seen, so we fast-path
|
// them.
|
nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
|
hostEndingChars = ['/', '?', '#'],
|
hostnameMaxLen = 255,
|
hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
|
hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
|
// protocols that can allow "unsafe" and "unwise" chars.
|
unsafeProtocol = {
|
'javascript': true,
|
'javascript:': true
|
},
|
// protocols that never have a hostname.
|
hostlessProtocol = {
|
'javascript': true,
|
'javascript:': true
|
},
|
// protocols that always contain a // bit.
|
slashedProtocol = {
|
'http': true,
|
'https': true,
|
'ftp': true,
|
'gopher': true,
|
'file': true,
|
'http:': true,
|
'https:': true,
|
'ftp:': true,
|
'gopher:': true,
|
'file:': true
|
},
|
querystring = __webpack_require__(62);
|
|
function urlParse(url, parseQueryString, slashesDenoteHost) {
|
if (url && util.isObject(url) && url instanceof Url) return url;
|
|
var u = new Url;
|
u.parse(url, parseQueryString, slashesDenoteHost);
|
return u;
|
}
|
|
Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
|
if (!util.isString(url)) {
|
throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
|
}
|
|
// Copy chrome, IE, opera backslash-handling behavior.
|
// Back slashes before the query string get converted to forward slashes
|
// See: https://code.google.com/p/chromium/issues/detail?id=25916
|
var queryIndex = url.indexOf('?'),
|
splitter =
|
(queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
|
uSplit = url.split(splitter),
|
slashRegex = /\\/g;
|
uSplit[0] = uSplit[0].replace(slashRegex, '/');
|
url = uSplit.join(splitter);
|
|
var rest = url;
|
|
// trim before proceeding.
|
// This is to support parse stuff like " http://foo.com \n"
|
rest = rest.trim();
|
|
if (!slashesDenoteHost && url.split('#').length === 1) {
|
// Try fast path regexp
|
var simplePath = simplePathPattern.exec(rest);
|
if (simplePath) {
|
this.path = rest;
|
this.href = rest;
|
this.pathname = simplePath[1];
|
if (simplePath[2]) {
|
this.search = simplePath[2];
|
if (parseQueryString) {
|
this.query = querystring.parse(this.search.substr(1));
|
} else {
|
this.query = this.search.substr(1);
|
}
|
} else if (parseQueryString) {
|
this.search = '';
|
this.query = {};
|
}
|
return this;
|
}
|
}
|
|
var proto = protocolPattern.exec(rest);
|
if (proto) {
|
proto = proto[0];
|
var lowerProto = proto.toLowerCase();
|
this.protocol = lowerProto;
|
rest = rest.substr(proto.length);
|
}
|
|
// figure out if it's got a host
|
// user@server is *always* interpreted as a hostname, and url
|
// resolution will treat //foo/bar as host=foo,path=bar because that's
|
// how the browser resolves relative URLs.
|
if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
|
var slashes = rest.substr(0, 2) === '//';
|
if (slashes && !(proto && hostlessProtocol[proto])) {
|
rest = rest.substr(2);
|
this.slashes = true;
|
}
|
}
|
|
if (!hostlessProtocol[proto] &&
|
(slashes || (proto && !slashedProtocol[proto]))) {
|
|
// there's a hostname.
|
// the first instance of /, ?, ;, or # ends the host.
|
//
|
// If there is an @ in the hostname, then non-host chars *are* allowed
|
// to the left of the last @ sign, unless some host-ending character
|
// comes *before* the @-sign.
|
// URLs are obnoxious.
|
//
|
// ex:
|
// http://a@b@c/ => user:a@b host:c
|
// http://a@b?@c => user:a host:c path:/?@c
|
|
// v0.12 TODO(isaacs): This is not quite how Chrome does things.
|
// Review our test case against browsers more comprehensively.
|
|
// find the first instance of any hostEndingChars
|
var hostEnd = -1;
|
for (var i = 0; i < hostEndingChars.length; i++) {
|
var hec = rest.indexOf(hostEndingChars[i]);
|
if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
|
hostEnd = hec;
|
}
|
|
// at this point, either we have an explicit point where the
|
// auth portion cannot go past, or the last @ char is the decider.
|
var auth, atSign;
|
if (hostEnd === -1) {
|
// atSign can be anywhere.
|
atSign = rest.lastIndexOf('@');
|
} else {
|
// atSign must be in auth portion.
|
// http://a@b/c@d => host:b auth:a path:/c@d
|
atSign = rest.lastIndexOf('@', hostEnd);
|
}
|
|
// Now we have a portion which is definitely the auth.
|
// Pull that off.
|
if (atSign !== -1) {
|
auth = rest.slice(0, atSign);
|
rest = rest.slice(atSign + 1);
|
this.auth = decodeURIComponent(auth);
|
}
|
|
// the host is the remaining to the left of the first non-host char
|
hostEnd = -1;
|
for (var i = 0; i < nonHostChars.length; i++) {
|
var hec = rest.indexOf(nonHostChars[i]);
|
if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
|
hostEnd = hec;
|
}
|
// if we still have not hit it, then the entire thing is a host.
|
if (hostEnd === -1)
|
hostEnd = rest.length;
|
|
this.host = rest.slice(0, hostEnd);
|
rest = rest.slice(hostEnd);
|
|
// pull out port.
|
this.parseHost();
|
|
// we've indicated that there is a hostname,
|
// so even if it's empty, it has to be present.
|
this.hostname = this.hostname || '';
|
|
// if hostname begins with [ and ends with ]
|
// assume that it's an IPv6 address.
|
var ipv6Hostname = this.hostname[0] === '[' &&
|
this.hostname[this.hostname.length - 1] === ']';
|
|
// validate a little.
|
if (!ipv6Hostname) {
|
var hostparts = this.hostname.split(/\./);
|
for (var i = 0, l = hostparts.length; i < l; i++) {
|
var part = hostparts[i];
|
if (!part) continue;
|
if (!part.match(hostnamePartPattern)) {
|
var newpart = '';
|
for (var j = 0, k = part.length; j < k; j++) {
|
if (part.charCodeAt(j) > 127) {
|
// we replace non-ASCII char with a temporary placeholder
|
// we need this to make sure size of hostname is not
|
// broken by replacing non-ASCII by nothing
|
newpart += 'x';
|
} else {
|
newpart += part[j];
|
}
|
}
|
// we test again with ASCII char only
|
if (!newpart.match(hostnamePartPattern)) {
|
var validParts = hostparts.slice(0, i);
|
var notHost = hostparts.slice(i + 1);
|
var bit = part.match(hostnamePartStart);
|
if (bit) {
|
validParts.push(bit[1]);
|
notHost.unshift(bit[2]);
|
}
|
if (notHost.length) {
|
rest = '/' + notHost.join('.') + rest;
|
}
|
this.hostname = validParts.join('.');
|
break;
|
}
|
}
|
}
|
}
|
|
if (this.hostname.length > hostnameMaxLen) {
|
this.hostname = '';
|
} else {
|
// hostnames are always lower case.
|
this.hostname = this.hostname.toLowerCase();
|
}
|
|
if (!ipv6Hostname) {
|
// IDNA Support: Returns a punycoded representation of "domain".
|
// It only converts parts of the domain name that
|
// have non-ASCII characters, i.e. it doesn't matter if
|
// you call it with a domain that already is ASCII-only.
|
this.hostname = punycode.toASCII(this.hostname);
|
}
|
|
var p = this.port ? ':' + this.port : '';
|
var h = this.hostname || '';
|
this.host = h + p;
|
this.href += this.host;
|
|
// strip [ and ] from the hostname
|
// the host field still retains them, though
|
if (ipv6Hostname) {
|
this.hostname = this.hostname.substr(1, this.hostname.length - 2);
|
if (rest[0] !== '/') {
|
rest = '/' + rest;
|
}
|
}
|
}
|
|
// now rest is set to the post-host stuff.
|
// chop off any delim chars.
|
if (!unsafeProtocol[lowerProto]) {
|
|
// First, make 100% sure that any "autoEscape" chars get
|
// escaped, even if encodeURIComponent doesn't think they
|
// need to be.
|
for (var i = 0, l = autoEscape.length; i < l; i++) {
|
var ae = autoEscape[i];
|
if (rest.indexOf(ae) === -1)
|
continue;
|
var esc = encodeURIComponent(ae);
|
if (esc === ae) {
|
esc = escape(ae);
|
}
|
rest = rest.split(ae).join(esc);
|
}
|
}
|
|
|
// chop off from the tail first.
|
var hash = rest.indexOf('#');
|
if (hash !== -1) {
|
// got a fragment string.
|
this.hash = rest.substr(hash);
|
rest = rest.slice(0, hash);
|
}
|
var qm = rest.indexOf('?');
|
if (qm !== -1) {
|
this.search = rest.substr(qm);
|
this.query = rest.substr(qm + 1);
|
if (parseQueryString) {
|
this.query = querystring.parse(this.query);
|
}
|
rest = rest.slice(0, qm);
|
} else if (parseQueryString) {
|
// no query string, but parseQueryString still requested
|
this.search = '';
|
this.query = {};
|
}
|
if (rest) this.pathname = rest;
|
if (slashedProtocol[lowerProto] &&
|
this.hostname && !this.pathname) {
|
this.pathname = '/';
|
}
|
|
//to support http.request
|
if (this.pathname || this.search) {
|
var p = this.pathname || '';
|
var s = this.search || '';
|
this.path = p + s;
|
}
|
|
// finally, reconstruct the href based on what has been validated.
|
this.href = this.format();
|
return this;
|
};
|
|
// format a parsed object into a url string
|
function urlFormat(obj) {
|
// ensure it's an object, and not a string url.
|
// If it's an obj, this is a no-op.
|
// this way, you can call url_format() on strings
|
// to clean up potentially wonky urls.
|
if (util.isString(obj)) obj = urlParse(obj);
|
if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
|
return obj.format();
|
}
|
|
Url.prototype.format = function() {
|
var auth = this.auth || '';
|
if (auth) {
|
auth = encodeURIComponent(auth);
|
auth = auth.replace(/%3A/i, ':');
|
auth += '@';
|
}
|
|
var protocol = this.protocol || '',
|
pathname = this.pathname || '',
|
hash = this.hash || '',
|
host = false,
|
query = '';
|
|
if (this.host) {
|
host = auth + this.host;
|
} else if (this.hostname) {
|
host = auth + (this.hostname.indexOf(':') === -1 ?
|
this.hostname :
|
'[' + this.hostname + ']');
|
if (this.port) {
|
host += ':' + this.port;
|
}
|
}
|
|
if (this.query &&
|
util.isObject(this.query) &&
|
Object.keys(this.query).length) {
|
query = querystring.stringify(this.query);
|
}
|
|
var search = this.search || (query && ('?' + query)) || '';
|
|
if (protocol && protocol.substr(-1) !== ':') protocol += ':';
|
|
// only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
|
// unless they had them to begin with.
|
if (this.slashes ||
|
(!protocol || slashedProtocol[protocol]) && host !== false) {
|
host = '//' + (host || '');
|
if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
|
} else if (!host) {
|
host = '';
|
}
|
|
if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
|
if (search && search.charAt(0) !== '?') search = '?' + search;
|
|
pathname = pathname.replace(/[?#]/g, function(match) {
|
return encodeURIComponent(match);
|
});
|
search = search.replace('#', '%23');
|
|
return protocol + host + pathname + search + hash;
|
};
|
|
function urlResolve(source, relative) {
|
return urlParse(source, false, true).resolve(relative);
|
}
|
|
Url.prototype.resolve = function(relative) {
|
return this.resolveObject(urlParse(relative, false, true)).format();
|
};
|
|
function urlResolveObject(source, relative) {
|
if (!source) return relative;
|
return urlParse(source, false, true).resolveObject(relative);
|
}
|
|
Url.prototype.resolveObject = function(relative) {
|
if (util.isString(relative)) {
|
var rel = new Url();
|
rel.parse(relative, false, true);
|
relative = rel;
|
}
|
|
var result = new Url();
|
var tkeys = Object.keys(this);
|
for (var tk = 0; tk < tkeys.length; tk++) {
|
var tkey = tkeys[tk];
|
result[tkey] = this[tkey];
|
}
|
|
// hash is always overridden, no matter what.
|
// even href="" will remove it.
|
result.hash = relative.hash;
|
|
// if the relative url is empty, then there's nothing left to do here.
|
if (relative.href === '') {
|
result.href = result.format();
|
return result;
|
}
|
|
// hrefs like //foo/bar always cut to the protocol.
|
if (relative.slashes && !relative.protocol) {
|
// take everything except the protocol from relative
|
var rkeys = Object.keys(relative);
|
for (var rk = 0; rk < rkeys.length; rk++) {
|
var rkey = rkeys[rk];
|
if (rkey !== 'protocol')
|
result[rkey] = relative[rkey];
|
}
|
|
//urlParse appends trailing / to urls like http://www.example.com
|
if (slashedProtocol[result.protocol] &&
|
result.hostname && !result.pathname) {
|
result.path = result.pathname = '/';
|
}
|
|
result.href = result.format();
|
return result;
|
}
|
|
if (relative.protocol && relative.protocol !== result.protocol) {
|
// if it's a known url protocol, then changing
|
// the protocol does weird things
|
// first, if it's not file:, then we MUST have a host,
|
// and if there was a path
|
// to begin with, then we MUST have a path.
|
// if it is file:, then the host is dropped,
|
// because that's known to be hostless.
|
// anything else is assumed to be absolute.
|
if (!slashedProtocol[relative.protocol]) {
|
var keys = Object.keys(relative);
|
for (var v = 0; v < keys.length; v++) {
|
var k = keys[v];
|
result[k] = relative[k];
|
}
|
result.href = result.format();
|
return result;
|
}
|
|
result.protocol = relative.protocol;
|
if (!relative.host && !hostlessProtocol[relative.protocol]) {
|
var relPath = (relative.pathname || '').split('/');
|
while (relPath.length && !(relative.host = relPath.shift()));
|
if (!relative.host) relative.host = '';
|
if (!relative.hostname) relative.hostname = '';
|
if (relPath[0] !== '') relPath.unshift('');
|
if (relPath.length < 2) relPath.unshift('');
|
result.pathname = relPath.join('/');
|
} else {
|
result.pathname = relative.pathname;
|
}
|
result.search = relative.search;
|
result.query = relative.query;
|
result.host = relative.host || '';
|
result.auth = relative.auth;
|
result.hostname = relative.hostname || relative.host;
|
result.port = relative.port;
|
// to support http.request
|
if (result.pathname || result.search) {
|
var p = result.pathname || '';
|
var s = result.search || '';
|
result.path = p + s;
|
}
|
result.slashes = result.slashes || relative.slashes;
|
result.href = result.format();
|
return result;
|
}
|
|
var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
|
isRelAbs = (
|
relative.host ||
|
relative.pathname && relative.pathname.charAt(0) === '/'
|
),
|
mustEndAbs = (isRelAbs || isSourceAbs ||
|
(result.host && relative.pathname)),
|
removeAllDots = mustEndAbs,
|
srcPath = result.pathname && result.pathname.split('/') || [],
|
relPath = relative.pathname && relative.pathname.split('/') || [],
|
psychotic = result.protocol && !slashedProtocol[result.protocol];
|
|
// if the url is a non-slashed url, then relative
|
// links like ../.. should be able
|
// to crawl up to the hostname, as well. This is strange.
|
// result.protocol has already been set by now.
|
// Later on, put the first path part into the host field.
|
if (psychotic) {
|
result.hostname = '';
|
result.port = null;
|
if (result.host) {
|
if (srcPath[0] === '') srcPath[0] = result.host;
|
else srcPath.unshift(result.host);
|
}
|
result.host = '';
|
if (relative.protocol) {
|
relative.hostname = null;
|
relative.port = null;
|
if (relative.host) {
|
if (relPath[0] === '') relPath[0] = relative.host;
|
else relPath.unshift(relative.host);
|
}
|
relative.host = null;
|
}
|
mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
|
}
|
|
if (isRelAbs) {
|
// it's absolute.
|
result.host = (relative.host || relative.host === '') ?
|
relative.host : result.host;
|
result.hostname = (relative.hostname || relative.hostname === '') ?
|
relative.hostname : result.hostname;
|
result.search = relative.search;
|
result.query = relative.query;
|
srcPath = relPath;
|
// fall through to the dot-handling below.
|
} else if (relPath.length) {
|
// it's relative
|
// throw away the existing file, and take the new path instead.
|
if (!srcPath) srcPath = [];
|
srcPath.pop();
|
srcPath = srcPath.concat(relPath);
|
result.search = relative.search;
|
result.query = relative.query;
|
} else if (!util.isNullOrUndefined(relative.search)) {
|
// just pull out the search.
|
// like href='?foo'.
|
// Put this after the other two cases because it simplifies the booleans
|
if (psychotic) {
|
result.hostname = result.host = srcPath.shift();
|
//occationaly the auth can get stuck only in host
|
//this especially happens in cases like
|
//url.resolveObject('mailto:local1@domain1', 'local2@domain2')
|
var authInHost = result.host && result.host.indexOf('@') > 0 ?
|
result.host.split('@') : false;
|
if (authInHost) {
|
result.auth = authInHost.shift();
|
result.host = result.hostname = authInHost.shift();
|
}
|
}
|
result.search = relative.search;
|
result.query = relative.query;
|
//to support http.request
|
if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
|
result.path = (result.pathname ? result.pathname : '') +
|
(result.search ? result.search : '');
|
}
|
result.href = result.format();
|
return result;
|
}
|
|
if (!srcPath.length) {
|
// no path at all. easy.
|
// we've already handled the other stuff above.
|
result.pathname = null;
|
//to support http.request
|
if (result.search) {
|
result.path = '/' + result.search;
|
} else {
|
result.path = null;
|
}
|
result.href = result.format();
|
return result;
|
}
|
|
// if a url ENDs in . or .., then it must get a trailing slash.
|
// however, if it ends in anything else non-slashy,
|
// then it must NOT get a trailing slash.
|
var last = srcPath.slice(-1)[0];
|
var hasTrailingSlash = (
|
(result.host || relative.host || srcPath.length > 1) &&
|
(last === '.' || last === '..') || last === '');
|
|
// strip single dots, resolve double dots to parent dir
|
// if the path tries to go above the root, `up` ends up > 0
|
var up = 0;
|
for (var i = srcPath.length; i >= 0; i--) {
|
last = srcPath[i];
|
if (last === '.') {
|
srcPath.splice(i, 1);
|
} else if (last === '..') {
|
srcPath.splice(i, 1);
|
up++;
|
} else if (up) {
|
srcPath.splice(i, 1);
|
up--;
|
}
|
}
|
|
// if the path is allowed to go above the root, restore leading ..s
|
if (!mustEndAbs && !removeAllDots) {
|
for (; up--; up) {
|
srcPath.unshift('..');
|
}
|
}
|
|
if (mustEndAbs && srcPath[0] !== '' &&
|
(!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
|
srcPath.unshift('');
|
}
|
|
if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
|
srcPath.push('');
|
}
|
|
var isAbsolute = srcPath[0] === '' ||
|
(srcPath[0] && srcPath[0].charAt(0) === '/');
|
|
// put the host back
|
if (psychotic) {
|
result.hostname = result.host = isAbsolute ? '' :
|
srcPath.length ? srcPath.shift() : '';
|
//occationaly the auth can get stuck only in host
|
//this especially happens in cases like
|
//url.resolveObject('mailto:local1@domain1', 'local2@domain2')
|
var authInHost = result.host && result.host.indexOf('@') > 0 ?
|
result.host.split('@') : false;
|
if (authInHost) {
|
result.auth = authInHost.shift();
|
result.host = result.hostname = authInHost.shift();
|
}
|
}
|
|
mustEndAbs = mustEndAbs || (result.host && srcPath.length);
|
|
if (mustEndAbs && !isAbsolute) {
|
srcPath.unshift('');
|
}
|
|
if (!srcPath.length) {
|
result.pathname = null;
|
result.path = null;
|
} else {
|
result.pathname = srcPath.join('/');
|
}
|
|
//to support request.http
|
if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
|
result.path = (result.pathname ? result.pathname : '') +
|
(result.search ? result.search : '');
|
}
|
result.auth = relative.auth || result.auth;
|
result.slashes = result.slashes || relative.slashes;
|
result.href = result.format();
|
return result;
|
};
|
|
Url.prototype.parseHost = function() {
|
var host = this.host;
|
var port = portPattern.exec(host);
|
if (port) {
|
port = port[0];
|
if (port !== ':') {
|
this.port = port.substr(1);
|
}
|
host = host.substr(0, host.length - port.length);
|
}
|
if (host) this.hostname = host;
|
};
|
|
|
/***/ }),
|
/* 27 */
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
"use strict";
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return unzip; });
|
/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
|
/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__);
|
/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0);
|
/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1__);
|
|
|
|
var JSZip = __webpack_require__(47);
|
|
function unzip(_x) {
|
return _unzip.apply(this, arguments);
|
}
|
|
function _unzip() {
|
_unzip = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default.a.mark(function _callee2(buffer) {
|
var zip, files, out;
|
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default.a.wrap(function _callee2$(_context2) {
|
while (1) {
|
switch (_context2.prev = _context2.next) {
|
case 0:
|
zip = new JSZip();
|
_context2.next = 3;
|
return zip.loadAsync(buffer);
|
|
case 3:
|
files = zip.file(/.+/);
|
out = {};
|
_context2.next = 7;
|
return Promise.all(files.map( /*#__PURE__*/function () {
|
var _ref = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default.a.mark(function _callee(a) {
|
var result;
|
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default.a.wrap(function _callee$(_context) {
|
while (1) {
|
switch (_context.prev = _context.next) {
|
case 0:
|
if (!(a.name.slice(-3).toLowerCase() === 'shp' || a.name.slice(-3).toLowerCase() === 'dbf')) {
|
_context.next = 6;
|
break;
|
}
|
|
_context.next = 3;
|
return a.async('nodebuffer');
|
|
case 3:
|
result = _context.sent;
|
_context.next = 9;
|
break;
|
|
case 6:
|
_context.next = 8;
|
return a.async('text');
|
|
case 8:
|
result = _context.sent;
|
|
case 9:
|
out[a.name] = result;
|
|
case 10:
|
case "end":
|
return _context.stop();
|
}
|
}
|
}, _callee);
|
}));
|
|
return function (_x2) {
|
return _ref.apply(this, arguments);
|
};
|
}()));
|
|
case 7:
|
return _context2.abrupt("return", out);
|
|
case 8:
|
case "end":
|
return _context2.stop();
|
}
|
}
|
}, _callee2);
|
}));
|
return _unzip.apply(this, arguments);
|
}
|
|
/***/ }),
|
/* 28 */
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
"use strict";
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return parseShp; });
|
function isClockWise(array) {
|
var sum = 0;
|
var i = 1;
|
var len = array.length;
|
var prev, cur;
|
|
while (i < len) {
|
prev = cur || array[0];
|
cur = array[i];
|
sum += (cur[0] - prev[0]) * (cur[1] + prev[1]);
|
i++;
|
}
|
|
return sum > 0;
|
}
|
|
function polyReduce(a, b) {
|
if (isClockWise(b) || !a.length) {
|
a.push([b]);
|
} else {
|
a[a.length - 1].push(b);
|
}
|
|
return a;
|
}
|
|
ParseShp.prototype.parsePoint = function (data) {
|
return {
|
type: 'Point',
|
coordinates: this.parseCoord(data, 0)
|
};
|
};
|
|
ParseShp.prototype.parseZPoint = function (data) {
|
var pointXY = this.parsePoint(data);
|
pointXY.coordinates.push(data.readDoubleLE(16));
|
return pointXY;
|
};
|
|
ParseShp.prototype.parsePointArray = function (data, offset, num) {
|
var out = [];
|
var done = 0;
|
|
while (done < num) {
|
out.push(this.parseCoord(data, offset));
|
offset += 16;
|
done++;
|
}
|
|
return out;
|
};
|
|
ParseShp.prototype.parseZPointArray = function (data, zOffset, num, coordinates) {
|
var i = 0;
|
|
while (i < num) {
|
coordinates[i].push(data.readDoubleLE(zOffset));
|
i++;
|
zOffset += 8;
|
}
|
|
return coordinates;
|
};
|
|
ParseShp.prototype.parseArrayGroup = function (data, offset, partOffset, num, tot) {
|
var out = [];
|
var done = 0;
|
var curNum;
|
var nextNum = 0;
|
var pointNumber;
|
|
while (done < num) {
|
done++;
|
partOffset += 4;
|
curNum = nextNum;
|
|
if (done === num) {
|
nextNum = tot;
|
} else {
|
nextNum = data.readInt32LE(partOffset);
|
}
|
|
pointNumber = nextNum - curNum;
|
|
if (!pointNumber) {
|
continue;
|
}
|
|
out.push(this.parsePointArray(data, offset, pointNumber));
|
offset += pointNumber << 4;
|
}
|
|
return out;
|
};
|
|
ParseShp.prototype.parseZArrayGroup = function (data, zOffset, num, coordinates) {
|
var i = 0;
|
|
while (i < num) {
|
coordinates[i] = this.parseZPointArray(data, zOffset, coordinates[i].length, coordinates[i]);
|
zOffset += coordinates[i].length << 3;
|
i++;
|
}
|
|
return coordinates;
|
};
|
|
ParseShp.prototype.parseMultiPoint = function (data) {
|
var out = {};
|
var num = data.readInt32LE(32, true);
|
|
if (!num) {
|
return null;
|
}
|
|
var mins = this.parseCoord(data, 0);
|
var maxs = this.parseCoord(data, 16);
|
out.bbox = [mins[0], mins[1], maxs[0], maxs[1]];
|
var offset = 36;
|
|
if (num === 1) {
|
out.type = 'Point';
|
out.coordinates = this.parseCoord(data, offset);
|
} else {
|
out.type = 'MultiPoint';
|
out.coordinates = this.parsePointArray(data, offset, num);
|
}
|
|
return out;
|
};
|
|
ParseShp.prototype.parseZMultiPoint = function (data) {
|
var geoJson = this.parseMultiPoint(data);
|
|
if (!geoJson) {
|
return null;
|
}
|
|
var num;
|
|
if (geoJson.type === 'Point') {
|
geoJson.coordinates.push(data.readDoubleLE(72));
|
return geoJson;
|
} else {
|
num = geoJson.coordinates.length;
|
}
|
|
var zOffset = 52 + (num << 4);
|
geoJson.coordinates = this.parseZPointArray(data, zOffset, num, geoJson.coordinates);
|
return geoJson;
|
};
|
|
ParseShp.prototype.parsePolyline = function (data) {
|
var out = {};
|
var numParts = data.readInt32LE(32);
|
|
if (!numParts) {
|
return null;
|
}
|
|
var mins = this.parseCoord(data, 0);
|
var maxs = this.parseCoord(data, 16);
|
out.bbox = [mins[0], mins[1], maxs[0], maxs[1]];
|
var num = data.readInt32LE(36);
|
var offset, partOffset;
|
|
if (numParts === 1) {
|
out.type = 'LineString';
|
offset = 44;
|
out.coordinates = this.parsePointArray(data, offset, num);
|
} else {
|
out.type = 'MultiLineString';
|
offset = 40 + (numParts << 2);
|
partOffset = 40;
|
out.coordinates = this.parseArrayGroup(data, offset, partOffset, numParts, num);
|
}
|
|
return out;
|
};
|
|
ParseShp.prototype.parseZPolyline = function (data) {
|
var geoJson = this.parsePolyline(data);
|
|
if (!geoJson) {
|
return null;
|
}
|
|
var num = geoJson.coordinates.length;
|
var zOffset;
|
|
if (geoJson.type === 'LineString') {
|
zOffset = 60 + (num << 4);
|
geoJson.coordinates = this.parseZPointArray(data, zOffset, num, geoJson.coordinates);
|
return geoJson;
|
} else {
|
var totalPoints = geoJson.coordinates.reduce(function (a, v) {
|
return a + v.length;
|
}, 0);
|
zOffset = 56 + (totalPoints << 4) + (num << 2);
|
geoJson.coordinates = this.parseZArrayGroup(data, zOffset, num, geoJson.coordinates);
|
return geoJson;
|
}
|
};
|
|
ParseShp.prototype.polyFuncs = function (out) {
|
if (!out) {
|
return out;
|
}
|
|
if (out.type === 'LineString') {
|
out.type = 'Polygon';
|
out.coordinates = [out.coordinates];
|
return out;
|
} else {
|
out.coordinates = out.coordinates.reduce(polyReduce, []);
|
|
if (out.coordinates.length === 1) {
|
out.type = 'Polygon';
|
out.coordinates = out.coordinates[0];
|
return out;
|
} else {
|
out.type = 'MultiPolygon';
|
return out;
|
}
|
}
|
};
|
|
ParseShp.prototype.parsePolygon = function (data) {
|
return this.polyFuncs(this.parsePolyline(data));
|
};
|
|
ParseShp.prototype.parseZPolygon = function (data) {
|
return this.polyFuncs(this.parseZPolyline(data));
|
};
|
|
var shpFuncObj = {
|
1: 'parsePoint',
|
3: 'parsePolyline',
|
5: 'parsePolygon',
|
8: 'parseMultiPoint',
|
11: 'parseZPoint',
|
13: 'parseZPolyline',
|
15: 'parseZPolygon',
|
18: 'parseZMultiPoint'
|
};
|
|
function makeParseCoord(trans) {
|
if (trans) {
|
return function (data, offset) {
|
var args = [data.readDoubleLE(offset), data.readDoubleLE(offset + 8)];
|
return trans.inverse(args);
|
};
|
} else {
|
return function (data, offset) {
|
return [data.readDoubleLE(offset), data.readDoubleLE(offset + 8)];
|
};
|
}
|
}
|
|
function ParseShp(buffer, trans) {
|
if (!(this instanceof ParseShp)) {
|
return new ParseShp(buffer, trans);
|
}
|
|
this.buffer = buffer;
|
this.headers = this.parseHeader();
|
|
if (this.headers.length < this.buffer.byteLength) {
|
this.buffer = this.buffer.slice(0, this.headers.length);
|
}
|
|
this.shpFuncs(trans);
|
this.rows = this.getRows();
|
}
|
|
ParseShp.prototype.shpFuncs = function (tran) {
|
var num = this.headers.shpCode;
|
|
if (num > 20) {
|
num -= 20;
|
}
|
|
if (!(num in shpFuncObj)) {
|
throw new Error("I don't know that shp type");
|
}
|
|
this.parseFunc = this[shpFuncObj[num]];
|
this.parseCoord = makeParseCoord(tran);
|
};
|
|
ParseShp.prototype.getShpCode = function () {
|
return this.parseHeader().shpCode;
|
};
|
|
ParseShp.prototype.parseHeader = function () {
|
var view = this.buffer.slice(0, 100);
|
return {
|
length: view.readInt32BE(6 << 2) << 1,
|
version: view.readInt32LE(7 << 2),
|
shpCode: view.readInt32LE(8 << 2),
|
bbox: [view.readDoubleLE(9 << 2), view.readDoubleLE(11 << 2), view.readDoubleLE(13 << 2), view.readDoubleLE(13 << 2)]
|
};
|
};
|
|
ParseShp.prototype.getRows = function () {
|
var offset = 100;
|
var len = this.buffer.byteLength;
|
var out = [];
|
var current;
|
|
while (offset < len) {
|
current = this.getRow(offset);
|
|
if (!current) {
|
break;
|
}
|
|
offset += 8;
|
offset += current.len;
|
|
if (current.type) {
|
out.push(this.parseFunc(current.data));
|
} else {
|
out.push(null);
|
}
|
}
|
|
return out;
|
};
|
|
ParseShp.prototype.getRow = function (offset) {
|
var view = this.buffer.slice(offset, offset + 12);
|
var len = view.readInt32BE(4) << 1;
|
var id = view.readInt32BE(0);
|
|
if (len === 0) {
|
return {
|
id: id,
|
len: len,
|
type: 0
|
};
|
}
|
|
return {
|
id: id,
|
len: len,
|
data: this.buffer.slice(offset + 12, offset + len + 8),
|
type: view.readInt32LE(8)
|
};
|
};
|
|
function parseShp(buffer, trans) {
|
return new ParseShp(buffer, trans).rows;
|
}
|
|
/***/ }),
|
/* 29 */
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
"use strict";
|
__webpack_require__.r(__webpack_exports__);
|
/* WEBPACK VAR INJECTION */(function(global) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toGeoJSON", function() { return toGeoJSON; });
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "combine", function() { return combine; });
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseZip", function() { return parseZip; });
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getZip", function() { return getZip; });
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getShapefile", function() { return getShapefile; });
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseShp", function() { return parseShp; });
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseDbf", function() { return parseDbf; });
|
/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
|
/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__);
|
/* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(12);
|
/* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1__);
|
/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(0);
|
/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__);
|
/* harmony import */ var _unzip__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(27);
|
/* harmony import */ var _binaryajax__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7);
|
/* harmony import */ var _parseShp__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(28);
|
|
|
|
|
var proj4 = __webpack_require__(66);
|
|
var _parseDbf = __webpack_require__(37);
|
|
var Promise = __webpack_require__(14);
|
|
var Cache = __webpack_require__(46);
|
|
var Buffer = __webpack_require__(2).Buffer;
|
|
|
|
|
|
if (proj4["default"]) {
|
proj4 = proj4["default"];
|
}
|
|
function getProj4(value) {
|
if (window.proj4) {
|
return window.proj4(value);
|
}
|
|
if (window.mars3d && window.mars3d.proj4) {
|
return window.mars3d.proj4(value);
|
}
|
|
return proj4(value);
|
}
|
|
var cache = new Cache({
|
max: 20
|
});
|
|
function toBuffer(b) {
|
if (!b) {
|
throw new Error('forgot to pass buffer');
|
}
|
|
if (Buffer.isBuffer(b)) {
|
return b;
|
}
|
|
if (isArrayBuffer(b)) {
|
return Buffer.from(b);
|
}
|
|
if (isArrayBuffer(b.buffer)) {
|
if (b.BYTES_PER_ELEMENT === 1) {
|
return Buffer.from(b);
|
}
|
|
return Buffer.from(b.buffer);
|
}
|
}
|
|
function isArrayBuffer(subject) {
|
return subject instanceof global.ArrayBuffer || Object.prototype.toString.call(subject) === '[object ArrayBuffer]';
|
}
|
|
function toGeoJSON(base, whiteList, encoding, crs) {
|
if (typeof base === 'string' && cache.has(base)) {
|
return Promise.resolve(cache.get(base));
|
}
|
|
return getShapefile(base, whiteList, encoding, crs).then(function (resp) {
|
if (typeof base === 'string') {
|
cache.set(base, resp);
|
}
|
|
return resp;
|
});
|
}
|
function combine(_ref) {
|
var _ref2 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1___default()(_ref, 2),
|
shp = _ref2[0],
|
dbf = _ref2[1];
|
|
var out = {};
|
out.type = 'FeatureCollection';
|
out.features = [];
|
var i = 0;
|
var len = shp.length;
|
|
if (!dbf) {
|
dbf = [];
|
}
|
|
while (i < len) {
|
out.features.push({
|
type: 'Feature',
|
geometry: shp[i],
|
properties: dbf[i] || {}
|
});
|
i++;
|
}
|
|
return out;
|
}
|
function parseZip(_x, _x2, _x3, _x4) {
|
return _parseZip.apply(this, arguments);
|
}
|
|
function _parseZip() {
|
_parseZip = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.mark(function _callee(buffer, whiteList, encoding, crs) {
|
var key, zip, names, nowProj, geojson;
|
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.wrap(function _callee$(_context) {
|
while (1) {
|
switch (_context.prev = _context.next) {
|
case 0:
|
buffer = toBuffer(buffer);
|
_context.next = 3;
|
return Object(_unzip__WEBPACK_IMPORTED_MODULE_3__[/* unzip */ "a"])(buffer);
|
|
case 3:
|
zip = _context.sent;
|
names = [];
|
whiteList = whiteList || [];
|
_context.t0 = _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.keys(zip);
|
|
case 7:
|
if ((_context.t1 = _context.t0()).done) {
|
_context.next = 14;
|
break;
|
}
|
|
key = _context.t1.value;
|
|
if (!(key.indexOf('__MACOSX') !== -1)) {
|
_context.next = 11;
|
break;
|
}
|
|
return _context.abrupt("continue", 7);
|
|
case 11:
|
if (key.slice(-3).toLowerCase() === 'shp') {
|
names.push(key.slice(0, -4));
|
zip[key.slice(0, -3) + key.slice(-3).toLowerCase()] = zip[key];
|
} else if (key.slice(-3).toLowerCase() === 'prj') {
|
nowProj = void 0;
|
|
try {
|
nowProj = getProj4(crs || zip[key]);
|
} catch (e) {
|
console.error('该坐标系proj4未解析,将原样转出', e);
|
nowProj = getProj4('EPSG:4326');
|
}
|
|
zip[key.slice(0, -3) + key.slice(-3).toLowerCase()] = nowProj;
|
} else if (key.slice(-4).toLowerCase() === 'json' || whiteList.indexOf(key.split('.').pop()) > -1) {
|
names.push(key.slice(0, -3) + key.slice(-3).toLowerCase());
|
} else if (key.slice(-3).toLowerCase() === 'dbf' || key.slice(-3).toLowerCase() === 'cpg') {
|
zip[key.slice(0, -3) + key.slice(-3).toLowerCase()] = zip[key];
|
}
|
|
_context.next = 7;
|
break;
|
|
case 14:
|
if (names.length) {
|
_context.next = 16;
|
break;
|
}
|
|
throw new Error('no layers founds');
|
|
case 16:
|
geojson = names.map(function (name) {
|
var parsed, dbf;
|
var lastDotIdx = name.lastIndexOf('.');
|
|
if (lastDotIdx > -1 && name.slice(lastDotIdx).indexOf('json') > -1) {
|
parsed = JSON.parse(zip[name]);
|
parsed.fileName = name.slice(0, lastDotIdx);
|
} else if (whiteList.indexOf(name.slice(lastDotIdx + 1)) > -1) {
|
parsed = zip[name];
|
parsed.fileName = name;
|
} else {
|
if (zip[name + '.dbf']) {
|
dbf = parseDbf(zip[name + '.dbf'], encoding || zip[name + '.cpg']);
|
}
|
|
parsed = combine([parseShp(zip[name + '.shp'], zip[name + '.prj']), dbf]);
|
parsed.fileName = name;
|
}
|
|
return parsed;
|
});
|
|
if (!(geojson.length === 1)) {
|
_context.next = 21;
|
break;
|
}
|
|
return _context.abrupt("return", geojson[0]);
|
|
case 21:
|
return _context.abrupt("return", geojson);
|
|
case 22:
|
case "end":
|
return _context.stop();
|
}
|
}
|
}, _callee);
|
}));
|
return _parseZip.apply(this, arguments);
|
}
|
|
function getZip(_x5, _x6, _x7, _x8) {
|
return _getZip.apply(this, arguments);
|
}
|
|
function _getZip() {
|
_getZip = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.mark(function _callee2(base, whiteList, encoding, crs) {
|
var a;
|
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.wrap(function _callee2$(_context2) {
|
while (1) {
|
switch (_context2.prev = _context2.next) {
|
case 0:
|
_context2.next = 2;
|
return Object(_binaryajax__WEBPACK_IMPORTED_MODULE_4__[/* binaryAjax */ "a"])(base);
|
|
case 2:
|
a = _context2.sent;
|
return _context2.abrupt("return", parseZip(a, whiteList, encoding, crs));
|
|
case 4:
|
case "end":
|
return _context2.stop();
|
}
|
}
|
}, _callee2);
|
}));
|
return _getZip.apply(this, arguments);
|
}
|
|
function handleShp(_x9) {
|
return _handleShp.apply(this, arguments);
|
}
|
|
function _handleShp() {
|
_handleShp = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.mark(function _callee3(base) {
|
var args, prj;
|
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.wrap(function _callee3$(_context3) {
|
while (1) {
|
switch (_context3.prev = _context3.next) {
|
case 0:
|
_context3.next = 2;
|
return Promise.all([Object(_binaryajax__WEBPACK_IMPORTED_MODULE_4__[/* binaryAjax */ "a"])(base, 'shp'), Object(_binaryajax__WEBPACK_IMPORTED_MODULE_4__[/* binaryAjax */ "a"])(base, 'prj')]);
|
|
case 2:
|
args = _context3.sent;
|
prj = false;
|
|
try {
|
if (args[1]) {
|
prj = getProj4(args[1]);
|
}
|
} catch (e) {
|
prj = false;
|
}
|
|
return _context3.abrupt("return", parseShp(args[0], prj));
|
|
case 6:
|
case "end":
|
return _context3.stop();
|
}
|
}
|
}, _callee3);
|
}));
|
return _handleShp.apply(this, arguments);
|
}
|
|
function handleDbf(_x10) {
|
return _handleDbf.apply(this, arguments);
|
}
|
|
function _handleDbf() {
|
_handleDbf = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.mark(function _callee4(base) {
|
var _yield$Promise$all, _yield$Promise$all2, dbf, cpg;
|
|
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.wrap(function _callee4$(_context4) {
|
while (1) {
|
switch (_context4.prev = _context4.next) {
|
case 0:
|
_context4.next = 2;
|
return Promise.all([Object(_binaryajax__WEBPACK_IMPORTED_MODULE_4__[/* binaryAjax */ "a"])(base, 'dbf'), Object(_binaryajax__WEBPACK_IMPORTED_MODULE_4__[/* binaryAjax */ "a"])(base, 'cpg')]);
|
|
case 2:
|
_yield$Promise$all = _context4.sent;
|
_yield$Promise$all2 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1___default()(_yield$Promise$all, 2);
|
dbf = _yield$Promise$all2[0];
|
cpg = _yield$Promise$all2[1];
|
|
if (dbf) {
|
_context4.next = 8;
|
break;
|
}
|
|
return _context4.abrupt("return");
|
|
case 8:
|
return _context4.abrupt("return", parseDbf(dbf, cpg));
|
|
case 9:
|
case "end":
|
return _context4.stop();
|
}
|
}
|
}, _callee4);
|
}));
|
return _handleDbf.apply(this, arguments);
|
}
|
|
function checkSuffix(base, suffix) {
|
return base.toLowerCase().endsWith(suffix);
|
}
|
|
function getShapefile(_x11, _x12, _x13, _x14) {
|
return _getShapefile.apply(this, arguments);
|
}
|
|
function _getShapefile() {
|
_getShapefile = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.mark(function _callee5(base, whiteList, encoding, crs) {
|
var results;
|
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.wrap(function _callee5$(_context5) {
|
while (1) {
|
switch (_context5.prev = _context5.next) {
|
case 0:
|
if (!(typeof base !== 'string')) {
|
_context5.next = 2;
|
break;
|
}
|
|
return _context5.abrupt("return", parseZip(base, whiteList, encoding, crs));
|
|
case 2:
|
if (!checkSuffix(base, '.zip')) {
|
_context5.next = 4;
|
break;
|
}
|
|
return _context5.abrupt("return", getZip(base, whiteList, encoding, crs));
|
|
case 4:
|
_context5.next = 6;
|
return Promise.all([handleShp(base), handleDbf(base)]);
|
|
case 6:
|
results = _context5.sent;
|
return _context5.abrupt("return", combine(results));
|
|
case 8:
|
case "end":
|
return _context5.stop();
|
}
|
}
|
}, _callee5);
|
}));
|
return _getShapefile.apply(this, arguments);
|
}
|
|
function parseShp(shp, prj) {
|
shp = toBuffer(shp);
|
|
if (Buffer.isBuffer(prj)) {
|
prj = prj.toString();
|
}
|
|
if (typeof prj === 'string') {
|
try {
|
prj = getProj4(prj);
|
} catch (e) {
|
prj = false;
|
}
|
}
|
|
return Object(_parseShp__WEBPACK_IMPORTED_MODULE_5__[/* parseShp */ "a"])(shp, prj);
|
}
|
function parseDbf(dbf, cpg) {
|
dbf = toBuffer(dbf);
|
return _parseDbf(dbf, cpg);
|
}
|
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(1)))
|
|
/***/ }),
|
/* 30 */
|
/***/ (function(module, exports) {
|
|
function _arrayWithHoles(arr) {
|
if (Array.isArray(arr)) return arr;
|
}
|
|
module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
/***/ }),
|
/* 31 */
|
/***/ (function(module, exports) {
|
|
function _iterableToArrayLimit(arr, i) {
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
if (_i == null) return;
|
var _arr = [];
|
var _n = true;
|
var _d = false;
|
|
var _s, _e;
|
|
try {
|
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
_arr.push(_s.value);
|
|
if (i && _arr.length === i) break;
|
}
|
} catch (err) {
|
_d = true;
|
_e = err;
|
} finally {
|
try {
|
if (!_n && _i["return"] != null) _i["return"]();
|
} finally {
|
if (_d) throw _e;
|
}
|
}
|
|
return _arr;
|
}
|
|
module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
/***/ }),
|
/* 32 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
var arrayLikeToArray = __webpack_require__(33);
|
|
function _unsupportedIterableToArray(o, minLen) {
|
if (!o) return;
|
if (typeof o === "string") return arrayLikeToArray(o, minLen);
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
if (n === "Map" || n === "Set") return Array.from(o);
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);
|
}
|
|
module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
/***/ }),
|
/* 33 */
|
/***/ (function(module, exports) {
|
|
function _arrayLikeToArray(arr, len) {
|
if (len == null || len > arr.length) len = arr.length;
|
|
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
arr2[i] = arr[i];
|
}
|
|
return arr2;
|
}
|
|
module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
/***/ }),
|
/* 34 */
|
/***/ (function(module, exports) {
|
|
function _nonIterableRest() {
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
}
|
|
module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
/***/ }),
|
/* 35 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
var _typeof = __webpack_require__(36)["default"];
|
|
function _regeneratorRuntime() {
|
"use strict";
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
|
return exports;
|
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
var exports = {},
|
Op = Object.prototype,
|
hasOwn = Op.hasOwnProperty,
|
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
function define(obj, key, value) {
|
return Object.defineProperty(obj, key, {
|
value: value,
|
enumerable: !0,
|
configurable: !0,
|
writable: !0
|
}), obj[key];
|
}
|
|
try {
|
define({}, "");
|
} catch (err) {
|
define = function define(obj, key, value) {
|
return obj[key] = value;
|
};
|
}
|
|
function wrap(innerFn, outerFn, self, tryLocsList) {
|
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
generator = Object.create(protoGenerator.prototype),
|
context = new Context(tryLocsList || []);
|
return generator._invoke = function (innerFn, self, context) {
|
var state = "suspendedStart";
|
return function (method, arg) {
|
if ("executing" === state) throw new Error("Generator is already running");
|
|
if ("completed" === state) {
|
if ("throw" === method) throw arg;
|
return doneResult();
|
}
|
|
for (context.method = method, context.arg = arg;;) {
|
var delegate = context.delegate;
|
|
if (delegate) {
|
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
if (delegateResult) {
|
if (delegateResult === ContinueSentinel) continue;
|
return delegateResult;
|
}
|
}
|
|
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
context.dispatchException(context.arg);
|
} else "return" === context.method && context.abrupt("return", context.arg);
|
state = "executing";
|
var record = tryCatch(innerFn, self, context);
|
|
if ("normal" === record.type) {
|
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
return {
|
value: record.arg,
|
done: context.done
|
};
|
}
|
|
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
}
|
};
|
}(innerFn, self, context), generator;
|
}
|
|
function tryCatch(fn, obj, arg) {
|
try {
|
return {
|
type: "normal",
|
arg: fn.call(obj, arg)
|
};
|
} catch (err) {
|
return {
|
type: "throw",
|
arg: err
|
};
|
}
|
}
|
|
exports.wrap = wrap;
|
var ContinueSentinel = {};
|
|
function Generator() {}
|
|
function GeneratorFunction() {}
|
|
function GeneratorFunctionPrototype() {}
|
|
var IteratorPrototype = {};
|
define(IteratorPrototype, iteratorSymbol, function () {
|
return this;
|
});
|
var getProto = Object.getPrototypeOf,
|
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
function defineIteratorMethods(prototype) {
|
["next", "throw", "return"].forEach(function (method) {
|
define(prototype, method, function (arg) {
|
return this._invoke(method, arg);
|
});
|
});
|
}
|
|
function AsyncIterator(generator, PromiseImpl) {
|
function invoke(method, arg, resolve, reject) {
|
var record = tryCatch(generator[method], generator, arg);
|
|
if ("throw" !== record.type) {
|
var result = record.arg,
|
value = result.value;
|
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
invoke("next", value, resolve, reject);
|
}, function (err) {
|
invoke("throw", err, resolve, reject);
|
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
result.value = unwrapped, resolve(result);
|
}, function (error) {
|
return invoke("throw", error, resolve, reject);
|
});
|
}
|
|
reject(record.arg);
|
}
|
|
var previousPromise;
|
|
this._invoke = function (method, arg) {
|
function callInvokeWithMethodAndArg() {
|
return new PromiseImpl(function (resolve, reject) {
|
invoke(method, arg, resolve, reject);
|
});
|
}
|
|
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
};
|
}
|
|
function maybeInvokeDelegate(delegate, context) {
|
var method = delegate.iterator[context.method];
|
|
if (undefined === method) {
|
if (context.delegate = null, "throw" === context.method) {
|
if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
}
|
|
return ContinueSentinel;
|
}
|
|
var record = tryCatch(method, delegate.iterator, context.arg);
|
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
var info = record.arg;
|
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
}
|
|
function pushTryEntry(locs) {
|
var entry = {
|
tryLoc: locs[0]
|
};
|
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
}
|
|
function resetTryEntry(entry) {
|
var record = entry.completion || {};
|
record.type = "normal", delete record.arg, entry.completion = record;
|
}
|
|
function Context(tryLocsList) {
|
this.tryEntries = [{
|
tryLoc: "root"
|
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
}
|
|
function values(iterable) {
|
if (iterable) {
|
var iteratorMethod = iterable[iteratorSymbol];
|
if (iteratorMethod) return iteratorMethod.call(iterable);
|
if ("function" == typeof iterable.next) return iterable;
|
|
if (!isNaN(iterable.length)) {
|
var i = -1,
|
next = function next() {
|
for (; ++i < iterable.length;) {
|
if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
}
|
|
return next.value = undefined, next.done = !0, next;
|
};
|
|
return next.next = next;
|
}
|
}
|
|
return {
|
next: doneResult
|
};
|
}
|
|
function doneResult() {
|
return {
|
value: undefined,
|
done: !0
|
};
|
}
|
|
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
var ctor = "function" == typeof genFun && genFun.constructor;
|
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
}, exports.mark = function (genFun) {
|
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
}, exports.awrap = function (arg) {
|
return {
|
__await: arg
|
};
|
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
return this;
|
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
return result.done ? result.value : iter.next();
|
});
|
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
return this;
|
}), define(Gp, "toString", function () {
|
return "[object Generator]";
|
}), exports.keys = function (object) {
|
var keys = [];
|
|
for (var key in object) {
|
keys.push(key);
|
}
|
|
return keys.reverse(), function next() {
|
for (; keys.length;) {
|
var key = keys.pop();
|
if (key in object) return next.value = key, next.done = !1, next;
|
}
|
|
return next.done = !0, next;
|
};
|
}, exports.values = values, Context.prototype = {
|
constructor: Context,
|
reset: function reset(skipTempReset) {
|
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
|
"t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
}
|
},
|
stop: function stop() {
|
this.done = !0;
|
var rootRecord = this.tryEntries[0].completion;
|
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
return this.rval;
|
},
|
dispatchException: function dispatchException(exception) {
|
if (this.done) throw exception;
|
var context = this;
|
|
function handle(loc, caught) {
|
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
}
|
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
var entry = this.tryEntries[i],
|
record = entry.completion;
|
if ("root" === entry.tryLoc) return handle("end");
|
|
if (entry.tryLoc <= this.prev) {
|
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
if (hasCatch && hasFinally) {
|
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
} else if (hasCatch) {
|
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
} else {
|
if (!hasFinally) throw new Error("try statement without catch or finally");
|
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
}
|
}
|
}
|
},
|
abrupt: function abrupt(type, arg) {
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
var entry = this.tryEntries[i];
|
|
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
var finallyEntry = entry;
|
break;
|
}
|
}
|
|
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
var record = finallyEntry ? finallyEntry.completion : {};
|
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
},
|
complete: function complete(record, afterLoc) {
|
if ("throw" === record.type) throw record.arg;
|
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
},
|
finish: function finish(finallyLoc) {
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
var entry = this.tryEntries[i];
|
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
}
|
},
|
"catch": function _catch(tryLoc) {
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
var entry = this.tryEntries[i];
|
|
if (entry.tryLoc === tryLoc) {
|
var record = entry.completion;
|
|
if ("throw" === record.type) {
|
var thrown = record.arg;
|
resetTryEntry(entry);
|
}
|
|
return thrown;
|
}
|
}
|
|
throw new Error("illegal catch attempt");
|
},
|
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
return this.delegate = {
|
iterator: values(iterable),
|
resultName: resultName,
|
nextLoc: nextLoc
|
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
}
|
}, exports;
|
}
|
|
module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
/***/ }),
|
/* 36 */
|
/***/ (function(module, exports) {
|
|
function _typeof(obj) {
|
"@babel/helpers - typeof";
|
|
return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
return typeof obj;
|
} : function (obj) {
|
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
}, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
|
}
|
|
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
/***/ }),
|
/* 37 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
var createDecoder = __webpack_require__(38);
|
function dbfHeader(data) {
|
var out = {};
|
out.lastUpdated = new Date(data.readUInt8(1) + 1900, data.readUInt8(2), data.readUInt8(3));
|
out.records = data.readUInt32LE(4);
|
out.headerLen = data.readUInt16LE(8);
|
out.recLen = data.readUInt16LE(10);
|
return out;
|
}
|
|
function dbfRowHeader(data, headerLen, decoder) {
|
var out = [];
|
var offset = 32;
|
while (offset < headerLen) {
|
out.push({
|
name: decoder(data.slice(offset, offset + 11)),
|
dataType: String.fromCharCode(data.readUInt8(offset + 11)),
|
len: data.readUInt8(offset + 16),
|
decimal: data.readUInt8(offset + 17)
|
});
|
if (data.readUInt8(offset + 32) === 13) {
|
break;
|
} else {
|
offset += 32;
|
}
|
}
|
return out;
|
}
|
|
function rowFuncs(buffer, offset, len, type, decoder) {
|
var data = buffer.slice(offset, offset + len);
|
var textData = decoder(data);
|
switch (type) {
|
case 'N':
|
case 'F':
|
case 'O':
|
return parseFloat(textData, 10);
|
case 'D':
|
return new Date(textData.slice(0, 4), parseInt(textData.slice(4, 6), 10) - 1, textData.slice(6, 8));
|
case 'L':
|
return textData.toLowerCase() === 'y' || textData.toLowerCase() === 't';
|
default:
|
return textData;
|
}
|
}
|
|
function parseRow(buffer, offset, rowHeaders, decoder) {
|
var out = {};
|
var i = 0;
|
var len = rowHeaders.length;
|
var field;
|
var header;
|
while (i < len) {
|
header = rowHeaders[i];
|
field = rowFuncs(buffer, offset, header.len, header.dataType, decoder);
|
offset += header.len;
|
if (typeof field !== 'undefined') {
|
out[header.name] = field;
|
}
|
i++;
|
}
|
return out;
|
}
|
|
module.exports = function(buffer, encoding) {
|
var decoder = createDecoder(encoding);
|
var header = dbfHeader(buffer);
|
var rowHeaders = dbfRowHeader(buffer, header.headerLen - 1, decoder);
|
|
var offset = ((rowHeaders.length + 1) << 5) + 2;
|
var recLen = header.recLen;
|
var records = header.records;
|
var out = [];
|
while (records) {
|
out.push(parseRow(buffer, offset, rowHeaders, decoder));
|
offset += recLen;
|
records--;
|
}
|
return out;
|
};
|
|
|
/***/ }),
|
/* 38 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
__webpack_require__(39);
|
var StringDecoder = __webpack_require__(10).StringDecoder;
|
function defaultDecoder(data) {
|
var decoder = new StringDecoder();
|
var out = decoder.write(data) + decoder.end();
|
return out.replace(/\0/g, '').trim();
|
}
|
module.exports = createDecoder;
|
var regex = /^(?:ANSI\s)?(\d+)$/m;
|
function createDecoder(encoding, second) {
|
if (!encoding) {
|
return defaultDecoder;
|
}
|
try {
|
new TextDecoder(encoding.trim());
|
} catch(e) {
|
var match = regex.exec(encoding);
|
if (match && !second) {
|
return createDecoder('windows-' + match[1], true);
|
} else {
|
return defaultDecoder;
|
}
|
}
|
return browserDecoder;
|
function browserDecoder(buffer) {
|
var decoder = new TextDecoder(encoding);
|
var out = decoder.decode(buffer, {
|
stream: true
|
}) + decoder.decode();
|
return out.replace(/\0/g, '').trim();
|
}
|
}
|
|
|
/***/ }),
|
/* 39 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
// This is free and unencumbered software released into the public domain.
|
// See LICENSE.md for more information.
|
|
module.exports = __webpack_require__(40);
|
|
|
/***/ }),
|
/* 40 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
// This is free and unencumbered software released into the public domain.
|
// See LICENSE.md for more information.
|
|
/**
|
* @fileoverview Global |this| required for resolving indexes in node.
|
* @suppress {globalThis}
|
*/
|
(function(global) {
|
'use strict';
|
|
// If we're in node require encoding-indexes and attach it to the global.
|
if ( true && module.exports &&
|
!global["encoding-indexes"]) {
|
__webpack_require__(41);
|
}
|
|
//
|
// Utilities
|
//
|
|
/**
|
* @param {number} a The number to test.
|
* @param {number} min The minimum value in the range, inclusive.
|
* @param {number} max The maximum value in the range, inclusive.
|
* @return {boolean} True if a >= min and a <= max.
|
*/
|
function inRange(a, min, max) {
|
return min <= a && a <= max;
|
}
|
|
/**
|
* @param {!Array.<*>} array The array to check.
|
* @param {*} item The item to look for in the array.
|
* @return {boolean} True if the item appears in the array.
|
*/
|
function includes(array, item) {
|
return array.indexOf(item) !== -1;
|
}
|
|
var floor = Math.floor;
|
|
/**
|
* @param {*} o
|
* @return {Object}
|
*/
|
function ToDictionary(o) {
|
if (o === undefined) return {};
|
if (o === Object(o)) return o;
|
throw TypeError('Could not convert argument to dictionary');
|
}
|
|
/**
|
* @param {string} string Input string of UTF-16 code units.
|
* @return {!Array.<number>} Code points.
|
*/
|
function stringToCodePoints(string) {
|
// https://heycam.github.io/webidl/#dfn-obtain-unicode
|
|
// 1. Let S be the DOMString value.
|
var s = String(string);
|
|
// 2. Let n be the length of S.
|
var n = s.length;
|
|
// 3. Initialize i to 0.
|
var i = 0;
|
|
// 4. Initialize U to be an empty sequence of Unicode characters.
|
var u = [];
|
|
// 5. While i < n:
|
while (i < n) {
|
|
// 1. Let c be the code unit in S at index i.
|
var c = s.charCodeAt(i);
|
|
// 2. Depending on the value of c:
|
|
// c < 0xD800 or c > 0xDFFF
|
if (c < 0xD800 || c > 0xDFFF) {
|
// Append to U the Unicode character with code point c.
|
u.push(c);
|
}
|
|
// 0xDC00 ≤ c ≤ 0xDFFF
|
else if (0xDC00 <= c && c <= 0xDFFF) {
|
// Append to U a U+FFFD REPLACEMENT CHARACTER.
|
u.push(0xFFFD);
|
}
|
|
// 0xD800 ≤ c ≤ 0xDBFF
|
else if (0xD800 <= c && c <= 0xDBFF) {
|
// 1. If i = n−1, then append to U a U+FFFD REPLACEMENT
|
// CHARACTER.
|
if (i === n - 1) {
|
u.push(0xFFFD);
|
}
|
// 2. Otherwise, i < n−1:
|
else {
|
// 1. Let d be the code unit in S at index i+1.
|
var d = s.charCodeAt(i + 1);
|
|
// 2. If 0xDC00 ≤ d ≤ 0xDFFF, then:
|
if (0xDC00 <= d && d <= 0xDFFF) {
|
// 1. Let a be c & 0x3FF.
|
var a = c & 0x3FF;
|
|
// 2. Let b be d & 0x3FF.
|
var b = d & 0x3FF;
|
|
// 3. Append to U the Unicode character with code point
|
// 2^16+2^10*a+b.
|
u.push(0x10000 + (a << 10) + b);
|
|
// 4. Set i to i+1.
|
i += 1;
|
}
|
|
// 3. Otherwise, d < 0xDC00 or d > 0xDFFF. Append to U a
|
// U+FFFD REPLACEMENT CHARACTER.
|
else {
|
u.push(0xFFFD);
|
}
|
}
|
}
|
|
// 3. Set i to i+1.
|
i += 1;
|
}
|
|
// 6. Return U.
|
return u;
|
}
|
|
/**
|
* @param {!Array.<number>} code_points Array of code points.
|
* @return {string} string String of UTF-16 code units.
|
*/
|
function codePointsToString(code_points) {
|
var s = '';
|
for (var i = 0; i < code_points.length; ++i) {
|
var cp = code_points[i];
|
if (cp <= 0xFFFF) {
|
s += String.fromCharCode(cp);
|
} else {
|
cp -= 0x10000;
|
s += String.fromCharCode((cp >> 10) + 0xD800,
|
(cp & 0x3FF) + 0xDC00);
|
}
|
}
|
return s;
|
}
|
|
|
//
|
// Implementation of Encoding specification
|
// https://encoding.spec.whatwg.org/
|
//
|
|
//
|
// 4. Terminology
|
//
|
|
/**
|
* An ASCII byte is a byte in the range 0x00 to 0x7F, inclusive.
|
* @param {number} a The number to test.
|
* @return {boolean} True if a is in the range 0x00 to 0x7F, inclusive.
|
*/
|
function isASCIIByte(a) {
|
return 0x00 <= a && a <= 0x7F;
|
}
|
|
/**
|
* An ASCII code point is a code point in the range U+0000 to
|
* U+007F, inclusive.
|
*/
|
var isASCIICodePoint = isASCIIByte;
|
|
|
/**
|
* End-of-stream is a special token that signifies no more tokens
|
* are in the stream.
|
* @const
|
*/ var end_of_stream = -1;
|
|
/**
|
* A stream represents an ordered sequence of tokens.
|
*
|
* @constructor
|
* @param {!(Array.<number>|Uint8Array)} tokens Array of tokens that provide
|
* the stream.
|
*/
|
function Stream(tokens) {
|
/** @type {!Array.<number>} */
|
this.tokens = [].slice.call(tokens);
|
// Reversed as push/pop is more efficient than shift/unshift.
|
this.tokens.reverse();
|
}
|
|
Stream.prototype = {
|
/**
|
* @return {boolean} True if end-of-stream has been hit.
|
*/
|
endOfStream: function() {
|
return !this.tokens.length;
|
},
|
|
/**
|
* When a token is read from a stream, the first token in the
|
* stream must be returned and subsequently removed, and
|
* end-of-stream must be returned otherwise.
|
*
|
* @return {number} Get the next token from the stream, or
|
* end_of_stream.
|
*/
|
read: function() {
|
if (!this.tokens.length)
|
return end_of_stream;
|
return this.tokens.pop();
|
},
|
|
/**
|
* When one or more tokens are prepended to a stream, those tokens
|
* must be inserted, in given order, before the first token in the
|
* stream.
|
*
|
* @param {(number|!Array.<number>)} token The token(s) to prepend to the
|
* stream.
|
*/
|
prepend: function(token) {
|
if (Array.isArray(token)) {
|
var tokens = /**@type {!Array.<number>}*/(token);
|
while (tokens.length)
|
this.tokens.push(tokens.pop());
|
} else {
|
this.tokens.push(token);
|
}
|
},
|
|
/**
|
* When one or more tokens are pushed to a stream, those tokens
|
* must be inserted, in given order, after the last token in the
|
* stream.
|
*
|
* @param {(number|!Array.<number>)} token The tokens(s) to push to the
|
* stream.
|
*/
|
push: function(token) {
|
if (Array.isArray(token)) {
|
var tokens = /**@type {!Array.<number>}*/(token);
|
while (tokens.length)
|
this.tokens.unshift(tokens.shift());
|
} else {
|
this.tokens.unshift(token);
|
}
|
}
|
};
|
|
//
|
// 5. Encodings
|
//
|
|
// 5.1 Encoders and decoders
|
|
/** @const */
|
var finished = -1;
|
|
/**
|
* @param {boolean} fatal If true, decoding errors raise an exception.
|
* @param {number=} opt_code_point Override the standard fallback code point.
|
* @return {number} The code point to insert on a decoding error.
|
*/
|
function decoderError(fatal, opt_code_point) {
|
if (fatal)
|
throw TypeError('Decoder error');
|
return opt_code_point || 0xFFFD;
|
}
|
|
/**
|
* @param {number} code_point The code point that could not be encoded.
|
* @return {number} Always throws, no value is actually returned.
|
*/
|
function encoderError(code_point) {
|
throw TypeError('The code point ' + code_point + ' could not be encoded.');
|
}
|
|
/** @interface */
|
function Decoder() {}
|
Decoder.prototype = {
|
/**
|
* @param {Stream} stream The stream of bytes being decoded.
|
* @param {number} bite The next byte read from the stream.
|
* @return {?(number|!Array.<number>)} The next code point(s)
|
* decoded, or null if not enough data exists in the input
|
* stream to decode a complete code point, or |finished|.
|
*/
|
handler: function(stream, bite) {}
|
};
|
|
/** @interface */
|
function Encoder() {}
|
Encoder.prototype = {
|
/**
|
* @param {Stream} stream The stream of code points being encoded.
|
* @param {number} code_point Next code point read from the stream.
|
* @return {(number|!Array.<number>)} Byte(s) to emit, or |finished|.
|
*/
|
handler: function(stream, code_point) {}
|
};
|
|
// 5.2 Names and labels
|
|
// TODO: Define @typedef for Encoding: {name:string,labels:Array.<string>}
|
// https://github.com/google/closure-compiler/issues/247
|
|
/**
|
* @param {string} label The encoding label.
|
* @return {?{name:string,labels:Array.<string>}}
|
*/
|
function getEncoding(label) {
|
// 1. Remove any leading and trailing ASCII whitespace from label.
|
label = String(label).trim().toLowerCase();
|
|
// 2. If label is an ASCII case-insensitive match for any of the
|
// labels listed in the table below, return the corresponding
|
// encoding, and failure otherwise.
|
if (Object.prototype.hasOwnProperty.call(label_to_encoding, label)) {
|
return label_to_encoding[label];
|
}
|
return null;
|
}
|
|
/**
|
* Encodings table: https://encoding.spec.whatwg.org/encodings.json
|
* @const
|
* @type {!Array.<{
|
* heading: string,
|
* encodings: Array.<{name:string,labels:Array.<string>}>
|
* }>}
|
*/
|
var encodings = [
|
{
|
"encodings": [
|
{
|
"labels": [
|
"unicode-1-1-utf-8",
|
"utf-8",
|
"utf8"
|
],
|
"name": "UTF-8"
|
}
|
],
|
"heading": "The Encoding"
|
},
|
{
|
"encodings": [
|
{
|
"labels": [
|
"866",
|
"cp866",
|
"csibm866",
|
"ibm866"
|
],
|
"name": "IBM866"
|
},
|
{
|
"labels": [
|
"csisolatin2",
|
"iso-8859-2",
|
"iso-ir-101",
|
"iso8859-2",
|
"iso88592",
|
"iso_8859-2",
|
"iso_8859-2:1987",
|
"l2",
|
"latin2"
|
],
|
"name": "ISO-8859-2"
|
},
|
{
|
"labels": [
|
"csisolatin3",
|
"iso-8859-3",
|
"iso-ir-109",
|
"iso8859-3",
|
"iso88593",
|
"iso_8859-3",
|
"iso_8859-3:1988",
|
"l3",
|
"latin3"
|
],
|
"name": "ISO-8859-3"
|
},
|
{
|
"labels": [
|
"csisolatin4",
|
"iso-8859-4",
|
"iso-ir-110",
|
"iso8859-4",
|
"iso88594",
|
"iso_8859-4",
|
"iso_8859-4:1988",
|
"l4",
|
"latin4"
|
],
|
"name": "ISO-8859-4"
|
},
|
{
|
"labels": [
|
"csisolatincyrillic",
|
"cyrillic",
|
"iso-8859-5",
|
"iso-ir-144",
|
"iso8859-5",
|
"iso88595",
|
"iso_8859-5",
|
"iso_8859-5:1988"
|
],
|
"name": "ISO-8859-5"
|
},
|
{
|
"labels": [
|
"arabic",
|
"asmo-708",
|
"csiso88596e",
|
"csiso88596i",
|
"csisolatinarabic",
|
"ecma-114",
|
"iso-8859-6",
|
"iso-8859-6-e",
|
"iso-8859-6-i",
|
"iso-ir-127",
|
"iso8859-6",
|
"iso88596",
|
"iso_8859-6",
|
"iso_8859-6:1987"
|
],
|
"name": "ISO-8859-6"
|
},
|
{
|
"labels": [
|
"csisolatingreek",
|
"ecma-118",
|
"elot_928",
|
"greek",
|
"greek8",
|
"iso-8859-7",
|
"iso-ir-126",
|
"iso8859-7",
|
"iso88597",
|
"iso_8859-7",
|
"iso_8859-7:1987",
|
"sun_eu_greek"
|
],
|
"name": "ISO-8859-7"
|
},
|
{
|
"labels": [
|
"csiso88598e",
|
"csisolatinhebrew",
|
"hebrew",
|
"iso-8859-8",
|
"iso-8859-8-e",
|
"iso-ir-138",
|
"iso8859-8",
|
"iso88598",
|
"iso_8859-8",
|
"iso_8859-8:1988",
|
"visual"
|
],
|
"name": "ISO-8859-8"
|
},
|
{
|
"labels": [
|
"csiso88598i",
|
"iso-8859-8-i",
|
"logical"
|
],
|
"name": "ISO-8859-8-I"
|
},
|
{
|
"labels": [
|
"csisolatin6",
|
"iso-8859-10",
|
"iso-ir-157",
|
"iso8859-10",
|
"iso885910",
|
"l6",
|
"latin6"
|
],
|
"name": "ISO-8859-10"
|
},
|
{
|
"labels": [
|
"iso-8859-13",
|
"iso8859-13",
|
"iso885913"
|
],
|
"name": "ISO-8859-13"
|
},
|
{
|
"labels": [
|
"iso-8859-14",
|
"iso8859-14",
|
"iso885914"
|
],
|
"name": "ISO-8859-14"
|
},
|
{
|
"labels": [
|
"csisolatin9",
|
"iso-8859-15",
|
"iso8859-15",
|
"iso885915",
|
"iso_8859-15",
|
"l9"
|
],
|
"name": "ISO-8859-15"
|
},
|
{
|
"labels": [
|
"iso-8859-16"
|
],
|
"name": "ISO-8859-16"
|
},
|
{
|
"labels": [
|
"cskoi8r",
|
"koi",
|
"koi8",
|
"koi8-r",
|
"koi8_r"
|
],
|
"name": "KOI8-R"
|
},
|
{
|
"labels": [
|
"koi8-ru",
|
"koi8-u"
|
],
|
"name": "KOI8-U"
|
},
|
{
|
"labels": [
|
"csmacintosh",
|
"mac",
|
"macintosh",
|
"x-mac-roman"
|
],
|
"name": "macintosh"
|
},
|
{
|
"labels": [
|
"dos-874",
|
"iso-8859-11",
|
"iso8859-11",
|
"iso885911",
|
"tis-620",
|
"windows-874"
|
],
|
"name": "windows-874"
|
},
|
{
|
"labels": [
|
"cp1250",
|
"windows-1250",
|
"x-cp1250"
|
],
|
"name": "windows-1250"
|
},
|
{
|
"labels": [
|
"cp1251",
|
"windows-1251",
|
"x-cp1251"
|
],
|
"name": "windows-1251"
|
},
|
{
|
"labels": [
|
"ansi_x3.4-1968",
|
"ascii",
|
"cp1252",
|
"cp819",
|
"csisolatin1",
|
"ibm819",
|
"iso-8859-1",
|
"iso-ir-100",
|
"iso8859-1",
|
"iso88591",
|
"iso_8859-1",
|
"iso_8859-1:1987",
|
"l1",
|
"latin1",
|
"us-ascii",
|
"windows-1252",
|
"x-cp1252"
|
],
|
"name": "windows-1252"
|
},
|
{
|
"labels": [
|
"cp1253",
|
"windows-1253",
|
"x-cp1253"
|
],
|
"name": "windows-1253"
|
},
|
{
|
"labels": [
|
"cp1254",
|
"csisolatin5",
|
"iso-8859-9",
|
"iso-ir-148",
|
"iso8859-9",
|
"iso88599",
|
"iso_8859-9",
|
"iso_8859-9:1989",
|
"l5",
|
"latin5",
|
"windows-1254",
|
"x-cp1254"
|
],
|
"name": "windows-1254"
|
},
|
{
|
"labels": [
|
"cp1255",
|
"windows-1255",
|
"x-cp1255"
|
],
|
"name": "windows-1255"
|
},
|
{
|
"labels": [
|
"cp1256",
|
"windows-1256",
|
"x-cp1256"
|
],
|
"name": "windows-1256"
|
},
|
{
|
"labels": [
|
"cp1257",
|
"windows-1257",
|
"x-cp1257"
|
],
|
"name": "windows-1257"
|
},
|
{
|
"labels": [
|
"cp1258",
|
"windows-1258",
|
"x-cp1258"
|
],
|
"name": "windows-1258"
|
},
|
{
|
"labels": [
|
"x-mac-cyrillic",
|
"x-mac-ukrainian"
|
],
|
"name": "x-mac-cyrillic"
|
}
|
],
|
"heading": "Legacy single-byte encodings"
|
},
|
{
|
"encodings": [
|
{
|
"labels": [
|
"chinese",
|
"csgb2312",
|
"csiso58gb231280",
|
"gb2312",
|
"gb_2312",
|
"gb_2312-80",
|
"gbk",
|
"iso-ir-58",
|
"x-gbk"
|
],
|
"name": "GBK"
|
},
|
{
|
"labels": [
|
"gb18030"
|
],
|
"name": "gb18030"
|
}
|
],
|
"heading": "Legacy multi-byte Chinese (simplified) encodings"
|
},
|
{
|
"encodings": [
|
{
|
"labels": [
|
"big5",
|
"big5-hkscs",
|
"cn-big5",
|
"csbig5",
|
"x-x-big5"
|
],
|
"name": "Big5"
|
}
|
],
|
"heading": "Legacy multi-byte Chinese (traditional) encodings"
|
},
|
{
|
"encodings": [
|
{
|
"labels": [
|
"cseucpkdfmtjapanese",
|
"euc-jp",
|
"x-euc-jp"
|
],
|
"name": "EUC-JP"
|
},
|
{
|
"labels": [
|
"csiso2022jp",
|
"iso-2022-jp"
|
],
|
"name": "ISO-2022-JP"
|
},
|
{
|
"labels": [
|
"csshiftjis",
|
"ms932",
|
"ms_kanji",
|
"shift-jis",
|
"shift_jis",
|
"sjis",
|
"windows-31j",
|
"x-sjis"
|
],
|
"name": "Shift_JIS"
|
}
|
],
|
"heading": "Legacy multi-byte Japanese encodings"
|
},
|
{
|
"encodings": [
|
{
|
"labels": [
|
"cseuckr",
|
"csksc56011987",
|
"euc-kr",
|
"iso-ir-149",
|
"korean",
|
"ks_c_5601-1987",
|
"ks_c_5601-1989",
|
"ksc5601",
|
"ksc_5601",
|
"windows-949"
|
],
|
"name": "EUC-KR"
|
}
|
],
|
"heading": "Legacy multi-byte Korean encodings"
|
},
|
{
|
"encodings": [
|
{
|
"labels": [
|
"csiso2022kr",
|
"hz-gb-2312",
|
"iso-2022-cn",
|
"iso-2022-cn-ext",
|
"iso-2022-kr"
|
],
|
"name": "replacement"
|
},
|
{
|
"labels": [
|
"utf-16be"
|
],
|
"name": "UTF-16BE"
|
},
|
{
|
"labels": [
|
"utf-16",
|
"utf-16le"
|
],
|
"name": "UTF-16LE"
|
},
|
{
|
"labels": [
|
"x-user-defined"
|
],
|
"name": "x-user-defined"
|
}
|
],
|
"heading": "Legacy miscellaneous encodings"
|
}
|
];
|
|
// Label to encoding registry.
|
/** @type {Object.<string,{name:string,labels:Array.<string>}>} */
|
var label_to_encoding = {};
|
encodings.forEach(function(category) {
|
category.encodings.forEach(function(encoding) {
|
encoding.labels.forEach(function(label) {
|
label_to_encoding[label] = encoding;
|
});
|
});
|
});
|
|
// Registry of of encoder/decoder factories, by encoding name.
|
/** @type {Object.<string, function({fatal:boolean}): Encoder>} */
|
var encoders = {};
|
/** @type {Object.<string, function({fatal:boolean}): Decoder>} */
|
var decoders = {};
|
|
//
|
// 6. Indexes
|
//
|
|
/**
|
* @param {number} pointer The |pointer| to search for.
|
* @param {(!Array.<?number>|undefined)} index The |index| to search within.
|
* @return {?number} The code point corresponding to |pointer| in |index|,
|
* or null if |code point| is not in |index|.
|
*/
|
function indexCodePointFor(pointer, index) {
|
if (!index) return null;
|
return index[pointer] || null;
|
}
|
|
/**
|
* @param {number} code_point The |code point| to search for.
|
* @param {!Array.<?number>} index The |index| to search within.
|
* @return {?number} The first pointer corresponding to |code point| in
|
* |index|, or null if |code point| is not in |index|.
|
*/
|
function indexPointerFor(code_point, index) {
|
var pointer = index.indexOf(code_point);
|
return pointer === -1 ? null : pointer;
|
}
|
|
/**
|
* @param {string} name Name of the index.
|
* @return {(!Array.<number>|!Array.<Array.<number>>)}
|
* */
|
function index(name) {
|
if (!('encoding-indexes' in global)) {
|
throw Error("Indexes missing." +
|
" Did you forget to include encoding-indexes.js first?");
|
}
|
return global['encoding-indexes'][name];
|
}
|
|
/**
|
* @param {number} pointer The |pointer| to search for in the gb18030 index.
|
* @return {?number} The code point corresponding to |pointer| in |index|,
|
* or null if |code point| is not in the gb18030 index.
|
*/
|
function indexGB18030RangesCodePointFor(pointer) {
|
// 1. If pointer is greater than 39419 and less than 189000, or
|
// pointer is greater than 1237575, return null.
|
if ((pointer > 39419 && pointer < 189000) || (pointer > 1237575))
|
return null;
|
|
// 2. If pointer is 7457, return code point U+E7C7.
|
if (pointer === 7457) return 0xE7C7;
|
|
// 3. Let offset be the last pointer in index gb18030 ranges that
|
// is equal to or less than pointer and let code point offset be
|
// its corresponding code point.
|
var offset = 0;
|
var code_point_offset = 0;
|
var idx = index('gb18030-ranges');
|
var i;
|
for (i = 0; i < idx.length; ++i) {
|
/** @type {!Array.<number>} */
|
var entry = idx[i];
|
if (entry[0] <= pointer) {
|
offset = entry[0];
|
code_point_offset = entry[1];
|
} else {
|
break;
|
}
|
}
|
|
// 4. Return a code point whose value is code point offset +
|
// pointer − offset.
|
return code_point_offset + pointer - offset;
|
}
|
|
/**
|
* @param {number} code_point The |code point| to locate in the gb18030 index.
|
* @return {number} The first pointer corresponding to |code point| in the
|
* gb18030 index.
|
*/
|
function indexGB18030RangesPointerFor(code_point) {
|
// 1. If code point is U+E7C7, return pointer 7457.
|
if (code_point === 0xE7C7) return 7457;
|
|
// 2. Let offset be the last code point in index gb18030 ranges
|
// that is equal to or less than code point and let pointer offset
|
// be its corresponding pointer.
|
var offset = 0;
|
var pointer_offset = 0;
|
var idx = index('gb18030-ranges');
|
var i;
|
for (i = 0; i < idx.length; ++i) {
|
/** @type {!Array.<number>} */
|
var entry = idx[i];
|
if (entry[1] <= code_point) {
|
offset = entry[1];
|
pointer_offset = entry[0];
|
} else {
|
break;
|
}
|
}
|
|
// 3. Return a pointer whose value is pointer offset + code point
|
// − offset.
|
return pointer_offset + code_point - offset;
|
}
|
|
/**
|
* @param {number} code_point The |code_point| to search for in the Shift_JIS
|
* index.
|
* @return {?number} The code point corresponding to |pointer| in |index|,
|
* or null if |code point| is not in the Shift_JIS index.
|
*/
|
function indexShiftJISPointerFor(code_point) {
|
// 1. Let index be index jis0208 excluding all entries whose
|
// pointer is in the range 8272 to 8835, inclusive.
|
shift_jis_index = shift_jis_index ||
|
index('jis0208').map(function(code_point, pointer) {
|
return inRange(pointer, 8272, 8835) ? null : code_point;
|
});
|
var index_ = shift_jis_index;
|
|
// 2. Return the index pointer for code point in index.
|
return index_.indexOf(code_point);
|
}
|
var shift_jis_index;
|
|
/**
|
* @param {number} code_point The |code_point| to search for in the big5
|
* index.
|
* @return {?number} The code point corresponding to |pointer| in |index|,
|
* or null if |code point| is not in the big5 index.
|
*/
|
function indexBig5PointerFor(code_point) {
|
// 1. Let index be index Big5 excluding all entries whose pointer
|
big5_index_no_hkscs = big5_index_no_hkscs ||
|
index('big5').map(function(code_point, pointer) {
|
return (pointer < (0xA1 - 0x81) * 157) ? null : code_point;
|
});
|
var index_ = big5_index_no_hkscs;
|
|
// 2. If code point is U+2550, U+255E, U+2561, U+256A, U+5341, or
|
// U+5345, return the last pointer corresponding to code point in
|
// index.
|
if (code_point === 0x2550 || code_point === 0x255E ||
|
code_point === 0x2561 || code_point === 0x256A ||
|
code_point === 0x5341 || code_point === 0x5345) {
|
return index_.lastIndexOf(code_point);
|
}
|
|
// 3. Return the index pointer for code point in index.
|
return indexPointerFor(code_point, index_);
|
}
|
var big5_index_no_hkscs;
|
|
//
|
// 8. API
|
//
|
|
/** @const */ var DEFAULT_ENCODING = 'utf-8';
|
|
// 8.1 Interface TextDecoder
|
|
/**
|
* @constructor
|
* @param {string=} label The label of the encoding;
|
* defaults to 'utf-8'.
|
* @param {Object=} options
|
*/
|
function TextDecoder(label, options) {
|
// Web IDL conventions
|
if (!(this instanceof TextDecoder))
|
throw TypeError('Called as a function. Did you forget \'new\'?');
|
label = label !== undefined ? String(label) : DEFAULT_ENCODING;
|
options = ToDictionary(options);
|
|
// A TextDecoder object has an associated encoding, decoder,
|
// stream, ignore BOM flag (initially unset), BOM seen flag
|
// (initially unset), error mode (initially replacement), and do
|
// not flush flag (initially unset).
|
|
/** @private */
|
this._encoding = null;
|
/** @private @type {?Decoder} */
|
this._decoder = null;
|
/** @private @type {boolean} */
|
this._ignoreBOM = false;
|
/** @private @type {boolean} */
|
this._BOMseen = false;
|
/** @private @type {string} */
|
this._error_mode = 'replacement';
|
/** @private @type {boolean} */
|
this._do_not_flush = false;
|
|
|
// 1. Let encoding be the result of getting an encoding from
|
// label.
|
var encoding = getEncoding(label);
|
|
// 2. If encoding is failure or replacement, throw a RangeError.
|
if (encoding === null || encoding.name === 'replacement')
|
throw RangeError('Unknown encoding: ' + label);
|
if (!decoders[encoding.name]) {
|
throw Error('Decoder not present.' +
|
' Did you forget to include encoding-indexes.js first?');
|
}
|
|
// 3. Let dec be a new TextDecoder object.
|
var dec = this;
|
|
// 4. Set dec's encoding to encoding.
|
dec._encoding = encoding;
|
|
// 5. If options's fatal member is true, set dec's error mode to
|
// fatal.
|
if (Boolean(options['fatal']))
|
dec._error_mode = 'fatal';
|
|
// 6. If options's ignoreBOM member is true, set dec's ignore BOM
|
// flag.
|
if (Boolean(options['ignoreBOM']))
|
dec._ignoreBOM = true;
|
|
// For pre-ES5 runtimes:
|
if (!Object.defineProperty) {
|
this.encoding = dec._encoding.name.toLowerCase();
|
this.fatal = dec._error_mode === 'fatal';
|
this.ignoreBOM = dec._ignoreBOM;
|
}
|
|
// 7. Return dec.
|
return dec;
|
}
|
|
if (Object.defineProperty) {
|
// The encoding attribute's getter must return encoding's name.
|
Object.defineProperty(TextDecoder.prototype, 'encoding', {
|
/** @this {TextDecoder} */
|
get: function() { return this._encoding.name.toLowerCase(); }
|
});
|
|
// The fatal attribute's getter must return true if error mode
|
// is fatal, and false otherwise.
|
Object.defineProperty(TextDecoder.prototype, 'fatal', {
|
/** @this {TextDecoder} */
|
get: function() { return this._error_mode === 'fatal'; }
|
});
|
|
// The ignoreBOM attribute's getter must return true if ignore
|
// BOM flag is set, and false otherwise.
|
Object.defineProperty(TextDecoder.prototype, 'ignoreBOM', {
|
/** @this {TextDecoder} */
|
get: function() { return this._ignoreBOM; }
|
});
|
}
|
|
/**
|
* @param {BufferSource=} input The buffer of bytes to decode.
|
* @param {Object=} options
|
* @return {string} The decoded string.
|
*/
|
TextDecoder.prototype.decode = function decode(input, options) {
|
var bytes;
|
if (typeof input === 'object' && input instanceof ArrayBuffer) {
|
bytes = new Uint8Array(input);
|
} else if (typeof input === 'object' && 'buffer' in input &&
|
input.buffer instanceof ArrayBuffer) {
|
bytes = new Uint8Array(input.buffer,
|
input.byteOffset,
|
input.byteLength);
|
} else {
|
bytes = new Uint8Array(0);
|
}
|
|
options = ToDictionary(options);
|
|
// 1. If the do not flush flag is unset, set decoder to a new
|
// encoding's decoder, set stream to a new stream, and unset the
|
// BOM seen flag.
|
if (!this._do_not_flush) {
|
this._decoder = decoders[this._encoding.name]({
|
fatal: this._error_mode === 'fatal'});
|
this._BOMseen = false;
|
}
|
|
// 2. If options's stream is true, set the do not flush flag, and
|
// unset the do not flush flag otherwise.
|
this._do_not_flush = Boolean(options['stream']);
|
|
// 3. If input is given, push a copy of input to stream.
|
// TODO: Align with spec algorithm - maintain stream on instance.
|
var input_stream = new Stream(bytes);
|
|
// 4. Let output be a new stream.
|
var output = [];
|
|
/** @type {?(number|!Array.<number>)} */
|
var result;
|
|
// 5. While true:
|
while (true) {
|
// 1. Let token be the result of reading from stream.
|
var token = input_stream.read();
|
|
// 2. If token is end-of-stream and the do not flush flag is
|
// set, return output, serialized.
|
// TODO: Align with spec algorithm.
|
if (token === end_of_stream)
|
break;
|
|
// 3. Otherwise, run these subsubsteps:
|
|
// 1. Let result be the result of processing token for decoder,
|
// stream, output, and error mode.
|
result = this._decoder.handler(input_stream, token);
|
|
// 2. If result is finished, return output, serialized.
|
if (result === finished)
|
break;
|
|
if (result !== null) {
|
if (Array.isArray(result))
|
output.push.apply(output, /**@type {!Array.<number>}*/(result));
|
else
|
output.push(result);
|
}
|
|
// 3. Otherwise, if result is error, throw a TypeError.
|
// (Thrown in handler)
|
|
// 4. Otherwise, do nothing.
|
}
|
// TODO: Align with spec algorithm.
|
if (!this._do_not_flush) {
|
do {
|
result = this._decoder.handler(input_stream, input_stream.read());
|
if (result === finished)
|
break;
|
if (result === null)
|
continue;
|
if (Array.isArray(result))
|
output.push.apply(output, /**@type {!Array.<number>}*/(result));
|
else
|
output.push(result);
|
} while (!input_stream.endOfStream());
|
this._decoder = null;
|
}
|
|
// A TextDecoder object also has an associated serialize stream
|
// algorithm...
|
/**
|
* @param {!Array.<number>} stream
|
* @return {string}
|
* @this {TextDecoder}
|
*/
|
function serializeStream(stream) {
|
// 1. Let token be the result of reading from stream.
|
// (Done in-place on array, rather than as a stream)
|
|
// 2. If encoding is UTF-8, UTF-16BE, or UTF-16LE, and ignore
|
// BOM flag and BOM seen flag are unset, run these subsubsteps:
|
if (includes(['UTF-8', 'UTF-16LE', 'UTF-16BE'], this._encoding.name) &&
|
!this._ignoreBOM && !this._BOMseen) {
|
if (stream.length > 0 && stream[0] === 0xFEFF) {
|
// 1. If token is U+FEFF, set BOM seen flag.
|
this._BOMseen = true;
|
stream.shift();
|
} else if (stream.length > 0) {
|
// 2. Otherwise, if token is not end-of-stream, set BOM seen
|
// flag and append token to stream.
|
this._BOMseen = true;
|
} else {
|
// 3. Otherwise, if token is not end-of-stream, append token
|
// to output.
|
// (no-op)
|
}
|
}
|
// 4. Otherwise, return output.
|
return codePointsToString(stream);
|
}
|
|
return serializeStream.call(this, output);
|
};
|
|
// 8.2 Interface TextEncoder
|
|
/**
|
* @constructor
|
* @param {string=} label The label of the encoding. NONSTANDARD.
|
* @param {Object=} options NONSTANDARD.
|
*/
|
function TextEncoder(label, options) {
|
// Web IDL conventions
|
if (!(this instanceof TextEncoder))
|
throw TypeError('Called as a function. Did you forget \'new\'?');
|
options = ToDictionary(options);
|
|
// A TextEncoder object has an associated encoding and encoder.
|
|
/** @private */
|
this._encoding = null;
|
/** @private @type {?Encoder} */
|
this._encoder = null;
|
|
// Non-standard
|
/** @private @type {boolean} */
|
this._do_not_flush = false;
|
/** @private @type {string} */
|
this._fatal = Boolean(options['fatal']) ? 'fatal' : 'replacement';
|
|
// 1. Let enc be a new TextEncoder object.
|
var enc = this;
|
|
// 2. Set enc's encoding to UTF-8's encoder.
|
if (Boolean(options['NONSTANDARD_allowLegacyEncoding'])) {
|
// NONSTANDARD behavior.
|
label = label !== undefined ? String(label) : DEFAULT_ENCODING;
|
var encoding = getEncoding(label);
|
if (encoding === null || encoding.name === 'replacement')
|
throw RangeError('Unknown encoding: ' + label);
|
if (!encoders[encoding.name]) {
|
throw Error('Encoder not present.' +
|
' Did you forget to include encoding-indexes.js first?');
|
}
|
enc._encoding = encoding;
|
} else {
|
// Standard behavior.
|
enc._encoding = getEncoding('utf-8');
|
|
if (label !== undefined && 'console' in global) {
|
console.warn('TextEncoder constructor called with encoding label, '
|
+ 'which is ignored.');
|
}
|
}
|
|
// For pre-ES5 runtimes:
|
if (!Object.defineProperty)
|
this.encoding = enc._encoding.name.toLowerCase();
|
|
// 3. Return enc.
|
return enc;
|
}
|
|
if (Object.defineProperty) {
|
// The encoding attribute's getter must return encoding's name.
|
Object.defineProperty(TextEncoder.prototype, 'encoding', {
|
/** @this {TextEncoder} */
|
get: function() { return this._encoding.name.toLowerCase(); }
|
});
|
}
|
|
/**
|
* @param {string=} opt_string The string to encode.
|
* @param {Object=} options
|
* @return {!Uint8Array} Encoded bytes, as a Uint8Array.
|
*/
|
TextEncoder.prototype.encode = function encode(opt_string, options) {
|
opt_string = opt_string === undefined ? '' : String(opt_string);
|
options = ToDictionary(options);
|
|
// NOTE: This option is nonstandard. None of the encodings
|
// permitted for encoding (i.e. UTF-8, UTF-16) are stateful when
|
// the input is a USVString so streaming is not necessary.
|
if (!this._do_not_flush)
|
this._encoder = encoders[this._encoding.name]({
|
fatal: this._fatal === 'fatal'});
|
this._do_not_flush = Boolean(options['stream']);
|
|
// 1. Convert input to a stream.
|
var input = new Stream(stringToCodePoints(opt_string));
|
|
// 2. Let output be a new stream
|
var output = [];
|
|
/** @type {?(number|!Array.<number>)} */
|
var result;
|
// 3. While true, run these substeps:
|
while (true) {
|
// 1. Let token be the result of reading from input.
|
var token = input.read();
|
if (token === end_of_stream)
|
break;
|
// 2. Let result be the result of processing token for encoder,
|
// input, output.
|
result = this._encoder.handler(input, token);
|
if (result === finished)
|
break;
|
if (Array.isArray(result))
|
output.push.apply(output, /**@type {!Array.<number>}*/(result));
|
else
|
output.push(result);
|
}
|
// TODO: Align with spec algorithm.
|
if (!this._do_not_flush) {
|
while (true) {
|
result = this._encoder.handler(input, input.read());
|
if (result === finished)
|
break;
|
if (Array.isArray(result))
|
output.push.apply(output, /**@type {!Array.<number>}*/(result));
|
else
|
output.push(result);
|
}
|
this._encoder = null;
|
}
|
// 3. If result is finished, convert output into a byte sequence,
|
// and then return a Uint8Array object wrapping an ArrayBuffer
|
// containing output.
|
return new Uint8Array(output);
|
};
|
|
|
//
|
// 9. The encoding
|
//
|
|
// 9.1 utf-8
|
|
// 9.1.1 utf-8 decoder
|
/**
|
* @constructor
|
* @implements {Decoder}
|
* @param {{fatal: boolean}} options
|
*/
|
function UTF8Decoder(options) {
|
var fatal = options.fatal;
|
|
// utf-8's decoder's has an associated utf-8 code point, utf-8
|
// bytes seen, and utf-8 bytes needed (all initially 0), a utf-8
|
// lower boundary (initially 0x80), and a utf-8 upper boundary
|
// (initially 0xBF).
|
var /** @type {number} */ utf8_code_point = 0,
|
/** @type {number} */ utf8_bytes_seen = 0,
|
/** @type {number} */ utf8_bytes_needed = 0,
|
/** @type {number} */ utf8_lower_boundary = 0x80,
|
/** @type {number} */ utf8_upper_boundary = 0xBF;
|
|
/**
|
* @param {Stream} stream The stream of bytes being decoded.
|
* @param {number} bite The next byte read from the stream.
|
* @return {?(number|!Array.<number>)} The next code point(s)
|
* decoded, or null if not enough data exists in the input
|
* stream to decode a complete code point.
|
*/
|
this.handler = function(stream, bite) {
|
// 1. If byte is end-of-stream and utf-8 bytes needed is not 0,
|
// set utf-8 bytes needed to 0 and return error.
|
if (bite === end_of_stream && utf8_bytes_needed !== 0) {
|
utf8_bytes_needed = 0;
|
return decoderError(fatal);
|
}
|
|
// 2. If byte is end-of-stream, return finished.
|
if (bite === end_of_stream)
|
return finished;
|
|
// 3. If utf-8 bytes needed is 0, based on byte:
|
if (utf8_bytes_needed === 0) {
|
|
// 0x00 to 0x7F
|
if (inRange(bite, 0x00, 0x7F)) {
|
// Return a code point whose value is byte.
|
return bite;
|
}
|
|
// 0xC2 to 0xDF
|
else if (inRange(bite, 0xC2, 0xDF)) {
|
// 1. Set utf-8 bytes needed to 1.
|
utf8_bytes_needed = 1;
|
|
// 2. Set UTF-8 code point to byte & 0x1F.
|
utf8_code_point = bite & 0x1F;
|
}
|
|
// 0xE0 to 0xEF
|
else if (inRange(bite, 0xE0, 0xEF)) {
|
// 1. If byte is 0xE0, set utf-8 lower boundary to 0xA0.
|
if (bite === 0xE0)
|
utf8_lower_boundary = 0xA0;
|
// 2. If byte is 0xED, set utf-8 upper boundary to 0x9F.
|
if (bite === 0xED)
|
utf8_upper_boundary = 0x9F;
|
// 3. Set utf-8 bytes needed to 2.
|
utf8_bytes_needed = 2;
|
// 4. Set UTF-8 code point to byte & 0xF.
|
utf8_code_point = bite & 0xF;
|
}
|
|
// 0xF0 to 0xF4
|
else if (inRange(bite, 0xF0, 0xF4)) {
|
// 1. If byte is 0xF0, set utf-8 lower boundary to 0x90.
|
if (bite === 0xF0)
|
utf8_lower_boundary = 0x90;
|
// 2. If byte is 0xF4, set utf-8 upper boundary to 0x8F.
|
if (bite === 0xF4)
|
utf8_upper_boundary = 0x8F;
|
// 3. Set utf-8 bytes needed to 3.
|
utf8_bytes_needed = 3;
|
// 4. Set UTF-8 code point to byte & 0x7.
|
utf8_code_point = bite & 0x7;
|
}
|
|
// Otherwise
|
else {
|
// Return error.
|
return decoderError(fatal);
|
}
|
|
// Return continue.
|
return null;
|
}
|
|
// 4. If byte is not in the range utf-8 lower boundary to utf-8
|
// upper boundary, inclusive, run these substeps:
|
if (!inRange(bite, utf8_lower_boundary, utf8_upper_boundary)) {
|
|
// 1. Set utf-8 code point, utf-8 bytes needed, and utf-8
|
// bytes seen to 0, set utf-8 lower boundary to 0x80, and set
|
// utf-8 upper boundary to 0xBF.
|
utf8_code_point = utf8_bytes_needed = utf8_bytes_seen = 0;
|
utf8_lower_boundary = 0x80;
|
utf8_upper_boundary = 0xBF;
|
|
// 2. Prepend byte to stream.
|
stream.prepend(bite);
|
|
// 3. Return error.
|
return decoderError(fatal);
|
}
|
|
// 5. Set utf-8 lower boundary to 0x80 and utf-8 upper boundary
|
// to 0xBF.
|
utf8_lower_boundary = 0x80;
|
utf8_upper_boundary = 0xBF;
|
|
// 6. Set UTF-8 code point to (UTF-8 code point << 6) | (byte &
|
// 0x3F)
|
utf8_code_point = (utf8_code_point << 6) | (bite & 0x3F);
|
|
// 7. Increase utf-8 bytes seen by one.
|
utf8_bytes_seen += 1;
|
|
// 8. If utf-8 bytes seen is not equal to utf-8 bytes needed,
|
// continue.
|
if (utf8_bytes_seen !== utf8_bytes_needed)
|
return null;
|
|
// 9. Let code point be utf-8 code point.
|
var code_point = utf8_code_point;
|
|
// 10. Set utf-8 code point, utf-8 bytes needed, and utf-8 bytes
|
// seen to 0.
|
utf8_code_point = utf8_bytes_needed = utf8_bytes_seen = 0;
|
|
// 11. Return a code point whose value is code point.
|
return code_point;
|
};
|
}
|
|
// 9.1.2 utf-8 encoder
|
/**
|
* @constructor
|
* @implements {Encoder}
|
* @param {{fatal: boolean}} options
|
*/
|
function UTF8Encoder(options) {
|
var fatal = options.fatal;
|
/**
|
* @param {Stream} stream Input stream.
|
* @param {number} code_point Next code point read from the stream.
|
* @return {(number|!Array.<number>)} Byte(s) to emit.
|
*/
|
this.handler = function(stream, code_point) {
|
// 1. If code point is end-of-stream, return finished.
|
if (code_point === end_of_stream)
|
return finished;
|
|
// 2. If code point is an ASCII code point, return a byte whose
|
// value is code point.
|
if (isASCIICodePoint(code_point))
|
return code_point;
|
|
// 3. Set count and offset based on the range code point is in:
|
var count, offset;
|
// U+0080 to U+07FF, inclusive:
|
if (inRange(code_point, 0x0080, 0x07FF)) {
|
// 1 and 0xC0
|
count = 1;
|
offset = 0xC0;
|
}
|
// U+0800 to U+FFFF, inclusive:
|
else if (inRange(code_point, 0x0800, 0xFFFF)) {
|
// 2 and 0xE0
|
count = 2;
|
offset = 0xE0;
|
}
|
// U+10000 to U+10FFFF, inclusive:
|
else if (inRange(code_point, 0x10000, 0x10FFFF)) {
|
// 3 and 0xF0
|
count = 3;
|
offset = 0xF0;
|
}
|
|
// 4. Let bytes be a byte sequence whose first byte is (code
|
// point >> (6 × count)) + offset.
|
var bytes = [(code_point >> (6 * count)) + offset];
|
|
// 5. Run these substeps while count is greater than 0:
|
while (count > 0) {
|
|
// 1. Set temp to code point >> (6 × (count − 1)).
|
var temp = code_point >> (6 * (count - 1));
|
|
// 2. Append to bytes 0x80 | (temp & 0x3F).
|
bytes.push(0x80 | (temp & 0x3F));
|
|
// 3. Decrease count by one.
|
count -= 1;
|
}
|
|
// 6. Return bytes bytes, in order.
|
return bytes;
|
};
|
}
|
|
/** @param {{fatal: boolean}} options */
|
encoders['UTF-8'] = function(options) {
|
return new UTF8Encoder(options);
|
};
|
/** @param {{fatal: boolean}} options */
|
decoders['UTF-8'] = function(options) {
|
return new UTF8Decoder(options);
|
};
|
|
//
|
// 10. Legacy single-byte encodings
|
//
|
|
// 10.1 single-byte decoder
|
/**
|
* @constructor
|
* @implements {Decoder}
|
* @param {!Array.<number>} index The encoding index.
|
* @param {{fatal: boolean}} options
|
*/
|
function SingleByteDecoder(index, options) {
|
var fatal = options.fatal;
|
/**
|
* @param {Stream} stream The stream of bytes being decoded.
|
* @param {number} bite The next byte read from the stream.
|
* @return {?(number|!Array.<number>)} The next code point(s)
|
* decoded, or null if not enough data exists in the input
|
* stream to decode a complete code point.
|
*/
|
this.handler = function(stream, bite) {
|
// 1. If byte is end-of-stream, return finished.
|
if (bite === end_of_stream)
|
return finished;
|
|
// 2. If byte is an ASCII byte, return a code point whose value
|
// is byte.
|
if (isASCIIByte(bite))
|
return bite;
|
|
// 3. Let code point be the index code point for byte − 0x80 in
|
// index single-byte.
|
var code_point = index[bite - 0x80];
|
|
// 4. If code point is null, return error.
|
if (code_point === null)
|
return decoderError(fatal);
|
|
// 5. Return a code point whose value is code point.
|
return code_point;
|
};
|
}
|
|
// 10.2 single-byte encoder
|
/**
|
* @constructor
|
* @implements {Encoder}
|
* @param {!Array.<?number>} index The encoding index.
|
* @param {{fatal: boolean}} options
|
*/
|
function SingleByteEncoder(index, options) {
|
var fatal = options.fatal;
|
/**
|
* @param {Stream} stream Input stream.
|
* @param {number} code_point Next code point read from the stream.
|
* @return {(number|!Array.<number>)} Byte(s) to emit.
|
*/
|
this.handler = function(stream, code_point) {
|
// 1. If code point is end-of-stream, return finished.
|
if (code_point === end_of_stream)
|
return finished;
|
|
// 2. If code point is an ASCII code point, return a byte whose
|
// value is code point.
|
if (isASCIICodePoint(code_point))
|
return code_point;
|
|
// 3. Let pointer be the index pointer for code point in index
|
// single-byte.
|
var pointer = indexPointerFor(code_point, index);
|
|
// 4. If pointer is null, return error with code point.
|
if (pointer === null)
|
encoderError(code_point);
|
|
// 5. Return a byte whose value is pointer + 0x80.
|
return pointer + 0x80;
|
};
|
}
|
|
(function() {
|
if (!('encoding-indexes' in global))
|
return;
|
encodings.forEach(function(category) {
|
if (category.heading !== 'Legacy single-byte encodings')
|
return;
|
category.encodings.forEach(function(encoding) {
|
var name = encoding.name;
|
var idx = index(name.toLowerCase());
|
/** @param {{fatal: boolean}} options */
|
decoders[name] = function(options) {
|
return new SingleByteDecoder(idx, options);
|
};
|
/** @param {{fatal: boolean}} options */
|
encoders[name] = function(options) {
|
return new SingleByteEncoder(idx, options);
|
};
|
});
|
});
|
}());
|
|
//
|
// 11. Legacy multi-byte Chinese (simplified) encodings
|
//
|
|
// 11.1 gbk
|
|
// 11.1.1 gbk decoder
|
// gbk's decoder is gb18030's decoder.
|
/** @param {{fatal: boolean}} options */
|
decoders['GBK'] = function(options) {
|
return new GB18030Decoder(options);
|
};
|
|
// 11.1.2 gbk encoder
|
// gbk's encoder is gb18030's encoder with its gbk flag set.
|
/** @param {{fatal: boolean}} options */
|
encoders['GBK'] = function(options) {
|
return new GB18030Encoder(options, true);
|
};
|
|
// 11.2 gb18030
|
|
// 11.2.1 gb18030 decoder
|
/**
|
* @constructor
|
* @implements {Decoder}
|
* @param {{fatal: boolean}} options
|
*/
|
function GB18030Decoder(options) {
|
var fatal = options.fatal;
|
// gb18030's decoder has an associated gb18030 first, gb18030
|
// second, and gb18030 third (all initially 0x00).
|
var /** @type {number} */ gb18030_first = 0x00,
|
/** @type {number} */ gb18030_second = 0x00,
|
/** @type {number} */ gb18030_third = 0x00;
|
/**
|
* @param {Stream} stream The stream of bytes being decoded.
|
* @param {number} bite The next byte read from the stream.
|
* @return {?(number|!Array.<number>)} The next code point(s)
|
* decoded, or null if not enough data exists in the input
|
* stream to decode a complete code point.
|
*/
|
this.handler = function(stream, bite) {
|
// 1. If byte is end-of-stream and gb18030 first, gb18030
|
// second, and gb18030 third are 0x00, return finished.
|
if (bite === end_of_stream && gb18030_first === 0x00 &&
|
gb18030_second === 0x00 && gb18030_third === 0x00) {
|
return finished;
|
}
|
// 2. If byte is end-of-stream, and gb18030 first, gb18030
|
// second, or gb18030 third is not 0x00, set gb18030 first,
|
// gb18030 second, and gb18030 third to 0x00, and return error.
|
if (bite === end_of_stream &&
|
(gb18030_first !== 0x00 || gb18030_second !== 0x00 ||
|
gb18030_third !== 0x00)) {
|
gb18030_first = 0x00;
|
gb18030_second = 0x00;
|
gb18030_third = 0x00;
|
decoderError(fatal);
|
}
|
var code_point;
|
// 3. If gb18030 third is not 0x00, run these substeps:
|
if (gb18030_third !== 0x00) {
|
// 1. Let code point be null.
|
code_point = null;
|
// 2. If byte is in the range 0x30 to 0x39, inclusive, set
|
// code point to the index gb18030 ranges code point for
|
// (((gb18030 first − 0x81) × 10 + gb18030 second − 0x30) ×
|
// 126 + gb18030 third − 0x81) × 10 + byte − 0x30.
|
if (inRange(bite, 0x30, 0x39)) {
|
code_point = indexGB18030RangesCodePointFor(
|
(((gb18030_first - 0x81) * 10 + gb18030_second - 0x30) * 126 +
|
gb18030_third - 0x81) * 10 + bite - 0x30);
|
}
|
|
// 3. Let buffer be a byte sequence consisting of gb18030
|
// second, gb18030 third, and byte, in order.
|
var buffer = [gb18030_second, gb18030_third, bite];
|
|
// 4. Set gb18030 first, gb18030 second, and gb18030 third to
|
// 0x00.
|
gb18030_first = 0x00;
|
gb18030_second = 0x00;
|
gb18030_third = 0x00;
|
|
// 5. If code point is null, prepend buffer to stream and
|
// return error.
|
if (code_point === null) {
|
stream.prepend(buffer);
|
return decoderError(fatal);
|
}
|
|
// 6. Return a code point whose value is code point.
|
return code_point;
|
}
|
|
// 4. If gb18030 second is not 0x00, run these substeps:
|
if (gb18030_second !== 0x00) {
|
|
// 1. If byte is in the range 0x81 to 0xFE, inclusive, set
|
// gb18030 third to byte and return continue.
|
if (inRange(bite, 0x81, 0xFE)) {
|
gb18030_third = bite;
|
return null;
|
}
|
|
// 2. Prepend gb18030 second followed by byte to stream, set
|
// gb18030 first and gb18030 second to 0x00, and return error.
|
stream.prepend([gb18030_second, bite]);
|
gb18030_first = 0x00;
|
gb18030_second = 0x00;
|
return decoderError(fatal);
|
}
|
|
// 5. If gb18030 first is not 0x00, run these substeps:
|
if (gb18030_first !== 0x00) {
|
|
// 1. If byte is in the range 0x30 to 0x39, inclusive, set
|
// gb18030 second to byte and return continue.
|
if (inRange(bite, 0x30, 0x39)) {
|
gb18030_second = bite;
|
return null;
|
}
|
|
// 2. Let lead be gb18030 first, let pointer be null, and set
|
// gb18030 first to 0x00.
|
var lead = gb18030_first;
|
var pointer = null;
|
gb18030_first = 0x00;
|
|
// 3. Let offset be 0x40 if byte is less than 0x7F and 0x41
|
// otherwise.
|
var offset = bite < 0x7F ? 0x40 : 0x41;
|
|
// 4. If byte is in the range 0x40 to 0x7E, inclusive, or 0x80
|
// to 0xFE, inclusive, set pointer to (lead − 0x81) × 190 +
|
// (byte − offset).
|
if (inRange(bite, 0x40, 0x7E) || inRange(bite, 0x80, 0xFE))
|
pointer = (lead - 0x81) * 190 + (bite - offset);
|
|
// 5. Let code point be null if pointer is null and the index
|
// code point for pointer in index gb18030 otherwise.
|
code_point = pointer === null ? null :
|
indexCodePointFor(pointer, index('gb18030'));
|
|
// 6. If code point is null and byte is an ASCII byte, prepend
|
// byte to stream.
|
if (code_point === null && isASCIIByte(bite))
|
stream.prepend(bite);
|
|
// 7. If code point is null, return error.
|
if (code_point === null)
|
return decoderError(fatal);
|
|
// 8. Return a code point whose value is code point.
|
return code_point;
|
}
|
|
// 6. If byte is an ASCII byte, return a code point whose value
|
// is byte.
|
if (isASCIIByte(bite))
|
return bite;
|
|
// 7. If byte is 0x80, return code point U+20AC.
|
if (bite === 0x80)
|
return 0x20AC;
|
|
// 8. If byte is in the range 0x81 to 0xFE, inclusive, set
|
// gb18030 first to byte and return continue.
|
if (inRange(bite, 0x81, 0xFE)) {
|
gb18030_first = bite;
|
return null;
|
}
|
|
// 9. Return error.
|
return decoderError(fatal);
|
};
|
}
|
|
// 11.2.2 gb18030 encoder
|
/**
|
* @constructor
|
* @implements {Encoder}
|
* @param {{fatal: boolean}} options
|
* @param {boolean=} gbk_flag
|
*/
|
function GB18030Encoder(options, gbk_flag) {
|
var fatal = options.fatal;
|
// gb18030's decoder has an associated gbk flag (initially unset).
|
/**
|
* @param {Stream} stream Input stream.
|
* @param {number} code_point Next code point read from the stream.
|
* @return {(number|!Array.<number>)} Byte(s) to emit.
|
*/
|
this.handler = function(stream, code_point) {
|
// 1. If code point is end-of-stream, return finished.
|
if (code_point === end_of_stream)
|
return finished;
|
|
// 2. If code point is an ASCII code point, return a byte whose
|
// value is code point.
|
if (isASCIICodePoint(code_point))
|
return code_point;
|
|
// 3. If code point is U+E5E5, return error with code point.
|
if (code_point === 0xE5E5)
|
return encoderError(code_point);
|
|
// 4. If the gbk flag is set and code point is U+20AC, return
|
// byte 0x80.
|
if (gbk_flag && code_point === 0x20AC)
|
return 0x80;
|
|
// 5. Let pointer be the index pointer for code point in index
|
// gb18030.
|
var pointer = indexPointerFor(code_point, index('gb18030'));
|
|
// 6. If pointer is not null, run these substeps:
|
if (pointer !== null) {
|
|
// 1. Let lead be floor(pointer / 190) + 0x81.
|
var lead = floor(pointer / 190) + 0x81;
|
|
// 2. Let trail be pointer % 190.
|
var trail = pointer % 190;
|
|
// 3. Let offset be 0x40 if trail is less than 0x3F and 0x41 otherwise.
|
var offset = trail < 0x3F ? 0x40 : 0x41;
|
|
// 4. Return two bytes whose values are lead and trail + offset.
|
return [lead, trail + offset];
|
}
|
|
// 7. If gbk flag is set, return error with code point.
|
if (gbk_flag)
|
return encoderError(code_point);
|
|
// 8. Set pointer to the index gb18030 ranges pointer for code
|
// point.
|
pointer = indexGB18030RangesPointerFor(code_point);
|
|
// 9. Let byte1 be floor(pointer / 10 / 126 / 10).
|
var byte1 = floor(pointer / 10 / 126 / 10);
|
|
// 10. Set pointer to pointer − byte1 × 10 × 126 × 10.
|
pointer = pointer - byte1 * 10 * 126 * 10;
|
|
// 11. Let byte2 be floor(pointer / 10 / 126).
|
var byte2 = floor(pointer / 10 / 126);
|
|
// 12. Set pointer to pointer − byte2 × 10 × 126.
|
pointer = pointer - byte2 * 10 * 126;
|
|
// 13. Let byte3 be floor(pointer / 10).
|
var byte3 = floor(pointer / 10);
|
|
// 14. Let byte4 be pointer − byte3 × 10.
|
var byte4 = pointer - byte3 * 10;
|
|
// 15. Return four bytes whose values are byte1 + 0x81, byte2 +
|
// 0x30, byte3 + 0x81, byte4 + 0x30.
|
return [byte1 + 0x81,
|
byte2 + 0x30,
|
byte3 + 0x81,
|
byte4 + 0x30];
|
};
|
}
|
|
/** @param {{fatal: boolean}} options */
|
encoders['gb18030'] = function(options) {
|
return new GB18030Encoder(options);
|
};
|
/** @param {{fatal: boolean}} options */
|
decoders['gb18030'] = function(options) {
|
return new GB18030Decoder(options);
|
};
|
|
|
//
|
// 12. Legacy multi-byte Chinese (traditional) encodings
|
//
|
|
// 12.1 Big5
|
|
// 12.1.1 Big5 decoder
|
/**
|
* @constructor
|
* @implements {Decoder}
|
* @param {{fatal: boolean}} options
|
*/
|
function Big5Decoder(options) {
|
var fatal = options.fatal;
|
// Big5's decoder has an associated Big5 lead (initially 0x00).
|
var /** @type {number} */ Big5_lead = 0x00;
|
|
/**
|
* @param {Stream} stream The stream of bytes being decoded.
|
* @param {number} bite The next byte read from the stream.
|
* @return {?(number|!Array.<number>)} The next code point(s)
|
* decoded, or null if not enough data exists in the input
|
* stream to decode a complete code point.
|
*/
|
this.handler = function(stream, bite) {
|
// 1. If byte is end-of-stream and Big5 lead is not 0x00, set
|
// Big5 lead to 0x00 and return error.
|
if (bite === end_of_stream && Big5_lead !== 0x00) {
|
Big5_lead = 0x00;
|
return decoderError(fatal);
|
}
|
|
// 2. If byte is end-of-stream and Big5 lead is 0x00, return
|
// finished.
|
if (bite === end_of_stream && Big5_lead === 0x00)
|
return finished;
|
|
// 3. If Big5 lead is not 0x00, let lead be Big5 lead, let
|
// pointer be null, set Big5 lead to 0x00, and then run these
|
// substeps:
|
if (Big5_lead !== 0x00) {
|
var lead = Big5_lead;
|
var pointer = null;
|
Big5_lead = 0x00;
|
|
// 1. Let offset be 0x40 if byte is less than 0x7F and 0x62
|
// otherwise.
|
var offset = bite < 0x7F ? 0x40 : 0x62;
|
|
// 2. If byte is in the range 0x40 to 0x7E, inclusive, or 0xA1
|
// to 0xFE, inclusive, set pointer to (lead − 0x81) × 157 +
|
// (byte − offset).
|
if (inRange(bite, 0x40, 0x7E) || inRange(bite, 0xA1, 0xFE))
|
pointer = (lead - 0x81) * 157 + (bite - offset);
|
|
// 3. If there is a row in the table below whose first column
|
// is pointer, return the two code points listed in its second
|
// column
|
// Pointer | Code points
|
// --------+--------------
|
// 1133 | U+00CA U+0304
|
// 1135 | U+00CA U+030C
|
// 1164 | U+00EA U+0304
|
// 1166 | U+00EA U+030C
|
switch (pointer) {
|
case 1133: return [0x00CA, 0x0304];
|
case 1135: return [0x00CA, 0x030C];
|
case 1164: return [0x00EA, 0x0304];
|
case 1166: return [0x00EA, 0x030C];
|
}
|
|
// 4. Let code point be null if pointer is null and the index
|
// code point for pointer in index Big5 otherwise.
|
var code_point = (pointer === null) ? null :
|
indexCodePointFor(pointer, index('big5'));
|
|
// 5. If code point is null and byte is an ASCII byte, prepend
|
// byte to stream.
|
if (code_point === null && isASCIIByte(bite))
|
stream.prepend(bite);
|
|
// 6. If code point is null, return error.
|
if (code_point === null)
|
return decoderError(fatal);
|
|
// 7. Return a code point whose value is code point.
|
return code_point;
|
}
|
|
// 4. If byte is an ASCII byte, return a code point whose value
|
// is byte.
|
if (isASCIIByte(bite))
|
return bite;
|
|
// 5. If byte is in the range 0x81 to 0xFE, inclusive, set Big5
|
// lead to byte and return continue.
|
if (inRange(bite, 0x81, 0xFE)) {
|
Big5_lead = bite;
|
return null;
|
}
|
|
// 6. Return error.
|
return decoderError(fatal);
|
};
|
}
|
|
// 12.1.2 Big5 encoder
|
/**
|
* @constructor
|
* @implements {Encoder}
|
* @param {{fatal: boolean}} options
|
*/
|
function Big5Encoder(options) {
|
var fatal = options.fatal;
|
/**
|
* @param {Stream} stream Input stream.
|
* @param {number} code_point Next code point read from the stream.
|
* @return {(number|!Array.<number>)} Byte(s) to emit.
|
*/
|
this.handler = function(stream, code_point) {
|
// 1. If code point is end-of-stream, return finished.
|
if (code_point === end_of_stream)
|
return finished;
|
|
// 2. If code point is an ASCII code point, return a byte whose
|
// value is code point.
|
if (isASCIICodePoint(code_point))
|
return code_point;
|
|
// 3. Let pointer be the index Big5 pointer for code point.
|
var pointer = indexBig5PointerFor(code_point);
|
|
// 4. If pointer is null, return error with code point.
|
if (pointer === null)
|
return encoderError(code_point);
|
|
// 5. Let lead be floor(pointer / 157) + 0x81.
|
var lead = floor(pointer / 157) + 0x81;
|
|
// 6. If lead is less than 0xA1, return error with code point.
|
if (lead < 0xA1)
|
return encoderError(code_point);
|
|
// 7. Let trail be pointer % 157.
|
var trail = pointer % 157;
|
|
// 8. Let offset be 0x40 if trail is less than 0x3F and 0x62
|
// otherwise.
|
var offset = trail < 0x3F ? 0x40 : 0x62;
|
|
// Return two bytes whose values are lead and trail + offset.
|
return [lead, trail + offset];
|
};
|
}
|
|
/** @param {{fatal: boolean}} options */
|
encoders['Big5'] = function(options) {
|
return new Big5Encoder(options);
|
};
|
/** @param {{fatal: boolean}} options */
|
decoders['Big5'] = function(options) {
|
return new Big5Decoder(options);
|
};
|
|
|
//
|
// 13. Legacy multi-byte Japanese encodings
|
//
|
|
// 13.1 euc-jp
|
|
// 13.1.1 euc-jp decoder
|
/**
|
* @constructor
|
* @implements {Decoder}
|
* @param {{fatal: boolean}} options
|
*/
|
function EUCJPDecoder(options) {
|
var fatal = options.fatal;
|
|
// euc-jp's decoder has an associated euc-jp jis0212 flag
|
// (initially unset) and euc-jp lead (initially 0x00).
|
var /** @type {boolean} */ eucjp_jis0212_flag = false,
|
/** @type {number} */ eucjp_lead = 0x00;
|
|
/**
|
* @param {Stream} stream The stream of bytes being decoded.
|
* @param {number} bite The next byte read from the stream.
|
* @return {?(number|!Array.<number>)} The next code point(s)
|
* decoded, or null if not enough data exists in the input
|
* stream to decode a complete code point.
|
*/
|
this.handler = function(stream, bite) {
|
// 1. If byte is end-of-stream and euc-jp lead is not 0x00, set
|
// euc-jp lead to 0x00, and return error.
|
if (bite === end_of_stream && eucjp_lead !== 0x00) {
|
eucjp_lead = 0x00;
|
return decoderError(fatal);
|
}
|
|
// 2. If byte is end-of-stream and euc-jp lead is 0x00, return
|
// finished.
|
if (bite === end_of_stream && eucjp_lead === 0x00)
|
return finished;
|
|
// 3. If euc-jp lead is 0x8E and byte is in the range 0xA1 to
|
// 0xDF, inclusive, set euc-jp lead to 0x00 and return a code
|
// point whose value is 0xFF61 − 0xA1 + byte.
|
if (eucjp_lead === 0x8E && inRange(bite, 0xA1, 0xDF)) {
|
eucjp_lead = 0x00;
|
return 0xFF61 - 0xA1 + bite;
|
}
|
|
// 4. If euc-jp lead is 0x8F and byte is in the range 0xA1 to
|
// 0xFE, inclusive, set the euc-jp jis0212 flag, set euc-jp lead
|
// to byte, and return continue.
|
if (eucjp_lead === 0x8F && inRange(bite, 0xA1, 0xFE)) {
|
eucjp_jis0212_flag = true;
|
eucjp_lead = bite;
|
return null;
|
}
|
|
// 5. If euc-jp lead is not 0x00, let lead be euc-jp lead, set
|
// euc-jp lead to 0x00, and run these substeps:
|
if (eucjp_lead !== 0x00) {
|
var lead = eucjp_lead;
|
eucjp_lead = 0x00;
|
|
// 1. Let code point be null.
|
var code_point = null;
|
|
// 2. If lead and byte are both in the range 0xA1 to 0xFE,
|
// inclusive, set code point to the index code point for (lead
|
// − 0xA1) × 94 + byte − 0xA1 in index jis0208 if the euc-jp
|
// jis0212 flag is unset and in index jis0212 otherwise.
|
if (inRange(lead, 0xA1, 0xFE) && inRange(bite, 0xA1, 0xFE)) {
|
code_point = indexCodePointFor(
|
(lead - 0xA1) * 94 + (bite - 0xA1),
|
index(!eucjp_jis0212_flag ? 'jis0208' : 'jis0212'));
|
}
|
|
// 3. Unset the euc-jp jis0212 flag.
|
eucjp_jis0212_flag = false;
|
|
// 4. If byte is not in the range 0xA1 to 0xFE, inclusive,
|
// prepend byte to stream.
|
if (!inRange(bite, 0xA1, 0xFE))
|
stream.prepend(bite);
|
|
// 5. If code point is null, return error.
|
if (code_point === null)
|
return decoderError(fatal);
|
|
// 6. Return a code point whose value is code point.
|
return code_point;
|
}
|
|
// 6. If byte is an ASCII byte, return a code point whose value
|
// is byte.
|
if (isASCIIByte(bite))
|
return bite;
|
|
// 7. If byte is 0x8E, 0x8F, or in the range 0xA1 to 0xFE,
|
// inclusive, set euc-jp lead to byte and return continue.
|
if (bite === 0x8E || bite === 0x8F || inRange(bite, 0xA1, 0xFE)) {
|
eucjp_lead = bite;
|
return null;
|
}
|
|
// 8. Return error.
|
return decoderError(fatal);
|
};
|
}
|
|
// 13.1.2 euc-jp encoder
|
/**
|
* @constructor
|
* @implements {Encoder}
|
* @param {{fatal: boolean}} options
|
*/
|
function EUCJPEncoder(options) {
|
var fatal = options.fatal;
|
/**
|
* @param {Stream} stream Input stream.
|
* @param {number} code_point Next code point read from the stream.
|
* @return {(number|!Array.<number>)} Byte(s) to emit.
|
*/
|
this.handler = function(stream, code_point) {
|
// 1. If code point is end-of-stream, return finished.
|
if (code_point === end_of_stream)
|
return finished;
|
|
// 2. If code point is an ASCII code point, return a byte whose
|
// value is code point.
|
if (isASCIICodePoint(code_point))
|
return code_point;
|
|
// 3. If code point is U+00A5, return byte 0x5C.
|
if (code_point === 0x00A5)
|
return 0x5C;
|
|
// 4. If code point is U+203E, return byte 0x7E.
|
if (code_point === 0x203E)
|
return 0x7E;
|
|
// 5. If code point is in the range U+FF61 to U+FF9F, inclusive,
|
// return two bytes whose values are 0x8E and code point −
|
// 0xFF61 + 0xA1.
|
if (inRange(code_point, 0xFF61, 0xFF9F))
|
return [0x8E, code_point - 0xFF61 + 0xA1];
|
|
// 6. If code point is U+2212, set it to U+FF0D.
|
if (code_point === 0x2212)
|
code_point = 0xFF0D;
|
|
// 7. Let pointer be the index pointer for code point in index
|
// jis0208.
|
var pointer = indexPointerFor(code_point, index('jis0208'));
|
|
// 8. If pointer is null, return error with code point.
|
if (pointer === null)
|
return encoderError(code_point);
|
|
// 9. Let lead be floor(pointer / 94) + 0xA1.
|
var lead = floor(pointer / 94) + 0xA1;
|
|
// 10. Let trail be pointer % 94 + 0xA1.
|
var trail = pointer % 94 + 0xA1;
|
|
// 11. Return two bytes whose values are lead and trail.
|
return [lead, trail];
|
};
|
}
|
|
/** @param {{fatal: boolean}} options */
|
encoders['EUC-JP'] = function(options) {
|
return new EUCJPEncoder(options);
|
};
|
/** @param {{fatal: boolean}} options */
|
decoders['EUC-JP'] = function(options) {
|
return new EUCJPDecoder(options);
|
};
|
|
// 13.2 iso-2022-jp
|
|
// 13.2.1 iso-2022-jp decoder
|
/**
|
* @constructor
|
* @implements {Decoder}
|
* @param {{fatal: boolean}} options
|
*/
|
function ISO2022JPDecoder(options) {
|
var fatal = options.fatal;
|
/** @enum */
|
var states = {
|
ASCII: 0,
|
Roman: 1,
|
Katakana: 2,
|
LeadByte: 3,
|
TrailByte: 4,
|
EscapeStart: 5,
|
Escape: 6
|
};
|
// iso-2022-jp's decoder has an associated iso-2022-jp decoder
|
// state (initially ASCII), iso-2022-jp decoder output state
|
// (initially ASCII), iso-2022-jp lead (initially 0x00), and
|
// iso-2022-jp output flag (initially unset).
|
var /** @type {number} */ iso2022jp_decoder_state = states.ASCII,
|
/** @type {number} */ iso2022jp_decoder_output_state = states.ASCII,
|
/** @type {number} */ iso2022jp_lead = 0x00,
|
/** @type {boolean} */ iso2022jp_output_flag = false;
|
/**
|
* @param {Stream} stream The stream of bytes being decoded.
|
* @param {number} bite The next byte read from the stream.
|
* @return {?(number|!Array.<number>)} The next code point(s)
|
* decoded, or null if not enough data exists in the input
|
* stream to decode a complete code point.
|
*/
|
this.handler = function(stream, bite) {
|
// switching on iso-2022-jp decoder state:
|
switch (iso2022jp_decoder_state) {
|
default:
|
case states.ASCII:
|
// ASCII
|
// Based on byte:
|
|
// 0x1B
|
if (bite === 0x1B) {
|
// Set iso-2022-jp decoder state to escape start and return
|
// continue.
|
iso2022jp_decoder_state = states.EscapeStart;
|
return null;
|
}
|
|
// 0x00 to 0x7F, excluding 0x0E, 0x0F, and 0x1B
|
if (inRange(bite, 0x00, 0x7F) && bite !== 0x0E
|
&& bite !== 0x0F && bite !== 0x1B) {
|
// Unset the iso-2022-jp output flag and return a code point
|
// whose value is byte.
|
iso2022jp_output_flag = false;
|
return bite;
|
}
|
|
// end-of-stream
|
if (bite === end_of_stream) {
|
// Return finished.
|
return finished;
|
}
|
|
// Otherwise
|
// Unset the iso-2022-jp output flag and return error.
|
iso2022jp_output_flag = false;
|
return decoderError(fatal);
|
|
case states.Roman:
|
// Roman
|
// Based on byte:
|
|
// 0x1B
|
if (bite === 0x1B) {
|
// Set iso-2022-jp decoder state to escape start and return
|
// continue.
|
iso2022jp_decoder_state = states.EscapeStart;
|
return null;
|
}
|
|
// 0x5C
|
if (bite === 0x5C) {
|
// Unset the iso-2022-jp output flag and return code point
|
// U+00A5.
|
iso2022jp_output_flag = false;
|
return 0x00A5;
|
}
|
|
// 0x7E
|
if (bite === 0x7E) {
|
// Unset the iso-2022-jp output flag and return code point
|
// U+203E.
|
iso2022jp_output_flag = false;
|
return 0x203E;
|
}
|
|
// 0x00 to 0x7F, excluding 0x0E, 0x0F, 0x1B, 0x5C, and 0x7E
|
if (inRange(bite, 0x00, 0x7F) && bite !== 0x0E && bite !== 0x0F
|
&& bite !== 0x1B && bite !== 0x5C && bite !== 0x7E) {
|
// Unset the iso-2022-jp output flag and return a code point
|
// whose value is byte.
|
iso2022jp_output_flag = false;
|
return bite;
|
}
|
|
// end-of-stream
|
if (bite === end_of_stream) {
|
// Return finished.
|
return finished;
|
}
|
|
// Otherwise
|
// Unset the iso-2022-jp output flag and return error.
|
iso2022jp_output_flag = false;
|
return decoderError(fatal);
|
|
case states.Katakana:
|
// Katakana
|
// Based on byte:
|
|
// 0x1B
|
if (bite === 0x1B) {
|
// Set iso-2022-jp decoder state to escape start and return
|
// continue.
|
iso2022jp_decoder_state = states.EscapeStart;
|
return null;
|
}
|
|
// 0x21 to 0x5F
|
if (inRange(bite, 0x21, 0x5F)) {
|
// Unset the iso-2022-jp output flag and return a code point
|
// whose value is 0xFF61 − 0x21 + byte.
|
iso2022jp_output_flag = false;
|
return 0xFF61 - 0x21 + bite;
|
}
|
|
// end-of-stream
|
if (bite === end_of_stream) {
|
// Return finished.
|
return finished;
|
}
|
|
// Otherwise
|
// Unset the iso-2022-jp output flag and return error.
|
iso2022jp_output_flag = false;
|
return decoderError(fatal);
|
|
case states.LeadByte:
|
// Lead byte
|
// Based on byte:
|
|
// 0x1B
|
if (bite === 0x1B) {
|
// Set iso-2022-jp decoder state to escape start and return
|
// continue.
|
iso2022jp_decoder_state = states.EscapeStart;
|
return null;
|
}
|
|
// 0x21 to 0x7E
|
if (inRange(bite, 0x21, 0x7E)) {
|
// Unset the iso-2022-jp output flag, set iso-2022-jp lead
|
// to byte, iso-2022-jp decoder state to trail byte, and
|
// return continue.
|
iso2022jp_output_flag = false;
|
iso2022jp_lead = bite;
|
iso2022jp_decoder_state = states.TrailByte;
|
return null;
|
}
|
|
// end-of-stream
|
if (bite === end_of_stream) {
|
// Return finished.
|
return finished;
|
}
|
|
// Otherwise
|
// Unset the iso-2022-jp output flag and return error.
|
iso2022jp_output_flag = false;
|
return decoderError(fatal);
|
|
case states.TrailByte:
|
// Trail byte
|
// Based on byte:
|
|
// 0x1B
|
if (bite === 0x1B) {
|
// Set iso-2022-jp decoder state to escape start and return
|
// continue.
|
iso2022jp_decoder_state = states.EscapeStart;
|
return decoderError(fatal);
|
}
|
|
// 0x21 to 0x7E
|
if (inRange(bite, 0x21, 0x7E)) {
|
// 1. Set the iso-2022-jp decoder state to lead byte.
|
iso2022jp_decoder_state = states.LeadByte;
|
|
// 2. Let pointer be (iso-2022-jp lead − 0x21) × 94 + byte − 0x21.
|
var pointer = (iso2022jp_lead - 0x21) * 94 + bite - 0x21;
|
|
// 3. Let code point be the index code point for pointer in
|
// index jis0208.
|
var code_point = indexCodePointFor(pointer, index('jis0208'));
|
|
// 4. If code point is null, return error.
|
if (code_point === null)
|
return decoderError(fatal);
|
|
// 5. Return a code point whose value is code point.
|
return code_point;
|
}
|
|
// end-of-stream
|
if (bite === end_of_stream) {
|
// Set the iso-2022-jp decoder state to lead byte, prepend
|
// byte to stream, and return error.
|
iso2022jp_decoder_state = states.LeadByte;
|
stream.prepend(bite);
|
return decoderError(fatal);
|
}
|
|
// Otherwise
|
// Set iso-2022-jp decoder state to lead byte and return
|
// error.
|
iso2022jp_decoder_state = states.LeadByte;
|
return decoderError(fatal);
|
|
case states.EscapeStart:
|
// Escape start
|
|
// 1. If byte is either 0x24 or 0x28, set iso-2022-jp lead to
|
// byte, iso-2022-jp decoder state to escape, and return
|
// continue.
|
if (bite === 0x24 || bite === 0x28) {
|
iso2022jp_lead = bite;
|
iso2022jp_decoder_state = states.Escape;
|
return null;
|
}
|
|
// 2. Prepend byte to stream.
|
stream.prepend(bite);
|
|
// 3. Unset the iso-2022-jp output flag, set iso-2022-jp
|
// decoder state to iso-2022-jp decoder output state, and
|
// return error.
|
iso2022jp_output_flag = false;
|
iso2022jp_decoder_state = iso2022jp_decoder_output_state;
|
return decoderError(fatal);
|
|
case states.Escape:
|
// Escape
|
|
// 1. Let lead be iso-2022-jp lead and set iso-2022-jp lead to
|
// 0x00.
|
var lead = iso2022jp_lead;
|
iso2022jp_lead = 0x00;
|
|
// 2. Let state be null.
|
var state = null;
|
|
// 3. If lead is 0x28 and byte is 0x42, set state to ASCII.
|
if (lead === 0x28 && bite === 0x42)
|
state = states.ASCII;
|
|
// 4. If lead is 0x28 and byte is 0x4A, set state to Roman.
|
if (lead === 0x28 && bite === 0x4A)
|
state = states.Roman;
|
|
// 5. If lead is 0x28 and byte is 0x49, set state to Katakana.
|
if (lead === 0x28 && bite === 0x49)
|
state = states.Katakana;
|
|
// 6. If lead is 0x24 and byte is either 0x40 or 0x42, set
|
// state to lead byte.
|
if (lead === 0x24 && (bite === 0x40 || bite === 0x42))
|
state = states.LeadByte;
|
|
// 7. If state is non-null, run these substeps:
|
if (state !== null) {
|
// 1. Set iso-2022-jp decoder state and iso-2022-jp decoder
|
// output state to states.
|
iso2022jp_decoder_state = iso2022jp_decoder_state = state;
|
|
// 2. Let output flag be the iso-2022-jp output flag.
|
var output_flag = iso2022jp_output_flag;
|
|
// 3. Set the iso-2022-jp output flag.
|
iso2022jp_output_flag = true;
|
|
// 4. Return continue, if output flag is unset, and error
|
// otherwise.
|
return !output_flag ? null : decoderError(fatal);
|
}
|
|
// 8. Prepend lead and byte to stream.
|
stream.prepend([lead, bite]);
|
|
// 9. Unset the iso-2022-jp output flag, set iso-2022-jp
|
// decoder state to iso-2022-jp decoder output state and
|
// return error.
|
iso2022jp_output_flag = false;
|
iso2022jp_decoder_state = iso2022jp_decoder_output_state;
|
return decoderError(fatal);
|
}
|
};
|
}
|
|
// 13.2.2 iso-2022-jp encoder
|
/**
|
* @constructor
|
* @implements {Encoder}
|
* @param {{fatal: boolean}} options
|
*/
|
function ISO2022JPEncoder(options) {
|
var fatal = options.fatal;
|
// iso-2022-jp's encoder has an associated iso-2022-jp encoder
|
// state which is one of ASCII, Roman, and jis0208 (initially
|
// ASCII).
|
/** @enum */
|
var states = {
|
ASCII: 0,
|
Roman: 1,
|
jis0208: 2
|
};
|
var /** @type {number} */ iso2022jp_state = states.ASCII;
|
/**
|
* @param {Stream} stream Input stream.
|
* @param {number} code_point Next code point read from the stream.
|
* @return {(number|!Array.<number>)} Byte(s) to emit.
|
*/
|
this.handler = function(stream, code_point) {
|
// 1. If code point is end-of-stream and iso-2022-jp encoder
|
// state is not ASCII, prepend code point to stream, set
|
// iso-2022-jp encoder state to ASCII, and return three bytes
|
// 0x1B 0x28 0x42.
|
if (code_point === end_of_stream &&
|
iso2022jp_state !== states.ASCII) {
|
stream.prepend(code_point);
|
iso2022jp_state = states.ASCII;
|
return [0x1B, 0x28, 0x42];
|
}
|
|
// 2. If code point is end-of-stream and iso-2022-jp encoder
|
// state is ASCII, return finished.
|
if (code_point === end_of_stream && iso2022jp_state === states.ASCII)
|
return finished;
|
|
// 3. If ISO-2022-JP encoder state is ASCII or Roman, and code
|
// point is U+000E, U+000F, or U+001B, return error with U+FFFD.
|
if ((iso2022jp_state === states.ASCII ||
|
iso2022jp_state === states.Roman) &&
|
(code_point === 0x000E || code_point === 0x000F ||
|
code_point === 0x001B)) {
|
return encoderError(0xFFFD);
|
}
|
|
// 4. If iso-2022-jp encoder state is ASCII and code point is an
|
// ASCII code point, return a byte whose value is code point.
|
if (iso2022jp_state === states.ASCII &&
|
isASCIICodePoint(code_point))
|
return code_point;
|
|
// 5. If iso-2022-jp encoder state is Roman and code point is an
|
// ASCII code point, excluding U+005C and U+007E, or is U+00A5
|
// or U+203E, run these substeps:
|
if (iso2022jp_state === states.Roman &&
|
((isASCIICodePoint(code_point) &&
|
code_point !== 0x005C && code_point !== 0x007E) ||
|
(code_point == 0x00A5 || code_point == 0x203E))) {
|
|
// 1. If code point is an ASCII code point, return a byte
|
// whose value is code point.
|
if (isASCIICodePoint(code_point))
|
return code_point;
|
|
// 2. If code point is U+00A5, return byte 0x5C.
|
if (code_point === 0x00A5)
|
return 0x5C;
|
|
// 3. If code point is U+203E, return byte 0x7E.
|
if (code_point === 0x203E)
|
return 0x7E;
|
}
|
|
// 6. If code point is an ASCII code point, and iso-2022-jp
|
// encoder state is not ASCII, prepend code point to stream, set
|
// iso-2022-jp encoder state to ASCII, and return three bytes
|
// 0x1B 0x28 0x42.
|
if (isASCIICodePoint(code_point) &&
|
iso2022jp_state !== states.ASCII) {
|
stream.prepend(code_point);
|
iso2022jp_state = states.ASCII;
|
return [0x1B, 0x28, 0x42];
|
}
|
|
// 7. If code point is either U+00A5 or U+203E, and iso-2022-jp
|
// encoder state is not Roman, prepend code point to stream, set
|
// iso-2022-jp encoder state to Roman, and return three bytes
|
// 0x1B 0x28 0x4A.
|
if ((code_point === 0x00A5 || code_point === 0x203E) &&
|
iso2022jp_state !== states.Roman) {
|
stream.prepend(code_point);
|
iso2022jp_state = states.Roman;
|
return [0x1B, 0x28, 0x4A];
|
}
|
|
// 8. If code point is U+2212, set it to U+FF0D.
|
if (code_point === 0x2212)
|
code_point = 0xFF0D;
|
|
// 9. Let pointer be the index pointer for code point in index
|
// jis0208.
|
var pointer = indexPointerFor(code_point, index('jis0208'));
|
|
// 10. If pointer is null, return error with code point.
|
if (pointer === null)
|
return encoderError(code_point);
|
|
// 11. If iso-2022-jp encoder state is not jis0208, prepend code
|
// point to stream, set iso-2022-jp encoder state to jis0208,
|
// and return three bytes 0x1B 0x24 0x42.
|
if (iso2022jp_state !== states.jis0208) {
|
stream.prepend(code_point);
|
iso2022jp_state = states.jis0208;
|
return [0x1B, 0x24, 0x42];
|
}
|
|
// 12. Let lead be floor(pointer / 94) + 0x21.
|
var lead = floor(pointer / 94) + 0x21;
|
|
// 13. Let trail be pointer % 94 + 0x21.
|
var trail = pointer % 94 + 0x21;
|
|
// 14. Return two bytes whose values are lead and trail.
|
return [lead, trail];
|
};
|
}
|
|
/** @param {{fatal: boolean}} options */
|
encoders['ISO-2022-JP'] = function(options) {
|
return new ISO2022JPEncoder(options);
|
};
|
/** @param {{fatal: boolean}} options */
|
decoders['ISO-2022-JP'] = function(options) {
|
return new ISO2022JPDecoder(options);
|
};
|
|
// 13.3 Shift_JIS
|
|
// 13.3.1 Shift_JIS decoder
|
/**
|
* @constructor
|
* @implements {Decoder}
|
* @param {{fatal: boolean}} options
|
*/
|
function ShiftJISDecoder(options) {
|
var fatal = options.fatal;
|
// Shift_JIS's decoder has an associated Shift_JIS lead (initially
|
// 0x00).
|
var /** @type {number} */ Shift_JIS_lead = 0x00;
|
/**
|
* @param {Stream} stream The stream of bytes being decoded.
|
* @param {number} bite The next byte read from the stream.
|
* @return {?(number|!Array.<number>)} The next code point(s)
|
* decoded, or null if not enough data exists in the input
|
* stream to decode a complete code point.
|
*/
|
this.handler = function(stream, bite) {
|
// 1. If byte is end-of-stream and Shift_JIS lead is not 0x00,
|
// set Shift_JIS lead to 0x00 and return error.
|
if (bite === end_of_stream && Shift_JIS_lead !== 0x00) {
|
Shift_JIS_lead = 0x00;
|
return decoderError(fatal);
|
}
|
|
// 2. If byte is end-of-stream and Shift_JIS lead is 0x00,
|
// return finished.
|
if (bite === end_of_stream && Shift_JIS_lead === 0x00)
|
return finished;
|
|
// 3. If Shift_JIS lead is not 0x00, let lead be Shift_JIS lead,
|
// let pointer be null, set Shift_JIS lead to 0x00, and then run
|
// these substeps:
|
if (Shift_JIS_lead !== 0x00) {
|
var lead = Shift_JIS_lead;
|
var pointer = null;
|
Shift_JIS_lead = 0x00;
|
|
// 1. Let offset be 0x40, if byte is less than 0x7F, and 0x41
|
// otherwise.
|
var offset = (bite < 0x7F) ? 0x40 : 0x41;
|
|
// 2. Let lead offset be 0x81, if lead is less than 0xA0, and
|
// 0xC1 otherwise.
|
var lead_offset = (lead < 0xA0) ? 0x81 : 0xC1;
|
|
// 3. If byte is in the range 0x40 to 0x7E, inclusive, or 0x80
|
// to 0xFC, inclusive, set pointer to (lead − lead offset) ×
|
// 188 + byte − offset.
|
if (inRange(bite, 0x40, 0x7E) || inRange(bite, 0x80, 0xFC))
|
pointer = (lead - lead_offset) * 188 + bite - offset;
|
|
// 4. If pointer is in the range 8836 to 10715, inclusive,
|
// return a code point whose value is 0xE000 − 8836 + pointer.
|
if (inRange(pointer, 8836, 10715))
|
return 0xE000 - 8836 + pointer;
|
|
// 5. Let code point be null, if pointer is null, and the
|
// index code point for pointer in index jis0208 otherwise.
|
var code_point = (pointer === null) ? null :
|
indexCodePointFor(pointer, index('jis0208'));
|
|
// 6. If code point is null and byte is an ASCII byte, prepend
|
// byte to stream.
|
if (code_point === null && isASCIIByte(bite))
|
stream.prepend(bite);
|
|
// 7. If code point is null, return error.
|
if (code_point === null)
|
return decoderError(fatal);
|
|
// 8. Return a code point whose value is code point.
|
return code_point;
|
}
|
|
// 4. If byte is an ASCII byte or 0x80, return a code point
|
// whose value is byte.
|
if (isASCIIByte(bite) || bite === 0x80)
|
return bite;
|
|
// 5. If byte is in the range 0xA1 to 0xDF, inclusive, return a
|
// code point whose value is 0xFF61 − 0xA1 + byte.
|
if (inRange(bite, 0xA1, 0xDF))
|
return 0xFF61 - 0xA1 + bite;
|
|
// 6. If byte is in the range 0x81 to 0x9F, inclusive, or 0xE0
|
// to 0xFC, inclusive, set Shift_JIS lead to byte and return
|
// continue.
|
if (inRange(bite, 0x81, 0x9F) || inRange(bite, 0xE0, 0xFC)) {
|
Shift_JIS_lead = bite;
|
return null;
|
}
|
|
// 7. Return error.
|
return decoderError(fatal);
|
};
|
}
|
|
// 13.3.2 Shift_JIS encoder
|
/**
|
* @constructor
|
* @implements {Encoder}
|
* @param {{fatal: boolean}} options
|
*/
|
function ShiftJISEncoder(options) {
|
var fatal = options.fatal;
|
/**
|
* @param {Stream} stream Input stream.
|
* @param {number} code_point Next code point read from the stream.
|
* @return {(number|!Array.<number>)} Byte(s) to emit.
|
*/
|
this.handler = function(stream, code_point) {
|
// 1. If code point is end-of-stream, return finished.
|
if (code_point === end_of_stream)
|
return finished;
|
|
// 2. If code point is an ASCII code point or U+0080, return a
|
// byte whose value is code point.
|
if (isASCIICodePoint(code_point) || code_point === 0x0080)
|
return code_point;
|
|
// 3. If code point is U+00A5, return byte 0x5C.
|
if (code_point === 0x00A5)
|
return 0x5C;
|
|
// 4. If code point is U+203E, return byte 0x7E.
|
if (code_point === 0x203E)
|
return 0x7E;
|
|
// 5. If code point is in the range U+FF61 to U+FF9F, inclusive,
|
// return a byte whose value is code point − 0xFF61 + 0xA1.
|
if (inRange(code_point, 0xFF61, 0xFF9F))
|
return code_point - 0xFF61 + 0xA1;
|
|
// 6. If code point is U+2212, set it to U+FF0D.
|
if (code_point === 0x2212)
|
code_point = 0xFF0D;
|
|
// 7. Let pointer be the index Shift_JIS pointer for code point.
|
var pointer = indexShiftJISPointerFor(code_point);
|
|
// 8. If pointer is null, return error with code point.
|
if (pointer === null)
|
return encoderError(code_point);
|
|
// 9. Let lead be floor(pointer / 188).
|
var lead = floor(pointer / 188);
|
|
// 10. Let lead offset be 0x81, if lead is less than 0x1F, and
|
// 0xC1 otherwise.
|
var lead_offset = (lead < 0x1F) ? 0x81 : 0xC1;
|
|
// 11. Let trail be pointer % 188.
|
var trail = pointer % 188;
|
|
// 12. Let offset be 0x40, if trail is less than 0x3F, and 0x41
|
// otherwise.
|
var offset = (trail < 0x3F) ? 0x40 : 0x41;
|
|
// 13. Return two bytes whose values are lead + lead offset and
|
// trail + offset.
|
return [lead + lead_offset, trail + offset];
|
};
|
}
|
|
/** @param {{fatal: boolean}} options */
|
encoders['Shift_JIS'] = function(options) {
|
return new ShiftJISEncoder(options);
|
};
|
/** @param {{fatal: boolean}} options */
|
decoders['Shift_JIS'] = function(options) {
|
return new ShiftJISDecoder(options);
|
};
|
|
//
|
// 14. Legacy multi-byte Korean encodings
|
//
|
|
// 14.1 euc-kr
|
|
// 14.1.1 euc-kr decoder
|
/**
|
* @constructor
|
* @implements {Decoder}
|
* @param {{fatal: boolean}} options
|
*/
|
function EUCKRDecoder(options) {
|
var fatal = options.fatal;
|
|
// euc-kr's decoder has an associated euc-kr lead (initially 0x00).
|
var /** @type {number} */ euckr_lead = 0x00;
|
/**
|
* @param {Stream} stream The stream of bytes being decoded.
|
* @param {number} bite The next byte read from the stream.
|
* @return {?(number|!Array.<number>)} The next code point(s)
|
* decoded, or null if not enough data exists in the input
|
* stream to decode a complete code point.
|
*/
|
this.handler = function(stream, bite) {
|
// 1. If byte is end-of-stream and euc-kr lead is not 0x00, set
|
// euc-kr lead to 0x00 and return error.
|
if (bite === end_of_stream && euckr_lead !== 0) {
|
euckr_lead = 0x00;
|
return decoderError(fatal);
|
}
|
|
// 2. If byte is end-of-stream and euc-kr lead is 0x00, return
|
// finished.
|
if (bite === end_of_stream && euckr_lead === 0)
|
return finished;
|
|
// 3. If euc-kr lead is not 0x00, let lead be euc-kr lead, let
|
// pointer be null, set euc-kr lead to 0x00, and then run these
|
// substeps:
|
if (euckr_lead !== 0x00) {
|
var lead = euckr_lead;
|
var pointer = null;
|
euckr_lead = 0x00;
|
|
// 1. If byte is in the range 0x41 to 0xFE, inclusive, set
|
// pointer to (lead − 0x81) × 190 + (byte − 0x41).
|
if (inRange(bite, 0x41, 0xFE))
|
pointer = (lead - 0x81) * 190 + (bite - 0x41);
|
|
// 2. Let code point be null, if pointer is null, and the
|
// index code point for pointer in index euc-kr otherwise.
|
var code_point = (pointer === null)
|
? null : indexCodePointFor(pointer, index('euc-kr'));
|
|
// 3. If code point is null and byte is an ASCII byte, prepend
|
// byte to stream.
|
if (pointer === null && isASCIIByte(bite))
|
stream.prepend(bite);
|
|
// 4. If code point is null, return error.
|
if (code_point === null)
|
return decoderError(fatal);
|
|
// 5. Return a code point whose value is code point.
|
return code_point;
|
}
|
|
// 4. If byte is an ASCII byte, return a code point whose value
|
// is byte.
|
if (isASCIIByte(bite))
|
return bite;
|
|
// 5. If byte is in the range 0x81 to 0xFE, inclusive, set
|
// euc-kr lead to byte and return continue.
|
if (inRange(bite, 0x81, 0xFE)) {
|
euckr_lead = bite;
|
return null;
|
}
|
|
// 6. Return error.
|
return decoderError(fatal);
|
};
|
}
|
|
// 14.1.2 euc-kr encoder
|
/**
|
* @constructor
|
* @implements {Encoder}
|
* @param {{fatal: boolean}} options
|
*/
|
function EUCKREncoder(options) {
|
var fatal = options.fatal;
|
/**
|
* @param {Stream} stream Input stream.
|
* @param {number} code_point Next code point read from the stream.
|
* @return {(number|!Array.<number>)} Byte(s) to emit.
|
*/
|
this.handler = function(stream, code_point) {
|
// 1. If code point is end-of-stream, return finished.
|
if (code_point === end_of_stream)
|
return finished;
|
|
// 2. If code point is an ASCII code point, return a byte whose
|
// value is code point.
|
if (isASCIICodePoint(code_point))
|
return code_point;
|
|
// 3. Let pointer be the index pointer for code point in index
|
// euc-kr.
|
var pointer = indexPointerFor(code_point, index('euc-kr'));
|
|
// 4. If pointer is null, return error with code point.
|
if (pointer === null)
|
return encoderError(code_point);
|
|
// 5. Let lead be floor(pointer / 190) + 0x81.
|
var lead = floor(pointer / 190) + 0x81;
|
|
// 6. Let trail be pointer % 190 + 0x41.
|
var trail = (pointer % 190) + 0x41;
|
|
// 7. Return two bytes whose values are lead and trail.
|
return [lead, trail];
|
};
|
}
|
|
/** @param {{fatal: boolean}} options */
|
encoders['EUC-KR'] = function(options) {
|
return new EUCKREncoder(options);
|
};
|
/** @param {{fatal: boolean}} options */
|
decoders['EUC-KR'] = function(options) {
|
return new EUCKRDecoder(options);
|
};
|
|
|
//
|
// 15. Legacy miscellaneous encodings
|
//
|
|
// 15.1 replacement
|
|
// Not needed - API throws RangeError
|
|
// 15.2 Common infrastructure for utf-16be and utf-16le
|
|
/**
|
* @param {number} code_unit
|
* @param {boolean} utf16be
|
* @return {!Array.<number>} bytes
|
*/
|
function convertCodeUnitToBytes(code_unit, utf16be) {
|
// 1. Let byte1 be code unit >> 8.
|
var byte1 = code_unit >> 8;
|
|
// 2. Let byte2 be code unit & 0x00FF.
|
var byte2 = code_unit & 0x00FF;
|
|
// 3. Then return the bytes in order:
|
// utf-16be flag is set: byte1, then byte2.
|
if (utf16be)
|
return [byte1, byte2];
|
// utf-16be flag is unset: byte2, then byte1.
|
return [byte2, byte1];
|
}
|
|
// 15.2.1 shared utf-16 decoder
|
/**
|
* @constructor
|
* @implements {Decoder}
|
* @param {boolean} utf16_be True if big-endian, false if little-endian.
|
* @param {{fatal: boolean}} options
|
*/
|
function UTF16Decoder(utf16_be, options) {
|
var fatal = options.fatal;
|
var /** @type {?number} */ utf16_lead_byte = null,
|
/** @type {?number} */ utf16_lead_surrogate = null;
|
/**
|
* @param {Stream} stream The stream of bytes being decoded.
|
* @param {number} bite The next byte read from the stream.
|
* @return {?(number|!Array.<number>)} The next code point(s)
|
* decoded, or null if not enough data exists in the input
|
* stream to decode a complete code point.
|
*/
|
this.handler = function(stream, bite) {
|
// 1. If byte is end-of-stream and either utf-16 lead byte or
|
// utf-16 lead surrogate is not null, set utf-16 lead byte and
|
// utf-16 lead surrogate to null, and return error.
|
if (bite === end_of_stream && (utf16_lead_byte !== null ||
|
utf16_lead_surrogate !== null)) {
|
return decoderError(fatal);
|
}
|
|
// 2. If byte is end-of-stream and utf-16 lead byte and utf-16
|
// lead surrogate are null, return finished.
|
if (bite === end_of_stream && utf16_lead_byte === null &&
|
utf16_lead_surrogate === null) {
|
return finished;
|
}
|
|
// 3. If utf-16 lead byte is null, set utf-16 lead byte to byte
|
// and return continue.
|
if (utf16_lead_byte === null) {
|
utf16_lead_byte = bite;
|
return null;
|
}
|
|
// 4. Let code unit be the result of:
|
var code_unit;
|
if (utf16_be) {
|
// utf-16be decoder flag is set
|
// (utf-16 lead byte << 8) + byte.
|
code_unit = (utf16_lead_byte << 8) + bite;
|
} else {
|
// utf-16be decoder flag is unset
|
// (byte << 8) + utf-16 lead byte.
|
code_unit = (bite << 8) + utf16_lead_byte;
|
}
|
// Then set utf-16 lead byte to null.
|
utf16_lead_byte = null;
|
|
// 5. If utf-16 lead surrogate is not null, let lead surrogate
|
// be utf-16 lead surrogate, set utf-16 lead surrogate to null,
|
// and then run these substeps:
|
if (utf16_lead_surrogate !== null) {
|
var lead_surrogate = utf16_lead_surrogate;
|
utf16_lead_surrogate = null;
|
|
// 1. If code unit is in the range U+DC00 to U+DFFF,
|
// inclusive, return a code point whose value is 0x10000 +
|
// ((lead surrogate − 0xD800) << 10) + (code unit − 0xDC00).
|
if (inRange(code_unit, 0xDC00, 0xDFFF)) {
|
return 0x10000 + (lead_surrogate - 0xD800) * 0x400 +
|
(code_unit - 0xDC00);
|
}
|
|
// 2. Prepend the sequence resulting of converting code unit
|
// to bytes using utf-16be decoder flag to stream and return
|
// error.
|
stream.prepend(convertCodeUnitToBytes(code_unit, utf16_be));
|
return decoderError(fatal);
|
}
|
|
// 6. If code unit is in the range U+D800 to U+DBFF, inclusive,
|
// set utf-16 lead surrogate to code unit and return continue.
|
if (inRange(code_unit, 0xD800, 0xDBFF)) {
|
utf16_lead_surrogate = code_unit;
|
return null;
|
}
|
|
// 7. If code unit is in the range U+DC00 to U+DFFF, inclusive,
|
// return error.
|
if (inRange(code_unit, 0xDC00, 0xDFFF))
|
return decoderError(fatal);
|
|
// 8. Return code point code unit.
|
return code_unit;
|
};
|
}
|
|
// 15.2.2 shared utf-16 encoder
|
/**
|
* @constructor
|
* @implements {Encoder}
|
* @param {boolean} utf16_be True if big-endian, false if little-endian.
|
* @param {{fatal: boolean}} options
|
*/
|
function UTF16Encoder(utf16_be, options) {
|
var fatal = options.fatal;
|
/**
|
* @param {Stream} stream Input stream.
|
* @param {number} code_point Next code point read from the stream.
|
* @return {(number|!Array.<number>)} Byte(s) to emit.
|
*/
|
this.handler = function(stream, code_point) {
|
// 1. If code point is end-of-stream, return finished.
|
if (code_point === end_of_stream)
|
return finished;
|
|
// 2. If code point is in the range U+0000 to U+FFFF, inclusive,
|
// return the sequence resulting of converting code point to
|
// bytes using utf-16be encoder flag.
|
if (inRange(code_point, 0x0000, 0xFFFF))
|
return convertCodeUnitToBytes(code_point, utf16_be);
|
|
// 3. Let lead be ((code point − 0x10000) >> 10) + 0xD800,
|
// converted to bytes using utf-16be encoder flag.
|
var lead = convertCodeUnitToBytes(
|
((code_point - 0x10000) >> 10) + 0xD800, utf16_be);
|
|
// 4. Let trail be ((code point − 0x10000) & 0x3FF) + 0xDC00,
|
// converted to bytes using utf-16be encoder flag.
|
var trail = convertCodeUnitToBytes(
|
((code_point - 0x10000) & 0x3FF) + 0xDC00, utf16_be);
|
|
// 5. Return a byte sequence of lead followed by trail.
|
return lead.concat(trail);
|
};
|
}
|
|
// 15.3 utf-16be
|
// 15.3.1 utf-16be decoder
|
/** @param {{fatal: boolean}} options */
|
encoders['UTF-16BE'] = function(options) {
|
return new UTF16Encoder(true, options);
|
};
|
// 15.3.2 utf-16be encoder
|
/** @param {{fatal: boolean}} options */
|
decoders['UTF-16BE'] = function(options) {
|
return new UTF16Decoder(true, options);
|
};
|
|
// 15.4 utf-16le
|
// 15.4.1 utf-16le decoder
|
/** @param {{fatal: boolean}} options */
|
encoders['UTF-16LE'] = function(options) {
|
return new UTF16Encoder(false, options);
|
};
|
// 15.4.2 utf-16le encoder
|
/** @param {{fatal: boolean}} options */
|
decoders['UTF-16LE'] = function(options) {
|
return new UTF16Decoder(false, options);
|
};
|
|
// 15.5 x-user-defined
|
|
// 15.5.1 x-user-defined decoder
|
/**
|
* @constructor
|
* @implements {Decoder}
|
* @param {{fatal: boolean}} options
|
*/
|
function XUserDefinedDecoder(options) {
|
var fatal = options.fatal;
|
/**
|
* @param {Stream} stream The stream of bytes being decoded.
|
* @param {number} bite The next byte read from the stream.
|
* @return {?(number|!Array.<number>)} The next code point(s)
|
* decoded, or null if not enough data exists in the input
|
* stream to decode a complete code point.
|
*/
|
this.handler = function(stream, bite) {
|
// 1. If byte is end-of-stream, return finished.
|
if (bite === end_of_stream)
|
return finished;
|
|
// 2. If byte is an ASCII byte, return a code point whose value
|
// is byte.
|
if (isASCIIByte(bite))
|
return bite;
|
|
// 3. Return a code point whose value is 0xF780 + byte − 0x80.
|
return 0xF780 + bite - 0x80;
|
};
|
}
|
|
// 15.5.2 x-user-defined encoder
|
/**
|
* @constructor
|
* @implements {Encoder}
|
* @param {{fatal: boolean}} options
|
*/
|
function XUserDefinedEncoder(options) {
|
var fatal = options.fatal;
|
/**
|
* @param {Stream} stream Input stream.
|
* @param {number} code_point Next code point read from the stream.
|
* @return {(number|!Array.<number>)} Byte(s) to emit.
|
*/
|
this.handler = function(stream, code_point) {
|
// 1.If code point is end-of-stream, return finished.
|
if (code_point === end_of_stream)
|
return finished;
|
|
// 2. If code point is an ASCII code point, return a byte whose
|
// value is code point.
|
if (isASCIICodePoint(code_point))
|
return code_point;
|
|
// 3. If code point is in the range U+F780 to U+F7FF, inclusive,
|
// return a byte whose value is code point − 0xF780 + 0x80.
|
if (inRange(code_point, 0xF780, 0xF7FF))
|
return code_point - 0xF780 + 0x80;
|
|
// 4. Return error with code point.
|
return encoderError(code_point);
|
};
|
}
|
|
/** @param {{fatal: boolean}} options */
|
encoders['x-user-defined'] = function(options) {
|
return new XUserDefinedEncoder(options);
|
};
|
/** @param {{fatal: boolean}} options */
|
decoders['x-user-defined'] = function(options) {
|
return new XUserDefinedDecoder(options);
|
};
|
|
if (!global['TextEncoder'])
|
global['TextEncoder'] = TextEncoder;
|
if (!global['TextDecoder'])
|
global['TextDecoder'] = TextDecoder;
|
|
if ( true && module.exports) {
|
module.exports = {
|
TextEncoder: global['TextEncoder'],
|
TextDecoder: global['TextDecoder'],
|
EncodingIndexes: global["encoding-indexes"]
|
};
|
}
|
|
// For strict environments where `this` inside the global scope
|
// is `undefined`, take a pure object instead
|
}(this || {}));
|
|
|
/***/ }),
|
/* 41 */
|
/***/ (function(module, exports) {
|
|
/* (ignored) */
|
|
/***/ }),
|
/* 42 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
/* eslint-disable node/no-deprecated-api */
|
var buffer = __webpack_require__(2)
|
var Buffer = buffer.Buffer
|
|
// alternative to using Object.keys for old browsers
|
function copyProps (src, dst) {
|
for (var key in src) {
|
dst[key] = src[key]
|
}
|
}
|
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
|
module.exports = buffer
|
} else {
|
// Copy properties from require('buffer')
|
copyProps(buffer, exports)
|
exports.Buffer = SafeBuffer
|
}
|
|
function SafeBuffer (arg, encodingOrOffset, length) {
|
return Buffer(arg, encodingOrOffset, length)
|
}
|
|
SafeBuffer.prototype = Object.create(Buffer.prototype)
|
|
// Copy static methods from Buffer
|
copyProps(Buffer, SafeBuffer)
|
|
SafeBuffer.from = function (arg, encodingOrOffset, length) {
|
if (typeof arg === 'number') {
|
throw new TypeError('Argument must not be a number')
|
}
|
return Buffer(arg, encodingOrOffset, length)
|
}
|
|
SafeBuffer.alloc = function (size, fill, encoding) {
|
if (typeof size !== 'number') {
|
throw new TypeError('Argument must be a number')
|
}
|
var buf = Buffer(size)
|
if (fill !== undefined) {
|
if (typeof encoding === 'string') {
|
buf.fill(fill, encoding)
|
} else {
|
buf.fill(fill)
|
}
|
} else {
|
buf.fill(0)
|
}
|
return buf
|
}
|
|
SafeBuffer.allocUnsafe = function (size) {
|
if (typeof size !== 'number') {
|
throw new TypeError('Argument must be a number')
|
}
|
return Buffer(size)
|
}
|
|
SafeBuffer.allocUnsafeSlow = function (size) {
|
if (typeof size !== 'number') {
|
throw new TypeError('Argument must be a number')
|
}
|
return buffer.SlowBuffer(size)
|
}
|
|
|
/***/ }),
|
/* 43 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
"use strict";
|
|
|
exports.byteLength = byteLength
|
exports.toByteArray = toByteArray
|
exports.fromByteArray = fromByteArray
|
|
var lookup = []
|
var revLookup = []
|
var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
|
|
var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
for (var i = 0, len = code.length; i < len; ++i) {
|
lookup[i] = code[i]
|
revLookup[code.charCodeAt(i)] = i
|
}
|
|
// Support decoding URL-safe base64 strings, as Node.js does.
|
// See: https://en.wikipedia.org/wiki/Base64#URL_applications
|
revLookup['-'.charCodeAt(0)] = 62
|
revLookup['_'.charCodeAt(0)] = 63
|
|
function getLens (b64) {
|
var len = b64.length
|
|
if (len % 4 > 0) {
|
throw new Error('Invalid string. Length must be a multiple of 4')
|
}
|
|
// Trim off extra bytes after placeholder bytes are found
|
// See: https://github.com/beatgammit/base64-js/issues/42
|
var validLen = b64.indexOf('=')
|
if (validLen === -1) validLen = len
|
|
var placeHoldersLen = validLen === len
|
? 0
|
: 4 - (validLen % 4)
|
|
return [validLen, placeHoldersLen]
|
}
|
|
// base64 is 4/3 + up to two characters of the original data
|
function byteLength (b64) {
|
var lens = getLens(b64)
|
var validLen = lens[0]
|
var placeHoldersLen = lens[1]
|
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
}
|
|
function _byteLength (b64, validLen, placeHoldersLen) {
|
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
}
|
|
function toByteArray (b64) {
|
var tmp
|
var lens = getLens(b64)
|
var validLen = lens[0]
|
var placeHoldersLen = lens[1]
|
|
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
|
|
var curByte = 0
|
|
// if there are placeholders, only get up to the last complete 4 chars
|
var len = placeHoldersLen > 0
|
? validLen - 4
|
: validLen
|
|
var i
|
for (i = 0; i < len; i += 4) {
|
tmp =
|
(revLookup[b64.charCodeAt(i)] << 18) |
|
(revLookup[b64.charCodeAt(i + 1)] << 12) |
|
(revLookup[b64.charCodeAt(i + 2)] << 6) |
|
revLookup[b64.charCodeAt(i + 3)]
|
arr[curByte++] = (tmp >> 16) & 0xFF
|
arr[curByte++] = (tmp >> 8) & 0xFF
|
arr[curByte++] = tmp & 0xFF
|
}
|
|
if (placeHoldersLen === 2) {
|
tmp =
|
(revLookup[b64.charCodeAt(i)] << 2) |
|
(revLookup[b64.charCodeAt(i + 1)] >> 4)
|
arr[curByte++] = tmp & 0xFF
|
}
|
|
if (placeHoldersLen === 1) {
|
tmp =
|
(revLookup[b64.charCodeAt(i)] << 10) |
|
(revLookup[b64.charCodeAt(i + 1)] << 4) |
|
(revLookup[b64.charCodeAt(i + 2)] >> 2)
|
arr[curByte++] = (tmp >> 8) & 0xFF
|
arr[curByte++] = tmp & 0xFF
|
}
|
|
return arr
|
}
|
|
function tripletToBase64 (num) {
|
return lookup[num >> 18 & 0x3F] +
|
lookup[num >> 12 & 0x3F] +
|
lookup[num >> 6 & 0x3F] +
|
lookup[num & 0x3F]
|
}
|
|
function encodeChunk (uint8, start, end) {
|
var tmp
|
var output = []
|
for (var i = start; i < end; i += 3) {
|
tmp =
|
((uint8[i] << 16) & 0xFF0000) +
|
((uint8[i + 1] << 8) & 0xFF00) +
|
(uint8[i + 2] & 0xFF)
|
output.push(tripletToBase64(tmp))
|
}
|
return output.join('')
|
}
|
|
function fromByteArray (uint8) {
|
var tmp
|
var len = uint8.length
|
var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
|
var parts = []
|
var maxChunkLength = 16383 // must be multiple of 3
|
|
// go through the array every three bytes, we'll deal with trailing stuff later
|
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
|
parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
|
}
|
|
// pad the end with zeros, but make sure to not forget the extra bytes
|
if (extraBytes === 1) {
|
tmp = uint8[len - 1]
|
parts.push(
|
lookup[tmp >> 2] +
|
lookup[(tmp << 4) & 0x3F] +
|
'=='
|
)
|
} else if (extraBytes === 2) {
|
tmp = (uint8[len - 2] << 8) + uint8[len - 1]
|
parts.push(
|
lookup[tmp >> 10] +
|
lookup[(tmp >> 4) & 0x3F] +
|
lookup[(tmp << 2) & 0x3F] +
|
'='
|
)
|
}
|
|
return parts.join('')
|
}
|
|
|
/***/ }),
|
/* 44 */
|
/***/ (function(module, exports) {
|
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
exports.read = function (buffer, offset, isLE, mLen, nBytes) {
|
var e, m
|
var eLen = (nBytes * 8) - mLen - 1
|
var eMax = (1 << eLen) - 1
|
var eBias = eMax >> 1
|
var nBits = -7
|
var i = isLE ? (nBytes - 1) : 0
|
var d = isLE ? -1 : 1
|
var s = buffer[offset + i]
|
|
i += d
|
|
e = s & ((1 << (-nBits)) - 1)
|
s >>= (-nBits)
|
nBits += eLen
|
for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
|
|
m = e & ((1 << (-nBits)) - 1)
|
e >>= (-nBits)
|
nBits += mLen
|
for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
|
|
if (e === 0) {
|
e = 1 - eBias
|
} else if (e === eMax) {
|
return m ? NaN : ((s ? -1 : 1) * Infinity)
|
} else {
|
m = m + Math.pow(2, mLen)
|
e = e - eBias
|
}
|
return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
|
}
|
|
exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
var e, m, c
|
var eLen = (nBytes * 8) - mLen - 1
|
var eMax = (1 << eLen) - 1
|
var eBias = eMax >> 1
|
var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
|
var i = isLE ? 0 : (nBytes - 1)
|
var d = isLE ? 1 : -1
|
var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
|
|
value = Math.abs(value)
|
|
if (isNaN(value) || value === Infinity) {
|
m = isNaN(value) ? 1 : 0
|
e = eMax
|
} else {
|
e = Math.floor(Math.log(value) / Math.LN2)
|
if (value * (c = Math.pow(2, -e)) < 1) {
|
e--
|
c *= 2
|
}
|
if (e + eBias >= 1) {
|
value += rt / c
|
} else {
|
value += rt * Math.pow(2, 1 - eBias)
|
}
|
if (value * c >= 2) {
|
e++
|
c /= 2
|
}
|
|
if (e + eBias >= eMax) {
|
m = 0
|
e = eMax
|
} else if (e + eBias >= 1) {
|
m = ((value * c) - 1) * Math.pow(2, mLen)
|
e = e + eBias
|
} else {
|
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
|
e = 0
|
}
|
}
|
|
for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
|
|
e = (e << mLen) | m
|
eLen += mLen
|
for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
|
|
buffer[offset + i - d] |= s * 128
|
}
|
|
|
/***/ }),
|
/* 45 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
"use strict";
|
/* WEBPACK VAR INJECTION */(function(global) {
|
var Mutation = global.MutationObserver || global.WebKitMutationObserver;
|
|
var scheduleDrain;
|
|
{
|
if (Mutation) {
|
var called = 0;
|
var observer = new Mutation(nextTick);
|
var element = global.document.createTextNode('');
|
observer.observe(element, {
|
characterData: true
|
});
|
scheduleDrain = function () {
|
element.data = (called = ++called % 2);
|
};
|
} else if (!global.setImmediate && typeof global.MessageChannel !== 'undefined') {
|
var channel = new global.MessageChannel();
|
channel.port1.onmessage = nextTick;
|
scheduleDrain = function () {
|
channel.port2.postMessage(0);
|
};
|
} else if ('document' in global && 'onreadystatechange' in global.document.createElement('script')) {
|
scheduleDrain = function () {
|
|
// Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
|
// into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
|
var scriptEl = global.document.createElement('script');
|
scriptEl.onreadystatechange = function () {
|
nextTick();
|
|
scriptEl.onreadystatechange = null;
|
scriptEl.parentNode.removeChild(scriptEl);
|
scriptEl = null;
|
};
|
global.document.documentElement.appendChild(scriptEl);
|
};
|
} else {
|
scheduleDrain = function () {
|
setTimeout(nextTick, 0);
|
};
|
}
|
}
|
|
var draining;
|
var queue = [];
|
//named nextTick for less confusing stack traces
|
function nextTick() {
|
draining = true;
|
var i, oldQueue;
|
var len = queue.length;
|
while (len) {
|
oldQueue = queue;
|
queue = [];
|
i = -1;
|
while (++i < len) {
|
oldQueue[i]();
|
}
|
len = queue.length;
|
}
|
draining = false;
|
}
|
|
module.exports = immediate;
|
function immediate(task) {
|
if (queue.push(task) === 1 && !draining) {
|
scheduleDrain();
|
}
|
}
|
|
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(1)))
|
|
/***/ }),
|
/* 46 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
/* WEBPACK VAR INJECTION */(function(process) {const perf =
|
typeof performance === 'object' &&
|
performance &&
|
typeof performance.now === 'function'
|
? performance
|
: Date
|
|
const hasAbortController = typeof AbortController === 'function'
|
|
// minimal backwards-compatibility polyfill
|
// this doesn't have nearly all the checks and whatnot that
|
// actual AbortController/Signal has, but it's enough for
|
// our purposes, and if used properly, behaves the same.
|
const AC = hasAbortController
|
? AbortController
|
: class AbortController {
|
constructor() {
|
this.signal = new AS()
|
}
|
abort() {
|
this.signal.dispatchEvent('abort')
|
}
|
}
|
|
const hasAbortSignal = typeof AbortSignal === 'function'
|
// Some polyfills put this on the AC class, not global
|
const hasACAbortSignal = typeof AC.AbortSignal === 'function'
|
const AS = hasAbortSignal
|
? AbortSignal
|
: hasACAbortSignal
|
? AC.AbortController
|
: class AbortSignal {
|
constructor() {
|
this.aborted = false
|
this._listeners = []
|
}
|
dispatchEvent(type) {
|
if (type === 'abort') {
|
this.aborted = true
|
const e = { type, target: this }
|
this.onabort(e)
|
this._listeners.forEach(f => f(e), this)
|
}
|
}
|
onabort() {}
|
addEventListener(ev, fn) {
|
if (ev === 'abort') {
|
this._listeners.push(fn)
|
}
|
}
|
removeEventListener(ev, fn) {
|
if (ev === 'abort') {
|
this._listeners = this._listeners.filter(f => f !== fn)
|
}
|
}
|
}
|
|
const warned = new Set()
|
const deprecatedOption = (opt, instead) => {
|
const code = `LRU_CACHE_OPTION_${opt}`
|
if (shouldWarn(code)) {
|
warn(code, `${opt} option`, `options.${instead}`, LRUCache)
|
}
|
}
|
const deprecatedMethod = (method, instead) => {
|
const code = `LRU_CACHE_METHOD_${method}`
|
if (shouldWarn(code)) {
|
const { prototype } = LRUCache
|
const { get } = Object.getOwnPropertyDescriptor(prototype, method)
|
warn(code, `${method} method`, `cache.${instead}()`, get)
|
}
|
}
|
const deprecatedProperty = (field, instead) => {
|
const code = `LRU_CACHE_PROPERTY_${field}`
|
if (shouldWarn(code)) {
|
const { prototype } = LRUCache
|
const { get } = Object.getOwnPropertyDescriptor(prototype, field)
|
warn(code, `${field} property`, `cache.${instead}`, get)
|
}
|
}
|
|
const emitWarning = (...a) => {
|
typeof process === 'object' &&
|
process &&
|
typeof process.emitWarning === 'function'
|
? process.emitWarning(...a)
|
: console.error(...a)
|
}
|
|
const shouldWarn = code => !warned.has(code)
|
|
const warn = (code, what, instead, fn) => {
|
warned.add(code)
|
const msg = `The ${what} is deprecated. Please use ${instead} instead.`
|
emitWarning(msg, 'DeprecationWarning', code, fn)
|
}
|
|
const isPosInt = n => n && n === Math.floor(n) && n > 0 && isFinite(n)
|
|
/* istanbul ignore next - This is a little bit ridiculous, tbh.
|
* The maximum array length is 2^32-1 or thereabouts on most JS impls.
|
* And well before that point, you're caching the entire world, I mean,
|
* that's ~32GB of just integers for the next/prev links, plus whatever
|
* else to hold that many keys and values. Just filling the memory with
|
* zeroes at init time is brutal when you get that big.
|
* But why not be complete?
|
* Maybe in the future, these limits will have expanded. */
|
const getUintArray = max =>
|
!isPosInt(max)
|
? null
|
: max <= Math.pow(2, 8)
|
? Uint8Array
|
: max <= Math.pow(2, 16)
|
? Uint16Array
|
: max <= Math.pow(2, 32)
|
? Uint32Array
|
: max <= Number.MAX_SAFE_INTEGER
|
? ZeroArray
|
: null
|
|
class ZeroArray extends Array {
|
constructor(size) {
|
super(size)
|
this.fill(0)
|
}
|
}
|
|
class Stack {
|
constructor(max) {
|
if (max === 0) {
|
return []
|
}
|
const UintArray = getUintArray(max)
|
this.heap = new UintArray(max)
|
this.length = 0
|
}
|
push(n) {
|
this.heap[this.length++] = n
|
}
|
pop() {
|
return this.heap[--this.length]
|
}
|
}
|
|
class LRUCache {
|
constructor(options = {}) {
|
const {
|
max = 0,
|
ttl,
|
ttlResolution = 1,
|
ttlAutopurge,
|
updateAgeOnGet,
|
updateAgeOnHas,
|
allowStale,
|
dispose,
|
disposeAfter,
|
noDisposeOnSet,
|
noUpdateTTL,
|
maxSize = 0,
|
maxEntrySize = 0,
|
sizeCalculation,
|
fetchMethod,
|
fetchContext,
|
noDeleteOnFetchRejection,
|
noDeleteOnStaleGet,
|
} = options
|
|
// deprecated options, don't trigger a warning for getting them if
|
// the thing being passed in is another LRUCache we're copying.
|
const { length, maxAge, stale } =
|
options instanceof LRUCache ? {} : options
|
|
if (max !== 0 && !isPosInt(max)) {
|
throw new TypeError('max option must be a nonnegative integer')
|
}
|
|
const UintArray = max ? getUintArray(max) : Array
|
if (!UintArray) {
|
throw new Error('invalid max value: ' + max)
|
}
|
|
this.max = max
|
this.maxSize = maxSize
|
this.maxEntrySize = maxEntrySize || this.maxSize
|
this.sizeCalculation = sizeCalculation || length
|
if (this.sizeCalculation) {
|
if (!this.maxSize && !this.maxEntrySize) {
|
throw new TypeError(
|
'cannot set sizeCalculation without setting maxSize or maxEntrySize'
|
)
|
}
|
if (typeof this.sizeCalculation !== 'function') {
|
throw new TypeError('sizeCalculation set to non-function')
|
}
|
}
|
|
this.fetchMethod = fetchMethod || null
|
if (this.fetchMethod && typeof this.fetchMethod !== 'function') {
|
throw new TypeError(
|
'fetchMethod must be a function if specified'
|
)
|
}
|
|
this.fetchContext = fetchContext
|
if (!this.fetchMethod && fetchContext !== undefined) {
|
throw new TypeError(
|
'cannot set fetchContext without fetchMethod'
|
)
|
}
|
|
this.keyMap = new Map()
|
this.keyList = new Array(max).fill(null)
|
this.valList = new Array(max).fill(null)
|
this.next = new UintArray(max)
|
this.prev = new UintArray(max)
|
this.head = 0
|
this.tail = 0
|
this.free = new Stack(max)
|
this.initialFill = 1
|
this.size = 0
|
|
if (typeof dispose === 'function') {
|
this.dispose = dispose
|
}
|
if (typeof disposeAfter === 'function') {
|
this.disposeAfter = disposeAfter
|
this.disposed = []
|
} else {
|
this.disposeAfter = null
|
this.disposed = null
|
}
|
this.noDisposeOnSet = !!noDisposeOnSet
|
this.noUpdateTTL = !!noUpdateTTL
|
this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection
|
|
// NB: maxEntrySize is set to maxSize if it's set
|
if (this.maxEntrySize !== 0) {
|
if (this.maxSize !== 0) {
|
if (!isPosInt(this.maxSize)) {
|
throw new TypeError(
|
'maxSize must be a positive integer if specified'
|
)
|
}
|
}
|
if (!isPosInt(this.maxEntrySize)) {
|
throw new TypeError(
|
'maxEntrySize must be a positive integer if specified'
|
)
|
}
|
this.initializeSizeTracking()
|
}
|
|
this.allowStale = !!allowStale || !!stale
|
this.noDeleteOnStaleGet = !!noDeleteOnStaleGet
|
this.updateAgeOnGet = !!updateAgeOnGet
|
this.updateAgeOnHas = !!updateAgeOnHas
|
this.ttlResolution =
|
isPosInt(ttlResolution) || ttlResolution === 0
|
? ttlResolution
|
: 1
|
this.ttlAutopurge = !!ttlAutopurge
|
this.ttl = ttl || maxAge || 0
|
if (this.ttl) {
|
if (!isPosInt(this.ttl)) {
|
throw new TypeError(
|
'ttl must be a positive integer if specified'
|
)
|
}
|
this.initializeTTLTracking()
|
}
|
|
// do not allow completely unbounded caches
|
if (this.max === 0 && this.ttl === 0 && this.maxSize === 0) {
|
throw new TypeError(
|
'At least one of max, maxSize, or ttl is required'
|
)
|
}
|
if (!this.ttlAutopurge && !this.max && !this.maxSize) {
|
const code = 'LRU_CACHE_UNBOUNDED'
|
if (shouldWarn(code)) {
|
warned.add(code)
|
const msg =
|
'TTL caching without ttlAutopurge, max, or maxSize can ' +
|
'result in unbounded memory consumption.'
|
emitWarning(msg, 'UnboundedCacheWarning', code, LRUCache)
|
}
|
}
|
|
if (stale) {
|
deprecatedOption('stale', 'allowStale')
|
}
|
if (maxAge) {
|
deprecatedOption('maxAge', 'ttl')
|
}
|
if (length) {
|
deprecatedOption('length', 'sizeCalculation')
|
}
|
}
|
|
getRemainingTTL(key) {
|
return this.has(key, { updateAgeOnHas: false }) ? Infinity : 0
|
}
|
|
initializeTTLTracking() {
|
this.ttls = new ZeroArray(this.max)
|
this.starts = new ZeroArray(this.max)
|
|
this.setItemTTL = (index, ttl, start = perf.now()) => {
|
this.starts[index] = ttl !== 0 ? start : 0
|
this.ttls[index] = ttl
|
if (ttl !== 0 && this.ttlAutopurge) {
|
const t = setTimeout(() => {
|
if (this.isStale(index)) {
|
this.delete(this.keyList[index])
|
}
|
}, ttl + 1)
|
/* istanbul ignore else - unref() not supported on all platforms */
|
if (t.unref) {
|
t.unref()
|
}
|
}
|
}
|
|
this.updateItemAge = index => {
|
this.starts[index] = this.ttls[index] !== 0 ? perf.now() : 0
|
}
|
|
// debounce calls to perf.now() to 1s so we're not hitting
|
// that costly call repeatedly.
|
let cachedNow = 0
|
const getNow = () => {
|
const n = perf.now()
|
if (this.ttlResolution > 0) {
|
cachedNow = n
|
const t = setTimeout(
|
() => (cachedNow = 0),
|
this.ttlResolution
|
)
|
/* istanbul ignore else - not available on all platforms */
|
if (t.unref) {
|
t.unref()
|
}
|
}
|
return n
|
}
|
|
this.getRemainingTTL = key => {
|
const index = this.keyMap.get(key)
|
if (index === undefined) {
|
return 0
|
}
|
return this.ttls[index] === 0 || this.starts[index] === 0
|
? Infinity
|
: this.starts[index] +
|
this.ttls[index] -
|
(cachedNow || getNow())
|
}
|
|
this.isStale = index => {
|
return (
|
this.ttls[index] !== 0 &&
|
this.starts[index] !== 0 &&
|
(cachedNow || getNow()) - this.starts[index] >
|
this.ttls[index]
|
)
|
}
|
}
|
updateItemAge(index) {}
|
setItemTTL(index, ttl, start) {}
|
isStale(index) {
|
return false
|
}
|
|
initializeSizeTracking() {
|
this.calculatedSize = 0
|
this.sizes = new ZeroArray(this.max)
|
this.removeItemSize = index => {
|
this.calculatedSize -= this.sizes[index]
|
this.sizes[index] = 0
|
}
|
this.requireSize = (k, v, size, sizeCalculation) => {
|
// provisionally accept background fetches.
|
// actual value size will be checked when they return.
|
if (this.isBackgroundFetch(v)) {
|
return 0
|
}
|
if (!isPosInt(size)) {
|
if (sizeCalculation) {
|
if (typeof sizeCalculation !== 'function') {
|
throw new TypeError('sizeCalculation must be a function')
|
}
|
size = sizeCalculation(v, k)
|
if (!isPosInt(size)) {
|
throw new TypeError(
|
'sizeCalculation return invalid (expect positive integer)'
|
)
|
}
|
} else {
|
throw new TypeError(
|
'invalid size value (must be positive integer)'
|
)
|
}
|
}
|
return size
|
}
|
this.addItemSize = (index, size) => {
|
this.sizes[index] = size
|
if (this.maxSize) {
|
const maxSize = this.maxSize - this.sizes[index]
|
while (this.calculatedSize > maxSize) {
|
this.evict(true)
|
}
|
}
|
this.calculatedSize += this.sizes[index]
|
}
|
}
|
removeItemSize(index) {}
|
addItemSize(index, size) {}
|
requireSize(k, v, size, sizeCalculation) {
|
if (size || sizeCalculation) {
|
throw new TypeError(
|
'cannot set size without setting maxSize or maxEntrySize on cache'
|
)
|
}
|
}
|
|
*indexes({ allowStale = this.allowStale } = {}) {
|
if (this.size) {
|
for (let i = this.tail; true; ) {
|
if (!this.isValidIndex(i)) {
|
break
|
}
|
if (allowStale || !this.isStale(i)) {
|
yield i
|
}
|
if (i === this.head) {
|
break
|
} else {
|
i = this.prev[i]
|
}
|
}
|
}
|
}
|
|
*rindexes({ allowStale = this.allowStale } = {}) {
|
if (this.size) {
|
for (let i = this.head; true; ) {
|
if (!this.isValidIndex(i)) {
|
break
|
}
|
if (allowStale || !this.isStale(i)) {
|
yield i
|
}
|
if (i === this.tail) {
|
break
|
} else {
|
i = this.next[i]
|
}
|
}
|
}
|
}
|
|
isValidIndex(index) {
|
return this.keyMap.get(this.keyList[index]) === index
|
}
|
|
*entries() {
|
for (const i of this.indexes()) {
|
yield [this.keyList[i], this.valList[i]]
|
}
|
}
|
*rentries() {
|
for (const i of this.rindexes()) {
|
yield [this.keyList[i], this.valList[i]]
|
}
|
}
|
|
*keys() {
|
for (const i of this.indexes()) {
|
yield this.keyList[i]
|
}
|
}
|
*rkeys() {
|
for (const i of this.rindexes()) {
|
yield this.keyList[i]
|
}
|
}
|
|
*values() {
|
for (const i of this.indexes()) {
|
yield this.valList[i]
|
}
|
}
|
*rvalues() {
|
for (const i of this.rindexes()) {
|
yield this.valList[i]
|
}
|
}
|
|
[Symbol.iterator]() {
|
return this.entries()
|
}
|
|
find(fn, getOptions = {}) {
|
for (const i of this.indexes()) {
|
if (fn(this.valList[i], this.keyList[i], this)) {
|
return this.get(this.keyList[i], getOptions)
|
}
|
}
|
}
|
|
forEach(fn, thisp = this) {
|
for (const i of this.indexes()) {
|
fn.call(thisp, this.valList[i], this.keyList[i], this)
|
}
|
}
|
|
rforEach(fn, thisp = this) {
|
for (const i of this.rindexes()) {
|
fn.call(thisp, this.valList[i], this.keyList[i], this)
|
}
|
}
|
|
get prune() {
|
deprecatedMethod('prune', 'purgeStale')
|
return this.purgeStale
|
}
|
|
purgeStale() {
|
let deleted = false
|
for (const i of this.rindexes({ allowStale: true })) {
|
if (this.isStale(i)) {
|
this.delete(this.keyList[i])
|
deleted = true
|
}
|
}
|
return deleted
|
}
|
|
dump() {
|
const arr = []
|
for (const i of this.indexes({ allowStale: true })) {
|
const key = this.keyList[i]
|
const v = this.valList[i]
|
const value = this.isBackgroundFetch(v)
|
? v.__staleWhileFetching
|
: v
|
const entry = { value }
|
if (this.ttls) {
|
entry.ttl = this.ttls[i]
|
// always dump the start relative to a portable timestamp
|
// it's ok for this to be a bit slow, it's a rare operation.
|
const age = perf.now() - this.starts[i]
|
entry.start = Math.floor(Date.now() - age)
|
}
|
if (this.sizes) {
|
entry.size = this.sizes[i]
|
}
|
arr.unshift([key, entry])
|
}
|
return arr
|
}
|
|
load(arr) {
|
this.clear()
|
for (const [key, entry] of arr) {
|
if (entry.start) {
|
// entry.start is a portable timestamp, but we may be using
|
// node's performance.now(), so calculate the offset.
|
// it's ok for this to be a bit slow, it's a rare operation.
|
const age = Date.now() - entry.start
|
entry.start = perf.now() - age
|
}
|
this.set(key, entry.value, entry)
|
}
|
}
|
|
dispose(v, k, reason) {}
|
|
set(
|
k,
|
v,
|
{
|
ttl = this.ttl,
|
start,
|
noDisposeOnSet = this.noDisposeOnSet,
|
size = 0,
|
sizeCalculation = this.sizeCalculation,
|
noUpdateTTL = this.noUpdateTTL,
|
} = {}
|
) {
|
size = this.requireSize(k, v, size, sizeCalculation)
|
// if the item doesn't fit, don't do anything
|
// NB: maxEntrySize set to maxSize by default
|
if (this.maxEntrySize && size > this.maxEntrySize) {
|
// have to delete, in case a background fetch is there already.
|
// in non-async cases, this is a no-op
|
this.delete(k)
|
return this
|
}
|
let index = this.size === 0 ? undefined : this.keyMap.get(k)
|
if (index === undefined) {
|
// addition
|
index = this.newIndex()
|
this.keyList[index] = k
|
this.valList[index] = v
|
this.keyMap.set(k, index)
|
this.next[this.tail] = index
|
this.prev[index] = this.tail
|
this.tail = index
|
this.size++
|
this.addItemSize(index, size)
|
noUpdateTTL = false
|
} else {
|
// update
|
const oldVal = this.valList[index]
|
if (v !== oldVal) {
|
if (this.isBackgroundFetch(oldVal)) {
|
oldVal.__abortController.abort()
|
} else {
|
if (!noDisposeOnSet) {
|
this.dispose(oldVal, k, 'set')
|
if (this.disposeAfter) {
|
this.disposed.push([oldVal, k, 'set'])
|
}
|
}
|
}
|
this.removeItemSize(index)
|
this.valList[index] = v
|
this.addItemSize(index, size)
|
}
|
this.moveToTail(index)
|
}
|
if (ttl !== 0 && this.ttl === 0 && !this.ttls) {
|
this.initializeTTLTracking()
|
}
|
if (!noUpdateTTL) {
|
this.setItemTTL(index, ttl, start)
|
}
|
if (this.disposeAfter) {
|
while (this.disposed.length) {
|
this.disposeAfter(...this.disposed.shift())
|
}
|
}
|
return this
|
}
|
|
newIndex() {
|
if (this.size === 0) {
|
return this.tail
|
}
|
if (this.size === this.max && this.max !== 0) {
|
return this.evict(false)
|
}
|
if (this.free.length !== 0) {
|
return this.free.pop()
|
}
|
// initial fill, just keep writing down the list
|
return this.initialFill++
|
}
|
|
pop() {
|
if (this.size) {
|
const val = this.valList[this.head]
|
this.evict(true)
|
return val
|
}
|
}
|
|
evict(free) {
|
const head = this.head
|
const k = this.keyList[head]
|
const v = this.valList[head]
|
if (this.isBackgroundFetch(v)) {
|
v.__abortController.abort()
|
} else {
|
this.dispose(v, k, 'evict')
|
if (this.disposeAfter) {
|
this.disposed.push([v, k, 'evict'])
|
}
|
}
|
this.removeItemSize(head)
|
// if we aren't about to use the index, then null these out
|
if (free) {
|
this.keyList[head] = null
|
this.valList[head] = null
|
this.free.push(head)
|
}
|
this.head = this.next[head]
|
this.keyMap.delete(k)
|
this.size--
|
return head
|
}
|
|
has(k, { updateAgeOnHas = this.updateAgeOnHas } = {}) {
|
const index = this.keyMap.get(k)
|
if (index !== undefined) {
|
if (!this.isStale(index)) {
|
if (updateAgeOnHas) {
|
this.updateItemAge(index)
|
}
|
return true
|
}
|
}
|
return false
|
}
|
|
// like get(), but without any LRU updating or TTL expiration
|
peek(k, { allowStale = this.allowStale } = {}) {
|
const index = this.keyMap.get(k)
|
if (index !== undefined && (allowStale || !this.isStale(index))) {
|
const v = this.valList[index]
|
// either stale and allowed, or forcing a refresh of non-stale value
|
return this.isBackgroundFetch(v) ? v.__staleWhileFetching : v
|
}
|
}
|
|
backgroundFetch(k, index, options, context) {
|
const v = index === undefined ? undefined : this.valList[index]
|
if (this.isBackgroundFetch(v)) {
|
return v
|
}
|
const ac = new AC()
|
const fetchOpts = {
|
signal: ac.signal,
|
options,
|
context,
|
}
|
const cb = v => {
|
if (!ac.signal.aborted) {
|
this.set(k, v, fetchOpts.options)
|
}
|
return v
|
}
|
const eb = er => {
|
if (this.valList[index] === p) {
|
const del =
|
!options.noDeleteOnFetchRejection ||
|
p.__staleWhileFetching === undefined
|
if (del) {
|
this.delete(k)
|
} else {
|
// still replace the *promise* with the stale value,
|
// since we are done with the promise at this point.
|
this.valList[index] = p.__staleWhileFetching
|
}
|
}
|
if (p.__returned === p) {
|
throw er
|
}
|
}
|
const pcall = res => res(this.fetchMethod(k, v, fetchOpts))
|
const p = new Promise(pcall).then(cb, eb)
|
p.__abortController = ac
|
p.__staleWhileFetching = v
|
p.__returned = null
|
if (index === undefined) {
|
this.set(k, p, fetchOpts.options)
|
index = this.keyMap.get(k)
|
} else {
|
this.valList[index] = p
|
}
|
return p
|
}
|
|
isBackgroundFetch(p) {
|
return (
|
p &&
|
typeof p === 'object' &&
|
typeof p.then === 'function' &&
|
Object.prototype.hasOwnProperty.call(
|
p,
|
'__staleWhileFetching'
|
) &&
|
Object.prototype.hasOwnProperty.call(p, '__returned') &&
|
(p.__returned === p || p.__returned === null)
|
)
|
}
|
|
// this takes the union of get() and set() opts, because it does both
|
async fetch(
|
k,
|
{
|
// get options
|
allowStale = this.allowStale,
|
updateAgeOnGet = this.updateAgeOnGet,
|
noDeleteOnStaleGet = this.noDeleteOnStaleGet,
|
// set options
|
ttl = this.ttl,
|
noDisposeOnSet = this.noDisposeOnSet,
|
size = 0,
|
sizeCalculation = this.sizeCalculation,
|
noUpdateTTL = this.noUpdateTTL,
|
// fetch exclusive options
|
noDeleteOnFetchRejection = this.noDeleteOnFetchRejection,
|
fetchContext = this.fetchContext,
|
forceRefresh = false,
|
} = {}
|
) {
|
if (!this.fetchMethod) {
|
return this.get(k, {
|
allowStale,
|
updateAgeOnGet,
|
noDeleteOnStaleGet,
|
})
|
}
|
|
const options = {
|
allowStale,
|
updateAgeOnGet,
|
noDeleteOnStaleGet,
|
ttl,
|
noDisposeOnSet,
|
size,
|
sizeCalculation,
|
noUpdateTTL,
|
noDeleteOnFetchRejection,
|
}
|
|
let index = this.keyMap.get(k)
|
if (index === undefined) {
|
const p = this.backgroundFetch(k, index, options, fetchContext)
|
return (p.__returned = p)
|
} else {
|
// in cache, maybe already fetching
|
const v = this.valList[index]
|
if (this.isBackgroundFetch(v)) {
|
return allowStale && v.__staleWhileFetching !== undefined
|
? v.__staleWhileFetching
|
: (v.__returned = v)
|
}
|
|
// if we force a refresh, that means do NOT serve the cached value,
|
// unless we are already in the process of refreshing the cache.
|
if (!forceRefresh && !this.isStale(index)) {
|
this.moveToTail(index)
|
if (updateAgeOnGet) {
|
this.updateItemAge(index)
|
}
|
return v
|
}
|
|
// ok, it is stale or a forced refresh, and not already fetching.
|
// refresh the cache.
|
const p = this.backgroundFetch(k, index, options, fetchContext)
|
return allowStale && p.__staleWhileFetching !== undefined
|
? p.__staleWhileFetching
|
: (p.__returned = p)
|
}
|
}
|
|
get(
|
k,
|
{
|
allowStale = this.allowStale,
|
updateAgeOnGet = this.updateAgeOnGet,
|
noDeleteOnStaleGet = this.noDeleteOnStaleGet,
|
} = {}
|
) {
|
const index = this.keyMap.get(k)
|
if (index !== undefined) {
|
const value = this.valList[index]
|
const fetching = this.isBackgroundFetch(value)
|
if (this.isStale(index)) {
|
// delete only if not an in-flight background fetch
|
if (!fetching) {
|
if (!noDeleteOnStaleGet) {
|
this.delete(k)
|
}
|
return allowStale ? value : undefined
|
} else {
|
return allowStale ? value.__staleWhileFetching : undefined
|
}
|
} else {
|
// if we're currently fetching it, we don't actually have it yet
|
// it's not stale, which means this isn't a staleWhileRefetching,
|
// so we just return undefined
|
if (fetching) {
|
return undefined
|
}
|
this.moveToTail(index)
|
if (updateAgeOnGet) {
|
this.updateItemAge(index)
|
}
|
return value
|
}
|
}
|
}
|
|
connect(p, n) {
|
this.prev[n] = p
|
this.next[p] = n
|
}
|
|
moveToTail(index) {
|
// if tail already, nothing to do
|
// if head, move head to next[index]
|
// else
|
// move next[prev[index]] to next[index] (head has no prev)
|
// move prev[next[index]] to prev[index]
|
// prev[index] = tail
|
// next[tail] = index
|
// tail = index
|
if (index !== this.tail) {
|
if (index === this.head) {
|
this.head = this.next[index]
|
} else {
|
this.connect(this.prev[index], this.next[index])
|
}
|
this.connect(this.tail, index)
|
this.tail = index
|
}
|
}
|
|
get del() {
|
deprecatedMethod('del', 'delete')
|
return this.delete
|
}
|
|
delete(k) {
|
let deleted = false
|
if (this.size !== 0) {
|
const index = this.keyMap.get(k)
|
if (index !== undefined) {
|
deleted = true
|
if (this.size === 1) {
|
this.clear()
|
} else {
|
this.removeItemSize(index)
|
const v = this.valList[index]
|
if (this.isBackgroundFetch(v)) {
|
v.__abortController.abort()
|
} else {
|
this.dispose(v, k, 'delete')
|
if (this.disposeAfter) {
|
this.disposed.push([v, k, 'delete'])
|
}
|
}
|
this.keyMap.delete(k)
|
this.keyList[index] = null
|
this.valList[index] = null
|
if (index === this.tail) {
|
this.tail = this.prev[index]
|
} else if (index === this.head) {
|
this.head = this.next[index]
|
} else {
|
this.next[this.prev[index]] = this.next[index]
|
this.prev[this.next[index]] = this.prev[index]
|
}
|
this.size--
|
this.free.push(index)
|
}
|
}
|
}
|
if (this.disposed) {
|
while (this.disposed.length) {
|
this.disposeAfter(...this.disposed.shift())
|
}
|
}
|
return deleted
|
}
|
|
clear() {
|
for (const index of this.rindexes({ allowStale: true })) {
|
const v = this.valList[index]
|
if (this.isBackgroundFetch(v)) {
|
v.__abortController.abort()
|
} else {
|
const k = this.keyList[index]
|
this.dispose(v, k, 'delete')
|
if (this.disposeAfter) {
|
this.disposed.push([v, k, 'delete'])
|
}
|
}
|
}
|
|
this.keyMap.clear()
|
this.valList.fill(null)
|
this.keyList.fill(null)
|
if (this.ttls) {
|
this.ttls.fill(0)
|
this.starts.fill(0)
|
}
|
if (this.sizes) {
|
this.sizes.fill(0)
|
}
|
this.head = 0
|
this.tail = 0
|
this.initialFill = 1
|
this.free.length = 0
|
this.calculatedSize = 0
|
this.size = 0
|
if (this.disposed) {
|
while (this.disposed.length) {
|
this.disposeAfter(...this.disposed.shift())
|
}
|
}
|
}
|
|
get reset() {
|
deprecatedMethod('reset', 'clear')
|
return this.clear
|
}
|
|
get length() {
|
deprecatedProperty('length', 'size')
|
return this.size
|
}
|
|
static get AbortController() {
|
return AC
|
}
|
static get AbortSignal() {
|
return AS
|
}
|
}
|
|
module.exports = LRUCache
|
|
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(4)))
|
|
/***/ }),
|
/* 47 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
/* WEBPACK VAR INJECTION */(function(Buffer, setImmediate, global, process) {var require;var require;/*!
|
|
JSZip v3.10.0 - A JavaScript class for generating and reading zip files
|
<http://stuartk.com/jszip>
|
|
(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
|
Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.
|
|
JSZip uses the library pako released under the MIT license :
|
https://github.com/nodeca/pako/blob/main/LICENSE
|
*/
|
|
!function(e){if(true)module.exports=e();else {}}(function(){return function s(a,o,h){function u(r,e){if(!o[r]){if(!a[r]){var t="function"==typeof require&&require;if(!e&&__webpack_require__(49))return require(r,!0);if(l)return l(r,!0);var n=new Error("Cannot find module '"+r+"'");throw n.code="MODULE_NOT_FOUND",n}var i=o[r]={exports:{}};a[r][0].call(i.exports,function(e){var t=a[r][1][e];return u(t||e)},i,i.exports,s,a,o,h)}return o[r].exports}for(var l="function"==typeof require&&require,e=0;e<h.length;e++)u(h[e]);return u}({1:[function(e,t,r){"use strict";var d=e("./utils"),c=e("./support"),p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(e){for(var t,r,n,i,s,a,o,h=[],u=0,l=e.length,f=l,c="string"!==d.getTypeOf(e);u<e.length;)f=l-u,n=c?(t=e[u++],r=u<l?e[u++]:0,u<l?e[u++]:0):(t=e.charCodeAt(u++),r=u<l?e.charCodeAt(u++):0,u<l?e.charCodeAt(u++):0),i=t>>2,s=(3&t)<<4|r>>4,a=1<f?(15&r)<<2|n>>6:64,o=2<f?63&n:64,h.push(p.charAt(i)+p.charAt(s)+p.charAt(a)+p.charAt(o));return h.join("")},r.decode=function(e){var t,r,n,i,s,a,o=0,h=0,u="data:";if(e.substr(0,u.length)===u)throw new Error("Invalid base64 input, it looks like a data url.");var l,f=3*(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"")).length/4;if(e.charAt(e.length-1)===p.charAt(64)&&f--,e.charAt(e.length-2)===p.charAt(64)&&f--,f%1!=0)throw new Error("Invalid base64 input, bad content length.");for(l=c.uint8array?new Uint8Array(0|f):new Array(0|f);o<e.length;)t=p.indexOf(e.charAt(o++))<<2|(i=p.indexOf(e.charAt(o++)))>>4,r=(15&i)<<4|(s=p.indexOf(e.charAt(o++)))>>2,n=(3&s)<<6|(a=p.indexOf(e.charAt(o++))),l[h++]=t,64!==s&&(l[h++]=r),64!==a&&(l[h++]=n);return l}},{"./support":30,"./utils":32}],2:[function(e,t,r){"use strict";var n=e("./external"),i=e("./stream/DataWorker"),s=e("./stream/Crc32Probe"),a=e("./stream/DataLengthProbe");function o(e,t,r,n,i){this.compressedSize=e,this.uncompressedSize=t,this.crc32=r,this.compression=n,this.compressedContent=i}o.prototype={getContentWorker:function(){var e=new i(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new a("data_length")),t=this;return e.on("end",function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),e},getCompressedWorker:function(){return new i(n.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},o.createWorkerFrom=function(e,t,r){return e.pipe(new s).pipe(new a("uncompressedSize")).pipe(t.compressWorker(r)).pipe(new a("compressedSize")).withStreamInfo("compression",t)},t.exports=o},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,r){"use strict";var n=e("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(e){return new n("STORE compression")},uncompressWorker:function(){return new n("STORE decompression")}},r.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,r){"use strict";var n=e("./utils");var o=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();t.exports=function(e,t){return void 0!==e&&e.length?"string"!==n.getTypeOf(e)?function(e,t,r,n){var i=o,s=n+r;e^=-1;for(var a=n;a<s;a++)e=e>>>8^i[255&(e^t[a])];return-1^e}(0|t,e,e.length,0):function(e,t,r,n){var i=o,s=n+r;e^=-1;for(var a=n;a<s;a++)e=e>>>8^i[255&(e^t.charCodeAt(a))];return-1^e}(0|t,e,e.length,0):0}},{"./utils":32}],5:[function(e,t,r){"use strict";r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(e,t,r){"use strict";var n=null;n="undefined"!=typeof Promise?Promise:e("lie"),t.exports={Promise:n}},{lie:37}],7:[function(e,t,r){"use strict";var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,i=e("pako"),s=e("./utils"),a=e("./stream/GenericWorker"),o=n?"uint8array":"array";function h(e,t){a.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}r.magic="\b\0",s.inherits(h,a),h.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(s.transformTo(o,e.data),!1)},h.prototype.flush=function(){a.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},h.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this._pako=null},h.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var t=this;this._pako.onData=function(e){t.push({data:e,meta:t.meta})}},r.compressWorker=function(e){return new h("Deflate",e)},r.uncompressWorker=function(){return new h("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,r){"use strict";function A(e,t){var r,n="";for(r=0;r<t;r++)n+=String.fromCharCode(255&e),e>>>=8;return n}function n(e,t,r,n,i,s){var a,o,h=e.file,u=e.compression,l=s!==O.utf8encode,f=I.transformTo("string",s(h.name)),c=I.transformTo("string",O.utf8encode(h.name)),d=h.comment,p=I.transformTo("string",s(d)),m=I.transformTo("string",O.utf8encode(d)),_=c.length!==h.name.length,g=m.length!==d.length,b="",v="",y="",w=h.dir,k=h.date,x={crc32:0,compressedSize:0,uncompressedSize:0};t&&!r||(x.crc32=e.crc32,x.compressedSize=e.compressedSize,x.uncompressedSize=e.uncompressedSize);var S=0;t&&(S|=8),l||!_&&!g||(S|=2048);var z=0,C=0;w&&(z|=16),"UNIX"===i?(C=798,z|=function(e,t){var r=e;return e||(r=t?16893:33204),(65535&r)<<16}(h.unixPermissions,w)):(C=20,z|=function(e){return 63&(e||0)}(h.dosPermissions)),a=k.getUTCHours(),a<<=6,a|=k.getUTCMinutes(),a<<=5,a|=k.getUTCSeconds()/2,o=k.getUTCFullYear()-1980,o<<=4,o|=k.getUTCMonth()+1,o<<=5,o|=k.getUTCDate(),_&&(v=A(1,1)+A(B(f),4)+c,b+="up"+A(v.length,2)+v),g&&(y=A(1,1)+A(B(p),4)+m,b+="uc"+A(y.length,2)+y);var E="";return E+="\n\0",E+=A(S,2),E+=u.magic,E+=A(a,2),E+=A(o,2),E+=A(x.crc32,4),E+=A(x.compressedSize,4),E+=A(x.uncompressedSize,4),E+=A(f.length,2),E+=A(b.length,2),{fileRecord:R.LOCAL_FILE_HEADER+E+f+b,dirRecord:R.CENTRAL_FILE_HEADER+A(C,2)+E+A(p.length,2)+"\0\0\0\0"+A(z,4)+A(n,4)+f+b+p}}var I=e("../utils"),i=e("../stream/GenericWorker"),O=e("../utf8"),B=e("../crc32"),R=e("../signature");function s(e,t,r,n){i.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=r,this.encodeFileName=n,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}I.inherits(s,i),s.prototype.push=function(e){var t=e.meta.percent||0,r=this.entriesCount,n=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,i.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:r?(t+100*(r-n-1))/r:100}}))},s.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var r=n(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:r.fileRecord,meta:{percent:0}})}else this.accumulate=!0},s.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,r=n(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(r.dirRecord),t)this.push({data:function(e){return R.DATA_DESCRIPTOR+A(e.crc32,4)+A(e.compressedSize,4)+A(e.uncompressedSize,4)}(e),meta:{percent:100}});else for(this.push({data:r.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},s.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t<this.dirRecords.length;t++)this.push({data:this.dirRecords[t],meta:{percent:100}});var r=this.bytesWritten-e,n=function(e,t,r,n,i){var s=I.transformTo("string",i(n));return R.CENTRAL_DIRECTORY_END+"\0\0\0\0"+A(e,2)+A(e,2)+A(t,4)+A(r,4)+A(s.length,2)+s}(this.dirRecords.length,r,e,this.zipComment,this.encodeFileName);this.push({data:n,meta:{percent:100}})},s.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},s.prototype.registerPrevious=function(e){this._sources.push(e);var t=this;return e.on("data",function(e){t.processChunk(e)}),e.on("end",function(){t.closedSource(t.previous.streamInfo),t._sources.length?t.prepareNextSource():t.end()}),e.on("error",function(e){t.error(e)}),this},s.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},s.prototype.error=function(e){var t=this._sources;if(!i.prototype.error.call(this,e))return!1;for(var r=0;r<t.length;r++)try{t[r].error(e)}catch(e){}return!0},s.prototype.lock=function(){i.prototype.lock.call(this);for(var e=this._sources,t=0;t<e.length;t++)e[t].lock()},t.exports=s},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(e,t,r){"use strict";var u=e("../compressions"),n=e("./ZipFileWorker");r.generateWorker=function(e,a,t){var o=new n(a.streamFiles,t,a.platform,a.encodeFileName),h=0;try{e.forEach(function(e,t){h++;var r=function(e,t){var r=e||t,n=u[r];if(!n)throw new Error(r+" is not a valid compression method !");return n}(t.options.compression,a.compression),n=t.options.compressionOptions||a.compressionOptions||{},i=t.dir,s=t.date;t._compressWorker(r,n).withStreamInfo("file",{name:e,dir:i,date:s,comment:t.comment||"",unixPermissions:t.unixPermissions,dosPermissions:t.dosPermissions}).pipe(o)}),o.entriesCount=h}catch(e){o.error(e)}return o}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,t,r){"use strict";function n(){if(!(this instanceof n))return new n;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var e=new n;for(var t in this)"function"!=typeof this[t]&&(e[t]=this[t]);return e}}(n.prototype=e("./object")).loadAsync=e("./load"),n.support=e("./support"),n.defaults=e("./defaults"),n.version="3.10.0",n.loadAsync=function(e,t){return(new n).loadAsync(e,t)},n.external=e("./external"),t.exports=n},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(e,t,r){"use strict";var u=e("./utils"),i=e("./external"),n=e("./utf8"),s=e("./zipEntries"),a=e("./stream/Crc32Probe"),l=e("./nodejsUtils");function f(n){return new i.Promise(function(e,t){var r=n.decompressed.getContentWorker().pipe(new a);r.on("error",function(e){t(e)}).on("end",function(){r.streamInfo.crc32!==n.decompressed.crc32?t(new Error("Corrupted zip : CRC32 mismatch")):e()}).resume()})}t.exports=function(e,o){var h=this;return o=u.extend(o||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:n.utf8decode}),l.isNode&&l.isStream(e)?i.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):u.prepareContent("the loaded zip file",e,!0,o.optimizedBinaryString,o.base64).then(function(e){var t=new s(o);return t.load(e),t}).then(function(e){var t=[i.Promise.resolve(e)],r=e.files;if(o.checkCRC32)for(var n=0;n<r.length;n++)t.push(f(r[n]));return i.Promise.all(t)}).then(function(e){for(var t=e.shift(),r=t.files,n=0;n<r.length;n++){var i=r[n],s=i.fileNameStr,a=u.resolve(i.fileNameStr);h.file(a,i.decompressed,{binary:!0,optimizedBinaryString:!0,date:i.date,dir:i.dir,comment:i.fileCommentStr.length?i.fileCommentStr:null,unixPermissions:i.unixPermissions,dosPermissions:i.dosPermissions,createFolders:o.createFolders}),i.dir||(h.file(a).unsafeOriginalName=s)}return t.zipComment.length&&(h.comment=t.zipComment),h})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(e,t,r){"use strict";var n=e("../utils"),i=e("../stream/GenericWorker");function s(e,t){i.call(this,"Nodejs stream input adapter for "+e),this._upstreamEnded=!1,this._bindStream(t)}n.inherits(s,i),s.prototype._bindStream=function(e){var t=this;(this._stream=e).pause(),e.on("data",function(e){t.push({data:e,meta:{percent:0}})}).on("error",function(e){t.isPaused?this.generatedError=e:t.error(e)}).on("end",function(){t.isPaused?t._upstreamEnded=!0:t.end()})},s.prototype.pause=function(){return!!i.prototype.pause.call(this)&&(this._stream.pause(),!0)},s.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},t.exports=s},{"../stream/GenericWorker":28,"../utils":32}],13:[function(e,t,r){"use strict";var i=e("readable-stream").Readable;function n(e,t,r){i.call(this,t),this._helper=e;var n=this;e.on("data",function(e,t){n.push(e)||n._helper.pause(),r&&r(t)}).on("error",function(e){n.emit("error",e)}).on("end",function(){n.push(null)})}e("../utils").inherits(n,i),n.prototype._read=function(){this._helper.resume()},t.exports=n},{"../utils":32,"readable-stream":16}],14:[function(e,t,r){"use strict";t.exports={isNode:"undefined"!=typeof Buffer,newBufferFrom:function(e,t){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(e,t);if("number"==typeof e)throw new Error('The "data" argument must not be a number');return new Buffer(e,t)},allocBuffer:function(e){if(Buffer.alloc)return Buffer.alloc(e);var t=new Buffer(e);return t.fill(0),t},isBuffer:function(e){return Buffer.isBuffer(e)},isStream:function(e){return e&&"function"==typeof e.on&&"function"==typeof e.pause&&"function"==typeof e.resume}}},{}],15:[function(e,t,r){"use strict";function s(e,t,r){var n,i=u.getTypeOf(t),s=u.extend(r||{},f);s.date=s.date||new Date,null!==s.compression&&(s.compression=s.compression.toUpperCase()),"string"==typeof s.unixPermissions&&(s.unixPermissions=parseInt(s.unixPermissions,8)),s.unixPermissions&&16384&s.unixPermissions&&(s.dir=!0),s.dosPermissions&&16&s.dosPermissions&&(s.dir=!0),s.dir&&(e=g(e)),s.createFolders&&(n=_(e))&&b.call(this,n,!0);var a="string"===i&&!1===s.binary&&!1===s.base64;r&&void 0!==r.binary||(s.binary=!a),(t instanceof c&&0===t.uncompressedSize||s.dir||!t||0===t.length)&&(s.base64=!1,s.binary=!0,t="",s.compression="STORE",i="string");var o=null;o=t instanceof c||t instanceof l?t:p.isNode&&p.isStream(t)?new m(e,t):u.prepareContent(e,t,s.binary,s.optimizedBinaryString,s.base64);var h=new d(e,o,s);this.files[e]=h}var i=e("./utf8"),u=e("./utils"),l=e("./stream/GenericWorker"),a=e("./stream/StreamHelper"),f=e("./defaults"),c=e("./compressedObject"),d=e("./zipObject"),o=e("./generate"),p=e("./nodejsUtils"),m=e("./nodejs/NodejsStreamInputAdapter"),_=function(e){"/"===e.slice(-1)&&(e=e.substring(0,e.length-1));var t=e.lastIndexOf("/");return 0<t?e.substring(0,t):""},g=function(e){return"/"!==e.slice(-1)&&(e+="/"),e},b=function(e,t){return t=void 0!==t?t:f.createFolders,e=g(e),this.files[e]||s.call(this,e,null,{dir:!0,createFolders:t}),this.files[e]};function h(e){return"[object RegExp]"===Object.prototype.toString.call(e)}var n={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(e){var t,r,n;for(t in this.files)n=this.files[t],(r=t.slice(this.root.length,t.length))&&t.slice(0,this.root.length)===this.root&&e(r,n)},filter:function(r){var n=[];return this.forEach(function(e,t){r(e,t)&&n.push(t)}),n},file:function(e,t,r){if(1!==arguments.length)return e=this.root+e,s.call(this,e,t,r),this;if(h(e)){var n=e;return this.filter(function(e,t){return!t.dir&&n.test(e)})}var i=this.files[this.root+e];return i&&!i.dir?i:null},folder:function(r){if(!r)return this;if(h(r))return this.filter(function(e,t){return t.dir&&r.test(e)});var e=this.root+r,t=b.call(this,e),n=this.clone();return n.root=t.name,n},remove:function(r){r=this.root+r;var e=this.files[r];if(e||("/"!==r.slice(-1)&&(r+="/"),e=this.files[r]),e&&!e.dir)delete this.files[r];else for(var t=this.filter(function(e,t){return t.name.slice(0,r.length)===r}),n=0;n<t.length;n++)delete this.files[t[n].name];return this},generate:function(e){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(e){var t,r={};try{if((r=u.extend(e||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:i.utf8encode})).type=r.type.toLowerCase(),r.compression=r.compression.toUpperCase(),"binarystring"===r.type&&(r.type="string"),!r.type)throw new Error("No output type specified.");u.checkSupport(r.type),"darwin"!==r.platform&&"freebsd"!==r.platform&&"linux"!==r.platform&&"sunos"!==r.platform||(r.platform="UNIX"),"win32"===r.platform&&(r.platform="DOS");var n=r.comment||this.comment||"";t=o.generateWorker(this,r,n)}catch(e){(t=new l("error")).error(e)}return new a(t,r.type||"string",r.mimeType)},generateAsync:function(e,t){return this.generateInternalStream(e).accumulate(t)},generateNodeStream:function(e,t){return(e=e||{}).type||(e.type="nodebuffer"),this.generateInternalStream(e).toNodejsStream(t)}};t.exports=n},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(e,t,r){t.exports=e("stream")},{stream:void 0}],17:[function(e,t,r){"use strict";var n=e("./DataReader");function i(e){n.call(this,e);for(var t=0;t<this.data.length;t++)e[t]=255&e[t]}e("../utils").inherits(i,n),i.prototype.byteAt=function(e){return this.data[this.zero+e]},i.prototype.lastIndexOfSignature=function(e){for(var t=e.charCodeAt(0),r=e.charCodeAt(1),n=e.charCodeAt(2),i=e.charCodeAt(3),s=this.length-4;0<=s;--s)if(this.data[s]===t&&this.data[s+1]===r&&this.data[s+2]===n&&this.data[s+3]===i)return s-this.zero;return-1},i.prototype.readAndCheckSignature=function(e){var t=e.charCodeAt(0),r=e.charCodeAt(1),n=e.charCodeAt(2),i=e.charCodeAt(3),s=this.readData(4);return t===s[0]&&r===s[1]&&n===s[2]&&i===s[3]},i.prototype.readData=function(e){if(this.checkOffset(e),0===e)return[];var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],18:[function(e,t,r){"use strict";var n=e("../utils");function i(e){this.data=e,this.length=e.length,this.index=0,this.zero=0}i.prototype={checkOffset:function(e){this.checkIndex(this.index+e)},checkIndex:function(e){if(this.length<this.zero+e||e<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+e+"). Corrupted zip ?")},setIndex:function(e){this.checkIndex(e),this.index=e},skip:function(e){this.setIndex(this.index+e)},byteAt:function(e){},readInt:function(e){var t,r=0;for(this.checkOffset(e),t=this.index+e-1;t>=this.index;t--)r=(r<<8)+this.byteAt(t);return this.index+=e,r},readString:function(e){return n.transformTo("string",this.readData(e))},readData:function(e){},lastIndexOfSignature:function(e){},readAndCheckSignature:function(e){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=i},{"../utils":32}],19:[function(e,t,r){"use strict";var n=e("./Uint8ArrayReader");function i(e){n.call(this,e)}e("../utils").inherits(i,n),i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,r){"use strict";var n=e("./DataReader");function i(e){n.call(this,e)}e("../utils").inherits(i,n),i.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},i.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},i.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],21:[function(e,t,r){"use strict";var n=e("./ArrayReader");function i(e){n.call(this,e)}e("../utils").inherits(i,n),i.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,r){"use strict";var n=e("../utils"),i=e("../support"),s=e("./ArrayReader"),a=e("./StringReader"),o=e("./NodeBufferReader"),h=e("./Uint8ArrayReader");t.exports=function(e){var t=n.getTypeOf(e);return n.checkSupport(t),"string"!==t||i.uint8array?"nodebuffer"===t?new o(e):i.uint8array?new h(n.transformTo("uint8array",e)):new s(n.transformTo("array",e)):new a(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,r){"use strict";r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\b"},{}],24:[function(e,t,r){"use strict";var n=e("./GenericWorker"),i=e("../utils");function s(e){n.call(this,"ConvertWorker to "+e),this.destType=e}i.inherits(s,n),s.prototype.processChunk=function(e){this.push({data:i.transformTo(this.destType,e.data),meta:e.meta})},t.exports=s},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,r){"use strict";var n=e("./GenericWorker"),i=e("../crc32");function s(){n.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(s,n),s.prototype.processChunk=function(e){this.streamInfo.crc32=i(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=s},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,r){"use strict";var n=e("../utils"),i=e("./GenericWorker");function s(e){i.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}n.inherits(s,i),s.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}i.prototype.processChunk.call(this,e)},t.exports=s},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,r){"use strict";var n=e("../utils"),i=e("./GenericWorker");function s(e){i.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then(function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=n.getTypeOf(e),t.isPaused||t._tickAndRepeat()},function(e){t.error(e)})}n.inherits(s,i),s.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},s.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,n.delay(this._tickAndRepeat,[],this)),!0)},s.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(n.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},s.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=s},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,r){"use strict";function n(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}n.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var r=0;r<this._listeners[e].length;r++)this._listeners[e][r].call(this,t)},pipe:function(e){return e.registerPrevious(this)},registerPrevious:function(e){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=e.streamInfo,this.mergeStreamInfo(),this.previous=e;var t=this;return e.on("data",function(e){t.processChunk(e)}),e.on("end",function(){t.end()}),e.on("error",function(e){t.error(e)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var e=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),e=!0),this.previous&&this.previous.resume(),!e},flush:function(){},processChunk:function(e){this.push(e)},withStreamInfo:function(e,t){return this.extraStreamInfo[e]=t,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var e in this.extraStreamInfo)this.extraStreamInfo.hasOwnProperty(e)&&(this.streamInfo[e]=this.extraStreamInfo[e])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var e="Worker "+this.name;return this.previous?this.previous+" -> "+e:e}},t.exports=n},{}],29:[function(e,t,r){"use strict";var h=e("../utils"),i=e("./ConvertWorker"),s=e("./GenericWorker"),u=e("../base64"),n=e("../support"),a=e("../external"),o=null;if(n.nodestream)try{o=e("../nodejs/NodejsStreamOutputAdapter")}catch(e){}function l(e,o){return new a.Promise(function(t,r){var n=[],i=e._internalType,s=e._outputType,a=e._mimeType;e.on("data",function(e,t){n.push(e),o&&o(t)}).on("error",function(e){n=[],r(e)}).on("end",function(){try{var e=function(e,t,r){switch(e){case"blob":return h.newBlob(h.transformTo("arraybuffer",t),r);case"base64":return u.encode(t);default:return h.transformTo(e,t)}}(s,function(e,t){var r,n=0,i=null,s=0;for(r=0;r<t.length;r++)s+=t[r].length;switch(e){case"string":return t.join("");case"array":return Array.prototype.concat.apply([],t);case"uint8array":for(i=new Uint8Array(s),r=0;r<t.length;r++)i.set(t[r],n),n+=t[r].length;return i;case"nodebuffer":return Buffer.concat(t);default:throw new Error("concat : unsupported type '"+e+"'")}}(i,n),a);t(e)}catch(e){r(e)}n=[]}).resume()})}function f(e,t,r){var n=t;switch(t){case"blob":case"arraybuffer":n="uint8array";break;case"base64":n="string"}try{this._internalType=n,this._outputType=t,this._mimeType=r,h.checkSupport(n),this._worker=e.pipe(new i(n)),e.lock()}catch(e){this._worker=new s("error"),this._worker.error(e)}}f.prototype={accumulate:function(e){return l(this,e)},on:function(e,t){var r=this;return"data"===e?this._worker.on(e,function(e){t.call(r,e.data,e.meta)}):this._worker.on(e,function(){h.delay(t,arguments,r)}),this},resume:function(){return h.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(e){if(h.checkSupport("nodestream"),"nodebuffer"!==this._outputType)throw new Error(this._outputType+" is not supported by this method");return new o(this,{objectMode:"nodebuffer"!==this._outputType},e)}},t.exports=f},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(e,t,r){"use strict";if(r.base64=!0,r.array=!0,r.string=!0,r.arraybuffer="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,r.nodebuffer="undefined"!=typeof Buffer,r.uint8array="undefined"!=typeof Uint8Array,"undefined"==typeof ArrayBuffer)r.blob=!1;else{var n=new ArrayBuffer(0);try{r.blob=0===new Blob([n],{type:"application/zip"}).size}catch(e){try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(n),r.blob=0===i.getBlob("application/zip").size}catch(e){r.blob=!1}}}try{r.nodestream=!!e("readable-stream").Readable}catch(e){r.nodestream=!1}},{"readable-stream":16}],31:[function(e,t,s){"use strict";for(var o=e("./utils"),h=e("./support"),r=e("./nodejsUtils"),n=e("./stream/GenericWorker"),u=new Array(256),i=0;i<256;i++)u[i]=252<=i?6:248<=i?5:240<=i?4:224<=i?3:192<=i?2:1;u[254]=u[254]=1;function a(){n.call(this,"utf-8 decode"),this.leftOver=null}function l(){n.call(this,"utf-8 encode")}s.utf8encode=function(e){return h.nodebuffer?r.newBufferFrom(e,"utf-8"):function(e){var t,r,n,i,s,a=e.length,o=0;for(i=0;i<a;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),o+=r<128?1:r<2048?2:r<65536?3:4;for(t=h.uint8array?new Uint8Array(o):new Array(o),i=s=0;s<o;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),r<128?t[s++]=r:(r<2048?t[s++]=192|r>>>6:(r<65536?t[s++]=224|r>>>12:(t[s++]=240|r>>>18,t[s++]=128|r>>>12&63),t[s++]=128|r>>>6&63),t[s++]=128|63&r);return t}(e)},s.utf8decode=function(e){return h.nodebuffer?o.transformTo("nodebuffer",e).toString("utf-8"):function(e){var t,r,n,i,s=e.length,a=new Array(2*s);for(t=r=0;t<s;)if((n=e[t++])<128)a[r++]=n;else if(4<(i=u[n]))a[r++]=65533,t+=i-1;else{for(n&=2===i?31:3===i?15:7;1<i&&t<s;)n=n<<6|63&e[t++],i--;1<i?a[r++]=65533:n<65536?a[r++]=n:(n-=65536,a[r++]=55296|n>>10&1023,a[r++]=56320|1023&n)}return a.length!==r&&(a.subarray?a=a.subarray(0,r):a.length=r),o.applyFromCharCode(a)}(e=o.transformTo(h.uint8array?"uint8array":"array",e))},o.inherits(a,n),a.prototype.processChunk=function(e){var t=o.transformTo(h.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(h.uint8array){var r=t;(t=new Uint8Array(r.length+this.leftOver.length)).set(this.leftOver,0),t.set(r,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var n=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;0<=r&&128==(192&e[r]);)r--;return r<0?t:0===r?t:r+u[e[r]]>t?r:t}(t),i=t;n!==t.length&&(h.uint8array?(i=t.subarray(0,n),this.leftOver=t.subarray(n,t.length)):(i=t.slice(0,n),this.leftOver=t.slice(n,t.length))),this.push({data:s.utf8decode(i),meta:e.meta})},a.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:s.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},s.Utf8DecodeWorker=a,o.inherits(l,n),l.prototype.processChunk=function(e){this.push({data:s.utf8encode(e.data),meta:e.meta})},s.Utf8EncodeWorker=l},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,a){"use strict";var o=e("./support"),h=e("./base64"),r=e("./nodejsUtils"),u=e("./external");function n(e){return e}function l(e,t){for(var r=0;r<e.length;++r)t[r]=255&e.charCodeAt(r);return t}e("setimmediate"),a.newBlob=function(t,r){a.checkSupport("blob");try{return new Blob([t],{type:r})}catch(e){try{var n=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return n.append(t),n.getBlob(r)}catch(e){throw new Error("Bug : can't construct the Blob.")}}};var i={stringifyByChunk:function(e,t,r){var n=[],i=0,s=e.length;if(s<=r)return String.fromCharCode.apply(null,e);for(;i<s;)"array"===t||"nodebuffer"===t?n.push(String.fromCharCode.apply(null,e.slice(i,Math.min(i+r,s)))):n.push(String.fromCharCode.apply(null,e.subarray(i,Math.min(i+r,s)))),i+=r;return n.join("")},stringifyByChar:function(e){for(var t="",r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},applyCanBeUsed:{uint8array:function(){try{return o.uint8array&&1===String.fromCharCode.apply(null,new Uint8Array(1)).length}catch(e){return!1}}(),nodebuffer:function(){try{return o.nodebuffer&&1===String.fromCharCode.apply(null,r.allocBuffer(1)).length}catch(e){return!1}}()}};function s(e){var t=65536,r=a.getTypeOf(e),n=!0;if("uint8array"===r?n=i.applyCanBeUsed.uint8array:"nodebuffer"===r&&(n=i.applyCanBeUsed.nodebuffer),n)for(;1<t;)try{return i.stringifyByChunk(e,r,t)}catch(e){t=Math.floor(t/2)}return i.stringifyByChar(e)}function f(e,t){for(var r=0;r<e.length;r++)t[r]=e[r];return t}a.applyFromCharCode=s;var c={};c.string={string:n,array:function(e){return l(e,new Array(e.length))},arraybuffer:function(e){return c.string.uint8array(e).buffer},uint8array:function(e){return l(e,new Uint8Array(e.length))},nodebuffer:function(e){return l(e,r.allocBuffer(e.length))}},c.array={string:s,array:n,arraybuffer:function(e){return new Uint8Array(e).buffer},uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return r.newBufferFrom(e)}},c.arraybuffer={string:function(e){return s(new Uint8Array(e))},array:function(e){return f(new Uint8Array(e),new Array(e.byteLength))},arraybuffer:n,uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return r.newBufferFrom(new Uint8Array(e))}},c.uint8array={string:s,array:function(e){return f(e,new Array(e.length))},arraybuffer:function(e){return e.buffer},uint8array:n,nodebuffer:function(e){return r.newBufferFrom(e)}},c.nodebuffer={string:s,array:function(e){return f(e,new Array(e.length))},arraybuffer:function(e){return c.nodebuffer.uint8array(e).buffer},uint8array:function(e){return f(e,new Uint8Array(e.length))},nodebuffer:n},a.transformTo=function(e,t){if(t=t||"",!e)return t;a.checkSupport(e);var r=a.getTypeOf(t);return c[r][e](t)},a.resolve=function(e){for(var t=e.split("/"),r=[],n=0;n<t.length;n++){var i=t[n];"."===i||""===i&&0!==n&&n!==t.length-1||(".."===i?r.pop():r.push(i))}return r.join("/")},a.getTypeOf=function(e){return"string"==typeof e?"string":"[object Array]"===Object.prototype.toString.call(e)?"array":o.nodebuffer&&r.isBuffer(e)?"nodebuffer":o.uint8array&&e instanceof Uint8Array?"uint8array":o.arraybuffer&&e instanceof ArrayBuffer?"arraybuffer":void 0},a.checkSupport=function(e){if(!o[e.toLowerCase()])throw new Error(e+" is not supported by this platform")},a.MAX_VALUE_16BITS=65535,a.MAX_VALUE_32BITS=-1,a.pretty=function(e){var t,r,n="";for(r=0;r<(e||"").length;r++)n+="\\x"+((t=e.charCodeAt(r))<16?"0":"")+t.toString(16).toUpperCase();return n},a.delay=function(e,t,r){setImmediate(function(){e.apply(r||null,t||[])})},a.inherits=function(e,t){function r(){}r.prototype=t.prototype,e.prototype=new r},a.extend=function(){var e,t,r={};for(e=0;e<arguments.length;e++)for(t in arguments[e])arguments[e].hasOwnProperty(t)&&void 0===r[t]&&(r[t]=arguments[e][t]);return r},a.prepareContent=function(r,e,n,i,s){return u.Promise.resolve(e).then(function(n){return o.blob&&(n instanceof Blob||-1!==["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(n)))&&"undefined"!=typeof FileReader?new u.Promise(function(t,r){var e=new FileReader;e.onload=function(e){t(e.target.result)},e.onerror=function(e){r(e.target.error)},e.readAsArrayBuffer(n)}):n}).then(function(e){var t=a.getTypeOf(e);return t?("arraybuffer"===t?e=a.transformTo("uint8array",e):"string"===t&&(s?e=h.decode(e):n&&!0!==i&&(e=function(e){return l(e,o.uint8array?new Uint8Array(e.length):new Array(e.length))}(e))),e):u.Promise.reject(new Error("Can't read the data of '"+r+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(e,t,r){"use strict";var n=e("./reader/readerFor"),i=e("./utils"),s=e("./signature"),a=e("./zipEntry"),o=(e("./utf8"),e("./support"));function h(e){this.files=[],this.loadOptions=e}h.prototype={checkSignature:function(e){if(!this.reader.readAndCheckSignature(e)){this.reader.index-=4;var t=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+i.pretty(t)+", expected "+i.pretty(e)+")")}},isSignature:function(e,t){var r=this.reader.index;this.reader.setIndex(e);var n=this.reader.readString(4)===t;return this.reader.setIndex(r),n},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var e=this.reader.readData(this.zipCommentLength),t=o.uint8array?"uint8array":"array",r=i.transformTo(t,e);this.zipComment=this.loadOptions.decodeFileName(r)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var e,t,r,n=this.zip64EndOfCentralSize-44;0<n;)e=this.reader.readInt(2),t=this.reader.readInt(4),r=this.reader.readData(t),this.zip64ExtensibleData[e]={id:e,length:t,value:r}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var e,t;for(e=0;e<this.files.length;e++)t=this.files[e],this.reader.setIndex(t.localHeaderOffset),this.checkSignature(s.LOCAL_FILE_HEADER),t.readLocalPart(this.reader),t.handleUTF8(),t.processAttributes()},readCentralDir:function(){var e;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(s.CENTRAL_FILE_HEADER);)(e=new a({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(e);if(this.centralDirRecords!==this.files.length&&0!==this.centralDirRecords&&0===this.files.length)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var e=this.reader.lastIndexOfSignature(s.CENTRAL_DIRECTORY_END);if(e<0)throw!this.isSignature(0,s.LOCAL_FILE_HEADER)?new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html"):new Error("Corrupted zip: can't find end of central directory");this.reader.setIndex(e);var t=e;if(this.checkSignature(s.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===i.MAX_VALUE_16BITS||this.diskWithCentralDirStart===i.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===i.MAX_VALUE_16BITS||this.centralDirRecords===i.MAX_VALUE_16BITS||this.centralDirSize===i.MAX_VALUE_32BITS||this.centralDirOffset===i.MAX_VALUE_32BITS){if(this.zip64=!0,(e=this.reader.lastIndexOfSignature(s.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(e),this.checkSignature(s.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,s.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(s.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(s.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var r=this.centralDirOffset+this.centralDirSize;this.zip64&&(r+=20,r+=12+this.zip64EndOfCentralSize);var n=t-r;if(0<n)this.isSignature(t,s.CENTRAL_FILE_HEADER)||(this.reader.zero=n);else if(n<0)throw new Error("Corrupted zip: missing "+Math.abs(n)+" bytes.")},prepareReader:function(e){this.reader=n(e)},load:function(e){this.prepareReader(e),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},t.exports=h},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utf8":31,"./utils":32,"./zipEntry":34}],34:[function(e,t,r){"use strict";var n=e("./reader/readerFor"),s=e("./utils"),i=e("./compressedObject"),a=e("./crc32"),o=e("./utf8"),h=e("./compressions"),u=e("./support");function l(e,t){this.options=e,this.loadOptions=t}l.prototype={isEncrypted:function(){return 1==(1&this.bitFlag)},useUTF8:function(){return 2048==(2048&this.bitFlag)},readLocalPart:function(e){var t,r;if(e.skip(22),this.fileNameLength=e.readInt(2),r=e.readInt(2),this.fileName=e.readData(this.fileNameLength),e.skip(r),-1===this.compressedSize||-1===this.uncompressedSize)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(null===(t=function(e){for(var t in h)if(h.hasOwnProperty(t)&&h[t].magic===e)return h[t];return null}(this.compressionMethod)))throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new i(this.compressedSize,this.uncompressedSize,this.crc32,t,e.readData(this.compressedSize))},readCentralPart:function(e){this.versionMadeBy=e.readInt(2),e.skip(2),this.bitFlag=e.readInt(2),this.compressionMethod=e.readString(2),this.date=e.readDate(),this.crc32=e.readInt(4),this.compressedSize=e.readInt(4),this.uncompressedSize=e.readInt(4);var t=e.readInt(2);if(this.extraFieldsLength=e.readInt(2),this.fileCommentLength=e.readInt(2),this.diskNumberStart=e.readInt(2),this.internalFileAttributes=e.readInt(2),this.externalFileAttributes=e.readInt(4),this.localHeaderOffset=e.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");e.skip(t),this.readExtraFields(e),this.parseZIP64ExtraField(e),this.fileComment=e.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var e=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(e){if(this.extraFields[1]){var t=n(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=t.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=t.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=t.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=t.readInt(4))}},readExtraFields:function(e){var t,r,n,i=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4<i;)t=e.readInt(2),r=e.readInt(2),n=e.readData(r),this.extraFields[t]={id:t,length:r,value:n};e.setIndex(i)},handleUTF8:function(){var e=u.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=o.utf8decode(this.fileName),this.fileCommentStr=o.utf8decode(this.fileComment);else{var t=this.findExtraFieldUnicodePath();if(null!==t)this.fileNameStr=t;else{var r=s.transformTo(e,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(r)}var n=this.findExtraFieldUnicodeComment();if(null!==n)this.fileCommentStr=n;else{var i=s.transformTo(e,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(i)}}},findExtraFieldUnicodePath:function(){var e=this.extraFields[28789];if(e){var t=n(e.value);return 1!==t.readInt(1)?null:a(this.fileName)!==t.readInt(4)?null:o.utf8decode(t.readData(e.length-5))}return null},findExtraFieldUnicodeComment:function(){var e=this.extraFields[25461];if(e){var t=n(e.value);return 1!==t.readInt(1)?null:a(this.fileComment)!==t.readInt(4)?null:o.utf8decode(t.readData(e.length-5))}return null}},t.exports=l},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(e,t,r){"use strict";function n(e,t,r){this.name=e,this.dir=r.dir,this.date=r.date,this.comment=r.comment,this.unixPermissions=r.unixPermissions,this.dosPermissions=r.dosPermissions,this._data=t,this._dataBinary=r.binary,this.options={compression:r.compression,compressionOptions:r.compressionOptions}}var s=e("./stream/StreamHelper"),i=e("./stream/DataWorker"),a=e("./utf8"),o=e("./compressedObject"),h=e("./stream/GenericWorker");n.prototype={internalStream:function(e){var t=null,r="string";try{if(!e)throw new Error("No output type specified.");var n="string"===(r=e.toLowerCase())||"text"===r;"binarystring"!==r&&"text"!==r||(r="string"),t=this._decompressWorker();var i=!this._dataBinary;i&&!n&&(t=t.pipe(new a.Utf8EncodeWorker)),!i&&n&&(t=t.pipe(new a.Utf8DecodeWorker))}catch(e){(t=new h("error")).error(e)}return new s(t,r,"")},async:function(e,t){return this.internalStream(e).accumulate(t)},nodeStream:function(e,t){return this.internalStream(e||"nodebuffer").toNodejsStream(t)},_compressWorker:function(e,t){if(this._data instanceof o&&this._data.compression.magic===e.magic)return this._data.getCompressedWorker();var r=this._decompressWorker();return this._dataBinary||(r=r.pipe(new a.Utf8EncodeWorker)),o.createWorkerFrom(r,e,t)},_decompressWorker:function(){return this._data instanceof o?this._data.getContentWorker():this._data instanceof h?this._data:new i(this._data)}};for(var u=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],l=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},f=0;f<u.length;f++)n.prototype[u[f]]=l;t.exports=n},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(e,l,t){(function(t){"use strict";var r,n,e=t.MutationObserver||t.WebKitMutationObserver;if(e){var i=0,s=new e(u),a=t.document.createTextNode("");s.observe(a,{characterData:!0}),r=function(){a.data=i=++i%2}}else if(t.setImmediate||void 0===t.MessageChannel)r="document"in t&&"onreadystatechange"in t.document.createElement("script")?function(){var e=t.document.createElement("script");e.onreadystatechange=function(){u(),e.onreadystatechange=null,e.parentNode.removeChild(e),e=null},t.document.documentElement.appendChild(e)}:function(){setTimeout(u,0)};else{var o=new t.MessageChannel;o.port1.onmessage=u,r=function(){o.port2.postMessage(0)}}var h=[];function u(){var e,t;n=!0;for(var r=h.length;r;){for(t=h,h=[],e=-1;++e<r;)t[e]();r=h.length}n=!1}l.exports=function(e){1!==h.push(e)||n||r()}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],37:[function(e,t,r){"use strict";var i=e("immediate");function u(){}var l={},s=["REJECTED"],a=["FULFILLED"],n=["PENDING"];function o(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=n,this.queue=[],this.outcome=void 0,e!==u&&d(this,e)}function h(e,t,r){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof r&&(this.onRejected=r,this.callRejected=this.otherCallRejected)}function f(t,r,n){i(function(){var e;try{e=r(n)}catch(e){return l.reject(t,e)}e===t?l.reject(t,new TypeError("Cannot resolve promise with itself")):l.resolve(t,e)})}function c(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function d(t,e){var r=!1;function n(e){r||(r=!0,l.reject(t,e))}function i(e){r||(r=!0,l.resolve(t,e))}var s=p(function(){e(i,n)});"error"===s.status&&n(s.value)}function p(e,t){var r={};try{r.value=e(t),r.status="success"}catch(e){r.status="error",r.value=e}return r}(t.exports=o).prototype.finally=function(t){if("function"!=typeof t)return this;var r=this.constructor;return this.then(function(e){return r.resolve(t()).then(function(){return e})},function(e){return r.resolve(t()).then(function(){throw e})})},o.prototype.catch=function(e){return this.then(null,e)},o.prototype.then=function(e,t){if("function"!=typeof e&&this.state===a||"function"!=typeof t&&this.state===s)return this;var r=new this.constructor(u);this.state!==n?f(r,this.state===a?e:t,this.outcome):this.queue.push(new h(r,e,t));return r},h.prototype.callFulfilled=function(e){l.resolve(this.promise,e)},h.prototype.otherCallFulfilled=function(e){f(this.promise,this.onFulfilled,e)},h.prototype.callRejected=function(e){l.reject(this.promise,e)},h.prototype.otherCallRejected=function(e){f(this.promise,this.onRejected,e)},l.resolve=function(e,t){var r=p(c,t);if("error"===r.status)return l.reject(e,r.value);var n=r.value;if(n)d(e,n);else{e.state=a,e.outcome=t;for(var i=-1,s=e.queue.length;++i<s;)e.queue[i].callFulfilled(t)}return e},l.reject=function(e,t){e.state=s,e.outcome=t;for(var r=-1,n=e.queue.length;++r<n;)e.queue[r].callRejected(t);return e},o.resolve=function(e){if(e instanceof this)return e;return l.resolve(new this(u),e)},o.reject=function(e){var t=new this(u);return l.reject(t,e)},o.all=function(e){var r=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,i=!1;if(!n)return this.resolve([]);var s=new Array(n),a=0,t=-1,o=new this(u);for(;++t<n;)h(e[t],t);return o;function h(e,t){r.resolve(e).then(function(e){s[t]=e,++a!==n||i||(i=!0,l.resolve(o,s))},function(e){i||(i=!0,l.reject(o,e))})}},o.race=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var r=e.length,n=!1;if(!r)return this.resolve([]);var i=-1,s=new this(u);for(;++i<r;)a=e[i],t.resolve(a).then(function(e){n||(n=!0,l.resolve(s,e))},function(e){n||(n=!0,l.reject(s,e))});var a;return s}},{immediate:36}],38:[function(e,t,r){"use strict";var n={};(0,e("./lib/utils/common").assign)(n,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),t.exports=n},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(e,t,r){"use strict";var a=e("./zlib/deflate"),o=e("./utils/common"),h=e("./utils/strings"),i=e("./zlib/messages"),s=e("./zlib/zstream"),u=Object.prototype.toString,l=0,f=-1,c=0,d=8;function p(e){if(!(this instanceof p))return new p(e);this.options=o.assign({level:f,method:d,chunkSize:16384,windowBits:15,memLevel:8,strategy:c,to:""},e||{});var t=this.options;t.raw&&0<t.windowBits?t.windowBits=-t.windowBits:t.gzip&&0<t.windowBits&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new s,this.strm.avail_out=0;var r=a.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==l)throw new Error(i[r]);if(t.header&&a.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n="string"==typeof t.dictionary?h.string2buf(t.dictionary):"[object ArrayBuffer]"===u.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=a.deflateSetDictionary(this.strm,n))!==l)throw new Error(i[r]);this._dict_set=!0}}function n(e,t){var r=new p(t);if(r.push(e,!0),r.err)throw r.msg||i[r.err];return r.result}p.prototype.push=function(e,t){var r,n,i=this.strm,s=this.options.chunkSize;if(this.ended)return!1;n=t===~~t?t:!0===t?4:0,"string"==typeof e?i.input=h.string2buf(e):"[object ArrayBuffer]"===u.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;do{if(0===i.avail_out&&(i.output=new o.Buf8(s),i.next_out=0,i.avail_out=s),1!==(r=a.deflate(i,n))&&r!==l)return this.onEnd(r),!(this.ended=!0);0!==i.avail_out&&(0!==i.avail_in||4!==n&&2!==n)||("string"===this.options.to?this.onData(h.buf2binstring(o.shrinkBuf(i.output,i.next_out))):this.onData(o.shrinkBuf(i.output,i.next_out)))}while((0<i.avail_in||0===i.avail_out)&&1!==r);return 4===n?(r=a.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===l):2!==n||(this.onEnd(l),!(i.avail_out=0))},p.prototype.onData=function(e){this.chunks.push(e)},p.prototype.onEnd=function(e){e===l&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},r.Deflate=p,r.deflate=n,r.deflateRaw=function(e,t){return(t=t||{}).raw=!0,n(e,t)},r.gzip=function(e,t){return(t=t||{}).gzip=!0,n(e,t)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(e,t,r){"use strict";var c=e("./zlib/inflate"),d=e("./utils/common"),p=e("./utils/strings"),m=e("./zlib/constants"),n=e("./zlib/messages"),i=e("./zlib/zstream"),s=e("./zlib/gzheader"),_=Object.prototype.toString;function a(e){if(!(this instanceof a))return new a(e);this.options=d.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&0<=t.windowBits&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(0<=t.windowBits&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),15<t.windowBits&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new i,this.strm.avail_out=0;var r=c.inflateInit2(this.strm,t.windowBits);if(r!==m.Z_OK)throw new Error(n[r]);this.header=new s,c.inflateGetHeader(this.strm,this.header)}function o(e,t){var r=new a(t);if(r.push(e,!0),r.err)throw r.msg||n[r.err];return r.result}a.prototype.push=function(e,t){var r,n,i,s,a,o,h=this.strm,u=this.options.chunkSize,l=this.options.dictionary,f=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?m.Z_FINISH:m.Z_NO_FLUSH,"string"==typeof e?h.input=p.binstring2buf(e):"[object ArrayBuffer]"===_.call(e)?h.input=new Uint8Array(e):h.input=e,h.next_in=0,h.avail_in=h.input.length;do{if(0===h.avail_out&&(h.output=new d.Buf8(u),h.next_out=0,h.avail_out=u),(r=c.inflate(h,m.Z_NO_FLUSH))===m.Z_NEED_DICT&&l&&(o="string"==typeof l?p.string2buf(l):"[object ArrayBuffer]"===_.call(l)?new Uint8Array(l):l,r=c.inflateSetDictionary(this.strm,o)),r===m.Z_BUF_ERROR&&!0===f&&(r=m.Z_OK,f=!1),r!==m.Z_STREAM_END&&r!==m.Z_OK)return this.onEnd(r),!(this.ended=!0);h.next_out&&(0!==h.avail_out&&r!==m.Z_STREAM_END&&(0!==h.avail_in||n!==m.Z_FINISH&&n!==m.Z_SYNC_FLUSH)||("string"===this.options.to?(i=p.utf8border(h.output,h.next_out),s=h.next_out-i,a=p.buf2string(h.output,i),h.next_out=s,h.avail_out=u-s,s&&d.arraySet(h.output,h.output,i,s,0),this.onData(a)):this.onData(d.shrinkBuf(h.output,h.next_out)))),0===h.avail_in&&0===h.avail_out&&(f=!0)}while((0<h.avail_in||0===h.avail_out)&&r!==m.Z_STREAM_END);return r===m.Z_STREAM_END&&(n=m.Z_FINISH),n===m.Z_FINISH?(r=c.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===m.Z_OK):n!==m.Z_SYNC_FLUSH||(this.onEnd(m.Z_OK),!(h.avail_out=0))},a.prototype.onData=function(e){this.chunks.push(e)},a.prototype.onEnd=function(e){e===m.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=d.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},r.Inflate=a,r.inflate=o,r.inflateRaw=function(e,t){return(t=t||{}).raw=!0,o(e,t)},r.ungzip=o},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(e,t,r){"use strict";var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;r.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])}}return e},r.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var i={arraySet:function(e,t,r,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+n),i);else for(var s=0;s<n;s++)e[i+s]=t[r+s]},flattenChunks:function(e){var t,r,n,i,s,a;for(t=n=0,r=e.length;t<r;t++)n+=e[t].length;for(a=new Uint8Array(n),t=i=0,r=e.length;t<r;t++)s=e[t],a.set(s,i),i+=s.length;return a}},s={arraySet:function(e,t,r,n,i){for(var s=0;s<n;s++)e[i+s]=t[r+s]},flattenChunks:function(e){return[].concat.apply([],e)}};r.setTyped=function(e){e?(r.Buf8=Uint8Array,r.Buf16=Uint16Array,r.Buf32=Int32Array,r.assign(r,i)):(r.Buf8=Array,r.Buf16=Array,r.Buf32=Array,r.assign(r,s))},r.setTyped(n)},{}],42:[function(e,t,r){"use strict";var h=e("./common"),i=!0,s=!0;try{String.fromCharCode.apply(null,[0])}catch(e){i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){s=!1}for(var u=new h.Buf8(256),n=0;n<256;n++)u[n]=252<=n?6:248<=n?5:240<=n?4:224<=n?3:192<=n?2:1;function l(e,t){if(t<65537&&(e.subarray&&s||!e.subarray&&i))return String.fromCharCode.apply(null,h.shrinkBuf(e,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}u[254]=u[254]=1,r.string2buf=function(e){var t,r,n,i,s,a=e.length,o=0;for(i=0;i<a;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),o+=r<128?1:r<2048?2:r<65536?3:4;for(t=new h.Buf8(o),i=s=0;s<o;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),r<128?t[s++]=r:(r<2048?t[s++]=192|r>>>6:(r<65536?t[s++]=224|r>>>12:(t[s++]=240|r>>>18,t[s++]=128|r>>>12&63),t[s++]=128|r>>>6&63),t[s++]=128|63&r);return t},r.buf2binstring=function(e){return l(e,e.length)},r.binstring2buf=function(e){for(var t=new h.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},r.buf2string=function(e,t){var r,n,i,s,a=t||e.length,o=new Array(2*a);for(r=n=0;r<a;)if((i=e[r++])<128)o[n++]=i;else if(4<(s=u[i]))o[n++]=65533,r+=s-1;else{for(i&=2===s?31:3===s?15:7;1<s&&r<a;)i=i<<6|63&e[r++],s--;1<s?o[n++]=65533:i<65536?o[n++]=i:(i-=65536,o[n++]=55296|i>>10&1023,o[n++]=56320|1023&i)}return l(o,n)},r.utf8border=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;0<=r&&128==(192&e[r]);)r--;return r<0?t:0===r?t:r+u[e[r]]>t?r:t}},{"./common":41}],43:[function(e,t,r){"use strict";t.exports=function(e,t,r,n){for(var i=65535&e|0,s=e>>>16&65535|0,a=0;0!==r;){for(r-=a=2e3<r?2e3:r;s=s+(i=i+t[n++]|0)|0,--a;);i%=65521,s%=65521}return i|s<<16|0}},{}],44:[function(e,t,r){"use strict";t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(e,t,r){"use strict";var o=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();t.exports=function(e,t,r,n){var i=o,s=n+r;e^=-1;for(var a=n;a<s;a++)e=e>>>8^i[255&(e^t[a])];return-1^e}},{}],46:[function(e,t,r){"use strict";var h,c=e("../utils/common"),u=e("./trees"),d=e("./adler32"),p=e("./crc32"),n=e("./messages"),l=0,f=4,m=0,_=-2,g=-1,b=4,i=2,v=8,y=9,s=286,a=30,o=19,w=2*s+1,k=15,x=3,S=258,z=S+x+1,C=42,E=113,A=1,I=2,O=3,B=4;function R(e,t){return e.msg=n[t],t}function T(e){return(e<<1)-(4<e?9:0)}function D(e){for(var t=e.length;0<=--t;)e[t]=0}function F(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(c.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function N(e,t){u._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,F(e.strm)}function U(e,t){e.pending_buf[e.pending++]=t}function P(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function L(e,t){var r,n,i=e.max_chain_length,s=e.strstart,a=e.prev_length,o=e.nice_match,h=e.strstart>e.w_size-z?e.strstart-(e.w_size-z):0,u=e.window,l=e.w_mask,f=e.prev,c=e.strstart+S,d=u[s+a-1],p=u[s+a];e.prev_length>=e.good_match&&(i>>=2),o>e.lookahead&&(o=e.lookahead);do{if(u[(r=t)+a]===p&&u[r+a-1]===d&&u[r]===u[s]&&u[++r]===u[s+1]){s+=2,r++;do{}while(u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&s<c);if(n=S-(c-s),s=c-S,a<n){if(e.match_start=t,o<=(a=n))break;d=u[s+a-1],p=u[s+a]}}}while((t=f[t&l])>h&&0!=--i);return a<=e.lookahead?a:e.lookahead}function j(e){var t,r,n,i,s,a,o,h,u,l,f=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=f+(f-z)){for(c.arraySet(e.window,e.window,f,f,0),e.match_start-=f,e.strstart-=f,e.block_start-=f,t=r=e.hash_size;n=e.head[--t],e.head[t]=f<=n?n-f:0,--r;);for(t=r=f;n=e.prev[--t],e.prev[t]=f<=n?n-f:0,--r;);i+=f}if(0===e.strm.avail_in)break;if(a=e.strm,o=e.window,h=e.strstart+e.lookahead,u=i,l=void 0,l=a.avail_in,u<l&&(l=u),r=0===l?0:(a.avail_in-=l,c.arraySet(o,a.input,a.next_in,l,h),1===a.state.wrap?a.adler=d(a.adler,o,l,h):2===a.state.wrap&&(a.adler=p(a.adler,o,l,h)),a.next_in+=l,a.total_in+=l,l),e.lookahead+=r,e.lookahead+e.insert>=x)for(s=e.strstart-e.insert,e.ins_h=e.window[s],e.ins_h=(e.ins_h<<e.hash_shift^e.window[s+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[s+x-1])&e.hash_mask,e.prev[s&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=s,s++,e.insert--,!(e.lookahead+e.insert<x)););}while(e.lookahead<z&&0!==e.strm.avail_in)}function Z(e,t){for(var r,n;;){if(e.lookahead<z){if(j(e),e.lookahead<z&&t===l)return A;if(0===e.lookahead)break}if(r=0,e.lookahead>=x&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+x-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-z&&(e.match_length=L(e,r)),e.match_length>=x)if(n=u._tr_tally(e,e.strstart-e.match_start,e.match_length-x),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=x){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+x-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart,0!=--e.match_length;);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else n=u._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(N(e,!1),0===e.strm.avail_out))return A}return e.insert=e.strstart<x-1?e.strstart:x-1,t===f?(N(e,!0),0===e.strm.avail_out?O:B):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?A:I}function W(e,t){for(var r,n,i;;){if(e.lookahead<z){if(j(e),e.lookahead<z&&t===l)return A;if(0===e.lookahead)break}if(r=0,e.lookahead>=x&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+x-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=x-1,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-z&&(e.match_length=L(e,r),e.match_length<=5&&(1===e.strategy||e.match_length===x&&4096<e.strstart-e.match_start)&&(e.match_length=x-1)),e.prev_length>=x&&e.match_length<=e.prev_length){for(i=e.strstart+e.lookahead-x,n=u._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-x),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+x-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!=--e.prev_length;);if(e.match_available=0,e.match_length=x-1,e.strstart++,n&&(N(e,!1),0===e.strm.avail_out))return A}else if(e.match_available){if((n=u._tr_tally(e,0,e.window[e.strstart-1]))&&N(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return A}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=u._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<x-1?e.strstart:x-1,t===f?(N(e,!0),0===e.strm.avail_out?O:B):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?A:I}function M(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}function H(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=v,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new c.Buf16(2*w),this.dyn_dtree=new c.Buf16(2*(2*a+1)),this.bl_tree=new c.Buf16(2*(2*o+1)),D(this.dyn_ltree),D(this.dyn_dtree),D(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new c.Buf16(k+1),this.heap=new c.Buf16(2*s+1),D(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new c.Buf16(2*s+1),D(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function G(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=i,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?C:E,e.adler=2===t.wrap?0:1,t.last_flush=l,u._tr_init(t),m):R(e,_)}function K(e){var t=G(e);return t===m&&function(e){e.window_size=2*e.w_size,D(e.head),e.max_lazy_match=h[e.level].max_lazy,e.good_match=h[e.level].good_length,e.nice_match=h[e.level].nice_length,e.max_chain_length=h[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=x-1,e.match_available=0,e.ins_h=0}(e.state),t}function Y(e,t,r,n,i,s){if(!e)return _;var a=1;if(t===g&&(t=6),n<0?(a=0,n=-n):15<n&&(a=2,n-=16),i<1||y<i||r!==v||n<8||15<n||t<0||9<t||s<0||b<s)return R(e,_);8===n&&(n=9);var o=new H;return(e.state=o).strm=e,o.wrap=a,o.gzhead=null,o.w_bits=n,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=i+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+x-1)/x),o.window=new c.Buf8(2*o.w_size),o.head=new c.Buf16(o.hash_size),o.prev=new c.Buf16(o.w_size),o.lit_bufsize=1<<i+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new c.Buf8(o.pending_buf_size),o.d_buf=1*o.lit_bufsize,o.l_buf=3*o.lit_bufsize,o.level=t,o.strategy=s,o.method=r,K(e)}h=[new M(0,0,0,0,function(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(j(e),0===e.lookahead&&t===l)return A;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,N(e,!1),0===e.strm.avail_out))return A;if(e.strstart-e.block_start>=e.w_size-z&&(N(e,!1),0===e.strm.avail_out))return A}return e.insert=0,t===f?(N(e,!0),0===e.strm.avail_out?O:B):(e.strstart>e.block_start&&(N(e,!1),e.strm.avail_out),A)}),new M(4,4,8,4,Z),new M(4,5,16,8,Z),new M(4,6,32,32,Z),new M(4,4,16,16,W),new M(8,16,32,32,W),new M(8,16,128,128,W),new M(8,32,128,256,W),new M(32,128,258,1024,W),new M(32,258,258,4096,W)],r.deflateInit=function(e,t){return Y(e,t,v,15,8,0)},r.deflateInit2=Y,r.deflateReset=K,r.deflateResetKeep=G,r.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?_:(e.state.gzhead=t,m):_},r.deflate=function(e,t){var r,n,i,s;if(!e||!e.state||5<t||t<0)return e?R(e,_):_;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||666===n.status&&t!==f)return R(e,0===e.avail_out?-5:_);if(n.strm=e,r=n.last_flush,n.last_flush=t,n.status===C)if(2===n.wrap)e.adler=0,U(n,31),U(n,139),U(n,8),n.gzhead?(U(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),U(n,255&n.gzhead.time),U(n,n.gzhead.time>>8&255),U(n,n.gzhead.time>>16&255),U(n,n.gzhead.time>>24&255),U(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),U(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(U(n,255&n.gzhead.extra.length),U(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=p(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(U(n,0),U(n,0),U(n,0),U(n,0),U(n,0),U(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),U(n,3),n.status=E);else{var a=v+(n.w_bits-8<<4)<<8;a|=(2<=n.strategy||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(a|=32),a+=31-a%31,n.status=E,P(n,a),0!==n.strstart&&(P(n,e.adler>>>16),P(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),F(e),i=n.pending,n.pending!==n.pending_buf_size));)U(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),F(e),i=n.pending,n.pending===n.pending_buf_size)){s=1;break}s=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,U(n,s)}while(0!==s);n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),0===s&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),F(e),i=n.pending,n.pending===n.pending_buf_size)){s=1;break}s=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,U(n,s)}while(0!==s);n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),0===s&&(n.status=103)}else n.status=103;if(103===n.status&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&F(e),n.pending+2<=n.pending_buf_size&&(U(n,255&e.adler),U(n,e.adler>>8&255),e.adler=0,n.status=E)):n.status=E),0!==n.pending){if(F(e),0===e.avail_out)return n.last_flush=-1,m}else if(0===e.avail_in&&T(t)<=T(r)&&t!==f)return R(e,-5);if(666===n.status&&0!==e.avail_in)return R(e,-5);if(0!==e.avail_in||0!==n.lookahead||t!==l&&666!==n.status){var o=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(j(e),0===e.lookahead)){if(t===l)return A;break}if(e.match_length=0,r=u._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(N(e,!1),0===e.strm.avail_out))return A}return e.insert=0,t===f?(N(e,!0),0===e.strm.avail_out?O:B):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?A:I}(n,t):3===n.strategy?function(e,t){for(var r,n,i,s,a=e.window;;){if(e.lookahead<=S){if(j(e),e.lookahead<=S&&t===l)return A;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=x&&0<e.strstart&&(n=a[i=e.strstart-1])===a[++i]&&n===a[++i]&&n===a[++i]){s=e.strstart+S;do{}while(n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&i<s);e.match_length=S-(s-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=x?(r=u._tr_tally(e,1,e.match_length-x),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=u._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(N(e,!1),0===e.strm.avail_out))return A}return e.insert=0,t===f?(N(e,!0),0===e.strm.avail_out?O:B):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?A:I}(n,t):h[n.level].func(n,t);if(o!==O&&o!==B||(n.status=666),o===A||o===O)return 0===e.avail_out&&(n.last_flush=-1),m;if(o===I&&(1===t?u._tr_align(n):5!==t&&(u._tr_stored_block(n,0,0,!1),3===t&&(D(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),F(e),0===e.avail_out))return n.last_flush=-1,m}return t!==f?m:n.wrap<=0?1:(2===n.wrap?(U(n,255&e.adler),U(n,e.adler>>8&255),U(n,e.adler>>16&255),U(n,e.adler>>24&255),U(n,255&e.total_in),U(n,e.total_in>>8&255),U(n,e.total_in>>16&255),U(n,e.total_in>>24&255)):(P(n,e.adler>>>16),P(n,65535&e.adler)),F(e),0<n.wrap&&(n.wrap=-n.wrap),0!==n.pending?m:1)},r.deflateEnd=function(e){var t;return e&&e.state?(t=e.state.status)!==C&&69!==t&&73!==t&&91!==t&&103!==t&&t!==E&&666!==t?R(e,_):(e.state=null,t===E?R(e,-3):m):_},r.deflateSetDictionary=function(e,t){var r,n,i,s,a,o,h,u,l=t.length;if(!e||!e.state)return _;if(2===(s=(r=e.state).wrap)||1===s&&r.status!==C||r.lookahead)return _;for(1===s&&(e.adler=d(e.adler,t,l,0)),r.wrap=0,l>=r.w_size&&(0===s&&(D(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new c.Buf8(r.w_size),c.arraySet(u,t,l-r.w_size,r.w_size,0),t=u,l=r.w_size),a=e.avail_in,o=e.next_in,h=e.input,e.avail_in=l,e.next_in=0,e.input=t,j(r);r.lookahead>=x;){for(n=r.strstart,i=r.lookahead-(x-1);r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+x-1])&r.hash_mask,r.prev[n&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=n,n++,--i;);r.strstart=n,r.lookahead=x-1,j(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=x-1,r.match_available=0,e.next_in=o,e.input=h,e.avail_in=a,r.wrap=s,m},r.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(e,t,r){"use strict";t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(e,t,r){"use strict";t.exports=function(e,t){var r,n,i,s,a,o,h,u,l,f,c,d,p,m,_,g,b,v,y,w,k,x,S,z,C;r=e.state,n=e.next_in,z=e.input,i=n+(e.avail_in-5),s=e.next_out,C=e.output,a=s-(t-e.avail_out),o=s+(e.avail_out-257),h=r.dmax,u=r.wsize,l=r.whave,f=r.wnext,c=r.window,d=r.hold,p=r.bits,m=r.lencode,_=r.distcode,g=(1<<r.lenbits)-1,b=(1<<r.distbits)-1;e:do{p<15&&(d+=z[n++]<<p,p+=8,d+=z[n++]<<p,p+=8),v=m[d&g];t:for(;;){if(d>>>=y=v>>>24,p-=y,0===(y=v>>>16&255))C[s++]=65535&v;else{if(!(16&y)){if(0==(64&y)){v=m[(65535&v)+(d&(1<<y)-1)];continue t}if(32&y){r.mode=12;break e}e.msg="invalid literal/length code",r.mode=30;break e}w=65535&v,(y&=15)&&(p<y&&(d+=z[n++]<<p,p+=8),w+=d&(1<<y)-1,d>>>=y,p-=y),p<15&&(d+=z[n++]<<p,p+=8,d+=z[n++]<<p,p+=8),v=_[d&b];r:for(;;){if(d>>>=y=v>>>24,p-=y,!(16&(y=v>>>16&255))){if(0==(64&y)){v=_[(65535&v)+(d&(1<<y)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(k=65535&v,p<(y&=15)&&(d+=z[n++]<<p,(p+=8)<y&&(d+=z[n++]<<p,p+=8)),h<(k+=d&(1<<y)-1)){e.msg="invalid distance too far back",r.mode=30;break e}if(d>>>=y,p-=y,(y=s-a)<k){if(l<(y=k-y)&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(S=c,(x=0)===f){if(x+=u-y,y<w){for(w-=y;C[s++]=c[x++],--y;);x=s-k,S=C}}else if(f<y){if(x+=u+f-y,(y-=f)<w){for(w-=y;C[s++]=c[x++],--y;);if(x=0,f<w){for(w-=y=f;C[s++]=c[x++],--y;);x=s-k,S=C}}}else if(x+=f-y,y<w){for(w-=y;C[s++]=c[x++],--y;);x=s-k,S=C}for(;2<w;)C[s++]=S[x++],C[s++]=S[x++],C[s++]=S[x++],w-=3;w&&(C[s++]=S[x++],1<w&&(C[s++]=S[x++]))}else{for(x=s-k;C[s++]=C[x++],C[s++]=C[x++],C[s++]=C[x++],2<(w-=3););w&&(C[s++]=C[x++],1<w&&(C[s++]=C[x++]))}break}}break}}while(n<i&&s<o);n-=w=p>>3,d&=(1<<(p-=w<<3))-1,e.next_in=n,e.next_out=s,e.avail_in=n<i?i-n+5:5-(n-i),e.avail_out=s<o?o-s+257:257-(s-o),r.hold=d,r.bits=p}},{}],49:[function(e,t,r){"use strict";var I=e("../utils/common"),O=e("./adler32"),B=e("./crc32"),R=e("./inffast"),T=e("./inftrees"),D=1,F=2,N=0,U=-2,P=1,n=852,i=592;function L(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function s(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new I.Buf16(320),this.work=new I.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function a(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=P,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new I.Buf32(n),t.distcode=t.distdyn=new I.Buf32(i),t.sane=1,t.back=-1,N):U}function o(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,a(e)):U}function h(e,t){var r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15<t)?U:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,o(e))):U}function u(e,t){var r,n;return e?(n=new s,(e.state=n).window=null,(r=h(e,t))!==N&&(e.state=null),r):U}var l,f,c=!0;function j(e){if(c){var t;for(l=new I.Buf32(512),f=new I.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(T(D,e.lens,0,288,l,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;T(F,e.lens,0,32,f,0,e.work,{bits:5}),c=!1}e.lencode=l,e.lenbits=9,e.distcode=f,e.distbits=5}function Z(e,t,r,n){var i,s=e.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new I.Buf8(s.wsize)),n>=s.wsize?(I.arraySet(s.window,t,r-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):(n<(i=s.wsize-s.wnext)&&(i=n),I.arraySet(s.window,t,r-n,i,s.wnext),(n-=i)?(I.arraySet(s.window,t,r-n,n,0),s.wnext=n,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=i))),0}r.inflateReset=o,r.inflateReset2=h,r.inflateResetKeep=a,r.inflateInit=function(e){return u(e,15)},r.inflateInit2=u,r.inflate=function(e,t){var r,n,i,s,a,o,h,u,l,f,c,d,p,m,_,g,b,v,y,w,k,x,S,z,C=0,E=new I.Buf8(4),A=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return U;12===(r=e.state).mode&&(r.mode=13),a=e.next_out,i=e.output,h=e.avail_out,s=e.next_in,n=e.input,o=e.avail_in,u=r.hold,l=r.bits,f=o,c=h,x=N;e:for(;;)switch(r.mode){case P:if(0===r.wrap){r.mode=13;break}for(;l<16;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(2&r.wrap&&35615===u){E[r.check=0]=255&u,E[1]=u>>>8&255,r.check=B(r.check,E,2,0),l=u=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=30;break}if(8!=(15&u)){e.msg="unknown compression method",r.mode=30;break}if(l-=4,k=8+(15&(u>>>=4)),0===r.wbits)r.wbits=k;else if(k>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<<k,e.adler=r.check=1,r.mode=512&u?10:12,l=u=0;break;case 2:for(;l<16;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(r.flags=u,8!=(255&r.flags)){e.msg="unknown compression method",r.mode=30;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=30;break}r.head&&(r.head.text=u>>8&1),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,r.check=B(r.check,E,2,0)),l=u=0,r.mode=3;case 3:for(;l<32;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}r.head&&(r.head.time=u),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,E[2]=u>>>16&255,E[3]=u>>>24&255,r.check=B(r.check,E,4,0)),l=u=0,r.mode=4;case 4:for(;l<16;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}r.head&&(r.head.xflags=255&u,r.head.os=u>>8),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,r.check=B(r.check,E,2,0)),l=u=0,r.mode=5;case 5:if(1024&r.flags){for(;l<16;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}r.length=u,r.head&&(r.head.extra_len=u),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,r.check=B(r.check,E,2,0)),l=u=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&(o<(d=r.length)&&(d=o),d&&(r.head&&(k=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),I.arraySet(r.head.extra,n,s,d,k)),512&r.flags&&(r.check=B(r.check,n,d,s)),o-=d,s+=d,r.length-=d),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===o)break e;for(d=0;k=n[s+d++],r.head&&k&&r.length<65536&&(r.head.name+=String.fromCharCode(k)),k&&d<o;);if(512&r.flags&&(r.check=B(r.check,n,d,s)),o-=d,s+=d,k)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===o)break e;for(d=0;k=n[s+d++],r.head&&k&&r.length<65536&&(r.head.comment+=String.fromCharCode(k)),k&&d<o;);if(512&r.flags&&(r.check=B(r.check,n,d,s)),o-=d,s+=d,k)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;l<16;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(u!==(65535&r.check)){e.msg="header crc mismatch",r.mode=30;break}l=u=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;l<32;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}e.adler=r.check=L(u),l=u=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=a,e.avail_out=h,e.next_in=s,e.avail_in=o,r.hold=u,r.bits=l,2;e.adler=r.check=1,r.mode=12;case 12:if(5===t||6===t)break e;case 13:if(r.last){u>>>=7&l,l-=7&l,r.mode=27;break}for(;l<3;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}switch(r.last=1&u,l-=1,3&(u>>>=1)){case 0:r.mode=14;break;case 1:if(j(r),r.mode=20,6!==t)break;u>>>=2,l-=2;break e;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30}u>>>=2,l-=2;break;case 14:for(u>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&u,l=u=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(d=r.length){if(o<d&&(d=o),h<d&&(d=h),0===d)break e;I.arraySet(i,n,s,d,a),o-=d,s+=d,h-=d,a+=d,r.length-=d;break}r.mode=12;break;case 17:for(;l<14;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(r.nlen=257+(31&u),u>>>=5,l-=5,r.ndist=1+(31&u),u>>>=5,l-=5,r.ncode=4+(15&u),u>>>=4,l-=4,286<r.nlen||30<r.ndist){e.msg="too many length or distance symbols",r.mode=30;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;l<3;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}r.lens[A[r.have++]]=7&u,u>>>=3,l-=3}for(;r.have<19;)r.lens[A[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,S={bits:r.lenbits},x=T(0,r.lens,0,19,r.lencode,0,r.work,S),r.lenbits=S.bits,x){e.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;g=(C=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(b<16)u>>>=_,l-=_,r.lens[r.have++]=b;else{if(16===b){for(z=_+2;l<z;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(u>>>=_,l-=_,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}k=r.lens[r.have-1],d=3+(3&u),u>>>=2,l-=2}else if(17===b){for(z=_+3;l<z;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}l-=_,k=0,d=3+(7&(u>>>=_)),u>>>=3,l-=3}else{for(z=_+7;l<z;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}l-=_,k=0,d=11+(127&(u>>>=_)),u>>>=7,l-=7}if(r.have+d>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;d--;)r.lens[r.have++]=k}}if(30===r.mode)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,S={bits:r.lenbits},x=T(D,r.lens,0,r.nlen,r.lencode,0,r.work,S),r.lenbits=S.bits,x){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,S={bits:r.distbits},x=T(F,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,S),r.distbits=S.bits,x){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(6<=o&&258<=h){e.next_out=a,e.avail_out=h,e.next_in=s,e.avail_in=o,r.hold=u,r.bits=l,R(e,c),a=e.next_out,i=e.output,h=e.avail_out,s=e.next_in,n=e.input,o=e.avail_in,u=r.hold,l=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;g=(C=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(g&&0==(240&g)){for(v=_,y=g,w=b;g=(C=r.lencode[w+((u&(1<<v+y)-1)>>v)])>>>16&255,b=65535&C,!(v+(_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}u>>>=v,l-=v,r.back+=v}if(u>>>=_,l-=_,r.back+=_,r.length=b,0===g){r.mode=26;break}if(32&g){r.back=-1,r.mode=12;break}if(64&g){e.msg="invalid literal/length code",r.mode=30;break}r.extra=15&g,r.mode=22;case 22:if(r.extra){for(z=r.extra;l<z;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;g=(C=r.distcode[u&(1<<r.distbits)-1])>>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(0==(240&g)){for(v=_,y=g,w=b;g=(C=r.distcode[w+((u&(1<<v+y)-1)>>v)])>>>16&255,b=65535&C,!(v+(_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}u>>>=v,l-=v,r.back+=v}if(u>>>=_,l-=_,r.back+=_,64&g){e.msg="invalid distance code",r.mode=30;break}r.offset=b,r.extra=15&g,r.mode=24;case 24:if(r.extra){for(z=r.extra;l<z;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===h)break e;if(d=c-h,r.offset>d){if((d=r.offset-d)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}p=d>r.wnext?(d-=r.wnext,r.wsize-d):r.wnext-d,d>r.length&&(d=r.length),m=r.window}else m=i,p=a-r.offset,d=r.length;for(h<d&&(d=h),h-=d,r.length-=d;i[a++]=m[p++],--d;);0===r.length&&(r.mode=21);break;case 26:if(0===h)break e;i[a++]=r.length,h--,r.mode=21;break;case 27:if(r.wrap){for(;l<32;){if(0===o)break e;o--,u|=n[s++]<<l,l+=8}if(c-=h,e.total_out+=c,r.total+=c,c&&(e.adler=r.check=r.flags?B(r.check,i,c,a-c):O(r.check,i,c,a-c)),c=h,(r.flags?u:L(u))!==r.check){e.msg="incorrect data check",r.mode=30;break}l=u=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;l<32;){if(0===o)break e;o--,u+=n[s++]<<l,l+=8}if(u!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=30;break}l=u=0}r.mode=29;case 29:x=1;break e;case 30:x=-3;break e;case 31:return-4;case 32:default:return U}return e.next_out=a,e.avail_out=h,e.next_in=s,e.avail_in=o,r.hold=u,r.bits=l,(r.wsize||c!==e.avail_out&&r.mode<30&&(r.mode<27||4!==t))&&Z(e,e.output,e.next_out,c-e.avail_out)?(r.mode=31,-4):(f-=e.avail_in,c-=e.avail_out,e.total_in+=f,e.total_out+=c,r.total+=c,r.wrap&&c&&(e.adler=r.check=r.flags?B(r.check,i,c,e.next_out-c):O(r.check,i,c,e.next_out-c)),e.data_type=r.bits+(r.last?64:0)+(12===r.mode?128:0)+(20===r.mode||15===r.mode?256:0),(0==f&&0===c||4===t)&&x===N&&(x=-5),x)},r.inflateEnd=function(e){if(!e||!e.state)return U;var t=e.state;return t.window&&(t.window=null),e.state=null,N},r.inflateGetHeader=function(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?U:((r.head=t).done=!1,N):U},r.inflateSetDictionary=function(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?U:11===r.mode&&O(1,t,n,0)!==r.check?-3:Z(e,t,n,n)?(r.mode=31,-4):(r.havedict=1,N):U},r.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,t,r){"use strict";var D=e("../utils/common"),F=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],N=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],U=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],P=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(e,t,r,n,i,s,a,o){var h,u,l,f,c,d,p,m,_,g=o.bits,b=0,v=0,y=0,w=0,k=0,x=0,S=0,z=0,C=0,E=0,A=null,I=0,O=new D.Buf16(16),B=new D.Buf16(16),R=null,T=0;for(b=0;b<=15;b++)O[b]=0;for(v=0;v<n;v++)O[t[r+v]]++;for(k=g,w=15;1<=w&&0===O[w];w--);if(w<k&&(k=w),0===w)return i[s++]=20971520,i[s++]=20971520,o.bits=1,0;for(y=1;y<w&&0===O[y];y++);for(k<y&&(k=y),b=z=1;b<=15;b++)if(z<<=1,(z-=O[b])<0)return-1;if(0<z&&(0===e||1!==w))return-1;for(B[1]=0,b=1;b<15;b++)B[b+1]=B[b]+O[b];for(v=0;v<n;v++)0!==t[r+v]&&(a[B[t[r+v]]++]=v);if(d=0===e?(A=R=a,19):1===e?(A=F,I-=257,R=N,T-=257,256):(A=U,R=P,-1),b=y,c=s,S=v=E=0,l=-1,f=(C=1<<(x=k))-1,1===e&&852<C||2===e&&592<C)return 1;for(;;){for(p=b-S,_=a[v]<d?(m=0,a[v]):a[v]>d?(m=R[T+a[v]],A[I+a[v]]):(m=96,0),h=1<<b-S,y=u=1<<x;i[c+(E>>S)+(u-=h)]=p<<24|m<<16|_|0,0!==u;);for(h=1<<b-1;E&h;)h>>=1;if(0!==h?(E&=h-1,E+=h):E=0,v++,0==--O[b]){if(b===w)break;b=t[r+a[v]]}if(k<b&&(E&f)!==l){for(0===S&&(S=k),c+=y,z=1<<(x=b-S);x+S<w&&!((z-=O[x+S])<=0);)x++,z<<=1;if(C+=1<<x,1===e&&852<C||2===e&&592<C)return 1;i[l=E&f]=k<<24|x<<16|c-s|0}}return 0!==E&&(i[c+E]=b-S<<24|64<<16|0),o.bits=k,0}},{"../utils/common":41}],51:[function(e,t,r){"use strict";t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(e,t,r){"use strict";var i=e("../utils/common"),o=0,h=1;function n(e){for(var t=e.length;0<=--t;)e[t]=0}var s=0,a=29,u=256,l=u+1+a,f=30,c=19,_=2*l+1,g=15,d=16,p=7,m=256,b=16,v=17,y=18,w=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],k=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],x=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],S=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],z=new Array(2*(l+2));n(z);var C=new Array(2*f);n(C);var E=new Array(512);n(E);var A=new Array(256);n(A);var I=new Array(a);n(I);var O,B,R,T=new Array(f);function D(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function F(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function N(e){return e<256?E[e]:E[256+(e>>>7)]}function U(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function P(e,t,r){e.bi_valid>d-r?(e.bi_buf|=t<<e.bi_valid&65535,U(e,e.bi_buf),e.bi_buf=t>>d-e.bi_valid,e.bi_valid+=r-d):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function L(e,t,r){P(e,r[2*t],r[2*t+1])}function j(e,t){for(var r=0;r|=1&e,e>>>=1,r<<=1,0<--t;);return r>>>1}function Z(e,t,r){var n,i,s=new Array(g+1),a=0;for(n=1;n<=g;n++)s[n]=a=a+r[n-1]<<1;for(i=0;i<=t;i++){var o=e[2*i+1];0!==o&&(e[2*i]=j(s[o]++,o))}}function W(e){var t;for(t=0;t<l;t++)e.dyn_ltree[2*t]=0;for(t=0;t<f;t++)e.dyn_dtree[2*t]=0;for(t=0;t<c;t++)e.bl_tree[2*t]=0;e.dyn_ltree[2*m]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function M(e){8<e.bi_valid?U(e,e.bi_buf):0<e.bi_valid&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function H(e,t,r,n){var i=2*t,s=2*r;return e[i]<e[s]||e[i]===e[s]&&n[t]<=n[r]}function G(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&H(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!H(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function K(e,t,r){var n,i,s,a,o=0;if(0!==e.last_lit)for(;n=e.pending_buf[e.d_buf+2*o]<<8|e.pending_buf[e.d_buf+2*o+1],i=e.pending_buf[e.l_buf+o],o++,0===n?L(e,i,t):(L(e,(s=A[i])+u+1,t),0!==(a=w[s])&&P(e,i-=I[s],a),L(e,s=N(--n),r),0!==(a=k[s])&&P(e,n-=T[s],a)),o<e.last_lit;);L(e,m,t)}function Y(e,t){var r,n,i,s=t.dyn_tree,a=t.stat_desc.static_tree,o=t.stat_desc.has_stree,h=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=_,r=0;r<h;r++)0!==s[2*r]?(e.heap[++e.heap_len]=u=r,e.depth[r]=0):s[2*r+1]=0;for(;e.heap_len<2;)s[2*(i=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[i]=0,e.opt_len--,o&&(e.static_len-=a[2*i+1]);for(t.max_code=u,r=e.heap_len>>1;1<=r;r--)G(e,s,r);for(i=h;r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],G(e,s,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,s[2*i]=s[2*r]+s[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,s[2*r+1]=s[2*n+1]=i,e.heap[1]=i++,G(e,s,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,s,a,o,h=t.dyn_tree,u=t.max_code,l=t.stat_desc.static_tree,f=t.stat_desc.has_stree,c=t.stat_desc.extra_bits,d=t.stat_desc.extra_base,p=t.stat_desc.max_length,m=0;for(s=0;s<=g;s++)e.bl_count[s]=0;for(h[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<_;r++)p<(s=h[2*h[2*(n=e.heap[r])+1]+1]+1)&&(s=p,m++),h[2*n+1]=s,u<n||(e.bl_count[s]++,a=0,d<=n&&(a=c[n-d]),o=h[2*n],e.opt_len+=o*(s+a),f&&(e.static_len+=o*(l[2*n+1]+a)));if(0!==m){do{for(s=p-1;0===e.bl_count[s];)s--;e.bl_count[s]--,e.bl_count[s+1]+=2,e.bl_count[p]--,m-=2}while(0<m);for(s=p;0!==s;s--)for(n=e.bl_count[s];0!==n;)u<(i=e.heap[--r])||(h[2*i+1]!==s&&(e.opt_len+=(s-h[2*i+1])*h[2*i],h[2*i+1]=s),n--)}}(e,t),Z(s,u,e.bl_count)}function X(e,t,r){var n,i,s=-1,a=t[1],o=0,h=7,u=4;for(0===a&&(h=138,u=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=a,a=t[2*(n+1)+1],++o<h&&i===a||(o<u?e.bl_tree[2*i]+=o:0!==i?(i!==s&&e.bl_tree[2*i]++,e.bl_tree[2*b]++):o<=10?e.bl_tree[2*v]++:e.bl_tree[2*y]++,s=i,u=(o=0)===a?(h=138,3):i===a?(h=6,3):(h=7,4))}function V(e,t,r){var n,i,s=-1,a=t[1],o=0,h=7,u=4;for(0===a&&(h=138,u=3),n=0;n<=r;n++)if(i=a,a=t[2*(n+1)+1],!(++o<h&&i===a)){if(o<u)for(;L(e,i,e.bl_tree),0!=--o;);else 0!==i?(i!==s&&(L(e,i,e.bl_tree),o--),L(e,b,e.bl_tree),P(e,o-3,2)):o<=10?(L(e,v,e.bl_tree),P(e,o-3,3)):(L(e,y,e.bl_tree),P(e,o-11,7));s=i,u=(o=0)===a?(h=138,3):i===a?(h=6,3):(h=7,4)}}n(T);var q=!1;function J(e,t,r,n){P(e,(s<<1)+(n?1:0),3),function(e,t,r,n){M(e),n&&(U(e,r),U(e,~r)),i.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}(e,t,r,!0)}r._tr_init=function(e){q||(function(){var e,t,r,n,i,s=new Array(g+1);for(n=r=0;n<a-1;n++)for(I[n]=r,e=0;e<1<<w[n];e++)A[r++]=n;for(A[r-1]=n,n=i=0;n<16;n++)for(T[n]=i,e=0;e<1<<k[n];e++)E[i++]=n;for(i>>=7;n<f;n++)for(T[n]=i<<7,e=0;e<1<<k[n]-7;e++)E[256+i++]=n;for(t=0;t<=g;t++)s[t]=0;for(e=0;e<=143;)z[2*e+1]=8,e++,s[8]++;for(;e<=255;)z[2*e+1]=9,e++,s[9]++;for(;e<=279;)z[2*e+1]=7,e++,s[7]++;for(;e<=287;)z[2*e+1]=8,e++,s[8]++;for(Z(z,l+1,s),e=0;e<f;e++)C[2*e+1]=5,C[2*e]=j(e,5);O=new D(z,w,u+1,l,g),B=new D(C,k,0,f,g),R=new D(new Array(0),x,0,c,p)}(),q=!0),e.l_desc=new F(e.dyn_ltree,O),e.d_desc=new F(e.dyn_dtree,B),e.bl_desc=new F(e.bl_tree,R),e.bi_buf=0,e.bi_valid=0,W(e)},r._tr_stored_block=J,r._tr_flush_block=function(e,t,r,n){var i,s,a=0;0<e.level?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return o;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return h;for(t=32;t<u;t++)if(0!==e.dyn_ltree[2*t])return h;return o}(e)),Y(e,e.l_desc),Y(e,e.d_desc),a=function(e){var t;for(X(e,e.dyn_ltree,e.l_desc.max_code),X(e,e.dyn_dtree,e.d_desc.max_code),Y(e,e.bl_desc),t=c-1;3<=t&&0===e.bl_tree[2*S[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(s=e.static_len+3+7>>>3)<=i&&(i=s)):i=s=r+5,r+4<=i&&-1!==t?J(e,t,r,n):4===e.strategy||s===i?(P(e,2+(n?1:0),3),K(e,z,C)):(P(e,4+(n?1:0),3),function(e,t,r,n){var i;for(P(e,t-257,5),P(e,r-1,5),P(e,n-4,4),i=0;i<n;i++)P(e,e.bl_tree[2*S[i]+1],3);V(e,e.dyn_ltree,t-1),V(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),K(e,e.dyn_ltree,e.dyn_dtree)),W(e),n&&M(e)},r._tr_tally=function(e,t,r){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(A[r]+u+1)]++,e.dyn_dtree[2*N(t)]++),e.last_lit===e.lit_bufsize-1},r._tr_align=function(e){P(e,2,3),L(e,m,z),function(e){16===e.bi_valid?(U(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{"../utils/common":41}],53:[function(e,t,r){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,r){(function(e){!function(r,n){"use strict";if(!r.setImmediate){var i,s,t,a,o=1,h={},u=!1,l=r.document,e=Object.getPrototypeOf&&Object.getPrototypeOf(r);e=e&&e.setTimeout?e:r,i="[object process]"==={}.toString.call(r.process)?function(e){process.nextTick(function(){c(e)})}:function(){if(r.postMessage&&!r.importScripts){var e=!0,t=r.onmessage;return r.onmessage=function(){e=!1},r.postMessage("","*"),r.onmessage=t,e}}()?(a="setImmediate$"+Math.random()+"$",r.addEventListener?r.addEventListener("message",d,!1):r.attachEvent("onmessage",d),function(e){r.postMessage(a+e,"*")}):r.MessageChannel?((t=new MessageChannel).port1.onmessage=function(e){c(e.data)},function(e){t.port2.postMessage(e)}):l&&"onreadystatechange"in l.createElement("script")?(s=l.documentElement,function(e){var t=l.createElement("script");t.onreadystatechange=function(){c(e),t.onreadystatechange=null,s.removeChild(t),t=null},s.appendChild(t)}):function(e){setTimeout(c,0,e)},e.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r<t.length;r++)t[r]=arguments[r+1];var n={callback:e,args:t};return h[o]=n,i(o),o++},e.clearImmediate=f}function f(e){delete h[e]}function c(e){if(u)setTimeout(c,0,e);else{var t=h[e];if(t){u=!0;try{!function(e){var t=e.callback,r=e.args;switch(r.length){case 0:t();break;case 1:t(r[0]);break;case 2:t(r[0],r[1]);break;case 3:t(r[0],r[1],r[2]);break;default:t.apply(n,r)}}(t)}finally{f(e),u=!1}}}}function d(e){e.source===r&&"string"==typeof e.data&&0===e.data.indexOf(a)&&c(+e.data.slice(a.length))}}("undefined"==typeof self?void 0===e?this:e:self)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[10])(10)});
|
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(2).Buffer, __webpack_require__(15).setImmediate, __webpack_require__(1), __webpack_require__(4)))
|
|
/***/ }),
|
/* 48 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
/* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
|
"use strict";
|
|
if (global.setImmediate) {
|
return;
|
}
|
|
var nextHandle = 1; // Spec says greater than zero
|
var tasksByHandle = {};
|
var currentlyRunningATask = false;
|
var doc = global.document;
|
var registerImmediate;
|
|
function setImmediate(callback) {
|
// Callback can either be a function or a string
|
if (typeof callback !== "function") {
|
callback = new Function("" + callback);
|
}
|
// Copy function arguments
|
var args = new Array(arguments.length - 1);
|
for (var i = 0; i < args.length; i++) {
|
args[i] = arguments[i + 1];
|
}
|
// Store and register the task
|
var task = { callback: callback, args: args };
|
tasksByHandle[nextHandle] = task;
|
registerImmediate(nextHandle);
|
return nextHandle++;
|
}
|
|
function clearImmediate(handle) {
|
delete tasksByHandle[handle];
|
}
|
|
function run(task) {
|
var callback = task.callback;
|
var args = task.args;
|
switch (args.length) {
|
case 0:
|
callback();
|
break;
|
case 1:
|
callback(args[0]);
|
break;
|
case 2:
|
callback(args[0], args[1]);
|
break;
|
case 3:
|
callback(args[0], args[1], args[2]);
|
break;
|
default:
|
callback.apply(undefined, args);
|
break;
|
}
|
}
|
|
function runIfPresent(handle) {
|
// From the spec: "Wait until any invocations of this algorithm started before this one have completed."
|
// So if we're currently running a task, we'll need to delay this invocation.
|
if (currentlyRunningATask) {
|
// Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
|
// "too much recursion" error.
|
setTimeout(runIfPresent, 0, handle);
|
} else {
|
var task = tasksByHandle[handle];
|
if (task) {
|
currentlyRunningATask = true;
|
try {
|
run(task);
|
} finally {
|
clearImmediate(handle);
|
currentlyRunningATask = false;
|
}
|
}
|
}
|
}
|
|
function installNextTickImplementation() {
|
registerImmediate = function(handle) {
|
process.nextTick(function () { runIfPresent(handle); });
|
};
|
}
|
|
function canUsePostMessage() {
|
// The test against `importScripts` prevents this implementation from being installed inside a web worker,
|
// where `global.postMessage` means something completely different and can't be used for this purpose.
|
if (global.postMessage && !global.importScripts) {
|
var postMessageIsAsynchronous = true;
|
var oldOnMessage = global.onmessage;
|
global.onmessage = function() {
|
postMessageIsAsynchronous = false;
|
};
|
global.postMessage("", "*");
|
global.onmessage = oldOnMessage;
|
return postMessageIsAsynchronous;
|
}
|
}
|
|
function installPostMessageImplementation() {
|
// Installs an event handler on `global` for the `message` event: see
|
// * https://developer.mozilla.org/en/DOM/window.postMessage
|
// * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
|
|
var messagePrefix = "setImmediate$" + Math.random() + "$";
|
var onGlobalMessage = function(event) {
|
if (event.source === global &&
|
typeof event.data === "string" &&
|
event.data.indexOf(messagePrefix) === 0) {
|
runIfPresent(+event.data.slice(messagePrefix.length));
|
}
|
};
|
|
if (global.addEventListener) {
|
global.addEventListener("message", onGlobalMessage, false);
|
} else {
|
global.attachEvent("onmessage", onGlobalMessage);
|
}
|
|
registerImmediate = function(handle) {
|
global.postMessage(messagePrefix + handle, "*");
|
};
|
}
|
|
function installMessageChannelImplementation() {
|
var channel = new MessageChannel();
|
channel.port1.onmessage = function(event) {
|
var handle = event.data;
|
runIfPresent(handle);
|
};
|
|
registerImmediate = function(handle) {
|
channel.port2.postMessage(handle);
|
};
|
}
|
|
function installReadyStateChangeImplementation() {
|
var html = doc.documentElement;
|
registerImmediate = function(handle) {
|
// Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
|
// into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
|
var script = doc.createElement("script");
|
script.onreadystatechange = function () {
|
runIfPresent(handle);
|
script.onreadystatechange = null;
|
html.removeChild(script);
|
script = null;
|
};
|
html.appendChild(script);
|
};
|
}
|
|
function installSetTimeoutImplementation() {
|
registerImmediate = function(handle) {
|
setTimeout(runIfPresent, 0, handle);
|
};
|
}
|
|
// If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
|
var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
|
attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
|
|
// Don't get fooled by e.g. browserify environments.
|
if ({}.toString.call(global.process) === "[object process]") {
|
// For Node.js before 0.9
|
installNextTickImplementation();
|
|
} else if (canUsePostMessage()) {
|
// For non-IE10 modern browsers
|
installPostMessageImplementation();
|
|
} else if (global.MessageChannel) {
|
// For web workers, where supported
|
installMessageChannelImplementation();
|
|
} else if (doc && "onreadystatechange" in doc.createElement("script")) {
|
// For IE 6–8
|
installReadyStateChangeImplementation();
|
|
} else {
|
// For older browsers
|
installSetTimeoutImplementation();
|
}
|
|
attachTo.setImmediate = setImmediate;
|
attachTo.clearImmediate = clearImmediate;
|
}(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
|
|
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(1), __webpack_require__(4)))
|
|
/***/ }),
|
/* 49 */
|
/***/ (function(module, exports) {
|
|
function webpackEmptyContext(req) {
|
var e = new Error("Cannot find module '" + req + "'");
|
e.code = 'MODULE_NOT_FOUND';
|
throw e;
|
}
|
webpackEmptyContext.keys = function() { return []; };
|
webpackEmptyContext.resolve = webpackEmptyContext;
|
module.exports = webpackEmptyContext;
|
webpackEmptyContext.id = 49;
|
|
/***/ }),
|
/* 50 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
/* WEBPACK VAR INJECTION */(function(Buffer, global, process) {var capability = __webpack_require__(17)
|
var inherits = __webpack_require__(5)
|
var response = __webpack_require__(18)
|
var stream = __webpack_require__(19)
|
var toArrayBuffer = __webpack_require__(56)
|
|
var IncomingMessage = response.IncomingMessage
|
var rStates = response.readyStates
|
|
function decideMode (preferBinary, useFetch) {
|
if (capability.fetch && useFetch) {
|
return 'fetch'
|
} else if (capability.mozchunkedarraybuffer) {
|
return 'moz-chunked-arraybuffer'
|
} else if (capability.msstream) {
|
return 'ms-stream'
|
} else if (capability.arraybuffer && preferBinary) {
|
return 'arraybuffer'
|
} else if (capability.vbArray && preferBinary) {
|
return 'text:vbarray'
|
} else {
|
return 'text'
|
}
|
}
|
|
var ClientRequest = module.exports = function (opts) {
|
var self = this
|
stream.Writable.call(self)
|
|
self._opts = opts
|
self._body = []
|
self._headers = {}
|
if (opts.auth)
|
self.setHeader('Authorization', 'Basic ' + new Buffer(opts.auth).toString('base64'))
|
Object.keys(opts.headers).forEach(function (name) {
|
self.setHeader(name, opts.headers[name])
|
})
|
|
var preferBinary
|
var useFetch = true
|
if (opts.mode === 'disable-fetch' || ('requestTimeout' in opts && !capability.abortController)) {
|
// If the use of XHR should be preferred. Not typically needed.
|
useFetch = false
|
preferBinary = true
|
} else if (opts.mode === 'prefer-streaming') {
|
// If streaming is a high priority but binary compatibility and
|
// the accuracy of the 'content-type' header aren't
|
preferBinary = false
|
} else if (opts.mode === 'allow-wrong-content-type') {
|
// If streaming is more important than preserving the 'content-type' header
|
preferBinary = !capability.overrideMimeType
|
} else if (!opts.mode || opts.mode === 'default' || opts.mode === 'prefer-fast') {
|
// Use binary if text streaming may corrupt data or the content-type header, or for speed
|
preferBinary = true
|
} else {
|
throw new Error('Invalid value for opts.mode')
|
}
|
self._mode = decideMode(preferBinary, useFetch)
|
self._fetchTimer = null
|
|
self.on('finish', function () {
|
self._onFinish()
|
})
|
}
|
|
inherits(ClientRequest, stream.Writable)
|
|
ClientRequest.prototype.setHeader = function (name, value) {
|
var self = this
|
var lowerName = name.toLowerCase()
|
// This check is not necessary, but it prevents warnings from browsers about setting unsafe
|
// headers. To be honest I'm not entirely sure hiding these warnings is a good thing, but
|
// http-browserify did it, so I will too.
|
if (unsafeHeaders.indexOf(lowerName) !== -1)
|
return
|
|
self._headers[lowerName] = {
|
name: name,
|
value: value
|
}
|
}
|
|
ClientRequest.prototype.getHeader = function (name) {
|
var header = this._headers[name.toLowerCase()]
|
if (header)
|
return header.value
|
return null
|
}
|
|
ClientRequest.prototype.removeHeader = function (name) {
|
var self = this
|
delete self._headers[name.toLowerCase()]
|
}
|
|
ClientRequest.prototype._onFinish = function () {
|
var self = this
|
|
if (self._destroyed)
|
return
|
var opts = self._opts
|
|
var headersObj = self._headers
|
var body = null
|
if (opts.method !== 'GET' && opts.method !== 'HEAD') {
|
if (capability.arraybuffer) {
|
body = toArrayBuffer(Buffer.concat(self._body))
|
} else if (capability.blobConstructor) {
|
body = new global.Blob(self._body.map(function (buffer) {
|
return toArrayBuffer(buffer)
|
}), {
|
type: (headersObj['content-type'] || {}).value || ''
|
})
|
} else {
|
// get utf8 string
|
body = Buffer.concat(self._body).toString()
|
}
|
}
|
|
// create flattened list of headers
|
var headersList = []
|
Object.keys(headersObj).forEach(function (keyName) {
|
var name = headersObj[keyName].name
|
var value = headersObj[keyName].value
|
if (Array.isArray(value)) {
|
value.forEach(function (v) {
|
headersList.push([name, v])
|
})
|
} else {
|
headersList.push([name, value])
|
}
|
})
|
|
if (self._mode === 'fetch') {
|
var signal = null
|
var fetchTimer = null
|
if (capability.abortController) {
|
var controller = new AbortController()
|
signal = controller.signal
|
self._fetchAbortController = controller
|
|
if ('requestTimeout' in opts && opts.requestTimeout !== 0) {
|
self._fetchTimer = global.setTimeout(function () {
|
self.emit('requestTimeout')
|
if (self._fetchAbortController)
|
self._fetchAbortController.abort()
|
}, opts.requestTimeout)
|
}
|
}
|
|
global.fetch(self._opts.url, {
|
method: self._opts.method,
|
headers: headersList,
|
body: body || undefined,
|
mode: 'cors',
|
credentials: opts.withCredentials ? 'include' : 'same-origin',
|
signal: signal
|
}).then(function (response) {
|
self._fetchResponse = response
|
self._connect()
|
}, function (reason) {
|
global.clearTimeout(self._fetchTimer)
|
if (!self._destroyed)
|
self.emit('error', reason)
|
})
|
} else {
|
var xhr = self._xhr = new global.XMLHttpRequest()
|
try {
|
xhr.open(self._opts.method, self._opts.url, true)
|
} catch (err) {
|
process.nextTick(function () {
|
self.emit('error', err)
|
})
|
return
|
}
|
|
// Can't set responseType on really old browsers
|
if ('responseType' in xhr)
|
xhr.responseType = self._mode.split(':')[0]
|
|
if ('withCredentials' in xhr)
|
xhr.withCredentials = !!opts.withCredentials
|
|
if (self._mode === 'text' && 'overrideMimeType' in xhr)
|
xhr.overrideMimeType('text/plain; charset=x-user-defined')
|
|
if ('requestTimeout' in opts) {
|
xhr.timeout = opts.requestTimeout
|
xhr.ontimeout = function () {
|
self.emit('requestTimeout')
|
}
|
}
|
|
headersList.forEach(function (header) {
|
xhr.setRequestHeader(header[0], header[1])
|
})
|
|
self._response = null
|
xhr.onreadystatechange = function () {
|
switch (xhr.readyState) {
|
case rStates.LOADING:
|
case rStates.DONE:
|
self._onXHRProgress()
|
break
|
}
|
}
|
// Necessary for streaming in Firefox, since xhr.response is ONLY defined
|
// in onprogress, not in onreadystatechange with xhr.readyState = 3
|
if (self._mode === 'moz-chunked-arraybuffer') {
|
xhr.onprogress = function () {
|
self._onXHRProgress()
|
}
|
}
|
|
xhr.onerror = function () {
|
if (self._destroyed)
|
return
|
self.emit('error', new Error('XHR error'))
|
}
|
|
try {
|
xhr.send(body)
|
} catch (err) {
|
process.nextTick(function () {
|
self.emit('error', err)
|
})
|
return
|
}
|
}
|
}
|
|
/**
|
* Checks if xhr.status is readable and non-zero, indicating no error.
|
* Even though the spec says it should be available in readyState 3,
|
* accessing it throws an exception in IE8
|
*/
|
function statusValid (xhr) {
|
try {
|
var status = xhr.status
|
return (status !== null && status !== 0)
|
} catch (e) {
|
return false
|
}
|
}
|
|
ClientRequest.prototype._onXHRProgress = function () {
|
var self = this
|
|
if (!statusValid(self._xhr) || self._destroyed)
|
return
|
|
if (!self._response)
|
self._connect()
|
|
self._response._onXHRProgress()
|
}
|
|
ClientRequest.prototype._connect = function () {
|
var self = this
|
|
if (self._destroyed)
|
return
|
|
self._response = new IncomingMessage(self._xhr, self._fetchResponse, self._mode, self._fetchTimer)
|
self._response.on('error', function(err) {
|
self.emit('error', err)
|
})
|
|
self.emit('response', self._response)
|
}
|
|
ClientRequest.prototype._write = function (chunk, encoding, cb) {
|
var self = this
|
|
self._body.push(chunk)
|
cb()
|
}
|
|
ClientRequest.prototype.abort = ClientRequest.prototype.destroy = function () {
|
var self = this
|
self._destroyed = true
|
global.clearTimeout(self._fetchTimer)
|
if (self._response)
|
self._response._destroyed = true
|
if (self._xhr)
|
self._xhr.abort()
|
else if (self._fetchAbortController)
|
self._fetchAbortController.abort()
|
}
|
|
ClientRequest.prototype.end = function (data, encoding, cb) {
|
var self = this
|
if (typeof data === 'function') {
|
cb = data
|
data = undefined
|
}
|
|
stream.Writable.prototype.end.call(self, data, encoding, cb)
|
}
|
|
ClientRequest.prototype.flushHeaders = function () {}
|
ClientRequest.prototype.setTimeout = function () {}
|
ClientRequest.prototype.setNoDelay = function () {}
|
ClientRequest.prototype.setSocketKeepAlive = function () {}
|
|
// Taken from http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader%28%29-method
|
var unsafeHeaders = [
|
'accept-charset',
|
'accept-encoding',
|
'access-control-request-headers',
|
'access-control-request-method',
|
'connection',
|
'content-length',
|
'cookie',
|
'cookie2',
|
'date',
|
'dnt',
|
'expect',
|
'host',
|
'keep-alive',
|
'origin',
|
'referer',
|
'te',
|
'trailer',
|
'transfer-encoding',
|
'upgrade',
|
'via'
|
]
|
|
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(2).Buffer, __webpack_require__(1), __webpack_require__(4)))
|
|
/***/ }),
|
/* 51 */
|
/***/ (function(module, exports) {
|
|
/* (ignored) */
|
|
/***/ }),
|
/* 52 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
"use strict";
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
var Buffer = __webpack_require__(11).Buffer;
|
var util = __webpack_require__(53);
|
|
function copyBuffer(src, target, offset) {
|
src.copy(target, offset);
|
}
|
|
module.exports = function () {
|
function BufferList() {
|
_classCallCheck(this, BufferList);
|
|
this.head = null;
|
this.tail = null;
|
this.length = 0;
|
}
|
|
BufferList.prototype.push = function push(v) {
|
var entry = { data: v, next: null };
|
if (this.length > 0) this.tail.next = entry;else this.head = entry;
|
this.tail = entry;
|
++this.length;
|
};
|
|
BufferList.prototype.unshift = function unshift(v) {
|
var entry = { data: v, next: this.head };
|
if (this.length === 0) this.tail = entry;
|
this.head = entry;
|
++this.length;
|
};
|
|
BufferList.prototype.shift = function shift() {
|
if (this.length === 0) return;
|
var ret = this.head.data;
|
if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
|
--this.length;
|
return ret;
|
};
|
|
BufferList.prototype.clear = function clear() {
|
this.head = this.tail = null;
|
this.length = 0;
|
};
|
|
BufferList.prototype.join = function join(s) {
|
if (this.length === 0) return '';
|
var p = this.head;
|
var ret = '' + p.data;
|
while (p = p.next) {
|
ret += s + p.data;
|
}return ret;
|
};
|
|
BufferList.prototype.concat = function concat(n) {
|
if (this.length === 0) return Buffer.alloc(0);
|
if (this.length === 1) return this.head.data;
|
var ret = Buffer.allocUnsafe(n >>> 0);
|
var p = this.head;
|
var i = 0;
|
while (p) {
|
copyBuffer(p.data, ret, i);
|
i += p.data.length;
|
p = p.next;
|
}
|
return ret;
|
};
|
|
return BufferList;
|
}();
|
|
if (util && util.inspect && util.inspect.custom) {
|
module.exports.prototype[util.inspect.custom] = function () {
|
var obj = util.inspect({ length: this.length });
|
return this.constructor.name + ' ' + obj;
|
};
|
}
|
|
/***/ }),
|
/* 53 */
|
/***/ (function(module, exports) {
|
|
/* (ignored) */
|
|
/***/ }),
|
/* 54 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
/* WEBPACK VAR INJECTION */(function(global) {
|
/**
|
* Module exports.
|
*/
|
|
module.exports = deprecate;
|
|
/**
|
* Mark that a method should not be used.
|
* Returns a modified function which warns once by default.
|
*
|
* If `localStorage.noDeprecation = true` is set, then it is a no-op.
|
*
|
* If `localStorage.throwDeprecation = true` is set, then deprecated functions
|
* will throw an Error when invoked.
|
*
|
* If `localStorage.traceDeprecation = true` is set, then deprecated functions
|
* will invoke `console.trace()` instead of `console.error()`.
|
*
|
* @param {Function} fn - the function to deprecate
|
* @param {String} msg - the string to print to the console when `fn` is invoked
|
* @returns {Function} a new "deprecated" version of `fn`
|
* @api public
|
*/
|
|
function deprecate (fn, msg) {
|
if (config('noDeprecation')) {
|
return fn;
|
}
|
|
var warned = false;
|
function deprecated() {
|
if (!warned) {
|
if (config('throwDeprecation')) {
|
throw new Error(msg);
|
} else if (config('traceDeprecation')) {
|
console.trace(msg);
|
} else {
|
console.warn(msg);
|
}
|
warned = true;
|
}
|
return fn.apply(this, arguments);
|
}
|
|
return deprecated;
|
}
|
|
/**
|
* Checks `localStorage` for boolean values for the given `name`.
|
*
|
* @param {String} name
|
* @returns {Boolean}
|
* @api private
|
*/
|
|
function config (name) {
|
// accessing global.localStorage can trigger a DOMException in sandboxed iframes
|
try {
|
if (!global.localStorage) return false;
|
} catch (_) {
|
return false;
|
}
|
var val = global.localStorage[name];
|
if (null == val) return false;
|
return String(val).toLowerCase() === 'true';
|
}
|
|
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(1)))
|
|
/***/ }),
|
/* 55 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
"use strict";
|
// Copyright Joyent, Inc. and other Node contributors.
|
//
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
// copy of this software and associated documentation files (the
|
// "Software"), to deal in the Software without restriction, including
|
// without limitation the rights to use, copy, modify, merge, publish,
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
// persons to whom the Software is furnished to do so, subject to the
|
// following conditions:
|
//
|
// The above copyright notice and this permission notice shall be included
|
// in all copies or substantial portions of the Software.
|
//
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
// a passthrough stream.
|
// basically just the most minimal sort of Transform stream.
|
// Every written chunk gets output as-is.
|
|
|
|
module.exports = PassThrough;
|
|
var Transform = __webpack_require__(25);
|
|
/*<replacement>*/
|
var util = Object.create(__webpack_require__(8));
|
util.inherits = __webpack_require__(5);
|
/*</replacement>*/
|
|
util.inherits(PassThrough, Transform);
|
|
function PassThrough(options) {
|
if (!(this instanceof PassThrough)) return new PassThrough(options);
|
|
Transform.call(this, options);
|
}
|
|
PassThrough.prototype._transform = function (chunk, encoding, cb) {
|
cb(null, chunk);
|
};
|
|
/***/ }),
|
/* 56 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
var Buffer = __webpack_require__(2).Buffer
|
|
module.exports = function (buf) {
|
// If the buffer is backed by a Uint8Array, a faster version will work
|
if (buf instanceof Uint8Array) {
|
// If the buffer isn't a subarray, return the underlying ArrayBuffer
|
if (buf.byteOffset === 0 && buf.byteLength === buf.buffer.byteLength) {
|
return buf.buffer
|
} else if (typeof buf.buffer.slice === 'function') {
|
// Otherwise we need to get a proper copy
|
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength)
|
}
|
}
|
|
if (Buffer.isBuffer(buf)) {
|
// This is the slow version that will work with any Buffer
|
// implementation (even in old browsers)
|
var arrayCopy = new Uint8Array(buf.length)
|
var len = buf.length
|
for (var i = 0; i < len; i++) {
|
arrayCopy[i] = buf[i]
|
}
|
return arrayCopy.buffer
|
} else {
|
throw new Error('Argument must be a Buffer')
|
}
|
}
|
|
|
/***/ }),
|
/* 57 */
|
/***/ (function(module, exports) {
|
|
module.exports = extend
|
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
function extend() {
|
var target = {}
|
|
for (var i = 0; i < arguments.length; i++) {
|
var source = arguments[i]
|
|
for (var key in source) {
|
if (hasOwnProperty.call(source, key)) {
|
target[key] = source[key]
|
}
|
}
|
}
|
|
return target
|
}
|
|
|
/***/ }),
|
/* 58 */
|
/***/ (function(module, exports) {
|
|
module.exports = {
|
"100": "Continue",
|
"101": "Switching Protocols",
|
"102": "Processing",
|
"200": "OK",
|
"201": "Created",
|
"202": "Accepted",
|
"203": "Non-Authoritative Information",
|
"204": "No Content",
|
"205": "Reset Content",
|
"206": "Partial Content",
|
"207": "Multi-Status",
|
"208": "Already Reported",
|
"226": "IM Used",
|
"300": "Multiple Choices",
|
"301": "Moved Permanently",
|
"302": "Found",
|
"303": "See Other",
|
"304": "Not Modified",
|
"305": "Use Proxy",
|
"307": "Temporary Redirect",
|
"308": "Permanent Redirect",
|
"400": "Bad Request",
|
"401": "Unauthorized",
|
"402": "Payment Required",
|
"403": "Forbidden",
|
"404": "Not Found",
|
"405": "Method Not Allowed",
|
"406": "Not Acceptable",
|
"407": "Proxy Authentication Required",
|
"408": "Request Timeout",
|
"409": "Conflict",
|
"410": "Gone",
|
"411": "Length Required",
|
"412": "Precondition Failed",
|
"413": "Payload Too Large",
|
"414": "URI Too Long",
|
"415": "Unsupported Media Type",
|
"416": "Range Not Satisfiable",
|
"417": "Expectation Failed",
|
"418": "I'm a teapot",
|
"421": "Misdirected Request",
|
"422": "Unprocessable Entity",
|
"423": "Locked",
|
"424": "Failed Dependency",
|
"425": "Unordered Collection",
|
"426": "Upgrade Required",
|
"428": "Precondition Required",
|
"429": "Too Many Requests",
|
"431": "Request Header Fields Too Large",
|
"451": "Unavailable For Legal Reasons",
|
"500": "Internal Server Error",
|
"501": "Not Implemented",
|
"502": "Bad Gateway",
|
"503": "Service Unavailable",
|
"504": "Gateway Timeout",
|
"505": "HTTP Version Not Supported",
|
"506": "Variant Also Negotiates",
|
"507": "Insufficient Storage",
|
"508": "Loop Detected",
|
"509": "Bandwidth Limit Exceeded",
|
"510": "Not Extended",
|
"511": "Network Authentication Required"
|
}
|
|
|
/***/ }),
|
/* 59 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
/* WEBPACK VAR INJECTION */(function(module, global) {var __WEBPACK_AMD_DEFINE_RESULT__;/*! https://mths.be/punycode v1.4.1 by @mathias */
|
;(function(root) {
|
|
/** Detect free variables */
|
var freeExports = true && exports &&
|
!exports.nodeType && exports;
|
var freeModule = true && module &&
|
!module.nodeType && module;
|
var freeGlobal = typeof global == 'object' && global;
|
if (
|
freeGlobal.global === freeGlobal ||
|
freeGlobal.window === freeGlobal ||
|
freeGlobal.self === freeGlobal
|
) {
|
root = freeGlobal;
|
}
|
|
/**
|
* The `punycode` object.
|
* @name punycode
|
* @type Object
|
*/
|
var punycode,
|
|
/** Highest positive signed 32-bit float value */
|
maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
|
|
/** Bootstring parameters */
|
base = 36,
|
tMin = 1,
|
tMax = 26,
|
skew = 38,
|
damp = 700,
|
initialBias = 72,
|
initialN = 128, // 0x80
|
delimiter = '-', // '\x2D'
|
|
/** Regular expressions */
|
regexPunycode = /^xn--/,
|
regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
|
regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
|
|
/** Error messages */
|
errors = {
|
'overflow': 'Overflow: input needs wider integers to process',
|
'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
|
'invalid-input': 'Invalid input'
|
},
|
|
/** Convenience shortcuts */
|
baseMinusTMin = base - tMin,
|
floor = Math.floor,
|
stringFromCharCode = String.fromCharCode,
|
|
/** Temporary variable */
|
key;
|
|
/*--------------------------------------------------------------------------*/
|
|
/**
|
* A generic error utility function.
|
* @private
|
* @param {String} type The error type.
|
* @returns {Error} Throws a `RangeError` with the applicable error message.
|
*/
|
function error(type) {
|
throw new RangeError(errors[type]);
|
}
|
|
/**
|
* A generic `Array#map` utility function.
|
* @private
|
* @param {Array} array The array to iterate over.
|
* @param {Function} callback The function that gets called for every array
|
* item.
|
* @returns {Array} A new array of values returned by the callback function.
|
*/
|
function map(array, fn) {
|
var length = array.length;
|
var result = [];
|
while (length--) {
|
result[length] = fn(array[length]);
|
}
|
return result;
|
}
|
|
/**
|
* A simple `Array#map`-like wrapper to work with domain name strings or email
|
* addresses.
|
* @private
|
* @param {String} domain The domain name or email address.
|
* @param {Function} callback The function that gets called for every
|
* character.
|
* @returns {Array} A new string of characters returned by the callback
|
* function.
|
*/
|
function mapDomain(string, fn) {
|
var parts = string.split('@');
|
var result = '';
|
if (parts.length > 1) {
|
// In email addresses, only the domain name should be punycoded. Leave
|
// the local part (i.e. everything up to `@`) intact.
|
result = parts[0] + '@';
|
string = parts[1];
|
}
|
// Avoid `split(regex)` for IE8 compatibility. See #17.
|
string = string.replace(regexSeparators, '\x2E');
|
var labels = string.split('.');
|
var encoded = map(labels, fn).join('.');
|
return result + encoded;
|
}
|
|
/**
|
* Creates an array containing the numeric code points of each Unicode
|
* character in the string. While JavaScript uses UCS-2 internally,
|
* this function will convert a pair of surrogate halves (each of which
|
* UCS-2 exposes as separate characters) into a single code point,
|
* matching UTF-16.
|
* @see `punycode.ucs2.encode`
|
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
* @memberOf punycode.ucs2
|
* @name decode
|
* @param {String} string The Unicode input string (UCS-2).
|
* @returns {Array} The new array of code points.
|
*/
|
function ucs2decode(string) {
|
var output = [],
|
counter = 0,
|
length = string.length,
|
value,
|
extra;
|
while (counter < length) {
|
value = string.charCodeAt(counter++);
|
if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
|
// high surrogate, and there is a next character
|
extra = string.charCodeAt(counter++);
|
if ((extra & 0xFC00) == 0xDC00) { // low surrogate
|
output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
|
} else {
|
// unmatched surrogate; only append this code unit, in case the next
|
// code unit is the high surrogate of a surrogate pair
|
output.push(value);
|
counter--;
|
}
|
} else {
|
output.push(value);
|
}
|
}
|
return output;
|
}
|
|
/**
|
* Creates a string based on an array of numeric code points.
|
* @see `punycode.ucs2.decode`
|
* @memberOf punycode.ucs2
|
* @name encode
|
* @param {Array} codePoints The array of numeric code points.
|
* @returns {String} The new Unicode string (UCS-2).
|
*/
|
function ucs2encode(array) {
|
return map(array, function(value) {
|
var output = '';
|
if (value > 0xFFFF) {
|
value -= 0x10000;
|
output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
|
value = 0xDC00 | value & 0x3FF;
|
}
|
output += stringFromCharCode(value);
|
return output;
|
}).join('');
|
}
|
|
/**
|
* Converts a basic code point into a digit/integer.
|
* @see `digitToBasic()`
|
* @private
|
* @param {Number} codePoint The basic numeric code point value.
|
* @returns {Number} The numeric value of a basic code point (for use in
|
* representing integers) in the range `0` to `base - 1`, or `base` if
|
* the code point does not represent a value.
|
*/
|
function basicToDigit(codePoint) {
|
if (codePoint - 48 < 10) {
|
return codePoint - 22;
|
}
|
if (codePoint - 65 < 26) {
|
return codePoint - 65;
|
}
|
if (codePoint - 97 < 26) {
|
return codePoint - 97;
|
}
|
return base;
|
}
|
|
/**
|
* Converts a digit/integer into a basic code point.
|
* @see `basicToDigit()`
|
* @private
|
* @param {Number} digit The numeric value of a basic code point.
|
* @returns {Number} The basic code point whose value (when used for
|
* representing integers) is `digit`, which needs to be in the range
|
* `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
|
* used; else, the lowercase form is used. The behavior is undefined
|
* if `flag` is non-zero and `digit` has no uppercase form.
|
*/
|
function digitToBasic(digit, flag) {
|
// 0..25 map to ASCII a..z or A..Z
|
// 26..35 map to ASCII 0..9
|
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
|
}
|
|
/**
|
* Bias adaptation function as per section 3.4 of RFC 3492.
|
* https://tools.ietf.org/html/rfc3492#section-3.4
|
* @private
|
*/
|
function adapt(delta, numPoints, firstTime) {
|
var k = 0;
|
delta = firstTime ? floor(delta / damp) : delta >> 1;
|
delta += floor(delta / numPoints);
|
for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
|
delta = floor(delta / baseMinusTMin);
|
}
|
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
|
}
|
|
/**
|
* Converts a Punycode string of ASCII-only symbols to a string of Unicode
|
* symbols.
|
* @memberOf punycode
|
* @param {String} input The Punycode string of ASCII-only symbols.
|
* @returns {String} The resulting string of Unicode symbols.
|
*/
|
function decode(input) {
|
// Don't use UCS-2
|
var output = [],
|
inputLength = input.length,
|
out,
|
i = 0,
|
n = initialN,
|
bias = initialBias,
|
basic,
|
j,
|
index,
|
oldi,
|
w,
|
k,
|
digit,
|
t,
|
/** Cached calculation results */
|
baseMinusT;
|
|
// Handle the basic code points: let `basic` be the number of input code
|
// points before the last delimiter, or `0` if there is none, then copy
|
// the first basic code points to the output.
|
|
basic = input.lastIndexOf(delimiter);
|
if (basic < 0) {
|
basic = 0;
|
}
|
|
for (j = 0; j < basic; ++j) {
|
// if it's not a basic code point
|
if (input.charCodeAt(j) >= 0x80) {
|
error('not-basic');
|
}
|
output.push(input.charCodeAt(j));
|
}
|
|
// Main decoding loop: start just after the last delimiter if any basic code
|
// points were copied; start at the beginning otherwise.
|
|
for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
|
|
// `index` is the index of the next character to be consumed.
|
// Decode a generalized variable-length integer into `delta`,
|
// which gets added to `i`. The overflow checking is easier
|
// if we increase `i` as we go, then subtract off its starting
|
// value at the end to obtain `delta`.
|
for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
|
|
if (index >= inputLength) {
|
error('invalid-input');
|
}
|
|
digit = basicToDigit(input.charCodeAt(index++));
|
|
if (digit >= base || digit > floor((maxInt - i) / w)) {
|
error('overflow');
|
}
|
|
i += digit * w;
|
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
|
|
if (digit < t) {
|
break;
|
}
|
|
baseMinusT = base - t;
|
if (w > floor(maxInt / baseMinusT)) {
|
error('overflow');
|
}
|
|
w *= baseMinusT;
|
|
}
|
|
out = output.length + 1;
|
bias = adapt(i - oldi, out, oldi == 0);
|
|
// `i` was supposed to wrap around from `out` to `0`,
|
// incrementing `n` each time, so we'll fix that now:
|
if (floor(i / out) > maxInt - n) {
|
error('overflow');
|
}
|
|
n += floor(i / out);
|
i %= out;
|
|
// Insert `n` at position `i` of the output
|
output.splice(i++, 0, n);
|
|
}
|
|
return ucs2encode(output);
|
}
|
|
/**
|
* Converts a string of Unicode symbols (e.g. a domain name label) to a
|
* Punycode string of ASCII-only symbols.
|
* @memberOf punycode
|
* @param {String} input The string of Unicode symbols.
|
* @returns {String} The resulting Punycode string of ASCII-only symbols.
|
*/
|
function encode(input) {
|
var n,
|
delta,
|
handledCPCount,
|
basicLength,
|
bias,
|
j,
|
m,
|
q,
|
k,
|
t,
|
currentValue,
|
output = [],
|
/** `inputLength` will hold the number of code points in `input`. */
|
inputLength,
|
/** Cached calculation results */
|
handledCPCountPlusOne,
|
baseMinusT,
|
qMinusT;
|
|
// Convert the input in UCS-2 to Unicode
|
input = ucs2decode(input);
|
|
// Cache the length
|
inputLength = input.length;
|
|
// Initialize the state
|
n = initialN;
|
delta = 0;
|
bias = initialBias;
|
|
// Handle the basic code points
|
for (j = 0; j < inputLength; ++j) {
|
currentValue = input[j];
|
if (currentValue < 0x80) {
|
output.push(stringFromCharCode(currentValue));
|
}
|
}
|
|
handledCPCount = basicLength = output.length;
|
|
// `handledCPCount` is the number of code points that have been handled;
|
// `basicLength` is the number of basic code points.
|
|
// Finish the basic string - if it is not empty - with a delimiter
|
if (basicLength) {
|
output.push(delimiter);
|
}
|
|
// Main encoding loop:
|
while (handledCPCount < inputLength) {
|
|
// All non-basic code points < n have been handled already. Find the next
|
// larger one:
|
for (m = maxInt, j = 0; j < inputLength; ++j) {
|
currentValue = input[j];
|
if (currentValue >= n && currentValue < m) {
|
m = currentValue;
|
}
|
}
|
|
// Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
|
// but guard against overflow
|
handledCPCountPlusOne = handledCPCount + 1;
|
if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
|
error('overflow');
|
}
|
|
delta += (m - n) * handledCPCountPlusOne;
|
n = m;
|
|
for (j = 0; j < inputLength; ++j) {
|
currentValue = input[j];
|
|
if (currentValue < n && ++delta > maxInt) {
|
error('overflow');
|
}
|
|
if (currentValue == n) {
|
// Represent delta as a generalized variable-length integer
|
for (q = delta, k = base; /* no condition */; k += base) {
|
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
|
if (q < t) {
|
break;
|
}
|
qMinusT = q - t;
|
baseMinusT = base - t;
|
output.push(
|
stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
|
);
|
q = floor(qMinusT / baseMinusT);
|
}
|
|
output.push(stringFromCharCode(digitToBasic(q, 0)));
|
bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
|
delta = 0;
|
++handledCPCount;
|
}
|
}
|
|
++delta;
|
++n;
|
|
}
|
return output.join('');
|
}
|
|
/**
|
* Converts a Punycode string representing a domain name or an email address
|
* to Unicode. Only the Punycoded parts of the input will be converted, i.e.
|
* it doesn't matter if you call it on a string that has already been
|
* converted to Unicode.
|
* @memberOf punycode
|
* @param {String} input The Punycoded domain name or email address to
|
* convert to Unicode.
|
* @returns {String} The Unicode representation of the given Punycode
|
* string.
|
*/
|
function toUnicode(input) {
|
return mapDomain(input, function(string) {
|
return regexPunycode.test(string)
|
? decode(string.slice(4).toLowerCase())
|
: string;
|
});
|
}
|
|
/**
|
* Converts a Unicode string representing a domain name or an email address to
|
* Punycode. Only the non-ASCII parts of the domain name will be converted,
|
* i.e. it doesn't matter if you call it with a domain that's already in
|
* ASCII.
|
* @memberOf punycode
|
* @param {String} input The domain name or email address to convert, as a
|
* Unicode string.
|
* @returns {String} The Punycode representation of the given domain name or
|
* email address.
|
*/
|
function toASCII(input) {
|
return mapDomain(input, function(string) {
|
return regexNonASCII.test(string)
|
? 'xn--' + encode(string)
|
: string;
|
});
|
}
|
|
/*--------------------------------------------------------------------------*/
|
|
/** Define the public API */
|
punycode = {
|
/**
|
* A string representing the current Punycode.js version number.
|
* @memberOf punycode
|
* @type String
|
*/
|
'version': '1.4.1',
|
/**
|
* An object of methods to convert from JavaScript's internal character
|
* representation (UCS-2) to Unicode code points, and back.
|
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
* @memberOf punycode
|
* @type Object
|
*/
|
'ucs2': {
|
'decode': ucs2decode,
|
'encode': ucs2encode
|
},
|
'decode': decode,
|
'encode': encode,
|
'toASCII': toASCII,
|
'toUnicode': toUnicode
|
};
|
|
/** Expose `punycode` */
|
// Some AMD build optimizers, like r.js, check for specific condition patterns
|
// like the following:
|
if (
|
true
|
) {
|
!(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
|
return punycode;
|
}).call(exports, __webpack_require__, exports, module),
|
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
} else {}
|
|
}(this));
|
|
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(60)(module), __webpack_require__(1)))
|
|
/***/ }),
|
/* 60 */
|
/***/ (function(module, exports) {
|
|
module.exports = function(module) {
|
if (!module.webpackPolyfill) {
|
module.deprecate = function() {};
|
module.paths = [];
|
// module.parent = undefined by default
|
if (!module.children) module.children = [];
|
Object.defineProperty(module, "loaded", {
|
enumerable: true,
|
get: function() {
|
return module.l;
|
}
|
});
|
Object.defineProperty(module, "id", {
|
enumerable: true,
|
get: function() {
|
return module.i;
|
}
|
});
|
module.webpackPolyfill = 1;
|
}
|
return module;
|
};
|
|
|
/***/ }),
|
/* 61 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
"use strict";
|
|
|
module.exports = {
|
isString: function(arg) {
|
return typeof(arg) === 'string';
|
},
|
isObject: function(arg) {
|
return typeof(arg) === 'object' && arg !== null;
|
},
|
isNull: function(arg) {
|
return arg === null;
|
},
|
isNullOrUndefined: function(arg) {
|
return arg == null;
|
}
|
};
|
|
|
/***/ }),
|
/* 62 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
"use strict";
|
|
|
exports.decode = exports.parse = __webpack_require__(63);
|
exports.encode = exports.stringify = __webpack_require__(64);
|
|
|
/***/ }),
|
/* 63 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
"use strict";
|
// Copyright Joyent, Inc. and other Node contributors.
|
//
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
// copy of this software and associated documentation files (the
|
// "Software"), to deal in the Software without restriction, including
|
// without limitation the rights to use, copy, modify, merge, publish,
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
// persons to whom the Software is furnished to do so, subject to the
|
// following conditions:
|
//
|
// The above copyright notice and this permission notice shall be included
|
// in all copies or substantial portions of the Software.
|
//
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
// If obj.hasOwnProperty has been overridden, then calling
|
// obj.hasOwnProperty(prop) will break.
|
// See: https://github.com/joyent/node/issues/1707
|
function hasOwnProperty(obj, prop) {
|
return Object.prototype.hasOwnProperty.call(obj, prop);
|
}
|
|
module.exports = function(qs, sep, eq, options) {
|
sep = sep || '&';
|
eq = eq || '=';
|
var obj = {};
|
|
if (typeof qs !== 'string' || qs.length === 0) {
|
return obj;
|
}
|
|
var regexp = /\+/g;
|
qs = qs.split(sep);
|
|
var maxKeys = 1000;
|
if (options && typeof options.maxKeys === 'number') {
|
maxKeys = options.maxKeys;
|
}
|
|
var len = qs.length;
|
// maxKeys <= 0 means that we should not limit keys count
|
if (maxKeys > 0 && len > maxKeys) {
|
len = maxKeys;
|
}
|
|
for (var i = 0; i < len; ++i) {
|
var x = qs[i].replace(regexp, '%20'),
|
idx = x.indexOf(eq),
|
kstr, vstr, k, v;
|
|
if (idx >= 0) {
|
kstr = x.substr(0, idx);
|
vstr = x.substr(idx + 1);
|
} else {
|
kstr = x;
|
vstr = '';
|
}
|
|
k = decodeURIComponent(kstr);
|
v = decodeURIComponent(vstr);
|
|
if (!hasOwnProperty(obj, k)) {
|
obj[k] = v;
|
} else if (isArray(obj[k])) {
|
obj[k].push(v);
|
} else {
|
obj[k] = [obj[k], v];
|
}
|
}
|
|
return obj;
|
};
|
|
var isArray = Array.isArray || function (xs) {
|
return Object.prototype.toString.call(xs) === '[object Array]';
|
};
|
|
|
/***/ }),
|
/* 64 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
"use strict";
|
// Copyright Joyent, Inc. and other Node contributors.
|
//
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
// copy of this software and associated documentation files (the
|
// "Software"), to deal in the Software without restriction, including
|
// without limitation the rights to use, copy, modify, merge, publish,
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
// persons to whom the Software is furnished to do so, subject to the
|
// following conditions:
|
//
|
// The above copyright notice and this permission notice shall be included
|
// in all copies or substantial portions of the Software.
|
//
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
var stringifyPrimitive = function(v) {
|
switch (typeof v) {
|
case 'string':
|
return v;
|
|
case 'boolean':
|
return v ? 'true' : 'false';
|
|
case 'number':
|
return isFinite(v) ? v : '';
|
|
default:
|
return '';
|
}
|
};
|
|
module.exports = function(obj, sep, eq, name) {
|
sep = sep || '&';
|
eq = eq || '=';
|
if (obj === null) {
|
obj = undefined;
|
}
|
|
if (typeof obj === 'object') {
|
return map(objectKeys(obj), function(k) {
|
var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
|
if (isArray(obj[k])) {
|
return map(obj[k], function(v) {
|
return ks + encodeURIComponent(stringifyPrimitive(v));
|
}).join(sep);
|
} else {
|
return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
|
}
|
}).join(sep);
|
|
}
|
|
if (!name) return '';
|
return encodeURIComponent(stringifyPrimitive(name)) + eq +
|
encodeURIComponent(stringifyPrimitive(obj));
|
};
|
|
var isArray = Array.isArray || function (xs) {
|
return Object.prototype.toString.call(xs) === '[object Array]';
|
};
|
|
function map (xs, f) {
|
if (xs.map) return xs.map(f);
|
var res = [];
|
for (var i = 0; i < xs.length; i++) {
|
res.push(f(xs[i], i));
|
}
|
return res;
|
}
|
|
var objectKeys = Object.keys || function (obj) {
|
var res = [];
|
for (var key in obj) {
|
if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
|
}
|
return res;
|
};
|
|
|
/***/ }),
|
/* 65 */
|
/***/ (function(module, exports, __webpack_require__) {
|
|
var http = __webpack_require__(16)
|
var url = __webpack_require__(26)
|
|
var https = module.exports
|
|
for (var key in http) {
|
if (http.hasOwnProperty(key)) https[key] = http[key]
|
}
|
|
https.request = function (params, cb) {
|
params = validateParams(params)
|
return http.request.call(this, params, cb)
|
}
|
|
https.get = function (params, cb) {
|
params = validateParams(params)
|
return http.get.call(this, params, cb)
|
}
|
|
function validateParams (params) {
|
if (typeof params === 'string') {
|
params = url.parse(params)
|
}
|
if (!params.protocol) {
|
params.protocol = 'https:'
|
}
|
if (params.protocol !== 'https:') {
|
throw new Error('Protocol "' + params.protocol + '" not supported. Expected "https:"')
|
}
|
return params
|
}
|
|
|
/***/ }),
|
/* 66 */
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
"use strict";
|
// ESM COMPAT FLAG
|
__webpack_require__.r(__webpack_exports__);
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/global.js
|
/* harmony default export */ var global = (function(defs) {
|
defs('EPSG:4326', "+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees");
|
defs('EPSG:4269', "+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees");
|
defs('EPSG:3857', "+title=WGS 84 / Pseudo-Mercator +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs");
|
|
defs.WGS84 = defs['EPSG:4326'];
|
defs['EPSG:3785'] = defs['EPSG:3857']; // maintain backward compat, official code is 3857
|
defs.GOOGLE = defs['EPSG:3857'];
|
defs['EPSG:900913'] = defs['EPSG:3857'];
|
defs['EPSG:102113'] = defs['EPSG:3857'];
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/constants/values.js
|
var PJD_3PARAM = 1;
|
var PJD_7PARAM = 2;
|
var PJD_GRIDSHIFT = 3;
|
var PJD_WGS84 = 4; // WGS84 or equivalent
|
var PJD_NODATUM = 5; // WGS84 or equivalent
|
var SRS_WGS84_SEMIMAJOR = 6378137.0; // only used in grid shift transforms
|
var SRS_WGS84_SEMIMINOR = 6356752.314; // only used in grid shift transforms
|
var SRS_WGS84_ESQUARED = 0.0066943799901413165; // only used in grid shift transforms
|
var SEC_TO_RAD = 4.84813681109535993589914102357e-6;
|
var HALF_PI = Math.PI/2;
|
// ellipoid pj_set_ell.c
|
var SIXTH = 0.1666666666666666667;
|
/* 1/6 */
|
var RA4 = 0.04722222222222222222;
|
/* 17/360 */
|
var RA6 = 0.02215608465608465608;
|
var EPSLN = 1.0e-10;
|
// you'd think you could use Number.EPSILON above but that makes
|
// Mollweide get into an infinate loop.
|
|
var D2R = 0.01745329251994329577;
|
var R2D = 57.29577951308232088;
|
var FORTPI = Math.PI/4;
|
var TWO_PI = Math.PI * 2;
|
// SPI is slightly greater than Math.PI, so values that exceed the -180..180
|
// degree range by a tiny amount don't get wrapped. This prevents points that
|
// have drifted from their original location along the 180th meridian (due to
|
// floating point error) from changing their sign.
|
var SPI = 3.14159265359;
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/constants/PrimeMeridian.js
|
var PrimeMeridian_exports = {};
|
|
|
PrimeMeridian_exports.greenwich = 0.0; //"0dE",
|
PrimeMeridian_exports.lisbon = -9.131906111111; //"9d07'54.862\"W",
|
PrimeMeridian_exports.paris = 2.337229166667; //"2d20'14.025\"E",
|
PrimeMeridian_exports.bogota = -74.080916666667; //"74d04'51.3\"W",
|
PrimeMeridian_exports.madrid = -3.687938888889; //"3d41'16.58\"W",
|
PrimeMeridian_exports.rome = 12.452333333333; //"12d27'8.4\"E",
|
PrimeMeridian_exports.bern = 7.439583333333; //"7d26'22.5\"E",
|
PrimeMeridian_exports.jakarta = 106.807719444444; //"106d48'27.79\"E",
|
PrimeMeridian_exports.ferro = -17.666666666667; //"17d40'W",
|
PrimeMeridian_exports.brussels = 4.367975; //"4d22'4.71\"E",
|
PrimeMeridian_exports.stockholm = 18.058277777778; //"18d3'29.8\"E",
|
PrimeMeridian_exports.athens = 23.7163375; //"23d42'58.815\"E",
|
PrimeMeridian_exports.oslo = 10.722916666667; //"10d43'22.5\"E"
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/constants/units.js
|
/* harmony default export */ var units = ({
|
ft: {to_meter: 0.3048},
|
'us-ft': {to_meter: 1200 / 3937}
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/match.js
|
var ignoredChar = /[\s_\-\/\(\)]/g;
|
function match(obj, key) {
|
if (obj[key]) {
|
return obj[key];
|
}
|
var keys = Object.keys(obj);
|
var lkey = key.toLowerCase().replace(ignoredChar, '');
|
var i = -1;
|
var testkey, processedKey;
|
while (++i < keys.length) {
|
testkey = keys[i];
|
processedKey = testkey.toLowerCase().replace(ignoredChar, '');
|
if (processedKey === lkey) {
|
return obj[testkey];
|
}
|
}
|
}
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projString.js
|
|
|
|
|
|
/* harmony default export */ var projString = (function(defData) {
|
var self = {};
|
var paramObj = defData.split('+').map(function(v) {
|
return v.trim();
|
}).filter(function(a) {
|
return a;
|
}).reduce(function(p, a) {
|
var split = a.split('=');
|
split.push(true);
|
p[split[0].toLowerCase()] = split[1];
|
return p;
|
}, {});
|
var paramName, paramVal, paramOutname;
|
var params = {
|
proj: 'projName',
|
datum: 'datumCode',
|
rf: function(v) {
|
self.rf = parseFloat(v);
|
},
|
lat_0: function(v) {
|
self.lat0 = v * D2R;
|
},
|
lat_1: function(v) {
|
self.lat1 = v * D2R;
|
},
|
lat_2: function(v) {
|
self.lat2 = v * D2R;
|
},
|
lat_ts: function(v) {
|
self.lat_ts = v * D2R;
|
},
|
lon_0: function(v) {
|
self.long0 = v * D2R;
|
},
|
lon_1: function(v) {
|
self.long1 = v * D2R;
|
},
|
lon_2: function(v) {
|
self.long2 = v * D2R;
|
},
|
alpha: function(v) {
|
self.alpha = parseFloat(v) * D2R;
|
},
|
gamma: function(v) {
|
self.rectified_grid_angle = parseFloat(v);
|
},
|
lonc: function(v) {
|
self.longc = v * D2R;
|
},
|
x_0: function(v) {
|
self.x0 = parseFloat(v);
|
},
|
y_0: function(v) {
|
self.y0 = parseFloat(v);
|
},
|
k_0: function(v) {
|
self.k0 = parseFloat(v);
|
},
|
k: function(v) {
|
self.k0 = parseFloat(v);
|
},
|
a: function(v) {
|
self.a = parseFloat(v);
|
},
|
b: function(v) {
|
self.b = parseFloat(v);
|
},
|
r_a: function() {
|
self.R_A = true;
|
},
|
zone: function(v) {
|
self.zone = parseInt(v, 10);
|
},
|
south: function() {
|
self.utmSouth = true;
|
},
|
towgs84: function(v) {
|
self.datum_params = v.split(",").map(function(a) {
|
return parseFloat(a);
|
});
|
},
|
to_meter: function(v) {
|
self.to_meter = parseFloat(v);
|
},
|
units: function(v) {
|
self.units = v;
|
var unit = match(units, v);
|
if (unit) {
|
self.to_meter = unit.to_meter;
|
}
|
},
|
from_greenwich: function(v) {
|
self.from_greenwich = v * D2R;
|
},
|
pm: function(v) {
|
var pm = match(PrimeMeridian_exports, v);
|
self.from_greenwich = (pm ? pm : parseFloat(v)) * D2R;
|
},
|
nadgrids: function(v) {
|
if (v === '@null') {
|
self.datumCode = 'none';
|
}
|
else {
|
self.nadgrids = v;
|
}
|
},
|
axis: function(v) {
|
var legalAxis = "ewnsud";
|
if (v.length === 3 && legalAxis.indexOf(v.substr(0, 1)) !== -1 && legalAxis.indexOf(v.substr(1, 1)) !== -1 && legalAxis.indexOf(v.substr(2, 1)) !== -1) {
|
self.axis = v;
|
}
|
},
|
approx: function() {
|
self.approx = true;
|
}
|
};
|
for (paramName in paramObj) {
|
paramVal = paramObj[paramName];
|
if (paramName in params) {
|
paramOutname = params[paramName];
|
if (typeof paramOutname === 'function') {
|
paramOutname(paramVal);
|
}
|
else {
|
self[paramOutname] = paramVal;
|
}
|
}
|
else {
|
self[paramName] = paramVal;
|
}
|
}
|
if(typeof self.datumCode === 'string' && self.datumCode !== "WGS84"){
|
self.datumCode = self.datumCode.toLowerCase();
|
}
|
return self;
|
});
|
|
// CONCATENATED MODULE: ./node_modules/wkt-parser/parser.js
|
/* harmony default export */ var parser = (parseString);
|
|
var NEUTRAL = 1;
|
var KEYWORD = 2;
|
var NUMBER = 3;
|
var QUOTED = 4;
|
var AFTERQUOTE = 5;
|
var ENDED = -1;
|
var whitespace = /\s/;
|
var latin = /[A-Za-z]/;
|
var keyword = /[A-Za-z84_]/;
|
var endThings = /[,\]]/;
|
var digets = /[\d\.E\-\+]/;
|
// const ignoredChar = /[\s_\-\/\(\)]/g;
|
function Parser(text) {
|
if (typeof text !== 'string') {
|
throw new Error('not a string');
|
}
|
this.text = text.trim();
|
this.level = 0;
|
this.place = 0;
|
this.root = null;
|
this.stack = [];
|
this.currentObject = null;
|
this.state = NEUTRAL;
|
}
|
Parser.prototype.readCharicter = function() {
|
var char = this.text[this.place++];
|
if (this.state !== QUOTED) {
|
while (whitespace.test(char)) {
|
if (this.place >= this.text.length) {
|
return;
|
}
|
char = this.text[this.place++];
|
}
|
}
|
switch (this.state) {
|
case NEUTRAL:
|
return this.neutral(char);
|
case KEYWORD:
|
return this.keyword(char)
|
case QUOTED:
|
return this.quoted(char);
|
case AFTERQUOTE:
|
return this.afterquote(char);
|
case NUMBER:
|
return this.number(char);
|
case ENDED:
|
return;
|
}
|
};
|
Parser.prototype.afterquote = function(char) {
|
if (char === '"') {
|
this.word += '"';
|
this.state = QUOTED;
|
return;
|
}
|
if (endThings.test(char)) {
|
this.word = this.word.trim();
|
this.afterItem(char);
|
return;
|
}
|
throw new Error('havn\'t handled "' +char + '" in afterquote yet, index ' + this.place);
|
};
|
Parser.prototype.afterItem = function(char) {
|
if (char === ',') {
|
if (this.word !== null) {
|
this.currentObject.push(this.word);
|
}
|
this.word = null;
|
this.state = NEUTRAL;
|
return;
|
}
|
if (char === ']') {
|
this.level--;
|
if (this.word !== null) {
|
this.currentObject.push(this.word);
|
this.word = null;
|
}
|
this.state = NEUTRAL;
|
this.currentObject = this.stack.pop();
|
if (!this.currentObject) {
|
this.state = ENDED;
|
}
|
|
return;
|
}
|
};
|
Parser.prototype.number = function(char) {
|
if (digets.test(char)) {
|
this.word += char;
|
return;
|
}
|
if (endThings.test(char)) {
|
this.word = parseFloat(this.word);
|
this.afterItem(char);
|
return;
|
}
|
throw new Error('havn\'t handled "' +char + '" in number yet, index ' + this.place);
|
};
|
Parser.prototype.quoted = function(char) {
|
if (char === '"') {
|
this.state = AFTERQUOTE;
|
return;
|
}
|
this.word += char;
|
return;
|
};
|
Parser.prototype.keyword = function(char) {
|
if (keyword.test(char)) {
|
this.word += char;
|
return;
|
}
|
if (char === '[') {
|
var newObjects = [];
|
newObjects.push(this.word);
|
this.level++;
|
if (this.root === null) {
|
this.root = newObjects;
|
} else {
|
this.currentObject.push(newObjects);
|
}
|
this.stack.push(this.currentObject);
|
this.currentObject = newObjects;
|
this.state = NEUTRAL;
|
return;
|
}
|
if (endThings.test(char)) {
|
this.afterItem(char);
|
return;
|
}
|
throw new Error('havn\'t handled "' +char + '" in keyword yet, index ' + this.place);
|
};
|
Parser.prototype.neutral = function(char) {
|
if (latin.test(char)) {
|
this.word = char;
|
this.state = KEYWORD;
|
return;
|
}
|
if (char === '"') {
|
this.word = '';
|
this.state = QUOTED;
|
return;
|
}
|
if (digets.test(char)) {
|
this.word = char;
|
this.state = NUMBER;
|
return;
|
}
|
if (endThings.test(char)) {
|
this.afterItem(char);
|
return;
|
}
|
throw new Error('havn\'t handled "' +char + '" in neutral yet, index ' + this.place);
|
};
|
Parser.prototype.output = function() {
|
while (this.place < this.text.length) {
|
this.readCharicter();
|
}
|
if (this.state === ENDED) {
|
return this.root;
|
}
|
throw new Error('unable to parse string "' +this.text + '". State is ' + this.state);
|
};
|
|
function parseString(txt) {
|
var parser = new Parser(txt);
|
return parser.output();
|
}
|
|
// CONCATENATED MODULE: ./node_modules/wkt-parser/process.js
|
|
|
function mapit(obj, key, value) {
|
if (Array.isArray(key)) {
|
value.unshift(key);
|
key = null;
|
}
|
var thing = key ? {} : obj;
|
|
var out = value.reduce(function(newObj, item) {
|
sExpr(item, newObj);
|
return newObj
|
}, thing);
|
if (key) {
|
obj[key] = out;
|
}
|
}
|
|
function sExpr(v, obj) {
|
if (!Array.isArray(v)) {
|
obj[v] = true;
|
return;
|
}
|
var key = v.shift();
|
if (key === 'PARAMETER') {
|
key = v.shift();
|
}
|
if (v.length === 1) {
|
if (Array.isArray(v[0])) {
|
obj[key] = {};
|
sExpr(v[0], obj[key]);
|
return;
|
}
|
obj[key] = v[0];
|
return;
|
}
|
if (!v.length) {
|
obj[key] = true;
|
return;
|
}
|
if (key === 'TOWGS84') {
|
obj[key] = v;
|
return;
|
}
|
if (key === 'AXIS') {
|
if (!(key in obj)) {
|
obj[key] = [];
|
}
|
obj[key].push(v);
|
return;
|
}
|
if (!Array.isArray(key)) {
|
obj[key] = {};
|
}
|
|
var i;
|
switch (key) {
|
case 'UNIT':
|
case 'PRIMEM':
|
case 'VERT_DATUM':
|
obj[key] = {
|
name: v[0].toLowerCase(),
|
convert: v[1]
|
};
|
if (v.length === 3) {
|
sExpr(v[2], obj[key]);
|
}
|
return;
|
case 'SPHEROID':
|
case 'ELLIPSOID':
|
obj[key] = {
|
name: v[0],
|
a: v[1],
|
rf: v[2]
|
};
|
if (v.length === 4) {
|
sExpr(v[3], obj[key]);
|
}
|
return;
|
case 'PROJECTEDCRS':
|
case 'PROJCRS':
|
case 'GEOGCS':
|
case 'GEOCCS':
|
case 'PROJCS':
|
case 'LOCAL_CS':
|
case 'GEODCRS':
|
case 'GEODETICCRS':
|
case 'GEODETICDATUM':
|
case 'EDATUM':
|
case 'ENGINEERINGDATUM':
|
case 'VERT_CS':
|
case 'VERTCRS':
|
case 'VERTICALCRS':
|
case 'COMPD_CS':
|
case 'COMPOUNDCRS':
|
case 'ENGINEERINGCRS':
|
case 'ENGCRS':
|
case 'FITTED_CS':
|
case 'LOCAL_DATUM':
|
case 'DATUM':
|
v[0] = ['name', v[0]];
|
mapit(obj, key, v);
|
return;
|
default:
|
i = -1;
|
while (++i < v.length) {
|
if (!Array.isArray(v[i])) {
|
return sExpr(v, obj[key]);
|
}
|
}
|
return mapit(obj, key, v);
|
}
|
}
|
|
// CONCATENATED MODULE: ./node_modules/wkt-parser/index.js
|
var wkt_parser_D2R = 0.01745329251994329577;
|
|
|
|
|
|
function rename(obj, params) {
|
var outName = params[0];
|
var inName = params[1];
|
if (!(outName in obj) && (inName in obj)) {
|
obj[outName] = obj[inName];
|
if (params.length === 3) {
|
obj[outName] = params[2](obj[outName]);
|
}
|
}
|
}
|
|
function d2r(input) {
|
return input * wkt_parser_D2R;
|
}
|
|
function cleanWKT(wkt) {
|
if (wkt.type === 'GEOGCS') {
|
wkt.projName = 'longlat';
|
} else if (wkt.type === 'LOCAL_CS') {
|
wkt.projName = 'identity';
|
wkt.local = true;
|
} else {
|
if (typeof wkt.PROJECTION === 'object') {
|
wkt.projName = Object.keys(wkt.PROJECTION)[0];
|
} else {
|
wkt.projName = wkt.PROJECTION;
|
}
|
}
|
if (wkt.AXIS) {
|
var axisOrder = '';
|
for (var i = 0, ii = wkt.AXIS.length; i < ii; ++i) {
|
var axis = [wkt.AXIS[i][0].toLowerCase(), wkt.AXIS[i][1].toLowerCase()];
|
if (axis[0].indexOf('north') !== -1 || ((axis[0] === 'y' || axis[0] === 'lat') && axis[1] === 'north')) {
|
axisOrder += 'n';
|
} else if (axis[0].indexOf('south') !== -1 || ((axis[0] === 'y' || axis[0] === 'lat') && axis[1] === 'south')) {
|
axisOrder += 's';
|
} else if (axis[0].indexOf('east') !== -1 || ((axis[0] === 'x' || axis[0] === 'lon') && axis[1] === 'east')) {
|
axisOrder += 'e';
|
} else if (axis[0].indexOf('west') !== -1 || ((axis[0] === 'x' || axis[0] === 'lon') && axis[1] === 'west')) {
|
axisOrder += 'w';
|
}
|
}
|
if (axisOrder.length === 2) {
|
axisOrder += 'u';
|
}
|
if (axisOrder.length === 3) {
|
wkt.axis = axisOrder;
|
}
|
}
|
if (wkt.UNIT) {
|
wkt.units = wkt.UNIT.name.toLowerCase();
|
if (wkt.units === 'metre') {
|
wkt.units = 'meter';
|
}
|
if (wkt.UNIT.convert) {
|
if (wkt.type === 'GEOGCS') {
|
if (wkt.DATUM && wkt.DATUM.SPHEROID) {
|
wkt.to_meter = wkt.UNIT.convert*wkt.DATUM.SPHEROID.a;
|
}
|
} else {
|
wkt.to_meter = wkt.UNIT.convert;
|
}
|
}
|
}
|
var geogcs = wkt.GEOGCS;
|
if (wkt.type === 'GEOGCS') {
|
geogcs = wkt;
|
}
|
if (geogcs) {
|
//if(wkt.GEOGCS.PRIMEM&&wkt.GEOGCS.PRIMEM.convert){
|
// wkt.from_greenwich=wkt.GEOGCS.PRIMEM.convert*D2R;
|
//}
|
if (geogcs.DATUM) {
|
wkt.datumCode = geogcs.DATUM.name.toLowerCase();
|
} else {
|
wkt.datumCode = geogcs.name.toLowerCase();
|
}
|
if (wkt.datumCode.slice(0, 2) === 'd_') {
|
wkt.datumCode = wkt.datumCode.slice(2);
|
}
|
if (wkt.datumCode === 'new_zealand_geodetic_datum_1949' || wkt.datumCode === 'new_zealand_1949') {
|
wkt.datumCode = 'nzgd49';
|
}
|
if (wkt.datumCode === 'wgs_1984' || wkt.datumCode === 'world_geodetic_system_1984') {
|
if (wkt.PROJECTION === 'Mercator_Auxiliary_Sphere') {
|
wkt.sphere = true;
|
}
|
wkt.datumCode = 'wgs84';
|
}
|
if (wkt.datumCode.slice(-6) === '_ferro') {
|
wkt.datumCode = wkt.datumCode.slice(0, - 6);
|
}
|
if (wkt.datumCode.slice(-8) === '_jakarta') {
|
wkt.datumCode = wkt.datumCode.slice(0, - 8);
|
}
|
if (~wkt.datumCode.indexOf('belge')) {
|
wkt.datumCode = 'rnb72';
|
}
|
if (geogcs.DATUM && geogcs.DATUM.SPHEROID) {
|
wkt.ellps = geogcs.DATUM.SPHEROID.name.replace('_19', '').replace(/[Cc]larke\_18/, 'clrk');
|
if (wkt.ellps.toLowerCase().slice(0, 13) === 'international') {
|
wkt.ellps = 'intl';
|
}
|
|
wkt.a = geogcs.DATUM.SPHEROID.a;
|
wkt.rf = parseFloat(geogcs.DATUM.SPHEROID.rf, 10);
|
}
|
|
if (geogcs.DATUM && geogcs.DATUM.TOWGS84) {
|
wkt.datum_params = geogcs.DATUM.TOWGS84;
|
}
|
if (~wkt.datumCode.indexOf('osgb_1936')) {
|
wkt.datumCode = 'osgb36';
|
}
|
if (~wkt.datumCode.indexOf('osni_1952')) {
|
wkt.datumCode = 'osni52';
|
}
|
if (~wkt.datumCode.indexOf('tm65')
|
|| ~wkt.datumCode.indexOf('geodetic_datum_of_1965')) {
|
wkt.datumCode = 'ire65';
|
}
|
if (wkt.datumCode === 'ch1903+') {
|
wkt.datumCode = 'ch1903';
|
}
|
if (~wkt.datumCode.indexOf('israel')) {
|
wkt.datumCode = 'isr93';
|
}
|
}
|
if (wkt.b && !isFinite(wkt.b)) {
|
wkt.b = wkt.a;
|
}
|
|
function toMeter(input) {
|
var ratio = wkt.to_meter || 1;
|
return input * ratio;
|
}
|
var renamer = function(a) {
|
return rename(wkt, a);
|
};
|
var list = [
|
['standard_parallel_1', 'Standard_Parallel_1'],
|
['standard_parallel_1', 'Latitude of 1st standard parallel'],
|
['standard_parallel_2', 'Standard_Parallel_2'],
|
['standard_parallel_2', 'Latitude of 2nd standard parallel'],
|
['false_easting', 'False_Easting'],
|
['false_easting', 'False easting'],
|
['false-easting', 'Easting at false origin'],
|
['false_northing', 'False_Northing'],
|
['false_northing', 'False northing'],
|
['false_northing', 'Northing at false origin'],
|
['central_meridian', 'Central_Meridian'],
|
['central_meridian', 'Longitude of natural origin'],
|
['central_meridian', 'Longitude of false origin'],
|
['latitude_of_origin', 'Latitude_Of_Origin'],
|
['latitude_of_origin', 'Central_Parallel'],
|
['latitude_of_origin', 'Latitude of natural origin'],
|
['latitude_of_origin', 'Latitude of false origin'],
|
['scale_factor', 'Scale_Factor'],
|
['k0', 'scale_factor'],
|
['latitude_of_center', 'Latitude_Of_Center'],
|
['latitude_of_center', 'Latitude_of_center'],
|
['lat0', 'latitude_of_center', d2r],
|
['longitude_of_center', 'Longitude_Of_Center'],
|
['longitude_of_center', 'Longitude_of_center'],
|
['longc', 'longitude_of_center', d2r],
|
['x0', 'false_easting', toMeter],
|
['y0', 'false_northing', toMeter],
|
['long0', 'central_meridian', d2r],
|
['lat0', 'latitude_of_origin', d2r],
|
['lat0', 'standard_parallel_1', d2r],
|
['lat1', 'standard_parallel_1', d2r],
|
['lat2', 'standard_parallel_2', d2r],
|
['azimuth', 'Azimuth'],
|
['alpha', 'azimuth', d2r],
|
['srsCode', 'name']
|
];
|
list.forEach(renamer);
|
if (!wkt.long0 && wkt.longc && (wkt.projName === 'Albers_Conic_Equal_Area' || wkt.projName === 'Lambert_Azimuthal_Equal_Area')) {
|
wkt.long0 = wkt.longc;
|
}
|
if (!wkt.lat_ts && wkt.lat1 && (wkt.projName === 'Stereographic_South_Pole' || wkt.projName === 'Polar Stereographic (variant B)')) {
|
wkt.lat0 = d2r(wkt.lat1 > 0 ? 90 : -90);
|
wkt.lat_ts = wkt.lat1;
|
}
|
}
|
/* harmony default export */ var wkt_parser = (function(wkt) {
|
var lisp = parser(wkt);
|
var type = lisp.shift();
|
var name = lisp.shift();
|
lisp.unshift(['name', name]);
|
lisp.unshift(['type', type]);
|
var obj = {};
|
sExpr(lisp, obj);
|
cleanWKT(obj);
|
return obj;
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/defs.js
|
|
|
|
|
function defs(name) {
|
/*global console*/
|
var that = this;
|
if (arguments.length === 2) {
|
var def = arguments[1];
|
if (typeof def === 'string') {
|
if (def.charAt(0) === '+') {
|
defs[name] = projString(arguments[1]);
|
}
|
else {
|
defs[name] = wkt_parser(arguments[1]);
|
}
|
} else {
|
defs[name] = def;
|
}
|
}
|
else if (arguments.length === 1) {
|
if (Array.isArray(name)) {
|
return name.map(function(v) {
|
if (Array.isArray(v)) {
|
defs.apply(that, v);
|
}
|
else {
|
defs(v);
|
}
|
});
|
}
|
else if (typeof name === 'string') {
|
if (name in defs) {
|
return defs[name];
|
}
|
}
|
else if ('EPSG' in name) {
|
defs['EPSG:' + name.EPSG] = name;
|
}
|
else if ('ESRI' in name) {
|
defs['ESRI:' + name.ESRI] = name;
|
}
|
else if ('IAU2000' in name) {
|
defs['IAU2000:' + name.IAU2000] = name;
|
}
|
else {
|
console.log(name);
|
}
|
return;
|
}
|
|
|
}
|
global(defs);
|
/* harmony default export */ var lib_defs = (defs);
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/parseCode.js
|
|
|
|
|
function testObj(code){
|
return typeof code === 'string';
|
}
|
function testDef(code){
|
return code in lib_defs;
|
}
|
var codeWords = ['PROJECTEDCRS', 'PROJCRS', 'GEOGCS','GEOCCS','PROJCS','LOCAL_CS', 'GEODCRS', 'GEODETICCRS', 'GEODETICDATUM', 'ENGCRS', 'ENGINEERINGCRS'];
|
function testWKT(code){
|
return codeWords.some(function (word) {
|
return code.indexOf(word) > -1;
|
});
|
}
|
var codes = ['3857', '900913', '3785', '102113'];
|
function checkMercator(item) {
|
var auth = match(item, 'authority');
|
if (!auth) {
|
return;
|
}
|
var code = match(auth, 'epsg');
|
return code && codes.indexOf(code) > -1;
|
}
|
function checkProjStr(item) {
|
var ext = match(item, 'extension');
|
if (!ext) {
|
return;
|
}
|
return match(ext, 'proj4');
|
}
|
function testProj(code){
|
return code[0] === '+';
|
}
|
function parse(code){
|
if (testObj(code)) {
|
//check to see if this is a WKT string
|
if (testDef(code)) {
|
return lib_defs[code];
|
}
|
if (testWKT(code)) {
|
var out = wkt_parser(code);
|
// test of spetial case, due to this being a very common and often malformed
|
if (checkMercator(out)) {
|
return lib_defs['EPSG:3857'];
|
}
|
var maybeProjStr = checkProjStr(out);
|
if (maybeProjStr) {
|
return projString(maybeProjStr);
|
}
|
return out;
|
}
|
if (testProj(code)) {
|
return projString(code);
|
}
|
}else{
|
return code;
|
}
|
}
|
|
/* harmony default export */ var parseCode = (parse);
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/extend.js
|
/* harmony default export */ var extend = (function(destination, source) {
|
destination = destination || {};
|
var value, property;
|
if (!source) {
|
return destination;
|
}
|
for (property in source) {
|
value = source[property];
|
if (value !== undefined) {
|
destination[property] = value;
|
}
|
}
|
return destination;
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/msfnz.js
|
/* harmony default export */ var msfnz = (function(eccent, sinphi, cosphi) {
|
var con = eccent * sinphi;
|
return cosphi / (Math.sqrt(1 - con * con));
|
});
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/sign.js
|
/* harmony default export */ var sign = (function(x) {
|
return x<0 ? -1 : 1;
|
});
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/adjust_lon.js
|
|
|
|
|
/* harmony default export */ var adjust_lon = (function(x) {
|
return (Math.abs(x) <= SPI) ? x : (x - (sign(x) * TWO_PI));
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/tsfnz.js
|
|
|
/* harmony default export */ var tsfnz = (function(eccent, phi, sinphi) {
|
var con = eccent * sinphi;
|
var com = 0.5 * eccent;
|
con = Math.pow(((1 - con) / (1 + con)), com);
|
return (Math.tan(0.5 * (HALF_PI - phi)) / con);
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/phi2z.js
|
|
|
/* harmony default export */ var phi2z = (function(eccent, ts) {
|
var eccnth = 0.5 * eccent;
|
var con, dphi;
|
var phi = HALF_PI - 2 * Math.atan(ts);
|
for (var i = 0; i <= 15; i++) {
|
con = eccent * Math.sin(phi);
|
dphi = HALF_PI - 2 * Math.atan(ts * (Math.pow(((1 - con) / (1 + con)), eccnth))) - phi;
|
phi += dphi;
|
if (Math.abs(dphi) <= 0.0000000001) {
|
return phi;
|
}
|
}
|
//console.log("phi2z has NoConvergence");
|
return -9999;
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/merc.js
|
|
|
|
|
|
|
function init() {
|
var con = this.b / this.a;
|
this.es = 1 - con * con;
|
if(!('x0' in this)){
|
this.x0 = 0;
|
}
|
if(!('y0' in this)){
|
this.y0 = 0;
|
}
|
this.e = Math.sqrt(this.es);
|
if (this.lat_ts) {
|
if (this.sphere) {
|
this.k0 = Math.cos(this.lat_ts);
|
}
|
else {
|
this.k0 = msfnz(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts));
|
}
|
}
|
else {
|
if (!this.k0) {
|
if (this.k) {
|
this.k0 = this.k;
|
}
|
else {
|
this.k0 = 1;
|
}
|
}
|
}
|
}
|
|
/* Mercator forward equations--mapping lat,long to x,y
|
--------------------------------------------------*/
|
|
function forward(p) {
|
var lon = p.x;
|
var lat = p.y;
|
// convert to radians
|
if (lat * R2D > 90 && lat * R2D < -90 && lon * R2D > 180 && lon * R2D < -180) {
|
return null;
|
}
|
|
var x, y;
|
if (Math.abs(Math.abs(lat) - HALF_PI) <= EPSLN) {
|
return null;
|
}
|
else {
|
if (this.sphere) {
|
x = this.x0 + this.a * this.k0 * adjust_lon(lon - this.long0);
|
y = this.y0 + this.a * this.k0 * Math.log(Math.tan(FORTPI + 0.5 * lat));
|
}
|
else {
|
var sinphi = Math.sin(lat);
|
var ts = tsfnz(this.e, lat, sinphi);
|
x = this.x0 + this.a * this.k0 * adjust_lon(lon - this.long0);
|
y = this.y0 - this.a * this.k0 * Math.log(ts);
|
}
|
p.x = x;
|
p.y = y;
|
return p;
|
}
|
}
|
|
/* Mercator inverse equations--mapping x,y to lat/long
|
--------------------------------------------------*/
|
function merc_inverse(p) {
|
|
var x = p.x - this.x0;
|
var y = p.y - this.y0;
|
var lon, lat;
|
|
if (this.sphere) {
|
lat = HALF_PI - 2 * Math.atan(Math.exp(-y / (this.a * this.k0)));
|
}
|
else {
|
var ts = Math.exp(-y / (this.a * this.k0));
|
lat = phi2z(this.e, ts);
|
if (lat === -9999) {
|
return null;
|
}
|
}
|
lon = adjust_lon(this.long0 + x / (this.a * this.k0));
|
|
p.x = lon;
|
p.y = lat;
|
return p;
|
}
|
|
var names = ["Mercator", "Popular Visualisation Pseudo Mercator", "Mercator_1SP", "Mercator_Auxiliary_Sphere", "merc"];
|
/* harmony default export */ var merc = ({
|
init: init,
|
forward: forward,
|
inverse: merc_inverse,
|
names: names
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/longlat.js
|
function longlat_init() {
|
//no-op for longlat
|
}
|
|
function identity(pt) {
|
return pt;
|
}
|
|
|
var longlat_names = ["longlat", "identity"];
|
/* harmony default export */ var longlat = ({
|
init: longlat_init,
|
forward: identity,
|
inverse: identity,
|
names: longlat_names
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections.js
|
|
|
var projs = [merc, longlat];
|
var projections_names = {};
|
var projStore = [];
|
|
function add(proj, i) {
|
var len = projStore.length;
|
if (!proj.names) {
|
console.log(i);
|
return true;
|
}
|
projStore[len] = proj;
|
proj.names.forEach(function(n) {
|
projections_names[n.toLowerCase()] = len;
|
});
|
return this;
|
}
|
|
|
|
function get(name) {
|
if (!name) {
|
return false;
|
}
|
var n = name.toLowerCase();
|
if (typeof projections_names[n] !== 'undefined' && projStore[projections_names[n]]) {
|
return projStore[projections_names[n]];
|
}
|
}
|
|
function start() {
|
projs.forEach(add);
|
}
|
/* harmony default export */ var projections = ({
|
start: start,
|
add: add,
|
get: get
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/constants/Ellipsoid.js
|
var Ellipsoid_exports = {};
|
|
Ellipsoid_exports.MERIT = {
|
a: 6378137.0,
|
rf: 298.257,
|
ellipseName: "MERIT 1983"
|
};
|
|
Ellipsoid_exports.SGS85 = {
|
a: 6378136.0,
|
rf: 298.257,
|
ellipseName: "Soviet Geodetic System 85"
|
};
|
|
Ellipsoid_exports.GRS80 = {
|
a: 6378137.0,
|
rf: 298.257222101,
|
ellipseName: "GRS 1980(IUGG, 1980)"
|
};
|
|
Ellipsoid_exports.IAU76 = {
|
a: 6378140.0,
|
rf: 298.257,
|
ellipseName: "IAU 1976"
|
};
|
|
Ellipsoid_exports.airy = {
|
a: 6377563.396,
|
b: 6356256.910,
|
ellipseName: "Airy 1830"
|
};
|
|
Ellipsoid_exports.APL4 = {
|
a: 6378137,
|
rf: 298.25,
|
ellipseName: "Appl. Physics. 1965"
|
};
|
|
Ellipsoid_exports.NWL9D = {
|
a: 6378145.0,
|
rf: 298.25,
|
ellipseName: "Naval Weapons Lab., 1965"
|
};
|
|
Ellipsoid_exports.mod_airy = {
|
a: 6377340.189,
|
b: 6356034.446,
|
ellipseName: "Modified Airy"
|
};
|
|
Ellipsoid_exports.andrae = {
|
a: 6377104.43,
|
rf: 300.0,
|
ellipseName: "Andrae 1876 (Den., Iclnd.)"
|
};
|
|
Ellipsoid_exports.aust_SA = {
|
a: 6378160.0,
|
rf: 298.25,
|
ellipseName: "Australian Natl & S. Amer. 1969"
|
};
|
|
Ellipsoid_exports.GRS67 = {
|
a: 6378160.0,
|
rf: 298.2471674270,
|
ellipseName: "GRS 67(IUGG 1967)"
|
};
|
|
Ellipsoid_exports.bessel = {
|
a: 6377397.155,
|
rf: 299.1528128,
|
ellipseName: "Bessel 1841"
|
};
|
|
Ellipsoid_exports.bess_nam = {
|
a: 6377483.865,
|
rf: 299.1528128,
|
ellipseName: "Bessel 1841 (Namibia)"
|
};
|
|
Ellipsoid_exports.clrk66 = {
|
a: 6378206.4,
|
b: 6356583.8,
|
ellipseName: "Clarke 1866"
|
};
|
|
Ellipsoid_exports.clrk80 = {
|
a: 6378249.145,
|
rf: 293.4663,
|
ellipseName: "Clarke 1880 mod."
|
};
|
|
Ellipsoid_exports.clrk58 = {
|
a: 6378293.645208759,
|
rf: 294.2606763692654,
|
ellipseName: "Clarke 1858"
|
};
|
|
Ellipsoid_exports.CPM = {
|
a: 6375738.7,
|
rf: 334.29,
|
ellipseName: "Comm. des Poids et Mesures 1799"
|
};
|
|
Ellipsoid_exports.delmbr = {
|
a: 6376428.0,
|
rf: 311.5,
|
ellipseName: "Delambre 1810 (Belgium)"
|
};
|
|
Ellipsoid_exports.engelis = {
|
a: 6378136.05,
|
rf: 298.2566,
|
ellipseName: "Engelis 1985"
|
};
|
|
Ellipsoid_exports.evrst30 = {
|
a: 6377276.345,
|
rf: 300.8017,
|
ellipseName: "Everest 1830"
|
};
|
|
Ellipsoid_exports.evrst48 = {
|
a: 6377304.063,
|
rf: 300.8017,
|
ellipseName: "Everest 1948"
|
};
|
|
Ellipsoid_exports.evrst56 = {
|
a: 6377301.243,
|
rf: 300.8017,
|
ellipseName: "Everest 1956"
|
};
|
|
Ellipsoid_exports.evrst69 = {
|
a: 6377295.664,
|
rf: 300.8017,
|
ellipseName: "Everest 1969"
|
};
|
|
Ellipsoid_exports.evrstSS = {
|
a: 6377298.556,
|
rf: 300.8017,
|
ellipseName: "Everest (Sabah & Sarawak)"
|
};
|
|
Ellipsoid_exports.fschr60 = {
|
a: 6378166.0,
|
rf: 298.3,
|
ellipseName: "Fischer (Mercury Datum) 1960"
|
};
|
|
Ellipsoid_exports.fschr60m = {
|
a: 6378155.0,
|
rf: 298.3,
|
ellipseName: "Fischer 1960"
|
};
|
|
Ellipsoid_exports.fschr68 = {
|
a: 6378150.0,
|
rf: 298.3,
|
ellipseName: "Fischer 1968"
|
};
|
|
Ellipsoid_exports.helmert = {
|
a: 6378200.0,
|
rf: 298.3,
|
ellipseName: "Helmert 1906"
|
};
|
|
Ellipsoid_exports.hough = {
|
a: 6378270.0,
|
rf: 297.0,
|
ellipseName: "Hough"
|
};
|
|
Ellipsoid_exports.intl = {
|
a: 6378388.0,
|
rf: 297.0,
|
ellipseName: "International 1909 (Hayford)"
|
};
|
|
Ellipsoid_exports.kaula = {
|
a: 6378163.0,
|
rf: 298.24,
|
ellipseName: "Kaula 1961"
|
};
|
|
Ellipsoid_exports.lerch = {
|
a: 6378139.0,
|
rf: 298.257,
|
ellipseName: "Lerch 1979"
|
};
|
|
Ellipsoid_exports.mprts = {
|
a: 6397300.0,
|
rf: 191.0,
|
ellipseName: "Maupertius 1738"
|
};
|
|
Ellipsoid_exports.new_intl = {
|
a: 6378157.5,
|
b: 6356772.2,
|
ellipseName: "New International 1967"
|
};
|
|
Ellipsoid_exports.plessis = {
|
a: 6376523.0,
|
rf: 6355863.0,
|
ellipseName: "Plessis 1817 (France)"
|
};
|
|
Ellipsoid_exports.krass = {
|
a: 6378245.0,
|
rf: 298.3,
|
ellipseName: "Krassovsky, 1942"
|
};
|
|
Ellipsoid_exports.SEasia = {
|
a: 6378155.0,
|
b: 6356773.3205,
|
ellipseName: "Southeast Asia"
|
};
|
|
Ellipsoid_exports.walbeck = {
|
a: 6376896.0,
|
b: 6355834.8467,
|
ellipseName: "Walbeck"
|
};
|
|
Ellipsoid_exports.WGS60 = {
|
a: 6378165.0,
|
rf: 298.3,
|
ellipseName: "WGS 60"
|
};
|
|
Ellipsoid_exports.WGS66 = {
|
a: 6378145.0,
|
rf: 298.25,
|
ellipseName: "WGS 66"
|
};
|
|
Ellipsoid_exports.WGS7 = {
|
a: 6378135.0,
|
rf: 298.26,
|
ellipseName: "WGS 72"
|
};
|
|
var WGS84 = Ellipsoid_exports.WGS84 = {
|
a: 6378137.0,
|
rf: 298.257223563,
|
ellipseName: "WGS 84"
|
};
|
|
Ellipsoid_exports.sphere = {
|
a: 6370997.0,
|
b: 6370997.0,
|
ellipseName: "Normal Sphere (r=6370997)"
|
};
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/deriveConstants.js
|
|
|
|
|
function eccentricity(a, b, rf, R_A) {
|
var a2 = a * a; // used in geocentric
|
var b2 = b * b; // used in geocentric
|
var es = (a2 - b2) / a2; // e ^ 2
|
var e = 0;
|
if (R_A) {
|
a *= 1 - es * (SIXTH + es * (RA4 + es * RA6));
|
a2 = a * a;
|
es = 0;
|
} else {
|
e = Math.sqrt(es); // eccentricity
|
}
|
var ep2 = (a2 - b2) / b2; // used in geocentric
|
return {
|
es: es,
|
e: e,
|
ep2: ep2
|
};
|
}
|
function deriveConstants_sphere(a, b, rf, ellps, sphere) {
|
if (!a) { // do we have an ellipsoid?
|
var ellipse = match(Ellipsoid_exports, ellps);
|
if (!ellipse) {
|
ellipse = WGS84;
|
}
|
a = ellipse.a;
|
b = ellipse.b;
|
rf = ellipse.rf;
|
}
|
|
if (rf && !b) {
|
b = (1.0 - 1.0 / rf) * a;
|
}
|
if (rf === 0 || Math.abs(a - b) < EPSLN) {
|
sphere = true;
|
b = a;
|
}
|
return {
|
a: a,
|
b: b,
|
rf: rf,
|
sphere: sphere
|
};
|
}
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/constants/Datum.js
|
var Datum_exports = {};
|
|
Datum_exports.wgs84 = {
|
towgs84: "0,0,0",
|
ellipse: "WGS84",
|
datumName: "WGS84"
|
};
|
|
Datum_exports.ch1903 = {
|
towgs84: "674.374,15.056,405.346",
|
ellipse: "bessel",
|
datumName: "swiss"
|
};
|
|
Datum_exports.ggrs87 = {
|
towgs84: "-199.87,74.79,246.62",
|
ellipse: "GRS80",
|
datumName: "Greek_Geodetic_Reference_System_1987"
|
};
|
|
Datum_exports.nad83 = {
|
towgs84: "0,0,0",
|
ellipse: "GRS80",
|
datumName: "North_American_Datum_1983"
|
};
|
|
Datum_exports.nad27 = {
|
nadgrids: "@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat",
|
ellipse: "clrk66",
|
datumName: "North_American_Datum_1927"
|
};
|
|
Datum_exports.potsdam = {
|
towgs84: "598.1,73.7,418.2,0.202,0.045,-2.455,6.7",
|
ellipse: "bessel",
|
datumName: "Potsdam Rauenberg 1950 DHDN"
|
};
|
|
Datum_exports.carthage = {
|
towgs84: "-263.0,6.0,431.0",
|
ellipse: "clark80",
|
datumName: "Carthage 1934 Tunisia"
|
};
|
|
Datum_exports.hermannskogel = {
|
towgs84: "577.326,90.129,463.919,5.137,1.474,5.297,2.4232",
|
ellipse: "bessel",
|
datumName: "Hermannskogel"
|
};
|
|
Datum_exports.osni52 = {
|
towgs84: "482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",
|
ellipse: "airy",
|
datumName: "Irish National"
|
};
|
|
Datum_exports.ire65 = {
|
towgs84: "482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",
|
ellipse: "mod_airy",
|
datumName: "Ireland 1965"
|
};
|
|
Datum_exports.rassadiran = {
|
towgs84: "-133.63,-157.5,-158.62",
|
ellipse: "intl",
|
datumName: "Rassadiran"
|
};
|
|
Datum_exports.nzgd49 = {
|
towgs84: "59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993",
|
ellipse: "intl",
|
datumName: "New Zealand Geodetic Datum 1949"
|
};
|
|
Datum_exports.osgb36 = {
|
towgs84: "446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894",
|
ellipse: "airy",
|
datumName: "Airy 1830"
|
};
|
|
Datum_exports.s_jtsk = {
|
towgs84: "589,76,480",
|
ellipse: 'bessel',
|
datumName: 'S-JTSK (Ferro)'
|
};
|
|
Datum_exports.beduaram = {
|
towgs84: '-106,-87,188',
|
ellipse: 'clrk80',
|
datumName: 'Beduaram'
|
};
|
|
Datum_exports.gunung_segara = {
|
towgs84: '-403,684,41',
|
ellipse: 'bessel',
|
datumName: 'Gunung Segara Jakarta'
|
};
|
|
Datum_exports.rnb72 = {
|
towgs84: "106.869,-52.2978,103.724,-0.33657,0.456955,-1.84218,1",
|
ellipse: "intl",
|
datumName: "Reseau National Belge 1972"
|
};
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/datum.js
|
|
|
function datum(datumCode, datum_params, a, b, es, ep2, nadgrids) {
|
var out = {};
|
|
if (datumCode === undefined || datumCode === 'none') {
|
out.datum_type = PJD_NODATUM;
|
} else {
|
out.datum_type = PJD_WGS84;
|
}
|
|
if (datum_params) {
|
out.datum_params = datum_params.map(parseFloat);
|
if (out.datum_params[0] !== 0 || out.datum_params[1] !== 0 || out.datum_params[2] !== 0) {
|
out.datum_type = PJD_3PARAM;
|
}
|
if (out.datum_params.length > 3) {
|
if (out.datum_params[3] !== 0 || out.datum_params[4] !== 0 || out.datum_params[5] !== 0 || out.datum_params[6] !== 0) {
|
out.datum_type = PJD_7PARAM;
|
out.datum_params[3] *= SEC_TO_RAD;
|
out.datum_params[4] *= SEC_TO_RAD;
|
out.datum_params[5] *= SEC_TO_RAD;
|
out.datum_params[6] = (out.datum_params[6] / 1000000.0) + 1.0;
|
}
|
}
|
}
|
|
if (nadgrids) {
|
out.datum_type = PJD_GRIDSHIFT;
|
out.grids = nadgrids;
|
}
|
out.a = a; //datum object also uses these values
|
out.b = b;
|
out.es = es;
|
out.ep2 = ep2;
|
return out;
|
}
|
|
/* harmony default export */ var lib_datum = (datum);
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/nadgrid.js
|
/**
|
* Resources for details of NTv2 file formats:
|
* - https://web.archive.org/web/20140127204822if_/http://www.mgs.gov.on.ca:80/stdprodconsume/groups/content/@mgs/@iandit/documents/resourcelist/stel02_047447.pdf
|
* - http://mimaka.com/help/gs/html/004_NTV2%20Data%20Format.htm
|
*/
|
|
var loadedNadgrids = {};
|
|
/**
|
* Load a binary NTv2 file (.gsb) to a key that can be used in a proj string like +nadgrids=<key>. Pass the NTv2 file
|
* as an ArrayBuffer.
|
*/
|
function nadgrid(key, data) {
|
var view = new DataView(data);
|
var isLittleEndian = detectLittleEndian(view);
|
var header = readHeader(view, isLittleEndian);
|
if (header.nSubgrids > 1) {
|
console.log('Only single NTv2 subgrids are currently supported, subsequent sub grids are ignored');
|
}
|
var subgrids = readSubgrids(view, header, isLittleEndian);
|
var nadgrid = {header: header, subgrids: subgrids};
|
loadedNadgrids[key] = nadgrid;
|
return nadgrid;
|
}
|
|
/**
|
* Given a proj4 value for nadgrids, return an array of loaded grids
|
*/
|
function getNadgrids(nadgrids) {
|
// Format details: http://proj.maptools.org/gen_parms.html
|
if (nadgrids === undefined) { return null; }
|
var grids = nadgrids.split(',');
|
return grids.map(parseNadgridString);
|
}
|
|
function parseNadgridString(value) {
|
if (value.length === 0) {
|
return null;
|
}
|
var optional = value[0] === '@';
|
if (optional) {
|
value = value.slice(1);
|
}
|
if (value === 'null') {
|
return {name: 'null', mandatory: !optional, grid: null, isNull: true};
|
}
|
return {
|
name: value,
|
mandatory: !optional,
|
grid: loadedNadgrids[value] || null,
|
isNull: false
|
};
|
}
|
|
function secondsToRadians(seconds) {
|
return (seconds / 3600) * Math.PI / 180;
|
}
|
|
function detectLittleEndian(view) {
|
var nFields = view.getInt32(8, false);
|
if (nFields === 11) {
|
return false;
|
}
|
nFields = view.getInt32(8, true);
|
if (nFields !== 11) {
|
console.warn('Failed to detect nadgrid endian-ness, defaulting to little-endian');
|
}
|
return true;
|
}
|
|
function readHeader(view, isLittleEndian) {
|
return {
|
nFields: view.getInt32(8, isLittleEndian),
|
nSubgridFields: view.getInt32(24, isLittleEndian),
|
nSubgrids: view.getInt32(40, isLittleEndian),
|
shiftType: decodeString(view, 56, 56 + 8).trim(),
|
fromSemiMajorAxis: view.getFloat64(120, isLittleEndian),
|
fromSemiMinorAxis: view.getFloat64(136, isLittleEndian),
|
toSemiMajorAxis: view.getFloat64(152, isLittleEndian),
|
toSemiMinorAxis: view.getFloat64(168, isLittleEndian),
|
};
|
}
|
|
function decodeString(view, start, end) {
|
return String.fromCharCode.apply(null, new Uint8Array(view.buffer.slice(start, end)));
|
}
|
|
function readSubgrids(view, header, isLittleEndian) {
|
var gridOffset = 176;
|
var grids = [];
|
for (var i = 0; i < header.nSubgrids; i++) {
|
var subHeader = readGridHeader(view, gridOffset, isLittleEndian);
|
var nodes = readGridNodes(view, gridOffset, subHeader, isLittleEndian);
|
var lngColumnCount = Math.round(
|
1 + (subHeader.upperLongitude - subHeader.lowerLongitude) / subHeader.longitudeInterval);
|
var latColumnCount = Math.round(
|
1 + (subHeader.upperLatitude - subHeader.lowerLatitude) / subHeader.latitudeInterval);
|
// Proj4 operates on radians whereas the coordinates are in seconds in the grid
|
grids.push({
|
ll: [secondsToRadians(subHeader.lowerLongitude), secondsToRadians(subHeader.lowerLatitude)],
|
del: [secondsToRadians(subHeader.longitudeInterval), secondsToRadians(subHeader.latitudeInterval)],
|
lim: [lngColumnCount, latColumnCount],
|
count: subHeader.gridNodeCount,
|
cvs: mapNodes(nodes)
|
});
|
}
|
return grids;
|
}
|
|
function mapNodes(nodes) {
|
return nodes.map(function (r) {return [secondsToRadians(r.longitudeShift), secondsToRadians(r.latitudeShift)];});
|
}
|
|
function readGridHeader(view, offset, isLittleEndian) {
|
return {
|
name: decodeString(view, offset + 8, offset + 16).trim(),
|
parent: decodeString(view, offset + 24, offset + 24 + 8).trim(),
|
lowerLatitude: view.getFloat64(offset + 72, isLittleEndian),
|
upperLatitude: view.getFloat64(offset + 88, isLittleEndian),
|
lowerLongitude: view.getFloat64(offset + 104, isLittleEndian),
|
upperLongitude: view.getFloat64(offset + 120, isLittleEndian),
|
latitudeInterval: view.getFloat64(offset + 136, isLittleEndian),
|
longitudeInterval: view.getFloat64(offset + 152, isLittleEndian),
|
gridNodeCount: view.getInt32(offset + 168, isLittleEndian)
|
};
|
}
|
|
function readGridNodes(view, offset, gridHeader, isLittleEndian) {
|
var nodesOffset = offset + 176;
|
var gridRecordLength = 16;
|
var gridShiftRecords = [];
|
for (var i = 0; i < gridHeader.gridNodeCount; i++) {
|
var record = {
|
latitudeShift: view.getFloat32(nodesOffset + i * gridRecordLength, isLittleEndian),
|
longitudeShift: view.getFloat32(nodesOffset + i * gridRecordLength + 4, isLittleEndian),
|
latitudeAccuracy: view.getFloat32(nodesOffset + i * gridRecordLength + 8, isLittleEndian),
|
longitudeAccuracy: view.getFloat32(nodesOffset + i * gridRecordLength + 12, isLittleEndian),
|
};
|
gridShiftRecords.push(record);
|
}
|
return gridShiftRecords;
|
}
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/Proj.js
|
|
|
|
|
|
|
|
|
|
function Projection(srsCode,callback) {
|
if (!(this instanceof Projection)) {
|
return new Projection(srsCode);
|
}
|
callback = callback || function(error){
|
if(error){
|
throw error;
|
}
|
};
|
var json = parseCode(srsCode);
|
if(typeof json !== 'object'){
|
callback(srsCode);
|
return;
|
}
|
var ourProj = Projection.projections.get(json.projName);
|
if(!ourProj){
|
callback(srsCode);
|
return;
|
}
|
if (json.datumCode && json.datumCode !== 'none') {
|
var datumDef = match(Datum_exports, json.datumCode);
|
if (datumDef) {
|
json.datum_params = json.datum_params || (datumDef.towgs84 ? datumDef.towgs84.split(',') : null);
|
json.ellps = datumDef.ellipse;
|
json.datumName = datumDef.datumName ? datumDef.datumName : json.datumCode;
|
}
|
}
|
json.k0 = json.k0 || 1.0;
|
json.axis = json.axis || 'enu';
|
json.ellps = json.ellps || 'wgs84';
|
json.lat1 = json.lat1 || json.lat0; // Lambert_Conformal_Conic_1SP, for example, needs this
|
|
var sphere_ = deriveConstants_sphere(json.a, json.b, json.rf, json.ellps, json.sphere);
|
var ecc = eccentricity(sphere_.a, sphere_.b, sphere_.rf, json.R_A);
|
var nadgrids = getNadgrids(json.nadgrids);
|
var datumObj = json.datum || lib_datum(json.datumCode, json.datum_params, sphere_.a, sphere_.b, ecc.es, ecc.ep2,
|
nadgrids);
|
|
extend(this, json); // transfer everything over from the projection because we don't know what we'll need
|
extend(this, ourProj); // transfer all the methods from the projection
|
|
// copy the 4 things over we calculated in deriveConstants.sphere
|
this.a = sphere_.a;
|
this.b = sphere_.b;
|
this.rf = sphere_.rf;
|
this.sphere = sphere_.sphere;
|
|
// copy the 3 things we calculated in deriveConstants.eccentricity
|
this.es = ecc.es;
|
this.e = ecc.e;
|
this.ep2 = ecc.ep2;
|
|
// add in the datum object
|
this.datum = datumObj;
|
|
// init the projection
|
this.init();
|
|
// legecy callback from back in the day when it went to spatialreference.org
|
callback(null, this);
|
|
}
|
Projection.projections = projections;
|
Projection.projections.start();
|
/* harmony default export */ var Proj = (Projection);
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/datumUtils.js
|
|
|
function compareDatums(source, dest) {
|
if (source.datum_type !== dest.datum_type) {
|
return false; // false, datums are not equal
|
} else if (source.a !== dest.a || Math.abs(source.es - dest.es) > 0.000000000050) {
|
// the tolerance for es is to ensure that GRS80 and WGS84
|
// are considered identical
|
return false;
|
} else if (source.datum_type === PJD_3PARAM) {
|
return (source.datum_params[0] === dest.datum_params[0] && source.datum_params[1] === dest.datum_params[1] && source.datum_params[2] === dest.datum_params[2]);
|
} else if (source.datum_type === PJD_7PARAM) {
|
return (source.datum_params[0] === dest.datum_params[0] && source.datum_params[1] === dest.datum_params[1] && source.datum_params[2] === dest.datum_params[2] && source.datum_params[3] === dest.datum_params[3] && source.datum_params[4] === dest.datum_params[4] && source.datum_params[5] === dest.datum_params[5] && source.datum_params[6] === dest.datum_params[6]);
|
} else {
|
return true; // datums are equal
|
}
|
} // cs_compare_datums()
|
|
/*
|
* The function Convert_Geodetic_To_Geocentric converts geodetic coordinates
|
* (latitude, longitude, and height) to geocentric coordinates (X, Y, Z),
|
* according to the current ellipsoid parameters.
|
*
|
* Latitude : Geodetic latitude in radians (input)
|
* Longitude : Geodetic longitude in radians (input)
|
* Height : Geodetic height, in meters (input)
|
* X : Calculated Geocentric X coordinate, in meters (output)
|
* Y : Calculated Geocentric Y coordinate, in meters (output)
|
* Z : Calculated Geocentric Z coordinate, in meters (output)
|
*
|
*/
|
function geodeticToGeocentric(p, es, a) {
|
var Longitude = p.x;
|
var Latitude = p.y;
|
var Height = p.z ? p.z : 0; //Z value not always supplied
|
|
var Rn; /* Earth radius at location */
|
var Sin_Lat; /* Math.sin(Latitude) */
|
var Sin2_Lat; /* Square of Math.sin(Latitude) */
|
var Cos_Lat; /* Math.cos(Latitude) */
|
|
/*
|
** Don't blow up if Latitude is just a little out of the value
|
** range as it may just be a rounding issue. Also removed longitude
|
** test, it should be wrapped by Math.cos() and Math.sin(). NFW for PROJ.4, Sep/2001.
|
*/
|
if (Latitude < -HALF_PI && Latitude > -1.001 * HALF_PI) {
|
Latitude = -HALF_PI;
|
} else if (Latitude > HALF_PI && Latitude < 1.001 * HALF_PI) {
|
Latitude = HALF_PI;
|
} else if (Latitude < -HALF_PI) {
|
/* Latitude out of range */
|
//..reportError('geocent:lat out of range:' + Latitude);
|
return { x: -Infinity, y: -Infinity, z: p.z };
|
} else if (Latitude > HALF_PI) {
|
/* Latitude out of range */
|
return { x: Infinity, y: Infinity, z: p.z };
|
}
|
|
if (Longitude > Math.PI) {
|
Longitude -= (2 * Math.PI);
|
}
|
Sin_Lat = Math.sin(Latitude);
|
Cos_Lat = Math.cos(Latitude);
|
Sin2_Lat = Sin_Lat * Sin_Lat;
|
Rn = a / (Math.sqrt(1.0e0 - es * Sin2_Lat));
|
return {
|
x: (Rn + Height) * Cos_Lat * Math.cos(Longitude),
|
y: (Rn + Height) * Cos_Lat * Math.sin(Longitude),
|
z: ((Rn * (1 - es)) + Height) * Sin_Lat
|
};
|
} // cs_geodetic_to_geocentric()
|
|
function geocentricToGeodetic(p, es, a, b) {
|
/* local defintions and variables */
|
/* end-criterium of loop, accuracy of sin(Latitude) */
|
var genau = 1e-12;
|
var genau2 = (genau * genau);
|
var maxiter = 30;
|
|
var P; /* distance between semi-minor axis and location */
|
var RR; /* distance between center and location */
|
var CT; /* sin of geocentric latitude */
|
var ST; /* cos of geocentric latitude */
|
var RX;
|
var RK;
|
var RN; /* Earth radius at location */
|
var CPHI0; /* cos of start or old geodetic latitude in iterations */
|
var SPHI0; /* sin of start or old geodetic latitude in iterations */
|
var CPHI; /* cos of searched geodetic latitude */
|
var SPHI; /* sin of searched geodetic latitude */
|
var SDPHI; /* end-criterium: addition-theorem of sin(Latitude(iter)-Latitude(iter-1)) */
|
var iter; /* # of continous iteration, max. 30 is always enough (s.a.) */
|
|
var X = p.x;
|
var Y = p.y;
|
var Z = p.z ? p.z : 0.0; //Z value not always supplied
|
var Longitude;
|
var Latitude;
|
var Height;
|
|
P = Math.sqrt(X * X + Y * Y);
|
RR = Math.sqrt(X * X + Y * Y + Z * Z);
|
|
/* special cases for latitude and longitude */
|
if (P / a < genau) {
|
|
/* special case, if P=0. (X=0., Y=0.) */
|
Longitude = 0.0;
|
|
/* if (X,Y,Z)=(0.,0.,0.) then Height becomes semi-minor axis
|
* of ellipsoid (=center of mass), Latitude becomes PI/2 */
|
if (RR / a < genau) {
|
Latitude = HALF_PI;
|
Height = -b;
|
return {
|
x: p.x,
|
y: p.y,
|
z: p.z
|
};
|
}
|
} else {
|
/* ellipsoidal (geodetic) longitude
|
* interval: -PI < Longitude <= +PI */
|
Longitude = Math.atan2(Y, X);
|
}
|
|
/* --------------------------------------------------------------
|
* Following iterative algorithm was developped by
|
* "Institut for Erdmessung", University of Hannover, July 1988.
|
* Internet: www.ife.uni-hannover.de
|
* Iterative computation of CPHI,SPHI and Height.
|
* Iteration of CPHI and SPHI to 10**-12 radian resp.
|
* 2*10**-7 arcsec.
|
* --------------------------------------------------------------
|
*/
|
CT = Z / RR;
|
ST = P / RR;
|
RX = 1.0 / Math.sqrt(1.0 - es * (2.0 - es) * ST * ST);
|
CPHI0 = ST * (1.0 - es) * RX;
|
SPHI0 = CT * RX;
|
iter = 0;
|
|
/* loop to find sin(Latitude) resp. Latitude
|
* until |sin(Latitude(iter)-Latitude(iter-1))| < genau */
|
do {
|
iter++;
|
RN = a / Math.sqrt(1.0 - es * SPHI0 * SPHI0);
|
|
/* ellipsoidal (geodetic) height */
|
Height = P * CPHI0 + Z * SPHI0 - RN * (1.0 - es * SPHI0 * SPHI0);
|
|
RK = es * RN / (RN + Height);
|
RX = 1.0 / Math.sqrt(1.0 - RK * (2.0 - RK) * ST * ST);
|
CPHI = ST * (1.0 - RK) * RX;
|
SPHI = CT * RX;
|
SDPHI = SPHI * CPHI0 - CPHI * SPHI0;
|
CPHI0 = CPHI;
|
SPHI0 = SPHI;
|
}
|
while (SDPHI * SDPHI > genau2 && iter < maxiter);
|
|
/* ellipsoidal (geodetic) latitude */
|
Latitude = Math.atan(SPHI / Math.abs(CPHI));
|
return {
|
x: Longitude,
|
y: Latitude,
|
z: Height
|
};
|
} // cs_geocentric_to_geodetic()
|
|
/****************************************************************/
|
// pj_geocentic_to_wgs84( p )
|
// p = point to transform in geocentric coordinates (x,y,z)
|
|
|
/** point object, nothing fancy, just allows values to be
|
passed back and forth by reference rather than by value.
|
Other point classes may be used as long as they have
|
x and y properties, which will get modified in the transform method.
|
*/
|
function geocentricToWgs84(p, datum_type, datum_params) {
|
|
if (datum_type === PJD_3PARAM) {
|
// if( x[io] === HUGE_VAL )
|
// continue;
|
return {
|
x: p.x + datum_params[0],
|
y: p.y + datum_params[1],
|
z: p.z + datum_params[2],
|
};
|
} else if (datum_type === PJD_7PARAM) {
|
var Dx_BF = datum_params[0];
|
var Dy_BF = datum_params[1];
|
var Dz_BF = datum_params[2];
|
var Rx_BF = datum_params[3];
|
var Ry_BF = datum_params[4];
|
var Rz_BF = datum_params[5];
|
var M_BF = datum_params[6];
|
// if( x[io] === HUGE_VAL )
|
// continue;
|
return {
|
x: M_BF * (p.x - Rz_BF * p.y + Ry_BF * p.z) + Dx_BF,
|
y: M_BF * (Rz_BF * p.x + p.y - Rx_BF * p.z) + Dy_BF,
|
z: M_BF * (-Ry_BF * p.x + Rx_BF * p.y + p.z) + Dz_BF
|
};
|
}
|
} // cs_geocentric_to_wgs84
|
|
/****************************************************************/
|
// pj_geocentic_from_wgs84()
|
// coordinate system definition,
|
// point to transform in geocentric coordinates (x,y,z)
|
function geocentricFromWgs84(p, datum_type, datum_params) {
|
|
if (datum_type === PJD_3PARAM) {
|
//if( x[io] === HUGE_VAL )
|
// continue;
|
return {
|
x: p.x - datum_params[0],
|
y: p.y - datum_params[1],
|
z: p.z - datum_params[2],
|
};
|
|
} else if (datum_type === PJD_7PARAM) {
|
var Dx_BF = datum_params[0];
|
var Dy_BF = datum_params[1];
|
var Dz_BF = datum_params[2];
|
var Rx_BF = datum_params[3];
|
var Ry_BF = datum_params[4];
|
var Rz_BF = datum_params[5];
|
var M_BF = datum_params[6];
|
var x_tmp = (p.x - Dx_BF) / M_BF;
|
var y_tmp = (p.y - Dy_BF) / M_BF;
|
var z_tmp = (p.z - Dz_BF) / M_BF;
|
//if( x[io] === HUGE_VAL )
|
// continue;
|
|
return {
|
x: x_tmp + Rz_BF * y_tmp - Ry_BF * z_tmp,
|
y: -Rz_BF * x_tmp + y_tmp + Rx_BF * z_tmp,
|
z: Ry_BF * x_tmp - Rx_BF * y_tmp + z_tmp
|
};
|
} //cs_geocentric_from_wgs84()
|
}
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/datum_transform.js
|
|
|
|
|
function checkParams(type) {
|
return (type === PJD_3PARAM || type === PJD_7PARAM);
|
}
|
|
/* harmony default export */ var datum_transform = (function(source, dest, point) {
|
// Short cut if the datums are identical.
|
if (compareDatums(source, dest)) {
|
return point; // in this case, zero is sucess,
|
// whereas cs_compare_datums returns 1 to indicate TRUE
|
// confusing, should fix this
|
}
|
|
// Explicitly skip datum transform by setting 'datum=none' as parameter for either source or dest
|
if (source.datum_type === PJD_NODATUM || dest.datum_type === PJD_NODATUM) {
|
return point;
|
}
|
|
// If this datum requires grid shifts, then apply it to geodetic coordinates.
|
var source_a = source.a;
|
var source_es = source.es;
|
if (source.datum_type === PJD_GRIDSHIFT) {
|
var gridShiftCode = applyGridShift(source, false, point);
|
if (gridShiftCode !== 0) {
|
return undefined;
|
}
|
source_a = SRS_WGS84_SEMIMAJOR;
|
source_es = SRS_WGS84_ESQUARED;
|
}
|
|
var dest_a = dest.a;
|
var dest_b = dest.b;
|
var dest_es = dest.es;
|
if (dest.datum_type === PJD_GRIDSHIFT) {
|
dest_a = SRS_WGS84_SEMIMAJOR;
|
dest_b = SRS_WGS84_SEMIMINOR;
|
dest_es = SRS_WGS84_ESQUARED;
|
}
|
|
// Do we need to go through geocentric coordinates?
|
if (source_es === dest_es && source_a === dest_a && !checkParams(source.datum_type) && !checkParams(dest.datum_type)) {
|
return point;
|
}
|
|
// Convert to geocentric coordinates.
|
point = geodeticToGeocentric(point, source_es, source_a);
|
// Convert between datums
|
if (checkParams(source.datum_type)) {
|
point = geocentricToWgs84(point, source.datum_type, source.datum_params);
|
}
|
if (checkParams(dest.datum_type)) {
|
point = geocentricFromWgs84(point, dest.datum_type, dest.datum_params);
|
}
|
point = geocentricToGeodetic(point, dest_es, dest_a, dest_b);
|
|
if (dest.datum_type === PJD_GRIDSHIFT) {
|
var destGridShiftResult = applyGridShift(dest, true, point);
|
if (destGridShiftResult !== 0) {
|
return undefined;
|
}
|
}
|
|
return point;
|
});
|
|
function applyGridShift(source, inverse, point) {
|
if (source.grids === null || source.grids.length === 0) {
|
console.log('Grid shift grids not found');
|
return -1;
|
}
|
var input = {x: -point.x, y: point.y};
|
var output = {x: Number.NaN, y: Number.NaN};
|
var onlyMandatoryGrids = false;
|
var attemptedGrids = [];
|
for (var i = 0; i < source.grids.length; i++) {
|
var grid = source.grids[i];
|
attemptedGrids.push(grid.name);
|
if (grid.isNull) {
|
output = input;
|
break;
|
}
|
onlyMandatoryGrids = grid.mandatory;
|
if (grid.grid === null) {
|
if (grid.mandatory) {
|
console.log("Unable to find mandatory grid '" + grid.name + "'");
|
return -1;
|
}
|
continue;
|
}
|
var subgrid = grid.grid.subgrids[0];
|
// skip tables that don't match our point at all
|
var epsilon = (Math.abs(subgrid.del[1]) + Math.abs(subgrid.del[0])) / 10000.0;
|
var minX = subgrid.ll[0] - epsilon;
|
var minY = subgrid.ll[1] - epsilon;
|
var maxX = subgrid.ll[0] + (subgrid.lim[0] - 1) * subgrid.del[0] + epsilon;
|
var maxY = subgrid.ll[1] + (subgrid.lim[1] - 1) * subgrid.del[1] + epsilon;
|
if (minY > input.y || minX > input.x || maxY < input.y || maxX < input.x ) {
|
continue;
|
}
|
output = applySubgridShift(input, inverse, subgrid);
|
if (!isNaN(output.x)) {
|
break;
|
}
|
}
|
if (isNaN(output.x)) {
|
console.log("Failed to find a grid shift table for location '"+
|
-input.x * R2D + " " + input.y * R2D + " tried: '" + attemptedGrids + "'");
|
return -1;
|
}
|
point.x = -output.x;
|
point.y = output.y;
|
return 0;
|
}
|
|
function applySubgridShift(pin, inverse, ct) {
|
var val = {x: Number.NaN, y: Number.NaN};
|
if (isNaN(pin.x)) { return val; }
|
var tb = {x: pin.x, y: pin.y};
|
tb.x -= ct.ll[0];
|
tb.y -= ct.ll[1];
|
tb.x = adjust_lon(tb.x - Math.PI) + Math.PI;
|
var t = nadInterpolate(tb, ct);
|
if (inverse) {
|
if (isNaN(t.x)) {
|
return val;
|
}
|
t.x = tb.x - t.x;
|
t.y = tb.y - t.y;
|
var i = 9, tol = 1e-12;
|
var dif, del;
|
do {
|
del = nadInterpolate(t, ct);
|
if (isNaN(del.x)) {
|
console.log("Inverse grid shift iteration failed, presumably at grid edge. Using first approximation.");
|
break;
|
}
|
dif = {x: tb.x - (del.x + t.x), y: tb.y - (del.y + t.y)};
|
t.x += dif.x;
|
t.y += dif.y;
|
} while (i-- && Math.abs(dif.x) > tol && Math.abs(dif.y) > tol);
|
if (i < 0) {
|
console.log("Inverse grid shift iterator failed to converge.");
|
return val;
|
}
|
val.x = adjust_lon(t.x + ct.ll[0]);
|
val.y = t.y + ct.ll[1];
|
} else {
|
if (!isNaN(t.x)) {
|
val.x = pin.x + t.x;
|
val.y = pin.y + t.y;
|
}
|
}
|
return val;
|
}
|
|
function nadInterpolate(pin, ct) {
|
var t = {x: pin.x / ct.del[0], y: pin.y / ct.del[1]};
|
var indx = {x: Math.floor(t.x), y: Math.floor(t.y)};
|
var frct = {x: t.x - 1.0 * indx.x, y: t.y - 1.0 * indx.y};
|
var val= {x: Number.NaN, y: Number.NaN};
|
var inx;
|
if (indx.x < 0 || indx.x >= ct.lim[0]) {
|
return val;
|
}
|
if (indx.y < 0 || indx.y >= ct.lim[1]) {
|
return val;
|
}
|
inx = (indx.y * ct.lim[0]) + indx.x;
|
var f00 = {x: ct.cvs[inx][0], y: ct.cvs[inx][1]};
|
inx++;
|
var f10= {x: ct.cvs[inx][0], y: ct.cvs[inx][1]};
|
inx += ct.lim[0];
|
var f11 = {x: ct.cvs[inx][0], y: ct.cvs[inx][1]};
|
inx--;
|
var f01 = {x: ct.cvs[inx][0], y: ct.cvs[inx][1]};
|
var m11 = frct.x * frct.y, m10 = frct.x * (1.0 - frct.y),
|
m00 = (1.0 - frct.x) * (1.0 - frct.y), m01 = (1.0 - frct.x) * frct.y;
|
val.x = (m00 * f00.x + m10 * f10.x + m01 * f01.x + m11 * f11.x);
|
val.y = (m00 * f00.y + m10 * f10.y + m01 * f01.y + m11 * f11.y);
|
return val;
|
}
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/adjust_axis.js
|
/* harmony default export */ var adjust_axis = (function(crs, denorm, point) {
|
var xin = point.x,
|
yin = point.y,
|
zin = point.z || 0.0;
|
var v, t, i;
|
var out = {};
|
for (i = 0; i < 3; i++) {
|
if (denorm && i === 2 && point.z === undefined) {
|
continue;
|
}
|
if (i === 0) {
|
v = xin;
|
if ("ew".indexOf(crs.axis[i]) !== -1) {
|
t = 'x';
|
} else {
|
t = 'y';
|
}
|
|
}
|
else if (i === 1) {
|
v = yin;
|
if ("ns".indexOf(crs.axis[i]) !== -1) {
|
t = 'y';
|
} else {
|
t = 'x';
|
}
|
}
|
else {
|
v = zin;
|
t = 'z';
|
}
|
switch (crs.axis[i]) {
|
case 'e':
|
out[t] = v;
|
break;
|
case 'w':
|
out[t] = -v;
|
break;
|
case 'n':
|
out[t] = v;
|
break;
|
case 's':
|
out[t] = -v;
|
break;
|
case 'u':
|
if (point[t] !== undefined) {
|
out.z = v;
|
}
|
break;
|
case 'd':
|
if (point[t] !== undefined) {
|
out.z = -v;
|
}
|
break;
|
default:
|
//console.log("ERROR: unknow axis ("+crs.axis[i]+") - check definition of "+crs.projName);
|
return null;
|
}
|
}
|
return out;
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/toPoint.js
|
/* harmony default export */ var toPoint = (function (array){
|
var out = {
|
x: array[0],
|
y: array[1]
|
};
|
if (array.length>2) {
|
out.z = array[2];
|
}
|
if (array.length>3) {
|
out.m = array[3];
|
}
|
return out;
|
});
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/checkSanity.js
|
/* harmony default export */ var checkSanity = (function (point) {
|
checkCoord(point.x);
|
checkCoord(point.y);
|
});
|
function checkCoord(num) {
|
if (typeof Number.isFinite === 'function') {
|
if (Number.isFinite(num)) {
|
return;
|
}
|
throw new TypeError('coordinates must be finite numbers');
|
}
|
if (typeof num !== 'number' || num !== num || !isFinite(num)) {
|
throw new TypeError('coordinates must be finite numbers');
|
}
|
}
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/transform.js
|
|
|
|
|
|
|
|
function checkNotWGS(source, dest) {
|
return ((source.datum.datum_type === PJD_3PARAM || source.datum.datum_type === PJD_7PARAM) && dest.datumCode !== 'WGS84') || ((dest.datum.datum_type === PJD_3PARAM || dest.datum.datum_type === PJD_7PARAM) && source.datumCode !== 'WGS84');
|
}
|
|
function transform(source, dest, point, enforceAxis) {
|
var wgs84;
|
if (Array.isArray(point)) {
|
point = toPoint(point);
|
}
|
checkSanity(point);
|
// Workaround for datum shifts towgs84, if either source or destination projection is not wgs84
|
if (source.datum && dest.datum && checkNotWGS(source, dest)) {
|
wgs84 = new Proj('WGS84');
|
point = transform(source, wgs84, point, enforceAxis);
|
source = wgs84;
|
}
|
// DGR, 2010/11/12
|
if (enforceAxis && source.axis !== 'enu') {
|
point = adjust_axis(source, false, point);
|
}
|
// Transform source points to long/lat, if they aren't already.
|
if (source.projName === 'longlat') {
|
point = {
|
x: point.x * D2R,
|
y: point.y * D2R,
|
z: point.z || 0
|
};
|
} else {
|
if (source.to_meter) {
|
point = {
|
x: point.x * source.to_meter,
|
y: point.y * source.to_meter,
|
z: point.z || 0
|
};
|
}
|
point = source.inverse(point); // Convert Cartesian to longlat
|
if (!point) {
|
return;
|
}
|
}
|
// Adjust for the prime meridian if necessary
|
if (source.from_greenwich) {
|
point.x += source.from_greenwich;
|
}
|
|
// Convert datums if needed, and if possible.
|
point = datum_transform(source.datum, dest.datum, point);
|
if (!point) {
|
return;
|
}
|
|
// Adjust for the prime meridian if necessary
|
if (dest.from_greenwich) {
|
point = {
|
x: point.x - dest.from_greenwich,
|
y: point.y,
|
z: point.z || 0
|
};
|
}
|
|
if (dest.projName === 'longlat') {
|
// convert radians to decimal degrees
|
point = {
|
x: point.x * R2D,
|
y: point.y * R2D,
|
z: point.z || 0
|
};
|
} else { // else project
|
point = dest.forward(point);
|
if (dest.to_meter) {
|
point = {
|
x: point.x / dest.to_meter,
|
y: point.y / dest.to_meter,
|
z: point.z || 0
|
};
|
}
|
}
|
|
// DGR, 2010/11/12
|
if (enforceAxis && dest.axis !== 'enu') {
|
return adjust_axis(dest, true, point);
|
}
|
|
return point;
|
}
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/core.js
|
|
|
var core_wgs84 = Proj('WGS84');
|
|
function transformer(from, to, coords, enforceAxis) {
|
var transformedArray, out, keys;
|
if (Array.isArray(coords)) {
|
transformedArray = transform(from, to, coords, enforceAxis) || {x: NaN, y: NaN};
|
if (coords.length > 2) {
|
if ((typeof from.name !== 'undefined' && from.name === 'geocent') || (typeof to.name !== 'undefined' && to.name === 'geocent')) {
|
if (typeof transformedArray.z === 'number') {
|
return [transformedArray.x, transformedArray.y, transformedArray.z].concat(coords.splice(3));
|
} else {
|
return [transformedArray.x, transformedArray.y, coords[2]].concat(coords.splice(3));
|
}
|
} else {
|
return [transformedArray.x, transformedArray.y].concat(coords.splice(2));
|
}
|
} else {
|
return [transformedArray.x, transformedArray.y];
|
}
|
} else {
|
out = transform(from, to, coords, enforceAxis);
|
keys = Object.keys(coords);
|
if (keys.length === 2) {
|
return out;
|
}
|
keys.forEach(function (key) {
|
if ((typeof from.name !== 'undefined' && from.name === 'geocent') || (typeof to.name !== 'undefined' && to.name === 'geocent')) {
|
if (key === 'x' || key === 'y' || key === 'z') {
|
return;
|
}
|
} else {
|
if (key === 'x' || key === 'y') {
|
return;
|
}
|
}
|
out[key] = coords[key];
|
});
|
return out;
|
}
|
}
|
|
function checkProj(item) {
|
if (item instanceof Proj) {
|
return item;
|
}
|
if (item.oProj) {
|
return item.oProj;
|
}
|
return Proj(item);
|
}
|
|
function core_proj4(fromProj, toProj, coord) {
|
fromProj = checkProj(fromProj);
|
var single = false;
|
var obj;
|
if (typeof toProj === 'undefined') {
|
toProj = fromProj;
|
fromProj = core_wgs84;
|
single = true;
|
} else if (typeof toProj.x !== 'undefined' || Array.isArray(toProj)) {
|
coord = toProj;
|
toProj = fromProj;
|
fromProj = core_wgs84;
|
single = true;
|
}
|
toProj = checkProj(toProj);
|
if (coord) {
|
return transformer(fromProj, toProj, coord);
|
} else {
|
obj = {
|
forward: function (coords, enforceAxis) {
|
return transformer(fromProj, toProj, coords, enforceAxis);
|
},
|
inverse: function (coords, enforceAxis) {
|
return transformer(toProj, fromProj, coords, enforceAxis);
|
}
|
};
|
if (single) {
|
obj.oProj = toProj;
|
}
|
return obj;
|
}
|
}
|
/* harmony default export */ var core = (core_proj4);
|
// CONCATENATED MODULE: ./node_modules/mgrs/mgrs.js
|
|
|
|
/**
|
* UTM zones are grouped, and assigned to one of a group of 6
|
* sets.
|
*
|
* {int} @private
|
*/
|
var NUM_100K_SETS = 6;
|
|
/**
|
* The column letters (for easting) of the lower left value, per
|
* set.
|
*
|
* {string} @private
|
*/
|
var SET_ORIGIN_COLUMN_LETTERS = 'AJSAJS';
|
|
/**
|
* The row letters (for northing) of the lower left value, per
|
* set.
|
*
|
* {string} @private
|
*/
|
var SET_ORIGIN_ROW_LETTERS = 'AFAFAF';
|
|
var mgrs_A = 65; // A
|
var I = 73; // I
|
var O = 79; // O
|
var mgrs_V = 86; // V
|
var mgrs_Z = 90; // Z
|
/* harmony default export */ var mgrs = ({
|
forward: mgrs_forward,
|
inverse: mgrs_inverse,
|
toPoint: mgrs_toPoint
|
});
|
/**
|
* Conversion of lat/lon to MGRS.
|
*
|
* @param {object} ll Object literal with lat and lon properties on a
|
* WGS84 ellipsoid.
|
* @param {int} accuracy Accuracy in digits (5 for 1 m, 4 for 10 m, 3 for
|
* 100 m, 2 for 1000 m or 1 for 10000 m). Optional, default is 5.
|
* @return {string} the MGRS string for the given location and accuracy.
|
*/
|
function mgrs_forward(ll, accuracy) {
|
accuracy = accuracy || 5; // default accuracy 1m
|
return encode(LLtoUTM({
|
lat: ll[1],
|
lon: ll[0]
|
}), accuracy);
|
};
|
|
/**
|
* Conversion of MGRS to lat/lon.
|
*
|
* @param {string} mgrs MGRS string.
|
* @return {array} An array with left (longitude), bottom (latitude), right
|
* (longitude) and top (latitude) values in WGS84, representing the
|
* bounding box for the provided MGRS reference.
|
*/
|
function mgrs_inverse(mgrs) {
|
var bbox = UTMtoLL(decode(mgrs.toUpperCase()));
|
if (bbox.lat && bbox.lon) {
|
return [bbox.lon, bbox.lat, bbox.lon, bbox.lat];
|
}
|
return [bbox.left, bbox.bottom, bbox.right, bbox.top];
|
};
|
|
function mgrs_toPoint(mgrs) {
|
var bbox = UTMtoLL(decode(mgrs.toUpperCase()));
|
if (bbox.lat && bbox.lon) {
|
return [bbox.lon, bbox.lat];
|
}
|
return [(bbox.left + bbox.right) / 2, (bbox.top + bbox.bottom) / 2];
|
};
|
/**
|
* Conversion from degrees to radians.
|
*
|
* @private
|
* @param {number} deg the angle in degrees.
|
* @return {number} the angle in radians.
|
*/
|
function degToRad(deg) {
|
return (deg * (Math.PI / 180.0));
|
}
|
|
/**
|
* Conversion from radians to degrees.
|
*
|
* @private
|
* @param {number} rad the angle in radians.
|
* @return {number} the angle in degrees.
|
*/
|
function radToDeg(rad) {
|
return (180.0 * (rad / Math.PI));
|
}
|
|
/**
|
* Converts a set of Longitude and Latitude co-ordinates to UTM
|
* using the WGS84 ellipsoid.
|
*
|
* @private
|
* @param {object} ll Object literal with lat and lon properties
|
* representing the WGS84 coordinate to be converted.
|
* @return {object} Object literal containing the UTM value with easting,
|
* northing, zoneNumber and zoneLetter properties, and an optional
|
* accuracy property in digits. Returns null if the conversion failed.
|
*/
|
function LLtoUTM(ll) {
|
var Lat = ll.lat;
|
var Long = ll.lon;
|
var a = 6378137.0; //ellip.radius;
|
var eccSquared = 0.00669438; //ellip.eccsq;
|
var k0 = 0.9996;
|
var LongOrigin;
|
var eccPrimeSquared;
|
var N, T, C, A, M;
|
var LatRad = degToRad(Lat);
|
var LongRad = degToRad(Long);
|
var LongOriginRad;
|
var ZoneNumber;
|
// (int)
|
ZoneNumber = Math.floor((Long + 180) / 6) + 1;
|
|
//Make sure the longitude 180.00 is in Zone 60
|
if (Long === 180) {
|
ZoneNumber = 60;
|
}
|
|
// Special zone for Norway
|
if (Lat >= 56.0 && Lat < 64.0 && Long >= 3.0 && Long < 12.0) {
|
ZoneNumber = 32;
|
}
|
|
// Special zones for Svalbard
|
if (Lat >= 72.0 && Lat < 84.0) {
|
if (Long >= 0.0 && Long < 9.0) {
|
ZoneNumber = 31;
|
}
|
else if (Long >= 9.0 && Long < 21.0) {
|
ZoneNumber = 33;
|
}
|
else if (Long >= 21.0 && Long < 33.0) {
|
ZoneNumber = 35;
|
}
|
else if (Long >= 33.0 && Long < 42.0) {
|
ZoneNumber = 37;
|
}
|
}
|
|
LongOrigin = (ZoneNumber - 1) * 6 - 180 + 3; //+3 puts origin
|
// in middle of
|
// zone
|
LongOriginRad = degToRad(LongOrigin);
|
|
eccPrimeSquared = (eccSquared) / (1 - eccSquared);
|
|
N = a / Math.sqrt(1 - eccSquared * Math.sin(LatRad) * Math.sin(LatRad));
|
T = Math.tan(LatRad) * Math.tan(LatRad);
|
C = eccPrimeSquared * Math.cos(LatRad) * Math.cos(LatRad);
|
A = Math.cos(LatRad) * (LongRad - LongOriginRad);
|
|
M = a * ((1 - eccSquared / 4 - 3 * eccSquared * eccSquared / 64 - 5 * eccSquared * eccSquared * eccSquared / 256) * LatRad - (3 * eccSquared / 8 + 3 * eccSquared * eccSquared / 32 + 45 * eccSquared * eccSquared * eccSquared / 1024) * Math.sin(2 * LatRad) + (15 * eccSquared * eccSquared / 256 + 45 * eccSquared * eccSquared * eccSquared / 1024) * Math.sin(4 * LatRad) - (35 * eccSquared * eccSquared * eccSquared / 3072) * Math.sin(6 * LatRad));
|
|
var UTMEasting = (k0 * N * (A + (1 - T + C) * A * A * A / 6.0 + (5 - 18 * T + T * T + 72 * C - 58 * eccPrimeSquared) * A * A * A * A * A / 120.0) + 500000.0);
|
|
var UTMNorthing = (k0 * (M + N * Math.tan(LatRad) * (A * A / 2 + (5 - T + 9 * C + 4 * C * C) * A * A * A * A / 24.0 + (61 - 58 * T + T * T + 600 * C - 330 * eccPrimeSquared) * A * A * A * A * A * A / 720.0)));
|
if (Lat < 0.0) {
|
UTMNorthing += 10000000.0; //10000000 meter offset for
|
// southern hemisphere
|
}
|
|
return {
|
northing: Math.round(UTMNorthing),
|
easting: Math.round(UTMEasting),
|
zoneNumber: ZoneNumber,
|
zoneLetter: getLetterDesignator(Lat)
|
};
|
}
|
|
/**
|
* Converts UTM coords to lat/long, using the WGS84 ellipsoid. This is a convenience
|
* class where the Zone can be specified as a single string eg."60N" which
|
* is then broken down into the ZoneNumber and ZoneLetter.
|
*
|
* @private
|
* @param {object} utm An object literal with northing, easting, zoneNumber
|
* and zoneLetter properties. If an optional accuracy property is
|
* provided (in meters), a bounding box will be returned instead of
|
* latitude and longitude.
|
* @return {object} An object literal containing either lat and lon values
|
* (if no accuracy was provided), or top, right, bottom and left values
|
* for the bounding box calculated according to the provided accuracy.
|
* Returns null if the conversion failed.
|
*/
|
function UTMtoLL(utm) {
|
|
var UTMNorthing = utm.northing;
|
var UTMEasting = utm.easting;
|
var zoneLetter = utm.zoneLetter;
|
var zoneNumber = utm.zoneNumber;
|
// check the ZoneNummber is valid
|
if (zoneNumber < 0 || zoneNumber > 60) {
|
return null;
|
}
|
|
var k0 = 0.9996;
|
var a = 6378137.0; //ellip.radius;
|
var eccSquared = 0.00669438; //ellip.eccsq;
|
var eccPrimeSquared;
|
var e1 = (1 - Math.sqrt(1 - eccSquared)) / (1 + Math.sqrt(1 - eccSquared));
|
var N1, T1, C1, R1, D, M;
|
var LongOrigin;
|
var mu, phi1Rad;
|
|
// remove 500,000 meter offset for longitude
|
var x = UTMEasting - 500000.0;
|
var y = UTMNorthing;
|
|
// We must know somehow if we are in the Northern or Southern
|
// hemisphere, this is the only time we use the letter So even
|
// if the Zone letter isn't exactly correct it should indicate
|
// the hemisphere correctly
|
if (zoneLetter < 'N') {
|
y -= 10000000.0; // remove 10,000,000 meter offset used
|
// for southern hemisphere
|
}
|
|
// There are 60 zones with zone 1 being at West -180 to -174
|
LongOrigin = (zoneNumber - 1) * 6 - 180 + 3; // +3 puts origin
|
// in middle of
|
// zone
|
|
eccPrimeSquared = (eccSquared) / (1 - eccSquared);
|
|
M = y / k0;
|
mu = M / (a * (1 - eccSquared / 4 - 3 * eccSquared * eccSquared / 64 - 5 * eccSquared * eccSquared * eccSquared / 256));
|
|
phi1Rad = mu + (3 * e1 / 2 - 27 * e1 * e1 * e1 / 32) * Math.sin(2 * mu) + (21 * e1 * e1 / 16 - 55 * e1 * e1 * e1 * e1 / 32) * Math.sin(4 * mu) + (151 * e1 * e1 * e1 / 96) * Math.sin(6 * mu);
|
// double phi1 = ProjMath.radToDeg(phi1Rad);
|
|
N1 = a / Math.sqrt(1 - eccSquared * Math.sin(phi1Rad) * Math.sin(phi1Rad));
|
T1 = Math.tan(phi1Rad) * Math.tan(phi1Rad);
|
C1 = eccPrimeSquared * Math.cos(phi1Rad) * Math.cos(phi1Rad);
|
R1 = a * (1 - eccSquared) / Math.pow(1 - eccSquared * Math.sin(phi1Rad) * Math.sin(phi1Rad), 1.5);
|
D = x / (N1 * k0);
|
|
var lat = phi1Rad - (N1 * Math.tan(phi1Rad) / R1) * (D * D / 2 - (5 + 3 * T1 + 10 * C1 - 4 * C1 * C1 - 9 * eccPrimeSquared) * D * D * D * D / 24 + (61 + 90 * T1 + 298 * C1 + 45 * T1 * T1 - 252 * eccPrimeSquared - 3 * C1 * C1) * D * D * D * D * D * D / 720);
|
lat = radToDeg(lat);
|
|
var lon = (D - (1 + 2 * T1 + C1) * D * D * D / 6 + (5 - 2 * C1 + 28 * T1 - 3 * C1 * C1 + 8 * eccPrimeSquared + 24 * T1 * T1) * D * D * D * D * D / 120) / Math.cos(phi1Rad);
|
lon = LongOrigin + radToDeg(lon);
|
|
var result;
|
if (utm.accuracy) {
|
var topRight = UTMtoLL({
|
northing: utm.northing + utm.accuracy,
|
easting: utm.easting + utm.accuracy,
|
zoneLetter: utm.zoneLetter,
|
zoneNumber: utm.zoneNumber
|
});
|
result = {
|
top: topRight.lat,
|
right: topRight.lon,
|
bottom: lat,
|
left: lon
|
};
|
}
|
else {
|
result = {
|
lat: lat,
|
lon: lon
|
};
|
}
|
return result;
|
}
|
|
/**
|
* Calculates the MGRS letter designator for the given latitude.
|
*
|
* @private
|
* @param {number} lat The latitude in WGS84 to get the letter designator
|
* for.
|
* @return {char} The letter designator.
|
*/
|
function getLetterDesignator(lat) {
|
//This is here as an error flag to show that the Latitude is
|
//outside MGRS limits
|
var LetterDesignator = 'Z';
|
|
if ((84 >= lat) && (lat >= 72)) {
|
LetterDesignator = 'X';
|
}
|
else if ((72 > lat) && (lat >= 64)) {
|
LetterDesignator = 'W';
|
}
|
else if ((64 > lat) && (lat >= 56)) {
|
LetterDesignator = 'V';
|
}
|
else if ((56 > lat) && (lat >= 48)) {
|
LetterDesignator = 'U';
|
}
|
else if ((48 > lat) && (lat >= 40)) {
|
LetterDesignator = 'T';
|
}
|
else if ((40 > lat) && (lat >= 32)) {
|
LetterDesignator = 'S';
|
}
|
else if ((32 > lat) && (lat >= 24)) {
|
LetterDesignator = 'R';
|
}
|
else if ((24 > lat) && (lat >= 16)) {
|
LetterDesignator = 'Q';
|
}
|
else if ((16 > lat) && (lat >= 8)) {
|
LetterDesignator = 'P';
|
}
|
else if ((8 > lat) && (lat >= 0)) {
|
LetterDesignator = 'N';
|
}
|
else if ((0 > lat) && (lat >= -8)) {
|
LetterDesignator = 'M';
|
}
|
else if ((-8 > lat) && (lat >= -16)) {
|
LetterDesignator = 'L';
|
}
|
else if ((-16 > lat) && (lat >= -24)) {
|
LetterDesignator = 'K';
|
}
|
else if ((-24 > lat) && (lat >= -32)) {
|
LetterDesignator = 'J';
|
}
|
else if ((-32 > lat) && (lat >= -40)) {
|
LetterDesignator = 'H';
|
}
|
else if ((-40 > lat) && (lat >= -48)) {
|
LetterDesignator = 'G';
|
}
|
else if ((-48 > lat) && (lat >= -56)) {
|
LetterDesignator = 'F';
|
}
|
else if ((-56 > lat) && (lat >= -64)) {
|
LetterDesignator = 'E';
|
}
|
else if ((-64 > lat) && (lat >= -72)) {
|
LetterDesignator = 'D';
|
}
|
else if ((-72 > lat) && (lat >= -80)) {
|
LetterDesignator = 'C';
|
}
|
return LetterDesignator;
|
}
|
|
/**
|
* Encodes a UTM location as MGRS string.
|
*
|
* @private
|
* @param {object} utm An object literal with easting, northing,
|
* zoneLetter, zoneNumber
|
* @param {number} accuracy Accuracy in digits (1-5).
|
* @return {string} MGRS string for the given UTM location.
|
*/
|
function encode(utm, accuracy) {
|
// prepend with leading zeroes
|
var seasting = "00000" + utm.easting,
|
snorthing = "00000" + utm.northing;
|
|
return utm.zoneNumber + utm.zoneLetter + get100kID(utm.easting, utm.northing, utm.zoneNumber) + seasting.substr(seasting.length - 5, accuracy) + snorthing.substr(snorthing.length - 5, accuracy);
|
}
|
|
/**
|
* Get the two letter 100k designator for a given UTM easting,
|
* northing and zone number value.
|
*
|
* @private
|
* @param {number} easting
|
* @param {number} northing
|
* @param {number} zoneNumber
|
* @return the two letter 100k designator for the given UTM location.
|
*/
|
function get100kID(easting, northing, zoneNumber) {
|
var setParm = get100kSetForZone(zoneNumber);
|
var setColumn = Math.floor(easting / 100000);
|
var setRow = Math.floor(northing / 100000) % 20;
|
return getLetter100kID(setColumn, setRow, setParm);
|
}
|
|
/**
|
* Given a UTM zone number, figure out the MGRS 100K set it is in.
|
*
|
* @private
|
* @param {number} i An UTM zone number.
|
* @return {number} the 100k set the UTM zone is in.
|
*/
|
function get100kSetForZone(i) {
|
var setParm = i % NUM_100K_SETS;
|
if (setParm === 0) {
|
setParm = NUM_100K_SETS;
|
}
|
|
return setParm;
|
}
|
|
/**
|
* Get the two-letter MGRS 100k designator given information
|
* translated from the UTM northing, easting and zone number.
|
*
|
* @private
|
* @param {number} column the column index as it relates to the MGRS
|
* 100k set spreadsheet, created from the UTM easting.
|
* Values are 1-8.
|
* @param {number} row the row index as it relates to the MGRS 100k set
|
* spreadsheet, created from the UTM northing value. Values
|
* are from 0-19.
|
* @param {number} parm the set block, as it relates to the MGRS 100k set
|
* spreadsheet, created from the UTM zone. Values are from
|
* 1-60.
|
* @return two letter MGRS 100k code.
|
*/
|
function getLetter100kID(column, row, parm) {
|
// colOrigin and rowOrigin are the letters at the origin of the set
|
var index = parm - 1;
|
var colOrigin = SET_ORIGIN_COLUMN_LETTERS.charCodeAt(index);
|
var rowOrigin = SET_ORIGIN_ROW_LETTERS.charCodeAt(index);
|
|
// colInt and rowInt are the letters to build to return
|
var colInt = colOrigin + column - 1;
|
var rowInt = rowOrigin + row;
|
var rollover = false;
|
|
if (colInt > mgrs_Z) {
|
colInt = colInt - mgrs_Z + mgrs_A - 1;
|
rollover = true;
|
}
|
|
if (colInt === I || (colOrigin < I && colInt > I) || ((colInt > I || colOrigin < I) && rollover)) {
|
colInt++;
|
}
|
|
if (colInt === O || (colOrigin < O && colInt > O) || ((colInt > O || colOrigin < O) && rollover)) {
|
colInt++;
|
|
if (colInt === I) {
|
colInt++;
|
}
|
}
|
|
if (colInt > mgrs_Z) {
|
colInt = colInt - mgrs_Z + mgrs_A - 1;
|
}
|
|
if (rowInt > mgrs_V) {
|
rowInt = rowInt - mgrs_V + mgrs_A - 1;
|
rollover = true;
|
}
|
else {
|
rollover = false;
|
}
|
|
if (((rowInt === I) || ((rowOrigin < I) && (rowInt > I))) || (((rowInt > I) || (rowOrigin < I)) && rollover)) {
|
rowInt++;
|
}
|
|
if (((rowInt === O) || ((rowOrigin < O) && (rowInt > O))) || (((rowInt > O) || (rowOrigin < O)) && rollover)) {
|
rowInt++;
|
|
if (rowInt === I) {
|
rowInt++;
|
}
|
}
|
|
if (rowInt > mgrs_V) {
|
rowInt = rowInt - mgrs_V + mgrs_A - 1;
|
}
|
|
var twoLetter = String.fromCharCode(colInt) + String.fromCharCode(rowInt);
|
return twoLetter;
|
}
|
|
/**
|
* Decode the UTM parameters from a MGRS string.
|
*
|
* @private
|
* @param {string} mgrsString an UPPERCASE coordinate string is expected.
|
* @return {object} An object literal with easting, northing, zoneLetter,
|
* zoneNumber and accuracy (in meters) properties.
|
*/
|
function decode(mgrsString) {
|
|
if (mgrsString && mgrsString.length === 0) {
|
throw ("MGRSPoint coverting from nothing");
|
}
|
|
var length = mgrsString.length;
|
|
var hunK = null;
|
var sb = "";
|
var testChar;
|
var i = 0;
|
|
// get Zone number
|
while (!(/[A-Z]/).test(testChar = mgrsString.charAt(i))) {
|
if (i >= 2) {
|
throw ("MGRSPoint bad conversion from: " + mgrsString);
|
}
|
sb += testChar;
|
i++;
|
}
|
|
var zoneNumber = parseInt(sb, 10);
|
|
if (i === 0 || i + 3 > length) {
|
// A good MGRS string has to be 4-5 digits long,
|
// ##AAA/#AAA at least.
|
throw ("MGRSPoint bad conversion from: " + mgrsString);
|
}
|
|
var zoneLetter = mgrsString.charAt(i++);
|
|
// Should we check the zone letter here? Why not.
|
if (zoneLetter <= 'A' || zoneLetter === 'B' || zoneLetter === 'Y' || zoneLetter >= 'Z' || zoneLetter === 'I' || zoneLetter === 'O') {
|
throw ("MGRSPoint zone letter " + zoneLetter + " not handled: " + mgrsString);
|
}
|
|
hunK = mgrsString.substring(i, i += 2);
|
|
var set = get100kSetForZone(zoneNumber);
|
|
var east100k = getEastingFromChar(hunK.charAt(0), set);
|
var north100k = getNorthingFromChar(hunK.charAt(1), set);
|
|
// We have a bug where the northing may be 2000000 too low.
|
// How
|
// do we know when to roll over?
|
|
while (north100k < getMinNorthing(zoneLetter)) {
|
north100k += 2000000;
|
}
|
|
// calculate the char index for easting/northing separator
|
var remainder = length - i;
|
|
if (remainder % 2 !== 0) {
|
throw ("MGRSPoint has to have an even number \nof digits after the zone letter and two 100km letters - front \nhalf for easting meters, second half for \nnorthing meters" + mgrsString);
|
}
|
|
var sep = remainder / 2;
|
|
var sepEasting = 0.0;
|
var sepNorthing = 0.0;
|
var accuracyBonus, sepEastingString, sepNorthingString, easting, northing;
|
if (sep > 0) {
|
accuracyBonus = 100000.0 / Math.pow(10, sep);
|
sepEastingString = mgrsString.substring(i, i + sep);
|
sepEasting = parseFloat(sepEastingString) * accuracyBonus;
|
sepNorthingString = mgrsString.substring(i + sep);
|
sepNorthing = parseFloat(sepNorthingString) * accuracyBonus;
|
}
|
|
easting = sepEasting + east100k;
|
northing = sepNorthing + north100k;
|
|
return {
|
easting: easting,
|
northing: northing,
|
zoneLetter: zoneLetter,
|
zoneNumber: zoneNumber,
|
accuracy: accuracyBonus
|
};
|
}
|
|
/**
|
* Given the first letter from a two-letter MGRS 100k zone, and given the
|
* MGRS table set for the zone number, figure out the easting value that
|
* should be added to the other, secondary easting value.
|
*
|
* @private
|
* @param {char} e The first letter from a two-letter MGRS 100´k zone.
|
* @param {number} set The MGRS table set for the zone number.
|
* @return {number} The easting value for the given letter and set.
|
*/
|
function getEastingFromChar(e, set) {
|
// colOrigin is the letter at the origin of the set for the
|
// column
|
var curCol = SET_ORIGIN_COLUMN_LETTERS.charCodeAt(set - 1);
|
var eastingValue = 100000.0;
|
var rewindMarker = false;
|
|
while (curCol !== e.charCodeAt(0)) {
|
curCol++;
|
if (curCol === I) {
|
curCol++;
|
}
|
if (curCol === O) {
|
curCol++;
|
}
|
if (curCol > mgrs_Z) {
|
if (rewindMarker) {
|
throw ("Bad character: " + e);
|
}
|
curCol = mgrs_A;
|
rewindMarker = true;
|
}
|
eastingValue += 100000.0;
|
}
|
|
return eastingValue;
|
}
|
|
/**
|
* Given the second letter from a two-letter MGRS 100k zone, and given the
|
* MGRS table set for the zone number, figure out the northing value that
|
* should be added to the other, secondary northing value. You have to
|
* remember that Northings are determined from the equator, and the vertical
|
* cycle of letters mean a 2000000 additional northing meters. This happens
|
* approx. every 18 degrees of latitude. This method does *NOT* count any
|
* additional northings. You have to figure out how many 2000000 meters need
|
* to be added for the zone letter of the MGRS coordinate.
|
*
|
* @private
|
* @param {char} n Second letter of the MGRS 100k zone
|
* @param {number} set The MGRS table set number, which is dependent on the
|
* UTM zone number.
|
* @return {number} The northing value for the given letter and set.
|
*/
|
function getNorthingFromChar(n, set) {
|
|
if (n > 'V') {
|
throw ("MGRSPoint given invalid Northing " + n);
|
}
|
|
// rowOrigin is the letter at the origin of the set for the
|
// column
|
var curRow = SET_ORIGIN_ROW_LETTERS.charCodeAt(set - 1);
|
var northingValue = 0.0;
|
var rewindMarker = false;
|
|
while (curRow !== n.charCodeAt(0)) {
|
curRow++;
|
if (curRow === I) {
|
curRow++;
|
}
|
if (curRow === O) {
|
curRow++;
|
}
|
// fixing a bug making whole application hang in this loop
|
// when 'n' is a wrong character
|
if (curRow > mgrs_V) {
|
if (rewindMarker) { // making sure that this loop ends
|
throw ("Bad character: " + n);
|
}
|
curRow = mgrs_A;
|
rewindMarker = true;
|
}
|
northingValue += 100000.0;
|
}
|
|
return northingValue;
|
}
|
|
/**
|
* The function getMinNorthing returns the minimum northing value of a MGRS
|
* zone.
|
*
|
* Ported from Geotrans' c Lattitude_Band_Value structure table.
|
*
|
* @private
|
* @param {char} zoneLetter The MGRS zone to get the min northing for.
|
* @return {number}
|
*/
|
function getMinNorthing(zoneLetter) {
|
var northing;
|
switch (zoneLetter) {
|
case 'C':
|
northing = 1100000.0;
|
break;
|
case 'D':
|
northing = 2000000.0;
|
break;
|
case 'E':
|
northing = 2800000.0;
|
break;
|
case 'F':
|
northing = 3700000.0;
|
break;
|
case 'G':
|
northing = 4600000.0;
|
break;
|
case 'H':
|
northing = 5500000.0;
|
break;
|
case 'J':
|
northing = 6400000.0;
|
break;
|
case 'K':
|
northing = 7300000.0;
|
break;
|
case 'L':
|
northing = 8200000.0;
|
break;
|
case 'M':
|
northing = 9100000.0;
|
break;
|
case 'N':
|
northing = 0.0;
|
break;
|
case 'P':
|
northing = 800000.0;
|
break;
|
case 'Q':
|
northing = 1700000.0;
|
break;
|
case 'R':
|
northing = 2600000.0;
|
break;
|
case 'S':
|
northing = 3500000.0;
|
break;
|
case 'T':
|
northing = 4400000.0;
|
break;
|
case 'U':
|
northing = 5300000.0;
|
break;
|
case 'V':
|
northing = 6200000.0;
|
break;
|
case 'W':
|
northing = 7000000.0;
|
break;
|
case 'X':
|
northing = 7900000.0;
|
break;
|
default:
|
northing = -1.0;
|
}
|
if (northing >= 0.0) {
|
return northing;
|
}
|
else {
|
throw ("Invalid zone letter: " + zoneLetter);
|
}
|
|
}
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/Point.js
|
|
|
function Point(x, y, z) {
|
if (!(this instanceof Point)) {
|
return new Point(x, y, z);
|
}
|
if (Array.isArray(x)) {
|
this.x = x[0];
|
this.y = x[1];
|
this.z = x[2] || 0.0;
|
} else if(typeof x === 'object') {
|
this.x = x.x;
|
this.y = x.y;
|
this.z = x.z || 0.0;
|
} else if (typeof x === 'string' && typeof y === 'undefined') {
|
var coords = x.split(',');
|
this.x = parseFloat(coords[0], 10);
|
this.y = parseFloat(coords[1], 10);
|
this.z = parseFloat(coords[2], 10) || 0.0;
|
} else {
|
this.x = x;
|
this.y = y;
|
this.z = z || 0.0;
|
}
|
console.warn('proj4.Point will be removed in version 3, use proj4.toPoint');
|
}
|
|
Point.fromMGRS = function(mgrsStr) {
|
return new Point(mgrs_toPoint(mgrsStr));
|
};
|
Point.prototype.toMGRS = function(accuracy) {
|
return mgrs_forward([this.x, this.y], accuracy);
|
};
|
/* harmony default export */ var lib_Point = (Point);
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/pj_enfn.js
|
var C00 = 1;
|
var C02 = 0.25;
|
var C04 = 0.046875;
|
var C06 = 0.01953125;
|
var C08 = 0.01068115234375;
|
var C22 = 0.75;
|
var C44 = 0.46875;
|
var C46 = 0.01302083333333333333;
|
var C48 = 0.00712076822916666666;
|
var C66 = 0.36458333333333333333;
|
var C68 = 0.00569661458333333333;
|
var C88 = 0.3076171875;
|
|
/* harmony default export */ var pj_enfn = (function(es) {
|
var en = [];
|
en[0] = C00 - es * (C02 + es * (C04 + es * (C06 + es * C08)));
|
en[1] = es * (C22 - es * (C04 + es * (C06 + es * C08)));
|
var t = es * es;
|
en[2] = t * (C44 - es * (C46 + es * C48));
|
t *= es;
|
en[3] = t * (C66 - es * C68);
|
en[4] = t * es * C88;
|
return en;
|
});
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/pj_mlfn.js
|
/* harmony default export */ var pj_mlfn = (function(phi, sphi, cphi, en) {
|
cphi *= sphi;
|
sphi *= sphi;
|
return (en[0] * phi - cphi * (en[1] + sphi * (en[2] + sphi * (en[3] + sphi * en[4]))));
|
});
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/pj_inv_mlfn.js
|
|
|
|
var MAX_ITER = 20;
|
|
/* harmony default export */ var pj_inv_mlfn = (function(arg, es, en) {
|
var k = 1 / (1 - es);
|
var phi = arg;
|
for (var i = MAX_ITER; i; --i) { /* rarely goes over 2 iterations */
|
var s = Math.sin(phi);
|
var t = 1 - es * s * s;
|
//t = this.pj_mlfn(phi, s, Math.cos(phi), en) - arg;
|
//phi -= t * (t * Math.sqrt(t)) * k;
|
t = (pj_mlfn(phi, s, Math.cos(phi), en) - arg) * (t * Math.sqrt(t)) * k;
|
phi -= t;
|
if (Math.abs(t) < EPSLN) {
|
return phi;
|
}
|
}
|
//..reportError("cass:pj_inv_mlfn: Convergence error");
|
return phi;
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/tmerc.js
|
// Heavily based on this tmerc projection implementation
|
// https://github.com/mbloch/mapshaper-proj/blob/master/src/projections/tmerc.js
|
|
|
|
|
|
|
|
|
|
function tmerc_init() {
|
this.x0 = this.x0 !== undefined ? this.x0 : 0;
|
this.y0 = this.y0 !== undefined ? this.y0 : 0;
|
this.long0 = this.long0 !== undefined ? this.long0 : 0;
|
this.lat0 = this.lat0 !== undefined ? this.lat0 : 0;
|
|
if (this.es) {
|
this.en = pj_enfn(this.es);
|
this.ml0 = pj_mlfn(this.lat0, Math.sin(this.lat0), Math.cos(this.lat0), this.en);
|
}
|
}
|
|
/**
|
Transverse Mercator Forward - long/lat to x/y
|
long/lat in radians
|
*/
|
function tmerc_forward(p) {
|
var lon = p.x;
|
var lat = p.y;
|
|
var delta_lon = adjust_lon(lon - this.long0);
|
var con;
|
var x, y;
|
var sin_phi = Math.sin(lat);
|
var cos_phi = Math.cos(lat);
|
|
if (!this.es) {
|
var b = cos_phi * Math.sin(delta_lon);
|
|
if ((Math.abs(Math.abs(b) - 1)) < EPSLN) {
|
return (93);
|
}
|
else {
|
x = 0.5 * this.a * this.k0 * Math.log((1 + b) / (1 - b)) + this.x0;
|
y = cos_phi * Math.cos(delta_lon) / Math.sqrt(1 - Math.pow(b, 2));
|
b = Math.abs(y);
|
|
if (b >= 1) {
|
if ((b - 1) > EPSLN) {
|
return (93);
|
}
|
else {
|
y = 0;
|
}
|
}
|
else {
|
y = Math.acos(y);
|
}
|
|
if (lat < 0) {
|
y = -y;
|
}
|
|
y = this.a * this.k0 * (y - this.lat0) + this.y0;
|
}
|
}
|
else {
|
var al = cos_phi * delta_lon;
|
var als = Math.pow(al, 2);
|
var c = this.ep2 * Math.pow(cos_phi, 2);
|
var cs = Math.pow(c, 2);
|
var tq = Math.abs(cos_phi) > EPSLN ? Math.tan(lat) : 0;
|
var t = Math.pow(tq, 2);
|
var ts = Math.pow(t, 2);
|
con = 1 - this.es * Math.pow(sin_phi, 2);
|
al = al / Math.sqrt(con);
|
var ml = pj_mlfn(lat, sin_phi, cos_phi, this.en);
|
|
x = this.a * (this.k0 * al * (1 +
|
als / 6 * (1 - t + c +
|
als / 20 * (5 - 18 * t + ts + 14 * c - 58 * t * c +
|
als / 42 * (61 + 179 * ts - ts * t - 479 * t))))) +
|
this.x0;
|
|
y = this.a * (this.k0 * (ml - this.ml0 +
|
sin_phi * delta_lon * al / 2 * (1 +
|
als / 12 * (5 - t + 9 * c + 4 * cs +
|
als / 30 * (61 + ts - 58 * t + 270 * c - 330 * t * c +
|
als / 56 * (1385 + 543 * ts - ts * t - 3111 * t)))))) +
|
this.y0;
|
}
|
|
p.x = x;
|
p.y = y;
|
|
return p;
|
}
|
|
/**
|
Transverse Mercator Inverse - x/y to long/lat
|
*/
|
function tmerc_inverse(p) {
|
var con, phi;
|
var lat, lon;
|
var x = (p.x - this.x0) * (1 / this.a);
|
var y = (p.y - this.y0) * (1 / this.a);
|
|
if (!this.es) {
|
var f = Math.exp(x / this.k0);
|
var g = 0.5 * (f - 1 / f);
|
var temp = this.lat0 + y / this.k0;
|
var h = Math.cos(temp);
|
con = Math.sqrt((1 - Math.pow(h, 2)) / (1 + Math.pow(g, 2)));
|
lat = Math.asin(con);
|
|
if (y < 0) {
|
lat = -lat;
|
}
|
|
if ((g === 0) && (h === 0)) {
|
lon = 0;
|
}
|
else {
|
lon = adjust_lon(Math.atan2(g, h) + this.long0);
|
}
|
}
|
else { // ellipsoidal form
|
con = this.ml0 + y / this.k0;
|
phi = pj_inv_mlfn(con, this.es, this.en);
|
|
if (Math.abs(phi) < HALF_PI) {
|
var sin_phi = Math.sin(phi);
|
var cos_phi = Math.cos(phi);
|
var tan_phi = Math.abs(cos_phi) > EPSLN ? Math.tan(phi) : 0;
|
var c = this.ep2 * Math.pow(cos_phi, 2);
|
var cs = Math.pow(c, 2);
|
var t = Math.pow(tan_phi, 2);
|
var ts = Math.pow(t, 2);
|
con = 1 - this.es * Math.pow(sin_phi, 2);
|
var d = x * Math.sqrt(con) / this.k0;
|
var ds = Math.pow(d, 2);
|
con = con * tan_phi;
|
|
lat = phi - (con * ds / (1 - this.es)) * 0.5 * (1 -
|
ds / 12 * (5 + 3 * t - 9 * c * t + c - 4 * cs -
|
ds / 30 * (61 + 90 * t - 252 * c * t + 45 * ts + 46 * c -
|
ds / 56 * (1385 + 3633 * t + 4095 * ts + 1574 * ts * t))));
|
|
lon = adjust_lon(this.long0 + (d * (1 -
|
ds / 6 * (1 + 2 * t + c -
|
ds / 20 * (5 + 28 * t + 24 * ts + 8 * c * t + 6 * c -
|
ds / 42 * (61 + 662 * t + 1320 * ts + 720 * ts * t)))) / cos_phi));
|
}
|
else {
|
lat = HALF_PI * sign(y);
|
lon = 0;
|
}
|
}
|
|
p.x = lon;
|
p.y = lat;
|
|
return p;
|
}
|
|
var tmerc_names = ["Fast_Transverse_Mercator", "Fast Transverse Mercator"];
|
/* harmony default export */ var tmerc = ({
|
init: tmerc_init,
|
forward: tmerc_forward,
|
inverse: tmerc_inverse,
|
names: tmerc_names
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/sinh.js
|
/* harmony default export */ var sinh = (function(x) {
|
var r = Math.exp(x);
|
r = (r - 1 / r) / 2;
|
return r;
|
});
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/hypot.js
|
/* harmony default export */ var hypot = (function(x, y) {
|
x = Math.abs(x);
|
y = Math.abs(y);
|
var a = Math.max(x, y);
|
var b = Math.min(x, y) / (a ? a : 1);
|
|
return a * Math.sqrt(1 + Math.pow(b, 2));
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/log1py.js
|
/* harmony default export */ var log1py = (function(x) {
|
var y = 1 + x;
|
var z = y - 1;
|
|
return z === 0 ? x : x * Math.log(y) / z;
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/asinhy.js
|
|
|
|
/* harmony default export */ var asinhy = (function(x) {
|
var y = Math.abs(x);
|
y = log1py(y * (1 + y / (hypot(1, y) + 1)));
|
|
return x < 0 ? -y : y;
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/gatg.js
|
/* harmony default export */ var gatg = (function(pp, B) {
|
var cos_2B = 2 * Math.cos(2 * B);
|
var i = pp.length - 1;
|
var h1 = pp[i];
|
var h2 = 0;
|
var h;
|
|
while (--i >= 0) {
|
h = -h2 + cos_2B * h1 + pp[i];
|
h2 = h1;
|
h1 = h;
|
}
|
|
return (B + h * Math.sin(2 * B));
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/clens.js
|
/* harmony default export */ var clens = (function(pp, arg_r) {
|
var r = 2 * Math.cos(arg_r);
|
var i = pp.length - 1;
|
var hr1 = pp[i];
|
var hr2 = 0;
|
var hr;
|
|
while (--i >= 0) {
|
hr = -hr2 + r * hr1 + pp[i];
|
hr2 = hr1;
|
hr1 = hr;
|
}
|
|
return Math.sin(arg_r) * hr;
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/cosh.js
|
/* harmony default export */ var cosh = (function(x) {
|
var r = Math.exp(x);
|
r = (r + 1 / r) / 2;
|
return r;
|
});
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/clens_cmplx.js
|
|
|
|
/* harmony default export */ var clens_cmplx = (function(pp, arg_r, arg_i) {
|
var sin_arg_r = Math.sin(arg_r);
|
var cos_arg_r = Math.cos(arg_r);
|
var sinh_arg_i = sinh(arg_i);
|
var cosh_arg_i = cosh(arg_i);
|
var r = 2 * cos_arg_r * cosh_arg_i;
|
var i = -2 * sin_arg_r * sinh_arg_i;
|
var j = pp.length - 1;
|
var hr = pp[j];
|
var hi1 = 0;
|
var hr1 = 0;
|
var hi = 0;
|
var hr2;
|
var hi2;
|
|
while (--j >= 0) {
|
hr2 = hr1;
|
hi2 = hi1;
|
hr1 = hr;
|
hi1 = hi;
|
hr = -hr2 + r * hr1 - i * hi1 + pp[j];
|
hi = -hi2 + i * hr1 + r * hi1;
|
}
|
|
r = sin_arg_r * cosh_arg_i;
|
i = cos_arg_r * sinh_arg_i;
|
|
return [r * hr - i * hi, r * hi + i * hr];
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/etmerc.js
|
// Heavily based on this etmerc projection implementation
|
// https://github.com/mbloch/mapshaper-proj/blob/master/src/projections/etmerc.js
|
|
|
|
|
|
|
|
|
|
|
function etmerc_init() {
|
if (!this.approx && (isNaN(this.es) || this.es <= 0)) {
|
throw new Error('Incorrect elliptical usage. Try using the +approx option in the proj string, or PROJECTION["Fast_Transverse_Mercator"] in the WKT.');
|
}
|
if (this.approx) {
|
// When '+approx' is set, use tmerc instead
|
tmerc.init.apply(this);
|
this.forward = tmerc.forward;
|
this.inverse = tmerc.inverse;
|
}
|
|
this.x0 = this.x0 !== undefined ? this.x0 : 0;
|
this.y0 = this.y0 !== undefined ? this.y0 : 0;
|
this.long0 = this.long0 !== undefined ? this.long0 : 0;
|
this.lat0 = this.lat0 !== undefined ? this.lat0 : 0;
|
|
this.cgb = [];
|
this.cbg = [];
|
this.utg = [];
|
this.gtu = [];
|
|
var f = this.es / (1 + Math.sqrt(1 - this.es));
|
var n = f / (2 - f);
|
var np = n;
|
|
this.cgb[0] = n * (2 + n * (-2 / 3 + n * (-2 + n * (116 / 45 + n * (26 / 45 + n * (-2854 / 675 ))))));
|
this.cbg[0] = n * (-2 + n * ( 2 / 3 + n * ( 4 / 3 + n * (-82 / 45 + n * (32 / 45 + n * (4642 / 4725))))));
|
|
np = np * n;
|
this.cgb[1] = np * (7 / 3 + n * (-8 / 5 + n * (-227 / 45 + n * (2704 / 315 + n * (2323 / 945)))));
|
this.cbg[1] = np * (5 / 3 + n * (-16 / 15 + n * ( -13 / 9 + n * (904 / 315 + n * (-1522 / 945)))));
|
|
np = np * n;
|
this.cgb[2] = np * (56 / 15 + n * (-136 / 35 + n * (-1262 / 105 + n * (73814 / 2835))));
|
this.cbg[2] = np * (-26 / 15 + n * (34 / 21 + n * (8 / 5 + n * (-12686 / 2835))));
|
|
np = np * n;
|
this.cgb[3] = np * (4279 / 630 + n * (-332 / 35 + n * (-399572 / 14175)));
|
this.cbg[3] = np * (1237 / 630 + n * (-12 / 5 + n * ( -24832 / 14175)));
|
|
np = np * n;
|
this.cgb[4] = np * (4174 / 315 + n * (-144838 / 6237));
|
this.cbg[4] = np * (-734 / 315 + n * (109598 / 31185));
|
|
np = np * n;
|
this.cgb[5] = np * (601676 / 22275);
|
this.cbg[5] = np * (444337 / 155925);
|
|
np = Math.pow(n, 2);
|
this.Qn = this.k0 / (1 + n) * (1 + np * (1 / 4 + np * (1 / 64 + np / 256)));
|
|
this.utg[0] = n * (-0.5 + n * ( 2 / 3 + n * (-37 / 96 + n * ( 1 / 360 + n * (81 / 512 + n * (-96199 / 604800))))));
|
this.gtu[0] = n * (0.5 + n * (-2 / 3 + n * (5 / 16 + n * (41 / 180 + n * (-127 / 288 + n * (7891 / 37800))))));
|
|
this.utg[1] = np * (-1 / 48 + n * (-1 / 15 + n * (437 / 1440 + n * (-46 / 105 + n * (1118711 / 3870720)))));
|
this.gtu[1] = np * (13 / 48 + n * (-3 / 5 + n * (557 / 1440 + n * (281 / 630 + n * (-1983433 / 1935360)))));
|
|
np = np * n;
|
this.utg[2] = np * (-17 / 480 + n * (37 / 840 + n * (209 / 4480 + n * (-5569 / 90720 ))));
|
this.gtu[2] = np * (61 / 240 + n * (-103 / 140 + n * (15061 / 26880 + n * (167603 / 181440))));
|
|
np = np * n;
|
this.utg[3] = np * (-4397 / 161280 + n * (11 / 504 + n * (830251 / 7257600)));
|
this.gtu[3] = np * (49561 / 161280 + n * (-179 / 168 + n * (6601661 / 7257600)));
|
|
np = np * n;
|
this.utg[4] = np * (-4583 / 161280 + n * (108847 / 3991680));
|
this.gtu[4] = np * (34729 / 80640 + n * (-3418889 / 1995840));
|
|
np = np * n;
|
this.utg[5] = np * (-20648693 / 638668800);
|
this.gtu[5] = np * (212378941 / 319334400);
|
|
var Z = gatg(this.cbg, this.lat0);
|
this.Zb = -this.Qn * (Z + clens(this.gtu, 2 * Z));
|
}
|
|
function etmerc_forward(p) {
|
var Ce = adjust_lon(p.x - this.long0);
|
var Cn = p.y;
|
|
Cn = gatg(this.cbg, Cn);
|
var sin_Cn = Math.sin(Cn);
|
var cos_Cn = Math.cos(Cn);
|
var sin_Ce = Math.sin(Ce);
|
var cos_Ce = Math.cos(Ce);
|
|
Cn = Math.atan2(sin_Cn, cos_Ce * cos_Cn);
|
Ce = Math.atan2(sin_Ce * cos_Cn, hypot(sin_Cn, cos_Cn * cos_Ce));
|
Ce = asinhy(Math.tan(Ce));
|
|
var tmp = clens_cmplx(this.gtu, 2 * Cn, 2 * Ce);
|
|
Cn = Cn + tmp[0];
|
Ce = Ce + tmp[1];
|
|
var x;
|
var y;
|
|
if (Math.abs(Ce) <= 2.623395162778) {
|
x = this.a * (this.Qn * Ce) + this.x0;
|
y = this.a * (this.Qn * Cn + this.Zb) + this.y0;
|
}
|
else {
|
x = Infinity;
|
y = Infinity;
|
}
|
|
p.x = x;
|
p.y = y;
|
|
return p;
|
}
|
|
function etmerc_inverse(p) {
|
var Ce = (p.x - this.x0) * (1 / this.a);
|
var Cn = (p.y - this.y0) * (1 / this.a);
|
|
Cn = (Cn - this.Zb) / this.Qn;
|
Ce = Ce / this.Qn;
|
|
var lon;
|
var lat;
|
|
if (Math.abs(Ce) <= 2.623395162778) {
|
var tmp = clens_cmplx(this.utg, 2 * Cn, 2 * Ce);
|
|
Cn = Cn + tmp[0];
|
Ce = Ce + tmp[1];
|
Ce = Math.atan(sinh(Ce));
|
|
var sin_Cn = Math.sin(Cn);
|
var cos_Cn = Math.cos(Cn);
|
var sin_Ce = Math.sin(Ce);
|
var cos_Ce = Math.cos(Ce);
|
|
Cn = Math.atan2(sin_Cn * cos_Ce, hypot(sin_Ce, cos_Ce * cos_Cn));
|
Ce = Math.atan2(sin_Ce, cos_Ce * cos_Cn);
|
|
lon = adjust_lon(Ce + this.long0);
|
lat = gatg(this.cgb, Cn);
|
}
|
else {
|
lon = Infinity;
|
lat = Infinity;
|
}
|
|
p.x = lon;
|
p.y = lat;
|
|
return p;
|
}
|
|
var etmerc_names = ["Extended_Transverse_Mercator", "Extended Transverse Mercator", "etmerc", "Transverse_Mercator", "Transverse Mercator", "tmerc"];
|
/* harmony default export */ var etmerc = ({
|
init: etmerc_init,
|
forward: etmerc_forward,
|
inverse: etmerc_inverse,
|
names: etmerc_names
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/adjust_zone.js
|
|
|
/* harmony default export */ var adjust_zone = (function(zone, lon) {
|
if (zone === undefined) {
|
zone = Math.floor((adjust_lon(lon) + Math.PI) * 30 / Math.PI) + 1;
|
|
if (zone < 0) {
|
return 0;
|
} else if (zone > 60) {
|
return 60;
|
}
|
}
|
return zone;
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/utm.js
|
|
|
var dependsOn = 'etmerc';
|
|
|
|
function utm_init() {
|
var zone = adjust_zone(this.zone, this.long0);
|
if (zone === undefined) {
|
throw new Error('unknown utm zone');
|
}
|
this.lat0 = 0;
|
this.long0 = ((6 * Math.abs(zone)) - 183) * D2R;
|
this.x0 = 500000;
|
this.y0 = this.utmSouth ? 10000000 : 0;
|
this.k0 = 0.9996;
|
|
etmerc.init.apply(this);
|
this.forward = etmerc.forward;
|
this.inverse = etmerc.inverse;
|
}
|
|
var utm_names = ["Universal Transverse Mercator System", "utm"];
|
/* harmony default export */ var utm = ({
|
init: utm_init,
|
names: utm_names,
|
dependsOn: dependsOn
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/srat.js
|
/* harmony default export */ var srat = (function(esinp, exp) {
|
return (Math.pow((1 - esinp) / (1 + esinp), exp));
|
});
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/gauss.js
|
|
var gauss_MAX_ITER = 20;
|
|
|
function gauss_init() {
|
var sphi = Math.sin(this.lat0);
|
var cphi = Math.cos(this.lat0);
|
cphi *= cphi;
|
this.rc = Math.sqrt(1 - this.es) / (1 - this.es * sphi * sphi);
|
this.C = Math.sqrt(1 + this.es * cphi * cphi / (1 - this.es));
|
this.phic0 = Math.asin(sphi / this.C);
|
this.ratexp = 0.5 * this.C * this.e;
|
this.K = Math.tan(0.5 * this.phic0 + FORTPI) / (Math.pow(Math.tan(0.5 * this.lat0 + FORTPI), this.C) * srat(this.e * sphi, this.ratexp));
|
}
|
|
function gauss_forward(p) {
|
var lon = p.x;
|
var lat = p.y;
|
|
p.y = 2 * Math.atan(this.K * Math.pow(Math.tan(0.5 * lat + FORTPI), this.C) * srat(this.e * Math.sin(lat), this.ratexp)) - HALF_PI;
|
p.x = this.C * lon;
|
return p;
|
}
|
|
function gauss_inverse(p) {
|
var DEL_TOL = 1e-14;
|
var lon = p.x / this.C;
|
var lat = p.y;
|
var num = Math.pow(Math.tan(0.5 * lat + FORTPI) / this.K, 1 / this.C);
|
for (var i = gauss_MAX_ITER; i > 0; --i) {
|
lat = 2 * Math.atan(num * srat(this.e * Math.sin(p.y), - 0.5 * this.e)) - HALF_PI;
|
if (Math.abs(lat - p.y) < DEL_TOL) {
|
break;
|
}
|
p.y = lat;
|
}
|
/* convergence failed */
|
if (!i) {
|
return null;
|
}
|
p.x = lon;
|
p.y = lat;
|
return p;
|
}
|
|
var gauss_names = ["gauss"];
|
/* harmony default export */ var gauss = ({
|
init: gauss_init,
|
forward: gauss_forward,
|
inverse: gauss_inverse,
|
names: gauss_names
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/sterea.js
|
|
|
|
function sterea_init() {
|
gauss.init.apply(this);
|
if (!this.rc) {
|
return;
|
}
|
this.sinc0 = Math.sin(this.phic0);
|
this.cosc0 = Math.cos(this.phic0);
|
this.R2 = 2 * this.rc;
|
if (!this.title) {
|
this.title = "Oblique Stereographic Alternative";
|
}
|
}
|
|
function sterea_forward(p) {
|
var sinc, cosc, cosl, k;
|
p.x = adjust_lon(p.x - this.long0);
|
gauss.forward.apply(this, [p]);
|
sinc = Math.sin(p.y);
|
cosc = Math.cos(p.y);
|
cosl = Math.cos(p.x);
|
k = this.k0 * this.R2 / (1 + this.sinc0 * sinc + this.cosc0 * cosc * cosl);
|
p.x = k * cosc * Math.sin(p.x);
|
p.y = k * (this.cosc0 * sinc - this.sinc0 * cosc * cosl);
|
p.x = this.a * p.x + this.x0;
|
p.y = this.a * p.y + this.y0;
|
return p;
|
}
|
|
function sterea_inverse(p) {
|
var sinc, cosc, lon, lat, rho;
|
p.x = (p.x - this.x0) / this.a;
|
p.y = (p.y - this.y0) / this.a;
|
|
p.x /= this.k0;
|
p.y /= this.k0;
|
if ((rho = Math.sqrt(p.x * p.x + p.y * p.y))) {
|
var c = 2 * Math.atan2(rho, this.R2);
|
sinc = Math.sin(c);
|
cosc = Math.cos(c);
|
lat = Math.asin(cosc * this.sinc0 + p.y * sinc * this.cosc0 / rho);
|
lon = Math.atan2(p.x * sinc, rho * this.cosc0 * cosc - p.y * this.sinc0 * sinc);
|
}
|
else {
|
lat = this.phic0;
|
lon = 0;
|
}
|
|
p.x = lon;
|
p.y = lat;
|
gauss.inverse.apply(this, [p]);
|
p.x = adjust_lon(p.x + this.long0);
|
return p;
|
}
|
|
var sterea_names = ["Stereographic_North_Pole", "Oblique_Stereographic", "Polar_Stereographic", "sterea","Oblique Stereographic Alternative","Double_Stereographic"];
|
/* harmony default export */ var sterea = ({
|
init: sterea_init,
|
forward: sterea_forward,
|
inverse: sterea_inverse,
|
names: sterea_names
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/stere.js
|
|
|
|
|
|
|
|
|
function ssfn_(phit, sinphi, eccen) {
|
sinphi *= eccen;
|
return (Math.tan(0.5 * (HALF_PI + phit)) * Math.pow((1 - sinphi) / (1 + sinphi), 0.5 * eccen));
|
}
|
|
function stere_init() {
|
this.coslat0 = Math.cos(this.lat0);
|
this.sinlat0 = Math.sin(this.lat0);
|
if (this.sphere) {
|
if (this.k0 === 1 && !isNaN(this.lat_ts) && Math.abs(this.coslat0) <= EPSLN) {
|
this.k0 = 0.5 * (1 + sign(this.lat0) * Math.sin(this.lat_ts));
|
}
|
}
|
else {
|
if (Math.abs(this.coslat0) <= EPSLN) {
|
if (this.lat0 > 0) {
|
//North pole
|
//trace('stere:north pole');
|
this.con = 1;
|
}
|
else {
|
//South pole
|
//trace('stere:south pole');
|
this.con = -1;
|
}
|
}
|
this.cons = Math.sqrt(Math.pow(1 + this.e, 1 + this.e) * Math.pow(1 - this.e, 1 - this.e));
|
if (this.k0 === 1 && !isNaN(this.lat_ts) && Math.abs(this.coslat0) <= EPSLN) {
|
this.k0 = 0.5 * this.cons * msfnz(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts)) / tsfnz(this.e, this.con * this.lat_ts, this.con * Math.sin(this.lat_ts));
|
}
|
this.ms1 = msfnz(this.e, this.sinlat0, this.coslat0);
|
this.X0 = 2 * Math.atan(this.ssfn_(this.lat0, this.sinlat0, this.e)) - HALF_PI;
|
this.cosX0 = Math.cos(this.X0);
|
this.sinX0 = Math.sin(this.X0);
|
}
|
}
|
|
// Stereographic forward equations--mapping lat,long to x,y
|
function stere_forward(p) {
|
var lon = p.x;
|
var lat = p.y;
|
var sinlat = Math.sin(lat);
|
var coslat = Math.cos(lat);
|
var A, X, sinX, cosX, ts, rh;
|
var dlon = adjust_lon(lon - this.long0);
|
|
if (Math.abs(Math.abs(lon - this.long0) - Math.PI) <= EPSLN && Math.abs(lat + this.lat0) <= EPSLN) {
|
//case of the origine point
|
//trace('stere:this is the origin point');
|
p.x = NaN;
|
p.y = NaN;
|
return p;
|
}
|
if (this.sphere) {
|
//trace('stere:sphere case');
|
A = 2 * this.k0 / (1 + this.sinlat0 * sinlat + this.coslat0 * coslat * Math.cos(dlon));
|
p.x = this.a * A * coslat * Math.sin(dlon) + this.x0;
|
p.y = this.a * A * (this.coslat0 * sinlat - this.sinlat0 * coslat * Math.cos(dlon)) + this.y0;
|
return p;
|
}
|
else {
|
X = 2 * Math.atan(this.ssfn_(lat, sinlat, this.e)) - HALF_PI;
|
cosX = Math.cos(X);
|
sinX = Math.sin(X);
|
if (Math.abs(this.coslat0) <= EPSLN) {
|
ts = tsfnz(this.e, lat * this.con, this.con * sinlat);
|
rh = 2 * this.a * this.k0 * ts / this.cons;
|
p.x = this.x0 + rh * Math.sin(lon - this.long0);
|
p.y = this.y0 - this.con * rh * Math.cos(lon - this.long0);
|
//trace(p.toString());
|
return p;
|
}
|
else if (Math.abs(this.sinlat0) < EPSLN) {
|
//Eq
|
//trace('stere:equateur');
|
A = 2 * this.a * this.k0 / (1 + cosX * Math.cos(dlon));
|
p.y = A * sinX;
|
}
|
else {
|
//other case
|
//trace('stere:normal case');
|
A = 2 * this.a * this.k0 * this.ms1 / (this.cosX0 * (1 + this.sinX0 * sinX + this.cosX0 * cosX * Math.cos(dlon)));
|
p.y = A * (this.cosX0 * sinX - this.sinX0 * cosX * Math.cos(dlon)) + this.y0;
|
}
|
p.x = A * cosX * Math.sin(dlon) + this.x0;
|
}
|
//trace(p.toString());
|
return p;
|
}
|
|
//* Stereographic inverse equations--mapping x,y to lat/long
|
function stere_inverse(p) {
|
p.x -= this.x0;
|
p.y -= this.y0;
|
var lon, lat, ts, ce, Chi;
|
var rh = Math.sqrt(p.x * p.x + p.y * p.y);
|
if (this.sphere) {
|
var c = 2 * Math.atan(rh / (2 * this.a * this.k0));
|
lon = this.long0;
|
lat = this.lat0;
|
if (rh <= EPSLN) {
|
p.x = lon;
|
p.y = lat;
|
return p;
|
}
|
lat = Math.asin(Math.cos(c) * this.sinlat0 + p.y * Math.sin(c) * this.coslat0 / rh);
|
if (Math.abs(this.coslat0) < EPSLN) {
|
if (this.lat0 > 0) {
|
lon = adjust_lon(this.long0 + Math.atan2(p.x, - 1 * p.y));
|
}
|
else {
|
lon = adjust_lon(this.long0 + Math.atan2(p.x, p.y));
|
}
|
}
|
else {
|
lon = adjust_lon(this.long0 + Math.atan2(p.x * Math.sin(c), rh * this.coslat0 * Math.cos(c) - p.y * this.sinlat0 * Math.sin(c)));
|
}
|
p.x = lon;
|
p.y = lat;
|
return p;
|
}
|
else {
|
if (Math.abs(this.coslat0) <= EPSLN) {
|
if (rh <= EPSLN) {
|
lat = this.lat0;
|
lon = this.long0;
|
p.x = lon;
|
p.y = lat;
|
//trace(p.toString());
|
return p;
|
}
|
p.x *= this.con;
|
p.y *= this.con;
|
ts = rh * this.cons / (2 * this.a * this.k0);
|
lat = this.con * phi2z(this.e, ts);
|
lon = this.con * adjust_lon(this.con * this.long0 + Math.atan2(p.x, - 1 * p.y));
|
}
|
else {
|
ce = 2 * Math.atan(rh * this.cosX0 / (2 * this.a * this.k0 * this.ms1));
|
lon = this.long0;
|
if (rh <= EPSLN) {
|
Chi = this.X0;
|
}
|
else {
|
Chi = Math.asin(Math.cos(ce) * this.sinX0 + p.y * Math.sin(ce) * this.cosX0 / rh);
|
lon = adjust_lon(this.long0 + Math.atan2(p.x * Math.sin(ce), rh * this.cosX0 * Math.cos(ce) - p.y * this.sinX0 * Math.sin(ce)));
|
}
|
lat = -1 * phi2z(this.e, Math.tan(0.5 * (HALF_PI + Chi)));
|
}
|
}
|
p.x = lon;
|
p.y = lat;
|
|
//trace(p.toString());
|
return p;
|
|
}
|
|
var stere_names = ["stere", "Stereographic_South_Pole", "Polar Stereographic (variant B)"];
|
/* harmony default export */ var stere = ({
|
init: stere_init,
|
forward: stere_forward,
|
inverse: stere_inverse,
|
names: stere_names,
|
ssfn_: ssfn_
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/somerc.js
|
/*
|
references:
|
Formules et constantes pour le Calcul pour la
|
projection cylindrique conforme à axe oblique et pour la transformation entre
|
des systèmes de référence.
|
http://www.swisstopo.admin.ch/internet/swisstopo/fr/home/topics/survey/sys/refsys/switzerland.parsysrelated1.31216.downloadList.77004.DownloadFile.tmp/swissprojectionfr.pdf
|
*/
|
|
function somerc_init() {
|
var phy0 = this.lat0;
|
this.lambda0 = this.long0;
|
var sinPhy0 = Math.sin(phy0);
|
var semiMajorAxis = this.a;
|
var invF = this.rf;
|
var flattening = 1 / invF;
|
var e2 = 2 * flattening - Math.pow(flattening, 2);
|
var e = this.e = Math.sqrt(e2);
|
this.R = this.k0 * semiMajorAxis * Math.sqrt(1 - e2) / (1 - e2 * Math.pow(sinPhy0, 2));
|
this.alpha = Math.sqrt(1 + e2 / (1 - e2) * Math.pow(Math.cos(phy0), 4));
|
this.b0 = Math.asin(sinPhy0 / this.alpha);
|
var k1 = Math.log(Math.tan(Math.PI / 4 + this.b0 / 2));
|
var k2 = Math.log(Math.tan(Math.PI / 4 + phy0 / 2));
|
var k3 = Math.log((1 + e * sinPhy0) / (1 - e * sinPhy0));
|
this.K = k1 - this.alpha * k2 + this.alpha * e / 2 * k3;
|
}
|
|
function somerc_forward(p) {
|
var Sa1 = Math.log(Math.tan(Math.PI / 4 - p.y / 2));
|
var Sa2 = this.e / 2 * Math.log((1 + this.e * Math.sin(p.y)) / (1 - this.e * Math.sin(p.y)));
|
var S = -this.alpha * (Sa1 + Sa2) + this.K;
|
|
// spheric latitude
|
var b = 2 * (Math.atan(Math.exp(S)) - Math.PI / 4);
|
|
// spheric longitude
|
var I = this.alpha * (p.x - this.lambda0);
|
|
// psoeudo equatorial rotation
|
var rotI = Math.atan(Math.sin(I) / (Math.sin(this.b0) * Math.tan(b) + Math.cos(this.b0) * Math.cos(I)));
|
|
var rotB = Math.asin(Math.cos(this.b0) * Math.sin(b) - Math.sin(this.b0) * Math.cos(b) * Math.cos(I));
|
|
p.y = this.R / 2 * Math.log((1 + Math.sin(rotB)) / (1 - Math.sin(rotB))) + this.y0;
|
p.x = this.R * rotI + this.x0;
|
return p;
|
}
|
|
function somerc_inverse(p) {
|
var Y = p.x - this.x0;
|
var X = p.y - this.y0;
|
|
var rotI = Y / this.R;
|
var rotB = 2 * (Math.atan(Math.exp(X / this.R)) - Math.PI / 4);
|
|
var b = Math.asin(Math.cos(this.b0) * Math.sin(rotB) + Math.sin(this.b0) * Math.cos(rotB) * Math.cos(rotI));
|
var I = Math.atan(Math.sin(rotI) / (Math.cos(this.b0) * Math.cos(rotI) - Math.sin(this.b0) * Math.tan(rotB)));
|
|
var lambda = this.lambda0 + I / this.alpha;
|
|
var S = 0;
|
var phy = b;
|
var prevPhy = -1000;
|
var iteration = 0;
|
while (Math.abs(phy - prevPhy) > 0.0000001) {
|
if (++iteration > 20) {
|
//...reportError("omercFwdInfinity");
|
return;
|
}
|
//S = Math.log(Math.tan(Math.PI / 4 + phy / 2));
|
S = 1 / this.alpha * (Math.log(Math.tan(Math.PI / 4 + b / 2)) - this.K) + this.e * Math.log(Math.tan(Math.PI / 4 + Math.asin(this.e * Math.sin(phy)) / 2));
|
prevPhy = phy;
|
phy = 2 * Math.atan(Math.exp(S)) - Math.PI / 2;
|
}
|
|
p.x = lambda;
|
p.y = phy;
|
return p;
|
}
|
|
var somerc_names = ["somerc"];
|
/* harmony default export */ var somerc = ({
|
init: somerc_init,
|
forward: somerc_forward,
|
inverse: somerc_inverse,
|
names: somerc_names
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/omerc.js
|
|
|
|
|
|
var TOL = 1e-7;
|
|
function isTypeA(P) {
|
var typeAProjections = ['Hotine_Oblique_Mercator','Hotine_Oblique_Mercator_Azimuth_Natural_Origin'];
|
var projectionName = typeof P.PROJECTION === "object" ? Object.keys(P.PROJECTION)[0] : P.PROJECTION;
|
|
return 'no_uoff' in P || 'no_off' in P || typeAProjections.indexOf(projectionName) !== -1;
|
}
|
|
|
/* Initialize the Oblique Mercator projection
|
------------------------------------------*/
|
function omerc_init() {
|
var con, com, cosph0, D, F, H, L, sinph0, p, J, gamma = 0,
|
gamma0, lamc = 0, lam1 = 0, lam2 = 0, phi1 = 0, phi2 = 0, alpha_c = 0, AB;
|
|
// only Type A uses the no_off or no_uoff property
|
// https://github.com/OSGeo/proj.4/issues/104
|
this.no_off = isTypeA(this);
|
this.no_rot = 'no_rot' in this;
|
|
var alp = false;
|
if ("alpha" in this) {
|
alp = true;
|
}
|
|
var gam = false;
|
if ("rectified_grid_angle" in this) {
|
gam = true;
|
}
|
|
if (alp) {
|
alpha_c = this.alpha;
|
}
|
|
if (gam) {
|
gamma = (this.rectified_grid_angle * D2R);
|
}
|
|
if (alp || gam) {
|
lamc = this.longc;
|
} else {
|
lam1 = this.long1;
|
phi1 = this.lat1;
|
lam2 = this.long2;
|
phi2 = this.lat2;
|
|
if (Math.abs(phi1 - phi2) <= TOL || (con = Math.abs(phi1)) <= TOL ||
|
Math.abs(con - HALF_PI) <= TOL || Math.abs(Math.abs(this.lat0) - HALF_PI) <= TOL ||
|
Math.abs(Math.abs(phi2) - HALF_PI) <= TOL) {
|
throw new Error();
|
}
|
}
|
|
var one_es = 1.0 - this.es;
|
com = Math.sqrt(one_es);
|
|
if (Math.abs(this.lat0) > EPSLN) {
|
sinph0 = Math.sin(this.lat0);
|
cosph0 = Math.cos(this.lat0);
|
con = 1 - this.es * sinph0 * sinph0;
|
this.B = cosph0 * cosph0;
|
this.B = Math.sqrt(1 + this.es * this.B * this.B / one_es);
|
this.A = this.B * this.k0 * com / con;
|
D = this.B * com / (cosph0 * Math.sqrt(con));
|
F = D * D -1;
|
|
if (F <= 0) {
|
F = 0;
|
} else {
|
F = Math.sqrt(F);
|
if (this.lat0 < 0) {
|
F = -F;
|
}
|
}
|
|
this.E = F += D;
|
this.E *= Math.pow(tsfnz(this.e, this.lat0, sinph0), this.B);
|
} else {
|
this.B = 1 / com;
|
this.A = this.k0;
|
this.E = D = F = 1;
|
}
|
|
if (alp || gam) {
|
if (alp) {
|
gamma0 = Math.asin(Math.sin(alpha_c) / D);
|
if (!gam) {
|
gamma = alpha_c;
|
}
|
} else {
|
gamma0 = gamma;
|
alpha_c = Math.asin(D * Math.sin(gamma0));
|
}
|
this.lam0 = lamc - Math.asin(0.5 * (F - 1 / F) * Math.tan(gamma0)) / this.B;
|
} else {
|
H = Math.pow(tsfnz(this.e, phi1, Math.sin(phi1)), this.B);
|
L = Math.pow(tsfnz(this.e, phi2, Math.sin(phi2)), this.B);
|
F = this.E / H;
|
p = (L - H) / (L + H);
|
J = this.E * this.E;
|
J = (J - L * H) / (J + L * H);
|
con = lam1 - lam2;
|
|
if (con < -Math.pi) {
|
lam2 -=TWO_PI;
|
} else if (con > Math.pi) {
|
lam2 += TWO_PI;
|
}
|
|
this.lam0 = adjust_lon(0.5 * (lam1 + lam2) - Math.atan(J * Math.tan(0.5 * this.B * (lam1 - lam2)) / p) / this.B);
|
gamma0 = Math.atan(2 * Math.sin(this.B * adjust_lon(lam1 - this.lam0)) / (F - 1 / F));
|
gamma = alpha_c = Math.asin(D * Math.sin(gamma0));
|
}
|
|
this.singam = Math.sin(gamma0);
|
this.cosgam = Math.cos(gamma0);
|
this.sinrot = Math.sin(gamma);
|
this.cosrot = Math.cos(gamma);
|
|
this.rB = 1 / this.B;
|
this.ArB = this.A * this.rB;
|
this.BrA = 1 / this.ArB;
|
AB = this.A * this.B;
|
|
if (this.no_off) {
|
this.u_0 = 0;
|
} else {
|
this.u_0 = Math.abs(this.ArB * Math.atan(Math.sqrt(D * D - 1) / Math.cos(alpha_c)));
|
|
if (this.lat0 < 0) {
|
this.u_0 = - this.u_0;
|
}
|
}
|
|
F = 0.5 * gamma0;
|
this.v_pole_n = this.ArB * Math.log(Math.tan(FORTPI - F));
|
this.v_pole_s = this.ArB * Math.log(Math.tan(FORTPI + F));
|
}
|
|
|
/* Oblique Mercator forward equations--mapping lat,long to x,y
|
----------------------------------------------------------*/
|
function omerc_forward(p) {
|
var coords = {};
|
var S, T, U, V, W, temp, u, v;
|
p.x = p.x - this.lam0;
|
|
if (Math.abs(Math.abs(p.y) - HALF_PI) > EPSLN) {
|
W = this.E / Math.pow(tsfnz(this.e, p.y, Math.sin(p.y)), this.B);
|
|
temp = 1 / W;
|
S = 0.5 * (W - temp);
|
T = 0.5 * (W + temp);
|
V = Math.sin(this.B * p.x);
|
U = (S * this.singam - V * this.cosgam) / T;
|
|
if (Math.abs(Math.abs(U) - 1.0) < EPSLN) {
|
throw new Error();
|
}
|
|
v = 0.5 * this.ArB * Math.log((1 - U)/(1 + U));
|
temp = Math.cos(this.B * p.x);
|
|
if (Math.abs(temp) < TOL) {
|
u = this.A * p.x;
|
} else {
|
u = this.ArB * Math.atan2((S * this.cosgam + V * this.singam), temp);
|
}
|
} else {
|
v = p.y > 0 ? this.v_pole_n : this.v_pole_s;
|
u = this.ArB * p.y;
|
}
|
|
if (this.no_rot) {
|
coords.x = u;
|
coords.y = v;
|
} else {
|
u -= this.u_0;
|
coords.x = v * this.cosrot + u * this.sinrot;
|
coords.y = u * this.cosrot - v * this.sinrot;
|
}
|
|
coords.x = (this.a * coords.x + this.x0);
|
coords.y = (this.a * coords.y + this.y0);
|
|
return coords;
|
}
|
|
function omerc_inverse(p) {
|
var u, v, Qp, Sp, Tp, Vp, Up;
|
var coords = {};
|
|
p.x = (p.x - this.x0) * (1.0 / this.a);
|
p.y = (p.y - this.y0) * (1.0 / this.a);
|
|
if (this.no_rot) {
|
v = p.y;
|
u = p.x;
|
} else {
|
v = p.x * this.cosrot - p.y * this.sinrot;
|
u = p.y * this.cosrot + p.x * this.sinrot + this.u_0;
|
}
|
|
Qp = Math.exp(-this.BrA * v);
|
Sp = 0.5 * (Qp - 1 / Qp);
|
Tp = 0.5 * (Qp + 1 / Qp);
|
Vp = Math.sin(this.BrA * u);
|
Up = (Vp * this.cosgam + Sp * this.singam) / Tp;
|
|
if (Math.abs(Math.abs(Up) - 1) < EPSLN) {
|
coords.x = 0;
|
coords.y = Up < 0 ? -HALF_PI : HALF_PI;
|
} else {
|
coords.y = this.E / Math.sqrt((1 + Up) / (1 - Up));
|
coords.y = phi2z(this.e, Math.pow(coords.y, 1 / this.B));
|
|
if (coords.y === Infinity) {
|
throw new Error();
|
}
|
|
coords.x = -this.rB * Math.atan2((Sp * this.cosgam - Vp * this.singam), Math.cos(this.BrA * u));
|
}
|
|
coords.x += this.lam0;
|
|
return coords;
|
}
|
|
var omerc_names = ["Hotine_Oblique_Mercator", "Hotine Oblique Mercator", "Hotine_Oblique_Mercator_Azimuth_Natural_Origin", "Hotine_Oblique_Mercator_Two_Point_Natural_Origin", "Hotine_Oblique_Mercator_Azimuth_Center", "Oblique_Mercator", "omerc"];
|
/* harmony default export */ var omerc = ({
|
init: omerc_init,
|
forward: omerc_forward,
|
inverse: omerc_inverse,
|
names: omerc_names
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/lcc.js
|
|
|
|
|
|
|
function lcc_init() {
|
|
//double lat0; /* the reference latitude */
|
//double long0; /* the reference longitude */
|
//double lat1; /* first standard parallel */
|
//double lat2; /* second standard parallel */
|
//double r_maj; /* major axis */
|
//double r_min; /* minor axis */
|
//double false_east; /* x offset in meters */
|
//double false_north; /* y offset in meters */
|
|
//the above value can be set with proj4.defs
|
//example: proj4.defs("EPSG:2154","+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs");
|
|
if (!this.lat2) {
|
this.lat2 = this.lat1;
|
} //if lat2 is not defined
|
if (!this.k0) {
|
this.k0 = 1;
|
}
|
this.x0 = this.x0 || 0;
|
this.y0 = this.y0 || 0;
|
// Standard Parallels cannot be equal and on opposite sides of the equator
|
if (Math.abs(this.lat1 + this.lat2) < EPSLN) {
|
return;
|
}
|
|
var temp = this.b / this.a;
|
this.e = Math.sqrt(1 - temp * temp);
|
|
var sin1 = Math.sin(this.lat1);
|
var cos1 = Math.cos(this.lat1);
|
var ms1 = msfnz(this.e, sin1, cos1);
|
var ts1 = tsfnz(this.e, this.lat1, sin1);
|
|
var sin2 = Math.sin(this.lat2);
|
var cos2 = Math.cos(this.lat2);
|
var ms2 = msfnz(this.e, sin2, cos2);
|
var ts2 = tsfnz(this.e, this.lat2, sin2);
|
|
var ts0 = tsfnz(this.e, this.lat0, Math.sin(this.lat0));
|
|
if (Math.abs(this.lat1 - this.lat2) > EPSLN) {
|
this.ns = Math.log(ms1 / ms2) / Math.log(ts1 / ts2);
|
}
|
else {
|
this.ns = sin1;
|
}
|
if (isNaN(this.ns)) {
|
this.ns = sin1;
|
}
|
this.f0 = ms1 / (this.ns * Math.pow(ts1, this.ns));
|
this.rh = this.a * this.f0 * Math.pow(ts0, this.ns);
|
if (!this.title) {
|
this.title = "Lambert Conformal Conic";
|
}
|
}
|
|
// Lambert Conformal conic forward equations--mapping lat,long to x,y
|
// -----------------------------------------------------------------
|
function lcc_forward(p) {
|
|
var lon = p.x;
|
var lat = p.y;
|
|
// singular cases :
|
if (Math.abs(2 * Math.abs(lat) - Math.PI) <= EPSLN) {
|
lat = sign(lat) * (HALF_PI - 2 * EPSLN);
|
}
|
|
var con = Math.abs(Math.abs(lat) - HALF_PI);
|
var ts, rh1;
|
if (con > EPSLN) {
|
ts = tsfnz(this.e, lat, Math.sin(lat));
|
rh1 = this.a * this.f0 * Math.pow(ts, this.ns);
|
}
|
else {
|
con = lat * this.ns;
|
if (con <= 0) {
|
return null;
|
}
|
rh1 = 0;
|
}
|
var theta = this.ns * adjust_lon(lon - this.long0);
|
p.x = this.k0 * (rh1 * Math.sin(theta)) + this.x0;
|
p.y = this.k0 * (this.rh - rh1 * Math.cos(theta)) + this.y0;
|
|
return p;
|
}
|
|
// Lambert Conformal Conic inverse equations--mapping x,y to lat/long
|
// -----------------------------------------------------------------
|
function lcc_inverse(p) {
|
|
var rh1, con, ts;
|
var lat, lon;
|
var x = (p.x - this.x0) / this.k0;
|
var y = (this.rh - (p.y - this.y0) / this.k0);
|
if (this.ns > 0) {
|
rh1 = Math.sqrt(x * x + y * y);
|
con = 1;
|
}
|
else {
|
rh1 = -Math.sqrt(x * x + y * y);
|
con = -1;
|
}
|
var theta = 0;
|
if (rh1 !== 0) {
|
theta = Math.atan2((con * x), (con * y));
|
}
|
if ((rh1 !== 0) || (this.ns > 0)) {
|
con = 1 / this.ns;
|
ts = Math.pow((rh1 / (this.a * this.f0)), con);
|
lat = phi2z(this.e, ts);
|
if (lat === -9999) {
|
return null;
|
}
|
}
|
else {
|
lat = -HALF_PI;
|
}
|
lon = adjust_lon(theta / this.ns + this.long0);
|
|
p.x = lon;
|
p.y = lat;
|
return p;
|
}
|
|
var lcc_names = [
|
"Lambert Tangential Conformal Conic Projection",
|
"Lambert_Conformal_Conic",
|
"Lambert_Conformal_Conic_1SP",
|
"Lambert_Conformal_Conic_2SP",
|
"lcc",
|
"Lambert Conic Conformal (1SP)",
|
"Lambert Conic Conformal (2SP)"
|
];
|
|
/* harmony default export */ var lcc = ({
|
init: lcc_init,
|
forward: lcc_forward,
|
inverse: lcc_inverse,
|
names: lcc_names
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/krovak.js
|
|
|
function krovak_init() {
|
this.a = 6377397.155;
|
this.es = 0.006674372230614;
|
this.e = Math.sqrt(this.es);
|
if (!this.lat0) {
|
this.lat0 = 0.863937979737193;
|
}
|
if (!this.long0) {
|
this.long0 = 0.7417649320975901 - 0.308341501185665;
|
}
|
/* if scale not set default to 0.9999 */
|
if (!this.k0) {
|
this.k0 = 0.9999;
|
}
|
this.s45 = 0.785398163397448; /* 45 */
|
this.s90 = 2 * this.s45;
|
this.fi0 = this.lat0;
|
this.e2 = this.es;
|
this.e = Math.sqrt(this.e2);
|
this.alfa = Math.sqrt(1 + (this.e2 * Math.pow(Math.cos(this.fi0), 4)) / (1 - this.e2));
|
this.uq = 1.04216856380474;
|
this.u0 = Math.asin(Math.sin(this.fi0) / this.alfa);
|
this.g = Math.pow((1 + this.e * Math.sin(this.fi0)) / (1 - this.e * Math.sin(this.fi0)), this.alfa * this.e / 2);
|
this.k = Math.tan(this.u0 / 2 + this.s45) / Math.pow(Math.tan(this.fi0 / 2 + this.s45), this.alfa) * this.g;
|
this.k1 = this.k0;
|
this.n0 = this.a * Math.sqrt(1 - this.e2) / (1 - this.e2 * Math.pow(Math.sin(this.fi0), 2));
|
this.s0 = 1.37008346281555;
|
this.n = Math.sin(this.s0);
|
this.ro0 = this.k1 * this.n0 / Math.tan(this.s0);
|
this.ad = this.s90 - this.uq;
|
}
|
|
/* ellipsoid */
|
/* calculate xy from lat/lon */
|
/* Constants, identical to inverse transform function */
|
function krovak_forward(p) {
|
var gfi, u, deltav, s, d, eps, ro;
|
var lon = p.x;
|
var lat = p.y;
|
var delta_lon = adjust_lon(lon - this.long0);
|
/* Transformation */
|
gfi = Math.pow(((1 + this.e * Math.sin(lat)) / (1 - this.e * Math.sin(lat))), (this.alfa * this.e / 2));
|
u = 2 * (Math.atan(this.k * Math.pow(Math.tan(lat / 2 + this.s45), this.alfa) / gfi) - this.s45);
|
deltav = -delta_lon * this.alfa;
|
s = Math.asin(Math.cos(this.ad) * Math.sin(u) + Math.sin(this.ad) * Math.cos(u) * Math.cos(deltav));
|
d = Math.asin(Math.cos(u) * Math.sin(deltav) / Math.cos(s));
|
eps = this.n * d;
|
ro = this.ro0 * Math.pow(Math.tan(this.s0 / 2 + this.s45), this.n) / Math.pow(Math.tan(s / 2 + this.s45), this.n);
|
p.y = ro * Math.cos(eps) / 1;
|
p.x = ro * Math.sin(eps) / 1;
|
|
if (!this.czech) {
|
p.y *= -1;
|
p.x *= -1;
|
}
|
return (p);
|
}
|
|
/* calculate lat/lon from xy */
|
function krovak_inverse(p) {
|
var u, deltav, s, d, eps, ro, fi1;
|
var ok;
|
|
/* Transformation */
|
/* revert y, x*/
|
var tmp = p.x;
|
p.x = p.y;
|
p.y = tmp;
|
if (!this.czech) {
|
p.y *= -1;
|
p.x *= -1;
|
}
|
ro = Math.sqrt(p.x * p.x + p.y * p.y);
|
eps = Math.atan2(p.y, p.x);
|
d = eps / Math.sin(this.s0);
|
s = 2 * (Math.atan(Math.pow(this.ro0 / ro, 1 / this.n) * Math.tan(this.s0 / 2 + this.s45)) - this.s45);
|
u = Math.asin(Math.cos(this.ad) * Math.sin(s) - Math.sin(this.ad) * Math.cos(s) * Math.cos(d));
|
deltav = Math.asin(Math.cos(s) * Math.sin(d) / Math.cos(u));
|
p.x = this.long0 - deltav / this.alfa;
|
fi1 = u;
|
ok = 0;
|
var iter = 0;
|
do {
|
p.y = 2 * (Math.atan(Math.pow(this.k, - 1 / this.alfa) * Math.pow(Math.tan(u / 2 + this.s45), 1 / this.alfa) * Math.pow((1 + this.e * Math.sin(fi1)) / (1 - this.e * Math.sin(fi1)), this.e / 2)) - this.s45);
|
if (Math.abs(fi1 - p.y) < 0.0000000001) {
|
ok = 1;
|
}
|
fi1 = p.y;
|
iter += 1;
|
} while (ok === 0 && iter < 15);
|
if (iter >= 15) {
|
return null;
|
}
|
|
return (p);
|
}
|
|
var krovak_names = ["Krovak", "krovak"];
|
/* harmony default export */ var krovak = ({
|
init: krovak_init,
|
forward: krovak_forward,
|
inverse: krovak_inverse,
|
names: krovak_names
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/mlfn.js
|
/* harmony default export */ var mlfn = (function(e0, e1, e2, e3, phi) {
|
return (e0 * phi - e1 * Math.sin(2 * phi) + e2 * Math.sin(4 * phi) - e3 * Math.sin(6 * phi));
|
});
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/e0fn.js
|
/* harmony default export */ var e0fn = (function(x) {
|
return (1 - 0.25 * x * (1 + x / 16 * (3 + 1.25 * x)));
|
});
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/e1fn.js
|
/* harmony default export */ var e1fn = (function(x) {
|
return (0.375 * x * (1 + 0.25 * x * (1 + 0.46875 * x)));
|
});
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/e2fn.js
|
/* harmony default export */ var e2fn = (function(x) {
|
return (0.05859375 * x * x * (1 + 0.75 * x));
|
});
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/e3fn.js
|
/* harmony default export */ var e3fn = (function(x) {
|
return (x * x * x * (35 / 3072));
|
});
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/gN.js
|
/* harmony default export */ var gN = (function(a, e, sinphi) {
|
var temp = e * sinphi;
|
return a / Math.sqrt(1 - temp * temp);
|
});
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/adjust_lat.js
|
|
|
|
/* harmony default export */ var adjust_lat = (function(x) {
|
return (Math.abs(x) < HALF_PI) ? x : (x - (sign(x) * Math.PI));
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/imlfn.js
|
/* harmony default export */ var imlfn = (function(ml, e0, e1, e2, e3) {
|
var phi;
|
var dphi;
|
|
phi = ml / e0;
|
for (var i = 0; i < 15; i++) {
|
dphi = (ml - (e0 * phi - e1 * Math.sin(2 * phi) + e2 * Math.sin(4 * phi) - e3 * Math.sin(6 * phi))) / (e0 - 2 * e1 * Math.cos(2 * phi) + 4 * e2 * Math.cos(4 * phi) - 6 * e3 * Math.cos(6 * phi));
|
phi += dphi;
|
if (Math.abs(dphi) <= 0.0000000001) {
|
return phi;
|
}
|
}
|
|
//..reportError("IMLFN-CONV:Latitude failed to converge after 15 iterations");
|
return NaN;
|
});
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/cass.js
|
|
|
|
|
|
|
|
|
|
|
|
function cass_init() {
|
if (!this.sphere) {
|
this.e0 = e0fn(this.es);
|
this.e1 = e1fn(this.es);
|
this.e2 = e2fn(this.es);
|
this.e3 = e3fn(this.es);
|
this.ml0 = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, this.lat0);
|
}
|
}
|
|
/* Cassini forward equations--mapping lat,long to x,y
|
-----------------------------------------------------------------------*/
|
function cass_forward(p) {
|
|
/* Forward equations
|
-----------------*/
|
var x, y;
|
var lam = p.x;
|
var phi = p.y;
|
lam = adjust_lon(lam - this.long0);
|
|
if (this.sphere) {
|
x = this.a * Math.asin(Math.cos(phi) * Math.sin(lam));
|
y = this.a * (Math.atan2(Math.tan(phi), Math.cos(lam)) - this.lat0);
|
}
|
else {
|
//ellipsoid
|
var sinphi = Math.sin(phi);
|
var cosphi = Math.cos(phi);
|
var nl = gN(this.a, this.e, sinphi);
|
var tl = Math.tan(phi) * Math.tan(phi);
|
var al = lam * Math.cos(phi);
|
var asq = al * al;
|
var cl = this.es * cosphi * cosphi / (1 - this.es);
|
var ml = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, phi);
|
|
x = nl * al * (1 - asq * tl * (1 / 6 - (8 - tl + 8 * cl) * asq / 120));
|
y = ml - this.ml0 + nl * sinphi / cosphi * asq * (0.5 + (5 - tl + 6 * cl) * asq / 24);
|
|
|
}
|
|
p.x = x + this.x0;
|
p.y = y + this.y0;
|
return p;
|
}
|
|
/* Inverse equations
|
-----------------*/
|
function cass_inverse(p) {
|
p.x -= this.x0;
|
p.y -= this.y0;
|
var x = p.x / this.a;
|
var y = p.y / this.a;
|
var phi, lam;
|
|
if (this.sphere) {
|
var dd = y + this.lat0;
|
phi = Math.asin(Math.sin(dd) * Math.cos(x));
|
lam = Math.atan2(Math.tan(x), Math.cos(dd));
|
}
|
else {
|
/* ellipsoid */
|
var ml1 = this.ml0 / this.a + y;
|
var phi1 = imlfn(ml1, this.e0, this.e1, this.e2, this.e3);
|
if (Math.abs(Math.abs(phi1) - HALF_PI) <= EPSLN) {
|
p.x = this.long0;
|
p.y = HALF_PI;
|
if (y < 0) {
|
p.y *= -1;
|
}
|
return p;
|
}
|
var nl1 = gN(this.a, this.e, Math.sin(phi1));
|
|
var rl1 = nl1 * nl1 * nl1 / this.a / this.a * (1 - this.es);
|
var tl1 = Math.pow(Math.tan(phi1), 2);
|
var dl = x * this.a / nl1;
|
var dsq = dl * dl;
|
phi = phi1 - nl1 * Math.tan(phi1) / rl1 * dl * dl * (0.5 - (1 + 3 * tl1) * dl * dl / 24);
|
lam = dl * (1 - dsq * (tl1 / 3 + (1 + 3 * tl1) * tl1 * dsq / 15)) / Math.cos(phi1);
|
|
}
|
|
p.x = adjust_lon(lam + this.long0);
|
p.y = adjust_lat(phi);
|
return p;
|
|
}
|
|
var cass_names = ["Cassini", "Cassini_Soldner", "cass"];
|
/* harmony default export */ var cass = ({
|
init: cass_init,
|
forward: cass_forward,
|
inverse: cass_inverse,
|
names: cass_names
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/qsfnz.js
|
/* harmony default export */ var qsfnz = (function(eccent, sinphi) {
|
var con;
|
if (eccent > 1.0e-7) {
|
con = eccent * sinphi;
|
return ((1 - eccent * eccent) * (sinphi / (1 - con * con) - (0.5 / eccent) * Math.log((1 - con) / (1 + con))));
|
}
|
else {
|
return (2 * sinphi);
|
}
|
});
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/laea.js
|
|
|
|
|
|
|
/*
|
reference
|
"New Equal-Area Map Projections for Noncircular Regions", John P. Snyder,
|
The American Cartographer, Vol 15, No. 4, October 1988, pp. 341-355.
|
*/
|
|
var S_POLE = 1;
|
|
var N_POLE = 2;
|
var EQUIT = 3;
|
var OBLIQ = 4;
|
|
/* Initialize the Lambert Azimuthal Equal Area projection
|
------------------------------------------------------*/
|
function laea_init() {
|
var t = Math.abs(this.lat0);
|
if (Math.abs(t - HALF_PI) < EPSLN) {
|
this.mode = this.lat0 < 0 ? this.S_POLE : this.N_POLE;
|
}
|
else if (Math.abs(t) < EPSLN) {
|
this.mode = this.EQUIT;
|
}
|
else {
|
this.mode = this.OBLIQ;
|
}
|
if (this.es > 0) {
|
var sinphi;
|
|
this.qp = qsfnz(this.e, 1);
|
this.mmf = 0.5 / (1 - this.es);
|
this.apa = authset(this.es);
|
switch (this.mode) {
|
case this.N_POLE:
|
this.dd = 1;
|
break;
|
case this.S_POLE:
|
this.dd = 1;
|
break;
|
case this.EQUIT:
|
this.rq = Math.sqrt(0.5 * this.qp);
|
this.dd = 1 / this.rq;
|
this.xmf = 1;
|
this.ymf = 0.5 * this.qp;
|
break;
|
case this.OBLIQ:
|
this.rq = Math.sqrt(0.5 * this.qp);
|
sinphi = Math.sin(this.lat0);
|
this.sinb1 = qsfnz(this.e, sinphi) / this.qp;
|
this.cosb1 = Math.sqrt(1 - this.sinb1 * this.sinb1);
|
this.dd = Math.cos(this.lat0) / (Math.sqrt(1 - this.es * sinphi * sinphi) * this.rq * this.cosb1);
|
this.ymf = (this.xmf = this.rq) / this.dd;
|
this.xmf *= this.dd;
|
break;
|
}
|
}
|
else {
|
if (this.mode === this.OBLIQ) {
|
this.sinph0 = Math.sin(this.lat0);
|
this.cosph0 = Math.cos(this.lat0);
|
}
|
}
|
}
|
|
/* Lambert Azimuthal Equal Area forward equations--mapping lat,long to x,y
|
-----------------------------------------------------------------------*/
|
function laea_forward(p) {
|
|
/* Forward equations
|
-----------------*/
|
var x, y, coslam, sinlam, sinphi, q, sinb, cosb, b, cosphi;
|
var lam = p.x;
|
var phi = p.y;
|
|
lam = adjust_lon(lam - this.long0);
|
if (this.sphere) {
|
sinphi = Math.sin(phi);
|
cosphi = Math.cos(phi);
|
coslam = Math.cos(lam);
|
if (this.mode === this.OBLIQ || this.mode === this.EQUIT) {
|
y = (this.mode === this.EQUIT) ? 1 + cosphi * coslam : 1 + this.sinph0 * sinphi + this.cosph0 * cosphi * coslam;
|
if (y <= EPSLN) {
|
return null;
|
}
|
y = Math.sqrt(2 / y);
|
x = y * cosphi * Math.sin(lam);
|
y *= (this.mode === this.EQUIT) ? sinphi : this.cosph0 * sinphi - this.sinph0 * cosphi * coslam;
|
}
|
else if (this.mode === this.N_POLE || this.mode === this.S_POLE) {
|
if (this.mode === this.N_POLE) {
|
coslam = -coslam;
|
}
|
if (Math.abs(phi + this.lat0) < EPSLN) {
|
return null;
|
}
|
y = FORTPI - phi * 0.5;
|
y = 2 * ((this.mode === this.S_POLE) ? Math.cos(y) : Math.sin(y));
|
x = y * Math.sin(lam);
|
y *= coslam;
|
}
|
}
|
else {
|
sinb = 0;
|
cosb = 0;
|
b = 0;
|
coslam = Math.cos(lam);
|
sinlam = Math.sin(lam);
|
sinphi = Math.sin(phi);
|
q = qsfnz(this.e, sinphi);
|
if (this.mode === this.OBLIQ || this.mode === this.EQUIT) {
|
sinb = q / this.qp;
|
cosb = Math.sqrt(1 - sinb * sinb);
|
}
|
switch (this.mode) {
|
case this.OBLIQ:
|
b = 1 + this.sinb1 * sinb + this.cosb1 * cosb * coslam;
|
break;
|
case this.EQUIT:
|
b = 1 + cosb * coslam;
|
break;
|
case this.N_POLE:
|
b = HALF_PI + phi;
|
q = this.qp - q;
|
break;
|
case this.S_POLE:
|
b = phi - HALF_PI;
|
q = this.qp + q;
|
break;
|
}
|
if (Math.abs(b) < EPSLN) {
|
return null;
|
}
|
switch (this.mode) {
|
case this.OBLIQ:
|
case this.EQUIT:
|
b = Math.sqrt(2 / b);
|
if (this.mode === this.OBLIQ) {
|
y = this.ymf * b * (this.cosb1 * sinb - this.sinb1 * cosb * coslam);
|
}
|
else {
|
y = (b = Math.sqrt(2 / (1 + cosb * coslam))) * sinb * this.ymf;
|
}
|
x = this.xmf * b * cosb * sinlam;
|
break;
|
case this.N_POLE:
|
case this.S_POLE:
|
if (q >= 0) {
|
x = (b = Math.sqrt(q)) * sinlam;
|
y = coslam * ((this.mode === this.S_POLE) ? b : -b);
|
}
|
else {
|
x = y = 0;
|
}
|
break;
|
}
|
}
|
|
p.x = this.a * x + this.x0;
|
p.y = this.a * y + this.y0;
|
return p;
|
}
|
|
/* Inverse equations
|
-----------------*/
|
function laea_inverse(p) {
|
p.x -= this.x0;
|
p.y -= this.y0;
|
var x = p.x / this.a;
|
var y = p.y / this.a;
|
var lam, phi, cCe, sCe, q, rho, ab;
|
if (this.sphere) {
|
var cosz = 0,
|
rh, sinz = 0;
|
|
rh = Math.sqrt(x * x + y * y);
|
phi = rh * 0.5;
|
if (phi > 1) {
|
return null;
|
}
|
phi = 2 * Math.asin(phi);
|
if (this.mode === this.OBLIQ || this.mode === this.EQUIT) {
|
sinz = Math.sin(phi);
|
cosz = Math.cos(phi);
|
}
|
switch (this.mode) {
|
case this.EQUIT:
|
phi = (Math.abs(rh) <= EPSLN) ? 0 : Math.asin(y * sinz / rh);
|
x *= sinz;
|
y = cosz * rh;
|
break;
|
case this.OBLIQ:
|
phi = (Math.abs(rh) <= EPSLN) ? this.lat0 : Math.asin(cosz * this.sinph0 + y * sinz * this.cosph0 / rh);
|
x *= sinz * this.cosph0;
|
y = (cosz - Math.sin(phi) * this.sinph0) * rh;
|
break;
|
case this.N_POLE:
|
y = -y;
|
phi = HALF_PI - phi;
|
break;
|
case this.S_POLE:
|
phi -= HALF_PI;
|
break;
|
}
|
lam = (y === 0 && (this.mode === this.EQUIT || this.mode === this.OBLIQ)) ? 0 : Math.atan2(x, y);
|
}
|
else {
|
ab = 0;
|
if (this.mode === this.OBLIQ || this.mode === this.EQUIT) {
|
x /= this.dd;
|
y *= this.dd;
|
rho = Math.sqrt(x * x + y * y);
|
if (rho < EPSLN) {
|
p.x = this.long0;
|
p.y = this.lat0;
|
return p;
|
}
|
sCe = 2 * Math.asin(0.5 * rho / this.rq);
|
cCe = Math.cos(sCe);
|
x *= (sCe = Math.sin(sCe));
|
if (this.mode === this.OBLIQ) {
|
ab = cCe * this.sinb1 + y * sCe * this.cosb1 / rho;
|
q = this.qp * ab;
|
y = rho * this.cosb1 * cCe - y * this.sinb1 * sCe;
|
}
|
else {
|
ab = y * sCe / rho;
|
q = this.qp * ab;
|
y = rho * cCe;
|
}
|
}
|
else if (this.mode === this.N_POLE || this.mode === this.S_POLE) {
|
if (this.mode === this.N_POLE) {
|
y = -y;
|
}
|
q = (x * x + y * y);
|
if (!q) {
|
p.x = this.long0;
|
p.y = this.lat0;
|
return p;
|
}
|
ab = 1 - q / this.qp;
|
if (this.mode === this.S_POLE) {
|
ab = -ab;
|
}
|
}
|
lam = Math.atan2(x, y);
|
phi = authlat(Math.asin(ab), this.apa);
|
}
|
|
p.x = adjust_lon(this.long0 + lam);
|
p.y = phi;
|
return p;
|
}
|
|
/* determine latitude from authalic latitude */
|
var P00 = 0.33333333333333333333;
|
|
var P01 = 0.17222222222222222222;
|
var P02 = 0.10257936507936507936;
|
var P10 = 0.06388888888888888888;
|
var P11 = 0.06640211640211640211;
|
var P20 = 0.01641501294219154443;
|
|
function authset(es) {
|
var t;
|
var APA = [];
|
APA[0] = es * P00;
|
t = es * es;
|
APA[0] += t * P01;
|
APA[1] = t * P10;
|
t *= es;
|
APA[0] += t * P02;
|
APA[1] += t * P11;
|
APA[2] = t * P20;
|
return APA;
|
}
|
|
function authlat(beta, APA) {
|
var t = beta + beta;
|
return (beta + APA[0] * Math.sin(t) + APA[1] * Math.sin(t + t) + APA[2] * Math.sin(t + t + t));
|
}
|
|
var laea_names = ["Lambert Azimuthal Equal Area", "Lambert_Azimuthal_Equal_Area", "laea"];
|
/* harmony default export */ var laea = ({
|
init: laea_init,
|
forward: laea_forward,
|
inverse: laea_inverse,
|
names: laea_names,
|
S_POLE: S_POLE,
|
N_POLE: N_POLE,
|
EQUIT: EQUIT,
|
OBLIQ: OBLIQ
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/asinz.js
|
/* harmony default export */ var asinz = (function(x) {
|
if (Math.abs(x) > 1) {
|
x = (x > 1) ? 1 : -1;
|
}
|
return Math.asin(x);
|
});
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/aea.js
|
|
|
|
|
|
|
function aea_init() {
|
|
if (Math.abs(this.lat1 + this.lat2) < EPSLN) {
|
return;
|
}
|
this.temp = this.b / this.a;
|
this.es = 1 - Math.pow(this.temp, 2);
|
this.e3 = Math.sqrt(this.es);
|
|
this.sin_po = Math.sin(this.lat1);
|
this.cos_po = Math.cos(this.lat1);
|
this.t1 = this.sin_po;
|
this.con = this.sin_po;
|
this.ms1 = msfnz(this.e3, this.sin_po, this.cos_po);
|
this.qs1 = qsfnz(this.e3, this.sin_po, this.cos_po);
|
|
this.sin_po = Math.sin(this.lat2);
|
this.cos_po = Math.cos(this.lat2);
|
this.t2 = this.sin_po;
|
this.ms2 = msfnz(this.e3, this.sin_po, this.cos_po);
|
this.qs2 = qsfnz(this.e3, this.sin_po, this.cos_po);
|
|
this.sin_po = Math.sin(this.lat0);
|
this.cos_po = Math.cos(this.lat0);
|
this.t3 = this.sin_po;
|
this.qs0 = qsfnz(this.e3, this.sin_po, this.cos_po);
|
|
if (Math.abs(this.lat1 - this.lat2) > EPSLN) {
|
this.ns0 = (this.ms1 * this.ms1 - this.ms2 * this.ms2) / (this.qs2 - this.qs1);
|
}
|
else {
|
this.ns0 = this.con;
|
}
|
this.c = this.ms1 * this.ms1 + this.ns0 * this.qs1;
|
this.rh = this.a * Math.sqrt(this.c - this.ns0 * this.qs0) / this.ns0;
|
}
|
|
/* Albers Conical Equal Area forward equations--mapping lat,long to x,y
|
-------------------------------------------------------------------*/
|
function aea_forward(p) {
|
|
var lon = p.x;
|
var lat = p.y;
|
|
this.sin_phi = Math.sin(lat);
|
this.cos_phi = Math.cos(lat);
|
|
var qs = qsfnz(this.e3, this.sin_phi, this.cos_phi);
|
var rh1 = this.a * Math.sqrt(this.c - this.ns0 * qs) / this.ns0;
|
var theta = this.ns0 * adjust_lon(lon - this.long0);
|
var x = rh1 * Math.sin(theta) + this.x0;
|
var y = this.rh - rh1 * Math.cos(theta) + this.y0;
|
|
p.x = x;
|
p.y = y;
|
return p;
|
}
|
|
function aea_inverse(p) {
|
var rh1, qs, con, theta, lon, lat;
|
|
p.x -= this.x0;
|
p.y = this.rh - p.y + this.y0;
|
if (this.ns0 >= 0) {
|
rh1 = Math.sqrt(p.x * p.x + p.y * p.y);
|
con = 1;
|
}
|
else {
|
rh1 = -Math.sqrt(p.x * p.x + p.y * p.y);
|
con = -1;
|
}
|
theta = 0;
|
if (rh1 !== 0) {
|
theta = Math.atan2(con * p.x, con * p.y);
|
}
|
con = rh1 * this.ns0 / this.a;
|
if (this.sphere) {
|
lat = Math.asin((this.c - con * con) / (2 * this.ns0));
|
}
|
else {
|
qs = (this.c - con * con) / this.ns0;
|
lat = this.phi1z(this.e3, qs);
|
}
|
|
lon = adjust_lon(theta / this.ns0 + this.long0);
|
p.x = lon;
|
p.y = lat;
|
return p;
|
}
|
|
/* Function to compute phi1, the latitude for the inverse of the
|
Albers Conical Equal-Area projection.
|
-------------------------------------------*/
|
function phi1z(eccent, qs) {
|
var sinphi, cosphi, con, com, dphi;
|
var phi = asinz(0.5 * qs);
|
if (eccent < EPSLN) {
|
return phi;
|
}
|
|
var eccnts = eccent * eccent;
|
for (var i = 1; i <= 25; i++) {
|
sinphi = Math.sin(phi);
|
cosphi = Math.cos(phi);
|
con = eccent * sinphi;
|
com = 1 - con * con;
|
dphi = 0.5 * com * com / cosphi * (qs / (1 - eccnts) - sinphi / com + 0.5 / eccent * Math.log((1 - con) / (1 + con)));
|
phi = phi + dphi;
|
if (Math.abs(dphi) <= 1e-7) {
|
return phi;
|
}
|
}
|
return null;
|
}
|
|
var aea_names = ["Albers_Conic_Equal_Area", "Albers", "aea"];
|
/* harmony default export */ var aea = ({
|
init: aea_init,
|
forward: aea_forward,
|
inverse: aea_inverse,
|
names: aea_names,
|
phi1z: phi1z
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/gnom.js
|
|
|
|
|
/*
|
reference:
|
Wolfram Mathworld "Gnomonic Projection"
|
http://mathworld.wolfram.com/GnomonicProjection.html
|
Accessed: 12th November 2009
|
*/
|
function gnom_init() {
|
|
/* Place parameters in static storage for common use
|
-------------------------------------------------*/
|
this.sin_p14 = Math.sin(this.lat0);
|
this.cos_p14 = Math.cos(this.lat0);
|
// Approximation for projecting points to the horizon (infinity)
|
this.infinity_dist = 1000 * this.a;
|
this.rc = 1;
|
}
|
|
/* Gnomonic forward equations--mapping lat,long to x,y
|
---------------------------------------------------*/
|
function gnom_forward(p) {
|
var sinphi, cosphi; /* sin and cos value */
|
var dlon; /* delta longitude value */
|
var coslon; /* cos of longitude */
|
var ksp; /* scale factor */
|
var g;
|
var x, y;
|
var lon = p.x;
|
var lat = p.y;
|
/* Forward equations
|
-----------------*/
|
dlon = adjust_lon(lon - this.long0);
|
|
sinphi = Math.sin(lat);
|
cosphi = Math.cos(lat);
|
|
coslon = Math.cos(dlon);
|
g = this.sin_p14 * sinphi + this.cos_p14 * cosphi * coslon;
|
ksp = 1;
|
if ((g > 0) || (Math.abs(g) <= EPSLN)) {
|
x = this.x0 + this.a * ksp * cosphi * Math.sin(dlon) / g;
|
y = this.y0 + this.a * ksp * (this.cos_p14 * sinphi - this.sin_p14 * cosphi * coslon) / g;
|
}
|
else {
|
|
// Point is in the opposing hemisphere and is unprojectable
|
// We still need to return a reasonable point, so we project
|
// to infinity, on a bearing
|
// equivalent to the northern hemisphere equivalent
|
// This is a reasonable approximation for short shapes and lines that
|
// straddle the horizon.
|
|
x = this.x0 + this.infinity_dist * cosphi * Math.sin(dlon);
|
y = this.y0 + this.infinity_dist * (this.cos_p14 * sinphi - this.sin_p14 * cosphi * coslon);
|
|
}
|
p.x = x;
|
p.y = y;
|
return p;
|
}
|
|
function gnom_inverse(p) {
|
var rh; /* Rho */
|
var sinc, cosc;
|
var c;
|
var lon, lat;
|
|
/* Inverse equations
|
-----------------*/
|
p.x = (p.x - this.x0) / this.a;
|
p.y = (p.y - this.y0) / this.a;
|
|
p.x /= this.k0;
|
p.y /= this.k0;
|
|
if ((rh = Math.sqrt(p.x * p.x + p.y * p.y))) {
|
c = Math.atan2(rh, this.rc);
|
sinc = Math.sin(c);
|
cosc = Math.cos(c);
|
|
lat = asinz(cosc * this.sin_p14 + (p.y * sinc * this.cos_p14) / rh);
|
lon = Math.atan2(p.x * sinc, rh * this.cos_p14 * cosc - p.y * this.sin_p14 * sinc);
|
lon = adjust_lon(this.long0 + lon);
|
}
|
else {
|
lat = this.phic0;
|
lon = 0;
|
}
|
|
p.x = lon;
|
p.y = lat;
|
return p;
|
}
|
|
var gnom_names = ["gnom"];
|
/* harmony default export */ var gnom = ({
|
init: gnom_init,
|
forward: gnom_forward,
|
inverse: gnom_inverse,
|
names: gnom_names
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/common/iqsfnz.js
|
|
|
/* harmony default export */ var iqsfnz = (function(eccent, q) {
|
var temp = 1 - (1 - eccent * eccent) / (2 * eccent) * Math.log((1 - eccent) / (1 + eccent));
|
if (Math.abs(Math.abs(q) - temp) < 1.0E-6) {
|
if (q < 0) {
|
return (-1 * HALF_PI);
|
}
|
else {
|
return HALF_PI;
|
}
|
}
|
//var phi = 0.5* q/(1-eccent*eccent);
|
var phi = Math.asin(0.5 * q);
|
var dphi;
|
var sin_phi;
|
var cos_phi;
|
var con;
|
for (var i = 0; i < 30; i++) {
|
sin_phi = Math.sin(phi);
|
cos_phi = Math.cos(phi);
|
con = eccent * sin_phi;
|
dphi = Math.pow(1 - con * con, 2) / (2 * cos_phi) * (q / (1 - eccent * eccent) - sin_phi / (1 - con * con) + 0.5 / eccent * Math.log((1 - con) / (1 + con)));
|
phi += dphi;
|
if (Math.abs(dphi) <= 0.0000000001) {
|
return phi;
|
}
|
}
|
|
//console.log("IQSFN-CONV:Latitude failed to converge after 30 iterations");
|
return NaN;
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/cea.js
|
|
|
|
|
|
/*
|
reference:
|
"Cartographic Projection Procedures for the UNIX Environment-
|
A User's Manual" by Gerald I. Evenden,
|
USGS Open File Report 90-284and Release 4 Interim Reports (2003)
|
*/
|
function cea_init() {
|
//no-op
|
if (!this.sphere) {
|
this.k0 = msfnz(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts));
|
}
|
}
|
|
/* Cylindrical Equal Area forward equations--mapping lat,long to x,y
|
------------------------------------------------------------*/
|
function cea_forward(p) {
|
var lon = p.x;
|
var lat = p.y;
|
var x, y;
|
/* Forward equations
|
-----------------*/
|
var dlon = adjust_lon(lon - this.long0);
|
if (this.sphere) {
|
x = this.x0 + this.a * dlon * Math.cos(this.lat_ts);
|
y = this.y0 + this.a * Math.sin(lat) / Math.cos(this.lat_ts);
|
}
|
else {
|
var qs = qsfnz(this.e, Math.sin(lat));
|
x = this.x0 + this.a * this.k0 * dlon;
|
y = this.y0 + this.a * qs * 0.5 / this.k0;
|
}
|
|
p.x = x;
|
p.y = y;
|
return p;
|
}
|
|
/* Cylindrical Equal Area inverse equations--mapping x,y to lat/long
|
------------------------------------------------------------*/
|
function cea_inverse(p) {
|
p.x -= this.x0;
|
p.y -= this.y0;
|
var lon, lat;
|
|
if (this.sphere) {
|
lon = adjust_lon(this.long0 + (p.x / this.a) / Math.cos(this.lat_ts));
|
lat = Math.asin((p.y / this.a) * Math.cos(this.lat_ts));
|
}
|
else {
|
lat = iqsfnz(this.e, 2 * p.y * this.k0 / this.a);
|
lon = adjust_lon(this.long0 + p.x / (this.a * this.k0));
|
}
|
|
p.x = lon;
|
p.y = lat;
|
return p;
|
}
|
|
var cea_names = ["cea"];
|
/* harmony default export */ var cea = ({
|
init: cea_init,
|
forward: cea_forward,
|
inverse: cea_inverse,
|
names: cea_names
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/eqc.js
|
|
|
|
function eqc_init() {
|
|
this.x0 = this.x0 || 0;
|
this.y0 = this.y0 || 0;
|
this.lat0 = this.lat0 || 0;
|
this.long0 = this.long0 || 0;
|
this.lat_ts = this.lat_ts || 0;
|
this.title = this.title || "Equidistant Cylindrical (Plate Carre)";
|
|
this.rc = Math.cos(this.lat_ts);
|
}
|
|
// forward equations--mapping lat,long to x,y
|
// -----------------------------------------------------------------
|
function eqc_forward(p) {
|
|
var lon = p.x;
|
var lat = p.y;
|
|
var dlon = adjust_lon(lon - this.long0);
|
var dlat = adjust_lat(lat - this.lat0);
|
p.x = this.x0 + (this.a * dlon * this.rc);
|
p.y = this.y0 + (this.a * dlat);
|
return p;
|
}
|
|
// inverse equations--mapping x,y to lat/long
|
// -----------------------------------------------------------------
|
function eqc_inverse(p) {
|
|
var x = p.x;
|
var y = p.y;
|
|
p.x = adjust_lon(this.long0 + ((x - this.x0) / (this.a * this.rc)));
|
p.y = adjust_lat(this.lat0 + ((y - this.y0) / (this.a)));
|
return p;
|
}
|
|
var eqc_names = ["Equirectangular", "Equidistant_Cylindrical", "eqc"];
|
/* harmony default export */ var eqc = ({
|
init: eqc_init,
|
forward: eqc_forward,
|
inverse: eqc_inverse,
|
names: eqc_names
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/poly.js
|
|
|
|
|
|
|
|
|
|
|
var poly_MAX_ITER = 20;
|
|
function poly_init() {
|
/* Place parameters in static storage for common use
|
-------------------------------------------------*/
|
this.temp = this.b / this.a;
|
this.es = 1 - Math.pow(this.temp, 2); // devait etre dans tmerc.js mais n y est pas donc je commente sinon retour de valeurs nulles
|
this.e = Math.sqrt(this.es);
|
this.e0 = e0fn(this.es);
|
this.e1 = e1fn(this.es);
|
this.e2 = e2fn(this.es);
|
this.e3 = e3fn(this.es);
|
this.ml0 = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, this.lat0); //si que des zeros le calcul ne se fait pas
|
}
|
|
/* Polyconic forward equations--mapping lat,long to x,y
|
---------------------------------------------------*/
|
function poly_forward(p) {
|
var lon = p.x;
|
var lat = p.y;
|
var x, y, el;
|
var dlon = adjust_lon(lon - this.long0);
|
el = dlon * Math.sin(lat);
|
if (this.sphere) {
|
if (Math.abs(lat) <= EPSLN) {
|
x = this.a * dlon;
|
y = -1 * this.a * this.lat0;
|
}
|
else {
|
x = this.a * Math.sin(el) / Math.tan(lat);
|
y = this.a * (adjust_lat(lat - this.lat0) + (1 - Math.cos(el)) / Math.tan(lat));
|
}
|
}
|
else {
|
if (Math.abs(lat) <= EPSLN) {
|
x = this.a * dlon;
|
y = -1 * this.ml0;
|
}
|
else {
|
var nl = gN(this.a, this.e, Math.sin(lat)) / Math.tan(lat);
|
x = nl * Math.sin(el);
|
y = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, lat) - this.ml0 + nl * (1 - Math.cos(el));
|
}
|
|
}
|
p.x = x + this.x0;
|
p.y = y + this.y0;
|
return p;
|
}
|
|
/* Inverse equations
|
-----------------*/
|
function poly_inverse(p) {
|
var lon, lat, x, y, i;
|
var al, bl;
|
var phi, dphi;
|
x = p.x - this.x0;
|
y = p.y - this.y0;
|
|
if (this.sphere) {
|
if (Math.abs(y + this.a * this.lat0) <= EPSLN) {
|
lon = adjust_lon(x / this.a + this.long0);
|
lat = 0;
|
}
|
else {
|
al = this.lat0 + y / this.a;
|
bl = x * x / this.a / this.a + al * al;
|
phi = al;
|
var tanphi;
|
for (i = poly_MAX_ITER; i; --i) {
|
tanphi = Math.tan(phi);
|
dphi = -1 * (al * (phi * tanphi + 1) - phi - 0.5 * (phi * phi + bl) * tanphi) / ((phi - al) / tanphi - 1);
|
phi += dphi;
|
if (Math.abs(dphi) <= EPSLN) {
|
lat = phi;
|
break;
|
}
|
}
|
lon = adjust_lon(this.long0 + (Math.asin(x * Math.tan(phi) / this.a)) / Math.sin(lat));
|
}
|
}
|
else {
|
if (Math.abs(y + this.ml0) <= EPSLN) {
|
lat = 0;
|
lon = adjust_lon(this.long0 + x / this.a);
|
}
|
else {
|
|
al = (this.ml0 + y) / this.a;
|
bl = x * x / this.a / this.a + al * al;
|
phi = al;
|
var cl, mln, mlnp, ma;
|
var con;
|
for (i = poly_MAX_ITER; i; --i) {
|
con = this.e * Math.sin(phi);
|
cl = Math.sqrt(1 - con * con) * Math.tan(phi);
|
mln = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, phi);
|
mlnp = this.e0 - 2 * this.e1 * Math.cos(2 * phi) + 4 * this.e2 * Math.cos(4 * phi) - 6 * this.e3 * Math.cos(6 * phi);
|
ma = mln / this.a;
|
dphi = (al * (cl * ma + 1) - ma - 0.5 * cl * (ma * ma + bl)) / (this.es * Math.sin(2 * phi) * (ma * ma + bl - 2 * al * ma) / (4 * cl) + (al - ma) * (cl * mlnp - 2 / Math.sin(2 * phi)) - mlnp);
|
phi -= dphi;
|
if (Math.abs(dphi) <= EPSLN) {
|
lat = phi;
|
break;
|
}
|
}
|
|
//lat=phi4z(this.e,this.e0,this.e1,this.e2,this.e3,al,bl,0,0);
|
cl = Math.sqrt(1 - this.es * Math.pow(Math.sin(lat), 2)) * Math.tan(lat);
|
lon = adjust_lon(this.long0 + Math.asin(x * cl / this.a) / Math.sin(lat));
|
}
|
}
|
|
p.x = lon;
|
p.y = lat;
|
return p;
|
}
|
|
var poly_names = ["Polyconic", "poly"];
|
/* harmony default export */ var poly = ({
|
init: poly_init,
|
forward: poly_forward,
|
inverse: poly_inverse,
|
names: poly_names
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/nzmg.js
|
|
|
/*
|
reference
|
Department of Land and Survey Technical Circular 1973/32
|
http://www.linz.govt.nz/docs/miscellaneous/nz-map-definition.pdf
|
OSG Technical Report 4.1
|
http://www.linz.govt.nz/docs/miscellaneous/nzmg.pdf
|
*/
|
|
/**
|
* iterations: Number of iterations to refine inverse transform.
|
* 0 -> km accuracy
|
* 1 -> m accuracy -- suitable for most mapping applications
|
* 2 -> mm accuracy
|
*/
|
var iterations = 1;
|
|
function nzmg_init() {
|
this.A = [];
|
this.A[1] = 0.6399175073;
|
this.A[2] = -0.1358797613;
|
this.A[3] = 0.063294409;
|
this.A[4] = -0.02526853;
|
this.A[5] = 0.0117879;
|
this.A[6] = -0.0055161;
|
this.A[7] = 0.0026906;
|
this.A[8] = -0.001333;
|
this.A[9] = 0.00067;
|
this.A[10] = -0.00034;
|
|
this.B_re = [];
|
this.B_im = [];
|
this.B_re[1] = 0.7557853228;
|
this.B_im[1] = 0;
|
this.B_re[2] = 0.249204646;
|
this.B_im[2] = 0.003371507;
|
this.B_re[3] = -0.001541739;
|
this.B_im[3] = 0.041058560;
|
this.B_re[4] = -0.10162907;
|
this.B_im[4] = 0.01727609;
|
this.B_re[5] = -0.26623489;
|
this.B_im[5] = -0.36249218;
|
this.B_re[6] = -0.6870983;
|
this.B_im[6] = -1.1651967;
|
|
this.C_re = [];
|
this.C_im = [];
|
this.C_re[1] = 1.3231270439;
|
this.C_im[1] = 0;
|
this.C_re[2] = -0.577245789;
|
this.C_im[2] = -0.007809598;
|
this.C_re[3] = 0.508307513;
|
this.C_im[3] = -0.112208952;
|
this.C_re[4] = -0.15094762;
|
this.C_im[4] = 0.18200602;
|
this.C_re[5] = 1.01418179;
|
this.C_im[5] = 1.64497696;
|
this.C_re[6] = 1.9660549;
|
this.C_im[6] = 2.5127645;
|
|
this.D = [];
|
this.D[1] = 1.5627014243;
|
this.D[2] = 0.5185406398;
|
this.D[3] = -0.03333098;
|
this.D[4] = -0.1052906;
|
this.D[5] = -0.0368594;
|
this.D[6] = 0.007317;
|
this.D[7] = 0.01220;
|
this.D[8] = 0.00394;
|
this.D[9] = -0.0013;
|
}
|
|
/**
|
New Zealand Map Grid Forward - long/lat to x/y
|
long/lat in radians
|
*/
|
function nzmg_forward(p) {
|
var n;
|
var lon = p.x;
|
var lat = p.y;
|
|
var delta_lat = lat - this.lat0;
|
var delta_lon = lon - this.long0;
|
|
// 1. Calculate d_phi and d_psi ... // and d_lambda
|
// For this algorithm, delta_latitude is in seconds of arc x 10-5, so we need to scale to those units. Longitude is radians.
|
var d_phi = delta_lat / SEC_TO_RAD * 1E-5;
|
var d_lambda = delta_lon;
|
var d_phi_n = 1; // d_phi^0
|
|
var d_psi = 0;
|
for (n = 1; n <= 10; n++) {
|
d_phi_n = d_phi_n * d_phi;
|
d_psi = d_psi + this.A[n] * d_phi_n;
|
}
|
|
// 2. Calculate theta
|
var th_re = d_psi;
|
var th_im = d_lambda;
|
|
// 3. Calculate z
|
var th_n_re = 1;
|
var th_n_im = 0; // theta^0
|
var th_n_re1;
|
var th_n_im1;
|
|
var z_re = 0;
|
var z_im = 0;
|
for (n = 1; n <= 6; n++) {
|
th_n_re1 = th_n_re * th_re - th_n_im * th_im;
|
th_n_im1 = th_n_im * th_re + th_n_re * th_im;
|
th_n_re = th_n_re1;
|
th_n_im = th_n_im1;
|
z_re = z_re + this.B_re[n] * th_n_re - this.B_im[n] * th_n_im;
|
z_im = z_im + this.B_im[n] * th_n_re + this.B_re[n] * th_n_im;
|
}
|
|
// 4. Calculate easting and northing
|
p.x = (z_im * this.a) + this.x0;
|
p.y = (z_re * this.a) + this.y0;
|
|
return p;
|
}
|
|
/**
|
New Zealand Map Grid Inverse - x/y to long/lat
|
*/
|
function nzmg_inverse(p) {
|
var n;
|
var x = p.x;
|
var y = p.y;
|
|
var delta_x = x - this.x0;
|
var delta_y = y - this.y0;
|
|
// 1. Calculate z
|
var z_re = delta_y / this.a;
|
var z_im = delta_x / this.a;
|
|
// 2a. Calculate theta - first approximation gives km accuracy
|
var z_n_re = 1;
|
var z_n_im = 0; // z^0
|
var z_n_re1;
|
var z_n_im1;
|
|
var th_re = 0;
|
var th_im = 0;
|
for (n = 1; n <= 6; n++) {
|
z_n_re1 = z_n_re * z_re - z_n_im * z_im;
|
z_n_im1 = z_n_im * z_re + z_n_re * z_im;
|
z_n_re = z_n_re1;
|
z_n_im = z_n_im1;
|
th_re = th_re + this.C_re[n] * z_n_re - this.C_im[n] * z_n_im;
|
th_im = th_im + this.C_im[n] * z_n_re + this.C_re[n] * z_n_im;
|
}
|
|
// 2b. Iterate to refine the accuracy of the calculation
|
// 0 iterations gives km accuracy
|
// 1 iteration gives m accuracy -- good enough for most mapping applications
|
// 2 iterations bives mm accuracy
|
for (var i = 0; i < this.iterations; i++) {
|
var th_n_re = th_re;
|
var th_n_im = th_im;
|
var th_n_re1;
|
var th_n_im1;
|
|
var num_re = z_re;
|
var num_im = z_im;
|
for (n = 2; n <= 6; n++) {
|
th_n_re1 = th_n_re * th_re - th_n_im * th_im;
|
th_n_im1 = th_n_im * th_re + th_n_re * th_im;
|
th_n_re = th_n_re1;
|
th_n_im = th_n_im1;
|
num_re = num_re + (n - 1) * (this.B_re[n] * th_n_re - this.B_im[n] * th_n_im);
|
num_im = num_im + (n - 1) * (this.B_im[n] * th_n_re + this.B_re[n] * th_n_im);
|
}
|
|
th_n_re = 1;
|
th_n_im = 0;
|
var den_re = this.B_re[1];
|
var den_im = this.B_im[1];
|
for (n = 2; n <= 6; n++) {
|
th_n_re1 = th_n_re * th_re - th_n_im * th_im;
|
th_n_im1 = th_n_im * th_re + th_n_re * th_im;
|
th_n_re = th_n_re1;
|
th_n_im = th_n_im1;
|
den_re = den_re + n * (this.B_re[n] * th_n_re - this.B_im[n] * th_n_im);
|
den_im = den_im + n * (this.B_im[n] * th_n_re + this.B_re[n] * th_n_im);
|
}
|
|
// Complex division
|
var den2 = den_re * den_re + den_im * den_im;
|
th_re = (num_re * den_re + num_im * den_im) / den2;
|
th_im = (num_im * den_re - num_re * den_im) / den2;
|
}
|
|
// 3. Calculate d_phi ... // and d_lambda
|
var d_psi = th_re;
|
var d_lambda = th_im;
|
var d_psi_n = 1; // d_psi^0
|
|
var d_phi = 0;
|
for (n = 1; n <= 9; n++) {
|
d_psi_n = d_psi_n * d_psi;
|
d_phi = d_phi + this.D[n] * d_psi_n;
|
}
|
|
// 4. Calculate latitude and longitude
|
// d_phi is calcuated in second of arc * 10^-5, so we need to scale back to radians. d_lambda is in radians.
|
var lat = this.lat0 + (d_phi * SEC_TO_RAD * 1E5);
|
var lon = this.long0 + d_lambda;
|
|
p.x = lon;
|
p.y = lat;
|
|
return p;
|
}
|
|
var nzmg_names = ["New_Zealand_Map_Grid", "nzmg"];
|
/* harmony default export */ var nzmg = ({
|
init: nzmg_init,
|
forward: nzmg_forward,
|
inverse: nzmg_inverse,
|
names: nzmg_names
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/mill.js
|
|
|
/*
|
reference
|
"New Equal-Area Map Projections for Noncircular Regions", John P. Snyder,
|
The American Cartographer, Vol 15, No. 4, October 1988, pp. 341-355.
|
*/
|
|
|
/* Initialize the Miller Cylindrical projection
|
-------------------------------------------*/
|
function mill_init() {
|
//no-op
|
}
|
|
/* Miller Cylindrical forward equations--mapping lat,long to x,y
|
------------------------------------------------------------*/
|
function mill_forward(p) {
|
var lon = p.x;
|
var lat = p.y;
|
/* Forward equations
|
-----------------*/
|
var dlon = adjust_lon(lon - this.long0);
|
var x = this.x0 + this.a * dlon;
|
var y = this.y0 + this.a * Math.log(Math.tan((Math.PI / 4) + (lat / 2.5))) * 1.25;
|
|
p.x = x;
|
p.y = y;
|
return p;
|
}
|
|
/* Miller Cylindrical inverse equations--mapping x,y to lat/long
|
------------------------------------------------------------*/
|
function mill_inverse(p) {
|
p.x -= this.x0;
|
p.y -= this.y0;
|
|
var lon = adjust_lon(this.long0 + p.x / this.a);
|
var lat = 2.5 * (Math.atan(Math.exp(0.8 * p.y / this.a)) - Math.PI / 4);
|
|
p.x = lon;
|
p.y = lat;
|
return p;
|
}
|
|
var mill_names = ["Miller_Cylindrical", "mill"];
|
/* harmony default export */ var mill = ({
|
init: mill_init,
|
forward: mill_forward,
|
inverse: mill_inverse,
|
names: mill_names
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/sinu.js
|
|
|
|
var sinu_MAX_ITER = 20;
|
|
|
|
|
|
|
|
function sinu_init() {
|
/* Place parameters in static storage for common use
|
-------------------------------------------------*/
|
|
|
if (!this.sphere) {
|
this.en = pj_enfn(this.es);
|
}
|
else {
|
this.n = 1;
|
this.m = 0;
|
this.es = 0;
|
this.C_y = Math.sqrt((this.m + 1) / this.n);
|
this.C_x = this.C_y / (this.m + 1);
|
}
|
|
}
|
|
/* Sinusoidal forward equations--mapping lat,long to x,y
|
-----------------------------------------------------*/
|
function sinu_forward(p) {
|
var x, y;
|
var lon = p.x;
|
var lat = p.y;
|
/* Forward equations
|
-----------------*/
|
lon = adjust_lon(lon - this.long0);
|
|
if (this.sphere) {
|
if (!this.m) {
|
lat = this.n !== 1 ? Math.asin(this.n * Math.sin(lat)) : lat;
|
}
|
else {
|
var k = this.n * Math.sin(lat);
|
for (var i = sinu_MAX_ITER; i; --i) {
|
var V = (this.m * lat + Math.sin(lat) - k) / (this.m + Math.cos(lat));
|
lat -= V;
|
if (Math.abs(V) < EPSLN) {
|
break;
|
}
|
}
|
}
|
x = this.a * this.C_x * lon * (this.m + Math.cos(lat));
|
y = this.a * this.C_y * lat;
|
|
}
|
else {
|
|
var s = Math.sin(lat);
|
var c = Math.cos(lat);
|
y = this.a * pj_mlfn(lat, s, c, this.en);
|
x = this.a * lon * c / Math.sqrt(1 - this.es * s * s);
|
}
|
|
p.x = x;
|
p.y = y;
|
return p;
|
}
|
|
function sinu_inverse(p) {
|
var lat, temp, lon, s;
|
|
p.x -= this.x0;
|
lon = p.x / this.a;
|
p.y -= this.y0;
|
lat = p.y / this.a;
|
|
if (this.sphere) {
|
lat /= this.C_y;
|
lon = lon / (this.C_x * (this.m + Math.cos(lat)));
|
if (this.m) {
|
lat = asinz((this.m * lat + Math.sin(lat)) / this.n);
|
}
|
else if (this.n !== 1) {
|
lat = asinz(Math.sin(lat) / this.n);
|
}
|
lon = adjust_lon(lon + this.long0);
|
lat = adjust_lat(lat);
|
}
|
else {
|
lat = pj_inv_mlfn(p.y / this.a, this.es, this.en);
|
s = Math.abs(lat);
|
if (s < HALF_PI) {
|
s = Math.sin(lat);
|
temp = this.long0 + p.x * Math.sqrt(1 - this.es * s * s) / (this.a * Math.cos(lat));
|
//temp = this.long0 + p.x / (this.a * Math.cos(lat));
|
lon = adjust_lon(temp);
|
}
|
else if ((s - EPSLN) < HALF_PI) {
|
lon = this.long0;
|
}
|
}
|
p.x = lon;
|
p.y = lat;
|
return p;
|
}
|
|
var sinu_names = ["Sinusoidal", "sinu"];
|
/* harmony default export */ var sinu = ({
|
init: sinu_init,
|
forward: sinu_forward,
|
inverse: sinu_inverse,
|
names: sinu_names
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/moll.js
|
|
function moll_init() {}
|
|
/* Mollweide forward equations--mapping lat,long to x,y
|
----------------------------------------------------*/
|
function moll_forward(p) {
|
|
/* Forward equations
|
-----------------*/
|
var lon = p.x;
|
var lat = p.y;
|
|
var delta_lon = adjust_lon(lon - this.long0);
|
var theta = lat;
|
var con = Math.PI * Math.sin(lat);
|
|
/* Iterate using the Newton-Raphson method to find theta
|
-----------------------------------------------------*/
|
while (true) {
|
var delta_theta = -(theta + Math.sin(theta) - con) / (1 + Math.cos(theta));
|
theta += delta_theta;
|
if (Math.abs(delta_theta) < EPSLN) {
|
break;
|
}
|
}
|
theta /= 2;
|
|
/* If the latitude is 90 deg, force the x coordinate to be "0 + false easting"
|
this is done here because of precision problems with "cos(theta)"
|
--------------------------------------------------------------------------*/
|
if (Math.PI / 2 - Math.abs(lat) < EPSLN) {
|
delta_lon = 0;
|
}
|
var x = 0.900316316158 * this.a * delta_lon * Math.cos(theta) + this.x0;
|
var y = 1.4142135623731 * this.a * Math.sin(theta) + this.y0;
|
|
p.x = x;
|
p.y = y;
|
return p;
|
}
|
|
function moll_inverse(p) {
|
var theta;
|
var arg;
|
|
/* Inverse equations
|
-----------------*/
|
p.x -= this.x0;
|
p.y -= this.y0;
|
arg = p.y / (1.4142135623731 * this.a);
|
|
/* Because of division by zero problems, 'arg' can not be 1. Therefore
|
a number very close to one is used instead.
|
-------------------------------------------------------------------*/
|
if (Math.abs(arg) > 0.999999999999) {
|
arg = 0.999999999999;
|
}
|
theta = Math.asin(arg);
|
var lon = adjust_lon(this.long0 + (p.x / (0.900316316158 * this.a * Math.cos(theta))));
|
if (lon < (-Math.PI)) {
|
lon = -Math.PI;
|
}
|
if (lon > Math.PI) {
|
lon = Math.PI;
|
}
|
arg = (2 * theta + Math.sin(2 * theta)) / Math.PI;
|
if (Math.abs(arg) > 1) {
|
arg = 1;
|
}
|
var lat = Math.asin(arg);
|
|
p.x = lon;
|
p.y = lat;
|
return p;
|
}
|
|
var moll_names = ["Mollweide", "moll"];
|
/* harmony default export */ var moll = ({
|
init: moll_init,
|
forward: moll_forward,
|
inverse: moll_inverse,
|
names: moll_names
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/eqdc.js
|
|
|
|
|
|
|
|
|
|
|
|
function eqdc_init() {
|
|
/* Place parameters in static storage for common use
|
-------------------------------------------------*/
|
// Standard Parallels cannot be equal and on opposite sides of the equator
|
if (Math.abs(this.lat1 + this.lat2) < EPSLN) {
|
return;
|
}
|
this.lat2 = this.lat2 || this.lat1;
|
this.temp = this.b / this.a;
|
this.es = 1 - Math.pow(this.temp, 2);
|
this.e = Math.sqrt(this.es);
|
this.e0 = e0fn(this.es);
|
this.e1 = e1fn(this.es);
|
this.e2 = e2fn(this.es);
|
this.e3 = e3fn(this.es);
|
|
this.sinphi = Math.sin(this.lat1);
|
this.cosphi = Math.cos(this.lat1);
|
|
this.ms1 = msfnz(this.e, this.sinphi, this.cosphi);
|
this.ml1 = mlfn(this.e0, this.e1, this.e2, this.e3, this.lat1);
|
|
if (Math.abs(this.lat1 - this.lat2) < EPSLN) {
|
this.ns = this.sinphi;
|
}
|
else {
|
this.sinphi = Math.sin(this.lat2);
|
this.cosphi = Math.cos(this.lat2);
|
this.ms2 = msfnz(this.e, this.sinphi, this.cosphi);
|
this.ml2 = mlfn(this.e0, this.e1, this.e2, this.e3, this.lat2);
|
this.ns = (this.ms1 - this.ms2) / (this.ml2 - this.ml1);
|
}
|
this.g = this.ml1 + this.ms1 / this.ns;
|
this.ml0 = mlfn(this.e0, this.e1, this.e2, this.e3, this.lat0);
|
this.rh = this.a * (this.g - this.ml0);
|
}
|
|
/* Equidistant Conic forward equations--mapping lat,long to x,y
|
-----------------------------------------------------------*/
|
function eqdc_forward(p) {
|
var lon = p.x;
|
var lat = p.y;
|
var rh1;
|
|
/* Forward equations
|
-----------------*/
|
if (this.sphere) {
|
rh1 = this.a * (this.g - lat);
|
}
|
else {
|
var ml = mlfn(this.e0, this.e1, this.e2, this.e3, lat);
|
rh1 = this.a * (this.g - ml);
|
}
|
var theta = this.ns * adjust_lon(lon - this.long0);
|
var x = this.x0 + rh1 * Math.sin(theta);
|
var y = this.y0 + this.rh - rh1 * Math.cos(theta);
|
p.x = x;
|
p.y = y;
|
return p;
|
}
|
|
/* Inverse equations
|
-----------------*/
|
function eqdc_inverse(p) {
|
p.x -= this.x0;
|
p.y = this.rh - p.y + this.y0;
|
var con, rh1, lat, lon;
|
if (this.ns >= 0) {
|
rh1 = Math.sqrt(p.x * p.x + p.y * p.y);
|
con = 1;
|
}
|
else {
|
rh1 = -Math.sqrt(p.x * p.x + p.y * p.y);
|
con = -1;
|
}
|
var theta = 0;
|
if (rh1 !== 0) {
|
theta = Math.atan2(con * p.x, con * p.y);
|
}
|
|
if (this.sphere) {
|
lon = adjust_lon(this.long0 + theta / this.ns);
|
lat = adjust_lat(this.g - rh1 / this.a);
|
p.x = lon;
|
p.y = lat;
|
return p;
|
}
|
else {
|
var ml = this.g - rh1 / this.a;
|
lat = imlfn(ml, this.e0, this.e1, this.e2, this.e3);
|
lon = adjust_lon(this.long0 + theta / this.ns);
|
p.x = lon;
|
p.y = lat;
|
return p;
|
}
|
|
}
|
|
var eqdc_names = ["Equidistant_Conic", "eqdc"];
|
/* harmony default export */ var eqdc = ({
|
init: eqdc_init,
|
forward: eqdc_forward,
|
inverse: eqdc_inverse,
|
names: eqdc_names
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/vandg.js
|
|
|
|
|
|
|
/* Initialize the Van Der Grinten projection
|
----------------------------------------*/
|
function vandg_init() {
|
//this.R = 6370997; //Radius of earth
|
this.R = this.a;
|
}
|
|
function vandg_forward(p) {
|
|
var lon = p.x;
|
var lat = p.y;
|
|
/* Forward equations
|
-----------------*/
|
var dlon = adjust_lon(lon - this.long0);
|
var x, y;
|
|
if (Math.abs(lat) <= EPSLN) {
|
x = this.x0 + this.R * dlon;
|
y = this.y0;
|
}
|
var theta = asinz(2 * Math.abs(lat / Math.PI));
|
if ((Math.abs(dlon) <= EPSLN) || (Math.abs(Math.abs(lat) - HALF_PI) <= EPSLN)) {
|
x = this.x0;
|
if (lat >= 0) {
|
y = this.y0 + Math.PI * this.R * Math.tan(0.5 * theta);
|
}
|
else {
|
y = this.y0 + Math.PI * this.R * -Math.tan(0.5 * theta);
|
}
|
// return(OK);
|
}
|
var al = 0.5 * Math.abs((Math.PI / dlon) - (dlon / Math.PI));
|
var asq = al * al;
|
var sinth = Math.sin(theta);
|
var costh = Math.cos(theta);
|
|
var g = costh / (sinth + costh - 1);
|
var gsq = g * g;
|
var m = g * (2 / sinth - 1);
|
var msq = m * m;
|
var con = Math.PI * this.R * (al * (g - msq) + Math.sqrt(asq * (g - msq) * (g - msq) - (msq + asq) * (gsq - msq))) / (msq + asq);
|
if (dlon < 0) {
|
con = -con;
|
}
|
x = this.x0 + con;
|
//con = Math.abs(con / (Math.PI * this.R));
|
var q = asq + g;
|
con = Math.PI * this.R * (m * q - al * Math.sqrt((msq + asq) * (asq + 1) - q * q)) / (msq + asq);
|
if (lat >= 0) {
|
//y = this.y0 + Math.PI * this.R * Math.sqrt(1 - con * con - 2 * al * con);
|
y = this.y0 + con;
|
}
|
else {
|
//y = this.y0 - Math.PI * this.R * Math.sqrt(1 - con * con - 2 * al * con);
|
y = this.y0 - con;
|
}
|
p.x = x;
|
p.y = y;
|
return p;
|
}
|
|
/* Van Der Grinten inverse equations--mapping x,y to lat/long
|
---------------------------------------------------------*/
|
function vandg_inverse(p) {
|
var lon, lat;
|
var xx, yy, xys, c1, c2, c3;
|
var a1;
|
var m1;
|
var con;
|
var th1;
|
var d;
|
|
/* inverse equations
|
-----------------*/
|
p.x -= this.x0;
|
p.y -= this.y0;
|
con = Math.PI * this.R;
|
xx = p.x / con;
|
yy = p.y / con;
|
xys = xx * xx + yy * yy;
|
c1 = -Math.abs(yy) * (1 + xys);
|
c2 = c1 - 2 * yy * yy + xx * xx;
|
c3 = -2 * c1 + 1 + 2 * yy * yy + xys * xys;
|
d = yy * yy / c3 + (2 * c2 * c2 * c2 / c3 / c3 / c3 - 9 * c1 * c2 / c3 / c3) / 27;
|
a1 = (c1 - c2 * c2 / 3 / c3) / c3;
|
m1 = 2 * Math.sqrt(-a1 / 3);
|
con = ((3 * d) / a1) / m1;
|
if (Math.abs(con) > 1) {
|
if (con >= 0) {
|
con = 1;
|
}
|
else {
|
con = -1;
|
}
|
}
|
th1 = Math.acos(con) / 3;
|
if (p.y >= 0) {
|
lat = (-m1 * Math.cos(th1 + Math.PI / 3) - c2 / 3 / c3) * Math.PI;
|
}
|
else {
|
lat = -(-m1 * Math.cos(th1 + Math.PI / 3) - c2 / 3 / c3) * Math.PI;
|
}
|
|
if (Math.abs(xx) < EPSLN) {
|
lon = this.long0;
|
}
|
else {
|
lon = adjust_lon(this.long0 + Math.PI * (xys - 1 + Math.sqrt(1 + 2 * (xx * xx - yy * yy) + xys * xys)) / 2 / xx);
|
}
|
|
p.x = lon;
|
p.y = lat;
|
return p;
|
}
|
|
var vandg_names = ["Van_der_Grinten_I", "VanDerGrinten", "vandg"];
|
/* harmony default export */ var vandg = ({
|
init: vandg_init,
|
forward: vandg_forward,
|
inverse: vandg_inverse,
|
names: vandg_names
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/aeqd.js
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function aeqd_init() {
|
this.sin_p12 = Math.sin(this.lat0);
|
this.cos_p12 = Math.cos(this.lat0);
|
}
|
|
function aeqd_forward(p) {
|
var lon = p.x;
|
var lat = p.y;
|
var sinphi = Math.sin(p.y);
|
var cosphi = Math.cos(p.y);
|
var dlon = adjust_lon(lon - this.long0);
|
var e0, e1, e2, e3, Mlp, Ml, tanphi, Nl1, Nl, psi, Az, G, H, GH, Hs, c, kp, cos_c, s, s2, s3, s4, s5;
|
if (this.sphere) {
|
if (Math.abs(this.sin_p12 - 1) <= EPSLN) {
|
//North Pole case
|
p.x = this.x0 + this.a * (HALF_PI - lat) * Math.sin(dlon);
|
p.y = this.y0 - this.a * (HALF_PI - lat) * Math.cos(dlon);
|
return p;
|
}
|
else if (Math.abs(this.sin_p12 + 1) <= EPSLN) {
|
//South Pole case
|
p.x = this.x0 + this.a * (HALF_PI + lat) * Math.sin(dlon);
|
p.y = this.y0 + this.a * (HALF_PI + lat) * Math.cos(dlon);
|
return p;
|
}
|
else {
|
//default case
|
cos_c = this.sin_p12 * sinphi + this.cos_p12 * cosphi * Math.cos(dlon);
|
c = Math.acos(cos_c);
|
kp = c ? c / Math.sin(c) : 1;
|
p.x = this.x0 + this.a * kp * cosphi * Math.sin(dlon);
|
p.y = this.y0 + this.a * kp * (this.cos_p12 * sinphi - this.sin_p12 * cosphi * Math.cos(dlon));
|
return p;
|
}
|
}
|
else {
|
e0 = e0fn(this.es);
|
e1 = e1fn(this.es);
|
e2 = e2fn(this.es);
|
e3 = e3fn(this.es);
|
if (Math.abs(this.sin_p12 - 1) <= EPSLN) {
|
//North Pole case
|
Mlp = this.a * mlfn(e0, e1, e2, e3, HALF_PI);
|
Ml = this.a * mlfn(e0, e1, e2, e3, lat);
|
p.x = this.x0 + (Mlp - Ml) * Math.sin(dlon);
|
p.y = this.y0 - (Mlp - Ml) * Math.cos(dlon);
|
return p;
|
}
|
else if (Math.abs(this.sin_p12 + 1) <= EPSLN) {
|
//South Pole case
|
Mlp = this.a * mlfn(e0, e1, e2, e3, HALF_PI);
|
Ml = this.a * mlfn(e0, e1, e2, e3, lat);
|
p.x = this.x0 + (Mlp + Ml) * Math.sin(dlon);
|
p.y = this.y0 + (Mlp + Ml) * Math.cos(dlon);
|
return p;
|
}
|
else {
|
//Default case
|
tanphi = sinphi / cosphi;
|
Nl1 = gN(this.a, this.e, this.sin_p12);
|
Nl = gN(this.a, this.e, sinphi);
|
psi = Math.atan((1 - this.es) * tanphi + this.es * Nl1 * this.sin_p12 / (Nl * cosphi));
|
Az = Math.atan2(Math.sin(dlon), this.cos_p12 * Math.tan(psi) - this.sin_p12 * Math.cos(dlon));
|
if (Az === 0) {
|
s = Math.asin(this.cos_p12 * Math.sin(psi) - this.sin_p12 * Math.cos(psi));
|
}
|
else if (Math.abs(Math.abs(Az) - Math.PI) <= EPSLN) {
|
s = -Math.asin(this.cos_p12 * Math.sin(psi) - this.sin_p12 * Math.cos(psi));
|
}
|
else {
|
s = Math.asin(Math.sin(dlon) * Math.cos(psi) / Math.sin(Az));
|
}
|
G = this.e * this.sin_p12 / Math.sqrt(1 - this.es);
|
H = this.e * this.cos_p12 * Math.cos(Az) / Math.sqrt(1 - this.es);
|
GH = G * H;
|
Hs = H * H;
|
s2 = s * s;
|
s3 = s2 * s;
|
s4 = s3 * s;
|
s5 = s4 * s;
|
c = Nl1 * s * (1 - s2 * Hs * (1 - Hs) / 6 + s3 / 8 * GH * (1 - 2 * Hs) + s4 / 120 * (Hs * (4 - 7 * Hs) - 3 * G * G * (1 - 7 * Hs)) - s5 / 48 * GH);
|
p.x = this.x0 + c * Math.sin(Az);
|
p.y = this.y0 + c * Math.cos(Az);
|
return p;
|
}
|
}
|
|
|
}
|
|
function aeqd_inverse(p) {
|
p.x -= this.x0;
|
p.y -= this.y0;
|
var rh, z, sinz, cosz, lon, lat, con, e0, e1, e2, e3, Mlp, M, N1, psi, Az, cosAz, tmp, A, B, D, Ee, F, sinpsi;
|
if (this.sphere) {
|
rh = Math.sqrt(p.x * p.x + p.y * p.y);
|
if (rh > (2 * HALF_PI * this.a)) {
|
return;
|
}
|
z = rh / this.a;
|
|
sinz = Math.sin(z);
|
cosz = Math.cos(z);
|
|
lon = this.long0;
|
if (Math.abs(rh) <= EPSLN) {
|
lat = this.lat0;
|
}
|
else {
|
lat = asinz(cosz * this.sin_p12 + (p.y * sinz * this.cos_p12) / rh);
|
con = Math.abs(this.lat0) - HALF_PI;
|
if (Math.abs(con) <= EPSLN) {
|
if (this.lat0 >= 0) {
|
lon = adjust_lon(this.long0 + Math.atan2(p.x, - p.y));
|
}
|
else {
|
lon = adjust_lon(this.long0 - Math.atan2(-p.x, p.y));
|
}
|
}
|
else {
|
/*con = cosz - this.sin_p12 * Math.sin(lat);
|
if ((Math.abs(con) < EPSLN) && (Math.abs(p.x) < EPSLN)) {
|
//no-op, just keep the lon value as is
|
} else {
|
var temp = Math.atan2((p.x * sinz * this.cos_p12), (con * rh));
|
lon = adjust_lon(this.long0 + Math.atan2((p.x * sinz * this.cos_p12), (con * rh)));
|
}*/
|
lon = adjust_lon(this.long0 + Math.atan2(p.x * sinz, rh * this.cos_p12 * cosz - p.y * this.sin_p12 * sinz));
|
}
|
}
|
|
p.x = lon;
|
p.y = lat;
|
return p;
|
}
|
else {
|
e0 = e0fn(this.es);
|
e1 = e1fn(this.es);
|
e2 = e2fn(this.es);
|
e3 = e3fn(this.es);
|
if (Math.abs(this.sin_p12 - 1) <= EPSLN) {
|
//North pole case
|
Mlp = this.a * mlfn(e0, e1, e2, e3, HALF_PI);
|
rh = Math.sqrt(p.x * p.x + p.y * p.y);
|
M = Mlp - rh;
|
lat = imlfn(M / this.a, e0, e1, e2, e3);
|
lon = adjust_lon(this.long0 + Math.atan2(p.x, - 1 * p.y));
|
p.x = lon;
|
p.y = lat;
|
return p;
|
}
|
else if (Math.abs(this.sin_p12 + 1) <= EPSLN) {
|
//South pole case
|
Mlp = this.a * mlfn(e0, e1, e2, e3, HALF_PI);
|
rh = Math.sqrt(p.x * p.x + p.y * p.y);
|
M = rh - Mlp;
|
|
lat = imlfn(M / this.a, e0, e1, e2, e3);
|
lon = adjust_lon(this.long0 + Math.atan2(p.x, p.y));
|
p.x = lon;
|
p.y = lat;
|
return p;
|
}
|
else {
|
//default case
|
rh = Math.sqrt(p.x * p.x + p.y * p.y);
|
Az = Math.atan2(p.x, p.y);
|
N1 = gN(this.a, this.e, this.sin_p12);
|
cosAz = Math.cos(Az);
|
tmp = this.e * this.cos_p12 * cosAz;
|
A = -tmp * tmp / (1 - this.es);
|
B = 3 * this.es * (1 - A) * this.sin_p12 * this.cos_p12 * cosAz / (1 - this.es);
|
D = rh / N1;
|
Ee = D - A * (1 + A) * Math.pow(D, 3) / 6 - B * (1 + 3 * A) * Math.pow(D, 4) / 24;
|
F = 1 - A * Ee * Ee / 2 - D * Ee * Ee * Ee / 6;
|
psi = Math.asin(this.sin_p12 * Math.cos(Ee) + this.cos_p12 * Math.sin(Ee) * cosAz);
|
lon = adjust_lon(this.long0 + Math.asin(Math.sin(Az) * Math.sin(Ee) / Math.cos(psi)));
|
sinpsi = Math.sin(psi);
|
lat = Math.atan2((sinpsi - this.es * F * this.sin_p12) * Math.tan(psi), sinpsi * (1 - this.es));
|
p.x = lon;
|
p.y = lat;
|
return p;
|
}
|
}
|
|
}
|
|
var aeqd_names = ["Azimuthal_Equidistant", "aeqd"];
|
/* harmony default export */ var aeqd = ({
|
init: aeqd_init,
|
forward: aeqd_forward,
|
inverse: aeqd_inverse,
|
names: aeqd_names
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/ortho.js
|
|
|
|
|
function ortho_init() {
|
//double temp; /* temporary variable */
|
|
/* Place parameters in static storage for common use
|
-------------------------------------------------*/
|
this.sin_p14 = Math.sin(this.lat0);
|
this.cos_p14 = Math.cos(this.lat0);
|
}
|
|
/* Orthographic forward equations--mapping lat,long to x,y
|
---------------------------------------------------*/
|
function ortho_forward(p) {
|
var sinphi, cosphi; /* sin and cos value */
|
var dlon; /* delta longitude value */
|
var coslon; /* cos of longitude */
|
var ksp; /* scale factor */
|
var g, x, y;
|
var lon = p.x;
|
var lat = p.y;
|
/* Forward equations
|
-----------------*/
|
dlon = adjust_lon(lon - this.long0);
|
|
sinphi = Math.sin(lat);
|
cosphi = Math.cos(lat);
|
|
coslon = Math.cos(dlon);
|
g = this.sin_p14 * sinphi + this.cos_p14 * cosphi * coslon;
|
ksp = 1;
|
if ((g > 0) || (Math.abs(g) <= EPSLN)) {
|
x = this.a * ksp * cosphi * Math.sin(dlon);
|
y = this.y0 + this.a * ksp * (this.cos_p14 * sinphi - this.sin_p14 * cosphi * coslon);
|
}
|
p.x = x;
|
p.y = y;
|
return p;
|
}
|
|
function ortho_inverse(p) {
|
var rh; /* height above ellipsoid */
|
var z; /* angle */
|
var sinz, cosz; /* sin of z and cos of z */
|
var con;
|
var lon, lat;
|
/* Inverse equations
|
-----------------*/
|
p.x -= this.x0;
|
p.y -= this.y0;
|
rh = Math.sqrt(p.x * p.x + p.y * p.y);
|
z = asinz(rh / this.a);
|
|
sinz = Math.sin(z);
|
cosz = Math.cos(z);
|
|
lon = this.long0;
|
if (Math.abs(rh) <= EPSLN) {
|
lat = this.lat0;
|
p.x = lon;
|
p.y = lat;
|
return p;
|
}
|
lat = asinz(cosz * this.sin_p14 + (p.y * sinz * this.cos_p14) / rh);
|
con = Math.abs(this.lat0) - HALF_PI;
|
if (Math.abs(con) <= EPSLN) {
|
if (this.lat0 >= 0) {
|
lon = adjust_lon(this.long0 + Math.atan2(p.x, - p.y));
|
}
|
else {
|
lon = adjust_lon(this.long0 - Math.atan2(-p.x, p.y));
|
}
|
p.x = lon;
|
p.y = lat;
|
return p;
|
}
|
lon = adjust_lon(this.long0 + Math.atan2((p.x * sinz), rh * this.cos_p14 * cosz - p.y * this.sin_p14 * sinz));
|
p.x = lon;
|
p.y = lat;
|
return p;
|
}
|
|
var ortho_names = ["ortho"];
|
/* harmony default export */ var ortho = ({
|
init: ortho_init,
|
forward: ortho_forward,
|
inverse: ortho_inverse,
|
names: ortho_names
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/qsc.js
|
// QSC projection rewritten from the original PROJ4
|
// https://github.com/OSGeo/proj.4/blob/master/src/PJ_qsc.c
|
|
|
|
/* constants */
|
var FACE_ENUM = {
|
FRONT: 1,
|
RIGHT: 2,
|
BACK: 3,
|
LEFT: 4,
|
TOP: 5,
|
BOTTOM: 6
|
};
|
|
var AREA_ENUM = {
|
AREA_0: 1,
|
AREA_1: 2,
|
AREA_2: 3,
|
AREA_3: 4
|
};
|
|
function qsc_init() {
|
|
this.x0 = this.x0 || 0;
|
this.y0 = this.y0 || 0;
|
this.lat0 = this.lat0 || 0;
|
this.long0 = this.long0 || 0;
|
this.lat_ts = this.lat_ts || 0;
|
this.title = this.title || "Quadrilateralized Spherical Cube";
|
|
/* Determine the cube face from the center of projection. */
|
if (this.lat0 >= HALF_PI - FORTPI / 2.0) {
|
this.face = FACE_ENUM.TOP;
|
} else if (this.lat0 <= -(HALF_PI - FORTPI / 2.0)) {
|
this.face = FACE_ENUM.BOTTOM;
|
} else if (Math.abs(this.long0) <= FORTPI) {
|
this.face = FACE_ENUM.FRONT;
|
} else if (Math.abs(this.long0) <= HALF_PI + FORTPI) {
|
this.face = this.long0 > 0.0 ? FACE_ENUM.RIGHT : FACE_ENUM.LEFT;
|
} else {
|
this.face = FACE_ENUM.BACK;
|
}
|
|
/* Fill in useful values for the ellipsoid <-> sphere shift
|
* described in [LK12]. */
|
if (this.es !== 0) {
|
this.one_minus_f = 1 - (this.a - this.b) / this.a;
|
this.one_minus_f_squared = this.one_minus_f * this.one_minus_f;
|
}
|
}
|
|
// QSC forward equations--mapping lat,long to x,y
|
// -----------------------------------------------------------------
|
function qsc_forward(p) {
|
var xy = {x: 0, y: 0};
|
var lat, lon;
|
var theta, phi;
|
var t, mu;
|
/* nu; */
|
var area = {value: 0};
|
|
// move lon according to projection's lon
|
p.x -= this.long0;
|
|
/* Convert the geodetic latitude to a geocentric latitude.
|
* This corresponds to the shift from the ellipsoid to the sphere
|
* described in [LK12]. */
|
if (this.es !== 0) {//if (P->es != 0) {
|
lat = Math.atan(this.one_minus_f_squared * Math.tan(p.y));
|
} else {
|
lat = p.y;
|
}
|
|
/* Convert the input lat, lon into theta, phi as used by QSC.
|
* This depends on the cube face and the area on it.
|
* For the top and bottom face, we can compute theta and phi
|
* directly from phi, lam. For the other faces, we must use
|
* unit sphere cartesian coordinates as an intermediate step. */
|
lon = p.x; //lon = lp.lam;
|
if (this.face === FACE_ENUM.TOP) {
|
phi = HALF_PI - lat;
|
if (lon >= FORTPI && lon <= HALF_PI + FORTPI) {
|
area.value = AREA_ENUM.AREA_0;
|
theta = lon - HALF_PI;
|
} else if (lon > HALF_PI + FORTPI || lon <= -(HALF_PI + FORTPI)) {
|
area.value = AREA_ENUM.AREA_1;
|
theta = (lon > 0.0 ? lon - SPI : lon + SPI);
|
} else if (lon > -(HALF_PI + FORTPI) && lon <= -FORTPI) {
|
area.value = AREA_ENUM.AREA_2;
|
theta = lon + HALF_PI;
|
} else {
|
area.value = AREA_ENUM.AREA_3;
|
theta = lon;
|
}
|
} else if (this.face === FACE_ENUM.BOTTOM) {
|
phi = HALF_PI + lat;
|
if (lon >= FORTPI && lon <= HALF_PI + FORTPI) {
|
area.value = AREA_ENUM.AREA_0;
|
theta = -lon + HALF_PI;
|
} else if (lon < FORTPI && lon >= -FORTPI) {
|
area.value = AREA_ENUM.AREA_1;
|
theta = -lon;
|
} else if (lon < -FORTPI && lon >= -(HALF_PI + FORTPI)) {
|
area.value = AREA_ENUM.AREA_2;
|
theta = -lon - HALF_PI;
|
} else {
|
area.value = AREA_ENUM.AREA_3;
|
theta = (lon > 0.0 ? -lon + SPI : -lon - SPI);
|
}
|
} else {
|
var q, r, s;
|
var sinlat, coslat;
|
var sinlon, coslon;
|
|
if (this.face === FACE_ENUM.RIGHT) {
|
lon = qsc_shift_lon_origin(lon, +HALF_PI);
|
} else if (this.face === FACE_ENUM.BACK) {
|
lon = qsc_shift_lon_origin(lon, +SPI);
|
} else if (this.face === FACE_ENUM.LEFT) {
|
lon = qsc_shift_lon_origin(lon, -HALF_PI);
|
}
|
sinlat = Math.sin(lat);
|
coslat = Math.cos(lat);
|
sinlon = Math.sin(lon);
|
coslon = Math.cos(lon);
|
q = coslat * coslon;
|
r = coslat * sinlon;
|
s = sinlat;
|
|
if (this.face === FACE_ENUM.FRONT) {
|
phi = Math.acos(q);
|
theta = qsc_fwd_equat_face_theta(phi, s, r, area);
|
} else if (this.face === FACE_ENUM.RIGHT) {
|
phi = Math.acos(r);
|
theta = qsc_fwd_equat_face_theta(phi, s, -q, area);
|
} else if (this.face === FACE_ENUM.BACK) {
|
phi = Math.acos(-q);
|
theta = qsc_fwd_equat_face_theta(phi, s, -r, area);
|
} else if (this.face === FACE_ENUM.LEFT) {
|
phi = Math.acos(-r);
|
theta = qsc_fwd_equat_face_theta(phi, s, q, area);
|
} else {
|
/* Impossible */
|
phi = theta = 0;
|
area.value = AREA_ENUM.AREA_0;
|
}
|
}
|
|
/* Compute mu and nu for the area of definition.
|
* For mu, see Eq. (3-21) in [OL76], but note the typos:
|
* compare with Eq. (3-14). For nu, see Eq. (3-38). */
|
mu = Math.atan((12 / SPI) * (theta + Math.acos(Math.sin(theta) * Math.cos(FORTPI)) - HALF_PI));
|
t = Math.sqrt((1 - Math.cos(phi)) / (Math.cos(mu) * Math.cos(mu)) / (1 - Math.cos(Math.atan(1 / Math.cos(theta)))));
|
|
/* Apply the result to the real area. */
|
if (area.value === AREA_ENUM.AREA_1) {
|
mu += HALF_PI;
|
} else if (area.value === AREA_ENUM.AREA_2) {
|
mu += SPI;
|
} else if (area.value === AREA_ENUM.AREA_3) {
|
mu += 1.5 * SPI;
|
}
|
|
/* Now compute x, y from mu and nu */
|
xy.x = t * Math.cos(mu);
|
xy.y = t * Math.sin(mu);
|
xy.x = xy.x * this.a + this.x0;
|
xy.y = xy.y * this.a + this.y0;
|
|
p.x = xy.x;
|
p.y = xy.y;
|
return p;
|
}
|
|
// QSC inverse equations--mapping x,y to lat/long
|
// -----------------------------------------------------------------
|
function qsc_inverse(p) {
|
var lp = {lam: 0, phi: 0};
|
var mu, nu, cosmu, tannu;
|
var tantheta, theta, cosphi, phi;
|
var t;
|
var area = {value: 0};
|
|
/* de-offset */
|
p.x = (p.x - this.x0) / this.a;
|
p.y = (p.y - this.y0) / this.a;
|
|
/* Convert the input x, y to the mu and nu angles as used by QSC.
|
* This depends on the area of the cube face. */
|
nu = Math.atan(Math.sqrt(p.x * p.x + p.y * p.y));
|
mu = Math.atan2(p.y, p.x);
|
if (p.x >= 0.0 && p.x >= Math.abs(p.y)) {
|
area.value = AREA_ENUM.AREA_0;
|
} else if (p.y >= 0.0 && p.y >= Math.abs(p.x)) {
|
area.value = AREA_ENUM.AREA_1;
|
mu -= HALF_PI;
|
} else if (p.x < 0.0 && -p.x >= Math.abs(p.y)) {
|
area.value = AREA_ENUM.AREA_2;
|
mu = (mu < 0.0 ? mu + SPI : mu - SPI);
|
} else {
|
area.value = AREA_ENUM.AREA_3;
|
mu += HALF_PI;
|
}
|
|
/* Compute phi and theta for the area of definition.
|
* The inverse projection is not described in the original paper, but some
|
* good hints can be found here (as of 2011-12-14):
|
* http://fits.gsfc.nasa.gov/fitsbits/saf.93/saf.9302
|
* (search for "Message-Id: <9302181759.AA25477 at fits.cv.nrao.edu>") */
|
t = (SPI / 12) * Math.tan(mu);
|
tantheta = Math.sin(t) / (Math.cos(t) - (1 / Math.sqrt(2)));
|
theta = Math.atan(tantheta);
|
cosmu = Math.cos(mu);
|
tannu = Math.tan(nu);
|
cosphi = 1 - cosmu * cosmu * tannu * tannu * (1 - Math.cos(Math.atan(1 / Math.cos(theta))));
|
if (cosphi < -1) {
|
cosphi = -1;
|
} else if (cosphi > +1) {
|
cosphi = +1;
|
}
|
|
/* Apply the result to the real area on the cube face.
|
* For the top and bottom face, we can compute phi and lam directly.
|
* For the other faces, we must use unit sphere cartesian coordinates
|
* as an intermediate step. */
|
if (this.face === FACE_ENUM.TOP) {
|
phi = Math.acos(cosphi);
|
lp.phi = HALF_PI - phi;
|
if (area.value === AREA_ENUM.AREA_0) {
|
lp.lam = theta + HALF_PI;
|
} else if (area.value === AREA_ENUM.AREA_1) {
|
lp.lam = (theta < 0.0 ? theta + SPI : theta - SPI);
|
} else if (area.value === AREA_ENUM.AREA_2) {
|
lp.lam = theta - HALF_PI;
|
} else /* area.value == AREA_ENUM.AREA_3 */ {
|
lp.lam = theta;
|
}
|
} else if (this.face === FACE_ENUM.BOTTOM) {
|
phi = Math.acos(cosphi);
|
lp.phi = phi - HALF_PI;
|
if (area.value === AREA_ENUM.AREA_0) {
|
lp.lam = -theta + HALF_PI;
|
} else if (area.value === AREA_ENUM.AREA_1) {
|
lp.lam = -theta;
|
} else if (area.value === AREA_ENUM.AREA_2) {
|
lp.lam = -theta - HALF_PI;
|
} else /* area.value == AREA_ENUM.AREA_3 */ {
|
lp.lam = (theta < 0.0 ? -theta - SPI : -theta + SPI);
|
}
|
} else {
|
/* Compute phi and lam via cartesian unit sphere coordinates. */
|
var q, r, s;
|
q = cosphi;
|
t = q * q;
|
if (t >= 1) {
|
s = 0;
|
} else {
|
s = Math.sqrt(1 - t) * Math.sin(theta);
|
}
|
t += s * s;
|
if (t >= 1) {
|
r = 0;
|
} else {
|
r = Math.sqrt(1 - t);
|
}
|
/* Rotate q,r,s into the correct area. */
|
if (area.value === AREA_ENUM.AREA_1) {
|
t = r;
|
r = -s;
|
s = t;
|
} else if (area.value === AREA_ENUM.AREA_2) {
|
r = -r;
|
s = -s;
|
} else if (area.value === AREA_ENUM.AREA_3) {
|
t = r;
|
r = s;
|
s = -t;
|
}
|
/* Rotate q,r,s into the correct cube face. */
|
if (this.face === FACE_ENUM.RIGHT) {
|
t = q;
|
q = -r;
|
r = t;
|
} else if (this.face === FACE_ENUM.BACK) {
|
q = -q;
|
r = -r;
|
} else if (this.face === FACE_ENUM.LEFT) {
|
t = q;
|
q = r;
|
r = -t;
|
}
|
/* Now compute phi and lam from the unit sphere coordinates. */
|
lp.phi = Math.acos(-s) - HALF_PI;
|
lp.lam = Math.atan2(r, q);
|
if (this.face === FACE_ENUM.RIGHT) {
|
lp.lam = qsc_shift_lon_origin(lp.lam, -HALF_PI);
|
} else if (this.face === FACE_ENUM.BACK) {
|
lp.lam = qsc_shift_lon_origin(lp.lam, -SPI);
|
} else if (this.face === FACE_ENUM.LEFT) {
|
lp.lam = qsc_shift_lon_origin(lp.lam, +HALF_PI);
|
}
|
}
|
|
/* Apply the shift from the sphere to the ellipsoid as described
|
* in [LK12]. */
|
if (this.es !== 0) {
|
var invert_sign;
|
var tanphi, xa;
|
invert_sign = (lp.phi < 0 ? 1 : 0);
|
tanphi = Math.tan(lp.phi);
|
xa = this.b / Math.sqrt(tanphi * tanphi + this.one_minus_f_squared);
|
lp.phi = Math.atan(Math.sqrt(this.a * this.a - xa * xa) / (this.one_minus_f * xa));
|
if (invert_sign) {
|
lp.phi = -lp.phi;
|
}
|
}
|
|
lp.lam += this.long0;
|
p.x = lp.lam;
|
p.y = lp.phi;
|
return p;
|
}
|
|
/* Helper function for forward projection: compute the theta angle
|
* and determine the area number. */
|
function qsc_fwd_equat_face_theta(phi, y, x, area) {
|
var theta;
|
if (phi < EPSLN) {
|
area.value = AREA_ENUM.AREA_0;
|
theta = 0.0;
|
} else {
|
theta = Math.atan2(y, x);
|
if (Math.abs(theta) <= FORTPI) {
|
area.value = AREA_ENUM.AREA_0;
|
} else if (theta > FORTPI && theta <= HALF_PI + FORTPI) {
|
area.value = AREA_ENUM.AREA_1;
|
theta -= HALF_PI;
|
} else if (theta > HALF_PI + FORTPI || theta <= -(HALF_PI + FORTPI)) {
|
area.value = AREA_ENUM.AREA_2;
|
theta = (theta >= 0.0 ? theta - SPI : theta + SPI);
|
} else {
|
area.value = AREA_ENUM.AREA_3;
|
theta += HALF_PI;
|
}
|
}
|
return theta;
|
}
|
|
/* Helper function: shift the longitude. */
|
function qsc_shift_lon_origin(lon, offset) {
|
var slon = lon + offset;
|
if (slon < -SPI) {
|
slon += TWO_PI;
|
} else if (slon > +SPI) {
|
slon -= TWO_PI;
|
}
|
return slon;
|
}
|
|
var qsc_names = ["Quadrilateralized Spherical Cube", "Quadrilateralized_Spherical_Cube", "qsc"];
|
/* harmony default export */ var qsc = ({
|
init: qsc_init,
|
forward: qsc_forward,
|
inverse: qsc_inverse,
|
names: qsc_names
|
});
|
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/robin.js
|
// Robinson projection
|
// Based on https://github.com/OSGeo/proj.4/blob/master/src/PJ_robin.c
|
// Polynomial coeficients from http://article.gmane.org/gmane.comp.gis.proj-4.devel/6039
|
|
|
|
|
var COEFS_X = [
|
[1.0000, 2.2199e-17, -7.15515e-05, 3.1103e-06],
|
[0.9986, -0.000482243, -2.4897e-05, -1.3309e-06],
|
[0.9954, -0.00083103, -4.48605e-05, -9.86701e-07],
|
[0.9900, -0.00135364, -5.9661e-05, 3.6777e-06],
|
[0.9822, -0.00167442, -4.49547e-06, -5.72411e-06],
|
[0.9730, -0.00214868, -9.03571e-05, 1.8736e-08],
|
[0.9600, -0.00305085, -9.00761e-05, 1.64917e-06],
|
[0.9427, -0.00382792, -6.53386e-05, -2.6154e-06],
|
[0.9216, -0.00467746, -0.00010457, 4.81243e-06],
|
[0.8962, -0.00536223, -3.23831e-05, -5.43432e-06],
|
[0.8679, -0.00609363, -0.000113898, 3.32484e-06],
|
[0.8350, -0.00698325, -6.40253e-05, 9.34959e-07],
|
[0.7986, -0.00755338, -5.00009e-05, 9.35324e-07],
|
[0.7597, -0.00798324, -3.5971e-05, -2.27626e-06],
|
[0.7186, -0.00851367, -7.01149e-05, -8.6303e-06],
|
[0.6732, -0.00986209, -0.000199569, 1.91974e-05],
|
[0.6213, -0.010418, 8.83923e-05, 6.24051e-06],
|
[0.5722, -0.00906601, 0.000182, 6.24051e-06],
|
[0.5322, -0.00677797, 0.000275608, 6.24051e-06]
|
];
|
|
var COEFS_Y = [
|
[-5.20417e-18, 0.0124, 1.21431e-18, -8.45284e-11],
|
[0.0620, 0.0124, -1.26793e-09, 4.22642e-10],
|
[0.1240, 0.0124, 5.07171e-09, -1.60604e-09],
|
[0.1860, 0.0123999, -1.90189e-08, 6.00152e-09],
|
[0.2480, 0.0124002, 7.10039e-08, -2.24e-08],
|
[0.3100, 0.0123992, -2.64997e-07, 8.35986e-08],
|
[0.3720, 0.0124029, 9.88983e-07, -3.11994e-07],
|
[0.4340, 0.0123893, -3.69093e-06, -4.35621e-07],
|
[0.4958, 0.0123198, -1.02252e-05, -3.45523e-07],
|
[0.5571, 0.0121916, -1.54081e-05, -5.82288e-07],
|
[0.6176, 0.0119938, -2.41424e-05, -5.25327e-07],
|
[0.6769, 0.011713, -3.20223e-05, -5.16405e-07],
|
[0.7346, 0.0113541, -3.97684e-05, -6.09052e-07],
|
[0.7903, 0.0109107, -4.89042e-05, -1.04739e-06],
|
[0.8435, 0.0103431, -6.4615e-05, -1.40374e-09],
|
[0.8936, 0.00969686, -6.4636e-05, -8.547e-06],
|
[0.9394, 0.00840947, -0.000192841, -4.2106e-06],
|
[0.9761, 0.00616527, -0.000256, -4.2106e-06],
|
[1.0000, 0.00328947, -0.000319159, -4.2106e-06]
|
];
|
|
var FXC = 0.8487;
|
var FYC = 1.3523;
|
var C1 = R2D/5; // rad to 5-degree interval
|
var RC1 = 1/C1;
|
var NODES = 18;
|
|
var poly3_val = function(coefs, x) {
|
return coefs[0] + x * (coefs[1] + x * (coefs[2] + x * coefs[3]));
|
};
|
|
var poly3_der = function(coefs, x) {
|
return coefs[1] + x * (2 * coefs[2] + x * 3 * coefs[3]);
|
};
|
|
function newton_rapshon(f_df, start, max_err, iters) {
|
var x = start;
|
for (; iters; --iters) {
|
var upd = f_df(x);
|
x -= upd;
|
if (Math.abs(upd) < max_err) {
|
break;
|
}
|
}
|
return x;
|
}
|
|
function robin_init() {
|
this.x0 = this.x0 || 0;
|
this.y0 = this.y0 || 0;
|
this.long0 = this.long0 || 0;
|
this.es = 0;
|
this.title = this.title || "Robinson";
|
}
|
|
function robin_forward(ll) {
|
var lon = adjust_lon(ll.x - this.long0);
|
|
var dphi = Math.abs(ll.y);
|
var i = Math.floor(dphi * C1);
|
if (i < 0) {
|
i = 0;
|
} else if (i >= NODES) {
|
i = NODES - 1;
|
}
|
dphi = R2D * (dphi - RC1 * i);
|
var xy = {
|
x: poly3_val(COEFS_X[i], dphi) * lon,
|
y: poly3_val(COEFS_Y[i], dphi)
|
};
|
if (ll.y < 0) {
|
xy.y = -xy.y;
|
}
|
|
xy.x = xy.x * this.a * FXC + this.x0;
|
xy.y = xy.y * this.a * FYC + this.y0;
|
return xy;
|
}
|
|
function robin_inverse(xy) {
|
var ll = {
|
x: (xy.x - this.x0) / (this.a * FXC),
|
y: Math.abs(xy.y - this.y0) / (this.a * FYC)
|
};
|
|
if (ll.y >= 1) { // pathologic case
|
ll.x /= COEFS_X[NODES][0];
|
ll.y = xy.y < 0 ? -HALF_PI : HALF_PI;
|
} else {
|
// find table interval
|
var i = Math.floor(ll.y * NODES);
|
if (i < 0) {
|
i = 0;
|
} else if (i >= NODES) {
|
i = NODES - 1;
|
}
|
for (;;) {
|
if (COEFS_Y[i][0] > ll.y) {
|
--i;
|
} else if (COEFS_Y[i+1][0] <= ll.y) {
|
++i;
|
} else {
|
break;
|
}
|
}
|
// linear interpolation in 5 degree interval
|
var coefs = COEFS_Y[i];
|
var t = 5 * (ll.y - coefs[0]) / (COEFS_Y[i+1][0] - coefs[0]);
|
// find t so that poly3_val(coefs, t) = ll.y
|
t = newton_rapshon(function(x) {
|
return (poly3_val(coefs, x) - ll.y) / poly3_der(coefs, x);
|
}, t, EPSLN, 100);
|
|
ll.x /= poly3_val(COEFS_X[i], t);
|
ll.y = (5 * i + t) * D2R;
|
if (xy.y < 0) {
|
ll.y = -ll.y;
|
}
|
}
|
|
ll.x = adjust_lon(ll.x + this.long0);
|
return ll;
|
}
|
|
var robin_names = ["Robinson", "robin"];
|
/* harmony default export */ var robin = ({
|
init: robin_init,
|
forward: robin_forward,
|
inverse: robin_inverse,
|
names: robin_names
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/geocent.js
|
|
|
function geocent_init() {
|
this.name = 'geocent';
|
|
}
|
|
function geocent_forward(p) {
|
var point = geodeticToGeocentric(p, this.es, this.a);
|
return point;
|
}
|
|
function geocent_inverse(p) {
|
var point = geocentricToGeodetic(p, this.es, this.a, this.b);
|
return point;
|
}
|
|
var geocent_names = ["Geocentric", 'geocentric', "geocent", "Geocent"];
|
/* harmony default export */ var geocent = ({
|
init: geocent_init,
|
forward: geocent_forward,
|
inverse: geocent_inverse,
|
names: geocent_names
|
});
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/tpers.js
|
|
var mode = {
|
N_POLE: 0,
|
S_POLE: 1,
|
EQUIT: 2,
|
OBLIQ: 3
|
};
|
|
|
|
|
var tpers_params = {
|
h: { def: 100000, num: true }, // default is Karman line, no default in PROJ.7
|
azi: { def: 0, num: true, degrees: true }, // default is North
|
tilt: { def: 0, num: true, degrees: true }, // default is Nadir
|
long0: { def: 0, num: true }, // default is Greenwich, conversion to rad is automatic
|
lat0: { def: 0, num: true } // default is Equator, conversion to rad is automatic
|
};
|
|
function tpers_init() {
|
Object.keys(tpers_params).forEach(function (p) {
|
if (typeof this[p] === "undefined") {
|
this[p] = tpers_params[p].def;
|
} else if (tpers_params[p].num && isNaN(this[p])) {
|
throw new Error("Invalid parameter value, must be numeric " + p + " = " + this[p]);
|
} else if (tpers_params[p].num) {
|
this[p] = parseFloat(this[p]);
|
}
|
if (tpers_params[p].degrees) {
|
this[p] = this[p] * D2R;
|
}
|
}.bind(this));
|
|
if (Math.abs((Math.abs(this.lat0) - HALF_PI)) < EPSLN) {
|
this.mode = this.lat0 < 0 ? mode.S_POLE : mode.N_POLE;
|
} else if (Math.abs(this.lat0) < EPSLN) {
|
this.mode = mode.EQUIT;
|
} else {
|
this.mode = mode.OBLIQ;
|
this.sinph0 = Math.sin(this.lat0);
|
this.cosph0 = Math.cos(this.lat0);
|
}
|
|
this.pn1 = this.h / this.a; // Normalize relative to the Earth's radius
|
|
if (this.pn1 <= 0 || this.pn1 > 1e10) {
|
throw new Error("Invalid height");
|
}
|
|
this.p = 1 + this.pn1;
|
this.rp = 1 / this.p;
|
this.h1 = 1 / this.pn1;
|
this.pfact = (this.p + 1) * this.h1;
|
this.es = 0;
|
|
var omega = this.tilt;
|
var gamma = this.azi;
|
this.cg = Math.cos(gamma);
|
this.sg = Math.sin(gamma);
|
this.cw = Math.cos(omega);
|
this.sw = Math.sin(omega);
|
}
|
|
function tpers_forward(p) {
|
p.x -= this.long0;
|
var sinphi = Math.sin(p.y);
|
var cosphi = Math.cos(p.y);
|
var coslam = Math.cos(p.x);
|
var x, y;
|
switch (this.mode) {
|
case mode.OBLIQ:
|
y = this.sinph0 * sinphi + this.cosph0 * cosphi * coslam;
|
break;
|
case mode.EQUIT:
|
y = cosphi * coslam;
|
break;
|
case mode.S_POLE:
|
y = -sinphi;
|
break;
|
case mode.N_POLE:
|
y = sinphi;
|
break;
|
}
|
y = this.pn1 / (this.p - y);
|
x = y * cosphi * Math.sin(p.x);
|
|
switch (this.mode) {
|
case mode.OBLIQ:
|
y *= this.cosph0 * sinphi - this.sinph0 * cosphi * coslam;
|
break;
|
case mode.EQUIT:
|
y *= sinphi;
|
break;
|
case mode.N_POLE:
|
y *= -(cosphi * coslam);
|
break;
|
case mode.S_POLE:
|
y *= cosphi * coslam;
|
break;
|
}
|
|
// Tilt
|
var yt, ba;
|
yt = y * this.cg + x * this.sg;
|
ba = 1 / (yt * this.sw * this.h1 + this.cw);
|
x = (x * this.cg - y * this.sg) * this.cw * ba;
|
y = yt * ba;
|
|
p.x = x * this.a;
|
p.y = y * this.a;
|
return p;
|
}
|
|
function tpers_inverse(p) {
|
p.x /= this.a;
|
p.y /= this.a;
|
var r = { x: p.x, y: p.y };
|
|
// Un-Tilt
|
var bm, bq, yt;
|
yt = 1 / (this.pn1 - p.y * this.sw);
|
bm = this.pn1 * p.x * yt;
|
bq = this.pn1 * p.y * this.cw * yt;
|
p.x = bm * this.cg + bq * this.sg;
|
p.y = bq * this.cg - bm * this.sg;
|
|
var rh = hypot(p.x, p.y);
|
if (Math.abs(rh) < EPSLN) {
|
r.x = 0;
|
r.y = p.y;
|
} else {
|
var cosz, sinz;
|
sinz = 1 - rh * rh * this.pfact;
|
sinz = (this.p - Math.sqrt(sinz)) / (this.pn1 / rh + rh / this.pn1);
|
cosz = Math.sqrt(1 - sinz * sinz);
|
switch (this.mode) {
|
case mode.OBLIQ:
|
r.y = Math.asin(cosz * this.sinph0 + p.y * sinz * this.cosph0 / rh);
|
p.y = (cosz - this.sinph0 * Math.sin(r.y)) * rh;
|
p.x *= sinz * this.cosph0;
|
break;
|
case mode.EQUIT:
|
r.y = Math.asin(p.y * sinz / rh);
|
p.y = cosz * rh;
|
p.x *= sinz;
|
break;
|
case mode.N_POLE:
|
r.y = Math.asin(cosz);
|
p.y = -p.y;
|
break;
|
case mode.S_POLE:
|
r.y = -Math.asin(cosz);
|
break;
|
}
|
r.x = Math.atan2(p.x, p.y);
|
}
|
|
p.x = r.x + this.long0;
|
p.y = r.y;
|
return p;
|
}
|
|
var tpers_names = ["Tilted_Perspective", "tpers"];
|
/* harmony default export */ var tpers = ({
|
init: tpers_init,
|
forward: tpers_forward,
|
inverse: tpers_inverse,
|
names: tpers_names
|
});
|
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/projections/geos.js
|
|
|
function geos_init() {
|
this.flip_axis = (this.sweep === 'x' ? 1 : 0);
|
this.h = Number(this.h);
|
this.radius_g_1 = this.h / this.a;
|
|
if (this.radius_g_1 <= 0 || this.radius_g_1 > 1e10) {
|
throw new Error();
|
}
|
|
this.radius_g = 1.0 + this.radius_g_1;
|
this.C = this.radius_g * this.radius_g - 1.0;
|
|
if (this.es !== 0.0) {
|
var one_es = 1.0 - this.es;
|
var rone_es = 1 / one_es;
|
|
this.radius_p = Math.sqrt(one_es);
|
this.radius_p2 = one_es;
|
this.radius_p_inv2 = rone_es;
|
|
this.shape = 'ellipse'; // Use as a condition in the forward and inverse functions.
|
} else {
|
this.radius_p = 1.0;
|
this.radius_p2 = 1.0;
|
this.radius_p_inv2 = 1.0;
|
|
this.shape = 'sphere'; // Use as a condition in the forward and inverse functions.
|
}
|
|
if (!this.title) {
|
this.title = "Geostationary Satellite View";
|
}
|
}
|
|
function geos_forward(p) {
|
var lon = p.x;
|
var lat = p.y;
|
var tmp, v_x, v_y, v_z;
|
lon = lon - this.long0;
|
|
if (this.shape === 'ellipse') {
|
lat = Math.atan(this.radius_p2 * Math.tan(lat));
|
var r = this.radius_p / hypot(this.radius_p * Math.cos(lat), Math.sin(lat));
|
|
v_x = r * Math.cos(lon) * Math.cos(lat);
|
v_y = r * Math.sin(lon) * Math.cos(lat);
|
v_z = r * Math.sin(lat);
|
|
if (((this.radius_g - v_x) * v_x - v_y * v_y - v_z * v_z * this.radius_p_inv2) < 0.0) {
|
p.x = Number.NaN;
|
p.y = Number.NaN;
|
return p;
|
}
|
|
tmp = this.radius_g - v_x;
|
if (this.flip_axis) {
|
p.x = this.radius_g_1 * Math.atan(v_y / hypot(v_z, tmp));
|
p.y = this.radius_g_1 * Math.atan(v_z / tmp);
|
} else {
|
p.x = this.radius_g_1 * Math.atan(v_y / tmp);
|
p.y = this.radius_g_1 * Math.atan(v_z / hypot(v_y, tmp));
|
}
|
} else if (this.shape === 'sphere') {
|
tmp = Math.cos(lat);
|
v_x = Math.cos(lon) * tmp;
|
v_y = Math.sin(lon) * tmp;
|
v_z = Math.sin(lat);
|
tmp = this.radius_g - v_x;
|
|
if (this.flip_axis) {
|
p.x = this.radius_g_1 * Math.atan(v_y / hypot(v_z, tmp));
|
p.y = this.radius_g_1 * Math.atan(v_z / tmp);
|
} else {
|
p.x = this.radius_g_1 * Math.atan(v_y / tmp);
|
p.y = this.radius_g_1 * Math.atan(v_z / hypot(v_y, tmp));
|
}
|
}
|
p.x = p.x * this.a;
|
p.y = p.y * this.a;
|
return p;
|
}
|
|
function geos_inverse(p) {
|
var v_x = -1.0;
|
var v_y = 0.0;
|
var v_z = 0.0;
|
var a, b, det, k;
|
|
p.x = p.x / this.a;
|
p.y = p.y / this.a;
|
|
if (this.shape === 'ellipse') {
|
if (this.flip_axis) {
|
v_z = Math.tan(p.y / this.radius_g_1);
|
v_y = Math.tan(p.x / this.radius_g_1) * hypot(1.0, v_z);
|
} else {
|
v_y = Math.tan(p.x / this.radius_g_1);
|
v_z = Math.tan(p.y / this.radius_g_1) * hypot(1.0, v_y);
|
}
|
|
var v_zp = v_z / this.radius_p;
|
a = v_y * v_y + v_zp * v_zp + v_x * v_x;
|
b = 2 * this.radius_g * v_x;
|
det = (b * b) - 4 * a * this.C;
|
|
if (det < 0.0) {
|
p.x = Number.NaN;
|
p.y = Number.NaN;
|
return p;
|
}
|
|
k = (-b - Math.sqrt(det)) / (2.0 * a);
|
v_x = this.radius_g + k * v_x;
|
v_y *= k;
|
v_z *= k;
|
|
p.x = Math.atan2(v_y, v_x);
|
p.y = Math.atan(v_z * Math.cos(p.x) / v_x);
|
p.y = Math.atan(this.radius_p_inv2 * Math.tan(p.y));
|
} else if (this.shape === 'sphere') {
|
if (this.flip_axis) {
|
v_z = Math.tan(p.y / this.radius_g_1);
|
v_y = Math.tan(p.x / this.radius_g_1) * Math.sqrt(1.0 + v_z * v_z);
|
} else {
|
v_y = Math.tan(p.x / this.radius_g_1);
|
v_z = Math.tan(p.y / this.radius_g_1) * Math.sqrt(1.0 + v_y * v_y);
|
}
|
|
a = v_y * v_y + v_z * v_z + v_x * v_x;
|
b = 2 * this.radius_g * v_x;
|
det = (b * b) - 4 * a * this.C;
|
if (det < 0.0) {
|
p.x = Number.NaN;
|
p.y = Number.NaN;
|
return p;
|
}
|
|
k = (-b - Math.sqrt(det)) / (2.0 * a);
|
v_x = this.radius_g + k * v_x;
|
v_y *= k;
|
v_z *= k;
|
|
p.x = Math.atan2(v_y, v_x);
|
p.y = Math.atan(v_z * Math.cos(p.x) / v_x);
|
}
|
p.x = p.x + this.long0;
|
return p;
|
}
|
|
var geos_names = ["Geostationary Satellite View", "Geostationary_Satellite", "geos"];
|
/* harmony default export */ var geos = ({
|
init: geos_init,
|
forward: geos_forward,
|
inverse: geos_inverse,
|
names: geos_names,
|
});
|
|
|
// CONCATENATED MODULE: ./node_modules/proj4/projs.js
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* harmony default export */ var proj4_projs = (function(proj4){
|
proj4.Proj.projections.add(tmerc);
|
proj4.Proj.projections.add(etmerc);
|
proj4.Proj.projections.add(utm);
|
proj4.Proj.projections.add(sterea);
|
proj4.Proj.projections.add(stere);
|
proj4.Proj.projections.add(somerc);
|
proj4.Proj.projections.add(omerc);
|
proj4.Proj.projections.add(lcc);
|
proj4.Proj.projections.add(krovak);
|
proj4.Proj.projections.add(cass);
|
proj4.Proj.projections.add(laea);
|
proj4.Proj.projections.add(aea);
|
proj4.Proj.projections.add(gnom);
|
proj4.Proj.projections.add(cea);
|
proj4.Proj.projections.add(eqc);
|
proj4.Proj.projections.add(poly);
|
proj4.Proj.projections.add(nzmg);
|
proj4.Proj.projections.add(mill);
|
proj4.Proj.projections.add(sinu);
|
proj4.Proj.projections.add(moll);
|
proj4.Proj.projections.add(eqdc);
|
proj4.Proj.projections.add(vandg);
|
proj4.Proj.projections.add(aeqd);
|
proj4.Proj.projections.add(ortho);
|
proj4.Proj.projections.add(qsc);
|
proj4.Proj.projections.add(robin);
|
proj4.Proj.projections.add(geocent);
|
proj4.Proj.projections.add(tpers);
|
proj4.Proj.projections.add(geos);
|
});
|
// CONCATENATED MODULE: ./node_modules/proj4/lib/index.js
|
|
|
|
|
|
|
|
|
|
|
core.defaultDatum = 'WGS84'; //default datum
|
core.Proj = Proj;
|
core.WGS84 = new core.Proj('WGS84');
|
core.Point = lib_Point;
|
core.toPoint = toPoint;
|
core.defs = lib_defs;
|
core.nadgrid = nadgrid;
|
core.transform = transform;
|
core.mgrs = mgrs;
|
core.version = '__VERSION__';
|
proj4_projs(core);
|
/* harmony default export */ var lib = __webpack_exports__["default"] = (core);
|
|
|
/***/ })
|
/******/ ]);
|
});
|