Commit 741650b
committed
Bun compatibility for IO and HTTP
In the interest of supporting Bun, this commit makes many breaking
changes across existing modules. It also introduces Bun-specific IO
and HTTP modules, and auto-resolution between environment-specific
modules via `package.json` `imports` directives.
Due to inevitable breaking changes, opportunity was taken to cleanup
some other modules as well.
---
Breaking: replaced `live_deno.mjs` with a reworked `http_live.mjs`.
This module now works in both Bun and Deno.
---
Breaking: replaced `http_srv.mjs` with a reworked `http_shared.mjs`.
Added `concatStreams`.
Moved `EXT_TO_MIME_TYPE` and `guessContentType` to this file.
All features of this module are also exported by `http_deno.mjs`
and the new `http_bun.mjs`.
---
`http_deno.mjs`:
Breaking:
- Dropped:
- `isErrCancel`
- `dirAbs`
- `dirRel`
- `DirBase`
- `Fil`
- `HttpFileInfo` (see `HttpFile`)
- `HttpFileStream` (no longer needed in Deno)
- Renamed:
- `DirBase` → `BaseHttpDir`
- `DirAbs` → `HttpDir`
- `DirRel` → `HttpDir`
- `DirRelFil` → `HttpDir` (merged 3 into 1)
- `Dirs` → `HttpDirs`
- All "resolve file" directory methods now require a properly parsed
URL pathname string, expecting the caller to handle its parsing.
However, they do perform URL component decoding.
Added: `HttpFile`, which serves the same role as the earlier
`HttpFileInfo`, with almost the same API.
---
Added `http_bun.mjs` whose API nearly mirrors `http_deno.mjs`.
The environment-appropriate module is auto-resolved when importing
the pseudo-module `http`.
---
`io_deno.mjs`:
Breaking:
- Dropped:
- `create` (use `writeFile`)
- `touch`
- `readTextCreate`
- `readJson`
- `filterWatch`
- `FileInfo`
- `isReader`
- `reqReader`
- `isCloser`
- `reqCloser`
- `ReaderStreamSource` (no longer needed in Deno)
- `FileStream` (no longer needed in Deno)
- `EnvMap`
- Renamed:
- `readText` → `readFileText`
- `readTextOpt` → `readFileTextOpt`
- `readTextSync` → `readFileTextSync`
- `readTextSyncOpt` → `readFileTextOptSync`
- Moved:
- `ConcatStreamSource`: to `http_shared.mjs` / `http_deno.mjs`.
- Modified:
- `watchCwd` and `watchRel` now yield events one-by-one.
Added:
- `ENV`
- `exit`
- `skipErrNotFound`
- `readFileBytes`
- `readFileBytesSync`
- `writeFileSync`
- `remove`
- `removeSync`
- `exists`
- `existsSync`
- `stat`
- `statSync`
- `statOpt`
- `statOptSync`
- `fileReadStream`
- `fileWriteStream`
- `readDir`
- `readDirSync`
- `validPath`
---
Added `io_bun.mjs` whose API almost mirrors `io_deno.mjs`, with some
differences which are expensive to fix:
- No `fileWriteStream`.
- `readDir` and `readDirSync` list strings, not stringable objects
with metadata.
The environment-appropriate module is auto-resolved when importing
the pseudo-module `io`.
---
`dom.mjs`:
Breaking: dropped:
- `DOM_EXISTS`
- `isDomHandler`
- `reqDomHandler`
- `optDomHandler`
- `addEvents`
- `removeEvents`
- `clipNode`
- `setText`
- `mutDoc`
- `DocHeadMut`
- `DocBodyMut`
- `DocFoc`
Added:
- `eventDispatch`
- `eventListen`
- `ListenRef`
---
`http.mjs`:
Breaking: dropped:
- `Ctx..link`
- `Ctx..unlink`
- `Ctx..handleEvent`
- `Ctx..sub`
Improved memory management in `Ctx`. When linking a `Ctx` against a
parent signal, the signal and the child context now hold each other
weakly, via `ListenRef`. User code is now free to drop either the
parent signal or the child context without calling `.abort`, and the
dropped object will now be eligible for GC while the other one is
still in use. When a child context is GC-d, its listener is removed
from the parent signal. In engines without support for `WeakRef` or
`FinalizationRegistry`, references work as before this change.
Added `notFound`.
---
`iter.mjs`:
Breaking:
- Dropped:
- `setOf`
- `setCopy`
- `mapOf`
- Renamed:
- `setFrom` → `toSet`
---
`path.mjs`:
Breaking: dropped:
- `isPath` (use `lang.mjs` → `isScalar`)
- `reqPath` (use `lang.mjs` → `reqScalar`)
- `optPath` (use `lang.mjs` → `optScalar`)
Added `hasExt` which should be slightly faster than `!!ext(path)`.
---
`prax.mjs`:
`Ren..replaceChi` now avoids touching child nodes which occur in the
exact same positions at the start of both lists: existing child nodes
and new list of putative child nodes; but only at the start. This
avoids side-effectful disconnect / reconnect when repeatedly passing
the same starting children for the same target element.
---
`lang.mjs`:
Added `errSkip`.1 parent 83d369e commit 741650b
File tree
100 files changed
+2960
-2494
lines changed- docs
- doc
- cli
- http
- test
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
100 files changed
+2960
-2494
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
145 | | - | |
| 144 | + | |
146 | 145 | | |
147 | 146 | | |
148 | 147 | | |
| |||
215 | 214 | | |
216 | 215 | | |
217 | 216 | | |
218 | | - | |
| 217 | + | |
219 | 218 | | |
220 | 219 | | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
221 | 226 | | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
229 | 232 | | |
230 | 233 | | |
231 | 234 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
14 | 14 | | |
0 commit comments