Skip to content

Releases: nalgeon/codapi-js

0.18.1

11 Mar 17:14
Compare
Choose a tag to compare

Change sandbox on the fly

You can now change the following sandbox attributes on the fly:

sandbox
engine
command
template
files

When you click the Run button, the newly set values are used.

0.18.0

05 Mar 10:27
Compare
Choose a tag to compare

Inline frame output mode. The widget can now display a full HTML document inside an iframe.

Edit-only mode. To hide the Run button, remove the sandbox attribute. Leave the editor attribute to allow editing.

0.17.0

03 Mar 16:05
Compare
Choose a tag to compare

DOM files. You can now define files using in-page scripts, pres and even other codapi-snippets.

File renaming. You can set a different name for a file using :.

Prefer stdout over stderr. If the sandbox returns both stdout and stderr, the widget will only display stdout. This is because some programs tend to return "debug" information in stderr, and showing it can be confusing to the reader.

0.16.0

26 Feb 15:09
Compare
Choose a tag to compare

Global settings

To change the settings, use the codapi-settings element.

⚠️ The url attribute in codapi-snippet is no longer supported. Use codapi-settings to change the base URL.

0.15.0

23 Feb 13:02
Compare
Choose a tag to compare

In-browser PostgreSQL playground

Now you can run PostgreSQL completely in your browser, no server required! And it only weighs 12 MB. Powered by the PGlite runtime.

Table output mode

If the sandbox returns a JSON array, you can render it as an HTML table using the table output mode.

0.14.0

14 Feb 20:49
Compare
Choose a tag to compare

Minor improvements:

  • Package version is now available as a global property window.codapi.version.
  • Better handling of syntax-highlighted pre and code elements.
  • The widget correctly attaches to the preceding code block even if it is rendered inside the p element (due to Markdown processing rules). Previously, it threw an exception in this case (see #13 (comment)).

⚠️ There are some breaking changes in undocumented APIs (hopefully you didn't use them):

  • The global window.Codapi object is renamed to window.codapi.
  • The global window.CodapiSnippet object is removed.

0.13.0

03 Feb 14:41
Compare
Choose a tag to compare

Images, HTML and interactive output

Previously, the widget only supported text output. Now it supports different output modes: text, SVG images, custom HTML, and even interactive DOM.

0.12.2

09 Jan 09:31
Compare
Choose a tag to compare

Fixed ##CODE## replacement in templates. Now the code is replaced as it is, without special treatment of the $ symbol.

Here is an example of the code that previously failed, but now works as expected:

<script id="mode.sql" type="text/plain">
.mode list
##CODE##
</script>

<pre><code>select json('{"a":1}') -> '$';</code></pre>
<codapi-snippet sandbox="sqlite" editor="basic" template="#mode.sql">
</codapi-snippet>

Previously resulted in:

Parse error near line 3: unrecognized token: "'
        ;
        "
  select json('{"a":1}') -> '         ;         
              error here ---^
 (exit status 1)

Now it works as expected:

{"a":1}

0.12.1

08 Jan 12:19
Compare
Choose a tag to compare

Customizable WASI path

By default, Codapi loads WASI binaries from the UNKPG CDN. For example:

https://unpkg.com/@antonz/[email protected]/dist/lua.wasm

Now you can customize the base path (the part of the URL before the filename) by passing it to the wasi.js script. For example, here is how to load lua.wasm from /assets/js (so the full URL would be /assets/js/lua.wasm):

<script src="wasi.js?path=/assets/js"></script>

Pass the path parameter without the trailing slash.

The filename part cannot be changed, so if you host the .wasm files yourself, do not change their names and put them all in the same folder (accessible by the URL you pass as the path parameter).

See the default settings in boxes.json.

0.12.0

04 Jan 11:08
Compare
Choose a tag to compare

More in-browser playgrounds

Most playgrounds (like Go or PostgreSQL) run code on the Codapi server. But there are some playgrounds that work completely in the browser, no Codapi server required. There used to be two of them: JavaScript and Fetch.

Now there are five more:

These playgrounds are WASI based (WASI is an executable binary format for browsers based on WebAssembly). They require two additional scripts besides the usual snippet.js:

<script src="https://unpkg.com/@antonz/[email protected]/dist/runno.js"></script>
<script src="https://unpkg.com/@antonz/[email protected]/dist/engine/wasi.js"></script>
<script src="https://unpkg.com/@antonz/[email protected]/dist/snippet.js"></script>

JavaScript and Fetch playgrounds changes

⚠️ Old JavaScript and Fetch playgrounds now require the engine attribute:

<codapi-snippet engine="browser" sandbox="javascript" editor="basic">
</codapi-snippet>

<codapi-snippet engine="browser" sandbox="fetch" editor="basic">
</codapi-snippet>

This is a breaking change.