@sorisdk/matcher 0.1.2 → 0.1.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/README.md +19 -0
- package/dist/default-loader.js +5 -0
- package/dist/generated/core.js +1 -1
- package/dist/generated/core_bg.js +29 -29
- package/dist/generated/core_bg.wasm +0 -0
- package/dist/index.js +14 -14
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,6 +14,11 @@ npm install @sorisdk/matcher
|
|
|
14
14
|
|
|
15
15
|
Vite-based apps need `vite-plugin-wasm`.
|
|
16
16
|
|
|
17
|
+
The default loader is intended to work in both Vite dev/build and Nuxt client production bundles. If you need to override wasm loading explicitly, pass either:
|
|
18
|
+
|
|
19
|
+
- `loader: () => import("@sorisdk/matcher/generated/core.js")`
|
|
20
|
+
- `wasmModule: await import("@sorisdk/matcher/generated/core.js")`
|
|
21
|
+
|
|
17
22
|
## Minimal example
|
|
18
23
|
|
|
19
24
|
```ts
|
|
@@ -35,6 +40,20 @@ const result = await session.match(new Uint8Array([1, 2, 3]));
|
|
|
35
40
|
console.log(result.best);
|
|
36
41
|
```
|
|
37
42
|
|
|
43
|
+
## Advanced wasm loading
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import { MatcherSession, initMatcher } from "@sorisdk/matcher";
|
|
47
|
+
|
|
48
|
+
await initMatcher({
|
|
49
|
+
loader: () => import("@sorisdk/matcher/generated/core.js")
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const session = new MatcherSession({
|
|
53
|
+
wasmModule: await import("@sorisdk/matcher/generated/core.js")
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
38
57
|
## Pack loading
|
|
39
58
|
|
|
40
59
|
`loadPack(...)` accepts:
|
package/dist/generated/core.js
CHANGED
|
@@ -149,11 +149,11 @@ if (Symbol.dispose) WasmMatcherEngine.prototype[Symbol.dispose] = WasmMatcherEng
|
|
|
149
149
|
export function init_matcher_wasm() {
|
|
150
150
|
wasm.init_matcher_wasm();
|
|
151
151
|
}
|
|
152
|
-
export function
|
|
152
|
+
export function __wbg_Error_960c155d3d49e4c2(arg0, arg1) {
|
|
153
153
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
154
154
|
return ret;
|
|
155
155
|
}
|
|
156
|
-
export function
|
|
156
|
+
export function __wbg_Number_32bf70a599af1d4b(arg0) {
|
|
157
157
|
const ret = Number(arg0);
|
|
158
158
|
return ret;
|
|
159
159
|
}
|
|
@@ -164,46 +164,46 @@ export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
|
164
164
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
165
165
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
166
166
|
}
|
|
167
|
-
export function
|
|
167
|
+
export function __wbg___wbindgen_boolean_get_6ea149f0a8dcc5ff(arg0) {
|
|
168
168
|
const v = arg0;
|
|
169
169
|
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
170
170
|
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
171
171
|
}
|
|
172
|
-
export function
|
|
172
|
+
export function __wbg___wbindgen_debug_string_ab4b34d23d6778bd(arg0, arg1) {
|
|
173
173
|
const ret = debugString(arg1);
|
|
174
174
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
175
175
|
const len1 = WASM_VECTOR_LEN;
|
|
176
176
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
177
177
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
178
178
|
}
|
|
179
|
-
export function
|
|
179
|
+
export function __wbg___wbindgen_in_a5d8b22e52b24dd1(arg0, arg1) {
|
|
180
180
|
const ret = arg0 in arg1;
|
|
181
181
|
return ret;
|
|
182
182
|
}
|
|
183
|
-
export function
|
|
183
|
+
export function __wbg___wbindgen_is_null_52ff4ec04186736f(arg0) {
|
|
184
184
|
const ret = arg0 === null;
|
|
185
185
|
return ret;
|
|
186
186
|
}
|
|
187
|
-
export function
|
|
187
|
+
export function __wbg___wbindgen_is_object_63322ec0cd6ea4ef(arg0) {
|
|
188
188
|
const val = arg0;
|
|
189
189
|
const ret = typeof(val) === 'object' && val !== null;
|
|
190
190
|
return ret;
|
|
191
191
|
}
|
|
192
|
-
export function
|
|
192
|
+
export function __wbg___wbindgen_is_undefined_29a43b4d42920abd(arg0) {
|
|
193
193
|
const ret = arg0 === undefined;
|
|
194
194
|
return ret;
|
|
195
195
|
}
|
|
196
|
-
export function
|
|
196
|
+
export function __wbg___wbindgen_jsval_loose_eq_cac3565e89b4134c(arg0, arg1) {
|
|
197
197
|
const ret = arg0 == arg1;
|
|
198
198
|
return ret;
|
|
199
199
|
}
|
|
200
|
-
export function
|
|
200
|
+
export function __wbg___wbindgen_number_get_c7f42aed0525c451(arg0, arg1) {
|
|
201
201
|
const obj = arg1;
|
|
202
202
|
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
203
203
|
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
204
204
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
205
205
|
}
|
|
206
|
-
export function
|
|
206
|
+
export function __wbg___wbindgen_string_get_7ed5322991caaec5(arg0, arg1) {
|
|
207
207
|
const obj = arg1;
|
|
208
208
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
209
209
|
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -211,7 +211,7 @@ export function __wbg___wbindgen_string_get_914df97fcfa788f2(arg0, arg1) {
|
|
|
211
211
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
212
212
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
213
213
|
}
|
|
214
|
-
export function
|
|
214
|
+
export function __wbg___wbindgen_throw_6b64449b9b9ed33c(arg0, arg1) {
|
|
215
215
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
216
216
|
}
|
|
217
217
|
export function __wbg_error_a6fa202b58aa1cd3(arg0, arg1) {
|
|
@@ -229,7 +229,7 @@ export function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) {
|
|
|
229
229
|
const ret = arg0[arg1];
|
|
230
230
|
return ret;
|
|
231
231
|
}
|
|
232
|
-
export function
|
|
232
|
+
export function __wbg_instanceof_ArrayBuffer_7c8433c6ed14ffe3(arg0) {
|
|
233
233
|
let result;
|
|
234
234
|
try {
|
|
235
235
|
result = arg0 instanceof ArrayBuffer;
|
|
@@ -239,7 +239,7 @@ export function __wbg_instanceof_ArrayBuffer_ff7c1337a5e3b33a(arg0) {
|
|
|
239
239
|
const ret = result;
|
|
240
240
|
return ret;
|
|
241
241
|
}
|
|
242
|
-
export function
|
|
242
|
+
export function __wbg_instanceof_Uint8Array_152ba1f289edcf3f(arg0) {
|
|
243
243
|
let result;
|
|
244
244
|
try {
|
|
245
245
|
result = arg0 instanceof Uint8Array;
|
|
@@ -249,43 +249,43 @@ export function __wbg_instanceof_Uint8Array_4b8da683deb25d72(arg0) {
|
|
|
249
249
|
const ret = result;
|
|
250
250
|
return ret;
|
|
251
251
|
}
|
|
252
|
-
export function
|
|
252
|
+
export function __wbg_isSafeInteger_4fc213d1989d6d2a(arg0) {
|
|
253
253
|
const ret = Number.isSafeInteger(arg0);
|
|
254
254
|
return ret;
|
|
255
255
|
}
|
|
256
|
-
export function
|
|
256
|
+
export function __wbg_length_9f1775224cf1d815(arg0) {
|
|
257
257
|
const ret = arg0.length;
|
|
258
258
|
return ret;
|
|
259
259
|
}
|
|
260
|
-
export function
|
|
261
|
-
const ret = new
|
|
260
|
+
export function __wbg_new_0c7403db6e782f19(arg0) {
|
|
261
|
+
const ret = new Uint8Array(arg0);
|
|
262
262
|
return ret;
|
|
263
263
|
}
|
|
264
|
-
export function
|
|
265
|
-
const ret = new
|
|
264
|
+
export function __wbg_new_227d7c05414eb861() {
|
|
265
|
+
const ret = new Error();
|
|
266
266
|
return ret;
|
|
267
267
|
}
|
|
268
|
-
export function
|
|
269
|
-
const ret = new
|
|
268
|
+
export function __wbg_new_682678e2f47e32bc() {
|
|
269
|
+
const ret = new Array();
|
|
270
270
|
return ret;
|
|
271
271
|
}
|
|
272
|
-
export function
|
|
273
|
-
const ret = new
|
|
272
|
+
export function __wbg_new_aa8d0fa9762c29bd() {
|
|
273
|
+
const ret = new Object();
|
|
274
274
|
return ret;
|
|
275
275
|
}
|
|
276
|
-
export function
|
|
276
|
+
export function __wbg_now_a9b7df1cbee90986() {
|
|
277
277
|
const ret = Date.now();
|
|
278
278
|
return ret;
|
|
279
279
|
}
|
|
280
|
-
export function
|
|
280
|
+
export function __wbg_prototypesetcall_a6b02eb00b0f4ce2(arg0, arg1, arg2) {
|
|
281
281
|
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
282
282
|
}
|
|
283
|
+
export function __wbg_set_3bf1de9fab0cd644(arg0, arg1, arg2) {
|
|
284
|
+
arg0[arg1 >>> 0] = arg2;
|
|
285
|
+
}
|
|
283
286
|
export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
|
|
284
287
|
arg0[arg1] = arg2;
|
|
285
288
|
}
|
|
286
|
-
export function __wbg_set_6c60b2e8ad0e9383(arg0, arg1, arg2) {
|
|
287
|
-
arg0[arg1 >>> 0] = arg2;
|
|
288
|
-
}
|
|
289
289
|
export function __wbg_stack_3b0d974bbf31e44f(arg0, arg1) {
|
|
290
290
|
const ret = arg1.stack;
|
|
291
291
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
Binary file
|
package/dist/index.js
CHANGED
|
@@ -289,11 +289,8 @@ function getCallable(obj, names) {
|
|
|
289
289
|
return null;
|
|
290
290
|
}
|
|
291
291
|
var defaultLoader = async () => {
|
|
292
|
-
const
|
|
293
|
-
return
|
|
294
|
-
/* @vite-ignore */
|
|
295
|
-
generatedModuleUrl.href
|
|
296
|
-
);
|
|
292
|
+
const loaderModule = await import("./default-loader.js");
|
|
293
|
+
return loaderModule.default();
|
|
297
294
|
};
|
|
298
295
|
var INTERNAL_DUPLICATE_MATCH_FLAG = "__matcherDuplicate";
|
|
299
296
|
var WrappedDatabase = class {
|
|
@@ -380,15 +377,18 @@ var WrappedMatcher = class {
|
|
|
380
377
|
if (!raw) {
|
|
381
378
|
return null;
|
|
382
379
|
}
|
|
383
|
-
if (typeof raw === "object" && raw !== null
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
380
|
+
if (typeof raw === "object" && raw !== null) {
|
|
381
|
+
const duplicateResult = raw;
|
|
382
|
+
if (duplicateResult.duplicate === true && duplicateResult.best) {
|
|
383
|
+
const normalized = normalizeResult(duplicateResult.best);
|
|
384
|
+
Object.defineProperty(normalized, INTERNAL_DUPLICATE_MATCH_FLAG, {
|
|
385
|
+
value: true,
|
|
386
|
+
enumerable: false,
|
|
387
|
+
configurable: false,
|
|
388
|
+
writable: false
|
|
389
|
+
});
|
|
390
|
+
return normalized;
|
|
391
|
+
}
|
|
392
392
|
}
|
|
393
393
|
return normalizeResult(raw);
|
|
394
394
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sorisdk/matcher",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Browser WASM SDK for audio fingerprint matching",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build:wasm": "node ../../scripts/build-wasm-package.mjs matcher",
|
|
42
42
|
"build:assets": "node ./scripts/copy-assets.mjs",
|
|
43
|
-
"build": "tsup src/index.ts --format esm --dts && pnpm run build:wasm && pnpm run build:assets",
|
|
43
|
+
"build": "tsup src/index.ts --format esm --dts && pnpm run build:wasm && pnpm run build:assets && node ../../scripts/write-default-loader.mjs packages/matcher ./generated/core.js",
|
|
44
44
|
"test": "vitest run",
|
|
45
45
|
"test:watch": "vitest"
|
|
46
46
|
}
|