X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/b5ba6a1e3f2d306128b82c818802921f2892d73f..dcd55590709ab18657cdbe5ab4ddd5e360ba6b43:/vendor/assets/iD/iD/mapillary-js/mapillary.js diff --git a/vendor/assets/iD/iD/mapillary-js/mapillary.js b/vendor/assets/iD/iD/mapillary-js/mapillary.js index daaeeec55..78087cb38 100644 --- a/vendor/assets/iD/iD/mapillary-js/mapillary.js +++ b/vendor/assets/iD/iD/mapillary-js/mapillary.js @@ -156,7 +156,7 @@ function getSegDistSq(px, py, a, b) { return dx * dx + dy * dy; } -},{"tinyqueue":226}],2:[function(require,module,exports){ +},{"tinyqueue":243}],2:[function(require,module,exports){ /* * Copyright (C) 2008 Apple Inc. All Rights Reserved. * @@ -3883,6 +3883,8543 @@ Geohash.neighbours = function(geohash) { if (typeof module != 'undefined' && module.exports) module.exports = Geohash; // CommonJS, node.js },{}],22:[function(require,module,exports){ +/** + * martinez v0.5.0 + * Martinez polygon clipping algorithm, does boolean operation on polygons (multipolygons, polygons with holes etc): intersection, union, difference, xor + * + * @author Alex Milevski + * @license MIT + * @preserve + */ + +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (factory((global.martinez = {}))); +}(this, (function (exports) { 'use strict'; + + function DEFAULT_COMPARE (a, b) { return a > b ? 1 : a < b ? -1 : 0; } + + var SplayTree = function SplayTree(compare, noDuplicates) { + if ( compare === void 0 ) compare = DEFAULT_COMPARE; + if ( noDuplicates === void 0 ) noDuplicates = false; + + this._compare = compare; + this._root = null; + this._size = 0; + this._noDuplicates = !!noDuplicates; + }; + + var prototypeAccessors = { size: { configurable: true } }; + + + SplayTree.prototype.rotateLeft = function rotateLeft (x) { + var y = x.right; + if (y) { + x.right = y.left; + if (y.left) { y.left.parent = x; } + y.parent = x.parent; + } + + if (!x.parent) { this._root = y; } + else if (x === x.parent.left) { x.parent.left = y; } + else { x.parent.right = y; } + if (y) { y.left = x; } + x.parent = y; + }; + + + SplayTree.prototype.rotateRight = function rotateRight (x) { + var y = x.left; + if (y) { + x.left = y.right; + if (y.right) { y.right.parent = x; } + y.parent = x.parent; + } + + if (!x.parent) { this._root = y; } + else if(x === x.parent.left) { x.parent.left = y; } + else { x.parent.right = y; } + if (y) { y.right = x; } + x.parent = y; + }; + + + SplayTree.prototype._splay = function _splay (x) { + var this$1 = this; + + while (x.parent) { + var p = x.parent; + if (!p.parent) { + if (p.left === x) { this$1.rotateRight(p); } + else { this$1.rotateLeft(p); } + } else if (p.left === x && p.parent.left === p) { + this$1.rotateRight(p.parent); + this$1.rotateRight(p); + } else if (p.right === x && p.parent.right === p) { + this$1.rotateLeft(p.parent); + this$1.rotateLeft(p); + } else if (p.left === x && p.parent.right === p) { + this$1.rotateRight(p); + this$1.rotateLeft(p); + } else { + this$1.rotateLeft(p); + this$1.rotateRight(p); + } + } + }; + + + SplayTree.prototype.splay = function splay (x) { + var this$1 = this; + + var p, gp, ggp, l, r; + + while (x.parent) { + p = x.parent; + gp = p.parent; + + if (gp && gp.parent) { + ggp = gp.parent; + if (ggp.left === gp) { ggp.left= x; } + else { ggp.right = x; } + x.parent = ggp; + } else { + x.parent = null; + this$1._root = x; + } + + l = x.left; r = x.right; + + if (x === p.left) { // left + if (gp) { + if (gp.left === p) { + /* zig-zig */ + if (p.right) { + gp.left = p.right; + gp.left.parent = gp; + } else { gp.left = null; } + + p.right = gp; + gp.parent = p; + } else { + /* zig-zag */ + if (l) { + gp.right = l; + l.parent = gp; + } else { gp.right = null; } + + x.left = gp; + gp.parent = x; + } + } + if (r) { + p.left = r; + r.parent = p; + } else { p.left = null; } + + x.right= p; + p.parent = x; + } else { // right + if (gp) { + if (gp.right === p) { + /* zig-zig */ + if (p.left) { + gp.right = p.left; + gp.right.parent = gp; + } else { gp.right = null; } + + p.left = gp; + gp.parent = p; + } else { + /* zig-zag */ + if (r) { + gp.left = r; + r.parent = gp; + } else { gp.left = null; } + + x.right = gp; + gp.parent = x; + } + } + if (l) { + p.right = l; + l.parent = p; + } else { p.right = null; } + + x.left = p; + p.parent = x; + } + } + }; + + + SplayTree.prototype.replace = function replace (u, v) { + if (!u.parent) { this._root = v; } + else if (u === u.parent.left) { u.parent.left = v; } + else { u.parent.right = v; } + if (v) { v.parent = u.parent; } + }; + + + SplayTree.prototype.minNode = function minNode (u) { + if ( u === void 0 ) u = this._root; + + if (u) { while (u.left) { u = u.left; } } + return u; + }; + + + SplayTree.prototype.maxNode = function maxNode (u) { + if ( u === void 0 ) u = this._root; + + if (u) { while (u.right) { u = u.right; } } + return u; + }; + + + SplayTree.prototype.insert = function insert (key, data) { + var z = this._root; + var p = null; + var comp = this._compare; + var cmp; + + if (this._noDuplicates) { + while (z) { + p = z; + cmp = comp(z.key, key); + if (cmp === 0) { return; } + else if (comp(z.key, key) < 0) { z = z.right; } + else { z = z.left; } + } + } else { + while (z) { + p = z; + if (comp(z.key, key) < 0) { z = z.right; } + else { z = z.left; } + } + } + + z = { key: key, data: data, left: null, right: null, parent: p }; + + if (!p) { this._root = z; } + else if (comp(p.key, z.key) < 0) { p.right = z; } + else { p.left= z; } + + this.splay(z); + this._size++; + return z; + }; + + + SplayTree.prototype.find = function find (key) { + var z = this._root; + var comp = this._compare; + while (z) { + var cmp = comp(z.key, key); + if (cmp < 0) { z = z.right; } + else if (cmp > 0) { z = z.left; } + else { return z; } + } + return null; + }; + + /** + * Whether the tree contains a node with the given key + * @param{Key} key + * @return {boolean} true/false + */ + SplayTree.prototype.contains = function contains (key) { + var node = this._root; + var comparator = this._compare; + while (node){ + var cmp = comparator(key, node.key); + if (cmp === 0) { return true; } + else if (cmp < 0) { node = node.left; } + else { node = node.right; } + } + + return false; + }; + + + SplayTree.prototype.remove = function remove (key) { + var z = this.find(key); + + if (!z) { return false; } + + this.splay(z); + + if (!z.left) { this.replace(z, z.right); } + else if (!z.right) { this.replace(z, z.left); } + else { + var y = this.minNode(z.right); + if (y.parent !== z) { + this.replace(y, y.right); + y.right = z.right; + y.right.parent = y; + } + this.replace(z, y); + y.left = z.left; + y.left.parent = y; + } + + this._size--; + return true; + }; + + + SplayTree.prototype.removeNode = function removeNode (z) { + if (!z) { return false; } + + this.splay(z); + + if (!z.left) { this.replace(z, z.right); } + else if (!z.right) { this.replace(z, z.left); } + else { + var y = this.minNode(z.right); + if (y.parent !== z) { + this.replace(y, y.right); + y.right = z.right; + y.right.parent = y; + } + this.replace(z, y); + y.left = z.left; + y.left.parent = y; + } + + this._size--; + return true; + }; + + + SplayTree.prototype.erase = function erase (key) { + var z = this.find(key); + if (!z) { return; } + + this.splay(z); + + var s = z.left; + var t = z.right; + + var sMax = null; + if (s) { + s.parent = null; + sMax = this.maxNode(s); + this.splay(sMax); + this._root = sMax; + } + if (t) { + if (s) { sMax.right = t; } + else { this._root = t; } + t.parent = sMax; + } + + this._size--; + }; + + /** + * Removes and returns the node with smallest key + * @return {?Node} + */ + SplayTree.prototype.pop = function pop () { + var node = this._root, returnValue = null; + if (node) { + while (node.left) { node = node.left; } + returnValue = { key: node.key, data: node.data }; + this.remove(node.key); + } + return returnValue; + }; + + + /* eslint-disable class-methods-use-this */ + + /** + * Successor node + * @param{Node} node + * @return {?Node} + */ + SplayTree.prototype.next = function next (node) { + var successor = node; + if (successor) { + if (successor.right) { + successor = successor.right; + while (successor && successor.left) { successor = successor.left; } + } else { + successor = node.parent; + while (successor && successor.right === node) { + node = successor; successor = successor.parent; + } + } + } + return successor; + }; + + + /** + * Predecessor node + * @param{Node} node + * @return {?Node} + */ + SplayTree.prototype.prev = function prev (node) { + var predecessor = node; + if (predecessor) { + if (predecessor.left) { + predecessor = predecessor.left; + while (predecessor && predecessor.right) { predecessor = predecessor.right; } + } else { + predecessor = node.parent; + while (predecessor && predecessor.left === node) { + node = predecessor; + predecessor = predecessor.parent; + } + } + } + return predecessor; + }; + /* eslint-enable class-methods-use-this */ + + + /** + * @param{forEachCallback} callback + * @return {SplayTree} + */ + SplayTree.prototype.forEach = function forEach (callback) { + var current = this._root; + var s = [], done = false, i = 0; + + while (!done) { + // Reach the left most Node of the current Node + if (current) { + // Place pointer to a tree node on the stack + // before traversing the node's left subtree + s.push(current); + current = current.left; + } else { + // BackTrack from the empty subtree and visit the Node + // at the top of the stack; however, if the stack is + // empty you are done + if (s.length > 0) { + current = s.pop(); + callback(current, i++); + + // We have visited the node and its left + // subtree. Now, it's right subtree's turn + current = current.right; + } else { done = true; } + } + } + return this; + }; + + + /** + * Walk key range from `low` to `high`. Stops if `fn` returns a value. + * @param{Key} low + * @param{Key} high + * @param{Function} fn + * @param{*?} ctx + * @return {SplayTree} + */ + SplayTree.prototype.range = function range (low, high, fn, ctx) { + var this$1 = this; + + var Q = []; + var compare = this._compare; + var node = this._root, cmp; + + while (Q.length !== 0 || node) { + if (node) { + Q.push(node); + node = node.left; + } else { + node = Q.pop(); + cmp = compare(node.key, high); + if (cmp > 0) { + break; + } else if (compare(node.key, low) >= 0) { + if (fn.call(ctx, node)) { return this$1; } // stop if smth is returned + } + node = node.right; + } + } + return this; + }; + + /** + * Returns all keys in order + * @return {Array} + */ + SplayTree.prototype.keys = function keys () { + var current = this._root; + var s = [], r = [], done = false; + + while (!done) { + if (current) { + s.push(current); + current = current.left; + } else { + if (s.length > 0) { + current = s.pop(); + r.push(current.key); + current = current.right; + } else { done = true; } + } + } + return r; + }; + + + /** + * Returns `data` fields of all nodes in order. + * @return {Array} + */ + SplayTree.prototype.values = function values () { + var current = this._root; + var s = [], r = [], done = false; + + while (!done) { + if (current) { + s.push(current); + current = current.left; + } else { + if (s.length > 0) { + current = s.pop(); + r.push(current.data); + current = current.right; + } else { done = true; } + } + } + return r; + }; + + + /** + * Returns node at given index + * @param{number} index + * @return {?Node} + */ + SplayTree.prototype.at = function at (index) { + // removed after a consideration, more misleading than useful + // index = index % this.size; + // if (index < 0) index = this.size - index; + + var current = this._root; + var s = [], done = false, i = 0; + + while (!done) { + if (current) { + s.push(current); + current = current.left; + } else { + if (s.length > 0) { + current = s.pop(); + if (i === index) { return current; } + i++; + current = current.right; + } else { done = true; } + } + } + return null; + }; + + /** + * Bulk-load items. Both array have to be same size + * @param{Array} keys + * @param{Array}[values] + * @param{Boolean} [presort=false] Pre-sort keys and values, using + * tree's comparator. Sorting is done + * in-place + * @return {AVLTree} + */ + SplayTree.prototype.load = function load (keys, values, presort) { + if ( keys === void 0 ) keys = []; + if ( values === void 0 ) values = []; + if ( presort === void 0 ) presort = false; + + if (this._size !== 0) { throw new Error('bulk-load: tree is not empty'); } + var size = keys.length; + if (presort) { sort(keys, values, 0, size - 1, this._compare); } + this._root = loadRecursive(null, keys, values, 0, size); + this._size = size; + return this; + }; + + + SplayTree.prototype.min = function min () { + var node = this.minNode(this._root); + if (node) { return node.key; } + else { return null; } + }; + + + SplayTree.prototype.max = function max () { + var node = this.maxNode(this._root); + if (node) { return node.key; } + else { return null; } + }; + + SplayTree.prototype.isEmpty = function isEmpty () { return this._root === null; }; + prototypeAccessors.size.get = function () { return this._size; }; + + + /** + * Create a tree and load it with items + * @param{Array} keys + * @param{Array?} [values] + + * @param{Function?} [comparator] + * @param{Boolean?} [presort=false] Pre-sort keys and values, using + * tree's comparator. Sorting is done + * in-place + * @param{Boolean?} [noDuplicates=false] Allow duplicates + * @return {SplayTree} + */ + SplayTree.createTree = function createTree (keys, values, comparator, presort, noDuplicates) { + return new SplayTree(comparator, noDuplicates).load(keys, values, presort); + }; + + Object.defineProperties( SplayTree.prototype, prototypeAccessors ); + + + function loadRecursive (parent, keys, values, start, end) { + var size = end - start; + if (size > 0) { + var middle = start + Math.floor(size / 2); + var key = keys[middle]; + var data = values[middle]; + var node = { key: key, data: data, parent: parent }; + node.left = loadRecursive(node, keys, values, start, middle); + node.right = loadRecursive(node, keys, values, middle + 1, end); + return node; + } + return null; + } + + + function sort(keys, values, left, right, compare) { + if (left >= right) { return; } + + var pivot = keys[(left + right) >> 1]; + var i = left - 1; + var j = right + 1; + + while (true) { + do { i++; } while (compare(keys[i], pivot) < 0); + do { j--; } while (compare(keys[j], pivot) > 0); + if (i >= j) { break; } + + var tmp = keys[i]; + keys[i] = keys[j]; + keys[j] = tmp; + + tmp = values[i]; + values[i] = values[j]; + values[j] = tmp; + } + + sort(keys, values, left, j, compare); + sort(keys, values, j + 1, right, compare); + } + + var NORMAL = 0; + var NON_CONTRIBUTING = 1; + var SAME_TRANSITION = 2; + var DIFFERENT_TRANSITION = 3; + + var INTERSECTION = 0; + var UNION = 1; + var DIFFERENCE = 2; + var XOR = 3; + + /** + * @param {SweepEvent} event + * @param {SweepEvent} prev + * @param {Operation} operation + */ + function computeFields (event, prev, operation) { + // compute inOut and otherInOut fields + if (prev === null) { + event.inOut = false; + event.otherInOut = true; + + // previous line segment in sweepline belongs to the same polygon + } else { + if (event.isSubject === prev.isSubject) { + event.inOut = !prev.inOut; + event.otherInOut = prev.otherInOut; + + // previous line segment in sweepline belongs to the clipping polygon + } else { + event.inOut = !prev.otherInOut; + event.otherInOut = prev.isVertical() ? !prev.inOut : prev.inOut; + } + + // compute prevInResult field + if (prev) { + event.prevInResult = (!inResult(prev, operation) || prev.isVertical()) + ? prev.prevInResult : prev; + } + } + + // check if the line segment belongs to the Boolean operation + event.inResult = inResult(event, operation); + } + + + /* eslint-disable indent */ + function inResult(event, operation) { + switch (event.type) { + case NORMAL: + switch (operation) { + case INTERSECTION: + return !event.otherInOut; + case UNION: + return event.otherInOut; + case DIFFERENCE: + // return (event.isSubject && !event.otherInOut) || + // (!event.isSubject && event.otherInOut); + return (event.isSubject && event.otherInOut) || + (!event.isSubject && !event.otherInOut); + case XOR: + return true; + } + break; + case SAME_TRANSITION: + return operation === INTERSECTION || operation === UNION; + case DIFFERENT_TRANSITION: + return operation === DIFFERENCE; + case NON_CONTRIBUTING: + return false; + } + return false; + } + /* eslint-enable indent */ + + var SweepEvent = function SweepEvent (point, left, otherEvent, isSubject, edgeType) { + + /** + * Is left endpoint? + * @type {Boolean} + */ + this.left = left; + + /** + * @type {Array.} + */ + this.point = point; + + /** + * Other edge reference + * @type {SweepEvent} + */ + this.otherEvent = otherEvent; + + /** + * Belongs to source or clipping polygon + * @type {Boolean} + */ + this.isSubject = isSubject; + + /** + * Edge contribution type + * @type {Number} + */ + this.type = edgeType || NORMAL; + + + /** + * In-out transition for the sweepline crossing polygon + * @type {Boolean} + */ + this.inOut = false; + + + /** + * @type {Boolean} + */ + this.otherInOut = false; + + /** + * Previous event in result? + * @type {SweepEvent} + */ + this.prevInResult = null; + + /** + * Does event belong to result? + * @type {Boolean} + */ + this.inResult = false; + + + // connection step + + /** + * @type {Boolean} + */ + this.resultInOut = false; + + this.isExteriorRing = true; + }; + + + /** + * @param{Array.}p + * @return {Boolean} + */ + SweepEvent.prototype.isBelow = function isBelow (p) { + var p0 = this.point, p1 = this.otherEvent.point; + return this.left + ? (p0[0] - p[0]) * (p1[1] - p[1]) - (p1[0] - p[0]) * (p0[1] - p[1]) > 0 + // signedArea(this.point, this.otherEvent.point, p) > 0 : + : (p1[0] - p[0]) * (p0[1] - p[1]) - (p0[0] - p[0]) * (p1[1] - p[1]) > 0; + //signedArea(this.otherEvent.point, this.point, p) > 0; + }; + + + /** + * @param{Array.}p + * @return {Boolean} + */ + SweepEvent.prototype.isAbove = function isAbove (p) { + return !this.isBelow(p); + }; + + + /** + * @return {Boolean} + */ + SweepEvent.prototype.isVertical = function isVertical () { + return this.point[0] === this.otherEvent.point[0]; + }; + + + SweepEvent.prototype.clone = function clone () { + var copy = new SweepEvent( + this.point, this.left, this.otherEvent, this.isSubject, this.type); + + copy.inResult = this.inResult; + copy.prevInResult = this.prevInResult; + copy.isExteriorRing = this.isExteriorRing; + copy.inOut = this.inOut; + copy.otherInOut = this.otherInOut; + + return copy; + }; + + function equals(p1, p2) { + if (p1[0] === p2[0]) { + if (p1[1] === p2[1]) { + return true; + } else { + return false; + } + } + return false; + } + + // const EPSILON = 1e-9; + // const abs = Math.abs; + // TODO https://github.com/w8r/martinez/issues/6#issuecomment-262847164 + // Precision problem. + // + // module.exports = function equals(p1, p2) { + // return abs(p1[0] - p2[0]) <= EPSILON && abs(p1[1] - p2[1]) <= EPSILON; + // }; + + /** + * Signed area of the triangle (p0, p1, p2) + * @param {Array.} p0 + * @param {Array.} p1 + * @param {Array.} p2 + * @return {Number} + */ + function signedArea(p0, p1, p2) { + return (p0[0] - p2[0]) * (p1[1] - p2[1]) - (p1[0] - p2[0]) * (p0[1] - p2[1]); + } + + /** + * @param {SweepEvent} e1 + * @param {SweepEvent} e2 + * @return {Number} + */ + function compareEvents(e1, e2) { + var p1 = e1.point; + var p2 = e2.point; + + // Different x-coordinate + if (p1[0] > p2[0]) { return 1; } + if (p1[0] < p2[0]) { return -1; } + + // Different points, but same x-coordinate + // Event with lower y-coordinate is processed first + if (p1[1] !== p2[1]) { return p1[1] > p2[1] ? 1 : -1; } + + return specialCases(e1, e2, p1, p2); + } + + + /* eslint-disable no-unused-vars */ + function specialCases(e1, e2, p1, p2) { + // Same coordinates, but one is a left endpoint and the other is + // a right endpoint. The right endpoint is processed first + if (e1.left !== e2.left) + { return e1.left ? 1 : -1; } + + // const p2 = e1.otherEvent.point, p3 = e2.otherEvent.point; + // const sa = (p1[0] - p3[0]) * (p2[1] - p3[1]) - (p2[0] - p3[0]) * (p1[1] - p3[1]) + // Same coordinates, both events + // are left endpoints or right endpoints. + // not collinear + if (signedArea(p1, e1.otherEvent.point, e2.otherEvent.point) !== 0) { + // the event associate to the bottom segment is processed first + return (!e1.isBelow(e2.otherEvent.point)) ? 1 : -1; + } + + return (!e1.isSubject && e2.isSubject) ? 1 : -1; + } + /* eslint-enable no-unused-vars */ + + /** + * @param {SweepEvent} se + * @param {Array.} p + * @param {Queue} queue + * @return {Queue} + */ + function divideSegment(se, p, queue) { + var r = new SweepEvent(p, false, se, se.isSubject); + var l = new SweepEvent(p, true, se.otherEvent, se.isSubject); + + /* eslint-disable no-console */ + if (equals(se.point, se.otherEvent.point)) { + + console.warn('what is that, a collapsed segment?', se); + } + /* eslint-enable no-console */ + + r.contourId = l.contourId = se.contourId; + + // avoid a rounding error. The left event would be processed after the right event + if (compareEvents(l, se.otherEvent) > 0) { + se.otherEvent.left = true; + l.left = false; + } + + // avoid a rounding error. The left event would be processed after the right event + // if (compareEvents(se, r) > 0) {} + + se.otherEvent.otherEvent = l; + se.otherEvent = r; + + queue.push(l); + queue.push(r); + + return queue; + } + + //const EPS = 1e-9; + + /** + * Finds the magnitude of the cross product of two vectors (if we pretend + * they're in three dimensions) + * + * @param {Object} a First vector + * @param {Object} b Second vector + * @private + * @returns {Number} The magnitude of the cross product + */ + function crossProduct(a, b) { + return (a[0] * b[1]) - (a[1] * b[0]); + } + + /** + * Finds the dot product of two vectors. + * + * @param {Object} a First vector + * @param {Object} b Second vector + * @private + * @returns {Number} The dot product + */ + function dotProduct(a, b) { + return (a[0] * b[0]) + (a[1] * b[1]); + } + + /** + * Finds the intersection (if any) between two line segments a and b, given the + * line segments' end points a1, a2 and b1, b2. + * + * This algorithm is based on Schneider and Eberly. + * http://www.cimec.org.ar/~ncalvo/Schneider_Eberly.pdf + * Page 244. + * + * @param {Array.} a1 point of first line + * @param {Array.} a2 point of first line + * @param {Array.} b1 point of second line + * @param {Array.} b2 point of second line + * @param {Boolean=} noEndpointTouch whether to skip single touchpoints + * (meaning connected segments) as + * intersections + * @returns {Array.>|Null} If the lines intersect, the point of + * intersection. If they overlap, the two end points of the overlapping segment. + * Otherwise, null. + */ + function intersection (a1, a2, b1, b2, noEndpointTouch) { + // The algorithm expects our lines in the form P + sd, where P is a point, + // s is on the interval [0, 1], and d is a vector. + // We are passed two points. P can be the first point of each pair. The + // vector, then, could be thought of as the distance (in x and y components) + // from the first point to the second point. + // So first, let's make our vectors: + var va = [a2[0] - a1[0], a2[1] - a1[1]]; + var vb = [b2[0] - b1[0], b2[1] - b1[1]]; + // We also define a function to convert back to regular point form: + + /* eslint-disable arrow-body-style */ + + function toPoint(p, s, d) { + return [ + p[0] + s * d[0], + p[1] + s * d[1] + ]; + } + + /* eslint-enable arrow-body-style */ + + // The rest is pretty much a straight port of the algorithm. + var e = [b1[0] - a1[0], b1[1] - a1[1]]; + var kross = crossProduct(va, vb); + var sqrKross = kross * kross; + var sqrLenA = dotProduct(va, va); + //const sqrLenB = dotProduct(vb, vb); + + // Check for line intersection. This works because of the properties of the + // cross product -- specifically, two vectors are parallel if and only if the + // cross product is the 0 vector. The full calculation involves relative error + // to account for possible very small line segments. See Schneider & Eberly + // for details. + if (sqrKross > 0/* EPS * sqrLenB * sqLenA */) { + // If they're not parallel, then (because these are line segments) they + // still might not actually intersect. This code checks that the + // intersection point of the lines is actually on both line segments. + var s = crossProduct(e, vb) / kross; + if (s < 0 || s > 1) { + // not on line segment a + return null; + } + var t = crossProduct(e, va) / kross; + if (t < 0 || t > 1) { + // not on line segment b + return null; + } + if (s === 0 || s === 1) { + // on an endpoint of line segment a + return noEndpointTouch ? null : [toPoint(a1, s, va)]; + } + if (t === 0 || t === 1) { + // on an endpoint of line segment b + return noEndpointTouch ? null : [toPoint(b1, t, vb)]; + } + return [toPoint(a1, s, va)]; + } + + // If we've reached this point, then the lines are either parallel or the + // same, but the segments could overlap partially or fully, or not at all. + // So we need to find the overlap, if any. To do that, we can use e, which is + // the (vector) difference between the two initial points. If this is parallel + // with the line itself, then the two lines are the same line, and there will + // be overlap. + //const sqrLenE = dotProduct(e, e); + kross = crossProduct(e, va); + sqrKross = kross * kross; + + if (sqrKross > 0 /* EPS * sqLenB * sqLenE */) { + // Lines are just parallel, not the same. No overlap. + return null; + } + + var sa = dotProduct(va, e) / sqrLenA; + var sb = sa + dotProduct(va, vb) / sqrLenA; + var smin = Math.min(sa, sb); + var smax = Math.max(sa, sb); + + // this is, essentially, the FindIntersection acting on floats from + // Schneider & Eberly, just inlined into this function. + if (smin <= 1 && smax >= 0) { + + // overlap on an end point + if (smin === 1) { + return noEndpointTouch ? null : [toPoint(a1, smin > 0 ? smin : 0, va)]; + } + + if (smax === 0) { + return noEndpointTouch ? null : [toPoint(a1, smax < 1 ? smax : 1, va)]; + } + + if (noEndpointTouch && smin === 0 && smax === 1) { return null; } + + // There's overlap on a segment -- two points of intersection. Return both. + return [ + toPoint(a1, smin > 0 ? smin : 0, va), + toPoint(a1, smax < 1 ? smax : 1, va) + ]; + } + + return null; + } + + /** + * @param {SweepEvent} se1 + * @param {SweepEvent} se2 + * @param {Queue} queue + * @return {Number} + */ + function possibleIntersection (se1, se2, queue) { + // that disallows self-intersecting polygons, + // did cost us half a day, so I'll leave it + // out of respect + // if (se1.isSubject === se2.isSubject) return; + var inter = intersection( + se1.point, se1.otherEvent.point, + se2.point, se2.otherEvent.point + ); + + var nintersections = inter ? inter.length : 0; + if (nintersections === 0) { return 0; } // no intersection + + // the line segments intersect at an endpoint of both line segments + if ((nintersections === 1) && + (equals(se1.point, se2.point) || + equals(se1.otherEvent.point, se2.otherEvent.point))) { + return 0; + } + + if (nintersections === 2 && se1.isSubject === se2.isSubject) { + // if(se1.contourId === se2.contourId){ + // console.warn('Edges of the same polygon overlap', + // se1.point, se1.otherEvent.point, se2.point, se2.otherEvent.point); + // } + //throw new Error('Edges of the same polygon overlap'); + return 0; + } + + // The line segments associated to se1 and se2 intersect + if (nintersections === 1) { + + // if the intersection point is not an endpoint of se1 + if (!equals(se1.point, inter[0]) && !equals(se1.otherEvent.point, inter[0])) { + divideSegment(se1, inter[0], queue); + } + + // if the intersection point is not an endpoint of se2 + if (!equals(se2.point, inter[0]) && !equals(se2.otherEvent.point, inter[0])) { + divideSegment(se2, inter[0], queue); + } + return 1; + } + + // The line segments associated to se1 and se2 overlap + var events = []; + var leftCoincide = false; + var rightCoincide = false; + + if (equals(se1.point, se2.point)) { + leftCoincide = true; // linked + } else if (compareEvents(se1, se2) === 1) { + events.push(se2, se1); + } else { + events.push(se1, se2); + } + + if (equals(se1.otherEvent.point, se2.otherEvent.point)) { + rightCoincide = true; + } else if (compareEvents(se1.otherEvent, se2.otherEvent) === 1) { + events.push(se2.otherEvent, se1.otherEvent); + } else { + events.push(se1.otherEvent, se2.otherEvent); + } + + if ((leftCoincide && rightCoincide) || leftCoincide) { + // both line segments are equal or share the left endpoint + se2.type = NON_CONTRIBUTING; + se1.type = (se2.inOut === se1.inOut) + ? SAME_TRANSITION : DIFFERENT_TRANSITION; + + if (leftCoincide && !rightCoincide) { + // honestly no idea, but changing events selection from [2, 1] + // to [0, 1] fixes the overlapping self-intersecting polygons issue + divideSegment(events[1].otherEvent, events[0].point, queue); + } + return 2; + } + + // the line segments share the right endpoint + if (rightCoincide) { + divideSegment(events[0], events[1].point, queue); + return 3; + } + + // no line segment includes totally the other one + if (events[0] !== events[3].otherEvent) { + divideSegment(events[0], events[1].point, queue); + divideSegment(events[1], events[2].point, queue); + return 3; + } + + // one line segment includes the other one + divideSegment(events[0], events[1].point, queue); + divideSegment(events[3].otherEvent, events[2].point, queue); + + return 3; + } + + /** + * @param {SweepEvent} le1 + * @param {SweepEvent} le2 + * @return {Number} + */ + function compareSegments(le1, le2) { + if (le1 === le2) { return 0; } + + // Segments are not collinear + if (signedArea(le1.point, le1.otherEvent.point, le2.point) !== 0 || + signedArea(le1.point, le1.otherEvent.point, le2.otherEvent.point) !== 0) { + + // If they share their left endpoint use the right endpoint to sort + if (equals(le1.point, le2.point)) { return le1.isBelow(le2.otherEvent.point) ? -1 : 1; } + + // Different left endpoint: use the left endpoint to sort + if (le1.point[0] === le2.point[0]) { return le1.point[1] < le2.point[1] ? -1 : 1; } + + // has the line segment associated to e1 been inserted + // into S after the line segment associated to e2 ? + if (compareEvents(le1, le2) === 1) { return le2.isAbove(le1.point) ? -1 : 1; } + + // The line segment associated to e2 has been inserted + // into S after the line segment associated to e1 + return le1.isBelow(le2.point) ? -1 : 1; + } + + if (le1.isSubject === le2.isSubject) { // same polygon + var p1 = le1.point, p2 = le2.point; + if (p1[0] === p2[0] && p1[1] === p2[1]/*equals(le1.point, le2.point)*/) { + p1 = le1.otherEvent.point; p2 = le2.otherEvent.point; + if (p1[0] === p2[0] && p1[1] === p2[1]) { return 0; } + else { return le1.contourId > le2.contourId ? 1 : -1; } + } + } else { // Segments are collinear, but belong to separate polygons + return le1.isSubject ? -1 : 1; + } + + return compareEvents(le1, le2) === 1 ? 1 : -1; + } + + function subdivide(eventQueue, subject, clipping, sbbox, cbbox, operation) { + var sweepLine = new SplayTree(compareSegments); + var sortedEvents = []; + + var rightbound = Math.min(sbbox[2], cbbox[2]); + + var prev, next, begin; + + while (eventQueue.length !== 0) { + var event = eventQueue.pop(); + sortedEvents.push(event); + + // optimization by bboxes for intersection and difference goes here + if ((operation === INTERSECTION && event.point[0] > rightbound) || + (operation === DIFFERENCE && event.point[0] > sbbox[2])) { + break; + } + + if (event.left) { + next = prev = sweepLine.insert(event); + begin = sweepLine.minNode(); + + if (prev !== begin) { prev = sweepLine.prev(prev); } + else { prev = null; } + + next = sweepLine.next(next); + + var prevEvent = prev ? prev.key : null; + var prevprevEvent = (void 0); + computeFields(event, prevEvent, operation); + if (next) { + if (possibleIntersection(event, next.key, eventQueue) === 2) { + computeFields(event, prevEvent, operation); + computeFields(event, next.key, operation); + } + } + + if (prev) { + if (possibleIntersection(prev.key, event, eventQueue) === 2) { + var prevprev = prev; + if (prevprev !== begin) { prevprev = sweepLine.prev(prevprev); } + else { prevprev = null; } + + prevprevEvent = prevprev ? prevprev.key : null; + computeFields(prevEvent, prevprevEvent, operation); + computeFields(event, prevEvent, operation); + } + } + } else { + event = event.otherEvent; + next = prev = sweepLine.find(event); + + if (prev && next) { + + if (prev !== begin) { prev = sweepLine.prev(prev); } + else { prev = null; } + + next = sweepLine.next(next); + sweepLine.remove(event); + + if (next && prev) { + possibleIntersection(prev.key, next.key, eventQueue); + } + } + } + } + return sortedEvents; + } + + /** + * @param {Array.} sortedEvents + * @return {Array.} + */ + function orderEvents(sortedEvents) { + var event, i, len, tmp; + var resultEvents = []; + for (i = 0, len = sortedEvents.length; i < len; i++) { + event = sortedEvents[i]; + if ((event.left && event.inResult) || + (!event.left && event.otherEvent.inResult)) { + resultEvents.push(event); + } + } + // Due to overlapping edges the resultEvents array can be not wholly sorted + var sorted = false; + while (!sorted) { + sorted = true; + for (i = 0, len = resultEvents.length; i < len; i++) { + if ((i + 1) < len && + compareEvents(resultEvents[i], resultEvents[i + 1]) === 1) { + tmp = resultEvents[i]; + resultEvents[i] = resultEvents[i + 1]; + resultEvents[i + 1] = tmp; + sorted = false; + } + } + } + + + for (i = 0, len = resultEvents.length; i < len; i++) { + event = resultEvents[i]; + event.pos = i; + } + + // imagine, the right event is found in the beginning of the queue, + // when his left counterpart is not marked yet + for (i = 0, len = resultEvents.length; i < len; i++) { + event = resultEvents[i]; + if (!event.left) { + tmp = event.pos; + event.pos = event.otherEvent.pos; + event.otherEvent.pos = tmp; + } + } + + return resultEvents; + } + + + /** + * @param {Number} pos + * @param {Array.} resultEvents + * @param {Object>} processed + * @return {Number} + */ + function nextPos(pos, resultEvents, processed, origIndex) { + var p, p1; + var newPos = pos + 1; + var length = resultEvents.length; + + p = resultEvents[pos].point; + + if (newPos < length) + { p1 = resultEvents[newPos].point; } + + + // while in range and not the current one by value + while (newPos < length && p1[0] === p[0] && p1[1] === p[1]) { + if (!processed[newPos]) { + return newPos; + } else { + newPos++; + } + p1 = resultEvents[newPos].point; + } + + newPos = pos - 1; + + while (processed[newPos] && newPos >= origIndex) { + newPos--; + } + return newPos; + } + + + /** + * @param {Array.} sortedEvents + * @return {Array.<*>} polygons + */ + function connectEdges(sortedEvents, operation) { + var i, len; + var resultEvents = orderEvents(sortedEvents); + + // "false"-filled array + var processed = {}; + var result = []; + var event; + + for (i = 0, len = resultEvents.length; i < len; i++) { + if (processed[i]) { continue; } + var contour = [[]]; + + if (!resultEvents[i].isExteriorRing) { + if (operation === DIFFERENCE && !resultEvents[i].isSubject && result.length === 0) { + result.push(contour); + } else if (result.length === 0) { + result.push([[contour]]); + } else { + result[result.length - 1].push(contour[0]); + } + } else if (operation === DIFFERENCE && !resultEvents[i].isSubject && result.length > 1) { + result[result.length - 1].push(contour[0]); + } else { + result.push(contour); + } + + var ringId = result.length - 1; + var pos = i; + + var initial = resultEvents[i].point; + contour[0].push(initial); + + while (pos >= i) { + event = resultEvents[pos]; + processed[pos] = true; + + if (event.left) { + event.resultInOut = false; + event.contourId = ringId; + } else { + event.otherEvent.resultInOut = true; + event.otherEvent.contourId = ringId; + } + + pos = event.pos; + processed[pos] = true; + contour[0].push(resultEvents[pos].point); + pos = nextPos(pos, resultEvents, processed, i); + } + + pos = pos === -1 ? i : pos; + + event = resultEvents[pos]; + processed[pos] = processed[event.pos] = true; + event.otherEvent.resultInOut = true; + event.otherEvent.contourId = ringId; + } + + // Handle if the result is a polygon (eg not multipoly) + // Commented it again, let's see what do we mean by that + // if (result.length === 1) result = result[0]; + return result; + } + + var tinyqueue = TinyQueue; + var default_1 = TinyQueue; + + function TinyQueue(data, compare) { + var this$1 = this; + + if (!(this instanceof TinyQueue)) { return new TinyQueue(data, compare); } + + this.data = data || []; + this.length = this.data.length; + this.compare = compare || defaultCompare; + + if (this.length > 0) { + for (var i = (this.length >> 1) - 1; i >= 0; i--) { this$1._down(i); } + } + } + + function defaultCompare(a, b) { + return a < b ? -1 : a > b ? 1 : 0; + } + + TinyQueue.prototype = { + + push: function (item) { + this.data.push(item); + this.length++; + this._up(this.length - 1); + }, + + pop: function () { + if (this.length === 0) { return undefined; } + + var top = this.data[0]; + this.length--; + + if (this.length > 0) { + this.data[0] = this.data[this.length]; + this._down(0); + } + this.data.pop(); + + return top; + }, + + peek: function () { + return this.data[0]; + }, + + _up: function (pos) { + var data = this.data; + var compare = this.compare; + var item = data[pos]; + + while (pos > 0) { + var parent = (pos - 1) >> 1; + var current = data[parent]; + if (compare(item, current) >= 0) { break; } + data[pos] = current; + pos = parent; + } + + data[pos] = item; + }, + + _down: function (pos) { + var this$1 = this; + + var data = this.data; + var compare = this.compare; + var halfLength = this.length >> 1; + var item = data[pos]; + + while (pos < halfLength) { + var left = (pos << 1) + 1; + var right = left + 1; + var best = data[left]; + + if (right < this$1.length && compare(data[right], best) < 0) { + left = right; + best = data[right]; + } + if (compare(best, item) >= 0) { break; } + + data[pos] = best; + pos = left; + } + + data[pos] = item; + } + }; + tinyqueue.default = default_1; + + var max = Math.max; + var min = Math.min; + + var contourId = 0; + + + function processPolygon(contourOrHole, isSubject, depth, Q, bbox, isExteriorRing) { + var i, len, s1, s2, e1, e2; + for (i = 0, len = contourOrHole.length - 1; i < len; i++) { + s1 = contourOrHole[i]; + s2 = contourOrHole[i + 1]; + e1 = new SweepEvent(s1, false, undefined, isSubject); + e2 = new SweepEvent(s2, false, e1, isSubject); + e1.otherEvent = e2; + + if (s1[0] === s2[0] && s1[1] === s2[1]) { + continue; // skip collapsed edges, or it breaks + } + + e1.contourId = e2.contourId = depth; + if (!isExteriorRing) { + e1.isExteriorRing = false; + e2.isExteriorRing = false; + } + if (compareEvents(e1, e2) > 0) { + e2.left = true; + } else { + e1.left = true; + } + + var x = s1[0], y = s1[1]; + bbox[0] = min(bbox[0], x); + bbox[1] = min(bbox[1], y); + bbox[2] = max(bbox[2], x); + bbox[3] = max(bbox[3], y); + + // Pushing it so the queue is sorted from left to right, + // with object on the left having the highest priority. + Q.push(e1); + Q.push(e2); + } + } + + + function fillQueue(subject, clipping, sbbox, cbbox, operation) { + var eventQueue = new tinyqueue(null, compareEvents); + var polygonSet, isExteriorRing, i, ii, j, jj; //, k, kk; + + for (i = 0, ii = subject.length; i < ii; i++) { + polygonSet = subject[i]; + for (j = 0, jj = polygonSet.length; j < jj; j++) { + isExteriorRing = j === 0; + if (isExteriorRing) { contourId++; } + processPolygon(polygonSet[j], true, contourId, eventQueue, sbbox, isExteriorRing); + } + } + + for (i = 0, ii = clipping.length; i < ii; i++) { + polygonSet = clipping[i]; + for (j = 0, jj = polygonSet.length; j < jj; j++) { + isExteriorRing = j === 0; + if (operation === DIFFERENCE) { isExteriorRing = false; } + if (isExteriorRing) { contourId++; } + processPolygon(polygonSet[j], false, contourId, eventQueue, cbbox, isExteriorRing); + } + } + + return eventQueue; + } + + var EMPTY = []; + + + function trivialOperation(subject, clipping, operation) { + var result = null; + if (subject.length * clipping.length === 0) { + if (operation === INTERSECTION) { + result = EMPTY; + } else if (operation === DIFFERENCE) { + result = subject; + } else if (operation === UNION || + operation === XOR) { + result = (subject.length === 0) ? clipping : subject; + } + } + return result; + } + + + function compareBBoxes(subject, clipping, sbbox, cbbox, operation) { + var result = null; + if (sbbox[0] > cbbox[2] || + cbbox[0] > sbbox[2] || + sbbox[1] > cbbox[3] || + cbbox[1] > sbbox[3]) { + if (operation === INTERSECTION) { + result = EMPTY; + } else if (operation === DIFFERENCE) { + result = subject; + } else if (operation === UNION || + operation === XOR) { + result = subject.concat(clipping); + } + } + return result; + } + + + function boolean(subject, clipping, operation) { + if (typeof subject[0][0][0] === 'number') { + subject = [subject]; + } + if (typeof clipping[0][0][0] === 'number') { + clipping = [clipping]; + } + var trivial = trivialOperation(subject, clipping, operation); + if (trivial) { + return trivial === EMPTY ? null : trivial; + } + var sbbox = [Infinity, Infinity, -Infinity, -Infinity]; + var cbbox = [Infinity, Infinity, -Infinity, -Infinity]; + + //console.time('fill queue'); + var eventQueue = fillQueue(subject, clipping, sbbox, cbbox, operation); + //console.timeEnd('fill queue'); + + trivial = compareBBoxes(subject, clipping, sbbox, cbbox, operation); + if (trivial) { + return trivial === EMPTY ? null : trivial; + } + //console.time('subdivide edges'); + var sortedEvents = subdivide(eventQueue, subject, clipping, sbbox, cbbox, operation); + //console.timeEnd('subdivide edges'); + + //console.time('connect vertices'); + var result = connectEdges(sortedEvents, operation); + //console.timeEnd('connect vertices'); + return result; + } + + function union (subject, clipping) { + return boolean(subject, clipping, UNION); + } + + function diff (subject, clipping) { + return boolean(subject, clipping, DIFFERENCE); + } + + function xor (subject, clipping){ + return boolean(subject, clipping, XOR); + } + + function intersection$1 (subject, clipping) { + return boolean(subject, clipping, INTERSECTION); + } + + /** + * @enum {Number} + */ + var operations = { UNION: UNION, DIFFERENCE: DIFFERENCE, INTERSECTION: INTERSECTION, XOR: XOR }; + + exports.union = union; + exports.diff = diff; + exports.xor = xor; + exports.intersection = intersection$1; + exports.operations = operations; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}))); + + +},{}],23:[function(require,module,exports){ +// Top level file is just a mixin of submodules & constants +'use strict'; + +var assign = require('./lib/utils/common').assign; + +var deflate = require('./lib/deflate'); +var inflate = require('./lib/inflate'); +var constants = require('./lib/zlib/constants'); + +var pako = {}; + +assign(pako, deflate, inflate, constants); + +module.exports = pako; + +},{"./lib/deflate":24,"./lib/inflate":25,"./lib/utils/common":26,"./lib/zlib/constants":29}],24:[function(require,module,exports){ +'use strict'; + + +var zlib_deflate = require('./zlib/deflate'); +var utils = require('./utils/common'); +var strings = require('./utils/strings'); +var msg = require('./zlib/messages'); +var ZStream = require('./zlib/zstream'); + +var toString = Object.prototype.toString; + +/* Public constants ==========================================================*/ +/* ===========================================================================*/ + +var Z_NO_FLUSH = 0; +var Z_FINISH = 4; + +var Z_OK = 0; +var Z_STREAM_END = 1; +var Z_SYNC_FLUSH = 2; + +var Z_DEFAULT_COMPRESSION = -1; + +var Z_DEFAULT_STRATEGY = 0; + +var Z_DEFLATED = 8; + +/* ===========================================================================*/ + + +/** + * class Deflate + * + * Generic JS-style wrapper for zlib calls. If you don't need + * streaming behaviour - use more simple functions: [[deflate]], + * [[deflateRaw]] and [[gzip]]. + **/ + +/* internal + * Deflate.chunks -> Array + * + * Chunks of output data, if [[Deflate#onData]] not overridden. + **/ + +/** + * Deflate.result -> Uint8Array|Array + * + * Compressed result, generated by default [[Deflate#onData]] + * and [[Deflate#onEnd]] handlers. Filled after you push last chunk + * (call [[Deflate#push]] with `Z_FINISH` / `true` param) or if you + * push a chunk with explicit flush (call [[Deflate#push]] with + * `Z_SYNC_FLUSH` param). + **/ + +/** + * Deflate.err -> Number + * + * Error code after deflate finished. 0 (Z_OK) on success. + * You will not need it in real life, because deflate errors + * are possible only on wrong options or bad `onData` / `onEnd` + * custom handlers. + **/ + +/** + * Deflate.msg -> String + * + * Error message, if [[Deflate.err]] != 0 + **/ + + +/** + * new Deflate(options) + * - options (Object): zlib deflate options. + * + * Creates new deflator instance with specified params. Throws exception + * on bad params. Supported options: + * + * - `level` + * - `windowBits` + * - `memLevel` + * - `strategy` + * - `dictionary` + * + * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced) + * for more information on these. + * + * Additional options, for internal needs: + * + * - `chunkSize` - size of generated data chunks (16K by default) + * - `raw` (Boolean) - do raw deflate + * - `gzip` (Boolean) - create gzip wrapper + * - `to` (String) - if equal to 'string', then result will be "binary string" + * (each char code [0..255]) + * - `header` (Object) - custom header for gzip + * - `text` (Boolean) - true if compressed data believed to be text + * - `time` (Number) - modification time, unix timestamp + * - `os` (Number) - operation system code + * - `extra` (Array) - array of bytes with extra data (max 65536) + * - `name` (String) - file name (binary string) + * - `comment` (String) - comment (binary string) + * - `hcrc` (Boolean) - true if header crc should be added + * + * ##### Example: + * + * ```javascript + * var pako = require('pako') + * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9]) + * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]); + * + * var deflate = new pako.Deflate({ level: 3}); + * + * deflate.push(chunk1, false); + * deflate.push(chunk2, true); // true -> last chunk + * + * if (deflate.err) { throw new Error(deflate.err); } + * + * console.log(deflate.result); + * ``` + **/ +function Deflate(options) { + if (!(this instanceof Deflate)) return new Deflate(options); + + this.options = utils.assign({ + level: Z_DEFAULT_COMPRESSION, + method: Z_DEFLATED, + chunkSize: 16384, + windowBits: 15, + memLevel: 8, + strategy: Z_DEFAULT_STRATEGY, + to: '' + }, options || {}); + + var opt = this.options; + + if (opt.raw && (opt.windowBits > 0)) { + opt.windowBits = -opt.windowBits; + } + + else if (opt.gzip && (opt.windowBits > 0) && (opt.windowBits < 16)) { + opt.windowBits += 16; + } + + this.err = 0; // error code, if happens (0 = Z_OK) + this.msg = ''; // error message + this.ended = false; // used to avoid multiple onEnd() calls + this.chunks = []; // chunks of compressed data + + this.strm = new ZStream(); + this.strm.avail_out = 0; + + var status = zlib_deflate.deflateInit2( + this.strm, + opt.level, + opt.method, + opt.windowBits, + opt.memLevel, + opt.strategy + ); + + if (status !== Z_OK) { + throw new Error(msg[status]); + } + + if (opt.header) { + zlib_deflate.deflateSetHeader(this.strm, opt.header); + } + + if (opt.dictionary) { + var dict; + // Convert data if needed + if (typeof opt.dictionary === 'string') { + // If we need to compress text, change encoding to utf8. + dict = strings.string2buf(opt.dictionary); + } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') { + dict = new Uint8Array(opt.dictionary); + } else { + dict = opt.dictionary; + } + + status = zlib_deflate.deflateSetDictionary(this.strm, dict); + + if (status !== Z_OK) { + throw new Error(msg[status]); + } + + this._dict_set = true; + } +} + +/** + * Deflate#push(data[, mode]) -> Boolean + * - data (Uint8Array|Array|ArrayBuffer|String): input data. Strings will be + * converted to utf8 byte sequence. + * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes. + * See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH. + * + * Sends input data to deflate pipe, generating [[Deflate#onData]] calls with + * new compressed chunks. Returns `true` on success. The last data block must have + * mode Z_FINISH (or `true`). That will flush internal pending buffers and call + * [[Deflate#onEnd]]. For interim explicit flushes (without ending the stream) you + * can use mode Z_SYNC_FLUSH, keeping the compression context. + * + * On fail call [[Deflate#onEnd]] with error code and return false. + * + * We strongly recommend to use `Uint8Array` on input for best speed (output + * array format is detected automatically). Also, don't skip last param and always + * use the same type in your code (boolean or number). That will improve JS speed. + * + * For regular `Array`-s make sure all elements are [0..255]. + * + * ##### Example + * + * ```javascript + * push(chunk, false); // push one of data chunks + * ... + * push(chunk, true); // push last chunk + * ``` + **/ +Deflate.prototype.push = function (data, mode) { + var strm = this.strm; + var chunkSize = this.options.chunkSize; + var status, _mode; + + if (this.ended) { return false; } + + _mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH : Z_NO_FLUSH); + + // Convert data if needed + if (typeof data === 'string') { + // If we need to compress text, change encoding to utf8. + strm.input = strings.string2buf(data); + } else if (toString.call(data) === '[object ArrayBuffer]') { + strm.input = new Uint8Array(data); + } else { + strm.input = data; + } + + strm.next_in = 0; + strm.avail_in = strm.input.length; + + do { + if (strm.avail_out === 0) { + strm.output = new utils.Buf8(chunkSize); + strm.next_out = 0; + strm.avail_out = chunkSize; + } + status = zlib_deflate.deflate(strm, _mode); /* no bad return value */ + + if (status !== Z_STREAM_END && status !== Z_OK) { + this.onEnd(status); + this.ended = true; + return false; + } + if (strm.avail_out === 0 || (strm.avail_in === 0 && (_mode === Z_FINISH || _mode === Z_SYNC_FLUSH))) { + if (this.options.to === 'string') { + this.onData(strings.buf2binstring(utils.shrinkBuf(strm.output, strm.next_out))); + } else { + this.onData(utils.shrinkBuf(strm.output, strm.next_out)); + } + } + } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END); + + // Finalize on the last chunk. + if (_mode === Z_FINISH) { + status = zlib_deflate.deflateEnd(this.strm); + this.onEnd(status); + this.ended = true; + return status === Z_OK; + } + + // callback interim results if Z_SYNC_FLUSH. + if (_mode === Z_SYNC_FLUSH) { + this.onEnd(Z_OK); + strm.avail_out = 0; + return true; + } + + return true; +}; + + +/** + * Deflate#onData(chunk) -> Void + * - chunk (Uint8Array|Array|String): output data. Type of array depends + * on js engine support. When string output requested, each chunk + * will be string. + * + * By default, stores data blocks in `chunks[]` property and glue + * those in `onEnd`. Override this handler, if you need another behaviour. + **/ +Deflate.prototype.onData = function (chunk) { + this.chunks.push(chunk); +}; + + +/** + * Deflate#onEnd(status) -> Void + * - status (Number): deflate status. 0 (Z_OK) on success, + * other if not. + * + * Called once after you tell deflate that the input stream is + * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH) + * or if an error happened. By default - join collected chunks, + * free memory and fill `results` / `err` properties. + **/ +Deflate.prototype.onEnd = function (status) { + // On success - join + if (status === Z_OK) { + if (this.options.to === 'string') { + this.result = this.chunks.join(''); + } else { + this.result = utils.flattenChunks(this.chunks); + } + } + this.chunks = []; + this.err = status; + this.msg = this.strm.msg; +}; + + +/** + * deflate(data[, options]) -> Uint8Array|Array|String + * - data (Uint8Array|Array|String): input data to compress. + * - options (Object): zlib deflate options. + * + * Compress `data` with deflate algorithm and `options`. + * + * Supported options are: + * + * - level + * - windowBits + * - memLevel + * - strategy + * - dictionary + * + * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced) + * for more information on these. + * + * Sugar (options): + * + * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify + * negative windowBits implicitly. + * - `to` (String) - if equal to 'string', then result will be "binary string" + * (each char code [0..255]) + * + * ##### Example: + * + * ```javascript + * var pako = require('pako') + * , data = Uint8Array([1,2,3,4,5,6,7,8,9]); + * + * console.log(pako.deflate(data)); + * ``` + **/ +function deflate(input, options) { + var deflator = new Deflate(options); + + deflator.push(input, true); + + // That will never happens, if you don't cheat with options :) + if (deflator.err) { throw deflator.msg || msg[deflator.err]; } + + return deflator.result; +} + + +/** + * deflateRaw(data[, options]) -> Uint8Array|Array|String + * - data (Uint8Array|Array|String): input data to compress. + * - options (Object): zlib deflate options. + * + * The same as [[deflate]], but creates raw data, without wrapper + * (header and adler32 crc). + **/ +function deflateRaw(input, options) { + options = options || {}; + options.raw = true; + return deflate(input, options); +} + + +/** + * gzip(data[, options]) -> Uint8Array|Array|String + * - data (Uint8Array|Array|String): input data to compress. + * - options (Object): zlib deflate options. + * + * The same as [[deflate]], but create gzip wrapper instead of + * deflate one. + **/ +function gzip(input, options) { + options = options || {}; + options.gzip = true; + return deflate(input, options); +} + + +exports.Deflate = Deflate; +exports.deflate = deflate; +exports.deflateRaw = deflateRaw; +exports.gzip = gzip; + +},{"./utils/common":26,"./utils/strings":27,"./zlib/deflate":31,"./zlib/messages":36,"./zlib/zstream":38}],25:[function(require,module,exports){ +'use strict'; + + +var zlib_inflate = require('./zlib/inflate'); +var utils = require('./utils/common'); +var strings = require('./utils/strings'); +var c = require('./zlib/constants'); +var msg = require('./zlib/messages'); +var ZStream = require('./zlib/zstream'); +var GZheader = require('./zlib/gzheader'); + +var toString = Object.prototype.toString; + +/** + * class Inflate + * + * Generic JS-style wrapper for zlib calls. If you don't need + * streaming behaviour - use more simple functions: [[inflate]] + * and [[inflateRaw]]. + **/ + +/* internal + * inflate.chunks -> Array + * + * Chunks of output data, if [[Inflate#onData]] not overridden. + **/ + +/** + * Inflate.result -> Uint8Array|Array|String + * + * Uncompressed result, generated by default [[Inflate#onData]] + * and [[Inflate#onEnd]] handlers. Filled after you push last chunk + * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you + * push a chunk with explicit flush (call [[Inflate#push]] with + * `Z_SYNC_FLUSH` param). + **/ + +/** + * Inflate.err -> Number + * + * Error code after inflate finished. 0 (Z_OK) on success. + * Should be checked if broken data possible. + **/ + +/** + * Inflate.msg -> String + * + * Error message, if [[Inflate.err]] != 0 + **/ + + +/** + * new Inflate(options) + * - options (Object): zlib inflate options. + * + * Creates new inflator instance with specified params. Throws exception + * on bad params. Supported options: + * + * - `windowBits` + * - `dictionary` + * + * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced) + * for more information on these. + * + * Additional options, for internal needs: + * + * - `chunkSize` - size of generated data chunks (16K by default) + * - `raw` (Boolean) - do raw inflate + * - `to` (String) - if equal to 'string', then result will be converted + * from utf8 to utf16 (javascript) string. When string output requested, + * chunk length can differ from `chunkSize`, depending on content. + * + * By default, when no options set, autodetect deflate/gzip data format via + * wrapper header. + * + * ##### Example: + * + * ```javascript + * var pako = require('pako') + * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9]) + * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]); + * + * var inflate = new pako.Inflate({ level: 3}); + * + * inflate.push(chunk1, false); + * inflate.push(chunk2, true); // true -> last chunk + * + * if (inflate.err) { throw new Error(inflate.err); } + * + * console.log(inflate.result); + * ``` + **/ +function Inflate(options) { + if (!(this instanceof Inflate)) return new Inflate(options); + + this.options = utils.assign({ + chunkSize: 16384, + windowBits: 0, + to: '' + }, options || {}); + + var opt = this.options; + + // Force window size for `raw` data, if not set directly, + // because we have no header for autodetect. + if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) { + opt.windowBits = -opt.windowBits; + if (opt.windowBits === 0) { opt.windowBits = -15; } + } + + // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate + if ((opt.windowBits >= 0) && (opt.windowBits < 16) && + !(options && options.windowBits)) { + opt.windowBits += 32; + } + + // Gzip header has no info about windows size, we can do autodetect only + // for deflate. So, if window size not set, force it to max when gzip possible + if ((opt.windowBits > 15) && (opt.windowBits < 48)) { + // bit 3 (16) -> gzipped data + // bit 4 (32) -> autodetect gzip/deflate + if ((opt.windowBits & 15) === 0) { + opt.windowBits |= 15; + } + } + + this.err = 0; // error code, if happens (0 = Z_OK) + this.msg = ''; // error message + this.ended = false; // used to avoid multiple onEnd() calls + this.chunks = []; // chunks of compressed data + + this.strm = new ZStream(); + this.strm.avail_out = 0; + + var status = zlib_inflate.inflateInit2( + this.strm, + opt.windowBits + ); + + if (status !== c.Z_OK) { + throw new Error(msg[status]); + } + + this.header = new GZheader(); + + zlib_inflate.inflateGetHeader(this.strm, this.header); + + // Setup dictionary + if (opt.dictionary) { + // Convert data if needed + if (typeof opt.dictionary === 'string') { + opt.dictionary = strings.string2buf(opt.dictionary); + } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') { + opt.dictionary = new Uint8Array(opt.dictionary); + } + if (opt.raw) { //In raw mode we need to set the dictionary early + status = zlib_inflate.inflateSetDictionary(this.strm, opt.dictionary); + if (status !== c.Z_OK) { + throw new Error(msg[status]); + } + } + } +} + +/** + * Inflate#push(data[, mode]) -> Boolean + * - data (Uint8Array|Array|ArrayBuffer|String): input data + * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes. + * See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH. + * + * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with + * new output chunks. Returns `true` on success. The last data block must have + * mode Z_FINISH (or `true`). That will flush internal pending buffers and call + * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you + * can use mode Z_SYNC_FLUSH, keeping the decompression context. + * + * On fail call [[Inflate#onEnd]] with error code and return false. + * + * We strongly recommend to use `Uint8Array` on input for best speed (output + * format is detected automatically). Also, don't skip last param and always + * use the same type in your code (boolean or number). That will improve JS speed. + * + * For regular `Array`-s make sure all elements are [0..255]. + * + * ##### Example + * + * ```javascript + * push(chunk, false); // push one of data chunks + * ... + * push(chunk, true); // push last chunk + * ``` + **/ +Inflate.prototype.push = function (data, mode) { + var strm = this.strm; + var chunkSize = this.options.chunkSize; + var dictionary = this.options.dictionary; + var status, _mode; + var next_out_utf8, tail, utf8str; + + // Flag to properly process Z_BUF_ERROR on testing inflate call + // when we check that all output data was flushed. + var allowBufError = false; + + if (this.ended) { return false; } + _mode = (mode === ~~mode) ? mode : ((mode === true) ? c.Z_FINISH : c.Z_NO_FLUSH); + + // Convert data if needed + if (typeof data === 'string') { + // Only binary strings can be decompressed on practice + strm.input = strings.binstring2buf(data); + } else if (toString.call(data) === '[object ArrayBuffer]') { + strm.input = new Uint8Array(data); + } else { + strm.input = data; + } + + strm.next_in = 0; + strm.avail_in = strm.input.length; + + do { + if (strm.avail_out === 0) { + strm.output = new utils.Buf8(chunkSize); + strm.next_out = 0; + strm.avail_out = chunkSize; + } + + status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH); /* no bad return value */ + + if (status === c.Z_NEED_DICT && dictionary) { + status = zlib_inflate.inflateSetDictionary(this.strm, dictionary); + } + + if (status === c.Z_BUF_ERROR && allowBufError === true) { + status = c.Z_OK; + allowBufError = false; + } + + if (status !== c.Z_STREAM_END && status !== c.Z_OK) { + this.onEnd(status); + this.ended = true; + return false; + } + + if (strm.next_out) { + if (strm.avail_out === 0 || status === c.Z_STREAM_END || (strm.avail_in === 0 && (_mode === c.Z_FINISH || _mode === c.Z_SYNC_FLUSH))) { + + if (this.options.to === 'string') { + + next_out_utf8 = strings.utf8border(strm.output, strm.next_out); + + tail = strm.next_out - next_out_utf8; + utf8str = strings.buf2string(strm.output, next_out_utf8); + + // move tail + strm.next_out = tail; + strm.avail_out = chunkSize - tail; + if (tail) { utils.arraySet(strm.output, strm.output, next_out_utf8, tail, 0); } + + this.onData(utf8str); + + } else { + this.onData(utils.shrinkBuf(strm.output, strm.next_out)); + } + } + } + + // When no more input data, we should check that internal inflate buffers + // are flushed. The only way to do it when avail_out = 0 - run one more + // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR. + // Here we set flag to process this error properly. + // + // NOTE. Deflate does not return error in this case and does not needs such + // logic. + if (strm.avail_in === 0 && strm.avail_out === 0) { + allowBufError = true; + } + + } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c.Z_STREAM_END); + + if (status === c.Z_STREAM_END) { + _mode = c.Z_FINISH; + } + + // Finalize on the last chunk. + if (_mode === c.Z_FINISH) { + status = zlib_inflate.inflateEnd(this.strm); + this.onEnd(status); + this.ended = true; + return status === c.Z_OK; + } + + // callback interim results if Z_SYNC_FLUSH. + if (_mode === c.Z_SYNC_FLUSH) { + this.onEnd(c.Z_OK); + strm.avail_out = 0; + return true; + } + + return true; +}; + + +/** + * Inflate#onData(chunk) -> Void + * - chunk (Uint8Array|Array|String): output data. Type of array depends + * on js engine support. When string output requested, each chunk + * will be string. + * + * By default, stores data blocks in `chunks[]` property and glue + * those in `onEnd`. Override this handler, if you need another behaviour. + **/ +Inflate.prototype.onData = function (chunk) { + this.chunks.push(chunk); +}; + + +/** + * Inflate#onEnd(status) -> Void + * - status (Number): inflate status. 0 (Z_OK) on success, + * other if not. + * + * Called either after you tell inflate that the input stream is + * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH) + * or if an error happened. By default - join collected chunks, + * free memory and fill `results` / `err` properties. + **/ +Inflate.prototype.onEnd = function (status) { + // On success - join + if (status === c.Z_OK) { + if (this.options.to === 'string') { + // Glue & convert here, until we teach pako to send + // utf8 aligned strings to onData + this.result = this.chunks.join(''); + } else { + this.result = utils.flattenChunks(this.chunks); + } + } + this.chunks = []; + this.err = status; + this.msg = this.strm.msg; +}; + + +/** + * inflate(data[, options]) -> Uint8Array|Array|String + * - data (Uint8Array|Array|String): input data to decompress. + * - options (Object): zlib inflate options. + * + * Decompress `data` with inflate/ungzip and `options`. Autodetect + * format via wrapper header by default. That's why we don't provide + * separate `ungzip` method. + * + * Supported options are: + * + * - windowBits + * + * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced) + * for more information. + * + * Sugar (options): + * + * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify + * negative windowBits implicitly. + * - `to` (String) - if equal to 'string', then result will be converted + * from utf8 to utf16 (javascript) string. When string output requested, + * chunk length can differ from `chunkSize`, depending on content. + * + * + * ##### Example: + * + * ```javascript + * var pako = require('pako') + * , input = pako.deflate([1,2,3,4,5,6,7,8,9]) + * , output; + * + * try { + * output = pako.inflate(input); + * } catch (err) + * console.log(err); + * } + * ``` + **/ +function inflate(input, options) { + var inflator = new Inflate(options); + + inflator.push(input, true); + + // That will never happens, if you don't cheat with options :) + if (inflator.err) { throw inflator.msg || msg[inflator.err]; } + + return inflator.result; +} + + +/** + * inflateRaw(data[, options]) -> Uint8Array|Array|String + * - data (Uint8Array|Array|String): input data to decompress. + * - options (Object): zlib inflate options. + * + * The same as [[inflate]], but creates raw data, without wrapper + * (header and adler32 crc). + **/ +function inflateRaw(input, options) { + options = options || {}; + options.raw = true; + return inflate(input, options); +} + + +/** + * ungzip(data[, options]) -> Uint8Array|Array|String + * - data (Uint8Array|Array|String): input data to decompress. + * - options (Object): zlib inflate options. + * + * Just shortcut to [[inflate]], because it autodetects format + * by header.content. Done for convenience. + **/ + + +exports.Inflate = Inflate; +exports.inflate = inflate; +exports.inflateRaw = inflateRaw; +exports.ungzip = inflate; + +},{"./utils/common":26,"./utils/strings":27,"./zlib/constants":29,"./zlib/gzheader":32,"./zlib/inflate":34,"./zlib/messages":36,"./zlib/zstream":38}],26:[function(require,module,exports){ +'use strict'; + + +var TYPED_OK = (typeof Uint8Array !== 'undefined') && + (typeof Uint16Array !== 'undefined') && + (typeof Int32Array !== 'undefined'); + +function _has(obj, key) { + return Object.prototype.hasOwnProperty.call(obj, key); +} + +exports.assign = function (obj /*from1, from2, from3, ...*/) { + var sources = Array.prototype.slice.call(arguments, 1); + while (sources.length) { + var source = sources.shift(); + if (!source) { continue; } + + if (typeof source !== 'object') { + throw new TypeError(source + 'must be non-object'); + } + + for (var p in source) { + if (_has(source, p)) { + obj[p] = source[p]; + } + } + } + + return obj; +}; + + +// reduce buffer size, avoiding mem copy +exports.shrinkBuf = function (buf, size) { + if (buf.length === size) { return buf; } + if (buf.subarray) { return buf.subarray(0, size); } + buf.length = size; + return buf; +}; + + +var fnTyped = { + arraySet: function (dest, src, src_offs, len, dest_offs) { + if (src.subarray && dest.subarray) { + dest.set(src.subarray(src_offs, src_offs + len), dest_offs); + return; + } + // Fallback to ordinary array + for (var i = 0; i < len; i++) { + dest[dest_offs + i] = src[src_offs + i]; + } + }, + // Join array of chunks to single array. + flattenChunks: function (chunks) { + var i, l, len, pos, chunk, result; + + // calculate data length + len = 0; + for (i = 0, l = chunks.length; i < l; i++) { + len += chunks[i].length; + } + + // join chunks + result = new Uint8Array(len); + pos = 0; + for (i = 0, l = chunks.length; i < l; i++) { + chunk = chunks[i]; + result.set(chunk, pos); + pos += chunk.length; + } + + return result; + } +}; + +var fnUntyped = { + arraySet: function (dest, src, src_offs, len, dest_offs) { + for (var i = 0; i < len; i++) { + dest[dest_offs + i] = src[src_offs + i]; + } + }, + // Join array of chunks to single array. + flattenChunks: function (chunks) { + return [].concat.apply([], chunks); + } +}; + + +// Enable/Disable typed arrays use, for testing +// +exports.setTyped = function (on) { + if (on) { + exports.Buf8 = Uint8Array; + exports.Buf16 = Uint16Array; + exports.Buf32 = Int32Array; + exports.assign(exports, fnTyped); + } else { + exports.Buf8 = Array; + exports.Buf16 = Array; + exports.Buf32 = Array; + exports.assign(exports, fnUntyped); + } +}; + +exports.setTyped(TYPED_OK); + +},{}],27:[function(require,module,exports){ +// String encode/decode helpers +'use strict'; + + +var utils = require('./common'); + + +// Quick check if we can use fast array to bin string conversion +// +// - apply(Array) can fail on Android 2.2 +// - apply(Uint8Array) can fail on iOS 5.1 Safari +// +var STR_APPLY_OK = true; +var STR_APPLY_UIA_OK = true; + +try { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; } +try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; } + + +// Table with utf8 lengths (calculated by first byte of sequence) +// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS, +// because max possible codepoint is 0x10ffff +var _utf8len = new utils.Buf8(256); +for (var q = 0; q < 256; q++) { + _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1); +} +_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start + + +// convert string to array (typed, when possible) +exports.string2buf = function (str) { + var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0; + + // count binary size + for (m_pos = 0; m_pos < str_len; m_pos++) { + c = str.charCodeAt(m_pos); + if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) { + c2 = str.charCodeAt(m_pos + 1); + if ((c2 & 0xfc00) === 0xdc00) { + c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00); + m_pos++; + } + } + buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4; + } + + // allocate buffer + buf = new utils.Buf8(buf_len); + + // convert + for (i = 0, m_pos = 0; i < buf_len; m_pos++) { + c = str.charCodeAt(m_pos); + if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) { + c2 = str.charCodeAt(m_pos + 1); + if ((c2 & 0xfc00) === 0xdc00) { + c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00); + m_pos++; + } + } + if (c < 0x80) { + /* one byte */ + buf[i++] = c; + } else if (c < 0x800) { + /* two bytes */ + buf[i++] = 0xC0 | (c >>> 6); + buf[i++] = 0x80 | (c & 0x3f); + } else if (c < 0x10000) { + /* three bytes */ + buf[i++] = 0xE0 | (c >>> 12); + buf[i++] = 0x80 | (c >>> 6 & 0x3f); + buf[i++] = 0x80 | (c & 0x3f); + } else { + /* four bytes */ + buf[i++] = 0xf0 | (c >>> 18); + buf[i++] = 0x80 | (c >>> 12 & 0x3f); + buf[i++] = 0x80 | (c >>> 6 & 0x3f); + buf[i++] = 0x80 | (c & 0x3f); + } + } + + return buf; +}; + +// Helper (used in 2 places) +function buf2binstring(buf, len) { + // On Chrome, the arguments in a function call that are allowed is `65534`. + // If the length of the buffer is smaller than that, we can use this optimization, + // otherwise we will take a slower path. + if (len < 65534) { + if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) { + return String.fromCharCode.apply(null, utils.shrinkBuf(buf, len)); + } + } + + var result = ''; + for (var i = 0; i < len; i++) { + result += String.fromCharCode(buf[i]); + } + return result; +} + + +// Convert byte array to binary string +exports.buf2binstring = function (buf) { + return buf2binstring(buf, buf.length); +}; + + +// Convert binary string (typed, when possible) +exports.binstring2buf = function (str) { + var buf = new utils.Buf8(str.length); + for (var i = 0, len = buf.length; i < len; i++) { + buf[i] = str.charCodeAt(i); + } + return buf; +}; + + +// convert array to string +exports.buf2string = function (buf, max) { + var i, out, c, c_len; + var len = max || buf.length; + + // Reserve max possible length (2 words per char) + // NB: by unknown reasons, Array is significantly faster for + // String.fromCharCode.apply than Uint16Array. + var utf16buf = new Array(len * 2); + + for (out = 0, i = 0; i < len;) { + c = buf[i++]; + // quick process ascii + if (c < 0x80) { utf16buf[out++] = c; continue; } + + c_len = _utf8len[c]; + // skip 5 & 6 byte codes + if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; } + + // apply mask on first byte + c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07; + // join the rest + while (c_len > 1 && i < len) { + c = (c << 6) | (buf[i++] & 0x3f); + c_len--; + } + + // terminated by end of string? + if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; } + + if (c < 0x10000) { + utf16buf[out++] = c; + } else { + c -= 0x10000; + utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff); + utf16buf[out++] = 0xdc00 | (c & 0x3ff); + } + } + + return buf2binstring(utf16buf, out); +}; + + +// Calculate max possible position in utf8 buffer, +// that will not break sequence. If that's not possible +// - (very small limits) return max size as is. +// +// buf[] - utf8 bytes array +// max - length limit (mandatory); +exports.utf8border = function (buf, max) { + var pos; + + max = max || buf.length; + if (max > buf.length) { max = buf.length; } + + // go back from last position, until start of sequence found + pos = max - 1; + while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; } + + // Very small and broken sequence, + // return max, because we should return something anyway. + if (pos < 0) { return max; } + + // If we came to start of buffer - that means buffer is too small, + // return max too. + if (pos === 0) { return max; } + + return (pos + _utf8len[buf[pos]] > max) ? pos : max; +}; + +},{"./common":26}],28:[function(require,module,exports){ +'use strict'; + +// Note: adler32 takes 12% for level 0 and 2% for level 6. +// It isn't worth it to make additional optimizations as in original. +// Small size is preferable. + +// (C) 1995-2013 Jean-loup Gailly and Mark Adler +// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would be +// appreciated but is not required. +// 2. Altered source versions must be plainly marked as such, and must not be +// misrepresented as being the original software. +// 3. This notice may not be removed or altered from any source distribution. + +function adler32(adler, buf, len, pos) { + var s1 = (adler & 0xffff) |0, + s2 = ((adler >>> 16) & 0xffff) |0, + n = 0; + + while (len !== 0) { + // Set limit ~ twice less than 5552, to keep + // s2 in 31-bits, because we force signed ints. + // in other case %= will fail. + n = len > 2000 ? 2000 : len; + len -= n; + + do { + s1 = (s1 + buf[pos++]) |0; + s2 = (s2 + s1) |0; + } while (--n); + + s1 %= 65521; + s2 %= 65521; + } + + return (s1 | (s2 << 16)) |0; +} + + +module.exports = adler32; + +},{}],29:[function(require,module,exports){ +'use strict'; + +// (C) 1995-2013 Jean-loup Gailly and Mark Adler +// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would be +// appreciated but is not required. +// 2. Altered source versions must be plainly marked as such, and must not be +// misrepresented as being the original software. +// 3. This notice may not be removed or altered from any source distribution. + +module.exports = { + + /* Allowed flush values; see deflate() and inflate() below for details */ + 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, + + /* Return codes for the compression/decompression functions. Negative values + * are errors, positive values are used for special but normal events. + */ + Z_OK: 0, + Z_STREAM_END: 1, + Z_NEED_DICT: 2, + Z_ERRNO: -1, + Z_STREAM_ERROR: -2, + Z_DATA_ERROR: -3, + //Z_MEM_ERROR: -4, + Z_BUF_ERROR: -5, + //Z_VERSION_ERROR: -6, + + /* compression levels */ + 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, + + /* Possible values of the data_type field (though see inflate()) */ + Z_BINARY: 0, + Z_TEXT: 1, + //Z_ASCII: 1, // = Z_TEXT (deprecated) + Z_UNKNOWN: 2, + + /* The deflate compression method */ + Z_DEFLATED: 8 + //Z_NULL: null // Use -1 or null inline, depending on var type +}; + +},{}],30:[function(require,module,exports){ +'use strict'; + +// Note: we can't get significant speed boost here. +// So write code to minimize size - no pregenerated tables +// and array tools dependencies. + +// (C) 1995-2013 Jean-loup Gailly and Mark Adler +// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would be +// appreciated but is not required. +// 2. Altered source versions must be plainly marked as such, and must not be +// misrepresented as being the original software. +// 3. This notice may not be removed or altered from any source distribution. + +// Use ordinary array, since untyped makes no boost here +function makeTable() { + var c, table = []; + + for (var n = 0; n < 256; n++) { + c = n; + for (var k = 0; k < 8; k++) { + c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1)); + } + table[n] = c; + } + + return table; +} + +// Create table on load. Just 255 signed longs. Not a problem. +var crcTable = makeTable(); + + +function crc32(crc, buf, len, pos) { + var t = crcTable, + end = pos + len; + + crc ^= -1; + + for (var i = pos; i < end; i++) { + crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF]; + } + + return (crc ^ (-1)); // >>> 0; +} + + +module.exports = crc32; + +},{}],31:[function(require,module,exports){ +'use strict'; + +// (C) 1995-2013 Jean-loup Gailly and Mark Adler +// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would be +// appreciated but is not required. +// 2. Altered source versions must be plainly marked as such, and must not be +// misrepresented as being the original software. +// 3. This notice may not be removed or altered from any source distribution. + +var utils = require('../utils/common'); +var trees = require('./trees'); +var adler32 = require('./adler32'); +var crc32 = require('./crc32'); +var msg = require('./messages'); + +/* Public constants ==========================================================*/ +/* ===========================================================================*/ + + +/* Allowed flush values; see deflate() and inflate() below for details */ +var Z_NO_FLUSH = 0; +var Z_PARTIAL_FLUSH = 1; +//var Z_SYNC_FLUSH = 2; +var Z_FULL_FLUSH = 3; +var Z_FINISH = 4; +var Z_BLOCK = 5; +//var Z_TREES = 6; + + +/* Return codes for the compression/decompression functions. Negative values + * are errors, positive values are used for special but normal events. + */ +var Z_OK = 0; +var Z_STREAM_END = 1; +//var Z_NEED_DICT = 2; +//var Z_ERRNO = -1; +var Z_STREAM_ERROR = -2; +var Z_DATA_ERROR = -3; +//var Z_MEM_ERROR = -4; +var Z_BUF_ERROR = -5; +//var Z_VERSION_ERROR = -6; + + +/* compression levels */ +//var Z_NO_COMPRESSION = 0; +//var Z_BEST_SPEED = 1; +//var Z_BEST_COMPRESSION = 9; +var Z_DEFAULT_COMPRESSION = -1; + + +var Z_FILTERED = 1; +var Z_HUFFMAN_ONLY = 2; +var Z_RLE = 3; +var Z_FIXED = 4; +var Z_DEFAULT_STRATEGY = 0; + +/* Possible values of the data_type field (though see inflate()) */ +//var Z_BINARY = 0; +//var Z_TEXT = 1; +//var Z_ASCII = 1; // = Z_TEXT +var Z_UNKNOWN = 2; + + +/* The deflate compression method */ +var Z_DEFLATED = 8; + +/*============================================================================*/ + + +var MAX_MEM_LEVEL = 9; +/* Maximum value for memLevel in deflateInit2 */ +var MAX_WBITS = 15; +/* 32K LZ77 window */ +var DEF_MEM_LEVEL = 8; + + +var LENGTH_CODES = 29; +/* number of length codes, not counting the special END_BLOCK code */ +var LITERALS = 256; +/* number of literal bytes 0..255 */ +var L_CODES = LITERALS + 1 + LENGTH_CODES; +/* number of Literal or Length codes, including the END_BLOCK code */ +var D_CODES = 30; +/* number of distance codes */ +var BL_CODES = 19; +/* number of codes used to transfer the bit lengths */ +var HEAP_SIZE = 2 * L_CODES + 1; +/* maximum heap size */ +var MAX_BITS = 15; +/* All codes must not exceed MAX_BITS bits */ + +var MIN_MATCH = 3; +var MAX_MATCH = 258; +var MIN_LOOKAHEAD = (MAX_MATCH + MIN_MATCH + 1); + +var PRESET_DICT = 0x20; + +var INIT_STATE = 42; +var EXTRA_STATE = 69; +var NAME_STATE = 73; +var COMMENT_STATE = 91; +var HCRC_STATE = 103; +var BUSY_STATE = 113; +var FINISH_STATE = 666; + +var BS_NEED_MORE = 1; /* block not completed, need more input or more output */ +var BS_BLOCK_DONE = 2; /* block flush performed */ +var BS_FINISH_STARTED = 3; /* finish started, need only more output at next deflate */ +var BS_FINISH_DONE = 4; /* finish done, accept no more input or output */ + +var OS_CODE = 0x03; // Unix :) . Don't detect, use this default. + +function err(strm, errorCode) { + strm.msg = msg[errorCode]; + return errorCode; +} + +function rank(f) { + return ((f) << 1) - ((f) > 4 ? 9 : 0); +} + +function zero(buf) { var len = buf.length; while (--len >= 0) { buf[len] = 0; } } + + +/* ========================================================================= + * Flush as much pending output as possible. All deflate() output goes + * through this function so some applications may wish to modify it + * to avoid allocating a large strm->output buffer and copying into it. + * (See also read_buf()). + */ +function flush_pending(strm) { + var s = strm.state; + + //_tr_flush_bits(s); + var len = s.pending; + if (len > strm.avail_out) { + len = strm.avail_out; + } + if (len === 0) { return; } + + utils.arraySet(strm.output, s.pending_buf, s.pending_out, len, strm.next_out); + strm.next_out += len; + s.pending_out += len; + strm.total_out += len; + strm.avail_out -= len; + s.pending -= len; + if (s.pending === 0) { + s.pending_out = 0; + } +} + + +function flush_block_only(s, last) { + trees._tr_flush_block(s, (s.block_start >= 0 ? s.block_start : -1), s.strstart - s.block_start, last); + s.block_start = s.strstart; + flush_pending(s.strm); +} + + +function put_byte(s, b) { + s.pending_buf[s.pending++] = b; +} + + +/* ========================================================================= + * Put a short in the pending buffer. The 16-bit value is put in MSB order. + * IN assertion: the stream state is correct and there is enough room in + * pending_buf. + */ +function putShortMSB(s, b) { +// put_byte(s, (Byte)(b >> 8)); +// put_byte(s, (Byte)(b & 0xff)); + s.pending_buf[s.pending++] = (b >>> 8) & 0xff; + s.pending_buf[s.pending++] = b & 0xff; +} + + +/* =========================================================================== + * Read a new buffer from the current input stream, update the adler32 + * and total number of bytes read. All deflate() input goes through + * this function so some applications may wish to modify it to avoid + * allocating a large strm->input buffer and copying from it. + * (See also flush_pending()). + */ +function read_buf(strm, buf, start, size) { + var len = strm.avail_in; + + if (len > size) { len = size; } + if (len === 0) { return 0; } + + strm.avail_in -= len; + + // zmemcpy(buf, strm->next_in, len); + utils.arraySet(buf, strm.input, strm.next_in, len, start); + if (strm.state.wrap === 1) { + strm.adler = adler32(strm.adler, buf, len, start); + } + + else if (strm.state.wrap === 2) { + strm.adler = crc32(strm.adler, buf, len, start); + } + + strm.next_in += len; + strm.total_in += len; + + return len; +} + + +/* =========================================================================== + * Set match_start to the longest match starting at the given string and + * return its length. Matches shorter or equal to prev_length are discarded, + * in which case the result is equal to prev_length and match_start is + * garbage. + * IN assertions: cur_match is the head of the hash chain for the current + * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 + * OUT assertion: the match length is not greater than s->lookahead. + */ +function longest_match(s, cur_match) { + var chain_length = s.max_chain_length; /* max hash chain length */ + var scan = s.strstart; /* current string */ + var match; /* matched string */ + var len; /* length of current match */ + var best_len = s.prev_length; /* best match length so far */ + var nice_match = s.nice_match; /* stop if match long enough */ + var limit = (s.strstart > (s.w_size - MIN_LOOKAHEAD)) ? + s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0/*NIL*/; + + var _win = s.window; // shortcut + + var wmask = s.w_mask; + var prev = s.prev; + + /* Stop when cur_match becomes <= limit. To simplify the code, + * we prevent matches with the string of window index 0. + */ + + var strend = s.strstart + MAX_MATCH; + var scan_end1 = _win[scan + best_len - 1]; + var scan_end = _win[scan + best_len]; + + /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. + * It is easy to get rid of this optimization if necessary. + */ + // Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); + + /* Do not waste too much time if we already have a good match: */ + if (s.prev_length >= s.good_match) { + chain_length >>= 2; + } + /* Do not look for matches beyond the end of the input. This is necessary + * to make deflate deterministic. + */ + if (nice_match > s.lookahead) { nice_match = s.lookahead; } + + // Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); + + do { + // Assert(cur_match < s->strstart, "no future"); + match = cur_match; + + /* Skip to next match if the match length cannot increase + * or if the match length is less than 2. Note that the checks below + * for insufficient lookahead only occur occasionally for performance + * reasons. Therefore uninitialized memory will be accessed, and + * conditional jumps will be made that depend on those values. + * However the length of the match is limited to the lookahead, so + * the output of deflate is not affected by the uninitialized values. + */ + + if (_win[match + best_len] !== scan_end || + _win[match + best_len - 1] !== scan_end1 || + _win[match] !== _win[scan] || + _win[++match] !== _win[scan + 1]) { + continue; + } + + /* The check at best_len-1 can be removed because it will be made + * again later. (This heuristic is not always a win.) + * It is not necessary to compare scan[2] and match[2] since they + * are always equal when the other bytes match, given that + * the hash keys are equal and that HASH_BITS >= 8. + */ + scan += 2; + match++; + // Assert(*scan == *match, "match[2]?"); + + /* We check for insufficient lookahead only every 8th comparison; + * the 256th check will be made at strstart+258. + */ + do { + /*jshint noempty:false*/ + } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] && + _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && + _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && + _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && + scan < strend); + + // Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + + len = MAX_MATCH - (strend - scan); + scan = strend - MAX_MATCH; + + if (len > best_len) { + s.match_start = cur_match; + best_len = len; + if (len >= nice_match) { + break; + } + scan_end1 = _win[scan + best_len - 1]; + scan_end = _win[scan + best_len]; + } + } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0); + + if (best_len <= s.lookahead) { + return best_len; + } + return s.lookahead; +} + + +/* =========================================================================== + * Fill the window when the lookahead becomes insufficient. + * Updates strstart and lookahead. + * + * IN assertion: lookahead < MIN_LOOKAHEAD + * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD + * At least one byte has been read, or avail_in == 0; reads are + * performed for at least two bytes (required for the zip translate_eol + * option -- not supported here). + */ +function fill_window(s) { + var _w_size = s.w_size; + var p, n, m, more, str; + + //Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); + + do { + more = s.window_size - s.lookahead - s.strstart; + + // JS ints have 32 bit, block below not needed + /* Deal with !@#$% 64K limit: */ + //if (sizeof(int) <= 2) { + // if (more == 0 && s->strstart == 0 && s->lookahead == 0) { + // more = wsize; + // + // } else if (more == (unsigned)(-1)) { + // /* Very unlikely, but possible on 16 bit machine if + // * strstart == 0 && lookahead == 1 (input done a byte at time) + // */ + // more--; + // } + //} + + + /* If the window is almost full and there is insufficient lookahead, + * move the upper half to the lower one to make room in the upper half. + */ + if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) { + + utils.arraySet(s.window, s.window, _w_size, _w_size, 0); + s.match_start -= _w_size; + s.strstart -= _w_size; + /* we now have strstart >= MAX_DIST */ + s.block_start -= _w_size; + + /* Slide the hash table (could be avoided with 32 bit values + at the expense of memory usage). We slide even when level == 0 + to keep the hash table consistent if we switch back to level > 0 + later. (Using level 0 permanently is not an optimal usage of + zlib, so we don't care about this pathological case.) + */ + + n = s.hash_size; + p = n; + do { + m = s.head[--p]; + s.head[p] = (m >= _w_size ? m - _w_size : 0); + } while (--n); + + n = _w_size; + p = n; + do { + m = s.prev[--p]; + s.prev[p] = (m >= _w_size ? m - _w_size : 0); + /* If n is not on any hash chain, prev[n] is garbage but + * its value will never be used. + */ + } while (--n); + + more += _w_size; + } + if (s.strm.avail_in === 0) { + break; + } + + /* If there was no sliding: + * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && + * more == window_size - lookahead - strstart + * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) + * => more >= window_size - 2*WSIZE + 2 + * In the BIG_MEM or MMAP case (not yet supported), + * window_size == input_size + MIN_LOOKAHEAD && + * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. + * Otherwise, window_size == 2*WSIZE so more >= 2. + * If there was sliding, more >= WSIZE. So in all cases, more >= 2. + */ + //Assert(more >= 2, "more < 2"); + n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more); + s.lookahead += n; + + /* Initialize the hash value now that we have some input: */ + if (s.lookahead + s.insert >= MIN_MATCH) { + str = s.strstart - s.insert; + s.ins_h = s.window[str]; + + /* UPDATE_HASH(s, s->ins_h, s->window[str + 1]); */ + s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + 1]) & s.hash_mask; +//#if MIN_MATCH != 3 +// Call update_hash() MIN_MATCH-3 more times +//#endif + while (s.insert) { + /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */ + s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask; + + s.prev[str & s.w_mask] = s.head[s.ins_h]; + s.head[s.ins_h] = str; + str++; + s.insert--; + if (s.lookahead + s.insert < MIN_MATCH) { + break; + } + } + } + /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, + * but this is not important since only literal bytes will be emitted. + */ + + } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0); + + /* If the WIN_INIT bytes after the end of the current data have never been + * written, then zero those bytes in order to avoid memory check reports of + * the use of uninitialized (or uninitialised as Julian writes) bytes by + * the longest match routines. Update the high water mark for the next + * time through here. WIN_INIT is set to MAX_MATCH since the longest match + * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. + */ +// if (s.high_water < s.window_size) { +// var curr = s.strstart + s.lookahead; +// var init = 0; +// +// if (s.high_water < curr) { +// /* Previous high water mark below current data -- zero WIN_INIT +// * bytes or up to end of window, whichever is less. +// */ +// init = s.window_size - curr; +// if (init > WIN_INIT) +// init = WIN_INIT; +// zmemzero(s->window + curr, (unsigned)init); +// s->high_water = curr + init; +// } +// else if (s->high_water < (ulg)curr + WIN_INIT) { +// /* High water mark at or above current data, but below current data +// * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up +// * to end of window, whichever is less. +// */ +// init = (ulg)curr + WIN_INIT - s->high_water; +// if (init > s->window_size - s->high_water) +// init = s->window_size - s->high_water; +// zmemzero(s->window + s->high_water, (unsigned)init); +// s->high_water += init; +// } +// } +// +// Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, +// "not enough room for search"); +} + +/* =========================================================================== + * Copy without compression as much as possible from the input stream, return + * the current block state. + * This function does not insert new strings in the dictionary since + * uncompressible data is probably not useful. This function is used + * only for the level=0 compression option. + * NOTE: this function should be optimized to avoid extra copying from + * window to pending_buf. + */ +function deflate_stored(s, flush) { + /* Stored blocks are limited to 0xffff bytes, pending_buf is limited + * to pending_buf_size, and each stored block has a 5 byte header: + */ + var max_block_size = 0xffff; + + if (max_block_size > s.pending_buf_size - 5) { + max_block_size = s.pending_buf_size - 5; + } + + /* Copy as much as possible from input to output: */ + for (;;) { + /* Fill the window as much as possible: */ + if (s.lookahead <= 1) { + + //Assert(s->strstart < s->w_size+MAX_DIST(s) || + // s->block_start >= (long)s->w_size, "slide too late"); +// if (!(s.strstart < s.w_size + (s.w_size - MIN_LOOKAHEAD) || +// s.block_start >= s.w_size)) { +// throw new Error("slide too late"); +// } + + fill_window(s); + if (s.lookahead === 0 && flush === Z_NO_FLUSH) { + return BS_NEED_MORE; + } + + if (s.lookahead === 0) { + break; + } + /* flush the current block */ + } + //Assert(s->block_start >= 0L, "block gone"); +// if (s.block_start < 0) throw new Error("block gone"); + + s.strstart += s.lookahead; + s.lookahead = 0; + + /* Emit a stored block if pending_buf will be full: */ + var max_start = s.block_start + max_block_size; + + if (s.strstart === 0 || s.strstart >= max_start) { + /* strstart == 0 is possible when wraparound on 16-bit machine */ + s.lookahead = s.strstart - max_start; + s.strstart = max_start; + /*** FLUSH_BLOCK(s, 0); ***/ + flush_block_only(s, false); + if (s.strm.avail_out === 0) { + return BS_NEED_MORE; + } + /***/ + + + } + /* Flush if we may have to slide, otherwise block_start may become + * negative and the data will be gone: + */ + if (s.strstart - s.block_start >= (s.w_size - MIN_LOOKAHEAD)) { + /*** FLUSH_BLOCK(s, 0); ***/ + flush_block_only(s, false); + if (s.strm.avail_out === 0) { + return BS_NEED_MORE; + } + /***/ + } + } + + s.insert = 0; + + if (flush === Z_FINISH) { + /*** FLUSH_BLOCK(s, 1); ***/ + flush_block_only(s, true); + if (s.strm.avail_out === 0) { + return BS_FINISH_STARTED; + } + /***/ + return BS_FINISH_DONE; + } + + if (s.strstart > s.block_start) { + /*** FLUSH_BLOCK(s, 0); ***/ + flush_block_only(s, false); + if (s.strm.avail_out === 0) { + return BS_NEED_MORE; + } + /***/ + } + + return BS_NEED_MORE; +} + +/* =========================================================================== + * Compress as much as possible from the input stream, return the current + * block state. + * This function does not perform lazy evaluation of matches and inserts + * new strings in the dictionary only for unmatched strings or for short + * matches. It is used only for the fast compression options. + */ +function deflate_fast(s, flush) { + var hash_head; /* head of the hash chain */ + var bflush; /* set if current block must be flushed */ + + for (;;) { + /* Make sure that we always have enough lookahead, except + * at the end of the input file. We need MAX_MATCH bytes + * for the next match, plus MIN_MATCH bytes to insert the + * string following the next match. + */ + if (s.lookahead < MIN_LOOKAHEAD) { + fill_window(s); + if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) { + return BS_NEED_MORE; + } + if (s.lookahead === 0) { + break; /* flush the current block */ + } + } + + /* Insert the string window[strstart .. strstart+2] in the + * dictionary, and set hash_head to the head of the hash chain: + */ + hash_head = 0/*NIL*/; + if (s.lookahead >= MIN_MATCH) { + /*** INSERT_STRING(s, s.strstart, hash_head); ***/ + s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask; + hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]; + s.head[s.ins_h] = s.strstart; + /***/ + } + + /* Find the longest match, discarding those <= prev_length. + * At this point we have always match_length < MIN_MATCH + */ + if (hash_head !== 0/*NIL*/ && ((s.strstart - hash_head) <= (s.w_size - MIN_LOOKAHEAD))) { + /* To simplify the code, we prevent matches with the string + * of window index 0 (in particular we have to avoid a match + * of the string with itself at the start of the input file). + */ + s.match_length = longest_match(s, hash_head); + /* longest_match() sets match_start */ + } + if (s.match_length >= MIN_MATCH) { + // check_match(s, s.strstart, s.match_start, s.match_length); // for debug only + + /*** _tr_tally_dist(s, s.strstart - s.match_start, + s.match_length - MIN_MATCH, bflush); ***/ + bflush = trees._tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH); + + s.lookahead -= s.match_length; + + /* Insert new strings in the hash table only if the match length + * is not too large. This saves time but degrades compression. + */ + if (s.match_length <= s.max_lazy_match/*max_insert_length*/ && s.lookahead >= MIN_MATCH) { + s.match_length--; /* string at strstart already in table */ + do { + s.strstart++; + /*** INSERT_STRING(s, s.strstart, hash_head); ***/ + s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask; + hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]; + s.head[s.ins_h] = s.strstart; + /***/ + /* strstart never exceeds WSIZE-MAX_MATCH, so there are + * always MIN_MATCH bytes ahead. + */ + } while (--s.match_length !== 0); + s.strstart++; + } else + { + s.strstart += s.match_length; + s.match_length = 0; + s.ins_h = s.window[s.strstart]; + /* UPDATE_HASH(s, s.ins_h, s.window[s.strstart+1]); */ + s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + 1]) & s.hash_mask; + +//#if MIN_MATCH != 3 +// Call UPDATE_HASH() MIN_MATCH-3 more times +//#endif + /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not + * matter since it will be recomputed at next deflate call. + */ + } + } else { + /* No match, output a literal byte */ + //Tracevv((stderr,"%c", s.window[s.strstart])); + /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/ + bflush = trees._tr_tally(s, 0, s.window[s.strstart]); + + s.lookahead--; + s.strstart++; + } + if (bflush) { + /*** FLUSH_BLOCK(s, 0); ***/ + flush_block_only(s, false); + if (s.strm.avail_out === 0) { + return BS_NEED_MORE; + } + /***/ + } + } + s.insert = ((s.strstart < (MIN_MATCH - 1)) ? s.strstart : MIN_MATCH - 1); + if (flush === Z_FINISH) { + /*** FLUSH_BLOCK(s, 1); ***/ + flush_block_only(s, true); + if (s.strm.avail_out === 0) { + return BS_FINISH_STARTED; + } + /***/ + return BS_FINISH_DONE; + } + if (s.last_lit) { + /*** FLUSH_BLOCK(s, 0); ***/ + flush_block_only(s, false); + if (s.strm.avail_out === 0) { + return BS_NEED_MORE; + } + /***/ + } + return BS_BLOCK_DONE; +} + +/* =========================================================================== + * Same as above, but achieves better compression. We use a lazy + * evaluation for matches: a match is finally adopted only if there is + * no better match at the next window position. + */ +function deflate_slow(s, flush) { + var hash_head; /* head of hash chain */ + var bflush; /* set if current block must be flushed */ + + var max_insert; + + /* Process the input block. */ + for (;;) { + /* Make sure that we always have enough lookahead, except + * at the end of the input file. We need MAX_MATCH bytes + * for the next match, plus MIN_MATCH bytes to insert the + * string following the next match. + */ + if (s.lookahead < MIN_LOOKAHEAD) { + fill_window(s); + if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) { + return BS_NEED_MORE; + } + if (s.lookahead === 0) { break; } /* flush the current block */ + } + + /* Insert the string window[strstart .. strstart+2] in the + * dictionary, and set hash_head to the head of the hash chain: + */ + hash_head = 0/*NIL*/; + if (s.lookahead >= MIN_MATCH) { + /*** INSERT_STRING(s, s.strstart, hash_head); ***/ + s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask; + hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]; + s.head[s.ins_h] = s.strstart; + /***/ + } + + /* Find the longest match, discarding those <= prev_length. + */ + s.prev_length = s.match_length; + s.prev_match = s.match_start; + s.match_length = MIN_MATCH - 1; + + if (hash_head !== 0/*NIL*/ && s.prev_length < s.max_lazy_match && + s.strstart - hash_head <= (s.w_size - MIN_LOOKAHEAD)/*MAX_DIST(s)*/) { + /* To simplify the code, we prevent matches with the string + * of window index 0 (in particular we have to avoid a match + * of the string with itself at the start of the input file). + */ + s.match_length = longest_match(s, hash_head); + /* longest_match() sets match_start */ + + if (s.match_length <= 5 && + (s.strategy === Z_FILTERED || (s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096/*TOO_FAR*/))) { + + /* If prev_match is also MIN_MATCH, match_start is garbage + * but we will ignore the current match anyway. + */ + s.match_length = MIN_MATCH - 1; + } + } + /* If there was a match at the previous step and the current + * match is not better, output the previous match: + */ + if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) { + max_insert = s.strstart + s.lookahead - MIN_MATCH; + /* Do not insert strings in hash table beyond this. */ + + //check_match(s, s.strstart-1, s.prev_match, s.prev_length); + + /***_tr_tally_dist(s, s.strstart - 1 - s.prev_match, + s.prev_length - MIN_MATCH, bflush);***/ + bflush = trees._tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH); + /* Insert in hash table all strings up to the end of the match. + * strstart-1 and strstart are already inserted. If there is not + * enough lookahead, the last two strings are not inserted in + * the hash table. + */ + s.lookahead -= s.prev_length - 1; + s.prev_length -= 2; + do { + if (++s.strstart <= max_insert) { + /*** INSERT_STRING(s, s.strstart, hash_head); ***/ + s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask; + hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]; + s.head[s.ins_h] = s.strstart; + /***/ + } + } while (--s.prev_length !== 0); + s.match_available = 0; + s.match_length = MIN_MATCH - 1; + s.strstart++; + + if (bflush) { + /*** FLUSH_BLOCK(s, 0); ***/ + flush_block_only(s, false); + if (s.strm.avail_out === 0) { + return BS_NEED_MORE; + } + /***/ + } + + } else if (s.match_available) { + /* If there was no match at the previous position, output a + * single literal. If there was a match but the current match + * is longer, truncate the previous match to a single literal. + */ + //Tracevv((stderr,"%c", s->window[s->strstart-1])); + /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/ + bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]); + + if (bflush) { + /*** FLUSH_BLOCK_ONLY(s, 0) ***/ + flush_block_only(s, false); + /***/ + } + s.strstart++; + s.lookahead--; + if (s.strm.avail_out === 0) { + return BS_NEED_MORE; + } + } else { + /* There is no previous match to compare with, wait for + * the next step to decide. + */ + s.match_available = 1; + s.strstart++; + s.lookahead--; + } + } + //Assert (flush != Z_NO_FLUSH, "no flush?"); + if (s.match_available) { + //Tracevv((stderr,"%c", s->window[s->strstart-1])); + /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/ + bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]); + + s.match_available = 0; + } + s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1; + if (flush === Z_FINISH) { + /*** FLUSH_BLOCK(s, 1); ***/ + flush_block_only(s, true); + if (s.strm.avail_out === 0) { + return BS_FINISH_STARTED; + } + /***/ + return BS_FINISH_DONE; + } + if (s.last_lit) { + /*** FLUSH_BLOCK(s, 0); ***/ + flush_block_only(s, false); + if (s.strm.avail_out === 0) { + return BS_NEED_MORE; + } + /***/ + } + + return BS_BLOCK_DONE; +} + + +/* =========================================================================== + * For Z_RLE, simply look for runs of bytes, generate matches only of distance + * one. Do not maintain a hash table. (It will be regenerated if this run of + * deflate switches away from Z_RLE.) + */ +function deflate_rle(s, flush) { + var bflush; /* set if current block must be flushed */ + var prev; /* byte at distance one to match */ + var scan, strend; /* scan goes up to strend for length of run */ + + var _win = s.window; + + for (;;) { + /* Make sure that we always have enough lookahead, except + * at the end of the input file. We need MAX_MATCH bytes + * for the longest run, plus one for the unrolled loop. + */ + if (s.lookahead <= MAX_MATCH) { + fill_window(s); + if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH) { + return BS_NEED_MORE; + } + if (s.lookahead === 0) { break; } /* flush the current block */ + } + + /* See how many times the previous byte repeats */ + s.match_length = 0; + if (s.lookahead >= MIN_MATCH && s.strstart > 0) { + scan = s.strstart - 1; + prev = _win[scan]; + if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) { + strend = s.strstart + MAX_MATCH; + do { + /*jshint noempty:false*/ + } while (prev === _win[++scan] && prev === _win[++scan] && + prev === _win[++scan] && prev === _win[++scan] && + prev === _win[++scan] && prev === _win[++scan] && + prev === _win[++scan] && prev === _win[++scan] && + scan < strend); + s.match_length = MAX_MATCH - (strend - scan); + if (s.match_length > s.lookahead) { + s.match_length = s.lookahead; + } + } + //Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan"); + } + + /* Emit match if have run of MIN_MATCH or longer, else emit literal */ + if (s.match_length >= MIN_MATCH) { + //check_match(s, s.strstart, s.strstart - 1, s.match_length); + + /*** _tr_tally_dist(s, 1, s.match_length - MIN_MATCH, bflush); ***/ + bflush = trees._tr_tally(s, 1, s.match_length - MIN_MATCH); + + s.lookahead -= s.match_length; + s.strstart += s.match_length; + s.match_length = 0; + } else { + /* No match, output a literal byte */ + //Tracevv((stderr,"%c", s->window[s->strstart])); + /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/ + bflush = trees._tr_tally(s, 0, s.window[s.strstart]); + + s.lookahead--; + s.strstart++; + } + if (bflush) { + /*** FLUSH_BLOCK(s, 0); ***/ + flush_block_only(s, false); + if (s.strm.avail_out === 0) { + return BS_NEED_MORE; + } + /***/ + } + } + s.insert = 0; + if (flush === Z_FINISH) { + /*** FLUSH_BLOCK(s, 1); ***/ + flush_block_only(s, true); + if (s.strm.avail_out === 0) { + return BS_FINISH_STARTED; + } + /***/ + return BS_FINISH_DONE; + } + if (s.last_lit) { + /*** FLUSH_BLOCK(s, 0); ***/ + flush_block_only(s, false); + if (s.strm.avail_out === 0) { + return BS_NEED_MORE; + } + /***/ + } + return BS_BLOCK_DONE; +} + +/* =========================================================================== + * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table. + * (It will be regenerated if this run of deflate switches away from Huffman.) + */ +function deflate_huff(s, flush) { + var bflush; /* set if current block must be flushed */ + + for (;;) { + /* Make sure that we have a literal to write. */ + if (s.lookahead === 0) { + fill_window(s); + if (s.lookahead === 0) { + if (flush === Z_NO_FLUSH) { + return BS_NEED_MORE; + } + break; /* flush the current block */ + } + } + + /* Output a literal byte */ + s.match_length = 0; + //Tracevv((stderr,"%c", s->window[s->strstart])); + /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/ + bflush = trees._tr_tally(s, 0, s.window[s.strstart]); + s.lookahead--; + s.strstart++; + if (bflush) { + /*** FLUSH_BLOCK(s, 0); ***/ + flush_block_only(s, false); + if (s.strm.avail_out === 0) { + return BS_NEED_MORE; + } + /***/ + } + } + s.insert = 0; + if (flush === Z_FINISH) { + /*** FLUSH_BLOCK(s, 1); ***/ + flush_block_only(s, true); + if (s.strm.avail_out === 0) { + return BS_FINISH_STARTED; + } + /***/ + return BS_FINISH_DONE; + } + if (s.last_lit) { + /*** FLUSH_BLOCK(s, 0); ***/ + flush_block_only(s, false); + if (s.strm.avail_out === 0) { + return BS_NEED_MORE; + } + /***/ + } + return BS_BLOCK_DONE; +} + +/* Values for max_lazy_match, good_match and max_chain_length, depending on + * the desired pack level (0..9). The values given below have been tuned to + * exclude worst case performance for pathological files. Better values may be + * found for specific files. + */ +function Config(good_length, max_lazy, nice_length, max_chain, func) { + this.good_length = good_length; + this.max_lazy = max_lazy; + this.nice_length = nice_length; + this.max_chain = max_chain; + this.func = func; +} + +var configuration_table; + +configuration_table = [ + /* good lazy nice chain */ + new Config(0, 0, 0, 0, deflate_stored), /* 0 store only */ + new Config(4, 4, 8, 4, deflate_fast), /* 1 max speed, no lazy matches */ + new Config(4, 5, 16, 8, deflate_fast), /* 2 */ + new Config(4, 6, 32, 32, deflate_fast), /* 3 */ + + new Config(4, 4, 16, 16, deflate_slow), /* 4 lazy matches */ + new Config(8, 16, 32, 32, deflate_slow), /* 5 */ + new Config(8, 16, 128, 128, deflate_slow), /* 6 */ + new Config(8, 32, 128, 256, deflate_slow), /* 7 */ + new Config(32, 128, 258, 1024, deflate_slow), /* 8 */ + new Config(32, 258, 258, 4096, deflate_slow) /* 9 max compression */ +]; + + +/* =========================================================================== + * Initialize the "longest match" routines for a new zlib stream + */ +function lm_init(s) { + s.window_size = 2 * s.w_size; + + /*** CLEAR_HASH(s); ***/ + zero(s.head); // Fill with NIL (= 0); + + /* Set the default configuration parameters: + */ + s.max_lazy_match = configuration_table[s.level].max_lazy; + s.good_match = configuration_table[s.level].good_length; + s.nice_match = configuration_table[s.level].nice_length; + s.max_chain_length = configuration_table[s.level].max_chain; + + s.strstart = 0; + s.block_start = 0; + s.lookahead = 0; + s.insert = 0; + s.match_length = s.prev_length = MIN_MATCH - 1; + s.match_available = 0; + s.ins_h = 0; +} + + +function DeflateState() { + this.strm = null; /* pointer back to this zlib stream */ + this.status = 0; /* as the name implies */ + this.pending_buf = null; /* output still pending */ + this.pending_buf_size = 0; /* size of pending_buf */ + this.pending_out = 0; /* next pending byte to output to the stream */ + this.pending = 0; /* nb of bytes in the pending buffer */ + this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */ + this.gzhead = null; /* gzip header information to write */ + this.gzindex = 0; /* where in extra, name, or comment */ + this.method = Z_DEFLATED; /* can only be DEFLATED */ + this.last_flush = -1; /* value of flush param for previous deflate call */ + + this.w_size = 0; /* LZ77 window size (32K by default) */ + this.w_bits = 0; /* log2(w_size) (8..16) */ + this.w_mask = 0; /* w_size - 1 */ + + this.window = null; + /* Sliding window. Input bytes are read into the second half of the window, + * and move to the first half later to keep a dictionary of at least wSize + * bytes. With this organization, matches are limited to a distance of + * wSize-MAX_MATCH bytes, but this ensures that IO is always + * performed with a length multiple of the block size. + */ + + this.window_size = 0; + /* Actual size of window: 2*wSize, except when the user input buffer + * is directly used as sliding window. + */ + + this.prev = null; + /* Link to older string with same hash index. To limit the size of this + * array to 64K, this link is maintained only for the last 32K strings. + * An index in this array is thus a window index modulo 32K. + */ + + this.head = null; /* Heads of the hash chains or NIL. */ + + this.ins_h = 0; /* hash index of string to be inserted */ + this.hash_size = 0; /* number of elements in hash table */ + this.hash_bits = 0; /* log2(hash_size) */ + this.hash_mask = 0; /* hash_size-1 */ + + this.hash_shift = 0; + /* Number of bits by which ins_h must be shifted at each input + * step. It must be such that after MIN_MATCH steps, the oldest + * byte no longer takes part in the hash key, that is: + * hash_shift * MIN_MATCH >= hash_bits + */ + + this.block_start = 0; + /* Window position at the beginning of the current output block. Gets + * negative when the window is moved backwards. + */ + + this.match_length = 0; /* length of best match */ + this.prev_match = 0; /* previous match */ + this.match_available = 0; /* set if previous match exists */ + this.strstart = 0; /* start of string to insert */ + this.match_start = 0; /* start of matching string */ + this.lookahead = 0; /* number of valid bytes ahead in window */ + + this.prev_length = 0; + /* Length of the best match at previous step. Matches not greater than this + * are discarded. This is used in the lazy match evaluation. + */ + + this.max_chain_length = 0; + /* To speed up deflation, hash chains are never searched beyond this + * length. A higher limit improves compression ratio but degrades the + * speed. + */ + + this.max_lazy_match = 0; + /* Attempt to find a better match only when the current match is strictly + * smaller than this value. This mechanism is used only for compression + * levels >= 4. + */ + // That's alias to max_lazy_match, don't use directly + //this.max_insert_length = 0; + /* Insert new strings in the hash table only if the match length is not + * greater than this length. This saves time but degrades compression. + * max_insert_length is used only for compression levels <= 3. + */ + + this.level = 0; /* compression level (1..9) */ + this.strategy = 0; /* favor or force Huffman coding*/ + + this.good_match = 0; + /* Use a faster search when the previous match is longer than this */ + + this.nice_match = 0; /* Stop searching when current match exceeds this */ + + /* used by trees.c: */ + + /* Didn't use ct_data typedef below to suppress compiler warning */ + + // struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ + // struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ + // struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ + + // Use flat array of DOUBLE size, with interleaved fata, + // because JS does not support effective + this.dyn_ltree = new utils.Buf16(HEAP_SIZE * 2); + this.dyn_dtree = new utils.Buf16((2 * D_CODES + 1) * 2); + this.bl_tree = new utils.Buf16((2 * BL_CODES + 1) * 2); + zero(this.dyn_ltree); + zero(this.dyn_dtree); + zero(this.bl_tree); + + this.l_desc = null; /* desc. for literal tree */ + this.d_desc = null; /* desc. for distance tree */ + this.bl_desc = null; /* desc. for bit length tree */ + + //ush bl_count[MAX_BITS+1]; + this.bl_count = new utils.Buf16(MAX_BITS + 1); + /* number of codes at each bit length for an optimal tree */ + + //int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ + this.heap = new utils.Buf16(2 * L_CODES + 1); /* heap used to build the Huffman trees */ + zero(this.heap); + + this.heap_len = 0; /* number of elements in the heap */ + this.heap_max = 0; /* element of largest frequency */ + /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. + * The same heap array is used to build all trees. + */ + + this.depth = new utils.Buf16(2 * L_CODES + 1); //uch depth[2*L_CODES+1]; + zero(this.depth); + /* Depth of each subtree used as tie breaker for trees of equal frequency + */ + + this.l_buf = 0; /* buffer index for literals or lengths */ + + this.lit_bufsize = 0; + /* Size of match buffer for literals/lengths. There are 4 reasons for + * limiting lit_bufsize to 64K: + * - frequencies can be kept in 16 bit counters + * - if compression is not successful for the first block, all input + * data is still in the window so we can still emit a stored block even + * when input comes from standard input. (This can also be done for + * all blocks if lit_bufsize is not greater than 32K.) + * - if compression is not successful for a file smaller than 64K, we can + * even emit a stored file instead of a stored block (saving 5 bytes). + * This is applicable only for zip (not gzip or zlib). + * - creating new Huffman trees less frequently may not provide fast + * adaptation to changes in the input data statistics. (Take for + * example a binary file with poorly compressible code followed by + * a highly compressible string table.) Smaller buffer sizes give + * fast adaptation but have of course the overhead of transmitting + * trees more frequently. + * - I can't count above 4 + */ + + this.last_lit = 0; /* running index in l_buf */ + + this.d_buf = 0; + /* Buffer index for distances. To simplify the code, d_buf and l_buf have + * the same number of elements. To use different lengths, an extra flag + * array would be necessary. + */ + + this.opt_len = 0; /* bit length of current block with optimal trees */ + this.static_len = 0; /* bit length of current block with static trees */ + this.matches = 0; /* number of string matches in current block */ + this.insert = 0; /* bytes at end of window left to insert */ + + + this.bi_buf = 0; + /* Output buffer. bits are inserted starting at the bottom (least + * significant bits). + */ + this.bi_valid = 0; + /* Number of valid bits in bi_buf. All bits above the last valid bit + * are always zero. + */ + + // Used for window memory init. We safely ignore it for JS. That makes + // sense only for pointers and memory check tools. + //this.high_water = 0; + /* High water mark offset in window for initialized bytes -- bytes above + * this are set to zero in order to avoid memory check warnings when + * longest match routines access bytes past the input. This is then + * updated to the new high water mark. + */ +} + + +function deflateResetKeep(strm) { + var s; + + if (!strm || !strm.state) { + return err(strm, Z_STREAM_ERROR); + } + + strm.total_in = strm.total_out = 0; + strm.data_type = Z_UNKNOWN; + + s = strm.state; + s.pending = 0; + s.pending_out = 0; + + if (s.wrap < 0) { + s.wrap = -s.wrap; + /* was made negative by deflate(..., Z_FINISH); */ + } + s.status = (s.wrap ? INIT_STATE : BUSY_STATE); + strm.adler = (s.wrap === 2) ? + 0 // crc32(0, Z_NULL, 0) + : + 1; // adler32(0, Z_NULL, 0) + s.last_flush = Z_NO_FLUSH; + trees._tr_init(s); + return Z_OK; +} + + +function deflateReset(strm) { + var ret = deflateResetKeep(strm); + if (ret === Z_OK) { + lm_init(strm.state); + } + return ret; +} + + +function deflateSetHeader(strm, head) { + if (!strm || !strm.state) { return Z_STREAM_ERROR; } + if (strm.state.wrap !== 2) { return Z_STREAM_ERROR; } + strm.state.gzhead = head; + return Z_OK; +} + + +function deflateInit2(strm, level, method, windowBits, memLevel, strategy) { + if (!strm) { // === Z_NULL + return Z_STREAM_ERROR; + } + var wrap = 1; + + if (level === Z_DEFAULT_COMPRESSION) { + level = 6; + } + + if (windowBits < 0) { /* suppress zlib wrapper */ + wrap = 0; + windowBits = -windowBits; + } + + else if (windowBits > 15) { + wrap = 2; /* write gzip wrapper instead */ + windowBits -= 16; + } + + + if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED || + windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || + strategy < 0 || strategy > Z_FIXED) { + return err(strm, Z_STREAM_ERROR); + } + + + if (windowBits === 8) { + windowBits = 9; + } + /* until 256-byte window bug fixed */ + + var s = new DeflateState(); + + strm.state = s; + s.strm = strm; + + s.wrap = wrap; + s.gzhead = null; + s.w_bits = windowBits; + s.w_size = 1 << s.w_bits; + s.w_mask = s.w_size - 1; + + s.hash_bits = memLevel + 7; + s.hash_size = 1 << s.hash_bits; + s.hash_mask = s.hash_size - 1; + s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH); + + s.window = new utils.Buf8(s.w_size * 2); + s.head = new utils.Buf16(s.hash_size); + s.prev = new utils.Buf16(s.w_size); + + // Don't need mem init magic for JS. + //s.high_water = 0; /* nothing written to s->window yet */ + + s.lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ + + s.pending_buf_size = s.lit_bufsize * 4; + + //overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); + //s->pending_buf = (uchf *) overlay; + s.pending_buf = new utils.Buf8(s.pending_buf_size); + + // It is offset from `s.pending_buf` (size is `s.lit_bufsize * 2`) + //s->d_buf = overlay + s->lit_bufsize/sizeof(ush); + s.d_buf = 1 * s.lit_bufsize; + + //s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; + s.l_buf = (1 + 2) * s.lit_bufsize; + + s.level = level; + s.strategy = strategy; + s.method = method; + + return deflateReset(strm); +} + +function deflateInit(strm, level) { + return deflateInit2(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY); +} + + +function deflate(strm, flush) { + var old_flush, s; + var beg, val; // for gzip header write only + + if (!strm || !strm.state || + flush > Z_BLOCK || flush < 0) { + return strm ? err(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR; + } + + s = strm.state; + + if (!strm.output || + (!strm.input && strm.avail_in !== 0) || + (s.status === FINISH_STATE && flush !== Z_FINISH)) { + return err(strm, (strm.avail_out === 0) ? Z_BUF_ERROR : Z_STREAM_ERROR); + } + + s.strm = strm; /* just in case */ + old_flush = s.last_flush; + s.last_flush = flush; + + /* Write the header */ + if (s.status === INIT_STATE) { + + if (s.wrap === 2) { // GZIP header + strm.adler = 0; //crc32(0L, Z_NULL, 0); + put_byte(s, 31); + put_byte(s, 139); + put_byte(s, 8); + if (!s.gzhead) { // s->gzhead == Z_NULL + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, s.level === 9 ? 2 : + (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? + 4 : 0)); + put_byte(s, OS_CODE); + s.status = BUSY_STATE; + } + else { + put_byte(s, (s.gzhead.text ? 1 : 0) + + (s.gzhead.hcrc ? 2 : 0) + + (!s.gzhead.extra ? 0 : 4) + + (!s.gzhead.name ? 0 : 8) + + (!s.gzhead.comment ? 0 : 16) + ); + put_byte(s, s.gzhead.time & 0xff); + put_byte(s, (s.gzhead.time >> 8) & 0xff); + put_byte(s, (s.gzhead.time >> 16) & 0xff); + put_byte(s, (s.gzhead.time >> 24) & 0xff); + put_byte(s, s.level === 9 ? 2 : + (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? + 4 : 0)); + put_byte(s, s.gzhead.os & 0xff); + if (s.gzhead.extra && s.gzhead.extra.length) { + put_byte(s, s.gzhead.extra.length & 0xff); + put_byte(s, (s.gzhead.extra.length >> 8) & 0xff); + } + if (s.gzhead.hcrc) { + strm.adler = crc32(strm.adler, s.pending_buf, s.pending, 0); + } + s.gzindex = 0; + s.status = EXTRA_STATE; + } + } + else // DEFLATE header + { + var header = (Z_DEFLATED + ((s.w_bits - 8) << 4)) << 8; + var level_flags = -1; + + if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) { + level_flags = 0; + } else if (s.level < 6) { + level_flags = 1; + } else if (s.level === 6) { + level_flags = 2; + } else { + level_flags = 3; + } + header |= (level_flags << 6); + if (s.strstart !== 0) { header |= PRESET_DICT; } + header += 31 - (header % 31); + + s.status = BUSY_STATE; + putShortMSB(s, header); + + /* Save the adler32 of the preset dictionary: */ + if (s.strstart !== 0) { + putShortMSB(s, strm.adler >>> 16); + putShortMSB(s, strm.adler & 0xffff); + } + strm.adler = 1; // adler32(0L, Z_NULL, 0); + } + } + +//#ifdef GZIP + if (s.status === EXTRA_STATE) { + if (s.gzhead.extra/* != Z_NULL*/) { + beg = s.pending; /* start of bytes to update crc */ + + while (s.gzindex < (s.gzhead.extra.length & 0xffff)) { + if (s.pending === s.pending_buf_size) { + if (s.gzhead.hcrc && s.pending > beg) { + strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg); + } + flush_pending(strm); + beg = s.pending; + if (s.pending === s.pending_buf_size) { + break; + } + } + put_byte(s, s.gzhead.extra[s.gzindex] & 0xff); + s.gzindex++; + } + if (s.gzhead.hcrc && s.pending > beg) { + strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg); + } + if (s.gzindex === s.gzhead.extra.length) { + s.gzindex = 0; + s.status = NAME_STATE; + } + } + else { + s.status = NAME_STATE; + } + } + if (s.status === NAME_STATE) { + if (s.gzhead.name/* != Z_NULL*/) { + beg = s.pending; /* start of bytes to update crc */ + //int val; + + do { + if (s.pending === s.pending_buf_size) { + if (s.gzhead.hcrc && s.pending > beg) { + strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg); + } + flush_pending(strm); + beg = s.pending; + if (s.pending === s.pending_buf_size) { + val = 1; + break; + } + } + // JS specific: little magic to add zero terminator to end of string + if (s.gzindex < s.gzhead.name.length) { + val = s.gzhead.name.charCodeAt(s.gzindex++) & 0xff; + } else { + val = 0; + } + put_byte(s, val); + } while (val !== 0); + + if (s.gzhead.hcrc && s.pending > beg) { + strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg); + } + if (val === 0) { + s.gzindex = 0; + s.status = COMMENT_STATE; + } + } + else { + s.status = COMMENT_STATE; + } + } + if (s.status === COMMENT_STATE) { + if (s.gzhead.comment/* != Z_NULL*/) { + beg = s.pending; /* start of bytes to update crc */ + //int val; + + do { + if (s.pending === s.pending_buf_size) { + if (s.gzhead.hcrc && s.pending > beg) { + strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg); + } + flush_pending(strm); + beg = s.pending; + if (s.pending === s.pending_buf_size) { + val = 1; + break; + } + } + // JS specific: little magic to add zero terminator to end of string + if (s.gzindex < s.gzhead.comment.length) { + val = s.gzhead.comment.charCodeAt(s.gzindex++) & 0xff; + } else { + val = 0; + } + put_byte(s, val); + } while (val !== 0); + + if (s.gzhead.hcrc && s.pending > beg) { + strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg); + } + if (val === 0) { + s.status = HCRC_STATE; + } + } + else { + s.status = HCRC_STATE; + } + } + if (s.status === HCRC_STATE) { + if (s.gzhead.hcrc) { + if (s.pending + 2 > s.pending_buf_size) { + flush_pending(strm); + } + if (s.pending + 2 <= s.pending_buf_size) { + put_byte(s, strm.adler & 0xff); + put_byte(s, (strm.adler >> 8) & 0xff); + strm.adler = 0; //crc32(0L, Z_NULL, 0); + s.status = BUSY_STATE; + } + } + else { + s.status = BUSY_STATE; + } + } +//#endif + + /* Flush as much pending output as possible */ + if (s.pending !== 0) { + flush_pending(strm); + if (strm.avail_out === 0) { + /* Since avail_out is 0, deflate will be called again with + * more output space, but possibly with both pending and + * avail_in equal to zero. There won't be anything to do, + * but this is not an error situation so make sure we + * return OK instead of BUF_ERROR at next call of deflate: + */ + s.last_flush = -1; + return Z_OK; + } + + /* Make sure there is something to do and avoid duplicate consecutive + * flushes. For repeated and useless calls with Z_FINISH, we keep + * returning Z_STREAM_END instead of Z_BUF_ERROR. + */ + } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) && + flush !== Z_FINISH) { + return err(strm, Z_BUF_ERROR); + } + + /* User must not provide more input after the first FINISH: */ + if (s.status === FINISH_STATE && strm.avail_in !== 0) { + return err(strm, Z_BUF_ERROR); + } + + /* Start a new block or continue the current one. + */ + if (strm.avail_in !== 0 || s.lookahead !== 0 || + (flush !== Z_NO_FLUSH && s.status !== FINISH_STATE)) { + var bstate = (s.strategy === Z_HUFFMAN_ONLY) ? deflate_huff(s, flush) : + (s.strategy === Z_RLE ? deflate_rle(s, flush) : + configuration_table[s.level].func(s, flush)); + + if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) { + s.status = FINISH_STATE; + } + if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) { + if (strm.avail_out === 0) { + s.last_flush = -1; + /* avoid BUF_ERROR next call, see above */ + } + return Z_OK; + /* If flush != Z_NO_FLUSH && avail_out == 0, the next call + * of deflate should use the same flush parameter to make sure + * that the flush is complete. So we don't have to output an + * empty block here, this will be done at next call. This also + * ensures that for a very small output buffer, we emit at most + * one empty block. + */ + } + if (bstate === BS_BLOCK_DONE) { + if (flush === Z_PARTIAL_FLUSH) { + trees._tr_align(s); + } + else if (flush !== Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */ + + trees._tr_stored_block(s, 0, 0, false); + /* For a full flush, this empty block will be recognized + * as a special marker by inflate_sync(). + */ + if (flush === Z_FULL_FLUSH) { + /*** CLEAR_HASH(s); ***/ /* forget history */ + zero(s.head); // Fill with NIL (= 0); + + if (s.lookahead === 0) { + s.strstart = 0; + s.block_start = 0; + s.insert = 0; + } + } + } + flush_pending(strm); + if (strm.avail_out === 0) { + s.last_flush = -1; /* avoid BUF_ERROR at next call, see above */ + return Z_OK; + } + } + } + //Assert(strm->avail_out > 0, "bug2"); + //if (strm.avail_out <= 0) { throw new Error("bug2");} + + if (flush !== Z_FINISH) { return Z_OK; } + if (s.wrap <= 0) { return Z_STREAM_END; } + + /* Write the trailer */ + if (s.wrap === 2) { + put_byte(s, strm.adler & 0xff); + put_byte(s, (strm.adler >> 8) & 0xff); + put_byte(s, (strm.adler >> 16) & 0xff); + put_byte(s, (strm.adler >> 24) & 0xff); + put_byte(s, strm.total_in & 0xff); + put_byte(s, (strm.total_in >> 8) & 0xff); + put_byte(s, (strm.total_in >> 16) & 0xff); + put_byte(s, (strm.total_in >> 24) & 0xff); + } + else + { + putShortMSB(s, strm.adler >>> 16); + putShortMSB(s, strm.adler & 0xffff); + } + + flush_pending(strm); + /* If avail_out is zero, the application will call deflate again + * to flush the rest. + */ + if (s.wrap > 0) { s.wrap = -s.wrap; } + /* write the trailer only once! */ + return s.pending !== 0 ? Z_OK : Z_STREAM_END; +} + +function deflateEnd(strm) { + var status; + + if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) { + return Z_STREAM_ERROR; + } + + status = strm.state.status; + if (status !== INIT_STATE && + status !== EXTRA_STATE && + status !== NAME_STATE && + status !== COMMENT_STATE && + status !== HCRC_STATE && + status !== BUSY_STATE && + status !== FINISH_STATE + ) { + return err(strm, Z_STREAM_ERROR); + } + + strm.state = null; + + return status === BUSY_STATE ? err(strm, Z_DATA_ERROR) : Z_OK; +} + + +/* ========================================================================= + * Initializes the compression dictionary from the given byte + * sequence without producing any compressed output. + */ +function deflateSetDictionary(strm, dictionary) { + var dictLength = dictionary.length; + + var s; + var str, n; + var wrap; + var avail; + var next; + var input; + var tmpDict; + + if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) { + return Z_STREAM_ERROR; + } + + s = strm.state; + wrap = s.wrap; + + if (wrap === 2 || (wrap === 1 && s.status !== INIT_STATE) || s.lookahead) { + return Z_STREAM_ERROR; + } + + /* when using zlib wrappers, compute Adler-32 for provided dictionary */ + if (wrap === 1) { + /* adler32(strm->adler, dictionary, dictLength); */ + strm.adler = adler32(strm.adler, dictionary, dictLength, 0); + } + + s.wrap = 0; /* avoid computing Adler-32 in read_buf */ + + /* if dictionary would fill window, just replace the history */ + if (dictLength >= s.w_size) { + if (wrap === 0) { /* already empty otherwise */ + /*** CLEAR_HASH(s); ***/ + zero(s.head); // Fill with NIL (= 0); + s.strstart = 0; + s.block_start = 0; + s.insert = 0; + } + /* use the tail */ + // dictionary = dictionary.slice(dictLength - s.w_size); + tmpDict = new utils.Buf8(s.w_size); + utils.arraySet(tmpDict, dictionary, dictLength - s.w_size, s.w_size, 0); + dictionary = tmpDict; + dictLength = s.w_size; + } + /* insert dictionary into window and hash */ + avail = strm.avail_in; + next = strm.next_in; + input = strm.input; + strm.avail_in = dictLength; + strm.next_in = 0; + strm.input = dictionary; + fill_window(s); + while (s.lookahead >= MIN_MATCH) { + str = s.strstart; + n = s.lookahead - (MIN_MATCH - 1); + do { + /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */ + s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask; + + s.prev[str & s.w_mask] = s.head[s.ins_h]; + + s.head[s.ins_h] = str; + str++; + } while (--n); + s.strstart = str; + s.lookahead = MIN_MATCH - 1; + fill_window(s); + } + s.strstart += s.lookahead; + s.block_start = s.strstart; + s.insert = s.lookahead; + s.lookahead = 0; + s.match_length = s.prev_length = MIN_MATCH - 1; + s.match_available = 0; + strm.next_in = next; + strm.input = input; + strm.avail_in = avail; + s.wrap = wrap; + return Z_OK; +} + + +exports.deflateInit = deflateInit; +exports.deflateInit2 = deflateInit2; +exports.deflateReset = deflateReset; +exports.deflateResetKeep = deflateResetKeep; +exports.deflateSetHeader = deflateSetHeader; +exports.deflate = deflate; +exports.deflateEnd = deflateEnd; +exports.deflateSetDictionary = deflateSetDictionary; +exports.deflateInfo = 'pako deflate (from Nodeca project)'; + +/* Not implemented +exports.deflateBound = deflateBound; +exports.deflateCopy = deflateCopy; +exports.deflateParams = deflateParams; +exports.deflatePending = deflatePending; +exports.deflatePrime = deflatePrime; +exports.deflateTune = deflateTune; +*/ + +},{"../utils/common":26,"./adler32":28,"./crc32":30,"./messages":36,"./trees":37}],32:[function(require,module,exports){ +'use strict'; + +// (C) 1995-2013 Jean-loup Gailly and Mark Adler +// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would be +// appreciated but is not required. +// 2. Altered source versions must be plainly marked as such, and must not be +// misrepresented as being the original software. +// 3. This notice may not be removed or altered from any source distribution. + +function GZheader() { + /* true if compressed data believed to be text */ + this.text = 0; + /* modification time */ + this.time = 0; + /* extra flags (not used when writing a gzip file) */ + this.xflags = 0; + /* operating system */ + this.os = 0; + /* pointer to extra field or Z_NULL if none */ + this.extra = null; + /* extra field length (valid if extra != Z_NULL) */ + this.extra_len = 0; // Actually, we don't need it in JS, + // but leave for few code modifications + + // + // Setup limits is not necessary because in js we should not preallocate memory + // for inflate use constant limit in 65536 bytes + // + + /* space at extra (only when reading header) */ + // this.extra_max = 0; + /* pointer to zero-terminated file name or Z_NULL */ + this.name = ''; + /* space at name (only when reading header) */ + // this.name_max = 0; + /* pointer to zero-terminated comment or Z_NULL */ + this.comment = ''; + /* space at comment (only when reading header) */ + // this.comm_max = 0; + /* true if there was or will be a header crc */ + this.hcrc = 0; + /* true when done reading gzip header (not used when writing a gzip file) */ + this.done = false; +} + +module.exports = GZheader; + +},{}],33:[function(require,module,exports){ +'use strict'; + +// (C) 1995-2013 Jean-loup Gailly and Mark Adler +// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would be +// appreciated but is not required. +// 2. Altered source versions must be plainly marked as such, and must not be +// misrepresented as being the original software. +// 3. This notice may not be removed or altered from any source distribution. + +// See state defs from inflate.js +var BAD = 30; /* got a data error -- remain here until reset */ +var TYPE = 12; /* i: waiting for type bits, including last-flag bit */ + +/* + Decode literal, length, and distance codes and write out the resulting + literal and match bytes until either not enough input or output is + available, an end-of-block is encountered, or a data error is encountered. + When large enough input and output buffers are supplied to inflate(), for + example, a 16K input buffer and a 64K output buffer, more than 95% of the + inflate execution time is spent in this routine. + + Entry assumptions: + + state.mode === LEN + strm.avail_in >= 6 + strm.avail_out >= 258 + start >= strm.avail_out + state.bits < 8 + + On return, state.mode is one of: + + LEN -- ran out of enough output space or enough available input + TYPE -- reached end of block code, inflate() to interpret next block + BAD -- error in block data + + Notes: + + - The maximum input bits used by a length/distance pair is 15 bits for the + length code, 5 bits for the length extra, 15 bits for the distance code, + and 13 bits for the distance extra. This totals 48 bits, or six bytes. + Therefore if strm.avail_in >= 6, then there is enough input to avoid + checking for available input while decoding. + + - The maximum bytes that a single length/distance pair can output is 258 + bytes, which is the maximum length that can be coded. inflate_fast() + requires strm.avail_out >= 258 for each loop to avoid checking for + output space. + */ +module.exports = function inflate_fast(strm, start) { + var state; + var _in; /* local strm.input */ + var last; /* have enough input while in < last */ + var _out; /* local strm.output */ + var beg; /* inflate()'s initial strm.output */ + var end; /* while out < end, enough space available */ +//#ifdef INFLATE_STRICT + var dmax; /* maximum distance from zlib header */ +//#endif + var wsize; /* window size or zero if not using window */ + var whave; /* valid bytes in the window */ + var wnext; /* window write index */ + // Use `s_window` instead `window`, avoid conflict with instrumentation tools + var s_window; /* allocated sliding window, if wsize != 0 */ + var hold; /* local strm.hold */ + var bits; /* local strm.bits */ + var lcode; /* local strm.lencode */ + var dcode; /* local strm.distcode */ + var lmask; /* mask for first level of length codes */ + var dmask; /* mask for first level of distance codes */ + var here; /* retrieved table entry */ + var op; /* code bits, operation, extra bits, or */ + /* window position, window bytes to copy */ + var len; /* match length, unused bytes */ + var dist; /* match distance */ + var from; /* where to copy match from */ + var from_source; + + + var input, output; // JS specific, because we have no pointers + + /* copy state to local variables */ + state = strm.state; + //here = state.here; + _in = strm.next_in; + input = strm.input; + last = _in + (strm.avail_in - 5); + _out = strm.next_out; + output = strm.output; + beg = _out - (start - strm.avail_out); + end = _out + (strm.avail_out - 257); +//#ifdef INFLATE_STRICT + dmax = state.dmax; +//#endif + wsize = state.wsize; + whave = state.whave; + wnext = state.wnext; + s_window = state.window; + hold = state.hold; + bits = state.bits; + lcode = state.lencode; + dcode = state.distcode; + lmask = (1 << state.lenbits) - 1; + dmask = (1 << state.distbits) - 1; + + + /* decode literals and length/distances until end-of-block or not enough + input data or output space */ + + top: + do { + if (bits < 15) { + hold += input[_in++] << bits; + bits += 8; + hold += input[_in++] << bits; + bits += 8; + } + + here = lcode[hold & lmask]; + + dolen: + for (;;) { // Goto emulation + op = here >>> 24/*here.bits*/; + hold >>>= op; + bits -= op; + op = (here >>> 16) & 0xff/*here.op*/; + if (op === 0) { /* literal */ + //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? + // "inflate: literal '%c'\n" : + // "inflate: literal 0x%02x\n", here.val)); + output[_out++] = here & 0xffff/*here.val*/; + } + else if (op & 16) { /* length base */ + len = here & 0xffff/*here.val*/; + op &= 15; /* number of extra bits */ + if (op) { + if (bits < op) { + hold += input[_in++] << bits; + bits += 8; + } + len += hold & ((1 << op) - 1); + hold >>>= op; + bits -= op; + } + //Tracevv((stderr, "inflate: length %u\n", len)); + if (bits < 15) { + hold += input[_in++] << bits; + bits += 8; + hold += input[_in++] << bits; + bits += 8; + } + here = dcode[hold & dmask]; + + dodist: + for (;;) { // goto emulation + op = here >>> 24/*here.bits*/; + hold >>>= op; + bits -= op; + op = (here >>> 16) & 0xff/*here.op*/; + + if (op & 16) { /* distance base */ + dist = here & 0xffff/*here.val*/; + op &= 15; /* number of extra bits */ + if (bits < op) { + hold += input[_in++] << bits; + bits += 8; + if (bits < op) { + hold += input[_in++] << bits; + bits += 8; + } + } + dist += hold & ((1 << op) - 1); +//#ifdef INFLATE_STRICT + if (dist > dmax) { + strm.msg = 'invalid distance too far back'; + state.mode = BAD; + break top; + } +//#endif + hold >>>= op; + bits -= op; + //Tracevv((stderr, "inflate: distance %u\n", dist)); + op = _out - beg; /* max distance in output */ + if (dist > op) { /* see if copy from window */ + op = dist - op; /* distance back in window */ + if (op > whave) { + if (state.sane) { + strm.msg = 'invalid distance too far back'; + state.mode = BAD; + break top; + } + +// (!) This block is disabled in zlib defaults, +// don't enable it for binary compatibility +//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR +// if (len <= op - whave) { +// do { +// output[_out++] = 0; +// } while (--len); +// continue top; +// } +// len -= op - whave; +// do { +// output[_out++] = 0; +// } while (--op > whave); +// if (op === 0) { +// from = _out - dist; +// do { +// output[_out++] = output[from++]; +// } while (--len); +// continue top; +// } +//#endif + } + from = 0; // window index + from_source = s_window; + if (wnext === 0) { /* very common case */ + from += wsize - op; + if (op < len) { /* some from window */ + len -= op; + do { + output[_out++] = s_window[from++]; + } while (--op); + from = _out - dist; /* rest from output */ + from_source = output; + } + } + else if (wnext < op) { /* wrap around window */ + from += wsize + wnext - op; + op -= wnext; + if (op < len) { /* some from end of window */ + len -= op; + do { + output[_out++] = s_window[from++]; + } while (--op); + from = 0; + if (wnext < len) { /* some from start of window */ + op = wnext; + len -= op; + do { + output[_out++] = s_window[from++]; + } while (--op); + from = _out - dist; /* rest from output */ + from_source = output; + } + } + } + else { /* contiguous in window */ + from += wnext - op; + if (op < len) { /* some from window */ + len -= op; + do { + output[_out++] = s_window[from++]; + } while (--op); + from = _out - dist; /* rest from output */ + from_source = output; + } + } + while (len > 2) { + output[_out++] = from_source[from++]; + output[_out++] = from_source[from++]; + output[_out++] = from_source[from++]; + len -= 3; + } + if (len) { + output[_out++] = from_source[from++]; + if (len > 1) { + output[_out++] = from_source[from++]; + } + } + } + else { + from = _out - dist; /* copy direct from output */ + do { /* minimum length is three */ + output[_out++] = output[from++]; + output[_out++] = output[from++]; + output[_out++] = output[from++]; + len -= 3; + } while (len > 2); + if (len) { + output[_out++] = output[from++]; + if (len > 1) { + output[_out++] = output[from++]; + } + } + } + } + else if ((op & 64) === 0) { /* 2nd level distance code */ + here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))]; + continue dodist; + } + else { + strm.msg = 'invalid distance code'; + state.mode = BAD; + break top; + } + + break; // need to emulate goto via "continue" + } + } + else if ((op & 64) === 0) { /* 2nd level length code */ + here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))]; + continue dolen; + } + else if (op & 32) { /* end-of-block */ + //Tracevv((stderr, "inflate: end of block\n")); + state.mode = TYPE; + break top; + } + else { + strm.msg = 'invalid literal/length code'; + state.mode = BAD; + break top; + } + + break; // need to emulate goto via "continue" + } + } while (_in < last && _out < end); + + /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ + len = bits >> 3; + _in -= len; + bits -= len << 3; + hold &= (1 << bits) - 1; + + /* update state and return */ + strm.next_in = _in; + strm.next_out = _out; + strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last)); + strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end)); + state.hold = hold; + state.bits = bits; + return; +}; + +},{}],34:[function(require,module,exports){ +'use strict'; + +// (C) 1995-2013 Jean-loup Gailly and Mark Adler +// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would be +// appreciated but is not required. +// 2. Altered source versions must be plainly marked as such, and must not be +// misrepresented as being the original software. +// 3. This notice may not be removed or altered from any source distribution. + +var utils = require('../utils/common'); +var adler32 = require('./adler32'); +var crc32 = require('./crc32'); +var inflate_fast = require('./inffast'); +var inflate_table = require('./inftrees'); + +var CODES = 0; +var LENS = 1; +var DISTS = 2; + +/* Public constants ==========================================================*/ +/* ===========================================================================*/ + + +/* Allowed flush values; see deflate() and inflate() below for details */ +//var Z_NO_FLUSH = 0; +//var Z_PARTIAL_FLUSH = 1; +//var Z_SYNC_FLUSH = 2; +//var Z_FULL_FLUSH = 3; +var Z_FINISH = 4; +var Z_BLOCK = 5; +var Z_TREES = 6; + + +/* Return codes for the compression/decompression functions. Negative values + * are errors, positive values are used for special but normal events. + */ +var Z_OK = 0; +var Z_STREAM_END = 1; +var Z_NEED_DICT = 2; +//var Z_ERRNO = -1; +var Z_STREAM_ERROR = -2; +var Z_DATA_ERROR = -3; +var Z_MEM_ERROR = -4; +var Z_BUF_ERROR = -5; +//var Z_VERSION_ERROR = -6; + +/* The deflate compression method */ +var Z_DEFLATED = 8; + + +/* STATES ====================================================================*/ +/* ===========================================================================*/ + + +var HEAD = 1; /* i: waiting for magic header */ +var FLAGS = 2; /* i: waiting for method and flags (gzip) */ +var TIME = 3; /* i: waiting for modification time (gzip) */ +var OS = 4; /* i: waiting for extra flags and operating system (gzip) */ +var EXLEN = 5; /* i: waiting for extra length (gzip) */ +var EXTRA = 6; /* i: waiting for extra bytes (gzip) */ +var NAME = 7; /* i: waiting for end of file name (gzip) */ +var COMMENT = 8; /* i: waiting for end of comment (gzip) */ +var HCRC = 9; /* i: waiting for header crc (gzip) */ +var DICTID = 10; /* i: waiting for dictionary check value */ +var DICT = 11; /* waiting for inflateSetDictionary() call */ +var TYPE = 12; /* i: waiting for type bits, including last-flag bit */ +var TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */ +var STORED = 14; /* i: waiting for stored size (length and complement) */ +var COPY_ = 15; /* i/o: same as COPY below, but only first time in */ +var COPY = 16; /* i/o: waiting for input or output to copy stored block */ +var TABLE = 17; /* i: waiting for dynamic block table lengths */ +var LENLENS = 18; /* i: waiting for code length code lengths */ +var CODELENS = 19; /* i: waiting for length/lit and distance code lengths */ +var LEN_ = 20; /* i: same as LEN below, but only first time in */ +var LEN = 21; /* i: waiting for length/lit/eob code */ +var LENEXT = 22; /* i: waiting for length extra bits */ +var DIST = 23; /* i: waiting for distance code */ +var DISTEXT = 24; /* i: waiting for distance extra bits */ +var MATCH = 25; /* o: waiting for output space to copy string */ +var LIT = 26; /* o: waiting for output space to write literal */ +var CHECK = 27; /* i: waiting for 32-bit check value */ +var LENGTH = 28; /* i: waiting for 32-bit length (gzip) */ +var DONE = 29; /* finished check, done -- remain here until reset */ +var BAD = 30; /* got a data error -- remain here until reset */ +var MEM = 31; /* got an inflate() memory error -- remain here until reset */ +var SYNC = 32; /* looking for synchronization bytes to restart inflate() */ + +/* ===========================================================================*/ + + + +var ENOUGH_LENS = 852; +var ENOUGH_DISTS = 592; +//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS); + +var MAX_WBITS = 15; +/* 32K LZ77 window */ +var DEF_WBITS = MAX_WBITS; + + +function zswap32(q) { + return (((q >>> 24) & 0xff) + + ((q >>> 8) & 0xff00) + + ((q & 0xff00) << 8) + + ((q & 0xff) << 24)); +} + + +function InflateState() { + this.mode = 0; /* current inflate mode */ + this.last = false; /* true if processing last block */ + this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */ + this.havedict = false; /* true if dictionary provided */ + this.flags = 0; /* gzip header method and flags (0 if zlib) */ + this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */ + this.check = 0; /* protected copy of check value */ + this.total = 0; /* protected copy of output count */ + // TODO: may be {} + this.head = null; /* where to save gzip header information */ + + /* sliding window */ + this.wbits = 0; /* log base 2 of requested window size */ + this.wsize = 0; /* window size or zero if not using window */ + this.whave = 0; /* valid bytes in the window */ + this.wnext = 0; /* window write index */ + this.window = null; /* allocated sliding window, if needed */ + + /* bit accumulator */ + this.hold = 0; /* input bit accumulator */ + this.bits = 0; /* number of bits in "in" */ + + /* for string and stored block copying */ + this.length = 0; /* literal or length of data to copy */ + this.offset = 0; /* distance back to copy string from */ + + /* for table and code decoding */ + this.extra = 0; /* extra bits needed */ + + /* fixed and dynamic code tables */ + this.lencode = null; /* starting table for length/literal codes */ + this.distcode = null; /* starting table for distance codes */ + this.lenbits = 0; /* index bits for lencode */ + this.distbits = 0; /* index bits for distcode */ + + /* dynamic table building */ + this.ncode = 0; /* number of code length code lengths */ + this.nlen = 0; /* number of length code lengths */ + this.ndist = 0; /* number of distance code lengths */ + this.have = 0; /* number of code lengths in lens[] */ + this.next = null; /* next available space in codes[] */ + + this.lens = new utils.Buf16(320); /* temporary storage for code lengths */ + this.work = new utils.Buf16(288); /* work area for code table building */ + + /* + because we don't have pointers in js, we use lencode and distcode directly + as buffers so we don't need codes + */ + //this.codes = new utils.Buf32(ENOUGH); /* space for code tables */ + this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */ + this.distdyn = null; /* dynamic table for distance codes (JS specific) */ + this.sane = 0; /* if false, allow invalid distance too far */ + this.back = 0; /* bits back of last unprocessed length/lit */ + this.was = 0; /* initial length of match */ +} + +function inflateResetKeep(strm) { + var state; + + if (!strm || !strm.state) { return Z_STREAM_ERROR; } + state = strm.state; + strm.total_in = strm.total_out = state.total = 0; + strm.msg = ''; /*Z_NULL*/ + if (state.wrap) { /* to support ill-conceived Java test suite */ + strm.adler = state.wrap & 1; + } + state.mode = HEAD; + state.last = 0; + state.havedict = 0; + state.dmax = 32768; + state.head = null/*Z_NULL*/; + state.hold = 0; + state.bits = 0; + //state.lencode = state.distcode = state.next = state.codes; + state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS); + state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS); + + state.sane = 1; + state.back = -1; + //Tracev((stderr, "inflate: reset\n")); + return Z_OK; +} + +function inflateReset(strm) { + var state; + + if (!strm || !strm.state) { return Z_STREAM_ERROR; } + state = strm.state; + state.wsize = 0; + state.whave = 0; + state.wnext = 0; + return inflateResetKeep(strm); + +} + +function inflateReset2(strm, windowBits) { + var wrap; + var state; + + /* get the state */ + if (!strm || !strm.state) { return Z_STREAM_ERROR; } + state = strm.state; + + /* extract wrap request from windowBits parameter */ + if (windowBits < 0) { + wrap = 0; + windowBits = -windowBits; + } + else { + wrap = (windowBits >> 4) + 1; + if (windowBits < 48) { + windowBits &= 15; + } + } + + /* set number of window bits, free window if different */ + if (windowBits && (windowBits < 8 || windowBits > 15)) { + return Z_STREAM_ERROR; + } + if (state.window !== null && state.wbits !== windowBits) { + state.window = null; + } + + /* update state and reset the rest of it */ + state.wrap = wrap; + state.wbits = windowBits; + return inflateReset(strm); +} + +function inflateInit2(strm, windowBits) { + var ret; + var state; + + if (!strm) { return Z_STREAM_ERROR; } + //strm.msg = Z_NULL; /* in case we return an error */ + + state = new InflateState(); + + //if (state === Z_NULL) return Z_MEM_ERROR; + //Tracev((stderr, "inflate: allocated\n")); + strm.state = state; + state.window = null/*Z_NULL*/; + ret = inflateReset2(strm, windowBits); + if (ret !== Z_OK) { + strm.state = null/*Z_NULL*/; + } + return ret; +} + +function inflateInit(strm) { + return inflateInit2(strm, DEF_WBITS); +} + + +/* + Return state with length and distance decoding tables and index sizes set to + fixed code decoding. Normally this returns fixed tables from inffixed.h. + If BUILDFIXED is defined, then instead this routine builds the tables the + first time it's called, and returns those tables the first time and + thereafter. This reduces the size of the code by about 2K bytes, in + exchange for a little execution time. However, BUILDFIXED should not be + used for threaded applications, since the rewriting of the tables and virgin + may not be thread-safe. + */ +var virgin = true; + +var lenfix, distfix; // We have no pointers in JS, so keep tables separate + +function fixedtables(state) { + /* build fixed huffman tables if first call (may not be thread safe) */ + if (virgin) { + var sym; + + lenfix = new utils.Buf32(512); + distfix = new utils.Buf32(32); + + /* literal/length table */ + sym = 0; + while (sym < 144) { state.lens[sym++] = 8; } + while (sym < 256) { state.lens[sym++] = 9; } + while (sym < 280) { state.lens[sym++] = 7; } + while (sym < 288) { state.lens[sym++] = 8; } + + inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 }); + + /* distance table */ + sym = 0; + while (sym < 32) { state.lens[sym++] = 5; } + + inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 }); + + /* do this just once */ + virgin = false; + } + + state.lencode = lenfix; + state.lenbits = 9; + state.distcode = distfix; + state.distbits = 5; +} + + +/* + Update the window with the last wsize (normally 32K) bytes written before + returning. If window does not exist yet, create it. This is only called + when a window is already in use, or when output has been written during this + inflate call, but the end of the deflate stream has not been reached yet. + It is also called to create a window for dictionary data when a dictionary + is loaded. + + Providing output buffers larger than 32K to inflate() should provide a speed + advantage, since only the last 32K of output is copied to the sliding window + upon return from inflate(), and since all distances after the first 32K of + output will fall in the output data, making match copies simpler and faster. + The advantage may be dependent on the size of the processor's data caches. + */ +function updatewindow(strm, src, end, copy) { + var dist; + var state = strm.state; + + /* if it hasn't been done already, allocate space for the window */ + if (state.window === null) { + state.wsize = 1 << state.wbits; + state.wnext = 0; + state.whave = 0; + + state.window = new utils.Buf8(state.wsize); + } + + /* copy state->wsize or less output bytes into the circular window */ + if (copy >= state.wsize) { + utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0); + state.wnext = 0; + state.whave = state.wsize; + } + else { + dist = state.wsize - state.wnext; + if (dist > copy) { + dist = copy; + } + //zmemcpy(state->window + state->wnext, end - copy, dist); + utils.arraySet(state.window, src, end - copy, dist, state.wnext); + copy -= dist; + if (copy) { + //zmemcpy(state->window, end - copy, copy); + utils.arraySet(state.window, src, end - copy, copy, 0); + state.wnext = copy; + state.whave = state.wsize; + } + else { + state.wnext += dist; + if (state.wnext === state.wsize) { state.wnext = 0; } + if (state.whave < state.wsize) { state.whave += dist; } + } + } + return 0; +} + +function inflate(strm, flush) { + var state; + var input, output; // input/output buffers + var next; /* next input INDEX */ + var put; /* next output INDEX */ + var have, left; /* available input and output */ + var hold; /* bit buffer */ + var bits; /* bits in bit buffer */ + var _in, _out; /* save starting available input and output */ + var copy; /* number of stored or match bytes to copy */ + var from; /* where to copy match bytes from */ + var from_source; + var here = 0; /* current decoding table entry */ + var here_bits, here_op, here_val; // paked "here" denormalized (JS specific) + //var last; /* parent table entry */ + var last_bits, last_op, last_val; // paked "last" denormalized (JS specific) + var len; /* length to copy for repeats, bits to drop */ + var ret; /* return code */ + var hbuf = new utils.Buf8(4); /* buffer for gzip header crc calculation */ + var opts; + + var n; // temporary var for NEED_BITS + + var order = /* permutation of code lengths */ + [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ]; + + + if (!strm || !strm.state || !strm.output || + (!strm.input && strm.avail_in !== 0)) { + return Z_STREAM_ERROR; + } + + state = strm.state; + if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */ + + + //--- LOAD() --- + put = strm.next_out; + output = strm.output; + left = strm.avail_out; + next = strm.next_in; + input = strm.input; + have = strm.avail_in; + hold = state.hold; + bits = state.bits; + //--- + + _in = have; + _out = left; + ret = Z_OK; + + inf_leave: // goto emulation + for (;;) { + switch (state.mode) { + case HEAD: + if (state.wrap === 0) { + state.mode = TYPEDO; + break; + } + //=== NEEDBITS(16); + while (bits < 16) { + if (have === 0) { break inf_leave; } + have--; + hold += input[next++] << bits; + bits += 8; + } + //===// + if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */ + state.check = 0/*crc32(0L, Z_NULL, 0)*/; + //=== CRC2(state.check, hold); + hbuf[0] = hold & 0xff; + hbuf[1] = (hold >>> 8) & 0xff; + state.check = crc32(state.check, hbuf, 2, 0); + //===// + + //=== INITBITS(); + hold = 0; + bits = 0; + //===// + state.mode = FLAGS; + break; + } + state.flags = 0; /* expect zlib header */ + if (state.head) { + state.head.done = false; + } + if (!(state.wrap & 1) || /* check if zlib header allowed */ + (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) { + strm.msg = 'incorrect header check'; + state.mode = BAD; + break; + } + if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) { + strm.msg = 'unknown compression method'; + state.mode = BAD; + break; + } + //--- DROPBITS(4) ---// + hold >>>= 4; + bits -= 4; + //---// + len = (hold & 0x0f)/*BITS(4)*/ + 8; + if (state.wbits === 0) { + state.wbits = len; + } + else if (len > state.wbits) { + strm.msg = 'invalid window size'; + state.mode = BAD; + break; + } + state.dmax = 1 << len; + //Tracev((stderr, "inflate: zlib header ok\n")); + strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/; + state.mode = hold & 0x200 ? DICTID : TYPE; + //=== INITBITS(); + hold = 0; + bits = 0; + //===// + break; + case FLAGS: + //=== NEEDBITS(16); */ + while (bits < 16) { + if (have === 0) { break inf_leave; } + have--; + hold += input[next++] << bits; + bits += 8; + } + //===// + state.flags = hold; + if ((state.flags & 0xff) !== Z_DEFLATED) { + strm.msg = 'unknown compression method'; + state.mode = BAD; + break; + } + if (state.flags & 0xe000) { + strm.msg = 'unknown header flags set'; + state.mode = BAD; + break; + } + if (state.head) { + state.head.text = ((hold >> 8) & 1); + } + if (state.flags & 0x0200) { + //=== CRC2(state.check, hold); + hbuf[0] = hold & 0xff; + hbuf[1] = (hold >>> 8) & 0xff; + state.check = crc32(state.check, hbuf, 2, 0); + //===// + } + //=== INITBITS(); + hold = 0; + bits = 0; + //===// + state.mode = TIME; + /* falls through */ + case TIME: + //=== NEEDBITS(32); */ + while (bits < 32) { + if (have === 0) { break inf_leave; } + have--; + hold += input[next++] << bits; + bits += 8; + } + //===// + if (state.head) { + state.head.time = hold; + } + if (state.flags & 0x0200) { + //=== CRC4(state.check, hold) + hbuf[0] = hold & 0xff; + hbuf[1] = (hold >>> 8) & 0xff; + hbuf[2] = (hold >>> 16) & 0xff; + hbuf[3] = (hold >>> 24) & 0xff; + state.check = crc32(state.check, hbuf, 4, 0); + //=== + } + //=== INITBITS(); + hold = 0; + bits = 0; + //===// + state.mode = OS; + /* falls through */ + case OS: + //=== NEEDBITS(16); */ + while (bits < 16) { + if (have === 0) { break inf_leave; } + have--; + hold += input[next++] << bits; + bits += 8; + } + //===// + if (state.head) { + state.head.xflags = (hold & 0xff); + state.head.os = (hold >> 8); + } + if (state.flags & 0x0200) { + //=== CRC2(state.check, hold); + hbuf[0] = hold & 0xff; + hbuf[1] = (hold >>> 8) & 0xff; + state.check = crc32(state.check, hbuf, 2, 0); + //===// + } + //=== INITBITS(); + hold = 0; + bits = 0; + //===// + state.mode = EXLEN; + /* falls through */ + case EXLEN: + if (state.flags & 0x0400) { + //=== NEEDBITS(16); */ + while (bits < 16) { + if (have === 0) { break inf_leave; } + have--; + hold += input[next++] << bits; + bits += 8; + } + //===// + state.length = hold; + if (state.head) { + state.head.extra_len = hold; + } + if (state.flags & 0x0200) { + //=== CRC2(state.check, hold); + hbuf[0] = hold & 0xff; + hbuf[1] = (hold >>> 8) & 0xff; + state.check = crc32(state.check, hbuf, 2, 0); + //===// + } + //=== INITBITS(); + hold = 0; + bits = 0; + //===// + } + else if (state.head) { + state.head.extra = null/*Z_NULL*/; + } + state.mode = EXTRA; + /* falls through */ + case EXTRA: + if (state.flags & 0x0400) { + copy = state.length; + if (copy > have) { copy = have; } + if (copy) { + if (state.head) { + len = state.head.extra_len - state.length; + if (!state.head.extra) { + // Use untyped array for more convenient processing later + state.head.extra = new Array(state.head.extra_len); + } + utils.arraySet( + state.head.extra, + input, + next, + // extra field is limited to 65536 bytes + // - no need for additional size check + copy, + /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/ + len + ); + //zmemcpy(state.head.extra + len, next, + // len + copy > state.head.extra_max ? + // state.head.extra_max - len : copy); + } + if (state.flags & 0x0200) { + state.check = crc32(state.check, input, copy, next); + } + have -= copy; + next += copy; + state.length -= copy; + } + if (state.length) { break inf_leave; } + } + state.length = 0; + state.mode = NAME; + /* falls through */ + case NAME: + if (state.flags & 0x0800) { + if (have === 0) { break inf_leave; } + copy = 0; + do { + // TODO: 2 or 1 bytes? + len = input[next + copy++]; + /* use constant limit because in js we should not preallocate memory */ + if (state.head && len && + (state.length < 65536 /*state.head.name_max*/)) { + state.head.name += String.fromCharCode(len); + } + } while (len && copy < have); + + if (state.flags & 0x0200) { + state.check = crc32(state.check, input, copy, next); + } + have -= copy; + next += copy; + if (len) { break inf_leave; } + } + else if (state.head) { + state.head.name = null; + } + state.length = 0; + state.mode = COMMENT; + /* falls through */ + case COMMENT: + if (state.flags & 0x1000) { + if (have === 0) { break inf_leave; } + copy = 0; + do { + len = input[next + copy++]; + /* use constant limit because in js we should not preallocate memory */ + if (state.head && len && + (state.length < 65536 /*state.head.comm_max*/)) { + state.head.comment += String.fromCharCode(len); + } + } while (len && copy < have); + if (state.flags & 0x0200) { + state.check = crc32(state.check, input, copy, next); + } + have -= copy; + next += copy; + if (len) { break inf_leave; } + } + else if (state.head) { + state.head.comment = null; + } + state.mode = HCRC; + /* falls through */ + case HCRC: + if (state.flags & 0x0200) { + //=== NEEDBITS(16); */ + while (bits < 16) { + if (have === 0) { break inf_leave; } + have--; + hold += input[next++] << bits; + bits += 8; + } + //===// + if (hold !== (state.check & 0xffff)) { + strm.msg = 'header crc mismatch'; + state.mode = BAD; + break; + } + //=== INITBITS(); + hold = 0; + bits = 0; + //===// + } + if (state.head) { + state.head.hcrc = ((state.flags >> 9) & 1); + state.head.done = true; + } + strm.adler = state.check = 0; + state.mode = TYPE; + break; + case DICTID: + //=== NEEDBITS(32); */ + while (bits < 32) { + if (have === 0) { break inf_leave; } + have--; + hold += input[next++] << bits; + bits += 8; + } + //===// + strm.adler = state.check = zswap32(hold); + //=== INITBITS(); + hold = 0; + bits = 0; + //===// + state.mode = DICT; + /* falls through */ + case DICT: + if (state.havedict === 0) { + //--- RESTORE() --- + strm.next_out = put; + strm.avail_out = left; + strm.next_in = next; + strm.avail_in = have; + state.hold = hold; + state.bits = bits; + //--- + return Z_NEED_DICT; + } + strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/; + state.mode = TYPE; + /* falls through */ + case TYPE: + if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; } + /* falls through */ + case TYPEDO: + if (state.last) { + //--- BYTEBITS() ---// + hold >>>= bits & 7; + bits -= bits & 7; + //---// + state.mode = CHECK; + break; + } + //=== NEEDBITS(3); */ + while (bits < 3) { + if (have === 0) { break inf_leave; } + have--; + hold += input[next++] << bits; + bits += 8; + } + //===// + state.last = (hold & 0x01)/*BITS(1)*/; + //--- DROPBITS(1) ---// + hold >>>= 1; + bits -= 1; + //---// + + switch ((hold & 0x03)/*BITS(2)*/) { + case 0: /* stored block */ + //Tracev((stderr, "inflate: stored block%s\n", + // state.last ? " (last)" : "")); + state.mode = STORED; + break; + case 1: /* fixed block */ + fixedtables(state); + //Tracev((stderr, "inflate: fixed codes block%s\n", + // state.last ? " (last)" : "")); + state.mode = LEN_; /* decode codes */ + if (flush === Z_TREES) { + //--- DROPBITS(2) ---// + hold >>>= 2; + bits -= 2; + //---// + break inf_leave; + } + break; + case 2: /* dynamic block */ + //Tracev((stderr, "inflate: dynamic codes block%s\n", + // state.last ? " (last)" : "")); + state.mode = TABLE; + break; + case 3: + strm.msg = 'invalid block type'; + state.mode = BAD; + } + //--- DROPBITS(2) ---// + hold >>>= 2; + bits -= 2; + //---// + break; + case STORED: + //--- BYTEBITS() ---// /* go to byte boundary */ + hold >>>= bits & 7; + bits -= bits & 7; + //---// + //=== NEEDBITS(32); */ + while (bits < 32) { + if (have === 0) { break inf_leave; } + have--; + hold += input[next++] << bits; + bits += 8; + } + //===// + if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) { + strm.msg = 'invalid stored block lengths'; + state.mode = BAD; + break; + } + state.length = hold & 0xffff; + //Tracev((stderr, "inflate: stored length %u\n", + // state.length)); + //=== INITBITS(); + hold = 0; + bits = 0; + //===// + state.mode = COPY_; + if (flush === Z_TREES) { break inf_leave; } + /* falls through */ + case COPY_: + state.mode = COPY; + /* falls through */ + case COPY: + copy = state.length; + if (copy) { + if (copy > have) { copy = have; } + if (copy > left) { copy = left; } + if (copy === 0) { break inf_leave; } + //--- zmemcpy(put, next, copy); --- + utils.arraySet(output, input, next, copy, put); + //---// + have -= copy; + next += copy; + left -= copy; + put += copy; + state.length -= copy; + break; + } + //Tracev((stderr, "inflate: stored end\n")); + state.mode = TYPE; + break; + case TABLE: + //=== NEEDBITS(14); */ + while (bits < 14) { + if (have === 0) { break inf_leave; } + have--; + hold += input[next++] << bits; + bits += 8; + } + //===// + state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257; + //--- DROPBITS(5) ---// + hold >>>= 5; + bits -= 5; + //---// + state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1; + //--- DROPBITS(5) ---// + hold >>>= 5; + bits -= 5; + //---// + state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4; + //--- DROPBITS(4) ---// + hold >>>= 4; + bits -= 4; + //---// +//#ifndef PKZIP_BUG_WORKAROUND + if (state.nlen > 286 || state.ndist > 30) { + strm.msg = 'too many length or distance symbols'; + state.mode = BAD; + break; + } +//#endif + //Tracev((stderr, "inflate: table sizes ok\n")); + state.have = 0; + state.mode = LENLENS; + /* falls through */ + case LENLENS: + while (state.have < state.ncode) { + //=== NEEDBITS(3); + while (bits < 3) { + if (have === 0) { break inf_leave; } + have--; + hold += input[next++] << bits; + bits += 8; + } + //===// + state.lens[order[state.have++]] = (hold & 0x07);//BITS(3); + //--- DROPBITS(3) ---// + hold >>>= 3; + bits -= 3; + //---// + } + while (state.have < 19) { + state.lens[order[state.have++]] = 0; + } + // We have separate tables & no pointers. 2 commented lines below not needed. + //state.next = state.codes; + //state.lencode = state.next; + // Switch to use dynamic table + state.lencode = state.lendyn; + state.lenbits = 7; + + opts = { bits: state.lenbits }; + ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts); + state.lenbits = opts.bits; + + if (ret) { + strm.msg = 'invalid code lengths set'; + state.mode = BAD; + break; + } + //Tracev((stderr, "inflate: code lengths ok\n")); + state.have = 0; + state.mode = CODELENS; + /* falls through */ + case CODELENS: + while (state.have < state.nlen + state.ndist) { + for (;;) { + here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/ + here_bits = here >>> 24; + here_op = (here >>> 16) & 0xff; + here_val = here & 0xffff; + + if ((here_bits) <= bits) { break; } + //--- PULLBYTE() ---// + if (have === 0) { break inf_leave; } + have--; + hold += input[next++] << bits; + bits += 8; + //---// + } + if (here_val < 16) { + //--- DROPBITS(here.bits) ---// + hold >>>= here_bits; + bits -= here_bits; + //---// + state.lens[state.have++] = here_val; + } + else { + if (here_val === 16) { + //=== NEEDBITS(here.bits + 2); + n = here_bits + 2; + while (bits < n) { + if (have === 0) { break inf_leave; } + have--; + hold += input[next++] << bits; + bits += 8; + } + //===// + //--- DROPBITS(here.bits) ---// + hold >>>= here_bits; + bits -= here_bits; + //---// + if (state.have === 0) { + strm.msg = 'invalid bit length repeat'; + state.mode = BAD; + break; + } + len = state.lens[state.have - 1]; + copy = 3 + (hold & 0x03);//BITS(2); + //--- DROPBITS(2) ---// + hold >>>= 2; + bits -= 2; + //---// + } + else if (here_val === 17) { + //=== NEEDBITS(here.bits + 3); + n = here_bits + 3; + while (bits < n) { + if (have === 0) { break inf_leave; } + have--; + hold += input[next++] << bits; + bits += 8; + } + //===// + //--- DROPBITS(here.bits) ---// + hold >>>= here_bits; + bits -= here_bits; + //---// + len = 0; + copy = 3 + (hold & 0x07);//BITS(3); + //--- DROPBITS(3) ---// + hold >>>= 3; + bits -= 3; + //---// + } + else { + //=== NEEDBITS(here.bits + 7); + n = here_bits + 7; + while (bits < n) { + if (have === 0) { break inf_leave; } + have--; + hold += input[next++] << bits; + bits += 8; + } + //===// + //--- DROPBITS(here.bits) ---// + hold >>>= here_bits; + bits -= here_bits; + //---// + len = 0; + copy = 11 + (hold & 0x7f);//BITS(7); + //--- DROPBITS(7) ---// + hold >>>= 7; + bits -= 7; + //---// + } + if (state.have + copy > state.nlen + state.ndist) { + strm.msg = 'invalid bit length repeat'; + state.mode = BAD; + break; + } + while (copy--) { + state.lens[state.have++] = len; + } + } + } + + /* handle error breaks in while */ + if (state.mode === BAD) { break; } + + /* check for end-of-block code (better have one) */ + if (state.lens[256] === 0) { + strm.msg = 'invalid code -- missing end-of-block'; + state.mode = BAD; + break; + } + + /* build code tables -- note: do not change the lenbits or distbits + values here (9 and 6) without reading the comments in inftrees.h + concerning the ENOUGH constants, which depend on those values */ + state.lenbits = 9; + + opts = { bits: state.lenbits }; + ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts); + // We have separate tables & no pointers. 2 commented lines below not needed. + // state.next_index = opts.table_index; + state.lenbits = opts.bits; + // state.lencode = state.next; + + if (ret) { + strm.msg = 'invalid literal/lengths set'; + state.mode = BAD; + break; + } + + state.distbits = 6; + //state.distcode.copy(state.codes); + // Switch to use dynamic table + state.distcode = state.distdyn; + opts = { bits: state.distbits }; + ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts); + // We have separate tables & no pointers. 2 commented lines below not needed. + // state.next_index = opts.table_index; + state.distbits = opts.bits; + // state.distcode = state.next; + + if (ret) { + strm.msg = 'invalid distances set'; + state.mode = BAD; + break; + } + //Tracev((stderr, 'inflate: codes ok\n')); + state.mode = LEN_; + if (flush === Z_TREES) { break inf_leave; } + /* falls through */ + case LEN_: + state.mode = LEN; + /* falls through */ + case LEN: + if (have >= 6 && left >= 258) { + //--- RESTORE() --- + strm.next_out = put; + strm.avail_out = left; + strm.next_in = next; + strm.avail_in = have; + state.hold = hold; + state.bits = bits; + //--- + inflate_fast(strm, _out); + //--- LOAD() --- + put = strm.next_out; + output = strm.output; + left = strm.avail_out; + next = strm.next_in; + input = strm.input; + have = strm.avail_in; + hold = state.hold; + bits = state.bits; + //--- + + if (state.mode === TYPE) { + state.back = -1; + } + break; + } + state.back = 0; + for (;;) { + here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/ + here_bits = here >>> 24; + here_op = (here >>> 16) & 0xff; + here_val = here & 0xffff; + + if (here_bits <= bits) { break; } + //--- PULLBYTE() ---// + if (have === 0) { break inf_leave; } + have--; + hold += input[next++] << bits; + bits += 8; + //---// + } + if (here_op && (here_op & 0xf0) === 0) { + last_bits = here_bits; + last_op = here_op; + last_val = here_val; + for (;;) { + here = state.lencode[last_val + + ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)]; + here_bits = here >>> 24; + here_op = (here >>> 16) & 0xff; + here_val = here & 0xffff; + + if ((last_bits + here_bits) <= bits) { break; } + //--- PULLBYTE() ---// + if (have === 0) { break inf_leave; } + have--; + hold += input[next++] << bits; + bits += 8; + //---// + } + //--- DROPBITS(last.bits) ---// + hold >>>= last_bits; + bits -= last_bits; + //---// + state.back += last_bits; + } + //--- DROPBITS(here.bits) ---// + hold >>>= here_bits; + bits -= here_bits; + //---// + state.back += here_bits; + state.length = here_val; + if (here_op === 0) { + //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? + // "inflate: literal '%c'\n" : + // "inflate: literal 0x%02x\n", here.val)); + state.mode = LIT; + break; + } + if (here_op & 32) { + //Tracevv((stderr, "inflate: end of block\n")); + state.back = -1; + state.mode = TYPE; + break; + } + if (here_op & 64) { + strm.msg = 'invalid literal/length code'; + state.mode = BAD; + break; + } + state.extra = here_op & 15; + state.mode = LENEXT; + /* falls through */ + case LENEXT: + if (state.extra) { + //=== NEEDBITS(state.extra); + n = state.extra; + while (bits < n) { + if (have === 0) { break inf_leave; } + have--; + hold += input[next++] << bits; + bits += 8; + } + //===// + state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/; + //--- DROPBITS(state.extra) ---// + hold >>>= state.extra; + bits -= state.extra; + //---// + state.back += state.extra; + } + //Tracevv((stderr, "inflate: length %u\n", state.length)); + state.was = state.length; + state.mode = DIST; + /* falls through */ + case DIST: + for (;;) { + here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/ + here_bits = here >>> 24; + here_op = (here >>> 16) & 0xff; + here_val = here & 0xffff; + + if ((here_bits) <= bits) { break; } + //--- PULLBYTE() ---// + if (have === 0) { break inf_leave; } + have--; + hold += input[next++] << bits; + bits += 8; + //---// + } + if ((here_op & 0xf0) === 0) { + last_bits = here_bits; + last_op = here_op; + last_val = here_val; + for (;;) { + here = state.distcode[last_val + + ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)]; + here_bits = here >>> 24; + here_op = (here >>> 16) & 0xff; + here_val = here & 0xffff; + + if ((last_bits + here_bits) <= bits) { break; } + //--- PULLBYTE() ---// + if (have === 0) { break inf_leave; } + have--; + hold += input[next++] << bits; + bits += 8; + //---// + } + //--- DROPBITS(last.bits) ---// + hold >>>= last_bits; + bits -= last_bits; + //---// + state.back += last_bits; + } + //--- DROPBITS(here.bits) ---// + hold >>>= here_bits; + bits -= here_bits; + //---// + state.back += here_bits; + if (here_op & 64) { + strm.msg = 'invalid distance code'; + state.mode = BAD; + break; + } + state.offset = here_val; + state.extra = (here_op) & 15; + state.mode = DISTEXT; + /* falls through */ + case DISTEXT: + if (state.extra) { + //=== NEEDBITS(state.extra); + n = state.extra; + while (bits < n) { + if (have === 0) { break inf_leave; } + have--; + hold += input[next++] << bits; + bits += 8; + } + //===// + state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/; + //--- DROPBITS(state.extra) ---// + hold >>>= state.extra; + bits -= state.extra; + //---// + state.back += state.extra; + } +//#ifdef INFLATE_STRICT + if (state.offset > state.dmax) { + strm.msg = 'invalid distance too far back'; + state.mode = BAD; + break; + } +//#endif + //Tracevv((stderr, "inflate: distance %u\n", state.offset)); + state.mode = MATCH; + /* falls through */ + case MATCH: + if (left === 0) { break inf_leave; } + copy = _out - left; + if (state.offset > copy) { /* copy from window */ + copy = state.offset - copy; + if (copy > state.whave) { + if (state.sane) { + strm.msg = 'invalid distance too far back'; + state.mode = BAD; + break; + } +// (!) This block is disabled in zlib defaults, +// don't enable it for binary compatibility +//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR +// Trace((stderr, "inflate.c too far\n")); +// copy -= state.whave; +// if (copy > state.length) { copy = state.length; } +// if (copy > left) { copy = left; } +// left -= copy; +// state.length -= copy; +// do { +// output[put++] = 0; +// } while (--copy); +// if (state.length === 0) { state.mode = LEN; } +// break; +//#endif + } + if (copy > state.wnext) { + copy -= state.wnext; + from = state.wsize - copy; + } + else { + from = state.wnext - copy; + } + if (copy > state.length) { copy = state.length; } + from_source = state.window; + } + else { /* copy from output */ + from_source = output; + from = put - state.offset; + copy = state.length; + } + if (copy > left) { copy = left; } + left -= copy; + state.length -= copy; + do { + output[put++] = from_source[from++]; + } while (--copy); + if (state.length === 0) { state.mode = LEN; } + break; + case LIT: + if (left === 0) { break inf_leave; } + output[put++] = state.length; + left--; + state.mode = LEN; + break; + case CHECK: + if (state.wrap) { + //=== NEEDBITS(32); + while (bits < 32) { + if (have === 0) { break inf_leave; } + have--; + // Use '|' instead of '+' to make sure that result is signed + hold |= input[next++] << bits; + bits += 8; + } + //===// + _out -= left; + strm.total_out += _out; + state.total += _out; + if (_out) { + strm.adler = state.check = + /*UPDATE(state.check, put - _out, _out);*/ + (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out)); + + } + _out = left; + // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too + if ((state.flags ? hold : zswap32(hold)) !== state.check) { + strm.msg = 'incorrect data check'; + state.mode = BAD; + break; + } + //=== INITBITS(); + hold = 0; + bits = 0; + //===// + //Tracev((stderr, "inflate: check matches trailer\n")); + } + state.mode = LENGTH; + /* falls through */ + case LENGTH: + if (state.wrap && state.flags) { + //=== NEEDBITS(32); + while (bits < 32) { + if (have === 0) { break inf_leave; } + have--; + hold += input[next++] << bits; + bits += 8; + } + //===// + if (hold !== (state.total & 0xffffffff)) { + strm.msg = 'incorrect length check'; + state.mode = BAD; + break; + } + //=== INITBITS(); + hold = 0; + bits = 0; + //===// + //Tracev((stderr, "inflate: length matches trailer\n")); + } + state.mode = DONE; + /* falls through */ + case DONE: + ret = Z_STREAM_END; + break inf_leave; + case BAD: + ret = Z_DATA_ERROR; + break inf_leave; + case MEM: + return Z_MEM_ERROR; + case SYNC: + /* falls through */ + default: + return Z_STREAM_ERROR; + } + } + + // inf_leave <- here is real place for "goto inf_leave", emulated via "break inf_leave" + + /* + Return from inflate(), updating the total counts and the check value. + If there was no progress during the inflate() call, return a buffer + error. Call updatewindow() to create and/or update the window state. + Note: a memory error from inflate() is non-recoverable. + */ + + //--- RESTORE() --- + strm.next_out = put; + strm.avail_out = left; + strm.next_in = next; + strm.avail_in = have; + state.hold = hold; + state.bits = bits; + //--- + + if (state.wsize || (_out !== strm.avail_out && state.mode < BAD && + (state.mode < CHECK || flush !== Z_FINISH))) { + if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) { + state.mode = MEM; + return Z_MEM_ERROR; + } + } + _in -= strm.avail_in; + _out -= strm.avail_out; + strm.total_in += _in; + strm.total_out += _out; + state.total += _out; + if (state.wrap && _out) { + strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/ + (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out)); + } + strm.data_type = state.bits + (state.last ? 64 : 0) + + (state.mode === TYPE ? 128 : 0) + + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0); + if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) { + ret = Z_BUF_ERROR; + } + return ret; +} + +function inflateEnd(strm) { + + if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) { + return Z_STREAM_ERROR; + } + + var state = strm.state; + if (state.window) { + state.window = null; + } + strm.state = null; + return Z_OK; +} + +function inflateGetHeader(strm, head) { + var state; + + /* check state */ + if (!strm || !strm.state) { return Z_STREAM_ERROR; } + state = strm.state; + if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; } + + /* save header structure */ + state.head = head; + head.done = false; + return Z_OK; +} + +function inflateSetDictionary(strm, dictionary) { + var dictLength = dictionary.length; + + var state; + var dictid; + var ret; + + /* check state */ + if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; } + state = strm.state; + + if (state.wrap !== 0 && state.mode !== DICT) { + return Z_STREAM_ERROR; + } + + /* check for correct dictionary identifier */ + if (state.mode === DICT) { + dictid = 1; /* adler32(0, null, 0)*/ + /* dictid = adler32(dictid, dictionary, dictLength); */ + dictid = adler32(dictid, dictionary, dictLength, 0); + if (dictid !== state.check) { + return Z_DATA_ERROR; + } + } + /* copy dictionary to window using updatewindow(), which will amend the + existing dictionary if appropriate */ + ret = updatewindow(strm, dictionary, dictLength, dictLength); + if (ret) { + state.mode = MEM; + return Z_MEM_ERROR; + } + state.havedict = 1; + // Tracev((stderr, "inflate: dictionary set\n")); + return Z_OK; +} + +exports.inflateReset = inflateReset; +exports.inflateReset2 = inflateReset2; +exports.inflateResetKeep = inflateResetKeep; +exports.inflateInit = inflateInit; +exports.inflateInit2 = inflateInit2; +exports.inflate = inflate; +exports.inflateEnd = inflateEnd; +exports.inflateGetHeader = inflateGetHeader; +exports.inflateSetDictionary = inflateSetDictionary; +exports.inflateInfo = 'pako inflate (from Nodeca project)'; + +/* Not implemented +exports.inflateCopy = inflateCopy; +exports.inflateGetDictionary = inflateGetDictionary; +exports.inflateMark = inflateMark; +exports.inflatePrime = inflatePrime; +exports.inflateSync = inflateSync; +exports.inflateSyncPoint = inflateSyncPoint; +exports.inflateUndermine = inflateUndermine; +*/ + +},{"../utils/common":26,"./adler32":28,"./crc32":30,"./inffast":33,"./inftrees":35}],35:[function(require,module,exports){ +'use strict'; + +// (C) 1995-2013 Jean-loup Gailly and Mark Adler +// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would be +// appreciated but is not required. +// 2. Altered source versions must be plainly marked as such, and must not be +// misrepresented as being the original software. +// 3. This notice may not be removed or altered from any source distribution. + +var utils = require('../utils/common'); + +var MAXBITS = 15; +var ENOUGH_LENS = 852; +var ENOUGH_DISTS = 592; +//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS); + +var CODES = 0; +var LENS = 1; +var DISTS = 2; + +var lbase = [ /* Length codes 257..285 base */ + 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 +]; + +var lext = [ /* Length codes 257..285 extra */ + 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 +]; + +var dbase = [ /* Distance codes 0..29 base */ + 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 +]; + +var dext = [ /* Distance codes 0..29 extra */ + 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 +]; + +module.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts) +{ + var bits = opts.bits; + //here = opts.here; /* table entry for duplication */ + + var len = 0; /* a code's length in bits */ + var sym = 0; /* index of code symbols */ + var min = 0, max = 0; /* minimum and maximum code lengths */ + var root = 0; /* number of index bits for root table */ + var curr = 0; /* number of index bits for current table */ + var drop = 0; /* code bits to drop for sub-table */ + var left = 0; /* number of prefix codes available */ + var used = 0; /* code entries in table used */ + var huff = 0; /* Huffman code */ + var incr; /* for incrementing code, index */ + var fill; /* index for replicating entries */ + var low; /* low bits for current root entry */ + var mask; /* mask for low root bits */ + var next; /* next available space in table */ + var base = null; /* base value table to use */ + var base_index = 0; +// var shoextra; /* extra bits table to use */ + var end; /* use base and extra for symbol > end */ + var count = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */ + var offs = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */ + var extra = null; + var extra_index = 0; + + var here_bits, here_op, here_val; + + /* + Process a set of code lengths to create a canonical Huffman code. The + code lengths are lens[0..codes-1]. Each length corresponds to the + symbols 0..codes-1. The Huffman code is generated by first sorting the + symbols by length from short to long, and retaining the symbol order + for codes with equal lengths. Then the code starts with all zero bits + for the first code of the shortest length, and the codes are integer + increments for the same length, and zeros are appended as the length + increases. For the deflate format, these bits are stored backwards + from their more natural integer increment ordering, and so when the + decoding tables are built in the large loop below, the integer codes + are incremented backwards. + + This routine assumes, but does not check, that all of the entries in + lens[] are in the range 0..MAXBITS. The caller must assure this. + 1..MAXBITS is interpreted as that code length. zero means that that + symbol does not occur in this code. + + The codes are sorted by computing a count of codes for each length, + creating from that a table of starting indices for each length in the + sorted table, and then entering the symbols in order in the sorted + table. The sorted table is work[], with that space being provided by + the caller. + + The length counts are used for other purposes as well, i.e. finding + the minimum and maximum length codes, determining if there are any + codes at all, checking for a valid set of lengths, and looking ahead + at length counts to determine sub-table sizes when building the + decoding tables. + */ + + /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ + for (len = 0; len <= MAXBITS; len++) { + count[len] = 0; + } + for (sym = 0; sym < codes; sym++) { + count[lens[lens_index + sym]]++; + } + + /* bound code lengths, force root to be within code lengths */ + root = bits; + for (max = MAXBITS; max >= 1; max--) { + if (count[max] !== 0) { break; } + } + if (root > max) { + root = max; + } + if (max === 0) { /* no symbols to code at all */ + //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */ + //table.bits[opts.table_index] = 1; //here.bits = (var char)1; + //table.val[opts.table_index++] = 0; //here.val = (var short)0; + table[table_index++] = (1 << 24) | (64 << 16) | 0; + + + //table.op[opts.table_index] = 64; + //table.bits[opts.table_index] = 1; + //table.val[opts.table_index++] = 0; + table[table_index++] = (1 << 24) | (64 << 16) | 0; + + opts.bits = 1; + return 0; /* no symbols, but wait for decoding to report error */ + } + for (min = 1; min < max; min++) { + if (count[min] !== 0) { break; } + } + if (root < min) { + root = min; + } + + /* check for an over-subscribed or incomplete set of lengths */ + left = 1; + for (len = 1; len <= MAXBITS; len++) { + left <<= 1; + left -= count[len]; + if (left < 0) { + return -1; + } /* over-subscribed */ + } + if (left > 0 && (type === CODES || max !== 1)) { + return -1; /* incomplete set */ + } + + /* generate offsets into symbol table for each length for sorting */ + offs[1] = 0; + for (len = 1; len < MAXBITS; len++) { + offs[len + 1] = offs[len] + count[len]; + } + + /* sort symbols by length, by symbol order within each length */ + for (sym = 0; sym < codes; sym++) { + if (lens[lens_index + sym] !== 0) { + work[offs[lens[lens_index + sym]]++] = sym; + } + } + + /* + Create and fill in decoding tables. In this loop, the table being + filled is at next and has curr index bits. The code being used is huff + with length len. That code is converted to an index by dropping drop + bits off of the bottom. For codes where len is less than drop + curr, + those top drop + curr - len bits are incremented through all values to + fill the table with replicated entries. + + root is the number of index bits for the root table. When len exceeds + root, sub-tables are created pointed to by the root entry with an index + of the low root bits of huff. This is saved in low to check for when a + new sub-table should be started. drop is zero when the root table is + being filled, and drop is root when sub-tables are being filled. + + When a new sub-table is needed, it is necessary to look ahead in the + code lengths to determine what size sub-table is needed. The length + counts are used for this, and so count[] is decremented as codes are + entered in the tables. + + used keeps track of how many table entries have been allocated from the + provided *table space. It is checked for LENS and DIST tables against + the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in + the initial root table size constants. See the comments in inftrees.h + for more information. + + sym increments through all symbols, and the loop terminates when + all codes of length max, i.e. all codes, have been processed. This + routine permits incomplete codes, so another loop after this one fills + in the rest of the decoding tables with invalid code markers. + */ + + /* set up for code type */ + // poor man optimization - use if-else instead of switch, + // to avoid deopts in old v8 + if (type === CODES) { + base = extra = work; /* dummy value--not used */ + end = 19; + + } else if (type === LENS) { + base = lbase; + base_index -= 257; + extra = lext; + extra_index -= 257; + end = 256; + + } else { /* DISTS */ + base = dbase; + extra = dext; + end = -1; + } + + /* initialize opts for loop */ + huff = 0; /* starting code */ + sym = 0; /* starting code symbol */ + len = min; /* starting code length */ + next = table_index; /* current table to fill in */ + curr = root; /* current table index bits */ + drop = 0; /* current bits to drop from code for index */ + low = -1; /* trigger new sub-table when len > root */ + used = 1 << root; /* use root table entries */ + mask = used - 1; /* mask for comparing low */ + + /* check available table space */ + if ((type === LENS && used > ENOUGH_LENS) || + (type === DISTS && used > ENOUGH_DISTS)) { + return 1; + } + + /* process all codes and make table entries */ + for (;;) { + /* create table entry */ + here_bits = len - drop; + if (work[sym] < end) { + here_op = 0; + here_val = work[sym]; + } + else if (work[sym] > end) { + here_op = extra[extra_index + work[sym]]; + here_val = base[base_index + work[sym]]; + } + else { + here_op = 32 + 64; /* end of block */ + here_val = 0; + } + + /* replicate for those indices with low len bits equal to huff */ + incr = 1 << (len - drop); + fill = 1 << curr; + min = fill; /* save offset to next table */ + do { + fill -= incr; + table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0; + } while (fill !== 0); + + /* backwards increment the len-bit code huff */ + incr = 1 << (len - 1); + while (huff & incr) { + incr >>= 1; + } + if (incr !== 0) { + huff &= incr - 1; + huff += incr; + } else { + huff = 0; + } + + /* go to next symbol, update count, len */ + sym++; + if (--count[len] === 0) { + if (len === max) { break; } + len = lens[lens_index + work[sym]]; + } + + /* create new sub-table if needed */ + if (len > root && (huff & mask) !== low) { + /* if first time, transition to sub-tables */ + if (drop === 0) { + drop = root; + } + + /* increment past last table */ + next += min; /* here min is 1 << curr */ + + /* determine length of next table */ + curr = len - drop; + left = 1 << curr; + while (curr + drop < max) { + left -= count[curr + drop]; + if (left <= 0) { break; } + curr++; + left <<= 1; + } + + /* check for enough space */ + used += 1 << curr; + if ((type === LENS && used > ENOUGH_LENS) || + (type === DISTS && used > ENOUGH_DISTS)) { + return 1; + } + + /* point entry in root table to sub-table */ + low = huff & mask; + /*table.op[low] = curr; + table.bits[low] = root; + table.val[low] = next - opts.table_index;*/ + table[low] = (root << 24) | (curr << 16) | (next - table_index) |0; + } + } + + /* fill in remaining table entry if code is incomplete (guaranteed to have + at most one remaining entry, since if the code is incomplete, the + maximum code length that was allowed to get this far is one bit) */ + if (huff !== 0) { + //table.op[next + huff] = 64; /* invalid code marker */ + //table.bits[next + huff] = len - drop; + //table.val[next + huff] = 0; + table[next + huff] = ((len - drop) << 24) | (64 << 16) |0; + } + + /* set return parameters */ + //opts.table_index += used; + opts.bits = root; + return 0; +}; + +},{"../utils/common":26}],36:[function(require,module,exports){ +'use strict'; + +// (C) 1995-2013 Jean-loup Gailly and Mark Adler +// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would be +// appreciated but is not required. +// 2. Altered source versions must be plainly marked as such, and must not be +// misrepresented as being the original software. +// 3. This notice may not be removed or altered from any source distribution. + +module.exports = { + 2: 'need dictionary', /* Z_NEED_DICT 2 */ + 1: 'stream end', /* Z_STREAM_END 1 */ + 0: '', /* Z_OK 0 */ + '-1': 'file error', /* Z_ERRNO (-1) */ + '-2': 'stream error', /* Z_STREAM_ERROR (-2) */ + '-3': 'data error', /* Z_DATA_ERROR (-3) */ + '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */ + '-5': 'buffer error', /* Z_BUF_ERROR (-5) */ + '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */ +}; + +},{}],37:[function(require,module,exports){ +'use strict'; + +// (C) 1995-2013 Jean-loup Gailly and Mark Adler +// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would be +// appreciated but is not required. +// 2. Altered source versions must be plainly marked as such, and must not be +// misrepresented as being the original software. +// 3. This notice may not be removed or altered from any source distribution. + +/* eslint-disable space-unary-ops */ + +var utils = require('../utils/common'); + +/* Public constants ==========================================================*/ +/* ===========================================================================*/ + + +//var Z_FILTERED = 1; +//var Z_HUFFMAN_ONLY = 2; +//var Z_RLE = 3; +var Z_FIXED = 4; +//var Z_DEFAULT_STRATEGY = 0; + +/* Possible values of the data_type field (though see inflate()) */ +var Z_BINARY = 0; +var Z_TEXT = 1; +//var Z_ASCII = 1; // = Z_TEXT +var Z_UNKNOWN = 2; + +/*============================================================================*/ + + +function zero(buf) { var len = buf.length; while (--len >= 0) { buf[len] = 0; } } + +// From zutil.h + +var STORED_BLOCK = 0; +var STATIC_TREES = 1; +var DYN_TREES = 2; +/* The three kinds of block type */ + +var MIN_MATCH = 3; +var MAX_MATCH = 258; +/* The minimum and maximum match lengths */ + +// From deflate.h +/* =========================================================================== + * Internal compression state. + */ + +var LENGTH_CODES = 29; +/* number of length codes, not counting the special END_BLOCK code */ + +var LITERALS = 256; +/* number of literal bytes 0..255 */ + +var L_CODES = LITERALS + 1 + LENGTH_CODES; +/* number of Literal or Length codes, including the END_BLOCK code */ + +var D_CODES = 30; +/* number of distance codes */ + +var BL_CODES = 19; +/* number of codes used to transfer the bit lengths */ + +var HEAP_SIZE = 2 * L_CODES + 1; +/* maximum heap size */ + +var MAX_BITS = 15; +/* All codes must not exceed MAX_BITS bits */ + +var Buf_size = 16; +/* size of bit buffer in bi_buf */ + + +/* =========================================================================== + * Constants + */ + +var MAX_BL_BITS = 7; +/* Bit length codes must not exceed MAX_BL_BITS bits */ + +var END_BLOCK = 256; +/* end of block literal code */ + +var REP_3_6 = 16; +/* repeat previous bit length 3-6 times (2 bits of repeat count) */ + +var REPZ_3_10 = 17; +/* repeat a zero length 3-10 times (3 bits of repeat count) */ + +var REPZ_11_138 = 18; +/* repeat a zero length 11-138 times (7 bits of repeat count) */ + +/* eslint-disable comma-spacing,array-bracket-spacing */ +var extra_lbits = /* extra bits for each length code */ + [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]; + +var extra_dbits = /* extra bits for each distance code */ + [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]; + +var extra_blbits = /* extra bits for each bit length code */ + [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]; + +var bl_order = + [16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]; +/* eslint-enable comma-spacing,array-bracket-spacing */ + +/* The lengths of the bit length codes are sent in order of decreasing + * probability, to avoid transmitting the lengths for unused bit length codes. + */ + +/* =========================================================================== + * Local data. These are initialized only once. + */ + +// We pre-fill arrays with 0 to avoid uninitialized gaps + +var DIST_CODE_LEN = 512; /* see definition of array dist_code below */ + +// !!!! Use flat array instead of structure, Freq = i*2, Len = i*2+1 +var static_ltree = new Array((L_CODES + 2) * 2); +zero(static_ltree); +/* The static literal tree. Since the bit lengths are imposed, there is no + * need for the L_CODES extra codes used during heap construction. However + * The codes 286 and 287 are needed to build a canonical tree (see _tr_init + * below). + */ + +var static_dtree = new Array(D_CODES * 2); +zero(static_dtree); +/* The static distance tree. (Actually a trivial tree since all codes use + * 5 bits.) + */ + +var _dist_code = new Array(DIST_CODE_LEN); +zero(_dist_code); +/* Distance codes. The first 256 values correspond to the distances + * 3 .. 258, the last 256 values correspond to the top 8 bits of + * the 15 bit distances. + */ + +var _length_code = new Array(MAX_MATCH - MIN_MATCH + 1); +zero(_length_code); +/* length code for each normalized match length (0 == MIN_MATCH) */ + +var base_length = new Array(LENGTH_CODES); +zero(base_length); +/* First normalized length for each code (0 = MIN_MATCH) */ + +var base_dist = new Array(D_CODES); +zero(base_dist); +/* First normalized distance for each code (0 = distance of 1) */ + + +function StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) { + + this.static_tree = static_tree; /* static tree or NULL */ + this.extra_bits = extra_bits; /* extra bits for each code or NULL */ + this.extra_base = extra_base; /* base index for extra_bits */ + this.elems = elems; /* max number of elements in the tree */ + this.max_length = max_length; /* max bit length for the codes */ + + // show if `static_tree` has data or dummy - needed for monomorphic objects + this.has_stree = static_tree && static_tree.length; +} + + +var static_l_desc; +var static_d_desc; +var static_bl_desc; + + +function TreeDesc(dyn_tree, stat_desc) { + this.dyn_tree = dyn_tree; /* the dynamic tree */ + this.max_code = 0; /* largest code with non zero frequency */ + this.stat_desc = stat_desc; /* the corresponding static tree */ +} + + + +function d_code(dist) { + return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)]; +} + + +/* =========================================================================== + * Output a short LSB first on the stream. + * IN assertion: there is enough room in pendingBuf. + */ +function put_short(s, w) { +// put_byte(s, (uch)((w) & 0xff)); +// put_byte(s, (uch)((ush)(w) >> 8)); + s.pending_buf[s.pending++] = (w) & 0xff; + s.pending_buf[s.pending++] = (w >>> 8) & 0xff; +} + + +/* =========================================================================== + * Send a value on a given number of bits. + * IN assertion: length <= 16 and value fits in length bits. + */ +function send_bits(s, value, length) { + if (s.bi_valid > (Buf_size - length)) { + s.bi_buf |= (value << s.bi_valid) & 0xffff; + put_short(s, s.bi_buf); + s.bi_buf = value >> (Buf_size - s.bi_valid); + s.bi_valid += length - Buf_size; + } else { + s.bi_buf |= (value << s.bi_valid) & 0xffff; + s.bi_valid += length; + } +} + + +function send_code(s, c, tree) { + send_bits(s, tree[c * 2]/*.Code*/, tree[c * 2 + 1]/*.Len*/); +} + + +/* =========================================================================== + * Reverse the first len bits of a code, using straightforward code (a faster + * method would use a table) + * IN assertion: 1 <= len <= 15 + */ +function bi_reverse(code, len) { + var res = 0; + do { + res |= code & 1; + code >>>= 1; + res <<= 1; + } while (--len > 0); + return res >>> 1; +} + + +/* =========================================================================== + * Flush the bit buffer, keeping at most 7 bits in it. + */ +function bi_flush(s) { + if (s.bi_valid === 16) { + put_short(s, s.bi_buf); + s.bi_buf = 0; + s.bi_valid = 0; + + } else if (s.bi_valid >= 8) { + s.pending_buf[s.pending++] = s.bi_buf & 0xff; + s.bi_buf >>= 8; + s.bi_valid -= 8; + } +} + + +/* =========================================================================== + * Compute the optimal bit lengths for a tree and update the total bit length + * for the current block. + * IN assertion: the fields freq and dad are set, heap[heap_max] and + * above are the tree nodes sorted by increasing frequency. + * OUT assertions: the field len is set to the optimal bit length, the + * array bl_count contains the frequencies for each bit length. + * The length opt_len is updated; static_len is also updated if stree is + * not null. + */ +function gen_bitlen(s, desc) +// deflate_state *s; +// tree_desc *desc; /* the tree descriptor */ +{ + var tree = desc.dyn_tree; + var max_code = desc.max_code; + var stree = desc.stat_desc.static_tree; + var has_stree = desc.stat_desc.has_stree; + var extra = desc.stat_desc.extra_bits; + var base = desc.stat_desc.extra_base; + var max_length = desc.stat_desc.max_length; + var h; /* heap index */ + var n, m; /* iterate over the tree elements */ + var bits; /* bit length */ + var xbits; /* extra bits */ + var f; /* frequency */ + var overflow = 0; /* number of elements with bit length too large */ + + for (bits = 0; bits <= MAX_BITS; bits++) { + s.bl_count[bits] = 0; + } + + /* In a first pass, compute the optimal bit lengths (which may + * overflow in the case of the bit length tree). + */ + tree[s.heap[s.heap_max] * 2 + 1]/*.Len*/ = 0; /* root of the heap */ + + for (h = s.heap_max + 1; h < HEAP_SIZE; h++) { + n = s.heap[h]; + bits = tree[tree[n * 2 + 1]/*.Dad*/ * 2 + 1]/*.Len*/ + 1; + if (bits > max_length) { + bits = max_length; + overflow++; + } + tree[n * 2 + 1]/*.Len*/ = bits; + /* We overwrite tree[n].Dad which is no longer needed */ + + if (n > max_code) { continue; } /* not a leaf node */ + + s.bl_count[bits]++; + xbits = 0; + if (n >= base) { + xbits = extra[n - base]; + } + f = tree[n * 2]/*.Freq*/; + s.opt_len += f * (bits + xbits); + if (has_stree) { + s.static_len += f * (stree[n * 2 + 1]/*.Len*/ + xbits); + } + } + if (overflow === 0) { return; } + + // Trace((stderr,"\nbit length overflow\n")); + /* This happens for example on obj2 and pic of the Calgary corpus */ + + /* Find the first bit length which could increase: */ + do { + bits = max_length - 1; + while (s.bl_count[bits] === 0) { bits--; } + s.bl_count[bits]--; /* move one leaf down the tree */ + s.bl_count[bits + 1] += 2; /* move one overflow item as its brother */ + s.bl_count[max_length]--; + /* The brother of the overflow item also moves one step up, + * but this does not affect bl_count[max_length] + */ + overflow -= 2; + } while (overflow > 0); + + /* Now recompute all bit lengths, scanning in increasing frequency. + * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all + * lengths instead of fixing only the wrong ones. This idea is taken + * from 'ar' written by Haruhiko Okumura.) + */ + for (bits = max_length; bits !== 0; bits--) { + n = s.bl_count[bits]; + while (n !== 0) { + m = s.heap[--h]; + if (m > max_code) { continue; } + if (tree[m * 2 + 1]/*.Len*/ !== bits) { + // Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); + s.opt_len += (bits - tree[m * 2 + 1]/*.Len*/) * tree[m * 2]/*.Freq*/; + tree[m * 2 + 1]/*.Len*/ = bits; + } + n--; + } + } +} + + +/* =========================================================================== + * Generate the codes for a given tree and bit counts (which need not be + * optimal). + * IN assertion: the array bl_count contains the bit length statistics for + * the given tree and the field len is set for all tree elements. + * OUT assertion: the field code is set for all tree elements of non + * zero code length. + */ +function gen_codes(tree, max_code, bl_count) +// ct_data *tree; /* the tree to decorate */ +// int max_code; /* largest code with non zero frequency */ +// ushf *bl_count; /* number of codes at each bit length */ +{ + var next_code = new Array(MAX_BITS + 1); /* next code value for each bit length */ + var code = 0; /* running code value */ + var bits; /* bit index */ + var n; /* code index */ + + /* The distribution counts are first used to generate the code values + * without bit reversal. + */ + for (bits = 1; bits <= MAX_BITS; bits++) { + next_code[bits] = code = (code + bl_count[bits - 1]) << 1; + } + /* Check that the bit counts in bl_count are consistent. The last code + * must be all ones. + */ + //Assert (code + bl_count[MAX_BITS]-1 == (1< length code (0..28) */ + length = 0; + for (code = 0; code < LENGTH_CODES - 1; code++) { + base_length[code] = length; + for (n = 0; n < (1 << extra_lbits[code]); n++) { + _length_code[length++] = code; + } + } + //Assert (length == 256, "tr_static_init: length != 256"); + /* Note that the length 255 (match length 258) can be represented + * in two different ways: code 284 + 5 bits or code 285, so we + * overwrite length_code[255] to use the best encoding: + */ + _length_code[length - 1] = code; + + /* Initialize the mapping dist (0..32K) -> dist code (0..29) */ + dist = 0; + for (code = 0; code < 16; code++) { + base_dist[code] = dist; + for (n = 0; n < (1 << extra_dbits[code]); n++) { + _dist_code[dist++] = code; + } + } + //Assert (dist == 256, "tr_static_init: dist != 256"); + dist >>= 7; /* from now on, all distances are divided by 128 */ + for (; code < D_CODES; code++) { + base_dist[code] = dist << 7; + for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) { + _dist_code[256 + dist++] = code; + } + } + //Assert (dist == 256, "tr_static_init: 256+dist != 512"); + + /* Construct the codes of the static literal tree */ + for (bits = 0; bits <= MAX_BITS; bits++) { + bl_count[bits] = 0; + } + + n = 0; + while (n <= 143) { + static_ltree[n * 2 + 1]/*.Len*/ = 8; + n++; + bl_count[8]++; + } + while (n <= 255) { + static_ltree[n * 2 + 1]/*.Len*/ = 9; + n++; + bl_count[9]++; + } + while (n <= 279) { + static_ltree[n * 2 + 1]/*.Len*/ = 7; + n++; + bl_count[7]++; + } + while (n <= 287) { + static_ltree[n * 2 + 1]/*.Len*/ = 8; + n++; + bl_count[8]++; + } + /* Codes 286 and 287 do not exist, but we must include them in the + * tree construction to get a canonical Huffman tree (longest code + * all ones) + */ + gen_codes(static_ltree, L_CODES + 1, bl_count); + + /* The static distance tree is trivial: */ + for (n = 0; n < D_CODES; n++) { + static_dtree[n * 2 + 1]/*.Len*/ = 5; + static_dtree[n * 2]/*.Code*/ = bi_reverse(n, 5); + } + + // Now data ready and we can init static trees + static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS); + static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0, D_CODES, MAX_BITS); + static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS); + + //static_init_done = true; +} + + +/* =========================================================================== + * Initialize a new block. + */ +function init_block(s) { + var n; /* iterates over tree elements */ + + /* Initialize the trees. */ + for (n = 0; n < L_CODES; n++) { s.dyn_ltree[n * 2]/*.Freq*/ = 0; } + for (n = 0; n < D_CODES; n++) { s.dyn_dtree[n * 2]/*.Freq*/ = 0; } + for (n = 0; n < BL_CODES; n++) { s.bl_tree[n * 2]/*.Freq*/ = 0; } + + s.dyn_ltree[END_BLOCK * 2]/*.Freq*/ = 1; + s.opt_len = s.static_len = 0; + s.last_lit = s.matches = 0; +} + + +/* =========================================================================== + * Flush the bit buffer and align the output on a byte boundary + */ +function bi_windup(s) +{ + if (s.bi_valid > 8) { + put_short(s, s.bi_buf); + } else if (s.bi_valid > 0) { + //put_byte(s, (Byte)s->bi_buf); + s.pending_buf[s.pending++] = s.bi_buf; + } + s.bi_buf = 0; + s.bi_valid = 0; +} + +/* =========================================================================== + * Copy a stored block, storing first the length and its + * one's complement if requested. + */ +function copy_block(s, buf, len, header) +//DeflateState *s; +//charf *buf; /* the input data */ +//unsigned len; /* its length */ +//int header; /* true if block header must be written */ +{ + bi_windup(s); /* align on byte boundary */ + + if (header) { + put_short(s, len); + put_short(s, ~len); + } +// while (len--) { +// put_byte(s, *buf++); +// } + utils.arraySet(s.pending_buf, s.window, buf, len, s.pending); + s.pending += len; +} + +/* =========================================================================== + * Compares to subtrees, using the tree depth as tie breaker when + * the subtrees have equal frequency. This minimizes the worst case length. + */ +function smaller(tree, n, m, depth) { + var _n2 = n * 2; + var _m2 = m * 2; + return (tree[_n2]/*.Freq*/ < tree[_m2]/*.Freq*/ || + (tree[_n2]/*.Freq*/ === tree[_m2]/*.Freq*/ && depth[n] <= depth[m])); +} + +/* =========================================================================== + * Restore the heap property by moving down the tree starting at node k, + * exchanging a node with the smallest of its two sons if necessary, stopping + * when the heap property is re-established (each father smaller than its + * two sons). + */ +function pqdownheap(s, tree, k) +// deflate_state *s; +// ct_data *tree; /* the tree to restore */ +// int k; /* node to move down */ +{ + var v = s.heap[k]; + var j = k << 1; /* left son of k */ + while (j <= s.heap_len) { + /* Set j to the smallest of the two sons: */ + if (j < s.heap_len && + smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) { + j++; + } + /* Exit if v is smaller than both sons */ + if (smaller(tree, v, s.heap[j], s.depth)) { break; } + + /* Exchange v with the smallest son */ + s.heap[k] = s.heap[j]; + k = j; + + /* And continue down the tree, setting j to the left son of k */ + j <<= 1; + } + s.heap[k] = v; +} + + +// inlined manually +// var SMALLEST = 1; + +/* =========================================================================== + * Send the block data compressed using the given Huffman trees + */ +function compress_block(s, ltree, dtree) +// deflate_state *s; +// const ct_data *ltree; /* literal tree */ +// const ct_data *dtree; /* distance tree */ +{ + var dist; /* distance of matched string */ + var lc; /* match length or unmatched char (if dist == 0) */ + var lx = 0; /* running index in l_buf */ + var code; /* the code to send */ + var extra; /* number of extra bits to send */ + + if (s.last_lit !== 0) { + do { + dist = (s.pending_buf[s.d_buf + lx * 2] << 8) | (s.pending_buf[s.d_buf + lx * 2 + 1]); + lc = s.pending_buf[s.l_buf + lx]; + lx++; + + if (dist === 0) { + send_code(s, lc, ltree); /* send a literal byte */ + //Tracecv(isgraph(lc), (stderr," '%c' ", lc)); + } else { + /* Here, lc is the match length - MIN_MATCH */ + code = _length_code[lc]; + send_code(s, code + LITERALS + 1, ltree); /* send the length code */ + extra = extra_lbits[code]; + if (extra !== 0) { + lc -= base_length[code]; + send_bits(s, lc, extra); /* send the extra length bits */ + } + dist--; /* dist is now the match distance - 1 */ + code = d_code(dist); + //Assert (code < D_CODES, "bad d_code"); + + send_code(s, code, dtree); /* send the distance code */ + extra = extra_dbits[code]; + if (extra !== 0) { + dist -= base_dist[code]; + send_bits(s, dist, extra); /* send the extra distance bits */ + } + } /* literal or match pair ? */ + + /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */ + //Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx, + // "pendingBuf overflow"); + + } while (lx < s.last_lit); + } + + send_code(s, END_BLOCK, ltree); +} + + +/* =========================================================================== + * Construct one Huffman tree and assigns the code bit strings and lengths. + * Update the total bit length for the current block. + * IN assertion: the field freq is set for all tree elements. + * OUT assertions: the fields len and code are set to the optimal bit length + * and corresponding code. The length opt_len is updated; static_len is + * also updated if stree is not null. The field max_code is set. + */ +function build_tree(s, desc) +// deflate_state *s; +// tree_desc *desc; /* the tree descriptor */ +{ + var tree = desc.dyn_tree; + var stree = desc.stat_desc.static_tree; + var has_stree = desc.stat_desc.has_stree; + var elems = desc.stat_desc.elems; + var n, m; /* iterate over heap elements */ + var max_code = -1; /* largest code with non zero frequency */ + var node; /* new node being created */ + + /* Construct the initial heap, with least frequent element in + * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. + * heap[0] is not used. + */ + s.heap_len = 0; + s.heap_max = HEAP_SIZE; + + for (n = 0; n < elems; n++) { + if (tree[n * 2]/*.Freq*/ !== 0) { + s.heap[++s.heap_len] = max_code = n; + s.depth[n] = 0; + + } else { + tree[n * 2 + 1]/*.Len*/ = 0; + } + } + + /* The pkzip format requires that at least one distance code exists, + * and that at least one bit should be sent even if there is only one + * possible code. So to avoid special checks later on we force at least + * two codes of non zero frequency. + */ + while (s.heap_len < 2) { + node = s.heap[++s.heap_len] = (max_code < 2 ? ++max_code : 0); + tree[node * 2]/*.Freq*/ = 1; + s.depth[node] = 0; + s.opt_len--; + + if (has_stree) { + s.static_len -= stree[node * 2 + 1]/*.Len*/; + } + /* node is 0 or 1 so it does not have extra bits */ + } + desc.max_code = max_code; + + /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, + * establish sub-heaps of increasing lengths: + */ + for (n = (s.heap_len >> 1/*int /2*/); n >= 1; n--) { pqdownheap(s, tree, n); } + + /* Construct the Huffman tree by repeatedly combining the least two + * frequent nodes. + */ + node = elems; /* next internal node of the tree */ + do { + //pqremove(s, tree, n); /* n = node of least frequency */ + /*** pqremove ***/ + n = s.heap[1/*SMALLEST*/]; + s.heap[1/*SMALLEST*/] = s.heap[s.heap_len--]; + pqdownheap(s, tree, 1/*SMALLEST*/); + /***/ + + m = s.heap[1/*SMALLEST*/]; /* m = node of next least frequency */ + + s.heap[--s.heap_max] = n; /* keep the nodes sorted by frequency */ + s.heap[--s.heap_max] = m; + + /* Create a new node father of n and m */ + tree[node * 2]/*.Freq*/ = tree[n * 2]/*.Freq*/ + tree[m * 2]/*.Freq*/; + s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1; + tree[n * 2 + 1]/*.Dad*/ = tree[m * 2 + 1]/*.Dad*/ = node; + + /* and insert the new node in the heap */ + s.heap[1/*SMALLEST*/] = node++; + pqdownheap(s, tree, 1/*SMALLEST*/); + + } while (s.heap_len >= 2); + + s.heap[--s.heap_max] = s.heap[1/*SMALLEST*/]; + + /* At this point, the fields freq and dad are set. We can now + * generate the bit lengths. + */ + gen_bitlen(s, desc); + + /* The field len is now set, we can generate the bit codes */ + gen_codes(tree, max_code, s.bl_count); +} + + +/* =========================================================================== + * Scan a literal or distance tree to determine the frequencies of the codes + * in the bit length tree. + */ +function scan_tree(s, tree, max_code) +// deflate_state *s; +// ct_data *tree; /* the tree to be scanned */ +// int max_code; /* and its largest code of non zero frequency */ +{ + var n; /* iterates over all tree elements */ + var prevlen = -1; /* last emitted length */ + var curlen; /* length of current code */ + + var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */ + + var count = 0; /* repeat count of the current code */ + var max_count = 7; /* max repeat count */ + var min_count = 4; /* min repeat count */ + + if (nextlen === 0) { + max_count = 138; + min_count = 3; + } + tree[(max_code + 1) * 2 + 1]/*.Len*/ = 0xffff; /* guard */ + + for (n = 0; n <= max_code; n++) { + curlen = nextlen; + nextlen = tree[(n + 1) * 2 + 1]/*.Len*/; + + if (++count < max_count && curlen === nextlen) { + continue; + + } else if (count < min_count) { + s.bl_tree[curlen * 2]/*.Freq*/ += count; + + } else if (curlen !== 0) { + + if (curlen !== prevlen) { s.bl_tree[curlen * 2]/*.Freq*/++; } + s.bl_tree[REP_3_6 * 2]/*.Freq*/++; + + } else if (count <= 10) { + s.bl_tree[REPZ_3_10 * 2]/*.Freq*/++; + + } else { + s.bl_tree[REPZ_11_138 * 2]/*.Freq*/++; + } + + count = 0; + prevlen = curlen; + + if (nextlen === 0) { + max_count = 138; + min_count = 3; + + } else if (curlen === nextlen) { + max_count = 6; + min_count = 3; + + } else { + max_count = 7; + min_count = 4; + } + } +} + + +/* =========================================================================== + * Send a literal or distance tree in compressed form, using the codes in + * bl_tree. + */ +function send_tree(s, tree, max_code) +// deflate_state *s; +// ct_data *tree; /* the tree to be scanned */ +// int max_code; /* and its largest code of non zero frequency */ +{ + var n; /* iterates over all tree elements */ + var prevlen = -1; /* last emitted length */ + var curlen; /* length of current code */ + + var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */ + + var count = 0; /* repeat count of the current code */ + var max_count = 7; /* max repeat count */ + var min_count = 4; /* min repeat count */ + + /* tree[max_code+1].Len = -1; */ /* guard already set */ + if (nextlen === 0) { + max_count = 138; + min_count = 3; + } + + for (n = 0; n <= max_code; n++) { + curlen = nextlen; + nextlen = tree[(n + 1) * 2 + 1]/*.Len*/; + + if (++count < max_count && curlen === nextlen) { + continue; + + } else if (count < min_count) { + do { send_code(s, curlen, s.bl_tree); } while (--count !== 0); + + } else if (curlen !== 0) { + if (curlen !== prevlen) { + send_code(s, curlen, s.bl_tree); + count--; + } + //Assert(count >= 3 && count <= 6, " 3_6?"); + send_code(s, REP_3_6, s.bl_tree); + send_bits(s, count - 3, 2); + + } else if (count <= 10) { + send_code(s, REPZ_3_10, s.bl_tree); + send_bits(s, count - 3, 3); + + } else { + send_code(s, REPZ_11_138, s.bl_tree); + send_bits(s, count - 11, 7); + } + + count = 0; + prevlen = curlen; + if (nextlen === 0) { + max_count = 138; + min_count = 3; + + } else if (curlen === nextlen) { + max_count = 6; + min_count = 3; + + } else { + max_count = 7; + min_count = 4; + } + } +} + + +/* =========================================================================== + * Construct the Huffman tree for the bit lengths and return the index in + * bl_order of the last bit length code to send. + */ +function build_bl_tree(s) { + var max_blindex; /* index of last bit length code of non zero freq */ + + /* Determine the bit length frequencies for literal and distance trees */ + scan_tree(s, s.dyn_ltree, s.l_desc.max_code); + scan_tree(s, s.dyn_dtree, s.d_desc.max_code); + + /* Build the bit length tree: */ + build_tree(s, s.bl_desc); + /* opt_len now includes the length of the tree representations, except + * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. + */ + + /* Determine the number of bit length codes to send. The pkzip format + * requires that at least 4 bit length codes be sent. (appnote.txt says + * 3 but the actual value used is 4.) + */ + for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) { + if (s.bl_tree[bl_order[max_blindex] * 2 + 1]/*.Len*/ !== 0) { + break; + } + } + /* Update opt_len to include the bit length tree and counts */ + s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4; + //Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", + // s->opt_len, s->static_len)); + + return max_blindex; +} + + +/* =========================================================================== + * Send the header for a block using dynamic Huffman trees: the counts, the + * lengths of the bit length codes, the literal tree and the distance tree. + * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. + */ +function send_all_trees(s, lcodes, dcodes, blcodes) +// deflate_state *s; +// int lcodes, dcodes, blcodes; /* number of codes for each tree */ +{ + var rank; /* index in bl_order */ + + //Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); + //Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, + // "too many codes"); + //Tracev((stderr, "\nbl counts: ")); + send_bits(s, lcodes - 257, 5); /* not +255 as stated in appnote.txt */ + send_bits(s, dcodes - 1, 5); + send_bits(s, blcodes - 4, 4); /* not -3 as stated in appnote.txt */ + for (rank = 0; rank < blcodes; rank++) { + //Tracev((stderr, "\nbl code %2d ", bl_order[rank])); + send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1]/*.Len*/, 3); + } + //Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); + + send_tree(s, s.dyn_ltree, lcodes - 1); /* literal tree */ + //Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); + + send_tree(s, s.dyn_dtree, dcodes - 1); /* distance tree */ + //Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); +} + + +/* =========================================================================== + * Check if the data type is TEXT or BINARY, using the following algorithm: + * - TEXT if the two conditions below are satisfied: + * a) There are no non-portable control characters belonging to the + * "black list" (0..6, 14..25, 28..31). + * b) There is at least one printable character belonging to the + * "white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255). + * - BINARY otherwise. + * - The following partially-portable control characters form a + * "gray list" that is ignored in this detection algorithm: + * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}). + * IN assertion: the fields Freq of dyn_ltree are set. + */ +function detect_data_type(s) { + /* black_mask is the bit mask of black-listed bytes + * set bits 0..6, 14..25, and 28..31 + * 0xf3ffc07f = binary 11110011111111111100000001111111 + */ + var black_mask = 0xf3ffc07f; + var n; + + /* Check for non-textual ("black-listed") bytes. */ + for (n = 0; n <= 31; n++, black_mask >>>= 1) { + if ((black_mask & 1) && (s.dyn_ltree[n * 2]/*.Freq*/ !== 0)) { + return Z_BINARY; + } + } + + /* Check for textual ("white-listed") bytes. */ + if (s.dyn_ltree[9 * 2]/*.Freq*/ !== 0 || s.dyn_ltree[10 * 2]/*.Freq*/ !== 0 || + s.dyn_ltree[13 * 2]/*.Freq*/ !== 0) { + return Z_TEXT; + } + for (n = 32; n < LITERALS; n++) { + if (s.dyn_ltree[n * 2]/*.Freq*/ !== 0) { + return Z_TEXT; + } + } + + /* There are no "black-listed" or "white-listed" bytes: + * this stream either is empty or has tolerated ("gray-listed") bytes only. + */ + return Z_BINARY; +} + + +var static_init_done = false; + +/* =========================================================================== + * Initialize the tree data structures for a new zlib stream. + */ +function _tr_init(s) +{ + + if (!static_init_done) { + tr_static_init(); + static_init_done = true; + } + + s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc); + s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc); + s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc); + + s.bi_buf = 0; + s.bi_valid = 0; + + /* Initialize the first block of the first file: */ + init_block(s); +} + + +/* =========================================================================== + * Send a stored block + */ +function _tr_stored_block(s, buf, stored_len, last) +//DeflateState *s; +//charf *buf; /* input block */ +//ulg stored_len; /* length of input block */ +//int last; /* one if this is the last block for a file */ +{ + send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3); /* send block type */ + copy_block(s, buf, stored_len, true); /* with header */ +} + + +/* =========================================================================== + * Send one empty static block to give enough lookahead for inflate. + * This takes 10 bits, of which 7 may remain in the bit buffer. + */ +function _tr_align(s) { + send_bits(s, STATIC_TREES << 1, 3); + send_code(s, END_BLOCK, static_ltree); + bi_flush(s); +} + + +/* =========================================================================== + * Determine the best encoding for the current block: dynamic trees, static + * trees or store, and output the encoded block to the zip file. + */ +function _tr_flush_block(s, buf, stored_len, last) +//DeflateState *s; +//charf *buf; /* input block, or NULL if too old */ +//ulg stored_len; /* length of input block */ +//int last; /* one if this is the last block for a file */ +{ + var opt_lenb, static_lenb; /* opt_len and static_len in bytes */ + var max_blindex = 0; /* index of last bit length code of non zero freq */ + + /* Build the Huffman trees unless a stored block is forced */ + if (s.level > 0) { + + /* Check if the file is binary or text */ + if (s.strm.data_type === Z_UNKNOWN) { + s.strm.data_type = detect_data_type(s); + } + + /* Construct the literal and distance trees */ + build_tree(s, s.l_desc); + // Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len, + // s->static_len)); + + build_tree(s, s.d_desc); + // Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len, + // s->static_len)); + /* At this point, opt_len and static_len are the total bit lengths of + * the compressed block data, excluding the tree representations. + */ + + /* Build the bit length tree for the above two trees, and get the index + * in bl_order of the last bit length code to send. + */ + max_blindex = build_bl_tree(s); + + /* Determine the best encoding. Compute the block lengths in bytes. */ + opt_lenb = (s.opt_len + 3 + 7) >>> 3; + static_lenb = (s.static_len + 3 + 7) >>> 3; + + // Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", + // opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, + // s->last_lit)); + + if (static_lenb <= opt_lenb) { opt_lenb = static_lenb; } + + } else { + // Assert(buf != (char*)0, "lost buf"); + opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ + } + + if ((stored_len + 4 <= opt_lenb) && (buf !== -1)) { + /* 4: two words for the lengths */ + + /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. + * Otherwise we can't have processed more than WSIZE input bytes since + * the last block flush, because compression would have been + * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to + * transform a block into a stored block. + */ + _tr_stored_block(s, buf, stored_len, last); + + } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) { + + send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3); + compress_block(s, static_ltree, static_dtree); + + } else { + send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3); + send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1); + compress_block(s, s.dyn_ltree, s.dyn_dtree); + } + // Assert (s->compressed_len == s->bits_sent, "bad compressed size"); + /* The above check is made mod 2^32, for files larger than 512 MB + * and uLong implemented on 32 bits. + */ + init_block(s); + + if (last) { + bi_windup(s); + } + // Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, + // s->compressed_len-7*last)); +} + +/* =========================================================================== + * Save the match info and tally the frequency counts. Return true if + * the current block must be flushed. + */ +function _tr_tally(s, dist, lc) +// deflate_state *s; +// unsigned dist; /* distance of matched string */ +// unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ +{ + //var out_length, in_length, dcode; + + s.pending_buf[s.d_buf + s.last_lit * 2] = (dist >>> 8) & 0xff; + s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 0xff; + + s.pending_buf[s.l_buf + s.last_lit] = lc & 0xff; + s.last_lit++; + + if (dist === 0) { + /* lc is the unmatched char */ + s.dyn_ltree[lc * 2]/*.Freq*/++; + } else { + s.matches++; + /* Here, lc is the match length - MIN_MATCH */ + dist--; /* dist = match distance - 1 */ + //Assert((ush)dist < (ush)MAX_DIST(s) && + // (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && + // (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); + + s.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]/*.Freq*/++; + s.dyn_dtree[d_code(dist) * 2]/*.Freq*/++; + } + +// (!) This block is disabled in zlib defaults, +// don't enable it for binary compatibility + +//#ifdef TRUNCATE_BLOCK +// /* Try to guess if it is profitable to stop the current block here */ +// if ((s.last_lit & 0x1fff) === 0 && s.level > 2) { +// /* Compute an upper bound for the compressed length */ +// out_length = s.last_lit*8; +// in_length = s.strstart - s.block_start; +// +// for (dcode = 0; dcode < D_CODES; dcode++) { +// out_length += s.dyn_dtree[dcode*2]/*.Freq*/ * (5 + extra_dbits[dcode]); +// } +// out_length >>>= 3; +// //Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ", +// // s->last_lit, in_length, out_length, +// // 100L - out_length*100L/in_length)); +// if (s.matches < (s.last_lit>>1)/*int /2*/ && out_length < (in_length>>1)/*int /2*/) { +// return true; +// } +// } +//#endif + + return (s.last_lit === s.lit_bufsize - 1); + /* We avoid equality with lit_bufsize because of wraparound at 64K + * on 16 bit machines and because stored blocks are restricted to + * 64K-1 bytes. + */ +} + +exports._tr_init = _tr_init; +exports._tr_stored_block = _tr_stored_block; +exports._tr_flush_block = _tr_flush_block; +exports._tr_tally = _tr_tally; +exports._tr_align = _tr_align; + +},{"../utils/common":26}],38:[function(require,module,exports){ +'use strict'; + +// (C) 1995-2013 Jean-loup Gailly and Mark Adler +// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would be +// appreciated but is not required. +// 2. Altered source versions must be plainly marked as such, and must not be +// misrepresented as being the original software. +// 3. This notice may not be removed or altered from any source distribution. + +function ZStream() { + /* next input byte */ + this.input = null; // JS specific, because we have no pointers + this.next_in = 0; + /* number of bytes available at input */ + this.avail_in = 0; + /* total number of input bytes read so far */ + this.total_in = 0; + /* next output byte should be put there */ + this.output = null; // JS specific, because we have no pointers + this.next_out = 0; + /* remaining free space at output */ + this.avail_out = 0; + /* total number of bytes output so far */ + this.total_out = 0; + /* last error message, NULL if no error */ + this.msg = ''/*Z_NULL*/; + /* not visible by applications */ + this.state = null; + /* best guess about the data type: binary or text */ + this.data_type = 2/*Z_UNKNOWN*/; + /* adler32 value of the uncompressed data */ + this.adler = 0; +} + +module.exports = ZStream; + +},{}],39:[function(require,module,exports){ (function (process){ // Copyright Joyent, Inc. and other Node contributors. // @@ -4111,7 +12648,7 @@ var substr = 'ab'.substr(-1) === 'b' }).call(this,require('_process')) -},{"_process":6}],23:[function(require,module,exports){ +},{"_process":6}],40:[function(require,module,exports){ 'use strict'; module.exports = Pbf; @@ -4731,7 +13268,7 @@ function writeUtf8(buf, str, pos) { return pos; } -},{"ieee754":17}],24:[function(require,module,exports){ +},{"ieee754":17}],41:[function(require,module,exports){ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : @@ -4796,7 +13333,7 @@ return quickselect; }))); -},{}],25:[function(require,module,exports){ +},{}],42:[function(require,module,exports){ 'use strict'; module.exports = rbush; @@ -5360,7 +13897,7 @@ function multiSelect(arr, left, right, n, compare) { } } -},{"quickselect":24}],26:[function(require,module,exports){ +},{"quickselect":41}],43:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Observable_1 = require("./internal/Observable"); @@ -5471,7 +14008,7 @@ exports.NEVER = never_2.NEVER; var config_1 = require("./internal/config"); exports.config = config_1.config; -},{"./internal/AsyncSubject":27,"./internal/BehaviorSubject":28,"./internal/Notification":30,"./internal/Observable":31,"./internal/ReplaySubject":34,"./internal/Scheduler":35,"./internal/Subject":36,"./internal/Subscriber":38,"./internal/Subscription":39,"./internal/config":40,"./internal/observable/ConnectableObservable":41,"./internal/observable/bindCallback":43,"./internal/observable/bindNodeCallback":44,"./internal/observable/combineLatest":45,"./internal/observable/concat":46,"./internal/observable/defer":47,"./internal/observable/empty":48,"./internal/observable/forkJoin":49,"./internal/observable/from":50,"./internal/observable/fromEvent":52,"./internal/observable/fromEventPattern":53,"./internal/observable/generate":57,"./internal/observable/iif":58,"./internal/observable/interval":59,"./internal/observable/merge":60,"./internal/observable/never":61,"./internal/observable/of":62,"./internal/observable/onErrorResumeNext":63,"./internal/observable/pairs":64,"./internal/observable/race":65,"./internal/observable/range":66,"./internal/observable/throwError":68,"./internal/observable/timer":69,"./internal/observable/using":70,"./internal/observable/zip":71,"./internal/operators/groupBy":107,"./internal/scheduler/VirtualTimeScheduler":184,"./internal/scheduler/animationFrame":185,"./internal/scheduler/asap":186,"./internal/scheduler/async":187,"./internal/scheduler/queue":188,"./internal/symbol/observable":190,"./internal/util/ArgumentOutOfRangeError":192,"./internal/util/EmptyError":193,"./internal/util/ObjectUnsubscribedError":195,"./internal/util/TimeoutError":196,"./internal/util/UnsubscriptionError":197,"./internal/util/identity":201,"./internal/util/isObservable":210,"./internal/util/noop":213,"./internal/util/pipe":215}],27:[function(require,module,exports){ +},{"./internal/AsyncSubject":44,"./internal/BehaviorSubject":45,"./internal/Notification":47,"./internal/Observable":48,"./internal/ReplaySubject":51,"./internal/Scheduler":52,"./internal/Subject":53,"./internal/Subscriber":55,"./internal/Subscription":56,"./internal/config":57,"./internal/observable/ConnectableObservable":58,"./internal/observable/bindCallback":60,"./internal/observable/bindNodeCallback":61,"./internal/observable/combineLatest":62,"./internal/observable/concat":63,"./internal/observable/defer":64,"./internal/observable/empty":65,"./internal/observable/forkJoin":66,"./internal/observable/from":67,"./internal/observable/fromEvent":69,"./internal/observable/fromEventPattern":70,"./internal/observable/generate":74,"./internal/observable/iif":75,"./internal/observable/interval":76,"./internal/observable/merge":77,"./internal/observable/never":78,"./internal/observable/of":79,"./internal/observable/onErrorResumeNext":80,"./internal/observable/pairs":81,"./internal/observable/race":82,"./internal/observable/range":83,"./internal/observable/throwError":85,"./internal/observable/timer":86,"./internal/observable/using":87,"./internal/observable/zip":88,"./internal/operators/groupBy":124,"./internal/scheduler/VirtualTimeScheduler":201,"./internal/scheduler/animationFrame":202,"./internal/scheduler/asap":203,"./internal/scheduler/async":204,"./internal/scheduler/queue":205,"./internal/symbol/observable":207,"./internal/util/ArgumentOutOfRangeError":209,"./internal/util/EmptyError":210,"./internal/util/ObjectUnsubscribedError":212,"./internal/util/TimeoutError":213,"./internal/util/UnsubscriptionError":214,"./internal/util/identity":218,"./internal/util/isObservable":227,"./internal/util/noop":230,"./internal/util/pipe":232}],44:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -5532,7 +14069,7 @@ var AsyncSubject = (function (_super) { }(Subject_1.Subject)); exports.AsyncSubject = AsyncSubject; -},{"./Subject":36,"./Subscription":39}],28:[function(require,module,exports){ +},{"./Subject":53,"./Subscription":56}],45:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -5589,7 +14126,7 @@ var BehaviorSubject = (function (_super) { }(Subject_1.Subject)); exports.BehaviorSubject = BehaviorSubject; -},{"./Subject":36,"./util/ObjectUnsubscribedError":195}],29:[function(require,module,exports){ +},{"./Subject":53,"./util/ObjectUnsubscribedError":212}],46:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -5631,7 +14168,7 @@ var InnerSubscriber = (function (_super) { }(Subscriber_1.Subscriber)); exports.InnerSubscriber = InnerSubscriber; -},{"./Subscriber":38}],30:[function(require,module,exports){ +},{"./Subscriber":55}],47:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var empty_1 = require("./observable/empty"); @@ -5703,7 +14240,7 @@ var Notification = (function () { }()); exports.Notification = Notification; -},{"./observable/empty":48,"./observable/of":62,"./observable/throwError":68}],31:[function(require,module,exports){ +},{"./observable/empty":65,"./observable/of":79,"./observable/throwError":85}],48:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var canReportError_1 = require("./util/canReportError"); @@ -5821,7 +14358,7 @@ function getPromiseCtor(promiseCtor) { return promiseCtor; } -},{"../internal/symbol/observable":190,"./config":40,"./util/canReportError":198,"./util/pipe":215,"./util/toSubscriber":222}],32:[function(require,module,exports){ +},{"../internal/symbol/observable":207,"./config":57,"./util/canReportError":215,"./util/pipe":232,"./util/toSubscriber":239}],49:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var config_1 = require("./config"); @@ -5840,7 +14377,7 @@ exports.empty = { complete: function () { } }; -},{"./config":40,"./util/hostReportError":200}],33:[function(require,module,exports){ +},{"./config":57,"./util/hostReportError":217}],50:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -5875,7 +14412,7 @@ var OuterSubscriber = (function (_super) { }(Subscriber_1.Subscriber)); exports.OuterSubscriber = OuterSubscriber; -},{"./Subscriber":38}],34:[function(require,module,exports){ +},{"./Subscriber":55}],51:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -6002,7 +14539,7 @@ var ReplayEvent = (function () { return ReplayEvent; }()); -},{"./Subject":36,"./SubjectSubscription":37,"./Subscription":39,"./operators/observeOn":122,"./scheduler/queue":188,"./util/ObjectUnsubscribedError":195}],35:[function(require,module,exports){ +},{"./Subject":53,"./SubjectSubscription":54,"./Subscription":56,"./operators/observeOn":139,"./scheduler/queue":205,"./util/ObjectUnsubscribedError":212}],52:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Scheduler = (function () { @@ -6020,7 +14557,7 @@ var Scheduler = (function () { }()); exports.Scheduler = Scheduler; -},{}],36:[function(require,module,exports){ +},{}],53:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -6192,7 +14729,7 @@ var AnonymousSubject = (function (_super) { }(Subject)); exports.AnonymousSubject = AnonymousSubject; -},{"../internal/symbol/rxSubscriber":191,"./Observable":31,"./SubjectSubscription":37,"./Subscriber":38,"./Subscription":39,"./util/ObjectUnsubscribedError":195}],37:[function(require,module,exports){ +},{"../internal/symbol/rxSubscriber":208,"./Observable":48,"./SubjectSubscription":54,"./Subscriber":55,"./Subscription":56,"./util/ObjectUnsubscribedError":212}],54:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -6238,7 +14775,7 @@ var SubjectSubscription = (function (_super) { }(Subscription_1.Subscription)); exports.SubjectSubscription = SubjectSubscription; -},{"./Subscription":39}],38:[function(require,module,exports){ +},{"./Subscription":56}],55:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -6489,7 +15026,7 @@ var SafeSubscriber = (function (_super) { }(Subscriber)); exports.SafeSubscriber = SafeSubscriber; -},{"../internal/symbol/rxSubscriber":191,"./Observer":32,"./Subscription":39,"./config":40,"./util/hostReportError":200,"./util/isFunction":205}],39:[function(require,module,exports){ +},{"../internal/symbol/rxSubscriber":208,"./Observer":49,"./Subscription":56,"./config":57,"./util/hostReportError":217,"./util/isFunction":222}],56:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var isArray_1 = require("./util/isArray"); @@ -6623,7 +15160,7 @@ function flattenUnsubscriptionErrors(errors) { return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError_1.UnsubscriptionError) ? err.errors : err); }, []); } -},{"./util/UnsubscriptionError":197,"./util/errorObject":199,"./util/isArray":202,"./util/isFunction":205,"./util/isObject":209,"./util/tryCatch":223}],40:[function(require,module,exports){ +},{"./util/UnsubscriptionError":214,"./util/errorObject":216,"./util/isArray":219,"./util/isFunction":222,"./util/isObject":226,"./util/tryCatch":240}],57:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _enable_super_gross_mode_that_will_cause_bad_things = false; @@ -6644,7 +15181,7 @@ exports.config = { }, }; -},{}],41:[function(require,module,exports){ +},{}],58:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -6801,7 +15338,7 @@ var RefCountSubscriber = (function (_super) { return RefCountSubscriber; }(Subscriber_1.Subscriber)); -},{"../Observable":31,"../Subject":36,"../Subscriber":38,"../Subscription":39,"../operators/refCount":133}],42:[function(require,module,exports){ +},{"../Observable":48,"../Subject":53,"../Subscriber":55,"../Subscription":56,"../operators/refCount":150}],59:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -6858,7 +15395,7 @@ var SubscribeOnObservable = (function (_super) { }(Observable_1.Observable)); exports.SubscribeOnObservable = SubscribeOnObservable; -},{"../Observable":31,"../scheduler/asap":186,"../util/isNumeric":208}],43:[function(require,module,exports){ +},{"../Observable":48,"../scheduler/asap":203,"../util/isNumeric":225}],60:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Observable_1 = require("../Observable"); @@ -6966,7 +15503,7 @@ function dispatchError(state) { subject.error(err); } -},{"../AsyncSubject":27,"../Observable":31,"../operators/map":111,"../util/canReportError":198,"../util/isArray":202,"../util/isScheduler":212}],44:[function(require,module,exports){ +},{"../AsyncSubject":44,"../Observable":48,"../operators/map":128,"../util/canReportError":215,"../util/isArray":219,"../util/isScheduler":229}],61:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Observable_1 = require("../Observable"); @@ -7082,7 +15619,7 @@ function dispatchError(arg) { subject.error(err); } -},{"../AsyncSubject":27,"../Observable":31,"../operators/map":111,"../util/canReportError":198,"../util/isArray":202,"../util/isScheduler":212}],45:[function(require,module,exports){ +},{"../AsyncSubject":44,"../Observable":48,"../operators/map":128,"../util/canReportError":215,"../util/isArray":219,"../util/isScheduler":229}],62:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -7198,7 +15735,7 @@ var CombineLatestSubscriber = (function (_super) { }(OuterSubscriber_1.OuterSubscriber)); exports.CombineLatestSubscriber = CombineLatestSubscriber; -},{"../OuterSubscriber":33,"../util/isArray":202,"../util/isScheduler":212,"../util/subscribeToResult":221,"./fromArray":51}],46:[function(require,module,exports){ +},{"../OuterSubscriber":50,"../util/isArray":219,"../util/isScheduler":229,"../util/subscribeToResult":238,"./fromArray":68}],63:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var isScheduler_1 = require("../util/isScheduler"); @@ -7217,7 +15754,7 @@ function concat() { } exports.concat = concat; -},{"../operators/concatAll":83,"../util/isScheduler":212,"./from":50,"./of":62}],47:[function(require,module,exports){ +},{"../operators/concatAll":100,"../util/isScheduler":229,"./from":67,"./of":79}],64:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Observable_1 = require("../Observable"); @@ -7239,7 +15776,7 @@ function defer(observableFactory) { } exports.defer = defer; -},{"../Observable":31,"./empty":48,"./from":50}],48:[function(require,module,exports){ +},{"../Observable":48,"./empty":65,"./from":67}],65:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Observable_1 = require("../Observable"); @@ -7253,7 +15790,7 @@ function emptyScheduled(scheduler) { } exports.emptyScheduled = emptyScheduled; -},{"../Observable":31}],49:[function(require,module,exports){ +},{"../Observable":48}],66:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -7342,7 +15879,7 @@ var ForkJoinSubscriber = (function (_super) { return ForkJoinSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../Observable":31,"../OuterSubscriber":33,"../operators/map":111,"../util/isArray":202,"../util/subscribeToResult":221,"./empty":48}],50:[function(require,module,exports){ +},{"../Observable":48,"../OuterSubscriber":50,"../operators/map":128,"../util/isArray":219,"../util/subscribeToResult":238,"./empty":65}],67:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Observable_1 = require("../Observable"); @@ -7380,7 +15917,7 @@ function from(input, scheduler) { } exports.from = from; -},{"../Observable":31,"../util/isArrayLike":203,"../util/isInteropObservable":206,"../util/isIterable":207,"../util/isPromise":211,"../util/subscribeTo":216,"./fromArray":51,"./fromIterable":54,"./fromObservable":55,"./fromPromise":56}],51:[function(require,module,exports){ +},{"../Observable":48,"../util/isArrayLike":220,"../util/isInteropObservable":223,"../util/isIterable":224,"../util/isPromise":228,"../util/subscribeTo":233,"./fromArray":68,"./fromIterable":71,"./fromObservable":72,"./fromPromise":73}],68:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Observable_1 = require("../Observable"); @@ -7410,7 +15947,7 @@ function fromArray(input, scheduler) { } exports.fromArray = fromArray; -},{"../Observable":31,"../Subscription":39,"../util/subscribeToArray":217}],52:[function(require,module,exports){ +},{"../Observable":48,"../Subscription":56,"../util/subscribeToArray":234}],69:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Observable_1 = require("../Observable"); @@ -7476,7 +16013,7 @@ function isEventTarget(sourceObj) { return sourceObj && typeof sourceObj.addEventListener === 'function' && typeof sourceObj.removeEventListener === 'function'; } -},{"../Observable":31,"../operators/map":111,"../util/isArray":202,"../util/isFunction":205}],53:[function(require,module,exports){ +},{"../Observable":48,"../operators/map":128,"../util/isArray":219,"../util/isFunction":222}],70:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Observable_1 = require("../Observable"); @@ -7511,7 +16048,7 @@ function fromEventPattern(addHandler, removeHandler, resultSelector) { } exports.fromEventPattern = fromEventPattern; -},{"../Observable":31,"../operators/map":111,"../util/isArray":202,"../util/isFunction":205}],54:[function(require,module,exports){ +},{"../Observable":48,"../operators/map":128,"../util/isArray":219,"../util/isFunction":222}],71:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Observable_1 = require("../Observable"); @@ -7566,7 +16103,7 @@ function fromIterable(input, scheduler) { } exports.fromIterable = fromIterable; -},{"../Observable":31,"../Subscription":39,"../symbol/iterator":189,"../util/subscribeToIterable":218}],55:[function(require,module,exports){ +},{"../Observable":48,"../Subscription":56,"../symbol/iterator":206,"../util/subscribeToIterable":235}],72:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Observable_1 = require("../Observable"); @@ -7594,7 +16131,7 @@ function fromObservable(input, scheduler) { } exports.fromObservable = fromObservable; -},{"../Observable":31,"../Subscription":39,"../symbol/observable":190,"../util/subscribeToObservable":219}],56:[function(require,module,exports){ +},{"../Observable":48,"../Subscription":56,"../symbol/observable":207,"../util/subscribeToObservable":236}],73:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Observable_1 = require("../Observable"); @@ -7621,7 +16158,7 @@ function fromPromise(input, scheduler) { } exports.fromPromise = fromPromise; -},{"../Observable":31,"../Subscription":39,"../util/subscribeToPromise":220}],57:[function(require,module,exports){ +},{"../Observable":48,"../Subscription":56,"../util/subscribeToPromise":237}],74:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Observable_1 = require("../Observable"); @@ -7749,7 +16286,7 @@ function dispatch(state) { return this.schedule(state); } -},{"../Observable":31,"../util/identity":201,"../util/isScheduler":212}],58:[function(require,module,exports){ +},{"../Observable":48,"../util/identity":218,"../util/isScheduler":229}],75:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var defer_1 = require("./defer"); @@ -7761,7 +16298,7 @@ function iif(condition, trueResult, falseResult) { } exports.iif = iif; -},{"./defer":47,"./empty":48}],59:[function(require,module,exports){ +},{"./defer":64,"./empty":65}],76:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Observable_1 = require("../Observable"); @@ -7788,7 +16325,7 @@ function dispatch(state) { this.schedule({ subscriber: subscriber, counter: counter + 1, period: period }, period); } -},{"../Observable":31,"../scheduler/async":187,"../util/isNumeric":208}],60:[function(require,module,exports){ +},{"../Observable":48,"../scheduler/async":204,"../util/isNumeric":225}],77:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Observable_1 = require("../Observable"); @@ -7819,7 +16356,7 @@ function merge() { } exports.merge = merge; -},{"../Observable":31,"../operators/mergeAll":116,"../util/isScheduler":212,"./fromArray":51}],61:[function(require,module,exports){ +},{"../Observable":48,"../operators/mergeAll":133,"../util/isScheduler":229,"./fromArray":68}],78:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Observable_1 = require("../Observable"); @@ -7830,7 +16367,7 @@ function never() { } exports.never = never; -},{"../Observable":31,"../util/noop":213}],62:[function(require,module,exports){ +},{"../Observable":48,"../util/noop":230}],79:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var isScheduler_1 = require("../util/isScheduler"); @@ -7860,7 +16397,7 @@ function of() { } exports.of = of; -},{"../util/isScheduler":212,"./empty":48,"./fromArray":51,"./scalar":67}],63:[function(require,module,exports){ +},{"../util/isScheduler":229,"./empty":65,"./fromArray":68,"./scalar":84}],80:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Observable_1 = require("../Observable"); @@ -7890,7 +16427,7 @@ function onErrorResumeNext() { } exports.onErrorResumeNext = onErrorResumeNext; -},{"../Observable":31,"../util/isArray":202,"./empty":48,"./from":50}],64:[function(require,module,exports){ +},{"../Observable":48,"../util/isArray":219,"./empty":65,"./from":67}],81:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Observable_1 = require("../Observable"); @@ -7933,7 +16470,7 @@ function dispatch(state) { } exports.dispatch = dispatch; -},{"../Observable":31,"../Subscription":39}],65:[function(require,module,exports){ +},{"../Observable":48,"../Subscription":56}],82:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -8026,7 +16563,7 @@ var RaceSubscriber = (function (_super) { }(OuterSubscriber_1.OuterSubscriber)); exports.RaceSubscriber = RaceSubscriber; -},{"../OuterSubscriber":33,"../util/isArray":202,"../util/subscribeToResult":221,"./fromArray":51}],66:[function(require,module,exports){ +},{"../OuterSubscriber":50,"../util/isArray":219,"../util/subscribeToResult":238,"./fromArray":68}],83:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Observable_1 = require("../Observable"); @@ -8073,7 +16610,7 @@ function dispatch(state) { } exports.dispatch = dispatch; -},{"../Observable":31}],67:[function(require,module,exports){ +},{"../Observable":48}],84:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Observable_1 = require("../Observable"); @@ -8088,7 +16625,7 @@ function scalar(value) { } exports.scalar = scalar; -},{"../Observable":31}],68:[function(require,module,exports){ +},{"../Observable":48}],85:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Observable_1 = require("../Observable"); @@ -8106,7 +16643,7 @@ function dispatch(_a) { subscriber.error(error); } -},{"../Observable":31}],69:[function(require,module,exports){ +},{"../Observable":48}],86:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Observable_1 = require("../Observable"); @@ -8148,7 +16685,7 @@ function dispatch(state) { this.schedule(state, period); } -},{"../Observable":31,"../scheduler/async":187,"../util/isNumeric":208,"../util/isScheduler":212}],70:[function(require,module,exports){ +},{"../Observable":48,"../scheduler/async":204,"../util/isNumeric":225,"../util/isScheduler":229}],87:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Observable_1 = require("../Observable"); @@ -8184,7 +16721,7 @@ function using(resourceFactory, observableFactory) { } exports.using = using; -},{"../Observable":31,"./empty":48,"./from":50}],71:[function(require,module,exports){ +},{"../Observable":48,"./empty":65,"./from":67}],88:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -8415,7 +16952,7 @@ var ZipBufferIterator = (function (_super) { return ZipBufferIterator; }(OuterSubscriber_1.OuterSubscriber)); -},{"../../internal/symbol/iterator":189,"../OuterSubscriber":33,"../Subscriber":38,"../util/isArray":202,"../util/subscribeToResult":221,"./fromArray":51}],72:[function(require,module,exports){ +},{"../../internal/symbol/iterator":206,"../OuterSubscriber":50,"../Subscriber":55,"../util/isArray":219,"../util/subscribeToResult":238,"./fromArray":68}],89:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -8499,7 +17036,7 @@ var AuditSubscriber = (function (_super) { return AuditSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":33,"../util/errorObject":199,"../util/subscribeToResult":221,"../util/tryCatch":223}],73:[function(require,module,exports){ +},{"../OuterSubscriber":50,"../util/errorObject":216,"../util/subscribeToResult":238,"../util/tryCatch":240}],90:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var async_1 = require("../scheduler/async"); @@ -8511,7 +17048,7 @@ function auditTime(duration, scheduler) { } exports.auditTime = auditTime; -},{"../observable/timer":69,"../scheduler/async":187,"./audit":72}],74:[function(require,module,exports){ +},{"../observable/timer":86,"../scheduler/async":204,"./audit":89}],91:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -8563,7 +17100,7 @@ var BufferSubscriber = (function (_super) { return BufferSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":33,"../util/subscribeToResult":221}],75:[function(require,module,exports){ +},{"../OuterSubscriber":50,"../util/subscribeToResult":238}],92:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -8666,7 +17203,7 @@ var BufferSkipCountSubscriber = (function (_super) { return BufferSkipCountSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38}],76:[function(require,module,exports){ +},{"../Subscriber":55}],93:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -8829,7 +17366,7 @@ function dispatchBufferClose(arg) { subscriber.closeContext(context); } -},{"../Subscriber":38,"../scheduler/async":187,"../util/isScheduler":212}],77:[function(require,module,exports){ +},{"../Subscriber":55,"../scheduler/async":204,"../util/isScheduler":229}],94:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -8951,7 +17488,7 @@ var BufferToggleSubscriber = (function (_super) { return BufferToggleSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":33,"../Subscription":39,"../util/subscribeToResult":221}],78:[function(require,module,exports){ +},{"../OuterSubscriber":50,"../Subscription":56,"../util/subscribeToResult":238}],95:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -9048,7 +17585,7 @@ var BufferWhenSubscriber = (function (_super) { return BufferWhenSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":33,"../Subscription":39,"../util/errorObject":199,"../util/subscribeToResult":221,"../util/tryCatch":223}],79:[function(require,module,exports){ +},{"../OuterSubscriber":50,"../Subscription":56,"../util/errorObject":216,"../util/subscribeToResult":238,"../util/tryCatch":240}],96:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -9111,7 +17648,7 @@ var CatchSubscriber = (function (_super) { return CatchSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../InnerSubscriber":29,"../OuterSubscriber":33,"../util/subscribeToResult":221}],80:[function(require,module,exports){ +},{"../InnerSubscriber":46,"../OuterSubscriber":50,"../util/subscribeToResult":238}],97:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var combineLatest_1 = require("../observable/combineLatest"); @@ -9120,7 +17657,7 @@ function combineAll(project) { } exports.combineAll = combineAll; -},{"../observable/combineLatest":45}],81:[function(require,module,exports){ +},{"../observable/combineLatest":62}],98:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var isArray_1 = require("../util/isArray"); @@ -9143,7 +17680,7 @@ function combineLatest() { } exports.combineLatest = combineLatest; -},{"../observable/combineLatest":45,"../observable/from":50,"../util/isArray":202}],82:[function(require,module,exports){ +},{"../observable/combineLatest":62,"../observable/from":67,"../util/isArray":219}],99:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var concat_1 = require("../observable/concat"); @@ -9156,7 +17693,7 @@ function concat() { } exports.concat = concat; -},{"../observable/concat":46}],83:[function(require,module,exports){ +},{"../observable/concat":63}],100:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var mergeAll_1 = require("./mergeAll"); @@ -9165,7 +17702,7 @@ function concatAll() { } exports.concatAll = concatAll; -},{"./mergeAll":116}],84:[function(require,module,exports){ +},{"./mergeAll":133}],101:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var mergeMap_1 = require("./mergeMap"); @@ -9174,7 +17711,7 @@ function concatMap(project, resultSelector) { } exports.concatMap = concatMap; -},{"./mergeMap":117}],85:[function(require,module,exports){ +},{"./mergeMap":134}],102:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var concatMap_1 = require("./concatMap"); @@ -9183,7 +17720,7 @@ function concatMapTo(innerObservable, resultSelector) { } exports.concatMapTo = concatMapTo; -},{"./concatMap":84}],86:[function(require,module,exports){ +},{"./concatMap":101}],103:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -9252,7 +17789,7 @@ var CountSubscriber = (function (_super) { return CountSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38}],87:[function(require,module,exports){ +},{"../Subscriber":55}],104:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -9343,7 +17880,7 @@ var DebounceSubscriber = (function (_super) { return DebounceSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":33,"../util/subscribeToResult":221}],88:[function(require,module,exports){ +},{"../OuterSubscriber":50,"../util/subscribeToResult":238}],105:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -9420,7 +17957,7 @@ function dispatchNext(subscriber) { subscriber.debouncedNext(); } -},{"../Subscriber":38,"../scheduler/async":187}],89:[function(require,module,exports){ +},{"../Subscriber":55,"../scheduler/async":204}],106:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -9472,7 +18009,7 @@ var DefaultIfEmptySubscriber = (function (_super) { return DefaultIfEmptySubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38}],90:[function(require,module,exports){ +},{"../Subscriber":55}],107:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -9578,7 +18115,7 @@ var DelayMessage = (function () { return DelayMessage; }()); -},{"../Notification":30,"../Subscriber":38,"../scheduler/async":187,"../util/isDate":204}],91:[function(require,module,exports){ +},{"../Notification":47,"../Subscriber":55,"../scheduler/async":204,"../util/isDate":221}],108:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -9725,7 +18262,7 @@ var SubscriptionDelaySubscriber = (function (_super) { return SubscriptionDelaySubscriber; }(Subscriber_1.Subscriber)); -},{"../Observable":31,"../OuterSubscriber":33,"../Subscriber":38,"../util/subscribeToResult":221}],92:[function(require,module,exports){ +},{"../Observable":48,"../OuterSubscriber":50,"../Subscriber":55,"../util/subscribeToResult":238}],109:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -9767,7 +18304,7 @@ var DeMaterializeSubscriber = (function (_super) { return DeMaterializeSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38}],93:[function(require,module,exports){ +},{"../Subscriber":55}],110:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -9847,7 +18384,7 @@ var DistinctSubscriber = (function (_super) { }(OuterSubscriber_1.OuterSubscriber)); exports.DistinctSubscriber = DistinctSubscriber; -},{"../OuterSubscriber":33,"../util/subscribeToResult":221}],94:[function(require,module,exports){ +},{"../OuterSubscriber":50,"../util/subscribeToResult":238}],111:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -9921,7 +18458,7 @@ var DistinctUntilChangedSubscriber = (function (_super) { return DistinctUntilChangedSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38,"../util/errorObject":199,"../util/tryCatch":223}],95:[function(require,module,exports){ +},{"../Subscriber":55,"../util/errorObject":216,"../util/tryCatch":240}],112:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var distinctUntilChanged_1 = require("./distinctUntilChanged"); @@ -9930,7 +18467,7 @@ function distinctUntilKeyChanged(key, compare) { } exports.distinctUntilKeyChanged = distinctUntilKeyChanged; -},{"./distinctUntilChanged":94}],96:[function(require,module,exports){ +},{"./distinctUntilChanged":111}],113:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var ArgumentOutOfRangeError_1 = require("../util/ArgumentOutOfRangeError"); @@ -9949,7 +18486,7 @@ function elementAt(index, defaultValue) { } exports.elementAt = elementAt; -},{"../util/ArgumentOutOfRangeError":192,"./defaultIfEmpty":89,"./filter":102,"./take":154,"./throwIfEmpty":161}],97:[function(require,module,exports){ +},{"../util/ArgumentOutOfRangeError":209,"./defaultIfEmpty":106,"./filter":119,"./take":171,"./throwIfEmpty":178}],114:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var fromArray_1 = require("../observable/fromArray"); @@ -9984,7 +18521,7 @@ function endWith() { } exports.endWith = endWith; -},{"../observable/concat":46,"../observable/empty":48,"../observable/fromArray":51,"../observable/scalar":67,"../util/isScheduler":212}],98:[function(require,module,exports){ +},{"../observable/concat":63,"../observable/empty":65,"../observable/fromArray":68,"../observable/scalar":84,"../util/isScheduler":229}],115:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -10050,7 +18587,7 @@ var EverySubscriber = (function (_super) { return EverySubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38}],99:[function(require,module,exports){ +},{"../Subscriber":55}],116:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -10110,7 +18647,7 @@ var SwitchFirstSubscriber = (function (_super) { return SwitchFirstSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":33,"../util/subscribeToResult":221}],100:[function(require,module,exports){ +},{"../OuterSubscriber":50,"../util/subscribeToResult":238}],117:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -10207,7 +18744,7 @@ var ExhaustMapSubscriber = (function (_super) { return ExhaustMapSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../InnerSubscriber":29,"../OuterSubscriber":33,"../observable/from":50,"../util/subscribeToResult":221,"./map":111}],101:[function(require,module,exports){ +},{"../InnerSubscriber":46,"../OuterSubscriber":50,"../observable/from":67,"../util/subscribeToResult":238,"./map":128}],118:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -10322,7 +18859,7 @@ var ExpandSubscriber = (function (_super) { }(OuterSubscriber_1.OuterSubscriber)); exports.ExpandSubscriber = ExpandSubscriber; -},{"../OuterSubscriber":33,"../util/errorObject":199,"../util/subscribeToResult":221,"../util/tryCatch":223}],102:[function(require,module,exports){ +},{"../OuterSubscriber":50,"../util/errorObject":216,"../util/subscribeToResult":238,"../util/tryCatch":240}],119:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -10380,7 +18917,7 @@ var FilterSubscriber = (function (_super) { return FilterSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38}],103:[function(require,module,exports){ +},{"../Subscriber":55}],120:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -10421,7 +18958,7 @@ var FinallySubscriber = (function (_super) { return FinallySubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38,"../Subscription":39}],104:[function(require,module,exports){ +},{"../Subscriber":55,"../Subscription":56}],121:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -10495,7 +19032,7 @@ var FindValueSubscriber = (function (_super) { }(Subscriber_1.Subscriber)); exports.FindValueSubscriber = FindValueSubscriber; -},{"../Subscriber":38}],105:[function(require,module,exports){ +},{"../Subscriber":55}],122:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var find_1 = require("../operators/find"); @@ -10504,7 +19041,7 @@ function findIndex(predicate, thisArg) { } exports.findIndex = findIndex; -},{"../operators/find":104}],106:[function(require,module,exports){ +},{"../operators/find":121}],123:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var EmptyError_1 = require("../util/EmptyError"); @@ -10519,7 +19056,7 @@ function first(predicate, defaultValue) { } exports.first = first; -},{"../util/EmptyError":193,"../util/identity":201,"./defaultIfEmpty":89,"./filter":102,"./take":154,"./throwIfEmpty":161}],107:[function(require,module,exports){ +},{"../util/EmptyError":210,"../util/identity":218,"./defaultIfEmpty":106,"./filter":119,"./take":171,"./throwIfEmpty":178}],124:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -10716,7 +19253,7 @@ var InnerRefCountSubscription = (function (_super) { return InnerRefCountSubscription; }(Subscription_1.Subscription)); -},{"../Observable":31,"../Subject":36,"../Subscriber":38,"../Subscription":39}],108:[function(require,module,exports){ +},{"../Observable":48,"../Subject":53,"../Subscriber":55,"../Subscription":56}],125:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -10757,7 +19294,7 @@ var IgnoreElementsSubscriber = (function (_super) { return IgnoreElementsSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38}],109:[function(require,module,exports){ +},{"../Subscriber":55}],126:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -10805,7 +19342,7 @@ var IsEmptySubscriber = (function (_super) { return IsEmptySubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38}],110:[function(require,module,exports){ +},{"../Subscriber":55}],127:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var EmptyError_1 = require("../util/EmptyError"); @@ -10820,7 +19357,7 @@ function last(predicate, defaultValue) { } exports.last = last; -},{"../util/EmptyError":193,"../util/identity":201,"./defaultIfEmpty":89,"./filter":102,"./takeLast":155,"./throwIfEmpty":161}],111:[function(require,module,exports){ +},{"../util/EmptyError":210,"../util/identity":218,"./defaultIfEmpty":106,"./filter":119,"./takeLast":172,"./throwIfEmpty":178}],128:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -10880,7 +19417,7 @@ var MapSubscriber = (function (_super) { return MapSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38}],112:[function(require,module,exports){ +},{"../Subscriber":55}],129:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -10923,7 +19460,7 @@ var MapToSubscriber = (function (_super) { return MapToSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38}],113:[function(require,module,exports){ +},{"../Subscriber":55}],130:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -10976,7 +19513,7 @@ var MaterializeSubscriber = (function (_super) { return MaterializeSubscriber; }(Subscriber_1.Subscriber)); -},{"../Notification":30,"../Subscriber":38}],114:[function(require,module,exports){ +},{"../Notification":47,"../Subscriber":55}],131:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var reduce_1 = require("./reduce"); @@ -10988,7 +19525,7 @@ function max(comparer) { } exports.max = max; -},{"./reduce":132}],115:[function(require,module,exports){ +},{"./reduce":149}],132:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var merge_1 = require("../observable/merge"); @@ -11001,7 +19538,7 @@ function merge() { } exports.merge = merge; -},{"../observable/merge":60}],116:[function(require,module,exports){ +},{"../observable/merge":77}],133:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var mergeMap_1 = require("./mergeMap"); @@ -11012,7 +19549,7 @@ function mergeAll(concurrent) { } exports.mergeAll = mergeAll; -},{"../util/identity":201,"./mergeMap":117}],117:[function(require,module,exports){ +},{"../util/identity":218,"./mergeMap":134}],134:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -11121,7 +19658,7 @@ var MergeMapSubscriber = (function (_super) { }(OuterSubscriber_1.OuterSubscriber)); exports.MergeMapSubscriber = MergeMapSubscriber; -},{"../InnerSubscriber":29,"../OuterSubscriber":33,"../observable/from":50,"../util/subscribeToResult":221,"./map":111}],118:[function(require,module,exports){ +},{"../InnerSubscriber":46,"../OuterSubscriber":50,"../observable/from":67,"../util/subscribeToResult":238,"./map":128}],135:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var mergeMap_1 = require("./mergeMap"); @@ -11137,7 +19674,7 @@ function mergeMapTo(innerObservable, resultSelector, concurrent) { } exports.mergeMapTo = mergeMapTo; -},{"./mergeMap":117}],119:[function(require,module,exports){ +},{"./mergeMap":134}],136:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -11247,7 +19784,7 @@ var MergeScanSubscriber = (function (_super) { }(OuterSubscriber_1.OuterSubscriber)); exports.MergeScanSubscriber = MergeScanSubscriber; -},{"../InnerSubscriber":29,"../OuterSubscriber":33,"../util/errorObject":199,"../util/subscribeToResult":221,"../util/tryCatch":223}],120:[function(require,module,exports){ +},{"../InnerSubscriber":46,"../OuterSubscriber":50,"../util/errorObject":216,"../util/subscribeToResult":238,"../util/tryCatch":240}],137:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var reduce_1 = require("./reduce"); @@ -11259,7 +19796,7 @@ function min(comparer) { } exports.min = min; -},{"./reduce":132}],121:[function(require,module,exports){ +},{"./reduce":149}],138:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var ConnectableObservable_1 = require("../observable/ConnectableObservable"); @@ -11300,7 +19837,7 @@ var MulticastOperator = (function () { }()); exports.MulticastOperator = MulticastOperator; -},{"../observable/ConnectableObservable":41}],122:[function(require,module,exports){ +},{"../observable/ConnectableObservable":58}],139:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -11378,7 +19915,7 @@ var ObserveOnMessage = (function () { }()); exports.ObserveOnMessage = ObserveOnMessage; -},{"../Notification":30,"../Subscriber":38}],123:[function(require,module,exports){ +},{"../Notification":47,"../Subscriber":55}],140:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -11469,7 +20006,7 @@ var OnErrorResumeNextSubscriber = (function (_super) { return OnErrorResumeNextSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../InnerSubscriber":29,"../OuterSubscriber":33,"../observable/from":50,"../util/isArray":202,"../util/subscribeToResult":221}],124:[function(require,module,exports){ +},{"../InnerSubscriber":46,"../OuterSubscriber":50,"../observable/from":67,"../util/isArray":219,"../util/subscribeToResult":238}],141:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -11517,7 +20054,7 @@ var PairwiseSubscriber = (function (_super) { return PairwiseSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38}],125:[function(require,module,exports){ +},{"../Subscriber":55}],142:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var not_1 = require("../util/not"); @@ -11530,7 +20067,7 @@ function partition(predicate, thisArg) { } exports.partition = partition; -},{"../util/not":214,"./filter":102}],126:[function(require,module,exports){ +},{"../util/not":231,"./filter":119}],143:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var map_1 = require("./map"); @@ -11563,7 +20100,7 @@ function plucker(props, length) { return mapper; } -},{"./map":111}],127:[function(require,module,exports){ +},{"./map":128}],144:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Subject_1 = require("../Subject"); @@ -11575,7 +20112,7 @@ function publish(selector) { } exports.publish = publish; -},{"../Subject":36,"./multicast":121}],128:[function(require,module,exports){ +},{"../Subject":53,"./multicast":138}],145:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var BehaviorSubject_1 = require("../BehaviorSubject"); @@ -11585,7 +20122,7 @@ function publishBehavior(value) { } exports.publishBehavior = publishBehavior; -},{"../BehaviorSubject":28,"./multicast":121}],129:[function(require,module,exports){ +},{"../BehaviorSubject":45,"./multicast":138}],146:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var AsyncSubject_1 = require("../AsyncSubject"); @@ -11595,7 +20132,7 @@ function publishLast() { } exports.publishLast = publishLast; -},{"../AsyncSubject":27,"./multicast":121}],130:[function(require,module,exports){ +},{"../AsyncSubject":44,"./multicast":138}],147:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var ReplaySubject_1 = require("../ReplaySubject"); @@ -11610,7 +20147,7 @@ function publishReplay(bufferSize, windowTime, selectorOrScheduler, scheduler) { } exports.publishReplay = publishReplay; -},{"../ReplaySubject":34,"./multicast":121}],131:[function(require,module,exports){ +},{"../ReplaySubject":51,"./multicast":138}],148:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var isArray_1 = require("../util/isArray"); @@ -11629,7 +20166,7 @@ function race() { } exports.race = race; -},{"../observable/race":65,"../util/isArray":202}],132:[function(require,module,exports){ +},{"../observable/race":82,"../util/isArray":219}],149:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var scan_1 = require("./scan"); @@ -11648,7 +20185,7 @@ function reduce(accumulator, seed) { } exports.reduce = reduce; -},{"../util/pipe":215,"./defaultIfEmpty":89,"./scan":140,"./takeLast":155}],133:[function(require,module,exports){ +},{"../util/pipe":232,"./defaultIfEmpty":106,"./scan":157,"./takeLast":172}],150:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -11721,7 +20258,7 @@ var RefCountSubscriber = (function (_super) { return RefCountSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38}],134:[function(require,module,exports){ +},{"../Subscriber":55}],151:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -11787,7 +20324,7 @@ var RepeatSubscriber = (function (_super) { return RepeatSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38,"../observable/empty":48}],135:[function(require,module,exports){ +},{"../Subscriber":55,"../observable/empty":65}],152:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -11883,7 +20420,7 @@ var RepeatWhenSubscriber = (function (_super) { return RepeatWhenSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":33,"../Subject":36,"../util/errorObject":199,"../util/subscribeToResult":221,"../util/tryCatch":223}],136:[function(require,module,exports){ +},{"../OuterSubscriber":50,"../Subject":53,"../util/errorObject":216,"../util/subscribeToResult":238,"../util/tryCatch":240}],153:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -11938,7 +20475,7 @@ var RetrySubscriber = (function (_super) { return RetrySubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38}],137:[function(require,module,exports){ +},{"../Subscriber":55}],154:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -12027,7 +20564,7 @@ var RetryWhenSubscriber = (function (_super) { return RetryWhenSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":33,"../Subject":36,"../util/errorObject":199,"../util/subscribeToResult":221,"../util/tryCatch":223}],138:[function(require,module,exports){ +},{"../OuterSubscriber":50,"../Subject":53,"../util/errorObject":216,"../util/subscribeToResult":238,"../util/tryCatch":240}],155:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -12087,7 +20624,7 @@ var SampleSubscriber = (function (_super) { return SampleSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":33,"../util/subscribeToResult":221}],139:[function(require,module,exports){ +},{"../OuterSubscriber":50,"../util/subscribeToResult":238}],156:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -12148,7 +20685,7 @@ function dispatchNotification(state) { this.schedule(state, period); } -},{"../Subscriber":38,"../scheduler/async":187}],140:[function(require,module,exports){ +},{"../Subscriber":55,"../scheduler/async":204}],157:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -12232,7 +20769,7 @@ var ScanSubscriber = (function (_super) { return ScanSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38}],141:[function(require,module,exports){ +},{"../Subscriber":55}],158:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -12362,7 +20899,7 @@ var SequenceEqualCompareToSubscriber = (function (_super) { return SequenceEqualCompareToSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38,"../util/errorObject":199,"../util/tryCatch":223}],142:[function(require,module,exports){ +},{"../Subscriber":55,"../util/errorObject":216,"../util/tryCatch":240}],159:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var multicast_1 = require("./multicast"); @@ -12376,7 +20913,7 @@ function share() { } exports.share = share; -},{"../Subject":36,"./multicast":121,"./refCount":133}],143:[function(require,module,exports){ +},{"../Subject":53,"./multicast":138,"./refCount":150}],160:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var ReplaySubject_1 = require("../ReplaySubject"); @@ -12420,7 +20957,7 @@ function shareReplayOperator(bufferSize, windowTime, scheduler) { }; } -},{"../ReplaySubject":34}],144:[function(require,module,exports){ +},{"../ReplaySubject":51}],161:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -12503,7 +21040,7 @@ var SingleSubscriber = (function (_super) { return SingleSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38,"../util/EmptyError":193}],145:[function(require,module,exports){ +},{"../Subscriber":55,"../util/EmptyError":210}],162:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -12549,7 +21086,7 @@ var SkipSubscriber = (function (_super) { return SkipSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38}],146:[function(require,module,exports){ +},{"../Subscriber":55}],163:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -12614,7 +21151,7 @@ var SkipLastSubscriber = (function (_super) { return SkipLastSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38,"../util/ArgumentOutOfRangeError":192}],147:[function(require,module,exports){ +},{"../Subscriber":55,"../util/ArgumentOutOfRangeError":209}],164:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -12673,7 +21210,7 @@ var SkipUntilSubscriber = (function (_super) { return SkipUntilSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../InnerSubscriber":29,"../OuterSubscriber":33,"../util/subscribeToResult":221}],148:[function(require,module,exports){ +},{"../InnerSubscriber":46,"../OuterSubscriber":50,"../util/subscribeToResult":238}],165:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -12733,7 +21270,7 @@ var SkipWhileSubscriber = (function (_super) { return SkipWhileSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38}],149:[function(require,module,exports){ +},{"../Subscriber":55}],166:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var fromArray_1 = require("../observable/fromArray"); @@ -12768,7 +21305,7 @@ function startWith() { } exports.startWith = startWith; -},{"../observable/concat":46,"../observable/empty":48,"../observable/fromArray":51,"../observable/scalar":67,"../util/isScheduler":212}],150:[function(require,module,exports){ +},{"../observable/concat":63,"../observable/empty":65,"../observable/fromArray":68,"../observable/scalar":84,"../util/isScheduler":229}],167:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var SubscribeOnObservable_1 = require("../observable/SubscribeOnObservable"); @@ -12790,7 +21327,7 @@ var SubscribeOnOperator = (function () { return SubscribeOnOperator; }()); -},{"../observable/SubscribeOnObservable":42}],151:[function(require,module,exports){ +},{"../observable/SubscribeOnObservable":59}],168:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var switchMap_1 = require("./switchMap"); @@ -12800,7 +21337,7 @@ function switchAll() { } exports.switchAll = switchAll; -},{"../util/identity":201,"./switchMap":152}],152:[function(require,module,exports){ +},{"../util/identity":218,"./switchMap":169}],169:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -12891,7 +21428,7 @@ var SwitchMapSubscriber = (function (_super) { return SwitchMapSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../InnerSubscriber":29,"../OuterSubscriber":33,"../observable/from":50,"../util/subscribeToResult":221,"./map":111}],153:[function(require,module,exports){ +},{"../InnerSubscriber":46,"../OuterSubscriber":50,"../observable/from":67,"../util/subscribeToResult":238,"./map":128}],170:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var switchMap_1 = require("./switchMap"); @@ -12900,7 +21437,7 @@ function switchMapTo(innerObservable, resultSelector) { } exports.switchMapTo = switchMapTo; -},{"./switchMap":152}],154:[function(require,module,exports){ +},{"./switchMap":169}],171:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -12964,7 +21501,7 @@ var TakeSubscriber = (function (_super) { return TakeSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38,"../observable/empty":48,"../util/ArgumentOutOfRangeError":192}],155:[function(require,module,exports){ +},{"../Subscriber":55,"../observable/empty":65,"../util/ArgumentOutOfRangeError":209}],172:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -13043,7 +21580,7 @@ var TakeLastSubscriber = (function (_super) { return TakeLastSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38,"../observable/empty":48,"../util/ArgumentOutOfRangeError":192}],156:[function(require,module,exports){ +},{"../Subscriber":55,"../observable/empty":65,"../util/ArgumentOutOfRangeError":209}],173:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -13096,7 +21633,7 @@ var TakeUntilSubscriber = (function (_super) { return TakeUntilSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":33,"../util/subscribeToResult":221}],157:[function(require,module,exports){ +},{"../OuterSubscriber":50,"../util/subscribeToResult":238}],174:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -13158,7 +21695,7 @@ var TakeWhileSubscriber = (function (_super) { return TakeWhileSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38}],158:[function(require,module,exports){ +},{"../Subscriber":55}],175:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -13248,7 +21785,7 @@ var TapSubscriber = (function (_super) { return TapSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subscriber":38,"../util/isFunction":205,"../util/noop":213}],159:[function(require,module,exports){ +},{"../Subscriber":55,"../util/isFunction":222,"../util/noop":230}],176:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -13352,7 +21889,7 @@ var ThrottleSubscriber = (function (_super) { return ThrottleSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":33,"../util/subscribeToResult":221}],160:[function(require,module,exports){ +},{"../OuterSubscriber":50,"../util/subscribeToResult":238}],177:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -13444,7 +21981,7 @@ function dispatchNext(arg) { subscriber.clearThrottle(); } -},{"../Subscriber":38,"../scheduler/async":187,"./throttle":159}],161:[function(require,module,exports){ +},{"../Subscriber":55,"../scheduler/async":204,"./throttle":176}],178:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tap_1 = require("./tap"); @@ -13465,7 +22002,7 @@ function defaultErrorFactory() { return new EmptyError_1.EmptyError(); } -},{"../util/EmptyError":193,"./tap":158}],162:[function(require,module,exports){ +},{"../util/EmptyError":210,"./tap":175}],179:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var async_1 = require("../scheduler/async"); @@ -13494,7 +22031,7 @@ var TimeInterval = (function () { }()); exports.TimeInterval = TimeInterval; -},{"../observable/defer":47,"../scheduler/async":187,"./map":111,"./scan":140}],163:[function(require,module,exports){ +},{"../observable/defer":64,"../scheduler/async":204,"./map":128,"./scan":157}],180:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var async_1 = require("../scheduler/async"); @@ -13507,7 +22044,7 @@ function timeout(due, scheduler) { } exports.timeout = timeout; -},{"../observable/throwError":68,"../scheduler/async":187,"../util/TimeoutError":196,"./timeoutWith":164}],164:[function(require,module,exports){ +},{"../observable/throwError":85,"../scheduler/async":204,"../util/TimeoutError":213,"./timeoutWith":181}],181:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -13588,7 +22125,7 @@ var TimeoutWithSubscriber = (function (_super) { return TimeoutWithSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":33,"../scheduler/async":187,"../util/isDate":204,"../util/subscribeToResult":221}],165:[function(require,module,exports){ +},{"../OuterSubscriber":50,"../scheduler/async":204,"../util/isDate":221,"../util/subscribeToResult":238}],182:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var async_1 = require("../scheduler/async"); @@ -13607,7 +22144,7 @@ var Timestamp = (function () { }()); exports.Timestamp = Timestamp; -},{"../scheduler/async":187,"./map":111}],166:[function(require,module,exports){ +},{"../scheduler/async":204,"./map":128}],183:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var reduce_1 = require("./reduce"); @@ -13623,7 +22160,7 @@ function toArray() { } exports.toArray = toArray; -},{"./reduce":132}],167:[function(require,module,exports){ +},{"./reduce":149}],184:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -13705,7 +22242,7 @@ var WindowSubscriber = (function (_super) { return WindowSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":33,"../Subject":36,"../util/subscribeToResult":221}],168:[function(require,module,exports){ +},{"../OuterSubscriber":50,"../Subject":53,"../util/subscribeToResult":238}],185:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -13796,7 +22333,7 @@ var WindowCountSubscriber = (function (_super) { return WindowCountSubscriber; }(Subscriber_1.Subscriber)); -},{"../Subject":36,"../Subscriber":38}],169:[function(require,module,exports){ +},{"../Subject":53,"../Subscriber":55}],186:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -13966,7 +22503,7 @@ function dispatchWindowClose(state) { subscriber.closeWindow(window); } -},{"../Subject":36,"../Subscriber":38,"../scheduler/async":187,"../util/isNumeric":208,"../util/isScheduler":212}],170:[function(require,module,exports){ +},{"../Subject":53,"../Subscriber":55,"../scheduler/async":204,"../util/isNumeric":225,"../util/isScheduler":229}],187:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -14111,7 +22648,7 @@ var WindowToggleSubscriber = (function (_super) { return WindowToggleSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":33,"../Subject":36,"../Subscription":39,"../util/errorObject":199,"../util/subscribeToResult":221,"../util/tryCatch":223}],171:[function(require,module,exports){ +},{"../OuterSubscriber":50,"../Subject":53,"../Subscription":56,"../util/errorObject":216,"../util/subscribeToResult":238,"../util/tryCatch":240}],188:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -14208,7 +22745,7 @@ var WindowSubscriber = (function (_super) { return WindowSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":33,"../Subject":36,"../util/errorObject":199,"../util/subscribeToResult":221,"../util/tryCatch":223}],172:[function(require,module,exports){ +},{"../OuterSubscriber":50,"../Subject":53,"../util/errorObject":216,"../util/subscribeToResult":238,"../util/tryCatch":240}],189:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -14306,7 +22843,7 @@ var WithLatestFromSubscriber = (function (_super) { return WithLatestFromSubscriber; }(OuterSubscriber_1.OuterSubscriber)); -},{"../OuterSubscriber":33,"../util/subscribeToResult":221}],173:[function(require,module,exports){ +},{"../OuterSubscriber":50,"../util/subscribeToResult":238}],190:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var zip_1 = require("../observable/zip"); @@ -14321,7 +22858,7 @@ function zip() { } exports.zip = zip; -},{"../observable/zip":71}],174:[function(require,module,exports){ +},{"../observable/zip":88}],191:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var zip_1 = require("../observable/zip"); @@ -14330,7 +22867,7 @@ function zipAll(project) { } exports.zipAll = zipAll; -},{"../observable/zip":71}],175:[function(require,module,exports){ +},{"../observable/zip":88}],192:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -14360,7 +22897,7 @@ var Action = (function (_super) { }(Subscription_1.Subscription)); exports.Action = Action; -},{"../Subscription":39}],176:[function(require,module,exports){ +},{"../Subscription":56}],193:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -14408,7 +22945,7 @@ var AnimationFrameAction = (function (_super) { }(AsyncAction_1.AsyncAction)); exports.AnimationFrameAction = AnimationFrameAction; -},{"./AsyncAction":180}],177:[function(require,module,exports){ +},{"./AsyncAction":197}],194:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -14455,7 +22992,7 @@ var AnimationFrameScheduler = (function (_super) { }(AsyncScheduler_1.AsyncScheduler)); exports.AnimationFrameScheduler = AnimationFrameScheduler; -},{"./AsyncScheduler":181}],178:[function(require,module,exports){ +},{"./AsyncScheduler":198}],195:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -14504,7 +23041,7 @@ var AsapAction = (function (_super) { }(AsyncAction_1.AsyncAction)); exports.AsapAction = AsapAction; -},{"../util/Immediate":194,"./AsyncAction":180}],179:[function(require,module,exports){ +},{"../util/Immediate":211,"./AsyncAction":197}],196:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -14551,7 +23088,7 @@ var AsapScheduler = (function (_super) { }(AsyncScheduler_1.AsyncScheduler)); exports.AsapScheduler = AsapScheduler; -},{"./AsyncScheduler":181}],180:[function(require,module,exports){ +},{"./AsyncScheduler":198}],197:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -14653,7 +23190,7 @@ var AsyncAction = (function (_super) { }(Action_1.Action)); exports.AsyncAction = AsyncAction; -},{"./Action":175}],181:[function(require,module,exports){ +},{"./Action":192}],198:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -14721,7 +23258,7 @@ var AsyncScheduler = (function (_super) { }(Scheduler_1.Scheduler)); exports.AsyncScheduler = AsyncScheduler; -},{"../Scheduler":35}],182:[function(require,module,exports){ +},{"../Scheduler":52}],199:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -14772,7 +23309,7 @@ var QueueAction = (function (_super) { }(AsyncAction_1.AsyncAction)); exports.QueueAction = QueueAction; -},{"./AsyncAction":180}],183:[function(require,module,exports){ +},{"./AsyncAction":197}],200:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -14798,7 +23335,7 @@ var QueueScheduler = (function (_super) { }(AsyncScheduler_1.AsyncScheduler)); exports.QueueScheduler = QueueScheduler; -},{"./AsyncScheduler":181}],184:[function(require,module,exports){ +},{"./AsyncScheduler":198}],201:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -14908,35 +23445,35 @@ var VirtualAction = (function (_super) { }(AsyncAction_1.AsyncAction)); exports.VirtualAction = VirtualAction; -},{"./AsyncAction":180,"./AsyncScheduler":181}],185:[function(require,module,exports){ +},{"./AsyncAction":197,"./AsyncScheduler":198}],202:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var AnimationFrameAction_1 = require("./AnimationFrameAction"); var AnimationFrameScheduler_1 = require("./AnimationFrameScheduler"); exports.animationFrame = new AnimationFrameScheduler_1.AnimationFrameScheduler(AnimationFrameAction_1.AnimationFrameAction); -},{"./AnimationFrameAction":176,"./AnimationFrameScheduler":177}],186:[function(require,module,exports){ +},{"./AnimationFrameAction":193,"./AnimationFrameScheduler":194}],203:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var AsapAction_1 = require("./AsapAction"); var AsapScheduler_1 = require("./AsapScheduler"); exports.asap = new AsapScheduler_1.AsapScheduler(AsapAction_1.AsapAction); -},{"./AsapAction":178,"./AsapScheduler":179}],187:[function(require,module,exports){ +},{"./AsapAction":195,"./AsapScheduler":196}],204:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var AsyncAction_1 = require("./AsyncAction"); var AsyncScheduler_1 = require("./AsyncScheduler"); exports.async = new AsyncScheduler_1.AsyncScheduler(AsyncAction_1.AsyncAction); -},{"./AsyncAction":180,"./AsyncScheduler":181}],188:[function(require,module,exports){ +},{"./AsyncAction":197,"./AsyncScheduler":198}],205:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var QueueAction_1 = require("./QueueAction"); var QueueScheduler_1 = require("./QueueScheduler"); exports.queue = new QueueScheduler_1.QueueScheduler(QueueAction_1.QueueAction); -},{"./QueueAction":182,"./QueueScheduler":183}],189:[function(require,module,exports){ +},{"./QueueAction":199,"./QueueScheduler":200}],206:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function getSymbolIterator() { @@ -14949,12 +23486,12 @@ exports.getSymbolIterator = getSymbolIterator; exports.iterator = getSymbolIterator(); exports.$$iterator = exports.iterator; -},{}],190:[function(require,module,exports){ +},{}],207:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.observable = typeof Symbol === 'function' && Symbol.observable || '@@observable'; -},{}],191:[function(require,module,exports){ +},{}],208:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.rxSubscriber = typeof Symbol === 'function' @@ -14962,7 +23499,7 @@ exports.rxSubscriber = typeof Symbol === 'function' : '@@rxSubscriber_' + Math.random(); exports.$$rxSubscriber = exports.rxSubscriber; -},{}],192:[function(require,module,exports){ +},{}],209:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function ArgumentOutOfRangeErrorImpl() { @@ -14974,7 +23511,7 @@ function ArgumentOutOfRangeErrorImpl() { ArgumentOutOfRangeErrorImpl.prototype = Object.create(Error.prototype); exports.ArgumentOutOfRangeError = ArgumentOutOfRangeErrorImpl; -},{}],193:[function(require,module,exports){ +},{}],210:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function EmptyErrorImpl() { @@ -14986,7 +23523,7 @@ function EmptyErrorImpl() { EmptyErrorImpl.prototype = Object.create(Error.prototype); exports.EmptyError = EmptyErrorImpl; -},{}],194:[function(require,module,exports){ +},{}],211:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var nextHandle = 1; @@ -15009,7 +23546,7 @@ exports.Immediate = { }, }; -},{}],195:[function(require,module,exports){ +},{}],212:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function ObjectUnsubscribedErrorImpl() { @@ -15021,7 +23558,7 @@ function ObjectUnsubscribedErrorImpl() { ObjectUnsubscribedErrorImpl.prototype = Object.create(Error.prototype); exports.ObjectUnsubscribedError = ObjectUnsubscribedErrorImpl; -},{}],196:[function(require,module,exports){ +},{}],213:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function TimeoutErrorImpl() { @@ -15033,7 +23570,7 @@ function TimeoutErrorImpl() { TimeoutErrorImpl.prototype = Object.create(Error.prototype); exports.TimeoutError = TimeoutErrorImpl; -},{}],197:[function(require,module,exports){ +},{}],214:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function UnsubscriptionErrorImpl(errors) { @@ -15047,7 +23584,7 @@ function UnsubscriptionErrorImpl(errors) { UnsubscriptionErrorImpl.prototype = Object.create(Error.prototype); exports.UnsubscriptionError = UnsubscriptionErrorImpl; -},{}],198:[function(require,module,exports){ +},{}],215:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Subscriber_1 = require("../Subscriber"); @@ -15068,12 +23605,12 @@ function canReportError(observer) { } exports.canReportError = canReportError; -},{"../Subscriber":38}],199:[function(require,module,exports){ +},{"../Subscriber":55}],216:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.errorObject = { e: {} }; -},{}],200:[function(require,module,exports){ +},{}],217:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function hostReportError(err) { @@ -15081,7 +23618,7 @@ function hostReportError(err) { } exports.hostReportError = hostReportError; -},{}],201:[function(require,module,exports){ +},{}],218:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function identity(x) { @@ -15089,17 +23626,17 @@ function identity(x) { } exports.identity = identity; -},{}],202:[function(require,module,exports){ +},{}],219:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isArray = Array.isArray || (function (x) { return x && typeof x.length === 'number'; }); -},{}],203:[function(require,module,exports){ +},{}],220:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isArrayLike = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; }); -},{}],204:[function(require,module,exports){ +},{}],221:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function isDate(value) { @@ -15107,7 +23644,7 @@ function isDate(value) { } exports.isDate = isDate; -},{}],205:[function(require,module,exports){ +},{}],222:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function isFunction(x) { @@ -15115,7 +23652,7 @@ function isFunction(x) { } exports.isFunction = isFunction; -},{}],206:[function(require,module,exports){ +},{}],223:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var observable_1 = require("../symbol/observable"); @@ -15124,7 +23661,7 @@ function isInteropObservable(input) { } exports.isInteropObservable = isInteropObservable; -},{"../symbol/observable":190}],207:[function(require,module,exports){ +},{"../symbol/observable":207}],224:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var iterator_1 = require("../symbol/iterator"); @@ -15133,7 +23670,7 @@ function isIterable(input) { } exports.isIterable = isIterable; -},{"../symbol/iterator":189}],208:[function(require,module,exports){ +},{"../symbol/iterator":206}],225:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var isArray_1 = require("./isArray"); @@ -15142,7 +23679,7 @@ function isNumeric(val) { } exports.isNumeric = isNumeric; -},{"./isArray":202}],209:[function(require,module,exports){ +},{"./isArray":219}],226:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function isObject(x) { @@ -15150,7 +23687,7 @@ function isObject(x) { } exports.isObject = isObject; -},{}],210:[function(require,module,exports){ +},{}],227:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Observable_1 = require("../Observable"); @@ -15159,7 +23696,7 @@ function isObservable(obj) { } exports.isObservable = isObservable; -},{"../Observable":31}],211:[function(require,module,exports){ +},{"../Observable":48}],228:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function isPromise(value) { @@ -15167,7 +23704,7 @@ function isPromise(value) { } exports.isPromise = isPromise; -},{}],212:[function(require,module,exports){ +},{}],229:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function isScheduler(value) { @@ -15175,13 +23712,13 @@ function isScheduler(value) { } exports.isScheduler = isScheduler; -},{}],213:[function(require,module,exports){ +},{}],230:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function noop() { } exports.noop = noop; -},{}],214:[function(require,module,exports){ +},{}],231:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function not(pred, thisArg) { @@ -15194,7 +23731,7 @@ function not(pred, thisArg) { } exports.not = not; -},{}],215:[function(require,module,exports){ +},{}],232:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var noop_1 = require("./noop"); @@ -15219,7 +23756,7 @@ function pipeFromArray(fns) { } exports.pipeFromArray = pipeFromArray; -},{"./noop":213}],216:[function(require,module,exports){ +},{"./noop":230}],233:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Observable_1 = require("../Observable"); @@ -15265,7 +23802,7 @@ exports.subscribeTo = function (result) { } }; -},{"../Observable":31,"../symbol/iterator":189,"../symbol/observable":190,"./isArrayLike":203,"./isObject":209,"./isPromise":211,"./subscribeToArray":217,"./subscribeToIterable":218,"./subscribeToObservable":219,"./subscribeToPromise":220}],217:[function(require,module,exports){ +},{"../Observable":48,"../symbol/iterator":206,"../symbol/observable":207,"./isArrayLike":220,"./isObject":226,"./isPromise":228,"./subscribeToArray":234,"./subscribeToIterable":235,"./subscribeToObservable":236,"./subscribeToPromise":237}],234:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.subscribeToArray = function (array) { return function (subscriber) { @@ -15277,7 +23814,7 @@ exports.subscribeToArray = function (array) { return function (subscriber) { } }; }; -},{}],218:[function(require,module,exports){ +},{}],235:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var iterator_1 = require("../symbol/iterator"); @@ -15304,7 +23841,7 @@ exports.subscribeToIterable = function (iterable) { return function (subscriber) return subscriber; }; }; -},{"../symbol/iterator":189}],219:[function(require,module,exports){ +},{"../symbol/iterator":206}],236:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var observable_1 = require("../symbol/observable"); @@ -15318,7 +23855,7 @@ exports.subscribeToObservable = function (obj) { return function (subscriber) { } }; }; -},{"../symbol/observable":190}],220:[function(require,module,exports){ +},{"../symbol/observable":207}],237:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var hostReportError_1 = require("./hostReportError"); @@ -15333,7 +23870,7 @@ exports.subscribeToPromise = function (promise) { return function (subscriber) { return subscriber; }; }; -},{"./hostReportError":200}],221:[function(require,module,exports){ +},{"./hostReportError":217}],238:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var InnerSubscriber_1 = require("../InnerSubscriber"); @@ -15347,7 +23884,7 @@ function subscribeToResult(outerSubscriber, result, outerValue, outerIndex, dest } exports.subscribeToResult = subscribeToResult; -},{"../InnerSubscriber":29,"./subscribeTo":216}],222:[function(require,module,exports){ +},{"../InnerSubscriber":46,"./subscribeTo":233}],239:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Subscriber_1 = require("../Subscriber"); @@ -15369,7 +23906,7 @@ function toSubscriber(nextOrObserver, error, complete) { } exports.toSubscriber = toSubscriber; -},{"../Observer":32,"../Subscriber":38,"../symbol/rxSubscriber":191}],223:[function(require,module,exports){ +},{"../Observer":49,"../Subscriber":55,"../symbol/rxSubscriber":208}],240:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var errorObject_1 = require("./errorObject"); @@ -15389,7 +23926,7 @@ function tryCatch(fn) { } exports.tryCatch = tryCatch; -},{"./errorObject":199}],224:[function(require,module,exports){ +},{"./errorObject":216}],241:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var audit_1 = require("../internal/operators/audit"); @@ -15601,7 +24138,7 @@ exports.zip = zip_1.zip; var zipAll_1 = require("../internal/operators/zipAll"); exports.zipAll = zipAll_1.zipAll; -},{"../internal/operators/audit":72,"../internal/operators/auditTime":73,"../internal/operators/buffer":74,"../internal/operators/bufferCount":75,"../internal/operators/bufferTime":76,"../internal/operators/bufferToggle":77,"../internal/operators/bufferWhen":78,"../internal/operators/catchError":79,"../internal/operators/combineAll":80,"../internal/operators/combineLatest":81,"../internal/operators/concat":82,"../internal/operators/concatAll":83,"../internal/operators/concatMap":84,"../internal/operators/concatMapTo":85,"../internal/operators/count":86,"../internal/operators/debounce":87,"../internal/operators/debounceTime":88,"../internal/operators/defaultIfEmpty":89,"../internal/operators/delay":90,"../internal/operators/delayWhen":91,"../internal/operators/dematerialize":92,"../internal/operators/distinct":93,"../internal/operators/distinctUntilChanged":94,"../internal/operators/distinctUntilKeyChanged":95,"../internal/operators/elementAt":96,"../internal/operators/endWith":97,"../internal/operators/every":98,"../internal/operators/exhaust":99,"../internal/operators/exhaustMap":100,"../internal/operators/expand":101,"../internal/operators/filter":102,"../internal/operators/finalize":103,"../internal/operators/find":104,"../internal/operators/findIndex":105,"../internal/operators/first":106,"../internal/operators/groupBy":107,"../internal/operators/ignoreElements":108,"../internal/operators/isEmpty":109,"../internal/operators/last":110,"../internal/operators/map":111,"../internal/operators/mapTo":112,"../internal/operators/materialize":113,"../internal/operators/max":114,"../internal/operators/merge":115,"../internal/operators/mergeAll":116,"../internal/operators/mergeMap":117,"../internal/operators/mergeMapTo":118,"../internal/operators/mergeScan":119,"../internal/operators/min":120,"../internal/operators/multicast":121,"../internal/operators/observeOn":122,"../internal/operators/onErrorResumeNext":123,"../internal/operators/pairwise":124,"../internal/operators/partition":125,"../internal/operators/pluck":126,"../internal/operators/publish":127,"../internal/operators/publishBehavior":128,"../internal/operators/publishLast":129,"../internal/operators/publishReplay":130,"../internal/operators/race":131,"../internal/operators/reduce":132,"../internal/operators/refCount":133,"../internal/operators/repeat":134,"../internal/operators/repeatWhen":135,"../internal/operators/retry":136,"../internal/operators/retryWhen":137,"../internal/operators/sample":138,"../internal/operators/sampleTime":139,"../internal/operators/scan":140,"../internal/operators/sequenceEqual":141,"../internal/operators/share":142,"../internal/operators/shareReplay":143,"../internal/operators/single":144,"../internal/operators/skip":145,"../internal/operators/skipLast":146,"../internal/operators/skipUntil":147,"../internal/operators/skipWhile":148,"../internal/operators/startWith":149,"../internal/operators/subscribeOn":150,"../internal/operators/switchAll":151,"../internal/operators/switchMap":152,"../internal/operators/switchMapTo":153,"../internal/operators/take":154,"../internal/operators/takeLast":155,"../internal/operators/takeUntil":156,"../internal/operators/takeWhile":157,"../internal/operators/tap":158,"../internal/operators/throttle":159,"../internal/operators/throttleTime":160,"../internal/operators/throwIfEmpty":161,"../internal/operators/timeInterval":162,"../internal/operators/timeout":163,"../internal/operators/timeoutWith":164,"../internal/operators/timestamp":165,"../internal/operators/toArray":166,"../internal/operators/window":167,"../internal/operators/windowCount":168,"../internal/operators/windowTime":169,"../internal/operators/windowToggle":170,"../internal/operators/windowWhen":171,"../internal/operators/withLatestFrom":172,"../internal/operators/zip":173,"../internal/operators/zipAll":174}],225:[function(require,module,exports){ +},{"../internal/operators/audit":89,"../internal/operators/auditTime":90,"../internal/operators/buffer":91,"../internal/operators/bufferCount":92,"../internal/operators/bufferTime":93,"../internal/operators/bufferToggle":94,"../internal/operators/bufferWhen":95,"../internal/operators/catchError":96,"../internal/operators/combineAll":97,"../internal/operators/combineLatest":98,"../internal/operators/concat":99,"../internal/operators/concatAll":100,"../internal/operators/concatMap":101,"../internal/operators/concatMapTo":102,"../internal/operators/count":103,"../internal/operators/debounce":104,"../internal/operators/debounceTime":105,"../internal/operators/defaultIfEmpty":106,"../internal/operators/delay":107,"../internal/operators/delayWhen":108,"../internal/operators/dematerialize":109,"../internal/operators/distinct":110,"../internal/operators/distinctUntilChanged":111,"../internal/operators/distinctUntilKeyChanged":112,"../internal/operators/elementAt":113,"../internal/operators/endWith":114,"../internal/operators/every":115,"../internal/operators/exhaust":116,"../internal/operators/exhaustMap":117,"../internal/operators/expand":118,"../internal/operators/filter":119,"../internal/operators/finalize":120,"../internal/operators/find":121,"../internal/operators/findIndex":122,"../internal/operators/first":123,"../internal/operators/groupBy":124,"../internal/operators/ignoreElements":125,"../internal/operators/isEmpty":126,"../internal/operators/last":127,"../internal/operators/map":128,"../internal/operators/mapTo":129,"../internal/operators/materialize":130,"../internal/operators/max":131,"../internal/operators/merge":132,"../internal/operators/mergeAll":133,"../internal/operators/mergeMap":134,"../internal/operators/mergeMapTo":135,"../internal/operators/mergeScan":136,"../internal/operators/min":137,"../internal/operators/multicast":138,"../internal/operators/observeOn":139,"../internal/operators/onErrorResumeNext":140,"../internal/operators/pairwise":141,"../internal/operators/partition":142,"../internal/operators/pluck":143,"../internal/operators/publish":144,"../internal/operators/publishBehavior":145,"../internal/operators/publishLast":146,"../internal/operators/publishReplay":147,"../internal/operators/race":148,"../internal/operators/reduce":149,"../internal/operators/refCount":150,"../internal/operators/repeat":151,"../internal/operators/repeatWhen":152,"../internal/operators/retry":153,"../internal/operators/retryWhen":154,"../internal/operators/sample":155,"../internal/operators/sampleTime":156,"../internal/operators/scan":157,"../internal/operators/sequenceEqual":158,"../internal/operators/share":159,"../internal/operators/shareReplay":160,"../internal/operators/single":161,"../internal/operators/skip":162,"../internal/operators/skipLast":163,"../internal/operators/skipUntil":164,"../internal/operators/skipWhile":165,"../internal/operators/startWith":166,"../internal/operators/subscribeOn":167,"../internal/operators/switchAll":168,"../internal/operators/switchMap":169,"../internal/operators/switchMapTo":170,"../internal/operators/take":171,"../internal/operators/takeLast":172,"../internal/operators/takeUntil":173,"../internal/operators/takeWhile":174,"../internal/operators/tap":175,"../internal/operators/throttle":176,"../internal/operators/throttleTime":177,"../internal/operators/throwIfEmpty":178,"../internal/operators/timeInterval":179,"../internal/operators/timeout":180,"../internal/operators/timeoutWith":181,"../internal/operators/timestamp":182,"../internal/operators/toArray":183,"../internal/operators/window":184,"../internal/operators/windowCount":185,"../internal/operators/windowTime":186,"../internal/operators/windowToggle":187,"../internal/operators/windowWhen":188,"../internal/operators/withLatestFrom":189,"../internal/operators/zip":190,"../internal/operators/zipAll":191}],242:[function(require,module,exports){ // threejs.org/license (function(l,ya){"object"===typeof exports&&"undefined"!==typeof module?ya(exports):"function"===typeof define&&define.amd?define(["exports"],ya):ya(l.THREE={})})(this,function(l){function ya(){}function z(a,b){this.x=a||0;this.y=b||0}function I(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];0 b ? 1 : -1 } -},{}],235:[function(require,module,exports){ +},{}],252:[function(require,module,exports){ var applyProperties = require("./apply-properties") var isWidget = require("../vnode/is-widget.js") @@ -17063,7 +25600,7 @@ function replaceRoot(oldRoot, newRoot) { return newRoot; } -},{"../vnode/is-widget.js":247,"../vnode/vpatch.js":250,"./apply-properties":232,"./update-widget":237}],236:[function(require,module,exports){ +},{"../vnode/is-widget.js":264,"../vnode/vpatch.js":267,"./apply-properties":249,"./update-widget":254}],253:[function(require,module,exports){ var document = require("global/document") var isArray = require("x-is-array") @@ -17145,7 +25682,7 @@ function patchIndices(patches) { return indices } -},{"./create-element":233,"./dom-index":234,"./patch-op":235,"global/document":16,"x-is-array":272}],237:[function(require,module,exports){ +},{"./create-element":250,"./dom-index":251,"./patch-op":252,"global/document":16,"x-is-array":289}],254:[function(require,module,exports){ var isWidget = require("../vnode/is-widget.js") module.exports = updateWidget @@ -17162,7 +25699,7 @@ function updateWidget(a, b) { return false } -},{"../vnode/is-widget.js":247}],238:[function(require,module,exports){ +},{"../vnode/is-widget.js":264}],255:[function(require,module,exports){ 'use strict'; var EvStore = require('ev-store'); @@ -17191,7 +25728,7 @@ EvHook.prototype.unhook = function(node, propertyName) { es[propName] = undefined; }; -},{"ev-store":9}],239:[function(require,module,exports){ +},{"ev-store":9}],256:[function(require,module,exports){ 'use strict'; module.exports = SoftSetHook; @@ -17210,7 +25747,7 @@ SoftSetHook.prototype.hook = function (node, propertyName) { } }; -},{}],240:[function(require,module,exports){ +},{}],257:[function(require,module,exports){ 'use strict'; var isArray = require('x-is-array'); @@ -17349,7 +25886,7 @@ function errorString(obj) { } } -},{"../vnode/is-thunk":243,"../vnode/is-vhook":244,"../vnode/is-vnode":245,"../vnode/is-vtext":246,"../vnode/is-widget":247,"../vnode/vnode.js":249,"../vnode/vtext.js":251,"./hooks/ev-hook.js":238,"./hooks/soft-set-hook.js":239,"./parse-tag.js":241,"x-is-array":272}],241:[function(require,module,exports){ +},{"../vnode/is-thunk":260,"../vnode/is-vhook":261,"../vnode/is-vnode":262,"../vnode/is-vtext":263,"../vnode/is-widget":264,"../vnode/vnode.js":266,"../vnode/vtext.js":268,"./hooks/ev-hook.js":255,"./hooks/soft-set-hook.js":256,"./parse-tag.js":258,"x-is-array":289}],258:[function(require,module,exports){ 'use strict'; var split = require('browser-split'); @@ -17405,7 +25942,7 @@ function parseTag(tag, props) { return props.namespace ? tagName : tagName.toUpperCase(); } -},{"browser-split":5}],242:[function(require,module,exports){ +},{"browser-split":5}],259:[function(require,module,exports){ var isVNode = require("./is-vnode") var isVText = require("./is-vtext") var isWidget = require("./is-widget") @@ -17447,14 +25984,14 @@ function renderThunk(thunk, previous) { return renderedThunk } -},{"./is-thunk":243,"./is-vnode":245,"./is-vtext":246,"./is-widget":247}],243:[function(require,module,exports){ +},{"./is-thunk":260,"./is-vnode":262,"./is-vtext":263,"./is-widget":264}],260:[function(require,module,exports){ module.exports = isThunk function isThunk(t) { return t && t.type === "Thunk" } -},{}],244:[function(require,module,exports){ +},{}],261:[function(require,module,exports){ module.exports = isHook function isHook(hook) { @@ -17463,7 +26000,7 @@ function isHook(hook) { typeof hook.unhook === "function" && !hook.hasOwnProperty("unhook")) } -},{}],245:[function(require,module,exports){ +},{}],262:[function(require,module,exports){ var version = require("./version") module.exports = isVirtualNode @@ -17472,7 +26009,7 @@ function isVirtualNode(x) { return x && x.type === "VirtualNode" && x.version === version } -},{"./version":248}],246:[function(require,module,exports){ +},{"./version":265}],263:[function(require,module,exports){ var version = require("./version") module.exports = isVirtualText @@ -17481,17 +26018,17 @@ function isVirtualText(x) { return x && x.type === "VirtualText" && x.version === version } -},{"./version":248}],247:[function(require,module,exports){ +},{"./version":265}],264:[function(require,module,exports){ module.exports = isWidget function isWidget(w) { return w && w.type === "Widget" } -},{}],248:[function(require,module,exports){ +},{}],265:[function(require,module,exports){ module.exports = "2" -},{}],249:[function(require,module,exports){ +},{}],266:[function(require,module,exports){ var version = require("./version") var isVNode = require("./is-vnode") var isWidget = require("./is-widget") @@ -17565,7 +26102,7 @@ function VirtualNode(tagName, properties, children, key, namespace) { VirtualNode.prototype.version = version VirtualNode.prototype.type = "VirtualNode" -},{"./is-thunk":243,"./is-vhook":244,"./is-vnode":245,"./is-widget":247,"./version":248}],250:[function(require,module,exports){ +},{"./is-thunk":260,"./is-vhook":261,"./is-vnode":262,"./is-widget":264,"./version":265}],267:[function(require,module,exports){ var version = require("./version") VirtualPatch.NONE = 0 @@ -17589,7 +26126,7 @@ function VirtualPatch(type, vNode, patch) { VirtualPatch.prototype.version = version VirtualPatch.prototype.type = "VirtualPatch" -},{"./version":248}],251:[function(require,module,exports){ +},{"./version":265}],268:[function(require,module,exports){ var version = require("./version") module.exports = VirtualText @@ -17601,7 +26138,7 @@ function VirtualText(text) { VirtualText.prototype.version = version VirtualText.prototype.type = "VirtualText" -},{"./version":248}],252:[function(require,module,exports){ +},{"./version":265}],269:[function(require,module,exports){ var isObject = require("is-object") var isHook = require("../vnode/is-vhook") @@ -17661,7 +26198,7 @@ function getPrototype(value) { } } -},{"../vnode/is-vhook":244,"is-object":20}],253:[function(require,module,exports){ +},{"../vnode/is-vhook":261,"is-object":20}],270:[function(require,module,exports){ var isArray = require("x-is-array") var VPatch = require("../vnode/vpatch") @@ -18090,7 +26627,7 @@ function appendPatch(apply, patch) { } } -},{"../vnode/handle-thunk":242,"../vnode/is-thunk":243,"../vnode/is-vnode":245,"../vnode/is-vtext":246,"../vnode/is-widget":247,"../vnode/vpatch":250,"./diff-props":252,"x-is-array":272}],254:[function(require,module,exports){ +},{"../vnode/handle-thunk":259,"../vnode/is-thunk":260,"../vnode/is-vnode":262,"../vnode/is-vtext":263,"../vnode/is-widget":264,"../vnode/vpatch":267,"./diff-props":269,"x-is-array":289}],271:[function(require,module,exports){ /** @license MIT License (c) copyright 2010-2014 original author or authors */ /** @author Brian Cavalier */ /** @author John Hann */ @@ -18109,7 +26646,7 @@ define(function (require) { }); })(typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); }); -},{"./Scheduler":255,"./env":267,"./makePromise":269}],255:[function(require,module,exports){ +},{"./Scheduler":272,"./env":284,"./makePromise":286}],272:[function(require,module,exports){ /** @license MIT License (c) copyright 2010-2014 original author or authors */ /** @author Brian Cavalier */ /** @author John Hann */ @@ -18191,7 +26728,7 @@ define(function() { }); }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); })); -},{}],256:[function(require,module,exports){ +},{}],273:[function(require,module,exports){ /** @license MIT License (c) copyright 2010-2014 original author or authors */ /** @author Brian Cavalier */ /** @author John Hann */ @@ -18219,7 +26756,7 @@ define(function() { return TimeoutError; }); }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); })); -},{}],257:[function(require,module,exports){ +},{}],274:[function(require,module,exports){ /** @license MIT License (c) copyright 2010-2014 original author or authors */ /** @author Brian Cavalier */ /** @author John Hann */ @@ -18276,7 +26813,7 @@ define(function() { -},{}],258:[function(require,module,exports){ +},{}],275:[function(require,module,exports){ /** @license MIT License (c) copyright 2010-2014 original author or authors */ /** @author Brian Cavalier */ /** @author John Hann */ @@ -18577,7 +27114,7 @@ define(function(require) { }); }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); })); -},{"../apply":257,"../state":270}],259:[function(require,module,exports){ +},{"../apply":274,"../state":287}],276:[function(require,module,exports){ /** @license MIT License (c) copyright 2010-2014 original author or authors */ /** @author Brian Cavalier */ /** @author John Hann */ @@ -18739,7 +27276,7 @@ define(function() { }); }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); })); -},{}],260:[function(require,module,exports){ +},{}],277:[function(require,module,exports){ /** @license MIT License (c) copyright 2010-2014 original author or authors */ /** @author Brian Cavalier */ /** @author John Hann */ @@ -18768,7 +27305,7 @@ define(function() { }); }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); })); -},{}],261:[function(require,module,exports){ +},{}],278:[function(require,module,exports){ /** @license MIT License (c) copyright 2010-2014 original author or authors */ /** @author Brian Cavalier */ /** @author John Hann */ @@ -18790,7 +27327,7 @@ define(function(require) { }); }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); })); -},{"../state":270}],262:[function(require,module,exports){ +},{"../state":287}],279:[function(require,module,exports){ /** @license MIT License (c) copyright 2010-2014 original author or authors */ /** @author Brian Cavalier */ /** @author John Hann */ @@ -18857,7 +27394,7 @@ define(function() { }); }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); })); -},{}],263:[function(require,module,exports){ +},{}],280:[function(require,module,exports){ /** @license MIT License (c) copyright 2010-2014 original author or authors */ /** @author Brian Cavalier */ /** @author John Hann */ @@ -18883,7 +27420,7 @@ define(function() { }); }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); })); -},{}],264:[function(require,module,exports){ +},{}],281:[function(require,module,exports){ /** @license MIT License (c) copyright 2010-2014 original author or authors */ /** @author Brian Cavalier */ /** @author John Hann */ @@ -18963,7 +27500,7 @@ define(function(require) { }); }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); })); -},{"../TimeoutError":256,"../env":267}],265:[function(require,module,exports){ +},{"../TimeoutError":273,"../env":284}],282:[function(require,module,exports){ /** @license MIT License (c) copyright 2010-2014 original author or authors */ /** @author Brian Cavalier */ /** @author John Hann */ @@ -19051,7 +27588,7 @@ define(function(require) { }); }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); })); -},{"../env":267,"../format":268}],266:[function(require,module,exports){ +},{"../env":284,"../format":285}],283:[function(require,module,exports){ /** @license MIT License (c) copyright 2010-2014 original author or authors */ /** @author Brian Cavalier */ /** @author John Hann */ @@ -19091,7 +27628,7 @@ define(function() { }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); })); -},{}],267:[function(require,module,exports){ +},{}],284:[function(require,module,exports){ (function (process){ /** @license MIT License (c) copyright 2010-2014 original author or authors */ /** @author Brian Cavalier */ @@ -19169,7 +27706,7 @@ define(function(require) { }).call(this,require('_process')) -},{"_process":6}],268:[function(require,module,exports){ +},{"_process":6}],285:[function(require,module,exports){ /** @license MIT License (c) copyright 2010-2014 original author or authors */ /** @author Brian Cavalier */ /** @author John Hann */ @@ -19227,7 +27764,7 @@ define(function() { }); }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); })); -},{}],269:[function(require,module,exports){ +},{}],286:[function(require,module,exports){ (function (process){ /** @license MIT License (c) copyright 2010-2014 original author or authors */ /** @author Brian Cavalier */ @@ -20187,7 +28724,7 @@ define(function() { }).call(this,require('_process')) -},{"_process":6}],270:[function(require,module,exports){ +},{"_process":6}],287:[function(require,module,exports){ /** @license MIT License (c) copyright 2010-2014 original author or authors */ /** @author Brian Cavalier */ /** @author John Hann */ @@ -20224,7 +28761,7 @@ define(function() { }); }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); })); -},{}],271:[function(require,module,exports){ +},{}],288:[function(require,module,exports){ /** @license MIT License (c) copyright 2010-2014 original author or authors */ /** @@ -20454,7 +28991,7 @@ define(function (require) { }); })(typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); }); -},{"./lib/Promise":254,"./lib/TimeoutError":256,"./lib/apply":257,"./lib/decorators/array":258,"./lib/decorators/flow":259,"./lib/decorators/fold":260,"./lib/decorators/inspect":261,"./lib/decorators/iterate":262,"./lib/decorators/progress":263,"./lib/decorators/timed":264,"./lib/decorators/unhandledRejection":265,"./lib/decorators/with":266}],272:[function(require,module,exports){ +},{"./lib/Promise":271,"./lib/TimeoutError":273,"./lib/apply":274,"./lib/decorators/array":275,"./lib/decorators/flow":276,"./lib/decorators/fold":277,"./lib/decorators/inspect":278,"./lib/decorators/iterate":279,"./lib/decorators/progress":280,"./lib/decorators/timed":281,"./lib/decorators/unhandledRejection":282,"./lib/decorators/with":283}],289:[function(require,module,exports){ var nativeIsArray = Array.isArray var toString = Object.prototype.toString @@ -20464,7 +29001,7 @@ function isArray(obj) { return toString.call(obj) === "[object Array]" } -},{}],273:[function(require,module,exports){ +},{}],290:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var APIv3_1 = require("./api/APIv3"); @@ -20472,7 +29009,7 @@ exports.APIv3 = APIv3_1.APIv3; var ModelCreator_1 = require("./api/ModelCreator"); exports.ModelCreator = ModelCreator_1.ModelCreator; -},{"./api/APIv3":286,"./api/ModelCreator":287}],274:[function(require,module,exports){ +},{"./api/APIv3":303,"./api/ModelCreator":304}],291:[function(require,module,exports){ "use strict"; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; @@ -20490,6 +29027,8 @@ var MeshScene_1 = require("./component/utils/MeshScene"); exports.MeshScene = MeshScene_1.MeshScene; var MouseOperator_1 = require("./component/utils/MouseOperator"); exports.MouseOperator = MouseOperator_1.MouseOperator; +var ComponentSize_1 = require("./component/utils/ComponentSize"); +exports.ComponentSize = ComponentSize_1.ComponentSize; var AttributionComponent_1 = require("./component/AttributionComponent"); exports.AttributionComponent = AttributionComponent_1.AttributionComponent; var BackgroundComponent_1 = require("./component/BackgroundComponent"); @@ -20592,6 +29131,8 @@ var CreatePointHandler_1 = require("./component/tag/handlers/CreatePointHandler" exports.CreatePointHandler = CreatePointHandler_1.CreatePointHandler; var CreateVertexHandler_1 = require("./component/tag/handlers/CreateVertexHandler"); exports.CreateVertexHandler = CreateVertexHandler_1.CreateVertexHandler; +var CreatePointsHandler_1 = require("./component/tag/handlers/CreatePointsHandler"); +exports.CreatePointsHandler = CreatePointsHandler_1.CreatePointsHandler; var CreatePolygonHandler_1 = require("./component/tag/handlers/CreatePolygonHandler"); exports.CreatePolygonHandler = CreatePolygonHandler_1.CreatePolygonHandler; var CreateRectHandler_1 = require("./component/tag/handlers/CreateRectHandler"); @@ -20604,12 +29145,16 @@ var Tag_1 = require("./component/tag/tag/Tag"); exports.Tag = Tag_1.Tag; var OutlineTag_1 = require("./component/tag/tag/OutlineTag"); exports.OutlineTag = OutlineTag_1.OutlineTag; +var ExtremePointTag_1 = require("./component/tag/tag/ExtremePointTag"); +exports.ExtremePointTag = ExtremePointTag_1.ExtremePointTag; var RenderTag_1 = require("./component/tag/tag/RenderTag"); exports.RenderTag = RenderTag_1.RenderTag; +var OutlineRenderTagBase_1 = require("./component/tag/tag/OutlineRenderTagBase"); +exports.OutlineRenderTagBase = OutlineRenderTagBase_1.OutlineRenderTagBase; var OutlineRenderTag_1 = require("./component/tag/tag/OutlineRenderTag"); exports.OutlineRenderTag = OutlineRenderTag_1.OutlineRenderTag; -var OutlineCreateTag_1 = require("./component/tag/tag/OutlineCreateTag"); -exports.OutlineCreateTag = OutlineCreateTag_1.OutlineCreateTag; +var ExtremePointRenderTag_1 = require("./component/tag/tag/ExtremePointRenderTag"); +exports.ExtremePointRenderTag = ExtremePointRenderTag_1.ExtremePointRenderTag; var SpotTag_1 = require("./component/tag/tag/SpotTag"); exports.SpotTag = SpotTag_1.SpotTag; var SpotRenderTag_1 = require("./component/tag/tag/SpotRenderTag"); @@ -20638,15 +29183,23 @@ var RectGeometry_1 = require("./component/tag/geometry/RectGeometry"); exports.RectGeometry = RectGeometry_1.RectGeometry; var PointGeometry_1 = require("./component/tag/geometry/PointGeometry"); exports.PointGeometry = PointGeometry_1.PointGeometry; +var PointsGeometry_1 = require("./component/tag/geometry/PointsGeometry"); +exports.PointsGeometry = PointsGeometry_1.PointsGeometry; var PolygonGeometry_1 = require("./component/tag/geometry/PolygonGeometry"); exports.PolygonGeometry = PolygonGeometry_1.PolygonGeometry; var GeometryTagError_1 = require("./component/tag/error/GeometryTagError"); exports.GeometryTagError = GeometryTagError_1.GeometryTagError; var ZoomComponent_1 = require("./component/zoom/ZoomComponent"); exports.ZoomComponent = ZoomComponent_1.ZoomComponent; +var CreateTag_1 = require("./component/tag/tag/CreateTag"); +exports.CreateTag = CreateTag_1.CreateTag; +var OutlineCreateTag_1 = require("./component/tag/tag/OutlineCreateTag"); +exports.OutlineCreateTag = OutlineCreateTag_1.OutlineCreateTag; +var ExtremePointCreateTag_1 = require("./component/tag/tag/ExtremePointCreateTag"); +exports.ExtremePointCreateTag = ExtremePointCreateTag_1.ExtremePointCreateTag; __export(require("./component/interfaces/interfaces")); -},{"./component/AttributionComponent":288,"./component/BackgroundComponent":289,"./component/BearingComponent":290,"./component/CacheComponent":291,"./component/Component":292,"./component/ComponentService":293,"./component/CoverComponent":294,"./component/DebugComponent":295,"./component/ImageComponent":296,"./component/LoadingComponent":297,"./component/NavigationComponent":298,"./component/RouteComponent":299,"./component/StatsComponent":300,"./component/direction/DirectionComponent":301,"./component/direction/DirectionDOMCalculator":302,"./component/direction/DirectionDOMRenderer":303,"./component/imageplane/ImagePlaneComponent":304,"./component/imageplane/ImagePlaneGLRenderer":305,"./component/interfaces/interfaces":308,"./component/keyboard/KeyPlayHandler":309,"./component/keyboard/KeySequenceNavigationHandler":310,"./component/keyboard/KeySpatialNavigationHandler":311,"./component/keyboard/KeyZoomHandler":312,"./component/keyboard/KeyboardComponent":313,"./component/marker/MarkerComponent":315,"./component/marker/MarkerScene":316,"./component/marker/MarkerSet":317,"./component/marker/marker/CircleMarker":318,"./component/marker/marker/Marker":319,"./component/marker/marker/SimpleMarker":320,"./component/mouse/BounceHandler":321,"./component/mouse/DoubleClickZoomHandler":322,"./component/mouse/DragPanHandler":323,"./component/mouse/EarthControlHandler":324,"./component/mouse/ImageBoundary":325,"./component/mouse/MouseComponent":326,"./component/mouse/ScrollZoomHandler":327,"./component/mouse/TouchZoomHandler":328,"./component/popup/PopupComponent":330,"./component/popup/popup/Popup":331,"./component/sequence/SequenceComponent":332,"./component/sequence/SequenceDOMRenderer":333,"./component/sequence/SequenceMode":334,"./component/shaders/Shaders":335,"./component/slider/SliderComponent":336,"./component/slider/SliderDOMRenderer":337,"./component/slider/SliderGLRenderer":338,"./component/spatialdata/SpatialDataCache":339,"./component/spatialdata/SpatialDataComponent":340,"./component/spatialdata/SpatialDataScene":341,"./component/tag/TagComponent":343,"./component/tag/TagCreator":344,"./component/tag/TagDOMRenderer":345,"./component/tag/TagMode":346,"./component/tag/TagOperation":347,"./component/tag/TagScene":348,"./component/tag/TagSet":349,"./component/tag/error/GeometryTagError":350,"./component/tag/geometry/Geometry":351,"./component/tag/geometry/PointGeometry":352,"./component/tag/geometry/PolygonGeometry":353,"./component/tag/geometry/RectGeometry":354,"./component/tag/geometry/VertexGeometry":355,"./component/tag/handlers/CreateHandlerBase":356,"./component/tag/handlers/CreatePointHandler":357,"./component/tag/handlers/CreatePolygonHandler":358,"./component/tag/handlers/CreateRectDragHandler":359,"./component/tag/handlers/CreateRectHandler":360,"./component/tag/handlers/CreateVertexHandler":361,"./component/tag/handlers/EditVertexHandler":362,"./component/tag/handlers/TagHandlerBase":363,"./component/tag/tag/OutlineCreateTag":364,"./component/tag/tag/OutlineRenderTag":365,"./component/tag/tag/OutlineTag":366,"./component/tag/tag/RenderTag":367,"./component/tag/tag/SpotRenderTag":368,"./component/tag/tag/SpotTag":369,"./component/tag/tag/Tag":370,"./component/tag/tag/TagDomain":371,"./component/utils/HandlerBase":372,"./component/utils/MeshFactory":373,"./component/utils/MeshScene":374,"./component/utils/MouseOperator":375,"./component/zoom/ZoomComponent":376}],275:[function(require,module,exports){ +},{"./component/AttributionComponent":305,"./component/BackgroundComponent":306,"./component/BearingComponent":307,"./component/CacheComponent":308,"./component/Component":309,"./component/ComponentService":310,"./component/CoverComponent":311,"./component/DebugComponent":312,"./component/ImageComponent":313,"./component/LoadingComponent":314,"./component/NavigationComponent":315,"./component/RouteComponent":316,"./component/StatsComponent":317,"./component/direction/DirectionComponent":318,"./component/direction/DirectionDOMCalculator":319,"./component/direction/DirectionDOMRenderer":320,"./component/imageplane/ImagePlaneComponent":321,"./component/imageplane/ImagePlaneGLRenderer":322,"./component/interfaces/interfaces":325,"./component/keyboard/KeyPlayHandler":326,"./component/keyboard/KeySequenceNavigationHandler":327,"./component/keyboard/KeySpatialNavigationHandler":328,"./component/keyboard/KeyZoomHandler":329,"./component/keyboard/KeyboardComponent":330,"./component/marker/MarkerComponent":332,"./component/marker/MarkerScene":333,"./component/marker/MarkerSet":334,"./component/marker/marker/CircleMarker":335,"./component/marker/marker/Marker":336,"./component/marker/marker/SimpleMarker":337,"./component/mouse/BounceHandler":338,"./component/mouse/DoubleClickZoomHandler":339,"./component/mouse/DragPanHandler":340,"./component/mouse/EarthControlHandler":341,"./component/mouse/ImageBoundary":342,"./component/mouse/MouseComponent":343,"./component/mouse/ScrollZoomHandler":344,"./component/mouse/TouchZoomHandler":345,"./component/popup/PopupComponent":347,"./component/popup/popup/Popup":348,"./component/sequence/SequenceComponent":349,"./component/sequence/SequenceDOMRenderer":350,"./component/sequence/SequenceMode":351,"./component/shaders/Shaders":352,"./component/slider/SliderComponent":353,"./component/slider/SliderDOMRenderer":354,"./component/slider/SliderGLRenderer":355,"./component/spatialdata/SpatialDataCache":358,"./component/spatialdata/SpatialDataComponent":359,"./component/spatialdata/SpatialDataScene":360,"./component/tag/TagComponent":362,"./component/tag/TagCreator":363,"./component/tag/TagDOMRenderer":364,"./component/tag/TagMode":365,"./component/tag/TagOperation":366,"./component/tag/TagScene":367,"./component/tag/TagSet":368,"./component/tag/error/GeometryTagError":369,"./component/tag/geometry/Geometry":370,"./component/tag/geometry/PointGeometry":371,"./component/tag/geometry/PointsGeometry":372,"./component/tag/geometry/PolygonGeometry":373,"./component/tag/geometry/RectGeometry":374,"./component/tag/geometry/VertexGeometry":375,"./component/tag/handlers/CreateHandlerBase":376,"./component/tag/handlers/CreatePointHandler":377,"./component/tag/handlers/CreatePointsHandler":378,"./component/tag/handlers/CreatePolygonHandler":379,"./component/tag/handlers/CreateRectDragHandler":380,"./component/tag/handlers/CreateRectHandler":381,"./component/tag/handlers/CreateVertexHandler":382,"./component/tag/handlers/EditVertexHandler":383,"./component/tag/handlers/TagHandlerBase":384,"./component/tag/tag/CreateTag":385,"./component/tag/tag/ExtremePointCreateTag":386,"./component/tag/tag/ExtremePointRenderTag":387,"./component/tag/tag/ExtremePointTag":388,"./component/tag/tag/OutlineCreateTag":389,"./component/tag/tag/OutlineRenderTag":390,"./component/tag/tag/OutlineRenderTagBase":391,"./component/tag/tag/OutlineTag":392,"./component/tag/tag/RenderTag":393,"./component/tag/tag/SpotRenderTag":394,"./component/tag/tag/SpotTag":395,"./component/tag/tag/Tag":396,"./component/tag/tag/TagDomain":397,"./component/utils/ComponentSize":398,"./component/utils/HandlerBase":399,"./component/utils/MeshFactory":400,"./component/utils/MeshScene":401,"./component/utils/MouseOperator":402,"./component/zoom/ZoomComponent":403}],292:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var EdgeDirection_1 = require("./graph/edge/EdgeDirection"); @@ -20660,7 +29213,7 @@ exports.EdgeCalculatorCoefficients = EdgeCalculatorCoefficients_1.EdgeCalculator var EdgeCalculator_1 = require("./graph/edge/EdgeCalculator"); exports.EdgeCalculator = EdgeCalculator_1.EdgeCalculator; -},{"./graph/edge/EdgeCalculator":398,"./graph/edge/EdgeCalculatorCoefficients":399,"./graph/edge/EdgeCalculatorDirections":400,"./graph/edge/EdgeCalculatorSettings":401,"./graph/edge/EdgeDirection":402}],276:[function(require,module,exports){ +},{"./graph/edge/EdgeCalculator":425,"./graph/edge/EdgeCalculatorCoefficients":426,"./graph/edge/EdgeCalculatorDirections":427,"./graph/edge/EdgeCalculatorSettings":428,"./graph/edge/EdgeDirection":429}],293:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var AbortMapillaryError_1 = require("./error/AbortMapillaryError"); @@ -20672,7 +29225,7 @@ exports.GraphMapillaryError = GraphMapillaryError_1.GraphMapillaryError; var MapillaryError_1 = require("./error/MapillaryError"); exports.MapillaryError = MapillaryError_1.MapillaryError; -},{"./error/AbortMapillaryError":377,"./error/ArgumentMapillaryError":378,"./error/GraphMapillaryError":379,"./error/MapillaryError":380}],277:[function(require,module,exports){ +},{"./error/AbortMapillaryError":404,"./error/ArgumentMapillaryError":405,"./error/GraphMapillaryError":406,"./error/MapillaryError":407}],294:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Camera_1 = require("./geo/Camera"); @@ -20690,7 +29243,7 @@ exports.Geo = Geo; var Lines = require("./geo/Lines"); exports.Lines = Lines; -},{"./geo/Camera":381,"./geo/Geo":382,"./geo/GeoCoords":383,"./geo/Lines":384,"./geo/Spatial":385,"./geo/Transform":386,"./geo/ViewportCoords":387}],278:[function(require,module,exports){ +},{"./geo/Camera":408,"./geo/Geo":409,"./geo/GeoCoords":410,"./geo/Lines":411,"./geo/Spatial":412,"./geo/Transform":413,"./geo/ViewportCoords":414}],295:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var FilterCreator_1 = require("./graph/FilterCreator"); @@ -20714,7 +29267,7 @@ exports.NodeCache = NodeCache_1.NodeCache; var Sequence_1 = require("./graph/Sequence"); exports.Sequence = Sequence_1.Sequence; -},{"./graph/FilterCreator":388,"./graph/Graph":389,"./graph/GraphCalculator":390,"./graph/GraphMode":391,"./graph/GraphService":392,"./graph/ImageLoadingService":393,"./graph/MeshReader":394,"./graph/Node":395,"./graph/NodeCache":396,"./graph/Sequence":397}],279:[function(require,module,exports){ +},{"./graph/FilterCreator":415,"./graph/Graph":416,"./graph/GraphCalculator":417,"./graph/GraphMode":418,"./graph/GraphService":419,"./graph/ImageLoadingService":420,"./graph/MeshReader":421,"./graph/Node":422,"./graph/NodeCache":423,"./graph/Sequence":424}],296:[function(require,module,exports){ "use strict"; /** * MapillaryJS is a WebGL JavaScript library for exploring street level imagery @@ -20739,14 +29292,17 @@ exports.ImageSize = Viewer_1.ImageSize; exports.Viewer = Viewer_1.Viewer; var Component_1 = require("./Component"); exports.SliderMode = Component_1.SliderMode; +exports.ComponentSize = Component_1.ComponentSize; var TagComponent = require("./component/tag/Tag"); exports.TagComponent = TagComponent; var MarkerComponent = require("./component/marker/Marker"); exports.MarkerComponent = MarkerComponent; var PopupComponent = require("./component/popup/Popup"); exports.PopupComponent = PopupComponent; +var SpatialDataComponent = require("./component/spatialdata/SpatialData"); +exports.SpatialDataComponent = SpatialDataComponent; -},{"./Component":274,"./Edge":275,"./Error":276,"./Render":280,"./State":281,"./Support":282,"./Viewer":285,"./component/marker/Marker":314,"./component/popup/Popup":329,"./component/tag/Tag":342}],280:[function(require,module,exports){ +},{"./Component":291,"./Edge":292,"./Error":293,"./Render":297,"./State":298,"./Support":299,"./Viewer":302,"./component/marker/Marker":331,"./component/popup/Popup":346,"./component/spatialdata/SpatialData":357,"./component/tag/Tag":361}],297:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var DOMRenderer_1 = require("./render/DOMRenderer"); @@ -20762,7 +29318,7 @@ exports.RenderMode = RenderMode_1.RenderMode; var RenderService_1 = require("./render/RenderService"); exports.RenderService = RenderService_1.RenderService; -},{"./render/DOMRenderer":403,"./render/GLRenderStage":404,"./render/GLRenderer":405,"./render/RenderCamera":406,"./render/RenderMode":407,"./render/RenderService":408}],281:[function(require,module,exports){ +},{"./render/DOMRenderer":430,"./render/GLRenderStage":431,"./render/GLRenderer":432,"./render/RenderCamera":433,"./render/RenderMode":434,"./render/RenderService":435}],298:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var FrameGenerator_1 = require("./state/FrameGenerator"); @@ -20790,7 +29346,7 @@ exports.TraversingState = TraversingState_1.TraversingState; var WaitingState_1 = require("./state/states/WaitingState"); exports.WaitingState = WaitingState_1.WaitingState; -},{"./state/FrameGenerator":409,"./state/RotationDelta":410,"./state/State":411,"./state/StateContext":412,"./state/StateService":413,"./state/TransitionMode":414,"./state/states/EarthState":415,"./state/states/InteractiveStateBase":416,"./state/states/InteractiveWaitingState":417,"./state/states/StateBase":418,"./state/states/TraversingState":419,"./state/states/WaitingState":420}],282:[function(require,module,exports){ +},{"./state/FrameGenerator":436,"./state/RotationDelta":437,"./state/State":438,"./state/StateContext":439,"./state/StateService":440,"./state/TransitionMode":441,"./state/states/EarthState":442,"./state/states/InteractiveStateBase":443,"./state/states/InteractiveWaitingState":444,"./state/states/StateBase":445,"./state/states/TraversingState":446,"./state/states/WaitingState":447}],299:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var support = require("./utils/Support"); @@ -20830,7 +29386,7 @@ function isFallbackSupported() { } exports.isFallbackSupported = isFallbackSupported; -},{"./utils/Support":428}],283:[function(require,module,exports){ +},{"./utils/Support":455}],300:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var ImageTileLoader_1 = require("./tiles/ImageTileLoader"); @@ -20842,7 +29398,7 @@ exports.TextureProvider = TextureProvider_1.TextureProvider; var RegionOfInterestCalculator_1 = require("./tiles/RegionOfInterestCalculator"); exports.RegionOfInterestCalculator = RegionOfInterestCalculator_1.RegionOfInterestCalculator; -},{"./tiles/ImageTileLoader":421,"./tiles/ImageTileStore":422,"./tiles/RegionOfInterestCalculator":423,"./tiles/TextureProvider":424}],284:[function(require,module,exports){ +},{"./tiles/ImageTileLoader":448,"./tiles/ImageTileStore":449,"./tiles/RegionOfInterestCalculator":450,"./tiles/TextureProvider":451}],301:[function(require,module,exports){ "use strict"; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; @@ -20858,7 +29414,7 @@ __export(require("./utils/Support")); var Urls_1 = require("./utils/Urls"); exports.Urls = Urls_1.Urls; -},{"./utils/DOM":425,"./utils/EventEmitter":426,"./utils/Settings":427,"./utils/Support":428,"./utils/Urls":429}],285:[function(require,module,exports){ +},{"./utils/DOM":452,"./utils/EventEmitter":453,"./utils/Settings":454,"./utils/Support":455,"./utils/Urls":456}],302:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Alignment_1 = require("./viewer/Alignment"); @@ -20892,7 +29448,7 @@ exports.TouchService = TouchService_1.TouchService; var Viewer_1 = require("./viewer/Viewer"); exports.Viewer = Viewer_1.Viewer; -},{"./viewer/Alignment":430,"./viewer/CacheService":431,"./viewer/ComponentController":432,"./viewer/Container":433,"./viewer/ImageSize":434,"./viewer/KeyboardService":435,"./viewer/LoadingService":436,"./viewer/MouseService":437,"./viewer/Navigator":438,"./viewer/Observer":439,"./viewer/PlayService":440,"./viewer/Projection":441,"./viewer/SpriteService":442,"./viewer/TouchService":443,"./viewer/Viewer":444}],286:[function(require,module,exports){ +},{"./viewer/Alignment":457,"./viewer/CacheService":458,"./viewer/ComponentController":459,"./viewer/Container":460,"./viewer/ImageSize":461,"./viewer/KeyboardService":462,"./viewer/LoadingService":463,"./viewer/MouseService":464,"./viewer/Navigator":465,"./viewer/Observer":466,"./viewer/PlayService":468,"./viewer/Projection":469,"./viewer/SpriteService":470,"./viewer/TouchService":471,"./viewer/Viewer":472}],303:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var operators_1 = require("rxjs/operators"); @@ -20944,8 +29500,11 @@ var APIv3 = /** @class */ (function () { ]; this._propertiesSpatial = [ "atomic_scale", + "cluster_key", + "c_rotation", "ca", "calt", + "camera_projection_type", "cca", "cfocal", "ck1", @@ -20954,7 +29513,6 @@ var APIv3 = /** @class */ (function () { "height", "merge_cc", "merge_version", - "c_rotation", "orientation", "width", ]; @@ -21121,7 +29679,7 @@ var APIv3 = /** @class */ (function () { exports.APIv3 = APIv3; exports.default = APIv3; -},{"../API":273,"rxjs":26,"rxjs/operators":224}],287:[function(require,module,exports){ +},{"../API":290,"rxjs":43,"rxjs/operators":241}],304:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var falcor = require("falcor"); @@ -21164,7 +29722,7 @@ var ModelCreator = /** @class */ (function () { exports.ModelCreator = ModelCreator; exports.default = ModelCreator; -},{"../Utils":284,"falcor":15,"falcor-http-datasource":10}],288:[function(require,module,exports){ +},{"../Utils":301,"falcor":15,"falcor-http-datasource":10}],305:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -21231,7 +29789,7 @@ exports.AttributionComponent = AttributionComponent; Component_1.ComponentService.register(AttributionComponent); exports.default = AttributionComponent; -},{"../Component":274,"../Utils":284,"rxjs":26,"rxjs/operators":224,"virtual-dom":230}],289:[function(require,module,exports){ +},{"../Component":291,"../Utils":301,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],306:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -21277,7 +29835,7 @@ exports.BackgroundComponent = BackgroundComponent; Component_1.ComponentService.register(BackgroundComponent); exports.default = BackgroundComponent; -},{"../Component":274,"virtual-dom":230}],290:[function(require,module,exports){ +},{"../Component":291,"virtual-dom":247}],307:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -21295,15 +29853,38 @@ var __extends = (this && this.__extends) || (function () { Object.defineProperty(exports, "__esModule", { value: true }); var operators_1 = require("rxjs/operators"); var vd = require("virtual-dom"); +var UnitBezier = require("@mapbox/unitbezier"); +var rxjs_1 = require("rxjs"); var Component_1 = require("../Component"); var Geo_1 = require("../Geo"); +var ViewportCoords_1 = require("../geo/ViewportCoords"); +var ComponentSize_1 = require("./utils/ComponentSize"); +/** + * @class BearingComponent + * + * @classdesc Component for indicating bearing and field of view. + * + * @example + * ``` + * var viewer = new Mapillary.Viewer( + * "", + * "", + * ""); + * + * var bearingComponent = viewer.getComponent("bearing"); + * bearingComponent.configure({ size: Mapillary.ComponentSize.Small }); + * ``` + */ var BearingComponent = /** @class */ (function (_super) { __extends(BearingComponent, _super); function BearingComponent(name, container, navigator) { var _this = _super.call(this, name, container, navigator) || this; _this._spatial = new Geo_1.Spatial(); + _this._viewportCoords = new ViewportCoords_1.default(); _this._svgNamespace = "http://www.w3.org/2000/svg"; _this._distinctThreshold = Math.PI / 360; + _this._animationSpeed = 0.075; + _this._unitBezier = new UnitBezier(0.74, 0.67, 0.38, 0.96); return _this; } BearingComponent.prototype._activate = function () { @@ -21318,17 +29899,110 @@ var BearingComponent = /** @class */ (function (_super) { return Math.abs(a2[0] - a1[0]) < _this._distinctThreshold && Math.abs(a2[1] - a1[1]) < _this._distinctThreshold; })); - this._renderSubscription = cameraBearingFov$.pipe(operators_1.map(function (_a) { - var bearing = _a[0], fov = _a[1]; - var background = vd.h("div.BearingIndicatorBackground", {}, []); - var backgroundCircle = vd.h("div.BearingIndicatorBackgroundCircle", {}, []); - var north = _this._createNorth(bearing); - var cameraSector = _this._createCircleSectorCompass(_this._createCircleSector(Math.max(Math.PI / 20, fov), "#FFF")); + var nodeFov$ = rxjs_1.combineLatest(this._navigator.stateService.currentState$.pipe(operators_1.distinctUntilChanged(undefined, function (frame) { + return frame.state.currentNode.key; + })), this._navigator.panService.panNodes$).pipe(operators_1.map(function (_a) { + var frame = _a[0], panNodes = _a[1]; + var node = frame.state.currentNode; + var transform = frame.state.currentTransform; + if (node.pano) { + var panoHFov = 2 * Math.PI * node.gpano.CroppedAreaImageWidthPixels / node.gpano.FullPanoWidthPixels; + return [panoHFov / 2, panoHFov / 2]; + } + var currentProjectedPoints = _this._computeProjectedPoints(transform); + var hFov = _this._spatial.degToRad(_this._computeHorizontalFov(currentProjectedPoints)); + var hFovLeft = hFov / 2; + var hFovRight = hFov / 2; + for (var _i = 0, panNodes_1 = panNodes; _i < panNodes_1.length; _i++) { + var _b = panNodes_1[_i], n = _b[0], f = _b[2]; + var diff = _this._spatial.wrap(n.ca - node.ca, -180, 180); + if (diff < 0) { + hFovLeft = _this._spatial.degToRad(Math.abs(diff)) + f / 2; + } + else { + hFovRight = _this._spatial.degToRad(Math.abs(diff)) + f / 2; + } + } + return [hFovLeft, hFovRight]; + }), operators_1.distinctUntilChanged(function (_a, _b) { + var hFovLeft1 = _a[0], hFovRight1 = _a[1]; + var hFovLeft2 = _b[0], hFovRight2 = _b[1]; + return Math.abs(hFovLeft2 - hFovLeft1) < _this._distinctThreshold && + Math.abs(hFovRight2 - hFovRight1) < _this._distinctThreshold; + })); + var offset$ = rxjs_1.combineLatest(this._navigator.stateService.currentState$.pipe(operators_1.distinctUntilChanged(undefined, function (frame) { + return frame.state.currentNode.key; + })), this._container.renderService.bearing$).pipe(operators_1.map(function (_a) { + var frame = _a[0], bearing = _a[1]; + var offset = _this._spatial.degToRad(frame.state.currentNode.ca - bearing); + return offset; + })); + var nodeFovOperation$ = new rxjs_1.Subject(); + var smoothNodeFov$ = nodeFovOperation$.pipe(operators_1.scan(function (state, operation) { + return operation(state); + }, { alpha: 0, curr: [0, 0, 0], prev: [0, 0, 0] }), operators_1.map(function (state) { + var alpha = _this._unitBezier.solve(state.alpha); + var curr = state.curr; + var prev = state.prev; + return [ + _this._interpolate(prev[0], curr[0], alpha), + _this._interpolate(prev[1], curr[1], alpha), + ]; + })); + this._fovSubscription = nodeFov$.pipe(operators_1.map(function (nbf) { + return function (state) { + var a = _this._unitBezier.solve(state.alpha); + var c = state.curr; + var p = state.prev; + var prev = [ + _this._interpolate(p[0], c[0], a), + _this._interpolate(p[1], c[1], a), + ]; + var curr = nbf.slice(); + return { + alpha: 0, + curr: curr, + prev: prev, + }; + }; + })) + .subscribe(nodeFovOperation$); + this._fovAnimationSubscription = nodeFov$.pipe(operators_1.switchMap(function () { + return _this._container.renderService.renderCameraFrame$.pipe(operators_1.skip(1), operators_1.scan(function (alpha) { + return alpha + _this._animationSpeed; + }, 0), operators_1.takeWhile(function (alpha) { + return alpha <= 1 + _this._animationSpeed; + }), operators_1.map(function (alpha) { + return Math.min(alpha, 1); + })); + }), operators_1.map(function (alpha) { + return function (nbfState) { + return { + alpha: alpha, + curr: nbfState.curr.slice(), + prev: nbfState.prev.slice(), + }; + }; + })) + .subscribe(nodeFovOperation$); + var nodeBearingFov$ = rxjs_1.combineLatest(offset$, smoothNodeFov$).pipe(operators_1.map(function (_a) { + var offset = _a[0], fov = _a[1]; + return [offset, fov[0], fov[1]]; + })); + this._renderSubscription = rxjs_1.combineLatest(cameraBearingFov$, nodeBearingFov$, this._configuration$, this._container.renderService.size$).pipe(operators_1.map(function (_a) { + var _b = _a[0], cb = _b[0], cf = _b[1], _c = _a[1], no = _c[0], nfl = _c[1], nfr = _c[2], configuration = _a[2], size = _a[3]; + var background = _this._createBackground(cb); + var fovIndicator = _this._createFovIndicator(nfl, nfr, no); + var north = _this._createNorth(cb); + var cameraSector = _this._createCircleSectorCompass(_this._createCircleSector(Math.max(Math.PI / 20, cf), "#FFF")); + var compact = configuration.size === ComponentSize_1.default.Small || + configuration.size === ComponentSize_1.default.Automatic && size.width < 640 ? + ".BearingCompact" : ""; return { name: _this._name, - vnode: vd.h("div.BearingIndicatorContainer", { oncontextmenu: function (event) { event.preventDefault(); } }, [ + vnode: vd.h("div.BearingIndicatorContainer" + compact, { oncontextmenu: function (event) { event.preventDefault(); } }, [ background, - backgroundCircle, + fovIndicator, north, cameraSector, ]), @@ -21338,9 +30012,66 @@ var BearingComponent = /** @class */ (function (_super) { }; BearingComponent.prototype._deactivate = function () { this._renderSubscription.unsubscribe(); + this._fovSubscription.unsubscribe(); + this._fovAnimationSubscription.unsubscribe(); }; BearingComponent.prototype._getDefaultConfiguration = function () { - return {}; + return { size: ComponentSize_1.default.Automatic }; + }; + BearingComponent.prototype._createFovIndicator = function (fovLeft, fovRigth, offset) { + var arc = this._createFovArc(fovLeft, fovRigth); + var group = vd.h("g", { + attributes: { transform: "translate(18,18)" }, + namespace: this._svgNamespace, + }, [arc]); + var svg = vd.h("svg", { + attributes: { viewBox: "0 0 36 36" }, + namespace: this._svgNamespace, + style: { + height: "36px", + left: "2px", + position: "absolute", + top: "2px", + transform: "rotateZ(" + this._spatial.radToDeg(offset) + "deg)", + width: "36px", + }, + }, [group]); + return svg; + }; + BearingComponent.prototype._createFovArc = function (fovLeft, fovRigth) { + var radius = 16.75; + var strokeWidth = 2.5; + var fov = fovLeft + fovRigth; + if (fov > 2 * Math.PI - Math.PI / 90) { + return vd.h("circle", { + attributes: { + cx: "0", + cy: "0", + "fill-opacity": "0", + r: "" + radius, + stroke: "#FFF", + "stroke-width": "" + strokeWidth, + }, + namespace: this._svgNamespace, + }, []); + } + var arcStart = -Math.PI / 2 - fovLeft; + var arcEnd = arcStart + fov; + var startX = radius * Math.cos(arcStart); + var startY = radius * Math.sin(arcStart); + var endX = radius * Math.cos(arcEnd); + var endY = radius * Math.sin(arcEnd); + var largeArc = fov >= Math.PI ? 1 : 0; + var description = "M " + startX + " " + startY + " A " + radius + " " + radius + " 0 " + largeArc + " 1 " + endX + " " + endY; + return vd.h("path", { + attributes: { + d: description, + "fill-opacity": "0", + stroke: "#FFF", + "stroke-width": "" + strokeWidth, + }, + namespace: this._svgNamespace, + }, []); }; BearingComponent.prototype._createCircleSectorCompass = function (cameraSector) { var group = vd.h("g", { @@ -21351,11 +30082,11 @@ var BearingComponent = /** @class */ (function (_super) { attributes: { viewBox: "0 0 2 2" }, namespace: this._svgNamespace, style: { - height: "30px", - left: "4px", + height: "26px", + left: "7px", position: "absolute", - top: "4px", - width: "30px", + top: "7px", + width: "26px", }, }, [group]); return svg; @@ -21382,9 +30113,38 @@ var BearingComponent = /** @class */ (function (_super) { }; BearingComponent.prototype._createNorth = function (bearing) { var north = vd.h("div.BearingNorth", []); - var container = vd.h("div.BearingNorthContainer", { style: { transform: "rotateZ(" + -bearing * 180 / Math.PI + "deg)" } }, [north]); + var container = vd.h("div.BearingNorthContainer", { style: { transform: "rotateZ(" + this._spatial.radToDeg(-bearing) + "deg)" } }, [north]); return container; }; + BearingComponent.prototype._createBackground = function (bearing) { + return vd.h("div.BearingIndicatorBackground", { style: { transform: "rotateZ(" + this._spatial.radToDeg(-bearing) + "deg)" } }, [ + vd.h("div.BearingIndicatorBackgroundCircle", []), + vd.h("div.BearingIndicatorBackgroundArrowContainer", [ + vd.h("div.BearingIndicatorBackgroundArrow", []), + ]), + ]); + }; + BearingComponent.prototype._computeProjectedPoints = function (transform) { + var vertices = [[1, 0]]; + var directions = [[0, 0.5]]; + var pointsPerLine = 12; + return Geo_1.Geo.computeProjectedPoints(transform, vertices, directions, pointsPerLine, this._viewportCoords); + }; + BearingComponent.prototype._computeHorizontalFov = function (projectedPoints) { + var _this = this; + var fovs = projectedPoints + .map(function (projectedPoint) { + return _this._coordToFov(projectedPoint[0]); + }); + var fov = Math.min.apply(Math, fovs); + return fov; + }; + BearingComponent.prototype._coordToFov = function (x) { + return this._spatial.radToDeg(2 * Math.atan(x)); + }; + BearingComponent.prototype._interpolate = function (x1, x2, alpha) { + return (1 - alpha) * x1 + alpha * x2; + }; BearingComponent.componentName = "bearing"; return BearingComponent; }(Component_1.Component)); @@ -21392,7 +30152,8 @@ exports.BearingComponent = BearingComponent; Component_1.ComponentService.register(BearingComponent); exports.default = BearingComponent; -},{"../Component":274,"../Geo":277,"rxjs/operators":224,"virtual-dom":230}],291:[function(require,module,exports){ + +},{"../Component":291,"../Geo":294,"../geo/ViewportCoords":414,"./utils/ComponentSize":398,"@mapbox/unitbezier":2,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],308:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -21514,7 +30275,7 @@ exports.CacheComponent = CacheComponent; Component_1.ComponentService.register(CacheComponent); exports.default = CacheComponent; -},{"../Component":274,"../Edge":275,"rxjs":26,"rxjs/operators":224}],292:[function(require,module,exports){ +},{"../Component":291,"../Edge":292,"rxjs":43,"rxjs/operators":241}],309:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -21640,7 +30401,7 @@ var Component = /** @class */ (function (_super) { exports.Component = Component; exports.default = Component; -},{"../Utils":284,"rxjs":26,"rxjs/operators":224}],293:[function(require,module,exports){ +},{"../Utils":301,"rxjs":43,"rxjs/operators":241}],310:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Error_1 = require("../Error"); @@ -21724,15 +30485,6 @@ var ComponentService = /** @class */ (function () { this.get(name).deactivate(); } }; - ComponentService.prototype.resize = function () { - for (var componentName in this._components) { - if (!this._components.hasOwnProperty(componentName)) { - continue; - } - var component = this._components[componentName]; - component.component.resize(); - } - }; ComponentService.prototype.get = function (name) { return this._components[name].component; }; @@ -21750,7 +30502,7 @@ var ComponentService = /** @class */ (function () { exports.ComponentService = ComponentService; exports.default = ComponentService; -},{"../Error":276}],294:[function(require,module,exports){ +},{"../Error":293}],311:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -21825,9 +30577,15 @@ var CoverComponent = /** @class */ (function (_super) { CoverComponent.prototype._getCoverButtonVNode = function (configuration) { var _this = this; var cover = configuration.state === Component_1.CoverState.Loading ? "div.Cover.CoverLoading" : "div.Cover"; - var coverButton = vd.h("div.CoverButton", { onclick: function () { _this.configure({ state: Component_1.CoverState.Loading }); } }, [vd.h("div.CoverButtonIcon", [])]); + var coverButton = vd.h("div.CoverButton", [vd.h("div.CoverButtonIcon", [])]); var coverLogo = vd.h("a.CoverLogo", { href: Utils_1.Urls.explore, target: "_blank" }, []); - return vd.h(cover, [this._getCoverBackgroundVNode(configuration), coverButton, coverLogo]); + var coverIndicator = vd.h("div.CoverIndicator", { onclick: function () { _this.configure({ state: Component_1.CoverState.Loading }); } }, []); + return vd.h(cover, [ + this._getCoverBackgroundVNode(configuration), + coverIndicator, + coverButton, + coverLogo, + ]); }; CoverComponent.prototype._getCoverBackgroundVNode = function (conf) { var url = conf.src != null ? @@ -21846,7 +30604,7 @@ exports.CoverComponent = CoverComponent; Component_1.ComponentService.registerCover(CoverComponent); exports.default = CoverComponent; -},{"../Component":274,"../Utils":284,"../Viewer":285,"rxjs":26,"rxjs/operators":224,"virtual-dom":230}],295:[function(require,module,exports){ +},{"../Component":291,"../Utils":301,"../Viewer":302,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],312:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -21963,7 +30721,7 @@ exports.DebugComponent = DebugComponent; Component_1.ComponentService.register(DebugComponent); exports.default = DebugComponent; -},{"../Component":274,"rxjs":26,"rxjs/operators":224,"virtual-dom":230}],296:[function(require,module,exports){ +},{"../Component":291,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],313:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -22034,7 +30792,7 @@ Component_1.ComponentService.register(ImageComponent); exports.default = ImageComponent; -},{"../Component":274,"../Utils":284,"rxjs":26,"rxjs/operators":224,"virtual-dom":230}],297:[function(require,module,exports){ +},{"../Component":291,"../Utils":301,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],314:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -22112,7 +30870,7 @@ exports.LoadingComponent = LoadingComponent; Component_1.ComponentService.register(LoadingComponent); exports.default = LoadingComponent; -},{"../Component":274,"rxjs":26,"rxjs/operators":224,"virtual-dom":230}],298:[function(require,module,exports){ +},{"../Component":291,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],315:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -22241,7 +30999,7 @@ exports.NavigationComponent = NavigationComponent; Component_1.ComponentService.register(NavigationComponent); exports.default = NavigationComponent; -},{"../Component":274,"../Edge":275,"../Error":276,"rxjs":26,"rxjs/operators":224,"virtual-dom":230}],299:[function(require,module,exports){ +},{"../Component":291,"../Edge":292,"../Error":293,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],316:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -22463,7 +31221,7 @@ exports.RouteComponent = RouteComponent; Component_1.ComponentService.register(RouteComponent); exports.default = RouteComponent; -},{"../Component":274,"rxjs":26,"rxjs/operators":224,"virtual-dom":230}],300:[function(require,module,exports){ +},{"../Component":291,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],317:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -22544,7 +31302,7 @@ exports.StatsComponent = StatsComponent; Component_1.ComponentService.register(StatsComponent); exports.default = StatsComponent; -},{"../Component":274,"rxjs":26,"rxjs/operators":224}],301:[function(require,module,exports){ +},{"../Component":291,"rxjs":43,"rxjs/operators":241}],318:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -22560,9 +31318,9 @@ var __extends = (this && this.__extends) || (function () { }; })(); Object.defineProperty(exports, "__esModule", { value: true }); +var vd = require("virtual-dom"); var rxjs_1 = require("rxjs"); var operators_1 = require("rxjs/operators"); -var vd = require("virtual-dom"); var Component_1 = require("../../Component"); /** * @class DirectionComponent @@ -22574,7 +31332,7 @@ var DirectionComponent = /** @class */ (function (_super) { var _this = _super.call(this, name, container, navigator) || this; _this._renderer = !!directionDOMRenderer ? directionDOMRenderer : - new Component_1.DirectionDOMRenderer(_this.defaultConfiguration, container.element); + new Component_1.DirectionDOMRenderer(_this.defaultConfiguration, { height: container.element.offsetHeight, width: container.element.offsetWidth }); _this._hoveredKeySubject$ = new rxjs_1.Subject(); _this._hoveredKey$ = _this._hoveredKeySubject$.pipe(operators_1.share()); return _this; @@ -22637,16 +31395,16 @@ var DirectionComponent = /** @class */ (function (_super) { DirectionComponent.prototype.setMaxWidth = function (maxWidth) { this.configure({ maxWidth: maxWidth }); }; - /** @inheritdoc */ - DirectionComponent.prototype.resize = function () { - this._renderer.resize(this._container.element); - }; DirectionComponent.prototype._activate = function () { var _this = this; this._configurationSubscription = this._configuration$ .subscribe(function (configuration) { _this._renderer.setConfiguration(configuration); }); + this._resizeSubscription = this._container.renderService.size$ + .subscribe(function (size) { + _this._renderer.resize(size); + }); this._nodeSubscription = this._navigator.stateService.currentNode$.pipe(operators_1.tap(function (node) { _this._container.domRenderer.render$.next({ name: _this._name, vnode: vd.h("div", {}, []) }); _this._renderer.setNode(node); @@ -22724,7 +31482,8 @@ exports.DirectionComponent = DirectionComponent; Component_1.ComponentService.register(DirectionComponent); exports.default = DirectionComponent; -},{"../../Component":274,"rxjs":26,"rxjs/operators":224,"virtual-dom":230}],302:[function(require,module,exports){ + +},{"../../Component":291,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],319:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Geo_1 = require("../../Geo"); @@ -22733,14 +31492,14 @@ var Geo_1 = require("../../Geo"); * @classdesc Helper class for calculating DOM CSS properties. */ var DirectionDOMCalculator = /** @class */ (function () { - function DirectionDOMCalculator(configuration, element) { + function DirectionDOMCalculator(configuration, size) { this._spatial = new Geo_1.Spatial(); this._minThresholdWidth = 320; this._maxThresholdWidth = 1480; this._minThresholdHeight = 240; this._maxThresholdHeight = 820; this._configure(configuration); - this._resize(element); + this._resize(size); this._reset(); } Object.defineProperty(DirectionDOMCalculator.prototype, "minWidth", { @@ -22874,13 +31633,12 @@ var DirectionDOMCalculator = /** @class */ (function () { }; /** * Resizes all properties according to the width and height - * of the element. + * of the size object. * - * @param {HTMLElement} element The container element from which to extract - * the width and height. + * @param {ISize} size The size of the container element. */ - DirectionDOMCalculator.prototype.resize = function (element) { - this._resize(element); + DirectionDOMCalculator.prototype.resize = function (size) { + this._resize(size); this._reset(); }; /** @@ -22909,9 +31667,9 @@ var DirectionDOMCalculator = /** @class */ (function () { this._minWidth = configuration.minWidth; this._maxWidth = this._getMaxWidth(configuration.minWidth, configuration.maxWidth); }; - DirectionDOMCalculator.prototype._resize = function (element) { - this._elementWidth = element.offsetWidth; - this._elementHeight = element.offsetHeight; + DirectionDOMCalculator.prototype._resize = function (size) { + this._elementWidth = size.width; + this._elementHeight = size.height; }; DirectionDOMCalculator.prototype._reset = function () { this._containerWidth = this._getContainerWidth(this._elementWidth, this._elementHeight); @@ -22964,7 +31722,7 @@ exports.DirectionDOMCalculator = DirectionDOMCalculator; exports.default = DirectionDOMCalculator; -},{"../../Geo":277}],303:[function(require,module,exports){ +},{"../../Geo":294}],320:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var vd = require("virtual-dom"); @@ -22977,10 +31735,10 @@ var Geo_1 = require("../../Geo"); * @classdesc DOM renderer for direction arrows. */ var DirectionDOMRenderer = /** @class */ (function () { - function DirectionDOMRenderer(configuration, element) { + function DirectionDOMRenderer(configuration, size) { this._isEdge = false; this._spatial = new Geo_1.Spatial(); - this._calculator = new Component_1.DirectionDOMCalculator(configuration, element); + this._calculator = new Component_1.DirectionDOMCalculator(configuration, size); this._node = null; this._rotation = { phi: 0, theta: 0 }; this._epsilon = 0.5 * Math.PI / 180; @@ -23095,10 +31853,10 @@ var DirectionDOMRenderer = /** @class */ (function () { * Detect the element's width and height and resize * elements accordingly. * - * @param {HTMLElement} element Viewer container element. + * @param {ISize} size Size of vßiewer container element. */ - DirectionDOMRenderer.prototype.resize = function (element) { - this._calculator.resize(element); + DirectionDOMRenderer.prototype.resize = function (size) { + this._calculator.resize(size); this._setNeedsRender(); }; DirectionDOMRenderer.prototype._setNeedsRender = function () { @@ -23344,7 +32102,7 @@ exports.DirectionDOMRenderer = DirectionDOMRenderer; exports.default = DirectionDOMRenderer; -},{"../../Component":274,"../../Edge":275,"../../Error":276,"../../Geo":277,"virtual-dom":230}],304:[function(require,module,exports){ +},{"../../Component":291,"../../Edge":292,"../../Error":293,"../../Geo":294,"virtual-dom":247}],321:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -23363,9 +32121,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); var rxjs_1 = require("rxjs"); var operators_1 = require("rxjs/operators"); var Component_1 = require("../../Component"); +var Viewer_1 = require("../../Viewer"); var Render_1 = require("../../Render"); var Tiles_1 = require("../../Tiles"); var Utils_1 = require("../../Utils"); +var ViewportCoords_1 = require("../../geo/ViewportCoords"); +var Spatial_1 = require("../../geo/Spatial"); var ImagePlaneComponent = /** @class */ (function (_super) { __extends(ImagePlaneComponent, _super); function ImagePlaneComponent(name, container, navigator) { @@ -23483,10 +32244,16 @@ var ImagePlaneComponent = /** @class */ (function (_super) { this._setRegionOfInterestSubscription = textureProvider$.pipe(operators_1.switchMap(function (provider) { return roiTrigger$.pipe(operators_1.map(function (_a) { var camera = _a[0], size = _a[1], transform = _a[2]; + var basic = new ViewportCoords_1.default().viewportToBasic(0, 0, transform, camera.perspective); + if (basic[0] < 0 || basic[1] < 0 || basic[0] > 1 || basic[1] > 1) { + return undefined; + } return [ _this._roiCalculator.computeRegionOfInterest(camera, size, transform), provider, ]; + }), operators_1.filter(function (args) { + return !!args; })); }), operators_1.filter(function (args) { return !args[1].disposed; @@ -23547,6 +32314,92 @@ var ImagePlaneComponent = /** @class */ (function (_super) { }; })) .subscribe(this._rendererOperation$); + this._clearPeripheryPlaneSubscription = this._navigator.panService.panNodes$.pipe(operators_1.filter(function (panNodes) { + return panNodes.length === 0; + }), operators_1.map(function () { + return function (renderer) { + renderer.clearPeripheryPlanes(); + return renderer; + }; + })) + .subscribe(this._rendererOperation$); + var cachedPanNodes$ = this._navigator.panService.panNodes$.pipe(operators_1.switchMap(function (nts) { + return rxjs_1.from(nts).pipe(operators_1.mergeMap(function (_a) { + var n = _a[0], t = _a[1]; + return rxjs_1.combineLatest(_this._navigator.graphService.cacheNode$(n.key).pipe(operators_1.catchError(function (error) { + console.error("Failed to cache periphery node (" + n.key + ")", error); + return rxjs_1.empty(); + })), rxjs_1.of(t)); + })); + }), operators_1.share()); + this._addPeripheryPlaneSubscription = cachedPanNodes$.pipe(operators_1.map(function (_a) { + var n = _a[0], t = _a[1]; + return function (renderer) { + renderer.addPeripheryPlane(n, t); + return renderer; + }; + })) + .subscribe(this._rendererOperation$); + this._updatePeripheryPlaneTextureSubscription = cachedPanNodes$.pipe(operators_1.mergeMap(function (_a) { + var n = _a[0]; + return Viewer_1.ImageSize.Size2048 > Math.max(n.image.width, n.image.height) ? + n.cacheImage$(Viewer_1.ImageSize.Size2048).pipe(operators_1.catchError(function () { + return rxjs_1.empty(); + })) : + rxjs_1.empty(); + }), operators_1.map(function (n) { + return function (renderer) { + renderer.updateTextureImage(n.image, n); + return renderer; + }; + })) + .subscribe(this._rendererOperation$); + var inTransition$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) { + return frame.state.alpha < 1; + }), operators_1.distinctUntilChanged()); + var panTrigger$ = rxjs_1.combineLatest(this._container.mouseService.active$, this._container.touchService.active$, this._navigator.stateService.inMotion$, inTransition$).pipe(operators_1.map(function (_a) { + var mouseActive = _a[0], touchActive = _a[1], inMotion = _a[2], inTransition = _a[3]; + return !(mouseActive || touchActive || inMotion || inTransition); + }), operators_1.filter(function (trigger) { + return trigger; + })); + this._moveToPeripheryNodeSubscription = this._navigator.panService.panNodes$.pipe(operators_1.switchMap(function (nts) { + return panTrigger$.pipe(operators_1.withLatestFrom(_this._container.renderService.renderCamera$, _this._navigator.stateService.currentNode$, _this._navigator.stateService.currentTransform$), operators_1.mergeMap(function (_a) { + var renderCamera = _a[1], currentNode = _a[2], currentTransform = _a[3]; + return rxjs_1.of([ + renderCamera, + currentNode, + currentTransform, + nts, + ]); + })); + }), operators_1.switchMap(function (_a) { + var camera = _a[0], cn = _a[1], ct = _a[2], nts = _a[3]; + var direction = camera.camera.lookat.clone().sub(camera.camera.position); + var cd = new Spatial_1.default().viewingDirection(cn.rotation); + var ca = cd.angleTo(direction); + var closest = [ca, undefined]; + var basic = new ViewportCoords_1.default().viewportToBasic(0, 0, ct, camera.perspective); + if (basic[0] >= 0 && basic[0] <= 1 && basic[1] >= 0 && basic[1] <= 1) { + closest[0] = Number.NEGATIVE_INFINITY; + } + for (var _i = 0, nts_1 = nts; _i < nts_1.length; _i++) { + var n = nts_1[_i][0]; + var d = new Spatial_1.default().viewingDirection(n.rotation); + var a = d.angleTo(direction); + if (a < closest[0]) { + closest[0] = a; + closest[1] = n.key; + } + } + if (!closest[1]) { + return rxjs_1.empty(); + } + return _this._navigator.moveToKey$(closest[1]).pipe(operators_1.catchError(function () { + return rxjs_1.empty(); + })); + })) + .subscribe(); }; ImagePlaneComponent.prototype._deactivate = function () { this._rendererDisposer$.next(null); @@ -23560,6 +32413,10 @@ var ImagePlaneComponent = /** @class */ (function (_super) { this._textureProviderSubscription.unsubscribe(); this._updateBackgroundSubscription.unsubscribe(); this._updateTextureImageSubscription.unsubscribe(); + this._clearPeripheryPlaneSubscription.unsubscribe(); + this._addPeripheryPlaneSubscription.unsubscribe(); + this._updatePeripheryPlaneTextureSubscription.unsubscribe(); + this._moveToPeripheryNodeSubscription.unsubscribe(); }; ImagePlaneComponent.prototype._getDefaultConfiguration = function () { return {}; @@ -23571,7 +32428,7 @@ exports.ImagePlaneComponent = ImagePlaneComponent; Component_1.ComponentService.register(ImagePlaneComponent); exports.default = ImagePlaneComponent; -},{"../../Component":274,"../../Render":280,"../../Tiles":283,"../../Utils":284,"rxjs":26,"rxjs/operators":224}],305:[function(require,module,exports){ +},{"../../Component":291,"../../Render":297,"../../Tiles":300,"../../Utils":301,"../../Viewer":302,"../../geo/Spatial":412,"../../geo/ViewportCoords":414,"rxjs":43,"rxjs/operators":241}],322:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Component_1 = require("../../Component"); @@ -23605,6 +32462,17 @@ var ImagePlaneGLRenderer = /** @class */ (function () { ImagePlaneGLRenderer.prototype.indicateNeedsRender = function () { this._needsRender = true; }; + ImagePlaneGLRenderer.prototype.addPeripheryPlane = function (node, transform) { + var mesh = this._factory.createMesh(node, transform); + var planes = {}; + planes[node.key] = mesh; + this._scene.addPeripheryPlanes(planes); + this._needsRender = true; + }; + ImagePlaneGLRenderer.prototype.clearPeripheryPlanes = function () { + this._scene.setPeripheryPlanes({}); + this._needsRender = true; + }; ImagePlaneGLRenderer.prototype.updateFrame = function (frame) { this._updateFrameId(frame.id); this._needsRender = this._updateAlpha(frame.state.alpha) || this._needsRender; @@ -23636,24 +32504,17 @@ var ImagePlaneGLRenderer = /** @class */ (function () { } this._providerDisposers[key] = dispose; }; - ImagePlaneGLRenderer.prototype._updateTexture = function (texture) { - this._needsRender = true; - for (var _i = 0, _a = this._scene.imagePlanes; _i < _a.length; _i++) { - var plane = _a[_i]; - var material = plane.material; - var oldTexture = material.uniforms.projectorTex.value; - material.uniforms.projectorTex.value = null; - oldTexture.dispose(); - material.uniforms.projectorTex.value = texture; - } - }; ImagePlaneGLRenderer.prototype.updateTextureImage = function (image, node) { - if (this._currentKey !== node.key) { - return; - } this._needsRender = true; - for (var _i = 0, _a = this._scene.imagePlanes; _i < _a.length; _i++) { - var plane = _a[_i]; + var planes = this._extend({}, this._scene.planes, this._scene.planesOld, this._scene.planesPeriphery); + for (var key in planes) { + if (!planes.hasOwnProperty(key)) { + continue; + } + if (key !== node.key) { + continue; + } + var plane = planes[key]; var material = plane.material; var texture = material.uniforms.projectorTex.value; texture.image = image; @@ -23661,19 +32522,40 @@ var ImagePlaneGLRenderer = /** @class */ (function () { } }; ImagePlaneGLRenderer.prototype.render = function (perspectiveCamera, renderer) { - var planeAlpha = this._scene.imagePlanesOld.length ? 1 : this._alpha; - for (var _i = 0, _a = this._scene.imagePlanes; _i < _a.length; _i++) { - var plane = _a[_i]; + var planes = this._scene.planes; + var planesOld = this._scene.planesOld; + var planesPeriphery = this._scene.planesPeriphery; + var planeAlpha = Object.keys(planesOld).length ? 1 : this._alpha; + var peripheryAlpha = Object.keys(planesOld).length ? 1 : Math.floor(this._alpha); + for (var key in planes) { + if (!planes.hasOwnProperty(key)) { + continue; + } + var plane = planes[key]; plane.material.uniforms.opacity.value = planeAlpha; } - for (var _b = 0, _c = this._scene.imagePlanesOld; _b < _c.length; _b++) { - var plane = _c[_b]; + for (var key in planesOld) { + if (!planesOld.hasOwnProperty(key)) { + continue; + } + var plane = planesOld[key]; plane.material.uniforms.opacity.value = this._alphaOld; } + for (var key in planesPeriphery) { + if (!planesPeriphery.hasOwnProperty(key)) { + continue; + } + var plane = planesPeriphery[key]; + plane.material.uniforms.opacity.value = peripheryAlpha; + } + renderer.render(this._scene.scenePeriphery, perspectiveCamera); renderer.render(this._scene.scene, perspectiveCamera); renderer.render(this._scene.sceneOld, perspectiveCamera); - for (var _d = 0, _e = this._scene.imagePlanes; _d < _e.length; _d++) { - var plane = _e[_d]; + for (var key in planes) { + if (!planes.hasOwnProperty(key)) { + continue; + } + var plane = planes[key]; plane.material.uniforms.opacity.value = this._alpha; } renderer.render(this._scene.scene, perspectiveCamera); @@ -23717,22 +32599,57 @@ var ImagePlaneGLRenderer = /** @class */ (function () { if (previousKey != null) { if (previousKey !== this._currentKey && previousKey !== this._previousKey) { var previousMesh = this._factory.createMesh(state.previousNode, state.previousTransform); - this._scene.updateImagePlanes([previousMesh]); + var previousPlanes = {}; + previousPlanes[previousKey] = previousMesh; + this._scene.updateImagePlanes(previousPlanes); } this._previousKey = previousKey; } this._currentKey = currentKey; var currentMesh = this._factory.createMesh(state.currentNode, state.currentTransform); - this._scene.updateImagePlanes([currentMesh]); + var planes = {}; + planes[currentKey] = currentMesh; + this._scene.updateImagePlanes(planes); this._alphaOld = 1; return true; }; + ImagePlaneGLRenderer.prototype._updateTexture = function (texture) { + this._needsRender = true; + var planes = this._scene.planes; + for (var key in planes) { + if (!planes.hasOwnProperty(key)) { + continue; + } + var plane = planes[key]; + var material = plane.material; + var oldTexture = material.uniforms.projectorTex.value; + material.uniforms.projectorTex.value = null; + oldTexture.dispose(); + material.uniforms.projectorTex.value = texture; + } + }; + ImagePlaneGLRenderer.prototype._extend = function (dest) { + var sources = []; + for (var _i = 1; _i < arguments.length; _i++) { + sources[_i - 1] = arguments[_i]; + } + for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) { + var src = sources_1[_a]; + for (var k in src) { + if (!src.hasOwnProperty(k)) { + continue; + } + dest[k] = src[k]; + } + } + return dest; + }; return ImagePlaneGLRenderer; }()); exports.ImagePlaneGLRenderer = ImagePlaneGLRenderer; exports.default = ImagePlaneGLRenderer; -},{"../../Component":274}],306:[function(require,module,exports){ +},{"../../Component":291}],323:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var CoverState; @@ -23742,7 +32659,7 @@ var CoverState; CoverState[CoverState["Visible"] = 2] = "Visible"; })(CoverState = exports.CoverState || (exports.CoverState = {})); -},{}],307:[function(require,module,exports){ +},{}],324:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** @@ -23782,7 +32699,7 @@ var SliderMode; SliderMode[SliderMode["Stationary"] = 1] = "Stationary"; })(SliderMode = exports.SliderMode || (exports.SliderMode = {})); -},{}],308:[function(require,module,exports){ +},{}],325:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var ICoverConfiguration_1 = require("./ICoverConfiguration"); @@ -23790,7 +32707,7 @@ exports.CoverState = ICoverConfiguration_1.CoverState; var ISliderConfiguration_1 = require("./ISliderConfiguration"); exports.SliderMode = ISliderConfiguration_1.SliderMode; -},{"./ICoverConfiguration":306,"./ISliderConfiguration":307}],309:[function(require,module,exports){ +},{"./ICoverConfiguration":323,"./ISliderConfiguration":324}],326:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -23895,7 +32812,7 @@ var KeyPlayHandler = /** @class */ (function (_super) { exports.KeyPlayHandler = KeyPlayHandler; exports.default = KeyPlayHandler; -},{"../../Component":274,"../../Edge":275,"rxjs/operators":224}],310:[function(require,module,exports){ +},{"../../Component":291,"../../Edge":292,"rxjs/operators":241}],327:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -23985,7 +32902,7 @@ var KeySequenceNavigationHandler = /** @class */ (function (_super) { exports.KeySequenceNavigationHandler = KeySequenceNavigationHandler; exports.default = KeySequenceNavigationHandler; -},{"../../Component":274,"../../Edge":275,"../../Error":276,"rxjs/operators":224}],311:[function(require,module,exports){ +},{"../../Component":291,"../../Edge":292,"../../Error":293,"rxjs/operators":241}],328:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -24134,7 +33051,7 @@ var KeySpatialNavigationHandler = /** @class */ (function (_super) { exports.KeySpatialNavigationHandler = KeySpatialNavigationHandler; exports.default = KeySpatialNavigationHandler; -},{"../../Component":274,"../../Edge":275,"../../Error":276,"rxjs/operators":224}],312:[function(require,module,exports){ +},{"../../Component":291,"../../Edge":292,"../../Error":293,"rxjs/operators":241}],329:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -24213,7 +33130,7 @@ var KeyZoomHandler = /** @class */ (function (_super) { exports.KeyZoomHandler = KeyZoomHandler; exports.default = KeyZoomHandler; -},{"../../Component":274,"rxjs/operators":224}],313:[function(require,module,exports){ +},{"../../Component":291,"rxjs/operators":241}],330:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -24354,7 +33271,7 @@ exports.KeyboardComponent = KeyboardComponent; Component_1.ComponentService.register(KeyboardComponent); exports.default = KeyboardComponent; -},{"../../Component":274,"../../Geo":277}],314:[function(require,module,exports){ +},{"../../Component":291,"../../Geo":294}],331:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var MarkerComponent_1 = require("./MarkerComponent"); @@ -24364,7 +33281,7 @@ exports.SimpleMarker = SimpleMarker_1.SimpleMarker; var CircleMarker_1 = require("./marker/CircleMarker"); exports.CircleMarker = CircleMarker_1.CircleMarker; -},{"./MarkerComponent":315,"./marker/CircleMarker":318,"./marker/SimpleMarker":320}],315:[function(require,module,exports){ +},{"./MarkerComponent":332,"./marker/CircleMarker":335,"./marker/SimpleMarker":337}],332:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -24802,7 +33719,7 @@ Component_1.ComponentService.register(MarkerComponent); exports.default = MarkerComponent; -},{"../../Component":274,"../../Geo":277,"../../Graph":278,"../../Render":280,"rxjs":26,"rxjs/operators":224,"three":225,"when":271}],316:[function(require,module,exports){ +},{"../../Component":291,"../../Geo":294,"../../Graph":295,"../../Render":297,"rxjs":43,"rxjs/operators":241,"three":242,"when":288}],333:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var THREE = require("three"); @@ -24924,7 +33841,7 @@ var MarkerScene = /** @class */ (function () { exports.MarkerScene = MarkerScene; exports.default = MarkerScene; -},{"three":225}],317:[function(require,module,exports){ +},{"three":242}],334:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var rbush = require("rbush"); @@ -25041,7 +33958,7 @@ var MarkerSet = /** @class */ (function () { exports.MarkerSet = MarkerSet; exports.default = MarkerSet; -},{"rbush":25,"rxjs":26}],318:[function(require,module,exports){ +},{"rbush":42,"rxjs":43}],335:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -25126,7 +34043,7 @@ var CircleMarker = /** @class */ (function (_super) { exports.CircleMarker = CircleMarker; exports.default = CircleMarker; -},{"../../../Component":274,"three":225}],319:[function(require,module,exports){ +},{"../../../Component":291,"three":242}],336:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** @@ -25222,7 +34139,7 @@ var Marker = /** @class */ (function () { exports.Marker = Marker; exports.default = Marker; -},{}],320:[function(require,module,exports){ +},{}],337:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -25371,7 +34288,7 @@ var SimpleMarker = /** @class */ (function (_super) { exports.SimpleMarker = SimpleMarker; exports.default = SimpleMarker; -},{"../../../Component":274,"three":225}],321:[function(require,module,exports){ +},{"../../../Component":291,"three":242}],338:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -25406,16 +34323,16 @@ var BounceHandler = /** @class */ (function (_super) { var _this = this; var inTransition$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) { return frame.state.alpha < 1; - })); + }), operators_1.distinctUntilChanged()); this._bounceSubscription = rxjs_1.combineLatest(inTransition$, this._navigator.stateService.inTranslation$, this._container.mouseService.active$, this._container.touchService.active$).pipe(operators_1.map(function (noForce) { return noForce[0] || noForce[1] || noForce[2] || noForce[3]; }), operators_1.distinctUntilChanged(), operators_1.switchMap(function (noForce) { return noForce ? rxjs_1.empty() : rxjs_1.combineLatest(_this._container.renderService.renderCamera$, _this._navigator.stateService.currentTransform$.pipe(operators_1.first())); - })) + }), operators_1.withLatestFrom(this._navigator.panService.panNodes$)) .subscribe(function (_a) { - var render = _a[0], transform = _a[1]; + var _b = _a[0], render = _b[0], transform = _b[1], nts = _a[1]; if (!transform.hasValidScale && render.camera.focal < 0.1) { return; } @@ -25423,6 +34340,19 @@ var BounceHandler = /** @class */ (function (_super) { return; } var distances = Component_1.ImageBoundary.viewportDistances(transform, render.perspective, _this._viewportCoords); + var basic = _this._viewportCoords.viewportToBasic(0, 0, transform, render.perspective); + if ((basic[0] < 0 || basic[0] > 1) && nts.length > 0) { + distances[0] = distances[2] = 0; + } + for (var _i = 0, nts_1 = nts; _i < nts_1.length; _i++) { + var _c = nts_1[_i], t = _c[1]; + var d = Component_1.ImageBoundary.viewportDistances(t, render.perspective, _this._viewportCoords); + for (var i = 1; i < distances.length; i += 2) { + if (d[i] < distances[i]) { + distances[i] = d[i]; + } + } + } if (Math.max.apply(Math, distances) < 0.01) { return; } @@ -25457,7 +34387,7 @@ var BounceHandler = /** @class */ (function (_super) { exports.BounceHandler = BounceHandler; exports.default = BounceHandler; -},{"../../Component":274,"rxjs":26,"rxjs/operators":224}],322:[function(require,module,exports){ +},{"../../Component":291,"rxjs":43,"rxjs/operators":241}],339:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -25525,7 +34455,7 @@ var DoubleClickZoomHandler = /** @class */ (function (_super) { exports.DoubleClickZoomHandler = DoubleClickZoomHandler; exports.default = DoubleClickZoomHandler; -},{"../../Component":274,"rxjs":26,"rxjs/operators":224}],323:[function(require,module,exports){ +},{"../../Component":291,"rxjs":43,"rxjs/operators":241}],340:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -25609,8 +34539,8 @@ var DragPanHandler = /** @class */ (function (_super) { return pair[0] != null && pair[1] != null; })); return rxjs_1.merge(mouseDrag$, singleTouchDrag$); - }), operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) { - var events = _a[0], render = _a[1], transform = _a[2]; + }), operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$, this._navigator.panService.panNodes$), operators_1.map(function (_a) { + var events = _a[0], render = _a[1], transform = _a[2], nts = _a[3]; var previousEvent = events[0]; var event = events[1]; var movementX = event.clientX - previousEvent.clientX; @@ -25626,6 +34556,15 @@ var DragPanHandler = /** @class */ (function (_super) { var phi = (movementX > 0 ? 1 : -1) * directionX.angleTo(currentDirection); var theta = (movementY > 0 ? -1 : 1) * directionY.angleTo(currentDirection); var distances = Component_1.ImageBoundary.viewportDistances(transform, render.perspective, _this._viewportCoords); + for (var _i = 0, nts_1 = nts; _i < nts_1.length; _i++) { + var _c = nts_1[_i], t = _c[1]; + var d = Component_1.ImageBoundary.viewportDistances(t, render.perspective, _this._viewportCoords); + for (var i = 0; i < distances.length; i++) { + if (d[i] < distances[i]) { + distances[i] = d[i]; + } + } + } if (distances[0] > 0 && theta < 0) { theta /= Math.max(1, 2e2 * distances[0]); } @@ -25697,7 +34636,7 @@ var DragPanHandler = /** @class */ (function (_super) { exports.DragPanHandler = DragPanHandler; exports.default = DragPanHandler; -},{"../../Component":274,"rxjs":26,"rxjs/operators":224}],324:[function(require,module,exports){ +},{"../../Component":291,"rxjs":43,"rxjs/operators":241}],341:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -25845,7 +34784,7 @@ var EarthControlHandler = /** @class */ (function (_super) { exports.EarthControlHandler = EarthControlHandler; exports.default = EarthControlHandler; -},{"../../Component":274,"../../State":281,"rxjs":26,"rxjs/operators":224,"three":225}],325:[function(require,module,exports){ +},{"../../Component":291,"../../State":298,"rxjs":43,"rxjs/operators":241,"three":242}],342:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Geo_1 = require("../../../src/Geo"); @@ -25962,7 +34901,7 @@ function viewportDistances(transform, perspective, viewportCoords) { } exports.viewportDistances = viewportDistances; -},{"../../../src/Geo":277}],326:[function(require,module,exports){ +},{"../../../src/Geo":294}],343:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -26114,7 +35053,7 @@ exports.MouseComponent = MouseComponent; Component_1.ComponentService.register(MouseComponent); exports.default = MouseComponent; -},{"../../Component":274,"../../Geo":277}],327:[function(require,module,exports){ +},{"../../Component":291,"../../Geo":294}],344:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -26206,7 +35145,7 @@ var ScrollZoomHandler = /** @class */ (function (_super) { exports.ScrollZoomHandler = ScrollZoomHandler; exports.default = ScrollZoomHandler; -},{"../../Component":274,"rxjs/operators":224}],328:[function(require,module,exports){ +},{"../../Component":291,"rxjs/operators":241}],345:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -26292,7 +35231,7 @@ var TouchZoomHandler = /** @class */ (function (_super) { exports.TouchZoomHandler = TouchZoomHandler; exports.default = TouchZoomHandler; -},{"../../Component":274,"rxjs":26,"rxjs/operators":224}],329:[function(require,module,exports){ +},{"../../Component":291,"rxjs":43,"rxjs/operators":241}],346:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Popup_1 = require("./popup/Popup"); @@ -26300,7 +35239,7 @@ exports.Popup = Popup_1.Popup; var PopupComponent_1 = require("./PopupComponent"); exports.PopupComponent = PopupComponent_1.PopupComponent; -},{"./PopupComponent":330,"./popup/Popup":331}],330:[function(require,module,exports){ +},{"./PopupComponent":347,"./popup/Popup":348}],347:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -26480,7 +35419,7 @@ exports.PopupComponent = PopupComponent; Component_1.ComponentService.register(PopupComponent); exports.default = PopupComponent; -},{"../../Component":274,"../../Utils":284,"rxjs":26,"rxjs/operators":224}],331:[function(require,module,exports){ +},{"../../Component":291,"../../Utils":301,"rxjs":43,"rxjs/operators":241}],348:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var rxjs_1 = require("rxjs"); @@ -26764,10 +35703,10 @@ var Popup = /** @class */ (function () { } } if (pointPixel == null) { - this._container.style.visibility = "hidden"; + this._container.style.display = "none"; return; } - this._container.style.visibility = "visible"; + this._container.style.display = ""; if (!float) { var width = this._container.offsetWidth; var height = this._container.offsetHeight; @@ -26962,7 +35901,7 @@ exports.Popup = Popup; exports.default = Popup; -},{"../../../Geo":277,"../../../Utils":284,"../../../Viewer":285,"rxjs":26}],332:[function(require,module,exports){ +},{"../../../Geo":294,"../../../Utils":301,"../../../Viewer":302,"rxjs":43}],349:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -27109,16 +36048,6 @@ var SequenceComponent = /** @class */ (function (_super) { SequenceComponent.prototype.setVisible = function (visible) { this.configure({ visible: visible }); }; - /** @inheritdoc */ - SequenceComponent.prototype.resize = function () { - var _this = this; - this._configuration$.pipe(operators_1.first(), operators_1.map(function (configuration) { - return _this._sequenceDOMRenderer.getContainerWidth(_this._container.element, configuration); - })) - .subscribe(function (containerWidth) { - _this._containerWidth$.next(containerWidth); - }); - }; SequenceComponent.prototype._activate = function () { var _this = this; this._sequenceDOMRenderer.activate(); @@ -27224,12 +36153,13 @@ var SequenceComponent = /** @class */ (function (_super) { .subscribe(function (direction) { _this._navigator.playService.setDirection(direction); }); - this._containerWidthSubscription = this._configuration$.pipe(operators_1.distinctUntilChanged(function (value1, value2) { + this._containerWidthSubscription = rxjs_1.combineLatest(this._container.renderService.size$, this._configuration$.pipe(operators_1.distinctUntilChanged(function (value1, value2) { return value1[0] === value2[0] && value1[1] === value2[1]; }, function (configuration) { return [configuration.minWidth, configuration.maxWidth]; - }), operators_1.map(function (configuration) { - return _this._sequenceDOMRenderer.getContainerWidth(_this._container.element, configuration); + }))).pipe(operators_1.map(function (_a) { + var size = _a[0], configuration = _a[1]; + return _this._sequenceDOMRenderer.getContainerWidth(size, configuration); })) .subscribe(this._containerWidth$); this._playingSubscription = this._configuration$.pipe(operators_1.map(function (configuration) { @@ -27312,7 +36242,7 @@ exports.SequenceComponent = SequenceComponent; Component_1.ComponentService.register(SequenceComponent); exports.default = SequenceComponent; -},{"../../Component":274,"../../Edge":275,"../../Graph":278,"rxjs":26,"rxjs/operators":224}],333:[function(require,module,exports){ +},{"../../Component":291,"../../Edge":292,"../../Graph":295,"rxjs":43,"rxjs/operators":241}],350:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var rxjs_1 = require("rxjs"); @@ -27424,16 +36354,14 @@ var SequenceDOMRenderer = /** @class */ (function () { var timeline = this._createTimelineControls(containerWidth, index, max); return vd.h("div.SequenceContainer", [stepper, controls, playback, timeline]); }; - SequenceDOMRenderer.prototype.getContainerWidth = function (element, configuration) { - var elementWidth = element.offsetWidth; - var elementHeight = element.offsetHeight; + SequenceDOMRenderer.prototype.getContainerWidth = function (size, configuration) { var minWidth = configuration.minWidth; var maxWidth = configuration.maxWidth; if (maxWidth < minWidth) { maxWidth = minWidth; } - var relativeWidth = (elementWidth - this._minThresholdWidth) / (this._maxThresholdWidth - this._minThresholdWidth); - var relativeHeight = (elementHeight - this._minThresholdHeight) / (this._maxThresholdHeight - this._minThresholdHeight); + var relativeWidth = (size.width - this._minThresholdWidth) / (this._maxThresholdWidth - this._minThresholdWidth); + var relativeHeight = (size.height - this._minThresholdHeight) / (this._maxThresholdHeight - this._minThresholdHeight); var coeff = Math.max(0, Math.min(1, Math.min(relativeWidth, relativeHeight))); return minWidth + coeff * (maxWidth - minWidth); }; @@ -27743,8 +36671,7 @@ var SequenceDOMRenderer = /** @class */ (function () { exports.SequenceDOMRenderer = SequenceDOMRenderer; exports.default = SequenceDOMRenderer; - -},{"../../Component":274,"../../Edge":275,"../../Error":276,"rxjs":26,"rxjs/operators":224,"virtual-dom":230}],334:[function(require,module,exports){ +},{"../../Component":291,"../../Edge":292,"../../Error":293,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],351:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var SequenceMode; @@ -27755,7 +36682,7 @@ var SequenceMode; })(SequenceMode = exports.SequenceMode || (exports.SequenceMode = {})); exports.default = SequenceMode; -},{}],335:[function(require,module,exports){ +},{}],352:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); @@ -27779,6 +36706,14 @@ var Shaders = /** @class */ (function () { fragment: "#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform float focal;\nuniform float k1;\nuniform float k2;\nuniform float scale_x;\nuniform float scale_y;\nuniform float radial_peak;\nuniform float curtain;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float x = vRstq.x / vRstq.z;\n float y = vRstq.y / vRstq.z;\n float r2 = x * x + y * y;\n\n if (radial_peak > 0. && r2 > radial_peak * sqrt(r2)) {\n r2 = radial_peak * radial_peak;\n }\n\n float d = 1.0 + k1 * r2 + k2 * r2 * r2;\n float u = scale_x * focal * d * x + 0.5;\n float v = - scale_y * focal * d * y + 0.5;\n\n vec4 baseColor;\n if ((u < curtain || curtain >= 1.0) && u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n", vertex: "#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}", }; + Shaders.fisheye = { + fragment: "#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform float focal;\nuniform float k1;\nuniform float k2;\nuniform float scale_x;\nuniform float scale_y;\nuniform float radial_peak;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float x = vRstq.x;\n float y = vRstq.y;\n float z = vRstq.z;\n\n float r = sqrt(x * x + y * y);\n float theta = atan(r, z);\n\n if (radial_peak > 0. && theta > radial_peak) {\n theta = radial_peak;\n }\n\n float theta2 = theta * theta;\n float theta_d = theta * (1.0 + theta2 * (k1 + theta2 * k2));\n float s = focal * theta_d / r;\n\n float u = scale_x * s * x + 0.5;\n float v = -scale_y * s * y + 0.5;\n\n vec4 baseColor;\n if (u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n", + vertex: "#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}", + }; + Shaders.fisheyeCurtain = { + fragment: "#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform float focal;\nuniform float k1;\nuniform float k2;\nuniform float scale_x;\nuniform float scale_y;\nuniform float radial_peak;\nuniform float curtain;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float x = vRstq.x;\n float y = vRstq.y;\n float z = vRstq.z;\n\n float r2 = sqrt(x * x + y * y);\n float theta = atan(r2, z);\n\n if (radial_peak > 0. && theta > radial_peak) {\n theta = radial_peak;\n }\n\n float theta2 = theta * theta;\n float theta_d = theta * (1.0 + theta2 * (k1 + theta2 * k2));\n float s = focal * theta_d / r2;\n\n float u = scale_x * s * x + 0.5;\n float v = -scale_y * s * y + 0.5;\n\n vec4 baseColor;\n if ((u < curtain || curtain >= 1.0) && u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n", + vertex: "#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}", + }; Shaders.perspectiveDistorted = { fragment: "#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float u = vRstq.x / vRstq.w;\n float v = vRstq.y / vRstq.w;\n\n vec4 baseColor;\n if (u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n", vertex: "#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n", @@ -27792,7 +36727,7 @@ var Shaders = /** @class */ (function () { exports.Shaders = Shaders; -},{"path":22}],336:[function(require,module,exports){ +},{"path":39}],353:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -27826,7 +36761,7 @@ var Utils_1 = require("../../Utils"); * components when activating the slider component to avoid * interfering UI elements. * - * To retrive and use the marker component + * To retrive and use the slider component * * @example * ``` @@ -27841,7 +36776,7 @@ var Utils_1 = require("../../Utils"); * * viewer.activateComponent("slider"); * - * var sliderComponent = viewer.getComponent("marker"); + * var sliderComponent = viewer.getComponent("slider"); * ``` */ var SliderComponent = /** @class */ (function (_super) { @@ -28472,7 +37407,7 @@ Component_1.ComponentService.register(SliderComponent); exports.default = SliderComponent; -},{"../../Component":274,"../../Geo":277,"../../Render":280,"../../State":281,"../../Tiles":283,"../../Utils":284,"rxjs":26,"rxjs/operators":224}],337:[function(require,module,exports){ +},{"../../Component":291,"../../Geo":294,"../../Render":297,"../../State":298,"../../Tiles":300,"../../Utils":301,"rxjs":43,"rxjs/operators":241}],354:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var rxjs_1 = require("rxjs"); @@ -28530,6 +37465,7 @@ var SliderDOMRenderer = /** @class */ (function () { var modeVisible = !(motionless || pano); if (modeVisible) { children.push(this._createModeButton(mode)); + children.push(this._createModeButton2d(mode)); } children.push(this._createPositionInput(position, modeVisible)); } @@ -28541,16 +37477,32 @@ var SliderDOMRenderer = /** @class */ (function () { var _this = this; var properties = { onclick: function () { - _this._notifyModeChanged$.next(mode === Component_1.SliderMode.Motion ? - Component_1.SliderMode.Stationary : - Component_1.SliderMode.Motion); + if (mode === Component_1.SliderMode.Motion) { + return; + } + _this._notifyModeChanged$.next(Component_1.SliderMode.Motion); }, }; var className = mode === Component_1.SliderMode.Stationary ? - "SliderModeButtonPressed" : + "SliderModeButtonDisabled" : "SliderModeButton"; return vd.h("div." + className, properties, [vd.h("div.SliderModeIcon", [])]); }; + SliderDOMRenderer.prototype._createModeButton2d = function (mode) { + var _this = this; + var properties = { + onclick: function () { + if (mode === Component_1.SliderMode.Stationary) { + return; + } + _this._notifyModeChanged$.next(Component_1.SliderMode.Stationary); + }, + }; + var className = mode === Component_1.SliderMode.Motion ? + "SliderModeButton2dDisabled" : + "SliderModeButton2d"; + return vd.h("div." + className, properties, [vd.h("div.SliderModeIcon2d", [])]); + }; SliderDOMRenderer.prototype._createPositionInput = function (position, modeVisible) { var _this = this; var onChange = function (e) { @@ -28572,7 +37524,7 @@ var SliderDOMRenderer = /** @class */ (function () { } }; var boundingRect = this._container.domContainer.getBoundingClientRect(); - var width = Math.max(215, Math.min(400, boundingRect.width - 105)) - 68 + (modeVisible ? 0 : 36); + var width = Math.max(215, Math.min(400, boundingRect.width - 105)) - 84 + (modeVisible ? 0 : 52); var positionInput = vd.h("input.SliderPosition", { max: 1000, min: 0, @@ -28596,7 +37548,7 @@ var SliderDOMRenderer = /** @class */ (function () { exports.SliderDOMRenderer = SliderDOMRenderer; exports.default = SliderDOMRenderer; -},{"../../Component":274,"rxjs":26,"rxjs/operators":224,"virtual-dom":230}],338:[function(require,module,exports){ +},{"../../Component":291,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],355:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Component_1 = require("../../Component"); @@ -28656,17 +37608,20 @@ var SliderGLRenderer = /** @class */ (function () { this._needsRender = true; }; SliderGLRenderer.prototype.updateTexture = function (image, node) { - var imagePlanes = node.key === this._currentKey ? - this._scene.imagePlanes : + var planes = node.key === this._currentKey ? + this._scene.planes : node.key === this._previousKey ? - this._scene.imagePlanesOld : - []; - if (imagePlanes.length === 0) { + this._scene.planesOld : + {}; + if (Object.keys(planes).length === 0) { return; } this._needsRender = true; - for (var _i = 0, imagePlanes_1 = imagePlanes; _i < imagePlanes_1.length; _i++) { - var plane = imagePlanes_1[_i]; + for (var key in planes) { + if (!planes.hasOwnProperty(key)) { + continue; + } + var plane = planes[key]; var material = plane.material; var texture = material.uniforms.projectorTex.value; texture.image = image; @@ -28678,8 +37633,12 @@ var SliderGLRenderer = /** @class */ (function () { return; } this._needsRender = true; - for (var _i = 0, _a = this._scene.imagePlanes; _i < _a.length; _i++) { - var plane = _a[_i]; + var planes = this._scene.planes; + for (var key in planes) { + if (!planes.hasOwnProperty(key)) { + continue; + } + var plane = planes[key]; var material = plane.material; var texture = material.uniforms.projectorTex.value; texture.image = image; @@ -28754,8 +37713,12 @@ var SliderGLRenderer = /** @class */ (function () { providerDisposers[key] = dispose; }; SliderGLRenderer.prototype._updateCurtain = function () { - for (var _i = 0, _a = this._scene.imagePlanes; _i < _a.length; _i++) { - var plane = _a[_i]; + var planes = this._scene.planes; + for (var key in planes) { + if (!planes.hasOwnProperty(key)) { + continue; + } + var plane = planes[key]; var shaderMaterial = plane.material; if (!!shaderMaterial.uniforms.curtain) { shaderMaterial.uniforms.curtain.value = this._curtain; @@ -28783,7 +37746,7 @@ var SliderGLRenderer = /** @class */ (function () { } } if (this.disabled) { - this._scene.setImagePlanesOld([]); + this._scene.setImagePlanesOld({}); } else { if (previousChanged || modeChanged) { @@ -28824,7 +37787,9 @@ var SliderGLRenderer = /** @class */ (function () { mesh = this._factory.createMesh(state.previousNode, state.previousTransform); } } - this._scene.setImagePlanesOld([mesh]); + var previousPlanes = {}; + previousPlanes[previousNode.key] = mesh; + this._scene.setImagePlanesOld(previousPlanes); } } if (currentChanged || modeChanged) { @@ -28833,29 +37798,33 @@ var SliderGLRenderer = /** @class */ (function () { delete this._currentProviderDisposers[this._currentKey]; } this._currentKey = state.currentNode.key; - var imagePlanes = []; + var planes = {}; if (state.currentNode.fullPano) { - imagePlanes.push(this._factory.createCurtainMesh(state.currentNode, state.currentTransform)); + planes[state.currentNode.key] = this._factory.createCurtainMesh(state.currentNode, state.currentTransform); } else if (state.currentNode.pano && !state.currentNode.fullPano) { - imagePlanes.push(this._factory.createMesh(state.currentNode, state.currentTransform)); + planes[state.currentNode.key] = this._factory.createMesh(state.currentNode, state.currentTransform); } else { if (motionless) { - imagePlanes.push(this._factory.createDistortedCurtainMesh(state.currentNode, state.currentTransform)); + planes[state.currentNode.key] = this._factory.createDistortedCurtainMesh(state.currentNode, state.currentTransform); } else { - imagePlanes.push(this._factory.createCurtainMesh(state.currentNode, state.currentTransform)); + planes[state.currentNode.key] = this._factory.createCurtainMesh(state.currentNode, state.currentTransform); } } - this._scene.setImagePlanes(imagePlanes); + this._scene.setImagePlanes(planes); this._updateCurtain(); } }; SliderGLRenderer.prototype._updateTexture = function (texture) { this._needsRender = true; - for (var _i = 0, _a = this._scene.imagePlanes; _i < _a.length; _i++) { - var plane = _a[_i]; + var planes = this._scene.planes; + for (var key in planes) { + if (!planes.hasOwnProperty(key)) { + continue; + } + var plane = planes[key]; var material = plane.material; var oldTexture = material.uniforms.projectorTex.value; material.uniforms.projectorTex.value = null; @@ -28865,8 +37834,12 @@ var SliderGLRenderer = /** @class */ (function () { }; SliderGLRenderer.prototype._updateTexturePrev = function (texture) { this._needsRender = true; - for (var _i = 0, _a = this._scene.imagePlanesOld; _i < _a.length; _i++) { - var plane = _a[_i]; + var planes = this._scene.planesOld; + for (var key in planes) { + if (!planes.hasOwnProperty(key)) { + continue; + } + var plane = planes[key]; var material = plane.material; var oldTexture = material.uniforms.projectorTex.value; material.uniforms.projectorTex.value = null; @@ -28880,10 +37853,29 @@ exports.SliderGLRenderer = SliderGLRenderer; exports.default = SliderGLRenderer; -},{"../../Component":274,"../../Geo":277}],339:[function(require,module,exports){ +},{"../../Component":291,"../../Geo":294}],356:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var CameraVisualizationMode; +(function (CameraVisualizationMode) { + CameraVisualizationMode[CameraVisualizationMode["Default"] = 0] = "Default"; + CameraVisualizationMode[CameraVisualizationMode["Cluster"] = 1] = "Cluster"; + CameraVisualizationMode[CameraVisualizationMode["ConnectedComponent"] = 2] = "ConnectedComponent"; + CameraVisualizationMode[CameraVisualizationMode["Sequence"] = 3] = "Sequence"; +})(CameraVisualizationMode = exports.CameraVisualizationMode || (exports.CameraVisualizationMode = {})); +exports.default = CameraVisualizationMode; + +},{}],357:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var CameraVisualizationMode_1 = require("./CameraVisualizationMode"); +exports.CameraVisualizationMode = CameraVisualizationMode_1.CameraVisualizationMode; + +},{"./CameraVisualizationMode":356}],358:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var geohash = require("latlon-geohash"); +var pako = require("pako"); var rxjs_1 = require("rxjs"); var operators_1 = require("rxjs/operators"); var Error_1 = require("../../Error"); @@ -28893,68 +37885,68 @@ var SpatialDataCache = /** @class */ (function () { this._graphService = graphService; this._tiles = {}; this._cacheRequests = {}; - this._reconstructions = {}; - this._cachingReconstructions$ = {}; + this._clusterReconstructions = {}; + this._clusterReconstructionTiles = {}; + this._tileClusters = {}; this._cachingTiles$ = {}; + this._cachingClusterReconstructions$ = {}; } - SpatialDataCache.prototype.cacheReconstructions$ = function (hash) { + SpatialDataCache.prototype.cacheClusterReconstructions$ = function (hash) { var _this = this; - if (!(hash in this._tiles)) { + if (!this.hasTile(hash)) { throw new Error("Cannot cache reconstructions of a non-existing tile."); } - if (this.hasReconstructions(hash)) { + if (this.hasClusterReconstructions(hash)) { throw new Error("Cannot cache reconstructions that already exists."); } - if (hash in this._cachingReconstructions$) { - return this._cachingReconstructions$[hash]; + if (this.isCachingClusterReconstructions(hash)) { + return this._cachingClusterReconstructions$[hash]; } - var tile = []; - if (hash in this._reconstructions) { - var reconstructionKeys = this.getReconstructions(hash) - .map(function (reconstruction) { - return reconstruction.data.key; - }); - for (var _i = 0, _a = this.getTile(hash); _i < _a.length; _i++) { - var node = _a[_i]; - if (reconstructionKeys.indexOf(node.key) === -1) { - tile.push(node); + var clusterKeys = this.getTile(hash) + .filter(function (nd) { + return !!nd.clusterKey; + }) + .map(function (nd) { + return nd.clusterKey; + }) + .filter(function (v, i, a) { + return a.indexOf(v) === i; + }); + this._tileClusters[hash] = clusterKeys; + this._cacheRequests[hash] = []; + this._cachingClusterReconstructions$[hash] = rxjs_1.from(clusterKeys).pipe(operators_1.mergeMap(function (key) { + if (_this._hasClusterReconstruction(key)) { + return rxjs_1.of(_this._getClusterReconstruction(key)); + } + return _this._getClusterReconstruction$(key, _this._cacheRequests[hash]) + .pipe(operators_1.catchError(function (error) { + if (error instanceof Error_1.AbortMapillaryError) { + return rxjs_1.empty(); } + console.error(error); + return rxjs_1.empty(); + })); + }, 6), operators_1.filter(function () { + return hash in _this._tileClusters; + }), operators_1.tap(function (reconstruction) { + if (!_this._hasClusterReconstruction(reconstruction.key)) { + _this._clusterReconstructions[reconstruction.key] = reconstruction; + } + if (!(reconstruction.key in _this._clusterReconstructionTiles)) { + _this._clusterReconstructionTiles[reconstruction.key] = []; + } + if (_this._clusterReconstructionTiles[reconstruction.key].indexOf(hash) === -1) { + _this._clusterReconstructionTiles[reconstruction.key].push(hash); } - } - else { - tile.push.apply(tile, this.getTile(hash)); - this._reconstructions[hash] = []; - } - this._cacheRequests[hash] = []; - this._cachingReconstructions$[hash] = rxjs_1.from(tile).pipe(operators_1.mergeMap(function (nodeData) { - return !_this._cacheRequests[hash] ? - rxjs_1.empty() : - rxjs_1.zip(rxjs_1.of(nodeData), _this._getAtomicReconstruction(nodeData.key, _this._cacheRequests[hash])) - .pipe(operators_1.catchError(function (error) { - if (error instanceof Error_1.AbortMapillaryError) { - return rxjs_1.empty(); - } - console.error(error); - return rxjs_1.of([nodeData, null]); - })); - }, 6), operators_1.map(function (_a) { - var nodeData = _a[0], reconstruction = _a[1]; - return { data: nodeData, reconstruction: reconstruction }; - }), operators_1.filter(function () { - return hash in _this._reconstructions; - }), operators_1.tap(function (data) { - _this._reconstructions[hash].push(data); - }), operators_1.filter(function (data) { - return !!data.reconstruction; }), operators_1.finalize(function () { - if (hash in _this._cachingReconstructions$) { - delete _this._cachingReconstructions$[hash]; + if (hash in _this._cachingClusterReconstructions$) { + delete _this._cachingClusterReconstructions$[hash]; } if (hash in _this._cacheRequests) { delete _this._cacheRequests[hash]; } }), operators_1.publish(), operators_1.refCount()); - return this._cachingReconstructions$[hash]; + return this._cachingClusterReconstructions$[hash]; }; SpatialDataCache.prototype.cacheTile$ = function (hash) { var _this = this; @@ -28964,15 +37956,14 @@ var SpatialDataCache = /** @class */ (function () { if (this.hasTile(hash)) { throw new Error("Cannot cache tile that already exists."); } - if (hash in this._cachingTiles$) { + if (this.isCachingTile(hash)) { return this._cachingTiles$[hash]; } var bounds = geohash.bounds(hash); var sw = { lat: bounds.sw.lat, lon: bounds.sw.lon }; var ne = { lat: bounds.ne.lat, lon: bounds.ne.lon }; - this._tiles[hash] = []; - this._cachingTiles$[hash] = this._graphService.cacheBoundingBox$(sw, ne).pipe(operators_1.catchError(function () { - delete _this._tiles[hash]; + this._cachingTiles$[hash] = this._graphService.cacheBoundingBox$(sw, ne).pipe(operators_1.catchError(function (error) { + console.error(error); return rxjs_1.empty(); }), operators_1.map(function (nodes) { return nodes @@ -28980,9 +37971,10 @@ var SpatialDataCache = /** @class */ (function () { return _this._createNodeData(n); }); }), operators_1.filter(function () { - return hash in _this._tiles; + return !(hash in _this._tiles); }), operators_1.tap(function (nodeData) { var _a; + _this._tiles[hash] = []; (_a = _this._tiles[hash]).push.apply(_a, nodeData); delete _this._cachingTiles$[hash]; }), operators_1.finalize(function () { @@ -28992,25 +37984,37 @@ var SpatialDataCache = /** @class */ (function () { }), operators_1.publish(), operators_1.refCount()); return this._cachingTiles$[hash]; }; - SpatialDataCache.prototype.isCachingReconstructions = function (hash) { - return hash in this._cachingReconstructions$; + SpatialDataCache.prototype.isCachingClusterReconstructions = function (hash) { + return hash in this._cachingClusterReconstructions$; }; SpatialDataCache.prototype.isCachingTile = function (hash) { return hash in this._cachingTiles$; }; - SpatialDataCache.prototype.hasReconstructions = function (hash) { - return !(hash in this._cachingReconstructions$) && - hash in this._reconstructions && - this._reconstructions[hash].length === this._tiles[hash].length; + SpatialDataCache.prototype.hasClusterReconstructions = function (hash) { + if (hash in this._cachingClusterReconstructions$ || + !(hash in this._tileClusters)) { + return false; + } + for (var _i = 0, _a = this._tileClusters[hash]; _i < _a.length; _i++) { + var key = _a[_i]; + if (!(key in this._clusterReconstructions)) { + return false; + } + } + return true; }; SpatialDataCache.prototype.hasTile = function (hash) { return !(hash in this._cachingTiles$) && hash in this._tiles; }; - SpatialDataCache.prototype.getReconstructions = function (hash) { - return hash in this._reconstructions ? - this._reconstructions[hash] - .filter(function (data) { - return !!data.reconstruction; + SpatialDataCache.prototype.getClusterReconstructions = function (hash) { + var _this = this; + return hash in this._tileClusters ? + this._tileClusters[hash] + .map(function (key) { + return _this._clusterReconstructions[key]; + }) + .filter(function (reconstruction) { + return !!reconstruction; }) : []; }; @@ -29029,15 +38033,31 @@ var SpatialDataCache = /** @class */ (function () { } delete this._cacheRequests[hash]; } - for (var _d = 0, _e = Object.keys(this._reconstructions); _d < _e.length; _d++) { + for (var _d = 0, _e = Object.keys(this._tileClusters); _d < _e.length; _d++) { var hash = _e[_d]; if (!!keepHashes && keepHashes.indexOf(hash) !== -1) { continue; } - delete this._reconstructions[hash]; + for (var _f = 0, _g = this._tileClusters[hash]; _f < _g.length; _f++) { + var key = _g[_f]; + if (!(key in this._clusterReconstructionTiles)) { + continue; + } + var index = this._clusterReconstructionTiles[key].indexOf(hash); + if (index === -1) { + continue; + } + this._clusterReconstructionTiles[key].splice(index, 1); + if (this._clusterReconstructionTiles[key].length > 0) { + continue; + } + delete this._clusterReconstructionTiles[key]; + delete this._clusterReconstructions[key]; + } + delete this._tileClusters[hash]; } - for (var _f = 0, _g = Object.keys(this._tiles); _f < _g.length; _f++) { - var hash = _g[_f]; + for (var _h = 0, _j = Object.keys(this._tiles); _h < _j.length; _h++) { + var hash = _j[_h]; if (!!keepHashes && keepHashes.indexOf(hash) !== -1) { continue; } @@ -29047,6 +38067,8 @@ var SpatialDataCache = /** @class */ (function () { SpatialDataCache.prototype._createNodeData = function (node) { return { alt: node.alt, + cameraProjection: node.cameraProjection, + clusterKey: node.clusterKey, focal: node.focal, gpano: node.gpano, height: node.height, @@ -29061,43 +38083,57 @@ var SpatialDataCache = /** @class */ (function () { originalLon: node.originalLatLon.lon, rotation: [node.rotation[0], node.rotation[1], node.rotation[2]], scale: node.scale, + sequenceKey: node.sequenceKey, width: node.width, }; }; - SpatialDataCache.prototype._getAtomicReconstruction = function (key, requests) { + SpatialDataCache.prototype._getClusterReconstruction = function (key) { + return this._clusterReconstructions[key]; + }; + SpatialDataCache.prototype._getClusterReconstruction$ = function (key, requests) { return rxjs_1.Observable.create(function (subscriber) { - var xmlHTTP = new XMLHttpRequest(); - xmlHTTP.open("GET", Utils_1.Urls.atomicReconstruction(key), true); - xmlHTTP.responseType = "json"; - xmlHTTP.timeout = 15000; - xmlHTTP.onload = function () { - if (!xmlHTTP.response) { - subscriber.error(new Error("Atomic reconstruction does not exist (" + key + ")")); + var xhr = new XMLHttpRequest(); + xhr.open("GET", Utils_1.Urls.clusterReconstruction(key), true); + xhr.responseType = "arraybuffer"; + xhr.timeout = 15000; + xhr.onload = function () { + if (!xhr.response) { + subscriber.error(new Error("Cluster reconstruction retreival failed (" + key + ")")); } else { - subscriber.next(xmlHTTP.response); + var inflated = pako.inflate(xhr.response, { to: "string" }); + var reconstructions = JSON.parse(inflated); + if (reconstructions.length < 1) { + subscriber.error(new Error("No cluster reconstruction exists (" + key + ")")); + } + var reconstruction = reconstructions[0]; + reconstruction.key = key; + subscriber.next(reconstruction); subscriber.complete(); } }; - xmlHTTP.onerror = function () { - subscriber.error(new Error("Failed to get atomic reconstruction (" + key + ")")); + xhr.onerror = function () { + subscriber.error(new Error("Failed to get cluster reconstruction (" + key + ")")); }; - xmlHTTP.ontimeout = function () { - subscriber.error(new Error("Atomic reconstruction request timed out (" + key + ")")); + xhr.ontimeout = function () { + subscriber.error(new Error("Cluster reconstruction request timed out (" + key + ")")); }; - xmlHTTP.onabort = function () { - subscriber.error(new Error_1.AbortMapillaryError("Atomic reconstruction request was aborted (" + key + ")")); + xhr.onabort = function () { + subscriber.error(new Error_1.AbortMapillaryError("Cluster reconstruction request was aborted (" + key + ")")); }; - requests.push(xmlHTTP); - xmlHTTP.send(null); + requests.push(xhr); + xhr.send(null); }); }; + SpatialDataCache.prototype._hasClusterReconstruction = function (key) { + return key in this._clusterReconstructions; + }; return SpatialDataCache; }()); exports.SpatialDataCache = SpatialDataCache; exports.default = SpatialDataCache; -},{"../../Error":276,"../../Utils":284,"latlon-geohash":21,"rxjs":26,"rxjs/operators":224}],340:[function(require,module,exports){ +},{"../../Error":293,"../../Utils":301,"latlon-geohash":21,"pako":23,"rxjs":43,"rxjs/operators":241}],359:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -29121,6 +38157,7 @@ var Geo_1 = require("../../Geo"); var Render_1 = require("../../Render"); var PlayService_1 = require("../../viewer/PlayService"); var State_1 = require("../../state/State"); +var CameraVisualizationMode_1 = require("./CameraVisualizationMode"); var SpatialDataComponent = /** @class */ (function (_super) { __extends(SpatialDataComponent, _super); function SpatialDataComponent(name, container, navigator) { @@ -29133,6 +38170,18 @@ var SpatialDataComponent = /** @class */ (function (_super) { } SpatialDataComponent.prototype._activate = function () { var _this = this; + this._earthControlsSubscription = this._configuration$.pipe(operators_1.map(function (configuration) { + return configuration.earthControls; + }), operators_1.distinctUntilChanged(), operators_1.withLatestFrom(this._navigator.stateService.state$)) + .subscribe(function (_a) { + var earth = _a[0], state = _a[1]; + if (earth && state !== State_1.default.Earth) { + _this._navigator.stateService.earth(); + } + else if (!earth && state === State_1.default.Earth) { + _this._navigator.stateService.traverse(); + } + }); var direction$ = this._container.renderService.bearing$.pipe(operators_1.map(function (bearing) { var direction = ""; if (bearing > 292.5 || bearing <= 67.5) { @@ -29160,80 +38209,81 @@ var SpatialDataComponent = /** @class */ (function (_super) { var playing = _a[0], speed = _a[1]; return playing && speed > PlayService_1.default.sequenceSpeed; }), operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount()); - this._addSubscription = this._navigator.stateService.state$.pipe(operators_1.map(function (state) { + var hashes$ = rxjs_1.combineLatest(this._navigator.stateService.state$.pipe(operators_1.map(function (state) { return state === State_1.default.Earth; - }), operators_1.distinctUntilChanged(), operators_1.switchMap(function (earth) { - if (earth) { - return rxjs_1.combineLatest(hash$, sequencePlay$).pipe(operators_1.mergeMap(function (_a) { - var hash = _a[0], sequencePlay = _a[1]; - return sequencePlay ? - rxjs_1.of([hash]) : - rxjs_1.of(_this._adjacentComponent(hash, 4)); - })); + }), operators_1.distinctUntilChanged()), hash$, sequencePlay$, direction$).pipe(operators_1.distinctUntilChanged(function (_a, _b) { + var e1 = _a[0], h1 = _a[1], s1 = _a[2], d1 = _a[3]; + var e2 = _b[0], h2 = _b[1], s2 = _b[2], d2 = _b[3]; + if (e1 !== e2) { + return false; + } + if (e1) { + return h1 === h2 && s1 === s2; } - return rxjs_1.combineLatest(hash$, sequencePlay$, direction$).pipe(operators_1.mergeMap(function (_a) { - var hash = _a[0], sequencePlay = _a[1], direction = _a[2]; + return h1 === h2 && s1 === s2 && d1 === d2; + }), operators_1.concatMap(function (_a) { + var earth = _a[0], hash = _a[1], sequencePlay = _a[2], direction = _a[3]; + if (earth) { return sequencePlay ? - rxjs_1.of([hash, geohash.neighbours(hash)[direction]]) : - rxjs_1.of(_this._computeTiles(hash, direction)); - })); - }), operators_1.switchMap(function (hashes) { + rxjs_1.of([hash]) : + rxjs_1.of(_this._adjacentComponent(hash, 4)); + } + return sequencePlay ? + rxjs_1.of([hash, geohash.neighbours(hash)[direction]]) : + rxjs_1.of(_this._computeTiles(hash, direction)); + }), operators_1.publish(), operators_1.refCount()); + var tile$ = hashes$.pipe(operators_1.switchMap(function (hashes) { return rxjs_1.from(hashes).pipe(operators_1.mergeMap(function (h) { - var tile$; - if (_this._cache.hasTile(h)) { - tile$ = rxjs_1.of(_this._cache.getTile(h)); - } - else if (_this._cache.isCachingTile(h)) { - tile$ = _this._cache.cacheTile$(h).pipe(operators_1.last(null, {}), operators_1.switchMap(function () { - return rxjs_1.of(_this._cache.getTile(h)); - })); - } - else { - tile$ = _this._cache.cacheTile$(h); + var t$ = _this._cache.hasTile(h) ? + rxjs_1.of(_this._cache.getTile(h)) : + _this._cache.cacheTile$(h); + return rxjs_1.combineLatest(rxjs_1.of(h), t$); + }, 6)); + }), operators_1.publish(), operators_1.refCount()); + this._addTileSubscription = tile$.pipe(operators_1.withLatestFrom(this._navigator.stateService.reference$)) + .subscribe(function (_a) { + var hash = _a[0][0], reference = _a[1]; + if (_this._scene.hasTile(hash)) { + return; + } + _this._scene.addTile(_this._computeTileBBox(hash, reference), hash); + }); + this._addNodeSubscription = tile$.pipe(operators_1.withLatestFrom(this._navigator.stateService.reference$)) + .subscribe(function (_a) { + var _b = _a[0], hash = _b[0], datas = _b[1], reference = _a[1]; + for (var _i = 0, datas_1 = datas; _i < datas_1.length; _i++) { + var data = datas_1[_i]; + if (_this._scene.hasNode(data.key, hash)) { + continue; } - return rxjs_1.combineLatest(rxjs_1.of(h), tile$); - }, 1), operators_1.map(function (_a) { - var hash = _a[0]; - return hash; - })); - }), operators_1.concatMap(function (hash) { + _this._scene.addNode(data, _this._createTransform(data, reference), _this._computeOriginalPosition(data, reference), hash); + } + }); + this._addReconstructionSubscription = tile$.pipe(operators_1.concatMap(function (_a) { + var hash = _a[0]; var reconstructions$; - if (_this._cache.hasReconstructions(hash)) { - reconstructions$ = rxjs_1.from(_this._cache.getReconstructions(hash)); + if (_this._cache.hasClusterReconstructions(hash)) { + reconstructions$ = rxjs_1.from(_this._cache.getClusterReconstructions(hash)); } - else if (_this._cache.isCachingReconstructions(hash)) { - reconstructions$ = _this._cache.cacheReconstructions$(hash).pipe(operators_1.last(null, {}), operators_1.switchMap(function () { - return rxjs_1.from(_this._cache.getReconstructions(hash)); + else if (_this._cache.isCachingClusterReconstructions(hash)) { + reconstructions$ = _this._cache.cacheClusterReconstructions$(hash).pipe(operators_1.last(null, {}), operators_1.switchMap(function () { + return rxjs_1.from(_this._cache.getClusterReconstructions(hash)); })); } else if (_this._cache.hasTile(hash)) { - reconstructions$ = _this._cache.cacheReconstructions$(hash); + reconstructions$ = _this._cache.cacheClusterReconstructions$(hash); } else { reconstructions$ = rxjs_1.empty(); } return rxjs_1.combineLatest(rxjs_1.of(hash), reconstructions$); - }), operators_1.withLatestFrom(this._navigator.stateService.reference$), operators_1.tap(function (_a) { - var hash = _a[0][0], reference = _a[1]; - if (_this._scene.hasTile(hash)) { + }), operators_1.withLatestFrom(this._navigator.stateService.reference$)) + .subscribe(function (_a) { + var _b = _a[0], hash = _b[0], reconstruction = _b[1], reference = _a[1]; + if (_this._scene.hasClusterReconstruction(reconstruction.key, hash)) { return; } - _this._scene.addTile(_this._computeTileBBox(hash, reference), hash); - }), operators_1.filter(function (_a) { - var _b = _a[0], hash = _b[0], data = _b[1]; - return !_this._scene.hasReconstruction(data.reconstruction.main_shot, hash); - }), operators_1.map(function (_a) { - var _b = _a[0], hash = _b[0], data = _b[1], reference = _a[1]; - return [ - data, - _this._createTransform(data.data, reference), - _this._computeOriginalPosition(data.data, reference), - hash - ]; - })) - .subscribe(function (_a) { - var data = _a[0], transform = _a[1], position = _a[2], hash = _a[3]; - _this._scene.addReconstruction(data.reconstruction, transform, position, !!data.data.mergeCC ? data.data.mergeCC.toString() : "", hash); + _this._scene.addClusterReconstruction(reconstruction, _this._computeTranslation(reconstruction, reference), hash); }); this._cameraVisibilitySubscription = this._configuration$.pipe(operators_1.map(function (configuration) { return configuration.camerasVisible; @@ -29259,11 +38309,19 @@ var SpatialDataComponent = /** @class */ (function (_super) { .subscribe(function (visible) { _this._scene.setTileVisibility(visible); }); - this._visualizeConnectedComponentSubscription = this._configuration$.pipe(operators_1.map(function (configuration) { - return configuration.connectedComponents; + this._ccToModeSubscription = this._configuration$.pipe(operators_1.map(function (configuration) { + return configuration.connectedComponents === true ? + CameraVisualizationMode_1.default.ConnectedComponent : + CameraVisualizationMode_1.default.Default; }), operators_1.distinctUntilChanged()) - .subscribe(function (visualize) { - _this._scene.setConnectedComponentVisualization(visualize); + .subscribe(function (mode) { + _this.configure({ cameraVisualizationMode: mode }); + }); + this._cameraVisualizationModeSubscription = this._configuration$.pipe(operators_1.map(function (configuration) { + return configuration.cameraVisualizationMode; + }), operators_1.distinctUntilChanged()) + .subscribe(function (mode) { + _this._scene.setCameraVisualizationMode(mode); }); this._uncacheSubscription = hash$ .subscribe(function (hash) { @@ -29301,30 +38359,14 @@ var SpatialDataComponent = /** @class */ (function (_super) { }; })) .subscribe(this._container.glRenderer.render$); - this._earthControlsSubscription = this._configuration$.pipe(operators_1.map(function (configuration) { - return configuration.earthControls; - }), operators_1.distinctUntilChanged(), operators_1.withLatestFrom(this._navigator.stateService.state$)) - .subscribe(function (_a) { - var earth = _a[0], state = _a[1]; - if (earth && state !== State_1.default.Earth) { - _this._navigator.stateService.earth(); - } - else if (!earth && state === State_1.default.Earth) { - _this._navigator.stateService.traverse(); - } - }); }; SpatialDataComponent.prototype._deactivate = function () { var _this = this; - this._navigator.stateService.state$.pipe(operators_1.first()) - .subscribe(function (state) { - if (state === State_1.default.Earth) { - _this._navigator.stateService.traverse(); - } - }); this._cache.uncache(); this._scene.uncache(); - this._addSubscription.unsubscribe(); + this._addNodeSubscription.unsubscribe(); + this._addReconstructionSubscription.unsubscribe(); + this._addTileSubscription.unsubscribe(); this._cameraVisibilitySubscription.unsubscribe(); this._earthControlsSubscription.unsubscribe(); this._moveSubscription.unsubscribe(); @@ -29333,10 +38375,24 @@ var SpatialDataComponent = /** @class */ (function (_super) { this._renderSubscription.unsubscribe(); this._tileVisibilitySubscription.unsubscribe(); this._uncacheSubscription.unsubscribe(); - this._visualizeConnectedComponentSubscription.unsubscribe(); + this._cameraVisualizationModeSubscription.unsubscribe(); + this._ccToModeSubscription.unsubscribe(); + this._navigator.stateService.state$.pipe(operators_1.first()) + .subscribe(function (state) { + if (state === State_1.default.Earth) { + _this._navigator.stateService.traverse(); + } + }); }; SpatialDataComponent.prototype._getDefaultConfiguration = function () { - return { camerasVisible: false, pointsVisible: true, positionsVisible: false, tilesVisible: false }; + return { + cameraVisualizationMode: CameraVisualizationMode_1.default.Default, + camerasVisible: false, + connectedComponents: false, + pointsVisible: true, + positionsVisible: false, + tilesVisible: false, + }; }; SpatialDataComponent.prototype._adjacentComponent = function (hash, depth) { var hashSet = new Set(); @@ -29380,7 +38436,7 @@ var SpatialDataComponent = /** @class */ (function (_super) { }; SpatialDataComponent.prototype._createTransform = function (data, reference) { var translation = Geo_1.Geo.computeTranslation({ alt: data.alt, lat: data.lat, lon: data.lon }, data.rotation, reference); - var transform = new Geo_1.Transform(data.orientation, data.width, data.height, data.focal, data.scale, data.gpano, data.rotation, translation, undefined, undefined, data.k1, data.k2); + var transform = new Geo_1.Transform(data.orientation, data.width, data.height, data.focal, data.scale, data.gpano, data.rotation, translation, undefined, undefined, data.k1, data.k2, data.cameraProjection); return transform; }; SpatialDataComponent.prototype._computeTiles = function (hash, direction) { @@ -29407,6 +38463,9 @@ var SpatialDataComponent = /** @class */ (function (_super) { this._computeTilesRecursive(hashSet, directionNeighbour, direction, directions, currentDepth + 1, maxDepth); } }; + SpatialDataComponent.prototype._computeTranslation = function (reconstruction, reference) { + return this._geoCoords.geodeticToEnu(reconstruction.reference_lla.latitude, reconstruction.reference_lla.longitude, reconstruction.reference_lla.altitude, reference.lat, reference.lon, reference.alt); + }; SpatialDataComponent.prototype._modulo = function (a, n) { return ((a % n) + n) % n; }; @@ -29424,24 +38483,33 @@ exports.SpatialDataComponent = SpatialDataComponent; Component_1.ComponentService.register(SpatialDataComponent); exports.default = SpatialDataComponent; -},{"../../Component":274,"../../Geo":277,"../../Render":280,"../../state/State":411,"../../viewer/PlayService":440,"latlon-geohash":21,"rxjs":26,"rxjs/operators":224}],341:[function(require,module,exports){ +},{"../../Component":291,"../../Geo":294,"../../Render":297,"../../state/State":438,"../../viewer/PlayService":468,"./CameraVisualizationMode":356,"latlon-geohash":21,"rxjs":43,"rxjs/operators":241}],360:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var THREE = require("three"); +var CameraVisualizationMode_1 = require("./CameraVisualizationMode"); var SpatialDataScene = /** @class */ (function () { function SpatialDataScene(configuration, scene, raycaster) { this._scene = !!scene ? scene : new THREE.Scene(); this._raycaster = !!raycaster ? raycaster : new THREE.Raycaster(undefined, undefined, 0.8); - this._connectedComponentColors = {}; + this._cameraColors = {}; this._needsRender = false; this._interactiveObjects = []; - this._reconstructions = {}; + this._nodes = {}; this._tiles = {}; + this._tileClusterReconstructions = {}; + this._clusterReconstructions = {}; + this._cameraVisualizationMode = !!configuration.cameraVisualizationMode ? + configuration.cameraVisualizationMode : + CameraVisualizationMode_1.default.Default; + if (this._cameraVisualizationMode === CameraVisualizationMode_1.default.Default && + configuration.connectedComponents === true) { + this._cameraVisualizationMode = CameraVisualizationMode_1.default.ConnectedComponent; + } this._camerasVisible = configuration.camerasVisible; this._pointsVisible = configuration.pointsVisible; this._positionsVisible = configuration.positionsVisible; this._tilesVisible = configuration.tilesVisible; - this._visualizeConnectedComponents = configuration.connectedComponents; } Object.defineProperty(SpatialDataScene.prototype, "needsRender", { get: function () { @@ -29450,39 +38518,79 @@ var SpatialDataScene = /** @class */ (function () { enumerable: true, configurable: true }); - SpatialDataScene.prototype.addReconstruction = function (reconstruction, transform, originalPosition, connectedComponent, hash) { - if (!(hash in this._reconstructions)) { - this._reconstructions[hash] = { + SpatialDataScene.prototype.addClusterReconstruction = function (reconstruction, translation, hash) { + if (this.hasClusterReconstruction(reconstruction.key, hash)) { + return; + } + var key = reconstruction.key; + if (!(key in this._clusterReconstructions)) { + this._clusterReconstructions[key] = { + points: new THREE.Object3D(), + tiles: [], + }; + this._clusterReconstructions[key].points.visible = this._pointsVisible; + this._clusterReconstructions[key].points.add(this._createClusterPoints(reconstruction, translation)); + this._scene.add(this._clusterReconstructions[key].points); + } + if (this._clusterReconstructions[key].tiles.indexOf(hash) === -1) { + this._clusterReconstructions[key].tiles.push(hash); + } + if (!(hash in this._tileClusterReconstructions)) { + this._tileClusterReconstructions[hash] = { + keys: [], + }; + } + if (this._tileClusterReconstructions[hash].keys.indexOf(key) === -1) { + this._tileClusterReconstructions[hash].keys.push(key); + } + this._needsRender = true; + }; + SpatialDataScene.prototype.addNode = function (data, transform, originalPosition, hash) { + var key = data.key; + var clusterKey = data.clusterKey; + var sequenceKey = data.sequenceKey; + var connectedComponent = !!data.mergeCC ? data.mergeCC.toString() : ""; + if (this.hasNode(key, hash)) { + return; + } + if (!(hash in this._nodes)) { + this._nodes[hash] = { cameraKeys: {}, cameras: new THREE.Object3D(), + clusters: {}, connectedComponents: {}, keys: [], - points: new THREE.Object3D(), positions: new THREE.Object3D(), + sequences: {}, }; - this._reconstructions[hash].cameras.visible = this._camerasVisible; - this._reconstructions[hash].points.visible = this._pointsVisible; - this._reconstructions[hash].positions.visible = this._positionsVisible; - this._scene.add(this._reconstructions[hash].cameras, this._reconstructions[hash].points, this._reconstructions[hash].positions); + this._nodes[hash].cameras.visible = this._camerasVisible; + this._nodes[hash].positions.visible = this._positionsVisible; + this._scene.add(this._nodes[hash].cameras, this._nodes[hash].positions); + } + if (!(connectedComponent in this._nodes[hash].connectedComponents)) { + this._nodes[hash].connectedComponents[connectedComponent] = []; } - if (!(connectedComponent in this._reconstructions[hash].connectedComponents)) { - this._reconstructions[hash].connectedComponents[connectedComponent] = []; + if (!(clusterKey in this._nodes[hash].clusters)) { + this._nodes[hash].clusters[clusterKey] = []; } - if (transform.hasValidScale) { - this._reconstructions[hash].points.add(this._createPoints(reconstruction, transform)); + if (!(sequenceKey in this._nodes[hash].sequences)) { + this._nodes[hash].sequences[sequenceKey] = []; } var camera = this._createCamera(transform); - this._reconstructions[hash].cameras.add(camera); + this._nodes[hash].cameras.add(camera); for (var _i = 0, _a = camera.children; _i < _a.length; _i++) { var child = _a[_i]; - this._reconstructions[hash].cameraKeys[child.uuid] = reconstruction.main_shot; + this._nodes[hash].cameraKeys[child.uuid] = key; this._interactiveObjects.push(child); } - this._reconstructions[hash].connectedComponents[connectedComponent].push(camera); - var color = this._getColor(connectedComponent, this._visualizeConnectedComponents); + this._nodes[hash].connectedComponents[connectedComponent].push(camera); + this._nodes[hash].clusters[clusterKey].push(camera); + this._nodes[hash].sequences[sequenceKey].push(camera); + var id = this._getId(clusterKey, connectedComponent, sequenceKey, this._cameraVisualizationMode); + var color = this._getColor(id, this._cameraVisualizationMode); this._setCameraColor(color, camera); - this._reconstructions[hash].positions.add(this._createPosition(transform, originalPosition)); - this._reconstructions[hash].keys.push(reconstruction.main_shot); + this._nodes[hash].positions.add(this._createPosition(transform, originalPosition)); + this._nodes[hash].keys.push(key); this._needsRender = true; }; SpatialDataScene.prototype.addTile = function (tileBBox, hash) { @@ -29501,28 +38609,39 @@ var SpatialDataScene = /** @class */ (function () { this._needsRender = true; }; SpatialDataScene.prototype.uncache = function (keepHashes) { - for (var _i = 0, _a = Object.keys(this._reconstructions); _i < _a.length; _i++) { + for (var _i = 0, _a = Object.keys(this._tileClusterReconstructions); _i < _a.length; _i++) { var hash = _a[_i]; if (!!keepHashes && keepHashes.indexOf(hash) !== -1) { continue; } this._disposeReconstruction(hash); } - for (var _b = 0, _c = Object.keys(this._tiles); _b < _c.length; _b++) { + for (var _b = 0, _c = Object.keys(this._nodes); _b < _c.length; _b++) { var hash = _c[_b]; if (!!keepHashes && keepHashes.indexOf(hash) !== -1) { continue; } + this._disposeNodes(hash); + } + for (var _d = 0, _e = Object.keys(this._tiles); _d < _e.length; _d++) { + var hash = _e[_d]; + if (!!keepHashes && keepHashes.indexOf(hash) !== -1) { + continue; + } this._disposeTile(hash); } this._needsRender = true; }; - SpatialDataScene.prototype.hasReconstruction = function (key, hash) { - return hash in this._reconstructions && this._reconstructions[hash].keys.indexOf(key) !== -1; + SpatialDataScene.prototype.hasClusterReconstruction = function (key, hash) { + return key in this._clusterReconstructions && + this._clusterReconstructions[key].tiles.indexOf(hash) !== -1; }; SpatialDataScene.prototype.hasTile = function (hash) { return hash in this._tiles; }; + SpatialDataScene.prototype.hasNode = function (key, hash) { + return hash in this._nodes && this._nodes[hash].keys.indexOf(key) !== -1; + }; SpatialDataScene.prototype.intersectObjects = function (_a, camera) { var viewportX = _a[0], viewportY = _a[1]; if (!this._camerasVisible) { @@ -29532,12 +38651,12 @@ var SpatialDataScene = /** @class */ (function () { var intersects = this._raycaster.intersectObjects(this._interactiveObjects); for (var _i = 0, intersects_1 = intersects; _i < intersects_1.length; _i++) { var intersect = intersects_1[_i]; - for (var hash in this._reconstructions) { - if (!this._reconstructions.hasOwnProperty(hash)) { + for (var hash in this._nodes) { + if (!this._nodes.hasOwnProperty(hash)) { continue; } - if (intersect.object.uuid in this._reconstructions[hash].cameraKeys) { - return this._reconstructions[hash].cameraKeys[intersect.object.uuid]; + if (intersect.object.uuid in this._nodes[hash].cameraKeys) { + return this._nodes[hash].cameraKeys[intersect.object.uuid]; } } } @@ -29547,11 +38666,11 @@ var SpatialDataScene = /** @class */ (function () { if (visible === this._camerasVisible) { return; } - for (var hash in this._reconstructions) { - if (!this._reconstructions.hasOwnProperty(hash)) { + for (var hash in this._nodes) { + if (!this._nodes.hasOwnProperty(hash)) { continue; } - this._reconstructions[hash].cameras.visible = visible; + this._nodes[hash].cameras.visible = visible; } this._camerasVisible = visible; this._needsRender = true; @@ -29560,11 +38679,11 @@ var SpatialDataScene = /** @class */ (function () { if (visible === this._pointsVisible) { return; } - for (var hash in this._reconstructions) { - if (!this._reconstructions.hasOwnProperty(hash)) { + for (var key in this._clusterReconstructions) { + if (!this._clusterReconstructions.hasOwnProperty(key)) { continue; } - this._reconstructions[hash].points.visible = visible; + this._clusterReconstructions[key].points.visible = visible; } this._pointsVisible = visible; this._needsRender = true; @@ -29573,11 +38692,11 @@ var SpatialDataScene = /** @class */ (function () { if (visible === this._positionsVisible) { return; } - for (var hash in this._reconstructions) { - if (!this._reconstructions.hasOwnProperty(hash)) { + for (var hash in this._nodes) { + if (!this._nodes.hasOwnProperty(hash)) { continue; } - this._reconstructions[hash].positions.visible = visible; + this._nodes[hash].positions.visible = visible; } this._positionsVisible = visible; this._needsRender = true; @@ -29595,27 +38714,44 @@ var SpatialDataScene = /** @class */ (function () { this._tilesVisible = visible; this._needsRender = true; }; - SpatialDataScene.prototype.setConnectedComponentVisualization = function (visualize) { - if (visualize === this._visualizeConnectedComponents) { + SpatialDataScene.prototype.setCameraVisualizationMode = function (mode) { + if (mode === this._cameraVisualizationMode) { return; } - for (var hash in this._reconstructions) { - if (!this._reconstructions.hasOwnProperty(hash)) { + for (var hash in this._nodes) { + if (!this._nodes.hasOwnProperty(hash)) { + continue; + } + var cameras = undefined; + if (mode === CameraVisualizationMode_1.default.Cluster) { + cameras = this._nodes[hash].clusters; + } + else if (mode === CameraVisualizationMode_1.default.ConnectedComponent) { + cameras = this._nodes[hash].connectedComponents; + } + else if (mode === CameraVisualizationMode_1.default.Sequence) { + cameras = this._nodes[hash].sequences; + } + else { + for (var _i = 0, _a = this._nodes[hash].cameras.children; _i < _a.length; _i++) { + var child = _a[_i]; + var color = this._getColor("", mode); + this._setCameraColor(color, child); + } continue; } - var connectedComponents = this._reconstructions[hash].connectedComponents; - for (var connectedComponent in connectedComponents) { - if (!connectedComponents.hasOwnProperty(connectedComponent)) { + for (var id in cameras) { + if (!cameras.hasOwnProperty(id)) { continue; } - var color = this._getColor(connectedComponent, visualize); - for (var _i = 0, _a = connectedComponents[connectedComponent]; _i < _a.length; _i++) { - var camera = _a[_i]; + var color = this._getColor(id, mode); + for (var _b = 0, _c = cameras[id]; _b < _c.length; _b++) { + var camera = _c[_b]; this._setCameraColor(color, camera); } } } - this._visualizeConnectedComponents = visualize; + this._cameraVisualizationMode = mode; this._needsRender = true; }; SpatialDataScene.prototype.render = function (perspectiveCamera, renderer) { @@ -29711,8 +38847,7 @@ var SpatialDataScene = /** @class */ (function () { camera.children.push(this._createLongitude(0.75, 6, transform)); return camera; }; - SpatialDataScene.prototype._createPoints = function (reconstruction, transform) { - var srtInverse = new THREE.Matrix4().getInverse(transform.srt); + SpatialDataScene.prototype._createClusterPoints = function (reconstruction, translation) { var points = Object .keys(reconstruction.points) .map(function (key) { @@ -29725,7 +38860,7 @@ var SpatialDataScene = /** @class */ (function () { var index = 3 * i; var coords = points[i].coordinates; var point = new THREE.Vector3(coords[0], coords[1], coords[2]) - .applyMatrix4(srtInverse); + .add(new THREE.Vector3().fromArray(translation)); positions[index + 0] = point.x; positions[index + 1] = point.y; positions[index + 2] = point.z; @@ -29758,7 +38893,7 @@ var SpatialDataScene = /** @class */ (function () { return camera; }; SpatialDataScene.prototype._disposeCameras = function (hash) { - var tileCameras = this._reconstructions[hash].cameras; + var tileCameras = this._nodes[hash].cameras; for (var _i = 0, _a = tileCameras.children.slice(); _i < _a.length; _i++) { var camera = _a[_i]; for (var _b = 0, _c = camera.children; _b < _c.length; _b++) { @@ -29778,17 +38913,30 @@ var SpatialDataScene = /** @class */ (function () { this._scene.remove(tileCameras); }; SpatialDataScene.prototype._disposePoints = function (hash) { - var tilePoints = this._reconstructions[hash].points; - for (var _i = 0, _a = tilePoints.children.slice(); _i < _a.length; _i++) { - var points = _a[_i]; - points.geometry.dispose(); - points.material.dispose(); - tilePoints.remove(points); + for (var _i = 0, _a = this._tileClusterReconstructions[hash].keys; _i < _a.length; _i++) { + var key = _a[_i]; + if (!(key in this._clusterReconstructions)) { + continue; + } + var index = this._clusterReconstructions[key].tiles.indexOf(hash); + if (index === -1) { + continue; + } + this._clusterReconstructions[key].tiles.splice(index, 1); + if (this._clusterReconstructions[key].tiles.length > 0) { + continue; + } + for (var _b = 0, _c = this._clusterReconstructions[key].points.children.slice(); _b < _c.length; _b++) { + var points = _c[_b]; + points.geometry.dispose(); + points.material.dispose(); + } + this._scene.remove(this._clusterReconstructions[key].points); + delete this._clusterReconstructions[key]; } - this._scene.remove(tilePoints); }; SpatialDataScene.prototype._disposePositions = function (hash) { - var tilePositions = this._reconstructions[hash].positions; + var tilePositions = this._nodes[hash].positions; for (var _i = 0, _a = tilePositions.children.slice(); _i < _a.length; _i++) { var position = _a[_i]; position.geometry.dispose(); @@ -29797,11 +38945,14 @@ var SpatialDataScene = /** @class */ (function () { } this._scene.remove(tilePositions); }; - SpatialDataScene.prototype._disposeReconstruction = function (hash) { + SpatialDataScene.prototype._disposeNodes = function (hash) { this._disposeCameras(hash); - this._disposePoints(hash); this._disposePositions(hash); - delete this._reconstructions[hash]; + delete this._nodes[hash]; + }; + SpatialDataScene.prototype._disposeReconstruction = function (hash) { + this._disposePoints(hash); + delete this._tileClusterReconstructions[hash]; }; SpatialDataScene.prototype._disposeTile = function (hash) { var tile = this._tiles[hash]; @@ -29814,16 +38965,28 @@ var SpatialDataScene = /** @class */ (function () { this._scene.remove(tile); delete this._tiles[hash]; }; - SpatialDataScene.prototype._getColor = function (connectedComponent, visualizeConnectedComponents) { - return visualizeConnectedComponents ? - this._getConnectedComponentColor(connectedComponent) : + SpatialDataScene.prototype._getColor = function (id, mode) { + return mode !== CameraVisualizationMode_1.default.Default && id.length > 0 ? + this._getCameraColor(id) : "#FFFFFF"; }; - SpatialDataScene.prototype._getConnectedComponentColor = function (connectedComponent) { - if (!(connectedComponent in this._connectedComponentColors)) { - this._connectedComponentColors[connectedComponent] = this._randomColor(); + SpatialDataScene.prototype._getCameraColor = function (id) { + if (!(id in this._cameraColors)) { + this._cameraColors[id] = this._randomColor(); + } + return this._cameraColors[id]; + }; + SpatialDataScene.prototype._getId = function (clusterKey, connectedComponent, sequenceKey, mode) { + switch (mode) { + case CameraVisualizationMode_1.default.Cluster: + return clusterKey; + case CameraVisualizationMode_1.default.ConnectedComponent: + return connectedComponent; + case CameraVisualizationMode_1.default.Sequence: + return sequenceKey; + default: + return ""; } - return this._connectedComponentColors[connectedComponent]; }; SpatialDataScene.prototype._interpolate = function (a, b, alpha) { return a + alpha * (b - a); @@ -29856,19 +39019,23 @@ var SpatialDataScene = /** @class */ (function () { exports.SpatialDataScene = SpatialDataScene; exports.default = SpatialDataScene; -},{"three":225}],342:[function(require,module,exports){ +},{"./CameraVisualizationMode":356,"three":242}],361:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var GeometryTagError_1 = require("./error/GeometryTagError"); exports.GeometryTagError = GeometryTagError_1.GeometryTagError; var PointGeometry_1 = require("./geometry/PointGeometry"); exports.PointGeometry = PointGeometry_1.PointGeometry; +var PointsGeometry_1 = require("./geometry/PointsGeometry"); +exports.PointsGeometry = PointsGeometry_1.PointsGeometry; var RectGeometry_1 = require("./geometry/RectGeometry"); exports.RectGeometry = RectGeometry_1.RectGeometry; var PolygonGeometry_1 = require("./geometry/PolygonGeometry"); exports.PolygonGeometry = PolygonGeometry_1.PolygonGeometry; var OutlineTag_1 = require("./tag/OutlineTag"); exports.OutlineTag = OutlineTag_1.OutlineTag; +var ExtremePointTag_1 = require("./tag/ExtremePointTag"); +exports.ExtremePointTag = ExtremePointTag_1.ExtremePointTag; var SpotTag_1 = require("./tag/SpotTag"); exports.SpotTag = SpotTag_1.SpotTag; var TagDomain_1 = require("./tag/TagDomain"); @@ -29878,7 +39045,7 @@ exports.TagComponent = TagComponent_1.TagComponent; var TagMode_1 = require("./TagMode"); exports.TagMode = TagMode_1.TagMode; -},{"./TagComponent":343,"./TagMode":346,"./error/GeometryTagError":350,"./geometry/PointGeometry":352,"./geometry/PolygonGeometry":353,"./geometry/RectGeometry":354,"./tag/OutlineTag":366,"./tag/SpotTag":369,"./tag/TagDomain":371}],343:[function(require,module,exports){ +},{"./TagComponent":362,"./TagMode":365,"./error/GeometryTagError":369,"./geometry/PointGeometry":371,"./geometry/PointsGeometry":372,"./geometry/PolygonGeometry":373,"./geometry/RectGeometry":374,"./tag/ExtremePointTag":388,"./tag/OutlineTag":392,"./tag/SpotTag":395,"./tag/TagDomain":397}],362:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -29950,6 +39117,7 @@ var TagComponent = /** @class */ (function (_super) { _this._viewportCoords = new Geo_1.ViewportCoords(); _this._createHandlers = { "CreatePoint": new Component_1.CreatePointHandler(_this, container, navigator, _this._viewportCoords, _this._tagCreator), + "CreatePoints": new Component_1.CreatePointsHandler(_this, container, navigator, _this._viewportCoords, _this._tagCreator), "CreatePolygon": new Component_1.CreatePolygonHandler(_this, container, navigator, _this._viewportCoords, _this._tagCreator), "CreateRect": new Component_1.CreateRectHandler(_this, container, navigator, _this._viewportCoords, _this._tagCreator), "CreateRectDrag": new Component_1.CreateRectDragHandler(_this, container, navigator, _this._viewportCoords, _this._tagCreator), @@ -30035,6 +39203,70 @@ var TagComponent = /** @class */ (function (_super) { this._tagSet.addDeactivated(tags); } }; + /** + * Calculate the smallest rectangle containing all the points + * in the points geometry. + * + * @description The result may be different depending on if the + * current node is an equirectangular panorama or not. If the + * current node is an equirectangular panorama the rectangle may + * wrap the horizontal border of the image. + * + * @returns {Promise>} Promise to the rectangle + * on the format specified for the {@link RectGeometry} in basic + * coordinates. + */ + TagComponent.prototype.calculateRect = function (geometry) { + var _this = this; + return when.promise(function (resolve, reject) { + _this._navigator.stateService.currentTransform$.pipe(operators_1.first(), operators_1.map(function (transform) { + return geometry.getRect2d(transform); + })) + .subscribe(function (rect) { + resolve(rect); + }, function (error) { + reject(error); + }); + }); + }; + /** + * Force the creation of a geometry programatically using its + * current vertices. + * + * @description The method only has an effect when the tag + * mode is either of the following modes: + * + * TagMode.CreatePoints + * TagMode.CreatePolygon + * TagMode.CreateRect + * TagMode.CreateRectDrag + * + * In the case of points or polygon creation, only the created + * vertices are used, i.e. the mouse position is disregarded. + * + * In the case of rectangle creation the position of the mouse + * at the time of the method call is used as one of the vertices + * defining the rectangle. + * + * @fires TagComponent.geometrycreated + * + * @example + * ``` + * tagComponent.on("geometrycreated", function(geometry) { + * console.log(geometry); + * }); + * + * tagComponent.create(); + * ``` + */ + TagComponent.prototype.create = function () { + this._tagCreator.replayedTag$.pipe(operators_1.first(), operators_1.filter(function (tag) { + return !!tag; + })) + .subscribe(function (tag) { + tag.create(); + }); + }; /** * Change the current tag mode. * @@ -30091,7 +39323,8 @@ var TagComponent = /** @class */ (function (_super) { * tags that do not have a fill will also be returned if the point is inside * the geometry of the tag. Tags with point geometries can not be retrieved. * - * No tag ids will be returned for panoramas. + * No tag ids will be returned for polygons rendered in cropped panoramas or + * rectangles rendered in panoramas. * * Notice that the pixelPoint argument requires x, y coordinates from pixel space. * @@ -30101,7 +39334,8 @@ var TagComponent = /** @class */ (function (_super) { * If no tag at exist the pixel point, an empty array will be returned. * * @param {Array} pixelPoint - Pixel coordinates on the viewer element. - * @returns {Array} Ids of the tags that contain the specified pixel point. + * @returns {Promise>} Promise to the ids of the tags that + * contain the specified pixel point. * * @example * ``` @@ -30202,12 +39436,12 @@ var TagComponent = /** @class */ (function (_super) { } }); this._fireTagsChangedSubscription = this._renderTags$ - .subscribe(function (tags) { + .subscribe(function () { _this.fire(TagComponent.tagschanged, _this); }); this._stopCreateSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) { return tag != null ? - tag.aborted$.pipe(operators_1.map(function (t) { return null; })) : + tag.aborted$.pipe(operators_1.map(function () { return null; })) : rxjs_1.empty(); })) .subscribe(function () { _this.changeMode(Component_1.TagMode.Default); }); @@ -30229,16 +39463,16 @@ var TagComponent = /** @class */ (function (_super) { _this._tagScene.updateObjects(tag); }); this._updateTagSceneSubscription = this._tagChanged$ - .subscribe(function (tag) { + .subscribe(function () { _this._tagScene.update(); }); - this._domSubscription = rxjs_1.combineLatest(this._renderTags$.pipe(operators_1.startWith([]), operators_1.tap(function (tags) { + this._domSubscription = rxjs_1.combineLatest(this._renderTags$.pipe(operators_1.startWith([]), operators_1.tap(function () { _this._container.domRenderer.render$.next({ name: _this._name, vnode: _this._tagDomRenderer.clear(), }); })), this._container.renderService.renderCamera$, this._container.spriteService.spriteAtlas$, this._container.renderService.size$, this._tagChanged$.pipe(operators_1.startWith(null)), rxjs_1.merge(this._tagCreator.tag$, this._createGeometryChanged$).pipe(operators_1.startWith(null))).pipe(operators_1.map(function (_a) { - var renderTags = _a[0], rc = _a[1], atlas = _a[2], size = _a[3], tag = _a[4], ct = _a[5]; + var renderTags = _a[0], rc = _a[1], atlas = _a[2], size = _a[3], ct = _a[5]; return { name: _this._name, vnode: _this._tagDomRenderer.render(renderTags, ct, atlas, rc.perspective, size), @@ -30287,6 +39521,7 @@ var TagComponent = /** @class */ (function (_super) { TagComponent.prototype._getDefaultConfiguration = function () { return { createColor: 0xFFFFFF, + indicatePointsCompleter: true, mode: Component_1.TagMode.Default, }; }; @@ -30381,7 +39616,7 @@ exports.TagComponent = TagComponent; Component_1.ComponentService.register(TagComponent); exports.default = TagComponent; -},{"../../Component":274,"../../Geo":277,"../../Render":280,"rxjs":26,"rxjs/operators":224,"when":271}],344:[function(require,module,exports){ +},{"../../Component":291,"../../Geo":294,"../../Render":297,"rxjs":43,"rxjs/operators":241,"when":288}],363:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var operators_1 = require("rxjs/operators"); @@ -30392,15 +39627,32 @@ var TagCreator = /** @class */ (function () { this._component = component; this._navigator = navigator; this._tagOperation$ = new rxjs_1.Subject(); + this._createPoints$ = new rxjs_1.Subject(); this._createPolygon$ = new rxjs_1.Subject(); this._createRect$ = new rxjs_1.Subject(); this._delete$ = new rxjs_1.Subject(); this._tag$ = this._tagOperation$.pipe(operators_1.scan(function (tag, operation) { return operation(tag); }, null), operators_1.share()); + this._replayedTag$ = this._tag$.pipe(operators_1.publishReplay(1), operators_1.refCount()); + this._replayedTag$.subscribe(); + this._createPoints$.pipe(operators_1.withLatestFrom(this._component.configuration$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) { + var coord = _a[0], conf = _a[1], transform = _a[2]; + return function () { + var geometry = new Component_1.PointsGeometry([ + [coord[0], coord[1]], + [coord[0], coord[1]], + ]); + return new Component_1.ExtremePointCreateTag(geometry, { + color: conf.createColor, + indicateCompleter: conf.indicatePointsCompleter, + }, transform); + }; + })) + .subscribe(this._tagOperation$); this._createRect$.pipe(operators_1.withLatestFrom(this._component.configuration$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) { var coord = _a[0], conf = _a[1], transform = _a[2]; - return function (tag) { + return function () { var geometry = new Component_1.RectGeometry([ coord[0], coord[1], @@ -30413,7 +39665,7 @@ var TagCreator = /** @class */ (function () { .subscribe(this._tagOperation$); this._createPolygon$.pipe(operators_1.withLatestFrom(this._component.configuration$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) { var coord = _a[0], conf = _a[1], transform = _a[2]; - return function (tag) { + return function () { var geometry = new Component_1.PolygonGeometry([ [coord[0], coord[1]], [coord[0], coord[1]], @@ -30424,7 +39676,7 @@ var TagCreator = /** @class */ (function () { })) .subscribe(this._tagOperation$); this._delete$.pipe(operators_1.map(function () { - return function (tag) { + return function () { return null; }; })) @@ -30444,6 +39696,13 @@ var TagCreator = /** @class */ (function () { enumerable: true, configurable: true }); + Object.defineProperty(TagCreator.prototype, "createPoints$", { + get: function () { + return this._createPoints$; + }, + enumerable: true, + configurable: true + }); Object.defineProperty(TagCreator.prototype, "delete$", { get: function () { return this._delete$; @@ -30458,12 +39717,19 @@ var TagCreator = /** @class */ (function () { enumerable: true, configurable: true }); + Object.defineProperty(TagCreator.prototype, "replayedTag$", { + get: function () { + return this._replayedTag$; + }, + enumerable: true, + configurable: true + }); return TagCreator; }()); exports.TagCreator = TagCreator; exports.default = TagCreator; -},{"../../Component":274,"rxjs":26,"rxjs/operators":224}],345:[function(require,module,exports){ +},{"../../Component":291,"rxjs":43,"rxjs/operators":241}],364:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var vd = require("virtual-dom"); @@ -30488,7 +39754,7 @@ var TagDOMRenderer = /** @class */ (function () { }()); exports.TagDOMRenderer = TagDOMRenderer; -},{"virtual-dom":230}],346:[function(require,module,exports){ +},{"virtual-dom":247}],365:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** @@ -30507,25 +39773,29 @@ var TagMode; * Create a point geometry through a click. */ TagMode[TagMode["CreatePoint"] = 1] = "CreatePoint"; + /** + * Create a points geometry through clicks. + */ + TagMode[TagMode["CreatePoints"] = 2] = "CreatePoints"; /** * Create a polygon geometry through clicks. */ - TagMode[TagMode["CreatePolygon"] = 2] = "CreatePolygon"; + TagMode[TagMode["CreatePolygon"] = 3] = "CreatePolygon"; /** * Create a rect geometry through clicks. */ - TagMode[TagMode["CreateRect"] = 3] = "CreateRect"; + TagMode[TagMode["CreateRect"] = 4] = "CreateRect"; /** * Create a rect geometry through drag. * * @description Claims the mouse which results in mouse handlers like * drag pan and scroll zoom becoming inactive. */ - TagMode[TagMode["CreateRectDrag"] = 4] = "CreateRectDrag"; + TagMode[TagMode["CreateRectDrag"] = 5] = "CreateRectDrag"; })(TagMode = exports.TagMode || (exports.TagMode = {})); exports.default = TagMode; -},{}],347:[function(require,module,exports){ +},{}],366:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var TagOperation; @@ -30536,7 +39806,7 @@ var TagOperation; })(TagOperation = exports.TagOperation || (exports.TagOperation = {})); exports.default = TagOperation; -},{}],348:[function(require,module,exports){ +},{}],367:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var THREE = require("three"); @@ -30703,11 +39973,13 @@ var TagScene = /** @class */ (function () { exports.TagScene = TagScene; exports.default = TagScene; -},{"three":225}],349:[function(require,module,exports){ +},{"three":242}],368:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var rxjs_1 = require("rxjs"); var Component_1 = require("../../Component"); +var ExtremePointTag_1 = require("./tag/ExtremePointTag"); +var ExtremePointRenderTag_1 = require("./tag/ExtremePointRenderTag"); var TagSet = /** @class */ (function () { function TagSet() { this._active = false; @@ -30769,7 +40041,9 @@ var TagSet = /** @class */ (function () { this._assertActivationState(false); for (var _i = 0, tags_2 = tags; _i < tags_2.length; _i++) { var tag = tags_2[_i]; - if (!(tag instanceof Component_1.OutlineTag || tag instanceof Component_1.SpotTag)) { + if (!(tag instanceof Component_1.OutlineTag || + tag instanceof Component_1.SpotTag || + tag instanceof ExtremePointTag_1.default)) { throw new Error("Tag type not supported"); } this._hashDeactivated[tag.id] = tag; @@ -30840,6 +40114,9 @@ var TagSet = /** @class */ (function () { else if (tag instanceof Component_1.SpotTag) { this._hash[tag.id] = new Component_1.SpotRenderTag(tag, transform); } + else if (tag instanceof ExtremePointTag_1.default) { + this._hash[tag.id] = new ExtremePointRenderTag_1.default(tag, transform); + } else { throw new Error("Tag type not supported"); } @@ -30854,7 +40131,7 @@ var TagSet = /** @class */ (function () { exports.TagSet = TagSet; exports.default = TagSet; -},{"../../Component":274,"rxjs":26}],350:[function(require,module,exports){ +},{"../../Component":291,"./tag/ExtremePointRenderTag":387,"./tag/ExtremePointTag":388,"rxjs":43}],369:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -30875,6 +40152,7 @@ var GeometryTagError = /** @class */ (function (_super) { __extends(GeometryTagError, _super); function GeometryTagError(message) { var _this = _super.call(this, message != null ? message : "The provided geometry value is incorrect") || this; + Object.setPrototypeOf(_this, GeometryTagError.prototype); _this.name = "GeometryTagError"; return _this; } @@ -30883,7 +40161,7 @@ var GeometryTagError = /** @class */ (function (_super) { exports.GeometryTagError = GeometryTagError; exports.default = Error_1.MapillaryError; -},{"../../../Error":276}],351:[function(require,module,exports){ +},{"../../../Error":293}],370:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var rxjs_1 = require("rxjs"); @@ -30923,7 +40201,7 @@ var Geometry = /** @class */ (function () { exports.Geometry = Geometry; exports.default = Geometry; -},{"rxjs":26}],352:[function(require,module,exports){ +},{"rxjs":43}],371:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -31023,8 +40301,224 @@ var PointGeometry = /** @class */ (function (_super) { return PointGeometry; }(Component_1.Geometry)); exports.PointGeometry = PointGeometry; +exports.default = PointGeometry; -},{"../../../Component":274}],353:[function(require,module,exports){ +},{"../../../Component":291}],372:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var Component_1 = require("../../../Component"); +/** + * @class PointsGeometry + * + * @classdesc Represents a point set in the 2D basic image coordinate system. + * + * @example + * ``` + * var points = [[0.5, 0.3], [0.7, 0.3], [0.6, 0.5]]; + * var pointsGeometry = new Mapillary.TagComponent.PointsGeometry(points); + * ``` + */ +var PointsGeometry = /** @class */ (function (_super) { + __extends(PointsGeometry, _super); + /** + * Create a points geometry. + * + * @constructor + * @param {Array>} points - Array of 2D points on the basic coordinate + * system. The number of points must be greater than or equal to two. + * + * @throws {GeometryTagError} Point coordinates must be valid basic coordinates. + */ + function PointsGeometry(points) { + var _this = _super.call(this) || this; + var pointsLength = points.length; + if (pointsLength < 2) { + throw new Component_1.GeometryTagError("A points geometry must have two or more positions."); + } + _this._points = []; + for (var _i = 0, points_1 = points; _i < points_1.length; _i++) { + var point = points_1[_i]; + if (point[0] < 0 || point[0] > 1 || + point[1] < 0 || point[1] > 1) { + throw new Component_1.GeometryTagError("Basic coordinates of points must be on the interval [0, 1]."); + } + _this._points.push(point.slice()); + } + return _this; + } + Object.defineProperty(PointsGeometry.prototype, "points", { + /** + * Get points property. + * @returns {Array>} Array of 2d points. + */ + get: function () { + return this._points; + }, + enumerable: true, + configurable: true + }); + /** + * Add a point to the point set. + * + * @param {Array} point - Point to add. + * @ignore + */ + PointsGeometry.prototype.addPoint2d = function (point) { + var clamped = [ + Math.max(0, Math.min(1, point[0])), + Math.max(0, Math.min(1, point[1])), + ]; + this._points.push(clamped); + this._notifyChanged$.next(this); + }; + /** + * Get the coordinates of a point from the point set representation of the geometry. + * + * @param {number} index - Point index. + * @returns {Array} Array representing the 2D basic coordinates of the point. + * @ignore + */ + PointsGeometry.prototype.getPoint2d = function (index) { + return this._points[index].slice(); + }; + /** + * Remove a point from the point set. + * + * @param {number} index - The index of the point to remove. + * @ignore + */ + PointsGeometry.prototype.removePoint2d = function (index) { + if (index < 0 || + index >= this._points.length || + this._points.length < 3) { + throw new Component_1.GeometryTagError("Index for removed point must be valid."); + } + this._points.splice(index, 1); + this._notifyChanged$.next(this); + }; + /** @ignore */ + PointsGeometry.prototype.setVertex2d = function (index, value, transform) { + this.setPoint2d(index, value, transform); + }; + /** @ignore */ + PointsGeometry.prototype.setPoint2d = function (index, value, transform) { + var changed = [ + Math.max(0, Math.min(1, value[0])), + Math.max(0, Math.min(1, value[1])), + ]; + this._points[index] = changed; + this._notifyChanged$.next(this); + }; + /** @ignore */ + PointsGeometry.prototype.getPoints3d = function (transform) { + return this._getPoints3d(this._points, transform); + }; + /** @ignore */ + PointsGeometry.prototype.getPoint3d = function (index, transform) { + return transform.unprojectBasic(this._points[index], 200); + }; + /** @ignore */ + PointsGeometry.prototype.getPoints2d = function () { + return this._points.slice(); + }; + /** @ignore */ + PointsGeometry.prototype.getCentroid2d = function (transform) { + if (!transform) { + throw new Component_1.GeometryTagError("Get centroid must be called with a transform for points geometries."); + } + var _a = this.getRect2d(transform), minX = _a[0], minY = _a[1], maxX = _a[2], maxY = _a[3]; + var centroidX = minX < maxX ? + (minX + maxX) / 2 : + ((minX + maxX + 1) / 2) % 1; + var centroidY = (minY + maxY) / 2; + return [centroidX, centroidY]; + }; + /** @ignore */ + PointsGeometry.prototype.getCentroid3d = function (transform) { + var centroid2d = this.getCentroid2d(); + return transform.unprojectBasic(centroid2d, 200); + }; + /** @ignore */ + PointsGeometry.prototype.getRect2d = function (transform) { + var minX = 1; + var maxX = 0; + var minY = 1; + var maxY = 0; + var points = this._points; + for (var _i = 0, points_2 = points; _i < points_2.length; _i++) { + var point = points_2[_i]; + if (point[0] < minX) { + minX = point[0]; + } + if (point[0] > maxX) { + maxX = point[0]; + } + if (point[1] < minY) { + minY = point[1]; + } + if (point[1] > maxY) { + maxY = point[1]; + } + } + if (transform.fullPano) { + var indices = []; + for (var i = 0; i < points.length; i++) { + indices[i] = i; + } + indices.sort(function (a, b) { + return points[a][0] < points[b][0] ? + -1 : + points[a][0] > points[b][0] ? + 1 : + a < b ? -1 : 1; + }); + var maxDistanceX = points[indices[0]][0] + 1 - points[indices[indices.length - 1]][0]; + var leftMostIndex = 0; + for (var i = 0; i < indices.length - 1; i++) { + var index1 = indices[i]; + var index2 = indices[i + 1]; + var distanceX = points[index2][0] - points[index1][0]; + if (distanceX > maxDistanceX) { + maxDistanceX = distanceX; + leftMostIndex = i + 1; + } + } + if (leftMostIndex > 0) { + minX = points[indices[leftMostIndex]][0]; + maxX = points[indices[leftMostIndex - 1]][0]; + } + } + return [minX, minY, maxX, maxY]; + }; + /** @ignore */ + PointsGeometry.prototype.setCentroid2d = function (value, transform) { + throw new Error("Not implemented"); + }; + PointsGeometry.prototype._getPoints3d = function (points2d, transform) { + return points2d + .map(function (point) { + return transform.unprojectBasic(point, 200); + }); + }; + return PointsGeometry; +}(Component_1.Geometry)); +exports.PointsGeometry = PointsGeometry; +exports.default = PointsGeometry; + +},{"../../../Component":291}],373:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -31067,7 +40561,6 @@ var PolygonGeometry = /** @class */ (function (_super) { */ function PolygonGeometry(polygon, holes) { var _this = _super.call(this) || this; - _this._subsampleThreshold = 0.01; var polygonLength = polygon.length; if (polygonLength < 3) { throw new Component_1.GeometryTagError("A polygon must have three or more positions."); @@ -31150,9 +40643,6 @@ var PolygonGeometry = /** @class */ (function (_super) { /** * Get the coordinates of a vertex from the polygon representation of the geometry. * - * @description The first vertex represents the bottom-left corner with the rest of - * the vertices following in clockwise order. - * * @param {number} index - Vertex index. * @returns {Array} Array representing the 2D basic coordinates of the vertex. * @ignore @@ -31222,7 +40712,7 @@ var PolygonGeometry = /** @class */ (function (_super) { }; /** @ignore */ PolygonGeometry.prototype.getPoints3d = function (transform) { - return this._getPoints3d(this._subsample(this._polygon, this._subsampleThreshold), transform); + return this._getPoints3d(this._subsample(this._polygon), transform); }; /** @ignore */ PolygonGeometry.prototype.getVertex3d = function (index, transform) { @@ -31250,7 +40740,7 @@ var PolygonGeometry = /** @class */ (function (_super) { var _this = this; return this._holes .map(function (hole2d) { - return _this._getPoints3d(_this._subsample(hole2d, _this._subsampleThreshold), transform); + return _this._getPoints3d(_this._subsample(hole2d), transform); }); }; /** @@ -31306,12 +40796,14 @@ var PolygonGeometry = /** @class */ (function (_super) { /** @ignore */ PolygonGeometry.prototype.getTriangles3d = function (transform) { var _this = this; - var threshold = this._subsampleThreshold; - var points2d = this._project(this._subsample(this._polygon, threshold), transform); + if (transform.fullPano) { + return this._triangulatePano(this._polygon.slice(), this.holes.slice(), transform); + } + var points2d = this._project(this._subsample(this._polygon), transform); var points3d = this.getPoints3d(transform); var holes2d = this._holes .map(function (hole) { - return _this._project(_this._subsample(hole, threshold), transform); + return _this._project(_this._subsample(hole), transform); }); var holes3d = this.getHolePoints3d(transform); return this._triangulate(points2d, points3d, holes2d, holes3d); @@ -31331,33 +40823,12 @@ var PolygonGeometry = /** @class */ (function (_super) { return transform.unprojectBasic(point, 200); }); }; - PolygonGeometry.prototype._subsample = function (points2d, threshold) { - var subsampled = []; - var length = points2d.length; - for (var index = 0; index < length; index++) { - var p1 = points2d[index]; - var p2 = points2d[(index + 1) % length]; - subsampled.push(p1); - var dist = Math.sqrt(Math.pow((p2[0] - p1[0]), 2) + Math.pow((p2[1] - p1[1]), 2)); - var subsamples = Math.floor(dist / threshold); - var coeff = 1 / (subsamples + 1); - for (var i = 1; i <= subsamples; i++) { - var alpha = i * coeff; - var subsample = [ - (1 - alpha) * p1[0] + alpha * p2[0], - (1 - alpha) * p1[1] + alpha * p2[1], - ]; - subsampled.push(subsample); - } - } - return subsampled; - }; return PolygonGeometry; }(Component_1.VertexGeometry)); exports.PolygonGeometry = PolygonGeometry; exports.default = PolygonGeometry; -},{"../../../Component":274}],354:[function(require,module,exports){ +},{"../../../Component":291}],374:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -31920,7 +41391,9 @@ var RectGeometry = /** @class */ (function (_super) { }; /** @ignore */ RectGeometry.prototype.getTriangles3d = function (transform) { - return this._triangulate(this._project(this._getPoints2d(), transform), this.getPoints3d(transform)); + return transform.fullPano ? + [] : + this._triangulate(this._project(this._getPoints2d(), transform), this.getPoints3d(transform)); }; /** * Check if a particular bottom-right value is valid according to the current @@ -32019,7 +41492,7 @@ var RectGeometry = /** @class */ (function (_super) { exports.RectGeometry = RectGeometry; exports.default = RectGeometry; -},{"../../../Component":274}],355:[function(require,module,exports){ +},{"../../../Component":291}],375:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -32036,6 +41509,7 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); var earcut_1 = require("earcut"); +var martinez = require("martinez-polygon-clipping"); var polylabel = require("@mapbox/polylabel"); var THREE = require("three"); var Component_1 = require("../../../Component"); @@ -32053,7 +41527,9 @@ var VertexGeometry = /** @class */ (function (_super) { * @ignore */ function VertexGeometry() { - return _super.call(this) || this; + var _this = _super.call(this) || this; + _this._subsampleThreshold = 0.005; + return _this; } /** * Finds the polygon pole of inaccessibility, the most distant internal @@ -32067,6 +41543,32 @@ var VertexGeometry = /** @class */ (function (_super) { var pole2d = polylabel([points2d], 3e-2); return pole2d; }; + VertexGeometry.prototype._project = function (points2d, transform) { + var camera = this._createCamera(transform.upVector().toArray(), transform.unprojectSfM([0, 0], 0), transform.unprojectSfM([0, 0], 10)); + return this._deunproject(points2d, transform, camera); + }; + VertexGeometry.prototype._subsample = function (points2d, threshold) { + if (threshold === void 0) { threshold = this._subsampleThreshold; } + var subsampled = []; + var length = points2d.length; + for (var index = 0; index < length; index++) { + var p1 = points2d[index]; + var p2 = points2d[(index + 1) % length]; + subsampled.push(p1); + var dist = Math.sqrt(Math.pow((p2[0] - p1[0]), 2) + Math.pow((p2[1] - p1[1]), 2)); + var subsamples = Math.floor(dist / threshold); + var coeff = 1 / (subsamples + 1); + for (var i = 1; i <= subsamples; i++) { + var alpha = i * coeff; + var subsample = [ + (1 - alpha) * p1[0] + alpha * p2[0], + (1 - alpha) * p1[1] + alpha * p2[1], + ]; + subsampled.push(subsample); + } + } + return subsampled; + }; /** * Triangulates a 2d polygon and returns the triangle * representation as a flattened array of 3d points. @@ -32100,28 +41602,92 @@ var VertexGeometry = /** @class */ (function (_super) { } return triangles; }; - VertexGeometry.prototype._project = function (points2d, transform) { + VertexGeometry.prototype._triangulatePano = function (points2d, holes2d, transform) { + var triangles = []; + var epsilon = 1e-9; + var subareasX = 3; + var subareasY = 3; + for (var x = 0; x < subareasX; x++) { + for (var y = 0; y < subareasY; y++) { + var epsilonX0 = x === 0 ? -epsilon : epsilon; + var epsilonY0 = y === 0 ? -epsilon : epsilon; + var x0 = x / subareasX + epsilonX0; + var y0 = y / subareasY + epsilonY0; + var x1 = (x + 1) / subareasX + epsilon; + var y1 = (y + 1) / subareasY + epsilon; + var bbox2d = [ + [x0, y0], + [x0, y1], + [x1, y1], + [x1, y0], + [x0, y0], + ]; + var lookat2d = [ + (2 * x + 1) / (2 * subareasX), + (2 * y + 1) / (2 * subareasY), + ]; + triangles.push.apply(triangles, this._triangulateSubarea(points2d, holes2d, bbox2d, lookat2d, transform)); + } + } + return triangles; + }; + VertexGeometry.prototype._unproject = function (points2d, transform, distance) { + if (distance === void 0) { distance = 200; } + return points2d + .map(function (point) { + return transform.unprojectBasic(point, distance); + }); + }; + VertexGeometry.prototype._createCamera = function (upVector, position, lookAt) { var camera = new THREE.Camera(); - camera.up.copy(transform.upVector()); - camera.position.copy(new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 0))); - camera.lookAt(new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 10))); + camera.up.copy(new THREE.Vector3().fromArray(upVector)); + camera.position.copy(new THREE.Vector3().fromArray(position)); + camera.lookAt(new THREE.Vector3().fromArray(lookAt)); camera.updateMatrix(); camera.updateMatrixWorld(true); - var projected = points2d + return camera; + }; + VertexGeometry.prototype._deunproject = function (points2d, transform, camera) { + return points2d .map(function (point2d) { var pointWorld = transform.unprojectBasic(point2d, 10000); var pointCamera = new THREE.Vector3(pointWorld[0], pointWorld[1], pointWorld[2]) .applyMatrix4(camera.matrixWorldInverse); return [pointCamera.x / pointCamera.z, pointCamera.y / pointCamera.z]; }); - return projected; + }; + VertexGeometry.prototype._triangulateSubarea = function (points2d, holes2d, bbox2d, lookat2d, transform) { + var intersections = martinez.intersection([points2d].concat(holes2d), [bbox2d]); + if (!intersections) { + return []; + } + var triangles = []; + var threshold = this._subsampleThreshold; + var camera = this._createCamera(transform.upVector().toArray(), transform.unprojectSfM([0, 0], 0), transform.unprojectBasic(lookat2d, 10)); + for (var _i = 0, intersections_1 = intersections; _i < intersections_1.length; _i++) { + var intersection = intersections_1[_i]; + var subsampledPolygon2d = this._subsample(intersection[0], threshold); + var polygon2d = this._deunproject(subsampledPolygon2d, transform, camera); + var polygon3d = this._unproject(subsampledPolygon2d, transform); + var polygonHoles2d = []; + var polygonHoles3d = []; + for (var i = 1; i < intersection.length; i++) { + var subsampledHole2d = this._subsample(intersection[i], threshold); + var hole2d = this._deunproject(subsampledHole2d, transform, camera); + var hole3d = this._unproject(subsampledHole2d, transform); + polygonHoles2d.push(hole2d); + polygonHoles3d.push(hole3d); + } + triangles.push.apply(triangles, this._triangulate(polygon2d, polygon3d, polygonHoles2d, polygonHoles3d)); + } + return triangles; }; return VertexGeometry; }(Component_1.Geometry)); exports.VertexGeometry = VertexGeometry; exports.default = VertexGeometry; -},{"../../../Component":274,"@mapbox/polylabel":1,"earcut":8,"three":225}],356:[function(require,module,exports){ +},{"../../../Component":291,"@mapbox/polylabel":1,"earcut":8,"martinez-polygon-clipping":22,"three":242}],376:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -32180,7 +41746,7 @@ var CreateHandlerBase = /** @class */ (function (_super) { exports.CreateHandlerBase = CreateHandlerBase; exports.default = CreateHandlerBase; -},{"../../../Component":274,"rxjs":26,"rxjs/operators":224}],357:[function(require,module,exports){ +},{"../../../Component":291,"rxjs":43,"rxjs/operators":241}],377:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -32222,7 +41788,50 @@ var CreatePointHandler = /** @class */ (function (_super) { exports.CreatePointHandler = CreatePointHandler; exports.default = CreatePointHandler; -},{"../../../Component":274,"rxjs/operators":224}],358:[function(require,module,exports){ +},{"../../../Component":291,"rxjs/operators":241}],378:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var Component_1 = require("../../../Component"); +var CreatePointsHandler = /** @class */ (function (_super) { + __extends(CreatePointsHandler, _super); + function CreatePointsHandler() { + return _super !== null && _super.apply(this, arguments) || this; + } + CreatePointsHandler.prototype._addPoint = function (tag, basicPoint) { + tag.geometry.addPoint2d(basicPoint); + }; + Object.defineProperty(CreatePointsHandler.prototype, "_create$", { + get: function () { + return this._tagCreator.createPoints$; + }, + enumerable: true, + configurable: true + }); + CreatePointsHandler.prototype._getNameExtension = function () { + return "create-points"; + }; + CreatePointsHandler.prototype._setVertex2d = function (tag, basicPoint, transform) { + tag.geometry.setPoint2d((tag.geometry).points.length - 1, basicPoint, transform); + }; + return CreatePointsHandler; +}(Component_1.CreateVertexHandler)); +exports.CreatePointsHandler = CreatePointsHandler; +exports.default = CreatePointsHandler; + +},{"../../../Component":291}],379:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -32265,7 +41874,7 @@ var CreatePolygonHandler = /** @class */ (function (_super) { exports.CreatePolygonHandler = CreatePolygonHandler; exports.default = CreatePolygonHandler; -},{"../../../Component":274}],359:[function(require,module,exports){ +},{"../../../Component":291}],380:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -32358,7 +41967,7 @@ var CreateRectDragHandler = /** @class */ (function (_super) { exports.CreateRectDragHandler = CreateRectDragHandler; exports.default = CreateRectDragHandler; -},{"../../../Component":274,"rxjs":26,"rxjs/operators":224}],360:[function(require,module,exports){ +},{"../../../Component":291,"rxjs":43,"rxjs/operators":241}],381:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -32419,7 +42028,7 @@ var CreateRectHandler = /** @class */ (function (_super) { exports.CreateRectHandler = CreateRectHandler; exports.default = CreateRectHandler; -},{"../../../Component":274,"rxjs/operators":224}],361:[function(require,module,exports){ +},{"../../../Component":291,"rxjs/operators":241}],382:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -32446,7 +42055,7 @@ var CreateVertexHandler = /** @class */ (function (_super) { CreateVertexHandler.prototype._enableCreate = function () { var _this = this; this._container.mouseService.deferPixels(this._name, 4); - var transformChanged$ = this._navigator.stateService.currentTransform$.pipe(operators_1.map(function (transform) { }), operators_1.publishReplay(1), operators_1.refCount()); + var transformChanged$ = this._navigator.stateService.currentTransform$.pipe(operators_1.map(function () { }), operators_1.publishReplay(1), operators_1.refCount()); this._deleteSubscription = transformChanged$.pipe(operators_1.skip(1)) .subscribe(this._tagCreator.delete$); var basicClick$ = this._mouseEventToBasic$(this._container.mouseService.proximateClick$).pipe(operators_1.share()); @@ -32496,7 +42105,7 @@ var CreateVertexHandler = /** @class */ (function (_super) { exports.CreateVertexHandler = CreateVertexHandler; exports.default = CreateVertexHandler; -},{"../../../Component":274,"rxjs":26,"rxjs/operators":224}],362:[function(require,module,exports){ +},{"../../../Component":291,"rxjs":43,"rxjs/operators":241}],383:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -32609,7 +42218,7 @@ exports.EditVertexHandler = EditVertexHandler; exports.default = EditVertexHandler; -},{"../../../Component":274,"rxjs":26,"rxjs/operators":224}],363:[function(require,module,exports){ +},{"../../../Component":291,"rxjs":43,"rxjs/operators":241}],384:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -32650,84 +42259,678 @@ exports.TagHandlerBase = TagHandlerBase; exports.default = TagHandlerBase; -},{"../../../Component":274}],364:[function(require,module,exports){ +},{"../../../Component":291}],385:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var operators_1 = require("rxjs/operators"); var THREE = require("three"); -var vd = require("virtual-dom"); var rxjs_1 = require("rxjs"); -var Component_1 = require("../../../Component"); var Geo_1 = require("../../../Geo"); -var OutlineCreateTag = /** @class */ (function () { - function OutlineCreateTag(geometry, options, transform, viewportCoords) { +var CreateTag = /** @class */ (function () { + function CreateTag(geometry, transform, viewportCoords) { var _this = this; this._geometry = geometry; - this._options = { color: options.color == null ? 0xFFFFFF : options.color }; this._transform = transform; this._viewportCoords = !!viewportCoords ? viewportCoords : new Geo_1.ViewportCoords(); - this._outline = this._createOutine(); - this._glObjects = [this._outline]; this._aborted$ = new rxjs_1.Subject(); this._created$ = new rxjs_1.Subject(); this._glObjectsChanged$ = new rxjs_1.Subject(); this._geometryChangedSubscription = this._geometry.changed$ - .subscribe(function (vertexGeometry) { - _this._disposeOutline(); - _this._outline = _this._createOutine(); - _this._glObjects = [_this._outline]; + .subscribe(function () { + _this._onGeometryChanged(); _this._glObjectsChanged$.next(_this); }); } - Object.defineProperty(OutlineCreateTag.prototype, "geometry", { + Object.defineProperty(CreateTag.prototype, "geometry", { get: function () { return this._geometry; }, enumerable: true, configurable: true }); - Object.defineProperty(OutlineCreateTag.prototype, "glObjects", { + Object.defineProperty(CreateTag.prototype, "glObjects", { get: function () { return this._glObjects; }, enumerable: true, configurable: true }); - Object.defineProperty(OutlineCreateTag.prototype, "aborted$", { + Object.defineProperty(CreateTag.prototype, "aborted$", { get: function () { return this._aborted$; }, enumerable: true, configurable: true }); - Object.defineProperty(OutlineCreateTag.prototype, "created$", { + Object.defineProperty(CreateTag.prototype, "created$", { get: function () { return this._created$; }, enumerable: true, configurable: true }); - Object.defineProperty(OutlineCreateTag.prototype, "glObjectsChanged$", { + Object.defineProperty(CreateTag.prototype, "glObjectsChanged$", { get: function () { return this._glObjectsChanged$; }, enumerable: true, configurable: true }); - Object.defineProperty(OutlineCreateTag.prototype, "geometryChanged$", { + Object.defineProperty(CreateTag.prototype, "geometryChanged$", { get: function () { var _this = this; - return this._geometry.changed$.pipe(operators_1.map(function (geometry) { + return this._geometry.changed$.pipe(operators_1.map(function () { return _this; })); }, enumerable: true, configurable: true }); - OutlineCreateTag.prototype.dispose = function () { - this._disposeOutline(); + CreateTag.prototype.dispose = function () { this._geometryChangedSubscription.unsubscribe(); }; + CreateTag.prototype._canvasToTransform = function (canvas) { + var canvasX = Math.round(canvas[0]); + var canvasY = Math.round(canvas[1]); + var transform = "translate(-50%,-50%) translate(" + canvasX + "px," + canvasY + "px)"; + return transform; + }; + CreateTag.prototype._colorToBackground = function (color) { + return "#" + ("000000" + color.toString(16)).substr(-6); + }; + CreateTag.prototype._createOutine = function (polygon3d, color) { + var positions = this._getLinePositions(polygon3d); + var geometry = new THREE.BufferGeometry(); + geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3)); + var material = new THREE.LineBasicMaterial({ + color: color, + linewidth: 1, + }); + return new THREE.Line(geometry, material); + }; + CreateTag.prototype._disposeLine = function (line) { + if (line == null) { + return; + } + line.geometry.dispose(); + line.material.dispose(); + }; + CreateTag.prototype._getLinePositions = function (polygon3d) { + var length = polygon3d.length; + var positions = new Float32Array(length * 3); + for (var i = 0; i < length; ++i) { + var index = 3 * i; + var position = polygon3d[i]; + positions[index] = position[0]; + positions[index + 1] = position[1]; + positions[index + 2] = position[2]; + } + return positions; + }; + return CreateTag; +}()); +exports.CreateTag = CreateTag; +exports.default = CreateTag; + +},{"../../../Geo":294,"rxjs":43,"rxjs/operators":241,"three":242}],386:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var vd = require("virtual-dom"); +var Tag_1 = require("../Tag"); +var Component_1 = require("../../../Component"); +var ExtremePointCreateTag = /** @class */ (function (_super) { + __extends(ExtremePointCreateTag, _super); + function ExtremePointCreateTag(geometry, options, transform, viewportCoords) { + var _this = _super.call(this, geometry, transform, viewportCoords) || this; + _this._options = { + color: options.color == null ? 0xFFFFFF : options.color, + indicateCompleter: options.indicateCompleter == null ? true : options.indicateCompleter, + }; + _this._rectGeometry = new Tag_1.RectGeometry(_this._geometry.getRect2d(transform)); + _this._createGlObjects(); + return _this; + } + ExtremePointCreateTag.prototype.create = function () { + if (this._geometry.points.length < 3) { + return; + } + this._geometry.removePoint2d(this._geometry.points.length - 1); + this._created$.next(this); + }; + ExtremePointCreateTag.prototype.dispose = function () { + _super.prototype.dispose.call(this); + this._disposeObjects(); + }; + ExtremePointCreateTag.prototype.getDOMObjects = function (camera, size) { + var _this = this; + var container = { + offsetHeight: size.height, offsetWidth: size.width, + }; + var vNodes = []; + var points2d = this._geometry.getPoints2d(); + var length = points2d.length; + var _loop_1 = function (index) { + var nonModifiedIndex = index; + var _a = points2d[index], pointX = _a[0], pointY = _a[1]; + var pointCanvas = this_1._viewportCoords.basicToCanvasSafe(pointX, pointY, container, this_1._transform, camera); + if (!pointCanvas) { + return "continue"; + } + var abort = function (e) { + e.stopPropagation(); + _this._aborted$.next(_this); + }; + var remove = function (e) { + e.stopPropagation(); + _this._geometry.removePoint2d(nonModifiedIndex); + }; + var transform = this_1._canvasToTransform(pointCanvas); + var completerProperties = { + onclick: index === 0 && length < 3 ? abort : remove, + style: { transform: transform }, + }; + vNodes.push(vd.h("div.TagInteractor", completerProperties, [])); + var background = this_1._colorToBackground(this_1._options.color); + var pointProperties = { + style: { + background: background, + transform: transform, + }, + }; + vNodes.push(vd.h("div.TagVertex", pointProperties, [])); + }; + var this_1 = this; + for (var index = 0; index < length - 1; index++) { + _loop_1(index); + } + if (length > 2 && this._options.indicateCompleter === true) { + var _a = this._geometry.getCentroid2d(this._transform), centroidX = _a[0], centroidY = _a[1]; + var centroidCanvas = this._viewportCoords.basicToCanvasSafe(centroidX, centroidY, container, this._transform, camera); + if (!!centroidCanvas) { + var complete = function (e) { + e.stopPropagation(); + _this._geometry.removePoint2d(_this._geometry.points.length - 1); + _this._created$.next(_this); + }; + var transform = this._canvasToTransform(centroidCanvas); + var completerProperties = { + onclick: complete, + style: { transform: transform }, + }; + vNodes.push(vd.h("div.TagCompleter.TagLarger", completerProperties, [])); + var pointProperties = { + style: { + background: this._colorToBackground(this._options.color), + transform: transform, + }, + }; + vNodes.push(vd.h("div.TagVertex.TagLarger", pointProperties, [])); + var dotProperties = { + style: { + transform: transform, + }, + }; + vNodes.push(vd.h("div.TagDot", dotProperties, [])); + } + } + return vNodes; + }; + ExtremePointCreateTag.prototype._onGeometryChanged = function () { + this._disposeObjects(); + this._rectGeometry = new Tag_1.RectGeometry(this._geometry.getRect2d(this._transform)); + this._createGlObjects(); + }; + ExtremePointCreateTag.prototype._createGlObjects = function () { + this._glObjects = []; + var polygon3d = this._rectGeometry.getPoints3d(this._transform); + this._outline = this._createOutine(polygon3d, this._options.color); + this._glObjects.push(this._outline); + }; + ExtremePointCreateTag.prototype._disposeObjects = function () { + this._disposeLine(this._outline); + this._outline = null; + this._glObjects = null; + }; + return ExtremePointCreateTag; +}(Component_1.CreateTag)); +exports.ExtremePointCreateTag = ExtremePointCreateTag; + + +},{"../../../Component":291,"../Tag":361,"virtual-dom":247}],387:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var THREE = require("three"); +var vd = require("virtual-dom"); +var Component_1 = require("../../../Component"); +/** + * @class OutlineRenderTag + * @classdesc Tag visualizing the properties of an OutlineTag. + */ +var ExtremePointRenderTag = /** @class */ (function (_super) { + __extends(ExtremePointRenderTag, _super); + function ExtremePointRenderTag(tag, transform) { + var _this = _super.call(this, tag, transform) || this; + _this._rectGeometry = new Component_1.RectGeometry(_this._tag.geometry.getRect2d(transform)); + _this._fill = !transform.gpano ? + _this._createFill() : null; + _this._outline = _this._tag.lineWidth >= 1 ? + _this._createOutline() : + null; + return _this; + } + ExtremePointRenderTag.prototype.dispose = function () { + _super.prototype.dispose.call(this); + this._disposeFill(); + this._disposeOutline(); + }; + ExtremePointRenderTag.prototype.getDOMObjects = function (atlas, camera, size) { + var vNodes = []; + var container = { + offsetHeight: size.height, offsetWidth: size.width, + }; + if (!this._tag.editable) { + return vNodes; + } + var lineColor = this._colorToCss(this._tag.lineColor); + var points2d = this._tag.geometry.getPoints2d(); + for (var i = 0; i < points2d.length; i++) { + var _a = points2d[i], vertexBasicX = _a[0], vertexBasicY = _a[1]; + var vertexCanvas = this._viewportCoords.basicToCanvasSafe(vertexBasicX, vertexBasicY, container, this._transform, camera); + if (vertexCanvas == null) { + continue; + } + var cursor = "crosshair"; + var interact = this._interact(Component_1.TagOperation.Vertex, cursor, i); + var vertexCanvasX = Math.round(vertexCanvas[0]); + var vertexCanvasY = Math.round(vertexCanvas[1]); + var transform = "translate(-50%, -50%) translate(" + vertexCanvasX + "px," + vertexCanvasY + "px)"; + var properties = { + onmousedown: interact, + style: { background: lineColor, transform: transform, cursor: cursor }, + }; + vNodes.push(vd.h("div.TagResizer", properties, [])); + if (!this._tag.indicateVertices) { + continue; + } + var pointProperties = { + style: { background: lineColor, transform: transform }, + }; + vNodes.push(vd.h("div.TagVertex", pointProperties, [])); + } + return vNodes; + }; + ExtremePointRenderTag.prototype.getGLObjects = function () { + var glObjects = []; + if (this._fill != null) { + glObjects.push(this._fill); + } + if (this._outline != null) { + glObjects.push(this._outline); + } + return glObjects; + }; + ExtremePointRenderTag.prototype.getRetrievableObjects = function () { + return this._fill != null ? [this._fill] : []; + }; + ExtremePointRenderTag.prototype._onGeometryChanged = function () { + this._rectGeometry = new Component_1.RectGeometry(this._tag.geometry.getRect2d(this._transform)); + if (this._fill != null) { + this._updateFillGeometry(); + } + if (this._outline != null) { + this._updateOulineGeometry(); + } + }; + ExtremePointRenderTag.prototype._onTagChanged = function () { + var glObjectsChanged = false; + if (this._fill != null) { + this._updateFillMaterial(this._fill.material); + } + if (this._outline == null) { + if (this._tag.lineWidth >= 1) { + this._outline = this._createOutline(); + glObjectsChanged = true; + } + } + else { + this._updateOutlineMaterial(); + } + return glObjectsChanged; + }; + ExtremePointRenderTag.prototype._getPoints3d = function () { + return this._rectGeometry.getPoints3d(this._transform); + }; + ExtremePointRenderTag.prototype._getTriangles = function () { + return this._rectGeometry.getTriangles3d(this._transform); + }; + ExtremePointRenderTag.prototype._updateFillMaterial = function (material) { + material.color = new THREE.Color(this._tag.fillColor); + material.opacity = this._tag.fillOpacity; + material.needsUpdate = true; + }; + ExtremePointRenderTag.prototype._updateLineBasicMaterial = function (material) { + material.color = new THREE.Color(this._tag.lineColor); + material.linewidth = Math.max(this._tag.lineWidth, 1); + material.visible = this._tag.lineWidth >= 1 && this._tag.lineOpacity > 0; + material.opacity = this._tag.lineOpacity; + material.transparent = this._tag.lineOpacity < 1; + material.needsUpdate = true; + }; + ExtremePointRenderTag.prototype._updateOutlineMaterial = function () { + var material = this._outline.material; + this._updateLineBasicMaterial(material); + }; + return ExtremePointRenderTag; +}(Component_1.OutlineRenderTagBase)); +exports.ExtremePointRenderTag = ExtremePointRenderTag; +exports.default = ExtremePointRenderTag; + + +},{"../../../Component":291,"three":242,"virtual-dom":247}],388:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var Component_1 = require("../../../Component"); +/** + * @class ExtremePointTag + * + * @classdesc Tag holding properties for visualizing a extreme points + * and their outline. + * + * @example + * ``` + * var geometry = new Mapillary.TagComponent.PointsGeometry([[0.3, 0.3], [0.5, 0.4]]); + * var tag = new Mapillary.TagComponent.ExtremePointTag( + * "id-1", + * geometry + * { editable: true, lineColor: 0xff0000 }); + * + * tagComponent.add([tag]); + * ``` + */ +var ExtremePointTag = /** @class */ (function (_super) { + __extends(ExtremePointTag, _super); + /** + * Create an extreme point tag. + * + * @override + * @constructor + * @param {string} id - Unique identifier of the tag. + * @param {PointsGeometry} geometry - Geometry defining points of tag. + * @param {IExtremePointTagOptions} options - Options defining the visual appearance and + * behavior of the extreme point tag. + */ + function ExtremePointTag(id, geometry, options) { + var _this = _super.call(this, id, geometry) || this; + options = !!options ? options : {}; + _this._editable = options.editable == null ? false : options.editable; + _this._fillColor = options.fillColor == null ? 0xFFFFFF : options.fillColor; + _this._fillOpacity = options.fillOpacity == null ? 0.0 : options.fillOpacity; + _this._indicateVertices = options.indicateVertices == null ? true : options.indicateVertices; + _this._lineColor = options.lineColor == null ? 0xFFFFFF : options.lineColor; + _this._lineOpacity = options.lineOpacity == null ? 1 : options.lineOpacity; + _this._lineWidth = options.lineWidth == null ? 1 : options.lineWidth; + return _this; + } + Object.defineProperty(ExtremePointTag.prototype, "editable", { + /** + * Get editable property. + * @returns {boolean} Value indicating if tag is editable. + */ + get: function () { + return this._editable; + }, + /** + * Set editable property. + * @param {boolean} + * + * @fires Tag#changed + */ + set: function (value) { + this._editable = value; + this._notifyChanged$.next(this); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ExtremePointTag.prototype, "fillColor", { + /** + * Get fill color property. + * @returns {number} + */ + get: function () { + return this._fillColor; + }, + /** + * Set fill color property. + * @param {number} + * + * @fires Tag#changed + */ + set: function (value) { + this._fillColor = value; + this._notifyChanged$.next(this); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ExtremePointTag.prototype, "fillOpacity", { + /** + * Get fill opacity property. + * @returns {number} + */ + get: function () { + return this._fillOpacity; + }, + /** + * Set fill opacity property. + * @param {number} + * + * @fires Tag#changed + */ + set: function (value) { + this._fillOpacity = value; + this._notifyChanged$.next(this); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ExtremePointTag.prototype, "geometry", { + /** @inheritdoc */ + get: function () { + return this._geometry; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ExtremePointTag.prototype, "indicateVertices", { + /** + * Get indicate vertices property. + * @returns {boolean} Value indicating if vertices should be indicated + * when tag is editable. + */ + get: function () { + return this._indicateVertices; + }, + /** + * Set indicate vertices property. + * @param {boolean} + * + * @fires Tag#changed + */ + set: function (value) { + this._indicateVertices = value; + this._notifyChanged$.next(this); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ExtremePointTag.prototype, "lineColor", { + /** + * Get line color property. + * @returns {number} + */ + get: function () { + return this._lineColor; + }, + /** + * Set line color property. + * @param {number} + * + * @fires Tag#changed + */ + set: function (value) { + this._lineColor = value; + this._notifyChanged$.next(this); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ExtremePointTag.prototype, "lineOpacity", { + /** + * Get line opacity property. + * @returns {number} + */ + get: function () { + return this._lineOpacity; + }, + /** + * Set line opacity property. + * @param {number} + * + * @fires Tag#changed + */ + set: function (value) { + this._lineOpacity = value; + this._notifyChanged$.next(this); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ExtremePointTag.prototype, "lineWidth", { + /** + * Get line width property. + * @returns {number} + */ + get: function () { + return this._lineWidth; + }, + /** + * Set line width property. + * @param {number} + * + * @fires Tag#changed + */ + set: function (value) { + this._lineWidth = value; + this._notifyChanged$.next(this); + }, + enumerable: true, + configurable: true + }); + /** + * Set options for tag. + * + * @description Sets all the option properties provided and keeps + * the rest of the values as is. + * + * @param {IExtremePointTagOptions} options - Extreme point tag options + * + * @fires {Tag#changed} + */ + ExtremePointTag.prototype.setOptions = function (options) { + this._editable = options.editable == null ? this._editable : options.editable; + this._indicateVertices = options.indicateVertices == null ? this._indicateVertices : options.indicateVertices; + this._lineColor = options.lineColor == null ? this._lineColor : options.lineColor; + this._lineWidth = options.lineWidth == null ? this._lineWidth : options.lineWidth; + this._fillColor = options.fillColor == null ? this._fillColor : options.fillColor; + this._fillOpacity = options.fillOpacity == null ? this._fillOpacity : options.fillOpacity; + this._notifyChanged$.next(this); + }; + return ExtremePointTag; +}(Component_1.Tag)); +exports.ExtremePointTag = ExtremePointTag; +exports.default = ExtremePointTag; + +},{"../../../Component":291}],389:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var vd = require("virtual-dom"); +var Component_1 = require("../../../Component"); +var OutlineCreateTag = /** @class */ (function (_super) { + __extends(OutlineCreateTag, _super); + function OutlineCreateTag(geometry, options, transform, viewportCoords) { + var _this = _super.call(this, geometry, transform, viewportCoords) || this; + _this._options = { color: options.color == null ? 0xFFFFFF : options.color }; + _this._createGlObjects(); + return _this; + } + OutlineCreateTag.prototype.create = function () { + if (this._geometry instanceof Component_1.RectGeometry) { + this._created$.next(this); + } + else if (this._geometry instanceof Component_1.PolygonGeometry) { + var polygonGeometry = this._geometry; + polygonGeometry.removeVertex2d(polygonGeometry.polygon.length - 2); + this._created$.next(this); + } + }; + OutlineCreateTag.prototype.dispose = function () { + _super.prototype.dispose.call(this); + this._disposeLine(this._outline); + this._disposeObjects(); + }; OutlineCreateTag.prototype.getDOMObjects = function (camera, size) { var _this = this; var vNodes = []; @@ -32828,57 +43031,29 @@ var OutlineCreateTag = /** @class */ (function () { polygonGeometry.addVertex2d(point); } }; - OutlineCreateTag.prototype._canvasToTransform = function (canvas) { - var canvasX = Math.round(canvas[0]); - var canvasY = Math.round(canvas[1]); - var transform = "translate(-50%,-50%) translate(" + canvasX + "px," + canvasY + "px)"; - return transform; + OutlineCreateTag.prototype._onGeometryChanged = function () { + this._disposeLine(this._outline); + this._disposeObjects(); + this._createGlObjects(); }; - OutlineCreateTag.prototype._colorToBackground = function (color) { - return "#" + ("000000" + color.toString(16)).substr(-6); + OutlineCreateTag.prototype._disposeObjects = function () { + this._outline = null; + this._glObjects = []; }; - OutlineCreateTag.prototype._createOutine = function () { + OutlineCreateTag.prototype._createGlObjects = function () { var polygon3d = this._geometry instanceof Component_1.RectGeometry ? this._geometry.getPoints3d(this._transform) : this._geometry.getVertices3d(this._transform); - var positions = this._getLinePositions(polygon3d); - var geometry = new THREE.BufferGeometry(); - geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3)); - var material = new THREE.LineBasicMaterial({ - color: this._options.color, - linewidth: 1, - }); - return new THREE.Line(geometry, material); - }; - OutlineCreateTag.prototype._disposeOutline = function () { - if (this._outline == null) { - return; - } - var line = this._outline; - line.geometry.dispose(); - line.material.dispose(); - this._outline = null; - this._glObjects = []; - }; - OutlineCreateTag.prototype._getLinePositions = function (polygon3d) { - var length = polygon3d.length; - var positions = new Float32Array(length * 3); - for (var i = 0; i < length; ++i) { - var index = 3 * i; - var position = polygon3d[i]; - positions[index] = position[0]; - positions[index + 1] = position[1]; - positions[index + 2] = position[2]; - } - return positions; + this._outline = this._createOutine(polygon3d, this._options.color); + this._glObjects = [this._outline]; }; return OutlineCreateTag; -}()); +}(Component_1.CreateTag)); exports.OutlineCreateTag = OutlineCreateTag; exports.default = OutlineCreateTag; -},{"../../../Component":274,"../../../Geo":277,"rxjs":26,"rxjs/operators":224,"three":225,"virtual-dom":230}],365:[function(require,module,exports){ +},{"../../../Component":291,"virtual-dom":247}],390:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -32907,54 +43082,24 @@ var OutlineRenderTag = /** @class */ (function (_super) { var _this = _super.call(this, tag, transform) || this; _this._fill = !transform.gpano ? _this._createFill() : - null; + transform.fullPano && + tag.domain === Component_1.TagDomain.TwoDimensional && + tag.geometry instanceof Component_1.PolygonGeometry ? + _this._createFill() : + null; _this._holes = _this._tag.lineWidth >= 1 ? _this._createHoles() : []; _this._outline = _this._tag.lineWidth >= 1 ? _this._createOutline() : null; - _this._geometryChangedSubscription = _this._tag.geometry.changed$ - .subscribe(function (geometry) { - if (_this._fill != null) { - _this._updateFillGeometry(); - } - if (_this._holes.length > 0) { - _this._updateHoleGeometries(); - } - if (_this._outline != null) { - _this._updateOulineGeometry(); - } - }); - _this._changedSubscription = _this._tag.changed$ - .subscribe(function (changedTag) { - var glObjectsChanged = false; - if (_this._fill != null) { - _this._updateFillMaterial(_this._fill.material); - } - if (_this._outline == null) { - if (_this._tag.lineWidth >= 1) { - _this._holes = _this._createHoles(); - _this._outline = _this._createOutline(); - glObjectsChanged = true; - } - } - else { - _this._updateHoleMaterials(); - _this._updateOutlineMaterial(); - } - if (glObjectsChanged) { - _this._glObjectsChanged$.next(_this); - } - }); return _this; } OutlineRenderTag.prototype.dispose = function () { + _super.prototype.dispose.call(this); this._disposeFill(); this._disposeHoles(); this._disposeOutline(); - this._changedSubscription.unsubscribe(); - this._geometryChangedSubscription.unsubscribe(); }; OutlineRenderTag.prototype.getDOMObjects = function (atlas, camera, size) { var _this = this; @@ -32970,7 +43115,7 @@ var OutlineRenderTag = /** @class */ (function (_super) { this._tag.geometry.getPoleOfInaccessibility2d(), iconBasicX = _a[0], iconBasicY = _a[1]; var iconCanvas = this._viewportCoords.basicToCanvasSafe(iconBasicX, iconBasicY, container, this._transform, camera); if (iconCanvas != null) { - var interact = function (e) { + var interact = function () { _this._interact$.next({ offsetX: 0, offsetY: 0, operation: Component_1.TagOperation.None, tag: _this._tag }); }; if (atlas.loaded) { @@ -33002,7 +43147,7 @@ var OutlineRenderTag = /** @class */ (function (_super) { var transform = this._tag.geometry instanceof Component_1.RectGeometry ? "translate(" + textCanvasX + "px," + textCanvasY + "px)" : "translate(-50%, -50%) translate(" + textCanvasX + "px," + textCanvasY + "px)"; - var interact = function (e) { + var interact = function () { _this._interact$.next({ offsetX: 0, offsetY: 0, operation: Component_1.TagOperation.None, tag: _this._tag }); }; var properties = { @@ -33086,18 +43231,57 @@ var OutlineRenderTag = /** @class */ (function (_super) { OutlineRenderTag.prototype.getRetrievableObjects = function () { return this._fill != null ? [this._fill] : []; }; - OutlineRenderTag.prototype._colorToCss = function (color) { - return "#" + ("000000" + color.toString(16)).substr(-6); + OutlineRenderTag.prototype._onGeometryChanged = function () { + if (this._fill != null) { + this._updateFillGeometry(); + } + if (this._holes.length > 0) { + this._updateHoleGeometries(); + } + if (this._outline != null) { + this._updateOulineGeometry(); + } }; - OutlineRenderTag.prototype._createFill = function () { - var triangles = this._getTriangles(); - var positions = new Float32Array(triangles); - var geometry = new THREE.BufferGeometry(); - geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3)); - geometry.computeBoundingSphere(); - var material = new THREE.MeshBasicMaterial({ side: THREE.DoubleSide, transparent: true }); - this._updateFillMaterial(material); - return new THREE.Mesh(geometry, material); + OutlineRenderTag.prototype._onTagChanged = function () { + var glObjectsChanged = false; + if (this._fill != null) { + this._updateFillMaterial(this._fill.material); + } + if (this._outline == null) { + if (this._tag.lineWidth >= 1) { + this._holes = this._createHoles(); + this._outline = this._createOutline(); + glObjectsChanged = true; + } + } + else { + this._updateHoleMaterials(); + this._updateOutlineMaterial(); + } + return glObjectsChanged; + }; + OutlineRenderTag.prototype._getPoints3d = function () { + return this._in3dDomain() ? + this._tag.geometry.getVertices3d(this._transform) : + this._tag.geometry.getPoints3d(this._transform); + }; + OutlineRenderTag.prototype._getTriangles = function () { + return this._in3dDomain() ? + this._tag.geometry.get3dDomainTriangles3d(this._transform) : + this._tag.geometry.getTriangles3d(this._transform); + }; + OutlineRenderTag.prototype._updateFillMaterial = function (material) { + material.color = new THREE.Color(this._tag.fillColor); + material.opacity = this._tag.fillOpacity; + material.needsUpdate = true; + }; + OutlineRenderTag.prototype._updateLineBasicMaterial = function (material) { + material.color = new THREE.Color(this._tag.lineColor); + material.linewidth = Math.max(this._tag.lineWidth, 1); + material.visible = this._tag.lineWidth >= 1 && this._tag.lineOpacity > 0; + material.opacity = this._tag.lineOpacity; + material.transparent = this._tag.lineOpacity < 1; + material.needsUpdate = true; }; OutlineRenderTag.prototype._createHoles = function () { var holes = []; @@ -33111,7 +43295,101 @@ var OutlineRenderTag = /** @class */ (function (_super) { } return holes; }; - OutlineRenderTag.prototype._createLine = function (points3d) { + OutlineRenderTag.prototype._disposeHoles = function () { + for (var _i = 0, _a = this._holes; _i < _a.length; _i++) { + var hole = _a[_i]; + hole.geometry.dispose(); + hole.material.dispose(); + } + this._holes = []; + }; + OutlineRenderTag.prototype._getHoles3d = function () { + var polygonGeometry = this._tag.geometry; + return this._in3dDomain() ? + polygonGeometry.getHoleVertices3d(this._transform) : + polygonGeometry.getHolePoints3d(this._transform); + }; + OutlineRenderTag.prototype._in3dDomain = function () { + return this._tag.geometry instanceof Component_1.PolygonGeometry && this._tag.domain === Component_1.TagDomain.ThreeDimensional; + }; + OutlineRenderTag.prototype._updateHoleGeometries = function () { + var holes3d = this._getHoles3d(); + if (holes3d.length !== this._holes.length) { + throw new Error("Changing the number of holes is not supported."); + } + for (var i = 0; i < this._holes.length; i++) { + var holePoints3d = holes3d[i]; + var hole = this._holes[i]; + this._updateLine(hole, holePoints3d); + } + }; + OutlineRenderTag.prototype._updateHoleMaterials = function () { + for (var _i = 0, _a = this._holes; _i < _a.length; _i++) { + var hole = _a[_i]; + this._updateLineBasicMaterial(hole.material); + } + }; + OutlineRenderTag.prototype._updateOutlineMaterial = function () { + this._updateLineBasicMaterial(this._outline.material); + }; + return OutlineRenderTag; +}(Component_1.OutlineRenderTagBase)); +exports.OutlineRenderTag = OutlineRenderTag; + + +},{"../../../Component":291,"three":242,"virtual-dom":247}],391:[function(require,module,exports){ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var THREE = require("three"); +var Component_1 = require("../../../Component"); +var OutlineRenderTagBase = /** @class */ (function (_super) { + __extends(OutlineRenderTagBase, _super); + function OutlineRenderTagBase(tag, transform) { + var _this = _super.call(this, tag, transform) || this; + _this._geometryChangedSubscription = _this._tag.geometry.changed$ + .subscribe(function () { + _this._onGeometryChanged(); + }); + _this._changedSubscription = _this._tag.changed$ + .subscribe(function () { + var glObjectsChanged = _this._onTagChanged(); + if (glObjectsChanged) { + _this._glObjectsChanged$.next(_this); + } + }); + return _this; + } + OutlineRenderTagBase.prototype.dispose = function () { + this._changedSubscription.unsubscribe(); + this._geometryChangedSubscription.unsubscribe(); + }; + OutlineRenderTagBase.prototype._colorToCss = function (color) { + return "#" + ("000000" + color.toString(16)).substr(-6); + }; + OutlineRenderTagBase.prototype._createFill = function () { + var triangles = this._getTriangles(); + var positions = new Float32Array(triangles); + var geometry = new THREE.BufferGeometry(); + geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3)); + geometry.computeBoundingSphere(); + var material = new THREE.MeshBasicMaterial({ side: THREE.DoubleSide, transparent: true }); + this._updateFillMaterial(material); + return new THREE.Mesh(geometry, material); + }; + OutlineRenderTagBase.prototype._createLine = function (points3d) { var positions = this._getLinePositions(points3d); var geometry = new THREE.BufferGeometry(); geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3)); @@ -33122,10 +43400,10 @@ var OutlineRenderTag = /** @class */ (function (_super) { line.renderOrder = 1; return line; }; - OutlineRenderTag.prototype._createOutline = function () { + OutlineRenderTagBase.prototype._createOutline = function () { return this._createLine(this._getPoints3d()); }; - OutlineRenderTag.prototype._disposeFill = function () { + OutlineRenderTagBase.prototype._disposeFill = function () { if (this._fill == null) { return; } @@ -33133,15 +43411,7 @@ var OutlineRenderTag = /** @class */ (function (_super) { this._fill.material.dispose(); this._fill = null; }; - OutlineRenderTag.prototype._disposeHoles = function () { - for (var _i = 0, _a = this._holes; _i < _a.length; _i++) { - var hole = _a[_i]; - hole.geometry.dispose(); - hole.material.dispose(); - } - this._holes = []; - }; - OutlineRenderTag.prototype._disposeOutline = function () { + OutlineRenderTagBase.prototype._disposeOutline = function () { if (this._outline == null) { return; } @@ -33149,7 +43419,7 @@ var OutlineRenderTag = /** @class */ (function (_super) { this._outline.material.dispose(); this._outline = null; }; - OutlineRenderTag.prototype._getLinePositions = function (points3d) { + OutlineRenderTagBase.prototype._getLinePositions = function (points3d) { var length = points3d.length; var positions = new Float32Array(length * 3); for (var i = 0; i < length; ++i) { @@ -33161,26 +43431,7 @@ var OutlineRenderTag = /** @class */ (function (_super) { } return positions; }; - OutlineRenderTag.prototype._getHoles3d = function () { - var polygonGeometry = this._tag.geometry; - return this._in3dDomain() ? - polygonGeometry.getHoleVertices3d(this._transform) : - polygonGeometry.getHolePoints3d(this._transform); - }; - OutlineRenderTag.prototype._getPoints3d = function () { - return this._in3dDomain() ? - this._tag.geometry.getVertices3d(this._transform) : - this._tag.geometry.getPoints3d(this._transform); - }; - OutlineRenderTag.prototype._getTriangles = function () { - return this._in3dDomain() ? - this._tag.geometry.get3dDomainTriangles3d(this._transform) : - this._tag.geometry.getTriangles3d(this._transform); - }; - OutlineRenderTag.prototype._in3dDomain = function () { - return this._tag.geometry instanceof Component_1.PolygonGeometry && this._tag.domain === Component_1.TagDomain.ThreeDimensional; - }; - OutlineRenderTag.prototype._interact = function (operation, cursor, vertexIndex) { + OutlineRenderTagBase.prototype._interact = function (operation, cursor, vertexIndex) { var _this = this; return function (e) { var offsetX = e.offsetX - e.target.offsetWidth / 2; @@ -33195,7 +43446,7 @@ var OutlineRenderTag = /** @class */ (function (_super) { }); }; }; - OutlineRenderTag.prototype._updateFillGeometry = function () { + OutlineRenderTagBase.prototype._updateFillGeometry = function () { var triangles = this._getTriangles(); var positions = new Float32Array(triangles); var geometry = this._fill.geometry; @@ -33210,30 +43461,7 @@ var OutlineRenderTag = /** @class */ (function (_super) { } geometry.computeBoundingSphere(); }; - OutlineRenderTag.prototype._updateFillMaterial = function (material) { - material.color = new THREE.Color(this._tag.fillColor); - material.opacity = this._tag.fillOpacity; - material.needsUpdate = true; - }; - OutlineRenderTag.prototype._updateHoleGeometries = function () { - var holes3d = this._getHoles3d(); - if (holes3d.length !== this._holes.length) { - throw new Error("Changing the number of holes is not supported."); - } - for (var i = 0; i < this._holes.length; i++) { - var holePoints3d = holes3d[i]; - var hole = this._holes[i]; - this._updateLine(hole, holePoints3d); - } - }; - OutlineRenderTag.prototype._updateHoleMaterials = function () { - for (var _i = 0, _a = this._holes; _i < _a.length; _i++) { - var hole = _a[_i]; - var material = hole.material; - this._updateLineBasicMaterial(material); - } - }; - OutlineRenderTag.prototype._updateLine = function (line, points3d) { + OutlineRenderTagBase.prototype._updateLine = function (line, points3d) { var positions = this._getLinePositions(points3d); var geometry = line.geometry; var attribute = geometry.getAttribute("position"); @@ -33241,27 +43469,16 @@ var OutlineRenderTag = /** @class */ (function (_super) { attribute.needsUpdate = true; geometry.computeBoundingSphere(); }; - OutlineRenderTag.prototype._updateOulineGeometry = function () { + OutlineRenderTagBase.prototype._updateOulineGeometry = function () { this._updateLine(this._outline, this._getPoints3d()); }; - OutlineRenderTag.prototype._updateOutlineMaterial = function () { - var material = this._outline.material; - this._updateLineBasicMaterial(material); - }; - OutlineRenderTag.prototype._updateLineBasicMaterial = function (material) { - material.color = new THREE.Color(this._tag.lineColor); - material.linewidth = Math.max(this._tag.lineWidth, 1); - material.visible = this._tag.lineWidth >= 1 && this._tag.lineOpacity > 0; - material.opacity = this._tag.lineOpacity; - material.transparent = this._tag.lineOpacity < 1; - material.needsUpdate = true; - }; - return OutlineRenderTag; + return OutlineRenderTagBase; }(Component_1.RenderTag)); -exports.OutlineRenderTag = OutlineRenderTag; +exports.OutlineRenderTagBase = OutlineRenderTagBase; +exports.default = OutlineRenderTagBase; -},{"../../../Component":274,"three":225,"virtual-dom":230}],366:[function(require,module,exports){ +},{"../../../Component":291,"three":242}],392:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -33667,7 +43884,7 @@ var OutlineTag = /** @class */ (function (_super) { exports.OutlineTag = OutlineTag; exports.default = OutlineTag; -},{"../../../Component":274,"../../../Viewer":285,"rxjs":26}],367:[function(require,module,exports){ +},{"../../../Component":291,"../../../Viewer":302,"rxjs":43}],393:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var rxjs_1 = require("rxjs"); @@ -33706,7 +43923,7 @@ var RenderTag = /** @class */ (function () { exports.RenderTag = RenderTag; exports.default = RenderTag; -},{"../../../Geo":277,"rxjs":26}],368:[function(require,module,exports){ +},{"../../../Geo":294,"rxjs":43}],394:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -33824,7 +44041,7 @@ var SpotRenderTag = /** @class */ (function (_super) { exports.SpotRenderTag = SpotRenderTag; -},{"../../../Component":274,"../../../Viewer":285,"virtual-dom":230}],369:[function(require,module,exports){ +},{"../../../Component":291,"../../../Viewer":302,"virtual-dom":247}],395:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -34007,7 +44224,7 @@ var SpotTag = /** @class */ (function (_super) { exports.SpotTag = SpotTag; exports.default = SpotTag; -},{"../../../Component":274}],370:[function(require,module,exports){ +},{"../../../Component":291}],396:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -34124,7 +44341,7 @@ var Tag = /** @class */ (function (_super) { exports.Tag = Tag; exports.default = Tag; -},{"../../../Utils":284,"rxjs":26,"rxjs/operators":224}],371:[function(require,module,exports){ +},{"../../../Utils":301,"rxjs":43,"rxjs/operators":241}],397:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** @@ -34156,7 +44373,37 @@ var TagDomain; })(TagDomain = exports.TagDomain || (exports.TagDomain = {})); exports.default = TagDomain; -},{}],372:[function(require,module,exports){ +},{}],398:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Enumeration for component size. + * @enum {number} + * @readonly + * @description May be used by a component to allow for resizing + * of the UI elements rendered by the component. + */ +var ComponentSize; +(function (ComponentSize) { + /** + * Automatic size. The size of the elements will automatically + * change at a predefined threshold. + */ + ComponentSize[ComponentSize["Automatic"] = 0] = "Automatic"; + /** + * Large size. The size of the elements will be fixed until another + * component size is configured. + */ + ComponentSize[ComponentSize["Large"] = 1] = "Large"; + /** + * Small size. The size of the elements will be fixed until another + * component size is configured. + */ + ComponentSize[ComponentSize["Small"] = 2] = "Small"; +})(ComponentSize = exports.ComponentSize || (exports.ComponentSize = {})); +exports.default = ComponentSize; + +},{}],399:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var HandlerBase = /** @class */ (function () { @@ -34212,7 +44459,7 @@ var HandlerBase = /** @class */ (function () { exports.HandlerBase = HandlerBase; exports.default = HandlerBase; -},{}],373:[function(require,module,exports){ +},{}],400:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var THREE = require("three"); @@ -34223,10 +44470,15 @@ var MeshFactory = /** @class */ (function () { this._imageSphereRadius = imageSphereRadius != null ? imageSphereRadius : 200; } MeshFactory.prototype.createMesh = function (node, transform) { - var mesh = node.pano ? - this._createImageSphere(node, transform) : - this._createImagePlane(node, transform); - return mesh; + if (node.pano) { + return this._createImageSphere(node, transform); + } + else if (transform.cameraProjection === "fisheye") { + return this._createImagePlaneFisheye(node, transform); + } + else { + return this._createImagePlane(node, transform); + } }; MeshFactory.prototype.createFlatMesh = function (node, transform, basicX0, basicX1, basicY0, basicY1) { var texture = this._createTexture(node.image); @@ -34239,9 +44491,15 @@ var MeshFactory = /** @class */ (function () { if (node.pano && !node.fullPano) { throw new Error("Cropped panoramas cannot have curtain."); } - return node.pano ? - this._createSphereCurtainMesh(node, transform) : - this._createCurtainMesh(node, transform); + if (node.pano) { + return this._createSphereCurtainMesh(node, transform); + } + else if (transform.cameraProjection === "fisheye") { + return this._createCurtainMeshFisheye(node, transform); + } + else { + return this._createCurtainMesh(node, transform); + } }; MeshFactory.prototype.createDistortedCurtainMesh = function (node, transform) { if (node.pano) { @@ -34258,6 +44516,15 @@ var MeshFactory = /** @class */ (function () { this._getRegularFlatImagePlaneGeo(transform); return new THREE.Mesh(geometry, material); }; + MeshFactory.prototype._createCurtainMeshFisheye = function (node, transform) { + var texture = this._createTexture(node.image); + var materialParameters = this._createCurtainPlaneMaterialParametersFisheye(transform, texture); + var material = new THREE.ShaderMaterial(materialParameters); + var geometry = this._useMesh(transform, node) ? + this._getImagePlaneGeoFisheye(transform, node) : + this._getRegularFlatImagePlaneGeo(transform); + return new THREE.Mesh(geometry, material); + }; MeshFactory.prototype._createDistortedCurtainMesh = function (node, transform) { var texture = this._createTexture(node.image); var materialParameters = this._createDistortedCurtainPlaneMaterialParameters(transform, texture); @@ -34291,6 +44558,15 @@ var MeshFactory = /** @class */ (function () { this._getRegularFlatImagePlaneGeo(transform); return new THREE.Mesh(geometry, material); }; + MeshFactory.prototype._createImagePlaneFisheye = function (node, transform) { + var texture = this._createTexture(node.image); + var materialParameters = this._createPlaneMaterialParametersFisheye(transform, texture); + var material = new THREE.ShaderMaterial(materialParameters); + var geometry = this._useMesh(transform, node) ? + this._getImagePlaneGeoFisheye(transform, node) : + this._getRegularFlatImagePlaneGeoFisheye(transform); + return new THREE.Mesh(geometry, material); + }; MeshFactory.prototype._createSphereMaterialParameters = function (transform, texture) { var gpano = transform.gpano; var halfCroppedWidth = (gpano.FullPanoWidthPixels - gpano.CroppedAreaImageWidthPixels) / 2; @@ -34334,68 +44610,168 @@ var MeshFactory = /** @class */ (function () { value: thetaShift, }, }, - vertexShader: Component_1.Shaders.equirectangular.vertex, + vertexShader: Component_1.Shaders.equirectangular.vertex, + }; + return materialParameters; + }; + MeshFactory.prototype._createCurtainSphereMaterialParameters = function (transform, texture) { + var gpano = transform.gpano; + var halfCroppedWidth = (gpano.FullPanoWidthPixels - gpano.CroppedAreaImageWidthPixels) / 2; + var phiShift = 2 * Math.PI * (gpano.CroppedAreaLeftPixels - halfCroppedWidth) / gpano.FullPanoWidthPixels; + var phiLength = 2 * Math.PI * gpano.CroppedAreaImageWidthPixels / gpano.FullPanoWidthPixels; + var halfCroppedHeight = (gpano.FullPanoHeightPixels - gpano.CroppedAreaImageHeightPixels) / 2; + var thetaShift = Math.PI * (halfCroppedHeight - gpano.CroppedAreaTopPixels) / gpano.FullPanoHeightPixels; + var thetaLength = Math.PI * gpano.CroppedAreaImageHeightPixels / gpano.FullPanoHeightPixels; + var materialParameters = { + depthWrite: false, + fragmentShader: Component_1.Shaders.equirectangularCurtain.fragment, + side: THREE.DoubleSide, + transparent: true, + uniforms: { + curtain: { + type: "f", + value: 1, + }, + opacity: { + type: "f", + value: 1, + }, + phiLength: { + type: "f", + value: phiLength, + }, + phiShift: { + type: "f", + value: phiShift, + }, + projectorMat: { + type: "m4", + value: transform.rt, + }, + projectorTex: { + type: "t", + value: texture, + }, + thetaLength: { + type: "f", + value: thetaLength, + }, + thetaShift: { + type: "f", + value: thetaShift, + }, + }, + vertexShader: Component_1.Shaders.equirectangularCurtain.vertex, }; return materialParameters; }; - MeshFactory.prototype._createCurtainSphereMaterialParameters = function (transform, texture) { - var gpano = transform.gpano; - var halfCroppedWidth = (gpano.FullPanoWidthPixels - gpano.CroppedAreaImageWidthPixels) / 2; - var phiShift = 2 * Math.PI * (gpano.CroppedAreaLeftPixels - halfCroppedWidth) / gpano.FullPanoWidthPixels; - var phiLength = 2 * Math.PI * gpano.CroppedAreaImageWidthPixels / gpano.FullPanoWidthPixels; - var halfCroppedHeight = (gpano.FullPanoHeightPixels - gpano.CroppedAreaImageHeightPixels) / 2; - var thetaShift = Math.PI * (halfCroppedHeight - gpano.CroppedAreaTopPixels) / gpano.FullPanoHeightPixels; - var thetaLength = Math.PI * gpano.CroppedAreaImageHeightPixels / gpano.FullPanoHeightPixels; + MeshFactory.prototype._createPlaneMaterialParameters = function (transform, texture) { var materialParameters = { depthWrite: false, - fragmentShader: Component_1.Shaders.equirectangularCurtain.fragment, + fragmentShader: Component_1.Shaders.perspective.fragment, side: THREE.DoubleSide, transparent: true, uniforms: { - curtain: { + focal: { type: "f", - value: 1, + value: transform.focal, + }, + k1: { + type: "f", + value: transform.ck1, + }, + k2: { + type: "f", + value: transform.ck2, }, opacity: { type: "f", value: 1, }, - phiLength: { + projectorMat: { + type: "m4", + value: transform.basicRt, + }, + projectorTex: { + type: "t", + value: texture, + }, + radial_peak: { type: "f", - value: phiLength, + value: !!transform.radialPeak ? transform.radialPeak : 0, }, - phiShift: { + scale_x: { type: "f", - value: phiShift, + value: Math.max(transform.basicHeight, transform.basicWidth) / transform.basicWidth, + }, + scale_y: { + type: "f", + value: Math.max(transform.basicWidth, transform.basicHeight) / transform.basicHeight, + }, + }, + vertexShader: Component_1.Shaders.perspective.vertex, + }; + return materialParameters; + }; + MeshFactory.prototype._createPlaneMaterialParametersFisheye = function (transform, texture) { + var materialParameters = { + depthWrite: false, + fragmentShader: Component_1.Shaders.fisheye.fragment, + side: THREE.DoubleSide, + transparent: true, + uniforms: { + focal: { + type: "f", + value: transform.focal, + }, + k1: { + type: "f", + value: transform.ck1, + }, + k2: { + type: "f", + value: transform.ck2, + }, + opacity: { + type: "f", + value: 1, }, projectorMat: { type: "m4", - value: transform.rt, + value: transform.basicRt, }, projectorTex: { type: "t", value: texture, }, - thetaLength: { + radial_peak: { type: "f", - value: thetaLength, + value: !!transform.radialPeak ? transform.radialPeak : 0, }, - thetaShift: { + scale_x: { type: "f", - value: thetaShift, + value: Math.max(transform.basicHeight, transform.basicWidth) / transform.basicWidth, + }, + scale_y: { + type: "f", + value: Math.max(transform.basicWidth, transform.basicHeight) / transform.basicHeight, }, }, - vertexShader: Component_1.Shaders.equirectangularCurtain.vertex, + vertexShader: Component_1.Shaders.fisheye.vertex, }; return materialParameters; }; - MeshFactory.prototype._createPlaneMaterialParameters = function (transform, texture) { + MeshFactory.prototype._createCurtainPlaneMaterialParametersFisheye = function (transform, texture) { var materialParameters = { depthWrite: false, - fragmentShader: Component_1.Shaders.perspective.fragment, + fragmentShader: Component_1.Shaders.fisheyeCurtain.fragment, side: THREE.DoubleSide, transparent: true, uniforms: { + curtain: { + type: "f", + value: 1, + }, focal: { type: "f", value: transform.focal, @@ -34433,7 +44809,7 @@ var MeshFactory = /** @class */ (function () { value: Math.max(transform.basicWidth, transform.basicHeight) / transform.basicHeight, }, }, - vertexShader: Component_1.Shaders.perspective.vertex, + vertexShader: Component_1.Shaders.fisheyeCurtain.vertex, }; return materialParameters; }; @@ -34618,6 +44994,38 @@ var MeshFactory = /** @class */ (function () { geometry.setIndex(new THREE.BufferAttribute(indices, 1)); return geometry; }; + MeshFactory.prototype._getImagePlaneGeoFisheye = function (transform, node) { + var t = new THREE.Matrix4().getInverse(transform.srt); + // push everything at least 5 meters in front of the camera + var minZ = 5.0 * transform.scale; + var maxZ = this._imagePlaneDepth * transform.scale; + var vertices = node.mesh.vertices; + var numVertices = vertices.length / 3; + var positions = new Float32Array(vertices.length); + for (var i = 0; i < numVertices; ++i) { + var index = 3 * i; + var x = vertices[index + 0]; + var y = vertices[index + 1]; + var z = vertices[index + 2]; + var l = Math.sqrt(x * x + y * y + z * z); + var boundedL = Math.max(minZ, Math.min(l, maxZ)); + var factor = boundedL / l; + var p = new THREE.Vector3(x * factor, y * factor, z * factor); + p.applyMatrix4(t); + positions[index + 0] = p.x; + positions[index + 1] = p.y; + positions[index + 2] = p.z; + } + var faces = node.mesh.faces; + var indices = new Uint16Array(faces.length); + for (var i = 0; i < faces.length; ++i) { + indices[i] = faces[i]; + } + var geometry = new THREE.BufferGeometry(); + geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3)); + geometry.setIndex(new THREE.BufferAttribute(indices, 1)); + return geometry; + }; MeshFactory.prototype._getFlatImageSphereGeo = function (transform) { var gpano = transform.gpano; var phiStart = 2 * Math.PI * gpano.CroppedAreaLeftPixels / gpano.FullPanoWidthPixels; @@ -34646,6 +45054,22 @@ var MeshFactory = /** @class */ (function () { vertices.push(transform.unprojectSfM([-dx, dy], this._imagePlaneDepth)); return this._createFlatGeometry(vertices); }; + MeshFactory.prototype._getRegularFlatImagePlaneGeoFisheye = function (transform) { + var width = transform.width; + var height = transform.height; + var size = Math.max(width, height); + var dx = width / 2.0 / size; + var dy = height / 2.0 / size; + return this._getFlatImagePlaneGeoFisheye(transform, dx, dy); + }; + MeshFactory.prototype._getFlatImagePlaneGeoFisheye = function (transform, dx, dy) { + var vertices = []; + vertices.push(transform.unprojectSfM([-dx, -dy], this._imagePlaneDepth)); + vertices.push(transform.unprojectSfM([dx, -dy], this._imagePlaneDepth)); + vertices.push(transform.unprojectSfM([dx, dy], this._imagePlaneDepth)); + vertices.push(transform.unprojectSfM([-dx, dy], this._imagePlaneDepth)); + return this._createFlatGeometry(vertices); + }; MeshFactory.prototype._getFlatImagePlaneGeoFromBasic = function (transform, basicX0, basicX1, basicY0, basicY1) { var vertices = []; vertices.push(transform.unprojectBasic([basicX0, basicY0], this._imagePlaneDepth)); @@ -34679,49 +45103,118 @@ var MeshFactory = /** @class */ (function () { exports.MeshFactory = MeshFactory; exports.default = MeshFactory; -},{"../../Component":274,"three":225}],374:[function(require,module,exports){ +},{"../../Component":291,"three":242}],401:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var THREE = require("three"); var MeshScene = /** @class */ (function () { function MeshScene() { - this.scene = new THREE.Scene(); - this.sceneOld = new THREE.Scene(); - this.imagePlanes = []; - this.imagePlanesOld = []; + this._planes = {}; + this._planesOld = {}; + this._planesPeriphery = {}; + this._scene = new THREE.Scene(); + this._sceneOld = new THREE.Scene(); + this._scenePeriphery = new THREE.Scene(); } + Object.defineProperty(MeshScene.prototype, "planes", { + get: function () { + return this._planes; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(MeshScene.prototype, "planesOld", { + get: function () { + return this._planesOld; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(MeshScene.prototype, "planesPeriphery", { + get: function () { + return this._planesPeriphery; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(MeshScene.prototype, "scene", { + get: function () { + return this._scene; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(MeshScene.prototype, "sceneOld", { + get: function () { + return this._sceneOld; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(MeshScene.prototype, "scenePeriphery", { + get: function () { + return this._scenePeriphery; + }, + enumerable: true, + configurable: true + }); MeshScene.prototype.updateImagePlanes = function (planes) { - this._dispose(this.imagePlanesOld, this.sceneOld); - for (var _i = 0, _a = this.imagePlanes; _i < _a.length; _i++) { - var plane = _a[_i]; - this.scene.remove(plane); - this.sceneOld.add(plane); + this._dispose(this._planesOld, this.sceneOld); + for (var key in this._planes) { + if (!this._planes.hasOwnProperty(key)) { + continue; + } + var plane = this._planes[key]; + this._scene.remove(plane); + this._sceneOld.add(plane); } - for (var _b = 0, planes_1 = planes; _b < planes_1.length; _b++) { - var plane = planes_1[_b]; - this.scene.add(plane); + for (var key in planes) { + if (!planes.hasOwnProperty(key)) { + continue; + } + this._scene.add(planes[key]); } - this.imagePlanesOld = this.imagePlanes; - this.imagePlanes = planes; + this._planesOld = this._planes; + this._planes = planes; }; MeshScene.prototype.addImagePlanes = function (planes) { - for (var _i = 0, planes_2 = planes; _i < planes_2.length; _i++) { - var plane = planes_2[_i]; - this.scene.add(plane); - this.imagePlanes.push(plane); + for (var key in planes) { + if (!planes.hasOwnProperty(key)) { + continue; + } + var plane = planes[key]; + this._scene.add(plane); + this._planes[key] = plane; } }; MeshScene.prototype.addImagePlanesOld = function (planes) { - for (var _i = 0, planes_3 = planes; _i < planes_3.length; _i++) { - var plane = planes_3[_i]; - this.sceneOld.add(plane); - this.imagePlanesOld.push(plane); + for (var key in planes) { + if (!planes.hasOwnProperty(key)) { + continue; + } + var plane = planes[key]; + this._sceneOld.add(plane); + this._planesOld[key] = plane; } }; MeshScene.prototype.setImagePlanes = function (planes) { this._clear(); this.addImagePlanes(planes); }; + MeshScene.prototype.addPeripheryPlanes = function (planes) { + for (var key in planes) { + if (!planes.hasOwnProperty(key)) { + continue; + } + var plane = planes[key]; + this._scenePeriphery.add(plane); + this._planesPeriphery[key] = plane; + } + }; + MeshScene.prototype.setPeripheryPlanes = function (planes) { + this._clearPeriphery(); + this.addPeripheryPlanes(planes); + }; MeshScene.prototype.setImagePlanesOld = function (planes) { this._clearOld(); this.addImagePlanesOld(planes); @@ -34731,16 +45224,23 @@ var MeshScene = /** @class */ (function () { this._clearOld(); }; MeshScene.prototype._clear = function () { - this._dispose(this.imagePlanes, this.scene); - this.imagePlanes.length = 0; + this._dispose(this._planes, this._scene); + this._planes = {}; }; MeshScene.prototype._clearOld = function () { - this._dispose(this.imagePlanesOld, this.sceneOld); - this.imagePlanesOld.length = 0; + this._dispose(this._planesOld, this._sceneOld); + this._planesOld = {}; + }; + MeshScene.prototype._clearPeriphery = function () { + this._dispose(this._planesPeriphery, this._scenePeriphery); + this._planesPeriphery = {}; }; MeshScene.prototype._dispose = function (planes, scene) { - for (var _i = 0, planes_4 = planes; _i < planes_4.length; _i++) { - var plane = planes_4[_i]; + for (var key in planes) { + if (!planes.hasOwnProperty(key)) { + continue; + } + var plane = planes[key]; scene.remove(plane); plane.geometry.dispose(); plane.material.dispose(); @@ -34755,7 +45255,7 @@ var MeshScene = /** @class */ (function () { exports.MeshScene = MeshScene; exports.default = MeshScene; -},{"three":225}],375:[function(require,module,exports){ +},{"three":242}],402:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var rxjs_1 = require("rxjs"); @@ -34784,7 +45284,7 @@ var MouseOperator = /** @class */ (function () { exports.MouseOperator = MouseOperator; exports.default = MouseOperator; -},{"rxjs":26,"rxjs/operators":224}],376:[function(require,module,exports){ +},{"rxjs":43,"rxjs/operators":241}],403:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -34806,6 +45306,23 @@ var vd = require("virtual-dom"); var Component_1 = require("../../Component"); var Geo_1 = require("../../Geo"); var State_1 = require("../../State"); +var ComponentSize_1 = require("../utils/ComponentSize"); +/** + * @class ZoomComponent + * + * @classdesc Component rendering UI elements used for zooming. + * + * @example + * ``` + * var viewer = new Mapillary.Viewer( + * "", + * "", + * ""); + * + * var zoomComponent = viewer.getComponent("zoom"); + * zoomComponent.configure({ size: Mapillary.ComponentSize.Small }); + * ``` + */ var ZoomComponent = /** @class */ (function (_super) { __extends(ZoomComponent, _super); function ZoomComponent(name, container, navigator) { @@ -34816,11 +45333,9 @@ var ZoomComponent = /** @class */ (function (_super) { } ZoomComponent.prototype._activate = function () { var _this = this; - this._renderSubscription = rxjs_1.combineLatest(this._navigator.stateService.currentState$, this._navigator.stateService.state$).pipe(operators_1.map(function (_a) { - var frame = _a[0], state = _a[1]; - return [frame.state.zoom, state]; - }), operators_1.map(function (_a) { - var zoom = _a[0], state = _a[1]; + this._renderSubscription = rxjs_1.combineLatest(this._navigator.stateService.currentState$, this._navigator.stateService.state$, this._configuration$, this._container.renderService.size$).pipe(operators_1.map(function (_a) { + var frame = _a[0], state = _a[1], configuration = _a[2], size = _a[3]; + var zoom = frame.state.zoom; var zoomInIcon = vd.h("div.ZoomInIcon", []); var zoomInButton = zoom >= 3 || state === State_1.State.Waiting ? vd.h("div.ZoomInButtonDisabled", [zoomInIcon]) : @@ -34829,9 +45344,12 @@ var ZoomComponent = /** @class */ (function (_super) { var zoomOutButton = zoom <= 0 || state === State_1.State.Waiting ? vd.h("div.ZoomOutButtonDisabled", [zoomOutIcon]) : vd.h("div.ZoomOutButton", { onclick: function () { _this._zoomDelta$.next(-1); } }, [zoomOutIcon]); + var compact = configuration.size === ComponentSize_1.default.Small || + configuration.size === ComponentSize_1.default.Automatic && size.width < 640 ? + ".ZoomCompact" : ""; return { name: _this._name, - vnode: vd.h("div.ZoomContainer", { oncontextmenu: function (event) { event.preventDefault(); } }, [zoomInButton, zoomOutButton]), + vnode: vd.h("div.ZoomContainer" + compact, { oncontextmenu: function (event) { event.preventDefault(); } }, [zoomInButton, zoomOutButton]), }; })) .subscribe(this._container.domRenderer.render$); @@ -34848,7 +45366,7 @@ var ZoomComponent = /** @class */ (function (_super) { this._zoomSubscription.unsubscribe(); }; ZoomComponent.prototype._getDefaultConfiguration = function () { - return {}; + return { size: ComponentSize_1.default.Automatic }; }; ZoomComponent.componentName = "zoom"; return ZoomComponent; @@ -34857,7 +45375,7 @@ exports.ZoomComponent = ZoomComponent; Component_1.ComponentService.register(ZoomComponent); exports.default = ZoomComponent; -},{"../../Component":274,"../../Geo":277,"../../State":281,"rxjs":26,"rxjs/operators":224,"virtual-dom":230}],377:[function(require,module,exports){ +},{"../../Component":291,"../../Geo":294,"../../State":298,"../utils/ComponentSize":398,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],404:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -34893,7 +45411,7 @@ var AbortMapillaryError = /** @class */ (function (_super) { exports.AbortMapillaryError = AbortMapillaryError; exports.default = AbortMapillaryError; -},{"./MapillaryError":380}],378:[function(require,module,exports){ +},{"./MapillaryError":407}],405:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -34923,7 +45441,7 @@ var ArgumentMapillaryError = /** @class */ (function (_super) { exports.ArgumentMapillaryError = ArgumentMapillaryError; exports.default = ArgumentMapillaryError; -},{"./MapillaryError":380}],379:[function(require,module,exports){ +},{"./MapillaryError":407}],406:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -34953,7 +45471,7 @@ var GraphMapillaryError = /** @class */ (function (_super) { exports.GraphMapillaryError = GraphMapillaryError; exports.default = GraphMapillaryError; -},{"./MapillaryError":380}],380:[function(require,module,exports){ +},{"./MapillaryError":407}],407:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -34982,7 +45500,7 @@ var MapillaryError = /** @class */ (function (_super) { exports.MapillaryError = MapillaryError; exports.default = MapillaryError; -},{}],381:[function(require,module,exports){ +},{}],408:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var THREE = require("three"); @@ -35131,9 +45649,10 @@ var Camera = /** @class */ (function () { }()); exports.Camera = Camera; -},{"three":225}],382:[function(require,module,exports){ +},{"three":242}],409:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +var THREE = require("three"); var Geo_1 = require("../Geo"); var geoCoords = new Geo_1.GeoCoords(); var spatial = new Geo_1.Spatial(); @@ -35144,8 +45663,36 @@ function computeTranslation(position, rotation, reference) { return translation; } exports.computeTranslation = computeTranslation; +function computeProjectedPoints(transform, basicVertices, basicDirections, pointsPerLine, viewportCoords) { + var basicPoints = []; + for (var side = 0; side < basicVertices.length; ++side) { + var v = basicVertices[side]; + var d = basicDirections[side]; + for (var i = 0; i <= pointsPerLine; ++i) { + basicPoints.push([v[0] + d[0] * i / pointsPerLine, + v[1] + d[1] * i / pointsPerLine]); + } + } + var camera = new THREE.Camera(); + camera.up.copy(transform.upVector()); + camera.position.copy(new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 0))); + camera.lookAt(new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 10))); + camera.updateMatrix(); + camera.updateMatrixWorld(true); + var projectedPoints = basicPoints + .map(function (basicPoint) { + var worldPoint = transform.unprojectBasic(basicPoint, 10000); + var cameraPoint = viewportCoords.worldToCamera(worldPoint, camera); + return [ + Math.abs(cameraPoint[0] / cameraPoint[2]), + Math.abs(cameraPoint[1] / cameraPoint[2]), + ]; + }); + return projectedPoints; +} +exports.computeProjectedPoints = computeProjectedPoints; -},{"../Geo":277}],383:[function(require,module,exports){ +},{"../Geo":294,"three":242}],410:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** @@ -35369,7 +45916,7 @@ var GeoCoords = /** @class */ (function () { exports.GeoCoords = GeoCoords; exports.default = GeoCoords; -},{}],384:[function(require,module,exports){ +},{}],411:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function sign(n) { @@ -35442,7 +45989,7 @@ function segmentIntersection(s1, s2) { } exports.segmentIntersection = segmentIntersection; -},{}],385:[function(require,module,exports){ +},{}],412:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var THREE = require("three"); @@ -35645,6 +46192,13 @@ var Spatial = /** @class */ (function () { var projection = v.dot(new THREE.Vector3().fromArray(planeNormal)); return Math.asin(projection / norm); }; + Spatial.prototype.azimuthal = function (direction, up) { + var directionVector = new THREE.Vector3().fromArray(direction); + var upVector = new THREE.Vector3().fromArray(up); + var upProjection = directionVector.clone().dot(upVector); + var planeProjection = directionVector.clone().sub(upVector.clone().multiplyScalar(upProjection)); + return Math.atan2(planeProjection.y, planeProjection.x); + }; /** * Calculates the distance between two coordinates * (latitude longitude pairs) in meters according to @@ -35671,7 +46225,7 @@ var Spatial = /** @class */ (function () { exports.Spatial = Spatial; exports.default = Spatial; -},{"three":225}],386:[function(require,module,exports){ +},{"three":242}],413:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var THREE = require("three"); @@ -35694,7 +46248,7 @@ var Transform = /** @class */ (function () { * @param {Array} translation - Translation vector in three dimensions. * @param {HTMLImageElement} image - Image for fallback size calculations. */ - function Transform(orientation, width, height, focal, scale, gpano, rotation, translation, image, textureScale, ck1, ck2) { + function Transform(orientation, width, height, focal, scale, gpano, rotation, translation, image, textureScale, ck1, ck2, cameraProjection) { this._orientation = this._getValue(orientation, 1); var imageWidth = image != null ? image.width : 4; var imageHeight = image != null ? image.height : 3; @@ -35715,6 +46269,11 @@ var Transform = /** @class */ (function () { this._textureScale = !!textureScale ? textureScale : [1, 1]; this._ck1 = !!ck1 ? ck1 : 0; this._ck2 = !!ck2 ? ck2 : 0; + this._cameraProjection = !!cameraProjection ? + cameraProjection : + !!gpano ? + "equirectangular" : + "perspective"; this._radialPeak = this._getRadialPeak(this._ck1, this._ck2); } Object.defineProperty(Transform.prototype, "ck1", { @@ -35731,6 +46290,13 @@ var Transform = /** @class */ (function () { enumerable: true, configurable: true }); + Object.defineProperty(Transform.prototype, "cameraProjection", { + get: function () { + return this._cameraProjection; + }, + enumerable: true, + configurable: true + }); Object.defineProperty(Transform.prototype, "basicAspect", { /** * Get basic aspect. @@ -36035,18 +46601,21 @@ var Transform = /** @class */ (function () { var z = Math.cos(lat) * Math.cos(lon); return [x, y, z]; } - else { + else if (this._cameraProjection === "fisheye") { var _a = [sfm[0] / this._focal, sfm[1] / this._focal], dxn = _a[0], dyn = _a[1]; - var rp = this._radialPeak; + var dTheta = Math.sqrt(dxn * dxn + dyn * dyn); + var d = this._distortionFromDistortedRadius(dTheta, this._ck1, this._ck2, this._radialPeak); + var theta = dTheta / d; + var z = Math.cos(theta); + var r = Math.sin(theta); + var x = r * dxn / dTheta; + var y = r * dyn / dTheta; + return [x, y, z]; + } + else { + var _b = [sfm[0] / this._focal, sfm[1] / this._focal], dxn = _b[0], dyn = _b[1]; var dr = Math.sqrt(dxn * dxn + dyn * dyn); - var d = 1.0; - for (var i = 0; i < 10; i++) { - var r = dr / d; - if (r > rp) { - r = rp; - } - d = 1 + this._ck1 * Math.pow(r, 2) + this._ck2 * Math.pow(r, 4); - } + var d = this._distortionFromDistortedRadius(dr, this._ck1, this._ck2, this._radialPeak); var xn = dxn / d; var yn = dyn / d; var v = new THREE.Vector3(xn, yn, 1); @@ -36054,6 +46623,23 @@ var Transform = /** @class */ (function () { return [v.x, v.y, v.z]; } }; + /** Compute distortion given the distorted radius. + * + * Solves for d in the equation + * y = d(x, k1, k2) * x + * given the distorted radius, y. + */ + Transform.prototype._distortionFromDistortedRadius = function (distortedRadius, k1, k2, radialPeak) { + var d = 1.0; + for (var i = 0; i < 10; i++) { + var radius = distortedRadius / d; + if (radius > radialPeak) { + radius = radialPeak; + } + d = 1 + k1 * Math.pow(radius, 2) + k2 * Math.pow(radius, 4); + } + return d; + }; /** * Transform bearing vector (3D cartesian coordiantes on the unit sphere) to * SfM coordinates. @@ -36087,6 +46673,25 @@ var Transform = /** @class */ (function () { (fullPanoPixel[1] - this.gpano.CroppedAreaTopPixels - this.gpano.CroppedAreaImageHeightPixels / 2) / size, ]; } + else if (this._cameraProjection === "fisheye") { + if (bearing[2] > 0) { + var x = bearing[0], y = bearing[1], z = bearing[2]; + var r = Math.sqrt(x * x + y * y); + var theta = Math.atan2(r, z); + if (theta > this._radialPeak) { + theta = this._radialPeak; + } + var distortion = 1.0 + Math.pow(theta, 2) * (this._ck1 + Math.pow(theta, 2) * this._ck2); + var s = this._focal * distortion * theta / r; + return [s * x, s * y]; + } + else { + return [ + bearing[0] < 0 ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY, + bearing[1] < 0 ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY, + ]; + } + } else { if (bearing[2] > 0) { var _a = [bearing[0] / bearing[2], bearing[1] / bearing[2]], xn = _a[0], yn = _a[1]; @@ -36311,7 +46916,7 @@ var Transform = /** @class */ (function () { }()); exports.Transform = Transform; -},{"three":225}],387:[function(require,module,exports){ +},{"three":242}],414:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var THREE = require("three"); @@ -36615,6 +47220,24 @@ var ViewportCoords = /** @class */ (function () { var canvas = this.viewportToCanvas(viewport[0], viewport[1], container); return canvas; }; + /** + * Project 3D world coordinates to canvas coordinates safely. If 3D + * point is behind camera null will be returned. + * + * @param {Array} point3D - 3D world coordinates. + * @param {HTMLElement} container - The viewer container. + * @param {THREE.Camera} camera - Camera used in rendering. + * @returns {Array} 2D canvas coordinates. + */ + ViewportCoords.prototype.projectToCanvasSafe = function (point3d, container, camera) { + var pointCamera = this.worldToCamera(point3d, camera); + if (pointCamera[2] > 0) { + return null; + } + var viewport = this.projectToViewport(point3d, camera); + var canvas = this.viewportToCanvas(viewport[0], viewport[1], container); + return canvas; + }; /** * Project 3D world coordinates to viewport coordinates. * @@ -36705,7 +47328,7 @@ exports.ViewportCoords = ViewportCoords; exports.default = ViewportCoords; -},{"three":225}],388:[function(require,module,exports){ +},{"three":242}],415:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** @@ -36793,7 +47416,7 @@ var FilterCreator = /** @class */ (function () { exports.FilterCreator = FilterCreator; exports.default = FilterCreator; -},{}],389:[function(require,module,exports){ +},{}],416:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var rxjs_1 = require("rxjs"); @@ -38004,7 +48627,7 @@ var Graph = /** @class */ (function () { exports.Graph = Graph; exports.default = Graph; -},{"../Edge":275,"../Error":276,"../Graph":278,"rbush":25,"rxjs":26,"rxjs/operators":224}],390:[function(require,module,exports){ +},{"../Edge":292,"../Error":293,"../Graph":295,"rbush":42,"rxjs":43,"rxjs/operators":241}],417:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var geohash = require("latlon-geohash"); @@ -38179,7 +48802,7 @@ var GraphCalculator = /** @class */ (function () { exports.GraphCalculator = GraphCalculator; exports.default = GraphCalculator; -},{"../Error":276,"../Geo":277,"latlon-geohash":21,"three":225}],391:[function(require,module,exports){ +},{"../Error":293,"../Geo":294,"latlon-geohash":21,"three":242}],418:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** @@ -38211,7 +48834,7 @@ var GraphMode; })(GraphMode = exports.GraphMode || (exports.GraphMode = {})); exports.default = GraphMode; -},{}],392:[function(require,module,exports){ +},{}],419:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var rxjs_1 = require("rxjs"); @@ -38571,7 +49194,7 @@ var GraphService = /** @class */ (function () { exports.GraphService = GraphService; exports.default = GraphService; -},{"../Graph":278,"rxjs":26,"rxjs/operators":224}],393:[function(require,module,exports){ +},{"../Graph":295,"rxjs":43,"rxjs/operators":241}],420:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var operators_1 = require("rxjs/operators"); @@ -38620,7 +49243,7 @@ var ImageLoadingService = /** @class */ (function () { }()); exports.ImageLoadingService = ImageLoadingService; -},{"rxjs":26,"rxjs/operators":224}],394:[function(require,module,exports){ +},{"rxjs":43,"rxjs/operators":241}],421:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Pbf = require("pbf"); @@ -38643,7 +49266,7 @@ var MeshReader = /** @class */ (function () { }()); exports.MeshReader = MeshReader; -},{"pbf":23}],395:[function(require,module,exports){ +},{"pbf":40}],422:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var operators_1 = require("rxjs/operators"); @@ -38746,6 +49369,20 @@ var Node = /** @class */ (function () { enumerable: true, configurable: true }); + Object.defineProperty(Node.prototype, "cameraProjection", { + /** + * Get cameraProjection. + * + * @description Will be undefined if SfM has not been run. + * + * @returns {number} The camera projection of the image. + */ + get: function () { + return this._fill.camera_projection_type; + }, + enumerable: true, + configurable: true + }); Object.defineProperty(Node.prototype, "capturedAt", { /** * Get capturedAt. @@ -38774,6 +49411,19 @@ var Node = /** @class */ (function () { enumerable: true, configurable: true }); + Object.defineProperty(Node.prototype, "clusterKey", { + /** + * Get clusterKey. + * + * @returns {string} Unique key of the SfM cluster to which + * the node belongs. + */ + get: function () { + return this._fill.cluster_key; + }, + enumerable: true, + configurable: true + }); Object.defineProperty(Node.prototype, "ck1", { /** * Get ck1. @@ -38974,6 +49624,8 @@ var Node = /** @class */ (function () { * * @returns {ILoadStatus} Value indicating the load status * of the mesh and image. + * + * @ignore */ get: function () { return this._cache.loadStatus; @@ -39185,6 +49837,8 @@ var Node = /** @class */ (function () { * * @returns {IEdgeStatus} Value describing the status of the * sequence edges. + * + * @ignore */ get: function () { return this._cache.sequenceEdges; @@ -39215,6 +49869,8 @@ var Node = /** @class */ (function () { * * @returns {IEdgeStatus} Value describing the status of the * spatial edges. + * + * @ignore */ get: function () { return this._cache.spatialEdges; @@ -39414,7 +50070,7 @@ var Node = /** @class */ (function () { exports.Node = Node; exports.default = Node; -},{"rxjs/operators":224}],396:[function(require,module,exports){ +},{"rxjs/operators":241}],423:[function(require,module,exports){ (function (Buffer){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); @@ -39836,7 +50492,7 @@ exports.default = NodeCache; }).call(this,require("buffer").Buffer) -},{"../Graph":278,"../Utils":284,"buffer":7,"rxjs":26,"rxjs/operators":224}],397:[function(require,module,exports){ +},{"../Graph":295,"../Utils":301,"buffer":7,"rxjs":43,"rxjs/operators":241}],424:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** @@ -39924,7 +50580,7 @@ var Sequence = /** @class */ (function () { exports.Sequence = Sequence; exports.default = Sequence; -},{}],398:[function(require,module,exports){ +},{}],425:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var THREE = require("three"); @@ -40525,7 +51181,7 @@ var EdgeCalculator = /** @class */ (function () { exports.EdgeCalculator = EdgeCalculator; exports.default = EdgeCalculator; -},{"../../Edge":275,"../../Error":276,"../../Geo":277,"three":225}],399:[function(require,module,exports){ +},{"../../Edge":292,"../../Error":293,"../../Geo":294,"three":242}],426:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var EdgeCalculatorCoefficients = /** @class */ (function () { @@ -40551,7 +51207,7 @@ var EdgeCalculatorCoefficients = /** @class */ (function () { exports.EdgeCalculatorCoefficients = EdgeCalculatorCoefficients; exports.default = EdgeCalculatorCoefficients; -},{}],400:[function(require,module,exports){ +},{}],427:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Edge_1 = require("../../Edge"); @@ -40624,7 +51280,7 @@ var EdgeCalculatorDirections = /** @class */ (function () { }()); exports.EdgeCalculatorDirections = EdgeCalculatorDirections; -},{"../../Edge":275}],401:[function(require,module,exports){ +},{"../../Edge":292}],428:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var EdgeCalculatorSettings = /** @class */ (function () { @@ -40661,7 +51317,7 @@ var EdgeCalculatorSettings = /** @class */ (function () { exports.EdgeCalculatorSettings = EdgeCalculatorSettings; exports.default = EdgeCalculatorSettings; -},{}],402:[function(require,module,exports){ +},{}],429:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** @@ -40719,7 +51375,7 @@ var EdgeDirection; EdgeDirection[EdgeDirection["Similar"] = 10] = "Similar"; })(EdgeDirection = exports.EdgeDirection || (exports.EdgeDirection = {})); -},{}],403:[function(require,module,exports){ +},{}],430:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var rxjs_1 = require("rxjs"); @@ -40896,7 +51552,7 @@ exports.DOMRenderer = DOMRenderer; exports.default = DOMRenderer; -},{"../Render":280,"rxjs":26,"rxjs/operators":224,"virtual-dom":230}],404:[function(require,module,exports){ +},{"../Render":297,"rxjs":43,"rxjs/operators":241,"virtual-dom":247}],431:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var GLRenderStage; @@ -40906,7 +51562,7 @@ var GLRenderStage; })(GLRenderStage = exports.GLRenderStage || (exports.GLRenderStage = {})); exports.default = GLRenderStage; -},{}],405:[function(require,module,exports){ +},{}],432:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var rxjs_1 = require("rxjs"); @@ -41122,7 +51778,7 @@ exports.GLRenderer = GLRenderer; exports.default = GLRenderer; -},{"../Render":280,"../Utils":284,"rxjs":26,"rxjs/operators":224,"three":225}],406:[function(require,module,exports){ +},{"../Render":297,"../Utils":301,"rxjs":43,"rxjs/operators":241,"three":242}],433:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var THREE = require("three"); @@ -41210,6 +51866,20 @@ var RenderCamera = /** @class */ (function () { enumerable: true, configurable: true }); + RenderCamera.prototype.getTilt = function () { + return 90 - this._spatial.radToDeg(this._rotation.theta); + }; + RenderCamera.prototype.fovToZoom = function (fov) { + fov = Math.min(90, Math.max(0, fov)); + var currentFov = this._computeCurrentFov(0); + var actualFov = this._alpha === 1 ? + currentFov : + this._interpolateFov(currentFov, this._computePreviousFov(0), this._alpha); + var y0 = Math.tan(actualFov / 2 * Math.PI / 180); + var y1 = Math.tan(fov / 2 * Math.PI / 180); + var zoom = Math.log(y0 / y1) / Math.log(2); + return zoom; + }; RenderCamera.prototype.setFrame = function (frame) { var state = frame.state; if (state.state !== this._state) { @@ -41236,8 +51906,8 @@ var RenderCamera = /** @class */ (function () { this._changed = true; } if (this._changed) { - this._currentFov = this._computeCurrentFov(); - this._previousFov = this._computePreviousFov(); + this._currentFov = this._computeCurrentFov(this.zoom); + this._previousFov = this._computePreviousFov(this._zoom); } var alpha = state.alpha; if (this._changed || alpha !== this._alpha) { @@ -41278,59 +51948,40 @@ var RenderCamera = /** @class */ (function () { RenderCamera.prototype._computeAspect = function (elementWidth, elementHeight) { return elementWidth === 0 ? 0 : elementWidth / elementHeight; }; - RenderCamera.prototype._computeCurrentFov = function () { + RenderCamera.prototype._computeCurrentFov = function (zoom) { + if (this._perspective.aspect === 0) { + return 0; + } if (!this._currentNodeId) { return this._initialFov; } return this._currentPano ? - this._yToFov(1, this._zoom) : - this._computeVerticalFov(this._currentProjectedPoints, this._renderMode, this._zoom, this.perspective.aspect); + this._yToFov(1, zoom) : + this._computeVerticalFov(this._currentProjectedPoints, this._renderMode, zoom, this.perspective.aspect); }; RenderCamera.prototype._computeFov = function () { - this._currentFov = this._computeCurrentFov(); - this._previousFov = this._computePreviousFov(); + this._currentFov = this._computeCurrentFov(this._zoom); + this._previousFov = this._computePreviousFov(this._zoom); return this._interpolateFov(this._currentFov, this._previousFov, this._alpha); }; - RenderCamera.prototype._computePreviousFov = function () { + RenderCamera.prototype._computePreviousFov = function (zoom) { + if (this._perspective.aspect === 0) { + return 0; + } if (!this._currentNodeId) { return this._initialFov; } return !this._previousNodeId ? this._currentFov : this._previousPano ? - this._yToFov(1, this._zoom) : - this._computeVerticalFov(this._previousProjectedPoints, this._renderMode, this._zoom, this.perspective.aspect); + this._yToFov(1, zoom) : + this._computeVerticalFov(this._previousProjectedPoints, this._renderMode, zoom, this.perspective.aspect); }; RenderCamera.prototype._computeProjectedPoints = function (transform) { - var _this = this; - var os = [[0.5, 0], [1, 0]]; - var ds = [[0.5, 0], [0, 0.5]]; - var pointsPerSide = 100; - var basicPoints = []; - for (var side = 0; side < os.length; ++side) { - var o = os[side]; - var d = ds[side]; - for (var i = 0; i <= pointsPerSide; ++i) { - basicPoints.push([o[0] + d[0] * i / pointsPerSide, - o[1] + d[1] * i / pointsPerSide]); - } - } - var camera = new THREE.Camera(); - camera.up.copy(transform.upVector()); - camera.position.copy(new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 0))); - camera.lookAt(new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 10))); - camera.updateMatrix(); - camera.updateMatrixWorld(true); - var projectedPoints = basicPoints - .map(function (basicPoint) { - var worldPoint = transform.unprojectBasic(basicPoint, 10000); - var cameraPoint = _this._viewportCoords.worldToCamera(worldPoint, camera); - return [ - Math.abs(cameraPoint[0] / cameraPoint[2]), - Math.abs(cameraPoint[1] / cameraPoint[2]), - ]; - }); - return projectedPoints; + var vertices = [[0.5, 0], [1, 0]]; + var directions = [[0.5, 0], [0, 0.5]]; + var pointsPerLine = 100; + return Geo_1.Geo.computeProjectedPoints(transform, vertices, directions, pointsPerLine, this._viewportCoords); }; RenderCamera.prototype._computeRequiredVerticalFov = function (projectedPoint, zoom, aspect) { var maxY = Math.max(projectedPoint[0] / aspect, projectedPoint[1]); @@ -41339,9 +51990,7 @@ var RenderCamera = /** @class */ (function () { RenderCamera.prototype._computeRotation = function (camera) { var direction = camera.lookat.clone().sub(camera.position); var up = camera.up.clone(); - var upProjection = direction.clone().dot(up); - var planeProjection = direction.clone().sub(up.clone().multiplyScalar(upProjection)); - var phi = Math.atan2(planeProjection.y, planeProjection.x); + var phi = this._spatial.azimuthal(direction.toArray(), up.toArray()); var theta = Math.PI / 2 - this._spatial.angleToPlane(direction.toArray(), [0, 0, 1]); return { phi: phi, theta: theta }; }; @@ -41373,7 +52022,7 @@ var RenderCamera = /** @class */ (function () { exports.RenderCamera = RenderCamera; exports.default = RenderCamera; -},{"../Geo":277,"../Render":280,"../State":281,"three":225}],407:[function(require,module,exports){ +},{"../Geo":294,"../Render":297,"../State":298,"three":242}],434:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** @@ -41409,7 +52058,7 @@ var RenderMode; })(RenderMode = exports.RenderMode || (exports.RenderMode = {})); exports.default = RenderMode; -},{}],408:[function(require,module,exports){ +},{}],435:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var operators_1 = require("rxjs/operators"); @@ -41529,7 +52178,7 @@ exports.RenderService = RenderService; exports.default = RenderService; -},{"../Geo":277,"../Render":280,"rxjs":26,"rxjs/operators":224}],409:[function(require,module,exports){ +},{"../Geo":294,"../Render":297,"rxjs":43,"rxjs/operators":241}],436:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var FrameGenerator = /** @class */ (function () { @@ -41578,7 +52227,7 @@ var FrameGenerator = /** @class */ (function () { exports.FrameGenerator = FrameGenerator; exports.default = FrameGenerator; -},{}],410:[function(require,module,exports){ +},{}],437:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var RotationDelta = /** @class */ (function () { @@ -41641,7 +52290,7 @@ var RotationDelta = /** @class */ (function () { exports.RotationDelta = RotationDelta; exports.default = RotationDelta; -},{}],411:[function(require,module,exports){ +},{}],438:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var State; @@ -41653,7 +52302,7 @@ var State; })(State = exports.State || (exports.State = {})); exports.default = State; -},{}],412:[function(require,module,exports){ +},{}],439:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var State_1 = require("../State"); @@ -41881,7 +52530,7 @@ var StateContext = /** @class */ (function () { }()); exports.StateContext = StateContext; -},{"../Geo":277,"../State":281}],413:[function(require,module,exports){ +},{"../Geo":294,"../State":298}],440:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var rxjs_1 = require("rxjs"); @@ -42235,7 +52884,7 @@ var StateService = /** @class */ (function () { }()); exports.StateService = StateService; -},{"../State":281,"rxjs":26,"rxjs/operators":224}],414:[function(require,module,exports){ +},{"../State":298,"rxjs":43,"rxjs/operators":241}],441:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** @@ -42266,7 +52915,7 @@ var TransitionMode; })(TransitionMode = exports.TransitionMode || (exports.TransitionMode = {})); exports.default = TransitionMode; -},{}],415:[function(require,module,exports){ +},{}],442:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -42350,7 +52999,7 @@ exports.EarthState = EarthState; exports.default = EarthState; -},{"../../State":281,"three":225}],416:[function(require,module,exports){ +},{"../../State":298,"three":242}],443:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -42395,6 +53044,9 @@ var InteractiveStateBase = /** @class */ (function (_super) { if (this._currentNode == null) { return; } + if (rotationDelta.phi === 0 && rotationDelta.theta === 0) { + return; + } this._desiredZoom = this._zoom; this._desiredLookat = null; this._requestedBasicRotation = null; @@ -42693,7 +53345,8 @@ var InteractiveStateBase = /** @class */ (function (_super) { if (this._rotationDelta.isZero) { return; } - this._rotationDelta.multiply(this._rotationAcceleration); + var alpha = this.currentNode.fullPano ? 1 : this._alpha; + this._rotationDelta.multiply(this._rotationAcceleration * alpha); this._rotationDelta.threshold(this._rotationThreshold); }; InteractiveStateBase.prototype._updateRotationBasic = function () { @@ -42784,7 +53437,7 @@ exports.InteractiveStateBase = InteractiveStateBase; exports.default = InteractiveStateBase; -},{"../../State":281,"three":225}],417:[function(require,module,exports){ +},{"../../State":298,"three":242}],444:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -42869,7 +53522,7 @@ var InteractiveWaitingState = /** @class */ (function (_super) { exports.InteractiveWaitingState = InteractiveWaitingState; exports.default = InteractiveWaitingState; -},{"../../State":281}],418:[function(require,module,exports){ +},{"../../State":298}],445:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Error_1 = require("../../Error"); @@ -42892,7 +53545,7 @@ var StateBase = /** @class */ (function () { for (var _i = 0, _a = this._trajectory; _i < _a.length; _i++) { var node = _a[_i]; var translation = this._nodeToTranslation(node, this._reference); - var transform = new Geo_1.Transform(node.orientation, node.width, node.height, node.focal, node.scale, node.gpano, node.rotation, translation, node.image, undefined, node.ck1, node.ck2); + var transform = new Geo_1.Transform(node.orientation, node.width, node.height, node.focal, node.scale, node.gpano, node.rotation, translation, node.image, undefined, node.ck1, node.ck2, node.cameraProjection); this._trajectoryTransforms.push(transform); this._trajectoryCameras.push(new Geo_1.Camera(transform)); } @@ -43169,7 +53822,7 @@ var StateBase = /** @class */ (function () { throw new Error_1.ArgumentMapillaryError("Assets must be cached when node is added to trajectory"); } var translation = this._nodeToTranslation(node, this.reference); - var transform = new Geo_1.Transform(node.orientation, node.width, node.height, node.focal, node.scale, node.gpano, node.rotation, translation, node.image, undefined, node.ck1, node.ck2); + var transform = new Geo_1.Transform(node.orientation, node.width, node.height, node.focal, node.scale, node.gpano, node.rotation, translation, node.image, undefined, node.ck1, node.ck2, node.cameraProjection); this._trajectoryTransforms.push(transform); this._trajectoryCameras.push(new Geo_1.Camera(transform)); } @@ -43181,7 +53834,7 @@ var StateBase = /** @class */ (function () { throw new Error_1.ArgumentMapillaryError("Assets must be cached when added to trajectory"); } var translation = this._nodeToTranslation(node, this.reference); - var transform = new Geo_1.Transform(node.orientation, node.width, node.height, node.focal, node.scale, node.gpano, node.rotation, translation, node.image, undefined, node.ck1, node.ck2); + var transform = new Geo_1.Transform(node.orientation, node.width, node.height, node.focal, node.scale, node.gpano, node.rotation, translation, node.image, undefined, node.ck1, node.ck2, node.cameraProjection); this._trajectoryTransforms.unshift(transform); this._trajectoryCameras.unshift(new Geo_1.Camera(transform)); } @@ -43209,7 +53862,7 @@ var StateBase = /** @class */ (function () { }()); exports.StateBase = StateBase; -},{"../../Error":276,"../../Geo":277,"../../State":281}],419:[function(require,module,exports){ +},{"../../Error":293,"../../Geo":294,"../../State":298}],446:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -43343,7 +53996,7 @@ var TraversingState = /** @class */ (function (_super) { exports.TraversingState = TraversingState; exports.default = TraversingState; -},{"../../State":281,"@mapbox/unitbezier":2}],420:[function(require,module,exports){ +},{"../../State":298,"@mapbox/unitbezier":2}],447:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -43417,7 +54070,7 @@ var WaitingState = /** @class */ (function (_super) { exports.WaitingState = WaitingState; exports.default = WaitingState; -},{"../../State":281}],421:[function(require,module,exports){ +},{"../../State":298}],448:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var rxjs_1 = require("rxjs"); @@ -43509,7 +54162,7 @@ var ImageTileLoader = /** @class */ (function () { exports.ImageTileLoader = ImageTileLoader; exports.default = ImageTileLoader; -},{"rxjs":26}],422:[function(require,module,exports){ +},{"rxjs":43}],449:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** @@ -43577,7 +54230,7 @@ var ImageTileStore = /** @class */ (function () { exports.ImageTileStore = ImageTileStore; exports.default = ImageTileStore; -},{}],423:[function(require,module,exports){ +},{}],450:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Geo_1 = require("../Geo"); @@ -43717,7 +54370,7 @@ var RegionOfInterestCalculator = /** @class */ (function () { exports.RegionOfInterestCalculator = RegionOfInterestCalculator; exports.default = RegionOfInterestCalculator; -},{"../Geo":277}],424:[function(require,module,exports){ +},{"../Geo":294}],451:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var operators_1 = require("rxjs/operators"); @@ -44193,7 +54846,7 @@ var TextureProvider = /** @class */ (function () { exports.TextureProvider = TextureProvider; exports.default = TextureProvider; -},{"rxjs":26,"rxjs/operators":224,"three":225}],425:[function(require,module,exports){ +},{"rxjs":43,"rxjs/operators":241,"three":242}],452:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var DOM = /** @class */ (function () { @@ -44222,7 +54875,7 @@ var DOM = /** @class */ (function () { exports.DOM = DOM; exports.default = DOM; -},{}],426:[function(require,module,exports){ +},{}],453:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var EventEmitter = /** @class */ (function () { @@ -44281,7 +54934,7 @@ var EventEmitter = /** @class */ (function () { exports.EventEmitter = EventEmitter; exports.default = EventEmitter; -},{}],427:[function(require,module,exports){ +},{}],454:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Viewer_1 = require("../Viewer"); @@ -44325,7 +54978,7 @@ var Settings = /** @class */ (function () { exports.Settings = Settings; exports.default = Settings; -},{"../Viewer":285}],428:[function(require,module,exports){ +},{"../Viewer":302}],455:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function isBrowser() { @@ -44395,7 +55048,7 @@ function isWebGLSupported() { } exports.isWebGLSupported = isWebGLSupported; -},{}],429:[function(require,module,exports){ +},{}],456:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Urls = /** @class */ (function () { @@ -44429,8 +55082,8 @@ var Urls = /** @class */ (function () { enumerable: true, configurable: true }); - Urls.atomicReconstruction = function (key) { - return Urls._scheme + "://" + Urls._atomicReconstructionHost + "/" + key + "/sfm/v1.0/atomic_reconstruction.json"; + Urls.clusterReconstruction = function (key) { + return Urls._scheme + "://" + Urls._clusterReconstructionHost + "/" + key + "/v1.0/aligned.jsonz"; }; Urls.exporeImage = function (key) { return Urls._scheme + "://" + Urls._exploreHost + "/app/?pKey=" + key + "&focus=photo"; @@ -44455,8 +55108,8 @@ var Urls = /** @class */ (function () { if (!!options.apiHost) { Urls._apiHost = options.apiHost; } - if (!!options.atomicReconstructionHost) { - Urls._atomicReconstructionHost = options.atomicReconstructionHost; + if (!!options.clusterReconstructionHost) { + Urls._clusterReconstructionHost = options.clusterReconstructionHost; } if (!!options.exploreHost) { Urls._exploreHost = options.exploreHost; @@ -44475,11 +55128,11 @@ var Urls = /** @class */ (function () { } }; Urls._apiHost = "a.mapillary.com"; - Urls._atomicReconstructionHost = "d3necqxnn15whe.cloudfront.net"; + Urls._clusterReconstructionHost = "cluster-reconstructions.mapillary.com"; Urls._exploreHost = "www.mapillary.com"; - Urls._imageHost = "d1cuyjsrcm0gby.cloudfront.net"; - Urls._imageTileHost = "d2qb1440i7l50o.cloudfront.net"; - Urls._meshHost = "d1brzeo354iq2l.cloudfront.net"; + Urls._imageHost = "images.mapillary.com"; + Urls._imageTileHost = "loris.mapillary.com"; + Urls._meshHost = "meshes.mapillary.com"; Urls._origin = "mapillary.webgl"; Urls._scheme = "https"; return Urls; @@ -44487,7 +55140,7 @@ var Urls = /** @class */ (function () { exports.Urls = Urls; exports.default = Urls; -},{}],430:[function(require,module,exports){ +},{}],457:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** @@ -44536,7 +55189,7 @@ var Alignment; })(Alignment = exports.Alignment || (exports.Alignment = {})); exports.default = Alignment; -},{}],431:[function(require,module,exports){ +},{}],458:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var rxjs_1 = require("rxjs"); @@ -44620,7 +55273,7 @@ var CacheService = /** @class */ (function () { exports.CacheService = CacheService; exports.default = CacheService; -},{"../Graph":278,"rxjs":26,"rxjs/operators":224}],432:[function(require,module,exports){ +},{"../Graph":295,"rxjs":43,"rxjs/operators":241}],459:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var operators_1 = require("rxjs/operators"); @@ -44654,6 +55307,7 @@ var ComponentController = /** @class */ (function () { _this._subscribeCoverComponent(); _this._navigator.stateService.start(); _this._navigator.cacheService.start(); + _this._navigator.panService.start(); _this._observer.startEmit(); }); } @@ -44680,9 +55334,6 @@ var ComponentController = /** @class */ (function () { ComponentController.prototype.deactivateCover = function () { this._coverComponent.configure({ state: Component_1.CoverState.Loading }); }; - ComponentController.prototype.resize = function () { - this._componentService.resize(); - }; ComponentController.prototype._initializeComponents = function () { var options = this._options; this._uFalse(options.background, "background"); @@ -44743,6 +55394,7 @@ var ComponentController = /** @class */ (function () { .subscribe(function () { _this._navigator.stateService.start(); _this._navigator.cacheService.start(); + _this._navigator.panService.start(); _this._observer.startEmit(); _this._coverComponent.configure({ state: Component_1.CoverState.Hidden }); _this._componentService.deactivateCover(); @@ -44757,6 +55409,7 @@ var ComponentController = /** @class */ (function () { _this._navigator.stateService.stop(); _this._navigator.cacheService.stop(); _this._navigator.playService.stop(); + _this._navigator.panService.stop(); _this._componentService.activateCover(); _this._setNavigable(conf.key == null); } @@ -44800,7 +55453,7 @@ var ComponentController = /** @class */ (function () { }()); exports.ComponentController = ComponentController; -},{"../Component":274,"rxjs/operators":224}],433:[function(require,module,exports){ +},{"../Component":291,"rxjs/operators":241}],460:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Render_1 = require("../Render"); @@ -44851,7 +55504,7 @@ var Container = /** @class */ (function () { exports.Container = Container; exports.default = Container; -},{"../Render":280,"../Utils":284,"../Viewer":285}],434:[function(require,module,exports){ +},{"../Render":297,"../Utils":301,"../Viewer":302}],461:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** @@ -44880,7 +55533,7 @@ var ImageSize; ImageSize[ImageSize["Size2048"] = 2048] = "Size2048"; })(ImageSize = exports.ImageSize || (exports.ImageSize = {})); -},{}],435:[function(require,module,exports){ +},{}],462:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var rxjs_1 = require("rxjs"); @@ -44908,7 +55561,7 @@ var KeyboardService = /** @class */ (function () { exports.KeyboardService = KeyboardService; exports.default = KeyboardService; -},{"rxjs":26}],436:[function(require,module,exports){ +},{"rxjs":43}],463:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var operators_1 = require("rxjs/operators"); @@ -44956,16 +55609,14 @@ var LoadingService = /** @class */ (function () { exports.LoadingService = LoadingService; exports.default = LoadingService; -},{"rxjs":26,"rxjs/operators":224}],437:[function(require,module,exports){ +},{"rxjs":43,"rxjs/operators":241}],464:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var rxjs_1 = require("rxjs"); var operators_1 = require("rxjs/operators"); -var Geo_1 = require("../Geo"); var MouseService = /** @class */ (function () { - function MouseService(container, canvasContainer, domContainer, doc, viewportCoords) { + function MouseService(container, canvasContainer, domContainer, doc) { var _this = this; - viewportCoords = viewportCoords != null ? viewportCoords : new Geo_1.ViewportCoords(); this._activeSubject$ = new rxjs_1.BehaviorSubject(false); this._active$ = this._activeSubject$.pipe(operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount()); this._claimMouse$ = new rxjs_1.Subject(); @@ -45339,7 +55990,7 @@ var MouseService = /** @class */ (function () { exports.MouseService = MouseService; exports.default = MouseService; -},{"../Geo":277,"rxjs":26,"rxjs/operators":224}],438:[function(require,module,exports){ +},{"rxjs":43,"rxjs/operators":241}],465:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var rxjs_1 = require("rxjs"); @@ -45350,8 +56001,9 @@ var Edge_1 = require("../Edge"); var Error_1 = require("../Error"); var State_1 = require("../State"); var Viewer_1 = require("../Viewer"); +var PanService_1 = require("./PanService"); var Navigator = /** @class */ (function () { - function Navigator(clientId, options, token, apiV3, graphService, imageLoadingService, loadingService, stateService, cacheService, playService) { + function Navigator(clientId, options, token, apiV3, graphService, imageLoadingService, loadingService, stateService, cacheService, playService, panService) { this._apiV3 = apiV3 != null ? apiV3 : new API_1.APIv3(clientId, token); this._imageLoadingService = imageLoadingService != null ? imageLoadingService : new Graph_1.ImageLoadingService(); this._graphService = graphService != null ? @@ -45366,6 +56018,9 @@ var Navigator = /** @class */ (function () { this._playService = playService != null ? playService : new Viewer_1.PlayService(this._graphService, this._stateService); + this._panService = panService != null ? + panService : + new PanService_1.PanService(this._graphService, this._stateService, options.combinedPanning); this._keyRequested$ = new rxjs_1.BehaviorSubject(null); this._movedToKey$ = new rxjs_1.BehaviorSubject(null); this._request$ = null; @@ -45414,6 +56069,13 @@ var Navigator = /** @class */ (function () { enumerable: true, configurable: true }); + Object.defineProperty(Navigator.prototype, "panService", { + get: function () { + return this._panService; + }, + enumerable: true, + configurable: true + }); Object.defineProperty(Navigator.prototype, "playService", { get: function () { return this._playService; @@ -45579,7 +56241,7 @@ var Navigator = /** @class */ (function () { exports.Navigator = Navigator; exports.default = Navigator; -},{"../API":273,"../Edge":275,"../Error":276,"../Graph":278,"../State":281,"../Viewer":285,"rxjs":26,"rxjs/operators":224}],439:[function(require,module,exports){ +},{"../API":290,"../Edge":292,"../Error":293,"../Graph":295,"../State":298,"../Viewer":302,"./PanService":467,"rxjs":43,"rxjs/operators":241}],466:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var rxjs_1 = require("rxjs"); @@ -45618,12 +56280,34 @@ var Observer = /** @class */ (function () { enumerable: true, configurable: true }); + Object.defineProperty(Observer.prototype, "projection", { + get: function () { + return this._projection; + }, + enumerable: true, + configurable: true + }); + Observer.prototype.project$ = function (latLon) { + var _this = this; + return rxjs_1.combineLatest(this._container.renderService.renderCamera$, this._navigator.stateService.currentNode$, this._navigator.stateService.reference$).pipe(operators_1.first(), operators_1.map(function (_a) { + var render = _a[0], node = _a[1], reference = _a[2]; + if (_this._projection.distanceBetweenLatLons(latLon, node.latLon) > 1000) { + return null; + } + var canvasPoint = _this._projection.latLonToCanvas(latLon, _this._container.element, render, reference); + return !!canvasPoint ? + [Math.round(canvasPoint[0]), Math.round(canvasPoint[1])] : + null; + })); + }; Observer.prototype.projectBasic$ = function (basicPoint) { var _this = this; return rxjs_1.combineLatest(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$).pipe(operators_1.first(), operators_1.map(function (_a) { var render = _a[0], transform = _a[1]; var canvasPoint = _this._projection.basicToCanvas(basicPoint, _this._container.element, render, transform); - return [Math.round(canvasPoint[0]), Math.round(canvasPoint[1])]; + return !!canvasPoint ? + [Math.round(canvasPoint[0]), Math.round(canvasPoint[1])] : + null; })); }; Observer.prototype.startEmit = function () { @@ -45685,6 +56369,45 @@ var Observer = /** @class */ (function () { .subscribe(function (event) { _this._eventEmitter.fire(event.type, event); }); + this._positionSubscription = this._container.renderService.renderCamera$.pipe(operators_1.distinctUntilChanged(function (_a, _b) { + var x1 = _a[0], y1 = _a[1]; + var x2 = _b[0], y2 = _b[1]; + return _this._closeTo(x1, x2, 1e-2) && + _this._closeTo(y1, y2, 1e-2); + }, function (rc) { + return rc.camera.position.toArray(); + })) + .subscribe(function () { + _this._eventEmitter.fire(Viewer_1.Viewer.positionchanged, { + target: _this._eventEmitter, + type: Viewer_1.Viewer.positionchanged, + }); + }); + this._povSubscription = this._container.renderService.renderCamera$.pipe(operators_1.distinctUntilChanged(function (_a, _b) { + var phi1 = _a[0], theta1 = _a[1]; + var phi2 = _b[0], theta2 = _b[1]; + return _this._closeTo(phi1, phi2, 1e-3) && + _this._closeTo(theta1, theta2, 1e-3); + }, function (rc) { + return [rc.rotation.phi, rc.rotation.theta]; + })) + .subscribe(function () { + _this._eventEmitter.fire(Viewer_1.Viewer.povchanged, { + target: _this._eventEmitter, + type: Viewer_1.Viewer.povchanged, + }); + }); + this._fovSubscription = this._container.renderService.renderCamera$.pipe(operators_1.distinctUntilChanged(function (fov1, fov2) { + return _this._closeTo(fov1, fov2, 1e-2); + }, function (rc) { + return rc.perspective.fov; + })) + .subscribe(function () { + _this._eventEmitter.fire(Viewer_1.Viewer.fovchanged, { + target: _this._eventEmitter, + type: Viewer_1.Viewer.fovchanged, + }); + }); }; Observer.prototype.stopEmit = function () { if (!this.started) { @@ -45693,13 +56416,19 @@ var Observer = /** @class */ (function () { this._started = false; this._bearingSubscription.unsubscribe(); this._currentNodeSubscription.unsubscribe(); + this._fovSubscription.unsubscribe(); this._moveSubscription.unsubscribe(); + this._positionSubscription.unsubscribe(); + this._povSubscription.unsubscribe(); this._sequenceEdgesSubscription.unsubscribe(); this._spatialEdgesSubscription.unsubscribe(); this._viewerMouseEventSubscription.unsubscribe(); this._bearingSubscription = null; this._currentNodeSubscription = null; + this._fovSubscription = null; this._moveSubscription = null; + this._positionSubscription = null; + this._povSubscription = null; this._sequenceEdgesSubscription = null; this._spatialEdgesSubscription = null; this._viewerMouseEventSubscription = null; @@ -45719,6 +56448,9 @@ var Observer = /** @class */ (function () { return _this._projection.canvasToBasic(canvasPoint, _this._container.element, render, transform); })); }; + Observer.prototype._closeTo = function (v1, v2, absoluteTolerance) { + return Math.abs(v1 - v2) <= absoluteTolerance; + }; Observer.prototype._mapMouseEvent$ = function (type, mouseEvent$) { return mouseEvent$.pipe(operators_1.map(function (event) { return [type, event]; @@ -45729,7 +56461,226 @@ var Observer = /** @class */ (function () { exports.Observer = Observer; exports.default = Observer; -},{"../Viewer":285,"rxjs":26,"rxjs/operators":224}],440:[function(require,module,exports){ +},{"../Viewer":302,"rxjs":43,"rxjs/operators":241}],467:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var rxjs_1 = require("rxjs"); +var operators_1 = require("rxjs/operators"); +var Geo = require("../geo/Geo"); +var GeoCoords_1 = require("../geo/GeoCoords"); +var GraphCalculator_1 = require("../graph/GraphCalculator"); +var Spatial_1 = require("../geo/Spatial"); +var Transform_1 = require("../geo/Transform"); +var ViewportCoords_1 = require("../geo/ViewportCoords"); +var PanMode; +(function (PanMode) { + PanMode[PanMode["Disabled"] = 0] = "Disabled"; + PanMode[PanMode["Enabled"] = 1] = "Enabled"; + PanMode[PanMode["Started"] = 2] = "Started"; +})(PanMode || (PanMode = {})); +var PanService = /** @class */ (function () { + function PanService(graphService, stateService, enabled, geoCoords, graphCalculator, spatial, viewportCoords) { + this._graphService = graphService; + this._stateService = stateService; + this._geoCoords = !!geoCoords ? geoCoords : new GeoCoords_1.default(); + this._graphCalculator = !!graphCalculator ? graphCalculator : new GraphCalculator_1.default(this._geoCoords); + this._spatial = !!spatial ? spatial : new Spatial_1.default(); + this._viewportCoords = !!viewportCoords ? viewportCoords : new ViewportCoords_1.default(); + this._mode = enabled !== false ? PanMode.Enabled : PanMode.Disabled; + this._panNodesSubject$ = new rxjs_1.Subject(); + this._panNodes$ = this._panNodesSubject$.pipe(operators_1.startWith([]), operators_1.publishReplay(1), operators_1.refCount()); + this._panNodes$.subscribe(); + } + Object.defineProperty(PanService.prototype, "panNodes$", { + get: function () { + return this._panNodes$; + }, + enumerable: true, + configurable: true + }); + PanService.prototype.enable = function () { + if (this._mode !== PanMode.Disabled) { + return; + } + this._mode = PanMode.Enabled; + this.start(); + }; + PanService.prototype.disable = function () { + if (this._mode === PanMode.Disabled) { + return; + } + this.stop(); + this._mode = PanMode.Disabled; + }; + PanService.prototype.start = function () { + var _this = this; + if (this._mode !== PanMode.Enabled) { + return; + } + var panNodes$ = this._stateService.currentNode$.pipe(operators_1.switchMap(function (current) { + if (!current.merged) { + return rxjs_1.of([]); + } + var current$ = rxjs_1.of(current); + var bounds = _this._graphCalculator.boundingBoxCorners(current.latLon, 20); + var adjacent$ = _this._graphService + .cacheBoundingBox$(bounds[0], bounds[1]).pipe(operators_1.catchError(function (error) { + console.error("Failed to cache periphery bounding box (" + current.key + ")", error); + return rxjs_1.empty(); + }), operators_1.map(function (nodes) { + if (current.pano) { + return []; + } + var potential = []; + for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { + var node = nodes_1[_i]; + if (node.key === current.key) { + continue; + } + if (node.mergeCC !== current.mergeCC) { + continue; + } + if (node.pano) { + continue; + } + if (_this._distance(node, current) > 4) { + continue; + } + potential.push(node); + } + return potential; + })); + return rxjs_1.combineLatest(current$, adjacent$).pipe(operators_1.withLatestFrom(_this._stateService.reference$), operators_1.map(function (_a) { + var _b = _a[0], cn = _b[0], adjacent = _b[1], reference = _a[1]; + var currentDirection = _this._spatial.viewingDirection(cn.rotation); + var currentTranslation = Geo.computeTranslation({ lat: cn.latLon.lat, lon: cn.latLon.lon, alt: cn.alt }, cn.rotation, reference); + var currentTransform = _this._createTransform(cn, currentTranslation); + var currentAzimuthal = _this._spatial.wrap(_this._spatial.azimuthal(currentDirection.toArray(), currentTransform.upVector().toArray()), 0, 2 * Math.PI); + var currentProjectedPoints = _this._computeProjectedPoints(currentTransform); + var currentHFov = _this._computeHorizontalFov(currentProjectedPoints) / 180 * Math.PI; + var preferredOverlap = Math.PI / 8; + var left = undefined; + var right = undefined; + for (var _i = 0, adjacent_1 = adjacent; _i < adjacent_1.length; _i++) { + var a = adjacent_1[_i]; + var translation = Geo.computeTranslation({ lat: a.latLon.lat, lon: a.latLon.lon, alt: a.alt }, a.rotation, reference); + var transform = _this._createTransform(a, translation); + var projectedPoints = _this._computeProjectedPoints(transform); + var hFov = _this._computeHorizontalFov(projectedPoints) / 180 * Math.PI; + var direction = _this._spatial.viewingDirection(a.rotation); + var azimuthal = _this._spatial.wrap(_this._spatial.azimuthal(direction.toArray(), transform.upVector().toArray()), 0, 2 * Math.PI); + var directionChange = _this._spatial.angleBetweenVector2(currentDirection.x, currentDirection.y, direction.x, direction.y); + var overlap = Number.NEGATIVE_INFINITY; + if (directionChange > 0) { + if (currentAzimuthal > azimuthal) { + overlap = currentAzimuthal - 2 * Math.PI + currentHFov / 2 - (azimuthal - hFov / 2); + } + else { + overlap = currentAzimuthal + currentHFov / 2 - (azimuthal - hFov / 2); + } + } + else { + if (currentAzimuthal < azimuthal) { + overlap = azimuthal + hFov / 2 - (currentAzimuthal + 2 * Math.PI - currentHFov / 2); + } + else { + overlap = azimuthal + hFov / 2 - (currentAzimuthal - currentHFov / 2); + } + } + var nonOverlap = Math.abs(hFov - overlap); + var distanceCost = _this._distance(a, cn); + var timeCost = Math.min(_this._timeDifference(a, cn), 4); + var overlapCost = 20 * Math.abs(overlap - preferredOverlap); + var fovCost = Math.min(5, 1 / Math.min(hFov / currentHFov, 1)); + var nonOverlapCost = overlap > 0 ? -2 * nonOverlap : 0; + var cost = distanceCost + timeCost + overlapCost + fovCost + nonOverlapCost; + if (overlap > 0 && + overlap < 0.5 * currentHFov && + overlap < 0.5 * hFov && + nonOverlap > 0.5 * currentHFov) { + if (directionChange > 0) { + if (!left) { + left = [cost, a, transform, hFov]; + } + else { + if (cost < left[0]) { + left = [cost, a, transform, hFov]; + } + } + } + else { + if (!right) { + right = [cost, a, transform, hFov]; + } + else { + if (cost < right[0]) { + right = [cost, a, transform, hFov]; + } + } + } + } + } + var panNodes = []; + if (!!left) { + panNodes.push([left[1], left[2], left[3]]); + } + if (!!right) { + panNodes.push([right[1], right[2], right[3]]); + } + return panNodes; + }), operators_1.startWith([])); + })); + this._panNodesSubscription = this._stateService.currentState$.pipe(operators_1.map(function (frame) { + return frame.state.nodesAhead > 0; + }), operators_1.distinctUntilChanged(), operators_1.switchMap(function (traversing) { + return traversing ? rxjs_1.of([]) : panNodes$; + })) + .subscribe(function (panNodes) { + _this._panNodesSubject$.next(panNodes); + }); + this._mode = PanMode.Started; + }; + PanService.prototype.stop = function () { + if (this._mode !== PanMode.Started) { + return; + } + this._panNodesSubscription.unsubscribe(); + this._panNodesSubject$.next([]); + this._mode = PanMode.Enabled; + }; + PanService.prototype._distance = function (node, reference) { + var _a = this._geoCoords.geodeticToEnu(node.latLon.lat, node.latLon.lon, node.alt, reference.latLon.lat, reference.latLon.lon, reference.alt), x = _a[0], y = _a[1], z = _a[2]; + return Math.sqrt(x * x + y * y + z * z); + }; + PanService.prototype._timeDifference = function (node, reference) { + return Math.abs(node.capturedAt - reference.capturedAt) / (1000 * 60 * 60 * 24 * 30); + }; + PanService.prototype._createTransform = function (node, translation) { + return new Transform_1.Transform(node.orientation, node.width, node.height, node.focal, node.scale, node.gpano, node.rotation, translation, node.assetsCached ? node.image : undefined, undefined, node.ck1, node.ck2, node.cameraProjection); + }; + PanService.prototype._computeProjectedPoints = function (transform) { + var vertices = [[1, 0]]; + var directions = [[0, 0.5]]; + var pointsPerLine = 20; + return Geo.computeProjectedPoints(transform, vertices, directions, pointsPerLine, this._viewportCoords); + }; + PanService.prototype._computeHorizontalFov = function (projectedPoints) { + var _this = this; + var fovs = projectedPoints + .map(function (projectedPoint) { + return _this._coordToFov(projectedPoint[0]); + }); + var fov = Math.min.apply(Math, fovs); + return fov; + }; + PanService.prototype._coordToFov = function (x) { + return 2 * Math.atan(x) * 180 / Math.PI; + }; + return PanService; +}()); +exports.PanService = PanService; + +},{"../geo/Geo":409,"../geo/GeoCoords":410,"../geo/Spatial":412,"../geo/Transform":413,"../geo/ViewportCoords":414,"../graph/GraphCalculator":417,"rxjs":43,"rxjs/operators":241}],468:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var rxjs_1 = require("rxjs"); @@ -46050,19 +57001,21 @@ var PlayService = /** @class */ (function () { exports.PlayService = PlayService; exports.default = PlayService; -},{"../Edge":275,"../Graph":278,"rxjs":26,"rxjs/operators":224}],441:[function(require,module,exports){ +},{"../Edge":292,"../Graph":295,"rxjs":43,"rxjs/operators":241}],469:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var THREE = require("three"); var Geo_1 = require("../Geo"); +var Spatial_1 = require("../geo/Spatial"); var Projection = /** @class */ (function () { - function Projection(geoCoords, viewportCoords) { + function Projection(geoCoords, viewportCoords, spatial) { this._geoCoords = !!geoCoords ? geoCoords : new Geo_1.GeoCoords(); + this._spatial = !!spatial ? spatial : new Spatial_1.default(); this._viewportCoords = !!viewportCoords ? viewportCoords : new Geo_1.ViewportCoords(); } Projection.prototype.basicToCanvas = function (basicPoint, container, render, transform) { return this._viewportCoords - .basicToCanvas(basicPoint[0], basicPoint[1], container, transform, render.perspective); + .basicToCanvasSafe(basicPoint[0], basicPoint[1], container, transform, render.perspective); }; Projection.prototype.canvasToBasic = function (canvasPoint, container, render, transform) { var basicPoint = this._viewportCoords @@ -46103,12 +57056,25 @@ var Projection = /** @class */ (function () { }; return unprojection; }; + Projection.prototype.cameraToLatLon = function (render, reference) { + var position = render.camera.position; + var _a = this._geoCoords.enuToGeodetic(position.x, position.y, position.z, reference.lat, reference.lon, reference.alt), lat = _a[0], lon = _a[1]; + return { lat: lat, lon: lon }; + }; + Projection.prototype.latLonToCanvas = function (latLon, container, render, reference) { + var point3d = this._geoCoords.geodeticToEnu(latLon.lat, latLon.lon, 0, reference.lat, reference.lon, reference.alt); + var canvas = this._viewportCoords.projectToCanvasSafe(point3d, container, render.perspective); + return canvas; + }; + Projection.prototype.distanceBetweenLatLons = function (latLon1, latLon2) { + return this._spatial.distanceFromLatLon(latLon1.lat, latLon1.lon, latLon2.lat, latLon2.lon); + }; return Projection; }()); exports.Projection = Projection; exports.default = Projection; -},{"../Geo":277,"three":225}],442:[function(require,module,exports){ +},{"../Geo":294,"../geo/Spatial":412,"three":242}],470:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var operators_1 = require("rxjs/operators"); @@ -46301,7 +57267,7 @@ exports.SpriteService = SpriteService; exports.default = SpriteService; -},{"../Viewer":285,"rxjs":26,"rxjs/operators":224,"three":225,"virtual-dom":230}],443:[function(require,module,exports){ +},{"../Viewer":302,"rxjs":43,"rxjs/operators":241,"three":242,"virtual-dom":247}],471:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var rxjs_1 = require("rxjs"); @@ -46525,7 +57491,7 @@ var TouchService = /** @class */ (function () { }()); exports.TouchService = TouchService; -},{"rxjs":26,"rxjs/operators":224}],444:[function(require,module,exports){ +},{"rxjs":43,"rxjs/operators":241}],472:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -46669,7 +57635,7 @@ var Viewer = /** @class */ (function (_super) { * Return a boolean indicating if the viewer is in a navigable state. * * @description The navigable state indicates if the viewer supports - * moving, i.e. calling the {@link moveToKey}, {@link moveDir`} + * moving, i.e. calling the {@link moveToKey}, {@link moveDir} * and {@link moveCloseTo} methods or changing the authentication state, * i.e. calling {@link setAuthToken}. The viewer will not be in a navigable * state if the cover is activated and the viewer has been supplied a key. @@ -46684,6 +57650,14 @@ var Viewer = /** @class */ (function (_super) { enumerable: true, configurable: true }); + /** + * Activate the combined panning functionality. + * + * @description The combined panning functionality is active by default. + */ + Viewer.prototype.activateCombinedPanning = function () { + this._navigator.panService.enable(); + }; /** * Activate a component. * @@ -46703,6 +57677,15 @@ var Viewer = /** @class */ (function (_super) { Viewer.prototype.activateCover = function () { this._componentController.activateCover(); }; + /** + * Deactivate the combined panning functionality. + * + * @description Deactivating the combined panning functionality + * could be needed in scenarios involving sequence only navigation. + */ + Viewer.prototype.deactivateCombinedPanning = function () { + this._navigator.panService.disable(); + }; /** * Deactivate a component. * @@ -46752,6 +57735,17 @@ var Viewer = /** @class */ (function (_super) { }); }); }; + /** + * Returns the HTML element containing the viewer's element. + * + * @description This is the element to which event bindings for viewer + * interactivity (such as panning and zooming) are attached. + * + * @returns {HTMLElement} The container viewer's element. + */ + Viewer.prototype.getCanvasContainer = function () { + return this._container.canvasContainer; + }; /** * Get the basic coordinates of the current image that is * at the center of the viewport. @@ -46802,6 +57796,80 @@ var Viewer = /** @class */ (function (_super) { Viewer.prototype.getContainer = function () { return this._container.element; }; + /** + * Get the viewer's current vertical field of view. + * + * @description The vertical field of view rendered on the viewer canvas + * measured in degrees. + * + * @returns {Promise} Promise to the current field of view + * of the viewer camera. + * + * @example + * ``` + * viewer.getFieldOfView().then((fov) => { console.log(fov); }); + * ``` + */ + Viewer.prototype.getFieldOfView = function () { + var _this = this; + return when.promise(function (resolve, reject) { + _this._container.renderService.renderCamera$.pipe(operators_1.first()) + .subscribe(function (rc) { + resolve(rc.perspective.fov); + }, function (error) { + reject(error); + }); + }); + }; + /** + * Get the viewer's current point of view. + * + * @returns {Promise} Promise to the current point of view + * of the viewer camera. + * + * @example + * ``` + * viewer.getPointOfView().then((pov) => { console.log(pov); }); + * ``` + */ + Viewer.prototype.getPointOfView = function () { + var _this = this; + return when.promise(function (resolve, reject) { + rxjs_1.combineLatest(_this._container.renderService.renderCamera$, _this._container.renderService.bearing$).pipe(operators_1.first()) + .subscribe(function (_a) { + var rc = _a[0], bearing = _a[1]; + resolve({ + bearing: bearing, + tilt: rc.getTilt(), + }); + }, function (error) { + reject(error); + }); + }); + }; + /** + * Get the viewer's current position + * + * @returns {Promise} Promise to the viewers's current + * position. + * + * @example + * ``` + * viewer.getPosition().then((pos) => { console.log(pos); }); + * ``` + */ + Viewer.prototype.getPosition = function () { + var _this = this; + return when.promise(function (resolve, reject) { + rxjs_1.combineLatest(_this._container.renderService.renderCamera$, _this._navigator.stateService.reference$).pipe(operators_1.first()) + .subscribe(function (_a) { + var render = _a[0], reference = _a[1]; + resolve(_this._observer.projection.cameraToLatLon(render, reference)); + }, function (error) { + reject(error); + }); + }); + }; /** * Get the image's current zoom level. * @@ -46837,7 +57905,7 @@ var Viewer = /** @class */ (function (_super) { * longitude. * @throws {Error} Propagates any IO errors to the caller. * @throws {Error} When viewer is not navigable. - * @throws {AbortMapillaryError} When a subsequent move request is made + * @throws {@link AbortMapillaryError} When a subsequent move request is made * before the move close to call has completed. * * @example @@ -46870,7 +57938,7 @@ var Viewer = /** @class */ (function (_super) { * or the edges has not yet been cached. * @throws {Error} Propagates any IO errors to the caller. * @throws {Error} When viewer is not navigable. - * @throws {AbortMapillaryError} When a subsequent move request is made + * @throws {@link AbortMapillaryError} When a subsequent move request is made * before the move dir call has completed. * * @example @@ -46899,7 +57967,7 @@ var Viewer = /** @class */ (function (_super) { * @returns {Promise} Promise to the node that was navigated to. * @throws {Error} Propagates any IO errors to the caller. * @throws {Error} When viewer is not navigable. - * @throws {AbortMapillaryError} When a subsequent move request is made + * @throws {@link AbortMapillaryError} When a subsequent move request is made * before the move to key call has completed. * * @example @@ -46921,12 +57989,60 @@ var Viewer = /** @class */ (function (_super) { }); }); }; + /** + * Project an ILatLon representing geographicalcoordinates to + * canvas pixel coordinates. + * + * @description The geographical coordinates may not always correspond to pixel + * coordinates, e.g. if the geographical coordinates have a position behind the + * viewer camera. In the case of no correspondence the returned value will + * be `null`. + * + * If the distance from the viewer camera position to the provided lat-lon + * is more than 1000 meters `null` will be returned. + * + * The projection is performed from the ground plane, i.e. + * the altitude with respect to the ground plane for the geographical + * point is zero. + * + * Note that whenever the camera moves, the result of the method will be + * different. + * + * @param {ILatLon} latLon - Geographical coordinates to project. + * @returns {Promise>} Promise to the pixel coordinates corresponding + * to the latLon. + * + * @example + * ``` + * viewer.project({ lat: 0, lon: 0 }) + * .then((pixelPoint) => { + * if (!pixelPoint) { + * console.log("no correspondence"); + * } + * + * console.log(pixelPoint); + * }); + * ``` + */ + Viewer.prototype.project = function (latLon) { + var _this = this; + return when.promise(function (resolve, reject) { + _this._observer.project$(latLon) + .subscribe(function (pixelPoint) { + resolve(pixelPoint); + }, function (error) { + reject(error); + }); + }); + }; /** * Project basic image coordinates for the current node to canvas pixel * coordinates. * * @description The basic image coordinates may not always correspond to a - * pixel point that lies in the visible area of the viewer container. + * pixel point that lies in the visible area of the viewer container. In the + * case of no correspondence the returned value can be `null`. + * * * @param {Array} basicPoint - Basic images coordinates to project. * @returns {Promise>} Promise to the pixel coordinates corresponding @@ -46962,7 +58078,6 @@ var Viewer = /** @class */ (function (_super) { */ Viewer.prototype.resize = function () { this._container.renderService.resize$.next(null); - this._componentController.resize(); }; /** * Set a bearer token for authenticated API requests of @@ -47061,12 +58176,30 @@ var Viewer = /** @class */ (function (_super) { * * Clear the filter by setting it to null or empty array. * + * Commonly used filter properties (see the {@link Node} class + * documentation for a full list of properties that can be used + * in a filter) and common use cases: + * + * ``` + * fullPano // Show only full 360 panoramas or not + * organizationKey // Show images from one or several organizations + * sequenceKey // Show images from one or several sequences + * userKey // Show images from one or several users + * capturedAt // Show images from a certain time interval + * ``` + * * @param {FilterExpression} filter - The filter expression. * @returns {Promise} Promise that resolves after filter is applied. * * @example * ``` * viewer.setFilter(["==", "sequenceKey", ""]); + * + * // Other examples + * // viewer.setFilter(["==", "organizationKey", ""]); + * // viewer.setFilter(["in", "userKey", "", ""]); + * // viewer.setFilter(["==", "fullPano", true]); + * // viewer.setFilter([">=", "capturedAt", ]); * ``` */ Viewer.prototype.setFilter = function (filter) { @@ -47080,6 +58213,30 @@ var Viewer = /** @class */ (function (_super) { }); }); }; + /** + * Set the viewer's current vertical field of view. + * + * @description Sets the vertical field of view rendered + * on the viewer canvas measured in degrees. The value + * will be clamped to be able to set a valid zoom level + * based on the projection model of the current image and + * the viewer's current render mode. + * + * @param {number} fov - Vertical field of view in degrees. + * + * @example + * ``` + * viewer.setFieldOfView(45); + * ``` + */ + Viewer.prototype.setFieldOfView = function (fov) { + var _this = this; + this._container.renderService.renderCamera$.pipe(operators_1.first()) + .subscribe(function (rc) { + var zoom = rc.fovToZoom(fov); + _this._navigator.stateService.setZoom(zoom); + }); + }; /** * Set the viewer's render mode. * @@ -47131,6 +58288,9 @@ var Viewer = /** @class */ (function (_super) { * coordinates. In the case of no correspondence the returned value will * be `null`. * + * The unprojection to a latLon will be performed towards the ground plane, i.e. + * the altitude with respect to the ground plane for the returned latLon is zero. + * * @param {Array} pixelPoint - Pixel coordinates to unproject. * @returns {Promise} Promise to the latLon corresponding to the pixel point. * @@ -47184,7 +58344,7 @@ var Viewer = /** @class */ (function (_super) { * Fired when the viewing direction of the camera changes. * * @description Related to the computed compass angle - * ({@link Node.computedCa}) from SfM, not the original EXIF compass + * ({@link Node.computedCA}) from SfM, not the original EXIF compass * angle. * * @event @@ -47196,22 +58356,29 @@ var Viewer = /** @class */ (function (_super) { * Fired when a pointing device (usually a mouse) is pressed and released at * the same point in the viewer. * @event - * @type {IViewerMouseEvent} event - Viewer mouse event data. + * @type {@link IViewerMouseEvent} event - Viewer mouse event data. */ Viewer.click = "click"; /** * Fired when the right button of the mouse is clicked within the viewer. * @event - * @type {IViewerMouseEvent} event - Viewer mouse event data. + * @type {@link IViewerMouseEvent} event - Viewer mouse event data. */ Viewer.contextmenu = "contextmenu"; /** * Fired when a pointing device (usually a mouse) is clicked twice at * the same point in the viewer. * @event - * @type {IViewerMouseEvent} event - Viewer mouse event data. + * @type {@link IViewerMouseEvent} event - Viewer mouse event data. */ Viewer.dblclick = "dblclick"; + /** + * Fired when the viewer's vertical field of view changes. + * + * @event + * @type {@link IViewerEvent} event - The event object. + */ + Viewer.fovchanged = "fovchanged"; /** * Fired when the viewer is loading more data. * @event @@ -47221,32 +58388,32 @@ var Viewer = /** @class */ (function (_super) { /** * Fired when a pointing device (usually a mouse) is pressed within the viewer. * @event - * @type {IViewerMouseEvent} event - Viewer mouse event data. + * @type {@link IViewerMouseEvent} event - Viewer mouse event data. */ Viewer.mousedown = "mousedown"; /** * Fired when a pointing device (usually a mouse) is moved within the viewer. * @description Will not fire when the mouse is actively used, e.g. for drag pan. * @event - * @type {IViewerMouseEvent} event - Viewer mouse event data. + * @type {@link IViewerMouseEvent} event - Viewer mouse event data. */ Viewer.mousemove = "mousemove"; /** * Fired when a pointing device (usually a mouse) leaves the viewer's canvas. * @event - * @type {IViewerMouseEvent} event - Viewer mouse event data. + * @type {@link IViewerMouseEvent} event - Viewer mouse event data. */ Viewer.mouseout = "mouseout"; /** * Fired when a pointing device (usually a mouse) is moved onto the viewer's canvas. * @event - * @type {IViewerMouseEvent} event - Viewer mouse event data. + * @type {@link IViewerMouseEvent} event - Viewer mouse event data. */ Viewer.mouseover = "mouseover"; /** * Fired when a pointing device (usually a mouse) is released within the viewer. * @event - * @type {IViewerMouseEvent} event - Viewer mouse event data. + * @type {@link IViewerMouseEvent} event - Viewer mouse event data. */ Viewer.mouseup = "mouseup"; /** @@ -47278,26 +58445,45 @@ var Viewer = /** @class */ (function (_super) { Viewer.navigablechanged = "navigablechanged"; /** * Fired every time the viewer navigates to a new node. + * * @event - * @type {Node} node - Current node. + * @type {@link Node} node - Current node. */ Viewer.nodechanged = "nodechanged"; + /** + * Fired when the viewer's position changes. + * + * @description The viewer's position changes when transitioning + * between nodes. + * + * @event + * @type {@link IViewerEvent} event - The event object. + */ + Viewer.positionchanged = "positionchanged"; + /** + * Fired when the viewer's point of view changes. The point of view changes + * when the bearing, or tilt changes. + * + * @event + * @type {@link IViewerEvent} event - The event object. + */ + Viewer.povchanged = "povchanged"; /** * Fired every time the sequence edges of the current node changes. * @event - * @type {IEdgeStatus} status - The edge status object. + * @type {@link IEdgeStatus} status - The edge status object. */ Viewer.sequenceedgeschanged = "sequenceedgeschanged"; /** * Fired every time the spatial edges of the current node changes. * @event - * @type {IEdgeStatus} status - The edge status object. + * @type {@link IEdgeStatus} status - The edge status object. */ Viewer.spatialedgeschanged = "spatialedgeschanged"; return Viewer; }(Utils_1.EventEmitter)); exports.Viewer = Viewer; -},{"../Utils":284,"../Viewer":285,"rxjs":26,"rxjs/operators":224,"when":271}]},{},[279])(279) +},{"../Utils":301,"../Viewer":302,"rxjs":43,"rxjs/operators":241,"when":288}]},{},[296])(296) }); //# sourceMappingURL=mapillary.js.map