markstream-vue2 0.0.46-beta.1 → 0.0.48

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.
package/dist/index.js CHANGED
@@ -2968,29 +2968,277 @@ const ParagraphNode = __component__$l.exports;
2968
2968
  const _sfc_main$k = /* @__PURE__ */ defineComponent({
2969
2969
  __name: "PreCodeNode",
2970
2970
  props: {
2971
- node: null
2971
+ node: null,
2972
+ showLineNumbers: { type: Boolean },
2973
+ diffInline: { type: Boolean }
2972
2974
  },
2973
2975
  setup(__props) {
2974
2976
  const props = __props;
2975
2977
  const normalizedLanguage = computed(() => {
2976
2978
  var _a2, _b, _c;
2977
2979
  const raw = String((_b = (_a2 = props.node) == null ? void 0 : _a2.language) != null ? _b : "");
2978
- const head = String((_c = String(raw).split(/\s+/g)[0]) != null ? _c : "").toLowerCase();
2980
+ const head = String((_c = String(raw).split(/\s+/g)[0]) != null ? _c : "").split(":")[0].toLowerCase();
2979
2981
  const safe = head.replace(/[^\w-]/g, "");
2980
2982
  return safe || "plaintext";
2981
2983
  });
2982
2984
  const languageClass = computed(() => `language-${normalizedLanguage.value}`);
2985
+ const isDiffPreview = computed(() => {
2986
+ var _a2;
2987
+ return props.showLineNumbers === true && ((_a2 = props.node) == null ? void 0 : _a2.diff) === true;
2988
+ });
2989
+ const isInlineDiffPreview = computed(() => isDiffPreview.value && props.diffInline === true);
2990
+ const displayCode = computed(() => {
2991
+ var _a2, _b, _c, _d, _e, _f;
2992
+ if (((_a2 = props.node) == null ? void 0 : _a2.diff) === true)
2993
+ return String((_c = (_b = props.node) == null ? void 0 : _b.code) != null ? _c : "");
2994
+ const value = String((_e = (_d = props.node) == null ? void 0 : _d.code) != null ? _e : "");
2995
+ return ((_f = props.node) == null ? void 0 : _f.loading) === true ? value : value.replace(/\r\n$|\n$|\r$/, "");
2996
+ });
2983
2997
  const ariaLabel = computed(() => {
2984
2998
  const lang = normalizedLanguage.value;
2985
2999
  return lang ? `Code block: ${lang}` : "Code block";
2986
3000
  });
2987
- return { __sfc: true, props, normalizedLanguage, languageClass, ariaLabel };
3001
+ function splitLines(source) {
3002
+ return String(source != null ? source : "").split(/\r\n|\n|\r/);
3003
+ }
3004
+ function splitDiffSource(source) {
3005
+ const code = String(source != null ? source : "");
3006
+ if (!code)
3007
+ return [];
3008
+ return code.split(/\r\n|\n|\r/);
3009
+ }
3010
+ function isRemovedDiffLine(line) {
3011
+ return line.startsWith("-") && !line.startsWith("---");
3012
+ }
3013
+ function isAddedDiffLine(line) {
3014
+ return line.startsWith("+") && !line.startsWith("+++");
3015
+ }
3016
+ function isExplicitDiffLanguage() {
3017
+ var _a2, _b, _c, _d;
3018
+ if (normalizedLanguage.value === "diff")
3019
+ return true;
3020
+ const firstLine = (_d = (_c = String((_b = (_a2 = props.node) == null ? void 0 : _a2.raw) != null ? _b : "").split(/\r?\n/, 1)[0]) == null ? void 0 : _c.trim()) != null ? _d : "";
3021
+ return /^`{3,}\s*diff(?:\s|$)|^~{3,}\s*diff(?:\s|$)/.test(firstLine);
3022
+ }
3023
+ function hasPatchLines(lines) {
3024
+ const hasRemoved = lines.some((line) => isRemovedDiffLine(line));
3025
+ const hasAdded = lines.some((line) => isAddedDiffLine(line));
3026
+ return hasRemoved && hasAdded || isExplicitDiffLanguage() && (hasRemoved || hasAdded);
3027
+ }
3028
+ function hasDiffSourcePair() {
3029
+ var _a2, _b;
3030
+ return ((_a2 = props.node) == null ? void 0 : _a2.originalCode) != null || ((_b = props.node) == null ? void 0 : _b.updatedCode) != null;
3031
+ }
3032
+ function shouldPreserveSourceBlankDiffKind(lines, index2) {
3033
+ return !isBlankDiffLine(lines[index2]) || index2 < lines.length - 1;
3034
+ }
3035
+ function isBlankDiffLine(code) {
3036
+ return String(code != null ? code : "").trim().length === 0;
3037
+ }
3038
+ function toDiffLine(code, kind, key, number, options = {}) {
3039
+ const empty = String(code != null ? code : "").trim().length === 0;
3040
+ return {
3041
+ code,
3042
+ empty,
3043
+ kind: empty && kind !== "hunk" && !options.preserveBlankKind ? "context" : kind,
3044
+ key,
3045
+ number
3046
+ };
3047
+ }
3048
+ function computeSourceLineMatches(original, modified) {
3049
+ const n = original.length;
3050
+ const m = modified.length;
3051
+ const maxCells = 15e5;
3052
+ if ((n + 1) * (m + 1) > maxCells)
3053
+ return null;
3054
+ const cols = m + 1;
3055
+ const scores = new Uint16Array((n + 1) * (m + 1));
3056
+ for (let i2 = n - 1; i2 >= 0; i2--) {
3057
+ for (let j2 = m - 1; j2 >= 0; j2--) {
3058
+ const current = i2 * cols + j2;
3059
+ if (original[i2] === modified[j2]) {
3060
+ scores[current] = scores[(i2 + 1) * cols + j2 + 1] + 1;
3061
+ } else {
3062
+ scores[current] = Math.max(scores[(i2 + 1) * cols + j2], scores[i2 * cols + j2 + 1]);
3063
+ }
3064
+ }
3065
+ }
3066
+ const matches = [];
3067
+ let i = 0;
3068
+ let j = 0;
3069
+ while (i < n && j < m) {
3070
+ if (original[i] === modified[j]) {
3071
+ matches.push({ originalIndex: i, modifiedIndex: j });
3072
+ i++;
3073
+ j++;
3074
+ } else if (scores[(i + 1) * cols + j] >= scores[i * cols + j + 1]) {
3075
+ i++;
3076
+ } else {
3077
+ j++;
3078
+ }
3079
+ }
3080
+ return matches;
3081
+ }
3082
+ function buildInlinePatchPreviewLines(lines) {
3083
+ let modifiedLine = 1;
3084
+ return lines.map((raw, index2) => {
3085
+ if (raw.startsWith("@@"))
3086
+ return toDiffLine(raw, "hunk", `inline-hunk-${index2}`, "");
3087
+ if (isRemovedDiffLine(raw)) {
3088
+ const line = toDiffLine(raw.slice(1), "removed", `inline-removed-${index2}`, "", { preserveBlankKind: true });
3089
+ return line;
3090
+ }
3091
+ if (isAddedDiffLine(raw))
3092
+ return toDiffLine(raw.slice(1), "added", `inline-added-${index2}`, modifiedLine++, { preserveBlankKind: true });
3093
+ const code = raw.startsWith(" ") ? raw.slice(1) : raw;
3094
+ return toDiffLine(code, "context", `inline-context-${index2}`, modifiedLine++);
3095
+ });
3096
+ }
3097
+ function buildInlineSourcePreviewLines(originalSource, modifiedSource) {
3098
+ const original = splitDiffSource(originalSource);
3099
+ const modified = splitDiffSource(modifiedSource);
3100
+ const matches = computeSourceLineMatches(original, modified);
3101
+ if (matches) {
3102
+ const result2 = [];
3103
+ let originalIndex = 0;
3104
+ let modifiedIndex = 0;
3105
+ for (const match of matches) {
3106
+ while (originalIndex < match.originalIndex) {
3107
+ result2.push(toDiffLine(original[originalIndex], "removed", `inline-removed-source-${originalIndex}`, "", {
3108
+ preserveBlankKind: shouldPreserveSourceBlankDiffKind(original, originalIndex)
3109
+ }));
3110
+ originalIndex++;
3111
+ }
3112
+ while (modifiedIndex < match.modifiedIndex) {
3113
+ result2.push(toDiffLine(modified[modifiedIndex], "added", `inline-added-source-${modifiedIndex}`, modifiedIndex + 1, {
3114
+ preserveBlankKind: shouldPreserveSourceBlankDiffKind(modified, modifiedIndex)
3115
+ }));
3116
+ modifiedIndex++;
3117
+ }
3118
+ result2.push(toDiffLine(modified[match.modifiedIndex], "context", `inline-context-source-${match.originalIndex}-${match.modifiedIndex}`, match.modifiedIndex + 1));
3119
+ originalIndex = match.originalIndex + 1;
3120
+ modifiedIndex = match.modifiedIndex + 1;
3121
+ }
3122
+ while (originalIndex < original.length) {
3123
+ result2.push(toDiffLine(original[originalIndex], "removed", `inline-removed-source-${originalIndex}`, "", {
3124
+ preserveBlankKind: shouldPreserveSourceBlankDiffKind(original, originalIndex)
3125
+ }));
3126
+ originalIndex++;
3127
+ }
3128
+ while (modifiedIndex < modified.length) {
3129
+ result2.push(toDiffLine(modified[modifiedIndex], "added", `inline-added-source-${modifiedIndex}`, modifiedIndex + 1, {
3130
+ preserveBlankKind: shouldPreserveSourceBlankDiffKind(modified, modifiedIndex)
3131
+ }));
3132
+ modifiedIndex++;
3133
+ }
3134
+ return result2;
3135
+ }
3136
+ const result = [];
3137
+ let start = 0;
3138
+ let originalEnd = original.length - 1;
3139
+ let modifiedEnd = modified.length - 1;
3140
+ while (start <= originalEnd && start <= modifiedEnd && original[start] === modified[start]) {
3141
+ result.push(toDiffLine(modified[start], "context", `inline-prefix-${start}`, start + 1));
3142
+ start++;
3143
+ }
3144
+ const suffix = [];
3145
+ while (originalEnd >= start && modifiedEnd >= start && original[originalEnd] === modified[modifiedEnd]) {
3146
+ suffix.unshift(toDiffLine(modified[modifiedEnd], "context", `inline-suffix-${modifiedEnd}`, modifiedEnd + 1));
3147
+ originalEnd--;
3148
+ modifiedEnd--;
3149
+ }
3150
+ for (let index2 = start; index2 <= originalEnd; index2++) {
3151
+ result.push(toDiffLine(original[index2], "removed", `inline-removed-source-${index2}`, "", {
3152
+ preserveBlankKind: shouldPreserveSourceBlankDiffKind(original, index2)
3153
+ }));
3154
+ }
3155
+ for (let index2 = start; index2 <= modifiedEnd; index2++) {
3156
+ result.push(toDiffLine(modified[index2], "added", `inline-added-source-${index2}`, index2 + 1, {
3157
+ preserveBlankKind: shouldPreserveSourceBlankDiffKind(modified, index2)
3158
+ }));
3159
+ }
3160
+ return result.concat(suffix);
3161
+ }
3162
+ function buildDiffPanes(inline = false) {
3163
+ var _a2, _b, _c, _d, _e;
3164
+ const patchLines = splitLines((_a2 = props.node) == null ? void 0 : _a2.code);
3165
+ const hasPatchDiffLines = hasPatchLines(patchLines);
3166
+ if (!hasPatchDiffLines && hasDiffSourcePair()) {
3167
+ if (inline) {
3168
+ const lines = buildInlineSourcePreviewLines((_b = props.node) == null ? void 0 : _b.originalCode, (_c = props.node) == null ? void 0 : _c.updatedCode);
3169
+ return [{ key: "inline", className: "markstream-pre__diff-pane--inline", lines }];
3170
+ }
3171
+ const original2 = splitDiffSource((_d = props.node) == null ? void 0 : _d.originalCode);
3172
+ const modified2 = splitDiffSource((_e = props.node) == null ? void 0 : _e.updatedCode);
3173
+ return [
3174
+ {
3175
+ key: "original",
3176
+ className: "markstream-pre__diff-pane--original",
3177
+ lines: original2.map((line, index2) => {
3178
+ const kind = modified2[index2] === line ? "context" : "removed";
3179
+ return toDiffLine(line, kind, `original-${index2}`, index2 + 1, {
3180
+ preserveBlankKind: shouldPreserveSourceBlankDiffKind(original2, index2)
3181
+ });
3182
+ })
3183
+ },
3184
+ {
3185
+ key: "modified",
3186
+ className: "markstream-pre__diff-pane--modified",
3187
+ lines: modified2.map((line, index2) => {
3188
+ const kind = original2[index2] === line ? "context" : "added";
3189
+ return toDiffLine(line, kind, `modified-${index2}`, index2 + 1, {
3190
+ preserveBlankKind: shouldPreserveSourceBlankDiffKind(modified2, index2)
3191
+ });
3192
+ })
3193
+ }
3194
+ ];
3195
+ }
3196
+ if (inline) {
3197
+ const lines = buildInlinePatchPreviewLines(patchLines);
3198
+ return [{ key: "inline", className: "markstream-pre__diff-pane--inline", lines }];
3199
+ }
3200
+ const original = [];
3201
+ const modified = [];
3202
+ let originalLine = 1;
3203
+ let modifiedLine = 1;
3204
+ for (const [index2, raw] of patchLines.entries()) {
3205
+ if (raw.startsWith("@@")) {
3206
+ original.push(toDiffLine(raw, "hunk", `original-hunk-${index2}`, ""));
3207
+ modified.push(toDiffLine(raw, "hunk", `modified-hunk-${index2}`, ""));
3208
+ } else if (isRemovedDiffLine(raw)) {
3209
+ original.push(toDiffLine(raw.slice(1), "removed", `original-removed-${index2}`, originalLine++, { preserveBlankKind: true }));
3210
+ } else if (isAddedDiffLine(raw)) {
3211
+ modified.push(toDiffLine(raw.slice(1), "added", `modified-added-${index2}`, modifiedLine++, { preserveBlankKind: true }));
3212
+ } else {
3213
+ const code = raw.startsWith(" ") ? raw.slice(1) : raw;
3214
+ original.push(toDiffLine(code, "context", `original-context-${index2}`, originalLine++));
3215
+ modified.push(toDiffLine(code, "context", `modified-context-${index2}`, modifiedLine++));
3216
+ }
3217
+ }
3218
+ return [
3219
+ { key: "original", className: "markstream-pre__diff-pane--original", lines: original },
3220
+ { key: "modified", className: "markstream-pre__diff-pane--modified", lines: modified }
3221
+ ];
3222
+ }
3223
+ const diffPreviewPanes = computed(() => isDiffPreview.value ? buildDiffPanes(isInlineDiffPreview.value) : []);
3224
+ return { __sfc: true, props, normalizedLanguage, languageClass, isDiffPreview, isInlineDiffPreview, displayCode, ariaLabel, splitLines, splitDiffSource, isRemovedDiffLine, isAddedDiffLine, isExplicitDiffLanguage, hasPatchLines, hasDiffSourcePair, shouldPreserveSourceBlankDiffKind, isBlankDiffLine, toDiffLine, computeSourceLineMatches, buildInlinePatchPreviewLines, buildInlineSourcePreviewLines, buildDiffPanes, diffPreviewPanes };
2988
3225
  }
2989
3226
  });
2990
3227
  const PreCodeNode_vue_vue_type_style_index_0_lang = "";
2991
3228
  var _sfc_render$k = function render26() {
2992
3229
  var _vm = this, _c = _vm._self._c, _setup = _vm._self._setupProxy;
2993
- return _c("pre", { class: [_setup.languageClass], attrs: { "aria-busy": _vm.node.loading === true, "aria-label": _setup.ariaLabel, "data-language": _setup.normalizedLanguage, "tabindex": "0" } }, [_c("code", { attrs: { "translate": "no" }, domProps: { "textContent": _vm._s(_vm.node.code) } })]);
3230
+ return _c("pre", { class: [
3231
+ _setup.languageClass,
3232
+ {
3233
+ "markstream-pre--line-numbers": _setup.props.showLineNumbers,
3234
+ "markstream-pre--diff-preview": _setup.isDiffPreview,
3235
+ "markstream-pre--diff-inline": _setup.isInlineDiffPreview
3236
+ }
3237
+ ], attrs: { "aria-busy": _vm.node.loading === true, "aria-label": _setup.ariaLabel, "data-language": _setup.normalizedLanguage, "data-markstream-line-numbers": _setup.props.showLineNumbers ? "1" : void 0, "data-markstream-pre": "1", "tabindex": "0" } }, [_setup.isDiffPreview ? _c("code", { staticClass: "markstream-pre__diff-code", attrs: { "translate": "no" } }, _vm._l(_setup.diffPreviewPanes, function(pane) {
3238
+ return _c("span", { key: pane.key, staticClass: "markstream-pre__diff-pane", class: pane.className }, _vm._l(pane.lines, function(line) {
3239
+ return _c("span", { key: line.key, staticClass: "markstream-pre__diff-line", class: [`markstream-pre__diff-line--${line.kind}`, { "markstream-pre__diff-line--empty": line.empty }] }, [_c("span", { staticClass: "markstream-pre__diff-rail", attrs: { "aria-hidden": "true" } }), _c("span", { staticClass: "markstream-pre__diff-number", attrs: { "aria-hidden": "true" } }, [_vm._v(_vm._s(line.number))]), _c("span", { staticClass: "markstream-pre__diff-content" }, [_c("span", { staticClass: "markstream-pre__diff-content-inner" }, [_vm._v(_vm._s(line.code))])])]);
3240
+ }), 0);
3241
+ }), 0) : _c("code", { attrs: { "translate": "no" }, domProps: { "textContent": _vm._s(_setup.displayCode) } })]);
2994
3242
  };
2995
3243
  var _sfc_staticRenderFns$k = [];
2996
3244
  var __component__$k = /* @__PURE__ */ normalizeComponent(
@@ -3288,7 +3536,7 @@ function getUseMonaco() {
3288
3536
  if (importAttempted)
3289
3537
  return null;
3290
3538
  try {
3291
- const imported = yield import("./chunks/index.legacy-1f634d9d.js").then((n) => n.i);
3539
+ const imported = yield import("stream-monaco/legacy");
3292
3540
  mod = (_a2 = imported == null ? void 0 : imported.default) != null ? _a2 : imported;
3293
3541
  yield preload(mod);
3294
3542
  const ok = yield warmupShikiTokenizer(mod);
@@ -6399,6 +6647,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
6399
6647
  const isExpanded = ref(false);
6400
6648
  const isCollapsed = ref(false);
6401
6649
  const editorCreated = ref(false);
6650
+ const editorReady = ref(false);
6402
6651
  const monacoReady = ref(false);
6403
6652
  let expandRafId = null;
6404
6653
  const heightBeforeCollapse = ref(null);
@@ -6464,6 +6713,21 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
6464
6713
  minimumLineCount: 4,
6465
6714
  revealLineCount: 5
6466
6715
  });
6716
+ const defaultPreFallbackFontSize = 12;
6717
+ const defaultPreFallbackLineHeight = 18;
6718
+ function readPositiveNumber(value) {
6719
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
6720
+ }
6721
+ function readMonacoPadding(value) {
6722
+ var _a3, _b2;
6723
+ if (!value || typeof value !== "object")
6724
+ return { top: 0, bottom: 0 };
6725
+ const raw = value;
6726
+ return {
6727
+ top: (_a3 = readPositiveNumber(raw.top)) != null ? _a3 : 0,
6728
+ bottom: (_b2 = readPositiveNumber(raw.bottom)) != null ? _b2 : 0
6729
+ };
6730
+ }
6467
6731
  function resolveDiffHideUnchangedRegionsOption(value) {
6468
6732
  var _a3;
6469
6733
  if (typeof value === "boolean")
@@ -6477,14 +6741,13 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
6477
6741
  return __spreadValues({}, defaultDiffHideUnchangedRegions);
6478
6742
  }
6479
6743
  const resolvedMonacoOptions = computed(() => {
6480
- var _a3;
6744
+ var _a3, _b2;
6481
6745
  const raw = props.monacoOptions ? __spreadValues({}, props.monacoOptions) : {};
6482
6746
  if (!isDiff.value)
6483
6747
  return raw;
6484
6748
  const diffHideUnchangedRegions = raw.diffHideUnchangedRegions === void 0 ? __spreadValues({}, defaultDiffHideUnchangedRegions) : resolveDiffHideUnchangedRegionsOption(raw.diffHideUnchangedRegions);
6485
6749
  const hideUnchangedRegions = raw.hideUnchangedRegions === void 0 ? void 0 : resolveDiffHideUnchangedRegionsOption(raw.hideUnchangedRegions);
6486
6750
  const diffUnchangedRegionStyle = (_a3 = raw.diffUnchangedRegionStyle) != null ? _a3 : "line-info";
6487
- const needsExtraBottomSpace = diffUnchangedRegionStyle === "line-info" || diffUnchangedRegionStyle === "line-info-basic" || diffUnchangedRegionStyle === "metadata";
6488
6751
  const diffDefaults = {
6489
6752
  maxComputationTime: 0,
6490
6753
  diffAlgorithm: "legacy",
@@ -6496,21 +6759,20 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
6496
6759
  selectionHighlight: false,
6497
6760
  occurrencesHighlight: "off",
6498
6761
  matchBrackets: "never",
6499
- lineDecorationsWidth: 12,
6762
+ lineDecorationsWidth: 4,
6500
6763
  lineNumbersMinChars: 2,
6501
6764
  glyphMargin: false,
6502
- fontSize: 13,
6503
- lineHeight: 30,
6765
+ minimap: { enabled: false },
6504
6766
  renderOverviewRuler: false,
6505
6767
  overviewRulerBorder: false,
6506
6768
  hideCursorInOverviewRuler: true,
6507
6769
  scrollBeyondLastLine: false,
6508
- padding: { top: 10, bottom: needsExtraBottomSpace ? 22 : 14 },
6509
6770
  diffHideUnchangedRegions,
6771
+ useInlineViewWhenSpaceIsLimited: (_b2 = raw.useInlineViewWhenSpaceIsLimited) != null ? _b2 : false,
6510
6772
  diffLineStyle: "background",
6511
6773
  diffAppearance: "auto",
6512
6774
  diffUnchangedRegionStyle,
6513
- diffHunkActionsOnHover: true,
6775
+ diffHunkActionsOnHover: false,
6514
6776
  diffHunkHoverHideDelayMs: 160
6515
6777
  };
6516
6778
  return __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, diffDefaults), raw), hideUnchangedRegions === void 0 ? {} : { hideUnchangedRegions }), {
@@ -6571,7 +6833,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
6571
6833
  const codeFontMax = 36;
6572
6834
  const codeFontStep = 1;
6573
6835
  const defaultCodeFontSize = ref(
6574
- typeof ((_b = resolvedMonacoOptions.value) == null ? void 0 : _b.fontSize) === "number" ? resolvedMonacoOptions.value.fontSize : Number.NaN
6836
+ typeof ((_b = resolvedMonacoOptions.value) == null ? void 0 : _b.fontSize) === "number" ? resolvedMonacoOptions.value.fontSize : defaultPreFallbackFontSize
6575
6837
  );
6576
6838
  const codeFontSize = ref(defaultCodeFontSize.value);
6577
6839
  const fontBaselineReady = computed(() => {
@@ -7290,6 +7552,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
7290
7552
  scheduleEditorVisualSync();
7291
7553
  });
7292
7554
  }
7555
+ editorReady.value = true;
7293
7556
  });
7294
7557
  }
7295
7558
  function ensureEditorCreation(el) {
@@ -7298,6 +7561,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
7298
7561
  if (createEditorPromise)
7299
7562
  return createEditorPromise;
7300
7563
  editorCreated.value = true;
7564
+ editorReady.value = false;
7301
7565
  const pending2 = (() => __async(this, null, function* () {
7302
7566
  yield runEditorCreation(el);
7303
7567
  }))();
@@ -7358,12 +7622,48 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
7358
7622
  return String(theme.name);
7359
7623
  return null;
7360
7624
  }
7361
- function resolveRequestedTheme() {
7625
+ function hasTheme(themes, theme) {
7626
+ const name = getThemeName(theme);
7627
+ return themes.some((item) => item === theme || name && getThemeName(item) === name);
7628
+ }
7629
+ function addRuntimeLanguage(languages, language) {
7630
+ if (typeof language !== "string")
7631
+ return;
7632
+ const canonical = normalizeLanguageIdentifier(language);
7633
+ const monacoId = resolveMonacoLanguageId(canonical);
7634
+ for (const value of [canonical, monacoId]) {
7635
+ if (value && !languages.includes(value))
7636
+ languages.push(value);
7637
+ }
7638
+ }
7639
+ const runtimeMonacoThemes = computed(() => {
7640
+ const themes = Array.isArray(props.themes) ? [...props.themes] : [];
7641
+ for (const theme of [props.darkTheme, props.lightTheme]) {
7642
+ if (theme != null && !hasTheme(themes, theme))
7643
+ themes.push(theme);
7644
+ }
7645
+ return themes.length ? themes : void 0;
7646
+ });
7647
+ const runtimeMonacoLanguages = computed(() => {
7362
7648
  var _a3;
7649
+ const languages = [];
7650
+ const configured = (_a3 = resolvedMonacoOptions.value) == null ? void 0 : _a3.languages;
7651
+ if (Array.isArray(configured)) {
7652
+ for (const language of configured)
7653
+ addRuntimeLanguage(languages, language);
7654
+ }
7655
+ addRuntimeLanguage(languages, props.node.language);
7656
+ addRuntimeLanguage(languages, codeLanguage.value);
7657
+ addRuntimeLanguage(languages, monacoLanguage.value);
7658
+ addRuntimeLanguage(languages, "plaintext");
7659
+ return languages;
7660
+ });
7661
+ function resolveRequestedTheme() {
7662
+ var _a3, _b2;
7363
7663
  const preferred = getPreferredColorScheme();
7364
7664
  const explicit = (_a3 = resolvedMonacoOptions.value) == null ? void 0 : _a3.theme;
7365
7665
  const requested = preferred != null ? preferred : explicit;
7366
- const availableThemes = Array.isArray(props.themes) ? props.themes : [];
7666
+ const availableThemes = (_b2 = runtimeMonacoThemes.value) != null ? _b2 : [];
7367
7667
  if (!availableThemes.length || requested == null)
7368
7668
  return requested;
7369
7669
  const requestedName = getThemeName(requested);
@@ -7439,18 +7739,72 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
7439
7739
  const resolvedSurfaceIsDark = computed(
7440
7740
  () => isDiff.value ? effectiveDiffAppearance.value === "dark" : resolvedChromeIsDark.value
7441
7741
  );
7742
+ const preFallbackMetrics = computed(() => {
7743
+ var _a3, _b2, _c;
7744
+ const raw = resolvedMonacoOptions.value;
7745
+ const fallbackFontSize = Number.isFinite(codeFontSize.value) && codeFontSize.value > 0 ? codeFontSize.value : defaultPreFallbackFontSize;
7746
+ const resolvedFontSize = (_a3 = readPositiveNumber(raw == null ? void 0 : raw.fontSize)) != null ? _a3 : fallbackFontSize;
7747
+ const resolvedLineHeight = (_b2 = readPositiveNumber(raw == null ? void 0 : raw.lineHeight)) != null ? _b2 : resolvedFontSize === defaultPreFallbackFontSize ? defaultPreFallbackLineHeight : Math.max(12, Math.round(resolvedFontSize * 1.5));
7748
+ const fontFamily = typeof (raw == null ? void 0 : raw.fontFamily) === "string" && raw.fontFamily.trim() ? raw.fontFamily.trim() : void 0;
7749
+ const padding = readMonacoPadding(raw == null ? void 0 : raw.padding);
7750
+ const tabSize = (_c = readPositiveNumber(raw == null ? void 0 : raw.tabSize)) != null ? _c : 4;
7751
+ return {
7752
+ fontFamily,
7753
+ fontSize: resolvedFontSize,
7754
+ lineHeight: resolvedLineHeight,
7755
+ paddingBottom: padding.bottom,
7756
+ paddingTop: padding.top,
7757
+ tabSize
7758
+ };
7759
+ });
7760
+ const preFallbackDiffInline = computed(() => {
7761
+ var _a3;
7762
+ if (!isDiff.value)
7763
+ return false;
7764
+ return ((_a3 = resolvedMonacoOptions.value) == null ? void 0 : _a3.renderSideBySide) === false;
7765
+ });
7766
+ const preFallbackStyle = computed(() => {
7767
+ const metrics = preFallbackMetrics.value;
7768
+ const style = {
7769
+ "--markstream-code-padding-left": "62px",
7770
+ "--markstream-pre-diff-line-height": `${metrics.lineHeight}px`,
7771
+ "--markstream-pre-line-number-top": `${metrics.paddingTop}px`,
7772
+ "--markstream-pre-line-number-width": "36px",
7773
+ "--markstream-pre-line-number-gap": "0px",
7774
+ "fontSize": `${metrics.fontSize}px`,
7775
+ "lineHeight": `${metrics.lineHeight}px`,
7776
+ "paddingBottom": `${metrics.paddingBottom}px`,
7777
+ "paddingTop": `${metrics.paddingTop}px`,
7778
+ "tabSize": metrics.tabSize
7779
+ };
7780
+ if (metrics.fontFamily)
7781
+ style.fontFamily = metrics.fontFamily;
7782
+ return style;
7783
+ });
7442
7784
  function buildRuntimeMonacoOptions() {
7443
- return __spreadProps(__spreadValues(__spreadProps(__spreadValues({
7785
+ var _a3, _b2, _c, _d, _e;
7786
+ const nextOptions = __spreadProps(__spreadValues(__spreadProps(__spreadValues({
7444
7787
  wordWrap: "on",
7445
- wrappingIndent: "same",
7446
- themes: props.themes
7788
+ wrappingIndent: "same"
7447
7789
  }, resolvedMonacoOptions.value || {}), {
7790
+ themes: runtimeMonacoThemes.value,
7791
+ languages: runtimeMonacoLanguages.value,
7448
7792
  theme: resolveRequestedTheme()
7449
7793
  }), isDiff.value ? { diffAppearance: effectiveDiffAppearance.value } : {}), {
7450
7794
  onThemeChange() {
7451
7795
  syncEditorCssVars();
7452
7796
  }
7453
7797
  });
7798
+ if (isDiff.value) {
7799
+ const metrics = preFallbackMetrics.value;
7800
+ (_a3 = nextOptions.fontSize) != null ? _a3 : nextOptions.fontSize = metrics.fontSize;
7801
+ (_b2 = nextOptions.lineHeight) != null ? _b2 : nextOptions.lineHeight = metrics.lineHeight;
7802
+ (_c = nextOptions.padding) != null ? _c : nextOptions.padding = { top: metrics.paddingTop, bottom: metrics.paddingBottom };
7803
+ (_d = nextOptions.tabSize) != null ? _d : nextOptions.tabSize = metrics.tabSize;
7804
+ if (metrics.fontFamily)
7805
+ (_e = nextOptions.fontFamily) != null ? _e : nextOptions.fontFamily = metrics.fontFamily;
7806
+ }
7807
+ return nextOptions;
7454
7808
  }
7455
7809
  function syncRuntimeMonacoOptions() {
7456
7810
  const nextOptions = buildRuntimeMonacoOptions();
@@ -7574,13 +7928,13 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
7574
7928
  }
7575
7929
  cleanupEditor();
7576
7930
  });
7577
- return { __sfc: true, props, emits, MONACO_TOUCH_PATCH_FLAG, ensureMonacoPassiveTouchListeners, shouldForcePassiveForMonaco, withPassiveOptions, instance, hasPreviewListener, t, codeEditor, container, copyText, codeLanguage, monacoLanguage, isPlainTextLanguage, isExpanded, isCollapsed, editorCreated, monacoReady, expandRafId, heightBeforeCollapse, resumeGuardFrames, registerVisibility, viewportHandle, viewportReady, createEditor, createDiffEditor, updateCode, updateDiffCode, getEditor, getEditorView, getDiffEditorView, cleanupEditor, safeClean, refreshDiffPresentation, createEditorPromise, detectLanguage, setTheme, runtimeMonacoOptions, inlineFoldProxyCleanups, deferredEditorVisualSyncRafId, isDiff, defaultDiffHideUnchangedRegions, resolveDiffHideUnchangedRegionsOption, resolvedMonacoOptions, desiredEditorKind, currentEditorKind, usePreCodeRender, showInlinePreview, isDevEnv: isDevEnv2, codeFontMin, codeFontMax, codeFontStep, defaultCodeFontSize, codeFontSize, fontBaselineReady, CONTENT_PADDING, LINE_EXTRA_PER_LINE, PIXEL_EPSILON, measureLineHeightFromDom, readActualFontSizeFromEditor, getLineHeightSafe, ensureFontBaseline, increaseCodeFont, decreaseCodeFont, resetCodeFont, computeContentHeight, getColorLuminance, shouldPreferPlainTextFallbackSurface, syncEditorCssVars, resizeSyncHandler, SCROLL_PARENT_OVERFLOW_RE, resolveScrollRootElement, adjustScrollAfterHeightChange, updateExpandedHeight, clearInlineFoldProxies, syncInlineFoldProxies, scheduleEditorVisualSync, syncDiffRevealButtons, applyCollapsedContainerHeight, updateCollapsedHeight, getMaxHeightValue, isPreviewable, displayLanguage, languageIcon, containerStyle, headerStyle, tooltipsEnabled, copy, resolveTooltipTarget, onBtnHover, onBtnLeave, onCopyHover, toggleExpand, toggleHeaderCollapse, previewCode, setAutomaticLayout, runEditorCreation, ensureEditorCreation, stopCreateEditorWatch, getPreferredColorScheme, getThemeName, resolveRequestedTheme, themeUpdate, themeLooksDark, resolvedChromeIsDark, effectiveDiffAppearance, resolvedSurfaceIsDark, buildRuntimeMonacoOptions, syncRuntimeMonacoOptions, monacoStructuralSignature, stopLoadingWatch, stopExpandAutoResize, PreCodeNode, HtmlPreviewFrame };
7931
+ return { __sfc: true, props, emits, MONACO_TOUCH_PATCH_FLAG, ensureMonacoPassiveTouchListeners, shouldForcePassiveForMonaco, withPassiveOptions, instance, hasPreviewListener, t, codeEditor, container, copyText, codeLanguage, monacoLanguage, isPlainTextLanguage, isExpanded, isCollapsed, editorCreated, editorReady, monacoReady, expandRafId, heightBeforeCollapse, resumeGuardFrames, registerVisibility, viewportHandle, viewportReady, createEditor, createDiffEditor, updateCode, updateDiffCode, getEditor, getEditorView, getDiffEditorView, cleanupEditor, safeClean, refreshDiffPresentation, createEditorPromise, detectLanguage, setTheme, runtimeMonacoOptions, inlineFoldProxyCleanups, deferredEditorVisualSyncRafId, isDiff, defaultDiffHideUnchangedRegions, defaultPreFallbackFontSize, defaultPreFallbackLineHeight, readPositiveNumber, readMonacoPadding, resolveDiffHideUnchangedRegionsOption, resolvedMonacoOptions, desiredEditorKind, currentEditorKind, usePreCodeRender, showInlinePreview, isDevEnv: isDevEnv2, codeFontMin, codeFontMax, codeFontStep, defaultCodeFontSize, codeFontSize, fontBaselineReady, CONTENT_PADDING, LINE_EXTRA_PER_LINE, PIXEL_EPSILON, measureLineHeightFromDom, readActualFontSizeFromEditor, getLineHeightSafe, ensureFontBaseline, increaseCodeFont, decreaseCodeFont, resetCodeFont, computeContentHeight, getColorLuminance, shouldPreferPlainTextFallbackSurface, syncEditorCssVars, resizeSyncHandler, SCROLL_PARENT_OVERFLOW_RE, resolveScrollRootElement, adjustScrollAfterHeightChange, updateExpandedHeight, clearInlineFoldProxies, syncInlineFoldProxies, scheduleEditorVisualSync, syncDiffRevealButtons, applyCollapsedContainerHeight, updateCollapsedHeight, getMaxHeightValue, isPreviewable, displayLanguage, languageIcon, containerStyle, headerStyle, tooltipsEnabled, copy, resolveTooltipTarget, onBtnHover, onBtnLeave, onCopyHover, toggleExpand, toggleHeaderCollapse, previewCode, setAutomaticLayout, runEditorCreation, ensureEditorCreation, stopCreateEditorWatch, getPreferredColorScheme, getThemeName, hasTheme, addRuntimeLanguage, runtimeMonacoThemes, runtimeMonacoLanguages, resolveRequestedTheme, themeUpdate, themeLooksDark, resolvedChromeIsDark, effectiveDiffAppearance, resolvedSurfaceIsDark, preFallbackMetrics, preFallbackDiffInline, preFallbackStyle, buildRuntimeMonacoOptions, syncRuntimeMonacoOptions, monacoStructuralSignature, stopLoadingWatch, stopExpandAutoResize, PreCodeNode, HtmlPreviewFrame };
7578
7932
  }
7579
7933
  });
7580
- const CodeBlockNode_vue_vue_type_style_index_0_scoped_f73cb5ae_lang = "";
7934
+ const CodeBlockNode_vue_vue_type_style_index_0_scoped_b3974933_lang = "";
7581
7935
  var _sfc_render$9 = function render37() {
7582
7936
  var _vm = this, _c = _vm._self._c, _setup = _vm._self._setupProxy;
7583
- return _setup.usePreCodeRender ? _c(_setup.PreCodeNode, { attrs: { "node": _vm.node, "loading": _setup.props.loading } }) : _c("div", { ref: "container", staticClass: "code-block-container my-4 rounded-lg border overflow-hidden shadow-sm", class: [
7937
+ return _setup.usePreCodeRender ? _c(_setup.PreCodeNode, { staticClass: "code-pre-fallback", style: _setup.preFallbackStyle, attrs: { "node": _vm.node, "show-line-numbers": _setup.isDiff, "diff-inline": _setup.preFallbackDiffInline } }) : _c("div", { ref: "container", staticClass: "code-block-container my-4 rounded-lg border overflow-hidden shadow-sm", class: [
7584
7938
  _setup.resolvedSurfaceIsDark ? "border-gray-700/30 bg-gray-900" : "border-gray-200 bg-white",
7585
7939
  { "is-rendering": _setup.props.loading, "is-dark": _setup.resolvedSurfaceIsDark, "is-diff": _setup.isDiff, "is-plain-text": _setup.isPlainTextLanguage }
7586
7940
  ], style: _setup.containerStyle }, [_setup.props.showHeader ? _c("div", { staticClass: "code-block-header flex justify-between items-center px-4 py-2.5 border-b border-gray-400/5", style: _setup.headerStyle }, [_vm._t("header-left", function() {
@@ -7623,7 +7977,7 @@ var _sfc_render$9 = function render37() {
7623
7977
  }, "focus": function($event) {
7624
7978
  _setup.onBtnHover($event, _setup.t("common.preview") || "Preview");
7625
7979
  }, "mouseleave": _setup.onBtnLeave, "blur": _setup.onBtnLeave } }, [_c("svg", { attrs: { "xmlns": "http://www.w3.org/2000/svg", "width": "12", "height": "12", "viewBox": "0 0 24 24" } }, [_c("g", { attrs: { "fill": "currentColor", "fill-rule": "evenodd", "clip-rule": "evenodd" } }, [_c("path", { attrs: { "d": "M23.628 7.41c-.12-1.172-.08-3.583-.9-4.233c-1.921-1.51-6.143-1.11-8.815-1.19c-3.481-.15-7.193.14-10.625.24a.34.34 0 0 0 0 .67c3.472-.05 7.074-.29 10.575-.09c2.471.15 6.653-.14 8.254 1.16c.4.33.41 2.732.49 3.582a42 42 0 0 1 .08 9.005a13.8 13.8 0 0 1-.45 3.001c-2.42 1.4-19.69 2.381-20.72.55a21 21 0 0 1-.65-4.632a41.5 41.5 0 0 1 .12-7.964c.08 0 7.334.33 12.586.24c2.331 0 4.682-.13 6.764-.21a.33.33 0 0 0 0-.66c-7.714-.16-12.897-.43-19.31.05c.11-1.38.48-3.922.38-4.002a.3.3 0 0 0-.42 0c-.37.41-.29 1.77-.36 2.251s-.14 1.07-.2 1.6a45 45 0 0 0-.36 8.645a21.8 21.8 0 0 0 .66 5.002c1.46 2.702 17.248 1.461 20.95.43c1.45-.4 1.69-.8 1.871-1.95c.575-3.809.602-7.68.08-11.496" } }), _c("path", { attrs: { "d": "M4.528 5.237a.84.84 0 0 0-.21-1c-.77-.41-1.71.39-1 1.1a.83.83 0 0 0 1.21-.1m2.632-.25c.14-.14.19-.84-.2-1c-.77-.41-1.71.39-1 1.09a.82.82 0 0 0 1.2-.09m2.88 0a.83.83 0 0 0-.21-1c-.77-.41-1.71.39-1 1.09a.82.82 0 0 0 1.21-.09m-4.29 8.735c0 .08.23 2.471.31 2.561a.371.371 0 0 0 .63-.14c0-.09 0 0 .15-1.72a10 10 0 0 0-.11-2.232a5.3 5.3 0 0 1-.26-1.37a.3.3 0 0 0-.54-.24a6.8 6.8 0 0 0-.2 2.33c-1.281-.38-1.121.13-1.131-.42a15 15 0 0 0-.19-1.93c-.16-.17-.36-.17-.51.14a20 20 0 0 0-.43 3.471c.04.773.18 1.536.42 2.272c.26.4.7.22.7-.1c0-.09-.16-.09 0-1.862c.06-1.18-.23-.3 1.16-.76m5.033-2.552c.32-.07.41-.28.39-.37c0-.55-3.322-.34-3.462-.24s-.2.18-.18.28s0 .11 0 .16a3.8 3.8 0 0 0 1.591.361v.82a15 15 0 0 0-.13 3.132c0 .2-.09.94.17 1.16a.34.34 0 0 0 .48 0c.125-.35.196-.718.21-1.09a8 8 0 0 0 .14-3.232c0-.13.05-.7-.1-.89a8 8 0 0 0 .89-.09m5.544-.181a.69.69 0 0 0-.89-.44a2.8 2.8 0 0 0-1.252 1.001a2.3 2.3 0 0 0-.41-.83a1 1 0 0 0-1.6.27a7 7 0 0 0-.35 2.07c0 .571 0 2.642.06 2.762c.14 1.09 1 .51.63.13a17.6 17.6 0 0 1 .38-3.962c.32-1.18.32.2.39.51s.11 1.081.73 1.081s.48-.93 1.401-1.78q.075 1.345 0 2.69a15 15 0 0 0 0 1.811a.34.34 0 0 0 .68 0q.112-.861.11-1.73a16.7 16.7 0 0 0 .12-3.582m1.441-.201c-.05.16-.3 3.002-.31 3.202a6.3 6.3 0 0 0 .21 1.741c.33 1 1.21 1.07 2.291.82a3.7 3.7 0 0 0 1.14-.23c.21-.22.10-.59-.41-.64q-.817.096-1.64.07c-.44-.07-.34 0-.67-4.442q.015-.185 0-.37a.316.316 0 0 0-.23-.38a.316.316 0 0 0-.38.23" } })])])]) : _vm._e()], 2)];
7626
- })], 2) : _vm._e(), _c("div", { directives: [{ name: "show", rawName: "v-show", value: !_setup.isCollapsed && (_vm.stream ? true : !_vm.loading), expression: "!isCollapsed && (stream ? true : !loading)" }], staticClass: "code-editor-layer" }, [_c("div", { ref: "codeEditor", staticClass: "code-editor-container", class: [_vm.stream ? "" : "code-height-placeholder"] })]), _setup.showInlinePreview && !_setup.hasPreviewListener && _setup.isPreviewable && _setup.codeLanguage === "html" ? _c(_setup.HtmlPreviewFrame, { attrs: { "code": _vm.node.code, "html-preview-allow-scripts": _setup.props.htmlPreviewAllowScripts, "html-preview-sandbox": _setup.props.htmlPreviewSandbox, "is-dark": _setup.props.isDark, "on-close": () => _setup.showInlinePreview = false } }) : _vm._e(), _c("div", { directives: [{ name: "show", rawName: "v-show", value: !_vm.stream && _vm.loading, expression: "!stream && loading" }], staticClass: "code-loading-placeholder" }, [_vm._t("loading", function() {
7980
+ })], 2) : _vm._e(), _c("div", { directives: [{ name: "show", rawName: "v-show", value: !_setup.isCollapsed && (_vm.stream ? true : !_vm.loading), expression: "!isCollapsed && (stream ? true : !loading)" }], staticClass: "code-editor-layer" }, [_c("div", { ref: "codeEditor", staticClass: "code-editor-container", class: [_vm.stream ? "" : "code-height-placeholder"], style: { visibility: _setup.editorReady ? "visible" : "hidden" }, attrs: { "aria-hidden": _setup.editorReady ? void 0 : "true" } }), !_setup.editorReady ? _c("div", { staticClass: "code-editor-fallback-surface" }, [_c(_setup.PreCodeNode, { staticClass: "code-pre-fallback", style: _setup.preFallbackStyle, attrs: { "node": _vm.node, "show-line-numbers": _setup.isDiff, "diff-inline": _setup.preFallbackDiffInline } })], 1) : _vm._e()]), _setup.showInlinePreview && !_setup.hasPreviewListener && _setup.isPreviewable && _setup.codeLanguage === "html" ? _c(_setup.HtmlPreviewFrame, { attrs: { "code": _vm.node.code, "html-preview-allow-scripts": _setup.props.htmlPreviewAllowScripts, "html-preview-sandbox": _setup.props.htmlPreviewSandbox, "is-dark": _setup.props.isDark, "on-close": () => _setup.showInlinePreview = false } }) : _vm._e(), _c("div", { directives: [{ name: "show", rawName: "v-show", value: !_vm.stream && _vm.loading, expression: "!stream && loading" }], staticClass: "code-loading-placeholder" }, [_vm._t("loading", function() {
7627
7981
  return [_c("div", { staticClass: "loading-skeleton" }, [_c("div", { staticClass: "skeleton-line" }), _c("div", { staticClass: "skeleton-line" }), _c("div", { staticClass: "skeleton-line short" })])];
7628
7982
  }, { "loading": _vm.loading, "stream": _vm.stream })], 2), _c("span", { staticClass: "sr-only", attrs: { "aria-live": "polite", "role": "status" } }, [_vm._v(_vm._s(_setup.copyText ? _setup.t("common.copied") || "Copied" : ""))])], 1);
7629
7983
  };
@@ -7634,7 +7988,7 @@ var __component__$9 = /* @__PURE__ */ normalizeComponent(
7634
7988
  _sfc_staticRenderFns$9,
7635
7989
  false,
7636
7990
  null,
7637
- "f73cb5ae",
7991
+ "b3974933",
7638
7992
  null,
7639
7993
  null
7640
7994
  );