diff --git a/.github/workflows/license-check.yaml b/.github/workflows/license-check.yaml index 639d7c16..ebadf5b5 100644 --- a/.github/workflows/license-check.yaml +++ b/.github/workflows/license-check.yaml @@ -10,4 +10,4 @@ jobs: steps: - uses: actions/checkout@v3 - name: Check License Header - uses: apache/skywalking-eyes/header@5dfa68f93380a5e57259faaf95088b7f133b5778 \ No newline at end of file + uses: apache/skywalking-eyes/header@5dfa68f93380a5e57259faaf95088b7f133b5778 diff --git a/.licenserc.yaml b/.licenserc.yaml index 27284bb8..314fd797 100644 --- a/.licenserc.yaml +++ b/.licenserc.yaml @@ -16,4 +16,4 @@ header: - '**/*.md' - 'LICENSE' - comment: on-failure \ No newline at end of file + comment: on-failure diff --git a/components/dist/asciidoc.css b/components/dist/asciidoc.css index dc2b68e3..ab7a7507 100644 --- a/components/dist/asciidoc.css +++ b/components/dist/asciidoc.css @@ -32,6 +32,14 @@ @apply text-accent; } + .asciidoc-body .admonition-content .paragraph { + @apply mb-1 last:mb-0; + } + + .asciidoc-body .admonition-content > div { + @apply normal-case; + } + .asciidoc-body img { @apply mx-auto h-auto w-auto w-full rounded-lg border border-tertiary; max-height: max(500px, 75vh); diff --git a/components/dist/index.d.ts b/components/dist/index.d.ts index 0522b874..0d380474 100644 --- a/components/dist/index.d.ts +++ b/components/dist/index.d.ts @@ -15,6 +15,9 @@ declare const AsciiDocBlocks: { Table: ({ node }: { node: _asciidoctor_core_types.Table; }) => react_jsx_runtime.JSX.Element; + Section: ({ node }: { + node: _asciidoctor_core_types.Section; + }) => react_jsx_runtime.JSX.Element; }; type BadgeColor = 'default' | 'destructive' | 'notice' | 'neutral' | 'purple' | 'blue'; diff --git a/components/dist/index.js b/components/dist/index.js index 3aa2784e..59fe497e 100644 --- a/components/dist/index.js +++ b/components/dist/index.js @@ -1182,11 +1182,7 @@ var require_Tokenizer = __commonJS({ State2[State2["BeforeSpecialS"] = 22] = "BeforeSpecialS"; State2[State2["SpecialStartSequence"] = 23] = "SpecialStartSequence"; State2[State2["InSpecialTag"] = 24] = "InSpecialTag"; - State2[State2["BeforeEntity"] = 25] = "BeforeEntity"; - State2[State2["BeforeNumericEntity"] = 26] = "BeforeNumericEntity"; - State2[State2["InNamedEntity"] = 27] = "InNamedEntity"; - State2[State2["InNumericEntity"] = 28] = "InNumericEntity"; - State2[State2["InHexEntity"] = 29] = "InHexEntity"; + State2[State2["InEntity"] = 25] = "InEntity"; })(State || (State = {})); function isWhitespace(c) { return c === CharCodes.Space || c === CharCodes.NewLine || c === CharCodes.Tab || c === CharCodes.FormFeed || c === CharCodes.CarriageReturn; @@ -1194,15 +1190,9 @@ var require_Tokenizer = __commonJS({ function isEndOfTagSection(c) { return c === CharCodes.Slash || c === CharCodes.Gt || isWhitespace(c); } - function isNumber(c) { - return c >= CharCodes.Zero && c <= CharCodes.Nine; - } function isASCIIAlpha(c) { return c >= CharCodes.LowerA && c <= CharCodes.LowerZ || c >= CharCodes.UpperA && c <= CharCodes.UpperZ; } - function isHexDigit(c) { - return c >= CharCodes.UpperA && c <= CharCodes.UpperF || c >= CharCodes.LowerA && c <= CharCodes.LowerF; - } var QuoteType; (function(QuoteType2) { QuoteType2[QuoteType2["NoValue"] = 0] = "NoValue"; @@ -1224,24 +1214,24 @@ var require_Tokenizer = __commonJS({ function() { function Tokenizer2(_a, cbs) { var _b = _a.xmlMode, xmlMode = _b === void 0 ? false : _b, _c = _a.decodeEntities, decodeEntities = _c === void 0 ? true : _c; + var _this = this; this.cbs = cbs; this.state = State.Text; this.buffer = ""; this.sectionStart = 0; this.index = 0; + this.entityStart = 0; this.baseState = State.Text; this.isSpecial = false; this.running = true; this.offset = 0; this.currentSequence = void 0; this.sequenceIndex = 0; - this.trieIndex = 0; - this.trieCurrent = 0; - this.entityResult = 0; - this.entityExcess = 0; this.xmlMode = xmlMode; this.decodeEntities = decodeEntities; - this.entityTrie = xmlMode ? decode_js_1.xmlDecodeTree : decode_js_1.htmlDecodeTree; + this.entityDecoder = new decode_js_1.EntityDecoder(xmlMode ? decode_js_1.xmlDecodeTree : decode_js_1.htmlDecodeTree, function(cp, consumed) { + return _this.emitCodePoint(cp, consumed); + }); } Tokenizer2.prototype.reset = function() { this.state = State.Text; @@ -1271,12 +1261,6 @@ var require_Tokenizer = __commonJS({ this.parse(); } }; - Tokenizer2.prototype.getIndex = function() { - return this.index; - }; - Tokenizer2.prototype.getSectionStart = function() { - return this.sectionStart; - }; Tokenizer2.prototype.stateText = function(c) { if (c === CharCodes.Lt || !this.decodeEntities && this.fastForwardTo(CharCodes.Lt)) { if (this.index > this.sectionStart) { @@ -1285,7 +1269,7 @@ var require_Tokenizer = __commonJS({ this.state = State.BeforeTagName; this.sectionStart = this.index; } else if (this.decodeEntities && c === CharCodes.Amp) { - this.state = State.BeforeEntity; + this.startEntity(); } }; Tokenizer2.prototype.stateSpecialStartSequence = function(c) { @@ -1329,7 +1313,7 @@ var require_Tokenizer = __commonJS({ } else if (this.sequenceIndex === 0) { if (this.currentSequence === Sequences.TitleEnd) { if (this.decodeEntities && c === CharCodes.Amp) { - this.state = State.BeforeEntity; + this.startEntity(); } } else if (this.fastForwardTo(CharCodes.Lt)) { this.sequenceIndex = 1; @@ -1440,7 +1424,6 @@ var require_Tokenizer = __commonJS({ Tokenizer2.prototype.stateAfterClosingTagName = function(c) { if (c === CharCodes.Gt || this.fastForwardTo(CharCodes.Gt)) { this.state = State.Text; - this.baseState = State.Text; this.sectionStart = this.index + 1; } }; @@ -1453,7 +1436,6 @@ var require_Tokenizer = __commonJS({ } else { this.state = State.Text; } - this.baseState = this.state; this.sectionStart = this.index + 1; } else if (c === CharCodes.Slash) { this.state = State.InSelfClosingTag; @@ -1466,7 +1448,6 @@ var require_Tokenizer = __commonJS({ if (c === CharCodes.Gt) { this.cbs.onselfclosingtag(this.index); this.state = State.Text; - this.baseState = State.Text; this.sectionStart = this.index + 1; this.isSpecial = false; } else if (!isWhitespace(c)) { @@ -1515,8 +1496,7 @@ var require_Tokenizer = __commonJS({ this.cbs.onattribend(quote === CharCodes.DoubleQuote ? QuoteType.Double : QuoteType.Single, this.index); this.state = State.BeforeAttributeName; } else if (this.decodeEntities && c === CharCodes.Amp) { - this.baseState = this.state; - this.state = State.BeforeEntity; + this.startEntity(); } }; Tokenizer2.prototype.stateInAttributeValueDoubleQuotes = function(c) { @@ -1533,8 +1513,7 @@ var require_Tokenizer = __commonJS({ this.state = State.BeforeAttributeName; this.stateBeforeAttributeName(c); } else if (this.decodeEntities && c === CharCodes.Amp) { - this.baseState = this.state; - this.state = State.BeforeEntity; + this.startEntity(); } }; Tokenizer2.prototype.stateBeforeDeclaration = function(c) { @@ -1587,126 +1566,23 @@ var require_Tokenizer = __commonJS({ this.stateInTagName(c); } }; - Tokenizer2.prototype.stateBeforeEntity = function(c) { - this.entityExcess = 1; - this.entityResult = 0; - if (c === CharCodes.Number) { - this.state = State.BeforeNumericEntity; - } else if (c === CharCodes.Amp) { - } else { - this.trieIndex = 0; - this.trieCurrent = this.entityTrie[0]; - this.state = State.InNamedEntity; - this.stateInNamedEntity(c); - } - }; - Tokenizer2.prototype.stateInNamedEntity = function(c) { - this.entityExcess += 1; - this.trieIndex = (0, decode_js_1.determineBranch)(this.entityTrie, this.trieCurrent, this.trieIndex + 1, c); - if (this.trieIndex < 0) { - this.emitNamedEntity(); - this.index--; - return; - } - this.trieCurrent = this.entityTrie[this.trieIndex]; - var masked = this.trieCurrent & decode_js_1.BinTrieFlags.VALUE_LENGTH; - if (masked) { - var valueLength = (masked >> 14) - 1; - if (!this.allowLegacyEntity() && c !== CharCodes.Semi) { - this.trieIndex += valueLength; - } else { - var entityStart = this.index - this.entityExcess + 1; - if (entityStart > this.sectionStart) { - this.emitPartial(this.sectionStart, entityStart); - } - this.entityResult = this.trieIndex; - this.trieIndex += valueLength; - this.entityExcess = 0; - this.sectionStart = this.index + 1; - if (valueLength === 0) { - this.emitNamedEntity(); - } - } - } - }; - Tokenizer2.prototype.emitNamedEntity = function() { - this.state = this.baseState; - if (this.entityResult === 0) { - return; - } - var valueLength = (this.entityTrie[this.entityResult] & decode_js_1.BinTrieFlags.VALUE_LENGTH) >> 14; - switch (valueLength) { - case 1: { - this.emitCodePoint(this.entityTrie[this.entityResult] & ~decode_js_1.BinTrieFlags.VALUE_LENGTH); - break; - } - case 2: { - this.emitCodePoint(this.entityTrie[this.entityResult + 1]); - break; - } - case 3: { - this.emitCodePoint(this.entityTrie[this.entityResult + 1]); - this.emitCodePoint(this.entityTrie[this.entityResult + 2]); - } - } - }; - Tokenizer2.prototype.stateBeforeNumericEntity = function(c) { - if ((c | 32) === CharCodes.LowerX) { - this.entityExcess++; - this.state = State.InHexEntity; - } else { - this.state = State.InNumericEntity; - this.stateInNumericEntity(c); - } + Tokenizer2.prototype.startEntity = function() { + this.baseState = this.state; + this.state = State.InEntity; + this.entityStart = this.index; + this.entityDecoder.startEntity(this.xmlMode ? decode_js_1.DecodingMode.Strict : this.baseState === State.Text || this.baseState === State.InSpecialTag ? decode_js_1.DecodingMode.Legacy : decode_js_1.DecodingMode.Attribute); }; - Tokenizer2.prototype.emitNumericEntity = function(strict) { - var entityStart = this.index - this.entityExcess - 1; - var numberStart = entityStart + 2 + Number(this.state === State.InHexEntity); - if (numberStart !== this.index) { - if (entityStart > this.sectionStart) { - this.emitPartial(this.sectionStart, entityStart); + Tokenizer2.prototype.stateInEntity = function() { + var length = this.entityDecoder.write(this.buffer, this.index - this.offset); + if (length >= 0) { + this.state = this.baseState; + if (length === 0) { + this.index = this.entityStart; } - this.sectionStart = this.index + Number(strict); - this.emitCodePoint((0, decode_js_1.replaceCodePoint)(this.entityResult)); - } - this.state = this.baseState; - }; - Tokenizer2.prototype.stateInNumericEntity = function(c) { - if (c === CharCodes.Semi) { - this.emitNumericEntity(true); - } else if (isNumber(c)) { - this.entityResult = this.entityResult * 10 + (c - CharCodes.Zero); - this.entityExcess++; } else { - if (this.allowLegacyEntity()) { - this.emitNumericEntity(false); - } else { - this.state = this.baseState; - } - this.index--; + this.index = this.offset + this.buffer.length - 1; } }; - Tokenizer2.prototype.stateInHexEntity = function(c) { - if (c === CharCodes.Semi) { - this.emitNumericEntity(true); - } else if (isNumber(c)) { - this.entityResult = this.entityResult * 16 + (c - CharCodes.Zero); - this.entityExcess++; - } else if (isHexDigit(c)) { - this.entityResult = this.entityResult * 16 + ((c | 32) - CharCodes.LowerA + 10); - this.entityExcess++; - } else { - if (this.allowLegacyEntity()) { - this.emitNumericEntity(false); - } else { - this.state = this.baseState; - } - this.index--; - } - }; - Tokenizer2.prototype.allowLegacyEntity = function() { - return !this.xmlMode && (this.baseState === State.Text || this.baseState === State.InSpecialTag); - }; Tokenizer2.prototype.cleanup = function() { if (this.running && this.sectionStart !== this.index) { if (this.state === State.Text || this.state === State.InSpecialTag && this.sequenceIndex === 0) { @@ -1821,68 +1697,54 @@ var require_Tokenizer = __commonJS({ this.stateInProcessingInstruction(c); break; } - case State.InNamedEntity: { - this.stateInNamedEntity(c); + case State.InEntity: { + this.stateInEntity(); break; } - case State.BeforeEntity: { - this.stateBeforeEntity(c); - break; - } - case State.InHexEntity: { - this.stateInHexEntity(c); - break; - } - case State.InNumericEntity: { - this.stateInNumericEntity(c); - break; - } - default: { - this.stateBeforeNumericEntity(c); - } } this.index++; } this.cleanup(); }; Tokenizer2.prototype.finish = function() { - if (this.state === State.InNamedEntity) { - this.emitNamedEntity(); - } - if (this.sectionStart < this.index) { - this.handleTrailingData(); + if (this.state === State.InEntity) { + this.entityDecoder.end(); + this.state = this.baseState; } + this.handleTrailingData(); this.cbs.onend(); }; Tokenizer2.prototype.handleTrailingData = function() { var endIndex = this.buffer.length + this.offset; + if (this.sectionStart >= endIndex) { + return; + } if (this.state === State.InCommentLike) { if (this.currentSequence === Sequences.CdataEnd) { this.cbs.oncdata(this.sectionStart, endIndex, 0); } else { this.cbs.oncomment(this.sectionStart, endIndex, 0); } - } else if (this.state === State.InNumericEntity && this.allowLegacyEntity()) { - this.emitNumericEntity(false); - } else if (this.state === State.InHexEntity && this.allowLegacyEntity()) { - this.emitNumericEntity(false); } else if (this.state === State.InTagName || this.state === State.BeforeAttributeName || this.state === State.BeforeAttributeValue || this.state === State.AfterAttributeName || this.state === State.InAttributeName || this.state === State.InAttributeValueSq || this.state === State.InAttributeValueDq || this.state === State.InAttributeValueNq || this.state === State.InClosingTagName) { } else { this.cbs.ontext(this.sectionStart, endIndex); } }; - Tokenizer2.prototype.emitPartial = function(start, endIndex) { - if (this.baseState !== State.Text && this.baseState !== State.InSpecialTag) { - this.cbs.onattribdata(start, endIndex); - } else { - this.cbs.ontext(start, endIndex); - } - }; - Tokenizer2.prototype.emitCodePoint = function(cp) { + Tokenizer2.prototype.emitCodePoint = function(cp, consumed) { if (this.baseState !== State.Text && this.baseState !== State.InSpecialTag) { + if (this.sectionStart < this.entityStart) { + this.cbs.onattribdata(this.sectionStart, this.entityStart); + } + this.sectionStart = this.entityStart + consumed; + this.index = this.sectionStart - 1; this.cbs.onattribentity(cp); } else { - this.cbs.ontextentity(cp); + if (this.sectionStart < this.entityStart) { + this.cbs.ontext(this.sectionStart, this.entityStart); + } + this.sectionStart = this.entityStart + consumed; + this.index = this.sectionStart - 1; + this.cbs.ontextentity(cp, this.sectionStart); } }; return Tokenizer2; @@ -2045,15 +1907,16 @@ var require_Parser = __commonJS({ this.attribvalue = ""; this.attribs = null; this.stack = []; - this.foreignContext = []; this.buffers = []; this.bufferOffset = 0; this.writeIndex = 0; this.ended = false; this.cbs = cbs !== null && cbs !== void 0 ? cbs : {}; - this.lowerCaseTagNames = (_a = options.lowerCaseTags) !== null && _a !== void 0 ? _a : !options.xmlMode; - this.lowerCaseAttributeNames = (_b = options.lowerCaseAttributeNames) !== null && _b !== void 0 ? _b : !options.xmlMode; + this.htmlMode = !this.options.xmlMode; + this.lowerCaseTagNames = (_a = options.lowerCaseTags) !== null && _a !== void 0 ? _a : this.htmlMode; + this.lowerCaseAttributeNames = (_b = options.lowerCaseAttributeNames) !== null && _b !== void 0 ? _b : this.htmlMode; this.tokenizer = new ((_c = options.Tokenizer) !== null && _c !== void 0 ? _c : Tokenizer_js_1.default)(this.options, this); + this.foreignContext = [!this.htmlMode]; (_e = (_d = this.cbs).onparserinit) === null || _e === void 0 ? void 0 : _e.call(_d, this); } Parser2.prototype.ontext = function(start, endIndex) { @@ -2063,15 +1926,14 @@ var require_Parser = __commonJS({ (_b = (_a = this.cbs).ontext) === null || _b === void 0 ? void 0 : _b.call(_a, data); this.startIndex = endIndex; }; - Parser2.prototype.ontextentity = function(cp) { + Parser2.prototype.ontextentity = function(cp, endIndex) { var _a, _b; - var index = this.tokenizer.getSectionStart(); - this.endIndex = index - 1; + this.endIndex = endIndex - 1; (_b = (_a = this.cbs).ontext) === null || _b === void 0 ? void 0 : _b.call(_a, (0, decode_js_1.fromCodePoint)(cp)); - this.startIndex = index; + this.startIndex = endIndex; }; Parser2.prototype.isVoidElement = function(name) { - return !this.options.xmlMode && voidElements.has(name); + return this.htmlMode && voidElements.has(name); }; Parser2.prototype.onopentagname = function(start, endIndex) { this.endIndex = endIndex; @@ -2085,19 +1947,21 @@ var require_Parser = __commonJS({ var _a, _b, _c, _d; this.openTagStart = this.startIndex; this.tagname = name; - var impliesClose = !this.options.xmlMode && openImpliesClose.get(name); + var impliesClose = this.htmlMode && openImpliesClose.get(name); if (impliesClose) { - while (this.stack.length > 0 && impliesClose.has(this.stack[this.stack.length - 1])) { - var element = this.stack.pop(); + while (this.stack.length > 0 && impliesClose.has(this.stack[0])) { + var element = this.stack.shift(); (_b = (_a = this.cbs).onclosetag) === null || _b === void 0 ? void 0 : _b.call(_a, element, true); } } if (!this.isVoidElement(name)) { - this.stack.push(name); - if (foreignContextElements.has(name)) { - this.foreignContext.push(true); - } else if (htmlIntegrationElements.has(name)) { - this.foreignContext.push(false); + this.stack.unshift(name); + if (this.htmlMode) { + if (foreignContextElements.has(name)) { + this.foreignContext.unshift(true); + } else if (htmlIntegrationElements.has(name)) { + this.foreignContext.unshift(false); + } } } (_d = (_c = this.cbs).onopentagname) === null || _d === void 0 ? void 0 : _d.call(_c, name); @@ -2122,39 +1986,36 @@ var require_Parser = __commonJS({ this.startIndex = endIndex + 1; }; Parser2.prototype.onclosetag = function(start, endIndex) { - var _a, _b, _c, _d, _e, _f; + var _a, _b, _c, _d, _e, _f, _g, _h; this.endIndex = endIndex; var name = this.getSlice(start, endIndex); if (this.lowerCaseTagNames) { name = name.toLowerCase(); } - if (foreignContextElements.has(name) || htmlIntegrationElements.has(name)) { - this.foreignContext.pop(); + if (this.htmlMode && (foreignContextElements.has(name) || htmlIntegrationElements.has(name))) { + this.foreignContext.shift(); } if (!this.isVoidElement(name)) { - var pos = this.stack.lastIndexOf(name); + var pos = this.stack.indexOf(name); if (pos !== -1) { - if (this.cbs.onclosetag) { - var count = this.stack.length - pos; - while (count--) { - this.cbs.onclosetag(this.stack.pop(), count !== 0); - } - } else - this.stack.length = pos; - } else if (!this.options.xmlMode && name === "p") { + for (var index = 0; index <= pos; index++) { + var element = this.stack.shift(); + (_b = (_a = this.cbs).onclosetag) === null || _b === void 0 ? void 0 : _b.call(_a, element, index !== pos); + } + } else if (this.htmlMode && name === "p") { this.emitOpenTag("p"); this.closeCurrentTag(true); } - } else if (!this.options.xmlMode && name === "br") { - (_b = (_a = this.cbs).onopentagname) === null || _b === void 0 ? void 0 : _b.call(_a, "br"); - (_d = (_c = this.cbs).onopentag) === null || _d === void 0 ? void 0 : _d.call(_c, "br", {}, true); - (_f = (_e = this.cbs).onclosetag) === null || _f === void 0 ? void 0 : _f.call(_e, "br", false); + } else if (this.htmlMode && name === "br") { + (_d = (_c = this.cbs).onopentagname) === null || _d === void 0 ? void 0 : _d.call(_c, "br"); + (_f = (_e = this.cbs).onopentag) === null || _f === void 0 ? void 0 : _f.call(_e, "br", {}, true); + (_h = (_g = this.cbs).onclosetag) === null || _h === void 0 ? void 0 : _h.call(_g, "br", false); } this.startIndex = endIndex + 1; }; Parser2.prototype.onselfclosingtag = function(endIndex) { this.endIndex = endIndex; - if (this.options.xmlMode || this.options.recognizeSelfClosing || this.foreignContext[this.foreignContext.length - 1]) { + if (this.options.recognizeSelfClosing || this.foreignContext[0]) { this.closeCurrentTag(false); this.startIndex = endIndex + 1; } else { @@ -2165,9 +2026,9 @@ var require_Parser = __commonJS({ var _a, _b; var name = this.tagname; this.endOpenTag(isOpenImplied); - if (this.stack[this.stack.length - 1] === name) { + if (this.stack[0] === name) { (_b = (_a = this.cbs).onclosetag) === null || _b === void 0 ? void 0 : _b.call(_a, name, !isOpenImplied); - this.stack.pop(); + this.stack.shift(); } }; Parser2.prototype.onattribname = function(start, endIndex) { @@ -2227,7 +2088,7 @@ var require_Parser = __commonJS({ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; this.endIndex = endIndex; var value = this.getSlice(start, endIndex - offset2); - if (this.options.xmlMode || this.options.recognizeCDATA) { + if (!this.htmlMode || this.options.recognizeCDATA) { (_b = (_a = this.cbs).oncdatastart) === null || _b === void 0 ? void 0 : _b.call(_a); (_d = (_c = this.cbs).ontext) === null || _d === void 0 ? void 0 : _d.call(_c, value); (_f = (_e = this.cbs).oncdataend) === null || _f === void 0 ? void 0 : _f.call(_e); @@ -2241,8 +2102,9 @@ var require_Parser = __commonJS({ var _a, _b; if (this.cbs.onclosetag) { this.endIndex = this.startIndex; - for (var index = this.stack.length; index > 0; this.cbs.onclosetag(this.stack[--index], true)) - ; + for (var index = 0; index < this.stack.length; index++) { + this.cbs.onclosetag(this.stack[index], true); + } } (_b = (_a = this.cbs).onend) === null || _b === void 0 ? void 0 : _b.call(_a); }; @@ -2258,6 +2120,8 @@ var require_Parser = __commonJS({ this.endIndex = 0; (_d = (_c = this.cbs).onparserinit) === null || _d === void 0 ? void 0 : _d.call(_c, this); this.buffers.length = 0; + this.foreignContext.length = 0; + this.foreignContext.unshift(!this.htmlMode); this.bufferOffset = 0; this.writeIndex = 0; this.ended = false; @@ -3094,7 +2958,7 @@ var require_lib4 = __commonJS({ EncodingMode2[EncodingMode2["Attribute"] = 3] = "Attribute"; EncodingMode2[EncodingMode2["Text"] = 4] = "Text"; })(EncodingMode = exports.EncodingMode || (exports.EncodingMode = {})); - function decode(data, options) { + function decode2(data, options) { if (options === void 0) { options = EntityLevel.XML; } @@ -3105,7 +2969,7 @@ var require_lib4 = __commonJS({ } return (0, decode_js_1.decodeXML)(data); } - exports.decode = decode; + exports.decode = decode2; function decodeStrict(data, options) { var _a; if (options === void 0) { @@ -3113,7 +2977,7 @@ var require_lib4 = __commonJS({ } var opts = typeof options === "number" ? { level: options } : options; (_a = opts.mode) !== null && _a !== void 0 ? _a : opts.mode = decode_js_1.DecodingMode.Strict; - return decode(data, opts); + return decode2(data, opts); } exports.decodeStrict = decodeStrict; function encode(data, options) { @@ -4284,7 +4148,7 @@ var require_lib7 = __commonJS({ return mod && mod.__esModule ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); - exports.DomUtils = exports.parseFeed = exports.getFeed = exports.ElementType = exports.Tokenizer = exports.createDomStream = exports.parseDOM = exports.parseDocument = exports.DefaultHandler = exports.DomHandler = exports.Parser = void 0; + exports.DomUtils = exports.parseFeed = exports.getFeed = exports.ElementType = exports.Tokenizer = exports.createDomStream = exports.createDocumentStream = exports.parseDOM = exports.parseDocument = exports.DefaultHandler = exports.DomHandler = exports.Parser = void 0; var Parser_js_1 = require_Parser(); var Parser_js_2 = require_Parser(); Object.defineProperty(exports, "Parser", { enumerable: true, get: function() { @@ -4308,6 +4172,13 @@ var require_lib7 = __commonJS({ return parseDocument(data, options).children; } exports.parseDOM = parseDOM; + function createDocumentStream(callback, options, elementCallback) { + var handler = new domhandler_1.DomHandler(function(error) { + return callback(error, handler.root); + }, options, elementCallback); + return new Parser_js_1.Parser(handler, options); + } + exports.createDocumentStream = createDocumentStream; function createDomStream(callback, options, elementCallback) { var handler = new domhandler_1.DomHandler(callback, options, elementCallback); return new Parser_js_1.Parser(handler, options); @@ -6164,7 +6035,7 @@ var require_style_to_object = __commonJS({ var require_utilities2 = __commonJS({ "node_modules/style-to-js/cjs/utilities.js"(exports) { "use strict"; - exports.__esModule = true; + Object.defineProperty(exports, "__esModule", { value: true }); exports.camelCase = void 0; var CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9-]+$/; var HYPHEN_REGEX = /-([a-z])/g; @@ -6206,7 +6077,7 @@ var require_cjs = __commonJS({ var __importDefault = exports && exports.__importDefault || function(mod) { return mod && mod.__esModule ? mod : { "default": mod }; }; - exports.__esModule = true; + Object.defineProperty(exports, "__esModule", { value: true }); var style_to_object_1 = __importDefault(require_style_to_object()); var utilities_1 = require_utilities2(); function StyleToJS(style, options) { @@ -6214,14 +6085,14 @@ var require_cjs = __commonJS({ if (!style || typeof style !== "string") { return output; } - (0, style_to_object_1["default"])(style, function(property, value) { + (0, style_to_object_1.default)(style, function(property, value) { if (property && value) { output[(0, utilities_1.camelCase)(property, options)] = value; } }); return output; } - exports["default"] = StyleToJS; + exports.default = StyleToJS; } }); @@ -6235,13 +6106,11 @@ var require_utilities3 = __commonJS({ if (!obj || typeof obj !== "object") { throw new TypeError("First argument must be an object"); } - var key; - var value; var isOverridePresent = typeof override === "function"; var overrides = {}; var result = {}; - for (key in obj) { - value = obj[key]; + for (var key in obj) { + var value = obj[key]; if (isOverridePresent) { overrides = override(key, value); if (overrides && overrides.length === 2) { @@ -6255,37 +6124,38 @@ var require_utilities3 = __commonJS({ } return result; } + var RESERVED_SVG_MATHML_ELEMENTS = /* @__PURE__ */ new Set([ + "annotation-xml", + "color-profile", + "font-face", + "font-face-src", + "font-face-uri", + "font-face-format", + "font-face-name", + "missing-glyph" + ]); function isCustomComponent(tagName, props) { if (tagName.indexOf("-") === -1) { return props && typeof props.is === "string"; } - switch (tagName) { - case "annotation-xml": - case "color-profile": - case "font-face": - case "font-face-src": - case "font-face-uri": - case "font-face-format": - case "font-face-name": - case "missing-glyph": - return false; - default: - return true; + if (RESERVED_SVG_MATHML_ELEMENTS.has(tagName)) { + return false; } + return true; } - var styleToJSOptions = { reactCompat: true }; + var STYLE_TO_JS_OPTIONS = { reactCompat: true }; function setStyleProp(style, props) { if (style === null || style === void 0) { return; } try { - props.style = styleToJS(style, styleToJSOptions); + props.style = styleToJS(style, STYLE_TO_JS_OPTIONS); } catch (err) { props.style = {}; } } var PRESERVE_CUSTOM_ATTRIBUTES = React2.version.split(".")[0] >= 16; - var elementsWithNoTextChildren = /* @__PURE__ */ new Set([ + var ELEMENTS_WITH_NO_TEXT_CHILDREN = /* @__PURE__ */ new Set([ "tr", "tbody", "thead", @@ -6297,15 +6167,19 @@ var require_utilities3 = __commonJS({ "frameset" ]); function canTextBeChildOfNode(node) { - return !elementsWithNoTextChildren.has(node.name); + return !ELEMENTS_WITH_NO_TEXT_CHILDREN.has(node.name); + } + function returnFirstArg(arg) { + return arg; } module2.exports = { PRESERVE_CUSTOM_ATTRIBUTES, + ELEMENTS_WITH_NO_TEXT_CHILDREN, invertObject, isCustomComponent, setStyleProp, canTextBeChildOfNode, - elementsWithNoTextChildren + returnFirstArg }; } }); @@ -6383,12 +6257,13 @@ var require_dom_to_react = __commonJS({ options = options || {}; var library = options.library || React2; var cloneElement = library.cloneElement; - var createElement = library.createElement; + var createElement2 = library.createElement; var isValidElement = library.isValidElement; var result = []; var node; var isWhitespace; var hasReplace = typeof options.replace === "function"; + var transform = options.transform || utilities.returnFirstArg; var replaceElement; var props; var children; @@ -6403,7 +6278,7 @@ var require_dom_to_react = __commonJS({ key: replaceElement.key || i }); } - result.push(replaceElement); + result.push(transform(replaceElement, node, i)); continue; } } @@ -6415,7 +6290,7 @@ var require_dom_to_react = __commonJS({ if (trim && isWhitespace) { continue; } - result.push(node.data); + result.push(transform(node.data, node, i)); continue; } props = node.attribs; @@ -6447,7 +6322,7 @@ var require_dom_to_react = __commonJS({ if (len > 1) { props.key = i; } - result.push(createElement(node.name, props, children)); + result.push(transform(createElement2(node.name, props, children), node, i)); } return result.length === 1 ? result[0] : result; } @@ -56632,8 +56507,7 @@ var classed = { var import_jsx_runtime = require("react/jsx-runtime"); var Admonition = ({ node }) => { const attrs = node.getAttributes(); - const content = (0, import_react_asciidoc.useGetContent)(node); - const contentModel = node.getContentModel(); + const content = (0, import_react_asciidoc.getContent)(node); let icon; if (attrs.name === "caution") { icon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Error12, {}); @@ -56647,7 +56521,10 @@ var Admonition = ({ node }) => { /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "admonition-content content", children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_asciidoc.Title, { node }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: titleCase(attrs.name) }), - /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: contentModel === "simple" ? html_react_parser_default(content) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_asciidoc.Content, { blocks: node.getBlocks() }) }) + /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [ + /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_asciidoc.Title, { node }), + html_react_parser_default(content) + ] }) ] }) ] }); }; @@ -56700,15 +56577,17 @@ var import_lib = __toESM(require_lib10(), 1); var es_default = import_lib.default; // components/src/asciidoc/Listing.tsx +var import_html_entities = require("html-entities"); var import_jsx_runtime2 = require("react/jsx-runtime"); var Listing = ({ node }) => { const document2 = node.getDocument(); const attrs = node.getAttributes(); const nowrap = node.isOption("nowrap") || !document2.hasAttribute("prewrap"); - const content = (0, import_react_asciidoc2.useGetContent)(node); + const content = (0, import_react_asciidoc2.getContent)(node); + const decodedContent = (0, import_html_entities.decode)(content) || content; if (node.getStyle() === "source") { const lang = attrs.language; - return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "listingblock", children: [ + return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "listingblock", ...(0, import_react_asciidoc2.getLineNumber)(node), children: [ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_asciidoc2.CaptionedTitle, { node }), /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "content", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("pre", { className: (0, import_classnames.default)("highlight", nowrap ? " nowrap" : ""), children: lang ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( "code", @@ -56716,696 +56595,813 @@ var Listing = ({ node }) => { className: lang ? `language-${lang}` : "", "data-lang": lang, dangerouslySetInnerHTML: { - __html: es_default.getLanguage(lang) ? es_default.highlight(content, { language: lang }).value : content + __html: es_default.getLanguage(lang) ? es_default.highlight(decodedContent, { language: lang }).value : decodedContent } } - ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("code", { dangerouslySetInnerHTML: { __html: content } }) }) }) + ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("code", { dangerouslySetInnerHTML: { __html: decodedContent } }) }) }) ] }); } else { - return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "listingblock", children: [ + return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "listingblock", ...(0, import_react_asciidoc2.getLineNumber)(node), children: [ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_asciidoc2.CaptionedTitle, { node }), - /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "content", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("pre", { className: nowrap ? " nowrap" : "", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("code", { dangerouslySetInnerHTML: { __html: node.getSource() } }) }) }) + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "content", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("pre", { className: nowrap ? " nowrap" : "", children: node.getSource() }) }) ] }); } }; var Listing_default = Listing; -// components/src/asciidoc/Table.tsx -var import_react_asciidoc3 = require("@oxide/react-asciidoc"); +// icons/react/Access24Icon.tsx var import_jsx_runtime3 = require("react/jsx-runtime"); -var Table = ({ node }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "table-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_asciidoc3.Table, { node }) }); -var Table_default = Table; - -// components/src/asciidoc/index.ts -var AsciiDocBlocks = { - Admonition: Admonition_default, - Listing: Listing_default, - Table: Table_default -}; -// components/src/ui/badge/Badge.tsx -var import_classnames2 = __toESM(require_classnames()); +// icons/react/Action24Icon.tsx var import_jsx_runtime4 = require("react/jsx-runtime"); -var badgeColors = { - default: { - default: `ring-1 ring-inset bg-accent-secondary text-accent ring-[rgba(var(--base-green-800-rgb),0.15)]`, - destructive: `ring-1 ring-inset bg-destructive-secondary text-destructive ring-[rgba(var(--base-red-800-rgb),0.15)]`, - notice: `ring-1 ring-inset bg-notice-secondary text-notice ring-[rgba(var(--base-yellow-800-rgb),0.15)]`, - neutral: `ring-1 ring-inset bg-secondary text-secondary ring-[rgba(var(--base-neutral-700-rgb),0.15)]`, - purple: `ring-1 ring-inset bg-[var(--base-purple-200)] text-[var(--base-purple-700)] ring-[rgba(var(--base-purple-800-rgb),0.15)]`, - blue: `ring-1 ring-inset bg-info-secondary text-info ring-[rgba(var(--base-blue-800-rgb),0.15)]` - }, - solid: { - default: "bg-accent text-inverse", - destructive: "bg-destructive text-inverse", - notice: "bg-notice text-inverse", - neutral: "bg-inverse-tertiary text-inverse", - purple: "bg-[var(--base-purple-700)] text-inverse", - blue: "bg-info text-inverse" - } -}; -var Badge = ({ - className, - children, - color = "default", - variant = "default" -}) => { - return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)( - "span", - { - className: (0, import_classnames2.default)( - "ox-badge", - `variant-${variant}`, - "inline-flex h-4 items-center whitespace-nowrap rounded-sm px-[3px] py-[1px] uppercase text-mono-sm", - badgeColors[variant][color], - className - ), - children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children }) - } - ); -}; -// components/src/ui/button/Button.tsx -var import_classnames3 = __toESM(require_classnames()); -var import_react = require("react"); +// icons/react/AddRoundel24Icon.tsx var import_jsx_runtime5 = require("react/jsx-runtime"); -var buttonSizes = ["sm", "icon", "base"]; -var variants = ["primary", "secondary", "ghost", "danger"]; -var sizeStyle = { - sm: "h-8 px-3 text-mono-sm svg:w-4", - // meant for buttons that only contain a single icon - icon: "h-8 w-8 text-mono-sm svg:w-4", - base: "h-10 px-4 text-mono-sm svg:w-5" -}; -var buttonStyle = ({ - size: size2 = "base", - variant = "primary" -} = {}) => { - return (0, import_classnames3.default)( - "ox-button inline-flex items-center justify-center rounded align-top elevation-1 disabled:cursor-not-allowed", - `btn-${variant}`, - sizeStyle[size2], - variant === "danger" ? "focus:outline-destructive-secondary" : "focus:outline-accent-secondary" - ); -}; -var noop = (e) => { - e.stopPropagation(); - e.preventDefault(); -}; -var Button = (0, import_react.forwardRef)( - ({ - type = "button", - children, - size: size2, - variant, - className, - loading, - innerClassName, - disabled, - onClick, - // needs to be a spread because we sometimes get passed arbitrary