Skip to content

Commit a7b3431

Browse files
authored
Merge pull request #812 from live-codes/develop
release sdk-v0.10.0
2 parents 293a641 + 51a2ffb commit a7b3431

101 files changed

Lines changed: 1471 additions & 131 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# package.json is formatted by package managers, so we ignore it here
22
package.json
33
src/modules
4+
**/*.mdx

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. See [standa
44

55
---
66

7+
## [sdk-v0.10.0](https://github.com/live-codes/livecodes/compare/sdk-v0.9.1...sdk-v0.10.0) (2025-04-25)
8+
9+
- encode & compress sdk params ([b49c1cb](https://github.com/live-codes/livecodes/commit/b49c1cb13642ce95f8d5a01214891b01261fc067))
10+
- add `csharp-wasm` language ([63164e8](https://github.com/live-codes/livecodes/commit/63164e8eda6336434e2240e06f0b7fecc3cef4d8))
11+
- add `java` language ([0ecb6b3](https://github.com/live-codes/livecodes/commit/0ecb6b378b1f302794b32b2991015013936f31b3))
12+
13+
---
14+
715
## [v44](https://github.com/live-codes/livecodes/compare/v43...v44) (2025-04-10)
816

917
### Highlights for this release

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ A [feature-rich](https://livecodes.io/docs/features/), open-source, **client-sid
1313
[![LiveCodes: npm version](https://img.shields.io/npm/v/livecodes)](https://www.npmjs.com/package/livecodes)
1414
[![LiveCodes: npm downloads](https://img.shields.io/npm/dm/livecodes)](https://www.npmjs.com/package/livecodes)
1515
[![LiveCodes: jsdelivr downloads](https://data.jsdelivr.com/v1/package/npm/livecodes/badge?style=rounded)](https://www.jsdelivr.com/package/npm/livecodes)
16-
[![LiveCodes: languages](https://img.shields.io/badge/languages-93-blue)](https://livecodes.io/docs/languages/)
16+
[![LiveCodes: languages](https://img.shields.io/badge/languages-94-blue)](https://livecodes.io/docs/languages/)
1717
[![LiveCodes: docs](https://img.shields.io/badge/Documentation-575757?logo=gitbook&logoColor=white)](https://livecodes.io/docs/)
1818
[![LiveCodes: llms.txt](https://img.shields.io/badge/llms.txt-575757?logo=googledocs&logoColor=white)](https://livecodes.io/docs/llms.txt)
1919
[![LiveCodes: llms-full.txt](https://img.shields.io/badge/llms--full.txt-575757?logo=googledocs&logoColor=white)](https://livecodes.io/docs/llms-full.txt)
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# C# (Wasm)
2+
3+
C# is a high-level, general-purpose, object-oriented programming language developed by Microsoft.
4+
5+
In LiveCodes, C# runs in the browser using Blazor WebAssembly with a WebAssembly-based .NET runtime.
6+
7+
## Usage
8+
9+
Demo:
10+
11+
12+
import LiveCodes from '../../src/components/LiveCodes.tsx';
13+
export const csharpConfig = {
14+
activeEditor: 'script',
15+
script: {
16+
language: 'csharp-wasm',
17+
content: `using System;
18+
19+
public class Program
20+
{
21+
public static void Main()
22+
{
23+
int[] sortedArray = { 1, 3, 5, 7, 9, 11, 13, 15 };
24+
int itemToSearch = 7;
25+
26+
int result = BinarySearch(sortedArray, 0, sortedArray.Length - 1, itemToSearch);
27+
28+
if (result == -1)
29+
{
30+
Console.WriteLine("Result: Item not found in the array.");
31+
}
32+
else
33+
{
34+
Console.WriteLine($"Result: Item found at index -> {result}");
35+
}
36+
}
37+
38+
public static int BinarySearch(int[] arr, int left, int right, int item)
39+
{
40+
if (right >= left)
41+
{
42+
int mid = left + (right - left) / 2;
43+
if (arr[mid] == item)
44+
{
45+
return mid;
46+
}
47+
48+
if (arr[mid] > item)
49+
{
50+
return BinarySearch(arr, left, mid - 1, item);
51+
}
52+
53+
return BinarySearch(arr, mid + 1, right, item);
54+
}
55+
return -1;
56+
}
57+
}`,
58+
},
59+
mode: 'simple',
60+
editor: 'auto',
61+
tools: {
62+
status: 'full',
63+
},
64+
};
65+
66+
<LiveCodes config={csharpConfig}></LiveCodes>
67+
68+
69+
### Communication with JavaScript
70+
71+
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:
72+
73+
- `livecodes.csharp.input`: The initial standard input passed to the C# code.
74+
- `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.
75+
- `livecodes.csharp.output`: The standard output from the C# code execution.
76+
- `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.
77+
78+
Example:
79+
80+
81+
<LiveCodes template="csharp-wasm" params={{ activeEditor: 'markup' }} height="80vh"></LiveCodes>
82+
83+
84+
## Language Info
85+
86+
### Name
87+
88+
`csharp-wasm`
89+
90+
### Aliases / Extensions
91+
92+
`cs`, `csharp`, `wasm.cs`, `cs-wasm`
93+
94+
### Editor
95+
96+
`script`
97+
98+
## Compiler
99+
100+
Blazor WebAssembly with .NET WebAssembly runtime.
101+
102+
### Version
103+
104+
.NET 9.0
105+
106+
## Code Formatting
107+
108+
using [Prettier](https://prettier.io/)
109+
110+
## Live Reload
111+
112+
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.
113+
114+
This comment can be added in the `hiddenContent` property of the editor for embedded playgrounds.
115+
116+
## Example Usage
117+
118+
```csharp
119+
using System;
120+
121+
public class Program
122+
{
123+
public static void Main()
124+
{
125+
Console.WriteLine("Hello, LiveCodes C#!");
126+
}
127+
}
128+
```
129+
130+
## Starter Template
131+
132+
https://livecodes.io/?template=csharp-wasm
133+
134+
## Links
135+
136+
- [C#](https://learn.microsoft.com/en-us/dotnet/csharp/)
137+
- [Blazor WebAssembly](https://dotnet.microsoft.com/en-us/apps/aspnet/web-apps/blazor)

docs/docs/languages/java.mdx

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Java
2+
3+
Java is a high-level, general-purpose, memory-safe, object-oriented programming language.
4+
5+
In LiveCodes, Java runs in the browser using [DoppioJVM](https://github.com/plasma-umass/doppio).
6+
7+
## Usage
8+
9+
Demo:
10+
11+
import LiveCodes from '../../src/components/LiveCodes.tsx';
12+
13+
export const javaConfig = {
14+
activeEditor: 'script',
15+
script: {
16+
language: 'java',
17+
content: `public class BinarySearchSnippet {
18+
/**
19+
* Search an item with binarySearch algorithm.
20+
*
21+
* @param arr sorted array to search
22+
* @param item an item to search
23+
* @return if item is found, return the index position of the array item otherwise return -1
24+
*/
25+
26+
public static int binarySearch(int[] arr, int left, int right, int item) {
27+
if (right >= left) {
28+
int mid = left + (right - left) / 2;
29+
if (arr[mid] == item) {
30+
return mid;
31+
}
32+
33+
if (arr[mid] > item) {
34+
return binarySearch(arr, left, mid - 1, item);
35+
}
36+
37+
return binarySearch(arr, mid + 1, right, item);
38+
}
39+
return -1;
40+
}
41+
42+
public static void main(String[] args) {
43+
int[] sortedArray = {1, 3, 5, 7, 9, 11, 13, 15};
44+
int itemToSearch = 7;
45+
46+
int result = binarySearch(sortedArray, 0, sortedArray.length - 1, itemToSearch);
47+
48+
if (result == -1) {
49+
System.out.println("Result: Item not found in the array.");
50+
} else {
51+
System.out.println("Result: Item found at index -> " + result);
52+
}
53+
}
54+
}
55+
`,
56+
},
57+
mode: 'simple',
58+
editor: 'auto',
59+
tools: {
60+
status: 'full',
61+
},
62+
};
63+
64+
<LiveCodes config={javaConfig}></LiveCodes>
65+
66+
### Communication with JavaScript
67+
68+
The Java code runs in the context of the [result page](../features/result.mdx).
69+
A few helper properties and methods are available in the browser global `livecodes.java` object:
70+
71+
- `livecodes.java.input`: the initial standard input that is passed to the Java code.
72+
- `livecodes.java.loaded`: A promise that resolves when the Java environment is loaded. Any other helpers should be used after this promise resolves.
73+
- `livecodes.java.output`: the standard output.
74+
- `livecodes.java.error`: the standard error.
75+
- `livecodes.java.exitCode`: the exit code.
76+
- `livecodes.java.run`: a function that runs the Java code with new input. This function takes a string as input and returns a promise that resolves when the Java code is done running. The promise resolves with an object containing the `input`, `output`, `error`, and `exitCode` properties.
77+
78+
Example:
79+
80+
<LiveCodes template="java" params={{ activeEditor: 'markup' }} height="80vh"></LiveCodes>
81+
82+
## Language Info
83+
84+
### Name
85+
86+
`java`
87+
88+
### Extension
89+
90+
`.java`
91+
92+
### Editor
93+
94+
`script`
95+
96+
## Compiler
97+
98+
[DoppioJVM](https://github.com/plasma-umass/doppio)
99+
100+
### Version
101+
102+
`DoppioJVM`: v0.5.0, which runs Java 8 JDK.
103+
104+
## Code Formatting
105+
106+
Using [Prettier](https://prettier.io) with the [Prettier Java plugin](https://github.com/jhipster/prettier-java).
107+
108+
## Live Reload
109+
110+
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 Java environment.
111+
112+
This behavior can be disabled by adding the code comment `// __livecodes_reload__` to the code, which will force a full page reload.
113+
This comment can be added in the [`hiddenContent` property of the editor](../configuration/configuration-object.mdx#markup) for embedded playgrounds.
114+
115+
## Starter Template
116+
117+
https://livecodes.io/?template=java
118+
119+
## Links
120+
121+
- [Java](https://www.java.com/)
122+
- [DoppioJVM](https://github.com/plasma-umass/doppio)

docs/docs/languages/python-wasm.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ By default, when code is updated, the Pyodide environment is re-used while the g
117117

118118
Think of this like restarting the kernel in Jupyter notebooks.
119119

120+
This comment can be added in the [`hiddenContent` property of the editor](../configuration/configuration-object.mdx#markup) for embedded playgrounds.
121+
120122
## Example Usage
121123

122124
<!-- prettier-ignore -->

docs/docusaurus.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ const config: Config = {
226226
prism: {
227227
theme: lightCodeTheme,
228228
darkTheme: darkCodeTheme,
229-
additionalLanguages: ['bash'],
229+
additionalLanguages: ['bash', 'csharp', 'java'],
230230
},
231231
algolia: {
232232
appId: 'H9Z2PKYS80',

docs/src/components/LanguageSliders.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ export default function Sliders() {
8686
{ name: 'php-wasm', title: 'PHP (Wasm)' },
8787
{ name: 'cpp', title: 'C++' },
8888
{ name: 'cpp-wasm', title: 'C++ (Wasm)' },
89+
{ name: 'java', title: 'Java' },
90+
{ name: 'csharp-wasm', title: 'C# (Wasm)' },
8991
{ name: 'perl', title: 'Perl' },
9092
{ name: 'lua', title: 'Lua' },
9193
{ name: 'lua-wasm', title: 'Lua (Wasm)' },

docs/src/components/TemplateList.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ const templates = [
4646
{ name: 'php-wasm', title: 'PHP (Wasm) Starter', thumbnail: 'php.svg' },
4747
{ name: 'cpp', title: 'C++ Starter', thumbnail: 'cpp.svg' },
4848
{ name: 'cpp-wasm', title: 'C++ (Wasm) Starter', thumbnail: 'cpp.svg' },
49+
{ name: 'java', title: 'Java Starter', thumbnail: 'java.svg' },
50+
{ name: 'csharp-wasm', title: 'C# (Wasm)', thumbnail: 'csharp.svg' },
4951
{ name: 'perl', title: 'Perl Starter', thumbnail: 'perl.svg' },
5052
{ name: 'lua', title: 'Lua Starter', thumbnail: 'lua.svg' },
5153
{ name: 'lua-wasm', title: 'Lua (wasm) Starter', thumbnail: 'lua.svg' },
13.1 KB
Loading

0 commit comments

Comments
 (0)