Skip to content

Commit

Permalink
Merge pull request #116 from kamecha/refacter/use-jsr-npm-prefix
Browse files Browse the repository at this point in the history
できるかぎりのjsr対応させた
  • Loading branch information
kamecha authored Nov 10, 2024
2 parents 9b85409 + 3348494 commit 004871a
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 47 deletions.
2 changes: 1 addition & 1 deletion denops/@ddc-sources/stamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { isDdcItem } from "../traqvim/type_check.ts";

type Params = Record<never, never>;

export class Source extends ddcVim.BaseSource<Params> {
export class Source extends ddcVimSource.BaseSource<Params> {
async onInit(args: ddcVimSource.OnInitArguments<Params>): Promise<void> {
const path = await vars.globals.get(args.denops, "traqvim#token_file_path");
assert(path, is.String);
Expand Down
10 changes: 8 additions & 2 deletions denops/@ddu-columns/channel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { dduVim, dduVimColumn, ensure, fn, is } from "../traqvim/deps.ts";
import { dduVimColumn, ensure, fn, is } from "../traqvim/deps.ts";

export type Params = {
collapsedParentIcon: string;
Expand All @@ -7,7 +7,13 @@ export type Params = {
indentationWidth: number;
};

export class Column extends dduVim.BaseColumn<Params> {
export class Column extends dduVimColumn.BaseColumn<Params> {
getBaseText(
args: dduVimColumn.GetBaseTextArguments<Params>,
): string | Promise<string> {
// TODO: どういう意図なのかを理解して、適切に設定しときたい
return args.item.word;
}
getLength(
args: dduVimColumn.GetLengthArguments<Params>,
): Promise<number> {
Expand Down
8 changes: 5 additions & 3 deletions denops/@ddu-kinds/channel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {
as,
assert,
dduVim,
dduVimKind,
Denops,
ensure,
is,
Expand Down Expand Up @@ -28,10 +30,10 @@ type OpenParams = {
};

const isOpenParams: Predicate<OpenParams> = is.ObjectOf({
command: is.OptionalOf(is.String),
command: as.Optional(is.String),
});

export class Kind extends dduVim.BaseKind<Params> {
export class Kind extends dduVimKind.BaseKind<Params> {
actions: dduVim.Actions<Params> = {
open: async (args: {
denops: Denops;
Expand Down Expand Up @@ -94,7 +96,7 @@ export class Kind extends dduVim.BaseKind<Params> {
ret,
is.ObjectOf({
body: is.ArrayOf(is.String),
position: is.OptionalOf(is.ObjectOf({
position: as.Optional(is.ObjectOf({
quote: is.ArrayOf(is.ObjectOf({
index: is.Number,
start: is.Number,
Expand Down
2 changes: 1 addition & 1 deletion denops/@ddu-sources/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { api } from "../traqvim/api.ts";

type Params = Record<never, never>;

export class Source extends dduVim.BaseSource<Params> {
export class Source extends dduVimSource.BaseSource<Params> {
kind = "channel";
async onInit(args: dduVimSource.OnInitArguments<Params>): Promise<void> {
const path = await vars.globals.get(args.denops, "traqvim#token_file_path");
Expand Down
2 changes: 1 addition & 1 deletion denops/@ddu-sources/channel_rec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Params = {
type: "all" | "unread";
};

export class Source extends dduVim.BaseSource<Params> {
export class Source extends dduVimSource.BaseSource<Params> {
kind = "channel";
async onInit(args: dduVimSource.OnInitArguments<Params>): Promise<void> {
const path = await vars.globals.get(args.denops, "traqvim#token_file_path");
Expand Down
37 changes: 17 additions & 20 deletions denops/traqvim/deps.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
export * as oauth2Client from "https://deno.land/x/[email protected]/mod.ts";
export * as oak from "https://deno.land/x/[email protected]/mod.ts";
export * as path from "https://deno.land/[email protected]/path/mod.ts";
export {
assert,
ensure,
is,
} from "https://deno.land/x/[email protected]/mod.ts";
export type { Predicate } from "https://deno.land/x/[email protected]/mod.ts";
export type { Denops } from "https://deno.land/x/[email protected]/mod.ts";
export * as fn from "https://deno.land/x/[email protected]/function/mod.ts";
export * as vars from "https://deno.land/x/[email protected]/variable/mod.ts";
export * as helper from "https://deno.land/x/[email protected]/helper/mod.ts";
export * as bufname from "https://deno.land/x/[email protected]/bufname/mod.ts";
export * as ddcVim from "https://deno.land/x/[email protected]/types.ts";
export * as ddcVimSource from "https://deno.land/x/[email protected]/base/source.ts";
export * as dduVim from "https://deno.land/x/[email protected]/types.ts";
export * as dduVimSource from "https://deno.land/x/[email protected]/base/source.ts";
export * as dduVimColumn from "https://deno.land/x/[email protected]/base/column.ts";
export * as traq from "https://esm.sh/@traptitech/[email protected]";
export * as oauth2Client from "https://deno.land/x/[email protected]/mod.ts";
export * as oak from "jsr:@oak/[email protected]";
export * as path from "jsr:@std/[email protected]";
export { as, assert, ensure, is } from "jsr:@core/[email protected]";
export type { Predicate } from "jsr:@core/[email protected]";
export type { Denops } from "jsr:@denops/[email protected]";
export * as fn from "jsr:@denops/[email protected]/function";
export * as vars from "jsr:@denops/[email protected]/variable";
export * as helper from "jsr:@denops/[email protected]/helper";
export * as bufname from "jsr:@denops/[email protected]/bufname";
export * as ddcVim from "jsr:@shougo/[email protected]/types";
export * as ddcVimSource from "jsr:@shougo/[email protected]/source";
export * as dduVim from "jsr:@shougo/[email protected]/types";
export * as dduVimKind from "jsr:@shougo/[email protected]/kind";
export * as dduVimSource from "jsr:@shougo/[email protected]/source";
export * as dduVimColumn from "jsr:@shougo/[email protected]/column";
export * as traq from "npm:@traptitech/[email protected]";
3 changes: 2 additions & 1 deletion denops/traqvim/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
sendMessage,
} from "./model.ts";
import {
as,
assert,
bufname,
Denops,
Expand Down Expand Up @@ -60,7 +61,7 @@ export async function main(denops: Denops) {
assert(fileId, is.String);
assert(
opts,
is.OptionalOf(is.ObjectOf({
as.Optional(is.ObjectOf({
maxWidth: is.Number,
maxHeight: is.Number,
})),
Expand Down
36 changes: 18 additions & 18 deletions denops/traqvim/type_check.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ddcVim, is, Predicate, traq } from "./deps.ts";
import { as, ddcVim, is, Predicate, traq } from "./deps.ts";
import { channelMessageOptions, Message } from "./type.d.ts";

const isPumHighlight: Predicate<ddcVim.PumHighlight> = is.ObjectOf({
Expand All @@ -11,13 +11,13 @@ const isPumHighlight: Predicate<ddcVim.PumHighlight> = is.ObjectOf({

export const isDdcItem: Predicate<ddcVim.Item> = is.ObjectOf({
word: is.String,
abbr: is.OptionalOf(is.String),
menu: is.OptionalOf(is.String),
info: is.OptionalOf(is.String),
kind: is.OptionalOf(is.String),
user_data: is.OptionalOf(is.Unknown),
highlights: is.OptionalOf(is.ArrayOf(isPumHighlight)),
columns: is.OptionalOf(is.RecordOf(is.String)),
abbr: as.Optional(is.String),
menu: as.Optional(is.String),
info: as.Optional(is.String),
kind: as.Optional(is.String),
user_data: as.Optional(is.Unknown),
highlights: as.Optional(is.ArrayOf(isPumHighlight)),
columns: as.Optional(is.RecordOf(is.String)),
});

export const isMessageStamp: Predicate<traq.MessageStamp> = is.ObjectOf({
Expand Down Expand Up @@ -60,28 +60,28 @@ export const isMessage: Predicate<Message> = is.ObjectOf({
threadId: is.UnionOf([is.String, is.Null]),

user: isUser,
position: is.OptionalOf(is.ObjectOf({
position: as.Optional(is.ObjectOf({
index: is.Number,
start: is.Number,
end: is.Number,
quote: is.OptionalOf(is.ArrayOf(is.ObjectOf({
quote: as.Optional(is.ArrayOf(is.ObjectOf({
index: is.Number,
start: is.Number,
end: is.Number,
}))),
})),
// quote?: Message[];
quote: is.OptionalOf(is.ArrayOf((x: unknown): x is Message => isMessage(x))),
quote: as.Optional(is.ArrayOf((x: unknown): x is Message => isMessage(x))),
});

export const isChannelMessageOptions: Predicate<channelMessageOptions> = is
.ObjectOf({
id: is.String,
channelPath: is.OptionalOf(is.String),
limit: is.OptionalOf(is.Number),
offset: is.OptionalOf(is.Number),
since: is.OptionalOf(is.String),
until: is.OptionalOf(is.String),
inclusive: is.OptionalOf(is.Boolean),
order: is.OptionalOf(is.LiteralOneOf(["asc", "desc"] as const)),
channelPath: as.Optional(is.String),
limit: as.Optional(is.Number),
offset: as.Optional(is.Number),
since: as.Optional(is.String),
until: as.Optional(is.String),
inclusive: as.Optional(is.Boolean),
order: as.Optional(is.LiteralOneOf(["asc", "desc"] as const)),
});

0 comments on commit 004871a

Please sign in to comment.