Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
bc94651
upgrade node version
hatemhosny Jul 9, 2025
0b1c2eb
refactor vendors.ts to use `getUrl` & file extensions
hatemhosny Jul 9, 2025
70c7587
optimize vendor urls for download
hatemhosny Jul 10, 2025
1755888
change fonts to use BaseUrl
hatemhosny Jul 10, 2025
30d7f4e
upgrade pyodide to v0.28.0
hatemhosny Jul 10, 2025
333fc73
update opal to use gh CDN
hatemhosny Jul 10, 2025
fb27850
build(self-hosting): allow downloading modules during build
hatemhosny Jul 10, 2025
37ad7fa
fix
hatemhosny Jul 12, 2025
ef0f858
retry downloading failed modules
hatemhosny Jul 13, 2025
94f3fad
build(self-hosting): download modules
hatemhosny Jul 14, 2025
0f6c8fe
handle appCDN when using local modules
hatemhosny Jul 16, 2025
8a64e49
handle module cache by docker
hatemhosny Jul 16, 2025
0263245
use self-hosted URL in build
hatemhosny Jul 16, 2025
6ed47d5
download modules in parallel
hatemhosny Jul 16, 2025
9bbf100
fix
hatemhosny Jul 16, 2025
e65f703
add docs for local modules
hatemhosny Jul 16, 2025
6f876a0
set LOCAL_MODULES to false by default
hatemhosny Jul 16, 2025
bddae1b
fix
hatemhosny Jul 16, 2025
52213b9
upgrade to node v24.4.1
hatemhosny Jul 17, 2025
adc6098
fix
hatemhosny Jul 17, 2025
cc5cb78
add in docker NODE_OPTIONS="--max-old-space-size=4096"
hatemhosny Jul 18, 2025
21b47b8
fix
hatemhosny Jul 18, 2025
0343cbf
fix
hatemhosny Jul 20, 2025
8f45b35
avoid using node sync methods
hatemhosny Jul 27, 2025
3cb3b25
fixes
hatemhosny Jul 27, 2025
48a9dd6
fix color picker
hatemhosny Aug 2, 2025
79828e6
Merge branch 'develop' into local-modules
hatemhosny Aug 23, 2025
8b5d433
fix
hatemhosny Aug 23, 2025
169fd55
Merge branch 'develop' into local-modules
hatemhosny Aug 28, 2025
3531576
init
Muhammad-Ayman Sep 1, 2025
0178064
lint:prettier
Muhammad-Ayman Sep 1, 2025
d4da641
restore templates.js
Muhammad-Ayman Sep 1, 2025
4cc3352
fix rating issues
Muhammad-Ayman Sep 2, 2025
419a690
fix test
Muhammad-Ayman Sep 2, 2025
b2bba60
give up on e2e XD
Muhammad-Ayman Sep 2, 2025
419cd4d
fix the β€œruns once only” behavior
Muhammad-Ayman Sep 3, 2025
eecb75f
fix Quality Gate
Muhammad-Ayman Sep 3, 2025
f865ca5
test:lint
Muhammad-Ayman Sep 3, 2025
0719401
edit go-wasm script
hatemhosny Sep 3, 2025
f05fe7f
fixes
hatemhosny Sep 3, 2025
d9443b7
Merge pull request #1 from live-codes/go-wasm
Muhammad-Ayman Sep 8, 2025
cd349bd
Merge branch 'develop' into Feature_Support_Go_wasm
hatemhosny Sep 8, 2025
3a78ade
Stdin Buffer Management
Muhammad-Ayman Sep 10, 2025
9208fb8
JavaScript gets current count from Ui
Muhammad-Ayman Sep 10, 2025
8e77243
fix Loading... issue
Muhammad-Ayman Sep 10, 2025
169f23c
finish the starter
Muhammad-Ayman Sep 10, 2025
b5e57a8
add info
Muhammad-Ayman Sep 11, 2025
af05c0b
Merge branch 'develop' into Feature_Support_Go_wasm
hatemhosny Sep 13, 2025
2fb2d3d
minor edits
hatemhosny Sep 14, 2025
f156468
add docs for go & go-wasm
hatemhosny Sep 14, 2025
b59fff5
add licenses
hatemhosny Sep 14, 2025
e49863f
Yaegi WebAssembly - Guide
Muhammad-Ayman Sep 15, 2025
2536438
Merge branch 'develop' into Feature_Support_Go_wasm
hatemhosny Sep 15, 2025
9482640
Revert "Yaegi WebAssembly - Guide"
Muhammad-Ayman Sep 17, 2025
7b87bee
add link to `yaegi-wasm` repo and license
hatemhosny Sep 18, 2025
cadba67
run `i18n-export`
hatemhosny Sep 18, 2025
cec4187
Merge branch 'develop' into local-modules
hatemhosny Sep 20, 2025
b6d5d35
docs(Compilers): add docs for markdown support
hatemhosny Sep 21, 2025
ea0ae9d
docs(Compilers): add docs for mdx support
hatemhosny Sep 21, 2025
2d1dbc9
Merge pull request #874 from live-codes/add-language-docs
hatemhosny Sep 21, 2025
69c83da
Merge branch 'develop' into Feature_Support_Go_wasm
hatemhosny Sep 22, 2025
422c649
Merge pull request #866 from Muhammad-Ayman/Feature_Support_Go_wasm
hatemhosny Sep 22, 2025
2532f23
feat(Config): set config objects in query params
hatemhosny Sep 23, 2025
596462d
fix
hatemhosny Sep 23, 2025
5908cae
Merge pull request #876 from live-codes/config-objects-in-params
hatemhosny Sep 23, 2025
8a0bd4a
i18n: pull translation from Lokalise
livecodes-ci[bot] Sep 23, 2025
2ac1d64
i18n: pull translation from Lokalise
livecodes-ci[bot] Sep 23, 2025
7e3653f
Merge branch 'develop' into i18n/Muhammad-Ayman/Feature_Support_Go_wasm
hatemhosny Sep 23, 2025
341c5d5
Merge pull request #877 from live-codes/i18n/Muhammad-Ayman/Feature_S…
hatemhosny Sep 23, 2025
9719c9a
make `Config.Editor.language` optional
hatemhosny Sep 23, 2025
968e2a5
fix test
hatemhosny Sep 23, 2025
b46f8ca
Merge pull request #878 from live-codes/fix-validate-config
hatemhosny Sep 23, 2025
5eca80e
fix(Compilers): do not add Tailwind compiled CSS in code blocks
hatemhosny Sep 24, 2025
b206b43
Merge pull request #879 from live-codes/tailwind-blocks
hatemhosny Sep 24, 2025
1f0292c
fix(Config): fix updating editor config
hatemhosny Sep 24, 2025
1ac5860
Merge pull request #880 from live-codes/fix-updating-editor-config
hatemhosny Sep 24, 2025
79b4a70
fix(SDK): fix `height` in Vue SDK
hatemhosny Sep 24, 2025
98837f6
Merge pull request #881 from live-codes/fix-vue-sdk-height
hatemhosny Sep 24, 2025
b717efc
fix(Config): fix changing editor config from SDK
hatemhosny Sep 26, 2025
69cf99d
fix
hatemhosny Sep 26, 2025
f58ca11
fix content-only update from SDK
hatemhosny Sep 27, 2025
5b0ba07
fix
hatemhosny Sep 27, 2025
ba8ceff
Merge pull request #882 from live-codes/fix-changing-editor-config
hatemhosny Sep 27, 2025
f077639
fix(Editor): do not show lineNumbers in console editor
hatemhosny Sep 27, 2025
2d6fa4c
fix
hatemhosny Sep 27, 2025
6e0ee57
Merge pull request #883 from live-codes/fix-console-line-numbers
hatemhosny Sep 27, 2025
68796ad
upgrade node version
hatemhosny Sep 28, 2025
638c272
refactor vendors.ts to use `getUrl` & file extensions
hatemhosny Sep 28, 2025
3247d66
optimize vendor urls for download
hatemhosny Sep 28, 2025
21f79ca
change fonts to use BaseUrl
hatemhosny Sep 28, 2025
833cfe6
upgrade pyodide to v0.28.0
hatemhosny Sep 28, 2025
b558ed3
update opal to use gh CDN
hatemhosny Sep 28, 2025
1775f04
build(self-hosting): allow downloading modules during build
hatemhosny Sep 28, 2025
6cdd67d
fix
hatemhosny Sep 28, 2025
b57c2c7
retry downloading failed modules
hatemhosny Sep 28, 2025
60c479d
build(self-hosting): download modules
hatemhosny Sep 28, 2025
c8545d4
handle appCDN when using local modules
hatemhosny Sep 28, 2025
9d70ab7
handle module cache by docker
hatemhosny Sep 28, 2025
a8814f0
use self-hosted URL in build
hatemhosny Sep 28, 2025
9cc2d1a
download modules in parallel
hatemhosny Sep 28, 2025
cfa402c
fix
hatemhosny Sep 28, 2025
72e8c86
add docs for local modules
hatemhosny Sep 28, 2025
07c9dd6
set LOCAL_MODULES to false by default
hatemhosny Sep 28, 2025
fbc7a79
fix
hatemhosny Sep 28, 2025
19d24fe
upgrade to node v24.4.1
hatemhosny Sep 28, 2025
8825cc3
fix
hatemhosny Sep 28, 2025
27bd81d
add in docker NODE_OPTIONS="--max-old-space-size=4096"
hatemhosny Sep 28, 2025
6689efb
fix
hatemhosny Sep 28, 2025
f98246c
fix
hatemhosny Sep 28, 2025
2fbbafe
avoid using node sync methods
hatemhosny Sep 28, 2025
7b8a0ee
fixes
hatemhosny Sep 28, 2025
4f6dd51
fix color picker
hatemhosny Sep 28, 2025
ce9293b
fix
hatemhosny Sep 28, 2025
e11fc0d
Merge branch 'local-modules' of https://github.com/live-codes/livecod…
hatemhosny Sep 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18.20.4
v24.4.1
20 changes: 16 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:24.1.0-alpine3.21 AS builder
FROM node:24.4.1-alpine3.22 AS builder

RUN apk update --no-cache && apk add --no-cache git

Expand All @@ -11,23 +11,35 @@ COPY server/package*.json server/

RUN npm ci

COPY . .

ARG SELF_HOSTED
ARG HOST_NAME
ARG PORT
ARG SELF_HOSTED_SHARE
ARG SELF_HOSTED_BROADCAST
ARG BROADCAST_PORT
ARG SANDBOX_HOST_NAME
ARG SANDBOX_PORT
ARG FIREBASE_CONFIG
ARG DOCS_BASE_URL
ARG LOCAL_MODULES
ARG NODE_OPTIONS

COPY scripts/download-modules.js scripts/
COPY src/livecodes/vendors.ts src/livecodes/
COPY src/sdk/package.sdk.json src/sdk/

RUN if [ "$LOCAL_MODULES" == "true" ]; \
then npm run download-modules; \
fi

COPY . .

RUN if [ "$DOCS_BASE_URL" == "null" ]; \
then npm run build:app; \
else npm run build; \
fi

FROM node:24.1.0-alpine3.21 AS server
FROM node:24.4.1-alpine3.22 AS server

RUN addgroup -S appgroup
RUN adduser -S appuser -G appgroup
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ A [feature-rich](https://livecodes.io/docs/features/), open-source, **client-sid
[![LiveCodes: npm version](https://img.shields.io/npm/v/livecodes)](https://www.npmjs.com/package/livecodes)
[![LiveCodes: npm downloads](https://img.shields.io/npm/dm/livecodes)](https://www.npmjs.com/package/livecodes)
[![LiveCodes: jsdelivr downloads](https://data.jsdelivr.com/v1/package/npm/livecodes/badge?style=rounded)](https://www.jsdelivr.com/package/npm/livecodes)
[![LiveCodes: languages](https://img.shields.io/badge/languages-96-blue)](https://livecodes.io/docs/languages/)
[![LiveCodes: languages](https://img.shields.io/badge/languages-97-blue)](https://livecodes.io/docs/languages/)
[![LiveCodes: docs](https://img.shields.io/badge/Documentation-575757?logo=gitbook&logoColor=white)](https://livecodes.io/docs/)
[![LiveCodes: llms.txt](https://img.shields.io/badge/llms.txt-575757?logo=googledocs&logoColor=white)](https://livecodes.io/docs/llms.txt)
[![LiveCodes: llms-full.txt](https://img.shields.io/badge/llms--full.txt-575757?logo=googledocs&logoColor=white)](https://livecodes.io/docs/llms-full.txt)
Expand Down
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ services:
dockerfile: Dockerfile
args:
- SELF_HOSTED=true
- HOST_NAME=${HOST_NAME:-livecodes.localhost}
- PORT=${PORT:-443}
- SELF_HOSTED_SHARE=${SELF_HOSTED_SHARE:-true}
- SELF_HOSTED_BROADCAST=${SELF_HOSTED_BROADCAST:-true}
- BROADCAST_PORT=${BROADCAST_PORT:-3030}
- SANDBOX_HOST_NAME=${SANDBOX_HOST_NAME:-${HOST_NAME:-livecodes.localhost}}
- SANDBOX_PORT=${SANDBOX_PORT:-8090}
- FIREBASE_CONFIG=${FIREBASE_CONFIG:-}
- DOCS_BASE_URL=${DOCS_BASE_URL:-null}
- LOCAL_MODULES=${LOCAL_MODULES:-false}
- NODE_OPTIONS=--max-old-space-size=4096
restart: unless-stopped
environment:
- SELF_HOSTED=true
Expand All @@ -26,6 +30,7 @@ services:
- LOG_URL=${LOG_URL:-null}
- VALKEY_HOST=valkey
- VALKEY_PORT=6379
- NODE_OPTIONS=--max-old-space-size=4096
volumes:
- ./assets:/srv/build/assets
depends_on:
Expand Down
47 changes: 47 additions & 0 deletions docs/docs/advanced/docker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,56 @@ The hostname and many other options can be set using [environment variables](#en

Runs code in a separate origin [sandboxed iframe](https://www.html5rocks.com/en/tutorials/security/sandboxed-iframes/) to prevent cross-site scripting.

- Local modules

See [Local Modules](#local-modules) section for details.

- [404 page](https://livecodes.io/404)

Custom 404 page for resources that are not found.

## Local Modules

(EXPERIMENTAL)

LiveCodes depends on a large number of external modules to support a wide range of features (e.g. code editors, compilers, formatters, etc).
These modules are loaded from CDNs (e.g. [jsDelivr](https://www.jsdelivr.com/), [unpkg](https://unpkg.com/), etc).
So, in spite of being a client-side app, LiveCodes requires an internet connection to load these modules.

However, if you want to be able to run LiveCodes without an internet connection, you can download all these modules locally by setting the [environment variable](#environment-variables) `LOCAL_MODULES=true` (it is set to `false` by default).
In this case, all modules are downloaded during build (~ 1.5 GB), and are served locally.

When working without internet connection, all resources have to be available locally. So, automatic [module resolution](../features/module-resolution.mdx) (e.g. of npm modules imported in user code) and loading type definitions for [intellisense](../features/intellisense.mdx) and auto-complete will not work out of the box.
However, you can provide the list of modules to load using the [`imports`](../configuration/configuration-object.mdx#imports) property of the [config](../configuration/configuration-object.mdx) object (see [Custom Module Resolution](../features/module-resolution.mdx#custom-module-resolution)).
Similarly, you can also provide the list of type definitions to load using the [`types`](../configuration/configuration-object.mdx#types) property (see [Custom Types](../features/intellisense.mdx#custom-types)).
These modules and type definitions should be prepared in advance and made available to the running app (e.g. in the `/assets` directory - see [Volumes](#volumes)).

Example:

To run [React starter template](https://livecodes.io/?template=react) locally without internet connection, you need to:

(assuming that the app is running on this URL: https://livecodes.localhost/)

- Add [these files](https://github.com/hatemhosny/custom-modules-demo/tree/main/modules) to the [`/assets` directory](#volumes).
- Open React starter template: https://livecodes.localhost/?template=react
- Add this code to custom settings (Project menu β†’ Custom Settings):

```json
{
"imports": {
"react": "https://livecodes.localhost/assets/react.js",
"react/compiler-runtime": "https://livecodes.localhost/assets/react-compiler-runtime.js",
"react/jsx-runtime": "https://livecodes.localhost/assets/react-jsx-runtime.js",
"react-dom": "https://livecodes.localhost/assets/react-dom.js",
"react-dom/client": "https://livecodes.localhost/assets/react-dom-client.js",
"scheduler": "https://livecodes.localhost/assets/scheduler.js"
},
"types": {
"react": "https://livecodes.localhost/assets/react.d.ts"
}
}
```

## Environment Variables

The app can be customized by setting different environment variables.
Expand Down Expand Up @@ -205,6 +251,7 @@ The following environment variables are supported:
| `FIREBASE_CONFIG` | [Firebase config object](https://firebase.google.com/docs/web/learn-more#config-object) (JSON), used for [authentication](../features/github-integration.mdx) | |
| `DOCS_BASE_URL` | [Base URL](../features/self-hosting.mdx#custom-build) of the documentation (e.g. `/docs/`) | `null` |
| `LOG_URL` | Full URL to send [server-side analytics](https://github.com/live-codes/livecodes/blob/develop/functions/index.ts) (e.g. `https://api.website.com/log`) | `null` |
| `LOCAL_MODULES` | Download and use all modules locally (see [Local Modules](#local-modules)) | `false` |

:::info note
When running in a non-local environment (e.g. VPS),
Expand Down
93 changes: 93 additions & 0 deletions docs/docs/languages/go-wasm.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Go (Wasm)

[Go](https://go.dev/) (Golang), is an open-source, statically typed, and compiled programming language developed by Google. It is designed for simplicity, efficiency, and strong support for concurrency, making it well-suited for building scalable and high-performance applications.

LiveCodes uses [Yaegi](https://github.com/traefik/yaegi), the Go interpreter (running on WebAssembly), to run Go in the browser.

:::info Note

LiveCodes also supports running Go using [GopherJS](https://github.com/gopherjs/gopherjs) which is a Go to JavaScript compiler. Read documentation [here](./go.mdx).

:::

## Demo

import LiveCodes from '../../src/components/LiveCodes.tsx';

export const params = {
'go-wasm': 'package main\n\nimport "fmt"\n\nfunc main() {\n\tfmt.Println("Hello, World!")\n}\n',
console: 'full',
};

<LiveCodes params={params}></LiveCodes>

## Usage

LiveCodes runs Go in the browser, including the [standard library](https://pkg.go.dev/std).


### Communication with JavaScript

The Go code runs in the context of the [result page](../features/result.mdx).
A few helper properties and methods are available in the browser global `livecodes.goWasm` object:

- `livecodes.goWasm.input`: the initial standard input that is passed to the Go code.
- `livecodes.goWasm.loaded`: A promise that resolves when the Go environment is loaded. Any other helpers should be used after this promise resolves.
- `livecodes.goWasm.output`: the standard output.
- `livecodes.goWasm.error`: the standard error.
- `livecodes.goWasm.exitCode`: the exit code.
- `livecodes.goWasm.run`: a function that runs the Go code with new input. This function takes a string as input and returns a promise that resolves when the Go code is done running. The promise resolves with an object containing the `input`, `output`, `error`, and `exitCode` properties.

See the [example below](#example-usage) for more details.

## Language Info

### Name

`go-wasm`

### Extensions

`wasm.go`, `go-wasm`, `gowasm`

### Editor

`script`

## Compiler

[Yaegi](https://github.com/traefik/yaegi), compiled to WebAssembly ([yaegi-wasm](https://github.com/Muhammad-Ayman/yaegi-wasm))

### Version

Yaegi v0.16.1, running go1.25.0

## Code Formatting

Using [GopherJS](https://github.com/gopherjs/gopherjs)

## Example Usage

This example demonstrates standard library usage and JavaScript interoperability (also check the code in the HTML editor):

<LiveCodes template="go-wasm" height="80vh"></LiveCodes>


## Live Reload

By default, new code changes are sent to the result page for re-evaluation without a full page reload, to avoid the need to reload the Go environment.

This behavior can be disabled by adding the code comment `// __livecodes_reload__` to the code, which will force a full page reload.
This comment can be added in the [`hiddenContent` property of the editor](../configuration/configuration-object.mdx#markup) for embedded playgrounds.

## Starter Template

https://livecodes.io/?template=go-wasm

## Links

- [Go](https://go.dev/)
- [Go documentation](https://go.dev/doc/)
- [Go standard library](https://pkg.go.dev/std)
- [Yaegi](https://github.com/traefik/yaegi)
- [Go using GopherJS](./go.mdx) in LiveCodes
71 changes: 70 additions & 1 deletion docs/docs/languages/go.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,72 @@
# Go (Golang)

TODO...
[Go](https://go.dev/) (Golang), is an open-source, statically typed, and compiled programming language developed by Google. It is designed for simplicity, efficiency, and strong support for concurrency, making it well-suited for building scalable and high-performance applications.

LiveCodes uses [GopherJS](https://github.com/gopherjs/gopherjs) which is a Go to JavaScript compiler, to run Go in the browser.

:::info Note

LiveCodes also supports running Go using [Yaegi](https://github.com/traefik/yaegi), the Go interpreter (running on WebAssembly). Read documentation [here](./go-wasm.mdx).

:::

## Demo

import LiveCodes from '../../src/components/LiveCodes.tsx';

export const params = {
'go': 'package main\n\nimport "fmt"\n\nfunc main() {\n\tfmt.Println("Hello, World!")\n}\n',
console: 'full',
};

<LiveCodes params={params}></LiveCodes>

## Usage

LiveCodes runs Go in the browser, including the [standard library](https://pkg.go.dev/std).

JavaScript interoperability and DOM access is achieved using [package `js`](https://pkg.go.dev/syscall/js) (see the [example below](#example-usage)).

## Language Info

### Name

`go`

### Extensions

`go`, `golang`

### Editor

`script`

## Compiler

[GopherJS](https://github.com/gopherjs/gopherjs), the Go to JavaScript compiler.

### Version

GopherJS v1.19.0 beta1, running Go 1.19.13

## Code Formatting

Using [GopherJS](https://github.com/gopherjs/gopherjs)

## Example Usage

This example demonstrates standard library usage, JavaScript interoperability and DOM access:

<LiveCodes template="go" height="80vh"></LiveCodes>

## Starter Template

https://livecodes.io/?template=go

## Links

- [Go](https://go.dev/)
- [Go documentation](https://go.dev/doc/)
- [Go standard library](https://pkg.go.dev/std)
- [GopherJS](https://github.com/gopherjs/gopherjs)
- [Go using Yaegi](./go-wasm.mdx) in LiveCodes
Loading