Releases: nalgeon/codapi-js
0.18.1
0.18.0
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
DOM files. You can now define files using in-page script
s, pre
s and even other codapi-snippet
s.
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
Global settings
To change the settings, use the codapi-settings
element.
url
attribute in codapi-snippet
is no longer supported. Use codapi-settings
to change the base URL.
0.15.0
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
Minor improvements:
- Package version is now available as a global property
window.codapi.version
. - Better handling of syntax-highlighted
pre
andcode
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)).
- The global
window.Codapi
object is renamed towindow.codapi
. - The global
window.CodapiSnippet
object is removed.
0.13.0
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
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
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
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
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.