@singapore-editor/minimap 0.1.1

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.
Files changed (56) hide show
  1. package/README.md +29 -0
  2. package/dist/assets/minimap.worker-i4S59IOV.js +1616 -0
  3. package/dist/assets/minimap.worker-i4S59IOV.js.map +1 -0
  4. package/dist/color.d.ts +11 -0
  5. package/dist/color.d.ts.map +1 -0
  6. package/dist/color.js +83 -0
  7. package/dist/color.js.map +1 -0
  8. package/dist/decorationMerge.d.ts +10 -0
  9. package/dist/decorationMerge.d.ts.map +1 -0
  10. package/dist/decorationMerge.js +65 -0
  11. package/dist/decorationMerge.js.map +1 -0
  12. package/dist/index.d.ts +4 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +3 -0
  15. package/dist/layout.d.ts +43 -0
  16. package/dist/layout.d.ts.map +1 -0
  17. package/dist/layout.js +137 -0
  18. package/dist/layout.js.map +1 -0
  19. package/dist/minimap.worker.d.ts +2 -0
  20. package/dist/minimap.worker.d.ts.map +1 -0
  21. package/dist/minimapCharRenderer.d.ts +13 -0
  22. package/dist/minimapCharRenderer.d.ts.map +1 -0
  23. package/dist/minimapCharRendererFactory.d.ts +14 -0
  24. package/dist/minimapCharRendererFactory.d.ts.map +1 -0
  25. package/dist/minimapCharSheet.d.ts +15 -0
  26. package/dist/minimapCharSheet.d.ts.map +1 -0
  27. package/dist/minimapCharSheet.js +24 -0
  28. package/dist/minimapCharSheet.js.map +1 -0
  29. package/dist/options.d.ts +3 -0
  30. package/dist/options.d.ts.map +1 -0
  31. package/dist/options.js +65 -0
  32. package/dist/options.js.map +1 -0
  33. package/dist/plugin.d.ts +4 -0
  34. package/dist/plugin.d.ts.map +1 -0
  35. package/dist/plugin.js +415 -0
  36. package/dist/plugin.js.map +1 -0
  37. package/dist/raster.d.ts +10 -0
  38. package/dist/raster.d.ts.map +1 -0
  39. package/dist/renderer.d.ts +58 -0
  40. package/dist/renderer.d.ts.map +1 -0
  41. package/dist/sectionHeaders.d.ts +13 -0
  42. package/dist/sectionHeaders.d.ts.map +1 -0
  43. package/dist/style.css +97 -0
  44. package/dist/types.d.ts +211 -0
  45. package/dist/types.d.ts.map +1 -0
  46. package/dist/types.js +11 -0
  47. package/dist/types.js.map +1 -0
  48. package/dist/viewportGeometry.d.ts +28 -0
  49. package/dist/viewportGeometry.d.ts.map +1 -0
  50. package/dist/viewportGeometry.js +22 -0
  51. package/dist/viewportGeometry.js.map +1 -0
  52. package/dist/workerClient.d.ts +131 -0
  53. package/dist/workerClient.d.ts.map +1 -0
  54. package/dist/workerClient.js +1337 -0
  55. package/dist/workerClient.js.map +1 -0
  56. package/package.json +50 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"minimap.worker-i4S59IOV.js","names":[],"sources":["../../../editor/dist/logging/evlog.js","../../src/color.ts","../../src/minimapCharSheet.ts","../../src/types.ts","../../src/layout.ts","../../src/minimapCharRenderer.ts","../../src/minimapCharRendererFactory.ts","../../src/raster.ts","../../src/sectionHeaders.ts","../../src/renderer.ts","../../src/minimap.worker.ts"],"sourcesContent":["import { initLog, log } from \"evlog/client\";\n//#region src/logging/evlog.ts\nvar evlogErrorInternalKey = Symbol.for(\"editor.evlog.error.internal\");\nvar evlogInitialized = false;\nvar EditorEvlogError = class extends Error {\n\t[evlogErrorInternalKey];\n\tcode;\n\tfix;\n\tlink;\n\tstatus;\n\twhy;\n\tconstructor(options) {\n\t\tconst resolved = typeof options === \"string\" ? { message: options } : options;\n\t\tsuper(resolved.message, { cause: resolved.cause });\n\t\tthis.name = \"EvlogError\";\n\t\tthis.code = resolved.code;\n\t\tthis.fix = resolved.fix;\n\t\tthis.link = resolved.link;\n\t\tthis.status = resolved.status ?? 500;\n\t\tthis.why = resolved.why;\n\t\tif (resolved.internal !== void 0) this.defineInternal(resolved.internal);\n\t}\n\tget internal() {\n\t\treturn this[evlogErrorInternalKey];\n\t}\n\tget statusText() {\n\t\treturn this.message;\n\t}\n\tget statusCode() {\n\t\treturn this.status;\n\t}\n\tget statusMessage() {\n\t\treturn this.message;\n\t}\n\tget data() {\n\t\tif (!this.code && !this.why && !this.fix && !this.link) return void 0;\n\t\treturn {\n\t\t\tcode: this.code,\n\t\t\twhy: this.why,\n\t\t\tfix: this.fix,\n\t\t\tlink: this.link\n\t\t};\n\t}\n\ttoString() {\n\t\treturn evlogErrorLines(this).join(\"\\n\");\n\t}\n\ttoJSON() {\n\t\tconst serialized = {\n\t\t\tmessage: this.message,\n\t\t\tname: this.name,\n\t\t\tstatus: this.status\n\t\t};\n\t\tif (this.data) serialized.data = this.data;\n\t\tif (this.cause instanceof Error) serialized.cause = {\n\t\t\tmessage: this.cause.message,\n\t\t\tname: this.cause.name\n\t\t};\n\t\treturn serialized;\n\t}\n\tdefineInternal(internal) {\n\t\tObject.defineProperty(this, evlogErrorInternalKey, {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: false,\n\t\t\tvalue: internal,\n\t\t\twritable: false\n\t\t});\n\t}\n};\nfunction createError(options) {\n\treturn new EditorEvlogError(options);\n}\nfunction createEditorEvlogLoggingPlugin(options = {}) {\n\treturn {\n\t\tname: options.name ?? \"editor.evlog-logging\",\n\t\tactivate(context) {\n\t\t\tinitializeEvlog(options.init);\n\t\t\treturn context.registerLogger(createEditorEvlogLogger(options));\n\t\t}\n\t};\n}\nfunction createEditorEvlogLogger(options = {}) {\n\tconst target = options.log ?? log;\n\tconst mapEvent = options.mapEvent ?? editorLogEventToEvlogEvent;\n\treturn (event) => {\n\t\ttarget[event.level](mapEvent(event));\n\t};\n}\nfunction createEditorEvlogPlugin(options = {}) {\n\treturn createEditorEvlogLoggingPlugin(options);\n}\nfunction initializeEvlog(options) {\n\tif (options === false) return;\n\tif (evlogInitialized) return;\n\tinitLog({\n\t\tconsole: true,\n\t\tpretty: true,\n\t\tservice: \"editor\",\n\t\t...options\n\t});\n\tevlogInitialized = true;\n}\nfunction editorLogEventToEvlogEvent(event) {\n\treturn {\n\t\t...event,\n\t\taction: event.action,\n\t\tsource: event.source,\n\t\ttimestamp: event.timestamp\n\t};\n}\nfunction evlogErrorLines(error) {\n\tconst lines = [`Error: ${error.message}`];\n\tif (error.code) lines.push(`Code: ${error.code}`);\n\tif (error.why) lines.push(`Why: ${error.why}`);\n\tif (error.fix) lines.push(`Fix: ${error.fix}`);\n\tif (error.link) lines.push(`More info: ${error.link}`);\n\tif (error.cause instanceof Error) lines.push(`Caused by: ${error.cause.message}`);\n\treturn lines;\n}\n//#endregion\nexport { EditorEvlogError, createEditorEvlogLogger, createEditorEvlogLoggingPlugin, createEditorEvlogPlugin, createError, createError as createEvlogError };\n\n//# sourceMappingURL=evlog.js.map","import type { RGBA8 } from './types'\n\nexport const RGBA_EMPTY: RGBA8 = { r: 0, g: 0, b: 0, a: 0 }\nexport const RGBA_WHITE: RGBA8 = { r: 255, g: 255, b: 255, a: 255 }\nexport const RGBA_BLACK: RGBA8 = { r: 0, g: 0, b: 0, a: 255 }\n\nexport function rgbaEquals(left: RGBA8, right: RGBA8): boolean {\n return left.r === right.r && left.g === right.g && left.b === right.b && left.a === right.a\n}\n\nexport function transparent(color: RGBA8, ratio: number): RGBA8 {\n return { ...color, a: clamp8(color.a * ratio) }\n}\n\nexport function rgbaToCss(color: RGBA8): string {\n return `rgba(${color.r}, ${color.g}, ${color.b}, ${color.a / 255})`\n}\n\nexport function parseCssColor(value: string | undefined, fallback: RGBA8 = RGBA_EMPTY): RGBA8 {\n if (!value) return fallback\n\n const trimmed = value.trim()\n if (trimmed.startsWith('#')) return parseHexColor(trimmed, fallback)\n if (trimmed.startsWith('rgb')) return parseRgbColor(trimmed, fallback)\n return fallback\n}\n\nexport function relativeLuminance(color: RGBA8): number {\n const r = linearRgb(color.r / 255)\n const g = linearRgb(color.g / 255)\n const b = linearRgb(color.b / 255)\n return 0.2126 * r + 0.7152 * g + 0.0722 * b\n}\n\nexport function clamp8(value: number): number {\n return Math.min(255, Math.max(0, Math.round(value)))\n}\n\nfunction parseHexColor(value: string, fallback: RGBA8): RGBA8 {\n const hex = value.slice(1)\n if (hex.length === 3) return shortHex(hex, fallback)\n if (hex.length === 4) return shortHexAlpha(hex, fallback)\n if (hex.length === 6) return longHex(hex, 'ff', fallback)\n if (hex.length === 8) return longHex(hex.slice(0, 6), hex.slice(6), fallback)\n return fallback\n}\n\nfunction shortHex(hex: string, fallback: RGBA8): RGBA8 {\n return longHex(\n hex\n .split('')\n .map((char) => char + char)\n .join(''),\n 'ff',\n fallback,\n )\n}\n\nfunction shortHexAlpha(hex: string, fallback: RGBA8): RGBA8 {\n const rgb = hex.slice(0, 3)\n const alpha = hex[3] ?? 'f'\n return longHex(\n rgb\n .split('')\n .map((char) => char + char)\n .join(''),\n alpha + alpha,\n fallback,\n )\n}\n\nfunction longHex(rgb: string, alpha: string, fallback: RGBA8): RGBA8 {\n const value = Number.parseInt(rgb + alpha, 16)\n if (!Number.isFinite(value)) return fallback\n\n return {\n r: (value >> 24) & 0xff,\n g: (value >> 16) & 0xff,\n b: (value >> 8) & 0xff,\n a: value & 0xff,\n }\n}\n\nfunction parseRgbColor(value: string, fallback: RGBA8): RGBA8 {\n const body = value.slice(value.indexOf('(') + 1, value.lastIndexOf(')'))\n const parts = body.split(/[,\\s/]+/).filter(Boolean)\n if (parts.length < 3) return fallback\n\n return {\n r: clamp8(Number(parts[0])),\n g: clamp8(Number(parts[1])),\n b: clamp8(Number(parts[2])),\n a: alphaPart(parts[3]),\n }\n}\n\nfunction alphaPart(value: string | undefined): number {\n if (!value) return 255\n if (value.endsWith('%')) return clamp8((Number.parseFloat(value) / 100) * 255)\n\n const number = Number(value)\n if (!Number.isFinite(number)) return 255\n if (number <= 1) return clamp8(number * 255)\n return clamp8(number)\n}\n\nfunction linearRgb(value: number): number {\n if (value <= 0.04045) return value / 12.92\n return ((value + 0.055) / 1.055) ** 2.4\n}\n","export const enum Constants {\n START_CH_CODE = 32,\n END_CH_CODE = 126,\n UNKNOWN_CODE = 65533,\n CHAR_COUNT = END_CH_CODE - START_CH_CODE + 2,\n SAMPLED_CHAR_HEIGHT = 16,\n SAMPLED_CHAR_WIDTH = 10,\n BASE_CHAR_HEIGHT = 2,\n BASE_CHAR_WIDTH = 1,\n RGBA_CHANNELS_CNT = 4,\n RGBA_SAMPLED_ROW_WIDTH = RGBA_CHANNELS_CNT * CHAR_COUNT * SAMPLED_CHAR_WIDTH,\n}\n\nexport const allCharCodes: ReadonlyArray<number> = (() => {\n const values: number[] = []\n for (let index = Constants.START_CH_CODE; index <= Constants.END_CH_CODE; index += 1) {\n values.push(index)\n }\n\n values.push(Constants.UNKNOWN_CODE)\n return values\n})()\n\nexport const getCharIndex = (chCode: number, fontScale: number): number => {\n const index = chCode - Constants.START_CH_CODE\n if (index >= 0 && index <= Constants.CHAR_COUNT) return index\n if (fontScale <= 2) return (index + Constants.CHAR_COUNT) % Constants.CHAR_COUNT\n return Constants.CHAR_COUNT - 1\n}\n","import type { TextEdit } from '@singapore-editor/core/document'\nimport type {\n EditorMinimapDecoration as CoreEditorMinimapDecoration,\n EditorMinimapDecorationPosition as CoreEditorMinimapDecorationPosition,\n EditorMinimapSectionHeaderStyle as CoreEditorMinimapSectionHeaderStyle,\n} from '@singapore-editor/core/extensions'\n\nexport const enum RenderMinimap {\n None = 0,\n Text = 1,\n Blocks = 2,\n}\n\nexport type MinimapSide = 'left' | 'right'\nexport type MinimapSize = 'proportional' | 'fill' | 'fit'\nexport type MinimapSliderVisibility = 'always' | 'mouseover'\nexport type MinimapAutohide = 'none' | 'mouseover' | 'scroll'\nexport type MinimapDecorationPosition = CoreEditorMinimapDecorationPosition\nexport type MinimapSectionHeaderStyle = CoreEditorMinimapSectionHeaderStyle\n\nexport type RGBA8 = {\n readonly r: number\n readonly g: number\n readonly b: number\n readonly a: number\n}\n\nexport type EditorMinimapOptions = {\n readonly enabled?: boolean\n readonly autohide?: MinimapAutohide\n readonly side?: MinimapSide\n readonly size?: MinimapSize\n readonly showSlider?: MinimapSliderVisibility\n readonly renderCharacters?: boolean\n readonly maxColumn?: number\n readonly scale?: number\n readonly showRegionSectionHeaders?: boolean\n readonly showMarkSectionHeaders?: boolean\n readonly markSectionHeaderRegex?: string\n readonly sectionHeaderFontSize?: number\n readonly sectionHeaderLetterSpacing?: number\n}\n\nexport type ResolvedMinimapOptions = {\n readonly enabled: boolean\n readonly autohide: MinimapAutohide\n readonly side: MinimapSide\n readonly size: MinimapSize\n readonly showSlider: MinimapSliderVisibility\n readonly renderCharacters: boolean\n readonly maxColumn: number\n readonly scale: number\n readonly showRegionSectionHeaders: boolean\n readonly showMarkSectionHeaders: boolean\n readonly markSectionHeaderRegex: string\n readonly sectionHeaderFontSize: number\n readonly sectionHeaderLetterSpacing: number\n}\n\nexport type EditorMinimapDecoration = CoreEditorMinimapDecoration\n\nexport type MinimapToken = {\n readonly start: number\n readonly end: number\n readonly color: RGBA8\n}\n\nexport type MinimapTokenPatch = {\n readonly start: number\n readonly deleteCount: number\n readonly tokens: readonly MinimapToken[]\n}\n\nexport type MinimapSelection = {\n readonly startOffset: number\n readonly endOffset: number\n}\n\nexport type MinimapViewport = {\n readonly scrollTop: number\n readonly scrollRow: number\n readonly scrollLeft: number\n readonly scrollHeight: number\n readonly scrollWidth: number\n readonly clientHeight: number\n readonly clientWidth: number\n readonly minimapHeight: number\n /**\n * The overlay lane the minimap already holds. `clientWidth` is the content box, which\n * excludes it, so layout adds it back: a minimap sized from the space left after itself\n * is a feedback loop, and integer rounding parks it in a one-pixel two-frame cycle.\n */\n readonly reservedWidth: number\n /** Zero-based document-line bounds, end exclusive. */\n readonly visibleStart: number\n readonly visibleEnd: number\n}\n\nexport type MinimapMetrics = {\n readonly rowHeight: number\n readonly characterWidth: number\n readonly devicePixelRatio: number\n}\n\ntype MinimapDocumentLineSummary = {\n readonly text: string\n readonly length: number\n}\n\nexport type MinimapDocumentSummaryPayload = {\n readonly textLength: number\n readonly lineStarts: readonly number[]\n readonly lines: readonly MinimapDocumentLineSummary[]\n}\n\nexport type MinimapDocumentSummaryPatch = {\n readonly textLength: number\n // Omitted for incremental edits: cloning a full line-start array per\n // keystroke dominates main-thread cost on large documents. The worker\n // splices its own copy from startLine/deleteCount/lines instead.\n readonly lineStarts?: readonly number[]\n readonly startLine: number\n readonly deleteCount: number\n readonly lines: readonly MinimapDocumentLineSummary[]\n}\n\nexport type MinimapDocumentPayload = MinimapDocumentSummaryPayload & {\n readonly tokens: readonly MinimapToken[]\n readonly selections: readonly MinimapSelection[]\n readonly decorations: readonly EditorMinimapDecoration[]\n readonly externalDecorations?: readonly EditorMinimapDecoration[]\n}\n\nexport type MinimapDocumentEditPayload = {\n readonly selections: readonly MinimapSelection[]\n readonly summaryPatch: MinimapDocumentSummaryPatch\n}\n\nexport type MinimapRenderLayout = {\n readonly width: number\n readonly height: number\n readonly canvasInnerWidth: number\n readonly canvasInnerHeight: number\n readonly canvasOuterWidth: number\n readonly canvasOuterHeight: number\n readonly lineHeight: number\n readonly charWidth: number\n readonly scale: number\n readonly isSampling: boolean\n readonly heightIsEditorHeight: boolean\n readonly renderMinimap: RenderMinimap\n}\n\ntype MinimapWorkerInitRequest = {\n readonly type: 'init'\n readonly options: ResolvedMinimapOptions\n readonly baseStyles: MinimapBaseStyles\n readonly mainCanvas: OffscreenCanvas\n readonly decorationsCanvas: OffscreenCanvas\n}\n\nexport type MinimapBaseStyles = {\n readonly foreground: RGBA8\n readonly background: RGBA8\n readonly minimapBackground: RGBA8\n readonly foregroundOpacity: number\n readonly selection: RGBA8\n readonly slider: string\n readonly sliderHover: string\n readonly sliderActive: string\n readonly fontFamily: string\n}\n\nexport type MinimapWorkerRequest =\n | MinimapWorkerInitRequest\n | { readonly type: 'updateBaseStyles'; readonly baseStyles: MinimapBaseStyles }\n | { readonly type: 'openDocument'; readonly document: MinimapDocumentPayload }\n | { readonly type: 'replaceDocument'; readonly document: MinimapDocumentPayload }\n | {\n readonly type: 'applyEdit'\n readonly edit: TextEdit\n readonly document: MinimapDocumentEditPayload\n }\n | {\n readonly type: 'applyEdits'\n readonly edits: readonly TextEdit[]\n readonly document: MinimapDocumentEditPayload\n }\n | { readonly type: 'updateTokens'; readonly tokens: readonly MinimapToken[] }\n | { readonly type: 'updateTokenRange'; readonly patch: MinimapTokenPatch }\n | { readonly type: 'updateSelection'; readonly selections: readonly MinimapSelection[] }\n | { readonly type: 'updateDecorations'; readonly decorations: readonly EditorMinimapDecoration[] }\n | {\n readonly type: 'updateExternalDecorations'\n readonly decorations: readonly EditorMinimapDecoration[]\n }\n | {\n readonly type: 'updateLayout'\n readonly metrics: MinimapMetrics\n readonly viewport: MinimapViewport\n }\n | { readonly type: 'updateViewport'; readonly viewport: MinimapViewport }\n | { readonly type: 'render'; readonly sequence: number }\n | { readonly type: 'dispose' }\n\nexport type MinimapWorkerResponse =\n | { readonly type: 'layout'; readonly sequence: number; readonly layout: MinimapRenderLayout }\n | { readonly type: 'disposed' }\n | {\n readonly type: 'rendered'\n readonly sequence: number\n readonly sliderNeeded: boolean\n readonly sliderTop: number\n readonly sliderHeight: number\n readonly shadowVisible: boolean\n }\n | { readonly type: 'error'; readonly sequence?: number; readonly message: string }\n","import type { EditorViewSnapshot, EditorViewportSnapshot } from '@singapore-editor/core/extensions'\nimport { Constants } from './minimapCharSheet'\nimport type {\n MinimapMetrics,\n MinimapRenderLayout,\n MinimapViewport,\n ResolvedMinimapOptions,\n} from './types'\nimport { RenderMinimap } from './types'\n\nexport const MINIMAP_GUTTER_WIDTH = 2\nexport const MINIMAP_RIGHT_GUTTER_WIDTH = 8\n\nexport type MinimapFrameLayout = {\n readonly scrollTop: number\n readonly scrollHeight: number\n readonly sliderNeeded: boolean\n readonly sliderLineHeight: number\n readonly documentLineHeight: number\n readonly documentStart: number\n readonly sliderTop: number\n readonly sliderHeight: number\n readonly topPaddingLineCount: number\n readonly startLineNumber: number\n readonly startLineFraction: number\n readonly endLineNumber: number\n}\n\nexport function computeRenderLayout(options: {\n readonly minimap: ResolvedMinimapOptions\n readonly metrics: MinimapMetrics\n readonly viewport: MinimapViewport\n readonly lineCount: number\n}): MinimapRenderLayout {\n const pixelRatio = Math.max(1, options.metrics.devicePixelRatio)\n const height = Math.max(0, options.viewport.minimapHeight)\n const baseCharHeight = options.minimap.renderCharacters\n ? Constants.BASE_CHAR_HEIGHT\n : Constants.BASE_CHAR_HEIGHT + 1\n const configuredScale =\n pixelRatio >= 2 ? Math.round(options.minimap.scale * 2) : options.minimap.scale\n const baseCanvasInnerHeight = Math.floor(pixelRatio * height)\n const fitted = computeFittedScale({\n baseCharHeight,\n canvasInnerHeight: baseCanvasInnerHeight,\n configuredScale,\n height,\n lineCount: options.lineCount,\n // A collapsed span can exceed the proportional raster's document coverage.\n minimap:\n (options.viewport.visibleEnd - options.viewport.visibleStart) *\n baseCharHeight *\n configuredScale >\n baseCanvasInnerHeight\n ? { ...options.minimap, size: 'fill' }\n : options.minimap,\n pixelRatio,\n rowHeight: options.metrics.rowHeight,\n })\n const layoutCharWidth = fitted.scale / pixelRatio / fitted.widthMultiplier\n const width = computeMinimapWidth({\n charWidth: layoutCharWidth,\n maxColumn: options.minimap.maxColumn,\n viewportWidth: options.viewport.clientWidth + Math.max(0, options.viewport.reservedWidth),\n characterWidth: options.metrics.characterWidth,\n })\n const baseCanvasInnerWidth = Math.floor(pixelRatio * width)\n const canvasInnerWidth = Math.floor(baseCanvasInnerWidth * fitted.widthMultiplier)\n const canvasInnerHeight = fitted.heightIsEditorHeight\n ? Math.ceil(Math.max(baseCanvasInnerHeight, fitted.documentMinimapHeight))\n : baseCanvasInnerHeight\n\n return {\n width,\n height,\n canvasInnerWidth,\n canvasInnerHeight,\n canvasOuterWidth: baseCanvasInnerWidth / pixelRatio,\n canvasOuterHeight: baseCanvasInnerHeight / pixelRatio,\n lineHeight: fitted.lineHeight,\n charWidth: Constants.BASE_CHAR_WIDTH * fitted.scale,\n scale: fitted.scale,\n isSampling: fitted.isSampling,\n heightIsEditorHeight: fitted.heightIsEditorHeight,\n renderMinimap: options.minimap.enabled\n ? options.minimap.renderCharacters\n ? RenderMinimap.Text\n : RenderMinimap.Blocks\n : RenderMinimap.None,\n }\n}\n\nexport function computeFrameLayout(options: {\n readonly renderLayout: MinimapRenderLayout\n readonly metrics: MinimapMetrics\n readonly viewport: MinimapViewport\n readonly lineCount: number\n readonly realLineCount: number\n readonly previous: MinimapFrameLayout | null\n}): MinimapFrameLayout {\n const { renderLayout: layout, viewport, realLineCount } = options\n const pixelRatio = layout.canvasInnerHeight / Math.max(1, layout.canvasOuterHeight)\n const documentLineHeight = layout.isSampling\n ? layout.height / Math.max(1, realLineCount)\n : layout.lineHeight / pixelRatio\n const start = Math.min(realLineCount, Math.max(0, viewport.visibleStart))\n const end = Math.min(realLineCount, Math.max(start, viewport.visibleEnd))\n const visibleCount = end - start\n const linesFitting = layout.height / documentLineHeight\n const travel = Math.max(0, realLineCount - linesFitting)\n const progress = start / Math.max(1, realLineCount - visibleCount)\n const documentStart = Math.min(start, travel * progress)\n const rasterStart = layout.isSampling ? 0 : documentStart\n const startLineNumber = Math.floor(rasterStart) + 1\n const startLineFraction = rasterStart - Math.floor(rasterStart)\n return {\n scrollTop: viewport.scrollTop,\n scrollHeight: viewport.scrollHeight,\n sliderNeeded: visibleCount < realLineCount,\n documentLineHeight,\n sliderLineHeight:\n travel > 0\n ? Math.max(0, layout.height - visibleCount * documentLineHeight) /\n Math.max(1, realLineCount - visibleCount)\n : documentLineHeight,\n documentStart,\n sliderTop: (start - documentStart) * documentLineHeight,\n sliderHeight: Math.min(layout.height, visibleCount * documentLineHeight),\n topPaddingLineCount: 0,\n startLineNumber,\n startLineFraction,\n endLineNumber: Math.min(\n options.lineCount,\n startLineNumber +\n Math.ceil(layout.canvasInnerHeight / layout.lineHeight + startLineFraction) -\n 1,\n ),\n }\n}\n\n/** Zero-based document line at a CSS pixel in the rendered minimap. */\nexport function documentLineAtY(frame: MinimapFrameLayout, y: number): number {\n return frame.documentStart + y / frame.documentLineHeight\n}\n\n/** Inverse of slider placement, including a proportional raster's moving origin. */\nexport function documentLineForSliderY(frame: MinimapFrameLayout, y: number): number {\n if (frame.sliderLineHeight <= 0) return 0\n return y / frame.sliderLineHeight\n}\n\n/** Mounted rows include overscan. Continuations still identify a visible document line. */\nexport function visibleDocumentLineRange(\n snapshot: Pick<EditorViewSnapshot, 'visibleRows' | 'lineCount'>,\n viewport: EditorViewportSnapshot,\n): { readonly start: number; readonly end: number } {\n let start = Infinity\n let end = 0\n const wrapped = new Set(\n snapshot.visibleRows\n .filter((row) => row.source === 'document' && !row.firstWrapSegment)\n .map((row) => row.bufferRow),\n )\n for (const row of snapshot.visibleRows) {\n if (row.source !== 'document') continue\n if (row.top + row.height <= viewport.scrollTop) continue\n if (row.top >= viewport.scrollTop + viewport.clientHeight) continue\n const clippedStart = Math.max(0, (viewport.scrollTop - row.top) / row.height)\n const clippedEnd = Math.min(\n 1,\n (viewport.scrollTop + viewport.clientHeight - row.top) / row.height,\n )\n start = Math.min(start, row.bufferRow + (wrapped.has(row.bufferRow) ? 0 : clippedStart))\n end = Math.max(end, row.bufferRow + (wrapped.has(row.bufferRow) ? 1 : clippedEnd))\n }\n if (start !== Infinity) return { start, end }\n const nearest = snapshot.visibleRows.find((row) => row.source === 'document')\n const anchor = Math.min(Math.max(0, snapshot.lineCount - 1), nearest?.bufferRow ?? 0)\n return { start: anchor, end: anchor }\n}\n\nexport function yForLineNumber(\n frame: Pick<MinimapFrameLayout, 'startLineNumber' | 'topPaddingLineCount'>,\n lineNumber: number,\n minimapLineHeight: number,\n): number {\n return (lineNumber - frame.startLineNumber + frame.topPaddingLineCount) * minimapLineHeight\n}\n\nfunction computeFittedScale(options: {\n readonly minimap: ResolvedMinimapOptions\n readonly baseCharHeight: number\n readonly canvasInnerHeight: number\n readonly configuredScale: number\n readonly height: number\n readonly pixelRatio: number\n readonly rowHeight: number\n readonly lineCount: number\n}): {\n readonly scale: number\n readonly lineHeight: number\n readonly widthMultiplier: number\n readonly isSampling: boolean\n readonly heightIsEditorHeight: boolean\n readonly documentMinimapHeight: number\n} {\n const lineHeight = options.baseCharHeight * options.configuredScale\n if (options.minimap.size === 'proportional') {\n return fittedScale(options.configuredScale, lineHeight, 1, false, false, 0)\n }\n\n const desiredRatio = options.lineCount / Math.max(1, options.canvasInnerHeight)\n if (desiredRatio > 1) return fittedScale(1, 1, 1, true, true, options.canvasInnerHeight)\n\n if (options.minimap.size === 'fit') {\n const documentHeight = Math.ceil(options.lineCount * lineHeight)\n if (documentHeight <= options.canvasInnerHeight) {\n return fittedScale(options.configuredScale, lineHeight, 1, false, false, documentHeight)\n }\n }\n\n const maxScale = options.configuredScale + 1\n const fillLineHeight = Math.min(\n options.rowHeight * options.pixelRatio,\n Math.max(1, Math.floor(1 / desiredRatio)),\n )\n const scale = Math.min(maxScale, Math.max(1, Math.floor(fillLineHeight / options.baseCharHeight)))\n const widthMultiplier =\n scale > options.configuredScale ? Math.min(2, scale / options.configuredScale) : 1\n const typicalViewportLineCount = options.height / Math.max(1, options.rowHeight)\n return fittedScale(\n scale,\n fillLineHeight,\n widthMultiplier,\n false,\n true,\n Math.ceil(Math.max(typicalViewportLineCount, options.lineCount) * fillLineHeight),\n )\n}\n\nfunction fittedScale(\n scale: number,\n lineHeight: number,\n widthMultiplier: number,\n isSampling: boolean,\n heightIsEditorHeight: boolean,\n documentMinimapHeight: number,\n) {\n return {\n scale,\n lineHeight,\n widthMultiplier,\n isSampling,\n heightIsEditorHeight,\n documentMinimapHeight,\n }\n}\n\nfunction computeMinimapWidth(options: {\n readonly charWidth: number\n readonly maxColumn: number\n readonly viewportWidth: number\n readonly characterWidth: number\n}): number {\n const availableWidth = Math.max(0, options.viewportWidth)\n const minimapMaxWidth = Math.floor(options.maxColumn * options.charWidth)\n const proportionalWidth = Math.floor(\n ((availableWidth - 2) * options.charWidth) / (options.characterWidth + options.charWidth),\n )\n return Math.min(\n minimapMaxWidth,\n Math.max(0, proportionalWidth) + MINIMAP_GUTTER_WIDTH + MINIMAP_RIGHT_GUTTER_WIDTH,\n )\n}\n","import { clamp8 } from './color'\nimport { Constants, getCharIndex } from './minimapCharSheet'\nimport type { RGBA8 } from './types'\n\nexport class MinimapCharRenderer {\n private readonly charDataNormal: Uint8ClampedArray\n private readonly charDataLight: Uint8ClampedArray\n\n public constructor(\n charData: Uint8ClampedArray,\n public readonly scale: number,\n ) {\n this.charDataNormal = MinimapCharRenderer.soften(charData, 12 / 15)\n this.charDataLight = MinimapCharRenderer.soften(charData, 50 / 60)\n }\n\n public renderChar(\n target: ImageData,\n dx: number,\n dy: number,\n chCode: number,\n color: RGBA8,\n foregroundAlpha: number,\n backgroundColor: RGBA8,\n backgroundAlpha: number,\n fontScale: number,\n useLighterFont: boolean,\n force1pxHeight: boolean,\n ): void {\n const charWidth = Constants.BASE_CHAR_WIDTH * this.scale\n const charHeight = Constants.BASE_CHAR_HEIGHT * this.scale\n const renderHeight = force1pxHeight ? 1 : charHeight\n if (dx + charWidth > target.width || dy + renderHeight > target.height) return\n\n this.renderCharData({\n target,\n dx,\n dy,\n charWidth,\n renderHeight,\n charIndex: getCharIndex(chCode, fontScale),\n color,\n foregroundAlpha,\n backgroundColor,\n backgroundAlpha,\n charData: useLighterFont ? this.charDataLight : this.charDataNormal,\n })\n }\n\n public blockRenderChar(\n target: ImageData,\n dx: number,\n dy: number,\n color: RGBA8,\n foregroundAlpha: number,\n backgroundColor: RGBA8,\n backgroundAlpha: number,\n force1pxHeight: boolean,\n ): void {\n const charWidth = Constants.BASE_CHAR_WIDTH * this.scale\n const charHeight = Constants.BASE_CHAR_HEIGHT * this.scale\n const renderHeight = force1pxHeight ? 1 : charHeight\n if (dx + charWidth > target.width || dy + renderHeight > target.height) return\n\n const foregroundRatio = 0.5 * (foregroundAlpha / 255)\n const alpha = sourceOverAlpha(backgroundAlpha / 255, foregroundRatio)\n const blended = sourceOverColor(\n backgroundColor,\n color,\n backgroundAlpha / 255,\n foregroundRatio,\n alpha,\n )\n const destWidth = target.width * Constants.RGBA_CHANNELS_CNT\n let row = dy * destWidth + dx * Constants.RGBA_CHANNELS_CNT\n\n for (let y = 0; y < renderHeight; y += 1) {\n writeBlockRow(target.data, row, charWidth, blended, blended.a)\n row += destWidth\n }\n }\n\n private renderCharData(options: RenderCharDataOptions): void {\n if (options.backgroundAlpha === 0) {\n this.renderTransparentCharData(options)\n return\n }\n\n const dest = options.target.data\n const destWidth = options.target.width * Constants.RGBA_CHANNELS_CNT\n let sourceOffset =\n options.charIndex * options.charWidth * Constants.BASE_CHAR_HEIGHT * this.scale\n let row = options.dy * destWidth + options.dx * Constants.RGBA_CHANNELS_CNT\n\n for (let y = 0; y < options.renderHeight; y += 1) {\n sourceOffset = writeCharRow(dest, row, sourceOffset, {\n charWidth: options.charWidth,\n charData: options.charData,\n foregroundAlpha: options.foregroundAlpha,\n color: options.color,\n backgroundColor: options.backgroundColor,\n backgroundAlpha: options.backgroundAlpha,\n })\n row += destWidth\n }\n }\n\n private renderTransparentCharData(options: RenderCharDataOptions): void {\n const dest = options.target.data\n const destWidth = options.target.width * Constants.RGBA_CHANNELS_CNT\n let sourceOffset =\n options.charIndex * options.charWidth * Constants.BASE_CHAR_HEIGHT * this.scale\n let row = options.dy * destWidth + options.dx * Constants.RGBA_CHANNELS_CNT\n\n for (let y = 0; y < options.renderHeight; y += 1) {\n sourceOffset = writeTransparentCharRow(dest, row, sourceOffset, {\n charWidth: options.charWidth,\n charData: options.charData,\n foregroundAlpha: options.foregroundAlpha,\n color: options.color,\n })\n row += destWidth\n }\n }\n\n private static soften(input: Uint8ClampedArray, ratio: number): Uint8ClampedArray {\n const result = new Uint8ClampedArray(input.length)\n for (let index = 0; index < input.length; index += 1)\n result[index] = clamp8(input[index]! * ratio)\n return result\n }\n}\n\ntype RenderCharDataOptions = {\n readonly target: ImageData\n readonly dx: number\n readonly dy: number\n readonly charWidth: number\n readonly renderHeight: number\n readonly charIndex: number\n readonly color: RGBA8\n readonly foregroundAlpha: number\n readonly backgroundColor: RGBA8\n readonly backgroundAlpha: number\n readonly charData: Uint8ClampedArray\n}\n\ntype WriteCharRowOptions = {\n readonly charWidth: number\n readonly charData: Uint8ClampedArray\n readonly foregroundAlpha: number\n readonly color: RGBA8\n readonly backgroundColor: RGBA8\n readonly backgroundAlpha: number\n}\n\ntype WriteTransparentCharRowOptions = {\n readonly charWidth: number\n readonly charData: Uint8ClampedArray\n readonly foregroundAlpha: number\n readonly color: RGBA8\n}\n\nfunction writeCharRow(\n dest: Uint8ClampedArray,\n row: number,\n sourceOffset: number,\n options: WriteCharRowOptions,\n): number {\n let column = row\n let source = sourceOffset\n for (let x = 0; x < options.charWidth; x += 1) {\n const c = ((options.charData[source] ?? 0) / 255) * (options.foregroundAlpha / 255)\n source += 1\n const alpha = sourceOverAlpha(options.backgroundAlpha / 255, c)\n const color = sourceOverColor(\n options.backgroundColor,\n options.color,\n options.backgroundAlpha / 255,\n c,\n alpha,\n )\n dest[column++] = color.r\n dest[column++] = color.g\n dest[column++] = color.b\n dest[column++] = clamp8(alpha * 255)\n }\n return source\n}\n\nfunction writeTransparentCharRow(\n dest: Uint8ClampedArray,\n row: number,\n sourceOffset: number,\n options: WriteTransparentCharRowOptions,\n): number {\n let column = row\n let source = sourceOffset\n for (let x = 0; x < options.charWidth; x += 1) {\n const coverage = ((options.charData[source] ?? 0) / 255) * (options.foregroundAlpha / 255)\n source += 1\n dest[column++] = options.color.r\n dest[column++] = options.color.g\n dest[column++] = options.color.b\n dest[column++] = clamp8(coverage * 255)\n }\n return source\n}\n\nfunction sourceOverAlpha(backgroundAlpha: number, foregroundAlpha: number): number {\n return foregroundAlpha + backgroundAlpha * (1 - foregroundAlpha)\n}\n\nfunction sourceOverColor(\n background: RGBA8,\n foreground: RGBA8,\n backgroundAlpha: number,\n foregroundAlpha: number,\n alpha: number,\n): RGBA8 {\n if (alpha <= 0) return { r: 0, g: 0, b: 0, a: 0 }\n\n const backgroundRatio = (backgroundAlpha * (1 - foregroundAlpha)) / alpha\n const foregroundRatio = foregroundAlpha / alpha\n return {\n r: clamp8(background.r * backgroundRatio + foreground.r * foregroundRatio),\n g: clamp8(background.g * backgroundRatio + foreground.g * foregroundRatio),\n b: clamp8(background.b * backgroundRatio + foreground.b * foregroundRatio),\n a: clamp8(alpha * 255),\n }\n}\n\nfunction writeBlockRow(\n dest: Uint8ClampedArray,\n row: number,\n width: number,\n color: RGBA8,\n alpha: number,\n): void {\n let column = row\n for (let x = 0; x < width; x += 1) {\n dest[column++] = color.r\n dest[column++] = color.g\n dest[column++] = color.b\n dest[column++] = alpha\n }\n}\n","import { clamp8 } from './color'\nimport { MinimapCharRenderer } from './minimapCharRenderer'\nimport { allCharCodes, Constants } from './minimapCharSheet'\n\n/**\n * Creates minimap character renderers by sampling a normal canvas once and\n * downsampling the glyph data for tiny minimap text rendering.\n */\nexport class MinimapCharRendererFactory {\n private static lastCreated?: MinimapCharRenderer\n private static lastFontFamily?: string\n\n public static create(scale: number, fontFamily: string): MinimapCharRenderer {\n if (\n this.lastCreated &&\n scale === this.lastCreated.scale &&\n fontFamily === this.lastFontFamily\n ) {\n return this.lastCreated\n }\n\n const renderer = this.createFromSampleData(this.createSampleData(fontFamily).data, scale)\n this.lastFontFamily = fontFamily\n this.lastCreated = renderer\n return renderer\n }\n\n public static createSampleData(fontFamily: string): ImageData {\n const canvas = createSamplingCanvas()\n const context = canvas.getContext('2d')!\n\n context.fillStyle = '#ffffff'\n context.font = `bold ${Constants.SAMPLED_CHAR_HEIGHT}px ${fontFamily}`\n context.textBaseline = 'middle'\n\n let x = 0\n for (const code of allCharCodes) {\n context.fillText(String.fromCharCode(code), x, Constants.SAMPLED_CHAR_HEIGHT / 2)\n x += Constants.SAMPLED_CHAR_WIDTH\n }\n\n return context.getImageData(\n 0,\n 0,\n Constants.CHAR_COUNT * Constants.SAMPLED_CHAR_WIDTH,\n Constants.SAMPLED_CHAR_HEIGHT,\n )\n }\n\n public static createFromSampleData(\n source: Uint8ClampedArray,\n scale: number,\n ): MinimapCharRenderer {\n const expectedLength =\n Constants.SAMPLED_CHAR_HEIGHT *\n Constants.SAMPLED_CHAR_WIDTH *\n Constants.RGBA_CHANNELS_CNT *\n Constants.CHAR_COUNT\n if (source.length !== expectedLength)\n throw new Error('Unexpected source in MinimapCharRenderer')\n\n return new MinimapCharRenderer(MinimapCharRendererFactory.downsample(source, scale), scale)\n }\n\n private static downsample(data: Uint8ClampedArray, scale: number): Uint8ClampedArray {\n const pixelsPerCharacter =\n Constants.BASE_CHAR_HEIGHT * scale * Constants.BASE_CHAR_WIDTH * scale\n const resultLength = pixelsPerCharacter * Constants.CHAR_COUNT\n const result = new Uint8ClampedArray(resultLength)\n let resultOffset = 0\n let sourceOffset = 0\n let brightest = 0\n\n for (let index = 0; index < Constants.CHAR_COUNT; index += 1) {\n brightest = Math.max(\n brightest,\n downsampleChar(data, sourceOffset, result, resultOffset, scale),\n )\n resultOffset += pixelsPerCharacter\n sourceOffset += Constants.SAMPLED_CHAR_WIDTH * Constants.RGBA_CHANNELS_CNT\n }\n\n boostIntensity(result, brightest)\n return result\n }\n}\n\nfunction createSamplingCanvas(): OffscreenCanvas {\n return new OffscreenCanvas(\n Constants.CHAR_COUNT * Constants.SAMPLED_CHAR_WIDTH,\n Constants.SAMPLED_CHAR_HEIGHT,\n )\n}\n\nfunction downsampleChar(\n source: Uint8ClampedArray,\n sourceOffset: number,\n dest: Uint8ClampedArray,\n destOffset: number,\n scale: number,\n): number {\n const width = Constants.BASE_CHAR_WIDTH * scale\n const height = Constants.BASE_CHAR_HEIGHT * scale\n let targetIndex = destOffset\n let brightest = 0\n\n for (let y = 0; y < height; y += 1) {\n for (let x = 0; x < width; x += 1) {\n const final = samplePixel(source, sourceOffset, x, y, width, height)\n brightest = Math.max(brightest, final)\n dest[targetIndex++] = clamp8(final)\n }\n }\n\n return brightest\n}\n\nfunction samplePixel(\n source: Uint8ClampedArray,\n sourceOffset: number,\n x: number,\n y: number,\n width: number,\n height: number,\n): number {\n const sourceY1 = (y / height) * Constants.SAMPLED_CHAR_HEIGHT\n const sourceY2 = ((y + 1) / height) * Constants.SAMPLED_CHAR_HEIGHT\n const sourceX1 = (x / width) * Constants.SAMPLED_CHAR_WIDTH\n const sourceX2 = ((x + 1) / width) * Constants.SAMPLED_CHAR_WIDTH\n const sample = sampleSourceRect(source, sourceOffset, sourceX1, sourceX2, sourceY1, sourceY2)\n return sample.value / sample.samples\n}\n\nfunction sampleSourceRect(\n source: Uint8ClampedArray,\n sourceOffset: number,\n sourceX1: number,\n sourceX2: number,\n sourceY1: number,\n sourceY2: number,\n): { readonly value: number; readonly samples: number } {\n let value = 0\n let samples = 0\n for (let sy = sourceY1; sy < sourceY2; sy += 1) {\n const row = sourceOffset + Math.floor(sy) * Constants.RGBA_SAMPLED_ROW_WIDTH\n const yBalance = 1 - (sy - Math.floor(sy))\n const sampled = sampleSourceRow(source, row, sourceX1, sourceX2, yBalance)\n value += sampled.value\n samples += sampled.samples\n }\n\n return { value, samples }\n}\n\nfunction sampleSourceRow(\n source: Uint8ClampedArray,\n row: number,\n sourceX1: number,\n sourceX2: number,\n yBalance: number,\n): { readonly value: number; readonly samples: number } {\n let value = 0\n let samples = 0\n for (let sx = sourceX1; sx < sourceX2; sx += 1) {\n const xBalance = 1 - (sx - Math.floor(sx))\n const sourceIndex = row + Math.floor(sx) * Constants.RGBA_CHANNELS_CNT\n const weight = xBalance * yBalance\n samples += weight\n value += (((source[sourceIndex] ?? 0) * (source[sourceIndex + 3] ?? 0)) / 255) * weight\n }\n\n return { value, samples }\n}\n\nfunction boostIntensity(result: Uint8ClampedArray, brightest: number): void {\n if (brightest <= 0) return\n\n const adjust = 255 / brightest\n for (let index = 0; index < result.length; index += 1)\n result[index] = clamp8(result[index]! * adjust)\n}\n","import type { RGBA8 } from './types'\n\nexport class RasterBuffer {\n public readonly imageData: ImageData\n private readonly pixels: Uint32Array\n private readonly background: number\n\n public constructor(\n context: OffscreenCanvasRenderingContext2D,\n width: number,\n height: number,\n background: RGBA8,\n ) {\n this.imageData = context.createImageData(Math.max(1, width), Math.max(1, height))\n this.pixels = new Uint32Array(this.imageData.data.buffer)\n const channels = Uint8ClampedArray.of(background.r, background.g, background.b, background.a)\n this.background = new Uint32Array(channels.buffer)[0]!\n }\n\n public clearRows(start: number, end: number): void {\n this.pixels.fill(this.background, start * this.imageData.width, end * this.imageData.width)\n }\n\n public copyRows(source: number, destination: number, count: number): void {\n const width = this.imageData.width\n this.pixels.copyWithin(destination * width, source * width, (source + count) * width)\n }\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport type {\n EditorMinimapDecoration,\n MinimapSectionHeaderStyle,\n ResolvedMinimapOptions,\n} from './types'\n\nexport type SectionHeader = {\n readonly startLineNumber: number\n readonly startColumn: number\n readonly endLineNumber: number\n readonly endColumn: number\n readonly text: string\n readonly hasSeparatorLine: boolean\n}\n\nconst CHUNK_SIZE = 100\nconst MAX_SECTION_LINES = 5\n\nexport function findSectionHeaderDecorations(\n lines: readonly string[],\n options: ResolvedMinimapOptions,\n): EditorMinimapDecoration[] {\n if (!options.showMarkSectionHeaders) return []\n\n return collectMarkHeaders(lines, options.markSectionHeaderRegex).map(headerToDecoration)\n}\n\nexport function findSectionHeaderDecorationsInRange(\n lines: readonly string[],\n startLineNumber: number,\n options: ResolvedMinimapOptions,\n): EditorMinimapDecoration[] {\n return findSectionHeaderDecorations(lines, options).map((decoration) =>\n shiftDecorationLineNumbers(decoration, startLineNumber - 1),\n )\n}\n\nexport function collectMarkHeaders(\n lines: readonly string[],\n markSectionHeaderRegex: string,\n): SectionHeader[] {\n if (markSectionHeaderRegex.trim() === '') return []\n\n const regex = createHeaderRegex(markSectionHeaderRegex)\n if (!regex || regExpLeadsToEndlessLoop(regex)) return []\n\n const headers: SectionHeader[] = []\n for (let startLine = 1; startLine <= lines.length; startLine += CHUNK_SIZE - MAX_SECTION_LINES) {\n collectHeadersInChunk(headers, lines, startLine, regex)\n }\n\n return headers\n}\n\nfunction collectHeadersInChunk(\n headers: SectionHeader[],\n lines: readonly string[],\n startLine: number,\n regex: RegExp,\n): void {\n const endLine = Math.min(startLine + CHUNK_SIZE - 1, lines.length)\n const text = lines.slice(startLine - 1, endLine).join('\\n')\n regex.lastIndex = 0\n\n let match: RegExpExecArray | null\n while ((match = regex.exec(text)) !== null) {\n pushHeader(headers, startLine, text, match)\n regex.lastIndex = match.index + match[0].length\n }\n}\n\nfunction pushHeader(\n headers: SectionHeader[],\n startLine: number,\n chunkText: string,\n match: RegExpExecArray,\n): void {\n const header = matchToSectionHeader(startLine, chunkText, match)\n if (!header.text && !header.hasSeparatorLine) return\n\n const previous = headers.at(-1)\n if (previous && previous.endLineNumber >= header.startLineNumber) return\n\n headers.push(header)\n}\n\nfunction matchToSectionHeader(\n startLine: number,\n chunkText: string,\n match: RegExpExecArray,\n): SectionHeader {\n const precedingText = chunkText.substring(0, match.index)\n const lineOffset = (precedingText.match(/\\n/g) || []).length\n const lineNumber = startLine + lineOffset\n const matchLines = match[0].split('\\n')\n const matchHeight = matchLines.length\n const lineStartIndex = precedingText.lastIndexOf('\\n') + 1\n const startColumn = match.index - lineStartIndex + 1\n const lastMatchLine = matchLines[matchLines.length - 1] ?? ''\n\n return {\n startLineNumber: lineNumber,\n startColumn,\n endLineNumber: lineNumber + matchHeight - 1,\n endColumn: matchHeight === 1 ? startColumn + match[0].length : lastMatchLine.length + 1,\n text: (match.groups ?? {})['label'] ?? '',\n hasSeparatorLine: ((match.groups ?? {})['separator'] ?? '') !== '',\n }\n}\n\nfunction headerToDecoration(header: SectionHeader): EditorMinimapDecoration {\n return {\n startLineNumber: header.startLineNumber,\n startColumn: header.startColumn,\n endLineNumber: header.endLineNumber,\n endColumn: header.endColumn,\n position: 'inline',\n sectionHeaderStyle: headerStyle(header.hasSeparatorLine),\n sectionHeaderText: header.text,\n }\n}\n\nfunction shiftDecorationLineNumbers(\n decoration: EditorMinimapDecoration,\n lineDelta: number,\n): EditorMinimapDecoration {\n if (lineDelta === 0) return decoration\n\n return {\n ...decoration,\n startLineNumber: decoration.startLineNumber + lineDelta,\n endLineNumber: decoration.endLineNumber + lineDelta,\n }\n}\n\nfunction headerStyle(hasSeparatorLine: boolean): MinimapSectionHeaderStyle {\n return hasSeparatorLine ? 'underlined' : 'normal'\n}\n\nfunction createHeaderRegex(source: string): RegExp | null {\n try {\n return new RegExp(source, `gdm${isMultilineRegexSource(source) ? 's' : ''}`)\n } catch {\n return null\n }\n}\n\nfunction isMultilineRegexSource(source: string): boolean {\n return source.includes('\\\\n') || source.includes('\\n')\n}\n\nfunction regExpLeadsToEndlessLoop(regexp: RegExp): boolean {\n regexp.lastIndex = 0\n const match = regexp.exec('')\n regexp.lastIndex = 0\n return match !== null && match[0].length === 0\n}\n","import type { TextEdit } from '@singapore-editor/core/document'\nimport { createError } from '@singapore-editor/core/logging/evlog'\nimport { parseCssColor, relativeLuminance, rgbaToCss, transparent } from './color'\nimport {\n computeFrameLayout,\n computeRenderLayout,\n type MinimapFrameLayout,\n MINIMAP_GUTTER_WIDTH,\n MINIMAP_RIGHT_GUTTER_WIDTH,\n yForLineNumber,\n} from './layout'\nimport { MinimapCharRendererFactory } from './minimapCharRendererFactory'\nimport { RasterBuffer } from './raster'\nimport { findSectionHeaderDecorations, findSectionHeaderDecorationsInRange } from './sectionHeaders'\nimport type {\n EditorMinimapDecoration,\n MinimapBaseStyles,\n MinimapDocumentEditPayload,\n MinimapDocumentPayload,\n MinimapDocumentSummaryPatch,\n MinimapDocumentSummaryPayload,\n MinimapMetrics,\n MinimapRenderLayout,\n MinimapSelection,\n MinimapToken,\n MinimapTokenPatch,\n MinimapViewport,\n ResolvedMinimapOptions,\n RGBA8,\n} from './types'\nimport { RenderMinimap } from './types'\n\ntype RendererState = {\n readonly mainCanvas: OffscreenCanvas\n readonly decorationsCanvas: OffscreenCanvas\n readonly mainContext: OffscreenCanvasRenderingContext2D\n readonly decorationsContext: OffscreenCanvasRenderingContext2D\n options: ResolvedMinimapOptions\n styles: MinimapBaseStyles\n document: MinimapDocumentPayload\n externalDecorations: readonly EditorMinimapDecoration[]\n metrics: MinimapMetrics\n viewport: MinimapViewport\n layout: MinimapRenderLayout | null\n previousFrame: MinimapFrameLayout | null\n raster: RasterBuffer | null\n tokenIndex: TokenIndex | null\n surface: RasterSurface | null\n linesDirty: boolean\n decorationsDirty: boolean\n}\n\nconst EMPTY_DOCUMENT: MinimapDocumentPayload = {\n textLength: 0,\n lineStarts: [0],\n lines: [{ text: '', length: 0 }],\n tokens: [],\n selections: [],\n decorations: [],\n externalDecorations: [],\n}\n\nexport class MinimapWorkerRenderer {\n private state: RendererState | null = null\n\n public init(options: {\n readonly mainCanvas: OffscreenCanvas\n readonly decorationsCanvas: OffscreenCanvas\n readonly options: ResolvedMinimapOptions\n readonly styles: MinimapBaseStyles\n }): void {\n const mainContext = options.mainCanvas.getContext('2d')\n const decorationsContext = options.decorationsCanvas.getContext('2d')\n if (!mainContext || !decorationsContext)\n throw new Error('Unable to create minimap canvas context')\n\n this.state = {\n mainCanvas: options.mainCanvas,\n decorationsCanvas: options.decorationsCanvas,\n mainContext,\n decorationsContext,\n options: options.options,\n styles: options.styles,\n document: EMPTY_DOCUMENT,\n externalDecorations: [],\n metrics: defaultMetrics(),\n viewport: defaultViewport(),\n layout: null,\n previousFrame: null,\n raster: null,\n tokenIndex: null,\n surface: null,\n linesDirty: true,\n decorationsDirty: true,\n }\n }\n\n public setDocument(document: MinimapDocumentPayload): void {\n if (!this.state) return\n const externalDecorations =\n document.externalDecorations ?? externalDecorationsFrom(document.decorations)\n const sectionHeaders = findSectionHeaderDecorations(documentLines(document), this.state.options)\n this.state.externalDecorations = externalDecorations\n this.state.document = {\n ...document,\n decorations: sectionHeaders.concat(externalDecorations),\n externalDecorations,\n }\n this.state.previousFrame = null\n this.state.linesDirty = true\n this.state.decorationsDirty = true\n }\n\n public applyEdit(edit: TextEdit, document: MinimapDocumentEditPayload): void {\n this.applyEdits([edit], document)\n }\n\n public applyEdits(edits: readonly TextEdit[], document: MinimapDocumentEditPayload): void {\n if (!this.state) return\n if (edits.length === 0) {\n this.setSelections(document.selections)\n return\n }\n\n const previous = this.state.document\n const next = applyTextEditsToMinimapDocument(previous, edits, document.summaryPatch)\n this.setEditedDocument(previous, next, edits, document.selections)\n }\n\n public setExternalDecorations(decorations: readonly EditorMinimapDecoration[]): void {\n if (!this.state) return\n\n this.state.externalDecorations = decorations\n this.state.document = {\n ...this.state.document,\n externalDecorations: decorations,\n decorations: sectionHeaderDecorationsFrom(this.state.document.decorations).concat(\n decorations,\n ),\n }\n this.state.decorationsDirty = true\n }\n\n private setEditedDocument(\n previous: SectionHeaderDocument,\n document: MinimapDocumentSummaryPayload & Pick<MinimapDocumentPayload, 'tokens'>,\n edits: readonly TextEdit[],\n selections: readonly MinimapSelection[],\n ): void {\n const state = this.requireState()\n const decorations = updateSectionHeaderDecorations(\n previous,\n document,\n edits,\n state.options,\n ).concat(state.externalDecorations)\n state.document = {\n textLength: document.textLength,\n lineStarts: document.lineStarts,\n lines: document.lines,\n tokens: document.tokens,\n selections,\n decorations,\n externalDecorations: state.externalDecorations,\n }\n state.linesDirty = true\n state.decorationsDirty = true\n }\n\n public setBaseStyles(styles: MinimapBaseStyles): void {\n if (!this.state) return\n this.state.styles = styles\n this.state.raster = null\n this.state.linesDirty = true\n this.state.decorationsDirty = true\n }\n\n public setTokens(tokens: readonly MinimapToken[]): void {\n if (!this.state) return\n this.state.document = { ...this.state.document, tokens }\n this.state.linesDirty = true\n }\n\n public updateTokenRange(patch: MinimapTokenPatch): void {\n if (!this.state) return\n\n const tokens = replaceTokenRange(this.state.document.tokens, patch)\n this.state.document = { ...this.state.document, tokens }\n this.state.linesDirty = true\n }\n\n public setSelections(selections: readonly MinimapSelection[]): void {\n if (!this.state) return\n this.state.document = { ...this.state.document, selections }\n this.state.decorationsDirty = true\n }\n\n public setDecorations(decorations: readonly EditorMinimapDecoration[]): void {\n if (!this.state) return\n this.state.externalDecorations = externalDecorationsFrom(decorations)\n this.state.document = { ...this.state.document, decorations }\n this.state.decorationsDirty = true\n }\n\n public updateLayout(\n metrics: MinimapMetrics,\n viewport: MinimapViewport,\n ): MinimapRenderLayout | null {\n if (!this.state) return null\n this.state.metrics = metrics\n this.state.viewport = viewport\n const nextLayout = this.createRenderLayout()\n const layoutChanged = !this.state.layout || !renderLayoutsEqual(this.state.layout, nextLayout)\n this.state.layout = nextLayout\n if (layoutChanged) {\n this.state.linesDirty = true\n this.state.decorationsDirty = true\n this.state.previousFrame = null\n }\n this.resizeCanvases(this.state.layout)\n return this.state.layout\n }\n\n public updateViewport(viewport: MinimapViewport): MinimapRenderLayout | null {\n if (!this.state) return null\n const previous = this.state.layout\n const next = this.updateLayout(this.state.metrics, viewport)\n if (!next || (previous && renderLayoutsEqual(previous, next))) return null\n return next\n }\n\n public render(): RenderResult | null {\n if (!this.state) return null\n\n const layout = this.state.layout ?? this.createRenderLayout()\n this.state.layout = layout\n this.resizeCanvases(layout)\n if (layout.renderMinimap === RenderMinimap.None) return emptyRenderResult()\n\n const frame = computeFrameLayout({\n renderLayout: layout,\n metrics: this.state.metrics,\n viewport: this.state.viewport,\n lineCount: this.minimapLineCount(layout),\n realLineCount: this.state.document.lineStarts.length,\n previous: this.state.previousFrame,\n })\n const frameChanged =\n !this.state.previousFrame || !framesPaintSameWindow(this.state.previousFrame, frame)\n\n const surface = this.surfaceForLayout(layout)\n if (this.state.linesDirty || frameChanged) this.renderLines(layout, frame, surface.mainContext)\n if (this.state.decorationsDirty || frameChanged) {\n this.renderDecorations(layout, frame, surface.decorationsContext)\n }\n this.presentSurface(layout, frame, surface)\n this.state.previousFrame = frame\n this.state.linesDirty = false\n this.state.decorationsDirty = false\n return {\n sliderNeeded: frame.sliderNeeded,\n sliderTop: frame.sliderTop,\n sliderHeight: frame.sliderHeight,\n shadowVisible:\n this.state.viewport.scrollLeft + this.state.viewport.clientWidth <\n this.state.viewport.scrollWidth,\n }\n }\n\n public dispose(): void {\n this.state = null\n }\n\n private createRenderLayout(): MinimapRenderLayout {\n const state = this.requireState()\n return computeRenderLayout({\n minimap: state.options,\n metrics: state.metrics,\n viewport: state.viewport,\n lineCount: state.document.lineStarts.length,\n })\n }\n\n private renderLines(\n layout: MinimapRenderLayout,\n frame: FrameLike,\n context: OffscreenCanvasRenderingContext2D,\n ): void {\n const state = this.requireState()\n const raster = this.rasterForLayout(layout, context)\n const previous = state.linesDirty ? null : state.previousFrame\n const reusedStart = Math.max(frame.startLineNumber, previous?.startLineNumber ?? Infinity)\n const reusedEnd = Math.min(frame.endLineNumber, previous?.endLineNumber ?? -Infinity)\n\n if (previous && reusedStart <= reusedEnd) {\n const sourceY = yForLineNumber(previous, reusedStart, layout.lineHeight)\n const destinationY = yForLineNumber(frame, reusedStart, layout.lineHeight)\n const reusedHeight = (reusedEnd - reusedStart + 1) * layout.lineHeight\n raster.copyRows(sourceY, destinationY, reusedHeight)\n raster.clearRows(0, destinationY)\n raster.clearRows(destinationY + reusedHeight, raster.imageData.height)\n this.renderLineRange(layout, frame, raster.imageData, frame.startLineNumber, reusedStart - 1)\n this.renderLineRange(layout, frame, raster.imageData, reusedEnd + 1, frame.endLineNumber)\n } else {\n raster.clearRows(0, raster.imageData.height)\n this.renderLineRange(\n layout,\n frame,\n raster.imageData,\n frame.startLineNumber,\n frame.endLineNumber,\n )\n }\n\n context.putImageData(raster.imageData, 0, 0)\n }\n\n private rasterForLayout(\n layout: MinimapRenderLayout,\n context: OffscreenCanvasRenderingContext2D,\n ): RasterBuffer {\n const state = this.requireState()\n const width = Math.max(1, layout.canvasInnerWidth)\n const height = rasterHeight(layout)\n if (state.raster?.imageData.width === width && state.raster.imageData.height === height) {\n return state.raster\n }\n\n state.raster = new RasterBuffer(context, width, height, state.styles.minimapBackground)\n return state.raster\n }\n\n private renderLineRange(\n layout: MinimapRenderLayout,\n frame: FrameLike,\n imageData: ImageData,\n startLineNumber: number,\n endLineNumber: number,\n ): void {\n if (startLineNumber > endLineNumber) return\n\n const state = this.requireState()\n const charRenderer = MinimapCharRendererFactory.create(layout.scale, state.styles.fontFamily)\n const useLighterFont = relativeLuminance(state.styles.background) >= 0.5\n const renderBackground = state.styles.background\n let tokenCursor = this.tokenCursorForOffset(\n this.lineStartOffset(this.documentLineForRasterLine(layout, startLineNumber)),\n )\n\n for (let line = startLineNumber; line <= endLineNumber; line += 1) {\n const documentLine = this.documentLineForRasterLine(layout, line)\n const text = this.lineText(documentLine)\n const lineStart = this.lineStartOffset(documentLine)\n const lineEnd = lineStart + text.length\n const lineTokens = tokensForLineFromCursor(\n state.document.tokens,\n lineStart,\n lineEnd,\n tokenCursor,\n )\n tokenCursor = lineTokens.cursor\n this.renderLine({\n imageData,\n layout,\n frame,\n line,\n text,\n lineStart,\n tokens: state.document.tokens,\n tokenEnd: lineTokens.end,\n tokenStart: lineTokens.start,\n charRenderer,\n useLighterFont,\n renderBackground,\n renderBackgroundAlpha: state.styles.minimapBackground.a,\n })\n }\n }\n\n private tokenCursorForOffset(offset: number): number {\n const state = this.requireState()\n const tokens = state.document.tokens\n if (state.tokenIndex?.tokens !== tokens) {\n state.tokenIndex = { tokens, maxEnds: tokenMaxEnds(tokens) }\n }\n return firstTokenEndingAfter(state.tokenIndex.maxEnds, offset)\n }\n\n private renderLine(options: RenderLineOptions): void {\n const state = this.requireState()\n const y = yForLineNumber(options.frame, options.line, options.layout.lineHeight)\n const maxDx = options.layout.canvasInnerWidth - options.layout.charWidth\n let dx = MINIMAP_GUTTER_WIDTH\n\n visitTokenSegments(\n options.text,\n options.lineStart,\n options.tokens,\n options.tokenStart,\n options.tokenEnd,\n state.styles.foreground,\n (text, color) => {\n if (dx > maxDx) return false\n dx = renderSegment({ ...options, text, color, dx, y, maxDx })\n return dx <= maxDx\n },\n )\n }\n\n private renderDecorations(\n layout: MinimapRenderLayout,\n frame: FrameLike,\n context: OffscreenCanvasRenderingContext2D,\n ): void {\n context.clearRect(0, 0, layout.canvasInnerWidth, rasterHeight(layout))\n const lineCount = this.requireState().document.lineStarts.length\n const decorationLayout = layout.isSampling\n ? { ...layout, lineHeight: layout.canvasInnerHeight / Math.max(1, lineCount) }\n : layout\n const decorationFrame = layout.isSampling ? { ...frame, endLineNumber: lineCount } : frame\n this.renderSelectionHighlights(decorationLayout, decorationFrame, context)\n this.renderMinimapDecorations(decorationLayout, decorationFrame, context)\n this.renderSectionHeaders(decorationLayout, decorationFrame, context)\n }\n\n private renderSelectionHighlights(\n layout: MinimapRenderLayout,\n frame: FrameLike,\n context: OffscreenCanvasRenderingContext2D,\n ): void {\n const state = this.requireState()\n const color = transparent(state.styles.selection, 0.5)\n context.fillStyle = rgbaToCss(color)\n\n for (const selection of state.document.selections) {\n const range = this.offsetRangeToLineRange(selection.startOffset, selection.endOffset)\n fillLineRange(context, layout, frame, range.start, range.end)\n }\n }\n\n private renderMinimapDecorations(\n layout: MinimapRenderLayout,\n frame: FrameLike,\n context: OffscreenCanvasRenderingContext2D,\n ): void {\n const state = this.requireState()\n const decorations = state.document.decorations\n .filter((decoration) => !decoration.sectionHeaderStyle)\n .toSorted((left, right) => (left.zIndex ?? 0) - (right.zIndex ?? 0))\n\n for (const decoration of decorations) {\n const color = parseCssColor(decoration.color, state.styles.selection)\n context.fillStyle = rgbaToCss(transparent(color, 0.5))\n fillDecorationRange(context, layout, frame, decoration)\n }\n }\n\n private renderSectionHeaders(\n layout: MinimapRenderLayout,\n frame: FrameLike,\n context: OffscreenCanvasRenderingContext2D,\n ): void {\n const state = this.requireState()\n const fontSize = state.options.sectionHeaderFontSize * state.metrics.devicePixelRatio\n context.font = `500 ${fontSize}px ${state.styles.fontFamily}`\n context.fillStyle = rgbaToCss(transparent(state.styles.minimapBackground, 0.7))\n context.strokeStyle = rgbaToCss(state.styles.foreground)\n context.lineWidth = 0.4\n\n for (const decoration of state.document.decorations) {\n if (!decoration.sectionHeaderStyle) continue\n renderSectionHeader(context, decoration, layout, frame, fontSize, state.styles.foreground)\n }\n }\n\n private minimapLineCount(layout: MinimapRenderLayout): number {\n const state = this.requireState()\n if (!layout.isSampling) return state.document.lineStarts.length\n return Math.max(1, Math.min(state.document.lineStarts.length, layout.canvasInnerHeight))\n }\n\n private documentLineForRasterLine(layout: MinimapRenderLayout, line: number): number {\n if (!layout.isSampling) return line\n const count = this.requireState().document.lineStarts.length\n return Math.floor(((line - 1) * count) / this.minimapLineCount(layout)) + 1\n }\n\n private lineText(lineNumber: number): string {\n const state = this.requireState()\n return state.document.lines[lineNumber - 1]?.text ?? ''\n }\n\n private lineStartOffset(lineNumber: number): number {\n const state = this.requireState()\n return state.document.lineStarts[lineNumber - 1] ?? state.document.textLength\n }\n\n private offsetRangeToLineRange(startOffset: number, endOffset: number): LineRange {\n return {\n start: this.lineNumberForOffset(startOffset),\n end: this.lineNumberForOffset(endOffset),\n }\n }\n\n private lineNumberForOffset(offset: number): number {\n const state = this.requireState()\n let low = 0\n let high = state.document.lineStarts.length - 1\n const clamped = Math.max(0, Math.min(offset, state.document.textLength))\n\n while (low <= high) {\n const middle = Math.floor((low + high) / 2)\n const start = state.document.lineStarts[middle] ?? 0\n const next = state.document.lineStarts[middle + 1] ?? Number.POSITIVE_INFINITY\n if (clamped < start) high = middle - 1\n else if (clamped >= next) low = middle + 1\n else return middle + 1\n }\n\n return state.document.lineStarts.length\n }\n\n private resizeCanvases(layout: MinimapRenderLayout): void {\n const state = this.requireState()\n resizeCanvas(state.mainCanvas, layout.canvasInnerWidth, layout.canvasInnerHeight)\n resizeCanvas(state.decorationsCanvas, layout.canvasInnerWidth, layout.canvasInnerHeight)\n }\n\n private surfaceForLayout(layout: MinimapRenderLayout): RasterSurface {\n const state = this.requireState()\n state.surface ??= createRasterSurface()\n resizeCanvas(state.surface.mainCanvas, layout.canvasInnerWidth, rasterHeight(layout))\n resizeCanvas(state.surface.decorationsCanvas, layout.canvasInnerWidth, rasterHeight(layout))\n return state.surface\n }\n\n private presentSurface(\n layout: MinimapRenderLayout,\n frame: MinimapFrameLayout,\n surface: RasterSurface,\n ): void {\n const state = this.requireState()\n // Fractional pixel blending dims the glyphs while scrolling.\n const offsetY = Math.round(frame.startLineFraction * layout.lineHeight)\n presentRaster(state.mainContext, surface.mainCanvas, state.mainCanvas, offsetY)\n presentRaster(\n state.decorationsContext,\n surface.decorationsCanvas,\n state.decorationsCanvas,\n offsetY,\n )\n }\n\n private requireState(): RendererState {\n if (!this.state) throw new Error('Minimap renderer is not initialized')\n return this.state\n }\n}\n\ntype RenderResult = {\n readonly sliderNeeded: boolean\n readonly sliderTop: number\n readonly sliderHeight: number\n readonly shadowVisible: boolean\n}\n\ntype FrameLike = {\n readonly startLineNumber: number\n readonly endLineNumber: number\n readonly topPaddingLineCount: number\n}\n\ntype LineRange = {\n readonly start: number\n readonly end: number\n}\n\ntype RenderLineOptions = {\n readonly imageData: ImageData\n readonly layout: MinimapRenderLayout\n readonly frame: FrameLike\n readonly line: number\n readonly text: string\n readonly lineStart: number\n readonly tokens: readonly MinimapToken[]\n readonly tokenEnd: number\n readonly tokenStart: number\n readonly charRenderer: ReturnType<typeof MinimapCharRendererFactory.create>\n readonly useLighterFont: boolean\n readonly renderBackground: RGBA8\n readonly renderBackgroundAlpha: number\n}\n\ntype TokenRange = {\n readonly start: number\n readonly end: number\n readonly cursor: number\n}\n\ntype TokenIndex = {\n readonly tokens: readonly MinimapToken[]\n readonly maxEnds: Float64Array\n}\n\ntype RasterSurface = {\n readonly mainCanvas: OffscreenCanvas\n readonly decorationsCanvas: OffscreenCanvas\n readonly mainContext: OffscreenCanvasRenderingContext2D\n readonly decorationsContext: OffscreenCanvasRenderingContext2D\n}\n\nfunction createRasterSurface(): RasterSurface {\n const mainCanvas = new OffscreenCanvas(1, 1)\n const decorationsCanvas = new OffscreenCanvas(1, 1)\n const mainContext = mainCanvas.getContext('2d')\n const decorationsContext = decorationsCanvas.getContext('2d')\n if (!mainContext || !decorationsContext) {\n throw createError({\n message: 'Unable to create minimap raster surface',\n code: 'MINIMAP_RASTER_CONTEXT',\n status: 500,\n why: 'The browser did not provide a 2D context for the minimap raster.',\n fix: 'Check OffscreenCanvas 2D support and canvas resource limits.',\n })\n }\n return { mainCanvas, decorationsCanvas, mainContext, decorationsContext }\n}\n\nfunction rasterHeight(layout: MinimapRenderLayout): number {\n return Math.max(\n 1,\n (Math.ceil(layout.canvasInnerHeight / layout.lineHeight) + 1) * layout.lineHeight,\n )\n}\n\nfunction presentRaster(\n context: OffscreenCanvasRenderingContext2D,\n source: OffscreenCanvas,\n target: OffscreenCanvas,\n offsetY: number,\n): void {\n context.globalCompositeOperation = 'copy'\n context.imageSmoothingEnabled = true\n context.drawImage(\n source,\n 0,\n offsetY,\n target.width,\n target.height,\n 0,\n 0,\n target.width,\n target.height,\n )\n}\n\nfunction renderSegment(\n options: RenderLineOptions & {\n readonly text: string\n readonly color: RGBA8\n readonly maxDx: number\n dx: number\n y: number\n },\n): number {\n let dx = options.dx\n for (let index = 0; index < options.text.length; index += 1) {\n if (dx > options.maxDx) return dx\n dx = renderCharacter(options, dx, options.text.charCodeAt(index))\n }\n return dx\n}\n\nfunction renderCharacter(\n options: RenderLineOptions & { readonly color: RGBA8; y: number },\n dx: number,\n code: number,\n): number {\n if (code === 9) return dx + 4 * options.layout.charWidth\n if (code === 32) return dx + options.layout.charWidth\n\n if (options.layout.renderMinimap === RenderMinimap.Blocks) {\n options.charRenderer.blockRenderChar(\n options.imageData,\n dx,\n options.y,\n options.color,\n 255,\n options.renderBackground,\n options.renderBackgroundAlpha,\n options.layout.lineHeight === 1,\n )\n return dx + options.layout.charWidth\n }\n\n options.charRenderer.renderChar(\n options.imageData,\n dx,\n options.y,\n code,\n options.color,\n 255,\n options.renderBackground,\n options.renderBackgroundAlpha,\n options.layout.scale,\n options.useLighterFont,\n options.layout.lineHeight === 1,\n )\n return dx + options.layout.charWidth\n}\n\nfunction visitTokenSegments(\n text: string,\n lineStart: number,\n tokens: readonly MinimapToken[],\n tokenStart: number,\n tokenEnd: number,\n fallback: RGBA8,\n visit: (text: string, color: RGBA8) => boolean,\n): void {\n let cursor = 0\n for (let index = tokenStart; index < tokenEnd; index += 1) {\n const token = tokens[index]!\n const start = Math.max(0, token.start - lineStart)\n const end = Math.min(text.length, token.end - lineStart)\n if (start > cursor && !visit(text.slice(cursor, start), fallback)) return\n if (end > start && !visit(text.slice(start, end), token.color)) return\n cursor = Math.max(cursor, end)\n }\n if (cursor < text.length) visit(text.slice(cursor), fallback)\n}\n\nfunction tokensForLineFromCursor(\n tokens: readonly MinimapToken[],\n lineStart: number,\n lineEnd: number,\n cursor: number,\n): TokenRange {\n let index = cursor\n while (index < tokens.length && tokens[index]!.end <= lineStart) index += 1\n\n const start = index\n while (index < tokens.length && tokens[index]!.start < lineEnd) index += 1\n\n return { start, end: index, cursor: start }\n}\n\nfunction tokenMaxEnds(tokens: readonly MinimapToken[]): Float64Array {\n const maxEnds = new Float64Array(tokens.length)\n let maxEnd = 0\n for (let index = 0; index < tokens.length; index += 1) {\n maxEnd = Math.max(maxEnd, tokens[index]!.end)\n maxEnds[index] = maxEnd\n }\n return maxEnds\n}\n\nfunction firstTokenEndingAfter(maxEnds: Float64Array, offset: number): number {\n let low = 0\n let high = maxEnds.length\n while (low < high) {\n const middle = Math.floor((low + high) / 2)\n if (maxEnds[middle]! <= offset) {\n low = middle + 1\n continue\n }\n high = middle\n }\n return low\n}\n\nfunction fillLineRange(\n context: OffscreenCanvasRenderingContext2D,\n layout: MinimapRenderLayout,\n frame: FrameLike,\n startLineNumber: number,\n endLineNumber: number,\n): void {\n const start = Math.max(frame.startLineNumber, startLineNumber)\n const end = Math.min(frame.endLineNumber, endLineNumber)\n if (start > end) return\n\n const y = yForLineNumber(frame, start, layout.lineHeight)\n const height = Math.max(\n layout.lineHeight,\n yForLineNumber(frame, end, layout.lineHeight) - y + layout.lineHeight,\n )\n context.fillRect(MINIMAP_GUTTER_WIDTH, y, layout.canvasInnerWidth, height)\n}\n\nfunction fillDecorationRange(\n context: OffscreenCanvasRenderingContext2D,\n layout: MinimapRenderLayout,\n frame: FrameLike,\n decoration: EditorMinimapDecoration,\n): void {\n if (decoration.position === 'gutter') {\n fillGutterLineRange(\n context,\n layout,\n frame,\n decoration.startLineNumber,\n decoration.endLineNumber,\n )\n return\n }\n\n fillLineRange(context, layout, frame, decoration.startLineNumber, decoration.endLineNumber)\n}\n\nfunction fillGutterLineRange(\n context: OffscreenCanvasRenderingContext2D,\n layout: MinimapRenderLayout,\n frame: FrameLike,\n startLineNumber: number,\n endLineNumber: number,\n): void {\n const range = visibleLineRange(frame, startLineNumber, endLineNumber)\n if (!range) return\n\n const y = yForLineNumber(frame, range.start, layout.lineHeight)\n const height = lineRangeHeight(layout, frame, range.end, y)\n const width = minimapRightGutterWidth(layout)\n context.fillRect(layout.canvasInnerWidth - width, y, width, height)\n}\n\nfunction visibleLineRange(\n frame: FrameLike,\n startLineNumber: number,\n endLineNumber: number,\n): LineRange | null {\n const start = Math.max(frame.startLineNumber, startLineNumber)\n const end = Math.min(frame.endLineNumber, endLineNumber)\n if (start > end) return null\n return { start, end }\n}\n\nfunction lineRangeHeight(\n layout: MinimapRenderLayout,\n frame: FrameLike,\n endLineNumber: number,\n y: number,\n): number {\n return Math.max(\n layout.lineHeight,\n yForLineNumber(frame, endLineNumber, layout.lineHeight) - y + layout.lineHeight,\n )\n}\n\nfunction minimapRightGutterWidth(layout: MinimapRenderLayout): number {\n const horizontalScale = layout.canvasInnerWidth / Math.max(1, layout.canvasOuterWidth)\n return Math.max(2, Math.ceil(MINIMAP_RIGHT_GUTTER_WIDTH * horizontalScale))\n}\n\nfunction renderSectionHeader(\n context: OffscreenCanvasRenderingContext2D,\n decoration: EditorMinimapDecoration,\n layout: MinimapRenderLayout,\n frame: FrameLike,\n fontSize: number,\n color: RGBA8,\n): void {\n if (\n decoration.startLineNumber < frame.startLineNumber ||\n decoration.startLineNumber > frame.endLineNumber\n ) {\n return\n }\n\n const y = yForLineNumber(frame, decoration.startLineNumber, layout.lineHeight) + fontSize\n context.fillRect(0, y - fontSize, layout.canvasInnerWidth, fontSize * 1.5)\n context.fillStyle = rgbaToCss(color)\n if (decoration.sectionHeaderText) {\n context.fillText(decoration.sectionHeaderText, MINIMAP_GUTTER_WIDTH, y, layout.canvasInnerWidth)\n }\n if (decoration.sectionHeaderStyle === 'underlined') {\n context.beginPath()\n context.moveTo(0, y - fontSize + 2)\n context.lineTo(layout.canvasInnerWidth, y - fontSize + 2)\n context.stroke()\n }\n}\n\nfunction resizeCanvas(canvas: OffscreenCanvas, width: number, height: number): void {\n const safeWidth = Math.max(1, width)\n const safeHeight = Math.max(1, height)\n if (canvas.width !== safeWidth) canvas.width = safeWidth\n if (canvas.height !== safeHeight) canvas.height = safeHeight\n}\n\nfunction renderLayoutsEqual(left: MinimapRenderLayout, right: MinimapRenderLayout): boolean {\n return (\n left.width === right.width &&\n left.height === right.height &&\n left.canvasInnerWidth === right.canvasInnerWidth &&\n left.canvasInnerHeight === right.canvasInnerHeight &&\n left.lineHeight === right.lineHeight &&\n left.charWidth === right.charWidth &&\n left.scale === right.scale &&\n left.isSampling === right.isSampling &&\n left.heightIsEditorHeight === right.heightIsEditorHeight &&\n left.renderMinimap === right.renderMinimap\n )\n}\n\nfunction framesPaintSameWindow(left: MinimapFrameLayout, right: MinimapFrameLayout): boolean {\n return (\n left.startLineNumber === right.startLineNumber &&\n left.endLineNumber === right.endLineNumber &&\n left.topPaddingLineCount === right.topPaddingLineCount\n )\n}\n\nfunction defaultMetrics(): MinimapMetrics {\n return { rowHeight: 20, characterWidth: 8, devicePixelRatio: 1 }\n}\n\nfunction defaultViewport(): MinimapViewport {\n return {\n scrollTop: 0,\n scrollRow: 0,\n scrollLeft: 0,\n scrollHeight: 0,\n scrollWidth: 0,\n clientHeight: 0,\n clientWidth: 0,\n minimapHeight: 0,\n visibleStart: 0,\n reservedWidth: 0,\n visibleEnd: 1,\n }\n}\n\nfunction emptyRenderResult(): RenderResult {\n return { sliderNeeded: false, sliderTop: 0, sliderHeight: 0, shadowVisible: false }\n}\n\nfunction applyTextEditsToMinimapDocument(\n document: Pick<MinimapDocumentPayload, 'lineStarts' | 'lines' | 'textLength' | 'tokens'>,\n edits: readonly TextEdit[],\n summaryPatch: MinimapDocumentSummaryPatch,\n): MinimapDocumentSummaryPayload & Pick<MinimapDocumentPayload, 'tokens'> {\n let tokens = document.tokens\n\n for (const edit of edits) {\n tokens = projectMinimapTokensThroughEdit(tokens, edit, tokenProjectionText(document))\n }\n\n const summary = applyMinimapDocumentSummaryPatch(document, summaryPatch)\n return { ...summary, tokens }\n}\n\nfunction applyMinimapDocumentSummaryPatch(\n document: Pick<MinimapDocumentPayload, 'lines' | 'lineStarts' | 'textLength'>,\n patch: MinimapDocumentSummaryPatch,\n): MinimapDocumentSummaryPayload {\n const startLine = Math.min(Math.max(0, patch.startLine), document.lines.length)\n const deleteCount = Math.min(Math.max(0, patch.deleteCount), document.lines.length - startLine)\n\n return {\n textLength: patch.textLength,\n lineStarts: patch.lineStarts ?? splicedLineStarts(document, patch, startLine, deleteCount),\n lines: document.lines\n .slice(0, startLine)\n .concat(patch.lines, document.lines.slice(startLine + deleteCount)),\n }\n}\n\n// Rebuilds line starts from the patch instead of receiving them over\n// postMessage: lines before the patch keep their starts, inserted lines chain\n// from the previous line's full length, and lines after the patch shift by\n// the document length delta.\nfunction splicedLineStarts(\n document: Pick<MinimapDocumentPayload, 'lines' | 'lineStarts' | 'textLength'>,\n patch: MinimapDocumentSummaryPatch,\n startLine: number,\n deleteCount: number,\n): readonly number[] {\n const previous = document.lineStarts\n const next: number[] = previous.slice(0, startLine) as number[]\n let cursor = lineStartAt(previous, document.lines, startLine)\n for (const line of patch.lines) {\n next.push(cursor)\n cursor += line.length + 1\n }\n\n const delta = patch.textLength - document.textLength\n for (let index = startLine + deleteCount; index < previous.length; index += 1) {\n next.push(previous[index]! + delta)\n }\n\n return next\n}\n\nfunction lineStartAt(\n lineStarts: readonly number[],\n lines: MinimapDocumentSummaryPayload['lines'],\n line: number,\n): number {\n const existing = lineStarts[line]\n if (existing !== undefined) return existing\n if (line === 0) return 0\n\n const previousStart = lineStarts[line - 1] ?? 0\n const previousLength = lines[line - 1]?.length ?? 0\n return previousStart + previousLength + 1\n}\n\nfunction lineIndexForOffset(lineStarts: readonly number[], offset: number): number {\n let low = 0\n let high = lineStarts.length - 1\n const clamped = Math.max(0, offset)\n\n while (low <= high) {\n const middle = Math.floor((low + high) / 2)\n const start = lineStarts[middle] ?? 0\n const next = lineStarts[middle + 1] ?? Number.POSITIVE_INFINITY\n if (clamped < start) {\n high = middle - 1\n continue\n }\n if (clamped >= next) {\n low = middle + 1\n continue\n }\n return middle\n }\n\n return Math.max(0, lineStarts.length - 1)\n}\n\nconst SECTION_HEADER_EDIT_CONTEXT_LINES = 10\n\ntype SectionHeaderDocument = Pick<MinimapDocumentPayload, 'decorations' | 'lineStarts' | 'lines'>\ntype SectionHeaderTextDocument = Pick<MinimapDocumentPayload, 'lineStarts' | 'lines'>\ntype LineNumberRange = {\n readonly start: number\n readonly end: number\n}\n\nfunction updateSectionHeaderDecorations(\n previous: SectionHeaderDocument,\n next: SectionHeaderTextDocument,\n edits: readonly TextEdit[],\n options: ResolvedMinimapOptions,\n): readonly EditorMinimapDecoration[] {\n if (!options.showMarkSectionHeaders) return []\n if (edits.length === 0) return sectionHeaderDecorationsFrom(previous.decorations)\n\n const oldRange = affectedOldLineRange(previous.lineStarts, edits)\n const nextRange = affectedNextLineRange(next.lineStarts, edits)\n const lineDelta = next.lineStarts.length - previous.lineStarts.length\n const shifted = shiftedSectionHeaders(previous.decorations, oldRange, nextRange, lineDelta)\n const rescanned = rescanSectionHeaders(next, nextRange, options)\n return shifted.concat(rescanned).sort(compareDecorationsByLine)\n}\n\nfunction affectedOldLineRange(\n lineStarts: readonly number[],\n edits: readonly TextEdit[],\n): LineNumberRange {\n let start = Number.POSITIVE_INFINITY\n let end = 1\n\n for (const edit of edits) {\n start = Math.min(start, lineIndexForOffset(lineStarts, edit.from) + 1)\n end = Math.max(end, lineIndexForOffset(lineStarts, edit.to) + 1)\n }\n\n return expandLineRange({ start, end }, lineStarts.length)\n}\n\nfunction affectedNextLineRange(\n lineStarts: readonly number[],\n edits: readonly TextEdit[],\n): LineNumberRange {\n let start = Number.POSITIVE_INFINITY\n let end = 1\n\n for (const edit of edits) {\n start = Math.min(start, lineIndexForOffset(lineStarts, edit.from) + 1)\n end = Math.max(end, lineIndexForOffset(lineStarts, edit.from + edit.text.length) + 1)\n }\n\n return expandLineRange({ start, end }, lineStarts.length)\n}\n\nfunction expandLineRange(range: LineNumberRange, lineCount: number): LineNumberRange {\n return {\n start: Math.max(1, range.start - SECTION_HEADER_EDIT_CONTEXT_LINES),\n end: Math.min(lineCount, range.end + SECTION_HEADER_EDIT_CONTEXT_LINES),\n }\n}\n\nfunction shiftedSectionHeaders(\n decorations: readonly EditorMinimapDecoration[],\n oldRange: LineNumberRange,\n nextRange: LineNumberRange,\n lineDelta: number,\n): readonly EditorMinimapDecoration[] {\n const headers = sectionHeaderDecorationsFrom(decorations)\n return headers.flatMap((decoration) =>\n shiftSectionHeaderDecoration(decoration, oldRange, nextRange, lineDelta),\n )\n}\n\nfunction shiftSectionHeaderDecoration(\n decoration: EditorMinimapDecoration,\n oldRange: LineNumberRange,\n nextRange: LineNumberRange,\n lineDelta: number,\n): readonly EditorMinimapDecoration[] {\n if (lineRangesIntersect(decoration, oldRange)) return []\n\n if (decoration.startLineNumber <= oldRange.end) {\n return lineRangesIntersect(decoration, nextRange) ? [] : [decoration]\n }\n\n const shifted = shiftDecoration(decoration, lineDelta)\n return lineRangesIntersect(shifted, nextRange) ? [] : [shifted]\n}\n\nfunction shiftDecoration(\n decoration: EditorMinimapDecoration,\n lineDelta: number,\n): EditorMinimapDecoration {\n if (lineDelta === 0) return decoration\n\n return {\n ...decoration,\n startLineNumber: decoration.startLineNumber + lineDelta,\n endLineNumber: decoration.endLineNumber + lineDelta,\n }\n}\n\nfunction rescanSectionHeaders(\n document: SectionHeaderTextDocument,\n range: LineNumberRange,\n options: ResolvedMinimapOptions,\n): readonly EditorMinimapDecoration[] {\n const lines = linesForRange(document.lines, range)\n return findSectionHeaderDecorationsInRange(lines, range.start, options)\n}\n\nfunction linesForRange(\n summaries: readonly { readonly text: string }[],\n range: LineNumberRange,\n): readonly string[] {\n const lines: string[] = []\n for (let lineNumber = range.start; lineNumber <= range.end; lineNumber += 1) {\n lines.push(summaries[lineNumber - 1]?.text ?? '')\n }\n\n return lines\n}\n\nfunction lineRangesIntersect(decoration: EditorMinimapDecoration, range: LineNumberRange): boolean {\n return decoration.startLineNumber <= range.end && decoration.endLineNumber >= range.start\n}\n\nfunction compareDecorationsByLine(\n left: EditorMinimapDecoration,\n right: EditorMinimapDecoration,\n): number {\n return left.startLineNumber - right.startLineNumber || left.endLineNumber - right.endLineNumber\n}\n\nfunction externalDecorationsFrom(\n decorations: readonly EditorMinimapDecoration[],\n): readonly EditorMinimapDecoration[] {\n return decorations.filter((decoration) => !decoration.sectionHeaderStyle)\n}\n\nfunction sectionHeaderDecorationsFrom(\n decorations: readonly EditorMinimapDecoration[],\n): readonly EditorMinimapDecoration[] {\n return decorations.filter((decoration) => decoration.sectionHeaderStyle)\n}\n\nfunction replaceTokenRange(\n tokens: readonly MinimapToken[],\n patch: MinimapTokenPatch,\n): readonly MinimapToken[] {\n const start = clampTokenIndex(patch.start, tokens.length)\n const deleteEnd = clampTokenIndex(start + patch.deleteCount, tokens.length)\n return tokens.slice(0, start).concat(patch.tokens, tokens.slice(deleteEnd))\n}\n\nfunction clampTokenIndex(index: number, length: number): number {\n return Math.min(length, Math.max(0, index))\n}\n\nexport function projectMinimapTokensThroughEdit(\n tokens: readonly MinimapToken[],\n edit: TextEdit,\n previousText: MinimapTokenProjectionText,\n): readonly MinimapToken[] {\n const delta = edit.text.length - (edit.to - edit.from)\n const projected: MinimapToken[] = []\n for (const token of tokens) {\n const next = projectMinimapTokenThroughEdit(token, edit, previousText, delta)\n if (isRenderableMinimapToken(next)) projected.push(next)\n }\n return projected\n}\n\nfunction projectMinimapTokenThroughEdit(\n token: MinimapToken,\n edit: TextEdit,\n previousText: MinimapTokenProjectionText,\n delta: number,\n): MinimapToken | null {\n if (edit.from === edit.to) return projectMinimapTokenThroughInsertion(token, edit, previousText)\n if (token.end <= edit.from) return token\n if (token.start >= edit.to) return shiftMinimapToken(token, delta)\n if (!canResizeMinimapTokenAcrossEdit(token, edit)) return null\n\n return { ...token, end: token.end + delta }\n}\n\nfunction projectMinimapTokenThroughInsertion(\n token: MinimapToken,\n edit: TextEdit,\n previousText: MinimapTokenProjectionText,\n): MinimapToken {\n if (shouldExpandMinimapTokenForInsertion(token, edit, previousText)) {\n return { ...token, end: token.end + edit.text.length }\n }\n if (token.start >= edit.from) return shiftMinimapToken(token, edit.text.length)\n\n return token\n}\n\nfunction canResizeMinimapTokenAcrossEdit(token: MinimapToken, edit: TextEdit): boolean {\n if (edit.text.includes('\\n')) return false\n return token.start < edit.from && edit.to < token.end\n}\n\nfunction shouldExpandMinimapTokenForInsertion(\n token: MinimapToken,\n edit: TextEdit,\n previousText: MinimapTokenProjectionText,\n): boolean {\n if (edit.text.length === 0) return false\n if (edit.text.includes('\\n')) return false\n if (token.start < edit.from && edit.from < token.end) return true\n if (!isWordLikeText(edit.text)) return false\n if (token.end === edit.from) return textHasWordBeforeOffset(previousText, edit.from)\n if (token.start === edit.from) {\n return (\n !textHasWordBeforeOffset(previousText, edit.from) &&\n textHasWordCodePointAt(previousText, edit.from)\n )\n }\n\n return false\n}\n\nfunction shiftMinimapToken(token: MinimapToken, delta: number): MinimapToken {\n return {\n ...token,\n start: token.start + delta,\n end: token.end + delta,\n }\n}\n\nfunction isRenderableMinimapToken(token: MinimapToken | null): token is MinimapToken {\n if (!token) return false\n return token.end > token.start\n}\n\nfunction isWordLikeText(text: string): boolean {\n return /^[\\p{L}\\p{N}_]+$/u.test(text)\n}\n\ntype MinimapTokenProjectionText =\n | string\n | {\n isWordBeforeOffset(offset: number): boolean\n isWordCodePointAt(offset: number): boolean\n }\n\nfunction tokenProjectionText(\n document: Pick<MinimapDocumentPayload, 'lineStarts' | 'lines' | 'textLength'>,\n): MinimapTokenProjectionText {\n return {\n isWordBeforeOffset: (offset) => summaryHasWordBeforeOffset(document, offset),\n isWordCodePointAt: (offset) => summaryHasWordCodePointAt(document, offset),\n }\n}\n\nfunction documentLines(document: Pick<MinimapDocumentPayload, 'lines'>): readonly string[] {\n return document.lines.map((line) => line.text)\n}\n\nfunction textHasWordBeforeOffset(text: MinimapTokenProjectionText, offset: number): boolean {\n if (typeof text !== 'string') return text.isWordBeforeOffset(offset)\n return stringHasWordBeforeOffset(text, offset)\n}\n\nfunction textHasWordCodePointAt(text: MinimapTokenProjectionText, offset: number): boolean {\n if (typeof text !== 'string') return text.isWordCodePointAt(offset)\n return stringHasWordCodePointAt(text, offset)\n}\n\nfunction summaryHasWordBeforeOffset(\n document: Pick<MinimapDocumentPayload, 'lineStarts' | 'lines' | 'textLength'>,\n offset: number,\n): boolean {\n const location = summaryOffsetLocation(document, offset)\n if (!location) return false\n\n return stringHasWordBeforeOffset(location.text, location.localOffset)\n}\n\nfunction summaryHasWordCodePointAt(\n document: Pick<MinimapDocumentPayload, 'lineStarts' | 'lines' | 'textLength'>,\n offset: number,\n): boolean {\n const location = summaryOffsetLocation(document, offset)\n if (!location) return false\n\n return stringHasWordCodePointAt(location.text, location.localOffset)\n}\n\nfunction summaryOffsetLocation(\n document: Pick<MinimapDocumentPayload, 'lineStarts' | 'lines' | 'textLength'>,\n offset: number,\n): { readonly text: string; readonly localOffset: number } | null {\n const clamped = Math.max(0, Math.min(offset, document.textLength))\n const lineIndex = lineIndexForOffset(document.lineStarts, clamped)\n const lineStart = document.lineStarts[lineIndex] ?? 0\n const text = document.lines[lineIndex]?.text ?? ''\n const localOffset = clamped - lineStart\n if (localOffset < 0 || localOffset > text.length) return null\n\n return { text, localOffset }\n}\n\nfunction stringHasWordBeforeOffset(text: string, offset: number): boolean {\n const previous = previousCodePointStart(text, offset)\n if (previous === null) return false\n return stringHasWordCodePointAt(text, previous)\n}\n\nfunction stringHasWordCodePointAt(text: string, offset: number): boolean {\n const codePoint = text.codePointAt(offset)\n if (codePoint === undefined) return false\n return /^[\\p{L}\\p{N}_]$/u.test(String.fromCodePoint(codePoint))\n}\n\nfunction previousCodePointStart(text: string, offset: number): number | null {\n if (offset <= 0) return null\n\n const previous = offset - 1\n const codeUnit = text.charCodeAt(previous)\n const beforePrevious = previous - 1\n const isLowSurrogate = codeUnit >= 0xdc00 && codeUnit <= 0xdfff\n if (!isLowSurrogate || beforePrevious < 0) return previous\n\n const previousCodeUnit = text.charCodeAt(beforePrevious)\n const isHighSurrogate = previousCodeUnit >= 0xd800 && previousCodeUnit <= 0xdbff\n return isHighSurrogate ? beforePrevious : previous\n}\n","import { MinimapWorkerRenderer } from './renderer'\nimport type { MinimapWorkerRequest, MinimapWorkerResponse } from './types'\n\nconst renderer = new MinimapWorkerRenderer()\n\nglobalThis.onmessage = (event: MessageEvent<MinimapWorkerRequest>): void => {\n const request = event.data\n try {\n measureWorkerRequest(request, () => handleRequest(request))\n } catch (error) {\n post({ type: 'error', message: errorMessage(error) })\n }\n}\n\nfunction handleRequest(request: MinimapWorkerRequest): void {\n switch (request.type) {\n case 'init':\n renderer.init({\n mainCanvas: request.mainCanvas,\n decorationsCanvas: request.decorationsCanvas,\n options: request.options,\n styles: request.baseStyles,\n })\n return\n case 'updateBaseStyles':\n renderer.setBaseStyles(request.baseStyles)\n return\n case 'openDocument':\n case 'replaceDocument':\n renderer.setDocument(request.document)\n return\n case 'applyEdit':\n renderer.applyEdit(request.edit, request.document)\n return\n case 'applyEdits':\n renderer.applyEdits(request.edits, request.document)\n return\n case 'updateTokens':\n renderer.setTokens(request.tokens)\n return\n case 'updateTokenRange':\n renderer.updateTokenRange(request.patch)\n return\n case 'updateSelection':\n renderer.setSelections(request.selections)\n return\n case 'updateDecorations':\n renderer.setDecorations(request.decorations)\n return\n case 'updateExternalDecorations':\n renderer.setExternalDecorations(request.decorations)\n return\n case 'updateLayout': {\n const layout = renderer.updateLayout(request.metrics, request.viewport)\n if (layout) post({ type: 'layout', sequence: 0, layout })\n return\n }\n case 'updateViewport': {\n const layout = renderer.updateViewport(request.viewport)\n if (layout) post({ type: 'layout', sequence: 0, layout })\n return\n }\n case 'render':\n postRender(request.sequence)\n return\n case 'dispose':\n renderer.dispose()\n post({ type: 'disposed' })\n return\n }\n}\n\nfunction postRender(sequence: number): void {\n const result = renderer.render()\n if (!result) return\n\n post({\n type: 'rendered',\n sequence,\n sliderNeeded: result.sliderNeeded,\n sliderTop: result.sliderTop,\n sliderHeight: result.sliderHeight,\n shadowVisible: result.shadowVisible,\n })\n}\n\nfunction post(response: MinimapWorkerResponse): void {\n globalThis.postMessage(response)\n}\n\nfunction errorMessage(error: unknown): string {\n if (error instanceof Error) return error.message\n return String(error)\n}\n\ntype MinimapWorkerDiagnostic = {\n readonly name: string\n readonly durationMs?: number\n readonly detail?: Readonly<Record<string, unknown>>\n}\n\ntype MinimapWorkerDiagnosticSink =\n | ((diagnostic: MinimapWorkerDiagnostic) => void)\n | {\n readonly enabled?: boolean\n readonly record?: (diagnostic: MinimapWorkerDiagnostic) => void\n }\n\ntype MinimapWorkerDiagnosticGlobal = typeof globalThis & {\n __EDITOR_PERFORMANCE_DIAGNOSTICS__?: MinimapWorkerDiagnosticSink | null\n}\n\nfunction measureWorkerRequest(request: MinimapWorkerRequest, run: () => void): void {\n const sink = minimapWorkerDiagnosticSink()\n if (!sink) {\n run()\n return\n }\n\n const start = nowMs()\n try {\n run()\n } finally {\n recordMinimapWorkerDiagnostic(sink, {\n name: 'minimap.worker.request',\n durationMs: nowMs() - start,\n detail: { request: request.type },\n })\n }\n}\n\nfunction minimapWorkerDiagnosticSink(): MinimapWorkerDiagnosticSink | null {\n const sink = minimapWorkerDiagnosticGlobal().__EDITOR_PERFORMANCE_DIAGNOSTICS__\n if (!sink) return null\n if (typeof sink === 'function') return sink\n if (sink.enabled !== true && typeof sink.record !== 'function') return null\n return sink\n}\n\nfunction recordMinimapWorkerDiagnostic(\n sink: MinimapWorkerDiagnosticSink,\n diagnostic: MinimapWorkerDiagnostic,\n): void {\n if (typeof sink === 'function') {\n sink(diagnostic)\n return\n }\n\n sink.record?.(diagnostic)\n}\n\nfunction minimapWorkerDiagnosticGlobal(): MinimapWorkerDiagnosticGlobal {\n return globalThis as MinimapWorkerDiagnosticGlobal\n}\n\nfunction nowMs(): number {\n return globalThis.performance?.now() ?? Date.now()\n}\n"],"mappings":";AAEA,IAAI,wBAAwB,OAAO,IAAI,6BAA6B;AAEpE,IAAI,mBAAmB,cAAc,MAAM;CAC1C,CAAC;CACD;CACA;CACA;CACA;CACA;CACA,YAAY,SAAS;EACpB,MAAM,WAAW,OAAO,YAAY,WAAW,EAAE,SAAS,QAAQ,IAAI;EACtE,MAAM,SAAS,SAAS,EAAE,OAAO,SAAS,MAAM,CAAC;EACjD,KAAK,OAAO;EACZ,KAAK,OAAO,SAAS;EACrB,KAAK,MAAM,SAAS;EACpB,KAAK,OAAO,SAAS;EACrB,KAAK,SAAS,SAAS,UAAU;EACjC,KAAK,MAAM,SAAS;EACpB,IAAI,SAAS,aAAa,KAAK,GAAG,KAAK,eAAe,SAAS,QAAQ;CACxE;CACA,IAAI,WAAW;EACd,OAAO,KAAK;CACb;CACA,IAAI,aAAa;EAChB,OAAO,KAAK;CACb;CACA,IAAI,aAAa;EAChB,OAAO,KAAK;CACb;CACA,IAAI,gBAAgB;EACnB,OAAO,KAAK;CACb;CACA,IAAI,OAAO;EACV,IAAI,CAAC,KAAK,QAAQ,CAAC,KAAK,OAAO,CAAC,KAAK,OAAO,CAAC,KAAK,MAAM,OAAO,KAAK;EACpE,OAAO;GACN,MAAM,KAAK;GACX,KAAK,KAAK;GACV,KAAK,KAAK;GACV,MAAM,KAAK;EACZ;CACD;CACA,WAAW;EACV,OAAO,gBAAgB,IAAI,CAAC,CAAC,KAAK,IAAI;CACvC;CACA,SAAS;EACR,MAAM,aAAa;GAClB,SAAS,KAAK;GACd,MAAM,KAAK;GACX,QAAQ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AAI;EACJ;CACF;CAEA,MAAM,QAAQ,MAAM;CACpB,IAAI;EACF,IAAI;CACN,UAAU;EACR,8BAA8B,MAAM;GAClC,MAAM;GACN,YAAY,MAAM,IAAI;GACtB,QAAQ,EAAE,SAAS,QAAQ,KAAK;EAClC,CAAC;CACH;AACF;AAEA,SAAS,8BAAkE;CACzE,MAAM,OAAO,8BAA8B,CAAC,CAAC;CAC7C,IAAI,CAAC,MAAM,OAAO;CAClB,IAAI,OAAO,SAAS,YAAY,OAAO;CACvC,IAAI,KAAK,YAAY,QAAQ,OAAO,KAAK,WAAW,YAAY,OAAO;CACvE,OAAO;AACT;AAEA,SAAS,8BACP,MACA,YACM;CACN,IAAI,OAAO,SAAS,YAAY;EAC9B,KAAK,UAAU;EACf;CACF;CAEA,KAAK,SAAS,UAAU;AAC1B;AAEA,SAAS,gCAA+D;CACtE,OAAO;AACT;AAEA,SAAS,QAAgB;CACvB,OAAO,WAAW,aAAa,IAAI,KAAK,KAAK,IAAI;AACnD"}
@@ -0,0 +1,11 @@
1
+ import type { RGBA8 } from './types';
2
+ export declare const RGBA_EMPTY: RGBA8;
3
+ export declare const RGBA_WHITE: RGBA8;
4
+ export declare const RGBA_BLACK: RGBA8;
5
+ export declare function rgbaEquals(left: RGBA8, right: RGBA8): boolean;
6
+ export declare function transparent(color: RGBA8, ratio: number): RGBA8;
7
+ export declare function rgbaToCss(color: RGBA8): string;
8
+ export declare function parseCssColor(value: string | undefined, fallback?: RGBA8): RGBA8;
9
+ export declare function relativeLuminance(color: RGBA8): number;
10
+ export declare function clamp8(value: number): number;
11
+ //# sourceMappingURL=color.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../src/color.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpC,eAAO,MAAM,UAAU,EAAE,KAAkC,CAAA;AAC3D,eAAO,MAAM,UAAU,EAAE,KAA0C,CAAA;AACnE,eAAO,MAAM,UAAU,EAAE,KAAoC,CAAA;AAE7D,wBAAgB,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAE7D;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAE9D;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAE9C;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,GAAE,KAAkB,GAAG,KAAK,CAO5F;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAKtD;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE5C"}
package/dist/color.js ADDED
@@ -0,0 +1,83 @@
1
+ //#region src/color.ts
2
+ var RGBA_EMPTY = {
3
+ r: 0,
4
+ g: 0,
5
+ b: 0,
6
+ a: 0
7
+ };
8
+ var RGBA_WHITE = {
9
+ r: 255,
10
+ g: 255,
11
+ b: 255,
12
+ a: 255
13
+ };
14
+ var RGBA_BLACK = {
15
+ r: 0,
16
+ g: 0,
17
+ b: 0,
18
+ a: 255
19
+ };
20
+ function transparent(color, ratio) {
21
+ return {
22
+ ...color,
23
+ a: clamp8(color.a * ratio)
24
+ };
25
+ }
26
+ function parseCssColor(value, fallback = RGBA_EMPTY) {
27
+ if (!value) return fallback;
28
+ const trimmed = value.trim();
29
+ if (trimmed.startsWith("#")) return parseHexColor(trimmed, fallback);
30
+ if (trimmed.startsWith("rgb")) return parseRgbColor(trimmed, fallback);
31
+ return fallback;
32
+ }
33
+ function clamp8(value) {
34
+ return Math.min(255, Math.max(0, Math.round(value)));
35
+ }
36
+ function parseHexColor(value, fallback) {
37
+ const hex = value.slice(1);
38
+ if (hex.length === 3) return shortHex(hex, fallback);
39
+ if (hex.length === 4) return shortHexAlpha(hex, fallback);
40
+ if (hex.length === 6) return longHex(hex, "ff", fallback);
41
+ if (hex.length === 8) return longHex(hex.slice(0, 6), hex.slice(6), fallback);
42
+ return fallback;
43
+ }
44
+ function shortHex(hex, fallback) {
45
+ return longHex(hex.split("").map((char) => char + char).join(""), "ff", fallback);
46
+ }
47
+ function shortHexAlpha(hex, fallback) {
48
+ const rgb = hex.slice(0, 3);
49
+ const alpha = hex[3] ?? "f";
50
+ return longHex(rgb.split("").map((char) => char + char).join(""), alpha + alpha, fallback);
51
+ }
52
+ function longHex(rgb, alpha, fallback) {
53
+ const value = Number.parseInt(rgb + alpha, 16);
54
+ if (!Number.isFinite(value)) return fallback;
55
+ return {
56
+ r: value >> 24 & 255,
57
+ g: value >> 16 & 255,
58
+ b: value >> 8 & 255,
59
+ a: value & 255
60
+ };
61
+ }
62
+ function parseRgbColor(value, fallback) {
63
+ const parts = value.slice(value.indexOf("(") + 1, value.lastIndexOf(")")).split(/[,\s/]+/).filter(Boolean);
64
+ if (parts.length < 3) return fallback;
65
+ return {
66
+ r: clamp8(Number(parts[0])),
67
+ g: clamp8(Number(parts[1])),
68
+ b: clamp8(Number(parts[2])),
69
+ a: alphaPart(parts[3])
70
+ };
71
+ }
72
+ function alphaPart(value) {
73
+ if (!value) return 255;
74
+ if (value.endsWith("%")) return clamp8(Number.parseFloat(value) / 100 * 255);
75
+ const number = Number(value);
76
+ if (!Number.isFinite(number)) return 255;
77
+ if (number <= 1) return clamp8(number * 255);
78
+ return clamp8(number);
79
+ }
80
+ //#endregion
81
+ export { RGBA_BLACK, RGBA_EMPTY, RGBA_WHITE, clamp8, parseCssColor, transparent };
82
+
83
+ //# sourceMappingURL=color.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color.js","names":[],"sources":["../src/color.ts"],"sourcesContent":["import type { RGBA8 } from './types'\n\nexport const RGBA_EMPTY: RGBA8 = { r: 0, g: 0, b: 0, a: 0 }\nexport const RGBA_WHITE: RGBA8 = { r: 255, g: 255, b: 255, a: 255 }\nexport const RGBA_BLACK: RGBA8 = { r: 0, g: 0, b: 0, a: 255 }\n\nexport function rgbaEquals(left: RGBA8, right: RGBA8): boolean {\n return left.r === right.r && left.g === right.g && left.b === right.b && left.a === right.a\n}\n\nexport function transparent(color: RGBA8, ratio: number): RGBA8 {\n return { ...color, a: clamp8(color.a * ratio) }\n}\n\nexport function rgbaToCss(color: RGBA8): string {\n return `rgba(${color.r}, ${color.g}, ${color.b}, ${color.a / 255})`\n}\n\nexport function parseCssColor(value: string | undefined, fallback: RGBA8 = RGBA_EMPTY): RGBA8 {\n if (!value) return fallback\n\n const trimmed = value.trim()\n if (trimmed.startsWith('#')) return parseHexColor(trimmed, fallback)\n if (trimmed.startsWith('rgb')) return parseRgbColor(trimmed, fallback)\n return fallback\n}\n\nexport function relativeLuminance(color: RGBA8): number {\n const r = linearRgb(color.r / 255)\n const g = linearRgb(color.g / 255)\n const b = linearRgb(color.b / 255)\n return 0.2126 * r + 0.7152 * g + 0.0722 * b\n}\n\nexport function clamp8(value: number): number {\n return Math.min(255, Math.max(0, Math.round(value)))\n}\n\nfunction parseHexColor(value: string, fallback: RGBA8): RGBA8 {\n const hex = value.slice(1)\n if (hex.length === 3) return shortHex(hex, fallback)\n if (hex.length === 4) return shortHexAlpha(hex, fallback)\n if (hex.length === 6) return longHex(hex, 'ff', fallback)\n if (hex.length === 8) return longHex(hex.slice(0, 6), hex.slice(6), fallback)\n return fallback\n}\n\nfunction shortHex(hex: string, fallback: RGBA8): RGBA8 {\n return longHex(\n hex\n .split('')\n .map((char) => char + char)\n .join(''),\n 'ff',\n fallback,\n )\n}\n\nfunction shortHexAlpha(hex: string, fallback: RGBA8): RGBA8 {\n const rgb = hex.slice(0, 3)\n const alpha = hex[3] ?? 'f'\n return longHex(\n rgb\n .split('')\n .map((char) => char + char)\n .join(''),\n alpha + alpha,\n fallback,\n )\n}\n\nfunction longHex(rgb: string, alpha: string, fallback: RGBA8): RGBA8 {\n const value = Number.parseInt(rgb + alpha, 16)\n if (!Number.isFinite(value)) return fallback\n\n return {\n r: (value >> 24) & 0xff,\n g: (value >> 16) & 0xff,\n b: (value >> 8) & 0xff,\n a: value & 0xff,\n }\n}\n\nfunction parseRgbColor(value: string, fallback: RGBA8): RGBA8 {\n const body = value.slice(value.indexOf('(') + 1, value.lastIndexOf(')'))\n const parts = body.split(/[,\\s/]+/).filter(Boolean)\n if (parts.length < 3) return fallback\n\n return {\n r: clamp8(Number(parts[0])),\n g: clamp8(Number(parts[1])),\n b: clamp8(Number(parts[2])),\n a: alphaPart(parts[3]),\n }\n}\n\nfunction alphaPart(value: string | undefined): number {\n if (!value) return 255\n if (value.endsWith('%')) return clamp8((Number.parseFloat(value) / 100) * 255)\n\n const number = Number(value)\n if (!Number.isFinite(number)) return 255\n if (number <= 1) return clamp8(number * 255)\n return clamp8(number)\n}\n\nfunction linearRgb(value: number): number {\n if (value <= 0.04045) return value / 12.92\n return ((value + 0.055) / 1.055) ** 2.4\n}\n"],"mappings":";AAEA,IAAa,aAAoB;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE;AAC1D,IAAa,aAAoB;CAAE,GAAG;CAAK,GAAG;CAAK,GAAG;CAAK,GAAG;AAAI;AAClE,IAAa,aAAoB;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAG,GAAG;AAAI;AAM5D,SAAgB,YAAY,OAAc,OAAsB;CAC9D,OAAO;EAAE,GAAG;EAAO,GAAG,OAAO,MAAM,IAAI,KAAK;CAAE;AAChD;AAMA,SAAgB,cAAc,OAA2B,WAAkB,YAAmB;CAC5F,IAAI,CAAC,OAAO,OAAO;CAEnB,MAAM,UAAU,MAAM,KAAK;CAC3B,IAAI,QAAQ,WAAW,GAAG,GAAG,OAAO,cAAc,SAAS,QAAQ;CACnE,IAAI,QAAQ,WAAW,KAAK,GAAG,OAAO,cAAc,SAAS,QAAQ;CACrE,OAAO;AACT;AASA,SAAgB,OAAO,OAAuB;CAC5C,OAAO,KAAK,IAAI,KAA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GAAG,OAAO;CAE7B,OAAO;EACL,GAAG,OAAO,OAAO,MAAM,EAAE,CAAC;EAC1B,GAAG,OAAO,OAAO,MAAM,EAAE,CAAC;EAC1B,GAAG,OAAO,OAAO,MAAM,EAAE,CAAC;EAC1B,GAAG,UAAU,MAAM,EAAE;CACvB;AACF;AAEA,SAAS,UAAU,OAAmC;CACpD,IAAI,CAAC,OAAO,OAAO;CACnB,IAAI,MAAM,SAAS,GAAG,GAAG,OAAO,OAAQ,OAAO,WAAW,KAAK,IAAI,MAAO,GAAG;CAE7E,MAAM,SAAS,OAAO,KAAK;CAC3B,IAAI,CAAC,OAAO,SAAS,MAAM,GAAG,OAAO;CACrC,IAAI,UAAU,GAAG,OAAO,OAAO,SAAS,GAAG;CAC3C,OAAO,OAAO,MAAM;AACtB"}
@@ -0,0 +1,10 @@
1
+ import type { EditorMinimapDecoration } from './types';
2
+ /**
3
+ * Past this many bands sharing one appearance the minimap stops answering the
4
+ * question it was asked. The marks overlap into a solid wash that says no more
5
+ * than a count already did, and the whole flattened list is re-collected and
6
+ * re-posted whenever any source changes.
7
+ */
8
+ export declare const MINIMAP_DECORATION_MERGE_LIMIT = 1000;
9
+ export declare function mergeDenseDecorations(decorations: readonly EditorMinimapDecoration[], height: number, lineCount: number): readonly EditorMinimapDecoration[];
10
+ //# sourceMappingURL=decorationMerge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorationMerge.d.ts","sourceRoot":"","sources":["../src/decorationMerge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAEtD;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B,OAAO,CAAA;AAOlD,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,SAAS,uBAAuB,EAAE,EAC/C,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,SAAS,uBAAuB,EAAE,CAcpC"}
@@ -0,0 +1,65 @@
1
+ //#region src/decorationMerge.ts
2
+ /**
3
+ * Past this many bands sharing one appearance the minimap stops answering the
4
+ * question it was asked. The marks overlap into a solid wash that says no more
5
+ * than a count already did, and the whole flattened list is re-collected and
6
+ * re-posted whenever any source changes.
7
+ */
8
+ var MINIMAP_DECORATION_MERGE_LIMIT = 1e3;
9
+ var MERGE_PIXEL_DISTANCE = 3;
10
+ var MERGE_LINE_DISTANCE_FLOOR = 2;
11
+ function mergeDenseDecorations(decorations, height, lineCount) {
12
+ if (decorations.length <= 1e3) return decorations;
13
+ const distance = mergeLineDistance(height, lineCount);
14
+ const merged = [];
15
+ for (const group of groupByAppearance(decorations).values()) {
16
+ if (group.length <= 1e3) {
17
+ for (const decoration of group) merged.push(decoration);
18
+ continue;
19
+ }
20
+ appendMergedBands(merged, group, distance);
21
+ }
22
+ return merged;
23
+ }
24
+ function mergeLineDistance(height, lineCount) {
25
+ if (height <= 0) return Math.max(MERGE_LINE_DISTANCE_FLOOR, lineCount);
26
+ return Math.max(MERGE_LINE_DISTANCE_FLOOR, Math.ceil(MERGE_PIXEL_DISTANCE * lineCount / height));
27
+ }
28
+ function groupByAppearance(decorations) {
29
+ const groups = /* @__PURE__ */ new Map();
30
+ for (const decoration of decorations) {
31
+ const key = `${decoration.position}|${decoration.color ?? ""}|${decoration.zIndex ?? 0}`;
32
+ const group = groups.get(key);
33
+ if (group) {
34
+ group.push(decoration);
35
+ continue;
36
+ }
37
+ groups.set(key, [decoration]);
38
+ }
39
+ return groups;
40
+ }
41
+ function appendMergedBands(target, group, distance) {
42
+ const ordered = group.toSorted(byStartLineNumber);
43
+ let band = ordered[0];
44
+ if (!band) return;
45
+ for (let index = 1; index < ordered.length; index += 1) {
46
+ const next = ordered[index];
47
+ if (next.startLineNumber - band.endLineNumber > distance) {
48
+ target.push(band);
49
+ band = next;
50
+ continue;
51
+ }
52
+ if (next.endLineNumber > band.endLineNumber) band = {
53
+ ...band,
54
+ endLineNumber: next.endLineNumber
55
+ };
56
+ }
57
+ target.push(band);
58
+ }
59
+ function byStartLineNumber(left, right) {
60
+ return left.startLineNumber - right.startLineNumber;
61
+ }
62
+ //#endregion
63
+ export { MINIMAP_DECORATION_MERGE_LIMIT, mergeDenseDecorations };
64
+
65
+ //# sourceMappingURL=decorationMerge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorationMerge.js","names":[],"sources":["../src/decorationMerge.ts"],"sourcesContent":["import type { EditorMinimapDecoration } from './types'\n\n/**\n * Past this many bands sharing one appearance the minimap stops answering the\n * question it was asked. The marks overlap into a solid wash that says no more\n * than a count already did, and the whole flattened list is re-collected and\n * re-posted whenever any source changes.\n */\nexport const MINIMAP_DECORATION_MERGE_LIMIT = 1000\n\n// Two bands nearer than this cannot be told apart once painted, and neighbouring\n// rows are one thing to look at however many pixels the minimap has to spare.\nconst MERGE_PIXEL_DISTANCE = 3\nconst MERGE_LINE_DISTANCE_FLOOR = 2\n\nexport function mergeDenseDecorations(\n decorations: readonly EditorMinimapDecoration[],\n height: number,\n lineCount: number,\n): readonly EditorMinimapDecoration[] {\n if (decorations.length <= MINIMAP_DECORATION_MERGE_LIMIT) return decorations\n\n const distance = mergeLineDistance(height, lineCount)\n const merged: EditorMinimapDecoration[] = []\n for (const group of groupByAppearance(decorations).values()) {\n if (group.length <= MINIMAP_DECORATION_MERGE_LIMIT) {\n for (const decoration of group) merged.push(decoration)\n continue\n }\n\n appendMergedBands(merged, group, distance)\n }\n return merged\n}\n\n// How many document lines land within one band's width once the document is\n// projected onto the height it is drawn at.\nfunction mergeLineDistance(height: number, lineCount: number): number {\n if (height <= 0) return Math.max(MERGE_LINE_DISTANCE_FLOOR, lineCount)\n\n return Math.max(MERGE_LINE_DISTANCE_FLOOR, Math.ceil((MERGE_PIXEL_DISTANCE * lineCount) / height))\n}\n\n// One band standing in for several has to paint as one of them, so only bands\n// that already paint alike may be combined: a span covering both an error and a\n// search hit would have to pick a colour and be wrong about the other.\nfunction groupByAppearance(\n decorations: readonly EditorMinimapDecoration[],\n): Map<string, EditorMinimapDecoration[]> {\n const groups = new Map<string, EditorMinimapDecoration[]>()\n for (const decoration of decorations) {\n const key = `${decoration.position}|${decoration.color ?? ''}|${decoration.zIndex ?? 0}`\n const group = groups.get(key)\n if (group) {\n group.push(decoration)\n continue\n }\n\n groups.set(key, [decoration])\n }\n return groups\n}\n\nfunction appendMergedBands(\n target: EditorMinimapDecoration[],\n group: readonly EditorMinimapDecoration[],\n distance: number,\n): void {\n const ordered = group.toSorted(byStartLineNumber)\n let band = ordered[0]\n if (!band) return\n\n for (let index = 1; index < ordered.length; index += 1) {\n const next = ordered[index]!\n if (next.startLineNumber - band.endLineNumber > distance) {\n target.push(band)\n band = next\n continue\n }\n\n if (next.endLineNumber > band.endLineNumber) {\n band = { ...band, endLineNumber: next.endLineNumber }\n }\n }\n target.push(band)\n}\n\nfunction byStartLineNumber(left: EditorMinimapDecoration, right: EditorMinimapDecoration): number {\n return left.startLineNumber - right.startLineNumber\n}\n"],"mappings":";;;;;;;AAQA,IAAa,iCAAiC;AAI9C,IAAM,uBAAuB;AAC7B,IAAM,4BAA4B;AAElC,SAAgB,sBACd,aACA,QACA,WACoC;CACpC,IAAI,YAAY,UAAA,KAA0C,OAAO;CAEjE,MAAM,WAAW,kBAAkB,QAAQ,SAAS;CACpD,MAAM,SAAoC,CAAC;CAC3C,KAAK,MAAM,SAAS,kBAAkB,WAAW,CAAC,CAAC,OAAO,GAAG;EAC3D,IAAI,MAAM,UAAA,KAA0C;GAClD,KAAK,MAAM,cAAc,OAAO,OAAO,KAAK,UAAU;GACtD;EACF;EAEA,kBAAkB,QAAQ,OAAO,QAAQ;CAC3C;CACA,OAAO;AACT;AAIA,SAAS,kBAAkB,QAAgB,WAA2B;CACpE,IAAI,UAAU,GAAG,OAAO,KAAK,IAAI,2BAA2B,SAAS;CAErE,OAAO,KAAK,IAAI,2BAA2B,KAAK,KAAM,uBAAuB,YAAa,MAAM,CAAC;AACnG;AAKA,SAAS,kBACP,aACwC;CACxC,MAAM,yBAAS,IAAI,IAAuC;CAC1D,KAAK,MAAM,cAAc,aAAa;EACpC,MAAM,MAAM,GAAG,WAAW,SAAS,GAAG,WAAW,SAAS,GAAG,GAAG,WAAW,UAAU;EACrF,MAAM,QAAQ,OAAO,IAAI,GAAG;EAC5B,IAAI,OAAO;GACT,MAAM,KAAK,UAAU;GACrB;EACF;EAEA,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC;CAC9B;CACA,OAAO;AACT;AAEA,SAAS,kBACP,QACA,OACA,UACM;CACN,MAAM,UAAU,MAAM,SAAS,iBAAiB;CAChD,IAAI,OAAO,QAAQ;CACnB,IAAI,CAAC,MAAM;CAEX,KAAK,IAAI,QAAQ,GAAG,QAAQ,QAAQ,QAAQ,SAAS,GAAG;EACtD,MAAM,OAAO,QAAQ;EACrB,IAAI,KAAK,kBAAkB,KAAK,gBAAgB,UAAU;GACxD,OAAO,KAAK,IAAI;GAChB,OAAO;GACP;EACF;EAEA,IAAI,KAAK,gBAAgB,KAAK,eAC5B,OAAO;GAAE,GAAG;GAAM,eAAe,KAAK;EAAc;CAExD;CACA,OAAO,KAAK,IAAI;AAClB;AAEA,SAAS,kBAAkB,MAA+B,OAAwC;CAChG,OAAO,KAAK,kBAAkB,MAAM;AACtC"}
@@ -0,0 +1,4 @@
1
+ import './style.css';
2
+ export { createMinimapPlugin } from './plugin';
3
+ export type { EditorMinimapDecoration, EditorMinimapOptions, MinimapAutohide, MinimapDecorationPosition, MinimapSectionHeaderStyle, MinimapSide, MinimapSize, MinimapSliderVisibility, } from './types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAC9C,YAAY,EACV,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,EACf,yBAAyB,EACzB,yBAAyB,EACzB,WAAW,EACX,WAAW,EACX,uBAAuB,GACxB,MAAM,SAAS,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import { createMinimapPlugin } from "./plugin.js";
2
+ import "./style.css";
3
+ export { createMinimapPlugin };
@@ -0,0 +1,43 @@
1
+ import type { EditorViewSnapshot, EditorViewportSnapshot } from '@singapore-editor/core/extensions';
2
+ import type { MinimapMetrics, MinimapRenderLayout, MinimapViewport, ResolvedMinimapOptions } from './types';
3
+ export declare const MINIMAP_GUTTER_WIDTH = 2;
4
+ export declare const MINIMAP_RIGHT_GUTTER_WIDTH = 8;
5
+ export type MinimapFrameLayout = {
6
+ readonly scrollTop: number;
7
+ readonly scrollHeight: number;
8
+ readonly sliderNeeded: boolean;
9
+ readonly sliderLineHeight: number;
10
+ readonly documentLineHeight: number;
11
+ readonly documentStart: number;
12
+ readonly sliderTop: number;
13
+ readonly sliderHeight: number;
14
+ readonly topPaddingLineCount: number;
15
+ readonly startLineNumber: number;
16
+ readonly startLineFraction: number;
17
+ readonly endLineNumber: number;
18
+ };
19
+ export declare function computeRenderLayout(options: {
20
+ readonly minimap: ResolvedMinimapOptions;
21
+ readonly metrics: MinimapMetrics;
22
+ readonly viewport: MinimapViewport;
23
+ readonly lineCount: number;
24
+ }): MinimapRenderLayout;
25
+ export declare function computeFrameLayout(options: {
26
+ readonly renderLayout: MinimapRenderLayout;
27
+ readonly metrics: MinimapMetrics;
28
+ readonly viewport: MinimapViewport;
29
+ readonly lineCount: number;
30
+ readonly realLineCount: number;
31
+ readonly previous: MinimapFrameLayout | null;
32
+ }): MinimapFrameLayout;
33
+ /** Zero-based document line at a CSS pixel in the rendered minimap. */
34
+ export declare function documentLineAtY(frame: MinimapFrameLayout, y: number): number;
35
+ /** Inverse of slider placement, including a proportional raster's moving origin. */
36
+ export declare function documentLineForSliderY(frame: MinimapFrameLayout, y: number): number;
37
+ /** Mounted rows include overscan. Continuations still identify a visible document line. */
38
+ export declare function visibleDocumentLineRange(snapshot: Pick<EditorViewSnapshot, 'visibleRows' | 'lineCount'>, viewport: EditorViewportSnapshot): {
39
+ readonly start: number;
40
+ readonly end: number;
41
+ };
42
+ export declare function yForLineNumber(frame: Pick<MinimapFrameLayout, 'startLineNumber' | 'topPaddingLineCount'>, lineNumber: number, minimapLineHeight: number): number;
43
+ //# sourceMappingURL=layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../src/layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAA;AAEnG,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACvB,MAAM,SAAS,CAAA;AAGhB,eAAO,MAAM,oBAAoB,IAAI,CAAA;AACrC,eAAO,MAAM,0BAA0B,IAAI,CAAA;AAE3C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAA;IAC9B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAA;IACnC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAA;IACpC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAA;IAClC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;CAC/B,CAAA;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE;IAC3C,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAA;IACxC,QAAQ,CAAC,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