@dou-ui/code 0.0.0-stage → 0.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +10 -2
- package/dist/_virtual/_rolldown/runtime.js +12 -0
- package/dist/assets/default-BZBMZKf_.js.map +1 -0
- package/dist/code-diff.js +6 -0
- package/dist/code-diff.js.map +1 -0
- package/dist/code-diff.vue_vue_type_script_setup_true_lang.js +792 -0
- package/dist/code-diff.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/code-editor.js +6 -0
- package/dist/code-editor.js.map +1 -0
- package/dist/code-editor.vue_vue_type_script_setup_true_lang.js +4917 -0
- package/dist/code-editor.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/code-input.js +6 -0
- package/dist/code-input.js.map +1 -0
- package/dist/code-input.vue_vue_type_script_setup_true_lang.js +237 -0
- package/dist/code-input.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/code-keys.js +42 -0
- package/dist/code-keys.js.map +1 -0
- package/dist/code-keys.vue_vue_type_script_setup_true_lang.js +168 -0
- package/dist/code-keys.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/code-keys2.js +6 -0
- package/dist/code-keys2.js.map +1 -0
- package/dist/collaboration/index.js +255 -0
- package/dist/collaboration/index.js.map +1 -0
- package/dist/completion/match.js +55 -0
- package/dist/completion/match.js.map +1 -0
- package/dist/completion/snippet.js +71 -0
- package/dist/completion/snippet.js.map +1 -0
- package/dist/core/brackets.js +55 -0
- package/dist/core/brackets.js.map +1 -0
- package/dist/core/changes.js +185 -0
- package/dist/core/changes.js.map +1 -0
- package/dist/core/chars.js +130 -0
- package/dist/core/chars.js.map +1 -0
- package/dist/core/commands.js +910 -0
- package/dist/core/commands.js.map +1 -0
- package/dist/core/diff.js +215 -0
- package/dist/core/diff.js.map +1 -0
- package/dist/core/folding.js +87 -0
- package/dist/core/folding.js.map +1 -0
- package/dist/core/history.js +74 -0
- package/dist/core/history.js.map +1 -0
- package/dist/core/keymap.js +326 -0
- package/dist/core/keymap.js.map +1 -0
- package/dist/core/search.js +91 -0
- package/dist/core/search.js.map +1 -0
- package/dist/core/selection.js +88 -0
- package/dist/core/selection.js.map +1 -0
- package/dist/core/text.js +320 -0
- package/dist/core/text.js.map +1 -0
- package/dist/core/transaction.js +98 -0
- package/dist/core/transaction.js.map +1 -0
- package/dist/extension.js +16 -0
- package/dist/extension.js.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/language/highlighter.js +336 -0
- package/dist/language/highlighter.js.map +1 -0
- package/dist/language/language.js +138 -0
- package/dist/language/language.js.map +1 -0
- package/dist/language/stream.js +112 -0
- package/dist/language/stream.js.map +1 -0
- package/dist/language/to-html.js +36 -0
- package/dist/language/to-html.js.map +1 -0
- package/dist/language/worker-client.js +198 -0
- package/dist/language/worker-client.js.map +1 -0
- package/dist/language/worker-protocol.js +48 -0
- package/dist/language/worker-protocol.js.map +1 -0
- package/dist/languages/css.js +128 -0
- package/dist/languages/css.js.map +1 -0
- package/dist/languages/html.js +175 -0
- package/dist/languages/html.js.map +1 -0
- package/dist/languages/javascript.js +300 -0
- package/dist/languages/javascript.js.map +1 -0
- package/dist/languages/json.js +45 -0
- package/dist/languages/json.js.map +1 -0
- package/dist/languages/markdown.js +82 -0
- package/dist/languages/markdown.js.map +1 -0
- package/dist/languages/python.js +88 -0
- package/dist/languages/python.js.map +1 -0
- package/dist/languages/shell.js +153 -0
- package/dist/languages/shell.js.map +1 -0
- package/dist/languages/sql.js +91 -0
- package/dist/languages/sql.js.map +1 -0
- package/dist/languages/yaml.js +85 -0
- package/dist/languages/yaml.js.map +1 -0
- package/dist/locale.js +164 -0
- package/dist/locale.js.map +1 -0
- package/dist/lsp/index.js +715 -0
- package/dist/lsp/index.js.map +1 -0
- package/dist/lsp/markup.js +139 -0
- package/dist/lsp/markup.js.map +1 -0
- package/dist/render-part.js +14 -0
- package/dist/render-part.js.map +1 -0
- package/dist/shiki/index.js +140 -0
- package/dist/shiki/index.js.map +1 -0
- package/dist/style.css +1 -0
- package/dist/style.d.ts +1 -0
- package/dist/style.js +4 -0
- package/dist/types/code-diff.vue.d.ts +45 -0
- package/dist/types/code-editor.vue.d.ts +43 -0
- package/dist/types/code-input.vue.d.ts +32 -0
- package/dist/types/code-keys.d.ts +9 -0
- package/dist/types/code-keys.vue.d.ts +8 -0
- package/dist/types/collaboration/index.d.ts +36 -0
- package/dist/types/completion/match.d.ts +13 -0
- package/dist/types/completion/snippet.d.ts +17 -0
- package/dist/types/core/brackets.d.ts +15 -0
- package/dist/types/core/changes.d.ts +52 -0
- package/dist/types/core/chars.d.ts +24 -0
- package/dist/types/core/commands.d.ts +199 -0
- package/dist/types/core/diff.d.ts +52 -0
- package/dist/types/core/folding.d.ts +23 -0
- package/dist/types/core/history.d.ts +24 -0
- package/dist/types/core/keymap.d.ts +29 -0
- package/dist/types/core/search.d.ts +37 -0
- package/dist/types/core/selection.d.ts +28 -0
- package/dist/types/core/text.d.ts +79 -0
- package/dist/types/core/transaction.d.ts +65 -0
- package/dist/types/extension.d.ts +321 -0
- package/dist/types/index.d.ts +159 -0
- package/dist/types/language/highlighter.d.ts +99 -0
- package/dist/types/language/language.d.ts +100 -0
- package/dist/types/language/stream.d.ts +56 -0
- package/dist/types/language/to-html.d.ts +17 -0
- package/dist/types/language/worker-client.d.ts +52 -0
- package/dist/types/language/worker-protocol.d.ts +50 -0
- package/dist/types/languages/css.d.ts +17 -0
- package/dist/types/languages/html.d.ts +34 -0
- package/dist/types/languages/javascript.d.ts +29 -0
- package/dist/types/languages/json.d.ts +7 -0
- package/dist/types/languages/markdown.d.ts +17 -0
- package/dist/types/languages/python.d.ts +9 -0
- package/dist/types/languages/shell.d.ts +11 -0
- package/dist/types/languages/sql.d.ts +9 -0
- package/dist/types/languages/yaml.d.ts +14 -0
- package/dist/types/locale.d.ts +79 -0
- package/dist/types/lsp/index.d.ts +119 -0
- package/dist/types/lsp/markup.d.ts +14 -0
- package/dist/types/render-part.d.ts +14 -0
- package/dist/types/shiki/index.d.ts +63 -0
- package/dist/types/types.d.ts +267 -0
- package/dist/types/view/input.d.ts +12 -0
- package/dist/types/view/layout.d.ts +55 -0
- package/dist/types/view/measure.d.ts +22 -0
- package/dist/types/worker/default.d.ts +1 -0
- package/dist/types/worker/index.d.ts +34 -0
- package/dist/view/input.js +27 -0
- package/dist/view/input.js.map +1 -0
- package/dist/view/layout.js +194 -0
- package/dist/view/layout.js.map +1 -0
- package/dist/view/measure.js +104 -0
- package/dist/view/measure.js.map +1 -0
- package/dist/worker/default.js +20 -0
- package/dist/worker/default.js.map +1 -0
- package/dist/worker/index.js +139 -0
- package/dist/worker/index.js.map +1 -0
- package/package.json +88 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/lsp/index.ts"],"sourcesContent":["import type { VNodeChild } from 'vue'\nimport type { CodeCommand } from '../core/commands'\nimport type { CodeText } from '../core/text'\nimport type { CodeTransactionResult } from '../core/transaction'\nimport {\n type CodeCompletion,\n type CodeCompletionKind,\n type CodeCompletionResult,\n type CodeDiagnostic,\n type CodeDiagnosticSeverity,\n type CodeExtension,\n type CodeExtensionContext,\n type CodeHoverResult,\n type CodeSignatureResult,\n defineCodeExtension,\n} from '../extension'\nimport { type Markup, lspMarkup } from './markup'\n\n/** A position as the protocol counts it: line and character (UTF-16 code units), both from 0. */\nexport interface LspPosition {\n line: number\n character: number\n}\n\nexport interface LspRange {\n start: LspPosition\n end: LspPosition\n}\n\n/** A place in some document, e.g. where a name is defined. */\nexport interface LspLocation {\n uri: string\n range: LspRange\n}\n\n/** A JSON-RPC message: a request, its response, or a notification. */\nexport interface LspMessage {\n jsonrpc: '2.0'\n id?: number | string | null\n method?: string\n params?: unknown\n result?: unknown\n error?: { code: number; message: string; data?: unknown }\n}\n\n/**\n * How messages reach the server and come back: one JSON-RPC message\n * (an object, not a string) at a time.\n */\nexport interface LspTransport {\n send: (message: LspMessage) => void\n /** Listens for the server's messages; returns a function that stops listening. */\n onMessage: (listener: (message: LspMessage) => void) => () => void\n /** Ends the connection, e.g. terminates the worker. */\n close?: () => void\n /**\n * Listens for the connection breaking by itself, e.g. the worker failing\n * or the socket closing; returns a function that stops listening.\n */\n onClose?: (listener: () => void) => () => void\n}\n\nexport interface LanguageClientOptions {\n /**\n * The connection to the server. A function is called when the first\n * editor using the client mounts, and the connection is shut down and\n * closed when the last one unmounts; a later editor starts a new one.\n * A transport given as it is stays open until `close()`.\n *\n * Editors still mounted when the connection ends (`close()`, or the\n * server stopping by itself) stay without the server until they mount\n * again.\n */\n transport: LspTransport | (() => LspTransport)\n /** The workspace folder, sent as `rootUri`. */\n rootUri?: string | null\n /** Sent as `initializationOptions`, for what the server reads there. */\n initializationOptions?: unknown\n}\n\nexport interface LanguageDocumentOptions {\n /** The document's URI, e.g. `file:///src/report.ts`. */\n uri: string\n /** The language's identifier as the server knows it, e.g. `typescript`. */\n languageId: string\n /**\n * Opens a definition in another document (`F12` on a name defined\n * elsewhere). Definitions in this document are selected in place.\n */\n openLocation?: (location: LspLocation) => void\n}\n\n/** A document's extension, with its commands. */\nexport interface LanguageDocument extends CodeExtension {\n /**\n * Goes to the definition of the name at the cursor: a command for\n * `editor.run()`, a key of `DouCodeKeys` or your own button. Also on\n * `F12`, and in the touch toolbar when the cursor is on a name.\n */\n goToDefinition: CodeCommand\n}\n\nexport interface LanguageClient {\n /** An extension that opens a document on the server and shows what it says about it. One per editor. */\n document: (options: LanguageDocumentOptions) => LanguageDocument\n /** Sends a request once the server is ready; `signal` cancels it (`$/cancelRequest`). */\n request: <T = unknown>(method: string, params?: unknown, signal?: AbortSignal) => Promise<T>\n /** Sends a notification once the server is ready. */\n notify: (method: string, params?: unknown) => void\n /** Listens for one of the server's notifications, e.g. `window/logMessage`; returns a function that stops listening. */\n onNotification: (method: string, listener: (params: any) => void) => () => void\n /** What the server said it can do in its `initialize` answer; `null` until it answered. */\n readonly capabilities: Readonly<Record<string, any>> | null\n /** Shuts the server down and closes the connection. */\n close: () => void\n}\n\nconst warn = (message: string, error?: unknown) => {\n if (process.env.NODE_ENV === 'production') return\n console.warn(`[@dou-ui/code] ${message}`, ...(error === undefined ? [] : [error]))\n}\n\n/**\n * A transport over a Web Worker that runs the server, posting message\n * objects both ways. An error before the worker's first message (it failed\n * to load) counts as the connection closing; an error after it, thrown\n * while handling one request, leaves the worker running.\n */\nexport function workerTransport(worker: Worker): LspTransport {\n let answered = false\n let warned = false\n worker.addEventListener('message', () => (answered = true), { once: true })\n return {\n // oxlint-disable-next-line unicorn/require-post-message-target-origin -- a worker's postMessage has no target origin\n send: (message) => worker.postMessage(message),\n onMessage: (listener) => {\n const handle = (event: MessageEvent) => listener(event.data as LspMessage)\n worker.addEventListener('message', handle)\n return () => worker.removeEventListener('message', handle)\n },\n close: () => worker.terminate(),\n onClose: (listener) => {\n const handle = (event: Event) => {\n if (!answered) return listener()\n if (!warned) warn('the language server threw an error; it keeps running', event)\n warned = true\n }\n worker.addEventListener('error', handle)\n return () => worker.removeEventListener('error', handle)\n },\n }\n}\n\n/**\n * A transport over a WebSocket, one JSON message per frame. Messages sent\n * before it opens wait for it.\n */\nexport function socketTransport(socket: WebSocket): LspTransport {\n const waiting: string[] = []\n socket.addEventListener('open', () => {\n for (const text of waiting.splice(0)) socket.send(text)\n })\n return {\n send: (message) => {\n const text = JSON.stringify(message)\n if (socket.readyState === WebSocket.CONNECTING) waiting.push(text)\n else if (socket.readyState === WebSocket.OPEN) socket.send(text)\n },\n onMessage: (listener) => {\n const handle = (event: MessageEvent) => {\n if (typeof event.data !== 'string') return\n try {\n listener(JSON.parse(event.data) as LspMessage)\n } catch (error) {\n warn('the language server sent a frame that is not JSON', error)\n }\n }\n socket.addEventListener('message', handle)\n return () => socket.removeEventListener('message', handle)\n },\n close: () => socket.close(),\n onClose: (listener) => {\n const handle = () => listener()\n socket.addEventListener('close', handle)\n socket.addEventListener('error', handle)\n return () => {\n socket.removeEventListener('close', handle)\n socket.removeEventListener('error', handle)\n }\n },\n }\n}\n\n/** Offset `pos` as the protocol's line and character. */\nexport function toLspPosition(doc: CodeText, pos: number): LspPosition {\n const line = doc.lineAt(Math.max(0, Math.min(pos, doc.length)))\n return { line: line.number - 1, character: pos - line.from }\n}\n\n/** The offset of a protocol position; past the end of a line or the text, the nearest end. */\nexport function fromLspPosition(doc: CodeText, position: LspPosition): number {\n if (position.line < 0) return 0\n if (position.line >= doc.lines) return doc.length\n const line = doc.line(position.line + 1)\n return line.from + Math.max(0, Math.min(position.character, line.to - line.from))\n}\n\n/** What waiting requests are rejected with when the connection ends. */\nconst CLOSED = new Error('[@dou-ui/code] the connection to the language server ended')\n\nconst CLIENT_CAPABILITIES = {\n general: { positionEncodings: ['utf-16'] },\n textDocument: {\n synchronization: { dynamicRegistration: false, didSave: false },\n completion: {\n contextSupport: true,\n completionItem: {\n snippetSupport: true,\n documentationFormat: ['markdown', 'plaintext'],\n insertReplaceSupport: true,\n labelDetailsSupport: true,\n },\n },\n hover: { contentFormat: ['markdown', 'plaintext'] },\n signatureHelp: {\n signatureInformation: {\n documentationFormat: ['markdown', 'plaintext'],\n parameterInformation: { labelOffsetSupport: true },\n activeParameterSupport: true,\n },\n },\n definition: { linkSupport: true },\n publishDiagnostics: { versionSupport: true },\n diagnostic: { dynamicRegistration: false },\n },\n window: { workDoneProgress: false },\n}\n\n/**\n * Talks to a language server: its completions, hover texts, parameter\n * hints, problems and definitions show in the editors that use\n * `client.document(...)`.\n */\nexport function createLanguageClient(options: LanguageClientOptions): LanguageClient {\n let transport: LspTransport | null = null\n let stopListening: (() => void) | null = null\n /** Counts connections: a document that opened on an earlier one doesn't count toward this one. */\n let generation = 0\n /** The mounted documents, told when their connection ends. */\n const attached = new Set<() => void>()\n let ready: Promise<void> | null = null\n let capabilities: Record<string, any> | null = null\n let users = 0\n let nextId = 0\n const pending = new Map<number, { resolve: (value: any) => void; reject: (error: any) => void }>()\n const listeners = new Map<string, Set<(params: any) => void>>()\n const owned = typeof options.transport === 'function'\n\n const send = (message: Omit<LspMessage, 'jsonrpc'>) =>\n transport?.send({ jsonrpc: '2.0', ...message })\n\n function rawRequest<T>(method: string, params: unknown, signal?: AbortSignal): Promise<T> {\n const id = ++nextId\n return new Promise<T>((resolve, reject) => {\n if (signal?.aborted) return reject(signal.reason)\n pending.set(id, { resolve, reject })\n send({ id, method, params })\n signal?.addEventListener(\n 'abort',\n () => {\n if (!pending.delete(id)) return\n send({ method: '$/cancelRequest', params: { id } })\n reject(signal.reason)\n },\n { once: true },\n )\n })\n }\n\n /** What the client answers to the server's own requests: enough that none of them hangs. */\n function answer(message: LspMessage) {\n const { id, method, params } = message\n if (method === 'workspace/configuration') {\n const items = (params as { items?: unknown[] } | undefined)?.items ?? []\n send({ id, result: items.map(() => null) })\n } else if (\n method === 'client/registerCapability' ||\n method === 'client/unregisterCapability' ||\n method === 'window/workDoneProgress/create' ||\n method === 'window/showMessageRequest'\n )\n send({ id, result: null })\n else send({ id, error: { code: -32601, message: `Unhandled method ${method}` } })\n }\n\n function receive(message: LspMessage) {\n if (message.method !== undefined) {\n if (message.id !== undefined && message.id !== null) answer(message)\n else for (const listener of listeners.get(message.method) ?? []) listener(message.params)\n return\n }\n const waiting = pending.get(message.id as number)\n if (!waiting) return\n pending.delete(message.id as number)\n if (message.error) waiting.reject(message.error)\n else waiting.resolve(message.result ?? null)\n }\n\n /** A transport given as it is, once closed: it can't be opened again. */\n let ended = false\n let endedWarned = false\n\n function connect() {\n if (ready) return ready\n if (ended) {\n if (!endedWarned)\n warn(\n \"the connection to the language server has ended and can't be used again; pass `transport` as a function to connect again\",\n )\n endedWarned = true\n return Promise.reject(CLOSED)\n }\n transport = typeof options.transport === 'function' ? options.transport() : options.transport\n const stopMessages = transport.onMessage(receive)\n const stopClose = transport.onClose?.(() => {\n warn('the connection to the language server closed')\n drop(false)\n })\n stopListening = () => {\n stopMessages()\n stopClose?.()\n }\n ready = rawRequest<{ capabilities?: Record<string, any> }>('initialize', {\n processId: null,\n clientInfo: { name: 'DouCodeEditor' },\n rootUri: options.rootUri ?? null,\n workspaceFolders: options.rootUri\n ? [\n {\n uri: options.rootUri,\n name: options.rootUri.replace(/\\/+$/, '').split('/').pop() || options.rootUri,\n },\n ]\n : null,\n capabilities: CLIENT_CAPABILITIES,\n initializationOptions: options.initializationOptions,\n }).then((result) => {\n capabilities = result?.capabilities ?? {}\n send({ method: 'initialized', params: {} })\n })\n ready.catch((error: unknown) => {\n // Closed before it answered, e.g. its editor unmounted at once: nothing went wrong.\n if (error !== CLOSED) warn('the language server failed to start', error)\n })\n return ready\n }\n\n /** Ends the connection: `shutdown` asks the server to stop first, otherwise it is already gone. */\n function drop(shutdown: boolean) {\n if (!transport) return\n const ending = transport\n const stop = stopListening\n const wasReady = ready\n transport = null\n stopListening = null\n ready = null\n capabilities = null\n generation++\n if (!owned) ended = true\n users = 0\n for (const waiting of pending.values()) waiting.reject(CLOSED)\n pending.clear()\n for (const detach of attached) detach()\n attached.clear()\n // Ask it to shut down, then exit; a server that doesn't answer is closed all the same.\n const finish = () => {\n ending.send({ jsonrpc: '2.0', method: 'exit' })\n stop?.()\n ending.close?.()\n }\n if (!shutdown) {\n stop?.()\n ending.close?.()\n return\n }\n if (!wasReady) return finish()\n const id = ++nextId\n const timer = setTimeout(finish, 1000)\n const stopShutdown = ending.onMessage((message) => {\n if (message.id !== id || message.method !== undefined) return\n clearTimeout(timer)\n stopShutdown()\n finish()\n })\n ending.send({ jsonrpc: '2.0', id, method: 'shutdown' })\n }\n\n const request = <T>(method: string, params?: unknown, signal?: AbortSignal) =>\n connect().then(() => rawRequest<T>(method, params, signal))\n const notify = (method: string, params?: unknown) => {\n void connect().then(\n () => send({ method, params }),\n () => {},\n )\n }\n\n const onNotification = (method: string, listener: (params: any) => void) => {\n let set = listeners.get(method)\n if (!set) listeners.set(method, (set = new Set()))\n set.add(listener)\n return () => set.delete(listener)\n }\n\n function acquire(detach: () => void) {\n users++\n attached.add(detach)\n const at = generation\n return {\n ready: connect(),\n release: () => {\n // That connection has ended already; this document no longer counts.\n if (at !== generation) return\n attached.delete(detach)\n users--\n if (users === 0 && owned) drop(true)\n },\n }\n }\n\n const client: LanguageClient = {\n document: (documentOptions) =>\n documentExtension(documentOptions, {\n acquire,\n send: (method, params) => send({ method, params }),\n request: rawRequest,\n onNotification,\n capabilities: () => capabilities,\n }),\n request,\n notify,\n onNotification,\n get capabilities() {\n return capabilities\n },\n close: () => drop(true),\n }\n return client\n}\n\ninterface Connection {\n /** Counts the document in, connecting if needed; `detach` runs when the connection ends before `release`. */\n acquire: (detach: () => void) => { ready: Promise<void>; release: () => void }\n /** Sends a notification on the open connection. */\n send: (method: string, params: unknown) => void\n request: <T>(method: string, params: unknown, signal?: AbortSignal) => Promise<T>\n onNotification: (method: string, listener: (params: any) => void) => () => void\n capabilities: () => Record<string, any> | null\n}\n\nconst SEVERITY: Record<number, CodeDiagnosticSeverity> = {\n 1: 'error',\n 2: 'warning',\n 3: 'info',\n 4: 'hint',\n}\n\nconst KIND: Record<number, CodeCompletionKind> = {\n 1: 'text',\n 2: 'method',\n 3: 'function',\n 4: 'method',\n 5: 'property',\n 6: 'variable',\n 7: 'class',\n 8: 'type',\n 9: 'module',\n 10: 'property',\n 11: 'constant',\n 12: 'constant',\n 13: 'type',\n 14: 'keyword',\n 15: 'snippet',\n 16: 'constant',\n 17: 'module',\n 18: 'variable',\n 19: 'module',\n 20: 'constant',\n 21: 'constant',\n 22: 'class',\n 23: 'property',\n 24: 'keyword',\n 25: 'type',\n}\n\n/** `textDocumentSync`: whether documents are opened and closed, and how changes go (0 none, 1 whole text, 2 changes only). */\nfunction syncOf(capabilities: Record<string, any> | null): { open: boolean; change: number } {\n const sync = capabilities?.textDocumentSync\n if (typeof sync === 'number') return { open: sync > 0, change: sync }\n if (sync && typeof sync === 'object') return { open: !!sync.openClose, change: sync.change ?? 0 }\n return { open: false, change: 0 }\n}\n\n/** A completion's or signature's `documentation`: a plain string is plain text there. */\nfunction documentation(value: string | Markup | null | undefined): string | (() => VNodeChild) {\n if (!value) return ''\n return lspMarkup(typeof value === 'string' ? { kind: 'plaintext', value } : value)\n}\n\n/**\n * An LSP snippet as the editor reads them: a choice `${1|a,b|}` becomes\n * field 1 holding its first option, and a variable (`$TM_FILENAME`,\n * `${TM_SELECTED_TEXT:default}`) its default, or nothing.\n */\nfunction fromLspSnippet(snippet: string): string {\n return (\n snippet\n .replace(/(?<!\\\\)\\$\\{(\\d+)\\|((?:[^|\\\\]|\\\\.)*)\\|\\}/g, (_, index: string, choices: string) => {\n const first = /^(?:[^,\\\\]|\\\\.)*/.exec(choices)![0].replace(/\\\\([,|\\\\])/g, '$1')\n return `\\${${index}:${first.replace(/[$}\\\\]/g, '\\\\$&')}}`\n })\n // Bare variables first: a braced one's default must not run into the name before it.\n .replace(/(?<!\\\\)\\$([A-Za-z_]\\w*)/g, '')\n .replace(\n /(?<!\\\\)\\$\\{([A-Za-z_]\\w*)(?::((?:[^}\\\\]|\\\\.)*))?\\}/g,\n (_, _name, fallback?: string) => fallback ?? '',\n )\n )\n}\n\n/** The edit's range: the plain one, or the `insert` side of an insert-or-replace edit. */\nfunction editRange(edit: any): LspRange | null {\n if (!edit) return null\n return edit.range ?? edit.insert ?? null\n}\n\n/** The first place a definition answer points to. */\nfunction firstLocation(found: any): LspLocation | null {\n const one = Array.isArray(found) ? found[0] : found\n if (!one) return null\n if (one.targetUri)\n return { uri: one.targetUri, range: one.targetSelectionRange ?? one.targetRange }\n return one.uri ? { uri: one.uri, range: one.range } : null\n}\n\nfunction toDiagnostics(doc: CodeText, items: any[]): CodeDiagnostic[] {\n return items.map((item) => {\n const code = item.code === undefined || item.code === null ? '' : String(item.code)\n const source = [item.source, code].filter(Boolean).join(' ')\n return {\n from: fromLspPosition(doc, item.range.start),\n to: fromLspPosition(doc, item.range.end),\n severity: SEVERITY[item.severity as number] ?? 'error',\n message: item.message,\n ...(source ? { source } : {}),\n }\n })\n}\n\n/** Whether the cursor touches a name, for the touch toolbar's button. */\nfunction onName(context: CodeExtensionContext) {\n const { ranges, main } = context.selection\n const range = ranges[main]!\n if (range.anchor !== range.head) return false\n const line = context.doc.lineAt(range.head)\n const col = range.head - line.from\n return /[\\w$]/.test(line.text[col] ?? '') || /[\\w$]/.test(line.text[col - 1] ?? '')\n}\n\nfunction documentExtension(\n options: LanguageDocumentOptions,\n connection: Connection,\n): LanguageDocument {\n const { uri, languageId } = options\n const textDocument = { uri }\n const name = `lsp:${uri}`\n let version = 0\n /** The document is open on the server: changes and requests go there. */\n let opened = false\n let mounted = false\n let editor: CodeExtensionContext | null = null\n /** The problems the server last pushed, and for which version. */\n let published: { version: number; items: any[] } | null = null\n /** Linters waiting for the problems of their version to be pushed. */\n let waiting: Array<() => void> = []\n /** For pulled problems: the server's id of the last answer, to get `unchanged` back. */\n let resultId: string | undefined\n let pulled: any[] = []\n let stopDiagnostics: (() => void) | null = null\n let opening: Promise<boolean> = Promise.resolve(false)\n let release: (() => void) | null = null\n\n const can = (capability: string) => opened && !!connection.capabilities()?.[capability]\n\n function wake() {\n const runs = waiting\n waiting = []\n for (const run of runs) run()\n }\n\n function lint(context: CodeExtensionContext) {\n const doc = context.doc\n return opening.then((open): Promise<CodeDiagnostic[] | null> | CodeDiagnostic[] | null => {\n if (!open || !opened || context.doc !== doc) return null\n if (can('diagnosticProvider')) {\n return connection\n .request<any>('textDocument/diagnostic', {\n textDocument,\n ...(resultId ? { previousResultId: resultId } : {}),\n })\n .then((report) => {\n if (report?.kind === 'full') pulled = report.items ?? []\n resultId = report?.resultId\n return toDiagnostics(doc, pulled)\n })\n .catch(() => null)\n }\n // Pushed problems: those of this version, once the server sends them.\n const at = version\n if (published?.version === at) return toDiagnostics(doc, published.items)\n // Waits for an earlier version give up now, so a server that never pushes doesn't pile them up.\n wake()\n return new Promise<CodeDiagnostic[] | null>((resolve) => {\n const run = () => {\n if (!mounted || !opened || version !== at) resolve(null)\n else if (published?.version === at) resolve(toDiagnostics(doc, published.items))\n else waiting.push(run)\n }\n waiting.push(run)\n })\n })\n }\n\n function onPublish(params: any) {\n if (params?.uri !== uri || !opened) return\n // Without a version, the newest problems are taken to be about the text now.\n published = { version: params.version ?? version, items: params.diagnostics ?? [] }\n if (waiting.length) wake()\n // Nobody is waiting: a second round for the same text, or problems found\n // again for other reasons. The linter runs again and takes them.\n else if (published.version === version) editor?.relint(name)\n }\n\n /** The connection ended under the document: it stays without the server until mounted again. */\n function detach() {\n opened = false\n opening = Promise.resolve(false)\n release = null\n wake()\n }\n\n function openDocument(context: CodeExtensionContext, ready: Promise<void>): Promise<boolean> {\n return ready.then(\n () => {\n if (!mounted || !release) return false\n version = 1\n opened = syncOf(connection.capabilities()).open\n if (opened)\n connection.send('textDocument/didOpen', {\n textDocument: { uri, languageId, version, text: context.doc.toString() },\n })\n return opened\n },\n () => false,\n )\n }\n\n function update(result: CodeTransactionResult) {\n if (!opened || result.changes.empty) return\n version++\n const sync = syncOf(connection.capabilities()).change\n if (sync === 0) return\n let contentChanges: unknown[]\n if (sync === 2) {\n // Each change is in the text before the step: going from the last\n // one back, the earlier positions still hold when each is applied.\n const before = result.before.doc\n const { changes } = result.changes\n contentChanges = []\n for (let i = changes.length - 1; i >= 0; i--) {\n const change = changes[i]!\n contentChanges.push({\n range: {\n start: toLspPosition(before, change.from),\n end: toLspPosition(before, change.to),\n },\n text: change.insert,\n })\n }\n } else contentChanges = [{ text: result.state.doc.toString() }]\n connection.send('textDocument/didChange', { textDocument: { uri, version }, contentChanges })\n }\n\n async function completion(\n request: Parameters<NonNullable<CodeExtension['completion']>>[0],\n context: CodeExtensionContext,\n ): Promise<CodeCompletionResult | null> {\n if (!(await opening) || !can('completionProvider') || request.signal.aborted) return null\n const doc = context.doc\n const triggers: string[] =\n connection.capabilities()?.completionProvider?.triggerCharacters ?? []\n const before = request.pos > 0 ? doc.slice(request.pos - 1, request.pos) : ''\n const triggerContext =\n !request.explicit && triggers.includes(before)\n ? { triggerKind: 2, triggerCharacter: before }\n : { triggerKind: 1 }\n let found: any\n try {\n found = await connection.request(\n 'textDocument/completion',\n { textDocument, position: toLspPosition(doc, request.pos), context: triggerContext },\n request.signal,\n )\n } catch {\n return null\n }\n const items: any[] = Array.isArray(found) ? found : (found?.items ?? [])\n if (!items.length) return null\n const defaults = Array.isArray(found) ? undefined : found?.itemDefaults\n let from = request.word.from\n const firstEdit = editRange(\n items.find((item) => item.textEdit)?.textEdit ?? defaults?.editRange,\n )\n if (firstEdit) from = Math.min(fromLspPosition(doc, firstEdit.start), request.pos)\n // The server's own order breaks ties among equally good matches.\n const order = items\n .map((item, index) => ({ key: String(item.sortText ?? item.label), index }))\n // oxlint-disable-next-line unicorn/no-array-sort -- sorts a fresh array\n .sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : a.index - b.index))\n const rank = new Map(order.map((entry, at) => [entry.index, at]))\n const entries = items.map((item, index): CodeCompletion => {\n const text: string = item.textEdit?.newText ?? item.insertText ?? item.label\n const format = item.insertTextFormat ?? defaults?.insertTextFormat\n const detail = [item.labelDetails?.detail, item.detail ?? item.labelDetails?.description]\n .filter(Boolean)\n .join(' ')\n const info = documentation(item.documentation)\n const option: CodeCompletion = {\n label: item.label,\n boost: (items.length - rank.get(index)!) / items.length + (item.preselect ? 5 : 0),\n }\n const kind = KIND[item.kind as number]\n if (kind) option.kind = kind\n if (detail) option.detail = detail\n if (info) option.info = info\n if (format === 2) option.snippet = fromLspSnippet(text)\n else if (text !== item.label) option.insert = text\n return option\n })\n return { from, options: entries }\n }\n\n async function hover(\n request: { pos: number; signal: AbortSignal },\n context: CodeExtensionContext,\n ): Promise<CodeHoverResult | null> {\n if (!(await opening) || !can('hoverProvider') || request.signal.aborted) return null\n const doc = context.doc\n let found: any\n try {\n found = await connection.request(\n 'textDocument/hover',\n { textDocument, position: toLspPosition(doc, request.pos) },\n request.signal,\n )\n } catch {\n return null\n }\n if (!found?.contents) return null\n const content = lspMarkup(found.contents)\n if (!content) return null\n const result: CodeHoverResult = { content }\n if (found.range) {\n result.from = fromLspPosition(doc, found.range.start)\n result.to = fromLspPosition(doc, found.range.end)\n }\n return result\n }\n\n async function signature(\n request: { pos: number; signal: AbortSignal },\n context: CodeExtensionContext,\n ): Promise<CodeSignatureResult | null> {\n if (!(await opening) || !can('signatureHelpProvider') || request.signal.aborted) return null\n let found: any\n try {\n found = await connection.request(\n 'textDocument/signatureHelp',\n { textDocument, position: toLspPosition(context.doc, request.pos) },\n request.signal,\n )\n } catch {\n return null\n }\n const one = found?.signatures?.[found.activeSignature ?? 0] ?? found?.signatures?.[0]\n if (!one) return null\n const label: string = one.label\n let searchFrom = 0\n const params: Array<[number, number]> = (one.parameters ?? []).map((param: any) => {\n if (Array.isArray(param.label)) return [param.label[0], param.label[1]] as [number, number]\n const at = label.indexOf(param.label, searchFrom)\n if (at < 0) return [0, 0] as [number, number]\n searchFrom = at + param.label.length\n return [at, searchFrom] as [number, number]\n })\n const result: CodeSignatureResult = {\n label,\n params,\n active: one.activeParameter ?? found.activeParameter ?? 0,\n }\n const info = documentation(one.documentation)\n if (info) result.info = info\n return result\n }\n\n const goToDefinition: CodeCommand = (target) => {\n const context = editor\n if (!context || !can('definitionProvider')) return false\n const doc = target.state.doc\n const head = target.state.selection.ranges[target.state.selection.main]!.head\n connection\n .request<any>('textDocument/definition', {\n textDocument,\n position: toLspPosition(doc, head),\n })\n .then((found) => {\n const location = firstLocation(found)\n if (!location || editor !== context) return\n if (location.uri !== uri) return options.openLocation?.(location)\n // Moved on meanwhile: the answer is about a text that is gone.\n if (context.doc !== doc) return\n context.select(fromLspPosition(doc, location.range.start))\n })\n .catch(() => {})\n return true\n }\n\n const extension = defineCodeExtension({\n name,\n get completionTriggers() {\n return opened ? (connection.capabilities()?.completionProvider?.triggerCharacters ?? []) : []\n },\n keymap: () => ({ F12: goToDefinition }),\n menu: (context) =>\n can('definitionProvider') && onName(context)\n ? [{ label: context.messages.goToDefinition, run: (ctx) => void ctx.run(goToDefinition) }]\n : [],\n update,\n lint,\n completion,\n hover,\n signature,\n setup(context) {\n if (mounted)\n warn(\n `the document ${uri} is used by two editors at once; give each its own client.document()`,\n )\n mounted = true\n editor = context\n published = null\n resultId = undefined\n pulled = []\n stopDiagnostics = connection.onNotification('textDocument/publishDiagnostics', onPublish)\n const session = connection.acquire(detach)\n release = session.release\n opening = openDocument(context, session.ready)\n return () => {\n mounted = false\n stopDiagnostics?.()\n stopDiagnostics = null\n if (opened) connection.send('textDocument/didClose', { textDocument })\n opened = false\n opening = Promise.resolve(false)\n wake()\n editor = null\n release?.()\n release = null\n }\n },\n })\n return Object.assign(extension, { goToDefinition })\n}\n"],"mappings":";;;AAqHA,IAAM,QAAQ,SAAiB,UAAoB;CACjD,IAAA,QAAA,IAAA,aAA6B,cAAc;CAC3C,QAAQ,KAAK,kBAAkB,WAAW,GAAI,UAAU,KAAA,IAAY,CAAC,IAAI,CAAC,KAAK,CAAE;AACnF;;;;;;;AAQA,SAAgB,gBAAgB,QAA8B;CAC5D,IAAI,WAAW;CACf,IAAI,SAAS;CACb,OAAO,iBAAiB,iBAAkB,WAAW,MAAO,EAAE,MAAM,KAAK,CAAC;CAC1E,OAAO;EAEL,OAAO,YAAY,OAAO,YAAY,OAAO;EAC7C,YAAY,aAAa;GACvB,MAAM,UAAU,UAAwB,SAAS,MAAM,IAAkB;GACzE,OAAO,iBAAiB,WAAW,MAAM;GACzC,aAAa,OAAO,oBAAoB,WAAW,MAAM;EAC3D;EACA,aAAa,OAAO,UAAU;EAC9B,UAAU,aAAa;GACrB,MAAM,UAAU,UAAiB;IAC/B,IAAI,CAAC,UAAU,OAAO,SAAS;IAC/B,IAAI,CAAC,QAAQ,KAAK,wDAAwD,KAAK;IAC/E,SAAS;GACX;GACA,OAAO,iBAAiB,SAAS,MAAM;GACvC,aAAa,OAAO,oBAAoB,SAAS,MAAM;EACzD;CACF;AACF;;;;;AAMA,SAAgB,gBAAgB,QAAiC;CAC/D,MAAM,UAAoB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.!|~<>])/.source,
|
|
5
|
+
/`([^`]+)`/.source,
|
|
6
|
+
/\[([^\]]+)\]\(((?:[^()\s]|\([^()\s]*\))+)(?:\s+"[^"]*")?\)/.source,
|
|
7
|
+
/<(https?:\/\/[^\s>]+)>/.source,
|
|
8
|
+
/\*\*(.+?)\*\*|__(.+?)__/.source,
|
|
9
|
+
/\*([^*\s](?:[^*]*[^*\s])?)\*|(?<![\w])_([^_\s](?:[^_]*[^_\s])?)_(?![\w])/.source
|
|
10
|
+
].join("|"), "g");
|
|
11
|
+
var SAFE_LINK = /^https?:\/\//i;
|
|
12
|
+
function link(href, children) {
|
|
13
|
+
if (!SAFE_LINK.test(href)) return children;
|
|
14
|
+
return h("a", {
|
|
15
|
+
class: "dou-code-lsp-markup__link",
|
|
16
|
+
href,
|
|
17
|
+
target: "_blank",
|
|
18
|
+
rel: "noopener noreferrer"
|
|
19
|
+
}, children);
|
|
20
|
+
}
|
|
21
|
+
/** Inline Markdown: code, links (web addresses only), bold, italic and escapes; nothing is read as HTML. */
|
|
22
|
+
function inline(text) {
|
|
23
|
+
const out = [];
|
|
24
|
+
let at = 0;
|
|
25
|
+
for (const match of text.matchAll(INLINE)) {
|
|
26
|
+
if (match.index > at) out.push(text.slice(at, match.index));
|
|
27
|
+
const [, escaped, code, label, href, address, bold1, bold2, italic1, italic2] = match;
|
|
28
|
+
if (escaped !== void 0) out.push(escaped);
|
|
29
|
+
else if (code !== void 0) out.push(h("code", { class: "dou-code-lsp-markup__inline" }, code));
|
|
30
|
+
else if (label !== void 0) out.push(link(href, inline(label)));
|
|
31
|
+
else if (address !== void 0) out.push(link(address, [address]));
|
|
32
|
+
else if (bold1 !== void 0 || bold2 !== void 0) out.push(h("strong", inline(bold1 ?? bold2)));
|
|
33
|
+
else out.push(h("em", inline(italic1 ?? italic2)));
|
|
34
|
+
at = match.index + match[0].length;
|
|
35
|
+
}
|
|
36
|
+
if (at < text.length) out.push(text.slice(at));
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
/** Markdown text without code fences, as paragraphs, lists, rules and headings (shown in bold). */
|
|
40
|
+
function textBlocks(text, out) {
|
|
41
|
+
let paragraph = [];
|
|
42
|
+
let list = null;
|
|
43
|
+
const end = () => {
|
|
44
|
+
if (paragraph.length) out.push({
|
|
45
|
+
type: "text",
|
|
46
|
+
text: paragraph.join("\n")
|
|
47
|
+
});
|
|
48
|
+
paragraph = [];
|
|
49
|
+
if (list) out.push({
|
|
50
|
+
type: "list",
|
|
51
|
+
...list
|
|
52
|
+
});
|
|
53
|
+
list = null;
|
|
54
|
+
};
|
|
55
|
+
for (const line of text.split("\n")) {
|
|
56
|
+
if (!line.trim()) {
|
|
57
|
+
end();
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (/^\s{0,3}([-*_])(?:\s*\1){2,}\s*$/.test(line)) {
|
|
61
|
+
end();
|
|
62
|
+
out.push({ type: "rule" });
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const heading = /^\s{0,3}#{1,6}\s+(.*?)\s*#*\s*$/.exec(line);
|
|
66
|
+
if (heading) {
|
|
67
|
+
end();
|
|
68
|
+
out.push({
|
|
69
|
+
type: "text",
|
|
70
|
+
text: `**${heading[1]}**`
|
|
71
|
+
});
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const item = /^\s{0,3}(?:([-*+])|(\d+)[.)])\s+(.*)$/.exec(line);
|
|
75
|
+
if (item) {
|
|
76
|
+
const ordered = item[2] !== void 0;
|
|
77
|
+
if (paragraph.length || list && list.ordered !== ordered) end();
|
|
78
|
+
list ??= {
|
|
79
|
+
ordered,
|
|
80
|
+
items: []
|
|
81
|
+
};
|
|
82
|
+
list.items.push(item[3]);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (list && /^\s+\S/.test(line)) list.items[list.items.length - 1] += ` ${line.trim()}`;
|
|
86
|
+
else {
|
|
87
|
+
if (list) end();
|
|
88
|
+
paragraph.push(line.trim());
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
end();
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Documentation for the hover box, completion info and parameter hints:
|
|
95
|
+
* Markdown's code blocks, lists, rules, headings, links, bold, italic and
|
|
96
|
+
* code are drawn; plain text stays as it is. Nothing is read as HTML.
|
|
97
|
+
* Returns plain text when there is nothing to draw.
|
|
98
|
+
*/
|
|
99
|
+
function lspMarkup(markup) {
|
|
100
|
+
const list = Array.isArray(markup) ? markup : [markup];
|
|
101
|
+
const blocks = [];
|
|
102
|
+
for (const part of list) {
|
|
103
|
+
if (typeof part === "object" && part.language !== void 0) {
|
|
104
|
+
if (part.value.trim()) blocks.push({
|
|
105
|
+
type: "code",
|
|
106
|
+
text: part.value.replace(/\n$/, "")
|
|
107
|
+
});
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const value = typeof part === "string" ? part : part.value;
|
|
111
|
+
if (typeof part === "object" && part.kind === "plaintext") {
|
|
112
|
+
if (value.trim()) blocks.push({
|
|
113
|
+
type: "plain",
|
|
114
|
+
text: value.trim()
|
|
115
|
+
});
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
value.split(/^```[^\n]*\n([\s\S]*?)^```[ \t]*$/m).forEach((piece, index) => {
|
|
119
|
+
if (index % 2 === 0) textBlocks(piece, blocks);
|
|
120
|
+
else if (piece.trim()) blocks.push({
|
|
121
|
+
type: "code",
|
|
122
|
+
text: piece.replace(/\n$/, "")
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
if (!blocks.length) return "";
|
|
127
|
+
const only = blocks.length === 1 ? blocks[0] : null;
|
|
128
|
+
if (only?.type === "plain") return only.text;
|
|
129
|
+
if (only?.type === "text" && !/[\\`*_[<]/.test(only.text)) return only.text;
|
|
130
|
+
return () => h("div", { class: "dou-code-lsp-markup" }, blocks.map((block) => {
|
|
131
|
+
if (block.type === "code") return h("pre", { class: "dou-code-lsp-markup__code" }, block.text);
|
|
132
|
+
if (block.type === "rule") return h("hr", { class: "dou-code-lsp-markup__rule" });
|
|
133
|
+
if (block.type === "list") return h(block.ordered ? "ol" : "ul", { class: "dou-code-lsp-markup__list" }, block.items.map((item) => h("li", inline(item))));
|
|
134
|
+
return h("p", { class: "dou-code-lsp-markup__text" }, block.type === "plain" ? block.text : inline(block.text));
|
|
135
|
+
}));
|
|
136
|
+
}
|
|
137
|
+
export { lspMarkup };
|
|
138
|
+
|
|
139
|
+
//# sourceMappingURL=markup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markup.js","names":[],"sources":["../../src/lsp/markup.ts"],"sourcesContent":["import { h, type VNodeChild } from 'vue'\n\n/** Documentation as a language server sends it: Markdown or plain text, or a code block (`MarkedString`). */\nexport type Markup = string | { kind?: string; language?: string; value: string }\n\nconst INLINE = new RegExp(\n [\n /\\\\([\\\\`*_{}[\\]()#+\\-.!|~<>])/.source, // 1: an escaped mark\n /`([^`]+)`/.source, // 2: code\n /\\[([^\\]]+)\\]\\(((?:[^()\\s]|\\([^()\\s]*\\))+)(?:\\s+\"[^\"]*\")?\\)/.source, // 3, 4: a link\n /<(https?:\\/\\/[^\\s>]+)>/.source, // 5: an address in angle brackets\n /\\*\\*(.+?)\\*\\*|__(.+?)__/.source, // 6, 7: bold\n /\\*([^*\\s](?:[^*]*[^*\\s])?)\\*|(?<![\\w])_([^_\\s](?:[^_]*[^_\\s])?)_(?![\\w])/.source, // 8, 9: italic\n ].join('|'),\n 'g',\n)\n\nconst SAFE_LINK = /^https?:\\/\\//i\n\nfunction link(href: string, children: VNodeChild[]): VNodeChild {\n // Only web addresses become links; anything else (`javascript:`, file paths) stays text.\n if (!SAFE_LINK.test(href)) return children\n return h(\n 'a',\n { class: 'dou-code-lsp-markup__link', href, target: '_blank', rel: 'noopener noreferrer' },\n children,\n )\n}\n\n/** Inline Markdown: code, links (web addresses only), bold, italic and escapes; nothing is read as HTML. */\nfunction inline(text: string): VNodeChild[] {\n const out: VNodeChild[] = []\n let at = 0\n for (const match of text.matchAll(INLINE)) {\n if (match.index > at) out.push(text.slice(at, match.index))\n const [, escaped, code, label, href, address, bold1, bold2, italic1, italic2] = match\n if (escaped !== undefined) out.push(escaped)\n else if (code !== undefined) out.push(h('code', { class: 'dou-code-lsp-markup__inline' }, code))\n else if (label !== undefined) out.push(link(href!, inline(label)))\n else if (address !== undefined) out.push(link(address, [address]))\n else if (bold1 !== undefined || bold2 !== undefined)\n out.push(h('strong', inline(bold1 ?? bold2!)))\n else out.push(h('em', inline(italic1 ?? italic2!)))\n at = match.index + match[0].length\n }\n if (at < text.length) out.push(text.slice(at))\n return out\n}\n\ntype Block =\n | { type: 'code'; text: string }\n | { type: 'plain'; text: string }\n | { type: 'text'; text: string }\n | { type: 'list'; ordered: boolean; items: string[] }\n | { type: 'rule' }\n\n/** Markdown text without code fences, as paragraphs, lists, rules and headings (shown in bold). */\nfunction textBlocks(text: string, out: Block[]) {\n let paragraph: string[] = []\n let list: { ordered: boolean; items: string[] } | null = null\n const end = () => {\n if (paragraph.length) out.push({ type: 'text', text: paragraph.join('\\n') })\n paragraph = []\n if (list) out.push({ type: 'list', ...list })\n list = null\n }\n for (const line of text.split('\\n')) {\n if (!line.trim()) {\n end()\n continue\n }\n if (/^\\s{0,3}([-*_])(?:\\s*\\1){2,}\\s*$/.test(line)) {\n end()\n out.push({ type: 'rule' })\n continue\n }\n const heading = /^\\s{0,3}#{1,6}\\s+(.*?)\\s*#*\\s*$/.exec(line)\n if (heading) {\n end()\n out.push({ type: 'text', text: `**${heading[1]}**` })\n continue\n }\n const item = /^\\s{0,3}(?:([-*+])|(\\d+)[.)])\\s+(.*)$/.exec(line)\n if (item) {\n const ordered = item[2] !== undefined\n if (paragraph.length || (list && list.ordered !== ordered)) end()\n list ??= { ordered, items: [] }\n list.items.push(item[3]!)\n continue\n }\n // A line under a list item goes on with it.\n if (list && /^\\s+\\S/.test(line)) list.items[list.items.length - 1] += ` ${line.trim()}`\n else {\n if (list) end()\n paragraph.push(line.trim())\n }\n }\n end()\n}\n\n/**\n * Documentation for the hover box, completion info and parameter hints:\n * Markdown's code blocks, lists, rules, headings, links, bold, italic and\n * code are drawn; plain text stays as it is. Nothing is read as HTML.\n * Returns plain text when there is nothing to draw.\n */\nexport function lspMarkup(markup: Markup | Markup[]): string | (() => VNodeChild) {\n const list = Array.isArray(markup) ? markup : [markup]\n const blocks: Block[] = []\n for (const part of list) {\n if (typeof part === 'object' && part.language !== undefined) {\n if (part.value.trim()) blocks.push({ type: 'code', text: part.value.replace(/\\n$/, '') })\n continue\n }\n const value = typeof part === 'string' ? part : part.value\n if (typeof part === 'object' && part.kind === 'plaintext') {\n if (value.trim()) blocks.push({ type: 'plain', text: value.trim() })\n continue\n }\n value.split(/^```[^\\n]*\\n([\\s\\S]*?)^```[ \\t]*$/m).forEach((piece, index) => {\n if (index % 2 === 0) textBlocks(piece, blocks)\n else if (piece.trim()) blocks.push({ type: 'code', text: piece.replace(/\\n$/, '') })\n })\n }\n if (!blocks.length) return ''\n const only = blocks.length === 1 ? blocks[0]! : null\n if (only?.type === 'plain') return only.text\n // One paragraph with no marks in it reads the same as text.\n if (only?.type === 'text' && !/[\\\\`*_[<]/.test(only.text)) return only.text\n return () =>\n h(\n 'div',\n { class: 'dou-code-lsp-markup' },\n blocks.map((block) => {\n if (block.type === 'code')\n return h('pre', { class: 'dou-code-lsp-markup__code' }, block.text)\n if (block.type === 'rule') return h('hr', { class: 'dou-code-lsp-markup__rule' })\n if (block.type === 'list')\n return h(\n block.ordered ? 'ol' : 'ul',\n { class: 'dou-code-lsp-markup__list' },\n block.items.map((item) => h('li', inline(item))),\n )\n return h(\n 'p',\n { class: 'dou-code-lsp-markup__text' },\n block.type === 'plain' ? block.text : inline(block.text),\n )\n }),\n )\n}\n"],"mappings":";;AAKA,IAAM,SAAS,IAAI,OACjB;CACE,+BAA+B;CAC/B,YAAY;CACZ,6DAA6D;CAC7D,yBAAyB;CACzB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0,0 +1,14 @@
|
|
|
1
|
+
import { defineComponent } from "vue";
|
|
2
|
+
// src/render-part.ts
|
|
3
|
+
/** Draws what a render function returns: panels and widgets given by extensions. */
|
|
4
|
+
var render_part_default = defineComponent({
|
|
5
|
+
name: "DouCodeRenderPart",
|
|
6
|
+
props: { render: {
|
|
7
|
+
type: Function,
|
|
8
|
+
required: true
|
|
9
|
+
} },
|
|
10
|
+
setup: (props) => () => props.render()
|
|
11
|
+
});
|
|
12
|
+
export { render_part_default as default };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=render-part.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-part.js","names":[],"sources":["../src/render-part.ts"],"sourcesContent":["import { type PropType, type VNodeChild, defineComponent } from 'vue'\n\n/** Draws what a render function returns: panels and widgets given by extensions. */\nexport default defineComponent({\n name: 'DouCodeRenderPart',\n props: { render: { type: Function as PropType<() => VNodeChild>, required: true } },\n setup: (props) => () => props.render(),\n})\n"],"mappings":";;;AAGA,IAAA,sBAAe,gBAAgB;CAC7B,MAAM;CACN,OAAO,EAAE,QAAQ;EAAE,MAAM;EAAwC,UAAU;CAAK,EAAE;CAClF,QAAQ,gBAAgB,MAAM,OAAO;AACvC,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { defineCodeLanguage } from "../language/language.js";
|
|
2
|
+
// src/shiki/index.ts
|
|
3
|
+
/** Scope prefixes and the kind each is drawn as; the first that matches a token's scopes, from the innermost scope out, wins. */
|
|
4
|
+
var SCOPES = [
|
|
5
|
+
["comment", "comment"],
|
|
6
|
+
["punctuation.definition.comment", "comment"],
|
|
7
|
+
["string.regexp", "string"],
|
|
8
|
+
["constant.character.escape", "string"],
|
|
9
|
+
["punctuation.definition.string", "string"],
|
|
10
|
+
["string", "string"],
|
|
11
|
+
["constant.numeric", "number"],
|
|
12
|
+
["constant.language", "keyword"],
|
|
13
|
+
["constant.other.color", "number"],
|
|
14
|
+
["keyword.operator", "operator"],
|
|
15
|
+
["storage.type.function.arrow", "operator"],
|
|
16
|
+
["keyword", "keyword"],
|
|
17
|
+
["storage", "keyword"],
|
|
18
|
+
["entity.name.function", "function"],
|
|
19
|
+
["support.function", "function"],
|
|
20
|
+
["meta.function-call", "function"],
|
|
21
|
+
["entity.name.tag", "tag"],
|
|
22
|
+
["entity.other.attribute-name", "attribute"],
|
|
23
|
+
["entity.name.type", "type"],
|
|
24
|
+
["entity.name.class", "type"],
|
|
25
|
+
["entity.other.inherited-class", "type"],
|
|
26
|
+
["support.type.property-name", "property"],
|
|
27
|
+
["support.type", "type"],
|
|
28
|
+
["support.class", "type"],
|
|
29
|
+
["variable.other.property", "property"],
|
|
30
|
+
["variable.other.object.property", "property"],
|
|
31
|
+
["support.variable.property", "property"],
|
|
32
|
+
["meta.object-literal.key", "property"],
|
|
33
|
+
["variable.language", "keyword"],
|
|
34
|
+
["variable", "variable"],
|
|
35
|
+
["entity.name", "variable"],
|
|
36
|
+
["markup.heading", "heading"],
|
|
37
|
+
["markup.bold", "strong"],
|
|
38
|
+
["markup.italic", "emphasis"],
|
|
39
|
+
["markup.underline.link", "link"],
|
|
40
|
+
["markup.inline.raw", "string"],
|
|
41
|
+
["meta.preprocessor", "meta"],
|
|
42
|
+
["meta.decorator", "meta"],
|
|
43
|
+
["meta.annotation", "meta"],
|
|
44
|
+
["invalid", "invalid"],
|
|
45
|
+
["punctuation", "punctuation"]
|
|
46
|
+
];
|
|
47
|
+
var matches = (scope, prefix) => scope === prefix || scope.startsWith(prefix) && scope[prefix.length] === ".";
|
|
48
|
+
/** The kind a token with these scopes (outermost first, as Shiki gives them) is drawn as. */
|
|
49
|
+
function tokenTypeOfScopes(scopes) {
|
|
50
|
+
for (let i = scopes.length - 1; i > 0; i--) {
|
|
51
|
+
const scope = scopes[i];
|
|
52
|
+
for (const [prefix, type] of SCOPES) if (matches(scope, prefix)) return type;
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
/** How long one line may take to read, in milliseconds, so a huge line doesn't hold up typing. */
|
|
57
|
+
var TIME_LIMIT = 50;
|
|
58
|
+
/**
|
|
59
|
+
* Lines up to this long are read to the end even past the time limit. The
|
|
60
|
+
* first lines a grammar reads also build its patterns, which on a busy
|
|
61
|
+
* machine can take longer than the limit; stopping there would cut a block
|
|
62
|
+
* comment or string in two and color the lines after it wrongly.
|
|
63
|
+
*/
|
|
64
|
+
var ALWAYS_WHOLE = 2e3;
|
|
65
|
+
/** Reads a line within the time limit, and to its end when it is not too long. */
|
|
66
|
+
function readLine(grammar, text, stack) {
|
|
67
|
+
const result = grammar.tokenizeLine(text, stack, TIME_LIMIT);
|
|
68
|
+
return result.stoppedEarly && text.length <= ALWAYS_WHOLE ? grammar.tokenizeLine(text, stack, 0) : result;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Turns a language loaded into a Shiki highlighter into one the editor
|
|
72
|
+
* reads. Shiki's grammar does the reading; its scopes are drawn with the
|
|
73
|
+
* editor's own syntax colors, so the theme and dark mode apply as they do
|
|
74
|
+
* to the built-in languages.
|
|
75
|
+
*
|
|
76
|
+
* ```ts
|
|
77
|
+
* const highlighter = await createHighlighter({ langs: ['rust'], themes: [] })
|
|
78
|
+
* const rust = shikiLanguage(highlighter, 'rust', { comment: { line: '//' } })
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
function shikiLanguage(highlighter, language, options = {}) {
|
|
82
|
+
const grammar = highlighter.getLanguage(language);
|
|
83
|
+
const typeOf = options.tokenType ? (scopes) => {
|
|
84
|
+
const own = options.tokenType(scopes);
|
|
85
|
+
return own === void 0 ? tokenTypeOfScopes(scopes) : own;
|
|
86
|
+
} : tokenTypeOfScopes;
|
|
87
|
+
return defineCodeLanguage({
|
|
88
|
+
name: options.name ?? language,
|
|
89
|
+
aliases: options.aliases,
|
|
90
|
+
startState: () => ({
|
|
91
|
+
stack: null,
|
|
92
|
+
line: null
|
|
93
|
+
}),
|
|
94
|
+
copyState: (state) => ({
|
|
95
|
+
stack: state.stack,
|
|
96
|
+
line: state.line
|
|
97
|
+
}),
|
|
98
|
+
sameState: (a, b) => a.stack === b.stack || !!a.stack && !!b.stack && a.stack.equals(b.stack),
|
|
99
|
+
token(stream, state) {
|
|
100
|
+
let line = state.line;
|
|
101
|
+
if (!line || line.text !== stream.string || stream.pos < line.base) {
|
|
102
|
+
const text = stream.string.slice(stream.pos, stream.end);
|
|
103
|
+
const result = readLine(grammar, text, state.stack);
|
|
104
|
+
const ends = [];
|
|
105
|
+
const types = [];
|
|
106
|
+
for (const token of result.tokens) {
|
|
107
|
+
ends.push(stream.pos + Math.min(token.endIndex, text.length));
|
|
108
|
+
types.push(typeOf(token.scopes));
|
|
109
|
+
}
|
|
110
|
+
line = {
|
|
111
|
+
text: stream.string,
|
|
112
|
+
base: stream.pos,
|
|
113
|
+
ends,
|
|
114
|
+
types
|
|
115
|
+
};
|
|
116
|
+
state.stack = result.ruleStack;
|
|
117
|
+
state.line = line;
|
|
118
|
+
}
|
|
119
|
+
for (let i = 0; i < line.ends.length; i++) if (line.ends[i] > stream.pos) {
|
|
120
|
+
stream.pos = Math.min(line.ends[i], stream.end);
|
|
121
|
+
if (stream.pos >= stream.end) state.line = null;
|
|
122
|
+
return line.types[i];
|
|
123
|
+
}
|
|
124
|
+
stream.skipToEnd();
|
|
125
|
+
state.line = null;
|
|
126
|
+
return null;
|
|
127
|
+
},
|
|
128
|
+
blankLine(state) {
|
|
129
|
+
state.stack = readLine(grammar, "", state.stack).ruleStack;
|
|
130
|
+
state.line = null;
|
|
131
|
+
},
|
|
132
|
+
comment: options.comment,
|
|
133
|
+
brackets: options.brackets,
|
|
134
|
+
autoClose: options.autoClose,
|
|
135
|
+
indentAfter: options.indentAfter
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
export { shikiLanguage, tokenTypeOfScopes };
|
|
139
|
+
|
|
140
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/shiki/index.ts"],"sourcesContent":["import { type CodeLanguage, type CodeTokenType, defineCodeLanguage } from '../language/language'\n\n/** The part of a TextMate rule stack the editor uses: Shiki's `StateStack`. */\nexport interface ShikiStateStack {\n equals(other: ShikiStateStack): boolean\n}\n\n/** What the editor needs of a Shiki highlighter (`createHighlighter()` from `shiki`). */\nexport interface ShikiHighlighterLike {\n getLanguage(name: string): {\n tokenizeLine(\n line: string,\n state: ShikiStateStack | null,\n timeLimit?: number,\n ): {\n tokens: Array<{ startIndex: number; endIndex: number; scopes: string[] }>\n ruleStack: ShikiStateStack\n /** The time limit ran out before the end of the line. */\n stoppedEarly?: boolean\n }\n }\n}\n\nexport interface ShikiLanguageOptions {\n /** The name the editor and code blocks know it by; defaults to the Shiki language's. */\n name?: string\n aliases?: string[]\n /** How the language writes comments, for toggling them; Shiki doesn't say. */\n comment?: { line?: string; block?: [open: string, close: string] }\n brackets?: string\n autoClose?: string\n indentAfter?: RegExp\n /**\n * The token kind (syntax color) for a token's scopes, outermost first;\n * return `undefined` to use the built-in mapping (`tokenTypeOfScopes`).\n */\n tokenType?: (scopes: readonly string[]) => CodeTokenType | null | undefined\n}\n\nexport interface ShikiState {\n /** The grammar's state at the start of the line being read, or after the last line. */\n stack: ShikiStateStack | null\n /** The tokens of the line being read; positions from `base`. */\n line: { text: string; base: number; ends: number[]; types: Array<CodeTokenType | null> } | null\n}\n\n/** Scope prefixes and the kind each is drawn as; the first that matches a token's scopes, from the innermost scope out, wins. */\nconst SCOPES: Array<[prefix: string, type: CodeTokenType]> = [\n ['comment', 'comment'],\n ['punctuation.definition.comment', 'comment'],\n ['string.regexp', 'string'],\n ['constant.character.escape', 'string'],\n ['punctuation.definition.string', 'string'],\n ['string', 'string'],\n ['constant.numeric', 'number'],\n ['constant.language', 'keyword'],\n ['constant.other.color', 'number'],\n ['keyword.operator', 'operator'],\n ['storage.type.function.arrow', 'operator'],\n ['keyword', 'keyword'],\n ['storage', 'keyword'],\n ['entity.name.function', 'function'],\n ['support.function', 'function'],\n ['meta.function-call', 'function'],\n ['entity.name.tag', 'tag'],\n ['entity.other.attribute-name', 'attribute'],\n ['entity.name.type', 'type'],\n ['entity.name.class', 'type'],\n ['entity.other.inherited-class', 'type'],\n ['support.type.property-name', 'property'],\n ['support.type', 'type'],\n ['support.class', 'type'],\n ['variable.other.property', 'property'],\n ['variable.other.object.property', 'property'],\n ['support.variable.property', 'property'],\n ['meta.object-literal.key', 'property'],\n ['variable.language', 'keyword'],\n ['variable', 'variable'],\n ['entity.name', 'variable'],\n ['markup.heading', 'heading'],\n ['markup.bold', 'strong'],\n ['markup.italic', 'emphasis'],\n ['markup.underline.link', 'link'],\n ['markup.inline.raw', 'string'],\n ['meta.preprocessor', 'meta'],\n ['meta.decorator', 'meta'],\n ['meta.annotation', 'meta'],\n ['invalid', 'invalid'],\n ['punctuation', 'punctuation'],\n]\n\nconst matches = (scope: string, prefix: string) =>\n scope === prefix || (scope.startsWith(prefix) && scope[prefix.length] === '.')\n\n/** The kind a token with these scopes (outermost first, as Shiki gives them) is drawn as. */\nexport function tokenTypeOfScopes(scopes: readonly string[]): CodeTokenType | null {\n for (let i = scopes.length - 1; i > 0; i--) {\n const scope = scopes[i]!\n for (const [prefix, type] of SCOPES) if (matches(scope, prefix)) return type\n }\n return null\n}\n\n/** How long one line may take to read, in milliseconds, so a huge line doesn't hold up typing. */\nconst TIME_LIMIT = 50\n/**\n * Lines up to this long are read to the end even past the time limit. The\n * first lines a grammar reads also build its patterns, which on a busy\n * machine can take longer than the limit; stopping there would cut a block\n * comment or string in two and color the lines after it wrongly.\n */\nconst ALWAYS_WHOLE = 2000\n\ntype ShikiGrammar = ReturnType<ShikiHighlighterLike['getLanguage']>\n/** Reads a line within the time limit, and to its end when it is not too long. */\nfunction readLine(grammar: ShikiGrammar, text: string, stack: ShikiStateStack | null) {\n const result = grammar.tokenizeLine(text, stack, TIME_LIMIT)\n return result.stoppedEarly && text.length <= ALWAYS_WHOLE\n ? grammar.tokenizeLine(text, stack, 0)\n : result\n}\n\n/**\n * Turns a language loaded into a Shiki highlighter into one the editor\n * reads. Shiki's grammar does the reading; its scopes are drawn with the\n * editor's own syntax colors, so the theme and dark mode apply as they do\n * to the built-in languages.\n *\n * ```ts\n * const highlighter = await createHighlighter({ langs: ['rust'], themes: [] })\n * const rust = shikiLanguage(highlighter, 'rust', { comment: { line: '//' } })\n * ```\n */\nexport function shikiLanguage(\n highlighter: ShikiHighlighterLike,\n language: string,\n options: ShikiLanguageOptions = {},\n): CodeLanguage<ShikiState> {\n const grammar = highlighter.getLanguage(language)\n const typeOf = options.tokenType\n ? (scopes: readonly string[]) => {\n const own = options.tokenType!(scopes)\n return own === undefined ? tokenTypeOfScopes(scopes) : own\n }\n : tokenTypeOfScopes\n return defineCodeLanguage<ShikiState>({\n name: options.name ?? language,\n aliases: options.aliases,\n startState: () => ({ stack: null, line: null }),\n // the stack never changes once made: copies share it\n copyState: (state) => ({ stack: state.stack, line: state.line }),\n sameState: (a, b) => a.stack === b.stack || (!!a.stack && !!b.stack && a.stack.equals(b.stack)),\n token(stream, state) {\n let line = state.line\n if (!line || line.text !== stream.string || stream.pos < line.base) {\n // a new line: read it whole, and keep the state after it\n const text = stream.string.slice(stream.pos, stream.end)\n const result = readLine(grammar, text, state.stack)\n const ends: number[] = []\n const types: Array<CodeTokenType | null> = []\n for (const token of result.tokens) {\n ends.push(stream.pos + Math.min(token.endIndex, text.length))\n types.push(typeOf(token.scopes))\n }\n line = { text: stream.string, base: stream.pos, ends, types }\n state.stack = result.ruleStack\n state.line = line\n }\n for (let i = 0; i < line.ends.length; i++)\n if (line.ends[i]! > stream.pos) {\n stream.pos = Math.min(line.ends[i]!, stream.end)\n // the line is read: the next one is read afresh, even with the same text\n if (stream.pos >= stream.end) state.line = null\n return line.types[i]!\n }\n stream.skipToEnd()\n state.line = null\n return null\n },\n blankLine(state) {\n state.stack = readLine(grammar, '', state.stack).ruleStack\n state.line = null\n },\n comment: options.comment,\n brackets: options.brackets,\n autoClose: options.autoClose,\n indentAfter: options.indentAfter,\n })\n}\n"],"mappings":";;;AA+CA,IAAM,SAAuD;CAC3D,CAAC,WAAW,SAAS;CACrB,CAAC,kCAAkC,SAAS;CAC5C,CAAC,iBAAiB,QAAQ;CAC1B,CAAC,6BAA6B,QAAQ;CACtC,CAAC,iCAAiC,QAAQ;CAC1C,CAAC,UAAU,QAAQ;CACnB,CAAC,oBAAoB,QAAQ;CAC7B,CAAC,qBAAqB,SAAS;CAC/B,CAAC,wBAAwB,QAAQ;CACjC,CAAC,oBAAoB,UAAU;CAC/B,CAAC,+BAA+B,UAAU;CAC1C,CAAC,WAAW,SAAS;CACrB,CAAC,WAAW,SAAS;CACrB,CAAC,wBAAwB,UAAU;CACnC,CAAC,oBAAoB,UAAU;CAC/B,CAAC,sBAAsB,UAAU;CACjC,CAAC,mBAAmB,KAAK;CACzB,CAAC,+BAA+B,WAAW;CAC3C,CAAC,oBAAoB,MAAM;CAC3B,CAAC,qBAAqB,MAAM;CAC5B,CAAC,gCAAgC,MAAM;CACvC,CAAC,8BAA8B,UAAU;CACzC,CAAC,gBAAgB,MAAM;CACvB,CAAC,iBAAiB,MAAM;CACxB,CAAC,2BAA2B,UAAU;CACtC,CAAC,kCAAkC,UAAU;CAC7C,CAAC,6BAA6B,UAAU;CACxC,CAAC,2BAA2B,UAAU;CACtC,CAAC,qBAAqB,SAAS;CAC/B,CAAC,YAAY,UAAU;CACvB,CAAC,eAAe,UAAU;CAC1B,CAAC,kBAAkB,SAAS;CAC5B,CAAC,eAAe,QAAQ;CACxB,CAAC,iBAAiB,UAAU;CAC5B,CAAC,yBAAyB,MAAM;CAChC,CAAC,qBAAqB,QAAQ;CAC9B,CAAC,qBAAqB,MAAM;CAC5B,CAAC,kBAAkB,MAAM;CACzB,CAAC,mBAAmB,MAAM;CAC1B,CAAC,WAAW,SAAS;CACrB,CAAC,eAAe,aAAa;AAC/B;AAEA,IAAM,WA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GAAG;IACvD,MAAM,SAAS,SAAS,SAAS,MAAM,MAAM,KAAK;IAClD,MAAM,OAAiB,CAAC;IACxB,MAAM,QAAqC,CAAC;IAC5C,KAAK,MAAM,SAAS,OAAO,QAAQ;KACjC,KAAK,KAAK,OAAO,MAAM,KAAK,IAAI,MAAM,UAAU,KAAK,MAAM,CAAC;KAC5D,MAAM,KAAK,OAAO,MAAM,MAAM,CAAC;IACjC;IACA,OAAO;KAAE,MAAM,OAAO;KAAQ,MAAM,OAAO;KAAK;KAAM;IAAM;IAC5D,MAAM,QAAQ,OAAO;IACrB,MAAM,OAAO;GACf;GACA,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,KAAK,QAAQ,KACpC,IAAI,KAAK,KAAK,KAAM,OAAO,KAAK;IAC9B,OAAO,MAAM,KAAK,IAAI,KAAK,KAAK,IAAK,OAAO,GAAG;IAE/C,IAAI,OAAO,OAAO,OAAO,KAAK,MAAM,OAAO;IAC3C,OAAO,KAAK,MAAM;GACpB;GACF,OAAO,UAAU;GACjB,MAAM,OAAO;GACb,OAAO;EACT;EACA,UAAU,OAAO;GACf,MAAM,QAAQ,SAAS,SAAS,IAAI,MAAM,KAAK,CAAC,CAAC;GACjD,MAAM,OAAO;EACf;EACA,SAAS,QAAQ;EACjB,UAAU,QAAQ;EAClB,WAAW,QAAQ;EACnB,aAAa,QAAQ;CACvB,CAAC;AACH"}
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer dou.components{.dou-code-editor{--dou-code-editor-font-size:var(--dou-font-size-sm);--dou-code-editor-line-height:20px;--dou-code-editor-padding-y:8px;--dou-code-editor-padding-x:12px;--dou-code-editor-bg:var(--dou-color-bg-surface);--dou-code-editor-gutter-bg:var(--dou-code-editor-bg);--dou-code-editor-gutter-text:var(--dou-color-text-tertiary);--dou-code-editor-border:var(--dou-color-border);--dou-code-editor-border-focus:color-mix(in oklab,var(--dou-color-focus)70%,var(--dou-color-text));--dou-code-editor-cursor:var(--dou-color-text);--dou-code-editor-active-line:color-mix(in oklab,var(--dou-color-text)4%,transparent);--dou-code-editor-selection:color-mix(in oklab,var(--dou-color-primary)20%,transparent);--dou-code-editor-match:color-mix(in oklab,var(--dou-color-warning)22%,transparent);--dou-code-editor-match-current:color-mix(in oklab,var(--dou-color-warning-text)80%,transparent);--dou-code-editor-match-mark:color-mix(in oklab,var(--dou-color-warning)60%,transparent);--dou-code-editor-bracket:color-mix(in oklab,var(--dou-color-text)35%,transparent);--dou-code-editor-error:var(--dou-color-danger-text);--dou-code-editor-warning:var(--dou-color-warning-text);--dou-code-editor-info:var(--dou-color-primary-text);--dou-code-editor-bracket-unmatched:color-mix(in oklab,var(--dou-color-danger-text)70%,transparent);position:relative;display:flex;box-sizing:border-box;min-height:calc(var(--dou-code-editor-line-height) + 2*var(--dou-code-editor-padding-y) + 2px);overflow:hidden;border:1px solid var(--dou-code-editor-border);border-radius:var(--dou-radius-container);background-color:var(--dou-code-editor-bg);color:var(--dou-color-text);font-family:var(--dou-font-family-mono);font-size:var(--dou-code-editor-font-size);font-variant-ligatures:none;line-height:var(--dou-code-editor-line-height);transition:border-color var(--dou-motion-duration-fast)var(--dou-motion-easing);flex-direction:column;width:100%;min-width:0}.dou-code-editor.is-focused{border-color:var(--dou-code-editor-border-focus)}.dou-code-editor:not(.is-focused){--dou-code-editor-selection:color-mix(in oklab,var(--dou-color-text)10%,transparent)}.dou-code-editor.is-disabled{color:var(--dou-color-text-disabled);cursor:not-allowed}.dou-code-editor__body{position:relative;display:flex;flex:auto;min-height:0}.dou-code-editor__scroller{position:relative;overflow:auto;overscroll-behavior-x:contain;scrollbar-width:thin;flex:auto;min-width:0;min-height:0}.dou-code-editor__minimap{position:relative;overflow:hidden;box-shadow:inset 1px 0 0 color-mix(in oklab,var(--dou-color-text)6%,transparent);color:var(--dou-color-text-tertiary);cursor:default;touch-action:none;user-select:none;flex:none;width:96px}.dou-code-editor__minimap-canvas{position:absolute;width:100%;height:100%;inset:0}.dou-code-editor__minimap-view{position:absolute;background-color:color-mix(in oklab,var(--dou-color-text)6%,transparent);transition:background-color var(--dou-motion-duration-fast)var(--dou-motion-easing);top:0;left:0;right:0}.dou-code-editor__minimap:hover .dou-code-editor__minimap-view{background-color:color-mix(in oklab,var(--dou-color-text)9%,transparent)}.dou-code-editor__minimap:active .dou-code-editor__minimap-view{background-color:color-mix(in oklab,var(--dou-color-text)12%,transparent)}.dou-code-editor__sizer{position:relative;display:flex;box-sizing:border-box;width:max-content;min-width:100%}.dou-code-editor__gutter{position:sticky;z-index:2;box-sizing:border-box;width:var(--dou-code-editor-gutter);background-color:var(--dou-code-editor-gutter-bg);color:var(--dou-code-editor-gutter-text);font-variant-numeric:tabular-nums;cursor:default;user-select:none;-webkit-user-select:none;touch-action:manipulation;flex:none;left:0}.dou-code-editor__numbers{position:absolute;will-change:transform;top:0;left:0;right:0}.dou-code-editor__number{position:relative;box-sizing:border-box;height:var(--dou-code-editor-line-height);padding:0 12px 0 calc(16px + var(--dou-code-editor-gutter-cells,0px));text-align:right}.dou-code-editor__number.is-active{color:var(--dou-color-text-secondary)}.dou-code-editor.is-foldable .dou-code-editor__number{padding-right:24px}.dou-code-editor__fold-toggle{position:absolute;display:flex;height:var(--dou-code-editor-line-height);color:var(--dou-color-text-tertiary);cursor:pointer;opacity:0;transition:opacity var(--dou-motion-duration-fast)var(--dou-motion-easing);justify-content:center;align-items: center;width:14px;font-size:12px;top:0;right:6px}.dou-code-editor__gutter:hover .dou-code-editor__fold-toggle{opacity:1}.dou-code-editor__fold-toggle.is-folded{opacity:1}.dou-code-editor__fold-toggle:hover{color:var(--dou-color-text)}@media (pointer:coarse){.dou-code-editor__fold-toggle{opacity:1}.dou-code-editor__fold-toggle:before{position:absolute;content:"";inset:-4px -6px}}.dou-code-editor__content{position:relative;cursor:text;touch-action:manipulation;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;flex:auto;min-width:0}.dou-code-editor.is-disabled .dou-code-editor__content{cursor:not-allowed}.dou-code-editor__lines,.dou-code-editor__matches,.dou-code-editor__brackets,.dou-code-editor__selections,.dou-code-editor__cursors{position:absolute;pointer-events:none;top:0;left:0}.dou-code-editor__lines{will-change:transform;right:0}.dou-code-editor__line{box-sizing:border-box;height:var(--dou-code-editor-line-height);padding:0 var(--dou-code-editor-padding-x);white-space:pre;tab-size:var(--dou-code-editor-tab-size,2)}.dou-code-editor__line.is-wrapped{height:auto}.dou-code-editor__row{box-sizing:border-box;height:var(--dou-code-editor-line-height)}.dou-code-editor__fold-marker{display:inline-block;box-sizing:border-box;border:1px solid var(--dou-color-border);background-color:var(--dou-color-bg-muted);color:var(--dou-color-text-secondary);vertical-align:1px;cursor:pointer;pointer-events:auto;border-radius:4px;height:16px;margin-left:6px;padding:0 6px;font-size:12px;line-height:14px}.dou-code-editor__fold-marker:hover{color:var(--dou-color-text)}.dou-code-editor__line :-webkit-any(.dou-syntax-heading,.dou-syntax-strong){font-weight:inherit}.dou-code-editor__line :-moz-any(.dou-syntax-heading,.dou-syntax-strong){font-weight:inherit}.dou-code-editor__line :is(.dou-syntax-heading,.dou-syntax-strong){font-weight:inherit}.dou-code-editor__compose{text-decoration:underline;text-decoration-color:var(--dou-color-text-tertiary);text-underline-offset:3px}.dou-code-editor__probe{position:absolute;visibility:hidden;white-space:pre;pointer-events:none;top:0;left:0}.dou-code-editor__active-line{position:absolute;height:var(--dou-code-editor-line-height);background-color:var(--dou-code-editor-active-line);pointer-events:none;top:0;left:0;right:0}.dou-code-editor:not(.is-focused) .dou-code-editor__active-line{background-color:#0000}.dou-code-editor__match{position:absolute;box-sizing:border-box;height:var(--dou-code-editor-line-height);background-color:var(--dou-code-editor-match);border-radius:2px;top:0;left:0}.dou-code-editor__match.is-current{box-shadow:inset 0 0 0 1px var(--dou-code-editor-match-current)}.dou-code-editor__marks{position:absolute;z-index:3;pointer-events:none;width:6px;top:0;bottom:0;right:0}.dou-code-editor__mark{position:absolute;background-color:var(--dou-code-editor-match-mark);border-radius:1px;width:6px;height:2px;right:0}.dou-code-editor__mark.is-current{background-color:var(--dou-code-editor-match-current);height:3px}.dou-code-editor__live{position:absolute;overflow:hidden;clip-path:inset(50%);white-space:nowrap;width:1px;height:1px}.dou-code-editor__search{position:absolute;z-index:4;display:flex;container-type:inline-size;pointer-events:none;justify-content:flex-end;top:6px;left:6px;right:14px}.dou-code-editor__search>*{pointer-events:auto}.dou-code-editor__bracket{position:absolute;box-sizing:border-box;height:var(--dou-code-editor-line-height);border:1px solid var(--dou-code-editor-bracket);border-radius:2px;top:0;left:0}.dou-code-editor__bracket.is-unmatched{border-color:var(--dou-code-editor-bracket-unmatched)}.dou-code-editor__selection{position:absolute;height:var(--dou-code-editor-line-height);background-color:var(--dou-code-editor-selection);border-radius:2px;top:0;left:0}.dou-code-editor__cursor{position:absolute;height:var(--dou-code-editor-line-height);background-color:var(--dou-code-editor-cursor);animation:1.2s step-end .5s infinite dou-code-editor-blink;border-radius:1px;width:2px;top:0;left:0}.dou-code-editor.is-readonly .dou-code-editor__cursor{opacity:.4;animation:none}@media (prefers-reduced-motion:reduce){.dou-code-editor__cursor{animation:none}}.dou-code-editor__placeholder{position:absolute;top:var(--dou-code-editor-padding-y);left:var(--dou-code-editor-padding-x);color:var(--dou-color-text-tertiary);white-space:pre;pointer-events:none}.dou-code-editor__input{position:absolute;z-index:-1;box-sizing:border-box;width:calc(100% - var(--dou-code-editor-padding-x));overflow:hidden;outline:none;color:#0000;caret-color:transparent;font:inherit;font-size:max(var(--dou-font-size-input-min),var(--dou-code-editor-font-size));line-height:inherit;letter-spacing:inherit;white-space:pre;tab-size:var(--dou-code-editor-tab-size,2);resize:none;pointer-events:none;background:0 0;border:0;min-width:1px;margin:0;padding:0}.dou-code-editor__input::selection{background:0 0}}@layer dou.components{.dou-code-editor__problem{text-decoration-line:underline;text-decoration-style:wavy;text-decoration-thickness:1px;text-decoration-skip-ink:none;text-underline-offset:3px}.dou-code-editor__problem.is-error{text-decoration-color:var(--dou-code-editor-error)}.dou-code-editor__problem.is-warning{text-decoration-color:var(--dou-code-editor-warning)}.dou-code-editor__problem.is-info{text-decoration-color:var(--dou-code-editor-info)}.dou-code-editor__problem.is-hint{text-decoration-style:dotted;text-decoration-color:var(--dou-color-text-tertiary)}.dou-code-editor__cells{position:absolute;display:flex;height:var(--dou-code-editor-line-height);top:0;left:0}.dou-code-editor__cell{display:inline-flex;font-size:var(--dou-font-size-sm);flex:none;justify-content:center;align-items: center;height:100%}.dou-code-editor__cell[data-gutter-cell]{cursor:pointer}.dou-code-editor__cell>svg{width:14px;height:14px}.dou-code-editor__problem-icon.is-error{color:var(--dou-code-editor-error)}.dou-code-editor__problem-icon.is-warning{color:var(--dou-code-editor-warning)}.dou-code-editor__problem-icon.is-info{color:var(--dou-code-editor-info)}.dou-code-editor__problem-icon.is-hint{color:var(--dou-color-text-tertiary)}.dou-code-editor__problem-mark.is-error{background-color:var(--dou-code-editor-error)}.dou-code-editor__problem-mark.is-warning{background-color:var(--dou-code-editor-warning)}.dou-code-editor__problem-mark.is-info{background-color:var(--dou-code-editor-info)}.dou-code-editor__problem-mark.is-hint{background-color:var(--dou-color-text-tertiary)}.dou-code-editor__floating{display:contents}.dou-code-editor__floating.is-outside{--dou-code-editor-font-size:var(--dou-font-size-sm);--dou-code-editor-bg:var(--dou-color-bg-surface);--dou-code-editor-error:var(--dou-color-danger-text);--dou-code-editor-warning:var(--dou-color-warning-text);--dou-code-editor-info:var(--dou-color-primary-text);position:absolute;display:block;color:var(--dou-color-text);transition:opacity var(--dou-motion-duration-fast)var(--dou-motion-easing);width:0;height:0;line-height:20px;top:0;left:0}.dou-code-editor__floating.is-outside.is-scrolling{opacity:0;pointer-events:none;transition:none}.dou-code-editor__floating.is-outside.is-fixed{position:fixed}.dou-code-editor__problems{position:absolute;z-index:6;box-sizing:border-box;display:flex;border:1px solid var(--dou-color-border);border-radius:var(--dou-radius-control);background-color:var(--dou-color-bg-surface);box-shadow:var(--dou-shadow-md);font-family:var(--dou-font-family);font-size:var(--dou-font-size-sm);white-space:normal;overflow-y:auto;overscroll-behavior:contain;flex-direction:column;gap:4px;width:max-content;max-width:min(440px,100% - 8px);padding:6px;line-height:20px;top:0;left:0}.dou-code-editor__problems>*{flex-shrink:0}.dou-code-editor__problem-item{display:flex;align-items: flex-start;gap:6px;padding:0 2px}.dou-code-editor__problem-item.is-error{--dou-code-editor-problem:var(--dou-code-editor-error)}.dou-code-editor__problem-item.is-warning{--dou-code-editor-problem:var(--dou-code-editor-warning)}.dou-code-editor__problem-item.is-info{--dou-code-editor-problem:var(--dou-code-editor-info)}.dou-code-editor__problem-item.is-hint{--dou-code-editor-problem:var(--dou-color-text-tertiary)}.dou-code-editor__problem-severity{color:var(--dou-code-editor-problem);flex:none;width:14px;height:20px}.dou-code-editor__problem-message{overflow-wrap:anywhere;color:var(--dou-color-text);min-width:0}.dou-code-editor__problem-source{color:var(--dou-color-text-tertiary);margin-left:8px}.dou-code-editor__fixes{display:flex;border-top:1px solid var(--dou-color-border-subtle);flex-wrap:wrap;gap:2px;padding-top:4px}.dou-code-editor__fix{display:inline-flex;border-radius:calc(var(--dou-radius-control) - 2px);color:var(--dou-color-primary-text);font:inherit;cursor:pointer;background:0 0;border:0;align-items: center;height:24px;padding:0 8px}.dou-code-editor__fix.is-active{background-color:color-mix(in oklab,var(--dou-color-text)6%,transparent)}.dou-code-editor__fix:hover{background-color:color-mix(in oklab,var(--dou-color-text)6%,transparent)}@media (pointer:coarse){.dou-code-editor__fix{height:36px}}.dou-code-editor__hover{color:var(--dou-color-text);overflow-wrap:anywhere;white-space:pre-wrap;padding:0 2px}.dou-code-editor__hover+.dou-code-editor__problem-item{border-top:1px solid var(--dou-color-border-subtle);padding-top:4px}.dou-code-lsp-markup{display:flex;white-space:normal;flex-direction:column;gap:6px}.dou-code-lsp-markup__text{white-space:pre-wrap;margin:0}.dou-code-lsp-markup__code{font-family:var(--dou-font-family-mono);white-space:pre-wrap;margin:0}.dou-code-lsp-markup__inline{font-family:var(--dou-font-family-mono)}.dou-code-editor__completions{position:absolute;z-index:7;box-sizing:border-box;display:flex;border:1px solid var(--dou-color-border);border-radius:var(--dou-radius-control);background-color:var(--dou-color-bg-surface);box-shadow:var(--dou-shadow-md);font-family:var(--dou-font-family-mono);font-size:var(--dou-code-editor-font-size);flex-direction:column;width:max-content;min-width:min(200px,100%);max-height:264px;padding:4px;line-height:20px;top:0;left:0}.dou-code-editor__completion-list{overflow-y:auto;overscroll-behavior:contain;flex:0 auto;min-height:28px}.dou-code-editor__completion{display:flex;border-radius:calc(var(--dou-radius-control) - 2px);color:var(--dou-color-text);cursor:pointer;align-items: center;gap:8px;height:28px;padding:0 8px 0 6px}.dou-code-editor__completion.is-active{background-color:color-mix(in oklab,var(--dou-color-text)8%,transparent)}@media (hover:hover){.dou-code-editor__completion:not(.is-active):hover{background-color:color-mix(in oklab,var(--dou-color-text)4%,transparent)}}@media (pointer:coarse){.dou-code-editor__completion{height:36px}}.dou-code-editor__completion-kind{color:var(--dou-color-text-tertiary);flex:none;width:16px;height:16px}.dou-code-editor__completion-label{overflow:hidden;text-overflow:ellipsis;white-space:pre;flex:none;max-width:75%}.dou-code-editor__completion-match{color:var(--dou-color-primary-text);background:0 0;font-weight:600}.dou-code-editor__completion-detail{overflow:hidden;color:var(--dou-color-text-tertiary);font-family:var(--dou-font-family);font-size:var(--dou-font-size-sm);text-overflow:ellipsis;white-space:nowrap;flex:0 auto;min-width:0;margin-left:auto;padding-left:16px}.dou-code-editor__completion-info{border-top:1px solid var(--dou-color-border-subtle);color:var(--dou-color-text-secondary);font-family:var(--dou-font-family);font-size:var(--dou-font-size-sm);white-space:pre-wrap;overflow-wrap:anywhere;flex:none;max-width:400px;margin-top:4px;padding:6px 6px 2px}.dou-code-editor__signature{position:absolute;z-index:6;box-sizing:border-box;border:1px solid var(--dou-color-border);border-radius:var(--dou-radius-control);background-color:var(--dou-color-bg-surface);box-shadow:var(--dou-shadow-md);font-size:var(--dou-font-size-sm);overflow-y:auto;pointer-events:none;width:max-content;max-width:min(440px,100% - 8px);padding:4px 8px;line-height:20px;top:0;left:0}.dou-code-editor__signature-label{color:var(--dou-color-text-secondary);font-family:var(--dou-font-family-mono);font-size:var(--dou-code-editor-font-size);overflow-wrap:anywhere}.dou-code-editor__signature-active{color:var(--dou-color-text);text-decoration:underline;text-underline-offset:3px;font-weight:600}.dou-code-editor__signature-info{color:var(--dou-color-text-tertiary);font-family:var(--dou-font-family);white-space:pre-wrap}.dou-code-editor__field{box-shadow:inset 0 0 0 1px var(--dou-color-border-strong);border-radius:2px}.dou-code-editor__widgets{position:absolute;z-index:3;top:0;left:0}.dou-code-editor__widget{position:absolute;box-sizing:border-box;cursor:auto;font-family:var(--dou-font-family);font-size:var(--dou-font-size-sm);white-space:normal;user-select:text;-webkit-user-select:text;display:flow-root;line-height:20px;top:0;left:0}.dou-code-editor__inline{display:inline-block;vertical-align:top;height:var(--dou-code-editor-line-height);white-space:nowrap}.dou-code-editor__panels{font-family:var(--dou-font-family);flex:none}.dou-code-editor__panels.is-top{border-bottom:1px solid var(--dou-color-border-subtle)}.dou-code-editor__panels.is-bottom{border-top:1px solid var(--dou-color-border-subtle)}.dou-code-editor__handle{position:absolute;z-index:5;touch-action:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;width:0;height:0;top:0;left:0}.dou-code-editor__handle:before{position:absolute;content:"";width:36px;height:36px;top:-6px}.dou-code-editor__handle:after{position:absolute;background-color:var(--dou-color-primary);content:"";width:14px;height:14px;top:0}.dou-code-editor__handle.is-start:before{left:-27px}.dou-code-editor__handle.is-start:after{border-radius:50% 0 50% 50%;right:0}.dou-code-editor__handle.is-end:before{left:-9px}.dou-code-editor__handle.is-end:after{border-radius:0 50% 50%;left:0}.dou-code-editor__handle.is-caret:before{left:-18px}.dou-code-editor__handle.is-caret:after{border-radius:0 50% 50%;width:12px;height:12px;top:4px;left:-6px;transform:rotate(45deg)}.dou-code-editor__magnifier{position:absolute;z-index:6;box-sizing:border-box;overflow:hidden;border:1px solid var(--dou-color-border);background:linear-gradient(var(--dou-code-editor-bg),var(--dou-code-editor-bg)),var(--dou-color-bg-surface);box-shadow:var(--dou-shadow-md);pointer-events:none;border-radius:999px;width:128px;top:0;left:0}.dou-code-editor__magnifier-text{position:absolute;height:var(--dou-code-editor-line-height);margin-top:calc(var(--dou-code-editor-line-height)/-2);white-space:pre;tab-size:var(--dou-code-editor-tab-size);transform-origin:0 50%;top:50%;left:0}.dou-code-editor__magnifier-caret{position:absolute;height:calc(var(--dou-code-editor-line-height)*1.5);background-color:var(--dou-color-primary);border-radius:1px;width:2px;top:50%;translate:0 -50%}.dou-code-editor__menu{position:absolute;z-index:6;display:flex;border:1px solid var(--dou-color-border);border-radius:calc(var(--dou-radius-control) + 2px);background-color:var(--dou-color-bg-surface);box-shadow:var(--dou-shadow-md);font-family:var(--dou-font-family);white-space:nowrap;gap:2px;padding:2px;top:0;left:0}.dou-code-editor__menu-button{display:inline-flex;border-radius:var(--dou-radius-control);color:var(--dou-color-text);font:inherit;font-size:var(--dou-font-size-sm);cursor:pointer;-webkit-tap-highlight-color:transparent;background:0 0;border:0;align-items: center;min-width:36px;height:36px;padding:0 12px;line-height:1}.dou-code-editor__menu-button:active{background-color:color-mix(in oklab,var(--dou-color-text)8%,transparent)}@media (hover:hover){.dou-code-editor__menu-button:hover{background-color:color-mix(in oklab,var(--dou-color-text)5%,transparent)}}.dou-code-editor__keys{position:fixed;box-sizing:border-box;padding:0 max(8px,env(safe-area-inset-right))0 max(8px,env(safe-area-inset-left));pointer-events:none;transition:opacity var(--dou-motion-duration-fast)var(--dou-motion-easing);top:0;left:0}.dou-code-editor__keys.is-scrolling{opacity:0}.dou-code-editor__keys.is-scrolling>.dou-code-keys{pointer-events:none}.dou-code-editor__keys>.dou-code-keys{overflow:hidden;border:1px solid color-mix(in oklab,var(--dou-color-text)10%,transparent);background-color:color-mix(in oklab,var(--dou-color-bg-surface)92%,transparent);box-shadow:var(--dou-shadow-md);-webkit-backdrop-filter:blur(20px)saturate(1.8);backdrop-filter:blur(20px)saturate(1.8);pointer-events:auto;border-radius:22px;height:44px;padding:0 3px}.dou-code-editor__keys>.dou-code-keys .dou-code-keys__scroll{padding:0}.dou-code-editor__keys>.dou-code-keys .dou-code-keys__arrows{position:relative;box-shadow:none;padding:0 0 0 5px}.dou-code-editor__keys>.dou-code-keys .dou-code-keys__arrows:before{position:absolute;background-color:var(--dou-color-border-subtle);content:"";width:1px;top:10px;bottom:10px;left:0}.dou-code-editor__keys>.dou-code-keys .dou-code-keys__key{border-radius:18px}.dou-code-keys{display:flex;box-sizing:border-box;border-top:1px solid var(--dou-color-border);background-color:var(--dou-color-bg-surface);color:var(--dou-color-text);font-family:var(--dou-font-family-mono);font-size:var(--dou-font-size-md);user-select:none;-webkit-user-select:none;height:45px}.dou-code-keys__scroll{display:flex;overflow-x:auto;overscroll-behavior-x:contain;scrollbar-width:none;touch-action:pan-x;flex:auto;align-items: center;gap:2px;min-width:0;padding:0 4px}.dou-code-keys__scroll::-webkit-scrollbar{display:none}.dou-code-keys__arrows{display:flex;box-shadow:-1px 0 0 var(--dou-color-border-subtle);flex:none;align-items: center;gap:2px;padding:0 4px}.dou-code-keys__key{display:inline-flex;box-sizing:border-box;border-radius:var(--dou-radius-control);color:inherit;font:inherit;cursor:pointer;touch-action:pan-x;-webkit-tap-highlight-color:transparent;transition-property:background-color,transform;transition-duration:var(--dou-motion-duration-fast);transition-timing-function:var(--dou-motion-easing-exit);background:0 0;border:0;flex:none;justify-content:center;align-items: center;min-width:36px;height:36px;padding:0 8px;line-height:1}.dou-code-keys__key>svg{color:var(--dou-color-text-secondary);width:18px;height:18px}@media (hover:hover){.dou-code-keys__key:hover{background-color:color-mix(in oklab,var(--dou-color-text)5%,transparent)}}.dou-code-keys__key.is-pressed{background-color:color-mix(in oklab,var(--dou-color-text)10%,transparent);transition-duration:var(--dou-motion-duration-slow);transition-timing-function:var(--dou-motion-easing-spring);transform:scale(1.12)}}@layer dou.components{.dou-code-input{--dou-code-input-height:var(--dou-control-height-md);display:block;width:100%;min-width:0}.dou-code-input .dou-code-editor{--dou-code-editor-padding-x:var(--dou-control-padding-x-md);--dou-code-editor-padding-y:calc((var(--dou-code-input-height) - var(--dou-code-editor-line-height) - 2px)/2);min-height:var(--dou-code-input-height);border-radius:var(--dou-radius-control);transition-property:border-color,box-shadow}@media (hover:hover){.dou-code-input .dou-code-editor:not(:-webkit-any(.is-focused,.is-disabled)):hover{--dou-code-editor-border:var(--dou-color-border-strong)}.dou-code-input .dou-code-editor:not(:-moz-any(.is-focused,.is-disabled)):hover{--dou-code-editor-border:var(--dou-color-border-strong)}.dou-code-input .dou-code-editor:not(:is(.is-focused,.is-disabled)):hover{--dou-code-editor-border:var(--dou-color-border-strong)}}.dou-code-input .dou-code-editor__marks{display:none}.dou-code-input:not(.is-multiline) .dou-code-editor{height:var(--dou-code-input-height)}.dou-code-input:not(.is-multiline) .dou-code-editor .dou-code-editor__scroller{scrollbar-width:none}.dou-code-input:not(.is-multiline) .dou-code-editor .dou-code-editor__scroller::-webkit-scrollbar{display:none}.dou-code-input.is-multiline .dou-code-editor{min-height:calc(var(--dou-code-input-min-rows,1)*var(--dou-code-editor-line-height) + 2*var(--dou-code-editor-padding-y) + 2px);max-height:calc(var(--dou-code-input-max-rows,6)*var(--dou-code-editor-line-height) + 2*var(--dou-code-editor-padding-y) + 2px)}.dou-code-input.is-invalid .dou-code-editor{--dou-code-editor-border:color-mix(in oklab,var(--dou-color-danger)55%,var(--dou-color-border));--dou-code-editor-border-focus:var(--dou-color-danger)}.dou-code-input--sm{--dou-code-input-height:var(--dou-control-height-sm)}.dou-code-input--sm .dou-code-editor{--dou-code-editor-padding-x:var(--dou-control-padding-x-sm)}.dou-code-input--lg{--dou-code-input-height:var(--dou-control-height-lg)}.dou-code-input--lg .dou-code-editor{--dou-code-editor-padding-x:var(--dou-control-padding-x-lg)}}@keyframes dou-code-peer-name{to{opacity:0;visibility:hidden}}@keyframes dou-code-editor-blink{50%{opacity:0}}@layer dou.components{.dou-code-diff{--dou-code-diff-removed:color-mix(in oklab,var(--dou-color-danger)10%,transparent);--dou-code-diff-added:color-mix(in oklab,var(--dou-color-success)10%,transparent);--dou-code-diff-removed-word:color-mix(in oklab,var(--dou-color-danger-text)30%,transparent);--dou-code-diff-added-word:color-mix(in oklab,var(--dou-color-success-text)30%,transparent);--dou-code-diff-border:var(--dou-color-border);position:relative;display:flex;box-sizing:border-box;overflow:hidden;border:1px solid var(--dou-code-diff-border);border-radius:var(--dou-radius-container);background-color:var(--dou-color-bg-surface);transition:border-color var(--dou-motion-duration-fast)var(--dou-motion-easing);flex-direction:column;width:100%;min-width:0}.dou-code-diff:focus-within{border-color:color-mix(in oklab,var(--dou-color-focus)70%,var(--dou-color-text))}.dou-code-diff .dou-code-editor{border:0;border-radius:0}.dou-code-diff__toolbar{display:flex;border-bottom:1px solid var(--dou-code-diff-border);font-size:var(--dou-font-size-sm);flex:none;align-items: center;gap:2px;min-height:36px;padding:0 6px 0 12px}@media (pointer:coarse){.dou-code-diff__toolbar{min-height:44px}}.dou-code-diff__stats{display:flex;overflow:hidden;white-space:nowrap;flex:auto;align-items: center;gap:8px;min-width:0}.dou-code-diff__count{font-family:var(--dou-font-family-mono);font-variant-numeric:tabular-nums}.dou-code-diff__count.is-added{color:var(--dou-color-success-text)}.dou-code-diff__count.is-removed{color:var(--dou-color-danger-text)}.dou-code-diff__summary{overflow:hidden;color:var(--dou-color-text-secondary);text-overflow:ellipsis}.dou-code-diff__hidden-text{position:absolute;overflow:hidden;clip-path:inset(50%);white-space:nowrap;width:1px;height:1px}@media (pointer:coarse){.dou-code-diff__toolbar .dou-button{position:relative;min-width:36px;min-height:36px}.dou-code-diff__toolbar .dou-button:after{position:absolute;content:"";inset:-2px}}.dou-code-diff__body{display:grid;grid-template-rows:minmax(0,1fr);grid-template-columns:minmax(0,1fr);flex:auto;min-height:0}.dou-code-diff--split>.dou-code-diff__body{grid-template-rows:auto minmax(0,1fr);grid-template-columns:minmax(0,1fr)minmax(0,1fr)}.dou-code-diff__label{border-bottom:1px solid var(--dou-code-diff-border);color:var(--dou-color-text-secondary);padding:4px 12px;font-size:12px}.dou-code-diff__label:nth-child(2){border-left:1px solid var(--dou-code-diff-border)}.dou-code-diff__side{display:flex;flex-direction:column;min-width:0;min-height:0}.dou-code-diff__side.is-modified{border-left:1px solid var(--dou-code-diff-border)}.dou-code-diff__side>.dou-code-editor{flex:auto}.dou-code-diff__line.is-removed{background-color:var(--dou-code-diff-removed)}.dou-code-diff__line.is-added{background-color:var(--dou-code-diff-added)}.dou-code-diff__word.is-removed{background-color:var(--dou-code-diff-removed-word)}.dou-code-diff__word.is-added{background-color:var(--dou-code-diff-added-word)}.dou-code-editor__cell.dou-code-diff__sign{font-family:var(--dou-font-family-mono)}.dou-code-editor__cell.dou-code-diff__sign.is-removed{background-color:var(--dou-code-diff-removed);color:var(--dou-color-danger-text)}.dou-code-editor__cell.dou-code-diff__sign.is-added{background-color:var(--dou-code-diff-added);color:var(--dou-color-success-text)}.dou-code-editor__cell.dou-code-diff__number{box-sizing:border-box;color:var(--dou-code-editor-gutter-text);font-family:var(--dou-font-family-mono);font-size:inherit;font-variant-numeric:tabular-nums;justify-content:flex-end;padding-right:8px}.dou-code-editor__cell.dou-code-diff__number.is-removed{background-color:var(--dou-code-diff-removed)}.dou-code-editor__cell.dou-code-diff__number.is-added{background-color:var(--dou-code-diff-added)}.dou-code-diff__filler{background-image:repeating-linear-gradient(-45deg,transparent 0 6px,color-mix(in oklab,var(--dou-color-text)5%,transparent)6px 7px)}.dou-code-diff__bar{display:flex;box-sizing:border-box;border:0;border-block:1px solid var(--dou-code-diff-border);background-color:color-mix(in oklab,var(--dou-color-text)3%,transparent);color:var(--dou-color-text-secondary);font:inherit;text-align:left;cursor:pointer;align-items: center;gap:6px;width:100%;height:28px;margin:0;padding:0 12px;font-size:12px}@media (hover:hover){.dou-code-diff__bar:hover{background-color:color-mix(in oklab,var(--dou-color-text)6%,transparent);color:var(--dou-color-text)}}.dou-code-diff__bar:focus-visible{outline:2px solid var(--dou-color-focus);outline-offset:-2px}@media (pointer:coarse){.dou-code-diff__bar{height:36px}}.dou-code-diff__bar-icon{flex:none;font-size:14px}.dou-code-diff__live{position:absolute;overflow:hidden;clip-path:inset(50%);white-space:nowrap;width:1px;height:1px}.dou-code-peer{position:relative;z-index:1;display:inline-block;height:var(--dou-code-editor-line-height);vertical-align:top;pointer-events:none;width:0}.dou-code-peer:before{content:"";position:absolute;background-color:var(--dou-code-peer-color);border-radius:1px;width:2px;height:100%;top:0;left:-1px}.dou-code-peer__name{position:absolute;background-color:var(--dou-code-peer-color);color:oklch(from var(--dou-code-peer-color)clamp(.2,(.66 - l)*100,.99)0 0);font-family:var(--dou-font-family);font-size:var(--dou-font-size-sm);white-space:nowrap;user-select:none;animation:dou-code-peer-name var(--dou-motion-duration-fast)var(--dou-motion-easing)3s forwards;border-radius:4px 4px 4px 0;padding:0 6px;line-height:18px;bottom:100%;left:-1px}.dou-code-peer.is-below .dou-code-peer__name{border-radius:0 4px 4px;top:100%;bottom:auto}.dou-code-peer-selection{background-color:color-mix(in oklab,var(--dou-code-peer-color)20%,transparent)}}
|
package/dist/style.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/style.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type CodeDiffHunk } from './core/diff';
|
|
2
|
+
import { type CodeExtension } from './extension';
|
|
3
|
+
import type { CodeDiffProps, CodeEditorExpose } from './types';
|
|
4
|
+
declare function next(): boolean;
|
|
5
|
+
declare function previous(): boolean;
|
|
6
|
+
declare const __VLS_export: import("vue").DefineComponent<CodeDiffProps, {
|
|
7
|
+
/** The changes found now. */
|
|
8
|
+
readonly hunks: CodeDiffHunk[];
|
|
9
|
+
/** Moves to the next change; `false` when there is none. */
|
|
10
|
+
next: typeof next;
|
|
11
|
+
/** Moves to the previous change. */
|
|
12
|
+
previous: typeof previous;
|
|
13
|
+
/** Shows every unchanged line. */
|
|
14
|
+
expandAll: () => boolean;
|
|
15
|
+
/** Hides the runs of unchanged lines again. */
|
|
16
|
+
collapseAll: () => void;
|
|
17
|
+
/** The editors drawn now: both sides, or the inline one as `modified`. */
|
|
18
|
+
readonly original: CodeEditorExpose | undefined;
|
|
19
|
+
readonly modified: CodeEditorExpose | undefined;
|
|
20
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
21
|
+
"update:modelValue": (value: string) => any;
|
|
22
|
+
"update:mode": (mode: "split" | "inline") => any;
|
|
23
|
+
}, string, import("vue").PublicProps, Readonly<CodeDiffProps> & Readonly<{
|
|
24
|
+
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
25
|
+
"onUpdate:mode"?: ((mode: "split" | "inline") => any) | undefined;
|
|
26
|
+
}>, {
|
|
27
|
+
toolbar: boolean;
|
|
28
|
+
language: import("./index.js").CodeLanguage<any> | null;
|
|
29
|
+
tabSize: number;
|
|
30
|
+
messages: Partial<import("./locale").CodeMessages>;
|
|
31
|
+
modelValue: string;
|
|
32
|
+
wrap: boolean;
|
|
33
|
+
extensions: CodeExtension[];
|
|
34
|
+
editable: boolean;
|
|
35
|
+
mode: "split" | "inline" | "auto";
|
|
36
|
+
original: string;
|
|
37
|
+
collapseUnchanged: boolean | {
|
|
38
|
+
context?: number;
|
|
39
|
+
minLines?: number;
|
|
40
|
+
};
|
|
41
|
+
ignoreWhitespace: boolean;
|
|
42
|
+
words: boolean;
|
|
43
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
44
|
+
declare const _default: typeof __VLS_export;
|
|
45
|
+
export default _default;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type CodeSelection } from './core/selection';
|
|
2
|
+
import { CodeText } from './core/text';
|
|
3
|
+
import { type CodeTransactionResult } from './core/transaction';
|
|
4
|
+
import type { CodeEditorExpose, CodeEditorProps } from './types';
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<CodeEditorProps, CodeEditorExpose, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
6
|
+
blur: (event: FocusEvent) => any;
|
|
7
|
+
focus: (event: FocusEvent) => any;
|
|
8
|
+
"update:modelValue": (value: string) => any;
|
|
9
|
+
"update:doc": (value: CodeText) => any;
|
|
10
|
+
"update:selection": (value: CodeSelection) => any;
|
|
11
|
+
transaction: (result: CodeTransactionResult) => any;
|
|
12
|
+
foldChange: (lines: number[]) => any;
|
|
13
|
+
}, string, import("vue").PublicProps, Readonly<CodeEditorProps> & Readonly<{
|
|
14
|
+
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
15
|
+
onFocus?: ((event: FocusEvent) => any) | undefined;
|
|
16
|
+
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
17
|
+
"onUpdate:doc"?: ((value: CodeText) => any) | undefined;
|
|
18
|
+
"onUpdate:selection"?: ((value: CodeSelection) => any) | undefined;
|
|
19
|
+
onTransaction?: ((result: CodeTransactionResult) => any) | undefined;
|
|
20
|
+
onFoldChange?: ((lines: number[]) => any) | undefined;
|
|
21
|
+
}>, {
|
|
22
|
+
keys: boolean | readonly (string | import("./types").CodeKey)[];
|
|
23
|
+
selection: CodeSelection;
|
|
24
|
+
doc: CodeText;
|
|
25
|
+
language: import(".").CodeLanguage<any> | null;
|
|
26
|
+
tabSize: number;
|
|
27
|
+
worker: boolean | (() => Worker);
|
|
28
|
+
messages: Partial<import("./locale").CodeMessages>;
|
|
29
|
+
modelValue: string;
|
|
30
|
+
lineNumbers: boolean;
|
|
31
|
+
gutter: boolean;
|
|
32
|
+
activeLine: boolean;
|
|
33
|
+
closeBrackets: boolean;
|
|
34
|
+
matchBrackets: boolean;
|
|
35
|
+
searchable: boolean;
|
|
36
|
+
wrap: boolean;
|
|
37
|
+
minimap: boolean;
|
|
38
|
+
foldable: boolean;
|
|
39
|
+
tabIndents: boolean;
|
|
40
|
+
teleport: string | false | HTMLElement;
|
|
41
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
42
|
+
declare const _default: typeof __VLS_export;
|
|
43
|
+
export default _default;
|