UNPKG

@anoki/fse-ui

Version:

FSE UI components library

3 lines (2 loc) 3.16 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index.cjs715.js"),_=require("./index.cjs681.js"),h=require("./index.cjs716.js");var p;function y(){return p||(p=1,(function(d){var c=s.__exports&&s.__exports.__createBinding||(Object.create?(function(i,t,e,n){n===void 0&&(n=e);var o=Object.getOwnPropertyDescriptor(t,e);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[e]}}),Object.defineProperty(i,n,o)}):(function(i,t,e,n){n===void 0&&(n=e),i[n]=t[e]})),f=s.__exports&&s.__exports.__exportStar||function(i,t){for(var e in i)e!=="default"&&!Object.prototype.hasOwnProperty.call(t,e)&&c(t,i,e)};Object.defineProperty(d,"__esModule",{value:!0}),d.DomHandler=void 0;var a=_.__require(),r=h.__require();f(h.__require(),d);var l={withStartIndices:!1,withEndIndices:!1,xmlMode:!1},u=(function(){function i(t,e,n){this.dom=[],this.root=new r.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,typeof e=="function"&&(n=e,e=l),typeof t=="object"&&(e=t,t=void 0),this.callback=t??null,this.options=e??l,this.elementCB=n??null}return i.prototype.onparserinit=function(t){this.parser=t},i.prototype.onreset=function(){this.dom=[],this.root=new r.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null},i.prototype.onend=function(){this.done||(this.done=!0,this.parser=null,this.handleCallback(null))},i.prototype.onerror=function(t){this.handleCallback(t)},i.prototype.onclosetag=function(){this.lastNode=null;var t=this.tagStack.pop();this.options.withEndIndices&&(t.endIndex=this.parser.endIndex),this.elementCB&&this.elementCB(t)},i.prototype.onopentag=function(t,e){var n=this.options.xmlMode?a.ElementType.Tag:void 0,o=new r.Element(t,e,void 0,n);this.addNode(o),this.tagStack.push(o)},i.prototype.ontext=function(t){var e=this.lastNode;if(e&&e.type===a.ElementType.Text)e.data+=t,this.options.withEndIndices&&(e.endIndex=this.parser.endIndex);else{var n=new r.Text(t);this.addNode(n),this.lastNode=n}},i.prototype.oncomment=function(t){if(this.lastNode&&this.lastNode.type===a.ElementType.Comment){this.lastNode.data+=t;return}var e=new r.Comment(t);this.addNode(e),this.lastNode=e},i.prototype.oncommentend=function(){this.lastNode=null},i.prototype.oncdatastart=function(){var t=new r.Text(""),e=new r.CDATA([t]);this.addNode(e),t.parent=e,this.lastNode=t},i.prototype.oncdataend=function(){this.lastNode=null},i.prototype.onprocessinginstruction=function(t,e){var n=new r.ProcessingInstruction(t,e);this.addNode(n)},i.prototype.handleCallback=function(t){if(typeof this.callback=="function")this.callback(t,this.dom);else if(t)throw t},i.prototype.addNode=function(t){var e=this.tagStack[this.tagStack.length-1],n=e.children[e.children.length-1];this.options.withStartIndices&&(t.startIndex=this.parser.startIndex),this.options.withEndIndices&&(t.endIndex=this.parser.endIndex),e.children.push(t),n&&(t.prev=n,n.next=t),t.parent=e,this.lastNode=null},i})();d.DomHandler=u,d.default=u})(s.__exports)),s.__exports}exports.__require=y; //# sourceMappingURL=index.cjs679.js.map