@monaco-neovim-wasm/lib 0.1.6 → 0.1.8
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/dist/monaco-neovim-wasm.es.js +6 -6
- package/dist/nvimWorker.js +1548 -229
- package/dist/nvimWorkerAsyncify.js +1608 -289
- package/package.json +2 -3
- package/dist/msgpack-BSNDwQ9a.js +0 -1351
|
@@ -1,134 +1,1453 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
class fe {
|
|
2
|
+
static read_bytes(e, t) {
|
|
3
|
+
const i = new fe();
|
|
4
|
+
return i.buf = e.getUint32(t, !0), i.buf_len = e.getUint32(t + 4, !0), i;
|
|
5
|
+
}
|
|
6
|
+
static read_bytes_array(e, t, i) {
|
|
7
|
+
const a = [];
|
|
8
|
+
for (let r = 0; r < i; r++)
|
|
9
|
+
a.push(fe.read_bytes(e, t + 8 * r));
|
|
10
|
+
return a;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
class le {
|
|
14
|
+
static read_bytes(e, t) {
|
|
15
|
+
const i = new le();
|
|
16
|
+
return i.buf = e.getUint32(t, !0), i.buf_len = e.getUint32(t + 4, !0), i;
|
|
17
|
+
}
|
|
18
|
+
static read_bytes_array(e, t, i) {
|
|
19
|
+
const a = [];
|
|
20
|
+
for (let r = 0; r < i; r++)
|
|
21
|
+
a.push(le.read_bytes(e, t + 8 * r));
|
|
22
|
+
return a;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const bt = 0, Ut = 1, at = 2, I = 3, $ = 4;
|
|
26
|
+
class ve {
|
|
27
|
+
head_length() {
|
|
28
|
+
return 24;
|
|
29
|
+
}
|
|
30
|
+
name_length() {
|
|
31
|
+
return this.dir_name.byteLength;
|
|
32
|
+
}
|
|
33
|
+
write_head_bytes(e, t) {
|
|
34
|
+
e.setBigUint64(t, this.d_next, !0), e.setBigUint64(t + 8, this.d_ino, !0), e.setUint32(t + 16, this.dir_name.length, !0), e.setUint8(t + 20, this.d_type);
|
|
35
|
+
}
|
|
36
|
+
write_name_bytes(e, t, i) {
|
|
37
|
+
e.set(this.dir_name.slice(0, Math.min(this.dir_name.byteLength, i)), t);
|
|
38
|
+
}
|
|
39
|
+
constructor(e, t, i, a) {
|
|
40
|
+
const r = new TextEncoder().encode(i);
|
|
41
|
+
this.d_next = e, this.d_ino = t, this.d_namlen = r.byteLength, this.d_type = a, this.dir_name = r;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const At = 1;
|
|
45
|
+
class Oe {
|
|
46
|
+
write_bytes(e, t) {
|
|
47
|
+
e.setUint8(t, this.fs_filetype), e.setUint16(t + 2, this.fs_flags, !0), e.setBigUint64(t + 8, this.fs_rights_base, !0), e.setBigUint64(t + 16, this.fs_rights_inherited, !0);
|
|
48
|
+
}
|
|
49
|
+
constructor(e, t) {
|
|
50
|
+
this.fs_rights_base = 0n, this.fs_rights_inherited = 0n, this.fs_filetype = e, this.fs_flags = t;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const De = 1, J = 2, Je = 4, Qe = 8;
|
|
54
|
+
class ot {
|
|
55
|
+
write_bytes(e, t) {
|
|
56
|
+
e.setBigUint64(t, this.dev, !0), e.setBigUint64(t + 8, this.ino, !0), e.setUint8(t + 16, this.filetype), e.setBigUint64(t + 24, this.nlink, !0), e.setBigUint64(t + 32, this.size, !0), e.setBigUint64(t + 38, this.atim, !0), e.setBigUint64(t + 46, this.mtim, !0), e.setBigUint64(t + 52, this.ctim, !0);
|
|
57
|
+
}
|
|
58
|
+
constructor(e, t, i) {
|
|
59
|
+
this.dev = 0n, this.nlink = 0n, this.atim = 0n, this.mtim = 0n, this.ctim = 0n, this.ino = e, this.filetype = t, this.size = i;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const ft = 0, vt = 1, Ze = 2, lt = 1;
|
|
63
|
+
class Ve {
|
|
64
|
+
static read_bytes(e, t) {
|
|
65
|
+
return new Ve(e.getBigUint64(t, !0), e.getUint8(t + 8), e.getUint32(t + 16, !0), e.getBigUint64(t + 24, !0), e.getUint16(t + 36, !0));
|
|
66
|
+
}
|
|
67
|
+
constructor(e, t, i, a, r) {
|
|
68
|
+
this.userdata = e, this.eventtype = t, this.clockid = i, this.timeout = a, this.flags = r;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
class ct {
|
|
72
|
+
write_bytes(e, t) {
|
|
73
|
+
e.setBigUint64(t, this.userdata, !0), e.setUint16(t + 8, this.error, !0), e.setUint8(t + 10, this.eventtype);
|
|
74
|
+
}
|
|
75
|
+
constructor(e, t, i) {
|
|
76
|
+
this.userdata = e, this.error = t, this.eventtype = i;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const Dt = 0;
|
|
80
|
+
class Tt {
|
|
81
|
+
write_bytes(e, t) {
|
|
82
|
+
e.setUint32(t, this.pr_name.byteLength, !0);
|
|
83
|
+
}
|
|
84
|
+
constructor(e) {
|
|
85
|
+
this.pr_name = new TextEncoder().encode(e);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
class ze {
|
|
89
|
+
static dir(e) {
|
|
90
|
+
const t = new ze();
|
|
91
|
+
return t.tag = Dt, t.inner = new Tt(e), t;
|
|
92
|
+
}
|
|
93
|
+
write_bytes(e, t) {
|
|
94
|
+
e.setUint32(t, this.tag, !0), this.inner.write_bytes(e, t + 4);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
let Ct = class {
|
|
98
|
+
enable(e) {
|
|
99
|
+
this.log = xt(e === void 0 ? !0 : e, this.prefix);
|
|
100
|
+
}
|
|
101
|
+
get enabled() {
|
|
102
|
+
return this.isEnabled;
|
|
103
|
+
}
|
|
104
|
+
constructor(e) {
|
|
105
|
+
this.isEnabled = e, this.prefix = "wasi:", this.enable(e);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
function xt(n, e) {
|
|
109
|
+
return n ? console.log.bind(console, "%c%s", "color: #265BA0", e) : () => {
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
const b = new Ct(!1);
|
|
113
|
+
class ge extends Error {
|
|
114
|
+
constructor(e) {
|
|
115
|
+
super("exit with exit code " + e), this.code = e;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
let It = class {
|
|
119
|
+
start(e) {
|
|
120
|
+
this.inst = e;
|
|
121
|
+
try {
|
|
122
|
+
return e.exports._start(), 0;
|
|
123
|
+
} catch (t) {
|
|
124
|
+
if (t instanceof ge)
|
|
125
|
+
return t.code;
|
|
126
|
+
throw t;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
initialize(e) {
|
|
130
|
+
this.inst = e, e.exports._initialize && e.exports._initialize();
|
|
131
|
+
}
|
|
132
|
+
constructor(e, t, i, a = {}) {
|
|
133
|
+
this.args = [], this.env = [], this.fds = [], b.enable(a.debug), this.args = e, this.env = t, this.fds = i;
|
|
134
|
+
const r = this;
|
|
135
|
+
this.wasiImport = { args_sizes_get(s, o) {
|
|
136
|
+
const f = new DataView(r.inst.exports.memory.buffer);
|
|
137
|
+
f.setUint32(s, r.args.length, !0);
|
|
138
|
+
let l = 0;
|
|
139
|
+
for (const u of r.args)
|
|
140
|
+
l += u.length + 1;
|
|
141
|
+
return f.setUint32(o, l, !0), b.log(f.getUint32(s, !0), f.getUint32(o, !0)), 0;
|
|
142
|
+
}, args_get(s, o) {
|
|
143
|
+
const f = new DataView(r.inst.exports.memory.buffer), l = new Uint8Array(r.inst.exports.memory.buffer), u = o;
|
|
144
|
+
for (let c = 0; c < r.args.length; c++) {
|
|
145
|
+
f.setUint32(s, o, !0), s += 4;
|
|
146
|
+
const _ = new TextEncoder().encode(r.args[c]);
|
|
147
|
+
l.set(_, o), f.setUint8(o + _.length, 0), o += _.length + 1;
|
|
148
|
+
}
|
|
149
|
+
return b.enabled && b.log(new TextDecoder("utf-8").decode(l.slice(u, o))), 0;
|
|
150
|
+
}, environ_sizes_get(s, o) {
|
|
151
|
+
const f = new DataView(r.inst.exports.memory.buffer);
|
|
152
|
+
f.setUint32(s, r.env.length, !0);
|
|
153
|
+
let l = 0;
|
|
154
|
+
for (const u of r.env)
|
|
155
|
+
l += new TextEncoder().encode(u).length + 1;
|
|
156
|
+
return f.setUint32(o, l, !0), b.log(f.getUint32(s, !0), f.getUint32(o, !0)), 0;
|
|
157
|
+
}, environ_get(s, o) {
|
|
158
|
+
const f = new DataView(r.inst.exports.memory.buffer), l = new Uint8Array(r.inst.exports.memory.buffer), u = o;
|
|
159
|
+
for (let c = 0; c < r.env.length; c++) {
|
|
160
|
+
f.setUint32(s, o, !0), s += 4;
|
|
161
|
+
const _ = new TextEncoder().encode(r.env[c]);
|
|
162
|
+
l.set(_, o), f.setUint8(o + _.length, 0), o += _.length + 1;
|
|
163
|
+
}
|
|
164
|
+
return b.enabled && b.log(new TextDecoder("utf-8").decode(l.slice(u, o))), 0;
|
|
165
|
+
}, clock_res_get(s, o) {
|
|
166
|
+
let f;
|
|
167
|
+
switch (s) {
|
|
168
|
+
case 1: {
|
|
169
|
+
f = 5000n;
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
case 0: {
|
|
173
|
+
f = 1000000n;
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
default:
|
|
177
|
+
return 52;
|
|
178
|
+
}
|
|
179
|
+
return new DataView(r.inst.exports.memory.buffer).setBigUint64(o, f, !0), 0;
|
|
180
|
+
}, clock_time_get(s, o, f) {
|
|
181
|
+
const l = new DataView(r.inst.exports.memory.buffer);
|
|
182
|
+
if (s === 0)
|
|
183
|
+
l.setBigUint64(f, BigInt((/* @__PURE__ */ new Date()).getTime()) * 1000000n, !0);
|
|
184
|
+
else if (s == 1) {
|
|
185
|
+
let u;
|
|
186
|
+
try {
|
|
187
|
+
u = BigInt(Math.round(performance.now() * 1e6));
|
|
188
|
+
} catch {
|
|
189
|
+
u = 0n;
|
|
190
|
+
}
|
|
191
|
+
l.setBigUint64(f, u, !0);
|
|
192
|
+
} else
|
|
193
|
+
l.setBigUint64(f, 0n, !0);
|
|
194
|
+
return 0;
|
|
195
|
+
}, fd_advise(s, o, f, l) {
|
|
196
|
+
return r.fds[s] != null ? 0 : 8;
|
|
197
|
+
}, fd_allocate(s, o, f) {
|
|
198
|
+
return r.fds[s] != null ? r.fds[s].fd_allocate(o, f) : 8;
|
|
199
|
+
}, fd_close(s) {
|
|
200
|
+
if (r.fds[s] != null) {
|
|
201
|
+
const o = r.fds[s].fd_close();
|
|
202
|
+
return r.fds[s] = void 0, o;
|
|
203
|
+
} else
|
|
204
|
+
return 8;
|
|
205
|
+
}, fd_datasync(s) {
|
|
206
|
+
return r.fds[s] != null ? r.fds[s].fd_sync() : 8;
|
|
207
|
+
}, fd_fdstat_get(s, o) {
|
|
208
|
+
if (r.fds[s] != null) {
|
|
209
|
+
const { ret: f, fdstat: l } = r.fds[s].fd_fdstat_get();
|
|
210
|
+
return l?.write_bytes(new DataView(r.inst.exports.memory.buffer), o), f;
|
|
211
|
+
} else
|
|
212
|
+
return 8;
|
|
213
|
+
}, fd_fdstat_set_flags(s, o) {
|
|
214
|
+
return r.fds[s] != null ? r.fds[s].fd_fdstat_set_flags(o) : 8;
|
|
215
|
+
}, fd_fdstat_set_rights(s, o, f) {
|
|
216
|
+
return r.fds[s] != null ? r.fds[s].fd_fdstat_set_rights(o, f) : 8;
|
|
217
|
+
}, fd_filestat_get(s, o) {
|
|
218
|
+
if (r.fds[s] != null) {
|
|
219
|
+
const { ret: f, filestat: l } = r.fds[s].fd_filestat_get();
|
|
220
|
+
return l?.write_bytes(new DataView(r.inst.exports.memory.buffer), o), f;
|
|
221
|
+
} else
|
|
222
|
+
return 8;
|
|
223
|
+
}, fd_filestat_set_size(s, o) {
|
|
224
|
+
return r.fds[s] != null ? r.fds[s].fd_filestat_set_size(o) : 8;
|
|
225
|
+
}, fd_filestat_set_times(s, o, f, l) {
|
|
226
|
+
return r.fds[s] != null ? r.fds[s].fd_filestat_set_times(o, f, l) : 8;
|
|
227
|
+
}, fd_pread(s, o, f, l, u) {
|
|
228
|
+
const c = new DataView(r.inst.exports.memory.buffer), _ = new Uint8Array(r.inst.exports.memory.buffer);
|
|
229
|
+
if (r.fds[s] != null) {
|
|
230
|
+
const d = fe.read_bytes_array(c, o, f);
|
|
231
|
+
let p = 0;
|
|
232
|
+
for (const h of d) {
|
|
233
|
+
const { ret: y, data: R } = r.fds[s].fd_pread(h.buf_len, l);
|
|
234
|
+
if (y != 0)
|
|
235
|
+
return c.setUint32(u, p, !0), y;
|
|
236
|
+
if (_.set(R, h.buf), p += R.length, l += BigInt(R.length), R.length != h.buf_len)
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
return c.setUint32(u, p, !0), 0;
|
|
240
|
+
} else
|
|
241
|
+
return 8;
|
|
242
|
+
}, fd_prestat_get(s, o) {
|
|
243
|
+
const f = new DataView(r.inst.exports.memory.buffer);
|
|
244
|
+
if (r.fds[s] != null) {
|
|
245
|
+
const { ret: l, prestat: u } = r.fds[s].fd_prestat_get();
|
|
246
|
+
return u?.write_bytes(f, o), l;
|
|
247
|
+
} else
|
|
248
|
+
return 8;
|
|
249
|
+
}, fd_prestat_dir_name(s, o, f) {
|
|
250
|
+
if (r.fds[s] != null) {
|
|
251
|
+
const { ret: l, prestat: u } = r.fds[s].fd_prestat_get();
|
|
252
|
+
if (u == null)
|
|
253
|
+
return l;
|
|
254
|
+
const c = u.inner.pr_name;
|
|
255
|
+
return new Uint8Array(r.inst.exports.memory.buffer).set(c.slice(0, f), o), c.byteLength > f ? 37 : 0;
|
|
256
|
+
} else
|
|
257
|
+
return 8;
|
|
258
|
+
}, fd_pwrite(s, o, f, l, u) {
|
|
259
|
+
const c = new DataView(r.inst.exports.memory.buffer), _ = new Uint8Array(r.inst.exports.memory.buffer);
|
|
260
|
+
if (r.fds[s] != null) {
|
|
261
|
+
const d = le.read_bytes_array(c, o, f);
|
|
262
|
+
let p = 0;
|
|
263
|
+
for (const h of d) {
|
|
264
|
+
const y = _.slice(h.buf, h.buf + h.buf_len), { ret: R, nwritten: m } = r.fds[s].fd_pwrite(y, l);
|
|
265
|
+
if (R != 0)
|
|
266
|
+
return c.setUint32(u, p, !0), R;
|
|
267
|
+
if (p += m, l += BigInt(m), m != y.byteLength)
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
return c.setUint32(u, p, !0), 0;
|
|
271
|
+
} else
|
|
272
|
+
return 8;
|
|
273
|
+
}, fd_read(s, o, f, l) {
|
|
274
|
+
const u = new DataView(r.inst.exports.memory.buffer), c = new Uint8Array(r.inst.exports.memory.buffer);
|
|
275
|
+
if (r.fds[s] != null) {
|
|
276
|
+
const _ = fe.read_bytes_array(u, o, f);
|
|
277
|
+
let d = 0;
|
|
278
|
+
for (const p of _) {
|
|
279
|
+
const { ret: h, data: y } = r.fds[s].fd_read(p.buf_len);
|
|
280
|
+
if (h != 0)
|
|
281
|
+
return u.setUint32(l, d, !0), h;
|
|
282
|
+
if (c.set(y, p.buf), d += y.length, y.length != p.buf_len)
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
return u.setUint32(l, d, !0), 0;
|
|
286
|
+
} else
|
|
287
|
+
return 8;
|
|
288
|
+
}, fd_readdir(s, o, f, l, u) {
|
|
289
|
+
const c = new DataView(r.inst.exports.memory.buffer), _ = new Uint8Array(r.inst.exports.memory.buffer);
|
|
290
|
+
if (r.fds[s] != null) {
|
|
291
|
+
let d = 0;
|
|
292
|
+
for (; ; ) {
|
|
293
|
+
const { ret: p, dirent: h } = r.fds[s].fd_readdir_single(l);
|
|
294
|
+
if (p != 0)
|
|
295
|
+
return c.setUint32(u, d, !0), p;
|
|
296
|
+
if (h == null)
|
|
297
|
+
break;
|
|
298
|
+
if (f - d < h.head_length()) {
|
|
299
|
+
d = f;
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
const y = new ArrayBuffer(h.head_length());
|
|
303
|
+
if (h.write_head_bytes(new DataView(y), 0), _.set(new Uint8Array(y).slice(0, Math.min(y.byteLength, f - d)), o), o += h.head_length(), d += h.head_length(), f - d < h.name_length()) {
|
|
304
|
+
d = f;
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
h.write_name_bytes(_, o, f - d), o += h.name_length(), d += h.name_length(), l = h.d_next;
|
|
308
|
+
}
|
|
309
|
+
return c.setUint32(u, d, !0), 0;
|
|
310
|
+
} else
|
|
311
|
+
return 8;
|
|
312
|
+
}, fd_renumber(s, o) {
|
|
313
|
+
if (r.fds[s] != null && r.fds[o] != null) {
|
|
314
|
+
const f = r.fds[o].fd_close();
|
|
315
|
+
return f != 0 ? f : (r.fds[o] = r.fds[s], r.fds[s] = void 0, 0);
|
|
316
|
+
} else
|
|
317
|
+
return 8;
|
|
318
|
+
}, fd_seek(s, o, f, l) {
|
|
319
|
+
const u = new DataView(r.inst.exports.memory.buffer);
|
|
320
|
+
if (r.fds[s] != null) {
|
|
321
|
+
const { ret: c, offset: _ } = r.fds[s].fd_seek(o, f);
|
|
322
|
+
return u.setBigInt64(l, _, !0), c;
|
|
323
|
+
} else
|
|
324
|
+
return 8;
|
|
325
|
+
}, fd_sync(s) {
|
|
326
|
+
return r.fds[s] != null ? r.fds[s].fd_sync() : 8;
|
|
327
|
+
}, fd_tell(s, o) {
|
|
328
|
+
const f = new DataView(r.inst.exports.memory.buffer);
|
|
329
|
+
if (r.fds[s] != null) {
|
|
330
|
+
const { ret: l, offset: u } = r.fds[s].fd_tell();
|
|
331
|
+
return f.setBigUint64(o, u, !0), l;
|
|
332
|
+
} else
|
|
333
|
+
return 8;
|
|
334
|
+
}, fd_write(s, o, f, l) {
|
|
335
|
+
const u = new DataView(r.inst.exports.memory.buffer), c = new Uint8Array(r.inst.exports.memory.buffer);
|
|
336
|
+
if (r.fds[s] != null) {
|
|
337
|
+
const _ = le.read_bytes_array(u, o, f);
|
|
338
|
+
let d = 0;
|
|
339
|
+
for (const p of _) {
|
|
340
|
+
const h = c.slice(p.buf, p.buf + p.buf_len), { ret: y, nwritten: R } = r.fds[s].fd_write(h);
|
|
341
|
+
if (y != 0)
|
|
342
|
+
return u.setUint32(l, d, !0), y;
|
|
343
|
+
if (d += R, R != h.byteLength)
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
return u.setUint32(l, d, !0), 0;
|
|
347
|
+
} else
|
|
348
|
+
return 8;
|
|
349
|
+
}, path_create_directory(s, o, f) {
|
|
350
|
+
const l = new Uint8Array(r.inst.exports.memory.buffer);
|
|
351
|
+
if (r.fds[s] != null) {
|
|
352
|
+
const u = new TextDecoder("utf-8").decode(l.slice(o, o + f));
|
|
353
|
+
return r.fds[s].path_create_directory(u);
|
|
354
|
+
} else
|
|
355
|
+
return 8;
|
|
356
|
+
}, path_filestat_get(s, o, f, l, u) {
|
|
357
|
+
const c = new DataView(r.inst.exports.memory.buffer), _ = new Uint8Array(r.inst.exports.memory.buffer);
|
|
358
|
+
if (r.fds[s] != null) {
|
|
359
|
+
const d = new TextDecoder("utf-8").decode(_.slice(f, f + l)), { ret: p, filestat: h } = r.fds[s].path_filestat_get(o, d);
|
|
360
|
+
return h?.write_bytes(c, u), p;
|
|
361
|
+
} else
|
|
362
|
+
return 8;
|
|
363
|
+
}, path_filestat_set_times(s, o, f, l, u, c, _) {
|
|
364
|
+
const d = new Uint8Array(r.inst.exports.memory.buffer);
|
|
365
|
+
if (r.fds[s] != null) {
|
|
366
|
+
const p = new TextDecoder("utf-8").decode(d.slice(f, f + l));
|
|
367
|
+
return r.fds[s].path_filestat_set_times(o, p, u, c, _);
|
|
368
|
+
} else
|
|
369
|
+
return 8;
|
|
370
|
+
}, path_link(s, o, f, l, u, c, _) {
|
|
371
|
+
const d = new Uint8Array(r.inst.exports.memory.buffer);
|
|
372
|
+
if (r.fds[s] != null && r.fds[u] != null) {
|
|
373
|
+
const p = new TextDecoder("utf-8").decode(d.slice(f, f + l)), h = new TextDecoder("utf-8").decode(d.slice(c, c + _)), { ret: y, inode_obj: R } = r.fds[s].path_lookup(p, o);
|
|
374
|
+
return R == null ? y : r.fds[u].path_link(h, R, !1);
|
|
375
|
+
} else
|
|
376
|
+
return 8;
|
|
377
|
+
}, path_open(s, o, f, l, u, c, _, d, p) {
|
|
378
|
+
const h = new DataView(r.inst.exports.memory.buffer), y = new Uint8Array(r.inst.exports.memory.buffer);
|
|
379
|
+
if (r.fds[s] != null) {
|
|
380
|
+
const R = new TextDecoder("utf-8").decode(y.slice(f, f + l));
|
|
381
|
+
b.log(R);
|
|
382
|
+
const { ret: m, fd_obj: g } = r.fds[s].path_open(o, R, u, c, _, d);
|
|
383
|
+
if (m != 0)
|
|
384
|
+
return m;
|
|
385
|
+
r.fds.push(g);
|
|
386
|
+
const E = r.fds.length - 1;
|
|
387
|
+
return h.setUint32(p, E, !0), 0;
|
|
388
|
+
} else
|
|
389
|
+
return 8;
|
|
390
|
+
}, path_readlink(s, o, f, l, u, c) {
|
|
391
|
+
const _ = new DataView(r.inst.exports.memory.buffer), d = new Uint8Array(r.inst.exports.memory.buffer);
|
|
392
|
+
if (r.fds[s] != null) {
|
|
393
|
+
const p = new TextDecoder("utf-8").decode(d.slice(o, o + f));
|
|
394
|
+
b.log(p);
|
|
395
|
+
const { ret: h, data: y } = r.fds[s].path_readlink(p);
|
|
396
|
+
if (y != null) {
|
|
397
|
+
const R = new TextEncoder().encode(y);
|
|
398
|
+
if (R.length > u)
|
|
399
|
+
return _.setUint32(c, 0, !0), 8;
|
|
400
|
+
d.set(R, l), _.setUint32(c, R.length, !0);
|
|
401
|
+
}
|
|
402
|
+
return h;
|
|
403
|
+
} else
|
|
404
|
+
return 8;
|
|
405
|
+
}, path_remove_directory(s, o, f) {
|
|
406
|
+
const l = new Uint8Array(r.inst.exports.memory.buffer);
|
|
407
|
+
if (r.fds[s] != null) {
|
|
408
|
+
const u = new TextDecoder("utf-8").decode(l.slice(o, o + f));
|
|
409
|
+
return r.fds[s].path_remove_directory(u);
|
|
410
|
+
} else
|
|
411
|
+
return 8;
|
|
412
|
+
}, path_rename(s, o, f, l, u, c) {
|
|
413
|
+
const _ = new Uint8Array(r.inst.exports.memory.buffer);
|
|
414
|
+
if (r.fds[s] != null && r.fds[l] != null) {
|
|
415
|
+
const d = new TextDecoder("utf-8").decode(_.slice(o, o + f)), p = new TextDecoder("utf-8").decode(_.slice(u, u + c));
|
|
416
|
+
let { ret: h, inode_obj: y } = r.fds[s].path_unlink(d);
|
|
417
|
+
if (y == null)
|
|
418
|
+
return h;
|
|
419
|
+
if (h = r.fds[l].path_link(p, y, !0), h != 0 && r.fds[s].path_link(d, y, !0) != 0)
|
|
420
|
+
throw "path_link should always return success when relinking an inode back to the original place";
|
|
421
|
+
return h;
|
|
422
|
+
} else
|
|
423
|
+
return 8;
|
|
424
|
+
}, path_symlink(s, o, f, l, u) {
|
|
425
|
+
const c = new Uint8Array(r.inst.exports.memory.buffer);
|
|
426
|
+
return r.fds[f] != null ? (new TextDecoder("utf-8").decode(c.slice(s, s + o)), new TextDecoder("utf-8").decode(c.slice(l, l + u)), 58) : 8;
|
|
427
|
+
}, path_unlink_file(s, o, f) {
|
|
428
|
+
const l = new Uint8Array(r.inst.exports.memory.buffer);
|
|
429
|
+
if (r.fds[s] != null) {
|
|
430
|
+
const u = new TextDecoder("utf-8").decode(l.slice(o, o + f));
|
|
431
|
+
return r.fds[s].path_unlink_file(u);
|
|
432
|
+
} else
|
|
433
|
+
return 8;
|
|
434
|
+
}, poll_oneoff(s, o, f) {
|
|
435
|
+
if (f === 0)
|
|
436
|
+
return 28;
|
|
437
|
+
if (f > 1)
|
|
438
|
+
return b.log("poll_oneoff: only a single subscription is supported"), 58;
|
|
439
|
+
const l = new DataView(r.inst.exports.memory.buffer), u = Ve.read_bytes(l, s), c = u.eventtype, _ = u.clockid, d = u.timeout;
|
|
440
|
+
if (c !== ft)
|
|
441
|
+
return b.log("poll_oneoff: only clock subscriptions are supported"), 58;
|
|
442
|
+
let p;
|
|
443
|
+
if (_ === 1)
|
|
444
|
+
p = () => BigInt(Math.round(performance.now() * 1e6));
|
|
445
|
+
else if (_ === 0)
|
|
446
|
+
p = () => BigInt((/* @__PURE__ */ new Date()).getTime()) * 1000000n;
|
|
447
|
+
else
|
|
448
|
+
return 28;
|
|
449
|
+
const h = u.flags & lt ? d : p() + d;
|
|
450
|
+
for (; h > p(); )
|
|
451
|
+
;
|
|
452
|
+
return new ct(u.userdata, 0, c).write_bytes(l, o), 0;
|
|
453
|
+
}, proc_exit(s) {
|
|
454
|
+
throw new ge(s);
|
|
455
|
+
}, proc_raise(s) {
|
|
456
|
+
throw "raised signal " + s;
|
|
457
|
+
}, sched_yield() {
|
|
458
|
+
}, random_get(s, o) {
|
|
459
|
+
const f = new Uint8Array(r.inst.exports.memory.buffer).subarray(s, s + o);
|
|
460
|
+
if ("crypto" in globalThis && (typeof SharedArrayBuffer > "u" || !(r.inst.exports.memory.buffer instanceof SharedArrayBuffer)))
|
|
461
|
+
for (let l = 0; l < o; l += 65536)
|
|
462
|
+
crypto.getRandomValues(f.subarray(l, l + 65536));
|
|
463
|
+
else
|
|
464
|
+
for (let l = 0; l < o; l++)
|
|
465
|
+
f[l] = Math.random() * 256 | 0;
|
|
466
|
+
}, sock_recv(s, o, f) {
|
|
467
|
+
throw "sockets not supported";
|
|
468
|
+
}, sock_send(s, o, f) {
|
|
469
|
+
throw "sockets not supported";
|
|
470
|
+
}, sock_shutdown(s, o) {
|
|
471
|
+
throw "sockets not supported";
|
|
472
|
+
}, sock_accept(s, o) {
|
|
473
|
+
throw "sockets not supported";
|
|
474
|
+
} };
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
class Se {
|
|
478
|
+
fd_allocate(e, t) {
|
|
479
|
+
return 58;
|
|
480
|
+
}
|
|
481
|
+
fd_close() {
|
|
482
|
+
return 0;
|
|
483
|
+
}
|
|
484
|
+
fd_fdstat_get() {
|
|
485
|
+
return { ret: 58, fdstat: null };
|
|
486
|
+
}
|
|
487
|
+
fd_fdstat_set_flags(e) {
|
|
488
|
+
return 58;
|
|
489
|
+
}
|
|
490
|
+
fd_fdstat_set_rights(e, t) {
|
|
491
|
+
return 58;
|
|
492
|
+
}
|
|
493
|
+
fd_filestat_get() {
|
|
494
|
+
return { ret: 58, filestat: null };
|
|
495
|
+
}
|
|
496
|
+
fd_filestat_set_size(e) {
|
|
497
|
+
return 58;
|
|
498
|
+
}
|
|
499
|
+
fd_filestat_set_times(e, t, i) {
|
|
500
|
+
return 58;
|
|
501
|
+
}
|
|
502
|
+
fd_pread(e, t) {
|
|
503
|
+
return { ret: 58, data: new Uint8Array() };
|
|
504
|
+
}
|
|
505
|
+
fd_prestat_get() {
|
|
506
|
+
return { ret: 58, prestat: null };
|
|
507
|
+
}
|
|
508
|
+
fd_pwrite(e, t) {
|
|
509
|
+
return { ret: 58, nwritten: 0 };
|
|
510
|
+
}
|
|
511
|
+
fd_read(e) {
|
|
512
|
+
return { ret: 58, data: new Uint8Array() };
|
|
513
|
+
}
|
|
514
|
+
fd_readdir_single(e) {
|
|
515
|
+
return { ret: 58, dirent: null };
|
|
516
|
+
}
|
|
517
|
+
fd_seek(e, t) {
|
|
518
|
+
return { ret: 58, offset: 0n };
|
|
519
|
+
}
|
|
520
|
+
fd_sync() {
|
|
521
|
+
return 0;
|
|
522
|
+
}
|
|
523
|
+
fd_tell() {
|
|
524
|
+
return { ret: 58, offset: 0n };
|
|
525
|
+
}
|
|
526
|
+
fd_write(e) {
|
|
527
|
+
return { ret: 58, nwritten: 0 };
|
|
528
|
+
}
|
|
529
|
+
path_create_directory(e) {
|
|
530
|
+
return 58;
|
|
531
|
+
}
|
|
532
|
+
path_filestat_get(e, t) {
|
|
533
|
+
return { ret: 58, filestat: null };
|
|
534
|
+
}
|
|
535
|
+
path_filestat_set_times(e, t, i, a, r) {
|
|
536
|
+
return 58;
|
|
537
|
+
}
|
|
538
|
+
path_link(e, t, i) {
|
|
539
|
+
return 58;
|
|
540
|
+
}
|
|
541
|
+
path_unlink(e) {
|
|
542
|
+
return { ret: 58, inode_obj: null };
|
|
543
|
+
}
|
|
544
|
+
path_lookup(e, t) {
|
|
545
|
+
return { ret: 58, inode_obj: null };
|
|
546
|
+
}
|
|
547
|
+
path_open(e, t, i, a, r, s) {
|
|
548
|
+
return { ret: 54, fd_obj: null };
|
|
549
|
+
}
|
|
550
|
+
path_readlink(e) {
|
|
551
|
+
return { ret: 58, data: null };
|
|
552
|
+
}
|
|
553
|
+
path_remove_directory(e) {
|
|
554
|
+
return 58;
|
|
555
|
+
}
|
|
556
|
+
path_rename(e, t, i) {
|
|
557
|
+
return 58;
|
|
558
|
+
}
|
|
559
|
+
path_unlink_file(e) {
|
|
560
|
+
return 58;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
class G {
|
|
564
|
+
static issue_ino() {
|
|
565
|
+
return G.next_ino++;
|
|
566
|
+
}
|
|
567
|
+
static root_ino() {
|
|
568
|
+
return 0n;
|
|
569
|
+
}
|
|
570
|
+
constructor() {
|
|
571
|
+
this.ino = G.issue_ino();
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
G.next_ino = 1n;
|
|
575
|
+
class Bt extends Se {
|
|
576
|
+
fd_allocate(e, t) {
|
|
577
|
+
if (!(this.file.size > e + t)) {
|
|
578
|
+
const i = new Uint8Array(Number(e + t));
|
|
579
|
+
i.set(this.file.data, 0), this.file.data = i;
|
|
580
|
+
}
|
|
581
|
+
return 0;
|
|
582
|
+
}
|
|
583
|
+
fd_fdstat_get() {
|
|
584
|
+
return { ret: 0, fdstat: new Oe($, 0) };
|
|
585
|
+
}
|
|
586
|
+
fd_filestat_set_size(e) {
|
|
587
|
+
if (this.file.size > e)
|
|
588
|
+
this.file.data = new Uint8Array(this.file.data.buffer.slice(0, Number(e)));
|
|
589
|
+
else {
|
|
590
|
+
const t = new Uint8Array(Number(e));
|
|
591
|
+
t.set(this.file.data, 0), this.file.data = t;
|
|
592
|
+
}
|
|
593
|
+
return 0;
|
|
594
|
+
}
|
|
595
|
+
fd_read(e) {
|
|
596
|
+
const t = this.file.data.slice(Number(this.file_pos), Number(this.file_pos + BigInt(e)));
|
|
597
|
+
return this.file_pos += BigInt(t.length), { ret: 0, data: t };
|
|
598
|
+
}
|
|
599
|
+
fd_pread(e, t) {
|
|
600
|
+
return { ret: 0, data: this.file.data.slice(Number(t), Number(t + BigInt(e))) };
|
|
601
|
+
}
|
|
602
|
+
fd_seek(e, t) {
|
|
603
|
+
let i;
|
|
604
|
+
switch (t) {
|
|
605
|
+
case bt:
|
|
606
|
+
i = e;
|
|
607
|
+
break;
|
|
608
|
+
case Ut:
|
|
609
|
+
i = this.file_pos + e;
|
|
610
|
+
break;
|
|
611
|
+
case at:
|
|
612
|
+
i = BigInt(this.file.data.byteLength) + e;
|
|
613
|
+
break;
|
|
614
|
+
default:
|
|
615
|
+
return { ret: 28, offset: 0n };
|
|
616
|
+
}
|
|
617
|
+
return i < 0 ? { ret: 28, offset: 0n } : (this.file_pos = i, { ret: 0, offset: this.file_pos });
|
|
618
|
+
}
|
|
619
|
+
fd_tell() {
|
|
620
|
+
return { ret: 0, offset: this.file_pos };
|
|
621
|
+
}
|
|
622
|
+
fd_write(e) {
|
|
623
|
+
if (this.file.readonly) return { ret: 8, nwritten: 0 };
|
|
624
|
+
if (this.file_pos + BigInt(e.byteLength) > this.file.size) {
|
|
625
|
+
const t = this.file.data;
|
|
626
|
+
this.file.data = new Uint8Array(Number(this.file_pos + BigInt(e.byteLength))), this.file.data.set(t);
|
|
627
|
+
}
|
|
628
|
+
return this.file.data.set(e, Number(this.file_pos)), this.file_pos += BigInt(e.byteLength), { ret: 0, nwritten: e.byteLength };
|
|
629
|
+
}
|
|
630
|
+
fd_pwrite(e, t) {
|
|
631
|
+
if (this.file.readonly) return { ret: 8, nwritten: 0 };
|
|
632
|
+
if (t + BigInt(e.byteLength) > this.file.size) {
|
|
633
|
+
const i = this.file.data;
|
|
634
|
+
this.file.data = new Uint8Array(Number(t + BigInt(e.byteLength))), this.file.data.set(i);
|
|
635
|
+
}
|
|
636
|
+
return this.file.data.set(e, Number(t)), { ret: 0, nwritten: e.byteLength };
|
|
637
|
+
}
|
|
638
|
+
fd_filestat_get() {
|
|
639
|
+
return { ret: 0, filestat: this.file.stat() };
|
|
640
|
+
}
|
|
641
|
+
constructor(e) {
|
|
642
|
+
super(), this.file_pos = 0n, this.file = e;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
class ut extends Se {
|
|
646
|
+
fd_seek(e, t) {
|
|
647
|
+
return { ret: 8, offset: 0n };
|
|
648
|
+
}
|
|
649
|
+
fd_tell() {
|
|
650
|
+
return { ret: 8, offset: 0n };
|
|
651
|
+
}
|
|
652
|
+
fd_allocate(e, t) {
|
|
653
|
+
return 8;
|
|
654
|
+
}
|
|
655
|
+
fd_fdstat_get() {
|
|
656
|
+
return { ret: 0, fdstat: new Oe(I, 0) };
|
|
657
|
+
}
|
|
658
|
+
fd_readdir_single(e) {
|
|
659
|
+
if (b.enabled && (b.log("readdir_single", e), b.log(e, this.dir.contents.keys())), e == 0n)
|
|
660
|
+
return { ret: 0, dirent: new ve(1n, this.dir.ino, ".", I) };
|
|
661
|
+
if (e == 1n)
|
|
662
|
+
return { ret: 0, dirent: new ve(2n, this.dir.parent_ino(), "..", I) };
|
|
663
|
+
if (e >= BigInt(this.dir.contents.size) + 2n)
|
|
664
|
+
return { ret: 0, dirent: null };
|
|
665
|
+
const [t, i] = Array.from(this.dir.contents.entries())[Number(e - 2n)];
|
|
666
|
+
return { ret: 0, dirent: new ve(e + 1n, i.ino, t, i.stat().filetype) };
|
|
667
|
+
}
|
|
668
|
+
path_filestat_get(e, t) {
|
|
669
|
+
const { ret: i, path: a } = W.from(t);
|
|
670
|
+
if (a == null)
|
|
671
|
+
return { ret: i, filestat: null };
|
|
672
|
+
const { ret: r, entry: s } = this.dir.get_entry_for_path(a);
|
|
673
|
+
return s == null ? { ret: r, filestat: null } : { ret: 0, filestat: s.stat() };
|
|
674
|
+
}
|
|
675
|
+
path_lookup(e, t) {
|
|
676
|
+
const { ret: i, path: a } = W.from(e);
|
|
677
|
+
if (a == null)
|
|
678
|
+
return { ret: i, inode_obj: null };
|
|
679
|
+
const { ret: r, entry: s } = this.dir.get_entry_for_path(a);
|
|
680
|
+
return s == null ? { ret: r, inode_obj: null } : { ret: 0, inode_obj: s };
|
|
681
|
+
}
|
|
682
|
+
path_open(e, t, i, a, r, s) {
|
|
683
|
+
const { ret: o, path: f } = W.from(t);
|
|
684
|
+
if (f == null)
|
|
685
|
+
return { ret: o, fd_obj: null };
|
|
686
|
+
let { ret: l, entry: u } = this.dir.get_entry_for_path(f);
|
|
687
|
+
if (u == null) {
|
|
688
|
+
if (l != 44)
|
|
689
|
+
return { ret: l, fd_obj: null };
|
|
690
|
+
if ((i & De) == De) {
|
|
691
|
+
const { ret: c, entry: _ } = this.dir.create_entry_for_path(t, (i & J) == J);
|
|
692
|
+
if (_ == null)
|
|
693
|
+
return { ret: c, fd_obj: null };
|
|
694
|
+
u = _;
|
|
695
|
+
} else
|
|
696
|
+
return { ret: 44, fd_obj: null };
|
|
697
|
+
} else if ((i & Je) == Je)
|
|
698
|
+
return { ret: 20, fd_obj: null };
|
|
699
|
+
return (i & J) == J && u.stat().filetype !== I ? { ret: 54, fd_obj: null } : u.path_open(i, a, s);
|
|
700
|
+
}
|
|
701
|
+
path_create_directory(e) {
|
|
702
|
+
return this.path_open(0, e, De | J, 0n, 0n, 0).ret;
|
|
703
|
+
}
|
|
704
|
+
path_link(e, t, i) {
|
|
705
|
+
const { ret: a, path: r } = W.from(e);
|
|
706
|
+
if (r == null)
|
|
707
|
+
return a;
|
|
708
|
+
if (r.is_dir)
|
|
709
|
+
return 44;
|
|
710
|
+
const { ret: s, parent_entry: o, filename: f, entry: l } = this.dir.get_parent_dir_and_entry_for_path(r, !0);
|
|
711
|
+
if (o == null || f == null)
|
|
712
|
+
return s;
|
|
713
|
+
if (l != null) {
|
|
714
|
+
const u = t.stat().filetype == I, c = l.stat().filetype == I;
|
|
715
|
+
if (u && c)
|
|
716
|
+
if (i && l instanceof D) {
|
|
717
|
+
if (l.contents.size != 0) return 55;
|
|
718
|
+
} else
|
|
719
|
+
return 20;
|
|
720
|
+
else {
|
|
721
|
+
if (u && !c)
|
|
722
|
+
return 54;
|
|
723
|
+
if (!u && c)
|
|
724
|
+
return 31;
|
|
725
|
+
if (!(t.stat().filetype == $ && l.stat().filetype == $)) return 20;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
return !i && t.stat().filetype == I ? 63 : (o.contents.set(f, t), 0);
|
|
729
|
+
}
|
|
730
|
+
path_unlink(e) {
|
|
731
|
+
const { ret: t, path: i } = W.from(e);
|
|
732
|
+
if (i == null)
|
|
733
|
+
return { ret: t, inode_obj: null };
|
|
734
|
+
const { ret: a, parent_entry: r, filename: s, entry: o } = this.dir.get_parent_dir_and_entry_for_path(i, !0);
|
|
735
|
+
return r == null || s == null ? { ret: a, inode_obj: null } : o == null ? { ret: 44, inode_obj: null } : (r.contents.delete(s), { ret: 0, inode_obj: o });
|
|
736
|
+
}
|
|
737
|
+
path_unlink_file(e) {
|
|
738
|
+
const { ret: t, path: i } = W.from(e);
|
|
739
|
+
if (i == null)
|
|
740
|
+
return t;
|
|
741
|
+
const { ret: a, parent_entry: r, filename: s, entry: o } = this.dir.get_parent_dir_and_entry_for_path(i, !1);
|
|
742
|
+
return r == null || s == null || o == null ? a : o.stat().filetype === I ? 31 : (r.contents.delete(s), 0);
|
|
743
|
+
}
|
|
744
|
+
path_remove_directory(e) {
|
|
745
|
+
const { ret: t, path: i } = W.from(e);
|
|
746
|
+
if (i == null)
|
|
747
|
+
return t;
|
|
748
|
+
const { ret: a, parent_entry: r, filename: s, entry: o } = this.dir.get_parent_dir_and_entry_for_path(i, !1);
|
|
749
|
+
return r == null || s == null || o == null ? a : !(o instanceof D) || o.stat().filetype !== I ? 54 : o.contents.size !== 0 ? 55 : r.contents.delete(s) ? 0 : 44;
|
|
750
|
+
}
|
|
751
|
+
fd_filestat_get() {
|
|
752
|
+
return { ret: 0, filestat: this.dir.stat() };
|
|
753
|
+
}
|
|
754
|
+
fd_filestat_set_size(e) {
|
|
755
|
+
return 8;
|
|
756
|
+
}
|
|
757
|
+
fd_read(e) {
|
|
758
|
+
return { ret: 8, data: new Uint8Array() };
|
|
759
|
+
}
|
|
760
|
+
fd_pread(e, t) {
|
|
761
|
+
return { ret: 8, data: new Uint8Array() };
|
|
762
|
+
}
|
|
763
|
+
fd_write(e) {
|
|
764
|
+
return { ret: 8, nwritten: 0 };
|
|
765
|
+
}
|
|
766
|
+
fd_pwrite(e, t) {
|
|
767
|
+
return { ret: 8, nwritten: 0 };
|
|
768
|
+
}
|
|
769
|
+
constructor(e) {
|
|
770
|
+
super(), this.dir = e;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
class et extends ut {
|
|
774
|
+
fd_prestat_get() {
|
|
775
|
+
return { ret: 0, prestat: ze.dir(this.prestat_name) };
|
|
776
|
+
}
|
|
777
|
+
constructor(e, t) {
|
|
778
|
+
super(new D(t)), this.prestat_name = e;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
class je extends G {
|
|
782
|
+
path_open(e, t, i) {
|
|
783
|
+
if (this.readonly && (t & BigInt(64)) == BigInt(64))
|
|
784
|
+
return { ret: 63, fd_obj: null };
|
|
785
|
+
if ((e & Qe) == Qe) {
|
|
786
|
+
if (this.readonly) return { ret: 63, fd_obj: null };
|
|
787
|
+
this.data = new Uint8Array([]);
|
|
788
|
+
}
|
|
789
|
+
const a = new Bt(this);
|
|
790
|
+
return i & At && a.fd_seek(0n, at), { ret: 0, fd_obj: a };
|
|
791
|
+
}
|
|
792
|
+
get size() {
|
|
793
|
+
return BigInt(this.data.byteLength);
|
|
794
|
+
}
|
|
795
|
+
stat() {
|
|
796
|
+
return new ot(this.ino, $, this.size);
|
|
797
|
+
}
|
|
798
|
+
constructor(e, t) {
|
|
799
|
+
super(), this.data = new Uint8Array(e), this.readonly = !!t?.readonly;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
let W = class _t {
|
|
803
|
+
static from(e) {
|
|
804
|
+
const t = new _t();
|
|
805
|
+
if (t.is_dir = e.endsWith("/"), e.startsWith("/"))
|
|
806
|
+
return { ret: 76, path: null };
|
|
807
|
+
if (e.includes("\0"))
|
|
808
|
+
return { ret: 28, path: null };
|
|
809
|
+
for (const i of e.split("/"))
|
|
810
|
+
if (!(i === "" || i === ".")) {
|
|
811
|
+
if (i === "..") {
|
|
812
|
+
if (t.parts.pop() == null)
|
|
813
|
+
return { ret: 76, path: null };
|
|
814
|
+
continue;
|
|
815
|
+
}
|
|
816
|
+
t.parts.push(i);
|
|
817
|
+
}
|
|
818
|
+
return { ret: 0, path: t };
|
|
819
|
+
}
|
|
820
|
+
to_path_string() {
|
|
821
|
+
let e = this.parts.join("/");
|
|
822
|
+
return this.is_dir && (e += "/"), e;
|
|
823
|
+
}
|
|
824
|
+
constructor() {
|
|
825
|
+
this.parts = [], this.is_dir = !1;
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
class D extends G {
|
|
829
|
+
parent_ino() {
|
|
830
|
+
return this.parent == null ? G.root_ino() : this.parent.ino;
|
|
831
|
+
}
|
|
832
|
+
path_open(e, t, i) {
|
|
833
|
+
return { ret: 0, fd_obj: new ut(this) };
|
|
834
|
+
}
|
|
835
|
+
stat() {
|
|
836
|
+
return new ot(this.ino, I, 0n);
|
|
837
|
+
}
|
|
838
|
+
get_entry_for_path(e) {
|
|
839
|
+
let t = this;
|
|
840
|
+
for (const i of e.parts) {
|
|
841
|
+
if (!(t instanceof D))
|
|
842
|
+
return { ret: 54, entry: null };
|
|
843
|
+
const a = t.contents.get(i);
|
|
844
|
+
if (a !== void 0)
|
|
845
|
+
t = a;
|
|
846
|
+
else
|
|
847
|
+
return b.log(i), { ret: 44, entry: null };
|
|
848
|
+
}
|
|
849
|
+
return e.is_dir && t.stat().filetype != I ? { ret: 54, entry: null } : { ret: 0, entry: t };
|
|
850
|
+
}
|
|
851
|
+
get_parent_dir_and_entry_for_path(e, t) {
|
|
852
|
+
const i = e.parts.pop();
|
|
853
|
+
if (i === void 0)
|
|
854
|
+
return { ret: 28, parent_entry: null, filename: null, entry: null };
|
|
855
|
+
const { ret: a, entry: r } = this.get_entry_for_path(e);
|
|
856
|
+
if (r == null)
|
|
857
|
+
return { ret: a, parent_entry: null, filename: null, entry: null };
|
|
858
|
+
if (!(r instanceof D))
|
|
859
|
+
return { ret: 54, parent_entry: null, filename: null, entry: null };
|
|
860
|
+
const s = r.contents.get(i);
|
|
861
|
+
return s === void 0 ? t ? { ret: 0, parent_entry: r, filename: i, entry: null } : { ret: 44, parent_entry: null, filename: null, entry: null } : e.is_dir && s.stat().filetype != I ? { ret: 54, parent_entry: null, filename: null, entry: null } : { ret: 0, parent_entry: r, filename: i, entry: s };
|
|
862
|
+
}
|
|
863
|
+
create_entry_for_path(e, t) {
|
|
864
|
+
const { ret: i, path: a } = W.from(e);
|
|
865
|
+
if (a == null)
|
|
866
|
+
return { ret: i, entry: null };
|
|
867
|
+
let { ret: r, parent_entry: s, filename: o, entry: f } = this.get_parent_dir_and_entry_for_path(a, !0);
|
|
868
|
+
if (s == null || o == null)
|
|
869
|
+
return { ret: r, entry: null };
|
|
870
|
+
if (f != null)
|
|
871
|
+
return { ret: 20, entry: null };
|
|
872
|
+
b.log("create", a);
|
|
873
|
+
let l;
|
|
874
|
+
return t ? l = new D(/* @__PURE__ */ new Map()) : l = new je(new ArrayBuffer(0)), s.contents.set(o, l), f = l, { ret: 0, entry: f };
|
|
875
|
+
}
|
|
876
|
+
constructor(e) {
|
|
877
|
+
super(), this.parent = null, e instanceof Array ? this.contents = new Map(e) : this.contents = e;
|
|
878
|
+
for (const t of this.contents.values())
|
|
879
|
+
t instanceof D && (t.parent = this);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
var v = Uint8Array, X = Uint16Array, kt = Int32Array, dt = new v([
|
|
883
|
+
0,
|
|
884
|
+
0,
|
|
885
|
+
0,
|
|
886
|
+
0,
|
|
887
|
+
0,
|
|
888
|
+
0,
|
|
889
|
+
0,
|
|
890
|
+
0,
|
|
891
|
+
1,
|
|
892
|
+
1,
|
|
893
|
+
1,
|
|
894
|
+
1,
|
|
895
|
+
2,
|
|
896
|
+
2,
|
|
897
|
+
2,
|
|
898
|
+
2,
|
|
899
|
+
3,
|
|
900
|
+
3,
|
|
901
|
+
3,
|
|
902
|
+
3,
|
|
903
|
+
4,
|
|
904
|
+
4,
|
|
905
|
+
4,
|
|
906
|
+
4,
|
|
907
|
+
5,
|
|
908
|
+
5,
|
|
909
|
+
5,
|
|
910
|
+
5,
|
|
911
|
+
0,
|
|
912
|
+
/* unused */
|
|
913
|
+
0,
|
|
914
|
+
0,
|
|
915
|
+
/* impossible */
|
|
916
|
+
0
|
|
917
|
+
]), ht = new v([
|
|
918
|
+
0,
|
|
919
|
+
0,
|
|
920
|
+
0,
|
|
921
|
+
0,
|
|
922
|
+
1,
|
|
923
|
+
1,
|
|
924
|
+
2,
|
|
925
|
+
2,
|
|
926
|
+
3,
|
|
927
|
+
3,
|
|
928
|
+
4,
|
|
929
|
+
4,
|
|
930
|
+
5,
|
|
931
|
+
5,
|
|
932
|
+
6,
|
|
933
|
+
6,
|
|
934
|
+
7,
|
|
935
|
+
7,
|
|
936
|
+
8,
|
|
937
|
+
8,
|
|
938
|
+
9,
|
|
939
|
+
9,
|
|
940
|
+
10,
|
|
941
|
+
10,
|
|
942
|
+
11,
|
|
943
|
+
11,
|
|
944
|
+
12,
|
|
945
|
+
12,
|
|
946
|
+
13,
|
|
947
|
+
13,
|
|
948
|
+
/* unused */
|
|
949
|
+
0,
|
|
950
|
+
0
|
|
951
|
+
]), Ft = new v([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), pt = function(n, e) {
|
|
952
|
+
for (var t = new X(31), i = 0; i < 31; ++i)
|
|
953
|
+
t[i] = e += 1 << n[i - 1];
|
|
954
|
+
for (var a = new kt(t[30]), i = 1; i < 30; ++i)
|
|
955
|
+
for (var r = t[i]; r < t[i + 1]; ++r)
|
|
956
|
+
a[r] = r - t[i] << 5 | i;
|
|
957
|
+
return { b: t, r: a };
|
|
958
|
+
}, yt = pt(dt, 2), Rt = yt.b, Lt = yt.r;
|
|
959
|
+
Rt[28] = 258, Lt[258] = 28;
|
|
960
|
+
var Mt = pt(ht, 0), Pt = Mt.b, Me = new X(32768);
|
|
961
|
+
for (var w = 0; w < 32768; ++w) {
|
|
962
|
+
var j = (w & 43690) >> 1 | (w & 21845) << 1;
|
|
963
|
+
j = (j & 52428) >> 2 | (j & 13107) << 2, j = (j & 61680) >> 4 | (j & 3855) << 4, Me[w] = ((j & 65280) >> 8 | (j & 255) << 8) >> 1;
|
|
964
|
+
}
|
|
965
|
+
var ae = function(n, e, t) {
|
|
966
|
+
for (var i = n.length, a = 0, r = new X(e); a < i; ++a)
|
|
967
|
+
n[a] && ++r[n[a] - 1];
|
|
968
|
+
var s = new X(e);
|
|
969
|
+
for (a = 1; a < e; ++a)
|
|
970
|
+
s[a] = s[a - 1] + r[a - 1] << 1;
|
|
971
|
+
var o;
|
|
972
|
+
if (t) {
|
|
973
|
+
o = new X(1 << e);
|
|
974
|
+
var f = 15 - e;
|
|
975
|
+
for (a = 0; a < i; ++a)
|
|
976
|
+
if (n[a])
|
|
977
|
+
for (var l = a << 4 | n[a], u = e - n[a], c = s[n[a] - 1]++ << u, _ = c | (1 << u) - 1; c <= _; ++c)
|
|
978
|
+
o[Me[c] >> f] = l;
|
|
979
|
+
} else
|
|
980
|
+
for (o = new X(i), a = 0; a < i; ++a)
|
|
981
|
+
n[a] && (o[a] = Me[s[n[a] - 1]++] >> 15 - n[a]);
|
|
982
|
+
return o;
|
|
983
|
+
}, _e = new v(288);
|
|
984
|
+
for (var w = 0; w < 144; ++w)
|
|
985
|
+
_e[w] = 8;
|
|
986
|
+
for (var w = 144; w < 256; ++w)
|
|
987
|
+
_e[w] = 9;
|
|
988
|
+
for (var w = 256; w < 280; ++w)
|
|
989
|
+
_e[w] = 7;
|
|
990
|
+
for (var w = 280; w < 288; ++w)
|
|
991
|
+
_e[w] = 8;
|
|
992
|
+
var gt = new v(32);
|
|
993
|
+
for (var w = 0; w < 32; ++w)
|
|
994
|
+
gt[w] = 5;
|
|
995
|
+
var Vt = /* @__PURE__ */ ae(_e, 9, 1), zt = /* @__PURE__ */ ae(gt, 5, 1), Te = function(n) {
|
|
996
|
+
for (var e = n[0], t = 1; t < n.length; ++t)
|
|
997
|
+
n[t] > e && (e = n[t]);
|
|
998
|
+
return e;
|
|
999
|
+
}, B = function(n, e, t) {
|
|
1000
|
+
var i = e / 8 | 0;
|
|
1001
|
+
return (n[i] | n[i + 1] << 8) >> (e & 7) & t;
|
|
1002
|
+
}, Ce = function(n, e) {
|
|
1003
|
+
var t = e / 8 | 0;
|
|
1004
|
+
return (n[t] | n[t + 1] << 8 | n[t + 2] << 16) >> (e & 7);
|
|
1005
|
+
}, jt = function(n) {
|
|
1006
|
+
return (n + 7) / 8 | 0;
|
|
1007
|
+
}, Wt = function(n, e, t) {
|
|
1008
|
+
return (t == null || t > n.length) && (t = n.length), new v(n.subarray(e, t));
|
|
1009
|
+
}, Gt = [
|
|
1010
|
+
"unexpected EOF",
|
|
1011
|
+
"invalid block type",
|
|
1012
|
+
"invalid length/literal",
|
|
1013
|
+
"invalid distance",
|
|
1014
|
+
"stream finished",
|
|
1015
|
+
"no stream handler",
|
|
1016
|
+
,
|
|
1017
|
+
"no callback",
|
|
1018
|
+
"invalid UTF-8 data",
|
|
1019
|
+
"extra field too long",
|
|
1020
|
+
"date not in range 1980-2099",
|
|
1021
|
+
"filename too long",
|
|
1022
|
+
"stream finishing",
|
|
1023
|
+
"invalid zip data"
|
|
1024
|
+
// determined by unknown compression method
|
|
1025
|
+
], k = function(n, e, t) {
|
|
1026
|
+
var i = new Error(e || Gt[n]);
|
|
1027
|
+
if (i.code = n, Error.captureStackTrace && Error.captureStackTrace(i, k), !t)
|
|
1028
|
+
throw i;
|
|
1029
|
+
return i;
|
|
1030
|
+
}, Ht = function(n, e, t, i) {
|
|
1031
|
+
var a = n.length, r = 0;
|
|
1032
|
+
if (!a || e.f && !e.l)
|
|
1033
|
+
return t || new v(0);
|
|
1034
|
+
var s = !t, o = s || e.i != 2, f = e.i;
|
|
1035
|
+
s && (t = new v(a * 3));
|
|
1036
|
+
var l = function(Xe) {
|
|
1037
|
+
var $e = t.length;
|
|
1038
|
+
if (Xe > $e) {
|
|
1039
|
+
var qe = new v(Math.max($e * 2, Xe));
|
|
1040
|
+
qe.set(t), t = qe;
|
|
1041
|
+
}
|
|
1042
|
+
}, u = e.f || 0, c = e.p || 0, _ = e.b || 0, d = e.l, p = e.d, h = e.m, y = e.n, R = a * 8;
|
|
1043
|
+
do {
|
|
1044
|
+
if (!d) {
|
|
1045
|
+
u = B(n, c, 1);
|
|
1046
|
+
var m = B(n, c + 1, 3);
|
|
1047
|
+
if (c += 3, m)
|
|
1048
|
+
if (m == 1)
|
|
1049
|
+
d = Vt, p = zt, h = 9, y = 5;
|
|
1050
|
+
else if (m == 2) {
|
|
1051
|
+
var T = B(n, c, 31) + 257, A = B(n, c + 10, 15) + 4, C = T + B(n, c + 5, 31) + 1;
|
|
1052
|
+
c += 14;
|
|
1053
|
+
for (var F = new v(C), M = new v(19), U = 0; U < A; ++U)
|
|
1054
|
+
M[Ft[U]] = B(n, c + U * 3, 7);
|
|
1055
|
+
c += A * 3;
|
|
1056
|
+
for (var H = Te(M), de = (1 << H) - 1, Et = ae(M, H, 1), U = 0; U < C; ) {
|
|
1057
|
+
var We = Et[B(n, c, de)];
|
|
1058
|
+
c += We & 15;
|
|
1059
|
+
var g = We >> 4;
|
|
1060
|
+
if (g < 16)
|
|
1061
|
+
F[U++] = g;
|
|
1062
|
+
else {
|
|
1063
|
+
var K = 0, he = 0;
|
|
1064
|
+
for (g == 16 ? (he = 3 + B(n, c, 3), c += 2, K = F[U - 1]) : g == 17 ? (he = 3 + B(n, c, 7), c += 3) : g == 18 && (he = 11 + B(n, c, 127), c += 7); he--; )
|
|
1065
|
+
F[U++] = K;
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
var Ge = F.subarray(0, T), z = F.subarray(T);
|
|
1069
|
+
h = Te(Ge), y = Te(z), d = ae(Ge, h, 1), p = ae(z, y, 1);
|
|
1070
|
+
} else
|
|
1071
|
+
k(1);
|
|
1072
|
+
else {
|
|
1073
|
+
var g = jt(c) + 4, E = n[g - 4] | n[g - 3] << 8, O = g + E;
|
|
1074
|
+
if (O > a) {
|
|
1075
|
+
f && k(0);
|
|
1076
|
+
break;
|
|
1077
|
+
}
|
|
1078
|
+
o && l(_ + E), t.set(n.subarray(g, O), _), e.b = _ += E, e.p = c = O * 8, e.f = u;
|
|
1079
|
+
continue;
|
|
1080
|
+
}
|
|
1081
|
+
if (c > R) {
|
|
1082
|
+
f && k(0);
|
|
1083
|
+
break;
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
o && l(_ + 131072);
|
|
1087
|
+
for (var Nt = (1 << h) - 1, Ot = (1 << y) - 1, be = c; ; be = c) {
|
|
1088
|
+
var K = d[Ce(n, c) & Nt], Y = K >> 4;
|
|
1089
|
+
if (c += K & 15, c > R) {
|
|
1090
|
+
f && k(0);
|
|
1091
|
+
break;
|
|
1092
|
+
}
|
|
1093
|
+
if (K || k(2), Y < 256)
|
|
1094
|
+
t[_++] = Y;
|
|
1095
|
+
else if (Y == 256) {
|
|
1096
|
+
be = c, d = null;
|
|
1097
|
+
break;
|
|
1098
|
+
} else {
|
|
1099
|
+
var He = Y - 254;
|
|
1100
|
+
if (Y > 264) {
|
|
1101
|
+
var U = Y - 257, q = dt[U];
|
|
1102
|
+
He = B(n, c, (1 << q) - 1) + Rt[U], c += q;
|
|
1103
|
+
}
|
|
1104
|
+
var Ue = p[Ce(n, c) & Ot], Ae = Ue >> 4;
|
|
1105
|
+
Ue || k(3), c += Ue & 15;
|
|
1106
|
+
var z = Pt[Ae];
|
|
1107
|
+
if (Ae > 3) {
|
|
1108
|
+
var q = ht[Ae];
|
|
1109
|
+
z += Ce(n, c) & (1 << q) - 1, c += q;
|
|
1110
|
+
}
|
|
1111
|
+
if (c > R) {
|
|
1112
|
+
f && k(0);
|
|
1113
|
+
break;
|
|
1114
|
+
}
|
|
1115
|
+
o && l(_ + 131072);
|
|
1116
|
+
var Ke = _ + He;
|
|
1117
|
+
if (_ < z) {
|
|
1118
|
+
var Ye = r - z, St = Math.min(z, Ke);
|
|
1119
|
+
for (Ye + _ < 0 && k(3); _ < St; ++_)
|
|
1120
|
+
t[_] = i[Ye + _];
|
|
1121
|
+
}
|
|
1122
|
+
for (; _ < Ke; ++_)
|
|
1123
|
+
t[_] = t[_ - z];
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
e.l = d, e.p = be, e.b = _, e.f = u, d && (u = 1, e.m = h, e.d = p, e.n = y);
|
|
1127
|
+
} while (!u);
|
|
1128
|
+
return _ != t.length && s ? Wt(t, 0, _) : t.subarray(0, _);
|
|
1129
|
+
}, Kt = /* @__PURE__ */ new v(0), Yt = function(n) {
|
|
1130
|
+
(n[0] != 31 || n[1] != 139 || n[2] != 8) && k(6, "invalid gzip data");
|
|
1131
|
+
var e = n[3], t = 10;
|
|
1132
|
+
e & 4 && (t += (n[10] | n[11] << 8) + 2);
|
|
1133
|
+
for (var i = (e >> 3 & 1) + (e >> 4 & 1); i > 0; i -= !n[t++])
|
|
1134
|
+
;
|
|
1135
|
+
return t + (e & 2);
|
|
1136
|
+
}, Xt = function(n) {
|
|
1137
|
+
var e = n.length;
|
|
1138
|
+
return (n[e - 4] | n[e - 3] << 8 | n[e - 2] << 16 | n[e - 1] << 24) >>> 0;
|
|
1139
|
+
};
|
|
1140
|
+
function $t(n, e) {
|
|
1141
|
+
var t = Yt(n);
|
|
1142
|
+
return t + 8 > n.length && k(6, "invalid gzip data"), Ht(n.subarray(t, -8), { i: 2 }, new v(Xt(n)), e);
|
|
1143
|
+
}
|
|
1144
|
+
var qt = typeof TextDecoder < "u" && /* @__PURE__ */ new TextDecoder(), Jt = 0;
|
|
1145
|
+
try {
|
|
1146
|
+
qt.decode(Kt, { stream: !0 }), Jt = 1;
|
|
1147
|
+
} catch {
|
|
1148
|
+
}
|
|
1149
|
+
class tt {
|
|
1150
|
+
buffer;
|
|
1151
|
+
onMessage;
|
|
1152
|
+
constructor(e) {
|
|
1153
|
+
this.onMessage = e, this.buffer = new Uint8Array();
|
|
1154
|
+
}
|
|
1155
|
+
push(e) {
|
|
1156
|
+
this.buffer = Qt(this.buffer, e);
|
|
1157
|
+
let t = 0;
|
|
1158
|
+
for (; t < this.buffer.length; )
|
|
1159
|
+
try {
|
|
1160
|
+
const { value: i, nextOffset: a } = we(this.buffer, t);
|
|
1161
|
+
t = a, this.onMessage(i);
|
|
1162
|
+
} catch (i) {
|
|
1163
|
+
if (i.incomplete) break;
|
|
1164
|
+
throw i;
|
|
1165
|
+
}
|
|
1166
|
+
t > 0 && (this.buffer = this.buffer.slice(t));
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
function Qt(n, e) {
|
|
1170
|
+
const t = new Uint8Array(n.length + e.length);
|
|
1171
|
+
return t.set(n, 0), t.set(e, n.length), t;
|
|
1172
|
+
}
|
|
1173
|
+
function V() {
|
|
1174
|
+
const n = new Error("incomplete msgpack buffer");
|
|
1175
|
+
return n.incomplete = !0, n;
|
|
1176
|
+
}
|
|
1177
|
+
function we(n, e) {
|
|
1178
|
+
if (e >= n.length) throw V();
|
|
1179
|
+
const t = n[e];
|
|
1180
|
+
if (t <= 127) return { value: t, nextOffset: e + 1 };
|
|
1181
|
+
if (t >= 128 && t <= 143) return Be(n, e, t & 15, 1);
|
|
1182
|
+
if (t >= 144 && t <= 159) return Ie(n, e, t & 15, 1);
|
|
1183
|
+
if (t >= 160 && t <= 191) return pe(n, e, t & 31, 1);
|
|
1184
|
+
if (t >= 224) return { value: t - 256, nextOffset: e + 1 };
|
|
1185
|
+
switch (t) {
|
|
1186
|
+
case 192:
|
|
1187
|
+
return { value: null, nextOffset: e + 1 };
|
|
1188
|
+
case 194:
|
|
1189
|
+
return { value: !1, nextOffset: e + 1 };
|
|
1190
|
+
case 195:
|
|
1191
|
+
return { value: !0, nextOffset: e + 1 };
|
|
1192
|
+
case 199:
|
|
1193
|
+
return ke(n, e, Fe(n, e + 1, 1), 3);
|
|
1194
|
+
case 200:
|
|
1195
|
+
return ke(n, e, Fe(n, e + 1, 2), 4);
|
|
1196
|
+
case 201:
|
|
1197
|
+
return ke(n, e, Fe(n, e + 1, 4), 6);
|
|
1198
|
+
case 204:
|
|
1199
|
+
return ye(n, e, 1, !1);
|
|
1200
|
+
case 205:
|
|
1201
|
+
return ye(n, e, 2, !1);
|
|
1202
|
+
case 206:
|
|
1203
|
+
return ye(n, e, 4, !1);
|
|
1204
|
+
case 207:
|
|
1205
|
+
return ye(n, e, 8, !0);
|
|
1206
|
+
case 208:
|
|
1207
|
+
return Re(n, e, 1);
|
|
1208
|
+
case 209:
|
|
1209
|
+
return Re(n, e, 2);
|
|
1210
|
+
case 210:
|
|
1211
|
+
return Re(n, e, 4);
|
|
1212
|
+
case 211:
|
|
1213
|
+
return Re(n, e, 8);
|
|
1214
|
+
case 212:
|
|
1215
|
+
return Q(n, e, 1);
|
|
1216
|
+
case 213:
|
|
1217
|
+
return Q(n, e, 2);
|
|
1218
|
+
case 214:
|
|
1219
|
+
return Q(n, e, 4);
|
|
1220
|
+
case 215:
|
|
1221
|
+
return Q(n, e, 8);
|
|
1222
|
+
case 216:
|
|
1223
|
+
return Q(n, e, 16);
|
|
1224
|
+
case 217:
|
|
1225
|
+
return pe(n, e, n[e + 1], 2);
|
|
1226
|
+
case 218:
|
|
1227
|
+
return pe(n, e, ne(n, e + 1), 3);
|
|
1228
|
+
case 219:
|
|
1229
|
+
return pe(n, e, re(n, e + 1), 5);
|
|
1230
|
+
case 220:
|
|
1231
|
+
return Ie(n, e, ne(n, e + 1), 3);
|
|
1232
|
+
case 221:
|
|
1233
|
+
return Ie(n, e, re(n, e + 1), 5);
|
|
1234
|
+
case 222:
|
|
1235
|
+
return Be(n, e, ne(n, e + 1), 3);
|
|
1236
|
+
case 223:
|
|
1237
|
+
return Be(n, e, re(n, e + 1), 5);
|
|
1238
|
+
case 196:
|
|
1239
|
+
return xe(n, e, n[e + 1], 2);
|
|
1240
|
+
case 197:
|
|
1241
|
+
return xe(n, e, ne(n, e + 1), 3);
|
|
1242
|
+
case 198:
|
|
1243
|
+
return xe(n, e, re(n, e + 1), 5);
|
|
1244
|
+
case 203:
|
|
1245
|
+
return Zt(n, e, 8);
|
|
1246
|
+
default:
|
|
1247
|
+
throw new Error(`Unsupported msgpack type: 0x${t.toString(16)}`);
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
function xe(n, e, t, i) {
|
|
1251
|
+
const a = e + i, r = a + t;
|
|
1252
|
+
if (r > n.length) throw V();
|
|
1253
|
+
return { value: n.slice(a, r), nextOffset: r };
|
|
1254
|
+
}
|
|
1255
|
+
function pe(n, e, t, i) {
|
|
1256
|
+
const a = e + i, r = a + t;
|
|
1257
|
+
if (r > n.length) throw V();
|
|
1258
|
+
return { value: new TextDecoder().decode(n.slice(a, r)), nextOffset: r };
|
|
1259
|
+
}
|
|
1260
|
+
function Ie(n, e, t, i) {
|
|
1261
|
+
let a = e + i;
|
|
1262
|
+
const r = [];
|
|
1263
|
+
for (let s = 0; s < t; s += 1) {
|
|
1264
|
+
const { value: o, nextOffset: f } = we(n, a);
|
|
1265
|
+
r.push(o), a = f;
|
|
1266
|
+
}
|
|
1267
|
+
return { value: r, nextOffset: a };
|
|
1268
|
+
}
|
|
1269
|
+
function Be(n, e, t, i) {
|
|
1270
|
+
let a = e + i;
|
|
1271
|
+
const r = {};
|
|
1272
|
+
for (let s = 0; s < t; s += 1) {
|
|
1273
|
+
const o = we(n, a), f = we(n, o.nextOffset);
|
|
1274
|
+
r[String(o.value)] = f.value, a = f.nextOffset;
|
|
1275
|
+
}
|
|
1276
|
+
return { value: r, nextOffset: a };
|
|
1277
|
+
}
|
|
1278
|
+
function Q(n, e, t) {
|
|
1279
|
+
const i = e + 2, a = i + t;
|
|
1280
|
+
if (a > n.length) throw V();
|
|
1281
|
+
const r = n.slice(i, a);
|
|
1282
|
+
return { value: { type: n[e + 1], data: r }, nextOffset: a };
|
|
1283
|
+
}
|
|
1284
|
+
function ke(n, e, t, i) {
|
|
1285
|
+
const a = n[e + i - 1], r = e + i, s = r + t;
|
|
1286
|
+
if (s > n.length) throw V();
|
|
1287
|
+
const o = n.slice(r, s);
|
|
1288
|
+
return { value: { type: a, data: o }, nextOffset: s };
|
|
1289
|
+
}
|
|
1290
|
+
function ye(n, e, t, i) {
|
|
1291
|
+
const a = e + 1, r = a + t;
|
|
1292
|
+
if (r > n.length) throw V();
|
|
1293
|
+
const s = new DataView(n.slice(a, r).buffer);
|
|
1294
|
+
let o;
|
|
1295
|
+
return t === 1 ? o = s.getUint8(0) : t === 2 ? o = s.getUint16(0) : t === 4 ? o = s.getUint32(0) : o = s.getBigUint64(0), { value: i ? o : Number(o), nextOffset: r };
|
|
1296
|
+
}
|
|
1297
|
+
function Re(n, e, t) {
|
|
1298
|
+
const i = e + 1, a = i + t;
|
|
1299
|
+
if (a > n.length) throw V();
|
|
1300
|
+
const r = new DataView(n.slice(i, a).buffer);
|
|
1301
|
+
let s;
|
|
1302
|
+
return t === 1 ? s = r.getInt8(0) : t === 2 ? s = r.getInt16(0) : t === 4 ? s = r.getInt32(0) : s = r.getBigInt64(0), { value: Number(s), nextOffset: a };
|
|
1303
|
+
}
|
|
1304
|
+
function Zt(n, e, t) {
|
|
1305
|
+
const i = e + 1, a = i + t;
|
|
1306
|
+
if (a > n.length) throw V();
|
|
1307
|
+
const r = new DataView(n.slice(i, a).buffer);
|
|
1308
|
+
return { value: t === 4 ? r.getFloat32(0) : r.getFloat64(0), nextOffset: a };
|
|
1309
|
+
}
|
|
1310
|
+
function Fe(n, e, t) {
|
|
1311
|
+
const i = e;
|
|
1312
|
+
if (i + t > n.length) throw V();
|
|
1313
|
+
return t === 1 ? n[i] : t === 2 ? ne(n, i) : re(n, i);
|
|
1314
|
+
}
|
|
1315
|
+
function ne(n, e) {
|
|
1316
|
+
return n[e] << 8 | n[e + 1];
|
|
1317
|
+
}
|
|
1318
|
+
function re(n, e) {
|
|
1319
|
+
return n[e] * 16777216 + (n[e + 1] << 16 | n[e + 2] << 8 | n[e + 3]);
|
|
1320
|
+
}
|
|
1321
|
+
let se = null, x = null, N = null, S = null, ce = null, L = null, ie = null, P = 0, me = 0, Ee = 0;
|
|
1322
|
+
const en = new TextDecoder();
|
|
1323
|
+
let oe = "", Ne = !1, Z = null, ee = null;
|
|
1324
|
+
const Pe = [];
|
|
1325
|
+
self.addEventListener("error", (n) => {
|
|
1326
|
+
if (Ne) return;
|
|
1327
|
+
Ne = !0;
|
|
1328
|
+
const e = n.message || String(n.error || "worker error"), t = n.error?.stack;
|
|
10
1329
|
try {
|
|
11
|
-
postMessage({ type: "start-error", message:
|
|
12
|
-
${
|
|
1330
|
+
postMessage({ type: "start-error", message: t ? `${e}
|
|
1331
|
+
${t}` : e }), postMessage({ type: "exit", code: 1, lastStderr: oe });
|
|
13
1332
|
} catch {
|
|
14
1333
|
}
|
|
15
1334
|
});
|
|
16
|
-
self.addEventListener("unhandledrejection", (
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
const e =
|
|
1335
|
+
self.addEventListener("unhandledrejection", (n) => {
|
|
1336
|
+
if (Ne) return;
|
|
1337
|
+
Ne = !0;
|
|
1338
|
+
const e = n.reason, t = e && (e.message || String(e)) || "unhandled rejection", i = e?.stack;
|
|
20
1339
|
try {
|
|
21
|
-
postMessage({ type: "start-error", message:
|
|
22
|
-
${
|
|
1340
|
+
postMessage({ type: "start-error", message: i ? `${t}
|
|
1341
|
+
${i}` : t }), postMessage({ type: "exit", code: 1, lastStderr: oe });
|
|
23
1342
|
} catch {
|
|
24
1343
|
}
|
|
25
1344
|
});
|
|
26
|
-
self.onmessage = (
|
|
27
|
-
const { type: e } =
|
|
1345
|
+
self.onmessage = (n) => {
|
|
1346
|
+
const { type: e } = n.data || {};
|
|
28
1347
|
if (e === "start")
|
|
29
|
-
|
|
30
|
-
postMessage({ type: "start-error", message:
|
|
1348
|
+
nn(n.data).catch((t) => {
|
|
1349
|
+
postMessage({ type: "start-error", message: t?.message || String(t) }), postMessage({ type: "exit", code: 1 });
|
|
31
1350
|
});
|
|
32
1351
|
else if (e === "stdin") {
|
|
33
|
-
const
|
|
34
|
-
if (!
|
|
35
|
-
|
|
1352
|
+
const t = wt(n.data?.chunk);
|
|
1353
|
+
if (!t?.byteLength) return;
|
|
1354
|
+
N ? N.push(t) : Pe.push(t);
|
|
36
1355
|
} else if (e === "stop") {
|
|
37
1356
|
try {
|
|
38
|
-
|
|
1357
|
+
N?.close();
|
|
39
1358
|
} catch {
|
|
40
1359
|
}
|
|
41
1360
|
try {
|
|
42
|
-
|
|
1361
|
+
x?.wasiImport?.proc_exit?.(0);
|
|
43
1362
|
} catch {
|
|
44
1363
|
}
|
|
45
|
-
|
|
1364
|
+
N = null;
|
|
46
1365
|
}
|
|
47
1366
|
};
|
|
48
|
-
class
|
|
1367
|
+
class tn extends Se {
|
|
49
1368
|
chunks = [];
|
|
50
1369
|
total = 0;
|
|
51
1370
|
waiters = [];
|
|
52
1371
|
closed = !1;
|
|
53
1372
|
fd_fdstat_get() {
|
|
54
|
-
const e = new
|
|
55
|
-
return e.fs_rights_base = BigInt(
|
|
1373
|
+
const e = new Oe($, 0);
|
|
1374
|
+
return e.fs_rights_base = BigInt(66), { ret: 0, fdstat: e };
|
|
56
1375
|
}
|
|
57
1376
|
fd_close() {
|
|
58
|
-
return this.close(),
|
|
1377
|
+
return this.close(), 0;
|
|
59
1378
|
}
|
|
60
1379
|
close() {
|
|
61
1380
|
if (this.closed) return;
|
|
62
1381
|
this.closed = !0;
|
|
63
1382
|
const e = this.waiters;
|
|
64
1383
|
this.waiters = [];
|
|
65
|
-
for (const
|
|
1384
|
+
for (const t of e) t();
|
|
66
1385
|
}
|
|
67
1386
|
push(e) {
|
|
68
1387
|
if (this.closed || !e?.byteLength) return;
|
|
69
1388
|
this.chunks.push(e), this.total += e.byteLength;
|
|
70
|
-
const
|
|
1389
|
+
const t = this.waiters;
|
|
71
1390
|
this.waiters = [];
|
|
72
|
-
for (const
|
|
1391
|
+
for (const i of t) i();
|
|
73
1392
|
}
|
|
74
1393
|
waitForData() {
|
|
75
1394
|
return this.closed || this.total > 0 ? Promise.resolve() : new Promise((e) => this.waiters.push(e));
|
|
76
1395
|
}
|
|
77
1396
|
fd_read(e) {
|
|
78
|
-
if (this.closed && this.total === 0) return { ret:
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
81
|
-
const
|
|
82
|
-
let
|
|
83
|
-
for (;
|
|
84
|
-
const
|
|
85
|
-
|
|
1397
|
+
if (this.closed && this.total === 0) return { ret: 0, data: new Uint8Array() };
|
|
1398
|
+
const t = Math.min(Math.max(0, Number(e) || 0), this.total);
|
|
1399
|
+
if (t === 0) return { ret: 6, data: new Uint8Array() };
|
|
1400
|
+
const i = new Uint8Array(t);
|
|
1401
|
+
let a = 0;
|
|
1402
|
+
for (; a < t && this.chunks.length; ) {
|
|
1403
|
+
const r = this.chunks[0], s = Math.min(r.byteLength, t - a);
|
|
1404
|
+
i.set(r.subarray(0, s), a), a += s, s === r.byteLength ? this.chunks.shift() : this.chunks[0] = r.subarray(s);
|
|
86
1405
|
}
|
|
87
|
-
return this.total -=
|
|
1406
|
+
return this.total -= a, { ret: 0, data: i };
|
|
88
1407
|
}
|
|
89
1408
|
fd_write() {
|
|
90
|
-
return { ret:
|
|
1409
|
+
return { ret: 8, nwritten: 0 };
|
|
91
1410
|
}
|
|
92
1411
|
fd_seek() {
|
|
93
|
-
return { ret:
|
|
1412
|
+
return { ret: 8, offset: 0n };
|
|
94
1413
|
}
|
|
95
1414
|
fd_tell() {
|
|
96
|
-
return { ret:
|
|
1415
|
+
return { ret: 8, offset: 0n };
|
|
97
1416
|
}
|
|
98
1417
|
fd_pread() {
|
|
99
|
-
return { ret:
|
|
1418
|
+
return { ret: 8, data: new Uint8Array() };
|
|
100
1419
|
}
|
|
101
1420
|
fd_pwrite() {
|
|
102
|
-
return { ret:
|
|
1421
|
+
return { ret: 8, nwritten: 0 };
|
|
103
1422
|
}
|
|
104
1423
|
}
|
|
105
|
-
class
|
|
1424
|
+
class nt extends Se {
|
|
106
1425
|
onWrite;
|
|
107
1426
|
constructor(e) {
|
|
108
1427
|
super(), this.onWrite = e;
|
|
109
1428
|
}
|
|
110
1429
|
fd_fdstat_get() {
|
|
111
|
-
const e = new
|
|
112
|
-
return e.fs_rights_base = BigInt(
|
|
1430
|
+
const e = new Oe($, 0);
|
|
1431
|
+
return e.fs_rights_base = BigInt(64), { ret: 0, fdstat: e };
|
|
113
1432
|
}
|
|
114
1433
|
fd_write(e) {
|
|
115
|
-
return this.onWrite(new Uint8Array(e)), { ret:
|
|
1434
|
+
return this.onWrite(new Uint8Array(e)), { ret: 0, nwritten: e.byteLength };
|
|
116
1435
|
}
|
|
117
1436
|
fd_close() {
|
|
118
|
-
return
|
|
1437
|
+
return 0;
|
|
119
1438
|
}
|
|
120
1439
|
}
|
|
121
|
-
async function
|
|
122
|
-
let
|
|
1440
|
+
async function nn({ cols: n, rows: e, wasmPath: t, runtimePath: i, env: a, files: r }) {
|
|
1441
|
+
let s = 1;
|
|
123
1442
|
try {
|
|
124
|
-
for (
|
|
125
|
-
const
|
|
1443
|
+
for (se = null, ie = null, ce = null, L = null, S = null, N = new tn(); Pe.length; ) N.push(Pe.shift());
|
|
1444
|
+
const o = await ln(t), f = await cn(i), l = pn(f, () => {
|
|
126
1445
|
});
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
}),
|
|
1446
|
+
r && Array.isArray(r) && r.length && un(l, r);
|
|
1447
|
+
const u = new nt(_n), c = new nt((A) => {
|
|
1448
|
+
const C = en.decode(A);
|
|
1449
|
+
C && (oe = (oe + C).slice(-8192)), postMessage({ type: "stderr", message: C });
|
|
1450
|
+
}), _ = new it("nvim", l.contents), p = l.contents.get("tmp")?.contents || /* @__PURE__ */ new Map(), h = new it("tmp", p), y = ["nvim", "--headless", "--embed", "-u", "NORC", "--noplugin", "-i", "NONE", "-n"], R = [
|
|
132
1451
|
"VIMRUNTIME=/nvim/runtime",
|
|
133
1452
|
"HOME=/nvim/home",
|
|
134
1453
|
"PWD=/nvim",
|
|
@@ -137,277 +1456,277 @@ async function Dt({ cols: t, rows: e, wasmPath: n, runtimePath: s, env: r, files
|
|
|
137
1456
|
"XDG_STATE_HOME=/nvim/home/.local/state",
|
|
138
1457
|
"PATH=/usr/bin:/bin",
|
|
139
1458
|
"TMPDIR=/nvim/tmp",
|
|
140
|
-
`COLUMNS=${
|
|
1459
|
+
`COLUMNS=${n || 120}`,
|
|
141
1460
|
`LINES=${e || 40}`
|
|
142
1461
|
];
|
|
143
|
-
if (
|
|
144
|
-
for (const [
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const m =
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
wasi_snapshot_preview1:
|
|
1462
|
+
if (a && typeof a == "object")
|
|
1463
|
+
for (const [A, C] of Object.entries(a))
|
|
1464
|
+
A && R.push(`${A}=${String(C ?? "")}`);
|
|
1465
|
+
x = new It(y, R, [N, u, c, _, h], { debug: !1 }), x.fds[0] = N, x.fds[1] = u, x.fds[2] = c, x.fds[3] = _, x.fds[4] = h, x.preopens = { "/nvim": _, "/tmp": h };
|
|
1466
|
+
const m = yn(() => x?.wasiImport?.proc_exit?.(1)), g = { ...x.wasiImport };
|
|
1467
|
+
g.fd_read = x.wasiImport.fd_read, g.poll_oneoff = (A, C, F, M) => rn(A, C, F, M);
|
|
1468
|
+
const E = await WebAssembly.instantiate(o, {
|
|
1469
|
+
wasi_snapshot_preview1: g,
|
|
151
1470
|
env: m
|
|
152
|
-
}),
|
|
153
|
-
|
|
154
|
-
} catch (
|
|
155
|
-
if (
|
|
156
|
-
|
|
1471
|
+
}), T = E.instance ?? E.instance;
|
|
1472
|
+
S = T.exports, an(S), x.inst = T, s = await fn(S);
|
|
1473
|
+
} catch (o) {
|
|
1474
|
+
if (o instanceof ge)
|
|
1475
|
+
s = o.code;
|
|
157
1476
|
else {
|
|
158
|
-
const
|
|
159
|
-
postMessage({ type: "start-error", message:
|
|
160
|
-
${
|
|
1477
|
+
const f = o?.message || String(o), l = o?.stack;
|
|
1478
|
+
postMessage({ type: "start-error", message: l ? `${f}
|
|
1479
|
+
${l}` : f });
|
|
161
1480
|
}
|
|
162
1481
|
}
|
|
163
|
-
postMessage({ type: "exit", code:
|
|
164
|
-
}
|
|
165
|
-
function
|
|
166
|
-
if (!
|
|
167
|
-
const
|
|
168
|
-
if (
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
const
|
|
172
|
-
let
|
|
173
|
-
const
|
|
174
|
-
for (let m = 0; m <
|
|
175
|
-
const
|
|
176
|
-
if (
|
|
177
|
-
const
|
|
178
|
-
if (
|
|
179
|
-
|
|
1482
|
+
postMessage({ type: "exit", code: s, lastStderr: oe });
|
|
1483
|
+
}
|
|
1484
|
+
function rn(n, e, t, i) {
|
|
1485
|
+
if (!S?.memory) return 21;
|
|
1486
|
+
const a = Number(t) >>> 0;
|
|
1487
|
+
if (a === 0) return 28;
|
|
1488
|
+
const r = S?.asyncify_get_state?.() ?? 0;
|
|
1489
|
+
r === 0 && L && (L = null);
|
|
1490
|
+
const s = new DataView(S.memory.buffer), o = 48, f = 32, l = () => BigInt(Math.round(performance.now() * 1e6)), u = () => BigInt(Date.now()) * 1000000n;
|
|
1491
|
+
let c = !1, _ = null;
|
|
1492
|
+
const d = [], p = new Array(a).fill(null), h = r === 2 && L && L.in_ptr === n >>> 0 && L.nsubscriptions === a;
|
|
1493
|
+
for (let m = 0; m < a; m += 1) {
|
|
1494
|
+
const g = n + m * o >>> 0, E = s.getBigUint64(g, !0), O = s.getUint8(g + 8);
|
|
1495
|
+
if (O === vt || O === Ze) {
|
|
1496
|
+
const T = s.getUint32(g + 16, !0);
|
|
1497
|
+
if (O === Ze) {
|
|
1498
|
+
d.push({ userdata: E, eventtype: O });
|
|
180
1499
|
continue;
|
|
181
1500
|
}
|
|
182
|
-
if (
|
|
183
|
-
!!(
|
|
1501
|
+
if (T === 0) {
|
|
1502
|
+
!!(N && (N.total > 0 || N.closed)) ? d.push({ userdata: E, eventtype: O }) : c = !0;
|
|
184
1503
|
continue;
|
|
185
1504
|
}
|
|
186
|
-
|
|
1505
|
+
d.push({ userdata: E, eventtype: O });
|
|
187
1506
|
continue;
|
|
188
1507
|
}
|
|
189
|
-
if (
|
|
190
|
-
const
|
|
191
|
-
if (!
|
|
192
|
-
const
|
|
193
|
-
if (
|
|
194
|
-
|
|
1508
|
+
if (O === ft) {
|
|
1509
|
+
const T = s.getUint32(g + 16, !0), A = s.getBigUint64(g + 24, !0), C = s.getUint16(g + 36, !0), F = T === 1 ? l : T === 0 ? u : null;
|
|
1510
|
+
if (!F) return 28;
|
|
1511
|
+
const M = F(), U = (C & lt) !== 0, H = h && L?.clockDeadlines?.[m] != null ? BigInt(L.clockDeadlines[m]) : U ? A : M + A;
|
|
1512
|
+
if (p[m] = H, H <= M)
|
|
1513
|
+
d.push({ userdata: E, eventtype: O });
|
|
195
1514
|
else {
|
|
196
|
-
const
|
|
197
|
-
(
|
|
1515
|
+
const de = H - M;
|
|
1516
|
+
(_ === null || de < _) && (_ = de);
|
|
198
1517
|
}
|
|
199
1518
|
continue;
|
|
200
1519
|
}
|
|
201
|
-
return
|
|
202
|
-
}
|
|
203
|
-
if (
|
|
204
|
-
|
|
205
|
-
const m = new DataView(
|
|
206
|
-
for (let
|
|
207
|
-
const
|
|
208
|
-
new
|
|
1520
|
+
return 58;
|
|
1521
|
+
}
|
|
1522
|
+
if (d.length > 0) {
|
|
1523
|
+
r === 2 && rt(), L = null;
|
|
1524
|
+
const m = new DataView(S.memory.buffer), g = Math.min(d.length, a);
|
|
1525
|
+
for (let E = 0; E < g; E += 1) {
|
|
1526
|
+
const O = d[E];
|
|
1527
|
+
new ct(O.userdata, 0, O.eventtype).write_bytes(m, e + E * f >>> 0);
|
|
209
1528
|
}
|
|
210
|
-
return typeof
|
|
1529
|
+
return typeof i == "number" && m.setUint32(i, g, !0), 0;
|
|
211
1530
|
}
|
|
212
|
-
const
|
|
213
|
-
if ((
|
|
214
|
-
const
|
|
215
|
-
|
|
1531
|
+
const y = [], R = !!(N && !N.closed && N.total === 0);
|
|
1532
|
+
if ((c || R) && N && !N.closed && y.push(sn()), _ !== null) {
|
|
1533
|
+
const g = Number(_ / 1000000n), E = Number.isFinite(g) && g > 0 ? g : 0;
|
|
1534
|
+
y.push(new Promise((O) => setTimeout(O, Math.min(E, 50))));
|
|
216
1535
|
}
|
|
217
|
-
return
|
|
1536
|
+
return y.length === 0 ? (typeof i == "number" && s.setUint32(i, 0, !0), 0) : (r === 2 && rt(), r === 0 || r === 2 ? (L = { in_ptr: n >>> 0, nsubscriptions: a, clockDeadlines: p }, on(y.length === 1 ? y[0] : Promise.race(y)), typeof i == "number" && new DataView(S.memory.buffer).setUint32(i, 0, !0), 0) : (typeof i == "number" && s.setUint32(i, 0, !0), 0));
|
|
218
1537
|
}
|
|
219
|
-
function
|
|
220
|
-
return !
|
|
221
|
-
|
|
222
|
-
})),
|
|
1538
|
+
function sn() {
|
|
1539
|
+
return !N || N.closed || N.total > 0 ? Promise.resolve() : (ie || (ie = N.waitForData().finally(() => {
|
|
1540
|
+
ie = null;
|
|
1541
|
+
})), ie);
|
|
223
1542
|
}
|
|
224
|
-
function
|
|
225
|
-
if (!
|
|
226
|
-
if (typeof
|
|
227
|
-
if (typeof
|
|
228
|
-
|
|
1543
|
+
function an(n) {
|
|
1544
|
+
if (!n?.memory) throw new Error("asyncify: missing exported memory");
|
|
1545
|
+
if (typeof n.asyncify_start_unwind != "function") throw new Error("asyncify: missing exports");
|
|
1546
|
+
if (typeof n.nvim_asyncify_get_data_ptr == "function" && typeof n.nvim_asyncify_get_stack_start == "function" && typeof n.nvim_asyncify_get_stack_end == "function") {
|
|
1547
|
+
P = n.nvim_asyncify_get_data_ptr() >>> 0, me = n.nvim_asyncify_get_stack_start() >>> 0, Ee = n.nvim_asyncify_get_stack_end() >>> 0, ue();
|
|
229
1548
|
return;
|
|
230
1549
|
}
|
|
231
|
-
const e = 64 * 1024 * 1024,
|
|
232
|
-
|
|
233
|
-
const
|
|
234
|
-
|
|
1550
|
+
const e = 64 * 1024 * 1024, t = 65536, i = e + 64, a = Math.ceil(i / t);
|
|
1551
|
+
n.memory.grow(a);
|
|
1552
|
+
const r = n.memory.buffer.byteLength >>> 0;
|
|
1553
|
+
Ee = r, P = ((r - e >>> 0) - 8 & -8) >>> 0, me = P + 8 >>> 0, ue();
|
|
235
1554
|
}
|
|
236
|
-
function
|
|
237
|
-
if (!
|
|
238
|
-
const
|
|
239
|
-
|
|
1555
|
+
function ue() {
|
|
1556
|
+
if (!S?.memory || !P || !me || !Ee) return;
|
|
1557
|
+
const n = new DataView(S.memory.buffer);
|
|
1558
|
+
n.setInt32(P, me, !0), n.setInt32(P + 4, Ee, !0);
|
|
240
1559
|
}
|
|
241
|
-
function
|
|
242
|
-
if (!
|
|
243
|
-
if (
|
|
244
|
-
|
|
1560
|
+
function on(n) {
|
|
1561
|
+
if (!S || !P) throw new Error("asyncify: not initialized");
|
|
1562
|
+
if (ce) throw new Error("asyncify: overlapping async operation");
|
|
1563
|
+
ue(), ce = n, S.asyncify_start_unwind(P);
|
|
245
1564
|
}
|
|
246
|
-
function
|
|
247
|
-
!
|
|
1565
|
+
function rt() {
|
|
1566
|
+
!S?.asyncify_get_state || !S?.asyncify_stop_rewind || S.asyncify_get_state() === 2 && (S.asyncify_stop_rewind(), ue());
|
|
248
1567
|
}
|
|
249
|
-
async function
|
|
1568
|
+
async function fn(n) {
|
|
250
1569
|
for (; ; ) {
|
|
251
1570
|
try {
|
|
252
|
-
|
|
253
|
-
} catch (
|
|
254
|
-
if (
|
|
255
|
-
throw
|
|
1571
|
+
n._start();
|
|
1572
|
+
} catch (i) {
|
|
1573
|
+
if (i instanceof ge) return i.code;
|
|
1574
|
+
throw i;
|
|
256
1575
|
}
|
|
257
|
-
const e =
|
|
1576
|
+
const e = n.asyncify_get_state();
|
|
258
1577
|
if (e === 0) return 0;
|
|
259
1578
|
if (e === 2) {
|
|
260
|
-
|
|
1579
|
+
n.asyncify_stop_rewind(), ue();
|
|
261
1580
|
continue;
|
|
262
1581
|
}
|
|
263
1582
|
if (e !== 1) throw new Error(`asyncify: unexpected state ${e}`);
|
|
264
|
-
|
|
265
|
-
const
|
|
266
|
-
if (
|
|
267
|
-
await
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
async function
|
|
271
|
-
if (
|
|
272
|
-
const e = await
|
|
273
|
-
return
|
|
274
|
-
}
|
|
275
|
-
async function
|
|
276
|
-
if (
|
|
277
|
-
const e = await
|
|
278
|
-
let
|
|
279
|
-
if (
|
|
1583
|
+
n.asyncify_stop_unwind();
|
|
1584
|
+
const t = ce;
|
|
1585
|
+
if (ce = null, !t) throw new Error("asyncify: missing pending promise");
|
|
1586
|
+
await t, n.asyncify_start_rewind(P);
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
async function ln(n) {
|
|
1590
|
+
if (Z && Z.url === n && Z.bytes?.byteLength) return Z.bytes;
|
|
1591
|
+
const e = await mt(n);
|
|
1592
|
+
return Z = { url: n, bytes: e }, e;
|
|
1593
|
+
}
|
|
1594
|
+
async function cn(n) {
|
|
1595
|
+
if (ee && ee.url === n && ee.entries?.length) return ee.entries;
|
|
1596
|
+
const e = await mt(n);
|
|
1597
|
+
let t;
|
|
1598
|
+
if (dn(e))
|
|
280
1599
|
try {
|
|
281
|
-
|
|
282
|
-
} catch (
|
|
283
|
-
throw new Error(`gunzip runtime failed: ${
|
|
1600
|
+
t = $t(e);
|
|
1601
|
+
} catch (a) {
|
|
1602
|
+
throw new Error(`gunzip runtime failed: ${a?.message ?? a}`);
|
|
284
1603
|
}
|
|
285
1604
|
else
|
|
286
|
-
|
|
287
|
-
let
|
|
1605
|
+
t = e;
|
|
1606
|
+
let i;
|
|
288
1607
|
try {
|
|
289
|
-
|
|
290
|
-
} catch (
|
|
291
|
-
throw new Error(`untar runtime failed: ${
|
|
292
|
-
}
|
|
293
|
-
return
|
|
294
|
-
}
|
|
295
|
-
function
|
|
296
|
-
for (const
|
|
297
|
-
const
|
|
298
|
-
if (!
|
|
299
|
-
const
|
|
300
|
-
if (!
|
|
301
|
-
const
|
|
302
|
-
if (!
|
|
303
|
-
let
|
|
304
|
-
for (let
|
|
305
|
-
const
|
|
306
|
-
|
|
1608
|
+
i = hn(t);
|
|
1609
|
+
} catch (a) {
|
|
1610
|
+
throw new Error(`untar runtime failed: ${a?.message ?? a}`);
|
|
1611
|
+
}
|
|
1612
|
+
return ee = { url: n, entries: i }, i;
|
|
1613
|
+
}
|
|
1614
|
+
function un(n, e) {
|
|
1615
|
+
for (const t of e) {
|
|
1616
|
+
const a = String(t?.path ?? "").replace(/^\/+/, "").replace(/^\.\/+/, "");
|
|
1617
|
+
if (!a || a.endsWith("/")) continue;
|
|
1618
|
+
const r = wt(t?.data);
|
|
1619
|
+
if (!r) continue;
|
|
1620
|
+
const s = a.split("/").filter(Boolean);
|
|
1621
|
+
if (!s.length) continue;
|
|
1622
|
+
let o = n;
|
|
1623
|
+
for (let l = 0; l < s.length - 1; l += 1) {
|
|
1624
|
+
const u = s[l];
|
|
1625
|
+
o.contents.has(u) || o.contents.set(u, new D(/* @__PURE__ */ new Map())), o = o.contents.get(u);
|
|
307
1626
|
}
|
|
308
|
-
const
|
|
309
|
-
|
|
1627
|
+
const f = s[s.length - 1];
|
|
1628
|
+
o.contents.set(f, new je(r, { readonly: !1 }));
|
|
310
1629
|
}
|
|
311
1630
|
}
|
|
312
|
-
function
|
|
313
|
-
if (!
|
|
314
|
-
if (
|
|
315
|
-
if (
|
|
316
|
-
if (
|
|
317
|
-
if (Array.isArray(
|
|
318
|
-
if (
|
|
1631
|
+
function wt(n) {
|
|
1632
|
+
if (!n) return new Uint8Array();
|
|
1633
|
+
if (n instanceof Uint8Array) return n;
|
|
1634
|
+
if (n instanceof ArrayBuffer) return new Uint8Array(n);
|
|
1635
|
+
if (n instanceof SharedArrayBuffer) return new Uint8Array(n);
|
|
1636
|
+
if (Array.isArray(n)) return new Uint8Array(n);
|
|
1637
|
+
if (n && n.type === "Buffer" && Array.isArray(n.data)) return new Uint8Array(n.data);
|
|
319
1638
|
try {
|
|
320
|
-
return new TextEncoder().encode(String(
|
|
1639
|
+
return new TextEncoder().encode(String(n));
|
|
321
1640
|
} catch {
|
|
322
1641
|
return null;
|
|
323
1642
|
}
|
|
324
1643
|
}
|
|
325
|
-
function
|
|
326
|
-
|
|
1644
|
+
function _n(n) {
|
|
1645
|
+
se || (se = new tt(st));
|
|
327
1646
|
try {
|
|
328
|
-
|
|
1647
|
+
se.push(n);
|
|
329
1648
|
} catch {
|
|
330
|
-
|
|
1649
|
+
se = new tt(st);
|
|
331
1650
|
}
|
|
332
1651
|
}
|
|
333
|
-
function
|
|
334
|
-
if (!Array.isArray(
|
|
335
|
-
const e =
|
|
1652
|
+
function st(n) {
|
|
1653
|
+
if (!Array.isArray(n) || n.length < 1) return;
|
|
1654
|
+
const e = n[0];
|
|
336
1655
|
if (e === 0) {
|
|
337
|
-
const [,
|
|
338
|
-
postMessage(
|
|
1656
|
+
const [, t, i, a] = n;
|
|
1657
|
+
postMessage(i === "wasm-clipboard-paste" ? { type: "clipboard-paste", msgid: t } : { type: "rpc-request", msgid: t, method: i, params: a });
|
|
339
1658
|
} else if (e === 1) {
|
|
340
|
-
const [,
|
|
341
|
-
postMessage({ type: "rpc-response", msgid:
|
|
1659
|
+
const [, t, i, a] = n;
|
|
1660
|
+
postMessage({ type: "rpc-response", msgid: t, error: i, result: a });
|
|
342
1661
|
} else if (e === 2) {
|
|
343
|
-
const [,
|
|
344
|
-
if (
|
|
345
|
-
const
|
|
346
|
-
postMessage({ type: "clipboard-copy", lines:
|
|
347
|
-
} else (
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
async function
|
|
351
|
-
const e = await fetch(
|
|
352
|
-
if (!e.ok) throw new Error(`fetch ${
|
|
353
|
-
if ((e.headers.get("content-type") || "").toLowerCase().includes("text/html")) throw new Error(`fetch ${
|
|
354
|
-
const
|
|
355
|
-
if (!
|
|
356
|
-
return
|
|
357
|
-
}
|
|
358
|
-
function
|
|
359
|
-
return
|
|
360
|
-
}
|
|
361
|
-
function
|
|
362
|
-
const e = [],
|
|
363
|
-
let
|
|
364
|
-
const
|
|
365
|
-
let
|
|
366
|
-
for (;
|
|
367
|
-
if (
|
|
368
|
-
const
|
|
369
|
-
if (!
|
|
370
|
-
const
|
|
371
|
-
if (!Number.isFinite(
|
|
372
|
-
const
|
|
373
|
-
e.push({ name:
|
|
374
|
-
const
|
|
375
|
-
if (R <=
|
|
376
|
-
|
|
1662
|
+
const [, t, i] = n;
|
|
1663
|
+
if (t === "wasm-clipboard-copy") {
|
|
1664
|
+
const a = Array.isArray(i?.[0]) ? i[0] : [], r = typeof i?.[1] == "string" ? i[1] : "v";
|
|
1665
|
+
postMessage({ type: "clipboard-copy", lines: a, regtype: r });
|
|
1666
|
+
} else (t === "nvim_buf_lines_event" || t === "nvim_buf_detach_event" || t === "redraw" || t === "monaco_cursor" || t === "monaco_mode" || t === "monaco_cursorMove" || t === "monaco_scroll" || t === "monaco_reveal" || t === "monaco_moveCursor" || t === "monaco_scrolloff" || t === "monaco_host_command" || t === "monaco_buf_enter" || t === "monaco_buf_delete") && postMessage({ type: "rpc-notify", method: t, params: i });
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
async function mt(n) {
|
|
1670
|
+
const e = await fetch(n);
|
|
1671
|
+
if (!e.ok) throw new Error(`fetch ${n} failed (${e.status})`);
|
|
1672
|
+
if ((e.headers.get("content-type") || "").toLowerCase().includes("text/html")) throw new Error(`fetch ${n} returned HTML (likely wrong path or dev server fallback)`);
|
|
1673
|
+
const i = new Uint8Array(await e.arrayBuffer());
|
|
1674
|
+
if (!i.byteLength) throw new Error(`fetch ${n} returned empty body`);
|
|
1675
|
+
return i;
|
|
1676
|
+
}
|
|
1677
|
+
function dn(n) {
|
|
1678
|
+
return n && n.length >= 2 && n[0] === 31 && n[1] === 139;
|
|
1679
|
+
}
|
|
1680
|
+
function hn(n) {
|
|
1681
|
+
const e = [], t = n instanceof Uint8Array ? n : new Uint8Array(n);
|
|
1682
|
+
let i = 0;
|
|
1683
|
+
const a = new TextDecoder();
|
|
1684
|
+
let r = 0;
|
|
1685
|
+
for (; i + 512 <= t.length; ) {
|
|
1686
|
+
if (r++ > 1e5) throw new Error("untar safety break");
|
|
1687
|
+
const s = Le(a, t, i, 100), o = Le(a, t, i + 124, 12), f = t[i + 156], l = Le(a, t, i + 345, 155);
|
|
1688
|
+
if (!s && !l) break;
|
|
1689
|
+
const u = o.trim() || "0", c = parseInt(u, 8);
|
|
1690
|
+
if (!Number.isFinite(c) || c < 0) throw new Error(`invalid tar size: ${u}`);
|
|
1691
|
+
const _ = l ? `${l}/${s}` : s, d = i + 512, p = d + c, h = t.slice(d, p);
|
|
1692
|
+
e.push({ name: _, type: f === 53 ? "dir" : "file", data: h });
|
|
1693
|
+
const y = Math.ceil(c / 512), R = d + y * 512;
|
|
1694
|
+
if (R <= i) throw new Error("tar parse did not advance");
|
|
1695
|
+
i = R;
|
|
377
1696
|
}
|
|
378
1697
|
return e;
|
|
379
1698
|
}
|
|
380
|
-
function
|
|
381
|
-
let
|
|
382
|
-
const
|
|
383
|
-
for (;
|
|
384
|
-
return
|
|
1699
|
+
function Le(n, e, t, i) {
|
|
1700
|
+
let a = t;
|
|
1701
|
+
const r = t + i;
|
|
1702
|
+
for (; a < r && e[a] !== 0; ) a += 1;
|
|
1703
|
+
return n.decode(e.subarray(t, a)).trim();
|
|
385
1704
|
}
|
|
386
|
-
function
|
|
387
|
-
const
|
|
388
|
-
for (const
|
|
389
|
-
const
|
|
390
|
-
if (!
|
|
391
|
-
const
|
|
392
|
-
if (!
|
|
393
|
-
let
|
|
394
|
-
for (let
|
|
395
|
-
const
|
|
396
|
-
|
|
1705
|
+
function pn(n, e) {
|
|
1706
|
+
const t = new D(/* @__PURE__ */ new Map());
|
|
1707
|
+
for (const i of n) {
|
|
1708
|
+
const a = i.name.replace(/^\.\/?/, "");
|
|
1709
|
+
if (!a) continue;
|
|
1710
|
+
const r = a.split("/").filter(Boolean);
|
|
1711
|
+
if (!r.length) continue;
|
|
1712
|
+
let s = t;
|
|
1713
|
+
for (let f = 0; f < r.length - 1; f += 1) {
|
|
1714
|
+
const l = r[f];
|
|
1715
|
+
s.contents.has(l) || s.contents.set(l, new D(/* @__PURE__ */ new Map())), s = s.contents.get(l);
|
|
397
1716
|
}
|
|
398
|
-
const
|
|
399
|
-
|
|
1717
|
+
const o = r[r.length - 1];
|
|
1718
|
+
i.type === "dir" ? s.contents.has(o) || s.contents.set(o, new D(/* @__PURE__ */ new Map())) : s.contents.set(o, new je(i.data, { readonly: !0 }));
|
|
400
1719
|
}
|
|
401
|
-
return
|
|
1720
|
+
return te(t, "home"), te(t, "tmp"), te(t, "home/.config"), te(t, "home/.local/share"), te(t, "home/.local/state"), t;
|
|
402
1721
|
}
|
|
403
|
-
function
|
|
404
|
-
const
|
|
405
|
-
let
|
|
406
|
-
for (const
|
|
407
|
-
|
|
1722
|
+
function te(n, e) {
|
|
1723
|
+
const t = e.split("/").filter(Boolean);
|
|
1724
|
+
let i = n;
|
|
1725
|
+
for (const a of t)
|
|
1726
|
+
i.contents.has(a) || i.contents.set(a, new D(/* @__PURE__ */ new Map())), i = i.contents.get(a);
|
|
408
1727
|
}
|
|
409
|
-
function
|
|
410
|
-
const e = WebAssembly,
|
|
1728
|
+
function yn(n) {
|
|
1729
|
+
const e = WebAssembly, t = new e.Tag({ parameters: ["i32"], results: [] });
|
|
411
1730
|
return {
|
|
412
1731
|
flock: () => 0,
|
|
413
1732
|
getpid: () => 1,
|
|
@@ -417,8 +1736,8 @@ function xt(t) {
|
|
|
417
1736
|
uv_utf16_length_as_wtf8: () => 0,
|
|
418
1737
|
uv_utf16_to_wtf8: () => -38,
|
|
419
1738
|
uv_wtf8_length_as_utf16: () => 0,
|
|
420
|
-
__wasm_longjmp: (
|
|
421
|
-
throw
|
|
1739
|
+
__wasm_longjmp: (i) => {
|
|
1740
|
+
throw n && n(1), new e.Exception(t, [i ?? 0]);
|
|
422
1741
|
},
|
|
423
1742
|
__wasm_setjmp: () => 0,
|
|
424
1743
|
__wasm_setjmp_test: () => 0,
|
|
@@ -426,36 +1745,36 @@ function xt(t) {
|
|
|
426
1745
|
clock: () => 0,
|
|
427
1746
|
system: () => -1,
|
|
428
1747
|
tmpnam: () => 0,
|
|
429
|
-
__c_longjmp:
|
|
1748
|
+
__c_longjmp: t
|
|
430
1749
|
};
|
|
431
1750
|
}
|
|
432
|
-
class
|
|
433
|
-
#
|
|
1751
|
+
class it extends et {
|
|
1752
|
+
#e(e) {
|
|
434
1753
|
return e.replace(/^\/+/, "");
|
|
435
1754
|
}
|
|
436
|
-
path_open(e,
|
|
437
|
-
return super.path_open(e, this.#t
|
|
1755
|
+
path_open(e, t, i, a, r, s) {
|
|
1756
|
+
return super.path_open(e, this.#e(t), i, a, r, s);
|
|
438
1757
|
}
|
|
439
|
-
path_filestat_get(e,
|
|
440
|
-
return super.path_filestat_get(e, this.#t
|
|
1758
|
+
path_filestat_get(e, t) {
|
|
1759
|
+
return super.path_filestat_get(e, this.#e(t));
|
|
441
1760
|
}
|
|
442
1761
|
path_create_directory(e) {
|
|
443
|
-
return super.path_create_directory(this.#
|
|
1762
|
+
return super.path_create_directory(this.#e(e));
|
|
444
1763
|
}
|
|
445
1764
|
path_unlink_file(e) {
|
|
446
|
-
return super.path_unlink_file(this.#
|
|
1765
|
+
return super.path_unlink_file(this.#e(e));
|
|
447
1766
|
}
|
|
448
1767
|
path_remove_directory(e) {
|
|
449
|
-
return super.path_remove_directory(this.#
|
|
1768
|
+
return super.path_remove_directory(this.#e(e));
|
|
450
1769
|
}
|
|
451
|
-
path_link(e,
|
|
452
|
-
return super.path_link(this.#
|
|
1770
|
+
path_link(e, t, i) {
|
|
1771
|
+
return super.path_link(this.#e(e), t, i);
|
|
453
1772
|
}
|
|
454
1773
|
path_readlink(e) {
|
|
455
|
-
return super.path_readlink(this.#
|
|
1774
|
+
return super.path_readlink(this.#e(e));
|
|
456
1775
|
}
|
|
457
|
-
path_symlink(e,
|
|
458
|
-
const
|
|
459
|
-
return
|
|
1776
|
+
path_symlink(e, t) {
|
|
1777
|
+
const i = et.prototype.path_symlink;
|
|
1778
|
+
return i ? i.call(this, this.#e(e), this.#e(t)) : 58;
|
|
460
1779
|
}
|
|
461
1780
|
}
|