n8n-nodes-fasttext-language-detector 0.1.5 → 0.1.6

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.
@@ -195,17 +195,25 @@ class FastTextLanguageDetector {
195
195
  }
196
196
  // Динамически загружаем fasttext.js только когда он нужен
197
197
  // Это предотвращает загрузку WASM при старте n8n
198
- // Используем require для CommonJS модуля, обернутый в Promise
198
+ // ВАЖНО: используем прямой путь к lib/index.js, чтобы избежать автоматической загрузки WASM
199
199
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-var-requires
200
200
  const fastTextModule = await new Promise((resolve, reject) => {
201
201
  try {
202
- // Используем require для загрузки CommonJS модуля
202
+ // Используем прямой путь к index.js, минуя автоматическую загрузку WASM
203
203
  // eslint-disable-next-line @typescript-eslint/no-var-requires
204
- const FastText = require('fasttext.js');
204
+ const FastText = require('fasttext.js/lib/index');
205
205
  resolve(FastText);
206
206
  }
207
207
  catch (error) {
208
- reject(error);
208
+ // Если прямой путь не работает, пробуем обычный require
209
+ try {
210
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
211
+ const FastText = require('fasttext.js');
212
+ resolve(FastText);
213
+ }
214
+ catch (fallbackError) {
215
+ reject(fallbackError);
216
+ }
209
217
  }
210
218
  });
211
219
  // fasttext.js экспортирует класс FastText напрямую
@@ -217,9 +225,11 @@ class FastTextLanguageDetector {
217
225
  throw new n8n_workflow_1.ApplicationError(`Failed to load fastText module: FastText class not found. Available exports: ${availableExports}`, { level: 'error' });
218
226
  }
219
227
  // Создаем экземпляр FastText с путем к модели
228
+ // ВАЖНО: явно отключаем WASM, используем бинарный режим
220
229
  const fastTextInstance = new FastTextClass({
221
230
  loadModel: modelPath,
222
231
  predict: {
232
+ wasm: false, // КРИТИЧНО: отключаем WASM, используем бинарный файл
223
233
  mostlikely: topK,
224
234
  verbosity: 0,
225
235
  normalize: false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-fasttext-language-detector",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "n8n node for language detection using fastText",
5
5
  "author": {
6
6
  "name": "Your Name",