Socket
Socket
Sign inDemoInstall

vite-plugin-checker

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-checker - npm Package Compare versions

Comparing version 0.4.0-beta.1 to 0.4.0-beta.2

CHANGELOG.md

397

lib/@runtime/main.js

@@ -117,2 +117,5 @@ var __defProp = Object.defineProperty;

}
function empty() {
return text("");
}
function listen(node, event, handler, options) {

@@ -290,3 +293,3 @@ node.addEventListener(event, handler, options);

}
function init(component, options, instance5, create_fragment5, not_equal, props, append_styles2, dirty = [-1]) {
function init(component, options, instance6, create_fragment6, not_equal, props, append_styles2, dirty = [-1]) {
const parent_component = current_component;

@@ -314,3 +317,3 @@ set_current_component(component);

let ready = false;
$$.ctx = instance5 ? instance5(component, options.props || {}, (i, ret, ...rest) => {
$$.ctx = instance6 ? instance6(component, options.props || {}, (i, ret, ...rest) => {
const value = rest.length ? rest[0] : ret;

@@ -328,3 +331,3 @@ if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {

run_all($$.before_update);
$$.fragment = create_fragment5 ? create_fragment5($$.ctx) : false;
$$.fragment = create_fragment6 ? create_fragment6($$.ctx) : false;
if (options.target) {

@@ -827,4 +830,4 @@ if (options.hydrate) {

const child_ctx = ctx.slice();
child_ctx[1] = list[i];
child_ctx[3] = i;
child_ctx[2] = list[i];
child_ctx[4] = i;
return child_ctx;

@@ -834,3 +837,3 @@ }

let li;
let t0_value = (console.log(ctx[1]), "");
let t0_value = (console.log(ctx[2]), "");
let t0;

@@ -843,4 +846,4 @@ let t1;

props: {
diagnostics: ctx[1].diagnostics,
index: ctx[3]
diagnostics: ctx[2].diagnostics,
index: ctx[4]
}

@@ -866,7 +869,7 @@ });

p(ctx2, dirty) {
if ((!current || dirty & 1) && t0_value !== (t0_value = (console.log(ctx2[1]), "")))
if ((!current || dirty & 1) && t0_value !== (t0_value = (console.log(ctx2[2]), "")))
set_data(t0, t0_value);
const checker_changes = {};
if (dirty & 1)
checker_changes.diagnostics = ctx2[1].diagnostics;
checker_changes.diagnostics = ctx2[2].diagnostics;
checker.$set(checker_changes);

@@ -908,2 +911,3 @@ },

}
attr(ul, "style", ctx[1]);
attr(ul, "class", "svelte-9kex0m");

@@ -940,2 +944,5 @@ },

}
if (!current || dirty & 2) {
attr(ul, "style", ctx2[1]);
}
},

@@ -966,7 +973,10 @@ i(local) {

let { checkerResults } = $$props;
let { ulStyle } = $$props;
$$self.$$set = ($$props2) => {
if ("checkerResults" in $$props2)
$$invalidate(0, checkerResults = $$props2.checkerResults);
if ("ulStyle" in $$props2)
$$invalidate(1, ulStyle = $$props2.ulStyle);
};
return [checkerResults];
return [checkerResults, ulStyle];
}

@@ -976,3 +986,3 @@ var List = class extends SvelteComponent {

super();
init(this, options, instance3, create_fragment3, safe_not_equal, { checkerResults: 0 }, add_css3);
init(this, options, instance3, create_fragment3, safe_not_equal, { checkerResults: 0, ulStyle: 1 }, add_css3);
}

@@ -982,17 +992,278 @@ };

// src/App.svelte
// src/components/Badge.svelte
function add_css4(target) {
append_styles(target, "svelte-w1d7iq", ":host{position:fixed;z-index:9999;top:0;left:0;width:100%;height:100%;overflow-y:scroll;margin:0;background:rgba(0, 0, 0, 0.66);--monospace:'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;--red:#ff5555;--yellow:#e2aa53;--purple:#cfa4ff;--blue:#a4c1ff;--cyan:#2dd9da;--dim:#c9c9c9}.window.svelte-w1d7iq{font-family:var(--monospace);line-height:1.5;width:800px;color:#d8d8d8;margin:40px auto;padding:16px 32px 32px;position:relative;background:#24272e;border-radius:6px 6px 8px 8px;box-shadow:0 19px 38px rgba(0, 0, 0, 0.3), 0 15px 12px rgba(0, 0, 0, 0.22);overflow:scroll;direction:ltr;text-align:left;max-height:80vh}main.svelte-w1d7iq{text-align:center;padding:1em;max-width:240px;margin:0 auto}.tip.svelte-w1d7iq{font-size:12px;color:#999;padding-top:13px}code.svelte-w1d7iq{color:var(--yellow)}@media(min-width: 640px){main.svelte-w1d7iq{max-width:none}}");
append_styles(target, "svelte-hjneft", ".badge-base.svelte-hjneft{appearance:none;font-size:0.9em;font-weight:bold;border:0px;border-radius:0.3em;padding:0.5em;cursor:pointer;position:fixed;z-index:99999;margin:0.5em}.badge-bl.svelte-hjneft{bottom:0px;left:0px}.badge-br.svelte-hjneft{bottom:0px;right:0px}.badge-tl.svelte-hjneft{top:0px;left:0px}.badge-tr.svelte-hjneft{top:0px;right:0px}.to-collpase.svelte-hjneft{color:white;background:rgb(63, 78, 96)}.to-uncollpase.svelte-hjneft{color:white}.emoji.svelte-hjneft{margin-right:0.5ch;font-family:'apple color emoji,segoe ui emoji,noto color emoji,android emoji,emojisymbols,emojione mozilla,twemoji mozilla,segoe ui symbol'}.summary.svelte-hjneft{font-family:var(--monospace);margin-right:1ch}.summary.svelte-hjneft:last-of-type{margin-right:0}.summary-error.svelte-hjneft{background:var(--red)}.summary-warning.svelte-hjneft{background:var(--yellow)}");
}
function create_else_block2(ctx) {
let span;
return {
c() {
span = element("span");
span.textContent = "Close";
},
m(target, anchor) {
insert(target, span, anchor);
},
p: noop,
d(detaching) {
if (detaching)
detach(span);
}
};
}
function create_if_block2(ctx) {
let if_block_anchor;
let if_block = ctx[4].errorCount + ctx[4].warningCount > 0 && create_if_block_12(ctx);
return {
c() {
if (if_block)
if_block.c();
if_block_anchor = empty();
},
m(target, anchor) {
if (if_block)
if_block.m(target, anchor);
insert(target, if_block_anchor, anchor);
},
p(ctx2, dirty) {
if (ctx2[4].errorCount + ctx2[4].warningCount > 0) {
if (if_block) {
if_block.p(ctx2, dirty);
} else {
if_block = create_if_block_12(ctx2);
if_block.c();
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
} else if (if_block) {
if_block.d(1);
if_block = null;
}
},
d(detaching) {
if (if_block)
if_block.d(detaching);
if (detaching)
detach(if_block_anchor);
}
};
}
function create_if_block_12(ctx) {
let span1;
let span0;
let t1_value = ctx[4].errorCount + "";
let t1;
let t2;
let span3;
let span2;
let t4_value = ctx[4].warningCount + "";
let t4;
return {
c() {
span1 = element("span");
span0 = element("span");
span0.textContent = "\u2757\uFE0F";
t1 = text(t1_value);
t2 = space();
span3 = element("span");
span2 = element("span");
span2.textContent = "\u26A0\uFE0F";
t4 = text(t4_value);
attr(span0, "class", "emoji svelte-hjneft");
attr(span1, "class", "summary svelte-hjneft");
attr(span2, "class", "emoji svelte-hjneft");
attr(span3, "class", "summary svelte-hjneft");
},
m(target, anchor) {
insert(target, span1, anchor);
append(span1, span0);
append(span1, t1);
insert(target, t2, anchor);
insert(target, span3, anchor);
append(span3, span2);
append(span3, t4);
},
p(ctx2, dirty) {
if (dirty & 16 && t1_value !== (t1_value = ctx2[4].errorCount + ""))
set_data(t1, t1_value);
if (dirty & 16 && t4_value !== (t4_value = ctx2[4].warningCount + ""))
set_data(t4, t4_value);
},
d(detaching) {
if (detaching)
detach(span1);
if (detaching)
detach(t2);
if (detaching)
detach(span3);
}
};
}
function create_fragment4(ctx) {
let button;
let button_class_value;
let mounted;
let dispose;
function select_block_type(ctx2, dirty) {
if (ctx2[0])
return create_if_block2;
return create_else_block2;
}
let current_block_type = select_block_type(ctx, -1);
let if_block = current_block_type(ctx);
return {
c() {
button = element("button");
if_block.c();
attr(button, "class", button_class_value = null_to_empty(`badge-base ${ctx[0] ? `to-uncollpase ${ctx[5]}` : "to-collpase"} badge-${ctx[2]}`) + " svelte-hjneft");
attr(button, "style", ctx[3]);
},
m(target, anchor) {
insert(target, button, anchor);
if_block.m(button, null);
if (!mounted) {
dispose = listen(button, "click", stop_propagation(function() {
if (is_function(ctx[1]))
ctx[1].apply(this, arguments);
}));
mounted = true;
}
},
p(new_ctx, [dirty]) {
ctx = new_ctx;
if (current_block_type === (current_block_type = select_block_type(ctx, dirty)) && if_block) {
if_block.p(ctx, dirty);
} else {
if_block.d(1);
if_block = current_block_type(ctx);
if (if_block) {
if_block.c();
if_block.m(button, null);
}
}
if (dirty & 37 && button_class_value !== (button_class_value = null_to_empty(`badge-base ${ctx[0] ? `to-uncollpase ${ctx[5]}` : "to-collpase"} badge-${ctx[2]}`) + " svelte-hjneft")) {
attr(button, "class", button_class_value);
}
if (dirty & 8) {
attr(button, "style", ctx[3]);
}
},
i: noop,
o: noop,
d(detaching) {
if (detaching)
detach(button);
if_block.d();
mounted = false;
dispose();
}
};
}
function calcSummary(results) {
let errorCount = 0;
let warningCount = 0;
results.forEach((result) => {
result.diagnostics.forEach((d) => {
if (d.level === 1)
errorCount++;
if (d.level === 0)
warningCount++;
});
});
return { errorCount, warningCount };
}
function instance4($$self, $$props, $$invalidate) {
let summary;
let calcBgColorClass;
let bgColorClass;
let { collapsed } = $$props;
let { checkerResults } = $$props;
let { onClick } = $$props;
let { position = "bl" } = $$props;
let { badgeStyle = "" } = $$props;
$$self.$$set = ($$props2) => {
if ("collapsed" in $$props2)
$$invalidate(0, collapsed = $$props2.collapsed);
if ("checkerResults" in $$props2)
$$invalidate(6, checkerResults = $$props2.checkerResults);
if ("onClick" in $$props2)
$$invalidate(1, onClick = $$props2.onClick);
if ("position" in $$props2)
$$invalidate(2, position = $$props2.position);
if ("badgeStyle" in $$props2)
$$invalidate(3, badgeStyle = $$props2.badgeStyle);
};
$$self.$$.update = () => {
if ($$self.$$.dirty & 64) {
$:
$$invalidate(4, summary = calcSummary(checkerResults));
}
if ($$self.$$.dirty & 16) {
$:
$$invalidate(7, calcBgColorClass = () => {
if (!summary)
return "";
if (summary.errorCount > 0)
return "summary-error";
if (summary.warningCount > 0)
return "summary-warning";
return "summary-success";
});
}
if ($$self.$$.dirty & 128) {
$:
$$invalidate(5, bgColorClass = calcBgColorClass());
}
};
return [
collapsed,
onClick,
position,
badgeStyle,
summary,
bgColorClass,
checkerResults,
calcBgColorClass
];
}
var Badge = class extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance4, create_fragment4, safe_not_equal, {
collapsed: 0,
checkerResults: 6,
onClick: 1,
position: 2,
badgeStyle: 3
}, add_css4);
}
};
var Badge_default = Badge;
// src/App.svelte
function add_css5(target) {
append_styles(target, "svelte-semrb8", ":host{--monospace:'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;--red:#ff5555;--yellow:#e2aa53;--purple:#cfa4ff;--blue:#a4c1ff;--cyan:#2dd9da;--dim:#c9c9c9}.window.svelte-semrb8{font-family:sans-serif;background-color:rgb(11, 21, 33);color:white;position:fixed;bottom:0px;right:0px;z-index:99998;width:100%;height:500px;max-height:90%;box-shadow:rgb(0 0 0 / 30%) 0px 0px 20px;border-top:1px solid rgb(63, 78, 96);transform-origin:center top;visibility:visible;transition:all 0.2s ease 0s;opacity:1;pointer-events:all;transform:translateY(0px) scale(1)}.window-collapsed.svelte-semrb8{transform:translateY(0px) scale(1);visibility:hidden;transition:all 0.2s ease 0s;opacity:0;pointer-events:none;transform:translateY(15px) scale(1.02)}.list-scroll.svelte-semrb8{height:100%;overflow:scroll;flex-grow:1}main.svelte-semrb8{padding:16px;max-width:240px;width:100%;box-sizing:border-box}@media(min-width: 640px){main.svelte-semrb8{max-width:none}}");
}
function create_fragment5(ctx) {
let badge;
let t;
let main;
let div;
let list;
let t0;
let div;
let main_class_value;
let current;
let mounted;
let dispose;
badge = new Badge_default({
props: {
checkerResults: ctx[1],
collapsed: ctx[2],
position: ctx[0].position,
badgeStyle: ctx[0].badgeStyle,
onClick: ctx[3]
}
});
list = new List_default({
props: {
checkerResults: ctx[0]
checkerResults: ctx[1],
ulStyle: "margin-bottom: 36px;"
}

@@ -1002,19 +1273,19 @@ });

c() {
create_component(badge.$$.fragment);
t = space();
main = element("main");
div = element("div");
create_component(list.$$.fragment);
t0 = space();
div = element("div");
div.innerHTML = `Click outside or fix the code to dismiss. You can also disable this overlay by setting
<code class="svelte-w1d7iq">config.overlay</code> to <code class="svelte-w1d7iq">false</code> in <code class="svelte-w1d7iq">vite.config.js.</code>`;
attr(div, "class", "tip svelte-w1d7iq");
attr(main, "class", "window svelte-w1d7iq");
attr(div, "class", "list-scroll svelte-semrb8");
attr(main, "class", main_class_value = null_to_empty(`window ${ctx[2] ? "window-collapsed" : ""}`) + " svelte-semrb8");
},
m(target, anchor) {
mount_component(badge, target, anchor);
insert(target, t, anchor);
insert(target, main, anchor);
mount_component(list, main, null);
append(main, t0);
append(main, div);
mount_component(list, div, null);
current = true;
if (!mounted) {
dispose = listen(main, "click", stop_propagation(ctx[1]));
dispose = listen(main, "click", stop_propagation(ctx[5]));
mounted = true;

@@ -1024,6 +1295,19 @@ }

p(ctx2, [dirty]) {
const badge_changes = {};
if (dirty & 2)
badge_changes.checkerResults = ctx2[1];
if (dirty & 4)
badge_changes.collapsed = ctx2[2];
if (dirty & 1)
badge_changes.position = ctx2[0].position;
if (dirty & 1)
badge_changes.badgeStyle = ctx2[0].badgeStyle;
badge.$set(badge_changes);
const list_changes = {};
if (dirty & 1)
list_changes.checkerResults = ctx2[0];
if (dirty & 2)
list_changes.checkerResults = ctx2[1];
list.$set(list_changes);
if (!current || dirty & 4 && main_class_value !== (main_class_value = null_to_empty(`window ${ctx2[2] ? "window-collapsed" : ""}`) + " svelte-semrb8")) {
attr(main, "class", main_class_value);
}
},

@@ -1033,2 +1317,3 @@ i(local) {

return;
transition_in(badge.$$.fragment, local);
transition_in(list.$$.fragment, local);

@@ -1038,2 +1323,3 @@ current = true;

o(local) {
transition_out(badge.$$.fragment, local);
transition_out(list.$$.fragment, local);

@@ -1043,3 +1329,6 @@ current = false;

d(detaching) {
destroy_component(badge, detaching);
if (detaching)
detach(t);
if (detaching)
detach(main);

@@ -1052,4 +1341,10 @@ destroy_component(list);

}
function instance4($$self, $$props, $$invalidate) {
function instance5($$self, $$props, $$invalidate) {
let { overlayConfig: overlayConfig2 = {} } = $$props;
let { initialIsOpen = true } = $$props;
let { checkerResults } = $$props;
let collapsed = !initialIsOpen;
const toggle = () => {
$$invalidate(2, collapsed = !collapsed);
};
function click_handler(event) {

@@ -1059,6 +1354,10 @@ bubble.call(this, $$self, event);

$$self.$$set = ($$props2) => {
if ("overlayConfig" in $$props2)
$$invalidate(0, overlayConfig2 = $$props2.overlayConfig);
if ("initialIsOpen" in $$props2)
$$invalidate(4, initialIsOpen = $$props2.initialIsOpen);
if ("checkerResults" in $$props2)
$$invalidate(0, checkerResults = $$props2.checkerResults);
$$invalidate(1, checkerResults = $$props2.checkerResults);
};
return [checkerResults, click_handler];
return [overlayConfig2, checkerResults, collapsed, toggle, initialIsOpen, click_handler];
}

@@ -1068,3 +1367,7 @@ var App = class extends SvelteComponent {

super();
init(this, options, instance4, create_fragment4, safe_not_equal, { checkerResults: 0 }, add_css4);
init(this, options, instance5, create_fragment5, safe_not_equal, {
overlayConfig: 0,
initialIsOpen: 4,
checkerResults: 1
}, add_css5);
}

@@ -1080,4 +1383,9 @@ };

var WS_CHECKER_RECONNECT_EVENT = "vite-plugin-checker:reconnect";
var WS_CHECKER_CONFIG_RUNTIME_EVENT = "vite-plugin-checker:config-runtime";
var onCustomMessage = [];
var onReconnectMessage = [];
var onConfigMessage = [];
function listenToConfigMessage(cb) {
onConfigMessage.push(cb);
}
function listenToCustomMessage(cb) {

@@ -1097,12 +1405,15 @@ onCustomMessage.push(cb);

break;
default:
break;
}
if (data.type === "custom") {
if (data.event === WS_CHECKER_ERROR_EVENT) {
onCustomMessage.forEach((callbackfn) => callbackfn(data.data));
switch (data.event) {
case WS_CHECKER_ERROR_EVENT:
onCustomMessage.forEach((callbackfn) => callbackfn(data.data));
break;
case WS_CHECKER_RECONNECT_EVENT:
onReconnectMessage.forEach((callbackfn) => callbackfn(data.data));
break;
case WS_CHECKER_CONFIG_RUNTIME_EVENT:
onConfigMessage.forEach((callbackfn) => callbackfn(data.data));
break;
}
if (data.event === WS_CHECKER_RECONNECT_EVENT) {
onReconnectMessage.forEach((callbackfn) => callbackfn(data.data));
}
}

@@ -1120,2 +1431,3 @@ });

var checkerResultsStore = [];
var overlayConfig = {};
var ErrorOverlay = class extends HTMLElement {

@@ -1159,3 +1471,4 @@ constructor() {

props: {
checkerResults: checkerResultsStore
checkerResults: checkerResultsStore,
overlayConfig
}

@@ -1173,2 +1486,5 @@ });

}
function configOverlay(data) {
overlayConfig = data;
}
function clearErrorOverlay() {

@@ -1183,2 +1499,3 @@ document.querySelectorAll(overlayId).forEach((n) => n.close());

listenToReconnectMessage(resumeErrorOverlay);
listenToConfigMessage(configOverlay);
ws.start();

@@ -1185,0 +1502,0 @@ }

14

lib/checkers/eslint/main.js

@@ -30,5 +30,7 @@ "use strict";

let overlay = true;
let terminal = true;
return {
config: ({ enableOverlay }) => __awaiter(void 0, void 0, void 0, function* () {
config: ({ enableOverlay, enableTerminal }) => __awaiter(void 0, void 0, void 0, function* () {
overlay = enableOverlay;
terminal = enableTerminal;
}),

@@ -58,5 +60,7 @@ configureServer({ root }) {

const diagnostics = logger_1.filterLogLevel(manager.getDiagnostics(), logLevel);
diagnostics.forEach((d) => {
logger_1.consoleLog(logger_1.diagnosticToTerminalLog(d, 'ESLint'));
});
if (terminal) {
diagnostics.forEach((d) => {
logger_1.consoleLog(logger_1.diagnosticToTerminalLog(d, 'ESLint'));
});
}
if (overlay) {

@@ -87,3 +91,2 @@ worker_threads_1.parentPort === null || worker_threads_1.parentPort === void 0 ? void 0 : worker_threads_1.parentPort.postMessage({

manager.initWith(diagnostics.map((p) => logger_1.normalizeEslintDiagnostic(p)).flat(1));
// diagnosticsCache = diagnostics.map((p) => normalizeEslintDiagnostic(p)).flat(1)
dispatchDiagnostics();

@@ -115,3 +118,2 @@ // watch lint

const { lintCommand } = pluginConfig.eslint;
// const { _ } = cmdToOptions(lintCommand)
return ['eslint', lintCommand.split(' ').slice(1)];

@@ -118,0 +120,0 @@ }

@@ -26,6 +26,8 @@ "use strict";

let overlay = true;
let terminal = true;
let currDiagnostics = [];
return {
config: ({ enableOverlay }) => __awaiter(void 0, void 0, void 0, function* () {
config: ({ enableOverlay, enableTerminal }) => __awaiter(void 0, void 0, void 0, function* () {
overlay = enableOverlay;
terminal = enableTerminal;
}),

@@ -74,4 +76,2 @@ configureServer({ root }) {

if (overlay) {
// const normalizedDiagnostics = normalizeTsDiagnostic(diagnostic)
// parentPort?.postMessage(toWsPayload(currErrs))
worker_threads_1.parentPort === null || worker_threads_1.parentPort === void 0 ? void 0 : worker_threads_1.parentPort.postMessage({

@@ -87,3 +87,5 @@ type: types_1.ACTION_TYPES.overlayError,

}
logger_1.consoleLog(logChunk + os_1.default.EOL + diagnostic.messageText.toString());
if (terminal) {
logger_1.consoleLog(logChunk + os_1.default.EOL + diagnostic.messageText.toString());
}
});

@@ -90,0 +92,0 @@ };

/// <reference types="node" />
import { Duplex } from 'stream';
import { VLS } from 'vls';
import { DiagnosticSeverity, Logger, PublishDiagnosticsParams } from 'vscode-languageserver/node';
import { DiagnosticSeverity, Logger } from 'vscode-languageserver/node';
import { URI } from 'vscode-uri';
import { DeepPartial, DiagnosticToRuntime } from '../../types';
import { NormalizedDiagnostic } from '../../logger';
import { DeepPartial } from '../../types';
import { VlsOptions } from './initParams';

@@ -20,3 +21,4 @@ export declare type LogLevel = typeof logLevels[number];

config: DeepPartial<VlsOptions> | null;
errorCallback?: (diagnostic: PublishDiagnosticsParams, viteError: DiagnosticToRuntime[]) => void;
onDispatch?: (normalized: NormalizedDiagnostic[]) => void;
onDispatchInitialSummary?: (errorCount: number) => void;
}

@@ -23,0 +25,0 @@ export declare function diagnostics(workspace: string | null, logLevel: LogLevel, options?: DiagnosticOptions): Promise<void>;

@@ -43,4 +43,5 @@ "use strict";

function diagnostics(workspace, logLevel, options = { watch: false, verbose: false, config: null }) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const { watch, errorCallback } = options;
const { watch, onDispatch } = options;
if (options.verbose) {

@@ -64,15 +65,7 @@ console.log('====================================');

}
// initial report
if (!errCount) {
vlsConsoleLog(chalk_1.default.green(`[VLS checker] No error found`));
if (!watch) {
process.exit(0);
}
// dispatch error summary in build mode
if (!options.watch && typeof errCount === 'number') {
(_a = options === null || options === void 0 ? void 0 : options.onDispatchInitialSummary) === null || _a === void 0 ? void 0 : _a.call(options, errCount);
process.exit(errCount > 0 ? 1 : 0);
}
else {
vlsConsoleLog(chalk_1.default.red(`[VLS checker] Found ${errCount} ${errCount === 1 ? 'error' : 'errors'}`));
if (!watch) {
process.exit(1);
}
}
});

@@ -95,7 +88,6 @@ }

exports.TestStream = TestStream;
let vlsConsoleLog = logger_1.consoleLog;
function suppressConsole() {
let disposed = false;
const rawConsoleLog = vlsConsoleLog;
vlsConsoleLog = () => { };
const rawConsoleLog = console.log;
console.log = () => { };
return () => {

@@ -105,3 +97,3 @@ if (disposed)

disposed = true;
vlsConsoleLog = rawConsoleLog;
console.log = rawConsoleLog;
};

@@ -127,9 +119,4 @@ }

fileDiagnosticManager.updateByFileId(absFilePath, nextDiagnosticInFile);
const diagnostics = fileDiagnosticManager.getDiagnostics();
vlsConsoleLog(os_1.default.EOL);
vlsConsoleLog(diagnostics.map((d) => logger_1.diagnosticToTerminalLog(d, 'VLS')).join(os_1.default.EOL));
if (diagnostics) {
const normalized = logger_1.diagnosticToRuntimeError(diagnostics);
(_a = options.errorCallback) === null || _a === void 0 ? void 0 : _a.call(options, publishDiagnostics, normalized);
}
const normalized = fileDiagnosticManager.getDiagnostics();
(_a = options.onDispatch) === null || _a === void 0 ? void 0 : _a.call(options, normalized);
});

@@ -185,3 +172,3 @@ const vls = new vls_1.VLS(serverConnection);

if (files.length === 0) {
console.log('No input files');
console.log('[VLS checker] No input files');
return 0;

@@ -194,10 +181,9 @@ }

const absFilePaths = files.map((f) => path_1.default.resolve(workspaceUri.fsPath, f));
// initial diagnostics report
// watch mode will run this full diagnostic at starting
// VLS will stdout verbose log, suppress console before any serverConnection
disposeSuppressConsole = suppressConsole();
let initialErrCount = 0;
let logChunk = '';
if (options.watch) {
disposeSuppressConsole = suppressConsole();
}
yield Promise.all(absFilePaths.map((absFilePath) => __awaiter(this, void 0, void 0, function* () {
// serve mode - step 1
// build mode - step 1
// report all existing files from client side to server with type `DidOpenTextDocumentNotification.type`
const fileText = yield fs_1.default.promises.readFile(absFilePath, 'utf-8');

@@ -212,3 +198,4 @@ clientConnection.sendNotification(node_1.DidOpenTextDocumentNotification.type, {

});
// log in build mode
// build mode - step 2
// use $/getDiagnostics to get diagnostics from server side directly
if (!options.watch) {

@@ -221,2 +208,3 @@ try {

diagnostics = filterDiagnostics(diagnostics, severity);
let logChunk = '';
if (diagnostics.length > 0) {

@@ -238,42 +226,57 @@ logChunk +=

}
console.log(logChunk);
return initialErrCount;
}
catch (err) {
console.error(err.stack);
return initialErrCount;
}
}
})));
// watched diagnostics report
if (options.watch) {
const watcher = chokidar_1.default.watch([], {
ignored: (path) => path.includes('node_modules'),
if (!options.watch) {
return initialErrCount;
}
// serve mode - step 2
// watch files (.vue,.js,.ts,.json) change and send notification to server
yield Promise.all(absFilePaths.map((absFilePath) => __awaiter(this, void 0, void 0, function* () {
const fileText = yield fs_1.default.promises.readFile(absFilePath, 'utf-8');
clientConnection.sendNotification(node_1.DidOpenTextDocumentNotification.type, {
textDocument: {
languageId: 'vue',
uri: vscode_uri_1.URI.file(absFilePath).toString(),
version: DOC_VERSION.init,
text: fileText,
},
});
watcher.add(workspaceUri.fsPath);
watcher.on('all', (event, filePath) => __awaiter(this, void 0, void 0, function* () {
const extname = path_1.default.extname(filePath);
// .vue file changed
if (!filePath.endsWith('.vue'))
return;
const fileContent = yield fs_1.default.promises.readFile(filePath, 'utf-8');
clientConnection.sendNotification(node_1.DidChangeTextDocumentNotification.type, {
textDocument: {
uri: vscode_uri_1.URI.file(filePath).toString(),
version: Date.now(),
},
contentChanges: [{ text: fileContent }],
})));
const watcher = chokidar_1.default.watch([], {
ignored: (path) => path.includes('node_modules'),
});
watcher.add(workspaceUri.fsPath);
watcher.on('all', (event, filePath) => __awaiter(this, void 0, void 0, function* () {
const extname = path_1.default.extname(filePath);
// .vue file changed
if (!filePath.endsWith('.vue'))
return;
const fileContent = yield fs_1.default.promises.readFile(filePath, 'utf-8');
clientConnection.sendNotification(node_1.DidChangeTextDocumentNotification.type, {
textDocument: {
uri: vscode_uri_1.URI.file(filePath).toString(),
version: Date.now(),
},
contentChanges: [{ text: fileContent }],
});
// .js,.ts,.json file changed
if (watchedDidChangeWatchedFiles.includes(extname)) {
clientConnection.sendNotification(node_1.DidChangeWatchedFilesNotification.type, {
changes: [
{
uri: vscode_uri_1.URI.file(filePath).toString(),
type: event === 'add' ? 1 : event === 'unlink' ? 3 : 2,
},
],
});
// .js,.ts,.json file changed
if (watchedDidChangeWatchedFiles.includes(extname)) {
clientConnection.sendNotification(node_1.DidChangeWatchedFilesNotification.type, {
changes: [
{
uri: vscode_uri_1.URI.file(filePath).toString(),
type: event === 'add' ? 1 : event === 'unlink' ? 3 : 2,
},
],
});
}
}));
}
vlsConsoleLog(logChunk);
return initialErrCount;
}
}));
return null;
});

@@ -280,0 +283,0 @@ }

@@ -11,33 +11,53 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.VlsChecker = exports.createDiagnostic = void 0;
const chalk_1 = __importDefault(require("chalk"));
const os_1 = __importDefault(require("os"));
const worker_threads_1 = require("worker_threads");
const Checker_1 = require("../../Checker");
const logger_1 = require("../../logger");
const types_1 = require("../../types");
const diagnostics_1 = require("./diagnostics");
const logger_1 = require("../../logger");
const createDiagnostic = (pluginConfig) => {
let overlay = true;
let terminal = true;
let command;
return {
config: ({ enableOverlay }) => {
config: ({ enableOverlay, enableTerminal, env }) => {
overlay = enableOverlay;
terminal = enableTerminal;
command = env.command;
},
configureServer({ root }) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const workDir = root;
const errorCallback = (diagnostics, overlayErr) => {
if (!overlay)
return;
worker_threads_1.parentPort === null || worker_threads_1.parentPort === void 0 ? void 0 : worker_threads_1.parentPort.postMessage({
type: types_1.ACTION_TYPES.overlayError,
payload: logger_1.toViteCustomPayload('vls', overlayErr ? overlayErr : []),
});
const onDispatch = (normalized) => {
if (overlay && command === 'serve') {
worker_threads_1.parentPort === null || worker_threads_1.parentPort === void 0 ? void 0 : worker_threads_1.parentPort.postMessage({
type: types_1.ACTION_TYPES.overlayError,
payload: logger_1.toViteCustomPayload('vls', logger_1.diagnosticToRuntimeError(normalized)),
});
}
if (terminal) {
logger_1.consoleLog(normalized.map((d) => logger_1.diagnosticToTerminalLog(d, 'VLS')).join(os_1.default.EOL));
}
};
const vlsConfig = (_a = worker_threads_1.workerData === null || worker_threads_1.workerData === void 0 ? void 0 : worker_threads_1.workerData.checkerConfig) === null || _a === void 0 ? void 0 : _a.vls;
const onDispatchInitialSummary = (errCount) => {
if (!errCount) {
logger_1.consoleLog(chalk_1.default.green(`[VLS checker] No error found`));
}
else {
logger_1.consoleLog(chalk_1.default.red(`[VLS checker] Found ${errCount} ${errCount === 1 ? 'error' : 'errors'}`));
}
};
const vlsConfig = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.vls;
yield diagnostics_1.diagnostics(workDir, 'WARN', {
errorCallback,
onDispatch,
onDispatchInitialSummary,
watch: true,
verbose: false,
config: typeof vlsConfig === 'object' ? vlsConfig : undefined,
config: typeof vlsConfig === 'object' ? vlsConfig : null,
});

@@ -44,0 +64,0 @@ });

@@ -1,6 +0,7 @@

declare const RUNTIME_PUBLIC_PATH = "/@vite-plugin-checker-runtime";
declare const WS_CHECKER_ERROR_EVENT = "vite-plugin-checker:error";
declare const WS_CHECKER_RECONNECT_EVENT = "vite-plugin-checker:reconnect";
declare const runtimeCode: string;
export { runtimeCode, RUNTIME_PUBLIC_PATH, WS_CHECKER_ERROR_EVENT, WS_CHECKER_RECONNECT_EVENT };
export declare const RUNTIME_PUBLIC_PATH = "/@vite-plugin-checker-runtime";
export declare const RUNTIME_FILE_PATH: string;
export declare const WS_CHECKER_ERROR_EVENT = "vite-plugin-checker:error";
export declare const WS_CHECKER_RECONNECT_EVENT = "vite-plugin-checker:reconnect";
export declare const WS_CHECKER_CONFIG_RUNTIME_EVENT = "vite-plugin-checker:config-runtime";
export declare const runtimeCode: string;
//# sourceMappingURL=index.d.ts.map

@@ -6,12 +6,12 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.WS_CHECKER_RECONNECT_EVENT = exports.WS_CHECKER_ERROR_EVENT = exports.RUNTIME_PUBLIC_PATH = exports.runtimeCode = void 0;
exports.runtimeCode = exports.WS_CHECKER_CONFIG_RUNTIME_EVENT = exports.WS_CHECKER_RECONNECT_EVENT = exports.WS_CHECKER_ERROR_EVENT = exports.RUNTIME_FILE_PATH = exports.RUNTIME_PUBLIC_PATH = void 0;
const fs_1 = __importDefault(require("fs"));
const RUNTIME_PUBLIC_PATH = '/@vite-plugin-checker-runtime';
exports.RUNTIME_PUBLIC_PATH = RUNTIME_PUBLIC_PATH;
const RUNTIME_FILE_PATH = require.resolve('../@runtime/main.js');
const WS_CHECKER_ERROR_EVENT = 'vite-plugin-checker:error';
exports.WS_CHECKER_ERROR_EVENT = WS_CHECKER_ERROR_EVENT;
const WS_CHECKER_RECONNECT_EVENT = 'vite-plugin-checker:reconnect';
exports.WS_CHECKER_RECONNECT_EVENT = WS_CHECKER_RECONNECT_EVENT;
const runtimeCode = `${fs_1.default.readFileSync(RUNTIME_FILE_PATH, 'utf-8')};`;
exports.runtimeCode = runtimeCode;
// #region
// NOTE: sync modification with packages/runtime/src/ws.js
exports.RUNTIME_PUBLIC_PATH = '/@vite-plugin-checker-runtime';
exports.RUNTIME_FILE_PATH = require.resolve('../@runtime/main.js');
exports.WS_CHECKER_ERROR_EVENT = 'vite-plugin-checker:error';
exports.WS_CHECKER_RECONNECT_EVENT = 'vite-plugin-checker:reconnect';
exports.WS_CHECKER_CONFIG_RUNTIME_EVENT = 'vite-plugin-checker:config-runtime';
// #endregion
exports.runtimeCode = `${fs_1.default.readFileSync(exports.RUNTIME_FILE_PATH, 'utf-8')};`;

@@ -51,5 +51,7 @@ "use strict";

function Plugin(userConfig) {
var _a, _b;
var _a;
const enableBuild = (_a = userConfig === null || userConfig === void 0 ? void 0 : userConfig.enableBuild) !== null && _a !== void 0 ? _a : true;
const enableOverlay = (_b = userConfig === null || userConfig === void 0 ? void 0 : userConfig.overlay) !== null && _b !== void 0 ? _b : true;
const enableOverlay = (userConfig === null || userConfig === void 0 ? void 0 : userConfig.overlay) !== false;
const enableTerminal = (userConfig === null || userConfig === void 0 ? void 0 : userConfig.terminal) !== false;
const overlayConfig = typeof (userConfig === null || userConfig === void 0 ? void 0 : userConfig.overlay) === 'object' ? userConfig === null || userConfig === void 0 ? void 0 : userConfig.overlay : null;
let checkers = [];

@@ -66,8 +68,7 @@ let viteMode;

return;
// const hmr = config.server?.hmr
checkers.forEach((checker) => {
const workerConfig = checker.serve.config;
workerConfig({
// hmr: typeof hmr === 'object' ? { overlay: hmr.overlay } : hmr,
enableOverlay,
enableTerminal,
env,

@@ -130,2 +131,9 @@ });

// Get the server instance and keep reference in a closure
if (overlayConfig) {
server.ws.send({
type: 'custom',
event: index_1.WS_CHECKER_CONFIG_RUNTIME_EVENT,
data: overlayConfig,
});
}
checkers.forEach((checker, index) => {

@@ -154,2 +162,9 @@ const { worker, configureServer: workerConfigureServer } = checker.serve;

if (connectedTimes > 1) {
if (overlayConfig) {
server.ws.send({
type: 'custom',
event: index_1.WS_CHECKER_CONFIG_RUNTIME_EVENT,
data: overlayConfig,
});
}
server.ws.send({

@@ -156,0 +171,0 @@ type: 'custom',

@@ -6,9 +6,23 @@ /// <reference types="node" />

import type { VlsOptions } from './checkers/vls/initParams';
/** TypeScript checker configuration */
export declare type TscConfig = boolean | Partial<{
/** path to tsconfig.json file */
/**
* TypeScript checker configuration
* @default true
*/
export declare type TscConfig =
/**
* - set to `true` to enable type checking with default configuration
* - set to `false` to disable type checking, you can also remove `config.typescript` directly
*/
boolean | Partial<{
/**
* path to tsconfig.json file
*/
tsconfigPath: string;
/** root path of cwd */
/**
* root path of cwd
*/
root: string;
/** root path of cwd */
/**
* root path of cwd
*/
buildMode: boolean;

@@ -48,2 +62,35 @@ }>;

/**
* Show overlay on UI view when there are errors or warnings in dev mode.
* - Set `true` to show overlay
* - Set `false` to disable overlay
* - Set with a object to customize overlay
*
* @defaultValue `true`
*/
overlay: boolean | {
/**
* Set this true if you want the overlay to default to being open if errors/warnings are found
* @defaultValue `true`
*/
initialIsOpen?: boolean;
/**
* The position of the vite-plugin-checker badge to open and close the diagnostics panel
* @default `bl`
*/
position?: 'tl' | 'tr' | 'bl' | 'br';
/**
* Use this to add extra style to the badge button
* For example, if you want to want with react-query devtool, you can pass 'margin-left: 100px;' to avoid the badge overlap with the react-query's
*/
badgeStyle?: string;
};
/**
* stdout in terminal which starts the Vite server in dev mode.
* - Set `true` to enable
* - Set `false` to disable
*
* @defaultValue `true`
*/
terminal: boolean;
/**
* Enable checking in build mode

@@ -53,8 +100,2 @@ * @defaultValue `true`

enableBuild: boolean;
/**
* Show overlay when has TypeScript error
* @defaultValue
* Same as [Vite config](https://vitejs.dev/config/#root)
*/
overlay: boolean;
}

@@ -92,2 +133,3 @@ export interface BuildInCheckers {

enableOverlay: boolean;
enableTerminal: boolean;
env: ConfigEnv;

@@ -94,0 +136,0 @@ }

{
"name": "vite-plugin-checker",
"version": "0.4.0-beta.1",
"version": "0.4.0-beta.2",
"description": "Vite plugin that runs TypeScript type checker on a separate process.",

@@ -13,2 +13,10 @@ "main": "lib/main.js",

],
"scripts": {
"watch:node": "tsc -p tsconfig.build.json --watch",
"dev": "run-p watch:node",
"build": "tsc -p tsconfig.build.json",
"build:test": "tsc -p tsconfig.test.json",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . --lerna-package vite-plugin-checker",
"release": "zx ../../scripts/release.mjs"
},
"repository": {

@@ -55,11 +63,3 @@ "type": "git",

"vls": "^0.7.2"
},
"scripts": {
"watch:node": "tsc -p tsconfig.build.json --watch",
"dev": "run-p watch:node",
"build": "tsc -p tsconfig.build.json",
"build:test": "tsc -p tsconfig.test.json",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . --lerna-package vite-plugin-checker",
"release": "zx ../../scripts/release.mjs"
}
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc