# LiveCodes > LiveCodes is a feature-rich, open-source, client-side code playground that supports React, Vue, Svelte, Solid, JavaScript, TypeScript, CSS, Sass, Tailwind CSS, Python, Go, Ruby, PHP, and 90+ languages/frameworks. A large number of starter templates are available to help you get started quickly. Projects can be saved, shared, exported (e.g. to GitHub Gists), deployed (e.g. to GitHub Pages), or embedded in web pages. A powerful yet easy-to-use SDK enables the creation of and communication with embedded playgrounds. With extensive language support and high configurability, LiveCodes can easily adapt to your needs. It offers excellent mobile support, featuring a responsive layout and a touch-friendly code editor. LiveCodes is an outstanding tool for learning, teaching, prototyping, sharing, and testing code. It can be easily self-hosted, if needed, on any static file server. LiveCodes is completely free for unlimited use, with no ads and no account required. Its MIT License also permits commercial use. - [Docs](https://livecodes.io/docs/llms.txt) - [Full Docs](https://livecodes.io/docs/llms-full.txt) - [README](https://raw.githubusercontent.com/live-codes/livecodes/refs/heads/develop/README.md) # LiveCodes A Code Playground That Just Works!
Demo: (console=full)
:::tip Setting the querystring `languages` only shows these languages. Selecting one language and setting console to `full` gives an environment similar to a REPL. ::: Demo: (Python - print to console)
Demo: (template=jest-react)
Demo:
You can import from React like that: ```js import { useState } from 'react'; ``` Demo:
This is identified as <strong>HTML</strong> code
```
The HTML editor is prefilled with: `This is identified as HTML code`
Please note that the code should be html-encoded to avoid interference with the HTML of the page.
:::
Example:
https://livecodes.io/?x=https://live-codes.github.io/livecodes-examples/prefill-from-code-blocks.html
Alternatively, custom CSS selectors can be specified using [query params](../configuration/query-params.html.md):
`?x={url}&{language}-selector={selector}`
The following example loads the content of the first element that matches the CSS selector `h3` as `html`:
https://livecodes.io/?html-selector=h3&x=https://live-codes.github.io/livecodes-examples/prefill-from-code-blocks.html
Of course, [embedded playgrounds](./embeds.html.md) can be prefilled with code from the same embedding page. This works well for documentation and educational websites.
[This is a demo](https://live-codes.github.io/livecodes-examples/prefill-from-code-blocks.html) for automatic extraction of code blocks to prefill editors by creating "Edit in LiveCodes" links. Also embedded editors are prefilled from the code blocks. ([View source](https://github.com/live-codes/livecodes-examples/blob/master/prefill-from-code-blocks.html))
## Import Raw Code
If the response text could not be parsed as DOM or no elements matched the CSS selectors, it is assumed to be raw code and the response text is loaded to editor. If the URL ends with an extension it is used to identify the language, otherwise it is assumed to be `html`.
Alternatively, the language of raw code can be specified using [query params](../configuration/query-params.html.md):
`?x={url}&raw={language}`
## Import from CodePen
Currently, CodePen API does not allow directly importing code from Pens. However, you can export any saved Pen as a [zip file](https://blog.codepen.io/documentation/exporting-pens/#export-zip-1) or [Github gist](https://blog.codepen.io/documentation/exporting-pens/#save-as-github-gist-2) and then import it to LiveCodes. The format that Codepen exports is well understood by LiveCodes. Most Pens can be imported with no or minimal changes.
**Note:** External resources (styles/scripts) are not exported with source code in zip file export of CodePen. However, export to GitHub gist does export these. So if a Pen with external resources exported as zip file is not imported properly, try exporting to GitHub gist or manually add the [external resources](./external-resources.html.md).
## Import Code from Image (OCR)
Code can be extracted from images (local or via URL) using [Tesseract.js](https://github.com/naptha/tesseract.js), a library for Optical Character Recognition (OCR).
To ensure accurate identification, the text in the image should be clear, have high contrast against the background, and be free from unrelated text.
Language detection is performed using [highlight.js](https://highlightjs.readthedocs.io/en/latest/api.html#highlightauto), which makes its best guess based on the content.
Best results are obtained when the image is generated using LiveCodes "[Code to Image](./code-to-image.html.md)" feature.
## Import Exported LiveCodes Projects
A [single project exported as JSON](./export.html.md)#exporting-a-single-project) can be imported in the same or a different device from the import screen under the tab "Import Project JSON". The JSON file can be supplied as a local file upload or from a URL.
Similarly, [multiple projects exported in bulk](./export.html.md)#exporting-multiple-projects) can be imported from the tab "Bulk Import".
## Related
- [Code prefill](./code-prefill.html.md)
- [Export](./export.html.md)
- [External resources](./external-resources.html.md)
- [Module resolution](./module-resolution.html.md)
- [Projects](./projects.html.md)
---
# Export
## Exporting A Single Project
Project export can be accessed from the Project menu → Export.

Any project can be exported to:
- **Project (JSON):** a JSON file containing project [configuration object](../configuration/configuration-object.html.md). This can be used to later [import](./import.html.md)#import-exported-livecodes-projects) that project on the same or a different device or to share a copy of the project with others.
- **Source (ZIP):** a zip file containing the project configuration file as JSON, in addition to the source code in separate files. This can be useful for opening the code in an external IDE.
- **Result (HTML):** [result page](./result.html.md) as a single html file. Can be used for the purpose of demo or deploy.
- **GitHub gist** (_requires login with [GitHub account](./github-integration.html.md)_): creates a **public** GitHub gist on the user's GitHub account containing the source code as separate files.
- **CodePen:** creates a [CodePen](https://codepen.io/) prefilled with the project code. If the used [languages/frameworks](./../languages/index.html.md) are not supported in CodePen (e.g. Astro, Svelte, Python, ...etc), the compiled code is exported so that it continues to work there. [Bare module imports](./module-resolution.html.md) are converted to esm imports, for example:
```js
```
becomes:
```js
import React from 'https://cdn.skypack.dev/react';
```
- **JSFiddle:** creates a [JSFiddle](https://jsfiddle.net/) prefilled with the project code. Exported code may be modified like with CodePen (see above).
## Exporting Multiple Projects
Multiple projects can be exported in bulk from the [Saved Projects](./projects.html.md) screen (Project menu → Open) using the button `Export All`.

This produces a JSON file containing an array of project configuration objects. They can be later imported in the same or a different device using the `Bulk Import` functionality in the [Import screen](./import.html.md)#import-exported-livecodes-projects).
All the currently visible projects will be exported. If projects are filtered (e.g. by language, tag or search query), only the shown projects are exported.
## Related
- [Projects](./projects.html.md)
- [Import](./import.html.md)
- [Backup/Restore](./backup-restore.html.md)
- [Sync](./sync.html.md)
- [Share](./share.html.md)
---
# Share
It is easy to share LiveCodes projects!
A URL is generated to load the shared project. This URL can be copied or shared to different social media.
The share screen can be accessed from the share icon at the top right or from the Project menu → Share.

By default, the generated URL encodes the project configuration in a base-64-encoded compressed query string. This step is generated locally in the browser without sending the code to any server. However, depending on the size of the project, the URL can be very long. The length of the URL is indicated in the share screen. [Try not to use very long URLs](https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers) to ensure cross-browser compatibility.
When requested by the user, short URLs can be generated. This requires sending the project configuration (**including source code**) to a server that saves the code and provides a short Id which can be used to retrieve the project.

:::caution
Generating a short URL for sharing requires sending the project configuration (**including source code**) to LiveCodes share service. **It cannot then be deleted**.
:::
:::info Note
The app hosted on [`https://livecodes.io`](https://livecodes.io) uses an API endpoint specifically provided to generate short URLs for LiveCodes share service. We will make every effort to keep that online and available for free use, so long as it is not abused. Please help keep it available by not abusing it and by [sponsoring the project](../sponsor.html.md).
Short URLs generated by LiveCodes share service are **private** — the links are not published anywhere on the site, and the IDs are non-sequential.
However, _static_ [**self-hosted apps**](./self-hosting.html.md) use the free service [dpaste](https://dpaste.com/) for short URLs which are [**deleted after 365 days**](https://dpaste.com/help). If this is a significant issue for you, you may want to use the [docker setup](../advanced/docker.html.md) instead, which provides a self-hosted implementation for the share service among other features. LiveCodes [sponsors](../sponsor.html.md) (Bronze sponsors and above) get access to a hosted implementation.
:::
QR code can be generated for the share URL. This can then be scanned by any QR code scanner (e.g. mobile/tablet camera) to load the project on other devices without having to send the link. Please note that generating QR code also requires generating a short URL (code is sent to the share service - see above).

## Related
- [Export](./export.html.md)
- [Import](./import.html.md)
- [Deploy](./deploy.html.md)
- [Broadcast](./broadcast.html.md)
- [Backup / Restore](./backup-restore.html.md)
- [Sync](./sync.html.md)
- [Permanent URL](./permanent-url.html.md)
---
# Welcome Screen
---
# Recover Unsaved
---
# Code to Image
LiveCodes has a feature called "Code to Image" that allows converting the code in the code editor into nice-looking images (or code screenshots), that can be downloaded or shared.
This can be accessed from the camera icon in the toolbar below the editor. Clicking the icon will open the "Code to Image" screen and load the code in the editor.

Code can be modified in the "Code to Image" screen and then downloaded as image or shared.

There are many options to configure the image to be generated, including background color, border radius, image size, padding, shadow, window style, share URL, editor theme, opacity, code font, image format, etc.
There are multiple presets that can be used or the options can be manually configured.




---
# Display Modes
import LiveCodes from '../../src/components/LiveCodes.tsx';
The [configuration](../configuration/configuration-object.html.md) option [`mode`](../configuration/configuration-object.html.md)#mode), also available as [query param](../configuration/query-params.html.md), can be used to select different display modes.
The following display modes are supported:
## `full`
This is the default mode with toolbars, editor and result panes.
Example: https://livecodes.io/?template=react
Screenshot: (App in full mode)

Demo: (Embedded playground in full mode)
You clicked {count} times.
Hello World!
```
### Multiple Languages
You can include multiple `` blocks with different `data-lang` values to populate several editors in the same playground. For example, to create a playground with HTML, CSS, and TypeScript: ```html livecodes render=link``` ### Configuration via Data Attributes Each `.livecodes` element can optionally accept the following data attributes: **`data-options`**: A JSON string representing [embed options](../sdk/js-ts.html.md)#embed-options), such as `appUrl`, `config`, `import`, `loading`, `params`, and `template`. ```html livecodes render=linkThis code is in HTML code blocksWith HTML tagsbody { text-align: center; } .blue { color: blue; }const p = document.createElement('p'); p.classList.add('blue'); p.innerHTML = 'hello from Typescript!'; document.body.appendChild(p);``` **`data-height`**: A number (in pixels) or a CSS value representing the height of the playground (see below). ### Setting the Height The playground height can be set using inline styles: ```html {1} livecodes render=linkconsole.log('Hello World!');``` Alternatively, the height can be set using the `data-height` attribute. ```html {1} livecodes render=linkHello World!
``` ### Escaping Code It is recommended to escape code inside the code blocks using HTML entities (e.g. `<` instead of `<` and `>` instead of `>`) to avoid being evaluated by the browser as HTML. However, this is not strictly required. Example: ```htmlHello World!
``` :::caution The `data-prefill` attribute must be set on the ``} ); };<h1>Hello World!</h1>## Get Permanent URL You can get the permanent URL for the app from the [About screen](pathname:///../?screen=about) (Help menu → About). By default, the code generated in the [Embed screen](./embeds.html.md)#app-embed-screen) uses permanent URL. Alternatively, open the browser console of the standalone app (e.g. https://livecodes.io), and run this: export const GetPermanentUrl = () => { const { siteConfig } = useDocusaurusContext(); return ({`await livecodes.exec('showVersion');\n // output: // App Version: ${siteConfig.customFields.appVersion} (https://github.com/live-codes/livecodes/releases/tag/v${siteConfig.customFields.appVersion}) // SDK Version: ${siteConfig.customFields.sdkVersion} (https://www.npmjs.com/package/livecodes/v/${siteConfig.customFields.sdkVersion}) // Git commit: 0698f9f (https://github.com/live-codes/livecodes/commit/0698f9f) // App Permanent URL: https://v${siteConfig.customFields.appVersion}.livecodes.io/ // SDK Permanent URL: https://cdn.jsdelivr.net/npm/livecodes@${siteConfig.customFields.sdkVersion}/livecodes.js `} ); };:::caution Please note that this only applies to the LiveCodes app and its dependencies. [NPM imports](./module-resolution.html.md) in [project code](./projects.html.md)#script-editor) that do not specify versions use the latest version. [Package versions](./module-resolution.html.md)#package-version) can be specified in the import. [Custom import maps](./module-resolution.html.md)#custom-module-resolution) can be set to control the module import behavior. Example: ```js import lodash from 'lodash@4.17.21'; console.log(lodash.VERSION); // -> 4.17.21 ``` It is recommended to also specify versions of [external resources](./external-resources.html.md). ::: #### Full Example: export const FullCode = () => { const { siteConfig } = useDocusaurusContext(); return ( {`\n`} ); };## Related - [Embedded playgrounds](./embeds.html.md) - [Share](./share.html.md) - [SDK](../sdk/index.html.md) - [`exec` SDK method](../sdk/js-ts.html.md)#exec) --- # Data URLs > **Data URLs**, URLs prefixed with the `data:` scheme, allow content creators to embed small files inline in documents. > > — [MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs) Sometimes, you need to use an external file (e.g. script, stylesheet) that is not hosted online. In this case, you can use data URLs to embed the file in your code. These can then be used similar to regular URLs (e.g. for ` ``` However, if `imports` is specified as follows: ```json { "imports": { "moment": "https://cdn.jsdelivr.net/npm/moment@2.29.4/dist/moment.js" } } ``` The import map becomes like this: ```html ``` :::info Note Currently, multiple import maps are not yet supported. https://crbug.com/927119 When bare module imports are encountered, LiveCodes adds an import map to the result page. If you need to add custom import map or override the automatically generated one, you need to add them to `imports` config property or `imports` [customSettings](#customsettings) property. ::: ### `types` Type: `[key: string]: string | { autoload?: boolean ; declareAsModule?: boolean ; url: string }` Default: `{}` Allows providing custom [TypeScript type declarations](https://www.typescriptlang.org/docs/handbook/2/type-declarations.html) for better [editor intellisense](../features/intellisense.html.md). It is an object where each key represents module name and value represents the types. This can be a URL to a type declaration file. For example, if this is the type declaration file: ```ts title="https://my-custom-domain/my-type-declarations.d.ts" declare module 'my-demo-lib' { export class Greeter { morning(): string; evening(): string; } } ``` It can be used like that: ```json { "types": { "my-demo-lib": "https://my-custom-domain/my-type-declarations.d.ts" } } ``` Alternatively, the value for module name can be an object with the following properties: - `url`: `string` (required). The URL to type declaration file. - `autoload`: `boolean` (optional). By default, the types are only loaded when the module is imported in code. If `autoload` property is set to `true`, the types are loaded regardless if the module was imported. - `declareAsModule`: `boolean` (optional). Declares the types as module with the supplied module name. Example: ```json { "types": { "my-demo-lib": { "url": "https://my-custom-domain/types.d.ts", "autoload": true, "declareAsModule": true } } } ``` ### `tests` Type: `undefined` | `Partial ` Default: `{ language: 'typescript', content: '' }` Configures the [language](../features/tests.html.md)#supported-languages) and content of [tests](../features/tests.html.md). ### `version` Type: `Readonly` [`string`](../api/interfaces/Config.md#description) Default: Current LiveCodes Version. This is a read-only property which specifies the current LiveCodes version. It can be shown using the SDK [`exec`](../sdk/js-ts.html.md)#exec) method. ```js // in browser console of full app (e.g. https://livecodes.io) await livecodes.exec('showVersion'); ``` Version specified in [exported](../features/export.html.md) projects allows automatically upgrading the project configuration when imported by an app with a newer version. ## App Settings These are properties that define how the app behaves. ### `readonly` Type: [`boolean`](../api/interfaces/Config.md#readonly) Default: `false` If `true`, editors are loaded in read-only mode, where the user is not allowed to change the code. By default, when `readonly` is set to `true`, the light-weight code editor [CodeJar](../features/editor-settings.html.md)#code-editor) is used. If you wish to use another editor, set the [editor](#editor) property. ### `allowLangChange` Type: [`boolean`](../api/interfaces/Config.md#allowlangchange) Default: `true` If `false`, the UI will not show the menu that allows changing editor language. ### `view` Type: [`"split" | "editor" | "result"`](../api/interfaces/Config.md#view) Default: `"split"` The [default view](../features/default-view.html.md) for the playground. ### `mode` Type: [`"full" | "focus" | "simple" | "lite" | "result" | "editor" | "codeblock"`](../api/interfaces/Config.md#mode) Default: `"full"` Sets the [display mode](../features/display-modes.html.md). ### `tools` Type: [`Partial<{ enabled: Array<'console' | 'compiled' | 'tests' | 'zoom'> | 'all'; active: 'console' | 'compiled' | 'tests' | ''; status: 'closed' | 'open' | 'full' | 'none' | ''; }>`](../api/interfaces/Config.md#tools) Default: `{ enabled: 'all', active: '', status: '' }` Sets enabled and active tools and status of [tools pane](../features/tools-pane.html.md). Example: ```json { "tools": { "enabled": ["console", "compiled"], "active": "console", "status": "open" } } ``` ### `zoom` Type: [`1 | 0.5 | 0.25`](../api/interfaces/Config.md#zoom) Default: `1` Sets result page [zoom level](../features/result.html.md)#result-page-zoom). ### `disableHomeLink` Type: [`boolean`](../api/interfaces/Config.md#disablehomelink) Default: `false` If `true`, the link on LiveCodes logo ("Edit on LiveCodes") is disabled in [embeds](../features/embeds.html.md). ## User Settings These are properties that define the [user settings](./../features/user-settings.html.md), including [editor settings](../features/editor-settings.html.md). {/* ### `enableAI` Type: [`boolean`](../api/interfaces/Config.md#enableai) Default: `false` If `true`, [AI code assistant](../features/ai.html.md) is enabled. */} ### `autoupdate` Type: [`boolean`](../api/interfaces/Config.md#autoupdate) Default: `true` If `true`, the result page is automatically updated on code change, after time [delay](#delay). ### `autosave` Type: [`boolean`](../api/interfaces/Config.md#autosave) Default: `false` If `true`, the project is automatically saved on code change, after time [delay](#delay). ### `autotest` Type: [`boolean`](../api/interfaces/Config.md#autotest) Default: `false` If `true`, the project is watched for code changes which trigger tests to auto-run. ### `delay` Type: [`number`](../api/interfaces/Config.md#delay) Default: `1500` Time delay (in milliseconds) following code change, after which the result page is updated (if [`autoupdate`](#autoupdate) is `true`) and/or the project is saved (if [`autosave`](#autosave) is `true`). ### `formatOnsave` Type: [`boolean`](../api/interfaces/Config.md#formatonsave) Default: `false` If `true`, the code is automatically [formatted](../features/code-format.html.md) on saving the project. ### `layout` Type: [`"horizontal"| "vertical" | "responsive" | undefined`](../api/interfaces/Config.md#layout) Default: `"responsive"` Sets the app layout to horizontal or vertical. If set to `"responsive"` (the default) or `undefined`, the layout is vertical in small screens when the playground height is larger than its width, otherwise horizontal. ### `theme` Type: [`"light" | "dark"`](../api/interfaces/Config.md#theme) Default: `"dark"` Sets the app [theme](../features/themes.html.md) to light/dark mode. ### `themeColor` Type: [`string | undefined`](../api/interfaces/Config.md#themecolor) Default: `"hsl(214, 40%, 50%)"` A string representing a [CSS color value](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value), used to set the app [theme color](../features/themes.html.md). It can be any valid CSS color value, such as `"#4DB39E"`, `"rgb(245, 225, 49)"`, `"hsl(324, 40%, 50%)"` and `"lightblue"`. ### `editorTheme` Type: [`EditorTheme[] | string | undefined`](../api/interfaces/Config.md#editortheme) Default: `undefined` Sets the code editor themes. :::info Note You can preview and set editor themes in the [editor settings screen](pathname:///../?screen=editor-settings). ::: Three [code editors](#editor) are supported in LiveCodes: **Monaco** (the default on desktop), **CodeMirror** (the default on mobile) and **CodeJar** (the default in [codeblocks](../features/display-modes.html.md)#codeblock), in [lite mode](../features/lite.html.md) and in [readonly](#readonly) playgrounds). Each editor has its own set of themes, represented by the types: [`MonacoTheme`](../api/internal/type-aliases/MonacoTheme.md), [`CodemirrorTheme`](../api/internal/type-aliases/CodemirrorTheme.md) and [`CodejarTheme`](../api/internal/type-aliases/CodejarTheme.md). The `editorTheme` property can be used to set the editor theme for each editor and on light/dark modes. It can be set to an array of [`EditorTheme`](../api/internal/type-aliases/EditorTheme.md) items or a string of comma-separated items. Each item can be composed of: ` editor:` `theme-name` `@app-theme` Where: - `editor` is the name of the editor (`"monaco" | "codemirror" | "codejar"`). [Optional] - `theme-name` is the name of the theme (e.g. `"monokai"`). [Required] Valid theme names can be found here: - Monaco: [`MonacoTheme`](../api/internal/type-aliases/MonacoTheme.md) - CodeMirror: [`CodemirrorTheme`](../api/internal/type-aliases/CodemirrorTheme.md) - CodeJar: [`CodejarTheme`](../api/internal/type-aliases/CodejarTheme.md). - `app-theme` is the name of the app theme (`"dark" | "light"`). [Optional] Examples: - `"vs"` - `"monaco:twilight, codemirror:one-dark"` - `["vs@light"]` - `["vs@light", "vs-dark@dark"]` - `["monaco:vs@light", "codemirror:github-light@light", "dracula@dark"]` Each `EditorTheme` item requires a theme name. The theme name can optionally be preceded with the editor name separated by a colon to specify the editor (e.g. `"monaco:monokai"`). It can also optionally be followed by the app theme separated by "@" (e.g. `"monokai@dark"`). Multiple `EditorTheme` items can be supplied (as array items or in the comma-separated string) to specify the theme for each editor and in dark and light modes. The order matters. The first valid item in the array or string for the current editor (`monaco`, `codemirror` or `codejar`) and app theme (`light` or `dark`) will be used. If no items match the current editor and app theme, the default theme for the editor and app theme will be used. ### `appLanguage` Type: [`AppLanguage | undefined`](../api/interfaces/Config.md#applanguage) Default: `undefined` Spoken language code that sets the app UI language (e.g. `"ar"`, `"zh-CN"`). Used in translations for internationalization. If `undefined` (the default), the language is automatically detected based on the user's browser settings and falls back to English, if detection fails or the language is not supported. ### `recoverUnsaved` Type: [`boolean`](../api/interfaces/Config.md#recoverunsaved) Default: `true` Enables [recovering last unsaved project](../features/recover.html.md) when the app is reopened. ### `welcome` Type: [`boolean`](../api/interfaces/Config.md#welcome) Default: `true` If `true`, the [welcome screen](../features/welcome.html.md) is displayed when the app loads. ### `showSpacing` Type: [`boolean`](../api/interfaces/Config.md#showspacing) Default: `false` Enables [showing element spacing](../features/result.html.md)#show-spacings) in the result page. ### `editor` Type: [`"monaco" | "codemirror" | "codejar" | "auto" | undefined`](../api/interfaces/Config.md#editor) Default: `undefined` Selects the [code editor](../features/editor-settings.html.md)#code-editor) to use. If `undefined` (the default):
Monaco editor is used on desktop,
CodeMirror is used on mobile and in `simple` mode,
while CodeJar is used in [`codeblock` mode](../features/display-modes.html.md)#codeblock), in [`lite` mode](../features/lite.html.md) and in [`readonly`](#readonly) playgrounds. If set to `auto`, Monaco editor is used on desktop and CodeMirror is used on mobile regardless of other settings. ### `fontFamily` Type: [`string | undefined`](../api/interfaces/Config.md#fontfamily) Default: `undefined` Sets the [code editor](../features/editor-settings.html.md) font family. ### `fontSize` Type: [`number | undefined`](../api/interfaces/Config.md#fontfamily) Default: `undefined` Sets the [code editor](../features/editor-settings.html.md) font size. If `undefined` (the default), the font size is set to 14 for the full app and 12 for [embeds](../features/embeds.html.md). ### `useTabs` Type: [`boolean`](../api/interfaces/Config.md#usetabs) Default: `false` If `true`, lines are indented with tabs instead of spaces. Also used in [code formatting](../features/code-format.html.md). ### `tabSize` Type: [`number`](../api/interfaces/Config.md#tabsize) Default: `2` The number of spaces per indentation-level. Also used in [code formatting](../features/code-format.html.md). ### `lineNumbers` Type: [`boolean | "relative"`](../api/interfaces/Config.md#linenumbers) Default: `true` Show line numbers in [code editor](../features/editor-settings.html.md). If set to `"relative"`, line numbers are shown relative to the current line. This can be useful with [vim mode](#editormode). ### `wordWrap` Type: [`boolean`](../api/interfaces/Config.md#wordwrap) Default: `false` Enables word-wrap for long lines. ### `closeBrackets` Type: [`boolean`](../api/interfaces/Config.md#closebrackets) Default: `true` Use auto-complete to close brackets and quotes. ### `foldRegions` Type: [`boolean`](../api/interfaces/Config.md#foldregions) Default: `false` When set to `true`, regions marked by `#region` and `#endregion` comments are folded when the project is loaded. ### `minimap` Type: [`boolean`](../api/interfaces/Config.md#minimap) Default: `false` Enables minimap in code editor. ### `emmet` Type: [`boolean`](../api/interfaces/Config.md#emmet) Default: `true` Enables [Emmet](../features/editor-settings.html.md)#emmet). ### `editorMode` Type: [`"vim" | "emacs" | undefined`](../api/interfaces/Config.md#editormode) Default: `undefined` Sets [editor mode](../features/editor-settings.html.md)#editor-modes). ### `semicolons` Type: [`boolean`](../api/interfaces/Config.md#semicolons) Default: `true` Configures Prettier [code formatter](../features/code-format.html.md) to use [semi-colons](https://prettier.io/docs/en/options.html#semicolons). ### `singleQuote` Type: [`boolean`](../api/interfaces/Config.md#singlequote) Default: `false` Configures Prettier [code formatter](../features/code-format.html.md) to use [single quotes instead of double quotes](https://prettier.io/docs/en/options.html#quotes). ### `trailingComma` Type: [`boolean`](../api/interfaces/Config.md#trailingcomma) Default: `true` Configures Prettier [code formatter](../features/code-format.html.md) to use [trailing commas](https://prettier.io/docs/en/options.html#trailing-commas). --- # Query Parameters import LiveCodes from '../../src/components/LiveCodes.tsx'; A flexible and convenient way to configure the app is to use URL query parameters. It allows configuration of a wide range of options, including those of the [configuration object](./configuration-object.html.md) and [embed options](../sdk/js-ts.html.md)#embed-options). Example: ``` https://livecodes.io?js=console.log('Hello World!')&console=open ```## Usage - All properties of [configuration object](./configuration-object.html.md) and [embed options](../sdk/js-ts.html.md)#embed-options) that have values of primitive types (e.g. string, number, boolean) can be assigned to a query parameter with the same name. These include: [config](../sdk/js-ts.html.md)#config), [import](../sdk/js-ts.html.md)#import), [lite](../configuration/configuration-object.html.md)#mode), [loading](../sdk/js-ts.html.md)#loading), [template](../sdk/js-ts.html.md)#template), [view](../configuration/configuration-object.html.md)#view), [title](./configuration-object.html.md)#title), [description](./configuration-object.html.md)#description), [activeEditor](./configuration-object.html.md)#activeeditor), [cssPreset](./configuration-object.html.md)#csspreset), [readonly](./configuration-object.html.md)#readonly), [allowLangChange](./configuration-object.html.md)#allowlangchange), [mode](./configuration-object.html.md)#mode), [autoupdate](./configuration-object.html.md)#autoupdate), [autosave](./configuration-object.html.md)#autosave), [delay](./configuration-object.html.md)#delay), [formatOnsave](./configuration-object.html.md)#formatonsave), [theme](./configuration-object.html.md)#theme), [themeColor](./configuration-object.html.md)#themecolor), [appLanguage](./configuration-object.html.md)#applanguage), [recoverUnsaved](./configuration-object.html.md)#recoverunsaved), [welcome](./configuration-object.html.md)#welcome), [showSpacing](./configuration-object.html.md)#showspacing), [layout](./configuration-object.html.md)#layout), [editor](./configuration-object.html.md)#editor), [editorTheme](./configuration-object.html.md)#editortheme), [fontFamily](./configuration-object.html.md)#fontfamily), [fontSize](./configuration-object.html.md)#fontsize), [useTabs](./configuration-object.html.md)#usetabs), [tabSize](./configuration-object.html.md)#tabsize), [lineNumbers](./configuration-object.html.md)#linenumbers), [wordWrap](./configuration-object.html.md)#wordwrap), [closeBrackets](./configuration-object.html.md)#closebrackets), [emmet](./configuration-object.html.md)#emmet), [editorMode](./configuration-object.html.md)#editormode), [semicolons](./configuration-object.html.md)#semicolons), [singleQuote](./configuration-object.html.md)#singlequote), [trailingComma](./configuration-object.html.md)#trailingcomma). Example: ``` ?theme=light&delay=500&lineNumbers=false ``` - Any value given for booleans except `"false"` (including no value) will be considered `true`. Example: all these are considered `true` ``` ?lite=true ?lite=1 ?lite=any ?lite ``` while this is considered `false` ``` ?lite=false ``` - Parameters that expect array of values can be supplied with comma separated values. These include: [tags](./configuration-object.html.md)#tags), [languages](./configuration-object.html.md)#languages), [processors](./configuration-object.html.md)#processors), [stylesheets](./configuration-object.html.md)#stylesheets), [scripts](./configuration-object.html.md)#scripts). Example: ``` ?processors=tailwindcss,autoprefixer ``` - Custom Settings can be set like this: ``` ?customSettings={template:{prerender:false}} ``` or this: ``` ?customSettings.template.prerender=false ``` - Values set in the URL query parameters override those set in [configuration object](./configuration-object.html.md). - Unlike [user settings](../features/user-settings.html.md) that are set in the UI which are saved and subsequently used, those that are set in query parameters are not automatically saved. - Additional query parameters include: - `no-defaults`: `boolean` (Default: `false`). If `true`, the app will not load the [default template/language](../features/default-template-language.html.md). - `x`: `string`. Alias to [`import`](../sdk/js-ts.html.md)#import) (a URL to [import](../features/import.html.md)). - `files`: `string`. A comma-separated [list of files to import](../features/import.html.md)#file-selection). - `raw`: [`Language`](../api/type-aliases/Language.md). When used with `import` or `x`, imports the URL as code of the provided language. - `language`: [`Language`](../api/type-aliases/Language.md). The language to load by default in the editor. - `lang`: [`Language`](../api/type-aliases/Language.md). Alias to `language`. - `active`: `"markup" | "style" | "script" | 0 | 1 | 2`. Alias to [`activeEditor`](./configuration-object.html.md)#activeeditor). - `tools`: `"open" | "full" | "closed" | "console" | "compiled" | "tests" | "none"` The [tools pane](../features/tools-pane.html.md) status. - `console`: `"open" | "full" | "closed" | "none"` The [console](../features/console.html.md) status. - `compiled`: `"open" | "full" | "closed" | "none"` The [compiled code viewer](../features/compiled-code.html.md) status. - `tests`: `"open" | "full" | "closed" | "none"` The [tests panel](../features/tests.html.md) status. - `scrollPosition`: `boolean` (Default: `true`). If `false`, the [result page](../features/result.html.md) [scroll position](../features/result.html.md)#scroll-position) will not be maintained after reload. - Any [`Language`](../api/type-aliases/Language.md) can used as a query parameter, and the value will be used as its code. Example: ``` https://livecodes.io?js=console.log('Hello World!') ``` :::info Examples For usage examples, check [storybook](pathname:///../stories/?path=/story/embed-options-params--select-language) and [unit tests](https://github.com/live-codes/livecodes/blob/develop/src/livecodes/config/__tests__/build-config.spec.ts). ::: {/* TODO: add docs for languageSelector and ToolsStatus */} --- # LiveCodes SDK import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import LiveCodes from '../../src/components/LiveCodes.tsx'; The Software Development Kit (SDK) provides an easy, yet powerful, interface to embed and communicate with LiveCodes playgrounds. The SDK is provided as a light-weight [npm package](#npm-package) (or [jsr package](#jsr)), that is also available from [CDNs](#cdn). It can be used to create playgrounds with a wide variety of [configurations](../configuration/configuration-object.html.md) and [embed options](js-ts.html.md)#embed-options). In addition, [SDK methods](js-ts.html.md)#sdk-methods) allow programmatic communication and control of the playgrounds during runtime. The [JavaScript SDK](js-ts.html.md) is framework/library agnostic. However, wrapper components are also provided for popular libraries (currently [React](react.html.md), [Preact](preact.html.md), [Vue](vue.html.md), [Solid](solid.html.md) and [Svelte](svelte.html.md)), in addition to a [web component](web-components.html.md). [TypeScript support](js-ts.html.md)#typescript-types) provides type-safety and a great developer experience. ## SDK Demo This is an example of an editable embedded playground using the SDK. ## Installation ### NPM Package This is a single npm package for the SDK which provides support for JavaScript/TypeScript, Preact, React, Solid, Svelte, Vue and Web Components. Install the library from npm: ```bash npm2yarn npm install livecodes ``` then it can be used like that: ```js title="index.js" import { createPlayground } from 'livecodes'; createPlayground('#container', { // embed options }); ``` ### JSR The SDK is also available as a [JSR package](https://jsr.io/@livecodes/sdk). Install it with Deno: then it can be used like that: ```js title="index.js" import { createPlayground } from 'jsr:@livecodes/sdk'; createPlayground('#container', { // embed options }); ``` ### CDN Alternatively, it can just be loaded from a CDN. ESM: import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; import CodeBlock from '@theme/CodeBlock'; export const ESMCode = () => { const { siteConfig } = useDocusaurusContext(); return ( ```bash deno add jsr:@livecodes/sdk ``` {`\n`} ); };UMD: export const UMDCode = () => { const { siteConfig } = useDocusaurusContext(); return ( {`\n\n `} ); };:::note The UMD version allows [automatic code pre-fill](../features/code-prefill.html.md)#auto-pre-fill-from-page-dom) from the page DOM when `data-prefill` attribute is added to the script tag. ::: :::info In the full [standalone app](../getting-started.html.md)#standalone-app), the JavaScript SDK is accessible via the global variable `livecodes`, which can be interacted with in the browser console. ::: ## Usage The SDK is currently provided in the following variations: - [JavaScript/TypeScript](./js-ts.html.md) - [Preact](./preact.html.md) - [React](./react.html.md) - [Solid](./solid.html.md) - [Svelte](./svelte.html.md) - [Vue](./vue.html.md) - [Web Components](./web-components.html.md) ## Headless Mode The SDK also has a [headless mode](./headless.html.md). In this mode, no visible output is displayed in the embedding web page. However, all [SDK methods](../sdk/js-ts.html.md)#sdk-methods) are accessible. This provides the power of leveraging the wide range of features and language support offered by LiveCodes, while retaining full control over the UI. ## SDK Playground! A demo page that shows the usage of the SDK can be [found here](https://live-codes.github.io/livecodes-examples/sdk-demo.html) ([source](https://github.com/live-codes/livecodes-examples/blob/gh-pages/sdk-demo.html)). Or edit the SDK playground in LiveCodes. How meta! :) P.S. You may want to use the "Full Screen" button! --- # JavaScript/ TypeScript SDK import LiveCodes from '../../src/components/LiveCodes.tsx'; import RunInLiveCodes from '../../src/components/RunInLiveCodes.tsx'; This is the core SDK on which others ([Preact](preact.html.md), [React](react.html.md), [Solid](solid.html.md), [Svelte](svelte.html.md), [Vue](vue.html.md) and [Web Components](web-components.html.md) SDKs) are built on top. It is a light-weight, zero-dependencies library that allows creating, embedding and communication with LiveCodes playgrounds. It also allows easily creating links to playgrounds. ## Installation Please refer to the [SDK installation](./index.html.md)#installation) section. :::info In the full [standalone app](../getting-started.html.md)#standalone-app), the JavaScript SDK is accessible via the global variable `livecodes`, which can be interacted with in the browser console. ::: ## TypeScript Types TypeScript types are [documented here](../api/globals.md) and can be imported from the library. ```ts import type { EmbedOptions, Playground } from 'livecodes'; ``` The following 2 functions are exported by the library: ## `createPlayground` Type: [`(container: string | Element, options?: EmbedOptions) => Promise `](../api/functions/createPlayground.md) The library exports the function `createPlayground` which has 2 parameters: - `container` (required): `HTMLElement` or a string representing a CSS selector. This is the container where the playground is rendered. If not found, an error is thrown (except in [headless mode](./headless.html.md), in which this parameter is optional and can be omitted). - `options` (optional): an object with embed options ([EmbedOptions](../api/interfaces/EmbedOptions.md)). The `createPlayground` function returns a promise which resolves to an object that exposes the SDK methods ([Playground](../api/interfaces/Playground.md)). ```ts import { createPlayground, type EmbedOptions } from 'livecodes'; const options: EmbedOptions = { // appUrl: ... // config: ... // headless: ... // import: ... // loading: ... // params: ... // template: ... }; createPlayground('#container', options).then((playground) => { // the `playground` object exposes the SDK methods // e.g. playground.run() }); ``` :::caution Throws The `createPlayground` function throws an error (promise is rejected) in any of the following conditions: - The first parameter ([`container`](#createplayground)) is not an element or not found (by CSS selector), except in [headless mode](./headless.html.md). - The embed option [`appUrl`](#appurl) is supplied and is not a valid URL. - The embed option [`config`](#config) is supplied and is not an object or a valid URL. - Any of the [SDK methods](#sdk-methods) was called after calling the [`destroy`](#destroy) method. ::: ### Multiple Sources When multiple sources are provided in the [embed options](#embed-options), each is converted to a [configuration object](../configuration/configuration-object.html.md) and the properties are merged. In case there are conflicts between the properties of the configurations, they are overridden in the following order: - [`template`](#template) (lowest precedence) - [`import`](#import) - [`config`](#config) - [`params`](#params) (highest precedence) ## `getPlaygroundUrl` Type: [`(options?: EmbedOptions) => string`](../api/functions/getPlaygroundUrl.md) Gets the URL to playground (as a string) from the provided [options](#embed-options). This can be useful for providing links to run code in playgrounds. Example: ```html Open in playground ``` export const getPlaygroundUrlDemo = { html: `# Hello World!\nOpen in playground\n`, };# Hello World!## `compress` Type: `(uncompressed: string) => string` A utility function that allows compressing the stringified config object (e.g. for [sharing in URL hash](../tutorials/creating-shareable-urls.html.md)). It encodes it in base64 with a few tweaks to make it URI safe. This is the `compressToEncodedURIComponent` function re-exported from [`lz-string`](https://www.npmjs.com/package/lz-string) for convenience. ```js import { compress } from 'livecodes'; const config = { markup: { language: 'html', content: ' Hello World!
', }, }; const compressed = compress(JSON.stringify(config)); ``` ## `decompress` Type: `(compressed: string) => string | null` A utility function that allows decompressing the config object (compressed by [`compress`](#compress)). It decodes it to a string that should be `JSON.parse`d. This is the `decompressFromEncodedURIComponent` function re-exported from [`lz-string`](https://www.npmjs.com/package/lz-string) for convenience. ```js import { decompress } from 'livecodes'; const decompressed = decompress(compressedString); if (decompressed) { try { const config = JSON.parse(decompressed); } catch { // invalid JSON } } ``` ## Embed Options Type: [`EmbedOptions`](../api/interfaces/EmbedOptions.md) The [`createPlayground`](#createplayground) and [`getPlaygroundUrl`](#getplaygroundurl) functions accept an optional object that allows providing different options to the playground. This object can have the following optional properties: ### `appUrl` Type: [`string`](../api/interfaces/EmbedOptions.md#appurl) Default: `"https://livecodes.io/"` Allows loading the playground from a custom URL (e.g. a [self-hosted app](../features/self-hosting.html.md) or a [permanent URL](../features/permanent-url.html.md)). If supplied with an invalid URL, an error is thrown. ### `config` Type: [`string | Partial`](../api/interfaces/EmbedOptions.md#config) Default: `{}` A [configuration object](../configuration/configuration-object.html.md) or a URL to a JSON file representing a configuration object to load. If supplied and is not an object or a valid URL, an error is thrown. ### `headless` Type: [`boolean`](../api/interfaces/EmbedOptions.md#headless) Default: `false` When set to `true`, the playground is loaded in [headless mode](./headless.html.md). ### `import` Type: [`string`](../api/interfaces/EmbedOptions.md#import) A resource to [import](../features/import.html.md) (from any of the supported [sources](../features/import.html.md)#sources)). ### `loading` Type: [`"eager" | "lazy" | "click"`](../api/interfaces/EmbedOptions.md#loading) Default: `"lazy"` Sets how the playground loads: - `"eager"`: The playground loads immediately. - `"lazy"`: A playground embedded low down in the page will not load until the user scrolls so that it approaches the viewport. - `"click"`: The playground does not load automatically. Instead, a "Click-to-load" screen is shown. ### `params` Type: [`UrlQueryParams`](../api/interfaces/EmbedOptions.md#params) An object that represents [URL Query parameters](../configuration/query-params.html.md), that can be used to configure the playground. These 2 snippets produce similar output: ```js import { createPlayground } from 'livecodes'; // use config createPlayground('#container', { config: { markup: { language: 'markdown', content: '# Hello World!', }, }, }); // use params createPlayground('#container', { params: { md: '# Hello World!' } }); ``` ### `template` Type: [`TemplateName`](../api/interfaces/EmbedOptions.md#template) A [starter template](../features/templates.html.md) to load. Allowed valued can be found [here](../api/interfaces/EmbedOptions.md#template). ## SDK Methods The [`createPlayground`](#createplayground) function returns a promise which resolves to an object ([`Playground`](../api/interfaces/Playground.md)) that exposes some useful SDK methods that can be used to interact with the playground. These methods include: ### `load` Type: [`() => Promise `](../api/interfaces/Playground.md#load) When the embed option `loading` is set to `click`, the playground is not loaded automatically. Instead, a screen is shown with "Click to load" button. Calling the SDK method `load()` allows loading the playground. If the playground was not loaded, calling any other method will load the playground first before executing. ```js import { createPlayground } from 'livecodes'; createPlayground('#container').then(async (playground) => { await playground.load(); // playground loaded }); ``` ### `run` Type: [`() => Promise `](../api/interfaces/Playground.md#run) Runs the [result page](../features/result.html.md) (after any required compilation for code). ```js import { createPlayground } from 'livecodes'; createPlayground('#container').then(async (playground) => { await playground.run(); // new result page is displayed }); ``` ### `format` Type: [`(allEditors?: boolean) => Promise `](../api/interfaces/Playground.md#format) [Formats the code](../features/code-format.html.md). By default, the code in all editors (markup, style and script) is formatted. If you wish to format only the active editor, pass the value `false` as an argument. ```js import { createPlayground } from 'livecodes'; createPlayground('#container').then(async (playground) => { await playground.format(); // code in editors is formatted }); ``` ### `getShareUrl` Type: [`(shortUrl?: boolean) => Promise `](../api/interfaces/Playground.md#getshareurl) Gets a [share url](../features/share.html.md) for the current project. By default, the url has a long query string representing the compressed encoded config object. If the argument `shortUrl` was set to `true`, a short url is generated. ```js import { createPlayground } from 'livecodes'; createPlayground('#container').then(async (playground) => { const longUrl = await playground.getShareUrl(); const shortUrl = await playground.getShareUrl(true); }); ``` ### `getConfig` Type: [`(contentOnly?: boolean) => Promise `](../api/interfaces/Playground.md#getconfig) Gets a config object representing the playground state. This can be used to restore state if passed as [embed option](#createplayground) property on creating playground, or can be manipulated and loaded in run-time using [`setConfig`](#setconfig) method. ```js import { createPlayground } from 'livecodes'; createPlayground('#container').then(async (playground) => { const config = await playground.getConfig(); }); ``` ### `setConfig` Type: [`(config: Partial ) => Promise `](../api/interfaces/Playground.md#setconfig) Loads a new project using the passed configuration object. If it is a string, it is assumed to be a URL to a JSON file that contains the configuration object. It throws an error if the config object (or URL) is invalid. ```js import { createPlayground } from 'livecodes'; createPlayground('#container').then(async (playground) => { const config = { markup: { language: 'html', content: 'Hello World!', }, }; const newConfig = await playground.setConfig(config); // new project loaded }); ``` ### `getCode` Type: [`() => Promise `](../api/interfaces/Playground.md#getcode) Gets the playground code (including source code, source language and compiled code) for each editor (`markup`, `style`, `script`), in addition to result page HTML. ```js import { createPlayground } from 'livecodes'; createPlayground('#container').then(async (playground) => { const code = await playground.getCode(); // source code, language and compiled code for the script editor const { content, language, compiled } = code.script; // result page HTML const result = code.result; }); ``` ### `show` Type: [`(panel: 'editor' | 'markup' | 'style' | 'script' | 'console' | 'compiled' | 'tests' | 'result' | 'toggle-result', options?: { full?: boolean; line?: number; column?: number; zoom?: 1 | 0.5 | 0.25 }) => Promise`](../api/interfaces/Playground.md#show) Shows the selected panel, which is either: - Active Editor: `editor` - Specific Editor: `markup`, `style` or `script` - Tool: `console`, `compiled` or `tests` - Result page: `result` or `toggle-result` The second optional argument is an object: - It may have the boolean property `full`, which If `true`, selected editor or result page will take the full vertical and horizontal space of the playground, while tools will take the full vertical and half the horizontal space, leaving some space for the active editor. - The optional properties `line` and `column` allow scrolling to line/column number in the shown editor. - The optional property `zoom` sets the result page [zoom level](../features/result.html.md)#result-page-zoom) (the selected panel must be `result`). ```js import { createPlayground } from 'livecodes'; createPlayground('#container').then(async (playground) => { const delay = (duration) => new Promise((resolve) => { setTimeout(resolve, duration); }); await playground.show('toggle-result'); await delay(2000); await playground.show('style'); await delay(2000); await playground.show('result', { full: true }); await delay(2000); await playground.show('script'); await delay(2000); await playground.show('result', { zoom: 0.5 }); await delay(2000); await playground.show('console', { full: true }); }); ``` ### `runTests` Type: [`() => Promise<{ results: TestResult[] }>`](../api/interfaces/Playground.md#runtests) Runs project [tests](./../features/tests.html.md) (if present) and gets test results. ```js import { createPlayground } from 'livecodes'; createPlayground('#container').then(async (playground) => { const { results } = await playground.runTests(); }); ``` ### `watch` Type: [docs](../api/interfaces/Playground.md#watch) ```ts ((event: 'load', fn: () => void) => { remove: () => void }) & ((event: 'ready', fn: (data: { config: Config }) => void) => { remove: () => void }) & ((event: 'code', fn: (data: { code: Code; config: Config }) => void) => { remove: () => void }) & ((event: 'run', fn: (data: { code: Code; config: Config }) => void) => { remove: () => void }) & ((event: 'console', fn: (data: { method: string; args: any[] }) => void) => { remove: () => void }) & ((event: 'tests', fn: (data: { results: TestResult[]; error?: string }) => void) => { remove: () => void }) & ((event: 'destroy', fn: () => void) => { remove: () => void }); ``` Allows to watch for various playground events. It takes 2 arguments: event name and a callback function that will be called on every event. In some events, the callback function will be called with an object that supplies relevant data to the callback function (e.g. code, console output, test results). The `watch` method returns an object with a single method `remove`, which when called will remove the callback from watching further events. ```js import { createPlayground } from 'livecodes'; createPlayground('#container').then((playground) => { const codeWatcher = playground.watch('code', ({ code, config }) => { // this will run on every code change console.log('code:', code); console.log('config:', config); }); const consoleWatcher = playground.watch('console', ({ method, args }) => { // this will run on every console output console[method](...args); }); const testsWatcher = playground.watch('tests', ({ results }) => { // this will run when tests run results.forEach((testResult) => { console.log('status:', testResult.status); // "pass", "fail" or "skip" console.log(testResult.errors); // array of errors as strings }); }); // then later codeWatcher.remove(); consoleWatcher.remove(); testsWatcher.remove(); // events are no longer watched }); ``` These are the events that can be watched and the description of their callback functions: - `"load"`: Called when the playground first loads. ```ts ( event: "load", fn: () => void ) => { remove: () => void } ``` - `"ready"`: Called when a new project is loaded (including when [imported](../features/import.html.md)) and the playground is ready to run. ```ts ( event: "ready", fn: (data: { config: Config }) => void ) => { remove: () => void } ``` - `"code"`: Called when the playground "content" is changed (see [`getCode`](./js-ts.html.md)#getcode) and [`getConfig`](./js-ts.html.md)#getconfig)). This includes changes in: - Code (in editors) - Editor languages - [CSS processors](../features/css.html.md)#css-processors) - [External resources](../features/external-resources.html.md) - Project info (e.g. allows adding content in page head and attributes to `` element) - [Custom settings](../advanced/custom-settings.html.md) (e.g. allows changing [import maps](../features/module-resolution.html.md)#custom-module-resolution)) - Project title - [Test](../features/tests.html.md) code ```ts ( event: "code", fn: (data: { code: Code; config: Config }) => void ) => { remove: () => void } ``` - `"run"`: Called when running the playground code. ```ts ( event: "run", fn: (data: { code: Code; config: Config }) => void ) => { remove: () => void } ``` - `"console"`: Called when the playground console gets new outputs. The callback method is passed an object with 2 properties: `"method"` (e.g. `"log"`, `"error"`, etc.) and `"args"` (the arguments passed to the method, as an array). ```ts ( event: "console", fn: (data: { method: string; args: any[] }) => void ) => { remove: () => void } ``` - `"tests"`: Called when tests run and test results are available (see [`runTests`](./js-ts.html.md)#runtests)). ```ts ( event: "tests", fn: (data: { results: TestResult[]; error?: string }) => void ) => { remove: () => void } ``` - `"destroy"`: Called when the playground is destroyed. ```ts ( event: "destroy", fn: () => void ) => { remove: () => void } ``` ### `onChange` **Deprecated**: Use [`watch`](#watch) method instead. Type: [`(fn: ChangeHandler) => { remove: () => void }`](../api/interfaces/Playground.md#onchange) Allows to watch the playground for changes. It takes a callback function that will be called on every change. The callback function will be called with an object that has 2 properties: `code` and `config`, representing the current codes and configuration objects (see [`getCode`](#getcode) and [`getConfig`](#getconfig)). The `onChange` method returns an object with a single method `remove`, which when called will remove the callback from watching changes. ```js import { createPlayground } from 'livecodes'; createPlayground('#container').then((playground) => { const watcher = playground.onChange(({ code, config }) => { // this will run on every code change console.log('code:', code); console.log('config:', config); }); // then later watcher.remove(); // changes are no longer watched }); ``` ### `exec` Type: [`(command: APICommands, ...args: any[]) => Promise<{ output: any } | { error: string }>`](../api/interfaces/Playground.md#exec) Execute custom commands, including: - `"setBroadcastToken"`: Sets [broadcast `userToken`](../features/broadcast.html.md)#technical-details). ```js // in browser console of full app (e.g. https://livecodes.io) await livecodes.exec('setBroadcastToken', 'my-token'); ``` - `"showVersion"`: Logs the current LiveCodes app version, SDK version, git commit SHA, [permanent app URL](../features/permanent-url.html.md) and SDK URL in the browser console. ```js // in browser console of full app (e.g. https://livecodes.io) await livecodes.exec('showVersion'); ``` ### `destroy` Type: [`() => Promise `](../api/interfaces/Playground.md#destroy) Destroys the playground instance, and removes event listeners. Further call to any SDK methods throws an error. ```js import { createPlayground } from 'livecodes'; createPlayground('#container').then(async (playground) => { await playground.destroy(); // playground destroyed // any further SDK call throws an error }); ``` ## Styles ### Default Styles By default, the container element is styled when the SDK is initialized (including width, height, border, etc.). To disable default styles, set the container element attribute `data-default-styles` to `"false"` before initializing. Example: ```html ``` ### Height By default, the playground container height is set to `"300px"`. To change the height, either disable the default styles and override them, or simply set the `data-height` attribute to a number (in pixels) or any valid CSS value for `height` property (e.g. `"100%"` to take the full height of its parent element). Example: ```html ``` ## Demo export const sdkDemo = { js: `import { createPlayground } from "livecodes";\n\nconst params = {\n html: " Hello World!
",\n css: "h1 {color: blue;}",\n js: 'console.log("Hello, LiveCodes!")',\n console: "open",\n};\n\ncreatePlayground('#container', { params });\n`, html: '', };## Related - [Preact SDK](./preact.html.md) - [React SDK](./react.html.md) - [Solid SDK](./solid.html.md) - [Svelte SDK](./svelte.html.md) - [Vue SDK](./vue.html.md) - [Web Components SDK](./web-components.html.md) - [Embedded Playgrounds](../features/embeds.html.md) --- # Preact SDK import LiveCodes from '../../src/components/LiveCodes.tsx'; The Preact SDK is a thin wrapper around the [JavaScript SDK](js-ts.html.md) to provide an easy to use Preact component, yet retaining the full power, by having access to the [SDK methods](js-ts.html.md)#sdk-methods). ## Demo export const preactSDKDemo = { jsx: `import LiveCodes from "livecodes/preact";\n\nconst App = () => {\n const params = {\n html: " Hello World!
",\n css: "h1 {color: blue;}",\n js: 'console.log("Hello, World!")',\n console: "open",\n };\n\n return;\n};\n\nexport default App;\n`, }; ## Installation Please refer to the [SDK installation](./index.html.md)#installation) section. ## Usage The Preact component is provided as the default export from `livecodes/preact`. ```jsx title="JSX" livecodes render=link import LiveCodes from 'livecodes/preact'; export default () => ; ``` ### TypeScript Support Prop types are exported as `Props` from `livecodes/preact`. ```tsx title="TSX" livecodes render=link import LiveCodes, { type Props } from 'livecodes/preact'; const options: Props = { // embed options }; export default () => ; ``` For convenience, the following types are also exported from `livecodes/preact`:
`Code`, `Config`, `EmbedOptions`, `Language`, `Playground`. TypeScript types are [documented here](../api/globals.md). ### Props All [embed options](js-ts.html.md)#embed-options) are available as props with the corresponding types. Example: ```jsx title="JSX" livecodes render=link import LiveCodes from 'livecodes/preact'; const config = { markup: { language: 'markdown', content: '# Hello World!', }, }; export default () =>; ``` In addition, the following props are also available: - `className` Type: `string`. Class name(s) to add to playground container element. Example: ```jsx title="JSX" livecodes render=link import LiveCodes from 'livecodes/preact'; export default () => ; ``` - `height` Type: `string`. Sets the [height of playground container](js-ts.html.md)#height) element. Example: ```jsx title="JSX" livecodes render=link import LiveCodes from 'livecodes/preact'; export default () => ; ``` - `style` Type: `Record `. Defines styles to add to playground container element. Styles set here override the [default styles](js-ts.html.md)#default-styles). Example: ```tsx title="JSX" livecodes render=link import LiveCodes from 'livecodes/preact'; const style = { margin: 'auto', width: '80%', }; export default () => ; ``` - `sdkReady` Type: `(sdk: Playground) => void`. A callback function, that is provided with an instance of the [JavaScript SDK](js-ts.html.md) representing the current playground. This allows making use of full capability of the SDK by calling [SDK methods](js-ts.html.md)#sdk-methods). Example: ```tsx title="TSX" livecodes render=link import { useState } from 'preact/hooks'; import LiveCodes, { type Props } from 'livecodes/preact'; import type { Playground } from 'livecodes'; export default () => { const [playground, setPlayground] = useState (); const onReady = (sdk: Playground) => { setPlayground(sdk); }; const run = async () => { await playground?.run(); }; const options: Props = { config: { markup: { language: 'html', content: ' Hello World!
', }, }, }; return ( <>> ); }; ``` ### Reactive Props Changing any prop will cause the playground to reload with the new options. However, changing the `config` prop is an exception — it updates the playground in place using the SDK method [`setConfig`](js-ts.html.md)#setconfig), without triggering a full reload. This allows for a smooth update experience when only the configuration changes. Example: ```jsx title="JSX" livecodes render=link import { useState } from 'preact/hooks'; import LiveCodes from 'livecodes/preact'; export default () => { const [config, setConfig] = useState({ markup: { language: 'html', content: ' Hello World!
', }, }); function switchToMarkdown() { setConfig({ markup: { language: 'markdown', content: '# Hello World! (from Markdown)', }, }); } return ( <>> ); }; ``` ## Storybook See [storybook](pathname:///../stories/preact/) for usage examples. ## Related - [SDK Installation](./index.html.md)#installation) - [JS/TS SDK](./js-ts.html.md) - [React SDK](./react.html.md) - [Solid SDK](./solid.html.md) - [Svelte SDK](./svelte.html.md) - [Vue SDK](./vue.html.md) - [Web Components SDK](./web-components.html.md) - [Embedded Playgrounds](../features/embeds.html.md) --- # React SDK import LiveCodes from '../../src/components/LiveCodes.tsx'; The React SDK is a thin wrapper around the [JavaScript SDK](js-ts.html.md) to provide an easy to use react component, yet retaining the full power, by having access to the [SDK methods](js-ts.html.md)#sdk-methods). ## Demo export const reactSDKDemo = { jsx: `import LiveCodes from "livecodes/react";\n\nconst App = () => {\n const params = {\n html: " Hello World!
",\n css: "h1 {color: blue;}",\n js: 'console.log("Hello, World!")',\n console: "open",\n };\n\n return;\n};\n\nexport default App;\n`, }; ## Installation Please refer to the [SDK installation](./index.html.md)#installation) section. ## Usage The React component is provided as the default export from `livecodes/react`. ```jsx title="JSX" livecodes render=link lang=react import LiveCodes from 'livecodes/react'; export default () => ; ``` ### TypeScript Support Prop types are exported as `Props` from `livecodes/react`. ```tsx title="TSX" livecodes render=link lang=react.tsx import LiveCodes, { type Props } from 'livecodes/react'; const options: Props = { // embed options }; export default () => ; ``` For convenience, the following types are also exported from `livecodes/react`:
`Code`, `Config`, `EmbedOptions`, `Language`, `Playground`. TypeScript types are [documented here](../api/globals.md). ### Props All [embed options](js-ts.html.md)#embed-options) are available as props with the corresponding types. Example: ```jsx title="JSX" livecodes render=link lang=react import LiveCodes from 'livecodes/react'; const config = { markup: { language: 'markdown', content: '# Hello World!', }, }; export default () =>; ``` In addition, the following props are also available: - `className` Type: `string`. Class name(s) to add to playground container element. Example: ```jsx title="JSX" livecodes render=link lang=react import LiveCodes from 'livecodes/react'; export default () => ; ``` - `height` Type: `string`. Sets the [height of playground container](js-ts.html.md)#height) element. Example: ```jsx title="JSX" livecodes render=link lang=react import LiveCodes from 'livecodes/react'; export default () => ; ``` - `style` Type: `Record `. Defines styles to add to playground container element. Styles set here override the [default styles](js-ts.html.md)#default-styles). Example: ```tsx title="JSX" livecodes render=link lang=react import LiveCodes from 'livecodes/react'; const style = { margin: 'auto', width: '80%', }; export default () => ; ``` - `sdkReady` Type: `(sdk: Playground) => void`. A callback function, that is provided with an instance of the [JavaScript SDK](js-ts.html.md) representing the current playground. This allows making use of full capability of the SDK by calling [SDK methods](js-ts.html.md)#sdk-methods). Example: ```tsx title="TSX" livecodes render=link lang=react.tsx import { useState } from 'react'; import LiveCodes, { type Props } from 'livecodes/react'; import type { Playground } from 'livecodes'; export default () => { const [playground, setPlayground] = useState (); const onReady = (sdk: Playground) => { setPlayground(sdk); }; const run = async () => { await playground?.run(); }; const options: Props = { config: { markup: { language: 'html', content: ' Hello World!
', }, }, }; return ( <>> ); }; ``` ### Reactive Props Changing any prop will cause the playground to reload with the new options. However, changing the `config` prop is an exception — it updates the playground in place using the SDK method [`setConfig`](js-ts.html.md)#setconfig), without triggering a full reload. This allows for a smooth update experience when only the configuration changes. Example: ```jsx title="JSX" livecodes render=link lang=react import { useState } from 'react'; import LiveCodes from 'livecodes/react'; export default () => { const [config, setConfig] = useState({ markup: { language: 'html', content: ' Hello World!
', }, }); function switchToMarkdown() { setConfig({ markup: { language: 'markdown', content: '# Hello World! (from Markdown)', }, }); } return ( <>> ); }; ``` ## Storybook See [storybook](pathname:///../stories/react/) for usage examples. ## Related - [SDK Installation](./index.html.md)#installation) - [Preact SDK](./preact.html.md) - [Solid SDK](./solid.html.md) - [Svelte SDK](./svelte.html.md) - [Vue SDK](./vue.html.md) - [Web Components SDK](./web-components.html.md) - [Embedded Playgrounds](../features/embeds.html.md) --- # Solid SDK import LiveCodes from '../../src/components/LiveCodes.tsx'; The Solid SDK is a thin wrapper around the [JavaScript SDK](js-ts.html.md) to provide an easy to use Solid component, yet retaining the full power, by having access to the [SDK methods](js-ts.html.md)#sdk-methods). ## Demo export const solidSDKDemo = { solid: `import LiveCodes from "livecodes/solid";\n\nconst App = () => {\n const params = {\n html: " Hello World!
",\n css: "h1 {color: blue;}",\n js: 'console.log("Hello, World!")',\n console: "open",\n };\n\n return;\n};\n\nexport default App;\n`, }; ## Installation Please refer to the [SDK installation](./index.html.md)#installation) section. ## Usage The Solid component is provided as the default export from `livecodes/solid`. ```jsx title="JSX" livecodes render=link lang=solid import LiveCodes from 'livecodes/solid'; export default () => ; ``` ### TypeScript Support Prop types are exported as `Props` from `livecodes/solid`. ```tsx title="TSX" livecodes render=link lang=solid.tsx import LiveCodes, { type Props } from 'livecodes/solid'; const options: Props = { // embed options }; export default () => ; ``` For convenience, the following types are also exported from `livecodes/solid`:
`Code`, `Config`, `EmbedOptions`, `Language`, `Playground`. TypeScript types are [documented here](../api/globals.md). ### Props All [embed options](js-ts.html.md)#embed-options) are available as props with the corresponding types. Example: ```jsx title="JSX" livecodes render=link lang=solid import LiveCodes from 'livecodes/solid'; const config = { markup: { language: 'markdown', content: '# Hello World!', }, }; export default () =>; ``` In addition, the following props are also available: - `class` Type: `string`. Class name(s) to add to playground container element. Example: ```jsx title="JSX" livecodes render=link lang=solid import LiveCodes from 'livecodes/solid'; export default () => ; ``` - `height` Type: `string`. Sets the [height of playground container](js-ts.html.md)#height) element. Example: ```jsx title="JSX" livecodes render=link lang=solid import LiveCodes from 'livecodes/solid'; export default () => ; ``` - `style` Type: `JSX.CSSProperties`. Defines styles to add to playground container element. Styles set here override the [default styles](js-ts.html.md)#default-styles). Example: ```tsx title="JSX" livecodes render=link lang=solid import LiveCodes from 'livecodes/solid'; const style = { margin: 'auto', width: '80%', }; export default () => ; ``` - `sdkReady` Type: `(sdk: Playground) => void`. A callback function, that is provided with an instance of the [JavaScript SDK](js-ts.html.md) representing the current playground. This allows making use of full capability of the SDK by calling [SDK methods](js-ts.html.md)#sdk-methods). Example: ```tsx title="TSX" livecodes render=link lang=solid.tsx import { createSignal } from 'solid-js'; import LiveCodes, { type Props } from 'livecodes/solid'; import type { Playground } from 'livecodes'; export default () => { const [playground, setPlayground] = createSignal (); const onReady = (sdk: Playground) => { setPlayground(sdk); }; const run = async () => { await playground()?.run(); }; const options: Props = { config: { markup: { language: 'html', content: ' Hello World!
', }, }, }; return ( <>> ); }; ``` ### Reactive Props Changing any prop will cause the playground to reload with the new options. However, changing the `config` prop is an exception — it updates the playground in place using the SDK method [`setConfig`](js-ts.html.md)#setconfig), without triggering a full reload. This allows for a smooth update experience when only the configuration changes. Example: ```jsx title="JSX" livecodes render=link lang=solid import { createSignal } from 'solid-js'; import LiveCodes from 'livecodes/solid'; export default () => { const [config, setConfig] = createSignal({ markup: { language: 'html', content: ' Hello World!
', }, }); function switchToMarkdown() { setConfig({ markup: { language: 'markdown', content: '# Hello World! (from Markdown)', }, }); } return ( <>> ); }; ``` ## Storybook See [storybook](pathname:///../stories/solid/) for usage examples. ## Related - [SDK Installation](./index.html.md)#installation) - [JS/TS SDK](./js-ts.html.md) - [Preact SDK](./preact.html.md) - [React SDK](./react.html.md) - [Svelte SDK](./svelte.html.md) - [Vue SDK](./vue.html.md) - [Web Components SDK](./web-components.html.md) - [Embedded Playgrounds](../features/embeds.html.md) --- # Svelte SDK import LiveCodes from '../../src/components/LiveCodes.tsx'; The Svelte SDK is a thin wrapper around the [JavaScript SDK](js-ts.html.md) to provide an easy to use Svelte component, yet retaining the full power, by having access to the [SDK methods](js-ts.html.md)#sdk-methods). It requires Svelte 5 and uses [runes](https://svelte.dev/docs/svelte/what-are-runes) for reactivity. ## Demo export const svelteSDKDemo = { svelte: `\n\n \n`, }; ## Installation Please refer to the [SDK installation](./index.html.md)#installation) section. ## Usage The Svelte component is provided as the default export from `livecodes/svelte`. ```html title="Svelte" livecodes render=link lang=svelte ``` ### TypeScript Support Prop types are exported as `Props` from `livecodes/svelte`. ```html title="Svelte (TypeScript)" livecodes render=link lang=svelte ``` For convenience, the following types are also exported from `livecodes/svelte`:
`Code`, `Config`, `EmbedOptions`, `Language`, `Playground`. TypeScript types are [documented here](../api/globals.md). ### Props All [embed options](js-ts.html.md)#embed-options) are available as props with the corresponding types. Example: ```html title="Svelte" livecodes render=link lang=svelte``` In addition, the following props are also available: - `class` Type: `string`. Class name(s) to add to playground container element. Example: ```html title="Svelte" livecodes render=link lang=svelte ``` - `height` Type: `string`. Sets the [height of playground container](js-ts.html.md)#height) element. Example: ```html title="Svelte" livecodes render=link lang=svelte ``` - `style` Type: `Record `. Defines styles to add to playground container element. Styles set here override the [default styles](js-ts.html.md)#default-styles). Example: ```html title="Svelte" livecodes render=link lang=svelte ``` - `sdkReady` Type: `(sdk: Playground) => void`. A callback function, that is provided with an instance of the [JavaScript SDK](js-ts.html.md) representing the current playground. This allows making use of full capability of the SDK by calling [SDK methods](js-ts.html.md)#sdk-methods). Example: ```html title="Svelte (TypeScript)" livecodes render=link lang=svelte ``` ### Reactive Props Changing any prop will cause the playground to reload with the new options. However, changing the `config` prop is an exception — it updates the playground in place using the SDK method [`setConfig`](js-ts.html.md)#setconfig), without triggering a full reload. This allows for a smooth update experience when only the configuration changes. Example: ```html title="Svelte" livecodes render=link lang=svelte ``` ## Storybook See [storybook](pathname:///../stories/svelte/) for usage examples. ## Related - [SDK Installation](./index.html.md)#installation) - [JS/TS SDK](./js-ts.html.md) - [Preact SDK](./preact.html.md) - [React SDK](./react.html.md) - [Solid SDK](./solid.html.md) - [Vue SDK](./vue.html.md) - [Web Components SDK](./web-components.html.md) - [Embedded Playgrounds](../features/embeds.html.md) --- # Vue SDK import LiveCodes from '../../src/components/LiveCodes.tsx'; The Vue SDK is a thin wrapper around the [JavaScript SDK](js-ts.html.md) to provide an easy to use vue component, yet retaining the full power, by having access to the [SDK methods](js-ts.html.md)#sdk-methods). ## Demo export const vueSDKDemo = { vue: `\n\n\n \n\n`, }; ## Installation Please refer to the [SDK installation](./index.html.md)#installation) section. ## Usage The Vue component is provided as the default export from `livecodes/vue`. ```html title="Vue" livecodes render=link lang=vue ``` ### TypeScript Support Prop types are exported as `Props` from `livecodes/vue`. ```html title="Vue" livecodes render=link lang=vue ``` For convenience, the following types are also exported from `livecodes/vue`:
`Code`, `Config`, `EmbedOptions`, `Language`, `Playground`. TypeScript types are [documented here](../api/globals.md). ### Props All [embed options](js-ts.html.md)#embed-options) are available as props with the corresponding types. Example: ```html title="Vue" livecodes render=link lang=vue``` In addition, the following prop is also available: - `height` Type: `string`. Sets the [height of playground container](js-ts.html.md)#height) element. Example: ```html title="Vue" livecodes render=link lang=vue ``` ### Events - `"sdkReady"` Type: `(sdk: Playground) => void`. When the playground initializes, the event `"sdkReady"` is emitted. The event handler function is provided with an instance of the [JavaScript SDK](js-ts.html.md) representing the current playground. This allows making use of full capability of the SDK by calling [SDK methods](js-ts.html.md)#sdk-methods). Example: ```html title="Vue" livecodes render=link lang=vue ``` ### Styles Styles can be applied to the component [as usual](https://vuejs.org/guide/essentials/class-and-style.html#binding-html-classes). By default, a set of [default styles](js-ts.html.md)#default-styles) are applied to the playground container. Styles passed to the component override these default styles. Example: ```html title="Vue" livecodes render=link lang=vue ``` ### Reactive Props Changing any prop will cause the playground to reload with the new options. However, changing the `config` prop is an exception — it updates the playground in place using the SDK method [`setConfig`](js-ts.html.md)#setconfig), without triggering a full reload. This allows for a smooth update experience when only the configuration changes. Example: ```html title="Vue" livecodes render=link lang=vue ``` ## Storybook See [storybook](pathname:///../stories/vue/) for usage examples. ## Related - [SDK Installation](./index.html.md)#installation) - [JS/TS SDK](./js-ts.html.md) - [Preact SDK](./preact.html.md) - [React SDK](./react.html.md) - [Solid SDK](./solid.html.md) - [Svelte SDK](./svelte.html.md) - [Web Components SDK](./web-components.html.md) - [Embedded Playgrounds](../features/embeds.html.md) --- # Web Components SDK import LiveCodes from '../../src/components/LiveCodes.tsx'; The Web Components SDK is a wrapper around the [JavaScript SDK](js-ts.html.md) to provide an easy to use custom element (` `), yet retaining the full power, by having access to the [SDK methods](js-ts.html.md)#sdk-methods). ## Demo export const webComponentsSDKDemo = { markup: { language: 'html', content: ` ``` If the `lang` attribute is omitted, the defaults are `html`, `css`, and `javascript`. {/* #### Multi-File Mode Use a `filename` attribute instead of `lang` to provide multiple files. The language is inferred from the file extension. The element type (``, ` ``` */} #### Active Editor Use the `active` boolean attribute on a code element to set the initially active editor: ```html {5} title="HTML"`, }, }; Hello World!
## Installation Please refer to the [SDK installation](./index.html.md)#installation) section. ## Usage The custom element is registered by importing `livecodes/web-components`. ### Using a bundler ```html title="HTML" ``` ### Using a CDN Alternatively, you can load the web components SDK directly from a CDN using a script tag: import CodeBlock from '@theme/CodeBlock'; export const UMDCode = () => ( {` );`} ### TypeScript Support Types are exported from `livecodes/web-components` for convenience: ```ts title="TypeScript" import type { EmbedOptions, Playground } from 'livecodes/web-components'; ``` The following types are available:
`Code`, `Config`, `EmbedOptions`, `Language`, `Playground`. TypeScript types are [documented here](../api/globals.md). ### Declarative Code via Children \{#declarative-children} You can provide code for the playground declaratively using child elements inside a wrapper ``. This avoids the need to set code in JavaScript strings and gives you full IDE syntax highlighting and autocomplete. The outer `` element (highlighted in the example below) ensures that inner ```` {/* In multi-file mode, `active` sets the active file: ```html title="HTML" Hello
``` */} #### Combining Children with Config You can combine declarative children with `config` (attribute or property) and `params`. The merge precedence is: 1. **`config` property** (highest — explicit programmatic override) 2. **Children** (declarative defaults) 3. **`config` attribute** (lowest — inline JSON settings) Children are best used for code content, while the `config` attribute is useful for non-code settings: ```html title="HTML" Hello
``` If the `config` property is set programmatically for the same editor, the property wins: ```html title="HTML" Hello Tailwind
``` #### Reactivity Children content is reactive. Programmatically changing the content inside the wrapper `` will trigger a call to [`setConfig`](js-ts.html.md)#setconfig) on the existing playground. However, updating the [`config` property](#properties) is the preferred way to change the content. ```html title="HTML" Default from children
``` ### Attributes The following HTML attributes are supported and correspond to [embed options](js-ts.html.md)#embed-options): | Attribute | Type | Description | | ---------------------- | --------- | --------------------------------------------------------------------------------------------------------------------- | | `app-url` | `string` | The URL of the LiveCodes app. | | `config` | `string` | A JSON string representing the [config object](../api/interfaces/Config.md). | | `import` | `string` | A resource to [import](../features/import.html.md). | | `loading` | `string` | When to load the playground (`"click"`, `"lazy"`, or `"eager"`). | | `params` | `string` | A JSON string representing [URL Query parameters](../configuration/query-params.html.md). | | `template` | `string` | A [starter template](../features/templates.html.md) to load. | | `headless` | `boolean` | Whether to use the headless mode of LiveCodes. | | `height` | `string` | Sets the [height of playground container](js-ts.html.md)#height) element. | | `data-default-styles` | `string` | If set to `"false"`, disables the [default styles](js-ts.html.md)#default-styles) applied to the playground container. | Example: ```html title="HTML" Hello World!
``` #### Default Styles By default, the ` ` element is styled when the playground is initialized (including height, border, etc.). To disable default styles, set the `data-default-styles` attribute to `"false"`. ```html title="HTML" ``` ### Properties For complex values it is recommended to use JavaScript properties on the element. - `config` Type: `object | string`. The [config object](../api/interfaces/Config.md) for the playground or the URL of the config file. Example: ```html title="HTML" ``` - `params` Type: `object`. An object that represents [URL Query parameters](../configuration/query-params.html.md). Example: ```html title="HTML" ``` - `sdk` Type: `Playground | undefined` (read-only). The playground SDK instance. Available after the playground has been initialized. This allows making use of the full capability of the SDK by calling [SDK methods](js-ts.html.md)#sdk-methods). Example: ```html title="HTML" ``` ### Events - `sdkready` Fired when the SDK is ready. The SDK instance is available via `event.detail.sdk` or via the [`sdk`](#properties) property on the element. Use this event to access the [SDK methods](js-ts.html.md)#sdk-methods). Example: ```html title="HTML" ``` ### Reactive Attributes and Properties Changing any attribute or property will cause the playground to reload with the new options. However, changing the `config` property is an exception — it updates the playground in place using the SDK method [`setConfig`](js-ts.html.md)#setconfig), without triggering a full reload. This allows for a smooth update experience when only the configuration changes. Similarly, changing the `height` attribute and [children content](#reactivity) also update the playground in place without triggering a full reload. Example: ```html title="HTML" ``` ### Methods - `destroy()` Destroys the playground instance and cleans up resources. This is also called automatically when the element is removed from the DOM. Example: ```html title="HTML" ``` ## Storybook See [storybook](pathname:///../stories/web-components/) for usage examples. ## Related - [SDK Installation](./index.html.md)#installation) - [JS/TS SDK](./js-ts.html.md) - [Preact SDK](./preact.html.md) - [React SDK](./react.html.md) - [Solid SDK](./solid.html.md) - [Svelte SDK](./svelte.html.md) - [Vue SDK](./vue.html.md) - [Embedded Playgrounds](../features/embeds.html.md) --- # Headless Mode import LiveCodes from '../../src/components/LiveCodes.tsx'; The LiveCodes [SDK](../sdk/index.html.md) can be used to create playgrounds in headless mode. In this mode, no visible output is displayed in the embedding web page. However, all [SDK methods](../sdk/js-ts.html.md)#sdk-methods) are accessible (e.g. for [updating code](./js-ts.html.md)#setconfig), [getting compiled code](./js-ts.html.md)#getcode), console output, [result HTML](./js-ts.html.md)#getcode), [shareable URLs](./js-ts.html.md)#getshareurl), [formatting code](./js-ts.html.md)#format), [running tests](./js-ts.html.md)#runtests), etc). This provides the power of leveraging the wide range of features and language support offered by LiveCodes, while retaining full control over the UI. ## Usage To create a headless playground, set the [embed option](./js-ts.html.md)#embed-options) [`headless`](../sdk/js-ts.html.md)#headless) to `true`. Please note that in headless mode, the first parameter (`container`) of the function [`createPlayground`](../sdk/js-ts.html.md)#createplayground) is optional and can be omitted. Example: ```js {4} import { createPlayground } from 'livecodes'; createPlayground({ headless: true, config: { markup: { language: 'markdown', content: '# Hello World!', }, }, }).then(async (playground) => { const code = await playground.getCode(); console.log(code.markup.compiled); // " Hello World!
" console.log(code.result); // (result page HTML) }); ``` ## Examples The following examples show how to use the headless mode to make a Markdown editor, an MDX editor and a Python interpreter. :::tip You may want to view the following playgrounds in full screen (using the full screen button in the top right of each playground). ::: ### Markdown Editor In this demo, code changes are watched using the SDK method [`watch('code', callback)`](./js-ts.html.md)#watch). The callback function accepts an argument which is an object with the properties `code` and `config` (see [`getCode`](./js-ts.html.md)#getcode) and [`getConfig`](./js-ts.html.md)#getconfig)). The compiled code is obtained as `code.markup.compiled`. export const mdDemo = { markup: { language: 'html', content: `\nLoading...\n\n\x3Cscript type="module">\n import { createPlayground } from "https://cdn.jsdelivr.net/npm/livecodes";\n import debounce from "https://esm.sh/debounce";\n\n const initialCode = "# Hello, LiveCodes!\\n\\n";\n\n // the code editor\n const editor = CodeMirror.fromTextArea(document.getElementById("editor"), {\n lineNumbers: true,\n mode: "markdown",\n });\n editor.setSize("100%", 200);\n editor.setValue(initialCode);\n\n // the playground\n const options = {\n headless: true,\n };\n\n const livecodes = await createPlayground(options);\n\n const compile = async () => {\n await livecodes.setConfig({\n autoupdate: false,\n markup: {\n language: "markdown",\n content: editor.doc.getValue(),\n },\n });\n };\n\n // watch for changes\n editor.on("change", debounce(compile, 1000));\n livecodes.watch("code", ({ code, config }) => {\n createSandbox(document.querySelector("#output"), code.markup.compiled);\n });\n\n await compile();\n\n // create a sandbox for safe execution of compiled code\n function createSandbox (container, html) {\n const iframe = document.createElement("iframe");\n iframe.src = "https://livecodes-sandbox.pages.dev/v9/";\n iframe.sandbox =\n "allow-same-origin allow-downloads allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-presentation allow-scripts";\n iframe.onload = () => {\n iframe.contentWindow.postMessage({ html }, "*");\n };\n container.innerHTML = "";\n container.appendChild(iframe);\n return iframe;\n };\n\x3C/script>\n\n\n\x3Cscript src="https://unpkg.com/codemirror@5.65.15/lib/codemirror.js">\x3C/script>\n\x3Cscript src="https://unpkg.com/codemirror@5.65.15/mode/markdown/markdown.js">\x3C/script>\n\n\n` }}### MDX Editor In this demo, code changes are watched using the SDK method [`watch('code', callback)`](./js-ts.html.md)#watch). The callback function accepts an argument which is an object with the properties `code` and `config` (see [`getCode`](./js-ts.html.md)#getcode) and [`getConfig`](./js-ts.html.md)#getconfig)). The result HTML is obtained as `code.result`. :::tip If you do not want to run the result page in the headless playground and only want to get the generated result HTML, you can set the configuration option [`autoupdate](../configuration/configuration-object.html.md)#autoupdate) to `false`. ::: export const mdxDemo = { markup: { language: 'html', content: `\n Loading...\n\n\x3Cscript type="module">\n import { createPlayground } from "https://cdn.jsdelivr.net/npm/livecodes";\n import debounce from "https://esm.sh/debounce";\n\n const initialCode = \`import { useState, useEffect } from 'react';\n\nexport const Hello = ({name}) => {\n const [count, setCount] = useState(0);\n return (\n <>\nHello, {name}!
\nYou clicked {count} times.
\n \n >\n );\n};\n\n\n\n## MDX in short\n\n- ❤️ Powerful\n- 💻 Everything is a component\n- 🔧 Customizable\n- 📚 Markdown-based\n- 🔥 Blazingly blazing fast\n\n> from [mdxjs.com](https://mdxjs.com/)\n\`;\n\n // the code editor\n const editor = CodeMirror.fromTextArea(document.getElementById("editor"), {\n lineNumbers: true,\n mode: "markdown",\n });\n editor.setSize("100%", 200);\n editor.setValue(initialCode);\n\n // the playground\n const options = {\n headless: true,\n config: { autoupdate: false },\n };\n\n const livecodes = await createPlayground(options);\n\n const compile = async () => {\n await livecodes.setConfig({\n autoupdate: false,\n markup: {\n language: "mdx",\n content: editor.doc.getValue(),\n },\n });\n };\n\n // watch for changes\n editor.on("change", debounce(compile, 1000));\n livecodes.watch("code", ({ code, config }) => {\n createSandbox(document.querySelector("#output"), code.result);\n });\n\n await compile();\n\n // create a sandbox for safe execution of compiled code\n function createSandbox (container, html) {\n const iframe = document.createElement("iframe");\n iframe.src = "https://livecodes-sandbox.pages.dev/v7/";\n iframe.sandbox =\n "allow-same-origin allow-downloads allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-presentation allow-scripts";\n iframe.onload = () => {\n iframe.contentWindow.postMessage({ html }, "*");\n };\n container.innerHTML = "";\n container.appendChild(iframe);\n return iframe;\n };\n\x3C/script>\n\n\n\x3Cscript src="https://unpkg.com/codemirror@5.65.15/lib/codemirror.js">\x3C/script>\n\x3Cscript src="https://unpkg.com/codemirror@5.65.15/mode/markdown/markdown.js">\x3C/script>\n\n\n` }} ### Python Interpreter In this demo, console output is obtained using the SDK method [`watch('code', callback)`](./js-ts.html.md)#watch). The callback function accepts an argument which is an object with the properties `method` and `args` indicating the console method and the arguments that were passed (as an array). export const pyDemo = { markup: { language: 'html', content: `\n Loading...\n\n\x3Cscript type="module">\n import { createPlayground } from "https://cdn.jsdelivr.net/npm/livecodes";\n import debounce from "https://esm.sh/debounce";\n\n const initialCode = \`def say_hello(name):\n return f"Hello, {name}!"\n\nprint(say_hello("LiveCodes"))\n\`;\n\n // the code editor\n const editor = CodeMirror.fromTextArea(document.getElementById("editor"), {\n lineNumbers: true,\n mode: "python",\n });\n editor.setSize("100%", 250);\n editor.setValue(initialCode);\n\n // the playground\n const options = {\n headless: true,\n };\n\n const livecodes = await createPlayground(options);\n\n const run = async () => {\n await livecodes.setConfig({\n autoupdate: true,\n script: {\n language: "python",\n content: editor.doc.getValue(),\n },\n });\n };\n\n // watch for changes\n editor.on("change", debounce(run, 1000));\n livecodes.watch("console", ({ method, args }) => {\n const output = document.querySelector("#output");\n output.innerHTML = args.join("\\n");\n if (method === "error") {\n output.style.color = "red";\n } else {\n output.style.color = "unset";\n }\n });\n\n await run();\n\x3C/script>\n\n\n\x3Cscript src="https://unpkg.com/codemirror@5.65.15/lib/codemirror.js">\x3C/script>\n\x3Cscript src="https://unpkg.com/codemirror@5.65.15/mode/python/python.js">\x3C/script>\n\n\n` }}--- # Advanced Topics {#advanced-topics-custom-content-top} ```mdx-code-block import DocCardList from '@theme/DocCardList'; import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; item.docId !== 'languages/index')}/> ``` --- # Custom Settings Custom settings allow you to configure various aspects of a LiveCodes project. They are defined as a JSON object and provide fine-grained control over languages, compilers, processors, templates, module resolution, and more. ## Where to Use ### Standalone App In the standalone app, the custom settings screen can be accessed from: - The editor toolbar - below the editor (the `{}` button) - The Project menu → Custom Settings … - The URL parameter [`?screen=custom-settings`](https://livecodes.io/?screen=custom-settings). ### SDK For embedded playgrounds, use the [`config.customSettings`](../configuration/configuration-object.html.md)#customsettings) property of the [configuration object](../configuration/configuration-object.html.md): ```js import { createPlayground } from 'livecodes'; createPlayground('#container', { config: { customSettings: { // your settings here }, }, }); ``` ### URL Parameter Custom settings can also be passed as a [URL query parameter](../configuration/query-params.html.md) using `customSettings`: ``` https://livecodes.io/?customSettings={"jsx":{"jsxFactory":"h"}} ``` ## Language and Compiler Settings Custom settings can be passed as options to the compiler of any supported [language](../languages/index.html.md). The property name is the language name, and the value is a JSON object that gets passed to the compiler. Many languages document their supported options on their respective documentation pages. **Example:** TypeScript compiler options ```json title="Custom Settings" { "typescript": { "target": "es2020", "jsx": "react-jsx" } } ``` :::note Custom settings must be valid JSON. Functions, callbacks, and non-serializable values are not allowed. ::: ## CSS Processor Settings CSS processors can also be configured via custom settings using the processor name as the property. **Example:** PostCSS Preset Env ```json title="Custom Settings" { "postcssPresetEnv": { "stage": 2, "features": { "nesting-rules": true } } } ``` ## Template Data ### Pre-rendered (Default) For template languages (e.g. [EJS](../languages/ejs.html.md), [Handlebars](../languages/handlebars.html.md), [Mustache](../languages/mustache.html.md), [Jinja](../languages/jinja.html.md), etc.), template expressions are evaluated during compilation. The values are supplied using the `template.data` property: ```json title="Custom Settings" { "template": { "data": { "name": "LiveCodes", "description": "A Code Playground That Just Works!", } } } ``` ```html title="EJS Template" Hello, <%= name %>!
Description: <%= description %>
``` ### Dynamic Template rendering can be deferred to runtime by setting `template.prerender` to `false`. Values can then be provided at runtime via `window.livecodes.templateData`: ```json title="Custom Settings" { "template": { "prerender": false, "data": { "name": "Default Name" } } } ``` ```js title="Script Editor" window.livecodes.templateData = { name: 'Dynamic Value', }; ``` :::caution When `prerender` is `false`, the `window.livecodes.templateData` assignment must occur before the page `load` event, as template rendering happens on page load. ::: ## Module Resolution ### Custom Import Maps Custom import maps allow you to override module URLs, specify versions, or import unpublished libraries: ```json title="Custom Settings" { "imports": { "react": "https://esm.sh/react@18.3.1", "lodash": "https://cdn.jsdelivr.net/npm/lodash@4.17.21", "my-lib": "https://my-server.com/path/to/library.js" } } ``` This is equivalent to using [` ``` The inline equivalent uses the same attributes without `src`: ```html ``` For a complete example, see the [DOM blocks source](https://github.com/live-codes/blockly-utils/tree/master/src). :::tip You may want to add the code defining custom blocks in the [`hiddenContent` property of the editor](../configuration/configuration-object.html.md)#markup) for embedded playgrounds. ::: ### DOM Blocks Custom DOM manipulation blocks are provided by [`@live-codes/blockly-utils`](https://www.npmjs.com/package/@live-codes/blockly-utils). These blocks allow reading and writing to DOM elements, handling events, creating elements, and more. See [blockly starter template](https://livecodes.io/?template=blockly) for a demo. They can be used by adding the following code to the HTML: ```html ``` ## Language Info ### Name `blockly` ### Extensions `.blockly.xml`, `.xml` ### Editor `script` ## Compiler [Blockly](https://developers.google.com/blockly) ### Version `blockly`: v11.1.1 ## Starter Template https://livecodes.io/?template=blockly ## Links - [Blockly](https://developers.google.com/blockly) - [Blockly on GitHub](https://github.com/google/blockly) - [@live-codes/blockly-utils](https://www.npmjs.com/package/@live-codes/blockly-utils) --- # Civet [Civet](https://civet.dev/) is a programming language that compiles to TypeScript or JavaScript. It features a concise syntax with significant whitespace, pattern matching, and modern JavaScript features. ## Usage ### Demo import LiveCodes from '../../src/components/LiveCodes.tsx';## Language Info ### Name `civet` ### Extensions `.civet` ### Editor `script` ## Compiler [Civet compiler](https://civet.dev/) ### Version `@danielx/civet`: v0.11.0 ## Code Formatting Not supported. ## Starter Template https://livecodes.io/?template=civet ## Links - [Civet](https://civet.dev/) - [Civet on GitHub](https://github.com/DanielXMoore/Civet) --- # Clio [Clio](https://clio-lang.org/) is a fast, distributed, functional programming language that compiles to JavaScript. It is made to take advantage of multiple CPUs and CPU cores (parallelism) by default. LiveCodes compiles Clio code to JavaScript and executes it in the browser. ## Usage ### Demo import LiveCodes from '../../src/components/LiveCodes.tsx'; ## Language Info ### Name `clio` ### Extensions `.clio` ### Editor `script` ## Compiler [Clio compiler](https://github.com/clio-lang/clio): v0.12.0. ## Code Formatting Not supported. ## Starter Template https://livecodes.io/?template=clio ## Links - [Clio](https://clio-lang.org/) - [Clio Documentation](https://docs.clio-lang.org/) - [Clio on GitHub](https://github.com/clio-lang/clio) --- # ClojureScript [ClojureScript](https://clojurescript.org/) is a robust, practical, and fast programming language with a set of useful features that together form a simple, coherent, and powerful tool. ClojureScript is a compiler for [Clojure](https://clojure.org/) that targets JavaScript.
In LiveCodes, it runs in the browser using [Cherry](https://github.com/squint-cljs/cherry). :::info Note Lisp language family supported in LiveCodes includes [Common Lisp](./commonlisp.html.md), [Scheme](./scheme.html.md), [ClojureScript](./clojurescript.html.md) and [Fennel](./fennel.html.md). ::: ## Language Info ### Name `clojurescript` ### Extensions `cljs`, `cljc`, `clj`, `edn`, `clojure` ### Editor `script` ## Compiler [Cherry](https://github.com/squint-cljs/cherry) If `JSX` is used (using `#jsx` reader tag - [example](https://github.com/squint-cljs/cherry/blob/60adcf6e3a8fb940a80c6a193599da0272fe3058/examples/jsx/pages/component.cljs)), it is also compiled ([JSX](./jsx.html.md)). See [example usage](#example-usage). ### Version `cherry-cljs`: v0.2.18 ## Code Formatting Using [Parinfer](https://shaunlebron.github.io/parinfer/). ## Example Usage import LiveCodes from '../../src/components/LiveCodes.tsx'; export const params = { cljs: `(ns demo\n${' '};; you can use npm modules\n${' '}(:require ["canvas-confetti$default" :as confetti]))\n\n(let [el (js/document.getElementById "test")]\n${' '}(.addEventListener el "click"\n ${' '}(fn []\n ${' '}(confetti)\n${' '}(println "test"))))\n`, html: '', console: 'open', };Using React (with JSX): ## Starter Template https://livecodes.io/?template=clojurescript ## Links - [ClojureScript official website](https://clojurescript.org/) - [Clojure official website](https://clojure.org/) - [Cherry repo](https://github.com/squint-cljs/cherry) --- # CoffeeScript [CoffeeScript](https://coffeescript.org/) is a little language that compiles into JavaScript. ## Usage import LiveCodes from '../../src/components/LiveCodes.tsx'; This example demonstrates usage in LiveCodes: ## Language Info ### Name `coffeescript` ### Extensions `.coffee` ### Aliases `coffee`, `coffeescript` ### Editor `script` ## Compiler The official [CoffeeScript compiler](https://www.npmjs.com/package/coffeescript). ### Version `coffeescript`: v2.7.0 ## Starter Template https://livecodes.io/?template=coffeescript ## Links - [Official website](https://coffeescript.org/) - [Language Reference](https://coffeescript.org/#language) - [CoffeeScript on GitHub](https://github.com/jashkenas/coffeescript) --- # Common Lisp [Common Lisp](https://common-lisp.net/) is a dialect of the Lisp programming language. In LiveCodes, Common Lisp code runs in the browser using [JSCL](https://github.com/jscl-project/jscl), a Common Lisp to JavaScript compiler. :::info Note Lisp language family supported in LiveCodes includes [Common Lisp](./commonlisp.html.md), [Scheme](./scheme.html.md), [ClojureScript](./clojurescript.html.md) and [Fennel](./fennel.html.md). ::: ## Usage LiveCodes runs Common Lisp code in the browser. JSCL implements a subset of Common Lisp, but covers enough functionality to write practical code. import LiveCodes from '../../src/components/LiveCodes.tsx'; This example demonstrates basic Common Lisp syntax and functionality: ### JS Interoperability Please see [JSCL docs](https://github.com/jscl-project/jscl/wiki/JSCL-and-manipulations-with-JS-objects) ## Language Info ### Name `commonlisp` ### Aliases/Extensions `common-lisp`, `lisp` ### Editor `script` ## Compiler [JSCL](https://github.com/jscl-project/jscl) - Common Lisp to JavaScript compiler ## Code Formatting Using [Parinfer](https://shaunlebron.github.io/parinfer/). ## Limitations Since JSCL is a subset of Common Lisp, it doesn't implement all Common Lisp features. See the [JSCL documentation](https://github.com/jscl-project/jscl#status) for more information. ## Starter Template https://livecodes.io/?template=commonlisp ## Links - [Common Lisp](https://common-lisp.net/) - [JSCL](https://github.com/jscl-project/jscl) - [Common Lisp: A Gentle Introduction to Symbolic Computation](https://www.cs.cmu.edu/~dst/LispBook/) - [Practical Common Lisp](http://www.gigamonkeys.com/book/) --- # C/C++ (Wasm) The C++ (Wasm) language support in LiveCodes uses [Clang](https://clang.llvm.org/) compiled to WebAssembly via [`@chriskoch/cpp-wasm`](https://www.npmjs.com/package/@chriskoch/cpp-wasm). Unlike the [JSCPP-based C++](./cpp.html.md) interpreter, this provides a real C/C++ compiler running on WebAssembly. ## Usage ### Demo import LiveCodes from '../../src/components/LiveCodes.tsx'; ### Standard I/O C++ programs use `cin` for input and `cout` for output. Input is passed from JavaScript via `livecodes.cpp.run()`, and output is returned as a string. ### JavaScript Interoperability JavaScript can interact with the C++ runtime using the `livecodes.cpp` global: - `livecodes.cpp.input` — set this to pass input to the program (read by `cin`) - `livecodes.cpp.run(input?)` — execute the program with optional input, returns a promise that resolves to `{ input, output, exitCode, error }` - `livecodes.cpp.loaded` — a promise that resolves when the runtime is ready ### Live Reload The Clang WebAssembly compiler is a large download. Initial loading may take some time, after which subsequent runs should be faster. By default, when code is updated, the environment is re-used. This behavior is used for performance reasons. However, in order to get full reload and start a new environment, insert this comment in the code: ```cpp // __livecodes_reload__ ``` This comment can be added in the [`hiddenContent` property of the editor](../configuration/configuration-object.html.md)#markup) for embedded playgrounds. ## Language Info ### Name `cpp-wasm` ### Aliases `clang`, `c++-wasm` ### Extensions `.wasm.cpp`, `.cppwasm`, `.cwasm`, `.clang.cpp`, `.clang`, `.cpp`, `.c`, `.C`, `.cp`, `.cxx`, `.c++`, `.cppm`, `.ixx`, `.ii`, `.hpp`, `.h` ### Editor `script` ## Compiler [Clang](https://clang.llvm.org/) compiled to WebAssembly via [@chriskoch/cpp-wasm](https://www.npmjs.com/package/@chriskoch/cpp-wasm) ## Code Formatting Not supported. ## Starter Template https://livecodes.io/?template=cpp-wasm ## Links - [Clang](https://clang.llvm.org/) - [@chriskoch/cpp-wasm](https://www.npmjs.com/package/@chriskoch/cpp-wasm) - [C++ (JSCPP)](./cpp.html.md) in LiveCodes --- # C++ [C++](https://isocpp.org/) is a general-purpose programming language with a bias towards systems programming. It supports procedural, object-oriented, and generic programming paradigms. LiveCodes runs C++ in the browser using [JSCPP](https://github.com/felixhao28/JSCPP), a C++ interpreter written in JavaScript that runs in a Web Worker. ## Usage ### Demo import LiveCodes from '../../src/components/LiveCodes.tsx'; ### Standard I/O C++ programs in LiveCodes use `cin` for input and `cout` for output. Input is passed from JavaScript via `livecodes.cpp.run()`, and output is returned as a string. ### JavaScript Interoperability JavaScript can interact with the C++ runtime using the `livecodes.cpp` global: - `livecodes.cpp.input` — set this to pass input to the program (read by `cin`) - `livecodes.cpp.run(input?)` — execute the C++ program with optional input, returns a promise that resolves to `{ input, output, exitCode, error }` - `livecodes.cpp.loaded` — a promise that resolves when the runtime is ready ## Language Info ### Name `cpp` ### Extensions `.cpp`, `.c`, `.C`, `.cp`, `.cxx`, `.c++`, `.cppm`, `.ixx`, `.ii`, `.hpp`, `.h` ### Editor `script` ## Compiler [JSCPP](https://github.com/felixhao28/JSCPP) (C++ interpreter) ## Code Formatting Not supported. ## Starter Template https://livecodes.io/?template=cpp ## Links - [C++ Reference](https://en.cppreference.com/) - [JSCPP](https://github.com/felixhao28/JSCPP) --- # C# (Wasm) C# is a high-level, general-purpose, object-oriented programming language developed by Microsoft. In LiveCodes, C# runs in the browser using Blazor WebAssembly with a WebAssembly-based .NET runtime. ## Usage Demo: import LiveCodes from '../../src/components/LiveCodes.tsx'; export const csharpConfig = { activeEditor: 'script', script: { language: 'csharp-wasm', content: `using System; public class Program { public static void Main() { int[] sortedArray = { 1, 3, 5, 7, 9, 11, 13, 15 }; int itemToSearch = 7; int result = BinarySearch(sortedArray, 0, sortedArray.Length - 1, itemToSearch); if (result == -1) { Console.WriteLine("Result: Item not found in the array."); } else { Console.WriteLine($"Result: Item found at index -> {result}"); } } public static int BinarySearch(int[] arr, int left, int right, int item) { if (right >= left) { int mid = left + (right - left) / 2; if (arr[mid] == item) { return mid; } if (arr[mid] > item) { return BinarySearch(arr, left, mid - 1, item); } return BinarySearch(arr, mid + 1, right, item); } return -1; } }`, }, mode: 'simple', editor: 'auto', tools: { status: 'full', }, }; ### Communication with JavaScript The C# code runs in the context of the result page. A few helper properties and methods are available in the browser global `livecodes.csharp` object: - `livecodes.csharp.input`: The initial standard input passed to the C# code. - `livecodes.csharp.loaded`: A promise that resolves when the C# environment (Blazor WebAssembly) is fully loaded. Other helpers should be used after this promise resolves. - `livecodes.csharp.output`: The standard output from the C# code execution. - `livecodes.csharp.run`: A function that runs the C# code with new input. This function takes a string as input and returns a promise that resolves with an object containing the `output`, `error`, and `exitCode` properties. Example: ## Language Info ### Name `csharp-wasm` ### Aliases / Extensions `cs`, `csharp`, `wasm.cs`, `cs-wasm` ### Editor `script` ## Compiler Blazor WebAssembly with .NET WebAssembly runtime. ### Version .NET 9.0 ## Code Formatting using [Prettier](https://prettier.io/) ## Live Reload By default, new code changes are sent to the result page for re-evaluation without a full page reload, avoiding the need to reinitialize the Blazor environment. This behavior can be disabled by adding the code comment `// __livecodes_reload__` to the C# code, which forces a full page reload. This comment can be added in the `hiddenContent` property of the editor for embedded playgrounds. ## Example Usage ```csharp using System; public class Program { public static void Main() { Console.WriteLine("Hello, LiveCodes C#!"); } } ``` ## Starter Template https://livecodes.io/?template=csharp-wasm ## Links - [C#](https://learn.microsoft.com/en-us/dotnet/csharp/) - [Blazor WebAssembly](https://dotnet.microsoft.com/en-us/apps/aspnet/web-apps/blazor) --- # CSS import LiveCodes from '../../src/components/LiveCodes.tsx'; [CSS](https://developer.mozilla.org/docs/Web/CSS) (Cascading Style Sheets) is a style sheet language used for describing the presentation of a document written in HTML. It controls layout, colors, fonts, and the overall visual appearance of web pages. ## Demo export const cssConfig = { activeEditor: 'style', markup: { language: 'html', content: ` `, }, style: { language: 'css', content: `.container { font-family: sans-serif; max-width: 600px; margin: 2em auto; padding: 1.5em; border-radius: 8px; background: #f0f4f8; box-shadow: 0 2px 8px rgba(0,0,0,0.1); } h1 { color: #2d3748; } p { color: #4a5568; line-height: 1.6; } ul { list-style: none; padding: 0; display: flex; gap: 1em; } li { background: #3182ce; color: white; padding: 0.5em 1em; border-radius: 4px; } `, }, };Hello, LiveCodes!
This is styled with CSS.
- Flexible
- Powerful
- Beautiful
## Usage CSS code added to the [style editor](../features/css.html.md)#style-editor) is added as-is without any compilation to the [result page](../features/result.html.md). There is no need to add a full page structure (e.g. ``, ``, ``, ` ``` ### Module Imports npm modules can be imported as described in the section about [module resolution](../features/module-resolution.html.md), including bare module imports and importing from different CDNs. ### Root Element To mount the application instance to a specific DOM element use `"livecodes-app"` as the element `id` in the HTML. Otherwise, if that element is not found, Riot components are mounted on a new `div` element added to `document.body`. ## Language Info ### Name `riot` ### Aliases `riotjs` ### Extensions `.riot`, `.riotjs` ### Editor `script` ## Compiler [Riot.js compiler](https://riot.js.org/) ### Version `riot`: v9.2.2 ## Code Formatting Using [Prettier](https://prettier.io/). ## Custom Settings [Custom settings](../advanced/custom-settings.html.md) added to the property `riot` can include compiler options and template data. Please check the [Riot.js documentation](https://riot.js.org/compiler/) for full reference. Please note that custom settings should be valid JSON (i.e. functions are not allowed). **Example:** ```json title="Custom Settings" { "riot": { "template": "pug" } } ``` ## Starter Template https://livecodes.io/?template=riot ## Links - [Riot.js](https://riot.js.org/) - [Riot.js GitHub](https://github.com/riot/riot) --- # Ruby (Wasm) [Ruby](https://ruby-lang.org/) is a dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write. LiveCodes uses [ruby.wasm](https://github.com/ruby/ruby.wasm) to run Ruby in the browser. > ruby.wasm is a collection of [WebAssembly](https://webassembly.org/) ports of the [CRuby](https://github.com/ruby/ruby). It enables running Ruby application on browsers, WASI compatible WebAssembly runtimes, and Edge Computing platforms. > > [ruby.github.io/ruby.wasm/](https://ruby.github.io/ruby.wasm/) :::info Note LiveCodes also supports running Ruby using [Opal](https://opalrb.com/) which is a Ruby to JavaScript source-to-source compiler. Read documentation [here](./ruby.html.md). ::: ## Usage LiveCodes runs Ruby in the browser, including the stdlib. JavaScript interoperability and DOM access is achieved using [`"JS"` module](https://ruby.github.io/ruby.wasm/JS.html). See the [starter template](#starter-template) for an example. ## Language Info ### Name `ruby-wasm` ### Extension `.wasm.rb` ### Alias `rubywasm` ### Editor `script` ## Compiler [ruby.wasm](https://github.com/ruby/ruby.wasm) ### Version ruby.wasm v2.7.2, running Ruby v3.4 ## Code Formatting Not supported for Ruby. ## Example Usage import LiveCodes from '../../src/components/LiveCodes.tsx'; export const params = { 'ruby-wasm': `class User\n attr_accessor :name\n\n def initialize(name)\n @name = name\n end\n\n def admin?\n @name == 'Admin'\n end\nend\n\nuser = User.new('Bob')\n\n# the output will go to the console\nputs user\nputs user.admin?\n`, console: 'full', }; This example demonstrates stdlib usage, JavaScript interoperability and DOM access: ## Starter Template https://livecodes.io/?template=ruby-wasm ## Links - [Ruby](https://ruby-lang.org/) - [Ruby documentation](https://ruby-lang.org/en/documentation/) - [ruby.wasm](https://github.com/ruby/ruby.wasm) - [Ruby using Opal](./ruby.html.md) in LiveCodes --- # Ruby [Ruby](https://ruby-lang.org/) is a dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write. LiveCodes runs Ruby in the browser using [Opal](https://opalrb.com/). > Opal is a Ruby to JavaScript source-to-source compiler. > It comes packed with the Ruby corelib you know and love. > It is both fast as a runtime and small in its footprint. > > [opalrb.com](https://opalrb.com/) :::info Note LiveCodes also supports running Ruby using [ruby.wasm](https://github.com/ruby/ruby.wasm) which is a collection of WebAssembly ports of the official [CRuby](https://github.com/ruby/ruby). Read documentation [here](./ruby-wasm.html.md) ::: ## Usage LiveCodes runs Ruby in the browser, including [corelib](https://opalrb.com/docs/api/v1.7.3/corelib/index.html) and the supported [stdlib](https://opalrb.com/docs/api/v1.7.3/stdlib/index.html). JavaScript interoperability and DOM access is achieved using [`"Native"` module](https://opalrb.com/docs/api/v1.7.3/stdlib/Native). See the [starter template](#starter-template) for an example. ## Language Info ### Name `ruby` ### Extension `.rb` ### Editor `script` ## Compiler [Opal](https://opalrb.com/) ### Version Opal v1.8.2 ## Code Formatting Not supported for Ruby. ## Example Usage import LiveCodes from '../../src/components/LiveCodes.tsx'; export const params = { ruby: `class User\n attr_accessor :name\n\n def initialize(name)\n @name = name\n end\n\n def admin?\n @name == 'Admin'\n end\nend\n\nuser = User.new('Bob')\n\n# the output will go to the console\nputs user\nputs user.admin?\n`, console: 'full', }; This example demonstrates stdlib usage, JavaScript interoperability and DOM access: ## Starter Template https://livecodes.io/?template=ruby ## Links - [Ruby](https://ruby-lang.org/) - [Ruby documentation](https://ruby-lang.org/en/documentation/) - [Opal](https://opalrb.com/) - [ruby.wasm](./ruby-wasm.html.md) in LiveCodes --- # Sass import LiveCodes from '../../src/components/LiveCodes.tsx'; [Sass](https://sass-lang.com/) (Syntactically Awesome Style Sheets) is a CSS preprocessor that uses the indented syntax (no curly braces or semicolons). It adds features like variables, nesting, mixins, and functions to CSS. :::info Sass has two syntaxes. The **indented syntax** (`.sass`) is documented here. For the **SCSS syntax** (`.scss`), which uses curly braces and semicolons like CSS, see [SCSS](./scss.html.md). ::: ## Demo export const sassConfig = { activeEditor: 'style', markup: { language: 'html', content: ` `, }, style: { language: 'sass', content: `$primary: #3182ce $bg: #f0f4f8 $radius: 8px =flex-center display: flex gap: 1em .container font-family: sans-serif max-width: 600px margin: 2em auto padding: 1.5em border-radius: $radius background: $bg box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) h1 color: #2d3748 p color: #4a5568 line-height: 1.6 .features +flex-center list-style: none padding: 0 li background: $primary color: white padding: 0.5em 1em border-radius: $radius `, }, };Hello, Sass!
This is styled with Sass indented syntax.
- Variables
- Nesting
- Mixins
## Usage Sass code added to the [style editor](../features/projects.html.md)#style-editor) is compiled to CSS before being added to the [result page](../features/result.html.md). Sass uses the **indented syntax**, which relies on indentation instead of curly braces and newlines instead of semicolons. For more details about CSS support in LiveCodes, including CSS processors, style imports, CSS modules, and CSS frameworks, see the [CSS feature documentation](../features/css.html.md). ## Loading External Styles Sass supports loading external stylesheets and modules using `@use`, `@import`, and `meta.load-css()`. [Bare module](../features/module-resolution.html.md)#bare-module-imports) specifiers are resolved to full CDN URLs. ### Using `@use` You can load npm packages with `@use`: ```sass @use "bootstrap/scss/bootstrap" as * ``` ### Using `@import` You can import external modules and use their mixins: ```sass @import 'sass-utils' .center @include block--center width: fit-content ``` ### Using `meta.load-css()` You can dynamically load stylesheets from URLs using the built-in `sass:meta` module: ```sass @use "sass:meta" @include meta.load-css("https://raw.githubusercontent.com/live-codes/livecodes/refs/heads/develop/src/livecodes/styles/app.scss") ``` :::tip For more information about loading and importing styles, see the [Style Imports](../features/css.html.md)#style-imports) documentation. ::: ## Language Info ### Name `sass` ### Extensions `.sass` ### Editor `style` ## Compiler [Sass](https://sass-lang.com/) is compiled using the official [Dart Sass](https://sass-lang.com/dart-sass/) compiler (running in the browser). ### Version `sass`: v1.93.3 ### Custom Settings [Custom settings](../advanced/custom-settings.html.md) added to the property `sass` are passed as a JSON object to the Sass compiler during compile. Please check the [Sass JavaScript API documentation](https://sass-lang.com/documentation/js-api/interfaces/stringoptions/) for full reference. Please note that custom settings should be valid JSON (i.e. functions are not allowed). **Example:** ```json title="Custom Settings" { "sass": { "style": "compressed" } } ``` ## Code Formatting Code formatting is not supported for the Sass indented syntax. [Prettier](https://prettier.io/) supports SCSS (`.scss`) but not the indented `.sass` syntax. ## Links - [Sass Official Website](https://sass-lang.com/) - [Sass Documentation](https://sass-lang.com/documentation/) - [Sass Indented Syntax](https://sass-lang.com/documentation/syntax/#the-indented-syntax) - [SCSS in LiveCodes](./scss.html.md) - [CSS feature documentation in LiveCodes](../features/css.html.md) --- # Scheme [Scheme](https://www.scheme.org/) is a classic programming language in the Lisp family. It emphasizes functional programming and domain-specific languages but adapts to other styles. In LiveCodes, Scheme code runs in the browser using [BiwaScheme](https://www.biwascheme.org/), a Scheme interpreter written in JavaScript. :::info Note Lisp language family supported in LiveCodes includes [Common Lisp](./commonlisp.html.md), [Scheme](./scheme.html.md), [ClojureScript](./clojurescript.html.md) and [Fennel](./fennel.html.md). ::: ## Usage LiveCodes runs Scheme code in the browser. BiwaScheme [implements](https://www.biwascheme.org/doc/features.html) most of the features of [R7RS small](https://small.r7rs.org/), including first-class continuation and tail call optimization. **Example:** import LiveCodes from '../../src/components/LiveCodes.tsx'; export const basicSchemeDemo = { activeEditor: 'script', markup: { language: 'html', content: ` `, }, style: { language: 'css', content: `.container, .container button { text-align: center; font: 1em sans-serif; } .logo { width: 150px; } `, }, script: { language: 'scheme', content: `(let ((title "Scheme")) (set-content! "#title" title)) (let ((counter 0)) (add-handler! "#counter-button" "click" (lambda (ev) (set! counter (+ counter 1)) (set-content! "#counter" (number->string counter))))) ; check console (let ((time-now (date-hour (current-date)))) (console-log (cond ((< time-now 12) "Good morning") ((< time-now 18) "Good afternoon") (else "Good evening")))) ` } }Hello, World!
![]()
You clicked 0 times.
### JS Interoperability See [BiwaScheme docs](https://www.biwascheme.org/doc/features.html#javascript-language-interface). ## Language Info ### Name `scheme` ### Extensions `.scm` ### Editor `script` ## Compiler [BiwaScheme](https://www.biwascheme.org/), a Scheme interpreter written in JavaScript. ### Version `biwascheme`: v0.8.0 ## Code Formatting Using [Parinfer](https://shaunlebron.github.io/parinfer/). ## Limitations BiwaScheme implements most of the features of R7RS small, however some features are not supported. See the [BiwaScheme documentation](https://github.com/biwascheme/biwascheme#conformance) for more information. ## Starter Template https://livecodes.io/?template=scheme ## Links - [Scheme Programming Language](https://www.scheme.org/) - [BiwaScheme](https://www.biwascheme.org/) - [The Scheme Programming Language (4th Edition)](https://www.scheme.com/tspl4/) - [Structure and Interpretation of Computer Programs](https://mitp-content-server.mit.edu/books/content/sectbyfn/books_pres_0/6515/sicp.zip/index.html) --- # SCSS import LiveCodes from '../../src/components/LiveCodes.tsx'; [SCSS](https://sass-lang.com/) (Sassy CSS) is the main syntax of the Sass CSS preprocessor. It uses curly braces and semicolons like CSS, so every valid CSS stylesheet is also valid SCSS. It adds features like variables, nesting, mixins, and functions to CSS. :::info Sass has two syntaxes. The **SCSS syntax** (`.scss`), which uses curly braces and semicolons like CSS, is documented here. For the **indented syntax** (`.sass`), see [Sass](./sass.html.md). ::: ## Demo export const scssConfig = { activeEditor: 'style', markup: { language: 'html', content: ` `, }, style: { language: 'scss', content: `$primary: #3182ce; $bg: #f0f4f8; $radius: 8px; @mixin flex-center { display: flex; gap: 1em; } .container { font-family: sans-serif; max-width: 600px; margin: 2em auto; padding: 1.5em; border-radius: $radius; background: $bg; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); h1 { color: #2d3748; } p { color: #4a5568; line-height: 1.6; } } .features { @include flex-center; list-style: none; padding: 0; li { background: $primary; color: white; padding: 0.5em 1em; border-radius: $radius; } } `, }, };Hello, SCSS!
This is styled with SCSS syntax.
- Variables
- Nesting
- Mixins
## Usage SCSS code added to the [style editor](../features/projects.html.md)#style-editor) is compiled to CSS before being added to the [result page](../features/result.html.md). SCSS uses a CSS-like syntax with curly braces and semicolons. Since it is a superset of CSS, plain CSS works as-is and you can adopt Sass features incrementally. For more details about CSS support in LiveCodes, including CSS processors, style imports, CSS modules, and CSS frameworks, see the [CSS feature documentation](../features/css.html.md). ## Loading External Styles SCSS supports loading external stylesheets and modules using `@use`, `@import`, and `meta.load-css()`. [Bare module](../features/module-resolution.html.md)#bare-module-imports) specifiers are resolved to full CDN URLs. ### Using `@use` You can load npm packages with `@use`: ```scss @use 'bootstrap/scss/bootstrap' as *; ``` ### Using `@import` You can import external modules and use their mixins: ```scss @import 'sass-utils'; .center { @include block--center; width: fit-content; } ``` ### Using `meta.load-css()` You can dynamically load stylesheets from URLs using the built-in `sass:meta` module: ```scss @use 'sass:meta'; @include meta.load-css( 'https://raw.githubusercontent.com/live-codes/livecodes/refs/heads/develop/src/livecodes/styles/app.scss' ); ``` :::tip For more information about loading and importing styles, see the [Style Imports](../features/css.html.md)#style-imports) documentation. ::: ## Language Info ### Name `scss` ### Extensions `.scss` ### Editor `style` ## Compiler [SCSS](https://sass-lang.com/) is compiled using the official [Dart Sass](https://sass-lang.com/dart-sass/) compiler (running in the browser). ### Version `sass`: v1.93.3 ### Custom Settings [Custom settings](../advanced/custom-settings.html.md) added to the property `scss` are passed as a JSON object to the Sass compiler during compile. Please check the [Sass JavaScript API documentation](https://sass-lang.com/documentation/js-api/interfaces/stringoptions/) for full reference. Please note that custom settings should be valid JSON (i.e. functions are not allowed). **Example:** ```json title="Custom Settings" { "scss": { "style": "compressed" } } ``` ## Code Formatting Using [Prettier](https://prettier.io/). ## Links - [Sass Official Website](https://sass-lang.com/) - [Sass Documentation](https://sass-lang.com/documentation/) - [SCSS Syntax](https://sass-lang.com/documentation/syntax/) - [Sass (indented syntax) in LiveCodes](./sass.html.md) - [CSS feature documentation in LiveCodes](../features/css.html.md) --- # Solid import LiveCodes from '../../src/components/LiveCodes.tsx'; import RunInLiveCodes from '../../src/components/RunInLiveCodes.tsx'; [Solid](https://www.solidjs.com/) is a JavaScript framework for making interactive web applications. Solid offers very similar syntax to [React](https://react.dev/), with strong focus on [reactivity](https://www.solidjs.com/guides/reactivity) using signals. Solid supports templating in 3 forms [JSX](./jsx.html.md), Tagged Template Literals and Solid's HyperScript variant, although JSX is the predominate form. Solid also supports [TypeScript](./typescript.html.md) (See [Solid-TS](./solid.tsx.html.md)). ## Demo ## Usage For usage, see documentation for [JSX](./jsx.html.md) and [TypeScript](./typescript.html.md) support in LiveCodes. ## Language Info ### Name `solid` ### Extension `solid.jsx` ### Editor `script` ## Compiler [Official Solid JSX compiler](https://github.com/ryansolid/dom-expressions/tree/main/packages/babel-plugin-jsx-dom-expressions) (`babel-preset-solid`) ### Version `babel-preset-solid`: v1.9.10 ## Code Formatting Using [Prettier](https://prettier.io/). ## Custom Settings [Custom settings](../advanced/custom-settings.html.md) added to the property `solid` are passed to the Babel compiler during compile. Please check the [documentation](https://github.com/ryansolid/dom-expressions/tree/main/packages/babel-plugin-jsx-dom-expressions#plugin-options) for full reference. In addition, the option `disableAutoRender` can be set to `true` to disable [auto-rendering](./jsx#auto-rendering). Please note that custom settings should be valid JSON (i.e. functions are not allowed). **Example:** ```json title="Custom Settings" { "solid": { "disableAutoRender": true } } ``` ## Starter Template https://livecodes.io/?template=solid (uses TSX) ## Links - [Solid](https://www.solidjs.com/) - [JSX](https://react.dev/learn/writing-markup-with-jsx) - [TypeScript](https://www.typescriptlang.org/) --- # Solid (TS) import LiveCodes from '../../src/components/LiveCodes.tsx'; import RunInLiveCodes from '../../src/components/RunInLiveCodes.tsx'; [Solid](https://www.solidjs.com/) is a JavaScript framework for making interactive web applications. Solid offers very similar syntax to [React](https://react.dev/), with strong focus on [reactivity](https://www.solidjs.com/guides/reactivity) using signals. Solid supports templating in 3 forms [JSX](./jsx.html.md), Tagged Template Literals and Solid's HyperScript variant, although JSX is the predominate form. Solid also supports [TypeScript](./typescript.html.md). ## Demo ## Usage For usage, see documentation for [JSX](./jsx.html.md) and [TypeScript](./typescript.html.md) support in LiveCodes. ## Language Info ### Name `solid.tsx` ### Extension `solid.tsx` ### Editor `script` ## Compiler [Official Solid JSX compiler](https://github.com/ryansolid/dom-expressions/tree/main/packages/babel-plugin-jsx-dom-expressions) (`babel-preset-solid`) ### Version `babel-preset-solid` version 1.9.10 ## Code Formatting Using [Prettier](https://prettier.io/). ## Custom Settings [Custom settings](../advanced/custom-settings.html.md) added to the property `solid.tsx` are passed to the Babel compiler during compile. Please check the [documentation](https://github.com/ryansolid/dom-expressions/tree/main/packages/babel-plugin-jsx-dom-expressions#plugin-options) for full reference. In addition, the option `disableAutoRender` can be set to `true` to disable [auto-rendering](./jsx#auto-rendering). Please note that custom settings should be valid JSON (i.e. functions are not allowed). **Example:** ```json title="Custom Settings" { "solid": { "disableAutoRender": true } } ``` ## Starter Template https://livecodes.io/?template=solid ## Links - [Solid](https://www.solidjs.com/) - [JSX](https://react.dev/learn/writing-markup-with-jsx) - [TypeScript](https://www.typescriptlang.org/) --- # SQL (SQLite) [SQLite](https://www.sqlite.org/) is a small, fast, self-contained, high-reliability, full-featured, SQL database engine. LiveCodes runs SQLite (compiled to [Wasm](https://webassembly.org/)) in the browser using [SQL.js](https://sql.js.org/). :::info Note Please note that LiveCodes also supports [PostgreSQL](./postgresql.html.md). ::: ## Usage The SQL code runs (in the browser) and the output is produced as a JSON object. This JSON object is added to the [result page](../features/result.html.md) in a `script` block with type `application/json`. [Helper methods](#helper-methods) are provided for easy access/rendering of the JSON object (see below). ### Helper Methods The JavaScript object `livecodes.sql` is globally available in the [result page](../features/result.html.md). This can be used in `script` blocks in the [markup editor](../features/projects.html.md) (page HTML - see HTML editor is [example usage](#example-usage)). It provides the following methods for easy access/rendering of the JSON object: - `livecodes.sql.getResult` Type: `() => Promise<{ data: Array<{ columns: string[]; values: unknown[][]; }>}>`: Returns a promise that resolves to the JSON object. The object has a single property `data` which is an array of objects, each representing the output of a query (e.g. `SELECT * FROM table`). Each object has two properties `columns` (an array of column names) and `values` (an array of arrays of values). In case of errors, the promise rejects with the error message. Example: ```html title="HTML" ``` - `livecodes.sql.getResultAsObjects` Type: `() => Promise<{ [key: string]: unknown; }[][]>`: Returns a promise that resolves to the data as an array (representing queries/tables) of arrays (representing rows) of objects. Each object has key/value pairs for the column names and their values. In case of errors, the promise rejects with the error message. Example: ```html title="HTML" ``` - `livecodes.sql.render: (element?: HTMLElement | string) => Promise `: Accepts a single parameter which can be a DOM element or a CSS selector and renders the JSON object as HTML `table`(s) in that element. If no element is specified, it renders the table(s) in `document.body`. Example: ```html title="HTML" ``` :::info Note Helper methods for SQLite are identical to those for [PostgreSQL](./postgresql.html.md). So the same code can be used for both engines. ::: ### Example Usage import LiveCodes from '../../src/components/LiveCodes.tsx'; ### Custom Settings [Custom settings](../advanced/custom-settings.html.md) added to the property `sql` are used during running the SQL code. It is a JSON object with the following properties: - `dbURL`: a URL to a SQLite database. It is downloaded and used to run the SQL code ([CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) must be enabled). Changes are NOT persisted to the remote database. - `scriptURLs`: An array of URLs to SQL scripts that should be loaded before running the SQL code. - `params`: An object that can be used to pass parameters to the SQL code. Please note that custom settings should be valid JSON (i.e. functions are not allowed). **Example:** ```json title="Custom Settings" { "postgresql": { "dbURL": "https://myserver.com/sqlite.db", "scriptURLs": ["https://myserver.com/sql.sql"], "params": { "param1": "value1", "param2": "value2" } } } ``` ## Language Info ### Name `sql` ### Aliases/Extensions `sql`, `sqlite`, `sqlite3` ### Editor `script` ## Compiler [SQL.js](https://sql.js.org/) ### Version `sql.js`: v1.10.3 ## Code Formatting using [`sql-formatter`](https://github.com/sql-formatter-org/sql-formatter) ## Starter Template https://livecodes.io/?template=sql ## Links - [SQLite official website](https://www.sqlite.org/) - [SQLite syntax documentation](https://www.sqlite.org/lang.html) - [SQL.js official website](https://sql.js.org/) - [PostgreSQL in LiveCodes](./postgresql.html.md) --- # Stencil [Stencil](https://stenciljs.com/) is a compiler for generating Web Components. It combines the best concepts of modern frameworks — reactive data-binding, TypeScript, and JSX — into a tool that produces standards-compliant custom elements. ## Usage ### Demo import LiveCodes from '../../src/components/LiveCodes.tsx'; ### Component Syntax Stencil components are written in TypeScript with decorators and JSX. They are rendered as custom HTML elements: ```tsx import { Component, Prop, State, h } from "@stencil/core"; @Component({ tag: "my-counter", styles: `button { font: 1em sans-serif; }`, }) export class MyCounter { @Prop() label: string; @State() count = 0; render() { return ( ); } } ``` The component is then used in HTML as a custom element: ```html{this.label}: {this.count}
``` ## Language Info ### Name `stencil` ### Extensions `.stencil.tsx` ### Editor `script` ## Compiler [Stencil compiler](https://stenciljs.com/docs/compiler-api) ### Version `@stencil/core`: v3.2.2 ## Code Formatting Using [Prettier](https://prettier.io/). ## Custom Settings [Custom settings](../advanced/custom-settings.html.md) added to the property `stencil` are passed as transpile options to the Stencil compiler. Please check the [documentation](https://github.com/ionic-team/stencil/blob/1b8b7ec21f2622d05c9aafa417b2abdd4f2597a4/src/declarations/stencil-public-compiler.ts#L2311) for full reference. Please note that custom settings should be valid JSON (i.e. functions are not allowed). **Example:** ```json title="Custom Settings" { "stencil": { "target": "es2019" } } ``` ## Starter Template https://livecodes.io/?template=stencil ## Links - [Stencil](https://stenciljs.com/) - [Stencil on GitHub](https://github.com/stenciljs/core) --- # Stylis import LiveCodes from '../../src/components/LiveCodes.tsx'; [Stylis](https://stylis.js.org/) is a lightweight CSS preprocessor and parser. It supports CSS-like syntax with nesting, auto-prefixing, and other transformations. ## Demo export const stylisConfig = { activeEditor: 'style', markup: { language: 'html', content: ` `, }, style: { language: 'stylis', content: `.container { font-family: sans-serif; max-width: 600px; margin: 2em auto; padding: 1.5em; h1 { color: #2d3748; } p { color: #4a5568; } } .box { background: #4a90d9; color: white; padding: 1em; border-radius: 8px; user-select: none; transition: transform 0.3s ease; &:hover { transform: scale(1.05); } }`, }, };Hello, Stylis!
A lightweight CSS preprocessor.
Nested styles with auto-prefixing
## Usage Stylis code added to the [style editor](../features/projects.html.md)#style-editor) is compiled to CSS before being added to the [result page](../features/result.html.md). For more details about CSS support in LiveCodes, including CSS processors, style imports, CSS modules, and CSS frameworks, see the [CSS feature documentation](../features/css.html.md). ### Loading External Styles Stylis supports importing external stylesheets using the `@import` rule. [Bare module](../features/module-resolution.html.md)#bare-module-imports) specifiers are resolved to full CDN URLs. ```stylis @import "normalize.css"; ``` :::tip For more information about loading and importing styles, see the [Style Imports](../features/css.html.md)#style-imports) documentation. ::: ## Language Info ### Name `stylis` ### Extensions `.stylis` ### Editor `style` ## Compiler [Stylis](https://stylis.js.org/) ### Version `stylis`: v4.3.6 ## Code Formatting Not supported. ## Links - [Stylis Official Website](https://stylis.js.org/) - [Stylis on GitHub](https://github.com/thysultan/stylis) - [CSS feature documentation in LiveCodes](../features/css.html.md) --- # Stylus import LiveCodes from '../../src/components/LiveCodes.tsx'; [Stylus](https://stylus-lang.com/) is an expressive, dynamic CSS preprocessor. It supports both an indented, minimal syntax (optional braces, colons and semicolons) and regular CSS-like syntax, and adds variables, nesting, mixins and functions to CSS. ## Demo export const stylusConfig = { activeEditor: 'style', markup: { language: 'html', content: ` `, }, style: { language: 'stylus', content: `primary = #3182ce bg = #f0f4f8 radius = 8px flex-center() display flex gap 1em .container font-family sans-serif max-width 600px margin 2em auto padding 1.5em border-radius radius background bg box-shadow 0 2px 8px rgba(0, 0, 0, 0.1) h1 color #2d3748 p color #4a5568 line-height 1.6 .features flex-center() list-style none padding 0 li background primary color white padding 0.5em 1em border-radius radius `, }, };Hello, Stylus!
This is styled with Stylus.
- Variables
- Nesting
- Mixins
## Usage Stylus code added to the [style editor](../features/projects.html.md)#style-editor) is compiled to CSS before being added to the [result page](../features/result.html.md). Stylus has a very flexible syntax. Braces, colons and semicolons are optional, so you can write terse, indentation-based styles or use a more CSS-like style. Variables are defined by simple assignment (e.g. `primary = #3182ce`). For more details about CSS support in LiveCodes, including CSS processors, style imports, CSS modules, and CSS frameworks, see the [CSS feature documentation](../features/css.html.md). ## Loading External Styles Stylus supports importing external stylesheets using the `@import` rule. [Bare module](../features/module-resolution.html.md)#bare-module-imports) specifiers are resolved to full CDN URLs. ```stylus @import 'normalize.css' ``` :::tip For more information about loading and importing styles, see the [Style Imports](../features/css.html.md)#style-imports) documentation. ::: ## Language Info ### Name `stylus` ### Extensions `.styl` ### Editor `style` ## Compiler [Stylus](https://stylus-lang.com/) is compiled using the official [Stylus](https://www.npmjs.com/package/stylus) compiler (running in the browser). ### Version `stylus`: v0.54.5 ## Code Formatting Code formatting is not supported for Stylus. ## Links - [Stylus Official Website](https://stylus-lang.com/) - [Stylus Documentation](https://stylus-lang.com/docs/) - [Stylus on GitHub](https://github.com/stylus/stylus) - [CSS feature documentation in LiveCodes](../features/css.html.md) --- # Sucrase [Sucrase](https://sucrase.io/) is a super-fast alternative to [Babel](./babel.html.md) for when you can target modern JS runtimes. ## Language Info ### Name `sucrase` ### Extension `.sucrase` ### Editor `script` ## Compiler The official [Sucrase compiler](https://github.com/alangpierce/sucrase). ### Version `sucrase`: v3.32.0 ## Custom Settings [Custom settings](../advanced/custom-settings.html.md) added to the property `sucrase` are passed as a JSON object to the [`transform` function](https://github.com/alangpierce/sucrase#usage-from-code) during compile. Please check the [documentation](https://github.com/alangpierce/sucrase) for full reference. By default, the following transforms are enabled: `['jsx', 'typescript']` Please note that custom settings should be valid JSON (i.e. functions are not allowed). **Example:** ```json { "sucrase": { "transforms": ["typescript", "imports"] } } ``` ## Example Usage import LiveCodes from '../../src/components/LiveCodes.tsx'; export const params = { sucrase: 'export const Greet = (name: string) => <>Hello {name}!>;', compiled: 'open', }; ## Links - [Sucrase official website](https://sucrase.io/) - [Sucrase GitHub Repo](https://github.com/alangpierce/sucrase) --- # Svelte [Svelte](https://svelte.dev/docs/svelte/overview) is a framework for building user interfaces on the web. It uses a compiler to turn declarative components written in HTML, CSS and JavaScript. ## Usage Svelte components can be used as documented in the [docs](https://svelte.dev/docs/svelte/svelte-files). See below for usage. ### Demo import LiveCodes from '../../src/components/LiveCodes.tsx'; import RunInLiveCodes from '../../src/components/RunInLiveCodes.tsx'; ### CSS Frameworks [CSS Frameworks](../features/css.html.md)#css-processors) supported in LiveCodes (e.g. [Tailwind CSS](./tailwindcss.html.md), [UnoCSS](./unocss.html.md), [WindiCSS](./windicss.html.md)) can detect class names added in Svelte components. Make sure that the required utility is enabled (from style editor menu or in `processors` property of [configuration object](../configuration/configuration-object.html.md)#processors)). See [example below](#multiple-components). ### Languages and Pre-Processors Many of the [languages supported in LiveCodes](./index.html.md) can be used. The value of `lang` attribute can be the language name (specified in its documentation page) or any of its aliases (extensions). You may wrap the markup in a `template` element if you want to specify the `lang` attribute. export const processorsDemo = { svelte: `\nh1 {msg}\n\n\n\n\n\n`, }; ### Module Imports npm modules can be imported as described in the section about [module resolution](../features/module-resolution.html.md), including bare module imports and importing from different CDNs. Stylesheets imported in the `script` block are added as `` tags in the page `head`. Example: export const importsDemo = { svelte: `\n `, };You clicked {count} times.
Module imports can be customized using import maps as described in [module resolution](../features/module-resolution.html.md)#custom-module-resolution) documentations. ### Multiple Components Svelte is supported in both [markup](../features/projects.html.md)#markup-editor) and [script](../features/projects.html.md)#script-editor) editors. This allows having a component in the markup editor that imports (and passes props to) a component in the script editor. The opposite is not supported. This can be done using relative import of a file name in the same directory. Any file name will resolve to the component in the script editor, e.g. `./script.svelte`, `./Component.svelte`, `./Counter.svelte`, etc. export const multi = { markup: { language: 'svelte', content: ` `, }, script: { language: 'svelte', content: ` {count}`, }, style: { language: 'css', content: '@import "tailwindcss";\n', }, processors: ['tailwindcss'], }Please note that LiveCodes [does not have the concept of a file system](../features/projects.html.md). However, you can configure [editor options](../configuration/configuration-object.html.md)#markup) like `title`, `order` and `hideTitle` to simulate multiple files, change editor order or even hide editors. Example: export const multiFiles = { ...multi, markup: { ...multi.markup, title: 'App.svelte', }, script: { ...multi.script, title: 'Counter.svelte', }, style: { ...multi.style, title: 'styles.css', order: 3, }, }; When both markup and script editors use Svelte, the component in the markup editor is used as the main component rendered in the [root element](#root-element). To render the component in the script editor, it has to be imported and used by the main component. ### Importing External Components External Svelte components can be imported. The import URL has to be an absolute URL ending with `.svelte` extension. Any bare or relative imports in the imported files are resolved and compiled recursively. Example: ```html ``` ### Root Element To mount the application instance to a specific DOM element use `"livecodes-app"` as the element `id` in the HTML. Otherwise, if that element is not found, a new `div` element is added to `document.body` and is used to mount the instance. Example: export const customRoot = { markup: { language: 'html', content: ` Custom Root Element
...other page content
`, }, script: { language: 'svelte', content: `\nI'm a {name} component`, }, };## Language Info ### Name `svelte` ### Extensions `.svelte` ### Editor `script`, `markup` ## Compiler The official [Svelte compiler](https://svelte.dev/docs/svelte/svelte-compiler). ### Version `svelte`: v5.39.12 ## Code Formatting Using [Prettier](https://prettier.io/). ## Starter Template https://livecodes.io/?template=svelte ## Links - [Svelte](https://svelte.dev/) - [Svelte documentations](https://svelte.dev/docs/svelte/overview) --- # Tailwind CSS import LiveCodes from '../../src/components/LiveCodes.tsx'; import RunInLiveCodes from '../../src/components/RunInLiveCodes.tsx'; export const basicDemo = { activeEditor: 'markup', markup: { language: 'html', content: ` \n\n`, }, processors: ['tailwindcss'], }; export const tailwindcssDemo = { activeEditor: 'script', script: { language: 'react', content: `export default function() {\n returnHello, Tailwind!
\nHello, Tailwind CSS!
;\n}\n`, }, processors: ['tailwindcss'], }; [Tailwind CSS](https://tailwindcss.com/) is an open-source CSS framework that provides utility CSS classes that can be composed to build any design, directly in the markup. ## Demo## Usage Tailwind CSS is enabled as a [CSS processor](../features/css.html.md)#css-processors). Once enabled from the style editor menu or in [`processors`](../configuration/configuration-object.html.md)#processors) property of the [configuration object](../configuration/configuration-object.html.md), all Tailwind utility classes are available immediately in your markup. :::info note Tailwind CSS is imported using `@import "tailwindcss";` directive in the [style editor](../features/projects.html.md)#style-editor). If no `@import` is added to the style editor, LiveCodes automatically injects it when the Tailwind CSS processor is enabled. ::: ### Usage with CSS Frameworks in JSX/SFCs CSS Frameworks supported in LiveCodes (e.g. Tailwind CSS, [UnoCSS](./unocss.html.md), [WindiCSS](./windicss.html.md)) can detect class names added in JSX and framework SFCs such as [React](./react.html.md), [Vue](./vue.html.md) and [Svelte](./svelte.html.md). Make sure that the Tailwind CSS processor is enabled. ### Tailwind CSS Plugins Tailwind CSS [legacy JavaScript-based plugins](https://v3.tailwindcss.com/docs/plugins#official-plugins) can be loaded using the [`@plugin` directive](https://tailwindcss.com/docs/functions-and-directives#plugin-directive) in the [style editor](../features/projects.html.md)#style-editor). ```css @plugin "@tailwindcss/forms"; @plugin "@tailwindcss/typography"; @plugin "@tailwindcss/aspect-ratio"; @plugin "@tailwindcss/line-clamp"; ``` ## Processor Info ### Name `tailwindcss` ## Compiler Tailwind CSS official compiler, running client-side in the browser. The compiler generates styles on-demand, so only the classes used in your markup are included in the output. ### Version `tailwindcss`: v4.1.16 ## Starter Template https://livecodes.io/?template=tailwindcss ## Links - [Tailwind CSS](https://tailwindcss.com/) - [Tailwind CSS Documentation](https://tailwindcss.com/docs) - [LiveCodes CSS Processors](../features/css.html.md)#css-processors) - [UnoCSS](./unocss.html.md) - [WindiCSS](./windicss.html.md) --- # Tcl [Tcl](https://www.tcl.tk/) (Tool Command Language) is a powerful, interpretable scripting language known for its simple syntax and extensibility. It is commonly used for embedded systems, rapid prototyping, and GUI scripting. LiveCodes runs Tcl in the browser using [Wacl](https://github.com/ecky-l/wacl) (a Tcl distribution for WebAssembly). ## Usage ### Demo import LiveCodes from '../../src/components/LiveCodes.tsx'; ### JavaScript Interoperability Tcl programs run asynchronously in LiveCodes. JavaScript can interact with the Tcl interpreter using the `livecodes.tcl` global: - `livecodes.tcl.input` — set this to pass input to the Tcl script (accessible via `gets stdin`) - `livecodes.tcl.run()` — execute the Tcl script, returns a promise with `{ output, error }` - `livecodes.tcl.loaded` — a promise that resolves when the interpreter is ready - `livecodes.tcl.output` — the last output string ### DOM Access The Tcl script can interact with the DOM using `::wacl::dom`: ```tcl ::wacl::dom attr "#my-element" innerText "Hello from Tcl!" ``` ## Language Info ### Name `tcl` ### Extensions `.tcl` ### Editor `script` ## Compiler [Wacl](https://github.com/ecky-l/wacl) (Tcl v8.6.6 compiled to WebAssembly) ## Code Formatting Not supported. ## Starter Template https://livecodes.io/?template=tcl ## Links - [Tcl](https://www.tcl.tk/) - [Wacl](https://github.com/ecky-l/wacl) --- # Teal Teal is a typed dialect of [Lua](https://www.lua.org/). Teal code is compiled to Lua, which then runs in the browser using [Fengari](https://fengari.io/). See documentation for Lua language support in LiveCodes [here](./lua.html.md). ## Usage JavaScript interoperability and DOM access is achieved using [`"js"` module](https://github.com/fengari-lua/fengari-interop). import LiveCodes from '../../src/components/LiveCodes.tsx'; This example demonstrates usage, JavaScript interoperability and DOM access: ## Language Info ### Name `teal` ### Extension `.tl` ### Editor `script` ## Compiler [Teal](https://github.com/teal-language/tl) ### Version Teal v0.15.2 ## Code Formatting Using [`lua-fmt`](https://github.com/trixnz/lua-fmt). ## Starter Template https://livecodes.io/?template=teal ## Links - [Teal](https://github.com/teal-language/tl) - [Teal documentation](https://github.com/teal-language/tl/tree/master/docs) - [Teal tutorial](https://github.com/teal-language/tl/blob/master/docs/tutorial.html.md) - [Lua](https://www.lua.org/) - [Lua documentation](https://www.lua.org/docs.html) - [Fengari](https://fengari.io/) - [lua](./lua.html.md) in LiveCodes - [lua-wasm](./lua-wasm.html.md) in LiveCodes --- # Token CSS import LiveCodes from '../../src/components/LiveCodes.tsx'; [Token CSS](https://tokencss.com/) is a design token-based CSS framework. It allows you to define design tokens (colors, spacing, typography, etc.) and use them consistently across your stylesheets. The tokens are converted to CSS custom properties and utility classes. ## Usage Token CSS is a [CSS processor](../features/css.html.md)#css-processors) that can be enabled from the style editor menu, or configured via the [`processors`](../configuration/configuration-object.html.md)#processors) property of the [configuration object](../configuration/configuration-object.html.md). When enabled, Token CSS processes your stylesheet and converts design token references into standard CSS. By default, it uses the [`@tokencss/core/preset`](https://github.com/tokencss/tokencss/blob/main/packages/core/preset/token.config.json) preset. ### Demo export const tokencssConfig = { activeEditor: 'style', markup: { language: 'html', content: ` `, }, style: { language: 'css', content: `.card { background: var(--color-blue-5); border: 1px solid var(--color-gray-3); padding: var(--space-md); border-radius: var(--radius-md); margin-bottom: var(--space-sm); } .card.accent { background: var(--color-indigo-4); color: white; } `, }, processors: ['tokencss'], tools: { active: 'compiled', status: 'open' }, };Token CSS Demo
Design tokens are converted to CSS. Check the Compiled tab to see the processed output.
A card componentAn accent card## Processor Info ### Name `tokencss` ### Editor `style` ## Processor [Token CSS](https://tokencss.com/) ### Version `tokencss`: v0.9.0 ## Custom Settings [Custom settings](../advanced/custom-settings.html.md) added to the property `tokencss` define or override design tokens. By default, the `@tokencss/core` preset is applied. Custom tokens extend or override the preset values. Please note that custom settings should be valid JSON (i.e. functions are not allowed). **Example:** ```json title="Custom Settings" { "tokencss": { "extends": "@tokencss/core/preset", "color": { "brand": { "value": "#4a90d9" } }, "space": { "xl": { "value": "2rem" } } } } ``` ## Links - [Token CSS](https://tokencss.com/) - [Token CSS on GitHub](https://github.com/tokencss/tokencss) - [CSS Processors](../features/css.html.md)#css-processors) in LiveCodes --- # TSX TSX is a syntax that allows using TypeScript in JSX. [JSX](https://react.dev/learn/writing-markup-with-jsx) is a syntax extension for JavaScript that allows writing HTML-like markup inside JavaScript. It has been popularized by [React](https://react.dev/), and then adopted by many other libraries/frameworks. By default, when running JSX/TSX in LiveCodes, [React](https://react.dev/) runtime is used. However, other libraries like [Preact](https://preactjs.com/), [nano JSX](https://nanojsx.io/) and others can be used as well (see [Custom JSX Runtimes](./jsx.html.md)#custom-jsx-runtimes)). Please note that [React compiler](https://react.dev/learn/react-compiler) is also available in LiveCodes and is [documented here](./react.html.md). ## Usage For usage and examples, see documentation for [JSX](./jsx.html.md) and [TypeScript](./typescript.html.md) support in LiveCodes. ## Language Info ### Name `tsx` ### Extension `.tsx` ### Editor `script` ## Compiler [TypeScript compiler](./typescript.html.md) ## Code Formatting Using [Prettier](https://prettier.io/). ## Custom Settings [Custom settings](../advanced/custom-settings.html.md) added to the property `tsx` are passed to the TypeScript compiler as [compiler options](https://www.typescriptlang.org/tsconfig#compilerOptions) while compiling TSX. In addition, the option `disableAutoRender` can be set to `true` to disable [auto-rendering](./jsx#auto-rendering). Please note that custom settings should be valid JSON (i.e. functions are not allowed). **Example:** ```json title="Custom Settings" { "tsx": { "disableAutoRender": true, "jsxFactory": "h", "jsxFragmentFactory": "Fragment" } } ``` ## Links - [React](https://react.dev/) - [JSX](https://react.dev/learn/writing-markup-with-jsx) - [TypeScript](https://www.typescriptlang.org/) --- # Twig [Twig.js](https://github.com/twigjs/twig.js/) is a pure JavaScript implementation of the [Twig](https://twig.symfony.com/) PHP templating language. ## Usage There are 2 modes for rendering: ### Pre-rendered (Default) The values of the expressions are evaluated and added to the template during compilation of the [result page](../features/result.html.md). The values of all expressions should be supplied in advance using [custom settings](../advanced/custom-settings.html.md) to the property `template.data` which accepts an object of key-value pairs. Example: This provides the value of the expression `name` ```json title="Custom Settings" { "template": { "data": { "name": "LiveCodes" } } } ``` [Full example below](#pre-rendered) ### Dynamic To use this mode, the property `template.prerender` in [custom settings](../advanced/custom-settings.html.md) should be set to `false`. Example: ```json title="Custom Settings" { "template": { "prerender": false } } ``` In this mode, in addition to values supplied in custom settings (see above), expressions can have values that are evaluated during the [result page](../features/result.html.md) runtime. This can be achieved in JavaScript (or any [language](../languages/index.html.md) that compiles to it) by assigning `window.livecodes.templateData` to an object with the data. Please note that template rendering occurs on [page load](https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event), so the assignment must occur before that. Example: ```js title="Script Editor (JS)" window.livecodes.templateData = { name: 'LiveCodes' }; ``` [Full example below](#dynamic-1) ## Language Info ### Name `twig` ### Extension `.twig` ### Editor `markup` ## Compiler [Twig.js](https://www.npmjs.com/package/twig). ### Version `twig`: v1.15.4 ## Code Formatting Using [Prettier](https://prettier.io/). ## Custom Settings [Custom settings](../advanced/custom-settings.html.md) added to the property `twig` are passed as a JSON object to the [`twig`](https://github.com/twigjs/twig.js/wiki#browser-usage) method during compile. Please check the [documentation](https://github.com/twigjs/twig.js/wiki#browser-usage) for full reference. Please note that custom settings should be valid JSON (i.e. functions are not allowed). ## Example Usage import LiveCodes from '../../src/components/LiveCodes.tsx'; ### Pre-rendered export const config = { markup: { language: 'twig', content: 'Hello, {{ name }}!' }, customSettings: { template: { data: { name: 'LiveCodes' } } }, }; export const params = { compiled: 'open' }; ### Dynamic export const config2 = { markup: { language: 'twig', content: 'Hello, {{ name }}!' }, script: { language: 'javascript', content: 'window.livecodes.templateData = { name: "LiveCodes" };', }, customSettings: { template: { prerender: false } }, activeEditor: 'script', }; ## Links - [Twig](https://twig.symfony.com/) - [Twig documentation](https://twig.symfony.com/doc/3.x/) - [Twig.js](https://github.com/twigjs/twig.js/) - [Twig.js documentation](https://github.com/twigjs/twig.js/wiki) --- # TypeScript [TypeScript](https://www.typescriptlang.org/) is a strongly typed programming language that builds on JavaScript. It adds optional static typing, interfaces, generics, and other modern features that compile to plain JavaScript. ## Usage ### Demo import LiveCodes from '../../src/components/LiveCodes.tsx'; The compiled JavaScript output can be viewed in the [compiled code viewer](../features/compiled-code.html.md). ### Module Imports npm modules can be imported as described in the section about [module resolution](../features/module-resolution.html.md), including bare module imports and importing from different CDNs. ### Editor Support The code editor provides rich [IntelliSense](../features/intellisense.html.md) for TypeScript, including autocomplete, parameter hints, hover information, and inline errors. This also works in JavaScript, JSX, TSX, and other languages that use the TypeScript-based editor. **Automatic Types for npm Modules** — LiveCodes automatically loads type definitions for imported npm modules, providing autocomplete and type checking without manual configuration. **TypeScript TwoSlash** — The editor supports [TypeScript TwoSlash](https://github.com/microsoft/TypeScript-Website/tree/v2/packages/ts-twoslasher), useful for debugging, sharing, and teaching TypeScript. Use `// ^?` to see inferred types and `// @errors:` to annotate expected errors inline. **Custom Types** — For modules without published types, provide custom type definitions using the `types` property in [custom settings](../advanced/custom-settings.html.md): ```json title="Custom Settings" { "types": { "my-module": "https://cdn.jsdelivr.net/npm/my-module@1.0.0/types/index.d.ts" } } ``` See [IntelliSense documentation](../features/intellisense.html.md) for full details. ## Language Info ### Name `typescript` ### Aliases `ts` ### Extensions `.ts`, `.mts`, `.typescript` ### Editor `script` ## Compiler [TypeScript compiler](https://www.typescriptlang.org/) ### Version `typescript`: v5.9.3 ## Code Formatting Using [Prettier](https://prettier.io/). ## Custom Settings [Custom settings](../advanced/custom-settings.html.md) added to the property `typescript` are passed as compiler options to `ts.transpile`. Please check the [TypeScript documentation](https://www.typescriptlang.org/docs/handbook/compiler-options.html) for full reference. Please note that custom settings should be valid JSON (i.e. functions are not allowed). **Example:** ```json title="Custom Settings" { "typescript": { "target": "es2020", "strictNullChecks": true } } ``` ## Starter Template https://livecodes.io/?template=typescript ## Links - [TypeScript](https://www.typescriptlang.org/) - [TypeScript Handbook](https://www.typescriptlang.org/docs/handbook/intro.html) --- # UnoCSS import LiveCodes from '../../src/components/LiveCodes.tsx'; import RunInLiveCodes from '../../src/components/RunInLiveCodes.tsx'; export const basicDemo = { activeEditor: 'markup', markup: { language: 'html', content: ` \n\n`, }, processors: ['unocss'], }; [UnoCSS](https://unocss.dev/) is an atomic CSS engine that provides utility CSS classes. Unlike traditional CSS frameworks, it is fully customizable and works by scanning your source code to generate only the CSS you need. ## Demo export const unocssDemo = { activeEditor: 'markup', markup: { language: 'html', content: `Hello, UnoCSS!
\n\n\n`, }, processors: ['unocss'], };Hello, UnoCSS!
\n## Usage UnoCSS is a [CSS processor](../features/css.html.md)#css-processors) that can be enabled from the style editor menu, or configured via the [`processors`](../configuration/configuration-object.html.md)#processors) property of the [configuration object](../configuration/configuration-object.html.md). Once enabled, all UnoCSS utility classes are available immediately in your markup. ### Usage with JSX and Framework SFCs UnoCSS can detect class names added in JSX and framework SFCs such as [React](./react.html.md), [Vue](./vue.html.md), and [Svelte](./svelte.html.md). Make sure the UnoCSS processor is enabled. ### Presets UnoCSS is loaded with the following presets enabled by default: - `presetUno` — the default UnoCSS preset (a superset of Tailwind CSS, Windi CSS, and Bootstrap utilities) - [`presetAttributify`](https://unocss.dev/presets/attributify) — enables attributify mode for using utilities as HTML attributes - [`presetIcons`](https://unocss.dev/presets/icons) — enables icon support via class names like `i-carbon-campsite` Additional presets and transformers can be enabled or disabled via [custom settings](../advanced/custom-settings.html.md) using the `presets` property: ```json title="Custom Settings" { "unocss": { "presets": { "presetUno": true, "presetAttributify": true, "presetIcons": { "cdn": "https://esm.sh/" }, "presetTypography": true, "presetWebFonts": true }, "transformers": { "transformerDirectives": true, "transformerVariantGroup": true } } } ``` The following presets and transformers are available: **Presets:** `presetUno`, `presetAttributify`, `presetIcons`, `presetTagify`, `presetWebFonts`, `presetTypography`, `presetMini`, `presetWind` **Transformers:** `transformerDirectives`, `transformerVariantGroup`, `transformerCompileClass`, `transformerAttributifyJsx` ### Icon Preset The icon preset is enabled by default. It allows using thousands of icons from [Iconify](https://iconify.design/) as CSS classes: ```html ``` ## Processor Info ### Name `unocss` ### Editor `style` ## Compiler [UnoCSS](https://unocss.dev/) official compiler, running client-side in the browser. The compiler generates styles on-demand, so only the classes used in your markup are included in the output. ### Version `unocss`: v66.5.4 ## Custom Settings [Custom settings](../advanced/custom-settings.html.md) added to the property `unocss` are passed as configuration to UnoCSS. Please check the [documentation](https://unocss.dev/config/) for full reference. Please note that custom settings should be valid JSON (i.e. functions are not allowed). **Example:** ```json title="Custom Settings" { "unocss": { "shortcuts": { "btn": "py-2 px-4 font-semibold rounded-lg shadow-md" } } } ``` ## Starter Template https://livecodes.io/?template=unocss ## Links - [UnoCSS](https://unocss.dev/) - [UnoCSS Documentation](https://unocss.dev/guide/) - [CSS Processors](../features/css.html.md)#css-processors) in LiveCodes - [Tailwind CSS](./tailwindcss.html.md) - [WindiCSS](./windicss.html.md) --- # Vento [Vento](https://vento.js.org/) is a template engine for Deno. It's inspired by other engines, such as [Nunjucks](./nunjucks.html.md), [Liquid](./liquid.html.md), [Eta](./eta.html.md), and [Mustache](./mustache.html.md). ## Usage There are 2 modes for rendering: ### Pre-rendered (Default) The values of the expressions are evaluated and added to the template during compilation of the [result page](../features/result.html.md). The values of all expressions should be supplied in advance using [custom settings](../advanced/custom-settings.html.md) to the property `template.data` which accepts an object of key-value pairs. Example: This provides the value of the expression `name` ```json title="Custom Settings" { "template": { "data": { "name": "LiveCodes" } } } ``` [Full example below](#pre-rendered) ### Dynamic To use this mode, the property `template.prerender` in [custom settings](../advanced/custom-settings.html.md) should be set to `false`. Example: ```json title="Custom Settings" { "template": { "prerender": false } } ``` In this mode, in addition to values supplied in custom settings (see above), expressions can have values that are evaluated during the [result page](../features/result.html.md) runtime. This can be achieved in JavaScript (or any [language](../languages/index.html.md) that compiles to it) by assigning `window.livecodes.templateData` to an object with the data. Please note that template rendering occurs on [page load](https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event), so the assignment must occur before that. Example: ```js title="Script Editor (JS)" window.livecodes.templateData = { name: 'LiveCodes' }; ``` [Full example below](#dynamic-1) ## Language Info ### Name `vento` ### Extension `.vto` ### Editor `markup` ## Compiler [Vento](https://vento.js.org/). ### Version `ventojs`: v2.2.0 ## Code Formatting Using [Prettier](https://prettier.io/). ## Custom Settings [Custom settings](../advanced/custom-settings.html.md) added to the property `vento` are passed as a JSON object to the [`vento()`](https://vento.js.org/getting-started/#usage) function during compile. Please check the [documentation](https://vento.js.org/configuration/) for full reference. Please note that custom settings should be valid JSON (i.e. functions are not allowed). ## Example Usage import LiveCodes from '../../src/components/LiveCodes.tsx'; ### Pre-rendered export const config = { markup: { language: 'vento', content: 'Hello, {{ name }}!' }, customSettings: { template: { data: { name: 'LiveCodes' } } }, }; export const params = { compiled: 'open' }; ### Dynamic export const config2 = { markup: { language: 'vento', content: 'Hello, {{ name }}!' }, script: { language: 'javascript', content: 'window.livecodes.templateData = { name: "LiveCodes" };', }, customSettings: { template: { prerender: false } }, activeEditor: 'script', }; ## Links - [Vento](https://vento.js.org/) --- # Vue SFC [Vue.js](https://vuejs.org/), The Progressive JavaScript Framework, is an approachable, performant and versatile framework for building web user interfaces. This is the documentation for LiveCodes language support for Vue [Single-File Component (SFC)](https://vuejs.org/api/sfc-spec.html). The support for Vue 2 SFC (the older, EOL version) is [documented separately](./vue2.html.md). ## Usage Vue SFC can be used as documented in the [specs](https://vuejs.org/api/sfc-spec.html), including support for [Scoped CSS](https://vuejs.org/api/sfc-css-features.html#scoped-css), [CSS Modules](https://vuejs.org/api/sfc-css-features.html#css-modules), [pre-processors](https://vuejs.org/api/sfc-spec.html#pre-processors), [JSX](https://vuejs.org/guide/extras/render-function.html#jsx-tsx) and [`src` imports](https://vuejs.org/api/sfc-spec.html#src-imports). See below for usage. ### Demo import LiveCodes from '../../src/components/LiveCodes.tsx'; import RunInLiveCodes from '../../src/components/RunInLiveCodes.tsx'; ### Scoped CSS > When a `\n\n\n hi\n`, };### CSS Modules > A ``, }; ### CSS Frameworks [CSS Frameworks](../features/css.html.md)#css-processors) supported in LiveCodes (e.g. [Tailwind CSS](./tailwindcss.html.md), [UnoCSS](./unocss.html.md), [WindiCSS](./windicss.html.md)) can detect class names added in Vue SFCs. Make sure that the required utility is enabled (from style editor menu or in `processors` property of [configuration object](../configuration/configuration-object.html.md)#processors)). See [example below](#multiple-components). ### Languages and Pre-Processors > Blocks can declare pre-processor languages using the `lang` attribute. > > — [docs](https://vuejs.org/api/sfc-spec.html#pre-processors) Many of the [languages supported in LiveCodes](./index.html.md) can be used. The value of `lang` attribute can be the language name (specified in its documentation page) or any of its aliases (extensions). export const processorsDemo = { vue: `\nh1 {{ msg }}\n\n\n\n\n\n`, }; ### JSX JSX can be used in render functions without needing any configuration. export const jsxDemo = { vue: `\n\n`, }; ### `src` Imports The src attribute can be used to import an external file for a language block: ```html ``` The value of `src` attribute can be either: - Absolute URL (e.g. `https://unpkg.com/todomvc-app-css/index.css`) - Path in npm package (e.g. `todomvc-app-css/index.css`) Relative paths (e.g. `./my-styles.css`) cannot be used (because there is no file system in LiveCodes). The imported sources can use any of the supported languages/pre-processors (identified by the file extension or can be specified by `lang` attribute). ### Module Imports npm modules can be imported as described in the section about [module resolution](../features/module-resolution.html.md), including bare module imports and importing from different CDNs. Stylesheets imported in the `script` block are added as `` tags in the page `head`. Example: export const importsDemo = { vue: `\n\n\n \n\n\n`, };You clicked {{ count }} times.
\n \nModule imports can be customized using import maps as described in [module resolution](../features/module-resolution.html.md)#custom-module-resolution) documentations. ### Multiple Components Vue is supported in both [markup](../features/projects.html.md)#markup-editor) and [script](../features/projects.html.md)#script-editor) editors. This allows having a component in the markup editor that imports (and passes props to) a component in the script editor. The opposite is not supported. This can be done using relative import of a file name in the same directory. Any file name will resolve to the component in the script editor, e.g. `./script.vue`, `./Component.vue`, `./Counter.vue`, etc. export const multi = { markup: { language: 'vue', content: ` `, }, script: { language: 'vue', content: ` {{ count }}`, }, style: { language: 'css', content: '@import "tailwindcss";\n', }, processors: ['tailwindcss'], }Please note that LiveCodes [does not have the concept of a file system](../features/projects.html.md). However, you can configure [editor options](../configuration/configuration-object.html.md)#markup) like `title`, `order` and `hideTitle` to simulate multiple files, change editor order or even hide editors. Example: export const multiFiles = { ...multi, markup: { ...multi.markup, title: 'App.vue', }, script: { ...multi.script, title: 'Counter.vue', }, style: { ...multi.style, title: 'styles.css', order: 3, }, }; When both markup and script editors use Vue, the component in the markup editor is used as the main component rendered in the [root element](#root-element). To render the component in the script editor, it has to be imported and used by the main component. ### Importing External SFCs External Vue SFCs can be imported. The import URL has to be an absolute URL ending with `.vue` extension. Any bare or relative imports in the imported files are resolved and compiled recursively. This is an example of importing a Vue SFC, which in turn imports other Vue SFCs (the imported components use Tailwind CSS, which is enabled in this project as a CSS preprocessor): export const importExternal = { activeEditor: 'script', script: { language: 'vue', content: ` ` }, style: { language: 'css', content: '@import "tailwindcss";\n', }, processors: ['tailwindcss'], } { ' - ' } <>view source on GitHub> Please note that extensionless imports are not supported. However, you may customize the import URL using import maps as described in [module resolution](../features/module-resolution.html.md)#custom-module-resolution) section. Example: ```json title="Custom Settings" { "imports": { "https://raw.githubusercontent.com/hatemhosny/vue3-samples/master/src/composable/useTodoList": "https://raw.githubusercontent.com/hatemhosny/vue3-samples/master/src/composable/useTodoList.js", "https://raw.githubusercontent.com/hatemhosny/vue3-samples/master/src/composable/useMousePosition": "https://raw.githubusercontent.com/hatemhosny/vue3-samples/master/src/composable/useMousePosition.js" } } ``` export const importExternalWithImportMap = { activeEditor: 'script', script: { language: 'vue', content: ` `, }, imports: { "https://raw.githubusercontent.com/hatemhosny/vue3-samples/master/src/composable/useTodoList": "https://raw.githubusercontent.com/hatemhosny/vue3-samples/master/src/composable/useTodoList.js", "https://raw.githubusercontent.com/hatemhosny/vue3-samples/master/src/composable/useMousePosition": "https://raw.githubusercontent.com/hatemhosny/vue3-samples/master/src/composable/useMousePosition.js" } }; ### Importing Data URLs You may want to import other SFCs without having to host them on a server. These components can be encoded as [data URLs](https://developer.mozilla.org/en-US/docs/Web/URI/Reference/Schemes/data) and imported as usual. The data URL has to start with `data:text/vue` to be recognized as a Vue SFC. Any imports in the imported URLs (even if they are also data URLs) are resolved and compiled recursively. :::info The code in any code editor can be encoded as data URL from the LiveCodes UI using the "Copy code as data URL" button below the code editor. ::: This is the previous demo that uses data URLs (with nested imports) instead of external URLs: export const importDataUrls = { activeEditor: 'script', script: { language: 'vue', content: `{' '} {' - '} <>view source on GitHub> ` }, style: { language: 'css', content: '@import "tailwindcss";\n', }, processors: ['tailwindcss'], } In the above demo, this component is imported: ``` data:text/vue;charset=UTF-8;base64,PHNjcmlwdCBzZXR1cCBsYW5nPSJ0cyI+DQppbXBvcnQgeyByZWYgfSBmcm9tICJ2dWUiOw0KaW1wb3J0IFByaW1hcnlCdXR0b24gZnJvbSAiZGF0YTp0ZXh0L3Z1ZTtjaGFyc2V0PVVURi04O2Jhc2U2NCxQSE5qY21sd2RDQnpaWFIxY0NCc1lXNW5QU0owY3lJK0RRcGtaV1pwYm1WUWNtOXdjeWg3RFFvZ0lIUnBkR3hsT2lCN0RRb2dJQ0FnZEhsd1pUb2dVM1J5YVc1bkxBMEtJQ0FnSUdSbFptRjFiSFE2SUNKQ2RYUjBiMjRpTEEwS0lDQjlMQTBLZlNrN0RRbzhMM05qY21sd2RENE5DZzBLUEhSbGJYQnNZWFJsUGcwS0lDQThZblYwZEc5dURRb2dJQ0FnWTJ4aGMzTTlJblJsZUhRdGJXUWdabTl1ZEMxdFpXUnBkVzBnWW1jdFozSmhlUzAxTURBZ2FHOTJaWEk2WW1jdFozSmhlUzAyTURBZ2RISmhibk5wZEdsdmJpQndlUzB4SUhCNExUUWdkR1Y0ZEMxM2FHbDBaU0J5YjNWdVpHVmtJR1J5YjNBdGMyaGhaRzkzTFhoc0lnMEtJQ0ErRFFvZ0lDQWdlM3NnZEdsMGJHVWdmWDBOQ2lBZ1BDOWlkWFIwYjI0K0RRbzhMM1JsYlhCc1lYUmxQZz09IjsNCmltcG9ydCBEYW5nZXJCdXR0b24gZnJvbSAiZGF0YTp0ZXh0L3Z1ZTtjaGFyc2V0PVVURi04O2Jhc2U2NCxQSE5qY21sd2RDQnpaWFIxY0NCc1lXNW5QU0owY3lJK0RRcGtaV1pwYm1WUWNtOXdjeWg3RFFvZ0lIUnBkR3hsT2lCN0RRb2dJQ0FnZEhsd1pUb2dVM1J5YVc1bkxBMEtJQ0FnSUdSbFptRjFiSFE2SUNKQ2RYUjBiMjRpTEEwS0lDQjlMQTBLZlNrN0RRbzhMM05qY21sd2RENE5DZzBLUEhSbGJYQnNZWFJsUGcwS0lDQThZblYwZEc5dURRb2dJQ0FnWTJ4aGMzTTlJblJsZUhRdGJXUWdabTl1ZEMxdFpXUnBkVzBnWW1jdGNtVmtMVFV3TUNCb2IzWmxjanBpWnkxeVpXUXROakF3SUhSeVlXNXphWFJwYjI0Z2NIa3RNU0J3ZUMwMElIUmxlSFF0ZDJocGRHVWdjbTkxYm1SbFpDQmtjbTl3TFhOb1lXUnZkeTE0YkNJTkNpQWdQZzBLSUNBZ0lIdDdJSFJwZEd4bElIMTlEUW9nSUR3dlluVjBkRzl1UGcwS1BDOTBaVzF3YkdGMFpUND0iOw0KDQpjb25zdCBjb3VudCA9IHJlZigwKTsNCjwvc2NyaXB0Pg0KDQo8dGVtcGxhdGU+DQogIDxkaXYgY2xhc3M9InctZnVsbCBtdC04IGZsZXgganVzdGlmeS1jZW50ZXIiPg0KICAgIDxzcGFuIHJlZj0iY291bnRlciIgY2xhc3M9InRleHQtM3hsIGZvbnQtYm9sZCI+e3sgY291bnQgfX08L3NwYW4+DQogIDwvZGl2Pg0KICA8ZGl2IGNsYXNzPSJ3LWZ1bGwgbXQtNCBmbGV4IGZsZXgtcm93IHNwYWNlLXgtNCBqdXN0aWZ5LWNlbnRlciI+DQogICAgPHByaW1hcnktYnV0dG9uIHJlZj0iZGVjcmVtZW50QnV0dG9uIiB0aXRsZT0iLSIgQGNsaWNrPSJjb3VudC0tIiAvPg0KICAgIDxwcmltYXJ5LWJ1dHRvbiByZWY9ImluY3JlbWVudEJ1dHRvbiIgdGl0bGU9IisiIEBjbGljaz0iY291bnQrKyIgLz4NCiAgPC9kaXY+DQogIDxkaXYgY2xhc3M9InctZnVsbCBtdC00IGZsZXggZmxleC1yb3cgc3BhY2UteC00IGp1c3RpZnktY2VudGVyIj4NCiAgICA8ZGFuZ2VyLWJ1dHRvbiByZWY9InJlc2V0QnV0dG9uIiB0aXRsZT0iUmVzZXQiIEBjbGljaz0iY291bnQgPSAwIiAvPg0KICA8L2Rpdj4NCjwvdGVtcGxhdGU+ ``` which imports these: ``` data:text/vue;charset=UTF-8;base64,PHNjcmlwdCBzZXR1cCBsYW5nPSJ0cyI+DQpkZWZpbmVQcm9wcyh7DQogIHRpdGxlOiB7DQogICAgdHlwZTogU3RyaW5nLA0KICAgIGRlZmF1bHQ6ICJCdXR0b24iLA0KICB9LA0KfSk7DQo8L3NjcmlwdD4NCg0KPHRlbXBsYXRlPg0KICA8YnV0dG9uDQogICAgY2xhc3M9InRleHQtbWQgZm9udC1tZWRpdW0gYmctZ3JheS01MDAgaG92ZXI6YmctZ3JheS02MDAgdHJhbnNpdGlvbiBweS0xIHB4LTQgdGV4dC13aGl0ZSByb3VuZGVkIGRyb3Atc2hhZG93LXhsIg0KICA+DQogICAge3sgdGl0bGUgfX0NCiAgPC9idXR0b24+DQo8L3RlbXBsYXRlPg== ``` ``` data:text/vue;charset=UTF-8;base64,PHNjcmlwdCBzZXR1cCBsYW5nPSJ0cyI+DQpkZWZpbmVQcm9wcyh7DQogIHRpdGxlOiB7DQogICAgdHlwZTogU3RyaW5nLA0KICAgIGRlZmF1bHQ6ICJCdXR0b24iLA0KICB9LA0KfSk7DQo8L3NjcmlwdD4NCg0KPHRlbXBsYXRlPg0KICA8YnV0dG9uDQogICAgY2xhc3M9InRleHQtbWQgZm9udC1tZWRpdW0gYmctcmVkLTUwMCBob3ZlcjpiZy1yZWQtNjAwIHRyYW5zaXRpb24gcHktMSBweC00IHRleHQtd2hpdGUgcm91bmRlZCBkcm9wLXNoYWRvdy14bCINCiAgPg0KICAgIHt7IHRpdGxlIH19DQogIDwvYnV0dG9uPg0KPC90ZW1wbGF0ZT4= ``` ### Root Element To [mount](https://vuejs.org/api/application.html#app-mount) the application instance to a specific DOM element use `"livecodes-app"` as the element `id` in the HTML. Otherwise, if that element is not found, a new `div` element is added to `document.body` and is used to mount the instance. Example: export const customRoot = { markup: { language: 'html', content: ` Custom Root Element
...other page content
`, }, script: { language: 'vue', content: `I'm a Vue SFC`, }, };## Language Info ### Name `vue` ### Extensions `.vue`, `.vue3` ### Editor `script`, `markup` ## Compiler The official [@vue/compiler-sfc](https://github.com/vuejs/core/tree/main/packages/compiler-sfc). ### Version `@vue/compiler-sfc`: v3.5.22 ## Code Formatting Using [Prettier](https://prettier.io/). ## Limitations Currently, Vue support has the following limitations: - SSR is not supported. - The [`defineProps()`](https://vuejs.org/guide/components/props#props-declaration) macro cannot infer props from TypeScript types not defined in the same file. [PRs are welcome](https://github.com/live-codes/livecodes/issues/757). ## Starter Template https://livecodes.io/?template=vue ## Links - [Vue.js](https://vuejs.org/) - [Vue SFC specs](https://vuejs.org/api/sfc-spec.html) - [CSS Modules](https://github.com/css-modules/css-modules) --- # Vue 2 SFC [Vue.js](https://vuejs.org/), The Progressive JavaScript Framework, is an approachable, performant and versatile framework for building web user interfaces. This is the documentation for LiveCodes language support for the older **Vue 2** [Single-File Component (SFC)](https://v2.vuejs.org/v2/guide/single-file-components.html). For the latest Vue SFC head to [Vue 3 SFC documentations](./vue.html.md). :::caution Please note that, officially, Vue 2 has reached [End of Life (EOL)](https://v2.vuejs.org/eol/) on December 31st, 2023. ::: ## Important Note Vue 2 SFC language support in LiveCodes is different from that for Vue 3. Unlike Vue 3, which uses the official SFC compiler ([@vue/compiler-sfc](https://github.com/vuejs/core/tree/main/packages/compiler-sfc)) to compile SFC to regular JavaScript which is then sent to the result page, Vue 2 SFC support uses [vue3-sfc-loader](https://github.com/FranckFreiburger/vue3-sfc-loader), which is loaded in the result page and the SFC is compiled on the fly in the end user's browser. This has a significant performance impact. [vue3-sfc-loader](https://github.com/FranckFreiburger/vue3-sfc-loader) is currently at version 0.8.4, which is compatible with Vue 2 version 2.6.14. Vue 2.7 is not supported. ## Usage Vue 2 SFC support includes Scoped CSS, pre-processors, JSX and `src` imports. ## Language Info ### Name `vue2` ### Extensions `.vue2` ### Editor `script` ## Compiler [vue3-sfc-loader](https://github.com/FranckFreiburger/vue3-sfc-loader). ### Version `vue3-sfc-loader`: v0.9.5, which is compatible with Vue v2.6.14 ## Code Formatting Using [Prettier](https://prettier.io/). ## Links - [Vue 2 docs](https://v2.vuejs.org/) - [Vue 2 SFC](https://v2.vuejs.org/v2/guide/single-file-components.html) --- # WebAssembly Text Format [WebAssembly Text Format](https://developer.mozilla.org/en-US/docs/WebAssembly/Understanding_the_text_format) (WAT) is the human-readable text representation of WebAssembly. It uses S-expressions and allows writing low-level code that compiles to the binary Wasm format that browsers execute. LiveCodes compiles WAT to WebAssembly using [`wabt.js`](https://github.com/AssemblyScript/wabt.js) (the WebAssembly Binary Toolkit). ## Usage ### Demo import LiveCodes from '../../src/components/LiveCodes.tsx'; ### Loading the Wasm Module The compiled WebAssembly module is loaded using the `livecodes.loadWasm()` method, which optionally takes an import object and returns a promise that resolves to an object containing the instantiated `wasmModule` and the raw `binary`: ```js const { wasmModule } = await livecodes.loadWasm(); const { increment } = wasmModule.exports; ``` ### Import Object The import object passed to `loadWasm()` maps to the imports declared in the WAT module. Functions, memories, and other values can be provided from JavaScript: ```wat title="WAT" (module (import "env" "log" (func $log (param i32))) (func (export "run") (call $log (i32.const 42))) ) ``` ```js title="JavaScript" const { wasmModule } = await livecodes.loadWasm({ env: { log: (val) => console.log(val) }, }); wasmModule.exports.run(); // logs 42 ``` For writing strings from Wasm to JavaScript, the shared memory buffer can be accessed via `wasmModule.exports.memory` and decoded with `TextDecoder`: ```wat title="WAT" (module (import "title" "change" (func $changeTitle (param i32) (param i32))) (memory (export "memory") 1) (data (i32.const 0) "Hello, WAT!") (func (export "setTitle") (call $changeTitle (i32.const 0) (i32.const 11)) ) ) ``` ```js title="JavaScript" const { wasmModule } = await livecodes.loadWasm({ title: { change: (offset, length) => { const bytes = new Uint8Array(wasmModule.exports.memory.buffer, offset, length); const text = new TextDecoder('utf8').decode(bytes); document.querySelector('#title').innerText = text; }, }, }); wasmModule.exports.setTitle(); ``` ## Language Info ### Name `wat` ### Aliases `wast`, `webassembly`, `wasm` ### Extensions `.wat`, `.wast`, `.webassembly`, `.wasm` ### Editor `script` ## Compiler [wabt.js](https://github.com/AssemblyScript/wabt.js) (WebAssembly Binary Toolkit) ### Version `wabt`: v1.0.35 ## Code Formatting Using [wast-refmt](https://github.com/xtuc/webassemblyjs/tree/master/packages/wast-refmt). ## Custom Settings [Custom settings](../advanced/custom-settings.html.md) added to the property `wat` are passed as compiler features to the WAT parser. Supported features include `simd`, `threads`, `bulk_memory`, `reference_types`, and more. Please note that custom settings should be valid JSON (i.e. functions are not allowed). **Example:** ```json title="Custom Settings" { "wat": { "threads": false } } ``` ## Starter Template https://livecodes.io/?template=wat ## Links - [WebAssembly Text Format on MDN](https://developer.mozilla.org/en-US/docs/WebAssembly/Understanding_the_text_format) - [wabt.js](https://github.com/AssemblyScript/wabt.js) --- # Windi CSS import LiveCodes from '../../src/components/LiveCodes.tsx'; import RunInLiveCodes from '../../src/components/RunInLiveCodes.tsx'; export const basicDemo = { activeEditor: 'markup', markup: { language: 'html', content: ` \n\n`, }, processors: ['windicss'], }; [Windi CSS](https://windicss.org/) is a utility-first CSS framework that provides utility classes to build designs directly in your markup. It scans your source code and generates only the CSS you need, resulting in fast load times and small bundle sizes. ## Demo export const windicssDemo = { activeEditor: 'markup', markup: { language: 'html', content: `Hello, Windi CSS!
\n\n\n`, }, processors: ['windicss'], };Hello, Windi CSS!
\n## Usage Windi CSS is a [CSS processor](../features/css.html.md)#css-processors) that can be enabled from the style editor menu, or configured via the [`processors`](../configuration/configuration-object.html.md)#processors) property of the [configuration object](../configuration/configuration-object.html.md). Once enabled, all Windi CSS utility classes are available immediately in your markup. ### Usage with JSX and Framework SFCs Windi CSS can detect class names added in JSX and framework SFCs such as [React](./react.html.md), [Vue](./vue.html.md), and [Svelte](./svelte.html.md). Make sure the Windi CSS processor is enabled. ## Processor Info ### Name `windicss` ### Editor `style` ## Compiler [Windi CSS](https://windicss.org/) official compiler, running client-side in the browser. The compiler generates styles on-demand, so only the classes used in your markup are included in the output. ### Version `windicss`: v3.5.6 ## Custom Settings [Custom settings](../advanced/custom-settings.html.md) added to the property `windicss` are passed as configuration to Windi CSS. Please check the [documentation](https://windicss.org/guide/configuration.html) for full reference. Please note that custom settings should be valid JSON (i.e. functions are not allowed). **Example:** ```json title="Custom Settings" { "windicss": { "attributify": true } } ``` ## Starter Template https://livecodes.io/?template=windicss ## Links - [Windi CSS](https://windicss.org/) - [Windi CSS on GitHub](https://github.com/windicss/windicss) - [CSS Processors](../features/css.html.md)#css-processors) in LiveCodes - [Tailwind CSS](./tailwindcss.html.md) - [UnoCSS](./unocss.html.md) --- # Guides & Tutorials Welcome to the LiveCodes guides and tutorials! These step-by-step guides will help you learn how to use LiveCodes effectively. ## Getting Started - [Getting Started Guide](./getting-started-guide.html.md) - Your first steps with LiveCodes - [Building Your First App](./building-your-first-app.html.md) - Create a complete project from scratch ## SDK & Integration - [Embedding Playgrounds](./embedding-playgrounds.html.md) - Add an interactive code editor to your website - [Creating Shareable URLs](./creating-shareable-urls.html.md) - Create custom share links for embedded playgrounds Choose a guide above to get started! --- import CodeBlock from '@theme/CodeBlock'; import LiveCodes from '../../src/components/LiveCodes.tsx'; import RunInLiveCodes from '../../src/components/RunInLiveCodes.tsx'; export const gettingStartedParams = { html: ` `, css: `.container { max-width: 600px; margin: 50px auto; text-align: center; font-family: Arial, sans-serif; } h1 { color: #007bff; font-size: 2.5rem; } input { padding: 10px; font-size: 1rem; margin: 10px; border: 2px solid #007bff; border-radius: 5px; } button { padding: 10px 20px; font-size: 1rem; background-color: #007bff; color: white; border: none; border-radius: 5px; cursor: pointer; } button:hover { background-color: #0056b3; } `, js: `const greeting = document.getElementById('greeting'); const nameInput = document.getElementById('nameInput'); const greetBtn = document.getElementById('greetBtn'); greetBtn.addEventListener('click', () => { const name = nameInput.value.trim(); if (name) { greeting.textContent = \`Hello, \${name}!\`; } else { greeting.textContent = 'Hello, World!'; } }); `, }; # Getting Started Guide This guide will walk you through creating your first project in LiveCodes. Try the completed project below:Hello, World!
. ## Prerequisites - A web browser (Chrome, Firefox, Safari, or Edge) - Basic knowledge of HTML, CSS, and JavaScript ## Step 1: Open LiveCodes 1. Navigate to [livecodes.io](https://livecodes.io) 2. You'll see the editor interface with three panels: - **HTML** - **CSS** - **JavaScript** ## Step 2: Create a Simple Page Let's create a simple interactive greeting card. ### HTML Panel {gettingStartedParams.html} ### CSS Panel{gettingStartedParams.css} ### JavaScript Panel{gettingStartedParams.js} ## Step 3: See Your Results The result panel automatically updates as you type. Try: - Entering your name in the input field - Clicking the "Greet Me!" button - Modifying the colors in the CSS ## Step 4: Save Your Project 1. Click on the "**Project**" menu button in the toolbar 2. Click "**Save**" to save the project (on this device) 3. You can open it later from "**Project menu > Open**" 4. Use "**Project menu > Share**" to get a permanent URL to your project that you can share ## Congratulations! You've just built your first interactive app with LiveCodes! Compare your version with the completed project above. Did you add any personal touches?## Next Steps Now that you've created your first project, explore: - [Building Your First App](building-your-first-app) - Create more complex applications - [Features](../features/index.html.md) - Learn about all LiveCodes features - [Templates](../features/templates.html.md) - Use pre-built templates - [External Resources](../features/external-resources.html.md) - Add libraries to your projects ## Tips - Use **Ctrl/Cmd + S** to manually save - Press **Ctrl/Cmd + Alt + S** to open share panel - Press **Ctrl/Cmd + K** to open the command menu - Enable **Auto-save** in user settings for automatic saving --- import CodeBlock from '@theme/CodeBlock'; import LiveCodes from '../../src/components/LiveCodes.tsx'; import RunInLiveCodes from '../../src/components/RunInLiveCodes.tsx'; export const colorGeneratorParams = { html: ` `, css: `body { margin: 0; font-family: Arial, sans-serif; display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #3498db; transition: background 0.5s ease; } .container { text-align: center; background: white; padding: 40px; border-radius: 20px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); } h1 { margin: 0 0 30px 0; color: #333; } .color-display { background: #f0f0f0; padding: 30px; border-radius: 10px; margin-bottom: 30px; } #colorCode { font-size: 2rem; font-weight: bold; font-family: 'Courier New', monospace; color: #333; } #generateBtn { background: #333; color: white; border: none; padding: 15px 40px; font-size: 1.1rem; border-radius: 10px; cursor: pointer; transition: transform 0.2s; } #generateBtn:hover { transform: scale(1.05); } #generateBtn:active { transform: scale(0.95); } .hint { margin-top: 20px; color: #666; font-size: 0.9rem; } `, js: `const colorDisplay = document.getElementById('colorDisplay'); const colorCode = document.getElementById('colorCode'); const generateBtn = document.getElementById('generateBtn'); function getRandomColor() { const letters = '0123456789ABCDEF'; let color = '#'; for (let i = 0; i < 6; i++) { color += letters[Math.floor(Math.random() * 16)]; } return color; } function updateColor() { const newColor = getRandomColor(); document.body.style.background = newColor; colorCode.textContent = newColor; } generateBtn.addEventListener('click', updateColor); // Generate a color on page load updateColor(); `, }; # Building Your First App Learn how to build a simple color generator app using LiveCodes. This app will let users click a button to generate random background colors. Try the completed project below:Color Generator
#3498dbClick the button to generate a random color!
. ## What We'll Build A fun color generator with: - Random color generation - Display the color code - Simple, clean interface ## Project Setup 1. Open [LiveCodes](https://livecodes.io) 2. We'll use HTML, CSS, and JavaScript ## Implementation ### HTML Structure {colorGeneratorParams.html} ### Styling{colorGeneratorParams.css} ### JavaScript Logic{colorGeneratorParams.js} ## How It Works 1. **HTML**: Creates a simple layout with a color display and button 2. **CSS**: Styles the interface and adds smooth transitions 3. **JavaScript**: - `getRandomColor()`: Generates a random hex color - `updateColor()`: Changes the background and displays the color code - Event listener: Triggers color change on button click ## Testing Your App Try these features: 1. Click "Generate Color" multiple times 2. Watch the smooth color transitions 3. See the color code update 4. Notice the button hover and click effects ## Challenge: Enhance Your App Try adding these features: - Copy color code to clipboard when clicked - Add a history of recent colors - Let users save their favorite colors - Add different color format options (RGB, HSL) ## Congratulations! You've just built your color generator app with LiveCodes! Compare your version with the completed project above. Did you add any personal touches?## Next Steps - [External Resources](../features/external-resources.html.md) - Add libraries like color manipulation tools - [Getting Started Guide](./getting-started-guide.html.md) - Review the basics ## Complete Code Summary **Concepts Covered**: DOM manipulation, events, random generation, CSS transitions **Time to Build**: 10-15 minutes --- import CodeBlock from '@theme/CodeBlock'; import LiveCodes from '../../src/components/LiveCodes'; import RunInLiveCodes from '../../src/components/RunInLiveCodes'; export const embedDemoParams = { html: ` `, css: `body { font-family: system-ui, -apple-system, sans-serif; margin: 0; background: #f5f5f5; } #page { max-width: 900px; margin: 0 auto; padding: 20px; } header { text-align: center; margin-bottom: 20px; } h1 { margin: 0 0 8px; color: #1a1a1a; } p { margin: 0; color: #666; } #playground { border: 1px solid #ddd; border-radius: 8px; overflow: hidden; height: 500px; } `, js: `import { createPlayground } from 'livecodes'; const config = { markup: { language: 'html', content: \`My Code Playground
Edit the code below and see the result instantly!
\n\`, }, style: { language: 'css', content: \`body {\n font-family: system-ui;\n display: flex;\n justify-content: center;\n align-items: center;\n min-height: 100vh;\n margin: 0;\n background: #f0f0f0;\n}\n.card {\n background: white;\n padding: 40px;\n border-radius: 12px;\n box-shadow: 0 4px 20px rgba(0,0,0,0.1);\n text-align: center;\n}\nh2 {\n margin: 0 0 12px;\n color: #333;\n}\nbutton {\n padding: 10px 24px;\n background: #007bff;\n color: white;\n border: none;\n border-radius: 6px;\n cursor: pointer;\n font-size: 16px;\n}\nbutton:hover {\n background: #0056b3;\n}\`, }, script: { language: 'javascript', content: \`const btn = document.getElementById("actionBtn");\nbtn.addEventListener("click", () => {\n btn.textContent = "Clicked!";\n setTimeout(() => {\n btn.textContent = "Click me";\n }, 1000);\n});\`, }, }; await createPlayground('#playground', { config, loading: 'eager', }); `, }; export const lazyLoadParams = { html: `Hello LiveCodes!
\nEdit this code and see changes live.
\n \n`, css: `body { font-family: system-ui, sans-serif; margin: 0; padding: 20px; } .spacer { height: 80vh; display: flex; align-items: center; justify-content: center; color: #999; } #playground { height: 400px; border: 1px solid #ddd; border-radius: 8px; } `, js: `import { createPlayground } from 'livecodes'; const config = { markup: { language: 'html', content: 'Lazy Loaded Playground
Scroll down to see the playground load automatically.
I loaded lazily!
This playground only loads when it enters the viewport.
', }, }; createPlayground('#playground', { config, loading: 'lazy', }); `, }; export const clickToLoadParams = { html: ``, css: `body { font-family: system-ui, sans-serif; margin: 0; padding: 20px; } #playground { height: 400px; border: 1px solid #ddd; border-radius: 8px; } `, js: `import { createPlayground } from 'livecodes'; const config = { markup: { language: 'html', content: 'Click-to-Load Playground
The playground below won't load until you click it.
You clicked to load me!
', }, }; createPlayground('#playground', { config, loading: 'click', }); `, }; export const fullHtmlExample = `Embedded LiveCodes Playground `; # Embedding a Code Playground Learn how to embed a LiveCodes playground into any web page so your users can write, edit, and run code directly on your site. Try the live demo below:My Code Playground
Edit the code below and see the result instantly!
## What We'll Build A web page that: 1. Embeds a LiveCodes playground in a styled container 2. Pre-fills the playground with starter code 3. Lets users edit HTML, CSS, and JavaScript directly 4. Shows live results as they type ## Basic Embedding The simplest way to embed LiveCodes is with `createPlayground`: ```js import { createPlayground } from 'livecodes'; const config = { markup: { language: 'html', content: ' Hello!
' }, style: { language: 'css', content: 'h1 { color: blue; }' }, script: { language: 'javascript', content: 'console.log("hi")' }, }; await createPlayground('#playground', { config }); ``` This creates an interactive editor inside the `#playground` element. ## Loading Modes LiveCodes supports three loading modes: ### Eager Loading (Default) The playground loads immediately: ```js createPlayground('#playground', { config, loading: 'eager', }); ``` ### Lazy Loading The playground only loads when it scrolls into view:```js createPlayground('#playground', { config, loading: 'lazy', }); ``` ### Click-to-Load Shows a "Click to load" screen until the user clicks: ```js createPlayground('#playground', { config, loading: 'click', }); ``` ## Full Example Save this as `index.html` and open it in a browser: {fullHtmlExample} ## How It Works ### Container Setup LiveCodes needs a container element. You can use any `div`: ```html ``` By default, the playground has a height of `300px`. You can override this with CSS: ```css #playground { height: 500px; } ``` Or use the `data-height` attribute: ```html ``` ### Configuration Pass a [config object](../configuration/configuration-object.html.md) to pre-fill the playground: ```js const config = { markup: { language: 'html', content: 'Hello World
', }, style: { language: 'css', content: 'h1 { color: royalblue; }', }, script: { language: 'javascript', content: 'console.log("Hello!");', }, }; ``` ### CDN Import For quick testing without a build step, import from jsDelivr: ```html ``` ## Testing Your App 1. Save the HTML example to a file 2. Open it in your browser 3. Edit the code in the embedded playground 4. Watch the result update live ## Challenge: Enhance Your Playground Try adding these features: - [Configure](../configuration/configuration-object.html.md) the playground with a custom theme - Add a "Reset" button to restore the original config - Add a language selector to switch between different starter templates - Style the playground container to match your site's design ## Next Steps - [Creating Shareable URLs](./creating-shareable-urls.html.md): Let users share their edited code - [SDK Methods](../sdk/js-ts.html.md): Learn more about controlling the playground programmatically - [Configuration](../configuration/configuration-object.html.md): Explore all configuration options ## Complete Code Summary **Concepts Covered**: Embedding, container setup, loading modes, configuration, CDN import **Key SDK Functions**: `createPlayground` --- # Creating Shareable URLs Learn how to add a **Share** button to an embedded LiveCodes playground so users can save and share the exact code they have edited. Try the [live demo](https://hatemhosny.github.io/livecodes-custom-share/). ## What We'll Build A web page that: 1. Embeds a LiveCodes playground with default starter code 2. Lets users edit the code directly in the playground 3. Provides a **Share** button that captures the current playground state 4. Compresses the config into the page URL hash and copies it to clipboard 5. When someone opens that shared URL, the page decompresses the hash and loads the exact same playground state ## Why Compress/Decompress? The LiveCodes SDK exports two standalone utility functions: - **[`compress(string)`](../sdk/js-ts.html.md)#compress)**: Compresses a string into a URI-safe base64 format - **[`decompress(string)`](../sdk/js-ts.html.md)#decompress)**: Decompresses it back to the original string These are re-exports from `lz-string` and are useful when you want to: - Build your own share URL logic - Store compressed configs in `localStorage` or a database - Modify the config object before loading it - Add custom data to the URL hash - Create bookmarklets or browser extensions :::info If you only need a playground URL that opens in LiveCodes App, use instead the SDK method [`getShareUrl`](../sdk/js-ts.html.md)#getshareurl) of the playground instance or the standalone function [`getPlaygroundUrl`](../sdk/js-ts.html.md)#getplaygroundurl). [`compress`](../sdk/js-ts.html.md)#compress)/[`decompress`](../sdk/js-ts.html.md)#decompress) are lower-level utilities for custom use cases. ::: ## Full Example Save this as `index.html` and open it in a browser: ```htmlLiveCodes Share Demo ``` ## How It Works ### Loading from URL Hash When the page loads, we check the URL hash for a compressed config: ```js function getConfigFromHash() { const hash = location.hash.slice(1); if (!hash) return defaultConfig; try { const decompressed = decompress(hash); if (decompressed) { return JSON.parse(decompressed); } } catch { // invalid hash } return defaultConfig; } ``` If a hash is present, we decompress it and parse it as JSON. If not (or if it's invalid), we fall back to the default starter config. ### Creating the Playground We pass the loaded config to `createPlayground`: ```js const config = getConfigFromHash(); const playground = await createPlayground('#playground', { config }); ``` ### Sharing the Current State When the user clicks **Share**, we get the current config from the playground, compress it, update the URL hash, and copy the URL to clipboard: ```js document.getElementById('shareBtn').addEventListener('click', async () => { const currentConfig = await playground.getConfig(); const compressed = compress(JSON.stringify(currentConfig)); const url = new URL(location.href); url.hash = compressed; await navigator.clipboard.writeText(url.href); }); ``` :::caution `decompress` returns `null` if the input is invalid. Always check the result before parsing. ::: ## Testing Your App 1. Open the page: it shows the default starter code 2. Edit the code in the playground 3. Click **Share**: the URL is copied to clipboard 4. Paste the URL in a new tab: it loads the exact code you edited ## Challenge: Enhance Your App Try adding these features: - Add a "Reset" button to restore the default config - [Watch for code changes](../sdk/js-ts.html.md)#watch) and store the config in `localStorage` for "Recover Unsaved" feature - Add a dropdown to select different starter templates - Show a QR code for the share URL ## Next Steps - [SDK Methods](../sdk/js-ts.html.md): Learn more about the LiveCodes SDK - [Configuration](../configuration/configuration-object.html.md): Explore the full config object - [Import/Export](../features/import.html.md): Import and export projects ## Complete Code Summary **Concepts Covered**: Embedded playground, URL hash manipulation, compression, config objects, clipboard API **Key SDK Functions**: [`createPlayground`](../sdk/js-ts.html.md)#createplayground), [`getConfig`](../sdk/js-ts.html.md)#getconfig), [`compress`](../sdk/js-ts.html.md)#compress), [`decompress`](../sdk/js-ts.html.md)#decompress) --- # Bookmarklet LiveCodes allows [importing code](./features/import.html.md) from a [wide variety of sources](./features/import.html.md)#sources). Instead of manually copy/pasting URLs to import, adding **"Edit in LiveCodes"** bookmarklet to the browser bookmarks bar can be a more convenient way. It opens LiveCodes in a new window and imports the current webpage URL. ## Add Bookmarklet Drag this link to the browser bookmarks bar:Edit in LiveCodes`, }} />
or manually create a new bookmark in your browser and add this code as its URL: ```js javascript:(()=>{window.open("https://livecodes.io/?x="+encodeURIComponent(location.href),"_blank");})(); ``` ## Example Usage After adding the bookmarklet to your browser (see above), open this GitHub directory: https://github.com/bradtraversy/50projects50days/tree/master/expanding-cards Then click on the bookmarklet. LiveCodes playground should open in a new window and [import](./features/import.html.md) the directory files (each file in the appropriate editor). It just works! --- # GitHub Action ⚡ The [Preview in LiveCodes](https://github.com/live-codes/preview-in-livecodes) GitHub Action generates preview links to playgrounds for code changes in pull requests and posts them as pull request comments. Once added to a repo, it runs when a pull request is created or updated. The new code is optionally built. The action posts in a pull request comment links to playgrounds that can use the new code. **Screenshot:**  For usage and more information, see the [action docs](https://github.com/live-codes/preview-in-livecodes) on GitHub. Also check the [example repo](https://github.com/hatemhosny/preview-in-livecodes-demo) for a working demo. --- # Markdown to LiveCodes Markdown and MDX code blocks can be easily converted to interactive LiveCodes playgrounds. The playgrounds can run any of the supported [languages](./languages/index.html.md) in LiveCodes, and can be customized to any of the [configuration options](./configuration/index.html.md). A fenced code block in Markdown can be rendered as a LiveCodes playground by adding the `livecodes` parameter to the code block language meta. This is provided as [plugins](#packages) for [markdown-it](https://github.com/markdown-it/markdown-it), [marked](https://github.com/markedjs/marked) and [remark](https://github.com/remarkjs/remark). These plugins allow the seamless integration with most of the popular frameworks like Astro, Docusaurus, Next.js, Storybook, VitePress, etc. See the section "[Using with Frameworks](#using-with-frameworks)" for getting started. ## Demo This is an example code block: ````md ```jsx import { useState } from "react"; function App() { const [count, setCount] = useState(0); return (); } export default App; ``` ```` The above code block is normally rendered like this: ```jsx import { useState } from "react"; function App() { const [count, setCount] = useState(0); return (You clicked {count} times.
); } export default App; ```You clicked {count} times.
The code block can instead be rendered as an interactive playground by adding the `livecodes` parameter to the code block language meta: ````md {1} ```jsx livecodes import { useState } from "react"; function App() { const [count, setCount] = useState(0); return (); } export default App; ``` ```` to be displayed like this: ```jsx livecodes import { useState } from "react"; function App() { const [count, setCount] = useState(0); return (You clicked {count} times.
); } export default App; ```You clicked {count} times.
The playground can be customized by setting [options](#options) that are applied to all code blocks or by [meta parameters](#meta-parameters) that are applied to individual code blocks. Alternatively, the code block can be kept as it is, and a button or a link (**Edit in LiveCodes**) is appended, below the code block, that opens the code in a LiveCodes playground. This is achieved by adding the `render=button` or `render=link` parameter to the code block language meta. This displays a button: ````md {1} ```jsx livecodes render=button import { useState } from "react"; function App() { const [count, setCount] = useState(0); return (); } export default App; ``` ```` ```jsx livecodes render=button import { useState } from "react"; function App() { const [count, setCount] = useState(0); return (You clicked {count} times.
); } export default App; ```You clicked {count} times.
While this displays a link: ````md {1} ```jsx livecodes render=link import { useState } from "react"; function App() { const [count, setCount] = useState(0); return (); } export default App; ``` ```` ```jsx livecodes render=link import { useState } from "react"; function App() { const [count, setCount] = useState(0); return (You clicked {count} times.
); } export default App; ``` ## Packages All the functionality described here can be achieved using *any* of the following packages: - [`markdown-it-livecodes`](https://www.npmjs.com/package/markdown-it-livecodes): A [markdown-it](https://github.com/markdown-it/markdown-it) plugin. - [`marked-livecodes`](https://www.npmjs.com/package/marked-livecodes): A [marked](https://github.com/markedjs/marked) plugin. - [`remark-livecodes`](https://www.npmjs.com/package/remark-livecodes): A [remark](https://github.com/remarkjs/remark) plugin. - [`gatsby-remark-livecodes`](https://www.npmjs.com/package/gatsby-remark-livecodes): A [gatsby](https://github.com/gatsbyjs/gatsby) plugin. See the section "[Using with Frameworks](#using-with-frameworks)" for using the plugins with popular frameworks like Astro, Docusaurus, Next.js, Storybook, VitePress, etc. ## Usage ### markdown-it-livecodes To use the `markdown-it-livecodes` plugin, first install it: ```bash npm2yarn npm install markdown-it markdown-it-livecodes ``` Then it can be used like this: ````js import markdownIt from "markdown-it"; import markdownItLivecodes from "markdown-it-livecodes"; const input = "```js livecodes \nconsole.log('Hello World!');\n```"; const output = markdownIt() .use(markdownItLivecodes, { /* options */ }) .render(input); console.log(output); // ```` ### marked-livecodes To use the `marked-livecodes` plugin, first install it: ```bash npm2yarn npm install marked marked-livecodes ``` Then it can be used like this: ````js import marked from "marked"; import markedLivecodes from "marked-livecodes"; const input = "```js livecodes \nconsole.log('Hello World!');\n```"; const output = await marked .use(markedLivecodes, { /* options */ }) .parse(input); console.log(output); // ```` ### remark-livecodes To use the `remark-livecodes` plugin, first install it: ```bash npm2yarn npm install remark remark-livecodes ``` Then it can be used like this: ````js import { remark } from "remark"; import remarkLivecodes from "remark-livecodes"; const input = "```js livecodes \nconsole.log('Hello World!');\n```"; const output = await remark() .use(remarkLivecodes, { /* options */ }) .process(input); console.log(String(output)); // ```` ### gatsby-remark-livecodes See usage with [Gatsby](#gatsby). ## Options Options can be passed to the plugins. These options apply to all code blocks. These options include LiveCodes SDK [embed options](./sdk/js-ts.html.md)#embed-options) (except `headless`). Example: ````js const output = await remark() .use(remarkLivecodes, { // highlight-start loading: "click", params: { console: "open" theme: "light", } // highlight-end }) .process(input); ```` In addition, the following options are also available: - `render`: The render mode for the LiveCodes playgrounds. This can be one of the following: - `playground` (default): Replaces the code block with an iframe that displays the LiveCodes playground. By default, [`"simple"` mode](./features/display-modes.html.md) is used, but this can be changed in [options](#options) or [meta parameters](#meta-parameters). - `link`: Keeps the code block as it is, and appends a link (**Edit in LiveCodes**), below the code block, that opens the code in a LiveCodes playground. - `button`: Keeps the code block as it is, and appends a button (Edit in LiveCodes), below the code block, that opens the code in a LiveCodes playground.You clicked {count} times.
- `meta`: Keeps the code block as it is, and adds the URL of the playground to the `data-livecodes-url` attribute of the `
` element. In addition, in `remark-livecodes` the URL is added to the AST (`node.data.livecodesUrl` and `node.data.hProperties.dataLivecodesUrl`). In `markdown-it-livecodes` the URL is added to `env.livecodesUrl`. This can be used by other plugins (e.g. to display a custom run button overlying the code block). - `height`: The height of the playground iframe. - `className`: The class name to be applied to the iframe, link or button. Note: If the class name of the button contains `"dark"` (e.g. `"dark-btn"`), the dark button will be used.
- `auto`: When set to `true`, it automatically enables the `livecodes` parameter for all code blocks without having to explicitly add it. This is useful when you have a large number of code blocks and don't want to add the `livecodes` parameter to each code block. To disable this for a specific code block, add the `livecodes=false` [meta parameter](#meta-parameters) to the code block. ## Meta Parameters Individual code blocks can be configured using meta parameters. These are key/value pairs, separated by spaces, that are added after the language name. Meta parameters of code blocks override the [options](#options) passed to the plugin. Example: ````markdown {1} ```jsx livecodes render=button className=dark-btn console=open import { useState, useEffect } from "react"; export default () => { const [count, setCount] = useState(0); useEffect(() => { console.log("count:", count); }, [count]); return (
); }; ``` ```` All LiveCodes [configuration query parameters](./configuration/query-params.html.md) can be used as code block meta parameters (e.g. ` ```js livecodes console=open theme=light`). See the [LiveCodes configuration docs](./configuration/configuration-object.html.md) for more information. In addition, the following meta parameters are available: - `livecodes`: Enables the LiveCodes playground for the code block. This can be omitted if the `auto` option is set to `true`. When `livecodes` is set to `false`, the code block is not handled by the plugin. - `render`: The render mode. See the [Options](#options) section for more information. - `height`: The height of the playground iframe. - `className`: The class name for the playground iframe, link or button. - `lang`: This overrides the language of the code block (e.g. ` ```jsx livecodes lang=react` or ` ```py livecodes lang=py-wasm`). See the [Languages](./languages/index.html.md) docs for more language information. ## Using with Frameworks This guide shows how to use the suitable plugin in different frameworks. ### Astro ([demo](https://markdown-to-livecodes-astro.pages.dev/) - [code on GitHub](https://github.com/hatemhosny/markdown-to-livecodes-astro)) Install the `remark-livecodes` plugin: ```bash npm2yarn npm install -D remark-livecodes ``` This is an example for adding the `remark-livecodes` plugin to `astro.config.mjs` file: ```js title="astro.config.js" import { defineConfig } from "astro/config"; import mdx from "@astrojs/mdx"; import remarkLivecodes from "remark-livecodes"; export default defineConfig({ // ... integrations: [mdx()], markdown: { remarkPlugins: [ [remarkLivecodes, { /* options */ }], ], }, }); ``` ### Docusaurus ([demo](https://markdown-to-livecodes-docusaurus.pages.dev/) - [code on GitHub](https://github.com/hatemhosny/markdown-to-livecodes-docusaurus)) Install the `remark-livecodes` plugin: ```bash npm2yarn npm install -D remark-livecodes ``` This is an example for adding the `remark-livecodes` plugin to `docusaurus.config.js` file: ```js title="docusaurus.config.js" export default { presets: [ [ 'classic', { docs: { // ... remarkPlugins: [ [require('remark-livecodes'), { /* options */ }], ], }, }, ], ], // ... }; ``` ### Eleventy ([demo](https://markdown-to-livecodes-11ty.pages.dev/) - [code on GitHub](https://github.com/hatemhosny/markdown-to-livecodes-11ty)) Install the `markdown-it-livecodes` plugin: ```bash npm2yarn npm install -D markdown-it-livecodes ``` This is an example for adding the `markdown-it-livecodes` plugin to `eleventy.config.js` file: ```js title="eleventy.config.js" import markdownItLivecodes from "markdown-it-livecodes"; export default async function (eleventyConfig) { eleventyConfig.amendLibrary("md", (mdLib) => mdLib.use(markdownItLivecodes, { /* options */ }), ); // ... } ``` ### Gatsby ([demo](https://markdown-to-livecodes-gatsby.pages.dev/markdown-to-livecodes/) - [code on GitHub](https://github.com/hatemhosny/markdown-to-livecodes-gatsby)) Install the `gatsby-remark-livecodes` plugin: ```bash npm2yarn npm install -D gatsby-remark-livecodes ``` This is an example for adding the `gatsby-remark-livecodes` plugin to `gatsby-config.js` file: ```js title="gatsby-config.js" module.exports = { // ... plugins: [ // ... { resolve: 'gatsby-transformer-remark', options: { plugins: [ { resolve: 'gatsby-remark-livecodes', options: { /* options */ }, }, ], }, }, ], }; ``` ### Next.js ([demo](https://markdown-to-livecodes-nextjs.pages.dev/mdx-page) - [code on GitHub](https://github.com/hatemhosny/markdown-to-livecodes-nextjs)) See [Next.js docs](https://nextjs.org/docs/app/guides/mdx) for using markdown and MDX in Next.js. Install the `remark-livecodes` plugin: ```bash npm2yarn npm install -D remark-livecodes ``` This is an example for adding the `remark-livecodes` plugin to `next.config.js` file: ```js title="next.config.js" import createMDX from "@next/mdx"; import remarkLivecodes from "remark-livecodes"; const nextConfig = { // ... pageExtensions: ["js", "jsx", "md", "mdx", "ts", "tsx"], }; const withMDX = createMDX({ options: { remarkPlugins: [ [remarkLivecodes, { /* other options */ }], ], }, }); export default withMDX(nextConfig); ``` When using Turbopack for local development, check the guide for [using plugins with Turbopack](https://nextjs.org/docs/app/guides/mdx#using-plugins-with-turbopack). ### react-markdown `react-markdown` is a React component to render markdown. This is an example for using the `remark-livecodes` plugin with `react-markdown`: Install the `remark-livecodes` plugin: ```bash npm2yarn npm install remark-livecodes ``` ```jsx title="App.jsx" livecodes render=button import Markdown from 'react-markdown'; import remarkLivecodes from 'remark-livecodes'; const markdown = '```jsx livecodes\nexport default () =>You clicked {count} times.
Hello World
\n```'; export default () => ({markdown} ); ``` ### Storybook ([demo](https://markdown-to-livecodes-storybook.pages.dev/) - [code on GitHub](https://github.com/hatemhosny/markdown-to-livecodes-storybook)) Install the `remark-livecodes` plugin: ```bash npm2yarn npm install -D remark-livecodes ``` This is an example for adding the `remark-livecodes` plugin to `storybook/main.js` file: ```js title="storybook/main.js" import remarkLivecodes from "remark-livecodes"; export default { // ... addons: [ // ... { name: "@storybook/addon-docs", options: { mdxPluginOptions: { mdxCompileOptions: { remarkPlugins: [ [remarkLivecodes, { /* options */ }], ], }, }, }, }, ], }; ``` ### VitePress ([demo](https://markdown-to-livecodes-vitepress.pages.dev/) - [code on GitHub](https://github.com/hatemhosny/markdown-to-livecodes-vitepress)) Install the `markdown-it-livecodes` plugin: ```bash npm2yarn npm install -D markdown-it-livecodes ``` This is an example for adding the `markdown-it-livecodes` plugin to `vitepress.config.js` file: ```js title=".vitepress/config.js" import { defineConfig } from "vitepress"; import markDownItLivecodes from "markdown-it-livecodes"; export default defineConfig({ // ... markdown: { config: (md) => { md.use(markDownItLivecodes, { /* options */ }); }, }, }); ``` ### Xlog ([demo](https://xlog.emadelsaid.com/docs/Features%20Test/#blocks)) LiveCodes is natively supported by [Xlog](https://xlog.emadelsaid.com/) as an [official extension](https://xlog.emadelsaid.com/docs/official%20extensions/#livecodes-interactive-playgrounds). --- # Contribution Contributions are always welcome. Before contributing, please read the [code of conduct](https://github.com/live-codes/livecodes/blob/HEAD/CODE_OF_CONDUCT.md). For code contribution, please refer to the [contribution introduction](https://github.com/live-codes/livecodes/blob/HEAD/CONTRIBUTING.md). The internal architecture and system documentation are detailed in the [contribution guide](https://github.com/live-codes/livecodes/blob/HEAD/docs/docs/contribution/README.md). For AI agents, see the section [AI Guide](./ai-guide.html.md). For financial and in-kind contributions, please refer to the [sponsor page](./sponsor.html.md). You can always support the project by [giving feedback](https://github.com/live-codes/livecodes/discussions), [reporting issues, suggesting features](https://github.com/live-codes/livecodes/issues) and spreading the word. Thank you :) --- # AI Guide This guide is specifically designed for AI Large Language Models (LLMs) and autonomous agents to effectively use the LiveCodes library for creating and embedding code playgrounds. ## llms.txt For optimal context when working with LiveCodes, use these specially formatted documentation files: **📄 [llms.txt](pathname:///llms.txt)** - Concise overview of the library, installation, basic usage, and key concepts **📄 [llms-full.txt](pathname:///llms-full.txt)** - Complete documentation including all guides, API reference, and examples These files are specifically structured for AI consumption with: - Clear API signatures and type definitions - Code examples with expected outputs - Language and framework reference lists - Best practices and common patterns See [https://llmstxt.org/](https://llmstxt.org/) for more information about llms.txt standards. ## Skills LiveCodes provides skills for enhanced AI-assisted development. ### Installation for AI Agents ```bash # Add skills into your project npx skills add live-codes/livecodes ``` ### Available Skills | Skill | Description | | ----------------------------------- | ------------------------------------------------ | | `livecodes/getting-started` | Quick start, installation, first playground | | `livecodes/sdk-embedding` | createPlayground, EmbedOptions, containers | | `livecodes/sdk-methods` | run, getCode, setConfig, watch, format | | `livecodes/configuration` | Config object, query params, processors | | `livecodes/display-modes` | full, simple, lite, editor, result modes | | `livecodes/headless-mode` | Run without visible UI | | `livecodes/import-export` | GitHub, gists, URLs, files, ZIP, HTML | | `livecodes/language-support` | 90+ languages, compilers, CSS processors | | `livecodes/module-resolution` | npm, jsr, GitHub imports, CDN resolution | | `livecodes/testing` | Jest and Testing Library in the browser | | `livecodes/framework-wrappers` | React, Vue, Svelte, Solid, Preact wrappers | | `livecodes/markdown-integration` | Docusaurus, Astro, VitePress, Next.js | | `livecodes/self-hosting` | Static servers, GitHub Pages, Docker | | `livecodes/gh-action` | Preview PRs in LiveCodes | ### Using Skills AI agents can load relevant skills automatically based on context: - Creating a new embedded playground → loads `sdk-embedding` - Configuring languages or processors → loads `language-support` - Using React/Vue/Svelte wrappers → loads `framework-wrappers` - Running tests in the playground → loads `testing` - Importing npm packages → loads `module-resolution` - Self-hosting LiveCodes → loads `self-hosting` ## Key Concepts for AI Agents ### 1. Creating a Playground ```typescript import { createPlayground } from 'livecodes'; // Always await createPlayground - it returns a Promise const playground = await createPlayground('#container', { config: { markup: { language: 'html', content: 'Hello LiveCodes!
' }, style: { language: 'css', content: 'h1 { color: blue; }' }, script: { language: 'javascript', content: 'console.log("Hello!");' }, }, }); ``` ### 2. SDK Methods Are Async **All SDK methods return Promises. Always `await` them.** ```typescript // Run the playground await playground.run(); // Get current code const code = await playground.getCode(); // Set new configuration await playground.setConfig({ /* ... */ }); // Format code await playground.format(); ``` ### 3. Configuration ```typescript const playground = await createPlayground('#container', { // Default view view: 'split', // 'split' | 'editor' | 'result' // Readonly mode readonly: false, // Configuration for code editors config: { markup: { language: 'html', content: 'Hello' }, style: { language: 'css', content: 'div { color: red; }' }, script: { language: 'typescript', content: 'console.log("Hello");' }, }, }); ``` ### 4. Language Support LiveCodes supports 90+ languages. Use the `language` property in editor config: ```typescript const config = { markup: { language: 'markdown', content: '# Title' }, style: { language: 'scss', content: '$color: blue; div { color: $color; }' }, script: { language: 'python', content: 'print("Hello")' }, } ``` ### 5. Module Resolution Import npm packages directly without a bundler: ```typescript // In the script editor import confetti from 'canvas-confetti'; ``` ## Common Patterns ### React Integration ```tsx import { useState } from 'react'; import LiveCodes from 'livecodes/react'; export default function App() { const [playground, setPlayground] = useState(); const runCode = async () => { if (playground) { await playground.run(); } }; return ( <>Hello React!' }, script: { language: 'javascript', content: 'console.log("Hello");' }, }} /> > ); } ``` ### Headless Mode (No UI) ```typescript import { createPlayground } from 'livecodes'; const playground = await createPlayground({ headless: true, config: { markup: { language: 'markdown', content: '# Hello LiveCodes!' }, } }); // Compile and get output without visible UI await playground.run(); const result = await playground.getCode(); ``` ## Common Mistakes to Avoid ### Forgetting Async/Await ```typescript // ❌ Wrong: Not awaiting const playground = createPlayground('#container', {}); await playground.run(); // Error! playground is a Promise // ✅ Correct: Always await createPlayground const playground = await createPlayground('#container', {}); await playground.run(); ``` ### Server-Side Assumptions ```typescript // ❌ Wrong: Assuming server-side rendering import { createPlayground } from 'livecodes'; // This won't work in Node.js without a DOM // ✅ Correct: LiveCodes is client-side only // Use in browser environments or frameworks that hydrate client-side ``` ### Confusing Display Mode and Default View ```typescript // ❌ Wrong: Using 'code' instead of 'editor' const playground = await createPlayground('#container', { view: 'codeblock', // Invalid view }); // ✅ Correct: Use valid default view const playground = await createPlayground('#container', { view: 'editor', // 'split' | 'editor' | 'result' }); ``` ## Best Practices for AI Generation 1. **Always await `createPlayground`** - it returns a Promise 2. **Use descriptive configuration** for better maintainability 3. **Choose appropriate display modes** based on use case 4. **Import only needed languages** to optimize loading 5. **Handle async operations** properly with `await` or `.then()` 6. **Load relevant skills** for enhanced guidance on specific tasks 7. **Remember client-side only** - no server-side rendering ## Resources - 📚 [Full Documentation](https://livecodes.io/docs/) - 🔧 [SDK Reference](https://livecodes.io/docs/sdk/) - 🎨 [Language Support](https://livecodes.io/docs/languages/) - 🤖 [Skills](https://github.com/live-codes/livecodes/blob/develop/.agents/skills/livecodes/SKILL.md) - AI-assisted development - 📄 [llms.txt](pathname:///llms.txt) - Quick reference - 📄 [llms-full.txt](pathname:///llms-full.txt) - Complete docs --- # Credits ## Services LiveCodes uses services that are generously provided by: ## Third Party Packages Packages used by LiveCodes and their licenses are [listed here](https://github.com/live-codes/livecodes/blob/develop/vendor-licenses.html.md). ## Prior Art Many of LiveCodes features/ideas were inspired by: - [CodePen](https://codepen.io/) - [JSFiddle](https://jsfiddle.net/) - [JS Bin](https://jsbin.com/) - [CodeSandbox](https://codesandbox.io/) - [Replit](https://replit.com/) - [VS Code](https://code.visualstudio.com/) - [Monacode](https://github.com/lukejacksonn/monacode/) Thank you ❤️ --- # License LiveCodes is released under the permissive [MIT License](https://github.com/live-codes/livecodes/blob/develop/LICENSE) © [Hatem Hosny](https://github.com/hatemhosny). Third party packages used in LiveCodes and their licenses are [listed here](https://github.com/live-codes/livecodes/blob/develop/vendor-licenses.md). The source code is available on [GitHub](https://github.com/live-codes/livecodes). Please consider [sponsoring LiveCodes](./sponsor.html.md) to support its maintenance and continued development. --- # Terms of Service import MailLink from '../src/components/MailLink.tsx'; _Last updated: July 11, 2026_ ## 1. Acceptance of Terms By accessing or using LiveCodes ("the Service"), available at [livecodes.io](https://livecodes.io) and any related services, you agree to be bound by these Terms of Service. If you do not agree, do not use the Service. The Service is provided by Hatem Hosny ("we", "us", "our"). ## 2. Description of Service LiveCodes is a free, open-source, client-side code playground that supports 90+ programming languages and frameworks. The Service runs primarily in your browser with no server-side code execution required. It allows you to write, run, test, share, export, and deploy code projects. ## 3. Who Can Use the Service There is no minimum age to use the Service. LiveCodes does not require an account, does not collect personal information from unauthenticated users, and all code execution happens locally in your browser. Some features that require GitHub authentication may be subject to GitHub's own age requirements. Those are governed by GitHub's Terms of Service. ## 4. Accounts No account is required to use most features of the Service. Certain features (GitHub integration, deployment, sync, assets hosting) require authentication via a GitHub account through Firebase Authentication. You are responsible for maintaining the security of your account credentials and for all activities that occur under your account. ## 5. User Content ### 5.1 Ownership You retain all rights to the code, projects, assets, and other content you create using the Service ("User Content"). The Service does not claim ownership over your User Content. ### 5.2 Local Storage User Content is stored locally in your browser using IndexedDB and localStorage. The Service does not upload or store your User Content on our servers unless you explicitly choose to use features that require server-side storage (e.g., generating short share URLs, deploying to GitHub Pages). ### 5.3 Shared Content When you generate a short URL for sharing, your project configuration including source code is transmitted to the LiveCodes share service. Shared content **cannot be deleted** once a short URL is created. Exercise caution when sharing sensitive or proprietary code. ### 5.4 Prohibited Content You agree not to use the Service to create, share, or distribute content that: - Violates any applicable law or regulation - Infringes upon intellectual property rights of others - Contains malware, viruses, or malicious code - Is used for phishing, spamming, or fraudulent activities - Constitutes harassment, hate speech, or abuse - Facilitates illegal activities We reserve the right to disable access to shared URLs that violate these terms. ## 6. Third-Party Services ### 6.1 GitHub Integration Features including import from private repos, export to gists, deployment to GitHub Pages, assets hosting, and data sync require authentication with GitHub and are subject to [GitHub's Terms of Service](https://docs.github.com/en/site-policy/github-terms/github-terms-of-service). ### 6.2 Firebase Authentication User authentication is handled by Firebase Authentication, which may use cookies. By logging in, you agree that cookies may be stored on your device. Firebase Authentication is subject to [Google's Privacy Policy](https://policies.google.com/privacy). ### 6.3 CDN and Package Services The Service loads language runtimes, compilers, libraries, and packages from third-party CDNs including npm, jsDelivr, deno.land/x, JSR, and GitHub. These are subject to their respective terms of service. ## 7. Acceptable Use You agree not to: - Use the Service in any way that could disrupt, damage, or impair the Service - Attempt to gain unauthorized access to the Service or its related systems - Use automated means (bots, scrapers) to access the Service in a manner that imposes unreasonable load - Abuse the share service by generating excessive short URLs or storing prohibited content - Use the Service for cryptocurrency mining or other resource-intensive activities ## 8. Intellectual Property The LiveCodes source code is released under the [MIT License](https://github.com/live-codes/livecodes/blob/develop/LICENSE). The LiveCodes name, logo, and branding are proprietary and may not be used without permission except as allowed by the license. ## 9. Service Availability The Service is provided on an "as is" and "as available" basis. While we strive for high availability, we do not guarantee uninterrupted access. We reserve the right to modify, suspend, or discontinue the Service, or any part thereof, at any time without notice. ## 10. Disclaimer of Warranties THE SERVICE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. WE DO NOT WARRANT THAT THE SERVICE WILL BE ERROR-FREE, SECURE, OR UNINTERRUPTED. Code execution occurs in your browser using third-party compilers and runtimes. We make no guarantees about the correctness, security, or reliability of code execution results. ## 11. Limitation of Liability TO THE MAXIMUM EXTENT PERMITTED BY LAW, WE SHALL NOT BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES, INCLUDING LOSS OF DATA, PROFITS, OR CODE, ARISING FROM YOUR USE OF THE SERVICE. ## 12. Indemnification You agree to indemnify and hold us harmless from any claims, damages, liabilities, and expenses arising from your use of the Service or violation of these Terms. ## 13. Third-Party Links The Service or user-shared content may contain links to third-party websites. We are not responsible for the content, policies, or practices of any third-party websites. ## 14. Changes to Terms We reserve the right to update these Terms at any time. Continued use of the Service after changes constitutes acceptance of the updated Terms. We will make reasonable efforts to notify users of material changes. ## 15. Termination We may terminate or suspend your access to the Service at our discretion, without prior notice, for conduct that violates these Terms or is otherwise harmful to the Service or other users. You may stop using the Service at any time. Your locally stored data remains on your device unless you clear your browser storage. ## 16. Governing Law These Terms are governed by the laws of the jurisdiction in which the Service operator resides, without regard to conflict of law principles. ## 17. Contact For questions about these Terms, please contact us at . --- # Privacy Policy import MailLink from '../src/components/MailLink.tsx'; _Last updated: July 11, 2026_ ## 1. Introduction LiveCodes ("we", "us", "our") is committed to protecting your privacy. This Privacy Policy explains how we collect, use, and safeguard information when you use our Service at [livecodes.io](https://livecodes.io) and related services. The Service is designed with privacy in mind. Code execution, compilation, and most data storage happen entirely in your browser. Your code does not leave your device unless you choose to use features that require server interaction. ## 2. Information We Collect ### 2.1 Server-Side Analytics When you access the Service, our servers (hosted on Cloudflare) automatically collect the following information for operational analytics: - **Request data**: URL accessed, HTTP method - **Network data**: Cloudflare data center location (colo), HTTP protocol version - **Geographic data**: Country, city, continent, region, timezone (derived from IP address by Cloudflare) - **Device data**: User agent, Accept headers, Accept-Language, Accept-Encoding, Referer, Client Hints (`sec-ch-ua`, `sec-ch-ua-mobile`, `sec-ch-ua-platform`), fetch destination/site/mode headers This data is used for aggregate analytics, monitoring, and abuse prevention. ### 2.2 Locally Stored Data The Service stores the following data in your browser's local storage (IndexedDB and localStorage): - Projects (code, title, description, tags, language settings) - Code snippets - User assets (images, fonts, stylesheets, scripts) - User settings and preferences - Editor state and layout configuration - Templates This data remains on your device and is **not sent to our servers** unless you explicitly initiate features that require server interaction (see Section 2.3). ### 2.3 Data You Choose to Send Certain features transmit data to servers only when you explicitly initiate them: | Feature | Data Sent | Destination | |---------|-----------|-------------| | Short URL sharing | Project configuration including source code | LiveCodes share service or dpaste | | QR code generation | Project code (via short URL generation) | LiveCodes share service or dpaste | | GitHub login | Authentication token via GitHub OAuth | Firebase Authentication + GitHub | | GitHub integration | Repositories, gists, and file contents per user action | GitHub API | | Data sync | Projects, snippets, assets, settings | Your selected GitHub repository | | Asset hosting | Asset files | Your GitHub Pages repository (`livecodes-assets`) | | Deployment | Result page and source code | Your selected GitHub Pages repository | | Embed screen | Project code (via short URL generation) | LiveCodes share service or dpaste | ### 2.4 Cookies The Service may use cookies in the following circumstances: - **Firebase Authentication**: When you log in with GitHub, Firebase Authentication may set cookies on your device. By logging in, you consent to this. - **Essential functionality**: The Service itself may use cookies or similar storage for essential functionality (e.g., maintaining session state for authenticated users). ## 3. How We Use Information ### 3.1 Analytics Server-side analytics data is used to: - Monitor Service health and performance - Understand usage patterns in aggregate - Detect and prevent abuse - Debug operational issues ### 3.2 Share Service When you generate a short URL, your project code is stored by the share service to enable retrieval via the short URL. Shared projects are **private** — share URLs are not published or indexed by us, and IDs are non-sequential. However, anyone with the short URL can access the shared project. Shared content **cannot be deleted** after creation. For static self-hosted instances, the free service [dpaste](https://dpaste.com/) is used for short URLs, and content is automatically deleted after 365 days. ### 3.3 GitHub Integration When you authenticate with GitHub, we use the granted permissions solely to perform actions you initiate (e.g., importing from repos, pushing to repos, syncing data). We do not access your GitHub data for any other purpose. You can revoke permissions at any time through your [GitHub settings](https://docs.github.com/en/apps/oauth-apps/using-oauth-apps/reviewing-your-authorized-oauth-applications). ## 4. Data We Do Not Collect We do **not**: - Require personal information beyond what is necessary for authenticated features - Run server-side code execution — all compilation and execution happens in your browser - Sell, rent, or trade your data to third parties - Use tracking cookies or third-party analytics (e.g., Google Analytics) - Display advertisements or use ad tracking - Profile users or track behavior across sites - Collect keystrokes or monitor your coding activity - Access your local file system beyond what you explicitly upload ## 5. Data Storage and Security ### 5.1 Local Data Projects, assets, snippets, and settings are stored in your browser's IndexedDB and localStorage. This data is tied to your browser profile and device. If you clear your browser storage, this data will be permanently lost unless you have backed it up or synced it to GitHub. ### 5.2 Server Data - **Share service**: Project code stored for short URLs is retained indefinitely on LiveCodes infrastructure hosted on Cloudflare. - **Analytics**: Server-side analytics logs are retained for operational purposes. ### 5.3 Security Measures - Code execution and result pages run in **sandboxed iframes** with unique origins - Embedded playgrounds **cannot access** the parent page, its cookies, or localStorage - We follow security best practices and promptly address reported vulnerabilities (see our [Security Policy](https://github.com/live-codes/livecodes/blob/develop/SECURITY.md)) - All communication with the Service is encrypted via HTTPS ### 5.4 Security Vulnerabilities If you discover a security vulnerability, please report it to . Please do not disclose it publicly. See our [Security Policy](https://github.com/live-codes/livecodes/blob/develop/SECURITY.md) for details. ## 6. Third-Party Services ### 6.1 Compilers and Runtimes The Service loads language compilers, interpreters, and runtimes from third-party CDNs (esm.sh, jsDelivr, unpkg, deno.land/x, JSR, GitHub, and others) when needed for your selected languages. These services may log requests in accordance with their respective privacy policies. ### 6.2 Package Registries When you import modules from npm, deno.land/x, JSR, or GitHub in your code, requests are made directly from your browser to the respective registries. These services may log requests per their privacy policies. ### 6.3 GitHub Features using GitHub Integration transmit data to and from GitHub per your actions. GitHub's handling of this data is governed by [GitHub's Privacy Statement](https://docs.github.com/en/site-policy/privacy-policies/github-privacy-statement). ### 6.4 Firebase Authentication Authentication is handled by Firebase, a Google service. Firebase's data practices are governed by [Google's Privacy Policy](https://policies.google.com/privacy). ## 7. Children's Privacy LiveCodes is designed to be an educational tool and learning platform accessible to all ages. For unauthenticated use, we collect no personal information and all data stays on the user's device. Children can freely use the Service to learn to code. Features requiring GitHub authentication are subject to GitHub's age policies. ## 8. Data Portability and Deletion ### 8.1 Export Your Data You can export your locally stored data at any time using the [Backup](../docs/features/backup-restore.html.md) feature, which downloads a zip file of your projects, snippets, assets, templates, and settings. ### 8.2 Delete Your Data - **Local data**: Clear your browser storage to delete all locally stored data. You can also delete individual projects and assets through the app interface. - **Shared URLs**: Content shared via short URLs **cannot be deleted** after creation. - **Sync data**: Data synced to GitHub can be deleted by deleting the synced repository. - **GitHub permissions**: Revoke LiveCodes' access through your [GitHub authorized applications](https://docs.github.com/en/apps/oauth-apps/using-oauth-apps/reviewing-your-authorized-oauth-applications). ## 9. International Data Transfers The Service is hosted on Cloudflare's global network. Server-side analytics and share service data may be processed in data centers worldwide. By using the Service, you consent to this transfer and processing. ## 10. Changes to This Policy We may update this Privacy Policy from time to time. Material changes will be communicated through the Service or our GitHub repository. Continued use after changes constitutes acceptance of the updated policy. ## 11. Contact For privacy-related questions or to exercise your data rights, contact us at: - **Email**: - **Security**: - **GitHub**: [live-codes/livecodes](https://github.com/live-codes/livecodes) --- import MailLink from '../src/components/MailLink.tsx'; # Sponsor LiveCodes Thank you for considering becoming a sponsor of LiveCodes! 💚 LiveCodes is a feature-rich, open source code playground with a wide range of language support. With LiveCodes, learning, prototyping, experimenting, documenting, teaching, and sharing code is easier and more enjoyable than ever. LiveCodes is free, with no limits for use, no ads and no account required. The MIT license allows anyone to use (including commercial use), modify, and distribute. As a sponsor of LiveCodes, you will be supporting the ongoing development and maintenance of the project, as well as helping to ensure that it remains a valuable resource for the developer community. In return, you will receive recognition as a sponsor on the documentation website, GitHub repo and social media channels, as well as the opportunity to engage with our community of users and contributors. There are several ways to support LiveCodes as a sponsor: ### Financial Contributions LiveCodes relies on the support of sponsors like you to fund its ongoing development and maintenance. Your financial contribution will help to ensure that the project remains sustainable in the long term. Payments can be done via: - [GitHub Sponsors](https://github.com/sponsors/live-codes/) - [PayPal](https://paypal.me/hatemhosni) - [Ko-fi](https://ko-fi.com/hatemhosny) Both monthly-recurring sponsorships and one-time donations are accepted. Recurring sponsorships are entitled to logo placements as specified in [Sponsorship Benefits](#sponsorship-benefits). If you have questions, please reach out to . ### In-kind Contributions Do you have a service or product that could be useful to the LiveCodes community? We welcome in-kind contributions that can help to support the project and its users. In-kind contributors are recognized (logo and name) in the [credits](./credits.html.md) page and in the README of [live-codes/livecodes](https://github.com/live-codes/livecodes). ### Marketing and Promotion Help us to spread the word about LiveCodes by sharing our content on your social media channels, writing blog posts about LiveCodes or by providing us with promotional opportunities. ### Sponsorship Benefits #### ☕️ Backers (USD$5/mo): - Name listed in the README of [live-codes/livecodes](https://github.com/live-codes/livecodes). - Thank you 💚 Your support is really appreciated. #### 🍹 Generous Backers (USD$25/mo): - Name listed in the README of [live-codes/livecodes](https://github.com/live-codes/livecodes). - Priority in feature requests. #### 🥉 Bronze Sponsors (USD$100/mo): - Access to a hosted [docker setup](./advanced/docker.html.md) with managed [services](./advanced/docker.html.md)#services). - Small logo placement on the front page of [https://livecodes.io/docs](https://livecodes.io/docs). - Small logo placement in [this page](#livecodes-sponsors). - Small logo placement in the README of [live-codes/livecodes](https://github.com/live-codes/livecodes). - Priority in feature requests. #### 🥈 Silver Sponsors (USD$250/mo): - Access to a hosted [docker setup](./advanced/docker.html.md) with managed [services](./advanced/docker.html.md)#services). - Medium logo placement on the front page of [https://livecodes.io/docs](https://livecodes.io/docs). - Logo placement in sidebar of all content pages. - Medium logo placement in [this page](#livecodes-sponsors). - Medium logo placement in the README of [live-codes/livecodes](https://github.com/live-codes/livecodes). - Priority in feature requests. #### 🥇 Gold Sponsors (USD$500/mo): - Access to a hosted [docker setup](./advanced/docker.html.md) with managed [services](./advanced/docker.html.md)#services). - Large logo placement on the front page of [https://livecodes.io/docs](https://livecodes.io/docs). - Logo placement in sidebar of all content pages. - Large logo placement in [this page](#livecodes-sponsors). - Large logo placement in the README of [live-codes/livecodes](https://github.com/live-codes/livecodes). - Priority in feature requests. #### 🏆 Platinum Sponsors (USD$1,000/mo): - Access to a hosted [docker setup](./advanced/docker.html.md) with managed [services](./advanced/docker.html.md)#services). - Prominent logo placement on the front page of [https://livecodes.io/docs](https://livecodes.io/docs). - Prominent logo placement in sidebar of all content pages. - Prominent logo placement at the top of [this page](#). - Prominent logo placement in the README of [live-codes/livecodes](https://github.com/live-codes/livecodes). - Priority in feature requests. #### 💎 Diamond Sponsors (USD$2,000/mo): - **Custom build** of the playground with your **logo and brand**. The custom build is maintained and receives new updates. - Access to a hosted [docker setup](./advanced/docker.html.md) with managed [services](./advanced/docker.html.md)#services). - Prominent logo placement on the front page of [https://livecodes.io/docs](https://livecodes.io/docs). - Prominent logo placement in sidebar of all content pages. - Prominent logo placement at the top of [this page](#). - Prominent logo placement in the README of [live-codes/livecodes](https://github.com/live-codes/livecodes). - Priority in feature requests. #### 🌟 Special Sponsors (> USD$2,000/mo): . If you are interested in becoming a sponsor of LiveCodes, please don't hesitate to
. We would love to discuss the various sponsorship options available and find a way for you to get involved. Thank you for your support! ## LiveCodes Sponsors Your logo here--- # Contact {#contact-custom-content-none} We would love to hear from you! import ContactForm from '../src/components/ContactForm.tsx'; import MailLink from '../src/components/MailLink.tsx';Or you can send us an email to: - Info: - Security: - Sponsor: For non-security-related code issues, please report them in the [repo issues](https://github.com/live-codes/livecodes/issues). Please follow the twitter account: [@livecodes_io](https://twitter.com/livecodes_io). --- # About us LiveCodes is built and maintained by [Hatem Hosny](https://github.com/hatemhosny), and wonderful [contributors](https://github.com/live-codes/livecodes/graphs/contributors). Feature requests and bug reports are received on the [GitHub repo](https://github.com/live-codes/livecodes/issues). Contributions are most welcome. Please open an issue on the GitHub repo to discuss your potential contribution before submitting a pull request. Reach out to us using this [contact form](./contact.html.md). Please consider [sponsoring LiveCodes](./sponsor.html.md) to support its maintenance and continued development. --- # Display Modes import DocCardList from '@theme/DocCardList'; import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; --- # Display Mode: full import LiveCodes from '../../../src/components/LiveCodes.tsx'; --- # Display Mode: editor import LiveCodes from '../../../src/components/LiveCodes.tsx'; --- # Display Mode: codeblock import LiveCodes from '../../../src/components/LiveCodes.tsx'; --- # Display Mode: result import LiveCodes from '../../../src/components/LiveCodes.tsx'; --- # \_internal ## Index ### Interfaces - [API](interfaces/API.md) - [AppConfig](interfaces/AppConfig.md) - [ContentConfig](interfaces/ContentConfig.md) - [EditorConfig](interfaces/EditorConfig.md) - [EditorPosition](interfaces/EditorPosition.md) - [FormatterConfig](interfaces/FormatterConfig.md) - [TestResult](interfaces/TestResult.md) - [Types](interfaces/Types.md) - [UserConfig](interfaces/UserConfig.md) ### Type Aliases - [APICommands](type-aliases/APICommands.md) - [AppLanguage](type-aliases/AppLanguage.md) - [CDN](type-aliases/CDN.md) - [CodejarTheme](type-aliases/CodejarTheme.md) - [CodemirrorTheme](type-aliases/CodemirrorTheme.md) - [CssPresetId](type-aliases/CssPresetId.md) - [EditorId](type-aliases/EditorId.md) - [EditorTheme](type-aliases/EditorTheme.md) - [MonacoTheme](type-aliases/MonacoTheme.md) - [Processor](type-aliases/Processor.md) - [ScreenName](type-aliases/ScreenName.md) - [TemplateName](type-aliases/TemplateName.md) - [Theme](type-aliases/Theme.md) - [ToolName](type-aliases/ToolName.md) - [ToolsPaneStatus](type-aliases/ToolsPaneStatus.md) - [WatchCode](type-aliases/WatchCode.md) - [WatchConsole](type-aliases/WatchConsole.md) - [WatchDestroy](type-aliases/WatchDestroy.md) - [WatchLoad](type-aliases/WatchLoad.md) - [WatchReady](type-aliases/WatchReady.md) - [WatchRun](type-aliases/WatchRun.md) - [WatchTests](type-aliases/WatchTests.md) --- # Interface: API The SDK API interface for playground interaction. ## Extended by - [`Playground`](../../interfaces/Playground.md) ## Properties ### destroy() > **destroy**: () => `Promise`\<`void`\> Destroys the playground instance, and removes event listeners. Further call to any SDK methods throws an error. #### Returns `Promise`\<`void`\> #### Example ```ts import { createPlayground } from "livecodes"; createPlayground("#container").then(async (playground) => { await playground.destroy(); // playground destroyed // any further SDK call throws an error }); ``` #### Defined in [src/sdk/models.ts:1624](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1624) *** ### exec() > **exec**: (`command`, ...`args`) => `Promise`\<`object` \| `object`\> Executes custom commands, including: `"setBroadcastToken"` and `"showVersion"`. See [docs](https://livecodes.io/docs/sdk/js-ts#exec) for details. #### Parameters • **command**: [`APICommands`](../type-aliases/APICommands.md) • ...**args**: `any`[] #### Returns `Promise`\<`object` \| `object`\> #### Defined in [src/sdk/models.ts:1607](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1607) *** ### format() > **format**: (`allEditors`?) => `Promise`\<`void`\> Formats the code. By default, the code in all editors (markup, style and script) is formatted. To format only the active editor, the value `false` should be passed as an argument. #### Parameters • **allEditors?**: `boolean` #### Returns `Promise`\<`void`\> #### Example ```ts import { createPlayground } from "livecodes"; createPlayground("#container").then(async (playground) => { await playground.format(); // code in editors is formatted }); ``` #### Defined in [src/sdk/models.ts:1440](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1440) *** ### getCode() > **getCode**: () => `Promise`\<[`Code`](../../interfaces/Code.md)\> Gets the playground code (including source code, source language and compiled code) for each editor (markup, style, script), in addition to result page HTML. See [Code](https://livecodes.io/docs/api/interfaces/Code) for the structure of the returned object. #### Returns `Promise`\<[`Code`](../../interfaces/Code.md)\> #### Example ```ts import { createPlayground } from "livecodes"; createPlayground("#container").then(async (playground) => { const code = await playground.getCode(); // source code, language and compiled code for the script editor const { content, language, compiled } = code.script; // result page HTML const result = code.result; }); ``` #### Defined in [src/sdk/models.ts:1518](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1518) *** ### getConfig() > **getConfig**: (`contentOnly`?) => `Promise`\<[`Config`](../../interfaces/Config.md)\> Gets a [configuration object](https://livecodes.io/docs/configuration/configuration-object) representing the playground state. This can be used to restore state if passed as an [EmbedOptions](https://livecodes.io/docs/sdk/js-ts#embed-options) property when [creating playgrounds](https://livecodes.io/docs/sdk/js-ts/#createplayground), or can be manipulated and loaded in run-time using [`setConfig`](https://livecodes.io/docs/sdk/js-ts#setconfig) method. #### Parameters • **contentOnly?**: `boolean` #### Returns `Promise`\<[`Config`](../../interfaces/Config.md)\> #### Example ```ts import { createPlayground } from "livecodes"; createPlayground("#container").then(async (playground) => { const config = await playground.getConfig(); }); ``` #### Defined in [src/sdk/models.ts:1473](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1473) *** ### getShareUrl() > **getShareUrl**: (`shortUrl`?) => `Promise`\<`string`\> Gets a [share url](https://livecodes.io/docs/features/share) for the current project. By default, the url has a long query string representing the compressed encoded config object. If the argument `shortUrl` was set to `true`, a short url is generated. #### Parameters • **shortUrl?**: `boolean` #### Returns `Promise`\<`string`\> #### Example ```ts import { createPlayground } from "livecodes"; createPlayground("#container").then(async (playground) => { const longUrl = await playground.getShareUrl(); const shortUrl = await playground.getShareUrl(true); }); ``` #### Defined in [src/sdk/models.ts:1457](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1457) *** ### ~~onChange()~~ > **onChange**: (`fn`) => `object` Runs a callback function when code changes. #### Parameters • **fn** #### Returns `object` ##### ~~remove()~~ > **remove**: () => `void` ###### Returns `void` #### Deprecated Use [`watch`](https://livecodes.io/docs/sdk/js-ts#watch) method instead. #### Defined in [src/sdk/models.ts:1555](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1555) *** ### run() > **run**: () => `Promise`\<`void`\> Runs the [result page](https://livecodes.io/docs/features/result) (after any required compilation for code). #### Returns `Promise`\<`void`\> #### Example ```ts import { createPlayground } from "livecodes"; createPlayground("#container").then(async (playground) => { await playground.run(); // new result page is displayed }); ``` #### Defined in [src/sdk/models.ts:1423](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1423) *** ### runTests() > **runTests**: () => `Promise`\<`object`\> Runs project [tests](https://livecodes.io/docs/features/tests) (if present) and gets test results. #### Returns `Promise`\<`object`\> ##### results > **results**: [`TestResult`](TestResult.md)[] #### Example ```ts import { createPlayground } from "livecodes"; createPlayground("#container").then(async (playground) => { const { results } = await playground.runTests(); }); ``` #### Defined in [src/sdk/models.ts:1548](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1548) *** ### setConfig() > **setConfig**: (`config`) => `Promise`\<[`Config`](../../interfaces/Config.md)\> Loads a new project using the passed configuration object. If the config is a string, it is assumed to be a URL to a JSON file that contains the configuration object. #### Parameters • **config**: `string` \| `Partial`\<[`Config`](../../interfaces/Config.md)\> #### Returns `Promise`\<[`Config`](../../interfaces/Config.md)\> #### Throws It throws an error if the config object (or URL) is invalid. #### Example ```ts import { createPlayground } from "livecodes"; createPlayground("#container").then(async (playground) => { const config = { markup: { language: "html", content: "Hello World!", }, }; const newConfig = await playground.setConfig(config); // new project loaded }); ``` #### Defined in [src/sdk/models.ts:1497](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1497) *** ### show() > **show**: (`panel`, `options`?) => `Promise`\<`void`\> Shows the selected panel. See [docs](https://livecodes.io/docs/sdk/js-ts#show) for details. #### Parameters • **panel**: `"editor"` \| `"result"` \| [`EditorId`](../type-aliases/EditorId.md) \| [`ToolName`](../type-aliases/ToolName.md) \| `"toggle-result"` • **options?** • **options.column?**: `number` • **options.full?**: `boolean` • **options.line?**: `number` • **options.zoom?**: `1` \| `0.5` \| `0.25` #### Returns `Promise`\<`void`\> #### Example ```ts await playground.show("style"); await playground.show("toggle-result"); await playground.show("result", { full: true }); await playground.show("script"); await playground.show("result", { zoom: 0.5 }); await playground.show("console", { full: true }); ``` #### Defined in [src/sdk/models.ts:1532](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1532) *** ### watch > **watch**: [`WatchLoad`](../type-aliases/WatchLoad.md) & [`WatchReady`](../type-aliases/WatchReady.md) & [`WatchCode`](../type-aliases/WatchCode.md) & [`WatchRun`](../type-aliases/WatchRun.md) & [`WatchConsole`](../type-aliases/WatchConsole.md) & [`WatchTests`](../type-aliases/WatchTests.md) & [`WatchDestroy`](../type-aliases/WatchDestroy.md) Allows to watch for various playground events. It takes 2 arguments: event name and a callback function that will be called on every event. event name can be one of: `"load" | "ready" | "code" | "run" | "console" | "tests" | "destroy"` In some events, the callback function will be called with an object that supplies relevant data to the callback function (e.g. code, console output, test results). The watch method returns an object with a single method (`remove`), which when called will remove the callback from watching further events. See [docs](https://livecodes.io/docs/sdk/js-ts#watch) for details. #### Example ```ts import { createPlayground } from "livecodes"; createPlayground("#container").then((playground) => { const codeWatcher = playground.watch("code", ({ code, config }) => { // this will run on every code change console.log("code:", code); console.log("config:", config); }); const consoleWatcher = playground.watch("console", ({ method, args }) => { // this will run on every console output console[method](...args); }); const testsWatcher = playground.watch("tests", ({ results }) => { // this will run when tests run results.forEach((testResult) => { console.log("status:", testResult.status); // "pass", "fail" or "skip" console.log(testResult.errors); // array of errors as strings }); }); // then later codeWatcher.remove(); consoleWatcher.remove(); testsWatcher.remove(); // events are no longer watched }); ``` #### Defined in [src/sdk/models.ts:1600](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1600) --- # Interface: AppConfig These are properties that define how the app behaves. ## Extended by - [`Config`](../../interfaces/Config.md) ## Properties ### allowLangChange > **allowLangChange**: `boolean` If `false`, the UI will not show the menu that allows changing editor language. #### Default ```ts true ``` #### Defined in [src/sdk/models.ts:1044](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1044) *** ### disableHomeLink > **disableHomeLink**: `boolean` If `true`, the link on LiveCodes logo ("Edit on LiveCodes") is disabled in [embeds](https://livecodes.io/docs/features/embeds). #### Default ```ts false ``` #### Defined in [src/sdk/models.ts:1088](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1088) *** ### mode > **mode**: `"editor"` \| `"result"` \| `"full"` \| `"focus"` \| `"lite"` \| `"simple"` \| `"codeblock"` Sets the [display mode](https://livecodes.io/docs/features/display-modes). #### Default ```ts "full" ``` #### Defined in [src/sdk/models.ts:1056](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1056) *** ### readonly > **readonly**: `boolean` If `true`, editors are loaded in read-only mode, where the user is not allowed to change the code. By default, when readonly is set to true, the light-weight code editor [CodeJar](https://livecodes.io/docs/features/editor-settings#code-editor) is used. If you wish to use another editor, set the [editor](https://livecodes.io/docs/configuration/configuration-object#editor) property. #### Default ```ts false ``` #### Defined in [src/sdk/models.ts:1038](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1038) *** ### tools > **tools**: `Partial`\<`object`\> Sets enabled and active tools and status of [tools pane](https://livecodes.io/docs/features/tools-pane). #### Type declaration ##### active > **active**: `""` \| [`ToolName`](../type-aliases/ToolName.md) ##### enabled > **enabled**: ([`ToolName`](../type-aliases/ToolName.md) \| `"zoom"`)[] \| `"all"` ##### status > **status**: [`ToolsPaneStatus`](../type-aliases/ToolsPaneStatus.md) #### Default ```ts { enabled: "all", active: "", status: "" } ``` #### Example ```js { "tools": { "enabled": ["console", "compiled"], "active": "console", "status": "open" } } ``` #### Defined in [src/sdk/models.ts:1072](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1072) *** ### view? > `optional` **view**: `"split"` \| `"editor"` \| `"result"` Sets the [default view](https://livecodes.io/docs/features/default-view) for the playground. #### Default ```ts "split" ``` #### Defined in [src/sdk/models.ts:1050](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1050) *** ### zoom > **zoom**: `0.25` \| `0.5` \| `1` Sets result page [zoom level](https://livecodes.io/docs/features/result#result-page-zoom). #### Defined in [src/sdk/models.ts:1081](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1081) --- # Interface: ContentConfig The properties that define the content of the current [project](https://livecodes.io/docs/features/projects). ## Extended by - [`Config`](../../interfaces/Config.md) ## Properties ### activeEditor > **activeEditor**: `undefined` \| [`EditorId`](../type-aliases/EditorId.md) Selects the active editor to show. Defaults to the last used editor for user, otherwise `"markup"` #### Defined in [src/sdk/models.ts:1138](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1138) *** ### cssPreset > **cssPreset**: [`CssPresetId`](../type-aliases/CssPresetId.md) [CSS Preset](https://livecodes.io/docs/features/external-resources#css-presets) to use. #### Defined in [src/sdk/models.ts:1185](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1185) *** ### customSettings > **customSettings**: `object` Defines [custom settings](https://livecodes.io/docs/advanced/custom-settings) for the current project. #### adoc > **adoc**: `any` #### app.svelte > **svelte**: `any` #### app.vue > **vue**: `any` #### art > **art**: `any` #### art-template > **art-template**: `any` #### as > **as**: `any` #### asc > **asc**: `any` #### asciidoc > **asciidoc**: `any` #### assemblyscript > **assemblyscript**: `any` #### astro > **astro**: `any` #### autoprefixer > **autoprefixer**: `any` #### babel > **babel**: `any` #### bb > **bb**: `any` #### bbcode > **bbcode**: `any` #### Binary > **Binary**: `any` #### blockly > **blockly**: `any` #### blockly.xml > **xml**: `any` #### c > **c**: `any` #### C > **C**: `any` #### c++ > **c++**: `any` #### civet > **civet**: `any` #### clang > **clang**: `any` #### clang.cpp > **cpp**: `any` #### clio > **clio**: `any` #### clj > **clj**: `any` #### cljc > **cljc**: `any` #### cljs > **cljs**: `any` #### clojure > **clojure**: `any` #### clojurescript > **clojurescript**: `any` #### coffee > **coffee**: `any` #### coffeescript > **coffeescript**: `any` #### common-lisp > **common-lisp**: `any` #### commonlisp > **commonlisp**: `any` #### convertCommonjs? > `optional` **convertCommonjs**: `boolean` #### cp > **cp**: `any` #### cpp > **cpp**: `any` #### cpp-wasm > **cpp-wasm**: `any` #### cppm > **cppm**: `any` #### cppwasm > **cppwasm**: `any` #### cs > **cs**: `any` #### cs-wasm > **cs-wasm**: `any` #### csharp > **csharp**: `any` #### csharp-wasm > **csharp-wasm**: `any` #### css > **css**: `any` #### cssmodules > **cssmodules**: `any` #### cssnano > **cssnano**: `any` #### cwasm > **cwasm**: `any` #### cxx > **cxx**: `any` #### defaultCDN? > `optional` **defaultCDN**: [`CDN`](../type-aliases/CDN.md) #### diagram > **diagram**: `any` #### diagrams > **diagrams**: `any` #### dot > **dot**: `any` #### dzn > **dzn**: `any` #### edn > **edn**: `any` #### ejs > **ejs**: `any` #### es > **es**: `any` #### eta > **eta**: `any` #### fennel > **fennel**: `any` #### flow > **flow**: `any` #### fnl > **fnl**: `any` #### gleam > **gleam**: `any` #### go > **go**: `any` #### go-wasm > **go-wasm**: `any` #### golang > **golang**: `any` #### gowasm > **gowasm**: `any` #### graph > **graph**: `any` #### h > **h**: `any` #### haml > **haml**: `any` #### handlebars > **handlebars**: `any` #### hbs > **hbs**: `any` #### hpp > **hpp**: `any` #### htm > **htm**: `any` #### html > **html**: `any` #### ii > **ii**: `any` #### imba > **imba**: `any` #### imports? > `optional` **imports**: `Record`\<`string`, `string`\> #### ixx > **ixx**: `any` #### jade > **jade**: `any` #### java > **java**: `any` #### javascript > **javascript**: `any` #### jinja > **jinja**: `any` #### jl > **jl**: `any` #### js > **js**: `any` #### json > **json**: `any` #### jsx > **jsx**: `any` #### julia > **julia**: `any` #### less > **less**: `any` #### lightningcss > **lightningcss**: `any` #### liquid > **liquid**: `any` #### liquidjs > **liquidjs**: `any` #### lisp > **lisp**: `any` #### livescript > **livescript**: `any` #### ls > **ls**: `any` #### lua > **lua**: `any` #### lua-wasm > **lua-wasm**: `any` #### luawasm > **luawasm**: `any` #### malina > **malina**: `any` #### malinajs > **malinajs**: `any` #### mapImports? > `optional` **mapImports**: `boolean` #### markdown > **markdown**: `any` #### md > **md**: `any` #### mdown > **mdown**: `any` #### mdx > **mdx**: `any` #### minizinc > **minizinc**: `any` #### mjml > **mjml**: `any` #### mjs > **mjs**: `any` #### mkdn > **mkdn**: `any` #### ml > **ml**: `any` #### mli > **mli**: `any` #### mts > **mts**: `any` #### mustache > **mustache**: `any` #### mzn > **mzn**: `any` #### njk > **njk**: `any` #### nunjucks > **nunjucks**: `any` #### ocaml > **ocaml**: `any` #### perl > **perl**: `any` #### pg > **pg**: `any` #### pg.sql > **sql**: `any` #### pglite > **pglite**: `any` #### pglite.sql > **sql**: `any` #### pgsql > **pgsql**: `any` #### pgsql.sql > **sql**: `any` #### php > **php**: `any` #### php-wasm > **php-wasm**: `any` #### phpwasm > **phpwasm**: `any` #### pintora > **pintora**: `any` #### pl > **pl**: `any` #### plt > **plt**: `any` #### pm > **pm**: `any` #### postcss > **postcss**: `any` #### postcssImportUrl > **postcssImportUrl**: `any` #### postcssPresetEnv > **postcssPresetEnv**: `any` #### postgre.sql > **sql**: `any` #### postgres > **postgres**: `any` #### postgresql > **postgresql**: `any` #### postgresql.sql > **sql**: `any` #### prolog > **prolog**: `any` #### prolog.pl > **pl**: `any` #### pug > **pug**: `any` #### purgecss > **purgecss**: `any` #### py > **py**: `any` #### py-wasm > **py-wasm**: `any` #### py3 > **py3**: `any` #### pyodide > **pyodide**: `any` #### python > **python**: `any` #### python-wasm > **python-wasm**: `any` #### pythonwasm > **pythonwasm**: `any` #### pywasm > **pywasm**: `any` #### r > **r**: `any` #### r-wasm > **r-wasm**: `any` #### rb > **rb**: `any` #### re > **re**: `any` #### react > **react**: `any` #### react-jsx > **react-jsx**: `any` #### react-native > **react-native**: `any` #### react-native-tsx > **react-native-tsx**: `any` #### react-native.jsx > **jsx**: `any` #### react-native.tsx > **tsx**: `any` #### react-tsx > **react-tsx**: `any` #### react.jsx > **jsx**: `any` #### react.tsx > **tsx**: `any` #### reason > **reason**: `any` #### rei > **rei**: `any` #### res > **res**: `any` #### rescript > **rescript**: `any` #### resi > **resi**: `any` #### rich > **rich**: `any` #### richtext > **richtext**: `any` #### riot > **riot**: `any` #### riotjs > **riotjs**: `any` #### ripple > **ripple**: `any` #### ripplejs > **ripplejs**: `any` #### rlang > **rlang**: `any` #### rstats > **rstats**: `any` #### rte > **rte**: `any` #### rte.html > **html**: `any` #### ruby > **ruby**: `any` #### ruby-wasm > **ruby-wasm**: `any` #### rubywasm > **rubywasm**: `any` #### sass > **sass**: `any` #### scheme > **scheme**: `any` #### scm > **scm**: `any` #### scriptType? > `optional` **scriptType**: `""` \| `"module"` \| `"application/javascript"` \| `"application/ecmascript"` \| `"text/javascript"` \| `"text/ecmascript"` \| `"text/liquid"` \| `"text/python"` \| `"text/r"` \| `"text/ruby-wasm"` \| `"text/x-uniter-php"` \| `"text/php-wasm"` \| `"text/cpp"` \| `"text/java"` \| `"text/csharp-wasm"` \| `"text/perl"` \| `"text/julia"` \| `"text/biwascheme"` \| `"text/commonlisp"` \| `"text/tcl"` \| `"text/prolog"` \| `"text/minizinc"` \| `"text/go-wasm"` \| `"application/json"` \| `"application/lua"` \| `"text/fennel"` \| `"application/wasm-uint8"` #### scss > **scss**: `any` #### solid > **solid**: `any` #### solid.jsx > **jsx**: `any` #### solid.tsx > **tsx**: `any` #### sql > **sql**: `any` #### sqlite > **sqlite**: `any` #### sqlite3 > **sqlite3**: `any` #### stencil > **stencil**: `any` #### stencil.tsx > **tsx**: `any` #### styl > **styl**: `any` #### stylis > **stylis**: `any` #### stylus > **stylus**: `any` #### sucrase > **sucrase**: `any` #### svelte > **svelte**: `any` #### svelte-app > **svelte-app**: `any` #### swift > **swift**: `any` #### tailwindcss > **tailwindcss**: `any` #### tcl > **tcl**: `any` #### teal > **teal**: `any` #### template? > `optional` **template**: `object` #### template.data? > `optional` **data**: `any` #### template.prerender? > `optional` **prerender**: `boolean` #### tl > **tl**: `any` #### tokencss > **tokencss**: `any` #### ts > **ts**: `any` #### tsx > **tsx**: `any` #### twig > **twig**: `any` #### types? > `optional` **types**: [`Types`](Types.md) #### typescript > **typescript**: `any` #### unocss > **unocss**: `any` #### vento > **vento**: `any` #### vto > **vto**: `any` #### vue > **vue**: `any` #### vue-app > **vue-app**: `any` #### vue2 > **vue2**: `any` #### vue3 > **vue3**: `any` #### wasm > **wasm**: `any` #### wasm.cpp > **cpp**: `any` #### wasm.cs > **cs**: `any` #### wasm.go > **go**: `any` #### wasm.lua > **lua**: `any` #### wasm.php > **php**: `any` #### wasm.py > **py**: `any` #### wasm.rb > **rb**: `any` #### wast > **wast**: `any` #### wat > **wat**: `any` #### webassembly > **webassembly**: `any` #### windicss > **windicss**: `any` #### xht > **xht**: `any` #### xml > **xml**: `any` #### Defined in [src/sdk/models.ts:1197](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1197) *** ### description > **description**: `string` Project description. Used in [project](https://livecodes.io/docs/features/projects) search and [result page](https://livecodes.io/docs/features/result) description meta tag. #### Default ```ts "" ``` #### Defined in [src/sdk/models.ts:1108](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1108) *** ### head > **head**: `string` Content added to the [result page](https://livecodes.io/docs/features/result) `` element. #### Default ```ts '\n' ``` #### Defined in [src/sdk/models.ts:1114](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1114) *** ### htmlAttrs > **htmlAttrs**: `string` \| `Record`\<`string`, `string`\> Attributes added to the [result page](https://livecodes.io/docs/features/result) `` element. It can be an object or a string. #### Example ```ts { lang: "en", class: "dark" } 'lang="en" class="dark"' ``` #### Defined in [src/sdk/models.ts:1123](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1123) *** ### imports > **imports**: `object` Allows specifying custom [import maps](https://github.com/WICG/import-maps) for [module imports](https://livecodes.io/docs/features/module-resolution#custom-module-resolution). **Example** Setting `imports` like this: ```js "imports": { "moment": "https://cdn.jsdelivr.net/npm/moment@2.29.4/dist/moment.js" } ``` results in the following import map: ```html ``` See docs for [Imports](https://livecodes.io/docs/configuration/configuration-object#imports) and [Custom Module Resolution](https://livecodes.io/docs/features/module-resolution/#custom-module-resolution) #### Index Signature \[`key`: `string`\]: `string` #### Defined in [src/sdk/models.ts:1223](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1223) *** ### languages > **languages**: `undefined` \| (`"html"` \| `"htm"` \| `"markdown"` \| `"md"` \| `"mdown"` \| `"mkdn"` \| `"mdx"` \| `"astro"` \| `"pug"` \| `"jade"` \| `"haml"` \| `"asciidoc"` \| `"adoc"` \| `"asc"` \| `"mustache"` \| `"handlebars"` \| `"hbs"` \| `"ejs"` \| `"eta"` \| `"nunjucks"` \| `"njk"` \| `"liquid"` \| `"liquidjs"` \| `"dot"` \| `"twig"` \| `"vento"` \| `"vto"` \| `"art-template"` \| `"art"` \| `"jinja"` \| `"bbcode"` \| `"bb"` \| `"mjml"` \| `"diagrams"` \| `"diagram"` \| `"graph"` \| `"plt"` \| `"richtext"` \| `"rte"` \| `"rich"` \| `"rte.html"` \| `"css"` \| `"scss"` \| `"sass"` \| `"less"` \| `"stylus"` \| `"styl"` \| `"stylis"` \| `"postcss"` \| `"javascript"` \| `"js"` \| `"mjs"` \| `"json"` \| `"babel"` \| `"es"` \| `"sucrase"` \| `"typescript"` \| `"flow"` \| `"ts"` \| `"mts"` \| `"jsx"` \| `"tsx"` \| `"react"` \| `"react-jsx"` \| `"react.jsx"` \| `"react-tsx"` \| `"react.tsx"` \| `"react-native"` \| `"react-native.jsx"` \| `"react-native-tsx"` \| `"react-native.tsx"` \| `"vue"` \| `"vue3"` \| `"vue2"` \| `"vue-app"` \| `"app.vue"` \| `"svelte"` \| `"svelte-app"` \| `"app.svelte"` \| `"stencil"` \| `"stencil.tsx"` \| `"solid"` \| `"solid.jsx"` \| `"solid.tsx"` \| `"riot"` \| `"riotjs"` \| `"malina"` \| `"malinajs"` \| `"ripple"` \| `"ripplejs"` \| `"xht"` \| `"coffeescript"` \| `"coffee"` \| `"livescript"` \| `"ls"` \| `"civet"` \| `"clio"` \| `"imba"` \| `"assemblyscript"` \| `"as"` \| `"python"` \| `"py"` \| `"pyodide"` \| `"python-wasm"` \| `"py-wasm"` \| `"pythonwasm"` \| `"pywasm"` \| `"py3"` \| `"wasm.py"` \| `"r"` \| `"rlang"` \| `"rstats"` \| `"r-wasm"` \| `"ruby"` \| `"rb"` \| `"ruby-wasm"` \| `"wasm.rb"` \| `"rubywasm"` \| `"go"` \| `"golang"` \| `"go-wasm"` \| `"wasm.go"` \| `"gowasm"` \| `"php"` \| `"php-wasm"` \| `"phpwasm"` \| `"wasm.php"` \| `"cpp"` \| `"c"` \| `"C"` \| `"cp"` \| `"cxx"` \| `"c++"` \| `"cppm"` \| `"ixx"` \| `"ii"` \| `"hpp"` \| `"h"` \| `"cpp-wasm"` \| `"cppwasm"` \| `"cwasm"` \| `"wasm.cpp"` \| `"clang"` \| `"clang.cpp"` \| `"java"` \| `"csharp"` \| `"csharp-wasm"` \| `"cs"` \| `"cs-wasm"` \| `"wasm.cs"` \| `"perl"` \| `"pl"` \| `"pm"` \| `"lua"` \| `"lua-wasm"` \| `"luawasm"` \| `"wasm.lua"` \| `"teal"` \| `"tl"` \| `"fennel"` \| `"fnl"` \| `"julia"` \| `"jl"` \| `"scheme"` \| `"scm"` \| `"commonlisp"` \| `"common-lisp"` \| `"lisp"` \| `"clojurescript"` \| `"clojure"` \| `"cljs"` \| `"clj"` \| `"cljc"` \| `"edn"` \| `"gleam"` \| `"swift"` \| `"rescript"` \| `"res"` \| `"resi"` \| `"reason"` \| `"re"` \| `"rei"` \| `"ocaml"` \| `"ml"` \| `"mli"` \| `"tcl"` \| `"wat"` \| `"wast"` \| `"webassembly"` \| `"wasm"` \| `"Binary"` \| `"sql"` \| `"sqlite"` \| `"sqlite3"` \| `"pg.sql"` \| `"pgsql.sql"` \| `"pgsql"` \| `"pg"` \| `"pglite"` \| `"pglite.sql"` \| `"postgresql"` \| `"postgres"` \| `"postgre.sql"` \| `"postgresql.sql"` \| `"prolog.pl"` \| `"prolog"` \| `"minizinc"` \| `"mzn"` \| `"dzn"` \| `"blockly"` \| `"blockly.xml"` \| `"xml"` \| `"pintora"` \| `"postcssImportUrl"` \| `"tailwindcss"` \| `"windicss"` \| `"unocss"` \| `"tokencss"` \| `"lightningcss"` \| `"autoprefixer"` \| `"postcssPresetEnv"` \| `"cssmodules"` \| `"purgecss"` \| `"cssnano"`)[] List of enabled languages. Defaults to all supported languages in full app and only current editor languages in [embeds](https://livecodes.io/docs/features/embeds). #### Defined in [src/sdk/models.ts:1145](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1145) *** ### markup > **markup**: `object` An object that configures the language and content of the markup editor. See [docs](https://livecodes.io/docs/configuration/configuration-object/#markup) for details. #### content? > `optional` **content**: `string` The initial content of the code editor. ##### Default ```ts "" ``` #### contentUrl? > `optional` **contentUrl**: `string` A URL to load `content` from. It has to be a valid URL that is CORS-enabled. The URL is only fetched if `content` property had no value. #### foldedLines? > `optional` **foldedLines**: `object`[] Lines that get folded when the editor loads. This can be used for less relevant content. ##### Example ```ts [{ from: 5, to: 8 }, { from: 15, to: 20 }] ``` #### hiddenContent? > `optional` **hiddenContent**: `string` Hidden content that gets evaluated without being visible in the code editor. This can be useful in embedded playgrounds (e.g. for adding helper functions, utilities or tests) #### hiddenContentUrl? > `optional` **hiddenContentUrl**: `string` A URL to load `hiddenContent` from. It has to be a valid URL that is CORS-enabled. The URL is only fetched if `hiddenContent` property had no value. #### hideTitle? > `optional` **hideTitle**: `boolean` If `true`, the title of the code editor is hidden, however its code is still evaluated. This can be useful in embedded playgrounds (e.g. for hiding unnecessary code). #### language > **language**: [`Language`](../../type-aliases/Language.md) A language name, extension or alias (as defined in [language documentations](https://livecodes.io/docs/languages/)). For the list of supported values, see [Language](https://livecodes.io/docs/api/type-aliases/Language) #### order? > `optional` **order**: `number` The order of the editor in the UI. ##### Default ```ts 0 ``` #### position? > `optional` **position**: [`EditorPosition`](EditorPosition.md) The initial position of the cursor in the code editor. ##### Example ```ts {lineNumber: 5, column: 10} ``` #### selector? > `optional` **selector**: `string` A CSS selector to load content from [DOM import](https://livecodes.io/docs/features/import#import-code-from-dom). #### title? > `optional` **title**: `string` If set, this is used as the title of the editor in the UI, overriding the default title set to the language name (e.g. `"Python"` can be used instead of `"Py (Wasm)"`). #### Default ```ts { language: "html", content: "" } ``` #### Defined in [src/sdk/models.ts:1153](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1153) *** ### processors > **processors**: [`Processor`](../type-aliases/Processor.md)[] List of enabled [CSS processors](https://livecodes.io/docs/features/css/#css-processors). For the list of available processors, see [Processor](https://livecodes.io/docs/api/internal/type-aliases/Processor) #### Defined in [src/sdk/models.ts:1192](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1192) *** ### script > **script**: `object` An object that configures the language and content of the script editor. See [docs](https://livecodes.io/docs/configuration/configuration-object/#markup) for details. #### content? > `optional` **content**: `string` The initial content of the code editor. ##### Default ```ts "" ``` #### contentUrl? > `optional` **contentUrl**: `string` A URL to load `content` from. It has to be a valid URL that is CORS-enabled. The URL is only fetched if `content` property had no value. #### foldedLines? > `optional` **foldedLines**: `object`[] Lines that get folded when the editor loads. This can be used for less relevant content. ##### Example ```ts [{ from: 5, to: 8 }, { from: 15, to: 20 }] ``` #### hiddenContent? > `optional` **hiddenContent**: `string` Hidden content that gets evaluated without being visible in the code editor. This can be useful in embedded playgrounds (e.g. for adding helper functions, utilities or tests) #### hiddenContentUrl? > `optional` **hiddenContentUrl**: `string` A URL to load `hiddenContent` from. It has to be a valid URL that is CORS-enabled. The URL is only fetched if `hiddenContent` property had no value. #### hideTitle? > `optional` **hideTitle**: `boolean` If `true`, the title of the code editor is hidden, however its code is still evaluated. This can be useful in embedded playgrounds (e.g. for hiding unnecessary code). #### language > **language**: [`Language`](../../type-aliases/Language.md) A language name, extension or alias (as defined in [language documentations](https://livecodes.io/docs/languages/)). For the list of supported values, see [Language](https://livecodes.io/docs/api/type-aliases/Language) #### order? > `optional` **order**: `number` The order of the editor in the UI. ##### Default ```ts 0 ``` #### position? > `optional` **position**: [`EditorPosition`](EditorPosition.md) The initial position of the cursor in the code editor. ##### Example ```ts {lineNumber: 5, column: 10} ``` #### selector? > `optional` **selector**: `string` A CSS selector to load content from [DOM import](https://livecodes.io/docs/features/import#import-code-from-dom). #### title? > `optional` **title**: `string` If set, this is used as the title of the editor in the UI, overriding the default title set to the language name (e.g. `"Python"` can be used instead of `"Py (Wasm)"`). #### Default ```ts { language: "javascript", content: "" } ``` #### Defined in [src/sdk/models.ts:1169](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1169) *** ### scripts > **scripts**: `string`[] List of URLs for [external scripts](https://livecodes.io/docs/features/external-resources) to add to the [result page](https://livecodes.io/docs/features/result). #### Defined in [src/sdk/models.ts:1179](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1179) *** ### style > **style**: `object` An object that configures the language and content of the style editor. See [docs](https://livecodes.io/docs/configuration/configuration-object/#markup) for details. #### content? > `optional` **content**: `string` The initial content of the code editor. ##### Default ```ts "" ``` #### contentUrl? > `optional` **contentUrl**: `string` A URL to load `content` from. It has to be a valid URL that is CORS-enabled. The URL is only fetched if `content` property had no value. #### foldedLines? > `optional` **foldedLines**: `object`[] Lines that get folded when the editor loads. This can be used for less relevant content. ##### Example ```ts [{ from: 5, to: 8 }, { from: 15, to: 20 }] ``` #### hiddenContent? > `optional` **hiddenContent**: `string` Hidden content that gets evaluated without being visible in the code editor. This can be useful in embedded playgrounds (e.g. for adding helper functions, utilities or tests) #### hiddenContentUrl? > `optional` **hiddenContentUrl**: `string` A URL to load `hiddenContent` from. It has to be a valid URL that is CORS-enabled. The URL is only fetched if `hiddenContent` property had no value. #### hideTitle? > `optional` **hideTitle**: `boolean` If `true`, the title of the code editor is hidden, however its code is still evaluated. This can be useful in embedded playgrounds (e.g. for hiding unnecessary code). #### language > **language**: [`Language`](../../type-aliases/Language.md) A language name, extension or alias (as defined in [language documentations](https://livecodes.io/docs/languages/)). For the list of supported values, see [Language](https://livecodes.io/docs/api/type-aliases/Language) #### order? > `optional` **order**: `number` The order of the editor in the UI. ##### Default ```ts 0 ``` #### position? > `optional` **position**: [`EditorPosition`](EditorPosition.md) The initial position of the cursor in the code editor. ##### Example ```ts {lineNumber: 5, column: 10} ``` #### selector? > `optional` **selector**: `string` A CSS selector to load content from [DOM import](https://livecodes.io/docs/features/import#import-code-from-dom). #### title? > `optional` **title**: `string` If set, this is used as the title of the editor in the UI, overriding the default title set to the language name (e.g. `"Python"` can be used instead of `"Py (Wasm)"`). #### Default ```ts { language: "css", content: "" } ``` #### Defined in [src/sdk/models.ts:1161](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1161) *** ### stylesheets > **stylesheets**: `string`[] List of URLs for [external stylesheets](https://livecodes.io/docs/features/external-resources) to add to the [result page](https://livecodes.io/docs/features/result). #### Defined in [src/sdk/models.ts:1174](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1174) *** ### tags > **tags**: `string`[] Project tags. Used in [project](https://livecodes.io/docs/features/projects) filter and search. #### Default ```ts [] ``` #### Defined in [src/sdk/models.ts:1130](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1130) *** ### tests > **tests**: `undefined` \| `object` Configures the [language](https://livecodes.io/docs/features/tests#supported-languages) and content of [tests](https://livecodes.io/docs/features/tests). #### Defined in [src/sdk/models.ts:1259](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1259) *** ### title > **title**: `string` Project title. This is used as [result page](https://livecodes.io/docs/features/result) title and title meta tag. Also used in project search. #### Default ```ts "Untitled Project" ``` #### Defined in [src/sdk/models.ts:1101](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1101) *** ### types > **types**: `object` Allows providing custom TypeScript type declarations for better [editor intellisense](https://livecodes.io/docs/features/intellisense). It is an object where each key represents module name and value represents the types. See docs for [Types](https://livecodes.io/docs/configuration/configuration-object#types) and [Custom Types](https://livecodes.io/docs/features/intellisense#custom-types) #### Examples ```js { "types": { "my-demo-lib": "https://my-custom-domain/my-type-declarations.d.ts" } } ``` ``` { "types": { "my-demo-lib": { "url": "https://my-custom-domain/types.d.ts", "autoload": true, "declareAsModule": true } } ``` #### Defined in [src/sdk/models.ts:1253](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1253) *** ### version > `readonly` **version**: `string` This is a read-only property which specifies the current LiveCodes version. Version specified in [exported](https://livecodes.io/docs/features/export) projects allows automatically upgrading the project configuration when imported by an app with a newer version. #### Defined in [src/sdk/models.ts:1266](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1266) --- # Interface: EditorConfig Configuration for code editor settings. ## Extended by - [`UserConfig`](UserConfig.md) ## Properties ### closeBrackets > **closeBrackets**: `boolean` Use auto-complete to close brackets and quotes. #### Default ```ts true ``` #### Defined in [src/sdk/models.ts:937](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L937) *** ### editor > **editor**: `undefined` \| `"auto"` \| `"monaco"` \| `"codemirror"` \| `"codejar"` Selects the [code editor](https://livecodes.io/docs/features/editor-settings#code-editor) to use. If `undefined` (the default), Monaco editor is used on desktop, CodeMirror is used on mobile and in `simple` mode, while CodeJar is used in `codeblock` mode, in `lite` mode and in `readonly` playgrounds. If set to `auto`, Monaco editor is used on desktop and CodeMirror is used on mobile regardless of other settings. #### Default ```ts undefined ``` #### Defined in [src/sdk/models.ts:858](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L858) *** ### editorMode > **editorMode**: `undefined` \| `"vim"` \| `"emacs"` Sets [editor mode](https://livecodes.io/docs/features/editor-settings#editor-modes). #### Defined in [src/sdk/models.ts:954](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L954) *** ### editorTheme > **editorTheme**: `undefined` \| `string` \| [`EditorTheme`](../type-aliases/EditorTheme.md)[] Sets the [code editor](https://livecodes.io/docs/features/editor-settings) themes. See docs for [editor themes](https://livecodes.io/docs/configuration/configuration-object#editortheme) for details. #### Examples ```ts "vs" ``` ```ts "monaco:twilight, codemirror:one-dark" ``` ```ts ["vs@light"] ``` ```ts ["vs@light", "vs-dark@dark"] ``` ```ts ["monaco:vs@light", "codemirror:github-light@light", "dracula@dark"] ``` #### Defined in [src/sdk/models.ts:884](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L884) *** ### emmet > **emmet**: `boolean` Enables [Emmet](https://livecodes.io/docs/features/editor-settings#emmet). #### Default ```ts true ``` #### Defined in [src/sdk/models.ts:949](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L949) *** ### foldRegions > **foldRegions**: `boolean` When set to `true`, regions marked by `#region` and `#endregion` comments are folded when the project is loaded. #### Default ```ts false ``` #### Defined in [src/sdk/models.ts:931](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L931) *** ### fontFamily > **fontFamily**: `undefined` \| `string` Sets the [code editor](https://livecodes.io/docs/features/editor-settings) font family. #### Defined in [src/sdk/models.ts:889](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L889) *** ### fontSize > **fontSize**: `undefined` \| `number` Sets the font size. If `undefined` (the default), the font size is set to 14 for the full app and 12 for [embeds](https://livecodes.io/docs/features/embeds). #### Default ```ts undefined ``` #### Defined in [src/sdk/models.ts:897](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L897) *** ### lineNumbers > **lineNumbers**: `boolean` \| `"relative"` Show line numbers in [code editor](https://livecodes.io/docs/features/editor-settings). #### Default ```ts true ``` #### Defined in [src/sdk/models.ts:919](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L919) *** ### minimap > **minimap**: `boolean` Enables minimap in code editor. #### Default ```ts false ``` #### Defined in [src/sdk/models.ts:943](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L943) *** ### tabSize > **tabSize**: `number` The number of spaces per indentation-level. Also used in [code formatting](https://livecodes.io/docs/features/code-format). #### Default ```ts 2 ``` #### Defined in [src/sdk/models.ts:913](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L913) *** ### theme > **theme**: [`Theme`](../type-aliases/Theme.md) Sets the app [theme](https://livecodes.io/docs/features/themes) to light/dark mode. #### Default ```ts "dark" ``` #### Defined in [src/sdk/models.ts:864](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L864) *** ### themeColor > **themeColor**: `undefined` \| `string` Sets the app theme color. If `undefined`, it is set to `"hsl(214, 40%, 50%)"`. #### Default ```ts undefined ``` #### Defined in [src/sdk/models.ts:871](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L871) *** ### useTabs > **useTabs**: `boolean` If `true`, lines are indented with tabs instead of spaces. Also used in [code formatting](https://livecodes.io/docs/features/code-format). #### Default ```ts false ``` #### Defined in [src/sdk/models.ts:905](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L905) *** ### wordWrap > **wordWrap**: `boolean` Enables word-wrap for long lines. #### Default ```ts false ``` #### Defined in [src/sdk/models.ts:925](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L925) --- # Interface: EditorPosition Represents a position in a code editor, with 1-based line number and (optional) 1-based column number. ## Properties ### column? > `optional` **column**: `number` 1-based column number (optional) #### Defined in [src/sdk/models.ts:261](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L261) *** ### lineNumber > **lineNumber**: `number` 1-based line number #### Defined in [src/sdk/models.ts:258](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L258) --- # Interface: FormatterConfig Configuration for code formatting options. ## Extended by - [`UserConfig`](UserConfig.md) ## Properties ### semicolons > **semicolons**: `boolean` Configures Prettier [code formatter](https://livecodes.io/docs/features/code-format) to use semi-colons. #### Default ```ts true ``` #### Defined in [src/sdk/models.ts:829](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L829) *** ### singleQuote > **singleQuote**: `boolean` Configures Prettier [code formatter](https://livecodes.io/docs/features/code-format) to use single quotes instead of double quotes. #### Default ```ts false ``` #### Defined in [src/sdk/models.ts:834](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L834) *** ### tabSize > **tabSize**: `number` The number of spaces per indentation-level. #### Default ```ts 2 ``` #### Defined in [src/sdk/models.ts:823](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L823) *** ### trailingComma > **trailingComma**: `boolean` Configures Prettier [code formatter](https://livecodes.io/docs/features/code-format) to use [trailing commas](https://prettier.io/docs/en/options.html#trailing-commas). #### Default ```ts true ``` #### Defined in [src/sdk/models.ts:840](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L840) *** ### useTabs > **useTabs**: `boolean` If `true`, lines are indented with tabs instead of spaces. #### Default ```ts false ``` #### Defined in [src/sdk/models.ts:817](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L817) --- # Interface: TestResult Represents the result of a single test. ## Properties ### duration > **duration**: `number` Time taken to run the test in milliseconds. #### Defined in [src/sdk/models.ts:660](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L660) *** ### errors > **errors**: `string`[] Array of error messages if the test failed. #### Defined in [src/sdk/models.ts:662](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L662) *** ### status > **status**: `"pass"` \| `"fail"` \| `"skip"` The status of the test. #### Defined in [src/sdk/models.ts:664](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L664) *** ### testPath > **testPath**: `string`[] The path to the test in the test suite. #### Defined in [src/sdk/models.ts:666](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L666) --- # Interface: Types Custom type declarations for module imports. ## Indexable \[`key`: `string`\]: `string` \| `object` --- # Interface: UserConfig User preferences and settings for the playground. ## Extends - [`EditorConfig`](EditorConfig.md).[`FormatterConfig`](FormatterConfig.md) ## Extended by - [`Config`](../../interfaces/Config.md) ## Properties ### appLanguage > **appLanguage**: `undefined` \| [`AppLanguage`](../type-aliases/AppLanguage.md) Sets the app UI language used. #### Defined in [src/sdk/models.ts:1024](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1024) *** ### autosave > **autosave**: `boolean` If `true`, the project is automatically saved on code change, after time [delay](https://livecodes.io/docs/configuration/configuration-object#delay). #### Default ```ts false ``` #### Defined in [src/sdk/models.ts:973](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L973) *** ### autotest > **autotest**: `boolean` If `true`, the project is watched for code changes which trigger tests to auto-run. #### Default ```ts false ``` #### Defined in [src/sdk/models.ts:979](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L979) *** ### autoupdate > **autoupdate**: `boolean` If `true`, the result page is automatically updated on code change, after time [delay](https://livecodes.io/docs/configuration/configuration-object#delay). #### Default ```ts true ``` #### Defined in [src/sdk/models.ts:966](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L966) *** ### closeBrackets > **closeBrackets**: `boolean` Use auto-complete to close brackets and quotes. #### Default ```ts true ``` #### Inherited from [`EditorConfig`](EditorConfig.md).[`closeBrackets`](EditorConfig.md#closebrackets) #### Defined in [src/sdk/models.ts:937](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L937) *** ### delay > **delay**: `number` Time delay (in milliseconds) following code change, after which the result page is updated (if [`autoupdate`](https://livecodes.io/docs/configuration/configuration-object#autoupdate) is `true`) and/or the project is saved (if [`autosave`](https://livecodes.io/docs/configuration/configuration-object#autosave) is `true`). #### Default ```ts 1500 ``` #### Defined in [src/sdk/models.ts:987](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L987) *** ### editor > **editor**: `undefined` \| `"auto"` \| `"monaco"` \| `"codemirror"` \| `"codejar"` Selects the [code editor](https://livecodes.io/docs/features/editor-settings#code-editor) to use. If `undefined` (the default), Monaco editor is used on desktop, CodeMirror is used on mobile and in `simple` mode, while CodeJar is used in `codeblock` mode, in `lite` mode and in `readonly` playgrounds. If set to `auto`, Monaco editor is used on desktop and CodeMirror is used on mobile regardless of other settings. #### Default ```ts undefined ``` #### Inherited from [`EditorConfig`](EditorConfig.md).[`editor`](EditorConfig.md#editor) #### Defined in [src/sdk/models.ts:858](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L858) *** ### editorMode > **editorMode**: `undefined` \| `"vim"` \| `"emacs"` Sets [editor mode](https://livecodes.io/docs/features/editor-settings#editor-modes). #### Inherited from [`EditorConfig`](EditorConfig.md).[`editorMode`](EditorConfig.md#editormode) #### Defined in [src/sdk/models.ts:954](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L954) *** ### editorTheme > **editorTheme**: `undefined` \| `string` \| [`EditorTheme`](../type-aliases/EditorTheme.md)[] Sets the [code editor](https://livecodes.io/docs/features/editor-settings) themes. See docs for [editor themes](https://livecodes.io/docs/configuration/configuration-object#editortheme) for details. #### Examples ```ts "vs" ``` ```ts "monaco:twilight, codemirror:one-dark" ``` ```ts ["vs@light"] ``` ```ts ["vs@light", "vs-dark@dark"] ``` ```ts ["monaco:vs@light", "codemirror:github-light@light", "dracula@dark"] ``` #### Inherited from [`EditorConfig`](EditorConfig.md).[`editorTheme`](EditorConfig.md#editortheme) #### Defined in [src/sdk/models.ts:884](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L884) *** ### emmet > **emmet**: `boolean` Enables [Emmet](https://livecodes.io/docs/features/editor-settings#emmet). #### Default ```ts true ``` #### Inherited from [`EditorConfig`](EditorConfig.md).[`emmet`](EditorConfig.md#emmet) #### Defined in [src/sdk/models.ts:949](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L949) *** ### foldRegions > **foldRegions**: `boolean` When set to `true`, regions marked by `#region` and `#endregion` comments are folded when the project is loaded. #### Default ```ts false ``` #### Inherited from [`EditorConfig`](EditorConfig.md).[`foldRegions`](EditorConfig.md#foldregions) #### Defined in [src/sdk/models.ts:931](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L931) *** ### fontFamily > **fontFamily**: `undefined` \| `string` Sets the [code editor](https://livecodes.io/docs/features/editor-settings) font family. #### Inherited from [`EditorConfig`](EditorConfig.md).[`fontFamily`](EditorConfig.md#fontfamily) #### Defined in [src/sdk/models.ts:889](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L889) *** ### fontSize > **fontSize**: `undefined` \| `number` Sets the font size. If `undefined` (the default), the font size is set to 14 for the full app and 12 for [embeds](https://livecodes.io/docs/features/embeds). #### Default ```ts undefined ``` #### Inherited from [`EditorConfig`](EditorConfig.md).[`fontSize`](EditorConfig.md#fontsize) #### Defined in [src/sdk/models.ts:897](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L897) *** ### formatOnsave > **formatOnsave**: `boolean` If `true`, the code is automatically [formatted](https://livecodes.io/docs/features/code-format) on saving the project. #### Default ```ts false ``` #### Defined in [src/sdk/models.ts:993](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L993) *** ### layout > **layout**: `undefined` \| `"responsive"` \| `"horizontal"` \| `"vertical"` Sets the app layout to horizontal or vertical. If set to `"responsive"` (the default) or `undefined`, the layout is vertical in small screens when the playground height is larger than its width, otherwise horizontal. #### Default ```ts "responsive" ``` #### Defined in [src/sdk/models.ts:1002](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1002) *** ### lineNumbers > **lineNumbers**: `boolean` \| `"relative"` Show line numbers in [code editor](https://livecodes.io/docs/features/editor-settings). #### Default ```ts true ``` #### Inherited from [`EditorConfig`](EditorConfig.md).[`lineNumbers`](EditorConfig.md#linenumbers) #### Defined in [src/sdk/models.ts:919](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L919) *** ### minimap > **minimap**: `boolean` Enables minimap in code editor. #### Default ```ts false ``` #### Inherited from [`EditorConfig`](EditorConfig.md).[`minimap`](EditorConfig.md#minimap) #### Defined in [src/sdk/models.ts:943](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L943) *** ### recoverUnsaved > **recoverUnsaved**: `boolean` Enables [recovering last unsaved project](https://livecodes.io/docs/features/recover) when the app is reopened. #### Default ```ts true ``` #### Defined in [src/sdk/models.ts:1008](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1008) *** ### semicolons > **semicolons**: `boolean` Configures Prettier [code formatter](https://livecodes.io/docs/features/code-format) to use semi-colons. #### Default ```ts true ``` #### Inherited from [`FormatterConfig`](FormatterConfig.md).[`semicolons`](FormatterConfig.md#semicolons) #### Defined in [src/sdk/models.ts:829](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L829) *** ### showSpacing > **showSpacing**: `boolean` Enables [showing element spacing](https://livecodes.io/docs/features/result#show-spacings) in the result page. #### Default ```ts false ``` #### Defined in [src/sdk/models.ts:1014](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1014) *** ### singleQuote > **singleQuote**: `boolean` Configures Prettier [code formatter](https://livecodes.io/docs/features/code-format) to use single quotes instead of double quotes. #### Default ```ts false ``` #### Inherited from [`FormatterConfig`](FormatterConfig.md).[`singleQuote`](FormatterConfig.md#singlequote) #### Defined in [src/sdk/models.ts:834](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L834) *** ### tabSize > **tabSize**: `number` The number of spaces per indentation-level. Also used in [code formatting](https://livecodes.io/docs/features/code-format). #### Default ```ts 2 ``` #### Inherited from [`FormatterConfig`](FormatterConfig.md).[`tabSize`](FormatterConfig.md#tabsize) #### Defined in [src/sdk/models.ts:913](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L913) *** ### theme > **theme**: [`Theme`](../type-aliases/Theme.md) Sets the app [theme](https://livecodes.io/docs/features/themes) to light/dark mode. #### Default ```ts "dark" ``` #### Inherited from [`EditorConfig`](EditorConfig.md).[`theme`](EditorConfig.md#theme) #### Defined in [src/sdk/models.ts:864](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L864) *** ### themeColor > **themeColor**: `undefined` \| `string` Sets the app theme color. If `undefined`, it is set to `"hsl(214, 40%, 50%)"`. #### Default ```ts undefined ``` #### Inherited from [`EditorConfig`](EditorConfig.md).[`themeColor`](EditorConfig.md#themecolor) #### Defined in [src/sdk/models.ts:871](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L871) *** ### trailingComma > **trailingComma**: `boolean` Configures Prettier [code formatter](https://livecodes.io/docs/features/code-format) to use [trailing commas](https://prettier.io/docs/en/options.html#trailing-commas). #### Default ```ts true ``` #### Inherited from [`FormatterConfig`](FormatterConfig.md).[`trailingComma`](FormatterConfig.md#trailingcomma) #### Defined in [src/sdk/models.ts:840](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L840) *** ### useTabs > **useTabs**: `boolean` If `true`, lines are indented with tabs instead of spaces. Also used in [code formatting](https://livecodes.io/docs/features/code-format). #### Default ```ts false ``` #### Inherited from [`FormatterConfig`](FormatterConfig.md).[`useTabs`](FormatterConfig.md#usetabs) #### Defined in [src/sdk/models.ts:905](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L905) *** ### welcome > **welcome**: `boolean` If `true`, the [welcome screen](https://livecodes.io/docs/features/welcome) is displayed when the app loads. #### Defined in [src/sdk/models.ts:1019](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1019) *** ### wordWrap > **wordWrap**: `boolean` Enables word-wrap for long lines. #### Default ```ts false ``` #### Inherited from [`EditorConfig`](EditorConfig.md).[`wordWrap`](EditorConfig.md#wordwrap) #### Defined in [src/sdk/models.ts:925](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L925) --- # Type Alias: APICommands > **APICommands**: `"setBroadcastToken"` \| `"showVersion"` API commands for the SDK. ## Defined in [src/sdk/models.ts:431](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L431) --- # Type Alias: AppLanguage > **AppLanguage**: `"auto"` \| `"ar"` \| `"bn"` \| `"de"` \| `"en"` \| `"es"` \| `"fa"` \| `"fr"` \| `"hi"` \| `"hu"` \| `"id"` \| `"it"` \| `"ja"` \| `"nl"` \| `"pt"` \| `"tr"` \| `"ru"` \| `"ur"` \| `"zh-CN"` Supported UI/app languages for localization. ## Defined in [src/sdk/models.ts:323](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L323) --- # Type Alias: CDN > **CDN**: `"jspm"` \| `"skypack"` \| `"jsdelivr"` \| `"fastly.jsdelivr"` \| `"gcore.jsdelivr"` \| `"testingcf.jsdelivr"` \| `"jsdelivr.b-cdn"` \| `"jsdelivr.gh"` \| `"fastly.jsdelivr.gh"` \| `"gcore.jsdelivr.gh"` \| `"testingcf.jsdelivr.gh"` \| `"jsdelivr.b-cdn.gh"` \| `"jsdelivr.esm"` \| `"fastly.jsdelivr.esm"` \| `"gcore.jsdelivr.esm"` \| `"testingcf.jsdelivr.esm"` \| `"jsdelivr.b-cdn.esm"` \| `"esm.run"` \| `"esm.sh"` \| `"esbuild"` \| `"bundle.run"` \| `"unpkg"` \| `"npmcdn"` \| `"statically"` CDN providers for external resources. ## Defined in [src/sdk/models.ts:294](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L294) --- # Type Alias: CodejarTheme > **CodejarTheme**: `"a11y-dark"` \| `"atom-dark"` \| `"base16-ateliersulphurpool-light"` \| `"catppuccin-latte"` \| `"catppuccin-frappe"` \| `"catppuccin-macchiato"` \| `"catppuccin-mocha"` \| `"cb"` \| `"coldark-cold"` \| `"coldark-dark"` \| `"coy"` \| `"coy-without-shadows"` \| `"darcula"` \| `"dark"` \| `"dracula"` \| `"duotone-dark"` \| `"duotone-earth"` \| `"duotone-forest"` \| `"duotone-light"` \| `"duotone-sea"` \| `"duotone-space"` \| `"funky"` \| `"ghcolors"` \| `"gruvbox-dark"` \| `"gruvbox-light"` \| `"holi-theme"` \| `"hopscotch"` \| `"laserwave"` \| `"livecodes-dark"` \| `"livecodes-light"` \| `"lucario"` \| `"material-dark"` \| `"material-light"` \| `"material-oceanic"` \| `"monochrome"` \| `"monochrome-dark"` \| `"night-owl"` \| `"nord"` \| `"nord-2"` \| `"okaidia"` \| `"one-dark"` \| `"one-light"` \| `"pojoaque"` \| `"shades-of-purple"` \| `"solarized-dark-atom"` \| `"solarized-light"` \| `"synthwave84"` \| `"tomorrow"` \| `"twilight"` \| `"vs"` \| `"vsc-dark-plus"` \| `"xonokai"` \| `"z-touchs"` Themes for the CodeJar editor. ## Defined in [src/sdk/models.ts:581](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L581) --- # Type Alias: CodemirrorTheme > **CodemirrorTheme**: `"amy"` \| `"aura"` \| `"ayu-light"` \| `"barf"` \| `"basic-light"` \| `"basic-dark"` \| `"bespin"` \| `"birds-of-paradise"` \| `"boys-and-girls"` \| `"catppuccin-latte"` \| `"catppuccin-frappe"` \| `"catppuccin-macchiato"` \| `"catppuccin-mocha"` \| `"clouds"` \| `"cm-light"` \| `"cobalt"` \| `"cool-glow"` \| `"dracula"` \| `"espresso"` \| `"github-dark"` \| `"github-light"` \| `"gruvbox-dark"` \| `"gruvbox-light"` \| `"livecodes-dark"` \| `"livecodes-light"` \| `"material-dark"` \| `"material-light"` \| `"monochrome"` \| `"monochrome-dark"` \| `"noctis-lilac"` \| `"nord"` \| `"one-dark"` \| `"rose-pine-dawn"` \| `"smoothy"` \| `"solarized-light"` \| `"solarized-dark"` \| `"tokyo-night"` \| `"tokyo-night-day"` \| `"tokyo-night-storm"` \| `"tomorrow"` Themes for the CodeMirror editor. ## Defined in [src/sdk/models.ts:536](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L536) --- # Type Alias: CssPresetId > **CssPresetId**: `""` \| `"normalize.css"` \| `"reset-css"` CSS presets. ## Defined in [src/sdk/models.ts:289](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L289) --- # Type Alias: EditorId > **EditorId**: `"markup"` \| `"style"` \| `"script"` The identifier for each code editor pane in the playground. ## Defined in [src/sdk/models.ts:250](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L250) --- # Type Alias: EditorTheme > **EditorTheme**: [`MonacoTheme`](MonacoTheme.md) \| [`CodemirrorTheme`](CodemirrorTheme.md) \| [`CodejarTheme`](CodejarTheme.md) \| \`$\{MonacoTheme\}@$\{Theme\}\` \| \`$\{CodemirrorTheme\}@$\{Theme\}\` \| \`$\{CodejarTheme\}@$\{Theme\}\` \| \`monaco:$\{MonacoTheme\}\` \| \`codemirror:$\{CodemirrorTheme\}\` \| \`codejar:$\{CodejarTheme\}\` \| \`monaco:$\{MonacoTheme\}@$\{Theme\}\` \| \`codemirror:$\{CodemirrorTheme\}@$\{Theme\}\` \| \`codejar:$\{CodejarTheme\}@$\{Theme\}\` Editor theme that can be a Monaco, CodeMirror, or CodeJar theme, optionally with editor prefix and/or a theme suffix (light/dark). See [docs](https://livecodes.io/docs/configuration/configuration-object#editortheme) for details. ## Defined in [src/sdk/models.ts:641](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L641) --- # Type Alias: MonacoTheme > **MonacoTheme**: `"active4d"` \| `"all-hallows-eve"` \| `"amy"` \| `"birds-of-paradise"` \| `"blackboard"` \| `"brilliance-black"` \| `"brilliance-dull"` \| `"catppuccin-latte"` \| `"catppuccin-frappe"` \| `"catppuccin-macchiato"` \| `"catppuccin-mocha"` \| `"chrome-devtools"` \| `"clouds-midnight"` \| `"clouds"` \| `"cobalt"` \| `"cobalt2"` \| `"custom-vs-light"` \| `"custom-vs-dark"` \| `"dawn"` \| `"dracula"` \| `"dreamweaver"` \| `"eiffel"` \| `"espresso-libre"` \| `"github"` \| `"github-dark"` \| `"github-light"` \| `"hc-black"` \| `"hc-light"` \| `"idle"` \| `"idlefingers"` \| `"iplastic"` \| `"katzenmilch"` \| `"krtheme"` \| `"kuroir"` \| `"lazy"` \| `"livecodes-dark"` \| `"livecodes-light"` \| `"magicwb-amiga"` \| `"merbivore-soft"` \| `"merbivore"` \| `"monochrome"` \| `"monochrome-dark"` \| `"monokai"` \| `"monokai-bright"` \| `"monoindustrial"` \| `"night-owl"` \| `"nord"` \| `"oceanic-next"` \| `"pastels-on-dark"` \| `"slush-and-poppies"` \| `"solarized-dark"` \| `"solarized-light"` \| `"spacecadet"` \| `"sunburst"` \| `"textmate-mac-classic"` \| `"tomorrow"` \| `"tomorrow-night"` \| `"tomorrow-night-blue"` \| `"tomorrow-night-bright"` \| `"tomorrow-night-eighties"` \| `"twilight"` \| `"upstream-sunburst"` \| `"vibrant-ink"` \| `"vs"` \| `"vs-dark"` \| `"xcode-default"` \| `"zenburnesque"` Themes for the Monaco editor. ## Defined in [src/sdk/models.ts:464](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L464) --- # Type Alias: Processor > **Processor**: `"postcss"` \| `"postcssImportUrl"` \| `"tailwindcss"` \| `"windicss"` \| `"unocss"` \| `"tokencss"` \| `"lightningcss"` \| `"autoprefixer"` \| `"postcssPresetEnv"` \| `"cssmodules"` \| `"purgecss"` \| `"cssnano"` CSS preprocessors and PostCSS plugins. ## Defined in [src/sdk/models.ts:272](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L272) --- # Type Alias: ScreenName > **ScreenName**: `"login"` \| `"info"` \| `"new"` \| `"open"` \| `"assets"` \| `"add-asset"` \| `"snippets"` \| `"add-snippet"` \| `"import"` \| `"resources"` \| `"share"` \| `"embed"` \| `"deploy"` \| `"sync"` \| `"backup"` \| `"broadcast"` \| `"welcome"` \| `"about"` \| `"custom-settings"` \| `"editor-settings"` \| `"code-to-image"` \| `"test-editor"` \| `"keyboard-shortcuts"` Screen names in the app. ## Defined in [src/sdk/models.ts:436](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L436) --- # Type Alias: TemplateName > **TemplateName**: `"blank"` \| `"javascript"` \| `"typescript"` \| `"react"` \| `"react-native"` \| `"vue2"` \| `"vue"` \| `"angular"` \| `"preact"` \| `"svelte"` \| `"solid"` \| `"lit"` \| `"stencil"` \| `"mdx"` \| `"astro"` \| `"riot"` \| `"malina"` \| `"jquery"` \| `"backbone"` \| `"knockout"` \| `"jest"` \| `"jest-react"` \| `"bootstrap"` \| `"tailwindcss"` \| `"shadcn-ui"` \| `"daisyui"` \| `"d3"` \| `"phaser"` \| `"coffeescript"` \| `"livescript"` \| `"civet"` \| `"clio"` \| `"imba"` \| `"rescript"` \| `"reason"` \| `"ocaml"` \| `"python"` \| `"python-wasm"` \| `"r"` \| `"ruby"` \| `"ruby-wasm"` \| `"go"` \| `"go-wasm"` \| `"php"` \| `"php-wasm"` \| `"cpp"` \| `"cpp-wasm"` \| `"java"` \| `"csharp-wasm"` \| `"perl"` \| `"lua"` \| `"lua-wasm"` \| `"teal"` \| `"fennel"` \| `"julia"` \| `"scheme"` \| `"commonlisp"` \| `"clojurescript"` \| `"gleam"` \| `"tcl"` \| `"markdown"` \| `"assemblyscript"` \| `"wat"` \| `"sql"` \| `"postgresql"` \| `"prolog"` \| `"minizinc"` \| `"blockly"` \| `"diagrams"` Starter template names. ## Defined in [src/sdk/models.ts:347](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L347) --- # Type Alias: Theme > **Theme**: `"light"` \| `"dark"` The app theme mode. ## Defined in [src/sdk/models.ts:267](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L267) --- # Type Alias: ToolName > **ToolName**: `"console"` \| `"compiled"` \| `"tests"` Tools in the tools pane. ## Defined in [src/sdk/models.ts:421](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L421) --- # Type Alias: ToolsPaneStatus > **ToolsPaneStatus**: `"closed"` \| `"open"` \| `"full"` \| `"none"` \| `""` Status of the tools pane. ## Defined in [src/sdk/models.ts:426](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L426) --- # Type Alias: WatchCode() > **WatchCode**: (`event`, `fn`) => `object` Called when the playground code is changed (see [`getCode`](https://livecodes.io/docs/sdk/js-ts#getcode) and [`getConfig`](https://livecodes.io/docs/sdk/js-ts#getcode)). This includes changes in: - Code (in editors) - Editor [languages](https://livecodes.io/docs/languages/) - [CSS processors](https://livecodes.io/docs/features/css#css-processors) - [External resources](https://livecodes.io/docs/features/external-resources) - Project info (e.g. allows adding content in page head and attributes to `` element) - [Custom settings](https://livecodes.io/docs/advanced/custom-settings) (e.g. allows changing [import maps](https://livecodes.io/docs/features/module-resolution#custom-module-resolution)) - Project title - [Test](https://livecodes.io/docs/features/tests) code ## Parameters • **event**: `"code"` • **fn** ## Returns `object` ### remove() > **remove**: () => `void` #### Returns `void` ## Defined in [src/sdk/models.ts:1358](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1358) --- # Type Alias: WatchConsole() > **WatchConsole**: (`event`, `fn`) => `object` Called when console methods are called in the result page. ## Parameters • **event**: `"console"` • **fn** ## Returns `object` ### remove() > **remove**: () => `void` #### Returns `void` ## Defined in [src/sdk/models.ts:1374](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1374) --- # Type Alias: WatchDestroy() > **WatchDestroy**: (`event`, `fn`) => `object` Called when the playground is destroyed. ## Parameters • **event**: `"destroy"` • **fn** ## Returns `object` ### remove() > **remove**: () => `void` #### Returns `void` ## Defined in [src/sdk/models.ts:1390](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1390) --- # Type Alias: WatchLoad() > **WatchLoad**: (`event`, `fn`) => `object` Called when the playground first loads. ## Parameters • **event**: `"load"` • **fn** ## Returns `object` ### remove() > **remove**: () => `void` #### Returns `void` ## Defined in [src/sdk/models.ts:1335](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1335) --- # Type Alias: WatchReady() > **WatchReady**: (`event`, `fn`) => `object` Called when a new project is loaded (including when [imported](https://livecodes.io/docs/features/import)) and the playground is ready to run. ## Parameters • **event**: `"ready"` • **fn** ## Returns `object` ### remove() > **remove**: () => `void` #### Returns `void` ## Defined in [src/sdk/models.ts:1340](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1340) --- # Type Alias: WatchRun() > **WatchRun**: (`event`, `fn`) => `object` Called when running the playground code. ## Parameters • **event**: `"run"` • **fn** ## Returns `object` ### remove() > **remove**: () => `void` #### Returns `void` ## Defined in [src/sdk/models.ts:1366](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1366) --- # Type Alias: WatchTests() > **WatchTests**: (`event`, `fn`) => `object` Called when test results are available. ## Parameters • **event**: `"tests"` • **fn** ## Returns `object` ### remove() > **remove**: () => `void` #### Returns `void` ## Defined in [src/sdk/models.ts:1382](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1382) --- # Interface: Code An object that contains the language, content and compiled code for each of the 3 [code editors](https://livecodes.io/docs/features/projects) and the [result page](https://livecodes.io/docs/features/result) HTML. See [docs](https://livecodes.io/docs/api/interfaces/Code) for details. ## Properties ### markup > **markup**: `object` Markup editor code. #### compiled > **compiled**: `string` The compiled code. #### content > **content**: `string` The source code. #### language > **language**: [`Language`](../type-aliases/Language.md) The language of the code. #### Defined in [src/sdk/models.ts:1290](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1290) *** ### result > **result**: `string` The HTML content of the result page. #### Defined in [src/sdk/models.ts:1317](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1317) *** ### script > **script**: `object` Script editor code. #### compiled > **compiled**: `string` The compiled code. #### content > **content**: `string` The source code. #### language > **language**: [`Language`](../type-aliases/Language.md) The language of the code. #### Defined in [src/sdk/models.ts:1308](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1308) *** ### style > **style**: `object` Style editor code. #### compiled > **compiled**: `string` The compiled code. #### content > **content**: `string` The source code. #### language > **language**: [`Language`](../type-aliases/Language.md) The language of the code. #### Defined in [src/sdk/models.ts:1299](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1299) --- # Interface: Config The playground configuration interface combining content, app, and user settings. ## Extends - [`ContentConfig`](../internal/interfaces/ContentConfig.md).[`AppConfig`](../internal/interfaces/AppConfig.md).[`UserConfig`](../internal/interfaces/UserConfig.md) ## Properties ### activeEditor > **activeEditor**: `undefined` \| [`EditorId`](../internal/type-aliases/EditorId.md) Selects the active editor to show. Defaults to the last used editor for user, otherwise `"markup"` #### Inherited from [`ContentConfig`](../internal/interfaces/ContentConfig.md).[`activeEditor`](../internal/interfaces/ContentConfig.md#activeeditor) #### Defined in [src/sdk/models.ts:1138](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1138) *** ### allowLangChange > **allowLangChange**: `boolean` If `false`, the UI will not show the menu that allows changing editor language. #### Default ```ts true ``` #### Inherited from [`AppConfig`](../internal/interfaces/AppConfig.md).[`allowLangChange`](../internal/interfaces/AppConfig.md#allowlangchange) #### Defined in [src/sdk/models.ts:1044](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1044) *** ### appLanguage > **appLanguage**: `undefined` \| [`AppLanguage`](../internal/type-aliases/AppLanguage.md) Sets the app UI language used. #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`appLanguage`](../internal/interfaces/UserConfig.md#applanguage) #### Defined in [src/sdk/models.ts:1024](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1024) *** ### autosave > **autosave**: `boolean` If `true`, the project is automatically saved on code change, after time [delay](https://livecodes.io/docs/configuration/configuration-object#delay). #### Default ```ts false ``` #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`autosave`](../internal/interfaces/UserConfig.md#autosave) #### Defined in [src/sdk/models.ts:973](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L973) *** ### autotest > **autotest**: `boolean` If `true`, the project is watched for code changes which trigger tests to auto-run. #### Default ```ts false ``` #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`autotest`](../internal/interfaces/UserConfig.md#autotest) #### Defined in [src/sdk/models.ts:979](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L979) *** ### autoupdate > **autoupdate**: `boolean` If `true`, the result page is automatically updated on code change, after time [delay](https://livecodes.io/docs/configuration/configuration-object#delay). #### Default ```ts true ``` #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`autoupdate`](../internal/interfaces/UserConfig.md#autoupdate) #### Defined in [src/sdk/models.ts:966](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L966) *** ### closeBrackets > **closeBrackets**: `boolean` Use auto-complete to close brackets and quotes. #### Default ```ts true ``` #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`closeBrackets`](../internal/interfaces/UserConfig.md#closebrackets) #### Defined in [src/sdk/models.ts:937](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L937) *** ### cssPreset > **cssPreset**: [`CssPresetId`](../internal/type-aliases/CssPresetId.md) [CSS Preset](https://livecodes.io/docs/features/external-resources#css-presets) to use. #### Inherited from [`ContentConfig`](../internal/interfaces/ContentConfig.md).[`cssPreset`](../internal/interfaces/ContentConfig.md#csspreset) #### Defined in [src/sdk/models.ts:1185](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1185) *** ### customSettings > **customSettings**: `object` Defines [custom settings](https://livecodes.io/docs/advanced/custom-settings) for the current project. #### adoc > **adoc**: `any` #### app.svelte > **svelte**: `any` #### app.vue > **vue**: `any` #### art > **art**: `any` #### art-template > **art-template**: `any` #### as > **as**: `any` #### asc > **asc**: `any` #### asciidoc > **asciidoc**: `any` #### assemblyscript > **assemblyscript**: `any` #### astro > **astro**: `any` #### autoprefixer > **autoprefixer**: `any` #### babel > **babel**: `any` #### bb > **bb**: `any` #### bbcode > **bbcode**: `any` #### Binary > **Binary**: `any` #### blockly > **blockly**: `any` #### blockly.xml > **xml**: `any` #### c > **c**: `any` #### C > **C**: `any` #### c++ > **c++**: `any` #### civet > **civet**: `any` #### clang > **clang**: `any` #### clang.cpp > **cpp**: `any` #### clio > **clio**: `any` #### clj > **clj**: `any` #### cljc > **cljc**: `any` #### cljs > **cljs**: `any` #### clojure > **clojure**: `any` #### clojurescript > **clojurescript**: `any` #### coffee > **coffee**: `any` #### coffeescript > **coffeescript**: `any` #### common-lisp > **common-lisp**: `any` #### commonlisp > **commonlisp**: `any` #### convertCommonjs? > `optional` **convertCommonjs**: `boolean` #### cp > **cp**: `any` #### cpp > **cpp**: `any` #### cpp-wasm > **cpp-wasm**: `any` #### cppm > **cppm**: `any` #### cppwasm > **cppwasm**: `any` #### cs > **cs**: `any` #### cs-wasm > **cs-wasm**: `any` #### csharp > **csharp**: `any` #### csharp-wasm > **csharp-wasm**: `any` #### css > **css**: `any` #### cssmodules > **cssmodules**: `any` #### cssnano > **cssnano**: `any` #### cwasm > **cwasm**: `any` #### cxx > **cxx**: `any` #### defaultCDN? > `optional` **defaultCDN**: [`CDN`](../internal/type-aliases/CDN.md) #### diagram > **diagram**: `any` #### diagrams > **diagrams**: `any` #### dot > **dot**: `any` #### dzn > **dzn**: `any` #### edn > **edn**: `any` #### ejs > **ejs**: `any` #### es > **es**: `any` #### eta > **eta**: `any` #### fennel > **fennel**: `any` #### flow > **flow**: `any` #### fnl > **fnl**: `any` #### gleam > **gleam**: `any` #### go > **go**: `any` #### go-wasm > **go-wasm**: `any` #### golang > **golang**: `any` #### gowasm > **gowasm**: `any` #### graph > **graph**: `any` #### h > **h**: `any` #### haml > **haml**: `any` #### handlebars > **handlebars**: `any` #### hbs > **hbs**: `any` #### hpp > **hpp**: `any` #### htm > **htm**: `any` #### html > **html**: `any` #### ii > **ii**: `any` #### imba > **imba**: `any` #### imports? > `optional` **imports**: `Record`\<`string`, `string`\> #### ixx > **ixx**: `any` #### jade > **jade**: `any` #### java > **java**: `any` #### javascript > **javascript**: `any` #### jinja > **jinja**: `any` #### jl > **jl**: `any` #### js > **js**: `any` #### json > **json**: `any` #### jsx > **jsx**: `any` #### julia > **julia**: `any` #### less > **less**: `any` #### lightningcss > **lightningcss**: `any` #### liquid > **liquid**: `any` #### liquidjs > **liquidjs**: `any` #### lisp > **lisp**: `any` #### livescript > **livescript**: `any` #### ls > **ls**: `any` #### lua > **lua**: `any` #### lua-wasm > **lua-wasm**: `any` #### luawasm > **luawasm**: `any` #### malina > **malina**: `any` #### malinajs > **malinajs**: `any` #### mapImports? > `optional` **mapImports**: `boolean` #### markdown > **markdown**: `any` #### md > **md**: `any` #### mdown > **mdown**: `any` #### mdx > **mdx**: `any` #### minizinc > **minizinc**: `any` #### mjml > **mjml**: `any` #### mjs > **mjs**: `any` #### mkdn > **mkdn**: `any` #### ml > **ml**: `any` #### mli > **mli**: `any` #### mts > **mts**: `any` #### mustache > **mustache**: `any` #### mzn > **mzn**: `any` #### njk > **njk**: `any` #### nunjucks > **nunjucks**: `any` #### ocaml > **ocaml**: `any` #### perl > **perl**: `any` #### pg > **pg**: `any` #### pg.sql > **sql**: `any` #### pglite > **pglite**: `any` #### pglite.sql > **sql**: `any` #### pgsql > **pgsql**: `any` #### pgsql.sql > **sql**: `any` #### php > **php**: `any` #### php-wasm > **php-wasm**: `any` #### phpwasm > **phpwasm**: `any` #### pintora > **pintora**: `any` #### pl > **pl**: `any` #### plt > **plt**: `any` #### pm > **pm**: `any` #### postcss > **postcss**: `any` #### postcssImportUrl > **postcssImportUrl**: `any` #### postcssPresetEnv > **postcssPresetEnv**: `any` #### postgre.sql > **sql**: `any` #### postgres > **postgres**: `any` #### postgresql > **postgresql**: `any` #### postgresql.sql > **sql**: `any` #### prolog > **prolog**: `any` #### prolog.pl > **pl**: `any` #### pug > **pug**: `any` #### purgecss > **purgecss**: `any` #### py > **py**: `any` #### py-wasm > **py-wasm**: `any` #### py3 > **py3**: `any` #### pyodide > **pyodide**: `any` #### python > **python**: `any` #### python-wasm > **python-wasm**: `any` #### pythonwasm > **pythonwasm**: `any` #### pywasm > **pywasm**: `any` #### r > **r**: `any` #### r-wasm > **r-wasm**: `any` #### rb > **rb**: `any` #### re > **re**: `any` #### react > **react**: `any` #### react-jsx > **react-jsx**: `any` #### react-native > **react-native**: `any` #### react-native-tsx > **react-native-tsx**: `any` #### react-native.jsx > **jsx**: `any` #### react-native.tsx > **tsx**: `any` #### react-tsx > **react-tsx**: `any` #### react.jsx > **jsx**: `any` #### react.tsx > **tsx**: `any` #### reason > **reason**: `any` #### rei > **rei**: `any` #### res > **res**: `any` #### rescript > **rescript**: `any` #### resi > **resi**: `any` #### rich > **rich**: `any` #### richtext > **richtext**: `any` #### riot > **riot**: `any` #### riotjs > **riotjs**: `any` #### ripple > **ripple**: `any` #### ripplejs > **ripplejs**: `any` #### rlang > **rlang**: `any` #### rstats > **rstats**: `any` #### rte > **rte**: `any` #### rte.html > **html**: `any` #### ruby > **ruby**: `any` #### ruby-wasm > **ruby-wasm**: `any` #### rubywasm > **rubywasm**: `any` #### sass > **sass**: `any` #### scheme > **scheme**: `any` #### scm > **scm**: `any` #### scriptType? > `optional` **scriptType**: `""` \| `"module"` \| `"application/javascript"` \| `"application/ecmascript"` \| `"text/javascript"` \| `"text/ecmascript"` \| `"text/liquid"` \| `"text/python"` \| `"text/r"` \| `"text/ruby-wasm"` \| `"text/x-uniter-php"` \| `"text/php-wasm"` \| `"text/cpp"` \| `"text/java"` \| `"text/csharp-wasm"` \| `"text/perl"` \| `"text/julia"` \| `"text/biwascheme"` \| `"text/commonlisp"` \| `"text/tcl"` \| `"text/prolog"` \| `"text/minizinc"` \| `"text/go-wasm"` \| `"application/json"` \| `"application/lua"` \| `"text/fennel"` \| `"application/wasm-uint8"` #### scss > **scss**: `any` #### solid > **solid**: `any` #### solid.jsx > **jsx**: `any` #### solid.tsx > **tsx**: `any` #### sql > **sql**: `any` #### sqlite > **sqlite**: `any` #### sqlite3 > **sqlite3**: `any` #### stencil > **stencil**: `any` #### stencil.tsx > **tsx**: `any` #### styl > **styl**: `any` #### stylis > **stylis**: `any` #### stylus > **stylus**: `any` #### sucrase > **sucrase**: `any` #### svelte > **svelte**: `any` #### svelte-app > **svelte-app**: `any` #### swift > **swift**: `any` #### tailwindcss > **tailwindcss**: `any` #### tcl > **tcl**: `any` #### teal > **teal**: `any` #### template? > `optional` **template**: `object` #### template.data? > `optional` **data**: `any` #### template.prerender? > `optional` **prerender**: `boolean` #### tl > **tl**: `any` #### tokencss > **tokencss**: `any` #### ts > **ts**: `any` #### tsx > **tsx**: `any` #### twig > **twig**: `any` #### types? > `optional` **types**: [`Types`](../internal/interfaces/Types.md) #### typescript > **typescript**: `any` #### unocss > **unocss**: `any` #### vento > **vento**: `any` #### vto > **vto**: `any` #### vue > **vue**: `any` #### vue-app > **vue-app**: `any` #### vue2 > **vue2**: `any` #### vue3 > **vue3**: `any` #### wasm > **wasm**: `any` #### wasm.cpp > **cpp**: `any` #### wasm.cs > **cs**: `any` #### wasm.go > **go**: `any` #### wasm.lua > **lua**: `any` #### wasm.php > **php**: `any` #### wasm.py > **py**: `any` #### wasm.rb > **rb**: `any` #### wast > **wast**: `any` #### wat > **wat**: `any` #### webassembly > **webassembly**: `any` #### windicss > **windicss**: `any` #### xht > **xht**: `any` #### xml > **xml**: `any` #### Inherited from [`ContentConfig`](../internal/interfaces/ContentConfig.md).[`customSettings`](../internal/interfaces/ContentConfig.md#customsettings) #### Defined in [src/sdk/models.ts:1197](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1197) *** ### delay > **delay**: `number` Time delay (in milliseconds) following code change, after which the result page is updated (if [`autoupdate`](https://livecodes.io/docs/configuration/configuration-object#autoupdate) is `true`) and/or the project is saved (if [`autosave`](https://livecodes.io/docs/configuration/configuration-object#autosave) is `true`). #### Default ```ts 1500 ``` #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`delay`](../internal/interfaces/UserConfig.md#delay) #### Defined in [src/sdk/models.ts:987](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L987) *** ### description > **description**: `string` Project description. Used in [project](https://livecodes.io/docs/features/projects) search and [result page](https://livecodes.io/docs/features/result) description meta tag. #### Default ```ts "" ``` #### Inherited from [`ContentConfig`](../internal/interfaces/ContentConfig.md).[`description`](../internal/interfaces/ContentConfig.md#description) #### Defined in [src/sdk/models.ts:1108](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1108) *** ### disableHomeLink > **disableHomeLink**: `boolean` If `true`, the link on LiveCodes logo ("Edit on LiveCodes") is disabled in [embeds](https://livecodes.io/docs/features/embeds). #### Default ```ts false ``` #### Inherited from [`AppConfig`](../internal/interfaces/AppConfig.md).[`disableHomeLink`](../internal/interfaces/AppConfig.md#disablehomelink) #### Defined in [src/sdk/models.ts:1088](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1088) *** ### editor > **editor**: `undefined` \| `"auto"` \| `"monaco"` \| `"codemirror"` \| `"codejar"` Selects the [code editor](https://livecodes.io/docs/features/editor-settings#code-editor) to use. If `undefined` (the default), Monaco editor is used on desktop, CodeMirror is used on mobile and in `simple` mode, while CodeJar is used in `codeblock` mode, in `lite` mode and in `readonly` playgrounds. If set to `auto`, Monaco editor is used on desktop and CodeMirror is used on mobile regardless of other settings. #### Default ```ts undefined ``` #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`editor`](../internal/interfaces/UserConfig.md#editor) #### Defined in [src/sdk/models.ts:858](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L858) *** ### editorMode > **editorMode**: `undefined` \| `"vim"` \| `"emacs"` Sets [editor mode](https://livecodes.io/docs/features/editor-settings#editor-modes). #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`editorMode`](../internal/interfaces/UserConfig.md#editormode) #### Defined in [src/sdk/models.ts:954](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L954) *** ### editorTheme > **editorTheme**: `undefined` \| `string` \| [`EditorTheme`](../internal/type-aliases/EditorTheme.md)[] Sets the [code editor](https://livecodes.io/docs/features/editor-settings) themes. See docs for [editor themes](https://livecodes.io/docs/configuration/configuration-object#editortheme) for details. #### Examples ```ts "vs" ``` ```ts "monaco:twilight, codemirror:one-dark" ``` ```ts ["vs@light"] ``` ```ts ["vs@light", "vs-dark@dark"] ``` ```ts ["monaco:vs@light", "codemirror:github-light@light", "dracula@dark"] ``` #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`editorTheme`](../internal/interfaces/UserConfig.md#editortheme) #### Defined in [src/sdk/models.ts:884](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L884) *** ### emmet > **emmet**: `boolean` Enables [Emmet](https://livecodes.io/docs/features/editor-settings#emmet). #### Default ```ts true ``` #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`emmet`](../internal/interfaces/UserConfig.md#emmet) #### Defined in [src/sdk/models.ts:949](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L949) *** ### foldRegions > **foldRegions**: `boolean` When set to `true`, regions marked by `#region` and `#endregion` comments are folded when the project is loaded. #### Default ```ts false ``` #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`foldRegions`](../internal/interfaces/UserConfig.md#foldregions) #### Defined in [src/sdk/models.ts:931](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L931) *** ### fontFamily > **fontFamily**: `undefined` \| `string` Sets the [code editor](https://livecodes.io/docs/features/editor-settings) font family. #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`fontFamily`](../internal/interfaces/UserConfig.md#fontfamily) #### Defined in [src/sdk/models.ts:889](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L889) *** ### fontSize > **fontSize**: `undefined` \| `number` Sets the font size. If `undefined` (the default), the font size is set to 14 for the full app and 12 for [embeds](https://livecodes.io/docs/features/embeds). #### Default ```ts undefined ``` #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`fontSize`](../internal/interfaces/UserConfig.md#fontsize) #### Defined in [src/sdk/models.ts:897](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L897) *** ### formatOnsave > **formatOnsave**: `boolean` If `true`, the code is automatically [formatted](https://livecodes.io/docs/features/code-format) on saving the project. #### Default ```ts false ``` #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`formatOnsave`](../internal/interfaces/UserConfig.md#formatonsave) #### Defined in [src/sdk/models.ts:993](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L993) *** ### head > **head**: `string` Content added to the [result page](https://livecodes.io/docs/features/result) `` element. #### Default ```ts '\n' ``` #### Inherited from [`ContentConfig`](../internal/interfaces/ContentConfig.md).[`head`](../internal/interfaces/ContentConfig.md#head) #### Defined in [src/sdk/models.ts:1114](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1114) *** ### htmlAttrs > **htmlAttrs**: `string` \| `Record`\<`string`, `string`\> Attributes added to the [result page](https://livecodes.io/docs/features/result) `` element. It can be an object or a string. #### Example ```ts { lang: "en", class: "dark" } 'lang="en" class="dark"' ``` #### Inherited from [`ContentConfig`](../internal/interfaces/ContentConfig.md).[`htmlAttrs`](../internal/interfaces/ContentConfig.md#htmlattrs) #### Defined in [src/sdk/models.ts:1123](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1123) *** ### imports > **imports**: `object` Allows specifying custom [import maps](https://github.com/WICG/import-maps) for [module imports](https://livecodes.io/docs/features/module-resolution#custom-module-resolution). **Example** Setting `imports` like this: ```js "imports": { "moment": "https://cdn.jsdelivr.net/npm/moment@2.29.4/dist/moment.js" } ``` results in the following import map: ```html ``` See docs for [Imports](https://livecodes.io/docs/configuration/configuration-object#imports) and [Custom Module Resolution](https://livecodes.io/docs/features/module-resolution/#custom-module-resolution) #### Index Signature \[`key`: `string`\]: `string` #### Inherited from [`ContentConfig`](../internal/interfaces/ContentConfig.md).[`imports`](../internal/interfaces/ContentConfig.md#imports-1) #### Defined in [src/sdk/models.ts:1223](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1223) *** ### languages > **languages**: `undefined` \| (`"html"` \| `"htm"` \| `"markdown"` \| `"md"` \| `"mdown"` \| `"mkdn"` \| `"mdx"` \| `"astro"` \| `"pug"` \| `"jade"` \| `"haml"` \| `"asciidoc"` \| `"adoc"` \| `"asc"` \| `"mustache"` \| `"handlebars"` \| `"hbs"` \| `"ejs"` \| `"eta"` \| `"nunjucks"` \| `"njk"` \| `"liquid"` \| `"liquidjs"` \| `"dot"` \| `"twig"` \| `"vento"` \| `"vto"` \| `"art-template"` \| `"art"` \| `"jinja"` \| `"bbcode"` \| `"bb"` \| `"mjml"` \| `"diagrams"` \| `"diagram"` \| `"graph"` \| `"plt"` \| `"richtext"` \| `"rte"` \| `"rich"` \| `"rte.html"` \| `"css"` \| `"scss"` \| `"sass"` \| `"less"` \| `"stylus"` \| `"styl"` \| `"stylis"` \| `"postcss"` \| `"javascript"` \| `"js"` \| `"mjs"` \| `"json"` \| `"babel"` \| `"es"` \| `"sucrase"` \| `"typescript"` \| `"flow"` \| `"ts"` \| `"mts"` \| `"jsx"` \| `"tsx"` \| `"react"` \| `"react-jsx"` \| `"react.jsx"` \| `"react-tsx"` \| `"react.tsx"` \| `"react-native"` \| `"react-native.jsx"` \| `"react-native-tsx"` \| `"react-native.tsx"` \| `"vue"` \| `"vue3"` \| `"vue2"` \| `"vue-app"` \| `"app.vue"` \| `"svelte"` \| `"svelte-app"` \| `"app.svelte"` \| `"stencil"` \| `"stencil.tsx"` \| `"solid"` \| `"solid.jsx"` \| `"solid.tsx"` \| `"riot"` \| `"riotjs"` \| `"malina"` \| `"malinajs"` \| `"ripple"` \| `"ripplejs"` \| `"xht"` \| `"coffeescript"` \| `"coffee"` \| `"livescript"` \| `"ls"` \| `"civet"` \| `"clio"` \| `"imba"` \| `"assemblyscript"` \| `"as"` \| `"python"` \| `"py"` \| `"pyodide"` \| `"python-wasm"` \| `"py-wasm"` \| `"pythonwasm"` \| `"pywasm"` \| `"py3"` \| `"wasm.py"` \| `"r"` \| `"rlang"` \| `"rstats"` \| `"r-wasm"` \| `"ruby"` \| `"rb"` \| `"ruby-wasm"` \| `"wasm.rb"` \| `"rubywasm"` \| `"go"` \| `"golang"` \| `"go-wasm"` \| `"wasm.go"` \| `"gowasm"` \| `"php"` \| `"php-wasm"` \| `"phpwasm"` \| `"wasm.php"` \| `"cpp"` \| `"c"` \| `"C"` \| `"cp"` \| `"cxx"` \| `"c++"` \| `"cppm"` \| `"ixx"` \| `"ii"` \| `"hpp"` \| `"h"` \| `"cpp-wasm"` \| `"cppwasm"` \| `"cwasm"` \| `"wasm.cpp"` \| `"clang"` \| `"clang.cpp"` \| `"java"` \| `"csharp"` \| `"csharp-wasm"` \| `"cs"` \| `"cs-wasm"` \| `"wasm.cs"` \| `"perl"` \| `"pl"` \| `"pm"` \| `"lua"` \| `"lua-wasm"` \| `"luawasm"` \| `"wasm.lua"` \| `"teal"` \| `"tl"` \| `"fennel"` \| `"fnl"` \| `"julia"` \| `"jl"` \| `"scheme"` \| `"scm"` \| `"commonlisp"` \| `"common-lisp"` \| `"lisp"` \| `"clojurescript"` \| `"clojure"` \| `"cljs"` \| `"clj"` \| `"cljc"` \| `"edn"` \| `"gleam"` \| `"swift"` \| `"rescript"` \| `"res"` \| `"resi"` \| `"reason"` \| `"re"` \| `"rei"` \| `"ocaml"` \| `"ml"` \| `"mli"` \| `"tcl"` \| `"wat"` \| `"wast"` \| `"webassembly"` \| `"wasm"` \| `"Binary"` \| `"sql"` \| `"sqlite"` \| `"sqlite3"` \| `"pg.sql"` \| `"pgsql.sql"` \| `"pgsql"` \| `"pg"` \| `"pglite"` \| `"pglite.sql"` \| `"postgresql"` \| `"postgres"` \| `"postgre.sql"` \| `"postgresql.sql"` \| `"prolog.pl"` \| `"prolog"` \| `"minizinc"` \| `"mzn"` \| `"dzn"` \| `"blockly"` \| `"blockly.xml"` \| `"xml"` \| `"pintora"` \| `"postcssImportUrl"` \| `"tailwindcss"` \| `"windicss"` \| `"unocss"` \| `"tokencss"` \| `"lightningcss"` \| `"autoprefixer"` \| `"postcssPresetEnv"` \| `"cssmodules"` \| `"purgecss"` \| `"cssnano"`)[] List of enabled languages. Defaults to all supported languages in full app and only current editor languages in [embeds](https://livecodes.io/docs/features/embeds). #### Inherited from [`ContentConfig`](../internal/interfaces/ContentConfig.md).[`languages`](../internal/interfaces/ContentConfig.md#languages) #### Defined in [src/sdk/models.ts:1145](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1145) *** ### layout > **layout**: `undefined` \| `"responsive"` \| `"horizontal"` \| `"vertical"` Sets the app layout to horizontal or vertical. If set to `"responsive"` (the default) or `undefined`, the layout is vertical in small screens when the playground height is larger than its width, otherwise horizontal. #### Default ```ts "responsive" ``` #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`layout`](../internal/interfaces/UserConfig.md#layout) #### Defined in [src/sdk/models.ts:1002](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1002) *** ### lineNumbers > **lineNumbers**: `boolean` \| `"relative"` Show line numbers in [code editor](https://livecodes.io/docs/features/editor-settings). #### Default ```ts true ``` #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`lineNumbers`](../internal/interfaces/UserConfig.md#linenumbers) #### Defined in [src/sdk/models.ts:919](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L919) *** ### markup > **markup**: `object` An object that configures the language and content of the markup editor. See [docs](https://livecodes.io/docs/configuration/configuration-object/#markup) for details. #### content? > `optional` **content**: `string` The initial content of the code editor. ##### Default ```ts "" ``` #### contentUrl? > `optional` **contentUrl**: `string` A URL to load `content` from. It has to be a valid URL that is CORS-enabled. The URL is only fetched if `content` property had no value. #### foldedLines? > `optional` **foldedLines**: `object`[] Lines that get folded when the editor loads. This can be used for less relevant content. ##### Example ```ts [{ from: 5, to: 8 }, { from: 15, to: 20 }] ``` #### hiddenContent? > `optional` **hiddenContent**: `string` Hidden content that gets evaluated without being visible in the code editor. This can be useful in embedded playgrounds (e.g. for adding helper functions, utilities or tests) #### hiddenContentUrl? > `optional` **hiddenContentUrl**: `string` A URL to load `hiddenContent` from. It has to be a valid URL that is CORS-enabled. The URL is only fetched if `hiddenContent` property had no value. #### hideTitle? > `optional` **hideTitle**: `boolean` If `true`, the title of the code editor is hidden, however its code is still evaluated. This can be useful in embedded playgrounds (e.g. for hiding unnecessary code). #### language > **language**: [`Language`](../type-aliases/Language.md) A language name, extension or alias (as defined in [language documentations](https://livecodes.io/docs/languages/)). For the list of supported values, see [Language](https://livecodes.io/docs/api/type-aliases/Language) #### order? > `optional` **order**: `number` The order of the editor in the UI. ##### Default ```ts 0 ``` #### position? > `optional` **position**: [`EditorPosition`](../internal/interfaces/EditorPosition.md) The initial position of the cursor in the code editor. ##### Example ```ts {lineNumber: 5, column: 10} ``` #### selector? > `optional` **selector**: `string` A CSS selector to load content from [DOM import](https://livecodes.io/docs/features/import#import-code-from-dom). #### title? > `optional` **title**: `string` If set, this is used as the title of the editor in the UI, overriding the default title set to the language name (e.g. `"Python"` can be used instead of `"Py (Wasm)"`). #### Default ```ts { language: "html", content: "" } ``` #### Inherited from [`ContentConfig`](../internal/interfaces/ContentConfig.md).[`markup`](../internal/interfaces/ContentConfig.md#markup) #### Defined in [src/sdk/models.ts:1153](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1153) *** ### minimap > **minimap**: `boolean` Enables minimap in code editor. #### Default ```ts false ``` #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`minimap`](../internal/interfaces/UserConfig.md#minimap) #### Defined in [src/sdk/models.ts:943](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L943) *** ### mode > **mode**: `"editor"` \| `"result"` \| `"full"` \| `"focus"` \| `"lite"` \| `"simple"` \| `"codeblock"` Sets the [display mode](https://livecodes.io/docs/features/display-modes). #### Default ```ts "full" ``` #### Inherited from [`AppConfig`](../internal/interfaces/AppConfig.md).[`mode`](../internal/interfaces/AppConfig.md#mode) #### Defined in [src/sdk/models.ts:1056](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1056) *** ### processors > **processors**: [`Processor`](../internal/type-aliases/Processor.md)[] List of enabled [CSS processors](https://livecodes.io/docs/features/css/#css-processors). For the list of available processors, see [Processor](https://livecodes.io/docs/api/internal/type-aliases/Processor) #### Inherited from [`ContentConfig`](../internal/interfaces/ContentConfig.md).[`processors`](../internal/interfaces/ContentConfig.md#processors) #### Defined in [src/sdk/models.ts:1192](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1192) *** ### readonly > **readonly**: `boolean` If `true`, editors are loaded in read-only mode, where the user is not allowed to change the code. By default, when readonly is set to true, the light-weight code editor [CodeJar](https://livecodes.io/docs/features/editor-settings#code-editor) is used. If you wish to use another editor, set the [editor](https://livecodes.io/docs/configuration/configuration-object#editor) property. #### Default ```ts false ``` #### Inherited from [`AppConfig`](../internal/interfaces/AppConfig.md).[`readonly`](../internal/interfaces/AppConfig.md#readonly) #### Defined in [src/sdk/models.ts:1038](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1038) *** ### recoverUnsaved > **recoverUnsaved**: `boolean` Enables [recovering last unsaved project](https://livecodes.io/docs/features/recover) when the app is reopened. #### Default ```ts true ``` #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`recoverUnsaved`](../internal/interfaces/UserConfig.md#recoverunsaved) #### Defined in [src/sdk/models.ts:1008](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1008) *** ### script > **script**: `object` An object that configures the language and content of the script editor. See [docs](https://livecodes.io/docs/configuration/configuration-object/#markup) for details. #### content? > `optional` **content**: `string` The initial content of the code editor. ##### Default ```ts "" ``` #### contentUrl? > `optional` **contentUrl**: `string` A URL to load `content` from. It has to be a valid URL that is CORS-enabled. The URL is only fetched if `content` property had no value. #### foldedLines? > `optional` **foldedLines**: `object`[] Lines that get folded when the editor loads. This can be used for less relevant content. ##### Example ```ts [{ from: 5, to: 8 }, { from: 15, to: 20 }] ``` #### hiddenContent? > `optional` **hiddenContent**: `string` Hidden content that gets evaluated without being visible in the code editor. This can be useful in embedded playgrounds (e.g. for adding helper functions, utilities or tests) #### hiddenContentUrl? > `optional` **hiddenContentUrl**: `string` A URL to load `hiddenContent` from. It has to be a valid URL that is CORS-enabled. The URL is only fetched if `hiddenContent` property had no value. #### hideTitle? > `optional` **hideTitle**: `boolean` If `true`, the title of the code editor is hidden, however its code is still evaluated. This can be useful in embedded playgrounds (e.g. for hiding unnecessary code). #### language > **language**: [`Language`](../type-aliases/Language.md) A language name, extension or alias (as defined in [language documentations](https://livecodes.io/docs/languages/)). For the list of supported values, see [Language](https://livecodes.io/docs/api/type-aliases/Language) #### order? > `optional` **order**: `number` The order of the editor in the UI. ##### Default ```ts 0 ``` #### position? > `optional` **position**: [`EditorPosition`](../internal/interfaces/EditorPosition.md) The initial position of the cursor in the code editor. ##### Example ```ts {lineNumber: 5, column: 10} ``` #### selector? > `optional` **selector**: `string` A CSS selector to load content from [DOM import](https://livecodes.io/docs/features/import#import-code-from-dom). #### title? > `optional` **title**: `string` If set, this is used as the title of the editor in the UI, overriding the default title set to the language name (e.g. `"Python"` can be used instead of `"Py (Wasm)"`). #### Default ```ts { language: "javascript", content: "" } ``` #### Inherited from [`ContentConfig`](../internal/interfaces/ContentConfig.md).[`script`](../internal/interfaces/ContentConfig.md#script) #### Defined in [src/sdk/models.ts:1169](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1169) *** ### scripts > **scripts**: `string`[] List of URLs for [external scripts](https://livecodes.io/docs/features/external-resources) to add to the [result page](https://livecodes.io/docs/features/result). #### Inherited from [`ContentConfig`](../internal/interfaces/ContentConfig.md).[`scripts`](../internal/interfaces/ContentConfig.md#scripts) #### Defined in [src/sdk/models.ts:1179](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1179) *** ### semicolons > **semicolons**: `boolean` Configures Prettier [code formatter](https://livecodes.io/docs/features/code-format) to use semi-colons. #### Default ```ts true ``` #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`semicolons`](../internal/interfaces/UserConfig.md#semicolons) #### Defined in [src/sdk/models.ts:829](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L829) *** ### showSpacing > **showSpacing**: `boolean` Enables [showing element spacing](https://livecodes.io/docs/features/result#show-spacings) in the result page. #### Default ```ts false ``` #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`showSpacing`](../internal/interfaces/UserConfig.md#showspacing) #### Defined in [src/sdk/models.ts:1014](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1014) *** ### singleQuote > **singleQuote**: `boolean` Configures Prettier [code formatter](https://livecodes.io/docs/features/code-format) to use single quotes instead of double quotes. #### Default ```ts false ``` #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`singleQuote`](../internal/interfaces/UserConfig.md#singlequote) #### Defined in [src/sdk/models.ts:834](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L834) *** ### style > **style**: `object` An object that configures the language and content of the style editor. See [docs](https://livecodes.io/docs/configuration/configuration-object/#markup) for details. #### content? > `optional` **content**: `string` The initial content of the code editor. ##### Default ```ts "" ``` #### contentUrl? > `optional` **contentUrl**: `string` A URL to load `content` from. It has to be a valid URL that is CORS-enabled. The URL is only fetched if `content` property had no value. #### foldedLines? > `optional` **foldedLines**: `object`[] Lines that get folded when the editor loads. This can be used for less relevant content. ##### Example ```ts [{ from: 5, to: 8 }, { from: 15, to: 20 }] ``` #### hiddenContent? > `optional` **hiddenContent**: `string` Hidden content that gets evaluated without being visible in the code editor. This can be useful in embedded playgrounds (e.g. for adding helper functions, utilities or tests) #### hiddenContentUrl? > `optional` **hiddenContentUrl**: `string` A URL to load `hiddenContent` from. It has to be a valid URL that is CORS-enabled. The URL is only fetched if `hiddenContent` property had no value. #### hideTitle? > `optional` **hideTitle**: `boolean` If `true`, the title of the code editor is hidden, however its code is still evaluated. This can be useful in embedded playgrounds (e.g. for hiding unnecessary code). #### language > **language**: [`Language`](../type-aliases/Language.md) A language name, extension or alias (as defined in [language documentations](https://livecodes.io/docs/languages/)). For the list of supported values, see [Language](https://livecodes.io/docs/api/type-aliases/Language) #### order? > `optional` **order**: `number` The order of the editor in the UI. ##### Default ```ts 0 ``` #### position? > `optional` **position**: [`EditorPosition`](../internal/interfaces/EditorPosition.md) The initial position of the cursor in the code editor. ##### Example ```ts {lineNumber: 5, column: 10} ``` #### selector? > `optional` **selector**: `string` A CSS selector to load content from [DOM import](https://livecodes.io/docs/features/import#import-code-from-dom). #### title? > `optional` **title**: `string` If set, this is used as the title of the editor in the UI, overriding the default title set to the language name (e.g. `"Python"` can be used instead of `"Py (Wasm)"`). #### Default ```ts { language: "css", content: "" } ``` #### Inherited from [`ContentConfig`](../internal/interfaces/ContentConfig.md).[`style`](../internal/interfaces/ContentConfig.md#style) #### Defined in [src/sdk/models.ts:1161](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1161) *** ### stylesheets > **stylesheets**: `string`[] List of URLs for [external stylesheets](https://livecodes.io/docs/features/external-resources) to add to the [result page](https://livecodes.io/docs/features/result). #### Inherited from [`ContentConfig`](../internal/interfaces/ContentConfig.md).[`stylesheets`](../internal/interfaces/ContentConfig.md#stylesheets) #### Defined in [src/sdk/models.ts:1174](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1174) *** ### tabSize > **tabSize**: `number` The number of spaces per indentation-level. Also used in [code formatting](https://livecodes.io/docs/features/code-format). #### Default ```ts 2 ``` #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`tabSize`](../internal/interfaces/UserConfig.md#tabsize) #### Defined in [src/sdk/models.ts:913](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L913) *** ### tags > **tags**: `string`[] Project tags. Used in [project](https://livecodes.io/docs/features/projects) filter and search. #### Default ```ts [] ``` #### Inherited from [`ContentConfig`](../internal/interfaces/ContentConfig.md).[`tags`](../internal/interfaces/ContentConfig.md#tags) #### Defined in [src/sdk/models.ts:1130](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1130) *** ### tests > **tests**: `undefined` \| `object` Configures the [language](https://livecodes.io/docs/features/tests#supported-languages) and content of [tests](https://livecodes.io/docs/features/tests). #### Inherited from [`ContentConfig`](../internal/interfaces/ContentConfig.md).[`tests`](../internal/interfaces/ContentConfig.md#tests) #### Defined in [src/sdk/models.ts:1259](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1259) *** ### theme > **theme**: [`Theme`](../internal/type-aliases/Theme.md) Sets the app [theme](https://livecodes.io/docs/features/themes) to light/dark mode. #### Default ```ts "dark" ``` #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`theme`](../internal/interfaces/UserConfig.md#theme) #### Defined in [src/sdk/models.ts:864](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L864) *** ### themeColor > **themeColor**: `undefined` \| `string` Sets the app theme color. If `undefined`, it is set to `"hsl(214, 40%, 50%)"`. #### Default ```ts undefined ``` #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`themeColor`](../internal/interfaces/UserConfig.md#themecolor) #### Defined in [src/sdk/models.ts:871](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L871) *** ### title > **title**: `string` Project title. This is used as [result page](https://livecodes.io/docs/features/result) title and title meta tag. Also used in project search. #### Default ```ts "Untitled Project" ``` #### Inherited from [`ContentConfig`](../internal/interfaces/ContentConfig.md).[`title`](../internal/interfaces/ContentConfig.md#title-3) #### Defined in [src/sdk/models.ts:1101](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1101) *** ### tools > **tools**: `Partial`\<`object`\> Sets enabled and active tools and status of [tools pane](https://livecodes.io/docs/features/tools-pane). #### Type declaration ##### active > **active**: `""` \| [`ToolName`](../internal/type-aliases/ToolName.md) ##### enabled > **enabled**: ([`ToolName`](../internal/type-aliases/ToolName.md) \| `"zoom"`)[] \| `"all"` ##### status > **status**: [`ToolsPaneStatus`](../internal/type-aliases/ToolsPaneStatus.md) #### Default ```ts { enabled: "all", active: "", status: "" } ``` #### Example ```js { "tools": { "enabled": ["console", "compiled"], "active": "console", "status": "open" } } ``` #### Inherited from [`AppConfig`](../internal/interfaces/AppConfig.md).[`tools`](../internal/interfaces/AppConfig.md#tools) #### Defined in [src/sdk/models.ts:1072](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1072) *** ### trailingComma > **trailingComma**: `boolean` Configures Prettier [code formatter](https://livecodes.io/docs/features/code-format) to use [trailing commas](https://prettier.io/docs/en/options.html#trailing-commas). #### Default ```ts true ``` #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`trailingComma`](../internal/interfaces/UserConfig.md#trailingcomma) #### Defined in [src/sdk/models.ts:840](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L840) *** ### types > **types**: `object` Allows providing custom TypeScript type declarations for better [editor intellisense](https://livecodes.io/docs/features/intellisense). It is an object where each key represents module name and value represents the types. See docs for [Types](https://livecodes.io/docs/configuration/configuration-object#types) and [Custom Types](https://livecodes.io/docs/features/intellisense#custom-types) #### Examples ```js { "types": { "my-demo-lib": "https://my-custom-domain/my-type-declarations.d.ts" } } ``` ``` { "types": { "my-demo-lib": { "url": "https://my-custom-domain/types.d.ts", "autoload": true, "declareAsModule": true } } ``` #### Inherited from [`ContentConfig`](../internal/interfaces/ContentConfig.md).[`types`](../internal/interfaces/ContentConfig.md#types-1) #### Defined in [src/sdk/models.ts:1253](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1253) *** ### useTabs > **useTabs**: `boolean` If `true`, lines are indented with tabs instead of spaces. Also used in [code formatting](https://livecodes.io/docs/features/code-format). #### Default ```ts false ``` #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`useTabs`](../internal/interfaces/UserConfig.md#usetabs) #### Defined in [src/sdk/models.ts:905](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L905) *** ### version > `readonly` **version**: `string` This is a read-only property which specifies the current LiveCodes version. Version specified in [exported](https://livecodes.io/docs/features/export) projects allows automatically upgrading the project configuration when imported by an app with a newer version. #### Inherited from [`ContentConfig`](../internal/interfaces/ContentConfig.md).[`version`](../internal/interfaces/ContentConfig.md#version) #### Defined in [src/sdk/models.ts:1266](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1266) *** ### view? > `optional` **view**: `"split"` \| `"editor"` \| `"result"` Sets the [default view](https://livecodes.io/docs/features/default-view) for the playground. #### Default ```ts "split" ``` #### Inherited from [`AppConfig`](../internal/interfaces/AppConfig.md).[`view`](../internal/interfaces/AppConfig.md#view) #### Defined in [src/sdk/models.ts:1050](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1050) *** ### welcome > **welcome**: `boolean` If `true`, the [welcome screen](https://livecodes.io/docs/features/welcome) is displayed when the app loads. #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`welcome`](../internal/interfaces/UserConfig.md#welcome) #### Defined in [src/sdk/models.ts:1019](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1019) *** ### wordWrap > **wordWrap**: `boolean` Enables word-wrap for long lines. #### Default ```ts false ``` #### Inherited from [`UserConfig`](../internal/interfaces/UserConfig.md).[`wordWrap`](../internal/interfaces/UserConfig.md#wordwrap) #### Defined in [src/sdk/models.ts:925](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L925) *** ### zoom > **zoom**: `0.25` \| `0.5` \| `1` Sets result page [zoom level](https://livecodes.io/docs/features/result#result-page-zoom). #### Inherited from [`AppConfig`](../internal/interfaces/AppConfig.md).[`zoom`](../internal/interfaces/AppConfig.md#zoom) #### Defined in [src/sdk/models.ts:1081](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1081) --- # Interface: EmbedOptions An object that represents the playground embed options. See [docs](https://livecodes.io/docs/sdk/js-ts/#embed-options) for details. ## Properties ### appUrl? > `optional` **appUrl**: `string` Allows loading the playground from a custom URL (e.g. a [self-hosted app](https://livecodes.io/docs/features/self-hosting) or a [permanent URL](https://livecodes.io/docs/features/permanent-url)). If supplied with an invalid URL, an error is thrown. #### Default ```ts 'https://livecodes.io' ``` #### Defined in [src/sdk/models.ts:1716](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1716) *** ### config? > `optional` **config**: `string` \| `Partial`\<[`Config`](Config.md)\> A [configuration object](https://livecodes.io/docs/configuration/configuration-object) or a URL to a JSON file representing a configuration object to load. If supplied and is not an object or a valid URL, an error is thrown. #### Default ```ts {} ``` #### Defined in [src/sdk/models.ts:1748](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1748) *** ### headless? > `optional` **headless**: `boolean` If `true`, the playground is loaded in [headless mode](https://livecodes.io/docs/sdk/headless). #### Default ```ts false ``` #### Defined in [src/sdk/models.ts:1754](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1754) *** ### import? > `optional` **import**: `string` A resource to [import](https://livecodes.io/docs/features/import) (from any of the supported [sources](https://livecodes.io/docs/features/import#sources)). #### Defined in [src/sdk/models.ts:1759](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1759) *** ### ~~lite?~~ > `optional` **lite**: `boolean` If `true`, the playground is loaded in [lite mode](https://livecodes.io/docs/features/lite). #### Deprecated Use `{ config: { mode: "lite" } }` instead #### Default ```ts false ``` #### Defined in [src/sdk/models.ts:1770](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1770) *** ### loading? > `optional` **loading**: `"lazy"` \| `"click"` \| `"eager"` Sets how the playground loads: - `"eager"`: The playground loads immediately. - `"lazy"`: A playground embedded low down in the page will not load until the user scrolls so that it approaches the viewport. - `"click"`: The playground does not load automatically. Instead, a "Click-to-load" screen is shown. #### Default ```ts "lazy" ``` #### Defined in [src/sdk/models.ts:1780](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1780) *** ### params? > `optional` **params**: `object` An object that represents the [URL Query parameters](https://livecodes.io/docs/configuration/query-params), that can be used to configure the playground. These 2 snippets produce similar output: ```js import { createPlayground } from 'livecodes'; // use config createPlayground('#container', { config: { markup: { language: 'markdown', content: '# Hello World!', }, }, }); // use params createPlayground('#container', { params: { md: '# Hello World!' } }); ``` #### active? > `optional` **active**: `0` \| [`EditorId`](../internal/type-aliases/EditorId.md) \| `1` \| `2` #### activeEditor? > `optional` **activeEditor**: `0` \| [`EditorId`](../internal/type-aliases/EditorId.md) \| `1` \| `2` #### adoc > **adoc**: `undefined` \| `string` #### adoc-selector > **adoc-selector**: `undefined` \| `string` #### allowLangChange? > `optional` **allowLangChange**: `boolean` If `false`, the UI will not show the menu that allows changing editor language. ##### Default ```ts true ``` #### app.svelte > **svelte**: `undefined` \| `string` #### app.svelte-selector > **svelte-selector**: `undefined` \| `string` #### app.vue > **vue**: `undefined` \| `string` #### app.vue-selector > **vue-selector**: `undefined` \| `string` #### appLanguage? > `optional` **appLanguage**: [`AppLanguage`](../internal/type-aliases/AppLanguage.md) Sets the app UI language used. #### appUrl? > `optional` **appUrl**: `string` Allows loading the playground from a custom URL (e.g. a [self-hosted app](https://livecodes.io/docs/features/self-hosting) or a [permanent URL](https://livecodes.io/docs/features/permanent-url)). If supplied with an invalid URL, an error is thrown. ##### Default ```ts 'https://livecodes.io' ``` #### art > **art**: `undefined` \| `string` #### art-selector > **art-selector**: `undefined` \| `string` #### art-template > **art-template**: `undefined` \| `string` #### art-template-selector > **art-template-selector**: `undefined` \| `string` #### as > **as**: `undefined` \| `string` #### as-selector > **as-selector**: `undefined` \| `string` #### asc > **asc**: `undefined` \| `string` #### asc-selector > **asc-selector**: `undefined` \| `string` #### asciidoc > **asciidoc**: `undefined` \| `string` #### asciidoc-selector > **asciidoc-selector**: `undefined` \| `string` #### assemblyscript > **assemblyscript**: `undefined` \| `string` #### assemblyscript-selector > **assemblyscript-selector**: `undefined` \| `string` #### astro > **astro**: `undefined` \| `string` #### astro-selector > **astro-selector**: `undefined` \| `string` #### autosave? > `optional` **autosave**: `boolean` If `true`, the project is automatically saved on code change, after time [delay](https://livecodes.io/docs/configuration/configuration-object#delay). ##### Default ```ts false ``` #### autotest? > `optional` **autotest**: `boolean` If `true`, the project is watched for code changes which trigger tests to auto-run. ##### Default ```ts false ``` #### autoupdate? > `optional` **autoupdate**: `boolean` If `true`, the result page is automatically updated on code change, after time [delay](https://livecodes.io/docs/configuration/configuration-object#delay). ##### Default ```ts true ``` #### babel > **babel**: `undefined` \| `string` #### babel-selector > **babel-selector**: `undefined` \| `string` #### bb > **bb**: `undefined` \| `string` #### bb-selector > **bb-selector**: `undefined` \| `string` #### bbcode > **bbcode**: `undefined` \| `string` #### bbcode-selector > **bbcode-selector**: `undefined` \| `string` #### Binary > **Binary**: `undefined` \| `string` #### Binary-selector > **Binary-selector**: `undefined` \| `string` #### blockly > **blockly**: `undefined` \| `string` #### blockly-selector > **blockly-selector**: `undefined` \| `string` #### blockly.xml > **xml**: `undefined` \| `string` #### blockly.xml-selector > **xml-selector**: `undefined` \| `string` #### c > **c**: `undefined` \| `string` #### C > **C**: `undefined` \| `string` #### c-selector > **c-selector**: `undefined` \| `string` #### C-selector > **C-selector**: `undefined` \| `string` #### c++ > **c++**: `undefined` \| `string` #### c++-selector > **c++-selector**: `undefined` \| `string` #### civet > **civet**: `undefined` \| `string` #### civet-selector > **civet-selector**: `undefined` \| `string` #### clang > **clang**: `undefined` \| `string` #### clang-selector > **clang-selector**: `undefined` \| `string` #### clang.cpp > **cpp**: `undefined` \| `string` #### clang.cpp-selector > **cpp-selector**: `undefined` \| `string` #### clio > **clio**: `undefined` \| `string` #### clio-selector > **clio-selector**: `undefined` \| `string` #### clj > **clj**: `undefined` \| `string` #### clj-selector > **clj-selector**: `undefined` \| `string` #### cljc > **cljc**: `undefined` \| `string` #### cljc-selector > **cljc-selector**: `undefined` \| `string` #### cljs > **cljs**: `undefined` \| `string` #### cljs-selector > **cljs-selector**: `undefined` \| `string` #### clojure > **clojure**: `undefined` \| `string` #### clojure-selector > **clojure-selector**: `undefined` \| `string` #### clojurescript > **clojurescript**: `undefined` \| `string` #### clojurescript-selector > **clojurescript-selector**: `undefined` \| `string` #### closeBrackets? > `optional` **closeBrackets**: `boolean` Use auto-complete to close brackets and quotes. ##### Default ```ts true ``` #### coffee > **coffee**: `undefined` \| `string` #### coffee-selector > **coffee-selector**: `undefined` \| `string` #### coffeescript > **coffeescript**: `undefined` \| `string` #### coffeescript-selector > **coffeescript-selector**: `undefined` \| `string` #### common-lisp > **common-lisp**: `undefined` \| `string` #### common-lisp-selector > **common-lisp-selector**: `undefined` \| `string` #### commonlisp > **commonlisp**: `undefined` \| `string` #### commonlisp-selector > **commonlisp-selector**: `undefined` \| `string` #### compiled > **compiled**: `undefined` \| `""` \| `"full"` \| `"closed"` \| `"open"` \| `"none"` \| `"true"` #### config? > `optional` **config**: `string` \| `Partial`\<[`Config`](Config.md)\> & `string` A [configuration object](https://livecodes.io/docs/configuration/configuration-object) or a URL to a JSON file representing a configuration object to load. If supplied and is not an object or a valid URL, an error is thrown. ##### Default ```ts {} ``` #### console > **console**: `undefined` \| `""` \| `"full"` \| `"closed"` \| `"open"` \| `"none"` \| `"true"` #### cp > **cp**: `undefined` \| `string` #### cp-selector > **cp-selector**: `undefined` \| `string` #### cpp > **cpp**: `undefined` \| `string` #### cpp-selector > **cpp-selector**: `undefined` \| `string` #### cpp-wasm > **cpp-wasm**: `undefined` \| `string` #### cpp-wasm-selector > **cpp-wasm-selector**: `undefined` \| `string` #### cppm > **cppm**: `undefined` \| `string` #### cppm-selector > **cppm-selector**: `undefined` \| `string` #### cppwasm > **cppwasm**: `undefined` \| `string` #### cppwasm-selector > **cppwasm-selector**: `undefined` \| `string` #### cs > **cs**: `undefined` \| `string` #### cs-selector > **cs-selector**: `undefined` \| `string` #### cs-wasm > **cs-wasm**: `undefined` \| `string` #### cs-wasm-selector > **cs-wasm-selector**: `undefined` \| `string` #### csharp > **csharp**: `undefined` \| `string` #### csharp-selector > **csharp-selector**: `undefined` \| `string` #### csharp-wasm > **csharp-wasm**: `undefined` \| `string` #### csharp-wasm-selector > **csharp-wasm-selector**: `undefined` \| `string` #### css > **css**: `undefined` \| `string` #### css-selector > **css-selector**: `undefined` \| `string` #### cssPreset? > `optional` **cssPreset**: [`CssPresetId`](../internal/type-aliases/CssPresetId.md) [CSS Preset](https://livecodes.io/docs/features/external-resources#css-presets) to use. #### customSettings? > `optional` **customSettings**: `object` Defines [custom settings](https://livecodes.io/docs/advanced/custom-settings) for the current project. #### customSettings.adoc > **adoc**: `any` #### customSettings.app.svelte > **svelte**: `any` #### customSettings.app.vue > **vue**: `any` #### customSettings.art > **art**: `any` #### customSettings.art-template > **art-template**: `any` #### customSettings.as > **as**: `any` #### customSettings.asc > **asc**: `any` #### customSettings.asciidoc > **asciidoc**: `any` #### customSettings.assemblyscript > **assemblyscript**: `any` #### customSettings.astro > **astro**: `any` #### customSettings.autoprefixer > **autoprefixer**: `any` #### customSettings.babel > **babel**: `any` #### customSettings.bb > **bb**: `any` #### customSettings.bbcode > **bbcode**: `any` #### customSettings.Binary > **Binary**: `any` #### customSettings.blockly > **blockly**: `any` #### customSettings.blockly.xml > **xml**: `any` #### customSettings.c > **c**: `any` #### customSettings.C > **C**: `any` #### customSettings.c++ > **c++**: `any` #### customSettings.civet > **civet**: `any` #### customSettings.clang > **clang**: `any` #### customSettings.clang.cpp > **cpp**: `any` #### customSettings.clio > **clio**: `any` #### customSettings.clj > **clj**: `any` #### customSettings.cljc > **cljc**: `any` #### customSettings.cljs > **cljs**: `any` #### customSettings.clojure > **clojure**: `any` #### customSettings.clojurescript > **clojurescript**: `any` #### customSettings.coffee > **coffee**: `any` #### customSettings.coffeescript > **coffeescript**: `any` #### customSettings.common-lisp > **common-lisp**: `any` #### customSettings.commonlisp > **commonlisp**: `any` #### customSettings.convertCommonjs? > `optional` **convertCommonjs**: `boolean` #### customSettings.cp > **cp**: `any` #### customSettings.cpp > **cpp**: `any` #### customSettings.cpp-wasm > **cpp-wasm**: `any` #### customSettings.cppm > **cppm**: `any` #### customSettings.cppwasm > **cppwasm**: `any` #### customSettings.cs > **cs**: `any` #### customSettings.cs-wasm > **cs-wasm**: `any` #### customSettings.csharp > **csharp**: `any` #### customSettings.csharp-wasm > **csharp-wasm**: `any` #### customSettings.css > **css**: `any` #### customSettings.cssmodules > **cssmodules**: `any` #### customSettings.cssnano > **cssnano**: `any` #### customSettings.cwasm > **cwasm**: `any` #### customSettings.cxx > **cxx**: `any` #### customSettings.defaultCDN? > `optional` **defaultCDN**: [`CDN`](../internal/type-aliases/CDN.md) #### customSettings.diagram > **diagram**: `any` #### customSettings.diagrams > **diagrams**: `any` #### customSettings.dot > **dot**: `any` #### customSettings.dzn > **dzn**: `any` #### customSettings.edn > **edn**: `any` #### customSettings.ejs > **ejs**: `any` #### customSettings.es > **es**: `any` #### customSettings.eta > **eta**: `any` #### customSettings.fennel > **fennel**: `any` #### customSettings.flow > **flow**: `any` #### customSettings.fnl > **fnl**: `any` #### customSettings.gleam > **gleam**: `any` #### customSettings.go > **go**: `any` #### customSettings.go-wasm > **go-wasm**: `any` #### customSettings.golang > **golang**: `any` #### customSettings.gowasm > **gowasm**: `any` #### customSettings.graph > **graph**: `any` #### customSettings.h > **h**: `any` #### customSettings.haml > **haml**: `any` #### customSettings.handlebars > **handlebars**: `any` #### customSettings.hbs > **hbs**: `any` #### customSettings.hpp > **hpp**: `any` #### customSettings.htm > **htm**: `any` #### customSettings.html > **html**: `any` #### customSettings.ii > **ii**: `any` #### customSettings.imba > **imba**: `any` #### customSettings.imports? > `optional` **imports**: `Record`\<`string`, `string`\> #### customSettings.ixx > **ixx**: `any` #### customSettings.jade > **jade**: `any` #### customSettings.java > **java**: `any` #### customSettings.javascript > **javascript**: `any` #### customSettings.jinja > **jinja**: `any` #### customSettings.jl > **jl**: `any` #### customSettings.js > **js**: `any` #### customSettings.json > **json**: `any` #### customSettings.jsx > **jsx**: `any` #### customSettings.julia > **julia**: `any` #### customSettings.less > **less**: `any` #### customSettings.lightningcss > **lightningcss**: `any` #### customSettings.liquid > **liquid**: `any` #### customSettings.liquidjs > **liquidjs**: `any` #### customSettings.lisp > **lisp**: `any` #### customSettings.livescript > **livescript**: `any` #### customSettings.ls > **ls**: `any` #### customSettings.lua > **lua**: `any` #### customSettings.lua-wasm > **lua-wasm**: `any` #### customSettings.luawasm > **luawasm**: `any` #### customSettings.malina > **malina**: `any` #### customSettings.malinajs > **malinajs**: `any` #### customSettings.mapImports? > `optional` **mapImports**: `boolean` #### customSettings.markdown > **markdown**: `any` #### customSettings.md > **md**: `any` #### customSettings.mdown > **mdown**: `any` #### customSettings.html.md) > **mdx**: `any` #### customSettings.minizinc > **minizinc**: `any` #### customSettings.mjml > **mjml**: `any` #### customSettings.mjs > **mjs**: `any` #### customSettings.mkdn > **mkdn**: `any` #### customSettings.ml > **ml**: `any` #### customSettings.mli > **mli**: `any` #### customSettings.mts > **mts**: `any` #### customSettings.mustache > **mustache**: `any` #### customSettings.mzn > **mzn**: `any` #### customSettings.njk > **njk**: `any` #### customSettings.nunjucks > **nunjucks**: `any` #### customSettings.ocaml > **ocaml**: `any` #### customSettings.perl > **perl**: `any` #### customSettings.pg > **pg**: `any` #### customSettings.pg.sql > **sql**: `any` #### customSettings.pglite > **pglite**: `any` #### customSettings.pglite.sql > **sql**: `any` #### customSettings.pgsql > **pgsql**: `any` #### customSettings.pgsql.sql > **sql**: `any` #### customSettings.php > **php**: `any` #### customSettings.php-wasm > **php-wasm**: `any` #### customSettings.phpwasm > **phpwasm**: `any` #### customSettings.pintora > **pintora**: `any` #### customSettings.pl > **pl**: `any` #### customSettings.plt > **plt**: `any` #### customSettings.pm > **pm**: `any` #### customSettings.postcss > **postcss**: `any` #### customSettings.postcssImportUrl > **postcssImportUrl**: `any` #### customSettings.postcssPresetEnv > **postcssPresetEnv**: `any` #### customSettings.postgre.sql > **sql**: `any` #### customSettings.postgres > **postgres**: `any` #### customSettings.postgresql > **postgresql**: `any` #### customSettings.postgresql.sql > **sql**: `any` #### customSettings.prolog > **prolog**: `any` #### customSettings.prolog.pl > **pl**: `any` #### customSettings.pug > **pug**: `any` #### customSettings.purgecss > **purgecss**: `any` #### customSettings.py > **py**: `any` #### customSettings.py-wasm > **py-wasm**: `any` #### customSettings.py3 > **py3**: `any` #### customSettings.pyodide > **pyodide**: `any` #### customSettings.python > **python**: `any` #### customSettings.python-wasm > **python-wasm**: `any` #### customSettings.pythonwasm > **pythonwasm**: `any` #### customSettings.pywasm > **pywasm**: `any` #### customSettings.r > **r**: `any` #### customSettings.r-wasm > **r-wasm**: `any` #### customSettings.rb > **rb**: `any` #### customSettings.re > **re**: `any` #### customSettings.react > **react**: `any` #### customSettings.react-jsx > **react-jsx**: `any` #### customSettings.react-native > **react-native**: `any` #### customSettings.react-native-tsx > **react-native-tsx**: `any` #### customSettings.react-native.jsx > **jsx**: `any` #### customSettings.react-native.tsx > **tsx**: `any` #### customSettings.react-tsx > **react-tsx**: `any` #### customSettings.react.jsx > **jsx**: `any` #### customSettings.react.tsx > **tsx**: `any` #### customSettings.reason > **reason**: `any` #### customSettings.rei > **rei**: `any` #### customSettings.res > **res**: `any` #### customSettings.rescript > **rescript**: `any` #### customSettings.resi > **resi**: `any` #### customSettings.rich > **rich**: `any` #### customSettings.richtext > **richtext**: `any` #### customSettings.riot > **riot**: `any` #### customSettings.riotjs > **riotjs**: `any` #### customSettings.ripple > **ripple**: `any` #### customSettings.ripplejs > **ripplejs**: `any` #### customSettings.rlang > **rlang**: `any` #### customSettings.rstats > **rstats**: `any` #### customSettings.rte > **rte**: `any` #### customSettings.rte.html > **html**: `any` #### customSettings.ruby > **ruby**: `any` #### customSettings.ruby-wasm > **ruby-wasm**: `any` #### customSettings.rubywasm > **rubywasm**: `any` #### customSettings.sass > **sass**: `any` #### customSettings.scheme > **scheme**: `any` #### customSettings.scm > **scm**: `any` #### customSettings.scriptType? > `optional` **scriptType**: `""` \| `"module"` \| `"application/javascript"` \| `"application/ecmascript"` \| `"text/javascript"` \| `"text/ecmascript"` \| `"text/liquid"` \| `"text/python"` \| `"text/r"` \| `"text/ruby-wasm"` \| `"text/x-uniter-php"` \| `"text/php-wasm"` \| `"text/cpp"` \| `"text/java"` \| `"text/csharp-wasm"` \| `"text/perl"` \| `"text/julia"` \| `"text/biwascheme"` \| `"text/commonlisp"` \| `"text/tcl"` \| `"text/prolog"` \| `"text/minizinc"` \| `"text/go-wasm"` \| `"application/json"` \| `"application/lua"` \| `"text/fennel"` \| `"application/wasm-uint8"` #### customSettings.scss > **scss**: `any` #### customSettings.solid > **solid**: `any` #### customSettings.solid.jsx > **jsx**: `any` #### customSettings.solid.tsx > **tsx**: `any` #### customSettings.sql > **sql**: `any` #### customSettings.sqlite > **sqlite**: `any` #### customSettings.sqlite3 > **sqlite3**: `any` #### customSettings.stencil > **stencil**: `any` #### customSettings.stencil.tsx > **tsx**: `any` #### customSettings.styl > **styl**: `any` #### customSettings.stylis > **stylis**: `any` #### customSettings.stylus > **stylus**: `any` #### customSettings.sucrase > **sucrase**: `any` #### customSettings.svelte > **svelte**: `any` #### customSettings.svelte-app > **svelte-app**: `any` #### customSettings.swift > **swift**: `any` #### customSettings.tailwindcss > **tailwindcss**: `any` #### customSettings.tcl > **tcl**: `any` #### customSettings.teal > **teal**: `any` #### customSettings.template? > `optional` **template**: `object` #### customSettings.template.data? > `optional` **data**: `any` #### customSettings.template.prerender? > `optional` **prerender**: `boolean` #### customSettings.tl > **tl**: `any` #### customSettings.tokencss > **tokencss**: `any` #### customSettings.ts > **ts**: `any` #### customSettings.tsx > **tsx**: `any` #### customSettings.twig > **twig**: `any` #### customSettings.types? > `optional` **types**: [`Types`](../internal/interfaces/Types.md) #### customSettings.typescript > **typescript**: `any` #### customSettings.unocss > **unocss**: `any` #### customSettings.vento > **vento**: `any` #### customSettings.vto > **vto**: `any` #### customSettings.vue > **vue**: `any` #### customSettings.vue-app > **vue-app**: `any` #### customSettings.vue2 > **vue2**: `any` #### customSettings.vue3 > **vue3**: `any` #### customSettings.wasm > **wasm**: `any` #### customSettings.wasm.cpp > **cpp**: `any` #### customSettings.wasm.cs > **cs**: `any` #### customSettings.wasm.go > **go**: `any` #### customSettings.wasm.lua > **lua**: `any` #### customSettings.wasm.php > **php**: `any` #### customSettings.wasm.py > **py**: `any` #### customSettings.wasm.rb > **rb**: `any` #### customSettings.wast > **wast**: `any` #### customSettings.wat > **wat**: `any` #### customSettings.webassembly > **webassembly**: `any` #### customSettings.windicss > **windicss**: `any` #### customSettings.xht > **xht**: `any` #### customSettings.xml > **xml**: `any` #### cwasm > **cwasm**: `undefined` \| `string` #### cwasm-selector > **cwasm-selector**: `undefined` \| `string` #### cxx > **cxx**: `undefined` \| `string` #### cxx-selector > **cxx-selector**: `undefined` \| `string` #### delay? > `optional` **delay**: `number` Time delay (in milliseconds) following code change, after which the result page is updated (if [`autoupdate`](https://livecodes.io/docs/configuration/configuration-object#autoupdate) is `true`) and/or the project is saved (if [`autosave`](https://livecodes.io/docs/configuration/configuration-object#autosave) is `true`). ##### Default ```ts 1500 ``` #### description? > `optional` **description**: `string` Project description. Used in [project](https://livecodes.io/docs/features/projects) search and [result page](https://livecodes.io/docs/features/result) description meta tag. ##### Default ```ts "" ``` #### diagram > **diagram**: `undefined` \| `string` #### diagram-selector > **diagram-selector**: `undefined` \| `string` #### diagrams > **diagrams**: `undefined` \| `string` #### diagrams-selector > **diagrams-selector**: `undefined` \| `string` #### disableAI? > `optional` **disableAI**: `boolean` #### disableHomeLink? > `optional` **disableHomeLink**: `boolean` If `true`, the link on LiveCodes logo ("Edit on LiveCodes") is disabled in [embeds](https://livecodes.io/docs/features/embeds). ##### Default ```ts false ``` #### dot > **dot**: `undefined` \| `string` #### dot-selector > **dot-selector**: `undefined` \| `string` #### dzn > **dzn**: `undefined` \| `string` #### dzn-selector > **dzn-selector**: `undefined` \| `string` #### editor? > `optional` **editor**: `"auto"` \| `"monaco"` \| `"codemirror"` \| `"codejar"` Selects the [code editor](https://livecodes.io/docs/features/editor-settings#code-editor) to use. If `undefined` (the default), Monaco editor is used on desktop, CodeMirror is used on mobile and in `simple` mode, while CodeJar is used in `codeblock` mode, in `lite` mode and in `readonly` playgrounds. If set to `auto`, Monaco editor is used on desktop and CodeMirror is used on mobile regardless of other settings. ##### Default ```ts undefined ``` #### editorMode? > `optional` **editorMode**: `"vim"` \| `"emacs"` Sets [editor mode](https://livecodes.io/docs/features/editor-settings#editor-modes). #### editorTheme? > `optional` **editorTheme**: `string` \| [`EditorTheme`](../internal/type-aliases/EditorTheme.md)[] Sets the [code editor](https://livecodes.io/docs/features/editor-settings) themes. See docs for [editor themes](https://livecodes.io/docs/configuration/configuration-object#editortheme) for details. ##### Examples ```ts "vs" ``` ```ts "monaco:twilight, codemirror:one-dark" ``` ```ts ["vs@light"] ``` ```ts ["vs@light", "vs-dark@dark"] ``` ```ts ["monaco:vs@light", "codemirror:github-light@light", "dracula@dark"] ``` #### edn > **edn**: `undefined` \| `string` #### edn-selector > **edn-selector**: `undefined` \| `string` #### ejs > **ejs**: `undefined` \| `string` #### ejs-selector > **ejs-selector**: `undefined` \| `string` #### embed? > `optional` **embed**: `boolean` #### emmet? > `optional` **emmet**: `boolean` Enables [Emmet](https://livecodes.io/docs/features/editor-settings#emmet). ##### Default ```ts true ``` #### es > **es**: `undefined` \| `string` #### es-selector > **es-selector**: `undefined` \| `string` #### eta > **eta**: `undefined` \| `string` #### eta-selector > **eta-selector**: `undefined` \| `string` #### fennel > **fennel**: `undefined` \| `string` #### fennel-selector > **fennel-selector**: `undefined` \| `string` #### files? > `optional` **files**: `string` #### flow > **flow**: `undefined` \| `string` #### flow-selector > **flow-selector**: `undefined` \| `string` #### fnl > **fnl**: `undefined` \| `string` #### fnl-selector > **fnl-selector**: `undefined` \| `string` #### foldRegions? > `optional` **foldRegions**: `boolean` When set to `true`, regions marked by `#region` and `#endregion` comments are folded when the project is loaded. ##### Default ```ts false ``` #### fontFamily? > `optional` **fontFamily**: `string` Sets the [code editor](https://livecodes.io/docs/features/editor-settings) font family. #### fontSize? > `optional` **fontSize**: `number` Sets the font size. If `undefined` (the default), the font size is set to 14 for the full app and 12 for [embeds](https://livecodes.io/docs/features/embeds). ##### Default ```ts undefined ``` #### formatOnsave? > `optional` **formatOnsave**: `boolean` If `true`, the code is automatically [formatted](https://livecodes.io/docs/features/code-format) on saving the project. ##### Default ```ts false ``` #### gleam > **gleam**: `undefined` \| `string` #### gleam-selector > **gleam-selector**: `undefined` \| `string` #### go > **go**: `undefined` \| `string` #### go-selector > **go-selector**: `undefined` \| `string` #### go-wasm > **go-wasm**: `undefined` \| `string` #### go-wasm-selector > **go-wasm-selector**: `undefined` \| `string` #### golang > **golang**: `undefined` \| `string` #### golang-selector > **golang-selector**: `undefined` \| `string` #### gowasm > **gowasm**: `undefined` \| `string` #### gowasm-selector > **gowasm-selector**: `undefined` \| `string` #### graph > **graph**: `undefined` \| `string` #### graph-selector > **graph-selector**: `undefined` \| `string` #### h > **h**: `undefined` \| `string` #### h-selector > **h-selector**: `undefined` \| `string` #### haml > **haml**: `undefined` \| `string` #### haml-selector > **haml-selector**: `undefined` \| `string` #### handlebars > **handlebars**: `undefined` \| `string` #### handlebars-selector > **handlebars-selector**: `undefined` \| `string` #### hbs > **hbs**: `undefined` \| `string` #### hbs-selector > **hbs-selector**: `undefined` \| `string` #### head? > `optional` **head**: `string` Content added to the [result page](https://livecodes.io/docs/features/result) `` element. ##### Default ```ts '\n' ``` #### headless? > `optional` **headless**: `boolean` If `true`, the playground is loaded in [headless mode](https://livecodes.io/docs/sdk/headless). ##### Default ```ts false ``` #### hpp > **hpp**: `undefined` \| `string` #### hpp-selector > **hpp-selector**: `undefined` \| `string` #### htm > **htm**: `undefined` \| `string` #### htm-selector > **htm-selector**: `undefined` \| `string` #### html > **html**: `undefined` \| `string` #### html-selector > **html-selector**: `undefined` \| `string` #### htmlAttrs? > `optional` **htmlAttrs**: `string` \| `Record`\<`string`, `string`\> Attributes added to the [result page](https://livecodes.io/docs/features/result) `` element. It can be an object or a string. ##### Example ```ts { lang: "en", class: "dark" } 'lang="en" class="dark"' ``` #### ii > **ii**: `undefined` \| `string` #### ii-selector > **ii-selector**: `undefined` \| `string` #### imba > **imba**: `undefined` \| `string` #### imba-selector > **imba-selector**: `undefined` \| `string` #### import? > `optional` **import**: `string` A resource to [import](https://livecodes.io/docs/features/import) (from any of the supported [sources](https://livecodes.io/docs/features/import#sources)). #### imports? > `optional` **imports**: `object` Allows specifying custom [import maps](https://github.com/WICG/import-maps) for [module imports](https://livecodes.io/docs/features/module-resolution#custom-module-resolution). **Example** Setting `imports` like this: ```js "imports": { "moment": "https://cdn.jsdelivr.net/npm/moment@2.29.4/dist/moment.js" } ``` results in the following import map: ```html ``` See docs for [Imports](https://livecodes.io/docs/configuration/configuration-object#imports) and [Custom Module Resolution](https://livecodes.io/docs/features/module-resolution/#custom-module-resolution) ##### Index Signature \[`key`: `string`\]: `string` #### ixx > **ixx**: `undefined` \| `string` #### ixx-selector > **ixx-selector**: `undefined` \| `string` #### jade > **jade**: `undefined` \| `string` #### jade-selector > **jade-selector**: `undefined` \| `string` #### java > **java**: `undefined` \| `string` #### java-selector > **java-selector**: `undefined` \| `string` #### javascript > **javascript**: `undefined` \| `string` #### javascript-selector > **javascript-selector**: `undefined` \| `string` #### jinja > **jinja**: `undefined` \| `string` #### jinja-selector > **jinja-selector**: `undefined` \| `string` #### jl > **jl**: `undefined` \| `string` #### jl-selector > **jl-selector**: `undefined` \| `string` #### js > **js**: `undefined` \| `string` #### js-selector > **js-selector**: `undefined` \| `string` #### json > **json**: `undefined` \| `string` #### json-selector > **json-selector**: `undefined` \| `string` #### jsx > **jsx**: `undefined` \| `string` #### jsx-selector > **jsx-selector**: `undefined` \| `string` #### julia > **julia**: `undefined` \| `string` #### julia-selector > **julia-selector**: `undefined` \| `string` #### lang? > `optional` **lang**: [`Language`](../type-aliases/Language.md) #### language? > `optional` **language**: [`Language`](../type-aliases/Language.md) #### languages? > `optional` **languages**: `string` #### layout? > `optional` **layout**: `"responsive"` \| `"horizontal"` \| `"vertical"` Sets the app layout to horizontal or vertical. If set to `"responsive"` (the default) or `undefined`, the layout is vertical in small screens when the playground height is larger than its width, otherwise horizontal. ##### Default ```ts "responsive" ``` #### less > **less**: `undefined` \| `string` #### less-selector > **less-selector**: `undefined` \| `string` #### lineNumbers? > `optional` **lineNumbers**: `boolean` \| `"relative"` Show line numbers in [code editor](https://livecodes.io/docs/features/editor-settings). ##### Default ```ts true ``` #### liquid > **liquid**: `undefined` \| `string` #### liquid-selector > **liquid-selector**: `undefined` \| `string` #### liquidjs > **liquidjs**: `undefined` \| `string` #### liquidjs-selector > **liquidjs-selector**: `undefined` \| `string` #### lisp > **lisp**: `undefined` \| `string` #### lisp-selector > **lisp-selector**: `undefined` \| `string` #### ~~lite?~~ > `optional` **lite**: `boolean` If `true`, the playground is loaded in [lite mode](https://livecodes.io/docs/features/lite). ##### Deprecated Use `{ config: { mode: "lite" } }` instead ##### Default ```ts false ``` #### livescript > **livescript**: `undefined` \| `string` #### livescript-selector > **livescript-selector**: `undefined` \| `string` #### loading? > `optional` **loading**: `"lazy"` \| `"click"` \| `"eager"` Sets how the playground loads: - `"eager"`: The playground loads immediately. - `"lazy"`: A playground embedded low down in the page will not load until the user scrolls so that it approaches the viewport. - `"click"`: The playground does not load automatically. Instead, a "Click-to-load" screen is shown. ##### Default ```ts "lazy" ``` #### ls > **ls**: `undefined` \| `string` #### ls-selector > **ls-selector**: `undefined` \| `string` #### lua > **lua**: `undefined` \| `string` #### lua-selector > **lua-selector**: `undefined` \| `string` #### lua-wasm > **lua-wasm**: `undefined` \| `string` #### lua-wasm-selector > **lua-wasm-selector**: `undefined` \| `string` #### luawasm > **luawasm**: `undefined` \| `string` #### luawasm-selector > **luawasm-selector**: `undefined` \| `string` #### malina > **malina**: `undefined` \| `string` #### malina-selector > **malina-selector**: `undefined` \| `string` #### malinajs > **malinajs**: `undefined` \| `string` #### malinajs-selector > **malinajs-selector**: `undefined` \| `string` #### markdown > **markdown**: `undefined` \| `string` #### markdown-selector > **markdown-selector**: `undefined` \| `string` #### markup? > `optional` **markup**: `object` An object that configures the language and content of the markup editor. See [docs](https://livecodes.io/docs/configuration/configuration-object/#markup) for details. ##### Default ```ts { language: "html", content: "" } ``` #### markup.content? > `optional` **content**: `string` The initial content of the code editor. ##### Default ```ts "" ``` #### markup.contentUrl? > `optional` **contentUrl**: `string` A URL to load `content` from. It has to be a valid URL that is CORS-enabled. The URL is only fetched if `content` property had no value. #### markup.foldedLines? > `optional` **foldedLines**: `object`[] Lines that get folded when the editor loads. This can be used for less relevant content. ##### Example ```ts [{ from: 5, to: 8 }, { from: 15, to: 20 }] ``` #### markup.hiddenContent? > `optional` **hiddenContent**: `string` Hidden content that gets evaluated without being visible in the code editor. This can be useful in embedded playgrounds (e.g. for adding helper functions, utilities or tests) #### markup.hiddenContentUrl? > `optional` **hiddenContentUrl**: `string` A URL to load `hiddenContent` from. It has to be a valid URL that is CORS-enabled. The URL is only fetched if `hiddenContent` property had no value. #### markup.hideTitle? > `optional` **hideTitle**: `boolean` If `true`, the title of the code editor is hidden, however its code is still evaluated. This can be useful in embedded playgrounds (e.g. for hiding unnecessary code). #### markup.language > **language**: [`Language`](../type-aliases/Language.md) A language name, extension or alias (as defined in [language documentations](https://livecodes.io/docs/languages/)). For the list of supported values, see [Language](https://livecodes.io/docs/api/type-aliases/Language) #### markup.order? > `optional` **order**: `number` The order of the editor in the UI. ##### Default ```ts 0 ``` #### markup.position? > `optional` **position**: [`EditorPosition`](../internal/interfaces/EditorPosition.md) The initial position of the cursor in the code editor. ##### Example ```ts {lineNumber: 5, column: 10} ``` #### markup.selector? > `optional` **selector**: `string` A CSS selector to load content from [DOM import](https://livecodes.io/docs/features/import#import-code-from-dom). #### markup.title? > `optional` **title**: `string` If set, this is used as the title of the editor in the UI, overriding the default title set to the language name (e.g. `"Python"` can be used instead of `"Py (Wasm)"`). #### md > **md**: `undefined` \| `string` #### md-selector > **md-selector**: `undefined` \| `string` #### mdown > **mdown**: `undefined` \| `string` #### mdown-selector > **mdown-selector**: `undefined` \| `string` #### mdx > **mdx**: `undefined` \| `string` #### mdx-selector > **mdx-selector**: `undefined` \| `string` #### minimap? > `optional` **minimap**: `boolean` Enables minimap in code editor. ##### Default ```ts false ``` #### minizinc > **minizinc**: `undefined` \| `string` #### minizinc-selector > **minizinc-selector**: `undefined` \| `string` #### mjml > **mjml**: `undefined` \| `string` #### mjml-selector > **mjml-selector**: `undefined` \| `string` #### mjs > **mjs**: `undefined` \| `string` #### mjs-selector > **mjs-selector**: `undefined` \| `string` #### mkdn > **mkdn**: `undefined` \| `string` #### mkdn-selector > **mkdn-selector**: `undefined` \| `string` #### ml > **ml**: `undefined` \| `string` #### ml-selector > **ml-selector**: `undefined` \| `string` #### mli > **mli**: `undefined` \| `string` #### mli-selector > **mli-selector**: `undefined` \| `string` #### mode? > `optional` **mode**: `"editor"` \| `"result"` \| `"full"` \| `"focus"` \| `"lite"` \| `"simple"` \| `"codeblock"` Sets the [display mode](https://livecodes.io/docs/features/display-modes). ##### Default ```ts "full" ``` #### mts > **mts**: `undefined` \| `string` #### mts-selector > **mts-selector**: `undefined` \| `string` #### mustache > **mustache**: `undefined` \| `string` #### mustache-selector > **mustache-selector**: `undefined` \| `string` #### mzn > **mzn**: `undefined` \| `string` #### mzn-selector > **mzn-selector**: `undefined` \| `string` #### new? > `optional` **new**: `""` #### njk > **njk**: `undefined` \| `string` #### njk-selector > **njk-selector**: `undefined` \| `string` #### no-defaults? > `optional` **no-defaults**: `boolean` #### nunjucks > **nunjucks**: `undefined` \| `string` #### nunjucks-selector > **nunjucks-selector**: `undefined` \| `string` #### ocaml > **ocaml**: `undefined` \| `string` #### ocaml-selector > **ocaml-selector**: `undefined` \| `string` #### params? > `optional` **params**: \{ appUrl?: string \| undefined; params?: ... \| undefined; config?: string \| (Partial\ & string) \| undefined; headless?: boolean \| undefined; import?: string \| undefined; ... 498 more ...; compiled?: "" \| ... 5 more ... \| undefined; \} \| undefined An object that represents the [URL Query parameters](https://livecodes.io/docs/configuration/query-params), that can be used to configure the playground. These 2 snippets produce similar output: ```js import { createPlayground } from 'livecodes'; // use config createPlayground('#container', { config: { markup: { language: 'markdown', content: '# Hello World!', }, }, }); // use params createPlayground('#container', { params: { md: '# Hello World!' } }); ``` #### perl > **perl**: `undefined` \| `string` #### perl-selector > **perl-selector**: `undefined` \| `string` #### pg > **pg**: `undefined` \| `string` #### pg-selector > **pg-selector**: `undefined` \| `string` #### pg.sql > **sql**: `undefined` \| `string` #### pg.sql-selector > **sql-selector**: `undefined` \| `string` #### pglite > **pglite**: `undefined` \| `string` #### pglite-selector > **pglite-selector**: `undefined` \| `string` #### pglite.sql > **sql**: `undefined` \| `string` #### pglite.sql-selector > **sql-selector**: `undefined` \| `string` #### pgsql > **pgsql**: `undefined` \| `string` #### pgsql-selector > **pgsql-selector**: `undefined` \| `string` #### pgsql.sql > **sql**: `undefined` \| `string` #### pgsql.sql-selector > **sql-selector**: `undefined` \| `string` #### php > **php**: `undefined` \| `string` #### php-selector > **php-selector**: `undefined` \| `string` #### php-wasm > **php-wasm**: `undefined` \| `string` #### php-wasm-selector > **php-wasm-selector**: `undefined` \| `string` #### phpwasm > **phpwasm**: `undefined` \| `string` #### phpwasm-selector > **phpwasm-selector**: `undefined` \| `string` #### pintora > **pintora**: `undefined` \| `string` #### pintora-selector > **pintora-selector**: `undefined` \| `string` #### pl > **pl**: `undefined` \| `string` #### pl-selector > **pl-selector**: `undefined` \| `string` #### plt > **plt**: `undefined` \| `string` #### plt-selector > **plt-selector**: `undefined` \| `string` #### pm > **pm**: `undefined` \| `string` #### pm-selector > **pm-selector**: `undefined` \| `string` #### postcss > **postcss**: `undefined` \| `string` #### postcss-selector > **postcss-selector**: `undefined` \| `string` #### postgre.sql > **sql**: `undefined` \| `string` #### postgre.sql-selector > **sql-selector**: `undefined` \| `string` #### postgres > **postgres**: `undefined` \| `string` #### postgres-selector > **postgres-selector**: `undefined` \| `string` #### postgresql > **postgresql**: `undefined` \| `string` #### postgresql-selector > **postgresql-selector**: `undefined` \| `string` #### postgresql.sql > **sql**: `undefined` \| `string` #### postgresql.sql-selector > **sql-selector**: `undefined` \| `string` #### preview? > `optional` **preview**: `boolean` #### processors? > `optional` **processors**: `string` #### prolog > **prolog**: `undefined` \| `string` #### prolog-selector > **prolog-selector**: `undefined` \| `string` #### prolog.pl > **pl**: `undefined` \| `string` #### prolog.pl-selector > **pl-selector**: `undefined` \| `string` #### pug > **pug**: `undefined` \| `string` #### pug-selector > **pug-selector**: `undefined` \| `string` #### py > **py**: `undefined` \| `string` #### py-selector > **py-selector**: `undefined` \| `string` #### py-wasm > **py-wasm**: `undefined` \| `string` #### py-wasm-selector > **py-wasm-selector**: `undefined` \| `string` #### py3 > **py3**: `undefined` \| `string` #### py3-selector > **py3-selector**: `undefined` \| `string` #### pyodide > **pyodide**: `undefined` \| `string` #### pyodide-selector > **pyodide-selector**: `undefined` \| `string` #### python > **python**: `undefined` \| `string` #### python-selector > **python-selector**: `undefined` \| `string` #### python-wasm > **python-wasm**: `undefined` \| `string` #### python-wasm-selector > **python-wasm-selector**: `undefined` \| `string` #### pythonwasm > **pythonwasm**: `undefined` \| `string` #### pythonwasm-selector > **pythonwasm-selector**: `undefined` \| `string` #### pywasm > **pywasm**: `undefined` \| `string` #### pywasm-selector > **pywasm-selector**: `undefined` \| `string` #### r > **r**: `undefined` \| `string` #### r-selector > **r-selector**: `undefined` \| `string` #### r-wasm > **r-wasm**: `undefined` \| `string` #### r-wasm-selector > **r-wasm-selector**: `undefined` \| `string` #### raw? > `optional` **raw**: [`Language`](../type-aliases/Language.md) #### rb > **rb**: `undefined` \| `string` #### rb-selector > **rb-selector**: `undefined` \| `string` #### re > **re**: `undefined` \| `string` #### re-selector > **re-selector**: `undefined` \| `string` #### react > **react**: `undefined` \| `string` #### react-jsx > **react-jsx**: `undefined` \| `string` #### react-jsx-selector > **react-jsx-selector**: `undefined` \| `string` #### react-native > **react-native**: `undefined` \| `string` #### react-native-selector > **react-native-selector**: `undefined` \| `string` #### react-native-tsx > **react-native-tsx**: `undefined` \| `string` #### react-native-tsx-selector > **react-native-tsx-selector**: `undefined` \| `string` #### react-native.jsx > **jsx**: `undefined` \| `string` #### react-native.jsx-selector > **jsx-selector**: `undefined` \| `string` #### react-native.tsx > **tsx**: `undefined` \| `string` #### react-native.tsx-selector > **tsx-selector**: `undefined` \| `string` #### react-selector > **react-selector**: `undefined` \| `string` #### react-tsx > **react-tsx**: `undefined` \| `string` #### react-tsx-selector > **react-tsx-selector**: `undefined` \| `string` #### react.jsx > **jsx**: `undefined` \| `string` #### react.jsx-selector > **jsx-selector**: `undefined` \| `string` #### react.tsx > **tsx**: `undefined` \| `string` #### react.tsx-selector > **tsx-selector**: `undefined` \| `string` #### readonly? > `optional` **readonly**: `boolean` If `true`, editors are loaded in read-only mode, where the user is not allowed to change the code. By default, when readonly is set to true, the light-weight code editor [CodeJar](https://livecodes.io/docs/features/editor-settings#code-editor) is used. If you wish to use another editor, set the [editor](https://livecodes.io/docs/configuration/configuration-object#editor) property. ##### Default ```ts false ``` #### reason > **reason**: `undefined` \| `string` #### reason-selector > **reason-selector**: `undefined` \| `string` #### recoverUnsaved? > `optional` **recoverUnsaved**: `boolean` Enables [recovering last unsaved project](https://livecodes.io/docs/features/recover) when the app is reopened. ##### Default ```ts true ``` #### rei > **rei**: `undefined` \| `string` #### rei-selector > **rei-selector**: `undefined` \| `string` #### res > **res**: `undefined` \| `string` #### res-selector > **res-selector**: `undefined` \| `string` #### rescript > **rescript**: `undefined` \| `string` #### rescript-selector > **rescript-selector**: `undefined` \| `string` #### resi > **resi**: `undefined` \| `string` #### resi-selector > **resi-selector**: `undefined` \| `string` #### rich > **rich**: `undefined` \| `string` #### rich-selector > **rich-selector**: `undefined` \| `string` #### richtext > **richtext**: `undefined` \| `string` #### richtext-selector > **richtext-selector**: `undefined` \| `string` #### riot > **riot**: `undefined` \| `string` #### riot-selector > **riot-selector**: `undefined` \| `string` #### riotjs > **riotjs**: `undefined` \| `string` #### riotjs-selector > **riotjs-selector**: `undefined` \| `string` #### ripple > **ripple**: `undefined` \| `string` #### ripple-selector > **ripple-selector**: `undefined` \| `string` #### ripplejs > **ripplejs**: `undefined` \| `string` #### ripplejs-selector > **ripplejs-selector**: `undefined` \| `string` #### rlang > **rlang**: `undefined` \| `string` #### rlang-selector > **rlang-selector**: `undefined` \| `string` #### rstats > **rstats**: `undefined` \| `string` #### rstats-selector > **rstats-selector**: `undefined` \| `string` #### rte > **rte**: `undefined` \| `string` #### rte-selector > **rte-selector**: `undefined` \| `string` #### rte.html > **html**: `undefined` \| `string` #### rte.html-selector > **html-selector**: `undefined` \| `string` #### ruby > **ruby**: `undefined` \| `string` #### ruby-selector > **ruby-selector**: `undefined` \| `string` #### ruby-wasm > **ruby-wasm**: `undefined` \| `string` #### ruby-wasm-selector > **ruby-wasm-selector**: `undefined` \| `string` #### rubywasm > **rubywasm**: `undefined` \| `string` #### rubywasm-selector > **rubywasm-selector**: `undefined` \| `string` #### sass > **sass**: `undefined` \| `string` #### sass-selector > **sass-selector**: `undefined` \| `string` #### scheme > **scheme**: `undefined` \| `string` #### scheme-selector > **scheme-selector**: `undefined` \| `string` #### scm > **scm**: `undefined` \| `string` #### scm-selector > **scm-selector**: `undefined` \| `string` #### screen? > `optional` **screen**: [`ScreenName`](../internal/type-aliases/ScreenName.md) #### script? > `optional` **script**: `object` An object that configures the language and content of the script editor. See [docs](https://livecodes.io/docs/configuration/configuration-object/#markup) for details. ##### Default ```ts { language: "javascript", content: "" } ``` #### script.content? > `optional` **content**: `string` The initial content of the code editor. ##### Default ```ts "" ``` #### script.contentUrl? > `optional` **contentUrl**: `string` A URL to load `content` from. It has to be a valid URL that is CORS-enabled. The URL is only fetched if `content` property had no value. #### script.foldedLines? > `optional` **foldedLines**: `object`[] Lines that get folded when the editor loads. This can be used for less relevant content. ##### Example ```ts [{ from: 5, to: 8 }, { from: 15, to: 20 }] ``` #### script.hiddenContent? > `optional` **hiddenContent**: `string` Hidden content that gets evaluated without being visible in the code editor. This can be useful in embedded playgrounds (e.g. for adding helper functions, utilities or tests) #### script.hiddenContentUrl? > `optional` **hiddenContentUrl**: `string` A URL to load `hiddenContent` from. It has to be a valid URL that is CORS-enabled. The URL is only fetched if `hiddenContent` property had no value. #### script.hideTitle? > `optional` **hideTitle**: `boolean` If `true`, the title of the code editor is hidden, however its code is still evaluated. This can be useful in embedded playgrounds (e.g. for hiding unnecessary code). #### script.language > **language**: [`Language`](../type-aliases/Language.md) A language name, extension or alias (as defined in [language documentations](https://livecodes.io/docs/languages/)). For the list of supported values, see [Language](https://livecodes.io/docs/api/type-aliases/Language) #### script.order? > `optional` **order**: `number` The order of the editor in the UI. ##### Default ```ts 0 ``` #### script.position? > `optional` **position**: [`EditorPosition`](../internal/interfaces/EditorPosition.md) The initial position of the cursor in the code editor. ##### Example ```ts {lineNumber: 5, column: 10} ``` #### script.selector? > `optional` **selector**: `string` A CSS selector to load content from [DOM import](https://livecodes.io/docs/features/import#import-code-from-dom). #### script.title? > `optional` **title**: `string` If set, this is used as the title of the editor in the UI, overriding the default title set to the language name (e.g. `"Python"` can be used instead of `"Py (Wasm)"`). #### scripts? > `optional` **scripts**: `string` #### scrollPosition? > `optional` **scrollPosition**: `boolean` #### scss > **scss**: `undefined` \| `string` #### scss-selector > **scss-selector**: `undefined` \| `string` #### sdkVersion? > `optional` **sdkVersion**: `string` #### semicolons? > `optional` **semicolons**: `boolean` Configures Prettier [code formatter](https://livecodes.io/docs/features/code-format) to use semi-colons. ##### Default ```ts true ``` #### showSpacing? > `optional` **showSpacing**: `boolean` Enables [showing element spacing](https://livecodes.io/docs/features/result#show-spacings) in the result page. ##### Default ```ts false ``` #### singleQuote? > `optional` **singleQuote**: `boolean` Configures Prettier [code formatter](https://livecodes.io/docs/features/code-format) to use single quotes instead of double quotes. ##### Default ```ts false ``` #### solid > **solid**: `undefined` \| `string` #### solid-selector > **solid-selector**: `undefined` \| `string` #### solid.jsx > **jsx**: `undefined` \| `string` #### solid.jsx-selector > **jsx-selector**: `undefined` \| `string` #### solid.tsx > **tsx**: `undefined` \| `string` #### solid.tsx-selector > **tsx-selector**: `undefined` \| `string` #### sql > **sql**: `undefined` \| `string` #### sql-selector > **sql-selector**: `undefined` \| `string` #### sqlite > **sqlite**: `undefined` \| `string` #### sqlite-selector > **sqlite-selector**: `undefined` \| `string` #### sqlite3 > **sqlite3**: `undefined` \| `string` #### sqlite3-selector > **sqlite3-selector**: `undefined` \| `string` #### stencil > **stencil**: `undefined` \| `string` #### stencil-selector > **stencil-selector**: `undefined` \| `string` #### stencil.tsx > **tsx**: `undefined` \| `string` #### stencil.tsx-selector > **tsx-selector**: `undefined` \| `string` #### styl > **styl**: `undefined` \| `string` #### styl-selector > **styl-selector**: `undefined` \| `string` #### style? > `optional` **style**: `object` An object that configures the language and content of the style editor. See [docs](https://livecodes.io/docs/configuration/configuration-object/#markup) for details. ##### Default ```ts { language: "css", content: "" } ``` #### style.content? > `optional` **content**: `string` The initial content of the code editor. ##### Default ```ts "" ``` #### style.contentUrl? > `optional` **contentUrl**: `string` A URL to load `content` from. It has to be a valid URL that is CORS-enabled. The URL is only fetched if `content` property had no value. #### style.foldedLines? > `optional` **foldedLines**: `object`[] Lines that get folded when the editor loads. This can be used for less relevant content. ##### Example ```ts [{ from: 5, to: 8 }, { from: 15, to: 20 }] ``` #### style.hiddenContent? > `optional` **hiddenContent**: `string` Hidden content that gets evaluated without being visible in the code editor. This can be useful in embedded playgrounds (e.g. for adding helper functions, utilities or tests) #### style.hiddenContentUrl? > `optional` **hiddenContentUrl**: `string` A URL to load `hiddenContent` from. It has to be a valid URL that is CORS-enabled. The URL is only fetched if `hiddenContent` property had no value. #### style.hideTitle? > `optional` **hideTitle**: `boolean` If `true`, the title of the code editor is hidden, however its code is still evaluated. This can be useful in embedded playgrounds (e.g. for hiding unnecessary code). #### style.language > **language**: [`Language`](../type-aliases/Language.md) A language name, extension or alias (as defined in [language documentations](https://livecodes.io/docs/languages/)). For the list of supported values, see [Language](https://livecodes.io/docs/api/type-aliases/Language) #### style.order? > `optional` **order**: `number` The order of the editor in the UI. ##### Default ```ts 0 ``` #### style.position? > `optional` **position**: [`EditorPosition`](../internal/interfaces/EditorPosition.md) The initial position of the cursor in the code editor. ##### Example ```ts {lineNumber: 5, column: 10} ``` #### style.selector? > `optional` **selector**: `string` A CSS selector to load content from [DOM import](https://livecodes.io/docs/features/import#import-code-from-dom). #### style.title? > `optional` **title**: `string` If set, this is used as the title of the editor in the UI, overriding the default title set to the language name (e.g. `"Python"` can be used instead of `"Py (Wasm)"`). #### stylesheets? > `optional` **stylesheets**: `string` #### stylis > **stylis**: `undefined` \| `string` #### stylis-selector > **stylis-selector**: `undefined` \| `string` #### stylus > **stylus**: `undefined` \| `string` #### stylus-selector > **stylus-selector**: `undefined` \| `string` #### sucrase > **sucrase**: `undefined` \| `string` #### sucrase-selector > **sucrase-selector**: `undefined` \| `string` #### svelte > **svelte**: `undefined` \| `string` #### svelte-app > **svelte-app**: `undefined` \| `string` #### svelte-app-selector > **svelte-app-selector**: `undefined` \| `string` #### svelte-selector > **svelte-selector**: `undefined` \| `string` #### swift > **swift**: `undefined` \| `string` #### swift-selector > **swift-selector**: `undefined` \| `string` #### tabSize? > `optional` **tabSize**: `number` The number of spaces per indentation-level. Also used in [code formatting](https://livecodes.io/docs/features/code-format). ##### Default ```ts 2 ``` #### tags? > `optional` **tags**: `string` \| `string`[] #### tcl > **tcl**: `undefined` \| `string` #### tcl-selector > **tcl-selector**: `undefined` \| `string` #### teal > **teal**: `undefined` \| `string` #### teal-selector > **teal-selector**: `undefined` \| `string` #### template? > `optional` **template**: [`TemplateName`](../internal/type-aliases/TemplateName.md) A [starter template](https://livecodes.io/docs/features/templates) to load. Allowed valued can be found [here](https://livecodes.io/docs/api/internal/type-aliases/TemplateName). #### tests? > `optional` **tests**: (\{ language?: Language \| undefined; content?: string \| undefined; contentUrl?: string \| undefined; hiddenContent?: string \| undefined; hiddenContentUrl?: string \| undefined; ... 5 more ...; position?: EditorPosition \| undefined; \} \| undefined) & ("" \| ... 4 more ... \| "true") Configures the [language](https://livecodes.io/docs/features/tests#supported-languages) and content of [tests](https://livecodes.io/docs/features/tests). #### theme? > `optional` **theme**: [`Theme`](../internal/type-aliases/Theme.md) Sets the app [theme](https://livecodes.io/docs/features/themes) to light/dark mode. ##### Default ```ts "dark" ``` #### themeColor? > `optional` **themeColor**: `string` Sets the app theme color. If `undefined`, it is set to `"hsl(214, 40%, 50%)"`. ##### Default ```ts undefined ``` #### title? > `optional` **title**: `string` Project title. This is used as [result page](https://livecodes.io/docs/features/result) title and title meta tag. Also used in project search. ##### Default ```ts "Untitled Project" ``` #### tl > **tl**: `undefined` \| `string` #### tl-selector > **tl-selector**: `undefined` \| `string` #### tools? > `optional` **tools**: `"full"` \| `"console"` \| `"compiled"` \| `"tests"` \| `"closed"` \| `"open"` \| `"none"` \| "console\|undefined" \| "console\|" \| "console\|full" \| "console\|closed" \| "console\|open" \| "console\|none" \| "compiled\|undefined" \| "compiled\|" \| "compiled\|full" \| "compiled\|closed" \| "compiled\|open" \| "compiled\|none" \| "tests\|undefined" \| "tests\|" \| "tests\|full" \| "tests\|closed" \| "tests\|open" \| "tests\|none" \| "console,console\|undefined" \| "console,console\|" \| "console,console\|full" \| "console,console\|closed" \| "console,console\|open" \| "console,console\|none" \| "console,compiled\|undefined" \| "console,compiled\|" \| "console,compiled\|full" \| "console,compiled\|closed" \| "console,compiled\|open" \| "console,compiled\|none" \| "console,tests\|undefined" \| "console,tests\|" \| "console,tests\|full" \| "console,tests\|closed" \| "console,tests\|open" \| "console,tests\|none" \| "compiled,console\|undefined" \| "compiled,console\|" \| "compiled,console\|full" \| "compiled,console\|closed" \| "compiled,console\|open" \| "compiled,console\|none" \| "compiled,compiled\|undefined" \| "compiled,compiled\|" \| "compiled,compiled\|full" \| "compiled,compiled\|closed" \| "compiled,compiled\|open" \| "compiled,compiled\|none" \| "compiled,tests\|undefined" \| "compiled,tests\|" \| "compiled,tests\|full" \| "compiled,tests\|closed" \| "compiled,tests\|open" \| "compiled,tests\|none" \| "tests,console\|undefined" \| "tests,console\|" \| "tests,console\|full" \| "tests,console\|closed" \| "tests,console\|open" \| "tests,console\|none" \| "tests,compiled\|undefined" \| "tests,compiled\|" \| "tests,compiled\|full" \| "tests,compiled\|closed" \| "tests,compiled\|open" \| "tests,compiled\|none" \| "tests,tests\|undefined" \| "tests,tests\|" \| "tests,tests\|full" \| "tests,tests\|closed" \| "tests,tests\|open" \| "tests,tests\|none" \| "console,console,console\|undefined" \| "console,console,console\|" \| "console,console,console\|full" \| "console,console,console\|closed" \| "console,console,console\|open" \| "console,console,console\|none" \| "console,console,compiled\|undefined" \| "console,console,compiled\|" \| "console,console,compiled\|full" \| "console,console,compiled\|closed" \| "console,console,compiled\|open" \| "console,console,compiled\|none" \| "console,console,tests\|undefined" \| "console,console,tests\|" \| "console,console,tests\|full" \| "console,console,tests\|closed" \| "console,console,tests\|open" \| "console,console,tests\|none" \| "console,compiled,console\|undefined" \| "console,compiled,console\|" \| "console,compiled,console\|full" \| "console,compiled,console\|closed" \| "console,compiled,console\|open" \| "console,compiled,console\|none" \| "console,compiled,compiled\|undefined" \| "console,compiled,compiled\|" \| "console,compiled,compiled\|full" \| "console,compiled,compiled\|closed" \| "console,compiled,compiled\|open" \| "console,compiled,compiled\|none" \| "console,compiled,tests\|undefined" \| "console,compiled,tests\|" \| "console,compiled,tests\|full" \| "console,compiled,tests\|closed" \| "console,compiled,tests\|open" \| "console,compiled,tests\|none" \| "console,tests,console\|undefined" \| "console,tests,console\|" \| "console,tests,console\|full" \| "console,tests,console\|closed" \| "console,tests,console\|open" \| "console,tests,console\|none" \| "console,tests,compiled\|undefined" \| "console,tests,compiled\|" \| "console,tests,compiled\|full" \| "console,tests,compiled\|closed" \| "console,tests,compiled\|open" \| "console,tests,compiled\|none" \| "console,tests,tests\|undefined" \| "console,tests,tests\|" \| "console,tests,tests\|full" \| "console,tests,tests\|closed" \| "console,tests,tests\|open" \| "console,tests,tests\|none" \| "compiled,console,console\|undefined" \| "compiled,console,console\|" \| "compiled,console,console\|full" \| "compiled,console,console\|closed" \| "compiled,console,console\|open" \| "compiled,console,console\|none" \| "compiled,console,compiled\|undefined" \| "compiled,console,compiled\|" \| "compiled,console,compiled\|full" \| "compiled,console,compiled\|closed" \| "compiled,console,compiled\|open" \| "compiled,console,compiled\|none" \| "compiled,console,tests\|undefined" \| "compiled,console,tests\|" \| "compiled,console,tests\|full" \| "compiled,console,tests\|closed" \| "compiled,console,tests\|open" \| "compiled,console,tests\|none" \| "compiled,compiled,console\|undefined" \| "compiled,compiled,console\|" \| "compiled,compiled,console\|full" \| "compiled,compiled,console\|closed" \| "compiled,compiled,console\|open" \| "compiled,compiled,console\|none" \| "compiled,compiled,compiled\|undefined" \| "compiled,compiled,compiled\|" \| "compiled,compiled,compiled\|full" \| "compiled,compiled,compiled\|closed" \| "compiled,compiled,compiled\|open" \| "compiled,compiled,compiled\|none" \| "compiled,compiled,tests\|undefined" \| "compiled,compiled,tests\|" \| "compiled,compiled,tests\|full" \| "compiled,compiled,tests\|closed" \| "compiled,compiled,tests\|open" \| "compiled,compiled,tests\|none" \| "compiled,tests,console\|undefined" \| "compiled,tests,console\|" \| "compiled,tests,console\|full" \| "compiled,tests,console\|closed" \| "compiled,tests,console\|open" \| "compiled,tests,console\|none" \| "compiled,tests,compiled\|undefined" \| "compiled,tests,compiled\|" \| "compiled,tests,compiled\|full" \| "compiled,tests,compiled\|closed" \| "compiled,tests,compiled\|open" \| "compiled,tests,compiled\|none" \| "compiled,tests,tests\|undefined" \| "compiled,tests,tests\|" \| "compiled,tests,tests\|full" \| "compiled,tests,tests\|closed" \| "compiled,tests,tests\|open" \| "compiled,tests,tests\|none" \| "tests,console,console\|undefined" \| "tests,console,console\|" \| "tests,console,console\|full" \| "tests,console,console\|closed" \| "tests,console,console\|open" \| "tests,console,console\|none" \| "tests,console,compiled\|undefined" \| "tests,console,compiled\|" \| "tests,console,compiled\|full" \| "tests,console,compiled\|closed" \| "tests,console,compiled\|open" \| "tests,console,compiled\|none" \| "tests,console,tests\|undefined" \| "tests,console,tests\|" \| "tests,console,tests\|full" \| "tests,console,tests\|closed" \| "tests,console,tests\|open" \| "tests,console,tests\|none" \| "tests,compiled,console\|undefined" \| "tests,compiled,console\|" \| "tests,compiled,console\|full" \| "tests,compiled,console\|closed" \| "tests,compiled,console\|open" \| "tests,compiled,console\|none" \| "tests,compiled,compiled\|undefined" \| "tests,compiled,compiled\|" \| "tests,compiled,compiled\|full" \| "tests,compiled,compiled\|closed" \| "tests,compiled,compiled\|open" \| "tests,compiled,compiled\|none" \| "tests,compiled,tests\|undefined" \| "tests,compiled,tests\|" \| "tests,compiled,tests\|full" \| "tests,compiled,tests\|closed" \| "tests,compiled,tests\|open" \| "tests,compiled,tests\|none" \| "tests,tests,console\|undefined" \| "tests,tests,console\|" \| "tests,tests,console\|full" \| "tests,tests,console\|closed" \| "tests,tests,console\|open" \| "tests,tests,console\|none" \| "tests,tests,compiled\|undefined" \| "tests,tests,compiled\|" \| "tests,tests,compiled\|full" \| "tests,tests,compiled\|closed" \| "tests,tests,compiled\|open" \| "tests,tests,compiled\|none" \| "tests,tests,tests\|undefined" \| "tests,tests,tests\|" \| "tests,tests,tests\|full" \| "tests,tests,tests\|closed" \| "tests,tests,tests\|open" \| "tests,tests,tests\|none" #### trailingComma? > `optional` **trailingComma**: `boolean` Configures Prettier [code formatter](https://livecodes.io/docs/features/code-format) to use [trailing commas](https://prettier.io/docs/en/options.html#trailing-commas). ##### Default ```ts true ``` #### ts > **ts**: `undefined` \| `string` #### ts-selector > **ts-selector**: `undefined` \| `string` #### tsx > **tsx**: `undefined` \| `string` #### tsx-selector > **tsx-selector**: `undefined` \| `string` #### twig > **twig**: `undefined` \| `string` #### twig-selector > **twig-selector**: `undefined` \| `string` #### types? > `optional` **types**: `object` Allows providing custom TypeScript type declarations for better [editor intellisense](https://livecodes.io/docs/features/intellisense). It is an object where each key represents module name and value represents the types. See docs for [Types](https://livecodes.io/docs/configuration/configuration-object#types) and [Custom Types](https://livecodes.io/docs/features/intellisense#custom-types) ##### Examples ```js { "types": { "my-demo-lib": "https://my-custom-domain/my-type-declarations.d.ts" } } ``` ``` { "types": { "my-demo-lib": { "url": "https://my-custom-domain/types.d.ts", "autoload": true, "declareAsModule": true } } ``` #### typescript > **typescript**: `undefined` \| `string` #### typescript-selector > **typescript-selector**: `undefined` \| `string` #### useTabs? > `optional` **useTabs**: `boolean` If `true`, lines are indented with tabs instead of spaces. Also used in [code formatting](https://livecodes.io/docs/features/code-format). ##### Default ```ts false ``` #### vento > **vento**: `undefined` \| `string` #### vento-selector > **vento-selector**: `undefined` \| `string` #### version? > `readonly` `optional` **version**: `string` This is a read-only property which specifies the current LiveCodes version. Version specified in [exported](https://livecodes.io/docs/features/export) projects allows automatically upgrading the project configuration when imported by an app with a newer version. #### ~~view?~~ > `optional` **view**: `"split"` \| `"editor"` \| `"result"` The [default view](https://livecodes.io/docs/features/default-view) for the playground. When set to `"headless"`, the playground is loaded in [headless mode](https://livecodes.io/docs/sdk/headless). ##### Deprecated The `view` option has been moved to `config.view`. For headless mode use `headless: true`. ##### Default ```ts "split" ``` #### vto > **vto**: `undefined` \| `string` #### vto-selector > **vto-selector**: `undefined` \| `string` #### vue > **vue**: `undefined` \| `string` #### vue-app > **vue-app**: `undefined` \| `string` #### vue-app-selector > **vue-app-selector**: `undefined` \| `string` #### vue-selector > **vue-selector**: `undefined` \| `string` #### vue2 > **vue2**: `undefined` \| `string` #### vue2-selector > **vue2-selector**: `undefined` \| `string` #### vue3 > **vue3**: `undefined` \| `string` #### vue3-selector > **vue3-selector**: `undefined` \| `string` #### wasm > **wasm**: `undefined` \| `string` #### wasm-selector > **wasm-selector**: `undefined` \| `string` #### wasm.cpp > **cpp**: `undefined` \| `string` #### wasm.cpp-selector > **cpp-selector**: `undefined` \| `string` #### wasm.cs > **cs**: `undefined` \| `string` #### wasm.cs-selector > **cs-selector**: `undefined` \| `string` #### wasm.go > **go**: `undefined` \| `string` #### wasm.go-selector > **go-selector**: `undefined` \| `string` #### wasm.lua > **lua**: `undefined` \| `string` #### wasm.lua-selector > **lua-selector**: `undefined` \| `string` #### wasm.php > **php**: `undefined` \| `string` #### wasm.php-selector > **php-selector**: `undefined` \| `string` #### wasm.py > **py**: `undefined` \| `string` #### wasm.py-selector > **py-selector**: `undefined` \| `string` #### wasm.rb > **rb**: `undefined` \| `string` #### wasm.rb-selector > **rb-selector**: `undefined` \| `string` #### wast > **wast**: `undefined` \| `string` #### wast-selector > **wast-selector**: `undefined` \| `string` #### wat > **wat**: `undefined` \| `string` #### wat-selector > **wat-selector**: `undefined` \| `string` #### webassembly > **webassembly**: `undefined` \| `string` #### webassembly-selector > **webassembly-selector**: `undefined` \| `string` #### welcome? > `optional` **welcome**: `boolean` If `true`, the [welcome screen](https://livecodes.io/docs/features/welcome) is displayed when the app loads. #### wordWrap? > `optional` **wordWrap**: `boolean` Enables word-wrap for long lines. ##### Default ```ts false ``` #### x? > `optional` **x**: `string` #### xht > **xht**: `undefined` \| `string` #### xht-selector > **xht-selector**: `undefined` \| `string` #### xml > **xml**: `undefined` \| `string` #### xml-selector > **xml-selector**: `undefined` \| `string` #### zoom? > `optional` **zoom**: `1` \| `0.5` \| `0.25` Sets result page [zoom level](https://livecodes.io/docs/features/result#result-page-zoom). #### Defined in [src/sdk/models.ts:1740](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1740) *** ### template? > `optional` **template**: [`TemplateName`](../internal/type-aliases/TemplateName.md) A [starter template](https://livecodes.io/docs/features/templates) to load. Allowed valued can be found [here](https://livecodes.io/docs/api/internal/type-aliases/TemplateName). #### Defined in [src/sdk/models.ts:1786](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1786) *** ### ~~view?~~ > `optional` **view**: `"split"` \| `"editor"` \| `"result"` \| `"headless"` The [default view](https://livecodes.io/docs/features/default-view) for the playground. When set to `"headless"`, the playground is loaded in [headless mode](https://livecodes.io/docs/sdk/headless). #### Deprecated The `view` option has been moved to `config.view`. For headless mode use `headless: true`. #### Default ```ts "split" ``` #### Defined in [src/sdk/models.ts:1799](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1799) --- # Interface: Playground An object that represents the LiveCodes playground instance. The object exposes multiple [methods](https://livecodes.io/docs/sdk/js-ts/#sdk-methods) that can be used to interact with the playground. See [docs](https://livecodes.io/docs/sdk/js-ts) for details. ## Extends - [`API`](../internal/interfaces/API.md) ## Properties ### destroy() > **destroy**: () => `Promise`\<`void`\> Destroys the playground instance, and removes event listeners. Further call to any SDK methods throws an error. #### Returns `Promise`\<`void`\> #### Example ```ts import { createPlayground } from "livecodes"; createPlayground("#container").then(async (playground) => { await playground.destroy(); // playground destroyed // any further SDK call throws an error }); ``` #### Inherited from [`API`](../internal/interfaces/API.md).[`destroy`](../internal/interfaces/API.md#destroy) #### Defined in [src/sdk/models.ts:1624](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1624) *** ### exec() > **exec**: (`command`, ...`args`) => `Promise`\<`object` \| `object`\> Executes custom commands, including: `"setBroadcastToken"` and `"showVersion"`. See [docs](https://livecodes.io/docs/sdk/js-ts#exec) for details. #### Parameters • **command**: [`APICommands`](../internal/type-aliases/APICommands.md) • ...**args**: `any`[] #### Returns `Promise`\<`object` \| `object`\> #### Inherited from [`API`](../internal/interfaces/API.md).[`exec`](../internal/interfaces/API.md#exec) #### Defined in [src/sdk/models.ts:1607](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1607) *** ### format() > **format**: (`allEditors`?) => `Promise`\<`void`\> Formats the code. By default, the code in all editors (markup, style and script) is formatted. To format only the active editor, the value `false` should be passed as an argument. #### Parameters • **allEditors?**: `boolean` #### Returns `Promise`\<`void`\> #### Example ```ts import { createPlayground } from "livecodes"; createPlayground("#container").then(async (playground) => { await playground.format(); // code in editors is formatted }); ``` #### Inherited from [`API`](../internal/interfaces/API.md).[`format`](../internal/interfaces/API.md#format) #### Defined in [src/sdk/models.ts:1440](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1440) *** ### getCode() > **getCode**: () => `Promise`\<[`Code`](Code.md)\> Gets the playground code (including source code, source language and compiled code) for each editor (markup, style, script), in addition to result page HTML. See [Code](https://livecodes.io/docs/api/interfaces/Code) for the structure of the returned object. #### Returns `Promise`\<[`Code`](Code.md)\> #### Example ```ts import { createPlayground } from "livecodes"; createPlayground("#container").then(async (playground) => { const code = await playground.getCode(); // source code, language and compiled code for the script editor const { content, language, compiled } = code.script; // result page HTML const result = code.result; }); ``` #### Inherited from [`API`](../internal/interfaces/API.md).[`getCode`](../internal/interfaces/API.md#getcode) #### Defined in [src/sdk/models.ts:1518](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1518) *** ### getConfig() > **getConfig**: (`contentOnly`?) => `Promise`\<[`Config`](Config.md)\> Gets a [configuration object](https://livecodes.io/docs/configuration/configuration-object) representing the playground state. This can be used to restore state if passed as an [EmbedOptions](https://livecodes.io/docs/sdk/js-ts#embed-options) property when [creating playgrounds](https://livecodes.io/docs/sdk/js-ts/#createplayground), or can be manipulated and loaded in run-time using [`setConfig`](https://livecodes.io/docs/sdk/js-ts#setconfig) method. #### Parameters • **contentOnly?**: `boolean` #### Returns `Promise`\<[`Config`](Config.md)\> #### Example ```ts import { createPlayground } from "livecodes"; createPlayground("#container").then(async (playground) => { const config = await playground.getConfig(); }); ``` #### Inherited from [`API`](../internal/interfaces/API.md).[`getConfig`](../internal/interfaces/API.md#getconfig) #### Defined in [src/sdk/models.ts:1473](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1473) *** ### getShareUrl() > **getShareUrl**: (`shortUrl`?) => `Promise`\<`string`\> Gets a [share url](https://livecodes.io/docs/features/share) for the current project. By default, the url has a long query string representing the compressed encoded config object. If the argument `shortUrl` was set to `true`, a short url is generated. #### Parameters • **shortUrl?**: `boolean` #### Returns `Promise`\<`string`\> #### Example ```ts import { createPlayground } from "livecodes"; createPlayground("#container").then(async (playground) => { const longUrl = await playground.getShareUrl(); const shortUrl = await playground.getShareUrl(true); }); ``` #### Inherited from [`API`](../internal/interfaces/API.md).[`getShareUrl`](../internal/interfaces/API.md#getshareurl) #### Defined in [src/sdk/models.ts:1457](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1457) *** ### load() > **load**: () => `Promise`\<`void`\> Loads the playground, if not already loaded. When the embed option [loading](https://livecodes.io/docs/sdk/js-ts#loading) is set to `"click"`, the playground is not loaded automatically. Instead, a screen is shown with "Click to load" button. Calling the SDK method `load()` allows loading the playground. If the playground was not loaded, calling any other method will load the playground first before executing. #### Returns `Promise`\<`void`\> #### Defined in [src/sdk/models.ts:1643](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1643) *** ### ~~onChange()~~ > **onChange**: (`fn`) => `object` Runs a callback function when code changes. #### Parameters • **fn** #### Returns `object` ##### ~~remove()~~ > **remove**: () => `void` ###### Returns `void` #### Deprecated Use [`watch`](https://livecodes.io/docs/sdk/js-ts#watch) method instead. #### Inherited from [`API`](../internal/interfaces/API.md).[`onChange`](../internal/interfaces/API.md#onchange) #### Defined in [src/sdk/models.ts:1555](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1555) *** ### run() > **run**: () => `Promise`\<`void`\> Runs the [result page](https://livecodes.io/docs/features/result) (after any required compilation for code). #### Returns `Promise`\<`void`\> #### Example ```ts import { createPlayground } from "livecodes"; createPlayground("#container").then(async (playground) => { await playground.run(); // new result page is displayed }); ``` #### Inherited from [`API`](../internal/interfaces/API.md).[`run`](../internal/interfaces/API.md#run) #### Defined in [src/sdk/models.ts:1423](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1423) *** ### runTests() > **runTests**: () => `Promise`\<`object`\> Runs project [tests](https://livecodes.io/docs/features/tests) (if present) and gets test results. #### Returns `Promise`\<`object`\> ##### results > **results**: [`TestResult`](../internal/interfaces/TestResult.md)[] #### Example ```ts import { createPlayground } from "livecodes"; createPlayground("#container").then(async (playground) => { const { results } = await playground.runTests(); }); ``` #### Inherited from [`API`](../internal/interfaces/API.md).[`runTests`](../internal/interfaces/API.md#runtests) #### Defined in [src/sdk/models.ts:1548](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1548) *** ### setConfig() > **setConfig**: (`config`) => `Promise`\<[`Config`](Config.md)\> Loads a new project using the passed configuration object. If the config is a string, it is assumed to be a URL to a JSON file that contains the configuration object. #### Parameters • **config**: `string` \| `Partial`\<[`Config`](Config.md)\> #### Returns `Promise`\<[`Config`](Config.md)\> #### Throws It throws an error if the config object (or URL) is invalid. #### Example ```ts import { createPlayground } from "livecodes"; createPlayground("#container").then(async (playground) => { const config = { markup: { language: "html", content: "Hello World!", }, }; const newConfig = await playground.setConfig(config); // new project loaded }); ``` #### Inherited from [`API`](../internal/interfaces/API.md).[`setConfig`](../internal/interfaces/API.md#setconfig) #### Defined in [src/sdk/models.ts:1497](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1497) *** ### show() > **show**: (`panel`, `options`?) => `Promise`\<`void`\> Shows the selected panel. See [docs](https://livecodes.io/docs/sdk/js-ts#show) for details. #### Parameters • **panel**: `"editor"` \| `"result"` \| [`EditorId`](../internal/type-aliases/EditorId.md) \| [`ToolName`](../internal/type-aliases/ToolName.md) \| `"toggle-result"` • **options?** • **options.column?**: `number` • **options.full?**: `boolean` • **options.line?**: `number` • **options.zoom?**: `1` \| `0.5` \| `0.25` #### Returns `Promise`\<`void`\> #### Example ```ts await playground.show("style"); await playground.show("toggle-result"); await playground.show("result", { full: true }); await playground.show("script"); await playground.show("result", { zoom: 0.5 }); await playground.show("console", { full: true }); ``` #### Inherited from [`API`](../internal/interfaces/API.md).[`show`](../internal/interfaces/API.md#show) #### Defined in [src/sdk/models.ts:1532](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1532) *** ### watch > **watch**: [`WatchLoad`](../internal/type-aliases/WatchLoad.md) & [`WatchReady`](../internal/type-aliases/WatchReady.md) & [`WatchCode`](../internal/type-aliases/WatchCode.md) & [`WatchRun`](../internal/type-aliases/WatchRun.md) & [`WatchConsole`](../internal/type-aliases/WatchConsole.md) & [`WatchTests`](../internal/type-aliases/WatchTests.md) & [`WatchDestroy`](../internal/type-aliases/WatchDestroy.md) Allows to watch for various playground events. It takes 2 arguments: event name and a callback function that will be called on every event. event name can be one of: `"load" | "ready" | "code" | "run" | "console" | "tests" | "destroy"` In some events, the callback function will be called with an object that supplies relevant data to the callback function (e.g. code, console output, test results). The watch method returns an object with a single method (`remove`), which when called will remove the callback from watching further events. See [docs](https://livecodes.io/docs/sdk/js-ts#watch) for details. #### Example ```ts import { createPlayground } from "livecodes"; createPlayground("#container").then((playground) => { const codeWatcher = playground.watch("code", ({ code, config }) => { // this will run on every code change console.log("code:", code); console.log("config:", config); }); const consoleWatcher = playground.watch("console", ({ method, args }) => { // this will run on every console output console[method](...args); }); const testsWatcher = playground.watch("tests", ({ results }) => { // this will run when tests run results.forEach((testResult) => { console.log("status:", testResult.status); // "pass", "fail" or "skip" console.log(testResult.errors); // array of errors as strings }); }); // then later codeWatcher.remove(); consoleWatcher.remove(); testsWatcher.remove(); // events are no longer watched }); ``` #### Inherited from [`API`](../internal/interfaces/API.md).[`watch`](../internal/interfaces/API.md#watch) #### Defined in [src/sdk/models.ts:1600](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L1600) --- # Type Alias: Language > **Language**: `"html"` \| `"htm"` \| `"markdown"` \| `"md"` \| `"mdown"` \| `"mkdn"` \| `"mdx"` \| `"astro"` \| `"pug"` \| `"jade"` \| `"haml"` \| `"asciidoc"` \| `"adoc"` \| `"asc"` \| `"mustache"` \| `"handlebars"` \| `"hbs"` \| `"ejs"` \| `"eta"` \| `"nunjucks"` \| `"njk"` \| `"liquid"` \| `"liquidjs"` \| `"dot"` \| `"twig"` \| `"vento"` \| `"vto"` \| `"art-template"` \| `"art"` \| `"jinja"` \| `"bbcode"` \| `"bb"` \| `"mjml"` \| `"diagrams"` \| `"diagram"` \| `"graph"` \| `"plt"` \| `"richtext"` \| `"rte"` \| `"rich"` \| `"rte.html"` \| `"css"` \| `"scss"` \| `"sass"` \| `"less"` \| `"stylus"` \| `"styl"` \| `"stylis"` \| `"postcss"` \| `"javascript"` \| `"js"` \| `"mjs"` \| `"json"` \| `"babel"` \| `"es"` \| `"sucrase"` \| `"typescript"` \| `"flow"` \| `"ts"` \| `"mts"` \| `"jsx"` \| `"tsx"` \| `"react"` \| `"react-jsx"` \| `"react.jsx"` \| `"react-tsx"` \| `"react.tsx"` \| `"react-native"` \| `"react-native.jsx"` \| `"react-native-tsx"` \| `"react-native.tsx"` \| `"vue"` \| `"vue3"` \| `"vue2"` \| `"vue-app"` \| `"app.vue"` \| `"svelte"` \| `"svelte-app"` \| `"app.svelte"` \| `"stencil"` \| `"stencil.tsx"` \| `"solid"` \| `"solid.jsx"` \| `"solid.tsx"` \| `"riot"` \| `"riotjs"` \| `"malina"` \| `"malinajs"` \| `"ripple"` \| `"ripplejs"` \| `"xht"` \| `"coffeescript"` \| `"coffee"` \| `"livescript"` \| `"ls"` \| `"civet"` \| `"clio"` \| `"imba"` \| `"assemblyscript"` \| `"as"` \| `"python"` \| `"py"` \| `"pyodide"` \| `"python-wasm"` \| `"py-wasm"` \| `"pythonwasm"` \| `"pywasm"` \| `"py3"` \| `"wasm.py"` \| `"r"` \| `"rlang"` \| `"rstats"` \| `"r-wasm"` \| `"ruby"` \| `"rb"` \| `"ruby-wasm"` \| `"wasm.rb"` \| `"rubywasm"` \| `"go"` \| `"golang"` \| `"go-wasm"` \| `"wasm.go"` \| `"gowasm"` \| `"php"` \| `"php-wasm"` \| `"phpwasm"` \| `"wasm.php"` \| `"cpp"` \| `"c"` \| `"C"` \| `"cp"` \| `"cxx"` \| `"c++"` \| `"cppm"` \| `"ixx"` \| `"ii"` \| `"hpp"` \| `"h"` \| `"cpp-wasm"` \| `"cppwasm"` \| `"cwasm"` \| `"wasm.cpp"` \| `"clang"` \| `"clang.cpp"` \| `"java"` \| `"csharp"` \| `"csharp-wasm"` \| `"cs"` \| `"cs-wasm"` \| `"wasm.cs"` \| `"perl"` \| `"pl"` \| `"pm"` \| `"lua"` \| `"lua-wasm"` \| `"luawasm"` \| `"wasm.lua"` \| `"teal"` \| `"tl"` \| `"fennel"` \| `"fnl"` \| `"julia"` \| `"jl"` \| `"scheme"` \| `"scm"` \| `"commonlisp"` \| `"common-lisp"` \| `"lisp"` \| `"clojurescript"` \| `"clojure"` \| `"cljs"` \| `"clj"` \| `"cljc"` \| `"edn"` \| `"gleam"` \| `"swift"` \| `"rescript"` \| `"res"` \| `"resi"` \| `"reason"` \| `"re"` \| `"rei"` \| `"ocaml"` \| `"ml"` \| `"mli"` \| `"tcl"` \| `"wat"` \| `"wast"` \| `"webassembly"` \| `"wasm"` \| `"Binary"` \| `"sql"` \| `"sqlite"` \| `"sqlite3"` \| `"pg.sql"` \| `"pgsql.sql"` \| `"pgsql"` \| `"pg"` \| `"pglite"` \| `"pglite.sql"` \| `"postgresql"` \| `"postgres"` \| `"postgre.sql"` \| `"postgresql.sql"` \| `"prolog.pl"` \| `"prolog"` \| `"minizinc"` \| `"mzn"` \| `"dzn"` \| `"blockly"` \| `"blockly.xml"` \| `"xml"` \| `"pintora"` Language name, alias or extension. ## Defined in [src/sdk/models.ts:32](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/models.ts#L32) --- # Function: compress() > **compress**(`uncompressed`): `string` A utility function that allows compressing the stringified config object (e.g. for sharing in URL hash) It encodes it in base64 with a few tweaks to make it URI safe. This is the `compressToEncodedURIComponent` function re-exported from `lz-string` for convenience. ## Parameters • **uncompressed**: `string` A string which should be compressed. ## Returns `string` The compressed string ## Param The string to be compressed (e.g. stringified config object) ## Example ```ts const compressed = compress(JSON.stringify(config)); ``` ## Defined in [src/sdk/index.ts:527](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/index.ts#L527) --- # Function: createPlayground() ## createPlayground(container, options) > **createPlayground**(`container`, `options`?): `Promise`\<[`Playground`](../interfaces/Playground.md)\> Creates a LiveCodes playground. ### Parameters • **container**: `string` \| `HTMLElement` `HTMLElement` or a string representing a CSS selector. This is the container where the playground is rendered. If not found, an error is thrown (except in [headless mode](https://livecodes.io/docs/sdk/headless), in which this parameter is optional and can be omitted). • **options?**: [`EmbedOptions`](../interfaces/EmbedOptions.md) The [embed options](https://livecodes.io/docs/sdk/js-ts#embed-options) for the playground (optional). ### Returns `Promise`\<[`Playground`](../interfaces/Playground.md)\> A promise that resolves to a [`Playground`](https://livecodes.io/docs/api/interfaces/Playground/) object which exposes many [SDK methods](https://livecodes.io/docs/sdk/js-ts/#sdk-methods) that can be used to interact with the playground. ### Defined in [src/sdk/index.ts:36](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/index.ts#L36) ## createPlayground(options) > **createPlayground**(`options`): `Promise`\<[`Playground`](../interfaces/Playground.md)\> ### Parameters • **options**: [`EmbedOptions`](../interfaces/EmbedOptions.md) & `object` ### Returns `Promise`\<[`Playground`](../interfaces/Playground.md)\> ### Defined in [src/sdk/index.ts:40](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/index.ts#L40) --- # Function: decompress() > **decompress**(`compressed`): `null` \| `string` A utility function that allows decompressing the config object (compressed by [compress](compress.md)). It decodes it to a string that should be JSON.parsed. This is the `decompressFromEncodedURIComponent` function re-exported from `lz-string` for convenience. ## Parameters • **compressed**: `string` A string obtained from a call to compressToEncodedURIComponent(). ## Returns `null` \| `string` The decompressed string or `null` if it fails ## Param The string to be decompressed ## Example ```ts const decompressed = decompress(str); if (decompressed) { try { const config = JSON.parse(decompressed); } catch { // invalid JSON } } ``` ## Defined in [src/sdk/index.ts:550](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/index.ts#L550) --- # Function: getPlaygroundUrl() > **getPlaygroundUrl**(`options`): `string` Gets the URL to a LiveCodes playground (as a string) from the provided [options](https://livecodes.io/docs/sdk/js-ts#embed-options). This can be useful for providing links to run code in playgrounds. ## Parameters • **options**: [`EmbedOptions`](../interfaces/EmbedOptions.md) = `{}` The [options](https://livecodes.io/docs/sdk/js-ts#embed-options) for the playground. ## Returns `string` The URL of the playground (as a string). large objects like config and params are store in the url hash params while the rest are in the search params unless config is a string in which case it is stored in searchParams ## Defined in [src/sdk/index.ts:413](https://github.com/live-codes/livecodes/blob/cfa7c354fc07759804cebebdb94016b70a906821/src/sdk/index.ts#L413)