[Shared][Web] Refactor shared components

This commit is contained in:
orosmatthew 2024-03-12 11:49:15 -04:00
parent 37a0cd73bc
commit 247bd010b8
66 changed files with 2709 additions and 900 deletions

14
shared/.eslintignore Normal file
View File

@ -0,0 +1,14 @@
.DS_Store
node_modules
/build
/.svelte-kit
/dist
/package
.env
.env.*
!.env.example
# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock

26
shared/.eslintrc.js Normal file
View File

@ -0,0 +1,26 @@
module.exports = {
env: {
browser: true,
es2021: true,
node: true
},
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
overrides: [
{
env: {
node: true
},
files: ['.eslintrc.{js,cjs}'],
parserOptions: {
sourceType: 'script'
}
}
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module'
},
plugins: ['@typescript-eslint'],
rules: {}
};

2
shared/.prettierignore Normal file
View File

@ -0,0 +1,2 @@
/node_modules
/dist

7
shared/.prettierrc Normal file
View File

@ -0,0 +1,7 @@
{
"tabWidth": 2,
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100
}

View File

@ -1,10 +0,0 @@
{
"name": "extensionWeb",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"devDependencies": {}
}
}
}

View File

@ -1,3 +0,0 @@
{
"name": "contest-monitor-types"
}

View File

@ -1,12 +0,0 @@
{
"compilerOptions": {
"declaration": true,
"composite": true,
"emitDeclarationOnly": true,
"outDir": "./build",
"strict": true,
"target": "ESNext",
"moduleResolution": "Node"
},
"include": ["*.ts"]
}

207
shared/dist/submission-runner/cpp.cjs vendored Normal file
View File

@ -0,0 +1,207 @@
'use strict';
var __createBinding =
(this && this.__createBinding) ||
(Object.create
? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = {
enumerable: true,
get: function () {
return m[k];
}
};
}
Object.defineProperty(o, k2, desc);
}
: function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault =
(this && this.__setModuleDefault) ||
(Object.create
? function (o, v) {
Object.defineProperty(o, 'default', { enumerable: true, value: v });
}
: function (o, v) {
o['default'] = v;
});
var __importStar =
(this && this.__importStar) ||
function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null)
for (var k in mod)
if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k))
__createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
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());
});
};
var __importDefault =
(this && this.__importDefault) ||
function (mod) {
return mod && mod.__esModule ? mod : { default: mod };
};
Object.defineProperty(exports, '__esModule', { value: true });
exports.runCpp = void 0;
const path_1 = require('path');
const child_process_1 = require('child_process');
const util = __importStar(require('util'));
const settings_cjs_1 = require('./settings.cjs');
const tree_kill_1 = __importDefault(require('tree-kill'));
const os = __importStar(require('os'));
const fs = __importStar(require('fs-extra'));
const execPromise = util.promisify(child_process_1.exec);
const runCpp = function (params) {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b;
const tmpDir = os.tmpdir();
const buildDir = (0, path_1.join)(tmpDir, 'bwcontest-cpp');
if (fs.existsSync(buildDir)) {
fs.removeSync(buildDir);
}
fs.mkdirSync(buildDir);
console.log(`- BUILD: ${params.problemName}`);
const configureCommand = `cmake -S ${params.srcDir} -B ${buildDir}`;
try {
yield execPromise(configureCommand);
} catch (e) {
const buildErrorText =
(_a = e === null || e === void 0 ? void 0 : e.toString()) !== null && _a !== void 0
? _a
: 'Unknown build errors.';
console.log('Build errors: ' + buildErrorText);
return {
success: false,
runResult: { kind: 'CompileFailed', resultKindReason: buildErrorText }
};
}
const compileCommand = `cmake --build ${buildDir} --target ${params.problemName}`;
try {
yield execPromise(compileCommand);
} catch (e) {
const buildErrorText =
(_b = e === null || e === void 0 ? void 0 : e.toString()) !== null && _b !== void 0
? _b
: 'Unknown build errors.';
console.log('Build errors: ' + buildErrorText);
return {
success: false,
runResult: { kind: 'CompileFailed', resultKindReason: buildErrorText }
};
}
console.log(`- RUN: ${params.problemName}`);
let runCommand = '';
if (params.cppPlatform === 'VisualStudio') {
runCommand = `${(0, path_1.join)(buildDir, 'Debug', `${params.problemName}.exe`)}`;
} else {
runCommand = `${(0, path_1.join)(buildDir, params.problemName)}`;
}
try {
let outputBuffer = '';
const child = (0, child_process_1.spawn)(runCommand, { shell: true });
child.stdout.setEncoding('utf8');
child.stdout.on('data', (data) => {
outputBuffer += data.toString();
});
child.stderr.setEncoding('utf8');
child.stderr.on('data', (data) => {
outputBuffer += data.toString();
});
const runStartTime = performance.now();
child.stdin.write(params.input);
child.stdin.end();
let timeLimitExceeded = false;
let completedNormally = false;
return {
success: true,
runResult: new Promise((resolve) => {
child.on('close', () => {
completedNormally = !timeLimitExceeded;
const runEndTime = performance.now();
const runtimeMilliseconds = Math.floor(runEndTime - runStartTime);
if (completedNormally) {
clearTimeout(timeoutHandle);
resolve({
kind: 'Completed',
output: outputBuffer,
exitCode: child.exitCode,
runtimeMilliseconds
});
} else {
console.log(`Process terminated, total sandbox time: ${runtimeMilliseconds}ms`);
resolve({
kind: 'TimeLimitExceeded',
output: outputBuffer,
resultKindReason: `Timeout after ${settings_cjs_1.timeoutSeconds} seconds`
});
}
});
const timeoutHandle = setTimeout(() => {
if (completedNormally) {
return;
}
console.log(
`Run timed out after ${settings_cjs_1.timeoutSeconds} seconds, killing process...`
);
timeLimitExceeded = true;
child.stdin.end();
child.stdin.destroy();
child.stdout.destroy();
child.stderr.destroy();
child.kill('SIGKILL');
}, settings_cjs_1.timeoutSeconds * 1000);
}),
killFunc() {
var _a;
if (child.pid !== undefined) {
if (!completedNormally && !timeLimitExceeded) {
(0, tree_kill_1.default)(child.pid);
(_a = params.outputCallback) === null || _a === void 0
? void 0
: _a.call(params, '\n[Manually stopped]');
}
}
}
};
} catch (error) {
return { success: false, runResult: { kind: 'RunError' } };
}
});
};
exports.runCpp = runCpp;
//# sourceMappingURL=cpp.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"file":"cpp.cjs","sourceRoot":"","sources":["../../submission-runner/cpp.cts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA4B;AAC5B,iDAA4C;AAC5C,2CAA6B;AAE7B,iDAAgD;AAChD,0DAA6B;AAC7B,uCAAyB;AACzB,6CAA+B;AAE/B,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,oBAAI,CAAC,CAAC;AAYlC,MAAM,MAAM,GAA8B,UAChD,MAAwB;;;QAExB,MAAM,MAAM,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC;QAC3B,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,MAAM,EAAE,eAAe,CAAC,CAAC;QAC/C,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7B,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QACzB,CAAC;QACD,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAEvB,OAAO,CAAC,GAAG,CAAC,YAAY,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;QAE9C,MAAM,gBAAgB,GAAG,YAAY,MAAM,CAAC,MAAM,OAAO,QAAQ,EAAE,CAAC;QACpE,IAAI,CAAC;YACJ,MAAM,WAAW,CAAC,gBAAgB,CAAC,CAAC;QACrC,CAAC;QAAC,OAAO,CAAC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;YAChB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC;QAC5D,CAAC;IACF,CAAC;CAAA,CAAC;AArHW,QAAA,MAAM,UAqHjB"}

12
shared/dist/submission-runner/cpp.d.cts vendored Normal file
View File

@ -0,0 +1,12 @@
import type { IRunner, IRunnerParams } from './types.cjs';
export type CppPlatform = 'VisualStudio' | 'GCC';
interface IRunnerParamsCpp extends IRunnerParams {
srcDir: string;
problemName: string;
input: string;
cppPlatform: CppPlatform;
outputCallback?: (data: string) => void;
}
export declare const runCpp: IRunner<IRunnerParamsCpp>;
export {};
//# sourceMappingURL=cpp.d.cts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"cpp.d.cts","sourceRoot":"","sources":["../../submission-runner/cpp.cts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAA4B,MAAM,aAAa,CAAC;AAQpF,MAAM,MAAM,WAAW,GAAG,cAAc,GAAG,KAAK,CAAC;AAEjD,UAAU,gBAAiB,SAAQ,aAAa;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,WAAW,CAAC;IACzB,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED,eAAO,MAAM,MAAM,EAAE,OAAO,CAAC,gBAAgB,CAqH5C,CAAC"}

129
shared/dist/submission-runner/csharp.cjs vendored Normal file
View File

@ -0,0 +1,129 @@
'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());
});
};
var __importDefault =
(this && this.__importDefault) ||
function (mod) {
return mod && mod.__esModule ? mod : { default: mod };
};
Object.defineProperty(exports, '__esModule', { value: true });
exports.runCSharp = void 0;
const child_process_1 = require('child_process');
const tree_kill_1 = __importDefault(require('tree-kill'));
const settings_cjs_1 = require('./settings.cjs');
const runCSharp = function (params) {
return __awaiter(this, void 0, void 0, function* () {
console.log(`- RUN: ${params.srcDir}`);
const child = (0, child_process_1.spawn)('dotnet run', { shell: true, cwd: params.srcDir });
try {
let outputBuffer = '';
child.stdout.setEncoding('utf8');
child.stdout.on('data', (data) => {
var _a;
outputBuffer += data.toString();
(_a = params.outputCallback) === null || _a === void 0
? void 0
: _a.call(params, data.toString());
});
child.stderr.setEncoding('utf8');
child.stderr.on('data', (data) => {
var _a;
outputBuffer += data.toString();
(_a = params.outputCallback) === null || _a === void 0
? void 0
: _a.call(params, data.toString());
});
const runStartTime = performance.now();
child.stdin.write(params.input);
child.stdin.end();
let timeLimitExceeded = false;
let completedNormally = false;
return {
success: true,
runResult: new Promise((resolve) => {
child.on('close', () => {
completedNormally = !timeLimitExceeded;
const runEndTime = performance.now();
const runtimeMilliseconds = Math.floor(runEndTime - runStartTime);
if (completedNormally) {
clearTimeout(timeoutHandle);
resolve({
kind: 'Completed',
output: outputBuffer,
exitCode: child.exitCode,
runtimeMilliseconds
});
} else {
console.log(`Process terminated, total sandbox time: ${runtimeMilliseconds}ms`);
resolve({
kind: 'TimeLimitExceeded',
output: outputBuffer,
resultKindReason: `Timeout after ${settings_cjs_1.timeoutSeconds} seconds`
});
}
});
const timeoutHandle = setTimeout(() => {
if (completedNormally) {
return;
}
console.log(
`Run timed out after ${settings_cjs_1.timeoutSeconds} seconds, killing process...`
);
timeLimitExceeded = true;
child.stdin.end();
child.stdin.destroy();
child.stdout.destroy();
child.stderr.destroy();
if (child.pid !== undefined) {
(0, tree_kill_1.default)(child.pid);
}
}, settings_cjs_1.timeoutSeconds * 1000);
}),
killFunc() {
var _a;
if (child.pid !== undefined) {
if (!completedNormally && !timeLimitExceeded) {
(0, tree_kill_1.default)(child.pid);
(_a = params.outputCallback) === null || _a === void 0
? void 0
: _a.call(params, '\n[Manually stopped]');
}
}
}
};
} catch (error) {
return { success: false, runResult: { kind: 'RunError' } };
}
});
};
exports.runCSharp = runCSharp;
//# sourceMappingURL=csharp.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"file":"csharp.cjs","sourceRoot":"","sources":["../../submission-runner/csharp.cts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iDAAsC;AACtC,0DAA6B;AAE7B,iDAAgD;AAEzC,MAAM,SAAS,GAAY,UAAgB,MAIjD;;QACA,OAAO,CAAC,GAAG,CAAC,UAAU,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QACvC,MAAM,KAAK,GAAG,IAAA,qBAAK,EAAC,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QAEvE,IAAI,CAAC;YACJ,IAAI,YAAY,GAAG,EAAE,CAAC;YACtB,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YACjC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;;gBAChC,YAAY,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAChC,MAAA,MAAM,CAAC,cAAc,uDAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC1C,CAAC,CAAC,CAAC;YACH,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YACjC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;;gBAChC,YAAY,IAAI,IAAI,CAAC,QAAQ,EAAE,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I,iBAAiB,EAAE,CAAC;4BACvB,OAAO;wBACR,CAAC;wBAED,OAAO,CAAC,GAAG,CAAC,uBAAuB,6BAAc,8BAA8B,CAAC,CAAC;wBACjF,iBAAiB,GAAG,IAAI,CAAC;wBAEzB,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;wBAClB,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;wBACtB,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;wBACvB,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;wBACvB,IAAI,KAAK,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;4BAC7B,IAAA,mBAAI,EAAC,KAAK,CAAC,GAAG,CAAC,CAAC;wBACjB,CAAC;oBACF,CAAC,EAAE,6BAAc,GAAG,IAAI,CAAC,CAAC;gBAC3B,CAAC,CAAC;gBACF,QAAQ;;oBACP,IAAI,KAAK,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;wBAC7B,IAAI,CAAC,iBAAiB,IAAI,CAAC,iBAAiB,EAAE,CAAC;4BAC9C,IAAA,mBAAI,EAAC,KAAK,CAAC,GAAG,CAAC,CAAC;4BAChB,MAAA,MAAM,CAAC,cAAc,uDAAG,sBAAsB,CAAC,CAAC;wBACjD,CAAC;oBACF,CAAC;gBACF,CAAC;aACD,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC;QAC5D,CAAC;IACF,CAAC;CAAA,CAAC;AApFW,QAAA,SAAS,aAoFpB"}

View File

@ -0,0 +1,3 @@
import type { IRunner } from './types.cjs';
export declare const runCSharp: IRunner;
//# sourceMappingURL=csharp.d.cts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"csharp.d.cts","sourceRoot":"","sources":["../../submission-runner/csharp.cts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAA4B,MAAM,aAAa,CAAC;AAGrE,eAAO,MAAM,SAAS,EAAE,OAoFvB,CAAC"}

183
shared/dist/submission-runner/java.cjs vendored Normal file
View File

@ -0,0 +1,183 @@
'use strict';
var __createBinding =
(this && this.__createBinding) ||
(Object.create
? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = {
enumerable: true,
get: function () {
return m[k];
}
};
}
Object.defineProperty(o, k2, desc);
}
: function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault =
(this && this.__setModuleDefault) ||
(Object.create
? function (o, v) {
Object.defineProperty(o, 'default', { enumerable: true, value: v });
}
: function (o, v) {
o['default'] = v;
});
var __importStar =
(this && this.__importStar) ||
function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null)
for (var k in mod)
if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k))
__createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
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.runJava = void 0;
const path_1 = require('path');
const child_process_1 = require('child_process');
const util = __importStar(require('util'));
const settings_cjs_1 = require('./settings.cjs');
const kill = require('tree-kill');
const execPromise = util.promisify(child_process_1.exec);
const runJava = function (params) {
return __awaiter(this, void 0, void 0, function* () {
var _a;
console.log(`- BUILD: ${params.mainFile}`);
const compileCommand = `javac -cp ${(0, path_1.join)(params.srcDir, 'src')} ${params.mainFile} -d ${(0, path_1.join)(params.srcDir, 'build')}`;
try {
yield execPromise(compileCommand);
} catch (e) {
const buildErrorText =
(_a = e === null || e === void 0 ? void 0 : e.toString()) !== null && _a !== void 0
? _a
: 'Unknown build errors.';
console.log('Build errors: ' + buildErrorText);
return {
success: false,
runResult: { kind: 'CompileFailed', resultKindReason: buildErrorText }
};
}
console.log(`- RUN: ${params.mainClass}`);
const runCommand = `java -cp "${(0, path_1.join)(params.srcDir, 'build')}" ${params.mainClass}`;
try {
let outputBuffer = '';
const child = (0, child_process_1.spawn)(runCommand, { shell: true });
child.stdout.setEncoding('utf8');
child.stdout.on('data', (data) => {
var _a;
outputBuffer += data.toString();
(_a = params.outputCallback) === null || _a === void 0
? void 0
: _a.call(params, data.toString());
});
child.stderr.setEncoding('utf8');
child.stderr.on('data', (data) => {
var _a;
outputBuffer += data.toString();
(_a = params.outputCallback) === null || _a === void 0
? void 0
: _a.call(params, data.toString());
});
const runStartTime = performance.now();
child.stdin.write(params.input);
child.stdin.end();
let timeLimitExceeded = false;
let completedNormally = false;
return {
success: true,
runResult: new Promise((resolve) => {
child.on('close', () => {
completedNormally = !timeLimitExceeded;
const runEndTime = performance.now();
const runtimeMilliseconds = Math.floor(runEndTime - runStartTime);
if (completedNormally) {
clearTimeout(timeoutHandle);
resolve({
kind: 'Completed',
output: outputBuffer,
exitCode: child.exitCode,
runtimeMilliseconds
});
} else {
console.log(`Process terminated, total sandbox time: ${runtimeMilliseconds}ms`);
resolve({
kind: 'TimeLimitExceeded',
output: outputBuffer,
resultKindReason: `Timeout after ${settings_cjs_1.timeoutSeconds} seconds`
});
}
});
const timeoutHandle = setTimeout(() => {
if (completedNormally) {
return;
}
console.log(
`Run timed out after ${settings_cjs_1.timeoutSeconds} seconds, killing process...`
);
timeLimitExceeded = true;
child.stdin.end();
child.stdin.destroy();
child.stdout.destroy();
child.stderr.destroy();
child.kill('SIGKILL');
}, settings_cjs_1.timeoutSeconds * 1000);
}),
killFunc() {
var _a;
if (child.pid !== undefined) {
if (!completedNormally && !timeLimitExceeded) {
kill(child.pid);
(_a = params.outputCallback) === null || _a === void 0
? void 0
: _a.call(params, '\n[Manually stopped]');
}
}
}
};
} catch (error) {
return { success: false, runResult: { kind: 'RunError' } };
}
});
};
exports.runJava = runJava;
//# sourceMappingURL=java.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"file":"java.cjs","sourceRoot":"","sources":["../../submission-runner/java.cts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA4B;AAC5B,iDAA4C;AAC5C,2CAA6B;AAE7B,iDAAgD;AAEhD,kCAAmC;AAEnC,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,oBAAI,CAAC,CAAC;AAUlC,MAAM,OAAO,GAA+B,UAClD,MAAyB;;;QAEzB,OAAO,CAAC,GAAG,CAAC,YAAY,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC3C,MAAM,cAAc,GAAG,aAAa,IAAA,WAAI,EAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,QAAQ,OAAO,IAAA,WAAI,EAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;QAEvH,IAAI,CAAC;YACJ,MAAM,WAAW,CAAC,cAAc,CAAC,CAAC;QACnC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,MAAM,cAAc,GAAG,MAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,QAAQ,EAAE,mCAAI,uBAAuB,CAAC;YAChE,OAAO,CAAC,GAAG,CAAC,gBAAgB,GAAG,cAAc,CAAC,CAAC;YAC/C,OAAO;gBACN,OAAO,EAAE,KAAK;gBACd,SAAS,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,gBAAgB,EAAE,cAAc,EAAE;aACtE,CAAC;QACH,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C,EAAE,6BAAc,GAAG,IAAI,CAAC,CAAC;gBAC3B,CAAC,CAAC;gBACF,QAAQ;;oBACP,IAAI,KAAK,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;wBAC7B,IAAI,CAAC,iBAAiB,IAAI,CAAC,iBAAiB,EAAE,CAAC;4BAC9C,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;4BAChB,MAAA,MAAM,CAAC,cAAc,uDAAG,sBAAsB,CAAC,CAAC;wBACjD,CAAC;oBACF,CAAC;gBACF,CAAC;aACD,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC;QAC5D,CAAC;IACF,CAAC;CAAA,CAAC;AA/FW,QAAA,OAAO,WA+FlB"}

View File

@ -1,11 +1,11 @@
import type { IRunner, IRunnerParams } from './types.cjs'; import type { IRunner, IRunnerParams } from './types.cjs';
interface IRunnerParamsJava extends IRunnerParams { interface IRunnerParamsJava extends IRunnerParams {
srcDir: string; srcDir: string;
mainFile: string; mainFile: string;
mainClass: string; mainClass: string;
input: string; input: string;
outputCallback?: (data: string) => void; outputCallback?: (data: string) => void;
} }
export declare const runJava: IRunner<IRunnerParamsJava>; export declare const runJava: IRunner<IRunnerParamsJava>;
export {}; export {};
//# sourceMappingURL=java.d.cts.map //# sourceMappingURL=java.d.cts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"java.d.cts","sourceRoot":"","sources":["../../submission-runner/java.cts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAA4B,MAAM,aAAa,CAAC;AAOpF,UAAU,iBAAkB,SAAQ,aAAa;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED,eAAO,MAAM,OAAO,EAAE,OAAO,CAAC,iBAAiB,CA+F9C,CAAC"}

View File

@ -0,0 +1,5 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
exports.timeoutSeconds = void 0;
exports.timeoutSeconds = 30;
//# sourceMappingURL=settings.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"file":"settings.cjs","sourceRoot":"","sources":["../../submission-runner/settings.cts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG,EAAE,CAAC"}

View File

@ -1,2 +1,2 @@
export declare const timeoutSeconds = 30; export declare const timeoutSeconds = 30;
//# sourceMappingURL=settings.d.cts.map //# sourceMappingURL=settings.d.cts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"settings.d.cts","sourceRoot":"","sources":["../../submission-runner/settings.cts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,KAAK,CAAC"}

21
shared/dist/submission-runner/types.cjs vendored Normal file
View File

@ -0,0 +1,21 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
exports.RunResultZod = void 0;
const zod_1 = require('zod');
const RunResultKind = zod_1.z.enum([
'CompileFailed',
'TimeLimitExceeded',
'Completed',
'SandboxError',
'RunError'
]);
exports.RunResultZod = zod_1.z
.object({
kind: RunResultKind,
output: zod_1.z.string().optional(),
exitCode: zod_1.z.number().optional(),
runtimeMilliseconds: zod_1.z.number().optional(),
resultKindReason: zod_1.z.string().optional()
})
.strict();
//# sourceMappingURL=types.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../submission-runner/types.cts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,MAAM,aAAa,GAAG,OAAC,CAAC,IAAI,CAAC;IAC5B,eAAe;IACf,mBAAmB;IACnB,WAAW;IACX,cAAc;IACd,UAAU;CACV,CAAC,CAAC;AAIU,QAAA,YAAY,GAAG,OAAC;KAC3B,MAAM,CAAC;IACP,IAAI,EAAE,aAAa;IACnB,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,mBAAmB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC1C,gBAAgB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACvC,CAAC;KACD,MAAM,EAAE,CAAC"}

View File

@ -0,0 +1,53 @@
import { z } from 'zod';
declare const RunResultKind: z.ZodEnum<
['CompileFailed', 'TimeLimitExceeded', 'Completed', 'SandboxError', 'RunError']
>;
export type RunResultKind = z.infer<typeof RunResultKind>;
export declare const RunResultZod: z.ZodObject<
{
kind: z.ZodEnum<
['CompileFailed', 'TimeLimitExceeded', 'Completed', 'SandboxError', 'RunError']
>;
output: z.ZodOptional<z.ZodString>;
exitCode: z.ZodOptional<z.ZodNumber>;
runtimeMilliseconds: z.ZodOptional<z.ZodNumber>;
resultKindReason: z.ZodOptional<z.ZodString>;
},
'strict',
z.ZodTypeAny,
{
kind: 'CompileFailed' | 'TimeLimitExceeded' | 'Completed' | 'SandboxError' | 'RunError';
output?: string | undefined;
exitCode?: number | undefined;
runtimeMilliseconds?: number | undefined;
resultKindReason?: string | undefined;
},
{
kind: 'CompileFailed' | 'TimeLimitExceeded' | 'Completed' | 'SandboxError' | 'RunError';
output?: string | undefined;
exitCode?: number | undefined;
runtimeMilliseconds?: number | undefined;
resultKindReason?: string | undefined;
}
>;
export type RunResult = z.infer<typeof RunResultZod>;
export interface IRunnerParams {
srcDir: string;
input: string;
outputCallback?: (data: string) => void;
}
export type IRunnerReturn =
| {
success: true;
killFunc: () => void;
runResult: Promise<RunResult>;
}
| {
success: false;
runResult: RunResult;
};
export type IRunner<T extends IRunnerParams = IRunnerParams> = (
params: T
) => Promise<IRunnerReturn>;
export {};
//# sourceMappingURL=types.d.cts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../submission-runner/types.cts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,aAAa,4FAMjB,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAE1D,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;EAQf,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAErD,MAAM,WAAW,aAAa;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED,MAAM,MAAM,aAAa,GACtB;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,IAAI,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;CAAE,GACtE;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,SAAS,EAAE,SAAS,CAAA;CAAE,CAAC;AAE5C,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,IAAI,CAC9D,MAAM,EAAE,CAAC,KACL,OAAO,CAAC,aAAa,CAAC,CAAC"}

1
shared/dist/tsconfig.tsbuildinfo vendored Normal file

File diff suppressed because one or more lines are too long

1765
shared/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

21
shared/package.json Normal file
View File

@ -0,0 +1,21 @@
{
"name": "bwcontest-shared",
"scripts": {
"build": "tsc",
"format": "prettier --write .",
"lint": "prettier --check . && eslint .",
"check": "tsc -noEmit"
},
"devDependencies": {
"@types/fs-extra": "^11.0.4",
"@types/node": "20.x",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"eslint": "^8.57.0",
"fs-extra": "^11.2.0",
"prettier": "^3.2.5",
"tree-kill": "^1.2.2",
"typescript": "^5.4.2",
"zod": "^3.22.4"
}
}

View File

@ -1,148 +1,139 @@
import { join } from "path"; import { join } from 'path';
import { exec, spawn } from "child_process"; import { exec, spawn } from 'child_process';
import * as util from "util"; import * as util from 'util';
import type { import type { IRunner, IRunnerParams, IRunnerReturn, RunResult } from './types.cjs';
IRunner, import { timeoutSeconds } from './settings.cjs';
IRunnerParams, import kill from 'tree-kill';
IRunnerReturn, import * as os from 'os';
RunResult, import * as fs from 'fs-extra';
} from "./types.cjs";
import { timeoutSeconds } from "./settings.cjs";
import kill from "tree-kill";
import * as os from "os";
import * as fs from "fs-extra";
const execPromise = util.promisify(exec); const execPromise = util.promisify(exec);
export type CppPlatform = "VisualStudio" | "GCC"; export type CppPlatform = 'VisualStudio' | 'GCC';
interface IRunnerParamsCpp extends IRunnerParams { interface IRunnerParamsCpp extends IRunnerParams {
srcDir: string; srcDir: string;
problemName: string; problemName: string;
input: string; input: string;
cppPlatform: CppPlatform; cppPlatform: CppPlatform;
outputCallback?: (data: string) => void; outputCallback?: (data: string) => void;
} }
export const runCpp: IRunner<IRunnerParamsCpp> = async function ( export const runCpp: IRunner<IRunnerParamsCpp> = async function (
params: IRunnerParamsCpp params: IRunnerParamsCpp
): Promise<IRunnerReturn> { ): Promise<IRunnerReturn> {
const tmpDir = os.tmpdir(); const tmpDir = os.tmpdir();
const buildDir = join(tmpDir, "bwcontest-cpp"); const buildDir = join(tmpDir, 'bwcontest-cpp');
if (fs.existsSync(buildDir)) { if (fs.existsSync(buildDir)) {
fs.removeSync(buildDir); fs.removeSync(buildDir);
} }
fs.mkdirSync(buildDir); fs.mkdirSync(buildDir);
console.log(`- BUILD: ${params.problemName}`); console.log(`- BUILD: ${params.problemName}`);
const configureCommand = `cmake -S ${params.srcDir} -B ${buildDir}`; const configureCommand = `cmake -S ${params.srcDir} -B ${buildDir}`;
try { try {
await execPromise(configureCommand); await execPromise(configureCommand);
} catch (e) { } catch (e) {
const buildErrorText = e?.toString() ?? "Unknown build errors."; const buildErrorText = e?.toString() ?? 'Unknown build errors.';
console.log("Build errors: " + buildErrorText); console.log('Build errors: ' + buildErrorText);
return { return {
success: false, success: false,
runResult: { kind: "CompileFailed", resultKindReason: buildErrorText }, runResult: { kind: 'CompileFailed', resultKindReason: buildErrorText }
}; };
} }
const compileCommand = `cmake --build ${buildDir} --target ${params.problemName}`; const compileCommand = `cmake --build ${buildDir} --target ${params.problemName}`;
try { try {
await execPromise(compileCommand); await execPromise(compileCommand);
} catch (e) { } catch (e) {
const buildErrorText = e?.toString() ?? "Unknown build errors."; const buildErrorText = e?.toString() ?? 'Unknown build errors.';
console.log("Build errors: " + buildErrorText); console.log('Build errors: ' + buildErrorText);
return { return {
success: false, success: false,
runResult: { kind: "CompileFailed", resultKindReason: buildErrorText }, runResult: { kind: 'CompileFailed', resultKindReason: buildErrorText }
}; };
} }
console.log(`- RUN: ${params.problemName}`); console.log(`- RUN: ${params.problemName}`);
let runCommand = ""; let runCommand = '';
if (params.cppPlatform === "VisualStudio") { if (params.cppPlatform === 'VisualStudio') {
runCommand = `${join(buildDir, "Debug", `${params.problemName}.exe`)}`; runCommand = `${join(buildDir, 'Debug', `${params.problemName}.exe`)}`;
} else { } else {
runCommand = `${join(buildDir, params.problemName)}`; runCommand = `${join(buildDir, params.problemName)}`;
} }
try { try {
let outputBuffer = ""; let outputBuffer = '';
const child = spawn(runCommand, { shell: true }); const child = spawn(runCommand, { shell: true });
child.stdout.setEncoding("utf8"); child.stdout.setEncoding('utf8');
child.stdout.on("data", (data) => { child.stdout.on('data', (data) => {
outputBuffer += data.toString(); outputBuffer += data.toString();
}); });
child.stderr.setEncoding("utf8"); child.stderr.setEncoding('utf8');
child.stderr.on("data", (data) => { child.stderr.on('data', (data) => {
outputBuffer += data.toString(); outputBuffer += data.toString();
}); });
const runStartTime = performance.now(); const runStartTime = performance.now();
child.stdin.write(params.input); child.stdin.write(params.input);
child.stdin.end(); child.stdin.end();
let timeLimitExceeded = false; let timeLimitExceeded = false;
let completedNormally = false; let completedNormally = false;
return { return {
success: true, success: true,
runResult: new Promise<RunResult>((resolve) => { runResult: new Promise<RunResult>((resolve) => {
child.on("close", () => { child.on('close', () => {
completedNormally = !timeLimitExceeded; completedNormally = !timeLimitExceeded;
const runEndTime = performance.now(); const runEndTime = performance.now();
const runtimeMilliseconds = Math.floor(runEndTime - runStartTime); const runtimeMilliseconds = Math.floor(runEndTime - runStartTime);
if (completedNormally) { if (completedNormally) {
clearTimeout(timeoutHandle); clearTimeout(timeoutHandle);
resolve({ resolve({
kind: "Completed", kind: 'Completed',
output: outputBuffer, output: outputBuffer,
exitCode: child.exitCode!, exitCode: child.exitCode!,
runtimeMilliseconds, runtimeMilliseconds
}); });
} else { } else {
console.log( console.log(`Process terminated, total sandbox time: ${runtimeMilliseconds}ms`);
`Process terminated, total sandbox time: ${runtimeMilliseconds}ms` resolve({
); kind: 'TimeLimitExceeded',
resolve({ output: outputBuffer,
kind: "TimeLimitExceeded", resultKindReason: `Timeout after ${timeoutSeconds} seconds`
output: outputBuffer, });
resultKindReason: `Timeout after ${timeoutSeconds} seconds`, }
}); });
}
});
const timeoutHandle = setTimeout(() => { const timeoutHandle = setTimeout(() => {
if (completedNormally) { if (completedNormally) {
return; return;
} }
console.log( console.log(`Run timed out after ${timeoutSeconds} seconds, killing process...`);
`Run timed out after ${timeoutSeconds} seconds, killing process...` timeLimitExceeded = true;
);
timeLimitExceeded = true;
child.stdin.end(); child.stdin.end();
child.stdin.destroy(); child.stdin.destroy();
child.stdout.destroy(); child.stdout.destroy();
child.stderr.destroy(); child.stderr.destroy();
child.kill("SIGKILL"); child.kill('SIGKILL');
}, timeoutSeconds * 1000); }, timeoutSeconds * 1000);
}), }),
killFunc() { killFunc() {
if (child.pid !== undefined) { if (child.pid !== undefined) {
if (!completedNormally && !timeLimitExceeded) { if (!completedNormally && !timeLimitExceeded) {
kill(child.pid); kill(child.pid);
params.outputCallback?.("\n[Manually stopped]"); params.outputCallback?.('\n[Manually stopped]');
} }
} }
}, }
}; };
} catch (error) { } catch (error) {
return { success: false, runResult: { kind: "RunError" } }; return { success: false, runResult: { kind: 'RunError' } };
} }
}; };

View File

@ -1,94 +1,90 @@
import { spawn } from "child_process"; import { spawn } from 'child_process';
import kill from "tree-kill"; import kill from 'tree-kill';
import type { IRunner, IRunnerReturn, RunResult } from "./types.cjs"; import type { IRunner, IRunnerReturn, RunResult } from './types.cjs';
import { timeoutSeconds } from "./settings.cjs"; import { timeoutSeconds } from './settings.cjs';
export const runCSharp: IRunner = async function (params: { export const runCSharp: IRunner = async function (params: {
srcDir: string; srcDir: string;
input: string; input: string;
outputCallback?: (data: string) => void; outputCallback?: (data: string) => void;
}): Promise<IRunnerReturn> { }): Promise<IRunnerReturn> {
console.log(`- RUN: ${params.srcDir}`); console.log(`- RUN: ${params.srcDir}`);
const child = spawn("dotnet run", { shell: true, cwd: params.srcDir }); const child = spawn('dotnet run', { shell: true, cwd: params.srcDir });
try { try {
let outputBuffer = ""; let outputBuffer = '';
child.stdout.setEncoding("utf8"); child.stdout.setEncoding('utf8');
child.stdout.on("data", (data) => { child.stdout.on('data', (data) => {
outputBuffer += data.toString(); outputBuffer += data.toString();
params.outputCallback?.(data.toString()); params.outputCallback?.(data.toString());
}); });
child.stderr.setEncoding("utf8"); child.stderr.setEncoding('utf8');
child.stderr.on("data", (data) => { child.stderr.on('data', (data) => {
outputBuffer += data.toString(); outputBuffer += data.toString();
params.outputCallback?.(data.toString()); params.outputCallback?.(data.toString());
}); });
const runStartTime = performance.now(); const runStartTime = performance.now();
child.stdin.write(params.input); child.stdin.write(params.input);
child.stdin.end(); child.stdin.end();
let timeLimitExceeded = false; let timeLimitExceeded = false;
let completedNormally = false; let completedNormally = false;
return { return {
success: true, success: true,
runResult: new Promise<RunResult>((resolve) => { runResult: new Promise<RunResult>((resolve) => {
child.on("close", () => { child.on('close', () => {
completedNormally = !timeLimitExceeded; completedNormally = !timeLimitExceeded;
const runEndTime = performance.now(); const runEndTime = performance.now();
const runtimeMilliseconds = Math.floor(runEndTime - runStartTime); const runtimeMilliseconds = Math.floor(runEndTime - runStartTime);
if (completedNormally) { if (completedNormally) {
clearTimeout(timeoutHandle); clearTimeout(timeoutHandle);
resolve({ resolve({
kind: "Completed", kind: 'Completed',
output: outputBuffer, output: outputBuffer,
exitCode: child.exitCode!, exitCode: child.exitCode!,
runtimeMilliseconds, runtimeMilliseconds
}); });
} else { } else {
console.log( console.log(`Process terminated, total sandbox time: ${runtimeMilliseconds}ms`);
`Process terminated, total sandbox time: ${runtimeMilliseconds}ms` resolve({
); kind: 'TimeLimitExceeded',
resolve({ output: outputBuffer,
kind: "TimeLimitExceeded", resultKindReason: `Timeout after ${timeoutSeconds} seconds`
output: outputBuffer, });
resultKindReason: `Timeout after ${timeoutSeconds} seconds`, }
}); });
}
});
const timeoutHandle = setTimeout(() => { const timeoutHandle = setTimeout(() => {
if (completedNormally) { if (completedNormally) {
return; return;
} }
console.log( console.log(`Run timed out after ${timeoutSeconds} seconds, killing process...`);
`Run timed out after ${timeoutSeconds} seconds, killing process...` timeLimitExceeded = true;
);
timeLimitExceeded = true;
child.stdin.end(); child.stdin.end();
child.stdin.destroy(); child.stdin.destroy();
child.stdout.destroy(); child.stdout.destroy();
child.stderr.destroy(); child.stderr.destroy();
if (child.pid !== undefined) { if (child.pid !== undefined) {
kill(child.pid); kill(child.pid);
} }
}, timeoutSeconds * 1000); }, timeoutSeconds * 1000);
}), }),
killFunc() { killFunc() {
if (child.pid !== undefined) { if (child.pid !== undefined) {
if (!completedNormally && !timeLimitExceeded) { if (!completedNormally && !timeLimitExceeded) {
kill(child.pid); kill(child.pid);
params.outputCallback?.("\n[Manually stopped]"); params.outputCallback?.('\n[Manually stopped]');
} }
} }
}, }
}; };
} catch (error) { } catch (error) {
return { success: false, runResult: { kind: "RunError" } }; return { success: false, runResult: { kind: 'RunError' } };
} }
}; };

View File

@ -1,157 +0,0 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
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.runCpp = void 0;
const path_1 = require("path");
const child_process_1 = require("child_process");
const util = __importStar(require("util"));
const settings_cjs_1 = require("./settings.cjs");
const kill = __importStar(require("kill"));
const os = __importStar(require("os"));
const fs = __importStar(require("fs-extra"));
const execPromise = util.promisify(child_process_1.exec);
const runCpp = function (params) {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b;
const tmpDir = os.tmpdir();
const buildDir = (0, path_1.join)(tmpDir, "bwcontest-cpp");
if (fs.existsSync(buildDir)) {
fs.removeSync(buildDir);
}
fs.mkdirSync(buildDir);
console.log(`- BUILD: ${params.problemName}`);
const configureCommand = `cmake -S ${params.srcDir} -B ${buildDir}`;
try {
yield execPromise(configureCommand);
}
catch (e) {
const buildErrorText = (_a = e === null || e === void 0 ? void 0 : e.toString()) !== null && _a !== void 0 ? _a : "Unknown build errors.";
console.log("Build errors: " + buildErrorText);
return {
success: false,
runResult: { kind: "CompileFailed", resultKindReason: buildErrorText },
};
}
const compileCommand = `cmake --build ${buildDir} --target ${params.problemName}`;
try {
yield execPromise(compileCommand);
}
catch (e) {
const buildErrorText = (_b = e === null || e === void 0 ? void 0 : e.toString()) !== null && _b !== void 0 ? _b : "Unknown build errors.";
console.log("Build errors: " + buildErrorText);
return {
success: false,
runResult: { kind: "CompileFailed", resultKindReason: buildErrorText },
};
}
console.log(`- RUN: ${params.problemName}`);
let runCommand = "";
if (params.cppPlatform === "VisualStudio") {
runCommand = `${(0, path_1.join)(buildDir, "Debug", `${params.problemName}.exe`)}`;
}
else {
runCommand = `${(0, path_1.join)(buildDir, params.problemName)}`;
}
try {
let outputBuffer = "";
const child = (0, child_process_1.spawn)(runCommand, { shell: true });
child.stdout.setEncoding("utf8");
child.stdout.on("data", (data) => {
outputBuffer += data.toString();
});
child.stderr.setEncoding("utf8");
child.stderr.on("data", (data) => {
outputBuffer += data.toString();
});
const runStartTime = performance.now();
child.stdin.write(params.input);
child.stdin.end();
let timeLimitExceeded = false;
let completedNormally = false;
return {
success: true,
runResult: new Promise((resolve) => {
child.on("close", () => {
completedNormally = !timeLimitExceeded;
const runEndTime = performance.now();
const runtimeMilliseconds = Math.floor(runEndTime - runStartTime);
if (completedNormally) {
clearTimeout(timeoutHandle);
resolve({
kind: "Completed",
output: outputBuffer,
exitCode: child.exitCode,
runtimeMilliseconds,
});
}
else {
console.log(`Process terminated, total sandbox time: ${runtimeMilliseconds}ms`);
resolve({
kind: "TimeLimitExceeded",
output: outputBuffer,
resultKindReason: `Timeout after ${settings_cjs_1.timeoutSeconds} seconds`,
});
}
});
const timeoutHandle = setTimeout(() => {
if (completedNormally) {
return;
}
console.log(`Run timed out after ${settings_cjs_1.timeoutSeconds} seconds, killing process...`);
timeLimitExceeded = true;
child.stdin.end();
child.stdin.destroy();
child.stdout.destroy();
child.stderr.destroy();
child.kill("SIGKILL");
}, settings_cjs_1.timeoutSeconds * 1000);
}),
killFunc() {
var _a;
if (child.pid !== undefined) {
if (!completedNormally && !timeLimitExceeded) {
kill(child.pid);
(_a = params.outputCallback) === null || _a === void 0 ? void 0 : _a.call(params, "\n[Manually stopped]");
}
}
},
};
}
catch (error) {
return { success: false, runResult: { kind: "RunError" } };
}
});
};
exports.runCpp = runCpp;
//# sourceMappingURL=cpp.cjs.map

View File

@ -1 +0,0 @@
{"version":3,"file":"cpp.cjs","sourceRoot":"","sources":["../cpp.cts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA4B;AAC5B,iDAA4C;AAC5C,2CAA6B;AAO7B,iDAAgD;AAChD,2CAA6B;AAC7B,uCAAyB;AACzB,6CAA+B;AAE/B,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,oBAAI,CAAC,CAAC;AAYlC,MAAM,MAAM,GAA8B,UAC/C,MAAwB;;;QAExB,MAAM,MAAM,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC;QAC3B,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,MAAM,EAAE,eAAe,CAAC,CAAC;QAC/C,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC1B,CAAC;QACD,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAEvB,OAAO,CAAC,GAAG,CAAC,YAAY,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;QAE9C,MAAM,gBAAgB,GAAG,YAAY,MAAM,CAAC,MAAM,OAAO,QAAQ,EAAE,CAAC;QACpE,IAAI,CA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BACH,CAAC;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC;QAC7D,CAAC;IACH,CAAC;CAAA,CAAC;AAzHW,QAAA,MAAM,UAyHjB"}

View File

@ -1,12 +0,0 @@
import type { IRunner, IRunnerParams } from "./types.cjs";
export type CppPlatform = "VisualStudio" | "GCC";
interface IRunnerParamsCpp extends IRunnerParams {
srcDir: string;
problemName: string;
input: string;
cppPlatform: CppPlatform;
outputCallback?: (data: string) => void;
}
export declare const runCpp: IRunner<IRunnerParamsCpp>;
export {};
//# sourceMappingURL=cpp.d.cts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"cpp.d.cts","sourceRoot":"","sources":["../cpp.cts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,OAAO,EACP,aAAa,EAGd,MAAM,aAAa,CAAC;AAQrB,MAAM,MAAM,WAAW,GAAG,cAAc,GAAG,KAAK,CAAC;AAEjD,UAAU,gBAAiB,SAAQ,aAAa;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,WAAW,CAAC;IACzB,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAED,eAAO,MAAM,MAAM,EAAE,OAAO,CAAC,gBAAgB,CAyH5C,CAAC"}

View File

@ -1,119 +0,0 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
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.runCSharp = void 0;
const child_process_1 = require("child_process");
const kill = __importStar(require("tree-kill"));
const settings_cjs_1 = require("./settings.cjs");
const runCSharp = function (params) {
return __awaiter(this, void 0, void 0, function* () {
console.log(`- RUN: ${params.srcDir}`);
const child = (0, child_process_1.spawn)("dotnet run", { shell: true, cwd: params.srcDir });
try {
let outputBuffer = "";
child.stdout.setEncoding("utf8");
child.stdout.on("data", (data) => {
var _a;
outputBuffer += data.toString();
(_a = params.outputCallback) === null || _a === void 0 ? void 0 : _a.call(params, data.toString());
});
child.stderr.setEncoding("utf8");
child.stderr.on("data", (data) => {
var _a;
outputBuffer += data.toString();
(_a = params.outputCallback) === null || _a === void 0 ? void 0 : _a.call(params, data.toString());
});
const runStartTime = performance.now();
child.stdin.write(params.input);
child.stdin.end();
let timeLimitExceeded = false;
let completedNormally = false;
return {
success: true,
runResult: new Promise((resolve) => {
child.on("close", () => {
completedNormally = !timeLimitExceeded;
const runEndTime = performance.now();
const runtimeMilliseconds = Math.floor(runEndTime - runStartTime);
if (completedNormally) {
clearTimeout(timeoutHandle);
resolve({
kind: "Completed",
output: outputBuffer,
exitCode: child.exitCode,
runtimeMilliseconds,
});
}
else {
console.log(`Process terminated, total sandbox time: ${runtimeMilliseconds}ms`);
resolve({
kind: "TimeLimitExceeded",
output: outputBuffer,
resultKindReason: `Timeout after ${settings_cjs_1.timeoutSeconds} seconds`,
});
}
});
const timeoutHandle = setTimeout(() => {
if (completedNormally) {
return;
}
console.log(`Run timed out after ${settings_cjs_1.timeoutSeconds} seconds, killing process...`);
timeLimitExceeded = true;
child.stdin.end();
child.stdin.destroy();
child.stdout.destroy();
child.stderr.destroy();
if (child.pid !== undefined) {
kill(child.pid);
}
}, settings_cjs_1.timeoutSeconds * 1000);
}),
killFunc() {
var _a;
if (child.pid !== undefined) {
if (!completedNormally && !timeLimitExceeded) {
kill(child.pid);
(_a = params.outputCallback) === null || _a === void 0 ? void 0 : _a.call(params, "\n[Manually stopped]");
}
}
},
};
}
catch (error) {
return { success: false, runResult: { kind: "RunError" } };
}
});
};
exports.runCSharp = runCSharp;
//# sourceMappingURL=csharp.cjs.map

View File

@ -1 +0,0 @@
{"version":3,"file":"csharp.cjs","sourceRoot":"","sources":["../csharp.cts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAsC;AACtC,gDAAkC;AAElC,iDAAgD;AAEzC,MAAM,SAAS,GAAY,UAAgB,MAIjD;;QACC,OAAO,CAAC,GAAG,CAAC,UAAU,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QACvC,MAAM,KAAK,GAAG,IAAA,qBAAK,EAAC,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QAEvE,IAAI,CAAC;YACH,IAAI,YAAY,GAAG,EAAE,CAAC;YACtB,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YACjC,KAAK,CAAC,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OAAO,KAAK,EAAE,CAAC;YACf,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC;QAC7D,CAAC;IACH,CAAC;CAAA,CAAC;AAxFW,QAAA,SAAS,aAwFpB"}

View File

@ -1,3 +0,0 @@
import type { IRunner } from "./types.cjs";
export declare const runCSharp: IRunner;
//# sourceMappingURL=csharp.d.cts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"csharp.d.cts","sourceRoot":"","sources":["../csharp.cts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAA4B,MAAM,aAAa,CAAC;AAGrE,eAAO,MAAM,SAAS,EAAE,OAwFvB,CAAC"}

View File

@ -1,135 +0,0 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
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.runJava = void 0;
const path_1 = require("path");
const child_process_1 = require("child_process");
const util = __importStar(require("util"));
const settings_cjs_1 = require("./settings.cjs");
const kill = require("tree-kill");
const execPromise = util.promisify(child_process_1.exec);
const runJava = function (params) {
return __awaiter(this, void 0, void 0, function* () {
var _a;
console.log(`- BUILD: ${params.mainFile}`);
const compileCommand = `javac -cp ${(0, path_1.join)(params.srcDir, 'src')} ${params.mainFile} -d ${(0, path_1.join)(params.srcDir, 'build')}`;
try {
yield execPromise(compileCommand);
}
catch (e) {
const buildErrorText = (_a = e === null || e === void 0 ? void 0 : e.toString()) !== null && _a !== void 0 ? _a : 'Unknown build errors.';
console.log('Build errors: ' + buildErrorText);
return {
success: false,
runResult: { kind: 'CompileFailed', resultKindReason: buildErrorText }
};
}
console.log(`- RUN: ${params.mainClass}`);
const runCommand = `java -cp "${(0, path_1.join)(params.srcDir, 'build')}" ${params.mainClass}`;
try {
let outputBuffer = '';
const child = (0, child_process_1.spawn)(runCommand, { shell: true });
child.stdout.setEncoding('utf8');
child.stdout.on('data', (data) => {
var _a;
outputBuffer += data.toString();
(_a = params.outputCallback) === null || _a === void 0 ? void 0 : _a.call(params, data.toString());
});
child.stderr.setEncoding('utf8');
child.stderr.on('data', (data) => {
var _a;
outputBuffer += data.toString();
(_a = params.outputCallback) === null || _a === void 0 ? void 0 : _a.call(params, data.toString());
});
const runStartTime = performance.now();
child.stdin.write(params.input);
child.stdin.end();
let timeLimitExceeded = false;
let completedNormally = false;
return {
success: true,
runResult: new Promise((resolve) => {
child.on('close', () => {
completedNormally = !timeLimitExceeded;
const runEndTime = performance.now();
const runtimeMilliseconds = Math.floor(runEndTime - runStartTime);
if (completedNormally) {
clearTimeout(timeoutHandle);
resolve({
kind: 'Completed',
output: outputBuffer,
exitCode: child.exitCode,
runtimeMilliseconds
});
}
else {
console.log(`Process terminated, total sandbox time: ${runtimeMilliseconds}ms`);
resolve({
kind: 'TimeLimitExceeded',
output: outputBuffer,
resultKindReason: `Timeout after ${settings_cjs_1.timeoutSeconds} seconds`
});
}
});
const timeoutHandle = setTimeout(() => {
if (completedNormally) {
return;
}
console.log(`Run timed out after ${settings_cjs_1.timeoutSeconds} seconds, killing process...`);
timeLimitExceeded = true;
child.stdin.end();
child.stdin.destroy();
child.stdout.destroy();
child.stderr.destroy();
child.kill('SIGKILL');
}, settings_cjs_1.timeoutSeconds * 1000);
}),
killFunc() {
var _a;
if (child.pid !== undefined) {
if (!completedNormally && !timeLimitExceeded) {
kill(child.pid);
(_a = params.outputCallback) === null || _a === void 0 ? void 0 : _a.call(params, '\n[Manually stopped]');
}
}
}
};
}
catch (error) {
return { success: false, runResult: { kind: 'RunError' } };
}
});
};
exports.runJava = runJava;
//# sourceMappingURL=java.cjs.map

View File

@ -1 +0,0 @@
{"version":3,"file":"java.cjs","sourceRoot":"","sources":["../java.cts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA4B;AAC5B,iDAA4C;AAC5C,2CAA6B;AAE7B,iDAAgD;AAEhD,kCAAmC;AAEnC,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,oBAAI,CAAC,CAAC;AAUlC,MAAM,OAAO,GAA+B,UAClD,MAAyB;;;QAEzB,OAAO,CAAC,GAAG,CAAC,YAAY,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC3C,MAAM,cAAc,GAAG,aAAa,IAAA,WAAI,EAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,QAAQ,OAAO,IAAA,WAAI,EAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;QAEvH,IAAI,CAAC;YACJ,MAAM,WAAW,CAAC,cAAc,CAAC,CAAC;QACnC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC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,OAAO,EAAE,OAAO,CAAC,iBAAiB,CA+F9C,CAAC"}

View File

@ -1,5 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.timeoutSeconds = void 0;
exports.timeoutSeconds = 30;
//# sourceMappingURL=settings.cjs.map

View File

@ -1 +0,0 @@
{"version":3,"file":"settings.cjs","sourceRoot":"","sources":["../settings.cts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG,EAAE,CAAC"}

View File

@ -1 +0,0 @@
{"version":3,"file":"settings.d.cts","sourceRoot":"","sources":["../settings.cts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,KAAK,CAAC"}

File diff suppressed because one or more lines are too long

View File

@ -1,21 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RunResultZod = void 0;
const zod_1 = require("zod");
const RunResultKind = zod_1.z.enum([
'CompileFailed',
'TimeLimitExceeded',
'Completed',
'SandboxError',
'RunError'
]);
exports.RunResultZod = zod_1.z
.object({
kind: RunResultKind,
output: zod_1.z.string().optional(),
exitCode: zod_1.z.number().optional(),
runtimeMilliseconds: zod_1.z.number().optional(),
resultKindReason: zod_1.z.string().optional()
})
.strict();
//# sourceMappingURL=types.cjs.map

View File

@ -1 +0,0 @@
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../types.cts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,MAAM,aAAa,GAAG,OAAC,CAAC,IAAI,CAAC;IAC5B,eAAe;IACf,mBAAmB;IACnB,WAAW;IACX,cAAc;IACd,UAAU;CACV,CAAC,CAAC;AAIU,QAAA,YAAY,GAAG,OAAC;KAC3B,MAAM,CAAC;IACP,IAAI,EAAE,aAAa;IACnB,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,mBAAmB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC1C,gBAAgB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACvC,CAAC;KACD,MAAM,EAAE,CAAC"}

View File

@ -1,39 +0,0 @@
import { z } from 'zod';
declare const RunResultKind: z.ZodEnum<["CompileFailed", "TimeLimitExceeded", "Completed", "SandboxError", "RunError"]>;
export type RunResultKind = z.infer<typeof RunResultKind>;
export declare const RunResultZod: z.ZodObject<{
kind: z.ZodEnum<["CompileFailed", "TimeLimitExceeded", "Completed", "SandboxError", "RunError"]>;
output: z.ZodOptional<z.ZodString>;
exitCode: z.ZodOptional<z.ZodNumber>;
runtimeMilliseconds: z.ZodOptional<z.ZodNumber>;
resultKindReason: z.ZodOptional<z.ZodString>;
}, "strict", z.ZodTypeAny, {
kind: "CompileFailed" | "TimeLimitExceeded" | "Completed" | "SandboxError" | "RunError";
output?: string | undefined;
exitCode?: number | undefined;
runtimeMilliseconds?: number | undefined;
resultKindReason?: string | undefined;
}, {
kind: "CompileFailed" | "TimeLimitExceeded" | "Completed" | "SandboxError" | "RunError";
output?: string | undefined;
exitCode?: number | undefined;
runtimeMilliseconds?: number | undefined;
resultKindReason?: string | undefined;
}>;
export type RunResult = z.infer<typeof RunResultZod>;
export interface IRunnerParams {
srcDir: string;
input: string;
outputCallback?: (data: string) => void;
}
export type IRunnerReturn = {
success: true;
killFunc: () => void;
runResult: Promise<RunResult>;
} | {
success: false;
runResult: RunResult;
};
export type IRunner<T extends IRunnerParams = IRunnerParams> = (params: T) => Promise<IRunnerReturn>;
export {};
//# sourceMappingURL=types.d.cts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../types.cts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,aAAa,4FAMjB,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAE1D,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;EAQf,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAErD,MAAM,WAAW,aAAa;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED,MAAM,MAAM,aAAa,GACxB;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,IAAI,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;CAAE,GACtE;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,SAAS,EAAE,SAAS,CAAA;CAAE,CAAC;AAE1C,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,IAC1D,CAAC,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC"}

View File

@ -1,118 +0,0 @@
{
"name": "submissionRunner",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"dependencies": {
"fs-extra": "^11.2.0",
"tree-kill": "^1.2.2",
"typescript": "^5.4.2",
"zod": "^3.22.4"
},
"devDependencies": {
"@types/fs-extra": "^11.0.4",
"@types/node": "20.x"
}
},
"node_modules/@types/fs-extra": {
"version": "11.0.4",
"resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-11.0.4.tgz",
"integrity": "sha512-yTbItCNreRooED33qjunPthRcSjERP1r4MqCZc7wv0u2sUkzTFp45tgUfS5+r7FrZPdmCCNflLhVSP/o+SemsQ==",
"dev": true,
"dependencies": {
"@types/jsonfile": "*",
"@types/node": "*"
}
},
"node_modules/@types/jsonfile": {
"version": "6.1.4",
"resolved": "https://registry.npmjs.org/@types/jsonfile/-/jsonfile-6.1.4.tgz",
"integrity": "sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ==",
"dev": true,
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/node": {
"version": "20.11.25",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.25.tgz",
"integrity": "sha512-TBHyJxk2b7HceLVGFcpAUjsa5zIdsPWlR6XHfyGzd0SFu+/NFgQgMAl96MSDZgQDvJAvV6BKsFOrt6zIL09JDw==",
"dev": true,
"dependencies": {
"undici-types": "~5.26.4"
}
},
"node_modules/fs-extra": {
"version": "11.2.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.2.0.tgz",
"integrity": "sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==",
"dependencies": {
"graceful-fs": "^4.2.0",
"jsonfile": "^6.0.1",
"universalify": "^2.0.0"
},
"engines": {
"node": ">=14.14"
}
},
"node_modules/graceful-fs": {
"version": "4.2.11",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ=="
},
"node_modules/jsonfile": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz",
"integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
"dependencies": {
"universalify": "^2.0.0"
},
"optionalDependencies": {
"graceful-fs": "^4.1.6"
}
},
"node_modules/tree-kill": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz",
"integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==",
"bin": {
"tree-kill": "cli.js"
}
},
"node_modules/typescript": {
"version": "5.4.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.2.tgz",
"integrity": "sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==",
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
},
"node_modules/undici-types": {
"version": "5.26.5",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
"dev": true
},
"node_modules/universalify": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz",
"integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==",
"engines": {
"node": ">= 10.0.0"
}
},
"node_modules/zod": {
"version": "3.22.4",
"resolved": "https://registry.npmjs.org/zod/-/zod-3.22.4.tgz",
"integrity": "sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==",
"funding": {
"url": "https://github.com/sponsors/colinhacks"
}
}
}
}

View File

@ -1,13 +0,0 @@
{
"name": "submission-runner",
"scripts": {
"build": "tsc"
},
"devDependencies": {
"@types/node": "20.x",
"@types/fs-extra": "^11.0.4",
"zod": "^3.22.4",
"tree-kill": "^1.2.2",
"fs-extra": "^11.2.0"
}
}

View File

@ -1 +1 @@
export const timeoutSeconds = 30; export const timeoutSeconds = 30;

View File

@ -1,14 +0,0 @@
{
"compilerOptions": {
"composite": true,
"target": "es2016",
"module": "commonjs",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"outDir": "./dist",
"esModuleInterop": true,
"strict": true,
},
"include": ["*.cts"]
}

View File

@ -29,8 +29,9 @@ export interface IRunnerParams {
} }
export type IRunnerReturn = export type IRunnerReturn =
{ success: true; killFunc: () => void; runResult: Promise<RunResult> } | | { success: true; killFunc: () => void; runResult: Promise<RunResult> }
{ success: false; runResult: RunResult }; | { success: false; runResult: RunResult };
export type IRunner<T extends IRunnerParams = IRunnerParams> = export type IRunner<T extends IRunnerParams = IRunnerParams> = (
(params: T) => Promise<IRunnerReturn>; params: T
) => Promise<IRunnerReturn>;

14
shared/tsconfig.json Normal file
View File

@ -0,0 +1,14 @@
{
"compilerOptions": {
"composite": true,
"target": "es2016",
"module": "commonjs",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"outDir": "./dist",
"esModuleInterop": true,
"strict": true
},
"include": ["**/*.cts", "**/*.ts"]
}

View File

@ -6,6 +6,7 @@ node_modules
.env .env
.env.* .env.*
!.env.example !.env.example
/db
# Ignore files for PNPM, NPM and YARN # Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml pnpm-lock.yaml

3
web/.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"cSpell.words": ["bwcontest"]
}

28
web/package-lock.json generated
View File

@ -14,7 +14,7 @@
"bcrypt": "^5.1.1", "bcrypt": "^5.1.1",
"bootstrap": "^5.3.3", "bootstrap": "^5.3.3",
"bootstrap-icons": "^1.11.3", "bootstrap-icons": "^1.11.3",
"contest-monitor-types": "file:../shared/contest-monitor-types", "bwcontest-shared": "file:../shared",
"diff": "^5.2.0", "diff": "^5.2.0",
"diff2html": "^3.4.47", "diff2html": "^3.4.47",
"eslint-plugin-svelte": "^2.35.1", "eslint-plugin-svelte": "^2.35.1",
@ -50,7 +50,23 @@
"vite": "^5.1.6" "vite": "^5.1.6"
} }
}, },
"../shared/contest-monitor-types": {}, "../shared": {
"devDependencies": {
"@types/fs-extra": "^11.0.4",
"@types/node": "20.x",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"eslint": "^8.57.0",
"fs-extra": "^11.2.0",
"prettier": "^3.2.5",
"tree-kill": "^1.2.2",
"typescript": "^5.4.2",
"zod": "^3.22.4"
}
},
"../shared/contest-monitor-types": {
"extraneous": true
},
"node_modules/@aashutoshrathi/word-wrap": { "node_modules/@aashutoshrathi/word-wrap": {
"version": "1.2.6", "version": "1.2.6",
"resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz",
@ -1596,6 +1612,10 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/bwcontest-shared": {
"resolved": "../shared",
"link": true
},
"node_modules/callsites": { "node_modules/callsites": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
@ -1730,10 +1750,6 @@
"resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
"integrity": "sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ==" "integrity": "sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ=="
}, },
"node_modules/contest-monitor-types": {
"resolved": "../shared/contest-monitor-types",
"link": true
},
"node_modules/cookie": { "node_modules/cookie": {
"version": "0.6.0", "version": "0.6.0",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz",

View File

@ -41,7 +41,7 @@
"bcrypt": "^5.1.1", "bcrypt": "^5.1.1",
"bootstrap": "^5.3.3", "bootstrap": "^5.3.3",
"bootstrap-icons": "^1.11.3", "bootstrap-icons": "^1.11.3",
"contest-monitor-types": "file:../shared/contest-monitor-types", "bwcontest-shared": "file:../shared",
"diff": "^5.2.0", "diff": "^5.2.0",
"diff2html": "^3.4.47", "diff2html": "^3.4.47",
"eslint-plugin-svelte": "^2.35.1", "eslint-plugin-svelte": "^2.35.1",

View File

@ -1,5 +1,5 @@
import type { SubmissionState } from '@prisma/client'; import type { SubmissionState } from '@prisma/client';
import type { SubmissionStateForExtension } from 'contest-monitor-types/contestMonitorTypes'; import type { SubmissionStateForExtension } from 'bwcontest-shared/types/contestMonitorTypes';
export function convertSubmissionStateForExtension( export function convertSubmissionStateForExtension(
state: SubmissionState state: SubmissionState

View File

@ -5,7 +5,7 @@ import type {
ContestStateForExtension, ContestStateForExtension,
FullStateForExtension, FullStateForExtension,
SubmissionForExtension SubmissionForExtension
} from 'contest-monitor-types/contestMonitorTypes'; } from 'bwcontest-shared/types/contestMonitorTypes';
import { convertSubmissionStateForExtension } from '$lib/contestMonitor/contestMonitorUtils'; import { convertSubmissionStateForExtension } from '$lib/contestMonitor/contestMonitorUtils';
export const GET = (async ({ params }) => { export const GET = (async ({ params }) => {

View File

@ -3,7 +3,7 @@ import { error, json } from '@sveltejs/kit';
import type { RequestHandler } from './$types'; import type { RequestHandler } from './$types';
import { z } from 'zod'; import { z } from 'zod';
import { SubmissionState } from '@prisma/client'; import { SubmissionState } from '@prisma/client';
import type { SubmissionForExtension } from 'contest-monitor-types/contestMonitorTypes'; import type { SubmissionForExtension } from 'bwcontest-shared/types/contestMonitorTypes';
import { convertSubmissionStateForExtension } from '$lib/contestMonitor/contestMonitorUtils'; import { convertSubmissionStateForExtension } from '$lib/contestMonitor/contestMonitorUtils';
const submitPostData = z.object({ const submitPostData = z.object({