fixnow 2.0.0 → 2.0.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 CHANGED
@@ -141,6 +141,32 @@ await suggest("bonjoor", 3); // bound suggest is (word, max?)
141
141
  The slim entries (`fixnow/ar`, `fixnow/de`, `fixnow/en`, `fixnow/es`, `fixnow/fr`,
142
142
  `fixnow/pt`, `fixnow/ru`, `fixnow/vi`) re-export a checker pre-bound to that language.
143
143
 
144
+ ## Bundling
145
+
146
+ fixnow reads its dictionaries from disk at runtime — they ship as files under
147
+ `node_modules/fixnow/dictionaries/`, not as inlined bytes in the JS. So any bundler
148
+ must treat `fixnow` as **external**, leaving it to load from `node_modules` at runtime.
149
+ This is required for **VS Code extensions** and any **CJS bundle**: inlining fixnow into
150
+ a CJS output strips the path anchor it uses to find its dictionaries, and it will throw
151
+ a clear "mark 'fixnow' as external" error instead of resolving them.
152
+
153
+ ```js
154
+ // esbuild
155
+ await esbuild.build({
156
+ entryPoints: ["src/extension.ts"],
157
+ bundle: true,
158
+ format: "cjs",
159
+ platform: "node",
160
+ external: ["fixnow"],
161
+ });
162
+ ```
163
+
164
+ The matching option for other bundlers:
165
+
166
+ - **Vite** — `build.rollupOptions.external: ['fixnow']`
167
+ - **Rollup** — `external: ['fixnow']`
168
+ - **webpack** — `externals: { fixnow: 'commonjs fixnow' }`
169
+
144
170
  ## Migrating from 1.x
145
171
 
146
172
  `2.0.0` cleans up three rough edges from the extraction-from-F1 release. Each is a
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.1",
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",