fixnow 2.0.0 → 2.0.2

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 CHANGED
@@ -9,31 +9,53 @@
9
9
 
10
10
  <br>
11
11
 
12
- <a href="https://www.npmjs.com/package/fixnow"><img alt="NPM version" src="https://img.shields.io/npm/v/fixnow.svg?style=for-the-badge&labelColor=000000"></a>
13
- <a href="https://www.npmjs.com/package/fixnow"><img alt="NPM Downloads" src="https://img.shields.io/npm/dm/fixnow.svg?style=for-the-badge&labelColor=000000"></a>
14
- <a href="https://github.com/bastndev/fixnow/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/npm/l/fixnow.svg?style=for-the-badge&labelColor=000000"></a>
15
- <a href="https://github.com/bastndev/fixnow/stargazers"><img alt="GitHub Stars" src="https://img.shields.io/github/stars/bastndev/fixnow.svg?style=for-the-badge&labelColor=000000"></a>
12
+ <a href="https://www.npmjs.com/package/fixnow"><img alt="NPM version" src="https://img.shields.io/npm/v/fixnow.svg?style=for-the-badge&logo=npm&color=ef4444&labelColor=18181b"></a>
13
+ <a href="https://www.npmjs.com/package/fixnow"><img alt="NPM Downloads" src="https://img.shields.io/npm/dm/fixnow.svg?style=for-the-badge&logo=npm&color=ef4444&labelColor=18181b"></a>
14
+ <a href="https://github.com/bastndev/fixnow/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/npm/l/fixnow.svg?style=for-the-badge&color=ef4444&labelColor=18181b"></a>
15
+ <a href="https://github.com/bastndev/fixnow/stargazers"><img alt="GitHub Stars" src="https://img.shields.io/github/stars/bastndev/fixnow.svg?style=for-the-badge&logo=github&color=ef4444&labelColor=18181b"></a>
16
16
 
17
- <h1></h1>
17
+ <br>
18
18
 
19
19
  <p align="center">
20
- <a href="https://github.com/bastndev/fixnow/blob/main/public/docs/README_ES.md">Español 🇪🇸</a> |
21
- <a href="https://github.com/bastndev/fixnow/blob/main/public/docs/README_ZH.md">中文 🇨🇳</a> |
22
- <a href="https://github.com/bastndev/fixnow/blob/main/public/docs/README_DE.md">Deutsch 🇩🇪</a> |
23
- <a href="https://github.com/bastndev/fixnow/blob/main/public/docs/README_FR.md">Français 🇫🇷</a> |
24
- <a href="https://github.com/bastndev/fixnow/blob/main/public/docs/README_JA.md">日本語 🇯🇵</a> |
25
- <a href="https://github.com/bastndev/fixnow/blob/main/public/docs/README_KO.md">한국어 🇰🇷</a> |
26
- <a href="https://github.com/bastndev/fixnow/blob/main/public/docs/README_PT.md">Português 🇧🇷</a> |
27
- <a href="https://github.com/bastndev/fixnow/blob/main/public/docs/README_RU.md">Русский 🇷🇺</a> |
28
- <a href="https://github.com/bastndev/fixnow/blob/main/public/docs/README_VI.md">Tiếng Việt 🇻🇳</a> |
29
- <a href="https://github.com/bastndev/fixnow/blob/main/public/docs/README_AR.md">العربية 🇸🇦</a> |
30
- <a href="https://github.com/bastndev/fixnow/blob/main/public/docs/README_HI.md">हिन्दी 🇮🇳</a><span>...</span>
20
+ <a href="https://github.com/bastndev/fixnow/blob/main/public/docs/README_ES.md">Español 🇪🇸</a>
21
+ <a href="https://github.com/bastndev/fixnow/blob/main/public/docs/README_ZH.md">中文 🇨🇳</a>
22
+ <a href="https://github.com/bastndev/fixnow/blob/main/public/docs/README_DE.md">Deutsch 🇩🇪</a>
23
+ <a href="https://github.com/bastndev/fixnow/blob/main/public/docs/README_FR.md">Français 🇫🇷</a>
24
+ <a href="https://github.com/bastndev/fixnow/blob/main/public/docs/README_JA.md">日本語 🇯🇵</a>
25
+ <a href="https://github.com/bastndev/fixnow/blob/main/public/docs/README_KO.md">한국어 🇰🇷</a>
26
+ <a href="https://github.com/bastndev/fixnow/blob/main/public/docs/README_PT.md">Português 🇧🇷</a>
27
+ <a href="https://github.com/bastndev/fixnow/blob/main/public/docs/README_RU.md">Русский 🇷🇺</a>
28
+ <a href="https://github.com/bastndev/fixnow/blob/main/public/docs/README_VI.md">Tiếng Việt 🇻🇳</a>
29
+ <a href="https://github.com/bastndev/fixnow/blob/main/public/docs/README_AR.md">العربية 🇸🇦</a>
30
+ <a href="https://github.com/bastndev/fixnow/blob/main/public/docs/README_HI.md">हिन्दी 🇮🇳</a>
31
31
  </p>
32
32
  </div>
33
33
 
34
34
  <br>
35
35
 
36
- A tiny multilingual spell checker with correction suggestions. Dictionaries are bundled, so `npm i fixnow` gives you everything — with **zero runtime dependencies**, in both ESM and CommonJS.
36
+ > A tiny multilingual spell checker with correction suggestions. Dictionaries are bundled, so `npm i fixnow` gives you everything — with **zero runtime dependencies**, in both ESM and CommonJS.
37
+
38
+ ## Features
39
+
40
+ - 📦 **Zero Dependencies** — Keeps your `node_modules` clean and lightweight.
41
+ - 🌍 **Built-in Dictionaries** — Includes Arabic, German, English, Spanish, French, Portuguese, Russian, and Vietnamese.
42
+ - ⚡ **Slim Builds** — Import only the language you need (e.g. `import { check } from "fixnow/es"`) to optimize bundle size.
43
+ - 🛡️ **Smart Tokenization** — Automatically ignores code spans, URLs, emails, and identifiers to prevent false positives.
44
+ - 🧩 **Universal** — Works seamlessly in both ESM and CommonJS projects.
45
+
46
+ ## Architecture
47
+
48
+ ```mermaid
49
+ flowchart LR
50
+ Input["Input Text"] --> Tokenizer
51
+ Tokenizer --> |"Skips Code / URLs"| Check{"Dictionary"}
52
+ Check -->|"Valid Word"| Pass["No Issues"]
53
+ Check -->|"Typo Detected"| Engine("Correction Engine")
54
+ Engine --> Issues["SpellIssue[]"]
55
+
56
+ style Input fill:#18181b,stroke:#ef4444,stroke-width:2px,color:#fff
57
+ style Issues fill:#18181b,stroke:#ef4444,stroke-width:2px,color:#fff
58
+ ```
37
59
 
38
60
  ## Install
39
61
 
@@ -126,7 +148,7 @@ await checkText(text, { language: "en", protectedSegments: false });
126
148
 
127
149
  The same option is exposed on `tokenize(text, protectedSegments)`.
128
150
 
129
- ### Slim builds
151
+ ### Slim Builds
130
152
 
131
153
  If you only need one language, import it via the language subpath. Your bundler only
132
154
  copies the dictionary you actually use:
@@ -141,6 +163,32 @@ await suggest("bonjoor", 3); // bound suggest is (word, max?)
141
163
  The slim entries (`fixnow/ar`, `fixnow/de`, `fixnow/en`, `fixnow/es`, `fixnow/fr`,
142
164
  `fixnow/pt`, `fixnow/ru`, `fixnow/vi`) re-export a checker pre-bound to that language.
143
165
 
166
+ ## Bundling
167
+
168
+ fixnow reads its dictionaries from disk at runtime — they ship as files under
169
+ `node_modules/fixnow/dictionaries/`, not as inlined bytes in the JS. So any bundler
170
+ must treat `fixnow` as **external**, leaving it to load from `node_modules` at runtime.
171
+ This is required for **VS Code extensions** and any **CJS bundle**: inlining fixnow into
172
+ a CJS output strips the path anchor it uses to find its dictionaries, and it will throw
173
+ a clear "mark 'fixnow' as external" error instead of resolving them.
174
+
175
+ ```js
176
+ // esbuild
177
+ await esbuild.build({
178
+ entryPoints: ["src/extension.ts"],
179
+ bundle: true,
180
+ format: "cjs",
181
+ platform: "node",
182
+ external: ["fixnow"],
183
+ });
184
+ ```
185
+
186
+ The matching option for other bundlers:
187
+
188
+ - **Vite** — `build.rollupOptions.external: ['fixnow']`
189
+ - **Rollup** — `external: ['fixnow']`
190
+ - **webpack** — `externals: { fixnow: 'commonjs fixnow' }`
191
+
144
192
  ## Migrating from 1.x
145
193
 
146
194
  `2.0.0` cleans up three rough edges from the extraction-from-F1 release. Each is a
@@ -176,4 +224,4 @@ breaking change:
176
224
 
177
225
  ## License
178
226
 
179
- [MIT](./LICENSE)
227
+ [MIT](./LICENSE)
package/dist/ar.cjs CHANGED
@@ -5900,7 +5900,21 @@ function isSupportedLanguage(code) {
5900
5900
  }
5901
5901
 
5902
5902
  // src/dictionary.ts
5903
- var PACKAGE_ROOT = (0, import_node_path.join)((0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(importMetaUrl)), "..");
5903
+ function resolvePackageRoot() {
5904
+ let url;
5905
+ try {
5906
+ url = importMetaUrl;
5907
+ } catch {
5908
+ url = void 0;
5909
+ }
5910
+ if (url) {
5911
+ return (0, import_node_path.join)((0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(url)), "..");
5912
+ }
5913
+ throw new Error(
5914
+ "fixnow could not locate its dictionaries. Mark 'fixnow' as external in your bundler (esbuild: external: ['fixnow']) so it loads from node_modules."
5915
+ );
5916
+ }
5917
+ var PACKAGE_ROOT = resolvePackageRoot();
5904
5918
  var TrieDictionary = class {
5905
5919
  constructor(trie, compound) {
5906
5920
  this.trie = trie;
@@ -5939,7 +5953,16 @@ function loadDictionary(language) {
5939
5953
  async function decode(language) {
5940
5954
  const info = LANGUAGES[language];
5941
5955
  const file = (0, import_node_path.join)(PACKAGE_ROOT, "dictionaries", language, info.trie);
5942
- const text = (0, import_node_zlib.gunzipSync)(await (0, import_promises.readFile)(file)).toString("utf8");
5956
+ let buf;
5957
+ try {
5958
+ buf = await (0, import_promises.readFile)(file);
5959
+ } catch (cause) {
5960
+ throw new Error(
5961
+ `fixnow could not read its "${language}" dictionary at ${file}. If you bundle your app, mark 'fixnow' as external (esbuild: external: ['fixnow']) so it loads from node_modules at runtime.`,
5962
+ { cause }
5963
+ );
5964
+ }
5965
+ const text = (0, import_node_zlib.gunzipSync)(buf).toString("utf8");
5943
5966
  return new TrieDictionary(decodeTrie(text), info.compound ?? false);
5944
5967
  }
5945
5968
  function warmup(language) {
package/dist/ar.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  LANGUAGES,
4
4
  createChecker,
5
5
  tokenize
6
- } from "./chunk-FX7T7BEL.js";
6
+ } from "./chunk-MSMQKHBH.js";
7
7
 
8
8
  // src/entries/ar.ts
9
9
  var checker = createChecker("ar");
@@ -5863,7 +5863,21 @@ function isSupportedLanguage(code) {
5863
5863
  }
5864
5864
 
5865
5865
  // src/dictionary.ts
5866
- var PACKAGE_ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
5866
+ function resolvePackageRoot() {
5867
+ let url;
5868
+ try {
5869
+ url = import.meta.url;
5870
+ } catch {
5871
+ url = void 0;
5872
+ }
5873
+ if (url) {
5874
+ return join(dirname(fileURLToPath(url)), "..");
5875
+ }
5876
+ throw new Error(
5877
+ "fixnow could not locate its dictionaries. Mark 'fixnow' as external in your bundler (esbuild: external: ['fixnow']) so it loads from node_modules."
5878
+ );
5879
+ }
5880
+ var PACKAGE_ROOT = resolvePackageRoot();
5867
5881
  var TrieDictionary = class {
5868
5882
  constructor(trie, compound) {
5869
5883
  this.trie = trie;
@@ -5902,7 +5916,16 @@ function loadDictionary(language) {
5902
5916
  async function decode(language) {
5903
5917
  const info = LANGUAGES[language];
5904
5918
  const file = join(PACKAGE_ROOT, "dictionaries", language, info.trie);
5905
- const text = gunzipSync(await readFile(file)).toString("utf8");
5919
+ let buf;
5920
+ try {
5921
+ buf = await readFile(file);
5922
+ } catch (cause) {
5923
+ throw new Error(
5924
+ `fixnow could not read its "${language}" dictionary at ${file}. If you bundle your app, mark 'fixnow' as external (esbuild: external: ['fixnow']) so it loads from node_modules at runtime.`,
5925
+ { cause }
5926
+ );
5927
+ }
5928
+ const text = gunzipSync(buf).toString("utf8");
5906
5929
  return new TrieDictionary(decodeTrie(text), info.compound ?? false);
5907
5930
  }
5908
5931
  function warmup(language) {
package/dist/de.cjs CHANGED
@@ -5900,7 +5900,21 @@ function isSupportedLanguage(code) {
5900
5900
  }
5901
5901
 
5902
5902
  // src/dictionary.ts
5903
- var PACKAGE_ROOT = (0, import_node_path.join)((0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(importMetaUrl)), "..");
5903
+ function resolvePackageRoot() {
5904
+ let url;
5905
+ try {
5906
+ url = importMetaUrl;
5907
+ } catch {
5908
+ url = void 0;
5909
+ }
5910
+ if (url) {
5911
+ return (0, import_node_path.join)((0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(url)), "..");
5912
+ }
5913
+ throw new Error(
5914
+ "fixnow could not locate its dictionaries. Mark 'fixnow' as external in your bundler (esbuild: external: ['fixnow']) so it loads from node_modules."
5915
+ );
5916
+ }
5917
+ var PACKAGE_ROOT = resolvePackageRoot();
5904
5918
  var TrieDictionary = class {
5905
5919
  constructor(trie, compound) {
5906
5920
  this.trie = trie;
@@ -5939,7 +5953,16 @@ function loadDictionary(language) {
5939
5953
  async function decode(language) {
5940
5954
  const info = LANGUAGES[language];
5941
5955
  const file = (0, import_node_path.join)(PACKAGE_ROOT, "dictionaries", language, info.trie);
5942
- const text = (0, import_node_zlib.gunzipSync)(await (0, import_promises.readFile)(file)).toString("utf8");
5956
+ let buf;
5957
+ try {
5958
+ buf = await (0, import_promises.readFile)(file);
5959
+ } catch (cause) {
5960
+ throw new Error(
5961
+ `fixnow could not read its "${language}" dictionary at ${file}. If you bundle your app, mark 'fixnow' as external (esbuild: external: ['fixnow']) so it loads from node_modules at runtime.`,
5962
+ { cause }
5963
+ );
5964
+ }
5965
+ const text = (0, import_node_zlib.gunzipSync)(buf).toString("utf8");
5943
5966
  return new TrieDictionary(decodeTrie(text), info.compound ?? false);
5944
5967
  }
5945
5968
  function warmup(language) {
package/dist/de.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  LANGUAGES,
4
4
  createChecker,
5
5
  tokenize
6
- } from "./chunk-FX7T7BEL.js";
6
+ } from "./chunk-MSMQKHBH.js";
7
7
 
8
8
  // src/entries/de.ts
9
9
  var checker = createChecker("de");
package/dist/en.cjs CHANGED
@@ -5900,7 +5900,21 @@ function isSupportedLanguage(code) {
5900
5900
  }
5901
5901
 
5902
5902
  // src/dictionary.ts
5903
- var PACKAGE_ROOT = (0, import_node_path.join)((0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(importMetaUrl)), "..");
5903
+ function resolvePackageRoot() {
5904
+ let url;
5905
+ try {
5906
+ url = importMetaUrl;
5907
+ } catch {
5908
+ url = void 0;
5909
+ }
5910
+ if (url) {
5911
+ return (0, import_node_path.join)((0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(url)), "..");
5912
+ }
5913
+ throw new Error(
5914
+ "fixnow could not locate its dictionaries. Mark 'fixnow' as external in your bundler (esbuild: external: ['fixnow']) so it loads from node_modules."
5915
+ );
5916
+ }
5917
+ var PACKAGE_ROOT = resolvePackageRoot();
5904
5918
  var TrieDictionary = class {
5905
5919
  constructor(trie, compound) {
5906
5920
  this.trie = trie;
@@ -5939,7 +5953,16 @@ function loadDictionary(language) {
5939
5953
  async function decode(language) {
5940
5954
  const info = LANGUAGES[language];
5941
5955
  const file = (0, import_node_path.join)(PACKAGE_ROOT, "dictionaries", language, info.trie);
5942
- const text = (0, import_node_zlib.gunzipSync)(await (0, import_promises.readFile)(file)).toString("utf8");
5956
+ let buf;
5957
+ try {
5958
+ buf = await (0, import_promises.readFile)(file);
5959
+ } catch (cause) {
5960
+ throw new Error(
5961
+ `fixnow could not read its "${language}" dictionary at ${file}. If you bundle your app, mark 'fixnow' as external (esbuild: external: ['fixnow']) so it loads from node_modules at runtime.`,
5962
+ { cause }
5963
+ );
5964
+ }
5965
+ const text = (0, import_node_zlib.gunzipSync)(buf).toString("utf8");
5943
5966
  return new TrieDictionary(decodeTrie(text), info.compound ?? false);
5944
5967
  }
5945
5968
  function warmup(language) {
package/dist/en.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  LANGUAGES,
4
4
  createChecker,
5
5
  tokenize
6
- } from "./chunk-FX7T7BEL.js";
6
+ } from "./chunk-MSMQKHBH.js";
7
7
 
8
8
  // src/entries/en.ts
9
9
  var checker = createChecker("en");
package/dist/es.cjs CHANGED
@@ -5900,7 +5900,21 @@ function isSupportedLanguage(code) {
5900
5900
  }
5901
5901
 
5902
5902
  // src/dictionary.ts
5903
- var PACKAGE_ROOT = (0, import_node_path.join)((0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(importMetaUrl)), "..");
5903
+ function resolvePackageRoot() {
5904
+ let url;
5905
+ try {
5906
+ url = importMetaUrl;
5907
+ } catch {
5908
+ url = void 0;
5909
+ }
5910
+ if (url) {
5911
+ return (0, import_node_path.join)((0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(url)), "..");
5912
+ }
5913
+ throw new Error(
5914
+ "fixnow could not locate its dictionaries. Mark 'fixnow' as external in your bundler (esbuild: external: ['fixnow']) so it loads from node_modules."
5915
+ );
5916
+ }
5917
+ var PACKAGE_ROOT = resolvePackageRoot();
5904
5918
  var TrieDictionary = class {
5905
5919
  constructor(trie, compound) {
5906
5920
  this.trie = trie;
@@ -5939,7 +5953,16 @@ function loadDictionary(language) {
5939
5953
  async function decode(language) {
5940
5954
  const info = LANGUAGES[language];
5941
5955
  const file = (0, import_node_path.join)(PACKAGE_ROOT, "dictionaries", language, info.trie);
5942
- const text = (0, import_node_zlib.gunzipSync)(await (0, import_promises.readFile)(file)).toString("utf8");
5956
+ let buf;
5957
+ try {
5958
+ buf = await (0, import_promises.readFile)(file);
5959
+ } catch (cause) {
5960
+ throw new Error(
5961
+ `fixnow could not read its "${language}" dictionary at ${file}. If you bundle your app, mark 'fixnow' as external (esbuild: external: ['fixnow']) so it loads from node_modules at runtime.`,
5962
+ { cause }
5963
+ );
5964
+ }
5965
+ const text = (0, import_node_zlib.gunzipSync)(buf).toString("utf8");
5943
5966
  return new TrieDictionary(decodeTrie(text), info.compound ?? false);
5944
5967
  }
5945
5968
  function warmup(language) {
package/dist/es.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  LANGUAGES,
4
4
  createChecker,
5
5
  tokenize
6
- } from "./chunk-FX7T7BEL.js";
6
+ } from "./chunk-MSMQKHBH.js";
7
7
 
8
8
  // src/entries/es.ts
9
9
  var checker = createChecker("es");
package/dist/fr.cjs CHANGED
@@ -5900,7 +5900,21 @@ function isSupportedLanguage(code) {
5900
5900
  }
5901
5901
 
5902
5902
  // src/dictionary.ts
5903
- var PACKAGE_ROOT = (0, import_node_path.join)((0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(importMetaUrl)), "..");
5903
+ function resolvePackageRoot() {
5904
+ let url;
5905
+ try {
5906
+ url = importMetaUrl;
5907
+ } catch {
5908
+ url = void 0;
5909
+ }
5910
+ if (url) {
5911
+ return (0, import_node_path.join)((0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(url)), "..");
5912
+ }
5913
+ throw new Error(
5914
+ "fixnow could not locate its dictionaries. Mark 'fixnow' as external in your bundler (esbuild: external: ['fixnow']) so it loads from node_modules."
5915
+ );
5916
+ }
5917
+ var PACKAGE_ROOT = resolvePackageRoot();
5904
5918
  var TrieDictionary = class {
5905
5919
  constructor(trie, compound) {
5906
5920
  this.trie = trie;
@@ -5939,7 +5953,16 @@ function loadDictionary(language) {
5939
5953
  async function decode(language) {
5940
5954
  const info = LANGUAGES[language];
5941
5955
  const file = (0, import_node_path.join)(PACKAGE_ROOT, "dictionaries", language, info.trie);
5942
- const text = (0, import_node_zlib.gunzipSync)(await (0, import_promises.readFile)(file)).toString("utf8");
5956
+ let buf;
5957
+ try {
5958
+ buf = await (0, import_promises.readFile)(file);
5959
+ } catch (cause) {
5960
+ throw new Error(
5961
+ `fixnow could not read its "${language}" dictionary at ${file}. If you bundle your app, mark 'fixnow' as external (esbuild: external: ['fixnow']) so it loads from node_modules at runtime.`,
5962
+ { cause }
5963
+ );
5964
+ }
5965
+ const text = (0, import_node_zlib.gunzipSync)(buf).toString("utf8");
5943
5966
  return new TrieDictionary(decodeTrie(text), info.compound ?? false);
5944
5967
  }
5945
5968
  function warmup(language) {
package/dist/fr.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  LANGUAGES,
4
4
  createChecker,
5
5
  tokenize
6
- } from "./chunk-FX7T7BEL.js";
6
+ } from "./chunk-MSMQKHBH.js";
7
7
 
8
8
  // src/entries/fr.ts
9
9
  var checker = createChecker("fr");
package/dist/index.cjs CHANGED
@@ -5903,7 +5903,21 @@ function isSupportedLanguage(code) {
5903
5903
  }
5904
5904
 
5905
5905
  // src/dictionary.ts
5906
- var PACKAGE_ROOT = (0, import_node_path.join)((0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(importMetaUrl)), "..");
5906
+ function resolvePackageRoot() {
5907
+ let url;
5908
+ try {
5909
+ url = importMetaUrl;
5910
+ } catch {
5911
+ url = void 0;
5912
+ }
5913
+ if (url) {
5914
+ return (0, import_node_path.join)((0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(url)), "..");
5915
+ }
5916
+ throw new Error(
5917
+ "fixnow could not locate its dictionaries. Mark 'fixnow' as external in your bundler (esbuild: external: ['fixnow']) so it loads from node_modules."
5918
+ );
5919
+ }
5920
+ var PACKAGE_ROOT = resolvePackageRoot();
5907
5921
  var TrieDictionary = class {
5908
5922
  constructor(trie, compound) {
5909
5923
  this.trie = trie;
@@ -5942,7 +5956,16 @@ function loadDictionary(language) {
5942
5956
  async function decode(language) {
5943
5957
  const info = LANGUAGES[language];
5944
5958
  const file = (0, import_node_path.join)(PACKAGE_ROOT, "dictionaries", language, info.trie);
5945
- const text = (0, import_node_zlib.gunzipSync)(await (0, import_promises.readFile)(file)).toString("utf8");
5959
+ let buf;
5960
+ try {
5961
+ buf = await (0, import_promises.readFile)(file);
5962
+ } catch (cause) {
5963
+ throw new Error(
5964
+ `fixnow could not read its "${language}" dictionary at ${file}. If you bundle your app, mark 'fixnow' as external (esbuild: external: ['fixnow']) so it loads from node_modules at runtime.`,
5965
+ { cause }
5966
+ );
5967
+ }
5968
+ const text = (0, import_node_zlib.gunzipSync)(buf).toString("utf8");
5946
5969
  return new TrieDictionary(decodeTrie(text), info.compound ?? false);
5947
5970
  }
5948
5971
  function warmup(language) {
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  suggest,
11
11
  tokenize,
12
12
  warmup
13
- } from "./chunk-FX7T7BEL.js";
13
+ } from "./chunk-MSMQKHBH.js";
14
14
  export {
15
15
  DEFAULT_PROTECTED_PATTERN,
16
16
  LANGUAGES,
package/dist/pt.cjs CHANGED
@@ -5900,7 +5900,21 @@ function isSupportedLanguage(code) {
5900
5900
  }
5901
5901
 
5902
5902
  // src/dictionary.ts
5903
- var PACKAGE_ROOT = (0, import_node_path.join)((0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(importMetaUrl)), "..");
5903
+ function resolvePackageRoot() {
5904
+ let url;
5905
+ try {
5906
+ url = importMetaUrl;
5907
+ } catch {
5908
+ url = void 0;
5909
+ }
5910
+ if (url) {
5911
+ return (0, import_node_path.join)((0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(url)), "..");
5912
+ }
5913
+ throw new Error(
5914
+ "fixnow could not locate its dictionaries. Mark 'fixnow' as external in your bundler (esbuild: external: ['fixnow']) so it loads from node_modules."
5915
+ );
5916
+ }
5917
+ var PACKAGE_ROOT = resolvePackageRoot();
5904
5918
  var TrieDictionary = class {
5905
5919
  constructor(trie, compound) {
5906
5920
  this.trie = trie;
@@ -5939,7 +5953,16 @@ function loadDictionary(language) {
5939
5953
  async function decode(language) {
5940
5954
  const info = LANGUAGES[language];
5941
5955
  const file = (0, import_node_path.join)(PACKAGE_ROOT, "dictionaries", language, info.trie);
5942
- const text = (0, import_node_zlib.gunzipSync)(await (0, import_promises.readFile)(file)).toString("utf8");
5956
+ let buf;
5957
+ try {
5958
+ buf = await (0, import_promises.readFile)(file);
5959
+ } catch (cause) {
5960
+ throw new Error(
5961
+ `fixnow could not read its "${language}" dictionary at ${file}. If you bundle your app, mark 'fixnow' as external (esbuild: external: ['fixnow']) so it loads from node_modules at runtime.`,
5962
+ { cause }
5963
+ );
5964
+ }
5965
+ const text = (0, import_node_zlib.gunzipSync)(buf).toString("utf8");
5943
5966
  return new TrieDictionary(decodeTrie(text), info.compound ?? false);
5944
5967
  }
5945
5968
  function warmup(language) {
package/dist/pt.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  LANGUAGES,
4
4
  createChecker,
5
5
  tokenize
6
- } from "./chunk-FX7T7BEL.js";
6
+ } from "./chunk-MSMQKHBH.js";
7
7
 
8
8
  // src/entries/pt.ts
9
9
  var checker = createChecker("pt");
package/dist/ru.cjs CHANGED
@@ -5900,7 +5900,21 @@ function isSupportedLanguage(code) {
5900
5900
  }
5901
5901
 
5902
5902
  // src/dictionary.ts
5903
- var PACKAGE_ROOT = (0, import_node_path.join)((0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(importMetaUrl)), "..");
5903
+ function resolvePackageRoot() {
5904
+ let url;
5905
+ try {
5906
+ url = importMetaUrl;
5907
+ } catch {
5908
+ url = void 0;
5909
+ }
5910
+ if (url) {
5911
+ return (0, import_node_path.join)((0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(url)), "..");
5912
+ }
5913
+ throw new Error(
5914
+ "fixnow could not locate its dictionaries. Mark 'fixnow' as external in your bundler (esbuild: external: ['fixnow']) so it loads from node_modules."
5915
+ );
5916
+ }
5917
+ var PACKAGE_ROOT = resolvePackageRoot();
5904
5918
  var TrieDictionary = class {
5905
5919
  constructor(trie, compound) {
5906
5920
  this.trie = trie;
@@ -5939,7 +5953,16 @@ function loadDictionary(language) {
5939
5953
  async function decode(language) {
5940
5954
  const info = LANGUAGES[language];
5941
5955
  const file = (0, import_node_path.join)(PACKAGE_ROOT, "dictionaries", language, info.trie);
5942
- const text = (0, import_node_zlib.gunzipSync)(await (0, import_promises.readFile)(file)).toString("utf8");
5956
+ let buf;
5957
+ try {
5958
+ buf = await (0, import_promises.readFile)(file);
5959
+ } catch (cause) {
5960
+ throw new Error(
5961
+ `fixnow could not read its "${language}" dictionary at ${file}. If you bundle your app, mark 'fixnow' as external (esbuild: external: ['fixnow']) so it loads from node_modules at runtime.`,
5962
+ { cause }
5963
+ );
5964
+ }
5965
+ const text = (0, import_node_zlib.gunzipSync)(buf).toString("utf8");
5943
5966
  return new TrieDictionary(decodeTrie(text), info.compound ?? false);
5944
5967
  }
5945
5968
  function warmup(language) {
package/dist/ru.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  LANGUAGES,
4
4
  createChecker,
5
5
  tokenize
6
- } from "./chunk-FX7T7BEL.js";
6
+ } from "./chunk-MSMQKHBH.js";
7
7
 
8
8
  // src/entries/ru.ts
9
9
  var checker = createChecker("ru");
package/dist/vi.cjs CHANGED
@@ -5900,7 +5900,21 @@ function isSupportedLanguage(code) {
5900
5900
  }
5901
5901
 
5902
5902
  // src/dictionary.ts
5903
- var PACKAGE_ROOT = (0, import_node_path.join)((0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(importMetaUrl)), "..");
5903
+ function resolvePackageRoot() {
5904
+ let url;
5905
+ try {
5906
+ url = importMetaUrl;
5907
+ } catch {
5908
+ url = void 0;
5909
+ }
5910
+ if (url) {
5911
+ return (0, import_node_path.join)((0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(url)), "..");
5912
+ }
5913
+ throw new Error(
5914
+ "fixnow could not locate its dictionaries. Mark 'fixnow' as external in your bundler (esbuild: external: ['fixnow']) so it loads from node_modules."
5915
+ );
5916
+ }
5917
+ var PACKAGE_ROOT = resolvePackageRoot();
5904
5918
  var TrieDictionary = class {
5905
5919
  constructor(trie, compound) {
5906
5920
  this.trie = trie;
@@ -5939,7 +5953,16 @@ function loadDictionary(language) {
5939
5953
  async function decode(language) {
5940
5954
  const info = LANGUAGES[language];
5941
5955
  const file = (0, import_node_path.join)(PACKAGE_ROOT, "dictionaries", language, info.trie);
5942
- const text = (0, import_node_zlib.gunzipSync)(await (0, import_promises.readFile)(file)).toString("utf8");
5956
+ let buf;
5957
+ try {
5958
+ buf = await (0, import_promises.readFile)(file);
5959
+ } catch (cause) {
5960
+ throw new Error(
5961
+ `fixnow could not read its "${language}" dictionary at ${file}. If you bundle your app, mark 'fixnow' as external (esbuild: external: ['fixnow']) so it loads from node_modules at runtime.`,
5962
+ { cause }
5963
+ );
5964
+ }
5965
+ const text = (0, import_node_zlib.gunzipSync)(buf).toString("utf8");
5943
5966
  return new TrieDictionary(decodeTrie(text), info.compound ?? false);
5944
5967
  }
5945
5968
  function warmup(language) {
package/dist/vi.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  LANGUAGES,
4
4
  createChecker,
5
5
  tokenize
6
- } from "./chunk-FX7T7BEL.js";
6
+ } from "./chunk-MSMQKHBH.js";
7
7
 
8
8
  // src/entries/vi.ts
9
9
  var checker = createChecker("vi");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fixnow",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Tiny multilingual spell checker with suggestions. Arabic, German, English, Spanish, French, Portuguese, Russian and Vietnamese dictionaries bundled — one install, zero runtime dependencies.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",