Skip to content

Commit

Permalink
Prepare: Make examples pacakge externally available
Browse files Browse the repository at this point in the history
  • Loading branch information
kaisalmen committed Aug 30, 2023
1 parent 8379dfe commit e6ed7c0
Show file tree
Hide file tree
Showing 20 changed files with 314 additions and 194 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ The following table describes which version of **monaco-languageclient** and **m

| monaco-languageclient | monaco-vscode-api | monaco-editor | comment |
| :---- | :---- | :--- | :--- |
| 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 |
| 6.4.2 | 1.81.2 | 0.41.0 | Released 2023-08-19 |
Expand Down
322 changes: 169 additions & 153 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions packages/client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to this npm module are documented in this file.

## [6.4.5] - 2023-08-30

- Use direct `monaco-editor` imports
- Make examples publicly available

## [6.4.4] - 2023-08-24

- Update to `monaco-vscode-api` `1.81.5`
Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "monaco-languageclient",
"version": "6.4.4",
"version": "6.4.5",
"description": "Monaco Language client implementation",
"author": {
"name": "TypeFox GmbH",
Expand Down
7 changes: 7 additions & 0 deletions packages/examples/main/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

All notable changes to this npm module are documented in this file.

## [6.4.5] - 2023-08-30

- First release of the `monaco-languageclient-examples` package
11 changes: 11 additions & 0 deletions packages/examples/main/License.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Copyright (c) 2018-2023 TypeFox GmbH (http://www.typefox.io)

All rights reserved.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 changes: 19 additions & 0 deletions packages/examples/main/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Monaco Language Client Examples

[![Gitpod - Code Now](https://img.shields.io/badge/Gitpod-code%20now-blue.svg?longCache=true)](https://gitpod.io#https://github.com/TypeFox/monaco-languageclient)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?longCache=true)](https://github.com/TypeFox/monaco-languageclient/labels/help%20wanted)
[![monaco-languageclient](https://github.com/TypeFox/monaco-languageclient/actions/workflows/actions.yml/badge.svg)](https://github.com/TypeFox/monaco-languageclient/actions/workflows/actions.yml)
[![NPM Version](https://img.shields.io/npm/v/monaco-languageclient-examples.svg)](https://www.npmjs.com/package/monaco-languageclient-examples)
[![NPM Download](https://img.shields.io/npm/dt/monaco-languageclient-examples.svg)](https://www.npmjs.com/package/monaco-languageclient-examples)

Module to connect [Monaco editor](https://microsoft.github.io/monaco-editor/) with [language servers](https://microsoft.github.io/language-server-protocol/).

See [here](https://github.com/TypeFox/monaco-languageclient/blob/main/README.md) for a detailed documentation.

## History

For the history please see the [README](https://github.com/TypeFox/monaco-languageclient/blob/main/packages/examples/main/README.md#latest-important-project-changes) and [CHANGELOG](https://github.com/TypeFox/monaco-languageclient/blob/main/packages/examples/main/CHANGELOG.md).

## License

[MIT](https://github.com/TypeFox/monaco-languageclient/blob/main/packages/examples/main/License.txt)
59 changes: 48 additions & 11 deletions packages/examples/main/package.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,62 @@
{
"name": "examples-main",
"version": "1.0.0",
"private": true,
"name": "monaco-languageclient-examples",
"version": "6.4.5",
"description": "Monaco Language client examples",
"author": {
"name": "TypeFox GmbH",
"url": "http://www.typefox.io"
},
"homepage": "https://github.com/TypeFox/monaco-languageclient/blob/main/packages/examples/main/README.md",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/TypeFox/monaco-languageclient",
"directory": "packages/examples/main"
},
"bugs": {
"url": "https://github.com/TypeFox/monaco-languageclient/issues"
},
"type": "module",
"main": "./dist/common.js",
"module": "./dist/common.js",
"main": "./dist/index.js",
"module": "./dist/index.js",
"exports": {
".": {
"types": "./dist/common.d.ts",
"default": "./dist/common.js"
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./node": {
"types": "./dist/node.d.ts",
"default": "./dist/node.js"
},
"./langiumWorker": {
"types": "./dist/langium/langiumServerWorker.d.ts",
"default": "./dist/worker/langiumServerWorker.js"
}
},
"typesVersions": {
"*": {
".": [
"dist/common.d.ts"
"dist/index"
],
"node": [
"dist/node"
],
"langiumWorker": [
"dist/langium/langiumServerWorker"
]
}
},
"dependencies": {
"express": "~4.18.2",
"langium": "~2.0.0",
"langium": "~2.0.1",
"langium-statemachine-dsl": "~2.0.0",
"monaco-editor-workers": "~0.41.0",
"monaco-languageclient": "~6.4.4",
"monaco-languageclient": "~6.4.5",
"pyright": "~1.1.322",
"react": "~18.2.0",
"react-dom": "~18.2.0",
"request-light": "~0.7.0",
"vscode-json-languageservice": "~5.3.5",
"vscode-json-languageservice": "~5.3.6",
"vscode-languageserver": "~8.1.0",
"vscode-ws-jsonrpc": "~3.0.0",
"ws": "~8.13.0"
Expand All @@ -45,6 +73,15 @@
"node": "18.17.1",
"npm": "9.6.7"
},
"files": [
"dist",
"src",
"*.html",
"*.ts",
"README.md",
"CHANGELOG.md",
"License.txt"
],
"scripts": {
"clean": "shx rm -fr dist *.tsbuildinfo",
"compile": "tsc --build tsconfig.src.json",
Expand Down
13 changes: 13 additions & 0 deletions packages/examples/main/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */

export * from './common.js';
export * from './browser/main.js';
export * from './json/client/main.js';
export * from './langium/langiumClient.js';
export * from './langium/statemachineClient.js';
export * from './python/client.js';
export * from './react/app.js';
export * from './react/main.js';
16 changes: 8 additions & 8 deletions packages/examples/main/src/langium/langiumClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ const setup = async () => {
registerFileSystemOverlay(1, fileSystemProvider);

textModelRef = await createModelReference(Uri.file('/workspace/example.langium'));
};

const run = async () => {
createConfiguredEditor(document.getElementById('container')!, {
model: textModelRef.object.textEditorModel
});
Expand Down Expand Up @@ -138,9 +136,11 @@ const run = async () => {
// any further language client / server interaction can't be defined as needed
};

try {
await setup();
await run();
} catch (e) {
console.log(e);
}
const run = async () => {
try {
await setup();
} catch (e) {
console.log(e);
}
};
run();
16 changes: 8 additions & 8 deletions packages/examples/main/src/langium/statemachineClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ const setup = async () => {
"editor.fontSize": 14,
"workbench.colorTheme": "Default Dark Modern"
}`);
};

const run = async () => {
const exampleStatemachineUrl = new URL('./src/langium/example.statemachine', window.location.href).href;
const editorText = await (await fetch(exampleStatemachineUrl)).text();

Expand Down Expand Up @@ -143,9 +141,11 @@ const run = async () => {
reader.onClose(() => languageClient.stop());
};

try {
await setup();
await run();
} catch (e) {
console.error(e);
}
const run = async () => {
try {
await setup();
} catch (e) {
console.error(e);
}
};
run();
9 changes: 9 additions & 0 deletions packages/examples/main/src/node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */

export * from './json/server/json-server.js';
export * from './json/server/main.js';
export * from './python/server.js';
export * from './utils/fs-utils.js';
10 changes: 6 additions & 4 deletions packages/examples/main/src/python/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import { getLocalDirectory } from '../utils/fs-utils.js';

const serverName = 'PYRIGHT';

const launchLanguageServer = (socket: IWebSocket) => {
const launchLanguageServer = (socket: IWebSocket, baseDir: string, relativeDir: string) => {
// start the language server as an external process
const ls = resolve(getLocalDirectory(import.meta.url), '../../../../../node_modules/pyright/dist/pyright-langserver.js');
const ls = resolve(baseDir, relativeDir);
const serverConnection = createServerProcess(serverName, 'node', [ls, '--stdio']);

const reader = new WebSocketMessageReader(socket);
Expand Down Expand Up @@ -97,11 +97,13 @@ const run = () => {
dispose: () => webSocket.close()
};
// launch the server when the web socket is opened
const baseDir = resolve(getLocalDirectory(import.meta.url));
const relativeDir = '../../../../../node_modules/pyright/dist/pyright-langserver.js';
if (webSocket.readyState === webSocket.OPEN) {
launchLanguageServer(socket);
launchLanguageServer(socket, baseDir, relativeDir);
} else {
webSocket.on('open', () => {
launchLanguageServer(socket);
launchLanguageServer(socket, baseDir, relativeDir);
});
}
});
Expand Down
2 changes: 1 addition & 1 deletion packages/verify/pnpm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"private": "true",
"dependencies": {
"monaco-languageclient": "~6.4.4",
"monaco-languageclient": "~6.4.5",
"monaco-editor": "~0.41.0",
"vscode": "npm:@codingame/monaco-vscode-api@1.81.5"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/verify/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"type": "module",
"dependencies": {
"monaco-editor-workers": "~0.41.0",
"monaco-languageclient": "~6.4.4",
"examples-main": "../../examples/main",
"monaco-languageclient": "~6.4.5",
"monaco-languageclient-examples": "~6.4.5",
"vscode-ws-jsonrpc": "~3.0.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/verify/vite/src/client/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */

import { createDefaultJsonContent, createJsonEditor, createUrl, createWebSocketAndStartClient, performInit } from 'examples-main';
import { createDefaultJsonContent, createJsonEditor, createUrl, createWebSocketAndStartClient, performInit } from 'monaco-languageclient-examples';
import { buildWorkerDefinition } from 'monaco-editor-workers';
buildWorkerDefinition('./workers', new URL('', window.location.href).href, false);

Expand Down
4 changes: 2 additions & 2 deletions packages/verify/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"type": "module",
"dependencies": {
"monaco-editor-workers": "~0.41.0",
"monaco-languageclient": "~6.4.4",
"examples-main": "../../examples/main",
"monaco-languageclient": "~6.4.5",
"monaco-languageclient-examples": "~6.4.5",
"vscode-ws-jsonrpc": "~3.0.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/verify/webpack/src/client/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */

import { createDefaultJsonContent, createJsonEditor, createUrl, createWebSocketAndStartClient, performInit } from 'examples-main';
import { createDefaultJsonContent, createJsonEditor, createUrl, createWebSocketAndStartClient, performInit } from 'monaco-languageclient-examples';
import { buildWorkerDefinition } from 'monaco-editor-workers';
buildWorkerDefinition('dist/client/workers', new URL('', window.location.href).href, false);

Expand Down
2 changes: 1 addition & 1 deletion packages/verify/webpack/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const config = {
enforce: 'pre',
use: ['source-map-loader'],
// These modules seems to have broken sourcemaps, exclude them to prevent an error flood in the logs
exclude: [/vscode-jsonrpc/, /vscode-languageclient/, /vscode-languageserver-protocol/]
exclude: [/vscode-jsonrpc/, /vscode-languageclient/, /vscode-languageserver/, /vscode-languageserver-protocol/]
},
{
test: /\.(mp3|wasm)$/i,
Expand Down
2 changes: 1 addition & 1 deletion packages/verify/yarn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"private": "true",
"dependencies": {
"monaco-languageclient": "~6.4.4"
"monaco-languageclient": "~6.4.5"
},
"devDependencies": {
"shx": "~0.3.4"
Expand Down

0 comments on commit e6ed7c0

Please sign in to comment.