@amritk/nish-x86_64-linux 0.26.0 → 0.28.0
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/INSTALL.md +13 -8
- package/bin/nish +0 -0
- package/docs/AI.md +27 -5
- package/package.json +1 -1
- package/runtime/core.d.ts +47 -0
- package/runtime/core.mjs +67 -0
- package/runtime/nish.d.ts +54 -5
- package/runtime/nish.h +67 -8
- package/runtime/nish.mjs +6 -0
- package/runtime/runtime-checksum.c +270 -0
- package/runtime/runtime-os.c +9 -4
- package/runtime/runtime-parallel.c +21 -0
- package/runtime/runtime-sandbox.c +470 -0
- package/runtime/runtime-sha256.c +239 -0
- package/runtime/runtime-simd.c +63 -2
- package/runtime/runtime-wasm.c +18 -0
- package/scripts/build.sh +60 -24
- package/std/README.md +16 -10
- package/std/compress/checksum.ts +88 -75
- package/std/compress/deflate.ts +224 -0
- package/std/compress/gzip.ts +52 -0
- package/std/crypto/bcrypt.ts +816 -280
- package/std/crypto/sha256.ts +335 -188
- package/std/json-equal.ts +335 -0
- package/std/json-format.ts +1070 -0
- package/std/json-number.ts +428 -0
- package/std/json-pointer.ts +245 -0
- package/std/json-value.ts +510 -17
- package/std/net/http-client.ts +1645 -0
- package/std/net/http-compress.ts +259 -16
- package/std/net/http1-client.ts +104 -19
- package/std/net/http1-server.ts +61 -12
- package/std/net/postgres.ts +576 -8
- package/std/net/websocket.ts +295 -14
- package/std/regex.ts +613 -52
- package/std/term-io.ts +35 -8
- package/std/yaml-json.ts +841 -0
package/std/compress/gzip.ts
CHANGED
|
@@ -40,11 +40,13 @@ import {
|
|
|
40
40
|
DEFLATE_ERR_TRUNCATED,
|
|
41
41
|
DEFLATE_NO_ROOM,
|
|
42
42
|
Deflater,
|
|
43
|
+
FixedDeflater,
|
|
43
44
|
INFLATE_DONE,
|
|
44
45
|
INFLATE_NEED_INPUT,
|
|
45
46
|
INFLATE_NEED_OUTPUT,
|
|
46
47
|
Inflater,
|
|
47
48
|
deflateBound,
|
|
49
|
+
fixedDeflateBound,
|
|
48
50
|
} from "nish/compress/deflate"
|
|
49
51
|
import { copyBytes } from "nish/bytes"
|
|
50
52
|
|
|
@@ -203,6 +205,56 @@ export class GzipCompressor {
|
|
|
203
205
|
}
|
|
204
206
|
}
|
|
205
207
|
|
|
208
|
+
/** The most bytes `GzipFixedCompressor.compress` writes for `n` bytes of input. */
|
|
209
|
+
export const gzipFixedBound = (n: i32): i32 => fixedDeflateBound(n) + GZIP_HEADER_SIZE + GZIP_TRAILER_SIZE
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* A gzip compressor for short inputs: a `FixedDeflater` (one fixed-Huffman
|
|
213
|
+
* block, 16 KB window) and the CRC-32 tables, allocated once. Each call
|
|
214
|
+
* depends on its input alone. Not shared between threads.
|
|
215
|
+
*/
|
|
216
|
+
export class GzipFixedCompressor {
|
|
217
|
+
readonly deflater: FixedDeflater
|
|
218
|
+
readonly crc: Crc32
|
|
219
|
+
|
|
220
|
+
/** Builds the tables. */
|
|
221
|
+
constructor() {
|
|
222
|
+
this.deflater = new FixedDeflater()
|
|
223
|
+
this.crc = new Crc32()
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Compresses `src[off .. off + len)` into `out[at .. at + room)` as one gzip
|
|
228
|
+
* member, and answers where it ends, or `DEFLATE_NO_ROOM` (-1) as soon as
|
|
229
|
+
* it would need more than `room` bytes, so a caller passing the most it
|
|
230
|
+
* will take stops early on an input that does not shrink.
|
|
231
|
+
* `gzipFixedBound(len)` always fits. A window outside its array panics.
|
|
232
|
+
* Allocates nothing.
|
|
233
|
+
*/
|
|
234
|
+
compress(src: u8[], off: i32, len: i32, out: u8[], at: i32, room: i32): i32 {
|
|
235
|
+
gzipWindow("GzipFixedCompressor.compress", src, off, len)
|
|
236
|
+
gzipWindow("GzipFixedCompressor.compress", out, at, room)
|
|
237
|
+
if (room < GZIP_HEADER_SIZE + GZIP_TRAILER_SIZE) {
|
|
238
|
+
return DEFLATE_NO_ROOM
|
|
239
|
+
}
|
|
240
|
+
gzipWriteHeader(out, at, 1)
|
|
241
|
+
const end: i32 = this.deflater.compress(
|
|
242
|
+
src,
|
|
243
|
+
off,
|
|
244
|
+
len,
|
|
245
|
+
out,
|
|
246
|
+
at + GZIP_HEADER_SIZE,
|
|
247
|
+
room - GZIP_HEADER_SIZE - GZIP_TRAILER_SIZE
|
|
248
|
+
)
|
|
249
|
+
if (end < 0) {
|
|
250
|
+
return DEFLATE_NO_ROOM
|
|
251
|
+
}
|
|
252
|
+
gzipPut32(out, end, this.crc.update(toU32(0), src, off, len))
|
|
253
|
+
gzipPut32(out, end + 4, toU32(len))
|
|
254
|
+
return end + GZIP_TRAILER_SIZE
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
206
258
|
/**
|
|
207
259
|
* A gzip decompressor: an `Inflater` and the CRC-32 tables, allocated once.
|
|
208
260
|
* Not shared between threads.
|