diff --git a/.babelrc b/.babelrc index 3235ed0..180cb5a 100644 --- a/.babelrc +++ b/.babelrc @@ -7,7 +7,7 @@ "development": { "plugins": [ "istanbul", - "transform-class-properties" + "@babel/plugin-transform-class-properties" ], "minified": false }, diff --git a/.eslintrc.js b/.eslintrc.cjs similarity index 85% rename from .eslintrc.js rename to .eslintrc.cjs index 16d0977..aae2925 100644 --- a/.eslintrc.js +++ b/.eslintrc.cjs @@ -26,7 +26,12 @@ module.exports = { "max-params": ["error", 6], - "no-console": "off" + "no-console": "off", + + "comma-dangle": [ + "error", "always-multiline" + ], + // "sourceType": "module" // "max-statements": ["error", 30] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..fab9dbb --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,29 @@ +name: Build 🛠️ + +on: + workflow_dispatch: # can call manually + push: + branches: + - master + pull_request: + +jobs: + test: + name: Run the tests + strategy: + matrix: + node-version: ['18.x', '20.x'] + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm run lint + - run: npm run build + - run: npm run test diff --git a/README.md b/README.md index 4adc5fa..a112dd9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build 🛠️](https://github.com/bbc/adhere-lib/actions/workflows/build.yml/badge.svg?branch=main&event=status)](https://github.com/bbc/adhere-lib/actions/workflows/build.yml) + # adhere-lib Javascript library for processing AD profile TTML2 and presenting with an HTML video element @@ -20,9 +22,13 @@ A web page showcasing adhere-lib is available at https://bbc.github.io/Adhere/ ## Setup ```Shell -nvm install 14.16.0 -nvm use 14.16.0 +nvm install 20.11.0 +nvm use 20.11.0 +nvm install-latest-npm ``` + +(latest npm is currently 10.8.1) + `cd` to project dir ```Shell diff --git a/build-pr.sh b/build-pr.sh index b334cdf..dbd9960 100755 --- a/build-pr.sh +++ b/build-pr.sh @@ -3,9 +3,9 @@ set -e source /usr/local/nvm/nvm.sh -nvm install 12.12.0 -nvm use 12.12.0 - +nvm install 20.11.0 +nvm use 20.11.0 +nvm install-latest-npm # Install & Build npm install diff --git a/build.sh b/build.sh index aee1b12..62e86cc 100755 --- a/build.sh +++ b/build.sh @@ -3,8 +3,9 @@ set -e source /usr/local/nvm/nvm.sh -nvm install 12.12.0 -nvm use 12.12.0 +nvm install 20.11.0 +nvm use 20.11.0 +nvm install-latest-npm # Install & Build npm install diff --git a/dist/bin/js/bundle.js b/dist/bin/js/bundle.js index ea79b6b..b0ebdf1 100644 --- a/dist/bin/js/bundle.js +++ b/dist/bin/js/bundle.js @@ -6,18 +6,7 @@ * or disable the default devtool with "devtool: false". * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/). */ -(function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(); - else if(typeof define === 'function' && define.amd) - define([], factory); - else if(typeof exports === 'object') - exports["adhere-lib"] = factory(); - else - root["adhere-lib"] = factory(); -})(self, function() { -return /******/ (() => { // webpackBootstrap -/******/ var __webpack_modules__ = ({ +/******/ var __webpack_modules__ = ({ /***/ "./src/AdLeafNode.es6": /*!****************************!*\ @@ -25,8 +14,7 @@ return /******/ (() => { // webpackBootstrap \****************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { -"use strict"; -eval("\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\n\nvar _AudioNub2 = _interopRequireDefault(__webpack_require__(/*! ./AudioNub.es6 */ \"./src/AudioNub.es6\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { \"default\": obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _get(target, property, receiver) { if (typeof Reflect !== \"undefined\" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }\n\nfunction _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n// import Logger from \"./Logger.es6\";\nvar Logger = __webpack_require__(/*! ./Logger.es6 */ \"./src/Logger.es6\").Logger; // import TextPresenter from \"./TextPresenter.es6\";\n\n\nvar TextPresenter = __webpack_require__(/*! ./TextPresenter.es6 */ \"./src/TextPresenter.es6\").TextPresenter;\n\nvar defaultOutput = null;\n\nvar AdLeafNode = /*#__PURE__*/function (_AudioNub) {\n _inherits(AdLeafNode, _AudioNub);\n\n var _super = _createSuper(AdLeafNode);\n\n function AdLeafNode(parent, node, audioContext) {\n var _this;\n\n _classCallCheck(this, AdLeafNode);\n\n _this = _super.call(this, parent, node, audioContext);\n\n if (!_this._name) {\n _this._name = \"span (anonymous)\";\n }\n\n return _this;\n }\n\n _createClass(AdLeafNode, [{\n key: \"makeDefaultOutput\",\n value: function makeDefaultOutput() {\n if (defaultOutput) {\n defaultOutput.onInactive();\n }\n\n this.onActive();\n defaultOutput = this;\n }\n }, {\n key: \"onActive\",\n value: function onActive() {\n if (!this.isActive) {\n this.output.connect(this.audioContext.destination);\n\n if (defaultOutput && defaultOutput !== this) {\n defaultOutput.onInactive();\n }\n\n Logger.log(\"Active leaf: \".concat(this.pathString));\n }\n\n _get(_getPrototypeOf(AdLeafNode.prototype), \"onActive\", this).call(this);\n\n if (this.value) {\n this.tpKey = TextPresenter.present(this.value, this.pathString);\n }\n }\n }, {\n key: \"onInactive\",\n value: function onInactive() {\n if (this.isActive) {\n if (this.tpKey) {\n TextPresenter.unPresent(this.tpKey);\n }\n\n this.output.disconnect(this.audioContext.destination);\n\n if (defaultOutput && defaultOutput !== this) {\n defaultOutput.onActive();\n }\n\n Logger.log(\"Inactive leaf: \".concat(this.pathString));\n }\n\n _get(_getPrototypeOf(AdLeafNode.prototype), \"onInactive\", this).call(this);\n }\n }]);\n\n return AdLeafNode;\n}(_AudioNub2[\"default\"]);\n\nexports[\"default\"] = AdLeafNode;\n\n//# sourceURL=webpack://adhere-lib/./src/AdLeafNode.es6?"); +eval("\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\nvar _AudioNub2 = _interopRequireDefault(__webpack_require__(/*! ./AudioNub.es6 */ \"./src/AudioNub.es6\"));\nfunction _interopRequireDefault(e) { return e && e.__esModule ? e : { \"default\": e }; }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nfunction _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }\nfunction _possibleConstructorReturn(t, e) { if (e && (\"object\" == _typeof(e) || \"function\" == typeof e)) return e; if (void 0 !== e) throw new TypeError(\"Derived constructors may only return object or undefined\"); return _assertThisInitialized(t); }\nfunction _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); return e; }\nfunction _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }\nfunction _get() { return _get = \"undefined\" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { var p = _superPropBase(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } }, _get.apply(null, arguments); }\nfunction _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }\nfunction _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }\nfunction _inherits(t, e) { if (\"function\" != typeof e && null !== e) throw new TypeError(\"Super expression must either be null or a function\"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, \"prototype\", { writable: !1 }), e && _setPrototypeOf(t, e); }\nfunction _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } // Copyright 2019 British Broadcasting Corporation\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n// import Logger from \"./Logger.es6\";\nvar Logger = (__webpack_require__(/*! ./Logger.es6 */ \"./src/Logger.es6\").Logger);\n// import TextPresenter from \"./TextPresenter.es6\";\nvar TextPresenter = (__webpack_require__(/*! ./TextPresenter.es6 */ \"./src/TextPresenter.es6\").TextPresenter);\nvar defaultOutput = null;\nvar AdLeafNode = exports[\"default\"] = /*#__PURE__*/function (_AudioNub) {\n function AdLeafNode(parent, node, audioContext) {\n var _this;\n _classCallCheck(this, AdLeafNode);\n _this = _callSuper(this, AdLeafNode, [parent, node, audioContext]);\n if (!_this._name) {\n _this._name = \"span (anonymous)\";\n }\n return _this;\n }\n _inherits(AdLeafNode, _AudioNub);\n return _createClass(AdLeafNode, [{\n key: \"makeDefaultOutput\",\n value: function makeDefaultOutput() {\n if (defaultOutput) {\n defaultOutput.onInactive();\n }\n this.onActive();\n defaultOutput = this;\n }\n }, {\n key: \"onActive\",\n value: function onActive() {\n if (!this.isActive) {\n this.output.connect(this.audioContext.destination);\n if (defaultOutput && defaultOutput !== this) {\n defaultOutput.onInactive();\n }\n Logger.log(\"Active leaf: \".concat(this.pathString));\n }\n _get(_getPrototypeOf(AdLeafNode.prototype), \"onActive\", this).call(this);\n if (this.value) {\n this.tpKey = TextPresenter.present(this.value, this.pathString);\n }\n }\n }, {\n key: \"onInactive\",\n value: function onInactive() {\n if (this.isActive) {\n if (this.tpKey) {\n TextPresenter.unPresent(this.tpKey);\n }\n this.output.disconnect(this.audioContext.destination);\n if (defaultOutput && defaultOutput !== this) {\n defaultOutput.onActive();\n }\n Logger.log(\"Inactive leaf: \".concat(this.pathString));\n }\n _get(_getPrototypeOf(AdLeafNode.prototype), \"onInactive\", this).call(this);\n }\n }]);\n}(_AudioNub2[\"default\"]);\n\n//# sourceURL=webpack://adhere-lib/./src/AdLeafNode.es6?"); /***/ }), @@ -36,8 +24,7 @@ eval("\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol \************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { -"use strict"; -eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\n\nvar _Utils = _interopRequireDefault(__webpack_require__(/*! ./Utils.es6 */ \"./src/Utils.es6\"));\n\nvar _TimingCalculator = _interopRequireDefault(__webpack_require__(/*! ./TimingCalculator.es6 */ \"./src/TimingCalculator.es6\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { \"default\": obj }; }\n\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n//import Logger from \"./Logger.es6\";\nvar Logger = __webpack_require__(/*! ./Logger.es6 */ \"./src/Logger.es6\").Logger;\n\nvar AdNode = /*#__PURE__*/function () {\n function AdNode(parent, xmlNode, audioContext) {\n _classCallCheck(this, AdNode);\n\n this._xmlNode = xmlNode;\n this.parent = parent;\n this.time = {\n begin: _TimingCalculator[\"default\"].computeBegin(xmlNode),\n end: undefined\n };\n this._name = xmlNode.name;\n this._value = xmlNode.value;\n\n if (xmlNode.attributes) {\n this._pitch = _Utils[\"default\"].getAttributeByFullyQualifiedName(xmlNode, \"\".concat(_Utils[\"default\"].NS_TTML_AUDIO_URI, \"%%pitch\"));\n this._speak = _Utils[\"default\"].getAttributeByFullyQualifiedName(xmlNode, \"\".concat(_Utils[\"default\"].NS_TTML_AUDIO_URI, \"%%speak\"));\n this._id = _Utils[\"default\"].getAttributeByFullyQualifiedName(xmlNode, \"\".concat(_Utils[\"default\"].NS_XML_URI, \"%%id\"));\n }\n\n if (audioContext) {\n this.ac = audioContext;\n } // Logger.log(`Constructed an AdNode for ${this.pathString}, value \\\"${this.value}\\\"\n // ${this.begin} --> ${this.end}`); // DEBUG\n\n }\n\n _createClass(AdNode, [{\n key: \"postComputeEnd\",\n value: function postComputeEnd() {\n this.time.end = _TimingCalculator[\"default\"].computeEnd(this._xmlNode); // Logger.log(`postComputeEnd() for ${this.pathString}, value \\\"${this.value}\\\"\n // ${this.begin} --> ${this.end}`); // DEBUG\n\n if (this.children) {\n this.children.forEach(function (c) {\n c.postComputeEnd();\n });\n }\n }\n }, {\n key: \"audioContext\",\n get: function get() {\n if (this.ac) {\n return this.ac;\n }\n\n if (this.parent) {\n return this.parent.audioContext;\n }\n\n return null;\n }\n }, {\n key: \"begin\",\n get: function get() {\n var begin = NaN;\n\n if (this.time) {\n begin = this.time.begin;\n }\n\n return begin;\n }\n }, {\n key: \"end\",\n get: function get() {\n var end = NaN;\n\n if (this.time) {\n end = this.time.end;\n }\n\n return end;\n }\n }, {\n key: \"pitch\",\n get: function get() {\n if (this._pitch || this._pitch === 0) {\n return this._pitch;\n } else if (this.parent) {\n return this.parent.pitch;\n }\n\n return undefined;\n }\n }, {\n key: \"speak\",\n get: function get() {\n if (this._speak) {\n return this._speak;\n } else if (this.parent) {\n return this.parent.speak;\n }\n\n return undefined;\n }\n }, {\n key: \"value\",\n get: function get() {\n return this._value;\n }\n }, {\n key: \"videoMedia\",\n get: function get() {\n return this._videoMedia;\n },\n set: function set(vm) {\n this._videoMedia = vm;\n }\n }, {\n key: \"makeCueObjects\",\n value: function makeCueObjects(arr, videoMedia) {\n var _this = this;\n\n this.videoMedia = videoMedia;\n var b = this.begin;\n var e = !isNaN(this.end) ? this.end : videoMedia.duration;\n var v = this.value;\n\n if (!isNaN(b) && !isNaN(e)) {\n // Logger.log(`Making a cue for ${ this.pathString }, \\\"${ v }\\\",\n // ${b} --> ${e}.`); // DEBUG\n var newCue = new VTTCue(b, e, v);\n\n newCue.onenter = function () {\n return _this.onActive();\n };\n\n newCue.onexit = function () {\n return _this.onInactive();\n };\n\n arr.push(newCue); // } else {\n // Logger.log(`Not making a cue for ${ this.pathString }, \\\"${ v }\\\"\n // because b (${b}) or e (${e}) is NaN.`); // DEBUG\n }\n\n if (this.children) {\n var _iterator = _createForOfIteratorHelper(this.children),\n _step;\n\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var c = _step.value;\n c.makeCueObjects(arr, videoMedia);\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n }\n } //Go down the tree, apply fn(c) to all children\n\n }, {\n key: \"traverse\",\n value: function traverse(fn) {\n fn(this);\n\n if (this.children) {\n var _iterator2 = _createForOfIteratorHelper(this.children),\n _step2;\n\n try {\n for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {\n var c = _step2.value;\n c.traverse(fn);\n }\n } catch (err) {\n _iterator2.e(err);\n } finally {\n _iterator2.f();\n }\n }\n }\n }, {\n key: \"name\",\n get: function get() {\n return this._name;\n }\n }, {\n key: \"pathString\",\n get: function get() {\n return (this.parent ? \"\".concat(this.parent.pathString, \" -> \") : \"\") + \"\".concat(this.name).concat(this.idString);\n }\n }, {\n key: \"idString\",\n get: function get() {\n return this._id ? \" id:\\\"\".concat(this._id, \"\\\"\") : \"\";\n }\n }, {\n key: \"onActive\",\n value: function onActive() {\n this.isActive = true;\n Logger.log(\"Active AdNode: \".concat(this.pathString));\n }\n }, {\n key: \"onInactive\",\n value: function onInactive() {\n this.isActive = false;\n Logger.log(\"Inactive AdNode: \".concat(this.pathString));\n }\n }, {\n key: \"onFinalise\",\n value: function onFinalise() {\n if (this.isActive) {\n this.onInactive();\n }\n }\n }]);\n\n return AdNode;\n}();\n\nexports[\"default\"] = AdNode;\n\n//# sourceURL=webpack://adhere-lib/./src/AdNode.es6?"); +eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\nvar _Utils = _interopRequireDefault(__webpack_require__(/*! ./Utils.es6 */ \"./src/Utils.es6\"));\nvar _TimingCalculator = _interopRequireDefault(__webpack_require__(/*! ./TimingCalculator.es6 */ \"./src/TimingCalculator.es6\"));\nfunction _interopRequireDefault(e) { return e && e.__esModule ? e : { \"default\": e }; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(r, e) { var t = \"undefined\" != typeof Symbol && r[Symbol.iterator] || r[\"@@iterator\"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && \"number\" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t[\"return\"] || t[\"return\"](); } finally { if (u) throw o; } } }; }\nfunction _unsupportedIterableToArray(r, a) { if (r) { if (\"string\" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return \"Object\" === t && r.constructor && (t = r.constructor.name), \"Map\" === t || \"Set\" === t ? Array.from(r) : \"Arguments\" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }\nfunction _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); } // Copyright 2019 British Broadcasting Corporation\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n//import Logger from \"./Logger.es6\";\nvar Logger = (__webpack_require__(/*! ./Logger.es6 */ \"./src/Logger.es6\").Logger);\nvar AdNode = exports[\"default\"] = /*#__PURE__*/function () {\n function AdNode(parent, xmlNode, audioContext) {\n _classCallCheck(this, AdNode);\n this._xmlNode = xmlNode;\n this.parent = parent;\n this.time = {\n begin: _TimingCalculator[\"default\"].computeBegin(xmlNode),\n end: undefined\n };\n this._name = xmlNode.name;\n this._value = xmlNode.value;\n if (xmlNode.attributes) {\n this._pitch = _Utils[\"default\"].getAttributeByFullyQualifiedName(xmlNode, \"\".concat(_Utils[\"default\"].NS_TTML_AUDIO_URI, \"%%pitch\"));\n this._speak = _Utils[\"default\"].getAttributeByFullyQualifiedName(xmlNode, \"\".concat(_Utils[\"default\"].NS_TTML_AUDIO_URI, \"%%speak\"));\n this._id = _Utils[\"default\"].getAttributeByFullyQualifiedName(xmlNode, \"\".concat(_Utils[\"default\"].NS_XML_URI, \"%%id\"));\n }\n if (audioContext) {\n this.ac = audioContext;\n }\n // Logger.log(`Constructed an AdNode for ${this.pathString}, value \\\"${this.value}\\\"\n // ${this.begin} --> ${this.end}`); // DEBUG\n }\n return _createClass(AdNode, [{\n key: \"postComputeEnd\",\n value: function postComputeEnd() {\n this.time.end = _TimingCalculator[\"default\"].computeEnd(this._xmlNode);\n // Logger.log(`postComputeEnd() for ${this.pathString}, value \\\"${this.value}\\\"\n // ${this.begin} --> ${this.end}`); // DEBUG\n if (this.children) {\n this.children.forEach(function (c) {\n c.postComputeEnd();\n });\n }\n }\n }, {\n key: \"audioContext\",\n get: function get() {\n if (this.ac) {\n return this.ac;\n }\n if (this.parent) {\n return this.parent.audioContext;\n }\n return null;\n }\n }, {\n key: \"begin\",\n get: function get() {\n var begin = NaN;\n if (this.time) {\n begin = this.time.begin;\n }\n return begin;\n }\n }, {\n key: \"end\",\n get: function get() {\n var end = NaN;\n if (this.time) {\n end = this.time.end;\n }\n return end;\n }\n }, {\n key: \"pitch\",\n get: function get() {\n if (this._pitch || this._pitch === 0) {\n return this._pitch;\n } else if (this.parent) {\n return this.parent.pitch;\n }\n return undefined;\n }\n }, {\n key: \"speak\",\n get: function get() {\n if (this._speak) {\n return this._speak;\n } else if (this.parent) {\n return this.parent.speak;\n }\n return undefined;\n }\n }, {\n key: \"value\",\n get: function get() {\n return this._value;\n }\n }, {\n key: \"videoMedia\",\n get: function get() {\n return this._videoMedia;\n },\n set: function set(vm) {\n this._videoMedia = vm;\n }\n }, {\n key: \"makeCueObjects\",\n value: function makeCueObjects(arr, videoMedia) {\n var _this = this;\n this.videoMedia = videoMedia;\n var b = this.begin;\n var e = !isNaN(this.end) ? this.end : videoMedia.duration;\n var v = this.value;\n if (!isNaN(b) && !isNaN(e)) {\n // Logger.log(`Making a cue for ${ this.pathString }, \\\"${ v }\\\",\n // ${b} --> ${e}.`); // DEBUG\n var newCue = new VTTCue(b, e, v);\n newCue.onenter = function () {\n return _this.onActive();\n };\n newCue.onexit = function () {\n return _this.onInactive();\n };\n arr.push(newCue);\n // } else {\n // Logger.log(`Not making a cue for ${ this.pathString }, \\\"${ v }\\\"\n // because b (${b}) or e (${e}) is NaN.`); // DEBUG\n }\n if (this.children) {\n var _iterator = _createForOfIteratorHelper(this.children),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var c = _step.value;\n c.makeCueObjects(arr, videoMedia);\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n }\n }\n\n //Go down the tree, apply fn(c) to all children\n }, {\n key: \"traverse\",\n value: function traverse(fn) {\n fn(this);\n if (this.children) {\n var _iterator2 = _createForOfIteratorHelper(this.children),\n _step2;\n try {\n for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {\n var c = _step2.value;\n c.traverse(fn);\n }\n } catch (err) {\n _iterator2.e(err);\n } finally {\n _iterator2.f();\n }\n }\n }\n }, {\n key: \"name\",\n get: function get() {\n return this._name;\n }\n }, {\n key: \"pathString\",\n get: function get() {\n return (this.parent ? \"\".concat(this.parent.pathString, \" -> \") : \"\") + \"\".concat(this.name).concat(this.idString);\n }\n }, {\n key: \"idString\",\n get: function get() {\n return this._id ? \" id:\\\"\".concat(this._id, \"\\\"\") : \"\";\n }\n }, {\n key: \"onActive\",\n value: function onActive() {\n this.isActive = true;\n Logger.log(\"Active AdNode: \".concat(this.pathString));\n }\n }, {\n key: \"onInactive\",\n value: function onInactive() {\n this.isActive = false;\n Logger.log(\"Inactive AdNode: \".concat(this.pathString));\n }\n }, {\n key: \"onFinalise\",\n value: function onFinalise() {\n if (this.isActive) {\n this.onInactive();\n }\n }\n }]);\n}();\n\n//# sourceURL=webpack://adhere-lib/./src/AdNode.es6?"); /***/ }), @@ -47,8 +34,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n})); \******************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { -"use strict"; -eval("\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\n\nvar _AudioNub2 = _interopRequireDefault(__webpack_require__(/*! ./AudioNub.es6 */ \"./src/AudioNub.es6\"));\n\nvar _TimingCalculator = _interopRequireDefault(__webpack_require__(/*! ./TimingCalculator.es6 */ \"./src/TimingCalculator.es6\"));\n\nvar _PlaybackProperties = _interopRequireDefault(__webpack_require__(/*! ./PlaybackProperties.es6 */ \"./src/PlaybackProperties.es6\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { \"default\": obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _get(target, property, receiver) { if (typeof Reflect !== \"undefined\" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }\n\nfunction _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n// import Logger from \"./Logger.es6\";\nvar Logger = __webpack_require__(/*! ./Logger.es6 */ \"./src/Logger.es6\").Logger;\n\nvar readyStateMap = {\n 0: \"HAVE_NOTHING\",\n 1: \"HAVE_METADATA\",\n 2: \"HAVE_CURRENT_DATA\",\n 3: \"HAVE_FUTURE_DATA\",\n 4: \"HAVE_ENOUGH_DATA\"\n}; // This guy is a little weird - It's the input to it's parent; i.e. in the graph\n// it is the parent, but in the tree (and xml), it's a child.\n// Don't use it for user controlled sources like video elements:\n// instead user AdUserControlledSourceNode for them.\n\nvar AdSourceNode = /*#__PURE__*/function (_AudioNub) {\n _inherits(AdSourceNode, _AudioNub);\n\n var _super = _createSuper(AdSourceNode);\n\n function AdSourceNode(parent, xmlNode, audioContext, mediaPair) {\n var _this;\n\n _classCallCheck(this, AdSourceNode);\n\n _this = _super.call(this, parent, xmlNode, audioContext);\n _this.mediaPair = mediaPair;\n _this.media = mediaPair.media;\n _this.mediaNode = mediaPair.mediaNode;\n\n if (xmlNode.attributes.clipBegin) {\n _this.clipBegin = _TimingCalculator[\"default\"].parseSeconds(xmlNode.attributes.clipBegin) || 0;\n } else {\n _this.clipBegin = 0;\n }\n\n if (xmlNode.attributes.clipEnd) {\n _this.clipEnd = _TimingCalculator[\"default\"].parseSeconds(xmlNode.attributes.clipEnd) || NaN;\n }\n\n return _this;\n }\n\n _createClass(AdSourceNode, [{\n key: \"mediaReadyState\",\n value: function mediaReadyState(m) {\n var readyState = m.readyState;\n return readyStateMap[readyState];\n }\n }, {\n key: \"addDebugEventHandlers\",\n value: function addDebugEventHandlers() {\n var _this2 = this;\n\n var m = this.mediaPair.media;\n\n if (m) {\n m.addEventListener(\"abort\", function () {\n Logger.log(\"Audio source aborted loading. readyState = \".concat(_this2.mediaReadyState(m)));\n });\n m.addEventListener(\"error\", function () {\n Logger.log(\"Audio source error. readyState = \".concat(_this2.mediaReadyState(m)));\n });\n m.addEventListener(\"loadeddata\", function () {\n Logger.log(\"Audio source loaded data. readyState = \".concat(_this2.mediaReadyState(m)));\n });\n m.addEventListener(\"loadstart\", function () {\n Logger.log(\"Audio source loadstart. readyState = \".concat(_this2.mediaReadyState(m)));\n });\n m.addEventListener(\"playing\", function () {\n Logger.log(\"Audio source is playing. readyState = \".concat(_this2.mediaReadyState(m)));\n });\n m.addEventListener(\"progress\", function () {\n Logger.log(\"Audio source making progress. readyState = \".concat(_this2.mediaReadyState(m)));\n });\n m.addEventListener(\"waiting\", function () {\n Logger.log(\"Audio source is waiting for more data. readyState = \".concat(_this2.mediaReadyState(m)));\n });\n }\n }\n }, {\n key: \"end\",\n get: function get() {\n var ret;\n\n var normalEnd = _get(_getPrototypeOf(AdSourceNode.prototype), \"end\", this);\n\n if (this.clipEnd) {\n //The duration of the clip added to the start time, or the span end, whichever comes first.\n ret = Math.min(normalEnd, this.begin + (this.clipEnd - this.clipBegin));\n } else {\n ret = normalEnd;\n } // Logger.log(`AdSourceNode end() super said ${normalEnd} but I'm saying ${ret}`); // DEBUG\n\n\n return ret;\n }\n }, {\n key: \"onActive\",\n value: function onActive() {\n var _this3 = this;\n\n if (this.mediaPair && !this.isActive) {\n Logger.log(\"Active AdSourceNode: \".concat(this.pathString));\n var offset = this.videoMedia.currentTime - this.begin;\n this.media.currentTime = this.clipBegin ? this.clipBegin + offset : offset;\n this.input = this.mediaNode;\n this.gainNode.gain.value = this.gain * _PlaybackProperties[\"default\"].getCurrentGain();\n this.input.connect(this.gainNode);\n Logger.log(\"Connected to media element source with src= \".concat(this.input.mediaElement.currentSrc));\n this.media.play()[\"catch\"](function (e) {\n Logger.log(\"AdSourceNode play rejected with error: \".concat(e, \".\"));\n });\n this.output.connect(this.parent.gainNode); //TODO Make formal with .input\n\n Logger.log(\"Active source into: \".concat(this.parent.name, \"; src: \").concat(this.media.src, \"; from: \").concat(this.media.currentTime, \" including offset of \").concat(offset, \".\"));\n this.startTime = this.media.currentTime;\n this.isActive = true;\n this.gainId = _PlaybackProperties[\"default\"].registerCallback(function (uiGain) {\n //const oldVal = this.gainNode.gain.value;\n //console.info(\"Base gain\", this.gain, \"UI gain\", uiGain);\n _this3.gainNode.gain.value = _this3.gain * uiGain; //console.info(\"Final gain changes from\", oldVal, \"to\", this.gainNode.gain.value);\n });\n }\n }\n }, {\n key: \"onInactive\",\n value: function onInactive() {\n if (this.media && this.isActive) {\n Logger.log(\"Inactive AdSourceNode: \".concat(this.pathString));\n this.media.pause();\n this.input.disconnect(this.gainNode);\n this.input = null;\n this.output.disconnect(this.parent.gainNode);\n Logger.log(\"Inactive source into: \".concat(this.parent.name, \"; src: \").concat(this.media.src));\n this.endTime = this.media.currentTime; // DEBUG: clipBegin/clipEnd\n\n Logger.log( // eslint-disable-next-line max-len\n \"ran source for: \".concat(this.endTime - this.startTime, \" clipBegin: \").concat(this.startTime, \" clipEnd: \").concat(this.endTime));\n this.isActive = false;\n\n _PlaybackProperties[\"default\"].deregisterCallback(this.gainId);\n }\n }\n }, {\n key: \"onPause\",\n value: function onPause() {\n if (this.media && this.isActive) {\n this.media.pause();\n }\n }\n }, {\n key: \"onRestart\",\n value: function onRestart() {\n if (this.media && this.isActive) {\n this.media.play();\n }\n }\n }, {\n key: \"onFinalise\",\n value: function onFinalise() {\n if (this.media) {\n _get(_getPrototypeOf(AdSourceNode.prototype), \"onFinalise\", this).call(this);\n\n var src = this.media.src;\n\n if ((src + \"\").indexOf(\"blob://\") > 0) {\n Logger.log(\"Clear audio src \" + this.media.src);\n this.media.src = \"\";\n URL.revokeObjectURL(src);\n }\n\n if (this.input) {\n this.input.disconnect(this.gainNode);\n }\n }\n }\n }]);\n\n return AdSourceNode;\n}(_AudioNub2[\"default\"]);\n\nexports[\"default\"] = AdSourceNode;\n\n//# sourceURL=webpack://adhere-lib/./src/AdSourceNode.es6?"); +eval("\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\nvar _AudioNub2 = _interopRequireDefault(__webpack_require__(/*! ./AudioNub.es6 */ \"./src/AudioNub.es6\"));\nvar _TimingCalculator = _interopRequireDefault(__webpack_require__(/*! ./TimingCalculator.es6 */ \"./src/TimingCalculator.es6\"));\nvar _PlaybackProperties = _interopRequireDefault(__webpack_require__(/*! ./PlaybackProperties.es6 */ \"./src/PlaybackProperties.es6\"));\nfunction _interopRequireDefault(e) { return e && e.__esModule ? e : { \"default\": e }; }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nfunction _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }\nfunction _possibleConstructorReturn(t, e) { if (e && (\"object\" == _typeof(e) || \"function\" == typeof e)) return e; if (void 0 !== e) throw new TypeError(\"Derived constructors may only return object or undefined\"); return _assertThisInitialized(t); }\nfunction _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); return e; }\nfunction _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }\nfunction _get() { return _get = \"undefined\" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { var p = _superPropBase(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } }, _get.apply(null, arguments); }\nfunction _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }\nfunction _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }\nfunction _inherits(t, e) { if (\"function\" != typeof e && null !== e) throw new TypeError(\"Super expression must either be null or a function\"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, \"prototype\", { writable: !1 }), e && _setPrototypeOf(t, e); }\nfunction _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } // Copyright 2019 British Broadcasting Corporation\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n// import Logger from \"./Logger.es6\";\nvar Logger = (__webpack_require__(/*! ./Logger.es6 */ \"./src/Logger.es6\").Logger);\nvar readyStateMap = {\n 0: \"HAVE_NOTHING\",\n 1: \"HAVE_METADATA\",\n 2: \"HAVE_CURRENT_DATA\",\n 3: \"HAVE_FUTURE_DATA\",\n 4: \"HAVE_ENOUGH_DATA\"\n};\n\n// This guy is a little weird - It's the input to it's parent; i.e. in the graph\n// it is the parent, but in the tree (and xml), it's a child.\n// Don't use it for user controlled sources like video elements:\n// instead user AdUserControlledSourceNode for them.\nvar AdSourceNode = exports[\"default\"] = /*#__PURE__*/function (_AudioNub) {\n function AdSourceNode(parent, xmlNode, audioContext, mediaPair) {\n var _this;\n _classCallCheck(this, AdSourceNode);\n _this = _callSuper(this, AdSourceNode, [parent, xmlNode, audioContext]);\n _this.mediaPair = mediaPair;\n _this.media = mediaPair.media;\n _this.mediaNode = mediaPair.mediaNode;\n if (xmlNode.attributes.clipBegin) {\n _this.clipBegin = _TimingCalculator[\"default\"].parseSeconds(xmlNode.attributes.clipBegin) || 0;\n } else {\n _this.clipBegin = 0;\n }\n if (xmlNode.attributes.clipEnd) {\n _this.clipEnd = _TimingCalculator[\"default\"].parseSeconds(xmlNode.attributes.clipEnd) || NaN;\n }\n return _this;\n }\n _inherits(AdSourceNode, _AudioNub);\n return _createClass(AdSourceNode, [{\n key: \"mediaReadyState\",\n value: function mediaReadyState(m) {\n var readyState = m.readyState;\n return readyStateMap[readyState];\n }\n }, {\n key: \"addDebugEventHandlers\",\n value: function addDebugEventHandlers() {\n var _this2 = this;\n var m = this.mediaPair.media;\n if (m) {\n m.addEventListener(\"abort\", function () {\n Logger.log(\"Audio source aborted loading. readyState = \".concat(_this2.mediaReadyState(m)));\n });\n m.addEventListener(\"error\", function () {\n Logger.log(\"Audio source error. readyState = \".concat(_this2.mediaReadyState(m)));\n });\n m.addEventListener(\"loadeddata\", function () {\n Logger.log(\"Audio source loaded data. readyState = \".concat(_this2.mediaReadyState(m)));\n });\n m.addEventListener(\"loadstart\", function () {\n Logger.log(\"Audio source loadstart. readyState = \".concat(_this2.mediaReadyState(m)));\n });\n m.addEventListener(\"playing\", function () {\n Logger.log(\"Audio source is playing. readyState = \".concat(_this2.mediaReadyState(m)));\n });\n m.addEventListener(\"progress\", function () {\n Logger.log(\"Audio source making progress. readyState = \".concat(_this2.mediaReadyState(m)));\n });\n m.addEventListener(\"waiting\", function () {\n Logger.log(\"Audio source is waiting for more data. readyState = \".concat(_this2.mediaReadyState(m)));\n });\n }\n }\n }, {\n key: \"end\",\n get: function get() {\n var ret;\n var normalEnd = _get(_getPrototypeOf(AdSourceNode.prototype), \"end\", this);\n if (this.clipEnd) {\n //The duration of the clip added to the start time, or the span end, whichever comes first.\n ret = Math.min(normalEnd, this.begin + (this.clipEnd - this.clipBegin));\n } else {\n ret = normalEnd;\n }\n\n // Logger.log(`AdSourceNode end() super said ${normalEnd} but I'm saying ${ret}`); // DEBUG\n return ret;\n }\n }, {\n key: \"onActive\",\n value: function onActive() {\n var _this3 = this;\n if (this.mediaPair && !this.isActive) {\n Logger.log(\"Active AdSourceNode: \".concat(this.pathString));\n var offset = this.videoMedia.currentTime - this.begin;\n this.media.currentTime = this.clipBegin ? this.clipBegin + offset : offset;\n this.input = this.mediaNode;\n this.gainNode.gain.value = this.gain * _PlaybackProperties[\"default\"].getCurrentGain();\n this.input.connect(this.gainNode);\n Logger.log(\"Connected to media element source with src= \".concat(this.input.mediaElement.currentSrc));\n this.media.play()[\"catch\"](function (e) {\n Logger.log(\"AdSourceNode play rejected with error: \".concat(e, \".\"));\n });\n this.output.connect(this.parent.gainNode); //TODO Make formal with .input\n Logger.log(\"Active source into: \".concat(this.parent.name, \"; src: \").concat(this.media.src, \"; from: \").concat(this.media.currentTime, \" including offset of \").concat(offset, \".\"));\n this.startTime = this.media.currentTime;\n this.isActive = true;\n this.gainId = _PlaybackProperties[\"default\"].registerCallback(function (uiGain) {\n //const oldVal = this.gainNode.gain.value;\n //console.info(\"Base gain\", this.gain, \"UI gain\", uiGain);\n _this3.gainNode.gain.value = _this3.gain * uiGain;\n //console.info(\"Final gain changes from\", oldVal, \"to\", this.gainNode.gain.value);\n });\n }\n }\n }, {\n key: \"onInactive\",\n value: function onInactive() {\n if (this.media && this.isActive) {\n Logger.log(\"Inactive AdSourceNode: \".concat(this.pathString));\n this.media.pause();\n this.input.disconnect(this.gainNode);\n this.input = null;\n this.output.disconnect(this.parent.gainNode);\n Logger.log(\"Inactive source into: \".concat(this.parent.name, \"; src: \").concat(this.media.src));\n this.endTime = this.media.currentTime;\n // DEBUG: clipBegin/clipEnd\n Logger.log( // eslint-disable-next-line max-len\n \"ran source for: \".concat(this.endTime - this.startTime, \" clipBegin: \").concat(this.startTime, \" clipEnd: \").concat(this.endTime));\n this.isActive = false;\n _PlaybackProperties[\"default\"].deregisterCallback(this.gainId);\n }\n }\n }, {\n key: \"onPause\",\n value: function onPause() {\n if (this.media && this.isActive) {\n this.media.pause();\n }\n }\n }, {\n key: \"onRestart\",\n value: function onRestart() {\n if (this.media && this.isActive) {\n this.media.play();\n }\n }\n }, {\n key: \"onFinalise\",\n value: function onFinalise() {\n if (this.media) {\n _get(_getPrototypeOf(AdSourceNode.prototype), \"onFinalise\", this).call(this);\n var src = this.media.src;\n if ((src + \"\").indexOf(\"blob://\") > 0) {\n Logger.log(\"Clear audio src \" + this.media.src);\n this.media.src = \"\";\n URL.revokeObjectURL(src);\n }\n if (this.input) {\n this.input.disconnect(this.gainNode);\n }\n }\n }\n }]);\n}(_AudioNub2[\"default\"]);\n\n//# sourceURL=webpack://adhere-lib/./src/AdSourceNode.es6?"); /***/ }), @@ -58,8 +44,7 @@ eval("\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol \********************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { -"use strict"; -eval("\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\n\nvar _AdSourceNode2 = _interopRequireDefault(__webpack_require__(/*! ./AdSourceNode.es6 */ \"./src/AdSourceNode.es6\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { \"default\": obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n// import Logger from \"./Logger.es6\";\nvar Logger = __webpack_require__(/*! ./Logger.es6 */ \"./src/Logger.es6\").Logger; // This guy is a little weird - It's the input to it's parent; i.e. in the graph\n// it is the parent, but in the tree (and xml), it's a child.\n// This subclass is for user controlled sources like