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.
Files changed (178) hide show
  1. package/fjs/basen/cbase32/module.f.mjs +18 -10
  2. package/fjs/basen/cbase32/proof.f.d.mts +3 -0
  3. package/fjs/basen/cbase32/proof.f.mjs +24 -2
  4. package/fjs/basen/proof.f.mjs +8 -16
  5. package/fjs/bnf/ll1/proof.f.d.mts +2 -0
  6. package/fjs/bnf/ll1/proof.f.mjs +33 -18
  7. package/fjs/bnf/module.f.d.mts +2 -2
  8. package/fjs/bnf/module.f.mjs +2 -2
  9. package/fjs/cas/proof.f.mjs +4 -26
  10. package/fjs/ci/common/module.f.mjs +6 -0
  11. package/fjs/ci/config/module.f.d.mts +7 -7
  12. package/fjs/ci/config/module.f.mjs +7 -7
  13. package/fjs/cli/module.f.mjs +14 -10
  14. package/fjs/crypto/vdf/module.f.d.mts +0 -1
  15. package/fjs/crypto/vdf/module.f.mjs +3 -14
  16. package/fjs/dev/module.f.mjs +10 -20
  17. package/fjs/djs/parser/module.f.d.mts +101 -53
  18. package/fjs/djs/parser/module.f.mjs +732 -525
  19. package/fjs/djs/parser/proof.f.d.mts +6 -0
  20. package/fjs/djs/parser/proof.f.mjs +315 -11
  21. package/fjs/djs/parser/types.d.ts +29 -2
  22. package/fjs/djs/tokenizer/module.f.mjs +122 -105
  23. package/fjs/djs/tokenizer/proof.f.mjs +17 -0
  24. package/fjs/djs/transpiler/module.f.mjs +4 -5
  25. package/fjs/djs/transpiler/proof.f.d.mts +2 -0
  26. package/fjs/djs/transpiler/proof.f.mjs +25 -0
  27. package/fjs/edag/amnesia/module.f.d.mts +20 -0
  28. package/fjs/edag/amnesia/module.f.mjs +303 -0
  29. package/fjs/edag/amnesia/proof.f.d.mts +79 -0
  30. package/fjs/edag/amnesia/proof.f.mjs +573 -0
  31. package/fjs/edag/amnesia/types.d.ts +15 -0
  32. package/fjs/edag/module.f.d.mts +410 -0
  33. package/fjs/edag/module.f.mjs +559 -0
  34. package/fjs/edag/proof.f.d.mts +116 -0
  35. package/fjs/edag/proof.f.mjs +686 -0
  36. package/fjs/edag/types.d.ts +55 -0
  37. package/fjs/effects/node/memory/module.d.mts +37 -3
  38. package/fjs/effects/node/memory/module.mjs +38 -4
  39. package/fjs/effects/node/memory/proof.d.mts +5 -2
  40. package/fjs/effects/node/memory/proof.mjs +36 -6
  41. package/fjs/effects/node/module.d.mts +9 -1
  42. package/fjs/effects/node/module.f.d.mts +39 -0
  43. package/fjs/effects/node/module.f.mjs +46 -0
  44. package/fjs/effects/node/module.mjs +234 -32
  45. package/fjs/effects/node/types.d.ts +28 -2
  46. package/fjs/effects/node/virtual/module.f.d.mts +19 -10
  47. package/fjs/effects/node/virtual/module.f.mjs +246 -32
  48. package/fjs/effects/node/virtual/proof.f.d.mts +17 -2
  49. package/fjs/effects/node/virtual/proof.f.mjs +232 -8
  50. package/fjs/effects/node/virtual/types.d.ts +57 -1
  51. package/fjs/emergent_testing/browser/proof.d.mts +55 -0
  52. package/fjs/emergent_testing/browser/proof.mjs +352 -0
  53. package/fjs/emergent_testing/browser/species.proof.d.mts +4 -0
  54. package/fjs/emergent_testing/browser/species.proof.mjs +45 -0
  55. package/fjs/emergent_testing/browser.d.mts +79 -0
  56. package/fjs/emergent_testing/browser.mjs +432 -0
  57. package/fjs/emergent_testing/proof.f.d.mts +1 -1
  58. package/fjs/emergent_testing/proof.f.mjs +2 -2
  59. package/fjs/js/string_escape/module.f.d.mts +47 -0
  60. package/fjs/js/string_escape/module.f.mjs +95 -0
  61. package/fjs/js/string_escape/proof.f.d.mts +8 -0
  62. package/fjs/js/string_escape/proof.f.mjs +68 -0
  63. package/fjs/js/tokenizer/module.f.mjs +14 -12
  64. package/fjs/mcp/cas/module.f.d.mts +1 -7
  65. package/fjs/mcp/cas/module.f.mjs +24 -15
  66. package/fjs/mcp/evo/module.f.mjs +9 -24
  67. package/fjs/mcp/module.f.d.mts +3 -1
  68. package/fjs/mcp/module.f.mjs +4 -2
  69. package/fjs/media/json/rtti/module.f.d.mts +2 -2
  70. package/fjs/media/json/rtti/module.f.mjs +1 -1
  71. package/fjs/media/json/schema/module.f.d.mts +15 -5
  72. package/fjs/media/json/schema/module.f.mjs +42 -15
  73. package/fjs/media/json/schema/proof.f.d.mts +10 -1
  74. package/fjs/media/json/schema/proof.f.mjs +88 -16
  75. package/fjs/media/json/serializer/module.f.mjs +14 -26
  76. package/fjs/media/json/types.d.ts +1 -1
  77. package/fjs/media/lock/module.f.d.mts +8 -3
  78. package/fjs/media/lock/module.f.mjs +9 -3
  79. package/fjs/media/lock/proof.f.d.mts +1 -1
  80. package/fjs/media/lock/proof.f.mjs +2 -2
  81. package/fjs/media/lock/types.d.ts +1 -3
  82. package/fjs/media/module.f.d.mts +20 -13
  83. package/fjs/media/module.f.mjs +29 -16
  84. package/fjs/media/note/module.f.d.mts +14 -7
  85. package/fjs/media/note/module.f.mjs +14 -7
  86. package/fjs/media/note/proof.f.mjs +1 -1
  87. package/fjs/media/proof.f.mjs +5 -5
  88. package/fjs/media/revision/module.f.d.mts +8 -2
  89. package/fjs/media/revision/module.f.mjs +9 -3
  90. package/fjs/media/revision/proof.f.mjs +1 -1
  91. package/fjs/media/revision/types.d.ts +1 -1
  92. package/fjs/media/type/module.f.d.mts +20 -0
  93. package/fjs/media/type/module.f.mjs +74 -0
  94. package/fjs/media/type/proof.f.d.mts +5 -0
  95. package/fjs/media/type/proof.f.mjs +24 -1
  96. package/fjs/module.f.mjs +6 -0
  97. package/fjs/path/module.f.d.mts +60 -3
  98. package/fjs/path/module.f.mjs +138 -14
  99. package/fjs/path/proof.f.d.mts +3 -0
  100. package/fjs/path/proof.f.mjs +298 -2
  101. package/fjs/protocol/json_rpc/module.f.d.mts +65 -28
  102. package/fjs/protocol/json_rpc/module.f.mjs +49 -13
  103. package/fjs/protocol/json_rpc/proof.f.d.mts +4 -0
  104. package/fjs/protocol/json_rpc/proof.f.mjs +29 -0
  105. package/fjs/protocol/json_rpc/types.d.ts +12 -2
  106. package/fjs/protocol/mcp/module.f.d.mts +89 -54
  107. package/fjs/protocol/mcp/module.f.mjs +110 -56
  108. package/fjs/protocol/mcp/proof.f.d.mts +13 -0
  109. package/fjs/protocol/mcp/proof.f.mjs +107 -7
  110. package/fjs/protocol/mcp/stdio/module.f.mjs +3 -4
  111. package/fjs/protocol/mcp/stdio/proof.f.mjs +2 -2
  112. package/fjs/protocol/mcp/types.d.ts +14 -2
  113. package/fjs/text/utf8/module.f.mjs +27 -1
  114. package/fjs/text/utf8/proof.f.mjs +37 -0
  115. package/fjs/types/array/module.f.mjs +18 -11
  116. package/fjs/types/array/proof.f.mjs +27 -1
  117. package/fjs/types/bigfloat/module.f.d.mts +48 -9
  118. package/fjs/types/bigfloat/module.f.mjs +147 -59
  119. package/fjs/types/bigfloat/proof.f.d.mts +2 -0
  120. package/fjs/types/bigfloat/proof.f.mjs +136 -4
  121. package/fjs/types/bigfloat/types.d.ts +17 -0
  122. package/fjs/types/function/module.f.d.mts +11 -2
  123. package/fjs/types/function/module.f.mjs +20 -2
  124. package/fjs/types/function/proof.f.mjs +5 -1
  125. package/fjs/types/phantom/types.d.ts +21 -0
  126. package/fjs/types/result/module.f.d.mts +4 -4
  127. package/fjs/types/result/module.f.mjs +2 -2
  128. package/fjs/types/result/proof.f.d.mts +6 -2
  129. package/fjs/types/result/proof.f.mjs +17 -1
  130. package/fjs/types/rtti/common/module.f.d.mts +78 -5
  131. package/fjs/types/rtti/common/module.f.mjs +168 -3
  132. package/fjs/types/rtti/common/proof.f.d.mts +14 -0
  133. package/fjs/types/rtti/common/proof.f.mjs +61 -2
  134. package/fjs/types/rtti/common/types.d.ts +23 -1
  135. package/fjs/types/rtti/data/module.f.d.mts +57 -1
  136. package/fjs/types/rtti/data/module.f.mjs +241 -47
  137. package/fjs/types/rtti/data/proof.f.d.mts +10 -0
  138. package/fjs/types/rtti/data/proof.f.mjs +272 -39
  139. package/fjs/types/rtti/data/types.d.ts +14 -7
  140. package/fjs/types/rtti/host.proof.d.mts +33 -0
  141. package/fjs/types/rtti/host.proof.mjs +170 -0
  142. package/fjs/types/rtti/module.f.d.mts +51 -6
  143. package/fjs/types/rtti/module.f.mjs +50 -3
  144. package/fjs/types/rtti/parse/module.f.d.mts +31 -24
  145. package/fjs/types/rtti/parse/module.f.mjs +197 -59
  146. package/fjs/types/rtti/parse/proof.f.d.mts +37 -2
  147. package/fjs/types/rtti/parse/proof.f.mjs +171 -47
  148. package/fjs/types/rtti/proof.f.d.mts +6 -0
  149. package/fjs/types/rtti/proof.f.mjs +42 -1
  150. package/fjs/types/rtti/ts/module.f.d.mts +9 -3
  151. package/fjs/types/rtti/ts/module.f.mjs +68 -15
  152. package/fjs/types/rtti/ts/proof.f.d.mts +42 -2
  153. package/fjs/types/rtti/ts/proof.f.mjs +139 -6
  154. package/fjs/types/rtti/ts/types.d.ts +164 -16
  155. package/fjs/types/rtti/types.d.ts +31 -3
  156. package/fjs/types/rtti/validate/module.f.d.mts +120 -0
  157. package/fjs/types/rtti/validate/module.f.mjs +351 -0
  158. package/fjs/types/rtti/validate/proof.f.d.mts +154 -0
  159. package/fjs/types/rtti/validate/proof.f.mjs +781 -0
  160. package/fjs/types/ts/types.d.ts +4 -0
  161. package/fjs/web/module.f.d.mts +115 -0
  162. package/fjs/web/module.f.mjs +581 -0
  163. package/fjs/web/proof.f.d.mts +39 -0
  164. package/fjs/web/proof.f.mjs +413 -0
  165. package/fjs/web/types.d.ts +39 -0
  166. package/fjs/website/browser-prepare.d.mts +5 -0
  167. package/fjs/website/browser-prepare.mjs +115 -0
  168. package/fjs/website/browser-source.d.mts +37 -0
  169. package/fjs/website/browser-source.mjs +202 -0
  170. package/fjs/website/browser-source.proof.d.mts +31 -0
  171. package/fjs/website/browser-source.proof.mjs +162 -0
  172. package/fjs/website/browser.d.mts +5 -0
  173. package/fjs/website/browser.mjs +8 -0
  174. package/fjs/website/module.f.d.mts +3 -3
  175. package/fjs/website/module.f.mjs +62 -9
  176. package/fjs/website/proof.f.d.mts +4 -0
  177. package/fjs/website/proof.f.mjs +18 -3
  178. package/package.json +2 -3
@@ -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>;