diff options
Diffstat (limited to 'data/extensions/https-everywhere@eff.org/wasm')
-rw-r--r-- | data/extensions/https-everywhere@eff.org/wasm/https_everywhere_lib_wasm.js | 493 | ||||
-rw-r--r-- | data/extensions/https-everywhere@eff.org/wasm/https_everywhere_lib_wasm_bg.wasm | bin | 0 -> 66990 bytes |
2 files changed, 493 insertions, 0 deletions
diff --git a/data/extensions/https-everywhere@eff.org/wasm/https_everywhere_lib_wasm.js b/data/extensions/https-everywhere@eff.org/wasm/https_everywhere_lib_wasm.js new file mode 100644 index 0000000..cd72a81 --- /dev/null +++ b/data/extensions/https-everywhere@eff.org/wasm/https_everywhere_lib_wasm.js @@ -0,0 +1,493 @@ +(function() { + const __exports = {}; + let wasm; + + const heap = new Array(32); + + heap.fill(undefined); + + heap.push(undefined, null, true, false); + + let stack_pointer = 32; + + function addBorrowedObject(obj) { + if (stack_pointer == 1) throw new Error('out of js stack'); + heap[--stack_pointer] = obj; + return stack_pointer; + } + +function getObject(idx) { return heap[idx]; } + +let heap_next = heap.length; + +function dropObject(idx) { + if (idx < 36) return; + heap[idx] = heap_next; + heap_next = idx; +} + +function takeObject(idx) { + const ret = getObject(idx); + dropObject(idx); + return ret; +} + +let cachedTextDecoder = new TextDecoder('utf-8'); + +let cachegetUint8Memory = null; +function getUint8Memory() { + if (cachegetUint8Memory === null || cachegetUint8Memory.buffer !== wasm.memory.buffer) { + cachegetUint8Memory = new Uint8Array(wasm.memory.buffer); + } + return cachegetUint8Memory; +} + +function getStringFromWasm(ptr, len) { + return cachedTextDecoder.decode(getUint8Memory().subarray(ptr, ptr + len)); +} + +function addHeapObject(obj) { + if (heap_next === heap.length) heap.push(heap.length + 1); + const idx = heap_next; + heap_next = heap[idx]; + + heap[idx] = obj; + return idx; +} + +function handleError(e) { + wasm.__wbindgen_exn_store(addHeapObject(e)); +} + +let WASM_VECTOR_LEN = 0; + +let cachedTextEncoder = new TextEncoder('utf-8'); + +let passStringToWasm; +if (typeof cachedTextEncoder.encodeInto === 'function') { + passStringToWasm = function(arg) { + + + let size = arg.length; + let ptr = wasm.__wbindgen_malloc(size); + let offset = 0; + { + const mem = getUint8Memory(); + for (; offset < arg.length; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + } + + if (offset !== arg.length) { + arg = arg.slice(offset); + ptr = wasm.__wbindgen_realloc(ptr, size, size = offset + arg.length * 3); + const view = getUint8Memory().subarray(ptr + offset, ptr + size); + const ret = cachedTextEncoder.encodeInto(arg, view); + + offset += ret.written; + } + WASM_VECTOR_LEN = offset; + return ptr; + }; +} else { + passStringToWasm = function(arg) { + + + let size = arg.length; + let ptr = wasm.__wbindgen_malloc(size); + let offset = 0; + { + const mem = getUint8Memory(); + for (; offset < arg.length; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + } + + if (offset !== arg.length) { + const buf = cachedTextEncoder.encode(arg.slice(offset)); + ptr = wasm.__wbindgen_realloc(ptr, size, size = offset + buf.length); + getUint8Memory().set(buf, ptr + offset); + offset += buf.length; + } + WASM_VECTOR_LEN = offset; + return ptr; + }; +} + +let cachegetUint32Memory = null; +function getUint32Memory() { + if (cachegetUint32Memory === null || cachegetUint32Memory.buffer !== wasm.memory.buffer) { + cachegetUint32Memory = new Uint32Array(wasm.memory.buffer); + } + return cachegetUint32Memory; +} + +let cachegetInt32Memory = null; +function getInt32Memory() { + if (cachegetInt32Memory === null || cachegetInt32Memory.buffer !== wasm.memory.buffer) { + cachegetInt32Memory = new Int32Array(wasm.memory.buffer); + } + return cachegetInt32Memory; +} + +function debugString(val) { + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; + } + if (type == 'string') { + return `"${val}"`; + } + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } + } + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for(let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; +} +/** +* A newtype for rulesets, wrapping all the JS functionality +*/ +class RuleSets { + + static __wrap(ptr) { + const obj = Object.create(RuleSets.prototype); + obj.ptr = ptr; + + return obj; + } + + free() { + const ptr = this.ptr; + this.ptr = 0; + + wasm.__wbg_rulesets_free(ptr); + } + /** + * Returns a new JsRulesets struct + * @returns {RuleSets} + */ + static new() { + const ret = wasm.rulesets_new(); + return RuleSets.__wrap(ret); + } + /** + * Returns the number of targets in the current JsRuleSets struct as a `usize` + * @returns {number} + */ + count_targets() { + const ret = wasm.rulesets_count_targets(this.ptr); + return ret >>> 0; + } + /** + * Construct and add new rulesets given a JS array of values + * + * # Arguments + * + * * `array` - A JS Array object of rulesets + * * `enable_mixed_rulesets` - A JS Boolean indicating whether rulesets which trigger mixed + * content blocking should be enabled + * * `rule_active_states` - A JS object which lets us know whether rulesets have been disabled + * or enabled + * * `scope` - An optional JS string which indicates the scope of the current batch of + * rulesets being added (see the [ruleset update channels](https://github.com/EFForg/https-everywhere/blob/master/docs/en_US/ruleset-update-channels.md) documentation) + * @param {any} array + * @param {any} enable_mixed_rulesets + * @param {any} rule_active_states + * @param {any} scope + */ + add_all_from_js_array(array, enable_mixed_rulesets, rule_active_states, scope) { + try { + wasm.rulesets_add_all_from_js_array(this.ptr, addBorrowedObject(array), addBorrowedObject(enable_mixed_rulesets), addBorrowedObject(rule_active_states), addBorrowedObject(scope)); + } finally { + heap[stack_pointer++] = undefined; + heap[stack_pointer++] = undefined; + heap[stack_pointer++] = undefined; + heap[stack_pointer++] = undefined; + } + } + /** + * Remove a RuleSet from the RuleSets struct + * @param {any} ruleset_jsval + */ + remove_ruleset(ruleset_jsval) { + try { + wasm.rulesets_remove_ruleset(this.ptr, addBorrowedObject(ruleset_jsval)); + } finally { + heap[stack_pointer++] = undefined; + } + } + /** + * Return a JS array of rulesets which are active and have no exclusions, for all hosts that + * are in a single ruleset, and end in the given ending + * + * # Arguments + * + * * `ending` - A JS string which indicates the target ending to search for + * @param {any} ending + * @returns {any} + */ + get_simple_rules_ending_with(ending) { + try { + const ret = wasm.rulesets_get_simple_rules_ending_with(this.ptr, addBorrowedObject(ending)); + return takeObject(ret); + } finally { + heap[stack_pointer++] = undefined; + } + } + /** + * Return a JS set of rulesets that apply to the given host + * + * # Arguments + * + * * `host` - A JS string which indicates the host to search for potentially applicable rulesets + * @param {any} host + * @returns {any} + */ + potentially_applicable(host) { + try { + const ret = wasm.rulesets_potentially_applicable(this.ptr, addBorrowedObject(host)); + return takeObject(ret); + } finally { + heap[stack_pointer++] = undefined; + } + } +} +__exports.RuleSets = RuleSets; + +function init(module) { + + let result; + const imports = {}; + imports.wbg = {}; + imports.wbg.__wbindgen_object_drop_ref = function(arg0) { + takeObject(arg0); + }; + imports.wbg.__wbindgen_string_new = function(arg0, arg1) { + const ret = getStringFromWasm(arg0, arg1); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_is_object = function(arg0) { + const val = getObject(arg0); + const ret = typeof(val) === 'object' && val !== null; + return ret; + }; + imports.wbg.__wbindgen_jsval_eq = function(arg0, arg1) { + const ret = getObject(arg0) === getObject(arg1); + return ret; + }; + imports.wbg.__wbindgen_is_undefined = function(arg0) { + const ret = getObject(arg0) === undefined; + return ret; + }; + imports.wbg.__wbindgen_is_null = function(arg0) { + const ret = getObject(arg0) === null; + return ret; + }; + imports.wbg.__wbindgen_object_clone_ref = function(arg0) { + const ret = getObject(arg0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_valueOf_ba9b8eea6574e4cd = function(arg0) { + const ret = getObject(arg0).valueOf(); + return ret; + }; + imports.wbg.__wbg_done_d485bad1edfcebc6 = function(arg0) { + const ret = getObject(arg0).done; + return ret; + }; + imports.wbg.__wbg_value_ce1d7ad603d82534 = function(arg0) { + const ret = getObject(arg0).value; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_f1f0f3113e466334 = function() { + const ret = new Array(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_from_de9ef68c3ad78100 = function(arg0) { + const ret = Array.from(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_isArray_a354dddde485c5cb = function(arg0) { + const ret = Array.isArray(getObject(arg0)); + return ret; + }; + imports.wbg.__wbg_length_1fb83c219763252e = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_push_829cf1fbae322d44 = function(arg0, arg1) { + const ret = getObject(arg0).push(getObject(arg1)); + return ret; + }; + imports.wbg.__wbg_values_65bd19cf6fdcc3f3 = function(arg0) { + const ret = getObject(arg0).values(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_next_17e79f725ff5a87a = function(arg0) { + try { + const ret = getObject(arg0).next(); + return addHeapObject(ret); + } catch (e) { + handleError(e) + } + }; + imports.wbg.__wbg_new_abadb45e63451a4b = function() { + const ret = new Object(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_8b2f143a50ad38e8 = function(arg0, arg1, arg2, arg3) { + const ret = new RegExp(getStringFromWasm(arg0, arg1), getStringFromWasm(arg2, arg3)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_test_1c1b53250bceac51 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).test(getStringFromWasm(arg1, arg2)); + return ret; + }; + imports.wbg.__wbg_toString_bc87920f1a2b55ac = function(arg0) { + const ret = getObject(arg0).toString(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_add_5aa1e13fed2f3154 = function(arg0, arg1) { + const ret = getObject(arg0).add(getObject(arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_1f23e55940712795 = function(arg0) { + const ret = new Set(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_get_f54fa02552389dda = function(arg0, arg1) { + try { + const ret = Reflect.get(getObject(arg0), getObject(arg1)); + return addHeapObject(ret); + } catch (e) { + handleError(e) + } + }; + imports.wbg.__wbg_set_09ce0f7f67d68b09 = function(arg0, arg1, arg2) { + try { + const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2)); + return ret; + } catch (e) { + handleError(e) + } + }; + imports.wbg.__wbindgen_is_string = function(arg0) { + const ret = typeof(getObject(arg0)) === 'string'; + return ret; + }; + imports.wbg.__wbindgen_string_get = function(arg0, arg1) { + const obj = getObject(arg0); + if (typeof(obj) !== 'string') return 0; + const ptr = passStringToWasm(obj); + getUint32Memory()[arg1 / 4] = WASM_VECTOR_LEN; + const ret = ptr; + return ret; + }; + imports.wbg.__wbindgen_boolean_get = function(arg0) { + const v = getObject(arg0); + const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; + return ret; + }; + imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { + const ret = debugString(getObject(arg1)); + const ret0 = passStringToWasm(ret); + const ret1 = WASM_VECTOR_LEN; + getInt32Memory()[arg0 / 4 + 0] = ret0; + getInt32Memory()[arg0 / 4 + 1] = ret1; + }; + imports.wbg.__wbindgen_throw = function(arg0, arg1) { + throw new Error(getStringFromWasm(arg0, arg1)); + }; + + if (module instanceof URL || typeof module === 'string' || module instanceof Request) { + + const response = fetch(module); + if (typeof WebAssembly.instantiateStreaming === 'function') { + result = WebAssembly.instantiateStreaming(response, imports) + .catch(e => { + console.warn("`WebAssembly.instantiateStreaming` failed. Assuming this is because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); + return response + .then(r => r.arrayBuffer()) + .then(bytes => WebAssembly.instantiate(bytes, imports)); + }); + } else { + result = response + .then(r => r.arrayBuffer()) + .then(bytes => WebAssembly.instantiate(bytes, imports)); + } + } else { + + result = WebAssembly.instantiate(module, imports) + .then(result => { + if (result instanceof WebAssembly.Instance) { + return { instance: result, module }; + } else { + return result; + } + }); + } + return result.then(({instance, module}) => { + wasm = instance.exports; + init.__wbindgen_wasm_module = module; + + return wasm; + }); +} + +self.wasm_bindgen = Object.assign(init, __exports); + +})(); diff --git a/data/extensions/https-everywhere@eff.org/wasm/https_everywhere_lib_wasm_bg.wasm b/data/extensions/https-everywhere@eff.org/wasm/https_everywhere_lib_wasm_bg.wasm Binary files differnew file mode 100644 index 0000000..136048a --- /dev/null +++ b/data/extensions/https-everywhere@eff.org/wasm/https_everywhere_lib_wasm_bg.wasm |