Skip to content
ltgcgoPublic

About

πŸ¦• Continuing Deno's web-first APIs without requiring Deno.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Fly Leaf

Grief is the price we may pay. With flying leaves, sparks, thorns and ember, we may not have to.

Warning

Fly Leaf is not yet ready for prime time. It's currently still being developed as a component of Octavia, with all activities in the parent repository.

Once its completion reaches a certain milestone, it will become an independent project just like Rochelle and Seamstress. Check relevant information before proceeding to incorporate.

πŸ¦• Continuing Deno's web-first APIs without requiring Deno.

This is a best-effort compatibility layer making the global Deno APIs available on multiple runtimes, as well as enforcing a subset of commonly expected web conventions (W3C, WHATWG, WinterTC) onto runtimes that may not conform to such. As the successor of WingBlade, even if Deno and all of its successors vanish, this library can make Deno's legacy far outliving originals. Fly Leaf also makes runtime switching trivial, especially when waiting for security exploits to be patched on the primary runtime.

Fly Leaf makes all runtimes report as Deno 2.9.8, which is the current compatibility target. If relevant runtime features are provided, unstable Deno features will also be provided without a need for the --unstable flag, as that approach isn't feasible on alternative runtimes at all. API documentation available on JSR.

Like the project and want to support it? Learn how in the parent project Octavia (Codeberg, GitHub)!

Looking for runtime container images without Fly Leaf bundled? Check out Stratus(Docker Hub, GitHub Packages, Codeberg Packages, Codeberg, GitHub)!

Quick Start

Vendoring is the current recommended approach for loading Fly Leaf that sidesteps runtime feature support altogether. All examples below assume the library is vendored under ./libs/fly-leaf@ltgcgo/.

Conformance without shims

If you're sure a crashing component is intended for a web-compliant environment without requiring any Deno API or runtime-specific API, you can choose to use the conformance script without Fly Leaf.

  • Ant: ant --preload ./libs/fly-leaf@ltgcgo/vergilius.mjs ...
  • Bun: bun run --preload ./libs/fly-leaf@ltgcgo/vergilius.mjs ...
  • Node.js: node --import ./libs/fly-leaf@ltgcgo/vergilius.mjs ...

Deno globals

The Fly Leaf loader can be used if a component expects Deno globals. If provided in releases, you can use the bell ... (Belladonna) helper instead.

  • Ant: ant --input-type=module --preload ./libs/fly-leaf@ltgcgo/loader.mjs ...
  • Bun: bun run --preload ./libs/fly-leaf@ltgcgo/loader.mjs ...
  • Deno: deno run --preload ./libs/fly-leaf@ltgcgo/loader.mjs ...
  • Ende: ende run --preload ./libs/fly-leaf@ltgcgo/loader.mjs ...
  • Node.js: node --import ./libs/fly-leaf@ltgcgo/loader.mjs ...
  • Porffor: porf --module --import ./libs/fly-leaf@ltgcgo/loader.mjs ...

Async-only variants are available as well.

  • Ant: ant --input-type=module --preload ./libs/fly-leaf@ltgcgo/loadAsync.mjs ...
  • Bun: bun run --preload ./libs/fly-leaf@ltgcgo/loadAsync.mjs ...
  • Deno: deno run --preload ./libs/fly-leaf@ltgcgo/loadAsync.mjs ...
  • Ende: ende run --preload ./libs/fly-leaf@ltgcgo/loadAsync.mjs ...
  • Node.js: node --import ./libs/fly-leaf@ltgcgo/loadAsync.mjs ...
  • Porffor: porf --module --import ./libs/fly-leaf@ltgcgo/loadAsync.mjs ...

All supported runtimes set Deno.version.backend and Deno.version.engine. For a list of valid values, see the runtimes section below.

Runtimes may not actually execute the loader in the context of REPL, so debug with caution. Both Porffor and Txiki do not support preloading.

Force import

To make sure Fly Leaf remains available regardless of runtime, you can import Fly Leaf as a whole in your project, or import the required APIs granularly. Apart from vendoring, you can import via direct HTTP(S) imports, import maps, or JSR, whichever is available and convenient.

If Fly Leaf is going to be included in a pre-compiled bundle intended for a single runtime, use the separate rt.*.mjs versions instead.

// Default import. (recommended)
import Leaf from "./libs/fly-leaf@ltgcgo/leaf.full.mjs";
// Or glob import.
import * as Leaf from "./libs/fly-leaf@ltgcgo/leaf.full.mjs";
// Default import is also available for async-only variants.
import Leaf from "./libs/fly-leaf@ltgcgo/leaf.async.mjs";
// As well as glob import.
import * as Leaf from "./libs/fly-leaf@ltgcgo/leaf.async.mjs";

Support

Variants

Fly Leaf offers two separate variants of the same Deno API. Unless absolutely needed, it's generally recommended to use the async-only variant.

  • Async-only: When both the synchronous and the asynchronous versions of the same API exist, subject to runtime feature availability, this Fly Leaf variant implements only the asynchronous subset of the full variant. This allows Fly Leaf to support more runtimes and use more runtime-native features.
  • Full: This version offers the entire collection of in-scope Deno APIs, subject to runtime feature availability.

Runtimes

S A Runtime backend engine IMM UEP
βœ“ βœ“ Ant Ant Ant Silver 15.1+ ?
βœ“ βœ“ Bun Bun JavaScriptCore 0.6+ N/A
βœ“ βœ“ Deno Deno V8 1.0+ N/A
βœ“ βœ“ Ende Ende V8 20261014+ N/A
βœ“ βœ“ Node.js Node V8 22.18+, 24.2+ 22.21+, 24.0+
βœ“ βœ“ Porffor Porffor Porffor alpha 20+ ?
Γ— βœ“ Txiki.js Txiki QuickJS ? ?
  • IMM: import.meta.main

  • UEP: NODE_USE_ENV_PROXY

  • Ant: WIP.

    • If tests and benchmarks are not supported, Fly Leaf will use its own universal fallback.
  • Bun: WIP.

  • Deno: Supported.

  • Ende: Supported.

    • Deno.version.deno set to the Deno version targeted by Fly Leaf.
  • Generic browser: Async-only. Blocked by various fundamentally missing APIs, subject to runtime feature availability.

  • Generic WinterTC: Async-only. Blocked by various fundamentally missing APIs, subject to runtime feature availability.

  • Node.js: WIP.

  • Porffor: WIP.

    • Not recommended for validation due to upfront AOT costs. If tests and benchmarks are not supported, Fly Leaf will use its own universal fallback.
  • Txiki.js: Async-only, WIP. Linux builds available here, currently without FFI support.

    • Fly Leaf uses its own universal fallback for tests and benchmarks, as tjs test isn't an actual validation suite runner.
  • a-Shell JSC: Out of scope. Basic FS access, insufficient platform APIs.

  • Boa: Out of scope. Not an actual runtime.

  • Javy: Out of scope. Insufficient platform APIs.

  • Kiesel: Out of scope. Not an actual runtime.

  • Steve's Den: Out of scope. Insufficient documentation, and the den:* import scheme is the exact thing Fly Leaf avoids, despite being older than Ende.

As a side effect of offering Deno APIs on runtimes without them, Fly Leaf also tests whether a runtime upholds JS features and their own advertised feature sets.

Additional features

Common baseline

  • Testing and benchmarking: Whenever an environment lacks native validator and benchmark runners, Fly Leaf will supply its own fallback version. Setting LEAF_BASIC_VALIDATOR to 1 forces such fallbacks regardless of runtime availability.
  • Tracing: For certain operations and APIs, Fly Leaf (or Vergilius) offers traces printed in the standard output. Setting VERGILIUS_PRINT_TRACE to 0 or leaving it unset to disable it, or to 1 (light), 2 (medium), 3 (deep) and 4 (insane) to enable various levels of verbosity.

Deno deprecated

These are the features deprecated by the Deno runtime. Fly Leaf re-implements all of the ones listed below, with the remaining deprecated APIs completely absent.

Any deprecated feature that relies on resource IDs will not be re-implemented.

Web

Out-of-scope

Deno features

  • Bundling (Deno.bundle), for now. Use an external bundler like ESBuild, tdewolff Minify or SWC, some of which can be directly used on runtimes supporting WebAssembly. May be reversed in the future with optional ESBuild interfacing.
  • Cloud hosting. Fly Leaf is a compatibility layer, not a hosting provider.
  • HTTP imports. Unlike require() in CommonJS, ESM imports cannot be intercepted at all by solutions like Fly Leaf, as such it is solely up to the runtime to support HTTP imports. If the runtime does not support HTTP imports, you'll have to choose among loading bundles via importer ponyfills, vendoring, or registry mirroring.
    • This also means that Fly Leaf is unable to block runtime-native imports like node: and npm:. If you want to be absolutely certain your codebase does not rely on Node.js, please use Ende with or without Fly Leaf.
  • import.meta polyfilling. import.meta needs native runtime support, as Fly Leaf is purely unable to modify the entire import.meta object.
    • import.meta.main: Check the IMM column in the runtime table. Any older version will cause projects relying on its value being truthy break (e.g. ESBuild Deno CLI).
  • Jupyter Notebook, for now. Until the separate module is ready, please use dedicated Jupyter integration frameworks/libraries.
  • KV Store (Deno.openKv), for now. Use the storage APIs or external databases. May be reversed in the future.
  • Linter (Deno.lint). Use external language servers like Deno, Ende, typescript-language-server, vstls or ESLint.
  • Node.js-API Native Addon. Use FFI or WASM instead.
  • Permissions. Without native runtime enforcement, permissions checks are likely bypassed easily, as such Fly Leaf does not attempt to perform permission gating and report everything as green-lit instead. If the non-Deno-compatible runtime does offer permission gating, Fly Leaf will bridge it.
  • Sandbox. Use proper sandboxes, like containers on runsc, Sysbox and Bubblewrap instead. Fly Leaf is not and should not be used as a sandbox out-of-the-box. On runtimes like Ende where runtime-native globals can be fully replaced, Fly Leaf can allow Minuette-like safer interception after modification.
  • Telemetry. Deno relied on Node.js compatibility to interact with OpenTelemetry via npm:@opentelemetry, and its own documentation telemetry APIs are incomplete.
  • TypeScript. Fly Leaf is not a TypeScript transpiler, use runtimes with native TypeScript support, external bundlers, or TypeScript transpilers instead.

About

πŸ¦• Continuing Deno's web-first APIs without requiring Deno.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

Generated from ltgcgo/hyacinth