UNPKG

@anoki/fse-ui

Version:

FSE UI components library

262 lines (261 loc) • 12.7 kB
import { __exports as c } from "./index.es713.js"; import { __require as N } from "./index.es680.js"; import { __require as E } from "./index.es714.js"; var T; function B() { if (T) return c; T = 1; var k = c && c.__createBinding || (Object.create ? (function(s, t, e, i) { i === void 0 && (i = e); var n = Object.getOwnPropertyDescriptor(t, e); (!n || ("get" in n ? !t.__esModule : n.writable || n.configurable)) && (n = { enumerable: !0, get: function() { return t[e]; } }), Object.defineProperty(s, i, n); }) : (function(s, t, e, i) { i === void 0 && (i = e), s[i] = t[e]; })), O = c && c.__setModuleDefault || (Object.create ? (function(s, t) { Object.defineProperty(s, "default", { enumerable: !0, value: t }); }) : function(s, t) { s.default = t; }), I = c && c.__importStar || function(s) { if (s && s.__esModule) return s; var t = {}; if (s != null) for (var e in s) e !== "default" && Object.prototype.hasOwnProperty.call(s, e) && k(t, s, e); return O(t, s), t; }; Object.defineProperty(c, "__esModule", { value: !0 }), c.Parser = void 0; var b = I(/* @__PURE__ */ N()), g = /* @__PURE__ */ E(), f = /* @__PURE__ */ new Set([ "input", "option", "optgroup", "select", "button", "datalist", "textarea" ]), o = /* @__PURE__ */ new Set(["p"]), m = /* @__PURE__ */ new Set(["thead", "tbody"]), _ = /* @__PURE__ */ new Set(["dd", "dt"]), w = /* @__PURE__ */ new Set(["rt", "rp"]), z = /* @__PURE__ */ new Map([ ["tr", /* @__PURE__ */ new Set(["tr", "th", "td"])], ["th", /* @__PURE__ */ new Set(["th"])], ["td", /* @__PURE__ */ new Set(["thead", "th", "td"])], ["body", /* @__PURE__ */ new Set(["head", "link", "script"])], ["li", /* @__PURE__ */ new Set(["li"])], ["p", o], ["h1", o], ["h2", o], ["h3", o], ["h4", o], ["h5", o], ["h6", o], ["select", f], ["input", f], ["output", f], ["button", f], ["datalist", f], ["textarea", f], ["option", /* @__PURE__ */ new Set(["option"])], ["optgroup", /* @__PURE__ */ new Set(["optgroup", "option"])], ["dd", _], ["dt", _], ["address", o], ["article", o], ["aside", o], ["blockquote", o], ["details", o], ["div", o], ["dl", o], ["fieldset", o], ["figcaption", o], ["figure", o], ["footer", o], ["form", o], ["header", o], ["hr", o], ["main", o], ["nav", o], ["ol", o], ["pre", o], ["section", o], ["table", o], ["ul", o], ["rt", w], ["rp", w], ["tbody", m], ["tfoot", m] ]), P = /* @__PURE__ */ new Set([ "area", "base", "basefont", "br", "col", "command", "embed", "frame", "hr", "img", "input", "isindex", "keygen", "link", "meta", "param", "source", "track", "wbr" ]), x = /* @__PURE__ */ new Set(["math", "svg"]), y = /* @__PURE__ */ new Set([ "mi", "mo", "mn", "ms", "mtext", "annotation-xml", "foreignobject", "desc", "title" ]), M = /\s|\//, j = ( /** @class */ (function() { function s(t, e) { e === void 0 && (e = {}); var i, n, r, h, a; this.options = e, this.startIndex = 0, this.endIndex = 0, this.openTagStart = 0, this.tagname = "", this.attribname = "", this.attribvalue = "", this.attribs = null, this.stack = [], this.foreignContext = [], this.buffers = [], this.bufferOffset = 0, this.writeIndex = 0, this.ended = !1, this.cbs = t ?? {}, this.lowerCaseTagNames = (i = e.lowerCaseTags) !== null && i !== void 0 ? i : !e.xmlMode, this.lowerCaseAttributeNames = (n = e.lowerCaseAttributeNames) !== null && n !== void 0 ? n : !e.xmlMode, this.tokenizer = new ((r = e.Tokenizer) !== null && r !== void 0 ? r : b.default)(this.options, this), (a = (h = this.cbs).onparserinit) === null || a === void 0 || a.call(h, this); } return s.prototype.ontext = function(t, e) { var i, n, r = this.getSlice(t, e); this.endIndex = e - 1, (n = (i = this.cbs).ontext) === null || n === void 0 || n.call(i, r), this.startIndex = e; }, s.prototype.ontextentity = function(t) { var e, i, n = this.tokenizer.getSectionStart(); this.endIndex = n - 1, (i = (e = this.cbs).ontext) === null || i === void 0 || i.call(e, (0, g.fromCodePoint)(t)), this.startIndex = n; }, s.prototype.isVoidElement = function(t) { return !this.options.xmlMode && P.has(t); }, s.prototype.onopentagname = function(t, e) { this.endIndex = e; var i = this.getSlice(t, e); this.lowerCaseTagNames && (i = i.toLowerCase()), this.emitOpenTag(i); }, s.prototype.emitOpenTag = function(t) { var e, i, n, r; this.openTagStart = this.startIndex, this.tagname = t; var h = !this.options.xmlMode && z.get(t); if (h) for (; this.stack.length > 0 && h.has(this.stack[this.stack.length - 1]); ) { var a = this.stack.pop(); (i = (e = this.cbs).onclosetag) === null || i === void 0 || i.call(e, a, !0); } this.isVoidElement(t) || (this.stack.push(t), x.has(t) ? this.foreignContext.push(!0) : y.has(t) && this.foreignContext.push(!1)), (r = (n = this.cbs).onopentagname) === null || r === void 0 || r.call(n, t), this.cbs.onopentag && (this.attribs = {}); }, s.prototype.endOpenTag = function(t) { var e, i; this.startIndex = this.openTagStart, this.attribs && ((i = (e = this.cbs).onopentag) === null || i === void 0 || i.call(e, this.tagname, this.attribs, t), this.attribs = null), this.cbs.onclosetag && this.isVoidElement(this.tagname) && this.cbs.onclosetag(this.tagname, !0), this.tagname = ""; }, s.prototype.onopentagend = function(t) { this.endIndex = t, this.endOpenTag(!1), this.startIndex = t + 1; }, s.prototype.onclosetag = function(t, e) { var i, n, r, h, a, u; this.endIndex = e; var l = this.getSlice(t, e); if (this.lowerCaseTagNames && (l = l.toLowerCase()), (x.has(l) || y.has(l)) && this.foreignContext.pop(), this.isVoidElement(l)) !this.options.xmlMode && l === "br" && ((n = (i = this.cbs).onopentagname) === null || n === void 0 || n.call(i, "br"), (h = (r = this.cbs).onopentag) === null || h === void 0 || h.call(r, "br", {}, !0), (u = (a = this.cbs).onclosetag) === null || u === void 0 || u.call(a, "br", !1)); else { var d = this.stack.lastIndexOf(l); if (d !== -1) if (this.cbs.onclosetag) for (var p = this.stack.length - d; p--; ) this.cbs.onclosetag(this.stack.pop(), p !== 0); else this.stack.length = d; else !this.options.xmlMode && l === "p" && (this.emitOpenTag("p"), this.closeCurrentTag(!0)); } this.startIndex = e + 1; }, s.prototype.onselfclosingtag = function(t) { this.endIndex = t, this.options.xmlMode || this.options.recognizeSelfClosing || this.foreignContext[this.foreignContext.length - 1] ? (this.closeCurrentTag(!1), this.startIndex = t + 1) : this.onopentagend(t); }, s.prototype.closeCurrentTag = function(t) { var e, i, n = this.tagname; this.endOpenTag(t), this.stack[this.stack.length - 1] === n && ((i = (e = this.cbs).onclosetag) === null || i === void 0 || i.call(e, n, !t), this.stack.pop()); }, s.prototype.onattribname = function(t, e) { this.startIndex = t; var i = this.getSlice(t, e); this.attribname = this.lowerCaseAttributeNames ? i.toLowerCase() : i; }, s.prototype.onattribdata = function(t, e) { this.attribvalue += this.getSlice(t, e); }, s.prototype.onattribentity = function(t) { this.attribvalue += (0, g.fromCodePoint)(t); }, s.prototype.onattribend = function(t, e) { var i, n; this.endIndex = e, (n = (i = this.cbs).onattribute) === null || n === void 0 || n.call(i, this.attribname, this.attribvalue, t === b.QuoteType.Double ? '"' : t === b.QuoteType.Single ? "'" : t === b.QuoteType.NoValue ? void 0 : null), this.attribs && !Object.prototype.hasOwnProperty.call(this.attribs, this.attribname) && (this.attribs[this.attribname] = this.attribvalue), this.attribvalue = ""; }, s.prototype.getInstructionName = function(t) { var e = t.search(M), i = e < 0 ? t : t.substr(0, e); return this.lowerCaseTagNames && (i = i.toLowerCase()), i; }, s.prototype.ondeclaration = function(t, e) { this.endIndex = e; var i = this.getSlice(t, e); if (this.cbs.onprocessinginstruction) { var n = this.getInstructionName(i); this.cbs.onprocessinginstruction("!".concat(n), "!".concat(i)); } this.startIndex = e + 1; }, s.prototype.onprocessinginstruction = function(t, e) { this.endIndex = e; var i = this.getSlice(t, e); if (this.cbs.onprocessinginstruction) { var n = this.getInstructionName(i); this.cbs.onprocessinginstruction("?".concat(n), "?".concat(i)); } this.startIndex = e + 1; }, s.prototype.oncomment = function(t, e, i) { var n, r, h, a; this.endIndex = e, (r = (n = this.cbs).oncomment) === null || r === void 0 || r.call(n, this.getSlice(t, e - i)), (a = (h = this.cbs).oncommentend) === null || a === void 0 || a.call(h), this.startIndex = e + 1; }, s.prototype.oncdata = function(t, e, i) { var n, r, h, a, u, l, d, p, S, v; this.endIndex = e; var C = this.getSlice(t, e - i); this.options.xmlMode || this.options.recognizeCDATA ? ((r = (n = this.cbs).oncdatastart) === null || r === void 0 || r.call(n), (a = (h = this.cbs).ontext) === null || a === void 0 || a.call(h, C), (l = (u = this.cbs).oncdataend) === null || l === void 0 || l.call(u)) : ((p = (d = this.cbs).oncomment) === null || p === void 0 || p.call(d, "[CDATA[".concat(C, "]]")), (v = (S = this.cbs).oncommentend) === null || v === void 0 || v.call(S)), this.startIndex = e + 1; }, s.prototype.onend = function() { var t, e; if (this.cbs.onclosetag) { this.endIndex = this.startIndex; for (var i = this.stack.length; i > 0; this.cbs.onclosetag(this.stack[--i], !0)) ; } (e = (t = this.cbs).onend) === null || e === void 0 || e.call(t); }, s.prototype.reset = function() { var t, e, i, n; (e = (t = this.cbs).onreset) === null || e === void 0 || e.call(t), this.tokenizer.reset(), this.tagname = "", this.attribname = "", this.attribs = null, this.stack.length = 0, this.startIndex = 0, this.endIndex = 0, (n = (i = this.cbs).onparserinit) === null || n === void 0 || n.call(i, this), this.buffers.length = 0, this.bufferOffset = 0, this.writeIndex = 0, this.ended = !1; }, s.prototype.parseComplete = function(t) { this.reset(), this.end(t); }, s.prototype.getSlice = function(t, e) { for (; t - this.bufferOffset >= this.buffers[0].length; ) this.shiftBuffer(); for (var i = this.buffers[0].slice(t - this.bufferOffset, e - this.bufferOffset); e - this.bufferOffset > this.buffers[0].length; ) this.shiftBuffer(), i += this.buffers[0].slice(0, e - this.bufferOffset); return i; }, s.prototype.shiftBuffer = function() { this.bufferOffset += this.buffers[0].length, this.writeIndex--, this.buffers.shift(); }, s.prototype.write = function(t) { var e, i; if (this.ended) { (i = (e = this.cbs).onerror) === null || i === void 0 || i.call(e, new Error(".write() after done!")); return; } this.buffers.push(t), this.tokenizer.running && (this.tokenizer.write(t), this.writeIndex++); }, s.prototype.end = function(t) { var e, i; if (this.ended) { (i = (e = this.cbs).onerror) === null || i === void 0 || i.call(e, new Error(".end() after done!")); return; } t && this.write(t), this.ended = !0, this.tokenizer.end(); }, s.prototype.pause = function() { this.tokenizer.pause(); }, s.prototype.resume = function() { for (this.tokenizer.resume(); this.tokenizer.running && this.writeIndex < this.buffers.length; ) this.tokenizer.write(this.buffers[this.writeIndex++]); this.ended && this.tokenizer.end(); }, s.prototype.parseChunk = function(t) { this.write(t); }, s.prototype.done = function(t) { this.end(t); }, s; })() ); return c.Parser = j, c; } export { B as __require }; //# sourceMappingURL=index.es678.js.map