Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
John Cortell committed Jul 5, 2023
0 parents commit 3b355c8
Show file tree
Hide file tree
Showing 13 changed files with 10,071 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
.browser_modules
lib
*.log
*-app/*
!*-app/package.json
121 changes: 121 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Start Browser Backend",
"program": "${workspaceRoot}/browser-app/src-gen/backend/main.js",
"args": [
"--loglevel=debug",
"--port=3000",
"--no-cluster"
],
"env": {
"NODE_ENV": "development"
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/node_modules/@theia/*/lib/**/*.js",
"${workspaceRoot}/*/lib/**/*.js",
"${workspaceRoot}/browser-app/src-gen/**/*.js"
],
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
},
{
"type": "chrome",
"request": "attach",
"name": "Attach to Electron Frontend",
"port": 9222,
"webRoot": "${workspaceFolder}/electron-app/lib",
"timeout": 30000
},
{
"type": "node",
"request": "attach",
"name": "Attach to Plugin Host",
"port": 9339,
"timeout": 60000,
"smartStep": true,
"sourceMaps": true,
"internalConsoleOptions": "openOnSessionStart",
"outFiles": [
"${workspaceRoot}/electron-app/src-gen/frontend/electron-main.js",
"${workspaceRoot}/electron-app/src-gen/backend/main.js",
"${workspaceRoot}/*/lib/**/*.js",
"${workspaceRoot}/node_modules/@theia/*/lib/**/*.js",
],
},
{
"type": "node",
"request": "launch",
"name": "Start Electron Backend",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
},
"program": "${workspaceRoot}/electron-app/src-gen/frontend/electron-main.js",
"protocol": "inspector",
"args": [
"--loglevel=debug",
"--hostname=localhost",
"--no-cluster",
"--plugins=local-dir:${workspaceRoot}/plugins",
"--remote-debugging-port=9222",
"--hosted-plugin-inspect=9339",
],
"env": {
"NODE_ENV": "development"
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/electron-app/src-gen/frontend/electron-main.js",
"${workspaceRoot}/electron-app/src-gen/backend/main.js",
"${workspaceRoot}/*/lib/**/*.js",
"${workspaceRoot}/node_modules/@theia/*/lib/**/*.js",
],
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std",
"cwd": "${workspaceRoot}/electron-app"
},
{
"type": "node",
"request": "launch",
"name": "Start Electron Backend (bare)",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
},
"program": "${workspaceRoot}/electron-app/src-gen/frontend/electron-main.js",
"protocol": "inspector",
"args": [
"--loglevel=debug",
"--hostname=localhost",
"--no-cluster",
"--plugins=local-dir:${workspaceRoot}/plugins"
],
"env": {
"NODE_ENV": "development"
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/electron-app/src-gen/frontend/electron-main.js",
"${workspaceRoot}/electron-app/src-gen/backend/main.js",
"${workspaceRoot}/*/lib/**/*.js",
"${workspaceRoot}/node_modules/@theia/*/lib/**/*.js",
],
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std",
"cwd": "${workspaceRoot}/electron-app"
}


]
}
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# hello-world
The example of how to build the Theia-based applications with the hello-world.

## Getting started

Please install all necessary [prerequisites](https://github.com/eclipse-theia/theia/blob/master/doc/Developing.md#prerequisites).

## Running the browser example

yarn start:browser

*or:*

yarn rebuild:browser
cd browser-app
yarn start

*or:* launch `Start Browser Backend` configuration from VS code.

Open http://localhost:3000 in the browser.

## Running the Electron example

yarn start:electron

*or:*

yarn rebuild:electron
cd electron-app
yarn start

*or:* launch `Start Electron Backend` configuration from VS code.


## Developing with the browser example

Start watching all packages, including `browser-app`, of your application with

yarn watch

*or* watch only specific packages with

cd hello-world
yarn watch

and the browser example.

cd browser-app
yarn watch

Run the example as [described above](#Running-the-browser-example)
## Developing with the Electron example

Start watching all packages, including `electron-app`, of your application with

yarn watch

*or* watch only specific packages with

cd hello-world
yarn watch

and the Electron example.

cd electron-app
yarn watch

Run the example as [described above](#Running-the-Electron-example)

## Publishing hello-world

Create a npm user and login to the npm registry, [more on npm publishing](https://docs.npmjs.com/getting-started/publishing-npm-packages).

npm login

Publish packages with lerna to update versions properly across local packages, [more on publishing with lerna](https://github.com/lerna/lerna#publish).

npx lerna publish
30 changes: 30 additions & 0 deletions browser-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"private": true,
"name": "browser-app",
"version": "0.0.0",
"dependencies": {
"@theia/core": "latest",
"@theia/editor": "latest",
"@theia/filesystem": "latest",
"@theia/markers": "latest",
"@theia/messages": "latest",
"@theia/monaco": "latest",
"@theia/navigator": "latest",
"@theia/preferences": "latest",
"@theia/process": "latest",
"@theia/terminal": "latest",
"@theia/workspace": "latest",
"hello-world": "0.0.0"
},
"devDependencies": {
"@theia/cli": "latest"
},
"scripts": {
"prepare": "theia build --mode development",
"start": "theia start",
"watch": "theia build --watch --mode development"
},
"theia": {
"target": "browser"
}
}
33 changes: 33 additions & 0 deletions electron-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"private": true,
"name": "electron-app",
"version": "0.0.0",
"dependencies": {
"@theia/core": "latest",
"@theia/editor": "latest",
"@theia/electron": "latest",
"@theia/filesystem": "latest",
"@theia/markers": "latest",
"@theia/messages": "latest",
"@theia/monaco": "latest",
"@theia/navigator": "latest",
"@theia/preferences": "latest",
"@theia/process": "latest",
"@theia/terminal": "latest",
"@theia/workspace": "latest",
"@theia/plugin-ext-vscode": "latest",
"hello-world": "0.0.0"
},
"devDependencies": {
"@theia/cli": "latest",
"electron": "^23.2.4"
},
"scripts": {
"prepare": "theia build --mode development",
"start": "theia start --plugins=local-dir:../plugins",
"watch": "theia build --watch --mode development"
},
"theia": {
"target": "electron"
}
}
7 changes: 7 additions & 0 deletions hello-world/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Hello World Example

The example extension demonstrates how to register a command in Theia saying "Hello world" using the message service.

## How to use the Hello World example

In the running application, trigger the command "Say hello" via the command palette (F1 => "Say Hello"). A message dialog will pop up saying "Hello World".
29 changes: 29 additions & 0 deletions hello-world/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "hello-world",
"keywords": [
"theia-extension"
],
"version": "0.0.0",
"files": [
"lib",
"src"
],
"dependencies": {
"@theia/core": "latest"
},
"devDependencies": {
"rimraf": "latest",
"typescript": "~4.5.5"
},
"scripts": {
"prepare": "yarn run clean && yarn run build",
"clean": "rimraf lib",
"build": "tsc",
"watch": "tsc -w"
},
"theiaExtensions": [
{
"frontend": "lib/browser/hello-world-frontend-module"
}
]
}
33 changes: 33 additions & 0 deletions hello-world/src/browser/hello-world-contribution.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { injectable, inject } from '@theia/core/shared/inversify';
import { Command, CommandContribution, CommandRegistry, MenuContribution, MenuModelRegistry, MessageService } from '@theia/core/lib/common';
import { CommonMenus } from '@theia/core/lib/browser';

export const HelloWorldCommand: Command = {
id: 'HelloWorld.command',
label: 'Say Hello from Theia Extension'
};

@injectable()
export class HelloWorldCommandContribution implements CommandContribution {

constructor(
@inject(MessageService) private readonly messageService: MessageService,
) { }

registerCommands(registry: CommandRegistry): void {
registry.registerCommand(HelloWorldCommand, {
execute: () => this.messageService.info('Hello World!')
});
}
}

@injectable()
export class HelloWorldMenuContribution implements MenuContribution {

registerMenus(menus: MenuModelRegistry): void {
menus.registerMenuAction(CommonMenus.EDIT_FIND, {
commandId: HelloWorldCommand.id,
label: HelloWorldCommand.label
});
}
}
12 changes: 12 additions & 0 deletions hello-world/src/browser/hello-world-frontend-module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Generated using theia-extension-generator
*/
import { HelloWorldCommandContribution, HelloWorldMenuContribution } from './hello-world-contribution';
import { CommandContribution, MenuContribution } from '@theia/core/lib/common';
import { ContainerModule } from '@theia/core/shared/inversify';

export default new ContainerModule(bind => {
// add your contribution bindings here
bind(CommandContribution).to(HelloWorldCommandContribution);
bind(MenuContribution).to(HelloWorldMenuContribution);
});
30 changes: 30 additions & 0 deletions hello-world/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"compilerOptions": {
"skipLibCheck": true,
"declaration": true,
"declarationMap": true,
"noImplicitAny": true,
"noEmitOnError": false,
"noImplicitThis": true,
"noUnusedLocals": true,
"strictNullChecks": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"downlevelIteration": true,
"resolveJsonModule": true,
"module": "commonjs",
"moduleResolution": "node",
"target": "ES2017",
"jsx": "react",
"lib": [
"ES2017",
"dom"
],
"sourceMap": true,
"rootDir": "src",
"outDir": "lib"
},
"include": [
"src"
]
}
Loading

0 comments on commit 3b355c8

Please sign in to comment.