Skip to content

v1.0.0

Latest

Choose a tag to compare

@jgonet jgonet released this 27 Oct 15:06
· 3 commits to main since this release
43ba25b

Hello! Popcorn reached another milestone, which is:

🥁🥁🥁

OTP/BEAM support!

The full blog post explaining why we did such a move and how it works now can be found here.

In the meantime...

Added features

  • Popcorn now runs on OTP/BEAM (OTP 29.0.6, Elixir 1.20.4).
    • You can pass custom environment variables, options, and flags.
    • Use schedulers() to set scheduler counts. We use one scheduler of each type by default.
  • async send() in JS sends messages to VM processes; trySend() returns a result object.
  • Req adapter using browser fetch() for HTTP requests from Elixir.
  • We now support interactive terminal I/O through writeStdin() and resizeTty().
  • Popcorn.JS.available?/0 was added to detect if we're running in the browser.
  • The bridge supports atoms, tuples, PID handles, binaries, BigInt, Date, Map, and Set.

Changed features

  • Popcorn.Wasm is now Popcorn.JS; run_js() and run_js!() are now run() and run!(). JS functions receive (args, actions) and return values directly.
  • async call() in JS has a tryCall() variant.
  • cast() in JS is now asynchronous and has a tryCast() variant.
  • call() and cast() are now forwarded through Popcorn.Proxy to GenServers. The proxy starts automatically under the :popcorn application.
  • onMessage() in JS is now onEvent(). Send events with Popcorn.JS.send/1; the callback receives a single value.
  • PopcornInternalError and error codes are now PopcornError. We use structured errors, with t (type) and data fields.
  • JS try* methods return result objects ({ok: true, data} | {ok: false, error}). Other fallible methods throw or reject on failure.
  • %Popcorn.TrackedObject{} is replaced by handles from new TrackedValue(value, cleanup), with optional cleanup functions.
  • Applications now ship as tarballs instead of .avm bundles.
  • The VM now runs in Web Workers instead of an iframe plus Web Workers. JS interop runs in the page.

Removed features

  • AtomVM is now unsupported.
  • registerLogListener() and unregisterLogListener() were removed. Dispatch logs through onStdout and onStderr callbacks.
  • heartbeatTimeoutMs and onReload were removed. Use the onError callback to observe VM failures.
  • durationMs field in responses.
  • Wasm.ready/0,1. We now use the normal OTP application lifecycle.
  • Wasm.get_tracked_values/1 and Wasm.get_tracked_values!/1. Pass handles into Popcorn.JS.run/3 to access their values.
  • Wasm.register_event_listener/2 and Wasm.unregister_event_listener/1. Use addEventListener() and removeEventListener() inside Popcorn.JS.run/3.1

Others

  • Popcorn's landing page was redesigned!
  • Docs are much better now and contain tutorials for starting with Popcorn

See the migration guide and documentation.

  1. Use a tracked value with a cleanup callback to remove the listener when its handle is released. Call cleanup explicitly when timing matters. ↩