@gukhanmun/loanwords-fst 0.4.0-dev.236 → 0.4.0-dev.248
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/dist/index.d.ts +6 -78
- package/dist/index.js +4 -4
- package/dist/loanwords.fst +0 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,77 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Specifies a dictionary loaded from a binary file or URL.
|
|
5
|
-
*
|
|
6
|
-
* The `data` field accepts:
|
|
7
|
-
* - A `BufferSource` (`ArrayBuffer` or `ArrayBufferView`) — supported in all
|
|
8
|
-
* environments.
|
|
9
|
-
* - A `URL` — resolved via `fetch` in browsers; via `node:fs/promises`
|
|
10
|
-
* in Node.js, Deno 2.0+, and Bun.
|
|
11
|
-
* - A `string` — treated as a filesystem path; supported in Node.js,
|
|
12
|
-
* Deno 2.0+, and Bun only. Throws in browser environments.
|
|
13
|
-
*
|
|
14
|
-
* At runtime, a `FileDictionarySource` is distinguished from other values by
|
|
15
|
-
* the absence of an `entries` property (`"entries" in source` selects a
|
|
16
|
-
* {@link MapDictionarySource}).
|
|
17
|
-
*/
|
|
18
|
-
interface FileDictionarySource {
|
|
19
|
-
/**
|
|
20
|
-
* The binary dictionary data or a reference to where it can be loaded.
|
|
21
|
-
*
|
|
22
|
-
* Pass a `BufferSource` for data already in memory, a `URL` for a remote
|
|
23
|
-
* or local URL (resolved via `fetch` or `readFile`), or a path `string`
|
|
24
|
-
* for filesystem paths (Node.js / Deno 2.0+ / Bun only).
|
|
25
|
-
*/
|
|
26
|
-
readonly data: ArrayBuffer | ArrayBufferView | URL | string;
|
|
27
|
-
/**
|
|
28
|
-
* The on-disk format of the dictionary file.
|
|
29
|
-
*
|
|
30
|
-
* - `"fst"` — Gukhanmun FST file (`*.gukfst`); preferred for small
|
|
31
|
-
* WebAssembly bundles. Supported in all runtimes.
|
|
32
|
-
* - `"cdb"` — Gukhanmun CDB-trie file (`*.gukcdb`); preferred when code
|
|
33
|
-
* auditability or trivial mmap support matters. Requires a filesystem
|
|
34
|
-
* or in-memory bytes; supported in Node-API and (with `from_bytes`) in
|
|
35
|
-
* WASM builds that include the `cdb` feature.
|
|
36
|
-
*
|
|
37
|
-
* The `"tsv"` format is reserved and never accepted. Pass entries in memory
|
|
38
|
-
* through {@link MapDictionarySource} instead of compiling a table.
|
|
39
|
-
*/
|
|
40
|
-
readonly format: "fst" | "cdb";
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* A dictionary built from entries computed at runtime, such as per-document
|
|
44
|
-
* reading overrides.
|
|
45
|
-
*
|
|
46
|
-
* Use this instead of compiling a TSV file with `gukhanmun-mkdict` when the
|
|
47
|
-
* entries do not exist on disk, for example in a browser, an edge runtime, or a
|
|
48
|
-
* site generator that derives entries per document.
|
|
49
|
-
*
|
|
50
|
-
* A source is distinguished from a {@link FileDictionarySource} by the presence
|
|
51
|
-
* of an `entries` property.
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* ```ts
|
|
55
|
-
* import { stdictFst } from "@gukhanmun/stdict-fst";
|
|
56
|
-
* const g = await load({
|
|
57
|
-
* dictionaries: [
|
|
58
|
-
* {
|
|
59
|
-
* entries: [
|
|
60
|
-
* { hanja: "高橋", reading: "다카하시" },
|
|
61
|
-
* { hanja: "東京", reading: "도쿄", preference: 10 },
|
|
62
|
-
* { hanja: "年代", reading: "연대", suffixReading: "년대" },
|
|
63
|
-
* ],
|
|
64
|
-
* },
|
|
65
|
-
* await stdictFst(),
|
|
66
|
-
* ],
|
|
67
|
-
* });
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
//#endregion
|
|
71
|
-
//#region index.d.ts
|
|
72
|
-
|
|
1
|
+
import { FileDictionarySource, FileDictionarySource as FileDictionarySource$1, SourceRole } from "@gukhanmun/types";
|
|
73
2
|
/** URL of the bundled NIKL loanword examples FST binary. */
|
|
74
|
-
declare const loanwordsFstUrl: URL;
|
|
3
|
+
export declare const loanwordsFstUrl: URL;
|
|
75
4
|
/**
|
|
76
5
|
* Loads the bundled NIKL loanword examples as raw bytes.
|
|
77
6
|
*
|
|
@@ -90,13 +19,12 @@ declare const loanwordsFstUrl: URL;
|
|
|
90
19
|
* {@link loanwordsFstUrl}; pass another URL to load a relocated copy.
|
|
91
20
|
* @returns The FST binary as a `Uint8Array`.
|
|
92
21
|
*/
|
|
93
|
-
declare function loanwordsFstBytes(url?: URL): Promise<Uint8Array<ArrayBuffer>>;
|
|
22
|
+
export declare function loanwordsFstBytes(url?: URL): Promise<Uint8Array<ArrayBuffer>>;
|
|
94
23
|
/**
|
|
95
24
|
* Loads the bundled NIKL loanword examples as a
|
|
96
25
|
* {@link FileDictionarySource} ready to pass to `load({ dictionaries: [...] })`.
|
|
97
26
|
*
|
|
98
|
-
* @returns A `FileDictionarySource` with `format: "fst"`.
|
|
27
|
+
* @returns A `FileDictionarySource` with `format: "fst"` and `role: "loanword"`.
|
|
99
28
|
*/
|
|
100
|
-
declare function loanwordsFst(): Promise<FileDictionarySource>;
|
|
101
|
-
|
|
102
|
-
export { type FileDictionarySource, loanwordsFst, loanwordsFstBytes, loanwordsFstUrl };
|
|
29
|
+
export declare function loanwordsFst(): Promise<FileDictionarySource$1>;
|
|
30
|
+
export type { FileDictionarySource, SourceRole };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// index.ts
|
|
2
2
|
/** URL of the bundled NIKL loanword examples FST binary. */
|
|
3
3
|
const loanwordsFstUrl = new URL("./loanwords.fst", import.meta.url);
|
|
4
4
|
/**
|
|
@@ -35,13 +35,13 @@ async function loanwordsFstBytes(url = loanwordsFstUrl) {
|
|
|
35
35
|
* Loads the bundled NIKL loanword examples as a
|
|
36
36
|
* {@link FileDictionarySource} ready to pass to `load({ dictionaries: [...] })`.
|
|
37
37
|
*
|
|
38
|
-
* @returns A `FileDictionarySource` with `format: "fst"`.
|
|
38
|
+
* @returns A `FileDictionarySource` with `format: "fst"` and `role: "loanword"`.
|
|
39
39
|
*/
|
|
40
40
|
async function loanwordsFst() {
|
|
41
41
|
return {
|
|
42
42
|
data: await loanwordsFstBytes(),
|
|
43
|
-
format: "fst"
|
|
43
|
+
format: "fst",
|
|
44
|
+
role: "loanword"
|
|
44
45
|
};
|
|
45
46
|
}
|
|
46
|
-
//#endregion
|
|
47
47
|
export { loanwordsFst, loanwordsFstBytes, loanwordsFstUrl };
|
package/dist/loanwords.fst
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gukhanmun/loanwords-fst",
|
|
3
|
-
"version": "0.4.0-dev.
|
|
3
|
+
"version": "0.4.0-dev.248",
|
|
4
4
|
"description": "NIKL loanword examples bundled as an FST binary for @gukhanmun/wasm and @gukhanmun/napi.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@gukhanmun/types": "*"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@gukhanmun/types": "0.4.0-dev.
|
|
60
|
+
"@gukhanmun/types": "0.4.0-dev.248+36997e7"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "tsdown && node -e \"require('node:fs').copyFileSync('loanwords.fst','dist/loanwords.fst')\"",
|