lindera-wasm-web 2.3.4 → 3.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/lindera_wasm.js CHANGED
@@ -1,16 +1,5 @@
1
1
  /* @ts-self-types="./lindera_wasm.d.ts" */
2
2
 
3
- /**
4
- * Compression algorithm for dictionary data.
5
- * @enum {0 | 1 | 2 | 3}
6
- */
7
- export const CompressionAlgorithm = Object.freeze({
8
- Deflate: 0, "0": "Deflate",
9
- Zlib: 1, "1": "Zlib",
10
- Gzip: 2, "2": "Gzip",
11
- Raw: 3, "3": "Raw",
12
- });
13
-
14
3
  /**
15
4
  * A morphological analysis dictionary.
16
5
  */
@@ -295,13 +284,6 @@ export class Metadata {
295
284
  const ptr = this.__destroy_into_raw();
296
285
  wasm.__wbg_metadata_free(ptr, 0);
297
286
  }
298
- /**
299
- * @returns {CompressionAlgorithm}
300
- */
301
- get compress_algorithm() {
302
- const ret = wasm.jsmetadata_compress_algorithm(this.__wbg_ptr);
303
- return ret;
304
- }
305
287
  /**
306
288
  * @returns {Metadata}
307
289
  */
@@ -349,24 +331,17 @@ export class Metadata {
349
331
  /**
350
332
  * @param {string | null} [name]
351
333
  * @param {string | null} [encoding]
352
- * @param {CompressionAlgorithm | null} [compress_algorithm]
353
334
  */
354
- constructor(name, encoding, compress_algorithm) {
335
+ constructor(name, encoding) {
355
336
  var ptr0 = isLikeNone(name) ? 0 : passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
356
337
  var len0 = WASM_VECTOR_LEN;
357
338
  var ptr1 = isLikeNone(encoding) ? 0 : passStringToWasm0(encoding, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
358
339
  var len1 = WASM_VECTOR_LEN;
359
- const ret = wasm.jsmetadata_new(ptr0, len0, ptr1, len1, isLikeNone(compress_algorithm) ? 4 : compress_algorithm);
340
+ const ret = wasm.jsmetadata_new(ptr0, len0, ptr1, len1);
360
341
  this.__wbg_ptr = ret >>> 0;
361
342
  MetadataFinalization.register(this, this.__wbg_ptr, this);
362
343
  return this;
363
344
  }
364
- /**
365
- * @param {CompressionAlgorithm} algorithm
366
- */
367
- set compress_algorithm(algorithm) {
368
- wasm.jsmetadata_set_compress_algorithm(this.__wbg_ptr, algorithm);
369
- }
370
345
  /**
371
346
  * @param {Schema} schema
372
347
  */
@@ -970,6 +945,9 @@ export class TokenizerBuilder {
970
945
  }
971
946
  /**
972
947
  * Builds and returns a configured [`Tokenizer`] instance.
948
+ *
949
+ * If a dictionary instance was set via `setDictionaryInstance()`,
950
+ * it will be used directly instead of loading from a URI.
973
951
  * @returns {Tokenizer}
974
952
  */
975
953
  build() {
@@ -993,7 +971,7 @@ export class TokenizerBuilder {
993
971
  return this;
994
972
  }
995
973
  /**
996
- * Sets the dictionary to use for tokenization.
974
+ * Sets the dictionary to use for tokenization by URI.
997
975
  * @param {string} uri
998
976
  */
999
977
  setDictionary(uri) {
@@ -1004,6 +982,18 @@ export class TokenizerBuilder {
1004
982
  throw takeFromExternrefTable0(ret[0]);
1005
983
  }
1006
984
  }
985
+ /**
986
+ * Sets a pre-loaded dictionary instance for tokenization.
987
+ *
988
+ * Use this method when the dictionary has been loaded from bytes
989
+ * (e.g., via `loadDictionaryFromBytes()`) instead of from a URI.
990
+ * @param {Dictionary} dictionary
991
+ */
992
+ setDictionaryInstance(dictionary) {
993
+ _assertClass(dictionary, Dictionary);
994
+ var ptr0 = dictionary.__destroy_into_raw();
995
+ wasm.tokenizerbuilder_setDictionaryInstance(this.__wbg_ptr, ptr0);
996
+ }
1007
997
  /**
1008
998
  * Sets whether to keep whitespace tokens in the output.
1009
999
  * @param {boolean} keep
@@ -1027,7 +1017,7 @@ export class TokenizerBuilder {
1027
1017
  }
1028
1018
  }
1029
1019
  /**
1030
- * Sets a user-defined dictionary.
1020
+ * Sets a user-defined dictionary by URI.
1031
1021
  * @param {string} uri
1032
1022
  */
1033
1023
  setUserDictionary(uri) {
@@ -1038,6 +1028,18 @@ export class TokenizerBuilder {
1038
1028
  throw takeFromExternrefTable0(ret[0]);
1039
1029
  }
1040
1030
  }
1031
+ /**
1032
+ * Sets a pre-loaded user dictionary instance.
1033
+ *
1034
+ * Use this method when the user dictionary has been loaded from bytes
1035
+ * instead of from a URI.
1036
+ * @param {UserDictionary} user_dictionary
1037
+ */
1038
+ setUserDictionaryInstance(user_dictionary) {
1039
+ _assertClass(user_dictionary, UserDictionary);
1040
+ var ptr0 = user_dictionary.__destroy_into_raw();
1041
+ wasm.tokenizerbuilder_setUserDictionaryInstance(this.__wbg_ptr, ptr0);
1042
+ }
1041
1043
  /**
1042
1044
  * @param {string} uri
1043
1045
  */
@@ -1049,6 +1051,14 @@ export class TokenizerBuilder {
1049
1051
  throw takeFromExternrefTable0(ret[0]);
1050
1052
  }
1051
1053
  }
1054
+ /**
1055
+ * @param {Dictionary} dictionary
1056
+ */
1057
+ set_dictionary_instance(dictionary) {
1058
+ _assertClass(dictionary, Dictionary);
1059
+ var ptr0 = dictionary.__destroy_into_raw();
1060
+ wasm.tokenizerbuilder_set_dictionary_instance(this.__wbg_ptr, ptr0);
1061
+ }
1052
1062
  /**
1053
1063
  * @param {boolean} keep
1054
1064
  */
@@ -1080,6 +1090,14 @@ export class TokenizerBuilder {
1080
1090
  throw takeFromExternrefTable0(ret[0]);
1081
1091
  }
1082
1092
  }
1093
+ /**
1094
+ * @param {UserDictionary} user_dictionary
1095
+ */
1096
+ set_user_dictionary_instance(user_dictionary) {
1097
+ _assertClass(user_dictionary, UserDictionary);
1098
+ var ptr0 = user_dictionary.__destroy_into_raw();
1099
+ wasm.tokenizerbuilder_set_user_dictionary_instance(this.__wbg_ptr, ptr0);
1100
+ }
1083
1101
  }
1084
1102
  if (Symbol.dispose) TokenizerBuilder.prototype[Symbol.dispose] = TokenizerBuilder.prototype.free;
1085
1103
 
@@ -1220,6 +1238,61 @@ export function loadDictionary(uri) {
1220
1238
  return Dictionary.__wrap(ret[0]);
1221
1239
  }
1222
1240
 
1241
+ /**
1242
+ * Loads a dictionary from raw byte arrays.
1243
+ *
1244
+ * This function constructs a `Dictionary` directly from the binary data
1245
+ * of each dictionary component file, without requiring filesystem access.
1246
+ * This is useful for loading dictionaries from OPFS or other browser storage.
1247
+ *
1248
+ * # Arguments
1249
+ *
1250
+ * * `metadata` - The contents of `metadata.json`
1251
+ * * `dict_da` - The contents of `dict.da` (Double-Array Trie)
1252
+ * * `dict_vals` - The contents of `dict.vals` (word value data)
1253
+ * * `dict_words_idx` - The contents of `dict.wordsidx` (word details index)
1254
+ * * `dict_words` - The contents of `dict.words` (word details)
1255
+ * * `matrix_mtx` - The contents of `matrix.mtx` (connection cost matrix)
1256
+ * * `char_def` - The contents of `char_def.bin` (character definitions)
1257
+ * * `unk` - The contents of `unk.bin` (unknown word dictionary)
1258
+ *
1259
+ * # Returns
1260
+ *
1261
+ * A `Dictionary` instance constructed from the provided byte data.
1262
+ * @param {Uint8Array} metadata
1263
+ * @param {Uint8Array} dict_da
1264
+ * @param {Uint8Array} dict_vals
1265
+ * @param {Uint8Array} dict_words_idx
1266
+ * @param {Uint8Array} dict_words
1267
+ * @param {Uint8Array} matrix_mtx
1268
+ * @param {Uint8Array} char_def
1269
+ * @param {Uint8Array} unk
1270
+ * @returns {Dictionary}
1271
+ */
1272
+ export function loadDictionaryFromBytes(metadata, dict_da, dict_vals, dict_words_idx, dict_words, matrix_mtx, char_def, unk) {
1273
+ const ptr0 = passArray8ToWasm0(metadata, wasm.__wbindgen_malloc);
1274
+ const len0 = WASM_VECTOR_LEN;
1275
+ const ptr1 = passArray8ToWasm0(dict_da, wasm.__wbindgen_malloc);
1276
+ const len1 = WASM_VECTOR_LEN;
1277
+ const ptr2 = passArray8ToWasm0(dict_vals, wasm.__wbindgen_malloc);
1278
+ const len2 = WASM_VECTOR_LEN;
1279
+ const ptr3 = passArray8ToWasm0(dict_words_idx, wasm.__wbindgen_malloc);
1280
+ const len3 = WASM_VECTOR_LEN;
1281
+ const ptr4 = passArray8ToWasm0(dict_words, wasm.__wbindgen_malloc);
1282
+ const len4 = WASM_VECTOR_LEN;
1283
+ const ptr5 = passArray8ToWasm0(matrix_mtx, wasm.__wbindgen_malloc);
1284
+ const len5 = WASM_VECTOR_LEN;
1285
+ const ptr6 = passArray8ToWasm0(char_def, wasm.__wbindgen_malloc);
1286
+ const len6 = WASM_VECTOR_LEN;
1287
+ const ptr7 = passArray8ToWasm0(unk, wasm.__wbindgen_malloc);
1288
+ const len7 = WASM_VECTOR_LEN;
1289
+ const ret = wasm.loadDictionaryFromBytes(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6, ptr7, len7);
1290
+ if (ret[2]) {
1291
+ throw takeFromExternrefTable0(ret[1]);
1292
+ }
1293
+ return Dictionary.__wrap(ret[0]);
1294
+ }
1295
+
1223
1296
  /**
1224
1297
  * Loads a user dictionary from the specified URI.
1225
1298
  * @param {string} uri
@@ -1252,6 +1325,41 @@ export function load_dictionary(uri) {
1252
1325
  return Dictionary.__wrap(ret[0]);
1253
1326
  }
1254
1327
 
1328
+ /**
1329
+ * @param {Uint8Array} metadata
1330
+ * @param {Uint8Array} dict_da
1331
+ * @param {Uint8Array} dict_vals
1332
+ * @param {Uint8Array} dict_words_idx
1333
+ * @param {Uint8Array} dict_words
1334
+ * @param {Uint8Array} matrix_mtx
1335
+ * @param {Uint8Array} char_def
1336
+ * @param {Uint8Array} unk
1337
+ * @returns {Dictionary}
1338
+ */
1339
+ export function load_dictionary_from_bytes(metadata, dict_da, dict_vals, dict_words_idx, dict_words, matrix_mtx, char_def, unk) {
1340
+ const ptr0 = passArray8ToWasm0(metadata, wasm.__wbindgen_malloc);
1341
+ const len0 = WASM_VECTOR_LEN;
1342
+ const ptr1 = passArray8ToWasm0(dict_da, wasm.__wbindgen_malloc);
1343
+ const len1 = WASM_VECTOR_LEN;
1344
+ const ptr2 = passArray8ToWasm0(dict_vals, wasm.__wbindgen_malloc);
1345
+ const len2 = WASM_VECTOR_LEN;
1346
+ const ptr3 = passArray8ToWasm0(dict_words_idx, wasm.__wbindgen_malloc);
1347
+ const len3 = WASM_VECTOR_LEN;
1348
+ const ptr4 = passArray8ToWasm0(dict_words, wasm.__wbindgen_malloc);
1349
+ const len4 = WASM_VECTOR_LEN;
1350
+ const ptr5 = passArray8ToWasm0(matrix_mtx, wasm.__wbindgen_malloc);
1351
+ const len5 = WASM_VECTOR_LEN;
1352
+ const ptr6 = passArray8ToWasm0(char_def, wasm.__wbindgen_malloc);
1353
+ const len6 = WASM_VECTOR_LEN;
1354
+ const ptr7 = passArray8ToWasm0(unk, wasm.__wbindgen_malloc);
1355
+ const len7 = WASM_VECTOR_LEN;
1356
+ const ret = wasm.load_dictionary_from_bytes(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6, ptr7, len7);
1357
+ if (ret[2]) {
1358
+ throw takeFromExternrefTable0(ret[1]);
1359
+ }
1360
+ return Dictionary.__wrap(ret[0]);
1361
+ }
1362
+
1255
1363
  /**
1256
1364
  * @param {string} uri
1257
1365
  * @param {Metadata} metadata
@@ -1289,7 +1397,7 @@ export function version() {
1289
1397
  function __wbg_get_imports() {
1290
1398
  const import0 = {
1291
1399
  __proto__: null,
1292
- __wbg_Error_83742b46f01ce22d: function(arg0, arg1) {
1400
+ __wbg_Error_2e59b1b37a9a34c3: function(arg0, arg1) {
1293
1401
  const ret = Error(getStringFromWasm0(arg0, arg1));
1294
1402
  return ret;
1295
1403
  },
@@ -1300,64 +1408,64 @@ function __wbg_get_imports() {
1300
1408
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1301
1409
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1302
1410
  },
1303
- __wbg___wbindgen_bigint_get_as_i64_447a76b5c6ef7bda: function(arg0, arg1) {
1411
+ __wbg___wbindgen_bigint_get_as_i64_2c5082002e4826e2: function(arg0, arg1) {
1304
1412
  const v = arg1;
1305
1413
  const ret = typeof(v) === 'bigint' ? v : undefined;
1306
1414
  getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
1307
1415
  getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1308
1416
  },
1309
- __wbg___wbindgen_boolean_get_c0f3f60bac5a78d1: function(arg0) {
1417
+ __wbg___wbindgen_boolean_get_a86c216575a75c30: function(arg0) {
1310
1418
  const v = arg0;
1311
1419
  const ret = typeof(v) === 'boolean' ? v : undefined;
1312
1420
  return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
1313
1421
  },
1314
- __wbg___wbindgen_debug_string_5398f5bb970e0daa: function(arg0, arg1) {
1422
+ __wbg___wbindgen_debug_string_dd5d2d07ce9e6c57: function(arg0, arg1) {
1315
1423
  const ret = debugString(arg1);
1316
1424
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1317
1425
  const len1 = WASM_VECTOR_LEN;
1318
1426
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1319
1427
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1320
1428
  },
1321
- __wbg___wbindgen_in_41dbb8413020e076: function(arg0, arg1) {
1429
+ __wbg___wbindgen_in_4bd7a57e54337366: function(arg0, arg1) {
1322
1430
  const ret = arg0 in arg1;
1323
1431
  return ret;
1324
1432
  },
1325
- __wbg___wbindgen_is_bigint_e2141d4f045b7eda: function(arg0) {
1433
+ __wbg___wbindgen_is_bigint_6c98f7e945dacdde: function(arg0) {
1326
1434
  const ret = typeof(arg0) === 'bigint';
1327
1435
  return ret;
1328
1436
  },
1329
- __wbg___wbindgen_is_function_3c846841762788c1: function(arg0) {
1437
+ __wbg___wbindgen_is_function_49868bde5eb1e745: function(arg0) {
1330
1438
  const ret = typeof(arg0) === 'function';
1331
1439
  return ret;
1332
1440
  },
1333
- __wbg___wbindgen_is_null_0b605fc6b167c56f: function(arg0) {
1441
+ __wbg___wbindgen_is_null_344c8750a8525473: function(arg0) {
1334
1442
  const ret = arg0 === null;
1335
1443
  return ret;
1336
1444
  },
1337
- __wbg___wbindgen_is_object_781bc9f159099513: function(arg0) {
1445
+ __wbg___wbindgen_is_object_40c5a80572e8f9d3: function(arg0) {
1338
1446
  const val = arg0;
1339
1447
  const ret = typeof(val) === 'object' && val !== null;
1340
1448
  return ret;
1341
1449
  },
1342
- __wbg___wbindgen_is_undefined_52709e72fb9f179c: function(arg0) {
1450
+ __wbg___wbindgen_is_undefined_c0cca72b82b86f4d: function(arg0) {
1343
1451
  const ret = arg0 === undefined;
1344
1452
  return ret;
1345
1453
  },
1346
- __wbg___wbindgen_jsval_eq_ee31bfad3e536463: function(arg0, arg1) {
1454
+ __wbg___wbindgen_jsval_eq_7d430e744a913d26: function(arg0, arg1) {
1347
1455
  const ret = arg0 === arg1;
1348
1456
  return ret;
1349
1457
  },
1350
- __wbg___wbindgen_jsval_loose_eq_5bcc3bed3c69e72b: function(arg0, arg1) {
1458
+ __wbg___wbindgen_jsval_loose_eq_3a72ae764d46d944: function(arg0, arg1) {
1351
1459
  const ret = arg0 == arg1;
1352
1460
  return ret;
1353
1461
  },
1354
- __wbg___wbindgen_number_get_34bb9d9dcfa21373: function(arg0, arg1) {
1462
+ __wbg___wbindgen_number_get_7579aab02a8a620c: function(arg0, arg1) {
1355
1463
  const obj = arg1;
1356
1464
  const ret = typeof(obj) === 'number' ? obj : undefined;
1357
1465
  getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
1358
1466
  getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1359
1467
  },
1360
- __wbg___wbindgen_string_get_395e606bd0ee4427: function(arg0, arg1) {
1468
+ __wbg___wbindgen_string_get_914df97fcfa788f2: function(arg0, arg1) {
1361
1469
  const obj = arg1;
1362
1470
  const ret = typeof(obj) === 'string' ? obj : undefined;
1363
1471
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -1365,34 +1473,34 @@ function __wbg_get_imports() {
1365
1473
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1366
1474
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1367
1475
  },
1368
- __wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
1476
+ __wbg___wbindgen_throw_81fc77679af83bc6: function(arg0, arg1) {
1369
1477
  throw new Error(getStringFromWasm0(arg0, arg1));
1370
1478
  },
1371
- __wbg_call_e133b57c9155d22c: function() { return handleError(function (arg0, arg1) {
1479
+ __wbg_call_7f2987183bb62793: function() { return handleError(function (arg0, arg1) {
1372
1480
  const ret = arg0.call(arg1);
1373
1481
  return ret;
1374
1482
  }, arguments); },
1375
- __wbg_done_08ce71ee07e3bd17: function(arg0) {
1483
+ __wbg_done_547d467e97529006: function(arg0) {
1376
1484
  const ret = arg0.done;
1377
1485
  return ret;
1378
1486
  },
1379
- __wbg_entries_e8a20ff8c9757101: function(arg0) {
1487
+ __wbg_entries_616b1a459b85be0b: function(arg0) {
1380
1488
  const ret = Object.entries(arg0);
1381
1489
  return ret;
1382
1490
  },
1383
- __wbg_get_326e41e095fb2575: function() { return handleError(function (arg0, arg1) {
1384
- const ret = Reflect.get(arg0, arg1);
1385
- return ret;
1386
- }, arguments); },
1387
- __wbg_get_a8ee5c45dabc1b3b: function(arg0, arg1) {
1491
+ __wbg_get_4848e350b40afc16: function(arg0, arg1) {
1388
1492
  const ret = arg0[arg1 >>> 0];
1389
1493
  return ret;
1390
1494
  },
1391
- __wbg_get_unchecked_329cfe50afab7352: function(arg0, arg1) {
1495
+ __wbg_get_ed0642c4b9d31ddf: function() { return handleError(function (arg0, arg1) {
1496
+ const ret = Reflect.get(arg0, arg1);
1497
+ return ret;
1498
+ }, arguments); },
1499
+ __wbg_get_unchecked_7d7babe32e9e6a54: function(arg0, arg1) {
1392
1500
  const ret = arg0[arg1 >>> 0];
1393
1501
  return ret;
1394
1502
  },
1395
- __wbg_instanceof_ArrayBuffer_101e2bf31071a9f6: function(arg0) {
1503
+ __wbg_instanceof_ArrayBuffer_ff7c1337a5e3b33a: function(arg0) {
1396
1504
  let result;
1397
1505
  try {
1398
1506
  result = arg0 instanceof ArrayBuffer;
@@ -1402,7 +1510,7 @@ function __wbg_get_imports() {
1402
1510
  const ret = result;
1403
1511
  return ret;
1404
1512
  },
1405
- __wbg_instanceof_Map_f194b366846aca0c: function(arg0) {
1513
+ __wbg_instanceof_Map_a10a2795ef4bfe97: function(arg0) {
1406
1514
  let result;
1407
1515
  try {
1408
1516
  result = arg0 instanceof Map;
@@ -1412,7 +1520,7 @@ function __wbg_get_imports() {
1412
1520
  const ret = result;
1413
1521
  return ret;
1414
1522
  },
1415
- __wbg_instanceof_Uint8Array_740438561a5b956d: function(arg0) {
1523
+ __wbg_instanceof_Uint8Array_4b8da683deb25d72: function(arg0) {
1416
1524
  let result;
1417
1525
  try {
1418
1526
  result = arg0 instanceof Uint8Array;
@@ -1422,54 +1530,54 @@ function __wbg_get_imports() {
1422
1530
  const ret = result;
1423
1531
  return ret;
1424
1532
  },
1425
- __wbg_isArray_33b91feb269ff46e: function(arg0) {
1533
+ __wbg_isArray_db61795ad004c139: function(arg0) {
1426
1534
  const ret = Array.isArray(arg0);
1427
1535
  return ret;
1428
1536
  },
1429
- __wbg_isSafeInteger_ecd6a7f9c3e053cd: function(arg0) {
1537
+ __wbg_isSafeInteger_ea83862ba994770c: function(arg0) {
1430
1538
  const ret = Number.isSafeInteger(arg0);
1431
1539
  return ret;
1432
1540
  },
1433
- __wbg_iterator_d8f549ec8fb061b1: function() {
1541
+ __wbg_iterator_de403ef31815a3e6: function() {
1434
1542
  const ret = Symbol.iterator;
1435
1543
  return ret;
1436
1544
  },
1437
- __wbg_length_b3416cf66a5452c8: function(arg0) {
1545
+ __wbg_length_0c32cb8543c8e4c8: function(arg0) {
1438
1546
  const ret = arg0.length;
1439
1547
  return ret;
1440
1548
  },
1441
- __wbg_length_ea16607d7b61445b: function(arg0) {
1549
+ __wbg_length_6e821edde497a532: function(arg0) {
1442
1550
  const ret = arg0.length;
1443
1551
  return ret;
1444
1552
  },
1445
- __wbg_new_5f486cdf45a04d78: function(arg0) {
1553
+ __wbg_new_4f9fafbb3909af72: function() {
1554
+ const ret = new Object();
1555
+ return ret;
1556
+ },
1557
+ __wbg_new_a560378ea1240b14: function(arg0) {
1446
1558
  const ret = new Uint8Array(arg0);
1447
1559
  return ret;
1448
1560
  },
1449
- __wbg_new_a70fbab9066b301f: function() {
1561
+ __wbg_new_f3c9df4f38f3f798: function() {
1450
1562
  const ret = new Array();
1451
1563
  return ret;
1452
1564
  },
1453
- __wbg_new_ab79df5bd7c26067: function() {
1454
- const ret = new Object();
1565
+ __wbg_next_01132ed6134b8ef5: function(arg0) {
1566
+ const ret = arg0.next;
1455
1567
  return ret;
1456
1568
  },
1457
- __wbg_next_11b99ee6237339e3: function() { return handleError(function (arg0) {
1569
+ __wbg_next_b3713ec761a9dbfd: function() { return handleError(function (arg0) {
1458
1570
  const ret = arg0.next();
1459
1571
  return ret;
1460
1572
  }, arguments); },
1461
- __wbg_next_e01a967809d1aa68: function(arg0) {
1462
- const ret = arg0.next;
1463
- return ret;
1464
- },
1465
- __wbg_prototypesetcall_d62e5099504357e6: function(arg0, arg1, arg2) {
1573
+ __wbg_prototypesetcall_3e05eb9545565046: function(arg0, arg1, arg2) {
1466
1574
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
1467
1575
  },
1468
- __wbg_push_e87b0e732085a946: function(arg0, arg1) {
1576
+ __wbg_push_6bdbc990be5ac37b: function(arg0, arg1) {
1469
1577
  const ret = arg0.push(arg1);
1470
1578
  return ret;
1471
1579
  },
1472
- __wbg_set_7eaa4f96924fd6b3: function() { return handleError(function (arg0, arg1, arg2) {
1580
+ __wbg_set_8ee2d34facb8466e: function() { return handleError(function (arg0, arg1, arg2) {
1473
1581
  const ret = Reflect.set(arg0, arg1, arg2);
1474
1582
  return ret;
1475
1583
  }, arguments); },
@@ -1477,7 +1585,7 @@ function __wbg_get_imports() {
1477
1585
  const ret = Token.__wrap(arg0);
1478
1586
  return ret;
1479
1587
  },
1480
- __wbg_value_21fc78aab0322612: function(arg0) {
1588
+ __wbg_value_7f6052747ccf940f: function(arg0) {
1481
1589
  const ret = arg0.value;
1482
1590
  return ret;
1483
1591
  },
@@ -1678,6 +1786,13 @@ function isLikeNone(x) {
1678
1786
  return x === undefined || x === null;
1679
1787
  }
1680
1788
 
1789
+ function passArray8ToWasm0(arg, malloc) {
1790
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
1791
+ getUint8ArrayMemory0().set(arg, ptr / 1);
1792
+ WASM_VECTOR_LEN = arg.length;
1793
+ return ptr;
1794
+ }
1795
+
1681
1796
  function passArrayJsValueToWasm0(array, malloc) {
1682
1797
  const ptr = malloc(array.length * 4, 4) >>> 0;
1683
1798
  for (let i = 0; i < array.length; i++) {
Binary file
package/opfs.d.ts ADDED
@@ -0,0 +1,84 @@
1
+ /**
2
+ * OPFS (Origin Private File System) helper utilities for Lindera WASM.
3
+ *
4
+ * @module opfs
5
+ */
6
+
7
+ /** Dictionary binary file data loaded from OPFS. */
8
+ export interface DictionaryFiles {
9
+ /** Contents of metadata.json */
10
+ metadata: Uint8Array;
11
+ /** Contents of dict.da (Double-Array Trie) */
12
+ dictDa: Uint8Array;
13
+ /** Contents of dict.vals (word value data) */
14
+ dictVals: Uint8Array;
15
+ /** Contents of dict.wordsidx (word details index) */
16
+ dictWordsIdx: Uint8Array;
17
+ /** Contents of dict.words (word details) */
18
+ dictWords: Uint8Array;
19
+ /** Contents of matrix.mtx (connection cost matrix) */
20
+ matrixMtx: Uint8Array;
21
+ /** Contents of char_def.bin (character definitions) */
22
+ charDef: Uint8Array;
23
+ /** Contents of unk.bin (unknown word dictionary) */
24
+ unk: Uint8Array;
25
+ }
26
+
27
+ /** Progress information passed to the onProgress callback. */
28
+ export interface DownloadProgress {
29
+ /** Current phase of the operation. */
30
+ phase: "downloading" | "extracting" | "storing" | "complete";
31
+ /** Bytes downloaded so far (only during "downloading" phase). */
32
+ loaded?: number;
33
+ /** Total bytes to download, if known (only during "downloading" phase). */
34
+ total?: number;
35
+ }
36
+
37
+ /** Options for downloadDictionary(). */
38
+ export interface DownloadDictionaryOptions {
39
+ /** Progress callback. */
40
+ onProgress?: (progress: DownloadProgress) => void;
41
+ }
42
+
43
+ /**
44
+ * Downloads a dictionary archive, extracts it, and stores the files in OPFS.
45
+ *
46
+ * @param url - URL of the dictionary zip archive.
47
+ * @param name - Name to store the dictionary under (e.g., "ipadic").
48
+ * @param options - Optional settings.
49
+ */
50
+ export function downloadDictionary(
51
+ url: string,
52
+ name: string,
53
+ options?: DownloadDictionaryOptions,
54
+ ): Promise<void>;
55
+
56
+ /**
57
+ * Loads dictionary files from OPFS as an object of Uint8Arrays.
58
+ *
59
+ * @param name - The dictionary name (e.g., "ipadic").
60
+ * @returns Object containing the dictionary file data.
61
+ */
62
+ export function loadDictionaryFiles(name: string): Promise<DictionaryFiles>;
63
+
64
+ /**
65
+ * Removes a dictionary from OPFS.
66
+ *
67
+ * @param name - The dictionary name to remove.
68
+ */
69
+ export function removeDictionary(name: string): Promise<void>;
70
+
71
+ /**
72
+ * Lists all dictionaries stored in OPFS.
73
+ *
74
+ * @returns Array of dictionary names.
75
+ */
76
+ export function listDictionaries(): Promise<string[]>;
77
+
78
+ /**
79
+ * Checks if a dictionary exists in OPFS.
80
+ *
81
+ * @param name - The dictionary name to check.
82
+ * @returns True if the dictionary exists.
83
+ */
84
+ export function hasDictionary(name: string): Promise<boolean>;