Skip to content

Commit b2f364f

Browse files
committed
fix weavedrive extension
1 parent 351fffa commit b2f364f

File tree

5 files changed

+400
-276
lines changed

5 files changed

+400
-276
lines changed

src/bar.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class AR extends MAR {
1919
}
2020
async owner(di) {
2121
return base64url.encode(
22-
Buffer.from(await crypto.subtle.digest("SHA-256", di.rawOwner)),
22+
Buffer.from(await crypto.subtle.digest("SHA-256", di.rawOwner))
2323
)
2424
}
2525
async dataitem({ target = "", data = "1984", tags = {}, signer, item }) {
@@ -72,7 +72,7 @@ class AR extends MAR {
7272
const bundle = await bundleAndSignData(items, new ArweaveSigner(jwk))
7373
const tx = await this.mem.arweave.createTransaction(
7474
{ data: bundle.binary },
75-
jwk,
75+
jwk
7676
)
7777
tx.addTag("Bundle-Format", "binary")
7878
tx.addTag("Bundle-Version", "2.0.0")
@@ -140,7 +140,7 @@ class AR extends MAR {
140140
format: __tags["Module-Format"],
141141
},
142142
"wasms",
143-
tx.id,
143+
tx.id
144144
)
145145
}
146146
tx.tags = _tags
@@ -162,7 +162,7 @@ class AR extends MAR {
162162
if (this.log) {
163163
if (msg) {
164164
console.log(
165-
`New ${msg.type}:\t${msg.id}${msg.pid ? ` > ${msg.pid}` : ""}`,
165+
`New ${msg.type}:\t${msg.id}${msg.pid ? ` > ${msg.pid}` : ""}`
166166
)
167167
} else {
168168
console.log(`New Post:\t${tx.id}`)
@@ -213,7 +213,7 @@ function tobuff(base64url) {
213213
const base64 = base64url.replace(/-/g, "+").replace(/_/g, "/")
214214
const paddedBase64 = base64.padEnd(
215215
base64.length + ((4 - (base64.length % 4)) % 4),
216-
"=",
216+
"="
217217
)
218218
return Buffer.from(paddedBase64, "base64")
219219
}

src/waosm-node/waosm_bg.js

Lines changed: 117 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,147 +1,167 @@
1-
let wasm;
1+
let wasm
22
export function __wbg_set_wasm(val) {
3-
wasm = val;
3+
wasm = val
44
}
55

6+
const heap = new Array(128).fill(undefined)
67

7-
const heap = new Array(128).fill(undefined);
8+
heap.push(undefined, null, true, false)
89

9-
heap.push(undefined, null, true, false);
10-
11-
function getObject(idx) { return heap[idx]; }
10+
function getObject(idx) {
11+
return heap[idx]
12+
}
1213

13-
let heap_next = heap.length;
14+
let heap_next = heap.length
1415

1516
function addHeapObject(obj) {
16-
if (heap_next === heap.length) heap.push(heap.length + 1);
17-
const idx = heap_next;
18-
heap_next = heap[idx];
17+
if (heap_next === heap.length) heap.push(heap.length + 1)
18+
const idx = heap_next
19+
heap_next = heap[idx]
1920

20-
heap[idx] = obj;
21-
return idx;
21+
heap[idx] = obj
22+
return idx
2223
}
2324

2425
function dropObject(idx) {
25-
if (idx < 132) return;
26-
heap[idx] = heap_next;
27-
heap_next = idx;
26+
if (idx < 132) return
27+
heap[idx] = heap_next
28+
heap_next = idx
2829
}
2930

3031
function takeObject(idx) {
31-
const ret = getObject(idx);
32-
dropObject(idx);
33-
return ret;
32+
const ret = getObject(idx)
33+
dropObject(idx)
34+
return ret
3435
}
3536

36-
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
37+
const lTextDecoder =
38+
typeof TextDecoder === "undefined"
39+
? (0, module.require)("util").TextDecoder
40+
: TextDecoder
3741

38-
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
42+
let cachedTextDecoder = new lTextDecoder("utf-8", {
43+
ignoreBOM: true,
44+
fatal: true,
45+
})
3946

40-
cachedTextDecoder.decode();
47+
cachedTextDecoder.decode()
4148

42-
let cachedUint8ArrayMemory0 = null;
49+
let cachedUint8ArrayMemory0 = null
4350

4451
function getUint8ArrayMemory0() {
45-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
46-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
47-
}
48-
return cachedUint8ArrayMemory0;
52+
if (
53+
cachedUint8ArrayMemory0 === null ||
54+
cachedUint8ArrayMemory0.byteLength === 0
55+
) {
56+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer)
57+
}
58+
return cachedUint8ArrayMemory0
4959
}
5060

5161
function getStringFromWasm0(ptr, len) {
52-
ptr = ptr >>> 0;
53-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
62+
ptr = ptr >>> 0
63+
return cachedTextDecoder.decode(
64+
getUint8ArrayMemory0().subarray(ptr, ptr + len)
65+
)
5466
}
5567

56-
let WASM_VECTOR_LEN = 0;
68+
let WASM_VECTOR_LEN = 0
5769

5870
function passArray8ToWasm0(arg, malloc) {
59-
const ptr = malloc(arg.length * 1, 1) >>> 0;
60-
getUint8ArrayMemory0().set(arg, ptr / 1);
61-
WASM_VECTOR_LEN = arg.length;
62-
return ptr;
71+
const ptr = malloc(arg.length * 1, 1) >>> 0
72+
getUint8ArrayMemory0().set(arg, ptr / 1)
73+
WASM_VECTOR_LEN = arg.length
74+
return ptr
6375
}
6476

65-
const WaosmFinalization = (typeof FinalizationRegistry === 'undefined')
77+
const WaosmFinalization =
78+
typeof FinalizationRegistry === "undefined"
6679
? { register: () => {}, unregister: () => {} }
67-
: new FinalizationRegistry(ptr => wasm.__wbg_waosm_free(ptr >>> 0, 1));
80+
: new FinalizationRegistry(ptr => wasm.__wbg_waosm_free(ptr >>> 0, 1))
6881

6982
export class Waosm {
70-
71-
__destroy_into_raw() {
72-
const ptr = this.__wbg_ptr;
73-
this.__wbg_ptr = 0;
74-
WaosmFinalization.unregister(this);
75-
return ptr;
76-
}
77-
78-
free() {
79-
const ptr = this.__destroy_into_raw();
80-
wasm.__wbg_waosm_free(ptr, 0);
81-
}
82-
constructor() {
83-
const ret = wasm.waosm_new();
84-
this.__wbg_ptr = ret >>> 0;
85-
WaosmFinalization.register(this, this.__wbg_ptr, this);
86-
return this;
87-
}
88-
/**
89-
* @param {Uint8Array} data
90-
* @returns {Uint8Array}
91-
*/
92-
compress(data) {
93-
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
94-
const len0 = WASM_VECTOR_LEN;
95-
const ret = wasm.waosm_compress(this.__wbg_ptr, ptr0, len0);
96-
return takeObject(ret);
97-
}
98-
/**
99-
* @param {Uint8Array} data
100-
* @param {number} decompressed_size
101-
* @returns {Uint8Array}
102-
*/
103-
decompress(data, decompressed_size) {
104-
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
105-
const len0 = WASM_VECTOR_LEN;
106-
const ret = wasm.waosm_decompress(this.__wbg_ptr, ptr0, len0, decompressed_size);
107-
return takeObject(ret);
108-
}
83+
__destroy_into_raw() {
84+
const ptr = this.__wbg_ptr
85+
this.__wbg_ptr = 0
86+
WaosmFinalization.unregister(this)
87+
return ptr
88+
}
89+
90+
free() {
91+
const ptr = this.__destroy_into_raw()
92+
wasm.__wbg_waosm_free(ptr, 0)
93+
}
94+
constructor() {
95+
const ret = wasm.waosm_new()
96+
this.__wbg_ptr = ret >>> 0
97+
WaosmFinalization.register(this, this.__wbg_ptr, this)
98+
return this
99+
}
100+
/**
101+
* @param {Uint8Array} data
102+
* @returns {Uint8Array}
103+
*/
104+
compress(data) {
105+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc)
106+
const len0 = WASM_VECTOR_LEN
107+
const ret = wasm.waosm_compress(this.__wbg_ptr, ptr0, len0)
108+
return takeObject(ret)
109+
}
110+
/**
111+
* @param {Uint8Array} data
112+
* @param {number} decompressed_size
113+
* @returns {Uint8Array}
114+
*/
115+
decompress(data, decompressed_size) {
116+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc)
117+
const len0 = WASM_VECTOR_LEN
118+
const ret = wasm.waosm_decompress(
119+
this.__wbg_ptr,
120+
ptr0,
121+
len0,
122+
decompressed_size
123+
)
124+
return takeObject(ret)
125+
}
109126
}
110127

111128
export function __wbg_buffer_609cc3eee51ed158(arg0) {
112-
const ret = getObject(arg0).buffer;
113-
return addHeapObject(ret);
114-
};
129+
const ret = getObject(arg0).buffer
130+
return addHeapObject(ret)
131+
}
115132

116133
export function __wbg_length_a446193dc22c12f8(arg0) {
117-
const ret = getObject(arg0).length;
118-
return ret;
119-
};
134+
const ret = getObject(arg0).length
135+
return ret
136+
}
120137

121-
export function __wbg_newwithbyteoffsetandlength_d97e637ebe145a9a(arg0, arg1, arg2) {
122-
const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
123-
return addHeapObject(ret);
124-
};
138+
export function __wbg_newwithbyteoffsetandlength_d97e637ebe145a9a(
139+
arg0,
140+
arg1,
141+
arg2
142+
) {
143+
const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0)
144+
return addHeapObject(ret)
145+
}
125146

126147
export function __wbg_newwithlength_a381634e90c276d4(arg0) {
127-
const ret = new Uint8Array(arg0 >>> 0);
128-
return addHeapObject(ret);
129-
};
148+
const ret = new Uint8Array(arg0 >>> 0)
149+
return addHeapObject(ret)
150+
}
130151

131152
export function __wbg_set_65595bdd868b3009(arg0, arg1, arg2) {
132-
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
133-
};
153+
getObject(arg0).set(getObject(arg1), arg2 >>> 0)
154+
}
134155

135156
export function __wbindgen_memory() {
136-
const ret = wasm.memory;
137-
return addHeapObject(ret);
138-
};
157+
const ret = wasm.memory
158+
return addHeapObject(ret)
159+
}
139160

140161
export function __wbindgen_object_drop_ref(arg0) {
141-
takeObject(arg0);
142-
};
162+
takeObject(arg0)
163+
}
143164

144165
export function __wbindgen_throw(arg0, arg1) {
145-
throw new Error(getStringFromWasm0(arg0, arg1));
146-
};
147-
166+
throw new Error(getStringFromWasm0(arg0, arg1))
167+
}

0 commit comments

Comments
 (0)