# ZuzuScript Browser Bundle

This archive contains the standalone ZuzuScript browser runtime. It lets a web page compile and run ZuzuScript directly in a browser, with a bundled subset of the standard modules and browser-safe runtime support.

## Files

- `zuzu-browser.js`: readable browser bundle.
- `zuzu-browser.min.js`: minified browser bundle.
- `zuzu-browser-worker.js`: readable worker bundle for explicit worker loading.
- `zuzu-browser-worker.min.js`: minified worker bundle.

## Basic Use

Load the bundle from a page:

```html
<script src="zuzu-browser.min.js"></script>
```

After it loads, the global `ZuzuBrowser` object is available. The bundle also installs convenience globals:

```html
<script>
  zuzu_run('say "Hello from ZuzuScript";');
</script>
```

You can also embed ZuzuScript directly:

```html
<script type="text/x-zuzuscript">
  say "Hello from an embedded ZuzuScript block";
</script>
```

For an explicit runtime instance, use:

```html
<script>
  const runtime = ZuzuBrowser.createBrowserRuntime();
  runtime.zuzu_run('say "Hello";');
</script>
```

## Loading Remote Modules

Use `ZuzuBrowser.addModule(moduleName, url)` to allow a browser script to import a ZuzuScript module from a specific URL. The module is fetched, parsed, and cached the first time it is imported, so later imports of the same module reuse the cached module instead of making another HTTP request.

```html
<script>
  ZuzuBrowser.addModule(
    "foo/bar",
    "https://example.net/modules/foo/bar.zzm"
  );

  const runtime = ZuzuBrowser.createBrowserRuntime();
  await runtime.zuzu_run(`
    from foo/bar import answer;
    say answer;
  `);
</script>
```

The main bundle includes worker source by default. If you want the browser to load the worker as a separate file, keep `zuzu-browser-worker.min.js` beside the main bundle and pass a `workerUrl` option when creating a runtime.

## Bundled Modules

- javascript
- std/colour
- std/data/cbor
- std/data/csv
- std/data/json
- std/data/json/schema
- std/data/json/schema/core
- std/data/json/schema/format
- std/data/json/schema/model
- std/data/json/schema/output
- std/data/json/schema/relative_pointer
- std/data/json/schema/validation
- std/data/kdl
- std/data/kdl/json
- std/data/kdl/xml
- std/data/xml
- std/data/xml/escape
- std/data/yaml
- std/digest/md5
- std/digest/sha
- std/dump
- std/eval
- std/gui
- std/gui/dialogue
- std/gui/objects
- std/internals
- std/mail
- std/marshal
- std/math
- std/math/bignum
- std/net/http
- std/net/url
- std/path/jsonpointer
- std/path/simple
- std/path/z
- std/path/z/context
- std/path/z/evaluate
- std/path/z/functions
- std/path/z/lexer
- std/path/z/node
- std/path/z/operators
- std/path/z/parser
- std/path/zz
- std/path/zz/functions
- std/path/zz/operators
- std/result
- std/secure
- std/string
- std/string/base64
- std/string/encode
- std/string/quoted_printable
- std/task
- std/template/z
- std/template/zz
- std/time
- std/tui
- std/uuid
- std/worker

With the full zuzu-js distribution you can build an alternative browser bundle containing a custom set of modules.
