Skip to content

ESB64 1.0.0

Choose a tag to compare

@thelabcorner thelabcorner released this 07 Aug 17:14
· 11 commits to master since this release

ESB64 - ExtendScript Base64: a drop-in atob/btoa polyfill plus UTF-8 codec library for ExtendScript (ES3) engines. First stable release.

What ESB64 does

  • Drop-in atob/btoa - true polyfill semantics: installs the globals only when absent, leaves a correct native alone; standard InvalidCharacterError-named errors
  • WHATWG forgiving-base64 atob - whitespace stripped, missing padding tolerated, length % 4 == 1 and non-alphabet characters rejected; matches the WPT base64.json corpus (80/80 vectors) that browsers themselves are tested against
  • Extended UTF-8 lanes (encodeUtf8 / decodeUtf8, utf8Encode / utf8Decode) - WHATWG TextEncoder/Decoder semantics; round-trips any Unicode through base64
  • Fast in the ES3 engine - the UTF-8 encode fast path rides the engine's native escaping functions (~50x over hand-rolled on 450 KB); an ASCII-identity fast path skips the decode state machine entirely; two-tier memoization makes repeat 1 MB payloads ~1000x faster
  • Engine-hardened - charCodeAt-based scanning (the engine's charAt is NUL-broken), array+join output building, split bitwise temporaries (the engine mis-compiles mixed |/& chains)
  • ES3-safe - no let/const/Promise; ES5 TypeScript target, esbuild platform=neutral
  • No runtime dependencies - four artifacts, nothing to install

Attachments

File Purpose
vendor-esb64.js Production drop-in: ESB64 + gap-fill install footer (28.6 KB)
ESB64.jsx Bannerless IIFE facade ($.evalFile / COM-eval safe); defines ESB64
vendor-esb64-runtime.js Slim atob/btoa-only vendor (15.8 KB) for per-eval injection
esb64-core.esm.mjs ESM core bundle for Node/automation (19 exports)

Validation (v1.0.0)

  • npm test: 411 Node assertions - PASS (WPT base64.json corpus + differential vs native + UTF-8)
  • Fuzz: 144,000 differential checks vs V8 native atob/btoa, Node Buffer and TextDecoder, 0 divergences (12,000 iterations/lane, seed 12648430)
  • Live engine battery (Illustrator 30.6.0 / ExtendScript 4.5.6): 66/66 vectors (documented in README; re-run via npm run live-verify)
  • typecheck (tsc strict): clean

Notes

  • The UTF-8 decoder follows WHATWG error grouping (one U+FFFD per bad sequence), not Node's ICU-backed TextDecoder (one per bad byte); malformed-sequence expectations are hardcoded vectors
  • The engine has no native base64 at all (probed live: typeof atob === "undefined") - ESB64 fills the gap
  • License: GPL-3.0-or-later