diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b5dc918..9fb40a90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +# [1.1.0](https://github.com/atom-ide-community/atom-ide-base/compare/v1.0.0...v1.1.0) (2020-07-21) + + +### Bug Fixes + +* add description to package.json ([e94505a](https://github.com/atom-ide-community/atom-ide-base/commit/e94505a63658299103c931b3f83baa64c7a13cd6)) +* add readme about the types ([18eb027](https://github.com/atom-ide-community/atom-ide-base/commit/18eb027b6eba2e0ceffba3f0ca27a259ac35f088)) +* add types scripts ([b99f92b](https://github.com/atom-ide-community/atom-ide-base/commit/b99f92bb0f01557989bde9ccf07b52341c034f85)) +* rename index.d.ts ([7d2e5ed](https://github.com/atom-ide-community/atom-ide-base/commit/7d2e5ed91b894dee3934f8eb6ba7bd64be17a662)) +* use normal typescript syntax ([fe40ec2](https://github.com/atom-ide-community/atom-ide-base/commit/fe40ec2d6c0a193899bb5d5308ab45ceb8498295)) + + +### Features + +* add npm release to allow using types ([806b9a5](https://github.com/atom-ide-community/atom-ide-base/commit/806b9a51f6aa39dfb417afc5c34bcfb3c1dfb912)) + # 1.0.0 (2020-07-21) diff --git a/dist/busy-signal.d.ts b/dist/busy-signal.d.ts new file mode 100644 index 00000000..24dea561 --- /dev/null +++ b/dist/busy-signal.d.ts @@ -0,0 +1,45 @@ +// declare module "atom-ide-base" { + export interface BusySignalOptions { + // Can say that a busy signal will only appear when a given file is open. + // Default = `null`, meaning the busy signal applies to all files. + onlyForFile?: string; + // Is user waiting for computer to finish a task? (traditional busy spinner) + // or is the computer waiting for user to finish a task? (action required) + // Default = spinner. + waitingFor?: "computer" | "user"; + // Debounce it? default = `true` for busy-signal, and false for action-required. + debounce?: boolean; + // If `onClick` is set, then the tooltip will be clickable. Default = `null`. + onDidClick?: () => void; + // If set to `true`, the busy signal tooltip will be immediately revealed + // when it first becomes visible (without explicit mouse interaction). + revealTooltip?: boolean; + } + + export interface BusySignalService { + // Activates the busy signal with the given title and returns the promise + // from the provided callback. + // The busy signal automatically deactivates when the returned promise + // either resolves or rejects. + reportBusyWhile( + title: string, + f: () => Promise, + options?: BusySignalOptions + ): Promise; + + // Activates the busy signal. Set the title in the returned BusySignal + // object (you can update the title multiple times) and dispose it when done. + reportBusy(title: string, options?: BusySignalOptions): BusyMessage; + + // This is a no-op. When someone consumes the busy service, they get back a + // reference to the single shared instance, so disposing of it would be wrong. + dispose(): void; + } + + export interface BusyMessage { + // You can set/update the title. + setTitle(title: string): void; + // Dispose of the signal when done to make it go away. + dispose(): void; + } +// } diff --git a/dist/code-actions.d.ts b/dist/code-actions.d.ts new file mode 100644 index 00000000..96be9a6e --- /dev/null +++ b/dist/code-actions.d.ts @@ -0,0 +1,31 @@ +import * as Atom from "atom"; +import { Message } from "atom/linter"; + + export interface CodeAction { + apply(): Promise; + getTitle(): Promise; + dispose(): void; + } + + export interface CodeActionProvider { + grammarScopes?: ReadonlyArray; + priority: number; + getCodeActions( + editor: Atom.TextEditor, + range: Atom.Range, + diagnostics: Message[] + ): Promise; + } + + /** + * atom-ide-base-code-actions provides a CodeActionFetcher which offers an API to + * request CodeActions from all CodeAction providers. For now, CodeActionFetcher + * can only fetch CodeActions for a Diagnostic. In the future, this API can be + * extended to provide a stream of CodeActions based on the cursor position. + */ + export interface CodeActionFetcher { + getCodeActionForDiagnostic: ( + diagnostic: Message, + editor: Atom.TextEditor + ) => Promise; + } diff --git a/dist/code-highlight.d.ts b/dist/code-highlight.d.ts new file mode 100644 index 00000000..74e76573 --- /dev/null +++ b/dist/code-highlight.d.ts @@ -0,0 +1,10 @@ +import * as Atom from "atom"; + + export interface CodeHighlightProvider { + priority: number; + grammarScopes: ReadonlyArray; + highlight( + editor: Atom.TextEditor, + bufferPosition: Atom.Point + ): Promise; + } diff --git a/dist/datatip.d.ts b/dist/datatip.d.ts new file mode 100644 index 00000000..00c66ff9 --- /dev/null +++ b/dist/datatip.d.ts @@ -0,0 +1,71 @@ +import * as Atom from "atom"; + + export interface DatatipService { + addProvider(provider: DatatipProvider): Atom.DisposableLike; + addModifierProvider(provider: ModifierDatatipProvider): Atom.DisposableLike; + createPinnedDataTip( + datatip: Datatip, + editor: Atom.TextEditor, + options?: PinnedDatatipOptions + ): Atom.DisposableLike; + } + + export interface PinnedDatatipOptions { + // Defaults to 'end-of-line'. + position?: PinnedDatatipPosition; + // Defaults to true. + showRangeHighlight?: boolean; + } + + export type PinnedDatatipPosition = "end-of-line" | "above-range"; + + export interface DatatipProvider { + priority: number; + grammarScopes?: ReadonlyArray; + // A unique name for the provider to be used for analytics. + // It is recommended that it be the name of the provider's package. + providerName: string; + datatip( + editor: Atom.TextEditor, + bufferPosition: Atom.Point + ): Promise; + } + + export interface ModifierDatatipProvider { + priority: number; + grammarScopes?: string[]; + providerName: string; + modifierDatatip( + editor: Atom.TextEditor, + bufferPosition: Atom.Point, + heldKeys: Set + ): Promise; + } + + export type AnyDatatipProvider = DatatipProvider | ModifierDatatipProvider; + + export type Datatip = + | { + markedStrings: MarkedString[]; + range: Atom.Range; + pinnable?: boolean; + } + | { + component: () => JSX.Element; // React component + range: Atom.Range; + pinnable?: boolean; + }; + + // Borrowed from the LSP API. + export type MarkedString = + | { + type: "markdown"; + value: string; + } + | { + type: "snippet"; + grammar: Atom.Grammar; + value: string; + }; + + export type ModifierKey = "metaKey" | "shiftKey" | "altKey" | "ctrlKey"; diff --git a/dist/definitions.d.ts b/dist/definitions.d.ts new file mode 100644 index 00000000..1b6e2f99 --- /dev/null +++ b/dist/definitions.d.ts @@ -0,0 +1,57 @@ +import * as Atom from "atom"; + + export interface Definition { + // Path of the file in which the definition is located. + path: string; + // First character of the definition's identifier. + // e.g. "F" in `class Foo {}` + position: Atom.Point; + // Optional: the range of the entire definition. + // e.g. "c" to "}" in `class Foo {}` + range?: Atom.Range; + // Optional: `name` and `projectRoot` can be provided to display a more human-readable title + // inside of Hyperclick when there are multiple definitions. + name?: string; + // If provided, `projectRoot` will be used to display a relativized version of `path`. + projectRoot?: string; + // `language` may be used by consumers to identify the source of definitions. + language: string; + } + + // Definition queries supply a point. + // The returned queryRange is the range within which the returned definition is valid. + // Typically queryRange spans the containing identifier around the query point. + // (If a null queryRange is returned, the range of the word containing the point is used.) + export interface DefinitionQueryResult { + queryRange: ReadonlyArray | null | undefined; + definitions: ReadonlyArray; // Must be non-empty. + } + + // Provides definitions for a set of language grammars. + export interface DefinitionProvider { + // If there are multiple providers for a given grammar, + // the one with the highest priority will be used. + priority: number; + grammarScopes: ReadonlyArray; + wordRegExp: RegExp | null | undefined; + // Obtains the definition in an editor at the given point. + // This should return null if no definition is available. + getDefinition: ( + editor: Atom.TextEditor, + position: Atom.Point + ) => Promise; + } + + export interface DefinitionPreviewProvider { + getDefinitionPreview( + definition: Definition + ): Promise< + | { + mime: string; + contents: string; + encoding: string; + } + | null + | undefined + >; + } diff --git a/dist/find-references.d.ts b/dist/find-references.d.ts new file mode 100644 index 00000000..e643b573 --- /dev/null +++ b/dist/find-references.d.ts @@ -0,0 +1,34 @@ +import * as Atom from "atom"; + + export interface FindReferencesProvider { + // Return true if your provider supports finding references for the provided Atom.TextEditor. + isEditorSupported(editor: Atom.TextEditor): Promise; + + // `findReferences` will only be called if `isEditorSupported` previously returned true + // for the given Atom.TextEditor. + findReferences( + editor: Atom.TextEditor, + position: Atom.Point + ): Promise; + } + + export interface Reference { + uri: string; // Nuclide URI of the file path + name: string | undefined | null; // name of calling method/function/symbol + range: Atom.Range; + } + + export interface FindReferencesData { + type: "data"; + baseUri: string; + referencedSymbolName: string; + references: Reference[]; + title?: string; // defaults to 'Symbol References' + } + + export interface FindReferencesError { + type: "error"; + message: string; + } + + export type FindReferencesReturn = FindReferencesData | FindReferencesError; diff --git a/dist/hyperclick.d.ts b/dist/hyperclick.d.ts new file mode 100644 index 00000000..5c8c30eb --- /dev/null +++ b/dist/hyperclick.d.ts @@ -0,0 +1,39 @@ +import * as Atom from "atom"; + + export interface HyperclickProvider { + // Use this to provide a suggestion for single-word matches. + // Optionally set `wordRegExp` to adjust word-matching. + getSuggestionForWord?: ( + textEditor: Atom.TextEditor, + text: string, + range: Atom.Range + ) => Promise; + + wordRegExp?: RegExp; + + // Use this to provide a suggestion if it can have non-contiguous ranges. + // A primary use-case for this is Objective-C methods. + getSuggestion?: ( + textEditor: Atom.TextEditor, + position: Atom.Point + ) => Promise; + + // Must be unique. Used for analytics. + providerName?: string; + + // The higher this is, the more precedence the provider gets. + priority: number; + + // Optionally, limit the set of grammar scopes the provider should apply to. + grammarScopes?: string[]; + } + + export interface HyperclickSuggestion { + // The range(s) to underline to provide as a visual cue for clicking. + range: Atom.Range | Atom.Range[]; + + // The function to call when the underlined text is clicked. + callback: + | (() => void) + | Array<{ rightLabel?: string; title: string; callback: () => void }>; + } diff --git a/dist/main.d.ts b/dist/main.d.ts new file mode 100644 index 00000000..5de49f4a --- /dev/null +++ b/dist/main.d.ts @@ -0,0 +1,12 @@ +// atom-ide +// https://github.com/atom-ide-community/atom-ide-base + +export * from "./busy-signal" +export * from "./code-actions" +export * from "./code-highlight" +export * from "./datatip" +export * from "./definitions" +export * from "./find-references" +export * from "./hyperclick" +export * from "./outline" +export * from "./sig-help" diff --git a/dist/outline.d.ts b/dist/outline.d.ts new file mode 100644 index 00000000..499a2e9a --- /dev/null +++ b/dist/outline.d.ts @@ -0,0 +1,71 @@ +import * as Atom from "atom"; + + export interface OutlineProvider { + name: string; + // If there are multiple providers for a given grammar, the one with the highest priority will be + // used. + priority: number; + grammarScopes: ReadonlyArray; + updateOnEdit?: boolean; + getOutline(editor: Atom.TextEditor): Promise; + } + + export interface OutlineTree { + icon?: string; // from Atom.Octicon (that type's not allowed over rpc so we use string) + kind?: OutlineTreeKind; // kind you can pass to the UI for theming + + // Must be one or the other. If both are present, tokenizedText is preferred. + plainText?: string; + tokenizedText?: TokenizedText; + + // If user has atom-ide-base-outline-view.nameOnly then representativeName is used instead. + representativeName?: string; + + startPosition: Atom.Point; + endPosition?: Atom.Point; + landingPosition?: Atom.Point; + children: OutlineTree[]; + } + + export interface Outline { + outlineTrees: OutlineTree[]; + } + + // Kind of outline tree - matches the names from the Language Server Protocol v2. + export type OutlineTreeKind = + | "file" + | "module" + | "namespace" + | "package" + | "class" + | "method" + | "property" + | "field" + | "constructor" + | "enum" + | "interface" + | "function" + | "variable" + | "constant" + | "string" + | "number" + | "boolean" + | "array"; + + export type TokenKind = + | "keyword" + | "class-name" + | "constructor" + | "method" + | "param" + | "string" + | "whitespace" + | "plain" + | "type"; + + export interface TextToken { + kind: TokenKind; + value: string; + } + + export type TokenizedText = TextToken[]; diff --git a/dist/sig-help.d.ts b/dist/sig-help.d.ts new file mode 100644 index 00000000..421422fc --- /dev/null +++ b/dist/sig-help.d.ts @@ -0,0 +1,34 @@ +import { DisposableLike, Point, TextEditor } from "atom"; + + export type SignatureHelpRegistry = ( + provider: SignatureHelpProvider + ) => DisposableLike; + + export interface SignatureHelpProvider { + priority: number; + grammarScopes: ReadonlyArray; + + triggerCharacters?: Set; + + getSignatureHelp( + editor: TextEditor, + point: Point + ): Promise; + } + + export interface SignatureHelp { + signatures: Signature[]; + activeSignature?: number; + activeParameter?: number; + } + + export interface Signature { + label: string; + documentation?: string; + parameters?: SignatureParameter[]; + } + + export interface SignatureParameter { + label: string; + documentation?: string; + } diff --git a/package-lock.json b/package-lock.json index 30a40238..f0e3e0ea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "atom-ide-base", - "version": "1.0.0", + "version": "1.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 8c7781fb..3554e10a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "atom-ide-base", "main": "dist/main.js", - "version": "1.0.0", + "version": "1.1.0", "author": "atom-ide-community", "description": "Atom IDE packages for Atom", "keywords": [