Skip to content

Commit

Permalink
Move examples from packages/examples/main to packages/examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kaisalmen committed Sep 5, 2023
1 parent 041c3d0 commit 41ed66a
Show file tree
Hide file tree
Showing 46 changed files with 132 additions and 146 deletions.
8 changes: 4 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
"name": "Launch JSON LS",
"type": "node",
"request": "launch",
"args": ["${workspaceRoot}/packages/examples/main/src/json/server/direct.ts"],
"args": ["${workspaceRoot}/packages/examples/src/json/server/direct.ts"],
"runtimeArgs": ["--nolazy", "--loader", "ts-node/esm"],
"cwd": "${workspaceRoot}/packages/examples/main",
"cwd": "${workspaceRoot}/packages/examples",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "Launch Python LS",
"type": "node",
"request": "launch",
"args": ["${workspaceRoot}/packages/examples/main/src/python/server/direct.ts"],
"args": ["${workspaceRoot}/packages/examples/src/python/server/direct.ts"],
"runtimeArgs": ["--nolazy", "--loader", "ts-node/esm"],
"cwd": "${workspaceRoot}/packages/examples/main",
"cwd": "${workspaceRoot}/packages/examples",
"internalConsoleOptions": "openOnSessionStart"
},
{
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ The following table describes which version of **monaco-languageclient** and **m

| monaco-languageclient | monaco-vscode-api | monaco-editor | comment |
| :---- | :---- | :--- | :--- |
| 6.4.6 | 1.81.7 | 0.41.0 | Released 2023-09-0x |
| 6.4.6 | 1.81.7 | 0.41.0 | Released 2023-09-05 |
| 6.4.5 | 1.81.5 | 0.41.0 | Released 2023-08-30 |
| 6.4.4 | 1.81.5 | 0.41.0 | Released 2023-08-24 |
| 6.4.3 | 1.81.3 | 0.41.0 | Released 2023-08-22 |
Expand Down Expand Up @@ -133,33 +133,33 @@ npm run build:client
# Build only vscode-ws-jsonrpc
npm run build:vscode-ws-jsonrpc
# Build main examples
npm run build:example:main
npm run build:examples:main
```

## Examples

There are a couple of different examples that demonstrate how the `monaco-languageclient` can be used :

- [JSON Language client and language server example](./packages/examples/main/src/json):
- The **json-server** runs a Node.js [Express app](./packages/examples/main/src/json/server/main.ts) where web sockets are used to enable communication between the language server process and the client web application. The language server can be started as internal or external process. Use `npm run start:example:server:json` to start the language server (see [Server processes](#server-processes)).
- [JSON Language client and language server example](./packages/examples/src/json):
- The **json-server** runs a Node.js [Express app](./packages/examples/src/json/server/main.ts) where web sockets are used to enable communication between the language server process and the client web application. The language server can be started as internal or external process. Use `npm run start:example:server:json` to start the language server (see [Server processes](#server-processes)).

- The **json-client** contains the [client web app](./packages/examples/main/src/json/client/main.ts) which connects to the language server therefore requires the node server app to be run in parallel.
- The **json-client** contains the [client web app](./packages/examples/src/json/client/main.ts) which connects to the language server therefore requires the node server app to be run in parallel.

- [Python Language client and pyright language server example](./packages/examples/main/src/python):
- The **python-server** runs a Node.js [Express app](./packages/examples/main/src/python/server/main.ts) where web sockets are used to enable communication between the language server process and the client web application. The language server can be started as internal or external process. Use `npm run start:example:server:python` to start the language server (see [Server processes](#server-processes)).
- [Python Language client and pyright language server example](./packages/examples/src/python):
- The **python-server** runs a Node.js [Express app](./packages/examples/src/python/server/main.ts) where web sockets are used to enable communication between the language server process and the client web application. The language server can be started as internal or external process. Use `npm run start:example:server:python` to start the language server (see [Server processes](#server-processes)).

- The **python-client** contains the [client web app](./packages/examples/main/src/python/client/main.ts) which connects to the language server therefore requires the node server app to be run in parallel.
- The **python-client** contains the [client web app](./packages/examples/src/python/client/main.ts) which connects to the language server therefore requires the node server app to be run in parallel.

- Langium example:
- Statemachine DSL (created with Langium) **statemachine-web-worker-language-server** example located in [./packages/examples/main/src/langium](./packages/examples/main/src/langium) contains both the [language client](./packages/examples/main/src/langium/statemachineClient.ts) and the [langauge server (web worker)](https://github.com/langium/langium/blob/main/examples/statemachine/src/language-server/main-browser.ts). The web worker example communicate via `vscode-languageserver-protocol/browser` instead of a web socket used in the **JSON examples** examples.
- Statemachine DSL (created with Langium) **statemachine-web-worker-language-server** example located in [./packages/examples/src/langium](./packages/examples/src/langium) contains both the [language client](./packages/examples/src/langium/statemachineClient.ts) and the [langauge server (web worker)](https://github.com/langium/langium/blob/main/examples/statemachine/src/language-server/main-browser.ts). The web worker example communicate via `vscode-languageserver-protocol/browser` instead of a web socket used in the **JSON examples** examples.

- The **browser** example located in [./packages/examples/main/src/browser](./packages/examples/main/src/browser) demonstrates how a [language service written in JavaScript](./packages/examples/main/src/browser/main.ts) can be used in a Monaco Editor contained in a simple HTML page. This example can now be considered legacy as the web worker option eases client side language server implementation and separation.
- The **browser** example located in [./packages/examples/src/browser](./packages/examples/src/browser) demonstrates how a [language service written in JavaScript](./packages/examples/src/browser/main.ts) can be used in a Monaco Editor contained in a simple HTML page. This example can now be considered legacy as the web worker option eases client side language server implementation and separation.

- The **react-client** example located in [./packages/examples/main/src/react](./packages/examples/main/src/react) contains the [React client](./packages/examples/main/src/react/main.tsx). It does the same as the regular client example but inside a React Functional Component.
- The **react-client** example located in [./packages/examples/src/react](./packages/examples/src/react) contains the [React client](./packages/examples/src/react/main.tsx). It does the same as the regular client example but inside a React Functional Component.

- The **angular-client** example is now found in [its own repository](https://github.com/TypeFox/monaco-languageclient-ng-example.git)

**Important:** Apart from the **json-server** and **python-server** process all other will be server by the [Vite dev server](#vite-dev-server). Some examples share [common code](./packages/examples/main/src/common.ts) to reduce the amount of redundant code.
**Important:** Apart from the **json-server** and **python-server** process all other will be server by the [Vite dev server](#vite-dev-server). Some examples share [common code](./packages/examples/src/common.ts) to reduce the amount of redundant code.

## Verification

Expand Down
35 changes: 14 additions & 21 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,31 @@

<body>
<div style="padding: 5px">
<h1>Examples</h1>
<h2>Examples</h2>

<h2>JSON language client and language server example</h2>
<h3>JSON language client and language server</h3>
Please execute <b><code>npm run start:example:server:json</code></b> beforehand:<br>
<a href="packages/examples/main/client.html">Client for Node.js Language Server</a>
<h2>Python language client and language server example</h2>
<a href="packages/examples/client.html">Client for Node.js Language Server</a>
<h3>Python language client and language server</h3>
Please execute <b><code>npm run start:example:server:python</code></b> beforehand:<br>
<a href="packages/examples/main/python.html">Client for Python Pyright Language Server</a>
<a href="packages/examples/python.html">Client for Python Pyright Language Server</a>
<h3>Langium client and language server</h3>
<a href="packages/examples/statemachine_client.html">Client & Statemachine LS (Web Worker)</a>
<h3>Other examples</h3>
<a href="packages/examples/browser.html">Browser Example</a>
<br><br>
<h2>Langium client and language server example</h2>
<a href="packages/examples/main/statemachine_client.html">Client & Statemachine LS (Web Worker)</a>
<br><br>
<h2>Other examples</h2>
<a href="packages/examples/main/browser.html">Browser Example</a>
<br><br>
<a href="packages/examples/main/react.html">React Client Example</a>
<a href="packages/examples/react.html">React Client Example</a>

<h1>Verification</h1>
<h2>Webpack</h2>
<h2>Verification</h2>
<h3>Webpack</h3>
Please start <b><code>npm run start:verify:webpack</code></b> beforehand:<br>
<a href="http://localhost:8081">Web Client for Node.js Language Server (webpack build)</a>
<br>

<h2>Vite</h2>
<h3>Vite</h3>
Please start <b><code>npm run start:verify:vite</code></b> beforehand:<br>
<a href="http://localhost:8082">Web Client for Node.js Language Server (vite build)</a>
<br>

<h1>External examples</h1>
<h2>External examples</h2>
<a href="https://github.com/TypeFox/monaco-languageclient-ng-example.git">Angular Client Example</a>
<br>

</div>
</body>

Expand Down
90 changes: 45 additions & 45 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 41ed66a

Please sign in to comment.