lingotweaker-wasm 0.1.1 → 0.2.1
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/README.md +8 -7
- package/pack.js +7 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -55,23 +55,24 @@ passed in and pinned for the engine's date filters.
|
|
|
55
55
|
|
|
56
56
|
## Data
|
|
57
57
|
|
|
58
|
-
The package ships **code only** and depends on
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
The package ships **code only** and depends on the code-only
|
|
59
|
+
`lingotweaker-data` loader; the packs ship in one small package per language
|
|
60
|
+
(`lingotweaker-data-<lang>`). In Node.js the data helper resolves installed
|
|
61
|
+
`lingotweaker-data-<lang>` packages locally; in the browser (or without them)
|
|
62
|
+
it falls back to the per-release GitHub Release assets:
|
|
62
63
|
|
|
63
64
|
```js
|
|
64
65
|
import { fetchPack, packUrl, manifestUrl } from "lingotweaker-wasm/pack";
|
|
65
66
|
|
|
66
|
-
await fetchPack("en"); //
|
|
67
|
+
await fetchPack("en"); // installed lingotweaker-data-en in Node, else release assets
|
|
67
68
|
await fetchPack("gn", { baseUrl: "https://fiduswriter.github.io/LingoTweaker" });
|
|
68
69
|
packUrl("de"); // build a URL yourself
|
|
69
70
|
```
|
|
70
71
|
|
|
71
72
|
`baseUrl` points at a directory that contains `packs/<lang>.pack.gz` and
|
|
72
73
|
`manifest.json`. All languages are attached to every release; `manifest.json`
|
|
73
|
-
lists file sizes and sha256 hashes.
|
|
74
|
-
|
|
74
|
+
lists file sizes and sha256 hashes. Each pack is also served from any npm CDN
|
|
75
|
+
(`https://cdn.jsdelivr.net/npm/lingotweaker-data-<lang>/packs/<lang>.pack.gz`),
|
|
75
76
|
and you can host the packs yourself.
|
|
76
77
|
|
|
77
78
|
LingoTweaker is an independent project and includes a port of the legacy
|
package/pack.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
// Updated by scripts/release/set-version.sh together with the package version.
|
|
12
12
|
export const DEFAULT_DATA_BASE_URL =
|
|
13
|
-
"https://github.com/fiduswriter/LingoTweaker/releases/download/v0.
|
|
13
|
+
"https://github.com/fiduswriter/LingoTweaker/releases/download/v0.2.1";
|
|
14
14
|
|
|
15
15
|
/** The URL of the release data manifest (`{ <lang>: { file, bytes, sha256 } }`). */
|
|
16
16
|
export function manifestUrl(baseUrl = DEFAULT_DATA_BASE_URL) {
|
|
@@ -36,9 +36,10 @@ export async function decompressPack(bytes) {
|
|
|
36
36
|
/**
|
|
37
37
|
* Fetch and inflate the pack for `lang` (`en`, `de`, `gn`, …).
|
|
38
38
|
*
|
|
39
|
-
* Node.js prefers the locally installed `lingotweaker-data
|
|
40
|
-
* (and any environment without
|
|
41
|
-
* package version. Pass `baseUrl` to use different
|
|
39
|
+
* Node.js prefers the locally installed `lingotweaker-data-<lang>` data
|
|
40
|
+
* packages; browsers (and any environment without them) fall back to the
|
|
41
|
+
* release assets for this package version. Pass `baseUrl` to use different
|
|
42
|
+
* data — the Pages demo
|
|
42
43
|
* (`https://fiduswriter.github.io/LingoTweaker`) or a local directory.
|
|
43
44
|
*/
|
|
44
45
|
export async function fetchPack(lang, options = {}) {
|
|
@@ -58,7 +59,8 @@ export async function fetchPack(lang, options = {}) {
|
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
/**
|
|
61
|
-
* Read and inflate a pack from the installed
|
|
62
|
+
* Read and inflate a pack from the locally installed data packages (the
|
|
63
|
+
* code-only `lingotweaker-data` loader resolving `lingotweaker-data-<lang>`).
|
|
62
64
|
* Returns `null` outside Node.js, or when the package/language is missing.
|
|
63
65
|
*/
|
|
64
66
|
export async function localPack(lang) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lingotweaker-wasm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "LingoTweaker proofreading engine compiled to WebAssembly (browser and Node)",
|
|
5
5
|
"license": "LGPL-2.1-or-later",
|
|
6
6
|
"repository": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"module": "./web/lt_wasm.js",
|
|
23
23
|
"types": "./web/lt_wasm.d.ts",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"lingotweaker-data": "0.
|
|
25
|
+
"lingotweaker-data": "0.2.1"
|
|
26
26
|
},
|
|
27
27
|
"exports": {
|
|
28
28
|
".": {
|