@amritk/nish-x86_64-linux 0.18.0 → 0.21.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 +58 -28
- package/bin/nish +0 -0
- package/docs/AI.md +2759 -0
- package/package.json +3 -2
- package/runtime/browser.d.ts +14 -0
- package/runtime/browser.mjs +88 -0
- package/runtime/core/arrays.d.ts +18 -0
- package/runtime/core/arrays.mjs +125 -0
- package/runtime/core/checks.mjs +20 -0
- package/runtime/core/host.d.ts +70 -0
- package/runtime/core/host.mjs +311 -0
- package/runtime/core/numbers.d.ts +53 -0
- package/runtime/core/numbers.mjs +316 -0
- package/runtime/core/result.d.ts +41 -0
- package/runtime/core/result.mjs +127 -0
- package/runtime/core/strings.d.ts +14 -0
- package/runtime/core/strings.mjs +169 -0
- package/runtime/core.d.ts +9 -0
- package/runtime/core.mjs +55 -0
- package/runtime/host.d.ts +6 -0
- package/runtime/nish.d.ts +99 -5
- package/runtime/nish.h +289 -19
- package/runtime/nish.mjs +39 -3
- package/runtime/node.mjs +383 -0
- package/runtime/runtime-aes.c +490 -0
- package/runtime/runtime-bytes.c +401 -0
- package/runtime/runtime-cross.c +366 -0
- package/runtime/runtime-host.c +8 -7
- package/runtime/runtime-net.c +93 -34
- package/runtime/runtime-os.c +214 -16
- package/runtime/runtime-parallel.c +590 -107
- package/runtime/runtime-simd.c +235 -11
- package/runtime/runtime-term.c +504 -0
- package/runtime/runtime-wasm.c +5 -14
- package/runtime/runtime.c +257 -17
- package/runtime/shim.mjs +6 -915
- package/runtime/sqlite/LICENSE.md +85 -0
- package/runtime/sqlite/README.md +45 -0
- package/runtime/sqlite/nish-sqlite.c +359 -0
- package/runtime/sqlite/sqlite3.c +271131 -0
- package/runtime/sqlite/sqlite3.h +14447 -0
- package/scripts/build.sh +437 -28
- package/std/LICENSE-fast-float +23 -0
- package/std/LICENSE-fdlibm +8 -0
- package/std/README.md +108 -58
- package/std/base64.ts +116 -0
- package/std/bytes.ts +419 -0
- package/std/cli.ts +328 -0
- package/std/collections.ts +6 -5
- package/std/crypto/LICENSE-crypt_blowfish +26 -0
- package/std/crypto/LICENSE-libsecp256k1 +19 -0
- package/std/crypto/aes.ts +238 -76
- package/std/crypto/base64url.ts +125 -0
- package/std/crypto/bcrypt.ts +760 -0
- package/std/crypto/chacha20poly1305.ts +43 -9
- package/std/crypto/ed25519.ts +840 -0
- package/std/crypto/hkdf.ts +304 -12
- package/std/crypto/hmac.ts +382 -54
- package/std/crypto/p256.ts +932 -61
- package/std/crypto/x25519.ts +55 -37
- package/std/crypto/x509-random.ts +71 -0
- package/std/crypto/x509.ts +20 -131
- package/std/json-tokenizer.ts +4237 -0
- package/std/json-typed.ts +1014 -0
- package/std/json-value.ts +1182 -0
- package/std/json.ts +1202 -34
- package/std/math.ts +608 -0
- package/std/net/buffer-pool.ts +151 -0
- package/std/net/hpack.ts +416 -112
- package/std/net/http-fields.ts +93 -0
- package/std/net/http1-server.ts +501 -62
- package/std/net/http1.ts +31 -6
- package/std/net/http2-tls.ts +112 -24
- package/std/net/http2.ts +333 -75
- package/std/net/http3-server.ts +261 -43
- package/std/net/http3.ts +187 -28
- package/std/net/postgres.ts +1875 -0
- package/std/net/prefork.ts +412 -0
- package/std/net/quic-listener.ts +108 -11
- package/std/net/quic-packet.ts +243 -82
- package/std/net/quic-recovery.ts +361 -30
- package/std/net/quic-stream.ts +424 -24
- package/std/net/quic.ts +519 -167
- package/std/net/router.ts +676 -0
- package/std/net/tls/codec.ts +426 -27
- package/std/net/tls/record-server.ts +478 -132
- package/std/net/tls/record.ts +133 -42
- package/std/net/tls/schedule.ts +464 -55
- package/std/net/tls/ticket.ts +610 -0
- package/std/net/tls-tcp.ts +196 -53
- package/std/net/tls.ts +1018 -260
- package/std/net/url.ts +571 -0
- package/std/random.ts +94 -0
- package/std/regex.ts +4274 -0
- package/std/sqlite.ts +391 -0
- package/std/term-io.ts +978 -0
- package/std/term-pixels.ts +874 -0
- package/std/term-probe.ts +459 -0
- package/std/term-rate.ts +993 -0
- package/std/term.ts +2453 -0
- package/std/text.ts +90 -7
- package/std/threads.ts +438 -14
- package/std/yaml-lines.ts +141 -0
- package/std/yaml.ts +4675 -0
package/std/cli.ts
ADDED
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `std/cli` — a command-line tool's help menu: whether a stream gets colour,
|
|
3
|
+
* the escapes that paint it, and the rows a `--help` is made of.
|
|
4
|
+
*
|
|
5
|
+
* import { HelpMenu, agentDriven, styleFor } from "nish/cli";
|
|
6
|
+
*
|
|
7
|
+
* const menu = new HelpMenu(styleFor(1, agentDriven()), "greet", 30, 40);
|
|
8
|
+
* menu.header("1.0.0", "say hello");
|
|
9
|
+
* menu.usage("<name> [flags]", "greet someone");
|
|
10
|
+
* menu.section("Flags");
|
|
11
|
+
* menu.row("--shout", "", "in capitals");
|
|
12
|
+
* menu.row("--times", "<n>", "say it n times");
|
|
13
|
+
* console.log(menu.text());
|
|
14
|
+
*
|
|
15
|
+
* **The terminal's own colours.** A `Style` paints with the eight basic SGR
|
|
16
|
+
* colours, bold and faint, never a fixed RGB or 256-palette tone. Every theme
|
|
17
|
+
* redefines those eight, so the menu comes out in whatever palette the reader
|
|
18
|
+
* chose, and a terminal with no theme set paints them in its built-in
|
|
19
|
+
* defaults. A terminal with no colours at all (`tput colors` says fewer than
|
|
20
|
+
* eight) gets the failsafe: the same structure in bold and underline, which a
|
|
21
|
+
* monochrome terminal still shows. Colour that is forced is the theme's.
|
|
22
|
+
*
|
|
23
|
+
* **Colour is for a person reading a terminal**, and nothing else may see it:
|
|
24
|
+
* a script that captures `--help`, a test that compares it, a pipe into `less`
|
|
25
|
+
* without `-R` all want the plain bytes. So `styleFor` decides per stream, by
|
|
26
|
+
* asking whether that stream is a terminal, and the conventions people already
|
|
27
|
+
* set win over the guess: `NO_COLOR` (https://no-color.org) turns it off, and
|
|
28
|
+
* `CLICOLOR_FORCE` or `FORCE_COLOR` turns it on for a pager that understands
|
|
29
|
+
* escapes. The plain text is the same bytes either way, and a row's padding is
|
|
30
|
+
* counted on the plain text, so the columns line up with or without escapes.
|
|
31
|
+
*
|
|
32
|
+
* **An agent is a reader of its own kind**: it may drive a pseudo-terminal, so
|
|
33
|
+
* the terminal check says yes, but every escape is tokens it pays for and
|
|
34
|
+
* reads past. `agentDriven` says when one is at the keyboard, and `styleFor`
|
|
35
|
+
* is then plain whatever forcing variable its shell inherited.
|
|
36
|
+
*
|
|
37
|
+
* **What it reaches.** `Style` and `HelpMenu` reach no capability. `styleFor`
|
|
38
|
+
* reads the environment and, on the terminal check, forks a shell
|
|
39
|
+
* (`env` and `process.spawn`),
|
|
40
|
+
* and `agentDriven` reads the environment; a program that builds its `Style`
|
|
41
|
+
* by hand reaches neither.
|
|
42
|
+
*
|
|
43
|
+
* **The compiler's own help is built with it**, through a relative import from
|
|
44
|
+
* `src/cli-style.ts`, so this file is compiled by the last release as part of
|
|
45
|
+
* the compiler: it may use only what that release compiles (the rolling
|
|
46
|
+
* freeze, `.claude/selfhost.md`), which is why it asks the shell whether a
|
|
47
|
+
* descriptor is a terminal rather than calling `nish:term`'s `isTerminal`.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/** The Control Sequence Introducer every SGR escape opens with. */
|
|
51
|
+
const CSI: string = "\u001b["
|
|
52
|
+
|
|
53
|
+
/** `paletteOf`'s answer: marked up in the theme's colours. */
|
|
54
|
+
const PALETTE_THEME: i32 = 0
|
|
55
|
+
|
|
56
|
+
/** `paletteOf`'s answer: marked up in attributes only, the failsafe. */
|
|
57
|
+
const PALETTE_MONO: i32 = 2
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* How one output stream is painted. `on` says whether to mark the text up at
|
|
61
|
+
* all, and `colour` whether the terminal has colours to mark it up with;
|
|
62
|
+
* without them each mark falls back to bold, underline or nothing.
|
|
63
|
+
*/
|
|
64
|
+
export class Style {
|
|
65
|
+
on: boolean
|
|
66
|
+
colour: boolean
|
|
67
|
+
|
|
68
|
+
constructor(on: boolean, colour: boolean) {
|
|
69
|
+
this.on = on
|
|
70
|
+
this.colour = colour
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* `text` wrapped in the escape for `themed` (an SGR parameter list in the
|
|
75
|
+
* theme's basic colours) or `mono` (attributes only), and a reset after it;
|
|
76
|
+
* `text` unchanged when marking up is off or the chosen list is empty, so a
|
|
77
|
+
* caller never has to ask.
|
|
78
|
+
*/
|
|
79
|
+
paint(text: string, themed: string, mono: string): string {
|
|
80
|
+
const code = this.colour ? themed : mono
|
|
81
|
+
if (!this.on || text.length === 0 || code.length === 0) {
|
|
82
|
+
return text
|
|
83
|
+
}
|
|
84
|
+
return `${CSI}${code}m${text}${CSI}0m`
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** A section heading: bold, in the theme's magenta. */
|
|
88
|
+
heading(text: string): string {
|
|
89
|
+
return this.paint(text, "1;35", "1")
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** The tool's own name where it opens a line. */
|
|
93
|
+
name(text: string): string {
|
|
94
|
+
return this.paint(text, "1;35", "1")
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** A flag, or a command a person would type. */
|
|
98
|
+
flag(text: string): string {
|
|
99
|
+
return this.paint(text, "36", "1")
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** A placeholder the person fills in: `<file.ts>`, `speed|size`. */
|
|
103
|
+
meta(text: string): string {
|
|
104
|
+
return this.paint(text, "33", "4")
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Text that explains rather than names: descriptions, notes. Faint rather
|
|
109
|
+
* than bright black, which Solarized makes the background; plain without
|
|
110
|
+
* colour, where the bold flags already stand apart from it.
|
|
111
|
+
*/
|
|
112
|
+
dim(text: string): string {
|
|
113
|
+
return this.paint(text, "2", "")
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Whether the environment variable `name` is set to something other than empty. */
|
|
118
|
+
const envIsSet = (name: string): boolean => {
|
|
119
|
+
const value = getenv(name)
|
|
120
|
+
return value !== null && value.length > 0
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Whether `value` spells `word`, which is lower case, in any ASCII case. */
|
|
124
|
+
const spells = (value: string, word: string): boolean => {
|
|
125
|
+
if (value.length !== word.length) {
|
|
126
|
+
return false
|
|
127
|
+
}
|
|
128
|
+
// Both bounds, though the lengths match: the checker proves an index in range
|
|
129
|
+
// only for a string its loop condition names.
|
|
130
|
+
for (let i: i32 = 0; i < toI32(value.length) && i < toI32(word.length); i++) {
|
|
131
|
+
let code: i32 = toI32(value.charCodeAt(i))
|
|
132
|
+
if (code >= 65 && code <= 90) {
|
|
133
|
+
code = code + 32
|
|
134
|
+
}
|
|
135
|
+
if (code !== toI32(word.charCodeAt(i))) {
|
|
136
|
+
return false
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return true
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Whether `value` is a no: `0`, `false`, `no` or `off`, in any case. */
|
|
143
|
+
const isNo = (value: string): boolean =>
|
|
144
|
+
value === "0" || spells(value, "false") || spells(value, "no") || spells(value, "off")
|
|
145
|
+
|
|
146
|
+
/** Whether a variable's `value` is set to a no (`isNo`). */
|
|
147
|
+
const saysNo = (value: string | null): boolean => value !== null && isNo(value)
|
|
148
|
+
|
|
149
|
+
/** Whether a variable's `value` is set and says yes: not empty, and not a no. */
|
|
150
|
+
const saysYes = (value: string | null): boolean => value !== null && value.length > 0 && !isNo(value)
|
|
151
|
+
|
|
152
|
+
/** Whether the variable `name` is set to a no (`saysNo`). */
|
|
153
|
+
const envSaysNo = (name: string): boolean => saysNo(getenv(name))
|
|
154
|
+
|
|
155
|
+
/** Whether the variable `name` says yes (`saysYes`). */
|
|
156
|
+
const envSaysYes = (name: string): boolean => saysYes(getenv(name))
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* What terminal descriptor `fd` is: `PALETTE_THEME`, `PALETTE_MONO`, or
|
|
160
|
+
* anything else for no terminal, which is plain text. The shell answers: a
|
|
161
|
+
* child inherits the descriptors and the environment, `[ -t 1 ]` is POSIX,
|
|
162
|
+
* and `tput colors` reads the count `TERM`'s terminfo entry declares (`-1` for
|
|
163
|
+
* none). `tput` is run by absolute path, never looked up on `PATH`, so a
|
|
164
|
+
* `PATH` with `.` in it cannot run a `tput` planted in the working directory
|
|
165
|
+
* (`docs/security/cli.md`). When there is no `tput` there, or it does not know
|
|
166
|
+
* `TERM`, the answer is the theme: almost every terminal has colours, and an
|
|
167
|
+
* escape a monochrome one does not know it drops. It costs one fork of the
|
|
168
|
+
* shell and, on a terminal, one of `tput`. Where nothing can be spawned (a
|
|
169
|
+
* WebAssembly build) the answer is `-1`, which is plain text, the safe side.
|
|
170
|
+
*/
|
|
171
|
+
const paletteOf = (fd: i32): i32 => {
|
|
172
|
+
const tty = `[ -t ${fd} ] || exit 1; `
|
|
173
|
+
const find = "t=/usr/bin/tput; [ -x $t ] || t=/bin/tput; [ -x $t ] || exit 0; "
|
|
174
|
+
const count = "c=$($t colors 2>/dev/null) || exit 0; case $c in ''|*[!0-9-]*) exit 0;; esac; "
|
|
175
|
+
return toI32(spawnSync(["/bin/sh", "-c", `${tty}${find}${count}[ "$c" -ge 8 ] || exit ${PALETTE_MONO}`]))
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** The style for a `paletteOf` answer: the theme, the failsafe, or plain. */
|
|
179
|
+
const styleOfPalette = (palette: i32): Style => {
|
|
180
|
+
if (palette === PALETTE_THEME) {
|
|
181
|
+
return new Style(true, true)
|
|
182
|
+
}
|
|
183
|
+
return new Style(palette === PALETTE_MONO, false)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Whether an agent, rather than a person, is running the program.
|
|
188
|
+
* `NISH_AGENT` answers for any agent: a no (`envSaysNo`) for no, any other
|
|
189
|
+
* value for yes. Without it, the variables the agents that set one put in
|
|
190
|
+
* their commands' environment (Claude Code's `CLAUDECODE`, Gemini CLI's
|
|
191
|
+
* `GEMINI_CLI`) say yes.
|
|
192
|
+
*/
|
|
193
|
+
export const agentDriven = (): boolean => {
|
|
194
|
+
if (envIsSet("NISH_AGENT")) {
|
|
195
|
+
return !envSaysNo("NISH_AGENT")
|
|
196
|
+
}
|
|
197
|
+
return envSaysYes("CLAUDECODE") || envSaysYes("GEMINI_CLI")
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* The style for descriptor `fd` (1 or 2), for a reader `agent` says is an
|
|
202
|
+
* agent or not (`agentDriven`, asked once by the caller). `NO_COLOR` wins,
|
|
203
|
+
* then an agent, then `FORCE_COLOR` saying no (`isNo`; Node reads `0` and
|
|
204
|
+
* `false` so), then a forcing variable, then `CLICOLOR` saying no or
|
|
205
|
+
* `TERM=dumb`, and only then the terminal check, where the colours `TERM`
|
|
206
|
+
* declares choose between the theme and the failsafe (`paletteOf`). Forced
|
|
207
|
+
* colour is the theme's, asked of nothing: the reader is a pager or an editor
|
|
208
|
+
* that renders the escapes itself (Emacs's shell sets `TERM=dumb` and paints
|
|
209
|
+
* ANSI colour), so `TERM` does not describe it, and forcing forks nothing.
|
|
210
|
+
*/
|
|
211
|
+
export const styleFor = (fd: i32, agent: boolean): Style => {
|
|
212
|
+
const level = getenv("FORCE_COLOR")
|
|
213
|
+
if (envIsSet("NO_COLOR") || agent || saysNo(level)) {
|
|
214
|
+
return new Style(false, false)
|
|
215
|
+
}
|
|
216
|
+
if (saysYes(level) || envSaysYes("CLICOLOR_FORCE")) {
|
|
217
|
+
return new Style(true, true)
|
|
218
|
+
}
|
|
219
|
+
const term = getenv("TERM")
|
|
220
|
+
if (envSaysNo("CLICOLOR") || (term !== null && term === "dumb")) {
|
|
221
|
+
return new Style(false, false)
|
|
222
|
+
}
|
|
223
|
+
return styleOfPalette(paletteOf(fd))
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** A run of spaces to cut padding from, as wide as a terminal's usual 80 columns. */
|
|
227
|
+
const SPACE_RUN: string = " "
|
|
228
|
+
|
|
229
|
+
/** `count` spaces, or none when `count` is not positive: a cut of `SPACE_RUN`, built only past its width. */
|
|
230
|
+
const spaces = (count: i32): string => {
|
|
231
|
+
if (count <= 0) {
|
|
232
|
+
return ""
|
|
233
|
+
}
|
|
234
|
+
if (count <= toI32(SPACE_RUN.length)) {
|
|
235
|
+
return SPACE_RUN.substring(0, count)
|
|
236
|
+
}
|
|
237
|
+
const out: string[] = []
|
|
238
|
+
for (let i: i32 = 0; i < count; i++) {
|
|
239
|
+
out.push(" ")
|
|
240
|
+
}
|
|
241
|
+
return out.join("")
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* The spaces that take plain text `width` columns wide to `column`, or two
|
|
246
|
+
* when that would leave fewer, so a long flag still keeps apart from its text.
|
|
247
|
+
*/
|
|
248
|
+
const padTo = (width: i32, column: i32): string => spaces(width + 2 <= column ? column - width : 2)
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* A help menu, built a line at a time and answered whole by `text`. Rows are
|
|
252
|
+
* indented two columns and their descriptions start at `column`; usage lines'
|
|
253
|
+
* descriptions start at `usageColumn`, past the longest command shape. Every
|
|
254
|
+
* width is counted on the plain text, one column a byte, so the columns line
|
|
255
|
+
* up whether or not `style` paints, as long as the text is ASCII.
|
|
256
|
+
*/
|
|
257
|
+
export class HelpMenu {
|
|
258
|
+
style: Style
|
|
259
|
+
program: string
|
|
260
|
+
column: i32
|
|
261
|
+
usageColumn: i32
|
|
262
|
+
lines: string[]
|
|
263
|
+
usages: i32
|
|
264
|
+
|
|
265
|
+
constructor(style: Style, program: string, column: i32, usageColumn: i32) {
|
|
266
|
+
this.style = style
|
|
267
|
+
this.program = program
|
|
268
|
+
this.column = column
|
|
269
|
+
this.usageColumn = usageColumn
|
|
270
|
+
this.lines = []
|
|
271
|
+
this.usages = 0
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/** The opening line, the program's name, `version` and a one-line `summary`, and a blank after it. */
|
|
275
|
+
header(version: string, summary: string): void {
|
|
276
|
+
const style = this.style
|
|
277
|
+
this.lines.push(`${style.name(this.program)} ${style.dim(version)} ${style.dim(summary)}`)
|
|
278
|
+
this.lines.push("")
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* A usage line: the command `shape` after the program's name, and what it
|
|
283
|
+
* is for (`description` may be empty). The first opens with `usage:` and
|
|
284
|
+
* the rest are indented under it.
|
|
285
|
+
*/
|
|
286
|
+
usage(shape: string, description: string): void {
|
|
287
|
+
const style = this.style
|
|
288
|
+
const lead = this.usages === 0 ? `${style.heading("usage:")} ` : spaces(7)
|
|
289
|
+
const width: i32 = 8 + toI32(this.program.length) + toI32(shape.length)
|
|
290
|
+
const text = description.length > 0 ? `${padTo(width, this.usageColumn)}${style.dim(description)}` : ""
|
|
291
|
+
this.lines.push(`${lead}${style.name(this.program)} ${style.flag(shape)}${text}`)
|
|
292
|
+
this.usages = this.usages + 1
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/** A section: a blank line, then `title` as a heading. */
|
|
296
|
+
section(title: string): void {
|
|
297
|
+
this.lines.push("")
|
|
298
|
+
this.lines.push(this.style.heading(title))
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* One row: the `flag` (or a command), its placeholder `meta` (may be
|
|
303
|
+
* empty), and what it does, the description starting at `column`.
|
|
304
|
+
*/
|
|
305
|
+
row(flag: string, meta: string, description: string): void {
|
|
306
|
+
const style = this.style
|
|
307
|
+
const width: i32 = 2 + toI32(flag.length) + (meta.length > 0 ? 1 + toI32(meta.length) : 0)
|
|
308
|
+
const placeholder = meta.length > 0 ? ` ${style.meta(meta)}` : ""
|
|
309
|
+
this.lines.push(
|
|
310
|
+
` ${style.flag(flag)}${placeholder}${padTo(width, this.column)}${style.dim(description)}`
|
|
311
|
+
)
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/** An indented line of prose, faint. */
|
|
315
|
+
note(text: string): void {
|
|
316
|
+
this.lines.push(` ${this.style.dim(text)}`)
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/** An indented line the reader fills in or opens, a path or a value, as a placeholder. */
|
|
320
|
+
value(text: string): void {
|
|
321
|
+
this.lines.push(` ${this.style.meta(text)}`)
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/** The menu so far, its lines joined by newlines, with no newline after the last. */
|
|
325
|
+
text(): string {
|
|
326
|
+
return this.lines.join("\n")
|
|
327
|
+
}
|
|
328
|
+
}
|
package/std/collections.ts
CHANGED
|
@@ -53,11 +53,12 @@ const INDEX_CAP: i32 = 16777215
|
|
|
53
53
|
const INITIAL_SLOTS: i32 = 8
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
|
-
* The key's hash, never 0:
|
|
57
|
-
*
|
|
58
|
-
* integer
|
|
59
|
-
*
|
|
60
|
-
*
|
|
56
|
+
* The key's hash, never 0: SipHash-1-3 of a string's bytes under the process's
|
|
57
|
+
* random key, folded to 32 bits (docs/security/json.md, JSON-13), murmur3's
|
|
58
|
+
* `fmix32` for an integer of 32 bits or fewer, `fmix64` folded to 32 bits for a
|
|
59
|
+
* 64-bit integer, a float (normalised first, so that -0 and +0, and every NaN,
|
|
60
|
+
* hash alike) and a class instance's address (§5.2). SipHash's reference is
|
|
61
|
+
* CC0; MurmurHash3 and its constants are public domain.
|
|
61
62
|
*
|
|
62
63
|
* The body is never emitted. Every call is lowered in place, per key type, by
|
|
63
64
|
* `src/emit-map.ts`; the constant is what the checker and the whole-program
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
crypt_blowfish (https://www.openwall.com/crypt/), version 1.3, crypt_blowfish.c
|
|
2
|
+
|
|
3
|
+
Written by Solar Designer <solar at openwall.com> in 1998-2014.
|
|
4
|
+
No copyright is claimed, and the software is hereby placed in the public
|
|
5
|
+
domain. In case this attempt to disclaim copyright and place the software
|
|
6
|
+
in the public domain is deemed null and void, then the software is
|
|
7
|
+
Copyright (c) 1998-2014 Solar Designer and it is hereby released to the
|
|
8
|
+
general public under the following terms:
|
|
9
|
+
|
|
10
|
+
Redistribution and use in source and binary forms, with or without
|
|
11
|
+
modification, are permitted.
|
|
12
|
+
|
|
13
|
+
There's ABSOLUTELY NO WARRANTY, express or implied.
|
|
14
|
+
|
|
15
|
+
It is my intent that you should be able to use this on your system,
|
|
16
|
+
as part of a software package, or anywhere else to improve security,
|
|
17
|
+
ensure compatibility, or for any other purpose. I would appreciate
|
|
18
|
+
it if you give credit where it is due and keep your modifications in
|
|
19
|
+
the public domain as well, but I don't require that in order to let
|
|
20
|
+
you place this code and any modifications you make under a license
|
|
21
|
+
of your choice.
|
|
22
|
+
|
|
23
|
+
This implementation is fully compatible with OpenBSD's bcrypt.c for prefix
|
|
24
|
+
"$2b$", originally by Niels Provos <provos at citi.umich.edu>, and it uses
|
|
25
|
+
some of his ideas. The password hashing algorithm was designed by David
|
|
26
|
+
Mazieres <dm at lcs.mit.edu>.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2013 Pieter Wuille
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|