functionalscript 0.46.0 → 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/fjs/basen/cbase32/module.f.mjs +18 -10
- package/fjs/basen/cbase32/proof.f.d.mts +3 -0
- package/fjs/basen/cbase32/proof.f.mjs +24 -2
- package/fjs/basen/proof.f.mjs +8 -16
- package/fjs/bnf/ll1/proof.f.d.mts +2 -0
- package/fjs/bnf/ll1/proof.f.mjs +33 -18
- package/fjs/bnf/module.f.d.mts +2 -2
- package/fjs/bnf/module.f.mjs +2 -2
- package/fjs/cas/proof.f.mjs +4 -26
- package/fjs/ci/common/module.f.mjs +6 -0
- package/fjs/ci/config/module.f.d.mts +7 -7
- package/fjs/ci/config/module.f.mjs +7 -7
- package/fjs/cli/module.f.mjs +14 -10
- package/fjs/crypto/vdf/module.f.d.mts +0 -1
- package/fjs/crypto/vdf/module.f.mjs +3 -14
- package/fjs/dev/module.f.mjs +10 -20
- package/fjs/djs/parser/module.f.d.mts +101 -53
- package/fjs/djs/parser/module.f.mjs +732 -525
- package/fjs/djs/parser/proof.f.d.mts +6 -0
- package/fjs/djs/parser/proof.f.mjs +315 -11
- package/fjs/djs/parser/types.d.ts +29 -2
- package/fjs/djs/tokenizer/module.f.mjs +122 -105
- package/fjs/djs/tokenizer/proof.f.mjs +17 -0
- package/fjs/djs/transpiler/module.f.mjs +4 -5
- package/fjs/djs/transpiler/proof.f.d.mts +2 -0
- package/fjs/djs/transpiler/proof.f.mjs +25 -0
- package/fjs/edag/amnesia/module.f.d.mts +20 -0
- package/fjs/edag/amnesia/module.f.mjs +303 -0
- package/fjs/edag/amnesia/proof.f.d.mts +79 -0
- package/fjs/edag/amnesia/proof.f.mjs +573 -0
- package/fjs/edag/amnesia/types.d.ts +15 -0
- package/fjs/edag/module.f.d.mts +410 -0
- package/fjs/edag/module.f.mjs +559 -0
- package/fjs/edag/proof.f.d.mts +116 -0
- package/fjs/edag/proof.f.mjs +686 -0
- package/fjs/edag/types.d.ts +55 -0
- package/fjs/effects/node/memory/module.d.mts +37 -3
- package/fjs/effects/node/memory/module.mjs +38 -4
- package/fjs/effects/node/memory/proof.d.mts +5 -2
- package/fjs/effects/node/memory/proof.mjs +36 -6
- package/fjs/effects/node/module.d.mts +9 -1
- package/fjs/effects/node/module.f.d.mts +39 -0
- package/fjs/effects/node/module.f.mjs +46 -0
- package/fjs/effects/node/module.mjs +234 -32
- package/fjs/effects/node/types.d.ts +28 -2
- package/fjs/effects/node/virtual/module.f.d.mts +19 -10
- package/fjs/effects/node/virtual/module.f.mjs +246 -32
- package/fjs/effects/node/virtual/proof.f.d.mts +17 -2
- package/fjs/effects/node/virtual/proof.f.mjs +232 -8
- package/fjs/effects/node/virtual/types.d.ts +57 -1
- package/fjs/emergent_testing/browser/proof.d.mts +55 -0
- package/fjs/emergent_testing/browser/proof.mjs +352 -0
- package/fjs/emergent_testing/browser/species.proof.d.mts +4 -0
- package/fjs/emergent_testing/browser/species.proof.mjs +45 -0
- package/fjs/emergent_testing/browser.d.mts +79 -0
- package/fjs/emergent_testing/browser.mjs +432 -0
- package/fjs/emergent_testing/proof.f.d.mts +1 -1
- package/fjs/emergent_testing/proof.f.mjs +2 -2
- package/fjs/js/string_escape/module.f.d.mts +47 -0
- package/fjs/js/string_escape/module.f.mjs +95 -0
- package/fjs/js/string_escape/proof.f.d.mts +8 -0
- package/fjs/js/string_escape/proof.f.mjs +68 -0
- package/fjs/js/tokenizer/module.f.mjs +14 -12
- package/fjs/mcp/cas/module.f.d.mts +1 -7
- package/fjs/mcp/cas/module.f.mjs +24 -15
- package/fjs/mcp/evo/module.f.mjs +9 -24
- package/fjs/mcp/module.f.d.mts +3 -1
- package/fjs/mcp/module.f.mjs +4 -2
- package/fjs/media/json/rtti/module.f.d.mts +2 -2
- package/fjs/media/json/rtti/module.f.mjs +1 -1
- package/fjs/media/json/schema/module.f.d.mts +15 -5
- package/fjs/media/json/schema/module.f.mjs +42 -15
- package/fjs/media/json/schema/proof.f.d.mts +10 -1
- package/fjs/media/json/schema/proof.f.mjs +88 -16
- package/fjs/media/json/serializer/module.f.mjs +14 -26
- package/fjs/media/json/types.d.ts +1 -1
- package/fjs/media/lock/module.f.d.mts +8 -3
- package/fjs/media/lock/module.f.mjs +9 -3
- package/fjs/media/lock/proof.f.d.mts +1 -1
- package/fjs/media/lock/proof.f.mjs +2 -2
- package/fjs/media/lock/types.d.ts +1 -3
- package/fjs/media/module.f.d.mts +20 -13
- package/fjs/media/module.f.mjs +29 -16
- package/fjs/media/note/module.f.d.mts +14 -7
- package/fjs/media/note/module.f.mjs +14 -7
- package/fjs/media/note/proof.f.mjs +1 -1
- package/fjs/media/proof.f.mjs +5 -5
- package/fjs/media/revision/module.f.d.mts +8 -2
- package/fjs/media/revision/module.f.mjs +9 -3
- package/fjs/media/revision/proof.f.mjs +1 -1
- package/fjs/media/revision/types.d.ts +1 -1
- package/fjs/media/type/module.f.d.mts +20 -0
- package/fjs/media/type/module.f.mjs +74 -0
- package/fjs/media/type/proof.f.d.mts +5 -0
- package/fjs/media/type/proof.f.mjs +24 -1
- package/fjs/module.f.mjs +6 -0
- package/fjs/path/module.f.d.mts +60 -3
- package/fjs/path/module.f.mjs +138 -14
- package/fjs/path/proof.f.d.mts +3 -0
- package/fjs/path/proof.f.mjs +298 -2
- package/fjs/protocol/json_rpc/module.f.d.mts +65 -28
- package/fjs/protocol/json_rpc/module.f.mjs +49 -13
- package/fjs/protocol/json_rpc/proof.f.d.mts +4 -0
- package/fjs/protocol/json_rpc/proof.f.mjs +29 -0
- package/fjs/protocol/json_rpc/types.d.ts +12 -2
- package/fjs/protocol/mcp/module.f.d.mts +89 -54
- package/fjs/protocol/mcp/module.f.mjs +110 -56
- package/fjs/protocol/mcp/proof.f.d.mts +13 -0
- package/fjs/protocol/mcp/proof.f.mjs +107 -7
- package/fjs/protocol/mcp/stdio/module.f.mjs +3 -4
- package/fjs/protocol/mcp/stdio/proof.f.mjs +2 -2
- package/fjs/protocol/mcp/types.d.ts +14 -2
- package/fjs/text/utf8/module.f.mjs +27 -1
- package/fjs/text/utf8/proof.f.mjs +37 -0
- package/fjs/types/array/module.f.mjs +18 -11
- package/fjs/types/array/proof.f.mjs +27 -1
- package/fjs/types/bigfloat/module.f.d.mts +48 -9
- package/fjs/types/bigfloat/module.f.mjs +147 -59
- package/fjs/types/bigfloat/proof.f.d.mts +2 -0
- package/fjs/types/bigfloat/proof.f.mjs +136 -4
- package/fjs/types/bigfloat/types.d.ts +17 -0
- package/fjs/types/function/module.f.d.mts +11 -2
- package/fjs/types/function/module.f.mjs +20 -2
- package/fjs/types/function/proof.f.mjs +5 -1
- package/fjs/types/phantom/types.d.ts +21 -0
- package/fjs/types/result/module.f.d.mts +4 -4
- package/fjs/types/result/module.f.mjs +2 -2
- package/fjs/types/result/proof.f.d.mts +6 -2
- package/fjs/types/result/proof.f.mjs +17 -1
- package/fjs/types/rtti/common/module.f.d.mts +78 -5
- package/fjs/types/rtti/common/module.f.mjs +168 -3
- package/fjs/types/rtti/common/proof.f.d.mts +14 -0
- package/fjs/types/rtti/common/proof.f.mjs +61 -2
- package/fjs/types/rtti/common/types.d.ts +23 -1
- package/fjs/types/rtti/data/module.f.d.mts +57 -1
- package/fjs/types/rtti/data/module.f.mjs +241 -47
- package/fjs/types/rtti/data/proof.f.d.mts +10 -0
- package/fjs/types/rtti/data/proof.f.mjs +272 -39
- package/fjs/types/rtti/data/types.d.ts +14 -7
- package/fjs/types/rtti/host.proof.d.mts +33 -0
- package/fjs/types/rtti/host.proof.mjs +170 -0
- package/fjs/types/rtti/module.f.d.mts +51 -6
- package/fjs/types/rtti/module.f.mjs +50 -3
- package/fjs/types/rtti/parse/module.f.d.mts +31 -24
- package/fjs/types/rtti/parse/module.f.mjs +197 -59
- package/fjs/types/rtti/parse/proof.f.d.mts +37 -2
- package/fjs/types/rtti/parse/proof.f.mjs +171 -47
- package/fjs/types/rtti/proof.f.d.mts +6 -0
- package/fjs/types/rtti/proof.f.mjs +42 -1
- package/fjs/types/rtti/ts/module.f.d.mts +9 -3
- package/fjs/types/rtti/ts/module.f.mjs +68 -15
- package/fjs/types/rtti/ts/proof.f.d.mts +42 -2
- package/fjs/types/rtti/ts/proof.f.mjs +139 -6
- package/fjs/types/rtti/ts/types.d.ts +164 -16
- package/fjs/types/rtti/types.d.ts +31 -3
- package/fjs/types/rtti/validate/module.f.d.mts +120 -0
- package/fjs/types/rtti/validate/module.f.mjs +351 -0
- package/fjs/types/rtti/validate/proof.f.d.mts +154 -0
- package/fjs/types/rtti/validate/proof.f.mjs +781 -0
- package/fjs/types/ts/types.d.ts +4 -0
- package/fjs/web/module.f.d.mts +115 -0
- package/fjs/web/module.f.mjs +581 -0
- package/fjs/web/proof.f.d.mts +39 -0
- package/fjs/web/proof.f.mjs +413 -0
- package/fjs/web/types.d.ts +39 -0
- package/fjs/website/browser-prepare.d.mts +5 -0
- package/fjs/website/browser-prepare.mjs +115 -0
- package/fjs/website/browser-source.d.mts +37 -0
- package/fjs/website/browser-source.mjs +202 -0
- package/fjs/website/browser-source.proof.d.mts +31 -0
- package/fjs/website/browser-source.proof.mjs +162 -0
- package/fjs/website/browser.d.mts +5 -0
- package/fjs/website/browser.mjs +8 -0
- package/fjs/website/module.f.d.mts +3 -3
- package/fjs/website/module.f.mjs +62 -9
- package/fjs/website/proof.f.d.mts +4 -0
- package/fjs/website/proof.f.mjs +18 -3
- package/package.json +2 -3
package/fjs/types/ts/types.d.ts
CHANGED
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
7
7
|
export type Equal<A, B> = (<T>() => T extends A ? 1 : 2) extends (<T>() => T extends B ? 1 : 2) ? true : false;
|
|
8
|
+
export type And<A extends boolean, B extends boolean> = [
|
|
9
|
+
A,
|
|
10
|
+
B
|
|
11
|
+
] extends [true, true] ? true : false;
|
|
8
12
|
/**
|
|
9
13
|
* A `struct` field: the key, its type expression, and — when the third
|
|
10
14
|
* element is `true` — an optional-key marker (`"key"?: type`).
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A static file server: `fjs web [root] [port]` maps each request path to a
|
|
3
|
+
* file under `root` and answers with its bytes.
|
|
4
|
+
*
|
|
5
|
+
* The module is split so that the decision is pure and the socket handling is a
|
|
6
|
+
* thin shell around it. `resolve` turns a URL into a path and does every check
|
|
7
|
+
* that can be made without touching the disk; `respond` reads the file that
|
|
8
|
+
* path names and builds the response frame, performing IO but no networking;
|
|
9
|
+
* `main` is the only part that creates a server, listens, and blocks. That is
|
|
10
|
+
* why `respond` can be proven end to end against an in-memory file system.
|
|
11
|
+
*
|
|
12
|
+
* ## Responses
|
|
13
|
+
*
|
|
14
|
+
* | case | status |
|
|
15
|
+
* |-----------------------------------------------|--------|
|
|
16
|
+
* | file found | `200` |
|
|
17
|
+
* | `GET`/`HEAD` on a missing, dot-prefixed, or non-regular path | `404` |
|
|
18
|
+
* | any other method | `405` with `Allow` |
|
|
19
|
+
* | a `Host` this server does not answer for | `403` |
|
|
20
|
+
* | a path that escapes `root`, or an undecodable URL | `400` |
|
|
21
|
+
* | a file larger than one `Vec` | `413` |
|
|
22
|
+
* | any other host failure | `500` |
|
|
23
|
+
*
|
|
24
|
+
* Failures carry a `text/plain` body. Nothing else is configurable in this
|
|
25
|
+
* version — no directory listing, no range requests, no compression, no caching
|
|
26
|
+
* headers, no TLS.
|
|
27
|
+
*
|
|
28
|
+
* See `./README.md` for what is deliberately absent, and `./types.ts` for the
|
|
29
|
+
* type-level API.
|
|
30
|
+
*
|
|
31
|
+
* @module
|
|
32
|
+
*
|
|
33
|
+
* @import { Effect } from '../effects/types.ts'
|
|
34
|
+
* @import { FileStat, IoChannel, Program, ReadFile, ServerResponse } from '../effects/node/types.ts'
|
|
35
|
+
* @import { Nullable } from '../types/nullable/types.ts'
|
|
36
|
+
* @import { Result } from '../types/result/types.ts'
|
|
37
|
+
* @import { Vec } from '../types/bit_vec/types.ts'
|
|
38
|
+
* @import { Refusal, Resolve, Respond, WebOp } from './types.ts'
|
|
39
|
+
*/
|
|
40
|
+
import type { Program } from '../effects/node/types.ts';
|
|
41
|
+
import type { Nullable } from '../types/nullable/types.ts';
|
|
42
|
+
import type { Resolve, Respond, WebOp } from './types.ts';
|
|
43
|
+
export type _Target = {
|
|
44
|
+
readonly authority: Nullable<string>;
|
|
45
|
+
readonly path: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Maps a request URL to a path under `root`, or explains why none exists.
|
|
49
|
+
*
|
|
50
|
+
* A directory request — a path ending in `/`, including the bare `/` — is
|
|
51
|
+
* answered with its `index.html`, which is what makes a generated site browsable
|
|
52
|
+
* at all.
|
|
53
|
+
*
|
|
54
|
+
* An empty `root` is read as the working directory — see {@link served}.
|
|
55
|
+
*
|
|
56
|
+
* **Dot-prefixed segments are not served.** `.git/config`, `.env` and
|
|
57
|
+
* `.ssh/id_rsa` are the files whose exposure the loopback binding exists to
|
|
58
|
+
* prevent, and a static server that hands them to anyone who asks has the
|
|
59
|
+
* boundary in the wrong place. The answer is `404` rather than `403`: whether
|
|
60
|
+
* such a file exists is itself the thing not being disclosed.
|
|
61
|
+
*
|
|
62
|
+
* **A NUL is a malformed URL, not a host error.** `%00` decodes to a byte no
|
|
63
|
+
* path can contain; left to the file system it comes back as an
|
|
64
|
+
* `ERR_INVALID_ARG_VALUE` and a `500`, reporting a host failure for what is
|
|
65
|
+
* plainly a bad request.
|
|
66
|
+
*
|
|
67
|
+
* **Traversal is rejected in segment space, not by string comparison.**
|
|
68
|
+
* `escapes` folds the path with its root taken off, so a `..` with nothing left
|
|
69
|
+
* to cancel survives to be counted; that is the whole check. `parse` cannot
|
|
70
|
+
* answer it — `parse` folds *with* the root in place, and clamping away such a
|
|
71
|
+
* `..` is precisely what it does, which is why reading its output for one
|
|
72
|
+
* silently stopped working. Nor is taking the root off the same as dropping a
|
|
73
|
+
* leading `/`: the remainder of `///../x` is `//../x`, which reads as rooted
|
|
74
|
+
* again, so the question belongs to `fjs/path` rather than to string surgery
|
|
75
|
+
* here. Comparing the joined path against `root` textually is the weaker test;
|
|
76
|
+
* it became expressible once `normalize` began keeping roots, and is still not
|
|
77
|
+
* what is done.
|
|
78
|
+
*
|
|
79
|
+
* @type {Resolve}
|
|
80
|
+
*/
|
|
81
|
+
export declare const resolve: Resolve;
|
|
82
|
+
export type _TooLarge = readonly ['tooLarge', number];
|
|
83
|
+
export type _NotRegular = readonly ['notRegular'];
|
|
84
|
+
/**
|
|
85
|
+
* Answers one request: resolve, read, and frame the result.
|
|
86
|
+
*
|
|
87
|
+
* The host is checked first, against the loopback names this server answers for
|
|
88
|
+
* — see {@link servedHosts} for why binding loopback is not enough on its own.
|
|
89
|
+
* An absolute-form target names its own host, and RFC 9112 §3.2.2 says to
|
|
90
|
+
* believe that over the `Host` header.
|
|
91
|
+
*
|
|
92
|
+
* `HEAD` is answered exactly like `GET`, bytes included: Node drops the body of
|
|
93
|
+
* a `HEAD` response itself and keeps the headers, so the one frame serves both
|
|
94
|
+
* — and because {@link response} states `Content-Length`, a `HEAD` client still
|
|
95
|
+
* learns the size it asked for.
|
|
96
|
+
*
|
|
97
|
+
* @type {Respond}
|
|
98
|
+
*/
|
|
99
|
+
export declare const respond: Respond;
|
|
100
|
+
/**
|
|
101
|
+
* `fjs web [root] [port]` — serve `root` (default `.`) on `port` (default
|
|
102
|
+
* `8080`), bound to {@link loopback}.
|
|
103
|
+
*
|
|
104
|
+
* Both arguments are positional because `fjs/cli` has no notion of a named
|
|
105
|
+
* option yet; `port` becomes `--port` once one exists, and `--host` is what
|
|
106
|
+
* would let a caller bind anything but loopback.
|
|
107
|
+
*
|
|
108
|
+
* The chain ends in `forever`, so the program only stops when the process does.
|
|
109
|
+
* A runner that cannot block forever answers `notImplemented` there, which is
|
|
110
|
+
* how the whole program remains runnable — and observable — under the virtual
|
|
111
|
+
* runner.
|
|
112
|
+
*
|
|
113
|
+
* @type {Program<WebOp>}
|
|
114
|
+
*/
|
|
115
|
+
export declare const main: Program<WebOp>;
|