Skip to content

Commit

Permalink
Move all code example files out of src into resources, plus small cor…
Browse files Browse the repository at this point in the history
…rections
  • Loading branch information
kaisalmen committed Oct 23, 2024
1 parent c2659cf commit 48fa759
Show file tree
Hide file tree
Showing 17 changed files with 14 additions and 23 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ <h3>Multiple Languageclients</h3>
<br>

<h3>TypeScript</h3>
<a href="./packages/examples/ts.html">TypeScript Extension Host Worker</a>
<a href="./packages/examples/tsExtHost.html">TypeScript Extension Host Worker</a>
<br>

<h2>Monaco Editor React</h2>
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@
* ------------------------------------------------------------------------------------------ */

import getConfigurationServiceOverride from '@codingame/monaco-vscode-configuration-service-override';
import getEditorServiceOverride from '@codingame/monaco-vscode-editor-service-override';
import getKeybindingsServiceOverride from '@codingame/monaco-vscode-keybindings-service-override';
import { useOpenEditorStub } from 'monaco-editor-wrapper/vscode/services';
import { LogLevel } from 'vscode/services';
import { Logger } from 'monaco-languageclient/tools';
import { WrapperConfig } from 'monaco-editor-wrapper';
import { LangiumMonarchContent } from './langium.monarch.js';
import { loadLangiumWorker } from '../wrapperLangium.js';
import code from '../content/example.langium?raw';
import { useWorkerFactory } from 'monaco-editor-wrapper/workerFactory';
import code from '../../../../resources/langium/langium-dsl/example.langium?raw';

export const setupLangiumClientClassic = async (): Promise<WrapperConfig> => {
const langiumWorker = loadLangiumWorker();
Expand All @@ -22,7 +20,6 @@ export const setupLangiumClientClassic = async (): Promise<WrapperConfig> => {
vscodeApiConfig: {
userServices: {
...getConfigurationServiceOverride(),
...getEditorServiceOverride(useOpenEditorStub),
...getKeybindingsServiceOverride()
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
* Licensed under the MIT License. See LICENSE in the package root for license information.
* ------------------------------------------------------------------------------------------ */

import getEditorServiceOverride from '@codingame/monaco-vscode-editor-service-override';
import getKeybindingsServiceOverride from '@codingame/monaco-vscode-keybindings-service-override';
import '../../../../resources/vsix/github-vscode-theme.vsix';
import { useOpenEditorStub } from 'monaco-editor-wrapper/vscode/services';

import { BrowserMessageReader, BrowserMessageWriter } from 'vscode-languageclient/browser.js';
import { LogLevel } from 'vscode/services';
import { WrapperConfig } from 'monaco-editor-wrapper';
import { loadLangiumWorker } from '../wrapperLangium.js';
import { configureMonacoWorkers } from '../../../common/client/utils.js';
import langiumLanguageConfig from './langium.configuration.json?raw';
import langiumTextmateGrammar from './langium.tmLanguage.json?raw';
import text from '../content/example.langium?raw';
import text from '../../../../resources/langium/langium-dsl//example.langium?raw';

export const setupLangiumClientExtended = async (): Promise<WrapperConfig> => {

Expand All @@ -31,7 +30,6 @@ export const setupLangiumClientExtended = async (): Promise<WrapperConfig> => {
logLevel: LogLevel.Debug,
vscodeApiConfig: {
userServices: {
...getEditorServiceOverride(useOpenEditorStub),
...getKeybindingsServiceOverride()
},
userConfiguration: {
Expand All @@ -55,7 +53,7 @@ export const setupLangiumClientExtended = async (): Promise<WrapperConfig> => {
extensions: [{
config: {
name: 'langium-example',
publisher: 'monaco-editor-wrapper-examples',
publisher: 'TypeFox',
version: '1.0.0',
engines: {
vscode: '*'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const createLangiumGlobalConfig = async (params: {
extensions: [{
config: {
name: 'statemachine-example',
publisher: 'monaco-editor-wrapper-examples',
publisher: 'TypeFox',
version: '1.0.0',
engines: {
vscode: '*'
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/src/langium/statemachine/main-react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ReactDOM from 'react-dom/client';
import { MonacoEditorReactComp } from '@typefox/monaco-editor-react';
import { createLangiumGlobalConfig } from './config/wrapperStatemachineConfig.js';
import { loadStatemachineWorkerRegular } from './main.js';
import text from './content/example.statemachine?raw';
import text from '../../../resources/langium/statemachine/example.statemachine?raw';

export const runStatemachineReact = async () => {
const wrapperConfig = await createLangiumGlobalConfig({
Expand Down
4 changes: 2 additions & 2 deletions packages/examples/src/langium/statemachine/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { BrowserMessageReader, BrowserMessageWriter } from 'vscode-languageclien
import { createLangiumGlobalConfig } from './config/wrapperStatemachineConfig.js';
import workerUrl from './worker/statemachine-server?worker&url';
import workerPortUrl from './worker/statemachine-server-port?worker&url';
import text from './content/example.statemachine?raw';
import textMod from './content/example-mod.statemachine?raw';
import text from '../../../resources/langium/statemachine/example.statemachine?raw';
import textMod from '../../../resources/langium/statemachine/example-mod.statemachine?raw';

const wrapper = new MonacoEditorLanguageClientWrapper();
const wrapper2 = new MonacoEditorLanguageClientWrapper();
Expand Down
3 changes: 0 additions & 3 deletions packages/examples/src/python/client/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
* ------------------------------------------------------------------------------------------ */

import * as vscode from 'vscode';
import getEditorServiceOverride from '@codingame/monaco-vscode-editor-service-override';
import getKeybindingsServiceOverride from '@codingame/monaco-vscode-keybindings-service-override';
import '@codingame/monaco-vscode-python-default-extension';
import { LogLevel } from 'vscode/services';
import { MonacoLanguageClient } from 'monaco-languageclient';
import { createUrl } from 'monaco-languageclient/tools';
import { WrapperConfig } from 'monaco-editor-wrapper';
import { useOpenEditorStub } from 'monaco-editor-wrapper/vscode/services';
import { toSocket, WebSocketMessageReader, WebSocketMessageWriter } from 'vscode-ws-jsonrpc';
import { configureMonacoWorkers } from '../../common/client/utils.js';

Expand Down Expand Up @@ -67,7 +65,6 @@ export const createUserConfig = (workspaceRoot: string, code: string, codeUri: s
logLevel: LogLevel.Debug,
vscodeApiConfig: {
userServices: {
...getEditorServiceOverride(useOpenEditorStub),
...getKeybindingsServiceOverride()
},
userConfiguration: {
Expand Down
4 changes: 2 additions & 2 deletions packages/examples/src/python/client/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import '@codingame/monaco-vscode-python-default-extension';
import { RegisteredFileSystemProvider, registerFileSystemOverlay, RegisteredMemoryFile } from '@codingame/monaco-vscode-files-service-override';
import { MonacoEditorLanguageClientWrapper } from 'monaco-editor-wrapper';
import { createUserConfig } from './config.js';
import helloPyCode from './hello.py?raw';
import hello2PyCode from './hello2.py?raw';
import helloPyCode from '../../../resources/python/hello.py?raw';
import hello2PyCode from '../../../resources/python/hello2.py?raw';

export const runPythonWrapper = async () => {
const helloPyUri = vscode.Uri.file('/workspace/hello.py');
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/src/python/client/reactPython.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import ReactDOM from 'react-dom/client';
import { MonacoEditorReactComp } from '@typefox/monaco-editor-react';
import { MonacoEditorLanguageClientWrapper, TextChanges } from 'monaco-editor-wrapper';
import { createUserConfig } from './config.js';
import badPyCode from './bad.py?raw';
import badPyCode from '../../../resources/python/bad.py?raw';

export const runPythonReact = async () => {
const badPyUri = vscode.Uri.file('/workspace/bad.py');
Expand Down
1 change: 0 additions & 1 deletion packages/examples/src/ts/wrapperTs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import * as vscode from 'vscode';
import getKeybindingsServiceOverride from '@codingame/monaco-vscode-keybindings-service-override';
import '@codingame/monaco-vscode-theme-defaults-default-extension';
import '@codingame/monaco-vscode-typescript-basics-default-extension';
import '@codingame/monaco-vscode-typescript-language-features-default-extension';
import { LogLevel } from 'vscode/services';
Expand Down
4 changes: 2 additions & 2 deletions packages/examples/tsExtHost.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Monaco Editor Wrapper TypeScript Example</title>
<title>TypeScript Extension Host Worker</title>
<link rel="stylesheet" href="style.css">
</head>

<body>
<h2>Monaco Editor Wrapper TypeScript Example</h2>
<h2>TypeScript Extension Host Worker</h2>
<button type="button" id="button-start">Start</button>
<button type="button" id="button-swap-code">Swap Code</button>
<button type="button" id="button-diff">Show Diff</button>
Expand Down

0 comments on commit 48fa759

Please sign in to comment.