From ec909bdd0c0e2d70229ba26cbcfa168696ae70b2 Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 23 Jan 2019 17:44:57 -0600 Subject: [PATCH] Files open now --- packages/vscode/package.json | 1 + packages/vscode/src/fill/iconv-lite.ts | 65 +++++++++++++++++++++ packages/vscode/webpack.config.bootstrap.js | 20 ++----- packages/vscode/yarn.lock | 12 ++++ packages/web/webpack.common.config.js | 7 ++- 5 files changed, 86 insertions(+), 19 deletions(-) create mode 100644 packages/vscode/src/fill/iconv-lite.ts diff --git a/packages/vscode/package.json b/packages/vscode/package.json index ef193d73..bdbfe646 100644 --- a/packages/vscode/package.json +++ b/packages/vscode/package.json @@ -6,6 +6,7 @@ "build:bootstrap-fork": "../../node_modules/.bin/webpack --config ./webpack.config.bootstrap.js" }, "dependencies": { + "iconv-lite": "^0.4.24", "spdlog": "^0.7.2", "string-replace-loader": "^2.1.1" } diff --git a/packages/vscode/src/fill/iconv-lite.ts b/packages/vscode/src/fill/iconv-lite.ts new file mode 100644 index 00000000..9683b972 --- /dev/null +++ b/packages/vscode/src/fill/iconv-lite.ts @@ -0,0 +1,65 @@ +import * as iconv from "../../node_modules/iconv-lite"; +import { Transform, TransformCallback } from "stream"; + +class IconvLiteDecoderStream extends Transform { + + // tslint:disable-next-line no-any + private conv: any; + private encoding: string; + + public constructor(options: { encoding: string }) { + super(options); + // tslint:disable-next-line no-any + this.conv = (iconv as any).getDecoder(options.encoding, undefined); + options.encoding = this.encoding = "utf8"; + } + + // tslint:disable-next-line no-any + public _transform(chunk: any, _encoding: string, done: TransformCallback): void { + if (!Buffer.isBuffer(chunk)) { + return done(new Error("Iconv decoding stream needs buffers as its input.")); + } + try { + const res = this.conv.write(chunk); + if (res && res.length) { + this.push(res, this.encoding); + } + done(); + } catch (error) { + done(error); + } + } + + public _flush(done: TransformCallback): void { + try { + const res = this.conv.end(); + if (res && res.length) { + this.push(res, this.encoding); + } + done(); + } catch (error) { + done(error); + } + } + + // tslint:disable-next-line no-any + public collect(cb: (error: Error | null, response?: any) => void): this { + let res = ""; + this.on("error", cb); + this.on("data", (chunk) => res += chunk); + this.on("end", () => { + cb(null, res); + }); + + return this; + } +} + +const decodeStream = (encoding: string): NodeJS.ReadWriteStream => { + return new IconvLiteDecoderStream({ encoding }); +}; + +// @ts-ignore +iconv.decodeStream = decodeStream; + +export = iconv; diff --git a/packages/vscode/webpack.config.bootstrap.js b/packages/vscode/webpack.config.bootstrap.js index 1c0ad9c9..304e9c38 100644 --- a/packages/vscode/webpack.config.bootstrap.js +++ b/packages/vscode/webpack.config.bootstrap.js @@ -1,15 +1,14 @@ const path = require("path"); const webpack = require("webpack"); -const root = path.resolve(__dirname, "..", ".."); -const fills = path.join(root, "packages", "ide", "src", "fill"); -const vscodeFills = path.join(root, "packages", "vscode", "src", "fill"); +const root = path.resolve(__dirname, "../.."); +const fills = path.join(root, "packages/ide/src/fill"); +const vscodeFills = path.join(root, "packages/vscode/src/fill"); const merge = require("webpack-merge"); module.exports = (env) => { - const afterCompileCommand = env && env.afterCompileCommand; - return merge(require(path.join(root, "scripts", "webpack.general.config.js"))({ + return merge(require(path.join(root, "scripts/webpack.general.config.js"))({ typescriptCompilerOptions: { target: "es5", }, @@ -77,16 +76,5 @@ module.exports = (env) => { "vs/css": path.resolve(vscodeFills, "css.js"), }, }, - plugins: [ - new webpack.ProgressPlugin((percentage, msg) => { - if (percentage === 1) { - if (afterCompileCommand) { - require("child_process").execSync(afterCompileCommand, { - stdio: "inherit" - }); - } - } - }), - ], }); }; diff --git a/packages/vscode/yarn.lock b/packages/vscode/yarn.lock index afdcc85d..8ff7ecc7 100644 --- a/packages/vscode/yarn.lock +++ b/packages/vscode/yarn.lock @@ -42,6 +42,13 @@ fast-json-stable-stringify@^2.0.0: resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" integrity sha1-1RQsDK7msRifh9OnYREGT4bIu/I= +iconv-lite@^0.4.24: + version "0.4.24" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" + integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== + dependencies: + safer-buffer ">= 2.1.2 < 3" + json-schema-traverse@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" @@ -90,6 +97,11 @@ punycode@^2.1.0: resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== +"safer-buffer@>= 2.1.2 < 3": + version "2.1.2" + resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" + integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== + schema-utils@^0.4.5: version "0.4.7" resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-0.4.7.tgz#ba74f597d2be2ea880131746ee17d0a093c68187" diff --git a/packages/web/webpack.common.config.js b/packages/web/webpack.common.config.js index 420c155d..c93dbbcf 100644 --- a/packages/web/webpack.common.config.js +++ b/packages/web/webpack.common.config.js @@ -2,9 +2,9 @@ const path = require("path"); const HtmlWebpackPlugin = require("html-webpack-plugin"); const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer"); const PreloadWebpackPlugin = require("preload-webpack-plugin"); -const root = path.resolve(__dirname, "..", ".."); -const fills = path.join(root, "packages", "ide", "src", "fill"); -const vsFills = path.join(root, "packages", "vscode", "src", "fill"); +const root = path.resolve(__dirname, "../.."); +const fills = path.join(root, "packages/ide/src/fill"); +const vsFills = path.join(root, "packages/vscode/src/fill"); const merge = require("webpack-merge"); @@ -74,6 +74,7 @@ module.exports = merge({ "node-pty": path.join(vsFills, "node-pty.ts"), "graceful-fs": path.join(vsFills, "graceful-fs.ts"), "spdlog": path.join(vsFills, "spdlog.ts"), + "iconv-lite": path.join(vsFills, "iconv-lite.ts"), "vs/base/node/paths": path.join(vsFills, "paths.ts"), "vs/base/common/amd": path.join(vsFills, "amd.ts"),