├── .gitattributes ├── .gitignore ├── lerna.json ├── theia-extension ├── README.md ├── src │ └── browser │ │ ├── theia-plugin-backend-module.ts │ │ ├── theia-extension-frontend-module.ts │ │ ├── test.ts │ │ └── theia-extension-contribution.ts ├── package.json └── tsconfig.json ├── package.json ├── browser-app └── package.json ├── electron-app └── package.json ├── README.md └── .vscode └── launch.json /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .browser_modules 3 | lib 4 | *.log 5 | *-app/* 6 | !*-app/package.json 7 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "lerna": "2.4.0", 3 | "version": "0.0.0", 4 | "useWorkspaces": true, 5 | "npmClient": "yarn", 6 | "command": { 7 | "run": { 8 | "stream": true 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /theia-extension/README.md: -------------------------------------------------------------------------------- 1 | # Hello World Example 2 | 3 | The example extension demonstrates how to register a command in Theia saying "Hello world" using the message service. 4 | 5 | ## How to use the Hello World example 6 | 7 | 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". -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "prepare": "lerna run prepare", 5 | "rebuild:browser": "theia rebuild:browser", 6 | "rebuild:electron": "theia rebuild:electron", 7 | "start:browser": "yarn rebuild:browser && yarn --cwd browser-app start", 8 | "start:electron": "yarn rebuild:electron && yarn --cwd electron-app start", 9 | "watch": "lerna run --parallel watch" 10 | }, 11 | "devDependencies": { 12 | "lerna": "2.4.0" 13 | }, 14 | "workspaces": [ 15 | "theia-extension", "browser-app", "electron-app" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /theia-extension/src/browser/theia-plugin-backend-module.ts: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Generated using theia-plugin-generator 4 | */ 5 | 6 | import * as theia from '@theia/plugin'; 7 | 8 | export function start(context: theia.PluginContext) { 9 | const informationMessageTestCommand = { 10 | id: 'hello-world-example-generated', 11 | label: "Hello World" 12 | }; 13 | context.subscriptions.push(theia.commands.registerCommand(informationMessageTestCommand, (...args: any[]) => { 14 | theia.window.showInformationMessage('Hello World!'); 15 | })); 16 | 17 | } 18 | 19 | export function stop() { 20 | 21 | } 22 | -------------------------------------------------------------------------------- /theia-extension/src/browser/theia-extension-frontend-module.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Generated using theia-extension-generator 3 | */ 4 | import { TheiaExtensionCommandContribution, TheiaExtensionMenuContribution } from './theia-extension-contribution'; 5 | import { CommandContribution, MenuContribution } from '@theia/core/lib/common'; 6 | import { ContainerModule } from '@theia/core/shared/inversify'; 7 | 8 | export default new ContainerModule(bind => { 9 | // add your contribution bindings here 10 | bind(CommandContribution).to(TheiaExtensionCommandContribution); 11 | bind(MenuContribution).to(TheiaExtensionMenuContribution); 12 | }); 13 | -------------------------------------------------------------------------------- /theia-extension/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "theia-extension", 3 | "keywords": [ 4 | "theia-extension" 5 | ], 6 | "version": "0.0.0", 7 | "files": [ 8 | "lib", 9 | "src" 10 | ], 11 | "dependencies": { 12 | "@theia/core": "latest", 13 | "@theia/plugin": "^1.25.0" 14 | }, 15 | "devDependencies": { 16 | "rimraf": "latest", 17 | "typescript": "latest" 18 | }, 19 | "scripts": { 20 | "prepare": "yarn run clean && yarn run build", 21 | "clean": "rimraf lib", 22 | "build": "tsc", 23 | "watch": "tsc -w" 24 | }, 25 | "theiaExtensions": [ 26 | { 27 | "frontend": "lib/browser/theia-extension-frontend-module", 28 | "backend": "lib/browser/theia-plugin-backend-module" 29 | } 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /theia-extension/src/browser/test.ts: -------------------------------------------------------------------------------- 1 | // 测试前端插件 2 | import { ContainerModule, injectable } from "@theia/core/shared/inversify"; 3 | 4 | export interface IconTheme { 5 | canHandle(): number; 6 | getIcon(): string; 7 | } 8 | 9 | @injectable() 10 | export class NoneIconTheme implements IconTheme { 11 | readonly id = "none"; 12 | readonly label = "None"; 13 | readonly description = "Disable file icons"; 14 | readonly hasFileIcons = true; 15 | readonly hasFolderIcons = true; 16 | 17 | canHandle(): number { 18 | return Number.MAX_SAFE_INTEGER; 19 | } 20 | 21 | getIcon(): string { 22 | return ""; 23 | } 24 | } 25 | export default new ContainerModule((bind, unbind, isBound, rebind) => { 26 | bind("NoneIconTheme").to(NoneIconTheme); 27 | }); 28 | -------------------------------------------------------------------------------- /theia-extension/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "skipLibCheck": true, 4 | "declaration": true, 5 | "declarationMap": true, 6 | "noImplicitAny": true, 7 | "noEmitOnError": false, 8 | "noImplicitThis": true, 9 | "noUnusedLocals": true, 10 | "strictNullChecks": true, 11 | "experimentalDecorators": true, 12 | "emitDecoratorMetadata": true, 13 | "downlevelIteration": true, 14 | "resolveJsonModule": true, 15 | "module": "commonjs", 16 | "moduleResolution": "node", 17 | "target": "ES2017", 18 | "jsx": "react", 19 | "lib": [ 20 | "ES2017", 21 | "dom" 22 | ], 23 | "sourceMap": true, 24 | "rootDir": "src", 25 | "outDir": "lib" 26 | }, 27 | "include": [ 28 | "src" 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /browser-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "browser-app", 4 | "version": "0.0.0", 5 | "dependencies": { 6 | "@theia/core": "latest", 7 | "@theia/editor": "latest", 8 | "@theia/filesystem": "latest", 9 | "@theia/markers": "latest", 10 | "@theia/messages": "latest", 11 | "@theia/monaco": "latest", 12 | "@theia/navigator": "latest", 13 | "@theia/plugin": "^1.25.0", 14 | "@theia/preferences": "latest", 15 | "@theia/process": "latest", 16 | "@theia/terminal": "latest", 17 | "@theia/workspace": "latest", 18 | "theia-extension": "0.0.0" 19 | }, 20 | "devDependencies": { 21 | "@theia/cli": "latest" 22 | }, 23 | "scripts": { 24 | "prepare": "theia build --mode development", 25 | "start": "theia start", 26 | "watch": "theia build --watch --mode development" 27 | }, 28 | "theia": { 29 | "target": "browser" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /electron-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "electron-app", 4 | "version": "0.0.0", 5 | "dependencies": { 6 | "@theia/core": "latest", 7 | "@theia/editor": "latest", 8 | "@theia/electron": "latest", 9 | "@theia/filesystem": "latest", 10 | "@theia/markers": "latest", 11 | "@theia/messages": "latest", 12 | "@theia/monaco": "latest", 13 | "@theia/navigator": "latest", 14 | "@theia/preferences": "latest", 15 | "@theia/process": "latest", 16 | "@theia/terminal": "latest", 17 | "@theia/workspace": "latest", 18 | "theia-extension": "0.0.0" 19 | }, 20 | "devDependencies": { 21 | "@theia/cli": "latest", 22 | "electron": "^15.3.5" 23 | }, 24 | "scripts": { 25 | "prepare": "theia build --mode development", 26 | "start": "theia start", 27 | "watch": "theia build --watch --mode development" 28 | }, 29 | "theia": { 30 | "target": "electron" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /theia-extension/src/browser/theia-extension-contribution.ts: -------------------------------------------------------------------------------- 1 | import { injectable, inject } from '@theia/core/shared/inversify'; 2 | import { Command, CommandContribution, CommandRegistry, MenuContribution, MenuModelRegistry, MessageService } from '@theia/core/lib/common'; 3 | import { CommonMenus } from '@theia/core/lib/browser'; 4 | 5 | export const TheiaExtensionCommand: Command = { 6 | id: 'TheiaExtension.command', 7 | label: 'Say Hello' 8 | }; 9 | 10 | @injectable() 11 | export class TheiaExtensionCommandContribution implements CommandContribution { 12 | 13 | constructor( 14 | @inject(MessageService) private readonly messageService: MessageService, 15 | ) { } 16 | 17 | registerCommands(registry: CommandRegistry): void { 18 | registry.registerCommand(TheiaExtensionCommand, { 19 | execute: () => this.messageService.info('Hello World123123!') 20 | }); 21 | } 22 | } 23 | 24 | @injectable() 25 | export class TheiaExtensionMenuContribution implements MenuContribution { 26 | 27 | registerMenus(menus: MenuModelRegistry): void { 28 | menus.registerMenuAction(CommonMenus.EDIT_FIND, { 29 | commandId: TheiaExtensionCommand.id, 30 | label: TheiaExtensionCommand.label 31 | }); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # theia-extension 2 | The example of how to build the Theia-based applications with the theia-extension. 3 | 4 | ## Getting started 5 | 6 | Install [nvm](https://github.com/creationix/nvm#install-script). 7 | 8 | curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bash 9 | 10 | Install npm and node. 11 | 12 | nvm install 10 13 | nvm use 10 14 | 15 | Install yarn. 16 | 17 | npm install -g yarn 18 | 19 | ## Running the browser example 20 | 21 | yarn start:browser 22 | 23 | *or:* 24 | 25 | yarn rebuild:browser 26 | cd browser-app 27 | yarn start 28 | 29 | *or:* launch `Start Browser Backend` configuration from VS code. 30 | 31 | Open http://localhost:3000 in the browser. 32 | 33 | ## Running the Electron example 34 | 35 | yarn start:electron 36 | 37 | *or:* 38 | 39 | yarn rebuild:electron 40 | cd electron-app 41 | yarn start 42 | 43 | *or:* launch `Start Electron Backend` configuration from VS code. 44 | 45 | 46 | ## Developing with the browser example 47 | 48 | Start watching all packages, including `browser-app`, of your application with 49 | 50 | yarn watch 51 | 52 | *or* watch only specific packages with 53 | 54 | cd theia-extension 55 | yarn watch 56 | 57 | and the browser example. 58 | 59 | cd browser-app 60 | yarn watch 61 | 62 | Run the example as [described above](#Running-the-browser-example) 63 | ## Developing with the Electron example 64 | 65 | Start watching all packages, including `electron-app`, of your application with 66 | 67 | yarn watch 68 | 69 | *or* watch only specific packages with 70 | 71 | cd theia-extension 72 | yarn watch 73 | 74 | and the Electron example. 75 | 76 | cd electron-app 77 | yarn watch 78 | 79 | Run the example as [described above](#Running-the-Electron-example) 80 | 81 | ## Publishing theia-extension 82 | 83 | Create a npm user and login to the npm registry, [more on npm publishing](https://docs.npmjs.com/getting-started/publishing-npm-packages). 84 | 85 | npm login 86 | 87 | Publish packages with lerna to update versions properly across local packages, [more on publishing with lerna](https://github.com/lerna/lerna#publish). 88 | 89 | npx lerna publish 90 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible Node.js debug attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "launch", 10 | "name": "Start Browser Backend", 11 | "program": "${workspaceRoot}/browser-app/src-gen/backend/main.js", 12 | "args": [ 13 | "--loglevel=debug", 14 | "--port=3000", 15 | "--no-cluster" 16 | ], 17 | "env": { 18 | "NODE_ENV": "development" 19 | }, 20 | "sourceMaps": true, 21 | "outFiles": [ 22 | "${workspaceRoot}/node_modules/@theia/*/lib/**/*.js", 23 | "${workspaceRoot}/*/lib/**/*.js", 24 | "${workspaceRoot}/browser-app/src-gen/**/*.js" 25 | ], 26 | "smartStep": true, 27 | "internalConsoleOptions": "openOnSessionStart", 28 | "outputCapture": "std" 29 | }, 30 | { 31 | "type": "node", 32 | "request": "launch", 33 | "name": "Start Electron Backend", 34 | "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron", 35 | "windows": { 36 | "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd" 37 | }, 38 | "program": "${workspaceRoot}/electron-app/src-gen/frontend/electron-main.js", 39 | "protocol": "inspector", 40 | "args": [ 41 | "--loglevel=debug", 42 | "--hostname=localhost", 43 | "--no-cluster" 44 | ], 45 | "env": { 46 | "NODE_ENV": "development" 47 | }, 48 | "sourceMaps": true, 49 | "outFiles": [ 50 | "${workspaceRoot}/electron-app/src-gen/frontend/electron-main.js", 51 | "${workspaceRoot}/electron-app/src-gen/backend/main.js", 52 | "${workspaceRoot}/*/lib/**/*.js", 53 | "${workspaceRoot}/node_modules/@theia/*/lib/**/*.js" 54 | ], 55 | "smartStep": true, 56 | "internalConsoleOptions": "openOnSessionStart", 57 | "outputCapture": "std" 58 | } 59 | ] 60 | } --------------------------------------------------------------------------------