Commit fbfc0e4
feat(shim): cross-runtime (Deno/Bun/Node) + JSR fast-check types
Two bundled changes that both feed the @hyperpolymath/affinescript
0.1.2 publish path.
JSR fast-check: typed entrypoint
--------------------------------
JSR's `deno publish` emits an `unsupported-javascript-entrypoint`
warning whenever a JS module has no associated `.d.ts`. Without the
declaration, JSR falls back to type inference and consumers see no
editor types on the package page. Add `mod.d.ts` (TypeScript carve-
out, same precedent as `packages/affine-js/types.d.ts`) and a
`/// <reference types="./mod.d.ts" />` in `mod.js` so JSR picks it up.
Dry-run is now clean and the published files grow by one 2.87 KB type
file.
Cross-runtime: Deno, Bun, Node
------------------------------
The shim's consumers — LSP installers, IDE extensions, build scripts
wiring AffineScript into a CI pipeline — overwhelmingly live in Node
and Bun ecosystems, not Deno. Forcing them to install Deno solely to
fetch+verify+exec a binary defeats the "ergonomic install" purpose of
the shim. Refactor `mod.js` to detect the runtime once at module
load (`isDeno`/`isBun`/`isNode`) and branch every host effect through
a small helper layer:
hostOs() / hostArch() / envGet() — process.* on Bun+Node, Deno.*
on Deno; arch normalised to
Deno's spelling ("x86_64"/"aarch64")
so hostTarget() stays unchanged.
readBytes() / writeBytes() / mkdirRecursive() / chmodExec()
— Deno.* on Deno, Bun.file/Bun.write
on Bun, node:fs/promises on Node.
spawnInherit() — Deno.Command / Bun.spawn /
node:child_process.spawn.
thisIsMain() — import.meta.main on Deno+Bun;
URL comparison on Node.
The public API (hostTarget, sha256Hex, cachePath, resolveCompiler,
run) is unchanged; mod.d.ts captures the contract.
Browsers and Cloudflare Workers are explicitly NOT supported: the
shim's job is fetch+save+exec, and steps 2–3 are not possible in a
sandboxed JS runtime. Documented inline in the module header.
CLAUDE.md
---------
Add two carve-outs:
- TypeScript Exemptions: `packages/affinescript-cli/mod.d.ts`.
- Runtime Exemptions (NEW section): `packages/affinescript-cli/mod.js`
is the one approved Node+Bun exemption in the repo. Same
"explicit user approval" gate as the TS exemptions.
Verification
------------
- `deno test` (packages/affinescript-cli): 6/6 green (unchanged).
- `deno publish --dry-run`: 4 files including mod.d.ts, no warnings.
- Cross-runtime smoke (hermetic fake fetch + fake binary; same
contract as the Deno suite — download + checksum + cache + exec +
argv passthrough + exit-code):
Deno: OK
Bun: OK
Node: OK
Run under deno 2.x, bun 1.3.14, node 22.11.0.
Refs the @hyperpolymath/affinescript JSR-publish path (post-#295 follow-up).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 686adc1 commit fbfc0e4
3 files changed
Lines changed: 241 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
| |||
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
88 | 99 | | |
89 | 100 | | |
90 | 101 | | |
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
20 | 30 | | |
21 | 31 | | |
22 | 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 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
23 | 157 | | |
24 | | - | |
| 158 | + | |
25 | 159 | | |
26 | 160 | | |
27 | 161 | | |
| |||
42 | 176 | | |
43 | 177 | | |
44 | 178 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
49 | 183 | | |
50 | 184 | | |
51 | 185 | | |
| |||
74 | 208 | | |
75 | 209 | | |
76 | 210 | | |
77 | | - | |
| 211 | + | |
78 | 212 | | |
79 | 213 | | |
80 | 214 | | |
| |||
94 | 228 | | |
95 | 229 | | |
96 | 230 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
101 | 236 | | |
102 | 237 | | |
103 | 238 | | |
104 | 239 | | |
105 | 240 | | |
106 | 241 | | |
107 | 242 | | |
108 | | - | |
| 243 | + | |
109 | 244 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
| 245 | + | |
118 | 246 | | |
119 | 247 | | |
120 | | - | |
121 | | - | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
122 | 253 | | |
0 commit comments