├── CONTRIBUTING.md ├── .gitignore ├── images ├── icon.png └── feature.gif ├── test ├── test.js ├── extension.test.ts ├── test.html └── index.ts ├── .vscodeignore ├── .vscode ├── settings.json ├── tasks.json └── launch.json ├── tsconfig.json ├── i18n └── jpn │ └── package.i18n.json ├── package.nls.ja.json ├── LICENSE ├── package.nls.json ├── src ├── browserContentProvider.ts ├── server.ts ├── utility.ts └── extension.ts ├── CHANGELOG.md ├── gulpfile.js ├── tslint.json ├── README.md └── package.json /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ### Contributions are welcome 😸 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | out 2 | node_modules 3 | npm-debug.log 4 | vsc-extension-quickstart.md 5 | -------------------------------------------------------------------------------- /images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuichiNukiyama/vscode-preview-server/HEAD/images/icon.png -------------------------------------------------------------------------------- /images/feature.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuichiNukiyama/vscode-preview-server/HEAD/images/feature.gif -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | const app = new Vue({ 2 | el: "#target", 3 | data: { 4 | message: "I love cat!" 5 | } 6 | }); -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | out/test/** 4 | test/** 5 | src/** 6 | **/*.map 7 | .gitignore 8 | tsconfig.json 9 | tslint.json 10 | vsc-extension-quickstart.md 11 | -------------------------------------------------------------------------------- /test/extension.test.ts: -------------------------------------------------------------------------------- 1 | import * as assert from "assert"; 2 | import * as browserSync from "browser-sync"; 3 | import { Server } from "../src/server"; 4 | 5 | 6 | suite("Server Tests", () => { 7 | test("start server", () => { 8 | Server.start(".", 8888, true); 9 | assert.ok(browserSync.has("vscode-preview-server")); 10 | Server.stop(); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | "files.exclude": { 4 | "out": false // set this to true to hide the "out" folder with the compiled JS files 5 | }, 6 | "search.exclude": { 7 | "out": true // set this to false to include "out" folder in search results 8 | }, 9 | "typescript.tsdk": "./node_modules/typescript/lib" // we want to use the TS server from our node_modules folder to control its version 10 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // See https://go.microsoft.com/fwlink/?LinkId=733558 2 | // for the documentation about the tasks.json format 3 | { 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "type": "npm", 8 | "script": "watch", 9 | "problemMatcher": "$tsc-watch", 10 | "isBackground": true, 11 | "presentation": { 12 | "reveal": "never" 13 | }, 14 | "group": { 15 | "kind": "build", 16 | "isDefault": true 17 | } 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es6", 5 | "outDir": "out", 6 | "lib": [ 7 | "es6" 8 | ], 9 | "sourceMap": true, 10 | "allowJs": true, 11 | "rootDir": ".", 12 | "noImplicitAny": true, 13 | "noImplicitReturns": true, 14 | "noImplicitThis": true, 15 | "noUnusedLocals": true, 16 | "noUnusedParameters": true 17 | }, 18 | "include": [ 19 | "src/**/*", 20 | "test/**/*", 21 | "typings/**/*" 22 | ], 23 | "exclude": [ 24 | "node_modules", 25 | ".vscode-test", 26 | ".vscode" 27 | ] 28 | } -------------------------------------------------------------------------------- /test/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Test page 8 | 19 | 20 | 21 |
22 |

test

23 | 24 |

{{message}}

25 |
26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /i18n/jpn/package.i18n.json: -------------------------------------------------------------------------------- 1 | { 2 | "extension.preview.title": "vscode-preview-server: サイドパネルでプレビュー表示", 3 | "extension.launch.title": "vscode-preview-server: ブラウザーで起動", 4 | "extension.stop.title": "vscode-preview-server: Web サーバーを停止", 5 | "extension.resume.title": "vscode-preview-server: Web サーバーを再起動", 6 | "extension.ui.title": "vscode-preview-server: UI ページを表示", 7 | "previewServer.browsers.description": "プレビュー表示するブラウザー。", 8 | "previewServer.ignoreDefaultBrowser.description": "既定のブラウザーを起動しない。", 9 | "previewServer.isWatchConfiguration.description": "設定を変更したとき、Web サーバーを再起動するかどうか。", 10 | "previewServer.port.description": "Web サーバーのポート番号", 11 | "previewServer.proxy.description": "プロキシ URL で仮想ホストをラップして、サイトを表示します。", 12 | "previewServer.startupProject.description": "起動プロジェクト名。この設定は、ワークスペースを使用している場合のみ意味があります。", 13 | "previewServer.sync.description": "非同期かどうか。", 14 | "previewServer.ui.description": "UI ページの設定" 15 | } -------------------------------------------------------------------------------- /package.nls.ja.json: -------------------------------------------------------------------------------- 1 | { 2 | "extension.preview.title": "vscode-preview-server: サイドパネルでプレビュー表示", 3 | "extension.launch.title": "vscode-preview-server: ブラウザーで起動", 4 | "extension.stop.title": "vscode-preview-server: Web サーバーを停止", 5 | "extension.resume.title": "vscode-preview-server: Web サーバーを再起動", 6 | "extension.ui.title": "vscode-preview-server: UI ページを表示", 7 | "previewServer.browsers.description": "プレビュー表示するブラウザー。", 8 | "previewServer.ignoreDefaultBrowser.description": "既定のブラウザーを起動しない。", 9 | "previewServer.ignoreNotification.description": "通知を表示するかどうか。", 10 | "previewServer.isWatchConfiguration.description": "設定を変更したとき、Web サーバーを再起動するかどうか。", 11 | "previewServer.port.description": "Web サーバーのポート番号", 12 | "previewServer.proxy.description": "プロキシ URL で仮想ホストをラップして、サイトを表示します。", 13 | "previewServer.startupProject.description": "起動プロジェクト名。この設定は、ワークスペースを使用している場合のみ意味があります。", 14 | "previewServer.sync.description": "非同期かどうか。", 15 | "previewServer.ui.description": "UI ページの設定" 16 | } -------------------------------------------------------------------------------- /test/index.ts: -------------------------------------------------------------------------------- 1 | // 2 | // PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING 3 | // 4 | // This file is providing the test runner to use when running extension tests. 5 | // By default the test runner in use is Mocha based. 6 | // 7 | // You can provide your own test runner if you want to override it by exporting 8 | // a function run(testRoot: string, clb: (error:Error) => void) that the extension 9 | // host can call to run the tests. The test runner is expected to use console.log 10 | // to report the results back to the caller. When the tests are finished, return 11 | // a possible error to the callback or null if none. 12 | 13 | const testRunner = require("vscode/lib/testrunner"); 14 | 15 | // You can directly control Mocha options by uncommenting the following lines 16 | // See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info 17 | testRunner.configure({ 18 | ui: "tdd", // the TDD UI is being used in extension.test.ts (suite, test, etc.) 19 | useColors: true // colored output from test results 20 | }); 21 | 22 | module.exports = testRunner; 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Yuichi Nukiyama 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that compiles the extension and then opens it inside a new window 2 | { 3 | "version": "0.1.0", 4 | "configurations": [ 5 | { 6 | "name": "Extension", 7 | "type": "extensionHost", 8 | "request": "launch", 9 | "runtimeExecutable": "${execPath}", 10 | "args": ["--extensionDevelopmentPath=${workspaceRoot}" ], 11 | "stopOnEntry": false, 12 | "sourceMaps": true, 13 | "outFiles": [ "${workspaceRoot}/out/**/*.js" ], 14 | "preLaunchTask": "npm: watch" 15 | }, 16 | { 17 | "name": "Extension Tests", 18 | "type": "extensionHost", 19 | "request": "launch", 20 | "runtimeExecutable": "${execPath}", 21 | "args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test" ], 22 | "stopOnEntry": false, 23 | "sourceMaps": true, 24 | "outFiles": [ "${workspaceRoot}/out/test/**/*.js" ], 25 | "preLaunchTask": "npm: watch" 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /package.nls.json: -------------------------------------------------------------------------------- 1 | { 2 | "extension.preview.title": "vscode-preview-server: Preview on side panel", 3 | "extension.launch.title": "vscode-preview-server: Launch on browser", 4 | "extension.stop.title": "vscode-preview-server: Stop the web server", 5 | "extension.resume.title": "vscode-preview-server: Resume the web server", 6 | "extension.ui.title": "vscode-preview-server: Show UI Page", 7 | "previewServer.browsers.description": "Browsers to launch for preview.", 8 | "previewServer.ignoreDefaultBrowser.description": "Ignore default browsers.", 9 | "previewServer.ignoreNotification.description": "Controls wheter display notification or not.", 10 | "previewServer.isWatchConfiguration.description": "Controls whether resume the web Server or not, when change settings.", 11 | "previewServer.port.description": "Port number of the web Server.", 12 | "previewServer.proxy.description": "Wrap your vhost with a proxy URL to view your site.", 13 | "previewServer.startupProject.description": "Name of startup project. This setting is meaningful only when in the workspace.", 14 | "previewServer.sync.description": "Whether synchronized or not.", 15 | "previewServer.ui.description": "Settings for UI page." 16 | } -------------------------------------------------------------------------------- /src/browserContentProvider.ts: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | import * as vscode from "vscode"; 3 | import { Utility } from "./utility"; 4 | 5 | export class BrowserContentProvider implements vscode.TextDocumentContentProvider { 6 | private _onDidChange = new vscode.EventEmitter(); 7 | 8 | public provideTextDocumentContent() { 9 | const editor = vscode.window.activeTextEditor; 10 | const uri = Utility.getUriOfActiveEditor(); 11 | 12 | if (editor.document.languageId !== "html") { 13 | return ` 14 | 15 | Active editor doesn't show a HTML document 16 | `; 17 | } 18 | 19 | return ` 20 | 21 | 22 | 23 | 24 | 25 | Preview 26 | 27 | 28 | 29 |