hr-design-system-handlebars 0.120.4 → 0.121.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/chromatic.yml +1 -6
- package/CHANGELOG.md +29 -0
- package/dist/assets/index.css +3 -6
- package/dist/assets/js/components/mediaplayer/ardPlayerLoader.subfeature.js +5 -1
- package/dist/assets/vendor/ardplayer/ardplayer-hr-6.3.11.79310671.css +2 -0
- package/dist/assets/vendor/ardplayer/ardplayer-hr-6.3.11.c442fe17.js +6 -0
- package/dist/assets/vendor/ardplayer/ardplayer-libimsc.304b8154.chunk.js +12 -0
- package/dist/assets/vendor/ardplayer/ardplayer-pluginchromecast.68c280ed.chunk.js +1 -0
- package/dist/assets/vendor/ardplayer/ardplayer-plugindash.a7275c59.chunk.js +1174 -0
- package/dist/assets/vendor/ardplayer/ardplayer-pluginhls.f615d5a2.chunk.js +365 -0
- package/dist/assets/vendor/ardplayer/ardplayer-pluginhtmla.d04cedbb.chunk.js +1 -0
- package/dist/assets/vendor/ardplayer/ardplayer-pluginhtmlv.866c1fbf.chunk.js +1 -0
- package/dist/assets/vendor/ardplayer/ardplayer-sandlibrary.a58cd041.chunk.js +0 -0
- package/dist/views/components/button/button_pseudo.hbs +3 -2
- package/package.json +1 -1
- package/src/assets/fixtures/audio/audios.inc.json +6 -6
- package/src/assets/fixtures/video/videos.inc.json +5 -4
- package/src/assets/vendor/ardplayer/ardplayer-hr-6.3.11.79310671.css +2 -0
- package/src/assets/vendor/ardplayer/ardplayer-hr-6.3.11.c442fe17.js +6 -0
- package/src/assets/vendor/ardplayer/ardplayer-libimsc.304b8154.chunk.js +12 -0
- package/src/assets/vendor/ardplayer/ardplayer-pluginchromecast.68c280ed.chunk.js +1 -0
- package/src/assets/vendor/ardplayer/ardplayer-plugindash.a7275c59.chunk.js +1174 -0
- package/src/assets/vendor/ardplayer/ardplayer-pluginhls.f615d5a2.chunk.js +365 -0
- package/src/assets/vendor/ardplayer/ardplayer-pluginhtmla.d04cedbb.chunk.js +1 -0
- package/src/assets/vendor/ardplayer/ardplayer-pluginhtmlv.866c1fbf.chunk.js +1 -0
- package/src/assets/vendor/ardplayer/ardplayer-sandlibrary.a58cd041.chunk.js +0 -0
- package/src/stories/views/components/button/button_pseudo.hbs +3 -2
- package/src/stories/views/components/mediaplayer/ardPlayerLoader.subfeature.js +5 -1
- package/src/stories/views/components/teaser/fixtures/cluster_teaser_Podcast_Channel.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_alternative_100_serif_audio.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_alternative_100_serif_live.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_alternative_100_serif_video.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_alternative_50_serif_audio.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_alternative_50_serif_live.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_alternative_50_serif_video.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_alternative_hero_serif_audio.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_alternative_hero_serif_live.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_alternative_hero_serif_video.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_group_100 copy.json +726 -1
- package/src/stories/views/components/teaser/fixtures/teaser_group_100.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_group_100_highlight.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_group_100_highlight_2.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_group_related_content_100.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_index.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_podcast.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_podcast_50.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_podcast_playlist.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_podcast_playlist_50.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_standard_25_serif_audio.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_standard_25_serif_audio_livestream.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_standard_25_serif_live.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_standard_25_serif_podcast.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_standard_25_serif_video.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_standard_50_serif_audio.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_standard_50_serif_audio_livestream.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_standard_50_serif_live.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_standard_50_serif_podcast.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_standard_50_serif_video.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_tabbox.json +1 -1
- package/dist/assets/vendor/ardplayer/ardplayer-hr-6.3.4.4fc164e9.css +0 -7497
- package/dist/assets/vendor/ardplayer/ardplayer-hr-6.3.4.8ea4ea3d.js +0 -6322
- package/dist/assets/vendor/ardplayer/ardplayer-libimsc.179db74a.chunk.js +0 -444
- package/dist/assets/vendor/ardplayer/ardplayer-pluginhtmlv.4f6a1291.chunk.js +0 -27
- package/dist/assets/vendor/ardplayer/ardplayer-vendors~pluginchromecast.1fb1b290.chunk.js +0 -27
- package/dist/assets/vendor/ardplayer/ardplayer-vendors~pluginchromecast~plugindash~pluginhls~pluginhtmla~pluginhtmlv.a52f1cc9.chunk.js +0 -27
- package/dist/assets/vendor/ardplayer/ardplayer-vendors~plugindash.446f5c07.chunk.js +0 -38
- package/dist/assets/vendor/ardplayer/ardplayer-vendors~pluginhls.ab9656f5.chunk.js +0 -38
- package/dist/assets/vendor/ardplayer/ardplayer-vendors~pluginhtmla.aadd9d24.chunk.js +0 -27
- package/dist/assets/vendor/ardplayer/ardplayer-vendors~pluginhtmla~pluginhtmlv.08e5de97.chunk.js +0 -15
- package/src/assets/vendor/ardplayer/ardplayer-hr-6.3.4.4fc164e9.css +0 -7497
- package/src/assets/vendor/ardplayer/ardplayer-hr-6.3.4.8ea4ea3d.js +0 -6322
- package/src/assets/vendor/ardplayer/ardplayer-libimsc.179db74a.chunk.js +0 -444
- package/src/assets/vendor/ardplayer/ardplayer-pluginhtmlv.4f6a1291.chunk.js +0 -27
- package/src/assets/vendor/ardplayer/ardplayer-vendors~pluginchromecast.1fb1b290.chunk.js +0 -27
- package/src/assets/vendor/ardplayer/ardplayer-vendors~pluginchromecast~plugindash~pluginhls~pluginhtmla~pluginhtmlv.a52f1cc9.chunk.js +0 -27
- package/src/assets/vendor/ardplayer/ardplayer-vendors~plugindash.446f5c07.chunk.js +0 -38
- package/src/assets/vendor/ardplayer/ardplayer-vendors~pluginhls.ab9656f5.chunk.js +0 -38
- package/src/assets/vendor/ardplayer/ardplayer-vendors~pluginhtmla.aadd9d24.chunk.js +0 -27
- package/src/assets/vendor/ardplayer/ardplayer-vendors~pluginhtmla~pluginhtmlv.08e5de97.chunk.js +0 -15
|
@@ -1,444 +0,0 @@
|
|
|
1
|
-
(window["webpackJsonpardplayer"] = window["webpackJsonpardplayer"] || []).push([["libimsc"],{
|
|
2
|
-
|
|
3
|
-
/***/ "../base64-js/index.js":
|
|
4
|
-
/*!*****************************!*\
|
|
5
|
-
!*** ../base64-js/index.js ***!
|
|
6
|
-
\*****************************/
|
|
7
|
-
/*! no static exports found */
|
|
8
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
9
|
-
|
|
10
|
-
"use strict";
|
|
11
|
-
eval("\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n\n\n//# sourceURL=webpack://ardplayer/../base64-js/index.js?");
|
|
12
|
-
|
|
13
|
-
/***/ }),
|
|
14
|
-
|
|
15
|
-
/***/ "../buffer/index.js":
|
|
16
|
-
/*!**************************!*\
|
|
17
|
-
!*** ../buffer/index.js ***!
|
|
18
|
-
\**************************/
|
|
19
|
-
/*! no static exports found */
|
|
20
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
21
|
-
|
|
22
|
-
"use strict";
|
|
23
|
-
eval("/* WEBPACK VAR INJECTION */(function(global) {/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh <http://feross.org>\n * @license MIT\n */\n/* eslint-disable no-proto */\n\n\n\nvar base64 = __webpack_require__(/*! base64-js */ \"../base64-js/index.js\")\nvar ieee754 = __webpack_require__(/*! ieee754 */ \"../ieee754/index.js\")\nvar isArray = __webpack_require__(/*! isarray */ \"../isarray/index.js\")\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Use Object implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * Due to various browser bugs, sometimes the Object implementation will be used even\n * when the browser supports typed arrays.\n *\n * Note:\n *\n * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,\n * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.\n *\n * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.\n *\n * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of\n * incorrect length in some situations.\n\n * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they\n * get the Object implementation, which is slower but behaves correctly.\n */\nBuffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined\n ? global.TYPED_ARRAY_SUPPORT\n : typedArraySupport()\n\n/*\n * Export kMaxLength after typed array support is determined.\n */\nexports.kMaxLength = kMaxLength()\n\nfunction typedArraySupport () {\n try {\n var arr = new Uint8Array(1)\n arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}\n return arr.foo() === 42 && // typed array instances can be augmented\n typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`\n arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`\n } catch (e) {\n return false\n }\n}\n\nfunction kMaxLength () {\n return Buffer.TYPED_ARRAY_SUPPORT\n ? 0x7fffffff\n : 0x3fffffff\n}\n\nfunction createBuffer (that, length) {\n if (kMaxLength() < length) {\n throw new RangeError('Invalid typed array length')\n }\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = new Uint8Array(length)\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n if (that === null) {\n that = new Buffer(length)\n }\n that.length = length\n }\n\n return that\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {\n return new Buffer(arg, encodingOrOffset, length)\n }\n\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new Error(\n 'If encoding is specified then the first argument must be a string'\n )\n }\n return allocUnsafe(this, arg)\n }\n return from(this, arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\n// TODO: Legacy, not needed anymore. Remove in next major version.\nBuffer._augment = function (arr) {\n arr.__proto__ = Buffer.prototype\n return arr\n}\n\nfunction from (that, value, encodingOrOffset, length) {\n if (typeof value === 'number') {\n throw new TypeError('\"value\" argument must not be a number')\n }\n\n if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {\n return fromArrayBuffer(that, value, encodingOrOffset, length)\n }\n\n if (typeof value === 'string') {\n return fromString(that, value, encodingOrOffset)\n }\n\n return fromObject(that, value)\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(null, value, encodingOrOffset, length)\n}\n\nif (Buffer.TYPED_ARRAY_SUPPORT) {\n Buffer.prototype.__proto__ = Uint8Array.prototype\n Buffer.__proto__ = Uint8Array\n if (typeof Symbol !== 'undefined' && Symbol.species &&\n Buffer[Symbol.species] === Buffer) {\n // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97\n Object.defineProperty(Buffer, Symbol.species, {\n value: null,\n configurable: true\n })\n }\n}\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be a number')\n } else if (size < 0) {\n throw new RangeError('\"size\" argument must not be negative')\n }\n}\n\nfunction alloc (that, size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(that, size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpretted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(that, size).fill(fill, encoding)\n : createBuffer(that, size).fill(fill)\n }\n return createBuffer(that, size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(null, size, fill, encoding)\n}\n\nfunction allocUnsafe (that, size) {\n assertSize(size)\n that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) {\n for (var i = 0; i < size; ++i) {\n that[i] = 0\n }\n }\n return that\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(null, size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(null, size)\n}\n\nfunction fromString (that, string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('\"encoding\" must be a valid string encoding')\n }\n\n var length = byteLength(string, encoding) | 0\n that = createBuffer(that, length)\n\n var actual = that.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n that = that.slice(0, actual)\n }\n\n return that\n}\n\nfunction fromArrayLike (that, array) {\n var length = array.length < 0 ? 0 : checked(array.length) | 0\n that = createBuffer(that, length)\n for (var i = 0; i < length; i += 1) {\n that[i] = array[i] & 255\n }\n return that\n}\n\nfunction fromArrayBuffer (that, array, byteOffset, length) {\n array.byteLength // this throws if `array` is not a valid ArrayBuffer\n\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\\'offset\\' is out of bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\\'length\\' is out of bounds')\n }\n\n if (byteOffset === undefined && length === undefined) {\n array = new Uint8Array(array)\n } else if (length === undefined) {\n array = new Uint8Array(array, byteOffset)\n } else {\n array = new Uint8Array(array, byteOffset, length)\n }\n\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = array\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n that = fromArrayLike(that, array)\n }\n return that\n}\n\nfunction fromObject (that, obj) {\n if (Buffer.isBuffer(obj)) {\n var len = checked(obj.length) | 0\n that = createBuffer(that, len)\n\n if (that.length === 0) {\n return that\n }\n\n obj.copy(that, 0, 0, len)\n return that\n }\n\n if (obj) {\n if ((typeof ArrayBuffer !== 'undefined' &&\n obj.buffer instanceof ArrayBuffer) || 'length' in obj) {\n if (typeof obj.length !== 'number' || isnan(obj.length)) {\n return createBuffer(that, 0)\n }\n return fromArrayLike(that, obj)\n }\n\n if (obj.type === 'Buffer' && isArray(obj.data)) {\n return fromArrayLike(that, obj.data)\n }\n }\n\n throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')\n}\n\nfunction checked (length) {\n // Note: cannot use `length < kMaxLength()` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= kMaxLength()) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + kMaxLength().toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return !!(b != null && b._isBuffer)\n}\n\nBuffer.compare = function compare (a, b) {\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError('Arguments must be Buffers')\n }\n\n if (a === b) return 0\n\n var x = a.length\n var y = b.length\n\n for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n var i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n var buffer = Buffer.allocUnsafe(length)\n var pos = 0\n for (i = 0; i < list.length; ++i) {\n var buf = list[i]\n if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n buf.copy(buffer, pos)\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&\n (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n string = '' + string\n }\n\n var len = string.length\n if (len === 0) return 0\n\n // Use a for loop to avoid recursion\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n case undefined:\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) return utf8ToBytes(string).length // assume utf8\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n var loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coersion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect\n// Buffer instances.\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n var i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n var len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (var i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n var len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (var i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n var len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (var i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n var length = this.length | 0\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n var str = ''\n var max = exports.INSPECT_MAX_BYTES\n if (this.length > 0) {\n str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')\n if (this.length > max) str += ' ... '\n }\n return '<Buffer ' + str + '>'\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (!Buffer.isBuffer(target)) {\n throw new TypeError('Argument must be a Buffer')\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n var x = thisEnd - thisStart\n var y = end - start\n var len = Math.min(x, y)\n\n var thisCopy = this.slice(thisStart, thisEnd)\n var targetCopy = target.slice(start, end)\n\n for (var i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (isNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (Buffer.TYPED_ARRAY_SUPPORT &&\n typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n var indexSize = 1\n var arrLength = arr.length\n var valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n var i\n if (dir) {\n var foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n var found = true\n for (var j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n var remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n // must be an even number of digits\n var strLen = string.length\n if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n for (var i = 0; i < length; ++i) {\n var parsed = parseInt(string.substr(i * 2, 2), 16)\n if (isNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction latin1Write (buf, string, offset, length) {\n return asciiWrite(buf, string, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset | 0\n if (isFinite(length)) {\n length = length | 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n // legacy write(string, encoding, offset, length) - remove in v0.13\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n var remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n return asciiWrite(this, string, offset, length)\n\n case 'latin1':\n case 'binary':\n return latin1Write(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n var res = []\n\n var i = start\n while (i < end) {\n var firstByte = buf[i]\n var codePoint = null\n var bytesPerSequence = (firstByte > 0xEF) ? 4\n : (firstByte > 0xDF) ? 3\n : (firstByte > 0xBF) ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n var secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n var len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n var res = ''\n var i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n var len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n var out = ''\n for (var i = start; i < end; ++i) {\n out += toHex(buf[i])\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n var bytes = buf.slice(start, end)\n var res = ''\n for (var i = 0; i < bytes.length; i += 2) {\n res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n var len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n var newBuf\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n newBuf = this.subarray(start, end)\n newBuf.__proto__ = Buffer.prototype\n } else {\n var sliceLen = end - start\n newBuf = new Buffer(sliceLen, undefined)\n for (var i = 0; i < sliceLen; ++i) {\n newBuf[i] = this[i + start]\n }\n }\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n var val = this[offset + --byteLength]\n var mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var i = byteLength\n var mul = 1\n var val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var mul = 1\n var i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var i = byteLength - 1\n var mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nfunction objectWriteUInt16 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {\n buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>\n (littleEndian ? i : 1 - i) * 8\n }\n}\n\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nfunction objectWriteUInt32 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffffffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {\n buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff\n }\n}\n\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = 0\n var mul = 1\n var sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = byteLength - 1\n var mul = 1\n var sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n var len = end - start\n var i\n\n if (this === target && start < targetStart && targetStart < end) {\n // descending copy from end\n for (i = len - 1; i >= 0; --i) {\n target[i + targetStart] = this[i + start]\n }\n } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {\n // ascending copy from start\n for (i = 0; i < len; ++i) {\n target[i + targetStart] = this[i + start]\n }\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, start + len),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (val.length === 1) {\n var code = val.charCodeAt(0)\n if (code < 256) {\n val = code\n }\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n } else if (typeof val === 'number') {\n val = val & 255\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n var i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n var bytes = Buffer.isBuffer(val)\n ? val\n : utf8ToBytes(new Buffer(val, encoding).toString())\n var len = bytes.length\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+\\/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = stringtrim(str).replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction stringtrim (str) {\n if (str.trim) return str.trim()\n return str.replace(/^\\s+|\\s+$/g, '')\n}\n\nfunction toHex (n) {\n if (n < 16) return '0' + n.toString(16)\n return n.toString(16)\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n var codePoint\n var length = string.length\n var leadSurrogate = null\n var bytes = []\n\n for (var i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n var c, hi, lo\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n for (var i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\nfunction isnan (val) {\n return val !== val // eslint-disable-line no-self-compare\n}\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ \"../webpack/buildin/global.js\")))\n\n//# sourceURL=webpack://ardplayer/../buffer/index.js?");
|
|
24
|
-
|
|
25
|
-
/***/ }),
|
|
26
|
-
|
|
27
|
-
/***/ "../core-util-is/lib/util.js":
|
|
28
|
-
/*!***********************************!*\
|
|
29
|
-
!*** ../core-util-is/lib/util.js ***!
|
|
30
|
-
\***********************************/
|
|
31
|
-
/*! no static exports found */
|
|
32
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
33
|
-
|
|
34
|
-
eval("// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// NOTE: These type checking functions intentionally don't use `instanceof`\n// because it is fragile and can be easily faked with `Object.create()`.\n\nfunction isArray(arg) {\n if (Array.isArray) {\n return Array.isArray(arg);\n }\n return objectToString(arg) === '[object Array]';\n}\nexports.isArray = isArray;\n\nfunction isBoolean(arg) {\n return typeof arg === 'boolean';\n}\nexports.isBoolean = isBoolean;\n\nfunction isNull(arg) {\n return arg === null;\n}\nexports.isNull = isNull;\n\nfunction isNullOrUndefined(arg) {\n return arg == null;\n}\nexports.isNullOrUndefined = isNullOrUndefined;\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\nexports.isNumber = isNumber;\n\nfunction isString(arg) {\n return typeof arg === 'string';\n}\nexports.isString = isString;\n\nfunction isSymbol(arg) {\n return typeof arg === 'symbol';\n}\nexports.isSymbol = isSymbol;\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\nexports.isUndefined = isUndefined;\n\nfunction isRegExp(re) {\n return objectToString(re) === '[object RegExp]';\n}\nexports.isRegExp = isRegExp;\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\nexports.isObject = isObject;\n\nfunction isDate(d) {\n return objectToString(d) === '[object Date]';\n}\nexports.isDate = isDate;\n\nfunction isError(e) {\n return (objectToString(e) === '[object Error]' || e instanceof Error);\n}\nexports.isError = isError;\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\nexports.isFunction = isFunction;\n\nfunction isPrimitive(arg) {\n return arg === null ||\n typeof arg === 'boolean' ||\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'symbol' || // ES6 symbol\n typeof arg === 'undefined';\n}\nexports.isPrimitive = isPrimitive;\n\nexports.isBuffer = __webpack_require__(/*! buffer */ \"../buffer/index.js\").Buffer.isBuffer;\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n\n\n//# sourceURL=webpack://ardplayer/../core-util-is/lib/util.js?");
|
|
35
|
-
|
|
36
|
-
/***/ }),
|
|
37
|
-
|
|
38
|
-
/***/ "../events/events.js":
|
|
39
|
-
/*!***************************!*\
|
|
40
|
-
!*** ../events/events.js ***!
|
|
41
|
-
\***************************/
|
|
42
|
-
/*! no static exports found */
|
|
43
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
44
|
-
|
|
45
|
-
"use strict";
|
|
46
|
-
eval("// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\n\nvar R = typeof Reflect === 'object' ? Reflect : null\nvar ReflectApply = R && typeof R.apply === 'function'\n ? R.apply\n : function ReflectApply(target, receiver, args) {\n return Function.prototype.apply.call(target, receiver, args);\n }\n\nvar ReflectOwnKeys\nif (R && typeof R.ownKeys === 'function') {\n ReflectOwnKeys = R.ownKeys\n} else if (Object.getOwnPropertySymbols) {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target)\n .concat(Object.getOwnPropertySymbols(target));\n };\n} else {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target);\n };\n}\n\nfunction ProcessEmitWarning(warning) {\n if (console && console.warn) console.warn(warning);\n}\n\nvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\n return value !== value;\n}\n\nfunction EventEmitter() {\n EventEmitter.init.call(this);\n}\nmodule.exports = EventEmitter;\nmodule.exports.once = once;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nvar defaultMaxListeners = 10;\n\nfunction checkListener(listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n}\n\nObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\n throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\n }\n defaultMaxListeners = arg;\n }\n});\n\nEventEmitter.init = function() {\n\n if (this._events === undefined ||\n this._events === Object.getPrototypeOf(this)._events) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n};\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\n throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\n }\n this._maxListeners = n;\n return this;\n};\n\nfunction _getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return _getMaxListeners(this);\n};\n\nEventEmitter.prototype.emit = function emit(type) {\n var args = [];\n for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\n var doError = (type === 'error');\n\n var events = this._events;\n if (events !== undefined)\n doError = (doError && events.error === undefined);\n else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n var er;\n if (args.length > 0)\n er = args[0];\n if (er instanceof Error) {\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n }\n // At least give some kind of context to the user\n var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n var handler = events[type];\n\n if (handler === undefined)\n return false;\n\n if (typeof handler === 'function') {\n ReflectApply(handler, this, args);\n } else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n ReflectApply(listeners[i], this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n checkListener(listener);\n\n events = target._events;\n if (events === undefined) {\n events = target._events = Object.create(null);\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type,\n listener.listener ? listener.listener : listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n\n // Check for listener leak\n m = _getMaxListeners(target);\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true;\n // No error code for this since it is a Warning\n // eslint-disable-next-line no-restricted-syntax\n var w = new Error('Possible EventEmitter memory leak detected. ' +\n existing.length + ' ' + String(type) + ' listeners ' +\n 'added. Use emitter.setMaxListeners() to ' +\n 'increase limit');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n ProcessEmitWarning(w);\n }\n }\n\n return target;\n}\n\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n if (arguments.length === 0)\n return this.listener.call(this.target);\n return this.listener.apply(this.target, arguments);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\n var wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n checkListener(listener);\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n checkListener(listener);\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n// Emits a 'removeListener' event if and only if the listener was removed.\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n checkListener(listener);\n\n events = this._events;\n if (events === undefined)\n return this;\n\n list = events[type];\n if (list === undefined)\n return this;\n\n if (list === listener || list.listener === listener) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else {\n spliceOne(list, position);\n }\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener !== undefined)\n this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n var listeners, events, i;\n\n events = this._events;\n if (events === undefined)\n return this;\n\n // not listening for removeListener, no need to emit\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else\n delete events[type];\n }\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n var keys = Object.keys(events);\n var key;\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = Object.create(null);\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n var events = target._events;\n\n if (events === undefined)\n return [];\n\n var evlistener = events[type];\n if (evlistener === undefined)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ?\n unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n}\n\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events !== undefined) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener !== undefined) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr, n) {\n var copy = new Array(n);\n for (var i = 0; i < n; ++i)\n copy[i] = arr[i];\n return copy;\n}\n\nfunction spliceOne(list, index) {\n for (; index + 1 < list.length; index++)\n list[index] = list[index + 1];\n list.pop();\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n return ret;\n}\n\nfunction once(emitter, name) {\n return new Promise(function (resolve, reject) {\n function errorListener(err) {\n emitter.removeListener(name, resolver);\n reject(err);\n }\n\n function resolver() {\n if (typeof emitter.removeListener === 'function') {\n emitter.removeListener('error', errorListener);\n }\n resolve([].slice.call(arguments));\n };\n\n eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });\n if (name !== 'error') {\n addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });\n }\n });\n}\n\nfunction addErrorHandlerIfEventEmitter(emitter, handler, flags) {\n if (typeof emitter.on === 'function') {\n eventTargetAgnosticAddListener(emitter, 'error', handler, flags);\n }\n}\n\nfunction eventTargetAgnosticAddListener(emitter, name, listener, flags) {\n if (typeof emitter.on === 'function') {\n if (flags.once) {\n emitter.once(name, listener);\n } else {\n emitter.on(name, listener);\n }\n } else if (typeof emitter.addEventListener === 'function') {\n // EventTarget does not have `error` event semantics like Node\n // EventEmitters, we do not listen for `error` events here.\n emitter.addEventListener(name, function wrapListener(arg) {\n // IE does not have builtin `{ once: true }` support so we\n // have to do it manually.\n if (flags.once) {\n emitter.removeEventListener(name, wrapListener);\n }\n listener(arg);\n });\n } else {\n throw new TypeError('The \"emitter\" argument must be of type EventEmitter. Received type ' + typeof emitter);\n }\n}\n\n\n//# sourceURL=webpack://ardplayer/../events/events.js?");
|
|
47
|
-
|
|
48
|
-
/***/ }),
|
|
49
|
-
|
|
50
|
-
/***/ "../ieee754/index.js":
|
|
51
|
-
/*!***************************!*\
|
|
52
|
-
!*** ../ieee754/index.js ***!
|
|
53
|
-
\***************************/
|
|
54
|
-
/*! no static exports found */
|
|
55
|
-
/***/ (function(module, exports) {
|
|
56
|
-
|
|
57
|
-
eval("/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */\nexports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n\n\n//# sourceURL=webpack://ardplayer/../ieee754/index.js?");
|
|
58
|
-
|
|
59
|
-
/***/ }),
|
|
60
|
-
|
|
61
|
-
/***/ "../imsc/node_modules/sax/lib/sax.js":
|
|
62
|
-
/*!*******************************************!*\
|
|
63
|
-
!*** ../imsc/node_modules/sax/lib/sax.js ***!
|
|
64
|
-
\*******************************************/
|
|
65
|
-
/*! no static exports found */
|
|
66
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
67
|
-
|
|
68
|
-
eval("/* WEBPACK VAR INJECTION */(function(Buffer) {;(function (sax) { // wrapper for non-node envs\n sax.parser = function (strict, opt) { return new SAXParser(strict, opt) }\n sax.SAXParser = SAXParser\n sax.SAXStream = SAXStream\n sax.createStream = createStream\n\n // When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns.\n // When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)),\n // since that's the earliest that a buffer overrun could occur. This way, checks are\n // as rare as required, but as often as necessary to ensure never crossing this bound.\n // Furthermore, buffers are only tested at most once per write(), so passing a very\n // large string into write() might have undesirable effects, but this is manageable by\n // the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme\n // edge case, result in creating at most one complete copy of the string passed in.\n // Set to Infinity to have unlimited buffers.\n sax.MAX_BUFFER_LENGTH = 64 * 1024\n\n var buffers = [\n 'comment', 'sgmlDecl', 'textNode', 'tagName', 'doctype',\n 'procInstName', 'procInstBody', 'entity', 'attribName',\n 'attribValue', 'cdata', 'script'\n ]\n\n sax.EVENTS = [\n 'text',\n 'processinginstruction',\n 'sgmldeclaration',\n 'doctype',\n 'comment',\n 'opentagstart',\n 'attribute',\n 'opentag',\n 'closetag',\n 'opencdata',\n 'cdata',\n 'closecdata',\n 'error',\n 'end',\n 'ready',\n 'script',\n 'opennamespace',\n 'closenamespace'\n ]\n\n function SAXParser (strict, opt) {\n if (!(this instanceof SAXParser)) {\n return new SAXParser(strict, opt)\n }\n\n var parser = this\n clearBuffers(parser)\n parser.q = parser.c = ''\n parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH\n parser.opt = opt || {}\n parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags\n parser.looseCase = parser.opt.lowercase ? 'toLowerCase' : 'toUpperCase'\n parser.tags = []\n parser.closed = parser.closedRoot = parser.sawRoot = false\n parser.tag = parser.error = null\n parser.strict = !!strict\n parser.noscript = !!(strict || parser.opt.noscript)\n parser.state = S.BEGIN\n parser.strictEntities = parser.opt.strictEntities\n parser.ENTITIES = parser.strictEntities ? Object.create(sax.XML_ENTITIES) : Object.create(sax.ENTITIES)\n parser.attribList = []\n\n // namespaces form a prototype chain.\n // it always points at the current tag,\n // which protos to its parent tag.\n if (parser.opt.xmlns) {\n parser.ns = Object.create(rootNS)\n }\n\n // mostly just for error reporting\n parser.trackPosition = parser.opt.position !== false\n if (parser.trackPosition) {\n parser.position = parser.line = parser.column = 0\n }\n emit(parser, 'onready')\n }\n\n if (!Object.create) {\n Object.create = function (o) {\n function F () {}\n F.prototype = o\n var newf = new F()\n return newf\n }\n }\n\n if (!Object.keys) {\n Object.keys = function (o) {\n var a = []\n for (var i in o) if (o.hasOwnProperty(i)) a.push(i)\n return a\n }\n }\n\n function checkBufferLength (parser) {\n var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10)\n var maxActual = 0\n for (var i = 0, l = buffers.length; i < l; i++) {\n var len = parser[buffers[i]].length\n if (len > maxAllowed) {\n // Text/cdata nodes can get big, and since they're buffered,\n // we can get here under normal conditions.\n // Avoid issues by emitting the text node now,\n // so at least it won't get any bigger.\n switch (buffers[i]) {\n case 'textNode':\n closeText(parser)\n break\n\n case 'cdata':\n emitNode(parser, 'oncdata', parser.cdata)\n parser.cdata = ''\n break\n\n case 'script':\n emitNode(parser, 'onscript', parser.script)\n parser.script = ''\n break\n\n default:\n error(parser, 'Max buffer length exceeded: ' + buffers[i])\n }\n }\n maxActual = Math.max(maxActual, len)\n }\n // schedule the next check for the earliest possible buffer overrun.\n var m = sax.MAX_BUFFER_LENGTH - maxActual\n parser.bufferCheckPosition = m + parser.position\n }\n\n function clearBuffers (parser) {\n for (var i = 0, l = buffers.length; i < l; i++) {\n parser[buffers[i]] = ''\n }\n }\n\n function flushBuffers (parser) {\n closeText(parser)\n if (parser.cdata !== '') {\n emitNode(parser, 'oncdata', parser.cdata)\n parser.cdata = ''\n }\n if (parser.script !== '') {\n emitNode(parser, 'onscript', parser.script)\n parser.script = ''\n }\n }\n\n SAXParser.prototype = {\n end: function () { end(this) },\n write: write,\n resume: function () { this.error = null; return this },\n close: function () { return this.write(null) },\n flush: function () { flushBuffers(this) }\n }\n\n var Stream\n try {\n Stream = __webpack_require__(/*! stream */ \"../stream-browserify/index.js\").Stream\n } catch (ex) {\n Stream = function () {}\n }\n\n var streamWraps = sax.EVENTS.filter(function (ev) {\n return ev !== 'error' && ev !== 'end'\n })\n\n function createStream (strict, opt) {\n return new SAXStream(strict, opt)\n }\n\n function SAXStream (strict, opt) {\n if (!(this instanceof SAXStream)) {\n return new SAXStream(strict, opt)\n }\n\n Stream.apply(this)\n\n this._parser = new SAXParser(strict, opt)\n this.writable = true\n this.readable = true\n\n var me = this\n\n this._parser.onend = function () {\n me.emit('end')\n }\n\n this._parser.onerror = function (er) {\n me.emit('error', er)\n\n // if didn't throw, then means error was handled.\n // go ahead and clear error, so we can write again.\n me._parser.error = null\n }\n\n this._decoder = null\n\n streamWraps.forEach(function (ev) {\n Object.defineProperty(me, 'on' + ev, {\n get: function () {\n return me._parser['on' + ev]\n },\n set: function (h) {\n if (!h) {\n me.removeAllListeners(ev)\n me._parser['on' + ev] = h\n return h\n }\n me.on(ev, h)\n },\n enumerable: true,\n configurable: false\n })\n })\n }\n\n SAXStream.prototype = Object.create(Stream.prototype, {\n constructor: {\n value: SAXStream\n }\n })\n\n SAXStream.prototype.write = function (data) {\n if (typeof Buffer === 'function' &&\n typeof Buffer.isBuffer === 'function' &&\n Buffer.isBuffer(data)) {\n if (!this._decoder) {\n var SD = __webpack_require__(/*! string_decoder */ \"../string_decoder/lib/string_decoder.js\").StringDecoder\n this._decoder = new SD('utf8')\n }\n data = this._decoder.write(data)\n }\n\n this._parser.write(data.toString())\n this.emit('data', data)\n return true\n }\n\n SAXStream.prototype.end = function (chunk) {\n if (chunk && chunk.length) {\n this.write(chunk)\n }\n this._parser.end()\n return true\n }\n\n SAXStream.prototype.on = function (ev, handler) {\n var me = this\n if (!me._parser['on' + ev] && streamWraps.indexOf(ev) !== -1) {\n me._parser['on' + ev] = function () {\n var args = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments)\n args.splice(0, 0, ev)\n me.emit.apply(me, args)\n }\n }\n\n return Stream.prototype.on.call(me, ev, handler)\n }\n\n // character classes and tokens\n var whitespace = '\\r\\n\\t '\n\n // this really needs to be replaced with character classes.\n // XML allows all manner of ridiculous numbers and digits.\n var number = '0124356789'\n var letter = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'\n\n // (Letter | \"_\" | \":\")\n var quote = '\\'\"'\n var attribEnd = whitespace + '>'\n var CDATA = '[CDATA['\n var DOCTYPE = 'DOCTYPE'\n var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace'\n var XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/'\n var rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE }\n\n // turn all the string character sets into character class objects.\n whitespace = charClass(whitespace)\n number = charClass(number)\n letter = charClass(letter)\n\n // http://www.w3.org/TR/REC-xml/#NT-NameStartChar\n // This implementation works on strings, a single character at a time\n // as such, it cannot ever support astral-plane characters (10000-EFFFF)\n // without a significant breaking change to either this parser, or the\n // JavaScript language. Implementation of an emoji-capable xml parser\n // is left as an exercise for the reader.\n var nameStart = /[:_A-Za-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD]/\n\n var nameBody = /[:_A-Za-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\u00B7\\u0300-\\u036F\\u203F-\\u2040\\.\\d-]/\n\n var entityStart = /[#:_A-Za-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD]/\n var entityBody = /[#:_A-Za-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\u00B7\\u0300-\\u036F\\u203F-\\u2040\\.\\d-]/\n\n quote = charClass(quote)\n attribEnd = charClass(attribEnd)\n\n function charClass (str) {\n return str.split('').reduce(function (s, c) {\n s[c] = true\n return s\n }, {})\n }\n\n function isRegExp (c) {\n return Object.prototype.toString.call(c) === '[object RegExp]'\n }\n\n function is (charclass, c) {\n return isRegExp(charclass) ? !!c.match(charclass) : charclass[c]\n }\n\n function not (charclass, c) {\n return !is(charclass, c)\n }\n\n var S = 0\n sax.STATE = {\n BEGIN: S++, // leading byte order mark or whitespace\n BEGIN_WHITESPACE: S++, // leading whitespace\n TEXT: S++, // general stuff\n TEXT_ENTITY: S++, // & and such.\n OPEN_WAKA: S++, // <\n SGML_DECL: S++, // <!BLARG\n SGML_DECL_QUOTED: S++, // <!BLARG foo \"bar\n DOCTYPE: S++, // <!DOCTYPE\n DOCTYPE_QUOTED: S++, // <!DOCTYPE \"//blah\n DOCTYPE_DTD: S++, // <!DOCTYPE \"//blah\" [ ...\n DOCTYPE_DTD_QUOTED: S++, // <!DOCTYPE \"//blah\" [ \"foo\n COMMENT_STARTING: S++, // <!-\n COMMENT: S++, // <!--\n COMMENT_ENDING: S++, // <!-- blah -\n COMMENT_ENDED: S++, // <!-- blah --\n CDATA: S++, // <![CDATA[ something\n CDATA_ENDING: S++, // ]\n CDATA_ENDING_2: S++, // ]]\n PROC_INST: S++, // <?hi\n PROC_INST_BODY: S++, // <?hi there\n PROC_INST_ENDING: S++, // <?hi \"there\" ?\n OPEN_TAG: S++, // <strong\n OPEN_TAG_SLASH: S++, // <strong /\n ATTRIB: S++, // <a\n ATTRIB_NAME: S++, // <a foo\n ATTRIB_NAME_SAW_WHITE: S++, // <a foo _\n ATTRIB_VALUE: S++, // <a foo=\n ATTRIB_VALUE_QUOTED: S++, // <a foo=\"bar\n ATTRIB_VALUE_CLOSED: S++, // <a foo=\"bar\"\n ATTRIB_VALUE_UNQUOTED: S++, // <a foo=bar\n ATTRIB_VALUE_ENTITY_Q: S++, // <foo bar=\""\"\n ATTRIB_VALUE_ENTITY_U: S++, // <foo bar="\n CLOSE_TAG: S++, // </a\n CLOSE_TAG_SAW_WHITE: S++, // </a >\n SCRIPT: S++, // <script> ...\n SCRIPT_ENDING: S++ // <script> ... <\n }\n\n sax.XML_ENTITIES = {\n 'amp': '&',\n 'gt': '>',\n 'lt': '<',\n 'quot': '\"',\n 'apos': \"'\"\n }\n\n sax.ENTITIES = {\n 'amp': '&',\n 'gt': '>',\n 'lt': '<',\n 'quot': '\"',\n 'apos': \"'\",\n 'AElig': 198,\n 'Aacute': 193,\n 'Acirc': 194,\n 'Agrave': 192,\n 'Aring': 197,\n 'Atilde': 195,\n 'Auml': 196,\n 'Ccedil': 199,\n 'ETH': 208,\n 'Eacute': 201,\n 'Ecirc': 202,\n 'Egrave': 200,\n 'Euml': 203,\n 'Iacute': 205,\n 'Icirc': 206,\n 'Igrave': 204,\n 'Iuml': 207,\n 'Ntilde': 209,\n 'Oacute': 211,\n 'Ocirc': 212,\n 'Ograve': 210,\n 'Oslash': 216,\n 'Otilde': 213,\n 'Ouml': 214,\n 'THORN': 222,\n 'Uacute': 218,\n 'Ucirc': 219,\n 'Ugrave': 217,\n 'Uuml': 220,\n 'Yacute': 221,\n 'aacute': 225,\n 'acirc': 226,\n 'aelig': 230,\n 'agrave': 224,\n 'aring': 229,\n 'atilde': 227,\n 'auml': 228,\n 'ccedil': 231,\n 'eacute': 233,\n 'ecirc': 234,\n 'egrave': 232,\n 'eth': 240,\n 'euml': 235,\n 'iacute': 237,\n 'icirc': 238,\n 'igrave': 236,\n 'iuml': 239,\n 'ntilde': 241,\n 'oacute': 243,\n 'ocirc': 244,\n 'ograve': 242,\n 'oslash': 248,\n 'otilde': 245,\n 'ouml': 246,\n 'szlig': 223,\n 'thorn': 254,\n 'uacute': 250,\n 'ucirc': 251,\n 'ugrave': 249,\n 'uuml': 252,\n 'yacute': 253,\n 'yuml': 255,\n 'copy': 169,\n 'reg': 174,\n 'nbsp': 160,\n 'iexcl': 161,\n 'cent': 162,\n 'pound': 163,\n 'curren': 164,\n 'yen': 165,\n 'brvbar': 166,\n 'sect': 167,\n 'uml': 168,\n 'ordf': 170,\n 'laquo': 171,\n 'not': 172,\n 'shy': 173,\n 'macr': 175,\n 'deg': 176,\n 'plusmn': 177,\n 'sup1': 185,\n 'sup2': 178,\n 'sup3': 179,\n 'acute': 180,\n 'micro': 181,\n 'para': 182,\n 'middot': 183,\n 'cedil': 184,\n 'ordm': 186,\n 'raquo': 187,\n 'frac14': 188,\n 'frac12': 189,\n 'frac34': 190,\n 'iquest': 191,\n 'times': 215,\n 'divide': 247,\n 'OElig': 338,\n 'oelig': 339,\n 'Scaron': 352,\n 'scaron': 353,\n 'Yuml': 376,\n 'fnof': 402,\n 'circ': 710,\n 'tilde': 732,\n 'Alpha': 913,\n 'Beta': 914,\n 'Gamma': 915,\n 'Delta': 916,\n 'Epsilon': 917,\n 'Zeta': 918,\n 'Eta': 919,\n 'Theta': 920,\n 'Iota': 921,\n 'Kappa': 922,\n 'Lambda': 923,\n 'Mu': 924,\n 'Nu': 925,\n 'Xi': 926,\n 'Omicron': 927,\n 'Pi': 928,\n 'Rho': 929,\n 'Sigma': 931,\n 'Tau': 932,\n 'Upsilon': 933,\n 'Phi': 934,\n 'Chi': 935,\n 'Psi': 936,\n 'Omega': 937,\n 'alpha': 945,\n 'beta': 946,\n 'gamma': 947,\n 'delta': 948,\n 'epsilon': 949,\n 'zeta': 950,\n 'eta': 951,\n 'theta': 952,\n 'iota': 953,\n 'kappa': 954,\n 'lambda': 955,\n 'mu': 956,\n 'nu': 957,\n 'xi': 958,\n 'omicron': 959,\n 'pi': 960,\n 'rho': 961,\n 'sigmaf': 962,\n 'sigma': 963,\n 'tau': 964,\n 'upsilon': 965,\n 'phi': 966,\n 'chi': 967,\n 'psi': 968,\n 'omega': 969,\n 'thetasym': 977,\n 'upsih': 978,\n 'piv': 982,\n 'ensp': 8194,\n 'emsp': 8195,\n 'thinsp': 8201,\n 'zwnj': 8204,\n 'zwj': 8205,\n 'lrm': 8206,\n 'rlm': 8207,\n 'ndash': 8211,\n 'mdash': 8212,\n 'lsquo': 8216,\n 'rsquo': 8217,\n 'sbquo': 8218,\n 'ldquo': 8220,\n 'rdquo': 8221,\n 'bdquo': 8222,\n 'dagger': 8224,\n 'Dagger': 8225,\n 'bull': 8226,\n 'hellip': 8230,\n 'permil': 8240,\n 'prime': 8242,\n 'Prime': 8243,\n 'lsaquo': 8249,\n 'rsaquo': 8250,\n 'oline': 8254,\n 'frasl': 8260,\n 'euro': 8364,\n 'image': 8465,\n 'weierp': 8472,\n 'real': 8476,\n 'trade': 8482,\n 'alefsym': 8501,\n 'larr': 8592,\n 'uarr': 8593,\n 'rarr': 8594,\n 'darr': 8595,\n 'harr': 8596,\n 'crarr': 8629,\n 'lArr': 8656,\n 'uArr': 8657,\n 'rArr': 8658,\n 'dArr': 8659,\n 'hArr': 8660,\n 'forall': 8704,\n 'part': 8706,\n 'exist': 8707,\n 'empty': 8709,\n 'nabla': 8711,\n 'isin': 8712,\n 'notin': 8713,\n 'ni': 8715,\n 'prod': 8719,\n 'sum': 8721,\n 'minus': 8722,\n 'lowast': 8727,\n 'radic': 8730,\n 'prop': 8733,\n 'infin': 8734,\n 'ang': 8736,\n 'and': 8743,\n 'or': 8744,\n 'cap': 8745,\n 'cup': 8746,\n 'int': 8747,\n 'there4': 8756,\n 'sim': 8764,\n 'cong': 8773,\n 'asymp': 8776,\n 'ne': 8800,\n 'equiv': 8801,\n 'le': 8804,\n 'ge': 8805,\n 'sub': 8834,\n 'sup': 8835,\n 'nsub': 8836,\n 'sube': 8838,\n 'supe': 8839,\n 'oplus': 8853,\n 'otimes': 8855,\n 'perp': 8869,\n 'sdot': 8901,\n 'lceil': 8968,\n 'rceil': 8969,\n 'lfloor': 8970,\n 'rfloor': 8971,\n 'lang': 9001,\n 'rang': 9002,\n 'loz': 9674,\n 'spades': 9824,\n 'clubs': 9827,\n 'hearts': 9829,\n 'diams': 9830\n }\n\n Object.keys(sax.ENTITIES).forEach(function (key) {\n var e = sax.ENTITIES[key]\n var s = typeof e === 'number' ? String.fromCharCode(e) : e\n sax.ENTITIES[key] = s\n })\n\n for (var s in sax.STATE) {\n sax.STATE[sax.STATE[s]] = s\n }\n\n // shorthand\n S = sax.STATE\n\n function emit (parser, event, data) {\n parser[event] && parser[event](data)\n }\n\n function emitNode (parser, nodeType, data) {\n if (parser.textNode) closeText(parser)\n emit(parser, nodeType, data)\n }\n\n function closeText (parser) {\n parser.textNode = textopts(parser.opt, parser.textNode)\n if (parser.textNode) emit(parser, 'ontext', parser.textNode)\n parser.textNode = ''\n }\n\n function textopts (opt, text) {\n if (opt.trim) text = text.trim()\n if (opt.normalize) text = text.replace(/\\s+/g, ' ')\n return text\n }\n\n function error (parser, er) {\n closeText(parser)\n if (parser.trackPosition) {\n er += '\\nLine: ' + parser.line +\n '\\nColumn: ' + parser.column +\n '\\nChar: ' + parser.c\n }\n er = new Error(er)\n parser.error = er\n emit(parser, 'onerror', er)\n return parser\n }\n\n function end (parser) {\n if (parser.sawRoot && !parser.closedRoot) strictFail(parser, 'Unclosed root tag')\n if ((parser.state !== S.BEGIN) &&\n (parser.state !== S.BEGIN_WHITESPACE) &&\n (parser.state !== S.TEXT)) {\n error(parser, 'Unexpected end')\n }\n closeText(parser)\n parser.c = ''\n parser.closed = true\n emit(parser, 'onend')\n SAXParser.call(parser, parser.strict, parser.opt)\n return parser\n }\n\n function strictFail (parser, message) {\n if (typeof parser !== 'object' || !(parser instanceof SAXParser)) {\n throw new Error('bad call to strictFail')\n }\n if (parser.strict) {\n error(parser, message)\n }\n }\n\n function newTag (parser) {\n if (!parser.strict) parser.tagName = parser.tagName[parser.looseCase]()\n var parent = parser.tags[parser.tags.length - 1] || parser\n var tag = parser.tag = { name: parser.tagName, attributes: {} }\n\n // will be overridden if tag contails an xmlns=\"foo\" or xmlns:foo=\"bar\"\n if (parser.opt.xmlns) {\n tag.ns = parent.ns\n }\n parser.attribList.length = 0\n emitNode(parser, 'onopentagstart', tag)\n }\n\n function qname (name, attribute) {\n var i = name.indexOf(':')\n var qualName = i < 0 ? [ '', name ] : name.split(':')\n var prefix = qualName[0]\n var local = qualName[1]\n\n // <x \"xmlns\"=\"http://foo\">\n if (attribute && name === 'xmlns') {\n prefix = 'xmlns'\n local = ''\n }\n\n return { prefix: prefix, local: local }\n }\n\n function attrib (parser) {\n if (!parser.strict) {\n parser.attribName = parser.attribName[parser.looseCase]()\n }\n\n if (parser.attribList.indexOf(parser.attribName) !== -1 ||\n parser.tag.attributes.hasOwnProperty(parser.attribName)) {\n parser.attribName = parser.attribValue = ''\n return\n }\n\n if (parser.opt.xmlns) {\n var qn = qname(parser.attribName, true)\n var prefix = qn.prefix\n var local = qn.local\n\n if (prefix === 'xmlns') {\n // namespace binding attribute. push the binding into scope\n if (local === 'xml' && parser.attribValue !== XML_NAMESPACE) {\n strictFail(parser,\n 'xml: prefix must be bound to ' + XML_NAMESPACE + '\\n' +\n 'Actual: ' + parser.attribValue)\n } else if (local === 'xmlns' && parser.attribValue !== XMLNS_NAMESPACE) {\n strictFail(parser,\n 'xmlns: prefix must be bound to ' + XMLNS_NAMESPACE + '\\n' +\n 'Actual: ' + parser.attribValue)\n } else {\n var tag = parser.tag\n var parent = parser.tags[parser.tags.length - 1] || parser\n if (tag.ns === parent.ns) {\n tag.ns = Object.create(parent.ns)\n }\n tag.ns[local] = parser.attribValue\n }\n }\n\n // defer onattribute events until all attributes have been seen\n // so any new bindings can take effect. preserve attribute order\n // so deferred events can be emitted in document order\n parser.attribList.push([parser.attribName, parser.attribValue])\n } else {\n // in non-xmlns mode, we can emit the event right away\n parser.tag.attributes[parser.attribName] = parser.attribValue\n emitNode(parser, 'onattribute', {\n name: parser.attribName,\n value: parser.attribValue\n })\n }\n\n parser.attribName = parser.attribValue = ''\n }\n\n function openTag (parser, selfClosing) {\n if (parser.opt.xmlns) {\n // emit namespace binding events\n var tag = parser.tag\n\n // add namespace info to tag\n var qn = qname(parser.tagName)\n tag.prefix = qn.prefix\n tag.local = qn.local\n tag.uri = tag.ns[qn.prefix] || ''\n\n if (tag.prefix && !tag.uri) {\n strictFail(parser, 'Unbound namespace prefix: ' +\n JSON.stringify(parser.tagName))\n tag.uri = qn.prefix\n }\n\n var parent = parser.tags[parser.tags.length - 1] || parser\n if (tag.ns && parent.ns !== tag.ns) {\n Object.keys(tag.ns).forEach(function (p) {\n emitNode(parser, 'onopennamespace', {\n prefix: p,\n uri: tag.ns[p]\n })\n })\n }\n\n // handle deferred onattribute events\n // Note: do not apply default ns to attributes:\n // http://www.w3.org/TR/REC-xml-names/#defaulting\n for (var i = 0, l = parser.attribList.length; i < l; i++) {\n var nv = parser.attribList[i]\n var name = nv[0]\n var value = nv[1]\n var qualName = qname(name, true)\n var prefix = qualName.prefix\n var local = qualName.local\n var uri = prefix === '' ? '' : (tag.ns[prefix] || '')\n var a = {\n name: name,\n value: value,\n prefix: prefix,\n local: local,\n uri: uri\n }\n\n // if there's any attributes with an undefined namespace,\n // then fail on them now.\n if (prefix && prefix !== 'xmlns' && !uri) {\n strictFail(parser, 'Unbound namespace prefix: ' +\n JSON.stringify(prefix))\n a.uri = prefix\n }\n parser.tag.attributes[name] = a\n emitNode(parser, 'onattribute', a)\n }\n parser.attribList.length = 0\n }\n\n parser.tag.isSelfClosing = !!selfClosing\n\n // process the tag\n parser.sawRoot = true\n parser.tags.push(parser.tag)\n emitNode(parser, 'onopentag', parser.tag)\n if (!selfClosing) {\n // special case for <script> in non-strict mode.\n if (!parser.noscript && parser.tagName.toLowerCase() === 'script') {\n parser.state = S.SCRIPT\n } else {\n parser.state = S.TEXT\n }\n parser.tag = null\n parser.tagName = ''\n }\n parser.attribName = parser.attribValue = ''\n parser.attribList.length = 0\n }\n\n function closeTag (parser) {\n if (!parser.tagName) {\n strictFail(parser, 'Weird empty close tag.')\n parser.textNode += '</>'\n parser.state = S.TEXT\n return\n }\n\n if (parser.script) {\n if (parser.tagName !== 'script') {\n parser.script += '</' + parser.tagName + '>'\n parser.tagName = ''\n parser.state = S.SCRIPT\n return\n }\n emitNode(parser, 'onscript', parser.script)\n parser.script = ''\n }\n\n // first make sure that the closing tag actually exists.\n // <a><b></c></b></a> will close everything, otherwise.\n var t = parser.tags.length\n var tagName = parser.tagName\n if (!parser.strict) {\n tagName = tagName[parser.looseCase]()\n }\n var closeTo = tagName\n while (t--) {\n var close = parser.tags[t]\n if (close.name !== closeTo) {\n // fail the first time in strict mode\n strictFail(parser, 'Unexpected close tag')\n } else {\n break\n }\n }\n\n // didn't find it. we already failed for strict, so just abort.\n if (t < 0) {\n strictFail(parser, 'Unmatched closing tag: ' + parser.tagName)\n parser.textNode += '</' + parser.tagName + '>'\n parser.state = S.TEXT\n return\n }\n parser.tagName = tagName\n var s = parser.tags.length\n while (s-- > t) {\n var tag = parser.tag = parser.tags.pop()\n parser.tagName = parser.tag.name\n emitNode(parser, 'onclosetag', parser.tagName)\n\n var x = {}\n for (var i in tag.ns) {\n x[i] = tag.ns[i]\n }\n\n var parent = parser.tags[parser.tags.length - 1] || parser\n if (parser.opt.xmlns && tag.ns !== parent.ns) {\n // remove namespace bindings introduced by tag\n Object.keys(tag.ns).forEach(function (p) {\n var n = tag.ns[p]\n emitNode(parser, 'onclosenamespace', { prefix: p, uri: n })\n })\n }\n }\n if (t === 0) parser.closedRoot = true\n parser.tagName = parser.attribValue = parser.attribName = ''\n parser.attribList.length = 0\n parser.state = S.TEXT\n }\n\n function parseEntity (parser) {\n var entity = parser.entity\n var entityLC = entity.toLowerCase()\n var num\n var numStr = ''\n\n if (parser.ENTITIES[entity]) {\n return parser.ENTITIES[entity]\n }\n if (parser.ENTITIES[entityLC]) {\n return parser.ENTITIES[entityLC]\n }\n entity = entityLC\n if (entity.charAt(0) === '#') {\n if (entity.charAt(1) === 'x') {\n entity = entity.slice(2)\n num = parseInt(entity, 16)\n numStr = num.toString(16)\n } else {\n entity = entity.slice(1)\n num = parseInt(entity, 10)\n numStr = num.toString(10)\n }\n }\n entity = entity.replace(/^0+/, '')\n if (numStr.toLowerCase() !== entity) {\n strictFail(parser, 'Invalid character entity')\n return '&' + parser.entity + ';'\n }\n\n return String.fromCodePoint(num)\n }\n\n function beginWhiteSpace (parser, c) {\n if (c === '<') {\n parser.state = S.OPEN_WAKA\n parser.startTagPosition = parser.position\n } else if (not(whitespace, c)) {\n // have to process this as a text node.\n // weird, but happens.\n strictFail(parser, 'Non-whitespace before first tag.')\n parser.textNode = c\n parser.state = S.TEXT\n }\n }\n\n function charAt (chunk, i) {\n var result = ''\n if (i < chunk.length) {\n result = chunk.charAt(i)\n }\n return result\n }\n\n function write (chunk) {\n var parser = this\n if (this.error) {\n throw this.error\n }\n if (parser.closed) {\n return error(parser,\n 'Cannot write after close. Assign an onready handler.')\n }\n if (chunk === null) {\n return end(parser)\n }\n if (typeof chunk === 'object') {\n chunk = chunk.toString()\n }\n var i = 0\n var c = ''\n while (true) {\n c = charAt(chunk, i++)\n parser.c = c\n if (!c) {\n break\n }\n if (parser.trackPosition) {\n parser.position++\n if (c === '\\n') {\n parser.line++\n parser.column = 0\n } else {\n parser.column++\n }\n }\n switch (parser.state) {\n case S.BEGIN:\n parser.state = S.BEGIN_WHITESPACE\n if (c === '\\uFEFF') {\n continue\n }\n beginWhiteSpace(parser, c)\n continue\n\n case S.BEGIN_WHITESPACE:\n beginWhiteSpace(parser, c)\n continue\n\n case S.TEXT:\n if (parser.sawRoot && !parser.closedRoot) {\n var starti = i - 1\n while (c && c !== '<' && c !== '&') {\n c = charAt(chunk, i++)\n if (c && parser.trackPosition) {\n parser.position++\n if (c === '\\n') {\n parser.line++\n parser.column = 0\n } else {\n parser.column++\n }\n }\n }\n parser.textNode += chunk.substring(starti, i - 1)\n }\n if (c === '<' && !(parser.sawRoot && parser.closedRoot && !parser.strict)) {\n parser.state = S.OPEN_WAKA\n parser.startTagPosition = parser.position\n } else {\n if (not(whitespace, c) && (!parser.sawRoot || parser.closedRoot)) {\n strictFail(parser, 'Text data outside of root node.')\n }\n if (c === '&') {\n parser.state = S.TEXT_ENTITY\n } else {\n parser.textNode += c\n }\n }\n continue\n\n case S.SCRIPT:\n // only non-strict\n if (c === '<') {\n parser.state = S.SCRIPT_ENDING\n } else {\n parser.script += c\n }\n continue\n\n case S.SCRIPT_ENDING:\n if (c === '/') {\n parser.state = S.CLOSE_TAG\n } else {\n parser.script += '<' + c\n parser.state = S.SCRIPT\n }\n continue\n\n case S.OPEN_WAKA:\n // either a /, ?, !, or text is coming next.\n if (c === '!') {\n parser.state = S.SGML_DECL\n parser.sgmlDecl = ''\n } else if (is(whitespace, c)) {\n // wait for it...\n } else if (is(nameStart, c)) {\n parser.state = S.OPEN_TAG\n parser.tagName = c\n } else if (c === '/') {\n parser.state = S.CLOSE_TAG\n parser.tagName = ''\n } else if (c === '?') {\n parser.state = S.PROC_INST\n parser.procInstName = parser.procInstBody = ''\n } else {\n strictFail(parser, 'Unencoded <')\n // if there was some whitespace, then add that in.\n if (parser.startTagPosition + 1 < parser.position) {\n var pad = parser.position - parser.startTagPosition\n c = new Array(pad).join(' ') + c\n }\n parser.textNode += '<' + c\n parser.state = S.TEXT\n }\n continue\n\n case S.SGML_DECL:\n if ((parser.sgmlDecl + c).toUpperCase() === CDATA) {\n emitNode(parser, 'onopencdata')\n parser.state = S.CDATA\n parser.sgmlDecl = ''\n parser.cdata = ''\n } else if (parser.sgmlDecl + c === '--') {\n parser.state = S.COMMENT\n parser.comment = ''\n parser.sgmlDecl = ''\n } else if ((parser.sgmlDecl + c).toUpperCase() === DOCTYPE) {\n parser.state = S.DOCTYPE\n if (parser.doctype || parser.sawRoot) {\n strictFail(parser,\n 'Inappropriately located doctype declaration')\n }\n parser.doctype = ''\n parser.sgmlDecl = ''\n } else if (c === '>') {\n emitNode(parser, 'onsgmldeclaration', parser.sgmlDecl)\n parser.sgmlDecl = ''\n parser.state = S.TEXT\n } else if (is(quote, c)) {\n parser.state = S.SGML_DECL_QUOTED\n parser.sgmlDecl += c\n } else {\n parser.sgmlDecl += c\n }\n continue\n\n case S.SGML_DECL_QUOTED:\n if (c === parser.q) {\n parser.state = S.SGML_DECL\n parser.q = ''\n }\n parser.sgmlDecl += c\n continue\n\n case S.DOCTYPE:\n if (c === '>') {\n parser.state = S.TEXT\n emitNode(parser, 'ondoctype', parser.doctype)\n parser.doctype = true // just remember that we saw it.\n } else {\n parser.doctype += c\n if (c === '[') {\n parser.state = S.DOCTYPE_DTD\n } else if (is(quote, c)) {\n parser.state = S.DOCTYPE_QUOTED\n parser.q = c\n }\n }\n continue\n\n case S.DOCTYPE_QUOTED:\n parser.doctype += c\n if (c === parser.q) {\n parser.q = ''\n parser.state = S.DOCTYPE\n }\n continue\n\n case S.DOCTYPE_DTD:\n parser.doctype += c\n if (c === ']') {\n parser.state = S.DOCTYPE\n } else if (is(quote, c)) {\n parser.state = S.DOCTYPE_DTD_QUOTED\n parser.q = c\n }\n continue\n\n case S.DOCTYPE_DTD_QUOTED:\n parser.doctype += c\n if (c === parser.q) {\n parser.state = S.DOCTYPE_DTD\n parser.q = ''\n }\n continue\n\n case S.COMMENT:\n if (c === '-') {\n parser.state = S.COMMENT_ENDING\n } else {\n parser.comment += c\n }\n continue\n\n case S.COMMENT_ENDING:\n if (c === '-') {\n parser.state = S.COMMENT_ENDED\n parser.comment = textopts(parser.opt, parser.comment)\n if (parser.comment) {\n emitNode(parser, 'oncomment', parser.comment)\n }\n parser.comment = ''\n } else {\n parser.comment += '-' + c\n parser.state = S.COMMENT\n }\n continue\n\n case S.COMMENT_ENDED:\n if (c !== '>') {\n strictFail(parser, 'Malformed comment')\n // allow <!-- blah -- bloo --> in non-strict mode,\n // which is a comment of \" blah -- bloo \"\n parser.comment += '--' + c\n parser.state = S.COMMENT\n } else {\n parser.state = S.TEXT\n }\n continue\n\n case S.CDATA:\n if (c === ']') {\n parser.state = S.CDATA_ENDING\n } else {\n parser.cdata += c\n }\n continue\n\n case S.CDATA_ENDING:\n if (c === ']') {\n parser.state = S.CDATA_ENDING_2\n } else {\n parser.cdata += ']' + c\n parser.state = S.CDATA\n }\n continue\n\n case S.CDATA_ENDING_2:\n if (c === '>') {\n if (parser.cdata) {\n emitNode(parser, 'oncdata', parser.cdata)\n }\n emitNode(parser, 'onclosecdata')\n parser.cdata = ''\n parser.state = S.TEXT\n } else if (c === ']') {\n parser.cdata += ']'\n } else {\n parser.cdata += ']]' + c\n parser.state = S.CDATA\n }\n continue\n\n case S.PROC_INST:\n if (c === '?') {\n parser.state = S.PROC_INST_ENDING\n } else if (is(whitespace, c)) {\n parser.state = S.PROC_INST_BODY\n } else {\n parser.procInstName += c\n }\n continue\n\n case S.PROC_INST_BODY:\n if (!parser.procInstBody && is(whitespace, c)) {\n continue\n } else if (c === '?') {\n parser.state = S.PROC_INST_ENDING\n } else {\n parser.procInstBody += c\n }\n continue\n\n case S.PROC_INST_ENDING:\n if (c === '>') {\n emitNode(parser, 'onprocessinginstruction', {\n name: parser.procInstName,\n body: parser.procInstBody\n })\n parser.procInstName = parser.procInstBody = ''\n parser.state = S.TEXT\n } else {\n parser.procInstBody += '?' + c\n parser.state = S.PROC_INST_BODY\n }\n continue\n\n case S.OPEN_TAG:\n if (is(nameBody, c)) {\n parser.tagName += c\n } else {\n newTag(parser)\n if (c === '>') {\n openTag(parser)\n } else if (c === '/') {\n parser.state = S.OPEN_TAG_SLASH\n } else {\n if (not(whitespace, c)) {\n strictFail(parser, 'Invalid character in tag name')\n }\n parser.state = S.ATTRIB\n }\n }\n continue\n\n case S.OPEN_TAG_SLASH:\n if (c === '>') {\n openTag(parser, true)\n closeTag(parser)\n } else {\n strictFail(parser, 'Forward-slash in opening tag not followed by >')\n parser.state = S.ATTRIB\n }\n continue\n\n case S.ATTRIB:\n // haven't read the attribute name yet.\n if (is(whitespace, c)) {\n continue\n } else if (c === '>') {\n openTag(parser)\n } else if (c === '/') {\n parser.state = S.OPEN_TAG_SLASH\n } else if (is(nameStart, c)) {\n parser.attribName = c\n parser.attribValue = ''\n parser.state = S.ATTRIB_NAME\n } else {\n strictFail(parser, 'Invalid attribute name')\n }\n continue\n\n case S.ATTRIB_NAME:\n if (c === '=') {\n parser.state = S.ATTRIB_VALUE\n } else if (c === '>') {\n strictFail(parser, 'Attribute without value')\n parser.attribValue = parser.attribName\n attrib(parser)\n openTag(parser)\n } else if (is(whitespace, c)) {\n parser.state = S.ATTRIB_NAME_SAW_WHITE\n } else if (is(nameBody, c)) {\n parser.attribName += c\n } else {\n strictFail(parser, 'Invalid attribute name')\n }\n continue\n\n case S.ATTRIB_NAME_SAW_WHITE:\n if (c === '=') {\n parser.state = S.ATTRIB_VALUE\n } else if (is(whitespace, c)) {\n continue\n } else {\n strictFail(parser, 'Attribute without value')\n parser.tag.attributes[parser.attribName] = ''\n parser.attribValue = ''\n emitNode(parser, 'onattribute', {\n name: parser.attribName,\n value: ''\n })\n parser.attribName = ''\n if (c === '>') {\n openTag(parser)\n } else if (is(nameStart, c)) {\n parser.attribName = c\n parser.state = S.ATTRIB_NAME\n } else {\n strictFail(parser, 'Invalid attribute name')\n parser.state = S.ATTRIB\n }\n }\n continue\n\n case S.ATTRIB_VALUE:\n if (is(whitespace, c)) {\n continue\n } else if (is(quote, c)) {\n parser.q = c\n parser.state = S.ATTRIB_VALUE_QUOTED\n } else {\n strictFail(parser, 'Unquoted attribute value')\n parser.state = S.ATTRIB_VALUE_UNQUOTED\n parser.attribValue = c\n }\n continue\n\n case S.ATTRIB_VALUE_QUOTED:\n if (c !== parser.q) {\n if (c === '&') {\n parser.state = S.ATTRIB_VALUE_ENTITY_Q\n } else {\n parser.attribValue += c\n }\n continue\n }\n attrib(parser)\n parser.q = ''\n parser.state = S.ATTRIB_VALUE_CLOSED\n continue\n\n case S.ATTRIB_VALUE_CLOSED:\n if (is(whitespace, c)) {\n parser.state = S.ATTRIB\n } else if (c === '>') {\n openTag(parser)\n } else if (c === '/') {\n parser.state = S.OPEN_TAG_SLASH\n } else if (is(nameStart, c)) {\n strictFail(parser, 'No whitespace between attributes')\n parser.attribName = c\n parser.attribValue = ''\n parser.state = S.ATTRIB_NAME\n } else {\n strictFail(parser, 'Invalid attribute name')\n }\n continue\n\n case S.ATTRIB_VALUE_UNQUOTED:\n if (not(attribEnd, c)) {\n if (c === '&') {\n parser.state = S.ATTRIB_VALUE_ENTITY_U\n } else {\n parser.attribValue += c\n }\n continue\n }\n attrib(parser)\n if (c === '>') {\n openTag(parser)\n } else {\n parser.state = S.ATTRIB\n }\n continue\n\n case S.CLOSE_TAG:\n if (!parser.tagName) {\n if (is(whitespace, c)) {\n continue\n } else if (not(nameStart, c)) {\n if (parser.script) {\n parser.script += '</' + c\n parser.state = S.SCRIPT\n } else {\n strictFail(parser, 'Invalid tagname in closing tag.')\n }\n } else {\n parser.tagName = c\n }\n } else if (c === '>') {\n closeTag(parser)\n } else if (is(nameBody, c)) {\n parser.tagName += c\n } else if (parser.script) {\n parser.script += '</' + parser.tagName\n parser.tagName = ''\n parser.state = S.SCRIPT\n } else {\n if (not(whitespace, c)) {\n strictFail(parser, 'Invalid tagname in closing tag')\n }\n parser.state = S.CLOSE_TAG_SAW_WHITE\n }\n continue\n\n case S.CLOSE_TAG_SAW_WHITE:\n if (is(whitespace, c)) {\n continue\n }\n if (c === '>') {\n closeTag(parser)\n } else {\n strictFail(parser, 'Invalid characters in closing tag')\n }\n continue\n\n case S.TEXT_ENTITY:\n case S.ATTRIB_VALUE_ENTITY_Q:\n case S.ATTRIB_VALUE_ENTITY_U:\n var returnState\n var buffer\n switch (parser.state) {\n case S.TEXT_ENTITY:\n returnState = S.TEXT\n buffer = 'textNode'\n break\n\n case S.ATTRIB_VALUE_ENTITY_Q:\n returnState = S.ATTRIB_VALUE_QUOTED\n buffer = 'attribValue'\n break\n\n case S.ATTRIB_VALUE_ENTITY_U:\n returnState = S.ATTRIB_VALUE_UNQUOTED\n buffer = 'attribValue'\n break\n }\n\n if (c === ';') {\n parser[buffer] += parseEntity(parser)\n parser.entity = ''\n parser.state = returnState\n } else if (is(parser.entity.length ? entityBody : entityStart, c)) {\n parser.entity += c\n } else {\n strictFail(parser, 'Invalid character in entity name')\n parser[buffer] += '&' + parser.entity + c\n parser.entity = ''\n parser.state = returnState\n }\n\n continue\n\n default:\n throw new Error(parser, 'Unknown state: ' + parser.state)\n }\n } // while\n\n if (parser.position >= parser.bufferCheckPosition) {\n checkBufferLength(parser)\n }\n return parser\n }\n\n /*! http://mths.be/fromcodepoint v0.1.0 by @mathias */\n if (!String.fromCodePoint) {\n (function () {\n var stringFromCharCode = String.fromCharCode\n var floor = Math.floor\n var fromCodePoint = function () {\n var MAX_SIZE = 0x4000\n var codeUnits = []\n var highSurrogate\n var lowSurrogate\n var index = -1\n var length = arguments.length\n if (!length) {\n return ''\n }\n var result = ''\n while (++index < length) {\n var codePoint = Number(arguments[index])\n if (\n !isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`\n codePoint < 0 || // not a valid Unicode code point\n codePoint > 0x10FFFF || // not a valid Unicode code point\n floor(codePoint) !== codePoint // not an integer\n ) {\n throw RangeError('Invalid code point: ' + codePoint)\n }\n if (codePoint <= 0xFFFF) { // BMP code point\n codeUnits.push(codePoint)\n } else { // Astral code point; split in surrogate halves\n // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae\n codePoint -= 0x10000\n highSurrogate = (codePoint >> 10) + 0xD800\n lowSurrogate = (codePoint % 0x400) + 0xDC00\n codeUnits.push(highSurrogate, lowSurrogate)\n }\n if (index + 1 === length || codeUnits.length > MAX_SIZE) {\n result += stringFromCharCode.apply(null, codeUnits)\n codeUnits.length = 0\n }\n }\n return result\n }\n if (Object.defineProperty) {\n Object.defineProperty(String, 'fromCodePoint', {\n value: fromCodePoint,\n configurable: true,\n writable: true\n })\n } else {\n String.fromCodePoint = fromCodePoint\n }\n }())\n }\n})( false ? undefined : exports)\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../../buffer/index.js */ \"../buffer/index.js\").Buffer))\n\n//# sourceURL=webpack://ardplayer/../imsc/node_modules/sax/lib/sax.js?");
|
|
69
|
-
|
|
70
|
-
/***/ }),
|
|
71
|
-
|
|
72
|
-
/***/ "../imsc/src/main/js/doc.js":
|
|
73
|
-
/*!**********************************!*\
|
|
74
|
-
!*** ../imsc/src/main/js/doc.js ***!
|
|
75
|
-
\**********************************/
|
|
76
|
-
/*! no static exports found */
|
|
77
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
78
|
-
|
|
79
|
-
eval("/* \r\n * Copyright (c) 2016, Pierre-Anthony Lemieux <pal@sandflow.com>\r\n * All rights reserved.\r\n *\r\n * Redistribution and use in source and binary forms, with or without\r\n * modification, are permitted provided that the following conditions are met:\r\n *\r\n * * Redistributions of source code must retain the above copyright notice, this\r\n * list of conditions and the following disclaimer.\r\n * * Redistributions in binary form must reproduce the above copyright notice,\r\n * this list of conditions and the following disclaimer in the documentation\r\n * and/or other materials provided with the distribution.\r\n *\r\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\r\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r\n * POSSIBILITY OF SUCH DAMAGE.\r\n */\r\n\r\n/**\r\n * @module imscDoc\r\n */\r\n\r\n;\r\n(function (imscDoc, sax, imscNames, imscStyles, imscUtils) {\r\n\r\n\r\n /**\r\n * Allows a client to provide callbacks to handle children of the <metadata> element\r\n * @typedef {Object} MetadataHandler\r\n * @property {?OpenTagCallBack} onOpenTag\r\n * @property {?CloseTagCallBack} onCloseTag\r\n * @property {?TextCallBack} onText\r\n */\r\n\r\n /**\r\n * Called when the opening tag of an element node is encountered.\r\n * @callback OpenTagCallBack\r\n * @param {string} ns Namespace URI of the element\r\n * @param {string} name Local name of the element\r\n * @param {Object[]} attributes List of attributes, each consisting of a\r\n * `uri`, `name` and `value`\r\n */\r\n\r\n /**\r\n * Called when the closing tag of an element node is encountered.\r\n * @callback CloseTagCallBack\r\n */\r\n\r\n /**\r\n * Called when a text node is encountered.\r\n * @callback TextCallBack\r\n * @param {string} contents Contents of the text node\r\n */\r\n\r\n /**\r\n * Parses an IMSC1 document into an opaque in-memory representation that exposes\r\n * a single method <pre>getMediaTimeEvents()</pre> that returns a list of time\r\n * offsets (in seconds) of the ISD, i.e. the points in time where the visual\r\n * representation of the document change. `metadataHandler` allows the caller to\r\n * be called back when nodes are present in <metadata> elements. \r\n * \r\n * @param {string} xmlstring XML document\r\n * @param {?module:imscUtils.ErrorHandler} errorHandler Error callback\r\n * @param {?MetadataHandler} metadataHandler Callback for <Metadata> elements\r\n * @returns {Object} Opaque in-memory representation of an IMSC1 document\r\n */\r\n\r\n imscDoc.fromXML = function (xmlstring, errorHandler, metadataHandler) {\r\n var p = sax.parser(true, {xmlns: true});\r\n var estack = [];\r\n var xmllangstack = [];\r\n var xmlspacestack = [];\r\n var metadata_depth = 0;\r\n var doc = null;\r\n\r\n p.onclosetag = function (node) {\r\n\r\n \r\n if (estack[0] instanceof Region) {\r\n\r\n /* merge referenced styles */\r\n\r\n if (doc.head !== null && doc.head.styling !== null) {\r\n mergeReferencedStyles(doc.head.styling, estack[0].styleRefs, estack[0].styleAttrs, errorHandler);\r\n }\r\n\r\n delete estack[0].styleRefs;\r\n\r\n } else if (estack[0] instanceof Styling) {\r\n\r\n /* flatten chained referential styling */\r\n\r\n for (var sid in estack[0].styles) {\r\n\r\n if (! estack[0].styles.hasOwnProperty(sid)) continue;\r\n\r\n mergeChainedStyles(estack[0], estack[0].styles[sid], errorHandler);\r\n\r\n }\r\n\r\n } else if (estack[0] instanceof P || estack[0] instanceof Span) {\r\n\r\n /* merge anonymous spans */\r\n\r\n if (estack[0].contents.length > 1) {\r\n\r\n var cs = [estack[0].contents[0]];\r\n\r\n var c;\r\n\r\n for (c = 1; c < estack[0].contents.length; c++) {\r\n\r\n if (estack[0].contents[c] instanceof AnonymousSpan &&\r\n cs[cs.length - 1] instanceof AnonymousSpan) {\r\n\r\n cs[cs.length - 1].text += estack[0].contents[c].text;\r\n\r\n } else {\r\n\r\n cs.push(estack[0].contents[c]);\r\n\r\n }\r\n\r\n }\r\n\r\n estack[0].contents = cs;\r\n\r\n }\r\n\r\n // remove redundant nested anonymous spans (9.3.3(1)(c))\r\n\r\n if (estack[0] instanceof Span &&\r\n estack[0].contents.length === 1 &&\r\n estack[0].contents[0] instanceof AnonymousSpan) {\r\n\r\n estack[0].text = estack[0].contents[0].text;\r\n delete estack[0].contents;\r\n\r\n }\r\n\r\n } else if (estack[0] instanceof ForeignElement) {\r\n\r\n if (estack[0].node.uri === imscNames.ns_tt &&\r\n estack[0].node.local === 'metadata') {\r\n\r\n /* leave the metadata element */\r\n\r\n metadata_depth--;\r\n\r\n } else if (metadata_depth > 0 &&\r\n metadataHandler &&\r\n 'onCloseTag' in metadataHandler) {\r\n\r\n /* end of child of metadata element */\r\n\r\n metadataHandler.onCloseTag();\r\n\r\n }\r\n\r\n }\r\n\r\n // TODO: delete stylerefs?\r\n\r\n // maintain the xml:space stack\r\n\r\n xmlspacestack.shift();\r\n\r\n // maintain the xml:lang stack\r\n\r\n xmllangstack.shift();\r\n\r\n // prepare for the next element\r\n\r\n estack.shift();\r\n };\r\n\r\n p.ontext = function (str) {\r\n\r\n if (estack[0] === undefined) {\r\n\r\n /* ignoring text outside of elements */\r\n\r\n } else if (estack[0] instanceof Span || estack[0] instanceof P) {\r\n\r\n /* ignore children text nodes in ruby container spans */\r\n\r\n if (estack[0] instanceof Span) {\r\n\r\n var ruby = estack[0].styleAttrs[imscStyles.byName.ruby.qname];\r\n\r\n if (ruby === 'container' || ruby === 'textContainer' || ruby === 'baseContainer') {\r\n\r\n return;\r\n\r\n }\r\n\r\n }\r\n\r\n /* create an anonymous span */\r\n\r\n var s = new AnonymousSpan();\r\n\r\n s.initFromText(doc, estack[0], str, xmllangstack[0], xmlspacestack[0], errorHandler);\r\n\r\n estack[0].contents.push(s);\r\n\r\n } else if (estack[0] instanceof ForeignElement &&\r\n metadata_depth > 0 &&\r\n metadataHandler &&\r\n 'onText' in metadataHandler) {\r\n\r\n /* text node within a child of metadata element */\r\n\r\n metadataHandler.onText(str);\r\n\r\n }\r\n\r\n };\r\n\r\n\r\n p.onopentag = function (node) {\r\n\r\n // maintain the xml:space stack\r\n\r\n var xmlspace = node.attributes[\"xml:space\"];\r\n\r\n if (xmlspace) {\r\n\r\n xmlspacestack.unshift(xmlspace.value);\r\n\r\n } else {\r\n\r\n if (xmlspacestack.length === 0) {\r\n\r\n xmlspacestack.unshift(\"default\");\r\n\r\n } else {\r\n\r\n xmlspacestack.unshift(xmlspacestack[0]);\r\n\r\n }\r\n\r\n }\r\n\r\n /* maintain the xml:lang stack */\r\n\r\n\r\n var xmllang = node.attributes[\"xml:lang\"];\r\n\r\n if (xmllang) {\r\n\r\n xmllangstack.unshift(xmllang.value);\r\n\r\n } else {\r\n\r\n if (xmllangstack.length === 0) {\r\n\r\n xmllangstack.unshift(\"\");\r\n\r\n } else {\r\n\r\n xmllangstack.unshift(xmllangstack[0]);\r\n\r\n }\r\n\r\n }\r\n\r\n\r\n /* process the element */\r\n\r\n if (node.uri === imscNames.ns_tt) {\r\n\r\n if (node.local === 'tt') {\r\n\r\n if (doc !== null) {\r\n\r\n reportFatal(errorHandler, \"Two <tt> elements at (\" + this.line + \",\" + this.column + \")\");\r\n\r\n }\r\n\r\n doc = new TT();\r\n\r\n doc.initFromNode(node, xmllangstack[0], errorHandler);\r\n\r\n estack.unshift(doc);\r\n\r\n } else if (node.local === 'head') {\r\n\r\n if (!(estack[0] instanceof TT)) {\r\n reportFatal(errorHandler, \"Parent of <head> element is not <tt> at (\" + this.line + \",\" + this.column + \")\");\r\n }\r\n\r\n estack.unshift(doc.head);\r\n\r\n } else if (node.local === 'styling') {\r\n\r\n if (!(estack[0] instanceof Head)) {\r\n reportFatal(errorHandler, \"Parent of <styling> element is not <head> at (\" + this.line + \",\" + this.column + \")\");\r\n }\r\n\r\n estack.unshift(doc.head.styling);\r\n\r\n } else if (node.local === 'style') {\r\n\r\n var s;\r\n\r\n if (estack[0] instanceof Styling) {\r\n\r\n s = new Style();\r\n\r\n s.initFromNode(node, errorHandler);\r\n\r\n /* ignore <style> element missing @id */\r\n\r\n if (!s.id) {\r\n\r\n reportError(errorHandler, \"<style> element missing @id attribute\");\r\n\r\n } else {\r\n\r\n doc.head.styling.styles[s.id] = s;\r\n\r\n }\r\n\r\n estack.unshift(s);\r\n\r\n } else if (estack[0] instanceof Region) {\r\n\r\n /* nested styles can be merged with specified styles\r\n * immediately, with lower priority\r\n * (see 8.4.4.2(3) at TTML1 )\r\n */\r\n\r\n s = new Style();\r\n\r\n s.initFromNode(node, errorHandler);\r\n\r\n mergeStylesIfNotPresent(s.styleAttrs, estack[0].styleAttrs);\r\n\r\n estack.unshift(s);\r\n\r\n } else {\r\n\r\n reportFatal(errorHandler, \"Parent of <style> element is not <styling> or <region> at (\" + this.line + \",\" + this.column + \")\");\r\n\r\n }\r\n\r\n } else if (node.local === 'initial') {\r\n\r\n var ini;\r\n\r\n if (estack[0] instanceof Styling) {\r\n\r\n ini = new Initial();\r\n\r\n ini.initFromNode(node, errorHandler);\r\n \r\n for (var qn in ini.styleAttrs) {\r\n\r\n if (! ini.styleAttrs.hasOwnProperty(qn)) continue;\r\n \r\n doc.head.styling.initials[qn] = ini.styleAttrs[qn];\r\n \r\n }\r\n \r\n estack.unshift(ini);\r\n\r\n } else {\r\n\r\n reportFatal(errorHandler, \"Parent of <initial> element is not <styling> at (\" + this.line + \",\" + this.column + \")\");\r\n\r\n }\r\n\r\n } else if (node.local === 'layout') {\r\n\r\n if (!(estack[0] instanceof Head)) {\r\n\r\n reportFatal(errorHandler, \"Parent of <layout> element is not <head> at \" + this.line + \",\" + this.column + \")\");\r\n\r\n }\r\n\r\n estack.unshift(doc.head.layout);\r\n\r\n } else if (node.local === 'region') {\r\n\r\n if (!(estack[0] instanceof Layout)) {\r\n reportFatal(errorHandler, \"Parent of <region> element is not <layout> at \" + this.line + \",\" + this.column + \")\");\r\n }\r\n\r\n var r = new Region();\r\n\r\n r.initFromNode(doc, node, xmllangstack[0], errorHandler);\r\n\r\n if (!r.id || r.id in doc.head.layout.regions) {\r\n\r\n reportError(errorHandler, \"Ignoring <region> with duplicate or missing @id at \" + this.line + \",\" + this.column + \")\");\r\n\r\n } else {\r\n\r\n doc.head.layout.regions[r.id] = r;\r\n\r\n }\r\n\r\n estack.unshift(r);\r\n\r\n } else if (node.local === 'body') {\r\n\r\n if (!(estack[0] instanceof TT)) {\r\n\r\n reportFatal(errorHandler, \"Parent of <body> element is not <tt> at \" + this.line + \",\" + this.column + \")\");\r\n\r\n }\r\n\r\n if (doc.body !== null) {\r\n\r\n reportFatal(errorHandler, \"Second <body> element at \" + this.line + \",\" + this.column + \")\");\r\n\r\n }\r\n\r\n var b = new Body();\r\n\r\n b.initFromNode(doc, node, xmllangstack[0], errorHandler);\r\n\r\n doc.body = b;\r\n\r\n estack.unshift(b);\r\n\r\n } else if (node.local === 'div') {\r\n\r\n if (!(estack[0] instanceof Div || estack[0] instanceof Body)) {\r\n\r\n reportFatal(errorHandler, \"Parent of <div> element is not <body> or <div> at \" + this.line + \",\" + this.column + \")\");\r\n\r\n }\r\n\r\n var d = new Div();\r\n\r\n d.initFromNode(doc, estack[0], node, xmllangstack[0], errorHandler);\r\n \r\n /* transform smpte:backgroundImage to TTML2 image element */\r\n \r\n var bi = d.styleAttrs[imscStyles.byName.backgroundImage.qname];\r\n \r\n if (bi) {\r\n d.contents.push(new Image(bi));\r\n delete d.styleAttrs[imscStyles.byName.backgroundImage.qname]; \r\n }\r\n\r\n estack[0].contents.push(d);\r\n\r\n estack.unshift(d);\r\n\r\n } else if (node.local === 'image') {\r\n\r\n if (!(estack[0] instanceof Div)) {\r\n\r\n reportFatal(errorHandler, \"Parent of <image> element is not <div> at \" + this.line + \",\" + this.column + \")\");\r\n\r\n }\r\n\r\n var img = new Image();\r\n \r\n img.initFromNode(doc, estack[0], node, xmllangstack[0], errorHandler);\r\n \r\n estack[0].contents.push(img);\r\n\r\n estack.unshift(img);\r\n\r\n } else if (node.local === 'p') {\r\n\r\n if (!(estack[0] instanceof Div)) {\r\n\r\n reportFatal(errorHandler, \"Parent of <p> element is not <div> at \" + this.line + \",\" + this.column + \")\");\r\n\r\n }\r\n\r\n var p = new P();\r\n\r\n p.initFromNode(doc, estack[0], node, xmllangstack[0], errorHandler);\r\n\r\n estack[0].contents.push(p);\r\n\r\n estack.unshift(p);\r\n\r\n } else if (node.local === 'span') {\r\n\r\n if (!(estack[0] instanceof Span || estack[0] instanceof P)) {\r\n\r\n reportFatal(errorHandler, \"Parent of <span> element is not <span> or <p> at \" + this.line + \",\" + this.column + \")\");\r\n\r\n }\r\n\r\n var ns = new Span();\r\n\r\n ns.initFromNode(doc, estack[0], node, xmllangstack[0], xmlspacestack[0], errorHandler);\r\n\r\n estack[0].contents.push(ns);\r\n\r\n estack.unshift(ns);\r\n\r\n } else if (node.local === 'br') {\r\n\r\n if (!(estack[0] instanceof Span || estack[0] instanceof P)) {\r\n\r\n reportFatal(errorHandler, \"Parent of <br> element is not <span> or <p> at \" + this.line + \",\" + this.column + \")\");\r\n\r\n }\r\n\r\n var nb = new Br();\r\n\r\n nb.initFromNode(doc, estack[0], node, xmllangstack[0], errorHandler);\r\n\r\n estack[0].contents.push(nb);\r\n\r\n estack.unshift(nb);\r\n\r\n } else if (node.local === 'set') {\r\n\r\n if (!(estack[0] instanceof Span ||\r\n estack[0] instanceof P ||\r\n estack[0] instanceof Div ||\r\n estack[0] instanceof Body ||\r\n estack[0] instanceof Region ||\r\n estack[0] instanceof Br)) {\r\n\r\n reportFatal(errorHandler, \"Parent of <set> element is not a content element or a region at \" + this.line + \",\" + this.column + \")\");\r\n\r\n }\r\n\r\n var st = new Set();\r\n\r\n st.initFromNode(doc, estack[0], node, errorHandler);\r\n\r\n estack[0].sets.push(st);\r\n\r\n estack.unshift(st);\r\n\r\n } else {\r\n\r\n /* element in the TT namespace, but not a content element */\r\n\r\n estack.unshift(new ForeignElement(node));\r\n }\r\n\r\n } else {\r\n\r\n /* ignore elements not in the TTML namespace unless in metadata element */\r\n\r\n estack.unshift(new ForeignElement(node));\r\n\r\n }\r\n\r\n /* handle metadata callbacks */\r\n\r\n if (estack[0] instanceof ForeignElement) {\r\n\r\n if (node.uri === imscNames.ns_tt &&\r\n node.local === 'metadata') {\r\n\r\n /* enter the metadata element */\r\n\r\n metadata_depth++;\r\n\r\n } else if (\r\n metadata_depth > 0 &&\r\n metadataHandler &&\r\n 'onOpenTag' in metadataHandler\r\n ) {\r\n\r\n /* start of child of metadata element */\r\n\r\n var attrs = [];\r\n\r\n for (var a in node.attributes) {\r\n attrs[node.attributes[a].uri + \" \" + node.attributes[a].local] =\r\n {\r\n uri: node.attributes[a].uri,\r\n local: node.attributes[a].local,\r\n value: node.attributes[a].value\r\n };\r\n }\r\n\r\n metadataHandler.onOpenTag(node.uri, node.local, attrs);\r\n\r\n }\r\n\r\n }\r\n\r\n };\r\n\r\n // parse the document\r\n\r\n p.write(xmlstring).close();\r\n\r\n // all referential styling has been flatten, so delete styles\r\n\r\n delete doc.head.styling.styles;\r\n \r\n // create default region if no regions specified\r\n\r\n var hasRegions = false;\r\n\r\n /* AFAIK the only way to determine whether an object has members */\r\n\r\n for (var i in doc.head.layout.regions) {\r\n\r\n if (doc.head.layout.regions.hasOwnProperty(i)) {\r\n hasRegions = true;\r\n break;\r\n }\r\n\r\n }\r\n\r\n if (!hasRegions) {\r\n\r\n /* create default region */\r\n\r\n var dr = Region.prototype.createDefaultRegion(doc.lang);\r\n\r\n doc.head.layout.regions[dr.id] = dr;\r\n\r\n }\r\n\r\n /* resolve desired timing for regions */\r\n\r\n for (var region_i in doc.head.layout.regions) {\r\n\r\n if (! doc.head.layout.regions.hasOwnProperty(region_i)) continue;\r\n\r\n resolveTiming(doc, doc.head.layout.regions[region_i], null, null);\r\n\r\n }\r\n\r\n /* resolve desired timing for content elements */\r\n\r\n if (doc.body) {\r\n resolveTiming(doc, doc.body, null, null);\r\n }\r\n\r\n /* remove undefined spans in ruby containers */\r\n\r\n if (doc.body) {\r\n cleanRubyContainers(doc.body);\r\n }\r\n\r\n return doc;\r\n };\r\n\r\n function cleanRubyContainers(element) {\r\n \r\n if (! ('contents' in element)) return;\r\n\r\n var rubyval = 'styleAttrs' in element ? element.styleAttrs[imscStyles.byName.ruby.qname] : null;\r\n\r\n var isrubycontainer = (element.kind === 'span' && (rubyval === \"container\" || rubyval === \"textContainer\" || rubyval === \"baseContainer\"));\r\n\r\n for (var i = element.contents.length - 1; i >= 0; i--) {\r\n\r\n if (isrubycontainer && !('styleAttrs' in element.contents[i] && imscStyles.byName.ruby.qname in element.contents[i].styleAttrs)) {\r\n\r\n /* prune undefined <span> in ruby containers */\r\n\r\n delete element.contents[i];\r\n\r\n } else {\r\n\r\n cleanRubyContainers(element.contents[i]);\r\n\r\n }\r\n\r\n }\r\n\r\n }\r\n\r\n function resolveTiming(doc, element, prev_sibling, parent) {\r\n\r\n /* are we in a seq container? */\r\n\r\n var isinseq = parent && parent.timeContainer === \"seq\";\r\n\r\n /* determine implicit begin */\r\n\r\n var implicit_begin = 0; /* default */\r\n\r\n if (parent) {\r\n\r\n if (isinseq && prev_sibling) {\r\n\r\n /*\r\n * if seq time container, offset from the previous sibling end\r\n */\r\n\r\n implicit_begin = prev_sibling.end;\r\n\r\n\r\n } else {\r\n\r\n implicit_begin = parent.begin;\r\n\r\n }\r\n\r\n }\r\n\r\n /* compute desired begin */\r\n\r\n element.begin = element.explicit_begin ? element.explicit_begin + implicit_begin : implicit_begin;\r\n\r\n\r\n /* determine implicit end */\r\n\r\n var implicit_end = element.begin;\r\n\r\n var s = null;\r\n\r\n if (\"sets\" in element) {\r\n\r\n for (var set_i = 0; set_i < element.sets.length; set_i++) {\r\n\r\n resolveTiming(doc, element.sets[set_i], s, element);\r\n\r\n if (element.timeContainer === \"seq\") {\r\n\r\n implicit_end = element.sets[set_i].end;\r\n\r\n } else {\r\n\r\n implicit_end = Math.max(implicit_end, element.sets[set_i].end);\r\n\r\n }\r\n\r\n s = element.sets[set_i];\r\n\r\n }\r\n\r\n }\r\n\r\n if (!('contents' in element)) {\r\n\r\n /* anonymous spans and regions and <set> and <br>s and spans with only children text nodes */\r\n\r\n if (isinseq) {\r\n\r\n /* in seq container, implicit duration is zero */\r\n\r\n implicit_end = element.begin;\r\n\r\n } else {\r\n\r\n /* in par container, implicit duration is indefinite */\r\n\r\n implicit_end = Number.POSITIVE_INFINITY;\r\n\r\n }\r\n\r\n } else if (\"contents\" in element) {\r\n \r\n for (var content_i = 0; content_i < element.contents.length; content_i++) {\r\n\r\n resolveTiming(doc, element.contents[content_i], s, element);\r\n\r\n if (element.timeContainer === \"seq\") {\r\n\r\n implicit_end = element.contents[content_i].end;\r\n\r\n } else {\r\n\r\n implicit_end = Math.max(implicit_end, element.contents[content_i].end);\r\n\r\n }\r\n\r\n s = element.contents[content_i];\r\n\r\n }\r\n\r\n }\r\n\r\n /* determine desired end */\r\n /* it is never made really clear in SMIL that the explicit end is offset by the implicit begin */\r\n\r\n if (element.explicit_end !== null && element.explicit_dur !== null) {\r\n\r\n element.end = Math.min(element.begin + element.explicit_dur, implicit_begin + element.explicit_end);\r\n\r\n } else if (element.explicit_end === null && element.explicit_dur !== null) {\r\n\r\n element.end = element.begin + element.explicit_dur;\r\n\r\n } else if (element.explicit_end !== null && element.explicit_dur === null) {\r\n\r\n element.end = implicit_begin + element.explicit_end;\r\n\r\n } else {\r\n\r\n element.end = implicit_end;\r\n }\r\n\r\n delete element.explicit_begin;\r\n delete element.explicit_dur;\r\n delete element.explicit_end;\r\n\r\n doc._registerEvent(element);\r\n\r\n }\r\n\r\n function ForeignElement(node) {\r\n this.node = node;\r\n }\r\n\r\n function TT() {\r\n this.events = [];\r\n this.head = new Head();\r\n this.body = null;\r\n }\r\n\r\n TT.prototype.initFromNode = function (node, xmllang, errorHandler) {\r\n\r\n /* compute cell resolution */\r\n\r\n var cr = extractCellResolution(node, errorHandler);\r\n \r\n this.cellLength = {\r\n 'h': new imscUtils.ComputedLength(0, 1/cr.h),\r\n 'w': new imscUtils.ComputedLength(1/cr.w, 0)\r\n };\r\n\r\n /* extract frame rate and tick rate */\r\n\r\n var frtr = extractFrameAndTickRate(node, errorHandler);\r\n\r\n this.effectiveFrameRate = frtr.effectiveFrameRate;\r\n\r\n this.tickRate = frtr.tickRate;\r\n\r\n /* extract aspect ratio */\r\n\r\n this.aspectRatio = extractAspectRatio(node, errorHandler);\r\n\r\n /* check timebase */\r\n\r\n var attr = findAttribute(node, imscNames.ns_ttp, \"timeBase\");\r\n\r\n if (attr !== null && attr !== \"media\") {\r\n\r\n reportFatal(errorHandler, \"Unsupported time base\");\r\n\r\n }\r\n\r\n /* retrieve extent */\r\n\r\n var e = extractExtent(node, errorHandler);\r\n\r\n if (e === null) {\r\n\r\n this.pxLength = {\r\n 'h': null,\r\n 'w': null\r\n };\r\n\r\n } else {\r\n\r\n if (e.h.unit !== \"px\" || e.w.unit !== \"px\") {\r\n reportFatal(errorHandler, \"Extent on TT must be in px or absent\");\r\n }\r\n\r\n this.pxLength = {\r\n 'h': new imscUtils.ComputedLength(0, 1 / e.h.value),\r\n 'w': new imscUtils.ComputedLength(1 / e.w.value, 0)\r\n };\r\n }\r\n \r\n /** set root container dimensions to (1, 1) arbitrarily\r\n * the root container is mapped to actual dimensions at rendering\r\n **/\r\n \r\n this.dimensions = {\r\n 'h': new imscUtils.ComputedLength(0, 1),\r\n 'w': new imscUtils.ComputedLength(1, 0)\r\n\r\n };\r\n\r\n /* xml:lang */\r\n\r\n this.lang = xmllang;\r\n\r\n };\r\n\r\n /* register a temporal events */\r\n TT.prototype._registerEvent = function (elem) {\r\n\r\n /* skip if begin is not < then end */\r\n\r\n if (elem.end <= elem.begin)\r\n return;\r\n\r\n /* index the begin time of the event */\r\n\r\n var b_i = indexOf(this.events, elem.begin);\r\n\r\n if (!b_i.found) {\r\n this.events.splice(b_i.index, 0, elem.begin);\r\n }\r\n\r\n /* index the end time of the event */\r\n\r\n if (elem.end !== Number.POSITIVE_INFINITY) {\r\n\r\n var e_i = indexOf(this.events, elem.end);\r\n\r\n if (!e_i.found) {\r\n this.events.splice(e_i.index, 0, elem.end);\r\n }\r\n\r\n }\r\n\r\n };\r\n\r\n\r\n /*\r\n * Retrieves the range of ISD times covered by the document\r\n * \r\n * @returns {Array} Array of two elements: min_begin_time and max_begin_time\r\n * \r\n */\r\n TT.prototype.getMediaTimeRange = function () {\r\n\r\n return [this.events[0], this.events[this.events.length - 1]];\r\n };\r\n\r\n /*\r\n * Returns list of ISD begin times \r\n * \r\n * @returns {Array}\r\n */\r\n TT.prototype.getMediaTimeEvents = function () {\r\n\r\n return this.events;\r\n };\r\n\r\n /*\r\n * Represents a TTML Head element\r\n */\r\n\r\n function Head() {\r\n this.styling = new Styling();\r\n this.layout = new Layout();\r\n }\r\n\r\n /*\r\n * Represents a TTML Styling element\r\n */\r\n\r\n function Styling() {\r\n this.styles = {};\r\n this.initials = {};\r\n }\r\n\r\n /*\r\n * Represents a TTML Style element\r\n */\r\n\r\n function Style() {\r\n this.id = null;\r\n this.styleAttrs = null;\r\n this.styleRefs = null;\r\n }\r\n\r\n Style.prototype.initFromNode = function (node, errorHandler) {\r\n this.id = elementGetXMLID(node);\r\n this.styleAttrs = elementGetStyles(node, errorHandler);\r\n this.styleRefs = elementGetStyleRefs(node);\r\n };\r\n \r\n /*\r\n * Represents a TTML initial element\r\n */\r\n\r\n function Initial() {\r\n this.styleAttrs = null;\r\n }\r\n\r\n Initial.prototype.initFromNode = function (node, errorHandler) {\r\n \r\n this.styleAttrs = {};\r\n \r\n for (var i in node.attributes) {\r\n\r\n if (node.attributes[i].uri === imscNames.ns_itts ||\r\n node.attributes[i].uri === imscNames.ns_ebutts ||\r\n node.attributes[i].uri === imscNames.ns_tts) {\r\n \r\n var qname = node.attributes[i].uri + \" \" + node.attributes[i].local;\r\n \r\n this.styleAttrs[qname] = node.attributes[i].value;\r\n\r\n }\r\n }\r\n \r\n };\r\n\r\n /*\r\n * Represents a TTML Layout element\r\n * \r\n */\r\n\r\n function Layout() {\r\n this.regions = {};\r\n }\r\n \r\n /*\r\n * Represents a TTML image element\r\n */\r\n\r\n function Image(src, type) {\r\n ContentElement.call(this, 'image');\r\n this.src = src;\r\n this.type = type;\r\n }\r\n\r\n Image.prototype.initFromNode = function (doc, parent, node, xmllang, errorHandler) {\r\n this.src = 'src' in node.attributes ? node.attributes.src.value : null;\r\n \r\n if (! this.src) {\r\n reportError(errorHandler, \"Invalid image@src attribute\");\r\n }\r\n \r\n this.type = 'type' in node.attributes ? node.attributes.type.value : null;\r\n \r\n if (! this.type) {\r\n reportError(errorHandler, \"Invalid image@type attribute\");\r\n }\r\n \r\n StyledElement.prototype.initFromNode.call(this, doc, parent, node, errorHandler);\r\n TimedElement.prototype.initFromNode.call(this, doc, parent, node, errorHandler);\r\n AnimatedElement.prototype.initFromNode.call(this, doc, parent, node, errorHandler);\r\n LayoutElement.prototype.initFromNode.call(this, doc, parent, node, errorHandler);\r\n\r\n this.lang = xmllang;\r\n };\r\n\r\n /*\r\n * TTML element utility functions\r\n * \r\n */\r\n\r\n function ContentElement(kind) {\r\n this.kind = kind;\r\n }\r\n\r\n function IdentifiedElement(id) {\r\n this.id = id;\r\n }\r\n\r\n IdentifiedElement.prototype.initFromNode = function (doc, parent, node, errorHandler) {\r\n this.id = elementGetXMLID(node);\r\n };\r\n\r\n function LayoutElement(id) {\r\n this.regionID = id;\r\n }\r\n\r\n LayoutElement.prototype.initFromNode = function (doc, parent, node, errorHandler) {\r\n this.regionID = elementGetRegionID(node);\r\n };\r\n\r\n function StyledElement(styleAttrs) {\r\n this.styleAttrs = styleAttrs;\r\n }\r\n\r\n StyledElement.prototype.initFromNode = function (doc, parent, node, errorHandler) {\r\n\r\n this.styleAttrs = elementGetStyles(node, errorHandler);\r\n\r\n if (doc.head !== null && doc.head.styling !== null) {\r\n mergeReferencedStyles(doc.head.styling, elementGetStyleRefs(node), this.styleAttrs, errorHandler);\r\n }\r\n\r\n };\r\n\r\n function AnimatedElement(sets) {\r\n this.sets = sets;\r\n }\r\n\r\n AnimatedElement.prototype.initFromNode = function (doc, parent, node, errorHandler) {\r\n this.sets = [];\r\n };\r\n\r\n function ContainerElement(contents) {\r\n this.contents = contents;\r\n }\r\n\r\n ContainerElement.prototype.initFromNode = function (doc, parent, node, errorHandler) {\r\n this.contents = [];\r\n };\r\n\r\n function TimedElement(explicit_begin, explicit_end, explicit_dur) {\r\n this.explicit_begin = explicit_begin;\r\n this.explicit_end = explicit_end;\r\n this.explicit_dur = explicit_dur;\r\n }\r\n\r\n TimedElement.prototype.initFromNode = function (doc, parent, node, errorHandler) {\r\n var t = processTiming(doc, parent, node, errorHandler);\r\n this.explicit_begin = t.explicit_begin;\r\n this.explicit_end = t.explicit_end;\r\n this.explicit_dur = t.explicit_dur;\r\n\r\n this.timeContainer = elementGetTimeContainer(node, errorHandler);\r\n };\r\n\r\n\r\n /*\r\n * Represents a TTML body element\r\n */\r\n\r\n\r\n\r\n function Body() {\r\n ContentElement.call(this, 'body');\r\n }\r\n\r\n\r\n Body.prototype.initFromNode = function (doc, node, xmllang, errorHandler) {\r\n StyledElement.prototype.initFromNode.call(this, doc, null, node, errorHandler);\r\n TimedElement.prototype.initFromNode.call(this, doc, null, node, errorHandler);\r\n AnimatedElement.prototype.initFromNode.call(this, doc, null, node, errorHandler);\r\n LayoutElement.prototype.initFromNode.call(this, doc, null, node, errorHandler);\r\n ContainerElement.prototype.initFromNode.call(this, doc, null, node, errorHandler);\r\n\r\n this.lang = xmllang;\r\n };\r\n\r\n /*\r\n * Represents a TTML div element\r\n */\r\n\r\n function Div() {\r\n ContentElement.call(this, 'div');\r\n }\r\n\r\n Div.prototype.initFromNode = function (doc, parent, node, xmllang, errorHandler) {\r\n StyledElement.prototype.initFromNode.call(this, doc, parent, node, errorHandler);\r\n TimedElement.prototype.initFromNode.call(this, doc, parent, node, errorHandler);\r\n AnimatedElement.prototype.initFromNode.call(this, doc, parent, node, errorHandler);\r\n LayoutElement.prototype.initFromNode.call(this, doc, parent, node, errorHandler);\r\n ContainerElement.prototype.initFromNode.call(this, doc, parent, node, errorHandler);\r\n\r\n this.lang = xmllang;\r\n };\r\n\r\n /*\r\n * Represents a TTML p element\r\n */\r\n\r\n function P() {\r\n ContentElement.call(this, 'p');\r\n }\r\n\r\n P.prototype.initFromNode = function (doc, parent, node, xmllang, errorHandler) {\r\n StyledElement.prototype.initFromNode.call(this, doc, parent, node, errorHandler);\r\n TimedElement.prototype.initFromNode.call(this, doc, parent, node, errorHandler);\r\n AnimatedElement.prototype.initFromNode.call(this, doc, parent, node, errorHandler);\r\n LayoutElement.prototype.initFromNode.call(this, doc, parent, node, errorHandler);\r\n ContainerElement.prototype.initFromNode.call(this, doc, parent, node, errorHandler);\r\n\r\n this.lang = xmllang;\r\n };\r\n\r\n /*\r\n * Represents a TTML span element\r\n */\r\n\r\n function Span() {\r\n ContentElement.call(this, 'span');\r\n }\r\n\r\n Span.prototype.initFromNode = function (doc, parent, node, xmllang, xmlspace, errorHandler) {\r\n StyledElement.prototype.initFromNode.call(this, doc, parent, node, errorHandler);\r\n TimedElement.prototype.initFromNode.call(this, doc, parent, node, errorHandler);\r\n AnimatedElement.prototype.initFromNode.call(this, doc, parent, node, errorHandler);\r\n LayoutElement.prototype.initFromNode.call(this, doc, parent, node, errorHandler);\r\n ContainerElement.prototype.initFromNode.call(this, doc, parent, node, errorHandler);\r\n\r\n this.space = xmlspace;\r\n this.lang = xmllang;\r\n };\r\n\r\n /*\r\n * Represents a TTML anonymous span element\r\n */\r\n\r\n function AnonymousSpan() {\r\n ContentElement.call(this, 'span');\r\n }\r\n\r\n AnonymousSpan.prototype.initFromText = function (doc, parent, text, xmllang, xmlspace, errorHandler) {\r\n TimedElement.prototype.initFromNode.call(this, doc, parent, null, errorHandler);\r\n\r\n this.text = text;\r\n this.space = xmlspace;\r\n this.lang = xmllang;\r\n };\r\n\r\n /*\r\n * Represents a TTML br element\r\n */\r\n\r\n function Br() {\r\n ContentElement.call(this, 'br');\r\n }\r\n\r\n Br.prototype.initFromNode = function (doc, parent, node, xmllang, errorHandler) {\r\n LayoutElement.prototype.initFromNode.call(this, doc, parent, node, errorHandler);\r\n TimedElement.prototype.initFromNode.call(this, doc, parent, node, errorHandler);\r\n\r\n this.lang = xmllang;\r\n };\r\n\r\n /*\r\n * Represents a TTML Region element\r\n * \r\n */\r\n\r\n function Region() {\r\n }\r\n\r\n Region.prototype.createDefaultRegion = function (xmllang) {\r\n var r = new Region();\r\n\r\n IdentifiedElement.call(r, '');\r\n StyledElement.call(r, {});\r\n AnimatedElement.call(r, []);\r\n TimedElement.call(r, 0, Number.POSITIVE_INFINITY, null);\r\n\r\n this.lang = xmllang;\r\n\r\n return r;\r\n };\r\n\r\n Region.prototype.initFromNode = function (doc, node, xmllang, errorHandler) {\r\n IdentifiedElement.prototype.initFromNode.call(this, doc, null, node, errorHandler);\r\n TimedElement.prototype.initFromNode.call(this, doc, null, node, errorHandler);\r\n AnimatedElement.prototype.initFromNode.call(this, doc, null, node, errorHandler);\r\n\r\n /* add specified styles */\r\n\r\n this.styleAttrs = elementGetStyles(node, errorHandler);\r\n\r\n /* remember referential styles for merging after nested styling is processed*/\r\n\r\n this.styleRefs = elementGetStyleRefs(node);\r\n\r\n /* xml:lang */\r\n\r\n this.lang = xmllang;\r\n };\r\n\r\n /*\r\n * Represents a TTML Set element\r\n * \r\n */\r\n\r\n function Set() {\r\n }\r\n\r\n Set.prototype.initFromNode = function (doc, parent, node, errorHandler) {\r\n\r\n TimedElement.prototype.initFromNode.call(this, doc, parent, node, errorHandler);\r\n\r\n var styles = elementGetStyles(node, errorHandler);\r\n\r\n this.qname = null;\r\n this.value = null;\r\n\r\n for (var qname in styles) {\r\n\r\n if (! styles.hasOwnProperty(qname)) continue;\r\n\r\n if (this.qname) {\r\n\r\n reportError(errorHandler, \"More than one style specified on set\");\r\n break;\r\n\r\n }\r\n\r\n this.qname = qname;\r\n this.value = styles[qname];\r\n\r\n }\r\n\r\n };\r\n\r\n /*\r\n * Utility functions\r\n * \r\n */\r\n\r\n\r\n function elementGetXMLID(node) {\r\n return node && 'xml:id' in node.attributes ? node.attributes['xml:id'].value || null : null;\r\n }\r\n\r\n function elementGetRegionID(node) {\r\n return node && 'region' in node.attributes ? node.attributes.region.value : '';\r\n }\r\n\r\n function elementGetTimeContainer(node, errorHandler) {\r\n\r\n var tc = node && 'timeContainer' in node.attributes ? node.attributes.timeContainer.value : null;\r\n\r\n if ((!tc) || tc === \"par\") {\r\n\r\n return \"par\";\r\n\r\n } else if (tc === \"seq\") {\r\n\r\n return \"seq\";\r\n\r\n } else {\r\n\r\n reportError(errorHandler, \"Illegal value of timeContainer (assuming 'par')\");\r\n\r\n return \"par\";\r\n\r\n }\r\n\r\n }\r\n\r\n function elementGetStyleRefs(node) {\r\n\r\n return node && 'style' in node.attributes ? node.attributes.style.value.split(\" \") : [];\r\n\r\n }\r\n\r\n function elementGetStyles(node, errorHandler) {\r\n\r\n var s = {};\r\n\r\n if (node !== null) {\r\n\r\n for (var i in node.attributes) {\r\n\r\n var qname = node.attributes[i].uri + \" \" + node.attributes[i].local;\r\n\r\n var sa = imscStyles.byQName[qname];\r\n\r\n if (sa !== undefined) {\r\n\r\n var val = sa.parse(node.attributes[i].value);\r\n\r\n if (val !== null) {\r\n\r\n s[qname] = val;\r\n\r\n /* TODO: consider refactoring errorHandler into parse and compute routines */\r\n\r\n if (sa === imscStyles.byName.zIndex) {\r\n reportWarning(errorHandler, \"zIndex attribute present but not used by IMSC1 since regions do not overlap\");\r\n }\r\n\r\n } else {\r\n\r\n reportError(errorHandler, \"Cannot parse styling attribute \" + qname + \" --> \" + node.attributes[i].value);\r\n\r\n }\r\n\r\n }\r\n\r\n }\r\n\r\n }\r\n\r\n return s;\r\n }\r\n\r\n function findAttribute(node, ns, name) {\r\n for (var i in node.attributes) {\r\n\r\n if (node.attributes[i].uri === ns &&\r\n node.attributes[i].local === name) {\r\n\r\n return node.attributes[i].value;\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n function extractAspectRatio(node, errorHandler) {\r\n\r\n var ar = findAttribute(node, imscNames.ns_ittp, \"aspectRatio\");\r\n\r\n if (ar === null) {\r\n \r\n ar = findAttribute(node, imscNames.ns_ttp, \"displayAspectRatio\");\r\n \r\n }\r\n\r\n var rslt = null;\r\n\r\n if (ar !== null) {\r\n\r\n var ASPECT_RATIO_RE = /(\\d+)\\s+(\\d+)/;\r\n\r\n var m = ASPECT_RATIO_RE.exec(ar);\r\n\r\n if (m !== null) {\r\n\r\n var w = parseInt(m[1]);\r\n\r\n var h = parseInt(m[2]);\r\n\r\n if (w !== 0 && h !== 0) {\r\n\r\n rslt = w / h;\r\n\r\n } else {\r\n\r\n reportError(errorHandler, \"Illegal aspectRatio values (ignoring)\");\r\n }\r\n\r\n } else {\r\n\r\n reportError(errorHandler, \"Malformed aspectRatio attribute (ignoring)\");\r\n }\r\n\r\n }\r\n\r\n return rslt;\r\n\r\n }\r\n\r\n /*\r\n * Returns the cellResolution attribute from a node\r\n * \r\n */\r\n function extractCellResolution(node, errorHandler) {\r\n\r\n var cr = findAttribute(node, imscNames.ns_ttp, \"cellResolution\");\r\n\r\n // initial value\r\n\r\n var h = 15;\r\n var w = 32;\r\n\r\n if (cr !== null) {\r\n\r\n var CELL_RESOLUTION_RE = /(\\d+) (\\d+)/;\r\n\r\n var m = CELL_RESOLUTION_RE.exec(cr);\r\n\r\n if (m !== null) {\r\n\r\n w = parseInt(m[1]);\r\n\r\n h = parseInt(m[2]);\r\n\r\n } else {\r\n\r\n reportWarning(errorHandler, \"Malformed cellResolution value (using initial value instead)\");\r\n\r\n }\r\n\r\n }\r\n\r\n return {'w': w, 'h': h};\r\n\r\n }\r\n\r\n\r\n function extractFrameAndTickRate(node, errorHandler) {\r\n\r\n // subFrameRate is ignored per IMSC1 specification\r\n\r\n // extract frame rate\r\n\r\n var fps_attr = findAttribute(node, imscNames.ns_ttp, \"frameRate\");\r\n\r\n // initial value\r\n\r\n var fps = 30;\r\n\r\n // match variable\r\n\r\n var m;\r\n\r\n if (fps_attr !== null) {\r\n\r\n var FRAME_RATE_RE = /(\\d+)/;\r\n\r\n m = FRAME_RATE_RE.exec(fps_attr);\r\n\r\n if (m !== null) {\r\n\r\n fps = parseInt(m[1]);\r\n\r\n } else {\r\n\r\n reportWarning(errorHandler, \"Malformed frame rate attribute (using initial value instead)\");\r\n }\r\n\r\n }\r\n\r\n // extract frame rate multiplier\r\n\r\n var frm_attr = findAttribute(node, imscNames.ns_ttp, \"frameRateMultiplier\");\r\n\r\n // initial value\r\n\r\n var frm = 1;\r\n\r\n if (frm_attr !== null) {\r\n\r\n var FRAME_RATE_MULT_RE = /(\\d+) (\\d+)/;\r\n\r\n m = FRAME_RATE_MULT_RE.exec(frm_attr);\r\n\r\n if (m !== null) {\r\n\r\n frm = parseInt(m[1]) / parseInt(m[2]);\r\n\r\n } else {\r\n\r\n reportWarning(errorHandler, \"Malformed frame rate multiplier attribute (using initial value instead)\");\r\n }\r\n\r\n }\r\n\r\n var efps = frm * fps;\r\n\r\n // extract tick rate\r\n\r\n var tr = 1;\r\n\r\n var trattr = findAttribute(node, imscNames.ns_ttp, \"tickRate\");\r\n\r\n if (trattr === null) {\r\n\r\n if (fps_attr !== null)\r\n tr = efps;\r\n\r\n } else {\r\n\r\n var TICK_RATE_RE = /(\\d+)/;\r\n\r\n m = TICK_RATE_RE.exec(trattr);\r\n\r\n if (m !== null) {\r\n\r\n tr = parseInt(m[1]);\r\n\r\n } else {\r\n\r\n reportWarning(errorHandler, \"Malformed tick rate attribute (using initial value instead)\");\r\n }\r\n\r\n }\r\n\r\n return {effectiveFrameRate: efps, tickRate: tr};\r\n\r\n }\r\n\r\n function extractExtent(node, errorHandler) {\r\n\r\n var attr = findAttribute(node, imscNames.ns_tts, \"extent\");\r\n\r\n if (attr === null)\r\n return null;\r\n\r\n var s = attr.split(\" \");\r\n\r\n if (s.length !== 2) {\r\n\r\n reportWarning(errorHandler, \"Malformed extent (ignoring)\");\r\n\r\n return null;\r\n }\r\n\r\n var w = imscUtils.parseLength(s[0]);\r\n\r\n var h = imscUtils.parseLength(s[1]);\r\n\r\n if (!h || !w) {\r\n\r\n reportWarning(errorHandler, \"Malformed extent values (ignoring)\");\r\n\r\n return null;\r\n }\r\n\r\n return {'h': h, 'w': w};\r\n\r\n }\r\n\r\n function parseTimeExpression(tickRate, effectiveFrameRate, str) {\r\n\r\n var CLOCK_TIME_FRACTION_RE = /^(\\d{2,}):(\\d\\d):(\\d\\d(?:\\.\\d+)?)$/;\r\n var CLOCK_TIME_FRAMES_RE = /^(\\d{2,}):(\\d\\d):(\\d\\d)\\:(\\d{2,})$/;\r\n var OFFSET_FRAME_RE = /^(\\d+(?:\\.\\d+)?)f$/;\r\n var OFFSET_TICK_RE = /^(\\d+(?:\\.\\d+)?)t$/;\r\n var OFFSET_MS_RE = /^(\\d+(?:\\.\\d+)?)ms$/;\r\n var OFFSET_S_RE = /^(\\d+(?:\\.\\d+)?)s$/;\r\n var OFFSET_H_RE = /^(\\d+(?:\\.\\d+)?)h$/;\r\n var OFFSET_M_RE = /^(\\d+(?:\\.\\d+)?)m$/;\r\n var m;\r\n var r = null;\r\n if ((m = OFFSET_FRAME_RE.exec(str)) !== null) {\r\n\r\n if (effectiveFrameRate !== null) {\r\n\r\n r = parseFloat(m[1]) / effectiveFrameRate;\r\n }\r\n\r\n } else if ((m = OFFSET_TICK_RE.exec(str)) !== null) {\r\n\r\n if (tickRate !== null) {\r\n\r\n r = parseFloat(m[1]) / tickRate;\r\n }\r\n\r\n } else if ((m = OFFSET_MS_RE.exec(str)) !== null) {\r\n\r\n r = parseFloat(m[1]) / 1000.0;\r\n\r\n } else if ((m = OFFSET_S_RE.exec(str)) !== null) {\r\n\r\n r = parseFloat(m[1]);\r\n\r\n } else if ((m = OFFSET_H_RE.exec(str)) !== null) {\r\n\r\n r = parseFloat(m[1]) * 3600.0;\r\n\r\n } else if ((m = OFFSET_M_RE.exec(str)) !== null) {\r\n\r\n r = parseFloat(m[1]) * 60.0;\r\n\r\n } else if ((m = CLOCK_TIME_FRACTION_RE.exec(str)) !== null) {\r\n\r\n r = parseInt(m[1]) * 3600 +\r\n parseInt(m[2]) * 60 +\r\n parseFloat(m[3]);\r\n\r\n } else if ((m = CLOCK_TIME_FRAMES_RE.exec(str)) !== null) {\r\n\r\n /* this assumes that HH:MM:SS is a clock-time-with-fraction */\r\n\r\n if (effectiveFrameRate !== null) {\r\n\r\n r = parseInt(m[1]) * 3600 +\r\n parseInt(m[2]) * 60 +\r\n parseInt(m[3]) +\r\n (m[4] === null ? 0 : parseInt(m[4]) / effectiveFrameRate);\r\n }\r\n\r\n }\r\n\r\n return r;\r\n }\r\n\r\n function processTiming(doc, parent, node, errorHandler) {\r\n\r\n /* determine explicit begin */\r\n\r\n var explicit_begin = null;\r\n\r\n if (node && 'begin' in node.attributes) {\r\n\r\n explicit_begin = parseTimeExpression(doc.tickRate, doc.effectiveFrameRate, node.attributes.begin.value);\r\n\r\n if (explicit_begin === null) {\r\n\r\n reportWarning(errorHandler, \"Malformed begin value \" + node.attributes.begin.value + \" (using 0)\");\r\n\r\n }\r\n\r\n }\r\n\r\n /* determine explicit duration */\r\n\r\n var explicit_dur = null;\r\n\r\n if (node && 'dur' in node.attributes) {\r\n\r\n explicit_dur = parseTimeExpression(doc.tickRate, doc.effectiveFrameRate, node.attributes.dur.value);\r\n\r\n if (explicit_dur === null) {\r\n\r\n reportWarning(errorHandler, \"Malformed dur value \" + node.attributes.dur.value + \" (ignoring)\");\r\n\r\n }\r\n\r\n }\r\n\r\n /* determine explicit end */\r\n\r\n var explicit_end = null;\r\n\r\n if (node && 'end' in node.attributes) {\r\n\r\n explicit_end = parseTimeExpression(doc.tickRate, doc.effectiveFrameRate, node.attributes.end.value);\r\n\r\n if (explicit_end === null) {\r\n\r\n reportWarning(errorHandler, \"Malformed end value (ignoring)\");\r\n\r\n }\r\n\r\n }\r\n\r\n return {explicit_begin: explicit_begin,\r\n explicit_end: explicit_end,\r\n explicit_dur: explicit_dur};\r\n\r\n }\r\n\r\n\r\n\r\n function mergeChainedStyles(styling, style, errorHandler) {\r\n\r\n while (style.styleRefs.length > 0) {\r\n\r\n var sref = style.styleRefs.pop();\r\n\r\n if (!(sref in styling.styles)) {\r\n reportError(errorHandler, \"Non-existant style id referenced\");\r\n continue;\r\n }\r\n\r\n mergeChainedStyles(styling, styling.styles[sref], errorHandler);\r\n\r\n mergeStylesIfNotPresent(styling.styles[sref].styleAttrs, style.styleAttrs);\r\n\r\n }\r\n\r\n }\r\n\r\n function mergeReferencedStyles(styling, stylerefs, styleattrs, errorHandler) {\r\n\r\n for (var i = stylerefs.length - 1; i >= 0; i--) {\r\n\r\n var sref = stylerefs[i];\r\n\r\n if (!(sref in styling.styles)) {\r\n reportError(errorHandler, \"Non-existant style id referenced\");\r\n continue;\r\n }\r\n\r\n mergeStylesIfNotPresent(styling.styles[sref].styleAttrs, styleattrs);\r\n\r\n }\r\n\r\n }\r\n\r\n function mergeStylesIfNotPresent(from_styles, into_styles) {\r\n\r\n for (var sname in from_styles) {\r\n\r\n if (! from_styles.hasOwnProperty(sname)) continue;\r\n\r\n if (sname in into_styles)\r\n continue;\r\n\r\n into_styles[sname] = from_styles[sname];\r\n\r\n }\r\n\r\n }\r\n\r\n /* TODO: validate style format at parsing */\r\n\r\n\r\n /*\r\n * ERROR HANDLING UTILITY FUNCTIONS\r\n * \r\n */\r\n\r\n function reportInfo(errorHandler, msg) {\r\n\r\n if (errorHandler && errorHandler.info && errorHandler.info(msg))\r\n throw msg;\r\n\r\n }\r\n\r\n function reportWarning(errorHandler, msg) {\r\n\r\n if (errorHandler && errorHandler.warn && errorHandler.warn(msg))\r\n throw msg;\r\n\r\n }\r\n\r\n function reportError(errorHandler, msg) {\r\n\r\n if (errorHandler && errorHandler.error && errorHandler.error(msg))\r\n throw msg;\r\n\r\n }\r\n\r\n function reportFatal(errorHandler, msg) {\r\n\r\n if (errorHandler && errorHandler.fatal)\r\n errorHandler.fatal(msg);\r\n\r\n throw msg;\r\n\r\n }\r\n\r\n /*\r\n * Binary search utility function\r\n * \r\n * @typedef {Object} BinarySearchResult\r\n * @property {boolean} found Was an exact match found?\r\n * @property {number} index Position of the exact match or insert position\r\n * \r\n * @returns {BinarySearchResult}\r\n */\r\n\r\n function indexOf(arr, searchval) {\r\n\r\n var min = 0;\r\n var max = arr.length - 1;\r\n var cur;\r\n\r\n while (min <= max) {\r\n\r\n cur = Math.floor((min + max) / 2);\r\n\r\n var curval = arr[cur];\r\n\r\n if (curval < searchval) {\r\n\r\n min = cur + 1;\r\n\r\n } else if (curval > searchval) {\r\n\r\n max = cur - 1;\r\n\r\n } else {\r\n\r\n return {found: true, index: cur};\r\n\r\n }\r\n\r\n }\r\n\r\n return {found: false, index: min};\r\n }\r\n\r\n\r\n})( false ? undefined : exports,\r\n typeof sax === 'undefined' ? __webpack_require__(/*! sax */ \"../imsc/node_modules/sax/lib/sax.js\") : sax,\r\n typeof imscNames === 'undefined' ? __webpack_require__(/*! ./names */ \"../imsc/src/main/js/names.js\") : imscNames,\r\n typeof imscStyles === 'undefined' ? __webpack_require__(/*! ./styles */ \"../imsc/src/main/js/styles.js\") : imscStyles,\r\n typeof imscUtils === 'undefined' ? __webpack_require__(/*! ./utils */ \"../imsc/src/main/js/utils.js\") : imscUtils);\r\n\n\n//# sourceURL=webpack://ardplayer/../imsc/src/main/js/doc.js?");
|
|
80
|
-
|
|
81
|
-
/***/ }),
|
|
82
|
-
|
|
83
|
-
/***/ "../imsc/src/main/js/html.js":
|
|
84
|
-
/*!***********************************!*\
|
|
85
|
-
!*** ../imsc/src/main/js/html.js ***!
|
|
86
|
-
\***********************************/
|
|
87
|
-
/*! no static exports found */
|
|
88
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
89
|
-
|
|
90
|
-
eval("/* \r\n * Copyright (c) 2016, Pierre-Anthony Lemieux <pal@sandflow.com>\r\n * All rights reserved.\r\n *\r\n * Redistribution and use in source and binary forms, with or without\r\n * modification, are permitted provided that the following conditions are met:\r\n *\r\n * * Redistributions of source code must retain the above copyright notice, this\r\n * list of conditions and the following disclaimer.\r\n * * Redistributions in binary form must reproduce the above copyright notice,\r\n * this list of conditions and the following disclaimer in the documentation\r\n * and/or other materials provided with the distribution.\r\n *\r\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\r\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r\n * POSSIBILITY OF SUCH DAMAGE.\r\n */\r\n\r\n/**\r\n * @module imscHTML\r\n */\r\n\r\n;\r\n(function (imscHTML, imscNames, imscStyles) {\r\n\r\n /**\r\n * Function that maps <pre>smpte:background</pre> URIs to URLs resolving to image resource\r\n * @callback IMGResolver\r\n * @param {string} <pre>smpte:background</pre> URI\r\n * @return {string} PNG resource URL\r\n */\r\n\r\n\r\n /**\r\n * Renders an ISD object (returned by <pre>generateISD()</pre>) into a \r\n * parent element, that must be attached to the DOM. The ISD will be rendered\r\n * into a child <pre>div</pre>\r\n * with heigh and width equal to the clientHeight and clientWidth of the element,\r\n * unless explicitly specified otherwise by the caller. Images URIs specified \r\n * by <pre>smpte:background</pre> attributes are mapped to image resource URLs\r\n * by an <pre>imgResolver</pre> function. The latter takes the value of <code>smpte:background</code>\r\n * attribute and an <code>img</code> DOM element as input, and is expected to\r\n * set the <code>src</code> attribute of the <code>img</code> to the absolute URI of the image.\r\n * <pre>displayForcedOnlyMode</pre> sets the (boolean)\r\n * value of the IMSC1 displayForcedOnlyMode parameter. The function returns\r\n * an opaque object that should passed in <code>previousISDState</code> when this function\r\n * is called for the next ISD, otherwise <code>previousISDState</code> should be set to \r\n * <code>null</code>.\r\n * \r\n * @param {Object} isd ISD to be rendered\r\n * @param {Object} element Element into which the ISD is rendered\r\n * @param {?IMGResolver} imgResolver Resolve <pre>smpte:background</pre> URIs into URLs.\r\n * @param {?number} eheight Height (in pixel) of the child <div>div</div> or null \r\n * to use clientHeight of the parent element\r\n * @param {?number} ewidth Width (in pixel) of the child <div>div</div> or null\r\n * to use clientWidth of the parent element\r\n * @param {?boolean} displayForcedOnlyMode Value of the IMSC1 displayForcedOnlyMode parameter,\r\n * or false if null \r\n * @param {?module:imscUtils.ErrorHandler} errorHandler Error callback\r\n * @param {Object} previousISDState State saved during processing of the previous ISD, or null if initial call\r\n * @param {?boolean} enableRollUp Enables roll-up animations (see CEA 708)\r\n * @return {Object} ISD state to be provided when this funtion is called for the next ISD\r\n */\r\n\r\n imscHTML.render = function (isd,\r\n element,\r\n imgResolver,\r\n eheight,\r\n ewidth,\r\n displayForcedOnlyMode,\r\n errorHandler,\r\n previousISDState,\r\n enableRollUp\r\n ) {\r\n\r\n /* maintain aspect ratio if specified */\r\n\r\n var height = eheight || element.clientHeight;\r\n var width = ewidth || element.clientWidth;\r\n\r\n if (isd.aspectRatio !== null) {\r\n\r\n var twidth = height * isd.aspectRatio;\r\n\r\n if (twidth > width) {\r\n\r\n height = Math.round(width / isd.aspectRatio);\r\n\r\n } else {\r\n\r\n width = twidth;\r\n\r\n }\r\n\r\n }\r\n\r\n var rootcontainer = document.createElement(\"div\");\r\n\r\n rootcontainer.style.position = \"relative\";\r\n rootcontainer.style.width = width + \"px\";\r\n rootcontainer.style.height = height + \"px\";\r\n rootcontainer.style.margin = \"auto\";\r\n rootcontainer.style.top = 0;\r\n rootcontainer.style.bottom = 0;\r\n rootcontainer.style.left = 0;\r\n rootcontainer.style.right = 0;\r\n rootcontainer.style.zIndex = 0;\r\n\r\n var context = {\r\n h: height,\r\n w: width,\r\n regionH: null,\r\n regionW: null,\r\n imgResolver: imgResolver,\r\n displayForcedOnlyMode: displayForcedOnlyMode || false,\r\n isd: isd,\r\n errorHandler: errorHandler,\r\n previousISDState: previousISDState,\r\n enableRollUp: enableRollUp || false,\r\n currentISDState: {},\r\n flg: null, /* current fillLineGap value if active, null otherwise */\r\n lp: null, /* current linePadding value if active, null otherwise */\r\n mra: null, /* current multiRowAlign value if active, null otherwise */\r\n ipd: null, /* inline progression direction (lr, rl, tb) */\r\n bpd: null, /* block progression direction (lr, rl, tb) */\r\n ruby: null, /* is ruby present in a <p> */\r\n textEmphasis: null, /* is textEmphasis present in a <p> */\r\n rubyReserve: null /* is rubyReserve applicable to a <p> */\r\n };\r\n\r\n element.appendChild(rootcontainer);\r\n\r\n if (\"contents\" in isd) {\r\n\r\n for (var i = 0; i < isd.contents.length; i++) {\r\n\r\n processElement(context, rootcontainer, isd.contents[i], isd);\r\n\r\n }\r\n\r\n }\r\n\r\n return context.currentISDState;\r\n\r\n };\r\n\r\n function processElement(context, dom_parent, isd_element, isd_parent) {\r\n\r\n var e;\r\n\r\n if (isd_element.kind === 'region') {\r\n\r\n e = document.createElement(\"div\");\r\n e.style.position = \"absolute\";\r\n\r\n } else if (isd_element.kind === 'body') {\r\n\r\n e = document.createElement(\"div\");\r\n\r\n } else if (isd_element.kind === 'div') {\r\n\r\n e = document.createElement(\"div\");\r\n\r\n } else if (isd_element.kind === 'image') {\r\n\r\n e = document.createElement(\"img\");\r\n\r\n if (context.imgResolver !== null && isd_element.src !== null) {\r\n\r\n var uri = context.imgResolver(isd_element.src, e);\r\n\r\n if (uri)\r\n e.src = uri;\r\n\r\n e.height = context.regionH;\r\n e.width = context.regionW;\r\n\r\n }\r\n\r\n } else if (isd_element.kind === 'p') {\r\n\r\n e = document.createElement(\"p\");\r\n\r\n } else if (isd_element.kind === 'span') {\r\n\r\n if (isd_element.styleAttrs[imscStyles.byName.ruby.qname] === \"container\") {\r\n\r\n e = document.createElement(\"ruby\");\r\n\r\n context.ruby = true;\r\n\r\n } else if (isd_element.styleAttrs[imscStyles.byName.ruby.qname] === \"base\") {\r\n\r\n e = document.createElement(\"rb\");\r\n\r\n } else if (isd_element.styleAttrs[imscStyles.byName.ruby.qname] === \"text\") {\r\n\r\n e = document.createElement(\"rt\");\r\n\r\n\r\n } else if (isd_element.styleAttrs[imscStyles.byName.ruby.qname] === \"baseContainer\") {\r\n\r\n e = document.createElement(\"rbc\");\r\n\r\n\r\n } else if (isd_element.styleAttrs[imscStyles.byName.ruby.qname] === \"textContainer\") {\r\n\r\n e = document.createElement(\"rtc\");\r\n\r\n\r\n } else if (isd_element.styleAttrs[imscStyles.byName.ruby.qname] === \"delimiter\") {\r\n\r\n /* ignore rp */\r\n\r\n return;\r\n\r\n } else {\r\n\r\n e = document.createElement(\"span\");\r\n\r\n }\r\n\r\n //e.textContent = isd_element.text;\r\n\r\n } else if (isd_element.kind === 'br') {\r\n\r\n e = document.createElement(\"br\");\r\n\r\n }\r\n\r\n if (!e) {\r\n\r\n reportError(context.errorHandler, \"Error processing ISD element kind: \" + isd_element.kind);\r\n\r\n return;\r\n\r\n }\r\n\r\n /* set language */\r\n\r\n if (isd_element.lang) {\r\n\r\n if (isd_element.kind === 'region' || isd_element.lang !== isd_parent.lang) {\r\n e.lang = isd_element.lang;\r\n }\r\n\r\n }\r\n\r\n /* add to parent */\r\n\r\n dom_parent.appendChild(e);\r\n\r\n /* override UA default margin */\r\n /* TODO: should apply to <p> only */\r\n\r\n e.style.margin = \"0\";\r\n\r\n /* determine ipd and bpd */\r\n\r\n if (isd_element.kind === \"region\") {\r\n\r\n var wdir = isd_element.styleAttrs[imscStyles.byName.writingMode.qname];\r\n\r\n if (wdir === \"lrtb\" || wdir === \"lr\") {\r\n\r\n context.ipd = \"lr\";\r\n context.bpd = \"tb\";\r\n\r\n } else if (wdir === \"rltb\" || wdir === \"rl\") {\r\n\r\n context.ipd = \"rl\";\r\n context.bpd = \"tb\";\r\n\r\n } else if (wdir === \"tblr\") {\r\n\r\n context.ipd = \"tb\";\r\n context.bpd = \"lr\";\r\n\r\n } else if (wdir === \"tbrl\" || wdir === \"tb\") {\r\n\r\n context.ipd = \"tb\";\r\n context.bpd = \"rl\";\r\n\r\n }\r\n \r\n } else if (isd_element.kind === \"p\" && context.bpd === \"tb\") {\r\n\r\n var pdir = isd_element.styleAttrs[imscStyles.byName.direction.qname];\r\n\r\n context.ipd = pdir === \"ltr\" ? \"lr\" : \"rl\"; \r\n \r\n }\r\n\r\n /* tranform TTML styles to CSS styles */\r\n\r\n for (var i = 0; i < STYLING_MAP_DEFS.length; i++) {\r\n\r\n var sm = STYLING_MAP_DEFS[i];\r\n\r\n var attr = isd_element.styleAttrs[sm.qname];\r\n\r\n if (attr !== undefined && sm.map !== null) {\r\n\r\n sm.map(context, e, isd_element, attr);\r\n\r\n }\r\n\r\n }\r\n\r\n var proc_e = e;\r\n\r\n /* do we have linePadding ? */\r\n\r\n var lp = isd_element.styleAttrs[imscStyles.byName.linePadding.qname];\r\n\r\n if (lp && (! lp.isZero())) {\r\n\r\n var plength = lp.toUsedLength(context.w, context.h);\r\n\r\n\r\n if (plength > 0) {\r\n \r\n /* apply padding to the <p> so that line padding does not cause line wraps */\r\n\r\n var padmeasure = Math.ceil(plength) + \"px\";\r\n\r\n if (context.bpd === \"tb\") {\r\n\r\n proc_e.style.paddingLeft = padmeasure;\r\n proc_e.style.paddingRight = padmeasure;\r\n\r\n } else {\r\n\r\n proc_e.style.paddingTop = padmeasure;\r\n proc_e.style.paddingBottom = padmeasure;\r\n\r\n }\r\n\r\n context.lp = lp;\r\n }\r\n }\r\n\r\n // do we have multiRowAlign?\r\n\r\n var mra = isd_element.styleAttrs[imscStyles.byName.multiRowAlign.qname];\r\n\r\n if (mra && mra !== \"auto\") {\r\n\r\n /* create inline block to handle multirowAlign */\r\n\r\n var s = document.createElement(\"span\");\r\n\r\n s.style.display = \"inline-block\";\r\n\r\n s.style.textAlign = mra;\r\n\r\n e.appendChild(s);\r\n\r\n proc_e = s;\r\n\r\n context.mra = mra;\r\n\r\n }\r\n\r\n /* do we have rubyReserve? */\r\n\r\n var rr = isd_element.styleAttrs[imscStyles.byName.rubyReserve.qname];\r\n\r\n if (rr && rr[0] !== \"none\") {\r\n context.rubyReserve = rr;\r\n }\r\n\r\n\r\n /* remember we are filling line gaps */\r\n\r\n if (isd_element.styleAttrs[imscStyles.byName.fillLineGap.qname]) {\r\n context.flg = true;\r\n }\r\n\r\n\r\n if (isd_element.kind === \"span\" && isd_element.text) {\r\n\r\n var te = isd_element.styleAttrs[imscStyles.byName.textEmphasis.qname];\r\n\r\n if (te && te.style !== \"none\") {\r\n\r\n context.textEmphasis = true;\r\n\r\n }\r\n\r\n if (imscStyles.byName.textCombine.qname in isd_element.styleAttrs &&\r\n isd_element.styleAttrs[imscStyles.byName.textCombine.qname] === \"all\") {\r\n\r\n /* ignore tate-chu-yoku since line break cannot happen within */\r\n e.textContent = isd_element.text;\r\n\r\n if (te) {\r\n\r\n applyTextEmphasis(context, e, isd_element, te);\r\n\r\n };\r\n\r\n } else {\r\n\r\n // wrap characters in spans to find the line wrap locations\r\n\r\n var cbuf = '';\r\n\r\n for (var j = 0; j < isd_element.text.length; j++) {\r\n\r\n cbuf += isd_element.text.charAt(j);\r\n\r\n var cc = isd_element.text.charCodeAt(j);\r\n\r\n if (cc < 0xD800 || cc > 0xDBFF || j === isd_element.text.length - 1) {\r\n\r\n /* wrap the character(s) in a span unless it is a high surrogate */\r\n\r\n var span = document.createElement(\"span\");\r\n\r\n span.textContent = cbuf;\r\n\r\n /* apply textEmphasis */\r\n \r\n if (te) {\r\n\r\n applyTextEmphasis(context, span, isd_element, te);\r\n\r\n };\r\n \r\n e.appendChild(span);\r\n\r\n cbuf = '';\r\n\r\n //For the sake of merging these back together, record what isd element generated it.\r\n span._isd_element = isd_element;\r\n }\r\n\r\n }\r\n\r\n }\r\n }\r\n\r\n /* process the children of the ISD element */\r\n\r\n if (\"contents\" in isd_element) {\r\n\r\n for (var k = 0; k < isd_element.contents.length; k++) {\r\n\r\n processElement(context, proc_e, isd_element.contents[k], isd_element);\r\n\r\n }\r\n\r\n }\r\n\r\n /* list of lines */\r\n\r\n var linelist = [];\r\n\r\n\r\n /* paragraph processing */\r\n /* TODO: linePadding only supported for horizontal scripts */\r\n\r\n if (isd_element.kind === \"p\") {\r\n\r\n constructLineList(context, proc_e, linelist, null);\r\n\r\n /* apply rubyReserve */\r\n\r\n if (context.rubyReserve) {\r\n\r\n applyRubyReserve(linelist, context);\r\n\r\n context.rubyReserve = null;\r\n\r\n }\r\n\r\n /* apply tts:rubyPosition=\"outside\" */\r\n\r\n if (context.ruby || context.rubyReserve) {\r\n\r\n applyRubyPosition(linelist, context);\r\n\r\n context.ruby = null;\r\n\r\n }\r\n\r\n /* apply text emphasis \"outside\" position */\r\n\r\n if (context.textEmphasis) {\r\n\r\n applyTextEmphasisOutside(linelist, context);\r\n\r\n context.textEmphasis = null;\r\n\r\n }\r\n\r\n /* insert line breaks for multirowalign */\r\n\r\n if (context.mra) {\r\n\r\n applyMultiRowAlign(linelist);\r\n\r\n context.mra = null;\r\n\r\n }\r\n\r\n /* add linepadding */\r\n\r\n if (context.lp) {\r\n\r\n applyLinePadding(linelist, context.lp.toUsedLength(context.w, context.h), context);\r\n\r\n context.lp = null;\r\n\r\n }\r\n\r\n mergeSpans(linelist); // The earlier we can do this the less processing there will be.\r\n\r\n /* fill line gaps linepadding */\r\n\r\n if (context.flg) {\r\n\r\n var par_edges = rect2edges(proc_e.getBoundingClientRect(), context);\r\n\r\n applyFillLineGap(linelist, par_edges.before, par_edges.after, context, proc_e);\r\n\r\n context.flg = null;\r\n\r\n }\r\n\r\n }\r\n\r\n\r\n /* region processing */\r\n\r\n if (isd_element.kind === \"region\") {\r\n\r\n /* perform roll up if needed */\r\n if ((context.bpd === \"tb\") &&\r\n context.enableRollUp &&\r\n isd_element.contents.length > 0 &&\r\n isd_element.styleAttrs[imscStyles.byName.displayAlign.qname] === 'after') {\r\n\r\n /* build line list */\r\n constructLineList(context, proc_e, linelist, null);\r\n\r\n /* horrible hack, perhaps default region id should be underscore everywhere? */\r\n\r\n var rid = isd_element.id === '' ? '_' : isd_element.id;\r\n\r\n var rb = new RegionPBuffer(rid, linelist);\r\n\r\n context.currentISDState[rb.id] = rb;\r\n\r\n if (context.previousISDState &&\r\n rb.id in context.previousISDState &&\r\n context.previousISDState[rb.id].plist.length > 0 &&\r\n rb.plist.length > 1 &&\r\n rb.plist[rb.plist.length - 2].text ===\r\n context.previousISDState[rb.id].plist[context.previousISDState[rb.id].plist.length - 1].text) {\r\n\r\n var body_elem = e.firstElementChild;\r\n\r\n var h = rb.plist[rb.plist.length - 1].after - rb.plist[rb.plist.length - 1].before;\r\n\r\n body_elem.style.bottom = \"-\" + h + \"px\";\r\n body_elem.style.transition = \"transform 0.4s\";\r\n body_elem.style.position = \"relative\";\r\n body_elem.style.transform = \"translateY(-\" + h + \"px)\";\r\n\r\n }\r\n\r\n }\r\n }\r\n }\r\n\r\n function mergeSpans(lineList) {\r\n\r\n for (var i = 0; i < lineList.length; i++) {\r\n\r\n var line = lineList[i];\r\n\r\n for (var j = 1; j < line.elements.length;) {\r\n\r\n var previous = line.elements[j - 1];\r\n var span = line.elements[j];\r\n\r\n if (spanMerge(previous.node, span.node)) {\r\n\r\n //removed from DOM by spanMerge(), remove from the list too.\r\n line.elements.splice(j, 1);\r\n continue;\r\n\r\n } else {\r\n\r\n j++;\r\n\r\n }\r\n\r\n }\r\n }\r\n\r\n // Copy backgroundColor to each span so that fillLineGap will apply padding to elements with the right background\r\n var thisNode, ancestorBackgroundColor;\r\n var clearTheseBackgrounds = [];\r\n\r\n for (var l = 0; l < lineList.length; l++) {\r\n\r\n for (var el = 0; el < lineList[l].elements.length; el++) {\r\n\r\n thisNode = lineList[l].elements[el].node;\r\n ancestorBackgroundColor = getSpanAncestorColor(thisNode, clearTheseBackgrounds, false);\r\n\r\n if (ancestorBackgroundColor) {\r\n\r\n thisNode.style.backgroundColor = ancestorBackgroundColor;\r\n\r\n }\r\n }\r\n }\r\n\r\n for (var bi = 0; bi < clearTheseBackgrounds.length; bi++) {\r\n\r\n clearTheseBackgrounds[bi].style.backgroundColor = \"\";\r\n\r\n }\r\n }\r\n\r\n function getSpanAncestorColor(element, ancestorList, isAncestor) {\r\n\r\n if (element.style.backgroundColor) {\r\n\r\n if (isAncestor && !ancestorList.includes(element)) {\r\n\r\n ancestorList.push(element);\r\n\r\n }\r\n return element.style.backgroundColor;\r\n\r\n } else {\r\n\r\n if (element.parentElement.nodeName === \"SPAN\") {\r\n\r\n return getSpanAncestorColor(element.parentElement, ancestorList, true);\r\n\r\n }\r\n\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n function spanMerge(first, second) {\r\n\r\n if (first.tagName === \"SPAN\" &&\r\n second.tagName === \"SPAN\" &&\r\n first._isd_element === second._isd_element) {\r\n\r\n first.textContent += second.textContent;\r\n\r\n for (var i = 0; i < second.style.length; i++) {\r\n\r\n var styleName = second.style[i];\r\n if (styleName.indexOf(\"border\") >= 0 || \r\n styleName.indexOf(\"padding\") >= 0 ||\r\n styleName.indexOf(\"margin\") >= 0) {\r\n\r\n first.style[styleName] = second.style[styleName];\r\n\r\n }\r\n }\r\n\r\n second.parentElement.removeChild(second);\r\n\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n function applyLinePadding(lineList, lp, context) {\r\n\r\n if (lineList === null) return;\r\n\r\n for (var i = 0; i < lineList.length; i++) {\r\n\r\n var l = lineList[i].elements.length;\r\n\r\n var pospadpxlen = Math.ceil(lp) + \"px\";\r\n\r\n var negpadpxlen = \"-\" + Math.ceil(lp) + \"px\";\r\n\r\n if (l !== 0) {\r\n\r\n var se = lineList[i].elements[lineList[i].start_elem];\r\n\r\n var ee = lineList[i].elements[lineList[i].end_elem];\r\n\r\n if (se === ee) {\r\n\r\n // Check to see if there's any background at all\r\n elementBoundingRect = se.node.getBoundingClientRect();\r\n \r\n if (elementBoundingRect.width == 0 || elementBoundingRect.height == 0) {\r\n\r\n // There's no background on this line, move on.\r\n continue;\r\n\r\n }\r\n\r\n }\r\n\r\n // Start element\r\n if (context.ipd === \"lr\") {\r\n\r\n se.node.style.marginLeft = negpadpxlen;\r\n se.node.style.paddingLeft = pospadpxlen;\r\n\r\n } else if (context.ipd === \"rl\") {\r\n\r\n se.node.style.paddingRight = pospadpxlen;\r\n se.node.style.marginRight = negpadpxlen;\r\n\r\n } else if (context.ipd === \"tb\") {\r\n\r\n se.node.style.paddingTop = pospadpxlen;\r\n se.node.style.marginTop = negpadpxlen;\r\n\r\n }\r\n\r\n // End element\r\n if (context.ipd === \"lr\") {\r\n\r\n ee.node.style.marginRight = negpadpxlen;\r\n ee.node.style.paddingRight = pospadpxlen;\r\n\r\n } else if (context.ipd === \"rl\") {\r\n\r\n ee.node.style.paddingLeft = pospadpxlen;\r\n ee.node.style.marginLeft = negpadpxlen;\r\n\r\n } else if (context.ipd === \"tb\") {\r\n\r\n ee.node.style.paddingBottom = pospadpxlen;\r\n ee.node.style.marginBottom = negpadpxlen;\r\n\r\n }\r\n\r\n }\r\n\r\n }\r\n\r\n }\r\n\r\n function applyMultiRowAlign(lineList) {\r\n\r\n /* apply an explicit br to all but the last line */\r\n\r\n for (var i = 0; i < lineList.length - 1; i++) {\r\n\r\n var l = lineList[i].elements.length;\r\n\r\n if (l !== 0 && lineList[i].br === false) {\r\n var br = document.createElement(\"br\");\r\n\r\n var lastnode = lineList[i].elements[l - 1].node;\r\n\r\n lastnode.parentElement.insertBefore(br, lastnode.nextSibling);\r\n }\r\n\r\n }\r\n\r\n }\r\n\r\n function applyTextEmphasisOutside(lineList, context) {\r\n\r\n /* supports \"outside\" only */\r\n\r\n for (var i = 0; i < lineList.length; i++) {\r\n\r\n for (var j = 0; j < lineList[i].te.length; j++) {\r\n\r\n /* skip if position already set */\r\n\r\n if (lineList[i].te[j].style[TEXTEMPHASISPOSITION_PROP] &&\r\n lineList[i].te[j].style[TEXTEMPHASISPOSITION_PROP] !== \"none\")\r\n continue;\r\n\r\n var pos;\r\n\r\n if (context.bpd === \"tb\") {\r\n\r\n pos = (i === 0) ? \"left over\" : \"left under\";\r\n\r\n\r\n } else {\r\n\r\n if (context.bpd === \"rl\") {\r\n\r\n pos = (i === 0) ? \"right under\" : \"left under\";\r\n\r\n } else {\r\n\r\n pos = (i === 0) ? \"left under\" : \"right under\";\r\n\r\n }\r\n\r\n }\r\n\r\n lineList[i].te[j].style[TEXTEMPHASISPOSITION_PROP] = pos;\r\n\r\n }\r\n\r\n }\r\n\r\n }\r\n\r\n function applyRubyPosition(lineList, context) {\r\n\r\n for (var i = 0; i < lineList.length; i++) {\r\n\r\n for (var j = 0; j < lineList[i].rbc.length; j++) {\r\n\r\n /* skip if ruby-position already set */\r\n\r\n if (lineList[i].rbc[j].style[RUBYPOSITION_PROP])\r\n continue;\r\n\r\n var pos;\r\n\r\n if (RUBYPOSITION_ISWK) {\r\n\r\n /* WebKit exception */\r\n\r\n pos = (i === 0) ? \"before\" : \"after\";\r\n\r\n } else if (context.bpd === \"tb\") {\r\n\r\n pos = (i === 0) ? \"over\" : \"under\";\r\n\r\n\r\n } else {\r\n\r\n if (context.bpd === \"rl\") {\r\n\r\n pos = (i === 0) ? \"over\" : \"under\";\r\n\r\n } else {\r\n\r\n pos = (i === 0) ? \"under\" : \"over\";\r\n\r\n }\r\n\r\n }\r\n\r\n lineList[i].rbc[j].style[RUBYPOSITION_PROP] = pos;\r\n\r\n }\r\n\r\n }\r\n\r\n }\r\n\r\n function applyRubyReserve(lineList, context) {\r\n\r\n for (var i = 0; i < lineList.length; i++) {\r\n\r\n var ruby = document.createElement(\"ruby\");\r\n\r\n var rb = document.createElement(\"rb\");\r\n rb.textContent = \"\\u200B\";\r\n\r\n ruby.appendChild(rb);\r\n\r\n var rt1;\r\n var rt2;\r\n\r\n var fs = context.rubyReserve[1].toUsedLength(context.w, context.h) + \"px\";\r\n\r\n if (context.rubyReserve[0] === \"both\" || (context.rubyReserve[0] === \"outside\" && lineList.length == 1)) {\r\n\r\n rt1 = document.createElement(\"rtc\");\r\n rt1.style[RUBYPOSITION_PROP] = RUBYPOSITION_ISWK ? \"after\" : \"under\";\r\n rt1.textContent = \"\\u200B\";\r\n rt1.style.fontSize = fs;\r\n\r\n rt2 = document.createElement(\"rtc\");\r\n rt2.style[RUBYPOSITION_PROP] = RUBYPOSITION_ISWK ? \"before\" : \"over\";\r\n rt2.textContent = \"\\u200B\";\r\n rt2.style.fontSize = fs;\r\n\r\n ruby.appendChild(rt1);\r\n ruby.appendChild(rt2);\r\n\r\n } else {\r\n\r\n rt1 = document.createElement(\"rtc\");\r\n rt1.textContent = \"\\u200B\";\r\n rt1.style.fontSize = fs;\r\n\r\n var pos;\r\n\r\n if (context.rubyReserve[0] === \"after\" || (context.rubyReserve[0] === \"outside\" && i > 0)) {\r\n\r\n pos = RUBYPOSITION_ISWK ? \"after\" : ((context.bpd === \"tb\" || context.bpd === \"rl\") ? \"under\" : \"over\");\r\n\r\n } else {\r\n\r\n pos = RUBYPOSITION_ISWK ? \"before\" : ((context.bpd === \"tb\" || context.bpd === \"rl\") ? \"over\" : \"under\");\r\n\r\n }\r\n\r\n rt1.style[RUBYPOSITION_PROP] = pos;\r\n\r\n ruby.appendChild(rt1);\r\n\r\n }\r\n\r\n /* add in front of the first ruby element of the line, if it exists */\r\n\r\n var sib = null;\r\n\r\n for (var j = 0; j < lineList[i].rbc.length; j++) {\r\n\r\n if (lineList[i].rbc[j].localName === 'ruby') {\r\n\r\n sib = lineList[i].rbc[j];\r\n\r\n /* copy specified style properties from the sibling ruby container */\r\n \r\n for (var k = 0; k < sib.style.length; k++) {\r\n\r\n ruby.style.setProperty(sib.style.item(k), sib.style.getPropertyValue(sib.style.item(k)));\r\n\r\n }\r\n\r\n break;\r\n }\r\n\r\n }\r\n\r\n /* otherwise add before first span */\r\n\r\n sib = sib || lineList[i].elements[0].node;\r\n\r\n sib.parentElement.insertBefore(ruby, sib);\r\n\r\n }\r\n\r\n }\r\n\r\n function applyFillLineGap(lineList, par_before, par_after, context, element) {\r\n\r\n /* positive for BPD = lr and tb, negative for BPD = rl */\r\n var s = Math.sign(par_after - par_before);\r\n\r\n for (var i = 0; i <= lineList.length; i++) {\r\n\r\n /* compute frontier between lines */\r\n\r\n var frontier;\r\n\r\n if (i === 0) {\r\n\r\n frontier = Math.round(par_before);\r\n\r\n } else if (i === lineList.length) {\r\n\r\n frontier = Math.round(par_after);\r\n\r\n } else {\r\n\r\n frontier = Math.round((lineList[i - 1].after + lineList[i].before) / 2);\r\n\r\n }\r\n\r\n var padding;\r\n var l,thisNode;\r\n\r\n /* before line */\r\n if (i > 0) {\r\n\r\n if (lineList[i-1]) {\r\n\r\n for (l = 0; l < lineList[i - 1].elements.length; l++) {\r\n\r\n thisNode=lineList[i - 1].elements[l];\r\n padding = s*(frontier-thisNode.after) + \"px\";\r\n\r\n if (context.bpd === \"lr\") {\r\n\r\n thisNode.node.style.paddingRight = padding;\r\n\r\n } else if (context.bpd === \"rl\") {\r\n\r\n thisNode.node.style.paddingLeft = padding;\r\n\r\n } else if (context.bpd === \"tb\") {\r\n\r\n thisNode.node.style.paddingBottom = padding;\r\n\r\n }\r\n\r\n }\r\n\r\n }\r\n\r\n }\r\n\r\n /* after line */\r\n if (i < lineList.length) {\r\n\r\n for (l = 0; l < lineList[i].elements.length; l++) {\r\n\r\n thisNode = lineList[i].elements[l];\r\n padding = s * (thisNode.before - frontier) + \"px\";\r\n\r\n if (context.bpd === \"lr\") {\r\n\r\n thisNode.node.style.paddingLeft = padding;\r\n\r\n } else if (context.bpd === \"rl\") {\r\n\r\n thisNode.node.style.paddingRight = padding;\r\n\r\n } else if (context.bpd === \"tb\") {\r\n\r\n thisNode.node.style.paddingTop = padding;\r\n\r\n }\r\n }\r\n\r\n }\r\n\r\n }\r\n\r\n }\r\n\r\n function RegionPBuffer(id, lineList) {\r\n\r\n this.id = id;\r\n\r\n this.plist = lineList;\r\n\r\n }\r\n\r\n function rect2edges(rect, context) {\r\n\r\n var edges = {before: null, after: null, start: null, end: null};\r\n\r\n if (context.bpd === \"tb\") {\r\n\r\n edges.before = rect.top;\r\n edges.after = rect.bottom;\r\n\r\n if (context.ipd === \"lr\") {\r\n\r\n edges.start = rect.left;\r\n edges.end = rect.right;\r\n\r\n } else {\r\n\r\n edges.start = rect.right;\r\n edges.end = rect.left;\r\n }\r\n\r\n } else if (context.bpd === \"lr\") {\r\n\r\n edges.before = rect.left;\r\n edges.after = rect.right;\r\n edges.start = rect.top;\r\n edges.end = rect.bottom;\r\n\r\n } else if (context.bpd === \"rl\") {\r\n\r\n edges.before = rect.right;\r\n edges.after = rect.left;\r\n edges.start = rect.top;\r\n edges.end = rect.bottom;\r\n\r\n }\r\n\r\n return edges;\r\n\r\n }\r\n\r\n function constructLineList(context, element, llist, bgcolor) {\r\n\r\n if (element.localName === \"rt\" || element.localName === \"rtc\") {\r\n\r\n /* skip ruby annotations */\r\n\r\n return;\r\n\r\n }\r\n\r\n var curbgcolor = element.style.backgroundColor || bgcolor;\r\n\r\n if (element.childElementCount === 0) {\r\n\r\n if (element.localName === 'span' || element.localName === 'rb') {\r\n\r\n var r = element.getBoundingClientRect();\r\n\r\n var edges = rect2edges(r, context);\r\n\r\n if (llist.length === 0 ||\r\n (!isSameLine(edges.before, edges.after, llist[llist.length - 1].before, llist[llist.length - 1].after))\r\n ) {\r\n llist.push({\r\n before: edges.before,\r\n after: edges.after,\r\n start: edges.start,\r\n end: edges.end,\r\n start_elem: 0,\r\n end_elem: 0,\r\n elements: [],\r\n rbc: [],\r\n te: [],\r\n text: \"\",\r\n br: false\r\n });\r\n\r\n } else {\r\n\r\n /* positive for BPD = lr and tb, negative for BPD = rl */\r\n var bpd_dir = Math.sign(edges.after - edges.before);\r\n\r\n /* positive for IPD = lr and tb, negative for IPD = rl */\r\n var ipd_dir = Math.sign(edges.end - edges.start);\r\n\r\n /* check if the line height has increased */\r\n\r\n if (bpd_dir * (edges.before - llist[llist.length - 1].before) < 0) {\r\n llist[llist.length - 1].before = edges.before;\r\n }\r\n\r\n if (bpd_dir * (edges.after - llist[llist.length - 1].after) > 0) {\r\n llist[llist.length - 1].after = edges.after;\r\n }\r\n\r\n if (ipd_dir * (edges.start - llist[llist.length - 1].start) < 0) {\r\n llist[llist.length - 1].start = edges.start;\r\n llist[llist.length - 1].start_elem = llist[llist.length - 1].elements.length;\r\n }\r\n\r\n if (ipd_dir * (edges.end - llist[llist.length - 1].end) > 0) {\r\n llist[llist.length - 1].end = edges.end;\r\n llist[llist.length - 1].end_elem = llist[llist.length - 1].elements.length;\r\n }\r\n\r\n }\r\n\r\n llist[llist.length - 1].text += element.textContent;\r\n\r\n llist[llist.length - 1].elements.push(\r\n {\r\n node: element,\r\n bgcolor: curbgcolor,\r\n before: edges.before,\r\n after: edges.after\r\n }\r\n );\r\n\r\n } else if (element.localName === 'br' && llist.length !== 0) {\r\n\r\n llist[llist.length - 1].br = true;\r\n\r\n }\r\n\r\n } else {\r\n\r\n var child = element.firstChild;\r\n\r\n while (child) {\r\n\r\n if (child.nodeType === Node.ELEMENT_NODE) {\r\n\r\n constructLineList(context, child, llist, curbgcolor);\r\n\r\n if (child.localName === 'ruby' || child.localName === 'rtc') {\r\n\r\n /* remember non-empty ruby and rtc elements so that tts:rubyPosition can be applied */\r\n\r\n if (llist.length > 0) {\r\n\r\n llist[llist.length - 1].rbc.push(child);\r\n\r\n }\r\n\r\n } else if (child.localName === 'span' &&\r\n child.style[TEXTEMPHASISSTYLE_PROP] &&\r\n child.style[TEXTEMPHASISSTYLE_PROP] !== \"none\") {\r\n\r\n /* remember non-empty span elements with textEmphasis */\r\n\r\n if (llist.length > 0) {\r\n\r\n llist[llist.length - 1].te.push(child);\r\n\r\n }\r\n\r\n }\r\n \r\n\r\n }\r\n\r\n child = child.nextSibling;\r\n }\r\n }\r\n\r\n }\r\n\r\n function isSameLine(before1, after1, before2, after2) {\r\n\r\n return ((after1 < after2) && (before1 > before2)) || ((after2 <= after1) && (before2 >= before1));\r\n\r\n }\r\n\r\n function applyTextEmphasis(context, dom_element, isd_element, attr) {\r\n\r\n /* ignore color (not used in IMSC 1.1) */\r\n\r\n if (attr.style === \"none\") {\r\n\r\n /* text-emphasis is not inherited and the default is none, so nothing to do */\r\n \r\n return;\r\n \r\n } else if (attr.style === \"auto\") {\r\n\r\n dom_element.style[TEXTEMPHASISSTYLE_PROP] = \"filled\";\r\n \r\n } else {\r\n\r\n dom_element.style[TEXTEMPHASISSTYLE_PROP] = attr.style + \" \" + attr.symbol;\r\n }\r\n\r\n /* ignore \"outside\" position (set in postprocessing) */\r\n\r\n if (attr.position === \"before\" || attr.position === \"after\") {\r\n\r\n var pos;\r\n\r\n if (context.bpd === \"tb\") {\r\n\r\n pos = (attr.position === \"before\") ? \"left over\" : \"left under\";\r\n\r\n\r\n } else {\r\n\r\n if (context.bpd === \"rl\") {\r\n\r\n pos = (attr.position === \"before\") ? \"right under\" : \"left under\";\r\n\r\n } else {\r\n\r\n pos = (attr.position === \"before\") ? \"left under\" : \"right under\";\r\n\r\n }\r\n\r\n }\r\n\r\n dom_element.style[TEXTEMPHASISPOSITION_PROP] = pos;\r\n }\r\n }\r\n\r\n function HTMLStylingMapDefinition(qName, mapFunc) {\r\n this.qname = qName;\r\n this.map = mapFunc;\r\n }\r\n\r\n var STYLING_MAP_DEFS = [\r\n\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling backgroundColor\",\r\n function (context, dom_element, isd_element, attr) {\r\n\r\n /* skip if transparent */\r\n if (attr[3] === 0)\r\n return;\r\n\r\n dom_element.style.backgroundColor = \"rgba(\" +\r\n attr[0].toString() + \",\" +\r\n attr[1].toString() + \",\" +\r\n attr[2].toString() + \",\" +\r\n (attr[3] / 255).toString() +\r\n \")\";\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling color\",\r\n function (context, dom_element, isd_element, attr) {\r\n dom_element.style.color = \"rgba(\" +\r\n attr[0].toString() + \",\" +\r\n attr[1].toString() + \",\" +\r\n attr[2].toString() + \",\" +\r\n (attr[3] / 255).toString() +\r\n \")\";\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling direction\",\r\n function (context, dom_element, isd_element, attr) {\r\n\r\n dom_element.style.direction = attr;\r\n\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling display\",\r\n function (context, dom_element, isd_element, attr) {}\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling displayAlign\",\r\n function (context, dom_element, isd_element, attr) {\r\n\r\n /* see https://css-tricks.com/snippets/css/a-guide-to-flexbox/ */\r\n\r\n /* TODO: is this affected by writing direction? */\r\n\r\n dom_element.style.display = \"flex\";\r\n dom_element.style.flexDirection = \"column\";\r\n\r\n\r\n if (attr === \"before\") {\r\n\r\n dom_element.style.justifyContent = \"flex-start\";\r\n\r\n } else if (attr === \"center\") {\r\n\r\n dom_element.style.justifyContent = \"center\";\r\n\r\n } else if (attr === \"after\") {\r\n\r\n dom_element.style.justifyContent = \"flex-end\";\r\n }\r\n\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling extent\",\r\n function (context, dom_element, isd_element, attr) {\r\n /* TODO: this is super ugly */\r\n\r\n context.regionH = attr.h.toUsedLength(context.w, context.h);\r\n context.regionW = attr.w.toUsedLength(context.w, context.h);\r\n\r\n /* \r\n * CSS height/width are measured against the content rectangle,\r\n * whereas TTML height/width include padding\r\n */\r\n\r\n var hdelta = 0;\r\n var wdelta = 0;\r\n\r\n var p = isd_element.styleAttrs[\"http://www.w3.org/ns/ttml#styling padding\"];\r\n\r\n if (!p) {\r\n\r\n /* error */\r\n\r\n } else {\r\n\r\n hdelta = p[0].toUsedLength(context.w, context.h) + p[2].toUsedLength(context.w, context.h);\r\n wdelta = p[1].toUsedLength(context.w, context.h) + p[3].toUsedLength(context.w, context.h);\r\n\r\n }\r\n\r\n dom_element.style.height = (context.regionH - hdelta) + \"px\";\r\n dom_element.style.width = (context.regionW - wdelta) + \"px\";\r\n\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling fontFamily\",\r\n function (context, dom_element, isd_element, attr) {\r\n\r\n var rslt = [];\r\n\r\n /* per IMSC1 */\r\n\r\n for (var i = 0; i < attr.length; i++) {\r\n\r\n if (attr[i] === \"monospaceSerif\") {\r\n\r\n rslt.push(\"Courier New\");\r\n rslt.push('\"Liberation Mono\"');\r\n rslt.push(\"Courier\");\r\n rslt.push(\"monospace\");\r\n\r\n } else if (attr[i] === \"proportionalSansSerif\") {\r\n\r\n rslt.push(\"Arial\");\r\n rslt.push(\"Helvetica\");\r\n rslt.push('\"Liberation Sans\"');\r\n rslt.push(\"sans-serif\");\r\n\r\n } else if (attr[i] === \"monospace\") {\r\n\r\n rslt.push(\"monospace\");\r\n\r\n } else if (attr[i] === \"sansSerif\") {\r\n\r\n rslt.push(\"sans-serif\");\r\n\r\n } else if (attr[i] === \"serif\") {\r\n\r\n rslt.push(\"serif\");\r\n\r\n } else if (attr[i] === \"monospaceSansSerif\") {\r\n\r\n rslt.push(\"Consolas\");\r\n rslt.push(\"monospace\");\r\n\r\n } else if (attr[i] === \"proportionalSerif\") {\r\n\r\n rslt.push(\"serif\");\r\n\r\n } else {\r\n\r\n rslt.push(attr[i]);\r\n\r\n }\r\n\r\n }\r\n\r\n // prune later duplicates we may have inserted \r\n if (rslt.length > 0) {\r\n\r\n var unique=[rslt[0]];\r\n\r\n for (var fi = 1; fi < rslt.length; fi++) {\r\n\r\n if (unique.indexOf(rslt[fi]) == -1) {\r\n\r\n unique.push(rslt[fi]);\r\n\r\n }\r\n }\r\n\r\n rslt = unique;\r\n }\r\n\r\n dom_element.style.fontFamily = rslt.join(\",\");\r\n }\r\n ),\r\n\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling shear\",\r\n function (context, dom_element, isd_element, attr) {\r\n\r\n /* return immediately if tts:shear is 0% since CSS transforms are not inherited*/\r\n\r\n if (attr === 0)\r\n return;\r\n\r\n var angle = attr * -0.9;\r\n\r\n /* context.bpd is needed since writing mode is not inherited and sets the inline progression */\r\n\r\n if (context.bpd === \"tb\") {\r\n\r\n dom_element.style.transform = \"skewX(\" + angle + \"deg)\";\r\n\r\n } else {\r\n\r\n dom_element.style.transform = \"skewY(\" + angle + \"deg)\";\r\n\r\n }\r\n\r\n }\r\n ),\r\n\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling fontSize\",\r\n function (context, dom_element, isd_element, attr) {\r\n dom_element.style.fontSize = attr.toUsedLength(context.w, context.h) + \"px\";\r\n }\r\n ),\r\n\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling fontStyle\",\r\n function (context, dom_element, isd_element, attr) {\r\n dom_element.style.fontStyle = attr;\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling fontWeight\",\r\n function (context, dom_element, isd_element, attr) {\r\n dom_element.style.fontWeight = attr;\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling lineHeight\",\r\n function (context, dom_element, isd_element, attr) {\r\n if (attr === \"normal\") {\r\n\r\n dom_element.style.lineHeight = \"normal\";\r\n\r\n } else {\r\n\r\n dom_element.style.lineHeight = attr.toUsedLength(context.w, context.h) + \"px\";\r\n }\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling opacity\",\r\n function (context, dom_element, isd_element, attr) {\r\n dom_element.style.opacity = attr;\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling origin\",\r\n function (context, dom_element, isd_element, attr) {\r\n dom_element.style.top = attr.h.toUsedLength(context.w, context.h) + \"px\";\r\n dom_element.style.left = attr.w.toUsedLength(context.w, context.h) + \"px\";\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling overflow\",\r\n function (context, dom_element, isd_element, attr) {\r\n dom_element.style.overflow = attr;\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling padding\",\r\n function (context, dom_element, isd_element, attr) {\r\n\r\n /* attr: top,left,bottom,right*/\r\n\r\n /* style: top right bottom left*/\r\n\r\n var rslt = [];\r\n\r\n rslt[0] = attr[0].toUsedLength(context.w, context.h) + \"px\";\r\n rslt[1] = attr[3].toUsedLength(context.w, context.h) + \"px\";\r\n rslt[2] = attr[2].toUsedLength(context.w, context.h) + \"px\";\r\n rslt[3] = attr[1].toUsedLength(context.w, context.h) + \"px\";\r\n\r\n dom_element.style.padding = rslt.join(\" \");\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling position\",\r\n function (context, dom_element, isd_element, attr) {\r\n dom_element.style.top = attr.h.toUsedLength(context.w, context.h) + \"px\";\r\n dom_element.style.left = attr.w.toUsedLength(context.w, context.h) + \"px\";\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling rubyAlign\",\r\n function (context, dom_element, isd_element, attr) {\r\n dom_element.style.rubyAlign = attr === \"spaceAround\" ? \"space-around\" : \"center\";\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling rubyPosition\",\r\n function (context, dom_element, isd_element, attr) {\r\n\r\n /* skip if \"outside\", which is handled by applyRubyPosition() */\r\n\r\n if (attr === \"before\" || attr === \"after\") {\r\n\r\n var pos;\r\n\r\n if (RUBYPOSITION_ISWK) {\r\n\r\n /* WebKit exception */\r\n \r\n pos = attr;\r\n \r\n } else if (context.bpd === \"tb\") {\r\n\r\n pos = (attr === \"before\") ? \"over\" : \"under\";\r\n\r\n\r\n } else {\r\n\r\n if (context.bpd === \"rl\") {\r\n\r\n pos = (attr === \"before\") ? \"over\" : \"under\";\r\n\r\n } else {\r\n\r\n pos = (attr === \"before\") ? \"under\" : \"over\";\r\n\r\n }\r\n\r\n }\r\n\r\n /* apply position to the parent dom_element, i.e. ruby or rtc */\r\n\r\n dom_element.parentElement.style[RUBYPOSITION_PROP] = pos;\r\n }\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling showBackground\",\r\n null\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling textAlign\",\r\n function (context, dom_element, isd_element, attr) {\r\n\r\n var ta;\r\n\r\n /* handle UAs that do not understand start or end */\r\n\r\n if (attr === \"start\") {\r\n\r\n ta = (context.ipd === \"rl\") ? \"right\" : \"left\";\r\n\r\n } else if (attr === \"end\") {\r\n\r\n ta = (context.ipd === \"rl\") ? \"left\" : \"right\";\r\n\r\n } else {\r\n\r\n ta = attr;\r\n\r\n }\r\n\r\n dom_element.style.textAlign = ta;\r\n\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling textDecoration\",\r\n function (context, dom_element, isd_element, attr) {\r\n dom_element.style.textDecoration = attr.join(\" \").replace(\"lineThrough\", \"line-through\");\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling textOutline\",\r\n function (context, dom_element, isd_element, attr) {\r\n\r\n /* defer to tts:textShadow */\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling textShadow\",\r\n function (context, dom_element, isd_element, attr) {\r\n\r\n var txto = isd_element.styleAttrs[imscStyles.byName.textOutline.qname];\r\n\r\n if (attr === \"none\" && txto === \"none\") {\r\n\r\n dom_element.style.textShadow = \"\";\r\n\r\n } else {\r\n\r\n var s = [];\r\n\r\n if (txto !== \"none\") {\r\n\r\n /* emulate text outline */\r\n\r\n var to_color = \"rgba(\" +\r\n txto.color[0].toString() + \",\" +\r\n txto.color[1].toString() + \",\" +\r\n txto.color[2].toString() + \",\" +\r\n (txto.color[3] / 255).toString() +\r\n \")\";\r\n\r\n s.push( \"1px 1px 1px \" + to_color);\r\n s.push( \"-1px 1px 1px \" + to_color);\r\n s.push( \"1px -1px 1px \" + to_color);\r\n s.push( \"-1px -1px 1px \" + to_color);\r\n\r\n }\r\n\r\n /* add text shadow */\r\n\r\n if (attr !== \"none\") {\r\n\r\n for (var i = 0; i < attr.length; i++) {\r\n\r\n\r\n s.push(attr[i].x_off.toUsedLength(context.w, context.h) + \"px \" +\r\n attr[i].y_off.toUsedLength(context.w, context.h) + \"px \" +\r\n attr[i].b_radius.toUsedLength(context.w, context.h) + \"px \" +\r\n \"rgba(\" +\r\n attr[i].color[0].toString() + \",\" +\r\n attr[i].color[1].toString() + \",\" +\r\n attr[i].color[2].toString() + \",\" +\r\n (attr[i].color[3] / 255).toString() +\r\n \")\"\r\n );\r\n\r\n }\r\n\r\n }\r\n\r\n dom_element.style.textShadow = s.join(\",\");\r\n\r\n }\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling textCombine\",\r\n function (context, dom_element, isd_element, attr) {\r\n\r\n dom_element.style.textCombineUpright = attr;\r\n\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling textEmphasis\",\r\n function (context, dom_element, isd_element, attr) {\r\n\r\n /* applied as part of HTML document construction */\r\n\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling unicodeBidi\",\r\n function (context, dom_element, isd_element, attr) {\r\n\r\n var ub;\r\n\r\n if (attr === 'bidiOverride') {\r\n ub = \"bidi-override\";\r\n } else {\r\n ub = attr;\r\n }\r\n\r\n dom_element.style.unicodeBidi = ub;\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling visibility\",\r\n function (context, dom_element, isd_element, attr) {\r\n dom_element.style.visibility = attr;\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling wrapOption\",\r\n function (context, dom_element, isd_element, attr) {\r\n\r\n if (attr === \"wrap\") {\r\n\r\n if (isd_element.space === \"preserve\") {\r\n dom_element.style.whiteSpace = \"pre-wrap\";\r\n } else {\r\n dom_element.style.whiteSpace = \"normal\";\r\n }\r\n\r\n } else {\r\n\r\n if (isd_element.space === \"preserve\") {\r\n\r\n dom_element.style.whiteSpace = \"pre\";\r\n\r\n } else {\r\n dom_element.style.whiteSpace = \"noWrap\";\r\n }\r\n\r\n }\r\n\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling writingMode\",\r\n function (context, dom_element, isd_element, attr) {\r\n\r\n var wm;\r\n\r\n if (attr === \"lrtb\" || attr === \"lr\") {\r\n\r\n dom_element.style.writingMode = \"horizontal-tb\";\r\n\r\n } else if (attr === \"rltb\" || attr === \"rl\") {\r\n\r\n dom_element.style.writingMode = \"horizontal-tb\";\r\n\r\n } else if (attr === \"tblr\") {\r\n\r\n dom_element.style.writingMode = \"vertical-lr\";\r\n\r\n } else if (attr === \"tbrl\" || attr === \"tb\") {\r\n\r\n dom_element.style.writingMode = \"vertical-rl\";\r\n\r\n }\r\n\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml#styling zIndex\",\r\n function (context, dom_element, isd_element, attr) {\r\n dom_element.style.zIndex = attr;\r\n }\r\n ),\r\n new HTMLStylingMapDefinition(\r\n \"http://www.w3.org/ns/ttml/profile/imsc1#styling forcedDisplay\",\r\n function (context, dom_element, isd_element, attr) {\r\n\r\n if (context.displayForcedOnlyMode && attr === false) {\r\n dom_element.style.visibility = \"hidden\";\r\n }\r\n\r\n }\r\n )\r\n ];\r\n\r\n var STYLMAP_BY_QNAME = {};\r\n\r\n for (var i = 0; i < STYLING_MAP_DEFS.length; i++) {\r\n\r\n STYLMAP_BY_QNAME[STYLING_MAP_DEFS[i].qname] = STYLING_MAP_DEFS[i];\r\n }\r\n\r\n /* CSS property names */\r\n\r\n var RUBYPOSITION_ISWK = \"webkitRubyPosition\" in window.getComputedStyle(document.documentElement);\r\n\r\n var RUBYPOSITION_PROP = RUBYPOSITION_ISWK ? \"webkitRubyPosition\" : \"rubyPosition\";\r\n\r\n var TEXTEMPHASISSTYLE_PROP = \"webkitTextEmphasisStyle\" in window.getComputedStyle(document.documentElement) ? \"webkitTextEmphasisStyle\" : \"textEmphasisStyle\";\r\n\r\n var TEXTEMPHASISPOSITION_PROP = \"webkitTextEmphasisPosition\" in window.getComputedStyle(document.documentElement) ? \"webkitTextEmphasisPosition\" : \"textEmphasisPosition\";\r\n\r\n /* error utilities */\r\n\r\n function reportError(errorHandler, msg) {\r\n\r\n if (errorHandler && errorHandler.error && errorHandler.error(msg))\r\n throw msg;\r\n\r\n }\r\n\r\n})( false ? undefined : exports,\r\n typeof imscNames === 'undefined' ? __webpack_require__(/*! ./names */ \"../imsc/src/main/js/names.js\") : imscNames,\r\n typeof imscStyles === 'undefined' ? __webpack_require__(/*! ./styles */ \"../imsc/src/main/js/styles.js\") : imscStyles,\r\n typeof imscUtils === 'undefined' ? __webpack_require__(/*! ./utils */ \"../imsc/src/main/js/utils.js\") : imscUtils);\r\n\n\n//# sourceURL=webpack://ardplayer/../imsc/src/main/js/html.js?");
|
|
91
|
-
|
|
92
|
-
/***/ }),
|
|
93
|
-
|
|
94
|
-
/***/ "../imsc/src/main/js/isd.js":
|
|
95
|
-
/*!**********************************!*\
|
|
96
|
-
!*** ../imsc/src/main/js/isd.js ***!
|
|
97
|
-
\**********************************/
|
|
98
|
-
/*! no static exports found */
|
|
99
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
100
|
-
|
|
101
|
-
eval("/* \r\n * Copyright (c) 2016, Pierre-Anthony Lemieux <pal@sandflow.com>\r\n * All rights reserved.\r\n *\r\n * Redistribution and use in source and binary forms, with or without\r\n * modification, are permitted provided that the following conditions are met:\r\n *\r\n * * Redistributions of source code must retain the above copyright notice, this\r\n * list of conditions and the following disclaimer.\r\n * * Redistributions in binary form must reproduce the above copyright notice,\r\n * this list of conditions and the following disclaimer in the documentation\r\n * and/or other materials provided with the distribution.\r\n *\r\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\r\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r\n * POSSIBILITY OF SUCH DAMAGE.\r\n */\r\n\r\n/**\r\n * @module imscISD\r\n */\r\n\r\n\r\n;\r\n(function (imscISD, imscNames, imscStyles, imscUtils) { // wrapper for non-node envs\r\n\r\n /** \r\n * Creates a canonical representation of an IMSC1 document returned by <pre>imscDoc.fromXML()</pre>\r\n * at a given absolute offset in seconds. This offset does not have to be one of the values returned\r\n * by <pre>getMediaTimeEvents()</pre>.\r\n * \r\n * @param {Object} tt IMSC1 document\r\n * @param {number} offset Absolute offset (in seconds)\r\n * @param {?module:imscUtils.ErrorHandler} errorHandler Error callback\r\n * @returns {Object} Opaque in-memory representation of an ISD\r\n */\r\n\r\n imscISD.generateISD = function (tt, offset, errorHandler) {\r\n\r\n /* TODO check for tt and offset validity */\r\n\r\n /* create the ISD object from the IMSC1 doc */\r\n\r\n var isd = new ISD(tt);\r\n\r\n /* context */\r\n\r\n var context = {\r\n\r\n /*rubyfs: []*/ /* font size of the nearest textContainer or container */\r\n\r\n };\r\n\r\n /* Filter body contents - Only process what we need within the offset and discard regions not applicable to the content */\r\n var body = {};\r\n var activeRegions = {};\r\n\r\n /* gather any regions that might have showBackground=\"always\" and show a background */\r\n var initialShowBackground = tt.head.styling.initials[imscStyles.byName.showBackground.qname];\r\n var initialbackgroundColor = tt.head.styling.initials[imscStyles.byName.backgroundColor.qname];\r\n for (var layout_child in tt.head.layout.regions)\r\n {\r\n if (tt.head.layout.regions.hasOwnProperty(layout_child)) {\r\n var region = tt.head.layout.regions[layout_child];\r\n var showBackground = region.styleAttrs[imscStyles.byName.showBackground.qname] || initialShowBackground;\r\n var backgroundColor = region.styleAttrs[imscStyles.byName.backgroundColor.qname] || initialbackgroundColor;\r\n activeRegions[region.id] = (\r\n (showBackground === 'always' || showBackground === undefined) &&\r\n backgroundColor !== undefined &&\r\n !(offset < region.begin || offset >= region.end)\r\n );\r\n }\r\n }\r\n\r\n /* If the body specifies a region, catch it, since no filtered content will */\r\n /* likely specify the region. */\r\n if (tt.body && tt.body.regionID) {\r\n activeRegions[tt.body.regionID] = true;\r\n }\r\n\r\n function filter(offset, element) {\r\n function offsetFilter(element) {\r\n return !(offset < element.begin || offset >= element.end); \r\n } \r\n \r\n if (element.contents) {\r\n var clone = {};\r\n for (var prop in element) {\r\n if (element.hasOwnProperty(prop)) {\r\n clone[prop] = element[prop];\r\n }\r\n }\r\n clone.contents = [];\r\n\r\n element.contents.filter(offsetFilter).forEach(function (el) {\r\n var filteredElement = filter(offset, el);\r\n if (filteredElement.regionID) {\r\n activeRegions[filteredElement.regionID] = true;\r\n }\r\n \r\n if (filteredElement !== null) {\r\n clone.contents.push(filteredElement);\r\n }\r\n });\r\n return clone;\r\n } else {\r\n return element;\r\n }\r\n }\r\n\r\n if (tt.body !== null) {\r\n body = filter(offset, tt.body);\r\n } else {\r\n body = null;\r\n }\r\n\r\n /* rewritten TTML will always have a default - this covers it. because the region is defaulted to \"\" */\r\n if (activeRegions[\"\"] !== undefined) {\r\n activeRegions[\"\"] = true;\r\n }\r\n\r\n /* process regions */ \r\n for (var regionID in activeRegions) {\r\n if (activeRegions[regionID]) {\r\n /* post-order traversal of the body tree per [construct intermediate document] */\r\n\r\n var c = isdProcessContentElement(tt, offset, tt.head.layout.regions[regionID], body, null, '', tt.head.layout.regions[regionID], errorHandler, context);\r\n\r\n if (c !== null) {\r\n\r\n /* add the region to the ISD */\r\n\r\n isd.contents.push(c.element);\r\n }\r\n }\r\n }\r\n\r\n return isd;\r\n };\r\n\r\n /* set of styles not applicable to ruby container spans */\r\n\r\n var _rcs_na_styles = [\r\n imscStyles.byName.color.qname,\r\n imscStyles.byName.textCombine.qname,\r\n imscStyles.byName.textDecoration.qname,\r\n imscStyles.byName.textEmphasis.qname,\r\n imscStyles.byName.textOutline.qname,\r\n imscStyles.byName.textShadow.qname\r\n ];\r\n\r\n function isdProcessContentElement(doc, offset, region, body, parent, inherited_region_id, elem, errorHandler, context) {\r\n\r\n /* prune if temporally inactive */\r\n\r\n if (offset < elem.begin || offset >= elem.end) {\r\n return null;\r\n }\r\n\r\n /* \r\n * set the associated region as specified by the regionID attribute, or the \r\n * inherited associated region otherwise\r\n */\r\n\r\n var associated_region_id = 'regionID' in elem && elem.regionID !== '' ? elem.regionID : inherited_region_id;\r\n\r\n /* prune the element if either:\r\n * - the element is not terminal and the associated region is neither the default\r\n * region nor the parent region (this allows children to be associated with a \r\n * region later on)\r\n * - the element is terminal and the associated region is not the parent region\r\n */\r\n\r\n /* TODO: improve detection of terminal elements since <region> has no contents */\r\n\r\n if (parent !== null /* are we in the region element */ &&\r\n associated_region_id !== region.id &&\r\n (\r\n (!('contents' in elem)) ||\r\n ('contents' in elem && elem.contents.length === 0) ||\r\n associated_region_id !== ''\r\n )\r\n )\r\n return null;\r\n\r\n /* create an ISD element, including applying specified styles */\r\n\r\n var isd_element = new ISDContentElement(elem);\r\n\r\n /* apply set (animation) styling */\r\n\r\n if (\"sets\" in elem) {\r\n for (var i = 0; i < elem.sets.length; i++) {\r\n\r\n if (offset < elem.sets[i].begin || offset >= elem.sets[i].end)\r\n continue;\r\n\r\n isd_element.styleAttrs[elem.sets[i].qname] = elem.sets[i].value;\r\n\r\n }\r\n }\r\n\r\n /* \r\n * keep track of specified styling attributes so that we\r\n * can compute them later\r\n */\r\n\r\n var spec_attr = {};\r\n\r\n for (var qname in isd_element.styleAttrs) {\r\n\r\n if (! isd_element.styleAttrs.hasOwnProperty(qname)) continue;\r\n\r\n spec_attr[qname] = true;\r\n\r\n /* special rule for tts:writingMode (section 7.29.1 of XSL)\r\n * direction is set consistently with writingMode only\r\n * if writingMode sets inline-direction to LTR or RTL \r\n */\r\n\r\n if (isd_element.kind === 'region' &&\r\n qname === imscStyles.byName.writingMode.qname &&\r\n !(imscStyles.byName.direction.qname in isd_element.styleAttrs)) {\r\n\r\n var wm = isd_element.styleAttrs[qname];\r\n\r\n if (wm === \"lrtb\" || wm === \"lr\") {\r\n\r\n isd_element.styleAttrs[imscStyles.byName.direction.qname] = \"ltr\";\r\n\r\n } else if (wm === \"rltb\" || wm === \"rl\") {\r\n\r\n isd_element.styleAttrs[imscStyles.byName.direction.qname] = \"rtl\";\r\n\r\n }\r\n\r\n }\r\n }\r\n\r\n /* inherited styling */\r\n\r\n if (parent !== null) {\r\n\r\n for (var j = 0; j < imscStyles.all.length; j++) {\r\n\r\n var sa = imscStyles.all[j];\r\n\r\n /* textDecoration has special inheritance rules */\r\n\r\n if (sa.qname === imscStyles.byName.textDecoration.qname) {\r\n\r\n /* handle both textDecoration inheritance and specification */\r\n\r\n var ps = parent.styleAttrs[sa.qname];\r\n var es = isd_element.styleAttrs[sa.qname];\r\n var outs = [];\r\n\r\n if (es === undefined) {\r\n\r\n outs = ps;\r\n\r\n } else if (es.indexOf(\"none\") === -1) {\r\n\r\n if ((es.indexOf(\"noUnderline\") === -1 &&\r\n ps.indexOf(\"underline\") !== -1) ||\r\n es.indexOf(\"underline\") !== -1) {\r\n\r\n outs.push(\"underline\");\r\n\r\n }\r\n\r\n if ((es.indexOf(\"noLineThrough\") === -1 &&\r\n ps.indexOf(\"lineThrough\") !== -1) ||\r\n es.indexOf(\"lineThrough\") !== -1) {\r\n\r\n outs.push(\"lineThrough\");\r\n\r\n }\r\n\r\n if ((es.indexOf(\"noOverline\") === -1 &&\r\n ps.indexOf(\"overline\") !== -1) ||\r\n es.indexOf(\"overline\") !== -1) {\r\n\r\n outs.push(\"overline\");\r\n\r\n }\r\n\r\n } else {\r\n\r\n outs.push(\"none\");\r\n\r\n }\r\n\r\n isd_element.styleAttrs[sa.qname] = outs;\r\n\r\n } else if (sa.qname === imscStyles.byName.fontSize.qname &&\r\n !(sa.qname in isd_element.styleAttrs) &&\r\n isd_element.kind === 'span' &&\r\n isd_element.styleAttrs[imscStyles.byName.ruby.qname] === \"textContainer\") {\r\n \r\n /* special inheritance rule for ruby text container font size */\r\n \r\n var ruby_fs = parent.styleAttrs[imscStyles.byName.fontSize.qname];\r\n\r\n isd_element.styleAttrs[sa.qname] = new imscUtils.ComputedLength(\r\n 0.5 * ruby_fs.rw,\r\n 0.5 * ruby_fs.rh);\r\n\r\n } else if (sa.qname === imscStyles.byName.fontSize.qname &&\r\n !(sa.qname in isd_element.styleAttrs) &&\r\n isd_element.kind === 'span' &&\r\n isd_element.styleAttrs[imscStyles.byName.ruby.qname] === \"text\") {\r\n \r\n /* special inheritance rule for ruby text font size */\r\n \r\n var parent_fs = parent.styleAttrs[imscStyles.byName.fontSize.qname];\r\n \r\n if (parent.styleAttrs[imscStyles.byName.ruby.qname] === \"textContainer\") {\r\n \r\n isd_element.styleAttrs[sa.qname] = parent_fs;\r\n \r\n } else {\r\n \r\n isd_element.styleAttrs[sa.qname] = new imscUtils.ComputedLength(\r\n 0.5 * parent_fs.rw,\r\n 0.5 * parent_fs.rh);\r\n }\r\n \r\n } else if (sa.inherit &&\r\n (sa.qname in parent.styleAttrs) &&\r\n !(sa.qname in isd_element.styleAttrs)) {\r\n\r\n isd_element.styleAttrs[sa.qname] = parent.styleAttrs[sa.qname];\r\n\r\n }\r\n\r\n }\r\n\r\n }\r\n\r\n /* initial value styling */\r\n\r\n for (var k = 0; k < imscStyles.all.length; k++) {\r\n \r\n var ivs = imscStyles.all[k];\r\n\r\n /* skip if value is already specified */\r\n\r\n if (ivs.qname in isd_element.styleAttrs) continue;\r\n\r\n /* skip tts:position if tts:origin is specified */\r\n\r\n if (ivs.qname === imscStyles.byName.position.qname &&\r\n imscStyles.byName.origin.qname in isd_element.styleAttrs)\r\n continue;\r\n\r\n /* skip tts:origin if tts:position is specified */\r\n\r\n if (ivs.qname === imscStyles.byName.origin.qname &&\r\n imscStyles.byName.position.qname in isd_element.styleAttrs)\r\n continue;\r\n \r\n /* determine initial value */\r\n \r\n var iv = doc.head.styling.initials[ivs.qname] || ivs.initial;\r\n\r\n if (iv === null) {\r\n /* skip processing if no initial value defined */\r\n\r\n continue;\r\n }\r\n\r\n /* apply initial value to elements other than region only if non-inherited */\r\n\r\n if (isd_element.kind === 'region' || (ivs.inherit === false && iv !== null)) {\r\n\r\n var piv = ivs.parse(iv);\r\n\r\n if (piv !== null) {\r\n\r\n isd_element.styleAttrs[ivs.qname] = piv;\r\n\r\n /* keep track of the style as specified */\r\n\r\n spec_attr[ivs.qname] = true;\r\n\r\n } else {\r\n\r\n reportError(errorHandler, \"Invalid initial value for '\" + ivs.qname + \"' on element '\" + isd_element.kind);\r\n\r\n }\r\n\r\n }\r\n\r\n }\r\n\r\n /* compute styles (only for non-inherited styles) */\r\n /* TODO: get rid of spec_attr */\r\n\r\n for (var z = 0; z < imscStyles.all.length; z++) {\r\n \r\n var cs = imscStyles.all[z];\r\n\r\n if (!(cs.qname in spec_attr)) continue;\r\n\r\n if (cs.compute !== null) {\r\n\r\n var cstyle = cs.compute(\r\n /*doc, parent, element, attr, context*/\r\n doc,\r\n parent,\r\n isd_element,\r\n isd_element.styleAttrs[cs.qname],\r\n context\r\n );\r\n\r\n if (cstyle !== null) {\r\n\r\n isd_element.styleAttrs[cs.qname] = cstyle;\r\n \r\n } else {\r\n /* if the style cannot be computed, replace it by its initial value */\r\n\r\n isd_element.styleAttrs[cs.qname] = cs.compute(\r\n /*doc, parent, element, attr, context*/\r\n doc,\r\n parent,\r\n isd_element,\r\n cs.parse(cs.initial),\r\n context\r\n );\r\n\r\n reportError(errorHandler, \"Style '\" + cs.qname + \"' on element '\" + isd_element.kind + \"' cannot be computed\");\r\n }\r\n }\r\n\r\n }\r\n\r\n /* prune if tts:display is none */\r\n\r\n if (isd_element.styleAttrs[imscStyles.byName.display.qname] === \"none\")\r\n return null;\r\n\r\n /* process contents of the element */\r\n\r\n var contents = null;\r\n\r\n if (parent === null) {\r\n\r\n /* we are processing the region */\r\n\r\n if (body === null) {\r\n\r\n /* if there is no body, still process the region but with empty content */\r\n\r\n contents = [];\r\n\r\n } else {\r\n\r\n /*use the body element as contents */\r\n\r\n contents = [body];\r\n\r\n }\r\n\r\n } else if ('contents' in elem) {\r\n\r\n contents = elem.contents;\r\n\r\n }\r\n\r\n for (var x = 0; contents !== null && x < contents.length; x++) {\r\n\r\n var c = isdProcessContentElement(doc, offset, region, body, isd_element, associated_region_id, contents[x], errorHandler, context);\r\n\r\n /* \r\n * keep child element only if they are non-null and their region match \r\n * the region of this element\r\n */\r\n\r\n if (c !== null) {\r\n\r\n isd_element.contents.push(c.element);\r\n\r\n }\r\n\r\n }\r\n\r\n /* remove styles that are not applicable */\r\n\r\n for (var qnameb in isd_element.styleAttrs) {\r\n if (!isd_element.styleAttrs.hasOwnProperty(qnameb)) continue;\r\n\r\n /* true if not applicable */\r\n\r\n var na = false;\r\n\r\n /* special applicability of certain style properties to ruby container spans */\r\n /* TODO: in the future ruby elements should be translated to elements instead of kept as spans */\r\n\r\n if (isd_element.kind === 'span') {\r\n\r\n var rsp = isd_element.styleAttrs[imscStyles.byName.ruby.qname];\r\n\r\n na = ( rsp === 'container' || rsp === 'textContainer' || rsp === 'baseContainer' ) && \r\n _rcs_na_styles.indexOf(qnameb) !== -1;\r\n\r\n if (! na) {\r\n\r\n na = rsp !== 'container' &&\r\n qnameb === imscStyles.byName.rubyAlign.qname;\r\n\r\n }\r\n\r\n if (! na) {\r\n\r\n na = (! (rsp === 'textContainer' || rsp === 'text')) &&\r\n qnameb === imscStyles.byName.rubyPosition.qname;\r\n\r\n }\r\n\r\n }\r\n\r\n /* normal applicability */\r\n \r\n if (! na) {\r\n\r\n var da = imscStyles.byQName[qnameb];\r\n\r\n if (\"applies\" in da){\r\n\r\n na = da.applies.indexOf(isd_element.kind) === -1;\r\n\r\n }\r\n\r\n }\r\n\r\n\r\n if (na) {\r\n delete isd_element.styleAttrs[qnameb];\r\n }\r\n\r\n }\r\n\r\n /* trim whitespace around explicit line breaks */\r\n\r\n var ruby = isd_element.styleAttrs[imscStyles.byName.ruby.qname];\r\n\r\n if (isd_element.kind === 'p' ||\r\n (isd_element.kind === 'span' && (ruby === \"textContainer\" || ruby === \"text\"))\r\n ) {\r\n\r\n var elist = [];\r\n\r\n constructSpanList(isd_element, elist);\r\n\r\n collapseLWSP(elist);\r\n\r\n pruneEmptySpans(isd_element);\r\n\r\n }\r\n\r\n /* keep element if:\r\n * * contains a background image\r\n * * <br/>\r\n * * if there are children\r\n * * if it is an image\r\n * * if <span> and has text\r\n * * if region and showBackground = always\r\n */\r\n\r\n if ((isd_element.kind === 'div' && imscStyles.byName.backgroundImage.qname in isd_element.styleAttrs) ||\r\n isd_element.kind === 'br' ||\r\n isd_element.kind === 'image' ||\r\n ('contents' in isd_element && isd_element.contents.length > 0) ||\r\n (isd_element.kind === 'span' && isd_element.text !== null) ||\r\n (isd_element.kind === 'region' &&\r\n isd_element.styleAttrs[imscStyles.byName.showBackground.qname] === 'always')) {\r\n\r\n return {\r\n region_id: associated_region_id,\r\n element: isd_element\r\n };\r\n }\r\n\r\n return null;\r\n }\r\n\r\n function collapseLWSP(elist) {\r\n\r\n function isPrevCharLWSP(prev_element) {\r\n return prev_element.kind === 'br' || /[\\r\\n\\t ]$/.test(prev_element.text);\r\n }\r\n\r\n function isNextCharLWSP(next_element) {\r\n return next_element.kind === 'br' || (next_element.space === \"preserve\" && /^[\\r\\n]/.test(next_element.text));\r\n }\r\n\r\n /* collapse spaces and remove leading LWSPs */\r\n\r\n var element;\r\n\r\n for (var i = 0; i < elist.length;) {\r\n\r\n element = elist[i];\r\n\r\n if (element.kind === \"br\" || element.space === \"preserve\") {\r\n i++;\r\n continue;\r\n }\r\n\r\n var trimmed_text = element.text.replace(/[\\t\\r\\n ]+/g, ' ');\r\n\r\n if (/^[ ]/.test(trimmed_text)) {\r\n\r\n if (i === 0 || isPrevCharLWSP(elist[i - 1])) {\r\n trimmed_text = trimmed_text.substring(1);\r\n }\r\n\r\n }\r\n\r\n element.text = trimmed_text;\r\n\r\n if (trimmed_text.length === 0) {\r\n elist.splice(i, 1);\r\n } else {\r\n i++;\r\n }\r\n\r\n }\r\n\r\n /* remove trailing LWSPs */\r\n\r\n for (i = 0; i < elist.length; i++) {\r\n\r\n element = elist[i];\r\n\r\n if (element.kind === \"br\" || element.space === \"preserve\") {\r\n i++;\r\n continue;\r\n }\r\n\r\n if (/[ ]$/.test(element.text)) {\r\n\r\n if (i === (elist.length - 1) || isNextCharLWSP(elist[i + 1])) {\r\n element.text = element.text.slice(0, -1);\r\n }\r\n\r\n }\r\n\r\n }\r\n\r\n }\r\n\r\n function constructSpanList(element, elist) {\r\n\r\n if (! (\"contents\" in element)) {\r\n return;\r\n }\r\n\r\n for (var i = 0; i < element.contents.length; i++) {\r\n\r\n var child = element.contents[i];\r\n var ruby = child.styleAttrs[imscStyles.byName.ruby.qname];\r\n\r\n if (child.kind === 'span' && (ruby === \"textContainer\" || ruby === \"text\")) {\r\n\r\n /* skip ruby text and text containers, which are handled on their own */\r\n \r\n continue;\r\n\r\n } else if ('contents' in child) {\r\n \r\n constructSpanList(child, elist);\r\n \r\n } else if ((child.kind === 'span' && child.text.length !== 0) || child.kind === 'br') {\r\n\r\n /* skip empty spans */\r\n\r\n elist.push(child);\r\n\r\n }\r\n\r\n }\r\n\r\n }\r\n\r\n function pruneEmptySpans(element) {\r\n\r\n if (element.kind === 'br') {\r\n\r\n return false;\r\n\r\n } else if ('text' in element) {\r\n\r\n return element.text.length === 0;\r\n\r\n } else if ('contents' in element) {\r\n\r\n var i = element.contents.length;\r\n\r\n while (i--) {\r\n\r\n if (pruneEmptySpans(element.contents[i])) {\r\n element.contents.splice(i, 1);\r\n }\r\n\r\n }\r\n\r\n return element.contents.length === 0;\r\n\r\n }\r\n }\r\n\r\n function ISD(tt) {\r\n this.contents = [];\r\n this.aspectRatio = tt.aspectRatio;\r\n this.lang = tt.lang;\r\n }\r\n\r\n function ISDContentElement(ttelem) {\r\n\r\n /* assume the element is a region if it does not have a kind */\r\n\r\n this.kind = ttelem.kind || 'region';\r\n\r\n /* copy lang */\r\n\r\n this.lang = ttelem.lang;\r\n\r\n /* copy id */\r\n\r\n if (ttelem.id) {\r\n this.id = ttelem.id;\r\n }\r\n\r\n /* deep copy of style attributes */\r\n this.styleAttrs = {};\r\n\r\n for (var sname in ttelem.styleAttrs) {\r\n\r\n if (! ttelem.styleAttrs.hasOwnProperty(sname)) continue;\r\n\r\n this.styleAttrs[sname] =\r\n ttelem.styleAttrs[sname];\r\n }\r\n \r\n /* copy src and type if image */\r\n \r\n if ('src' in ttelem) {\r\n \r\n this.src = ttelem.src;\r\n \r\n }\r\n \r\n if ('type' in ttelem) {\r\n \r\n this.type = ttelem.type;\r\n \r\n }\r\n\r\n /* TODO: clean this! \r\n * TODO: ISDElement and document element should be better tied together */\r\n\r\n if ('text' in ttelem) {\r\n\r\n this.text = ttelem.text;\r\n\r\n } else if (this.kind === 'region' || 'contents' in ttelem) {\r\n\r\n this.contents = [];\r\n }\r\n\r\n if ('space' in ttelem) {\r\n\r\n this.space = ttelem.space;\r\n }\r\n }\r\n\r\n\r\n /*\r\n * ERROR HANDLING UTILITY FUNCTIONS\r\n * \r\n */\r\n\r\n function reportInfo(errorHandler, msg) {\r\n\r\n if (errorHandler && errorHandler.info && errorHandler.info(msg))\r\n throw msg;\r\n\r\n }\r\n\r\n function reportWarning(errorHandler, msg) {\r\n\r\n if (errorHandler && errorHandler.warn && errorHandler.warn(msg))\r\n throw msg;\r\n\r\n }\r\n\r\n function reportError(errorHandler, msg) {\r\n\r\n if (errorHandler && errorHandler.error && errorHandler.error(msg))\r\n throw msg;\r\n\r\n }\r\n\r\n function reportFatal(errorHandler, msg) {\r\n\r\n if (errorHandler && errorHandler.fatal)\r\n errorHandler.fatal(msg);\r\n\r\n throw msg;\r\n\r\n }\r\n\r\n\r\n})( false ? undefined : exports,\r\n typeof imscNames === 'undefined' ? __webpack_require__(/*! ./names */ \"../imsc/src/main/js/names.js\") : imscNames,\r\n typeof imscStyles === 'undefined' ? __webpack_require__(/*! ./styles */ \"../imsc/src/main/js/styles.js\") : imscStyles,\r\n typeof imscUtils === 'undefined' ? __webpack_require__(/*! ./utils */ \"../imsc/src/main/js/utils.js\") : imscUtils\r\n );\r\n\n\n//# sourceURL=webpack://ardplayer/../imsc/src/main/js/isd.js?");
|
|
102
|
-
|
|
103
|
-
/***/ }),
|
|
104
|
-
|
|
105
|
-
/***/ "../imsc/src/main/js/main.js":
|
|
106
|
-
/*!***********************************!*\
|
|
107
|
-
!*** ../imsc/src/main/js/main.js ***!
|
|
108
|
-
\***********************************/
|
|
109
|
-
/*! no static exports found */
|
|
110
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
111
|
-
|
|
112
|
-
eval("/* \r\n * Copyright (c) 2016, Pierre-Anthony Lemieux <pal@sandflow.com>\r\n * All rights reserved.\r\n *\r\n * Redistribution and use in source and binary forms, with or without\r\n * modification, are permitted provided that the following conditions are met:\r\n *\r\n * * Redistributions of source code must retain the above copyright notice, this\r\n * list of conditions and the following disclaimer.\r\n * * Redistributions in binary form must reproduce the above copyright notice,\r\n * this list of conditions and the following disclaimer in the documentation\r\n * and/or other materials provided with the distribution.\r\n *\r\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\r\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r\n * POSSIBILITY OF SUCH DAMAGE.\r\n */\r\n\r\nexports.generateISD = __webpack_require__(/*! ./isd */ \"../imsc/src/main/js/isd.js\").generateISD;\r\nexports.fromXML = __webpack_require__(/*! ./doc */ \"../imsc/src/main/js/doc.js\").fromXML;\r\nexports.renderHTML = __webpack_require__(/*! ./html */ \"../imsc/src/main/js/html.js\").render;\n\n//# sourceURL=webpack://ardplayer/../imsc/src/main/js/main.js?");
|
|
113
|
-
|
|
114
|
-
/***/ }),
|
|
115
|
-
|
|
116
|
-
/***/ "../imsc/src/main/js/names.js":
|
|
117
|
-
/*!************************************!*\
|
|
118
|
-
!*** ../imsc/src/main/js/names.js ***!
|
|
119
|
-
\************************************/
|
|
120
|
-
/*! no static exports found */
|
|
121
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
122
|
-
|
|
123
|
-
eval("/* \r\n * Copyright (c) 2016, Pierre-Anthony Lemieux <pal@sandflow.com>\r\n * All rights reserved.\r\n *\r\n * Redistribution and use in source and binary forms, with or without\r\n * modification, are permitted provided that the following conditions are met:\r\n *\r\n * * Redistributions of source code must retain the above copyright notice, this\r\n * list of conditions and the following disclaimer.\r\n * * Redistributions in binary form must reproduce the above copyright notice,\r\n * this list of conditions and the following disclaimer in the documentation\r\n * and/or other materials provided with the distribution.\r\n *\r\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\r\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r\n * POSSIBILITY OF SUCH DAMAGE.\r\n */\r\n\r\n/**\r\n * @module imscNames\r\n */\r\n\r\n;\r\n(function (imscNames) { // wrapper for non-node envs\r\n\r\n imscNames.ns_tt = \"http://www.w3.org/ns/ttml\";\r\n imscNames.ns_tts = \"http://www.w3.org/ns/ttml#styling\";\r\n imscNames.ns_ttp = \"http://www.w3.org/ns/ttml#parameter\";\r\n imscNames.ns_xml = \"http://www.w3.org/XML/1998/namespace\";\r\n imscNames.ns_itts = \"http://www.w3.org/ns/ttml/profile/imsc1#styling\";\r\n imscNames.ns_ittp = \"http://www.w3.org/ns/ttml/profile/imsc1#parameter\";\r\n imscNames.ns_smpte = \"http://www.smpte-ra.org/schemas/2052-1/2010/smpte-tt\";\r\n imscNames.ns_ebutts = \"urn:ebu:tt:style\";\r\n \r\n})( false ? undefined : exports);\r\n\r\n\r\n\r\n\r\n\n\n//# sourceURL=webpack://ardplayer/../imsc/src/main/js/names.js?");
|
|
124
|
-
|
|
125
|
-
/***/ }),
|
|
126
|
-
|
|
127
|
-
/***/ "../imsc/src/main/js/styles.js":
|
|
128
|
-
/*!*************************************!*\
|
|
129
|
-
!*** ../imsc/src/main/js/styles.js ***!
|
|
130
|
-
\*************************************/
|
|
131
|
-
/*! no static exports found */
|
|
132
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
133
|
-
|
|
134
|
-
eval("/* \r\n * Copyright (c) 2016, Pierre-Anthony Lemieux <pal@sandflow.com>\r\n * All rights reserved.\r\n *\r\n * Redistribution and use in source and binary forms, with or without\r\n * modification, are permitted provided that the following conditions are met:\r\n *\r\n * * Redistributions of source code must retain the above copyright notice, this\r\n * list of conditions and the following disclaimer.\r\n * * Redistributions in binary form must reproduce the above copyright notice,\r\n * this list of conditions and the following disclaimer in the documentation\r\n * and/or other materials provided with the distribution.\r\n *\r\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\r\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r\n * POSSIBILITY OF SUCH DAMAGE.\r\n */\r\n\r\n/**\r\n * @module imscStyles\r\n */\r\n\r\n;\r\n(function (imscStyles, imscNames, imscUtils) { // wrapper for non-node envs\r\n\r\n function StylingAttributeDefinition(ns, name, initialValue, appliesTo, isInherit, isAnimatable, parseFunc, computeFunc) {\r\n this.name = name;\r\n this.ns = ns;\r\n this.qname = ns + \" \" + name;\r\n this.inherit = isInherit;\r\n this.animatable = isAnimatable;\r\n this.initial = initialValue;\r\n this.applies = appliesTo;\r\n this.parse = parseFunc;\r\n this.compute = computeFunc;\r\n }\r\n\r\n imscStyles.all = [\r\n\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"backgroundColor\",\r\n \"transparent\",\r\n ['body', 'div', 'p', 'region', 'span'],\r\n false,\r\n true,\r\n imscUtils.parseColor,\r\n null\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"color\",\r\n \"white\",\r\n ['span'],\r\n true,\r\n true,\r\n imscUtils.parseColor,\r\n null\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"direction\",\r\n \"ltr\",\r\n ['p', 'span'],\r\n true,\r\n true,\r\n function (str) {\r\n return str;\r\n },\r\n null\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"display\",\r\n \"auto\",\r\n ['body', 'div', 'p', 'region', 'span'],\r\n false,\r\n true,\r\n function (str) {\r\n return str;\r\n },\r\n null\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"displayAlign\",\r\n \"before\",\r\n ['region'],\r\n false,\r\n true,\r\n function (str) {\r\n return str;\r\n },\r\n null\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"extent\",\r\n \"auto\",\r\n ['tt', 'region'],\r\n false,\r\n true,\r\n function (str) {\r\n\r\n if (str === \"auto\") {\r\n\r\n return str;\r\n\r\n } else {\r\n\r\n var s = str.split(\" \");\r\n if (s.length !== 2)\r\n return null;\r\n var w = imscUtils.parseLength(s[0]);\r\n var h = imscUtils.parseLength(s[1]);\r\n if (!h || !w)\r\n return null;\r\n return {'h': h, 'w': w};\r\n }\r\n\r\n },\r\n function (doc, parent, element, attr, context) {\r\n\r\n var h;\r\n var w;\r\n\r\n if (attr === \"auto\") {\r\n\r\n h = new imscUtils.ComputedLength(0, 1);\r\n\r\n } else {\r\n\r\n h = imscUtils.toComputedLength(\r\n attr.h.value,\r\n attr.h.unit,\r\n null,\r\n doc.dimensions.h,\r\n null,\r\n doc.pxLength.h\r\n );\r\n\r\n\r\n if (h === null) {\r\n\r\n return null;\r\n\r\n }\r\n }\r\n\r\n if (attr === \"auto\") {\r\n\r\n w = new imscUtils.ComputedLength(1, 0);\r\n\r\n } else {\r\n\r\n w = imscUtils.toComputedLength(\r\n attr.w.value,\r\n attr.w.unit,\r\n null,\r\n doc.dimensions.w,\r\n null,\r\n doc.pxLength.w\r\n );\r\n\r\n if (w === null) {\r\n\r\n return null;\r\n\r\n }\r\n\r\n }\r\n\r\n return {'h': h, 'w': w};\r\n }\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"fontFamily\",\r\n \"default\",\r\n ['span', 'p'],\r\n true,\r\n true,\r\n function (str) {\r\n var ffs = str.split(\",\");\r\n var rslt = [];\r\n\r\n for (var i = 0; i < ffs.length; i++) {\r\n\r\n if (ffs[i].charAt(0) !== \"'\" && ffs[i].charAt(0) !== '\"') {\r\n\r\n if (ffs[i] === \"default\") {\r\n\r\n /* per IMSC1 */\r\n\r\n rslt.push(\"monospaceSerif\");\r\n\r\n } else {\r\n\r\n rslt.push(ffs[i]);\r\n\r\n }\r\n\r\n } else {\r\n\r\n rslt.push(ffs[i]);\r\n\r\n }\r\n\r\n }\r\n\r\n return rslt;\r\n },\r\n null\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"shear\",\r\n \"0%\",\r\n ['p'],\r\n true,\r\n true,\r\n imscUtils.parseLength,\r\n function (doc, parent, element, attr) {\r\n\r\n var fs;\r\n\r\n if (attr.unit === \"%\") {\r\n\r\n fs = Math.abs(attr.value) > 100 ? Math.sign(attr.value) * 100 : attr.value;\r\n\r\n } else {\r\n\r\n return null;\r\n\r\n }\r\n\r\n return fs;\r\n }\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"fontSize\",\r\n \"1c\",\r\n ['span', 'p'],\r\n true,\r\n true,\r\n imscUtils.parseLength,\r\n function (doc, parent, element, attr, context) {\r\n\r\n var fs;\r\n\r\n fs = imscUtils.toComputedLength(\r\n attr.value,\r\n attr.unit,\r\n parent !== null ? parent.styleAttrs[imscStyles.byName.fontSize.qname] : doc.cellLength.h,\r\n parent !== null ? parent.styleAttrs[imscStyles.byName.fontSize.qname] : doc.cellLength.h,\r\n doc.cellLength.h,\r\n doc.pxLength.h\r\n );\r\n\r\n return fs;\r\n }\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"fontStyle\",\r\n \"normal\",\r\n ['span', 'p'],\r\n true,\r\n true,\r\n function (str) {\r\n /* TODO: handle font style */\r\n\r\n return str;\r\n },\r\n null\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"fontWeight\",\r\n \"normal\",\r\n ['span', 'p'],\r\n true,\r\n true,\r\n function (str) {\r\n /* TODO: handle font weight */\r\n\r\n return str;\r\n },\r\n null\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"lineHeight\",\r\n \"normal\",\r\n ['p'],\r\n true,\r\n true,\r\n function (str) {\r\n if (str === \"normal\") {\r\n return str;\r\n } else {\r\n return imscUtils.parseLength(str);\r\n }\r\n },\r\n function (doc, parent, element, attr, context) {\r\n\r\n var lh;\r\n\r\n if (attr === \"normal\") {\r\n\r\n /* inherit normal per https://github.com/w3c/ttml1/issues/220 */\r\n\r\n lh = attr;\r\n\r\n } else {\r\n\r\n lh = imscUtils.toComputedLength(\r\n attr.value,\r\n attr.unit,\r\n element.styleAttrs[imscStyles.byName.fontSize.qname],\r\n element.styleAttrs[imscStyles.byName.fontSize.qname],\r\n doc.cellLength.h,\r\n doc.pxLength.h\r\n );\r\n\r\n if (lh === null) {\r\n\r\n return null;\r\n\r\n }\r\n\r\n }\r\n\r\n /* TODO: create a Length constructor */\r\n\r\n return lh;\r\n }\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"opacity\",\r\n 1.0,\r\n ['region'],\r\n false,\r\n true,\r\n parseFloat,\r\n null\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"origin\",\r\n \"auto\",\r\n ['region'],\r\n false,\r\n true,\r\n function (str) {\r\n\r\n if (str === \"auto\") {\r\n\r\n return str;\r\n\r\n } else {\r\n\r\n var s = str.split(\" \");\r\n if (s.length !== 2)\r\n return null;\r\n var w = imscUtils.parseLength(s[0]);\r\n var h = imscUtils.parseLength(s[1]);\r\n if (!h || !w)\r\n return null;\r\n return {'h': h, 'w': w};\r\n }\r\n\r\n },\r\n function (doc, parent, element, attr, context) {\r\n\r\n var h;\r\n var w;\r\n\r\n if (attr === \"auto\") {\r\n\r\n h = new imscUtils.ComputedLength(0,0);\r\n\r\n } else {\r\n\r\n h = imscUtils.toComputedLength(\r\n attr.h.value,\r\n attr.h.unit,\r\n null,\r\n doc.dimensions.h,\r\n null,\r\n doc.pxLength.h\r\n );\r\n\r\n if (h === null) {\r\n\r\n return null;\r\n\r\n }\r\n\r\n }\r\n\r\n if (attr === \"auto\") {\r\n\r\n w = new imscUtils.ComputedLength(0,0);\r\n\r\n } else {\r\n\r\n w = imscUtils.toComputedLength(\r\n attr.w.value,\r\n attr.w.unit,\r\n null,\r\n doc.dimensions.w,\r\n null,\r\n doc.pxLength.w\r\n );\r\n\r\n if (w === null) {\r\n\r\n return null;\r\n\r\n }\r\n\r\n }\r\n\r\n return {'h': h, 'w': w};\r\n }\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"overflow\",\r\n \"hidden\",\r\n ['region'],\r\n false,\r\n true,\r\n function (str) {\r\n return str;\r\n },\r\n null\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"padding\",\r\n \"0px\",\r\n ['region'],\r\n false,\r\n true,\r\n function (str) {\r\n\r\n var s = str.split(\" \");\r\n if (s.length > 4)\r\n return null;\r\n var r = [];\r\n for (var i = 0; i < s.length; i++) {\r\n\r\n var l = imscUtils.parseLength(s[i]);\r\n if (!l)\r\n return null;\r\n r.push(l);\r\n }\r\n\r\n return r;\r\n },\r\n function (doc, parent, element, attr, context) {\r\n\r\n var padding;\r\n\r\n /* TODO: make sure we are in region */\r\n\r\n /*\r\n * expand padding shortcuts to \r\n * [before, end, after, start]\r\n * \r\n */\r\n\r\n if (attr.length === 1) {\r\n\r\n padding = [attr[0], attr[0], attr[0], attr[0]];\r\n\r\n } else if (attr.length === 2) {\r\n\r\n padding = [attr[0], attr[1], attr[0], attr[1]];\r\n\r\n } else if (attr.length === 3) {\r\n\r\n padding = [attr[0], attr[1], attr[2], attr[1]];\r\n\r\n } else if (attr.length === 4) {\r\n\r\n padding = [attr[0], attr[1], attr[2], attr[3]];\r\n\r\n } else {\r\n\r\n return null;\r\n\r\n }\r\n\r\n /* TODO: take into account tts:direction */\r\n\r\n /* \r\n * transform [before, end, after, start] according to writingMode to \r\n * [top,left,bottom,right]\r\n * \r\n */\r\n\r\n var dir = element.styleAttrs[imscStyles.byName.writingMode.qname];\r\n\r\n if (dir === \"lrtb\" || dir === \"lr\") {\r\n\r\n padding = [padding[0], padding[3], padding[2], padding[1]];\r\n\r\n } else if (dir === \"rltb\" || dir === \"rl\") {\r\n\r\n padding = [padding[0], padding[1], padding[2], padding[3]];\r\n\r\n } else if (dir === \"tblr\") {\r\n\r\n padding = [padding[3], padding[0], padding[1], padding[2]];\r\n\r\n } else if (dir === \"tbrl\" || dir === \"tb\") {\r\n\r\n padding = [padding[3], padding[2], padding[1], padding[0]];\r\n\r\n } else {\r\n\r\n return null;\r\n\r\n }\r\n\r\n var out = [];\r\n\r\n for (var i = 0 ; i < padding.length; i++) {\r\n\r\n if (padding[i].value === 0) {\r\n\r\n out[i] = new imscUtils.ComputedLength(0,0);\r\n\r\n } else {\r\n\r\n out[i] = imscUtils.toComputedLength(\r\n padding[i].value,\r\n padding[i].unit,\r\n element.styleAttrs[imscStyles.byName.fontSize.qname],\r\n i === 0 || i === 2 ? element.styleAttrs[imscStyles.byName.extent.qname].h : element.styleAttrs[imscStyles.byName.extent.qname].w,\r\n i === 0 || i === 2 ? doc.cellLength.h : doc.cellLength.w,\r\n i === 0 || i === 2 ? doc.pxLength.h: doc.pxLength.w\r\n );\r\n\r\n if (out[i] === null) return null;\r\n\r\n }\r\n }\r\n\r\n\r\n return out;\r\n }\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"position\",\r\n \"top left\",\r\n ['region'],\r\n false,\r\n true,\r\n function (str) {\r\n\r\n return imscUtils.parsePosition(str);\r\n\r\n },\r\n function (doc, parent, element, attr) {\r\n var h;\r\n var w;\r\n \r\n h = imscUtils.toComputedLength(\r\n attr.v.offset.value,\r\n attr.v.offset.unit,\r\n null,\r\n new imscUtils.ComputedLength(\r\n - element.styleAttrs[imscStyles.byName.extent.qname].h.rw,\r\n doc.dimensions.h.rh - element.styleAttrs[imscStyles.byName.extent.qname].h.rh \r\n ),\r\n null,\r\n doc.pxLength.h\r\n );\r\n\r\n if (h === null) return null;\r\n\r\n\r\n if (attr.v.edge === \"bottom\") {\r\n\r\n h = new imscUtils.ComputedLength(\r\n - h.rw - element.styleAttrs[imscStyles.byName.extent.qname].h.rw,\r\n doc.dimensions.h.rh - h.rh - element.styleAttrs[imscStyles.byName.extent.qname].h.rh\r\n );\r\n \r\n }\r\n\r\n w = imscUtils.toComputedLength(\r\n attr.h.offset.value,\r\n attr.h.offset.unit,\r\n null,\r\n new imscUtils.ComputedLength(\r\n doc.dimensions.w.rw - element.styleAttrs[imscStyles.byName.extent.qname].w.rw,\r\n - element.styleAttrs[imscStyles.byName.extent.qname].w.rh\r\n ),\r\n null,\r\n doc.pxLength.w\r\n );\r\n\r\n if (h === null) return null;\r\n\r\n if (attr.h.edge === \"right\") {\r\n \r\n w = new imscUtils.ComputedLength(\r\n doc.dimensions.w.rw - w.rw - element.styleAttrs[imscStyles.byName.extent.qname].w.rw,\r\n - w.rh - element.styleAttrs[imscStyles.byName.extent.qname].w.rh\r\n );\r\n\r\n }\r\n\r\n return {'h': h, 'w': w};\r\n }\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"ruby\",\r\n \"none\",\r\n ['span'],\r\n false,\r\n true,\r\n function (str) {\r\n return str;\r\n },\r\n null\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"rubyAlign\",\r\n \"center\",\r\n ['span'],\r\n true,\r\n true,\r\n function (str) {\r\n \r\n if (! (str === \"center\" || str === \"spaceAround\")) {\r\n return null;\r\n }\r\n \r\n return str;\r\n },\r\n null\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"rubyPosition\",\r\n \"outside\",\r\n ['span'],\r\n true,\r\n true,\r\n function (str) {\r\n return str;\r\n },\r\n null\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"rubyReserve\",\r\n \"none\",\r\n ['p'],\r\n true,\r\n true,\r\n function (str) {\r\n var s = str.split(\" \");\r\n\r\n var r = [null, null];\r\n\r\n if (s.length === 0 || s.length > 2)\r\n return null;\r\n\r\n if (s[0] === \"none\" ||\r\n s[0] === \"both\" ||\r\n s[0] === \"after\" ||\r\n s[0] === \"before\" ||\r\n s[0] === \"outside\") {\r\n\r\n r[0] = s[0];\r\n\r\n } else {\r\n\r\n return null;\r\n\r\n }\r\n\r\n if (s.length === 2 && s[0] !== \"none\") {\r\n\r\n var l = imscUtils.parseLength(s[1]);\r\n\r\n if (l) {\r\n\r\n r[1] = l;\r\n\r\n } else {\r\n\r\n return null;\r\n\r\n }\r\n\r\n }\r\n\r\n\r\n return r;\r\n },\r\n function (doc, parent, element, attr, context) {\r\n\r\n if (attr[0] === \"none\") {\r\n\r\n return attr;\r\n\r\n }\r\n\r\n var fs = null;\r\n\r\n if (attr[1] === null) {\r\n\r\n fs = new imscUtils.ComputedLength(\r\n element.styleAttrs[imscStyles.byName.fontSize.qname].rw * 0.5,\r\n element.styleAttrs[imscStyles.byName.fontSize.qname].rh * 0.5\r\n );\r\n\r\n } else {\r\n\r\n fs = imscUtils.toComputedLength(attr[1].value,\r\n attr[1].unit,\r\n element.styleAttrs[imscStyles.byName.fontSize.qname],\r\n element.styleAttrs[imscStyles.byName.fontSize.qname],\r\n doc.cellLength.h,\r\n doc.pxLength.h\r\n );\r\n \r\n }\r\n\r\n if (fs === null) return null;\r\n\r\n return [attr[0], fs];\r\n }\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"showBackground\",\r\n \"always\",\r\n ['region'],\r\n false,\r\n true,\r\n function (str) {\r\n return str;\r\n },\r\n null\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"textAlign\",\r\n \"start\",\r\n ['p'],\r\n true,\r\n true,\r\n function (str) {\r\n return str;\r\n },\r\n function (doc, parent, element, attr, context) {\r\n /* Section 7.16.9 of XSL */\r\n\r\n if (attr === \"left\") {\r\n\r\n return \"start\";\r\n\r\n } else if (attr === \"right\") {\r\n\r\n return \"end\";\r\n\r\n } else {\r\n\r\n return attr;\r\n\r\n }\r\n }\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"textCombine\",\r\n \"none\",\r\n ['span'],\r\n true,\r\n true,\r\n function (str) {\r\n if (str === \"none\" || str === \"all\") {\r\n\r\n return str;\r\n }\r\n\r\n return null;\r\n },\r\n null\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"textDecoration\",\r\n \"none\",\r\n ['span'],\r\n true,\r\n true,\r\n function (str) {\r\n return str.split(\" \");\r\n },\r\n null\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"textEmphasis\",\r\n \"none\",\r\n ['span'],\r\n true,\r\n true,\r\n function (str) {\r\n var e = str.split(\" \");\r\n\r\n var rslt = {style: null, symbol: null, color: null, position: null};\r\n\r\n for (var i = 0; i < e.length; i++) {\r\n\r\n if (e[i] === \"none\" || e[i] === \"auto\") {\r\n\r\n rslt.style = e[i];\r\n\r\n } else if (e[i] === \"filled\" ||\r\n e[i] === \"open\") {\r\n\r\n rslt.style = e[i];\r\n\r\n } else if (e[i] === \"circle\" ||\r\n e[i] === \"dot\" ||\r\n e[i] === \"sesame\") {\r\n\r\n rslt.symbol = e[i];\r\n\r\n } else if (e[i] === \"current\") {\r\n\r\n rslt.color = e[i];\r\n\r\n } else if (e[i] === \"outside\" || e[i] === \"before\" || e[i] === \"after\") {\r\n\r\n rslt.position = e[i];\r\n\r\n } else {\r\n\r\n rslt.color = imscUtils.parseColor(e[i]);\r\n\r\n if (rslt.color === null)\r\n return null;\r\n\r\n }\r\n }\r\n\r\n if (rslt.style == null && rslt.symbol == null) {\r\n\r\n rslt.style = \"auto\";\r\n\r\n } else {\r\n\r\n rslt.symbol = rslt.symbol || \"circle\";\r\n rslt.style = rslt.style || \"filled\";\r\n\r\n }\r\n\r\n rslt.position = rslt.position || \"outside\";\r\n rslt.color = rslt.color || \"current\";\r\n\r\n return rslt;\r\n },\r\n null\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"textOutline\",\r\n \"none\",\r\n ['span'],\r\n true,\r\n true,\r\n function (str) {\r\n\r\n /*\r\n * returns {c: <color>?, thichness: <length>} | \"none\"\r\n * \r\n */\r\n\r\n if (str === \"none\") {\r\n\r\n return str;\r\n\r\n } else {\r\n\r\n var r = {};\r\n var s = str.split(\" \");\r\n if (s.length === 0 || s.length > 2)\r\n return null;\r\n var c = imscUtils.parseColor(s[0]);\r\n\r\n r.color = c;\r\n\r\n if (c !== null)\r\n s.shift();\r\n\r\n if (s.length !== 1)\r\n return null;\r\n\r\n var l = imscUtils.parseLength(s[0]);\r\n\r\n if (!l)\r\n return null;\r\n\r\n r.thickness = l;\r\n\r\n return r;\r\n }\r\n\r\n },\r\n function (doc, parent, element, attr, context) {\r\n\r\n /*\r\n * returns {color: <color>, thickness: <norm length>}\r\n * \r\n */\r\n\r\n if (attr === \"none\")\r\n return attr;\r\n\r\n var rslt = {};\r\n\r\n if (attr.color === null) {\r\n\r\n rslt.color = element.styleAttrs[imscStyles.byName.color.qname];\r\n\r\n } else {\r\n\r\n rslt.color = attr.color;\r\n\r\n }\r\n\r\n rslt.thickness = imscUtils.toComputedLength(\r\n attr.thickness.value,\r\n attr.thickness.unit,\r\n element.styleAttrs[imscStyles.byName.fontSize.qname],\r\n element.styleAttrs[imscStyles.byName.fontSize.qname],\r\n doc.cellLength.h,\r\n doc.pxLength.h\r\n );\r\n\r\n if (rslt.thickness === null)\r\n return null;\r\n\r\n return rslt;\r\n }\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"textShadow\",\r\n \"none\",\r\n ['span'],\r\n true,\r\n true,\r\n imscUtils.parseTextShadow,\r\n function (doc, parent, element, attr) {\r\n\r\n /*\r\n * returns [{x_off: <length>, y_off: <length>, b_radius: <length>, color: <color>}*] or \"none\"\r\n * \r\n */\r\n\r\n if (attr === \"none\")\r\n return attr;\r\n\r\n var r = [];\r\n\r\n for (var i = 0; i < attr.length; i++) {\r\n\r\n var shadow = {};\r\n\r\n shadow.x_off = imscUtils.toComputedLength(\r\n attr[i][0].value,\r\n attr[i][0].unit,\r\n null,\r\n element.styleAttrs[imscStyles.byName.fontSize.qname],\r\n null,\r\n doc.pxLength.w\r\n );\r\n\r\n if (shadow.x_off === null)\r\n return null;\r\n\r\n shadow.y_off = imscUtils.toComputedLength(\r\n attr[i][1].value,\r\n attr[i][1].unit,\r\n null,\r\n element.styleAttrs[imscStyles.byName.fontSize.qname],\r\n null,\r\n doc.pxLength.h\r\n );\r\n\r\n if (shadow.y_off === null)\r\n return null;\r\n\r\n if (attr[i][2] === null) {\r\n\r\n shadow.b_radius = 0;\r\n\r\n } else {\r\n\r\n shadow.b_radius = imscUtils.toComputedLength(\r\n attr[i][2].value,\r\n attr[i][2].unit,\r\n null,\r\n element.styleAttrs[imscStyles.byName.fontSize.qname],\r\n null,\r\n doc.pxLength.h\r\n );\r\n\r\n if (shadow.b_radius === null)\r\n return null;\r\n\r\n }\r\n\r\n if (attr[i][3] === null) {\r\n\r\n shadow.color = element.styleAttrs[imscStyles.byName.color.qname];\r\n\r\n } else {\r\n\r\n shadow.color = attr[i][3];\r\n\r\n }\r\n\r\n r.push(shadow);\r\n\r\n }\r\n\r\n return r;\r\n }\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"unicodeBidi\",\r\n \"normal\",\r\n ['span', 'p'],\r\n false,\r\n true,\r\n function (str) {\r\n return str;\r\n },\r\n null\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"visibility\",\r\n \"visible\",\r\n ['body', 'div', 'p', 'region', 'span'],\r\n true,\r\n true,\r\n function (str) {\r\n return str;\r\n },\r\n null\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"wrapOption\",\r\n \"wrap\",\r\n ['span'],\r\n true,\r\n true,\r\n function (str) {\r\n return str;\r\n },\r\n null\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"writingMode\",\r\n \"lrtb\",\r\n ['region'],\r\n false,\r\n true,\r\n function (str) {\r\n return str;\r\n },\r\n null\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_tts,\r\n \"zIndex\",\r\n \"auto\",\r\n ['region'],\r\n false,\r\n true,\r\n function (str) {\r\n\r\n var rslt;\r\n\r\n if (str === 'auto') {\r\n\r\n rslt = str;\r\n\r\n } else {\r\n\r\n rslt = parseInt(str);\r\n\r\n if (isNaN(rslt)) {\r\n rslt = null;\r\n }\r\n\r\n }\r\n\r\n return rslt;\r\n },\r\n null\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_ebutts,\r\n \"linePadding\",\r\n \"0c\",\r\n ['p'],\r\n true,\r\n false,\r\n imscUtils.parseLength,\r\n function (doc, parent, element, attr, context) {\r\n\r\n return imscUtils.toComputedLength(attr.value, attr.unit, null, null, doc.cellLength.w, null);\r\n\r\n }\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_ebutts,\r\n \"multiRowAlign\",\r\n \"auto\",\r\n ['p'],\r\n true,\r\n false,\r\n function (str) {\r\n return str;\r\n },\r\n null\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_smpte,\r\n \"backgroundImage\",\r\n null,\r\n ['div'],\r\n false,\r\n false,\r\n function (str) {\r\n return str;\r\n },\r\n null\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_itts,\r\n \"forcedDisplay\",\r\n \"false\",\r\n ['body', 'div', 'p', 'region', 'span'],\r\n true,\r\n true,\r\n function (str) {\r\n return str === 'true' ? true : false;\r\n },\r\n null\r\n ),\r\n new StylingAttributeDefinition(\r\n imscNames.ns_itts,\r\n \"fillLineGap\",\r\n \"false\",\r\n ['p'],\r\n true,\r\n true,\r\n function (str) {\r\n return str === 'true' ? true : false;\r\n },\r\n null\r\n )\r\n ];\r\n\r\n /* TODO: allow null parse function */\r\n\r\n imscStyles.byQName = {};\r\n for (var i in imscStyles.all) {\r\n\r\n imscStyles.byQName[imscStyles.all[i].qname] = imscStyles.all[i];\r\n }\r\n\r\n imscStyles.byName = {};\r\n for (var j in imscStyles.all) {\r\n\r\n imscStyles.byName[imscStyles.all[j].name] = imscStyles.all[j];\r\n }\r\n\r\n\r\n})( false ? undefined : exports,\r\n typeof imscNames === 'undefined' ? __webpack_require__(/*! ./names */ \"../imsc/src/main/js/names.js\") : imscNames,\r\n typeof imscUtils === 'undefined' ? __webpack_require__(/*! ./utils */ \"../imsc/src/main/js/utils.js\") : imscUtils);\r\n\n\n//# sourceURL=webpack://ardplayer/../imsc/src/main/js/styles.js?");
|
|
135
|
-
|
|
136
|
-
/***/ }),
|
|
137
|
-
|
|
138
|
-
/***/ "../imsc/src/main/js/utils.js":
|
|
139
|
-
/*!************************************!*\
|
|
140
|
-
!*** ../imsc/src/main/js/utils.js ***!
|
|
141
|
-
\************************************/
|
|
142
|
-
/*! no static exports found */
|
|
143
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
144
|
-
|
|
145
|
-
eval("/* \r\n * Copyright (c) 2016, Pierre-Anthony Lemieux <pal@sandflow.com>\r\n * All rights reserved.\r\n *\r\n * Redistribution and use in source and binary forms, with or without\r\n * modification, are permitted provided that the following conditions are met:\r\n *\r\n * * Redistributions of source code must retain the above copyright notice, this\r\n * list of conditions and the following disclaimer.\r\n * * Redistributions in binary form must reproduce the above copyright notice,\r\n * this list of conditions and the following disclaimer in the documentation\r\n * and/or other materials provided with the distribution.\r\n *\r\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\r\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r\n * POSSIBILITY OF SUCH DAMAGE.\r\n */\r\n\r\n/**\r\n * @module imscUtils\r\n */\r\n\r\n;\r\n(function (imscUtils) { // wrapper for non-node envs\r\n\r\n /* Documents the error handler interface */\r\n\r\n /**\r\n * @classdesc Generic interface for handling events. The interface exposes four\r\n * methods:\r\n * * <pre>info</pre>: unusual event that does not result in an inconsistent state\r\n * * <pre>warn</pre>: unexpected event that should not result in an inconsistent state\r\n * * <pre>error</pre>: unexpected event that may result in an inconsistent state\r\n * * <pre>fatal</pre>: unexpected event that results in an inconsistent state\r\n * and termination of processing\r\n * Each method takes a single <pre>string</pre> describing the event as argument,\r\n * and returns a single <pre>boolean</pre>, which terminates processing if <pre>true</pre>.\r\n *\r\n * @name ErrorHandler\r\n * @class\r\n */\r\n\r\n\r\n /*\r\n * Parses a TTML color expression\r\n * \r\n */\r\n\r\n var HEX_COLOR_RE = /#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})?/;\r\n var DEC_COLOR_RE = /rgb\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*\\)/;\r\n var DEC_COLORA_RE = /rgba\\(\\s*(\\d+),\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*\\)/;\r\n var NAMED_COLOR = {\r\n transparent: [0, 0, 0, 0],\r\n black: [0, 0, 0, 255],\r\n silver: [192, 192, 192, 255],\r\n gray: [128, 128, 128, 255],\r\n white: [255, 255, 255, 255],\r\n maroon: [128, 0, 0, 255],\r\n red: [255, 0, 0, 255],\r\n purple: [128, 0, 128, 255],\r\n fuchsia: [255, 0, 255, 255],\r\n magenta: [255, 0, 255, 255],\r\n green: [0, 128, 0, 255],\r\n lime: [0, 255, 0, 255],\r\n olive: [128, 128, 0, 255],\r\n yellow: [255, 255, 0, 255],\r\n navy: [0, 0, 128, 255],\r\n blue: [0, 0, 255, 255],\r\n teal: [0, 128, 128, 255],\r\n aqua: [0, 255, 255, 255],\r\n cyan: [0, 255, 255, 255]\r\n };\r\n\r\n imscUtils.parseColor = function (str) {\r\n\r\n var m;\r\n \r\n var r = null;\r\n \r\n var nc = NAMED_COLOR[str.toLowerCase()];\r\n \r\n if (nc !== undefined) {\r\n\r\n r = nc;\r\n\r\n } else if ((m = HEX_COLOR_RE.exec(str)) !== null) {\r\n\r\n r = [parseInt(m[1], 16),\r\n parseInt(m[2], 16),\r\n parseInt(m[3], 16),\r\n (m[4] !== undefined ? parseInt(m[4], 16) : 255)];\r\n \r\n } else if ((m = DEC_COLOR_RE.exec(str)) !== null) {\r\n\r\n r = [parseInt(m[1]),\r\n parseInt(m[2]),\r\n parseInt(m[3]),\r\n 255];\r\n \r\n } else if ((m = DEC_COLORA_RE.exec(str)) !== null) {\r\n\r\n r = [parseInt(m[1]),\r\n parseInt(m[2]),\r\n parseInt(m[3]),\r\n parseInt(m[4])];\r\n \r\n }\r\n\r\n return r;\r\n };\r\n\r\n var LENGTH_RE = /^((?:\\+|\\-)?\\d*(?:\\.\\d+)?)(px|em|c|%|rh|rw)$/;\r\n\r\n imscUtils.parseLength = function (str) {\r\n\r\n var m;\r\n\r\n var r = null;\r\n\r\n if ((m = LENGTH_RE.exec(str)) !== null) {\r\n\r\n r = {value: parseFloat(m[1]), unit: m[2]};\r\n }\r\n\r\n return r;\r\n };\r\n\r\n imscUtils.parseTextShadow = function (str) {\r\n\r\n var shadows = str.match(/([^\\(,\\)]|\\([^\\)]+\\))+/g);\r\n \r\n var r = [];\r\n\r\n for (var i = 0; i < shadows.length; i++) {\r\n\r\n var shadow = shadows[i].split(\" \");\r\n\r\n if (shadow.length === 1 && shadow[0] === \"none\") {\r\n\r\n return \"none\";\r\n\r\n } else if (shadow.length > 1 && shadow.length < 5) {\r\n\r\n var out_shadow = [null, null, null, null];\r\n\r\n /* x offset */\r\n\r\n var l = imscUtils.parseLength(shadow.shift());\r\n\r\n if (l === null)\r\n return null;\r\n\r\n out_shadow[0] = l;\r\n\r\n /* y offset */\r\n\r\n l = imscUtils.parseLength(shadow.shift());\r\n\r\n if (l === null)\r\n return null;\r\n\r\n out_shadow[1] = l;\r\n\r\n /* is there a third component */\r\n\r\n if (shadow.length === 0) {\r\n r.push(out_shadow);\r\n continue;\r\n }\r\n\r\n l = imscUtils.parseLength(shadow[0]);\r\n\r\n if (l !== null) {\r\n\r\n out_shadow[2] = l;\r\n\r\n shadow.shift();\r\n\r\n }\r\n\r\n if (shadow.length === 0) {\r\n r.push(out_shadow);\r\n continue;\r\n }\r\n\r\n var c = imscUtils.parseColor(shadow[0]);\r\n\r\n if (c === null)\r\n return null;\r\n\r\n out_shadow[3] = c;\r\n\r\n r.push(out_shadow);\r\n }\r\n\r\n }\r\n\r\n return r;\r\n };\r\n\r\n\r\n imscUtils.parsePosition = function (str) {\r\n\r\n /* see https://www.w3.org/TR/ttml2/#style-value-position */\r\n\r\n var s = str.split(\" \");\r\n\r\n var isKeyword = function (str) {\r\n\r\n return str === \"center\" ||\r\n str === \"left\" ||\r\n str === \"top\" ||\r\n str === \"bottom\" ||\r\n str === \"right\";\r\n\r\n };\r\n\r\n if (s.length > 4) {\r\n\r\n return null;\r\n\r\n }\r\n\r\n /* initial clean-up pass */\r\n\r\n for (var j = 0 ; j < s.length; j++) {\r\n\r\n if (!isKeyword(s[j])) {\r\n\r\n var l = imscUtils.parseLength(s[j]);\r\n\r\n if (l === null)\r\n return null;\r\n\r\n s[j] = l;\r\n }\r\n\r\n }\r\n\r\n /* position default */\r\n\r\n var pos = {\r\n h: {edge: \"left\", offset: {value: 50, unit: \"%\"}},\r\n v: {edge: \"top\", offset: {value: 50, unit: \"%\"}}\r\n };\r\n\r\n /* update position */\r\n\r\n for (var i = 0; i < s.length; ) {\r\n\r\n /* extract the current component */\r\n\r\n var comp = s[i++];\r\n\r\n if (isKeyword(comp)) {\r\n\r\n /* we have a keyword */\r\n\r\n var offset = {value: 0, unit: \"%\"};\r\n\r\n /* peek at the next component */\r\n\r\n if (s.length !== 2 && i < s.length && (!isKeyword(s[i]))) {\r\n\r\n /* followed by an offset */\r\n\r\n offset = s[i++];\r\n\r\n }\r\n\r\n /* skip if center */\r\n\r\n if (comp === \"right\") {\r\n\r\n pos.h.edge = comp;\r\n\r\n pos.h.offset = offset;\r\n\r\n } else if (comp === \"bottom\") {\r\n\r\n pos.v.edge = comp;\r\n\r\n\r\n pos.v.offset = offset;\r\n\r\n\r\n } else if (comp === \"left\") {\r\n\r\n pos.h.offset = offset;\r\n\r\n\r\n } else if (comp === \"top\") {\r\n\r\n pos.v.offset = offset;\r\n\r\n\r\n }\r\n\r\n } else if (s.length === 1 || s.length === 2) {\r\n\r\n /* we have a bare value */\r\n\r\n if (i === 1) {\r\n\r\n /* assign it to left edge if first bare value */\r\n\r\n pos.h.offset = comp;\r\n\r\n } else {\r\n\r\n /* assign it to top edge if second bare value */\r\n\r\n pos.v.offset = comp;\r\n\r\n }\r\n\r\n } else {\r\n\r\n /* error condition */\r\n\r\n return null;\r\n\r\n }\r\n\r\n }\r\n\r\n return pos;\r\n };\r\n\r\n\r\n imscUtils.ComputedLength = function (rw, rh) {\r\n this.rw = rw;\r\n this.rh = rh;\r\n };\r\n\r\n imscUtils.ComputedLength.prototype.toUsedLength = function (width, height) {\r\n return width * this.rw + height * this.rh;\r\n };\r\n\r\n imscUtils.ComputedLength.prototype.isZero = function () {\r\n return this.rw === 0 && this.rh === 0;\r\n };\r\n\r\n /**\r\n * Computes a specified length to a root container relative length\r\n * \r\n * @param {number} lengthVal Length value to be computed\r\n * @param {string} lengthUnit Units of the length value\r\n * @param {number} emScale length of 1em, or null if em is not allowed\r\n * @param {number} percentScale length to which , or null if perecentage is not allowed\r\n * @param {number} cellScale length of 1c, or null if c is not allowed\r\n * @param {number} pxScale length of 1px, or null if px is not allowed\r\n * @param {number} direction 0 if the length is computed in the horizontal direction, 1 if the length is computed in the vertical direction\r\n * @return {number} Computed length\r\n */\r\n imscUtils.toComputedLength = function(lengthVal, lengthUnit, emLength, percentLength, cellLength, pxLength) {\r\n\r\n if (lengthUnit === \"%\" && percentLength) {\r\n\r\n return new imscUtils.ComputedLength(\r\n percentLength.rw * lengthVal / 100,\r\n percentLength.rh * lengthVal / 100\r\n );\r\n\r\n } else if (lengthUnit === \"em\" && emLength) {\r\n\r\n return new imscUtils.ComputedLength(\r\n emLength.rw * lengthVal,\r\n emLength.rh * lengthVal\r\n );\r\n\r\n } else if (lengthUnit === \"c\" && cellLength) {\r\n\r\n return new imscUtils.ComputedLength(\r\n lengthVal * cellLength.rw,\r\n lengthVal * cellLength.rh\r\n );\r\n\r\n } else if (lengthUnit === \"px\" && pxLength) {\r\n\r\n return new imscUtils.ComputedLength(\r\n lengthVal * pxLength.rw,\r\n lengthVal * pxLength.rh\r\n );\r\n\r\n } else if (lengthUnit === \"rh\") {\r\n\r\n return new imscUtils.ComputedLength(\r\n 0,\r\n lengthVal / 100\r\n );\r\n\r\n } else if (lengthUnit === \"rw\") {\r\n\r\n return new imscUtils.ComputedLength(\r\n lengthVal / 100,\r\n 0 \r\n );\r\n\r\n } else {\r\n\r\n return null;\r\n\r\n }\r\n\r\n };\r\n\r\n\r\n\r\n})( false ? undefined : exports);\r\n\n\n//# sourceURL=webpack://ardplayer/../imsc/src/main/js/utils.js?");
|
|
146
|
-
|
|
147
|
-
/***/ }),
|
|
148
|
-
|
|
149
|
-
/***/ "../inherits/inherits_browser.js":
|
|
150
|
-
/*!***************************************!*\
|
|
151
|
-
!*** ../inherits/inherits_browser.js ***!
|
|
152
|
-
\***************************************/
|
|
153
|
-
/*! no static exports found */
|
|
154
|
-
/***/ (function(module, exports) {
|
|
155
|
-
|
|
156
|
-
eval("if (typeof Object.create === 'function') {\n // implementation from standard node.js 'util' module\n module.exports = function inherits(ctor, superCtor) {\n if (superCtor) {\n ctor.super_ = superCtor\n ctor.prototype = Object.create(superCtor.prototype, {\n constructor: {\n value: ctor,\n enumerable: false,\n writable: true,\n configurable: true\n }\n })\n }\n };\n} else {\n // old school shim for old browsers\n module.exports = function inherits(ctor, superCtor) {\n if (superCtor) {\n ctor.super_ = superCtor\n var TempCtor = function () {}\n TempCtor.prototype = superCtor.prototype\n ctor.prototype = new TempCtor()\n ctor.prototype.constructor = ctor\n }\n }\n}\n\n\n//# sourceURL=webpack://ardplayer/../inherits/inherits_browser.js?");
|
|
157
|
-
|
|
158
|
-
/***/ }),
|
|
159
|
-
|
|
160
|
-
/***/ "../isarray/index.js":
|
|
161
|
-
/*!***************************!*\
|
|
162
|
-
!*** ../isarray/index.js ***!
|
|
163
|
-
\***************************/
|
|
164
|
-
/*! no static exports found */
|
|
165
|
-
/***/ (function(module, exports) {
|
|
166
|
-
|
|
167
|
-
eval("var toString = {}.toString;\n\nmodule.exports = Array.isArray || function (arr) {\n return toString.call(arr) == '[object Array]';\n};\n\n\n//# sourceURL=webpack://ardplayer/../isarray/index.js?");
|
|
168
|
-
|
|
169
|
-
/***/ }),
|
|
170
|
-
|
|
171
|
-
/***/ "../process-nextick-args/index.js":
|
|
172
|
-
/*!****************************************!*\
|
|
173
|
-
!*** ../process-nextick-args/index.js ***!
|
|
174
|
-
\****************************************/
|
|
175
|
-
/*! no static exports found */
|
|
176
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
177
|
-
|
|
178
|
-
"use strict";
|
|
179
|
-
eval("/* WEBPACK VAR INJECTION */(function(process) {\n\nif (typeof process === 'undefined' ||\n !process.version ||\n process.version.indexOf('v0.') === 0 ||\n process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {\n module.exports = { nextTick: nextTick };\n} else {\n module.exports = process\n}\n\nfunction nextTick(fn, arg1, arg2, arg3) {\n if (typeof fn !== 'function') {\n throw new TypeError('\"callback\" argument must be a function');\n }\n var len = arguments.length;\n var args, i;\n switch (len) {\n case 0:\n case 1:\n return process.nextTick(fn);\n case 2:\n return process.nextTick(function afterTickOne() {\n fn.call(null, arg1);\n });\n case 3:\n return process.nextTick(function afterTickTwo() {\n fn.call(null, arg1, arg2);\n });\n case 4:\n return process.nextTick(function afterTickThree() {\n fn.call(null, arg1, arg2, arg3);\n });\n default:\n args = new Array(len - 1);\n i = 0;\n while (i < args.length) {\n args[i++] = arguments[i];\n }\n return process.nextTick(function afterTick() {\n fn.apply(null, args);\n });\n }\n}\n\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../process/browser.js */ \"../process/browser.js\")))\n\n//# sourceURL=webpack://ardplayer/../process-nextick-args/index.js?");
|
|
180
|
-
|
|
181
|
-
/***/ }),
|
|
182
|
-
|
|
183
|
-
/***/ "../process/browser.js":
|
|
184
|
-
/*!*****************************!*\
|
|
185
|
-
!*** ../process/browser.js ***!
|
|
186
|
-
\*****************************/
|
|
187
|
-
/*! no static exports found */
|
|
188
|
-
/***/ (function(module, exports) {
|
|
189
|
-
|
|
190
|
-
eval("// shim for using process in browser\nvar process = module.exports = {};\n\n// cached from whatever global is present so that test runners that stub it\n// don't break things. But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals. It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\nfunction defaultSetTimout() {\n throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n throw new Error('clearTimeout has not been defined');\n}\n(function () {\n try {\n if (typeof setTimeout === 'function') {\n cachedSetTimeout = setTimeout;\n } else {\n cachedSetTimeout = defaultSetTimout;\n }\n } catch (e) {\n cachedSetTimeout = defaultSetTimout;\n }\n try {\n if (typeof clearTimeout === 'function') {\n cachedClearTimeout = clearTimeout;\n } else {\n cachedClearTimeout = defaultClearTimeout;\n }\n } catch (e) {\n cachedClearTimeout = defaultClearTimeout;\n }\n} ())\nfunction runTimeout(fun) {\n if (cachedSetTimeout === setTimeout) {\n //normal enviroments in sane situations\n return setTimeout(fun, 0);\n }\n // if setTimeout wasn't available but was latter defined\n if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n cachedSetTimeout = setTimeout;\n return setTimeout(fun, 0);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedSetTimeout(fun, 0);\n } catch(e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedSetTimeout.call(null, fun, 0);\n } catch(e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error\n return cachedSetTimeout.call(this, fun, 0);\n }\n }\n\n\n}\nfunction runClearTimeout(marker) {\n if (cachedClearTimeout === clearTimeout) {\n //normal enviroments in sane situations\n return clearTimeout(marker);\n }\n // if clearTimeout wasn't available but was latter defined\n if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n cachedClearTimeout = clearTimeout;\n return clearTimeout(marker);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedClearTimeout(marker);\n } catch (e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedClearTimeout.call(null, marker);\n } catch (e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.\n // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n return cachedClearTimeout.call(this, marker);\n }\n }\n\n\n\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n if (!draining || !currentQueue) {\n return;\n }\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = runTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n runClearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n runTimeout(drainQueue);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\nprocess.prependListener = noop;\nprocess.prependOnceListener = noop;\n\nprocess.listeners = function (name) { return [] }\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n\n\n//# sourceURL=webpack://ardplayer/../process/browser.js?");
|
|
191
|
-
|
|
192
|
-
/***/ }),
|
|
193
|
-
|
|
194
|
-
/***/ "../readable-stream/duplex-browser.js":
|
|
195
|
-
/*!********************************************!*\
|
|
196
|
-
!*** ../readable-stream/duplex-browser.js ***!
|
|
197
|
-
\********************************************/
|
|
198
|
-
/*! no static exports found */
|
|
199
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
200
|
-
|
|
201
|
-
eval("module.exports = __webpack_require__(/*! ./lib/_stream_duplex.js */ \"../readable-stream/lib/_stream_duplex.js\");\n\n\n//# sourceURL=webpack://ardplayer/../readable-stream/duplex-browser.js?");
|
|
202
|
-
|
|
203
|
-
/***/ }),
|
|
204
|
-
|
|
205
|
-
/***/ "../readable-stream/lib/_stream_duplex.js":
|
|
206
|
-
/*!************************************************!*\
|
|
207
|
-
!*** ../readable-stream/lib/_stream_duplex.js ***!
|
|
208
|
-
\************************************************/
|
|
209
|
-
/*! no static exports found */
|
|
210
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
211
|
-
|
|
212
|
-
"use strict";
|
|
213
|
-
eval("// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a duplex stream is just a stream that is both readable and writable.\n// Since JS doesn't have multiple prototypal inheritance, this class\n// prototypally inherits from Readable, and then parasitically from\n// Writable.\n\n\n\n/*<replacement>*/\n\nvar pna = __webpack_require__(/*! process-nextick-args */ \"../process-nextick-args/index.js\");\n/*</replacement>*/\n\n/*<replacement>*/\nvar objectKeys = Object.keys || function (obj) {\n var keys = [];\n for (var key in obj) {\n keys.push(key);\n }return keys;\n};\n/*</replacement>*/\n\nmodule.exports = Duplex;\n\n/*<replacement>*/\nvar util = Object.create(__webpack_require__(/*! core-util-is */ \"../core-util-is/lib/util.js\"));\nutil.inherits = __webpack_require__(/*! inherits */ \"../inherits/inherits_browser.js\");\n/*</replacement>*/\n\nvar Readable = __webpack_require__(/*! ./_stream_readable */ \"../readable-stream/lib/_stream_readable.js\");\nvar Writable = __webpack_require__(/*! ./_stream_writable */ \"../readable-stream/lib/_stream_writable.js\");\n\nutil.inherits(Duplex, Readable);\n\n{\n // avoid scope creep, the keys array can then be collected\n var keys = objectKeys(Writable.prototype);\n for (var v = 0; v < keys.length; v++) {\n var method = keys[v];\n if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];\n }\n}\n\nfunction Duplex(options) {\n if (!(this instanceof Duplex)) return new Duplex(options);\n\n Readable.call(this, options);\n Writable.call(this, options);\n\n if (options && options.readable === false) this.readable = false;\n\n if (options && options.writable === false) this.writable = false;\n\n this.allowHalfOpen = true;\n if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;\n\n this.once('end', onend);\n}\n\nObject.defineProperty(Duplex.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// the no-half-open enforcer\nfunction onend() {\n // if we allow half-open state, or if the writable side ended,\n // then we're ok.\n if (this.allowHalfOpen || this._writableState.ended) return;\n\n // no more data can be written.\n // But allow more writes to happen in this tick.\n pna.nextTick(onEndNT, this);\n}\n\nfunction onEndNT(self) {\n self.end();\n}\n\nObject.defineProperty(Duplex.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined || this._writableState === undefined) {\n return false;\n }\n return this._readableState.destroyed && this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (this._readableState === undefined || this._writableState === undefined) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n this._writableState.destroyed = value;\n }\n});\n\nDuplex.prototype._destroy = function (err, cb) {\n this.push(null);\n this.end();\n\n pna.nextTick(cb, err);\n};\n\n//# sourceURL=webpack://ardplayer/../readable-stream/lib/_stream_duplex.js?");
|
|
214
|
-
|
|
215
|
-
/***/ }),
|
|
216
|
-
|
|
217
|
-
/***/ "../readable-stream/lib/_stream_passthrough.js":
|
|
218
|
-
/*!*****************************************************!*\
|
|
219
|
-
!*** ../readable-stream/lib/_stream_passthrough.js ***!
|
|
220
|
-
\*****************************************************/
|
|
221
|
-
/*! no static exports found */
|
|
222
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
223
|
-
|
|
224
|
-
"use strict";
|
|
225
|
-
eval("// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a passthrough stream.\n// basically just the most minimal sort of Transform stream.\n// Every written chunk gets output as-is.\n\n\n\nmodule.exports = PassThrough;\n\nvar Transform = __webpack_require__(/*! ./_stream_transform */ \"../readable-stream/lib/_stream_transform.js\");\n\n/*<replacement>*/\nvar util = Object.create(__webpack_require__(/*! core-util-is */ \"../core-util-is/lib/util.js\"));\nutil.inherits = __webpack_require__(/*! inherits */ \"../inherits/inherits_browser.js\");\n/*</replacement>*/\n\nutil.inherits(PassThrough, Transform);\n\nfunction PassThrough(options) {\n if (!(this instanceof PassThrough)) return new PassThrough(options);\n\n Transform.call(this, options);\n}\n\nPassThrough.prototype._transform = function (chunk, encoding, cb) {\n cb(null, chunk);\n};\n\n//# sourceURL=webpack://ardplayer/../readable-stream/lib/_stream_passthrough.js?");
|
|
226
|
-
|
|
227
|
-
/***/ }),
|
|
228
|
-
|
|
229
|
-
/***/ "../readable-stream/lib/_stream_readable.js":
|
|
230
|
-
/*!**************************************************!*\
|
|
231
|
-
!*** ../readable-stream/lib/_stream_readable.js ***!
|
|
232
|
-
\**************************************************/
|
|
233
|
-
/*! no static exports found */
|
|
234
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
235
|
-
|
|
236
|
-
"use strict";
|
|
237
|
-
eval("/* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\n\n/*<replacement>*/\n\nvar pna = __webpack_require__(/*! process-nextick-args */ \"../process-nextick-args/index.js\");\n/*</replacement>*/\n\nmodule.exports = Readable;\n\n/*<replacement>*/\nvar isArray = __webpack_require__(/*! isarray */ \"../isarray/index.js\");\n/*</replacement>*/\n\n/*<replacement>*/\nvar Duplex;\n/*</replacement>*/\n\nReadable.ReadableState = ReadableState;\n\n/*<replacement>*/\nvar EE = __webpack_require__(/*! events */ \"../events/events.js\").EventEmitter;\n\nvar EElistenerCount = function (emitter, type) {\n return emitter.listeners(type).length;\n};\n/*</replacement>*/\n\n/*<replacement>*/\nvar Stream = __webpack_require__(/*! ./internal/streams/stream */ \"../readable-stream/lib/internal/streams/stream-browser.js\");\n/*</replacement>*/\n\n/*<replacement>*/\n\nvar Buffer = __webpack_require__(/*! safe-buffer */ \"../readable-stream/node_modules/safe-buffer/index.js\").Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/*</replacement>*/\n\n/*<replacement>*/\nvar util = Object.create(__webpack_require__(/*! core-util-is */ \"../core-util-is/lib/util.js\"));\nutil.inherits = __webpack_require__(/*! inherits */ \"../inherits/inherits_browser.js\");\n/*</replacement>*/\n\n/*<replacement>*/\nvar debugUtil = __webpack_require__(/*! util */ 1);\nvar debug = void 0;\nif (debugUtil && debugUtil.debuglog) {\n debug = debugUtil.debuglog('stream');\n} else {\n debug = function () {};\n}\n/*</replacement>*/\n\nvar BufferList = __webpack_require__(/*! ./internal/streams/BufferList */ \"../readable-stream/lib/internal/streams/BufferList.js\");\nvar destroyImpl = __webpack_require__(/*! ./internal/streams/destroy */ \"../readable-stream/lib/internal/streams/destroy.js\");\nvar StringDecoder;\n\nutil.inherits(Readable, Stream);\n\nvar kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];\n\nfunction prependListener(emitter, event, fn) {\n // Sadly this is not cacheable as some libraries bundle their own\n // event emitter implementation with them.\n if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);\n\n // This is a hack to make sure that our error handler is attached before any\n // userland ones. NEVER DO THIS. This is here only because this code needs\n // to continue to work with older versions of Node.js that do not include\n // the prependListener() method. The goal is to eventually remove this hack.\n if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];\n}\n\nfunction ReadableState(options, stream) {\n Duplex = Duplex || __webpack_require__(/*! ./_stream_duplex */ \"../readable-stream/lib/_stream_duplex.js\");\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag. Used to make read(n) ignore n and to\n // make all the buffer merging and length checks go away\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;\n\n // the point at which it stops calling _read() to fill the buffer\n // Note: 0 is a valid value, means \"don't call _read preemptively ever\"\n var hwm = options.highWaterMark;\n var readableHwm = options.readableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // A linked list is used to store data chunks instead of an array because the\n // linked list can remove elements from the beginning faster than\n // array.shift()\n this.buffer = new BufferList();\n this.length = 0;\n this.pipes = null;\n this.pipesCount = 0;\n this.flowing = null;\n this.ended = false;\n this.endEmitted = false;\n this.reading = false;\n\n // a flag to be able to tell if the event 'readable'/'data' is emitted\n // immediately, or on a later tick. We set this to true at first, because\n // any actions that shouldn't happen until \"later\" should generally also\n // not happen before the first read call.\n this.sync = true;\n\n // whenever we return null, then we set a flag to say\n // that we're awaiting a 'readable' event emission.\n this.needReadable = false;\n this.emittedReadable = false;\n this.readableListening = false;\n this.resumeScheduled = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // the number of writers that are awaiting a drain event in .pipe()s\n this.awaitDrain = 0;\n\n // if true, a maybeReadMore has been scheduled\n this.readingMore = false;\n\n this.decoder = null;\n this.encoding = null;\n if (options.encoding) {\n if (!StringDecoder) StringDecoder = __webpack_require__(/*! string_decoder/ */ \"../string_decoder/lib/string_decoder.js\").StringDecoder;\n this.decoder = new StringDecoder(options.encoding);\n this.encoding = options.encoding;\n }\n}\n\nfunction Readable(options) {\n Duplex = Duplex || __webpack_require__(/*! ./_stream_duplex */ \"../readable-stream/lib/_stream_duplex.js\");\n\n if (!(this instanceof Readable)) return new Readable(options);\n\n this._readableState = new ReadableState(options, this);\n\n // legacy\n this.readable = true;\n\n if (options) {\n if (typeof options.read === 'function') this._read = options.read;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n }\n\n Stream.call(this);\n}\n\nObject.defineProperty(Readable.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined) {\n return false;\n }\n return this._readableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._readableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n }\n});\n\nReadable.prototype.destroy = destroyImpl.destroy;\nReadable.prototype._undestroy = destroyImpl.undestroy;\nReadable.prototype._destroy = function (err, cb) {\n this.push(null);\n cb(err);\n};\n\n// Manually shove something into the read() buffer.\n// This returns true if the highWaterMark has not been hit yet,\n// similar to how Writable.write() returns true if you should\n// write() some more.\nReadable.prototype.push = function (chunk, encoding) {\n var state = this._readableState;\n var skipChunkCheck;\n\n if (!state.objectMode) {\n if (typeof chunk === 'string') {\n encoding = encoding || state.defaultEncoding;\n if (encoding !== state.encoding) {\n chunk = Buffer.from(chunk, encoding);\n encoding = '';\n }\n skipChunkCheck = true;\n }\n } else {\n skipChunkCheck = true;\n }\n\n return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);\n};\n\n// Unshift should *always* be something directly out of read()\nReadable.prototype.unshift = function (chunk) {\n return readableAddChunk(this, chunk, null, true, false);\n};\n\nfunction readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {\n var state = stream._readableState;\n if (chunk === null) {\n state.reading = false;\n onEofChunk(stream, state);\n } else {\n var er;\n if (!skipChunkCheck) er = chunkInvalid(state, chunk);\n if (er) {\n stream.emit('error', er);\n } else if (state.objectMode || chunk && chunk.length > 0) {\n if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (addToFront) {\n if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);\n } else if (state.ended) {\n stream.emit('error', new Error('stream.push() after EOF'));\n } else {\n state.reading = false;\n if (state.decoder && !encoding) {\n chunk = state.decoder.write(chunk);\n if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);\n } else {\n addChunk(stream, state, chunk, false);\n }\n }\n } else if (!addToFront) {\n state.reading = false;\n }\n }\n\n return needMoreData(state);\n}\n\nfunction addChunk(stream, state, chunk, addToFront) {\n if (state.flowing && state.length === 0 && !state.sync) {\n stream.emit('data', chunk);\n stream.read(0);\n } else {\n // update the buffer info.\n state.length += state.objectMode ? 1 : chunk.length;\n if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);\n\n if (state.needReadable) emitReadable(stream);\n }\n maybeReadMore(stream, state);\n}\n\nfunction chunkInvalid(state, chunk) {\n var er;\n if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n return er;\n}\n\n// if it's past the high water mark, we can push in some more.\n// Also, if we have no data yet, we can stand some\n// more bytes. This is to work around cases where hwm=0,\n// such as the repl. Also, if the push() triggered a\n// readable event, and the user called read(largeNumber) such that\n// needReadable was set, then we ought to push more, so that another\n// 'readable' event will be triggered.\nfunction needMoreData(state) {\n return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);\n}\n\nReadable.prototype.isPaused = function () {\n return this._readableState.flowing === false;\n};\n\n// backwards compatibility.\nReadable.prototype.setEncoding = function (enc) {\n if (!StringDecoder) StringDecoder = __webpack_require__(/*! string_decoder/ */ \"../string_decoder/lib/string_decoder.js\").StringDecoder;\n this._readableState.decoder = new StringDecoder(enc);\n this._readableState.encoding = enc;\n return this;\n};\n\n// Don't raise the hwm > 8MB\nvar MAX_HWM = 0x800000;\nfunction computeNewHighWaterMark(n) {\n if (n >= MAX_HWM) {\n n = MAX_HWM;\n } else {\n // Get the next highest power of 2 to prevent increasing hwm excessively in\n // tiny amounts\n n--;\n n |= n >>> 1;\n n |= n >>> 2;\n n |= n >>> 4;\n n |= n >>> 8;\n n |= n >>> 16;\n n++;\n }\n return n;\n}\n\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction howMuchToRead(n, state) {\n if (n <= 0 || state.length === 0 && state.ended) return 0;\n if (state.objectMode) return 1;\n if (n !== n) {\n // Only flow one buffer at a time\n if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;\n }\n // If we're asking for more than the current hwm, then raise the hwm.\n if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);\n if (n <= state.length) return n;\n // Don't have enough\n if (!state.ended) {\n state.needReadable = true;\n return 0;\n }\n return state.length;\n}\n\n// you can override either this method, or the async _read(n) below.\nReadable.prototype.read = function (n) {\n debug('read', n);\n n = parseInt(n, 10);\n var state = this._readableState;\n var nOrig = n;\n\n if (n !== 0) state.emittedReadable = false;\n\n // if we're doing read(0) to trigger a readable event, but we\n // already have a bunch of data in the buffer, then just trigger\n // the 'readable' event and move on.\n if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {\n debug('read: emitReadable', state.length, state.ended);\n if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);\n return null;\n }\n\n n = howMuchToRead(n, state);\n\n // if we've ended, and we're now clear, then finish it up.\n if (n === 0 && state.ended) {\n if (state.length === 0) endReadable(this);\n return null;\n }\n\n // All the actual chunk generation logic needs to be\n // *below* the call to _read. The reason is that in certain\n // synthetic stream cases, such as passthrough streams, _read\n // may be a completely synchronous operation which may change\n // the state of the read buffer, providing enough data when\n // before there was *not* enough.\n //\n // So, the steps are:\n // 1. Figure out what the state of things will be after we do\n // a read from the buffer.\n //\n // 2. If that resulting state will trigger a _read, then call _read.\n // Note that this may be asynchronous, or synchronous. Yes, it is\n // deeply ugly to write APIs this way, but that still doesn't mean\n // that the Readable class should behave improperly, as streams are\n // designed to be sync/async agnostic.\n // Take note if the _read call is sync or async (ie, if the read call\n // has returned yet), so that we know whether or not it's safe to emit\n // 'readable' etc.\n //\n // 3. Actually pull the requested chunks out of the buffer and return.\n\n // if we need a readable event, then we need to do some reading.\n var doRead = state.needReadable;\n debug('need readable', doRead);\n\n // if we currently have less than the highWaterMark, then also read some\n if (state.length === 0 || state.length - n < state.highWaterMark) {\n doRead = true;\n debug('length less than watermark', doRead);\n }\n\n // however, if we've ended, then there's no point, and if we're already\n // reading, then it's unnecessary.\n if (state.ended || state.reading) {\n doRead = false;\n debug('reading or ended', doRead);\n } else if (doRead) {\n debug('do read');\n state.reading = true;\n state.sync = true;\n // if the length is currently zero, then we *need* a readable event.\n if (state.length === 0) state.needReadable = true;\n // call internal read method\n this._read(state.highWaterMark);\n state.sync = false;\n // If _read pushed data synchronously, then `reading` will be false,\n // and we need to re-evaluate how much data we can return to the user.\n if (!state.reading) n = howMuchToRead(nOrig, state);\n }\n\n var ret;\n if (n > 0) ret = fromList(n, state);else ret = null;\n\n if (ret === null) {\n state.needReadable = true;\n n = 0;\n } else {\n state.length -= n;\n }\n\n if (state.length === 0) {\n // If we have nothing in the buffer, then we want to know\n // as soon as we *do* get something into the buffer.\n if (!state.ended) state.needReadable = true;\n\n // If we tried to read() past the EOF, then emit end on the next tick.\n if (nOrig !== n && state.ended) endReadable(this);\n }\n\n if (ret !== null) this.emit('data', ret);\n\n return ret;\n};\n\nfunction onEofChunk(stream, state) {\n if (state.ended) return;\n if (state.decoder) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) {\n state.buffer.push(chunk);\n state.length += state.objectMode ? 1 : chunk.length;\n }\n }\n state.ended = true;\n\n // emit 'readable' now to make sure it gets picked up.\n emitReadable(stream);\n}\n\n// Don't emit readable right away in sync mode, because this can trigger\n// another read() call => stack overflow. This way, it might trigger\n// a nextTick recursion warning, but that's not so bad.\nfunction emitReadable(stream) {\n var state = stream._readableState;\n state.needReadable = false;\n if (!state.emittedReadable) {\n debug('emitReadable', state.flowing);\n state.emittedReadable = true;\n if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);\n }\n}\n\nfunction emitReadable_(stream) {\n debug('emit readable');\n stream.emit('readable');\n flow(stream);\n}\n\n// at this point, the user has presumably seen the 'readable' event,\n// and called read() to consume some data. that may have triggered\n// in turn another _read(n) call, in which case reading = true if\n// it's in progress.\n// However, if we're not ended, or reading, and the length < hwm,\n// then go ahead and try to read some more preemptively.\nfunction maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n pna.nextTick(maybeReadMore_, stream, state);\n }\n}\n\nfunction maybeReadMore_(stream, state) {\n var len = state.length;\n while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {\n debug('maybeReadMore read 0');\n stream.read(0);\n if (len === state.length)\n // didn't get any data, stop spinning.\n break;else len = state.length;\n }\n state.readingMore = false;\n}\n\n// abstract method. to be overridden in specific implementation classes.\n// call cb(er, data) where data is <= n in length.\n// for virtual (non-string, non-buffer) streams, \"length\" is somewhat\n// arbitrary, and perhaps not very meaningful.\nReadable.prototype._read = function (n) {\n this.emit('error', new Error('_read() is not implemented'));\n};\n\nReadable.prototype.pipe = function (dest, pipeOpts) {\n var src = this;\n var state = this._readableState;\n\n switch (state.pipesCount) {\n case 0:\n state.pipes = dest;\n break;\n case 1:\n state.pipes = [state.pipes, dest];\n break;\n default:\n state.pipes.push(dest);\n break;\n }\n state.pipesCount += 1;\n debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);\n\n var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;\n\n var endFn = doEnd ? onend : unpipe;\n if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);\n\n dest.on('unpipe', onunpipe);\n function onunpipe(readable, unpipeInfo) {\n debug('onunpipe');\n if (readable === src) {\n if (unpipeInfo && unpipeInfo.hasUnpiped === false) {\n unpipeInfo.hasUnpiped = true;\n cleanup();\n }\n }\n }\n\n function onend() {\n debug('onend');\n dest.end();\n }\n\n // when the dest drains, it reduces the awaitDrain counter\n // on the source. This would be more elegant with a .once()\n // handler in flow(), but adding and removing repeatedly is\n // too slow.\n var ondrain = pipeOnDrain(src);\n dest.on('drain', ondrain);\n\n var cleanedUp = false;\n function cleanup() {\n debug('cleanup');\n // cleanup event handlers once the pipe is broken\n dest.removeListener('close', onclose);\n dest.removeListener('finish', onfinish);\n dest.removeListener('drain', ondrain);\n dest.removeListener('error', onerror);\n dest.removeListener('unpipe', onunpipe);\n src.removeListener('end', onend);\n src.removeListener('end', unpipe);\n src.removeListener('data', ondata);\n\n cleanedUp = true;\n\n // if the reader is waiting for a drain event from this\n // specific writer, then it would cause it to never start\n // flowing again.\n // So, if this is awaiting a drain, then we just call it now.\n // If we don't know, then assume that we are waiting for one.\n if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();\n }\n\n // If the user pushes more data while we're writing to dest then we'll end up\n // in ondata again. However, we only want to increase awaitDrain once because\n // dest will only emit one 'drain' event for the multiple writes.\n // => Introduce a guard on increasing awaitDrain.\n var increasedAwaitDrain = false;\n src.on('data', ondata);\n function ondata(chunk) {\n debug('ondata');\n increasedAwaitDrain = false;\n var ret = dest.write(chunk);\n if (false === ret && !increasedAwaitDrain) {\n // If the user unpiped during `dest.write()`, it is possible\n // to get stuck in a permanently paused state if that write\n // also returned false.\n // => Check whether `dest` is still a piping destination.\n if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {\n debug('false write response, pause', src._readableState.awaitDrain);\n src._readableState.awaitDrain++;\n increasedAwaitDrain = true;\n }\n src.pause();\n }\n }\n\n // if the dest has an error, then stop piping into it.\n // however, don't suppress the throwing behavior for this.\n function onerror(er) {\n debug('onerror', er);\n unpipe();\n dest.removeListener('error', onerror);\n if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);\n }\n\n // Make sure our error handler is attached before userland ones.\n prependListener(dest, 'error', onerror);\n\n // Both close and finish should trigger unpipe, but only once.\n function onclose() {\n dest.removeListener('finish', onfinish);\n unpipe();\n }\n dest.once('close', onclose);\n function onfinish() {\n debug('onfinish');\n dest.removeListener('close', onclose);\n unpipe();\n }\n dest.once('finish', onfinish);\n\n function unpipe() {\n debug('unpipe');\n src.unpipe(dest);\n }\n\n // tell the dest that it's being piped to\n dest.emit('pipe', src);\n\n // start the flow if it hasn't been started already.\n if (!state.flowing) {\n debug('pipe resume');\n src.resume();\n }\n\n return dest;\n};\n\nfunction pipeOnDrain(src) {\n return function () {\n var state = src._readableState;\n debug('pipeOnDrain', state.awaitDrain);\n if (state.awaitDrain) state.awaitDrain--;\n if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {\n state.flowing = true;\n flow(src);\n }\n };\n}\n\nReadable.prototype.unpipe = function (dest) {\n var state = this._readableState;\n var unpipeInfo = { hasUnpiped: false };\n\n // if we're not piping anywhere, then do nothing.\n if (state.pipesCount === 0) return this;\n\n // just one destination. most common case.\n if (state.pipesCount === 1) {\n // passed in one, but it's not the right one.\n if (dest && dest !== state.pipes) return this;\n\n if (!dest) dest = state.pipes;\n\n // got a match.\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n if (dest) dest.emit('unpipe', this, unpipeInfo);\n return this;\n }\n\n // slow case. multiple pipe destinations.\n\n if (!dest) {\n // remove all.\n var dests = state.pipes;\n var len = state.pipesCount;\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n\n for (var i = 0; i < len; i++) {\n dests[i].emit('unpipe', this, unpipeInfo);\n }return this;\n }\n\n // try to find the right one.\n var index = indexOf(state.pipes, dest);\n if (index === -1) return this;\n\n state.pipes.splice(index, 1);\n state.pipesCount -= 1;\n if (state.pipesCount === 1) state.pipes = state.pipes[0];\n\n dest.emit('unpipe', this, unpipeInfo);\n\n return this;\n};\n\n// set up data events if they are asked for\n// Ensure readable listeners eventually get something\nReadable.prototype.on = function (ev, fn) {\n var res = Stream.prototype.on.call(this, ev, fn);\n\n if (ev === 'data') {\n // Start flowing on next tick if stream isn't explicitly paused\n if (this._readableState.flowing !== false) this.resume();\n } else if (ev === 'readable') {\n var state = this._readableState;\n if (!state.endEmitted && !state.readableListening) {\n state.readableListening = state.needReadable = true;\n state.emittedReadable = false;\n if (!state.reading) {\n pna.nextTick(nReadingNextTick, this);\n } else if (state.length) {\n emitReadable(this);\n }\n }\n }\n\n return res;\n};\nReadable.prototype.addListener = Readable.prototype.on;\n\nfunction nReadingNextTick(self) {\n debug('readable nexttick read 0');\n self.read(0);\n}\n\n// pause() and resume() are remnants of the legacy readable stream API\n// If the user uses them, then switch into old mode.\nReadable.prototype.resume = function () {\n var state = this._readableState;\n if (!state.flowing) {\n debug('resume');\n state.flowing = true;\n resume(this, state);\n }\n return this;\n};\n\nfunction resume(stream, state) {\n if (!state.resumeScheduled) {\n state.resumeScheduled = true;\n pna.nextTick(resume_, stream, state);\n }\n}\n\nfunction resume_(stream, state) {\n if (!state.reading) {\n debug('resume read 0');\n stream.read(0);\n }\n\n state.resumeScheduled = false;\n state.awaitDrain = 0;\n stream.emit('resume');\n flow(stream);\n if (state.flowing && !state.reading) stream.read(0);\n}\n\nReadable.prototype.pause = function () {\n debug('call pause flowing=%j', this._readableState.flowing);\n if (false !== this._readableState.flowing) {\n debug('pause');\n this._readableState.flowing = false;\n this.emit('pause');\n }\n return this;\n};\n\nfunction flow(stream) {\n var state = stream._readableState;\n debug('flow', state.flowing);\n while (state.flowing && stream.read() !== null) {}\n}\n\n// wrap an old-style stream as the async data source.\n// This is *not* part of the readable stream interface.\n// It is an ugly unfortunate mess of history.\nReadable.prototype.wrap = function (stream) {\n var _this = this;\n\n var state = this._readableState;\n var paused = false;\n\n stream.on('end', function () {\n debug('wrapped end');\n if (state.decoder && !state.ended) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) _this.push(chunk);\n }\n\n _this.push(null);\n });\n\n stream.on('data', function (chunk) {\n debug('wrapped data');\n if (state.decoder) chunk = state.decoder.write(chunk);\n\n // don't skip over falsy values in objectMode\n if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;\n\n var ret = _this.push(chunk);\n if (!ret) {\n paused = true;\n stream.pause();\n }\n });\n\n // proxy all the other methods.\n // important when wrapping filters and duplexes.\n for (var i in stream) {\n if (this[i] === undefined && typeof stream[i] === 'function') {\n this[i] = function (method) {\n return function () {\n return stream[method].apply(stream, arguments);\n };\n }(i);\n }\n }\n\n // proxy certain important events.\n for (var n = 0; n < kProxyEvents.length; n++) {\n stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));\n }\n\n // when we try to consume some more bytes, simply unpause the\n // underlying stream.\n this._read = function (n) {\n debug('wrapped _read', n);\n if (paused) {\n paused = false;\n stream.resume();\n }\n };\n\n return this;\n};\n\nObject.defineProperty(Readable.prototype, 'readableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._readableState.highWaterMark;\n }\n});\n\n// exposed for testing purposes only.\nReadable._fromList = fromList;\n\n// Pluck off n bytes from an array of buffers.\n// Length is the combined lengths of all the buffers in the list.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromList(n, state) {\n // nothing buffered\n if (state.length === 0) return null;\n\n var ret;\n if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {\n // read it all, truncate the list\n if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);\n state.buffer.clear();\n } else {\n // read part of list\n ret = fromListPartial(n, state.buffer, state.decoder);\n }\n\n return ret;\n}\n\n// Extracts only enough buffered data to satisfy the amount requested.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromListPartial(n, list, hasStrings) {\n var ret;\n if (n < list.head.data.length) {\n // slice is the same for buffers and strings\n ret = list.head.data.slice(0, n);\n list.head.data = list.head.data.slice(n);\n } else if (n === list.head.data.length) {\n // first chunk is a perfect match\n ret = list.shift();\n } else {\n // result spans more than one buffer\n ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);\n }\n return ret;\n}\n\n// Copies a specified amount of characters from the list of buffered data\n// chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBufferString(n, list) {\n var p = list.head;\n var c = 1;\n var ret = p.data;\n n -= ret.length;\n while (p = p.next) {\n var str = p.data;\n var nb = n > str.length ? str.length : n;\n if (nb === str.length) ret += str;else ret += str.slice(0, n);\n n -= nb;\n if (n === 0) {\n if (nb === str.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = str.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\n// Copies a specified amount of bytes from the list of buffered data chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBuffer(n, list) {\n var ret = Buffer.allocUnsafe(n);\n var p = list.head;\n var c = 1;\n p.data.copy(ret);\n n -= p.data.length;\n while (p = p.next) {\n var buf = p.data;\n var nb = n > buf.length ? buf.length : n;\n buf.copy(ret, ret.length - n, 0, nb);\n n -= nb;\n if (n === 0) {\n if (nb === buf.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = buf.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\nfunction endReadable(stream) {\n var state = stream._readableState;\n\n // If we get here before consuming all the bytes, then that is a\n // bug in node. Should never happen.\n if (state.length > 0) throw new Error('\"endReadable()\" called on non-empty stream');\n\n if (!state.endEmitted) {\n state.ended = true;\n pna.nextTick(endReadableNT, state, stream);\n }\n}\n\nfunction endReadableNT(state, stream) {\n // Check that we didn't get one last unshift.\n if (!state.endEmitted && state.length === 0) {\n state.endEmitted = true;\n stream.readable = false;\n stream.emit('end');\n }\n}\n\nfunction indexOf(xs, x) {\n for (var i = 0, l = xs.length; i < l; i++) {\n if (xs[i] === x) return i;\n }\n return -1;\n}\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../webpack/buildin/global.js */ \"../webpack/buildin/global.js\"), __webpack_require__(/*! ./../../process/browser.js */ \"../process/browser.js\")))\n\n//# sourceURL=webpack://ardplayer/../readable-stream/lib/_stream_readable.js?");
|
|
238
|
-
|
|
239
|
-
/***/ }),
|
|
240
|
-
|
|
241
|
-
/***/ "../readable-stream/lib/_stream_transform.js":
|
|
242
|
-
/*!***************************************************!*\
|
|
243
|
-
!*** ../readable-stream/lib/_stream_transform.js ***!
|
|
244
|
-
\***************************************************/
|
|
245
|
-
/*! no static exports found */
|
|
246
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
247
|
-
|
|
248
|
-
"use strict";
|
|
249
|
-
eval("// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a transform stream is a readable/writable stream where you do\n// something with the data. Sometimes it's called a \"filter\",\n// but that's not a great name for it, since that implies a thing where\n// some bits pass through, and others are simply ignored. (That would\n// be a valid example of a transform, of course.)\n//\n// While the output is causally related to the input, it's not a\n// necessarily symmetric or synchronous transformation. For example,\n// a zlib stream might take multiple plain-text writes(), and then\n// emit a single compressed chunk some time in the future.\n//\n// Here's how this works:\n//\n// The Transform stream has all the aspects of the readable and writable\n// stream classes. When you write(chunk), that calls _write(chunk,cb)\n// internally, and returns false if there's a lot of pending writes\n// buffered up. When you call read(), that calls _read(n) until\n// there's enough pending readable data buffered up.\n//\n// In a transform stream, the written data is placed in a buffer. When\n// _read(n) is called, it transforms the queued up data, calling the\n// buffered _write cb's as it consumes chunks. If consuming a single\n// written chunk would result in multiple output chunks, then the first\n// outputted bit calls the readcb, and subsequent chunks just go into\n// the read buffer, and will cause it to emit 'readable' if necessary.\n//\n// This way, back-pressure is actually determined by the reading side,\n// since _read has to be called to start processing a new chunk. However,\n// a pathological inflate type of transform can cause excessive buffering\n// here. For example, imagine a stream where every byte of input is\n// interpreted as an integer from 0-255, and then results in that many\n// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in\n// 1kb of data being output. In this case, you could write a very small\n// amount of input, and end up with a very large amount of output. In\n// such a pathological inflating mechanism, there'd be no way to tell\n// the system to stop doing the transform. A single 4MB write could\n// cause the system to run out of memory.\n//\n// However, even in such a pathological case, only a single written chunk\n// would be consumed, and then the rest would wait (un-transformed) until\n// the results of the previous transformed chunk were consumed.\n\n\n\nmodule.exports = Transform;\n\nvar Duplex = __webpack_require__(/*! ./_stream_duplex */ \"../readable-stream/lib/_stream_duplex.js\");\n\n/*<replacement>*/\nvar util = Object.create(__webpack_require__(/*! core-util-is */ \"../core-util-is/lib/util.js\"));\nutil.inherits = __webpack_require__(/*! inherits */ \"../inherits/inherits_browser.js\");\n/*</replacement>*/\n\nutil.inherits(Transform, Duplex);\n\nfunction afterTransform(er, data) {\n var ts = this._transformState;\n ts.transforming = false;\n\n var cb = ts.writecb;\n\n if (!cb) {\n return this.emit('error', new Error('write callback called multiple times'));\n }\n\n ts.writechunk = null;\n ts.writecb = null;\n\n if (data != null) // single equals check for both `null` and `undefined`\n this.push(data);\n\n cb(er);\n\n var rs = this._readableState;\n rs.reading = false;\n if (rs.needReadable || rs.length < rs.highWaterMark) {\n this._read(rs.highWaterMark);\n }\n}\n\nfunction Transform(options) {\n if (!(this instanceof Transform)) return new Transform(options);\n\n Duplex.call(this, options);\n\n this._transformState = {\n afterTransform: afterTransform.bind(this),\n needTransform: false,\n transforming: false,\n writecb: null,\n writechunk: null,\n writeencoding: null\n };\n\n // start out asking for a readable event once data is transformed.\n this._readableState.needReadable = true;\n\n // we have implemented the _read method, and done the other things\n // that Readable wants before the first _read call, so unset the\n // sync guard flag.\n this._readableState.sync = false;\n\n if (options) {\n if (typeof options.transform === 'function') this._transform = options.transform;\n\n if (typeof options.flush === 'function') this._flush = options.flush;\n }\n\n // When the writable side finishes, then flush out anything remaining.\n this.on('prefinish', prefinish);\n}\n\nfunction prefinish() {\n var _this = this;\n\n if (typeof this._flush === 'function') {\n this._flush(function (er, data) {\n done(_this, er, data);\n });\n } else {\n done(this, null, null);\n }\n}\n\nTransform.prototype.push = function (chunk, encoding) {\n this._transformState.needTransform = false;\n return Duplex.prototype.push.call(this, chunk, encoding);\n};\n\n// This is the part where you do stuff!\n// override this function in implementation classes.\n// 'chunk' is an input chunk.\n//\n// Call `push(newChunk)` to pass along transformed output\n// to the readable side. You may call 'push' zero or more times.\n//\n// Call `cb(err)` when you are done with this chunk. If you pass\n// an error, then that'll put the hurt on the whole operation. If you\n// never call cb(), then you'll never get another chunk.\nTransform.prototype._transform = function (chunk, encoding, cb) {\n throw new Error('_transform() is not implemented');\n};\n\nTransform.prototype._write = function (chunk, encoding, cb) {\n var ts = this._transformState;\n ts.writecb = cb;\n ts.writechunk = chunk;\n ts.writeencoding = encoding;\n if (!ts.transforming) {\n var rs = this._readableState;\n if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);\n }\n};\n\n// Doesn't matter what the args are here.\n// _transform does all the work.\n// That we got here means that the readable side wants more data.\nTransform.prototype._read = function (n) {\n var ts = this._transformState;\n\n if (ts.writechunk !== null && ts.writecb && !ts.transforming) {\n ts.transforming = true;\n this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);\n } else {\n // mark that we need a transform, so that any data that comes in\n // will get processed, now that we've asked for it.\n ts.needTransform = true;\n }\n};\n\nTransform.prototype._destroy = function (err, cb) {\n var _this2 = this;\n\n Duplex.prototype._destroy.call(this, err, function (err2) {\n cb(err2);\n _this2.emit('close');\n });\n};\n\nfunction done(stream, er, data) {\n if (er) return stream.emit('error', er);\n\n if (data != null) // single equals check for both `null` and `undefined`\n stream.push(data);\n\n // if there's nothing in the write buffer, then that means\n // that nothing more will ever be provided\n if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');\n\n if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');\n\n return stream.push(null);\n}\n\n//# sourceURL=webpack://ardplayer/../readable-stream/lib/_stream_transform.js?");
|
|
250
|
-
|
|
251
|
-
/***/ }),
|
|
252
|
-
|
|
253
|
-
/***/ "../readable-stream/lib/_stream_writable.js":
|
|
254
|
-
/*!**************************************************!*\
|
|
255
|
-
!*** ../readable-stream/lib/_stream_writable.js ***!
|
|
256
|
-
\**************************************************/
|
|
257
|
-
/*! no static exports found */
|
|
258
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
259
|
-
|
|
260
|
-
"use strict";
|
|
261
|
-
eval("/* WEBPACK VAR INJECTION */(function(process, setImmediate, global) {// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// A bit simpler than readable streams.\n// Implement an async ._write(chunk, encoding, cb), and it'll handle all\n// the drain event emission and buffering.\n\n\n\n/*<replacement>*/\n\nvar pna = __webpack_require__(/*! process-nextick-args */ \"../process-nextick-args/index.js\");\n/*</replacement>*/\n\nmodule.exports = Writable;\n\n/* <replacement> */\nfunction WriteReq(chunk, encoding, cb) {\n this.chunk = chunk;\n this.encoding = encoding;\n this.callback = cb;\n this.next = null;\n}\n\n// It seems a linked list but it is not\n// there will be only 2 of these for each stream\nfunction CorkedRequest(state) {\n var _this = this;\n\n this.next = null;\n this.entry = null;\n this.finish = function () {\n onCorkedFinish(_this, state);\n };\n}\n/* </replacement> */\n\n/*<replacement>*/\nvar asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;\n/*</replacement>*/\n\n/*<replacement>*/\nvar Duplex;\n/*</replacement>*/\n\nWritable.WritableState = WritableState;\n\n/*<replacement>*/\nvar util = Object.create(__webpack_require__(/*! core-util-is */ \"../core-util-is/lib/util.js\"));\nutil.inherits = __webpack_require__(/*! inherits */ \"../inherits/inherits_browser.js\");\n/*</replacement>*/\n\n/*<replacement>*/\nvar internalUtil = {\n deprecate: __webpack_require__(/*! util-deprecate */ \"../util-deprecate/browser.js\")\n};\n/*</replacement>*/\n\n/*<replacement>*/\nvar Stream = __webpack_require__(/*! ./internal/streams/stream */ \"../readable-stream/lib/internal/streams/stream-browser.js\");\n/*</replacement>*/\n\n/*<replacement>*/\n\nvar Buffer = __webpack_require__(/*! safe-buffer */ \"../readable-stream/node_modules/safe-buffer/index.js\").Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/*</replacement>*/\n\nvar destroyImpl = __webpack_require__(/*! ./internal/streams/destroy */ \"../readable-stream/lib/internal/streams/destroy.js\");\n\nutil.inherits(Writable, Stream);\n\nfunction nop() {}\n\nfunction WritableState(options, stream) {\n Duplex = Duplex || __webpack_require__(/*! ./_stream_duplex */ \"../readable-stream/lib/_stream_duplex.js\");\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag to indicate whether or not this stream\n // contains buffers or objects.\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;\n\n // the point at which write() starts returning false\n // Note: 0 is a valid value, means that we always return false if\n // the entire buffer is not flushed immediately on write()\n var hwm = options.highWaterMark;\n var writableHwm = options.writableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // if _final has been called\n this.finalCalled = false;\n\n // drain event flag.\n this.needDrain = false;\n // at the start of calling end()\n this.ending = false;\n // when end() has been called, and returned\n this.ended = false;\n // when 'finish' is emitted\n this.finished = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // should we decode strings into buffers before passing to _write?\n // this is here so that some node-core streams can optimize string\n // handling at a lower level.\n var noDecode = options.decodeStrings === false;\n this.decodeStrings = !noDecode;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // not an actual buffer we keep track of, but a measurement\n // of how much we're waiting to get pushed to some underlying\n // socket or file.\n this.length = 0;\n\n // a flag to see when we're in the middle of a write.\n this.writing = false;\n\n // when true all writes will be buffered until .uncork() call\n this.corked = 0;\n\n // a flag to be able to tell if the onwrite cb is called immediately,\n // or on a later tick. We set this to true at first, because any\n // actions that shouldn't happen until \"later\" should generally also\n // not happen before the first write call.\n this.sync = true;\n\n // a flag to know if we're processing previously buffered items, which\n // may call the _write() callback in the same tick, so that we don't\n // end up in an overlapped onwrite situation.\n this.bufferProcessing = false;\n\n // the callback that's passed to _write(chunk,cb)\n this.onwrite = function (er) {\n onwrite(stream, er);\n };\n\n // the callback that the user supplies to write(chunk,encoding,cb)\n this.writecb = null;\n\n // the amount that is being written when _write is called.\n this.writelen = 0;\n\n this.bufferedRequest = null;\n this.lastBufferedRequest = null;\n\n // number of pending user-supplied write callbacks\n // this must be 0 before 'finish' can be emitted\n this.pendingcb = 0;\n\n // emit prefinish if the only thing we're waiting for is _write cbs\n // This is relevant for synchronous Transform streams\n this.prefinished = false;\n\n // True if the error was already emitted and should not be thrown again\n this.errorEmitted = false;\n\n // count buffered requests\n this.bufferedRequestCount = 0;\n\n // allocate the first CorkedRequest, there is always\n // one allocated and free to use, and we maintain at most two\n this.corkedRequestsFree = new CorkedRequest(this);\n}\n\nWritableState.prototype.getBuffer = function getBuffer() {\n var current = this.bufferedRequest;\n var out = [];\n while (current) {\n out.push(current);\n current = current.next;\n }\n return out;\n};\n\n(function () {\n try {\n Object.defineProperty(WritableState.prototype, 'buffer', {\n get: internalUtil.deprecate(function () {\n return this.getBuffer();\n }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')\n });\n } catch (_) {}\n})();\n\n// Test _writableState for inheritance to account for Duplex streams,\n// whose prototype chain only points to Readable.\nvar realHasInstance;\nif (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {\n realHasInstance = Function.prototype[Symbol.hasInstance];\n Object.defineProperty(Writable, Symbol.hasInstance, {\n value: function (object) {\n if (realHasInstance.call(this, object)) return true;\n if (this !== Writable) return false;\n\n return object && object._writableState instanceof WritableState;\n }\n });\n} else {\n realHasInstance = function (object) {\n return object instanceof this;\n };\n}\n\nfunction Writable(options) {\n Duplex = Duplex || __webpack_require__(/*! ./_stream_duplex */ \"../readable-stream/lib/_stream_duplex.js\");\n\n // Writable ctor is applied to Duplexes, too.\n // `realHasInstance` is necessary because using plain `instanceof`\n // would return false, as no `_writableState` property is attached.\n\n // Trying to use the custom `instanceof` for Writable here will also break the\n // Node.js LazyTransform implementation, which has a non-trivial getter for\n // `_writableState` that would lead to infinite recursion.\n if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {\n return new Writable(options);\n }\n\n this._writableState = new WritableState(options, this);\n\n // legacy.\n this.writable = true;\n\n if (options) {\n if (typeof options.write === 'function') this._write = options.write;\n\n if (typeof options.writev === 'function') this._writev = options.writev;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n\n if (typeof options.final === 'function') this._final = options.final;\n }\n\n Stream.call(this);\n}\n\n// Otherwise people can pipe Writable streams, which is just wrong.\nWritable.prototype.pipe = function () {\n this.emit('error', new Error('Cannot pipe, not readable'));\n};\n\nfunction writeAfterEnd(stream, cb) {\n var er = new Error('write after end');\n // TODO: defer error events consistently everywhere, not just the cb\n stream.emit('error', er);\n pna.nextTick(cb, er);\n}\n\n// Checks that a user-supplied chunk is valid, especially for the particular\n// mode the stream is in. Currently this means that `null` is never accepted\n// and undefined/non-string values are only allowed in object mode.\nfunction validChunk(stream, state, chunk, cb) {\n var valid = true;\n var er = false;\n\n if (chunk === null) {\n er = new TypeError('May not write null values to stream');\n } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n if (er) {\n stream.emit('error', er);\n pna.nextTick(cb, er);\n valid = false;\n }\n return valid;\n}\n\nWritable.prototype.write = function (chunk, encoding, cb) {\n var state = this._writableState;\n var ret = false;\n var isBuf = !state.objectMode && _isUint8Array(chunk);\n\n if (isBuf && !Buffer.isBuffer(chunk)) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;\n\n if (typeof cb !== 'function') cb = nop;\n\n if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {\n state.pendingcb++;\n ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);\n }\n\n return ret;\n};\n\nWritable.prototype.cork = function () {\n var state = this._writableState;\n\n state.corked++;\n};\n\nWritable.prototype.uncork = function () {\n var state = this._writableState;\n\n if (state.corked) {\n state.corked--;\n\n if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);\n }\n};\n\nWritable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {\n // node::ParseEncoding() requires lower case.\n if (typeof encoding === 'string') encoding = encoding.toLowerCase();\n if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);\n this._writableState.defaultEncoding = encoding;\n return this;\n};\n\nfunction decodeChunk(state, chunk, encoding) {\n if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {\n chunk = Buffer.from(chunk, encoding);\n }\n return chunk;\n}\n\nObject.defineProperty(Writable.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// if we're already writing something, then just put this\n// in the queue, and wait our turn. Otherwise, call _write\n// If we return false, then we need a drain event, so set that flag.\nfunction writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {\n if (!isBuf) {\n var newChunk = decodeChunk(state, chunk, encoding);\n if (chunk !== newChunk) {\n isBuf = true;\n encoding = 'buffer';\n chunk = newChunk;\n }\n }\n var len = state.objectMode ? 1 : chunk.length;\n\n state.length += len;\n\n var ret = state.length < state.highWaterMark;\n // we must ensure that previous needDrain will not be reset to false.\n if (!ret) state.needDrain = true;\n\n if (state.writing || state.corked) {\n var last = state.lastBufferedRequest;\n state.lastBufferedRequest = {\n chunk: chunk,\n encoding: encoding,\n isBuf: isBuf,\n callback: cb,\n next: null\n };\n if (last) {\n last.next = state.lastBufferedRequest;\n } else {\n state.bufferedRequest = state.lastBufferedRequest;\n }\n state.bufferedRequestCount += 1;\n } else {\n doWrite(stream, state, false, len, chunk, encoding, cb);\n }\n\n return ret;\n}\n\nfunction doWrite(stream, state, writev, len, chunk, encoding, cb) {\n state.writelen = len;\n state.writecb = cb;\n state.writing = true;\n state.sync = true;\n if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);\n state.sync = false;\n}\n\nfunction onwriteError(stream, state, sync, er, cb) {\n --state.pendingcb;\n\n if (sync) {\n // defer the callback if we are being called synchronously\n // to avoid piling up things on the stack\n pna.nextTick(cb, er);\n // this can emit finish, and it will always happen\n // after error\n pna.nextTick(finishMaybe, stream, state);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n } else {\n // the caller expect this to happen before if\n // it is async\n cb(er);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n // this can emit finish, but finish must\n // always follow error\n finishMaybe(stream, state);\n }\n}\n\nfunction onwriteStateUpdate(state) {\n state.writing = false;\n state.writecb = null;\n state.length -= state.writelen;\n state.writelen = 0;\n}\n\nfunction onwrite(stream, er) {\n var state = stream._writableState;\n var sync = state.sync;\n var cb = state.writecb;\n\n onwriteStateUpdate(state);\n\n if (er) onwriteError(stream, state, sync, er, cb);else {\n // Check if we're actually ready to finish, but don't emit yet\n var finished = needFinish(state);\n\n if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {\n clearBuffer(stream, state);\n }\n\n if (sync) {\n /*<replacement>*/\n asyncWrite(afterWrite, stream, state, finished, cb);\n /*</replacement>*/\n } else {\n afterWrite(stream, state, finished, cb);\n }\n }\n}\n\nfunction afterWrite(stream, state, finished, cb) {\n if (!finished) onwriteDrain(stream, state);\n state.pendingcb--;\n cb();\n finishMaybe(stream, state);\n}\n\n// Must force callback to be called on nextTick, so that we don't\n// emit 'drain' before the write() consumer gets the 'false' return\n// value, and has a chance to attach a 'drain' listener.\nfunction onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n}\n\n// if there's something in the buffer waiting, then process it\nfunction clearBuffer(stream, state) {\n state.bufferProcessing = true;\n var entry = state.bufferedRequest;\n\n if (stream._writev && entry && entry.next) {\n // Fast case, write everything using _writev()\n var l = state.bufferedRequestCount;\n var buffer = new Array(l);\n var holder = state.corkedRequestsFree;\n holder.entry = entry;\n\n var count = 0;\n var allBuffers = true;\n while (entry) {\n buffer[count] = entry;\n if (!entry.isBuf) allBuffers = false;\n entry = entry.next;\n count += 1;\n }\n buffer.allBuffers = allBuffers;\n\n doWrite(stream, state, true, state.length, buffer, '', holder.finish);\n\n // doWrite is almost always async, defer these to save a bit of time\n // as the hot path ends with doWrite\n state.pendingcb++;\n state.lastBufferedRequest = null;\n if (holder.next) {\n state.corkedRequestsFree = holder.next;\n holder.next = null;\n } else {\n state.corkedRequestsFree = new CorkedRequest(state);\n }\n state.bufferedRequestCount = 0;\n } else {\n // Slow case, write chunks one-by-one\n while (entry) {\n var chunk = entry.chunk;\n var encoding = entry.encoding;\n var cb = entry.callback;\n var len = state.objectMode ? 1 : chunk.length;\n\n doWrite(stream, state, false, len, chunk, encoding, cb);\n entry = entry.next;\n state.bufferedRequestCount--;\n // if we didn't call the onwrite immediately, then\n // it means that we need to wait until it does.\n // also, that means that the chunk and cb are currently\n // being processed, so move the buffer counter past them.\n if (state.writing) {\n break;\n }\n }\n\n if (entry === null) state.lastBufferedRequest = null;\n }\n\n state.bufferedRequest = entry;\n state.bufferProcessing = false;\n}\n\nWritable.prototype._write = function (chunk, encoding, cb) {\n cb(new Error('_write() is not implemented'));\n};\n\nWritable.prototype._writev = null;\n\nWritable.prototype.end = function (chunk, encoding, cb) {\n var state = this._writableState;\n\n if (typeof chunk === 'function') {\n cb = chunk;\n chunk = null;\n encoding = null;\n } else if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);\n\n // .end() fully uncorks\n if (state.corked) {\n state.corked = 1;\n this.uncork();\n }\n\n // ignore unnecessary end() calls.\n if (!state.ending && !state.finished) endWritable(this, state, cb);\n};\n\nfunction needFinish(state) {\n return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;\n}\nfunction callFinal(stream, state) {\n stream._final(function (err) {\n state.pendingcb--;\n if (err) {\n stream.emit('error', err);\n }\n state.prefinished = true;\n stream.emit('prefinish');\n finishMaybe(stream, state);\n });\n}\nfunction prefinish(stream, state) {\n if (!state.prefinished && !state.finalCalled) {\n if (typeof stream._final === 'function') {\n state.pendingcb++;\n state.finalCalled = true;\n pna.nextTick(callFinal, stream, state);\n } else {\n state.prefinished = true;\n stream.emit('prefinish');\n }\n }\n}\n\nfunction finishMaybe(stream, state) {\n var need = needFinish(state);\n if (need) {\n prefinish(stream, state);\n if (state.pendingcb === 0) {\n state.finished = true;\n stream.emit('finish');\n }\n }\n return need;\n}\n\nfunction endWritable(stream, state, cb) {\n state.ending = true;\n finishMaybe(stream, state);\n if (cb) {\n if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);\n }\n state.ended = true;\n stream.writable = false;\n}\n\nfunction onCorkedFinish(corkReq, state, err) {\n var entry = corkReq.entry;\n corkReq.entry = null;\n while (entry) {\n var cb = entry.callback;\n state.pendingcb--;\n cb(err);\n entry = entry.next;\n }\n if (state.corkedRequestsFree) {\n state.corkedRequestsFree.next = corkReq;\n } else {\n state.corkedRequestsFree = corkReq;\n }\n}\n\nObject.defineProperty(Writable.prototype, 'destroyed', {\n get: function () {\n if (this._writableState === undefined) {\n return false;\n }\n return this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._writableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._writableState.destroyed = value;\n }\n});\n\nWritable.prototype.destroy = destroyImpl.destroy;\nWritable.prototype._undestroy = destroyImpl.undestroy;\nWritable.prototype._destroy = function (err, cb) {\n this.end();\n cb(err);\n};\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ \"../process/browser.js\"), __webpack_require__(/*! ./../../timers-browserify/main.js */ \"../timers-browserify/main.js\").setImmediate, __webpack_require__(/*! ./../../webpack/buildin/global.js */ \"../webpack/buildin/global.js\")))\n\n//# sourceURL=webpack://ardplayer/../readable-stream/lib/_stream_writable.js?");
|
|
262
|
-
|
|
263
|
-
/***/ }),
|
|
264
|
-
|
|
265
|
-
/***/ "../readable-stream/lib/internal/streams/BufferList.js":
|
|
266
|
-
/*!*************************************************************!*\
|
|
267
|
-
!*** ../readable-stream/lib/internal/streams/BufferList.js ***!
|
|
268
|
-
\*************************************************************/
|
|
269
|
-
/*! no static exports found */
|
|
270
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
271
|
-
|
|
272
|
-
"use strict";
|
|
273
|
-
eval("\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar Buffer = __webpack_require__(/*! safe-buffer */ \"../readable-stream/node_modules/safe-buffer/index.js\").Buffer;\nvar util = __webpack_require__(/*! util */ 2);\n\nfunction copyBuffer(src, target, offset) {\n src.copy(target, offset);\n}\n\nmodule.exports = function () {\n function BufferList() {\n _classCallCheck(this, BufferList);\n\n this.head = null;\n this.tail = null;\n this.length = 0;\n }\n\n BufferList.prototype.push = function push(v) {\n var entry = { data: v, next: null };\n if (this.length > 0) this.tail.next = entry;else this.head = entry;\n this.tail = entry;\n ++this.length;\n };\n\n BufferList.prototype.unshift = function unshift(v) {\n var entry = { data: v, next: this.head };\n if (this.length === 0) this.tail = entry;\n this.head = entry;\n ++this.length;\n };\n\n BufferList.prototype.shift = function shift() {\n if (this.length === 0) return;\n var ret = this.head.data;\n if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;\n --this.length;\n return ret;\n };\n\n BufferList.prototype.clear = function clear() {\n this.head = this.tail = null;\n this.length = 0;\n };\n\n BufferList.prototype.join = function join(s) {\n if (this.length === 0) return '';\n var p = this.head;\n var ret = '' + p.data;\n while (p = p.next) {\n ret += s + p.data;\n }return ret;\n };\n\n BufferList.prototype.concat = function concat(n) {\n if (this.length === 0) return Buffer.alloc(0);\n if (this.length === 1) return this.head.data;\n var ret = Buffer.allocUnsafe(n >>> 0);\n var p = this.head;\n var i = 0;\n while (p) {\n copyBuffer(p.data, ret, i);\n i += p.data.length;\n p = p.next;\n }\n return ret;\n };\n\n return BufferList;\n}();\n\nif (util && util.inspect && util.inspect.custom) {\n module.exports.prototype[util.inspect.custom] = function () {\n var obj = util.inspect({ length: this.length });\n return this.constructor.name + ' ' + obj;\n };\n}\n\n//# sourceURL=webpack://ardplayer/../readable-stream/lib/internal/streams/BufferList.js?");
|
|
274
|
-
|
|
275
|
-
/***/ }),
|
|
276
|
-
|
|
277
|
-
/***/ "../readable-stream/lib/internal/streams/destroy.js":
|
|
278
|
-
/*!**********************************************************!*\
|
|
279
|
-
!*** ../readable-stream/lib/internal/streams/destroy.js ***!
|
|
280
|
-
\**********************************************************/
|
|
281
|
-
/*! no static exports found */
|
|
282
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
283
|
-
|
|
284
|
-
"use strict";
|
|
285
|
-
eval("\n\n/*<replacement>*/\n\nvar pna = __webpack_require__(/*! process-nextick-args */ \"../process-nextick-args/index.js\");\n/*</replacement>*/\n\n// undocumented cb() API, needed for core, not for public API\nfunction destroy(err, cb) {\n var _this = this;\n\n var readableDestroyed = this._readableState && this._readableState.destroyed;\n var writableDestroyed = this._writableState && this._writableState.destroyed;\n\n if (readableDestroyed || writableDestroyed) {\n if (cb) {\n cb(err);\n } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {\n pna.nextTick(emitErrorNT, this, err);\n }\n return this;\n }\n\n // we set destroyed to true before firing error callbacks in order\n // to make it re-entrance safe in case destroy() is called within callbacks\n\n if (this._readableState) {\n this._readableState.destroyed = true;\n }\n\n // if this is a duplex stream mark the writable part as destroyed as well\n if (this._writableState) {\n this._writableState.destroyed = true;\n }\n\n this._destroy(err || null, function (err) {\n if (!cb && err) {\n pna.nextTick(emitErrorNT, _this, err);\n if (_this._writableState) {\n _this._writableState.errorEmitted = true;\n }\n } else if (cb) {\n cb(err);\n }\n });\n\n return this;\n}\n\nfunction undestroy() {\n if (this._readableState) {\n this._readableState.destroyed = false;\n this._readableState.reading = false;\n this._readableState.ended = false;\n this._readableState.endEmitted = false;\n }\n\n if (this._writableState) {\n this._writableState.destroyed = false;\n this._writableState.ended = false;\n this._writableState.ending = false;\n this._writableState.finished = false;\n this._writableState.errorEmitted = false;\n }\n}\n\nfunction emitErrorNT(self, err) {\n self.emit('error', err);\n}\n\nmodule.exports = {\n destroy: destroy,\n undestroy: undestroy\n};\n\n//# sourceURL=webpack://ardplayer/../readable-stream/lib/internal/streams/destroy.js?");
|
|
286
|
-
|
|
287
|
-
/***/ }),
|
|
288
|
-
|
|
289
|
-
/***/ "../readable-stream/lib/internal/streams/stream-browser.js":
|
|
290
|
-
/*!*****************************************************************!*\
|
|
291
|
-
!*** ../readable-stream/lib/internal/streams/stream-browser.js ***!
|
|
292
|
-
\*****************************************************************/
|
|
293
|
-
/*! no static exports found */
|
|
294
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
295
|
-
|
|
296
|
-
eval("module.exports = __webpack_require__(/*! events */ \"../events/events.js\").EventEmitter;\n\n\n//# sourceURL=webpack://ardplayer/../readable-stream/lib/internal/streams/stream-browser.js?");
|
|
297
|
-
|
|
298
|
-
/***/ }),
|
|
299
|
-
|
|
300
|
-
/***/ "../readable-stream/node_modules/safe-buffer/index.js":
|
|
301
|
-
/*!************************************************************!*\
|
|
302
|
-
!*** ../readable-stream/node_modules/safe-buffer/index.js ***!
|
|
303
|
-
\************************************************************/
|
|
304
|
-
/*! no static exports found */
|
|
305
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
306
|
-
|
|
307
|
-
eval("/* eslint-disable node/no-deprecated-api */\nvar buffer = __webpack_require__(/*! buffer */ \"../buffer/index.js\")\nvar Buffer = buffer.Buffer\n\n// alternative to using Object.keys for old browsers\nfunction copyProps (src, dst) {\n for (var key in src) {\n dst[key] = src[key]\n }\n}\nif (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {\n module.exports = buffer\n} else {\n // Copy properties from require('buffer')\n copyProps(buffer, exports)\n exports.Buffer = SafeBuffer\n}\n\nfunction SafeBuffer (arg, encodingOrOffset, length) {\n return Buffer(arg, encodingOrOffset, length)\n}\n\n// Copy static methods from Buffer\ncopyProps(Buffer, SafeBuffer)\n\nSafeBuffer.from = function (arg, encodingOrOffset, length) {\n if (typeof arg === 'number') {\n throw new TypeError('Argument must not be a number')\n }\n return Buffer(arg, encodingOrOffset, length)\n}\n\nSafeBuffer.alloc = function (size, fill, encoding) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n var buf = Buffer(size)\n if (fill !== undefined) {\n if (typeof encoding === 'string') {\n buf.fill(fill, encoding)\n } else {\n buf.fill(fill)\n }\n } else {\n buf.fill(0)\n }\n return buf\n}\n\nSafeBuffer.allocUnsafe = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return Buffer(size)\n}\n\nSafeBuffer.allocUnsafeSlow = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return buffer.SlowBuffer(size)\n}\n\n\n//# sourceURL=webpack://ardplayer/../readable-stream/node_modules/safe-buffer/index.js?");
|
|
308
|
-
|
|
309
|
-
/***/ }),
|
|
310
|
-
|
|
311
|
-
/***/ "../readable-stream/passthrough.js":
|
|
312
|
-
/*!*****************************************!*\
|
|
313
|
-
!*** ../readable-stream/passthrough.js ***!
|
|
314
|
-
\*****************************************/
|
|
315
|
-
/*! no static exports found */
|
|
316
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
317
|
-
|
|
318
|
-
eval("module.exports = __webpack_require__(/*! ./readable */ \"../readable-stream/readable-browser.js\").PassThrough\n\n\n//# sourceURL=webpack://ardplayer/../readable-stream/passthrough.js?");
|
|
319
|
-
|
|
320
|
-
/***/ }),
|
|
321
|
-
|
|
322
|
-
/***/ "../readable-stream/readable-browser.js":
|
|
323
|
-
/*!**********************************************!*\
|
|
324
|
-
!*** ../readable-stream/readable-browser.js ***!
|
|
325
|
-
\**********************************************/
|
|
326
|
-
/*! no static exports found */
|
|
327
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
328
|
-
|
|
329
|
-
eval("exports = module.exports = __webpack_require__(/*! ./lib/_stream_readable.js */ \"../readable-stream/lib/_stream_readable.js\");\nexports.Stream = exports;\nexports.Readable = exports;\nexports.Writable = __webpack_require__(/*! ./lib/_stream_writable.js */ \"../readable-stream/lib/_stream_writable.js\");\nexports.Duplex = __webpack_require__(/*! ./lib/_stream_duplex.js */ \"../readable-stream/lib/_stream_duplex.js\");\nexports.Transform = __webpack_require__(/*! ./lib/_stream_transform.js */ \"../readable-stream/lib/_stream_transform.js\");\nexports.PassThrough = __webpack_require__(/*! ./lib/_stream_passthrough.js */ \"../readable-stream/lib/_stream_passthrough.js\");\n\n\n//# sourceURL=webpack://ardplayer/../readable-stream/readable-browser.js?");
|
|
330
|
-
|
|
331
|
-
/***/ }),
|
|
332
|
-
|
|
333
|
-
/***/ "../readable-stream/transform.js":
|
|
334
|
-
/*!***************************************!*\
|
|
335
|
-
!*** ../readable-stream/transform.js ***!
|
|
336
|
-
\***************************************/
|
|
337
|
-
/*! no static exports found */
|
|
338
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
339
|
-
|
|
340
|
-
eval("module.exports = __webpack_require__(/*! ./readable */ \"../readable-stream/readable-browser.js\").Transform\n\n\n//# sourceURL=webpack://ardplayer/../readable-stream/transform.js?");
|
|
341
|
-
|
|
342
|
-
/***/ }),
|
|
343
|
-
|
|
344
|
-
/***/ "../readable-stream/writable-browser.js":
|
|
345
|
-
/*!**********************************************!*\
|
|
346
|
-
!*** ../readable-stream/writable-browser.js ***!
|
|
347
|
-
\**********************************************/
|
|
348
|
-
/*! no static exports found */
|
|
349
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
350
|
-
|
|
351
|
-
eval("module.exports = __webpack_require__(/*! ./lib/_stream_writable.js */ \"../readable-stream/lib/_stream_writable.js\");\n\n\n//# sourceURL=webpack://ardplayer/../readable-stream/writable-browser.js?");
|
|
352
|
-
|
|
353
|
-
/***/ }),
|
|
354
|
-
|
|
355
|
-
/***/ "../safe-buffer/index.js":
|
|
356
|
-
/*!*******************************!*\
|
|
357
|
-
!*** ../safe-buffer/index.js ***!
|
|
358
|
-
\*******************************/
|
|
359
|
-
/*! no static exports found */
|
|
360
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
361
|
-
|
|
362
|
-
eval("/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */\n/* eslint-disable node/no-deprecated-api */\nvar buffer = __webpack_require__(/*! buffer */ \"../buffer/index.js\")\nvar Buffer = buffer.Buffer\n\n// alternative to using Object.keys for old browsers\nfunction copyProps (src, dst) {\n for (var key in src) {\n dst[key] = src[key]\n }\n}\nif (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {\n module.exports = buffer\n} else {\n // Copy properties from require('buffer')\n copyProps(buffer, exports)\n exports.Buffer = SafeBuffer\n}\n\nfunction SafeBuffer (arg, encodingOrOffset, length) {\n return Buffer(arg, encodingOrOffset, length)\n}\n\nSafeBuffer.prototype = Object.create(Buffer.prototype)\n\n// Copy static methods from Buffer\ncopyProps(Buffer, SafeBuffer)\n\nSafeBuffer.from = function (arg, encodingOrOffset, length) {\n if (typeof arg === 'number') {\n throw new TypeError('Argument must not be a number')\n }\n return Buffer(arg, encodingOrOffset, length)\n}\n\nSafeBuffer.alloc = function (size, fill, encoding) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n var buf = Buffer(size)\n if (fill !== undefined) {\n if (typeof encoding === 'string') {\n buf.fill(fill, encoding)\n } else {\n buf.fill(fill)\n }\n } else {\n buf.fill(0)\n }\n return buf\n}\n\nSafeBuffer.allocUnsafe = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return Buffer(size)\n}\n\nSafeBuffer.allocUnsafeSlow = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return buffer.SlowBuffer(size)\n}\n\n\n//# sourceURL=webpack://ardplayer/../safe-buffer/index.js?");
|
|
363
|
-
|
|
364
|
-
/***/ }),
|
|
365
|
-
|
|
366
|
-
/***/ "../setimmediate/setImmediate.js":
|
|
367
|
-
/*!***************************************!*\
|
|
368
|
-
!*** ../setimmediate/setImmediate.js ***!
|
|
369
|
-
\***************************************/
|
|
370
|
-
/*! no static exports found */
|
|
371
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
372
|
-
|
|
373
|
-
eval("/* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {\n \"use strict\";\n\n if (global.setImmediate) {\n return;\n }\n\n var nextHandle = 1; // Spec says greater than zero\n var tasksByHandle = {};\n var currentlyRunningATask = false;\n var doc = global.document;\n var registerImmediate;\n\n function setImmediate(callback) {\n // Callback can either be a function or a string\n if (typeof callback !== \"function\") {\n callback = new Function(\"\" + callback);\n }\n // Copy function arguments\n var args = new Array(arguments.length - 1);\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i + 1];\n }\n // Store and register the task\n var task = { callback: callback, args: args };\n tasksByHandle[nextHandle] = task;\n registerImmediate(nextHandle);\n return nextHandle++;\n }\n\n function clearImmediate(handle) {\n delete tasksByHandle[handle];\n }\n\n function run(task) {\n var callback = task.callback;\n var args = task.args;\n switch (args.length) {\n case 0:\n callback();\n break;\n case 1:\n callback(args[0]);\n break;\n case 2:\n callback(args[0], args[1]);\n break;\n case 3:\n callback(args[0], args[1], args[2]);\n break;\n default:\n callback.apply(undefined, args);\n break;\n }\n }\n\n function runIfPresent(handle) {\n // From the spec: \"Wait until any invocations of this algorithm started before this one have completed.\"\n // So if we're currently running a task, we'll need to delay this invocation.\n if (currentlyRunningATask) {\n // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a\n // \"too much recursion\" error.\n setTimeout(runIfPresent, 0, handle);\n } else {\n var task = tasksByHandle[handle];\n if (task) {\n currentlyRunningATask = true;\n try {\n run(task);\n } finally {\n clearImmediate(handle);\n currentlyRunningATask = false;\n }\n }\n }\n }\n\n function installNextTickImplementation() {\n registerImmediate = function(handle) {\n process.nextTick(function () { runIfPresent(handle); });\n };\n }\n\n function canUsePostMessage() {\n // The test against `importScripts` prevents this implementation from being installed inside a web worker,\n // where `global.postMessage` means something completely different and can't be used for this purpose.\n if (global.postMessage && !global.importScripts) {\n var postMessageIsAsynchronous = true;\n var oldOnMessage = global.onmessage;\n global.onmessage = function() {\n postMessageIsAsynchronous = false;\n };\n global.postMessage(\"\", \"*\");\n global.onmessage = oldOnMessage;\n return postMessageIsAsynchronous;\n }\n }\n\n function installPostMessageImplementation() {\n // Installs an event handler on `global` for the `message` event: see\n // * https://developer.mozilla.org/en/DOM/window.postMessage\n // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages\n\n var messagePrefix = \"setImmediate$\" + Math.random() + \"$\";\n var onGlobalMessage = function(event) {\n if (event.source === global &&\n typeof event.data === \"string\" &&\n event.data.indexOf(messagePrefix) === 0) {\n runIfPresent(+event.data.slice(messagePrefix.length));\n }\n };\n\n if (global.addEventListener) {\n global.addEventListener(\"message\", onGlobalMessage, false);\n } else {\n global.attachEvent(\"onmessage\", onGlobalMessage);\n }\n\n registerImmediate = function(handle) {\n global.postMessage(messagePrefix + handle, \"*\");\n };\n }\n\n function installMessageChannelImplementation() {\n var channel = new MessageChannel();\n channel.port1.onmessage = function(event) {\n var handle = event.data;\n runIfPresent(handle);\n };\n\n registerImmediate = function(handle) {\n channel.port2.postMessage(handle);\n };\n }\n\n function installReadyStateChangeImplementation() {\n var html = doc.documentElement;\n registerImmediate = function(handle) {\n // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted\n // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.\n var script = doc.createElement(\"script\");\n script.onreadystatechange = function () {\n runIfPresent(handle);\n script.onreadystatechange = null;\n html.removeChild(script);\n script = null;\n };\n html.appendChild(script);\n };\n }\n\n function installSetTimeoutImplementation() {\n registerImmediate = function(handle) {\n setTimeout(runIfPresent, 0, handle);\n };\n }\n\n // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.\n var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);\n attachTo = attachTo && attachTo.setTimeout ? attachTo : global;\n\n // Don't get fooled by e.g. browserify environments.\n if ({}.toString.call(global.process) === \"[object process]\") {\n // For Node.js before 0.9\n installNextTickImplementation();\n\n } else if (canUsePostMessage()) {\n // For non-IE10 modern browsers\n installPostMessageImplementation();\n\n } else if (global.MessageChannel) {\n // For web workers, where supported\n installMessageChannelImplementation();\n\n } else if (doc && \"onreadystatechange\" in doc.createElement(\"script\")) {\n // For IE 6–8\n installReadyStateChangeImplementation();\n\n } else {\n // For older browsers\n installSetTimeoutImplementation();\n }\n\n attachTo.setImmediate = setImmediate;\n attachTo.clearImmediate = clearImmediate;\n}(typeof self === \"undefined\" ? typeof global === \"undefined\" ? this : global : self));\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ \"../webpack/buildin/global.js\"), __webpack_require__(/*! ./../process/browser.js */ \"../process/browser.js\")))\n\n//# sourceURL=webpack://ardplayer/../setimmediate/setImmediate.js?");
|
|
374
|
-
|
|
375
|
-
/***/ }),
|
|
376
|
-
|
|
377
|
-
/***/ "../stream-browserify/index.js":
|
|
378
|
-
/*!*************************************!*\
|
|
379
|
-
!*** ../stream-browserify/index.js ***!
|
|
380
|
-
\*************************************/
|
|
381
|
-
/*! no static exports found */
|
|
382
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
383
|
-
|
|
384
|
-
eval("// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nmodule.exports = Stream;\n\nvar EE = __webpack_require__(/*! events */ \"../events/events.js\").EventEmitter;\nvar inherits = __webpack_require__(/*! inherits */ \"../inherits/inherits_browser.js\");\n\ninherits(Stream, EE);\nStream.Readable = __webpack_require__(/*! readable-stream/readable.js */ \"../readable-stream/readable-browser.js\");\nStream.Writable = __webpack_require__(/*! readable-stream/writable.js */ \"../readable-stream/writable-browser.js\");\nStream.Duplex = __webpack_require__(/*! readable-stream/duplex.js */ \"../readable-stream/duplex-browser.js\");\nStream.Transform = __webpack_require__(/*! readable-stream/transform.js */ \"../readable-stream/transform.js\");\nStream.PassThrough = __webpack_require__(/*! readable-stream/passthrough.js */ \"../readable-stream/passthrough.js\");\n\n// Backwards-compat with node 0.4.x\nStream.Stream = Stream;\n\n\n\n// old-style streams. Note that the pipe method (the only relevant\n// part of this class) is overridden in the Readable class.\n\nfunction Stream() {\n EE.call(this);\n}\n\nStream.prototype.pipe = function(dest, options) {\n var source = this;\n\n function ondata(chunk) {\n if (dest.writable) {\n if (false === dest.write(chunk) && source.pause) {\n source.pause();\n }\n }\n }\n\n source.on('data', ondata);\n\n function ondrain() {\n if (source.readable && source.resume) {\n source.resume();\n }\n }\n\n dest.on('drain', ondrain);\n\n // If the 'end' option is not supplied, dest.end() will be called when\n // source gets the 'end' or 'close' events. Only dest.end() once.\n if (!dest._isStdio && (!options || options.end !== false)) {\n source.on('end', onend);\n source.on('close', onclose);\n }\n\n var didOnEnd = false;\n function onend() {\n if (didOnEnd) return;\n didOnEnd = true;\n\n dest.end();\n }\n\n\n function onclose() {\n if (didOnEnd) return;\n didOnEnd = true;\n\n if (typeof dest.destroy === 'function') dest.destroy();\n }\n\n // don't leave dangling pipes when there are errors.\n function onerror(er) {\n cleanup();\n if (EE.listenerCount(this, 'error') === 0) {\n throw er; // Unhandled stream error in pipe.\n }\n }\n\n source.on('error', onerror);\n dest.on('error', onerror);\n\n // remove all the event listeners that were added.\n function cleanup() {\n source.removeListener('data', ondata);\n dest.removeListener('drain', ondrain);\n\n source.removeListener('end', onend);\n source.removeListener('close', onclose);\n\n source.removeListener('error', onerror);\n dest.removeListener('error', onerror);\n\n source.removeListener('end', cleanup);\n source.removeListener('close', cleanup);\n\n dest.removeListener('close', cleanup);\n }\n\n source.on('end', cleanup);\n source.on('close', cleanup);\n\n dest.on('close', cleanup);\n\n dest.emit('pipe', source);\n\n // Allow for unix-like usage: A.pipe(B).pipe(C)\n return dest;\n};\n\n\n//# sourceURL=webpack://ardplayer/../stream-browserify/index.js?");
|
|
385
|
-
|
|
386
|
-
/***/ }),
|
|
387
|
-
|
|
388
|
-
/***/ "../string_decoder/lib/string_decoder.js":
|
|
389
|
-
/*!***********************************************!*\
|
|
390
|
-
!*** ../string_decoder/lib/string_decoder.js ***!
|
|
391
|
-
\***********************************************/
|
|
392
|
-
/*! no static exports found */
|
|
393
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
394
|
-
|
|
395
|
-
"use strict";
|
|
396
|
-
eval("// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\n\n/*<replacement>*/\n\nvar Buffer = __webpack_require__(/*! safe-buffer */ \"../safe-buffer/index.js\").Buffer;\n/*</replacement>*/\n\nvar isEncoding = Buffer.isEncoding || function (encoding) {\n encoding = '' + encoding;\n switch (encoding && encoding.toLowerCase()) {\n case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':\n return true;\n default:\n return false;\n }\n};\n\nfunction _normalizeEncoding(enc) {\n if (!enc) return 'utf8';\n var retried;\n while (true) {\n switch (enc) {\n case 'utf8':\n case 'utf-8':\n return 'utf8';\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return 'utf16le';\n case 'latin1':\n case 'binary':\n return 'latin1';\n case 'base64':\n case 'ascii':\n case 'hex':\n return enc;\n default:\n if (retried) return; // undefined\n enc = ('' + enc).toLowerCase();\n retried = true;\n }\n }\n};\n\n// Do not cache `Buffer.isEncoding` when checking encoding names as some\n// modules monkey-patch it to support additional encodings\nfunction normalizeEncoding(enc) {\n var nenc = _normalizeEncoding(enc);\n if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);\n return nenc || enc;\n}\n\n// StringDecoder provides an interface for efficiently splitting a series of\n// buffers into a series of JS strings without breaking apart multi-byte\n// characters.\nexports.StringDecoder = StringDecoder;\nfunction StringDecoder(encoding) {\n this.encoding = normalizeEncoding(encoding);\n var nb;\n switch (this.encoding) {\n case 'utf16le':\n this.text = utf16Text;\n this.end = utf16End;\n nb = 4;\n break;\n case 'utf8':\n this.fillLast = utf8FillLast;\n nb = 4;\n break;\n case 'base64':\n this.text = base64Text;\n this.end = base64End;\n nb = 3;\n break;\n default:\n this.write = simpleWrite;\n this.end = simpleEnd;\n return;\n }\n this.lastNeed = 0;\n this.lastTotal = 0;\n this.lastChar = Buffer.allocUnsafe(nb);\n}\n\nStringDecoder.prototype.write = function (buf) {\n if (buf.length === 0) return '';\n var r;\n var i;\n if (this.lastNeed) {\n r = this.fillLast(buf);\n if (r === undefined) return '';\n i = this.lastNeed;\n this.lastNeed = 0;\n } else {\n i = 0;\n }\n if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);\n return r || '';\n};\n\nStringDecoder.prototype.end = utf8End;\n\n// Returns only complete characters in a Buffer\nStringDecoder.prototype.text = utf8Text;\n\n// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer\nStringDecoder.prototype.fillLast = function (buf) {\n if (this.lastNeed <= buf.length) {\n buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);\n return this.lastChar.toString(this.encoding, 0, this.lastTotal);\n }\n buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);\n this.lastNeed -= buf.length;\n};\n\n// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a\n// continuation byte. If an invalid byte is detected, -2 is returned.\nfunction utf8CheckByte(byte) {\n if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;\n return byte >> 6 === 0x02 ? -1 : -2;\n}\n\n// Checks at most 3 bytes at the end of a Buffer in order to detect an\n// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)\n// needed to complete the UTF-8 character (if applicable) are returned.\nfunction utf8CheckIncomplete(self, buf, i) {\n var j = buf.length - 1;\n if (j < i) return 0;\n var nb = utf8CheckByte(buf[j]);\n if (nb >= 0) {\n if (nb > 0) self.lastNeed = nb - 1;\n return nb;\n }\n if (--j < i || nb === -2) return 0;\n nb = utf8CheckByte(buf[j]);\n if (nb >= 0) {\n if (nb > 0) self.lastNeed = nb - 2;\n return nb;\n }\n if (--j < i || nb === -2) return 0;\n nb = utf8CheckByte(buf[j]);\n if (nb >= 0) {\n if (nb > 0) {\n if (nb === 2) nb = 0;else self.lastNeed = nb - 3;\n }\n return nb;\n }\n return 0;\n}\n\n// Validates as many continuation bytes for a multi-byte UTF-8 character as\n// needed or are available. If we see a non-continuation byte where we expect\n// one, we \"replace\" the validated continuation bytes we've seen so far with\n// a single UTF-8 replacement character ('\\ufffd'), to match v8's UTF-8 decoding\n// behavior. The continuation byte check is included three times in the case\n// where all of the continuation bytes for a character exist in the same buffer.\n// It is also done this way as a slight performance increase instead of using a\n// loop.\nfunction utf8CheckExtraBytes(self, buf, p) {\n if ((buf[0] & 0xC0) !== 0x80) {\n self.lastNeed = 0;\n return '\\ufffd';\n }\n if (self.lastNeed > 1 && buf.length > 1) {\n if ((buf[1] & 0xC0) !== 0x80) {\n self.lastNeed = 1;\n return '\\ufffd';\n }\n if (self.lastNeed > 2 && buf.length > 2) {\n if ((buf[2] & 0xC0) !== 0x80) {\n self.lastNeed = 2;\n return '\\ufffd';\n }\n }\n }\n}\n\n// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.\nfunction utf8FillLast(buf) {\n var p = this.lastTotal - this.lastNeed;\n var r = utf8CheckExtraBytes(this, buf, p);\n if (r !== undefined) return r;\n if (this.lastNeed <= buf.length) {\n buf.copy(this.lastChar, p, 0, this.lastNeed);\n return this.lastChar.toString(this.encoding, 0, this.lastTotal);\n }\n buf.copy(this.lastChar, p, 0, buf.length);\n this.lastNeed -= buf.length;\n}\n\n// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a\n// partial character, the character's bytes are buffered until the required\n// number of bytes are available.\nfunction utf8Text(buf, i) {\n var total = utf8CheckIncomplete(this, buf, i);\n if (!this.lastNeed) return buf.toString('utf8', i);\n this.lastTotal = total;\n var end = buf.length - (total - this.lastNeed);\n buf.copy(this.lastChar, 0, end);\n return buf.toString('utf8', i, end);\n}\n\n// For UTF-8, a replacement character is added when ending on a partial\n// character.\nfunction utf8End(buf) {\n var r = buf && buf.length ? this.write(buf) : '';\n if (this.lastNeed) return r + '\\ufffd';\n return r;\n}\n\n// UTF-16LE typically needs two bytes per character, but even if we have an even\n// number of bytes available, we need to check if we end on a leading/high\n// surrogate. In that case, we need to wait for the next two bytes in order to\n// decode the last character properly.\nfunction utf16Text(buf, i) {\n if ((buf.length - i) % 2 === 0) {\n var r = buf.toString('utf16le', i);\n if (r) {\n var c = r.charCodeAt(r.length - 1);\n if (c >= 0xD800 && c <= 0xDBFF) {\n this.lastNeed = 2;\n this.lastTotal = 4;\n this.lastChar[0] = buf[buf.length - 2];\n this.lastChar[1] = buf[buf.length - 1];\n return r.slice(0, -1);\n }\n }\n return r;\n }\n this.lastNeed = 1;\n this.lastTotal = 2;\n this.lastChar[0] = buf[buf.length - 1];\n return buf.toString('utf16le', i, buf.length - 1);\n}\n\n// For UTF-16LE we do not explicitly append special replacement characters if we\n// end on a partial character, we simply let v8 handle that.\nfunction utf16End(buf) {\n var r = buf && buf.length ? this.write(buf) : '';\n if (this.lastNeed) {\n var end = this.lastTotal - this.lastNeed;\n return r + this.lastChar.toString('utf16le', 0, end);\n }\n return r;\n}\n\nfunction base64Text(buf, i) {\n var n = (buf.length - i) % 3;\n if (n === 0) return buf.toString('base64', i);\n this.lastNeed = 3 - n;\n this.lastTotal = 3;\n if (n === 1) {\n this.lastChar[0] = buf[buf.length - 1];\n } else {\n this.lastChar[0] = buf[buf.length - 2];\n this.lastChar[1] = buf[buf.length - 1];\n }\n return buf.toString('base64', i, buf.length - n);\n}\n\nfunction base64End(buf) {\n var r = buf && buf.length ? this.write(buf) : '';\n if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);\n return r;\n}\n\n// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)\nfunction simpleWrite(buf) {\n return buf.toString(this.encoding);\n}\n\nfunction simpleEnd(buf) {\n return buf && buf.length ? this.write(buf) : '';\n}\n\n//# sourceURL=webpack://ardplayer/../string_decoder/lib/string_decoder.js?");
|
|
397
|
-
|
|
398
|
-
/***/ }),
|
|
399
|
-
|
|
400
|
-
/***/ "../timers-browserify/main.js":
|
|
401
|
-
/*!************************************!*\
|
|
402
|
-
!*** ../timers-browserify/main.js ***!
|
|
403
|
-
\************************************/
|
|
404
|
-
/*! no static exports found */
|
|
405
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
406
|
-
|
|
407
|
-
eval("/* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== \"undefined\" && global) ||\n (typeof self !== \"undefined\" && self) ||\n window;\nvar apply = Function.prototype.apply;\n\n// DOM APIs, for completeness\n\nexports.setTimeout = function() {\n return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);\n};\nexports.setInterval = function() {\n return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);\n};\nexports.clearTimeout =\nexports.clearInterval = function(timeout) {\n if (timeout) {\n timeout.close();\n }\n};\n\nfunction Timeout(id, clearFn) {\n this._id = id;\n this._clearFn = clearFn;\n}\nTimeout.prototype.unref = Timeout.prototype.ref = function() {};\nTimeout.prototype.close = function() {\n this._clearFn.call(scope, this._id);\n};\n\n// Does not start the time, just sets up the members needed.\nexports.enroll = function(item, msecs) {\n clearTimeout(item._idleTimeoutId);\n item._idleTimeout = msecs;\n};\n\nexports.unenroll = function(item) {\n clearTimeout(item._idleTimeoutId);\n item._idleTimeout = -1;\n};\n\nexports._unrefActive = exports.active = function(item) {\n clearTimeout(item._idleTimeoutId);\n\n var msecs = item._idleTimeout;\n if (msecs >= 0) {\n item._idleTimeoutId = setTimeout(function onTimeout() {\n if (item._onTimeout)\n item._onTimeout();\n }, msecs);\n }\n};\n\n// setimmediate attaches itself to the global object\n__webpack_require__(/*! setimmediate */ \"../setimmediate/setImmediate.js\");\n// On some exotic environments, it's not clear which object `setimmediate` was\n// able to install onto. Search each possibility in the same order as the\n// `setimmediate` library.\nexports.setImmediate = (typeof self !== \"undefined\" && self.setImmediate) ||\n (typeof global !== \"undefined\" && global.setImmediate) ||\n (this && this.setImmediate);\nexports.clearImmediate = (typeof self !== \"undefined\" && self.clearImmediate) ||\n (typeof global !== \"undefined\" && global.clearImmediate) ||\n (this && this.clearImmediate);\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ \"../webpack/buildin/global.js\")))\n\n//# sourceURL=webpack://ardplayer/../timers-browserify/main.js?");
|
|
408
|
-
|
|
409
|
-
/***/ }),
|
|
410
|
-
|
|
411
|
-
/***/ "../util-deprecate/browser.js":
|
|
412
|
-
/*!************************************!*\
|
|
413
|
-
!*** ../util-deprecate/browser.js ***!
|
|
414
|
-
\************************************/
|
|
415
|
-
/*! no static exports found */
|
|
416
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
417
|
-
|
|
418
|
-
eval("/* WEBPACK VAR INJECTION */(function(global) {\n/**\n * Module exports.\n */\n\nmodule.exports = deprecate;\n\n/**\n * Mark that a method should not be used.\n * Returns a modified function which warns once by default.\n *\n * If `localStorage.noDeprecation = true` is set, then it is a no-op.\n *\n * If `localStorage.throwDeprecation = true` is set, then deprecated functions\n * will throw an Error when invoked.\n *\n * If `localStorage.traceDeprecation = true` is set, then deprecated functions\n * will invoke `console.trace()` instead of `console.error()`.\n *\n * @param {Function} fn - the function to deprecate\n * @param {String} msg - the string to print to the console when `fn` is invoked\n * @returns {Function} a new \"deprecated\" version of `fn`\n * @api public\n */\n\nfunction deprecate (fn, msg) {\n if (config('noDeprecation')) {\n return fn;\n }\n\n var warned = false;\n function deprecated() {\n if (!warned) {\n if (config('throwDeprecation')) {\n throw new Error(msg);\n } else if (config('traceDeprecation')) {\n console.trace(msg);\n } else {\n console.warn(msg);\n }\n warned = true;\n }\n return fn.apply(this, arguments);\n }\n\n return deprecated;\n}\n\n/**\n * Checks `localStorage` for boolean values for the given `name`.\n *\n * @param {String} name\n * @returns {Boolean}\n * @api private\n */\n\nfunction config (name) {\n // accessing global.localStorage can trigger a DOMException in sandboxed iframes\n try {\n if (!global.localStorage) return false;\n } catch (_) {\n return false;\n }\n var val = global.localStorage[name];\n if (null == val) return false;\n return String(val).toLowerCase() === 'true';\n}\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ \"../webpack/buildin/global.js\")))\n\n//# sourceURL=webpack://ardplayer/../util-deprecate/browser.js?");
|
|
419
|
-
|
|
420
|
-
/***/ }),
|
|
421
|
-
|
|
422
|
-
/***/ 1:
|
|
423
|
-
/*!**********************!*\
|
|
424
|
-
!*** util (ignored) ***!
|
|
425
|
-
\**********************/
|
|
426
|
-
/*! no static exports found */
|
|
427
|
-
/***/ (function(module, exports) {
|
|
428
|
-
|
|
429
|
-
eval("/* (ignored) */\n\n//# sourceURL=webpack://ardplayer/util_(ignored)?");
|
|
430
|
-
|
|
431
|
-
/***/ }),
|
|
432
|
-
|
|
433
|
-
/***/ 2:
|
|
434
|
-
/*!**********************!*\
|
|
435
|
-
!*** util (ignored) ***!
|
|
436
|
-
\**********************/
|
|
437
|
-
/*! no static exports found */
|
|
438
|
-
/***/ (function(module, exports) {
|
|
439
|
-
|
|
440
|
-
eval("/* (ignored) */\n\n//# sourceURL=webpack://ardplayer/util_(ignored)?");
|
|
441
|
-
|
|
442
|
-
/***/ })
|
|
443
|
-
|
|
444
|
-
}]);
|