tvbox/0130/道长JS/cat/lib/cat.js

1 line
475 KiB
JavaScript
Raw Permalink Normal View History

2024-02-12 02:37:55 +02:00
var e,pe,t=function(){return(t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},n={xml:!1,decodeEntities:!0},r={_useHtmlParser2:!0,xmlMode:!0};function i(e){return null!=e&&e.xml?"boolean"==typeof e.xml?r:t(t({},r),e.xml):null!=e?e:void 0}!function(e){e.Root="root",e.Text="text",e.Directive="directive",e.Comment="comment",e.Script="script",e.Style="style",e.Tag="tag",e.CDATA="cdata",e.Doctype="doctype"}(e=e||{});const s=e.Root,a=e.Text,o=e.Directive,c=e.Comment,u=e.Script,l=e.Style,h=e.Tag,f=e.CDATA,p=e.Doctype;class d{constructor(){this.parent=null,this.prev=null,this.next=null,this.startIndex=null,this.endIndex=null}get parentNode(){return this.parent}set parentNode(e){this.parent=e}get previousSibling(){return this.prev}set previousSibling(e){this.prev=e}get nextSibling(){return this.next}set nextSibling(e){this.next=e}cloneNode(e=!1){return L(this,e)}}class m extends d{constructor(e){super(),this.data=e}get nodeValue(){return this.data}set nodeValue(e){this.data=e}}class _ extends m{constructor(){super(...arguments),this.type=e.Text}get nodeType(){return 3}}class E extends m{constructor(){super(...arguments),this.type=e.Comment}get nodeType(){return 8}}class T extends m{constructor(t,n){super(n),this.name=t,this.type=e.Directive}get nodeType(){return 1}}class A extends d{constructor(e){super(),this.children=e}get firstChild(){var e;return null!=(e=this.children[0])?e:null}get lastChild(){return 0<this.children.length?this.children[this.children.length-1]:null}get childNodes(){return this.children}set childNodes(e){this.children=e}}class g extends A{constructor(){super(...arguments),this.type=e.CDATA}get nodeType(){return 4}}class v extends A{constructor(){super(...arguments),this.type=e.Root}get nodeType(){return 9}}class y extends A{constructor(t,n,r=[],i="script"===t?e.Script:"style"===t?e.Style:e.Tag){super(r),this.name=t,this.attribs=n,this.type=i}get nodeType(){return 1}get tagName(){return this.name}set tagName(e){this.name=e}get attributes(){return Object.keys(this.attribs).map(e=>{var t;return{name:e,value:this.attribs[e],namespace:null==(t=this["x-attribsNamespace"])?void 0:t[e],prefix:null==(t=this["x-attribsPrefix"])?void 0:t[e]}})}}function S(t){return t.type===e.Tag||t.type===e.Script||t.type===e.Style}function C(t){return t.type===e.CDATA}function N(t){return t.type===e.Text}function b(t){return t.type===e.Comment}function I(t){return t.type===e.Directive}function O(t){return t.type===e.Root}function k(e){return Object.prototype.hasOwnProperty.call(e,"children")}function L(e,t=!1){let n;if(N(e))n=new _(e.data);else if(b(e))n=new E(e.data);else if(S(e)){const r=t?D(e.children):[],i=new y(e.name,{...e.attribs},r);r.forEach(e=>e.parent=i),null!=e.namespace&&(i.namespace=e.namespace),e["x-attribsNamespace"]&&(i["x-attribsNamespace"]={...e["x-attribsNamespace"]}),e["x-attribsPrefix"]&&(i["x-attribsPrefix"]={...e["x-attribsPrefix"]}),n=i}else if(C(e)){const r=t?D(e.children):[],i=new g(r);r.forEach(e=>e.parent=i),n=i}else if(O(e)){const r=t?D(e.children):[],i=new v(r);r.forEach(e=>e.parent=i),e["x-mode"]&&(i["x-mode"]=e["x-mode"]),n=i}else{if(!I(e))throw new Error("Not implemented yet: "+e.type);{const t=new T(e.name,e.data);null!=e["x-name"]&&(t["x-name"]=e["x-name"],t["x-publicId"]=e["x-publicId"],t["x-systemId"]=e["x-systemId"]),n=t}}return n.startIndex=e.startIndex,n.endIndex=e.endIndex,null!=e.sourceCodeLocation&&(n.sourceCodeLocation=e.sourceCodeLocation),n}function D(e){var t=e.map(e=>L(e,!0));for(let e=1;e<t.length;e++)t[e].prev=t[e-1],t[e-1].next=t[e];return t}const R={withStartIndices:!1,withEndIndices:!1,xmlMode:!1};class w{constructor(e,t,n){this.dom=[],this.root=new v(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,"function"==typeof t&&(n=t,t=R),"object"==typeof e&&(t=e,e=void 0),this.callback=null!=e?e:null,this.options=null!=t?t:R,this.elementCB=null!=n?n:null}onparserinit(e){this.parser=e}onreset(){this.dom=[],this.root=n