@mintlify/cli 4.0.1463 → 4.0.1464

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10022,7 +10022,12 @@ function isWordChar(ch) {
10022
10022
  var SerializerState = class {
10023
10023
  constructor(options = {}) {
10024
10024
  var _a, _b, _c, _d;
10025
- this.out = "";
10025
+ this.chunks = [];
10026
+ this.chunkStarts = [];
10027
+ this.outLength = 0;
10028
+ this.tail = "";
10029
+ this.trailingSpaces = 0;
10030
+ this.topLevelLead = null;
10026
10031
  this.delim = "";
10027
10032
  this.closed = false;
10028
10033
  this.inTable = false;
@@ -10040,22 +10045,118 @@ var SerializerState = class {
10040
10045
  this.indentSize = this.options.indentSize;
10041
10046
  this.hasReferenceDefinitions = this.options.hasReferenceDefinitions;
10042
10047
  }
10048
+ /** The serialized output */
10049
+ get out() {
10050
+ var _a;
10051
+ if (this.chunks.length > 1) {
10052
+ const joined = this.chunks.join("");
10053
+ this.chunks = [joined];
10054
+ this.chunkStarts = [0];
10055
+ }
10056
+ return (_a = this.chunks[0]) !== null && _a !== void 0 ? _a : "";
10057
+ }
10058
+ set out(value) {
10059
+ this.chunks = [];
10060
+ this.chunkStarts = [];
10061
+ this.outLength = 0;
10062
+ this.tail = "";
10063
+ this.trailingSpaces = 0;
10064
+ this.append(value);
10065
+ }
10066
+ get length() {
10067
+ return this.outLength;
10068
+ }
10069
+ get trailingSpaceCount() {
10070
+ return this.trailingSpaces;
10071
+ }
10072
+ /** Output written at or after `offset`. */
10073
+ sliceFrom(offset) {
10074
+ var _a, _b;
10075
+ let lo = 0;
10076
+ let hi = this.chunkStarts.length - 1;
10077
+ while (lo < hi) {
10078
+ const mid = lo + hi + 1 >> 1;
10079
+ if (((_a = this.chunkStarts[mid]) !== null && _a !== void 0 ? _a : 0) <= offset)
10080
+ lo = mid;
10081
+ else
10082
+ hi = mid - 1;
10083
+ }
10084
+ const first = this.chunks[lo];
10085
+ if (first === void 0)
10086
+ return "";
10087
+ return first.slice(offset - ((_b = this.chunkStarts[lo]) !== null && _b !== void 0 ? _b : 0)) + this.chunks.slice(lo + 1).join("");
10088
+ }
10089
+ /** Drop the last `count` characters of the output. */
10090
+ truncate(count) {
10091
+ var _a, _b, _c;
10092
+ let remaining = count;
10093
+ while (remaining > 0 && this.chunks.length > 0) {
10094
+ const last = (_a = this.chunks[this.chunks.length - 1]) !== null && _a !== void 0 ? _a : "";
10095
+ if (last.length <= remaining) {
10096
+ remaining -= last.length;
10097
+ this.chunks.pop();
10098
+ this.chunkStarts.pop();
10099
+ } else {
10100
+ this.chunks[this.chunks.length - 1] = last.slice(0, last.length - remaining);
10101
+ remaining = 0;
10102
+ }
10103
+ }
10104
+ this.outLength -= count - remaining;
10105
+ this.tail = "";
10106
+ this.trailingSpaces = 0;
10107
+ for (let i = this.chunks.length - 1; i >= 0 && this.tail.length < 2; i--) {
10108
+ this.tail = (((_b = this.chunks[i]) !== null && _b !== void 0 ? _b : "") + this.tail).slice(-2);
10109
+ }
10110
+ for (let i = this.chunks.length - 1; i >= 0; i--) {
10111
+ const chunk = (_c = this.chunks[i]) !== null && _c !== void 0 ? _c : "";
10112
+ let j = chunk.length;
10113
+ while (j > 0 && chunk.charCodeAt(j - 1) === 32)
10114
+ j--;
10115
+ this.trailingSpaces += chunk.length - j;
10116
+ if (j > 0)
10117
+ break;
10118
+ }
10119
+ }
10120
+ append(content) {
10121
+ if (content.length === 0)
10122
+ return;
10123
+ this.chunkStarts.push(this.outLength);
10124
+ this.chunks.push(content);
10125
+ this.outLength += content.length;
10126
+ this.tail = (this.tail + content).slice(-2);
10127
+ let i = content.length;
10128
+ while (i > 0 && content.charCodeAt(i - 1) === 32)
10129
+ i--;
10130
+ this.trailingSpaces = i === 0 ? this.trailingSpaces + content.length : content.length - i;
10131
+ const lead = this.topLevelLead;
10132
+ if (lead && !lead.content) {
10133
+ let j = 0;
10134
+ while (j < content.length && content.charCodeAt(j) === 10)
10135
+ j++;
10136
+ lead.lead += j;
10137
+ if (j < content.length)
10138
+ lead.content = true;
10139
+ }
10140
+ }
10043
10141
  beginBlock(index) {
10044
10142
  if (!this.sourceMap)
10045
10143
  return 0;
10046
10144
  this.nodePath.push(index);
10047
- return this.out.length;
10145
+ if (this.nodePath.length === 1)
10146
+ this.topLevelLead = { lead: 0, content: false };
10147
+ return this.outLength;
10048
10148
  }
10049
10149
  endBlock(start) {
10050
10150
  var _a, _b;
10051
10151
  if (!this.sourceMap)
10052
10152
  return;
10053
10153
  if (this.nodePath.length === 1) {
10054
- const lead = (_b = (_a = /^\n+/.exec(this.out.slice(start))) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
10154
+ const lead = (_b = (_a = this.topLevelLead) === null || _a === void 0 ? void 0 : _a.lead) !== null && _b !== void 0 ? _b : 0;
10155
+ this.topLevelLead = null;
10055
10156
  this.sourceMap.push({
10056
10157
  path: [...this.nodePath],
10057
10158
  start: start + lead,
10058
- end: this.out.length,
10159
+ end: this.outLength,
10059
10160
  kind: "block"
10060
10161
  });
10061
10162
  }
@@ -10066,8 +10167,8 @@ var SerializerState = class {
10066
10167
  return;
10067
10168
  this.sourceMap.push({
10068
10169
  path: [...this.nodePath, index],
10069
- start: this.out.length - length,
10070
- end: this.out.length,
10170
+ start: this.outLength - length,
10171
+ end: this.outLength,
10071
10172
  kind: "text",
10072
10173
  pmStart,
10073
10174
  pmEnd
@@ -10077,7 +10178,7 @@ var SerializerState = class {
10077
10178
  if (!this.sourceMap || length === 0)
10078
10179
  return null;
10079
10180
  const entry = this.sourceMap.at(-1);
10080
- if ((entry === null || entry === void 0 ? void 0 : entry.kind) !== "text" || entry.end !== this.out.length || entry.end - entry.start < length || entry.pmEnd - entry.pmStart < length) {
10181
+ if ((entry === null || entry === void 0 ? void 0 : entry.kind) !== "text" || entry.end !== this.outLength || entry.end - entry.start < length || entry.pmEnd - entry.pmStart < length) {
10081
10182
  return null;
10082
10183
  }
10083
10184
  const mapping = Object.assign({ path: [...entry.path], kind: "text", pmStart: entry.pmEnd - length, pmEnd: entry.pmEnd }, entry.offsetEncoding && { offsetEncoding: entry.offsetEncoding });
@@ -10129,24 +10230,24 @@ var SerializerState = class {
10129
10230
  */
10130
10231
  write(content) {
10131
10232
  if (this.closed) {
10132
- this.out += "\n";
10233
+ this.append("\n");
10133
10234
  this.closed = false;
10134
10235
  }
10135
- if (this.delim && this.out.endsWith("\n") && content.length > 0 && content[0] !== "\n") {
10136
- this.out += this.delim;
10236
+ if (this.delim && this.tail.endsWith("\n") && content.length > 0 && content[0] !== "\n") {
10237
+ this.append(this.delim);
10137
10238
  }
10138
- this.out += content;
10239
+ this.append(content);
10139
10240
  }
10140
10241
  ensureNewLine() {
10141
- if (!this.out.endsWith("\n")) {
10142
- this.out += "\n";
10242
+ if (!this.tail.endsWith("\n")) {
10243
+ this.append("\n");
10143
10244
  }
10144
10245
  }
10145
10246
  ensureBlankLine() {
10146
- if (this.out.endsWith("\n\n")) {
10247
+ if (this.tail.endsWith("\n\n")) {
10147
10248
  return;
10148
10249
  }
10149
- this.out += this.out.endsWith("\n") ? "\n" : "\n\n";
10250
+ this.append(this.tail.endsWith("\n") ? "\n" : "\n\n");
10150
10251
  }
10151
10252
  /**
10152
10253
  * Marks the current block as closed. Appropriate spacing will be added on the next write().
@@ -10391,7 +10492,7 @@ function renderBlockquote(state, node, renderNode2) {
10391
10492
  for (let j = 0; j < lines.length; j++) {
10392
10493
  const line = (_a = lines[j]) !== null && _a !== void 0 ? _a : "";
10393
10494
  state.write(line.length > 0 ? "> " : ">");
10394
- parentContentStarts.push(state.out.length);
10495
+ parentContentStarts.push(state.length);
10395
10496
  state.write(line);
10396
10497
  state.ensureNewLine();
10397
10498
  }
@@ -10423,18 +10524,18 @@ function renderList(state, node, ordered, renderContent2) {
10423
10524
  const line = (_a = lines[j]) !== null && _a !== void 0 ? _a : "";
10424
10525
  if (j === 0) {
10425
10526
  state.write(prefix);
10426
- parentContentStarts.push(state.out.length);
10527
+ parentContentStarts.push(state.length);
10427
10528
  state.write(line);
10428
10529
  } else if (line.length > 0) {
10429
10530
  state.ensureNewLine();
10430
10531
  state.write(indent);
10431
- parentContentStarts.push(state.out.length);
10532
+ parentContentStarts.push(state.length);
10432
10533
  state.write(line);
10433
10534
  } else if (!isTight && j < lines.length - 1) {
10434
10535
  state.ensureBlankLine();
10435
- parentContentStarts.push(state.out.length);
10536
+ parentContentStarts.push(state.length);
10436
10537
  } else {
10437
- parentContentStarts.push(state.out.length);
10538
+ parentContentStarts.push(state.length);
10438
10539
  }
10439
10540
  }
10440
10541
  state.importTextEntries((_b = itemState.sourceMap) !== null && _b !== void 0 ? _b : [], [i], offsetMapperForLines(itemOutput, parentContentStarts));
@@ -10696,20 +10797,21 @@ function renderTitledComponent(state, node, name, renderContent2, renderInline2,
10696
10797
  }
10697
10798
  const titleAttribute = isJSXContent(title) ? title.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;") : title;
10698
10799
  const extractedAttrs = titleAttribute ? Object.assign({ title: titleAttribute }, node.attrs) : Object.assign({}, node.attrs);
10699
- const outputStart = state.out.length;
10800
+ const outputStart = state.length;
10700
10801
  renderComponentWithAttrs(state, node, name, extractedAttrs, renderContent2, excludeAttrs);
10701
10802
  const titleText = titleChild === null || titleChild === void 0 ? void 0 : titleChild.firstChild;
10702
10803
  if (!(titleText === null || titleText === void 0 ? void 0 : titleText.isText) || titleText.text !== title)
10703
10804
  return;
10704
- const openingStart = state.out.indexOf(`<${name}`, outputStart);
10705
- const openingEnd = state.out.indexOf("\n", openingStart);
10706
- const attributeStart = state.out.indexOf("title=", openingStart);
10707
- const valueStart = state.out.indexOf(title, attributeStart + "title=".length);
10805
+ const rendered = state.sliceFrom(outputStart);
10806
+ const openingStart = rendered.indexOf(`<${name}`);
10807
+ const openingEnd = rendered.indexOf("\n", openingStart);
10808
+ const attributeStart = rendered.indexOf("title=", openingStart);
10809
+ const valueStart = rendered.indexOf(title, attributeStart + "title=".length);
10708
10810
  if (openingStart < 0 || openingEnd < 0 || attributeStart < 0 || valueStart < 0)
10709
10811
  return;
10710
10812
  if (attributeStart >= openingEnd || valueStart + title.length > openingEnd)
10711
10813
  return;
10712
- state.recordLiteralTextRange([0, 0], valueStart, valueStart + title.length);
10814
+ state.recordLiteralTextRange([0, 0], outputStart + valueStart, outputStart + valueStart + title.length);
10713
10815
  }
10714
10816
  function renderGenericComponent(state, node, name, renderContent2, excludeAttrs = []) {
10715
10817
  renderComponentWithAttrs(state, node, name, node.attrs, renderContent2, excludeAttrs);
@@ -11167,11 +11269,11 @@ function renderInline(state, node, renderNode2, inlineRenderers2) {
11167
11269
  return m !== void 0 && usesFlanking(m);
11168
11270
  });
11169
11271
  if (closingFlanking) {
11170
- const match = state.out.match(/ +$/);
11171
- if (match) {
11172
- trailingSpace = match[0];
11173
- trailingTextMapping = state.takeTextSuffix(trailingSpace.length);
11174
- state.out = state.out.slice(0, -trailingSpace.length);
11272
+ const spaces = state.trailingSpaceCount;
11273
+ if (spaces > 0) {
11274
+ trailingSpace = " ".repeat(spaces);
11275
+ trailingTextMapping = state.takeTextSuffix(spaces);
11276
+ state.truncate(spaces);
11175
11277
  }
11176
11278
  }
11177
11279
  for (let i = active.length - 1; i >= earliestClose; i--) {
@@ -11190,10 +11292,10 @@ function renderInline(state, node, renderNode2, inlineRenderers2) {
11190
11292
  }
11191
11293
  active = active.slice(0, earliestClose);
11192
11294
  if (trailingSpace) {
11193
- const trailingStart = state.out.length;
11295
+ const trailingStart = state.length;
11194
11296
  state.write(trailingSpace);
11195
11297
  if (trailingTextMapping) {
11196
- state.recordTextRange(trailingTextMapping, trailingStart, state.out.length);
11298
+ state.recordTextRange(trailingTextMapping, trailingStart, state.length);
11197
11299
  }
11198
11300
  }
11199
11301
  for (const mark of continuing) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintlify/cli",
3
- "version": "4.0.1463",
3
+ "version": "4.0.1464",
4
4
  "description": "The Mintlify CLI",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -86,7 +86,7 @@
86
86
  "keytar": "7.9.0"
87
87
  },
88
88
  "devDependencies": {
89
- "@mintlify/editor": "0.0.351",
89
+ "@mintlify/editor": "0.0.352",
90
90
  "@mintlify/ts-config": "2.0.2",
91
91
  "@tsconfig/recommended": "1.0.2",
92
92
  "@types/detect-port": "1.3.2",
@@ -105,5 +105,5 @@
105
105
  "vitest": "2.1.9",
106
106
  "vitest-mock-process": "1.0.4"
107
107
  },
108
- "gitHead": "f828b446b1bcec7e17b0b2b4b8a76cbf9f8d9eef"
108
+ "gitHead": "9e6f839a347a9cb77950592214722a59117b30b4"
109
109
  }