Skip to content

Commit

Permalink
Optimize types.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed Sep 4, 2024
1 parent 5cc7a90 commit 0b49606
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 32 deletions.
4 changes: 2 additions & 2 deletions denops/@ddu-sources/dpp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
type ActionFlags,
BaseSource,
type Item,
} from "jsr:@shougo/ddu-vim@5.0.0/types";
import type { ActionData } from "jsr:@shougo/ddu-kind-file@0.8.0";
} from "jsr:@shougo/ddu-vim@6.1.0/types";
import type { ActionData } from "jsr:@shougo/ddu-kind-file@0.9.0";

type Params = {
names: string[];
Expand Down
36 changes: 34 additions & 2 deletions denops/dpp/app.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { ContextBuilder } from "./context.ts";
import { Dpp } from "./dpp.ts";
import type { DppOptions } from "./types.ts";
import type {
BaseParams,
DppOptions,
ExtOptions,
Protocol,
ProtocolName,
} from "./types.ts";
import type { BaseExt } from "./base/ext.ts";
import { Loader } from "./loader.ts";
import { extAction } from "./ext.ts";
import { isDenoCacheIssueError } from "./utils.ts";
Expand Down Expand Up @@ -68,7 +75,6 @@ export const main: Entrypoint = (denops: Denops) => {
contextBuilder,
denops,
basePath,
dpp,
name,
});
//console.log(`${Date.now() - startTime} ms`);
Expand Down Expand Up @@ -99,5 +105,31 @@ export const main: Entrypoint = (denops: Denops) => {
throw e;
}
},
async getExt(
arg1: unknown,
): Promise<
[
BaseExt<BaseParams> | undefined,
ExtOptions,
BaseParams,
]
> {
const extName = ensure(arg1, is.String) as string;
const [_, options] = await contextBuilder.get(denops);

return await dpp.getExt(
denops,
options,
extName,
);
},
async getProtocols(): Promise<Record<ProtocolName, Protocol>> {
const [_, options] = await contextBuilder.get(denops);

return await dpp.getProtocols(
denops,
options,
);
},
};
};
2 changes: 1 addition & 1 deletion denops/dpp/dpp.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type {
ActionName,
BaseExt,
BaseParams,
Context,
DppOptions,
Expand All @@ -12,6 +11,7 @@ import type {
} from "./types.ts";
import type { Loader } from "./loader.ts";
import type { ConfigReturn } from "./base/config.ts";
import type { BaseExt } from "./base/ext.ts";
import { extAction, getExt, getProtocols } from "./ext.ts";
import {
convert2List,
Expand Down
6 changes: 2 additions & 4 deletions denops/dpp/ext.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import type {
ActionName,
BaseExt,
BaseParams,
BaseProtocol,
Context,
DppOptions,
ExtName,
Expand All @@ -20,8 +18,8 @@ import {
mergeProtocolParams,
} from "./context.ts";
import type { Loader } from "./loader.ts";
import { defaultExtOptions } from "./base/ext.ts";
import { defaultProtocolOptions } from "./base/protocol.ts";
import { type BaseExt, defaultExtOptions } from "./base/ext.ts";
import { type BaseProtocol, defaultProtocolOptions } from "./base/protocol.ts";
import { printError } from "./utils.ts";

import type { Denops } from "jsr:@denops/std@~7.1.0";
Expand Down
11 changes: 3 additions & 8 deletions denops/dpp/loader.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import type {
BaseExt,
BaseParams,
BaseProtocol,
DppExtType,
ExtName,
ProtocolName,
} from "./types.ts";
import type { BaseParams, DppExtType, ExtName, ProtocolName } from "./types.ts";
import type { BaseExt } from "./base/ext.ts";
import type { BaseProtocol } from "./base/protocol.ts";
import { isDenoCacheIssueError } from "./utils.ts";

import type { Denops } from "jsr:@denops/std@~7.1.0";
Expand Down
16 changes: 1 addition & 15 deletions denops/dpp/types.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
import type { BaseProtocol } from "./base/protocol.ts";
import type { Denops } from "jsr:@denops/std@~7.1.0";

export { BaseConfig } from "./base/config.ts";
export type {
ConfigArguments,
ConfigReturn,
MultipleHook,
} from "./base/config.ts";
export { BaseExt } from "./base/ext.ts";
export { BaseProtocol } from "./base/protocol.ts";
export type { Command } from "./base/protocol.ts";

export { ContextBuilder } from "./context.ts";

export { Dpp } from "./dpp.ts";
export type { Denops } from "jsr:@denops/std@~7.1.0";
import type { Denops } from "jsr:@denops/std@~7.1.0";

export type DppExtType = "ext" | "protocol";

Expand Down

0 comments on commit 0b49606

Please sign in to comment.