@singapore-editor/lsp 0.1.1 → 0.2.10
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 +22 -0
- package/README.md +37 -10
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +1 -2
- package/dist/client.d.ts +4 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +124 -46
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/performanceDiagnostics.js +1 -2
- package/dist/positions.d.ts.map +1 -1
- package/dist/positions.js +1 -2
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +1 -2
- package/dist/semanticTokens.js +1 -2
- package/dist/transports.d.ts.map +1 -1
- package/dist/transports.js +36 -8
- package/dist/transports.js.map +1 -1
- package/dist/types.d.ts +18 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/workspace.d.ts +14 -3
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +109 -29
- package/dist/workspace.js.map +1 -1
- package/dist/workspaceFactory.js +1 -2
- package/package.json +23 -5
package/dist/workspace.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.js","names":[],"sources":["../src/workspace.ts"],"sourcesContent":["import type * as lsp from 'vscode-languageserver-protocol'\nimport type {\n LspDocument,\n LspDocumentOpenSnapshotOptions,\n LspDocumentOpenSnapshotResult,\n LspDocumentTransitionOptions,\n LspDocumentTransitionNotification,\n LspDocumentTransitionResult,\n LspLineStarts,\n LspTextDocumentSnapshot,\n LspTextSnapshot,\n LspWorkspaceDocumentAttachment,\n LspWorkspaceSnapshotEditOptions,\n LspWorkspaceSyncTarget,\n LspWorkspaceUnchangedSourceOptions,\n} from './types'\nimport { registerDefaultLspWorkspaceFactory } from './workspaceFactory'\n\ntype MutableLspDocument = {\n languageId: string\n lineStarts: LspLineStarts\n sourceLogicalRevisionCount: number\n sourceRevision: number\n sourceSegment: object\n textSnapshot: LspTextSnapshot\n uri: lsp.DocumentUri\n version: number\n}\n\ntype WorkspaceDocumentAttachmentRecord = {\n readonly document: MutableLspDocument\n readonly onDocumentTransition?: (transition: LspDocumentTransitionNotification) => void\n}\n\nexport class LspWorkspace {\n private readonly attachments = new Map<\n LspWorkspaceDocumentAttachment,\n WorkspaceDocumentAttachmentRecord\n >()\n private readonly documentsByUri = new Map<lsp.DocumentUri, MutableLspDocument>()\n private readonly versionsByUri = new Map<lsp.DocumentUri, number>()\n private client: LspWorkspaceSyncTarget | null = null\n\n public get documents(): readonly LspDocument[] {\n return Array.from(this.documentsByUri.values()).map(cloneDocument)\n }\n\n public attachClient(client: LspWorkspaceSyncTarget): void {\n this.client = client\n }\n\n public openDocumentSnapshot(\n options: LspDocumentOpenSnapshotOptions,\n ): LspDocumentOpenSnapshotResult {\n assertSourceRevision(options.sourceRevision)\n const open = this.documentsByUri.get(options.uri)\n if (open) return this.attachOpenDocument(open, options)\n\n const document: MutableLspDocument = {\n languageId: options.languageId,\n lineStarts: options.lineStarts,\n sourceLogicalRevisionCount: 0,\n sourceRevision: options.sourceRevision,\n sourceSegment: options.sourceSegment,\n textSnapshot: options.textSnapshot,\n uri: options.uri,\n version: this.advanceVersion(options.uri, 1),\n }\n this.documentsByUri.set(options.uri, document)\n const result = this.attachDocument(document, options.onDocumentTransition)\n this.client?.didOpenDocument(cloneDocument(document))\n return result\n }\n\n public updateDocumentSnapshot(\n uri: lsp.DocumentUri,\n options: LspWorkspaceSnapshotEditOptions,\n ): LspDocument {\n const document = this.requireDocument(uri)\n assertLogicalRevisionCount(options.logicalRevisionCount)\n assertSourceRevision(options.sourceRevision)\n if (sameSourceTuple(document, options)) return adoptDuplicateSource(document, options)\n if (options.logicalRevisionCount === 0) {\n throw new Error('A new LSP document source requires a positive logical revision count.')\n }\n assertForwardSourcePoint(document, options)\n\n const nextVersion = this.advanceVersion(uri, options.logicalRevisionCount)\n const previousSnapshot = documentSnapshot(document)\n document.textSnapshot = options.textSnapshot\n document.lineStarts = options.lineStarts\n document.sourceLogicalRevisionCount = options.logicalRevisionCount\n document.sourceRevision = options.sourceRevision\n document.sourceSegment = options.sourceSegment\n document.version = nextVersion\n this.client?.didChangeDocument(cloneDocument(document), {\n edits: options.edits ?? [],\n previousSnapshot,\n })\n return cloneDocument(document)\n }\n\n public adoptUnchangedDocumentSource(\n uri: lsp.DocumentUri,\n options: LspWorkspaceUnchangedSourceOptions,\n ): LspDocument {\n const document = this.requireDocument(uri)\n assertSourceRevision(options.sourceRevision)\n if (options.textSnapshot !== document.textSnapshot) {\n throw new Error('An unchanged LSP source must retain the exact workspace text snapshot.')\n }\n if (sameSourceTuple(document, options)) return cloneDocument(document)\n assertForwardSourcePoint(document, options)\n\n document.sourceRevision = options.sourceRevision\n document.sourceSegment = options.sourceSegment\n document.sourceLogicalRevisionCount = 0\n return cloneDocument(document)\n }\n\n public transitionDocumentUri(\n attachment: LspWorkspaceDocumentAttachment,\n options: LspDocumentTransitionOptions,\n ): LspDocumentTransitionResult {\n const record = this.requireAttachment(attachment)\n const document = record.document\n if (document.uri === options.uri) return this.adoptCompletedTransition(document, options)\n\n assertSourceRevision(options.sourceRevision)\n assertSourceTextVersion(options.sourceTextVersion)\n assertTransitionTargetAvailable(this.documentsByUri.get(options.uri), document, options.uri)\n assertTransitionSourcePoint(document, options)\n if (document.sourceSegment === options.sourceSegment) {\n throw new Error('An LSP document URI transition requires a rotated source segment.')\n }\n\n const nextVersion = this.advanceVersion(options.uri, 1)\n const previousDocument = cloneDocument(document)\n this.client?.didCloseDocument(previousDocument)\n this.documentsByUri.delete(document.uri)\n document.uri = options.uri\n document.languageId = options.languageId\n document.textSnapshot = options.textSnapshot\n document.lineStarts = options.lineStarts\n document.sourceLogicalRevisionCount = 0\n document.sourceRevision = options.sourceRevision\n document.sourceSegment = options.sourceSegment\n document.version = nextVersion\n this.documentsByUri.set(options.uri, document)\n\n const nextDocument = cloneDocument(document)\n this.client?.didOpenDocument(nextDocument)\n this.notifyTransitionedAttachments(document, options.sourceTextVersion)\n return { document: nextDocument, previousDocument }\n }\n\n public closeDocument(attachment: LspWorkspaceDocumentAttachment): void {\n const record = this.attachments.get(attachment)\n if (!record) return\n\n this.attachments.delete(attachment)\n if (this.hasAttachment(record.document)) return\n\n this.documentsByUri.delete(record.document.uri)\n this.client?.didCloseDocument(cloneDocument(record.document))\n }\n\n public saveDocument(uri: lsp.DocumentUri): void {\n const document = this.documentsByUri.get(uri)\n if (!document) return\n this.client?.didSaveDocument(cloneDocument(document))\n }\n\n public getDocument(uri: lsp.DocumentUri): LspDocument | null {\n const document = this.documentsByUri.get(uri)\n return document ? cloneDocument(document) : null\n }\n\n public connected(): void {\n for (const document of this.documentsByUri.values()) {\n this.client?.didOpenDocument(cloneDocument(document))\n }\n }\n\n public disconnected(): void {\n return\n }\n\n private attachOpenDocument(\n document: MutableLspDocument,\n options: LspDocumentOpenSnapshotOptions,\n ): LspDocumentOpenSnapshotResult {\n if (document.languageId !== options.languageId) {\n throw new Error(\n `LSP document open as ${document.languageId}, reopened as ${options.languageId}: ${options.uri}`,\n )\n }\n if (!sameSourceTuple(document, options) || document.textSnapshot !== options.textSnapshot) {\n throw new Error('A second LSP document attachment must adopt the exact shared source point.')\n }\n return this.attachDocument(document, options.onDocumentTransition)\n }\n\n private attachDocument(\n document: MutableLspDocument,\n onDocumentTransition: ((transition: LspDocumentTransitionNotification) => void) | undefined,\n ): LspDocumentOpenSnapshotResult {\n const attachment = Object.freeze({}) as LspWorkspaceDocumentAttachment\n this.attachments.set(attachment, { document, onDocumentTransition })\n return { attachment, document: cloneDocument(document) }\n }\n\n private adoptCompletedTransition(\n document: MutableLspDocument,\n options: LspDocumentTransitionOptions,\n ): LspDocumentTransitionResult {\n if (document.languageId !== options.languageId) {\n throw new Error('An adopted LSP URI transition must retain the shared language identifier.')\n }\n if (document.textSnapshot !== options.textSnapshot || !sameSourceTuple(document, options)) {\n throw new Error('An adopted LSP URI transition must retain the exact shared source point.')\n }\n\n const current = cloneDocument(document)\n return { document: current, previousDocument: current }\n }\n\n private notifyTransitionedAttachments(\n document: MutableLspDocument,\n sourceTextVersion: number,\n ): void {\n for (const record of this.attachments.values()) {\n if (record.document !== document) continue\n record.onDocumentTransition?.({\n document: cloneDocument(document),\n sourceRevision: document.sourceRevision,\n sourceSegment: document.sourceSegment,\n sourceTextVersion,\n })\n }\n }\n\n private hasAttachment(document: MutableLspDocument): boolean {\n for (const record of this.attachments.values()) {\n if (record.document === document) return true\n }\n return false\n }\n\n private advanceVersion(uri: lsp.DocumentUri, count: number): number {\n const version = (this.versionsByUri.get(uri) ?? -1) + count\n if (!Number.isSafeInteger(version) || version < 0) {\n throw new RangeError(`LSP document version exceeds the safe integer range: ${uri}`)\n }\n this.versionsByUri.set(uri, version)\n return version\n }\n\n private requireDocument(uri: lsp.DocumentUri): MutableLspDocument {\n const document = this.documentsByUri.get(uri)\n if (document) return document\n throw new Error(`LSP document is not open: ${uri}`)\n }\n\n private requireAttachment(\n attachment: LspWorkspaceDocumentAttachment,\n ): WorkspaceDocumentAttachmentRecord {\n const record = this.attachments.get(attachment)\n if (record) return record\n throw new Error('LSP workspace document attachment is closed or belongs to another workspace.')\n }\n}\n\nfunction cloneDocument(document: MutableLspDocument): LspDocument {\n return {\n uri: document.uri,\n languageId: document.languageId,\n version: document.version,\n textSnapshot: document.textSnapshot,\n lineStarts: document.lineStarts,\n }\n}\n\nfunction documentSnapshot(document: MutableLspDocument): LspTextDocumentSnapshot {\n return {\n textSnapshot: document.textSnapshot,\n lineStarts: document.lineStarts,\n }\n}\n\nfunction sameSourceTuple(\n document: MutableLspDocument,\n source: { readonly sourceRevision: number; readonly sourceSegment: object },\n): boolean {\n return (\n document.sourceRevision === source.sourceRevision &&\n document.sourceSegment === source.sourceSegment\n )\n}\n\nfunction adoptDuplicateSource(\n document: MutableLspDocument,\n options: LspWorkspaceSnapshotEditOptions,\n): LspDocument {\n if (document.textSnapshot !== options.textSnapshot) {\n throw new Error('A duplicate LSP source tuple must retain the exact text snapshot.')\n }\n if (\n options.logicalRevisionCount !== 0 &&\n options.logicalRevisionCount !== document.sourceLogicalRevisionCount\n ) {\n throw new Error('A duplicate LSP source tuple must retain its logical revision count.')\n }\n return cloneDocument(document)\n}\n\nfunction assertForwardSourcePoint(\n document: MutableLspDocument,\n source: { readonly sourceRevision: number; readonly sourceSegment: object },\n): void {\n if (document.sourceSegment !== source.sourceSegment) return\n if (source.sourceRevision > document.sourceRevision) return\n throw new Error('An LSP source revision must advance within one source segment.')\n}\n\nfunction assertLogicalRevisionCount(count: number): void {\n if (Number.isSafeInteger(count) && count >= 0) return\n throw new RangeError('logicalRevisionCount must be a safe non-negative integer.')\n}\n\nfunction assertSourceRevision(revision: number): void {\n if (Number.isSafeInteger(revision) && revision >= 0) return\n throw new RangeError('sourceRevision must be a safe non-negative integer.')\n}\n\nfunction assertSourceTextVersion(version: number): void {\n if (Number.isSafeInteger(version) && version >= 0) return\n throw new RangeError('sourceTextVersion must be a safe non-negative integer.')\n}\n\nfunction assertTransitionTargetAvailable(\n target: MutableLspDocument | undefined,\n source: MutableLspDocument,\n uri: lsp.DocumentUri,\n): void {\n if (!target || target === source) return\n throw new Error(`LSP document URI transition target is already open: ${uri}`)\n}\n\nfunction assertTransitionSourcePoint(\n document: MutableLspDocument,\n options: LspDocumentTransitionOptions,\n): void {\n if (document.textSnapshot !== options.textSnapshot) {\n throw new Error('An LSP document URI transition must retain the exact synchronized snapshot.')\n }\n if (document.sourceRevision === options.sourceRevision) return\n throw new Error('An LSP document URI transition must retain the synchronized source revision.')\n}\n\nexport function arrayLspLineStarts(lineStarts: readonly number[]): LspLineStarts {\n return {\n length: lineStarts.length,\n at: (index) => lineStarts[index],\n indexForOffset: (offset) => arrayRowForOffset(lineStarts, offset),\n toArray: () => lineStarts,\n }\n}\n\nfunction arrayRowForOffset(lineStarts: readonly number[], offset: number): number {\n let low = 0\n let high = lineStarts.length - 1\n let row = 0\n while (low <= high) {\n const middle = (low + high) >> 1\n if ((lineStarts[middle] ?? 0) <= offset) {\n row = middle\n low = middle + 1\n continue\n }\n high = middle - 1\n }\n return row\n}\n\nregisterDefaultLspWorkspaceFactory(() => new LspWorkspace())\n"],"mappings":";;AAkCA,IAAa,eAAb,MAA0B;CACxB,8BAA+B,IAAI,IAGjC;CACF,iCAAkC,IAAI,IAAyC;CAC/E,gCAAiC,IAAI,IAA6B;CAClE,SAAgD;CAEhD,IAAW,YAAoC;EAC7C,OAAO,MAAM,KAAK,KAAK,eAAe,OAAO,CAAC,CAAC,CAAC,IAAI,aAAa;CACnE;CAEA,aAAoB,QAAsC;EACxD,KAAK,SAAS;CAChB;CAEA,qBACE,SAC+B;EAC/B,qBAAqB,QAAQ,cAAc;EAC3C,MAAM,OAAO,KAAK,eAAe,IAAI,QAAQ,GAAG;EAChD,IAAI,MAAM,OAAO,KAAK,mBAAmB,MAAM,OAAO;EAEtD,MAAM,WAA+B;GACnC,YAAY,QAAQ;GACpB,YAAY,QAAQ;GACpB,4BAA4B;GAC5B,gBAAgB,QAAQ;GACxB,eAAe,QAAQ;GACvB,cAAc,QAAQ;GACtB,KAAK,QAAQ;GACb,SAAS,KAAK,eAAe,QAAQ,KAAK,CAAC;EAC7C;EACA,KAAK,eAAe,IAAI,QAAQ,KAAK,QAAQ;EAC7C,MAAM,SAAS,KAAK,eAAe,UAAU,QAAQ,oBAAoB;EACzE,KAAK,QAAQ,gBAAgB,cAAc,QAAQ,CAAC;EACpD,OAAO;CACT;CAEA,uBACE,KACA,SACa;EACb,MAAM,WAAW,KAAK,gBAAgB,GAAG;EACzC,2BAA2B,QAAQ,oBAAoB;EACvD,qBAAqB,QAAQ,cAAc;EAC3C,IAAI,gBAAgB,UAAU,OAAO,GAAG,OAAO,qBAAqB,UAAU,OAAO;EACrF,IAAI,QAAQ,yBAAyB,GACnC,MAAM,IAAI,MAAM,uEAAuE;EAEzF,yBAAyB,UAAU,OAAO;EAE1C,MAAM,cAAc,KAAK,eA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M,IAAI,MAAM,uDAAuD,KAAK;AAC9E;AAEA,SAAS,4BACP,UACA,SACM;CACN,IAAI,SAAS,iBAAiB,QAAQ,cACpC,MAAM,IAAI,MAAM,6EAA6E;CAE/F,IAAI,SAAS,mBAAmB,QAAQ,gBAAgB;CACxD,MAAM,IAAI,MAAM,8EAA8E;AAChG;AAEA,SAAgB,mBAAmB,YAA8C;CAC/E,OAAO;EACL,QAAQ,WAAW;EACnB,KAAK,UAAU,WAAW;EAC1B,iBAAiB,WAAW,kBAAkB,YAAY,MAAM;EAChE,eAAe;CACjB;AACF;AAEA,SAAS,kBAAkB,YAA+B,QAAwB;CAChF,IAAI,MAAM;CACV,IAAI,OAAO,WAAW,SAAS;CAC/B,IAAI,MAAM;CACV,OAAO,OAAO,MAAM;EAClB,MAAM,SAAU,MAAM,QAAS;EAC/B,KAAK,WAAW,WAAW,MAAM,QAAQ;GACvC,MAAM;GACN,MAAM,SAAS;GACf;EACF;EACA,OAAO,SAAS;CAClB;CACA,OAAO;AACT;AAEA,yCAAyC,IAAI,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"workspace.js","names":[],"sources":["../src/workspace.ts"],"sourcesContent":["import type * as lsp from 'vscode-languageserver-protocol'\nimport type {\n LspDocument,\n LspDocumentOpenSnapshotOptions,\n LspDocumentOpenSnapshotResult,\n LspDocumentTransitionOptions,\n LspDocumentTransitionNotification,\n LspDocumentTransitionResult,\n LspLineStarts,\n LspTextDocumentSnapshot,\n LspTextSnapshot,\n LspWorkspaceDocumentAttachment,\n LspWorkspaceSnapshotEditOptions,\n LspWorkspaceSyncTarget,\n LspWorkspaceUnchangedSourceOptions,\n LspPreparedDocumentSource,\n LspDocumentSourcePreparation,\n} from './types'\nimport { registerDefaultLspWorkspaceFactory } from './workspaceFactory'\n\ntype MutableLspDocument = {\n languageId: string\n lineStarts: LspLineStarts\n sourceLogicalRevisionCount: number\n sourceRevision: number\n sourceSegment: object\n textSnapshot: LspTextSnapshot\n uri: lsp.DocumentUri\n version: number\n}\n\ntype WorkspaceDocumentAttachmentRecord = {\n readonly document: MutableLspDocument\n readonly onDocumentTransition?: (transition: LspDocumentTransitionNotification) => void\n}\ntype DocumentSourceRegistration = {\n readonly uri: string\n readonly runtimeSessionId: string\n prepare(): LspPreparedDocumentSource | Promise<LspPreparedDocumentSource>\n}\n\nexport class LspWorkspace {\n private readonly attachments = new Map<\n LspWorkspaceDocumentAttachment,\n WorkspaceDocumentAttachmentRecord\n >()\n private readonly documentsByUri = new Map<lsp.DocumentUri, MutableLspDocument>()\n private readonly versionsByUri = new Map<lsp.DocumentUri, number>()\n private client: LspWorkspaceSyncTarget | null = null\n private readonly sourceReadiness = new Map<string, Set<DocumentSourceRegistration>>()\n\n public registerDocumentSource(registration: DocumentSourceRegistration): () => void {\n const entries =\n this.sourceReadiness.get(registration.uri) ?? new Set<DocumentSourceRegistration>()\n entries.add(registration)\n this.sourceReadiness.set(registration.uri, entries)\n return () => {\n entries.delete(registration)\n if (entries.size === 0) this.sourceReadiness.delete(registration.uri)\n }\n }\n\n public prepareDocumentRequest(uri: string, signal?: AbortSignal): LspDocumentSourcePreparation {\n const entries = this.sourceReadiness.get(uri)\n if (!entries?.size) return { kind: 'unmanaged' }\n const groups = new Map<\n string,\n (LspPreparedDocumentSource | Promise<LspPreparedDocumentSource>)[]\n >()\n for (const entry of entries) {\n const prepared = entry.prepare()\n if (prepared instanceof Promise) void prepared.catch(() => undefined)\n const peers = groups.get(entry.runtimeSessionId) ?? []\n peers.push(prepared)\n groups.set(entry.runtimeSessionId, peers)\n }\n const reads = Array.from(groups.values(), currentSourcePeer)\n if (reads.every((read) => read !== null))\n return { kind: 'ready', read: requireCurrentSource(reads) }\n const ready = Promise.all(Array.from(groups.values(), waitForSourcePeer)).then(\n requireCurrentSource,\n )\n return { kind: 'pending', ready: signal ? waitForSourceSignal(ready, signal) : ready }\n }\n\n public get documents(): readonly LspDocument[] {\n return Array.from(this.documentsByUri.values(), cloneDocument)\n }\n\n public attachClient(client: LspWorkspaceSyncTarget): void {\n this.client = client\n }\n\n public openDocumentSnapshot(\n options: LspDocumentOpenSnapshotOptions,\n ): LspDocumentOpenSnapshotResult {\n assertSourceRevision(options.sourceRevision)\n const open = this.documentsByUri.get(options.uri)\n if (open) return this.attachOpenDocument(open, options)\n\n const document: MutableLspDocument = {\n languageId: options.languageId,\n lineStarts: options.lineStarts,\n sourceLogicalRevisionCount: 0,\n sourceRevision: options.sourceRevision,\n sourceSegment: options.sourceSegment,\n textSnapshot: options.textSnapshot,\n uri: options.uri,\n version: this.nextVersion(options.uri, 1),\n }\n this.client?.didOpenDocument(cloneDocument(document))\n this.versionsByUri.set(options.uri, document.version)\n this.documentsByUri.set(options.uri, document)\n const result = this.attachDocument(document, options.onDocumentTransition)\n return result\n }\n\n public updateDocumentSnapshot(\n uri: lsp.DocumentUri,\n options: LspWorkspaceSnapshotEditOptions,\n ): LspDocument {\n const document = this.requireDocument(uri)\n assertLogicalRevisionCount(options.logicalRevisionCount)\n assertSourceRevision(options.sourceRevision)\n if (sameSourceTuple(document, options)) return adoptDuplicateSource(document, options)\n if (options.logicalRevisionCount === 0) {\n throw new Error('A new LSP document source requires a positive logical revision count.')\n }\n assertForwardSourcePoint(document, options)\n\n const nextVersion = this.nextVersion(uri, options.logicalRevisionCount)\n const previousSnapshot = documentSnapshot(document)\n const nextDocument: MutableLspDocument = {\n ...document,\n textSnapshot: options.textSnapshot,\n lineStarts: options.lineStarts,\n sourceLogicalRevisionCount: options.logicalRevisionCount,\n sourceRevision: options.sourceRevision,\n sourceSegment: options.sourceSegment,\n version: nextVersion,\n }\n this.client?.didChangeDocument(cloneDocument(nextDocument), {\n edits: options.edits ?? [],\n previousSnapshot,\n })\n Object.assign(document, nextDocument)\n this.versionsByUri.set(uri, nextVersion)\n return cloneDocument(document)\n }\n\n public adoptUnchangedDocumentSource(\n uri: lsp.DocumentUri,\n options: LspWorkspaceUnchangedSourceOptions,\n ): LspDocument {\n const document = this.requireDocument(uri)\n assertSourceRevision(options.sourceRevision)\n if (options.textSnapshot !== document.textSnapshot) {\n throw new Error('An unchanged LSP source must retain the exact workspace text snapshot.')\n }\n if (sameSourceTuple(document, options)) return cloneDocument(document)\n assertForwardSourcePoint(document, options)\n\n document.sourceRevision = options.sourceRevision\n document.sourceSegment = options.sourceSegment\n document.sourceLogicalRevisionCount = 0\n return cloneDocument(document)\n }\n\n public transitionDocumentUri(\n attachment: LspWorkspaceDocumentAttachment,\n options: LspDocumentTransitionOptions,\n ): LspDocumentTransitionResult {\n const record = this.requireAttachment(attachment)\n const document = record.document\n if (document.uri === options.uri) return this.adoptCompletedTransition(document, options)\n\n assertSourceRevision(options.sourceRevision)\n assertSourceTextVersion(options.sourceTextVersion)\n assertTransitionTargetAvailable(this.documentsByUri.get(options.uri), document, options.uri)\n assertTransitionSourcePoint(document, options)\n if (document.sourceSegment === options.sourceSegment) {\n throw new Error('An LSP document URI transition requires a rotated source segment.')\n }\n\n const nextVersion = this.nextVersion(options.uri, 1)\n const previousDocument = cloneDocument(document)\n const nextState: MutableLspDocument = {\n uri: options.uri,\n languageId: options.languageId,\n textSnapshot: options.textSnapshot,\n lineStarts: options.lineStarts,\n sourceLogicalRevisionCount: 0,\n sourceRevision: options.sourceRevision,\n sourceSegment: options.sourceSegment,\n version: nextVersion,\n }\n const nextDocument = cloneDocument(nextState)\n this.client?.didCloseDocument(previousDocument)\n this.client?.didOpenDocument(nextDocument)\n this.documentsByUri.delete(document.uri)\n Object.assign(document, nextState)\n this.versionsByUri.set(options.uri, nextVersion)\n this.documentsByUri.set(options.uri, document)\n this.notifyTransitionedAttachments(document, options.sourceTextVersion)\n return { document: nextDocument, previousDocument }\n }\n\n public closeDocument(attachment: LspWorkspaceDocumentAttachment): void {\n const record = this.attachments.get(attachment)\n if (!record) return\n\n this.attachments.delete(attachment)\n if (this.hasAttachment(record.document)) return\n\n this.documentsByUri.delete(record.document.uri)\n this.client?.didCloseDocument(cloneDocument(record.document))\n }\n\n public saveDocument(uri: lsp.DocumentUri): Promise<void> {\n const ready = this.prepareDocumentRequest(uri)\n if (ready.kind === 'pending') return ready.ready.then((read) => this.savePreparedDocument(read))\n if (ready.kind === 'ready') this.savePreparedDocument(ready.read)\n else this.saveAcceptedDocument(uri)\n return Promise.resolve()\n }\n\n private savePreparedDocument(read: LspPreparedDocumentSource): void {\n if (!read.isCurrent())\n throw new DOMException('Language-server save source was retired', 'AbortError')\n this.client?.didSaveDocument(read.document)\n }\n\n private saveAcceptedDocument(uri: lsp.DocumentUri): void {\n const document = this.documentsByUri.get(uri)\n if (!document) return\n this.client?.didSaveDocument(cloneDocument(document))\n }\n\n public getDocument(uri: lsp.DocumentUri): LspDocument | null {\n const document = this.documentsByUri.get(uri)\n return document ? cloneDocument(document) : null\n }\n\n public connected(): void {\n for (const document of this.documentsByUri.values()) {\n this.client?.didOpenDocument(cloneDocument(document))\n }\n }\n\n public disconnected(): void {\n return\n }\n\n private attachOpenDocument(\n document: MutableLspDocument,\n options: LspDocumentOpenSnapshotOptions,\n ): LspDocumentOpenSnapshotResult {\n if (document.languageId !== options.languageId) {\n throw new Error(\n `LSP document open as ${document.languageId}, reopened as ${options.languageId}: ${options.uri}`,\n )\n }\n if (!sameSourceTuple(document, options) || document.textSnapshot !== options.textSnapshot) {\n throw new Error('A second LSP document attachment must adopt the exact shared source point.')\n }\n return this.attachDocument(document, options.onDocumentTransition)\n }\n\n private attachDocument(\n document: MutableLspDocument,\n onDocumentTransition: ((transition: LspDocumentTransitionNotification) => void) | undefined,\n ): LspDocumentOpenSnapshotResult {\n const attachment = Object.freeze({}) as LspWorkspaceDocumentAttachment\n this.attachments.set(attachment, { document, onDocumentTransition })\n return { attachment, document: cloneDocument(document) }\n }\n\n private adoptCompletedTransition(\n document: MutableLspDocument,\n options: LspDocumentTransitionOptions,\n ): LspDocumentTransitionResult {\n if (document.languageId !== options.languageId) {\n throw new Error('An adopted LSP URI transition must retain the shared language identifier.')\n }\n if (document.textSnapshot !== options.textSnapshot || !sameSourceTuple(document, options)) {\n throw new Error('An adopted LSP URI transition must retain the exact shared source point.')\n }\n\n const current = cloneDocument(document)\n return { document: current, previousDocument: current }\n }\n\n private notifyTransitionedAttachments(\n document: MutableLspDocument,\n sourceTextVersion: number,\n ): void {\n for (const record of this.attachments.values()) {\n if (record.document !== document) continue\n record.onDocumentTransition?.({\n document: cloneDocument(document),\n sourceRevision: document.sourceRevision,\n sourceSegment: document.sourceSegment,\n sourceTextVersion,\n })\n }\n }\n\n private hasAttachment(document: MutableLspDocument): boolean {\n for (const record of this.attachments.values()) {\n if (record.document === document) return true\n }\n return false\n }\n\n private nextVersion(uri: lsp.DocumentUri, count: number): number {\n const version = (this.versionsByUri.get(uri) ?? -1) + count\n if (!Number.isSafeInteger(version) || version < 0) {\n throw new RangeError(`LSP document version exceeds the safe integer range: ${uri}`)\n }\n return version\n }\n\n private requireDocument(uri: lsp.DocumentUri): MutableLspDocument {\n const document = this.documentsByUri.get(uri)\n if (document) return document\n throw new Error(`LSP document is not open: ${uri}`)\n }\n\n private requireAttachment(\n attachment: LspWorkspaceDocumentAttachment,\n ): WorkspaceDocumentAttachmentRecord {\n const record = this.attachments.get(attachment)\n if (record) return record\n throw new Error('LSP workspace document attachment is closed or belongs to another workspace.')\n }\n}\n\nfunction currentSourcePeer(\n peers: readonly (LspPreparedDocumentSource | Promise<LspPreparedDocumentSource>)[],\n): LspPreparedDocumentSource | null {\n return (\n peers.find(\n (read): read is LspPreparedDocumentSource => !(read instanceof Promise) && read.isCurrent(),\n ) ?? null\n )\n}\n\nasync function waitForSourcePeer(\n peers: readonly (LspPreparedDocumentSource | Promise<LspPreparedDocumentSource>)[],\n): Promise<LspPreparedDocumentSource> {\n const results = await Promise.allSettled(peers)\n const accepted = results.find(\n (result): result is PromiseFulfilledResult<LspPreparedDocumentSource> =>\n result.status === 'fulfilled' && result.value.isCurrent(),\n )\n if (accepted) return accepted.value\n const rejected = results.find((result) => result.status === 'rejected')\n if (rejected?.status === 'rejected') throw rejected.reason\n throw new DOMException('Language-server source interest was retired', 'AbortError')\n}\n\nfunction requireCurrentSource(\n reads: readonly (LspPreparedDocumentSource | null)[],\n): LspPreparedDocumentSource {\n const first = reads[0]\n const isCurrent = () => reads.every((read) => read !== null && read.isCurrent())\n if (!first || !isCurrent())\n throw new DOMException('Language-server source was superseded', 'AbortError')\n return { document: first.document, isCurrent }\n}\n\nfunction waitForSourceSignal(\n ready: Promise<LspPreparedDocumentSource>,\n signal: AbortSignal,\n): Promise<LspPreparedDocumentSource> {\n return new Promise((resolve, reject) => {\n const abort = () => reject(signal.reason)\n if (signal.aborted) abort()\n else signal.addEventListener('abort', abort, { once: true })\n void ready.then(resolve, reject).finally(() => signal.removeEventListener('abort', abort))\n })\n}\n\nfunction cloneDocument(document: MutableLspDocument): LspDocument {\n return {\n uri: document.uri,\n languageId: document.languageId,\n version: document.version,\n textSnapshot: document.textSnapshot,\n lineStarts: document.lineStarts,\n sourceRevision: document.sourceRevision,\n sourceSegment: document.sourceSegment,\n }\n}\n\nfunction documentSnapshot(document: MutableLspDocument): LspTextDocumentSnapshot {\n return {\n textSnapshot: document.textSnapshot,\n lineStarts: document.lineStarts,\n }\n}\n\nfunction sameSourceTuple(\n document: MutableLspDocument,\n source: { readonly sourceRevision: number; readonly sourceSegment: object },\n): boolean {\n return (\n document.sourceRevision === source.sourceRevision &&\n document.sourceSegment === source.sourceSegment\n )\n}\n\nfunction adoptDuplicateSource(\n document: MutableLspDocument,\n options: LspWorkspaceSnapshotEditOptions,\n): LspDocument {\n if (document.textSnapshot !== options.textSnapshot) {\n throw new Error('A duplicate LSP source tuple must retain the exact text snapshot.')\n }\n if (\n options.logicalRevisionCount !== 0 &&\n options.logicalRevisionCount !== document.sourceLogicalRevisionCount\n ) {\n throw new Error('A duplicate LSP source tuple must retain its logical revision count.')\n }\n return cloneDocument(document)\n}\n\nfunction assertForwardSourcePoint(\n document: MutableLspDocument,\n source: { readonly sourceRevision: number; readonly sourceSegment: object },\n): void {\n if (document.sourceSegment !== source.sourceSegment) return\n if (source.sourceRevision > document.sourceRevision) return\n throw new Error('An LSP source revision must advance within one source segment.')\n}\n\nfunction assertLogicalRevisionCount(count: number): void {\n if (Number.isSafeInteger(count) && count >= 0) return\n throw new RangeError('logicalRevisionCount must be a safe non-negative integer.')\n}\n\nfunction assertSourceRevision(revision: number): void {\n if (Number.isSafeInteger(revision) && revision >= 0) return\n throw new RangeError('sourceRevision must be a safe non-negative integer.')\n}\n\nfunction assertSourceTextVersion(version: number): void {\n if (Number.isSafeInteger(version) && version >= 0) return\n throw new RangeError('sourceTextVersion must be a safe non-negative integer.')\n}\n\nfunction assertTransitionTargetAvailable(\n target: MutableLspDocument | undefined,\n source: MutableLspDocument,\n uri: lsp.DocumentUri,\n): void {\n if (!target || target === source) return\n throw new Error(`LSP document URI transition target is already open: ${uri}`)\n}\n\nfunction assertTransitionSourcePoint(\n document: MutableLspDocument,\n options: LspDocumentTransitionOptions,\n): void {\n if (document.textSnapshot !== options.textSnapshot) {\n throw new Error('An LSP document URI transition must retain the exact synchronized snapshot.')\n }\n if (document.sourceRevision === options.sourceRevision) return\n throw new Error('An LSP document URI transition must retain the synchronized source revision.')\n}\n\nexport function arrayLspLineStarts(lineStarts: readonly number[]): LspLineStarts {\n return {\n length: lineStarts.length,\n at: (index) => lineStarts[index],\n indexForOffset: (offset) => arrayRowForOffset(lineStarts, offset),\n toArray: () => lineStarts,\n }\n}\n\nfunction arrayRowForOffset(lineStarts: readonly number[], offset: number): number {\n let low = 0\n let high = lineStarts.length - 1\n let row = 0\n while (low <= high) {\n const middle = (low + high) >> 1\n if ((lineStarts[middle] ?? 0) <= offset) {\n row = middle\n low = middle + 1\n continue\n }\n high = middle - 1\n }\n return row\n}\n\nregisterDefaultLspWorkspaceFactory(() => new LspWorkspace())\n"],"mappings":";;AAyCA,IAAa,eAAb,MAA0B;CACxB,8BAA+B,IAAI,IAGjC;CACF,iCAAkC,IAAI,IAAyC;CAC/E,gCAAiC,IAAI,IAA6B;CAClE,S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ChG;AAEA,SAAgB,mBAAmB,YAA8C;CAC/E,OAAO;EACL,QAAQ,WAAW;EACnB,KAAK,UAAU,WAAW;EAC1B,iBAAiB,WAAW,kBAAkB,YAAY,MAAM;EAChE,eAAe;CACjB;AACF;AAEA,SAAS,kBAAkB,YAA+B,QAAwB;CAChF,IAAI,MAAM;CACV,IAAI,OAAO,WAAW,SAAS;CAC/B,IAAI,MAAM;CACV,OAAO,OAAO,MAAM;EAClB,MAAM,SAAU,MAAM,QAAS;EAC/B,KAAK,WAAW,WAAW,MAAM,QAAQ;GACvC,MAAM;GACN,MAAM,SAAS;GACf;EACF;EACA,OAAO,SAAS;CAClB;CACA,OAAO;AACT;AAEA,yCAAyC,IAAI,aAAa,CAAC"}
|
package/dist/workspaceFactory.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/workspaceFactory.ts
|
|
2
2
|
var defaultWorkspaceFactory = null;
|
|
3
3
|
function createDefaultLspWorkspace() {
|
|
4
4
|
if (defaultWorkspaceFactory) return defaultWorkspaceFactory();
|
|
@@ -7,7 +7,6 @@ function createDefaultLspWorkspace() {
|
|
|
7
7
|
function registerDefaultLspWorkspaceFactory(factory) {
|
|
8
8
|
defaultWorkspaceFactory = factory;
|
|
9
9
|
}
|
|
10
|
-
//#endregion
|
|
11
10
|
export { createDefaultLspWorkspace, registerDefaultLspWorkspaceFactory };
|
|
12
11
|
|
|
13
12
|
//# sourceMappingURL=workspaceFactory.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@singapore-editor/lsp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.10",
|
|
4
|
+
"description": "A Language Server Protocol client with WebSocket and worker transports.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"browser",
|
|
7
|
+
"editor",
|
|
8
|
+
"json-rpc",
|
|
9
|
+
"lsp",
|
|
10
|
+
"singapore",
|
|
11
|
+
"typescript"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://singapore.shaulavo.dev/docs/reference/api/lsp/overview/",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/ShaulLavo/singapore/issues"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/ShaulLavo/singapore.git"
|
|
21
|
+
},
|
|
4
22
|
"files": [
|
|
5
23
|
"README.md",
|
|
6
24
|
"dist"
|
|
@@ -26,12 +44,13 @@
|
|
|
26
44
|
},
|
|
27
45
|
"publishConfig": {
|
|
28
46
|
"access": "public",
|
|
47
|
+
"provenance": true,
|
|
29
48
|
"registry": "https://registry.npmjs.org/"
|
|
30
49
|
},
|
|
31
50
|
"scripts": {
|
|
32
51
|
"build": "bun ../../scripts/build-package.ts",
|
|
33
52
|
"test": "vitest run",
|
|
34
|
-
"typecheck": "
|
|
53
|
+
"typecheck": "tsc --noEmit",
|
|
35
54
|
"lint": "oxlint .",
|
|
36
55
|
"format": "oxfmt --write .",
|
|
37
56
|
"format:check": "oxfmt --check ."
|
|
@@ -41,11 +60,10 @@
|
|
|
41
60
|
},
|
|
42
61
|
"devDependencies": {
|
|
43
62
|
"@types/node": "^26.6.3",
|
|
44
|
-
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
45
63
|
"happy-dom": "^20.14.5",
|
|
46
64
|
"oxfmt": "0.70.0",
|
|
47
65
|
"oxlint": "1.85.0",
|
|
48
|
-
"typescript": "
|
|
49
|
-
"vitest": "
|
|
66
|
+
"typescript": "7.0.2",
|
|
67
|
+
"vitest": "5.0.2"
|
|
50
68
|
}
|
|
51
69
|
}
|