wao 0.9.2 → 0.10.2
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/cjs/ao.js +31 -32
- package/cjs/aoconnect-base.js +197 -175
- package/cjs/armem-base.js +300 -116
- package/cjs/armem-web.js +11 -1
- package/cjs/armem.js +8 -1
- package/cjs/{ar-base.js → bar.js} +29 -30
- package/cjs/build.js +8 -0
- package/cjs/compress.js +165 -0
- package/cjs/server.js +66 -46
- package/cjs/tar.js +2 -2
- package/cjs/tgql.js +81 -78
- package/cjs/waosm/waosm.js +332 -0
- package/cjs/waosm-node/waosm.js +21 -0
- package/cjs/waosm-node/waosm_bg.js +193 -0
- package/cjs/waosm-node.js +28 -0
- package/cjs/war.js +2 -2
- package/esm/ao.js +7 -7
- package/esm/aoconnect-base.js +25 -24
- package/esm/armem-base.js +91 -11
- package/esm/armem-web.js +2 -1
- package/esm/armem.js +2 -1
- package/esm/{ar-base.js → bar.js} +9 -15
- package/esm/build.js +7 -0
- package/esm/compress.js +113 -0
- package/esm/lfdb.js +1 -3
- package/esm/server.js +5 -5
- package/esm/tar.js +1 -1
- package/esm/tgql.js +2 -2
- package/esm/waosm/README.md +79 -0
- package/esm/waosm/package.json +14 -0
- package/esm/waosm/waosm.d.ts +46 -0
- package/esm/waosm/waosm.js +264 -0
- package/esm/waosm/waosm_bg.wasm +0 -0
- package/esm/waosm/waosm_bg.wasm.d.ts +10 -0
- package/esm/waosm-node/README.md +79 -0
- package/esm/waosm-node/waosm.d.ts +12 -0
- package/esm/waosm-node/waosm.js +4 -0
- package/esm/waosm-node/waosm_bg.js +171 -0
- package/esm/waosm-node/waosm_bg.wasm +0 -0
- package/esm/waosm-node/waosm_bg.wasm.d.ts +10 -0
- package/esm/waosm-node.js +13 -0
- package/esm/war.js +1 -1
- package/package.json +4 -1
|
@@ -3,7 +3,7 @@ import { buildTags, tags as t } from "./utils.js"
|
|
|
3
3
|
import * as WarpArBundles from "warp-arbundles"
|
|
4
4
|
const pkg = WarpArBundles.default ?? WarpArBundles
|
|
5
5
|
const { DataItem } = pkg
|
|
6
|
-
import { bundleAndSignData, ArweaveSigner } from "arbundles"
|
|
6
|
+
import { Bundle, bundleAndSignData, ArweaveSigner } from "arbundles"
|
|
7
7
|
import base64url from "base64url"
|
|
8
8
|
import GQL from "./tgql.js"
|
|
9
9
|
import { last, is, includes, isNil } from "ramda"
|
|
@@ -18,21 +18,16 @@ class AR extends MAR {
|
|
|
18
18
|
this.arweave = this.mem.arweave
|
|
19
19
|
}
|
|
20
20
|
async owner(di) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
await crypto.subtle.digest("SHA-256", raw_owner),
|
|
21
|
+
return base64url.encode(
|
|
22
|
+
Buffer.from(await crypto.subtle.digest("SHA-256", di.rawOwner)),
|
|
24
23
|
)
|
|
25
|
-
return base64url.encode(hashBuffer)
|
|
26
24
|
}
|
|
27
25
|
async dataitem({ target = "", data = "1984", tags = {}, signer, item }) {
|
|
28
26
|
let di = item
|
|
29
27
|
if (!di) {
|
|
30
|
-
const
|
|
31
|
-
const _item = await signer({ data, tags: _tags, target })
|
|
28
|
+
const _item = await signer({ data, tags: buildTags(tags), target })
|
|
32
29
|
di = new DataItem(_item.raw)
|
|
33
|
-
} else
|
|
34
|
-
tags = t(di.tags)
|
|
35
|
-
}
|
|
30
|
+
} else tags = t(di.tags)
|
|
36
31
|
const owner = await this.owner(di)
|
|
37
32
|
return { id: await di.id, owner, item: di, tags }
|
|
38
33
|
}
|
|
@@ -42,8 +37,7 @@ class AR extends MAR {
|
|
|
42
37
|
;({ err, jwk } = await this.checkWallet({ jwk }))
|
|
43
38
|
if (err) return { err }
|
|
44
39
|
let tx = await this.arweave.createTransaction({ data: data })
|
|
45
|
-
|
|
46
|
-
for (const v of _tags) tx.addTag(v.name, v.value)
|
|
40
|
+
for (const v of buildTags(null, tags)) tx.addTag(v.name, v.value)
|
|
47
41
|
return await this.postTx(tx, jwk)
|
|
48
42
|
}
|
|
49
43
|
|
|
@@ -129,7 +123,7 @@ class AR extends MAR {
|
|
|
129
123
|
}
|
|
130
124
|
block.txs.push(item.id)
|
|
131
125
|
_txs.block = block.id
|
|
132
|
-
await this.mem.set(
|
|
126
|
+
await this.mem.set({ bundle: tx.id }, "txs", item.id)
|
|
133
127
|
}
|
|
134
128
|
}
|
|
135
129
|
let _tags = []
|
|
@@ -179,7 +173,7 @@ class AR extends MAR {
|
|
|
179
173
|
}
|
|
180
174
|
|
|
181
175
|
async tx(id) {
|
|
182
|
-
return await this.mem.
|
|
176
|
+
return await this.mem.getTx(id)
|
|
183
177
|
}
|
|
184
178
|
|
|
185
179
|
async data(id, _string, log) {
|
|
@@ -189,7 +183,7 @@ class AR extends MAR {
|
|
|
189
183
|
if (!isNil(_string.decode)) decode = _string.decode
|
|
190
184
|
if (!isNil(_string.string)) string = _string.string
|
|
191
185
|
}
|
|
192
|
-
let tx = await this.mem.
|
|
186
|
+
let tx = await this.mem.getTx(id)
|
|
193
187
|
let _data = tx?.data ?? null
|
|
194
188
|
if (tx?.format === 2 && _data) {
|
|
195
189
|
_data = Buffer.from(_data, "base64")
|
package/esm/build.js
ADDED
package/esm/compress.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
function toBase256(n) {
|
|
2
|
+
let result = []
|
|
3
|
+
while (n > 0) {
|
|
4
|
+
result.unshift(n % 256)
|
|
5
|
+
n = Math.floor(n / 256)
|
|
6
|
+
}
|
|
7
|
+
return [result.length, ...result]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const _comp = (arr, _arr, mode) => {
|
|
11
|
+
let _nums = null
|
|
12
|
+
let _elms = null
|
|
13
|
+
let len = _arr.length
|
|
14
|
+
let flag = 0
|
|
15
|
+
if (mode === 1 && _arr[0] !== 0) {
|
|
16
|
+
flag += 100
|
|
17
|
+
_elms = [_arr[0]]
|
|
18
|
+
} else if (mode === 2) {
|
|
19
|
+
flag += 200
|
|
20
|
+
_elms = _arr
|
|
21
|
+
}
|
|
22
|
+
if (len < 10) flag += len
|
|
23
|
+
else if (len !== 10) {
|
|
24
|
+
const [elm, ...nums] = toBase256(len)
|
|
25
|
+
_nums = nums
|
|
26
|
+
flag += elm * 10
|
|
27
|
+
if (_nums[0] < 10) flag += _nums.shift()
|
|
28
|
+
}
|
|
29
|
+
arr.push(flag)
|
|
30
|
+
if (_nums) for (const n of _nums) arr.push(n)
|
|
31
|
+
if (_elms) for (const n of _elms) arr.push(n)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const compress = d => {
|
|
35
|
+
let _arr = []
|
|
36
|
+
let mode = 1
|
|
37
|
+
let prev = null
|
|
38
|
+
let max = 0
|
|
39
|
+
let arr = []
|
|
40
|
+
for (const v of d) {
|
|
41
|
+
if (prev === null) _arr.push(v)
|
|
42
|
+
else if (_arr.length === 1) {
|
|
43
|
+
mode = prev !== v ? 2 : 1
|
|
44
|
+
_arr.push(v)
|
|
45
|
+
} else {
|
|
46
|
+
if (prev !== v && mode === 1) {
|
|
47
|
+
_comp(arr, _arr, mode)
|
|
48
|
+
_arr = [v]
|
|
49
|
+
mode = 2
|
|
50
|
+
} else if (prev === v && mode === 2) {
|
|
51
|
+
const last = _arr.pop()
|
|
52
|
+
_comp(arr, _arr, mode)
|
|
53
|
+
_arr = [last, v]
|
|
54
|
+
mode = 1
|
|
55
|
+
} else {
|
|
56
|
+
_arr.push(v)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
prev = v
|
|
60
|
+
}
|
|
61
|
+
if (_arr.length > 0) _comp(arr, _arr, mode)
|
|
62
|
+
return arr
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const decompress = d => {
|
|
66
|
+
let arr = []
|
|
67
|
+
let flag = null
|
|
68
|
+
let elm = 0
|
|
69
|
+
let sum = 0
|
|
70
|
+
let nums = []
|
|
71
|
+
let first = null
|
|
72
|
+
let second = null
|
|
73
|
+
let third = null
|
|
74
|
+
for (let v of d) {
|
|
75
|
+
if (flag === null) {
|
|
76
|
+
flag = v
|
|
77
|
+
first = Math.floor(flag / 100)
|
|
78
|
+
second = Math.floor((flag - first * 100) / 10)
|
|
79
|
+
third = flag - first * 100 - second * 10
|
|
80
|
+
nums = []
|
|
81
|
+
if (second === 0) {
|
|
82
|
+
nums.push(third === 0 ? 10 : third)
|
|
83
|
+
elm = 0
|
|
84
|
+
} else if (third !== 0) {
|
|
85
|
+
nums.push(third)
|
|
86
|
+
elm = second - 1
|
|
87
|
+
} else elm = second
|
|
88
|
+
console.log(flag, first, second, third, elm, nums)
|
|
89
|
+
} else if (sum === 0) {
|
|
90
|
+
elm -= 1
|
|
91
|
+
nums.push(v)
|
|
92
|
+
}
|
|
93
|
+
if (sum > 0) {
|
|
94
|
+
if (first === 2) arr.push(v)
|
|
95
|
+
else if (first === 1) for (let i = 0; i < to10(nums); i++) arr.push(v)
|
|
96
|
+
sum -= 1
|
|
97
|
+
if (sum === 0) flag = null
|
|
98
|
+
} else if (elm === 0) {
|
|
99
|
+
if (first === 0) {
|
|
100
|
+
for (let i = 0; i < to10(nums); i++) arr.push(0)
|
|
101
|
+
flag = null
|
|
102
|
+
} else if (first === 2) sum = to10(nums)
|
|
103
|
+
else sum = 1
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return new Uint8Array(arr)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function to10(arr) {
|
|
110
|
+
let num = 0
|
|
111
|
+
for (let i = 0; i < arr.length; i++) num = num * 256 + arr[i]
|
|
112
|
+
return num
|
|
113
|
+
}
|
package/esm/lfdb.js
CHANGED
|
@@ -48,9 +48,7 @@ export default _this => {
|
|
|
48
48
|
_this.keys[key] = true
|
|
49
49
|
await lf.setItem("keys", keys(_this.keys))
|
|
50
50
|
},
|
|
51
|
-
get: async key =>
|
|
52
|
-
return await lf.getItem(key)
|
|
53
|
-
},
|
|
51
|
+
get: async key => await lf.getItem(key),
|
|
54
52
|
getKeys: async ({ start, end }) => {
|
|
55
53
|
if (!_this.keyInit) {
|
|
56
54
|
const _keys = (await lf.getItem("keys")) ?? []
|
package/esm/server.js
CHANGED
|
@@ -216,13 +216,13 @@ class Server {
|
|
|
216
216
|
)
|
|
217
217
|
app.get("/:pid", (req, res) => {
|
|
218
218
|
const pid = req.params.pid
|
|
219
|
-
const edges = map(v => {
|
|
220
|
-
const tx = this.mem.
|
|
219
|
+
const edges = map(async v => {
|
|
220
|
+
const tx = await this.mem.getTx(v)
|
|
221
221
|
const _tags = tags(v.tags)
|
|
222
222
|
const mid = _tags.Message
|
|
223
|
-
const mtx = this.mem.
|
|
223
|
+
const mtx = await this.mem.getTx(mid)
|
|
224
224
|
return {
|
|
225
|
-
cursor: v
|
|
225
|
+
cursor: v,
|
|
226
226
|
node: {
|
|
227
227
|
message: {
|
|
228
228
|
id: mtx.id,
|
|
@@ -243,7 +243,7 @@ class Server {
|
|
|
243
243
|
},
|
|
244
244
|
},
|
|
245
245
|
}
|
|
246
|
-
})(reverse(this.mem.env[pid]?.
|
|
246
|
+
})(reverse(this.mem.env[pid]?.results ?? [])) // need mod
|
|
247
247
|
res.json({ page_info: { has_next_page: false }, edges })
|
|
248
248
|
})
|
|
249
249
|
const server = app.listen(this.ports.su, () =>
|
package/esm/tar.js
CHANGED
package/esm/tgql.js
CHANGED
|
@@ -10,6 +10,7 @@ const subs = {
|
|
|
10
10
|
parent: ["id"],
|
|
11
11
|
bundledIn: ["id"],
|
|
12
12
|
}
|
|
13
|
+
|
|
13
14
|
const field = (key, val = true) => {
|
|
14
15
|
if (includes(key, ["id", "anchor", "signature", "recipient"])) {
|
|
15
16
|
return { key }
|
|
@@ -101,8 +102,7 @@ export default class GQL {
|
|
|
101
102
|
break
|
|
102
103
|
}
|
|
103
104
|
if (!isNil(opt.after) && count === 0 && !after) continue
|
|
104
|
-
let tx = this.mem.
|
|
105
|
-
|
|
105
|
+
let tx = await this.mem.getTx(v2)
|
|
106
106
|
if (!isNil(ids) && ids.length > 0) {
|
|
107
107
|
if (!includes(tx.id, ids)) continue
|
|
108
108
|
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Waosm Compressor
|
|
2
|
+
|
|
3
|
+
Waosm is a lightweight new compression algorithm to efficiently compress Wasm memory.
|
|
4
|
+
|
|
5
|
+
It is implemented in Rust and compiled to Wasm for better performance in browsers.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
yarn build
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Using Waosm in nodejs.
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import init, { Compressor, Decompressor } from "../src/waosm-node.js"
|
|
15
|
+
|
|
16
|
+
const main = async ()=>{
|
|
17
|
+
await init()
|
|
18
|
+
const compressor = new Compressor()
|
|
19
|
+
const decompressor = new Decompressor()
|
|
20
|
+
const memory = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 0])
|
|
21
|
+
console.log(memory)
|
|
22
|
+
const compressed = compressor.compress(memory)
|
|
23
|
+
console.log(compressed)
|
|
24
|
+
const decompressed = decompressor.decompress(compressed)
|
|
25
|
+
console.log(decompressed)
|
|
26
|
+
}
|
|
27
|
+
main()
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## How Compression Works
|
|
31
|
+
|
|
32
|
+
Waosm Compression is a simple LRF variant that sequentially processes 8-bit integers. It is specifically optimized for zero-padded Wasm memory, achieving a 99% compression rate for largely idle WebAssembly memory. This enables efficient handling of large WebAssembly modules in browser environments.
|
|
33
|
+
|
|
34
|
+
The algorithm packs integers into chunks with 3 parts.
|
|
35
|
+
|
|
36
|
+
- flag
|
|
37
|
+
- 256-base number to tell the number of element in the current chunk
|
|
38
|
+
- actuall 8-bit intergers
|
|
39
|
+
|
|
40
|
+
### Flag
|
|
41
|
+
|
|
42
|
+
A flag is a 1 byte (8 bits) integer, which ranges from 0 to 255. So there are 3 digits.
|
|
43
|
+
|
|
44
|
+
- 1st digit: `mode`
|
|
45
|
+
- `0`: a sequence of 0s
|
|
46
|
+
- `1`: a sequence of a single repeating 8 bit integer
|
|
47
|
+
- `2`: a sequence of multiple unique 8 bit integer
|
|
48
|
+
- 2nd digit:
|
|
49
|
+
- `0`: the 3rd digit is the number of elements, no 256-base number required in this case
|
|
50
|
+
- `1-9`: the number of integers to represent the 256-base number
|
|
51
|
+
- 3rd digit:
|
|
52
|
+
- if the 2nd digit is `0`, the 3rd digit represents the number of the elements, `0` represents `10`
|
|
53
|
+
- otherwise, the 3rd digit represents the first integer in the 256-base number representation
|
|
54
|
+
|
|
55
|
+
### 256-Base Number
|
|
56
|
+
|
|
57
|
+
This part tells how many 8-bit integers are in the current chunk. For instance,
|
|
58
|
+
- `2, 200` = (256 ** 1 * 2) + 200 = 712
|
|
59
|
+
- `5, 50, 200` = (256 ** 2 * 5) + (256 ** 1 * 50) + 200 = 340680
|
|
60
|
+
|
|
61
|
+
Note that for space efficiency, the first integer is in the flag in some cases.
|
|
62
|
+
|
|
63
|
+
### 8 Bit Elements
|
|
64
|
+
|
|
65
|
+
- `Mode 0`: no need for this part since we know it's a sequence of 0
|
|
66
|
+
- `Mode 1`: 1 integer to tell which integer of a sequence this chunk is
|
|
67
|
+
- `Mode 2`: the entire integers are required
|
|
68
|
+
|
|
69
|
+
## Examples
|
|
70
|
+
|
|
71
|
+
`[ 1, 2, 3, 4, 5, 5, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]` (28 bytes)
|
|
72
|
+
|
|
73
|
+
- `204` | `-` | `1, 2, 3, 4`
|
|
74
|
+
- `103` | `-` | `5`
|
|
75
|
+
- `204` | `-` | `6, 7, 8, 9`
|
|
76
|
+
- `010` | `17` | `-`
|
|
77
|
+
|
|
78
|
+
It becomes `[204, 1, 2, 3, 4, 103, 5, 204, 6, 7, 8, 9, 10, 17]` (14 bytes - 50% compression rate).
|
|
79
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export class Compressor {
|
|
4
|
+
free(): void;
|
|
5
|
+
constructor();
|
|
6
|
+
compress(data: Uint8Array): Uint8Array;
|
|
7
|
+
}
|
|
8
|
+
export class Decompressor {
|
|
9
|
+
free(): void;
|
|
10
|
+
constructor();
|
|
11
|
+
decompress(data: Uint8Array): Uint8Array;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
15
|
+
|
|
16
|
+
export interface InitOutput {
|
|
17
|
+
readonly memory: WebAssembly.Memory;
|
|
18
|
+
readonly __wbg_compressor_free: (a: number, b: number) => void;
|
|
19
|
+
readonly compressor_new: () => number;
|
|
20
|
+
readonly compressor_compress: (a: number, b: number, c: number) => number;
|
|
21
|
+
readonly decompressor_decompress: (a: number, b: number, c: number) => number;
|
|
22
|
+
readonly __wbg_decompressor_free: (a: number, b: number) => void;
|
|
23
|
+
readonly decompressor_new: () => number;
|
|
24
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
28
|
+
/**
|
|
29
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
30
|
+
* a precompiled `WebAssembly.Module`.
|
|
31
|
+
*
|
|
32
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
33
|
+
*
|
|
34
|
+
* @returns {InitOutput}
|
|
35
|
+
*/
|
|
36
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
40
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
41
|
+
*
|
|
42
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
43
|
+
*
|
|
44
|
+
* @returns {Promise<InitOutput>}
|
|
45
|
+
*/
|
|
46
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
|
|
3
|
+
const heap = new Array(128).fill(undefined);
|
|
4
|
+
|
|
5
|
+
heap.push(undefined, null, true, false);
|
|
6
|
+
|
|
7
|
+
function getObject(idx) { return heap[idx]; }
|
|
8
|
+
|
|
9
|
+
let heap_next = heap.length;
|
|
10
|
+
|
|
11
|
+
function addHeapObject(obj) {
|
|
12
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
13
|
+
const idx = heap_next;
|
|
14
|
+
heap_next = heap[idx];
|
|
15
|
+
|
|
16
|
+
heap[idx] = obj;
|
|
17
|
+
return idx;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function dropObject(idx) {
|
|
21
|
+
if (idx < 132) return;
|
|
22
|
+
heap[idx] = heap_next;
|
|
23
|
+
heap_next = idx;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function takeObject(idx) {
|
|
27
|
+
const ret = getObject(idx);
|
|
28
|
+
dropObject(idx);
|
|
29
|
+
return ret;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
33
|
+
|
|
34
|
+
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
35
|
+
|
|
36
|
+
let cachedUint8ArrayMemory0 = null;
|
|
37
|
+
|
|
38
|
+
function getUint8ArrayMemory0() {
|
|
39
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
40
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
41
|
+
}
|
|
42
|
+
return cachedUint8ArrayMemory0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function getStringFromWasm0(ptr, len) {
|
|
46
|
+
ptr = ptr >>> 0;
|
|
47
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let WASM_VECTOR_LEN = 0;
|
|
51
|
+
|
|
52
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
53
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
54
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
55
|
+
WASM_VECTOR_LEN = arg.length;
|
|
56
|
+
return ptr;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const CompressorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
60
|
+
? { register: () => {}, unregister: () => {} }
|
|
61
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_compressor_free(ptr >>> 0, 1));
|
|
62
|
+
|
|
63
|
+
export class Compressor {
|
|
64
|
+
|
|
65
|
+
__destroy_into_raw() {
|
|
66
|
+
const ptr = this.__wbg_ptr;
|
|
67
|
+
this.__wbg_ptr = 0;
|
|
68
|
+
CompressorFinalization.unregister(this);
|
|
69
|
+
return ptr;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
free() {
|
|
73
|
+
const ptr = this.__destroy_into_raw();
|
|
74
|
+
wasm.__wbg_compressor_free(ptr, 0);
|
|
75
|
+
}
|
|
76
|
+
constructor() {
|
|
77
|
+
const ret = wasm.compressor_new();
|
|
78
|
+
this.__wbg_ptr = ret >>> 0;
|
|
79
|
+
CompressorFinalization.register(this, this.__wbg_ptr, this);
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* @param {Uint8Array} data
|
|
84
|
+
* @returns {Uint8Array}
|
|
85
|
+
*/
|
|
86
|
+
compress(data) {
|
|
87
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
88
|
+
const len0 = WASM_VECTOR_LEN;
|
|
89
|
+
const ret = wasm.compressor_compress(this.__wbg_ptr, ptr0, len0);
|
|
90
|
+
return takeObject(ret);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const DecompressorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
95
|
+
? { register: () => {}, unregister: () => {} }
|
|
96
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_decompressor_free(ptr >>> 0, 1));
|
|
97
|
+
|
|
98
|
+
export class Decompressor {
|
|
99
|
+
|
|
100
|
+
__destroy_into_raw() {
|
|
101
|
+
const ptr = this.__wbg_ptr;
|
|
102
|
+
this.__wbg_ptr = 0;
|
|
103
|
+
DecompressorFinalization.unregister(this);
|
|
104
|
+
return ptr;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
free() {
|
|
108
|
+
const ptr = this.__destroy_into_raw();
|
|
109
|
+
wasm.__wbg_decompressor_free(ptr, 0);
|
|
110
|
+
}
|
|
111
|
+
constructor() {
|
|
112
|
+
const ret = wasm.compressor_new();
|
|
113
|
+
this.__wbg_ptr = ret >>> 0;
|
|
114
|
+
DecompressorFinalization.register(this, this.__wbg_ptr, this);
|
|
115
|
+
return this;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* @param {Uint8Array} data
|
|
119
|
+
* @returns {Uint8Array}
|
|
120
|
+
*/
|
|
121
|
+
decompress(data) {
|
|
122
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
123
|
+
const len0 = WASM_VECTOR_LEN;
|
|
124
|
+
const ret = wasm.decompressor_decompress(this.__wbg_ptr, ptr0, len0);
|
|
125
|
+
return takeObject(ret);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async function __wbg_load(module, imports) {
|
|
130
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
131
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
132
|
+
try {
|
|
133
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
134
|
+
|
|
135
|
+
} catch (e) {
|
|
136
|
+
if (module.headers.get('Content-Type') != 'application/wasm') {
|
|
137
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
138
|
+
|
|
139
|
+
} else {
|
|
140
|
+
throw e;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const bytes = await module.arrayBuffer();
|
|
146
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
147
|
+
|
|
148
|
+
} else {
|
|
149
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
150
|
+
|
|
151
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
152
|
+
return { instance, module };
|
|
153
|
+
|
|
154
|
+
} else {
|
|
155
|
+
return instance;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function __wbg_get_imports() {
|
|
161
|
+
const imports = {};
|
|
162
|
+
imports.wbg = {};
|
|
163
|
+
imports.wbg.__wbg_buffer_609cc3eee51ed158 = function(arg0) {
|
|
164
|
+
const ret = getObject(arg0).buffer;
|
|
165
|
+
return addHeapObject(ret);
|
|
166
|
+
};
|
|
167
|
+
imports.wbg.__wbg_length_a446193dc22c12f8 = function(arg0) {
|
|
168
|
+
const ret = getObject(arg0).length;
|
|
169
|
+
return ret;
|
|
170
|
+
};
|
|
171
|
+
imports.wbg.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a = function(arg0, arg1, arg2) {
|
|
172
|
+
const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
|
|
173
|
+
return addHeapObject(ret);
|
|
174
|
+
};
|
|
175
|
+
imports.wbg.__wbg_newwithlength_a381634e90c276d4 = function(arg0) {
|
|
176
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
177
|
+
return addHeapObject(ret);
|
|
178
|
+
};
|
|
179
|
+
imports.wbg.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
|
|
180
|
+
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
|
|
181
|
+
};
|
|
182
|
+
imports.wbg.__wbindgen_memory = function() {
|
|
183
|
+
const ret = wasm.memory;
|
|
184
|
+
return addHeapObject(ret);
|
|
185
|
+
};
|
|
186
|
+
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
187
|
+
takeObject(arg0);
|
|
188
|
+
};
|
|
189
|
+
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
190
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
return imports;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function __wbg_init_memory(imports, memory) {
|
|
197
|
+
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function __wbg_finalize_init(instance, module) {
|
|
201
|
+
wasm = instance.exports;
|
|
202
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
203
|
+
cachedUint8ArrayMemory0 = null;
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
return wasm;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function initSync(module) {
|
|
211
|
+
if (wasm !== undefined) return wasm;
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
if (typeof module !== 'undefined') {
|
|
215
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
216
|
+
({module} = module)
|
|
217
|
+
} else {
|
|
218
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const imports = __wbg_get_imports();
|
|
223
|
+
|
|
224
|
+
__wbg_init_memory(imports);
|
|
225
|
+
|
|
226
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
227
|
+
module = new WebAssembly.Module(module);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
231
|
+
|
|
232
|
+
return __wbg_finalize_init(instance, module);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
async function __wbg_init(module_or_path) {
|
|
236
|
+
if (wasm !== undefined) return wasm;
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
if (typeof module_or_path !== 'undefined') {
|
|
240
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
241
|
+
({module_or_path} = module_or_path)
|
|
242
|
+
} else {
|
|
243
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (typeof module_or_path === 'undefined') {
|
|
248
|
+
module_or_path = new URL('waosm_bg.wasm', import.meta.url);
|
|
249
|
+
}
|
|
250
|
+
const imports = __wbg_get_imports();
|
|
251
|
+
|
|
252
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
253
|
+
module_or_path = fetch(module_or_path);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
__wbg_init_memory(imports);
|
|
257
|
+
|
|
258
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
259
|
+
|
|
260
|
+
return __wbg_finalize_init(instance, module);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export { initSync };
|
|
264
|
+
export default __wbg_init;
|
|
Binary file
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_compressor_free: (a: number, b: number) => void;
|
|
5
|
+
export const compressor_new: () => number;
|
|
6
|
+
export const compressor_compress: (a: number, b: number, c: number) => number;
|
|
7
|
+
export const decompressor_decompress: (a: number, b: number, c: number) => number;
|
|
8
|
+
export const __wbg_decompressor_free: (a: number, b: number) => void;
|
|
9
|
+
export const decompressor_new: () => number;
|
|
10
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|