├── test
├── lib.scss
├── index.tsx
├── index.min.css
├── dist
│ └── index.css
├── index.sass
├── index.jade
├── index.ts
├── index.pug
├── index.less
├── abc
│ └── lib.scss
├── index.vue
├── test.sass
├── .vscode
│ └── settings.json
├── index.js
├── index.scss
├── index.html
├── libs.less
└── libs1.styl
├── .npmignore
├── logos
├── hero2.png
├── hero3.png
├── hero4.png
├── hero5.png
└── others
│ ├── eno.png
│ ├── hero.png
│ └── hero2.jpeg
├── screenshots
├── 1.gif
├── 10.gif
├── 10.png
├── 2.gif
├── 3.gif
├── 4.gif
├── 5.gif
├── 6.gif
├── 7.gif
├── 8.gif
└── 9.png
├── .gitignore
├── push.sh
├── tslint.json
├── .vscodeignore
├── out
├── test
│ ├── index.js.map
│ ├── extension.test.js.map
│ ├── extension.test.js
│ └── index.js
├── .jshintrc
├── .jsbeautifyrc
├── compile.js
├── compile
│ ├── jade.js.map
│ ├── sass.js.map
│ ├── stylus.js.map
│ ├── pug.js.map
│ ├── jade.js
│ ├── javascript.js.map
│ ├── pug.js
│ ├── less.js.map
│ ├── javascript.js
│ ├── sass.js
│ ├── stylus.js
│ ├── typescriptx.js.map
│ ├── less.js
│ ├── typescript.js.map
│ ├── typescript.js
│ └── typescriptx.js
├── browser.js.map
├── status.js.map
├── browser.js
├── status.js
├── open.js.map
├── extension.js.map
├── open.js
├── extension.js
├── options.js
├── beautify.js
├── util.js.map
├── util.js
└── beautifyrc.json
├── tsconfig.json
├── src
├── test
│ ├── extension.test.ts
│ └── index.ts
├── compile
│ ├── pug.ts
│ ├── stylus.ts
│ ├── sass.ts
│ ├── javascript.ts
│ ├── less.ts
│ ├── typescript.ts
│ └── typescriptx.ts
├── browser.ts
├── status.ts
├── extension.ts
├── open.ts
└── util.ts
├── LICENSE
├── CHANGELOG.md
├── README.CN.md
├── package.json
└── README.md
/test/lib.scss:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/index.tsx:
--------------------------------------------------------------------------------
1 |
1234
--------------------------------------------------------------------------------
/test/index.min.css:
--------------------------------------------------------------------------------
1 | .container{color:#fff}
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | dist
2 | tests
3 | out
4 | node_modules
--------------------------------------------------------------------------------
/test/dist/index.css:
--------------------------------------------------------------------------------
1 | .nnn {
2 | color: white;
3 | }
--------------------------------------------------------------------------------
/test/index.sass:
--------------------------------------------------------------------------------
1 | .nnn
2 | color: white
3 |
--------------------------------------------------------------------------------
/test/index.jade:
--------------------------------------------------------------------------------
1 | h1 Compile Hero
2 | p Author:
3 | span Eno Yao
--------------------------------------------------------------------------------
/test/index.ts:
--------------------------------------------------------------------------------
1 | const a = 1;
2 | a = 1
3 |
4 | window.console.log(a);
5 |
6 |
7 |
--------------------------------------------------------------------------------
/logos/hero2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscats/compile-hero/master/logos/hero2.png
--------------------------------------------------------------------------------
/logos/hero3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscats/compile-hero/master/logos/hero3.png
--------------------------------------------------------------------------------
/logos/hero4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscats/compile-hero/master/logos/hero4.png
--------------------------------------------------------------------------------
/logos/hero5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscats/compile-hero/master/logos/hero5.png
--------------------------------------------------------------------------------
/screenshots/1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscats/compile-hero/master/screenshots/1.gif
--------------------------------------------------------------------------------
/screenshots/10.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscats/compile-hero/master/screenshots/10.gif
--------------------------------------------------------------------------------
/screenshots/10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscats/compile-hero/master/screenshots/10.png
--------------------------------------------------------------------------------
/screenshots/2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscats/compile-hero/master/screenshots/2.gif
--------------------------------------------------------------------------------
/screenshots/3.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscats/compile-hero/master/screenshots/3.gif
--------------------------------------------------------------------------------
/screenshots/4.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscats/compile-hero/master/screenshots/4.gif
--------------------------------------------------------------------------------
/screenshots/5.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscats/compile-hero/master/screenshots/5.gif
--------------------------------------------------------------------------------
/screenshots/6.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscats/compile-hero/master/screenshots/6.gif
--------------------------------------------------------------------------------
/screenshots/7.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscats/compile-hero/master/screenshots/7.gif
--------------------------------------------------------------------------------
/screenshots/8.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscats/compile-hero/master/screenshots/8.gif
--------------------------------------------------------------------------------
/screenshots/9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscats/compile-hero/master/screenshots/9.png
--------------------------------------------------------------------------------
/logos/others/eno.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscats/compile-hero/master/logos/others/eno.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .vscode-test/
3 | .vscode/**
4 | *.vsix
5 | tests
6 | auto.js
7 | auto2.js
--------------------------------------------------------------------------------
/logos/others/hero.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscats/compile-hero/master/logos/others/hero.png
--------------------------------------------------------------------------------
/logos/others/hero2.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscats/compile-hero/master/logos/others/hero2.jpeg
--------------------------------------------------------------------------------
/test/index.pug:
--------------------------------------------------------------------------------
1 | p 123123123123
2 | aaaaaaa 1231
3 | h1 ajslkdjasld
4 | a asdasdasasd
5 | a a a a a 12312
--------------------------------------------------------------------------------
/push.sh:
--------------------------------------------------------------------------------
1 | git add .
2 | echo -n "enter commit message:" ---:
3 | read name
4 | git commit -m"$name"
5 | git push origin master
--------------------------------------------------------------------------------
/test/index.less:
--------------------------------------------------------------------------------
1 | @import "./libs.less";
2 | p {
3 | color: red12;
4 |
5 | span {
6 | color: #ccc898;
7 |
8 | }
9 | }
--------------------------------------------------------------------------------
/test/abc/lib.scss:
--------------------------------------------------------------------------------
1 | $black: #000 !default;
2 | $border-radius: 0.25rem !default;
3 | $box-shadow: 0 0.5rem 1rem rgba($black, 0.15) !default;
4 |
5 | code {
6 | border-radius: $border-radius;
7 | box-shadow: $box-shadow;
8 | }
9 |
--------------------------------------------------------------------------------
/test/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
15 |
--------------------------------------------------------------------------------
/test/test.sass:
--------------------------------------------------------------------------------
1 | @import './index.scss'
2 | @import './index.sass'
3 | @import './index.css'
4 | // @import "./error.scss"
5 | .container
6 | color: white
7 |
8 | .abc
9 | position: absolute
10 | color: red
11 |
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rules": {
3 | "no-string-throw": true,
4 | "no-unused-expression": true,
5 | "no-duplicate-variable": true,
6 | "curly": true,
7 | "class-name": true,
8 | "semicolon": [
9 | true,
10 | "always"
11 | ],
12 | "triple-equals": true
13 | },
14 | "defaultSeverity": "warning"
15 | }
16 |
--------------------------------------------------------------------------------
/.vscodeignore:
--------------------------------------------------------------------------------
1 | .vscode/**
2 | .vscode-test/**
3 | out/test/**
4 | src/**
5 | .gitignore
6 | vsc-extension-quickstart.md
7 | **/tsconfig.json
8 | **/tslint.json
9 | **/*.map
10 | **/*.ts
11 | tests
12 | screenshots/**
13 | logos/others/**
14 | README.CN.md
15 | yarn.lock
16 | **.vsix
17 | logos/hero3.png
18 | logos/hero5.png
19 | logos/others/**
20 | publish.js
21 | test/**
22 | push.sh
--------------------------------------------------------------------------------
/out/test/index.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,mEAAmE;AACnE,EAAE;AACF,8EAA8E;AAC9E,oDAAoD;AACpD,EAAE;AACF,+EAA+E;AAC/E,0FAA0F;AAC1F,oGAAoG;AACpG,gFAAgF;AAChF,oDAAoD;;AAEpD,oDAAoD;AAEpD,8EAA8E;AAC9E,qFAAqF;AACrF,gBAAgB;AAChB,UAAU,CAAC,SAAS,CAAC;IACjB,EAAE,EAAE,KAAK;IACT,SAAS,EAAE,IAAI,CAAC,mCAAmC;CACtD,CAAC,CAAC;AAEH,MAAM,CAAC,OAAO,GAAG,UAAU,CAAC"}
--------------------------------------------------------------------------------
/test/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "compile-hero.disable-compile-files-on-did-save-code": false,
3 | "compile-hero.ignore": ["abc/**"],
4 | "compile-hero.generate-minified-javascript": true,
5 | "compile-hero.generate-minified-javascript-only": true,
6 | "compile-hero.generate-minified-css": true,
7 | "compile-hero.generate-minified-css-only": true,
8 | "compile-hero.generate-minified-html": true,
9 | "compile-hero.generate-minified-html-only": true
10 | }
--------------------------------------------------------------------------------
/out/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "devel": true,
3 | "eqeqeq": true,
4 | "expr": true,
5 | "freeze": true,
6 | "funcscope": true,
7 | "futurehostile": true,
8 | "lastsemic": true,
9 | "latedef": true,
10 | "indent": 1,
11 | "maxdepth": 5,
12 | "maxerr": 100,
13 | "noarg": true,
14 | "node": true,
15 | "nonbsp": true,
16 | "nonew": true,
17 | "strict": true,
18 | "undef": true,
19 | "unused": true,
20 | "esversion": 6,
21 | "varstmt": true
22 | }
--------------------------------------------------------------------------------
/out/test/extension.test.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"extension.test.js","sourceRoot":"","sources":["../../src/test/extension.test.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,kEAAkE;AAClE,wEAAwE;AACxE,EAAE;;AAEF,2DAA2D;AAC3D,iCAAiC;AAEjC,0DAA0D;AAC1D,8CAA8C;AAC9C,oCAAoC;AACpC,+CAA+C;AAE/C,qEAAqE;AACrE,KAAK,CAAC,iBAAiB,EAAE;IAErB,4BAA4B;IAC5B,IAAI,CAAC,aAAa,EAAE;QAChB,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QACvC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
--------------------------------------------------------------------------------
/test/index.js:
--------------------------------------------------------------------------------
1 | class A {
2 | plus(a, b) {
3 | window.enoDebug = () => { };
4 | enoDebug();
5 | let c = 1;
6 | window.a = 1;
7 | console.log(a, b);
8 | return a + b
9 | }
10 | }
11 | function plus(a, b) {
12 | let c = 1;
13 | window.a = 1;
14 | console.log(a, b);
15 | new A().plus(1, 2)
16 | return a + b
17 | }
18 | plus(1, 2);
19 |
20 | // debug(plus)
21 |
22 | function sum(a, b) {
23 | let result = a + b; // DevTools pauses on this line.
24 | return result;
25 | }
26 | // debug(sum); // Pass the function object, not a string.
27 | sum();
28 | console.trace('');
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "outDir": "out",
6 | "lib": [
7 | "es6"
8 | ],
9 | "sourceMap": true,
10 | "rootDir": "src",
11 | "strict": true /* enable all strict type-checking options */
12 | /* Additional Checks */
13 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
14 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
15 | // "noUnusedParameters": true, /* Report errors on unused parameters. */
16 | },
17 | "exclude": [
18 | "node_modules",
19 | ".vscode-test",
20 | "test",
21 | "src/auto"
22 | ]
23 | }
24 |
--------------------------------------------------------------------------------
/src/test/extension.test.ts:
--------------------------------------------------------------------------------
1 | //
2 | // Note: This example test is leveraging the Mocha test framework.
3 | // Please refer to their documentation on https://mochajs.org/ for help.
4 | //
5 |
6 | // The module 'assert' provides assertion methods from node
7 | import * as assert from 'assert';
8 |
9 | // You can import and use all API from the 'vscode' module
10 | // as well as import your extension to test it
11 | // import * as vscode from 'vscode';
12 | // import * as myExtension from '../extension';
13 |
14 | // Defines a Mocha test suite to group tests of similar kind together
15 | suite("Extension Tests", function () {
16 |
17 | // Defines a Mocha unit test
18 | test("Something 1", function() {
19 | assert.equal(-1, [1, 2, 3].indexOf(5));
20 | assert.equal(-1, [1, 2, 3].indexOf(0));
21 | });
22 | });
--------------------------------------------------------------------------------
/out/.jsbeautifyrc:
--------------------------------------------------------------------------------
1 | {
2 | "indent_with_tabs": false,
3 | "indent_size": 2,
4 | "max_preserve_newlines": 2,
5 | "preserve_newlines": true,
6 | "keep_array_indentation": true,
7 | "break_chained_methods": true,
8 | "wrap_line_length": 120,
9 | "end_with_newline": true,
10 | "brace_style": "collapse,preserve-inline",
11 | "unformatted": ["a", "abbr", "area", "audio", "b", "bdi", "bdo", "br", "button", "canvas", "cite", "code", "data",
12 | "datalist", "del", "dfn", "em", "embed", "i", "iframe", "img", "input", "ins", "kbd", "keygen", "label", "map",
13 | "mark", "math", "meter", "noscript", "object", "output", "progress", "q", "ruby", "s", "samp", "select", "small",
14 | "span", "strong", "sub", "sup", "template", "textarea", "time", "u", "var", "video", "wbr", "text", "acronym",
15 | "address", "big", "dt", "ins", "small", "strike", "tt", "pre", "h1", "h2", "h3", "h4", "h5", "h6"]
16 | }
--------------------------------------------------------------------------------
/out/test/extension.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | //
3 | // Note: This example test is leveraging the Mocha test framework.
4 | // Please refer to their documentation on https://mochajs.org/ for help.
5 | //
6 | Object.defineProperty(exports, "__esModule", { value: true });
7 | // The module 'assert' provides assertion methods from node
8 | const assert = require("assert");
9 | // You can import and use all API from the 'vscode' module
10 | // as well as import your extension to test it
11 | // import * as vscode from 'vscode';
12 | // import * as myExtension from '../extension';
13 | // Defines a Mocha test suite to group tests of similar kind together
14 | suite("Extension Tests", function () {
15 | // Defines a Mocha unit test
16 | test("Something 1", function () {
17 | assert.equal(-1, [1, 2, 3].indexOf(5));
18 | assert.equal(-1, [1, 2, 3].indexOf(0));
19 | });
20 | });
21 | //# sourceMappingURL=extension.test.js.map
--------------------------------------------------------------------------------
/test/index.scss:
--------------------------------------------------------------------------------
1 | // @forward "./index.sass";
2 | // @forward './index.sass' as ($blue: #0366d6);
3 | // @forward './index.sass' with (
4 | // $hue: 0 !default, // Can be overridden by upstream users.
5 | // $saturation: 50% // Cannot be overridden by upstream users.
6 | // );
7 |
8 |
9 | @use 'lib.scss' with ($black: #666);
10 | p {
11 | color: red;
12 | span {
13 | background-color: blue;
14 | }
15 | }
16 |
17 |
18 | // @import "./index.css";
19 |
20 | // @mixin special-text {
21 | // @include important-text;
22 | // @include link;
23 | // @include special-border;
24 | // }
25 |
26 | // /* Define mixin with two arguments */
27 | // @mixin bordered($color, $width) {
28 | // border: $width solid $color;
29 | // }
30 |
31 | // .myArticle {
32 | // @include bordered(blue, 1px); // Call mixin with two values
33 | // }
34 |
35 | // .myNotes {
36 | // @include bordered(red, 2px); // Call mixin with two values
37 | // }
38 |
--------------------------------------------------------------------------------
/test/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/test/libs.less:
--------------------------------------------------------------------------------
1 | .hljs-ln-numbers {
2 | -webkit-touch-callout: none;
3 | -webkit-user-select: none;
4 | -khtml-user-select: none;
5 | -moz-user-select: none;
6 | -ms-user-select: none;
7 | user-select: none;
8 |
9 | text-align: center;
10 | color: #ccc;
11 | //border-right: 1px solid #CCC;
12 | vertical-align: top;
13 | padding-right: 5px;
14 |
15 | /* your custom style here */
16 | }
17 |
18 | /* for block of code */
19 | .hljs-ln-code {
20 | padding-left: 10px !important;
21 | }
22 |
23 | td.hljs-ln-line.hljs-ln-numbers {
24 | width: 40px;
25 | text-align: center;
26 | background: rgba(200, 200, 200, 0.15);
27 | }
28 |
29 | .hljs-ln td,
30 | .hljs-ln th {
31 | border: none;
32 | line-height: 1.6rem;
33 | font-size: 14px;
34 | }
35 |
36 | .hljs-ln tbody tr:nth-of-type(odd) {
37 | background-color: #fafafa;
38 | }
39 |
40 | .hljs {
41 | padding: 0 !important;
42 | font-family: Consolas, "Microsoft YaHei", sans-serif, "Source Code Pro";
43 | }
44 |
45 | .hljs-ln {
46 | margin: 0 auto;
47 | }
--------------------------------------------------------------------------------
/test/libs1.styl:
--------------------------------------------------------------------------------
1 | .hljs-ln-numbers {
2 | -webkit-touch-callout: none;
3 | -webkit-user-select: none;
4 | -khtml-user-select: none;
5 | -moz-user-select: none;
6 | -ms-user-select: none;
7 | user-select: none;
8 |
9 | text-align: center;
10 | color: #ccc;
11 | //border-right: 1px solid #CCC;
12 | vertical-align: top;
13 | padding-right: 5px;
14 |
15 | /* your custom style here */
16 | }
17 |
18 | /* for block of code */
19 | .hljs-ln-code {
20 | padding-left: 10px !important;
21 | }
22 |
23 | td.hljs-ln-line.hljs-ln-numbers {
24 | width: 40px;
25 | text-align: center;
26 | background: rgba(200, 200, 200, 0.15);
27 | }
28 |
29 | .hljs-ln td,
30 | .hljs-ln th {
31 | border: none;
32 | line-height: 1.6rem;
33 | font-size: 14px;
34 | }
35 |
36 | .hljs-ln tbody tr:nth-of-type(odd) {
37 | background-color: #fafafa;
38 | }
39 |
40 | .hljs {
41 | padding: 0 !important;
42 | font-family: Consolas, "Microsoft YaHei", sans-serif, "Source Code Pro";
43 | }
44 |
45 | .hljs-ln {
46 | margin: 0 auto;
47 | }
--------------------------------------------------------------------------------
/out/compile.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const { src, dest } = require("gulp");
3 | const sass = require("sass");
4 | try {
5 | const { css } = sass.renderSync({ file: fileName });
6 | const text = css.toString();
7 | src(fileName)
8 | .pipe(empty(text))
9 | .pipe(rename({
10 | extname: ".css",
11 | }))
12 | .pipe(dest(outputPath))
13 | .pipe(dest(outputPath));
14 | if (compileOptions.generateMinifiedCss) {
15 | src(fileName)
16 | .pipe(empty(text))
17 | .pipe(rename({
18 | extname: ".css",
19 | }))
20 | .pipe(dest(outputPath))
21 | .pipe(cssmin({ compatibility: "ie7" }))
22 | .pipe(rename({
23 | extname: ".css",
24 | suffix: ".min",
25 | }))
26 | .pipe(dest(outputPath));
27 | }
28 | vscode.window.setStatusBarMessage(successMessage);
29 | }
30 | catch (error) {
31 | notificationStatus && vscode.window.showErrorMessage(error.message);
32 | vscode.window.setStatusBarMessage(errorMessage);
33 | }
34 | //# sourceMappingURL=compile.js.map
--------------------------------------------------------------------------------
/src/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(testsRoot: string, clb: (error: Error, failures?: number) => void): void
9 | // that the extension 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 | import * as testRunner from 'vscode/lib/testrunner';
14 |
15 | // You can directly control Mocha options by configuring the test runner below
16 | // See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options
17 | // for more info
18 | testRunner.configure({
19 | ui: 'tdd', // the TDD UI is being used in extension.test.ts (suite, test, etc.)
20 | useColors: true // colored output from test results
21 | });
22 |
23 | module.exports = testRunner;
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2019-2020 Eno Yao. https://github.com/wscats
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
13 | all 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
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/out/test/index.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | //
3 | // PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
4 | //
5 | // This file is providing the test runner to use when running extension tests.
6 | // By default the test runner in use is Mocha based.
7 | //
8 | // You can provide your own test runner if you want to override it by exporting
9 | // a function run(testsRoot: string, clb: (error: Error, failures?: number) => void): void
10 | // that the extension host can call to run the tests. The test runner is expected to use console.log
11 | // to report the results back to the caller. When the tests are finished, return
12 | // a possible error to the callback or null if none.
13 | Object.defineProperty(exports, "__esModule", { value: true });
14 | const testRunner = require("vscode/lib/testrunner");
15 | // You can directly control Mocha options by configuring the test runner below
16 | // See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options
17 | // for more info
18 | testRunner.configure({
19 | ui: 'tdd',
20 | useColors: true // colored output from test results
21 | });
22 | module.exports = testRunner;
23 | //# sourceMappingURL=index.js.map
--------------------------------------------------------------------------------
/out/compile/jade.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"jade.js","sourceRoot":"","sources":["../../src/compile/jade.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,kCAAsE;AACtE,iCAAiC;AACjC,6BAA6B;AAC7B,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7B,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AACtC,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAEzB,QAAA,UAAU,GAAG,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,kBAAkB,EAAE,cAAc,EAAE,YAAY,EAAU,EAAE,EAAE;IAC7G,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,IAAI,OAAO,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC9D,IAAI;QACA,IAAI,GAAG,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;KACpG;IAAC,OAAO,KAAK,EAAE;QACZ,kBAAkB,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACpE,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,mBAAY,CAAC,CAAC;KACnD;IAED,GAAG,CAAC,QAAQ,CAAC;SACR,IAAI,CAAC,YAAK,CAAC,IAAI,CAAC,CAAC;SACjB,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;SAClC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IAE5B,IAAI,cAAc,CAAC,oBAAoB,EAAE;QACrC,IAAI,GAAG,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC/E,GAAG,CAAC,QAAQ,CAAC;aACR,IAAI,CAAC,YAAK,CAAC,IAAI,CAAC,CAAC;aACjB,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;aAClD,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;KAC/B;IACD,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,qBAAc,CAAC,CAAC;AACtD,CAAC,CAAA"}
--------------------------------------------------------------------------------
/out/compile/sass.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"sass.js","sourceRoot":"","sources":["../../src/compile/sass.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAGH,iCAAiC;AACjC,6BAA6B;AAC7B,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AACtC,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7B,MAAM,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAC1C,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACtC,kCAA4E;AAE/D,QAAA,UAAU,GAAG,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,kBAAkB,EAAE,cAAc,EAAE,YAAY,EAAgB,EAAE,EAAE;IACnH,IAAI;QACA,YAAY,GAAG,YAAY,IAAI,IAAI,CAAC,UAAU,CAAC;YAC3C,IAAI,EAAE,YAAY;YAClB,iBAAiB;YACjB,YAAY,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;SAC7C,CAAC,CAAC,GAAG,CAAC;QACP,MAAM,IAAI,GAAG,YAAY,IAAI,IAAI,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QAEhF,IAAI,CAAC,cAAc,CAAC,uBAAuB,EAAE;YACzC,GAAG,CAAC,QAAQ,CAAC;iBACR,IAAI,CAAC,YAAK,CAAC,IAAI,CAAC,CAAC;iBACjB,IAAI,CACD,MAAM,CAAC;gBACH,OAAO,EAAE,MAAM;aAClB,CAAC,CACL;iBACA,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAA;SAC9B;QAED,IAAI,cAAc,CAAC,mBAAmB,EAAE;YACpC,GAAG,CAAC,QAAQ,CAAC;iBACR,IAAI,CAAC,YAAK,CAAC,IAAI,CAAC,CAAC;iBACjB,IAAI,CAAC,MAAM,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC;iBACtC,IAAI,CACD,MAAM,CAAC;gBACH,OAAO,EAAE,MAAM;gBACf,MAAM,EAAE,MAAM;aACjB,CAAC,CACL;iBACA,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;SAC/B;QACD,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,qBAAc,CAAC,CAAC;KACrD;IAAC,OAAO,KAAK,EAAE;QACZ,kBAAkB,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACpE,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,mBAAY,CAAC,CAAC;KACnD;AACL,CAAC,CAAA"}
--------------------------------------------------------------------------------
/out/compile/stylus.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"stylus.js","sourceRoot":"","sources":["../../src/compile/stylus.ts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C,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;iBACjD,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;iBACtB,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;gBACZ,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,qBAAc,CAAC,CAAC;YACtD,CAAC,CAAC,CAAC;SACV;KACJ;IAAC,OAAO,KAAK,EAAE;QACZ,kBAAkB,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACpE,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,mBAAY,CAAC,CAAC;KACnD;AACL,CAAC,CAAA"}
--------------------------------------------------------------------------------
/out/compile/pug.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"pug.js","sourceRoot":"","sources":["../../src/compile/pug.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAGH,kCAA4E;AAC5E,iCAAiC;AACjC,6BAA6B;AAC7B,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;AAC3B,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AACtC,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAEzB,QAAA,SAAS,GAAG,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,kBAAkB,EAAE,cAAc,EAAE,YAAY,EAAgB,EAAE,EAAE;IAClH,IAAI;QACA,IAAI,CAAC,cAAc,CAAC,wBAAwB,EAAE;YAC1C,MAAM,OAAO,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAChE,MAAM,IAAI,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YACrG,GAAG,CAAC,QAAQ,CAAC;iBACR,IAAI,CAAC,YAAK,CAAC,IAAI,CAAC,CAAC;iBACjB,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;iBAClC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;SAC/B;KACJ;IAAC,OAAO,KAAK,EAAE;QACZ,kBAAkB,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACpE,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,mBAAY,CAAC,CAAC;KACnD;IAED,IAAI,cAAc,CAAC,oBAAoB,EAAE;QACrC,MAAM,OAAO,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACrG,GAAG,CAAC,QAAQ,CAAC;aACR,IAAI,CAAC,YAAK,CAAC,IAAI,CAAC,CAAC;aACjB,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;aAClD,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;KAC/B;IACD,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,qBAAc,CAAC,CAAC;AACtD,CAAC,CAAA"}
--------------------------------------------------------------------------------
/out/compile/jade.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | /**
3 | * Copyright © 1998 - 2020 Tencent. All Rights Reserved.
4 | *
5 | * @author enoyao
6 | */
7 | Object.defineProperty(exports, "__esModule", { value: true });
8 | exports.jadeLoader = void 0;
9 | const util_1 = require("../util");
10 | const vscode = require("vscode");
11 | const path = require("path");
12 | const jade = require("jade");
13 | const { src, dest } = require("gulp");
14 | const rename = require("gulp-rename");
15 | exports.jadeLoader = ({ fileName, outputPath, notificationStatus, compileOptions, selectedText }) => {
16 | let html = "";
17 | let options = { pretty: true, filename: path.join(fileName) };
18 | try {
19 | html = selectedText ? jade.compile(selectedText, options)() : jade.renderFile(fileName, options);
20 | }
21 | catch (error) {
22 | notificationStatus && vscode.window.showErrorMessage(error.message);
23 | vscode.window.setStatusBarMessage(util_1.errorMessage);
24 | }
25 | src(fileName)
26 | .pipe(util_1.empty(html))
27 | .pipe(rename({ extname: ".html" }))
28 | .pipe(dest(outputPath));
29 | if (compileOptions.generateMinifiedHtml) {
30 | html = selectedText ? jade.compile(selectedText)() : jade.renderFile(fileName);
31 | src(fileName)
32 | .pipe(util_1.empty(html))
33 | .pipe(rename({ suffix: ".min", extname: ".html" }))
34 | .pipe(dest(outputPath));
35 | }
36 | vscode.window.setStatusBarMessage(util_1.successMessage);
37 | };
38 | //# sourceMappingURL=jade.js.map
--------------------------------------------------------------------------------
/out/compile/javascript.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"javascript.js","sourceRoot":"","sources":["../../src/compile/javascript.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAGH,iCAAiC;AACjC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AACtC,MAAM,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AACpC,MAAM,QAAQ,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC9C,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACtC,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACtC,kCAAqE;AAExD,QAAA,g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IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;KAC/B;IACD,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,qBAAc,CAAC,CAAC;AACtD,CAAC,CAAA"}
--------------------------------------------------------------------------------
/src/compile/pug.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © 1998 - 2020 Tencent. All Rights Reserved.
3 | *
4 | * @author enoyao
5 | */
6 |
7 |
8 | import { successMessage, errorMessage, empty, loaderOption } from '../util';
9 | import * as vscode from "vscode";
10 | import * as path from "path";
11 | const pug = require("pug");
12 | const { src, dest } = require("gulp");
13 | const rename = require("gulp-rename");
14 |
15 | export const pugLoader = ({ fileName, outputPath, notificationStatus, compileOptions, selectedText }: loaderOption) => {
16 | try {
17 | if (!compileOptions.generateMinifiedHtmlOnly) {
18 | const options = { pretty: true, filename: path.join(fileName) };
19 | const html = selectedText ? pug.compile(selectedText, options)() : pug.renderFile(fileName, options);
20 | src(fileName)
21 | .pipe(empty(html))
22 | .pipe(rename({ extname: ".html" }))
23 | .pipe(dest(outputPath));
24 | }
25 | } catch (error) {
26 | notificationStatus && vscode.window.showErrorMessage(error.message);
27 | vscode.window.setStatusBarMessage(errorMessage);
28 | }
29 |
30 | if (compileOptions.generateMinifiedHtml) {
31 | const options = { filename: path.join(fileName) };
32 | const html = selectedText ? pug.compile(selectedText, options)() : pug.renderFile(fileName, options);
33 | src(fileName)
34 | .pipe(empty(html))
35 | .pipe(rename({ suffix: ".min", extname: ".html" }))
36 | .pipe(dest(outputPath));
37 | }
38 | vscode.window.setStatusBarMessage(successMessage);
39 | }
--------------------------------------------------------------------------------
/out/compile/pug.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | /**
3 | * Copyright © 1998 - 2020 Tencent. All Rights Reserved.
4 | *
5 | * @author enoyao
6 | */
7 | Object.defineProperty(exports, "__esModule", { value: true });
8 | exports.pugLoader = void 0;
9 | const util_1 = require("../util");
10 | const vscode = require("vscode");
11 | const path = require("path");
12 | const pug = require("pug");
13 | const { src, dest } = require("gulp");
14 | const rename = require("gulp-rename");
15 | exports.pugLoader = ({ fileName, outputPath, notificationStatus, compileOptions, selectedText }) => {
16 | try {
17 | if (!compileOptions.generateMinifiedHtmlOnly) {
18 | const options = { pretty: true, filename: path.join(fileName) };
19 | const html = selectedText ? pug.compile(selectedText, options)() : pug.renderFile(fileName, options);
20 | src(fileName)
21 | .pipe(util_1.empty(html))
22 | .pipe(rename({ extname: ".html" }))
23 | .pipe(dest(outputPath));
24 | }
25 | }
26 | catch (error) {
27 | notificationStatus && vscode.window.showErrorMessage(error.message);
28 | vscode.window.setStatusBarMessage(util_1.errorMessage);
29 | }
30 | if (compileOptions.generateMinifiedHtml) {
31 | const options = { filename: path.join(fileName) };
32 | const html = selectedText ? pug.compile(selectedText, options)() : pug.renderFile(fileName, options);
33 | src(fileName)
34 | .pipe(util_1.empty(html))
35 | .pipe(rename({ suffix: ".min", extname: ".html" }))
36 | .pipe(dest(outputPath));
37 | }
38 | vscode.window.setStatusBarMessage(util_1.successMessage);
39 | };
40 | //# sourceMappingURL=pug.js.map
--------------------------------------------------------------------------------
/src/compile/stylus.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © 1998 - 2020 Tencent. All Rights Reserved.
3 | *
4 | * @author enoyao
5 | */
6 |
7 |
8 | import { successMessage, errorMessage, loaderOption, readFileContext, empty } from '../util';
9 | import * as path from "path";
10 | import * as vscode from "vscode";
11 | const { src, dest } = require("gulp");
12 | const stylus = require("stylus");
13 | const cssmin = require("gulp-minify-css");
14 | const rename = require("gulp-rename");
15 |
16 | export const stylusLoader = ({ fileName, outputPath, notificationStatus, compileOptions, selectedText }: loaderOption) => {
17 | try {
18 | const css = stylus.render(selectedText || readFileContext(fileName), {
19 | // 作用域,支持 @import
20 | paths: [path.join(fileName, '../')],
21 | })
22 | if (!compileOptions.generateMinifiedCssOnly) {
23 | src(fileName)
24 | .pipe(empty(css))
25 | .pipe(rename({ extname: ".css" }))
26 | .pipe(dest(outputPath))
27 | .on("end", () => {
28 | vscode.window.setStatusBarMessage(successMessage);
29 | });
30 | }
31 |
32 | if (compileOptions.generateMinifiedCss) {
33 | src(fileName)
34 | .pipe(empty(css))
35 | .pipe(cssmin({ compatibility: "ie7" }))
36 | .pipe(rename({ suffix: ".min", extname: ".css" }))
37 | .pipe(dest(outputPath))
38 | .on("end", () => {
39 | vscode.window.setStatusBarMessage(successMessage);
40 | });
41 | }
42 | } catch (error) {
43 | notificationStatus && vscode.window.showErrorMessage(error.message);
44 | vscode.window.setStatusBarMessage(errorMessage);
45 | }
46 | }
--------------------------------------------------------------------------------
/out/compile/less.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"less.js","sourceRoot":"","sources":["../../src/compile/less.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAGH,kCAA6F;AAC7F,iCAAiC;AACjC,6BAA6B;AAC7B,MAAM,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAC1C,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AACtC,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7B,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAEzB,QAAA,UAAU,GAAG,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,kBAAkB,EAAE,cAAc,EAAE,YAAY,EAAgB,EAAE,EAAE;IACnH,IAAI;QACA,IAAI,GAAG,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,CAAC,YAAY,IAAI,sBAAe,CAAC,QAAQ,CAAC,EAAE;YACnD,iBAAiB;YACjB,KAAK,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;SACtC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAW,EAAE,EAAE;YACpB,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;YAEjB,IAAI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,kBAAkB,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACpE,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,mBAAY,CAAC,CAAC;KACnD;AACL,CAAC,CAAA"}
--------------------------------------------------------------------------------
/out/compile/javascript.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | /**
3 | * Copyright © 1998 - 2020 Tencent. All Rights Reserved.
4 | *
5 | * @author enoyao
6 | */
7 | Object.defineProperty(exports, "__esModule", { value: true });
8 | exports.javascriptLoader = void 0;
9 | const vscode = require("vscode");
10 | const { src, dest } = require("gulp");
11 | const babel = require("gulp-babel");
12 | const babelEnv = require("@babel/preset-env");
13 | const uglify = require("gulp-uglify");
14 | const rename = require("gulp-rename");
15 | const util_1 = require("../util");
16 | exports.javascriptLoader = ({ fileName, outputPath, notificationStatus, compileOptions }) => {
17 | if (/.dev.js|.prod.js$/g.test(fileName)) {
18 | vscode.window.setStatusBarMessage(`The prod or dev file has been processed and will not be compiled.`);
19 | return;
20 | }
21 | if (!compileOptions.generateMinifiedJsOnly) {
22 | src(fileName)
23 | .pipe(babel({
24 | presets: [babelEnv],
25 | }).on("error", (error) => {
26 | notificationStatus && vscode.window.showErrorMessage(error.message);
27 | vscode.window.setStatusBarMessage(util_1.errorMessage);
28 | }))
29 | .pipe(rename({ suffix: ".dev" }))
30 | .pipe(dest(outputPath));
31 | }
32 | if (compileOptions.generateMinifiedJs) {
33 | src(fileName)
34 | .pipe(babel({
35 | presets: [babelEnv],
36 | }).on("error", (error) => {
37 | notificationStatus && vscode.window.showErrorMessage(error.message);
38 | vscode.window.setStatusBarMessage(util_1.errorMessage);
39 | }))
40 | .pipe(uglify())
41 | .pipe(rename({ suffix: ".prod" }))
42 | .pipe(dest(outputPath));
43 | }
44 | vscode.window.setStatusBarMessage(util_1.successMessage);
45 | };
46 | //# sourceMappingURL=javascript.js.map
--------------------------------------------------------------------------------
/out/compile/sass.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | /**
3 | * Copyright © 1998 - 2020 Tencent. All Rights Reserved.
4 | *
5 | * @author enoyao
6 | */
7 | Object.defineProperty(exports, "__esModule", { value: true });
8 | exports.sassLoader = void 0;
9 | const vscode = require("vscode");
10 | const path = require("path");
11 | const { src, dest } = require("gulp");
12 | const sass = require("sass");
13 | const cssmin = require("gulp-minify-css");
14 | const rename = require("gulp-rename");
15 | const util_1 = require("../util");
16 | exports.sassLoader = ({ fileName, outputPath, notificationStatus, compileOptions, selectedText }) => {
17 | try {
18 | selectedText = selectedText && sass.renderSync({
19 | data: selectedText,
20 | // 作用域,支持 @import
21 | includePaths: [path.join(fileName, '../')]
22 | }).css;
23 | const text = selectedText || sass.renderSync({ file: fileName }).css.toString();
24 | if (!compileOptions.generateMinifiedCssOnly) {
25 | src(fileName)
26 | .pipe(util_1.empty(text))
27 | .pipe(rename({
28 | extname: ".css",
29 | }))
30 | .pipe(dest(outputPath));
31 | }
32 | if (compileOptions.generateMinifiedCss) {
33 | src(fileName)
34 | .pipe(util_1.empty(text))
35 | .pipe(cssmin({ compatibility: "ie7" }))
36 | .pipe(rename({
37 | extname: ".css",
38 | suffix: ".min",
39 | }))
40 | .pipe(dest(outputPath));
41 | }
42 | vscode.window.setStatusBarMessage(util_1.successMessage);
43 | }
44 | catch (error) {
45 | notificationStatus && vscode.window.showErrorMessage(error.message);
46 | vscode.window.setStatusBarMessage(util_1.errorMessage);
47 | }
48 | };
49 | //# sourceMappingURL=sass.js.map
--------------------------------------------------------------------------------
/out/compile/stylus.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | /**
3 | * Copyright © 1998 - 2020 Tencent. All Rights Reserved.
4 | *
5 | * @author enoyao
6 | */
7 | Object.defineProperty(exports, "__esModule", { value: true });
8 | exports.stylusLoader = void 0;
9 | const util_1 = require("../util");
10 | const path = require("path");
11 | const vscode = require("vscode");
12 | const { src, dest } = require("gulp");
13 | const stylus = require("stylus");
14 | const cssmin = require("gulp-minify-css");
15 | const rename = require("gulp-rename");
16 | exports.stylusLoader = ({ fileName, outputPath, notificationStatus, compileOptions, selectedText }) => {
17 | try {
18 | const css = stylus.render(selectedText || util_1.readFileContext(fileName), {
19 | // 作用域,支持 @import
20 | paths: [path.join(fileName, '../')],
21 | });
22 | if (!compileOptions.generateMinifiedCssOnly) {
23 | src(fileName)
24 | .pipe(util_1.empty(css))
25 | .pipe(rename({ extname: ".css" }))
26 | .pipe(dest(outputPath))
27 | .on("end", () => {
28 | vscode.window.setStatusBarMessage(util_1.successMessage);
29 | });
30 | }
31 | if (compileOptions.generateMinifiedCss) {
32 | src(fileName)
33 | .pipe(util_1.empty(css))
34 | .pipe(cssmin({ compatibility: "ie7" }))
35 | .pipe(rename({ suffix: ".min", extname: ".css" }))
36 | .pipe(dest(outputPath))
37 | .on("end", () => {
38 | vscode.window.setStatusBarMessage(util_1.successMessage);
39 | });
40 | }
41 | }
42 | catch (error) {
43 | notificationStatus && vscode.window.showErrorMessage(error.message);
44 | vscode.window.setStatusBarMessage(util_1.errorMessage);
45 | }
46 | };
47 | //# sourceMappingURL=stylus.js.map
--------------------------------------------------------------------------------
/src/compile/sass.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © 1998 - 2020 Tencent. All Rights Reserved.
3 | *
4 | * @author enoyao
5 | */
6 |
7 |
8 | import * as vscode from "vscode";
9 | import * as path from "path";
10 | const { src, dest } = require("gulp");
11 | const sass = require("sass");
12 | const cssmin = require("gulp-minify-css");
13 | const rename = require("gulp-rename");
14 | import { empty, successMessage, errorMessage, loaderOption } from '../util';
15 |
16 | export const sassLoader = ({ fileName, outputPath, notificationStatus, compileOptions, selectedText }: loaderOption) => {
17 | try {
18 | selectedText = selectedText && sass.renderSync({
19 | data: selectedText,
20 | // 作用域,支持 @import
21 | includePaths: [path.join(fileName, '../')]
22 | }).css;
23 | const text = selectedText || sass.renderSync({ file: fileName }).css.toString();
24 |
25 | if (!compileOptions.generateMinifiedCssOnly) {
26 | src(fileName)
27 | .pipe(empty(text))
28 | .pipe(
29 | rename({
30 | extname: ".css",
31 | })
32 | )
33 | .pipe(dest(outputPath))
34 | }
35 |
36 | if (compileOptions.generateMinifiedCss) {
37 | src(fileName)
38 | .pipe(empty(text))
39 | .pipe(cssmin({ compatibility: "ie7" }))
40 | .pipe(
41 | rename({
42 | extname: ".css",
43 | suffix: ".min",
44 | })
45 | )
46 | .pipe(dest(outputPath));
47 | }
48 | vscode.window.setStatusBarMessage(successMessage);
49 | } catch (error) {
50 | notificationStatus && vscode.window.showErrorMessage(error.message);
51 | vscode.window.setStatusBarMessage(errorMessage);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/out/browser.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AASH,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;AAElC,MAAM,UAAU,GAAa;IAC3B,WAAW,EAAE,qBAAqB;IAClC,MAAM,EAAE,+DAA+D;IACvE,KAAK,EAAE,eAAe;IACtB,YAAY,EAAE,QAAQ,KAAK,OAAO;QAChC,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,CACA,QAAQ,KAAK,QAAQ;YACnB,CAAC,CAAC,eAAe;YACjB,CAAC,CAAC,eAAe,CACpB;IACH,UAAU,EAAE,CAAC,QAAQ,EAAE,eAAe,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,CAAC;CACxE,CAAC;AAEF,MAAM,YAAY,GAAa;IAC7B,WAAW,EAAE,KAAK;IAClB,MAAM,EAAE,+DAA+D;IACvE,KAAK,EAAE,iBAAiB;IACxB,YAAY,EAAE,UAAU;IACxB,UAAU,EAAE,CAAC,UAAU,CAAC;CACzB,CAAC;AACF,MAAM,WAAW,GAAa;IAC5B,WAAW,EAAE,qBAAqB;IAClC,MAAM,EAAE,wCAAwC;IAChD,KAAK,EAAE,iBAAiB;IACxB,YAAY,EAAE,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,CAAC,QAAQ,CAAC,CAAC;CACzB;KAAM,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE;IACxC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC1B,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC5B,QAAQ,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;CACrC;AAEY,QAAA,aAAa,GAAG;IAC3B,QAAQ,EAAE,QAAQ;IAClB,GAAG,EAAE,iBAAiB;CACvB,CAAC"}
--------------------------------------------------------------------------------
/src/compile/javascript.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © 1998 - 2020 Tencent. All Rights Reserved.
3 | *
4 | * @author enoyao
5 | */
6 |
7 |
8 | import * as vscode from "vscode";
9 | const { src, dest } = require("gulp");
10 | const babel = require("gulp-babel");
11 | const babelEnv = require("@babel/preset-env");
12 | const uglify = require("gulp-uglify");
13 | const rename = require("gulp-rename");
14 | import { successMessage, errorMessage, loaderOption } from '../util';
15 |
16 | export const javascriptLoader = ({ fileName, outputPath, notificationStatus, compileOptions }: loaderOption) => {
17 | if (/.dev.js|.prod.js$/g.test(fileName)) {
18 | vscode.window.setStatusBarMessage(
19 | `The prod or dev file has been processed and will not be compiled.`
20 | );
21 | return;
22 | }
23 |
24 | if (!compileOptions.generateMinifiedJsOnly) {
25 | src(fileName)
26 | .pipe(
27 | babel({
28 | presets: [babelEnv],
29 | }).on("error", (error: any) => {
30 | notificationStatus && vscode.window.showErrorMessage(error.message);
31 | vscode.window.setStatusBarMessage(errorMessage);
32 | })
33 | )
34 | .pipe(rename({ suffix: ".dev" }))
35 | .pipe(dest(outputPath));
36 | }
37 |
38 | if (compileOptions.generateMinifiedJs) {
39 | src(fileName)
40 | .pipe(
41 | babel({
42 | presets: [babelEnv],
43 | }).on("error", (error: any) => {
44 | notificationStatus && vscode.window.showErrorMessage(error.message);
45 | vscode.window.setStatusBarMessage(errorMessage);
46 | })
47 | )
48 | .pipe(uglify())
49 | .pipe(rename({ suffix: ".prod" }))
50 | .pipe(dest(outputPath));
51 | }
52 | vscode.window.setStatusBarMessage(successMessage);
53 | }
--------------------------------------------------------------------------------
/out/status.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"status.js","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAGH,iCAAiC;AAEjC,MAAa,WAAW;IAEZ,MAAM,KAAK,aAAa;QAC5B,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE;YAC7B,WAAW,CAAC,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,kBAAkB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YACrG,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;SAC7B;QACD,OAAO,WAAW,CAAC,cAAc,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,IAAI;QACP,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;IAC9B,CAAC;IAED,MAAM,CAAC,IAAI;QACP,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;IAC9B,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,gCAAwC;QAChD,WAAW,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QACnC,UAAU,CAAC;YACP,gCAAgC,CAAC,CAAC,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;QAC1F,CAAC,EAAE,IAAI,CAAC,CAAC;IACb,CAAC;IAED,MAAM,CAAC,QAAQ;QACX,WAAW,CAAC,aAAa,CAAC,IAAI,GAAG,yBAAyB,CAAC;QAC3D,WAAW,CAAC,aAAa,CAAC,KAAK,GAAG,SAAS,CAAC;QAC5C,WAAW,CAAC,aAAa,CAAC,OAAO,GAAG,4BAA4B,CAAC;QACjE,WAAW,CAAC,aAAa,CAAC,OAAO,GAAG,uBAAuB,CAAC;IACh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G,SAAS,CAAC;gBAC5C,WAAW,CAAC,QAAQ,EAAE,CAAC;YAC3B,CAAC,EAAE,IAAI,CAAC,CAAC;SACZ;aACI;YACD,WAAW,CAAC,WAAW,EAAE,CAAC;SAC7B;IACL,CAAC;IAED,MAAM,CAAC,OAAO;QACV,WAAW,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;IACxC,CAAC;CACJ;AA7ED,kCA6EC"}
--------------------------------------------------------------------------------
/src/compile/less.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © 1998 - 2020 Tencent. All Rights Reserved.
3 | *
4 | * @author enoyao
5 | */
6 |
7 |
8 | import { successMessage, errorMessage, loaderOption, readFileContext, empty } from '../util';
9 | import * as vscode from "vscode";
10 | import * as path from "path";
11 | const cssmin = require("gulp-minify-css");
12 | const { src, dest } = require("gulp");
13 | const less = require("less");
14 | const rename = require("gulp-rename");
15 |
16 | export const lessLoader = ({ fileName, outputPath, notificationStatus, compileOptions, selectedText }: loaderOption) => {
17 | try {
18 | let css = "";
19 | less.render(selectedText || readFileContext(fileName), {
20 | // 作用域,支持 @import
21 | paths: [path.join(fileName, '../')]
22 | }).then((output: any) => {
23 | css = output.css;
24 |
25 | if (!compileOptions.generateMinifiedCssOnly) {
26 | src(fileName)
27 | .pipe(empty(css))
28 | .pipe(rename({ extname: ".css" }))
29 | .pipe(dest(outputPath))
30 | .on("end", () => {
31 | vscode.window.setStatusBarMessage(successMessage);
32 | });
33 | }
34 |
35 | if (compileOptions.generateMinifiedCss) {
36 | src(fileName)
37 | .pipe(empty(css))
38 | .pipe(cssmin({ compatibility: "ie7" }))
39 | .pipe(rename({ suffix: ".min", extname: ".css" }))
40 | .pipe(dest(outputPath))
41 | .on("end", () => {
42 | vscode.window.setStatusBarMessage(successMessage);
43 | });
44 | }
45 | }).catch((error: any) => {
46 | const message = error.message + ' in file ' + error.filename + ' line no. ' + error.line;
47 | notificationStatus && vscode.window.showErrorMessage(message);
48 | vscode.window.setStatusBarMessage(errorMessage);
49 | });
50 | } catch (error) {
51 | notificationStatus && vscode.window.showErrorMessage(error.message);
52 | vscode.window.setStatusBarMessage(errorMessage);
53 | }
54 | }
--------------------------------------------------------------------------------
/out/compile/typescriptx.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"typescriptx.js","sourceRoot":"","sources":["../../src/compile/typescriptx.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,kCAAqE;AACrE,6BAA6B;AAC7B,yBAAyB;AACzB,iCAAiC;AACjC,MAAM,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AACtC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AACtC,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACtC,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAEzB,QAAA,iBAAiB,GAAG,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,kBAAkB,EAAE,cAAc,EAAgB,EAAE,EAAE;IAC5G,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;IAC9D,MAAM,qBAAqB,GAAG,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAE3D,IAAI,CAAC,cAAc,CAAC,sBAAsB,EAAE;QACxC,GAAG,CAAC,QAAQ,CAAC;aACR,IAAI,CAAC,CAAC,GAAG,EAAE;YACR,IAAI,qBAAqB,EAAE;gBACvB,MAAM,SAAS,GAAG,EAAE,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;gBAClD,OAAO,EAAE,CAAC;oBACN,GAAG,EAAE,OAAO;iBACf,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAU,EAAE,EAAE;oBAC5C,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,KAAK,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,CAAC,OAAO,CAAC,CAAC;oBACvD,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,mBAAY,CAAC,CAAC;gBACpD,CAAC,CAAC,CAAA;aACL;QACL,CAAC,CAAC,EAAE,CAAC;aACJ,IAAI,CAAC,MAAM,EAAE,CAAC;aACd,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;aAClC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;KAC/B;IACD,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,qBAAc,CAAC,CAAC;AACtD,CAAC,CAAA"}
--------------------------------------------------------------------------------
/out/compile/less.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | /**
3 | * Copyright © 1998 - 2020 Tencent. All Rights Reserved.
4 | *
5 | * @author enoyao
6 | */
7 | Object.defineProperty(exports, "__esModule", { value: true });
8 | exports.lessLoader = void 0;
9 | const util_1 = require("../util");
10 | const vscode = require("vscode");
11 | const path = require("path");
12 | const cssmin = require("gulp-minify-css");
13 | const { src, dest } = require("gulp");
14 | const less = require("less");
15 | const rename = require("gulp-rename");
16 | exports.lessLoader = ({ fileName, outputPath, notificationStatus, compileOptions, selectedText }) => {
17 | try {
18 | let css = "";
19 | less.render(selectedText || util_1.readFileContext(fileName), {
20 | // 作用域,支持 @import
21 | paths: [path.join(fileName, '../')]
22 | }).then((output) => {
23 | css = output.css;
24 | if (!compileOptions.generateMinifiedCssOnly) {
25 | src(fileName)
26 | .pipe(util_1.empty(css))
27 | .pipe(rename({ extname: ".css" }))
28 | .pipe(dest(outputPath))
29 | .on("end", () => {
30 | vscode.window.setStatusBarMessage(util_1.successMessage);
31 | });
32 | }
33 | if (compileOptions.generateMinifiedCss) {
34 | src(fileName)
35 | .pipe(util_1.empty(css))
36 | .pipe(cssmin({ compatibility: "ie7" }))
37 | .pipe(rename({ suffix: ".min", extname: ".css" }))
38 | .pipe(dest(outputPath))
39 | .on("end", () => {
40 | vscode.window.setStatusBarMessage(util_1.successMessage);
41 | });
42 | }
43 | }).catch((error) => {
44 | const message = error.message + ' in file ' + error.filename + ' line no. ' + error.line;
45 | notificationStatus && vscode.window.showErrorMessage(message);
46 | vscode.window.setStatusBarMessage(util_1.errorMessage);
47 | });
48 | }
49 | catch (error) {
50 | notificationStatus && vscode.window.showErrorMessage(error.message);
51 | vscode.window.setStatusBarMessage(util_1.errorMessage);
52 | }
53 | };
54 | //# sourceMappingURL=less.js.map
--------------------------------------------------------------------------------
/out/compile/typescript.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"typescript.js","sourceRoot":"","sources":["../../src/compile/typescript.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,kCAAqE;AACrE,6BAA6B;AAC7B,yBAAyB;AACzB,iCAAiC;AACjC,MAAM,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AACtC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AACtC,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACtC,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAEzB,QAAA,gBAAgB,GAAG,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,kBAAkB,EAAE,cAAc,EAAgB,EAAE,EAAE;IAC3G,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;IAC7D,MAAM,oBAAoB,GAAG,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,CAAA;IAExD,IAAI,CAAC,cAAc,CAAC,sBAAsB,EAAE;QACxC,GAAG,CAAC,QAAQ,CAAC;aACR,IAAI,CAAC,CAAC,GAAG,EAAE;YACR,IAAI,oBAAoB,EAAE;gBACtB,MAAM,QAAQ,GAAG,EAAE,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;gBAChD,OAA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ACnC,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;oBACvD,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,mBAAY,CAAC,CAAC;gBACpD,CAAC,CAAC,CAAA;aACL;QACL,CAAC,CAAC,EAAE,CAAC;aACJ,IAAI,CACD,MAAM,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAU,EAAE,EAAE;YAChC,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACvD,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,mBAAY,CAAC,CAAC;QACpD,CAAC,CAAC,CACL;aACA,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;aAClC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;KAC/B;IACD,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,qBAAc,CAAC,CAAC;AACtD,CAAC,CAAA"}
--------------------------------------------------------------------------------
/out/compile/typescript.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | /**
3 | * Copyright © 1998 - 2020 Tencent. All Rights Reserved.
4 | *
5 | * @author enoyao
6 | */
7 | Object.defineProperty(exports, "__esModule", { value: true });
8 | exports.typescriptLoader = void 0;
9 | const util_1 = require("../util");
10 | const path = require("path");
11 | const fs = require("fs");
12 | const vscode = require("vscode");
13 | const ts = require("gulp-typescript");
14 | const { src, dest } = require("gulp");
15 | const uglify = require("gulp-uglify");
16 | const rename = require("gulp-rename");
17 | exports.typescriptLoader = ({ fileName, outputPath, notificationStatus, compileOptions }) => {
18 | const tsConfigPath = path.join(fileName, '../tsconfig.json');
19 | const isExistsTsconfigPath = fs.existsSync(tsConfigPath);
20 | if (!compileOptions.generateMinifiedJsOnly) {
21 | src(fileName)
22 | .pipe((() => {
23 | if (isExistsTsconfigPath) {
24 | const tsConfig = ts.createProject(tsConfigPath);
25 | return ts().pipe(tsConfig()).on("error", (error) => {
26 | false && vscode.window.showErrorMessage(error.message);
27 | vscode.window.setStatusBarMessage(util_1.errorMessage);
28 | });
29 | }
30 | else {
31 | return ts().on("error", (error) => {
32 | false && vscode.window.showErrorMessage(error.message);
33 | vscode.window.setStatusBarMessage(util_1.errorMessage);
34 | });
35 | }
36 | })())
37 | .pipe(dest(outputPath));
38 | }
39 | if (compileOptions.generateMinifiedJs) {
40 | src(fileName)
41 | .pipe((() => {
42 | if (isExistsTsconfigPath) {
43 | const tsConfig = ts.createProject(tsConfigPath);
44 | return ts().pipe(tsConfig()).on("error", (error) => {
45 | false && vscode.window.showErrorMessage(error.message);
46 | vscode.window.setStatusBarMessage(util_1.errorMessage);
47 | });
48 | }
49 | else {
50 | return ts().on("error", (error) => {
51 | false && vscode.window.showErrorMessage(error.message);
52 | vscode.window.setStatusBarMessage(util_1.errorMessage);
53 | });
54 | }
55 | })())
56 | .pipe(uglify().on("error", (error) => {
57 | false && vscode.window.showErrorMessage(error.message);
58 | vscode.window.setStatusBarMessage(util_1.errorMessage);
59 | }))
60 | .pipe((rename({ suffix: ".min" })))
61 | .pipe(dest(outputPath));
62 | }
63 | vscode.window.setStatusBarMessage(util_1.successMessage);
64 | };
65 | //# sourceMappingURL=typescript.js.map
--------------------------------------------------------------------------------
/src/compile/typescript.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © 1998 - 2020 Tencent. All Rights Reserved.
3 | *
4 | * @author enoyao
5 | */
6 |
7 | import { successMessage, errorMessage, loaderOption } from '../util';
8 | import * as path from "path";
9 | import * as fs from "fs";
10 | import * as vscode from "vscode";
11 | const ts = require("gulp-typescript");
12 | const { src, dest } = require("gulp");
13 | const uglify = require("gulp-uglify");
14 | const rename = require("gulp-rename");
15 |
16 | export const typescriptLoader = ({ fileName, outputPath, notificationStatus, compileOptions }: loaderOption) => {
17 | const tsConfigPath = path.join(fileName, '../tsconfig.json');
18 | const isExistsTsconfigPath = fs.existsSync(tsConfigPath)
19 |
20 | if (!compileOptions.generateMinifiedJsOnly) {
21 | src(fileName)
22 | .pipe((() => {
23 | if (isExistsTsconfigPath) {
24 | const tsConfig = ts.createProject(tsConfigPath);
25 | return ts().pipe(tsConfig()).on("error", (error: any) => {
26 | false && vscode.window.showErrorMessage(error.message);
27 | vscode.window.setStatusBarMessage(errorMessage);
28 | })
29 | } else {
30 | return ts().on("error", (error: any) => {
31 | false && vscode.window.showErrorMessage(error.message);
32 | vscode.window.setStatusBarMessage(errorMessage);
33 | })
34 | }
35 | })())
36 | .pipe(dest(outputPath));
37 | }
38 | if (compileOptions.generateMinifiedJs) {
39 | src(fileName)
40 | .pipe((() => {
41 | if (isExistsTsconfigPath) {
42 | const tsConfig = ts.createProject(tsConfigPath);
43 | return ts().pipe(tsConfig()).on("error", (error: any) => {
44 | false && vscode.window.showErrorMessage(error.message);
45 | vscode.window.setStatusBarMessage(errorMessage);
46 | })
47 | } else {
48 | return ts().on("error", (error: any) => {
49 | false && vscode.window.showErrorMessage(error.message);
50 | vscode.window.setStatusBarMessage(errorMessage);
51 | })
52 | }
53 | })())
54 | .pipe(
55 | uglify().on("error", (error: any) => {
56 | false && vscode.window.showErrorMessage(error.message);
57 | vscode.window.setStatusBarMessage(errorMessage);
58 | })
59 | )
60 | .pipe((rename({ suffix: ".min" })))
61 | .pipe(dest(outputPath));
62 | }
63 | vscode.window.setStatusBarMessage(successMessage);
64 | }
--------------------------------------------------------------------------------
/out/browser.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | /**
3 | * Copyright © 1998 - 2020 Tencent. All Rights Reserved.
4 | *
5 | * @author enoyao
6 | */
7 | Object.defineProperty(exports, "__esModule", { value: true });
8 | exports.browserConfig = void 0;
9 | const platform = process.platform;
10 | const chromeItem = {
11 | description: "Windows, Mac, Linux",
12 | detail: "A fast, secure, and free web browser built for the modern web",
13 | label: "Google Chrome",
14 | standardName: platform === 'win32'
15 | ? 'chrome'
16 | : (platform === 'darwin'
17 | ? 'google chrome'
18 | : 'google-chrome'),
19 | acceptName: ['chrome', 'google chrome', 'google-chrome', 'gc', '谷歌浏览器']
20 | };
21 | const chromiumItem = {
22 | description: "Mac",
23 | detail: "A fast, secure, and free web browser built for the modern web",
24 | label: "Google Chromium",
25 | standardName: "Chromium",
26 | acceptName: ['chromium']
27 | };
28 | const firefoxItem = {
29 | description: "Windows, Mac, Linux",
30 | detail: "A fast, smart and personal web browser",
31 | label: "Mozilla Firefox",
32 | standardName: "firefox",
33 | acceptName: ['firefox', 'ff', 'mozilla firefox', '火狐浏览器']
34 | };
35 | const firefoxDeveloperItem = {
36 | description: "Mac",
37 | detail: "A fast, smart and personal web browser",
38 | label: "Mozilla Firefox Developer Edition",
39 | standardName: "FirefoxDeveloperEdition",
40 | acceptName: ['firefox developer', 'fde', 'firefox developer edition']
41 | };
42 | const ieItem = {
43 | description: "Windows",
44 | detail: "A slightly outdated browser",
45 | label: "Microsoft IE",
46 | standardName: "iexplore",
47 | acceptName: ['ie', 'iexplore']
48 | };
49 | const edgeItem = {
50 | description: "Windows",
51 | detail: "A modern browser aiming to replace ie",
52 | label: "Microsoft Edge",
53 | standardName: "MicrosoftEdge",
54 | acceptName: ['edge', 'msedge', 'microsoftedge']
55 | };
56 | const safariItem = {
57 | description: "Mac",
58 | detail: "A fast, efficient browser on Mac",
59 | label: "Apple Safari",
60 | standardName: "safari",
61 | acceptName: ['safari']
62 | };
63 | const operaItem = {
64 | description: "Windows, Mac",
65 | detail: 'A fast, secure, easy-to-use browser',
66 | label: 'Opera',
67 | standardName: 'opera',
68 | acceptName: ['opera']
69 | };
70 | const browsers = [chromeItem, firefoxItem, operaItem];
71 | if (process.platform === 'win32') {
72 | browsers.push(ieItem);
73 | browsers.push(edgeItem);
74 | }
75 | else if (process.platform === 'darwin') {
76 | browsers.push(safariItem);
77 | browsers.push(chromiumItem);
78 | browsers.push(firefoxDeveloperItem);
79 | }
80 | exports.browserConfig = {
81 | browsers: browsers,
82 | app: 'open-in-browser'
83 | };
84 | //# sourceMappingURL=browser.js.map
--------------------------------------------------------------------------------
/src/browser.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © 1998 - 2020 Tencent. All Rights Reserved.
3 | *
4 | * @author enoyao
5 | */
6 |
7 |
8 | import { QuickPickItem } from "vscode";
9 |
10 | interface PickItem extends QuickPickItem {
11 | [propName: string]: any;
12 | }
13 |
14 | const platform = process.platform;
15 |
16 | const chromeItem: PickItem = {
17 | description: "Windows, Mac, Linux",
18 | detail: "A fast, secure, and free web browser built for the modern web",
19 | label: "Google Chrome",
20 | standardName: platform === 'win32'
21 | ? 'chrome'
22 | : (
23 | platform === 'darwin'
24 | ? 'google chrome'
25 | : 'google-chrome'
26 | ),
27 | acceptName: ['chrome', 'google chrome', 'google-chrome', 'gc', '谷歌浏览器']
28 | };
29 |
30 | const chromiumItem: PickItem = {
31 | description: "Mac",
32 | detail: "A fast, secure, and free web browser built for the modern web",
33 | label: "Google Chromium",
34 | standardName: "Chromium",
35 | acceptName: ['chromium']
36 | };
37 | const firefoxItem: PickItem = {
38 | description: "Windows, Mac, Linux",
39 | detail: "A fast, smart and personal web browser",
40 | label: "Mozilla Firefox",
41 | standardName: "firefox",
42 | acceptName: ['firefox', 'ff', 'mozilla firefox', '火狐浏览器']
43 | };
44 | const firefoxDeveloperItem: PickItem = {
45 | description: "Mac",
46 | detail: "A fast, smart and personal web browser",
47 | label: "Mozilla Firefox Developer Edition",
48 | standardName: "FirefoxDeveloperEdition",
49 | acceptName: ['firefox developer', 'fde', 'firefox developer edition']
50 | };
51 |
52 | const ieItem: PickItem = {
53 | description: "Windows",
54 | detail: "A slightly outdated browser",
55 | label: "Microsoft IE",
56 | standardName: "iexplore",
57 | acceptName: ['ie', 'iexplore']
58 | };
59 | const edgeItem: PickItem = {
60 | description: "Windows",
61 | detail: "A modern browser aiming to replace ie",
62 | label: "Microsoft Edge",
63 | standardName: "MicrosoftEdge",
64 | acceptName: ['edge', 'msedge', 'microsoftedge']
65 | };
66 |
67 | const safariItem: PickItem = {
68 | description: "Mac",
69 | detail: "A fast, efficient browser on Mac",
70 | label: "Apple Safari",
71 | standardName: "safari",
72 | acceptName: ['safari']
73 | };
74 |
75 | const operaItem: PickItem = {
76 | description: "Windows, Mac",
77 | detail: 'A fast, secure, easy-to-use browser',
78 | label: 'Opera',
79 | standardName: 'opera',
80 | acceptName: ['opera']
81 | };
82 |
83 | const browsers = [chromeItem, firefoxItem, operaItem];
84 |
85 | if (process.platform === 'win32') {
86 | browsers.push(ieItem);
87 | browsers.push(edgeItem);
88 | } else if (process.platform === 'darwin') {
89 | browsers.push(safariItem);
90 | browsers.push(chromiumItem);
91 | browsers.push(firefoxDeveloperItem);
92 | }
93 |
94 | export const browserConfig = {
95 | browsers: browsers,
96 | app: 'open-in-browser'
97 | };
--------------------------------------------------------------------------------
/src/compile/typescriptx.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © 1998 - 2020 Tencent. All Rights Reserved.
3 | *
4 | * @author enoyao
5 | */
6 |
7 | import { successMessage, errorMessage, loaderOption } from '../util';
8 | import * as path from "path";
9 | import * as fs from "fs";
10 | import * as vscode from "vscode";
11 | const ts = require("gulp-typescript");
12 | const { src, dest } = require("gulp");
13 | const uglify = require("gulp-uglify");
14 | const rename = require("gulp-rename");
15 |
16 | export const typescriptxLoader = ({ fileName, outputPath, notificationStatus, compileOptions }: loaderOption) => {
17 | const tsxConfigPath = path.join(fileName, '../tsconfig.json');
18 | const isExistsTsxconfigPath = fs.existsSync(tsxConfigPath);
19 |
20 | if (!compileOptions.generateMinifiedJsOnly) {
21 | src(fileName)
22 | .pipe((() => {
23 | if (isExistsTsxconfigPath) {
24 | const tsxConfig = ts.createProject(tsxConfigPath);
25 | return ts({
26 | jsx: "react",
27 | }).pipe(tsxConfig()).on("error", (error: any) => {
28 | false && vscode.window.showErrorMessage(error.message);
29 | vscode.window.setStatusBarMessage(errorMessage);
30 | })
31 | } else {
32 | return ts({
33 | jsx: "react",
34 | }).on("error", (error: any) => {
35 | false && vscode.window.showErrorMessage(error.message);
36 | vscode.window.setStatusBarMessage(errorMessage);
37 | })
38 | }
39 | })())
40 | .pipe(dest(outputPath));
41 | }
42 |
43 | if (compileOptions.generateMinifiedJs) {
44 | src(fileName)
45 | .pipe((() => {
46 | if (isExistsTsxconfigPath) {
47 | const tsxConfig = ts.createProject(tsxConfigPath);
48 | return ts({
49 | jsx: "react",
50 | }).pipe(tsxConfig()).on("error", (error: any) => {
51 | false && vscode.window.showErrorMessage(error.message);
52 | vscode.window.setStatusBarMessage(errorMessage);
53 | })
54 | } else {
55 | return ts({
56 | jsx: "react",
57 | }).on("error", (error: any) => {
58 | false && vscode.window.showErrorMessage(error.message);
59 | vscode.window.setStatusBarMessage(errorMessage);
60 | })
61 | }
62 | })())
63 | .pipe(uglify())
64 | .pipe((rename({ suffix: ".min" })))
65 | .pipe(dest(outputPath));
66 | }
67 | vscode.window.setStatusBarMessage(successMessage);
68 | }
--------------------------------------------------------------------------------
/out/compile/typescriptx.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | /**
3 | * Copyright © 1998 - 2020 Tencent. All Rights Reserved.
4 | *
5 | * @author enoyao
6 | */
7 | Object.defineProperty(exports, "__esModule", { value: true });
8 | exports.typescriptxLoader = void 0;
9 | const util_1 = require("../util");
10 | const path = require("path");
11 | const fs = require("fs");
12 | const vscode = require("vscode");
13 | const ts = require("gulp-typescript");
14 | const { src, dest } = require("gulp");
15 | const uglify = require("gulp-uglify");
16 | const rename = require("gulp-rename");
17 | exports.typescriptxLoader = ({ fileName, outputPath, notificationStatus, compileOptions }) => {
18 | const tsxConfigPath = path.join(fileName, '../tsconfig.json');
19 | const isExistsTsxconfigPath = fs.existsSync(tsxConfigPath);
20 | if (!compileOptions.generateMinifiedJsOnly) {
21 | src(fileName)
22 | .pipe((() => {
23 | if (isExistsTsxconfigPath) {
24 | const tsxConfig = ts.createProject(tsxConfigPath);
25 | return ts({
26 | jsx: "react",
27 | }).pipe(tsxConfig()).on("error", (error) => {
28 | false && vscode.window.showErrorMessage(error.message);
29 | vscode.window.setStatusBarMessage(util_1.errorMessage);
30 | });
31 | }
32 | else {
33 | return ts({
34 | jsx: "react",
35 | }).on("error", (error) => {
36 | false && vscode.window.showErrorMessage(error.message);
37 | vscode.window.setStatusBarMessage(util_1.errorMessage);
38 | });
39 | }
40 | })())
41 | .pipe(dest(outputPath));
42 | }
43 | if (compileOptions.generateMinifiedJs) {
44 | src(fileName)
45 | .pipe((() => {
46 | if (isExistsTsxconfigPath) {
47 | const tsxConfig = ts.createProject(tsxConfigPath);
48 | return ts({
49 | jsx: "react",
50 | }).pipe(tsxConfig()).on("error", (error) => {
51 | false && vscode.window.showErrorMessage(error.message);
52 | vscode.window.setStatusBarMessage(util_1.errorMessage);
53 | });
54 | }
55 | else {
56 | return ts({
57 | jsx: "react",
58 | }).on("error", (error) => {
59 | false && vscode.window.showErrorMessage(error.message);
60 | vscode.window.setStatusBarMessage(util_1.errorMessage);
61 | });
62 | }
63 | })())
64 | .pipe(uglify())
65 | .pipe((rename({ suffix: ".min" })))
66 | .pipe(dest(outputPath));
67 | }
68 | vscode.window.setStatusBarMessage(util_1.successMessage);
69 | };
70 | //# sourceMappingURL=typescriptx.js.map
--------------------------------------------------------------------------------
/src/status.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © 1998 - 2020 Tencent. All Rights Reserved.
3 | *
4 | * @author enoyao
5 | */
6 |
7 |
8 | import * as vscode from 'vscode';
9 |
10 | export class StatusBarUi {
11 | private static _statusBarItem: vscode.StatusBarItem;
12 | private static get statusBarItem() {
13 | if (!StatusBarUi._statusBarItem) {
14 | StatusBarUi._statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 200);
15 | this.statusBarItem.show();
16 | }
17 | return StatusBarUi._statusBarItem;
18 | }
19 |
20 | static show() {
21 | this.statusBarItem.show();
22 | }
23 |
24 | static hide() {
25 | this.statusBarItem.hide();
26 | }
27 |
28 | static init(disableCompileFilesOnDidSaveCode: string) {
29 | StatusBarUi.working("Starting...");
30 | setTimeout(function () {
31 | disableCompileFilesOnDidSaveCode ? StatusBarUi.notWatching() : StatusBarUi.watching();
32 | }, 1000);
33 | }
34 |
35 | static watching() {
36 | StatusBarUi.statusBarItem.text = `$(eye) Compile Hero: On`;
37 | StatusBarUi.statusBarItem.color = 'inherit';
38 | StatusBarUi.statusBarItem.command = 'compile-hero.compileHeroOn';
39 | StatusBarUi.statusBarItem.tooltip = 'Stop live compilation';
40 | }
41 |
42 | static notWatching() {
43 | StatusBarUi.statusBarItem.text = `$(eye-closed) Compile Hero: Off`;
44 | StatusBarUi.statusBarItem.color = 'inherit';
45 | StatusBarUi.statusBarItem.command = 'compile-hero.compileHeroOff';
46 | StatusBarUi.statusBarItem.tooltip = 'live compilation';
47 | }
48 |
49 | static working(workingMsg: string = "Working on it...") {
50 | StatusBarUi.statusBarItem.text = `$(pulse) ${workingMsg}`;
51 | StatusBarUi.statusBarItem.tooltip = 'In case if it takes long time, Show output window and report.';
52 | StatusBarUi.statusBarItem.command = undefined;
53 | }
54 |
55 | static compilationSuccess(isWatching: boolean) {
56 | StatusBarUi.statusBarItem.text = `$(check) Success`;
57 | StatusBarUi.statusBarItem.color = '#33ff00';
58 | StatusBarUi.statusBarItem.command = undefined;
59 | if (isWatching) {
60 | setTimeout(function () {
61 | StatusBarUi.statusBarItem.color = 'inherit';
62 | StatusBarUi.watching();
63 | }, 4500);
64 | }
65 | else {
66 | StatusBarUi.notWatching();
67 | }
68 | }
69 | static compilationError(isWatching: boolean) {
70 | StatusBarUi.statusBarItem.text = `$(x) Error`;
71 | StatusBarUi.statusBarItem.color = '#ff0033';
72 | StatusBarUi.statusBarItem.command = undefined;
73 | if (isWatching) {
74 | setTimeout(function () {
75 | StatusBarUi.statusBarItem.color = 'inherit';
76 | StatusBarUi.watching();
77 | }, 4500);
78 | }
79 | else {
80 | StatusBarUi.notWatching();
81 | }
82 | }
83 |
84 | static dispose() {
85 | StatusBarUi.statusBarItem.dispose();
86 | }
87 | }
--------------------------------------------------------------------------------
/out/status.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | /**
3 | * Copyright © 1998 - 2020 Tencent. All Rights Reserved.
4 | *
5 | * @author enoyao
6 | */
7 | Object.defineProperty(exports, "__esModule", { value: true });
8 | exports.StatusBarUi = void 0;
9 | const vscode = require("vscode");
10 | class StatusBarUi {
11 | static get statusBarItem() {
12 | if (!StatusBarUi._statusBarItem) {
13 | StatusBarUi._statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 200);
14 | this.statusBarItem.show();
15 | }
16 | return StatusBarUi._statusBarItem;
17 | }
18 | static show() {
19 | this.statusBarItem.show();
20 | }
21 | static hide() {
22 | this.statusBarItem.hide();
23 | }
24 | static init(disableCompileFilesOnDidSaveCode) {
25 | StatusBarUi.working("Starting...");
26 | setTimeout(function () {
27 | disableCompileFilesOnDidSaveCode ? StatusBarUi.notWatching() : StatusBarUi.watching();
28 | }, 1000);
29 | }
30 | static watching() {
31 | StatusBarUi.statusBarItem.text = `$(eye) Compile Hero: On`;
32 | StatusBarUi.statusBarItem.color = 'inherit';
33 | StatusBarUi.statusBarItem.command = 'compile-hero.compileHeroOn';
34 | StatusBarUi.statusBarItem.tooltip = 'Stop live compilation';
35 | }
36 | static notWatching() {
37 | StatusBarUi.statusBarItem.text = `$(eye-closed) Compile Hero: Off`;
38 | StatusBarUi.statusBarItem.color = 'inherit';
39 | StatusBarUi.statusBarItem.command = 'compile-hero.compileHeroOff';
40 | StatusBarUi.statusBarItem.tooltip = 'live compilation';
41 | }
42 | static working(workingMsg = "Working on it...") {
43 | StatusBarUi.statusBarItem.text = `$(pulse) ${workingMsg}`;
44 | StatusBarUi.statusBarItem.tooltip = 'In case if it takes long time, Show output window and report.';
45 | StatusBarUi.statusBarItem.command = undefined;
46 | }
47 | static compilationSuccess(isWatching) {
48 | StatusBarUi.statusBarItem.text = `$(check) Success`;
49 | StatusBarUi.statusBarItem.color = '#33ff00';
50 | StatusBarUi.statusBarItem.command = undefined;
51 | if (isWatching) {
52 | setTimeout(function () {
53 | StatusBarUi.statusBarItem.color = 'inherit';
54 | StatusBarUi.watching();
55 | }, 4500);
56 | }
57 | else {
58 | StatusBarUi.notWatching();
59 | }
60 | }
61 | static compilationError(isWatching) {
62 | StatusBarUi.statusBarItem.text = `$(x) Error`;
63 | StatusBarUi.statusBarItem.color = '#ff0033';
64 | StatusBarUi.statusBarItem.command = undefined;
65 | if (isWatching) {
66 | setTimeout(function () {
67 | StatusBarUi.statusBarItem.color = 'inherit';
68 | StatusBarUi.watching();
69 | }, 4500);
70 | }
71 | else {
72 | StatusBarUi.notWatching();
73 | }
74 | }
75 | static dispose() {
76 | StatusBarUi.statusBarItem.dispose();
77 | }
78 | }
79 | exports.StatusBarUi = StatusBarUi;
80 | //# sourceMappingURL=status.js.map
--------------------------------------------------------------------------------
/out/open.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"open.js","sourceRoot":"","sources":["../src/open.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;AAEH,+BAAiC;AACjC,6BAA6B;AAC7B,yBAAyB;AACzB,8CAA8C;AAC9C,iCAAqC;AAErC,MAAM,OAAO,GAAG,gBAAS,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;AACrC,MAAM,SAAS,GAAG,gBAAS,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;AAEnD,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAE1D,MAAM,gBAAgB,GAAG,CAAO,IAAY,EAAE,EAAE;IAC5C,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAC5D,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC,CAAA,CAAC;A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I,CAAC;SACvC;KACJ;IAED,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAE1B,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;QAC1D,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,YAAY,CAAC,CAAC;KAChD;IAED,MAAM,UAAU,GAAG,YAAY,CAAC,KAAK,CAAC,OAAO,EAAE,YAAY,EAAE,mBAAmB,CAAC,CAAC;IAElF,IAAI,OAAO,CAAC,IAAI,EAAE;QACd,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACnC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAEjC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,QAAgB,EAAE,EAAE;gBAC1C,IAAI,OAAO,CAAC,oBAAoB,IAAI,QAAQ,GAAG,CAAC,EAAE;oBAC9C,MAAM,CAAC,IAAI,KAAK,CAAC,oBAAoB,QAAQ,EAAE,CAAC,CAAC,CAAC;oBAClD,OAAO;iBACV;gBAED,OAAO,CAAC,UAAU,CAAC,CAAC;YACxB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;KACN;IACD,UAAU,CAAC,KAAK,EAAE,CAAC;IACnB,OAAO,UAAU,CAAC;AACtB,CAAC,CAAA,CAAC"}
--------------------------------------------------------------------------------
/out/extension.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;AAGH,iCAAiC;AACjC,yBAAyB;AAEzB,qCAAuC;AACvC,iCAAwI;AACxI,MAAM,EAAE,UAAU,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAEnE,SAAgB,QAAQ,CAAC,OAAgC;IACvD,OAAO,CAAC,GAAG,CAAC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,CAAC,OAAO,EAAE,CAAC;AACxB,CAAC;AAFD,gCAEC"}
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | - 2017-05-12 Establish a private code repository and implement a simple compilation extension.
4 | - 2017-12-13 Continuous optimization and improvement, only for internal commercial projects, and plan to open source.
5 | - 2018-10-24 Start writing documents and tutorials, and adjust the code structure.
6 | - 2019-11-03 Automatically evaluate documents and generate download links.
7 | - 2019-11-04 Support compiling `scss` files.
8 | - 2019-11-05 Support compiling `jade`, `typescript` and `less` files.
9 | - 2019-11-06 Support `html` file opening in browser.
10 | - 2019-11-07 Supports generation of `js` files in two modes of `development` and `production`.
11 | - 2019-11-08 Support compiling `tsx` files.
12 | - 2019-11-09 Add a variety of dynamic diagram demonstration.
13 | - 2019-11-10 Change the style of the pop-up prompt.
14 | - 2019-11-11 Add switch to control compilation.
15 | - 2019-11-13 Add the function of closing the port.
16 | - 2019-11-14 Add configure extension settings.
17 | - 2019-11-15 Delete unused material files.
18 | - 2019-11-21 Support compiling `jade` files.
19 | - 2020-03-28 Add command `compileFile`.
20 | - 2020-04-24 Add switch to control compilation.
21 | - 2020-04-25 Add advanced extension settings - [Documentation on a per project config](https://github.com/Wscats/compile-hero/issues/6).
22 | - 2020-05-05 Add `scss` files configure extension settings.
23 | - 2020-05-06 Delete unused commands such as `makeRequest` - [Dubious makeRequest function](https://github.com/Wscats/compile-hero/issues/9).
24 | - 2020-05-07 Increase `scss/sass/less` compilation error monitoring.
25 | - 2020-05-08 Add Feature - [Feature: Output:❌Errors/ ✔Success](https://github.com/Wscats/compile-hero/issues/15).
26 | - 2020-05-20 Fix indented syntax which it can treat code as `sass` (as opposed to `scss`) - [Bug: Using sass syntax doesn't work but scss works](https://github.com/Wscats/compile-hero/issues/17).
27 | - 2020-05-23 Fix compilation failure due to relative path of pug - [Bug: Pug include tag not working](https://github.com/Wscats/compile-hero/issues/19).
28 | - 2020-06-21 Add javascript, css, html minified options settings - [Feature: Minified options settings](https://github.com/Wscats/compile-hero/issues/13).
29 | - 2020-06-27 Support to compile all files in the entire folder
30 | - 2020-08-18 Fix compilation failure due to relative path of sass - [Bug: Do Sass partials (\_variables.scss) work](https://github.com/Wscats/compile-hero/issues/38).
31 | - 2020-08-20 After the extension is successfully installed, it should work normally by default - [Fix: Press Ctrl+s and no css file is generated](https://github.com/Wscats/compile-hero/issues/36).
32 | - 2020-08-23 Support to beautify `javascript`, `json`, `css`, `sass`, and `html`.
33 | - 2020-08-29 Update detailed [Chinese documents](https://github.com/Wscats/compile-hero/blob/master/README.CN.md).
34 | - 2020-08-30 Add or overwrite certain settings in the `tsconfig.json` file - [Feature: Hero does not seem to use all options of tsconfig.json](https://github.com/Wscats/compile-hero/issues/43).
35 | - 2020-09-07 Typescript file is compiling successfully, but a notification appear on right bottom that says there's a compile error - [Bug: Typescript Compile Bug](https://github.com/Wscats/compile-hero/issues/55).
36 | - 2020-09-11 Add a notification toggle option - [Feature: Pop up notification in bottom right corner should have toggle option](https://github.com/Wscats/compile-hero/issues/58).
37 | - 2020-09-30 Support prohibiting partial compilation and formatting of specific files by `compile-hero.ignore` option - [Feature: How to ignore compile child \_xxx.scss files](https://github.com/Wscats/compile-hero/issues/56).
38 | - 2020-11-24 Adjust the code directory structure and disassemble it into different loaders for maintenance.
39 | - 2020-11-25 Support selected code block compilation for `jade`, `pug`, `scss` and `less`.
40 | - 2020-11-26 Fix the problem that shortcut keys can’t be used normally, and improve the documentation.
41 | - 2020-11-28 Fix when compiling `less`, `sass`, `jade` and `pug` files, `@import` syntax failed to find files - [Bug: @import syntax failed](https://github.com/Wscats/compile-hero/issues/80).
42 | - 2020-11-29 Support the compilation of `stylus` and merge the `pug` and `jade` engines.
43 | - 2020-12-15 Support for `-output-directory` for `${folderPath}` and `${workspaceFolder}` variables can be added - [Feature: Variable support settings.json](https://github.com/Wscats/compile-hero/issues/84).
44 | - 2020-12-21 Use `compile-hero.watch` to monitor partial files - [Feature: Main SCSS file doesn't compile when partials are saved](https://github.com/Wscats/compile-hero/issues/94).
45 | - 2020-12-24 Add the following switches `generate-minified-html-only`, `generate-minified-css-only` and `generate-minified-javascript-only` - [Feature: How to keep only compressed files](https://github.com/Wscats/compile-hero/issues/95).
46 | - 2020-12-25 Optimize the startup method and reset the settings of activationEvents.
47 |
48 | # Unreleased
49 |
50 | - Support opening in browser and starting non security mode to solve cross domain problems.
51 | - Support to start custom server and refresh page automatically.
52 | - [Feature: Support autoprefixer for less, scss, scss](https://github.com/Wscats/compile-hero/issues/14).
53 |
--------------------------------------------------------------------------------
/src/extension.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © 1998 - 2020 Tencent. All Rights Reserved.
3 | *
4 | * @author enoyao
5 | */
6 |
7 |
8 | import * as vscode from "vscode";
9 | import * as fs from "fs";
10 |
11 | import { StatusBarUi } from './status';
12 | import { command, transformPort, complieDir, complieFile, readFileName, getSelectedText, openBrowser, fileType, suffixs } from './util';
13 | const { formatters, formatActiveDocument } = require("./beautify");
14 |
15 | export function activate(context: vscode.ExtensionContext) {
16 | console.log('Congratulations, compile hero is now active!');
17 | let openInBrowser = vscode.commands.registerCommand(
18 | "compile-hero.openInBrowser",
19 | (path) => {
20 | let uri = path.fsPath;
21 | openBrowser(uri);
22 | }
23 | );
24 | let closePort = vscode.commands.registerCommand(
25 | "compile-hero.closePort",
26 | async () => {
27 | let inputPort = await vscode.window.showInputBox({
28 | placeHolder: "Enter the port you need to close?",
29 | });
30 | let info = await command(`lsof -i :${inputPort}`);
31 | let port = transformPort(info);
32 | if (port) {
33 | await command(`kill -9 ${port}`);
34 | vscode.window.setStatusBarMessage("Port closed successfully!");
35 | }
36 | }
37 | );
38 |
39 | let compileFile = vscode.commands.registerCommand(
40 | "compile-hero.compileFile",
41 | (path) => {
42 | const uri = path.fsPath;
43 | try {
44 | if (fs.readdirSync(uri).length > 0) {
45 | complieDir(uri);
46 | } else {
47 | complieFile(uri);
48 | }
49 | } catch (error) {
50 | complieFile(uri);
51 | }
52 | }
53 | );
54 |
55 | let compileSelected = vscode.commands.registerCommand(
56 | "compile-hero.compileSelected",
57 | (path) => {
58 | const uri = path ? path.fsPath : vscode.window.activeTextEditor?.document.uri.fsPath;
59 | const selectedText = getSelectedText();
60 | readFileName({ fileName: uri, selectedText });
61 | }
62 | );
63 |
64 | let compileHeroOn = vscode.commands.registerCommand(
65 | "compile-hero.compileHeroOn",
66 | () => {
67 | let config = vscode.workspace.getConfiguration("compile-hero");
68 | config.update("disable-compile-files-on-did-save-code", true);
69 | StatusBarUi.notWatching();
70 | }
71 | );
72 |
73 | let compileHeroOff = vscode.commands.registerCommand(
74 | "compile-hero.compileHeroOff",
75 | () => {
76 | let config = vscode.workspace.getConfiguration("compile-hero");
77 | config.update("disable-compile-files-on-did-save-code", false);
78 | StatusBarUi.watching();
79 | }
80 | );
81 |
82 | let compileHeroStatus = vscode.window.onDidChangeActiveTextEditor((document) => {
83 | if (!document?.document.fileName) {
84 | StatusBarUi.hide();
85 | return;
86 | }
87 | // 编辑器是否命中正确的编译文件,如果编译文件后缀正确才显示右下角状态栏
88 | if (suffixs.includes(fileType(document?.document.fileName))) {
89 | StatusBarUi.show();
90 | } else {
91 | StatusBarUi.hide();
92 | }
93 | })
94 |
95 | let compileHeroConfigure = vscode.workspace.onDidChangeConfiguration(() => {
96 | // 修改配置,更新右下角底部状态栏
97 | let config = vscode.workspace.getConfiguration("compile-hero");
98 | let isDisable = config.get("disable-compile-files-on-did-save-code");
99 | if (isDisable) {
100 | StatusBarUi.notWatching();
101 | } else {
102 | StatusBarUi.watching();
103 | }
104 | })
105 |
106 | formatters.configure();
107 | let beautify = vscode.commands.registerCommand('compile-hero.beautify', formatActiveDocument.bind(0, true));
108 | let beautifyFile = vscode.commands.registerCommand('compile-hero.beautifyFile', formatActiveDocument.bind(0, false));
109 | let formattersConfigure = vscode.workspace.onDidChangeConfiguration(formatters.configure.bind(formatters));
110 | let formattersOnFileOpen = vscode.workspace.onDidOpenTextDocument(formatters.onFileOpen.bind(formatters));
111 |
112 | context.subscriptions.push(openInBrowser);
113 | context.subscriptions.push(closePort);
114 | context.subscriptions.push(compileFile);
115 | context.subscriptions.push(compileSelected);
116 | context.subscriptions.push(compileHeroOn);
117 | context.subscriptions.push(compileHeroOff);
118 | context.subscriptions.push(compileHeroStatus);
119 | context.subscriptions.push(compileHeroConfigure);
120 | context.subscriptions.push(beautify);
121 | context.subscriptions.push(beautifyFile);
122 | context.subscriptions.push(formattersConfigure);
123 | context.subscriptions.push(formattersOnFileOpen);
124 |
125 | vscode.workspace.onDidSaveTextDocument((document) => {
126 | let config = vscode.workspace.getConfiguration("compile-hero");
127 | let isDisableOnDidSaveTextDocument =
128 | config.get("disable-compile-files-on-did-save-code") || "";
129 | if (isDisableOnDidSaveTextDocument) return;
130 | const { fileName } = document;
131 | readFileName({ fileName });
132 | });
133 |
134 | StatusBarUi.init(vscode.workspace.getConfiguration("compile-hero").get("disable-compile-files-on-did-save-code") || "");
135 | }
136 | export function deactivate() {
137 | StatusBarUi.dispose();
138 | }
139 |
--------------------------------------------------------------------------------
/src/open.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © 1998 - 2020 Tencent. All Rights Reserved.
3 | *
4 | * @author enoyao
5 | */
6 |
7 | import { promisify } from "util";
8 | import * as path from "path";
9 | import * as fs from "fs";
10 | import * as childProcess from "child_process";
11 | import { docker, wsl } from './util';
12 |
13 | const pAccess = promisify(fs.access);
14 | const pExecFile = promisify(childProcess.execFile);
15 |
16 | const localXdgOpenPath = path.join(__dirname, 'xdg-open');
17 |
18 | const wslToWindowsPath = async (path: string) => {
19 | const { stdout } = await pExecFile('wslpath', ['-w', path]);
20 | return stdout.trim();
21 | };
22 |
23 | const windowsToWslPath = async (path: string) => {
24 | const { stdout } = await pExecFile('wslpath', [path]);
25 | return stdout.trim();
26 | };
27 |
28 | const wslGetWindowsEnvVar = async (envVar: string) => {
29 | const { stdout } = await pExecFile('wslvar', [envVar]);
30 | return stdout.trim();
31 | };
32 |
33 | export default async (target: string, options: any) => {
34 | if (typeof target !== 'string') {
35 | throw new TypeError('Expected a `target`');
36 | }
37 |
38 | options = {
39 | wait: false,
40 | background: false,
41 | allowNonzeroExitCode: false,
42 | ...options
43 | };
44 |
45 | let command;
46 | let { app } = options;
47 | let appArguments = [];
48 | const cliArguments = [];
49 | const childProcessOptions: any = {};
50 |
51 | if (Array.isArray(app)) {
52 | appArguments = app.slice(1);
53 | app = app[0];
54 | }
55 |
56 | if (process.platform === 'darwin') {
57 | command = 'open';
58 |
59 | if (options.wait) {
60 | cliArguments.push('--wait-apps');
61 | }
62 |
63 | if (options.background) {
64 | cliArguments.push('--background');
65 | }
66 |
67 | if (app) {
68 | cliArguments.push('-a', app);
69 | }
70 | } else if (process.platform === 'win32' || (wsl && !docker())) {
71 | const windowsRoot = wsl ? await wslGetWindowsEnvVar('systemroot') : process.env.SYSTEMROOT;
72 | command = String.raw`${windowsRoot}\System32\WindowsPowerShell\v1.0\powershell${wsl ? '.exe' : ''}`;
73 | cliArguments.push(
74 | '-NoProfile',
75 | '-NonInteractive',
76 | '–ExecutionPolicy',
77 | 'Bypass',
78 | '-EncodedCommand'
79 | );
80 |
81 | if (wsl) {
82 | command = await windowsToWslPath(command);
83 | } else {
84 | childProcessOptions.windowsVerbatimArguments = true;
85 | }
86 |
87 | const encodedArguments = ['Start'];
88 |
89 | if (options.wait) {
90 | encodedArguments.push('-Wait');
91 | }
92 |
93 | if (app) {
94 | if (wsl && app.startsWith('/mnt/')) {
95 | const windowsPath = await wslToWindowsPath(app);
96 | app = windowsPath;
97 | }
98 |
99 | encodedArguments.push(`"\`"${app}\`""`, '-ArgumentList');
100 | appArguments.unshift(target);
101 | } else {
102 | encodedArguments.push(`"\`"${target}\`""`);
103 | }
104 |
105 | if (appArguments.length > 0) {
106 | appArguments = appArguments.map(arg => `"\`"${arg}\`""`);
107 | encodedArguments.push(appArguments.join(','));
108 | }
109 |
110 | target = Buffer.from(encodedArguments.join(' '), 'utf16le').toString('base64');
111 | } else {
112 | if (app) {
113 | command = app;
114 | } else {
115 | const isBundled = !__dirname || __dirname === '/';
116 |
117 | let exeLocalXdgOpen = false;
118 | try {
119 | await pAccess(localXdgOpenPath, fs.constants.X_OK);
120 | exeLocalXdgOpen = true;
121 | } catch (_) { }
122 |
123 | const useSystemXdgOpen = (process.versions as any).electron ||
124 | process.platform === 'android' || isBundled || !exeLocalXdgOpen;
125 | command = useSystemXdgOpen ? 'xdg-open' : localXdgOpenPath;
126 | }
127 |
128 | if (appArguments.length > 0) {
129 | cliArguments.push(...appArguments);
130 | }
131 |
132 | if (!options.wait) {
133 | childProcessOptions.stdio = 'ignore';
134 | childProcessOptions.detached = true;
135 | }
136 | }
137 |
138 | cliArguments.push(target);
139 |
140 | if (process.platform === 'darwin' && appArguments.length > 0) {
141 | cliArguments.push('--args', ...appArguments);
142 | }
143 |
144 | const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
145 |
146 | if (options.wait) {
147 | return new Promise((resolve, reject) => {
148 | subprocess.once('error', reject);
149 |
150 | subprocess.once('close', (exitCode: number) => {
151 | if (options.allowNonzeroExitCode && exitCode > 0) {
152 | reject(new Error(`Exited with code ${exitCode}`));
153 | return;
154 | }
155 |
156 | resolve(subprocess);
157 | });
158 | });
159 | }
160 | subprocess.unref();
161 | return subprocess;
162 | };
--------------------------------------------------------------------------------
/out/open.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | /**
3 | * Copyright © 1998 - 2020 Tencent. All Rights Reserved.
4 | *
5 | * @author enoyao
6 | */
7 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
9 | return new (P || (P = Promise))(function (resolve, reject) {
10 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13 | step((generator = generator.apply(thisArg, _arguments || [])).next());
14 | });
15 | };
16 | Object.defineProperty(exports, "__esModule", { value: true });
17 | const util_1 = require("util");
18 | const path = require("path");
19 | const fs = require("fs");
20 | const childProcess = require("child_process");
21 | const util_2 = require("./util");
22 | const pAccess = util_1.promisify(fs.access);
23 | const pExecFile = util_1.promisify(childProcess.execFile);
24 | const localXdgOpenPath = path.join(__dirname, 'xdg-open');
25 | const wslToWindowsPath = (path) => __awaiter(void 0, void 0, void 0, function* () {
26 | const { stdout } = yield pExecFile('wslpath', ['-w', path]);
27 | return stdout.trim();
28 | });
29 | const windowsToWslPath = (path) => __awaiter(void 0, void 0, void 0, function* () {
30 | const { stdout } = yield pExecFile('wslpath', [path]);
31 | return stdout.trim();
32 | });
33 | const wslGetWindowsEnvVar = (envVar) => __awaiter(void 0, void 0, void 0, function* () {
34 | const { stdout } = yield pExecFile('wslvar', [envVar]);
35 | return stdout.trim();
36 | });
37 | exports.default = (target, options) => __awaiter(void 0, void 0, void 0, function* () {
38 | if (typeof target !== 'string') {
39 | throw new TypeError('Expected a `target`');
40 | }
41 | options = Object.assign({ wait: false, background: false, allowNonzeroExitCode: false }, options);
42 | let command;
43 | let { app } = options;
44 | let appArguments = [];
45 | const cliArguments = [];
46 | const childProcessOptions = {};
47 | if (Array.isArray(app)) {
48 | appArguments = app.slice(1);
49 | app = app[0];
50 | }
51 | if (process.platform === 'darwin') {
52 | command = 'open';
53 | if (options.wait) {
54 | cliArguments.push('--wait-apps');
55 | }
56 | if (options.background) {
57 | cliArguments.push('--background');
58 | }
59 | if (app) {
60 | cliArguments.push('-a', app);
61 | }
62 | }
63 | else if (process.platform === 'win32' || (util_2.wsl && !util_2.docker())) {
64 | const windowsRoot = util_2.wsl ? yield wslGetWindowsEnvVar('systemroot') : process.env.SYSTEMROOT;
65 | command = String.raw `${windowsRoot}\System32\WindowsPowerShell\v1.0\powershell${util_2.wsl ? '.exe' : ''}`;
66 | cliArguments.push('-NoProfile', '-NonInteractive', '–ExecutionPolicy', 'Bypass', '-EncodedCommand');
67 | if (util_2.wsl) {
68 | command = yield windowsToWslPath(command);
69 | }
70 | else {
71 | childProcessOptions.windowsVerbatimArguments = true;
72 | }
73 | const encodedArguments = ['Start'];
74 | if (options.wait) {
75 | encodedArguments.push('-Wait');
76 | }
77 | if (app) {
78 | if (util_2.wsl && app.startsWith('/mnt/')) {
79 | const windowsPath = yield wslToWindowsPath(app);
80 | app = windowsPath;
81 | }
82 | encodedArguments.push(`"\`"${app}\`""`, '-ArgumentList');
83 | appArguments.unshift(target);
84 | }
85 | else {
86 | encodedArguments.push(`"\`"${target}\`""`);
87 | }
88 | if (appArguments.length > 0) {
89 | appArguments = appArguments.map(arg => `"\`"${arg}\`""`);
90 | encodedArguments.push(appArguments.join(','));
91 | }
92 | target = Buffer.from(encodedArguments.join(' '), 'utf16le').toString('base64');
93 | }
94 | else {
95 | if (app) {
96 | command = app;
97 | }
98 | else {
99 | const isBundled = !__dirname || __dirname === '/';
100 | let exeLocalXdgOpen = false;
101 | try {
102 | yield pAccess(localXdgOpenPath, fs.constants.X_OK);
103 | exeLocalXdgOpen = true;
104 | }
105 | catch (_) { }
106 | const useSystemXdgOpen = process.versions.electron ||
107 | process.platform === 'android' || isBundled || !exeLocalXdgOpen;
108 | command = useSystemXdgOpen ? 'xdg-open' : localXdgOpenPath;
109 | }
110 | if (appArguments.length > 0) {
111 | cliArguments.push(...appArguments);
112 | }
113 | if (!options.wait) {
114 | childProcessOptions.stdio = 'ignore';
115 | childProcessOptions.detached = true;
116 | }
117 | }
118 | cliArguments.push(target);
119 | if (process.platform === 'darwin' && appArguments.length > 0) {
120 | cliArguments.push('--args', ...appArguments);
121 | }
122 | const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
123 | if (options.wait) {
124 | return new Promise((resolve, reject) => {
125 | subprocess.once('error', reject);
126 | subprocess.once('close', (exitCode) => {
127 | if (options.allowNonzeroExitCode && exitCode > 0) {
128 | reject(new Error(`Exited with code ${exitCode}`));
129 | return;
130 | }
131 | resolve(subprocess);
132 | });
133 | });
134 | }
135 | subprocess.unref();
136 | return subprocess;
137 | });
138 | //# sourceMappingURL=open.js.map
--------------------------------------------------------------------------------
/out/extension.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | /**
3 | * Copyright © 1998 - 2020 Tencent. All Rights Reserved.
4 | *
5 | * @author enoyao
6 | */
7 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
9 | return new (P || (P = Promise))(function (resolve, reject) {
10 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13 | step((generator = generator.apply(thisArg, _arguments || [])).next());
14 | });
15 | };
16 | Object.defineProperty(exports, "__esModule", { value: true });
17 | exports.deactivate = exports.activate = void 0;
18 | const vscode = require("vscode");
19 | const fs = require("fs");
20 | const status_1 = require("./status");
21 | const util_1 = require("./util");
22 | const { formatters, formatActiveDocument } = require("./beautify");
23 | function activate(context) {
24 | console.log('Congratulations, compile hero is now active!');
25 | let openInBrowser = vscode.commands.registerCommand("compile-hero.openInBrowser", (path) => {
26 | let uri = path.fsPath;
27 | util_1.openBrowser(uri);
28 | });
29 | let closePort = vscode.commands.registerCommand("compile-hero.closePort", () => __awaiter(this, void 0, void 0, function* () {
30 | let inputPort = yield vscode.window.showInputBox({
31 | placeHolder: "Enter the port you need to close?",
32 | });
33 | let info = yield util_1.command(`lsof -i :${inputPort}`);
34 | let port = util_1.transformPort(info);
35 | if (port) {
36 | yield util_1.command(`kill -9 ${port}`);
37 | vscode.window.setStatusBarMessage("Port closed successfully!");
38 | }
39 | }));
40 | let compileFile = vscode.commands.registerCommand("compile-hero.compileFile", (path) => {
41 | const uri = path.fsPath;
42 | try {
43 | if (fs.readdirSync(uri).length > 0) {
44 | util_1.complieDir(uri);
45 | }
46 | else {
47 | util_1.complieFile(uri);
48 | }
49 | }
50 | catch (error) {
51 | util_1.complieFile(uri);
52 | }
53 | });
54 | let compileSelected = vscode.commands.registerCommand("compile-hero.compileSelected", (path) => {
55 | var _a;
56 | const uri = path ? path.fsPath : (_a = vscode.window.activeTextEditor) === null || _a === void 0 ? void 0 : _a.document.uri.fsPath;
57 | const selectedText = util_1.getSelectedText();
58 | util_1.readFileName({ fileName: uri, selectedText });
59 | });
60 | let compileHeroOn = vscode.commands.registerCommand("compile-hero.compileHeroOn", () => {
61 | let config = vscode.workspace.getConfiguration("compile-hero");
62 | config.update("disable-compile-files-on-did-save-code", true);
63 | status_1.StatusBarUi.notWatching();
64 | });
65 | let compileHeroOff = vscode.commands.registerCommand("compile-hero.compileHeroOff", () => {
66 | let config = vscode.workspace.getConfiguration("compile-hero");
67 | config.update("disable-compile-files-on-did-save-code", false);
68 | status_1.StatusBarUi.watching();
69 | });
70 | let compileHeroStatus = vscode.window.onDidChangeActiveTextEditor((document) => {
71 | if (!(document === null || document === void 0 ? void 0 : document.document.fileName)) {
72 | status_1.StatusBarUi.hide();
73 | return;
74 | }
75 | // 编辑器是否命中正确的编译文件,如果编译文件后缀正确才显示右下角状态栏
76 | if (util_1.suffixs.includes(util_1.fileType(document === null || document === void 0 ? void 0 : document.document.fileName))) {
77 | status_1.StatusBarUi.show();
78 | }
79 | else {
80 | status_1.StatusBarUi.hide();
81 | }
82 | });
83 | let compileHeroConfigure = vscode.workspace.onDidChangeConfiguration(() => {
84 | // 修改配置,更新右下角底部状态栏
85 | let config = vscode.workspace.getConfiguration("compile-hero");
86 | let isDisable = config.get("disable-compile-files-on-did-save-code");
87 | if (isDisable) {
88 | status_1.StatusBarUi.notWatching();
89 | }
90 | else {
91 | status_1.StatusBarUi.watching();
92 | }
93 | });
94 | formatters.configure();
95 | let beautify = vscode.commands.registerCommand('compile-hero.beautify', formatActiveDocument.bind(0, true));
96 | let beautifyFile = vscode.commands.registerCommand('compile-hero.beautifyFile', formatActiveDocument.bind(0, false));
97 | let formattersConfigure = vscode.workspace.onDidChangeConfiguration(formatters.configure.bind(formatters));
98 | let formattersOnFileOpen = vscode.workspace.onDidOpenTextDocument(formatters.onFileOpen.bind(formatters));
99 | context.subscriptions.push(openInBrowser);
100 | context.subscriptions.push(closePort);
101 | context.subscriptions.push(compileFile);
102 | context.subscriptions.push(compileSelected);
103 | context.subscriptions.push(compileHeroOn);
104 | context.subscriptions.push(compileHeroOff);
105 | context.subscriptions.push(compileHeroStatus);
106 | context.subscriptions.push(compileHeroConfigure);
107 | context.subscriptions.push(beautify);
108 | context.subscriptions.push(beautifyFile);
109 | context.subscriptions.push(formattersConfigure);
110 | context.subscriptions.push(formattersOnFileOpen);
111 | vscode.workspace.onDidSaveTextDocument((document) => {
112 | let config = vscode.workspace.getConfiguration("compile-hero");
113 | let isDisableOnDidSaveTextDocument = config.get("disable-compile-files-on-did-save-code") || "";
114 | if (isDisableOnDidSaveTextDocument)
115 | return;
116 | const { fileName } = document;
117 | util_1.readFileName({ fileName });
118 | });
119 | status_1.StatusBarUi.init(vscode.workspace.getConfiguration("compile-hero").get("disable-compile-files-on-did-save-code") || "");
120 | }
121 | exports.activate = activate;
122 | function deactivate() {
123 | status_1.StatusBarUi.dispose();
124 | }
125 | exports.deactivate = deactivate;
126 | //# sourceMappingURL=extension.js.map
--------------------------------------------------------------------------------
/README.CN.md:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 | 
7 | 
8 | 
9 |
10 | [English](./README.md) | [中文](./README.CN.md)
11 |
12 | # 特性
13 |
14 |
15 |
16 | > 1.打开 `less, sass, scss, styl, ts, tsx, jade, pug` 或 `js` 等文件。
17 |
18 | > 2.启动编辑器右下角底部栏开关 `Compile Hero: On` ↓
19 |
20 |
21 |
22 | 
23 |
24 | > 3.按快捷键 `(ctrl+s)`
25 |
26 | 或者在文件列表右键菜单选择 `Compile Files` 命令启动编译,将会在该文件的同级目录 `dist` 下生成编译后的文件,希望能你远离 `webpack` 和 `gulp` 等编译工具繁琐的操作。
27 |
28 | 
29 | 
30 |
31 | 你还可以选中部分代码使用 `Compile Selected` 菜单项或者快捷键 `(ctrl+shift+s)`,进行代码块的局部编译。
32 |
33 | 
34 |
35 | > 4.按快捷键 `(alt+shift+f)` 或者在文件列表右键菜单选择 `Format Document` 将会帮你自动格式化文件。
36 |
37 | 
38 |
39 | - 按保存 `Ctrl+S` 会自动编译编译 `less, sass, scss, stylus, typescript, typescriptreact, jade, pug and js` 等文件。
40 | - 支持 `less, scss, scss` 等文件代码高亮。
41 | - 支持在默认浏览器打开 `html` 文件。
42 | - 支持压缩 `javascript` 和 `css` 文件。
43 | - 支持格式化 `javascript`, `json`, `css`, `sass`, 和 `html` 等文件。
44 |
45 | | 编译前 | 编译后 |
46 | | ----------- | -------- |
47 | | .pug | .html |
48 | | .jade | .html |
49 | | .scss(sass) | .css |
50 | | .less | .css |
51 | | .styl | .css |
52 | | .ts/.tsx | .js(JSX) |
53 | | .js(ES6) | .js(ES5) |
54 |
55 | # 配置参数
56 |
57 | 点击插件的配置选项 `Extension Settings`:
58 |
59 | > 点击编辑器底部栏右下角 `Compile Hero: On/Off`,可以切换不同语言的自动编译开关。
60 |
61 | 
62 |
63 | > 你可以修改编译后目录和文件的输出位置
64 |
65 | 
66 |
67 | 具体参数如下:
68 |
69 | | 是否开启按 `(ctrl+s)` 时自动编译文件(所有语言的自动编译总开关) | 默认值 |
70 | | ---------------------------------------------------------------- | ------ |
71 | | disable-compile-files-on-did-save-code | false |
72 |
73 | | 编译失败左下角弹窗提醒开关 | 默认值 |
74 | | -------------------------- | ------ |
75 | | notification-toggle | true |
76 |
77 | | 配置文件编译后的目录的输出路径 | 默认值 | 是否开启按 `(ctrl+s)` 时自动编译文件 | 默认值 |
78 | | ------------------------------ | ------ | ------------------------------------ | ------ |
79 | | javascript-output-directory | ./dist | javascript-output-toggle | true |
80 | | sass-output-directory | ./dist | sass-output-toggle | true |
81 | | scss-output-directory | ./dist | scss-output-toggle | true |
82 | | less-output-directory | ./dist | less-output-toggle | true |
83 | | jade-output-directory | ./dist | jade-output-toggle | true |
84 | | typescript-output-directory | ./dist | typescript-output-toggle | true |
85 | | typescriptx-output-directory | ./dist | typescriptx-output-toggle | true |
86 | | pug-output-directory | ./dist | pug-output-toggle | true |
87 | | stylus-output-directory | ./dist | stylus-output-toggle | true |
88 | | generate-minified-html | false | generate-minified-html-only | false |
89 | | generate-minified-css | false | generate-minified-css-only | false |
90 | | generate-minified-javascript | false | generate-minified-javascript-only | false |
91 |
92 | ## 使用 `settings.json`
93 |
94 | > 在项目根目录下可以新建该目录和文件 `.vscode/settings.json` 配置高级选项。
95 |
96 | 这里列举一个 `.vscode/settings.json` 文件的例子:
97 |
98 | ```js
99 | {
100 | "compile-hero": {
101 | "disable-compile-files-on-did-save-code": false, // 全局开关,false 为开启自动编译, 默认 true 为开启不自动编译
102 | "notification-toggle": false, // 关闭编译失败时候右下角的弹窗提醒
103 | "javascript-output-directory": "./out", // javascript 输出的目录
104 | "javascript-output-toggle": false, // 局部开关,true 为开启 javascript 自动编译,false 为不开启 javascript 自动编译
105 | "sass-output-directory": "./out", // sass 输出的目录
106 | "sass-output-toggle": true, // 局部开关,true 为开启 sass 自动编译,false 为不开启 sass 自动编译
107 | "ignore": ["src/test.js", "*/test.scss", "**/spec/*", "**/src/**/*"], // 禁止文件和文件夹自动格式化和编译
108 | "watch": ["sass/test.sass", "**/less/**/*"] // 监听对应文件或者文件夹,保存的时候触发编译,一般配合 Compile Hero: On 开关打开使用
109 | }
110 | }
111 | // 更多配置项:详见下列表格
112 | ```
113 |
114 | ## 使用 `tsconfig.json`
115 |
116 | > 在 `.ts` 文件的同级目录创建 `tsconfig.json` 文件,这个文件可以覆盖 `typescript` 的默认编译配置。
117 |
118 | 这里列举一个 `.vscode/tsconfig.json` 文件的例子:
119 |
120 | ```json
121 | {
122 | "compilerOptions": {
123 | "alwaysStrict": true,
124 | "importHelpers": false
125 | }
126 | }
127 | ```
128 |
129 | # 在浏览器预览页面
130 |
131 | 在目录菜单对着 `xxx.html` 文件点击右键,会出现 `Open In Browser` 选项,可以在启动浏览器中预览 `xxx.html` 该页面。
132 |
133 | 
134 |
135 | # 关闭端口(仅 MAC)
136 |
137 | 使用 `Close Port` 命令可以关闭对应的端口。
138 |
139 | 
140 |
141 | # 感谢
142 |
143 | | [
Eno Yao](https://github.com/Wscats) | [
Aaron Xie](https://github.com/aaron-xie) | [
DK Lan](https://github.com/dk-lan) | [
Yong](https://github.com/flowerField) | [
Li Ting](https://github.com/Liting1) | 
Xin | [
Lemon](https://github.com/lemonyyye) | [
Jing](https://github.com/vickySC) | [
Lin](https://github.com/shirley3790) | [
Tian Fly](https://github.com/tiantengfly) |
144 | | - | - | - | - | - | - | - | - | - | - |
145 |
146 |
147 |
148 |
149 | 如果你觉得有用,希望你可以给我们[留言和点赞](https://marketplace.visualstudio.com/items?itemName=Wscats.qf&ssr=false#review-details),你的支持是我们前进的最大动力 😀
150 |
151 | # 协议
152 |
153 | 遵循 [MIT](http://opensource.org/licenses/MIT) 协议。
154 |
--------------------------------------------------------------------------------
/out/options.js:
--------------------------------------------------------------------------------
1 | const vscode = require('vscode'),
2 | path = require('path'),
3 | os = require('os'),
4 | fs = require('fs'),
5 | editorconfig = require('editorconfig');
6 | const dropComments = inText => inText
7 | .replace(/\/\*.*\*\//g, '')
8 | .replace(/("(?:[^\\"\r\n]|\\")*?")|(?:\/\/.*(?=[\r\n]|$))/g, (_, str) => str || '');
9 |
10 | const mergeOpts = (opts, kind) => {
11 | const finOpts = {};
12 | for (let a in opts) {
13 | if (a !== 'js' && a !== 'html' && a !== 'css') {
14 | finOpts[a] = opts[a];
15 | }
16 | }
17 | //merge in the per type settings
18 | if (kind in opts) {
19 | for (let b in opts[kind]) {
20 | if (b === 'allowed_file_extensions') continue;
21 | finOpts[b] = opts[kind][b];
22 | }
23 | }
24 | return finOpts;
25 | };
26 |
27 | const findRecursive = (dir, fileName, root) => {
28 | const fullPath = path.join(dir, fileName);
29 | const nextDir = path.dirname(dir);
30 | let result = fs.existsSync(fullPath) ? fullPath : null;
31 | if (!result && nextDir !== dir && dir !== root) {
32 | result = findRecursive(nextDir, fileName, root);
33 | }
34 | return result;
35 | };
36 |
37 | const optionsFromVSCode = (doc, formattingOptions, type) => {
38 | const config = vscode.workspace.getConfiguration();
39 | if (!formattingOptions) {
40 | formattingOptions = vscode.workspace.getConfiguration('editor');
41 | //if this document is open, use the settings from that window
42 | vscode.window.visibleTextEditors.some(editor => {
43 | if (editor.document && editor.document.fileName === doc.fileName) {
44 | return (formattingOptions = editor.options);
45 | }
46 | });
47 | }
48 | const options = {
49 | indent_with_tabs: formattingOptions.insertSpaces === undefined ? true : !formattingOptions.insertSpaces,
50 | indent_size: formattingOptions.tabSize,
51 | indent_char: ' ',
52 | end_with_newline: config.files.insertFinalNewLine,
53 | eol: config.files.eol,
54 | space_after_anon_function: config.javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions,
55 | space_in_paren: config.javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis
56 | };
57 | if (type === 'html') {
58 | options.end_with_newline = config.html.format.endWithNewline;
59 | if (typeof config.html.format.extraLiners === 'string') {
60 | options.extra_liners = config.html.format.extraLiners
61 | .split(',')
62 | .map(s => s.trim());
63 | }
64 | options.indent_handlebars = config.html.format.indentHandlebars;
65 | options.indent_inner_html = config.html.format.indentInnerHtml;
66 | options.max_preserve_newlines = config.html.format.maxPreserveNewLines;
67 | options.preserve_newlines = config.html.format.preserveNewLines;
68 | options.wrap_attributes = config.html.format.wrapAttributes;
69 |
70 | if (typeof config.html.format.unformatted === 'string') {
71 | options.unformatted = config.html.format.unformatted
72 | .split(',')
73 | .map(s => s.trim());
74 | }
75 | options.wrap_line_length = config.html.format.wrapLineLength;
76 | }
77 | return options;
78 | };
79 |
80 | /* set_file_editorconfig_opts directly from js-beautify/lib/cli.js */
81 | function set_file_editorconfig_opts(file, config) {
82 | try {
83 | const eConfigs = editorconfig.parseSync(file);
84 | if (eConfigs.indent_style === 'tab') {
85 | config.indent_with_tabs = true;
86 | config.indent_char = '\t';
87 | } else if (eConfigs.indent_style === 'space') {
88 | config.indent_with_tabs = false;
89 | config.indent_char = ' ';
90 | }
91 |
92 | if (eConfigs.indent_size && eConfigs.indent_size !== 'tab') {
93 | config.indent_size = eConfigs.indent_size;
94 | }
95 |
96 | if (eConfigs.max_line_length) {
97 | if (eConfigs.max_line_length === 'off') {
98 | config.wrap_line_length = 0;
99 | } else {
100 | config.wrap_line_length = parseInt(eConfigs.max_line_length);
101 | }
102 | }
103 |
104 | if (eConfigs.insert_final_newline === true) {
105 | config.end_with_newline = true;
106 | } else if (eConfigs.insert_final_newline === false) {
107 | config.end_with_newline = false;
108 | }
109 |
110 | if (eConfigs.end_of_line) {
111 | if (eConfigs.end_of_line === 'cr') {
112 | config.eol = '\r';
113 | } else if (eConfigs.end_of_line === 'lf') {
114 | config.eol = '\n';
115 | } else if (eConfigs.end_of_line === 'crlf') {
116 | config.eol = '\r\n';
117 | }
118 | }
119 | } catch (e) { }
120 | }
121 |
122 | const getWorkspaceRoot = doc => {
123 | if (!vscode.workspace.workspaceFolders || vscode.workspace.workspaceFolders.length === 0) return;
124 | if (!doc || doc.isUntitled) return vscode.workspace.workspaceFolders[0].uri.fsPath;
125 |
126 | const folder = vscode.workspace.getWorkspaceFolder(doc.uri);
127 | if (!folder) return;
128 | return folder.uri.fsPath;
129 | };
130 |
131 | module.exports = (doc, type, formattingOptions) => {
132 | let root = getWorkspaceRoot(doc) || vscode.workspace.rootPath;
133 | let dir = doc.isUntitled ? root : path.dirname(doc.fileName);
134 | let opts = optionsFromVSCode(doc, formattingOptions, type);
135 | set_file_editorconfig_opts(doc.fileName, opts); // this does nothing if no ec file was found
136 | let configFile = dir ? findRecursive(dir, '.jsbeautifyrc', root) : null;
137 |
138 | if (!configFile) {
139 | let beautify_config = vscode.workspace.getConfiguration('compile-hero')
140 | .config;
141 | if (beautify_config) {
142 | if (typeof beautify_config === 'object') {
143 | return Promise.resolve(mergeOpts(beautify_config, type));
144 | } else if (typeof beautify_config === 'string') {
145 | if (path.isAbsolute(beautify_config)) configFile = beautify_config;
146 | else configFile = path.resolve(root, beautify_config);
147 |
148 | configFile = fs.existsSync(configFile) ? configFile : null;
149 | }
150 | }
151 | }
152 | if (!configFile && root) {
153 | configFile = findRecursive(path.dirname(root), '.jsbeautifyrc');
154 | }
155 | if (!configFile) {
156 | configFile = path.join(os.homedir(), '.jsbeautifyrc');
157 | if (!fs.existsSync(configFile)) return Promise.resolve(opts);
158 | }
159 | return new Promise((resolve, reject) => {
160 | fs.readFile(configFile, 'utf8', (e, d) => {
161 | if (!d || !d.length) return resolve(opts);
162 | try {
163 | const unCommented = dropComments(d.toString());
164 | opts = JSON.parse(unCommented);
165 | opts = mergeOpts(opts, type);
166 | resolve(opts);
167 | } catch (e) {
168 | vscode.window.showWarningMessage(
169 | `Found a .jsbeautifyrc file [${configFile}], but it didn't parse correctly.`);
170 | reject();
171 | }
172 | });
173 | });
174 | };
--------------------------------------------------------------------------------
/out/beautify.js:
--------------------------------------------------------------------------------
1 | const vscode = require('vscode'),
2 | beautify = require('js-beautify'),
3 | options = require('./options'),
4 | minimatch = require('minimatch'),
5 | path = require('path');
6 | const dumpError = e => {
7 | if (0 && e) {
8 | // console.log('beautify err:', e);
9 | }
10 | };
11 |
12 | const getBeautifyType = () => {
13 | return vscode.window.showQuickPick(
14 | [
15 | { label: 'JS', description: 'Does JavaScript and JSON' },
16 | { label: 'CSS', description: 'Does CSS and SCSS' },
17 | { label: 'HTML' }
18 | ], {
19 | matchOnDescription: true,
20 | placeHolder: 'Couldn\'t determine type to beautify, please choose.'
21 | })
22 | .then(choice => {
23 | if (!choice || !choice.label) throw 'no beautify type selected';
24 | return choice.label.toLowerCase();
25 | });
26 | };
27 |
28 | const removeNewLineEndForPartial = (config, isPartial) => {
29 | if (isPartial) { config.end_with_newline = false; }
30 | return Promise.resolve(config);
31 | };
32 |
33 | const beautifyDocRanges = (doc, ranges, type, formattingOptions, isPartial) => {
34 | if (!doc) {
35 | vscode.window.showInformationMessage(
36 | 'Beautify can\'t get the file information because the editor won\'t supply it. (File probably too large)');
37 | throw '';
38 | }
39 | return Promise.resolve(type ? type : getBeautifyType())
40 | .then(type => options(doc, type, formattingOptions)
41 | .then(config => removeNewLineEndForPartial(config, isPartial))
42 | .then(config => Promise.all(ranges.map(range =>
43 | beautify[type](doc.getText(range), config)))));
44 | };
45 |
46 | const documentEdit = (range, newText) => [vscode.TextEdit.replace(range, newText)];
47 |
48 | const extendRange = (doc, rng) => {
49 | let end = rng.end;
50 | if (end.character === 0) end = end.translate(-1, Number.MAX_VALUE);
51 | else end = end.translate(0, Number.MAX_VALUE);
52 | const r = new vscode.Range(new vscode.Position(rng.start.line, 0), end);
53 | return doc.validateRange(r);
54 | };
55 |
56 | const fullRange = doc => doc.validateRange(new vscode.Range(0, 0, Number.MAX_VALUE, Number.MAX_VALUE));
57 |
58 | const getWorkspaceRoot = doc => {
59 | if (!vscode.workspace.workspaceFolders || vscode.workspace.workspaceFolders.length === 0) return;
60 | if (!doc || doc.isUntitled) return vscode.workspace.workspaceFolders[0].uri.fsPath;
61 |
62 | const folder = vscode.workspace.getWorkspaceFolder(doc.uri);
63 | if (!folder) return;
64 | return folder.uri.fsPath;
65 | };
66 |
67 | // gets bound
68 | function fullEdit(type, doc, formattingOptions) {
69 | let name = doc.fileName;
70 | let base = getWorkspaceRoot(doc) || vscode.workspace.rootPath || '';
71 | let ignore = vscode.workspace.getConfiguration('compile-hero', doc.uri)
72 | .ignore;
73 | console.log(ignore);
74 | if (!Array.isArray(ignore)) ignore = [ignore];
75 | if (base && name.startsWith(base)) name = path.relative(base, name);
76 | if (ignore.some(glob => minimatch(name, glob))) return [];
77 |
78 | const rng = fullRange(doc);
79 | return beautifyDocRanges(doc, [rng], type, formattingOptions)
80 | .then(newText => documentEdit(rng, newText[0]), dumpError);
81 | }
82 |
83 | function rangeEdit(type, doc, rng, formattingOptions) {
84 | // Fixes bug #106
85 | rng = extendRange(doc, rng);
86 | return beautifyDocRanges(doc, [rng], type, formattingOptions, true)
87 | .then(newText => documentEdit(rng, newText[0]), dumpError);
88 | }
89 |
90 | const register = (type, selector, partial) => {
91 | if (partial) return vscode.languages.registerDocumentRangeFormattingEditProvider(selector, {
92 | provideDocumentRangeFormattingEdits: rangeEdit.bind(0, type)
93 | });
94 | else return vscode.languages.registerDocumentFormattingEditProvider(selector, {
95 | provideDocumentFormattingEdits: fullEdit.bind(0, type)
96 | });
97 | };
98 |
99 | class Formatters {
100 | constructor() {
101 | this.available = {
102 | js: beautify.js,
103 | css: beautify.css,
104 | html: beautify.html
105 | };
106 | this.configTypes = {
107 | type: 1,
108 | ext: 1,
109 | filename: 1
110 | };
111 | this.handlers = {};
112 | }
113 | onFileOpen(doc) {
114 | for (let a in this.handlers) {
115 | if (vscode.languages.match(this.handlers[a].selector, doc)) {
116 | // drop and re-register this one
117 | this.handlers[a].full.dispose();
118 | this.handlers[a].partial.dispose();
119 | this.handlers[a].full = register(a, this.handlers[a].selector);
120 | this.handlers[a].partial = register(a, this.handlers[a].selector, true);
121 | return a;
122 | }
123 | }
124 | }
125 | configure() {
126 | let beautifyCfg = vscode.workspace.getConfiguration('compile-hero');
127 | let cfg = beautifyCfg.language;
128 | let js = beautifyCfg.JSFiles;
129 | let css = beautifyCfg.CSSFiles;
130 | let html = beautifyCfg.HTMLFiles;
131 | if (js || css || html) {
132 | cfg = {};
133 | if (js) cfg.js = { ext: js };
134 | if (css) cfg.css = { ext: css };
135 | if (html) cfg.html = { ext: html };
136 | vscode.window.showInformationMessage(
137 | '`beautify.*Files` setting is deprecated. please use `beautify.language` instead. Open settings ->',
138 | 'Global', 'Workspace')
139 | .then(open => {
140 | if (open) vscode.commands.executeCommand(`workbench.action.open${open}Settings`);
141 | }, dumpError);
142 | }
143 | cfg = cfg || {};
144 | this.dispose();
145 | for (let a in cfg) {
146 | if (!(a in this.available)) continue;
147 | // dispose of the current
148 | let selector = [];
149 | if (Array.isArray(cfg[a])) {
150 | selector = cfg[a].map(language => ({ language, scheme: 'file' }));
151 | } else {
152 | for (let b in cfg[a]) {
153 | let adder;
154 | switch (b) {
155 | case 'type':
156 | adder = cfg[a][b].map(language => ({ language, scheme: 'file' }));
157 | break;
158 | case 'ext':
159 | adder = [{ pattern: `**/*.{${cfg[a][b].join(',')}}`, scheme: 'file' }];
160 | break;
161 | case 'filename':
162 | adder = [{ pattern: `**/{${cfg[a][b].join(',')}}`, scheme: 'file' }];
163 | break;
164 | default:
165 | continue;
166 | }
167 | selector = selector.concat(adder);
168 | }
169 | }
170 | selector = selector.concat(selector.map(s => {
171 | const ss = Object.create(s);
172 | ss.scheme = 'untitled';
173 | return ss;
174 | }));
175 |
176 | if (selector.length) {
177 | this.handlers[a] = {
178 | selector,
179 | full: register(a, selector),
180 | partial: register(a, selector, true)
181 | };
182 | } else {
183 | delete this.handlers[a];
184 | }
185 | }
186 | }
187 | getFormat(doc) {
188 | for (let a in this.handlers) {
189 | if (vscode.languages.match(this.handlers[a].selector, doc)) return a;
190 | }
191 | }
192 | dispose() {
193 | for (let a in this.handlers) {
194 | this.handlers[a].full.dispose();
195 | this.handlers[a].partial.dispose();
196 | }
197 | this.handlers = {};
198 | }
199 | }
200 |
201 | const formatters = new Formatters();
202 |
203 | const applyEdits = (editor, ranges, edits) => {
204 | if (ranges.length !== edits.length) {
205 | vscode.window.showInformationMessage(
206 | 'Beautify ranges didn\'t get back the right number of edits');
207 | throw '';
208 | }
209 | return editor.edit(editorEdit => {
210 | for (let i = 0; i < ranges.length; i++) {
211 | editorEdit.replace(ranges[i], edits[i]);
212 | }
213 | });
214 | };
215 |
216 | const formatActiveDocument = ranged => {
217 | const active = vscode.window.activeTextEditor;
218 | if (!active || !active.document) return;
219 |
220 | const type = formatters.getFormat(active.document);
221 | let ranges = [];
222 | if (ranged && active.selection) {
223 | ranges = active.selections.filter(selection => !selection.isEmpty)
224 | .map(range => extendRange(active.document, range));
225 | }
226 | if (ranges.length === 0)
227 | ranges = [fullRange(active.document)];
228 |
229 | if (ranges.length) {
230 | return beautifyDocRanges(active.document, ranges, type, null, ranged)
231 | .then(edits => applyEdits(active, ranges, edits), dumpError);
232 | } else return Promise.resolve();
233 | };
234 |
235 |
236 | module.exports = {
237 | formatters,
238 | applyEdits,
239 | formatActiveDocument
240 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {"name":"eno","displayName":"Sass/Less/Stylus/Pug/Jade/Typescript/Javascript Compile Hero Pro","description":"🚀Easy to compile ts, tsx, scss, less, stylus, jade, pug and es6+ on save without using a build task.","author":{"name":"Eno Yao","email":"kalone.cool@gmail.com","url":"https://github.com/Wscats"},"publisher":"Wscats","version":"2.3.53","preview":true,"icon":"logos/hero2.png","homepage":"https://github.com/Wscats/compile-hero","engines":{"vscode":"^1.39.0"},"badges":[{"url":"https://img.shields.io/badge/Author-Eno Yao-blueviolet","href":"https://github.com/Wscats","description":"Eno Yao"},{"url":"https://vsmarketplacebadge.apphb.com/version-short/wscats.eno.svg?color=blue&style=flat-square","href":"https://marketplace.visualstudio.com/items?itemName=Wscats.eno","description":"VS Marketplace"}],"galleryBanner":{"color":"#58bc58","theme":"dark"},"bugs":{"url":"https://github.com/Wscats/compile-hero/issues/new"},"license":"MIT","repository":{"type":"git","url":"https://github.com/Wscats/compile-hero"},"categories":["Other","Programming Languages","Snippets","Linters","Debuggers","Formatters"],"keywords":["sass","beautify","scss","typescript","ts","less","stylus","ES6","ES5","js","css","javascript","html","compile","tsx","jade","hero","close","port","pug","minified","format","formatter","formate"],"activationEvents":["onLanguage:less","onLanguage:scss","onLanguage:sass","onLanguage:jade","onLanguage:pug","onLanguage:stylus","onLanguage:javascript","onLanguage:javascriptreact","onLanguage:typescript","onLanguage:typescriptreact","onCommand:compile-hero.openInBrowser","onCommand:compile-hero.closePort","onCommand:compile-hero.compileFile","onCommand:compile-hero.compileSelected","onCommand:compile-hero.compileHeroOn","onCommand:compile-hero.compileHeroOff","onCommand:compile-hero.beautify","onCommand:compile-hero.beautifyFile"],"main":"./out/extension.js","contributes":{"commands":[{"command":"compile-hero.openInBrowser","title":"Open In Browser"},{"command":"compile-hero.closePort","title":"Close Port"},{"command":"compile-hero.compileSelected","title":"Compile Selected"},{"command":"compile-hero.compileFile","title":"Compile Files"},{"command":"compile-hero.beautify","title":"Beautify"},{"command":"compile-hero.beautifyFile","title":"Beautify File"}],"languages":[{"id":"json","aliases":["JSON"],"filenames":[".jsbeautifyrc",".jshintrc"]},{"id":"sass","aliases":["SASS"],"extensions":[".sass"]},{"id":"stylus","aliases":["styl"],"extensions":[".styl"]}],"jsonValidation":[{"fileMatch":".jsbeautifyrc","url":"./beautifyrc.json"}],"configuration":{"title":"Compile hero configuration","properties":{"compile-hero.disable-compile-files-on-did-save-code":{"type":"boolean","default":true,"description":"Disable compile files on did save code."},"compile-hero.javascript-output-directory":{"type":"string","default":"./dist","description":"Set the directory to output after compiling javascript."},"compile-hero.sass-output-directory":{"type":"string","default":"./dist","description":"Set the directory to output after compiling sass."},"compile-hero.scss-output-directory":{"type":"string","default":"./dist","description":"Set the directory to output after compiling sass."},"compile-hero.less-output-directory":{"type":"string","default":"./dist","description":"Set the directory to output after compiling less."},"compile-hero.stylus-output-directory":{"type":"string","default":"./dist","description":"Set the directory to output after compiling stylus."},"compile-hero.jade-output-directory":{"type":"string","default":"./dist","description":"Set the directory to output after compiling jade."},"compile-hero.typescript-output-directory":{"type":"string","default":"./dist","description":"Set the directory to output after compiling typescript."},"compile-hero.typescriptx-output-directory":{"type":"string","default":"./dist","description":"Set the directory to output after compiling typescriptx."},"compile-hero.pug-output-directory":{"type":"string","default":"./dist","description":"Set the directory to output after compiling pug."},"compile-hero.javascript-output-toggle":{"type":"boolean","default":true,"description":"Switch to control the compilation of javascript."},"compile-hero.sass-output-toggle":{"type":"boolean","default":true,"description":"Switch to control the compilation of sass."},"compile-hero.scss-output-toggle":{"type":"boolean","default":true,"description":"Switch to control the compilation of sass."},"compile-hero.less-output-toggle":{"type":"boolean","default":true,"description":"Switch to control the compilation of less."},"compile-hero.stylus-output-toggle":{"type":"boolean","default":true,"description":"Switch to control the compilation of stylus."},"compile-hero.jade-output-toggle":{"type":"boolean","default":true,"description":"Switch to control the compilation of jade."},"compile-hero.typescript-output-toggle":{"type":"boolean","default":true,"description":"Switch to control the compilation of typescript."},"compile-hero.typescriptx-output-toggle":{"type":"boolean","default":true,"description":"Switch to control the compilation of typescriptx."},"compile-hero.pug-output-toggle":{"type":"boolean","default":true,"description":"Switch to control the compilation of pug."},"compile-hero.notification-toggle":{"type":"boolean","default":true,"description":"Switch to control the notification."},"compile-hero.generate-minified-html":{"type":"boolean","default":false,"description":"Enable to generate minified html (*.min.html) files."},"compile-hero.generate-minified-html-only":{"type":"boolean","default":false,"description":"Enable to generate only minified html (*.min.html) files."},"compile-hero.generate-minified-css":{"type":"boolean","default":false,"description":"Enable to generate minified css (*.min.css) files."},"compile-hero.generate-minified-css-only":{"type":"boolean","default":false,"description":"Enable to generate only minified css (*.min.css) files."},"compile-hero.generate-minified-javascript":{"type":"boolean","default":false,"description":"Enable to generate minified javascript (*.dev.js) files."},"compile-hero.generate-minified-javascript-only":{"type":"boolean","default":false,"description":"Enable to generate only minified javascript (*.dev.js) files."},"compile-hero.ignore":{"type":["string","array"],"items":{"type":"string"},"default":[],"description":"List of paths to ignore when using format or compile command, including format or compile on save, uses glob pattern matching.","scope":"resource"},"compile-hero.watch":{"type":["string","array"],"items":{"type":"string"},"default":[],"description":"List of paths to watch when using format or compile command, including format or compile on save, uses glob pattern matching.","scope":"resource"},"compile-hero.config":{"type":["string","object","null"],"default":null,"description":"A path to a file, or an object containing the configuration options for js-beautify, if the .jsbeautifyrc file exists in project root, it overrides this configuration."},"compile-hero.language":{"type":"object","description":"Link file types to the beautifier type.","default":{"js":{"type":["javascript","json","jsonc"],"filename":[".jshintrc",".jsbeautifyrc"]},"css":["css","less","scss"],"html":["htm","html"]},"properties":{"js":{"type":["object","array","null"],"items":{"type":"string"},"description":"Array of language types, or an object containing types, extensions and filenames to associate","properties":{"type":{"type":"array","items":{"type":"string"},"description":"VS Code language name"},"ext":{"type":"array","items":{"type":"string"},"description":"File extensions (without the leading dot)"},"filename":{"type":"array","items":{"type":"string"},"description":"Full filenames (eg: '.jsbeautifyrc')"}}},"css":{"type":["object","array","null"],"items":{"type":"string"},"description":"Array of language types, or an object containing types, extensions and filenames to associate","properties":{"type":{"type":"array","items":{"type":"string"},"description":"VS Code language name"},"ext":{"type":"array","items":{"type":"string"},"description":"File extensions (without the leading dot)"},"filename":{"type":"array","items":{"type":"string"},"description":"Full filenames (eg: '.jsbeautifyrc')"}}},"html":{"type":["object","array","null"],"items":{"type":"string"},"description":"Array of language types, or an object containing types, extensions and filenames to associate","properties":{"type":{"type":"array","items":{"type":"string"},"description":"VS Code language name"},"ext":{"type":"array","items":{"type":"string"},"description":"File extensions (without the leading dot)"},"filename":{"type":"array","items":{"type":"string"},"description":"Full filenames (eg: '.jsbeautifyrc')"}}}}}}},"keybindings":[{"when":"editorHasSelection && resourceLangId =~ /^less$|^scss$|^jade$|^pug$|^stylus$/","command":"compile-hero.compileSelected","key":"cmd+shift+s ctrl+shift+s","mac":"cmd+shift+s","win":"ctrl+shift+s"}],"menus":{"explorer/context":[{"when":"resourceLangId == html","command":"compile-hero.openInBrowser","group":"open-in-browser"},{"command":"compile-hero.compileFile","group":"navigation"},{"when":"editorHasSelection && resourceLangId =~ /^less$|^scss$|^jade$|^pug$|^stylus$/","command":"compile-hero.compileSelected","group":"navigation"}],"editor/context":[{"when":"resourceLangId == html","command":"compile-hero.openInBrowser","group":"open-in-browser"},{"command":"compile-hero.compileFile","group":"navigation"},{"when":"editorHasSelection && resourceLangId =~ /^less$|^scss$|^jade$|^pug$|^stylus$/","command":"compile-hero.compileSelected","group":"navigation"}],"editor/title/context":[{"when":"resourceLangId == html","command":"compile-hero.openInBrowser","group":"open-in-browser"},{"command":"compile-hero.compileFile","group":"navigation"},{"when":"editorHasSelection && resourceLangId =~ /^less$|^scss$|^jade$|^pug$|^stylus$/","command":"compile-hero.compileSelected","group":"navigation"}]}},"scripts":{"build":"npm run build:delete.vsix && npm run build:compile.hero && npm run build:beautify","vscode:prepublish":"yarn run compile","build:delete.vsix":"node publish d","build:compile.hero":"node publish c && vsce package","build:beautify":"node publish b && vsce package","compile":"tsc -p ./","watch":"tsc -watch -p ./","postinstall":"node ./node_modules/vscode/bin/install","test":"yarn run compile && node ./node_modules/vscode/bin/test"},"dependencies":{"@babel/core":"^7.7.0","@babel/preset-env":"^7.7.1","editorconfig":"^0.15.3","gulp":"^4.0.2","gulp-babel":"^8.0.0","gulp-minify-css":"^1.2.4","gulp-rename":"^1.4.0","gulp-typescript":"^5.0.1","gulp-uglify":"^3.0.2","js-beautify":"^1.13.0","minimatch":"^3.0.4","pug":"^3.0.1","sass":"^1.26.10","less":"^3.12.2","typescript":"^3.3.1","stylus":"^0.54.8"},"devDependencies":{"vscode":"^1.1.28","@types/mocha":"^2.2.42","@types/node":"^10.12.21"}}
--------------------------------------------------------------------------------
/out/util.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;AAEH,iCAAiC;AACjC,iDAAqC;AACrC,yBAAyB;AACzB,6BAA6B;AAC7B,yBAAyB;AACzB,iCAAyB;AACzB,uCAA0C;AAE1C,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC,MAAM,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAEvC,yCAA4C;AAC5C,qDAAwD;AACxD,yCAA4C;AAC5C,qDAAwD;AACxD,uDAA0D;AAC1D,uCAA0C;AAC1C,6CAAgD;AAEnC,QAAA,cAAc,GAAG,0BAA0B,CAAC;AAC5C,QAAA,YAAY,GAAG,uBAA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CAAC,aAAa,CAAC,CAAC;QAC9C,OAAO,KAAK,CAAC;KAChB;IACD,OAAO,GAAG,CAAC;AACf,CAAC;AAjCD,sCAiCC;AAAA,CAAC"}
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | 
4 | 
5 |
6 | [English](https://github.com/Wscats/compile-hero/blob/master/README.md) | [中文](https://gitee.com/wscats/compile-hero/blob/master/README.CN.md)
7 |
8 | # Features
9 |
10 |
11 |
12 | > 1.Open the `less, sass, scss, styl, ts, tsx, jade, pug or js` file.
13 |
14 | > 2.`Compile Hero: On/Off` will appear in the status bar at the bottom right corner, please turn on the `Compile Hero: On` switch when using ↓
15 |
16 |
17 |
18 | 
19 |
20 | > 3.Compile on save `(ctrl+s)` ↓
21 |
22 | Or select `Compile Files` on right-click menu item, it will automatically compile the files to the `dist` directory.
23 |
24 |
25 |
26 | 
27 | 
28 |
29 | You can also select part of the code and use the `Compile Selected` menu item or shortcut key `(ctrl+shift+s)` to perform partial compilation of the code block.
30 |
31 | 
32 |
33 | > 4.Beautify on save `(alt+shift+f)` or select `Format Document` on right-click menu item for `javascript, json, css, sass and html`.
34 |
35 | 
36 |
37 | - Compile `less, sass, scss, stylus, typescript, typescriptreact, jade, pug and javascript` on save.
38 | - Support autoprefixer for `less, scss, scss`.
39 | - Support to open `html` files to preview in browser.
40 | - minify `javascript` and `css` files.
41 | - Beautify `javascript`, `json`, `css`, `sass`, and `html`.
42 |
43 | | Before Compile | After Compile |
44 | | -------------- | ------------- |
45 | | .pug | .html |
46 | | .jade | .html |
47 | | .scss(sass) | .css |
48 | | .less | .css |
49 | | .styl | .css |
50 | | .ts/.tsx | .js(JSX) |
51 | | .js(ES6) | .js(ES5) |
52 |
53 | Easy to use. When you writing a file, press save `ctrl+s` to generate the compiled file in the same directory. I hope you can get rid of the constraint of `gulp` or `webpack`😁
54 |
55 | # Extension Settings
56 |
57 | Click to open the extension management interface `Configure Extension Settings`.
58 |
59 | 
60 |
61 | - You can change the output path of the project compilation directory.
62 | - Toggle the compile switch of different language.
63 | - Or disable automatic compilation on save `(ctrl+s)`.
64 |
65 | | Whether the configuration is automatically compiled after saving`(ctrl+s)` | Default Value |
66 | | -------------------------------------------------------------------------- | ------------- |
67 | | disable-compile-files-on-did-save-code | false |
68 |
69 | 
70 |
71 | | Switch to control the notification | Default Value |
72 | | ---------------------------------- | ------------- |
73 | | notification-toggle | true |
74 |
75 | | Switch to control compilation and formatting of specific files | Default Value |
76 | | -------------------------------------------------------------- | ------------- |
77 | | ignore | null |
78 |
79 | | Output Path Configuration | Default Value | Compile Switch Status | Default Value |
80 | | ---------------------------- | ------------- | --------------------------------- | ------------- |
81 | | javascript-output-directory | ./dist | javascript-output-toggle | true |
82 | | sass-output-directory | ./dist | sass-output-toggle | true |
83 | | scss-output-directory | ./dist | scss-output-toggle | true |
84 | | less-output-directory | ./dist | less-output-toggle | true |
85 | | jade-output-directory | ./dist | jade-output-toggle | true |
86 | | typescript-output-directory | ./dist | typescript-output-toggle | true |
87 | | typescriptx-output-directory | ./dist | typescriptx-output-toggle | true |
88 | | pug-output-directory | ./dist | pug-output-toggle | true |
89 | | stylus-output-directory | ./dist | stylus-output-toggle | true |
90 | | generate-minified-html | false | generate-minified-html-only | false |
91 | | generate-minified-css | false | generate-minified-css-only | false |
92 | | generate-minified-javascript | false | generate-minified-javascript-only | false |
93 |
94 | ## Using `settings.json`
95 |
96 | Advanced Extension Settings:
97 |
98 | - Project-wide settings are configured using the standard `settings.json` file (i.e. Workspace Settings).
99 | - `settings.json` must exist in the .vscode directory at the root level of your project.
100 | - Alternatively, settings can go in User Settings for global defaults.
101 | - Use the `compile-hero` key.
102 | - Prohibit partial compilation and formatting of specific files `compile-hero.ignore`.
103 | - Use `compile-hero.watch` to monitor partial files - You can turn this on -> `Compile Hero: On` when using.
104 |
105 | Here Example `settings.json` file:
106 |
107 | ```json
108 | {
109 | "compile-hero": {
110 | "disable-compile-files-on-did-save-code": false,
111 | "notification-toggle": false,
112 | "javascript-output-directory": "./out",
113 | "javascript-output-toggle": false,
114 | "sass-output-directory": "./out",
115 | "sass-output-toggle": true,
116 | "ignore": ["src/test.js", "*/test.scss", "**/spec/*", "**/src/**/*"],
117 | "watch": ["sass/test.sass", "**/less/**/*"]
118 | }
119 | }
120 | ```
121 |
122 | ## Using `tsconfig.json`
123 |
124 | If you want to add or overwrite certain settings in the `tsconfig.json` file, you can create a new `tsconfig.json` in the same directory of your `.ts` file.
125 |
126 | Here Example `tsconfig.json` file:
127 |
128 | ```json
129 | {
130 | "compilerOptions": {
131 | "alwaysStrict": true,
132 | "importHelpers": false
133 | }
134 | }
135 | ```
136 |
137 | # Open In Browser
138 |
139 | Right click the `html` file in the directory menu, and the `open in browser` option will appear. You can preview the page in the browser.
140 |
141 | 
142 |
143 | # Compile File Menu Item
144 |
145 | Sometimes you may not need to automatically compile the file every time you save the file, at this time you can disable the automatic compilation. And use the `Compile File(s)` menu item to replace.
146 |
147 | 
148 |
149 | # Close Port Command(MAC)
150 |
151 | At some point, you may be using ports for some services. You can use the `Close Port` command to close, but now only supported on mac.
152 |
153 | 
154 |
155 | # Thanks
156 |
157 |
158 |
159 | 👪 Tencent Alloyteam Team And Qian Feng Team:
160 |
161 | | [
Eno Yao](https://github.com/Wscats) | [
Aaron Xie](https://github.com/aaron-xie) | [
DK Lan](https://github.com/dk-lan) | [
Yong](https://github.com/flowerField) | [
Li Ting](https://github.com/Liting1) | 
Xin | [
Lemon](https://github.com/lemonyyye) | [
Jing](https://github.com/vickySC) | [
Lin](https://github.com/shirley3790) | [
Tian Fly](https://github.com/tiantengfly) |
162 | | - | - | - | - | - | - | - | - | - | - |
163 |
164 |
165 |
166 |
167 |
168 | If you think it's useful, hope you can leave us a [message and like it](https://marketplace.visualstudio.com/items?itemName=Wscats.eno&ssr=false#review-details)💝, your support is our driving force😀
169 |
170 |
171 |
172 |
173 |
174 |
181 |
182 | # License
183 |
184 | Compile Hero is released under the [MIT](http://opensource.org/licenses/MIT).
185 |
186 |
187 |
188 |
189 |
190 |
--------------------------------------------------------------------------------
/out/util.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | /**
3 | * Copyright © 1998 - 2020 Tencent. All Rights Reserved.
4 | *
5 | * @author enoyao
6 | */
7 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
9 | return new (P || (P = Promise))(function (resolve, reject) {
10 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13 | step((generator = generator.apply(thisArg, _arguments || [])).next());
14 | });
15 | };
16 | Object.defineProperty(exports, "__esModule", { value: true });
17 | exports.veriableCheck = exports.readFileName = exports.getWorkspaceRoot = exports.getSelectedText = exports.complieDir = exports.complieFile = exports.empty = exports.transformPort = exports.command = exports.fileType = exports.readFileContext = exports.openBrowser = exports.open = exports.defaultBrowser = exports.standardizedBrowserName = exports.wsl = exports.docker = exports.suffixs = exports.LANGUAGE_SUFFIX = exports.errorMessage = exports.successMessage = void 0;
18 | const vscode = require("vscode");
19 | const child_process_1 = require("child_process");
20 | const fs = require("fs");
21 | const path = require("path");
22 | const os = require("os");
23 | const open_1 = require("./open");
24 | const browser_1 = require("./browser");
25 | const through = require("through2");
26 | const minimatch = require('minimatch');
27 | const sass_1 = require("./compile/sass");
28 | const javascript_1 = require("./compile/javascript");
29 | const less_1 = require("./compile/less");
30 | const typescript_1 = require("./compile/typescript");
31 | const typescriptx_1 = require("./compile/typescriptx");
32 | const pug_1 = require("./compile/pug");
33 | const stylus_1 = require("./compile/stylus");
34 | exports.successMessage = "✔ Compilation Successed!";
35 | exports.errorMessage = "❌ Compilation Failed!";
36 | var LANGUAGE_SUFFIX;
37 | (function (LANGUAGE_SUFFIX) {
38 | LANGUAGE_SUFFIX["JAVASCRIPT"] = ".js";
39 | LANGUAGE_SUFFIX["SCSS"] = ".scss";
40 | LANGUAGE_SUFFIX["SASS"] = ".sass";
41 | LANGUAGE_SUFFIX["LESS"] = ".less";
42 | LANGUAGE_SUFFIX["JADE"] = ".jade";
43 | LANGUAGE_SUFFIX["TYPESCRIPT"] = ".ts";
44 | LANGUAGE_SUFFIX["TYPESCRIPTX"] = ".tsx";
45 | LANGUAGE_SUFFIX["PUG"] = ".pug";
46 | LANGUAGE_SUFFIX["STYLUS"] = ".styl";
47 | })(LANGUAGE_SUFFIX = exports.LANGUAGE_SUFFIX || (exports.LANGUAGE_SUFFIX = {}));
48 | exports.suffixs = [
49 | LANGUAGE_SUFFIX.JAVASCRIPT,
50 | LANGUAGE_SUFFIX.SCSS,
51 | LANGUAGE_SUFFIX.SASS,
52 | LANGUAGE_SUFFIX.LESS,
53 | LANGUAGE_SUFFIX.JADE,
54 | LANGUAGE_SUFFIX.TYPESCRIPT,
55 | LANGUAGE_SUFFIX.TYPESCRIPTX,
56 | LANGUAGE_SUFFIX.PUG,
57 | LANGUAGE_SUFFIX.STYLUS
58 | ];
59 | let isDocker;
60 | exports.docker = () => {
61 | const hasDockerEnv = () => {
62 | try {
63 | fs.statSync('/.dockerenv');
64 | return true;
65 | }
66 | catch (_) {
67 | return false;
68 | }
69 | };
70 | const hasDockerCGroup = () => {
71 | try {
72 | return fs.readFileSync('/proc/self/cgroup', 'utf8').includes('docker');
73 | }
74 | catch (_) {
75 | return false;
76 | }
77 | };
78 | if (isDocker === undefined) {
79 | isDocker = hasDockerEnv() || hasDockerCGroup();
80 | }
81 | return isDocker;
82 | };
83 | const wsll = () => {
84 | if (process.platform !== 'linux') {
85 | return false;
86 | }
87 | if (os.release().toLowerCase().includes('microsoft')) {
88 | if (exports.docker()) {
89 | return false;
90 | }
91 | return true;
92 | }
93 | try {
94 | return fs.readFileSync('/proc/version', 'utf8').toLowerCase().includes('microsoft') ?
95 | !exports.docker() : false;
96 | }
97 | catch (_) {
98 | return false;
99 | }
100 | };
101 | exports.wsl = process.env.__IS_WSL_TEST__ ? wsll : wsll();
102 | exports.standardizedBrowserName = (name = '') => {
103 | let _name = name.toLowerCase();
104 | const browser = browser_1.browserConfig.browsers.find(item => {
105 | return item.acceptName.indexOf(_name) !== -1;
106 | });
107 | return browser ? browser.standardName : '';
108 | };
109 | exports.defaultBrowser = () => {
110 | const config = vscode.workspace.getConfiguration(browser_1.browserConfig.app);
111 | return config ? config.default : '';
112 | };
113 | exports.open = (path, browser) => {
114 | open_1.default(path, { app: browser }).catch((err) => {
115 | vscode.window.showErrorMessage(`Open browser failed!! Please check if you have installed the browser ${browser} correctly!`);
116 | });
117 | };
118 | exports.openBrowser = (path) => {
119 | const browser = exports.standardizedBrowserName(exports.defaultBrowser());
120 | exports.open(path, browser);
121 | };
122 | exports.readFileContext = (path) => {
123 | return fs.readFileSync(path).toString();
124 | };
125 | exports.fileType = (filename) => {
126 | const index1 = filename.lastIndexOf(".");
127 | const index2 = filename.length;
128 | const type = filename.substring(index1, index2);
129 | return type;
130 | };
131 | exports.command = (cmd) => {
132 | return new Promise((resolve, reject) => {
133 | child_process_1.exec(cmd, (err, stdout, stderr) => {
134 | resolve(stdout);
135 | });
136 | });
137 | };
138 | exports.transformPort = (data) => {
139 | let port = "";
140 | data.split(/[\n|\r]/).forEach((item) => {
141 | if (item.indexOf("LISTEN") !== -1 && !port) {
142 | let reg = item.split(/\s+/);
143 | if (/\d+/.test(reg[1])) {
144 | port = reg[1];
145 | }
146 | }
147 | });
148 | return port;
149 | };
150 | exports.empty = function (code) {
151 | let stream = through.obj((file, encoding, callback) => {
152 | if (!file.isBuffer()) {
153 | return callback();
154 | }
155 | file.contents = Buffer.from(code || "");
156 | stream.push(file);
157 | callback();
158 | });
159 | return stream;
160 | };
161 | exports.complieFile = (uri) => {
162 | exports.readFileName({ fileName: uri });
163 | };
164 | exports.complieDir = (uri) => {
165 | const files = fs.readdirSync(uri);
166 | files.forEach((filename) => {
167 | const fileUrl = path.join(uri, filename);
168 | const fileStats = fs.statSync(fileUrl);
169 | if (fileStats.isDirectory()) {
170 | exports.complieDir(fileUrl);
171 | }
172 | else {
173 | exports.complieFile(fileUrl);
174 | }
175 | });
176 | };
177 | // 获取当前选中的文本
178 | exports.getSelectedText = () => {
179 | var _a, _b, _c, _d;
180 | const documentText = (_a = vscode.window.activeTextEditor) === null || _a === void 0 ? void 0 : _a.document.getText();
181 | if (!documentText) {
182 | return "";
183 | }
184 | const activeSelection = (_b = vscode.window.activeTextEditor) === null || _b === void 0 ? void 0 : _b.selection;
185 | if (activeSelection === null || activeSelection === void 0 ? void 0 : activeSelection.isEmpty) {
186 | return "";
187 | }
188 | const selectStartOffset = (_c = vscode.window.activeTextEditor) === null || _c === void 0 ? void 0 : _c.document.offsetAt(activeSelection === null || activeSelection === void 0 ? void 0 : activeSelection.start);
189 | const selectEndOffset = (_d = vscode.window.activeTextEditor) === null || _d === void 0 ? void 0 : _d.document.offsetAt(activeSelection === null || activeSelection === void 0 ? void 0 : activeSelection.end);
190 | let selectedText = documentText.slice(selectStartOffset, selectEndOffset).trim();
191 | selectedText = selectedText.replace(/\s\s+/g, " ");
192 | return selectedText;
193 | };
194 | // 获取工作区位置
195 | exports.getWorkspaceRoot = (doc) => {
196 | if (!vscode.workspace.workspaceFolders || vscode.workspace.workspaceFolders.length === 0)
197 | return;
198 | if (!doc || doc.isUntitled)
199 | return vscode.workspace.workspaceFolders[0].uri.fsPath;
200 | const folder = vscode.workspace.getWorkspaceFolder(doc.uri);
201 | if (!folder)
202 | return;
203 | return folder.uri.fsPath;
204 | };
205 | exports.readFileName = ({ fileName, selectedText }) => __awaiter(void 0, void 0, void 0, function* () {
206 | let workspaceRootPath = vscode.workspace.rootPath;
207 | let fileSuffix = exports.fileType(fileName);
208 | let config = vscode.workspace.getConfiguration("compile-hero");
209 | let outputDirectoryPath = {
210 | [LANGUAGE_SUFFIX.JAVASCRIPT]: config.get("javascript-output-directory") || "",
211 | [LANGUAGE_SUFFIX.SCSS]: config.get("scss-output-directory") || "",
212 | [LANGUAGE_SUFFIX.SASS]: config.get("sass-output-directory") || "",
213 | [LANGUAGE_SUFFIX.LESS]: config.get("less-output-directory") || "",
214 | [LANGUAGE_SUFFIX.JADE]: config.get("jade-output-directory") || "",
215 | [LANGUAGE_SUFFIX.TYPESCRIPT]: config.get("typescript-output-directory") || "",
216 | [LANGUAGE_SUFFIX.TYPESCRIPTX]: config.get("typescriptx-output-directory") || "",
217 | [LANGUAGE_SUFFIX.PUG]: config.get("pug-output-directory") || "",
218 | [LANGUAGE_SUFFIX.STYLUS]: config.get("stylus-output-directory") || "",
219 | };
220 | let compileStatus = {
221 | [LANGUAGE_SUFFIX.JAVASCRIPT]: config.get("javascript-output-toggle"),
222 | [LANGUAGE_SUFFIX.SCSS]: config.get("scss-output-toggle"),
223 | [LANGUAGE_SUFFIX.SASS]: config.get("sass-output-toggle"),
224 | [LANGUAGE_SUFFIX.LESS]: config.get("less-output-toggle"),
225 | [LANGUAGE_SUFFIX.JADE]: config.get("jade-output-toggle"),
226 | [LANGUAGE_SUFFIX.TYPESCRIPT]: config.get("typescript-output-toggle"),
227 | [LANGUAGE_SUFFIX.TYPESCRIPTX]: config.get("typescriptx-output-toggle"),
228 | [LANGUAGE_SUFFIX.PUG]: config.get("pug-output-toggle"),
229 | [LANGUAGE_SUFFIX.STYLUS]: config.get("stylus-output-toggle"),
230 | };
231 | let ignore = config.get("ignore") || [];
232 | let watch = config.get("watch") || [];
233 | if (workspaceRootPath && fileName.startsWith(workspaceRootPath)) {
234 | let relativePath = path.relative(workspaceRootPath, fileName);
235 | if (!Array.isArray(ignore)) {
236 | ignore = [ignore];
237 | }
238 | ;
239 | if (ignore.some(glob => minimatch(relativePath, glob)))
240 | return;
241 | // 如果设置了 watch,则监听保存的文件路径是否符合,如果不设置,则所有文件都会被监听
242 | if (!Array.isArray(watch)) {
243 | watch = [watch];
244 | }
245 | ;
246 | if (watch.length > 0 && !watch.some(glob => minimatch(relativePath, glob)))
247 | return;
248 | }
249 | ;
250 | let notificationStatus = config.get("notification-toggle");
251 | let compileOptions = {
252 | generateMinifiedHtml: config.get("generate-minified-html"),
253 | generateMinifiedHtmlOnly: config.get("generate-minified-html-only"),
254 | generateMinifiedCss: config.get("generate-minified-css"),
255 | generateMinifiedCssOnly: config.get("generate-minified-css-only"),
256 | generateMinifiedJs: config.get("generate-minified-javascript"),
257 | generateMinifiedJsOnly: config.get("generate-minified-javascript-only"),
258 | };
259 | if (!compileStatus[fileSuffix])
260 | return;
261 | let outputPath = path.resolve(fileName, "../", outputDirectoryPath[fileSuffix]);
262 | let loaderOption = { fileName, outputPath, notificationStatus, compileOptions, selectedText };
263 | switch (fileSuffix) {
264 | case LANGUAGE_SUFFIX.SCSS:
265 | case LANGUAGE_SUFFIX.SASS:
266 | sass_1.sassLoader(loaderOption);
267 | break;
268 | case LANGUAGE_SUFFIX.JAVASCRIPT:
269 | javascript_1.javascriptLoader(loaderOption);
270 | break;
271 | case LANGUAGE_SUFFIX.LESS:
272 | less_1.lessLoader(loaderOption);
273 | break;
274 | case LANGUAGE_SUFFIX.TYPESCRIPT:
275 | typescript_1.typescriptLoader(loaderOption);
276 | break;
277 | case LANGUAGE_SUFFIX.TYPESCRIPTX:
278 | typescriptx_1.typescriptxLoader(loaderOption);
279 | break;
280 | case LANGUAGE_SUFFIX.JADE:
281 | case LANGUAGE_SUFFIX.PUG:
282 | pug_1.pugLoader(loaderOption);
283 | break;
284 | case LANGUAGE_SUFFIX.STYLUS:
285 | stylus_1.stylusLoader(loaderOption);
286 | break;
287 | }
288 | });
289 | function veriableCheck(uri, fileSuffix, workspaceRootPath) {
290 | let veriableError;
291 | if ((uri.indexOf("}/") < 0) &&
292 | ((uri.length - uri.indexOf("}")) > 1) &&
293 | (uri.indexOf("$") >= 0)) {
294 | veriableError = fileSuffix +
295 | "; '/' must be used at the end of the variable or '}' must be the last character.";
296 | vscode.window.showErrorMessage(veriableError);
297 | return false;
298 | }
299 | else if (uri.indexOf("${workspaceFolder}") >= 0) {
300 | uri = uri.replace("${workspaceFolder}", String(workspaceRootPath));
301 | }
302 | else if (uri.indexOf("${folderPath}") >= 0) {
303 | uri = uri.replace("${folderPath}", String(workspaceRootPath));
304 | }
305 | else if (uri.indexOf("$") >= 0) {
306 | let findStartNumber = uri.indexOf("$");
307 | let findEndNumber;
308 | if (uri.indexOf("}") < 0) {
309 | if (uri.indexOf("/") < 0) {
310 | findEndNumber = uri.length;
311 | }
312 | else {
313 | findEndNumber = uri.indexOf("/");
314 | }
315 | }
316 | else {
317 | findEndNumber = uri.indexOf("}");
318 | }
319 | findEndNumber++;
320 | veriableError = fileSuffix + "; Output directory unsupported variable: " +
321 | uri.slice(findStartNumber, findEndNumber);
322 | vscode.window.showErrorMessage(veriableError);
323 | return false;
324 | }
325 | return uri;
326 | }
327 | exports.veriableCheck = veriableCheck;
328 | ;
329 | //# sourceMappingURL=util.js.map
--------------------------------------------------------------------------------
/src/util.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © 1998 - 2020 Tencent. All Rights Reserved.
3 | *
4 | * @author enoyao
5 | */
6 |
7 | import * as vscode from "vscode";
8 | import { exec } from "child_process";
9 | import * as fs from "fs";
10 | import * as path from "path";
11 | import * as os from "os";
12 | import opn from './open';
13 | import { browserConfig } from './browser';
14 |
15 | const through = require("through2");
16 | const minimatch = require('minimatch');
17 |
18 | import { sassLoader } from './compile/sass';
19 | import { javascriptLoader } from './compile/javascript';
20 | import { lessLoader } from './compile/less';
21 | import { typescriptLoader } from './compile/typescript';
22 | import { typescriptxLoader } from './compile/typescriptx';
23 | import { pugLoader } from './compile/pug';
24 | import { stylusLoader } from './compile/stylus';
25 |
26 | export const successMessage = "✔ Compilation Successed!";
27 | export const errorMessage = "❌ Compilation Failed!";
28 |
29 | export enum LANGUAGE_SUFFIX {
30 | JAVASCRIPT = ".js",
31 | SCSS = ".scss",
32 | SASS = ".sass",
33 | LESS = ".less",
34 | JADE = ".jade",
35 | TYPESCRIPT = ".ts",
36 | TYPESCRIPTX = ".tsx",
37 | PUG = ".pug",
38 | STYLUS = ".styl"
39 | }
40 |
41 | export const suffixs = [
42 | LANGUAGE_SUFFIX.JAVASCRIPT,
43 | LANGUAGE_SUFFIX.SCSS,
44 | LANGUAGE_SUFFIX.SASS,
45 | LANGUAGE_SUFFIX.LESS,
46 | LANGUAGE_SUFFIX.JADE,
47 | LANGUAGE_SUFFIX.TYPESCRIPT,
48 | LANGUAGE_SUFFIX.TYPESCRIPTX,
49 | LANGUAGE_SUFFIX.PUG,
50 | LANGUAGE_SUFFIX.STYLUS
51 | ];
52 |
53 | export interface OutputDirectoryPath {
54 | [LANGUAGE_SUFFIX.JAVASCRIPT]: string;
55 | [LANGUAGE_SUFFIX.SCSS]: string;
56 | [LANGUAGE_SUFFIX.SASS]: string;
57 | [LANGUAGE_SUFFIX.LESS]: string;
58 | [LANGUAGE_SUFFIX.JADE]: string;
59 | [LANGUAGE_SUFFIX.TYPESCRIPT]: string;
60 | [LANGUAGE_SUFFIX.TYPESCRIPTX]: string;
61 | [LANGUAGE_SUFFIX.PUG]: string;
62 | [LANGUAGE_SUFFIX.STYLUS]: string;
63 | }
64 |
65 | export interface CompileStatus {
66 | [LANGUAGE_SUFFIX.JAVASCRIPT]: boolean | undefined;
67 | [LANGUAGE_SUFFIX.SCSS]: boolean | undefined;
68 | [LANGUAGE_SUFFIX.SASS]: boolean | undefined;
69 | [LANGUAGE_SUFFIX.LESS]: boolean | undefined;
70 | [LANGUAGE_SUFFIX.JADE]: boolean | undefined;
71 | [LANGUAGE_SUFFIX.TYPESCRIPT]: boolean | undefined;
72 | [LANGUAGE_SUFFIX.TYPESCRIPTX]: boolean | undefined;
73 | [LANGUAGE_SUFFIX.PUG]: boolean | undefined;
74 | [LANGUAGE_SUFFIX.STYLUS]: boolean | undefined;
75 | }
76 |
77 | export interface CompileOptions {
78 | generateMinifiedHtml: boolean | undefined,
79 | generateMinifiedHtmlOnly: boolean | undefined,
80 | generateMinifiedCss: boolean | undefined,
81 | generateMinifiedCssOnly: boolean | undefined,
82 | generateMinifiedJs: boolean | undefined,
83 | generateMinifiedJsOnly: boolean | undefined,
84 | }
85 |
86 | export interface loaderOption {
87 | fileName: string
88 | outputPath: string;
89 | notificationStatus: boolean | undefined;
90 | compileOptions: CompileOptions;
91 | selectedText?: string;
92 | }
93 |
94 | let isDocker: boolean;
95 | export const docker = () => {
96 | const hasDockerEnv = () => {
97 | try {
98 | fs.statSync('/.dockerenv');
99 | return true;
100 | } catch (_) {
101 | return false;
102 | }
103 | }
104 | const hasDockerCGroup = () => {
105 | try {
106 | return fs.readFileSync('/proc/self/cgroup', 'utf8').includes('docker');
107 | } catch (_) {
108 | return false;
109 | }
110 | }
111 | if (isDocker === undefined) {
112 | isDocker = hasDockerEnv() || hasDockerCGroup();
113 | }
114 | return isDocker;
115 | };
116 |
117 | const wsll = () => {
118 | if (process.platform !== 'linux') {
119 | return false;
120 | }
121 | if (os.release().toLowerCase().includes('microsoft')) {
122 | if (docker()) {
123 | return false;
124 | }
125 | return true;
126 | }
127 | try {
128 | return fs.readFileSync('/proc/version', 'utf8').toLowerCase().includes('microsoft') ?
129 | !docker() : false;
130 | } catch (_) {
131 | return false;
132 | }
133 | };
134 |
135 | export const wsl = process.env.__IS_WSL_TEST__ ? wsll : wsll();
136 |
137 | export const standardizedBrowserName = (name: string = ''): string => {
138 | let _name = name.toLowerCase();
139 | const browser = browserConfig.browsers.find(item => {
140 | return item.acceptName.indexOf(_name) !== -1;
141 | });
142 | return browser ? browser.standardName : '';
143 | };
144 |
145 | export const defaultBrowser = (): string => {
146 | const config = vscode.workspace.getConfiguration(browserConfig.app);
147 | return config ? config.default : '';
148 | };
149 |
150 | export const open = (path: string, browser: string | string[]) => {
151 | opn(path, { app: browser }).catch((err: any) => {
152 | vscode.window.showErrorMessage(`Open browser failed!! Please check if you have installed the browser ${browser} correctly!`);
153 | });
154 | };
155 |
156 | export const openBrowser = (path: any): void => {
157 | const browser = standardizedBrowserName(defaultBrowser());
158 | open(path, browser);
159 | };
160 |
161 |
162 | export type FileSuffix =
163 | | LANGUAGE_SUFFIX.JAVASCRIPT
164 | | LANGUAGE_SUFFIX.SCSS
165 | | LANGUAGE_SUFFIX.SASS
166 | | LANGUAGE_SUFFIX.LESS
167 | | LANGUAGE_SUFFIX.JADE
168 | | LANGUAGE_SUFFIX.TYPESCRIPT
169 | | LANGUAGE_SUFFIX.TYPESCRIPTX
170 | | LANGUAGE_SUFFIX.PUG
171 | | LANGUAGE_SUFFIX.STYLUS;
172 |
173 | export const readFileContext = (path: string): string => {
174 | return fs.readFileSync(path).toString();
175 | };
176 |
177 | export const fileType = (filename: string) => {
178 | const index1 = filename.lastIndexOf(".");
179 | const index2 = filename.length;
180 | const type = filename.substring(index1, index2);
181 | return type as FileSuffix;
182 | };
183 |
184 | export const command = (cmd: string) => {
185 | return new Promise((resolve, reject) => {
186 | exec(cmd, (err, stdout, stderr) => {
187 | resolve(stdout);
188 | });
189 | });
190 | };
191 |
192 | export const transformPort = (data: string): string => {
193 | let port: string = "";
194 | data.split(/[\n|\r]/).forEach((item) => {
195 | if (item.indexOf("LISTEN") !== -1 && !port) {
196 | let reg = item.split(/\s+/);
197 | if (/\d+/.test(reg[1])) {
198 | port = reg[1];
199 | }
200 | }
201 | });
202 | return port;
203 | };
204 |
205 | export const empty = function (code: string) {
206 | let stream = through.obj((file: any, encoding: any, callback: Function) => {
207 | if (!file.isBuffer()) {
208 | return callback();
209 | }
210 | file.contents = Buffer.from(code || "");
211 | stream.push(file);
212 | callback();
213 | });
214 | return stream;
215 | };
216 |
217 | export const complieFile = (uri: string) => {
218 | readFileName({ fileName: uri });
219 | };
220 |
221 | export const complieDir = (uri: string) => {
222 | const files = fs.readdirSync(uri);
223 | files.forEach((filename) => {
224 | const fileUrl = path.join(uri, filename);
225 | const fileStats = fs.statSync(fileUrl);
226 | if (fileStats.isDirectory()) {
227 | complieDir(fileUrl);
228 | } else {
229 | complieFile(fileUrl);
230 | }
231 | });
232 | };
233 |
234 | // 获取当前选中的文本
235 | export const getSelectedText = () => {
236 | const documentText = vscode.window.activeTextEditor?.document.getText();
237 | if (!documentText) {
238 | return "";
239 | }
240 | const activeSelection = vscode.window.activeTextEditor?.selection;
241 | if (activeSelection?.isEmpty) {
242 | return "";
243 | }
244 | const selectStartOffset = vscode.window.activeTextEditor?.document.offsetAt(
245 | activeSelection?.start as vscode.Position
246 | );
247 | const selectEndOffset = vscode.window.activeTextEditor?.document.offsetAt(
248 | activeSelection?.end as vscode.Position
249 | );
250 |
251 | let selectedText = documentText.slice(selectStartOffset, selectEndOffset).trim();
252 | selectedText = selectedText.replace(/\s\s+/g, " ");
253 | return selectedText;
254 | }
255 |
256 | // 获取工作区位置
257 | export const getWorkspaceRoot = (doc: vscode.TextDocument) => {
258 | if (!vscode.workspace.workspaceFolders || vscode.workspace.workspaceFolders.length === 0) return;
259 | if (!doc || doc.isUntitled) return vscode.workspace.workspaceFolders[0].uri.fsPath;
260 |
261 | const folder = vscode.workspace.getWorkspaceFolder(doc.uri);
262 | if (!folder) return;
263 | return folder.uri.fsPath;
264 | };
265 |
266 | export const readFileName = async ({ fileName, selectedText }: { fileName: string; selectedText?: string }) => {
267 | let workspaceRootPath = vscode.workspace.rootPath;
268 | let fileSuffix: FileSuffix = fileType(fileName);
269 | let config = vscode.workspace.getConfiguration("compile-hero");
270 | let outputDirectoryPath: OutputDirectoryPath = {
271 | [LANGUAGE_SUFFIX.JAVASCRIPT]: config.get("javascript-output-directory") || "",
272 | [LANGUAGE_SUFFIX.SCSS]: config.get("scss-output-directory") || "",
273 | [LANGUAGE_SUFFIX.SASS]: config.get("sass-output-directory") || "",
274 | [LANGUAGE_SUFFIX.LESS]: config.get("less-output-directory") || "",
275 | [LANGUAGE_SUFFIX.JADE]: config.get("jade-output-directory") || "",
276 | [LANGUAGE_SUFFIX.TYPESCRIPT]: config.get("typescript-output-directory") || "",
277 | [LANGUAGE_SUFFIX.TYPESCRIPTX]: config.get("typescriptx-output-directory") || "",
278 | [LANGUAGE_SUFFIX.PUG]: config.get("pug-output-directory") || "",
279 | [LANGUAGE_SUFFIX.STYLUS]: config.get("stylus-output-directory") || "",
280 | };
281 | let compileStatus: CompileStatus = {
282 | [LANGUAGE_SUFFIX.JAVASCRIPT]: config.get("javascript-output-toggle"),
283 | [LANGUAGE_SUFFIX.SCSS]: config.get("scss-output-toggle"),
284 | [LANGUAGE_SUFFIX.SASS]: config.get("sass-output-toggle"),
285 | [LANGUAGE_SUFFIX.LESS]: config.get("less-output-toggle"),
286 | [LANGUAGE_SUFFIX.JADE]: config.get("jade-output-toggle"),
287 | [LANGUAGE_SUFFIX.TYPESCRIPT]: config.get("typescript-output-toggle"),
288 | [LANGUAGE_SUFFIX.TYPESCRIPTX]: config.get("typescriptx-output-toggle"),
289 | [LANGUAGE_SUFFIX.PUG]: config.get("pug-output-toggle"),
290 | [LANGUAGE_SUFFIX.STYLUS]: config.get("stylus-output-toggle"),
291 | };
292 | let ignore = config.get("ignore") || [];
293 | let watch = config.get("watch") || [];
294 |
295 | if (workspaceRootPath && fileName.startsWith(workspaceRootPath)) {
296 | let relativePath = path.relative(workspaceRootPath, fileName);
297 | if (!Array.isArray(ignore)) { ignore = [ignore] };
298 | if (ignore.some(glob => minimatch(relativePath, glob))) return;
299 |
300 | // 如果设置了 watch,则监听保存的文件路径是否符合,如果不设置,则所有文件都会被监听
301 | if (!Array.isArray(watch)) { watch = [watch] };
302 | if (watch.length > 0 && !watch.some(glob => minimatch(relativePath, glob))) return;
303 | };
304 |
305 | let notificationStatus: boolean | undefined = config.get("notification-toggle");
306 |
307 | let compileOptions: CompileOptions = {
308 | generateMinifiedHtml: config.get("generate-minified-html"),
309 | generateMinifiedHtmlOnly: config.get("generate-minified-html-only"),
310 | generateMinifiedCss: config.get("generate-minified-css"),
311 | generateMinifiedCssOnly: config.get("generate-minified-css-only"),
312 | generateMinifiedJs: config.get("generate-minified-javascript"),
313 | generateMinifiedJsOnly: config.get("generate-minified-javascript-only"),
314 | };
315 |
316 | if (!compileStatus[fileSuffix]) return;
317 | let outputPath = path.resolve(fileName, "../", outputDirectoryPath[fileSuffix]);
318 | let loaderOption: loaderOption = { fileName, outputPath, notificationStatus, compileOptions, selectedText };
319 | switch (fileSuffix) {
320 | case LANGUAGE_SUFFIX.SCSS:
321 | case LANGUAGE_SUFFIX.SASS:
322 | sassLoader(loaderOption);
323 | break;
324 | case LANGUAGE_SUFFIX.JAVASCRIPT:
325 | javascriptLoader(loaderOption);
326 | break;
327 | case LANGUAGE_SUFFIX.LESS:
328 | lessLoader(loaderOption);
329 | break;
330 | case LANGUAGE_SUFFIX.TYPESCRIPT:
331 | typescriptLoader(loaderOption);
332 | break;
333 | case LANGUAGE_SUFFIX.TYPESCRIPTX:
334 | typescriptxLoader(loaderOption);
335 | break;
336 | case LANGUAGE_SUFFIX.JADE:
337 | case LANGUAGE_SUFFIX.PUG:
338 | pugLoader(loaderOption);
339 | break;
340 | case LANGUAGE_SUFFIX.STYLUS:
341 | stylusLoader(loaderOption);
342 | break;
343 | }
344 | };
345 |
346 | export function veriableCheck(uri: string, fileSuffix: string, workspaceRootPath: string) {
347 | let veriableError: string;
348 |
349 | if ((uri.indexOf("}/") < 0) &&
350 | ((uri.length - uri.indexOf("}")) > 1) &&
351 | (uri.indexOf("$") >= 0)) {
352 | veriableError = fileSuffix +
353 | "; '/' must be used at the end of the variable or '}' must be the last character.";
354 | vscode.window.showErrorMessage(veriableError);
355 | return false;
356 | } else if (uri.indexOf("${workspaceFolder}") >= 0) {
357 | uri = uri.replace("${workspaceFolder}", String(workspaceRootPath));
358 | } else if (uri.indexOf("${folderPath}") >= 0) {
359 | uri = uri.replace("${folderPath}", String(workspaceRootPath));
360 | } else if (uri.indexOf("$") >= 0) {
361 | let findStartNumber: number = uri.indexOf("$");
362 | let findEndNumber: number;
363 | if (uri.indexOf("}") < 0) {
364 | if (uri.indexOf("/") < 0) {
365 | findEndNumber = uri.length;
366 | } else {
367 | findEndNumber = uri.indexOf("/");
368 | }
369 | } else {
370 | findEndNumber = uri.indexOf("}");
371 | }
372 | findEndNumber++;
373 | veriableError = fileSuffix + "; Output directory unsupported variable: " +
374 | uri.slice(findStartNumber, findEndNumber);
375 | vscode.window.showErrorMessage(veriableError);
376 | return false;
377 | }
378 | return uri;
379 | };
--------------------------------------------------------------------------------
/out/beautifyrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "JSON schema for beautifyrc",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "type": "object",
5 | "definitions": {
6 | "CHJProperties": {
7 | "type": "object",
8 | "properties": {
9 | "indent_size": {
10 | "description": "Indent size. [JS,CSS,HTML]",
11 | "type": "integer",
12 | "default": 4
13 | },
14 | "indent_char": {
15 | "description": "Indentation character. [JS,CSS,HTML]",
16 | "type": "string",
17 | "default": " ",
18 | "maxLength": 1
19 | },
20 | "eol": {
21 | "description": "Character(s) to use as line terminators. [JS,CSS,HTML]",
22 | "type": "string",
23 | "default": "\n"
24 | },
25 | "indent_with_tabs": {
26 | "description": "Indent with tabs, overrides 'indent_size' and 'indent_char' [JS,CSS,HTML]",
27 | "type": "boolean",
28 | "default": false
29 | },
30 | "end_with_newline": {
31 | "description": "Ensure newline at end of file. [JS,CSS,HTML]",
32 | "type": "boolean",
33 | "default": false
34 | },
35 | "preserve_newlines": {
36 | "description": "Preserve line-breaks. [JS,CSS,HTML]",
37 | "type": "boolean",
38 | "default": true
39 | }
40 | }
41 | },
42 | "HJProperties": {
43 | "type": "object",
44 | "properties": {
45 | "max_preserve_newlines": {
46 | "description": "Number of line-breaks to be preserved in one chunk. [JS,HTML]",
47 | "type": "integer",
48 | "default": 10
49 | },
50 | "wrap_line_length": {
51 | "description": "Wrap lines at next opportunity after N characters. [JS,HTML]",
52 | "type": "integer",
53 | "default": 0
54 | }
55 | }
56 | },
57 | "CProperties": {
58 | "type": "object",
59 | "properties": {
60 | "selector_separator_newline": {
61 | "description": "Add a newline between multiple selectors. [CSS]",
62 | "type": "boolean",
63 | "default": true
64 | },
65 | "newline_between_rules": {
66 | "description": "Add a newline between CSS rules. [CSS]",
67 | "type": "boolean",
68 | "default": false
69 | },
70 | "space_around_selector_separator": {
71 | "description": "(Deprecated: use space_around_combinator) [CSS]",
72 | "type": "boolean",
73 | "default": false
74 | },
75 | "space_around_combinator": {
76 | "description": "Ensure space around selector separators (>+~). [CSS]",
77 | "type": "boolean",
78 | "default": false
79 | }
80 | }
81 | },
82 | "HProperties": {
83 | "type": "object",
84 | "properties": {
85 | "void_elements": {
86 | "description": "HTLM void elements - aka self-closing tags. [HTML]",
87 | "type": "array",
88 | "items": {
89 | "type": "string"
90 | },
91 | "default": [
92 | "area",
93 | "base",
94 | "br",
95 | "col",
96 | "embed",
97 | "hr",
98 | "img",
99 | "input",
100 | "keygen",
101 | "link",
102 | "menuitem",
103 | "meta",
104 | "param",
105 | "source",
106 | "track",
107 | "wbr",
108 | "!doctype",
109 | "?xml",
110 | "?php",
111 | "?=",
112 | "basefont",
113 | "isindex"
114 | ]
115 | },
116 | "inline": {
117 | "description": "",
118 | "type": "array",
119 | "items": {
120 | "type": "string"
121 | },
122 | "default": [
123 | "a",
124 | "abbr",
125 | "area",
126 | "audio",
127 | "b",
128 | "bdi",
129 | "bdo",
130 | "br",
131 | "button",
132 | "canvas",
133 | "cite",
134 | "code",
135 | "data",
136 | "datalist",
137 | "del",
138 | "dfn",
139 | "em",
140 | "embed",
141 | "i",
142 | "iframe",
143 | "img",
144 | "input",
145 | "ins",
146 | "kbd",
147 | "keygen",
148 | "label",
149 | "map",
150 | "mark",
151 | "math",
152 | "meter",
153 | "noscript",
154 | "object",
155 | "output",
156 | "progress",
157 | "q",
158 | "ruby",
159 | "s",
160 | "samp",
161 | "select",
162 | "small",
163 | "span",
164 | "strong",
165 | "sub",
166 | "sup",
167 | "svg",
168 | "template",
169 | "textarea",
170 | "time",
171 | "u",
172 | "var",
173 | "video",
174 | "wbr",
175 | "text",
176 | "acronym",
177 | "address",
178 | "big",
179 | "dt",
180 | "ins",
181 | "strike",
182 | "tt"
183 | ]
184 | },
185 | "wrap_attributes": {
186 | "description": "Wrap attributes to new lines. [HTML]",
187 | "type": "string",
188 | "default": "auto",
189 | "enum": [
190 | "auto",
191 | "force",
192 | "force-aligned",
193 | "force-expand-multiline",
194 | "align-multiple",
195 | "preserve",
196 | "preserve-aligned"
197 | ]
198 | },
199 | "wrap_attributes_indent_size": {
200 | "description": "Indent wrapped attributes to after N characters. Defaults to 'indent_size'. [HTML]",
201 | "type": "number"
202 | },
203 | "indent_inner_html": {
204 | "description": "Indent and sections. [HTML]",
205 | "type": "boolean",
206 | "default": false
207 | },
208 | "indent_scripts": {
209 | "description": "[keep|separate|normal] [HTML]",
210 | "type": "string",
211 | "default": "normal",
212 | "enum": [
213 | "keep",
214 | "separate",
215 | "normal"
216 | ]
217 | },
218 | "unformatted": {
219 | "description": "List of tags that should not be reformatted. [HTML]",
220 | "type": "array",
221 | "items": {
222 | "type": "string"
223 | },
224 | "default": []
225 | },
226 | "content_unformatted": {
227 | "description": "List of tags whose content should not be reformatted. [HTML]",
228 | "type": "array",
229 | "items": {
230 | "type": "string"
231 | },
232 | "default": [
233 | "pre",
234 | "textarea"
235 | ]
236 | },
237 | "extra_liners": {
238 | "description": "List of tags that should have an extra newline before them. [HTML]",
239 | "type": "array",
240 | "items": {
241 | "type": "string"
242 | },
243 | "default": [
244 | "head",
245 | "body",
246 | "/html"
247 | ]
248 | },
249 | "indent_body_inner_html": {
250 | "description": "Indent elements within html element. [HTML]",
251 | "type": "boolean",
252 | "default": true
253 | },
254 | "indent_head_inner_html": {
255 | "description": "Indent elements within html element. [HTML]",
256 | "type": "boolean",
257 | "default": true
258 | },
259 | "indent_handlebars": {
260 | "description": "format and indent {{#foo}} and {{/foo}}. [HTML]",
261 | "type": "boolean",
262 | "default": false
263 | }
264 | }
265 | },
266 | "JProperties": {
267 | "type": "object",
268 | "properties": {
269 | "brace_style": {
270 | "description": "[collapse|expand|end-expand|none][,preserve-inline] [JS]",
271 | "type": "string",
272 | "default": "collapse",
273 | "enum": [
274 | "collapse",
275 | "expand",
276 | "end-expand",
277 | "none",
278 | "collapse,preserve-inline",
279 | "expand,preserve-inline",
280 | "end-expand,preserve-inline",
281 | "none,preserve-inline"
282 | ]
283 | },
284 | "indent_level": {
285 | "description": "Initial indentation level. [JS]",
286 | "type": "integer",
287 | "default": 0
288 | },
289 | "space_in_paren": {
290 | "description": "Add padding spaces within parentheses, ie. f( a, b ). [JS]",
291 | "type": "boolean",
292 | "default": false
293 | },
294 | "space_in_empty_paren": {
295 | "description": "Leave space in empty parentheses, ie. f( ). [JS]",
296 | "type": "boolean",
297 | "default": false
298 | },
299 | "jslint_happy": {
300 | "description": "Enable jslint-stricter mode. (Forces 'space_after_anon_function') [JS]",
301 | "type": "boolean",
302 | "default": false
303 | },
304 | "space_after_anon_function": {
305 | "description": "Add a space before an anonymous function's parens, ie. function (). [JS]",
306 | "type": "boolean",
307 | "default": false
308 | },
309 | "space_after_named_function": {
310 | "description": "Add a space before a named function's parens, ie. function example (). [JS]",
311 | "type": "boolean",
312 | "default": false
313 | },
314 | "break_chained_methods": {
315 | "description": "Break chained method calls across subsequent lines. [JS]",
316 | "type": "boolean",
317 | "default": false
318 | },
319 | "keep_array_indentation": {
320 | "description": "Preserve array indentation. [JS]",
321 | "type": "boolean",
322 | "default": false
323 | },
324 | "keep_function_indentation": {
325 | "description": "Preserve function indentation. [JS]",
326 | "type": "boolean",
327 | "default": false
328 | },
329 | "space_before_conditional": {
330 | "description": "Ensure a space before conditional statement. [JS]",
331 | "type": "boolean",
332 | "default": true
333 | },
334 | "unescape_strings": {
335 | "description": "Decode printable characters encoded in xNN notation. [JS]",
336 | "type": "boolean",
337 | "default": false
338 | },
339 | "comma_first": {
340 | "description": "Put commas at the beginning of new line instead of end. [JS]",
341 | "type": "boolean",
342 | "default": false
343 | },
344 | "operator_position": {
345 | "description": "Move operators to before or after a new line, or keep as is. [JS]",
346 | "type": "string",
347 | "enum": [
348 | "before-newline",
349 | "after-newline",
350 | "preserve-newline"
351 | ],
352 | "default": "before-newline"
353 | },
354 | "e4x": {
355 | "description": "Pass E4X xml literals through untouched. [JS]",
356 | "type": "boolean",
357 | "default": false
358 | },
359 | "unindent_chained_methods": {
360 | "description": "Unindent chained methods. [JS]",
361 | "type": "boolean",
362 | "default": false
363 | }
364 | }
365 | }
366 | },
367 | "allOf": [
368 | {
369 | "$ref": "#/definitions/CHJProperties"
370 | },
371 | {
372 | "$ref": "#/definitions/HJProperties"
373 | },
374 | {
375 | "$ref": "#/definitions/CProperties"
376 | },
377 | {
378 | "$ref": "#/definitions/HProperties"
379 | },
380 | {
381 | "$ref": "#/definitions/JProperties"
382 | },
383 | {
384 | "properties": {
385 | "css": {
386 | "type": "object",
387 | "allOf": [
388 | {
389 | "$ref": "#/definitions/CHJProperties"
390 | },
391 | {
392 | "$ref": "#/definitions/CProperties"
393 | }
394 | ]
395 | },
396 | "js": {
397 | "type": "object",
398 | "allOf": [
399 | {
400 | "$ref": "#/definitions/CHJProperties"
401 | },
402 | {
403 | "$ref": "#/definitions/HJProperties"
404 | },
405 | {
406 | "$ref": "#/definitions/JProperties"
407 | }
408 | ]
409 | },
410 | "html": {
411 | "type": "object",
412 | "allOf": [
413 | {
414 | "$ref": "#/definitions/CHJProperties"
415 | },
416 | {
417 | "$ref": "#/definitions/HJProperties"
418 | },
419 | {
420 | "$ref": "#/definitions/HProperties"
421 | }
422 | ]
423 | }
424 | }
425 | }
426 | ]
427 | }
--------------------------------------------------------------------------------