From 32f75a7bb7edab2b66b07279b402de5a3b447066 Mon Sep 17 00:00:00 2001 From: Alisue Date: Sat, 3 Aug 2024 18:27:01 +0900 Subject: [PATCH 1/2] =?UTF-8?q?jsmigemo=20=E3=82=92=20npm=20=E3=81=8B?= =?UTF-8?q?=E3=82=89=E3=82=A4=E3=83=B3=E3=83=9D=E3=83=BC=E3=83=88=E3=81=AB?= =?UTF-8?q?=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- denops/kensaku/migemo.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/denops/kensaku/migemo.ts b/denops/kensaku/migemo.ts index 925d7d0..00b0425 100644 --- a/denops/kensaku/migemo.ts +++ b/denops/kensaku/migemo.ts @@ -9,7 +9,7 @@ import * as path from "jsr:@std/path@^1.0.2"; import * as fs from "jsr:@std/fs@^1.0.0"; import * as batch from "jsr:@denops/std@^7.0.0/batch"; import * as vars from "jsr:@denops/std@^7.0.0/variable"; -import * as jsmigemo from "https://cdn.jsdelivr.net/npm/jsmigemo@0.4.8/dist/jsmigemo.min.mjs"; +import * as jsmigemo from "npm:jsmigemo@^0.4.8"; import { decompose, isKensakuRxop, KensakuRxop } from "./rxop.ts"; let migemo: jsmigemo.Migemo | undefined; From 16b07902a58cc77455f3d53087cc9c7525ce7a3e Mon Sep 17 00:00:00 2001 From: Alisue Date: Sat, 3 Aug 2024 18:28:00 +0900 Subject: [PATCH 2/2] =?UTF-8?q?unknownutil=20v4=20=E3=81=AB=E3=82=A2?= =?UTF-8?q?=E3=83=83=E3=83=97=E3=83=87=E3=83=BC=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- denops/kensaku/main.ts | 4 ++-- denops/kensaku/migemo.ts | 13 ++++--------- denops/kensaku/rxop.ts | 30 ++++++++++++------------------ 3 files changed, 18 insertions(+), 29 deletions(-) diff --git a/denops/kensaku/main.ts b/denops/kensaku/main.ts index 279a232..3b41a8e 100644 --- a/denops/kensaku/main.ts +++ b/denops/kensaku/main.ts @@ -1,5 +1,5 @@ import type { Denops } from "jsr:@denops/std@^7.0.0"; -import { assert, is } from "jsr:@core/unknownutil@^3.18.1"; +import { as, assert, is } from "jsr:@core/unknownutil@^4.0.0"; import { assertQueryOption, query, setRomanTable } from "./migemo.ts"; export function main(denops: Denops): void { @@ -23,4 +23,4 @@ export function main(denops: Denops): void { const isRomanTable = is.ArrayOf< [roman: string, hiragana: string, remain?: number] ->(is.ParametersOf([is.String, is.String, is.OptionalOf(is.Number)] as const)); +>(is.ParametersOf([is.String, is.String, as.Optional(is.Number)] as const)); diff --git a/denops/kensaku/migemo.ts b/denops/kensaku/migemo.ts index 00b0425..49e7cfa 100644 --- a/denops/kensaku/migemo.ts +++ b/denops/kensaku/migemo.ts @@ -1,10 +1,5 @@ import type { Denops } from "jsr:@denops/std@^7.0.0"; -import { - assert, - isRecord, - isString, - isUndefined, -} from "jsr:@core/unknownutil@^3.18.1"; +import { assert, is } from "jsr:@core/unknownutil@^4.0.0"; import * as path from "jsr:@std/path@^1.0.2"; import * as fs from "jsr:@std/fs@^1.0.0"; import * as batch from "jsr:@denops/std@^7.0.0/batch"; @@ -32,8 +27,8 @@ async function init(denops: Denops): Promise { vars.g.get(denops, "kensaku_dictionary_cache"), ], ); - assert(dictionaryUrl, isString); - assert(dictionaryCache, isString); + assert(dictionaryUrl, is.String); + assert(dictionaryCache, is.String); const data = await readOrFetch(dictionaryUrl, dictionaryCache); const dict = new jsmigemo.CompactDictionary(data.buffer); @@ -70,7 +65,7 @@ export type QueryOption = { }; export function assertQueryOption(x: unknown): asserts x is QueryOption { - if (!isRecord(x) || (!isUndefined(x.rxop) && !isKensakuRxop(x.rxop))) { + if (!is.Record(x) || (!is.Undefined(x.rxop) && !isKensakuRxop(x.rxop))) { throw new Error("Not a QueryOption"); } } diff --git a/denops/kensaku/rxop.ts b/denops/kensaku/rxop.ts index c3da557..63847b2 100644 --- a/denops/kensaku/rxop.ts +++ b/denops/kensaku/rxop.ts @@ -1,10 +1,4 @@ -import { - isArray, - isArrayOf, - isRecord, - isString, - isUndefined, -} from "jsr:@core/unknownutil@^3.18.1"; +import { is } from "jsr:@core/unknownutil@^4.0.0"; // https://github.com/oguna/jsmigemo/blob/d33052525dcb4bacdddc1e0b1f39a3675831ec92/src/TernaryRegexGenerator.ts#L127 const defaultEscape = "\\.[]{}()*+-?^$|"; @@ -49,25 +43,25 @@ export type KensakuRxop = }; export function isKensakuRxop(x: unknown): x is KensakuRxop { - if (isArrayOf(isString)(x)) { + if (is.ArrayOf(is.String)(x)) { return x.length === 6 || x.length === 7; - } else if (isRecord(x)) { + } else if (is.Record(x)) { return ( - (isUndefined(x.prefix) || isString(x.prefix)) && - isString(x.or) && - isString(x.startGroup) && - isString(x.endGroup) && - isString(x.startClass) && - isString(x.endClass) && - isString(x.newline) && - isString(x.escape) + (is.Undefined(x.prefix) || is.String(x.prefix)) && + is.String(x.or) && + is.String(x.startGroup) && + is.String(x.endGroup) && + is.String(x.startClass) && + is.String(x.endClass) && + is.String(x.newline) && + is.String(x.escape) ); } return false; } export function decompose(rxop: KensakuRxop): [string, Rxop] { - if (isArray(rxop)) { + if (is.Array(rxop)) { if (rxop.length === 6) { return ["", [...rxop, defaultEscape]]; } else {