@anoki/fse-ui
Version:
FSE UI components library
89 lines (88 loc) • 4.21 kB
JavaScript
import { __exports as s } from "./index.es715.js";
import { __require as m } from "./index.es681.js";
import { __require as u } from "./index.es716.js";
var p;
function N() {
return p ? s : (p = 1, (function(a) {
var f = s && s.__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];
})), c = s && s.__exportStar || function(i, t) {
for (var e in i) e !== "default" && !Object.prototype.hasOwnProperty.call(t, e) && f(t, i, e);
};
Object.defineProperty(a, "__esModule", { value: !0 }), a.DomHandler = void 0;
var d = /* @__PURE__ */ m(), r = /* @__PURE__ */ u();
c(/* @__PURE__ */ u(), a);
var l = {
withStartIndices: !1,
withEndIndices: !1,
xmlMode: !1
}, h = (
/** @class */
(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 ? d.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 === d.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 === d.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;
})()
);
a.DomHandler = h, a.default = h;
})(s), s);
}
export {
N as __require
};
//# sourceMappingURL=index.es679.js.map