Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove npm msgpack dependency #208

Merged
merged 5 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/[email protected]";
export { default as jsonschema } from "npm:[email protected]";
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;
Shougo marked this conversation as resolved.
Show resolved Hide resolved
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;
Shougo marked this conversation as resolved.
Show resolved Hide resolved
const validator = new jsonschema.Validator();
const result = validator.validate(jisyo, jisyoschema);
if (!result.valid) {
Expand Down
Loading