@furifont/dictionary 0.0.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@furifont/dictionary",
3
3
  "type": "module",
4
- "version": "0.0.0",
4
+ "version": "0.1.0",
5
5
  "description": "JMdict words aligned with per-kanji readings, compiled for Furifont",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "CC-BY-SA-4.0",
8
- "homepage": "https://github.com/antfu/furigana-font#readme",
8
+ "homepage": "https://github.com/antfu/furifont#readme",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "git+https://github.com/antfu/furigana-font.git",
11
+ "url": "git+https://github.com/antfu/furifont.git",
12
12
  "directory": "packages/dictionary"
13
13
  },
14
- "bugs": "https://github.com/antfu/furigana-font/issues",
14
+ "bugs": "https://github.com/antfu/furifont/issues",
15
15
  "sideEffects": false,
16
16
  "exports": {
17
17
  ".": "./dist/index.mjs",
@@ -25,7 +25,7 @@
25
25
  "dist"
26
26
  ],
27
27
  "dependencies": {
28
- "@furifont/core": "0.0.0",
28
+ "@furifont/core": "0.1.0",
29
29
  "valibot": "^1.5.0"
30
30
  },
31
31
  "scripts": {
package/dist/index.d.mts DELETED
@@ -1,5 +0,0 @@
1
- import { Dictionary } from "@furifont/core";
2
- //#region src/index.d.ts
3
- /** Loads the compiled dictionary: JMdict and JMnedict place names, aligned by JmdictFurigana, with KANJIDIC2's on'yomi and JLPT levels. */
4
- export declare function loadDictionary(): Promise<Dictionary>;
5
- //#endregion
package/dist/index.mjs DELETED
@@ -1,83 +0,0 @@
1
- import * as v from "valibot";
2
- //#region src/defaults.ts
3
- /**
4
- * Default readings the compiled data ranks wrong, in inline notation. JMdict's
5
- * frequency tags belong to a written form, so across entries they cannot tell
6
- * two readings apart; and a form that drops its okurigana usually meets it in
7
- * running text, where the font cannot see it. Users' pins override these.
8
- */
9
- const DEFAULT_READINGS = [
10
- "出[で]来[き]",
11
- "何[なん]人[にん]",
12
- "何[なん]時[じ]",
13
- "三[さん]十[じゅう]日[にち]",
14
- "外[そと]付[づ]",
15
- "支[し]払[はら]"
16
- ];
17
- //#endregion
18
- //#region src/index.ts
19
- const DataSchema = v.object({
20
- sources: v.record(v.string(), v.string()),
21
- onyomi: v.record(v.string(), v.array(v.string())),
22
- entries: v.array(v.tuple([
23
- v.string(),
24
- v.string(),
25
- v.number(),
26
- v.string(),
27
- v.number(),
28
- v.optional(v.literal(1))
29
- ]))
30
- });
31
- const PlacesSchema = v.array(v.tuple([v.string(), v.string()]));
32
- const JlptSchema = v.array(v.tuple([
33
- v.string(),
34
- v.string(),
35
- v.picklist([
36
- 1,
37
- 2,
38
- 3,
39
- 4,
40
- 5
41
- ])
42
- ]));
43
- /**
44
- * A data file as a JSON module, which Node loads and bundlers split into a
45
- * lazy chunk. The path is a template so that TypeScript leaves the 11 MB file
46
- * untyped rather than inferring it.
47
- */
48
- async function readData(name, schema) {
49
- const { default: data } = await import(`../data/${name}.json`, { with: { type: "json" } });
50
- return v.parse(schema, data);
51
- }
52
- /** Loads the compiled dictionary: JMdict and JMnedict place names, aligned by JmdictFurigana, with KANJIDIC2's on'yomi and JLPT levels. */
53
- async function loadDictionary() {
54
- const [data, places, jlpt] = await Promise.all([
55
- readData("dictionary", DataSchema),
56
- readData("places", PlacesSchema),
57
- readData("jlpt", JlptSchema)
58
- ]);
59
- const levels = new Map(jlpt.map(([form, furigana, level]) => [`${form}|${furigana}`, level]));
60
- return {
61
- sources: data.sources,
62
- onyomi: data.onyomi,
63
- defaults: DEFAULT_READINGS,
64
- places: places.map(([form, furigana]) => ({
65
- form,
66
- furigana
67
- })),
68
- entries: data.entries.map(([form, furigana, nf, priority, order, conjugates]) => {
69
- const level = levels.get(`${form}|${furigana}`);
70
- return {
71
- form,
72
- furigana,
73
- nf,
74
- priority,
75
- order,
76
- ...conjugates && { conjugatesReading: true },
77
- ...level && { jlpt: level }
78
- };
79
- })
80
- };
81
- }
82
- //#endregion
83
- export { loadDictionary };
@@ -1,8 +0,0 @@
1
- //#region src/okurigana.d.ts
2
- /**
3
- * Words of one kanji run and the kana after it, read as a pair: 来な is こ, 来ま
4
- * is き, 一人も is ひとり. The longest key a text starts with decides; null marks
5
- * a pair that reads two ways.
6
- */
7
- export declare const OKURIGANA: ReadonlyMap<string, string | null>;
8
- //#endregion