added vscode extensions
This commit is contained in:
parent
7cde0829be
commit
26e2a50441
316 changed files with 37301 additions and 0 deletions
88
.vscode/extensions/wix.vscode-import-cost-2.15.0/out/decorator.js
vendored
Normal file
88
.vscode/extensions/wix.vscode-import-cost-2.15.0/out/decorator.js
vendored
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.clearDecorations = exports.calculated = exports.flushDecorations = void 0;
|
||||
const vscode_1 = require("vscode");
|
||||
const fileSize = require("filesize");
|
||||
const logger_1 = require("./logger");
|
||||
const decorations = {};
|
||||
function flushDecorations(fileName, packages) {
|
||||
logger_1.default.log(`Flushing decorations ${JSON.stringify(packages, null, 2)}`);
|
||||
decorations[fileName] = {};
|
||||
packages.forEach(packageInfo => {
|
||||
if (packageInfo.size === undefined) {
|
||||
const configuration = vscode_1.workspace.getConfiguration('importCost');
|
||||
if (configuration.showCalculatingDecoration) {
|
||||
decorate('Calculating...', packageInfo);
|
||||
}
|
||||
}
|
||||
else {
|
||||
calculated(packageInfo);
|
||||
}
|
||||
});
|
||||
refreshDecorations(fileName);
|
||||
}
|
||||
exports.flushDecorations = flushDecorations;
|
||||
function calculated(packageInfo) {
|
||||
const decorationMessage = getDecorationMessage(packageInfo);
|
||||
decorate(decorationMessage, packageInfo, getDecorationColor(packageInfo.size));
|
||||
}
|
||||
exports.calculated = calculated;
|
||||
function getDecorationMessage(packageInfo) {
|
||||
if (packageInfo.size <= 0) {
|
||||
return '';
|
||||
}
|
||||
let decorationMessage;
|
||||
const configuration = vscode_1.workspace.getConfiguration('importCost');
|
||||
const size = fileSize(packageInfo.size, { unix: true });
|
||||
const gzip = fileSize(packageInfo.gzip, { unix: true });
|
||||
if (configuration.bundleSizeDecoration === 'both') {
|
||||
decorationMessage = `${size} (gzipped: ${gzip})`;
|
||||
}
|
||||
else if (configuration.bundleSizeDecoration === 'minified') {
|
||||
decorationMessage = size;
|
||||
}
|
||||
else if (configuration.bundleSizeDecoration === 'gzipped') {
|
||||
decorationMessage = gzip;
|
||||
}
|
||||
return decorationMessage;
|
||||
}
|
||||
function getDecorationColor(size) {
|
||||
const configuration = vscode_1.workspace.getConfiguration('importCost');
|
||||
const sizeInKB = size / 1024;
|
||||
if (sizeInKB < configuration.smallPackageSize) {
|
||||
return configuration.smallPackageColor;
|
||||
}
|
||||
else if (sizeInKB < configuration.mediumPackageSize) {
|
||||
return configuration.mediumPackageColor;
|
||||
}
|
||||
else {
|
||||
return configuration.largePackageColor;
|
||||
}
|
||||
}
|
||||
function decorate(text, packageInfo, color = getDecorationColor(0)) {
|
||||
const { fileName, line } = packageInfo;
|
||||
logger_1.default.log(`Setting Decoration: ${text}, ${JSON.stringify(packageInfo, null, 2)}`);
|
||||
decorations[fileName][line] = {
|
||||
renderOptions: { after: { contentText: text, color } },
|
||||
range: new vscode_1.Range(new vscode_1.Position(line - 1, 1024), new vscode_1.Position(line - 1, 1024))
|
||||
};
|
||||
refreshDecorations(fileName);
|
||||
}
|
||||
const decorationType = vscode_1.window.createTextEditorDecorationType({ after: { margin: '0 0 0 1rem' } });
|
||||
let decorationsDebounce;
|
||||
function refreshDecorations(fileName, delay = 10) {
|
||||
clearTimeout(decorationsDebounce);
|
||||
decorationsDebounce = setTimeout(() => getEditors(fileName).forEach(editor => {
|
||||
editor.setDecorations(decorationType, Object.keys(decorations[fileName]).map(x => decorations[fileName][x]));
|
||||
}), delay);
|
||||
}
|
||||
function getEditors(fileName) {
|
||||
return vscode_1.window.visibleTextEditors.filter(editor => editor.document.fileName === fileName);
|
||||
}
|
||||
function clearDecorations() {
|
||||
vscode_1.window.visibleTextEditors.forEach(textEditor => {
|
||||
return textEditor.setDecorations(decorationType, []);
|
||||
});
|
||||
}
|
||||
exports.clearDecorations = clearDecorations;
|
||||
//# sourceMappingURL=decorator.js.map
|
||||
89
.vscode/extensions/wix.vscode-import-cost-2.15.0/out/extension.js
vendored
Normal file
89
.vscode/extensions/wix.vscode-import-cost-2.15.0/out/extension.js
vendored
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.deactivate = exports.activate = void 0;
|
||||
const import_cost_1 = require("import-cost");
|
||||
const vscode_1 = require("vscode");
|
||||
const decorator_1 = require("./decorator");
|
||||
const logger_1 = require("./logger");
|
||||
let isActive = true;
|
||||
function activate(context) {
|
||||
try {
|
||||
logger_1.default.init(context);
|
||||
logger_1.default.log('starting...');
|
||||
vscode_1.workspace.onDidChangeTextDocument(ev => isActive && processActiveFile(ev.document));
|
||||
vscode_1.window.onDidChangeActiveTextEditor(ev => ev && isActive && processActiveFile(ev.document));
|
||||
if (vscode_1.window.activeTextEditor && isActive) {
|
||||
processActiveFile(vscode_1.window.activeTextEditor.document);
|
||||
}
|
||||
context.subscriptions.push(vscode_1.commands.registerCommand('importCost.toggle', () => {
|
||||
isActive = !isActive;
|
||||
if (isActive && vscode_1.window.activeTextEditor) {
|
||||
processActiveFile(vscode_1.window.activeTextEditor.document);
|
||||
}
|
||||
else {
|
||||
deactivate();
|
||||
decorator_1.clearDecorations();
|
||||
}
|
||||
}));
|
||||
}
|
||||
catch (e) {
|
||||
logger_1.default.log('wrapping error: ' + e);
|
||||
}
|
||||
}
|
||||
exports.activate = activate;
|
||||
function deactivate() {
|
||||
import_cost_1.cleanup();
|
||||
}
|
||||
exports.deactivate = deactivate;
|
||||
let emitters = {};
|
||||
function processActiveFile(document) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (document && language(document)) {
|
||||
const { fileName } = document;
|
||||
if (emitters[fileName]) {
|
||||
emitters[fileName].removeAllListeners();
|
||||
}
|
||||
const { timeout } = vscode_1.workspace.getConfiguration('importCost');
|
||||
emitters[fileName] = import_cost_1.importCost(fileName, document.getText(), language(document), { concurrent: true, maxCallTime: timeout });
|
||||
emitters[fileName].on('error', e => logger_1.default.log(`importCost error: ${e}`));
|
||||
emitters[fileName].on('start', packages => decorator_1.flushDecorations(fileName, packages));
|
||||
emitters[fileName].on('calculated', packageInfo => decorator_1.calculated(packageInfo));
|
||||
emitters[fileName].on('done', packages => decorator_1.flushDecorations(fileName, packages));
|
||||
}
|
||||
});
|
||||
}
|
||||
function language({ fileName, languageId }) {
|
||||
if (languageId === 'Log') {
|
||||
return;
|
||||
}
|
||||
const configuration = vscode_1.workspace.getConfiguration('importCost');
|
||||
const typescriptRegex = new RegExp(configuration.typescriptExtensions.join('|'));
|
||||
const javascriptRegex = new RegExp(configuration.javascriptExtensions.join('|'));
|
||||
const vueRegex = new RegExp(configuration.vueExtensions.join('|'));
|
||||
const svelteRegex = new RegExp(configuration.svelteExtensions.join('|'));
|
||||
if (languageId === 'svelte' || svelteRegex.test(fileName)) {
|
||||
return import_cost_1.SVELTE;
|
||||
}
|
||||
else if (languageId === 'vue' || vueRegex.test(fileName)) {
|
||||
return import_cost_1.VUE;
|
||||
}
|
||||
else if (languageId === 'typescript' || languageId === 'typescriptreact' || typescriptRegex.test(fileName)) {
|
||||
return import_cost_1.TYPESCRIPT;
|
||||
}
|
||||
else if (languageId === 'javascript' || languageId === 'javascriptreact' || javascriptRegex.test(fileName)) {
|
||||
return import_cost_1.JAVASCRIPT;
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=extension.js.map
|
||||
22
.vscode/extensions/wix.vscode-import-cost-2.15.0/out/logger.js
vendored
Normal file
22
.vscode/extensions/wix.vscode-import-cost-2.15.0/out/logger.js
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const vscode_1 = require("vscode");
|
||||
class Logger {
|
||||
constructor() {
|
||||
this.debug = !!vscode_1.workspace.getConfiguration('importCost').debug;
|
||||
}
|
||||
init(context) {
|
||||
this.context = context;
|
||||
if (this.debug) {
|
||||
this.channel = vscode_1.window.createOutputChannel('ImportCost');
|
||||
context.subscriptions.push(this.channel);
|
||||
}
|
||||
}
|
||||
log(text) {
|
||||
if (this.debug) {
|
||||
this.channel.appendLine(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.default = new Logger();
|
||||
//# sourceMappingURL=logger.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue