@amritk/nish-aarch64-linux 0.45.1 → 0.47.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 +3 -1
- package/bin/nish +0 -0
- package/docs/AI.md +29 -18
- package/package.json +1 -1
- package/runtime/nish.d.ts +41 -0
- package/runtime/nish.h +11 -0
- package/runtime/nish.mjs +1 -0
- package/runtime/runtime-bytes.c +167 -7
- package/runtime/runtime-host.c +15 -0
- package/runtime/runtime-net.c +272 -9
- package/runtime/runtime-os.c +15 -1
- package/runtime/runtime-uring.c +394 -85
- package/runtime/sqlite/nish-sqlite.c +448 -148
- package/std/README.md +14 -14
- package/std/base64.ts +28 -30
- package/std/crypto/aes.ts +81 -45
- package/std/crypto/bcrypt-batch.ts +23 -4
- package/std/crypto/bcrypt.ts +36 -11
- package/std/crypto/chacha20poly1305.ts +93 -52
- package/std/crypto/x25519.ts +7 -4
- package/std/host/game.ts +52 -20
- package/std/host/ring.ts +115 -31
- package/std/host/text.ts +9 -3
- package/std/json.ts +83 -0
- package/std/math.ts +161 -131
- package/std/net/handler.ts +42 -7
- package/std/net/http1-server.ts +36 -11
- package/std/net/prefork.ts +1 -2
- package/std/net/static.ts +7 -2
- package/std/random.ts +34 -51
- package/std/raster.ts +360 -110
- package/std/regex.ts +46 -15
- package/std/release.ts +19 -13
- package/std/sqlite.ts +551 -16
- package/std/synth.ts +11 -2
- package/std/temporal.ts +740 -363
- package/std/term-io.ts +81 -33
- package/std/term-pixels.ts +287 -112
- package/std/term-probe.ts +7 -3
- package/std/term-rate.ts +142 -66
- package/std/term.ts +782 -406
- package/std/testing.ts +14 -7
package/std/regex.ts
CHANGED
|
@@ -101,8 +101,6 @@
|
|
|
101
101
|
* `Regex` is used by one thread at a time.
|
|
102
102
|
*/
|
|
103
103
|
|
|
104
|
-
import { uncheckedGet } from "nish:unsafe"
|
|
105
|
-
|
|
106
104
|
// Derived from the Unicode Character Database 16.0.0 (https://www.unicode.org/Public/16.0.0/ucd/), the files scripts/gen-regex-unicode.mjs names. Copyright © 1991-2026 Unicode, Inc. Used under the Unicode License v3, whose text follows.
|
|
107
105
|
//
|
|
108
106
|
// UNICODE LICENSE V3
|
|
@@ -2100,16 +2098,29 @@ const regexLoadSlots = (dst: i32[], src: i32[], base: i32, ns: i32): void => {
|
|
|
2100
2098
|
}
|
|
2101
2099
|
}
|
|
2102
2100
|
|
|
2101
|
+
/**
|
|
2102
|
+
* `n` zeros, or none when `n` is not above 0. Pushed one at a time: an `i32`
|
|
2103
|
+
* length is a checked `new Array`, and every count here is a compile's table
|
|
2104
|
+
* size, made once per pattern.
|
|
2105
|
+
*/
|
|
2103
2106
|
const regexZeros = (n: i32): i32[] => {
|
|
2104
|
-
const a: i32[] =
|
|
2105
|
-
|
|
2107
|
+
const a: i32[] = []
|
|
2108
|
+
let k: i32 = 0
|
|
2109
|
+
while (k < n) {
|
|
2110
|
+
a.push(0)
|
|
2111
|
+
k += 1
|
|
2112
|
+
}
|
|
2106
2113
|
return a
|
|
2107
2114
|
}
|
|
2108
2115
|
|
|
2109
2116
|
/** `n` zero bytes, for the reason `regexZeros` gives. */
|
|
2110
2117
|
const regexZeroBytes = (n: i32): u8[] => {
|
|
2111
|
-
const a: u8[] =
|
|
2112
|
-
|
|
2118
|
+
const a: u8[] = []
|
|
2119
|
+
let k: i32 = 0
|
|
2120
|
+
while (k < n) {
|
|
2121
|
+
a.push(toU8(0))
|
|
2122
|
+
k += 1
|
|
2123
|
+
}
|
|
2113
2124
|
return a
|
|
2114
2125
|
}
|
|
2115
2126
|
|
|
@@ -4889,9 +4900,19 @@ export class Regex {
|
|
|
4889
4900
|
const cls: i32[] = this.dCls
|
|
4890
4901
|
while (true) {
|
|
4891
4902
|
// The hot loop: an ASCII byte and a transition already computed.
|
|
4903
|
+
// `dCls` has an entry for every byte and a state's row one for every
|
|
4904
|
+
// class, so the slot is in the table; were either not, giving up hands
|
|
4905
|
+
// the search to the NFA.
|
|
4892
4906
|
while (p >= 0 && p < len) {
|
|
4893
4907
|
const b: i32 = toI32(text.charCodeAt(p))
|
|
4894
|
-
|
|
4908
|
+
if (b >= toI32(cls.length)) {
|
|
4909
|
+
return DFA_GAVE_UP
|
|
4910
|
+
}
|
|
4911
|
+
const slot: i32 = off | cls[b]
|
|
4912
|
+
if (slot < 0 || slot >= toI32(trans.length)) {
|
|
4913
|
+
return DFA_GAVE_UP
|
|
4914
|
+
}
|
|
4915
|
+
const e: i32 = trans[slot]
|
|
4895
4916
|
if (e > 0) {
|
|
4896
4917
|
off = e
|
|
4897
4918
|
p += 1
|
|
@@ -4915,13 +4936,14 @@ export class Regex {
|
|
|
4915
4936
|
let w: i32 = 1
|
|
4916
4937
|
if (p >= 0 && p < len) {
|
|
4917
4938
|
const b: i32 = toI32(text.charCodeAt(p))
|
|
4918
|
-
if (b
|
|
4919
|
-
// `dCls` has an entry for every byte.
|
|
4920
|
-
c = uncheckedGet(cls, b)
|
|
4921
|
-
} else {
|
|
4939
|
+
if (b >= 128) {
|
|
4922
4940
|
const packed: i32 = regexDecodeAt(text, p)
|
|
4923
4941
|
c = this.dWideClass(packed >> 3)
|
|
4924
4942
|
w = packed & 7
|
|
4943
|
+
} else if (b < toI32(cls.length)) {
|
|
4944
|
+
c = cls[b]
|
|
4945
|
+
} else {
|
|
4946
|
+
return DFA_GAVE_UP
|
|
4925
4947
|
}
|
|
4926
4948
|
}
|
|
4927
4949
|
// States and classes are both non-negative, and a state's row holds
|
|
@@ -5017,7 +5039,15 @@ export class Regex {
|
|
|
5017
5039
|
let q: i32 = toI32(toU32(p) - 1)
|
|
5018
5040
|
while (q >= from && q >= 0 && q < len) {
|
|
5019
5041
|
const b: i32 = toI32(text.charCodeAt(q))
|
|
5020
|
-
|
|
5042
|
+
// A byte or a slot outside its table gives up, as in `dfaForward`.
|
|
5043
|
+
if (b >= toI32(cls.length)) {
|
|
5044
|
+
return DFA_GAVE_UP
|
|
5045
|
+
}
|
|
5046
|
+
const slot: i32 = off | cls[b]
|
|
5047
|
+
if (slot < 0 || slot >= toI32(trans.length)) {
|
|
5048
|
+
return DFA_GAVE_UP
|
|
5049
|
+
}
|
|
5050
|
+
const t: i32 = trans[slot]
|
|
5021
5051
|
if (t > 0) {
|
|
5022
5052
|
off = t
|
|
5023
5053
|
q -= 1
|
|
@@ -5043,9 +5073,10 @@ export class Regex {
|
|
|
5043
5073
|
let w: i32 = 1
|
|
5044
5074
|
if (q >= 0 && q < len) {
|
|
5045
5075
|
const b: i32 = toI32(text.charCodeAt(q))
|
|
5046
|
-
if (b < 128) {
|
|
5047
|
-
|
|
5048
|
-
|
|
5076
|
+
if (b < 128 && b < toI32(cls.length)) {
|
|
5077
|
+
c = cls[b]
|
|
5078
|
+
} else if (b < 128) {
|
|
5079
|
+
return DFA_GAVE_UP
|
|
5049
5080
|
} else {
|
|
5050
5081
|
const lim: i32 = p > from ? from : 0
|
|
5051
5082
|
let cp: i32 = REGEX_INVALID + b
|
package/std/release.ts
CHANGED
|
@@ -75,7 +75,8 @@ export class ReleaseCache {
|
|
|
75
75
|
*/
|
|
76
76
|
export const releaseValidVersion = (v: string): boolean => {
|
|
77
77
|
const n: i32 = toI32(v.length)
|
|
78
|
-
|
|
78
|
+
// biome-ignore lint/style/useExplicitLengthCheck: the panic prover reads `length < 1` as a bound for the charCodeAt(0) after it and does not read `=== 0`
|
|
79
|
+
if (v.length < 1 || n > 64) {
|
|
79
80
|
return false
|
|
80
81
|
}
|
|
81
82
|
const first: i32 = toI32(v.charCodeAt(0))
|
|
@@ -99,18 +100,19 @@ export const releaseValidVersion = (v: string): boolean => {
|
|
|
99
100
|
/** A run of ASCII digits as a number, or -1 when it is empty, too long, has a leading zero or holds anything else. */
|
|
100
101
|
const releaseNumber = (s: string): i64 => {
|
|
101
102
|
const n: i32 = toI32(s.length)
|
|
102
|
-
if (n === 0 || n > 15 || (
|
|
103
|
+
if (n === 0 || n > 15 || (s.length > 1 && s.charCodeAt(0) === 48)) {
|
|
103
104
|
return -1
|
|
104
105
|
}
|
|
105
|
-
|
|
106
|
+
// At most 15 digits, below 2^53, so every step is exact in an `f64`.
|
|
107
|
+
let value: f64 = 0
|
|
106
108
|
for (let i: i32 = 0; i < n; i++) {
|
|
107
109
|
const c: i32 = toI32(s.charCodeAt(i))
|
|
108
110
|
if (c < 48 || c > 57) {
|
|
109
111
|
return -1
|
|
110
112
|
}
|
|
111
|
-
value = value * 10 +
|
|
113
|
+
value = value * 10.0 + toF64(c - 48)
|
|
112
114
|
}
|
|
113
|
-
return value
|
|
115
|
+
return toI64(value)
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
/**
|
|
@@ -155,15 +157,15 @@ export const releaseParseVersion = (v: string): ReleaseVersion | null => {
|
|
|
155
157
|
}
|
|
156
158
|
let core: string = v
|
|
157
159
|
const plus: i32 = toI32(core.indexOf("+"))
|
|
158
|
-
if (plus >= 0) {
|
|
159
|
-
if (plus
|
|
160
|
+
if (plus >= 0 && plus < toI32(core.length)) {
|
|
161
|
+
if (plus === toI32(core.length) - 1 || !releasePreWellFormed(core.slice(plus + 1), false)) {
|
|
160
162
|
return null
|
|
161
163
|
}
|
|
162
164
|
core = core.slice(0, plus)
|
|
163
165
|
}
|
|
164
166
|
let pre: string = ""
|
|
165
167
|
const dash: i32 = toI32(core.indexOf("-"))
|
|
166
|
-
if (dash >= 0) {
|
|
168
|
+
if (dash >= 0 && dash < toI32(core.length)) {
|
|
167
169
|
pre = core.slice(dash + 1)
|
|
168
170
|
core = core.slice(0, dash)
|
|
169
171
|
if (!releasePreWellFormed(pre, true)) {
|
|
@@ -325,7 +327,8 @@ export const releaseTagFromLocation = (base: string, location: string): string |
|
|
|
325
327
|
/** Whether `rest`, what follows a host, is empty, a path, or a port of digits then nothing or a path. */
|
|
326
328
|
const releasePortThenPath = (rest: string): boolean => {
|
|
327
329
|
const n: i32 = toI32(rest.length)
|
|
328
|
-
|
|
330
|
+
// biome-ignore lint/style/useExplicitLengthCheck: the panic prover reads `length < 1` as a bound for the charCodeAt(0) after it and does not read `=== 0`
|
|
331
|
+
if (rest.length < 1 || rest.charCodeAt(0) === 47) {
|
|
329
332
|
return true
|
|
330
333
|
}
|
|
331
334
|
if (rest.charCodeAt(0) !== 58) {
|
|
@@ -335,7 +338,7 @@ const releasePortThenPath = (rest: string): boolean => {
|
|
|
335
338
|
while (i < n && rest.charCodeAt(i) >= 48 && rest.charCodeAt(i) <= 57) {
|
|
336
339
|
i++
|
|
337
340
|
}
|
|
338
|
-
return i > 1 && (i === n || rest.charCodeAt(i) === 47)
|
|
341
|
+
return i > 1 && (i === n || (i < n && rest.charCodeAt(i) === 47))
|
|
339
342
|
}
|
|
340
343
|
|
|
341
344
|
/**
|
|
@@ -518,15 +521,18 @@ export const releaseCacheParse = (text: string): ReleaseCache | null => {
|
|
|
518
521
|
/**
|
|
519
522
|
* Whether a cache checked at `checkedMs` still answers at `nowMs`: younger
|
|
520
523
|
* than `maxAgeMs`, and not dated in the future, which a clock set back or a
|
|
521
|
-
* planted file would give.
|
|
524
|
+
* planted file would give, which covers a clock before 1970. A cache dated
|
|
525
|
+
* before 1970, which only a hand-built one can be, is not fresh either.
|
|
522
526
|
*
|
|
523
527
|
* @param cache The cache.
|
|
524
528
|
* @param nowMs The time now, in milliseconds since 1970.
|
|
525
529
|
* @param maxAgeMs How long an answer stays fresh.
|
|
526
530
|
* @returns True when the cache need not be refreshed.
|
|
527
531
|
*/
|
|
528
|
-
export const releaseCacheFresh = (cache: ReleaseCache, nowMs: i64, maxAgeMs: i64): boolean =>
|
|
529
|
-
|
|
532
|
+
export const releaseCacheFresh = (cache: ReleaseCache, nowMs: i64, maxAgeMs: i64): boolean => {
|
|
533
|
+
const checked: i64 = cache.checkedMs
|
|
534
|
+
return checked >= 0 && nowMs >= 0 && checked <= nowMs && nowMs - checked < maxAgeMs
|
|
535
|
+
}
|
|
530
536
|
|
|
531
537
|
/**
|
|
532
538
|
* Writes the cache at `path`: its directory is created mode 0700 when missing
|