mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-28 08:26:57 +00:00
595 lines
15 KiB
JavaScript
595 lines
15 KiB
JavaScript
|
"use strict";
|
||
|
|
||
|
(function(e){if("function"==typeof bootstrap)bootstrap("bops",e);else if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeBops=e}else"undefined"!=typeof window?window.bops=e():global.bops=e()})(function(){var define,ses,bootstrap,module,exports;
|
||
|
return (function(e,t,n){function i(n,s){if(!t[n]){if(!e[n]){var o=typeof require=="function"&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);throw new Error("Cannot find module '"+n+"'")}var u=t[n]={exports:{}};e[n][0].call(u.exports,function(t){var r=e[n][1][t];return i(r?r:t)},u,u.exports)}return t[n].exports}var r=typeof require=="function"&&require;for(var s=0;s<n.length;s++)i(n[s]);return i})({1:[function(require,module,exports){
|
||
|
var proto = {}
|
||
|
module.exports = proto
|
||
|
|
||
|
proto.from = require('./from.js')
|
||
|
proto.to = require('./to.js')
|
||
|
proto.is = require('./is.js')
|
||
|
proto.subarray = require('./subarray.js')
|
||
|
proto.join = require('./join.js')
|
||
|
proto.copy = require('./copy.js')
|
||
|
proto.create = require('./create.js')
|
||
|
|
||
|
mix(require('./read.js'), proto)
|
||
|
mix(require('./write.js'), proto)
|
||
|
|
||
|
function mix(from, into) {
|
||
|
for(var key in from) {
|
||
|
into[key] = from[key]
|
||
|
}
|
||
|
}
|
||
|
|
||
|
},{"./from.js":2,"./to.js":3,"./is.js":4,"./subarray.js":5,"./join.js":6,"./copy.js":7,"./create.js":8,"./read.js":9,"./write.js":10}],4:[function(require,module,exports){
|
||
|
|
||
|
module.exports = function(buffer) {
|
||
|
return buffer instanceof Uint8Array;
|
||
|
}
|
||
|
|
||
|
},{}],5:[function(require,module,exports){
|
||
|
module.exports = subarray
|
||
|
|
||
|
function subarray(buf, from, to) {
|
||
|
return buf.subarray(from || 0, to || buf.length)
|
||
|
}
|
||
|
|
||
|
},{}],6:[function(require,module,exports){
|
||
|
module.exports = join
|
||
|
|
||
|
function join(targets, hint) {
|
||
|
if(!targets.length) {
|
||
|
return new Uint8Array(0)
|
||
|
}
|
||
|
|
||
|
var len = hint !== undefined ? hint : get_length(targets)
|
||
|
, out = new Uint8Array(len)
|
||
|
, cur = targets[0]
|
||
|
, curlen = cur.length
|
||
|
, curidx = 0
|
||
|
, curoff = 0
|
||
|
, i = 0
|
||
|
|
||
|
while(i < len) {
|
||
|
if(curoff === curlen) {
|
||
|
curoff = 0
|
||
|
++curidx
|
||
|
cur = targets[curidx]
|
||
|
curlen = cur && cur.length
|
||
|
continue
|
||
|
}
|
||
|
out[i++] = cur[curoff++]
|
||
|
}
|
||
|
|
||
|
return out
|
||
|
}
|
||
|
|
||
|
function get_length(targets) {
|
||
|
var size = 0
|
||
|
for(var i = 0, len = targets.length; i < len; ++i) {
|
||
|
size += targets[i].byteLength
|
||
|
}
|
||
|
return size
|
||
|
}
|
||
|
|
||
|
},{}],7:[function(require,module,exports){
|
||
|
module.exports = copy
|
||
|
|
||
|
var slice = [].slice
|
||
|
|
||
|
function copy(source, target, target_start, source_start, source_end) {
|
||
|
target_start = arguments.length < 3 ? 0 : target_start
|
||
|
source_start = arguments.length < 4 ? 0 : source_start
|
||
|
source_end = arguments.length < 5 ? source.length : source_end
|
||
|
|
||
|
if(source_end === source_start) {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
if(target.length === 0 || source.length === 0) {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
if(source_end > source.length) {
|
||
|
source_end = source.length
|
||
|
}
|
||
|
|
||
|
if(target.length - target_start < source_end - source_start) {
|
||
|
source_end = target.length - target_start + start
|
||
|
}
|
||
|
|
||
|
if(source.buffer !== target.buffer) {
|
||
|
return fast_copy(source, target, target_start, source_start, source_end)
|
||
|
}
|
||
|
return slow_copy(source, target, target_start, source_start, source_end)
|
||
|
}
|
||
|
|
||
|
function fast_copy(source, target, target_start, source_start, source_end) {
|
||
|
var len = (source_end - source_start) + target_start
|
||
|
|
||
|
for(var i = target_start, j = source_start;
|
||
|
i < len;
|
||
|
++i,
|
||
|
++j) {
|
||
|
target[i] = source[j]
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function slow_copy(from, to, j, i, jend) {
|
||
|
// the buffers could overlap.
|
||
|
var iend = jend + i
|
||
|
, tmp = new Uint8Array(slice.call(from, i, iend))
|
||
|
, x = 0
|
||
|
|
||
|
for(; i < iend; ++i, ++x) {
|
||
|
to[j++] = tmp[x]
|
||
|
}
|
||
|
}
|
||
|
|
||
|
},{}],8:[function(require,module,exports){
|
||
|
module.exports = function(size) {
|
||
|
return new Uint8Array(size)
|
||
|
}
|
||
|
|
||
|
},{}],9:[function(require,module,exports){
|
||
|
module.exports = {
|
||
|
readUInt8: read_uint8
|
||
|
, readInt8: read_int8
|
||
|
, readUInt16LE: read_uint16_le
|
||
|
, readUInt32LE: read_uint32_le
|
||
|
, readInt16LE: read_int16_le
|
||
|
, readInt32LE: read_int32_le
|
||
|
, readFloatLE: read_float_le
|
||
|
, readDoubleLE: read_double_le
|
||
|
, readUInt16BE: read_uint16_be
|
||
|
, readUInt32BE: read_uint32_be
|
||
|
, readInt16BE: read_int16_be
|
||
|
, readInt32BE: read_int32_be
|
||
|
, readFloatBE: read_float_be
|
||
|
, readDoubleBE: read_double_be
|
||
|
}
|
||
|
|
||
|
var map = require('./mapped.js')
|
||
|
|
||
|
function read_uint8(target, at) {
|
||
|
return target[at]
|
||
|
}
|
||
|
|
||
|
function read_int8(target, at) {
|
||
|
var v = target[at];
|
||
|
return v < 0x80 ? v : v - 0x100
|
||
|
}
|
||
|
|
||
|
function read_uint16_le(target, at) {
|
||
|
var dv = map.get(target);
|
||
|
return dv.getUint16(at + target.byteOffset, true)
|
||
|
}
|
||
|
|
||
|
function read_uint32_le(target, at) {
|
||
|
var dv = map.get(target);
|
||
|
return dv.getUint32(at + target.byteOffset, true)
|
||
|
}
|
||
|
|
||
|
function read_int16_le(target, at) {
|
||
|
var dv = map.get(target);
|
||
|
return dv.getInt16(at + target.byteOffset, true)
|
||
|
}
|
||
|
|
||
|
function read_int32_le(target, at) {
|
||
|
var dv = map.get(target);
|
||
|
return dv.getInt32(at + target.byteOffset, true)
|
||
|
}
|
||
|
|
||
|
function read_float_le(target, at) {
|
||
|
var dv = map.get(target);
|
||
|
return dv.getFloat32(at + target.byteOffset, true)
|
||
|
}
|
||
|
|
||
|
function read_double_le(target, at) {
|
||
|
var dv = map.get(target);
|
||
|
return dv.getFloat64(at + target.byteOffset, true)
|
||
|
}
|
||
|
|
||
|
function read_uint16_be(target, at) {
|
||
|
var dv = map.get(target);
|
||
|
return dv.getUint16(at + target.byteOffset, false)
|
||
|
}
|
||
|
|
||
|
function read_uint32_be(target, at) {
|
||
|
var dv = map.get(target);
|
||
|
return dv.getUint32(at + target.byteOffset, false)
|
||
|
}
|
||
|
|
||
|
function read_int16_be(target, at) {
|
||
|
var dv = map.get(target);
|
||
|
return dv.getInt16(at + target.byteOffset, false)
|
||
|
}
|
||
|
|
||
|
function read_int32_be(target, at) {
|
||
|
var dv = map.get(target);
|
||
|
return dv.getInt32(at + target.byteOffset, false)
|
||
|
}
|
||
|
|
||
|
function read_float_be(target, at) {
|
||
|
var dv = map.get(target);
|
||
|
return dv.getFloat32(at + target.byteOffset, false)
|
||
|
}
|
||
|
|
||
|
function read_double_be(target, at) {
|
||
|
var dv = map.get(target);
|
||
|
return dv.getFloat64(at + target.byteOffset, false)
|
||
|
}
|
||
|
|
||
|
},{"./mapped.js":11}],10:[function(require,module,exports){
|
||
|
module.exports = {
|
||
|
writeUInt8: write_uint8
|
||
|
, writeInt8: write_int8
|
||
|
, writeUInt16LE: write_uint16_le
|
||
|
, writeUInt32LE: write_uint32_le
|
||
|
, writeInt16LE: write_int16_le
|
||
|
, writeInt32LE: write_int32_le
|
||
|
, writeFloatLE: write_float_le
|
||
|
, writeDoubleLE: write_double_le
|
||
|
, writeUInt16BE: write_uint16_be
|
||
|
, writeUInt32BE: write_uint32_be
|
||
|
, writeInt16BE: write_int16_be
|
||
|
, writeInt32BE: write_int32_be
|
||
|
, writeFloatBE: write_float_be
|
||
|
, writeDoubleBE: write_double_be
|
||
|
}
|
||
|
|
||
|
var map = require('./mapped.js')
|
||
|
|
||
|
function write_uint8(target, value, at) {
|
||
|
return target[at] = value
|
||
|
}
|
||
|
|
||
|
function write_int8(target, value, at) {
|
||
|
return target[at] = value < 0 ? value + 0x100 : value
|
||
|
}
|
||
|
|
||
|
function write_uint16_le(target, value, at) {
|
||
|
var dv = map.get(target);
|
||
|
return dv.setUint16(at + target.byteOffset, value, true)
|
||
|
}
|
||
|
|
||
|
function write_uint32_le(target, value, at) {
|
||
|
var dv = map.get(target);
|
||
|
return dv.setUint32(at + target.byteOffset, value, true)
|
||
|
}
|
||
|
|
||
|
function write_int16_le(target, value, at) {
|
||
|
var dv = map.get(target);
|
||
|
return dv.setInt16(at + target.byteOffset, value, true)
|
||
|
}
|
||
|
|
||
|
function write_int32_le(target, value, at) {
|
||
|
var dv = map.get(target);
|
||
|
return dv.setInt32(at + target.byteOffset, value, true)
|
||
|
}
|
||
|
|
||
|
function write_float_le(target, value, at) {
|
||
|
var dv = map.get(target);
|
||
|
return dv.setFloat32(at + target.byteOffset, value, true)
|
||
|
}
|
||
|
|
||
|
function write_double_le(target, value, at) {
|
||
|
var dv = map.get(target);
|
||
|
return dv.setFloat64(at + target.byteOffset, value, true)
|
||
|
}
|
||
|
|
||
|
function write_uint16_be(target, value, at) {
|
||
|
var dv = map.get(target);
|
||
|
return dv.setUint16(at + target.byteOffset, value, false)
|
||
|
}
|
||
|
|
||
|
function write_uint32_be(target, value, at) {
|
||
|
var dv = map.get(target);
|
||
|
return dv.setUint32(at + target.byteOffset, value, false)
|
||
|
}
|
||
|
|
||
|
function write_int16_be(target, value, at) {
|
||
|
var dv = map.get(target);
|
||
|
return dv.setInt16(at + target.byteOffset, value, false)
|
||
|
}
|
||
|
|
||
|
function write_int32_be(target, value, at) {
|
||
|
var dv = map.get(target);
|
||
|
return dv.setInt32(at + target.byteOffset, value, false)
|
||
|
}
|
||
|
|
||
|
function write_float_be(target, value, at) {
|
||
|
var dv = map.get(target);
|
||
|
return dv.setFloat32(at + target.byteOffset, value, false)
|
||
|
}
|
||
|
|
||
|
function write_double_be(target, value, at) {
|
||
|
var dv = map.get(target);
|
||
|
return dv.setFloat64(at + target.byteOffset, value, false)
|
||
|
}
|
||
|
|
||
|
},{"./mapped.js":11}],11:[function(require,module,exports){
|
||
|
var proto
|
||
|
, map
|
||
|
|
||
|
module.exports = proto = {}
|
||
|
|
||
|
map = typeof WeakMap === 'undefined' ? null : new WeakMap
|
||
|
|
||
|
proto.get = !map ? no_weakmap_get : get
|
||
|
|
||
|
function no_weakmap_get(target) {
|
||
|
return new DataView(target.buffer, 0)
|
||
|
}
|
||
|
|
||
|
function get(target) {
|
||
|
var out = map.get(target.buffer)
|
||
|
if(!out) {
|
||
|
map.set(target.buffer, out = new DataView(target.buffer, 0))
|
||
|
}
|
||
|
return out
|
||
|
}
|
||
|
|
||
|
},{}],2:[function(require,module,exports){
|
||
|
module.exports = from
|
||
|
|
||
|
var base64 = require('base64-js')
|
||
|
|
||
|
var decoders = {
|
||
|
hex: from_hex
|
||
|
, utf8: from_utf
|
||
|
, base64: from_base64
|
||
|
}
|
||
|
|
||
|
function from(source, encoding) {
|
||
|
if(Array.isArray(source)) {
|
||
|
return new Uint8Array(source)
|
||
|
}
|
||
|
|
||
|
return decoders[encoding || 'utf8'](source)
|
||
|
}
|
||
|
|
||
|
function from_hex(str) {
|
||
|
var size = str.length / 2
|
||
|
, buf = new Uint8Array(size)
|
||
|
, character = ''
|
||
|
|
||
|
for(var i = 0, len = str.length; i < len; ++i) {
|
||
|
character += str.charAt(i)
|
||
|
|
||
|
if(i > 0 && (i % 2) === 1) {
|
||
|
buf[i>>>1] = parseInt(character, 16)
|
||
|
character = ''
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return buf
|
||
|
}
|
||
|
|
||
|
function from_utf(str) {
|
||
|
var bytes = []
|
||
|
, tmp
|
||
|
, ch
|
||
|
|
||
|
for(var i = 0, len = str.length; i < len; ++i) {
|
||
|
ch = str.charCodeAt(i)
|
||
|
if(ch & 0x80) {
|
||
|
tmp = encodeURIComponent(str.charAt(i)).substr(1).split('%')
|
||
|
for(var j = 0, jlen = tmp.length; j < jlen; ++j) {
|
||
|
bytes[bytes.length] = parseInt(tmp[j], 16)
|
||
|
}
|
||
|
} else {
|
||
|
bytes[bytes.length] = ch
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return new Uint8Array(bytes)
|
||
|
}
|
||
|
|
||
|
function from_base64(str) {
|
||
|
return new Uint8Array(base64.toByteArray(str))
|
||
|
}
|
||
|
|
||
|
},{"base64-js":12}],3:[function(require,module,exports){
|
||
|
module.exports = to
|
||
|
|
||
|
var base64 = require('base64-js')
|
||
|
, toutf8 = require('to-utf8')
|
||
|
|
||
|
var encoders = {
|
||
|
hex: to_hex
|
||
|
, utf8: to_utf
|
||
|
, base64: to_base64
|
||
|
}
|
||
|
|
||
|
function to(buf, encoding) {
|
||
|
return encoders[encoding || 'utf8'](buf)
|
||
|
}
|
||
|
|
||
|
function to_hex(buf) {
|
||
|
var str = ''
|
||
|
, byt
|
||
|
|
||
|
for(var i = 0, len = buf.length; i < len; ++i) {
|
||
|
byt = buf[i]
|
||
|
str += ((byt & 0xF0) >>> 4).toString(16)
|
||
|
str += (byt & 0x0F).toString(16)
|
||
|
}
|
||
|
|
||
|
return str
|
||
|
}
|
||
|
|
||
|
function to_utf(buf) {
|
||
|
return toutf8(buf)
|
||
|
}
|
||
|
|
||
|
function to_base64(buf) {
|
||
|
return base64.fromByteArray(buf)
|
||
|
}
|
||
|
|
||
|
|
||
|
},{"base64-js":12,"to-utf8":13}],12:[function(require,module,exports){
|
||
|
(function (exports) {
|
||
|
'use strict';
|
||
|
|
||
|
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
||
|
|
||
|
function b64ToByteArray(b64) {
|
||
|
var i, j, l, tmp, placeHolders, arr;
|
||
|
|
||
|
if (b64.length % 4 > 0) {
|
||
|
throw 'Invalid string. Length must be a multiple of 4';
|
||
|
}
|
||
|
|
||
|
// the number of equal signs (place holders)
|
||
|
// if there are two placeholders, than the two characters before it
|
||
|
// represent one byte
|
||
|
// if there is only one, then the three characters before it represent 2 bytes
|
||
|
// this is just a cheap hack to not do indexOf twice
|
||
|
placeHolders = b64.indexOf('=');
|
||
|
placeHolders = placeHolders > 0 ? b64.length - placeHolders : 0;
|
||
|
|
||
|
// base64 is 4/3 + up to two characters of the original data
|
||
|
arr = [];//new Uint8Array(b64.length * 3 / 4 - placeHolders);
|
||
|
|
||
|
// if there are placeholders, only get up to the last complete 4 chars
|
||
|
l = placeHolders > 0 ? b64.length - 4 : b64.length;
|
||
|
|
||
|
for (i = 0, j = 0; i < l; i += 4, j += 3) {
|
||
|
tmp = (lookup.indexOf(b64[i]) << 18) | (lookup.indexOf(b64[i + 1]) << 12) | (lookup.indexOf(b64[i + 2]) << 6) | lookup.indexOf(b64[i + 3]);
|
||
|
arr.push((tmp & 0xFF0000) >> 16);
|
||
|
arr.push((tmp & 0xFF00) >> 8);
|
||
|
arr.push(tmp & 0xFF);
|
||
|
}
|
||
|
|
||
|
if (placeHolders === 2) {
|
||
|
tmp = (lookup.indexOf(b64[i]) << 2) | (lookup.indexOf(b64[i + 1]) >> 4);
|
||
|
arr.push(tmp & 0xFF);
|
||
|
} else if (placeHolders === 1) {
|
||
|
tmp = (lookup.indexOf(b64[i]) << 10) | (lookup.indexOf(b64[i + 1]) << 4) | (lookup.indexOf(b64[i + 2]) >> 2);
|
||
|
arr.push((tmp >> 8) & 0xFF);
|
||
|
arr.push(tmp & 0xFF);
|
||
|
}
|
||
|
|
||
|
return arr;
|
||
|
}
|
||
|
|
||
|
function uint8ToBase64(uint8) {
|
||
|
var i,
|
||
|
extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
|
||
|
output = "",
|
||
|
temp, length;
|
||
|
|
||
|
function tripletToBase64 (num) {
|
||
|
return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F];
|
||
|
};
|
||
|
|
||
|
// go through the array every three bytes, we'll deal with trailing stuff later
|
||
|
for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
|
||
|
temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]);
|
||
|
output += tripletToBase64(temp);
|
||
|
}
|
||
|
|
||
|
// pad the end with zeros, but make sure to not forget the extra bytes
|
||
|
switch (extraBytes) {
|
||
|
case 1:
|
||
|
temp = uint8[uint8.length - 1];
|
||
|
output += lookup[temp >> 2];
|
||
|
output += lookup[(temp << 4) & 0x3F];
|
||
|
output += '==';
|
||
|
break;
|
||
|
case 2:
|
||
|
temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]);
|
||
|
output += lookup[temp >> 10];
|
||
|
output += lookup[(temp >> 4) & 0x3F];
|
||
|
output += lookup[(temp << 2) & 0x3F];
|
||
|
output += '=';
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
return output;
|
||
|
}
|
||
|
|
||
|
module.exports.toByteArray = b64ToByteArray;
|
||
|
module.exports.fromByteArray = uint8ToBase64;
|
||
|
}());
|
||
|
|
||
|
},{}],13:[function(require,module,exports){
|
||
|
module.exports = to_utf8
|
||
|
|
||
|
var out = []
|
||
|
, col = []
|
||
|
, fcc = String.fromCharCode
|
||
|
, mask = [0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01]
|
||
|
, unmask = [
|
||
|
0x00
|
||
|
, 0x01
|
||
|
, 0x02 | 0x01
|
||
|
, 0x04 | 0x02 | 0x01
|
||
|
, 0x08 | 0x04 | 0x02 | 0x01
|
||
|
, 0x10 | 0x08 | 0x04 | 0x02 | 0x01
|
||
|
, 0x20 | 0x10 | 0x08 | 0x04 | 0x02 | 0x01
|
||
|
, 0x40 | 0x20 | 0x10 | 0x08 | 0x04 | 0x02 | 0x01
|
||
|
]
|
||
|
|
||
|
function to_utf8(bytes, start, end) {
|
||
|
start = start === undefined ? 0 : start
|
||
|
end = end === undefined ? bytes.length : end
|
||
|
|
||
|
var idx = 0
|
||
|
, hi = 0x80
|
||
|
, collecting = 0
|
||
|
, pos
|
||
|
, by
|
||
|
|
||
|
col.length =
|
||
|
out.length = 0
|
||
|
|
||
|
while(idx < bytes.length) {
|
||
|
by = bytes[idx]
|
||
|
if(!collecting && by & hi) {
|
||
|
pos = find_pad_position(by)
|
||
|
collecting += pos
|
||
|
if(pos < 8) {
|
||
|
col[col.length] = by & unmask[6 - pos]
|
||
|
}
|
||
|
} else if(collecting) {
|
||
|
col[col.length] = by & unmask[6]
|
||
|
--collecting
|
||
|
if(!collecting && col.length) {
|
||
|
out[out.length] = fcc(reduced(col, pos))
|
||
|
col.length = 0
|
||
|
}
|
||
|
} else {
|
||
|
out[out.length] = fcc(by)
|
||
|
}
|
||
|
++idx
|
||
|
}
|
||
|
if(col.length && !collecting) {
|
||
|
out[out.length] = fcc(reduced(col, pos))
|
||
|
col.length = 0
|
||
|
}
|
||
|
return out.join('')
|
||
|
}
|
||
|
|
||
|
function find_pad_position(byt) {
|
||
|
for(var i = 0; i < 7; ++i) {
|
||
|
if(!(byt & mask[i])) {
|
||
|
break
|
||
|
}
|
||
|
}
|
||
|
return i
|
||
|
}
|
||
|
|
||
|
function reduced(list) {
|
||
|
var out = 0
|
||
|
for(var i = 0, len = list.length; i < len; ++i) {
|
||
|
out |= list[i] << ((len - i - 1) * 6)
|
||
|
}
|
||
|
return out
|
||
|
}
|
||
|
|
||
|
},{}]},{},[1])(1)
|
||
|
});
|
||
|
;
|