|
|
(window.webpackJsonp=window.webpackJsonp||[]).push([[186,5,7],{"55Ip":
|
|
|
/*!***************************************************************!*\
|
|
|
!*** ./node_modules/react-router-dom/esm/react-router-dom.js ***!
|
|
|
\***************************************************************/
|
|
|
/*! exports provided: MemoryRouter, Prompt, Redirect, Route, Router, StaticRouter, Switch, generatePath, matchPath, useHistory, useLocation, useParams, useRouteMatch, withRouter, BrowserRouter, HashRouter, Link, NavLink */
|
|
|
/*! exports used: Link, NavLink */function(e,t,r){"use strict";r.d(t,"a",(function(){return v})),r.d(t,"b",(function(){return b}));var n=r(/*! react-router */"Ty5D"),i=r(/*! @babel/runtime/helpers/esm/inheritsLoose */"dI71"),a=r(/*! react */"q1tI"),s=r.n(a),o=r(/*! history */"YS25"),l=(r(/*! prop-types */"17x9"),r(/*! @babel/runtime/helpers/esm/extends */"wx14")),u=r(/*! @babel/runtime/helpers/esm/objectWithoutPropertiesLoose */"zLVn"),c=r(/*! tiny-invariant */"9R94");s.a.Component;s.a.Component;var d=function(e,t){return"function"==typeof e?e(t):e},f=function(e,t){return"string"==typeof e?Object(o.c)(e,null,null,t):e},h=function(e){return e},g=s.a.forwardRef;void 0===g&&(g=h);var p=g((function(e,t){var r=e.innerRef,n=e.navigate,i=e.onClick,a=Object(u.a)(e,["innerRef","navigate","onClick"]),o=a.target,c=Object(l.a)({},a,{onClick:function(e){try{i&&i(e)}catch(t){throw e.preventDefault(),t}e.defaultPrevented||0!==e.button||o&&"_self"!==o||function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e)||(e.preventDefault(),n())}});return c.ref=h!==g&&t||r,s.a.createElement("a",c)}));var v=g((function(e,t){var r=e.component,i=void 0===r?p:r,a=e.replace,o=e.to,v=e.innerRef,m=Object(u.a)(e,["component","replace","to","innerRef"]);return s.a.createElement(n.e.Consumer,null,(function(e){e||Object(c.a)(!1);var r=e.history,n=f(d(o,e.location),e.location),u=n?r.createHref(n):"",p=Object(l.a)({},m,{href:u,navigate:function(){var t=d(o,e.location);(a?r.replace:r.push)(t)}});return h!==g?p.ref=t||v:p.innerRef=v,s.a.createElement(i,p)}))})),m=function(e){return e},y=s.a.forwardRef;void 0===y&&(y=m);var b=y((function(e,t){var r=e["aria-current"],i=void 0===r?"page":r,a=e.activeClassName,o=void 0===a?"active":a,h=e.activeStyle,g=e.className,p=e.exact,b=e.isActive,E=e.location,T=e.sensitive,S=e.strict,k=e.style,A=e.to,x=e.innerRef,L=Object(u.a)(e,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return s.a.createElement(n.e.Consumer,null,(function(e){e||Object(c.a)(!1);var r=E||e.location,a=f(d(A,r),r),u=a.pathname,D=u&&u.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),O=D?Object(n.f)(r.pathname,{path:D,exact:p,sensitive:T,strict:S}):null,C=!!(b?b(O,r):O),_=C?function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter((function(e){return e})).join(" ")}(g,o):g,w=C?Object(l.a)({},k,{},h):k,R=Object(l.a)({"aria-current":C&&i||null,className:_,style:w,to:a},L);return m!==y?R.ref=t||x:R.innerRef=x,s.a.createElement(v,R)}))}))},"815F":
|
|
|
/*!***************************************************!*\
|
|
|
!*** ./node_modules/rc-tree/es/utils/treeUtil.js ***!
|
|
|
\***************************************************/
|
|
|
/*! exports provided: getKey, warningWithoutKey, convertTreeToData, flattenTreeData, traverseDataNodes, convertDataToEntities, getTreeNodeProps, convertNodePropsToEventData */
|
|
|
/*! exports used: convertDataToEntities, convertNodePropsToEventData, convertTreeToData, flattenTreeData, getKey, getTreeNodeProps */function(e,t,r){"use strict";r.d(t,"e",(function(){return u})),r.d(t,"c",(function(){return c})),r.d(t,"d",(function(){return d})),r.d(t,"a",(function(){return h})),r.d(t,"f",(function(){return g})),r.d(t,"b",(function(){return p}));var n=r(/*! @babel/runtime/helpers/esm/toConsumableArray */"KQm4"),i=r(/*! @babel/runtime/helpers/esm/objectSpread2 */"VTBJ"),a=r(/*! @babel/runtime/helpers/esm/objectWithoutProperties */"Ff2n"),s=r(/*! rc-util/es/Children/toArray */"Zm9Q"),o=r(/*! rc-util/es/warning */"Kwbf"),l=r(/*! ../util */"OZM5");function u(e,t){return null!=e?e:t}function c(e){return function e(t){return Object(s.a)(t).map((function(t){if(!Object(l.i)(t))return Object(o.a)(!t,"Tree/TreeNode can only accept TreeNode as children."),null;var r=t.key,n=t.props,s=n.children,u=Object(a.a)(n,["children"]),c=Object(i.a)({key:r},u),d=e(s);return d.length&&(c.children=d),c})).filter((function(e){return e}))}(e)}function d(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=new Set(!0===t?[]:t),a=[];function s(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return e.map((function(c,d){var f=Object(l.h)(o?o.pos:"0",d),h=u(c.key,f),g=Object(i.a)(Object(i.a)({},c),{},{parent:o,pos:f,children:null,data:c,isStart:[].concat(Object(n.a)(o?o.isStart:[]),[0===d]),isEnd:[].concat(Object(n.a)(o?o.isEnd:[]),[d===e.length-1])});return a.push(g),!0===t||r.has(h)?g.children=s(c.children||[],g):g.children=[],g}))}return s(e),a}function f(e,t,r){var n;r?"string"==typeof r?n=function(e){return e[r]}:"function"==typeof r&&(n=function(e){return r(e)}):n=function(e,t){return u(e.key,t)},function r(i,a,s){var o=i?i.children:e,u=i?Object(l.h)(s.pos,a):"0";if(i){var c=n(i,u),d={node:i,index:a,pos:u,key:c,parentPos:s.node?s.pos:null,level:s.level+1};t(d)}o&&o.forEach((function(e,t){r(e,t,{node:i,pos:u,level:s?s.level+1:-1})}))}(null)}function h(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.initWrapper,n=t.processEntity,i=t.onProcessFinished,a=arguments.length>2?arguments[2]:void 0,s={},o={},l={posEntities:s,keyEntities:o};return r&&(l=r(l)||l),f(e,(function(e){var t=e.node,r=e.index,i=e.pos,a=e.key,c=e.parentPos,d={node:t,index:r,key:a,pos:i,level:e.level},f=u(a,i);s[i]=d,o[f]=d,d.parent=s[c],d.parent&&(d.parent.children=d.parent.children||[],d.parent.children.push(d)),n&&n(d,l)}),a),i&&i(l),l}function g(e,t){var r=t.expandedKeys,n=t.selectedKeys,i=t.loadedKeys,a=t.loadingKeys,s=t.checkedKeys,o=t.halfCheckedKeys,l=t.dragOverNodeKey,u=t.dropPosition,c=t.keyEntities[e];return{eventKey:e,expanded:-1!==r.indexOf(e),selected:-1!==n.indexOf(e),loaded:-1!==i.indexOf(e),loading:-1!==a.indexOf(e),checked:-1!==s.indexOf(e),halfChecked:-1!==o.indexOf(e),pos:String(c?c.pos:""),dragOver:l===e&&0===u,dragOverGapTop:l===e&&-1===u,dragOverGapBottom:l===e&&1===u}}function p(e){var t=e.data,r=e.expanded,n=e.selected,a=e.checked,s=e.loaded,l=e.loading,u=e.halfChecked,c=e.dragOver,d=e.dragOverGapTop,f=e.dragOverGapBottom,h=e.pos,g=e.active,p=Object(i.a)(Object(i.a)({},t),{},{expanded:r,selected:n,checked:a,loaded:s,loading:l,halfChecked:u,dragOver:c,dragOverGapTop:d,dragOverGapBottom:f,pos:h,active:g});return"props"in p||Object.defineProperty(p,"props",{get:function(){return Object(o.a)(!1,"Second param return from event is node data instead of TreeNode instance. Please read value directly instead of reading from `props`."),e}}),p}},"8Jsi":
|
|
|
/*!**************************************************************!*\
|
|
|
!*** ./node_modules/rc-tree-select/es/index.js + 12 modules ***!
|
|
|
\**************************************************************/
|
|
|
/*! exports provided: TreeNode, SHOW_ALL, SHOW_CHILD, SHOW_PARENT, default */
|
|
|
/*! exports used: SHOW_ALL, SHOW_CHILD, SHOW_PARENT, TreeNode, default */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/createClass.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/createSuper.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/inherits.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/typeof.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-select/es/generate.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-select/es/interface/generator.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-select/es/utils/valueUtil.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-tree/es/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-tree/es/utils/conductUtil.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-tree/es/utils/treeUtil.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/Children/toArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/KeyCode.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/hooks/useMemo.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/hooks/useMergedState.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/warning.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */function(e,t,r){"use strict";r.d(t,"d",(function(){return _})),r.d(t,"a",(function(){return G})),r.d(t,"b",(function(){return V})),r.d(t,"c",(function(){return H}));var n=r("1OyB"),i=r("vuIU"),a=r("Ji7U"),s=r("LK+K"),o=r("KQm4"),l=r("U8pU"),u=r("ODXe"),c=r("VTBJ"),d=r("q1tI"),f=r("qNPg"),h=r("2Qr1"),g=r("815F"),p=r("NvD2"),v=r("wPlo"),m=r("6cGi"),y=r("Kwbf"),b=r("4IlW"),E=r("YrtM"),T=r("fAei"),S=d.createContext(null);function k(e,t){if(!e)return!0;var r=e.data,n=r.disabled,i=r.disableCheckbox;switch(t){case"select":return n;case"checkbox":return n||i}return!1}function A(e,t){return[d.useCallback((function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"select",n=arguments.length>2?arguments[2]:void 0,i=e.get(t);return!n&&k(i,r)?null:i}),[e]),d.useCallback((function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"select",n=arguments.length>2?arguments[2]:void 0,i=t.get(e);return!n&&k(i,r)?null:i}),[t])]}function x(e){return d.useMemo((function(){var t=new Map,r=new Map;return e.forEach((function(e){t.set(e.key,e),r.set(e.data.value,e)})),[t,r]}),[e])}var L={width:0,height:0,display:"flex",overflow:"hidden",opacity:0,border:0,padding:0,margin:0},D=function(e,t){var r=e.prefixCls,n=e.height,i=e.itemHeight,a=e.virtual,s=e.options,l=e.flattenOptions,c=e.multiple,f=e.searchValue,h=e.onSelect,g=e.onToggleOpen,p=e.open,v=e.notFoundContent,m=e.onMouseEnter,y=d.useContext(S),k=y.checkable,D=y.checkedKeys,O=y.halfCheckedKeys,C=y.treeExpandedKeys,_=y.treeDefaultExpandAll,w=y.treeDefaultExpandedKeys,R=y.onTreeExpand,I=y.treeIcon,P=y.showTreeIcon,N=y.switcherIcon,M=y.treeLine,F=y.treeNodeFilterProp,j=y.loadData,B=y.treeLoadedKeys,U=y.treeMotion,K=y.onTreeLoad,G=d.useRef(),H=Object(E.a)((function(){return s}),[p,s],(function(e,t){return t[0]&&e[1]!==t[1]})),V=x(l),z=Object(u.a)(V,2),W=A(z[0],z[1]),q=Object(u.a)(W,2),Y=q[0],$=q[1],X=d.useMemo((function(){return D.map((function(e){var t=$(e);return t?t.key:null}))}),[D]),Z=d.useMemo((function(){return k?{checked:X,halfChecked:O}:null}),[X,O,k]);d.useEffect((function(){var e;p&&!c&&X.length&&(null===(e=G.current)||void 0===e||e.scrollTo({key:X[0]}))}),[p]);var Q=String(f).toLowerCase(),J=d.useState(w),ee=Object(u.a)(J,2),te=ee[0],re=ee[1],ne=d.useState(null),ie=Object(u.a)(ne,2),ae=ie[0],se=ie[1],oe=d.useMemo((function(){return C?Object(o.a)(C):f?ae:te}),[te,ae,Q,C]);d.useEffect((function(){f&&se(l.map((function(e){return e.key})))}),[f]);var le=function(e){e.preventDefault()},ue=function(e,t){var r=t.node.key,n=Y(r,k?"checkbox":"select");null!==n&&h(n.data.value,{selected:!D.includes(n.data.value)}),c||g(!1)},ce=d.useState(null),de=Object(u.a)(ce,2),fe=de[0],he=de[1],ge=Y(fe);if(d.useImperativeHandle(t,(function(){return{onKeyDown:function(e){var t;switch(e.which){case b.a.UP:case b.a.DOWN:case b.a.LEFT:case b.a.RIGHT:null===(t=G.current)||void 0===t||t.onKeyDown(e);break;case b.a.ENTER:null!==ge&&ue(0,{node:{key:fe},selected:!D.includes(ge.data.value)});break;case b.a.ESC:g(!1)}},onKeyUp:function(){}}})),0===H.length)return d.createElement("div",{role:"listbox",className:"".concat(r,"-empty"),onMouseDown:le},v);var pe={};return B&&(pe.loadedKeys=B),oe&&(pe.expandedKeys=oe),d.createElement("div",{onMouseDown:le,onMouseEnter:m},ge&&p&&d.createElement("span",{style:L,"aria-live":"assertive"},ge.data.value),d.createElement(T.b,Object.assign({ref:G,focusable:!1,prefixCls:"".concat(r,"-tree"),treeData:H,height:n,itemHeight:i,virtual:a,multiple:c,icon:I,showIcon:P,switcherIcon:N,showLine:M,loadData:f?null:j,motion:U,checkable:k,checkStrictly:!0,checkedKeys:Z,selectedKeys:k?[]:X,defaultExpandAll:_},pe,{onActiveChange:he,onSelect:ue,onCheck:ue,onExpand:function(e){re(e),se(e),R&&R(e)},onLoad:K,filterTreeNode:function(e){return!!Q&&String(e[F]).toLowerCase().includes(Q)}})))},O=d.forwardRef(D);O.displayName="OptionList";var C=O,_=function(){return null},w=r("Ff2n"),R=r("Zm9Q");function I(e){if(!e)return e;var t=Object(c.a)({},e);return"props"in t||Object.defineProperty(t,"props",{get:function(){return Object(y.a)(!1,"New `rc-tree-select` not support return node instance as argument anymore. Please consider to remove `props` access."),t}}),t}function P(e){return Array.isArray(e)?e:void 0!==e?[e]:[]}function N(e,t){var r=new Map;return t.forEach((function(e){var t=e.data;r.set(t.value,t)})),e.map((function(e){return I(r.get(e))}))}function M(e){return e.disabled||e.disableCheckbox||!1===e.checkable}function F(e){for(var t=0,r=e.parent;r;)r=r.parent,t+=1;return t}function j(e){return Object(g.d)(function e(t){return(t||[]).map((function(t){var r=t.value,n=t.key,i=t.children,a=Object(c.a)(Object(c.a)({},t),{},{key:"key"in t?n:r});return i&&(a.children=e(i)),a}))}(e),!0).map((function(e){return{key:e.data.key,data:e.data,level:F(e)}}))}function B(e,t,r,n){var i=new Map;return P(t).forEach((function(e){e&&"object"===Object(l.a)(e)&&"value"in e&&i.set(e.value,e)})),e.map((function(e){var t={value:e},a=r(e,"select",!0),s=a?n(a.data):e;if(i.has(e)){var o=i.get(e);t.label="label"in o?o.label:s,"halfChecked"in o&&(t.halfChecked=o.halfChecked)}else t.label=s;return t}))}function U(e,t){new Set;return function e(r){return(r||[]).map((function(r){var n=r.key,i=r.value,a=r.children,s=Object(w.a)(r,["key","value","children"]),o="value"in r?i:n,l=Object(c.a)(Object(c.a)({},s),{},{key:null!=n?n:o,value:o,title:t(r)});return"children"in r&&(l.children=e(a)),l}))}(e)}function K(e,t,r){var n=r.getLabelProp,i=r.simpleMode,a=d.useRef({});return e?(a.current.formatTreeData=a.current.treeData===e?a.current.formatTreeData:U(i?function(e,t){var r=t.id,n=t.pId,i=t.rootPId,a={},s=[];return e.map((function(e){var t=Object(c.a)({},e),n=t[r];return a[n]=t,t.key=t.key||n,t})).forEach((function(e){var t=e[n],r=a[t];r&&(r.children=r.children||[],r.children.push(e)),(t===i||!r&&null===i)&&s.push(e)})),s}(e,Object(c.a)({id:"id",pId:"pId",rootPId:null},!0!==i?i:{})):e,n),a.current.treeData=e):a.current.formatTreeData=a.current.children===t?a.current.formatTreeData:U(function e(t){return Object(R.a)(t).map((function(t){if(!d.isValidElement(t)||!t.type)return null;var r=t.key,n=t.props,i=n.children,a=n.value,s=Object(w.a)(n,["children","value"]),o=Object(c.a)({key:r,value:a},s),l=e(i);return l.length&&(o.children=l),o})).filter((function(e){return e}))}(t),n),a.current.formatTreeData}var G="SHOW_ALL",H="SHOW_PARENT",V="SHOW_CHILD";function z(e,t,r){var n=new Set(e);return t===V?e.filter((function(e){var t=r[e];return!(t&&t.children&&t.children.every((function(e){var t=e.node;return M(t)||n.has(t.key)})))})):t===H?e.filter((function(e){var t=r[e],i=t?t.parent:null;return!(i&&!M(i.node)&&n.has(i.node.key))})):e}var W=["expandedKeys","treeData","treeCheckable","showCheckedStrategy","searchPlaceholder","treeLine","treeIcon","showTreeIcon","switcherIcon","treeNodeFilterProp","filterTreeNode","dropdownPopupAlign","treeDefaultExpandAll","treeCheckStrictly","treeExpandedKeys","treeLoadedKeys","treeMotion","onTreeExpand","onTreeLoad","loadData","treeDataSimpleMode","treeNodeLabelProp","treeDefaultExpandedKeys"],q=Object(f.a)({prefixCls:"rc-tree-select",components:{optionList:C},convertChildrenToData:function(){return null},flattenOptions:j,getLabeledValue:h.e,filterOptions:function(e,t,r){var n,i=r.optionFilterProp,a=r.filterOption;return!1===a?t:(n="function"==typeof a?a:function(e){return function(t,r){var n=r[e];return String(n).toLowerCase().includes(String(t).toLowerCase())}}(i),function t(r){var i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return r.map((function(r){var a=r.children,s=i||n(e,I(r)),o=t(a||[],s);return s||o.length?Object(c.a)(Object(c.a)({},r),{},{children:o}):null})).filter((function(e){return e}))}(t))},isValueDisabled:function(e,t){var r=N([e],t)[0];return!!r&&r.disabled},findValueOption:N,omitDOMProps:function(e){var t=Object(c.a)({},e);return W.forEach((function(e){delete t[e]})),t}});q.displayName="Select";var Y=d.forwardRef((function(e,t){var r=e.multiple,n=e.treeCheckable,i=e.treeCheckStrictly,a=e.showCheckedStrategy,s=void 0===a?"SHOW_CHILD":a,c=e.labelInValue,f=e.loadData,h=e.treeLoadedKeys,b=e.treeNodeFilterProp,E=void 0===b?"value":b,T=e.treeNodeLabelProp,k=e.treeDataSimpleMode,L=e.treeData,D=e.treeExpandedKeys,O=e.treeDefaultExpandedKeys,C=e.treeDefaultExpandAll,w=e.children,R=e.treeIcon,I=e.showTreeIcon,N=e.switcherIcon,M=e.treeLine,F=e.treeMotion,U=e.filterTreeNode,G=e.dropdownPopupAlign,H=e.onChange,V=e.onTreeExpand,W=e.onTreeLoad,Y=e.onDropdownVisibleChange,$=e.onSelect,X=e.onDeselect,Z=n||i,Q=r||Z,J=n&&!i,ee=i||c,te=d.useRef(null);d.useImperativeHandle(t,(function(){return{focus:te.current.focus,blur:te.current.blur}}));var re=function(e){return L&&e.label||e.title},ne=function(e){return T?e[T]:re(e)},ie=K(L,w,{getLabelProp:re,simpleMode:k}),ae=x(Object(d.useMemo)((function(){return j(ie)}),[ie])),se=Object(u.a)(ae,2),oe=A(se[0],se[1]),le=Object(u.a)(oe,2),ue=le[0],ce=le[1],de=Object(d.useMemo)((function(){return J?Object(g.a)(ie):{keyEntities:null}}),[ie,n,i]).keyEntities,fe=Object(m.a)(e.defaultValue,{value:e.value}),he=Object(u.a)(fe,2),ge=he[0],pe=he[1],ve=function(e){var t=[],r=[];return e.forEach((function(e){ce(e)?r.push(e):t.push(e)})),{missingRawValues:t,existRawValues:r}},me=Object(d.useMemo)((function(){var e=[],t=[];if(P(ge).forEach((function(r){if(r&&"object"===Object(l.a)(r)&&"value"in r)if(r.halfChecked&&i){var n=ce(r.value);e.push(n?n.key:r.value)}else t.push(r.value);else t.push(r)})),J){var r=ve(t),n=r.missingRawValues,a=r.existRawValues.map((function(e){return ce(e).key})),s=Object(p.a)(a,!0,de),u=s.checkedKeys,c=s.halfCheckedKeys;return[[].concat(Object(o.a)(n),Object(o.a)(u.map((function(e){return ue(e).data.value})))),c]}return[t,e]}),[ge,Q,ee,n,i]),ye=Object(u.a)(me,2),be=ye[0],Ee=ye[1],Te=function(e,t){var r=t.value,n=t.getEntityByValue,i=t.getEntityByKey,a=t.treeConduction,s=t.showCheckedStrategy,o=t.conductKeyEntities,l=t.getLabelProp;return d.useMemo((function(){var t=e;a&&(t=z(e.map((function(e){var t=n(e);return t?t.key:e})),s,o).map((function(e){var t=i(e);return t?t.data.value:e})));return B(t,r,n,l)}),[e,r,a,s,n])}(be,{treeConduction:J,value:ge,showCheckedStrategy:s,conductKeyEntities:de,getEntityByValue:ce,getEntityByKey:ue,getLabelProp:ne}),Se=function(e,t,r){if(pe(Q?e:e[0]),H){var n=e;if(J&&"SHOW_ALL"!==s){var a=z(e.map((function(e){var t=ce(e);return t?t.key:e})),s,de);n=a.map((function(e){var t=ue(e);return t?t.data.value:e}))}var l=t||{triggerValue:void 0,selected:void 0},u=l.triggerValue,c=l.selected,f=ee?B(n,ge,ce,ne):n;if(i){var h=Ee.map((function(e){var t=ue(e);return t?t.data.value:e})).filter((function(e){return!n.includes(e)}));f=[].concat(Object(o.a)(f),Object(o.a)(B(h,ge,ce,ne)))}var g={preValue:Te,triggerValue:u},p=!0;(i||"selection"===r&&!c)&&(p=!1),function(e,t,r,n,i){var a=null,s=null;function o(){s||(s=[],function e(n){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0",o=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return n.map((function(n,l){var u="".concat(i,"-").concat(l),c=r.includes(n.value),f=e(n.children||[],u,c),h=d.createElement(_,Object.assign({},n),f.map((function(e){return e.node})));if(t===n.value&&(a=h),c){var g={pos:u,node:h,children:f};return o||s.push(g),g}return null})).filter((function(e){return e}))}(n),s.sort((function(e,t){var n=e.node.props.value,i=t.node.props.value;return r.indexOf(n)-r.indexOf(i)})))}Object.defineProperty(e,"triggerNode",{get:function(){return Object(y.a)(!1,"`triggerNode` is deprecated. Please consider decoupling data with node."),o(),a}}),Object.defineProperty(e,"allCheckedNodes",{get:function(){return Object(y.a)(!1,"`allCheckedNodes` is deprecated. Please consider decoupling data with node."),o(),i?s:s.map((function(e){return e.node}))}})}(g,u,e,ie,p),Z?g.checked=c:g.selected=c,H(Q?f:f[0],ee?null:n.map((function(e){var t=ce(e);return t?ne(t.data):null})),g)}},ke=d.useCallback((function(e){if(Y){var t={};Object.defineProperty(t,"documentClickClose",{get:function(){return Object(y.a)(!1,"Second param of `onDropdownVisibleChange` has been removed."),!1}}),Y(e,t)}}),[Y]);var Ae={optionLabelProp:null,optionFilterProp:E,dropdownAlign:G,internalProps:{mark:v.a,onClear:function(){Se([],null,"clear")},skipTriggerChange:!0,skipTriggerSelect:!0,onRawSelect:function(e,t,r){var n=e;if(Q){var i=function(e,t){var r=new Set(e);return r.add(t),Array.from(r)}(be,e);if(J){var a=ve(i),s=a.missingRawValues,l=a.existRawValues.map((function(e){return ce(e).key})),u=Object(p.a)(l,!0,de).checkedKeys;i=[].concat(Object(o.a)(s),Object(o.a)(u.map((function(e){return ue(e).data.value}))))}Se(i,{selected:!0,triggerValue:e},r)}else Se([e],{selected:!0,triggerValue:e},r);$&&$(n,t)},onRawDeselect:function(e,t,r){var n=e,i=function(e,t){var r=new Set(e);return r.delete(t),Array.from(r)}(be,e);if(J){var a=ve(i),s=a.missingRawValues,l=a.existRawValues.map((function(e){return ce(e).key})),u=Object(p.a)(l,{checked:!1,halfCheckedKeys:Ee},de).checkedKeys;i=[].concat(Object(o.a)(s),Object(o.a)(u.map((function(e){return ue(e).data.value}))))}Se(i,{selected:!1,triggerValue:e},r),X&&X(n,t)}}};return"filterTreeNode"in e&&(Ae.filterOption=U),d.createElement(S.Provider,{value:{checkable:Z,loadData:f,treeLoadedKeys:h,onTreeLoad:W,checkedKeys:be,halfCheckedKeys:Ee,treeDefaultExpandAll:C,treeExpandedKeys:D,treeDefaultExpandedKeys:O,onTreeExpand:V,treeIcon:R,treeMotion:F,showTreeIcon:I,switcherIcon:N,treeLine:M,treeNodeFilterProp:E}},d.createElement(q,Object.assign({ref:te,mode:Q?"multiple":null},e,Ae,{value:Te,labelInValue:!0,options:ie,onChange:null,onSelect:null,onDeselect:null,onDropdownVisibleChange:ke})))})),$=function(e){Object(a.a)(r,e);var t=Object(s.a)(r);function r(){var e;return Object(n.a)(this,r),(e=t.apply(this,arguments)).selectRef=d.createRef(),e.focus=function(){e.selectRef.current.focus()},e.blur=function(){e.selectRef.current.blur()},e}return Object(i.a)(r,[{key:"render",value:function(){return d.createElement(Y,Object.assign({ref:this.selectRef},this.props))}}]),r}(d.Component);$.TreeNode=_,$.SHOW_ALL=G,$.SHOW_PARENT=H,$.SHOW_CHILD=V;var X=$;t.e=X},"9Bee":
|
|
|
/*!*********************************************************!*\
|
|
|
!*** ./src/components/RenderHtml/index.tsx + 1 modules ***!
|
|
|
\*********************************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectSpread2.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/slicedToArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/components/PreviewAll/index.tsx */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/env.ts */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/hls.js/dist/hls.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/katex/dist/katex.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/marked/lib/marked.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/marked/src/helpers.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */function(e,t,r){"use strict";var n=r("k1fw"),i=r("tJVT"),a=r("q1tI"),s=r.n(a),o=(r("vg9a"),r("DlQD")),l=r.n(o),u=r("rUJ1");var c=[],d=["<ul>"],f=new l.a.Renderer,h=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function g(){c.length=0,d=["<ul>"]}var p={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function v(){return function e(t,r,n,i){if(r>=t.length||t[r].level<=n)return r;var a=t[r];i.push("<li><a href='#"+a.anchor+"'>"+a.text+"</a>");var s=[];return r=e(t,++r,a.level,s),s.length>0&&(i.push("<ul>"),s.forEach((function(e){i.push(e)})),i.push("</ul>")),i.push("</li>"),r=e(t,r,n,i)}(c,0,0,d),d.push("</ul>"),d.join("")}var m={heading:function(e){var t=h.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[1].length,text:t[2]}},fences:function(e){var t=this.rules.block.fences.exec(e);if(t){var r=t[0],n=function(e,t){var r=e.match(/^(\s+)(?:```)/);if(null===r)return t;var n=r[1];return t.split("\n").map((function(e){var t=e.match(/^\s+/);return null===t?e:Object(i.a)(t,1)[0].length>=n.length?e.slice(n.length):e})).join("\n")}(r,t[3]||""),a=t[2]?t[2].trim():t[2];if(["latex","katex","math"].indexOf(a)>=0){var s=E(),o=n;n=s,T[s]={type:"block",expression:o}}return{type:"code",raw:r,lang:a,text:n}}}},y=/(?:\${2})([^\n`]+?)(?:\${2})/gi,b=0,E=function(){return"__special_katext_id_".concat(b++,"__")},T={};function S(){b=0,T={}}function k(e){return e=e.replace(y,(function(e,t){var r=E();return T[r]={type:"inline",expression:t},r}))}var A=f.listitem;f.listitem=function(e){return A(k(e))};var x=f.paragraph;f.paragraph=function(e){return x(k(e))};var L=f.tablecell;f.tablecell=function(e,t){return L(k(e),t)},f.code=function(e,t,r){var n=(t||"").match(/\S*/)[0];return n?["latex","katex","math"].indexOf(n)>=0?"<p class='editormd-tex'>".concat(e,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(t,'">').concat(r?e:Object(u.escape)(e,!0),"</code></pre>\n"):'<pre class="prettyprint linenums"><code>'+(r?e:Object(u.escape)(e,!0))+"</code></pre>"},f.heading=function(e,t,r){var n=this.options.headerPrefix+r.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return c.push({anchor:n,level:t,text:e}),"<h"+t+' id="'+n+'">'+e+"</h"+t+">"},l.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),l.a.use({tokenizer:m,renderer:f});var D=l.a,O=(r("SJMd"),r("ulZh")),C=r.n(O),_=r("m3rI"),w=r("Oy/b"),R=r("p5ED"),I=/<pre[^>]*>/g;t.a=function(e){var t=e.value,r=void 0===t?"":t,o=e.className,l=e.showTextOnly,u=e.showLines,c=e.style,d=void 0===c?{}:c,f=e.stylesPrev,h=void 0===f?{}:f,m=String(r),y=Object(a.useState)(""),b=Object(i.a)(y,2),E=b[0],k=b[1],A=Object(a.useMemo)((function(){try{m=(m=m.replace(/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,"("+_.a.API_SERVER+"/api/attachments/").replace(/\"\/api\/attachments\/|\"\/attachments\/download\//g,'"'+_.a.API_SERVER+"/api/attachments/").replace(/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g,'"'+_.a.API_SERVER+"/files/uploads/").replaceAll("http://video.educoder","https://video.educoder").replaceAll("http://www.educoder.net/api","https://data.educoder.net/api").replaceAll("https://www.educoder.net/api","https://data.educoder.net/api").replace(/\r\n/g,"\n")).replace(new RegExp("(?<!\\n)\\n(?!\\n)","g")," \n")}catch(e){}var e=D(m),t=T;if(m.match(/\[TOC\]/)&&(e=e.replace("<p>[TOC]</p>",v()),g()),e=(e=e.replace(/(__special_katext_id_\d+__)/g,(function(e,r){var n=t[r],i=n.type,a=n.expression;return Object(w.renderToString)(function(e){var t=document.createElement("div");return t.innerHTML=e,0===t.childNodes.length?"":t.childNodes[0].nodeValue}(a)||"",{displayMode:"block"===i,throwOnError:!1,output:"html"})}))).replace(/▁/g,"▁▁▁"),S(),l){var r=document.createElement("div");return r.innerHTML=e,r.innerText}return setTimeout((function(){return O()}),500),e}),[m]),x=Object(a.useRef)();function L(e){var t=e.target;if("A"===t.tagName.toUpperCase()){var r=t.getAttribute("href");if(r.indexOf("office")>-1)e.preventDefault(),k(r);else if(r.startsWith("#")){e.preventDefault();var n=document.getElementById(r.replace("#",""));n&&n.scrollIntoView(!0)}}}p.WebkitLineClamp=u,u&&(d=Object(n.a)(Object(n.a)({},d),p));var O=function(){var e,t=null===(e=x.current)||void 0===e?void 0:e.querySelectorAll("video");null==t||t.forEach((function(e){if(e.oncontextmenu=function(){return!1},e.src.indexOf(".m3u8")>-1)if(e.canPlayType("application/vnd.apple.mpegurl"));else if(C.a.isSupported()){var t=new C.a;t.loadSource(e.src),t.attachMedia(e)}}))};return Object(a.useEffect)((function(){if(x.current&&A&&A.match(I)&&window.PR.prettyPrint(),x.current)return x.current.addEventListener("click",L),function(){x.current.removeEventListener("click",L),S(),g()}}),[A,x.current,L]),s.a.createElement(s.a.Fragment,null,s.a.createElement("div",{ref:x,style:Object(n.a)({},d),className:"".concat(o||""," markdown-body "),dangerouslySetInnerHTML:{__html:A}}),s.a.createElement(R.a,{close:!0,data:E,type:null!=E&&E.length?"office":"",style:Object(n.a)({},h),onClose:function(){return k("")}}))}},BU3w:
|
|
|
/*!***************************************************!*\
|
|
|
!*** ./node_modules/rc-util/es/Dom/dynamicCSS.js ***!
|
|
|
\***************************************************/
|
|
|
/*! exports provided: injectCSS, updateCSS */
|
|
|
/*! exports used: updateCSS */function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n=r(/*! ./canUseDom */"MNnm");function i(e){return e.attachTo?e.attachTo:document.querySelector("head")||document.body}function a(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Object(n.a)())return null;var a,s=document.createElement("style");(null===(t=r.csp)||void 0===t?void 0:t.nonce)&&(s.nonce=null===(a=r.csp)||void 0===a?void 0:a.nonce);s.innerHTML=e;var o=i(r),l=o.firstChild;return r.prepend&&o.prepend?o.prepend(s):r.prepend&&l?o.insertBefore(s,l):o.appendChild(s),s}var s=new Map;function o(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i(r);if(!s.has(n)){var o=a("",r),l=o.parentNode;s.set(n,l),l.removeChild(o)}var u=Array.from(s.get(n).children).find((function(e){return"STYLE"===e.tagName&&e["rc-util-key"]===t}));if(u){var c,d,f;if((null===(c=r.csp)||void 0===c?void 0:c.nonce)&&u.nonce!==(null===(d=r.csp)||void 0===d?void 0:d.nonce))u.nonce=null===(f=r.csp)||void 0===f?void 0:f.nonce;return u.innerHTML!==e&&(u.innerHTML=e),u}var h=a(e,r);return h["rc-util-key"]=t,h}},DlQD:
|
|
|
/*!*******************************************!*\
|
|
|
!*** ./node_modules/marked/lib/marked.js ***!
|
|
|
\*******************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,t,r){e.exports=function(){"use strict";function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function r(e,r){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return t(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}var n=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){function t(){return{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}e.exports={defaults:{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1},getDefaults:t,changeDefaults:function(t){e.exports.defaults=t}}})),i=(n.defaults,n.getDefaults,n.changeDefaults,/[&<>"']/),a=/[&<>"']/g,s=/[<>"']|&(?!#?\w+;)/,o=/[<>"']|&(?!#?\w+;)/g,l={"&":"&","<":"<",">":">",'"':""","'":"'"},u=function(e){return l[e]},c=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function d(e){return e.replace(c,(function(e,t){return"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""}))}var f=/(^|[^\[])\^/g,h=/[^\w:]/g,g=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i,p={},v=/^[^:]+:\/*[^/]*$/,m=/^([^:]+:)[\s\S]*$/,y=/^([^:]+:\/*[^/]*)[\s\S]*$/;function b(e,t){p[" "+e]||(v.test(e)?p[" "+e]=e+"/":p[" "+e]=E(e,"/",!0));var r=-1===(e=p[" "+e]).indexOf(":");return"//"===t.substring(0,2)?r?t:e.replace(m,"$1")+t:"/"===t.charAt(0)?r?t:e.replace(y,"$1")+t:e+t}function E(e,t,r){var n=e.length;if(0===n)return"";for(var i=0;i<n;){var a=e.charAt(n-i-1);if(a!==t||r){if(a===t||!r)break;i++}else i++}return e.substr(0,n-i)}var T=function(e,t){if(t){if(i.test(e))return e.replace(a,u)}else if(s.test(e))return e.replace(o,u);return e},S=d,k=function(e,t){e=e.source||e,t=t||"";var r={replace:function(t,n){return n=(n=n.source||n).replace(f,"$1"),e=e.replace(t,n),r},getRegex:function(){return new RegExp(e,t)}};return r},A=function(e,t,r){if(e){var n;try{n=decodeURIComponent(d(r)).replace(h,"").toLowerCase()}catch(e){return null}if(0===n.indexOf("javascript:")||0===n.indexOf("vbscript:")||0===n.indexOf("data:"))return null}t&&!g.test(r)&&(r=b(t,r));try{r=encodeURI(r).replace(/%25/g,"%")}catch(e){return null}return r},x={exec:function(){}},L=function(e){for(var t,r,n=1;n<arguments.length;n++)for(r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},D=function(e,t){var r=e.replace(/\|/g,(function(e,t,r){for(var n=!1,i=t;--i>=0&&"\\"===r[i];)n=!n;return n?"|":" |"})).split(/ \|/),n=0;if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;n<r.length;n++)r[n]=r[n].trim().replace(/\\\|/g,"|");return r},O=E,C=function(e,t){if(-1===e.indexOf(t[1]))return-1;for(var r=e.length,n=0,i=0;i<r;i++)if("\\"===e[i])i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&--n<0)return i;return-1},_=function(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")},w=n.defaults,R=O,I=D,P=T,N=C;function M(e,t,r){var n=t.href,i=t.title?P(t.title):null,a=e[1].replace(/\\([\[\]])/g,"$1");return"!"!==e[0].charAt(0)?{type:"link",raw:r,href:n,title:i,text:a}:{type:"image",raw:r,href:n,title:i,text:P(a)}}var F=function(){function e(e){this.options=e||w}var t=e.prototype;return t.space=function(e){var t=this.rules.block.newline.exec(e);if(t)return t[0].length>1?{type:"space",raw:t[0]}:{raw:"\n"}},t.code=function(e,t){var r=this.rules.block.code.exec(e);if(r){var n=t[t.length-1];if(n&&"paragraph"===n.type)return{raw:r[0],text:r[0].trimRight()};var i=r[0].replace(/^ {4}/gm,"");return{type:"code",raw:r[0],codeBlockStyle:"indented",text:this.options.pedantic?i:R(i,"\n")}}},t.fences=function(e){var t=this.rules.block.fences.exec(e);if(t){var r=t[0],n=function(e,t){var r=e.match(/^(\s+)(?:```)/);if(null===r)return t;var n=r[1];return t.split("\n").map((function(e){var t=e.match(/^\s+/);return null===t?e:t[0].length>=n.length?e.slice(n.length):e})).join("\n")}(r,t[3]||"");return{type:"code",raw:r,lang:t[2]?t[2].trim():t[2],text:n}}},t.heading=function(e){var t=this.rules.block.heading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[1].length,text:t[2]}},t.nptable=function(e){var t=this.rules.block.nptable.exec(e);if(t){var r={type:"table",header:I(t[1].replace(/^ *| *\| *$/g,"")),align:t[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:t[3]?t[3].replace(/\n$/,"").split("\n"):[],raw:t[0]};if(r.header.length===r.align.length){var n,i=r.align.length;for(n=0;n<i;n++)/^ *-+: *$/.test(r.align[n])?r.align[n]="right":/^ *:-+: *$/.test(r.align[n])?r.align[n]="center":/^ *:-+ *$/.test(r.align[n])?r.align[n]="left":r.align[n]=null;for(i=r.cells.length,n=0;n<i;n++)r.cells[n]=I(r.cells[n],r.header.length);return r}}},t.hr=function(e){var t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}},t.blockquote=function(e){var t=this.rules.block.blockquote.exec(e);if(t){var r=t[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:t[0],text:r}}},t.list=function(e){var t=this.rules.block.list.exec(e);if(t){for(var r,n,i,a,s,o,l,u=t[0],c=t[2],d=c.length>1,f=")"===c[c.length-1],h={type:"list",raw:u,ordered:d,start:d?+c.slice(0,-1):"",loose:!1,items:[]},g=t[0].match(this.rules.block.item),p=!1,v=g.length,m=0;m<v;m++)u=r=g[m],n=r.length,~(r=r.replace(/^ *([*+-]|\d+[.)]) */,"")).indexOf("\n ")&&(n-=r.length,r=this.options.pedantic?r.replace(/^ {1,4}/gm,""):r.replace(new RegExp("^ {1,"+n+"}","gm"),"")),m!==v-1&&(i=this.rules.block.bullet.exec(g[m+1])[0],(d?1===i.length||!f&&")"===i[i.length-1]:i.length>1||this.options.smartLists&&i!==c)&&(a=g.slice(m+1).join("\n"),h.raw=h.raw.substring(0,h.raw.length-a.length),m=v-1)),s=p||/\n\n(?!\s*$)/.test(r),m!==v-1&&(p="\n"===r.charAt(r.length-1),s||(s=p)),s&&(h.loose=!0),l=void 0,(o=/^\[[ xX]\] /.test(r))&&(l=" "!==r[1],r=r.replace(/^\[[ xX]\] +/,"")),h.items.push({type:"list_item",raw:u,task:o,checked:l,loose:s,text:r});return h}},t.html=function(e){var t=this.rules.block.html.exec(e);if(t)return{type:this.options.sanitize?"paragraph":"html",raw:t[0],pre:!this.options.sanitizer&&("pre"===t[1]||"script"===t[1]||"style"===t[1]),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(t[0]):P(t[0]):t[0]}},t.def=function(e){var t=this.rules.block.def.exec(e);if(t)return t[3]&&(t[3]=t[3].substring(1,t[3].length-1)),{tag:t[1].toLowerCase().replace(/\s+/g," "),raw:t[0],href:t[2],title:t[3]}},t.table=function(e){var t=this.rules.block.table.exec(e);if(t){var r={type:"table",header:I(t[1].replace(/^ *| *\| *$/g,"")),align:t[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:t[3]?t[3].replace(/\n$/,"").split("\n"):[]};if(r.header.length===r.align.length){r.raw=t[0];var n,i=r.align.length;for(n=0;n<i;n++)/^ *-+: *$/.test(r.align[n])?r.align[n]="right":/^ *:-+: *$/.test(r.align[n])?r.align[n]="center":/^ *:-+ *$/.test(r.align[n])?r.align[n]="left":r.align[n]=null;for(i=r.cells.length,n=0;n<i;n++)r.cells[n]=I(r.cells[n].replace(/^ *\| *| *\| *$/g,""),r.header.length);return r}}},t.lheading=function(e){var t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1]}},t.paragraph=function(e){var t=this.rules.block.paragraph.exec(e);if(t)return{type:"paragraph",raw:t[0],text:"\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1]}},t.text=function(e,t){var r=this.rules.block.text.exec(e);if(r){var n=t[t.length-1];return n&&"text"===n.type?{raw:r[0],text:r[0]}:{type:"text",raw:r[0],text:r[0]}}},t.escape=function(e){var t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:P(t[1])}},t.tag=function(e,t,r){var n=this.rules.inline.tag.exec(e);if(n)return!t&&/^<a /i.test(n[0])?t=!0:t&&/^<\/a>/i.test(n[0])&&(t=!1),!r&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?r=!0:r&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(r=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:t,inRawBlock:r,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):P(n[0]):n[0]}},t.link=function(e){var t=this.rules.inline.link.exec(e);if(t){var r=N(t[2],"()");if(r>-1){var n=(0===t[0].indexOf("!")?5:4)+t[1].length+r;t[2]=t[2].substring(0,r),t[0]=t[0].substring(0,n).trim(),t[3]=""}var i=t[2],a="";if(this.options.pedantic){var s=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);s?(i=s[1],a=s[3]):a=""}else a=t[3]?t[3].slice(1,-1):"";return M(t,{href:(i=i.trim().replace(/^<([\s\S]*)>$/,"$1"))?i.replace(this.rules.inline._escapes,"$1"):i,title:a?a.replace(this.rules.inline._escapes,"$1"):a},t[0])}},t.reflink=function(e,t){var r;if((r=this.rules.inline.reflink.exec(e))||(r=this.rules.inline.nolink.exec(e))){var n=(r[2]||r[1]).replace(/\s+/g," ");if(!(n=t[n.toLowerCase()])||!n.href){var i=r[0].charAt(0);return{type:"text",raw:i,text:i}}return M(r,n,r[0])}},t.strong=function(e,t,r){void 0===r&&(r="");var n=this.rules.inline.strong.start.exec(e);if(n&&(!n[1]||n[1]&&(""===r||this.rules.inline.punctuation.exec(r)))){t=t.slice(-1*e.length);var i,a="**"===n[0]?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;for(a.lastIndex=0;null!=(n=a.exec(t));)if(i=this.rules.inline.strong.middle.exec(t.slice(0,n.index+3)))return{type:"strong",raw:e.slice(0,i[0].length),text:e.slice(2,i[0].length-2)}}},t.em=function(e,t,r){void 0===r&&(r="");var n=this.rules.inline.em.start.exec(e);if(n&&(!n[1]||n[1]&&(""===r||this.rules.inline.punctuation.exec(r)))){t=t.slice(-1*e.length);var i,a="*"===n[0]?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;for(a.lastIndex=0;null!=(n=a.exec(t));)if(i=this.rules.inline.em.middle.exec(t.slice(0,n.index+2)))return{type:"em",raw:e.slice(0,i[0].length),text:e.slice(1,i[0].length-1)}}},t.codespan=function(e){var t=this.rules.inline.code.exec(e);if(t){var r=t[2].replace(/\n/g," "),n=/[^ ]/.test(r),i=r.startsWith(" ")&&r.endsWith(" ");return n&&i&&(r=r.substring(1,r.length-1)),r=P(r,!0),{type:"codespan",raw:t[0],text:r}}},t.br=function(e){var t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}},t.del=function(e){var t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[1]}},t.autolink=function(e,t){var r,n,i=this.rules.inline.autolink.exec(e);if(i)return n="@"===i[2]?"mailto:"+(r=P(this.options.mangle?t(i[1]):i[1])):r=P(i[1]),{type:"link",raw:i[0],text:r,href:n,tokens:[{type:"text",raw:r,text:r}]}},t.url=function(e,t){var r;if(r=this.rules.inline.url.exec(e)){var n,i;if("@"===r[2])i="mailto:"+(n=P(this.options.mangle?t(r[0]):r[0]));else{var a;do{a=r[0],r[0]=this.rules.inline._backpedal.exec(r[0])[0]}while(a!==r[0]);n=P(r[0]),i="www."===r[1]?"http://"+n:n}return{type:"link",raw:r[0],text:n,href:i,tokens:[{type:"text",raw:n,text:n}]}}},t.inlineText=function(e,t,r){var n,i=this.rules.inline.text.exec(e);if(i)return n=t?this.options.sanitize?this.options.sanitizer?this.options.sanitizer(i[0]):P(i[0]):i[0]:P(this.options.smartypants?r(i[0]):i[0]),{type:"text",raw:i[0],text:n}},e}(),j=x,B=k,U=L,K={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:"^ {0,3}(?:<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?\\?>\\n*|<![A-Z][\\s\\S]*?>\\n*|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$))",def:/^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,nptable:j,table:j,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/,_label:/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,_title:/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/};K.def=B(K.def).replace("label",K._label).replace("title",K._title).getRegex(),K.bullet=/(?:[*+-]|\d{1,9}[.)])/,K.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,K.item=B(K.item,"gm").replace(/bull/g,K.bullet).getRegex(),K.list=B(K.list).replace(/bull/g,K.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+K.def.source+")").getRegex(),K._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",K._comment=/<!--(?!-?>)[\s\S]*?-->/,K.html=B(K.html,"i").replace("comment",K._comment).replace("tag",K._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),K.paragraph=B(K._paragraph).replace("hr",K.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",K._tag).getRegex(),K.blockquote=B(K.blockquote).replace("paragraph",K.paragraph).getRegex(),K.normal=U({},K),K.gfm=U({},K.normal,{nptable:"^ *([^|\\n ].*\\|.*)\\n *([-:]+ *\\|[-| :]*)(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)",table:"^ *\\|(.+)\\n *\\|?( *[-:]+[-| :]*)(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),K.gfm.nptable=B(K.gfm.nptable).replace("hr",K.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",K._tag).getRegex(),K.gfm.table=B(K.gfm.table).replace("hr",K.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",K._tag).getRegex(),K.pedantic=U({},K.normal,{html:B("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",K._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,fences:j,paragraph:B(K.normal._paragraph).replace("hr",K.hr).replace("heading"," *#{1,6} *[^\n]").replace("lheading",K.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var G={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:j,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,nolink:/^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",strong:{start:/^(?:(\*\*(?=[*punctuation]))|\*\*)(?![\s])|__/,middle:/^\*\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*\*$|^__(?![\s])((?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?)__$/,endAst:/[^punctuation\s]\*\*(?!\*)|[punctuation]\*\*(?!\*)(?:(?=[punctuation\s]|$))/,endUnd:/[^\s]__(?!_)(?:(?=[punctuation\s])|$)/},em:{start:/^(?:(\*(?=[punctuation]))|\*)(?![*\s])|_/,middle:/^\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*$|^_(?![_\s])(?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?_$/,endAst:/[^punctuation\s]\*(?!\*)|[punctuation]\*(?!\*)(?:(?=[punctuation\s]|$))/,endUnd:/[^\s]_(?!_)(?:(?=[punctuation\s])|$)/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:j,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/,_punctuation:"!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~"};G.punctuation=B(G.punctuation).replace(/punctuation/g,G._punctuation).getRegex(),G._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",G._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",G.em.start=B(G.em.start).replace(/punctuation/g,G._punctuation).getRegex(),G.em.middle=B(G.em.middle).replace(/punctuation/g,G._punctuation).replace(/overlapSkip/g,G._overlapSkip).getRegex(),G.em.endAst=B(G.em.endAst,"g").replace(/punctuation/g,G._punctuation).getRegex(),G.em.endUnd=B(G.em.endUnd,"g").replace(/punctuation/g,G._punctuation).getRegex(),G.strong.start=B(G.strong.start).replace(/punctuation/g,G._punctuation).getRegex(),G.strong.middle=B(G.strong.middle).replace(/punctuation/g,G._punctuation).replace(/blockSkip/g,G._blockSkip).getRegex(),G.strong.endAst=B(G.strong.endAst,"g").replace(/punctuation/g,G._punctuation).getRegex(),G.strong.endUnd=B(G.strong.endUnd,"g").replace(/punctuation/g,G._punctuation).getRegex(),G.blockSkip=B(G._blockSkip,"g").getRegex(),G.overlapSkip=B(G._overlapSkip,"g").getRegex(),G._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,G._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,G._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,G.autolink=B(G.autolink).replace("scheme",G._scheme).replace("email",G._email).getRegex(),G._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,G.tag=B(G.tag).replace("comment",K._comment).replace("attribute",G._attribute).getRegex(),G._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,G._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,G._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,G.link=B(G.link).replace("label",G._label).replace("href",G._href).replace("title",G._title).getRegex(),G.reflink=B(G.reflink).replace("label",G._label).getRegex(),G.reflinkSearch=B(G.reflinkSearch,"g").replace("reflink",G.reflink).replace("nolink",G.nolink).getRegex(),G.normal=U({},G),G.pedantic=U({},G.normal,{strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:B(/^!?\[(label)\]\((.*?)\)/).replace("label",G._label).getRegex(),reflink:B(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",G._label).getRegex()}),G.gfm=U({},G.normal,{escape:B(G.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,del:/^~+(?=\S)([\s\S]*?\S)~+/,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?= {2,}\n|[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/}),G.gfm.url=B(G.gfm.url,"i").replace("email",G.gfm._extended_email).getRegex(),G.breaks=U({},G.gfm,{br:B(G.br).replace("{2,}","*").getRegex(),text:B(G.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var H={block:K,inline:G},V=n.defaults,z=H.block,W=H.inline;function q(e){return e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")}function Y(e){var t,r,n="",i=e.length;for(t=0;t<i;t++)r=e.charCodeAt(t),Math.random()>.5&&(r="x"+r.toString(16)),n+="&#"+r+";";return n}var $=function(){function t(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||V,this.options.tokenizer=this.options.tokenizer||new F,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var t={block:z.normal,inline:W.normal};this.options.pedantic?(t.block=z.pedantic,t.inline=W.pedantic):this.options.gfm&&(t.block=z.gfm,this.options.breaks?t.inline=W.breaks:t.inline=W.gfm),this.tokenizer.rules=t}t.lex=function(e,r){return new t(r).lex(e)};var r,n,i,a=t.prototype;return a.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," "),this.blockTokens(e,this.tokens,!0),this.inline(this.tokens),this.tokens},a.blockTokens=function(e,t,r){var n,i,a,s;for(void 0===t&&(t=[]),void 0===r&&(r=!0),e=e.replace(/^ +$/gm,"");e;)if(n=this.tokenizer.space(e))e=e.substring(n.raw.length),n.type&&t.push(n);else if(n=this.tokenizer.code(e,t))e=e.substring(n.raw.length),n.type?t.push(n):((s=t[t.length-1]).raw+="\n"+n.raw,s.text+="\n"+n.text);else if(n=this.tokenizer.fences(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.heading(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.nptable(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.hr(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.blockquote(e))e=e.substring(n.raw.length),n.tokens=this.blockTokens(n.text,[],r),t.push(n);else if(n=this.tokenizer.list(e)){for(e=e.substring(n.raw.length),a=n.items.length,i=0;i<a;i++)n.items[i].tokens=this.blockTokens(n.items[i].text,[],!1);t.push(n)}else if(n=this.tokenizer.html(e))e=e.substring(n.raw.length),t.push(n);else if(r&&(n=this.tokenizer.def(e)))e=e.substring(n.raw.length),this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title});else if(n=this.tokenizer.table(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.lheading(e))e=e.substring(n.raw.length),t.push(n);else if(r&&(n=this.tokenizer.paragraph(e)))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.text(e,t))e=e.substring(n.raw.length),n.type?t.push(n):((s=t[t.length-1]).raw+="\n"+n.raw,s.text+="\n"+n.text);else if(e){var o="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(o);break}throw new Error(o)}return t},a.inline=function(e){var t,r,n,i,a,s,o=e.length;for(t=0;t<o;t++)switch((s=e[t]).type){case"paragraph":case"text":case"heading":s.tokens=[],this.inlineTokens(s.text,s.tokens);break;case"table":for(s.tokens={header:[],cells:[]},i=s.header.length,r=0;r<i;r++)s.tokens.header[r]=[],this.inlineTokens(s.header[r],s.tokens.header[r]);for(i=s.cells.length,r=0;r<i;r++)for(a=s.cells[r],s.tokens.cells[r]=[],n=0;n<a.length;n++)s.tokens.cells[r][n]=[],this.inlineTokens(a[n],s.tokens.cells[r][n]);break;case"blockquote":this.inline(s.tokens);break;case"list":for(i=s.items.length,r=0;r<i;r++)this.inline(s.items[r].tokens)}return e},a.inlineTokens=function(e,t,r,n,i){var a;void 0===t&&(t=[]),void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===i&&(i="");var s,o=e;if(this.tokens.links){var l=Object.keys(this.tokens.links);if(l.length>0)for(;null!=(s=this.tokenizer.rules.inline.reflinkSearch.exec(o));)l.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(s=this.tokenizer.rules.inline.blockSkip.exec(o));)o=o.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;e;)if(a=this.tokenizer.escape(e))e=e.substring(a.raw.length),t.push(a);else if(a=this.tokenizer.tag(e,r,n))e=e.substring(a.raw.length),r=a.inLink,n=a.inRawBlock,t.push(a);else if(a=this.tokenizer.link(e))e=e.substring(a.raw.length),"link"===a.type&&(a.tokens=this.inlineTokens(a.text,[],!0,n)),t.push(a);else if(a=this.tokenizer.reflink(e,this.tokens.links))e=e.substring(a.raw.length),"link"===a.type&&(a.tokens=this.inlineTokens(a.text,[],!0,n)),t.push(a);else if(a=this.tokenizer.strong(e,o,i))e=e.substring(a.raw.length),a.tokens=this.inlineTokens(a.text,[],r,n),t.push(a);else if(a=this.tokenizer.em(e,o,i))e=e.substring(a.raw.length),a.tokens=this.inlineTokens(a.text,[],r,n),t.push(a);else if(a=this.tokenizer.codespan(e))e=e.substring(a.raw.length),t.push(a);else if(a=this.tokenizer.br(e))e=e.substring(a.raw.length),t.push(a);else if(a=this.tokenizer.del(e))e=e.substring(a.raw.length),a.tokens=this.inlineTokens(a.text,[],r,n),t.push(a);else if(a=this.tokenizer.autolink(e,Y))e=e.substring(a.raw.length),t.push(a);else if(r||!(a=this.tokenizer.url(e,Y))){if(a=this.tokenizer.inlineText(e,n,q))e=e.substring(a.raw.length),i=a.raw.slice(-1),t.push(a);else if(e){var u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}throw new Error(u)}}else e=e.substring(a.raw.length),t.push(a);return t},r=t,i=[{key:"rules",get:function(){return{block:z,inline:W}}}],(n=null)&&e(r.prototype,n),i&&e(r,i),t}(),X=n.defaults,Z=A,Q=T,J=function(){function e(e){this.options=e||X}var t=e.prototype;return t.code=function(e,t,r){var n=(t||"").match(/\S*/)[0];if(this.options.highlight){var i=this.options.highlight(e,n);null!=i&&i!==e&&(r=!0,e=i)}return n?'<pre><code class="'+this.options.langPrefix+Q(n,!0)+'">'+(r?e:Q(e,!0))+"</code></pre>\n":"<pre><code>"+(r?e:Q(e,!0))+"</code></pre>\n"},t.blockquote=function(e){return"<blockquote>\n"+e+"</blockquote>\n"},t.html=function(e){return e},t.heading=function(e,t,r,n){return this.options.headerIds?"<h"+t+' id="'+this.options.headerPrefix+n.slug(r)+'">'+e+"</h"+t+">\n":"<h"+t+">"+e+"</h"+t+">\n"},t.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"},t.list=function(e,t,r){var n=t?"ol":"ul";return"<"+n+(t&&1!==r?' start="'+r+'"':"")+">\n"+e+"</"+n+">\n"},t.listitem=function(e){return"<li>"+e+"</li>\n"},t.checkbox=function(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},t.paragraph=function(e){return"<p>"+e+"</p>\n"},t.table=function(e,t){return t&&(t="<tbody>"+t+"</tbody>"),"<table>\n<thead>\n"+e+"</thead>\n"+t+"</table>\n"},t.tablerow=function(e){return"<tr>\n"+e+"</tr>\n"},t.tablecell=function(e,t){var r=t.header?"th":"td";return(t.align?"<"+r+' align="'+t.align+'">':"<"+r+">")+e+"</"+r+">\n"},t.strong=function(e){return"<strong>"+e+"</strong>"},t.em=function(e){return"<em>"+e+"</em>"},t.codespan=function(e){return"<code>"+e+"</code>"},t.br=function(){return this.options.xhtml?"<br/>":"<br>"},t.del=function(e){return"<del>"+e+"</del>"},t.link=function(e,t,r){if(null===(e=Z(this.options.sanitize,this.options.baseUrl,e)))return r;var n='<a href="'+Q(e)+'"';return t&&(n+=' title="'+t+'"'),n+=">"+r+"</a>"},t.image=function(e,t,r){if(null===(e=Z(this.options.sanitize,this.options.baseUrl,e)))return r;var n='<img src="'+e+'" alt="'+r+'"';return t&&(n+=' title="'+t+'"'),n+=this.options.xhtml?"/>":">"},t.text=function(e){return e},e}(),ee=function(){function e(){}var t=e.prototype;return t.strong=function(e){return e},t.em=function(e){return e},t.codespan=function(e){return e},t.del=function(e){return e},t.html=function(e){return e},t.text=function(e){return e},t.link=function(e,t,r){return""+r},t.image=function(e,t,r){return""+r},t.br=function(){return""},e}(),te=function(){function e(){this.seen={}}return e.prototype.slug=function(e){var t=e.toLowerCase().trim().replace(/<[!\/a-z].*?>/gi,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(t)){var r=t;do{this.seen[r]++,t=r+"-"+this.seen[r]}while(this.seen.hasOwnProperty(t))}return this.seen[t]=0,t},e}(),re=n.defaults,ne=S,ie=function(){function e(e){this.options=e||re,this.options.renderer=this.options.renderer||new J,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new ee,this.slugger=new te}e.parse=function(t,r){return new e(r).parse(t)};var t=e.prototype;return t.parse=function(e,t){void 0===t&&(t=!0);var r,n,i,a,s,o,l,u,c,d,f,h,g,p,v,m,y,b,E="",T=e.length;for(r=0;r<T;r++)switch((d=e[r]).type){case"space":continue;case"hr":E+=this.renderer.hr();continue;case"heading":E+=this.renderer.heading(this.parseInline(d.tokens),d.depth,ne(this.parseInline(d.tokens,this.textRenderer)),this.slugger);continue;case"code":E+=this.renderer.code(d.text,d.lang,d.escaped);continue;case"table":for(u="",l="",a=d.header.length,n=0;n<a;n++)l+=this.renderer.tablecell(this.parseInline(d.tokens.header[n]),{header:!0,align:d.align[n]});for(u+=this.renderer.tablerow(l),c="",a=d.cells.length,n=0;n<a;n++){for(l="",s=(o=d.tokens.cells[n]).length,i=0;i<s;i++)l+=this.renderer.tablecell(this.parseInline(o[i]),{header:!1,align:d.align[i]});c+=this.renderer.tablerow(l)}E+=this.renderer.table(u,c);continue;case"blockquote":c=this.parse(d.tokens),E+=this.renderer.blockquote(c);continue;case"list":for(f=d.ordered,h=d.start,g=d.loose,a=d.items.length,c="",n=0;n<a;n++)m=(v=d.items[n]).checked,y=v.task,p="",v.task&&(b=this.renderer.checkbox(m),g?v.tokens.length>0&&"text"===v.tokens[0].type?(v.tokens[0].text=b+" "+v.tokens[0].text,v.tokens[0].tokens&&v.tokens[0].tokens.length>0&&"text"===v.tokens[0].tokens[0].type&&(v.tokens[0].tokens[0].text=b+" "+v.tokens[0].tokens[0].text)):v.tokens.unshift({type:"text",text:b}):p+=b),p+=this.parse(v.tokens,g),c+=this.renderer.listitem(p,y,m);E+=this.renderer.list(c,f,h);continue;case"html":E+=this.renderer.html(d.text);continue;case"paragraph":E+=this.renderer.paragraph(this.parseInline(d.tokens));continue;case"text":for(c=d.tokens?this.parseInline(d.tokens):d.text;r+1<T&&"text"===e[r+1].type;)c+="\n"+((d=e[++r]).tokens?this.parseInline(d.tokens):d.text);E+=t?this.renderer.paragraph(c):c;continue;default:var S='Token with "'+d.type+'" type was not found.';if(this.options.silent)return void console.error(S);throw new Error(S)}return E},t.parseInline=function(e,t){t=t||this.renderer;var r,n,i="",a=e.length;for(r=0;r<a;r++)switch((n=e[r]).type){case"escape":i+=t.text(n.text);break;case"html":i+=t.html(n.text);break;case"link":i+=t.link(n.href,n.title,this.parseInline(n.tokens,t));break;case"image":i+=t.image(n.href,n.title,n.text);break;case"strong":i+=t.strong(this.parseInline(n.tokens,t));break;case"em":i+=t.em(this.parseInline(n.tokens,t));break;case"codespan":i+=t.codespan(n.text);break;case"br":i+=t.br();break;case"del":i+=t.del(this.parseInline(n.tokens,t));break;case"text":i+=t.text(n.text);break;default:var s='Token with "'+n.type+'" type was not found.';if(this.options.silent)return void console.error(s);throw new Error(s)}return i},e}(),ae=L,se=_,oe=T,le=n.getDefaults,ue=n.changeDefaults,ce=n.defaults;function de(e,t,r){if(null==e)throw new Error("marked(): input parameter is undefined or null");if("string"!=typeof e)throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected");if("function"==typeof t&&(r=t,t=null),t=ae({},de.defaults,t||{}),se(t),r){var n,i=t.highlight;try{n=$.lex(e,t)}catch(e){return r(e)}var a=function(e){var a;if(!e)try{a=ie.parse(n,t)}catch(t){e=t}return t.highlight=i,e?r(e):r(null,a)};if(!i||i.length<3)return a();if(delete t.highlight,!n.length)return a();var s=0;return de.walkTokens(n,(function(e){"code"===e.type&&(s++,setTimeout((function(){i(e.text,e.lang,(function(t,r){if(t)return a(t);null!=r&&r!==e.text&&(e.text=r,e.escaped=!0),0==--s&&a()}))}),0))})),void(0===s&&a())}try{var o=$.lex(e,t);return t.walkTokens&&de.walkTokens(o,t.walkTokens),ie.parse(o,t)}catch(e){if(e.message+="\nPlease report this to https://github.com/markedjs/marked.",t.silent)return"<p>An error occurred:</p><pre>"+oe(e.message+"",!0)+"</pre>";throw e}}return de.options=de.setOptions=function(e){return ae(de.defaults,e),ue(de.defaults),de},de.getDefaults=le,de.defaults=ce,de.use=function(e){var t=ae({},e);if(e.renderer&&function(){var r=de.defaults.renderer||new J,n=function(t){var n=r[t];r[t]=function(){for(var i=arguments.length,a=new Array(i),s=0;s<i;s++)a[s]=arguments[s];var o=e.renderer[t].apply(r,a);return!1===o&&(o=n.apply(r,a)),o}};for(var i in e.renderer)n(i);t.renderer=r}(),e.tokenizer&&function(){var r=de.defaults.tokenizer||new F,n=function(t){var n=r[t];r[t]=function(){for(var i=arguments.length,a=new Array(i),s=0;s<i;s++)a[s]=arguments[s];var o=e.tokenizer[t].apply(r,a);return!1===o&&(o=n.apply(r,a)),o}};for(var i in e.tokenizer)n(i);t.tokenizer=r}(),e.walkTokens){var r=de.defaults.walkTokens;t.walkTokens=function(t){e.walkTokens(t),r&&r(t)}}de.setOptions(t)},de.walkTokens=function(e,t){for(var n,i=r(e);!(n=i()).done;){var a=n.value;switch(t(a),a.type){case"table":for(var s,o=r(a.tokens.header);!(s=o()).done;){var l=s.value;de.walkTokens(l,t)}for(var u,c=r(a.tokens.cells);!(u=c()).done;)for(var d,f=r(u.value);!(d=f()).done;){var h=d.value;de.walkTokens(h,t)}break;case"list":de.walkTokens(a.items,t);break;default:a.tokens&&de.walkTokens(a.tokens,t)}}},de.Parser=ie,de.parser=ie.parse,de.Renderer=J,de.TextRenderer=ee,de.Lexer=$,de.lexer=$.lex,de.Tokenizer=F,de.Slugger=te,de.parse=de,de}()},Etsf:
|
|
|
/*!*************************************************!*\
|
|
|
!*** ./src/pages/RestFul/index.tsx + 3 modules ***!
|
|
|
\*************************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! all exports used */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/defineProperty.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectSpread2.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/slicedToArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/regenerator/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/pages/RestFul/components/LeftBar/index.less?modules (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/pages/RestFul/index.less?modules (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/.umi-production/core/umiExports.ts */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/components/RenderHtml/index.tsx */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/service/restful.ts */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/authority.ts */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/fetch.ts */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/breadcrumb/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/breadcrumb/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/col/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/col/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/form/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/form/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/input/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/input/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/message/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/message/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/modal/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/modal/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/popover/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/popover/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/row/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/row/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/tooltip/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/tooltip/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/tree-select/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/tree-select/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/tree/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/tree/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react-router-dom/esm/react-router-dom.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react-router/esm/react-router.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */function(e,t,r){"use strict";r.r(t);r("5Dmo");var n=r("3S7+"),i=(r("14J3"),r("BMrR")),a=(r("jCWc"),r("kPKH")),s=(r("sPJy"),r("bE4q")),o=r("k1fw"),l=r("9og8"),u=(r("y8nQ"),r("Vl3Y")),c=r("tJVT"),d=r("PpiC"),f=r("WmNS"),h=r.n(f),g=r("q1tI"),p=r.n(g),v=r("55Ip"),m=r("9kvl"),y=r("9Bee"),b=r("xKgJ"),E=r("U/Y8"),T=r.n(E),S=(r("Q9mQ"),r("diRs")),k=(r("miYZ"),r("tsqr")),A=(r("2qtc"),r("kLXV")),x=r("oBTY"),L=(r("ozfa"),r("MJZm")),D=(r("5NDa"),r("5rEg")),O=r("jrin"),C=(r("nRaC"),r("5RzL")),_=r("ErOA"),w=r("Ty5D"),R=(C.a.TreeNode,Object(m.a)((function(e){return{restful:e.restful,loading:e.loading}}))((function(e){var t=e.restful,r=(e.loading,e.dispatch),n=(Object(w.i)(),Object(w.h)(),Object(g.useState)(!1)),s=Object(c.a)(n,2),d=s[0],f=s[1],v=Object(g.useState)(),m=Object(c.a)(v,2),y=(m[0],m[1],t.actionTabs,u.a.useForm()),b=Object(c.a)(y,1)[0];return Object(g.useEffect)((function(){"新建同级目录"==t.actionTabs.key&&b.resetFields()}),[t.actionTabs.key]),"新建同级目录"!==t.actionTabs.key?null:p.a.createElement(A.a,{centered:!0,title:"新建目录",visible:"新建同级目录"===t.actionTabs.key,okText:"确定",cancelText:"取消",bodyStyle:{minHeight:150},confirmLoading:d,onOk:Object(l.a)(h.a.mark((function e(){var t;return h.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.validateFields();case 2:return t=b.getFieldValue(),f(!0),"/api/restfuls.json",e.next=7,Object(_.a)("/api/restfuls.json",{method:"post",body:Object(o.a)({file_type:1},t)});case 7:0===e.sent.status&&(k.b.success("添加成功"),r({type:"restful/setActionTabs",payload:{}}),r({type:"restful/getRestful"})),f(!1);case 10:case"end":return e.stop()}}),e)}))),onCancel:function(){r({type:"restful/setActionTabs",payload:{}})}},p.a.createElement("div",{className:"pl30 pr30"},p.a.createElement(u.a,{form:b,initialValues:Object(O.a)({},"name","")},p.a.createElement(u.a.Item,{name:"name",rules:[{required:!0,message:"请输入目录名称"}]},p.a.createElement(i.a,{className:"mt30"},p.a.createElement(a.a,{flex:"80px",className:"font14"},"目录名称:"),p.a.createElement(a.a,{flex:"1"},p.a.createElement(D.a,{placeholder:"请输入名称,最大限制60个字符 ",maxLength:60})))))))}))),I=(C.a.TreeNode,Object(m.a)((function(e){return{restful:e.restful,loading:e.loading}}))((function(e){var t=e.restful,r=(e.loading,e.dispatch),n=(Object(w.i)(),Object(w.h)(),Object(g.useState)(!1)),s=Object(c.a)(n,2),d=s[0],f=s[1],v=Object(g.useState)(),m=Object(c.a)(v,2),y=(m[0],m[1],t.actionTabs,u.a.useForm()),b=Object(c.a)(y,1)[0];return Object(g.useEffect)((function(){"重命名"==t.actionTabs.key&&(b.resetFields(),b.setFieldsValue({name:t.actionTabs.data.title}))}),[t.actionTabs.key]),"重命名"!==t.actionTabs.key?null:p.a.createElement(A.a,{centered:!0,title:"重命名",visible:"重命名"===t.actionTabs.key,okText:"确定",cancelText:"取消",bodyStyle:{minHeight:150},confirmLoading:d,onOk:Object(l.a)(h.a.mark((function e(){var n,i;return h.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.validateFields();case 2:return n=b.getFieldValue(),f(!0),i="/api/restfuls/".concat(t.actionTabs.data.id,".json"),e.next=7,Object(_.a)(i,{method:"put",body:Object(o.a)({file_type:1},n)});case 7:0===e.sent.status&&(k.b.success("修改成功"),r({type:"restful/setActionTabs",payload:{}}),r({type:"restful/getRestful"})),f(!1);case 10:case"end":return e.stop()}}),e)}))),onCancel:function(){r({type:"restful/setActionTabs",payload:{}})}},p.a.createElement("div",{className:"pl30 pr30"},p.a.createElement(u.a,{form:b,initialValues:Object(O.a)({},"name","")},p.a.createElement(i.a,{className:"mt30"},p.a.createElement(a.a,{flex:"80px",className:"font14"},"目录名称:"),p.a.createElement(a.a,{flex:"1"},p.a.createElement(u.a.Item,{name:"name",rules:[{required:!0,message:"请输入新名称"}]},p.a.createElement(D.a,{placeholder:"请输入名称,最大限制60个字符 ",maxLength:60})))))))}))),P=r("s7vb"),N=r("P48q"),M=r.n(N),F=D.a.Search,j=L.a.DirectoryTree,B=Object(m.a)((function(e){var t=e.user,r=e.loading;return{user:t,globalSetting:e.globalSetting,restful:e.restful,loading:r.models.index}}))((function(e){e.user,e.globalSetting,e.loading;var t=e.dispatch,r=e.restful,n=Object(d.a)(e,["user","globalSetting","loading","dispatch","restful"]),i=Object(g.useState)({content:"",message:"",status:0,contacts:[],address:"",data:[]}),a=Object(c.a)(i,2),s=(a[0],a[1],Object(g.useState)(!0)),f=Object(c.a)(s,2),v=(f[0],f[1],u.a.useForm()),m=(Object(c.a)(v,1)[0],Object(g.useState)("")),y=Object(c.a)(m,2),E=y[0],T=y[1],L=Object(g.useState)([{id:1,name:"新建文件"},{id:2,name:"新建同级目录"},{id:3,name:"重命名"},{id:4,name:"编辑"},{id:5,name:"删除"}]),D=Object(c.a)(L,1)[0],O=Object(g.useState)([]),C=Object(c.a)(O,2),_=C[0],w=C[1],N=Object(g.useState)([]),B=Object(c.a)(N,2),U=B[0],K=B[1],G=Object(g.useState)(!1),H=Object(c.a)(G,2),V=H[0],z=H[1],W=Object(g.useState)([]),q=Object(c.a)(W,2),Y=q[0],$=q[1];Object(g.useEffect)((function(){var e;if(null!==(e=r.restful)&&void 0!==e&&e.data){var t,i,a;$(Object(x.a)(null===(t=r.restful)||void 0===t?void 0:t.data));var s,o=0;if(null===(i=r.restful)||void 0===i||null===(a=i.data)||void 0===a||a.map((function(e){var t;e.id==n.match.params.id&&(o=e.id),0!=e.file_type||s||(s=e.id),null==e||null===(t=e.children)||void 0===t||t.map((function(t){s||(s=t.id),t.id==n.match.params.id&&(o=e.id)})),e.children||s||(s=e.id)})),!n.match.params.id&&s)return void n.history.push("/ch/rest/".concat(s));o&&setTimeout((function(){w([o]),K([Number(n.match.params.id||s)])}),200)}}),[r.restful]);var X=function e(r){return r.map((function(r){var i,a=r.title.indexOf(E),s=r.title.substr(0,a),u=r.title.substr(a+E.length),c=p.a.createElement("span",null,s,p.a.createElement("span",{className:"c-blue"},E),u,Object(b.o)()&&p.a.createElement(S.a,{placement:"right",title:E,content:function(){return function(e){return p.a.createElement("div",null,D.map((function(r,i){return p.a.createElement("p",{key:r.id,className:"current",onClick:function(){switch(r.id){case 1:n.history.push("/ch/rest/edit/".concat(e.id,"/0"));break;case 2:case 3:t({type:"restful/setActionTabs",payload:{key:r.name,data:e}});break;case 4:document.location.href="/ch/rest/edit/".concat(e.pid||0,"/").concat(e.id);break;case 5:A.a.confirm({title:"提示",content:"是否确定删除?",onOk:(i=Object(l.a)(h.a.mark((function r(){var n;return h.a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,Object(P.a)({id:e.id});case 2:0==(null==(n=r.sent)?void 0:n.status)&&(k.b.success("删除成功"),t({type:"restful/getRestful"}));case 4:case"end":return r.stop()}}),r)}))),function(){return i.apply(this,arguments)})})}var i}},r.name)})).filter((function(e){return!!e})).filter((function(t){return e.pid||0==e.file_type?t.key>3:4!=t.key})))}(r)},trigger:"hover"},p.a.createElement("span",{className:"iconfont icon-sandian ".concat(M.a.actions)})));if(""!==E&&(-1===a&&(null===(i=r.children)||void 0===i||!i.length)))return null;return r.children&&1===r.file_type?Object(o.a)(Object(o.a)({},r),{},{title:c,key:r.key,children:e(r.children)}):Object(o.a)(Object(o.a)({},r),{},{title:c,key:r.key,isLeaf:!0})})).filter((function(e){return!!e}))};return console.log("loop(treeData):",X(Y)),p.a.createElement("div",{className:M.a.tree},p.a.createElement(F,{style:{marginBottom:8},placeholder:"输入关键字检索",onChange:function(e){var t=e.target.value,r=Y.map((function(e){var r;return null!=e&&e.children&&null!=e&&null!==(r=e.children.filter((function(e){return e.title.indexOf(t)>-1})))&&void 0!==r&&r.length?e.id:null}));T(t),z(!0),console.log("expandedKeys:",r),w(r)}}),p.a.createElement(j,{multiple:!0,defaultExpandAll:!0,onSelect:function(e,t){0===t.node.file_type?n.history.push("/ch/rest/".concat(e[0])):K(Object(x.a)(e)),console.log("Trigger Select",e,t)},onExpand:function(e){w(e),console.log("Trigger Expand",e)},expandedKeys:_,selectedKeys:U,autoExpandParent:V,treeData:X(Y)}),p.a.createElement(R,null),p.a.createElement(I,null))}));t.default=Object(m.a)((function(e){var t=e.user,r=e.loading;return{user:t,globalSetting:e.globalSetting,restful:e.restful,loading:r.models.index}}))((function(e){e.user,e.globalSetting,e.loading;var t,r,f=e.dispatch,m=e.restful,E=Object(d.a)(e,["user","globalSetting","loading","dispatch","restful"]),S=Object(g.useState)({content:"",message:"",status:0,contacts:[],address:"",data:[]}),k=Object(c.a)(S,2),A=(k[0],k[1],Object(g.useState)(!0)),x=Object(c.a)(A,2),L=(x[0],x[1]),D=u.a.useForm(),O=(Object(c.a)(D,1)[0],E.match.params),C=function(){var e=Object(l.a)(h.a.mark((function e(){return h.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:f({type:"restful/getRestful"}),O.id&&f({type:"restful/getRestfulDetail",payload:Object(o.a)({},O)});case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();Object(g.useEffect)((function(){L(!0),C()}),[O.id]);var _=function(){var e;if(null!==(e=m.restful)&&void 0!==e&&e.data){var t,r,n=0;return null===(t=m.restful)||void 0===t||null===(r=t.data)||void 0===r||r.map((function(e){var t;null==e||null===(t=e.children)||void 0===t||t.map((function(t){t.id==E.match.params.id&&(n=e.id)})),e.children||n||(n=e.id)})),n}return 0};return p.a.createElement("section",null,p.a.createElement("aside",{className:"edu-container mt20"},p.a.createElement(s.a,null,p.a.createElement(s.a.Item,null,p.a.createElement(v.a,{to:"/"},"首页")),p.a.createElement(s.a.Item,null,p.a.createElement(v.a,{to:"/ch/rest"},"API文档"))),p.a.createElement("div",{className:"mt20"},p.a.createElement(i.a,{gutter:[20,20]},p.a.createElement(a.a,{flex:"300px"},p.a.createElement(B,E)),p.a.createElement(a.a,{flex:"1"},p.a.createElement("div",{className:T.a.info},p.a.createElement("h1",{style:{fontSize:28,paddingBottom:15,borderBottom:"1px solid #eaeaea",textAlign:"center"}},null===(t=m.restfulDetail)||void 0===t?void 0:t.name),p.a.createElement(y.a,{value:null===(r=m.restfulDetail)||void 0===r?void 0:r.description}))))),Object(b.o)()&&p.a.createElement("div",{className:T.a.bar},p.a.createElement(i.a,null,!!_()&&p.a.createElement(a.a,null,p.a.createElement(n.a,{title:"编辑文件"},p.a.createElement(v.a,{to:"/ch/rest/edit/".concat(_(),"/").concat(E.match.params.id),className:"icon-zhongmingming current"}))),p.a.createElement(a.a,null,p.a.createElement(n.a,{title:"添加文件"},p.a.createElement(v.a,{to:"/ch/rest/edit/".concat(_(),"/0"),className:"icon-tianjiatimu current"}))),p.a.createElement(a.a,null,p.a.createElement(n.a,{title:"新建文件夹"},p.a.createElement("span",{className:"icon-wenjianjia1 current",onClick:function(){f({type:"restful/setActionTabs",payload:{key:"新建同级目录"}})}})))))))}))},NvD2:
|
|
|
/*!******************************************************!*\
|
|
|
!*** ./node_modules/rc-tree/es/utils/conductUtil.js ***!
|
|
|
\******************************************************/
|
|
|
/*! exports provided: isCheckDisabled, conductCheck */
|
|
|
/*! exports used: conductCheck */function(e,t,r){"use strict";r.d(t,"a",(function(){return s}));var n=r(/*! rc-util/es/warning */"Kwbf");function i(e,t){var r=new Set;return e.forEach((function(e){t.has(e)||r.add(e)})),r}function a(e){var t=e||{},r=t.disabled,n=t.disableCheckbox,i=t.checkable;return!(!r&&!n)||!1===i}function s(e,t,r,s){var o,l=[];o=s||a;var u=new Set(e.filter((function(e){var t=!!r[e];return t||l.push(e),t}))),c=new Map,d=0;return Object.keys(r).forEach((function(e){var t=r[e],n=t.level,i=c.get(n);i||(i=new Set,c.set(n,i)),i.add(t),d=Math.max(d,n)})),Object(n.a)(!l.length,"Tree missing follow keys: ".concat(l.slice(0,100).map((function(e){return"'".concat(e,"'")})).join(", "))),!0===t?function(e,t,r,n){for(var a=new Set(e),s=new Set,o=0;o<=r;o+=1){(t.get(o)||new Set).forEach((function(e){var t=e.key,r=e.node,i=e.children,s=void 0===i?[]:i;a.has(t)&&!n(r)&&s.filter((function(e){return!n(e.node)})).forEach((function(e){a.add(e.key)}))}))}for(var l=new Set,u=r;u>=0;u-=1){(t.get(u)||new Set).forEach((function(e){var t=e.parent,r=e.node;if(!n(r)&&e.parent&&!l.has(e.parent.key))if(n(e.parent.node))l.add(t.key);else{var i=!0,o=!1;(t.children||[]).filter((function(e){return!n(e.node)})).forEach((function(e){var t=e.key,r=a.has(t);i&&!r&&(i=!1),o||!r&&!s.has(t)||(o=!0)})),i&&a.add(t.key),o&&s.add(t.key),l.add(t.key)}}))}return{checkedKeys:Array.from(a),halfCheckedKeys:Array.from(i(s,a))}}(u,c,d,o):function(e,t,r,n,a){for(var s=new Set(e),o=new Set(t),l=0;l<=n;l+=1){(r.get(l)||new Set).forEach((function(e){var t=e.key,r=e.node,n=e.children,i=void 0===n?[]:n;s.has(t)||o.has(t)||a(r)||i.filter((function(e){return!a(e.node)})).forEach((function(e){s.delete(e.key)}))}))}o=new Set;for(var u=new Set,c=n;c>=0;c-=1){(r.get(c)||new Set).forEach((function(e){var t=e.parent,r=e.node;if(!a(r)&&e.parent&&!u.has(e.parent.key))if(a(e.parent.node))u.add(t.key);else{var n=!0,i=!1;(t.children||[]).filter((function(e){return!a(e.node)})).forEach((function(e){var t=e.key,r=s.has(t);n&&!r&&(n=!1),i||!r&&!o.has(t)||(i=!0)})),n||s.delete(t.key),i&&o.add(t.key),u.add(t.key)}}))}return{checkedKeys:Array.from(s),halfCheckedKeys:Array.from(i(o,s))}}(u,t.halfCheckedKeys,c,d,o)}},OZM5:
|
|
|
/*!*****************************************!*\
|
|
|
!*** ./node_modules/rc-tree/es/util.js ***!
|
|
|
\*****************************************/
|
|
|
/*! exports provided: arrDel, arrAdd, posToArr, getPosition, isTreeNode, getDragNodesKeys, calcDropPosition, calcSelectedKeys, convertDataToTree, parseCheckedKeys, conductExpandParent, getDataAndAria */
|
|
|
/*! exports used: arrAdd, arrDel, calcDropPosition, calcSelectedKeys, conductExpandParent, getDataAndAria, getDragNodesKeys, getPosition, isTreeNode, parseCheckedKeys, posToArr */function(e,t,r){"use strict";r.d(t,"b",(function(){return s})),r.d(t,"a",(function(){return o})),r.d(t,"k",(function(){return l})),r.d(t,"h",(function(){return u})),r.d(t,"i",(function(){return c})),r.d(t,"g",(function(){return d})),r.d(t,"c",(function(){return f})),r.d(t,"d",(function(){return h})),r.d(t,"j",(function(){return g})),r.d(t,"e",(function(){return p})),r.d(t,"f",(function(){return v}));var n=r(/*! @babel/runtime/helpers/esm/toConsumableArray */"KQm4"),i=r(/*! @babel/runtime/helpers/esm/typeof */"U8pU"),a=(r(/*! @babel/runtime/helpers/esm/objectWithoutProperties */"Ff2n"),r(/*! react */"q1tI"),r(/*! rc-util/es/warning */"Kwbf"));r(/*! ./TreeNode */"WaYH");function s(e,t){var r=e.slice(),n=r.indexOf(t);return n>=0&&r.splice(n,1),r}function o(e,t){var r=e.slice();return-1===r.indexOf(t)&&r.push(t),r}function l(e){return e.split("-")}function u(e,t){return"".concat(e,"-").concat(t)}function c(e){return e&&e.type&&e.type.isTreeNode}function d(e,t){var r=[e];return function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];t.forEach((function(t){var n=t.key,i=t.children;r.push(n),e(i)}))}(t[e].children),r}function f(e,t){var r=e.clientY,n=t.selectHandle.getBoundingClientRect(),i=n.top,a=n.bottom,s=n.height,o=Math.max(.25*s,2);return r<=i+o?-1:r>=a-o?1:0}function h(e,t){if(e)return t.multiple?e.slice():e.length?[e[0]]:e}function g(e){if(!e)return null;var t;if(Array.isArray(e))t={checkedKeys:e,halfCheckedKeys:void 0};else{if("object"!==Object(i.a)(e))return Object(a.a)(!1,"`checkedKeys` is not an array or an object"),null;t={checkedKeys:e.checked||void 0,halfCheckedKeys:e.halfChecked||void 0}}return t}function p(e,t){var r=new Set;return(e||[]).forEach((function(e){!function e(n){if(!r.has(n)){var i=t[n];if(i){r.add(n);var a=i.parent;i.node.disabled||a&&e(a.key)}}}(e)})),Object(n.a)(r)}function v(e){var t={};return Object.keys(e).forEach((function(r){(r.startsWith("data-")||r.startsWith("aria-"))&&(t[r]=e[r])})),t}},P48q:
|
|
|
/*!*****************************************************************!*\
|
|
|
!*** ./src/pages/RestFul/components/LeftBar/index.less?modules ***!
|
|
|
\*****************************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,t,r){e.exports={flex_box_center:"flex_box_center___BHtvi",flex_space_between:"flex_space_between___1noDr",flex_box_vertical_center:"flex_box_vertical_center___2UDAc",flex_box_center_end:"flex_box_center_end___2j8--",flex_box_column:"flex_box_column___3X60k",tree:"tree___2kCYs",actions:"actions___10Q_6"}},SJMd:
|
|
|
/*!****************************************************!*\
|
|
|
!*** ./node_modules/code-prettify/src/prettify.js ***!
|
|
|
\****************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,t){window.PR_SHOULD_USE_CONTINUATION=!0,function(){var e=window,t=["break,continue,do,else,for,if,return,while"],r=[[t,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,restrict,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],n=[r,"alignas,alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,noexcept,noreturn,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],i=[r,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],a=[r,"abstract,add,alias,as,ascending,async,await,base,bool,by,byte,checked,decimal,delegate,descending,dynamic,event,finally,fixed,foreach,from,get,global,group,implicit,in,interface,internal,into,is,join,let,lock,null,object,out,override,orderby,params,partial,readonly,ref,remove,sbyte,sealed,select,set,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,value,var,virtual,where,yield"],s=[r,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],o="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",l=[t,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],u=[t,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],c=[t,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],d=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/;function f(e,t,r,n,i){if(r){var a={sourceNode:e,pre:1,langExtension:null,numberLines:null,sourceCode:r,spans:null,basePos:t,decorations:null};n(a),i.push.apply(i,a.decorations)}}var h=/\S/;function g(e){for(var t=void 0,r=e.firstChild;r;r=r.nextSibling){var n=r.nodeType;t=1===n?t?e:r:3===n&&h.test(r.nodeValue)?e:t}return t===e?void 0:t}function p(e,t){var r,n={};!function(){for(var i=e.concat(t),a=[],s={},o=0,l=i.length;o<l;++o){var u=i[o],c=u[3];if(c)for(var d=c.length;--d>=0;)n[c.charAt(d)]=u;var f=u[1],h=""+f;s.hasOwnProperty(h)||(a.push(f),s[h]=null)}a.push(/[\0-\uffff]/),r=function(e){for(var t=0,r=!1,n=!1,i=0,a=e.length;i<a;++i){if((f=e[i]).ignoreCase)n=!0;else if(/[a-z]/i.test(f.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){r=!0,n=!1;break}}var s={b:8,t:9,n:10,v:11,f:12,r:13};function o(e){var t=e.charCodeAt(0);if(92!==t)return t;var r=e.charAt(1);return(t=s[r])||("0"<=r&&r<="7"?parseInt(e.substring(1),8):"u"===r||"x"===r?parseInt(e.substring(2),16):e.charCodeAt(1))}function l(e){if(e<32)return(e<16?"\\x0":"\\x")+e.toString(16);var t=String.fromCharCode(e);return"\\"===t||"-"===t||"]"===t||"^"===t?"\\"+t:t}function u(e){var t=e.substring(1,e.length-1).match(new RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]","g")),r=[],n="^"===t[0],i=["["];n&&i.push("^");for(var a=n?1:0,s=t.length;a<s;++a){var u=t[a];if(/\\[bdsw]/i.test(u))i.push(u);else{var c,d=o(u);a+2<s&&"-"===t[a+1]?(c=o(t[a+2]),a+=2):c=d,r.push([d,c]),c<65||d>122||(c<65||d>90||r.push([32|Math.max(65,d),32|Math.min(c,90)]),c<97||d>122||r.push([-33&Math.max(97,d),-33&Math.min(c,122)]))}}r.sort((function(e,t){return e[0]-t[0]||t[1]-e[1]}));var f=[],h=[];for(a=0;a<r.length;++a){(g=r[a])[0]<=h[1]+1?h[1]=Math.max(h[1],g[1]):f.push(h=g)}for(a=0;a<f.length;++a){var g=f[a];i.push(l(g[0])),g[1]>g[0]&&(g[1]+1>g[0]&&i.push("-"),i.push(l(g[1])))}return i.push("]"),i.join("")}function c(e){for(var n=e.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g")),i=n.length,a=[],s=0,o=0;s<i;++s){if("("===(d=n[s]))++o;else if("\\"===d.charAt(0)){(c=+d.substring(1))&&(c<=o?a[c]=-1:n[s]=l(c))}}for(s=1;s<a.length;++s)-1===a[s]&&(a[s]=++t);for(s=0,o=0;s<i;++s){if("("===(d=n[s]))a[++o]||(n[s]="(?:");else if("\\"===d.charAt(0)){var c;(c=+d.substring(1))&&c<=o&&(n[s]="\\"+a[c])}}for(s=0;s<i;++s)"^"===n[s]&&"^"!==n[s+1]&&(n[s]="");if(e.ignoreCase&&r)for(s=0;s<i;++s){var d,f=(d=n[s]).charAt(0);d.length>=2&&"["===f?n[s]=u(d):"\\"!==f&&(n[s]=d.replace(/[a-zA-Z]/g,(function(e){var t=e.charCodeAt(0);return"["+String.fromCharCode(-33&t,32|t)+"]"})))}return n.join("")}var d=[];for(i=0,a=e.length;i<a;++i){var f;if((f=e[i]).global||f.multiline)throw new Error(""+f);d.push("(?:"+c(f)+")")}return new RegExp(d.join("|"),n?"gi":"g")}(a)}();var i=t.length,a=function(e){for(var s=e.sourceCode,o=e.basePos,l=e.sourceNode,u=[o,"pln"],c=0,d=s.match(r)||[],h={},g=0,p=d.length;g<p;++g){var v,m=d[g],y=h[m],b=void 0;if("string"==typeof y)v=!1;else{var E=n[m.charAt(0)];if(E)b=m.match(E[1]),y=E[0];else{for(var S=0;S<i;++S)if(E=t[S],b=m.match(E[1])){y=E[0];break}b||(y="pln")}!(v=y.length>=5&&"lang-"===y.substring(0,5))||b&&"string"==typeof b[1]||(v=!1,y="src"),v||(h[m]=y)}var k=c;if(c+=m.length,v){var A=b[1],x=m.indexOf(A),L=x+A.length;b[2]&&(x=(L=m.length-b[2].length)-A.length);var D=y.substring(5);f(l,o+k,m.substring(0,x),a,u),f(l,o+k+x,A,T(D,A),u),f(l,o+k+L,m.substring(L),a,u)}else u.push(o+k,y)}e.decorations=u};return a}function v(e){var t=[],r=[];e.tripleQuotedStrings?t.push(["str",/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""]):e.multiLineStrings?t.push(["str",/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):t.push(["str",/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"]),e.verbatimStrings&&r.push(["str",/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var n=e.hashComments;n&&(e.cStyleComments?(n>1?t.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):t.push(["com",/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),r.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):t.push(["com",/^#[^\r\n]*/,null,"#"])),e.cStyleComments&&(r.push(["com",/^\/\/[^\r\n]*/,null]),r.push(["com",/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var i=e.regexLiterals;if(i){var a=i>1?"":"\n\r",s=a?".":"[\\S\\s]",o="/(?=[^/*"+a+"])(?:[^/\\x5B\\x5C"+a+"]|\\x5C"+s+"|\\x5B(?:[^\\x5C\\x5D"+a+"]|\\x5C"+s+")*(?:\\x5D|$))+/";r.push(["lang-regex",RegExp("^(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*("+o+")")])}var l=e.types;l&&r.push(["typ",l]);var u=(""+e.keywords).replace(/^ | $/g,"");u.length&&r.push(["kwd",new RegExp("^(?:"+u.replace(/[\s,]+/g,"|")+")\\b"),null]),t.push(["pln",/^\s+/,null," \r\n\t "]);var c="^.[^\\s\\w.$@'\"`/\\\\]*";return e.regexLiterals&&(c+="(?!s*/)"),r.push(["lit",/^@[a-z_$][a-z_$@0-9]*/i,null],["typ",/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],["pln",/^[a-z_$][a-z_$@0-9]*/i,null],["lit",new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],["pln",/^\\[\s\S]?/,null],["pun",new RegExp(c),null]),p(t,r)}var m=v({keywords:[n,a,i,s,o,l,u,c],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function y(e,t,r){for(var n=/(?:^|\s)nocode(?:\s|$)/,i=/\r\n?|\n/,a=e.ownerDocument,s=a.createElement("li");e.firstChild;)s.appendChild(e.firstChild);var o=[s];function l(e){var t=e.nodeType;if(1!=t||n.test(e.className)){if((3==t||4==t)&&r){var s=e.nodeValue,o=s.match(i);if(o){var c=s.substring(0,o.index);e.nodeValue=c;var d=s.substring(o.index+o[0].length);if(d)e.parentNode.insertBefore(a.createTextNode(d),e.nextSibling);u(e),c||e.parentNode.removeChild(e)}}}else if("br"===e.nodeName)u(e),e.parentNode&&e.parentNode.removeChild(e);else for(var f=e.firstChild;f;f=f.nextSibling)l(f)}function u(e){for(;!e.nextSibling;)if(!(e=e.parentNode))return;for(var t,r=function e(t,r){var n=r?t.cloneNode(!1):t,i=t.parentNode;if(i){var a=e(i,1),s=t.nextSibling;a.appendChild(n);for(var o=s;o;o=s)s=o.nextSibling,a.appendChild(o)}return n}(e.nextSibling,0);(t=r.parentNode)&&1===t.nodeType;)r=t;o.push(r)}for(var c=0;c<o.length;++c)l(o[c]);t===(0|t)&&o[0].setAttribute("value",t);var d=a.createElement("ol");d.className="linenums";for(var f=Math.max(0,t-1|0)||0,h=(c=0,o.length);c<h;++c)(s=o[c]).className="L"+(c+f)%10,s.firstChild||s.appendChild(a.createTextNode(" ")),d.appendChild(s);e.appendChild(d)}var b={};function E(t,r){for(var n=r.length;--n>=0;){var i=r[n];b.hasOwnProperty(i)?e.console&&console.warn("cannot override language handler %s",i):b[i]=t}}function T(e,t){return e&&b.hasOwnProperty(e)||(e=/^\s*</.test(t)?"default-markup":"default-code"),b[e]}function S(t){var r,n,i,a,s,o,l,u=t.langExtension;try{var c=(r=t.sourceNode,n=t.pre,i=/(?:^|\s)nocode(?:\s|$)/,a=[],s=0,o=[],l=0,function e(t){var r=t.nodeType;if(1==r){if(i.test(t.className))return;for(var u=t.firstChild;u;u=u.nextSibling)e(u);var c=t.nodeName.toLowerCase();"br"!==c&&"li"!==c||(a[l]="\n",o[l<<1]=s++,o[l++<<1|1]=t)}else if(3==r||4==r){var d=t.nodeValue;d.length&&(d=n?d.replace(/\r\n?/g,"\n"):d.replace(/[ \t\r\n]+/g," "),a[l]=d,o[l<<1]=s,s+=d.length,o[l++<<1|1]=t)}}(r),{sourceCode:a.join("").replace(/\n$/,""),spans:o}),d=c.sourceCode;t.sourceCode=d,t.spans=c.spans,t.basePos=0,T(u,d)(t),function(e){var t=/\bMSIE\s(\d+)/.exec(navigator.userAgent);t=t&&+t[1]<=8;var r,n,i=/\n/g,a=e.sourceCode,s=a.length,o=0,l=e.spans,u=l.length,c=0,d=e.decorations,f=d.length,h=0;for(d[f]=s,n=r=0;n<f;)d[n]!==d[n+2]?(d[r++]=d[n++],d[r++]=d[n++]):n+=2;for(f=r,n=r=0;n<f;){for(var g=d[n],p=d[n+1],v=n+2;v+2<=f&&d[v+1]===p;)v+=2;d[r++]=g,d[r++]=p,n=v}f=d.length=r;var m=e.sourceNode,y="";m&&(y=m.style.display,m.style.display="none");try{for(;c<u;){l[c];var b,E=l[c+2]||s,T=d[h+2]||s,S=(v=Math.min(E,T),l[c+1]);if(1!==S.nodeType&&(b=a.substring(o,v))){t&&(b=b.replace(i,"\r")),S.nodeValue=b;var k=S.ownerDocument,A=k.createElement("span");A.className=d[h+1];var x=S.parentNode;x.replaceChild(A,S),A.appendChild(S),o<E&&(l[c+1]=S=k.createTextNode(a.substring(v,E)),x.insertBefore(S,A.nextSibling))}(o=v)>=E&&(c+=2),o>=T&&(h+=2)}}finally{m&&(m.style.display=y)}}(t)}catch(t){e.console&&console.log(t&&t.stack||t)}}function k(e,t,r){var n=r||!1,i=t||null,a=document.createElement("div");return a.innerHTML="<pre>"+e+"</pre>",a=a.firstChild,n&&y(a,n,!0),S({langExtension:i,numberLines:n,sourceNode:a,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null}),a.innerHTML}function A(t,r){var n=r||document.body,i=n.ownerDocument||document;function a(e){return n.getElementsByTagName(e)}for(var s=[a("pre"),a("code"),a("xmp")],o=[],l=0;l<s.length;++l)for(var u=0,c=s[l].length;u<c;++u)o.push(s[l][u]);s=null;var d=Date;d.now||(d={now:function(){return+new Date}});var f=0,h=/\blang(?:uage)?-([\w.]+)(?!\S)/,p=/\bprettyprint\b/,v=/\bprettyprinted\b/,m=/pre|xmp/i,b=/^code$/i,E=/^(?:pre|code|xmp)$/i,T={};!function r(){for(var n=e.PR_SHOULD_USE_CONTINUATION?d.now()+250:1/0;f<o.length&&d.now()<n;f++){for(var a=o[f],s=T,l=a;l=l.previousSibling;){var u=l.nodeType,c=(7===u||8===u)&&l.nodeValue;if(c?!/^\??prettify\b/.test(c):3!==u||/\S/.test(l.nodeValue))break;if(c){s={},c.replace(/\b(\w+)=([\w:.%+-]+)/g,(function(e,t,r){s[t]=r}));break}}var k=a.className;if((s!==T||p.test(k))&&!v.test(k)){for(var A=!1,x=a.parentNode;x;x=x.parentNode){var L=x.tagName;if(E.test(L)&&x.className&&p.test(x.className)){A=!0;break}}if(!A){a.className+=" prettyprinted";var D,O,C=s.lang;if(!C)!(C=k.match(h))&&(D=g(a))&&b.test(D.tagName)&&(C=D.className.match(h)),C&&(C=C[1]);if(m.test(a.tagName))O=1;else{var _=a.currentStyle,w=i.defaultView,R=_?_.whiteSpace:w&&w.getComputedStyle?w.getComputedStyle(a,null).getPropertyValue("white-space"):0;O=R&&"pre"===R.substring(0,3)}var I=s.linenums;(I="true"===I||+I)||(I=!!(I=k.match(/\blinenums\b(?::(\d+))?/))&&(!I[1]||!I[1].length||+I[1])),I&&y(a,I,O),S({langExtension:C,sourceNode:a,numberLines:I,pre:O,sourceCode:null,basePos:null,spans:null,decorations:null})}}}f<o.length?e.setTimeout(r,250):"function"==typeof t&&t()}()}E(m,["default-code"]),E(p([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]),E(p([["pln",/^[\s]+/,null," \t\r\n"],["atv",/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],["pun",/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]),E(p([],[["atv",/^[\s\S]+/]]),["uq.val"]),E(v({keywords:n,hashComments:!0,cStyleComments:!0,types:d}),["c","cc","cpp","cxx","cyc","m"]),E(v({keywords:"null,true,false"}),["json"]),E(v({keywords:a,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:d}),["cs"]),E(v({keywords:i,cStyleComments:!0}),["java"]),E(v({keywords:c,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),E(v({keywords:l,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),E(v({keywords:o,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),E(v({keywords:u,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),E(v({keywords:s,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),E(v({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),E(p([],[["str",/^[\s\S]+/]]),["regex"]);var x=e.PR={createSimpleLexer:p,registerLangHandler:E,sourceDecorator:v,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ",prettyPrintOne:k,prettyPrint:A},L=e.define;"function"==typeof L&&L.amd&&L("google-code-prettify",[],(function(){return x}))}()},"U/Y8":
|
|
|
/*!**********************************************!*\
|
|
|
!*** ./src/pages/RestFul/index.less?modules ***!
|
|
|
\**********************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,t,r){e.exports={flex_box_center:"flex_box_center___2aRVA",flex_space_between:"flex_space_between___12c3F",flex_box_vertical_center:"flex_box_vertical_center___30OYS",flex_box_center_end:"flex_box_center_end___12QBt",flex_box_column:"flex_box_column___t6urT",info:"info___2BaCz",bar:"bar___3Aega"}},WaYH:
|
|
|
/*!*********************************************************!*\
|
|
|
!*** ./node_modules/rc-tree/es/TreeNode.js + 1 modules ***!
|
|
|
\*********************************************************/
|
|
|
/*! exports provided: InternalTreeNode, default */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/createClass.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/createSuper.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/defineProperty.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/inherits.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/classnames/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-tree/es/contextTypes.js because of ./node_modules/rc-tree/es/Tree.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-tree/es/util.js because of ./node_modules/antd/es/tree/DirectoryTree.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-tree/es/utils/treeUtil.js because of ./node_modules/antd/es/tree/DirectoryTree.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */function(e,t,r){"use strict";var n=r("rePB"),i=r("Ff2n"),a=r("VTBJ"),s=r("1OyB"),o=r("vuIU"),l=r("JX7q"),u=r("Ji7U"),c=r("LK+K"),d=r("q1tI"),f=r("TSYQ"),h=r.n(f),g=r("sboe"),p=r("OZM5"),v=function(e){var t=e.prefixCls,r=e.level,i=e.isStart,a=e.isEnd;if(!r)return null;for(var s="".concat(t,"-indent-unit"),o=[],l=0;l<r;l+=1){var u;o.push(d.createElement("span",{key:l,className:h()(s,(u={},Object(n.a)(u,"".concat(s,"-start"),i[l+1]),Object(n.a)(u,"".concat(s,"-end"),a[l+1]),Object(n.a)(u,"".concat(s,"-end-first-level"),!l&&a[0]),u))}))}return d.createElement("span",{"aria-hidden":"true",className:"".concat(t,"-indent")},o)},m=r("815F"),y=function(e){Object(u.a)(r,e);var t=Object(c.a)(r);function r(){var e;return Object(s.a)(this,r),(e=t.apply(this,arguments)).state={dragNodeHighlight:!1},e.onSelectorClick=function(t){(0,e.props.context.onNodeClick)(t,Object(m.b)(e.props)),e.isSelectable()?e.onSelect(t):e.onCheck(t)},e.onSelectorDoubleClick=function(t){(0,e.props.context.onNodeDoubleClick)(t,Object(m.b)(e.props))},e.onSelect=function(t){if(!e.isDisabled()){var r=e.props.context.onNodeSelect;t.preventDefault(),r(t,Object(m.b)(e.props))}},e.onCheck=function(t){if(!e.isDisabled()){var r=e.props,n=r.disableCheckbox,i=r.checked,a=e.props.context.onNodeCheck;if(e.isCheckable()&&!n){t.preventDefault();var s=!i;a(t,Object(m.b)(e.props),s)}}},e.onMouseEnter=function(t){(0,e.props.context.onNodeMouseEnter)(t,Object(m.b)(e.props))},e.onMouseLeave=function(t){(0,e.props.context.onNodeMouseLeave)(t,Object(m.b)(e.props))},e.onContextMenu=function(t){(0,e.props.context.onNodeContextMenu)(t,Object(m.b)(e.props))},e.onDragStart=function(t){var r=e.props.context.onNodeDragStart;t.stopPropagation(),e.setState({dragNodeHighlight:!0}),r(t,Object(l.a)(e));try{t.dataTransfer.setData("text/plain","")}catch(e){}},e.onDragEnter=function(t){var r=e.props.context.onNodeDragEnter;t.preventDefault(),t.stopPropagation(),r(t,Object(l.a)(e))},e.onDragOver=function(t){var r=e.props.context.onNodeDragOver;t.preventDefault(),t.stopPropagation(),r(t,Object(l.a)(e))},e.onDragLeave=function(t){var r=e.props.context.onNodeDragLeave;t.stopPropagation(),r(t,Object(l.a)(e))},e.onDragEnd=function(t){var r=e.props.context.onNodeDragEnd;t.stopPropagation(),e.setState({dragNodeHighlight:!1}),r(t,Object(l.a)(e))},e.onDrop=function(t){var r=e.props.context.onNodeDrop;t.preventDefault(),t.stopPropagation(),e.setState({dragNodeHighlight:!1}),r(t,Object(l.a)(e))},e.onExpand=function(t){(0,e.props.context.onNodeExpand)(t,Object(m.b)(e.props))},e.setSelectHandle=function(t){e.selectHandle=t},e.getNodeState=function(){var t=e.props.expanded;return e.isLeaf()?null:t?"open":"close"},e.hasChildren=function(){var t=e.props.eventKey;return!!((e.props.context.keyEntities[t]||{}).children||[]).length},e.isLeaf=function(){var t=e.props,r=t.isLeaf,n=t.loaded,i=e.props.context.loadData,a=e.hasChildren();return!1!==r&&(r||!i&&!a||i&&n&&!a)},e.isDisabled=function(){var t=e.props.disabled;return!(!e.props.context.disabled&&!t)},e.isCheckable=function(){var t=e.props.checkable,r=e.props.context.checkable;return!(!r||!1===t)&&r},e.syncLoadData=function(t){var r=t.expanded,n=t.loading,i=t.loaded,a=e.props.context,s=a.loadData,o=a.onNodeLoad;n||s&&r&&!e.isLeaf()&&(e.hasChildren()||i||o(Object(m.b)(e.props)))},e.renderSwitcher=function(){var t=e.props,r=t.expanded,n=t.switcherIcon,i=e.props.context,s=i.prefixCls,o=i.switcherIcon,l=n||o;if(e.isLeaf())return d.createElement("span",{className:h()("".concat(s,"-switcher"),"".concat(s,"-switcher-noop"))},"function"==typeof l?l(Object(a.a)(Object(a.a)({},e.props),{},{isLeaf:!0})):l);var u=h()("".concat(s,"-switcher"),"".concat(s,"-switcher_").concat(r?"open":"close"));return d.createElement("span",{onClick:e.onExpand,className:u},"function"==typeof l?l(Object(a.a)(Object(a.a)({},e.props),{},{isLeaf:!1})):l)},e.renderCheckbox=function(){var t=e.props,r=t.checked,n=t.halfChecked,i=t.disableCheckbox,a=e.props.context.prefixCls,s=e.isDisabled(),o=e.isCheckable();if(!o)return null;var l="boolean"!=typeof o?o:null;return d.createElement("span",{className:h()("".concat(a,"-checkbox"),r&&"".concat(a,"-checkbox-checked"),!r&&n&&"".concat(a,"-checkbox-indeterminate"),(s||i)&&"".concat(a,"-checkbox-disabled")),onClick:e.onCheck},l)},e.renderIcon=function(){var t=e.props.loading,r=e.props.context.prefixCls;return d.createElement("span",{className:h()("".concat(r,"-iconEle"),"".concat(r,"-icon__").concat(e.getNodeState()||"docu"),t&&"".concat(r,"-icon_loading"))})},e.renderSelector=function(){var t,r,n=e.state.dragNodeHighlight,i=e.props,a=i.title,s=i.selected,o=i.icon,l=i.loading,u=i.data,c=e.props.context,f=c.prefixCls,g=c.showIcon,p=c.icon,v=c.draggable,m=c.loadData,y=c.titleRender,b=e.isDisabled(),E="".concat(f,"-node-content-wrapper");if(g){var T=o||p;t=T?d.createElement("span",{className:h()("".concat(f,"-iconEle"),"".concat(f,"-icon__customize"))},"function"==typeof T?T(e.props):T):e.renderIcon()}else m&&l&&(t=e.renderIcon());r="function"==typeof a?a(u):y?y(u):a;var S=d.createElement("span",{className:"".concat(f,"-title")},r);return d.createElement("span",{ref:e.setSelectHandle,title:"string"==typeof a?a:"",className:h()("".concat(E),"".concat(E,"-").concat(e.getNodeState()||"normal"),!b&&(s||n)&&"".concat(f,"-node-selected"),!b&&v&&"draggable"),draggable:!b&&v||void 0,"aria-grabbed":!b&&v||void 0,onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave,onContextMenu:e.onContextMenu,onClick:e.onSelectorClick,onDoubleClick:e.onSelectorDoubleClick,onDragStart:v?e.onDragStart:void 0},t,S)},e}return Object(o.a)(r,[{key:"componentDidMount",value:function(){this.syncLoadData(this.props)}},{key:"componentDidUpdate",value:function(){this.syncLoadData(this.props)}},{key:"isSelectable",value:function(){var e=this.props.selectable,t=this.props.context.selectable;return"boolean"==typeof e?e:t}},{key:"render",value:function(){var e,t=this.props,r=t.eventKey,a=t.className,s=t.style,o=t.dragOver,l=t.dragOverGapTop,u=t.dragOverGapBottom,c=t.isLeaf,f=t.isStart,g=t.isEnd,y=t.expanded,b=t.selected,E=t.checked,T=t.halfChecked,S=t.loading,k=t.domRef,A=t.active,x=t.onMouseMove,L=Object(i.a)(t,["eventKey","className","style","dragOver","dragOverGapTop","dragOverGapBottom","isLeaf","isStart","isEnd","expanded","selected","checked","halfChecked","loading","domRef","active","onMouseMove"]),D=this.props.context,O=D.prefixCls,C=D.filterTreeNode,_=D.draggable,w=D.keyEntities,R=this.isDisabled(),I=Object(p.f)(L),P=(w[r]||{}).level,N=g[g.length-1];return d.createElement("div",Object.assign({ref:k,className:h()(a,"".concat(O,"-treenode"),(e={},Object(n.a)(e,"".concat(O,"-treenode-disabled"),R),Object(n.a)(e,"".concat(O,"-treenode-switcher-").concat(y?"open":"close"),!c),Object(n.a)(e,"".concat(O,"-treenode-checkbox-checked"),E),Object(n.a)(e,"".concat(O,"-treenode-checkbox-indeterminate"),T),Object(n.a)(e,"".concat(O,"-treenode-selected"),b),Object(n.a)(e,"".concat(O,"-treenode-loading"),S),Object(n.a)(e,"".concat(O,"-treenode-active"),A),Object(n.a)(e,"".concat(O,"-treenode-leaf-last"),N),Object(n.a)(e,"drag-over",!R&&o),Object(n.a)(e,"drag-over-gap-top",!R&&l),Object(n.a)(e,"drag-over-gap-bottom",!R&&u),Object(n.a)(e,"filter-node",C&&C(Object(m.b)(this.props))),e)),style:s,onDragEnter:_?this.onDragEnter:void 0,onDragOver:_?this.onDragOver:void 0,onDragLeave:_?this.onDragLeave:void 0,onDrop:_?this.onDrop:void 0,onDragEnd:_?this.onDragEnd:void 0,onMouseMove:x},I),d.createElement(v,{prefixCls:O,level:P,isStart:f,isEnd:g}),this.renderSwitcher(),this.renderCheckbox(),this.renderSelector())}}]),r}(d.Component),b=function(e){return d.createElement(g.a.Consumer,null,(function(t){return d.createElement(y,Object.assign({},e,{context:t}))}))};b.displayName="TreeNode",b.defaultProps={title:"---"},b.isTreeNode=1;t.a=b},Y1PL:
|
|
|
/*!**********************************************************!*\
|
|
|
!*** ./node_modules/rc-textarea/es/index.js + 7 modules ***!
|
|
|
\**********************************************************/
|
|
|
/*! exports provided: ResizableTextArea, default */
|
|
|
/*! all exports used */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/createClass.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/createSuper.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/defineProperty.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/extends.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/inherits.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/classnames/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/Children/toArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/Dom/findDOMNode.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/omit.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/ref.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/warning.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js (<- Module uses injected variables (global)) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/shallowequal/index.js (<- Module is not an ECMAScript module) */function(e,t,r){"use strict";r.r(t),r.d(t,"ResizableTextArea",(function(){return I}));var n=r("wx14"),i=r("1OyB"),a=r("vuIU"),s=r("Ji7U"),o=r("LK+K"),l=r("q1tI"),u=r("VTBJ"),c=r("rePB"),d=r("Zm9Q"),f=(r("Kwbf"),r("c+Xe")),h=r("m+aA"),g=r("bdgK"),p=new Map;var v=new g.default((function(e){e.forEach((function(e){var t,r=e.target;null===(t=p.get(r))||void 0===t||t.forEach((function(e){return e(r)}))}))}));var m=function(e){Object(s.a)(r,e);var t=Object(o.a)(r);function r(){return Object(i.a)(this,r),t.apply(this,arguments)}return Object(a.a)(r,[{key:"render",value:function(){return this.props.children}}]),r}(l.Component),y=l.createContext(null);function b(e){var t=e.children,r=e.disabled,n=l.useRef(null),i=l.useRef(null),a=l.useContext(y),s=l.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),o=l.isValidElement(t)&&Object(f.c)(t),c=o?t.ref:null,d=l.useMemo((function(){return Object(f.a)(c,n)}),[c,n]),g=l.useRef(e);g.current=e;var b=l.useCallback((function(e){var t=g.current,r=t.onResize,n=t.data,i=e.getBoundingClientRect(),o=i.width,l=i.height,c=e.offsetWidth,d=e.offsetHeight,f=Math.floor(o),h=Math.floor(l);if(s.current.width!==f||s.current.height!==h||s.current.offsetWidth!==c||s.current.offsetHeight!==d){var p={width:f,height:h,offsetWidth:c,offsetHeight:d};s.current=p;var v=c===Math.round(o)?o:c,m=d===Math.round(l)?l:d,y=Object(u.a)(Object(u.a)({},p),{},{offsetWidth:v,offsetHeight:m});null==a||a(y,e,n),r&&Promise.resolve().then((function(){r(y,e)}))}}),[]);return l.useEffect((function(){var e,t,a=Object(h.a)(n.current)||Object(h.a)(i.current);return a&&!r&&(e=a,t=b,p.has(e)||(p.set(e,new Set),v.observe(e)),p.get(e).add(t)),function(){return function(e,t){p.has(e)&&(p.get(e).delete(t),p.get(e).size||(v.unobserve(e),p.delete(e)))}(a,b)}}),[n.current,r]),l.createElement(m,{ref:i},o?l.cloneElement(t,{ref:d}):t)}function E(e){var t=e.children;return Object(d.a)(t).map((function(t,r){var i=(null==t?void 0:t.key)||"".concat("rc-observer-key","-").concat(r);return l.createElement(b,Object(n.a)({},e,{key:i}),t)}))}E.Collection=function(e){var t=e.children,r=e.onBatchResize,n=l.useRef(0),i=l.useRef([]),a=l.useContext(y),s=l.useCallback((function(e,t,s){n.current+=1;var o=n.current;i.current.push({size:e,element:t,data:s}),Promise.resolve().then((function(){o===n.current&&(null==r||r(i.current),i.current=[])})),null==a||a(e,t,s)}),[r,a]);return l.createElement(y.Provider,{value:s},t)};var T,S=E,k=r("bT9E"),A=r("TSYQ"),x=r.n(A),L="\n min-height:0 !important;\n max-height:none !important;\n height:0 !important;\n visibility:hidden !important;\n overflow:hidden !important;\n position:absolute !important;\n z-index:-1000 !important;\n top:0 !important;\n right:0 !important\n",D=["letter-spacing","line-height","padding-top","padding-bottom","font-family","font-weight","font-size","font-variant","text-rendering","text-transform","width","text-indent","padding-left","padding-right","border-width","box-sizing","word-break"],O={};function C(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=e.getAttribute("id")||e.getAttribute("data-reactid")||e.getAttribute("name");if(t&&O[r])return O[r];var n=window.getComputedStyle(e),i=n.getPropertyValue("box-sizing")||n.getPropertyValue("-moz-box-sizing")||n.getPropertyValue("-webkit-box-sizing"),a=parseFloat(n.getPropertyValue("padding-bottom"))+parseFloat(n.getPropertyValue("padding-top")),s=parseFloat(n.getPropertyValue("border-bottom-width"))+parseFloat(n.getPropertyValue("border-top-width")),o=D.map((function(e){return"".concat(e,":").concat(n.getPropertyValue(e))})).join(";"),l={sizingStyle:o,paddingSize:a,borderSize:s,boxSizing:i};return t&&r&&(O[r]=l),l}var _,w=r("Gytx"),R=r.n(w);!function(e){e[e.NONE=0]="NONE",e[e.RESIZING=1]="RESIZING",e[e.RESIZED=2]="RESIZED"}(_||(_={}));var I=function(e){Object(s.a)(r,e);var t=Object(o.a)(r);function r(e){var a;return Object(i.a)(this,r),(a=t.call(this,e)).nextFrameActionId=void 0,a.resizeFrameId=void 0,a.textArea=void 0,a.saveTextArea=function(e){a.textArea=e},a.handleResize=function(e){var t=a.state.resizeStatus,r=a.props,n=r.autoSize,i=r.onResize;t===_.NONE&&("function"==typeof i&&i(e),n&&a.resizeOnNextFrame())},a.resizeOnNextFrame=function(){cancelAnimationFrame(a.nextFrameActionId),a.nextFrameActionId=requestAnimationFrame(a.resizeTextarea)},a.resizeTextarea=function(){var e=a.props.autoSize;if(e&&a.textArea){var t=e.minRows,r=e.maxRows,n=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;T||((T=document.createElement("textarea")).setAttribute("tab-index","-1"),T.setAttribute("aria-hidden","true"),document.body.appendChild(T)),e.getAttribute("wrap")?T.setAttribute("wrap",e.getAttribute("wrap")):T.removeAttribute("wrap");var i=C(e,t),a=i.paddingSize,s=i.borderSize,o=i.boxSizing,l=i.sizingStyle;T.setAttribute("style","".concat(l,";").concat(L)),T.value=e.value||e.placeholder||"";var u,c=Number.MIN_SAFE_INTEGER,d=Number.MAX_SAFE_INTEGER,f=T.scrollHeight;if("border-box"===o?f+=s:"content-box"===o&&(f-=a),null!==r||null!==n){T.value=" ";var h=T.scrollHeight-a;null!==r&&(c=h*r,"border-box"===o&&(c=c+a+s),f=Math.max(c,f)),null!==n&&(d=h*n,"border-box"===o&&(d=d+a+s),u=f>d?"":"hidden",f=Math.min(d,f))}return{height:f,minHeight:c,maxHeight:d,overflowY:u,resize:"none"}}(a.textArea,!1,t,r);a.setState({textareaStyles:n,resizeStatus:_.RESIZING},(function(){cancelAnimationFrame(a.resizeFrameId),a.resizeFrameId=requestAnimationFrame((function(){a.setState({resizeStatus:_.RESIZED},(function(){a.resizeFrameId=requestAnimationFrame((function(){a.setState({resizeStatus:_.NONE}),a.fixFirefoxAutoScroll()}))}))}))}))}},a.renderTextArea=function(){var e=a.props,t=e.prefixCls,r=void 0===t?"rc-textarea":t,i=e.autoSize,s=e.onResize,o=e.className,d=e.disabled,f=a.state,h=f.textareaStyles,g=f.resizeStatus,p=Object(k.a)(a.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),v=x()(r,o,Object(c.a)({},"".concat(r,"-disabled"),d));"value"in p&&(p.value=p.value||"");var m=Object(u.a)(Object(u.a)(Object(u.a)({},a.props.style),h),g===_.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return l.createElement(S,{onResize:a.handleResize,disabled:!(i||s)},l.createElement("textarea",Object(n.a)({},p,{className:v,style:m,ref:a.saveTextArea})))},a.state={textareaStyles:{},resizeStatus:_.NONE},a}return Object(a.a)(r,[{key:"componentDidUpdate",value:function(e){e.value===this.props.value&&R()(e.autoSize,this.props.autoSize)||this.resizeTextarea()}},{key:"componentWillUnmount",value:function(){cancelAnimationFrame(this.nextFrameActionId),cancelAnimationFrame(this.resizeFrameId)}},{key:"fixFirefoxAutoScroll",value:function(){try{if(document.activeElement===this.textArea){var e=this.textArea.selectionStart,t=this.textArea.selectionEnd;this.textArea.setSelectionRange(e,t)}}catch(e){}}},{key:"render",value:function(){return this.renderTextArea()}}]),r}(l.Component),P=function(e){Object(s.a)(r,e);var t=Object(o.a)(r);function r(e){var n;Object(i.a)(this,r),(n=t.call(this,e)).resizableTextArea=void 0,n.focus=function(){n.resizableTextArea.textArea.focus()},n.saveTextArea=function(e){n.resizableTextArea=e},n.handleChange=function(e){var t=n.props.onChange;n.setValue(e.target.value,(function(){n.resizableTextArea.resizeTextarea()})),t&&t(e)},n.handleKeyDown=function(e){var t=n.props,r=t.onPressEnter,i=t.onKeyDown;13===e.keyCode&&r&&r(e),i&&i(e)};var a=void 0===e.value||null===e.value?e.defaultValue:e.value;return n.state={value:a},n}return Object(a.a)(r,[{key:"setValue",value:function(e,t){"value"in this.props||this.setState({value:e},t)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return l.createElement(I,Object(n.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(e){return"value"in e?{value:e.value}:null}}]),r}(l.Component);t.default=P},ZW9T:
|
|
|
/*!************************************************************!*\
|
|
|
!*** ./src/components/monaco-editor/index.jsx + 1 modules ***!
|
|
|
\************************************************************/
|
|
|
/*! exports provided: getLanguageByMirrorName, default, DiffEditor */
|
|
|
/*! exports used: DiffEditor, default */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/createForOfIteratorHelper.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectSpread2.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/slicedToArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/message/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/antd/es/message/style/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js (<- Module uses injected variables (global)) */function(e,t,r){"use strict";r.d(t,"a",(function(){return m}));var n=r("k1fw"),i=(r("miYZ"),r("tsqr")),a=r("rAM+"),s=r("tJVT"),o=r("PpiC"),l=r("q1tI"),u=r.n(l),c=r("bdgK");function d(e,t,r,i,a){var s=t.getWordUntilPosition(r),o={startLineNumber:r.lineNumber,endLineNumber:r.lineNumber,startColumn:s.startColumn,endColumn:s.endColumn},l=i.map((function(t){return{label:t,kind:e.languages.CompletionItemKind.Keyword,insertText:t,insertTextRules:e.languages.CompletionItemInsertTextRule.InsertAsSnippet,range:o}}));return a.map((function(e){l.push(Object(n.a)(Object(n.a)({},e),{},{range:o}))})),l}r("LvDl");function f(e){return/^\d+$/.test(e)?"".concat(e,"px"):e}function h(){}var g={"Python3.6":"python","Python2.7":"python",Dynamips:"cpp",Java:"java",Web:"php",Html:"html",Hive:"sql",Hadoop:"java",SDL:"cpp",PHP:"php",Matlab:"python",Git:"python",Python:"python","C/C++":"cpp","C++":"cpp",C:"cpp",Ruby:"ruby",Shell:"shell",JavaScript:"javascript",Perl6:"perl",Kotlin:"kotlin",Elixir:"elixir",Android:"java",JavaWeb:"java",Go:"go",Spark:"sql",MachineLearning:"python",Verilog:"xml","Verilog/VNC":"xml",Docker:"dockerfile","C#":"csharp",SQLite3:"sql",Oracle:"sql",Vhdl:"vhdl",R:"r",Swift:"swift",SQLServer:"mysql",MySQL:"mysql",Mongo:"sql",PostgreSql:"pgsql",Hbase:"powershell",Sqoop:"sql",Nasm:"cpp",Kafka:"java",Flink:"java",Sml:"javascript",OpenGL:"cpp",Perl5:"perl",Orange:"python"};function p(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=e;if(Array.isArray(e)){for(var r=0;r<e.length;r++){var n=g[e[r]];if(n)return n}return t[0]}return g[t]||t}var v=null;t.b=function(e){var t=e.width,g=void 0===t?"100%":t,m=e.height,y=void 0===m?"100%":m,b=e.value,E=e.language,T=void 0===E?"javascript":E,S=e.style,k=void 0===S?{}:S,A=e.options,x=void 0===A?{}:A,L=e.overrideServices,D=void 0===L?{}:L,O=e.theme,C=void 0===O?"vs-dark":O,_=e.onEditBlur,w=e.onSave,R=e.autoHeight,I=void 0!==R&&R,P=e.forbidCopy,N=void 0!==P&&P,M=e.onChange,F=void 0===M?h:M,j=e.editorDidMount,B=void 0===j?h:j,U=e.onFocus,K=void 0===U?h:U,G=e.filename,H=void 0===G?"educoder.txt":G,V=(Object(o.a)(e,["width","height","value","language","style","options","overrideServices","theme","onEditBlur","onSave","autoHeight","forbidCopy","onChange","editorDidMount","onFocus","filename"]),Object(l.useRef)()),z=Object(l.useRef)({}),W=Object(l.useRef)(),q=Object(l.useRef)(!1),Y=Object(l.useRef)(),$=Object(l.useState)(!1),X=Object(s.a)($,2),Z=X[0],Q=X[1];function J(){i.b.warn(decodeURIComponent("该任务关卡设置了禁止复制粘贴,请手动输入代码。"))}function ee(){var e=z.current.instance;if(e){var t=e.getSelection(),r=z.current.pastePos||{},n=new v.Range(r.startLineNumber||t.endLineNumber,r.startColumn||t.endColumn,r.endLineNumber||t.endLineNumber,r.endColumn||t.endColumn);setTimeout((function(){e.executeEdits("",[{range:n,text:""}])}),300)}}function te(e){(window.navigator.platform.match("Mac")?e.metaKey:e.ctrlKey)&&83==e.keyCode&&(e.preventDefault(),w())}Object(l.useEffect)((function(){W.current&&clearTimeout(W.current),W.current=setTimeout((function(){!function(){var e=z.current.instance;if(null!=b&&e&&Z){var t=e.getModel();t&&b!==t.getValue()&&(!0,t.setValue(b),e.layout(),!1)}}()}),500)}),[b,Z,z.current]);var re=function(){if(I&&z.current.instance){var e=z.current.instance.getContentHeight();ce(e<y?y:e)}else ce(y)};function ne(e,t){var r,n,i=window.URL||window.webkitURL||window,a=new Blob([t]),s=document.createElementNS("http://www.w3.org/1999/xhtml","a");s.href=i.createObjectURL(a),s.download=e,r=s,(n=document.createEvent("MouseEvents")).initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),r.dispatchEvent(n)}Object(l.useEffect)((function(){re()}),[re]),Object(l.useEffect)((function(){V.current&&!Z&&r.e(/*! import() | monaco-editor */27).then(r.t.bind(null,/*! monaco-editor/esm/vs/editor/editor.api.js */"M/lh",7)).then((function(e){try{v=e,z.current.instance=v.editor.create(V.current,{value:b,language:p(T),theme:C,requireConfig:{"vs/nls":{availableLanguages:{"*":"zh-cn"}}},wordWrap:!0},D);var t=z.current.instance;if(B(t,v),setTimeout((function(){re(),z.current.instance.addAction({id:"d123123",label:"Download File",contextMenuGroupId:"9_cutcopypaste",run:function(){ne(H||"educoder.txt",t.getValue())}})}),500),z.current.subscription=t.onDidChangeModelContent((function(e){q.current?clearTimeout(Y.current):(re(),F(t.getValue(),e)),Y.current=setTimeout((function(){q.current=!1}),500)})),window.Monaco||function(e){var t={label:"ifelse",kind:e.languages.CompletionItemKind.Method,insertText:["if (${1:condition}) {","\t$0","} else {","\t","}"].join("\n"),insertTextRules:e.languages.CompletionItemInsertTextRule.InsertAsSnippet},r=["auto","break","case","char","const","continue","default","do","double","else","enum","extern","float","for","goto","if","int","long","register","return","short","signed","sizeof","static","struct","switch","typedef","union","unsigned","void","volatile","while","inline","restrict","_Bool","_Complex","_Imaginary","_Alignas","_Alignof","_Atomic","_Static_assert","_Noreturn","_Thread_local","_Generic"];e.languages.registerCompletionItemProvider("cpp",{provideCompletionItems:function(n,i){return{suggestions:d(e,n,i,r,[t])}}});var n=["False","None","True","and","as","assert","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield"];e.languages.registerCompletionItemProvider("python",{provideCompletionItems:function(t,r){var i=[{label:"print",kind:e.languages.CompletionItemKind.Snippet,insertText:["print($0)"].join("\n"),insertTextRules:e.languages.CompletionItemInsertTextRule.InsertAsSnippet}];return{suggestions:d(e,t,r,n,i)}}});var i=["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","final","finally","float","for","goto","if","implements","import","instance of","int","interface","long","native","new","package","private","protected","public","return","strictfp","short","static","super","switch","synchronized","this","throw","throws","transient","try","void","volatile","while"];e.languages.registerCompletionItemProvider("java",{provideCompletionItems:function(r,n){var a=[t,{label:"main",kind:e.languages.CompletionItemKind.Snippet,insertText:["public static void main(String[] args) {","\t$0","}"].join("\n"),insertTextRules:e.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"System.out.print",kind:e.languages.CompletionItemKind.Snippet,insertText:["System.out.print($0)"].join("\n"),insertTextRules:e.languages.CompletionItemInsertTextRule.InsertAsSnippet}];return{suggestions:d(e,r,n,i,a)}}})}(v),N&&(t.addCommand(v.KeyMod.CtrlCmd|v.KeyMod.Shift|v.KeyCode.KEY_V,(function(){return J(),null})),t.addCommand(v.KeyMod.CtrlCmd|v.KeyCode.KEY_C,(function(){return J(),null}))),window.Monaco=v,_&&t.onDidBlurEditorWidget((function(){_(t.getValue())})),K&&t.onDidFocusEditorText((function(){K(t.getValue())})),N){t.addCommand(v.KeyMod.CtrlCmd|v.KeyCode.KEY_V,(function(){return J(),null})),t.onDidPaste((function(e){z.current.pastePos=e}));try{window.addEventListener("paste",ee)}catch(e){}}var r=function(){var e;return V.current&&(e=new c.default((function(e){var t,r=Object(a.a)(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;(n.target.offsetHeight>0||n.target.offsetWidth>0)&&z.current.instance.layout()}}catch(e){r.e(e)}finally{r.f()}}))).observe(V.current),e}();return Q(!0),function(){var e=z.current.instance;e.dispose();var t=e.getModel();t&&t.dispose(),z.current.subscription&&z.current.subscription.dispose(),N&&window.removeEventListener("paste",ee),r.unobserve(V.current)}}catch(e){}}))}),[]),Object(l.useEffect)((function(){if(z.current.instance&&Z)return document.addEventListener("keydown",te,!1),function(){document.removeEventListener("keydown",te)}}),[w,Z]),Object(l.useEffect)((function(){var e=z.current.instance;if(e&&Z){var t=p(T);v.editor.setModelLanguage(e.getModel(),t),console.log("language:",T,e.getModel(),t)}}),[T,Z]),Object(l.useEffect)((function(){z.current.instance&&Z&&v.editor.setTheme(C)}),[C,Z]),Object(l.useEffect)((function(){var e=z.current.instance;e&&Z&&(e.updateOptions(Object(n.a)({},x)),setTimeout((function(){e.getModel().updateOptions(Object(n.a)({},x))}),200))}),[JSON.stringify(x),Z]),Object(l.useEffect)((function(){var e=z.current.instance;e&&Z&&e.layout()}),[g,y,Z]);var ie=Object(l.useState)(f(g)),ae=Object(s.a)(ie,2),se=ae[0],oe=(ae[1],Object(l.useState)(f(y))),le=Object(s.a)(oe,2),ue=le[0],ce=le[1],de=Object(n.a)(Object(n.a)({},k),{},{width:se,height:ue});return u.a.createElement("div",{className:"my-monaco-editor",ref:V,style:de})};function m(e){var t=e.width,i=void 0===t?"100%":t,o=e.height,d=void 0===o?"100%":o,h=e.original,g=e.modified,p=e.language,m=e.options,y=void 0===m?{}:m,b=Object(l.useRef)(),E=Object(l.useState)(null),T=Object(s.a)(E,2),S=T[0],k=T[1];Object(l.useEffect)((function(){b.current&&r.e(/*! import() | monaco-editor */27).then(r.t.bind(null,/*! monaco-editor/esm/vs/editor/editor.api.js */"M/lh",7)).then((function(e){var t=(v=e).editor.createDiffEditor(b.current,Object(n.a)(Object(n.a)({enableSplitViewResizing:!1,scrollBeyondLastLine:!1,roundedSelection:!1,renderIndicators:!1,useShadows:!1,horizontal:"hidden",lineNumbers:"off",ignoreTrimWhitespace:!1,followsCaret:!0,ignoreCharChanges:!0,minimap:{enabled:!1},readOnly:!0},y),{},{wordWrap:!0}));k(t);var r=function(e){var t;return b.current&&(t=new c.default((function(t){var r,n=Object(a.a)(t);try{for(n.s();!(r=n.n()).done;){var i=r.value;(i.target.offsetHeight>0||i.target.offsetWidth>0)&&e.layout()}}catch(e){n.e(e)}finally{n.f()}}))).observe(b.current),t}(t);return function(){t.dispose();var e=t.getModel();e&&e.dispose(),r.unobserve(b.current)}}))}),[]),Object(l.useEffect)((function(){S&&S.setModel({original:v.editor.createModel(h,p),modified:v.editor.createModel(g,p)})}),[h,g,p,S]);var A={width:f(i),height:f(d)};return u.a.createElement("div",{className:"my-diff-editor",ref:b,style:A})}},ZpRC:
|
|
|
/*!*************************************************************************!*\
|
|
|
!*** ./node_modules/scroll-into-view-if-needed/es/index.js + 1 modules ***!
|
|
|
\*************************************************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(e,t,r){"use strict";function n(e){return"object"==typeof e&&null!=e&&1===e.nodeType}function i(e,t){return(!t||"hidden"!==e)&&"visible"!==e&&"clip"!==e}function a(e,t){if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){var r=getComputedStyle(e,null);return i(r.overflowY,t)||i(r.overflowX,t)||function(e){var t=function(e){if(!e.ownerDocument||!e.ownerDocument.defaultView)return null;try{return e.ownerDocument.defaultView.frameElement}catch(e){return null}}(e);return!!t&&(t.clientHeight<e.scrollHeight||t.clientWidth<e.scrollWidth)}(e)}return!1}function s(e,t,r,n,i,a,s,o){return a<e&&s>t||a>e&&s<t?0:a<=e&&o<=r||s>=t&&o>=r?a-e-n:s>t&&o<r||a<e&&o>r?s-t+i:0}var o=function(e,t){var r=window,i=t.scrollMode,o=t.block,l=t.inline,u=t.boundary,c=t.skipOverflowHiddenElements,d="function"==typeof u?u:function(e){return e!==u};if(!n(e))throw new TypeError("Invalid target");for(var f=document.scrollingElement||document.documentElement,h=[],g=e;n(g)&&d(g);){if((g=g.parentElement)===f){h.push(g);break}null!=g&&g===document.body&&a(g)&&!a(document.documentElement)||null!=g&&a(g,c)&&h.push(g)}for(var p=r.visualViewport?r.visualViewport.width:innerWidth,v=r.visualViewport?r.visualViewport.height:innerHeight,m=window.scrollX||pageXOffset,y=window.scrollY||pageYOffset,b=e.getBoundingClientRect(),E=b.height,T=b.width,S=b.top,k=b.right,A=b.bottom,x=b.left,L="start"===o||"nearest"===o?S:"end"===o?A:S+E/2,D="center"===l?x+T/2:"end"===l?k:x,O=[],C=0;C<h.length;C++){var _=h[C],w=_.getBoundingClientRect(),R=w.height,I=w.width,P=w.top,N=w.right,M=w.bottom,F=w.left;if("if-needed"===i&&S>=0&&x>=0&&A<=v&&k<=p&&S>=P&&A<=M&&x>=F&&k<=N)return O;var j=getComputedStyle(_),B=parseInt(j.borderLeftWidth,10),U=parseInt(j.borderTopWidth,10),K=parseInt(j.borderRightWidth,10),G=parseInt(j.borderBottomWidth,10),H=0,V=0,z="offsetWidth"in _?_.offsetWidth-_.clientWidth-B-K:0,W="offsetHeight"in _?_.offsetHeight-_.clientHeight-U-G:0;if(f===_)H="start"===o?L:"end"===o?L-v:"nearest"===o?s(y,y+v,v,U,G,y+L,y+L+E,E):L-v/2,V="start"===l?D:"center"===l?D-p/2:"end"===l?D-p:s(m,m+p,p,B,K,m+D,m+D+T,T),H=Math.max(0,H+y),V=Math.max(0,V+m);else{H="start"===o?L-P-U:"end"===o?L-M+G+W:"nearest"===o?s(P,M,R,U,G+W,L,L+E,E):L-(P+R/2)+W/2,V="start"===l?D-F-B:"center"===l?D-(F+I/2)+z/2:"end"===l?D-N+K+z:s(F,N,I,B,K+z,D,D+T,T);var q=_.scrollLeft,Y=_.scrollTop;L+=Y-(H=Math.max(0,Math.min(Y+H,_.scrollHeight-R+W))),D+=q-(V=Math.max(0,Math.min(q+V,_.scrollWidth-I+z)))}O.push({el:_,top:H,left:V})}return O};function l(e){return e===Object(e)&&0!==Object.keys(e).length}t.a=function(e,t){var r=!e.ownerDocument.documentElement.contains(e);if(l(t)&&"function"==typeof t.behavior)return t.behavior(r?[]:o(e,t));if(!r){var n=function(e){return!1===e?{block:"end",inline:"nearest"}:l(e)?e:{block:"start",inline:"nearest"}}(t);return function(e,t){void 0===t&&(t="auto");var r="scrollBehavior"in document.body.style;e.forEach((function(e){var n=e.el,i=e.top,a=e.left;n.scroll&&r?n.scroll({top:i,left:a,behavior:t}):(n.scrollTop=i,n.scrollLeft=a)}))}(o(e,n),n.behavior)}}},bT9E:
|
|
|
/*!*****************************************!*\
|
|
|
!*** ./node_modules/rc-util/es/omit.js ***!
|
|
|
\*****************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(/*! @babel/runtime/helpers/esm/objectSpread2 */"VTBJ");function i(e,t){var r=Object(n.a)({},e);return Array.isArray(t)&&t.forEach((function(e){delete r[e]})),r}},fAei:
|
|
|
/*!******************************************************!*\
|
|
|
!*** ./node_modules/rc-tree/es/index.js + 4 modules ***!
|
|
|
\******************************************************/
|
|
|
/*! exports provided: TreeNode, default */
|
|
|
/*! exports used: TreeNode, default */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/createClass.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/createSuper.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/defineProperty.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/inherits.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/classnames/index.js (<- Module is not an ECMAScript module) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-motion/es/index.js (<- Module is referenced from these modules with unsupported syntax: ./node_modules/antd/lib/button/LoadingIcon.js (referenced with cjs require)) */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-tree/es/TreeNode.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-tree/es/contextTypes.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-tree/es/util.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-tree/es/utils/conductUtil.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-tree/es/utils/treeUtil.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/KeyCode.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-util/es/warning.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/rc-virtual-list/es/index.js */
|
|
|
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/react/index.js (<- Module is not an ECMAScript module) */function(e,t,r){"use strict";r.d(t,"a",(function(){return S.a}));var n=r("rePB"),i=r("VTBJ"),a=r("KQm4"),s=r("1OyB"),o=r("vuIU"),l=r("Ji7U"),u=r("LK+K"),c=r("q1tI"),d=r("4IlW"),f=r("Kwbf"),h=r("TSYQ"),g=r.n(h),p=r("sboe"),v=r("OZM5"),m=r("815F"),y=r("ODXe"),b=r("Ff2n"),E=r("+nKL"),T=r("8XRh"),S=r("WaYH"),k=function(e,t){var r=e.className,n=e.style,i=e.motion,a=e.motionNodes,s=e.motionType,o=e.onMotionStart,l=e.onMotionEnd,u=e.active,d=e.treeNodeRequiredProps,f=Object(b.a)(e,["className","style","motion","motionNodes","motionType","onMotionStart","onMotionEnd","active","treeNodeRequiredProps"]),h=c.useState(!0),v=Object(y.a)(h,2),E=v[0],k=v[1],A=c.useContext(p.a).prefixCls,x=c.useRef(!1),L=function(){x.current||l(),x.current=!0};return Object(c.useEffect)((function(){a&&"hide"===s&&E&&k(!1)}),[a]),Object(c.useEffect)((function(){return a&&o(),function(){a&&L()}}),[]),a?c.createElement(T.default,Object.assign({ref:t,visible:E},i,{motionAppear:"show"===s,onAppearEnd:L,onLeaveEnd:L}),(function(e,t){var r=e.className,n=e.style;return c.createElement("div",{ref:t,className:g()("".concat(A,"-treenode-motion"),r),style:n},a.map((function(e){var t=e.data,r=t.key,n=Object(b.a)(t,["key"]),i=e.isStart,a=e.isEnd;delete n.children;var s=Object(m.f)(r,d);return c.createElement(S.a,Object.assign({},n,s,{active:u,data:e.data,key:r,isStart:i,isEnd:a}))})))})):c.createElement(S.a,Object.assign({domRef:t,className:r,style:n},f,{active:u}))};k.displayName="MotionTreeNode";var A=c.forwardRef(k);function x(e,t,r){var n=e.findIndex((function(e){return e.data.key===r})),i=e[n+1],a=t.findIndex((function(e){return e.data.key===r}));if(i){var s=t.findIndex((function(e){return e.data.key===i.data.key}));return t.slice(a+1,s)}return t.slice(a+1)}var L={width:0,height:0,display:"flex",overflow:"hidden",opacity:0,border:0,padding:0,margin:0},D=function(){},O="RC_TREE_MOTION_".concat(Math.random()),C={key:O},_={key:O,level:0,index:0,pos:"0",node:C},w={parent:null,children:[],pos:_.pos,data:C,isStart:[],isEnd:[]};function R(e,t,r,n){return!1!==t&&r?e.slice(0,Math.ceil(r/n)+1):e}function I(e){var t=e.data.key,r=e.pos;return Object(m.e)(t,r)}var P=c.forwardRef((function(e,t){var r=e.prefixCls,n=e.data,i=(e.selectable,e.checkable,e.expandedKeys),a=e.selectedKeys,s=e.checkedKeys,o=e.loadedKeys,l=e.loadingKeys,u=e.halfCheckedKeys,d=e.keyEntities,f=e.disabled,h=e.dragging,g=e.dragOverNodeKey,p=e.dropPosition,v=e.motion,T=e.height,S=e.itemHeight,k=e.virtual,C=e.focusable,_=e.activeItem,P=e.focused,N=e.tabIndex,M=e.onKeyDown,F=e.onFocus,j=e.onBlur,B=e.onActiveChange,U=e.onListChangeStart,K=e.onListChangeEnd,G=Object(b.a)(e,["prefixCls","data","selectable","checkable","expandedKeys","selectedKeys","checkedKeys","loadedKeys","loadingKeys","halfCheckedKeys","keyEntities","disabled","dragging","dragOverNodeKey","dropPosition","motion","height","itemHeight","virtual","focusable","activeItem","focused","tabIndex","onKeyDown","onFocus","onBlur","onActiveChange","onListChangeStart","onListChangeEnd"]),H=c.useRef(null);c.useImperativeHandle(t,(function(){return{scrollTo:function(e){H.current.scrollTo(e)}}}));var V=c.useState(i),z=Object(y.a)(V,2),W=z[0],q=z[1],Y=c.useState(n),$=Object(y.a)(Y,2),X=$[0],Z=$[1],Q=c.useState(n),J=Object(y.a)(Q,2),ee=J[0],te=J[1],re=c.useState([]),ne=Object(y.a)(re,2),ie=ne[0],ae=ne[1],se=c.useState(null),oe=Object(y.a)(se,2),le=oe[0],ue=oe[1];function ce(){Z(n),te(n),ae([]),ue(null),K()}c.useEffect((function(){q(i);var e=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=e.length,n=t.length;if(1!==Math.abs(r-n))return{add:!1,key:null};function i(e,t){var r=new Map;e.forEach((function(e){r.set(e,!0)}));var n=t.filter((function(e){return!r.has(e)}));return 1===n.length?n[0]:null}return r<n?{add:!0,key:i(e,t)}:{add:!1,key:i(t,e)}}(W,i);if(null!==e.key)if(e.add){var t=X.findIndex((function(t){return t.data.key===e.key})),r=R(x(X,n,e.key),k,T,S),a=X.slice();a.splice(t+1,0,w),te(a),ae(r),ue("show")}else{var s=n.findIndex((function(t){return t.data.key===e.key})),o=R(x(n,X,e.key),k,T,S),l=n.slice();l.splice(s+1,0,w),te(l),ae(o),ue("hide")}else X!==n&&(Z(n),te(n))}),[i,n]),c.useEffect((function(){h||ce()}),[h]);var de=v?ee:n,fe={expandedKeys:i,selectedKeys:a,loadedKeys:o,loadingKeys:l,checkedKeys:s,halfCheckedKeys:u,dragOverNodeKey:g,dropPosition:p,keyEntities:d};return c.createElement(c.Fragment,null,P&&_&&c.createElement("span",{style:L,"aria-live":"assertive"},function(e){for(var t=String(e.data.key),r=e;r.parent;)r=r.parent,t="".concat(r.data.key," > ").concat(t);return t}(_)),c.createElement("div",{role:"tree"},c.createElement("input",{style:L,disabled:!1===C||f,tabIndex:!1!==C?N:null,onKeyDown:M,onFocus:F,onBlur:j,value:"",onChange:D})),c.createElement(E.a,Object.assign({},G,{data:de,itemKey:I,height:T,fullHeight:!1,virtual:k,itemHeight:S,prefixCls:"".concat(r,"-list"),ref:H}),(function(e){var t=e.pos,r=e.data,n=r.key,i=Object(b.a)(r,["key"]),a=e.isStart,s=e.isEnd,o=Object(m.e)(n,t);delete i.children;var l=Object(m.f)(o,fe);return c.createElement(A,Object.assign({},i,l,{active:_&&n===_.data.key,pos:t,data:e.data,isStart:a,isEnd:s,motion:v,motionNodes:n===O?ie:null,motionType:le,onMotionStart:U,onMotionEnd:ce,treeNodeRequiredProps:fe,onMouseMove:function(){B(null)}}))})))}));P.displayName="NodeList";var N=P,M=r("NvD2"),F=function(e){Object(l.a)(r,e);var t=Object(u.a)(r);function r(){var e;return Object(s.a)(this,r),(e=t.apply(this,arguments)).destroyed=!1,e.state={keyEntities:{},selectedKeys:[],checkedKeys:[],halfCheckedKeys:[],loadedKeys:[],loadingKeys:[],expandedKeys:[],dragging:!1,dragNodesKeys:[],dragOverNodeKey:null,dropPosition:null,treeData:[],flattenNodes:[],focused:!1,activeKey:null,listChanging:!1,prevProps:null},e.listRef=c.createRef(),e.onNodeDragStart=function(t,r){var n=e.state,i=n.expandedKeys,a=n.keyEntities,s=e.props.onDragStart,o=r.props.eventKey;e.dragNode=r;var l=Object(v.b)(i,o);e.setState({dragging:!0,dragNodesKeys:Object(v.g)(o,a)}),e.setExpandedKeys(l),s&&s({event:t,node:Object(m.b)(r.props)})},e.onNodeDragEnter=function(t,r){var n=e.state,i=n.expandedKeys,s=n.keyEntities,o=n.dragNodesKeys,l=e.props.onDragEnter,u=r.props,c=u.pos,d=u.eventKey;if(e.dragNode&&-1===o.indexOf(d)){var f=Object(v.c)(t,r);e.dragNode.props.eventKey!==d||0!==f?setTimeout((function(){e.setState({dragOverNodeKey:d,dropPosition:f}),e.delayedDragEnterLogic||(e.delayedDragEnterLogic={}),Object.keys(e.delayedDragEnterLogic).forEach((function(t){clearTimeout(e.delayedDragEnterLogic[t])})),e.delayedDragEnterLogic[c]=window.setTimeout((function(){if(e.state.dragging){var n=Object(a.a)(i),o=s[d];o&&(o.children||[]).length&&(n=Object(v.a)(i,d)),"expandedKeys"in e.props||e.setExpandedKeys(n),l&&l({event:t,node:Object(m.b)(r.props),expandedKeys:n})}}),400)}),0):e.setState({dragOverNodeKey:"",dropPosition:null})}},e.onNodeDragOver=function(t,r){var n=e.state.dragNodesKeys,i=e.props.onDragOver,a=r.props.eventKey;if(-1===n.indexOf(a)){if(e.dragNode&&a===e.state.dragOverNodeKey){var s=Object(v.c)(t,r);if(s===e.state.dropPosition)return;e.setState({dropPosition:s})}i&&i({event:t,node:Object(m.b)(r.props)})}},e.onNodeDragLeave=function(t,r){var n=e.props.onDragLeave;e.setState({dragOverNodeKey:""}),n&&n({event:t,node:Object(m.b)(r.props)})},e.onNodeDragEnd=function(t,r){var n=e.props.onDragEnd;e.setState({dragOverNodeKey:""}),e.cleanDragState(),n&&n({event:t,node:Object(m.b)(r.props)}),e.dragNode=null},e.onNodeDrop=function(t,r){var n=e.state,i=n.dragNodesKeys,a=void 0===i?[]:i,s=n.dropPosition,o=e.props.onDrop,l=r.props,u=l.eventKey,c=l.pos;if(e.setState({dragOverNodeKey:""}),e.cleanDragState(),-1===a.indexOf(u)){var d=Object(v.k)(c),h={event:t,node:Object(m.b)(r.props),dragNode:e.dragNode?Object(m.b)(e.dragNode.props):null,dragNodesKeys:a.slice(),dropPosition:s+Number(d[d.length-1]),dropToGap:!1};0!==s&&(h.dropToGap=!0),o&&o(h),e.dragNode=null}else Object(f.a)(!1,"Can not drop to dragNode(include it's children node)")},e.cleanDragState=function(){e.state.dragging&&e.setState({dragging:!1})},e.onNodeClick=function(t,r){var n=e.props.onClick;n&&n(t,r)},e.onNodeDoubleClick=function(t,r){var n=e.props.onDoubleClick;n&&n(t,r)},e.onNodeSelect=function(t,r){var n=e.state.selectedKeys,i=e.state.keyEntities,a=e.props,s=a.onSelect,o=a.multiple,l=r.selected,u=r.key,c=!l,d=(n=c?o?Object(v.a)(n,u):[u]:Object(v.b)(n,u)).map((function(e){var t=i[e];return t?t.node:null})).filter((function(e){return e}));e.setUncontrolledState({selectedKeys:n}),s&&s(n,{event:"select",selected:c,node:r,selectedNodes:d,nativeEvent:t.nativeEvent})},e.onNodeCheck=function(t,r,n){var i,s=e.state,o=s.keyEntities,l=s.checkedKeys,u=s.halfCheckedKeys,c=e.props,d=c.checkStrictly,f=c.onCheck,h=r.key,g={event:"check",node:r,checked:n,nativeEvent:t.nativeEvent};if(d){var p=n?Object(v.a)(l,h):Object(v.b)(l,h);i={checked:p,halfChecked:Object(v.b)(u,h)},g.checkedNodes=p.map((function(e){return o[e]})).filter((function(e){return e})).map((function(e){return e.node})),e.setUncontrolledState({checkedKeys:p})}else{var m=Object(M.a)([].concat(Object(a.a)(l),[h]),!0,o),y=m.checkedKeys,b=m.halfCheckedKeys;if(!n){var E=new Set(y);E.delete(h);var T=Object(M.a)(Array.from(E),{checked:!1,halfCheckedKeys:b},o);y=T.checkedKeys,b=T.halfCheckedKeys}i=y,g.checkedNodes=[],g.checkedNodesPositions=[],g.halfCheckedKeys=b,y.forEach((function(e){var t=o[e];if(t){var r=t.node,n=t.pos;g.checkedNodes.push(r),g.checkedNodesPositions.push({node:r,pos:n})}})),e.setUncontrolledState({checkedKeys:y},!1,{halfCheckedKeys:b})}f&&f(i,g)},e.onNodeLoad=function(t){return new Promise((function(r){e.setState((function(n){var i=n.loadedKeys,a=void 0===i?[]:i,s=n.loadingKeys,o=void 0===s?[]:s,l=e.props,u=l.loadData,c=l.onLoad,d=t.key;return u&&-1===a.indexOf(d)&&-1===o.indexOf(d)?(u(t).then((function(){var n=e.state,i=n.loadedKeys,a=n.loadingKeys,s=Object(v.a)(i,d),o=Object(v.b)(a,d);c&&c(s,{event:"load",node:t}),e.setUncontrolledState({loadedKeys:s}),e.setState({loadingKeys:o}),r()})),{loadingKeys:Object(v.a)(o,d)}):{}}))}))},e.onNodeMouseEnter=function(t,r){var n=e.props.onMouseEnter;n&&n({event:t,node:r})},e.onNodeMouseLeave=function(t,r){var n=e.props.onMouseLeave;n&&n({event:t,node:r})},e.onNodeContextMenu=function(t,r){var n=e.props.onRightClick;n&&(t.preventDefault(),n({event:t,node:r}))},e.onFocus=function(){var t=e.props.onFocus;e.setState({focused:!0}),t&&t.apply(void 0,arguments)},e.onBlur=function(){var t=e.props.onBlur;e.setState({focused:!1}),e.onActiveChange(null),t&&t.apply(void 0,arguments)},e.getTreeNodeRequiredProps=function(){var t=e.state;return{expandedKeys:t.expandedKeys||[],selectedKeys:t.selectedKeys||[],loadedKeys:t.loadedKeys||[],loadingKeys:t.loadingKeys||[],checkedKeys:t.checkedKeys||[],halfCheckedKeys:t.halfCheckedKeys||[],dragOverNodeKey:t.dragOverNodeKey,dropPosition:t.dropPosition,keyEntities:t.keyEntities}},e.setExpandedKeys=function(t){var r=e.state.treeData,n=Object(m.d)(r,t);e.setUncontrolledState({expandedKeys:t,flattenNodes:n},!0)},e.onNodeExpand=function(t,r){var n=e.state.expandedKeys,i=e.state.listChanging,a=e.props,s=a.onExpand,o=a.loadData,l=r.key,u=r.expanded;if(!i){var c=n.indexOf(l),d=!u;if(Object(f.a)(u&&-1!==c||!u&&-1===c,"Expand state not sync with index check"),n=d?Object(v.a)(n,l):Object(v.b)(n,l),e.setExpandedKeys(n),s&&s(n,{node:r,expanded:d,nativeEvent:t.nativeEvent}),d&&o){var h=e.onNodeLoad(r);h&&h.then((function(){var t=Object(m.d)(e.state.treeData,n);e.setUncontrolledState({flattenNodes:t})}))}}},e.onListChangeStart=function(){e.setUncontrolledState({listChanging:!0})},e.onListChangeEnd=function(){setTimeout((function(){e.setUncontrolledState({listChanging:!1})}))},e.onActiveChange=function(t){var r=e.state.activeKey,n=e.props.onActiveChange;r!==t&&(e.setState({activeKey:t}),null!==t&&e.scrollTo({key:t}),n&&n(t))},e.getActiveItem=function(){var t=e.state,r=t.activeKey,n=t.flattenNodes;return null===r?null:n.find((function(e){return e.data.key===r}))||null},e.offsetActiveKey=function(t){var r=e.state,n=r.flattenNodes,i=r.activeKey,a=n.findIndex((function(e){return e.data.key===i}));-1===a&&t<0&&(a=n.length);var s=n[a=(a+t+n.length)%n.length];if(s){var o=s.data.key;e.onActiveChange(o)}else e.onActiveChange(null)},e.onKeyDown=function(t){var r=e.state,n=r.activeKey,a=r.expandedKeys,s=r.checkedKeys,o=e.props,l=o.onKeyDown,u=o.checkable,c=o.selectable;switch(t.which){case d.a.UP:e.offsetActiveKey(-1),t.preventDefault();break;case d.a.DOWN:e.offsetActiveKey(1),t.preventDefault()}var f=e.getActiveItem();if(f&&f.data){var h=e.getTreeNodeRequiredProps(),g=!1===f.data.isLeaf||!!(f.data.children||[]).length,p=Object(m.b)(Object(i.a)(Object(i.a)({},Object(m.f)(n,h)),{},{data:f.data,active:!0}));switch(t.which){case d.a.LEFT:g&&a.includes(n)?e.onNodeExpand({},p):f.parent&&e.onActiveChange(f.parent.data.key),t.preventDefault();break;case d.a.RIGHT:g&&!a.includes(n)?e.onNodeExpand({},p):f.children&&f.children.length&&e.onActiveChange(f.children[0].data.key),t.preventDefault();break;case d.a.ENTER:case d.a.SPACE:!u||p.disabled||!1===p.checkable||p.disableCheckbox?u||!c||p.disabled||!1===p.selectable||e.onNodeSelect({},p):e.onNodeCheck({},p,!s.includes(n))}}l&&l(t)},e.setUncontrolledState=function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(!e.destroyed){var a=!1,s=!0,o={};Object.keys(t).forEach((function(r){r in e.props?s=!1:(a=!0,o[r]=t[r])})),!a||r&&!s||e.setState(Object(i.a)(Object(i.a)({},o),n))}},e.scrollTo=function(t){e.listRef.current.scrollTo(t)},e}return Object(o.a)(r,[{key:"componentWillUnmount",value:function(){this.destroyed=!0}},{key:"render",value:function(){var e,t=this.state,r=t.focused,i=t.flattenNodes,a=t.keyEntities,s=t.dragging,o=t.activeKey,l=this.props,u=l.prefixCls,d=l.className,f=l.style,h=l.showLine,m=l.focusable,y=l.tabIndex,b=void 0===y?0:y,E=l.selectable,T=l.showIcon,S=l.icon,k=l.switcherIcon,A=l.draggable,x=l.checkable,L=l.checkStrictly,D=l.disabled,O=l.motion,C=l.loadData,_=l.filterTreeNode,w=l.height,R=l.itemHeight,I=l.virtual,P=l.titleRender,M=l.onContextMenu,F=Object(v.f)(this.props);return c.createElement(p.a.Provider,{value:{prefixCls:u,selectable:E,showIcon:T,icon:S,switcherIcon:k,draggable:A,checkable:x,checkStrictly:L,disabled:D,keyEntities:a,loadData:C,filterTreeNode:_,titleRender:P,onNodeClick:this.onNodeClick,onNodeDoubleClick:this.onNodeDoubleClick,onNodeExpand:this.onNodeExpand,onNodeSelect:this.onNodeSelect,onNodeCheck:this.onNodeCheck,onNodeLoad:this.onNodeLoad,onNodeMouseEnter:this.onNodeMouseEnter,onNodeMouseLeave:this.onNodeMouseLeave,onNodeContextMenu:this.onNodeContextMenu,onNodeDragStart:this.onNodeDragStart,onNodeDragEnter:this.onNodeDragEnter,onNodeDragOver:this.onNodeDragOver,onNodeDragLeave:this.onNodeDragLeave,onNodeDragEnd:this.onNodeDragEnd,onNodeDrop:this.onNodeDrop}},c.createElement("div",{className:g()(u,d,(e={},Object(n.a)(e,"".concat(u,"-show-line"),h),Object(n.a)(e,"".concat(u,"-focused"),r),Object(n.a)(e,"".concat(u,"-active-focused"),null!==o),e))},c.createElement(N,Object.assign({ref:this.listRef,prefixCls:u,style:f,data:i,disabled:D,selectable:E,checkable:!!x,motion:O,dragging:s,height:w,itemHeight:R,virtual:I,focusable:m,focused:r,tabIndex:b,activeItem:this.getActiveItem(),onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,onActiveChange:this.onActiveChange,onListChangeStart:this.onListChangeStart,onListChangeEnd:this.onListChangeEnd,onContextMenu:M},this.getTreeNodeRequiredProps(),F))))}}],[{key:"getDerivedStateFromProps",value:function(e,t){var r,a=t.prevProps,s={prevProps:e};function o(t){return!a&&t in e||a&&a[t]!==e[t]}if(o("treeData")?r=e.treeData:o("children")&&(Object(f.a)(!1,"`children` of Tree is deprecated. Please use `treeData` instead."),r=Object(m.c)(e.children)),r){s.treeData=r;var l=Object(m.a)(r);s.keyEntities=Object(i.a)(Object(n.a)({},O,_),l.keyEntities)}var u,c=s.keyEntities||t.keyEntities;if(o("expandedKeys")||a&&o("autoExpandParent"))s.expandedKeys=e.autoExpandParent||!a&&e.defaultExpandParent?Object(v.e)(e.expandedKeys,c):e.expandedKeys;else if(!a&&e.defaultExpandAll){var d=Object(i.a)({},c);delete d[O],s.expandedKeys=Object.keys(d).map((function(e){return d[e].key}))}else!a&&e.defaultExpandedKeys&&(s.expandedKeys=e.autoExpandParent||e.defaultExpandParent?Object(v.e)(e.defaultExpandedKeys,c):e.defaultExpandedKeys);if(s.expandedKeys||delete s.expandedKeys,r||s.expandedKeys){var h=Object(m.d)(r||t.treeData,s.expandedKeys||t.expandedKeys);s.flattenNodes=h}if((e.selectable&&(o("selectedKeys")?s.selectedKeys=Object(v.d)(e.selectedKeys,e):!a&&e.defaultSelectedKeys&&(s.selectedKeys=Object(v.d)(e.defaultSelectedKeys,e))),e.checkable)&&(o("checkedKeys")?u=Object(v.j)(e.checkedKeys)||{}:!a&&e.defaultCheckedKeys?u=Object(v.j)(e.defaultCheckedKeys)||{}:r&&(u=Object(v.j)(e.checkedKeys)||{checkedKeys:t.checkedKeys,halfCheckedKeys:t.halfCheckedKeys}),u)){var g=u,p=g.checkedKeys,y=void 0===p?[]:p,b=g.halfCheckedKeys,E=void 0===b?[]:b;if(!e.checkStrictly){var T=Object(M.a)(y,!0,c);y=T.checkedKeys,E=T.halfCheckedKeys}s.checkedKeys=y,s.halfCheckedKeys=E}return o("loadedKeys")&&(s.loadedKeys=e.loadedKeys),s}}]),r}(c.Component);F.defaultProps={prefixCls:"rc-tree",showLine:!1,showIcon:!0,selectable:!0,multiple:!1,checkable:!1,disabled:!1,checkStrictly:!1,draggable:!1,defaultExpandParent:!0,autoExpandParent:!1,defaultExpandAll:!1,defaultExpandedKeys:[],defaultCheckedKeys:[],defaultSelectedKeys:[]},F.TreeNode=S.a;var j=F;t.b=j},p5ED:
|
|
|
/*!*********************************************!*\
|
|
|
!*** ./src/components/PreviewAll/index.tsx ***!
|
|
|
\*********************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(e,t,r){"use strict";r(/*! antd/es/button/style */"+L6B");var n=r(/*! antd/es/button */"2/Rp"),i=(r(/*! antd/es/tooltip/style */"5Dmo"),r(/*! antd/es/tooltip */"3S7+")),a=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectSpread2 */"k1fw"),s=r(/*! ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/slicedToArray */"tJVT"),o=r(/*! react */"q1tI"),l=r.n(o),u=r(/*! ./index.less?modules */"vHTk"),c=r.n(u),d=r(/*! @ant-design/icons */"yEEn"),f=r(/*! @/components/monaco-editor */"ZW9T"),h=r(/*! @/utils/util */"1vsH");t.a=function(e){var t=e.name,r=e.data,u=(e.theme,e.type),g=e.filename,p=e.monacoEditor,v=e.className,m=e.style,y=e.close,b=e.onClose,E=e.hasMask,T=Object(o.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),S=Object(s.a)(T,2),k=(S[0],S[1],Object(o.useState)("")),A=Object(s.a)(k,2),x=(A[0],A[1]),L=Object(o.useRef)();g&&(p.filename=g),Object(o.useEffect)((function(){var e,t,r=null===(e=document.cookie)||void 0===e||null===(t=e.replace(/\s/g,""))||void 0===t?void 0:t.split(";");null==r||r.map((function(e){var t=e.split("=");"_educoder_session"===t[0]&&x(t[1])}))}),[]);var D=function(){r.startsWith("http")||r.startsWith("/")?O():Object(h.x)(g||"educoder",r,g)},O=function(){Object(h.v)(g||t,r)};return console.log("data:",r,"fileanme:",g," name:",t),l.a.createElement("div",{style:Object(a.a)({},m||{}),className:"".concat(E&&c.a.bgBlack," ").concat(u?c.a.wrp:"hide")},y&&l.a.createElement("div",{className:c.a.close,ref:L},l.a.createElement(i.a,{title:"点击下载此文件",getPopupContainer:function(){return L.current}},l.a.createElement("span",{onClick:O},l.a.createElement("i",{className:"icon-quxiaozhiding"}))),l.a.createElement(i.a,{title:"关闭",getPopupContainer:function(){return L.current}},l.a.createElement("span",{className:"",onClick:b},l.a.createElement("i",{className:"icon-guanbi1"})))),l.a.createElement("div",{className:"".concat(c.a[v]," ").concat(v," ").concat(c.a.monaco," ").concat("txt"===u?"show":"hide")},"txt"===u&&l.a.createElement(f.b,p)),"audio"===u&&l.a.createElement("audio",{src:"".concat(null!=r&&r.startsWith("/")||(null==r?void 0:r.indexOf("https://"))>-1?r:"data:audio/mp3;base64,").concat(r),autoPlay:!0}),"video"===u&&l.a.createElement(l.a.Fragment,null,null!=r&&r.startsWith("/")?l.a.createElement("video",{controls:!0,src:"".concat(r),autoPlay:!0}):l.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(r),autoPlay:!0})),"pdf"===u&&l.a.createElement("embed",{className:c.a.embed,src:r}),"image"===u&&l.a.createElement(l.a.Fragment,null,l.a.createElement("img",{src:"".concat(null!=r&&r.startsWith("/")||(null==r?void 0:r.indexOf("https://"))>-1?"":"data:image/png;base64,").concat(r)})),"other"===u&&l.a.createElement("div",null,l.a.createElement(n.a,{type:"primary",size:"large",onClick:D},l.a.createElement(d.a,null),"点击下载")),("download"===u||"office"===u)&&l.a.createElement(n.a,{type:"primary",size:"large",onClick:D},l.a.createElement(d.a,null),"点击下载"))}},"rAM+":
|
|
|
/*!*******************************************************************************************************************!*\
|
|
|
!*** ./node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/createForOfIteratorHelper.js ***!
|
|
|
\*******************************************************************************************************************/
|
|
|
/*! exports provided: default */
|
|
|
/*! exports used: default */function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(/*! @babel/runtime/helpers/esm/unsupportedIterableToArray */"Qw5x");function i(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=Object(n.a)(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,a=function(){};return{s:a,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:a}}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 s,o=!0,l=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return o=e.done,e},e:function(e){l=!0,s=e},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw s}}}}},rUJ1:
|
|
|
/*!********************************************!*\
|
|
|
!*** ./node_modules/marked/src/helpers.js ***!
|
|
|
\********************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: escape */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,t){const r=/[&<>"']/,n=/[&<>"']/g,i=/[<>"']|&(?!#?\w+;)/,a=/[<>"']|&(?!#?\w+;)/g,s={"&":"&","<":"<",">":">",'"':""","'":"'"},o=e=>s[e];const l=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function u(e){return e.replace(l,(e,t)=>"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):"")}const c=/(^|[^\[])\^/g;const d=/[^\w:]/g,f=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;const h={},g=/^[^:]+:\/*[^/]*$/,p=/^([^:]+:)[\s\S]*$/,v=/^([^:]+:\/*[^/]*)[\s\S]*$/;function m(e,t){h[" "+e]||(g.test(e)?h[" "+e]=e+"/":h[" "+e]=y(e,"/",!0));const r=-1===(e=h[" "+e]).indexOf(":");return"//"===t.substring(0,2)?r?t:e.replace(p,"$1")+t:"/"===t.charAt(0)?r?t:e.replace(v,"$1")+t:e+t}function y(e,t,r){const n=e.length;if(0===n)return"";let i=0;for(;i<n;){const a=e.charAt(n-i-1);if(a!==t||r){if(a===t||!r)break;i++}else i++}return e.substr(0,n-i)}e.exports={escape:function(e,t){if(t){if(r.test(e))return e.replace(n,o)}else if(i.test(e))return e.replace(a,o);return e},unescape:u,edit:function(e,t){e=e.source||e,t=t||"";const r={replace:(t,n)=>(n=(n=n.source||n).replace(c,"$1"),e=e.replace(t,n),r),getRegex:()=>new RegExp(e,t)};return r},cleanUrl:function(e,t,r){if(e){let e;try{e=decodeURIComponent(u(r)).replace(d,"").toLowerCase()}catch(e){return null}if(0===e.indexOf("javascript:")||0===e.indexOf("vbscript:")||0===e.indexOf("data:"))return null}t&&!f.test(r)&&(r=m(t,r));try{r=encodeURI(r).replace(/%25/g,"%")}catch(e){return null}return r},resolveUrl:m,noopTest:{exec:function(){}},merge:function(e){let t,r,n=1;for(;n<arguments.length;n++)for(r in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},splitCells:function(e,t){const r=e.replace(/\|/g,(e,t,r)=>{let n=!1,i=t;for(;--i>=0&&"\\"===r[i];)n=!n;return n?"|":" |"}).split(/ \|/);let n=0;if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;n<r.length;n++)r[n]=r[n].trim().replace(/\\\|/g,"|");return r},rtrim:y,findClosingBracket:function(e,t){if(-1===e.indexOf(t[1]))return-1;const r=e.length;let n=0,i=0;for(;i<r;i++)if("\\"===e[i])i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return-1},checkSanitizeDeprecation:function(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}}},sboe:
|
|
|
/*!*************************************************!*\
|
|
|
!*** ./node_modules/rc-tree/es/contextTypes.js ***!
|
|
|
\*************************************************/
|
|
|
/*! exports provided: TreeContext */
|
|
|
/*! exports used: TreeContext */function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(/*! react */"q1tI"),i=n.createContext(null)},ulZh:
|
|
|
/*!*****************************************!*\
|
|
|
!*** ./node_modules/hls.js/dist/hls.js ***!
|
|
|
\*****************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,t,r){var n;"undefined"!=typeof window&&(n=function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/dist/",r(r.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":
|
|
|
/*!*********************************************!*\
|
|
|
!*** ./node_modules/eventemitter3/index.js ***!
|
|
|
\*********************************************/
|
|
|
/*! no static exports found */function(e,t,r){"use strict";var n=Object.prototype.hasOwnProperty,i="~";function a(){}function s(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,r,n,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var o=new s(r,n||e,a),l=i?i+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],o]:e._events[l].push(o):(e._events[l]=o,e._eventsCount++),e}function l(e,t){0==--e._eventsCount?e._events=new a:delete e._events[t]}function u(){this._events=new a,this._eventsCount=0}Object.create&&(a.prototype=Object.create(null),(new a).__proto__||(i=!1)),u.prototype.eventNames=function(){var e,t,r=[];if(0===this._eventsCount)return r;for(t in e=this._events)n.call(e,t)&&r.push(i?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},u.prototype.listeners=function(e){var t=i?i+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var n=0,a=r.length,s=new Array(a);n<a;n++)s[n]=r[n].fn;return s},u.prototype.listenerCount=function(e){var t=i?i+e:e,r=this._events[t];return r?r.fn?1:r.length:0},u.prototype.emit=function(e,t,r,n,a,s){var o=i?i+e:e;if(!this._events[o])return!1;var l,u,c=this._events[o],d=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),d){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,r),!0;case 4:return c.fn.call(c.context,t,r,n),!0;case 5:return c.fn.call(c.context,t,r,n,a),!0;case 6:return c.fn.call(c.context,t,r,n,a,s),!0}for(u=1,l=new Array(d-1);u<d;u++)l[u-1]=arguments[u];c.fn.apply(c.context,l)}else{var f,h=c.length;for(u=0;u<h;u++)switch(c[u].once&&this.removeListener(e,c[u].fn,void 0,!0),d){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,t);break;case 3:c[u].fn.call(c[u].context,t,r);break;case 4:c[u].fn.call(c[u].context,t,r,n);break;default:if(!l)for(f=1,l=new Array(d-1);f<d;f++)l[f-1]=arguments[f];c[u].fn.apply(c[u].context,l)}}return!0},u.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},u.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},u.prototype.removeListener=function(e,t,r,n){var a=i?i+e:e;if(!this._events[a])return this;if(!t)return l(this,a),this;var s=this._events[a];if(s.fn)s.fn!==t||n&&!s.once||r&&s.context!==r||l(this,a);else{for(var o=0,u=[],c=s.length;o<c;o++)(s[o].fn!==t||n&&!s[o].once||r&&s[o].context!==r)&&u.push(s[o]);u.length?this._events[a]=1===u.length?u[0]:u:l(this,a)}return this},u.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&l(this,t)):(this._events=new a,this._eventsCount=0),this},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=i,u.EventEmitter=u,e.exports=u},"./node_modules/url-toolkit/src/url-toolkit.js":
|
|
|
/*!*****************************************************!*\
|
|
|
!*** ./node_modules/url-toolkit/src/url-toolkit.js ***!
|
|
|
\*****************************************************/
|
|
|
/*! no static exports found */function(e,t,r){var n,i,a,s,o;n=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,i=/^([^\/?#]*)([^]*)$/,a=/(?:\/|^)\.(?=\/)/g,s=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var n=o.parseURL(e);if(!n)throw new Error("Error trying to parse base URL.");return n.path=o.normalizePath(n.path),o.buildURLFromParts(n)}var a=o.parseURL(t);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return r.alwaysNormalize?(a.path=o.normalizePath(a.path),o.buildURLFromParts(a)):t;var s=o.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var l=i.exec(s.path);s.netLoc=l[1],s.path=l[2]}s.netLoc&&!s.path&&(s.path="/");var u={scheme:s.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(u.netLoc=s.netLoc,"/"!==a.path[0]))if(a.path){var c=s.path,d=c.substring(0,c.lastIndexOf("/")+1)+a.path;u.path=o.normalizePath(d)}else u.path=s.path,a.params||(u.params=s.params,a.query||(u.query=s.query));return null===u.path&&(u.path=r.alwaysNormalize?o.normalizePath(a.path):a.path),o.buildURLFromParts(u)},parseURL:function(e){var t=n.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(a,"");e.length!==(e=e.replace(s,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},e.exports=o},"./node_modules/webworkify-webpack/index.js":
|
|
|
/*!**************************************************!*\
|
|
|
!*** ./node_modules/webworkify-webpack/index.js ***!
|
|
|
\**************************************************/
|
|
|
/*! no static exports found */function(e,t,r){function n(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=e,r.c=t,r.i=function(e){return e},r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/",r.oe=function(e){throw console.error(e),e};var n=r(r.s=ENTRY_MODULE);return n.default||n}function i(e){return(e+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function a(e,t,n){var a={};a[n]=[];var s=t.toString(),o=s.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!o)return a;for(var l,u=o[1],c=new RegExp("(\\\\n|\\W)"+i(u)+"\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)","g");l=c.exec(s);)"dll-reference"!==l[3]&&a[n].push(l[3]);for(c=new RegExp("\\("+i(u)+'\\("(dll-reference\\s([\\.|\\-|\\+|\\w|/|@]+))"\\)\\)\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)',"g");l=c.exec(s);)e[l[2]]||(a[n].push(l[1]),e[l[2]]=r(l[1]).m),a[l[2]]=a[l[2]]||[],a[l[2]].push(l[4]);for(var d,f=Object.keys(a),h=0;h<f.length;h++)for(var g=0;g<a[f[h]].length;g++)d=a[f[h]][g],isNaN(1*d)||(a[f[h]][g]=1*a[f[h]][g]);return a}function s(e){return Object.keys(e).reduce((function(t,r){return t||e[r].length>0}),!1)}e.exports=function(e,t){t=t||{};var i={main:r.m},o=t.all?{main:Object.keys(i.main)}:function(e,t){for(var r={main:[t]},n={main:[]},i={main:{}};s(r);)for(var o=Object.keys(r),l=0;l<o.length;l++){var u=o[l],c=r[u].pop();if(i[u]=i[u]||{},!i[u][c]&&e[u][c]){i[u][c]=!0,n[u]=n[u]||[],n[u].push(c);for(var d=a(e,e[u][c],u),f=Object.keys(d),h=0;h<f.length;h++)r[f[h]]=r[f[h]]||[],r[f[h]]=r[f[h]].concat(d[f[h]])}}return n}(i,e),l="";Object.keys(o).filter((function(e){return"main"!==e})).forEach((function(e){for(var t=0;o[e][t];)t++;o[e].push(t),i[e][t]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",l=l+"var "+e+" = ("+n.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+o[e].map((function(t){return JSON.stringify(t)+": "+i[e][t].toString()})).join(",")+"});\n"})),l=l+"new (("+n.toString().replace("ENTRY_MODULE",JSON.stringify(e))+")({"+o.main.map((function(e){return JSON.stringify(e)+": "+i.main[e].toString()})).join(",")+"}))(self);";var u=new window.Blob([l],{type:"text/javascript"});if(t.bare)return u;var c=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(u),d=new window.Worker(c);return d.objectURL=c,d}},"./src/config.ts":
|
|
|
/*!***********************!*\
|
|
|
!*** ./src/config.ts ***!
|
|
|
\***********************/
|
|
|
/*! exports provided: hlsDefaultConfig, mergeConfig, enableStreamingMode */function(e,t,r){"use strict";r.r(t),r.d(t,"hlsDefaultConfig",(function(){return k})),r.d(t,"mergeConfig",(function(){return A})),r.d(t,"enableStreamingMode",(function(){return x}));var n=r(/*! ./controller/abr-controller */"./src/controller/abr-controller.ts"),i=r(/*! ./controller/audio-stream-controller */"./src/controller/audio-stream-controller.ts"),a=r(/*! ./controller/audio-track-controller */"./src/controller/audio-track-controller.ts"),s=r(/*! ./controller/subtitle-stream-controller */"./src/controller/subtitle-stream-controller.ts"),o=r(/*! ./controller/subtitle-track-controller */"./src/controller/subtitle-track-controller.ts"),l=r(/*! ./controller/buffer-controller */"./src/controller/buffer-controller.ts"),u=r(/*! ./controller/timeline-controller */"./src/controller/timeline-controller.ts"),c=r(/*! ./controller/cap-level-controller */"./src/controller/cap-level-controller.ts"),d=r(/*! ./controller/fps-controller */"./src/controller/fps-controller.ts"),f=r(/*! ./controller/eme-controller */"./src/controller/eme-controller.ts"),h=r(/*! ./controller/cmcd-controller */"./src/controller/cmcd-controller.ts"),g=r(/*! ./utils/xhr-loader */"./src/utils/xhr-loader.ts"),p=r(/*! ./utils/fetch-loader */"./src/utils/fetch-loader.ts"),v=r(/*! ./utils/cues */"./src/utils/cues.ts"),m=r(/*! ./utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts"),y=r(/*! ./utils/logger */"./src/utils/logger.ts");function b(){return(b=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function E(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function T(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?E(Object(r),!0).forEach((function(t){S(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function S(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var k=T(T({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:g.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:n.default,bufferController:l.default,capLevelController:c.default,fpsController:d.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:m.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},{cueHandler:v.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:s.SubtitleStreamController,subtitleTrackController:o.default,timelineController:u.TimelineController,audioStreamController:i.default,audioTrackController:a.default,emeController:f.default,cmcdController:h.default});function A(e,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return b({},e,t)}function x(e){var t=e.loader;t!==p.default&&t!==g.default?(y.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):Object(p.fetchSupported)()&&(e.loader=p.default,e.progressive=!0,e.enableSoftwareAES=!0,y.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}},"./src/controller/abr-controller.ts":
|
|
|
/*!******************************************!*\
|
|
|
!*** ./src/controller/abr-controller.ts ***!
|
|
|
\******************************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t);var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ../utils/ewma-bandwidth-estimator */"./src/utils/ewma-bandwidth-estimator.ts"),a=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=r(/*! ../errors */"./src/errors.ts"),l=r(/*! ../types/loader */"./src/types/loader.ts"),u=r(/*! ../utils/logger */"./src/utils/logger.ts");function c(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var d=function(){function e(e){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=e;var t=e.config;this.bwEstimator=new i.default(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}var t,r,d,f=e.prototype;return f.registerListeners=function(){var e=this.hls;e.on(a.Events.FRAG_LOADING,this.onFragLoading,this),e.on(a.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(a.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(a.Events.ERROR,this.onError,this)},f.unregisterListeners=function(){var e=this.hls;e.off(a.Events.FRAG_LOADING,this.onFragLoading,this),e.off(a.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(a.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(a.Events.ERROR,this.onError,this)},f.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},f.onFragLoading=function(e,t){var r,n=t.frag;n.type===l.PlaylistLevelType.MAIN&&(this.timer||(this.fragCurrent=n,this.partCurrent=null!=(r=t.part)?r:null,this.timer=self.setInterval(this.onCheck,100)))},f.onLevelLoaded=function(e,t){var r=this.hls.config;t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},f._abandonRulesCheck=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,i=r.autoLevelEnabled,o=r.config,l=r.media;if(e&&l){var c=t?t.stats:e.stats,d=t?t.duration:e.duration;if(c.aborted)return u.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),void(this._nextAutoLevel=-1);if(i&&!l.paused&&l.playbackRate&&l.readyState){var f=performance.now()-c.loading.start,h=Math.abs(l.playbackRate);if(!(f<=500*d/h)){var g=r.levels,p=r.minAutoLevel,v=g[e.level],m=c.total||Math.max(c.loaded,Math.round(d*v.maxBitrate/8)),y=Math.max(1,c.bwEstimate?c.bwEstimate/8:1e3*c.loaded/f),b=(m-c.loaded)/y,E=l.currentTime,T=(s.BufferHelper.bufferInfo(l,E,o.maxBufferHole).end-E)/h;if(!(T>=2*d/h||b<=T)){var S,k=Number.POSITIVE_INFINITY;for(S=e.level-1;S>p&&!((k=d*g[S].maxBitrate/(6.4*y))<T);S--);if(!(k>=b)){var A=this.bwEstimator.getEstimate();u.logger.warn("Fragment "+e.sn+(t?" part "+t.index:"")+" of level "+e.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+S+"\n Current BW estimate: "+(Object(n.isFiniteNumber)(A)?(A/1024).toFixed(3):"Unknown")+" Kb/s\n Estimated load time for current fragment: "+b.toFixed(3)+" s\n Estimated load time for the next fragment: "+k.toFixed(3)+" s\n Time to underbuffer: "+T.toFixed(3)+" s"),r.nextLoadLevel=S,this.bwEstimator.sample(f,c.loaded),this.clearTimer(),e.loader&&(this.fragCurrent=this.partCurrent=null,e.loader.abort()),r.trigger(a.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:c})}}}}}},f.onFragLoaded=function(e,t){var r=t.frag,i=t.part;if(r.type===l.PlaylistLevelType.MAIN&&Object(n.isFiniteNumber)(r.sn)){var s=i?i.stats:r.stats,o=i?i.duration:r.duration;if(this.clearTimer(),this.lastLoadedFragLevel=r.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var u=this.hls.levels[r.level],c=(u.loaded?u.loaded.bytes:0)+s.loaded,d=(u.loaded?u.loaded.duration:0)+o;u.loaded={bytes:c,duration:d},u.realBitrate=Math.round(8*c/d)}if(r.bitrateTest){var f={stats:s,frag:r,part:i,id:r.type};this.onFragBuffered(a.Events.FRAG_BUFFERED,f),r.bitrateTest=!1}}},f.onFragBuffered=function(e,t){var r=t.frag,n=t.part,i=n?n.stats:r.stats;if(!i.aborted&&r.type===l.PlaylistLevelType.MAIN&&"initSegment"!==r.sn){var a=i.parsing.end-i.loading.start;this.bwEstimator.sample(a,i.loaded),i.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}},f.onError=function(e,t){switch(t.details){case o.ErrorDetails.FRAG_LOAD_ERROR:case o.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer()}},f.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},f.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,n=r.maxAutoLevel,i=r.config,a=r.minAutoLevel,o=r.media,l=t?t.duration:e?e.duration:0,c=o?o.currentTime:0,d=o&&0!==o.playbackRate?Math.abs(o.playbackRate):1,f=this.bwEstimator?this.bwEstimator.getEstimate():i.abrEwmaDefaultEstimate,h=(s.BufferHelper.bufferInfo(o,c,i.maxBufferHole).end-c)/d,g=this.findBestLevel(f,a,n,h,i.abrBandWidthFactor,i.abrBandWidthUpFactor);if(g>=0)return g;u.logger.trace((h?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var p=l?Math.min(l,i.maxStarvationDelay):i.maxStarvationDelay,v=i.abrBandWidthFactor,m=i.abrBandWidthUpFactor;if(!h){var y=this.bitrateTestDelay;y&&(p=(l?Math.min(l,i.maxLoadingDelay):i.maxLoadingDelay)-y,u.logger.trace("bitrate test took "+Math.round(1e3*y)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*p)+" ms"),v=m=1)}return g=this.findBestLevel(f,a,n,h+p,v,m),Math.max(g,0)},f.findBestLevel=function(e,t,r,n,i,a){for(var s,o=this.fragCurrent,l=this.partCurrent,c=this.lastLoadedFragLevel,d=this.hls.levels,f=d[c],h=!(null==f||null===(s=f.details)||void 0===s||!s.live),g=null==f?void 0:f.codecSet,p=l?l.duration:o?o.duration:0,v=r;v>=t;v--){var m=d[v];if(m&&(!g||m.codecSet===g)){var y=m.details,b=(l?null==y?void 0:y.partTarget:null==y?void 0:y.averagetargetduration)||p,E=void 0;E=v<=c?i*e:a*e;var T=d[v].maxBitrate,S=T*b/E;if(u.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+v+"/"+Math.round(E)+"/"+T+"/"+b+"/"+n+"/"+S),E>T&&(!S||h&&!this.bitrateTestDelay||S<n))return v}}return-1},t=e,(r=[{key:"nextAutoLevel",get:function(){var e=this._nextAutoLevel,t=this.bwEstimator;if(!(-1===e||t&&t.canEstimate()))return e;var r=this.getNextABRAutoLevel();return-1!==e&&(r=Math.min(e,r)),r},set:function(e){this._nextAutoLevel=e}}])&&c(t.prototype,r),d&&c(t,d),e}();t.default=d},"./src/controller/audio-stream-controller.ts":
|
|
|
/*!***************************************************!*\
|
|
|
!*** ./src/controller/audio-stream-controller.ts ***!
|
|
|
\***************************************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t);var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),a=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),l=r(/*! ../types/level */"./src/types/level.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),c=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),d=r(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts"),f=r(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts"),h=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),g=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),p=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),v=r(/*! ../errors */"./src/errors.ts"),m=r(/*! ../utils/logger */"./src/utils/logger.ts");function y(){return(y=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function b(e,t){return(b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var E=function(e){var t,r;function E(t,r){var n;return(n=e.call(this,t,r,"[audio-stream-controller]")||this).videoBuffer=null,n.videoTrackCC=-1,n.waitingVideoCC=-1,n.audioSwitch=!1,n.trackId=-1,n.waitingData=null,n.mainDetails=null,n.bufferFlushed=!1,n._registerListeners(),n}r=e,(t=E).prototype=Object.create(r.prototype),t.prototype.constructor=t,b(t,r);var T=E.prototype;return T.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},T._registerListeners=function(){var e=this.hls;e.on(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(a.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(a.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(a.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(a.Events.ERROR,this.onError,this),e.on(a.Events.BUFFER_RESET,this.onBufferReset,this),e.on(a.Events.BUFFER_CREATED,this.onBufferCreated,this),e.on(a.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(a.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(a.Events.FRAG_BUFFERED,this.onFragBuffered,this)},T._unregisterListeners=function(){var e=this.hls;e.off(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(a.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(a.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(a.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(a.Events.ERROR,this.onError,this),e.off(a.Events.BUFFER_RESET,this.onBufferReset,this),e.off(a.Events.BUFFER_CREATED,this.onBufferCreated,this),e.off(a.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(a.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(a.Events.FRAG_BUFFERED,this.onFragBuffered,this)},T.onInitPtsFound=function(e,t){var r=t.frag,n=t.id,a=t.initPTS;if("main"===n){var s=r.cc;this.initPTS[r.cc]=a,this.log("InitPTS for cc: "+s+" found from main: "+a),this.videoTrackCC=s,this.state===i.State.WAITING_INIT_PTS&&this.tick()}},T.startLoad=function(e){if(!this.levels)return this.startPosition=e,void(this.state=i.State.STOPPED);var t=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),this.fragLoadError=0,t>0&&-1===e?(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),this.state=i.State.IDLE):(this.loadedmetadata=!1,this.state=i.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()},T.doTick=function(){switch(this.state){case i.State.IDLE:this.doTickIdle();break;case i.State.WAITING_TRACK:var t,r=this.levels,n=this.trackId,a=null==r||null===(t=r[n])||void 0===t?void 0:t.details;if(a){if(this.waitForCdnTuneIn(a))break;this.state=i.State.WAITING_INIT_PTS}break;case i.State.FRAG_LOADING_WAITING_RETRY:var o,l=performance.now(),u=this.retryDate;(!u||l>=u||null!==(o=this.media)&&void 0!==o&&o.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=i.State.IDLE);break;case i.State.WAITING_INIT_PTS:var c=this.waitingData;if(c){var d=c.frag,f=c.part,h=c.cache,p=c.complete;if(void 0!==this.initPTS[d.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=i.State.FRAG_LOADING;var v={frag:d,part:f,payload:h.flush(),networkDetails:null};this._handleFragmentLoadProgress(v),p&&e.prototype._handleFragmentLoadComplete.call(this,v)}else if(this.videoTrackCC!==this.waitingVideoCC)m.logger.log("Waiting fragment cc ("+d.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var y=this.getLoadPosition(),b=s.BufferHelper.bufferInfo(this.mediaBuffer,y,this.config.maxBufferHole);Object(g.fragmentWithinToleranceTest)(b.end,this.config.maxFragLookUpTolerance,d)<0&&(m.logger.log("Waiting fragment cc ("+d.cc+") @ "+d.start+" cancelled because another fragment at "+b.end+" is needed"),this.clearWaitingFragment())}}else this.state=i.State.IDLE}this.onTickEnd()},T.clearWaitingFragment=function(){var e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=i.State.IDLE)},T.onTickEnd=function(){var e=this.media;if(e&&e.readyState){var t=(this.mediaBuffer?this.mediaBuffer:e).buffered;!this.loadedmetadata&&t.length&&(this.loadedmetadata=!0),this.lastCurrentTime=e.currentTime}},T.doTickIdle=function(){var e,t,r=this.hls,n=this.levels,s=this.media,o=this.trackId,l=r.config;if(n&&n[o]&&(s||!this.startFragRequested&&l.startFragPrefetch)){var d=n[o].details;if(!d||d.live&&this.levelLastLoaded!==o||this.waitForCdnTuneIn(d))this.state=i.State.WAITING_TRACK;else{this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,c.ElementaryStreamTypes.AUDIO,u.PlaylistLevelType.AUDIO));var f=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,u.PlaylistLevelType.AUDIO);if(null!==f){var h=f.len,g=this.getMaxBufferLength(),p=this.audioSwitch;if(!(h>=g)||p){if(!p&&this._streamEnded(f,d))return r.trigger(a.Events.BUFFER_EOS,{type:"audio"}),void(this.state=i.State.ENDED);var v=d.fragments[0].start,m=f.end;if(p){var y=this.getLoadPosition();m=y,d.PTSKnown&&y<v&&(f.end>v||f.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),s.currentTime=v+.05)}var b=this.getNextFragment(m,d);b?"identity"!==(null===(e=b.decryptdata)||void 0===e?void 0:e.keyFormat)||null!==(t=b.decryptdata)&&void 0!==t&&t.key?this.loadFragment(b,d,m):this.loadKey(b,d):this.bufferFlushed=!0}}}}},T.getMaxBufferLength=function(){var t=e.prototype.getMaxBufferLength.call(this),r=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,u.PlaylistLevelType.MAIN);return null===r?t:Math.max(t,r.len)},T.onMediaDetaching=function(){this.videoBuffer=null,e.prototype.onMediaDetaching.call(this)},T.onAudioTracksUpdated=function(e,t){var r=t.audioTracks;this.resetTransmuxer(),this.levels=r.map((function(e){return new l.Level(e)}))},T.onAudioTrackSwitching=function(e,t){var r=!!t.url;this.trackId=t.id;var n=this.fragCurrent;null!=n&&n.loader&&n.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),r?this.setInterval(100):this.resetTransmuxer(),r?(this.audioSwitch=!0,this.state=i.State.IDLE):this.state=i.State.STOPPED,this.tick()},T.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},T.onLevelLoaded=function(e,t){this.mainDetails=t.details},T.onAudioTrackLoaded=function(e,t){var r,n=this.levels,a=t.details,s=t.id;if(n){this.log("Track "+s+" loaded ["+a.startSN+","+a.endSN+"],duration:"+a.totalduration);var o=n[s],l=0;if(a.live||null!==(r=o.details)&&void 0!==r&&r.live){var u=this.mainDetails;if(a.fragments[0]||(a.deltaUpdateFailed=!0),a.deltaUpdateFailed||!u)return;!o.details&&a.hasProgramDateTime&&u.hasProgramDateTime?(Object(p.alignMediaPlaylistByPDT)(a,u),l=a.fragments[0].start):l=this.alignPlaylists(a,o.details)}o.details=a,this.levelLastLoaded=s,this.startFragRequested||!this.mainDetails&&a.live||this.setStartPosition(o.details,l),this.state!==i.State.WAITING_TRACK||this.waitForCdnTuneIn(a)||(this.state=i.State.IDLE),this.tick()}else this.warn("Audio tracks were reset while loading level "+s)},T._handleFragmentLoadProgress=function(e){var t,r=e.frag,n=e.part,a=e.payload,s=this.config,o=this.trackId,l=this.levels;if(l){var c=l[o];console.assert(c,"Audio track is defined on fragment load progress");var g=c.details;console.assert(g,"Audio track details are defined on fragment load progress");var p=s.defaultAudioCodec||c.audioCodec||"mp4a.40.2",v=this.transmuxer;v||(v=this.transmuxer=new f.default(this.hls,u.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var y=this.initPTS[r.cc],b=null===(t=r.initSegment)||void 0===t?void 0:t.data;if(void 0!==y){var E=n?n.index:-1,T=-1!==E,S=new h.ChunkMetadata(r.level,r.sn,r.stats.chunkCount,a.byteLength,E,T);v.push(a,b,p,"",r,n,g.totalduration,!1,S,y)}else m.logger.log("Unknown video PTS for cc "+r.cc+", waiting for video PTS before demuxing audio frag "+r.sn+" of ["+g.startSN+" ,"+g.endSN+"],track "+o),(this.waitingData=this.waitingData||{frag:r,part:n,cache:new d.default,complete:!1}).cache.push(new Uint8Array(a)),this.waitingVideoCC=this.videoTrackCC,this.state=i.State.WAITING_INIT_PTS}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},T._handleFragmentLoadComplete=function(t){this.waitingData?this.waitingData.complete=!0:e.prototype._handleFragmentLoadComplete.call(this,t)},T.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},T.onBufferCreated=function(e,t){var r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer)},T.onFragBuffered=function(e,t){var r=t.frag,n=t.part;r.type===u.PlaylistLevelType.AUDIO&&(this.fragContextChanged(r)?this.warn("Fragment "+r.sn+(n?" p: "+n.index:"")+" of level "+r.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch):("initSegment"!==r.sn&&(this.fragPrevious=r,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(a.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(r,n)))},T.onError=function(t,r){switch(r.details){case v.ErrorDetails.FRAG_LOAD_ERROR:case v.ErrorDetails.FRAG_LOAD_TIMEOUT:case v.ErrorDetails.KEY_LOAD_ERROR:case v.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(u.PlaylistLevelType.AUDIO,r);break;case v.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case v.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==i.State.ERROR&&this.state!==i.State.STOPPED&&(this.state=r.fatal?i.State.ERROR:i.State.IDLE,this.warn(r.details+" while loading frag, switching to "+this.state+" state"));break;case v.ErrorDetails.BUFFER_FULL_ERROR:if("audio"===r.parent&&(this.state===i.State.PARSING||this.state===i.State.PARSED)){var n=!0,a=this.getFwdBufferInfo(this.mediaBuffer,u.PlaylistLevelType.AUDIO);a&&a.len>.5&&(n=!this.reduceMaxBufferLength(a.len)),n&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,e.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}}},T.onBufferFlushed=function(e,t){t.type===c.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},T._handleTransmuxComplete=function(e){var t,r="audio",n=this.hls,s=e.remuxResult,o=e.chunkMeta,l=this.getCurrentContext(o);if(!l)return this.warn("The loading context changed while buffering fragment "+o.sn+" of level "+o.level+". This chunk will not be buffered."),void this.resetLiveStartWhenNotLoaded(o.level);var u=l.frag,d=l.part,f=s.audio,h=s.text,g=s.id3,p=s.initSegment;if(!this.fragContextChanged(u)){if(this.state=i.State.PARSING,this.audioSwitch&&f&&this.completeAudioSwitch(),null!=p&&p.tracks&&(this._bufferInitSegment(p.tracks,u,o),n.trigger(a.Events.FRAG_PARSING_INIT_SEGMENT,{frag:u,id:r,tracks:p.tracks})),f){var v=f.startPTS,m=f.endPTS,b=f.startDTS,E=f.endDTS;d&&(d.elementaryStreams[c.ElementaryStreamTypes.AUDIO]={startPTS:v,endPTS:m,startDTS:b,endDTS:E}),u.setElementaryStreamInfo(c.ElementaryStreamTypes.AUDIO,v,m,b,E),this.bufferFragmentData(f,u,d,o)}if(null!=g&&null!==(t=g.samples)&&void 0!==t&&t.length){var T=y({frag:u,id:r},g);n.trigger(a.Events.FRAG_PARSING_METADATA,T)}if(h){var S=y({frag:u,id:r},h);n.trigger(a.Events.FRAG_PARSING_USERDATA,S)}}},T._bufferInitSegment=function(e,t,r){if(this.state===i.State.PARSING){e.video&&delete e.video;var n=e.audio;if(n){n.levelCodec=n.codec,n.id="audio",this.log("Init audio buffer, container:"+n.container+", codecs[parsed]=["+n.codec+"]"),this.hls.trigger(a.Events.BUFFER_CODECS,e);var s=n.initSegment;if(null!=s&&s.byteLength){var o={type:"audio",frag:t,part:null,chunkMeta:r,parent:t.type,data:s};this.hls.trigger(a.Events.BUFFER_APPENDING,o)}this.tick()}}},T.loadFragment=function(t,r,a){var s=this.fragmentTracker.getState(t);this.fragCurrent=t,(this.audioSwitch||s===o.FragmentState.NOT_LOADED||s===o.FragmentState.PARTIAL)&&("initSegment"===t.sn?this._loadInitSegment(t):r.live&&!Object(n.isFiniteNumber)(this.initPTS[t.cc])?(this.log("Waiting for video PTS in continuity counter "+t.cc+" of live stream before loading audio fragment "+t.sn+" of level "+this.trackId),this.state=i.State.WAITING_INIT_PTS):(this.startFragRequested=!0,e.prototype.loadFragment.call(this,t,r,a)))},T.completeAudioSwitch=function(){var t=this.hls,r=this.media,n=this.trackId;r&&(this.log("Switching audio track : flushing all audio"),e.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,t.trigger(a.Events.AUDIO_TRACK_SWITCHED,{id:n})},E}(i.default);t.default=E},"./src/controller/audio-track-controller.ts":
|
|
|
/*!**************************************************!*\
|
|
|
!*** ./src/controller/audio-track-controller.ts ***!
|
|
|
\**************************************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t);var n=r(/*! ../events */"./src/events.ts"),i=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),s=r(/*! ../types/loader */"./src/types/loader.ts");function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var u=function(e){var t,r;function a(t){var r;return(r=e.call(this,t,"[audio-track-controller]")||this).tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.trackName="",r.selectDefaultTrack=!0,r.registerListeners(),r}r=e,(t=a).prototype=Object.create(r.prototype),t.prototype.constructor=t,l(t,r);var u,c,d,f=a.prototype;return f.registerListeners=function(){var e=this.hls;e.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(n.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(n.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(n.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(n.Events.ERROR,this.onError,this)},f.unregisterListeners=function(){var e=this.hls;e.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(n.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(n.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(n.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(n.Events.ERROR,this.onError,this)},f.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,e.prototype.destroy.call(this)},f.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},f.onManifestParsed=function(e,t){this.tracks=t.audioTracks||[]},f.onAudioTrackLoaded=function(e,t){var r=t.id,n=t.details,i=this.tracksInGroup[r];if(i){var a=i.details;i.details=t.details,this.log("audioTrack "+r+" loaded ["+n.startSN+"-"+n.endSN+"]"),r===this.trackId&&(this.retryCount=0,this.playlistLoaded(r,t,a))}else this.warn("Invalid audio track id "+r)},f.onLevelLoading=function(e,t){this.switchLevel(t.level)},f.onLevelSwitching=function(e,t){this.switchLevel(t.level)},f.switchLevel=function(e){var t=this.hls.levels[e];if(null!=t&&t.audioGroupIds){var r=t.audioGroupIds[t.urlId];if(this.groupId!==r){this.groupId=r;var i=this.tracks.filter((function(e){return!r||e.groupId===r}));this.selectDefaultTrack&&!i.some((function(e){return e.default}))&&(this.selectDefaultTrack=!1),this.tracksInGroup=i;var a={audioTracks:i};this.log("Updating audio tracks, "+i.length+' track(s) found in "'+r+'" group-id'),this.hls.trigger(n.Events.AUDIO_TRACKS_UPDATED,a),this.selectInitialTrack()}}},f.onError=function(t,r){e.prototype.onError.call(this,t,r),!r.fatal&&r.context&&r.context.type===s.PlaylistContextType.AUDIO_TRACK&&r.context.id===this.trackId&&r.context.groupId===this.groupId&&this.retryLoadingOrFail(r)},f.setAudioTrack=function(e){var t=this.tracksInGroup;if(e<0||e>=t.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var r=t[this.trackId];this.log("Now switching to audio-track index "+e);var i=t[e],a=i.id,s=i.groupId,o=void 0===s?"":s,l=i.name,u=i.type,c=i.url;if(this.trackId=e,this.trackName=l,this.selectDefaultTrack=!1,this.hls.trigger(n.Events.AUDIO_TRACK_SWITCHING,{id:a,groupId:o,name:l,type:u,url:c}),!i.details||i.details.live){var d=this.switchParams(i.url,null==r?void 0:r.details);this.loadPlaylist(d)}}},f.selectInitialTrack=function(){var e=this.tracksInGroup;console.assert(e.length,"Initial audio track should be selected when tracks are known");var t=this.trackName,r=this.findTrackId(t)||this.findTrackId();-1!==r?this.setAudioTrack(r):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(n.Events.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},f.findTrackId=function(e){for(var t=this.tracksInGroup,r=0;r<t.length;r++){var n=t[r];if((!this.selectDefaultTrack||n.default)&&(!e||e===n.name))return n.id}return-1},f.loadPlaylist=function(e){var t=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(t)){var r=t.id,i=t.groupId,a=t.url;if(e)try{a=e.addDirectives(a)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}this.log("loading audio-track playlist for id: "+r),this.clearTimer(),this.hls.trigger(n.Events.AUDIO_TRACK_LOADING,{url:a,id:r,groupId:i,deliveryDirectives:e||null})}},u=a,(c=[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}}])&&o(u.prototype,c),d&&o(u,d),a}(a.default);t.default=u},"./src/controller/base-playlist-controller.ts":
|
|
|
/*!****************************************************!*\
|
|
|
!*** ./src/controller/base-playlist-controller.ts ***!
|
|
|
\****************************************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return l}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ../types/level */"./src/types/level.ts"),a=r(/*! ./level-helper */"./src/controller/level-helper.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../errors */"./src/errors.ts"),l=function(){function e(e,t){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=s.logger.log.bind(s.logger,t+":"),this.warn=s.logger.warn.bind(s.logger,t+":"),this.hls=e}var t=e.prototype;return t.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},t.onError=function(e,t){t.fatal&&t.type===o.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},t.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},t.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},t.stopLoad=function(){this.canLoad=!1,this.clearTimer()},t.switchParams=function(e,t){var r=null==t?void 0:t.renditionReports;if(r)for(var a=0;a<r.length;a++){var s=r[a],o=""+s.URI;if(o===e.substr(-o.length)){var l=parseInt(s["LAST-MSN"]),u=parseInt(s["LAST-PART"]);if(t&&this.hls.config.lowLatencyMode){var c=Math.min(t.age-t.partTarget,t.targetduration);void 0!==u&&c>t.partTarget&&(u+=1)}if(Object(n.isFiniteNumber)(l))return new i.HlsUrlParameters(l,Object(n.isFiniteNumber)(u)?u:void 0,i.HlsSkip.No)}}},t.loadPlaylist=function(e){},t.shouldLoadTrack=function(e){return this.canLoad&&e&&!!e.url&&(!e.details||e.details.live)},t.playlistLoaded=function(e,t,r){var n=this,i=t.details,s=t.stats,o=s.loading.end?Math.max(0,self.performance.now()-s.loading.end):0;if(i.advancedDateTime=Date.now()-o,i.live||null!=r&&r.live){if(i.reloaded(r),r&&this.log("live playlist "+e+" "+(i.advanced?"REFRESHED "+i.lastPartSn+"-"+i.lastPartIndex:"MISSED")),r&&i.fragments.length>0&&Object(a.mergeDetails)(r,i),!this.canLoad||!i.live)return;var l,u=void 0,c=void 0;if(i.canBlockReload&&i.endSN&&i.advanced){var d=this.hls.config.lowLatencyMode,f=i.lastPartSn,h=i.endSN,g=i.lastPartIndex,p=f===h;-1!==g?(u=p?h+1:f,c=p?d?0:g:g+1):u=h+1;var v=i.age,m=v+i.ageHeader,y=Math.min(m-i.partTarget,1.5*i.targetduration);if(y>0){if(r&&y>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+y+" with playlist age: "+i.age),y=0;else{var b=Math.floor(y/i.targetduration);u+=b,void 0!==c&&(c+=Math.round(y%i.targetduration/i.partTarget)),this.log("CDN Tune-in age: "+i.ageHeader+"s last advanced "+v.toFixed(2)+"s goal: "+y+" skip sn "+b+" to part "+c)}i.tuneInGoal=y}if(l=this.getDeliveryDirectives(i,t.deliveryDirectives,u,c),d||!p)return void this.loadPlaylist(l)}else l=this.getDeliveryDirectives(i,t.deliveryDirectives,u,c);var E=Object(a.computeReloadInterval)(i,s);void 0!==u&&i.canBlockReload&&(E-=i.partTarget||1),this.log("reload live playlist "+e+" in "+Math.round(E)+" ms"),this.timer=self.setTimeout((function(){return n.loadPlaylist(l)}),E)}else this.clearTimer()},t.getDeliveryDirectives=function(e,t,r,n){var a=Object(i.getSkipValue)(e,r);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,n=t.part,a=i.HlsSkip.No),new i.HlsUrlParameters(r,n,a)},t.retryLoadingOrFail=function(e){var t,r=this,n=this.hls.config,i=this.retryCount<n.levelLoadingMaxRetry;if(i)if(this.retryCount++,e.details.indexOf("LoadTimeOut")>-1&&null!==(t=e.context)&&void 0!==t&&t.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+e.details+'"'),this.loadPlaylist();else{var a=Math.min(Math.pow(2,this.retryCount)*n.levelLoadingRetryDelay,n.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout((function(){return r.loadPlaylist()}),a),this.warn("retry playlist loading #"+this.retryCount+" in "+a+' ms after "'+e.details+'"')}else this.warn('cannot recover from error "'+e.details+'"'),this.clearTimer(),e.fatal=!0;return i},e}()},"./src/controller/base-stream-controller.ts":
|
|
|
/*!**************************************************!*\
|
|
|
!*** ./src/controller/base-stream-controller.ts ***!
|
|
|
\**************************************************/
|
|
|
/*! exports provided: State, default */function(e,t,r){"use strict";r.r(t),r.d(t,"State",(function(){return T})),r.d(t,"default",(function(){return S}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ../task-loop */"./src/task-loop.ts"),a=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),s=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=r(/*! ../utils/logger */"./src/utils/logger.ts"),l=r(/*! ../events */"./src/events.ts"),u=r(/*! ../errors */"./src/errors.ts"),c=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),d=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),f=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),h=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),g=r(/*! ./level-helper */"./src/controller/level-helper.ts"),p=r(/*! ../loader/fragment-loader */"./src/loader/fragment-loader.ts"),v=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),m=r(/*! ../utils/time-ranges */"./src/utils/time-ranges.ts"),y=r(/*! ../types/loader */"./src/types/loader.ts");function b(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function E(e,t){return(E=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var T={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",BACKTRACKING:"BACKTRACKING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},S=function(e){var t,r;function i(t,r,n){var i;return(i=e.call(this)||this).hls=void 0,i.fragPrevious=null,i.fragCurrent=null,i.fragmentTracker=void 0,i.transmuxer=null,i._state=T.STOPPED,i.media=void 0,i.mediaBuffer=void 0,i.config=void 0,i.bitrateTest=!1,i.lastCurrentTime=0,i.nextLoadPosition=0,i.startPosition=0,i.loadedmetadata=!1,i.fragLoadError=0,i.retryDate=0,i.levels=null,i.fragmentLoader=void 0,i.levelLastLoaded=null,i.startFragRequested=!1,i.decrypter=void 0,i.initPTS=[],i.onvseeking=null,i.onvended=null,i.logPrefix="",i.log=void 0,i.warn=void 0,i.logPrefix=n,i.log=o.logger.log.bind(o.logger,n+":"),i.warn=o.logger.warn.bind(o.logger,n+":"),i.hls=t,i.fragmentLoader=new p.default(t.config),i.fragmentTracker=r,i.config=t.config,i.decrypter=new v.default(t,t.config),t.on(l.Events.KEY_LOADED,i.onKeyLoaded,function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(i)),i}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,E(t,r);var S,k,A,x=i.prototype;return x.doTick=function(){this.onTickEnd()},x.onTickEnd=function(){},x.startLoad=function(e){},x.stopLoad=function(){this.fragmentLoader.abort();var e=this.fragCurrent;e&&this.fragmentTracker.removeFragment(e),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=T.STOPPED},x._streamEnded=function(e,t){var r=this.fragCurrent,n=this.fragmentTracker;if(!t.live&&r&&r.sn===t.endSN&&!e.nextStart){var i=n.getState(r);return i===a.FragmentState.PARTIAL||i===a.FragmentState.OK}return!1},x.onMediaAttached=function(e,t){var r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);var n=this.config;this.levels&&n.autoStartLoad&&this.state===T.STOPPED&&this.startLoad(n.startPosition)},x.onMediaDetaching=function(){var e=this.media;null!=e&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},x.onMediaSeeking=function(){var e=this.config,t=this.fragCurrent,r=this.media,i=this.mediaBuffer,a=this.state,o=r?r.currentTime:0,l=s.BufferHelper.bufferInfo(i||r,o,e.maxBufferHole);if(this.log("media seeking to "+(Object(n.isFiniteNumber)(o)?o.toFixed(3):o)+", state: "+a),a===T.ENDED)this.resetLoadingState();else if(t&&!l.len){var u=e.maxFragLookUpTolerance,c=t.start-u,d=o>t.start+t.duration+u;(o<c||d)&&(d&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.loader.abort()),this.resetLoadingState())}r&&(this.lastCurrentTime=o),this.loadedmetadata||l.len||(this.nextLoadPosition=this.startPosition=o),this.tickImmediate()},x.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},x.onKeyLoaded=function(e,t){if(this.state===T.KEY_LOADING&&t.frag===this.fragCurrent&&this.levels){this.state=T.IDLE;var r=this.levels[t.frag.level].details;r&&this.loadFragment(t.frag,r,t.frag.start)}},x.onHandlerDestroying=function(){this.stopLoad(),e.prototype.onHandlerDestroying.call(this)},x.onHandlerDestroyed=function(){this.state=T.STOPPED,this.hls.off(l.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,e.prototype.onHandlerDestroyed.call(this)},x.loadKey=function(e,t){this.log("Loading key for "+e.sn+" of ["+t.startSN+"-"+t.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+e.level),this.state=T.KEY_LOADING,this.fragCurrent=e,this.hls.trigger(l.Events.KEY_LOADING,{frag:e})},x.loadFragment=function(e,t,r){this._loadFragForPlayback(e,t,r)},x._loadFragForPlayback=function(e,t,r){var n=this;this._doFragLoad(e,t,r,(function(t){if(n.fragContextChanged(e))return n.warn("Fragment "+e.sn+(t.part?" p: "+t.part.index:"")+" of level "+e.level+" was dropped during download."),void n.fragmentTracker.removeFragment(e);e.stats.chunkCount++,n._handleFragmentLoadProgress(t)})).then((function(t){if(t){n.fragLoadError=0;var r=n.state;if(!n.fragContextChanged(e))return"payload"in t&&(n.log("Loaded fragment "+e.sn+" of level "+e.level),n.hls.trigger(l.Events.FRAG_LOADED,t),n.state===T.BACKTRACKING)?(n.fragmentTracker.backtrack(e,t),void n.resetFragmentLoading(e)):void n._handleFragmentLoadComplete(t);(r===T.FRAG_LOADING||r===T.BACKTRACKING||!n.fragCurrent&&r===T.PARSING)&&(n.fragmentTracker.removeFragment(e),n.state=T.IDLE)}})).catch((function(t){n.warn(t),n.resetFragmentLoading(e)}))},x.flushMainBuffer=function(e,t,r){if(void 0===r&&(r=null),e-t){var n={startOffset:e,endOffset:t,type:r};this.fragLoadError=0,this.hls.trigger(l.Events.BUFFER_FLUSHING,n)}},x._loadInitSegment=function(e){var t=this;this._doFragLoad(e).then((function(r){if(!r||t.fragContextChanged(e)||!t.levels)throw new Error("init load aborted");return r})).then((function(r){var n=t.hls,i=r.payload,a=e.decryptdata;if(i&&i.byteLength>0&&a&&a.key&&a.iv&&"AES-128"===a.method){var s=self.performance.now();return t.decrypter.webCryptoDecrypt(new Uint8Array(i),a.key.buffer,a.iv.buffer).then((function(t){var i=self.performance.now();return n.trigger(l.Events.FRAG_DECRYPTED,{frag:e,payload:t,stats:{tstart:s,tdecrypt:i}}),r.payload=t,r}))}return r})).then((function(r){var n=t.fragCurrent,i=t.hls,a=t.levels;if(!a)throw new Error("init load aborted, missing levels");var s=a[e.level].details;console.assert(s,"Level details are defined when init segment is loaded");var o=e.stats;t.state=T.IDLE,t.fragLoadError=0,e.data=new Uint8Array(r.payload),o.parsing.start=o.buffering.start=self.performance.now(),o.parsing.end=o.buffering.end=self.performance.now(),r.frag===n&&i.trigger(l.Events.FRAG_BUFFERED,{stats:o,frag:n,part:null,id:e.type}),t.tick()})).catch((function(r){t.warn(r),t.resetFragmentLoading(e)}))},x.fragContextChanged=function(e){var t=this.fragCurrent;return!e||!t||e.level!==t.level||e.sn!==t.sn||e.urlId!==t.urlId},x.fragBufferedComplete=function(e,t){var r=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+e.type+" sn: "+e.sn+(t?" part: "+t.index:"")+" of "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+e.level+" "+m.default.toString(s.BufferHelper.getBuffered(r))),this.state=T.IDLE,this.tick()},x._handleFragmentLoadComplete=function(e){var t=this.transmuxer;if(t){var r=e.frag,n=e.part,i=e.partsLoaded,a=!i||0===i.length||i.some((function(e){return!e})),s=new c.ChunkMetadata(r.level,r.sn,r.stats.chunkCount+1,0,n?n.index:-1,!a);t.flush(s)}},x._handleFragmentLoadProgress=function(e){},x._doFragLoad=function(e,t,r,i){var a=this;if(void 0===r&&(r=null),!this.levels)throw new Error("frag load aborted, missing levels");if(r=Math.max(e.start,r||0),this.config.lowLatencyMode&&t){var s=t.partList;if(s&&i){r>e.end&&t.fragmentHint&&(e=t.fragmentHint);var o=this.getNextPart(s,e,r);if(o>-1){var u=s[o];return this.log("Loading part sn: "+e.sn+" p: "+u.index+" cc: "+e.cc+" of playlist ["+t.startSN+"-"+t.endSN+"] parts [0-"+o+"-"+(s.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(r.toFixed(3))),this.nextLoadPosition=u.start+u.duration,this.state=T.FRAG_LOADING,this.hls.trigger(l.Events.FRAG_LOADING,{frag:e,part:s[o],targetBufferTime:r}),this.doFragPartsLoad(e,s,o,i).catch((function(e){return a.handleFragLoadError(e)}))}if(!e.url||this.loadedEndOfParts(s,r))return Promise.resolve(null)}}return this.log("Loading fragment "+e.sn+" cc: "+e.cc+" "+(t?"of ["+t.startSN+"-"+t.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(r.toFixed(3))),Object(n.isFiniteNumber)(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=T.FRAG_LOADING,this.hls.trigger(l.Events.FRAG_LOADING,{frag:e,targetBufferTime:r}),this.fragmentLoader.load(e,i).catch((function(e){return a.handleFragLoadError(e)}))},x.doFragPartsLoad=function(e,t,r,n){var i=this;return new Promise((function(a,s){var o=[];!function r(u){var c=t[u];i.fragmentLoader.loadPart(e,c,n).then((function(n){o[c.index]=n;var s=n.part;i.hls.trigger(l.Events.FRAG_LOADED,n);var d=t[u+1];if(!d||d.fragment!==e)return a({frag:e,part:s,partsLoaded:o});r(u+1)})).catch(s)}(r)}))},x.handleFragLoadError=function(e){var t=e.data;return t&&t.details===u.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(l.Events.ERROR,t),null},x._handleTransmuxerFlush=function(e){var t=this.getCurrentContext(e);if(t&&this.state===T.PARSING){var r=t.frag,n=t.part,i=t.level,a=self.performance.now();r.stats.parsing.end=a,n&&(n.stats.parsing.end=a),this.updateLevelTiming(r,n,i,e.partial)}else this.fragCurrent||(this.state=T.IDLE)},x.getCurrentContext=function(e){var t=this.levels,r=e.level,n=e.sn,i=e.part;if(!t||!t[r])return this.warn("Levels object was unset while buffering fragment "+n+" of level "+r+". The current chunk will not be buffered."),null;var a=t[r],s=i>-1?Object(g.getPartWith)(a,n,i):null,o=s?s.fragment:Object(g.getFragmentWithSN)(a,n,this.fragCurrent);return o?{frag:o,part:s,level:a}:null},x.bufferFragmentData=function(e,t,r,n){if(e&&this.state===T.PARSING){var i=e.data1,a=e.data2,s=i;if(i&&a&&(s=Object(d.appendUint8Array)(i,a)),s&&s.length){var o={type:e.type,frag:t,part:r,chunkMeta:n,parent:t.type,data:s};this.hls.trigger(l.Events.BUFFER_APPENDING,o),e.dropped&&e.independent&&!r&&this.flushBufferGap(t)}}},x.flushBufferGap=function(e){var t=this.media;if(t)if(s.BufferHelper.isBuffered(t,t.currentTime)){var r=t.currentTime,n=s.BufferHelper.bufferInfo(t,r,0),i=e.duration,a=Math.min(2*this.config.maxFragLookUpTolerance,.25*i),o=Math.max(Math.min(e.start-a,n.end-a),r+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}else this.flushMainBuffer(0,e.start)},x.getFwdBufferInfo=function(e,t){var r=this.config,i=this.getLoadPosition();if(!Object(n.isFiniteNumber)(i))return null;var a=s.BufferHelper.bufferInfo(e,i,r.maxBufferHole);if(0===a.len&&void 0!==a.nextStart){var o=this.fragmentTracker.getBufferedFrag(i,t);if(o&&a.nextStart<o.end)return s.BufferHelper.bufferInfo(e,i,Math.max(a.nextStart,r.maxBufferHole))}return a},x.getMaxBufferLength=function(e){var t,r=this.config;return t=e?Math.max(8*r.maxBufferSize/e,r.maxBufferLength):r.maxBufferLength,Math.min(t,r.maxMaxBufferLength)},x.reduceMaxBufferLength=function(e){var t=this.config,r=e||t.maxBufferLength;return t.maxMaxBufferLength>=r&&(t.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+t.maxMaxBufferLength+"s"),!0)},x.getNextFragment=function(e,t){var r,n,i=t.fragments,a=i.length;if(!a)return null;var s,o=this.config,l=i[0].start;if(t.live){var u=o.initialLiveManifestSize;if(a<u)return this.warn("Not enough fragments to start playback (have: "+a+", need: "+u+")"),null;t.PTSKnown||this.startFragRequested||-1!==this.startPosition||(s=this.getInitialLiveFragment(t,i),this.startPosition=s?this.hls.liveSyncPosition||s.start:e)}else e<=l&&(s=i[0]);if(!s){var c=o.lowLatencyMode?t.partEnd:t.fragmentEnd;s=this.getFragmentAtPosition(e,c,t)}return null===(r=s)||void 0===r||!r.initSegment||null!==(n=s)&&void 0!==n&&n.initSegment.data||this.bitrateTest||(s=s.initSegment),s},x.getNextPart=function(e,t,r){for(var n=-1,i=!1,a=!0,s=0,o=e.length;s<o;s++){var l=e[s];if(a=a&&!l.independent,n>-1&&r<l.start)break;var u=l.loaded;!u&&(i||l.independent||a)&&l.fragment===t&&(n=s),i=u}return n},x.loadedEndOfParts=function(e,t){var r=e[e.length-1];return r&&t>r.start&&r.loaded},x.getInitialLiveFragment=function(e,t){var r=this.fragPrevious,n=null;if(r){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),n=Object(h.findFragmentByPDT)(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!n){var i=r.sn+1;if(i>=e.startSN&&i<=e.endSN){var a=t[i-e.startSN];r.cc===a.cc&&(n=a,this.log("Live playlist, switching playlist, load frag with next SN: "+n.sn))}n||(n=Object(h.findFragWithCC)(t,r.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+n.sn)}}else{var s=this.hls.liveSyncPosition;null!==s&&(n=this.getFragmentAtPosition(s,this.bitrateTest?e.fragmentEnd:e.edge,e))}return n},x.getFragmentAtPosition=function(e,t,r){var n,i=this.config,s=this.fragPrevious,o=r.fragments,l=r.endSN,u=r.fragmentHint,c=i.maxFragLookUpTolerance,d=!!(i.lowLatencyMode&&r.partList&&u);if(d&&u&&!this.bitrateTest&&(o=o.concat(u),l=u.sn),e<t){var f=e>t-c?0:c;n=Object(h.findFragmentByPTS)(s,o,e,f)}else n=o[o.length-1];if(n){var g=n.sn-r.startSN,p=s&&n.level===s.level,v=o[g+1];if(this.fragmentTracker.getState(n)===a.FragmentState.BACKTRACKED){n=null;for(var m=g;o[m]&&this.fragmentTracker.getState(o[m])===a.FragmentState.BACKTRACKED;)n=s?o[m--]:o[--m];n||(n=v)}else s&&n.sn===s.sn&&!d&&p&&(n.sn<l&&this.fragmentTracker.getState(v)!==a.FragmentState.OK?(this.log("SN "+n.sn+" just loaded, load next one: "+v.sn),n=v):n=null)}return n},x.synchronizeToLiveEdge=function(e){var t=this.config,r=this.media;if(r){var n=this.hls.liveSyncPosition,i=r.currentTime,a=e.fragments[0].start,s=e.edge,o=i>=a-t.maxFragLookUpTolerance&&i<=s;if(null!==n&&r.duration>n&&(i<n||!o)){var l=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!o&&r.readyState<4||i<s-l)&&(this.loadedmetadata||(this.nextLoadPosition=n),r.readyState&&(this.warn("Playback: "+i.toFixed(3)+" is located too far from the end of live sliding playlist: "+s+", reset currentTime to : "+n.toFixed(3)),r.currentTime=n))}}},x.alignPlaylists=function(e,t){var r=this.levels,i=this.levelLastLoaded,a=this.fragPrevious,s=null!==i?r[i]:null,o=e.fragments.length;if(!o)return this.warn("No fragments in live playlist"),0;var l=e.fragments[0].start,u=!t,c=e.alignedSliding&&Object(n.isFiniteNumber)(l);if(u||!c&&!l){Object(f.alignStream)(a,s,e);var d=e.fragments[0].start;return this.log("Live playlist sliding: "+d.toFixed(2)+" start-sn: "+(t?t.startSN:"na")+"->"+e.startSN+" prev-sn: "+(a?a.sn:"na")+" fragments: "+o),d}return l},x.waitForCdnTuneIn=function(e){return e.live&&e.canBlockReload&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)},x.setStartPosition=function(e,t){var r=this.startPosition;if(r<t&&(r=-1),-1===r||-1===this.lastCurrentTime){var i=e.startTimeOffset;Object(n.isFiniteNumber)(i)?(r=t+i,i<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log("Start time offset "+i+" found in playlist, adjust startPosition to "+r),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r},x.getLoadPosition=function(){var e=this.media,t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t},x.handleFragLoadAborted=function(e,t){this.transmuxer&&"initSegment"!==e.sn&&e.stats.aborted&&(this.warn("Fragment "+e.sn+(t?" part"+t.index:"")+" of level "+e.level+" was aborted"),this.resetFragmentLoading(e))},x.resetFragmentLoading=function(e){this.fragCurrent&&this.fragContextChanged(e)||(this.state=T.IDLE)},x.onFragmentOrKeyLoadError=function(e,t){if(!t.fatal){var r=t.frag;if(r&&r.type===e){var n=this.fragCurrent;console.assert(n&&r.sn===n.sn&&r.level===n.level&&r.urlId===n.urlId,"Frag load error must match current frag to retry");var i=this.config;if(this.fragLoadError+1<=i.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(r.level))return;var a=Math.min(Math.pow(2,this.fragLoadError)*i.fragLoadingRetryDelay,i.fragLoadingMaxRetryTimeout);this.warn("Fragment "+r.sn+" of "+e+" "+r.level+" failed to load, retrying in "+a+"ms"),this.retryDate=self.performance.now()+a,this.fragLoadError++,this.state=T.FRAG_LOADING_WAITING_RETRY}else t.levelRetry?(e===y.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=T.IDLE):(o.logger.error(t.details+" reaches max retry, redispatch as fatal ..."),t.fatal=!0,this.hls.stopLoad(),this.state=T.ERROR)}}},x.afterBufferFlushed=function(e,t,r){if(e){var n=s.BufferHelper.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,n,r),this.state===T.ENDED&&this.resetLoadingState()}},x.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=T.IDLE},x.resetLiveStartWhenNotLoaded=function(e){if(!this.loadedmetadata){this.startFragRequested=!1;var t=this.levels?this.levels[e].details:null;if(null!=t&&t.live)return this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},x.updateLevelTiming=function(e,t,r,n){var i=this,a=r.details;console.assert(!!a,"level.details must be defined"),Object.keys(e.elementaryStreams).reduce((function(t,s){var o=e.elementaryStreams[s];if(o){var u=o.endPTS-o.startPTS;if(u<=0)return i.warn("Could not parse fragment "+e.sn+" "+s+" duration reliably ("+u+") resetting transmuxer to fallback to playlist timing"),i.resetTransmuxer(),t||!1;var c=n?0:Object(g.updateFragPTSDTS)(a,e,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return i.hls.trigger(l.Events.LEVEL_PTS_UPDATED,{details:a,level:r,drift:c,type:s,frag:e,start:o.startPTS,end:o.endPTS}),!0}return t}),!1)?(this.state=T.PARSED,this.hls.trigger(l.Events.FRAG_PARSED,{frag:e,part:t})):this.resetLoadingState()},x.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},S=i,(k=[{key:"state",get:function(){return this._state},set:function(e){var t=this._state;t!==e&&(this._state=e,this.log(t+"->"+e))}}])&&b(S.prototype,k),A&&b(S,A),i}(i.default)},"./src/controller/buffer-controller.ts":
|
|
|
/*!*********************************************!*\
|
|
|
!*** ./src/controller/buffer-controller.ts ***!
|
|
|
\*********************************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return h}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! ../errors */"./src/errors.ts"),o=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),l=r(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),u=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),c=r(/*! ./buffer-operation-queue */"./src/controller/buffer-operation-queue.ts"),d=Object(l.getMediaSource)(),f=/([ha]vc.)(?:\.[^.,]+)+/,h=function(){function e(e){var t=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var e=t.hls,r=t.media,n=t.mediaSource;a.logger.log("[buffer-controller]: Media source opened"),r&&(t.updateMediaElementDuration(),e.trigger(i.Events.MEDIA_ATTACHED,{media:r})),n&&n.removeEventListener("sourceopen",t._onMediaSourceOpen),t.checkPendingTracks()},this._onMediaSourceClose=function(){a.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){a.logger.log("[buffer-controller]: Media source ended")},this.hls=e,this._initSourceBuffer(),this.registerListeners()}var t=e.prototype;return t.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},t.destroy=function(){this.unregisterListeners(),this.details=null},t.registerListeners=function(){var e=this.hls;e.on(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(i.Events.BUFFER_RESET,this.onBufferReset,this),e.on(i.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(i.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(i.Events.BUFFER_EOS,this.onBufferEos,this),e.on(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(i.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(i.Events.FRAG_PARSED,this.onFragParsed,this),e.on(i.Events.FRAG_CHANGED,this.onFragChanged,this)},t.unregisterListeners=function(){var e=this.hls;e.off(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(i.Events.BUFFER_RESET,this.onBufferReset,this),e.off(i.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(i.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(i.Events.BUFFER_EOS,this.onBufferEos,this),e.off(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(i.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(i.Events.FRAG_PARSED,this.onFragParsed,this),e.off(i.Events.FRAG_CHANGED,this.onFragChanged,this)},t._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new c.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},t.onManifestParsed=function(e,t){var r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.details=null,a.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},t.onMediaAttaching=function(e,t){var r=this.media=t.media;if(r&&d){var n=this.mediaSource=new d;n.addEventListener("sourceopen",this._onMediaSourceOpen),n.addEventListener("sourceended",this._onMediaSourceEnded),n.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(n),this._objectUrl=r.src}},t.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,r=this._objectUrl;if(t){if(a.logger.log("[buffer-controller]: media source detaching"),"open"===t.readyState)try{t.endOfStream()}catch(e){a.logger.warn("[buffer-controller]: onMediaDetaching: "+e.message+" while calling endOfStream")}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(r&&self.URL.revokeObjectURL(r),e.src===r?(e.removeAttribute("src"),e.load()):a.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(i.Events.MEDIA_DETACHED,void 0)},t.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach((function(t){var r=e.sourceBuffer[t];try{r&&(e.removeBufferListeners(t),e.mediaSource&&e.mediaSource.removeSourceBuffer(r),e.sourceBuffer[t]=void 0)}catch(e){a.logger.warn("[buffer-controller]: Failed to reset the "+t+" buffer",e)}})),this._initSourceBuffer()},t.onBufferCodecs=function(e,t){var r=this,n=this.getSourceBufferTypes().length;Object.keys(t).forEach((function(e){if(n){var i=r.tracks[e];if(i&&"function"==typeof i.buffer.changeType){var a=t[e],s=a.codec,o=a.levelCodec,l=a.container;if((i.levelCodec||i.codec).replace(f,"$1")!==(o||s).replace(f,"$1")){var u=l+";codecs="+(o||s);r.appendChangeType(e,u)}}}else r.pendingTracks[e]=t[e]})),n||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},t.appendChangeType=function(e,t){var r=this,n=this.operationQueue,i={execute:function(){var i=r.sourceBuffer[e];i&&(a.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+t),i.changeType(t)),n.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(t){a.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",t)}};n.append(i,e)},t.onBufferAppending=function(e,t){var r=this,n=this.hls,l=this.operationQueue,u=this.tracks,c=t.data,d=t.type,f=t.frag,h=t.part,g=t.chunkMeta,p=g.buffering[d],v=self.performance.now();p.start=v;var m=f.stats.buffering,y=h?h.stats.buffering:null;0===m.start&&(m.start=v),y&&0===y.start&&(y.start=v);var b=u.audio,E="audio"===d&&1===g.id&&"audio/mpeg"===(null==b?void 0:b.container),T={execute:function(){if(p.executeStart=self.performance.now(),E){var e=r.sourceBuffer[d];if(e){var t=f.start-e.timestampOffset;Math.abs(t)>=.1&&(a.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+f.start+" (delta: "+t+") sn: "+f.sn+")"),e.timestampOffset=f.start)}}r.appendExecutor(c,d)},onStart:function(){},onComplete:function(){var e=self.performance.now();p.executeEnd=p.end=e,0===m.first&&(m.first=e),y&&0===y.first&&(y.first=e);var t=r.sourceBuffer,n={};for(var a in t)n[a]=o.BufferHelper.getBuffered(t[a]);r.appendError=0,r.hls.trigger(i.Events.BUFFER_APPENDED,{type:d,frag:f,part:h,chunkMeta:g,parent:f.type,timeRanges:n})},onError:function(e){a.logger.error("[buffer-controller]: Error encountered while trying to append to the "+d+" SourceBuffer",e);var t={type:s.ErrorTypes.MEDIA_ERROR,parent:f.type,details:s.ErrorDetails.BUFFER_APPEND_ERROR,err:e,fatal:!1};e.code===DOMException.QUOTA_EXCEEDED_ERR?t.details=s.ErrorDetails.BUFFER_FULL_ERROR:(r.appendError++,t.details=s.ErrorDetails.BUFFER_APPEND_ERROR,r.appendError>n.config.appendErrorMaxRetry&&(a.logger.error("[buffer-controller]: Failed "+n.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),t.fatal=!0)),n.trigger(i.Events.ERROR,t)}};l.append(T,d)},t.onBufferFlushing=function(e,t){var r=this,n=this.operationQueue,s=function(e){return{execute:r.removeExecutor.bind(r,e,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(i.Events.BUFFER_FLUSHED,{type:e})},onError:function(t){a.logger.warn("[buffer-controller]: Failed to remove from "+e+" SourceBuffer",t)}}};t.type?n.append(s(t.type),t.type):this.getSourceBufferTypes().forEach((function(e){n.append(s(e),e)}))},t.onFragParsed=function(e,t){var r=this,n=t.frag,s=t.part,o=[],l=s?s.elementaryStreams:n.elementaryStreams;l[u.ElementaryStreamTypes.AUDIOVIDEO]?o.push("audiovideo"):(l[u.ElementaryStreamTypes.AUDIO]&&o.push("audio"),l[u.ElementaryStreamTypes.VIDEO]&&o.push("video")),0===o.length&&a.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+n.type+" level: "+n.level+" sn: "+n.sn),this.blockBuffers((function(){var e=self.performance.now();n.stats.buffering.end=e,s&&(s.stats.buffering.end=e);var t=s?s.stats:n.stats;r.hls.trigger(i.Events.FRAG_BUFFERED,{frag:n,part:s,stats:t,id:n.type})}),o)},t.onFragChanged=function(e,t){this.flushBackBuffer()},t.onBufferEos=function(e,t){var r=this;this.getSourceBufferTypes().reduce((function(e,n){var i=r.sourceBuffer[n];return t.type&&t.type!==n||i&&!i.ended&&(i.ended=!0,a.logger.log("[buffer-controller]: "+n+" sourceBuffer now EOS")),e&&!(i&&!i.ended)}),!0)&&this.blockBuffers((function(){var e=r.mediaSource;e&&"open"===e.readyState&&e.endOfStream()}))},t.onLevelUpdated=function(e,t){var r=t.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},t.flushBackBuffer=function(){var e=this.hls,t=this.details,r=this.media,a=this.sourceBuffer;if(r&&null!==t){var s=this.getSourceBufferTypes();if(s.length){var l=t.live&&null!==e.config.liveBackBufferLength?e.config.liveBackBufferLength:e.config.backBufferLength;if(Object(n.isFiniteNumber)(l)&&!(l<0)){var u=r.currentTime,c=t.levelTargetDuration,d=Math.max(l,c),f=Math.floor(u/c)*c-d;s.forEach((function(r){var n=a[r];if(n){var s=o.BufferHelper.getBuffered(n);s.length>0&&f>s.start(0)&&(e.trigger(i.Events.BACK_BUFFER_REACHED,{bufferEnd:f}),t.live&&e.trigger(i.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:f}),e.trigger(i.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:f,type:r}))}}))}}}},t.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var e=this.details,t=this.hls,r=this.media,i=this.mediaSource,s=e.fragments[0].start+e.totalduration,o=r.duration,l=Object(n.isFiniteNumber)(i.duration)?i.duration:0;e.live&&t.config.liveDurationInfinity?(a.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),i.duration=1/0,this.updateSeekableRange(e)):(s>l&&s>o||!Object(n.isFiniteNumber)(o))&&(a.logger.log("[buffer-controller]: Updating Media Source duration to "+s.toFixed(3)),i.duration=s)}},t.updateSeekableRange=function(e){var t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&null!=t&&t.setLiveSeekableRange){var n=Math.max(0,r[0].start),i=Math.max(n,n+e.totalduration);t.setLiveSeekableRange(n,i)}},t.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,r=this.pendingTracks,n=Object.keys(r).length;if(n&&!e||2===n){this.createSourceBuffers(r),this.pendingTracks={};var a=this.getSourceBufferTypes();if(0===a.length)return void this.hls.trigger(i.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});a.forEach((function(e){t.executeNext(e)}))}},t.createSourceBuffers=function(e){var t=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");var n=0;for(var o in e)if(!t[o]){var l=e[o];if(!l)throw Error("source buffer exists for track "+o+", however track does not");var u=l.levelCodec||l.codec,c=l.container+";codecs="+u;a.logger.log("[buffer-controller]: creating sourceBuffer("+c+")");try{var d=t[o]=r.addSourceBuffer(c),f=o;this.addBufferListener(f,"updatestart",this._onSBUpdateStart),this.addBufferListener(f,"updateend",this._onSBUpdateEnd),this.addBufferListener(f,"error",this._onSBUpdateError),this.tracks[o]={buffer:d,codec:u,container:l.container,levelCodec:l.levelCodec,id:l.id},n++}catch(e){a.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+e.message),this.hls.trigger(i.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,mimeType:c})}}n&&this.hls.trigger(i.Events.BUFFER_CREATED,{tracks:this.tracks})},t._onSBUpdateStart=function(e){this.operationQueue.current(e).onStart()},t._onSBUpdateEnd=function(e){var t=this.operationQueue;t.current(e).onComplete(),t.shiftAndExecuteNext(e)},t._onSBUpdateError=function(e,t){a.logger.error("[buffer-controller]: "+e+" SourceBuffer error",t),this.hls.trigger(i.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var r=this.operationQueue.current(e);r&&r.onError(t)},t.removeExecutor=function(e,t,r){var i=this.media,s=this.mediaSource,o=this.operationQueue,l=this.sourceBuffer[e];if(!i||!s||!l)return a.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void o.shiftAndExecuteNext(e);var u=Object(n.isFiniteNumber)(i.duration)?i.duration:1/0,c=Object(n.isFiniteNumber)(s.duration)?s.duration:1/0,d=Math.max(0,t),f=Math.min(r,u,c);f>d?(a.logger.log("[buffer-controller]: Removing ["+d+","+f+"] from the "+e+" SourceBuffer"),console.assert(!l.updating,e+" sourceBuffer must not be updating"),l.remove(d,f)):o.shiftAndExecuteNext(e)},t.appendExecutor=function(e,t){var r=this.operationQueue,n=this.sourceBuffer[t];if(!n)return a.logger.warn("[buffer-controller]: Attempting to append to the "+t+" SourceBuffer, but it does not exist"),void r.shiftAndExecuteNext(t);n.ended=!1,console.assert(!n.updating,t+" sourceBuffer must not be updating"),n.appendBuffer(e)},t.blockBuffers=function(e,t){var r=this;if(void 0===t&&(t=this.getSourceBufferTypes()),!t.length)return a.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve(e);var n=this.operationQueue,i=t.map((function(e){return n.appendBlocker(e)}));Promise.all(i).then((function(){e(),t.forEach((function(e){var t=r.sourceBuffer[e];t&&t.updating||n.shiftAndExecuteNext(e)}))}))},t.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},t.addBufferListener=function(e,t,r){var n=this.sourceBuffer[e];if(n){var i=r.bind(this,e);this.listeners[e].push({event:t,listener:i}),n.addEventListener(t,i)}},t.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach((function(e){t.removeEventListener(e.event,e.listener)}))},e}()},"./src/controller/buffer-operation-queue.ts":
|
|
|
/*!**************************************************!*\
|
|
|
!*** ./src/controller/buffer-operation-queue.ts ***!
|
|
|
\**************************************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return i}));var n=r(/*! ../utils/logger */"./src/utils/logger.ts"),i=function(){function e(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}var t=e.prototype;return t.append=function(e,t){var r=this.queues[t];r.push(e),1===r.length&&this.buffers[t]&&this.executeNext(t)},t.insertAbort=function(e,t){this.queues[t].unshift(e),this.executeNext(t)},t.appendBlocker=function(e){var t,r=new Promise((function(e){t=e})),n={execute:t,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(n,e),r},t.executeNext=function(e){var t=this.buffers,r=this.queues,i=t[e],a=r[e];if(a.length){var s=a[0];try{s.execute()}catch(t){n.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),s.onError(t),i&&i.updating||(a.shift(),this.executeNext(e))}}},t.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},t.current=function(e){return this.queues[e][0]},e}()},"./src/controller/cap-level-controller.ts":
|
|
|
/*!************************************************!*\
|
|
|
!*** ./src/controller/cap-level-controller.ts ***!
|
|
|
\************************************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t);var n=r(/*! ../events */"./src/events.ts");function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var a=function(){function e(e){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var t,r,a,s=e.prototype;return s.setStreamController=function(e){this.streamController=e},s.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},s.registerListeners=function(){var e=this.hls;e.on(n.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},s.unregisterListener=function(){var e=this.hls;e.off(n.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},s.onFpsDropLevelCapping=function(t,r){e.isLevelAllowed(r.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(r.droppedLevel)},s.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null},s.onManifestParsed=function(e,t){var r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},s.onBufferCodecs=function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()},s.onMediaDetaching=function(){this.stopCapping()},s.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var e=this.hls.levels;if(e.length){var t=this.hls;t.autoLevelCapping=this.getMaxLevel(e.length-1),t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},s.getMaxLevel=function(t){var r=this,n=this.hls.levels;if(!n.length)return-1;var i=n.filter((function(n,i){return e.isLevelAllowed(i,r.restrictedLevels)&&i<=t}));return this.clientRect=null,e.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)},s.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},s.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},s.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t},e.isLevelAllowed=function(e,t){return void 0===t&&(t=[]),-1===t.indexOf(e)},e.getMaxLevelByMediaSize=function(e,t,r){if(!e||!e.length)return-1;for(var n,i,a=e.length-1,s=0;s<e.length;s+=1){var o=e[s];if((o.width>=t||o.height>=r)&&(n=o,!(i=e[s+1])||n.width!==i.width||n.height!==i.height)){a=s;break}}return a},t=e,a=[{key:"contentScaleFactor",get:function(){var e=1;try{e=self.devicePixelRatio}catch(e){}return e}}],(r=[{key:"mediaWidth",get:function(){return this.getDimensions().width*e.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*e.contentScaleFactor}}])&&i(t.prototype,r),a&&i(t,a),e}();t.default=a},"./src/controller/cmcd-controller.ts":
|
|
|
/*!*******************************************!*\
|
|
|
!*** ./src/controller/cmcd-controller.ts ***!
|
|
|
\*******************************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return f}));var n=r(/*! ../events */"./src/events.ts"),i=r(/*! ../types/cmcd */"./src/types/cmcd.ts"),a=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts");function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function l(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),e}function u(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function d(){return(d=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var f=function(){function e(t){var r=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){r.initialized&&(r.starved=!0),r.buffering=!0},this.onPlaying=function(){r.initialized||(r.initialized=!0),r.buffering=!1},this.applyPlaylistData=function(e){try{r.apply(e,{ot:i.CMCDObjectType.MANIFEST,su:!r.initialized})}catch(e){s.logger.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=function(e){try{var t=e.frag,n=r.hls.levels[t.level],a=r.getObjectType(t),o={d:1e3*t.duration,ot:a};a!==i.CMCDObjectType.VIDEO&&a!==i.CMCDObjectType.AUDIO&&a!=i.CMCDObjectType.MUXED||(o.br=n.bitrate/1e3,o.tb=r.getTopBandwidth(a),o.bl=r.getBufferLength(a)),r.apply(e,o)}catch(e){s.logger.warn("Could not generate segment CMCD data.",e)}},this.hls=t;var n=this.config=t.config,a=n.cmcd;null!=a&&(n.pLoader=this.createPlaylistLoader(),n.fLoader=this.createFragmentLoader(),this.sid=a.sessionId||e.uuid(),this.cid=a.contentId,this.useHeaders=!0===a.useHeaders,this.registerListeners())}var t=e.prototype;return t.registerListeners=function(){var e=this.hls;e.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(n.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(n.Events.BUFFER_CREATED,this.onBufferCreated,this)},t.unregisterListeners=function(){var e=this.hls;e.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(n.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(n.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},t.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},t.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},t.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},t.onBufferCreated=function(e,t){var r,n;this.audioBuffer=null===(r=t.tracks.audio)||void 0===r?void 0:r.buffer,this.videoBuffer=null===(n=t.tracks.video)||void 0===n?void 0:n.buffer},t.createData=function(){var e;return{v:i.CMCDVersion,sf:i.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:null===(e=this.media)||void 0===e?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},t.apply=function(t,r){void 0===r&&(r={}),d(r,this.createData());var n=r.ot===i.CMCDObjectType.INIT||r.ot===i.CMCDObjectType.VIDEO||r.ot===i.CMCDObjectType.MUXED;if(this.starved&&n&&(r.bs=!0,r.su=!0,this.starved=!1),null==r.su&&(r.su=this.buffering),this.useHeaders){var a=e.toHeaders(r);if(!Object.keys(a).length)return;t.headers||(t.headers={}),d(t.headers,a)}else{var s=e.toQuery(r);if(!s)return;t.url=e.appendQueryToUri(t.url,s)}},t.getObjectType=function(e){var t=e.type;return"subtitle"===t?i.CMCDObjectType.TIMED_TEXT:"initSegment"===e.sn?i.CMCDObjectType.INIT:"audio"===t?i.CMCDObjectType.AUDIO:"main"===t?this.hls.audioTracks.length?i.CMCDObjectType.VIDEO:i.CMCDObjectType.MUXED:void 0},t.getTopBandwidth=function(e){for(var t,r=0,n=u(e===i.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels);!(t=n()).done;){var a=t.value;a.bitrate>r&&(r=a.bitrate)}return r>0?r:NaN},t.getBufferLength=function(e){var t=this.hls.media,r=e===i.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;return r&&t?1e3*a.BufferHelper.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len:NaN},t.createPlaylistLoader=function(){var e=this.config.pLoader,t=this.applyPlaylistData,r=e||this.config.loader;return function(){function e(e){this.loader=void 0,this.loader=new r(e)}var n=e.prototype;return n.destroy=function(){this.loader.destroy()},n.abort=function(){this.loader.abort()},n.load=function(e,r,n){t(e),this.loader.load(e,r,n)},l(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),e}()},t.createFragmentLoader=function(){var e=this.config.fLoader,t=this.applyFragmentData,r=e||this.config.loader;return function(){function e(e){this.loader=void 0,this.loader=new r(e)}var n=e.prototype;return n.destroy=function(){this.loader.destroy()},n.abort=function(){this.loader.abort()},n.load=function(e,r,n){t(e),this.loader.load(e,r,n)},l(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),e}()},e.uuid=function(){var e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.substr(t.lastIndexOf("/")+1)},e.serialize=function(e){for(var t,r=[],n=function(e){return!Number.isNaN(e)&&null!=e&&""!==e&&!1!==e},i=function(e){return Math.round(e)},a=function(e){return 100*i(e/100)},s={br:i,d:i,bl:a,dl:a,mtp:a,nor:function(e){return encodeURIComponent(e)},rtp:a,tb:i},o=u(Object.keys(e||{}).sort());!(t=o()).done;){var l=t.value,c=e[l];if(n(c)&&!("v"===l&&1===c||"pr"==l&&1===c)){var d=s[l];d&&(c=d(c));var f=typeof c,h=void 0;h="ot"===l||"sf"===l||"st"===l?l+"="+c:"boolean"===f?l:"number"===f?l+"="+c:l+"="+JSON.stringify(c),r.push(h)}}return r.join(",")},e.toHeaders=function(t){for(var r={},n=["Object","Request","Session","Status"],i=[{},{},{},{}],a={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},s=0,o=Object.keys(t);s<o.length;s++){var l=o[s];i[null!=a[l]?a[l]:1][l]=t[l]}for(var u=0;u<i.length;u++){var c=e.serialize(i[u]);c&&(r["CMCD-"+n[u]]=c)}return r},e.toQuery=function(t){return"CMCD="+encodeURIComponent(e.serialize(t))},e.appendQueryToUri=function(e,t){if(!t)return e;var r=e.includes("?")?"&":"?";return""+e+r+t},e}()},"./src/controller/eme-controller.ts":
|
|
|
/*!******************************************!*\
|
|
|
!*** ./src/controller/eme-controller.ts ***!
|
|
|
\******************************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t);var n=r(/*! ../events */"./src/events.ts"),i=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! ../utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts");function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var l=function(){function e(e){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=e,this._config=e.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var t,r,l,u=e.prototype;return u.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},u._registerListeners=function(){this.hls.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(n.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(n.Events.MANIFEST_PARSED,this.onManifestParsed,this)},u._unregisterListeners=function(){this.hls.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(n.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(n.Events.MANIFEST_PARSED,this.onManifestParsed,this)},u.getLicenseServerUrl=function(e){switch(e){case s.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+e+'"')},u._attemptKeySystemAccess=function(e,t,r){var n=this,i=function(e,t,r,n){switch(e){case s.KeySystems.WIDEVINE:return function(e,t,r){var n={audioCapabilities:[],videoCapabilities:[]};return e.forEach((function(e){n.audioCapabilities.push({contentType:'audio/mp4; codecs="'+e+'"',robustness:r.audioRobustness||""})})),t.forEach((function(e){n.videoCapabilities.push({contentType:'video/mp4; codecs="'+e+'"',robustness:r.videoRobustness||""})})),[n]}(t,r,n);default:throw new Error("Unknown key-system: "+e)}}(e,t,r,this._drmSystemOptions);a.logger.log("Requesting encrypted media key-system access");var o=this.requestMediaKeySystemAccess(e,i);this.mediaKeysPromise=o.then((function(t){return n._onMediaKeySystemAccessObtained(e,t)})),o.catch((function(t){a.logger.error('Failed to obtain key-system "'+e+'" access:',t)}))},u._onMediaKeySystemAccessObtained=function(e,t){var r=this;a.logger.log('Access for key-system "'+e+'" obtained');var n={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:t,mediaKeySystemDomain:e};this._mediaKeysList.push(n);var i=Promise.resolve().then((function(){return t.createMediaKeys()})).then((function(t){return n.mediaKeys=t,a.logger.log('Media-keys created for key-system "'+e+'"'),r._onMediaKeysCreated(),t}));return i.catch((function(e){a.logger.error("Failed to create media-keys:",e)})),i},u._onMediaKeysCreated=function(){var e=this;this._mediaKeysList.forEach((function(t){t.mediaKeysSession||(t.mediaKeysSession=t.mediaKeys.createSession(),e._onNewMediaKeySession(t.mediaKeysSession))}))},u._onNewMediaKeySession=function(e){var t=this;a.logger.log("New key-system session "+e.sessionId),e.addEventListener("message",(function(r){t._onKeySessionMessage(e,r.message)}),!1)},u._onKeySessionMessage=function(e,t){a.logger.log("Got EME message event, creating license request"),this._requestLicense(t,(function(t){a.logger.log("Received license data (length: "+(t?t.byteLength:t)+"), updating key-session"),e.update(t)}))},u.onMediaEncrypted=function(e){var t=this;if(a.logger.log('Media is encrypted using "'+e.initDataType+'" init data type'),!this.mediaKeysPromise)return a.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),void this.hls.trigger(n.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});var r=function(r){t._media&&(t._attemptSetMediaKeys(r),t._generateRequestWithPreferredKeySession(e.initDataType,e.initData))};this.mediaKeysPromise.then(r).catch(r)},u._attemptSetMediaKeys=function(e){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var t=this._mediaKeysList[0];if(!t||!t.mediaKeys)return a.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),void this.hls.trigger(n.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});a.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(t.mediaKeys),this._hasSetMediaKeys=!0}},u._generateRequestWithPreferredKeySession=function(e,t){var r=this,s=this._mediaKeysList[0];if(!s)return a.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),void this.hls.trigger(n.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});if(s.mediaKeysSessionInitialized)a.logger.warn("Key-Session already initialized but requested again");else{var o=s.mediaKeysSession;if(!o)return a.logger.error("Fatal: Media is encrypted but no key-session existing"),void this.hls.trigger(n.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});if(!t)return a.logger.warn("Fatal: initData required for generating a key session is null"),void this.hls.trigger(n.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});a.logger.log('Generating key-session request for "'+e+'" init data type'),s.mediaKeysSessionInitialized=!0,o.generateRequest(e,t).then((function(){a.logger.debug("Key-session generation succeeded")})).catch((function(e){a.logger.error("Error generating key-session request:",e),r.hls.trigger(n.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})}))}},u._createLicenseXhr=function(e,t,r){var n=new XMLHttpRequest;n.responseType="arraybuffer",n.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,n,e,t,r);var i=this._licenseXhrSetup;if(i)try{i.call(this.hls,n,e),i=void 0}catch(e){a.logger.error(e)}try{n.readyState||n.open("POST",e,!0),i&&i.call(this.hls,n,e)}catch(e){throw new Error("issue setting up KeySystem license XHR "+e)}return n},u._onLicenseRequestReadyStageChange=function(e,t,r,s){switch(e.readyState){case 4:if(200===e.status){this._requestLicenseFailureCount=0,a.logger.log("License request succeeded");var o=e.response,l=this._licenseResponseCallback;if(l)try{o=l.call(this.hls,e,t)}catch(e){a.logger.error(e)}s(o)}else{if(a.logger.error("License Request XHR failed ("+t+"). Status: "+e.status+" ("+e.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>3)return void this.hls.trigger(n.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});var u=3-this._requestLicenseFailureCount+1;a.logger.warn("Retrying license request, "+u+" attempts left"),this._requestLicense(r,s)}}},u._generateLicenseRequestChallenge=function(e,t){switch(e.mediaKeySystemDomain){case s.KeySystems.WIDEVINE:return t}throw new Error("unsupported key-system: "+e.mediaKeySystemDomain)},u._requestLicense=function(e,t){a.logger.log("Requesting content license for key-system");var r=this._mediaKeysList[0];if(!r)return a.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),void this.hls.trigger(n.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});try{var s=this.getLicenseServerUrl(r.mediaKeySystemDomain),o=this._createLicenseXhr(s,e,t);a.logger.log("Sending license request to URL: "+s);var l=this._generateLicenseRequestChallenge(r,e);o.send(l)}catch(e){a.logger.error("Failure requesting DRM license: "+e),this.hls.trigger(n.Events.ERROR,{type:i.ErrorTypes.KEY_SYSTEM_ERROR,details:i.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},u.onMediaAttached=function(e,t){if(this._emeEnabled){var r=t.media;this._media=r,r.addEventListener("encrypted",this._onMediaEncrypted)}},u.onMediaDetached=function(){var e=this._media,t=this._mediaKeysList;e&&(e.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(t.map((function(e){if(e.mediaKeysSession)return e.mediaKeysSession.close().catch((function(){}))}))).then((function(){return e.setMediaKeys(null)})).catch((function(){})))},u.onManifestParsed=function(e,t){if(this._emeEnabled){var r=t.levels.map((function(e){return e.audioCodec})).filter((function(e){return!!e})),n=t.levels.map((function(e){return e.videoCodec})).filter((function(e){return!!e}));this._attemptKeySystemAccess(s.KeySystems.WIDEVINE,r,n)}},t=e,(r=[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}])&&o(t.prototype,r),l&&o(t,l),e}();t.default=l},"./src/controller/fps-controller.ts":
|
|
|
/*!******************************************!*\
|
|
|
!*** ./src/controller/fps-controller.ts ***!
|
|
|
\******************************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t);var n=r(/*! ../events */"./src/events.ts"),i=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=function(){function e(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}var t=e.prototype;return t.setStreamController=function(e){this.streamController=e},t.registerListeners=function(){this.hls.on(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},t.unregisterListeners=function(){this.hls.off(n.Events.MEDIA_ATTACHING,this.onMediaAttaching)},t.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},t.onMediaAttaching=function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var n=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=n,n&&"function"==typeof n.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},t.checkFPS=function(e,t,r){var a=performance.now();if(t){if(this.lastTime){var s=a-this.lastTime,o=r-this.lastDroppedFrames,l=t-this.lastDecodedFrames,u=1e3*o/s,c=this.hls;if(c.trigger(n.Events.FPS_DROP,{currentDropped:o,currentDecoded:l,totalDroppedFrames:r}),u>0&&o>c.config.fpsDroppedMonitoringThreshold*l){var d=c.currentLevel;i.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+d),d>0&&(-1===c.autoLevelCapping||c.autoLevelCapping>=d)&&(d-=1,c.trigger(n.Events.FPS_DROP_LEVEL_CAPPING,{level:d,droppedLevel:c.currentLevel}),c.autoLevelCapping=d,this.streamController.nextLevelSwitch())}}this.lastTime=a,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},t.checkFPSInterval=function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},e}();t.default=a},"./src/controller/fragment-finders.ts":
|
|
|
/*!********************************************!*\
|
|
|
!*** ./src/controller/fragment-finders.ts ***!
|
|
|
\********************************************/
|
|
|
/*! exports provided: findFragmentByPDT, findFragmentByPTS, fragmentWithinToleranceTest, pdtWithinToleranceTest, findFragWithCC */function(e,t,r){"use strict";r.r(t),r.d(t,"findFragmentByPDT",(function(){return a})),r.d(t,"findFragmentByPTS",(function(){return s})),r.d(t,"fragmentWithinToleranceTest",(function(){return o})),r.d(t,"pdtWithinToleranceTest",(function(){return l})),r.d(t,"findFragWithCC",(function(){return u}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ../utils/binary-search */"./src/utils/binary-search.ts");function a(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!Object(n.isFiniteNumber)(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;r=r||0;for(var i=0;i<e.length;++i){var a=e[i];if(l(t,r,a))return a}return null}function s(e,t,r,n){void 0===r&&(r=0),void 0===n&&(n=0);var a=null;if(e?a=t[e.sn-t[0].sn+1]||null:0===r&&0===t[0].start&&(a=t[0]),a&&0===o(r,n,a))return a;var s=i.default.search(t,o.bind(null,r,n));return s||a}function o(e,t,r){void 0===e&&(e=0),void 0===t&&(t=0);var n=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-n<=e?1:r.start-n>e&&r.start?-1:0}function l(e,t,r){var n=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-n>e}function u(e,t){return i.default.search(e,(function(e){return e.cc<t?1:e.cc>t?-1:0}))}},"./src/controller/fragment-tracker.ts":
|
|
|
/*!********************************************!*\
|
|
|
!*** ./src/controller/fragment-tracker.ts ***!
|
|
|
\********************************************/
|
|
|
/*! exports provided: FragmentState, FragmentTracker */function(e,t,r){"use strict";r.r(t),r.d(t,"FragmentState",(function(){return n})),r.d(t,"FragmentTracker",(function(){return s}));var n,i=r(/*! ../events */"./src/events.ts"),a=r(/*! ../types/loader */"./src/types/loader.ts");!function(e){e.NOT_LOADED="NOT_LOADED",e.BACKTRACKED="BACKTRACKED",e.APPENDING="APPENDING",e.PARTIAL="PARTIAL",e.OK="OK"}(n||(n={}));var s=function(){function e(e){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=e,this._registerListeners()}var t=e.prototype;return t._registerListeners=function(){var e=this.hls;e.on(i.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.on(i.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(i.Events.FRAG_LOADED,this.onFragLoaded,this)},t._unregisterListeners=function(){var e=this.hls;e.off(i.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.off(i.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(i.Events.FRAG_LOADED,this.onFragLoaded,this)},t.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},t.getAppendedFrag=function(e,t){if(t===a.PlaylistLevelType.MAIN){var r=this.activeFragment,n=this.activeParts;if(!r)return null;if(n)for(var i=n.length;i--;){var s=n[i],o=s?s.end:r.appendedPTS;if(s.start<=e&&void 0!==o&&e<=o)return i>9&&(this.activeParts=n.slice(i-9)),s}else if(r.start<=e&&void 0!==r.appendedPTS&&e<=r.appendedPTS)return r}return this.getBufferedFrag(e,t)},t.getBufferedFrag=function(e,t){for(var r=this.fragments,n=Object.keys(r),i=n.length;i--;){var a=r[n[i]];if((null==a?void 0:a.body.type)===t&&a.buffered){var s=a.body;if(s.start<=e&&e<=s.end)return s}}return null},t.detectEvictedFragments=function(e,t,r){var n=this;Object.keys(this.fragments).forEach((function(i){var a=n.fragments[i];if(a)if(a.buffered){var s=a.range[e];s&&s.time.some((function(e){var r=!n.isTimeBuffered(e.startPTS,e.endPTS,t);return r&&n.removeFragment(a.body),r}))}else a.body.type===r&&n.removeFragment(a.body)}))},t.detectPartialFragments=function(e){var t=this,r=this.timeRanges,n=e.frag,i=e.part;if(r&&"initSegment"!==n.sn){var a=l(n),s=this.fragments[a];s&&(Object.keys(r).forEach((function(e){var a=n.elementaryStreams[e];if(a){var o=r[e],l=null!==i||!0===a.partial;s.range[e]=t.getBufferedTimes(n,i,l,o)}})),s.backtrack=s.loaded=null,Object.keys(s.range).length?s.buffered=!0:this.removeFragment(s.body))}},t.fragBuffered=function(e){var t=l(e),r=this.fragments[t];r&&(r.backtrack=r.loaded=null,r.buffered=!0)},t.getBufferedTimes=function(e,t,r,n){for(var i={time:[],partial:r},a=t?t.start:e.start,s=t?t.end:e.end,o=e.minEndPTS||s,l=e.maxStartPTS||a,u=0;u<n.length;u++){var c=n.start(u)-this.bufferPadding,d=n.end(u)+this.bufferPadding;if(l>=c&&o<=d){i.time.push({startPTS:Math.max(a,n.start(u)),endPTS:Math.min(s,n.end(u))});break}if(a<d&&s>c)i.partial=!0,i.time.push({startPTS:Math.max(a,n.start(u)),endPTS:Math.min(s,n.end(u))});else if(s<=c)break}return i},t.getPartialFragment=function(e){var t,r,n,i=null,a=0,s=this.bufferPadding,l=this.fragments;return Object.keys(l).forEach((function(u){var c=l[u];c&&o(c)&&(r=c.body.start-s,n=c.body.end+s,e>=r&&e<=n&&(t=Math.min(e-r,n-e),a<=t&&(i=c.body,a=t)))})),i},t.getState=function(e){var t=l(e),r=this.fragments[t];return r?r.buffered?o(r)?n.PARTIAL:n.OK:r.backtrack?n.BACKTRACKED:n.APPENDING:n.NOT_LOADED},t.backtrack=function(e,t){var r=l(e),n=this.fragments[r];if(!n||n.backtrack)return null;var i=n.backtrack=t||n.loaded;return n.loaded=null,i},t.getBacktrackData=function(e){var t=l(e),r=this.fragments[t];if(r){var n,i=r.backtrack;if(null!=i&&null!==(n=i.payload)&&void 0!==n&&n.byteLength)return i;this.removeFragment(e)}return null},t.isTimeBuffered=function(e,t,r){for(var n,i,a=0;a<r.length;a++){if(n=r.start(a)-this.bufferPadding,i=r.end(a)+this.bufferPadding,e>=n&&t<=i)return!0;if(t<=n)return!1}return!1},t.onFragLoaded=function(e,t){var r=t.frag,n=t.part;if("initSegment"!==r.sn&&!r.bitrateTest&&!n){var i=l(r);this.fragments[i]={body:r,loaded:t,backtrack:null,buffered:!1,range:Object.create(null)}}},t.onBufferAppended=function(e,t){var r=this,n=t.frag,i=t.part,s=t.timeRanges;if(n.type===a.PlaylistLevelType.MAIN)if(this.activeFragment=n,i){var o=this.activeParts;o||(this.activeParts=o=[]),o.push(i)}else this.activeParts=null;this.timeRanges=s,Object.keys(s).forEach((function(e){var t=s[e];if(r.detectEvictedFragments(e,t),!i)for(var a=0;a<t.length;a++)n.appendedPTS=Math.max(t.end(a),n.appendedPTS||0)}))},t.onFragBuffered=function(e,t){this.detectPartialFragments(t)},t.hasFragment=function(e){var t=l(e);return!!this.fragments[t]},t.removeFragmentsInRange=function(e,t,r){var n=this;Object.keys(this.fragments).forEach((function(i){var a=n.fragments[i];if(a&&a.buffered){var s=a.body;s.type===r&&s.start<t&&s.end>e&&n.removeFragment(s)}}))},t.removeFragment=function(e){var t=l(e);e.stats.loaded=0,e.clearElementaryStreamInfo(),delete this.fragments[t]},t.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},e}();function o(e){var t,r;return e.buffered&&((null===(t=e.range.video)||void 0===t?void 0:t.partial)||(null===(r=e.range.audio)||void 0===r?void 0:r.partial))}function l(e){return e.type+"_"+e.level+"_"+e.urlId+"_"+e.sn}},"./src/controller/gap-controller.ts":
|
|
|
/*!******************************************!*\
|
|
|
!*** ./src/controller/gap-controller.ts ***!
|
|
|
\******************************************/
|
|
|
/*! exports provided: STALL_MINIMUM_DURATION_MS, MAX_START_GAP_JUMP, SKIP_BUFFER_HOLE_STEP_SECONDS, SKIP_BUFFER_RANGE_START, default */function(e,t,r){"use strict";r.r(t),r.d(t,"STALL_MINIMUM_DURATION_MS",(function(){return o})),r.d(t,"MAX_START_GAP_JUMP",(function(){return l})),r.d(t,"SKIP_BUFFER_HOLE_STEP_SECONDS",(function(){return u})),r.d(t,"SKIP_BUFFER_RANGE_START",(function(){return c})),r.d(t,"default",(function(){return d}));var n=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),i=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=250,l=2,u=.1,c=.05,d=function(){function e(e,t,r,n){this.config=void 0,this.media=void 0,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=r,this.hls=n}var t=e.prototype;return t.destroy=function(){this.hls=this.fragmentTracker=this.media=null},t.poll=function(e){var t=this.config,r=this.media,i=this.stalled,a=r.currentTime,u=r.seeking,c=this.seeking&&!u,d=!this.seeking&&u;if(this.seeking=u,a===e){if((d||c)&&(this.stalled=null),!r.paused&&!r.ended&&0!==r.playbackRate&&n.BufferHelper.getBuffered(r).length){var f=n.BufferHelper.bufferInfo(r,a,0),h=f.len>0,g=f.nextStart||0;if(h||g){if(u){var p=f.len>l,v=!g||g-a>l&&!this.fragmentTracker.getPartialFragment(a);if(p||v)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var m,y=Math.max(g,f.start||0)-a,b=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,E=(null==b||null===(m=b.details)||void 0===m?void 0:m.live)?2*b.details.targetduration:l;if(y>0&&y<=E)return void this._trySkipBufferHole(null)}var T=self.performance.now();if(null!==i){var S=T-i;!u&&S>=o&&this._reportStall(f.len);var k=n.BufferHelper.bufferInfo(r,a,t.maxBufferHole);this._tryFixBufferStall(k,S)}else this.stalled=T}}}else if(this.moved=!0,null!==i){if(this.stallReported){var A=self.performance.now()-i;s.logger.warn("playback not stuck anymore @"+a+", after "+Math.round(A)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}},t._tryFixBufferStall=function(e,t){var r=this.config,n=this.fragmentTracker,i=this.media.currentTime,a=n.getPartialFragment(i);a&&this._trySkipBufferHole(a)||e.len>r.maxBufferHole&&t>1e3*r.highBufferWatchdogPeriod&&(s.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},t._reportStall=function(e){var t=this.hls,r=this.media;this.stallReported||(this.stallReported=!0,s.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer (buffer="+e+")"),t.trigger(a.Events.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:e}))},t._trySkipBufferHole=function(e){for(var t=this.config,r=this.hls,o=this.media,l=o.currentTime,d=0,f=n.BufferHelper.getBuffered(o),h=0;h<f.length;h++){var g=f.start(h);if(l+t.maxBufferHole>=d&&l<g){var p=Math.max(g+c,o.currentTime+u);return s.logger.warn("skipping hole, adjusting currentTime from "+l+" to "+p),this.moved=!0,this.stalled=null,o.currentTime=p,e&&r.trigger(a.Events.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+l+" to "+p,frag:e}),p}d=f.end(h)}return 0},t._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,n=r.currentTime,o=(this.nudgeRetry||0)+1;if(this.nudgeRetry=o,o<e.nudgeMaxRetry){var l=n+o*e.nudgeOffset;s.logger.warn("Nudging 'currentTime' from "+n+" to "+l),r.currentTime=l,t.trigger(a.Events.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else s.logger.error("Playhead still not moving while enough data buffered @"+n+" after "+e.nudgeMaxRetry+" nudges"),t.trigger(a.Events.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},e}()},"./src/controller/id3-track-controller.ts":
|
|
|
/*!************************************************!*\
|
|
|
!*** ./src/controller/id3-track-controller.ts ***!
|
|
|
\************************************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t);var n=r(/*! ../events */"./src/events.ts"),i=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),a=r(/*! ../demux/id3 */"./src/demux/id3.ts"),s=function(){function e(e){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=e,this._registerListeners()}var t=e.prototype;return t.destroy=function(){this._unregisterListeners()},t._registerListeners=function(){var e=this.hls;e.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(n.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},t._unregisterListeners=function(){var e=this.hls;e.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(n.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},t.onMediaAttached=function(e,t){this.media=t.media},t.onMediaDetaching=function(){this.id3Track&&(Object(i.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null)},t.getID3Track=function(e){if(this.media){for(var t=0;t<e.length;t++){var r=e[t];if("metadata"===r.kind&&"id3"===r.label)return Object(i.sendAddTrackEvent)(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},t.onFragParsingMetadata=function(e,t){if(this.media){var r=t.frag,n=t.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var i=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,s=0;s<n.length;s++){var o=a.getID3Frames(n[s].data);if(o){var l=n[s].pts,u=s<n.length-1?n[s+1].pts:r.end;u-l<=0&&(u=l+.25);for(var c=0;c<o.length;c++){var d=o[c];if(!a.isTimeStampFrame(d)){var f=new i(l,u,"");f.value=d,this.id3Track.addCue(f)}}}}}},t.onBufferFlushing=function(e,t){var r=t.startOffset,n=t.endOffset,a=t.type;if(!a||"audio"===a){var s=this.id3Track;s&&Object(i.removeCuesInRange)(s,r,n)}},e}();t.default=s},"./src/controller/latency-controller.ts":
|
|
|
/*!**********************************************!*\
|
|
|
!*** ./src/controller/latency-controller.ts ***!
|
|
|
\**********************************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return o}));var n=r(/*! ../errors */"./src/errors.ts"),i=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts");function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var o=function(){function e(e){var t=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return t.timeupdate()},this.hls=e,this.config=e.config,this.registerListeners()}var t,r,o,l=e.prototype;return l.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},l.registerListeners=function(){this.hls.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(i.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(i.Events.ERROR,this.onError,this)},l.unregisterListeners=function(){this.hls.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(i.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(i.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(i.Events.ERROR,this.onError)},l.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},l.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},l.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},l.onLevelUpdated=function(e,t){var r=t.details;this.levelDetails=r,r.advanced&&this.timeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},l.onError=function(e,t){t.details===n.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,a.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},l.timeupdate=function(){var e=this.media,t=this.levelDetails;if(e&&t){this.currentTime=e.currentTime;var r=this.computeLatency();if(null!==r){this._latency=r;var n=this.config,i=n.lowLatencyMode,a=n.maxLiveSyncPlaybackRate;if(i&&1!==a){var s=this.targetLatency;if(null!==s){var o=r-s,l=o<Math.min(this.maxLatency,s+t.targetduration);if(t.live&&l&&o>.05&&this.forwardBufferLength>1){var u=Math.min(2,Math.max(1,a)),c=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,c))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}}}}},l.estimateLiveEdge=function(){var e=this.levelDetails;return null===e?null:e.edge+e.age},l.computeLatency=function(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime},t=e,(r=[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config,t=this.levelDetails;return void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(null===e)return null;var t=e.holdBack,r=e.partHoldBack,n=e.targetduration,i=this.config,a=i.liveSyncDuration,s=i.liveSyncDurationCount,o=i.lowLatencyMode,l=this.hls.userConfig,u=o&&r||t;(l.liveSyncDuration||l.liveSyncDurationCount||0===u)&&(u=void 0!==a?a:s*n);var c=n;return u+Math.min(1*this.stallCount,c)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(null===e||null===t||null===r)return null;var n=r.edge,i=e-t-this.edgeStalled,a=n-r.totalduration,s=n-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,i),s)}},{key:"drift",get:function(){var e=this.levelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(null===e)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var r=e.buffered.length;return r?e.buffered.end(r-1):t.edge-this.currentTime}}])&&s(t.prototype,r),o&&s(t,o),e}()},"./src/controller/level-controller.ts":
|
|
|
/*!********************************************!*\
|
|
|
!*** ./src/controller/level-controller.ts ***!
|
|
|
\********************************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return g}));var n=r(/*! ../types/level */"./src/types/level.ts"),i=r(/*! ../events */"./src/events.ts"),a=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ../utils/codecs */"./src/utils/codecs.ts"),o=r(/*! ./level-helper */"./src/controller/level-helper.ts"),l=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts");function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function d(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var h=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),g=function(e){var t,r;function l(t){var r;return(r=e.call(this,t,"[level-controller]")||this)._levels=[],r._firstLevel=-1,r._startLevel=void 0,r.currentLevelIndex=-1,r.manualLevelIndex=-1,r.onParsedComplete=void 0,r._registerListeners(),r}r=e,(t=l).prototype=Object.create(r.prototype),t.prototype.constructor=t,f(t,r);var g,p,v,m=l.prototype;return m._registerListeners=function(){var e=this.hls;e.on(i.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(i.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(i.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(i.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(i.Events.ERROR,this.onError,this)},m._unregisterListeners=function(){var e=this.hls;e.off(i.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(i.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(i.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(i.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(i.Events.ERROR,this.onError,this)},m.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,e.prototype.destroy.call(this)},m.startLoad=function(){this._levels.forEach((function(e){e.loadError=0})),e.prototype.startLoad.call(this)},m.onManifestLoaded=function(e,t){var r,l,u=[],c=[],d=[],f={},g=!1,p=!1,v=!1;if(t.levels.forEach((function(e){var t=e.attrs;g=g||!(!e.width||!e.height),p=p||!!e.videoCodec,v=v||!!e.audioCodec,h&&e.audioCodec&&-1!==e.audioCodec.indexOf("mp4a.40.34")&&(e.audioCodec=void 0);var r=e.bitrate+"-"+e.attrs.RESOLUTION+"-"+e.attrs.CODECS;(l=f[r])?l.url.push(e.url):(l=new n.Level(e),f[r]=l,u.push(l)),t&&(t.AUDIO&&Object(o.addGroupId)(l,"audio",t.AUDIO),t.SUBTITLES&&Object(o.addGroupId)(l,"text",t.SUBTITLES))})),(g||p)&&v&&(u=u.filter((function(e){var t=e.videoCodec,r=e.width,n=e.height;return!!t||!(!r||!n)}))),u=u.filter((function(e){var t=e.audioCodec,r=e.videoCodec;return(!t||Object(s.isCodecSupportedInMp4)(t,"audio"))&&(!r||Object(s.isCodecSupportedInMp4)(r,"video"))})),t.audioTracks&&(c=t.audioTracks.filter((function(e){return!e.audioCodec||Object(s.isCodecSupportedInMp4)(e.audioCodec,"audio")})),Object(o.assignTrackIdsByGroup)(c)),t.subtitles&&(d=t.subtitles,Object(o.assignTrackIdsByGroup)(d)),u.length>0){r=u[0].bitrate,u.sort((function(e,t){return e.bitrate-t.bitrate})),this._levels=u;for(var m=0;m<u.length;m++)if(u[m].bitrate===r){this._firstLevel=m,this.log("manifest loaded, "+u.length+" level(s) found, first bitrate: "+r);break}var y=v&&!p,b={levels:u,audioTracks:c,subtitleTracks:d,firstLevel:this._firstLevel,stats:t.stats,audio:v,video:p,altAudio:!y&&c.some((function(e){return!!e.url}))};this.hls.trigger(i.Events.MANIFEST_PARSED,b),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(i.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,reason:"no level with compatible codecs found in manifest"})},m.onError=function(t,r){if(e.prototype.onError.call(this,t,r),!r.fatal){var n=r.context,i=this._levels[this.currentLevelIndex];if(n&&(n.type===u.PlaylistContextType.AUDIO_TRACK&&i.audioGroupIds&&n.groupId===i.audioGroupIds[i.urlId]||n.type===u.PlaylistContextType.SUBTITLE_TRACK&&i.textGroupIds&&n.groupId===i.textGroupIds[i.urlId]))this.redundantFailover(this.currentLevelIndex);else{var s,o=!1,l=!0;switch(r.details){case a.ErrorDetails.FRAG_LOAD_ERROR:case a.ErrorDetails.FRAG_LOAD_TIMEOUT:case a.ErrorDetails.KEY_LOAD_ERROR:case a.ErrorDetails.KEY_LOAD_TIMEOUT:if(r.frag){var c=this._levels[r.frag.level];c?(c.fragmentError++,c.fragmentError>this.hls.config.fragLoadingMaxRetry&&(s=r.frag.level)):s=r.frag.level}break;case a.ErrorDetails.LEVEL_LOAD_ERROR:case a.ErrorDetails.LEVEL_LOAD_TIMEOUT:n&&(n.deliveryDirectives&&(l=!1),s=n.level),o=!0;break;case a.ErrorDetails.REMUX_ALLOC_ERROR:s=r.level,o=!0}void 0!==s&&this.recoverLevel(r,s,o,l)}}},m.recoverLevel=function(e,t,r,n){var i=e.details,a=this._levels[t];if(a.loadError++,r){if(!this.retryLoadingOrFail(e))return void(this.currentLevelIndex=-1);e.levelRetry=!0}if(n){var s=a.url.length;if(s>1&&a.loadError<s)e.levelRetry=!0,this.redundantFailover(t);else if(-1===this.manualLevelIndex){var o=0===t?this._levels.length-1:t-1;this.currentLevelIndex!==o&&0===this._levels[o].loadError&&(this.warn(i+": switch to "+o),e.levelRetry=!0,this.hls.nextAutoLevel=o)}}},m.redundantFailover=function(e){var t=this._levels[e],r=t.url.length;if(r>1){var n=(t.urlId+1)%r;this.warn("Switching to redundant URL-id "+n),this._levels.forEach((function(e){e.urlId=n})),this.level=e}},m.onFragLoaded=function(e,t){var r=t.frag;if(void 0!==r&&r.type===u.PlaylistLevelType.MAIN){var n=this._levels[r.level];void 0!==n&&(n.fragmentError=0,n.loadError=0)}},m.onLevelLoaded=function(e,t){var r,n,i=t.level,a=t.details,s=this._levels[i];if(!s)return this.warn("Invalid level index "+i),void(null!==(n=t.deliveryDirectives)&&void 0!==n&&n.skip&&(a.deltaUpdateFailed=!0));i===this.currentLevelIndex?(0===s.fragmentError&&(s.loadError=0,this.retryCount=0),this.playlistLoaded(i,t,s.details)):null!==(r=t.deliveryDirectives)&&void 0!==r&&r.skip&&(a.deltaUpdateFailed=!0)},m.onAudioTrackSwitched=function(e,t){var r=this.hls.levels[this.currentLevelIndex];if(r&&r.audioGroupIds){for(var n=-1,i=this.hls.audioTracks[t.id].groupId,a=0;a<r.audioGroupIds.length;a++)if(r.audioGroupIds[a]===i){n=a;break}n!==r.urlId&&(r.urlId=n,this.startLoad())}},m.loadPlaylist=function(e){var t=this.currentLevelIndex,r=this._levels[t];if(this.canLoad&&r&&r.url.length>0){var n=r.urlId,a=r.url[n];if(e)try{a=e.addDirectives(a)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}this.log("Attempt loading level index "+t+(e?" at sn "+e.msn+" part "+e.part:"")+" with URL-id "+n+" "+a),this.clearTimer(),this.hls.trigger(i.Events.LEVEL_LOADING,{url:a,level:t,id:n,deliveryDirectives:e||null})}},m.removeLevel=function(e,t){var r=function(e,r){return r!==t},n=this._levels.filter((function(n,i){return i!==e||n.url.length>1&&void 0!==t&&(n.url=n.url.filter(r),n.audioGroupIds&&(n.audioGroupIds=n.audioGroupIds.filter(r)),n.textGroupIds&&(n.textGroupIds=n.textGroupIds.filter(r)),n.urlId=0,!0)})).map((function(e,t){var r=e.details;return null!=r&&r.fragments&&r.fragments.forEach((function(e){e.level=t})),e}));this._levels=n,this.hls.trigger(i.Events.LEVELS_UPDATED,{levels:n})},g=l,(p=[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t,r=this._levels;if(0!==r.length&&(this.currentLevelIndex!==e||null===(t=r[e])||void 0===t||!t.details)){if(e<0||e>=r.length){var n=e<0;if(this.hls.trigger(i.Events.ERROR,{type:a.ErrorTypes.OTHER_ERROR,details:a.ErrorDetails.LEVEL_SWITCH_ERROR,level:e,fatal:n,reason:"invalid level idx"}),n)return;e=Math.min(e,r.length-1)}this.clearTimer();var s=this.currentLevelIndex,o=r[s],l=r[e];this.log("switching to level "+e+" from "+s),this.currentLevelIndex=e;var u=c({},l,{level:e,maxBitrate:l.maxBitrate,uri:l.uri,urlId:l.urlId});delete u._urlId,this.hls.trigger(i.Events.LEVEL_SWITCHING,u);var d=l.details;if(!d||d.live){var f=this.switchParams(l.uri,null==o?void 0:o.details);this.loadPlaylist(f)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this._firstLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}}])&&d(g.prototype,p),v&&d(g,v),l}(l.default)},"./src/controller/level-helper.ts":
|
|
|
/*!****************************************!*\
|
|
|
!*** ./src/controller/level-helper.ts ***!
|
|
|
\****************************************/
|
|
|
/*! exports provided: addGroupId, assignTrackIdsByGroup, updatePTS, updateFragPTSDTS, mergeDetails, mapPartIntersection, mapFragmentIntersection, adjustSliding, addSliding, computeReloadInterval, getFragmentWithSN, getPartWith */function(e,t,r){"use strict";r.r(t),r.d(t,"addGroupId",(function(){return a})),r.d(t,"assignTrackIdsByGroup",(function(){return s})),r.d(t,"updatePTS",(function(){return o})),r.d(t,"updateFragPTSDTS",(function(){return u})),r.d(t,"mergeDetails",(function(){return c})),r.d(t,"mapPartIntersection",(function(){return d})),r.d(t,"mapFragmentIntersection",(function(){return f})),r.d(t,"adjustSliding",(function(){return h})),r.d(t,"addSliding",(function(){return g})),r.d(t,"computeReloadInterval",(function(){return p})),r.d(t,"getFragmentWithSN",(function(){return v})),r.d(t,"getPartWith",(function(){return m}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ../utils/logger */"./src/utils/logger.ts");function a(e,t,r){switch(t){case"audio":e.audioGroupIds||(e.audioGroupIds=[]),e.audioGroupIds.push(r);break;case"text":e.textGroupIds||(e.textGroupIds=[]),e.textGroupIds.push(r)}}function s(e){var t={};e.forEach((function(e){var r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++}))}function o(e,t,r){l(e[t],e[r])}function l(e,t){var r=t.startPTS;if(Object(n.isFiniteNumber)(r)){var i,a=0;t.sn>e.sn?(a=r-e.start,i=e):(a=e.start-r,i=t),i.duration!==a&&(i.duration=a)}else t.sn>e.sn?e.cc===t.cc&&e.minEndPTS?t.start=e.start+(e.minEndPTS-e.start):t.start=e.start+e.duration:t.start=Math.max(e.start-t.duration,0)}function u(e,t,r,a,s,o){a-r<=0&&(i.logger.warn("Fragment should have a positive duration",t),a=r+t.duration,o=s+t.duration);var u=r,c=a,d=t.startPTS,f=t.endPTS;if(Object(n.isFiniteNumber)(d)){var h=Math.abs(d-r);Object(n.isFiniteNumber)(t.deltaPTS)?t.deltaPTS=Math.max(h,t.deltaPTS):t.deltaPTS=h,u=Math.max(r,d),r=Math.min(r,d),s=Math.min(s,t.startDTS),c=Math.min(a,f),a=Math.max(a,f),o=Math.max(o,t.endDTS)}t.duration=a-r;var g=r-t.start;t.appendedPTS=a,t.start=t.startPTS=r,t.maxStartPTS=u,t.startDTS=s,t.endPTS=a,t.minEndPTS=c,t.endDTS=o;var p,v=t.sn;if(!e||v<e.startSN||v>e.endSN)return 0;var m=v-e.startSN,y=e.fragments;for(y[m]=t,p=m;p>0;p--)l(y[p],y[p-1]);for(p=m;p<y.length-1;p++)l(y[p],y[p+1]);return e.fragmentHint&&l(y[y.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,g}function c(e,t){for(var r=null,a=e.fragments,s=a.length-1;s>=0;s--){var o=a[s].initSegment;if(o){r=o;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;var l,c=0;if(f(e,t,(function(e,i){e.relurl&&(c=e.cc-i.cc),Object(n.isFiniteNumber)(e.startPTS)&&Object(n.isFiniteNumber)(e.endPTS)&&(i.start=i.startPTS=e.startPTS,i.startDTS=e.startDTS,i.appendedPTS=e.appendedPTS,i.maxStartPTS=e.maxStartPTS,i.endPTS=e.endPTS,i.endDTS=e.endDTS,i.minEndPTS=e.minEndPTS,i.duration=e.endPTS-e.startPTS,i.duration&&(l=i),t.PTSKnown=t.alignedSliding=!0),i.elementaryStreams=e.elementaryStreams,i.loader=e.loader,i.stats=e.stats,i.urlId=e.urlId,e.initSegment&&(i.initSegment=e.initSegment,r=e.initSegment)})),r&&(t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments).forEach((function(e){var t;e.initSegment&&e.initSegment.relurl!==(null===(t=r)||void 0===t?void 0:t.relurl)||(e.initSegment=r)})),t.skippedSegments&&(t.deltaUpdateFailed=t.fragments.some((function(e){return!e})),t.deltaUpdateFailed)){i.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var g=t.skippedSegments;g--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}var p=t.fragments;if(c){i.logger.warn("discontinuity sliding from playlist, take drift into account");for(var v=0;v<p.length;v++)p[v].cc+=c}t.skippedSegments&&(t.startCC=t.fragments[0].cc),d(e.partList,t.partList,(function(e,t){t.elementaryStreams=e.elementaryStreams,t.stats=e.stats})),l?u(t,l,l.startPTS,l.endPTS,l.startDTS,l.endDTS):h(e,t),p.length&&(t.totalduration=t.edge-p[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;var m=t.advancedDateTime;if(t.advanced&&m){var y=t.edge;t.driftStart||(t.driftStartTime=m,t.driftStart=y),t.driftEndTime=m,t.driftEnd=y}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime}function d(e,t,r){if(e&&t)for(var n=0,i=0,a=e.length;i<=a;i++){var s=e[i],o=t[i+n];s&&o&&s.index===o.index&&s.fragment.sn===o.fragment.sn?r(s,o):n--}}function f(e,t,r){for(var n=t.skippedSegments,i=Math.max(e.startSN,t.startSN)-t.startSN,a=(e.fragmentHint?1:0)+(n?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,s=t.startSN-e.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,u=i;u<=a;u++){var c=l[s+u],d=o[u];n&&!d&&u<n&&(d=t.fragments[u]=c),c&&d&&r(c,d)}}function h(e,t){var r=t.startSN+t.skippedSegments-e.startSN,n=e.fragments;r<0||r>=n.length||g(t,n[r].start)}function g(e,t){if(t){for(var r=e.fragments,n=e.skippedSegments;n<r.length;n++)r[n].start+=t;e.fragmentHint&&(e.fragmentHint.start+=t)}}function p(e,t){var r,n=1e3*e.levelTargetDuration,i=n/2,a=e.age,s=a>0&&a<3*n,o=t.loading.end-t.loading.start,l=e.availabilityDelay;if(!1===e.updated)if(s){var u=333*e.misses;r=Math.max(Math.min(i,2*o),u),e.availabilityDelay=(e.availabilityDelay||0)+r}else r=i;else s?(l=Math.min(l||n/2,a),e.availabilityDelay=l,r=l+n-a):r=n-o;return Math.round(r)}function v(e,t,r){if(!e||!e.details)return null;var n=e.details,i=n.fragments[t-n.startSN];return i||((i=n.fragmentHint)&&i.sn===t?i:t<n.startSN&&r&&r.sn===t?r:null)}function m(e,t,r){if(!e||!e.details)return null;var n=e.details.partList;if(n)for(var i=n.length;i--;){var a=n[i];if(a.index===r&&a.fragment.sn===t)return a}return null}},"./src/controller/stream-controller.ts":
|
|
|
/*!*********************************************!*\
|
|
|
!*** ./src/controller/stream-controller.ts ***!
|
|
|
\*********************************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return y}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),a=r(/*! ../is-supported */"./src/is-supported.ts"),s=r(/*! ../events */"./src/events.ts"),o=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),l=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),c=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),d=r(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts"),f=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),h=r(/*! ./gap-controller */"./src/controller/gap-controller.ts"),g=r(/*! ../errors */"./src/errors.ts"),p=r(/*! ../utils/logger */"./src/utils/logger.ts");function v(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function m(e,t){return(m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var y=function(e){var t,r;function y(t,r){var n;return(n=e.call(this,t,r,"[stream-controller]")||this).audioCodecSwap=!1,n.gapController=null,n.level=-1,n._forceStartLoad=!1,n.altAudio=!1,n.audioOnly=!1,n.fragPlaying=null,n.onvplaying=null,n.onvseeked=null,n.fragLastKbps=0,n.stalled=!1,n.couldBacktrack=!1,n.audioCodecSwitch=!1,n.videoBuffer=null,n._registerListeners(),n}r=e,(t=y).prototype=Object.create(r.prototype),t.prototype.constructor=t,m(t,r);var b,E,T,S=y.prototype;return S._registerListeners=function(){var e=this.hls;e.on(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(s.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(s.Events.ERROR,this.onError,this),e.on(s.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(s.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(s.Events.BUFFER_CREATED,this.onBufferCreated,this),e.on(s.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(s.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(s.Events.FRAG_BUFFERED,this.onFragBuffered,this)},S._unregisterListeners=function(){var e=this.hls;e.off(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(s.Events.ERROR,this.onError,this),e.off(s.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(s.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(s.Events.BUFFER_CREATED,this.onBufferCreated,this),e.off(s.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(s.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(s.Events.FRAG_BUFFERED,this.onFragBuffered,this)},S.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},S.startLoad=function(e){if(this.levels){var t=this.lastCurrentTime,r=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var n=r.startLevel;-1===n&&(r.config.testBandwidth?(n=0,this.bitrateTest=!0):n=r.nextAutoLevel),this.level=r.nextLoadLevel=n,this.loadedmetadata=!1}t>0&&-1===e&&(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=i.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=i.State.STOPPED},S.stopLoad=function(){this._forceStartLoad=!1,e.prototype.stopLoad.call(this)},S.doTick=function(){switch(this.state){case i.State.IDLE:this.doTickIdle();break;case i.State.WAITING_LEVEL:var e,t=this.levels,r=this.level,n=null==t||null===(e=t[r])||void 0===e?void 0:e.details;if(n&&(!n.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(n))break;this.state=i.State.IDLE;break}break;case i.State.FRAG_LOADING_WAITING_RETRY:var a,s=self.performance.now(),o=this.retryDate;(!o||s>=o||null!==(a=this.media)&&void 0!==a&&a.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=i.State.IDLE)}this.onTickEnd()},S.onTickEnd=function(){e.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},S.doTickIdle=function(){var e,t,r=this.hls,n=this.levelLastLoaded,a=this.levels,o=this.media,d=r.config,f=r.nextLoadLevel;if(null!==n&&(o||!this.startFragRequested&&d.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&a&&a[f]){var h=a[f];this.level=r.nextLoadLevel=f;var g=h.details;if(!g||this.state===i.State.WAITING_LEVEL||g.live&&this.levelLastLoaded!==f)this.state=i.State.WAITING_LEVEL;else{var p=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:o,u.PlaylistLevelType.MAIN);if(null!==p&&!(p.len>=this.getMaxBufferLength(h.maxBitrate))){if(this._streamEnded(p,g)){var v={};return this.altAudio&&(v.type="video"),this.hls.trigger(s.Events.BUFFER_EOS,v),void(this.state=i.State.ENDED)}var m=p.end,y=this.getNextFragment(m,g);if(this.couldBacktrack&&!this.fragPrevious&&y&&"initSegment"!==y.sn){var b=y.sn-g.startSN;b>1&&(y=g.fragments[b-1],this.fragmentTracker.removeFragment(y))}if(y&&this.fragmentTracker.getState(y)===l.FragmentState.OK&&this.nextLoadPosition>m){var E=this.audioOnly&&!this.altAudio?c.ElementaryStreamTypes.AUDIO:c.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(o,E,u.PlaylistLevelType.MAIN),y=this.getNextFragment(this.nextLoadPosition,g)}y&&(!y.initSegment||y.initSegment.data||this.bitrateTest||(y=y.initSegment),"identity"!==(null===(e=y.decryptdata)||void 0===e?void 0:e.keyFormat)||null!==(t=y.decryptdata)&&void 0!==t&&t.key?this.loadFragment(y,g,m):this.loadKey(y,g))}}}},S.loadFragment=function(t,r,n){var i,a=this.fragmentTracker.getState(t);if(this.fragCurrent=t,a===l.FragmentState.BACKTRACKED){var s=this.fragmentTracker.getBacktrackData(t);if(s)return this._handleFragmentLoadProgress(s),void this._handleFragmentLoadComplete(s);a=l.FragmentState.NOT_LOADED}a===l.FragmentState.NOT_LOADED||a===l.FragmentState.PARTIAL?"initSegment"===t.sn?this._loadInitSegment(t):this.bitrateTest?(t.bitrateTest=!0,this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t)):(this.startFragRequested=!0,e.prototype.loadFragment.call(this,t,r,n)):a===l.FragmentState.APPENDING?this.reduceMaxBufferLength(t.duration)&&this.fragmentTracker.removeFragment(t):0===(null===(i=this.media)||void 0===i?void 0:i.buffered.length)&&this.fragmentTracker.removeAllFragments()},S.getAppendedFrag=function(e){var t=this.fragmentTracker.getAppendedFrag(e,u.PlaylistLevelType.MAIN);return t&&"fragment"in t?t.fragment:t},S.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,u.PlaylistLevelType.MAIN)},S.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},S.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},S.nextLevelSwitch=function(){var e=this.levels,t=this.media;if(null!=t&&t.readyState){var r,n=this.getAppendedFrag(t.currentTime);if(n&&n.start>1&&this.flushMainBuffer(0,n.start-1),!t.paused&&e){var i=e[this.hls.nextLoadLevel],a=this.fragLastKbps;r=a&&this.fragCurrent?this.fragCurrent.duration*i.maxBitrate/(1e3*a)+1:0}else r=0;var s=this.getBufferedFrag(t.currentTime+r);if(s){var o=this.followingBufferedFrag(s);if(o){this.abortCurrentFrag();var l=o.maxStartPTS?o.maxStartPTS:o.start,u=o.duration,c=Math.max(s.end,l+Math.min(Math.max(u-this.config.maxFragLookUpTolerance,.5*u),.75*u));this.flushMainBuffer(c,Number.POSITIVE_INFINITY)}}}},S.abortCurrentFrag=function(){var e=this.fragCurrent;this.fragCurrent=null,null!=e&&e.loader&&e.loader.abort(),this.state===i.State.KEY_LOADING&&(this.state=i.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},S.flushMainBuffer=function(t,r){e.prototype.flushMainBuffer.call(this,t,r,this.altAudio?"video":null)},S.onMediaAttached=function(t,r){e.prototype.onMediaAttached.call(this,t,r);var n=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),n.addEventListener("playing",this.onvplaying),n.addEventListener("seeked",this.onvseeked),this.gapController=new h.default(this.config,n,this.fragmentTracker,this.hls)},S.onMediaDetaching=function(){var t=this.media;t&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),e.prototype.onMediaDetaching.call(this)},S.onMediaPlaying=function(){this.tick()},S.onMediaSeeked=function(){var e=this.media,t=e?e.currentTime:null;Object(n.isFiniteNumber)(t)&&this.log("Media seeked to "+t.toFixed(3)),this.tick()},S.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(s.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},S.onManifestParsed=function(e,t){var r,n=!1,i=!1;t.levels.forEach((function(e){(r=e.audioCodec)&&(-1!==r.indexOf("mp4a.40.2")&&(n=!0),-1!==r.indexOf("mp4a.40.5")&&(i=!0))})),this.audioCodecSwitch=n&&i&&!Object(a.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1},S.onLevelLoading=function(e,t){var r=this.levels;if(r&&this.state===i.State.IDLE){var n=r[t.level];(!n.details||n.details.live&&this.levelLastLoaded!==t.level||this.waitForCdnTuneIn(n.details))&&(this.state=i.State.WAITING_LEVEL)}},S.onLevelLoaded=function(e,t){var r,n=this.levels,a=t.level,o=t.details,l=o.totalduration;if(n){this.log("Level "+a+" loaded ["+o.startSN+","+o.endSN+"], cc ["+o.startCC+", "+o.endCC+"] duration:"+l);var u=this.fragCurrent;!u||this.state!==i.State.FRAG_LOADING&&this.state!==i.State.FRAG_LOADING_WAITING_RETRY||u.level!==t.level&&u.loader&&(this.state=i.State.IDLE,u.loader.abort());var c=n[a],d=0;if(o.live||null!==(r=c.details)&&void 0!==r&&r.live){if(o.fragments[0]||(o.deltaUpdateFailed=!0),o.deltaUpdateFailed)return;d=this.alignPlaylists(o,c.details)}if(c.details=o,this.levelLastLoaded=a,this.hls.trigger(s.Events.LEVEL_UPDATED,{details:o,level:a}),this.state===i.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=i.State.IDLE}this.startFragRequested?o.live&&this.synchronizeToLiveEdge(o):this.setStartPosition(o,d),this.tick()}else this.warn("Levels were reset while loading level "+a)},S._handleFragmentLoadProgress=function(e){var t,r=e.frag,n=e.part,i=e.payload,a=this.levels;if(a){var s=a[r.level],o=s.details;if(o){var l=s.videoCodec,c=o.PTSKnown||!o.live,h=null===(t=r.initSegment)||void 0===t?void 0:t.data,g=this._getAudioCodec(s),p=this.transmuxer=this.transmuxer||new d.default(this.hls,u.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),v=n?n.index:-1,m=-1!==v,y=new f.ChunkMetadata(r.level,r.sn,r.stats.chunkCount,i.byteLength,v,m),b=this.initPTS[r.cc];p.push(i,h,g,l,r,n,o.totalduration,c,y,b)}else this.warn("Dropping fragment "+r.sn+" of level "+r.level+" after level details were reset")}else this.warn("Levels were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},S.onAudioTrackSwitching=function(e,t){var r=this.altAudio,n=!!t.url,i=t.id;if(!n){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var a=this.fragCurrent;null!=a&&a.loader&&(this.log("Switching to main audio track, cancel main fragment load"),a.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var o=this.hls;r&&o.trigger(s.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),o.trigger(s.Events.AUDIO_TRACK_SWITCHED,{id:i})}},S.onAudioTrackSwitched=function(e,t){var r=t.id,n=!!this.hls.audioTracks[r].url;if(n){var i=this.videoBuffer;i&&this.mediaBuffer!==i&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i)}this.altAudio=n,this.tick()},S.onBufferCreated=function(e,t){var r,n,i=t.tracks,a=!1;for(var s in i){var o=i[s];if("main"===o.id){if(n=s,r=o,"video"===s){var l=i[s];l&&(this.videoBuffer=l.buffer)}}else a=!0}a&&r?(this.log("Alternate track found, use "+n+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media},S.onFragBuffered=function(e,t){var r=t.frag,n=t.part;if(!r||r.type===u.PlaylistLevelType.MAIN){if(this.fragContextChanged(r))return this.warn("Fragment "+r.sn+(n?" p: "+n.index:"")+" of level "+r.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===i.State.PARSED&&(this.state=i.State.IDLE));var a=n?n.stats:r.stats;this.fragLastKbps=Math.round(8*a.total/(a.buffering.end-a.loading.first)),"initSegment"!==r.sn&&(this.fragPrevious=r),this.fragBufferedComplete(r,n)}},S.onError=function(e,t){switch(t.details){case g.ErrorDetails.FRAG_LOAD_ERROR:case g.ErrorDetails.FRAG_LOAD_TIMEOUT:case g.ErrorDetails.KEY_LOAD_ERROR:case g.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(u.PlaylistLevelType.MAIN,t);break;case g.ErrorDetails.LEVEL_LOAD_ERROR:case g.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==i.State.ERROR&&(t.fatal?(this.warn(""+t.details),this.state=i.State.ERROR):t.levelRetry||this.state!==i.State.WAITING_LEVEL||(this.state=i.State.IDLE));break;case g.ErrorDetails.BUFFER_FULL_ERROR:if("main"===t.parent&&(this.state===i.State.PARSING||this.state===i.State.PARSED)){var r=!0,n=this.getFwdBufferInfo(this.media,u.PlaylistLevelType.MAIN);n&&n.len>.5&&(r=!this.reduceMaxBufferLength(n.len)),r&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}}},S.checkBuffer=function(){var e=this.media,t=this.gapController;if(e&&t&&e.readyState){var r=o.BufferHelper.getBuffered(e);!this.loadedmetadata&&r.length?(this.loadedmetadata=!0,this.seekToStartPos()):t.poll(this.lastCurrentTime),this.lastCurrentTime=e.currentTime}},S.onFragLoadEmergencyAborted=function(){this.state=i.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},S.onBufferFlushed=function(e,t){var r=t.type;if(r!==c.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var n=(r===c.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(n,r,u.PlaylistLevelType.MAIN)}},S.onLevelsUpdated=function(e,t){this.levels=t.levels},S.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},S.seekToStartPos=function(){var e=this.media,t=e.currentTime,r=this.startPosition;if(r>=0&&t<r){if(e.seeking)return void p.logger.log("could not seek to "+r+", already seeking at "+t);var n=o.BufferHelper.getBuffered(e),i=(n.length?n.start(0):0)-r;i>0&&(i<this.config.maxBufferHole||i<this.config.maxFragLookUpTolerance)&&(p.logger.log("adjusting start position by "+i+" to match buffer start"),r+=i,this.startPosition=r),this.log("seek to target start position "+r+" from current time "+t),e.currentTime=r}},S._getAudioCodec=function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t},S._loadBitrateTestFrag=function(e){var t=this;this._doFragLoad(e).then((function(r){var n=t.hls;if(r&&!n.nextLoadLevel&&!t.fragContextChanged(e)){t.fragLoadError=0,t.state=i.State.IDLE,t.startFragRequested=!1,t.bitrateTest=!1;var a=e.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),n.trigger(s.Events.FRAG_LOADED,r)}}))},S._handleTransmuxComplete=function(e){var t,r="main",a=this.hls,o=e.remuxResult,l=e.chunkMeta,u=this.getCurrentContext(l);if(!u)return this.warn("The loading context changed while buffering fragment "+l.sn+" of level "+l.level+". This chunk will not be buffered."),void this.resetLiveStartWhenNotLoaded(l.level);var d=u.frag,f=u.part,h=u.level,g=o.video,p=o.text,v=o.id3,m=o.initSegment,y=this.altAudio?void 0:o.audio;if(!this.fragContextChanged(d)){if(this.state=i.State.PARSING,m){m.tracks&&(this._bufferInitSegment(h,m.tracks,d,l),a.trigger(s.Events.FRAG_PARSING_INIT_SEGMENT,{frag:d,id:r,tracks:m.tracks}));var b=m.initPTS,E=m.timescale;Object(n.isFiniteNumber)(b)&&(this.initPTS[d.cc]=b,a.trigger(s.Events.INIT_PTS_FOUND,{frag:d,id:r,initPTS:b,timescale:E}))}if(g&&!1!==o.independent){if(h.details){var T=g.startPTS,S=g.endPTS,k=g.startDTS,A=g.endDTS;if(f)f.elementaryStreams[g.type]={startPTS:T,endPTS:S,startDTS:k,endDTS:A};else if(g.firstKeyFrame&&g.independent&&(this.couldBacktrack=!0),g.dropped&&g.independent){if(this.getLoadPosition()+this.config.maxBufferHole<T)return void this.backtrack(d);d.setElementaryStreamInfo(g.type,d.start,S,d.start,A,!0)}d.setElementaryStreamInfo(g.type,T,S,k,A),this.bufferFragmentData(g,d,f,l)}}else if(!1===o.independent)return void this.backtrack(d);if(y){var x=y.startPTS,L=y.endPTS,D=y.startDTS,O=y.endDTS;f&&(f.elementaryStreams[c.ElementaryStreamTypes.AUDIO]={startPTS:x,endPTS:L,startDTS:D,endDTS:O}),d.setElementaryStreamInfo(c.ElementaryStreamTypes.AUDIO,x,L,D,O),this.bufferFragmentData(y,d,f,l)}if(null!=v&&null!==(t=v.samples)&&void 0!==t&&t.length){var C={frag:d,id:r,samples:v.samples};a.trigger(s.Events.FRAG_PARSING_METADATA,C)}if(p){var _={frag:d,id:r,samples:p.samples};a.trigger(s.Events.FRAG_PARSING_USERDATA,_)}}},S._bufferInitSegment=function(e,t,r,n){var a=this;if(this.state===i.State.PARSING){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;var o=t.audio,l=t.video,u=t.audiovideo;if(o){var c=e.audioCodec,d=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(c&&(c=-1!==c.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),1!==o.metadata.channelCount&&-1===d.indexOf("firefox")&&(c="mp4a.40.5")),-1!==d.indexOf("android")&&"audio/mpeg"!==o.container&&(c="mp4a.40.2",this.log("Android: force audio codec to "+c)),e.audioCodec&&e.audioCodec!==c&&this.log('Swapping manifest audio codec "'+e.audioCodec+'" for "'+c+'"'),o.levelCodec=c,o.id="main",this.log("Init audio buffer, container:"+o.container+", codecs[selected/level/parsed]=["+(c||"")+"/"+(e.audioCodec||"")+"/"+o.codec+"]")}l&&(l.levelCodec=e.videoCodec,l.id="main",this.log("Init video buffer, container:"+l.container+", codecs[level/parsed]=["+(e.videoCodec||"")+"/"+l.codec+"]")),u&&this.log("Init audiovideo buffer, container:"+u.container+", codecs[level/parsed]=["+(e.attrs.CODECS||"")+"/"+u.codec+"]"),this.hls.trigger(s.Events.BUFFER_CODECS,t),Object.keys(t).forEach((function(e){var i=t[e].initSegment;null!=i&&i.byteLength&&a.hls.trigger(s.Events.BUFFER_APPENDING,{type:e,data:i,frag:r,part:null,chunkMeta:n,parent:r.type})})),this.tick()}},S.backtrack=function(e){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(e);var t=this.fragmentTracker.backtrack(e);this.fragPrevious=null,this.nextLoadPosition=e.start,t?this.resetFragmentLoading(e):this.state=i.State.BACKTRACKING},S.checkFragmentChanged=function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var r=e.currentTime;if(o.BufferHelper.isBuffered(e,r)?t=this.getAppendedFrag(r):o.BufferHelper.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){var n=this.fragPlaying,i=t.level;n&&t.sn===n.sn&&n.level===i&&t.urlId===n.urlId||(this.hls.trigger(s.Events.FRAG_CHANGED,{frag:t}),n&&n.level===i||this.hls.trigger(s.Events.LEVEL_SWITCHED,{level:i}),this.fragPlaying=t)}}},b=y,(E=[{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentLevel",get:function(){var e=this.media;if(e){var t=this.getAppendedFrag(e.currentTime);if(t)return t.level}return-1}},{key:"nextBufferedFrag",get:function(){var e=this.media;if(e){var t=this.getAppendedFrag(e.currentTime);return this.followingBufferedFrag(t)}return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])&&v(b.prototype,E),T&&v(b,T),y}(i.default)},"./src/controller/subtitle-stream-controller.ts":
|
|
|
/*!******************************************************!*\
|
|
|
!*** ./src/controller/subtitle-stream-controller.ts ***!
|
|
|
\******************************************************/
|
|
|
/*! exports provided: SubtitleStreamController */function(e,t,r){"use strict";r.r(t),r.d(t,"SubtitleStreamController",(function(){return p}));var n=r(/*! ../events */"./src/events.ts"),i=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),s=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),o=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),l=r(/*! ./level-helper */"./src/controller/level-helper.ts"),u=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),c=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),d=r(/*! ../types/loader */"./src/types/loader.ts"),f=r(/*! ../types/level */"./src/types/level.ts");function h(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function g(e,t){return(g=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var p=function(e){var t,r;function p(t,r){var n;return(n=e.call(this,t,r,"[subtitle-stream-controller]")||this).levels=[],n.currentTrackId=-1,n.tracksBuffered=[],n.mainDetails=null,n._registerListeners(),n}r=e,(t=p).prototype=Object.create(r.prototype),t.prototype.constructor=t,g(t,r);var v,m,y,b=p.prototype;return b.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},b._registerListeners=function(){var e=this.hls;e.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(n.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(n.Events.ERROR,this.onError,this),e.on(n.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(n.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(n.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(n.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},b._unregisterListeners=function(){var e=this.hls;e.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(n.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(n.Events.ERROR,this.onError,this),e.off(n.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(n.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(n.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(n.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},b.startLoad=function(){this.stopLoad(),this.state=c.State.IDLE,this.setInterval(500),this.tick()},b.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},b.onLevelLoaded=function(e,t){this.mainDetails=t.details},b.onSubtitleFragProcessed=function(e,t){var r=t.frag,n=t.success;if(this.fragPrevious=r,this.state=c.State.IDLE,n){var i=this.tracksBuffered[this.currentTrackId];if(i){for(var a,s=r.start,o=0;o<i.length;o++)if(s>=i[o].start&&s<=i[o].end){a=i[o];break}var l=r.start+r.duration;a?a.end=l:(a={start:s,end:l},i.push(a)),this.fragmentTracker.fragBuffered(r)}}},b.onBufferFlushing=function(e,t){var r=t.startOffset,n=t.endOffset;if(0===r&&n!==Number.POSITIVE_INFINITY){var i=this.currentTrackId,a=this.levels;if(!a.length||!a[i]||!a[i].details)return;var s=n-a[i].details.targetduration;if(s<=0)return;t.endOffsetSubtitles=Math.max(0,s),this.tracksBuffered.forEach((function(e){for(var t=0;t<e.length;)if(e[t].end<=s)e.shift();else{if(!(e[t].start<s))break;e[t].start=s,t++}})),this.fragmentTracker.removeFragmentsInRange(r,s,d.PlaylistLevelType.SUBTITLE)}},b.onError=function(e,t){var r,n=t.frag;n&&n.type===d.PlaylistLevelType.SUBTITLE&&(null!==(r=this.fragCurrent)&&void 0!==r&&r.loader&&this.fragCurrent.loader.abort(),this.state=c.State.IDLE)},b.onSubtitleTracksUpdated=function(e,t){var r=this,n=t.subtitleTracks;this.tracksBuffered=[],this.levels=n.map((function(e){return new f.Level(e)})),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach((function(e){r.tracksBuffered[e.id]=[]})),this.mediaBuffer=null},b.onSubtitleTrackSwitch=function(e,t){if(this.currentTrackId=t.id,this.levels.length&&-1!==this.currentTrackId){var r=this.levels[this.currentTrackId];null!=r&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.setInterval(500)}else this.clearInterval()},b.onSubtitleTrackLoaded=function(e,t){var r,n=t.details,i=t.id,a=this.currentTrackId,u=this.levels;if(u.length){var d=u[a];if(!(i>=u.length||i!==a)&&d){if(this.mediaBuffer=this.mediaBufferTimeRanges,n.live||null!==(r=d.details)&&void 0!==r&&r.live){var f=this.mainDetails;if(n.deltaUpdateFailed||!f)return;var h=f.fragments[0];d.details?0===this.alignPlaylists(n,d.details)&&h&&Object(l.addSliding)(n,h.start):n.hasProgramDateTime&&f.hasProgramDateTime?Object(o.alignMediaPlaylistByPDT)(n,f):h&&Object(l.addSliding)(n,h.start)}d.details=n,this.levelLastLoaded=i,this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===c.State.IDLE&&(Object(s.findFragmentByPTS)(null,n.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),d.details=void 0))}}},b._handleFragmentLoadComplete=function(e){var t=e.frag,r=e.payload,i=t.decryptdata,a=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&i&&i.key&&i.iv&&"AES-128"===i.method){var s=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(r),i.key.buffer,i.iv.buffer).then((function(e){var r=performance.now();a.trigger(n.Events.FRAG_DECRYPTED,{frag:t,payload:e,stats:{tstart:s,tdecrypt:r}})}))}},b.doTick=function(){if(this.media){if(this.state===c.State.IDLE){var e,t=this.currentTrackId,r=this.levels;if(!r.length||!r[t]||!r[t].details)return;var o=r[t].details,l=o.targetduration,d=this.config,f=this.media,h=a.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,f.currentTime-l,d.maxBufferHole),g=h.end;if(h.len>this.getMaxBufferLength()+l)return;console.assert(o,"Subtitle track details are defined on idle subtitle stream controller tick");var p,v=o.fragments,m=v.length,y=o.edge,b=this.fragPrevious;if(g<y){var E=d.maxFragLookUpTolerance;b&&o.hasProgramDateTime&&(p=Object(s.findFragmentByPDT)(v,b.endProgramDateTime,E)),p||!(p=Object(s.findFragmentByPTS)(b,v,g,E))&&b&&b.start<v[0].start&&(p=v[0])}else p=v[m-1];null!==(e=p)&&void 0!==e&&e.encrypted?(i.logger.log("Loading key for "+p.sn),this.state=c.State.KEY_LOADING,this.hls.trigger(n.Events.KEY_LOADING,{frag:p})):p&&this.fragmentTracker.getState(p)===u.FragmentState.NOT_LOADED&&this.loadFragment(p,o,g)}}else this.state=c.State.IDLE},b.loadFragment=function(t,r,n){this.fragCurrent=t,e.prototype.loadFragment.call(this,t,r,n)},v=p,(m=[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}])&&h(v.prototype,m),y&&h(v,y),p}(c.default)},"./src/controller/subtitle-track-controller.ts":
|
|
|
/*!*****************************************************!*\
|
|
|
!*** ./src/controller/subtitle-track-controller.ts ***!
|
|
|
\*****************************************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t);var n=r(/*! ../events */"./src/events.ts"),i=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),a=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),s=r(/*! ../types/loader */"./src/types/loader.ts");function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var u=function(e){var t,r;function a(t){var r;return(r=e.call(this,t,"[subtitle-track-controller]")||this).media=null,r.tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.selectDefaultTrack=!0,r.queuedDefaultTrack=-1,r.trackChangeListener=function(){return r.onTextTracksChanged()},r.asyncPollTrackChange=function(){return r.pollTrackChange(0)},r.useTextTrackPolling=!1,r.subtitlePollingInterval=-1,r.subtitleDisplay=!0,r.registerListeners(),r}r=e,(t=a).prototype=Object.create(r.prototype),t.prototype.constructor=t,l(t,r);var u,d,f,h=a.prototype;return h.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,e.prototype.destroy.call(this)},h.registerListeners=function(){var e=this.hls;e.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(n.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(n.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(n.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(n.Events.ERROR,this.onError,this)},h.unregisterListeners=function(){var e=this.hls;e.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(n.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(n.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(n.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(n.Events.ERROR,this.onError,this)},h.onMediaAttached=function(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},h.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)},h.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),c(this.media.textTracks).forEach((function(e){Object(i.clearCurrentCues)(e)})),this.subtitleTrack=-1,this.media=null)},h.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},h.onManifestParsed=function(e,t){this.tracks=t.subtitleTracks},h.onSubtitleTrackLoaded=function(e,t){var r=t.id,n=t.details,i=this.trackId,a=this.tracksInGroup[i];if(a){var s=a.details;a.details=t.details,this.log("subtitle track "+r+" loaded ["+n.startSN+"-"+n.endSN+"]"),r===this.trackId&&(this.retryCount=0,this.playlistLoaded(r,t,s))}else this.warn("Invalid subtitle track id "+r)},h.onLevelLoading=function(e,t){this.switchLevel(t.level)},h.onLevelSwitching=function(e,t){this.switchLevel(t.level)},h.switchLevel=function(e){var t=this.hls.levels[e];if(null!=t&&t.textGroupIds){var r=t.textGroupIds[t.urlId];if(this.groupId!==r){var i=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,a=this.tracks.filter((function(e){return!r||e.groupId===r}));this.tracksInGroup=a;var s=this.findTrackId(null==i?void 0:i.name)||this.findTrackId();this.groupId=r;var o={subtitleTracks:a};this.log("Updating subtitle tracks, "+a.length+' track(s) found in "'+r+'" group-id'),this.hls.trigger(n.Events.SUBTITLE_TRACKS_UPDATED,o),-1!==s&&this.setSubtitleTrack(s,i)}}},h.findTrackId=function(e){for(var t=this.tracksInGroup,r=0;r<t.length;r++){var n=t[r];if((!this.selectDefaultTrack||n.default)&&(!e||e===n.name))return n.id}return-1},h.onError=function(t,r){e.prototype.onError.call(this,t,r),!r.fatal&&r.context&&r.context.type===s.PlaylistContextType.SUBTITLE_TRACK&&r.context.id===this.trackId&&r.context.groupId===this.groupId&&this.retryLoadingOrFail(r)},h.loadPlaylist=function(e){var t=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(t)){var r=t.id,i=t.groupId,a=t.url;if(e)try{a=e.addDirectives(a)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}this.log("Loading subtitle playlist for id "+r),this.hls.trigger(n.Events.SUBTITLE_TRACK_LOADING,{url:a,id:r,groupId:i,deliveryDirectives:e||null})}},h.toggleTrackModes=function(e){var t=this,r=this.media,n=this.subtitleDisplay,i=this.trackId;if(r){var a=c(r.textTracks),s=a.filter((function(e){return e.groupId===t.groupId}));if(-1===e)[].slice.call(a).forEach((function(e){e.mode="disabled"}));else{var o=s[i];o&&(o.mode="disabled")}var l=s[e];l&&(l.mode=n?"showing":"hidden")}},h.setSubtitleTrack=function(e,t){var r,i=this.tracksInGroup;if(this.media){if(this.trackId!==e&&this.toggleTrackModes(e),!(this.trackId===e&&(-1===e||null!==(r=i[e])&&void 0!==r&&r.details)||e<-1||e>=i.length)){this.clearTimer();var a=i[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,a){var s=a.id,o=a.groupId,l=void 0===o?"":o,u=a.name,c=a.type,d=a.url;this.hls.trigger(n.Events.SUBTITLE_TRACK_SWITCH,{id:s,groupId:l,name:u,type:c,url:d});var f=this.switchParams(a.url,null==t?void 0:t.details);this.loadPlaylist(f)}else this.hls.trigger(n.Events.SUBTITLE_TRACK_SWITCH,{id:e})}}else this.queuedDefaultTrack=e},h.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var e=-1,t=c(this.media.textTracks),r=0;r<t.length;r++)if("hidden"===t[r].mode)e=r;else if("showing"===t[r].mode){e=r;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}},u=a,(d=[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1;var t=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,t)}}])&&o(u.prototype,d),f&&o(u,f),a}(a.default);function c(e){for(var t=[],r=0;r<e.length;r++){var n=e[r];"subtitles"===n.kind&&n.label&&t.push(e[r])}return t}t.default=u},"./src/controller/timeline-controller.ts":
|
|
|
/*!***********************************************!*\
|
|
|
!*** ./src/controller/timeline-controller.ts ***!
|
|
|
\***********************************************/
|
|
|
/*! exports provided: TimelineController */function(e,t,r){"use strict";r.r(t),r.d(t,"TimelineController",(function(){return f}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/cea-608-parser */"./src/utils/cea-608-parser.ts"),s=r(/*! ../utils/output-filter */"./src/utils/output-filter.ts"),o=r(/*! ../utils/webvtt-parser */"./src/utils/webvtt-parser.ts"),l=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),u=r(/*! ../utils/imsc1-ttml-parser */"./src/utils/imsc1-ttml-parser.ts"),c=r(/*! ../types/loader */"./src/types/loader.ts"),d=r(/*! ../utils/logger */"./src/utils/logger.ts"),f=function(){function e(e){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var t=new s.default(this,"textTrack1"),r=new s.default(this,"textTrack2"),n=new s.default(this,"textTrack3"),o=new s.default(this,"textTrack4");this.cea608Parser1=new a.default(1,t,r),this.cea608Parser2=new a.default(3,n,o)}e.on(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(i.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(i.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(i.Events.FRAG_LOADING,this.onFragLoading,this),e.on(i.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(i.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(i.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(i.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(i.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var t=e.prototype;return t.destroy=function(){var e=this.hls;e.off(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(i.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(i.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(i.Events.FRAG_LOADING,this.onFragLoading,this),e.off(i.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(i.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(i.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(i.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(i.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},t.addCues=function(e,t,r,n,a){for(var s,o,l,u,c=!1,d=a.length;d--;){var f=a[d],h=(s=f[0],o=f[1],l=t,u=r,Math.min(o,u)-Math.max(s,l));if(h>=0&&(f[0]=Math.min(f[0],t),f[1]=Math.max(f[1],r),c=!0,h/(r-t)>.5))return}if(c||a.push([t,r]),this.config.renderTextTracksNatively){var g=this.captionsTracks[e];this.Cues.newCue(g,t,r,n)}else{var p=this.Cues.newCue(null,t,r,n);this.hls.trigger(i.Events.CUES_PARSED,{type:"captions",cues:p,track:e})}},t.onInitPtsFound=function(e,t){var r=this,n=t.frag,a=t.id,s=t.initPTS,o=t.timescale,l=this.unparsedVttFrags;"main"===a&&(this.initPTS[n.cc]=s,this.timescale[n.cc]=o),l.length&&(this.unparsedVttFrags=[],l.forEach((function(e){r.onFragLoaded(i.Events.FRAG_LOADED,e)})))},t.getExistingTrack=function(e){var t=this.media;if(t)for(var r=0;r<t.textTracks.length;r++){var n=t.textTracks[r];if(n[e])return n}return null},t.createCaptionsTrack=function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)},t.createNativeTrack=function(e){if(!this.captionsTracks[e]){var t=this.captionsProperties,r=this.captionsTracks,n=this.media,i=t[e],a=i.label,s=i.languageCode,o=this.getExistingTrack(e);if(o)r[e]=o,Object(l.clearCurrentCues)(r[e]),Object(l.sendAddTrackEvent)(r[e],n);else{var u=this.createTextTrack("captions",a,s);u&&(u[e]=!0,r[e]=u)}}},t.createNonNativeTrack=function(e){if(!this.nonNativeCaptionsTracks[e]){var t=this.captionsProperties[e];if(t){var r={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(i.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}}},t.createTextTrack=function(e,t,r){var n=this.media;if(n)return n.addTextTrack(e,t,r)},t.onMediaAttaching=function(e,t){this.media=t.media,this._cleanTracks()},t.onMediaDetaching=function(){var e=this.captionsTracks;Object.keys(e).forEach((function(t){Object(l.clearCurrentCues)(e[t]),delete e[t]})),this.nonNativeCaptionsTracks={}},t.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},t._cleanTracks=function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var r=0;r<t.length;r++)Object(l.clearCurrentCues)(t[r])}},t.onSubtitleTracksUpdated=function(e,t){var r=this;this.textTracks=[];var n=t.subtitleTracks||[],a=n.some((function(e){return e.textCodec===u.IMSC1_CODEC}));if(this.config.enableWebVTT||a&&this.config.enableIMSC1){var s=this.tracks&&n&&this.tracks.length===n.length;if(this.tracks=n||[],this.config.renderTextTracksNatively){var o=this.media?this.media.textTracks:[];this.tracks.forEach((function(e,t){var n;if(t<o.length){for(var i=null,a=0;a<o.length;a++)if(h(o[a],e)){i=o[a];break}i&&(n=i)}n?Object(l.clearCurrentCues)(n):(n=r.createTextTrack("subtitles",e.name,e.lang))&&(n.mode="disabled"),n&&(n.groupId=e.groupId,r.textTracks.push(n))}))}else if(!s&&this.tracks&&this.tracks.length){var c=this.tracks.map((function(e){return{label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}}));this.hls.trigger(i.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:c})}}},t.onManifestLoaded=function(e,t){var r=this;this.config.enableCEA708Captions&&t.captions&&t.captions.forEach((function(e){var t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(t){var n="textTrack"+t[1],i=r.captionsProperties[n];i&&(i.label=e.name,e.lang&&(i.languageCode=e.lang),i.media=e)}}))},t.onFragLoading=function(e,t){var r=this.cea608Parser1,n=this.cea608Parser2,i=this.lastSn,a=this.lastPartIndex;if(this.enabled&&r&&n&&t.frag.type===c.PlaylistLevelType.MAIN){var s,o,l=t.frag.sn,u=null!=(s=null==t||null===(o=t.part)||void 0===o?void 0:o.index)?s:-1;l===i+1||l===i&&u===a+1||(r.reset(),n.reset()),this.lastSn=l,this.lastPartIndex=u}},t.onFragLoaded=function(e,t){var r=t.frag,a=t.payload,s=this.initPTS,o=this.unparsedVttFrags;if(r.type===c.PlaylistLevelType.SUBTITLE)if(a.byteLength){if(!Object(n.isFiniteNumber)(s[r.cc]))return o.push(t),void(s.length&&this.hls.trigger(i.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Missing initial subtitle PTS")}));var l=r.decryptdata;if(null==l||null==l.key||"AES-128"!==l.method){var d=this.tracks[r.level],f=this.vttCCs;f[r.cc]||(f[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),d&&d.textCodec===u.IMSC1_CODEC?this._parseIMSC1(r,a):this._parseVTTs(r,a,f)}}else this.hls.trigger(i.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})},t._parseIMSC1=function(e,t){var r=this,n=this.hls;Object(u.parseIMSC1)(t,this.initPTS[e.cc],this.timescale[e.cc],(function(t){r._appendCues(t,e.level),n.trigger(i.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})}),(function(t){d.logger.log("Failed to parse IMSC1: "+t),n.trigger(i.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})}))},t._parseVTTs=function(e,t,r){var n=this,a=this.hls;Object(o.parseWebVTT)(t,this.initPTS[e.cc],this.timescale[e.cc],r,e.cc,e.start,(function(t){n._appendCues(t,e.level),a.trigger(i.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})}),(function(r){n._fallbackToIMSC1(e,t),d.logger.log("Failed to parse VTT cue: "+r),a.trigger(i.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:r})}))},t._fallbackToIMSC1=function(e,t){var r=this,n=this.tracks[e.level];n.textCodec||Object(u.parseIMSC1)(t,this.initPTS[e.cc],this.timescale[e.cc],(function(){n.textCodec=u.IMSC1_CODEC,r._parseIMSC1(e,t)}),(function(){n.textCodec="wvtt"}))},t._appendCues=function(e,t){var r=this.hls;if(this.config.renderTextTracksNatively){var n=this.textTracks[t];if("disabled"===n.mode)return;e.forEach((function(e){return Object(l.addCueToTrack)(n,e)}))}else{var a=this.tracks[t].default?"default":"subtitles"+t;r.trigger(i.Events.CUES_PARSED,{type:"subtitles",cues:e,track:a})}},t.onFragDecrypted=function(e,t){var r=t.frag;if(r.type===c.PlaylistLevelType.SUBTITLE){if(!Object(n.isFiniteNumber)(this.initPTS[r.cc]))return void this.unparsedVttFrags.push(t);this.onFragLoaded(i.Events.FRAG_LOADED,t)}},t.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},t.onFragParsingUserdata=function(e,t){var r=this.cea608Parser1,n=this.cea608Parser2;if(this.enabled&&r&&n)for(var i=0;i<t.samples.length;i++){var a=t.samples[i].bytes;if(a){var s=this.extractCea608Data(a);r.addData(t.samples[i].pts,s[0]),n.addData(t.samples[i].pts,s[1])}}},t.onBufferFlushing=function(e,t){var r=t.startOffset,n=t.endOffset,i=t.endOffsetSubtitles,a=t.type,s=this.media;if(s&&!(s.currentTime<n)){if(!a||"video"===a){var o=this.captionsTracks;Object.keys(o).forEach((function(e){return Object(l.removeCuesInRange)(o[e],r,n)}))}if(this.config.renderTextTracksNatively&&0===r&&void 0!==i){var u=this.textTracks;Object.keys(u).forEach((function(e){return Object(l.removeCuesInRange)(u[e],r,i)}))}}},t.extractCea608Data=function(e){for(var t=31&e[0],r=2,n=[[],[]],i=0;i<t;i++){var a=e[r++],s=127&e[r++],o=127&e[r++],l=3&a;0===s&&0===o||0!=(4&a)&&(0!==l&&1!==l||(n[l].push(s),n[l].push(o)))}return n},e}();function h(e,t){return e&&e.label===t.name&&!(e.textTrack1||e.textTrack2)}},"./src/crypt/aes-crypto.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/crypt/aes-crypto.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return n}));var n=function(){function e(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}return e.prototype.decrypt=function(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)},e}()},"./src/crypt/aes-decryptor.ts":
|
|
|
/*!************************************!*\
|
|
|
!*** ./src/crypt/aes-decryptor.ts ***!
|
|
|
\************************************/
|
|
|
/*! exports provided: removePadding, default */function(e,t,r){"use strict";r.r(t),r.d(t,"removePadding",(function(){return i})),r.d(t,"default",(function(){return a}));var n=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts");function i(e){var t=e.byteLength,r=t&&new DataView(e.buffer).getUint8(t-1);return r?Object(n.sliceUint8)(e,0,t-r):e}var a=function(){function e(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var t=e.prototype;return t.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),n=0;n<4;n++)r[n]=t.getUint32(4*n);return r},t.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,n=r[0],i=r[1],a=r[2],s=r[3],o=this.invSubMix,l=o[0],u=o[1],c=o[2],d=o[3],f=new Uint32Array(256),h=0,g=0,p=0;for(p=0;p<256;p++)f[p]=p<128?p<<1:p<<1^283;for(p=0;p<256;p++){var v=g^g<<1^g<<2^g<<3^g<<4;v=v>>>8^255&v^99,e[h]=v,t[v]=h;var m=f[h],y=f[m],b=f[y],E=257*f[v]^16843008*v;n[h]=E<<24|E>>>8,i[h]=E<<16|E>>>16,a[h]=E<<8|E>>>24,s[h]=E,E=16843009*b^65537*y^257*m^16843008*h,l[v]=E<<24|E>>>8,u[v]=E<<16|E>>>16,c[v]=E<<8|E>>>24,d[v]=E,h?(h=m^f[f[f[b^m]]],g^=f[f[g]]):h=g=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,n=0;n<t.length&&r;)r=t[n]===this.key[n],n++;if(!r){this.key=t;var i=this.keySize=t.length;if(4!==i&&6!==i&&8!==i)throw new Error("Invalid aes key size="+i);var a,s,o,l,u=this.ksRows=4*(i+6+1),c=this.keySchedule=new Uint32Array(u),d=this.invKeySchedule=new Uint32Array(u),f=this.sBox,h=this.rcon,g=this.invSubMix,p=g[0],v=g[1],m=g[2],y=g[3];for(a=0;a<u;a++)a<i?o=c[a]=t[a]:(l=o,a%i==0?(l=f[(l=l<<8|l>>>24)>>>24]<<24|f[l>>>16&255]<<16|f[l>>>8&255]<<8|f[255&l],l^=h[a/i|0]<<24):i>6&&a%i==4&&(l=f[l>>>24]<<24|f[l>>>16&255]<<16|f[l>>>8&255]<<8|f[255&l]),c[a]=o=(c[a-i]^l)>>>0);for(s=0;s<u;s++)a=u-s,l=3&s?c[a]:c[a-4],d[s]=s<4||a<=4?l:p[f[l>>>24]]^v[f[l>>>16&255]]^m[f[l>>>8&255]]^y[f[255&l]],d[s]=d[s]>>>0}},t.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},t.decrypt=function(e,t,r){for(var n,i,a,s,o,l,u,c,d,f,h,g,p,v,m=this.keySize+6,y=this.invKeySchedule,b=this.invSBox,E=this.invSubMix,T=E[0],S=E[1],k=E[2],A=E[3],x=this.uint8ArrayToUint32Array_(r),L=x[0],D=x[1],O=x[2],C=x[3],_=new Int32Array(e),w=new Int32Array(_.length),R=this.networkToHostOrderSwap;t<_.length;){for(d=R(_[t]),f=R(_[t+1]),h=R(_[t+2]),g=R(_[t+3]),o=d^y[0],l=g^y[1],u=h^y[2],c=f^y[3],p=4,v=1;v<m;v++)n=T[o>>>24]^S[l>>16&255]^k[u>>8&255]^A[255&c]^y[p],i=T[l>>>24]^S[u>>16&255]^k[c>>8&255]^A[255&o]^y[p+1],a=T[u>>>24]^S[c>>16&255]^k[o>>8&255]^A[255&l]^y[p+2],s=T[c>>>24]^S[o>>16&255]^k[l>>8&255]^A[255&u]^y[p+3],o=n,l=i,u=a,c=s,p+=4;n=b[o>>>24]<<24^b[l>>16&255]<<16^b[u>>8&255]<<8^b[255&c]^y[p],i=b[l>>>24]<<24^b[u>>16&255]<<16^b[c>>8&255]<<8^b[255&o]^y[p+1],a=b[u>>>24]<<24^b[c>>16&255]<<16^b[o>>8&255]<<8^b[255&l]^y[p+2],s=b[c>>>24]<<24^b[o>>16&255]<<16^b[l>>8&255]<<8^b[255&u]^y[p+3],w[t]=R(n^L),w[t+1]=R(s^D),w[t+2]=R(a^O),w[t+3]=R(i^C),L=d,D=f,O=h,C=g,t+=4}return w.buffer},e}()},"./src/crypt/decrypter.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/crypt/decrypter.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return u}));var n=r(/*! ./aes-crypto */"./src/crypt/aes-crypto.ts"),i=r(/*! ./fast-aes-key */"./src/crypt/fast-aes-key.ts"),a=r(/*! ./aes-decryptor */"./src/crypt/aes-decryptor.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),l=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts"),u=function(){function e(e,t,r){var n=(void 0===r?{}:r).removePKCS7Padding,i=void 0===n||n;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=e,this.config=t,this.removePKCS7Padding=i,i)try{var a=self.crypto;a&&(this.subtle=a.subtle||a.webkitSubtle)}catch(e){}null===this.subtle&&(this.config.enableSoftwareAES=!0)}var t=e.prototype;return t.destroy=function(){this.observer=null},t.isSync=function(){return this.config.enableSoftwareAES},t.flush=function(){var e=this.currentResult;if(e){var t=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?Object(a.removePadding)(t):t}this.reset()},t.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},t.decrypt=function(e,t,r,n){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(e),t,r);var i=this.flush();i&&n(i.buffer)}else this.webCryptoDecrypt(new Uint8Array(e),t,r).then(n)},t.softwareDecrypt=function(e,t,r){var n=this.currentIV,i=this.currentResult,s=this.remainderData;this.logOnce("JS AES decrypt"),s&&(e=Object(o.appendUint8Array)(s,e),this.remainderData=null);var u=this.getValidChunk(e);if(!u.length)return null;n&&(r=n);var c=this.softwareDecrypter;c||(c=this.softwareDecrypter=new a.default),c.expandKey(t);var d=i;return this.currentResult=c.decrypt(u.buffer,0,r),this.currentIV=Object(l.sliceUint8)(u,-16).buffer,d||null},t.webCryptoDecrypt=function(e,t,r){var a=this,s=this.subtle;return this.key===t&&this.fastAesKey||(this.key=t,this.fastAesKey=new i.default(s,t)),this.fastAesKey.expandKey().then((function(t){return s?new n.default(s,r).decrypt(e.buffer,t):Promise.reject(new Error("web crypto not initialized"))})).catch((function(n){return a.onWebCryptoError(n,e,t,r)}))},t.onWebCryptoError=function(e,t,r,n){return s.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",e),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(t,r,n)},t.getValidChunk=function(e){var t=e,r=e.length-e.length%16;return r!==e.length&&(t=Object(l.sliceUint8)(e,0,r),this.remainderData=Object(l.sliceUint8)(e,r)),t},t.logOnce=function(e){this.logEnabled&&(s.logger.log("[decrypter.ts]: "+e),this.logEnabled=!1)},e}()},"./src/crypt/fast-aes-key.ts":
|
|
|
/*!***********************************!*\
|
|
|
!*** ./src/crypt/fast-aes-key.ts ***!
|
|
|
\***********************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return n}));var n=function(){function e(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}return e.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},e}()},"./src/demux/aacdemuxer.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/demux/aacdemuxer.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t);var n=r(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts"),i=r(/*! ./adts */"./src/demux/adts.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! ../demux/id3 */"./src/demux/id3.ts");function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var l=function(e){var t,r;function n(t,r){var n;return(n=e.call(this)||this).observer=void 0,n.config=void 0,n.observer=t,n.config=r,n}r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,o(t,r);var l=n.prototype;return l.resetInitSegment=function(t,r,n){e.prototype.resetInitSegment.call(this,t,r,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}},n.probe=function(e){if(!e)return!1;for(var t=(s.getID3Data(e,0)||[]).length,r=e.length;t<r;t++)if(i.probe(e,t))return a.logger.log("ADTS sync word found !"),!0;return!1},l.canParse=function(e,t){return i.canParse(e,t)},l.appendFrame=function(e,t,r){i.initTrackConfig(e,this.observer,t,r,e.manifestCodec);var n=i.appendFrame(e,t,r,this.initPTS,this.frameIndex);if(n&&0===n.missing)return n},n}(n.default);l.minProbeByteLength=9,t.default=l},"./src/demux/adts.ts":
|
|
|
/*!***************************!*\
|
|
|
!*** ./src/demux/adts.ts ***!
|
|
|
\***************************/
|
|
|
/*! exports provided: getAudioConfig, isHeaderPattern, getHeaderLength, getFullFrameLength, canGetFrameLength, isHeader, canParse, probe, initTrackConfig, getFrameDuration, parseFrameHeader, appendFrame */function(e,t,r){"use strict";r.r(t),r.d(t,"getAudioConfig",(function(){return s})),r.d(t,"isHeaderPattern",(function(){return o})),r.d(t,"getHeaderLength",(function(){return l})),r.d(t,"getFullFrameLength",(function(){return u})),r.d(t,"canGetFrameLength",(function(){return c})),r.d(t,"isHeader",(function(){return d})),r.d(t,"canParse",(function(){return f})),r.d(t,"probe",(function(){return h})),r.d(t,"initTrackConfig",(function(){return g})),r.d(t,"getFrameDuration",(function(){return p})),r.d(t,"parseFrameHeader",(function(){return v})),r.d(t,"appendFrame",(function(){return m}));var n=r(/*! ../utils/logger */"./src/utils/logger.ts"),i=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../events */"./src/events.ts");function s(e,t,r,s){var o,l,u,c,d=navigator.userAgent.toLowerCase(),f=s,h=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];o=1+((192&t[r+2])>>>6);var g=(60&t[r+2])>>>2;if(!(g>h.length-1))return u=(1&t[r+2])<<2,u|=(192&t[r+3])>>>6,n.logger.log("manifest codec:"+s+", ADTS type:"+o+", samplingIndex:"+g),/firefox/i.test(d)?g>=6?(o=5,c=new Array(4),l=g-3):(o=2,c=new Array(2),l=g):-1!==d.indexOf("android")?(o=2,c=new Array(2),l=g):(o=5,c=new Array(4),s&&(-1!==s.indexOf("mp4a.40.29")||-1!==s.indexOf("mp4a.40.5"))||!s&&g>=6?l=g-3:((s&&-1!==s.indexOf("mp4a.40.2")&&(g>=6&&1===u||/vivaldi/i.test(d))||!s&&1===u)&&(o=2,c=new Array(2)),l=g)),c[0]=o<<3,c[0]|=(14&g)>>1,c[1]|=(1&g)<<7,c[1]|=u<<3,5===o&&(c[1]|=(14&l)>>1,c[2]=(1&l)<<7,c[2]|=8,c[3]=0),{config:c,samplerate:h[g],channelCount:u,codec:"mp4a.40."+o,manifestCodec:f};e.trigger(a.Events.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+g})}function o(e,t){return 255===e[t]&&240==(246&e[t+1])}function l(e,t){return 1&e[t+1]?7:9}function u(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function c(e,t){return t+5<e.length}function d(e,t){return t+1<e.length&&o(e,t)}function f(e,t){return c(e,t)&&o(e,t)&&u(e,t)<=e.length-t}function h(e,t){if(d(e,t)){var r=l(e,t);if(t+r>=e.length)return!1;var n=u(e,t);if(n<=r)return!1;var i=t+n;return i===e.length||d(e,i)}return!1}function g(e,t,r,i,a){if(!e.samplerate){var o=s(t,r,i,a);if(!o)return;e.config=o.config,e.samplerate=o.samplerate,e.channelCount=o.channelCount,e.codec=o.codec,e.manifestCodec=o.manifestCodec,n.logger.log("parsed codec:"+e.codec+", rate:"+o.samplerate+", channels:"+o.channelCount)}}function p(e){return 9216e4/e}function v(e,t,r,n,i){var a=l(e,t),s=u(e,t);if((s-=a)>0)return{headerLength:a,frameLength:s,stamp:r+n*i}}function m(e,t,r,n,i){var a=v(t,r,n,i,p(e.samplerate));if(a){var s,o=a.frameLength,l=a.headerLength,u=a.stamp,c=l+o,d=Math.max(0,r+c-t.length);d?(s=new Uint8Array(c-l)).set(t.subarray(r+l,t.length),0):s=t.subarray(r+l,r+c);var f={unit:s,pts:u};return d||e.samples.push(f),{sample:f,length:c,missing:d}}}},"./src/demux/base-audio-demuxer.ts":
|
|
|
/*!*****************************************!*\
|
|
|
!*** ./src/demux/base-audio-demuxer.ts ***!
|
|
|
\*****************************************/
|
|
|
/*! exports provided: initPTSFn, default */function(e,t,r){"use strict";r.r(t),r.d(t,"initPTSFn",(function(){return u}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ../demux/id3 */"./src/demux/id3.ts"),a=r(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts"),s=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),o=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts"),l=function(){function e(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var t=e.prototype;return t.resetInitSegment=function(e,t,r){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},t.resetTimeStamp=function(){},t.resetContiguity=function(){},t.canParse=function(e,t){return!1},t.appendFrame=function(e,t,r){},t.demux=function(e,t){this.cachedData&&(e=Object(s.appendUint8Array)(this.cachedData,e),this.cachedData=null);var r,n,l=i.getID3Data(e,0),c=l?l.length:0,d=this._audioTrack,f=this._id3Track,h=l?i.getTimeStamp(l):void 0,g=e.length;for(0!==this.frameIndex&&null!==this.initPTS||(this.initPTS=u(h,t)),l&&l.length>0&&f.samples.push({pts:this.initPTS,dts:this.initPTS,data:l}),n=this.initPTS;c<g;){if(this.canParse(e,c)){var p=this.appendFrame(d,e,c);p?(this.frameIndex++,n=p.sample.pts,r=c+=p.length):c=g}else i.canParse(e,c)?(l=i.getID3Data(e,c),f.samples.push({pts:n,dts:n,data:l}),r=c+=l.length):c++;if(c===g&&r!==g){var v=Object(o.sliceUint8)(e,r);this.cachedData?this.cachedData=Object(s.appendUint8Array)(this.cachedData,v):this.cachedData=v}}return{audioTrack:d,avcTrack:Object(a.dummyTrack)(),id3Track:f,textTrack:Object(a.dummyTrack)()}},t.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},t.flush=function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(a.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(a.dummyTrack)()}},t.destroy=function(){},e}(),u=function(e,t){return Object(n.isFiniteNumber)(e)?90*e:9e4*t};t.default=l},"./src/demux/chunk-cache.ts":
|
|
|
/*!**********************************!*\
|
|
|
!*** ./src/demux/chunk-cache.ts ***!
|
|
|
\**********************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return n}));var n=function(){function e(){this.chunks=[],this.dataLength=0}var t=e.prototype;return t.push=function(e){this.chunks.push(e),this.dataLength+=e.length},t.flush=function(){var e,t=this.chunks,r=this.dataLength;return t.length?(e=1===t.length?t[0]:function(e,t){for(var r=new Uint8Array(t),n=0,i=0;i<e.length;i++){var a=e[i];r.set(a,n),n+=a.length}return r}(t,r),this.reset(),e):new Uint8Array(0)},t.reset=function(){this.chunks.length=0,this.dataLength=0},e}()},"./src/demux/dummy-demuxed-track.ts":
|
|
|
/*!******************************************!*\
|
|
|
!*** ./src/demux/dummy-demuxed-track.ts ***!
|
|
|
\******************************************/
|
|
|
/*! exports provided: dummyTrack */function(e,t,r){"use strict";function n(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}r.r(t),r.d(t,"dummyTrack",(function(){return n}))},"./src/demux/exp-golomb.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/demux/exp-golomb.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t);var n=r(/*! ../utils/logger */"./src/utils/logger.ts"),i=function(){function e(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}var t=e.prototype;return t.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,n=new Uint8Array(4),i=Math.min(4,t);if(0===i)throw new Error("no bytes available");n.set(e.subarray(r,r+i)),this.word=new DataView(n.buffer).getUint32(0),this.bitsAvailable=8*i,this.bytesAvailable-=i},t.skipBits=function(e){var t;this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)>>3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},t.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;return e>32&&n.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0?this.word<<=t:this.bytesAvailable>0&&this.loadWord(),(t=e-t)>0&&this.bitsAvailable?r<<t|this.readBits(t):r},t.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e)if(0!=(this.word&2147483648>>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},t.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.skipEG=function(){this.skipBits(1+this.skipLZ())},t.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},t.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},t.readBoolean=function(){return 1===this.readBits(1)},t.readUByte=function(){return this.readBits(8)},t.readUShort=function(){return this.readBits(16)},t.readUInt=function(){return this.readBits(32)},t.skipScalingList=function(e){for(var t=8,r=8,n=0;n<e;n++)0!==r&&(r=(t+this.readEG()+256)%256),t=0===r?t:r},t.readSPS=function(){var e,t,r,n=0,i=0,a=0,s=0,o=this.readUByte.bind(this),l=this.readBits.bind(this),u=this.readUEG.bind(this),c=this.readBoolean.bind(this),d=this.skipBits.bind(this),f=this.skipEG.bind(this),h=this.skipUEG.bind(this),g=this.skipScalingList.bind(this);o();var p=o();if(l(5),d(3),o(),h(),100===p||110===p||122===p||244===p||44===p||83===p||86===p||118===p||128===p){var v=u();if(3===v&&d(1),h(),h(),d(1),c())for(t=3!==v?8:12,r=0;r<t;r++)c()&&g(r<6?16:64)}h();var m=u();if(0===m)u();else if(1===m)for(d(1),f(),f(),e=u(),r=0;r<e;r++)f();h(),d(1);var y=u(),b=u(),E=l(1);0===E&&d(1),d(1),c()&&(n=u(),i=u(),a=u(),s=u());var T=[1,1];if(c()&&c())switch(o()){case 1:T=[1,1];break;case 2:T=[12,11];break;case 3:T=[10,11];break;case 4:T=[16,11];break;case 5:T=[40,33];break;case 6:T=[24,11];break;case 7:T=[20,11];break;case 8:T=[32,11];break;case 9:T=[80,33];break;case 10:T=[18,11];break;case 11:T=[15,11];break;case 12:T=[64,33];break;case 13:T=[160,99];break;case 14:T=[4,3];break;case 15:T=[3,2];break;case 16:T=[2,1];break;case 255:T=[o()<<8|o(),o()<<8|o()]}return{width:Math.ceil(16*(y+1)-2*n-2*i),height:(2-E)*(b+1)*16-(E?2:4)*(a+s),pixelRatio:T}},t.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},e}();t.default=i},"./src/demux/id3.ts":
|
|
|
/*!**************************!*\
|
|
|
!*** ./src/demux/id3.ts ***!
|
|
|
\**************************/
|
|
|
/*! exports provided: isHeader, isFooter, getID3Data, canParse, getTimeStamp, isTimeStampFrame, getID3Frames, decodeFrame, utf8ArrayToStr, testables */function(e,t,r){"use strict";r.r(t),r.d(t,"isHeader",(function(){return i})),r.d(t,"isFooter",(function(){return a})),r.d(t,"getID3Data",(function(){return s})),r.d(t,"canParse",(function(){return l})),r.d(t,"getTimeStamp",(function(){return u})),r.d(t,"isTimeStampFrame",(function(){return c})),r.d(t,"getID3Frames",(function(){return f})),r.d(t,"decodeFrame",(function(){return h})),r.d(t,"utf8ArrayToStr",(function(){return y})),r.d(t,"testables",(function(){return b}));var n,i=function(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},a=function(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},s=function(e,t){for(var r=t,n=0;i(e,t);)n+=10,n+=o(e,t+6),a(e,t+10)&&(n+=10),t+=n;if(n>0)return e.subarray(r,r+n)},o=function(e,t){var r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,r|=(127&e[t+2])<<7,r|=127&e[t+3]},l=function(e,t){return i(e,t)&&o(e,t+6)+10<=e.length-t},u=function(e){for(var t=f(e),r=0;r<t.length;r++){var n=t[r];if(c(n))return m(n)}},c=function(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info},d=function(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=o(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}},f=function(e){for(var t=0,r=[];i(e,t);){for(var n=o(e,t+6),s=(t+=10)+n;t+8<s;){var l=d(e.subarray(t)),u=h(l);u&&r.push(u),t+=l.size+10}a(e,t)&&(t+=10)}return r},h=function(e){return"PRIV"===e.type?g(e):"W"===e.type[0]?v(e):p(e)},g=function(e){if(!(e.size<2)){var t=y(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}}},p=function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,r=y(e.data.subarray(t),!0);t+=r.length+1;var n=y(e.data.subarray(t));return{key:e.type,info:r,data:n}}var i=y(e.data.subarray(1));return{key:e.type,data:i}}},v=function(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,r=y(e.data.subarray(t),!0);t+=r.length+1;var n=y(e.data.subarray(t));return{key:e.type,info:r,data:n}}var i=y(e.data);return{key:e.type,data:i}},m=function(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),r=1&t[3],n=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return n/=45,r&&(n+=47721858.84),Math.round(n)}},y=function(e,t){void 0===t&&(t=!1);var r=E();if(r){var n=r.decode(e);if(t){var i=n.indexOf("\0");return-1!==i?n.substring(0,i):n}return n.replace(/\0/g,"")}for(var a,s,o,l=e.length,u="",c=0;c<l;){if(0===(a=e[c++])&&t)return u;if(0!==a&&3!==a)switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(a);break;case 12:case 13:s=e[c++],u+=String.fromCharCode((31&a)<<6|63&s);break;case 14:s=e[c++],o=e[c++],u+=String.fromCharCode((15&a)<<12|(63&s)<<6|(63&o)<<0)}}return u},b={decodeTextFrame:p};function E(){return n||void 0===self.TextDecoder||(n=new self.TextDecoder("utf-8")),n}},"./src/demux/mp3demuxer.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/demux/mp3demuxer.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t);var n=r(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts"),i=r(/*! ../demux/id3 */"./src/demux/id3.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! ./mpegaudio */"./src/demux/mpegaudio.ts");function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var l=function(e){var t,r;function n(){return e.apply(this,arguments)||this}r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,o(t,r);var l=n.prototype;return l.resetInitSegment=function(t,r,n){e.prototype.resetInitSegment.call(this,t,r,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}},n.probe=function(e){if(!e)return!1;for(var t=(i.getID3Data(e,0)||[]).length,r=e.length;t<r;t++)if(s.probe(e,t))return a.logger.log("MPEG Audio sync word found !"),!0;return!1},l.canParse=function(e,t){return s.canParse(e,t)},l.appendFrame=function(e,t,r){if(null!==this.initPTS)return s.appendFrame(e,t,r,this.initPTS,this.frameIndex)},n}(n.default);l.minProbeByteLength=4,t.default=l},"./src/demux/mp4demuxer.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/demux/mp4demuxer.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t);var n=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),i=r(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts"),a=function(){function e(e,t){this.remainderData=null,this.config=void 0,this.config=t}var t=e.prototype;return t.resetTimeStamp=function(){},t.resetInitSegment=function(){},t.resetContiguity=function(){},e.probe=function(e){return Object(n.findBox)({data:e,start:0,end:Math.min(e.length,16384)},["moof"]).length>0},t.demux=function(e){var t=e,r=Object(i.dummyTrack)();if(this.config.progressive){this.remainderData&&(t=Object(n.appendUint8Array)(this.remainderData,e));var a=Object(n.segmentValidRange)(t);this.remainderData=a.remainder,r.samples=a.valid||new Uint8Array}else r.samples=t;return{audioTrack:Object(i.dummyTrack)(),avcTrack:r,id3Track:Object(i.dummyTrack)(),textTrack:Object(i.dummyTrack)()}},t.flush=function(){var e=Object(i.dummyTrack)();return e.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(i.dummyTrack)(),avcTrack:e,id3Track:Object(i.dummyTrack)(),textTrack:Object(i.dummyTrack)()}},t.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},t.destroy=function(){},e}();a.minProbeByteLength=1024,t.default=a},"./src/demux/mpegaudio.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/demux/mpegaudio.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: appendFrame, parseHeader, isHeaderPattern, isHeader, canParse, probe */function(e,t,r){"use strict";r.r(t),r.d(t,"appendFrame",(function(){return l})),r.d(t,"parseHeader",(function(){return u})),r.d(t,"isHeaderPattern",(function(){return c})),r.d(t,"isHeader",(function(){return d})),r.d(t,"canParse",(function(){return f})),r.d(t,"probe",(function(){return h}));var n=null,i=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],a=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],s=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],o=[0,1,1,4];function l(e,t,r,n,i){if(!(r+24>t.length)){var a=u(t,r);if(a&&r+a.frameLength<=t.length){var s=n+i*(9e4*a.samplesPerFrame/a.sampleRate),o={unit:t.subarray(r,r+a.frameLength),pts:s,dts:s};return e.config=[],e.channelCount=a.channelCount,e.samplerate=a.sampleRate,e.samples.push(o),{sample:o,length:a.frameLength,missing:0}}}}function u(e,t){var r=e[t+1]>>3&3,l=e[t+1]>>1&3,u=e[t+2]>>4&15,c=e[t+2]>>2&3;if(1!==r&&0!==u&&15!==u&&3!==c){var d=e[t+2]>>1&1,f=e[t+3]>>6,h=1e3*i[14*(3===r?3-l:3===l?3:4)+u-1],g=a[3*(3===r?0:2===r?1:2)+c],p=3===f?1:2,v=s[r][l],m=o[l],y=8*v*m,b=Math.floor(v*h/g+d)*m;if(null===n){var E=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);n=E?parseInt(E[1]):0}return!!n&&n<=87&&2===l&&h>=224e3&&0===f&&(e[t+3]=128|e[t+3]),{sampleRate:g,channelCount:p,frameLength:b,samplesPerFrame:y}}}function c(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function d(e,t){return t+1<e.length&&c(e,t)}function f(e,t){return c(e,t)&&4<=e.length-t}function h(e,t){if(t+1<e.length&&c(e,t)){var r=u(e,t),n=4;null!=r&&r.frameLength&&(n=r.frameLength);var i=t+n;return i===e.length||d(e,i)}return!1}},"./src/demux/sample-aes.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/demux/sample-aes.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t);var n=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),i=r(/*! ./tsdemuxer */"./src/demux/tsdemuxer.ts"),a=function(){function e(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new n.default(e,t,{removePKCS7Padding:!1})}var t=e.prototype;return t.decryptBuffer=function(e,t){this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,t)},t.decryptAacSample=function(e,t,r,n){var i=e[t].unit,a=i.subarray(16,i.length-i.length%16),s=a.buffer.slice(a.byteOffset,a.byteOffset+a.length),o=this;this.decryptBuffer(s,(function(a){var s=new Uint8Array(a);i.set(s,16),n||o.decryptAacSamples(e,t+1,r)}))},t.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32)){var n=this.decrypter.isSync();if(this.decryptAacSample(e,t,r,n),!n)return}}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),n=0,i=32;i<=e.length-16;i+=160,n+=16)r.set(e.subarray(i,i+16),n);return r},t.getAvcDecryptedUnit=function(e,t){for(var r=new Uint8Array(t),n=0,i=32;i<=e.length-16;i+=160,n+=16)e.set(r.subarray(n,n+16),i);return e},t.decryptAvcSample=function(e,t,r,n,a,s){var o=Object(i.discardEPB)(a.data),l=this.getAvcEncryptedData(o),u=this;this.decryptBuffer(l.buffer,(function(i){a.data=u.getAvcDecryptedUnit(o,i),s||u.decryptAvcSamples(e,t,r+1,n)}))},t.decryptAvcSamples=function(e,t,r,n){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void n();for(var i=e[t].units;!(r>=i.length);r++){var a=i[r];if(!(a.data.length<=48||1!==a.type&&5!==a.type)){var s=this.decrypter.isSync();if(this.decryptAvcSample(e,t,r,n,a,s),!s)return}}}},e}();t.default=a},"./src/demux/transmuxer-interface.ts":
|
|
|
/*!*******************************************!*\
|
|
|
!*** ./src/demux/transmuxer-interface.ts ***!
|
|
|
\*******************************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return d}));var n=r(/*! webworkify-webpack */"./node_modules/webworkify-webpack/index.js"),i=r(/*! ../events */"./src/events.ts"),a=r(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../errors */"./src/errors.ts"),l=r(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),u=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),c=Object(l.getMediaSource)()||{isTypeSupported:function(){return!1}},d=function(){function e(e,t,r,l){var d=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=e,this.id=t,this.onTransmuxComplete=r,this.onFlush=l;var f=e.config,h=function(t,r){(r=r||{}).frag=d.frag,r.id=d.id,e.trigger(t,r)};this.observer=new u.EventEmitter,this.observer.on(i.Events.FRAG_DECRYPTED,h),this.observer.on(i.Events.ERROR,h);var g={mp4:c.isTypeSupported("video/mp4"),mpeg:c.isTypeSupported("audio/mpeg"),mp3:c.isTypeSupported('audio/mp4; codecs="mp3"')},p=navigator.vendor;if(f.enableWorker&&"undefined"!=typeof Worker){var v;s.logger.log("demuxing in webworker");try{v=this.worker=n(/*! ../demux/transmuxer-worker.ts */"./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),v.addEventListener("message",this.onwmsg),v.onerror=function(t){e.trigger(i.Events.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(t.message+" ("+t.filename+":"+t.lineno+")")})},v.postMessage({cmd:"init",typeSupported:g,vendor:p,id:t,config:JSON.stringify(f)})}catch(e){s.logger.warn("Error in worker:",e),s.logger.error("Error while initializing DemuxerWorker, fallback to inline"),v&&self.URL.revokeObjectURL(v.objectURL),this.transmuxer=new a.default(this.observer,g,f,p,t),this.worker=null}}else this.transmuxer=new a.default(this.observer,g,f,p,t)}var t=e.prototype;return t.destroy=function(){var e=this.worker;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null;else{var t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}var r=this.observer;r&&r.removeAllListeners(),this.observer=null},t.push=function(e,t,r,n,i,o,l,u,c,d){var f=this;c.transmuxing.start=self.performance.now();var h=this.transmuxer,g=this.worker,p=o?o.start:i.start,v=i.decryptdata,m=this.frag,y=!(m&&i.cc===m.cc),b=!(m&&c.level===m.level),E=m?c.sn-m.sn:-1,T=this.part?c.part-this.part.index:1,S=!b&&(1===E||0===E&&1===T),k=self.performance.now();(b||E||0===i.stats.parsing.start)&&(i.stats.parsing.start=k),!o||!T&&S||(o.stats.parsing.start=k);var A=new a.TransmuxState(y,S,u,b,p);if(!S||y){s.logger.log("[transmuxer-interface, "+i.type+"]: Starting new transmux session for sn: "+c.sn+" p: "+c.part+" level: "+c.level+" id: "+c.id+"\n discontinuity: "+y+"\n trackSwitch: "+b+"\n contiguous: "+S+"\n accurateTimeOffset: "+u+"\n timeOffset: "+p);var x=new a.TransmuxConfig(r,n,t,l,d);this.configureTransmuxer(x)}if(this.frag=i,this.part=o,g)g.postMessage({cmd:"demux",data:e,decryptdata:v,chunkMeta:c,state:A},e instanceof ArrayBuffer?[e]:[]);else if(h){var L=h.push(e,v,c,A);Object(a.isPromise)(L)?L.then((function(e){f.handleTransmuxComplete(e)})):this.handleTransmuxComplete(L)}},t.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.transmuxer,n=this.worker;if(n)n.postMessage({cmd:"flush",chunkMeta:e});else if(r){var i=r.flush(e);Object(a.isPromise)(i)?i.then((function(r){t.handleFlushResult(r,e)})):this.handleFlushResult(i,e)}},t.handleFlushResult=function(e,t){var r=this;e.forEach((function(e){r.handleTransmuxComplete(e)})),this.onFlush(t)},t.onWorkerMessage=function(e){var t=e.data,r=this.hls;switch(t.event){case"init":self.URL.revokeObjectURL(this.worker.objectURL);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data)}},t.configureTransmuxer=function(e){var t=this.worker,r=this.transmuxer;t?t.postMessage({cmd:"configure",config:e}):r&&r.configure(e)},t.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},e}()},"./src/demux/transmuxer-worker.ts":
|
|
|
/*!****************************************!*\
|
|
|
!*** ./src/demux/transmuxer-worker.ts ***!
|
|
|
\****************************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return o}));var n=r(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts"),i=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js");function o(e){var t=new s.EventEmitter,r=function(t,r){e.postMessage({event:t,data:r})};t.on(i.Events.FRAG_DECRYPTED,r),t.on(i.Events.ERROR,r),e.addEventListener("message",(function(i){var s=i.data;switch(s.cmd){case"init":var o=JSON.parse(s.config);e.transmuxer=new n.default(t,s.typeSupported,o,s.vendor,s.id),Object(a.enableLogs)(o.debug),r("init",null);break;case"configure":e.transmuxer.configure(s.config);break;case"demux":var u=e.transmuxer.push(s.data,s.decryptdata,s.chunkMeta,s.state);Object(n.isPromise)(u)?u.then((function(t){l(e,t)})):l(e,u);break;case"flush":var d=s.chunkMeta,f=e.transmuxer.flush(d);Object(n.isPromise)(f)?f.then((function(t){c(e,t,d)})):c(e,f,d)}}))}function l(e,t){if((r=t.remuxResult).audio||r.video||r.text||r.id3||r.initSegment){var r,n=[],i=t.remuxResult,a=i.audio,s=i.video;a&&u(n,a),s&&u(n,s),e.postMessage({event:"transmuxComplete",data:t},n)}}function u(e,t){t.data1&&e.push(t.data1.buffer),t.data2&&e.push(t.data2.buffer)}function c(e,t,r){t.forEach((function(t){l(e,t)})),e.postMessage({event:"flush",data:r})}},"./src/demux/transmuxer.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/demux/transmuxer.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default, isPromise, TransmuxConfig, TransmuxState */function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return y})),r.d(t,"isPromise",(function(){return E})),r.d(t,"TransmuxConfig",(function(){return T})),r.d(t,"TransmuxState",(function(){return S}));var n,i=r(/*! ../events */"./src/events.ts"),a=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),o=r(/*! ../demux/aacdemuxer */"./src/demux/aacdemuxer.ts"),l=r(/*! ../demux/mp4demuxer */"./src/demux/mp4demuxer.ts"),u=r(/*! ../demux/tsdemuxer */"./src/demux/tsdemuxer.ts"),c=r(/*! ../demux/mp3demuxer */"./src/demux/mp3demuxer.ts"),d=r(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts"),f=r(/*! ../remux/passthrough-remuxer */"./src/remux/passthrough-remuxer.ts"),h=r(/*! ./chunk-cache */"./src/demux/chunk-cache.ts"),g=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),p=r(/*! ../utils/logger */"./src/utils/logger.ts");try{n=self.performance.now.bind(self.performance)}catch(e){p.logger.debug("Unable to use Performance API on this environment"),n=self.Date.now}var v=[{demux:u.default,remux:d.default},{demux:l.default,remux:f.default},{demux:o.default,remux:d.default},{demux:c.default,remux:d.default}],m=1024;v.forEach((function(e){var t=e.demux;m=Math.max(m,t.minProbeByteLength)}));var y=function(){function e(e,t,r,n,i){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.cache=new h.default,this.observer=e,this.typeSupported=t,this.config=r,this.vendor=n,this.id=i}var t=e.prototype;return t.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},t.push=function(e,t,r,i){var a=this,s=r.transmuxing;s.executeStart=n();var o=new Uint8Array(e),l=this.cache,u=this.config,c=this.currentTransmuxState,d=this.transmuxConfig;i&&(this.currentTransmuxState=i);var f=function(e,t){var r=null;return e.byteLength>0&&null!=t&&null!=t.key&&null!==t.iv&&null!=t.method&&(r=t),r}(o,t);if(f&&"AES-128"===f.method){var h=this.getDecrypter();if(!u.enableSoftwareAES)return this.decryptionPromise=h.webCryptoDecrypt(o,f.key.buffer,f.iv.buffer).then((function(e){var t=a.push(e,null,r);return a.decryptionPromise=null,t})),this.decryptionPromise;var p=h.softwareDecrypt(o,f.key.buffer,f.iv.buffer);if(!p)return s.executeEnd=n(),b(r);o=new Uint8Array(p)}var v=i||c,m=v.contiguous,y=v.discontinuity,E=v.trackSwitch,T=v.accurateTimeOffset,S=v.timeOffset,k=d.audioCodec,A=d.videoCodec,x=d.defaultInitPts,L=d.duration,D=d.initSegmentData;if((y||E)&&this.resetInitSegment(D,k,A,L),y&&this.resetInitialTimestamp(x),m||this.resetContiguity(),this.needsProbing(o,y,E)){if(l.dataLength){var O=l.flush();o=Object(g.appendUint8Array)(O,o)}this.configureTransmuxer(o,d)}var C=this.transmux(o,f,S,T,r),_=this.currentTransmuxState;return _.contiguous=!0,_.discontinuity=!1,_.trackSwitch=!1,s.executeEnd=n(),C},t.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=n();var s=this.decrypter,o=this.cache,l=this.currentTransmuxState,u=this.decryptionPromise;if(u)return u.then((function(){return t.flush(e)}));var c=[],d=l.timeOffset;if(s){var f=s.flush();f&&c.push(this.push(f,null,e))}var h=o.dataLength;o.reset();var g=this.demuxer,p=this.remuxer;if(!g||!p)return h>=m&&this.observer.emit(i.Events.ERROR,i.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),r.executeEnd=n(),[b(e)];var v=g.flush(d);return E(v)?v.then((function(r){return t.flushRemux(c,r,e),c})):(this.flushRemux(c,v,e),c)},t.flushRemux=function(e,t,r){var i=t.audioTrack,a=t.avcTrack,s=t.id3Track,o=t.textTrack,l=this.currentTransmuxState,u=l.accurateTimeOffset,c=l.timeOffset;p.logger.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var d=this.remuxer.remux(i,a,s,o,c,u,!0,this.id);e.push({remuxResult:d,chunkMeta:r}),r.transmuxing.executeEnd=n()},t.resetInitialTimestamp=function(e){var t=this.demuxer,r=this.remuxer;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))},t.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())},t.resetInitSegment=function(e,t,r,n){var i=this.demuxer,a=this.remuxer;i&&a&&(i.resetInitSegment(t,r,n),a.resetInitSegment(e,t,r))},t.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},t.transmux=function(e,t,r,n,i){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,n,i):this.transmuxUnencrypted(e,r,n,i)},t.transmuxUnencrypted=function(e,t,r,n){var i=this.demuxer.demux(e,t,!1,!this.config.progressive),a=i.audioTrack,s=i.avcTrack,o=i.id3Track,l=i.textTrack;return{remuxResult:this.remuxer.remux(a,s,o,l,t,r,!1,this.id),chunkMeta:n}},t.transmuxSampleAes=function(e,t,r,n,i){var a=this;return this.demuxer.demuxSampleAes(e,t,r).then((function(e){return{remuxResult:a.remuxer.remux(e.audioTrack,e.avcTrack,e.id3Track,e.textTrack,r,n,!1,a.id),chunkMeta:i}}))},t.configureTransmuxer=function(e,t){for(var r,n=this.config,i=this.observer,a=this.typeSupported,s=this.vendor,o=t.audioCodec,u=t.defaultInitPts,c=t.duration,d=t.initSegmentData,h=t.videoCodec,g=0,m=v.length;g<m;g++)if(v[g].demux.probe(e)){r=v[g];break}r||(p.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),r={demux:l.default,remux:f.default});var y=this.demuxer,b=this.remuxer,E=r.remux,T=r.demux;b&&b instanceof E||(this.remuxer=new E(i,n,a,s)),y&&y instanceof T||(this.demuxer=new T(i,n,a),this.probe=T.probe),this.resetInitSegment(d,o,h,c),this.resetInitialTimestamp(u)},t.needsProbing=function(e,t,r){return!this.demuxer||!this.remuxer||t||r},t.getDecrypter=function(){var e=this.decrypter;return e||(e=this.decrypter=new s.default(this.observer,this.config)),e},e}(),b=function(e){return{remuxResult:{},chunkMeta:e}};function E(e){return"then"in e&&e.then instanceof Function}var T=function(e,t,r,n,i){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=n,this.defaultInitPts=i},S=function(e,t,r,n,i){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=n,this.timeOffset=i}},"./src/demux/tsdemuxer.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/demux/tsdemuxer.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: discardEPB, default */function(e,t,r){"use strict";r.r(t),r.d(t,"discardEPB",(function(){return E}));var n=r(/*! ./adts */"./src/demux/adts.ts"),i=r(/*! ./mpegaudio */"./src/demux/mpegaudio.ts"),a=r(/*! ./exp-golomb */"./src/demux/exp-golomb.ts"),s=r(/*! ./id3 */"./src/demux/id3.ts"),o=r(/*! ./sample-aes */"./src/demux/sample-aes.ts"),l=r(/*! ../events */"./src/events.ts"),u=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),c=r(/*! ../utils/logger */"./src/utils/logger.ts"),d=r(/*! ../errors */"./src/errors.ts"),f={video:1,audio:2,id3:3,text:4},h=function(){function e(e,t,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this.aacLastPTS=null,this._initPTS=null,this._initDTS=null,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=e,this.config=t,this.typeSupported=r}e.probe=function(t){var r=e.syncOffset(t);return!(r<0||(r&&c.logger.warn("MPEG2-TS detected but first sync word found @ offset "+r+", junk ahead ?"),0))},e.syncOffset=function(e){for(var t=Math.min(1e3,e.length-564),r=0;r<t;){if(71===e[r]&&71===e[r+188]&&71===e[r+376])return r;r++}return-1},e.createTrack=function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:f[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}};var t=e.prototype;return t.resetInitSegment=function(t,r,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=e.createTrack("video",n),this._audioTrack=e.createTrack("audio",n),this._id3Track=e.createTrack("id3",n),this._txtTrack=e.createTrack("text",n),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=t,this.videoCodec=r,this._duration=n},t.resetTimeStamp=function(){},t.resetContiguity=function(){var e=this._audioTrack,t=this._avcTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},t.demux=function(t,r,n,i){var a;void 0===n&&(n=!1),void 0===i&&(i=!1),n||(this.sampleAes=null);var s=this._avcTrack,o=this._audioTrack,f=this._id3Track,h=s.pid,g=s.pesData,y=o.pid,b=f.pid,E=o.pesData,T=f.pesData,S=!1,k=this.pmtParsed,A=this._pmtId,x=t.length;if(this.remainderData&&(x=(t=Object(u.appendUint8Array)(this.remainderData,t)).length,this.remainderData=null),x<188&&!i)return this.remainderData=t,{audioTrack:o,avcTrack:s,id3Track:f,textTrack:this._txtTrack};var L=Math.max(0,e.syncOffset(t));(x-=(x+L)%188)<t.byteLength&&!i&&(this.remainderData=new Uint8Array(t.buffer,x,t.buffer.byteLength-x));for(var D=L;D<x;D+=188)if(71===t[D]){var O=!!(64&t[D+1]),C=((31&t[D+1])<<8)+t[D+2],_=void 0;if((48&t[D+3])>>4>1){if((_=D+5+t[D+4])===D+188)continue}else _=D+4;switch(C){case h:O&&(g&&(a=m(g))&&this.parseAVCPES(a,!1),g={data:[],size:0}),g&&(g.data.push(t.subarray(_,D+188)),g.size+=D+188-_);break;case y:O&&(E&&(a=m(E))&&(o.isAAC?this.parseAACPES(a):this.parseMPEGPES(a)),E={data:[],size:0}),E&&(E.data.push(t.subarray(_,D+188)),E.size+=D+188-_);break;case b:O&&(T&&(a=m(T))&&this.parseID3PES(a),T={data:[],size:0}),T&&(T.data.push(t.subarray(_,D+188)),T.size+=D+188-_);break;case 0:O&&(_+=t[_]+1),A=this._pmtId=p(t,_);break;case A:O&&(_+=t[_]+1);var w=v(t,_,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,n);(h=w.avc)>0&&(s.pid=h),(y=w.audio)>0&&(o.pid=y,o.isAAC=w.isAAC),(b=w.id3)>0&&(f.pid=b),S&&!k&&(c.logger.log("reparse from beginning"),S=!1,D=L-188),k=this.pmtParsed=!0;break;case 17:case 8191:break;default:S=!0}}else this.observer.emit(l.Events.ERROR,l.Events.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});s.pesData=g,o.pesData=E,f.pesData=T;var R={audioTrack:o,avcTrack:s,id3Track:f,textTrack:this._txtTrack};return i&&this.extractRemainingSamples(R),R},t.flush=function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e},t.extractRemainingSamples=function(e){var t,r=e.audioTrack,n=e.avcTrack,i=e.id3Track,a=n.pesData,s=r.pesData,o=i.pesData;a&&(t=m(a))?(this.parseAVCPES(t,!0),n.pesData=null):n.pesData=a,s&&(t=m(s))?(r.isAAC?this.parseAACPES(t):this.parseMPEGPES(t),r.pesData=null):(null!=s&&s.size&&c.logger.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=s),o&&(t=m(o))?(this.parseID3PES(t),i.pesData=null):i.pesData=o},t.demuxSampleAes=function(e,t,r){var n=this.demux(e,r,!0,!this.config.progressive),i=this.sampleAes=new o.default(this.observer,this.config,t);return this.decrypt(n,i)},t.decrypt=function(e,t){return new Promise((function(r){var n=e.audioTrack,i=e.avcTrack;n.samples&&n.isAAC?t.decryptAacSamples(n.samples,0,(function(){i.samples?t.decryptAvcSamples(i.samples,0,0,(function(){r(e)})):r(e)})):i.samples&&t.decryptAvcSamples(i.samples,0,0,(function(){r(e)}))}))},t.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},t.parseAVCPES=function(e,t){var r,n=this,i=this._avcTrack,o=this.parseAVCNALu(e.data),l=this.avcSample,u=!1;e.data=null,l&&o.length&&!i.audFound&&(y(l,i),l=this.avcSample=g(!1,e.pts,e.dts,"")),o.forEach((function(t){switch(t.type){case 1:r=!0,l||(l=n.avcSample=g(!0,e.pts,e.dts,"")),l.frame=!0;var o=t.data;if(u&&o.length>4){var c=new a.default(o).readSliceType();2!==c&&4!==c&&7!==c&&9!==c||(l.key=!0)}break;case 5:r=!0,l||(l=n.avcSample=g(!0,e.pts,e.dts,"")),l.key=!0,l.frame=!0;break;case 6:r=!0;var d=new a.default(E(t.data));d.readUByte();for(var f=0,h=0,p=!1,v=0;!p&&d.bytesAvailable>1;){f=0;do{f+=v=d.readUByte()}while(255===v);h=0;do{h+=v=d.readUByte()}while(255===v);if(4===f&&0!==d.bytesAvailable){if(p=!0,181===d.readUByte()&&49===d.readUShort()&&1195456820===d.readUInt()&&3===d.readUByte()){for(var m=d.readUByte(),T=31&m,S=[m,d.readUByte()],k=0;k<T;k++)S.push(d.readUByte()),S.push(d.readUByte()),S.push(d.readUByte());b(n._txtTrack.samples,{type:3,pts:e.pts,bytes:S})}}else if(5===f&&0!==d.bytesAvailable){if(p=!0,h>16){for(var A=[],x=0;x<16;x++)A.push(d.readUByte().toString(16)),3!==x&&5!==x&&7!==x&&9!==x||A.push("-");for(var L=h-16,D=new Uint8Array(L),O=0;O<L;O++)D[O]=d.readUByte();b(n._txtTrack.samples,{pts:e.pts,payloadType:f,uuid:A.join(""),userData:Object(s.utf8ArrayToStr)(D),userDataBytes:D})}}else if(h<d.bytesAvailable)for(var C=0;C<h;C++)d.readUByte()}break;case 7:if(r=!0,u=!0,!i.sps){var _=new a.default(t.data).readSPS();i.width=_.width,i.height=_.height,i.pixelRatio=_.pixelRatio,i.sps=[t.data],i.duration=n._duration;for(var w=t.data.subarray(1,4),R="avc1.",I=0;I<3;I++){var P=w[I].toString(16);P.length<2&&(P="0"+P),R+=P}i.codec=R}break;case 8:r=!0,i.pps||(i.pps=[t.data]);break;case 9:r=!1,i.audFound=!0,l&&y(l,i),l=n.avcSample=g(!1,e.pts,e.dts,"");break;case 12:r=!1;break;default:r=!1,l&&(l.debug+="unknown NAL "+t.type+" ")}l&&r&&l.units.push(t)})),t&&l&&(y(l,i),this.avcSample=null)},t.getLastNalUnit=function(){var e,t,r=this.avcSample;if(!r||0===r.units.length){var n=this._avcTrack.samples;r=n[n.length-1]}if(null!==(e=r)&&void 0!==e&&e.units){var i=r.units;t=i[i.length-1]}return t},t.parseAVCNALu=function(e){var t,r,n=e.byteLength,i=this._avcTrack,a=i.naluState||0,s=a,o=[],l=0,u=-1,c=0;for(-1===a&&(u=0,c=31&e[0],a=0,l=1);l<n;)if(t=e[l++],a)if(1!==a)if(t)if(1===t){if(u>=0){var d={data:e.subarray(u,l-a-1),type:c};o.push(d)}else{var f=this.getLastNalUnit();if(f&&(s&&l<=4-s&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-s)),(r=l-a-1)>0)){var h=new Uint8Array(f.data.byteLength+r);h.set(f.data,0),h.set(e.subarray(0,r),f.data.byteLength),f.data=h,f.state=0}}l<n?(u=l,c=31&e[l],a=0):a=-1}else a=0;else a=3;else a=t?0:2;else a=t?0:1;if(u>=0&&a>=0){var g={data:e.subarray(u,n),type:c,state:a};o.push(g)}if(0===o.length){var p=this.getLastNalUnit();if(p){var v=new Uint8Array(p.data.byteLength+e.byteLength);v.set(p.data,0),v.set(e,p.data.byteLength),p.data=v}}return i.naluState=a,o},t.parseAACPES=function(e){var t,r,i,a,s,o=0,u=this._audioTrack,f=this.aacOverFlow,h=e.data;if(f){this.aacOverFlow=null;var g=f.sample.unit.byteLength,p=Math.min(f.missing,g),v=g-p;f.sample.unit.set(h.subarray(0,p),v),u.samples.push(f.sample),o=f.missing}for(t=o,r=h.length;t<r-1&&!n.isHeader(h,t);t++);if(t===o||(t<r-1?(i="AAC PES did not start with ADTS header,offset:"+t,a=!1):(i="no ADTS header found in AAC PES",a=!0),c.logger.warn("parsing error:"+i),this.observer.emit(l.Events.ERROR,l.Events.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.FRAG_PARSING_ERROR,fatal:a,reason:i}),!a)){if(n.initTrackConfig(u,this.observer,h,t,this.audioCodec),void 0!==e.pts)s=e.pts;else{if(!f)return void c.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var m=n.getFrameDuration(u.samplerate);s=f.sample.pts+m}for(var y=0;t<r;){if(n.isHeader(h,t)){if(t+5<r){var b=n.appendFrame(u,h,t,s,y);if(b){if(!b.missing){t+=b.length,y++;continue}this.aacOverFlow=b}}break}t++}}},t.parseMPEGPES=function(e){var t=e.data,r=t.length,n=0,a=0,s=e.pts;if(void 0!==s)for(;a<r;)if(i.isHeader(t,a)){var o=i.appendFrame(this._audioTrack,t,a,s,n);if(!o)break;a+=o.length,n++}else a++;else c.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")},t.parseID3PES=function(e){void 0!==e.pts?this._id3Track.samples.push(e):c.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")},e}();function g(e,t,r,n){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:n,length:0}}function p(e,t){return(31&e[t+10])<<8|e[t+11]}function v(e,t,r,n){var i={audio:-1,avc:-1,id3:-1,isAAC:!0},a=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<a;){var s=(31&e[t+1])<<8|e[t+2];switch(e[t]){case 207:if(!n){c.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:-1===i.audio&&(i.audio=s);break;case 21:-1===i.id3&&(i.id3=s);break;case 219:if(!n){c.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:-1===i.avc&&(i.avc=s);break;case 3:case 4:r?-1===i.audio&&(i.audio=s,i.isAAC=!1):c.logger.log("MPEG audio found, not supported in this browser");break;case 36:c.logger.warn("Unsupported HEVC stream type found")}t+=5+((15&e[t+3])<<8|e[t+4])}return i}function m(e){var t,r,n,i,a,s=0,o=e.data;if(!e||0===e.size)return null;for(;o[0].length<19&&o.length>1;){var l=new Uint8Array(o[0].length+o[1].length);l.set(o[0]),l.set(o[1],o[0].length),o[0]=l,o.splice(1,1)}if(1===((t=o[0])[0]<<16)+(t[1]<<8)+t[2]){if((r=(t[4]<<8)+t[5])&&r>e.size-6)return null;var u=t[7];192&u&&(i=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,64&u?i-(a=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2)>54e5&&(c.logger.warn(Math.round((i-a)/9e4)+"s delta between PTS and DTS, align them"),i=a):a=i);var d=(n=t[8])+9;if(e.size<=d)return null;e.size-=d;for(var f=new Uint8Array(e.size),h=0,g=o.length;h<g;h++){var p=(t=o[h]).byteLength;if(d){if(d>p){d-=p;continue}t=t.subarray(d),p-=d,d=0}f.set(t,s),s+=p}return r&&(r-=n+3),{data:f,pts:i,dts:a,len:r}}return null}function y(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var r=t.samples,n=r.length;if(!n)return void t.dropped++;var i=r[n-1];e.pts=i.pts,e.dts=i.dts}t.samples.push(e)}e.debug.length&&c.logger.log(e.pts+"/"+e.dts+":"+e.debug)}function b(e,t){var r=e.length;if(r>0){if(t.pts>=e[r-1].pts)e.push(t);else for(var n=r-1;n>=0;n--)if(t.pts<e[n].pts){e.splice(n,0,t);break}}else e.push(t)}function E(e){for(var t=e.byteLength,r=[],n=1;n<t-2;)0===e[n]&&0===e[n+1]&&3===e[n+2]?(r.push(n+2),n+=2):n++;if(0===r.length)return e;var i=t-r.length,a=new Uint8Array(i),s=0;for(n=0;n<i;s++,n++)s===r[0]&&(s++,r.shift()),a[n]=e[s];return a}h.minProbeByteLength=188,t.default=h},"./src/errors.ts":
|
|
|
/*!***********************!*\
|
|
|
!*** ./src/errors.ts ***!
|
|
|
\***********************/
|
|
|
/*! exports provided: ErrorTypes, ErrorDetails */function(e,t,r){"use strict";var n,i;r.r(t),r.d(t,"ErrorTypes",(function(){return n})),r.d(t,"ErrorDetails",(function(){return i})),function(e){e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError"}(n||(n={})),function(e){e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.UNKNOWN="unknown"}(i||(i={}))},"./src/events.ts":
|
|
|
/*!***********************!*\
|
|
|
!*** ./src/events.ts ***!
|
|
|
\***********************/
|
|
|
/*! exports provided: Events */function(e,t,r){"use strict";var n;r.r(t),r.d(t,"Events",(function(){return n})),function(e){e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached"}(n||(n={}))},"./src/hls.ts":
|
|
|
/*!********************!*\
|
|
|
!*** ./src/hls.ts ***!
|
|
|
\********************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return y}));var n=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),i=r(/*! ./loader/playlist-loader */"./src/loader/playlist-loader.ts"),a=r(/*! ./loader/key-loader */"./src/loader/key-loader.ts"),s=r(/*! ./controller/id3-track-controller */"./src/controller/id3-track-controller.ts"),o=r(/*! ./controller/latency-controller */"./src/controller/latency-controller.ts"),l=r(/*! ./controller/level-controller */"./src/controller/level-controller.ts"),u=r(/*! ./controller/fragment-tracker */"./src/controller/fragment-tracker.ts"),c=r(/*! ./controller/stream-controller */"./src/controller/stream-controller.ts"),d=r(/*! ./is-supported */"./src/is-supported.ts"),f=r(/*! ./utils/logger */"./src/utils/logger.ts"),h=r(/*! ./config */"./src/config.ts"),g=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),p=r(/*! ./events */"./src/events.ts"),v=r(/*! ./errors */"./src/errors.ts");function m(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var y=function(){function e(t){void 0===t&&(t={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new g.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var r=this.config=Object(h.mergeConfig)(e.DefaultConfig,t);this.userConfig=t,Object(f.enableLogs)(r.debug),this._autoLevelCapping=-1,r.progressive&&Object(h.enableStreamingMode)(r);var n=r.abrController,d=r.bufferController,p=r.capLevelController,v=r.fpsController,m=this.abrController=new n(this),y=this.bufferController=new d(this),b=this.capLevelController=new p(this),E=new v(this),T=new i.default(this),S=new a.default(this),k=new s.default(this),A=this.levelController=new l.default(this),x=new u.FragmentTracker(this),L=this.streamController=new c.default(this,x);b.setStreamController(L),E.setStreamController(L);var D=[A,L];this.networkControllers=D;var O=[T,S,m,y,b,E,k,x];this.audioTrackController=this.createController(r.audioTrackController,null,D),this.createController(r.audioStreamController,x,D),this.subtitleTrackController=this.createController(r.subtitleTrackController,null,D),this.createController(r.subtitleStreamController,x,D),this.createController(r.timelineController,null,O),this.emeController=this.createController(r.emeController,null,O),this.cmcdController=this.createController(r.cmcdController,null,O),this.latencyController=this.createController(o.default,null,O),this.coreComponents=O}e.isSupported=function(){return Object(d.isSupported)()};var t,r,y,b=e.prototype;return b.createController=function(e,t,r){if(e){var n=t?new e(this,t):new e(this);return r&&r.push(n),n}return null},b.on=function(e,t,r){void 0===r&&(r=this),this._emitter.on(e,t,r)},b.once=function(e,t,r){void 0===r&&(r=this),this._emitter.once(e,t,r)},b.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},b.off=function(e,t,r,n){void 0===r&&(r=this),this._emitter.off(e,t,r,n)},b.listeners=function(e){return this._emitter.listeners(e)},b.emit=function(e,t,r){return this._emitter.emit(e,t,r)},b.trigger=function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){f.logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),this.trigger(p.Events.ERROR,{type:v.ErrorTypes.OTHER_ERROR,details:v.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:e,error:t})}return!1},b.listenerCount=function(e){return this._emitter.listenerCount(e)},b.destroy=function(){f.logger.log("destroy"),this.trigger(p.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((function(e){return e.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(e){return e.destroy()})),this.coreComponents.length=0},b.attachMedia=function(e){f.logger.log("attachMedia"),this._media=e,this.trigger(p.Events.MEDIA_ATTACHING,{media:e})},b.detachMedia=function(){f.logger.log("detachMedia"),this.trigger(p.Events.MEDIA_DETACHING,void 0),this._media=null},b.loadSource=function(e){this.stopLoad();var t=this.media,r=this.url,i=this.url=n.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});f.logger.log("loadSource:"+i),t&&r&&r!==i&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(t)),this.trigger(p.Events.MANIFEST_LOADING,{url:e})},b.startLoad=function(e){void 0===e&&(e=-1),f.logger.log("startLoad("+e+")"),this.networkControllers.forEach((function(t){t.startLoad(e)}))},b.stopLoad=function(){f.logger.log("stopLoad"),this.networkControllers.forEach((function(e){e.stopLoad()}))},b.swapAudioCodec=function(){f.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},b.recoverMediaError=function(){f.logger.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)},b.removeLevel=function(e,t){void 0===t&&(t=0),this.levelController.removeLevel(e,t)},t=e,y=[{key:"version",get:function(){return"1.1.2"}},{key:"Events",get:function(){return p.Events}},{key:"ErrorTypes",get:function(){return v.ErrorTypes}},{key:"ErrorDetails",get:function(){return v.ErrorDetails}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:h.hlsDefaultConfig},set:function(t){e.defaultConfig=t}}],(r=[{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){f.logger.log("set currentLevel:"+e),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){f.logger.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){f.logger.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){f.logger.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(e){f.logger.log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(f.logger.log("set autoLevelCapping:"+e),this._autoLevelCapping=e)}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,n=0;n<r;n++)if(e[n].maxBitrate>t)return n;return 0}},{key:"maxAutoLevel",get:function(){var e=this.levels,t=this.autoLevelCapping;return-1===t&&e&&e.length?e.length-1:t}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}])&&m(t.prototype,r),y&&m(t,y),e}();y.defaultConfig=void 0},"./src/is-supported.ts":
|
|
|
/*!*****************************!*\
|
|
|
!*** ./src/is-supported.ts ***!
|
|
|
\*****************************/
|
|
|
/*! exports provided: isSupported, changeTypeSupported */function(e,t,r){"use strict";r.r(t),r.d(t,"isSupported",(function(){return a})),r.d(t,"changeTypeSupported",(function(){return s}));var n=r(/*! ./utils/mediasource-helper */"./src/utils/mediasource-helper.ts");function i(){return self.SourceBuffer||self.WebKitSourceBuffer}function a(){var e=Object(n.getMediaSource)();if(!e)return!1;var t=i(),r=e&&"function"==typeof e.isTypeSupported&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),a=!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove;return!!r&&!!a}function s(){var e,t=i();return"function"==typeof(null==t||null===(e=t.prototype)||void 0===e?void 0:e.changeType)}},"./src/loader/fragment-loader.ts":
|
|
|
/*!***************************************!*\
|
|
|
!*** ./src/loader/fragment-loader.ts ***!
|
|
|
\***************************************/
|
|
|
/*! exports provided: default, LoadError */function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return d})),r.d(t,"LoadError",(function(){return h}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ../errors */"./src/errors.ts");function a(e){var t="function"==typeof Map?new Map:void 0;return(a=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return s(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),l(n,e)})(e)}function s(e,t,r){return(s=o()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&l(i,r.prototype),i}).apply(null,arguments)}function o(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var c=Math.pow(2,17),d=function(){function e(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var t=e.prototype;return t.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},t.abort=function(){this.loader&&this.loader.abort()},t.load=function(e,t){var r=this,n=e.url;if(!n)return Promise.reject(new h({type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,networkDetails:null},"Fragment does not have a "+(n?"part list":"url")));this.abort();var a=this.config,s=a.fLoader,o=a.loader;return new Promise((function(n,l){r.loader&&r.loader.destroy();var u=r.loader=e.loader=s?new s(a):new o(a),d=f(e),g={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:c};e.stats=u.stats,u.load(d,g,{onSuccess:function(t,i,a,s){r.resetLoader(e,u),n({frag:e,part:null,payload:t.data,networkDetails:s})},onError:function(t,n,a){r.resetLoader(e,u),l(new h({type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:t,networkDetails:a}))},onAbort:function(t,n,a){r.resetLoader(e,u),l(new h({type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,networkDetails:a}))},onTimeout:function(t,n,a){r.resetLoader(e,u),l(new h({type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,networkDetails:a}))},onProgress:function(r,n,i,a){t&&t({frag:e,part:null,payload:i,networkDetails:a})}})}))},t.loadPart=function(e,t,r){var n=this;this.abort();var a=this.config,s=a.fLoader,o=a.loader;return new Promise((function(l,u){n.loader&&n.loader.destroy();var d=n.loader=e.loader=s?new s(a):new o(a),g=f(e,t),p={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:c};t.stats=d.stats,d.load(g,p,{onSuccess:function(i,a,s,o){n.resetLoader(e,d),n.updateStatsFromPart(e,t);var u={frag:e,part:t,payload:i.data,networkDetails:o};r(u),l(u)},onError:function(r,a,s){n.resetLoader(e,d),u(new h({type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:r,networkDetails:s}))},onAbort:function(r,a,s){e.stats.aborted=t.stats.aborted,n.resetLoader(e,d),u(new h({type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,networkDetails:s}))},onTimeout:function(r,a,s){n.resetLoader(e,d),u(new h({type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,networkDetails:s}))}})}))},t.updateStatsFromPart=function(e,t){var r=e.stats,n=t.stats,i=n.total;if(r.loaded+=n.loaded,i){var a=Math.round(e.duration/t.duration),s=Math.min(Math.round(r.loaded/i),a),o=(a-s)*Math.round(r.loaded/s);r.total=r.loaded+o}else r.total=Math.max(r.loaded,r.total);var l=r.loading,u=n.loading;l.start?l.first+=u.first-u.start:(l.start=u.start,l.first=u.first),l.end=u.end},t.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},e}();function f(e,t){void 0===t&&(t=null);var r=t||e,i={frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},a=r.byteRangeStartOffset,s=r.byteRangeEndOffset;return Object(n.isFiniteNumber)(a)&&Object(n.isFiniteNumber)(s)&&(i.rangeStart=a,i.rangeEnd=s),i}var h=function(e){var t,r;function n(t){for(var r,n=arguments.length,i=new Array(n>1?n-1:0),a=1;a<n;a++)i[a-1]=arguments[a];return(r=e.call.apply(e,[this].concat(i))||this).data=void 0,r.data=t,r}return r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,l(t,r),n}(a(Error))},"./src/loader/fragment.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/loader/fragment.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: ElementaryStreamTypes, BaseSegment, Fragment, Part */function(e,t,r){"use strict";r.r(t),r.d(t,"ElementaryStreamTypes",(function(){return n})),r.d(t,"BaseSegment",(function(){return h})),r.d(t,"Fragment",(function(){return g})),r.d(t,"Part",(function(){return p}));var n,i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),a=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ./level-key */"./src/loader/level-key.ts"),l=r(/*! ./load-stats */"./src/loader/load-stats.ts");function u(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,c(e,t)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function d(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function f(e,t,r){return t&&d(e.prototype,t),r&&d(e,r),e}!function(e){e.AUDIO="audio",e.VIDEO="video",e.AUDIOVIDEO="audiovideo"}(n||(n={}));var h=function(){function e(e){var t;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((t={})[n.AUDIO]=null,t[n.VIDEO]=null,t[n.AUDIOVIDEO]=null,t),this.baseurl=e}return e.prototype.setByteRange=function(e,t){var r=e.split("@",2),n=[];1===r.length?n[0]=t?t.byteRangeEndOffset:0:n[0]=parseInt(r[1]),n[1]=parseInt(r[0])+n[0],this._byteRange=n},f(e,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(a.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}}]),e}(),g=function(e){function t(t,r){var n;return(n=e.call(this,r)||this)._decryptdata=null,n.rawProgramDateTime=null,n.programDateTime=null,n.tagList=[],n.duration=0,n.sn=0,n.levelkey=void 0,n.type=void 0,n.loader=null,n.level=-1,n.cc=0,n.startPTS=void 0,n.endPTS=void 0,n.appendedPTS=void 0,n.startDTS=void 0,n.endDTS=void 0,n.start=0,n.deltaPTS=void 0,n.maxStartPTS=void 0,n.minEndPTS=void 0,n.stats=new l.LoadStats,n.urlId=0,n.data=void 0,n.bitrateTest=!1,n.title=null,n.initSegment=null,n.type=t,n}u(t,e);var r=t.prototype;return r.createInitializationVector=function(e){for(var t=new Uint8Array(16),r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t},r.setDecryptDataFromLevelKey=function(e,t){var r=e;return"AES-128"===(null==e?void 0:e.method)&&e.uri&&!e.iv&&((r=o.LevelKey.fromURI(e.uri)).method=e.method,r.iv=this.createInitializationVector(t),r.keyFormat="identity"),r},r.setElementaryStreamInfo=function(e,t,r,n,i,a){void 0===a&&(a=!1);var s=this.elementaryStreams,o=s[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,n),o.endDTS=Math.max(o.endDTS,i)):s[e]={startPTS:t,endPTS:r,startDTS:n,endDTS:i,partial:a}},r.clearElementaryStreamInfo=function(){var e=this.elementaryStreams;e[n.AUDIO]=null,e[n.VIDEO]=null,e[n.AUDIOVIDEO]=null},f(t,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var e=this.sn;"number"!=typeof e&&(this.levelkey&&"AES-128"===this.levelkey.method&&!this.levelkey.iv&&s.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),e=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,e)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!Object(i.isFiniteNumber)(this.programDateTime))return null;var e=Object(i.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){var e;return!(null===(e=this.decryptdata)||void 0===e||!e.keyFormat||!this.decryptdata.uri)}}]),t}(h),p=function(e){function t(t,r,n,i,a){var s;(s=e.call(this,n)||this).fragOffset=0,s.duration=0,s.gap=!1,s.independent=!1,s.relurl=void 0,s.fragment=void 0,s.index=void 0,s.stats=new l.LoadStats,s.duration=t.decimalFloatingPoint("DURATION"),s.gap=t.bool("GAP"),s.independent=t.bool("INDEPENDENT"),s.relurl=t.enumeratedString("URI"),s.fragment=r,s.index=i;var o=t.enumeratedString("BYTERANGE");return o&&s.setByteRange(o,a),a&&(s.fragOffset=a.fragOffset+a.duration),s}return u(t,e),f(t,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),t}(h)},"./src/loader/key-loader.ts":
|
|
|
/*!**********************************!*\
|
|
|
!*** ./src/loader/key-loader.ts ***!
|
|
|
\**********************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return s}));var n=r(/*! ../events */"./src/events.ts"),i=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=function(){function e(e){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=e,this._registerListeners()}var t=e.prototype;return t._registerListeners=function(){this.hls.on(n.Events.KEY_LOADING,this.onKeyLoading,this)},t._unregisterListeners=function(){this.hls.off(n.Events.KEY_LOADING,this.onKeyLoading)},t.destroy=function(){for(var e in this._unregisterListeners(),this.loaders){var t=this.loaders[e];t&&t.destroy()}this.loaders={}},t.onKeyLoading=function(e,t){var r=t.frag,i=r.type,s=this.loaders[i];if(r.decryptdata){var o=r.decryptdata.uri;if(o!==this.decrypturl||null===this.decryptkey){var l=this.hls.config;if(s&&(a.logger.warn("abort previous key loader for type:"+i),s.abort()),!o)return void a.logger.warn("key uri is falsy");var u=l.loader,c=r.loader=this.loaders[i]=new u(l);this.decrypturl=o,this.decryptkey=null;var d={url:o,frag:r,responseType:"arraybuffer"},f={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:l.fragLoadingRetryDelay,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:0},h={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};c.load(d,f,h)}else this.decryptkey&&(r.decryptdata.key=this.decryptkey,this.hls.trigger(n.Events.KEY_LOADED,{frag:r}))}else a.logger.warn("Missing decryption data on fragment in onKeyLoading")},t.loadsuccess=function(e,t,r){var i=r.frag;i.decryptdata?(this.decryptkey=i.decryptdata.key=new Uint8Array(e.data),i.loader=null,delete this.loaders[i.type],this.hls.trigger(n.Events.KEY_LOADED,{frag:i})):a.logger.error("after key load, decryptdata unset")},t.loaderror=function(e,t){var r=t.frag,a=r.loader;a&&a.abort(),delete this.loaders[r.type],this.hls.trigger(n.Events.ERROR,{type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:r,response:e})},t.loadtimeout=function(e,t){var r=t.frag,a=r.loader;a&&a.abort(),delete this.loaders[r.type],this.hls.trigger(n.Events.ERROR,{type:i.ErrorTypes.NETWORK_ERROR,details:i.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:r})},e}()},"./src/loader/level-details.ts":
|
|
|
/*!*************************************!*\
|
|
|
!*** ./src/loader/level-details.ts ***!
|
|
|
\*************************************/
|
|
|
/*! exports provided: LevelDetails */function(e,t,r){"use strict";r.r(t),r.d(t,"LevelDetails",(function(){return a}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var a=function(){function e(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.fragments=[],this.url=e}var t,r,a;return e.prototype.reloaded=function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t,this.advanced=this.endSN>e.endSN||t>0||0===t&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay},t=e,(r=[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&Object(n.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!==(e=this.partList)&&void 0!==e&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var e;return null!==(e=this.fragments)&&void 0!==e&&e.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!==(e=this.partList)&&void 0!==e&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var e;return null!==(e=this.partList)&&void 0!==e&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}])&&i(t.prototype,r),a&&i(t,a),e}()},"./src/loader/level-key.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/loader/level-key.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: LevelKey */function(e,t,r){"use strict";r.r(t),r.d(t,"LevelKey",(function(){return a}));var n=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js");function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var a=function(){function e(e,t){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,this._uri=t?Object(n.buildAbsoluteURL)(e,t,{alwaysNormalize:!0}):e}var t,r,a;return e.fromURL=function(t,r){return new e(t,r)},e.fromURI=function(t){return new e(t)},t=e,(r=[{key:"uri",get:function(){return this._uri}}])&&i(t.prototype,r),a&&i(t,a),e}()},"./src/loader/load-stats.ts":
|
|
|
/*!**********************************!*\
|
|
|
!*** ./src/loader/load-stats.ts ***!
|
|
|
\**********************************/
|
|
|
/*! exports provided: LoadStats */function(e,t,r){"use strict";r.r(t),r.d(t,"LoadStats",(function(){return n}));var n=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":
|
|
|
/*!***********************************!*\
|
|
|
!*** ./src/loader/m3u8-parser.ts ***!
|
|
|
\***********************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return v}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),a=r(/*! ./fragment */"./src/loader/fragment.ts"),s=r(/*! ./level-details */"./src/loader/level-details.ts"),o=r(/*! ./level-key */"./src/loader/level-key.ts"),l=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts"),u=r(/*! ../utils/logger */"./src/utils/logger.ts"),c=r(/*! ../utils/codecs */"./src/utils/codecs.ts"),d=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,f=/#EXT-X-MEDIA:(.*)/g,h=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),g=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),p=/\.(mp4|m4s|m4v|m4a)$/i,v=function(){function e(){}return e.findGroup=function(e,t){for(var r=0;r<e.length;r++){var n=e[r];if(n.id===t)return n}},e.convertAVC1ToAVCOTI=function(e){var t=e.split(".");if(t.length>2){var r=t.shift()+".";return r+=parseInt(t.shift()).toString(16),r+=("000"+parseInt(t.shift()).toString(16)).substr(-4)}return e},e.resolve=function(e,t){return i.buildAbsoluteURL(t,e,{alwaysNormalize:!0})},e.parseMasterPlaylist=function(t,r){var n,i=[],a={},s=!1;for(d.lastIndex=0;null!=(n=d.exec(t));)if(n[1]){var o=new l.AttrList(n[1]),u={attrs:o,bitrate:o.decimalInteger("AVERAGE-BANDWIDTH")||o.decimalInteger("BANDWIDTH"),name:o.NAME,url:e.resolve(n[2],r)},c=o.decimalResolution("RESOLUTION");c&&(u.width=c.width,u.height=c.height),m((o.CODECS||"").split(/[ ,]+/).filter((function(e){return e})),u),u.videoCodec&&-1!==u.videoCodec.indexOf("avc1")&&(u.videoCodec=e.convertAVC1ToAVCOTI(u.videoCodec)),i.push(u)}else if(n[3]){var f=new l.AttrList(n[3]);f["DATA-ID"]&&(s=!0,a[f["DATA-ID"]]=f)}return{levels:i,sessionData:s?a:null}},e.parseMasterPlaylistMedia=function(t,r,n,i){var a;void 0===i&&(i=[]);var s=[],o=0;for(f.lastIndex=0;null!==(a=f.exec(t));){var u=new l.AttrList(a[1]);if(u.TYPE===n){var c={attrs:u,bitrate:0,id:o++,groupId:u["GROUP-ID"],instreamId:u["INSTREAM-ID"],name:u.NAME||u.LANGUAGE||"",type:n,default:u.bool("DEFAULT"),autoselect:u.bool("AUTOSELECT"),forced:u.bool("FORCED"),lang:u.LANGUAGE,url:u.URI?e.resolve(u.URI,r):""};if(i.length){var d=e.findGroup(i,c.groupId)||i[0];y(c,d,"audioCodec"),y(c,d,"textCodec")}s.push(c)}}return s},e.parseLevelPlaylist=function(e,t,r,c,d){var f,v,m,y=new s.LevelDetails(t),E=y.fragments,T=null,S=0,k=0,A=0,x=0,L=null,D=new a.Fragment(c,t),O=-1,C=!1;for(h.lastIndex=0,y.m3u8=e;null!==(f=h.exec(e));){C&&(C=!1,(D=new a.Fragment(c,t)).start=A,D.sn=S,D.cc=x,D.level=r,T&&(D.initSegment=T,D.rawProgramDateTime=T.rawProgramDateTime));var _=f[1];if(_){D.duration=parseFloat(_);var w=(" "+f[2]).slice(1);D.title=w||null,D.tagList.push(w?["INF",_,w]:["INF",_])}else if(f[3])Object(n.isFiniteNumber)(D.duration)&&(D.start=A,m&&(D.levelkey=m),D.sn=S,D.level=r,D.cc=x,D.urlId=d,E.push(D),D.relurl=(" "+f[3]).slice(1),b(D,L),L=D,A+=D.duration,S++,k=0,C=!0);else if(f[4]){var R=(" "+f[4]).slice(1);L?D.setByteRange(R,L):D.setByteRange(R)}else if(f[5])D.rawProgramDateTime=(" "+f[5]).slice(1),D.tagList.push(["PROGRAM-DATE-TIME",D.rawProgramDateTime]),-1===O&&(O=E.length);else{if(!(f=f[0].match(g))){u.logger.warn("No matches on slow regex match for level playlist!");continue}for(v=1;v<f.length&&void 0===f[v];v++);var I=(" "+f[v]).slice(1),P=(" "+f[v+1]).slice(1),N=f[v+2]?(" "+f[v+2]).slice(1):"";switch(I){case"PLAYLIST-TYPE":y.type=P.toUpperCase();break;case"MEDIA-SEQUENCE":S=y.startSN=parseInt(P);break;case"SKIP":var M=new l.AttrList(P),F=M.decimalInteger("SKIPPED-SEGMENTS");if(Object(n.isFiniteNumber)(F)){y.skippedSegments=F;for(var j=F;j--;)E.unshift(null);S+=F}var B=M.enumeratedString("RECENTLY-REMOVED-DATERANGES");B&&(y.recentlyRemovedDateranges=B.split("\t"));break;case"TARGETDURATION":y.targetduration=parseFloat(P);break;case"VERSION":y.version=parseInt(P);break;case"EXTM3U":break;case"ENDLIST":y.live=!1;break;case"#":(P||N)&&D.tagList.push(N?[P,N]:[P]);break;case"DIS":x++;case"GAP":D.tagList.push([I]);break;case"BITRATE":D.tagList.push([I,P]);break;case"DISCONTINUITY-SEQ":x=parseInt(P);break;case"KEY":var U,K=new l.AttrList(P),G=K.enumeratedString("METHOD"),H=K.URI,V=K.hexadecimalInteger("IV"),z=K.enumeratedString("KEYFORMATVERSIONS"),W=K.enumeratedString("KEYID"),q=null!=(U=K.enumeratedString("KEYFORMAT"))?U:"identity";if(["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"].indexOf(q)>-1){u.logger.warn("Keyformat "+q+" is not supported from the manifest");continue}if("identity"!==q)continue;G&&(m=o.LevelKey.fromURL(t,H),H&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(G)>=0&&(m.method=G,m.keyFormat=q,W&&(m.keyID=W),z&&(m.keyFormatVersions=z),m.iv=V));break;case"START":var Y=new l.AttrList(P).decimalFloatingPoint("TIME-OFFSET");Object(n.isFiniteNumber)(Y)&&(y.startTimeOffset=Y);break;case"MAP":var $=new l.AttrList(P);D.relurl=$.URI,$.BYTERANGE&&D.setByteRange($.BYTERANGE),D.level=r,D.sn="initSegment",m&&(D.levelkey=m),D.initSegment=null,T=D,C=!0;break;case"SERVER-CONTROL":var X=new l.AttrList(P);y.canBlockReload=X.bool("CAN-BLOCK-RELOAD"),y.canSkipUntil=X.optionalFloat("CAN-SKIP-UNTIL",0),y.canSkipDateRanges=y.canSkipUntil>0&&X.bool("CAN-SKIP-DATERANGES"),y.partHoldBack=X.optionalFloat("PART-HOLD-BACK",0),y.holdBack=X.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var Z=new l.AttrList(P);y.partTarget=Z.decimalFloatingPoint("PART-TARGET");break;case"PART":var Q=y.partList;Q||(Q=y.partList=[]);var J=k>0?Q[Q.length-1]:void 0,ee=k++,te=new a.Part(new l.AttrList(P),D,t,ee,J);Q.push(te),D.duration+=te.duration;break;case"PRELOAD-HINT":var re=new l.AttrList(P);y.preloadHint=re;break;case"RENDITION-REPORT":var ne=new l.AttrList(P);y.renditionReports=y.renditionReports||[],y.renditionReports.push(ne);break;default:u.logger.warn("line parsed but not handled: "+f)}}}L&&!L.relurl?(E.pop(),A-=L.duration,y.partList&&(y.fragmentHint=L)):y.partList&&(b(D,L),D.cc=x,y.fragmentHint=D);var ie=E.length,ae=E[0],se=E[ie-1];if((A+=y.skippedSegments*y.targetduration)>0&&ie&&se){y.averagetargetduration=A/ie;var oe=se.sn;y.endSN="initSegment"!==oe?oe:0,ae&&(y.startCC=ae.cc,ae.initSegment||y.fragments.every((function(e){return e.relurl&&(t=e.relurl,p.test(null!=(r=null===(n=i.parseURL(t))||void 0===n?void 0:n.path)?r:""));var t,r,n}))&&(u.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),(D=new a.Fragment(c,t)).relurl=se.relurl,D.level=r,D.sn="initSegment",ae.initSegment=D,y.needSidxRanges=!0))}else y.endSN=0,y.startCC=0;return y.fragmentHint&&(A+=y.fragmentHint.duration),y.totalduration=A,y.endCC=x,O>0&&function(e,t){for(var r=e[t],n=t;n--;){var i=e[n];if(!i)return;i.programDateTime=r.programDateTime-1e3*i.duration,r=i}}(E,O),y},e}();function m(e,t){["video","audio","text"].forEach((function(r){var n=e.filter((function(e){return Object(c.isCodecType)(e,r)}));if(n.length){var i=n.filter((function(e){return 0===e.lastIndexOf("avc1",0)||0===e.lastIndexOf("mp4a",0)}));t[r+"Codec"]=i.length>0?i[0]:n[0],e=e.filter((function(e){return-1===n.indexOf(e)}))}})),t.unknownCodecs=e}function y(e,t,r){var n=t[r];n&&(e[r]=n)}function b(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),Object(n.isFiniteNumber)(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":
|
|
|
/*!***************************************!*\
|
|
|
!*** ./src/loader/playlist-loader.ts ***!
|
|
|
\***************************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t);var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ../events */"./src/events.ts"),a=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),l=r(/*! ./m3u8-parser */"./src/loader/m3u8-parser.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),c=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts");function d(e,t){var r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}var f=function(){function e(e){this.hls=void 0,this.loaders=Object.create(null),this.hls=e,this.registerListeners()}var t=e.prototype;return t.registerListeners=function(){var e=this.hls;e.on(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(i.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(i.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(i.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.unregisterListeners=function(){var e=this.hls;e.off(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(i.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(i.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(i.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,n=t.loader,i=new(r||n)(t);return e.loader=i,this.loaders[e.type]=i,i},t.getInternalLoader=function(e){return this.loaders[e.type]},t.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},t.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},t.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},t.onManifestLoading=function(e,t){var r=t.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:u.PlaylistContextType.MANIFEST,url:r,deliveryDirectives:null})},t.onLevelLoading=function(e,t){var r=t.id,n=t.level,i=t.url,a=t.deliveryDirectives;this.load({id:r,groupId:null,level:n,responseType:"text",type:u.PlaylistContextType.LEVEL,url:i,deliveryDirectives:a})},t.onAudioTrackLoading=function(e,t){var r=t.id,n=t.groupId,i=t.url,a=t.deliveryDirectives;this.load({id:r,groupId:n,level:null,responseType:"text",type:u.PlaylistContextType.AUDIO_TRACK,url:i,deliveryDirectives:a})},t.onSubtitleTrackLoading=function(e,t){var r=t.id,n=t.groupId,i=t.url,a=t.deliveryDirectives;this.load({id:r,groupId:n,level:null,responseType:"text",type:u.PlaylistContextType.SUBTITLE_TRACK,url:i,deliveryDirectives:a})},t.load=function(e){var t,r,n,i,a,o,l=this.hls.config,c=this.getInternalLoader(e);if(c){var d=c.context;if(d&&d.url===e.url)return void s.logger.trace("[playlist-loader]: playlist request ongoing");s.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),c.abort()}switch(e.type){case u.PlaylistContextType.MANIFEST:r=l.manifestLoadingMaxRetry,n=l.manifestLoadingTimeOut,i=l.manifestLoadingRetryDelay,a=l.manifestLoadingMaxRetryTimeout;break;case u.PlaylistContextType.LEVEL:case u.PlaylistContextType.AUDIO_TRACK:case u.PlaylistContextType.SUBTITLE_TRACK:r=0,n=l.levelLoadingTimeOut;break;default:r=l.levelLoadingMaxRetry,n=l.levelLoadingTimeOut,i=l.levelLoadingRetryDelay,a=l.levelLoadingMaxRetryTimeout}if(c=this.createInternalLoader(e),null!==(t=e.deliveryDirectives)&&void 0!==t&&t.part&&(e.type===u.PlaylistContextType.LEVEL&&null!==e.level?o=this.hls.levels[e.level].details:e.type===u.PlaylistContextType.AUDIO_TRACK&&null!==e.id?o=this.hls.audioTracks[e.id].details:e.type===u.PlaylistContextType.SUBTITLE_TRACK&&null!==e.id&&(o=this.hls.subtitleTracks[e.id].details),o)){var f=o.partTarget,h=o.targetduration;f&&h&&(n=Math.min(1e3*Math.max(3*f,.8*h),n))}var g={timeout:n,maxRetry:r,retryDelay:i,maxRetryDelay:a,highWaterMark:0},p={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};c.load(e,g,p)},t.loadsuccess=function(e,t,r,n){if(void 0===n&&(n=null),r.isSidxRequest)return this.handleSidxRequest(e,r),void this.handlePlaylistLoaded(e,t,r,n);this.resetInternalLoader(r.type);var i=e.data;0===i.indexOf("#EXTM3U")?(t.parsing.start=performance.now(),i.indexOf("#EXTINF:")>0||i.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,t,r,n):this.handleMasterPlaylist(e,t,r,n)):this.handleManifestParsingError(e,r,"no EXTM3U delimiter",n)},t.loaderror=function(e,t,r){void 0===r&&(r=null),this.handleNetworkError(t,r,!1,e)},t.loadtimeout=function(e,t,r){void 0===r&&(r=null),this.handleNetworkError(t,r,!0)},t.handleMasterPlaylist=function(e,t,r,n){var a=this.hls,o=e.data,u=d(e,r),f=l.default.parseMasterPlaylist(o,u),h=f.levels,g=f.sessionData;if(h.length){var p=h.map((function(e){return{id:e.attrs.AUDIO,audioCodec:e.audioCodec}})),v=h.map((function(e){return{id:e.attrs.SUBTITLES,textCodec:e.textCodec}})),m=l.default.parseMasterPlaylistMedia(o,u,"AUDIO",p),y=l.default.parseMasterPlaylistMedia(o,u,"SUBTITLES",v),b=l.default.parseMasterPlaylistMedia(o,u,"CLOSED-CAPTIONS");m.length&&(m.some((function(e){return!e.url}))||!h[0].audioCodec||h[0].attrs.AUDIO||(s.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),m.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new c.AttrList({}),bitrate:0,url:""}))),a.trigger(i.Events.MANIFEST_LOADED,{levels:h,audioTracks:m,subtitles:y,captions:b,url:u,stats:t,networkDetails:n,sessionData:g})}else this.handleManifestParsingError(e,r,"no level found in manifest",n)},t.handleTrackOrLevelPlaylist=function(e,t,r,s){var o=this.hls,f=r.id,h=r.level,g=r.type,p=d(e,r),v=Object(n.isFiniteNumber)(f)?f:0,m=Object(n.isFiniteNumber)(h)?h:v,y=function(e){switch(e.type){case u.PlaylistContextType.AUDIO_TRACK:return u.PlaylistLevelType.AUDIO;case u.PlaylistContextType.SUBTITLE_TRACK:return u.PlaylistLevelType.SUBTITLE;default:return u.PlaylistLevelType.MAIN}}(r),b=l.default.parseLevelPlaylist(e.data,p,m,y,v);if(b.fragments.length){if(g===u.PlaylistContextType.MANIFEST){var E={attrs:new c.AttrList({}),bitrate:0,details:b,name:"",url:p};o.trigger(i.Events.MANIFEST_LOADED,{levels:[E],audioTracks:[],url:p,stats:t,networkDetails:s,sessionData:null})}if(t.parsing.end=performance.now(),b.needSidxRanges){var T,S=null===(T=b.fragments[0].initSegment)||void 0===T?void 0:T.url;this.load({url:S,isSidxRequest:!0,type:g,level:h,levelDetails:b,id:f,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null})}else r.levelDetails=b,this.handlePlaylistLoaded(e,t,r,s)}else o.trigger(i.Events.ERROR,{type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:p,reason:"no fragments found in level",level:"number"==typeof r.level?r.level:void 0})},t.handleSidxRequest=function(e,t){var r=Object(o.parseSegmentIndex)(new Uint8Array(e.data));if(r){var n=r.references,i=t.levelDetails;n.forEach((function(e,t){var n=e.info,a=i.fragments[t];0===a.byteRange.length&&a.setByteRange(String(1+n.end-n.start)+"@"+String(n.start)),a.initSegment&&a.initSegment.setByteRange(String(r.moovEndOffset)+"@0")}))}},t.handleManifestParsingError=function(e,t,r,n){this.hls.trigger(i.Events.ERROR,{type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:t.type===u.PlaylistContextType.MANIFEST,url:e.url,reason:r,response:e,context:t,networkDetails:n})},t.handleNetworkError=function(e,t,r,n){void 0===r&&(r=!1),s.logger.warn("[playlist-loader]: A network "+(r?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var o=a.ErrorDetails.UNKNOWN,l=!1,c=this.getInternalLoader(e);switch(e.type){case u.PlaylistContextType.MANIFEST:o=r?a.ErrorDetails.MANIFEST_LOAD_TIMEOUT:a.ErrorDetails.MANIFEST_LOAD_ERROR,l=!0;break;case u.PlaylistContextType.LEVEL:o=r?a.ErrorDetails.LEVEL_LOAD_TIMEOUT:a.ErrorDetails.LEVEL_LOAD_ERROR,l=!1;break;case u.PlaylistContextType.AUDIO_TRACK:o=r?a.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:a.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case u.PlaylistContextType.SUBTITLE_TRACK:o=r?a.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:a.ErrorDetails.SUBTITLE_LOAD_ERROR,l=!1}c&&this.resetInternalLoader(e.type);var d={type:a.ErrorTypes.NETWORK_ERROR,details:o,fatal:l,url:e.url,loader:c,context:e,networkDetails:t};n&&(d.response=n),this.hls.trigger(i.Events.ERROR,d)},t.handlePlaylistLoaded=function(e,t,r,n){var a=r.type,s=r.level,o=r.id,l=r.groupId,c=r.loader,d=r.levelDetails,f=r.deliveryDirectives;if(null!=d&&d.targetduration){if(c)switch(d.live&&(c.getCacheAge&&(d.ageHeader=c.getCacheAge()||0),c.getCacheAge&&!isNaN(d.ageHeader)||(d.ageHeader=0)),a){case u.PlaylistContextType.MANIFEST:case u.PlaylistContextType.LEVEL:this.hls.trigger(i.Events.LEVEL_LOADED,{details:d,level:s||0,id:o||0,stats:t,networkDetails:n,deliveryDirectives:f});break;case u.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(i.Events.AUDIO_TRACK_LOADED,{details:d,id:o||0,groupId:l||"",stats:t,networkDetails:n,deliveryDirectives:f});break;case u.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(i.Events.SUBTITLE_TRACK_LOADED,{details:d,id:o||0,groupId:l||"",stats:t,networkDetails:n,deliveryDirectives:f})}}else this.handleManifestParsingError(e,r,"invalid target duration",n)},e}();t.default=f},"./src/polyfills/number.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/polyfills/number.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: isFiniteNumber, MAX_SAFE_INTEGER */function(e,t,r){"use strict";r.r(t),r.d(t,"isFiniteNumber",(function(){return n})),r.d(t,"MAX_SAFE_INTEGER",(function(){return i}));var n=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},i=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/remux/aac-helper.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t);var n=function(){function e(){}return e.getSilentFrame=function(e,t){switch(e){case"mp4a.40.2":if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}},e}();t.default=n},"./src/remux/mp4-generator.ts":
|
|
|
/*!************************************!*\
|
|
|
!*** ./src/remux/mp4-generator.ts ***!
|
|
|
\************************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t);var n=Math.pow(2,32)-1,i=function(){function e(){}return e.init=function(){var t;for(t in e.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var r=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),n=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);e.HDLR_TYPES={video:r,audio:n};var i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),a=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=a,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var s=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,s,l,s,o),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,i))},e.box=function(e){for(var t=8,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];for(var a=n.length,s=a;a--;)t+=n[a].byteLength;var o=new Uint8Array(t);for(o[0]=t>>24&255,o[1]=t>>16&255,o[2]=t>>8&255,o[3]=255&t,o.set(e,4),a=0,t=8;a<s;a++)o.set(n[a],t),t+=n[a].byteLength;return o},e.hdlr=function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])},e.mdat=function(t){return e.box(e.types.mdat,t)},e.mdhd=function(t,r){r*=t;var i=Math.floor(r/(n+1)),a=Math.floor(r%(n+1));return e.box(e.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))},e.mfhd=function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))},e.minf=function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))},e.moof=function(t,r,n){return e.box(e.types.moof,e.mfhd(t),e.traf(n,r))},e.moov=function(t){for(var r=t.length,n=[];r--;)n[r]=e.trak(t[r]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(n).concat(e.mvex(t)))},e.mvex=function(t){for(var r=t.length,n=[];r--;)n[r]=e.trex(t[r]);return e.box.apply(null,[e.types.mvex].concat(n))},e.mvhd=function(t,r){r*=t;var i=Math.floor(r/(n+1)),a=Math.floor(r%(n+1)),s=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return e.box(e.types.mvhd,s)},e.sdtp=function(t){var r,n,i=t.samples||[],a=new Uint8Array(4+i.length);for(r=0;r<i.length;r++)n=i[r].flags,a[r+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return e.box(e.types.sdtp,a)},e.stbl=function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))},e.avc1=function(t){var r,n,i,a=[],s=[];for(r=0;r<t.sps.length;r++)i=(n=t.sps[r]).byteLength,a.push(i>>>8&255),a.push(255&i),a=a.concat(Array.prototype.slice.call(n));for(r=0;r<t.pps.length;r++)i=(n=t.pps[r]).byteLength,s.push(i>>>8&255),s.push(255&i),s=s.concat(Array.prototype.slice.call(n));var o=e.box(e.types.avcC,new Uint8Array([1,a[3],a[4],a[5],255,224|t.sps.length].concat(a).concat([t.pps.length]).concat(s))),l=t.width,u=t.height,c=t.pixelRatio[0],d=t.pixelRatio[1];return e.box(e.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,d>>24,d>>16&255,d>>8&255,255&d])))},e.esds=function(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))},e.mp4a=function(t){var r=t.samplerate;return e.box(e.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]),e.box(e.types.esds,e.esds(t)))},e.mp3=function(t){var r=t.samplerate;return e.box(e.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]))},e.stsd=function(t){return"audio"===t.type?t.isAAC||"mp3"!==t.codec?e.box(e.types.stsd,e.STSD,e.mp4a(t)):e.box(e.types.stsd,e.STSD,e.mp3(t)):e.box(e.types.stsd,e.STSD,e.avc1(t))},e.tkhd=function(t){var r=t.id,i=t.duration*t.timescale,a=t.width,s=t.height,o=Math.floor(i/(n+1)),l=Math.floor(i%(n+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,l>>24,l>>16&255,l>>8&255,255&l,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,a>>8&255,255&a,0,0,s>>8&255,255&s,0,0]))},e.traf=function(t,r){var i=e.sdtp(t),a=t.id,s=Math.floor(r/(n+1)),o=Math.floor(r%(n+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,o>>24,o>>16&255,o>>8&255,255&o])),e.trun(t,i.length+16+20+8+16+8+8),i)},e.trak=function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.trex=function(t){var r=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},e.trun=function(t,r){var n,i,a,s,o,l,u=t.samples||[],c=u.length,d=12+16*c,f=new Uint8Array(d);for(r+=8+d,f.set([0,0,15,1,c>>>24&255,c>>>16&255,c>>>8&255,255&c,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),n=0;n<c;n++)a=(i=u[n]).duration,s=i.size,o=i.flags,l=i.cts,f.set([a>>>24&255,a>>>16&255,a>>>8&255,255&a,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*n);return e.box(e.types.trun,f)},e.initSegment=function(t){e.types||e.init();var r=e.moov(t),n=new Uint8Array(e.FTYP.byteLength+r.byteLength);return n.set(e.FTYP),n.set(r,e.FTYP.byteLength),n},e}();i.types=void 0,i.HDLR_TYPES=void 0,i.STTS=void 0,i.STSC=void 0,i.STCO=void 0,i.STSZ=void 0,i.VMHD=void 0,i.SMHD=void 0,i.STSD=void 0,i.FTYP=void 0,i.DINF=void 0,t.default=i},"./src/remux/mp4-remuxer.ts":
|
|
|
/*!**********************************!*\
|
|
|
!*** ./src/remux/mp4-remuxer.ts ***!
|
|
|
\**********************************/
|
|
|
/*! exports provided: default, normalizePts */function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return p})),r.d(t,"normalizePts",(function(){return v}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ./aac-helper */"./src/remux/aac-helper.ts"),a=r(/*! ./mp4-generator */"./src/remux/mp4-generator.ts"),s=r(/*! ../events */"./src/events.ts"),o=r(/*! ../errors */"./src/errors.ts"),l=r(/*! ../utils/logger */"./src/utils/logger.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),c=r(/*! ../utils/timescale-conversion */"./src/utils/timescale-conversion.ts");function d(){return(d=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var f=null,h=null,g=!1,p=function(){function e(e,t,r,n){if(void 0===n&&(n=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,null===f){var i=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);f=i?parseInt(i[1]):0}if(null===h){var a=navigator.userAgent.match(/Safari\/(\d+)/i);h=a?parseInt(a[1]):0}g=!!f&&f<75||!!h&&h<600}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(e){l.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},t.resetNextTimestamp=function(){l.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},t.resetInitSegment=function(){l.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},t.getVideoStartPts=function(e){var t=!1,r=e.reduce((function(e,r){var n=r.pts-e;return n<-4294967296?(t=!0,v(e,r.pts)):n>0?e:r.pts}),e[0].pts);return t&&l.logger.debug("PTS rollover detected"),r},t.remux=function(e,t,r,n,i,a,s,o){var c,d,f,h,g,p,m=i,y=i,b=e.pid>-1,E=t.pid>-1,T=t.samples.length,S=e.samples.length>0,k=T>1;if((!b||S)&&(!E||k)||this.ISGenerated||s){this.ISGenerated||(f=this.generateIS(e,t,i));var A=this.isVideoContiguous,x=-1;if(k&&(x=function(e){for(var t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!A&&this.config.forceKeyFrameOnDiscontinuity))if(p=!0,x>0){l.logger.warn("[mp4-remuxer]: Dropped "+x+" out of "+T+" video samples due to a missing keyframe");var L=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(x),t.dropped+=x,y+=(t.samples[0].pts-L)/(t.timescale||9e4)}else-1===x&&(l.logger.warn("[mp4-remuxer]: No keyframe found out of "+T+" video samples"),p=!1);if(this.ISGenerated){if(S&&k){var D=this.getVideoStartPts(t.samples),O=(v(e.samples[0].pts,D)-D)/t.inputTimeScale;m+=Math.max(0,O),y+=Math.max(0,-O)}if(S){if(e.samplerate||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),f=this.generateIS(e,t,i)),d=this.remuxAudio(e,m,this.isAudioContiguous,a,E||k||o===u.PlaylistLevelType.AUDIO?y:void 0),k){var C=d?d.endPTS-d.startPTS:0;t.inputTimeScale||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),f=this.generateIS(e,t,i)),c=this.remuxVideo(t,y,A,C)}}else k&&(c=this.remuxVideo(t,y,A,0));c&&(c.firstKeyFrame=x,c.independent=-1!==x)}}return this.ISGenerated&&(r.samples.length&&(g=this.remuxID3(r,i)),n.samples.length&&(h=this.remuxText(n,i))),{audio:d,video:c,initSegment:f,independent:p,text:h,id3:g}},t.generateIS=function(e,t,r){var i,s,o,l=e.samples,u=t.samples,c=this.typeSupported,d={},f=!Object(n.isFiniteNumber)(this._initPTS),h="audio/mp4";if(f&&(i=s=1/0),e.config&&l.length&&(e.timescale=e.samplerate,e.isAAC||(c.mpeg?(h="audio/mpeg",e.codec=""):c.mp3&&(e.codec="mp3")),d.audio={id:"audio",container:h,codec:e.codec,initSegment:!e.isAAC&&c.mpeg?new Uint8Array(0):a.default.initSegment([e]),metadata:{channelCount:e.channelCount}},f&&(o=e.inputTimeScale,i=s=l[0].pts-Math.round(o*r))),t.sps&&t.pps&&u.length&&(t.timescale=t.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:a.default.initSegment([t]),metadata:{width:t.width,height:t.height}},f)){o=t.inputTimeScale;var g=this.getVideoStartPts(u),p=Math.round(o*r);s=Math.min(s,v(u[0].dts,g)-p),i=Math.min(i,g-p)}if(Object.keys(d).length)return this.ISGenerated=!0,f&&(this._initPTS=i,this._initDTS=s),{tracks:d,initPTS:i,timescale:o}},t.remuxVideo=function(e,t,r,n){var i,u,h,p=e.inputTimeScale,y=e.samples,b=[],E=y.length,T=this._initPTS,S=this.nextAvcDts,k=8,A=Number.POSITIVE_INFINITY,x=Number.NEGATIVE_INFINITY,L=0,D=!1;r&&null!==S||(S=t*p-(y[0].pts-v(y[0].dts,y[0].pts)));for(var O=0;O<E;O++){var C=y[O];C.pts=v(C.pts-T,S),C.dts=v(C.dts-T,S),C.dts>C.pts&&(L=Math.max(Math.min(L,C.pts-C.dts),-18e3)),C.dts<y[O>0?O-1:O].dts&&(D=!0)}D&&y.sort((function(e,t){var r=e.dts-t.dts,n=e.pts-t.pts;return r||n})),u=y[0].dts,h=y[y.length-1].dts;var _=Math.round((h-u)/(E-1));if(L<0){if(L<-2*_){l.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(c.toMsFromMpegTsClock)(-_,!0)+" ms");for(var w=L,R=0;R<E;R++)y[R].dts=w=Math.max(w,y[R].pts-_),y[R].pts=Math.max(w,y[R].pts)}else{l.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(c.toMsFromMpegTsClock)(L,!0)+" ms to overcome this issue");for(var I=0;I<E;I++)y[I].dts=y[I].dts+L}u=y[0].dts}if(r){var P=u-S,N=P>_;if(N||P<-1){N?l.logger.warn("AVC: "+Object(c.toMsFromMpegTsClock)(P,!0)+" ms ("+P+"dts) hole between fragments detected, filling it"):l.logger.warn("AVC: "+Object(c.toMsFromMpegTsClock)(-P,!0)+" ms ("+P+"dts) overlapping between fragments detected"),u=S;var M=y[0].pts-P;y[0].dts=u,y[0].pts=M,l.logger.log("Video: First PTS/DTS adjusted: "+Object(c.toMsFromMpegTsClock)(M,!0)+"/"+Object(c.toMsFromMpegTsClock)(u,!0)+", delta: "+Object(c.toMsFromMpegTsClock)(P,!0)+" ms")}}g&&(u=Math.max(0,u));for(var F=0,j=0,B=0;B<E;B++){for(var U=y[B],K=U.units,G=K.length,H=0,V=0;V<G;V++)H+=K[V].data.length;j+=H,F+=G,U.length=H,U.dts=Math.max(U.dts,u),U.pts=Math.max(U.pts,U.dts,0),A=Math.min(U.pts,A),x=Math.max(U.pts,x)}h=y[E-1].dts;var z,W=j+4*F+8;try{z=new Uint8Array(W)}catch(e){return void this.observer.emit(s.Events.ERROR,s.Events.ERROR,{type:o.ErrorTypes.MUX_ERROR,details:o.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:W,reason:"fail allocating video mdat "+W})}var q=new DataView(z.buffer);q.setUint32(0,W),z.set(a.default.types.mdat,4);for(var Y=0;Y<E;Y++){for(var $=y[Y],X=$.units,Z=0,Q=0,J=X.length;Q<J;Q++){var ee=X[Q],te=ee.data,re=ee.data.byteLength;q.setUint32(k,re),k+=4,z.set(te,k),k+=re,Z+=4+re}if(Y<E-1)i=y[Y+1].dts-$.dts;else{var ne=this.config,ie=$.dts-y[Y>0?Y-1:Y].dts;if(ne.stretchShortVideoTrack&&null!==this.nextAudioPts){var ae=Math.floor(ne.maxBufferHole*p),se=(n?A+n*p:this.nextAudioPts)-$.pts;se>ae?((i=se-ie)<0&&(i=ie),l.logger.log("[mp4-remuxer]: It is approximately "+se/90+" ms to the next segment; using duration "+i/90+" ms for the last video frame.")):i=ie}else i=ie}var oe=Math.round($.pts-$.dts);b.push(new m($.key,i,Z,oe))}if(b.length&&f&&f<70){var le=b[0].flags;le.dependsOn=2,le.isNonSync=0}console.assert(void 0!==i,"mp4SampleDuration must be computed"),this.nextAvcDts=S=h+i,this.isVideoContiguous=!0;var ue={data1:a.default.moof(e.sequenceNumber++,u,d({},e,{samples:b})),data2:z,startPTS:A/p,endPTS:(x+i)/p,startDTS:u/p,endDTS:S/p,type:"video",hasAudio:!1,hasVideo:!0,nb:b.length,dropped:e.dropped};return e.samples=[],e.dropped=0,console.assert(z.length,"MDAT length must not be zero"),ue},t.remuxAudio=function(e,t,r,n,u){var c=e.inputTimeScale,f=c/(e.samplerate?e.samplerate:c),h=e.isAAC?1024:1152,g=h*f,p=this._initPTS,y=!e.isAAC&&this.typeSupported.mpeg,b=[],E=e.samples,T=y?0:8,S=this.nextAudioPts||-1,k=t*c;if(this.isAudioContiguous=r=r||E.length&&S>0&&(n&&Math.abs(k-S)<9e3||Math.abs(v(E[0].pts-p,k)-S)<20*g),E.forEach((function(e){e.pts=v(e.pts-p,k)})),!r||S<0){if(!(E=E.filter((function(e){return e.pts>=0}))).length)return;S=0===u?0:n?Math.max(0,k):E[0].pts}if(e.isAAC)for(var A=void 0!==u,x=this.config.maxAudioFramesDrift,L=0,D=S;L<E.length;L++){var O=E[L],C=O.pts,_=C-D,w=Math.abs(1e3*_/c);if(_<=-x*g&&A)0===L&&(l.logger.warn("Audio frame @ "+(C/c).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*_/c)+" ms."),this.nextAudioPts=S=D=C);else if(_>=x*g&&w<1e4&&A){var R=Math.round(_/g);(D=C-R*g)<0&&(R--,D+=g),0===L&&(this.nextAudioPts=S=D),l.logger.warn("[mp4-remuxer]: Injecting "+R+" audio frame @ "+(D/c).toFixed(3)+"s due to "+Math.round(1e3*_/c)+" ms gap.");for(var I=0;I<R;I++){var P=Math.max(D,0),N=i.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);N||(l.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),N=O.unit.subarray()),E.splice(L,0,{unit:N,pts:P}),D+=g,L++}}O.pts=D,D+=g}for(var M,F=null,j=null,B=0,U=E.length;U--;)B+=E[U].unit.byteLength;for(var K=0,G=E.length;K<G;K++){var H=E[K],V=H.unit,z=H.pts;if(null!==j)b[K-1].duration=Math.round((z-j)/f);else{if(r&&e.isAAC&&(z=S),F=z,!(B>0))return;B+=T;try{M=new Uint8Array(B)}catch(e){return void this.observer.emit(s.Events.ERROR,s.Events.ERROR,{type:o.ErrorTypes.MUX_ERROR,details:o.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:B,reason:"fail allocating audio mdat "+B})}y||(new DataView(M.buffer).setUint32(0,B),M.set(a.default.types.mdat,4))}M.set(V,T);var W=V.byteLength;T+=W,b.push(new m(!0,h,W,0)),j=z}var q=b.length;if(q){var Y=b[b.length-1];this.nextAudioPts=S=j+f*Y.duration;var $=y?new Uint8Array(0):a.default.moof(e.sequenceNumber++,F/f,d({},e,{samples:b}));e.samples=[];var X=F/c,Z=S/c,Q={data1:$,data2:M,startPTS:X,endPTS:Z,startDTS:X,endDTS:Z,type:"audio",hasAudio:!0,hasVideo:!1,nb:q};return this.isAudioContiguous=!0,console.assert(M.length,"MDAT length must not be zero"),Q}},t.remuxEmptyAudio=function(e,t,r,n){var a=e.inputTimeScale,s=a/(e.samplerate?e.samplerate:a),o=this.nextAudioPts,u=(null!==o?o:n.startDTS*a)+this._initDTS,c=n.endDTS*a+this._initDTS,d=1024*s,f=Math.ceil((c-u)/d),h=i.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(l.logger.warn("[mp4-remuxer]: remux empty Audio"),h){for(var g=[],p=0;p<f;p++){var v=u+p*d;g.push({unit:h,pts:v,dts:v})}return e.samples=g,this.remuxAudio(e,t,r,!1)}l.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},t.remuxID3=function(e,t){var r=e.samples.length;if(r){for(var n=e.inputTimeScale,i=this._initPTS,a=this._initDTS,s=0;s<r;s++){var o=e.samples[s];o.pts=v(o.pts-i,t*n)/n,o.dts=v(o.dts-a,t*n)/n}var l=e.samples;return e.samples=[],{samples:l}}},t.remuxText=function(e,t){var r=e.samples.length;if(r){for(var n=e.inputTimeScale,i=this._initPTS,a=0;a<r;a++){var s=e.samples[a];s.pts=v(s.pts-i,t*n)/n}e.samples.sort((function(e,t){return e.pts-t.pts}));var o=e.samples;return e.samples=[],{samples:o}}},e}();function v(e,t){var r;if(null===t)return e;for(r=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=r;return e}var m=function(e,t,r,n){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=n,this.flags=new y(e)},y=function(e){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=e?2:1,this.isNonSync=e?0:1}},"./src/remux/passthrough-remuxer.ts":
|
|
|
/*!******************************************!*\
|
|
|
!*** ./src/remux/passthrough-remuxer.ts ***!
|
|
|
\******************************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t);var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),a=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=function(){function e(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndDTS=null}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(e){this.initPTS=e,this.lastEndDTS=null},t.resetNextTimestamp=function(){this.lastEndDTS=null},t.resetInitSegment=function(e,t,r){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(e),this.emitInitSegment=!0},t.generateInitSegment=function(e){var t=this.audioCodec,r=this.videoCodec;if(!e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var n=this.initData=Object(i.parseInitSegment)(e);t||(t=u(n.audio,a.ElementaryStreamTypes.AUDIO)),r||(r=u(n.video,a.ElementaryStreamTypes.VIDEO));var o={};n.audio&&n.video?o.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:n.audio?o.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:n.video?o.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:s.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},t.remux=function(e,t,r,a,o){var u=this.initPTS,c=this.lastEndDTS,d={audio:void 0,video:void 0,text:a,id3:r,initSegment:void 0};Object(n.isFiniteNumber)(c)||(c=this.lastEndDTS=o||0);var f=t.samples;if(!f||!f.length)return d;var h={initPTS:void 0,timescale:1},g=this.initData;if(g&&g.length||(this.generateInitSegment(f),g=this.initData),!g||!g.length)return s.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),d;this.emitInitSegment&&(h.tracks=this.initTracks,this.emitInitSegment=!1),Object(n.isFiniteNumber)(u)||(this.initPTS=h.initPTS=u=l(g,f,c));var p=Object(i.getDuration)(f,g),v=c,m=p+v;Object(i.offsetStartDTS)(g,f,u),p>0?this.lastEndDTS=m:(s.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var y=!!g.audio,b=!!g.video,E="";y&&(E+="audio"),b&&(E+="video");var T={data1:f,startPTS:v,startDTS:v,endPTS:m,endDTS:m,type:E,hasAudio:y,hasVideo:b,nb:1,dropped:0};return d.audio="audio"===T.type?T:void 0,d.video="audio"!==T.type?T:void 0,d.text=a,d.id3=r,d.initSegment=h,d},e}(),l=function(e,t,r){return Object(i.getStartDTS)(e,t)-r};function u(e,t){var r=null==e?void 0:e.codec;return r&&r.length>4?r:"hvc1"===r?"hvc1.1.c.L120.90":"av01"===r?"av01.0.04M.08":"avc1"===r||t===a.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}t.default=o},"./src/task-loop.ts":
|
|
|
/*!**************************!*\
|
|
|
!*** ./src/task-loop.ts ***!
|
|
|
\**************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return n}));var n=function(){function e(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var t=e.prototype;return t.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},t.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},t.onHandlerDestroyed=function(){},t.hasInterval=function(){return!!this._tickInterval},t.hasNextTick=function(){return!!this._tickTimer},t.setInterval=function(e){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,e),!0)},t.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},t.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},t.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},t.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},t.doTick=function(){},e}()},"./src/types/cmcd.ts":
|
|
|
/*!***************************!*\
|
|
|
!*** ./src/types/cmcd.ts ***!
|
|
|
\***************************/
|
|
|
/*! exports provided: CMCDVersion, CMCDObjectType, CMCDStreamingFormat, CMCDStreamType */function(e,t,r){"use strict";r.r(t),r.d(t,"CMCDVersion",(function(){return s})),r.d(t,"CMCDObjectType",(function(){return n})),r.d(t,"CMCDStreamingFormat",(function(){return i})),r.d(t,"CMCDStreamType",(function(){return a}));var n,i,a,s=1;!function(e){e.MANIFEST="m",e.AUDIO="a",e.VIDEO="v",e.MUXED="av",e.INIT="i",e.CAPTION="c",e.TIMED_TEXT="tt",e.KEY="k",e.OTHER="o"}(n||(n={})),function(e){e.DASH="d",e.HLS="h",e.SMOOTH="s",e.OTHER="o"}(i||(i={})),function(e){e.VOD="v",e.LIVE="l"}(a||(a={}))},"./src/types/level.ts":
|
|
|
/*!****************************!*\
|
|
|
!*** ./src/types/level.ts ***!
|
|
|
\****************************/
|
|
|
/*! exports provided: HlsSkip, getSkipValue, HlsUrlParameters, Level */function(e,t,r){"use strict";function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var i;function a(e,t){var r=e.canSkipUntil,n=e.canSkipDateRanges,a=e.endSN;return r&&(void 0!==t?t-a:0)<r?n?i.v2:i.Yes:i.No}r.r(t),r.d(t,"HlsSkip",(function(){return i})),r.d(t,"getSkipValue",(function(){return a})),r.d(t,"HlsUrlParameters",(function(){return s})),r.d(t,"Level",(function(){return o})),function(e){e.No="",e.Yes="YES",e.v2="v2"}(i||(i={}));var s=function(){function e(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}return e.prototype.addDirectives=function(e){var t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.toString()},e}(),o=function(){function e(e){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[e.url],this.attrs=e.attrs,this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.unknownCodecs=e.unknownCodecs,this.codecSet=[e.videoCodec,e.audioCodec].filter((function(e){return e})).join(",").replace(/\.[^.,]+/g,"")}var t,r,i;return t=e,(r=[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(e){var t=e%this.url.length;this._urlId!==t&&(this.details=void 0,this._urlId=t)}}])&&n(t.prototype,r),i&&n(t,i),e}()},"./src/types/loader.ts":
|
|
|
/*!*****************************!*\
|
|
|
!*** ./src/types/loader.ts ***!
|
|
|
\*****************************/
|
|
|
/*! exports provided: PlaylistContextType, PlaylistLevelType */function(e,t,r){"use strict";var n,i;r.r(t),r.d(t,"PlaylistContextType",(function(){return n})),r.d(t,"PlaylistLevelType",(function(){return i})),function(e){e.MANIFEST="manifest",e.LEVEL="level",e.AUDIO_TRACK="audioTrack",e.SUBTITLE_TRACK="subtitleTrack"}(n||(n={})),function(e){e.MAIN="main",e.AUDIO="audio",e.SUBTITLE="subtitle"}(i||(i={}))},"./src/types/transmuxer.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/types/transmuxer.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: ChunkMetadata */function(e,t,r){"use strict";r.r(t),r.d(t,"ChunkMetadata",(function(){return n}));var n=function(e,t,r,n,i,a){void 0===n&&(n=0),void 0===i&&(i=-1),void 0===a&&(a=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=e,this.sn=t,this.id=r,this.size=n,this.part=i,this.partial=a}},"./src/utils/attr-list.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/utils/attr-list.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: AttrList */function(e,t,r){"use strict";r.r(t),r.d(t,"AttrList",(function(){return a}));var n=/^(\d+)x(\d+)$/,i=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,a=function(){function e(t){for(var r in"string"==typeof t&&(t=e.parseAttrList(t)),t)t.hasOwnProperty(r)&&(this[r]=t[r])}var t=e.prototype;return t.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var r=new Uint8Array(t.length/2),n=0;n<t.length/2;n++)r[n]=parseInt(t.slice(2*n,2*n+2),16);return r}return null},t.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.decimalFloatingPoint=function(e){return parseFloat(this[e])},t.optionalFloat=function(e,t){var r=this[e];return r?parseFloat(r):t},t.enumeratedString=function(e){return this[e]},t.bool=function(e){return"YES"===this[e]},t.decimalResolution=function(e){var t=n.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},e.parseAttrList=function(e){var t,r={};for(i.lastIndex=0;null!==(t=i.exec(e));){var n=t[2];0===n.indexOf('"')&&n.lastIndexOf('"')===n.length-1&&(n=n.slice(1,-1)),r[t[1]]=n}return r},e}()},"./src/utils/binary-search.ts":
|
|
|
/*!************************************!*\
|
|
|
!*** ./src/utils/binary-search.ts ***!
|
|
|
\************************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t),t.default={search:function(e,t){for(var r=0,n=e.length-1,i=null,a=null;r<=n;){var s=t(a=e[i=(r+n)/2|0]);if(s>0)r=i+1;else{if(!(s<0))return a;n=i-1}}return null}}},"./src/utils/buffer-helper.ts":
|
|
|
/*!************************************!*\
|
|
|
!*** ./src/utils/buffer-helper.ts ***!
|
|
|
\************************************/
|
|
|
/*! exports provided: BufferHelper */function(e,t,r){"use strict";r.r(t),r.d(t,"BufferHelper",(function(){return a}));var n=r(/*! ./logger */"./src/utils/logger.ts"),i={length:0,start:function(){return 0},end:function(){return 0}},a=function(){function e(){}return e.isBuffered=function(t,r){try{if(t)for(var n=e.getBuffered(t),i=0;i<n.length;i++)if(r>=n.start(i)&&r<=n.end(i))return!0}catch(e){}return!1},e.bufferInfo=function(t,r,n){try{if(t){var i,a=e.getBuffered(t),s=[];for(i=0;i<a.length;i++)s.push({start:a.start(i),end:a.end(i)});return this.bufferedInfo(s,r,n)}}catch(e){}return{len:0,start:r,end:r,nextStart:void 0}},e.bufferedInfo=function(e,t,r){t=Math.max(0,t),e.sort((function(e,t){var r=e.start-t.start;return r||t.end-e.end}));var n=[];if(r)for(var i=0;i<e.length;i++){var a=n.length;if(a){var s=n[a-1].end;e[i].start-s<r?e[i].end>s&&(n[a-1].end=e[i].end):n.push(e[i])}else n.push(e[i])}else n=e;for(var o,l=0,u=t,c=t,d=0;d<n.length;d++){var f=n[d].start,h=n[d].end;if(t+r>=f&&t<h)u=f,l=(c=h)-t;else if(t+r<f){o=f;break}}return{len:l,start:u||0,end:c||0,nextStart:o}},e.getBuffered=function(e){try{return e.buffered}catch(e){return n.logger.log("failed to get media.buffered",e),i}},e}()},"./src/utils/cea-608-parser.ts":
|
|
|
/*!*************************************!*\
|
|
|
!*** ./src/utils/cea-608-parser.ts ***!
|
|
|
\*************************************/
|
|
|
/*! exports provided: Row, CaptionScreen, default */function(e,t,r){"use strict";r.r(t),r.d(t,"Row",(function(){return v})),r.d(t,"CaptionScreen",(function(){return m}));var n,i=r(/*! ../utils/logger */"./src/utils/logger.ts"),a={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},s=function(e){var t=e;return a.hasOwnProperty(e)&&(t=a[e]),String.fromCharCode(t)},o={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},l={17:2,18:4,21:6,22:8,23:10,19:13,20:15},u={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},c={25:2,26:4,29:6,30:8,31:10,27:13,28:15},d=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];!function(e){e[e.ERROR=0]="ERROR",e[e.TEXT=1]="TEXT",e[e.WARNING=2]="WARNING",e[e.INFO=2]="INFO",e[e.DEBUG=3]="DEBUG",e[e.DATA=3]="DATA"}(n||(n={}));var f=function(){function e(){this.time=null,this.verboseLevel=n.ERROR}return e.prototype.log=function(e,t){this.verboseLevel>=e&&i.logger.log(this.time+" ["+e+"] "+t)},e}(),h=function(e){for(var t=[],r=0;r<e.length;r++)t.push(e[r].toString(16));return t},g=function(){function e(e,t,r,n,i){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=t||!1,this.italics=r||!1,this.background=n||"black",this.flash=i||!1}var t=e.prototype;return t.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},t.setStyles=function(e){for(var t=["foreground","underline","italics","background","flash"],r=0;r<t.length;r++){var n=t[r];e.hasOwnProperty(n)&&(this[n]=e[n])}},t.isDefault=function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash},t.equals=function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash},t.copy=function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash},t.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},e}(),p=function(){function e(e,t,r,n,i,a){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new g(t,r,n,i,a)}var t=e.prototype;return t.reset=function(){this.uchar=" ",this.penState.reset()},t.setChar=function(e,t){this.uchar=e,this.penState.copy(t)},t.setPenState=function(e){this.penState.copy(e)},t.equals=function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)},t.copy=function(e){this.uchar=e.uchar,this.penState.copy(e.penState)},t.isEmpty=function(){return" "===this.uchar&&this.penState.isDefault()},e}(),v=function(){function e(e){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var t=0;t<100;t++)this.chars.push(new p);this.logger=e,this.pos=0,this.currPenState=new g}var t=e.prototype;return t.equals=function(e){for(var t=!0,r=0;r<100;r++)if(!this.chars[r].equals(e.chars[r])){t=!1;break}return t},t.copy=function(e){for(var t=0;t<100;t++)this.chars[t].copy(e.chars[t])},t.isEmpty=function(){for(var e=!0,t=0;t<100;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e},t.setCursor=function(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(n.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>100&&(this.logger.log(n.DEBUG,"Too large cursor position "+this.pos),this.pos=100)},t.moveCursor=function(e){var t=this.pos+e;if(e>1)for(var r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)},t.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},t.insertChar=function(e){e>=144&&this.backSpace();var t=s(e);this.pos>=100?this.logger.log(n.ERROR,"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))},t.clearFromPos=function(e){var t;for(t=e;t<100;t++)this.chars[t].reset()},t.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},t.clearToEndOfRow=function(){this.clearFromPos(this.pos)},t.getTextString=function(){for(var e=[],t=!0,r=0;r<100;r++){var n=this.chars[r].uchar;" "!==n&&(t=!1),e.push(n)}return t?"":e.join("")},t.setPenStyles=function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)},e}(),m=function(){function e(e){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var t=0;t<15;t++)this.rows.push(new v(e));this.logger=e,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var t=e.prototype;return t.reset=function(){for(var e=0;e<15;e++)this.rows[e].clear();this.currRow=14},t.equals=function(e){for(var t=!0,r=0;r<15;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t},t.copy=function(e){for(var t=0;t<15;t++)this.rows[t].copy(e.rows[t])},t.isEmpty=function(){for(var e=!0,t=0;t<15;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e},t.backSpace=function(){this.rows[this.currRow].backSpace()},t.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},t.insertChar=function(e){this.rows[this.currRow].insertChar(e)},t.setPen=function(e){this.rows[this.currRow].setPenStyles(e)},t.moveCursor=function(e){this.rows[this.currRow].moveCursor(e)},t.setCursor=function(e){this.logger.log(n.INFO,"setCursor: "+e),this.rows[this.currRow].setCursor(e)},t.setPAC=function(e){this.logger.log(n.INFO,"pacData = "+JSON.stringify(e));var t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(var r=0;r<15;r++)this.rows[r].clear();var i=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var s=a.rows[i].cueStartTime,o=this.logger.time;if(s&&null!==o&&s<o)for(var l=0;l<this.nrRollUpRows;l++)this.rows[t-this.nrRollUpRows+l+1].copy(a.rows[i+l])}}this.currRow=t;var u=this.rows[this.currRow];if(null!==e.indent){var c=e.indent,d=Math.max(c-1,0);u.setCursor(e.indent),e.color=u.chars[d].penState.foreground}var f={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(f)},t.setBkgData=function(e){this.logger.log(n.INFO,"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)},t.setRollUpRows=function(e){this.nrRollUpRows=e},t.rollUp=function(){if(null!==this.nrRollUpRows){this.logger.log(n.TEXT,this.getDisplayText());var e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(n.INFO,"Rolling up")}else this.logger.log(n.DEBUG,"roll_up but nrRollUpRows not set yet")},t.getDisplayText=function(e){e=e||!1;for(var t=[],r="",n=-1,i=0;i<15;i++){var a=this.rows[i].getTextString();a&&(n=i+1,e?t.push("Row "+n+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r},t.getTextAndFormat=function(){return this.rows},e}(),y=function(){function e(e,t,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new m(r),this.nonDisplayedMemory=new m(r),this.lastOutputScreen=new m(r),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}var t=e.prototype;return t.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},t.getHandler=function(){return this.outputFilter},t.setHandler=function(e){this.outputFilter=e},t.setPAC=function(e){this.writeScreen.setPAC(e)},t.setBkgData=function(e){this.writeScreen.setBkgData(e)},t.setMode=function(e){e!==this.mode&&(this.mode=e,this.logger.log(n.INFO,"MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)},t.insertChars=function(e){for(var t=0;t<e.length;t++)this.writeScreen.insertChar(e[t]);var r=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(n.INFO,r+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(n.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},t.ccRCL=function(){this.logger.log(n.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},t.ccBS=function(){this.logger.log(n.INFO,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},t.ccAOF=function(){},t.ccAON=function(){},t.ccDER=function(){this.logger.log(n.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},t.ccRU=function(e){this.logger.log(n.INFO,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)},t.ccFON=function(){this.logger.log(n.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},t.ccRDC=function(){this.logger.log(n.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},t.ccTR=function(){this.logger.log(n.INFO,"TR"),this.setMode("MODE_TEXT")},t.ccRTD=function(){this.logger.log(n.INFO,"RTD"),this.setMode("MODE_TEXT")},t.ccEDM=function(){this.logger.log(n.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},t.ccCR=function(){this.logger.log(n.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},t.ccENM=function(){this.logger.log(n.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},t.ccEOC=function(){if(this.logger.log(n.INFO,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(n.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},t.ccTO=function(e){this.logger.log(n.INFO,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)},t.ccMIDROW=function(e){var t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{var r=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][r]}this.logger.log(n.INFO,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)},t.outputDataUpdate=function(e){void 0===e&&(e=!1);var t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))},t.cueSplitAtTime=function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))},e}(),b=function(){function e(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var n=new f;this.channels=[null,new y(e,t,n),new y(e+1,r,n)],this.cmdHistory={a:null,b:null},this.logger=n}var t=e.prototype;return t.getHandler=function(e){return this.channels[e].getHandler()},t.setHandler=function(e,t){this.channels[e].setHandler(t)},t.addData=function(e,t){var r,i,a,s=!1;this.logger.time=e;for(var o=0;o<t.length;o+=2)if(i=127&t[o],a=127&t[o+1],0!==i||0!==a){if(this.logger.log(n.DATA,"["+h([t[o],t[o+1]])+"] -> ("+h([i,a])+")"),(r=this.parseCmd(i,a))||(r=this.parseMidrow(i,a)),r||(r=this.parsePAC(i,a)),r||(r=this.parseBackgroundAttributes(i,a)),!r&&(s=this.parseChars(i,a))){var l=this.currentChannel;l&&l>0?this.channels[l].insertChars(s):this.logger.log(n.WARNING,"No channel found yet. TEXT-MODE?")}r||s||this.logger.log(n.WARNING,"Couldn't parse cleaned data "+h([i,a])+" orig: "+h([t[o],t[o+1]]))}},t.parseCmd=function(e,t){var r=this.cmdHistory;if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=33&&t<=35))return!1;if(T(e,t,r))return E(null,null,r),this.logger.log(n.DEBUG,"Repeated command ("+h([e,t])+") is dropped"),!0;var i=20===e||21===e||23===e?1:2,a=this.channels[i];return 20===e||21===e||28===e||29===e?32===t?a.ccRCL():33===t?a.ccBS():34===t?a.ccAOF():35===t?a.ccAON():36===t?a.ccDER():37===t?a.ccRU(2):38===t?a.ccRU(3):39===t?a.ccRU(4):40===t?a.ccFON():41===t?a.ccRDC():42===t?a.ccTR():43===t?a.ccRTD():44===t?a.ccEDM():45===t?a.ccCR():46===t?a.ccENM():47===t&&a.ccEOC():a.ccTO(t-32),E(e,t,r),this.currentChannel=i,!0},t.parseMidrow=function(e,t){var r=0;if((17===e||25===e)&&t>=32&&t<=47){if((r=17===e?1:2)!==this.currentChannel)return this.logger.log(n.ERROR,"Mismatch channel in midrow parsing"),!1;var i=this.channels[r];return!!i&&(i.ccMIDROW(t),this.logger.log(n.DEBUG,"MIDROW ("+h([e,t])+")"),!0)}return!1},t.parsePAC=function(e,t){var r,n=this.cmdHistory;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127||(16===e||24===e)&&t>=64&&t<=95))return!1;if(T(e,t,n))return E(null,null,n),!0;var i=e<=23?1:2;r=t>=64&&t<=95?1===i?o[e]:u[e]:1===i?l[e]:c[e];var a=this.channels[i];return!!a&&(a.setPAC(this.interpretPAC(r,t)),E(e,t,n),this.currentChannel=i,!0)},t.interpretPAC=function(e,t){var r,n={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,n.underline=1==(1&r),r<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(n.italics=!0,n.color="white"):n.indent=4*Math.floor((r-16)/2),n},t.parseChars=function(e,t){var r,i,a=null,o=null;if(e>=25?(r=2,o=e-8):(r=1,o=e),o>=17&&o<=19?(i=17===o?t+80:18===o?t+112:t+144,this.logger.log(n.INFO,"Special char '"+s(i)+"' in channel "+r),a=[i]):e>=32&&e<=127&&(a=0===t?[e]:[e,t]),a){var l=h(a);this.logger.log(n.DEBUG,"Char codes = "+l.join(",")),E(e,t,this.cmdHistory)}return a},t.parseBackgroundAttributes=function(e,t){var r;if(!((16===e||24===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=45&&t<=47))return!1;var n={};16===e||24===e?(r=Math.floor((t-32)/2),n.background=d[r],t%2==1&&(n.background=n.background+"_semi")):45===t?n.background="transparent":(n.foreground="black",47===t&&(n.underline=!0));var i=e<=23?1:2;return this.channels[i].setBkgData(n),E(e,t,this.cmdHistory),!0},t.reset=function(){for(var e=0;e<Object.keys(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}this.cmdHistory={a:null,b:null}},t.cueSplitAtTime=function(e){for(var t=0;t<this.channels.length;t++){var r=this.channels[t];r&&r.cueSplitAtTime(e)}},e}();function E(e,t,r){r.a=e,r.b=t}function T(e,t,r){return r.a===e&&r.b===t}t.default=b},"./src/utils/codecs.ts":
|
|
|
/*!*****************************!*\
|
|
|
!*** ./src/utils/codecs.ts ***!
|
|
|
\*****************************/
|
|
|
/*! exports provided: isCodecType, isCodecSupportedInMp4 */function(e,t,r){"use strict";r.r(t),r.d(t,"isCodecType",(function(){return i})),r.d(t,"isCodecSupportedInMp4",(function(){return a}));var n={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function i(e,t){var r=n[t];return!!r&&!0===r[e.slice(0,4)]}function a(e,t){return MediaSource.isTypeSupported((t||"video")+'/mp4;codecs="'+e+'"')}},"./src/utils/cues.ts":
|
|
|
/*!***************************!*\
|
|
|
!*** ./src/utils/cues.ts ***!
|
|
|
\***************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t);var n=r(/*! ./vttparser */"./src/utils/vttparser.ts"),i=r(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts"),a=r(/*! ./texttrack-utils */"./src/utils/texttrack-utils.ts"),s=/\s/,o={newCue:function(e,t,r,o){for(var l,u,c,d,f,h=[],g=self.VTTCue||self.TextTrackCue,p=0;p<o.rows.length;p++)if(c=!0,d=0,f="",!(l=o.rows[p]).isEmpty()){for(var v=0;v<l.chars.length;v++)s.test(l.chars[v].uchar)&&c?d++:(f+=l.chars[v].uchar,c=!1);l.cueStartTime=t,t===r&&(r+=1e-4),d>=16?d--:d++;var m=Object(n.fixLineBreaks)(f.trim()),y=Object(i.generateCueId)(t,r,m);e&&e.cues&&e.cues.getCueById(y)||((u=new g(t,r,m)).id=y,u.line=p+1,u.align="left",u.position=10+Math.min(80,10*Math.floor(8*d/32)),h.push(u))}return e&&h.length&&(h.sort((function(e,t){return"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line})),h.forEach((function(t){return Object(a.addCueToTrack)(e,t)}))),h}};t.default=o},"./src/utils/discontinuities.ts":
|
|
|
/*!**************************************!*\
|
|
|
!*** ./src/utils/discontinuities.ts ***!
|
|
|
\**************************************/
|
|
|
/*! exports provided: findFirstFragWithCC, shouldAlignOnDiscontinuities, findDiscontinuousReferenceFrag, adjustSlidingStart, alignStream, alignPDT, alignFragmentByPDTDelta, alignMediaPlaylistByPDT */function(e,t,r){"use strict";r.r(t),r.d(t,"findFirstFragWithCC",(function(){return s})),r.d(t,"shouldAlignOnDiscontinuities",(function(){return o})),r.d(t,"findDiscontinuousReferenceFrag",(function(){return l})),r.d(t,"adjustSlidingStart",(function(){return c})),r.d(t,"alignStream",(function(){return d})),r.d(t,"alignPDT",(function(){return f})),r.d(t,"alignFragmentByPDTDelta",(function(){return h})),r.d(t,"alignMediaPlaylistByPDT",(function(){return g}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ./logger */"./src/utils/logger.ts"),a=r(/*! ../controller/level-helper */"./src/controller/level-helper.ts");function s(e,t){for(var r=null,n=0,i=e.length;n<i;n++){var a=e[n];if(a&&a.cc===t){r=a;break}}return r}function o(e,t,r){return!(!t.details||!(r.endCC>r.startCC||e&&e.cc<r.startCC))}function l(e,t){var r=e.fragments,n=t.fragments;if(n.length&&r.length){var a=s(r,n[0].cc);if(a&&(!a||a.startPTS))return a;i.logger.log("No frag in previous level to align on")}else i.logger.log("No fragments to align")}function u(e,t){if(e){var r=e.start+t;e.start=e.startPTS=r,e.endPTS=r+e.duration}}function c(e,t){for(var r=t.fragments,n=0,i=r.length;n<i;n++)u(r[n],e);t.fragmentHint&&u(t.fragmentHint,e),t.alignedSliding=!0}function d(e,t,r){t&&(function(e,t,r){if(o(e,r,t)){var a=l(r.details,t);a&&Object(n.isFiniteNumber)(a.start)&&(i.logger.log("Adjusting PTS using last level due to CC increase within current level "+t.url),c(a.start,t))}}(e,r,t),!r.alignedSliding&&t.details&&f(r,t.details),r.alignedSliding||!t.details||r.skippedSegments||Object(a.adjustSliding)(t.details,r))}function f(e,t){if(t.fragments.length&&e.hasProgramDateTime&&t.hasProgramDateTime){var r=t.fragments[0].programDateTime,a=e.fragments[0].programDateTime,s=(a-r)/1e3+t.fragments[0].start;s&&Object(n.isFiniteNumber)(s)&&(i.logger.log("Adjusting PTS using programDateTime delta "+(a-r)+"ms, sliding:"+s.toFixed(3)+" "+e.url+" "),c(s,e))}}function h(e,t){var r=e.programDateTime;if(r){var n=(r-t)/1e3;e.start=e.startPTS=n,e.endPTS=n+e.duration}}function g(e,t){if(t.fragments.length&&e.hasProgramDateTime&&t.hasProgramDateTime){var r=t.fragments[0].programDateTime-1e3*t.fragments[0].start;e.fragments.forEach((function(e){h(e,r)})),e.fragmentHint&&h(e.fragmentHint,r),e.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":
|
|
|
/*!***********************************************!*\
|
|
|
!*** ./src/utils/ewma-bandwidth-estimator.ts ***!
|
|
|
\***********************************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t);var n=r(/*! ../utils/ewma */"./src/utils/ewma.ts"),i=function(){function e(e,t,r){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new n.default(e),this.fast_=new n.default(t)}var t=e.prototype;return t.update=function(e,t){var r=this.slow_,i=this.fast_;this.slow_.halfLife!==e&&(this.slow_=new n.default(e,r.getEstimate(),r.getTotalWeight())),this.fast_.halfLife!==t&&(this.fast_=new n.default(t,i.getEstimate(),i.getTotalWeight()))},t.sample=function(e,t){var r=(e=Math.max(e,this.minDelayMs_))/1e3,n=8*t/r;this.fast_.sample(r,n),this.slow_.sample(r,n)},t.canEstimate=function(){var e=this.fast_;return e&&e.getTotalWeight()>=this.minWeight_},t.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.destroy=function(){},e}();t.default=i},"./src/utils/ewma.ts":
|
|
|
/*!***************************!*\
|
|
|
!*** ./src/utils/ewma.ts ***!
|
|
|
\***************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t);var n=function(){function e(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}var t=e.prototype;return t.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},t.getTotalWeight=function(){return this.totalWeight_},t.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},e}();t.default=n},"./src/utils/fetch-loader.ts":
|
|
|
/*!***********************************!*\
|
|
|
!*** ./src/utils/fetch-loader.ts ***!
|
|
|
\***********************************/
|
|
|
/*! exports provided: fetchSupported, default */function(e,t,r){"use strict";r.r(t),r.d(t,"fetchSupported",(function(){return f}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),a=r(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts");function s(e){var t="function"==typeof Map?new Map:void 0;return(s=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return o(e,arguments,c(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),u(n,e)})(e)}function o(e,t,r){return(o=l()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&u(i,r.prototype),i}).apply(null,arguments)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function d(){return(d=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function f(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}var h=function(){function e(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||g,this.controller=new self.AbortController,this.stats=new i.LoadStats}var t=e.prototype;return t.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},t.abortInternal=function(){var e=this.response;e&&e.ok||(this.stats.aborted=!0,this.controller.abort())},t.abort=function(){var e;this.abortInternal(),null!==(e=this.callbacks)&&void 0!==e&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},t.load=function(e,t,r){var i=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var s=function(e,t){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(d({},e.headers))};return e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1)),r}(e,this.controller.signal),o=r.onProgress,l="arraybuffer"===e.responseType,u=l?"byteLength":"length";this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,s),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout((function(){i.abortInternal(),r.onTimeout(a,e,i.response)}),t.timeout),self.fetch(this.request).then((function(r){if(i.response=i.loader=r,!r.ok){var s=r.status,u=r.statusText;throw new p(u||"fetch, bad network response",s,r)}return a.loading.first=Math.max(self.performance.now(),a.loading.start),a.total=parseInt(r.headers.get("Content-Length")||"0"),o&&Object(n.isFiniteNumber)(t.highWaterMark)?i.loadProgressively(r,a,e,t.highWaterMark,o):l?r.arrayBuffer():r.text()})).then((function(s){var l=i.response;self.clearTimeout(i.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first),a.loaded=a.total=s[u];var c={url:l.url,data:s};o&&!Object(n.isFiniteNumber)(t.highWaterMark)&&o(a,e,s,l),r.onSuccess(c,a,e,l)})).catch((function(t){if(self.clearTimeout(i.requestTimeout),!a.aborted){var n=t.code||0;r.onError({code:n,text:t.message},e,t.details)}}))},t.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},t.loadProgressively=function(e,t,r,n,i){void 0===n&&(n=0);var s=new a.default,o=e.body.getReader();return function a(){return o.read().then((function(o){if(o.done)return s.dataLength&&i(t,r,s.flush(),e),Promise.resolve(new ArrayBuffer(0));var l=o.value,u=l.length;return t.loaded+=u,u<n||s.dataLength?(s.push(l),s.dataLength>=n&&i(t,r,s.flush(),e)):i(t,r,l,e),a()})).catch((function(){return Promise.reject()}))}()},e}();function g(e,t){return new self.Request(e.url,t)}var p=function(e){var t,r;function n(t,r,n){var i;return(i=e.call(this,t)||this).code=void 0,i.details=void 0,i.code=r,i.details=n,i}return r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,u(t,r),n}(s(Error));t.default=h},"./src/utils/imsc1-ttml-parser.ts":
|
|
|
/*!****************************************!*\
|
|
|
!*** ./src/utils/imsc1-ttml-parser.ts ***!
|
|
|
\****************************************/
|
|
|
/*! exports provided: IMSC1_CODEC, parseIMSC1 */function(e,t,r){"use strict";r.r(t),r.d(t,"IMSC1_CODEC",(function(){return c})),r.d(t,"parseIMSC1",(function(){return g}));var n=r(/*! ./mp4-tools */"./src/utils/mp4-tools.ts"),i=r(/*! ./vttparser */"./src/utils/vttparser.ts"),a=r(/*! ./vttcue */"./src/utils/vttcue.ts"),s=r(/*! ../demux/id3 */"./src/demux/id3.ts"),o=r(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts"),l=r(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts");function u(){return(u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var c="stpp.ttml.im1t",d=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,f=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,h={left:"start",center:"center",right:"end",start:"start",end:"end"};function g(e,t,r,i,c){var d=Object(n.findBox)(new Uint8Array(e),["mdat"]);if(0!==d.length){var f=d[0],g=Object(s.utf8ArrayToStr)(new Uint8Array(e,f.start,f.end-f.start)),E=Object(o.toTimescaleFromScale)(t,1,r);try{i(function(e,t){var r=(new DOMParser).parseFromString(e,"text/xml").getElementsByTagName("tt")[0];if(!r)throw new Error("Invalid ttml");var n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},i=Object.keys(n).reduce((function(e,t){return e[t]=r.getAttribute("ttp:"+t)||n[t],e}),{}),s="preserve"!==r.getAttribute("xml:space"),o=v(p(r,"styling","style")),c=v(p(r,"layout","region")),d=p(r,"body","[begin]");return[].map.call(d,(function(e){var r=function e(t,r){return[].slice.call(t.childNodes).reduce((function(t,n,i){var a;return"br"===n.nodeName&&i?t+"\n":null!==(a=n.childNodes)&&void 0!==a&&a.length?e(n,r):r?t+n.textContent.trim().replace(/\s+/g," "):t+n.textContent}),"")}(e,s);if(!r||!e.hasAttribute("begin"))return null;var n=b(e.getAttribute("begin"),i),d=b(e.getAttribute("dur"),i),f=b(e.getAttribute("end"),i);if(null===n)throw y(e);if(null===f){if(null===d)throw y(e);f=n+d}var g=new a.default(n-t,f-t,r);g.id=Object(l.generateCueId)(g.startTime,g.endTime,g.text);var p=c[e.getAttribute("region")],v=o[e.getAttribute("style")];g.position=10,g.size=80;var E=function(e,t){var r="http://www.w3.org/ns/ttml#styling";return["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce((function(n,i){var a=m(t,r,i)||m(e,r,i);return a&&(n[i]=a),n}),{})}(p,v),T=E.textAlign;if(T){var S=h[T];S&&(g.lineAlign=S),g.align=T}return u(g,E),g})).filter((function(e){return null!==e}))}(g,E))}catch(e){c(e)}}else c(new Error("Could not parse IMSC1 mdat"))}function p(e,t,r){var n=e.getElementsByTagName(t)[0];return n?[].slice.call(n.querySelectorAll(r)):[]}function v(e){return e.reduce((function(e,t){var r=t.getAttribute("xml:id");return r&&(e[r]=t),e}),{})}function m(e,t,r){return e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function y(e){return new Error("Could not parse ttml timestamp "+e)}function b(e,t){if(!e)return null;var r=Object(i.parseTimeStamp)(e);return null===r&&(d.test(e)?r=function(e,t){var r=d.exec(e),n=(0|r[4])+(0|r[5])/t.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+n/t.frameRate}(e,t):f.test(e)&&(r=function(e,t){var r=f.exec(e),n=Number(r[1]);switch(r[2]){case"h":return 3600*n;case"m":return 60*n;case"ms":return 1e3*n;case"f":return n/t.frameRate;case"t":return n/t.tickRate}return n}(e,t))),r}},"./src/utils/logger.ts":
|
|
|
/*!*****************************!*\
|
|
|
!*** ./src/utils/logger.ts ***!
|
|
|
\*****************************/
|
|
|
/*! exports provided: enableLogs, logger */function(e,t,r){"use strict";r.r(t),r.d(t,"enableLogs",(function(){return o})),r.d(t,"logger",(function(){return l}));var n=function(){},i={trace:n,debug:n,log:n,warn:n,info:n,error:n},a=i;function s(e){var t=self.console[e];return t?t.bind(self.console,"["+e+"] >"):n}function o(e){if(self.console&&!0===e||"object"==typeof e){!function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];r.forEach((function(t){a[t]=e[t]?e[t].bind(e):s(t)}))}(e,"debug","log","info","warn","error");try{a.log()}catch(e){a=i}}else a=i}var l=i},"./src/utils/mediakeys-helper.ts":
|
|
|
/*!***************************************!*\
|
|
|
!*** ./src/utils/mediakeys-helper.ts ***!
|
|
|
\***************************************/
|
|
|
/*! exports provided: KeySystems, requestMediaKeySystemAccess */function(e,t,r){"use strict";var n;r.r(t),r.d(t,"KeySystems",(function(){return n})),r.d(t,"requestMediaKeySystemAccess",(function(){return i})),function(e){e.WIDEVINE="com.widevine.alpha",e.PLAYREADY="com.microsoft.playready"}(n||(n={}));var i="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null},"./src/utils/mediasource-helper.ts":
|
|
|
/*!*****************************************!*\
|
|
|
!*** ./src/utils/mediasource-helper.ts ***!
|
|
|
\*****************************************/
|
|
|
/*! exports provided: getMediaSource */function(e,t,r){"use strict";function n(){return self.MediaSource||self.WebKitMediaSource}r.r(t),r.d(t,"getMediaSource",(function(){return n}))},"./src/utils/mp4-tools.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/utils/mp4-tools.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: bin2str, readUint16, readUint32, writeUint32, findBox, parseSegmentIndex, parseInitSegment, getStartDTS, getDuration, computeRawDurationFromSamples, offsetStartDTS, segmentValidRange, appendUint8Array */function(e,t,r){"use strict";r.r(t),r.d(t,"bin2str",(function(){return o})),r.d(t,"readUint16",(function(){return l})),r.d(t,"readUint32",(function(){return u})),r.d(t,"writeUint32",(function(){return c})),r.d(t,"findBox",(function(){return d})),r.d(t,"parseSegmentIndex",(function(){return f})),r.d(t,"parseInitSegment",(function(){return h})),r.d(t,"getStartDTS",(function(){return g})),r.d(t,"getDuration",(function(){return p})),r.d(t,"computeRawDurationFromSamples",(function(){return v})),r.d(t,"offsetStartDTS",(function(){return m})),r.d(t,"segmentValidRange",(function(){return y})),r.d(t,"appendUint8Array",(function(){return b}));var n=r(/*! ./typed-array */"./src/utils/typed-array.ts"),i=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),a=Math.pow(2,32)-1,s=[].push;function o(e){return String.fromCharCode.apply(null,e)}function l(e,t){"data"in e&&(t+=e.start,e=e.data);var r=e[t]<<8|e[t+1];return r<0?65536+r:r}function u(e,t){"data"in e&&(t+=e.start,e=e.data);var r=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];return r<0?4294967296+r:r}function c(e,t,r){"data"in e&&(t+=e.start,e=e.data),e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}function d(e,t){var r,n,i,a=[];if(!t.length)return a;"data"in e?(r=e.data,n=e.start,i=e.end):(n=0,i=(r=e).byteLength);for(var l=n;l<i;){var c=u(r,l),f=c>1?l+c:i;if(o(r.subarray(l+4,l+8))===t[0])if(1===t.length)a.push({data:r,start:l+8,end:f});else{var h=d({data:r,start:l+8,end:f},t.slice(1));h.length&&s.apply(a,h)}l=f}return a}function f(e){var t=d(e,["moov"])[0],r=t?t.end:null,n=d(e,["sidx"]);if(!n||!n[0])return null;var i=[],a=n[0],s=a.data[0],o=0===s?8:16,c=u(a,o);o+=4,o+=0===s?8:16,o+=2;var f=a.end+0,h=l(a,o);o+=2;for(var g=0;g<h;g++){var p=o,v=u(a,p);p+=4;var m=2147483647&v;if(1==(2147483648&v)>>>31)return console.warn("SIDX has hierarchical references (not supported)"),null;var y=u(a,p);p+=4,i.push({referenceSize:m,subsegmentDuration:y,info:{duration:y/c,start:f,end:f+m-1}}),f+=m,o=p+=4}return{earliestPresentationTime:0,timescale:c,version:s,referencesCount:h,references:i,moovEndOffset:r}}function h(e){for(var t=[],r=d(e,["moov","trak"]),n=0;n<r.length;n++){var a=r[n],s=d(a,["tkhd"])[0];if(s){var l=s.data[s.start],c=0===l?12:20,f=u(s,c),h=d(a,["mdia","mdhd"])[0];if(h){var g=u(h,c=0===(l=h.data[h.start])?12:20),p=d(a,["mdia","hdlr"])[0];if(p){var v=o(p.data.subarray(p.start+8,p.start+12)),m={soun:i.ElementaryStreamTypes.AUDIO,vide:i.ElementaryStreamTypes.VIDEO}[v];if(m){var y=d(a,["mdia","minf","stbl","stsd"])[0],b=void 0;y&&(b=o(y.data.subarray(y.start+12,y.start+16))),t[f]={timescale:g,type:m},t[m]={timescale:g,id:f,codec:b}}}}}}return d(e,["moov","mvex","trex"]).forEach((function(e){var r=u(e,4),n=t[r];n&&(n.default={duration:u(e,12),flags:u(e,20)})})),t}function g(e,t){return d(t,["moof","traf"]).reduce((function(t,r){var n=d(r,["tfdt"])[0],i=n.data[n.start],a=d(r,["tfhd"]).reduce((function(t,r){var a=u(r,4),s=e[a];if(s){var o=u(n,4);1===i&&(o*=Math.pow(2,32),o+=u(n,8));var l=o/(s.timescale||9e4);if(isFinite(l)&&(null===t||l<t))return l}return t}),null);return null!==a&&isFinite(a)&&(null===t||a<t)?a:t}),null)||0}function p(e,t){for(var r=0,n=0,a=0,s=d(e,["moof","traf"]),o=0;o<s.length;o++){var l=s[o],c=d(l,["tfhd"])[0],h=t[u(c,4)];if(h){var g=h.default,p=u(c,0)|(null==g?void 0:g.flags),m=null==g?void 0:g.duration;8&p&&(m=u(c,2&p?12:8));for(var y=h.timescale||9e4,b=d(l,["trun"]),E=0;E<b.length;E++)r=m?m*u(b[E],4):v(b[E]),h.type===i.ElementaryStreamTypes.VIDEO?n+=r/y:h.type===i.ElementaryStreamTypes.AUDIO&&(a+=r/y)}}if(0===n&&0===a){var T=f(e);if(null!=T&&T.references)return T.references.reduce((function(e,t){return e+t.info.duration||0}),0)}return n||a}function v(e){var t=u(e,0),r=8;1&t&&(r+=4),4&t&&(r+=4);for(var n=0,i=u(e,4),a=0;a<i;a++)256&t&&(n+=u(e,r),r+=4),512&t&&(r+=4),1024&t&&(r+=4),2048&t&&(r+=4);return n}function m(e,t,r){d(t,["moof","traf"]).forEach((function(t){d(t,["tfhd"]).forEach((function(n){var i=u(n,4),s=e[i];if(s){var o=s.timescale||9e4;d(t,["tfdt"]).forEach((function(e){var t=e.data[e.start],n=u(e,4);if(0===t)c(e,4,n-r*o);else{n*=Math.pow(2,32),n+=u(e,8),n-=r*o,n=Math.max(n,0);var i=Math.floor(n/(a+1)),s=Math.floor(n%(a+1));c(e,4,i),c(e,8,s)}}))}}))}))}function y(e){var t={valid:null,remainder:null},r=d(e,["moof"]);if(!r)return t;if(r.length<2)return t.remainder=e,t;var i=r[r.length-1];return t.valid=Object(n.sliceUint8)(e,0,i.start-8),t.remainder=Object(n.sliceUint8)(e,i.start-8),t}function b(e,t){var r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}},"./src/utils/output-filter.ts":
|
|
|
/*!************************************!*\
|
|
|
!*** ./src/utils/output-filter.ts ***!
|
|
|
\************************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return n}));var n=function(){function e(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}var t=e.prototype;return t.dispatchCue=function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},t.newCue=function(e,t,r){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},t.reset=function(){this.cueRanges=[]},e}()},"./src/utils/texttrack-utils.ts":
|
|
|
/*!**************************************!*\
|
|
|
!*** ./src/utils/texttrack-utils.ts ***!
|
|
|
\**************************************/
|
|
|
/*! exports provided: sendAddTrackEvent, addCueToTrack, clearCurrentCues, removeCuesInRange, getCuesInRange */function(e,t,r){"use strict";r.r(t),r.d(t,"sendAddTrackEvent",(function(){return i})),r.d(t,"addCueToTrack",(function(){return a})),r.d(t,"clearCurrentCues",(function(){return s})),r.d(t,"removeCuesInRange",(function(){return o})),r.d(t,"getCuesInRange",(function(){return l}));var n=r(/*! ./logger */"./src/utils/logger.ts");function i(e,t){var r;try{r=new Event("addtrack")}catch(e){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function a(e,t){var r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error("addCue is failed for: "+t)}catch(r){n.logger.debug("[texttrack-utils]: "+r);var i=new self.TextTrackCue(t.startTime,t.endTime,t.text);i.id=t.id,e.addCue(i)}"disabled"===r&&(e.mode=r)}function s(e){var t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(var r=e.cues.length;r--;)e.removeCue(e.cues[r]);"disabled"===t&&(e.mode=t)}function o(e,t,r){var n=e.mode;if("disabled"===n&&(e.mode="hidden"),e.cues&&e.cues.length>0)for(var i=l(e.cues,t,r),a=0;a<i.length;a++)e.removeCue(i[a]);"disabled"===n&&(e.mode=n)}function l(e,t,r){var n=[],i=function(e,t){if(t<e[0].startTime)return 0;var r=e.length-1;if(t>e[r].endTime)return-1;for(var n=0,i=r;n<=i;){var a=Math.floor((i+n)/2);if(t<e[a].startTime)i=a-1;else{if(!(t>e[a].startTime&&n<r))return a;n=a+1}}return e[n].startTime-t<t-e[i].startTime?n:i}(e,t);if(i>-1)for(var a=i,s=e.length;a<s;a++){var o=e[a];if(o.startTime>=t&&o.endTime<=r)n.push(o);else if(o.startTime>r)return n}return n}},"./src/utils/time-ranges.ts":
|
|
|
/*!**********************************!*\
|
|
|
!*** ./src/utils/time-ranges.ts ***!
|
|
|
\**********************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t),t.default={toString:function(e){for(var t="",r=e.length,n=0;n<r;n++)t+="["+e.start(n).toFixed(3)+","+e.end(n).toFixed(3)+"]";return t}}},"./src/utils/timescale-conversion.ts":
|
|
|
/*!*******************************************!*\
|
|
|
!*** ./src/utils/timescale-conversion.ts ***!
|
|
|
\*******************************************/
|
|
|
/*! exports provided: toTimescaleFromBase, toTimescaleFromScale, toMsFromMpegTsClock, toMpegTsClockFromTimescale */function(e,t,r){"use strict";function n(e,t,r,n){void 0===r&&(r=1),void 0===n&&(n=!1);var i=e*t*r;return n?Math.round(i):i}function i(e,t,r,i){return void 0===r&&(r=1),void 0===i&&(i=!1),n(e,t,1/r,i)}function a(e,t){return void 0===t&&(t=!1),n(e,1e3,1/9e4,t)}function s(e,t){return void 0===t&&(t=1),n(e,9e4,1/t)}r.r(t),r.d(t,"toTimescaleFromBase",(function(){return n})),r.d(t,"toTimescaleFromScale",(function(){return i})),r.d(t,"toMsFromMpegTsClock",(function(){return a})),r.d(t,"toMpegTsClockFromTimescale",(function(){return s}))},"./src/utils/typed-array.ts":
|
|
|
/*!**********************************!*\
|
|
|
!*** ./src/utils/typed-array.ts ***!
|
|
|
\**********************************/
|
|
|
/*! exports provided: sliceUint8 */function(e,t,r){"use strict";function n(e,t,r){return Uint8Array.prototype.slice?e.slice(t,r):new Uint8Array(Array.prototype.slice.call(e,t,r))}r.r(t),r.d(t,"sliceUint8",(function(){return n}))},"./src/utils/vttcue.ts":
|
|
|
/*!*****************************!*\
|
|
|
!*** ./src/utils/vttcue.ts ***!
|
|
|
\*****************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t),t.default=function(){if("undefined"!=typeof self&&self.VTTCue)return self.VTTCue;var e=["","lr","rl"],t=["start","middle","end","left","right"];function r(e,t){if("string"!=typeof t)return!1;if(!Array.isArray(e))return!1;var r=t.toLowerCase();return!!~e.indexOf(r)&&r}function n(e){return r(t,e)}function i(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];for(var i=1;i<arguments.length;i++){var a=arguments[i];for(var s in a)e[s]=a[s]}return e}function a(t,a,s){var o=this,l={enumerable:!0};o.hasBeenReset=!1;var u="",c=!1,d=t,f=a,h=s,g=null,p="",v=!0,m="auto",y="start",b=50,E="middle",T=50,S="middle";Object.defineProperty(o,"id",i({},l,{get:function(){return u},set:function(e){u=""+e}})),Object.defineProperty(o,"pauseOnExit",i({},l,{get:function(){return c},set:function(e){c=!!e}})),Object.defineProperty(o,"startTime",i({},l,{get:function(){return d},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");d=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"endTime",i({},l,{get:function(){return f},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");f=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"text",i({},l,{get:function(){return h},set:function(e){h=""+e,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",i({},l,{get:function(){return g},set:function(e){g=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",i({},l,{get:function(){return p},set:function(t){var n=function(t){return r(e,t)}(t);if(!1===n)throw new SyntaxError("An invalid or illegal string was specified.");p=n,this.hasBeenReset=!0}})),Object.defineProperty(o,"snapToLines",i({},l,{get:function(){return v},set:function(e){v=!!e,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",i({},l,{get:function(){return m},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");m=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"lineAlign",i({},l,{get:function(){return y},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"position",i({},l,{get:function(){return b},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",i({},l,{get:function(){return E},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");E=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",i({},l,{get:function(){return T},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");T=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",i({},l,{get:function(){return S},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");S=t,this.hasBeenReset=!0}})),o.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}()},"./src/utils/vttparser.ts":
|
|
|
/*!********************************!*\
|
|
|
!*** ./src/utils/vttparser.ts ***!
|
|
|
\********************************/
|
|
|
/*! exports provided: parseTimeStamp, fixLineBreaks, VTTParser */function(e,t,r){"use strict";r.r(t),r.d(t,"parseTimeStamp",(function(){return a})),r.d(t,"fixLineBreaks",(function(){return d})),r.d(t,"VTTParser",(function(){return f}));var n=r(/*! ./vttcue */"./src/utils/vttcue.ts"),i=function(){function e(){}return e.prototype.decode=function(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))},e}();function a(e){function t(e,t,r,n){return 3600*(0|e)+60*(0|t)+(0|r)+parseFloat(n||0)}var r=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?parseFloat(r[2])>59?t(r[2],r[3],0,r[4]):t(r[1],r[2],r[3],r[4]):null}var s=function(){function e(){this.values=Object.create(null)}var t=e.prototype;return t.set=function(e,t){this.get(e)||""===t||(this.values[e]=t)},t.get=function(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t},t.has=function(e){return e in this.values},t.alt=function(e,t,r){for(var n=0;n<r.length;++n)if(t===r[n]){this.set(e,t);break}},t.integer=function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))},t.percent=function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1},e}();function o(e,t,r,n){var i=n?e.split(n):[e];for(var a in i)if("string"==typeof i[a]){var s=i[a].split(r);2===s.length&&t(s[0],s[1])}}var l=new n.default(0,0,""),u="middle"===l.align?"middle":"center";function c(e,t,r){var n=e;function i(){var t=a(e);if(null===t)throw new Error("Malformed timestamp: "+n);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function c(){e=e.replace(/^\s+/,"")}if(c(),t.startTime=i(),c(),"--\x3e"!==e.substr(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+n);e=e.substr(3),c(),t.endTime=i(),c(),function(e,t){var n=new s;o(e,(function(e,t){var i;switch(e){case"region":for(var a=r.length-1;a>=0;a--)if(r[a].id===t){n.set(e,r[a].region);break}break;case"vertical":n.alt(e,t,["rl","lr"]);break;case"line":i=t.split(","),n.integer(e,i[0]),n.percent(e,i[0])&&n.set("snapToLines",!1),n.alt(e,i[0],["auto"]),2===i.length&&n.alt("lineAlign",i[1],["start",u,"end"]);break;case"position":i=t.split(","),n.percent(e,i[0]),2===i.length&&n.alt("positionAlign",i[1],["start",u,"end","line-left","line-right","auto"]);break;case"size":n.percent(e,t);break;case"align":n.alt(e,t,["start",u,"end","left","right"])}}),/:/,/\s/),t.region=n.get("region",null),t.vertical=n.get("vertical","");var i=n.get("line","auto");"auto"===i&&-1===l.line&&(i=-1),t.line=i,t.lineAlign=n.get("lineAlign","start"),t.snapToLines=n.get("snapToLines",!0),t.size=n.get("size",100),t.align=n.get("align",u);var a=n.get("position","auto");"auto"===a&&50===l.position&&(a="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=a}(e,t)}function d(e){return e.replace(/<br(?: \/)?>/gi,"\n")}var f=function(){function e(){this.state="INITIAL",this.buffer="",this.decoder=new i,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var t=e.prototype;return t.parse=function(e){var t=this;function r(){var e=t.buffer,r=0;for(e=d(e);r<e.length&&"\r"!==e[r]&&"\n"!==e[r];)++r;var n=e.substr(0,r);return"\r"===e[r]&&++r,"\n"===e[r]&&++r,t.buffer=e.substr(r),n}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var i="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;var a=(i=r()).match(/^()?WEBVTT([ \t].*)?$/);if(!a||!a[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var s=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(s?s=!1:i=r(),t.state){case"HEADER":/:/.test(i)?o(i,(function(e,t){}),/:/):i||(t.state="ID");continue;case"NOTE":i||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(i)){t.state="NOTE";break}if(!i)continue;if(t.cue=new n.default(0,0,""),t.state="CUE",-1===i.indexOf("--\x3e")){t.cue.id=i;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{c(i,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var l=-1!==i.indexOf("--\x3e");if(!i||l&&(s=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(null===t.cue)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=i;continue;case"BADCUE":i||(t.state="ID")}}}catch(e){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this},t.flush=function(){try{if((this.cue||"HEADER"===this.state)&&(this.buffer+="\n\n",this.parse()),"INITIAL"===this.state||"BADWEBVTT"===this.state)throw new Error("Malformed WebVTT signature.")}catch(e){this.onparsingerror&&this.onparsingerror(e)}return this.onflush&&this.onflush(),this},e}()},"./src/utils/webvtt-parser.ts":
|
|
|
/*!************************************!*\
|
|
|
!*** ./src/utils/webvtt-parser.ts ***!
|
|
|
\************************************/
|
|
|
/*! exports provided: generateCueId, parseWebVTT */function(e,t,r){"use strict";r.r(t),r.d(t,"generateCueId",(function(){return d})),r.d(t,"parseWebVTT",(function(){return f}));var n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),i=r(/*! ./vttparser */"./src/utils/vttparser.ts"),a=r(/*! ../demux/id3 */"./src/demux/id3.ts"),s=r(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts"),o=r(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts"),l=/\r\n|\n\r|\n|\r/g,u=function(e,t,r){return void 0===r&&(r=0),e.substr(r,t.length)===t},c=function(e){for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()};function d(e,t,r){return c(e.toString())+c(t.toString())+c(r)}function f(e,t,r,c,f,h,g,p){var v,m=new i.VTTParser,y=Object(a.utf8ArrayToStr)(new Uint8Array(e)).trim().replace(l,"\n").split("\n"),b=[],E=Object(s.toMpegTsClockFromTimescale)(t,r),T="00:00.000",S=0,k=0,A=!0,x=!1;m.oncue=function(e){var t=c[f],r=c.ccOffset,n=(S-E)/9e4;if(null!=t&&t.new&&(void 0!==k?r=c.ccOffset=t.start:function(e,t,r){var n=e[t],i=e[n.prevCC];if(!i||!i.new&&n.new)return e.ccOffset=e.presentationOffset=n.start,void(n.new=!1);for(;null!==(a=i)&&void 0!==a&&a.new;){var a;e.ccOffset+=n.start-i.start,n.new=!1,i=e[(n=i).prevCC]}e.presentationOffset=r}(c,f,n)),n&&(r=n-c.presentationOffset),x){var i=e.endTime-e.startTime,a=Object(o.normalizePts)(9e4*(e.startTime+r-k),9e4*h)/9e4;e.startTime=a,e.endTime=a+i}var s=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(s)),e.id||(e.id=d(e.startTime,e.endTime,s)),e.endTime>0&&b.push(e)},m.onparsingerror=function(e){v=e},m.onflush=function(){v?p(v):g(b)},y.forEach((function(e){if(A){if(u(e,"X-TIMESTAMP-MAP=")){A=!1,x=!0,e.substr(16).split(",").forEach((function(e){u(e,"LOCAL:")?T=e.substr(6):u(e,"MPEGTS:")&&(S=parseInt(e.substr(7)))}));try{k=function(e){var t=parseInt(e.substr(-3)),r=parseInt(e.substr(-6,2)),i=parseInt(e.substr(-9,2)),a=e.length>9?parseInt(e.substr(0,e.indexOf(":"))):0;if(!(Object(n.isFiniteNumber)(t)&&Object(n.isFiniteNumber)(r)&&Object(n.isFiniteNumber)(i)&&Object(n.isFiniteNumber)(a)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+e);return t+=1e3*r,t+=6e4*i,t+=36e5*a}(T)/1e3}catch(e){x=!1,v=e}return}""===e&&(A=!1)}m.parse(e+"\n")})),m.flush()}},"./src/utils/xhr-loader.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./src/utils/xhr-loader.ts ***!
|
|
|
\*********************************/
|
|
|
/*! exports provided: default */function(e,t,r){"use strict";r.r(t);var n=r(/*! ../utils/logger */"./src/utils/logger.ts"),i=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),a=/^age:\s*[\d.]+\s*$/m,s=function(){function e(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=e?e.xhrSetup:null,this.stats=new i.LoadStats,this.retryDelay=0}var t=e.prototype;return t.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},t.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))},t.abort=function(){var e;this.abortInternal(),null!==(e=this.callbacks)&&void 0!==e&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},t.load=function(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.retryDelay=t.retryDelay,this.loadInternal()},t.loadInternal=function(){var e=this.config,t=this.context;if(e){var r=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0;var i=this.xhrSetup;try{if(i)try{i(r,t.url)}catch(e){r.open("GET",t.url,!0),i(r,t.url)}r.readyState||r.open("GET",t.url,!0);var a=this.context.headers;if(a)for(var s in a)r.setRequestHeader(s,a[s])}catch(e){return void this.callbacks.onError({code:r.status,text:e.message},t,r)}t.rangeEnd&&r.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),r.onreadystatechange=this.readystatechange.bind(this),r.onprogress=this.loadprogress.bind(this),r.responseType=t.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),e.timeout),r.send()}},t.readystatechange=function(){var e=this.context,t=this.loader,r=this.stats;if(e&&t){var i=t.readyState,a=this.config;if(!r.aborted&&i>=2)if(self.clearTimeout(this.requestTimeout),0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start)),4===i){t.onreadystatechange=null,t.onprogress=null;var s=t.status;if(s>=200&&s<300){var o,l;if(r.loading.end=Math.max(self.performance.now(),r.loading.first),l="arraybuffer"===e.responseType?(o=t.response).byteLength:(o=t.responseText).length,r.loaded=r.total=l,!this.callbacks)return;var u=this.callbacks.onProgress;if(u&&u(r,e,o,t),!this.callbacks)return;var c={url:t.responseURL,data:o};this.callbacks.onSuccess(c,r,e,t)}else r.retry>=a.maxRetry||s>=400&&s<499?(n.logger.error(s+" while loading "+e.url),this.callbacks.onError({code:s,text:t.statusText},e,t)):(n.logger.warn(s+" while loading "+e.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,a.maxRetryDelay),r.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.timeout)}},t.loadtimeout=function(){n.logger.warn("timeout while loading "+this.context.url);var e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))},t.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},t.getCacheAge=function(){var e=null;if(this.loader&&a.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},e}();t.default=s}}).default},e.exports=n())},vHTk:
|
|
|
/*!******************************************************!*\
|
|
|
!*** ./src/components/PreviewAll/index.less?modules ***!
|
|
|
\******************************************************/
|
|
|
/*! no static exports found */
|
|
|
/*! exports used: default */
|
|
|
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,t,r){e.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}}}]); |