From 2b10b751bff84eaaf36099a0585cabd0478c2fd7 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Sun, 15 Sep 2024 12:22:47 +0900 Subject: [PATCH 1/5] Remove npm msgpack dependency --- denops/skkeleton/deps/dictionary.ts | 1 - denops/skkeleton/sources/deno_kv.ts | 5 +++-- denops/skkeleton/sources/skk_dictionary.ts | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/denops/skkeleton/deps/dictionary.ts b/denops/skkeleton/deps/dictionary.ts index 66007c90..138b6252 100644 --- a/denops/skkeleton/deps/dictionary.ts +++ b/denops/skkeleton/deps/dictionary.ts @@ -1,4 +1,3 @@ export * as yaml from "jsr:@std/yaml@~1.0.5"; -export * as msgpack from "npm:@msgpack/msgpack@3.0.0-beta2"; export { default as jsonschema } from "npm:jsonschema@1.4.1"; export { default as jisyoschema } from "https://cdn.jsdelivr.net/gh/skk-dict/jisyo/schema/jisyo.schema.v0.0.0.json" with { type: "json" }; diff --git a/denops/skkeleton/sources/deno_kv.ts b/denops/skkeleton/sources/deno_kv.ts index ca4f92f8..b485e82f 100644 --- a/denops/skkeleton/sources/deno_kv.ts +++ b/denops/skkeleton/sources/deno_kv.ts @@ -10,7 +10,8 @@ import { Source as BaseSource, wrapDictionary, } from "../dictionary.ts"; -import { jisyoschema, jsonschema, msgpack, yaml } from "../deps/dictionary.ts"; +import { jisyoschema, jsonschema, yaml } from "../deps/dictionary.ts"; +import { decode as msgpackDecode } from "jsr:@std/msgpack@~1.0.2/decode"; interface Jisyo { okuri_ari: Record; @@ -235,7 +236,7 @@ export class Dictionary implements BaseDictionary { private async loadMsgpack() { const data = await Deno.readFile(this.#path); - const jisyo = msgpack.decode(data) as Jisyo; + const jisyo = msgpackDecode(data) as Jisyo; const validator = new jsonschema.Validator(); const result = validator.validate(jisyo, jisyoschema); if (!result.valid) { diff --git a/denops/skkeleton/sources/skk_dictionary.ts b/denops/skkeleton/sources/skk_dictionary.ts index 557dcae2..9246a58c 100644 --- a/denops/skkeleton/sources/skk_dictionary.ts +++ b/denops/skkeleton/sources/skk_dictionary.ts @@ -10,7 +10,9 @@ import { Source as BaseSource, wrapDictionary, } from "../dictionary.ts"; -import { jisyoschema, jsonschema, msgpack, yaml } from "../deps/dictionary.ts"; +import { jisyoschema, jsonschema, yaml } from "../deps/dictionary.ts"; + +import { decode as msgpackDecode } from "jsr:@std/msgpack@~1.0.2/decode"; interface Jisyo { okuri_ari: Record; @@ -155,7 +157,7 @@ export class Dictionary implements BaseDictionary { } private loadMsgpack(data: Uint8Array) { - const jisyo = msgpack.decode(data) as Jisyo; + const jisyo = msgpackDecode(data) as Jisyo; const validator = new jsonschema.Validator(); const result = validator.validate(jisyo, jisyoschema); if (!result.valid) { From 516b07066b8fdd13c3fcaecb0450f2d327c42296 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Sun, 15 Sep 2024 12:26:05 +0900 Subject: [PATCH 2/5] Optimize yaml dependency --- denops/skkeleton/deps/dictionary.ts | 1 - denops/skkeleton/sources/deno_kv.ts | 6 ++++-- denops/skkeleton/sources/skk_dictionary.ts | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/denops/skkeleton/deps/dictionary.ts b/denops/skkeleton/deps/dictionary.ts index 138b6252..3dcbcbce 100644 --- a/denops/skkeleton/deps/dictionary.ts +++ b/denops/skkeleton/deps/dictionary.ts @@ -1,3 +1,2 @@ -export * as yaml from "jsr:@std/yaml@~1.0.5"; export { default as jsonschema } from "npm:jsonschema@1.4.1"; export { default as jisyoschema } from "https://cdn.jsdelivr.net/gh/skk-dict/jisyo/schema/jisyo.schema.v0.0.0.json" with { type: "json" }; diff --git a/denops/skkeleton/sources/deno_kv.ts b/denops/skkeleton/sources/deno_kv.ts index b485e82f..83ac59c1 100644 --- a/denops/skkeleton/sources/deno_kv.ts +++ b/denops/skkeleton/sources/deno_kv.ts @@ -10,8 +10,10 @@ import { Source as BaseSource, wrapDictionary, } from "../dictionary.ts"; -import { jisyoschema, jsonschema, yaml } from "../deps/dictionary.ts"; +import { jisyoschema, jsonschema } from "../deps/dictionary.ts"; + import { decode as msgpackDecode } from "jsr:@std/msgpack@~1.0.2/decode"; +import { parse as yamlParse } from "jsr:@std/yaml@~1.0.5/parse"; interface Jisyo { okuri_ari: Record; @@ -218,7 +220,7 @@ export class Dictionary implements BaseDictionary { private async loadYaml() { const data = await Deno.readTextFile(this.#path); - const jisyo = yaml.parse(data) as Jisyo; + const jisyo = yamlParse(data) as Jisyo; const validator = new jsonschema.Validator(); const result = validator.validate(jisyo, jisyoschema); if (!result.valid) { diff --git a/denops/skkeleton/sources/skk_dictionary.ts b/denops/skkeleton/sources/skk_dictionary.ts index 9246a58c..6210a537 100644 --- a/denops/skkeleton/sources/skk_dictionary.ts +++ b/denops/skkeleton/sources/skk_dictionary.ts @@ -10,9 +10,10 @@ import { Source as BaseSource, wrapDictionary, } from "../dictionary.ts"; -import { jisyoschema, jsonschema, yaml } from "../deps/dictionary.ts"; +import { jisyoschema, jsonschema } from "../deps/dictionary.ts"; import { decode as msgpackDecode } from "jsr:@std/msgpack@~1.0.2/decode"; +import { parse as yamlParse } from "jsr:@std/yaml@~1.0.5/parse"; interface Jisyo { okuri_ari: Record; @@ -144,7 +145,7 @@ export class Dictionary implements BaseDictionary { } private loadYaml(data: string) { - const jisyo = yaml.parse(data) as Jisyo; + const jisyo = yamlParse(data) as Jisyo; const validator = new jsonschema.Validator(); const result = validator.validate(jisyo, jisyoschema); if (!result.valid) { From 2d559e8500d3e8cf410d5b6f53fe1d09ee9355f5 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Sun, 15 Sep 2024 12:29:48 +0900 Subject: [PATCH 3/5] Fix type errors --- denops/skkeleton/sources/deno_kv.ts | 2 +- denops/skkeleton/sources/skk_dictionary.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/denops/skkeleton/sources/deno_kv.ts b/denops/skkeleton/sources/deno_kv.ts index 83ac59c1..d70686e2 100644 --- a/denops/skkeleton/sources/deno_kv.ts +++ b/denops/skkeleton/sources/deno_kv.ts @@ -238,7 +238,7 @@ export class Dictionary implements BaseDictionary { private async loadMsgpack() { const data = await Deno.readFile(this.#path); - const jisyo = msgpackDecode(data) as Jisyo; + const jisyo = (msgpackDecode(data) as unknown) as Jisyo; const validator = new jsonschema.Validator(); const result = validator.validate(jisyo, jisyoschema); if (!result.valid) { diff --git a/denops/skkeleton/sources/skk_dictionary.ts b/denops/skkeleton/sources/skk_dictionary.ts index 6210a537..4d475451 100644 --- a/denops/skkeleton/sources/skk_dictionary.ts +++ b/denops/skkeleton/sources/skk_dictionary.ts @@ -158,7 +158,7 @@ export class Dictionary implements BaseDictionary { } private loadMsgpack(data: Uint8Array) { - const jisyo = msgpackDecode(data) as Jisyo; + const jisyo = (msgpackDecode(data) as unknown) as Jisyo; const validator = new jsonschema.Validator(); const result = validator.validate(jisyo, jisyoschema); if (!result.valid) { From b77e4161459b94ec7d5eb77ea5b755903f01a1e5 Mon Sep 17 00:00:00 2001 From: Shougo Date: Sun, 15 Sep 2024 16:32:04 +0900 Subject: [PATCH 4/5] Update denops/skkeleton/sources/deno_kv.ts Co-authored-by: Hibiki <4513echo@gmail.com> --- denops/skkeleton/sources/deno_kv.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/denops/skkeleton/sources/deno_kv.ts b/denops/skkeleton/sources/deno_kv.ts index d70686e2..9c2e466f 100644 --- a/denops/skkeleton/sources/deno_kv.ts +++ b/denops/skkeleton/sources/deno_kv.ts @@ -238,7 +238,7 @@ export class Dictionary implements BaseDictionary { private async loadMsgpack() { const data = await Deno.readFile(this.#path); - const jisyo = (msgpackDecode(data) as unknown) as Jisyo; + const jisyo = msgpackDecode(data) as unknown as Jisyo; const validator = new jsonschema.Validator(); const result = validator.validate(jisyo, jisyoschema); if (!result.valid) { From 56be7ef6abe21d05520800b13a27da923f411f64 Mon Sep 17 00:00:00 2001 From: Shougo Date: Sun, 15 Sep 2024 16:32:12 +0900 Subject: [PATCH 5/5] Update denops/skkeleton/sources/skk_dictionary.ts Co-authored-by: Hibiki <4513echo@gmail.com> --- denops/skkeleton/sources/skk_dictionary.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/denops/skkeleton/sources/skk_dictionary.ts b/denops/skkeleton/sources/skk_dictionary.ts index 4d475451..c9ac1815 100644 --- a/denops/skkeleton/sources/skk_dictionary.ts +++ b/denops/skkeleton/sources/skk_dictionary.ts @@ -158,7 +158,7 @@ export class Dictionary implements BaseDictionary { } private loadMsgpack(data: Uint8Array) { - const jisyo = (msgpackDecode(data) as unknown) as Jisyo; + const jisyo = msgpackDecode(data) as unknown as Jisyo; const validator = new jsonschema.Validator(); const result = validator.validate(jisyo, jisyoschema); if (!result.valid) {