@napi-rs/tar-wasm32-wasi 1.1.0 → 1.1.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/package.json +9 -7
- package/tar.wasi-browser.js +1417 -33
- package/tar.wasi.cjs +2251 -62
- package/tar.wasi.d.cts +499 -0
- package/tar.wasm32-wasi.wasm +0 -0
- package/wasi-worker-browser.mjs +37 -2
- package/wasi-worker.mjs +178 -55
package/tar.wasi.d.cts
ADDED
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/** The WASI flavor this loader instantiates. */
|
|
5
|
+
export declare const __napiBindingTarget: 'wasm32-wasi'
|
|
6
|
+
|
|
7
|
+
declare global {
|
|
8
|
+
interface IteratorObject<T, TReturn = unknown, TNext = unknown>
|
|
9
|
+
extends globalThis.Iterator<T, TReturn, TNext> {
|
|
10
|
+
[globalThis.Symbol.iterator](): globalThis.IteratorObject<T, TReturn, TNext>
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export declare class Archive {
|
|
15
|
+
/** Create a new archive with the underlying path. */
|
|
16
|
+
constructor(input: string | Uint8Array)
|
|
17
|
+
entries(): Entries
|
|
18
|
+
/**
|
|
19
|
+
* Unpacks the contents tarball into the specified `dst`.
|
|
20
|
+
*
|
|
21
|
+
* This function will iterate over the entire contents of this tarball,
|
|
22
|
+
* extracting each file in turn to the location specified by the entry's
|
|
23
|
+
* path name.
|
|
24
|
+
*
|
|
25
|
+
* This operation is relatively sensitive in that it will not write files
|
|
26
|
+
* outside of the path specified by `dst`. Files in the archive which have
|
|
27
|
+
* a '..' in their path are skipped during the unpacking process.
|
|
28
|
+
*/
|
|
29
|
+
unpack(to: string): void
|
|
30
|
+
/**
|
|
31
|
+
* Set the mask of the permission bits when unpacking this entry.
|
|
32
|
+
*
|
|
33
|
+
* The mask will be inverted when applying against a mode, similar to how
|
|
34
|
+
* `umask` works on Unix. In logical notation it looks like:
|
|
35
|
+
*
|
|
36
|
+
* ```text
|
|
37
|
+
* new_mode = old_mode & (~mask)
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* The mask is 0 by default and is currently only implemented on Unix.
|
|
41
|
+
*/
|
|
42
|
+
setMask(mask: number): void
|
|
43
|
+
/**
|
|
44
|
+
* Indicate whether extended file attributes (xattrs on Unix) are preserved
|
|
45
|
+
* when unpacking this archive.
|
|
46
|
+
*
|
|
47
|
+
* This flag is disabled by default and is currently only implemented on
|
|
48
|
+
* Unix using xattr support. This may eventually be implemented for
|
|
49
|
+
* Windows, however, if other archive implementations are found which do
|
|
50
|
+
* this as well.
|
|
51
|
+
*/
|
|
52
|
+
setUnpackXattrs(unpackXattrs: boolean): void
|
|
53
|
+
/**
|
|
54
|
+
* Indicate whether extended permissions (like suid on Unix) are preserved
|
|
55
|
+
* when unpacking this entry.
|
|
56
|
+
*
|
|
57
|
+
* This flag is disabled by default and is currently only implemented on
|
|
58
|
+
* Unix.
|
|
59
|
+
*/
|
|
60
|
+
setPreservePermissions(preservePermissions: boolean): void
|
|
61
|
+
/**
|
|
62
|
+
* Indicate whether numeric ownership ids (like uid and gid on Unix)
|
|
63
|
+
* are preserved when unpacking this entry.
|
|
64
|
+
*
|
|
65
|
+
* This flag is disabled by default and is currently only implemented on
|
|
66
|
+
* Unix.
|
|
67
|
+
*/
|
|
68
|
+
setPreserveOwnerships(preserveOwnerships: boolean): void
|
|
69
|
+
/** Indicate whether files and symlinks should be overwritten on extraction. */
|
|
70
|
+
setOverwrite(overwrite: boolean): void
|
|
71
|
+
/**
|
|
72
|
+
* Indicate whether access time information is preserved when unpacking
|
|
73
|
+
* this entry.
|
|
74
|
+
*
|
|
75
|
+
* This flag is enabled by default.
|
|
76
|
+
*/
|
|
77
|
+
setPreserveMtime(preserveMtime: boolean): void
|
|
78
|
+
/**
|
|
79
|
+
* Ignore zeroed headers, which would otherwise indicate to the archive that it has no more
|
|
80
|
+
* entries.
|
|
81
|
+
*
|
|
82
|
+
* This can be used in case multiple tar archives have been concatenated together.
|
|
83
|
+
*/
|
|
84
|
+
setIgnoreZeros(ignoreZeros: boolean): void
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export declare class Builder {
|
|
88
|
+
/**
|
|
89
|
+
* Create a new builder which will write to the specified output.
|
|
90
|
+
* The output can be a file path (string) or will create a buffer internally.
|
|
91
|
+
*/
|
|
92
|
+
constructor(output?: string | undefined | null)
|
|
93
|
+
/**
|
|
94
|
+
* Append a file from disk to this archive.
|
|
95
|
+
*
|
|
96
|
+
* This function will open the file specified by `src` and add it to the
|
|
97
|
+
* archive as `name`. The `name` specified is the name that will be used
|
|
98
|
+
* inside the archive.
|
|
99
|
+
*/
|
|
100
|
+
appendFile(name: string, src: string): void
|
|
101
|
+
/**
|
|
102
|
+
* Append a directory and all of its contents to this archive.
|
|
103
|
+
*
|
|
104
|
+
* This function will recursively add all files and directories in the
|
|
105
|
+
* specified `src` directory to the archive, preserving their relative
|
|
106
|
+
* paths under `name`.
|
|
107
|
+
*/
|
|
108
|
+
appendDirAll(name: string, src: string): void
|
|
109
|
+
/**
|
|
110
|
+
* Append raw data to this archive with the specified name.
|
|
111
|
+
*
|
|
112
|
+
* This function allows you to add arbitrary data to the archive with a
|
|
113
|
+
* specified filename.
|
|
114
|
+
*/
|
|
115
|
+
appendData(name: string, data: Uint8Array): void
|
|
116
|
+
/**
|
|
117
|
+
* Finalize the archive and return the resulting data.
|
|
118
|
+
*
|
|
119
|
+
* This function must be called to properly finish the archive.
|
|
120
|
+
* If a file path was provided during construction, this will flush
|
|
121
|
+
* and close the file. If no path was provided, this returns the
|
|
122
|
+
* archive data as a Buffer.
|
|
123
|
+
*/
|
|
124
|
+
finish(): Array<number> | null
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* This type implements JavaScript's iterable iterator protocol.
|
|
129
|
+
* On runtimes with `Iterator` helpers, its prototype also inherits those helpers.
|
|
130
|
+
*
|
|
131
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator#iterator_helper_methods
|
|
132
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterator_and_iterable_protocols
|
|
133
|
+
*/
|
|
134
|
+
export declare class Entries {
|
|
135
|
+
|
|
136
|
+
[globalThis.Symbol.iterator](): this
|
|
137
|
+
next(...[value]: [] | [void]): globalThis.IteratorResult<Entry, void | undefined>
|
|
138
|
+
return(...[value]: [] | [void]): globalThis.IteratorResult<Entry, void | undefined>
|
|
139
|
+
throw(exception?: unknown): globalThis.IteratorResult<Entry, void | undefined>
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface Entries extends globalThis.Omit<globalThis.IteratorObject<Entry, void | undefined, void>, 'next' | 'return' | 'throw'> {}
|
|
143
|
+
|
|
144
|
+
export declare class Entry {
|
|
145
|
+
/**
|
|
146
|
+
* Returns the path name for this entry.
|
|
147
|
+
*
|
|
148
|
+
* This method may fail if the pathname is not valid Unicode and this is
|
|
149
|
+
* called on a Windows platform.
|
|
150
|
+
*
|
|
151
|
+
* Note that this function will convert any `\` characters to directory
|
|
152
|
+
* separators, and it will not always return the same value as
|
|
153
|
+
* `self.header().path()` as some archive formats have support for longer
|
|
154
|
+
* path names described in separate entries.
|
|
155
|
+
*
|
|
156
|
+
* It is recommended to use this method instead of inspecting the `header`
|
|
157
|
+
* directly to ensure that various archive formats are handled correctly.
|
|
158
|
+
*/
|
|
159
|
+
path(): string | null
|
|
160
|
+
header(): ReadonlyHeader
|
|
161
|
+
/**
|
|
162
|
+
* Read the entirety of this entry into a byte vector.
|
|
163
|
+
*
|
|
164
|
+
* This is equivalent to the functionality provided by `tar -x -O -f archive.tar filename`
|
|
165
|
+
* which extracts a single file and outputs its contents to stdout.
|
|
166
|
+
*
|
|
167
|
+
* This method will read the entire contents of this entry into memory.
|
|
168
|
+
* For large files, consider using streaming methods if memory usage is a concern.
|
|
169
|
+
*/
|
|
170
|
+
asBytes(): Buffer
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export declare class Header {
|
|
174
|
+
/** Returns a view into this header as a byte array. */
|
|
175
|
+
asBytes(): Buffer
|
|
176
|
+
/**
|
|
177
|
+
* Returns the size of entry's data this header represents.
|
|
178
|
+
*
|
|
179
|
+
* This is different from `Header::size` for sparse files, which have
|
|
180
|
+
* some longer `size()` but shorter `entry_size()`. The `entry_size()`
|
|
181
|
+
* listed here should be the number of bytes in the archive this header
|
|
182
|
+
* describes.
|
|
183
|
+
*
|
|
184
|
+
* May return an error if the field is corrupted.
|
|
185
|
+
*/
|
|
186
|
+
entrySize(): bigint
|
|
187
|
+
/**
|
|
188
|
+
* Returns the file size this header represents.
|
|
189
|
+
*
|
|
190
|
+
* May return an error if the field is corrupted.
|
|
191
|
+
*/
|
|
192
|
+
size(): bigint
|
|
193
|
+
/** Encodes the `size` argument into the size field of this header. */
|
|
194
|
+
setSize(size: number | bigint): void
|
|
195
|
+
/**
|
|
196
|
+
* Returns the raw path name stored in this header.
|
|
197
|
+
*
|
|
198
|
+
* This method may fail if the pathname is not valid Unicode and this is
|
|
199
|
+
* called on a Windows platform.
|
|
200
|
+
*
|
|
201
|
+
* Note that this function will convert any `\` characters to directory
|
|
202
|
+
* separators.
|
|
203
|
+
*/
|
|
204
|
+
path(): string
|
|
205
|
+
/**
|
|
206
|
+
* Sets the path name for this header.
|
|
207
|
+
*
|
|
208
|
+
* This function will set the pathname listed in this header, encoding it
|
|
209
|
+
* in the appropriate format. May fail if the path is too long or if the
|
|
210
|
+
* path specified is not Unicode and this is a Windows platform. Will
|
|
211
|
+
* strip out any "." path component, which signifies the current directory.
|
|
212
|
+
*
|
|
213
|
+
* Note: This function does not support names over 100 bytes, or paths
|
|
214
|
+
* over 255 bytes, even for formats that support longer names. Instead,
|
|
215
|
+
* use `Builder` methods to insert a long-name extension at the same time
|
|
216
|
+
* as the file content.
|
|
217
|
+
*/
|
|
218
|
+
setPath(path: string): void
|
|
219
|
+
/**
|
|
220
|
+
* Returns the link name stored in this header as a byte array, if any.
|
|
221
|
+
*
|
|
222
|
+
* This function is guaranteed to succeed, but you may wish to call the
|
|
223
|
+
* `link_name` method to convert to a `Path`.
|
|
224
|
+
*
|
|
225
|
+
* Note that this function will convert any `\` characters to directory
|
|
226
|
+
* separators.
|
|
227
|
+
*/
|
|
228
|
+
linkName(): string | null
|
|
229
|
+
/**
|
|
230
|
+
* Sets the link name for this header.
|
|
231
|
+
*
|
|
232
|
+
* This function will set the linkname listed in this header, encoding it
|
|
233
|
+
* in the appropriate format. May fail if the link name is too long or if
|
|
234
|
+
* the path specified is not Unicode and this is a Windows platform. Will
|
|
235
|
+
* strip out any "." path component, which signifies the current directory.
|
|
236
|
+
*
|
|
237
|
+
* To use GNU long link names, prefer instead [`crate::Builder::append_link`].
|
|
238
|
+
*/
|
|
239
|
+
setLinkName(linkName: string): void
|
|
240
|
+
/**
|
|
241
|
+
* Sets the link name for this header without any transformation.
|
|
242
|
+
*
|
|
243
|
+
* This function is like [`Self::set_link_name`] but accepts an arbitrary byte array.
|
|
244
|
+
* Hence it will not perform any canonicalization, such as replacing duplicate `//` with `/`.
|
|
245
|
+
*/
|
|
246
|
+
setLinkNameLiteral(linkName: string): void
|
|
247
|
+
/**
|
|
248
|
+
* Returns the mode bits for this file
|
|
249
|
+
*
|
|
250
|
+
* May return an error if the field is corrupted.
|
|
251
|
+
*/
|
|
252
|
+
mode(): number
|
|
253
|
+
/** Encodes the `mode` provided into this header. */
|
|
254
|
+
setMode(mode: number): void
|
|
255
|
+
/**
|
|
256
|
+
* Returns the value of the owner's user ID field
|
|
257
|
+
*
|
|
258
|
+
* May return an error if the field is corrupted.
|
|
259
|
+
*/
|
|
260
|
+
uid(): bigint
|
|
261
|
+
/** Encodes the `uid` provided into this header. */
|
|
262
|
+
setUid(uid: bigint): void
|
|
263
|
+
/** Returns the value of the group's user ID field */
|
|
264
|
+
gid(): bigint
|
|
265
|
+
/** Encodes the `gid` provided into this header. */
|
|
266
|
+
setGid(gid: bigint): void
|
|
267
|
+
/** Returns the last modification time in Unix time format */
|
|
268
|
+
mtime(): bigint
|
|
269
|
+
/**
|
|
270
|
+
* Encodes the `mtime` provided into this header.
|
|
271
|
+
*
|
|
272
|
+
* Note that this time is typically a number of seconds passed since
|
|
273
|
+
* January 1, 1970.
|
|
274
|
+
*/
|
|
275
|
+
setTime(mtime: bigint): void
|
|
276
|
+
/**
|
|
277
|
+
* Return the user name of the owner of this file.
|
|
278
|
+
*
|
|
279
|
+
* A return value of `Ok(Some(..))` indicates that the user name was
|
|
280
|
+
* present and was valid utf-8, `Ok(None)` indicates that the user name is
|
|
281
|
+
* not present in this archive format, and `Err` indicates that the user
|
|
282
|
+
* name was present but was not valid utf-8.
|
|
283
|
+
*/
|
|
284
|
+
username(): string | null
|
|
285
|
+
/**
|
|
286
|
+
* Sets the username inside this header.
|
|
287
|
+
*
|
|
288
|
+
* This function will return an error if this header format cannot encode a
|
|
289
|
+
* user name or the name is too long.
|
|
290
|
+
*/
|
|
291
|
+
setUsername(username: string): void
|
|
292
|
+
/**
|
|
293
|
+
* Return the group name of the owner of this file.
|
|
294
|
+
*
|
|
295
|
+
* A return value of `Ok(Some(..))` indicates that the group name was
|
|
296
|
+
* present and was valid utf-8, `Ok(None)` indicates that the group name is
|
|
297
|
+
* not present in this archive format, and `Err` indicates that the group
|
|
298
|
+
* name was present but was not valid utf-8.
|
|
299
|
+
*/
|
|
300
|
+
groupname(): string | null
|
|
301
|
+
/**
|
|
302
|
+
* Sets the group name inside this header.
|
|
303
|
+
*
|
|
304
|
+
* This function will return an error if this header format cannot encode a
|
|
305
|
+
* group name or the name is too long.
|
|
306
|
+
*/
|
|
307
|
+
setGroupname(groupname: string): void
|
|
308
|
+
/**
|
|
309
|
+
* Returns the device major number, if present.
|
|
310
|
+
*
|
|
311
|
+
* This field may not be present in all archives, and it may not be
|
|
312
|
+
* correctly formed in all archives. `Ok(Some(..))` means it was present
|
|
313
|
+
* and correctly decoded, `Ok(None)` indicates that this header format does
|
|
314
|
+
* not include the device major number, and `Err` indicates that it was
|
|
315
|
+
* present and failed to decode.
|
|
316
|
+
*/
|
|
317
|
+
deviceMajor(): number | null
|
|
318
|
+
/**
|
|
319
|
+
* Encodes the value `major` into the dev_major field of this header.
|
|
320
|
+
*
|
|
321
|
+
* This function will return an error if this header format cannot encode a
|
|
322
|
+
* major device number.
|
|
323
|
+
*/
|
|
324
|
+
setDeviceMajor(deviceMajor: number): void
|
|
325
|
+
/**
|
|
326
|
+
* Returns the device minor number, if present.
|
|
327
|
+
*
|
|
328
|
+
* This field may not be present in all archives, and it may not be
|
|
329
|
+
* correctly formed in all archives. `Ok(Some(..))` means it was present
|
|
330
|
+
* and correctly decoded, `Ok(None)` indicates that this header format does
|
|
331
|
+
* not include the device minor number, and `Err` indicates that it was
|
|
332
|
+
* present and failed to decode.
|
|
333
|
+
*/
|
|
334
|
+
deviceMinor(): number | null
|
|
335
|
+
/**
|
|
336
|
+
* Encodes the value `minor` into the dev_minor field of this header.
|
|
337
|
+
*
|
|
338
|
+
* This function will return an error if this header format cannot encode a
|
|
339
|
+
* minor device number.
|
|
340
|
+
*/
|
|
341
|
+
setDeviceMinor(deviceMinor: number): void
|
|
342
|
+
/** Returns the type of file described by this header. */
|
|
343
|
+
entryType(): EntryType
|
|
344
|
+
/** Sets the type of file that will be described by this header. */
|
|
345
|
+
setEntryType(entryType: EntryType): void
|
|
346
|
+
/**
|
|
347
|
+
* Returns the checksum field of this header.
|
|
348
|
+
*
|
|
349
|
+
* May return an error if the field is corrupted.
|
|
350
|
+
*/
|
|
351
|
+
cksum(): number
|
|
352
|
+
/**
|
|
353
|
+
* Sets the checksum field of this header based on the current fields in
|
|
354
|
+
* this header.
|
|
355
|
+
*/
|
|
356
|
+
setCksum(): void
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export declare class ReadonlyHeader {
|
|
360
|
+
/** Returns a view into this header as a byte array. */
|
|
361
|
+
asBytes(): Buffer
|
|
362
|
+
/**
|
|
363
|
+
* Returns the size of entry's data this header represents.
|
|
364
|
+
*
|
|
365
|
+
* This is different from `Header::size` for sparse files, which have
|
|
366
|
+
* some longer `size()` but shorter `entry_size()`. The `entry_size()`
|
|
367
|
+
* listed here should be the number of bytes in the archive this header
|
|
368
|
+
* describes.
|
|
369
|
+
*
|
|
370
|
+
* May return an error if the field is corrupted.
|
|
371
|
+
*/
|
|
372
|
+
entrySize(): bigint
|
|
373
|
+
/**
|
|
374
|
+
* Returns the file size this header represents.
|
|
375
|
+
*
|
|
376
|
+
* May return an error if the field is corrupted.
|
|
377
|
+
*/
|
|
378
|
+
size(): bigint
|
|
379
|
+
/**
|
|
380
|
+
* Returns the raw path name stored in this header.
|
|
381
|
+
*
|
|
382
|
+
* This method may fail if the pathname is not valid Unicode and this is
|
|
383
|
+
* called on a Windows platform.
|
|
384
|
+
*
|
|
385
|
+
* Note that this function will convert any `\` characters to directory
|
|
386
|
+
* separators.
|
|
387
|
+
*/
|
|
388
|
+
path(): string
|
|
389
|
+
/**
|
|
390
|
+
* Returns the link name stored in this header as a byte array, if any.
|
|
391
|
+
*
|
|
392
|
+
* This function is guaranteed to succeed, but you may wish to call the
|
|
393
|
+
* `link_name` method to convert to a `Path`.
|
|
394
|
+
*
|
|
395
|
+
* Note that this function will convert any `\` characters to directory
|
|
396
|
+
* separators.
|
|
397
|
+
*/
|
|
398
|
+
linkName(): string | null
|
|
399
|
+
/**
|
|
400
|
+
* Returns the mode bits for this file
|
|
401
|
+
*
|
|
402
|
+
* May return an error if the field is corrupted.
|
|
403
|
+
*/
|
|
404
|
+
mode(): number
|
|
405
|
+
/**
|
|
406
|
+
* Returns the value of the owner's user ID field
|
|
407
|
+
*
|
|
408
|
+
* May return an error if the field is corrupted.
|
|
409
|
+
*/
|
|
410
|
+
uid(): bigint
|
|
411
|
+
/** Returns the value of the group's user ID field */
|
|
412
|
+
gid(): bigint
|
|
413
|
+
/** Returns the last modification time in Unix time format */
|
|
414
|
+
mtime(): bigint
|
|
415
|
+
/**
|
|
416
|
+
* Return the user name of the owner of this file.
|
|
417
|
+
*
|
|
418
|
+
* A return value of `Ok(Some(..))` indicates that the user name was
|
|
419
|
+
* present and was valid utf-8, `Ok(None)` indicates that the user name is
|
|
420
|
+
* not present in this archive format, and `Err` indicates that the user
|
|
421
|
+
* name was present but was not valid utf-8.
|
|
422
|
+
*/
|
|
423
|
+
username(): string | null
|
|
424
|
+
/**
|
|
425
|
+
* Return the group name of the owner of this file.
|
|
426
|
+
*
|
|
427
|
+
* A return value of `Ok(Some(..))` indicates that the group name was
|
|
428
|
+
* present and was valid utf-8, `Ok(None)` indicates that the group name is
|
|
429
|
+
* not present in this archive format, and `Err` indicates that the group
|
|
430
|
+
* name was present but was not valid utf-8.
|
|
431
|
+
*/
|
|
432
|
+
groupname(): string | null
|
|
433
|
+
/**
|
|
434
|
+
* Returns the device major number, if present.
|
|
435
|
+
*
|
|
436
|
+
* This field may not be present in all archives, and it may not be
|
|
437
|
+
* correctly formed in all archives. `Ok(Some(..))` means it was present
|
|
438
|
+
* and correctly decoded, `Ok(None)` indicates that this header format does
|
|
439
|
+
* not include the device major number, and `Err` indicates that it was
|
|
440
|
+
* present and failed to decode.
|
|
441
|
+
*/
|
|
442
|
+
deviceMajor(): number | null
|
|
443
|
+
/**
|
|
444
|
+
* Returns the device minor number, if present.
|
|
445
|
+
*
|
|
446
|
+
* This field may not be present in all archives, and it may not be
|
|
447
|
+
* correctly formed in all archives. `Ok(Some(..))` means it was present
|
|
448
|
+
* and correctly decoded, `Ok(None)` indicates that this header format does
|
|
449
|
+
* not include the device minor number, and `Err` indicates that it was
|
|
450
|
+
* present and failed to decode.
|
|
451
|
+
*/
|
|
452
|
+
deviceMinor(): number | null
|
|
453
|
+
/** Returns the type of file described by this header. */
|
|
454
|
+
entryType(): EntryType
|
|
455
|
+
/**
|
|
456
|
+
* Returns the checksum field of this header.
|
|
457
|
+
*
|
|
458
|
+
* May return an error if the field is corrupted.
|
|
459
|
+
*/
|
|
460
|
+
cksum(): number
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* See [https://en.wikipedia.org/wiki/Tar_%28computing%29#UStar_format](https://en.wikipedia.org/wiki/Tar_%28computing%29#UStar_format)
|
|
465
|
+
* Indicate for the type of file described by a header.
|
|
466
|
+
*
|
|
467
|
+
* Each `Header` has an `entry_type` method returning an instance of this type
|
|
468
|
+
* which can be used to inspect what the header is describing.
|
|
469
|
+
*
|
|
470
|
+
* A non-exhaustive enum representing the possible entry types
|
|
471
|
+
*/
|
|
472
|
+
export declare const enum EntryType {
|
|
473
|
+
/** Regular file */
|
|
474
|
+
Regular = 0,
|
|
475
|
+
/** Hard link */
|
|
476
|
+
Link = 1,
|
|
477
|
+
/** Symbolic link */
|
|
478
|
+
Symlink = 2,
|
|
479
|
+
/** Character device */
|
|
480
|
+
Char = 3,
|
|
481
|
+
/** Block device */
|
|
482
|
+
Block = 4,
|
|
483
|
+
/** Directory */
|
|
484
|
+
Directory = 5,
|
|
485
|
+
/** Named pipe (fifo) */
|
|
486
|
+
Fifo = 6,
|
|
487
|
+
/** Implementation-defined 'high-performance' type, treated as regular file */
|
|
488
|
+
Continuous = 7,
|
|
489
|
+
/** GNU extension - long file name */
|
|
490
|
+
GNULongName = 8,
|
|
491
|
+
/** GNU extension - long link name (link target) */
|
|
492
|
+
GNULongLink = 9,
|
|
493
|
+
/** GNU extension - sparse file */
|
|
494
|
+
GNUSparse = 10,
|
|
495
|
+
/** Global extended header */
|
|
496
|
+
XGlobalHeader = 11,
|
|
497
|
+
/** Extended Header */
|
|
498
|
+
XHeader = 12,
|
|
499
|
+
}
|
package/tar.wasm32-wasi.wasm
CHANGED
|
Binary file
|
package/wasi-worker-browser.mjs
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
instantiateNapiModuleSync,
|
|
3
|
+
MessageHandler,
|
|
4
|
+
WASI,
|
|
5
|
+
emnapiAsyncWorkPlugin,
|
|
6
|
+
emnapiTSFNPlugin,
|
|
7
|
+
} from '@napi-rs/wasm-runtime'
|
|
2
8
|
|
|
3
9
|
const handler = new MessageHandler({
|
|
4
10
|
onLoad({ wasmModule, wasmMemory }) {
|
|
@@ -7,7 +13,7 @@ const handler = new MessageHandler({
|
|
|
7
13
|
// eslint-disable-next-line no-console
|
|
8
14
|
console.log.apply(console, arguments)
|
|
9
15
|
},
|
|
10
|
-
printErr: function() {
|
|
16
|
+
printErr: function () {
|
|
11
17
|
// eslint-disable-next-line no-console
|
|
12
18
|
console.error.apply(console, arguments)
|
|
13
19
|
},
|
|
@@ -15,6 +21,11 @@ const handler = new MessageHandler({
|
|
|
15
21
|
return instantiateNapiModuleSync(wasmModule, {
|
|
16
22
|
childThread: true,
|
|
17
23
|
wasi,
|
|
24
|
+
// The wasm links a "basic" emnapi archive (no C async-work /
|
|
25
|
+
// threadsafe-function implementations), so every thread that
|
|
26
|
+
// instantiates it must provide the JavaScript implementations
|
|
27
|
+
// through the emnapi plugins.
|
|
28
|
+
plugins: [emnapiAsyncWorkPlugin, emnapiTSFNPlugin],
|
|
18
29
|
overwriteImports(importObject) {
|
|
19
30
|
importObject.env = {
|
|
20
31
|
...importObject.env,
|
|
@@ -27,6 +38,30 @@ const handler = new MessageHandler({
|
|
|
27
38
|
},
|
|
28
39
|
})
|
|
29
40
|
|
|
41
|
+
// When this wasm thread dies, raise the addon's crash flag before emnapi reports
|
|
42
|
+
// it. The loader thread may be inside wasm, in a cleanup call that waits on this
|
|
43
|
+
// thread; the flag is what those waits check between short slices, and once it
|
|
44
|
+
// is up they trap instead of waiting for good. It is a word in the shared wasm
|
|
45
|
+
// memory, and the loader posts a view of it (see
|
|
46
|
+
// napi_wasm_thread_crash_flag_address) after it instantiated the wasm, or right
|
|
47
|
+
// after it created this worker. No view, no flag: an addon built with an older
|
|
48
|
+
// napi, or a failure before the view arrived.
|
|
49
|
+
let __addonCrashFlag
|
|
50
|
+
const __beforeReportError = handler.beforeReportError
|
|
51
|
+
handler.beforeReportError = function (...args) {
|
|
52
|
+
if (__addonCrashFlag !== undefined) {
|
|
53
|
+
try {
|
|
54
|
+
Atomics.store(__addonCrashFlag, 0, 1)
|
|
55
|
+
} catch {}
|
|
56
|
+
}
|
|
57
|
+
return __beforeReportError.apply(this, args)
|
|
58
|
+
}
|
|
59
|
+
|
|
30
60
|
globalThis.onmessage = function (e) {
|
|
61
|
+
const data = e && e.data
|
|
62
|
+
if (data && data.__napiRsAddonCrashFlag instanceof Int32Array) {
|
|
63
|
+
__addonCrashFlag = data.__napiRsAddonCrashFlag
|
|
64
|
+
return
|
|
65
|
+
}
|
|
31
66
|
handler.handle(e)
|
|
32
67
|
}
|