Skip to content

Commit

Permalink
Merge pull request #208 from vim-skk/msgpack
Browse files Browse the repository at this point in the history
Remove npm msgpack dependency
  • Loading branch information
kuuote authored Sep 16, 2024
2 parents 89f79bd + 56be7ef commit 039aebf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 0 additions & 2 deletions denops/skkeleton/deps/dictionary.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
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" };
9 changes: 6 additions & 3 deletions denops/skkeleton/sources/deno_kv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import {
Source as BaseSource,
wrapDictionary,
} from "../dictionary.ts";
import { jisyoschema, jsonschema, msgpack, 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<string, string[]>;
Expand Down Expand Up @@ -217,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) {
Expand All @@ -235,7 +238,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 unknown as Jisyo;
const validator = new jsonschema.Validator();
const result = validator.validate(jisyo, jisyoschema);
if (!result.valid) {
Expand Down
9 changes: 6 additions & 3 deletions denops/skkeleton/sources/skk_dictionary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import {
Source as BaseSource,
wrapDictionary,
} from "../dictionary.ts";
import { jisyoschema, jsonschema, msgpack, 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<string, string[]>;
Expand Down Expand Up @@ -142,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) {
Expand All @@ -155,7 +158,7 @@ export class Dictionary implements BaseDictionary {
}

private loadMsgpack(data: Uint8Array) {
const jisyo = msgpack.decode(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) {
Expand Down

0 comments on commit 039aebf

Please sign in to comment.