sillstone 0.0.0-stage → 0.2.0

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.
@@ -0,0 +1,511 @@
1
+ /* Generated by sillstone-idl-gen. DO NOT EDIT. */
2
+ #include <node_api.h>
3
+ #include <stdint.h>
4
+ #include <stddef.h>
5
+ #include <stdio.h>
6
+ #include "sillstone.h"
7
+
8
+ static void throw_status(napi_env env, int32_t status) {
9
+ char buf[16];
10
+ snprintf(buf, sizeof(buf), "%d", status);
11
+ napi_throw_error(env, buf, "FFI error");
12
+ }
13
+
14
+ static napi_value n_sillstone_version_major(napi_env env, napi_callback_info info) {
15
+ uint32_t val = sillstone_version_major();
16
+ napi_value result;
17
+ napi_create_uint32(env, val, &result);
18
+ return result;
19
+ }
20
+
21
+ static napi_value n_sillstone_version_minor(napi_env env, napi_callback_info info) {
22
+ uint32_t val = sillstone_version_minor();
23
+ napi_value result;
24
+ napi_create_uint32(env, val, &result);
25
+ return result;
26
+ }
27
+
28
+ static napi_value n_sillstone_version_patch(napi_env env, napi_callback_info info) {
29
+ uint32_t val = sillstone_version_patch();
30
+ napi_value result;
31
+ napi_create_uint32(env, val, &result);
32
+ return result;
33
+ }
34
+
35
+ static napi_value n_sillstone_buffer_checksum(napi_env env, napi_callback_info info) {
36
+ size_t argc = 1;
37
+ napi_value args[1];
38
+ napi_get_cb_info(env, info, &argc, args, NULL, NULL);
39
+ void* data;
40
+ size_t length;
41
+ napi_get_buffer_info(env, args[0], &data, &length);
42
+ uint64_t res = sillstone_buffer_checksum((const uint8_t*)data, length);
43
+ napi_value result;
44
+ napi_create_bigint_uint64(env, res, &result);
45
+ return result;
46
+ }
47
+
48
+ static napi_value n_sillstone_digest_sha256(napi_env env, napi_callback_info info) {
49
+ size_t argc = 1;
50
+ napi_value args[1];
51
+ napi_get_cb_info(env, info, &argc, args, NULL, NULL);
52
+ void* data = NULL;
53
+ size_t length = 0;
54
+ if (argc > 0) {
55
+ napi_get_buffer_info(env, args[0], &data, &length);
56
+ }
57
+ uint8_t out[32];
58
+ sillstone_digest_sha256((const uint8_t*)data, length, out);
59
+ napi_value result;
60
+ napi_create_buffer_copy(env, 32, out, NULL, &result);
61
+ return result;
62
+ }
63
+
64
+ static napi_value n_sillstone_digest_sha3_256(napi_env env, napi_callback_info info) {
65
+ size_t argc = 1;
66
+ napi_value args[1];
67
+ napi_get_cb_info(env, info, &argc, args, NULL, NULL);
68
+ void* data = NULL;
69
+ size_t length = 0;
70
+ if (argc > 0) {
71
+ napi_get_buffer_info(env, args[0], &data, &length);
72
+ }
73
+ uint8_t out[32];
74
+ sillstone_digest_sha3_256((const uint8_t*)data, length, out);
75
+ napi_value result;
76
+ napi_create_buffer_copy(env, 32, out, NULL, &result);
77
+ return result;
78
+ }
79
+
80
+ static napi_value n_sillstone_digest_sha3_512(napi_env env, napi_callback_info info) {
81
+ size_t argc = 1;
82
+ napi_value args[1];
83
+ napi_get_cb_info(env, info, &argc, args, NULL, NULL);
84
+ void* data = NULL;
85
+ size_t length = 0;
86
+ if (argc > 0) {
87
+ napi_get_buffer_info(env, args[0], &data, &length);
88
+ }
89
+ uint8_t out[64];
90
+ sillstone_digest_sha3_512((const uint8_t*)data, length, out);
91
+ napi_value result;
92
+ napi_create_buffer_copy(env, 64, out, NULL, &result);
93
+ return result;
94
+ }
95
+
96
+ static napi_value n_sillstone_digest_blake2b_512(napi_env env, napi_callback_info info) {
97
+ size_t argc = 1;
98
+ napi_value args[1];
99
+ napi_get_cb_info(env, info, &argc, args, NULL, NULL);
100
+ void* data = NULL;
101
+ size_t length = 0;
102
+ if (argc > 0) {
103
+ napi_get_buffer_info(env, args[0], &data, &length);
104
+ }
105
+ uint8_t out[64];
106
+ sillstone_digest_blake2b_512((const uint8_t*)data, length, out);
107
+ napi_value result;
108
+ napi_create_buffer_copy(env, 64, out, NULL, &result);
109
+ return result;
110
+ }
111
+
112
+ static napi_value n_sillstone_digest_blake3(napi_env env, napi_callback_info info) {
113
+ size_t argc = 1;
114
+ napi_value args[1];
115
+ napi_get_cb_info(env, info, &argc, args, NULL, NULL);
116
+ void* data = NULL;
117
+ size_t length = 0;
118
+ if (argc > 0) {
119
+ napi_get_buffer_info(env, args[0], &data, &length);
120
+ }
121
+ uint8_t out[32];
122
+ sillstone_digest_blake3((const uint8_t*)data, length, out);
123
+ napi_value result;
124
+ napi_create_buffer_copy(env, 32, out, NULL, &result);
125
+ return result;
126
+ }
127
+
128
+ static napi_value n_sillstone_math_dst1(napi_env env, napi_callback_info info) {
129
+ size_t argc = 1;
130
+ napi_value args[1];
131
+ napi_get_cb_info(env, info, &argc, args, NULL, NULL);
132
+ void* data = NULL;
133
+ size_t length = 0;
134
+ if (argc > 0) {
135
+ napi_get_buffer_info(env, args[0], &data, &length);
136
+ }
137
+ size_t count = length / sizeof(double);
138
+ napi_value result;
139
+ void* out_data = NULL;
140
+ napi_create_buffer(env, length, &out_data, &result);
141
+ sillstone_math_dst1((const double*)data, count, (double*)out_data);
142
+ return result;
143
+ }
144
+
145
+ static napi_value n_sillstone_math_dst2(napi_env env, napi_callback_info info) {
146
+ size_t argc = 1;
147
+ napi_value args[1];
148
+ napi_get_cb_info(env, info, &argc, args, NULL, NULL);
149
+ void* data = NULL;
150
+ size_t length = 0;
151
+ if (argc > 0) {
152
+ napi_get_buffer_info(env, args[0], &data, &length);
153
+ }
154
+ size_t count = length / sizeof(double);
155
+ napi_value result;
156
+ void* out_data = NULL;
157
+ napi_create_buffer(env, length, &out_data, &result);
158
+ sillstone_math_dst2((const double*)data, count, (double*)out_data);
159
+ return result;
160
+ }
161
+
162
+ static napi_value n_sillstone_math_dst3(napi_env env, napi_callback_info info) {
163
+ size_t argc = 1;
164
+ napi_value args[1];
165
+ napi_get_cb_info(env, info, &argc, args, NULL, NULL);
166
+ void* data = NULL;
167
+ size_t length = 0;
168
+ if (argc > 0) {
169
+ napi_get_buffer_info(env, args[0], &data, &length);
170
+ }
171
+ size_t count = length / sizeof(double);
172
+ napi_value result;
173
+ void* out_data = NULL;
174
+ napi_create_buffer(env, length, &out_data, &result);
175
+ sillstone_math_dst3((const double*)data, count, (double*)out_data);
176
+ return result;
177
+ }
178
+
179
+ static napi_value n_sillstone_unicode_grapheme_count(napi_env env, napi_callback_info info) {
180
+ size_t argc = 1;
181
+ napi_value args[1];
182
+ napi_get_cb_info(env, info, &argc, args, NULL, NULL);
183
+ void* data = NULL;
184
+ size_t length = 0;
185
+ if (argc > 0) {
186
+ napi_get_buffer_info(env, args[0], &data, &length);
187
+ }
188
+ size_t count = 0;
189
+ sillstone_unicode_grapheme_count((const uint8_t*)data, length, &count);
190
+ napi_value result;
191
+ napi_create_int64(env, (int64_t)count, &result);
192
+ return result;
193
+ }
194
+
195
+ static napi_value n_sillstone_unicode_char_category(napi_env env, napi_callback_info info) {
196
+ size_t argc = 1;
197
+ napi_value args[1];
198
+ napi_get_cb_info(env, info, &argc, args, NULL, NULL);
199
+ uint32_t cp = 0;
200
+ if (argc > 0) {
201
+ napi_get_value_uint32(env, args[0], &cp);
202
+ }
203
+ uint8_t cat = 0;
204
+ sillstone_unicode_char_category(cp, &cat);
205
+ napi_value result;
206
+ napi_create_uint32(env, cat, &result);
207
+ return result;
208
+ }
209
+
210
+ static napi_value n_sillstone_curator_detect(napi_env env, napi_callback_info info) {
211
+ size_t argc = 1;
212
+ napi_value args[1];
213
+ napi_get_cb_info(env, info, &argc, args, NULL, NULL);
214
+ void* data = NULL; size_t length = 0;
215
+ if (argc > 0) napi_get_buffer_info(env, args[0], &data, &length);
216
+ uint32_t format = 0, modality = 0, pending = 0;
217
+ int32_t status = sillstone_curator_detect((const uint8_t*)data, length, &format, &modality, &pending);
218
+ if (status != 0) { throw_status(env, status); return NULL; }
219
+ napi_value result, v_fmt, v_mod, v_pend;
220
+ napi_create_object(env, &result);
221
+ napi_create_uint32(env, format, &v_fmt);
222
+ napi_set_named_property(env, result, "format", v_fmt);
223
+ napi_create_uint32(env, modality, &v_mod);
224
+ napi_set_named_property(env, result, "modality", v_mod);
225
+ napi_create_uint32(env, pending, &v_pend);
226
+ napi_set_named_property(env, result, "pending", v_pend);
227
+ return result;
228
+ }
229
+
230
+ static napi_value n_sillstone_curator_content_hash(napi_env env, napi_callback_info info) {
231
+ size_t argc = 1;
232
+ napi_value args[1];
233
+ napi_get_cb_info(env, info, &argc, args, NULL, NULL);
234
+ void* data = NULL; size_t length = 0;
235
+ if (argc > 0) napi_get_buffer_info(env, args[0], &data, &length);
236
+ uint8_t out_buf[32];
237
+ size_t out_len = 0;
238
+ int32_t status = sillstone_curator_content_hash((const uint8_t*)data, length, out_buf, 32, &out_len);
239
+ if (status != 0) { throw_status(env, status); return NULL; }
240
+ napi_value result;
241
+ napi_create_buffer_copy(env, 32, out_buf, NULL, &result);
242
+ return result;
243
+ }
244
+
245
+ static napi_value n_sillstone_curator_signature(napi_env env, napi_callback_info info) {
246
+ size_t argc = 1;
247
+ napi_value args[1];
248
+ napi_get_cb_info(env, info, &argc, args, NULL, NULL);
249
+ void* data = NULL; size_t length = 0;
250
+ if (argc > 0) napi_get_buffer_info(env, args[0], &data, &length);
251
+ uint8_t* out_ptr = NULL; size_t out_len = 0;
252
+ int32_t status = sillstone_curator_signature((const uint8_t*)data, length, &out_ptr, &out_len);
253
+ if (status != 0 || out_ptr == NULL) { throw_status(env, status != 0 ? status : -1); return NULL; }
254
+ napi_value result;
255
+ napi_create_buffer_copy(env, out_len, out_ptr, NULL, &result);
256
+ sillstone_curator_free(out_ptr, out_len);
257
+ return result;
258
+ }
259
+
260
+ static napi_value n_sillstone_curator_describe(napi_env env, napi_callback_info info) {
261
+ size_t argc = 1;
262
+ napi_value args[1];
263
+ napi_get_cb_info(env, info, &argc, args, NULL, NULL);
264
+ void* data = NULL; size_t length = 0;
265
+ if (argc > 0) napi_get_buffer_info(env, args[0], &data, &length);
266
+ uint8_t* out_ptr = NULL; size_t out_len = 0;
267
+ int32_t status = sillstone_curator_describe((const uint8_t*)data, length, &out_ptr, &out_len);
268
+ if (status != 0 || out_ptr == NULL) { throw_status(env, status != 0 ? status : -1); return NULL; }
269
+ napi_value result;
270
+ napi_create_buffer_copy(env, out_len, out_ptr, NULL, &result);
271
+ sillstone_curator_free(out_ptr, out_len);
272
+ return result;
273
+ }
274
+
275
+ static napi_value n_sillstone_curator_match(napi_env env, napi_callback_info info) {
276
+ size_t argc = 2;
277
+ napi_value args[2];
278
+ napi_get_cb_info(env, info, &argc, args, NULL, NULL);
279
+ void* a = NULL; size_t a_len = 0;
280
+ void* b = NULL; size_t b_len = 0;
281
+ if (argc > 0) napi_get_buffer_info(env, args[0], &a, &a_len);
282
+ if (argc > 1) napi_get_buffer_info(env, args[1], &b, &b_len);
283
+ uint32_t tag = 0, matched = 0; uint64_t slots[4] = {0};
284
+ int32_t status = sillstone_curator_match((const uint8_t*)a, a_len, (const uint8_t*)b, b_len, &tag, slots, 4, &matched);
285
+ if (status != 0) { throw_status(env, status); return NULL; }
286
+ napi_value result, v_tag, v_slots, v_matched;
287
+ napi_create_object(env, &result);
288
+ napi_create_uint32(env, tag, &v_tag);
289
+ napi_set_named_property(env, result, "tag", v_tag);
290
+ napi_create_array_with_length(env, 4, &v_slots);
291
+ for (uint32_t i = 0; i < 4; i++) {
292
+ napi_value sv;
293
+ napi_create_bigint_uint64(env, slots[i], &sv);
294
+ napi_set_element(env, v_slots, i, sv);
295
+ }
296
+ napi_set_named_property(env, result, "slots", v_slots);
297
+ napi_create_uint32(env, matched, &v_matched);
298
+ napi_set_named_property(env, result, "matched", v_matched);
299
+ return result;
300
+ }
301
+
302
+ static napi_value n_sillstone_curator_free(napi_env env, napi_callback_info info) {
303
+ napi_value result;
304
+ napi_get_undefined(env, &result);
305
+ return result;
306
+ }
307
+
308
+ static napi_value n_sillstone_image_phash(napi_env env, napi_callback_info info) {
309
+ size_t argc = 4;
310
+ napi_value args[4];
311
+ napi_get_cb_info(env, info, &argc, args, NULL, NULL);
312
+ void* data = NULL; size_t length = 0;
313
+ if (argc > 0) napi_get_buffer_info(env, args[0], &data, &length);
314
+ uint32_t width = 0, height = 0, layout = 0;
315
+ if (argc > 1) napi_get_value_uint32(env, args[1], &width);
316
+ if (argc > 2) napi_get_value_uint32(env, args[2], &height);
317
+ if (argc > 3) napi_get_value_uint32(env, args[3], &layout);
318
+ uint64_t hash_val = 0;
319
+ int32_t status = sillstone_image_phash((const uint8_t*)data, length, width, height, layout, &hash_val);
320
+ if (status != 0) { napi_throw_error(env, NULL, "image hash failed"); return NULL; }
321
+ napi_value result;
322
+ napi_create_bigint_uint64(env, hash_val, &result);
323
+ return result;
324
+ }
325
+
326
+ static napi_value n_sillstone_image_ahash(napi_env env, napi_callback_info info) {
327
+ size_t argc = 4;
328
+ napi_value args[4];
329
+ napi_get_cb_info(env, info, &argc, args, NULL, NULL);
330
+ void* data = NULL; size_t length = 0;
331
+ if (argc > 0) napi_get_buffer_info(env, args[0], &data, &length);
332
+ uint32_t width = 0, height = 0, layout = 0;
333
+ if (argc > 1) napi_get_value_uint32(env, args[1], &width);
334
+ if (argc > 2) napi_get_value_uint32(env, args[2], &height);
335
+ if (argc > 3) napi_get_value_uint32(env, args[3], &layout);
336
+ uint64_t hash_val = 0;
337
+ int32_t status = sillstone_image_ahash((const uint8_t*)data, length, width, height, layout, &hash_val);
338
+ if (status != 0) { napi_throw_error(env, NULL, "image hash failed"); return NULL; }
339
+ napi_value result;
340
+ napi_create_bigint_uint64(env, hash_val, &result);
341
+ return result;
342
+ }
343
+
344
+ static napi_value n_sillstone_image_dhash(napi_env env, napi_callback_info info) {
345
+ size_t argc = 4;
346
+ napi_value args[4];
347
+ napi_get_cb_info(env, info, &argc, args, NULL, NULL);
348
+ void* data = NULL; size_t length = 0;
349
+ if (argc > 0) napi_get_buffer_info(env, args[0], &data, &length);
350
+ uint32_t width = 0, height = 0, layout = 0;
351
+ if (argc > 1) napi_get_value_uint32(env, args[1], &width);
352
+ if (argc > 2) napi_get_value_uint32(env, args[2], &height);
353
+ if (argc > 3) napi_get_value_uint32(env, args[3], &layout);
354
+ uint64_t hash_val = 0;
355
+ int32_t status = sillstone_image_dhash((const uint8_t*)data, length, width, height, layout, &hash_val);
356
+ if (status != 0) { napi_throw_error(env, NULL, "image hash failed"); return NULL; }
357
+ napi_value result;
358
+ napi_create_bigint_uint64(env, hash_val, &result);
359
+ return result;
360
+ }
361
+
362
+ static napi_value n_sillstone_image_whash(napi_env env, napi_callback_info info) {
363
+ size_t argc = 4;
364
+ napi_value args[4];
365
+ napi_get_cb_info(env, info, &argc, args, NULL, NULL);
366
+ void* data = NULL; size_t length = 0;
367
+ if (argc > 0) napi_get_buffer_info(env, args[0], &data, &length);
368
+ uint32_t width = 0, height = 0, layout = 0;
369
+ if (argc > 1) napi_get_value_uint32(env, args[1], &width);
370
+ if (argc > 2) napi_get_value_uint32(env, args[2], &height);
371
+ if (argc > 3) napi_get_value_uint32(env, args[3], &layout);
372
+ uint64_t hash_val = 0;
373
+ int32_t status = sillstone_image_whash((const uint8_t*)data, length, width, height, layout, 3, &hash_val);
374
+ if (status != 0) { napi_throw_error(env, NULL, "image hash failed"); return NULL; }
375
+ napi_value result;
376
+ napi_create_bigint_uint64(env, hash_val, &result);
377
+ return result;
378
+ }
379
+
380
+ static napi_value n_sillstone_image_colorhash(napi_env env, napi_callback_info info) {
381
+ size_t argc = 4;
382
+ napi_value args[4];
383
+ napi_get_cb_info(env, info, &argc, args, NULL, NULL);
384
+ void* data = NULL; size_t length = 0;
385
+ if (argc > 0) napi_get_buffer_info(env, args[0], &data, &length);
386
+ uint32_t width = 0, height = 0, layout = 0;
387
+ if (argc > 1) napi_get_value_uint32(env, args[1], &width);
388
+ if (argc > 2) napi_get_value_uint32(env, args[2], &height);
389
+ if (argc > 3) napi_get_value_uint32(env, args[3], &layout);
390
+ uint64_t hash_val = 0;
391
+ int32_t status = sillstone_image_colorhash((const uint8_t*)data, length, width, height, layout, 4, &hash_val);
392
+ if (status != 0) { napi_throw_error(env, NULL, "image hash failed"); return NULL; }
393
+ napi_value result;
394
+ napi_create_bigint_uint64(env, hash_val, &result);
395
+ return result;
396
+ }
397
+
398
+ static napi_value n_sillstone_text_tlsh(napi_env env, napi_callback_info info) {
399
+ size_t argc = 1;
400
+ napi_value args[1];
401
+ napi_get_cb_info(env, info, &argc, args, NULL, NULL);
402
+ void* data = NULL; size_t length = 0;
403
+ if (argc > 0) napi_get_buffer_info(env, args[0], &data, &length);
404
+ uint8_t out_buf[72];
405
+ int32_t status = sillstone_text_tlsh((const uint8_t*)data, length, out_buf);
406
+ if (status != 0) { napi_throw_error(env, NULL, "tlsh failed"); return NULL; }
407
+ napi_value result;
408
+ napi_create_buffer_copy(env, 72, out_buf, NULL, &result);
409
+ return result;
410
+ }
411
+
412
+ static napi_value n_sillstone_text_tlsh_distance(napi_env env, napi_callback_info info) {
413
+ size_t argc = 2;
414
+ napi_value args[2];
415
+ napi_get_cb_info(env, info, &argc, args, NULL, NULL);
416
+ void* a = NULL; size_t a_len = 0;
417
+ void* b = NULL; size_t b_len = 0;
418
+ if (argc > 0) napi_get_buffer_info(env, args[0], &a, &a_len);
419
+ if (argc > 1) napi_get_buffer_info(env, args[1], &b, &b_len);
420
+ uint32_t dist = 0;
421
+ int32_t status = sillstone_text_tlsh_distance((const uint8_t*)a, (const uint8_t*)b, &dist);
422
+ if (status != 0) { throw_status(env, status); return NULL; }
423
+ napi_value result;
424
+ napi_create_uint32(env, dist, &result);
425
+ return result;
426
+ }
427
+
428
+ NAPI_MODULE_INIT() {
429
+ napi_value fn_sillstone_version_major;
430
+ napi_create_function(env, NULL, 0, n_sillstone_version_major, NULL, &fn_sillstone_version_major);
431
+ napi_set_named_property(env, exports, "sillstone_version_major", fn_sillstone_version_major);
432
+ napi_value fn_sillstone_version_minor;
433
+ napi_create_function(env, NULL, 0, n_sillstone_version_minor, NULL, &fn_sillstone_version_minor);
434
+ napi_set_named_property(env, exports, "sillstone_version_minor", fn_sillstone_version_minor);
435
+ napi_value fn_sillstone_version_patch;
436
+ napi_create_function(env, NULL, 0, n_sillstone_version_patch, NULL, &fn_sillstone_version_patch);
437
+ napi_set_named_property(env, exports, "sillstone_version_patch", fn_sillstone_version_patch);
438
+ napi_value fn_sillstone_buffer_checksum;
439
+ napi_create_function(env, NULL, 0, n_sillstone_buffer_checksum, NULL, &fn_sillstone_buffer_checksum);
440
+ napi_set_named_property(env, exports, "sillstone_buffer_checksum", fn_sillstone_buffer_checksum);
441
+ napi_value fn_sillstone_digest_sha256;
442
+ napi_create_function(env, NULL, 0, n_sillstone_digest_sha256, NULL, &fn_sillstone_digest_sha256);
443
+ napi_set_named_property(env, exports, "sillstone_digest_sha256", fn_sillstone_digest_sha256);
444
+ napi_value fn_sillstone_digest_sha3_256;
445
+ napi_create_function(env, NULL, 0, n_sillstone_digest_sha3_256, NULL, &fn_sillstone_digest_sha3_256);
446
+ napi_set_named_property(env, exports, "sillstone_digest_sha3_256", fn_sillstone_digest_sha3_256);
447
+ napi_value fn_sillstone_digest_sha3_512;
448
+ napi_create_function(env, NULL, 0, n_sillstone_digest_sha3_512, NULL, &fn_sillstone_digest_sha3_512);
449
+ napi_set_named_property(env, exports, "sillstone_digest_sha3_512", fn_sillstone_digest_sha3_512);
450
+ napi_value fn_sillstone_digest_blake2b_512;
451
+ napi_create_function(env, NULL, 0, n_sillstone_digest_blake2b_512, NULL, &fn_sillstone_digest_blake2b_512);
452
+ napi_set_named_property(env, exports, "sillstone_digest_blake2b_512", fn_sillstone_digest_blake2b_512);
453
+ napi_value fn_sillstone_digest_blake3;
454
+ napi_create_function(env, NULL, 0, n_sillstone_digest_blake3, NULL, &fn_sillstone_digest_blake3);
455
+ napi_set_named_property(env, exports, "sillstone_digest_blake3", fn_sillstone_digest_blake3);
456
+ napi_value fn_sillstone_math_dst1;
457
+ napi_create_function(env, NULL, 0, n_sillstone_math_dst1, NULL, &fn_sillstone_math_dst1);
458
+ napi_set_named_property(env, exports, "sillstone_math_dst1", fn_sillstone_math_dst1);
459
+ napi_value fn_sillstone_math_dst2;
460
+ napi_create_function(env, NULL, 0, n_sillstone_math_dst2, NULL, &fn_sillstone_math_dst2);
461
+ napi_set_named_property(env, exports, "sillstone_math_dst2", fn_sillstone_math_dst2);
462
+ napi_value fn_sillstone_math_dst3;
463
+ napi_create_function(env, NULL, 0, n_sillstone_math_dst3, NULL, &fn_sillstone_math_dst3);
464
+ napi_set_named_property(env, exports, "sillstone_math_dst3", fn_sillstone_math_dst3);
465
+ napi_value fn_sillstone_unicode_grapheme_count;
466
+ napi_create_function(env, NULL, 0, n_sillstone_unicode_grapheme_count, NULL, &fn_sillstone_unicode_grapheme_count);
467
+ napi_set_named_property(env, exports, "sillstone_unicode_grapheme_count", fn_sillstone_unicode_grapheme_count);
468
+ napi_value fn_sillstone_unicode_char_category;
469
+ napi_create_function(env, NULL, 0, n_sillstone_unicode_char_category, NULL, &fn_sillstone_unicode_char_category);
470
+ napi_set_named_property(env, exports, "sillstone_unicode_char_category", fn_sillstone_unicode_char_category);
471
+ napi_value fn_sillstone_curator_detect;
472
+ napi_create_function(env, NULL, 0, n_sillstone_curator_detect, NULL, &fn_sillstone_curator_detect);
473
+ napi_set_named_property(env, exports, "sillstone_curator_detect", fn_sillstone_curator_detect);
474
+ napi_value fn_sillstone_curator_content_hash;
475
+ napi_create_function(env, NULL, 0, n_sillstone_curator_content_hash, NULL, &fn_sillstone_curator_content_hash);
476
+ napi_set_named_property(env, exports, "sillstone_curator_content_hash", fn_sillstone_curator_content_hash);
477
+ napi_value fn_sillstone_curator_signature;
478
+ napi_create_function(env, NULL, 0, n_sillstone_curator_signature, NULL, &fn_sillstone_curator_signature);
479
+ napi_set_named_property(env, exports, "sillstone_curator_signature", fn_sillstone_curator_signature);
480
+ napi_value fn_sillstone_curator_describe;
481
+ napi_create_function(env, NULL, 0, n_sillstone_curator_describe, NULL, &fn_sillstone_curator_describe);
482
+ napi_set_named_property(env, exports, "sillstone_curator_describe", fn_sillstone_curator_describe);
483
+ napi_value fn_sillstone_curator_match;
484
+ napi_create_function(env, NULL, 0, n_sillstone_curator_match, NULL, &fn_sillstone_curator_match);
485
+ napi_set_named_property(env, exports, "sillstone_curator_match", fn_sillstone_curator_match);
486
+ napi_value fn_sillstone_curator_free;
487
+ napi_create_function(env, NULL, 0, n_sillstone_curator_free, NULL, &fn_sillstone_curator_free);
488
+ napi_set_named_property(env, exports, "sillstone_curator_free", fn_sillstone_curator_free);
489
+ napi_value fn_sillstone_image_phash;
490
+ napi_create_function(env, NULL, 0, n_sillstone_image_phash, NULL, &fn_sillstone_image_phash);
491
+ napi_set_named_property(env, exports, "sillstone_image_phash", fn_sillstone_image_phash);
492
+ napi_value fn_sillstone_image_ahash;
493
+ napi_create_function(env, NULL, 0, n_sillstone_image_ahash, NULL, &fn_sillstone_image_ahash);
494
+ napi_set_named_property(env, exports, "sillstone_image_ahash", fn_sillstone_image_ahash);
495
+ napi_value fn_sillstone_image_dhash;
496
+ napi_create_function(env, NULL, 0, n_sillstone_image_dhash, NULL, &fn_sillstone_image_dhash);
497
+ napi_set_named_property(env, exports, "sillstone_image_dhash", fn_sillstone_image_dhash);
498
+ napi_value fn_sillstone_image_whash;
499
+ napi_create_function(env, NULL, 0, n_sillstone_image_whash, NULL, &fn_sillstone_image_whash);
500
+ napi_set_named_property(env, exports, "sillstone_image_whash", fn_sillstone_image_whash);
501
+ napi_value fn_sillstone_image_colorhash;
502
+ napi_create_function(env, NULL, 0, n_sillstone_image_colorhash, NULL, &fn_sillstone_image_colorhash);
503
+ napi_set_named_property(env, exports, "sillstone_image_colorhash", fn_sillstone_image_colorhash);
504
+ napi_value fn_sillstone_text_tlsh;
505
+ napi_create_function(env, NULL, 0, n_sillstone_text_tlsh, NULL, &fn_sillstone_text_tlsh);
506
+ napi_set_named_property(env, exports, "sillstone_text_tlsh", fn_sillstone_text_tlsh);
507
+ napi_value fn_sillstone_text_tlsh_distance;
508
+ napi_create_function(env, NULL, 0, n_sillstone_text_tlsh_distance, NULL, &fn_sillstone_text_tlsh_distance);
509
+ napi_set_named_property(env, exports, "sillstone_text_tlsh_distance", fn_sillstone_text_tlsh_distance);
510
+ return exports;
511
+ }
package/src/node.def ADDED
@@ -0,0 +1,16 @@
1
+ EXPORTS
2
+ napi_create_array_with_length
3
+ napi_create_bigint_uint64
4
+ napi_create_buffer
5
+ napi_create_buffer_copy
6
+ napi_create_function
7
+ napi_create_int64
8
+ napi_create_object
9
+ napi_create_uint32
10
+ napi_get_buffer_info
11
+ napi_get_cb_info
12
+ napi_get_undefined
13
+ napi_get_value_uint32
14
+ napi_set_element
15
+ napi_set_named_property
16
+ napi_throw_error
package/src/node_api.h ADDED
@@ -0,0 +1,104 @@
1
+ #ifndef SRC_NODE_API_H_
2
+ #define SRC_NODE_API_H_
3
+
4
+ #include <stddef.h>
5
+ #include <stdint.h>
6
+
7
+ #ifdef __cplusplus
8
+ extern "C" {
9
+ #endif
10
+
11
+ typedef struct napi_env__* napi_env;
12
+ typedef struct napi_value__* napi_value;
13
+ typedef struct napi_ref__* napi_ref;
14
+ typedef struct napi_handle_scope__* napi_handle_scope;
15
+ typedef struct napi_escapable_handle_scope__* napi_escapable_handle_scope;
16
+ typedef struct napi_callback_info__* napi_callback_info;
17
+ typedef struct napi_async_context__* napi_async_context;
18
+ typedef struct napi_async_work__* napi_async_work;
19
+
20
+ typedef enum {
21
+ napi_ok,
22
+ napi_invalid_arg,
23
+ napi_object_expected,
24
+ napi_string_expected,
25
+ napi_name_expected,
26
+ napi_function_expected,
27
+ napi_number_expected,
28
+ napi_boolean_expected,
29
+ napi_array_expected,
30
+ napi_generic_failure,
31
+ napi_pending_exception,
32
+ napi_cancelled,
33
+ napi_escape_called_twice,
34
+ napi_handle_scope_mismatch,
35
+ napi_callback_scope_mismatch,
36
+ napi_queue_full,
37
+ napi_closing,
38
+ napi_bigint_expected,
39
+ napi_date_expected,
40
+ napi_arraybuffer_expected,
41
+ napi_detachable_arraybuffer_expected,
42
+ napi_would_deadlock
43
+ } napi_status;
44
+
45
+ typedef napi_value (*napi_callback)(napi_env env, napi_callback_info info);
46
+
47
+ #if defined(_WIN32)
48
+ #define NAPI_MODULE_EXPORT __declspec(dllexport)
49
+ #else
50
+ #define NAPI_MODULE_EXPORT __attribute__((visibility("default")))
51
+ #endif
52
+
53
+ #define NAPI_MODULE_INIT() \
54
+ NAPI_MODULE_EXPORT napi_value \
55
+ napi_register_module_v1(napi_env env, napi_value exports)
56
+
57
+ napi_status napi_get_cb_info(napi_env env,
58
+ napi_callback_info cbinfo,
59
+ size_t* argc,
60
+ napi_value* argv,
61
+ napi_value* this_arg,
62
+ void** data);
63
+
64
+ napi_status napi_get_buffer_info(napi_env env,
65
+ napi_value value,
66
+ void** data,
67
+ size_t* length);
68
+
69
+ napi_status napi_create_buffer(napi_env env,
70
+ size_t size,
71
+ void** data,
72
+ napi_value* result);
73
+
74
+ napi_status napi_create_buffer_copy(napi_env env,
75
+ size_t length,
76
+ const void* data,
77
+ void** result_data,
78
+ napi_value* result);
79
+
80
+ napi_status napi_create_uint32(napi_env env, uint32_t value, napi_value* result);
81
+ napi_status napi_get_value_uint32(napi_env env, napi_value value, uint32_t* result);
82
+ napi_status napi_create_int64(napi_env env, int64_t value, napi_value* result);
83
+ napi_status napi_create_bigint_uint64(napi_env env, uint64_t value, napi_value* result);
84
+ napi_status napi_create_object(napi_env env, napi_value* result);
85
+ napi_status napi_set_named_property(napi_env env,
86
+ napi_value object,
87
+ const char* utf8name,
88
+ napi_value value);
89
+ napi_status napi_create_array_with_length(napi_env env, size_t length, napi_value* result);
90
+ napi_status napi_set_element(napi_env env, napi_value object, uint32_t index, napi_value value);
91
+ napi_status napi_get_undefined(napi_env env, napi_value* result);
92
+ napi_status napi_throw_error(napi_env env, const char* code, const char* msg);
93
+ napi_status napi_create_function(napi_env env,
94
+ const char* utf8name,
95
+ size_t length,
96
+ napi_callback cb,
97
+ void* data,
98
+ napi_value* result);
99
+
100
+ #ifdef __cplusplus
101
+ }
102
+ #endif
103
+
104
+ #endif // SRC_NODE_API_H_