garu-ko 0.5.1 → 0.5.3

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/dist/index.js CHANGED
@@ -63,34 +63,27 @@ export class Garu {
63
63
  }
64
64
  modelBytes = new Uint8Array(await response.arrayBuffer());
65
65
  }
66
- // Construct the WASM analyzer
67
- const wasmInstance = new wasmModule.GaruWasm(modelBytes);
68
66
  // Load CNN reranker
69
- let cnnBytes = null;
70
- try {
71
- if (isNode) {
72
- const { readFile } = await import('fs/promises');
73
- const { fileURLToPath } = await import('url');
74
- const { join, dirname } = await import('path');
75
- const dir = dirname(fileURLToPath(import.meta.url));
76
- const buf = await readFile(join(dir, '..', 'models', 'cnn2.bin'));
77
- cnnBytes = new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
78
- }
79
- else {
80
- const cnnUrl = new URL('../models/cnn2.bin', import.meta.url).href;
81
- const cnnResp = await fetch(cnnUrl);
82
- if (cnnResp.ok) {
83
- cnnBytes = new Uint8Array(await cnnResp.arrayBuffer());
84
- }
85
- }
86
- }
87
- catch {
88
- // CNN loading is best-effort
67
+ let cnnBytes;
68
+ if (isNode) {
69
+ const { readFile } = await import('fs/promises');
70
+ const { fileURLToPath } = await import('url');
71
+ const { join, dirname } = await import('path');
72
+ const dir = dirname(fileURLToPath(import.meta.url));
73
+ const buf = await readFile(join(dir, '..', 'models', 'cnn2.bin'));
74
+ cnnBytes = new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
89
75
  }
90
- if (cnnBytes) {
91
- wasmInstance.load_cnn(cnnBytes);
76
+ else {
77
+ const cnnUrl = new URL('../models/cnn2.bin', import.meta.url).href;
78
+ const cnnResp = await fetch(cnnUrl);
79
+ if (!cnnResp.ok) {
80
+ throw new Error(`Failed to fetch CNN model from ${cnnUrl}: ${cnnResp.status}`);
81
+ }
82
+ cnnBytes = new Uint8Array(await cnnResp.arrayBuffer());
92
83
  }
93
- return new Garu(wasmInstance, modelBytes.byteLength + (cnnBytes?.byteLength ?? 0));
84
+ // Construct the WASM analyzer with both models
85
+ const wasmInstance = new wasmModule.GaruWasm(modelBytes, cnnBytes);
86
+ return new Garu(wasmInstance, modelBytes.byteLength + cnnBytes.byteLength);
94
87
  }
95
88
  /**
96
89
  * Analyze Korean text, returning morphological tokens with scores.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "garu-ko",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Ultra-lightweight Korean morphological analyzer for the web (1.7MB model, WASM, F1 93.7%)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/pkg/garu_wasm.js CHANGED
@@ -85,7 +85,7 @@ export class GaruWasm {
85
85
  }
86
86
  }
87
87
  if (Symbol.dispose) GaruWasm.prototype[Symbol.dispose] = GaruWasm.prototype.free;
88
- import * as import1 from "./snippets/garu-core-56e20afd30dd714b/inline0.js"
88
+ import * as import1 from "./snippets/garu-core-deda0dfbf85b90ef/inline0.js"
89
89
 
90
90
  function __wbg_get_imports() {
91
91
  const import0 = {
@@ -146,7 +146,7 @@ function __wbg_get_imports() {
146
146
  return {
147
147
  __proto__: null,
148
148
  "./garu_wasm_bg.js": import0,
149
- "./snippets/garu-core-56e20afd30dd714b/inline0.js": import1,
149
+ "./snippets/garu-core-deda0dfbf85b90ef/inline0.js": import1,
150
150
  };
151
151
  }
152
152
 
Binary file
package/pkg/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "garu-wasm",
3
3
  "type": "module",
4
- "version": "0.5.0",
4
+ "version": "0.5.2",
5
5
  "files": [
6
6
  "garu_wasm_bg.wasm",
7
7
  "garu_wasm.js",
@@ -0,0 +1 @@
1
+ export function performance_now() { return performance.now(); }
Binary file