deepbom 0.1.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.
- package/LICENSE +15 -0
- package/README.md +111 -0
- package/bin/deepbom.js +188 -0
- package/package.json +33 -0
- package/vendor/tflite_wasm_audit.js +1222 -0
- package/vendor/tflite_wasm_audit_bg.js +333 -0
- package/vendor/tflite_wasm_audit_bg.wasm +0 -0
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {Uint8Array} bytes
|
|
3
|
+
* @param {string} filename
|
|
4
|
+
* @returns {any}
|
|
5
|
+
*/
|
|
6
|
+
export function analyze_tflite(bytes, filename) {
|
|
7
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
8
|
+
const len0 = WASM_VECTOR_LEN;
|
|
9
|
+
const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
10
|
+
const len1 = WASM_VECTOR_LEN;
|
|
11
|
+
const ret = wasm.analyze_tflite(ptr0, len0, ptr1, len1);
|
|
12
|
+
if (ret[2]) {
|
|
13
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
14
|
+
}
|
|
15
|
+
return takeFromExternrefTable0(ret[0]);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {Uint8Array} bytes
|
|
20
|
+
* @param {string} filename
|
|
21
|
+
* @param {string} target_id
|
|
22
|
+
* @returns {any}
|
|
23
|
+
*/
|
|
24
|
+
export function analyze_tflite_for_target(bytes, filename, target_id) {
|
|
25
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
26
|
+
const len0 = WASM_VECTOR_LEN;
|
|
27
|
+
const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
28
|
+
const len1 = WASM_VECTOR_LEN;
|
|
29
|
+
const ptr2 = passStringToWasm0(target_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
30
|
+
const len2 = WASM_VECTOR_LEN;
|
|
31
|
+
const ret = wasm.analyze_tflite_for_target(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
32
|
+
if (ret[2]) {
|
|
33
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
34
|
+
}
|
|
35
|
+
return takeFromExternrefTable0(ret[0]);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @param {Uint8Array} rgba
|
|
40
|
+
* @param {number} channels
|
|
41
|
+
* @param {number} mean_r
|
|
42
|
+
* @param {number} mean_g
|
|
43
|
+
* @param {number} mean_b
|
|
44
|
+
* @param {number} std_r
|
|
45
|
+
* @param {number} std_g
|
|
46
|
+
* @param {number} std_b
|
|
47
|
+
* @param {boolean} bgr
|
|
48
|
+
* @returns {Float32Array}
|
|
49
|
+
*/
|
|
50
|
+
export function preprocess_rgba_to_float32(rgba, channels, mean_r, mean_g, mean_b, std_r, std_g, std_b, bgr) {
|
|
51
|
+
const ptr0 = passArray8ToWasm0(rgba, wasm.__wbindgen_malloc);
|
|
52
|
+
const len0 = WASM_VECTOR_LEN;
|
|
53
|
+
const ret = wasm.preprocess_rgba_to_float32(ptr0, len0, channels, mean_r, mean_g, mean_b, std_r, std_g, std_b, bgr);
|
|
54
|
+
if (ret[2]) {
|
|
55
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
56
|
+
}
|
|
57
|
+
return takeFromExternrefTable0(ret[0]);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @param {Uint8Array} rgba
|
|
62
|
+
* @param {number} channels
|
|
63
|
+
* @param {number} mean_r
|
|
64
|
+
* @param {number} mean_g
|
|
65
|
+
* @param {number} mean_b
|
|
66
|
+
* @param {number} std_r
|
|
67
|
+
* @param {number} std_g
|
|
68
|
+
* @param {number} std_b
|
|
69
|
+
* @param {number} scale
|
|
70
|
+
* @param {number} zero_point
|
|
71
|
+
* @param {boolean} bgr
|
|
72
|
+
* @returns {Int8Array}
|
|
73
|
+
*/
|
|
74
|
+
export function preprocess_rgba_to_int8(rgba, channels, mean_r, mean_g, mean_b, std_r, std_g, std_b, scale, zero_point, bgr) {
|
|
75
|
+
const ptr0 = passArray8ToWasm0(rgba, wasm.__wbindgen_malloc);
|
|
76
|
+
const len0 = WASM_VECTOR_LEN;
|
|
77
|
+
const ret = wasm.preprocess_rgba_to_int8(ptr0, len0, channels, mean_r, mean_g, mean_b, std_r, std_g, std_b, scale, zero_point, bgr);
|
|
78
|
+
if (ret[2]) {
|
|
79
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
80
|
+
}
|
|
81
|
+
return takeFromExternrefTable0(ret[0]);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @param {Uint8Array} rgba
|
|
86
|
+
* @param {number} channels
|
|
87
|
+
* @param {number} mean_r
|
|
88
|
+
* @param {number} mean_g
|
|
89
|
+
* @param {number} mean_b
|
|
90
|
+
* @param {number} std_r
|
|
91
|
+
* @param {number} std_g
|
|
92
|
+
* @param {number} std_b
|
|
93
|
+
* @param {number} scale
|
|
94
|
+
* @param {number} zero_point
|
|
95
|
+
* @param {boolean} bgr
|
|
96
|
+
* @returns {Uint8Array}
|
|
97
|
+
*/
|
|
98
|
+
export function preprocess_rgba_to_uint8(rgba, channels, mean_r, mean_g, mean_b, std_r, std_g, std_b, scale, zero_point, bgr) {
|
|
99
|
+
const ptr0 = passArray8ToWasm0(rgba, wasm.__wbindgen_malloc);
|
|
100
|
+
const len0 = WASM_VECTOR_LEN;
|
|
101
|
+
const ret = wasm.preprocess_rgba_to_uint8(ptr0, len0, channels, mean_r, mean_g, mean_b, std_r, std_g, std_b, scale, zero_point, bgr);
|
|
102
|
+
if (ret[2]) {
|
|
103
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
104
|
+
}
|
|
105
|
+
return takeFromExternrefTable0(ret[0]);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @returns {number}
|
|
110
|
+
*/
|
|
111
|
+
export function runtime_guard() {
|
|
112
|
+
const ret = wasm.runtime_guard();
|
|
113
|
+
return ret >>> 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @returns {any}
|
|
118
|
+
*/
|
|
119
|
+
export function target_profiles() {
|
|
120
|
+
const ret = wasm.target_profiles();
|
|
121
|
+
if (ret[2]) {
|
|
122
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
123
|
+
}
|
|
124
|
+
return takeFromExternrefTable0(ret[0]);
|
|
125
|
+
}
|
|
126
|
+
export function __wbg_Error_fdd633d4bb5dd76a(arg0, arg1) {
|
|
127
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
128
|
+
return ret;
|
|
129
|
+
}
|
|
130
|
+
export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
131
|
+
const ret = String(arg1);
|
|
132
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
133
|
+
const len1 = WASM_VECTOR_LEN;
|
|
134
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
135
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
136
|
+
}
|
|
137
|
+
export function __wbg___wbindgen_throw_ea4887a5f8f9a9db(arg0, arg1) {
|
|
138
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
139
|
+
}
|
|
140
|
+
export function __wbg_new_2e117a478906f062() {
|
|
141
|
+
const ret = new Object();
|
|
142
|
+
return ret;
|
|
143
|
+
}
|
|
144
|
+
export function __wbg_new_36e147a8ced3c6e0() {
|
|
145
|
+
const ret = new Array();
|
|
146
|
+
return ret;
|
|
147
|
+
}
|
|
148
|
+
export function __wbg_new_from_slice_11a22f36c0757610(arg0, arg1) {
|
|
149
|
+
const ret = new Int8Array(getArrayI8FromWasm0(arg0, arg1));
|
|
150
|
+
return ret;
|
|
151
|
+
}
|
|
152
|
+
export function __wbg_new_from_slice_543b875b27789a8f(arg0, arg1) {
|
|
153
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
154
|
+
return ret;
|
|
155
|
+
}
|
|
156
|
+
export function __wbg_new_from_slice_6696ab0c133d3f19(arg0, arg1) {
|
|
157
|
+
const ret = new Float32Array(getArrayF32FromWasm0(arg0, arg1));
|
|
158
|
+
return ret;
|
|
159
|
+
}
|
|
160
|
+
export function __wbg_now_d2e0afbad4edbe82() {
|
|
161
|
+
const ret = Date.now();
|
|
162
|
+
return ret;
|
|
163
|
+
}
|
|
164
|
+
export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
|
|
165
|
+
arg0[arg1] = arg2;
|
|
166
|
+
}
|
|
167
|
+
export function __wbg_set_dc601f4a69da0bc2(arg0, arg1, arg2) {
|
|
168
|
+
arg0[arg1 >>> 0] = arg2;
|
|
169
|
+
}
|
|
170
|
+
export function __wbindgen_cast_0000000000000001(arg0) {
|
|
171
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
172
|
+
const ret = arg0;
|
|
173
|
+
return ret;
|
|
174
|
+
}
|
|
175
|
+
export function __wbindgen_cast_0000000000000002(arg0) {
|
|
176
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
177
|
+
const ret = arg0;
|
|
178
|
+
return ret;
|
|
179
|
+
}
|
|
180
|
+
export function __wbindgen_cast_0000000000000003(arg0, arg1) {
|
|
181
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
182
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
183
|
+
return ret;
|
|
184
|
+
}
|
|
185
|
+
export function __wbindgen_cast_0000000000000004(arg0) {
|
|
186
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
187
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
188
|
+
return ret;
|
|
189
|
+
}
|
|
190
|
+
export function __wbindgen_init_externref_table() {
|
|
191
|
+
const table = wasm.__wbindgen_externrefs;
|
|
192
|
+
const offset = table.grow(4);
|
|
193
|
+
table.set(0, undefined);
|
|
194
|
+
table.set(offset + 0, undefined);
|
|
195
|
+
table.set(offset + 1, null);
|
|
196
|
+
table.set(offset + 2, true);
|
|
197
|
+
table.set(offset + 3, false);
|
|
198
|
+
}
|
|
199
|
+
function getArrayF32FromWasm0(ptr, len) {
|
|
200
|
+
ptr = ptr >>> 0;
|
|
201
|
+
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function getArrayI8FromWasm0(ptr, len) {
|
|
205
|
+
ptr = ptr >>> 0;
|
|
206
|
+
return getInt8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
210
|
+
ptr = ptr >>> 0;
|
|
211
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
let cachedDataViewMemory0 = null;
|
|
215
|
+
function getDataViewMemory0() {
|
|
216
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
217
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
218
|
+
}
|
|
219
|
+
return cachedDataViewMemory0;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
let cachedFloat32ArrayMemory0 = null;
|
|
223
|
+
function getFloat32ArrayMemory0() {
|
|
224
|
+
if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
|
|
225
|
+
cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
|
|
226
|
+
}
|
|
227
|
+
return cachedFloat32ArrayMemory0;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
let cachedInt8ArrayMemory0 = null;
|
|
231
|
+
function getInt8ArrayMemory0() {
|
|
232
|
+
if (cachedInt8ArrayMemory0 === null || cachedInt8ArrayMemory0.byteLength === 0) {
|
|
233
|
+
cachedInt8ArrayMemory0 = new Int8Array(wasm.memory.buffer);
|
|
234
|
+
}
|
|
235
|
+
return cachedInt8ArrayMemory0;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function getStringFromWasm0(ptr, len) {
|
|
239
|
+
return decodeText(ptr >>> 0, len);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
let cachedUint8ArrayMemory0 = null;
|
|
243
|
+
function getUint8ArrayMemory0() {
|
|
244
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
245
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
246
|
+
}
|
|
247
|
+
return cachedUint8ArrayMemory0;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
251
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
252
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
253
|
+
WASM_VECTOR_LEN = arg.length;
|
|
254
|
+
return ptr;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
258
|
+
if (realloc === undefined) {
|
|
259
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
260
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
261
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
262
|
+
WASM_VECTOR_LEN = buf.length;
|
|
263
|
+
return ptr;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
let len = arg.length;
|
|
267
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
268
|
+
|
|
269
|
+
const mem = getUint8ArrayMemory0();
|
|
270
|
+
|
|
271
|
+
let offset = 0;
|
|
272
|
+
|
|
273
|
+
for (; offset < len; offset++) {
|
|
274
|
+
const code = arg.charCodeAt(offset);
|
|
275
|
+
if (code > 0x7F) break;
|
|
276
|
+
mem[ptr + offset] = code;
|
|
277
|
+
}
|
|
278
|
+
if (offset !== len) {
|
|
279
|
+
if (offset !== 0) {
|
|
280
|
+
arg = arg.slice(offset);
|
|
281
|
+
}
|
|
282
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
283
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
284
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
285
|
+
|
|
286
|
+
offset += ret.written;
|
|
287
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
WASM_VECTOR_LEN = offset;
|
|
291
|
+
return ptr;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function takeFromExternrefTable0(idx) {
|
|
295
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
296
|
+
wasm.__externref_table_dealloc(idx);
|
|
297
|
+
return value;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
301
|
+
cachedTextDecoder.decode();
|
|
302
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
303
|
+
let numBytesDecoded = 0;
|
|
304
|
+
function decodeText(ptr, len) {
|
|
305
|
+
numBytesDecoded += len;
|
|
306
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
307
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
308
|
+
cachedTextDecoder.decode();
|
|
309
|
+
numBytesDecoded = len;
|
|
310
|
+
}
|
|
311
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
const cachedTextEncoder = new TextEncoder();
|
|
315
|
+
|
|
316
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
317
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
318
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
319
|
+
view.set(buf);
|
|
320
|
+
return {
|
|
321
|
+
read: arg.length,
|
|
322
|
+
written: buf.length
|
|
323
|
+
};
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
let WASM_VECTOR_LEN = 0;
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
let wasm;
|
|
331
|
+
export function __wbg_set_wasm(val) {
|
|
332
|
+
wasm = val;
|
|
333
|
+
}
|
|
Binary file
|