-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fee067a
commit 465b5c9
Showing
14 changed files
with
697 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,4 @@ | ||
# Logs | ||
logs | ||
.vscode | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
|
||
# Next.js build output | ||
.next | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and *not* Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
build | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Google Closure Compiler Desktop | ||
|
||
## 介绍 | ||
|
||
**Google Closure Compiler 桌面应用** | ||
|
||
### Google Closure Compiler是什么? | ||
|
||
> The Closure Compiler is a tool for making JavaScript download and run faster. Instead of compiling from a source language to machine code, it compiles from JavaScript to better JavaScript. It parses your JavaScript, analyzes it, removes dead code and rewrites and minimizes what's left. It also checks syntax, variable references, and types, and warns about common JavaScript pitfalls. | ||
> Closure Compiler是由Google所发展的一套JavaScript编译器,可以编译JavaScript,产生最佳化(最小化)JavaScript代码。Closure Tools是由Google所发展的一套网页应用程序工具组,可以帮助网页开发者快速发展大型的网页应用程序。Closure Compiler是Closure Tools的其中一项工具,它可以编译JavaScript的代码,经过最佳化处理后,产生高效能且最小化的JavaScript,让网页的加载速度与执行性能都可以提高。除了最佳化之外,Closure Compiler也会检查程序的语法,找出所有可能出问题的地方,协助程序设计者改善程序的质量,降低bugs的发生率。 | ||
> _更多详细文档和帮助请访问Google官方文档 https://developers.google.com/closure/compiler_ | ||
|
||
## 软件架构 | ||
软件架构说明 | ||
win32 x64 | ||
|
||
## 安装教程 | ||
|
||
1. 打开Google Closure Compiler Desktop Setup.exe | ||
2. 一直点击下一步,安装程序 | ||
3. 从桌面打开程序 | ||
|
||
## 程序截图 | ||
|
||
![aIoVsS.png](https://images.gitee.com/uploads/images/2020/0808/213934_9269214c_1440556.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"> | ||
<style> | ||
#input-code, | ||
#output-code { | ||
width: 100%; | ||
height: 250px; | ||
} | ||
|
||
#output-wrapper { | ||
width: 100%; | ||
height: 75px; | ||
} | ||
|
||
label { | ||
margin-left: 5px; | ||
} | ||
|
||
.footer { | ||
position: fixed; | ||
left: 0; | ||
bottom: 0; | ||
width: 100%; | ||
color: gray; | ||
text-align: center; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div class="container"> | ||
<h2>Google Closure Compiler Desktop</h2> | ||
<form role="form" onsubmit="return false"> | ||
<div class="form-group"> | ||
<div class="row"> | ||
<div class="col-xs-6 col-md-6"> | ||
<label for="input-code">Input Code(输入代码)</label> | ||
<textarea class="form-control" id="input-code" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea> | ||
</div> | ||
<div class="col-xs-6 col-md-6"> | ||
<label for="output-code">Output Code(输出代码)</label> | ||
<textarea class="form-control" id="output-code" placeholder='alert("Hello, New user");' autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<div class="row"> | ||
<div class="col-xs-6"> | ||
<label for="compilation-level">Compilation Level(处理等级)</label> | ||
<select id="compilation-level" class="form-control"> | ||
<option value="SIMPLE" selected>SIMPLE</option> | ||
<option value="BUNDLE">BUNDLE</option> | ||
<option value="WHITESPACE_ONLY">WHITESPACE_ONLY</option> | ||
<option value="ADVANCED">ADVANCED</option> | ||
</select> | ||
</div> | ||
<div class="col-xs-6"> | ||
<label for="warning-level">Warning Level(提示等级)</label> | ||
<select id="warning-level" class="form-control"> | ||
<option value="QUIET" selected>QUIET</option> | ||
<option value="DEFAULT">DEFAULT</option> | ||
<option value="VERBOSE">VERBOSE</option> | ||
</select> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<div class="row"> | ||
<div class="col-xs-6"> | ||
<label for="language-in">Language In(输入语言)</label> | ||
<select id="language-in" class="form-control"> | ||
<option value="ECMASCRIPT3">ECMASCRIPT3</option> | ||
<option value="ECMASCRIPT5" selected>ECMASCRIPT5</option> | ||
<option value="ECMASCRIPT5_STRICT">ECMASCRIPT5_STRICT</option> | ||
<option value="ECMASCRIPT6_TYPED">ECMASCRIPT6_TYPED(实验性)</option> | ||
<option value="ECMASCRIPT_2015">ECMASCRIPT_2015</option> | ||
<option value="ECMASCRIPT_2016">ECMASCRIPT_2016</option> | ||
<option value="ECMASCRIPT_2017">ECMASCRIPT_2017</option> | ||
<option value="ECMASCRIPT_2018">ECMASCRIPT_2018</option> | ||
<option value="ECMASCRIPT_2019">ECMASCRIPT_2019</option> | ||
<option value="ECMASCRIPT_2019">STABLE</option> | ||
<option value="ECMASCRIPT_NEXT">ECMASCRIPT_NEXT</option> | ||
</select> | ||
</div> | ||
<div class="col-xs-6"> | ||
<label for="language-out">Language Out(输出语言)</label> | ||
<select id="language-out" class="form-control"> | ||
<option value="ECMASCRIPT3">ECMASCRIPT3</option> | ||
<option value="ECMASCRIPT5" selected>ECMASCRIPT5</option> | ||
<option value="ECMASCRIPT5_STRICT">ECMASCRIPT5_STRICT</option> | ||
<option value="ECMASCRIPT_2015">ECMASCRIPT_2015</option> | ||
<option value="ECMASCRIPT_2016">ECMASCRIPT_2016</option> | ||
<option value="ECMASCRIPT_2017">ECMASCRIPT_2017</option> | ||
<option value="ECMASCRIPT_2018">ECMASCRIPT_2018</option> | ||
<option value="ECMASCRIPT_2019">ECMASCRIPT_2019</option> | ||
<option value="ECMASCRIPT_2019">STABLE</option> | ||
</select> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label for="output-wrapper">Output Wrapper(输出包裹)</label> | ||
<textarea class="form-control" id="output-wrapper" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea> | ||
</div> | ||
<div class="form-group"> | ||
<button type="submit" id="submit-compiler" class="btn btn-default">Start Compiler(开始编译)</button> | ||
</div> | ||
</form> | ||
<footer class="footer"> | ||
<p>2020 © 强某人<2962051004@qq.com></p> | ||
</footer> | ||
</div> | ||
|
||
<!-- You can also require other files to run in this process --> | ||
<script> | ||
window.nodeRequire = require; | ||
delete window.require; | ||
delete window.exports; | ||
delete window.module; | ||
</script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script> | ||
<script src="./renderer.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const jsCompiler = require("./index"); | ||
|
||
process.on("message", ({ src, opt }) => { | ||
ClosureCompiler(src, opt).then((result) => { | ||
process.send({ result }); | ||
}).catch((err) => { | ||
process.send({ err }); | ||
}) | ||
}) | ||
|
||
function ClosureCompiler(src, opt) { | ||
return new Promise((resolve, reject) => { | ||
|
||
let _compiler = new jsCompiler(opt); | ||
_compiler.run([{ src }], (exitCode, stdOut, stdErr) => { | ||
_compiler = null; | ||
if (stdErr) { | ||
reject(stdErr); | ||
return; | ||
} | ||
//compilation complete | ||
resolve(stdOut[0].src); | ||
}); | ||
}); | ||
} | ||
|
||
process.on("uncaughtException", console.log) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright 2018 The Closure Compiler Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* @fileoverview Low level class for calling the closure-compiler-js lib | ||
* | ||
* @author Chad Killingsworth ([email protected]) | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// const path = require('path'); | ||
// const contribPath = path.resolve(__dirname, 'contrib'); | ||
const jscomp = require('google-closure-compiler-js'); | ||
const CONSOLE_COLOR_CHARS = /\u001B\[\d+m/ug; | ||
|
||
class CompilerJS { | ||
/** @param {Object<string,string>|Array<string>} flags */ | ||
constructor(flags) { | ||
this.flags = {}; | ||
if (Array.isArray(flags)) { | ||
flags.forEach(flag => { | ||
const flagPargs = flag.split('='); | ||
const normalizedFlag = this.formatArgument(flagPargs[0], flagPargs[1]); | ||
this.flags[normalizedFlag.key] = normalizedFlag.val; | ||
}); | ||
} else { | ||
for (let key in flags) { | ||
const normalizedFlag = this.formatArgument(key, flags[key]); | ||
this.flags[normalizedFlag.key] = normalizedFlag.val; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @param {!Array<!{src: string, path: string, sourceMap: string}>} fileList | ||
* @param {function(number, Array<{src: string, path: string, sourceMap: (string|undefined)}>, string)=} callback | ||
* @return {child_process.ChildProcess} | ||
*/ | ||
run(fileList, callback) { | ||
const out = jscomp(this.flags, fileList); | ||
// GWT error and warnings are not true JS arrays, but are array-like. | ||
// Convert them to standard JS arrays. | ||
out.warnings = [].slice.call(out.warnings); | ||
out.errors = [].slice.call(out.errors); | ||
if (callback) { | ||
const errors = []; | ||
const logErrors = require('./logger'); | ||
logErrors(out, fileList, logOutput => { | ||
// The logger uses terminal color markers which we don't want by default. | ||
errors.push(logOutput.replace(CONSOLE_COLOR_CHARS, '')); | ||
}); | ||
callback(errors.length === 0 ? 0 : 1, out.compiledFiles, errors.join('\n\n')); | ||
} | ||
return out; | ||
} | ||
|
||
/** | ||
* @param {string} key | ||
* @param {(string|boolean)=} val | ||
* @return {{key: string, val: (string|undefined)}} | ||
*/ | ||
formatArgument(key, val) { | ||
let normalizedKey = key.replace(/_(\w)/g, match => match[1].toUpperCase()); | ||
normalizedKey = normalizedKey.replace(/^--/, ''); | ||
|
||
return { | ||
key: normalizedKey, | ||
val: val === undefined || val === null ? true : val | ||
}; | ||
} | ||
} | ||
|
||
/** @type {string} */ | ||
// CompilerJS.CONTRIB_PATH = contribPath; | ||
|
||
module.exports = CompilerJS; |
Oops, something went wrong.