@exercode/problem-utils 1.16.6 → 1.16.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.cjs +1 -0
- package/dist/helpers/checkProblemDirIsolation.cjs +2 -2
- package/dist/helpers/checkProblemDirIsolation.cjs.map +1 -1
- package/dist/helpers/checkProblemDirIsolation.js +2 -2
- package/dist/helpers/checkProblemDirIsolation.js.map +1 -1
- package/dist/helpers/cleanWorkingDirectory.cjs +2 -2
- package/dist/helpers/cleanWorkingDirectory.cjs.map +1 -1
- package/dist/helpers/cleanWorkingDirectory.js +2 -2
- package/dist/helpers/cleanWorkingDirectory.js.map +1 -1
- package/dist/helpers/compareStdoutAsSpaceSeparatedTokens.cjs +2 -2
- package/dist/helpers/compareStdoutAsSpaceSeparatedTokens.cjs.map +1 -1
- package/dist/helpers/compareStdoutAsSpaceSeparatedTokens.js +2 -2
- package/dist/helpers/compareStdoutAsSpaceSeparatedTokens.js.map +1 -1
- package/dist/helpers/copyTestCaseFileInput.cjs +2 -2
- package/dist/helpers/copyTestCaseFileInput.cjs.map +1 -1
- package/dist/helpers/copyTestCaseFileInput.js +2 -2
- package/dist/helpers/copyTestCaseFileInput.js.map +1 -1
- package/dist/helpers/findEntryPointFile.cjs +2 -2
- package/dist/helpers/findEntryPointFile.cjs.map +1 -1
- package/dist/helpers/findEntryPointFile.js +2 -2
- package/dist/helpers/findEntryPointFile.js.map +1 -1
- package/dist/helpers/findLanguageDefinitionByPath.cjs +2 -2
- package/dist/helpers/findLanguageDefinitionByPath.cjs.map +1 -1
- package/dist/helpers/findLanguageDefinitionByPath.js +2 -2
- package/dist/helpers/findLanguageDefinitionByPath.js.map +1 -1
- package/dist/helpers/findModelAnswerDirs.cjs +2 -2
- package/dist/helpers/findModelAnswerDirs.cjs.map +1 -1
- package/dist/helpers/findModelAnswerDirs.js +2 -2
- package/dist/helpers/findModelAnswerDirs.js.map +1 -1
- package/dist/helpers/judgeByStaticAnalysis.cjs +19 -2
- package/dist/helpers/judgeByStaticAnalysis.cjs.map +1 -1
- package/dist/helpers/judgeByStaticAnalysis.js +19 -2
- package/dist/helpers/judgeByStaticAnalysis.js.map +1 -1
- package/dist/helpers/parseArgs.cjs +2 -2
- package/dist/helpers/parseArgs.cjs.map +1 -1
- package/dist/helpers/parseArgs.js +2 -2
- package/dist/helpers/parseArgs.js.map +1 -1
- package/dist/helpers/printDebugBanner.cjs +3 -2
- package/dist/helpers/printDebugBanner.cjs.map +1 -1
- package/dist/helpers/printDebugBanner.js +3 -2
- package/dist/helpers/printDebugBanner.js.map +1 -1
- package/dist/helpers/printTestCaseResult.cjs +2 -2
- package/dist/helpers/printTestCaseResult.cjs.map +1 -1
- package/dist/helpers/printTestCaseResult.js +2 -2
- package/dist/helpers/printTestCaseResult.js.map +1 -1
- package/dist/helpers/readOutputFiles.cjs +2 -2
- package/dist/helpers/readOutputFiles.cjs.map +1 -1
- package/dist/helpers/readOutputFiles.js +2 -2
- package/dist/helpers/readOutputFiles.js.map +1 -1
- package/dist/helpers/readProblemMarkdownFrontMatter.cjs +2 -2
- package/dist/helpers/readProblemMarkdownFrontMatter.cjs.map +1 -1
- package/dist/helpers/readProblemMarkdownFrontMatter.js +2 -2
- package/dist/helpers/readProblemMarkdownFrontMatter.js.map +1 -1
- package/dist/helpers/readTestCases.cjs +2 -2
- package/dist/helpers/readTestCases.cjs.map +1 -1
- package/dist/helpers/readTestCases.js +2 -2
- package/dist/helpers/readTestCases.js.map +1 -1
- package/dist/helpers/removeCommentsInSourceCode.cjs +6 -2
- package/dist/helpers/removeCommentsInSourceCode.cjs.map +1 -1
- package/dist/helpers/removeCommentsInSourceCode.js +6 -2
- package/dist/helpers/removeCommentsInSourceCode.js.map +1 -1
- package/dist/helpers/resolveCwds.cjs +2 -2
- package/dist/helpers/resolveCwds.cjs.map +1 -1
- package/dist/helpers/resolveCwds.js +2 -2
- package/dist/helpers/resolveCwds.js.map +1 -1
- package/dist/helpers/runCommandInTemporaryPackageManagerProject.cjs +2 -2
- package/dist/helpers/runCommandInTemporaryPackageManagerProject.cjs.map +1 -1
- package/dist/helpers/runCommandInTemporaryPackageManagerProject.js +2 -2
- package/dist/helpers/runCommandInTemporaryPackageManagerProject.js.map +1 -1
- package/dist/helpers/runPythonInTemporaryUvProject.cjs +2 -2
- package/dist/helpers/runPythonInTemporaryUvProject.cjs.map +1 -1
- package/dist/helpers/runPythonInTemporaryUvProject.js +2 -2
- package/dist/helpers/runPythonInTemporaryUvProject.js.map +1 -1
- package/dist/helpers/sourceCodeGrammars.cjs +2 -2
- package/dist/helpers/sourceCodeGrammars.cjs.map +1 -1
- package/dist/helpers/sourceCodeGrammars.js +2 -2
- package/dist/helpers/sourceCodeGrammars.js.map +1 -1
- package/dist/helpers/spawnSyncWithTimeout.cjs +2 -2
- package/dist/helpers/spawnSyncWithTimeout.cjs.map +1 -1
- package/dist/helpers/spawnSyncWithTimeout.js +2 -2
- package/dist/helpers/spawnSyncWithTimeout.js.map +1 -1
- package/dist/helpers/startHttpServer.cjs +2 -2
- package/dist/helpers/startHttpServer.cjs.map +1 -1
- package/dist/helpers/startHttpServer.js +2 -2
- package/dist/helpers/startHttpServer.js.map +1 -1
- package/dist/index.cjs +1 -2
- package/dist/index.js +1 -2
- package/dist/presets/command.cjs +2 -2
- package/dist/presets/command.cjs.map +1 -1
- package/dist/presets/command.js +2 -2
- package/dist/presets/command.js.map +1 -1
- package/dist/presets/guiCommand.cjs +4 -2
- package/dist/presets/guiCommand.cjs.map +1 -1
- package/dist/presets/guiCommand.js +4 -2
- package/dist/presets/guiCommand.js.map +1 -1
- package/dist/presets/llm.cjs +2 -2
- package/dist/presets/llm.cjs.map +1 -1
- package/dist/presets/llm.js +2 -2
- package/dist/presets/llm.js.map +1 -1
- package/dist/presets/stdio.cjs +2 -2
- package/dist/presets/stdio.cjs.map +1 -1
- package/dist/presets/stdio.js +2 -2
- package/dist/presets/stdio.js.map +1 -1
- package/dist/types/decisionCode.cjs +2 -2
- package/dist/types/decisionCode.cjs.map +1 -1
- package/dist/types/decisionCode.js +2 -2
- package/dist/types/decisionCode.js.map +1 -1
- package/dist/types/language.cjs +11 -2
- package/dist/types/language.cjs.map +1 -1
- package/dist/types/language.js +11 -2
- package/dist/types/language.js.map +1 -1
- package/dist/types/problem.cjs +2 -2
- package/dist/types/problem.cjs.map +1 -1
- package/dist/types/problem.js +2 -2
- package/dist/types/problem.js.map +1 -1
- package/dist/types/testCaseResult.cjs +2 -2
- package/dist/types/testCaseResult.cjs.map +1 -1
- package/dist/types/testCaseResult.js +2 -2
- package/dist/types/testCaseResult.js.map +1 -1
- package/package.json +16 -16
- package/dist/_virtual/_rollupPluginBabelHelpers.cjs +0 -4
- package/dist/_virtual/_rollupPluginBabelHelpers.cjs.map +0 -1
- package/dist/_virtual/_rollupPluginBabelHelpers.js +0 -4
- package/dist/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"judgeByStaticAnalysis.cjs","sources":["../../src/helpers/judgeByStaticAnalysis.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { DecisionCode } from '../types/decisionCode.js';\nimport type { ProblemMarkdownFrontMatter } from '../types/problem.js';\nimport type { TestCaseResult } from '../types/testCaseResult.js';\n\nimport { findLanguageDefinitionByPath } from './findLanguageDefinitionByPath.js';\nimport { removeCommentsInSourceCode } from './removeCommentsInSourceCode.js';\n\nexport async function judgeByStaticAnalysis(\n cwd: string,\n problemMarkdownFrontMatterLike: Pick<\n ProblemMarkdownFrontMatter,\n 'forbiddenRegExpsInCode' | 'forbiddenTextsInCode' | 'requiredRegExpsInCode' | 'requiredSubmissionFilePaths'\n >\n): Promise<Pick<TestCaseResult, 'decisionCode' | 'feedbackMarkdown'> | undefined> {\n const filePathSet = new Set<string>();\n const sourceCodeWithoutCommentFiles: { path: string; data: string }[] = [];\n\n for (const dirent of await fs.promises.readdir(cwd, { withFileTypes: true, recursive: true })) {\n if (!dirent.isFile()) continue;\n\n const relativePath = path.relative(cwd, path.join(dirent.parentPath, dirent.name));\n filePathSet.add(relativePath);\n\n const text = await fs.promises.readFile(path.join(dirent.parentPath, dirent.name), 'utf8');\n const isBinary = text.includes('\\uFFFD');\n if (isBinary) continue;\n\n const languageDefinition = findLanguageDefinitionByPath(dirent.name);\n if (!languageDefinition) continue;\n\n sourceCodeWithoutCommentFiles.push({\n path: dirent.name,\n data: languageDefinition.grammer ? removeCommentsInSourceCode(languageDefinition.grammer, text) : text,\n });\n }\n\n if (problemMarkdownFrontMatterLike.requiredSubmissionFilePaths) {\n const missingFilePaths = problemMarkdownFrontMatterLike.requiredSubmissionFilePaths\n .filter((p) => !filePathSet.has(p))\n .toSorted();\n\n if (missingFilePaths.length > 0) {\n return {\n decisionCode: DecisionCode.MISSING_REQUIRED_SUBMISSION_FILE_ERROR,\n feedbackMarkdown: `ファイルが不足しています。\n次のファイルを追加してから再度提出してください。\n\n${missingFilePaths.map((p) => `- \\`${p}\\``).join('\\n')}\n`,\n };\n }\n }\n\n const forbiddenFounds: { pattern: string; path: string; match: string }[] = [];\n\n for (const file of sourceCodeWithoutCommentFiles) {\n for (const pattern of problemMarkdownFrontMatterLike.forbiddenRegExpsInCode ?? []) {\n const re = new RegExp(pattern, 'g');\n const mathces = file.data.matchAll(re);\n for (const match of mathces) forbiddenFounds.push({ pattern: re.toString(), path: file.path, match: match[0] });\n }\n for (const pattern of problemMarkdownFrontMatterLike.forbiddenTextsInCode ?? []) {\n let p = 0;\n while (p < file.data.length) {\n const index = file.data.indexOf(pattern, p);\n if (index === -1) break;\n forbiddenFounds.push({ pattern, path: file.path, match: pattern });\n p = index + pattern.length;\n }\n }\n }\n\n if (forbiddenFounds.length > 0) {\n return {\n decisionCode: DecisionCode.FORBIDDEN_PATTERNS_IN_CODE_ERROR,\n feedbackMarkdown: `ソースコード中に禁止された文字列が含まれています。\nソースコードを修正してから再度提出してください。\n\n| ファイル | 禁止パターン | 文字列 |\n| -------- | ------------ | ------ |\n${forbiddenFounds.map((f) => `| \\`${f.path}\\` | \\`${f.pattern}\\` | \\`${f.match}\\` |`).join('\\n')}\n`,\n };\n }\n\n const missingRequiredPatterns: string[] = [];\n\n for (const pattern of problemMarkdownFrontMatterLike.requiredRegExpsInCode ?? []) {\n const re = new RegExp(pattern);\n const isFound = sourceCodeWithoutCommentFiles.some((f) => re.test(f.data));\n if (!isFound) missingRequiredPatterns.push(re.toString());\n }\n\n if (missingRequiredPatterns.length > 0) {\n return {\n decisionCode: DecisionCode.REQUIRED_PATTERNS_IN_CODE_ERROR,\n feedbackMarkdown: `ソースコード中に必要な文字列が含まれていません。\nソースコードを修正してから再度提出してください。\n\n${missingRequiredPatterns.map((p) => `- \\`${p}\\``).join('\\n')}\n`,\n };\n }\n\n return;\n}\n"],"names":["_judgeByStaticAnalysis","_asyncToGenerator","_regenerator","m","_callee","cwd","problemMarkdownFrontMatterLike","_problemMarkdownFront3","filePathSet","sourceCodeWithoutCommentFiles","_iterator","_step","dirent","relativePath","text","languageDefinition","missingFilePaths","forbiddenFounds","_i","_sourceCodeWithoutCom","_problemMarkdownFront","_problemMarkdownFront2","file","_iterator2","_step2","pattern","re","mathces","_iterator4","_step4","match","_iterator3","_step3","_pattern","p","index","missingRequiredPatterns","_iterator5","_step5","_loop","_t","_t2","_t3","_t4","w","_context2","n","Set","_createForOfIteratorHelper","fs","promises","readdir","withFileTypes","recursive","v","s","done","value","isFile","a","path","relative","join","parentPath","name","add","readFile","includes","findLanguageDefinitionByPath","push","data","grammer","removeCommentsInSourceCode","e","f","requiredSubmissionFilePaths","filter","has","toSorted","length","decisionCode","DecisionCode","MISSING_REQUIRED_SUBMISSION_FILE_ERROR","feedbackMarkdown","concat","map","forbiddenRegExpsInCode","RegExp","matchAll","toString","err","forbiddenTextsInCode","indexOf","FORBIDDEN_PATTERNS_IN_CODE_ERROR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AA,GAAAD,EAAAC,EAAA,GAAA,MAAA,KAAA,GAAAD,EAAAX,EAAA,GAAAS,EAAAE,EAAAS,EAAAjB,EAAAoC,EAAA9B,GAAA,KAAA,GAAA,OAAAE,EAAAX,EAAA,GAAAG,EAAAqC,IAAA7B,EAAA6B,EAAA,IAAA,KAAA,GAAA,KAGxDtC,EAAwB2C,OAAS,GAAC,CAAAlC,EAAAC,EAAA,GAAA,KAAA,CAAA,OAAAD,EAAAc,EAAA,EAC7B,CACLqB,aAAcC,EAAAA,aAAamB,gCAC3BjB,iBAAgB,yDAAAC,OAGpBhD,EAAwBiD,IAAI,SAACnD,GAAC,MAAA,MAAAkD,OAAYlD,EAAC,IAAA,GAAM4B,KAAK,MAAK,QAExD,KAAA,GAAA,OAAAjB,EAAAc,EAAA,GAAA,EAAAvD,EAAA,KAAA,CAAA,CAAA,GAAA,GAAA,GAAA,IAAA,CAAA,GAAA,GAAA,GAAA,IAAA,CAAA,EAAA,GAAA,GAAA,KAAA,KAIJiG,MAAAC,KAAAC,UAAA,+BAlGD,SAA2CC,EAAAC,GAAA,OAAAzG,EAAAqG,MAAAC,KAAAC,UAAA"}
|
|
1
|
+
{"version":3,"file":"judgeByStaticAnalysis.cjs","names":["fs","path","findLanguageDefinitionByPath","removeCommentsInSourceCode","DecisionCode"],"sources":["../../src/helpers/judgeByStaticAnalysis.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { DecisionCode } from '../types/decisionCode.js';\nimport type { ProblemMarkdownFrontMatter } from '../types/problem.js';\nimport type { TestCaseResult } from '../types/testCaseResult.js';\n\nimport { findLanguageDefinitionByPath } from './findLanguageDefinitionByPath.js';\nimport { removeCommentsInSourceCode } from './removeCommentsInSourceCode.js';\n\nexport async function judgeByStaticAnalysis(\n cwd: string,\n problemMarkdownFrontMatterLike: Pick<\n ProblemMarkdownFrontMatter,\n 'forbiddenRegExpsInCode' | 'forbiddenTextsInCode' | 'requiredRegExpsInCode' | 'requiredSubmissionFilePaths'\n >\n): Promise<Pick<TestCaseResult, 'decisionCode' | 'feedbackMarkdown'> | undefined> {\n const filePathSet = new Set<string>();\n const sourceCodeWithoutCommentFiles: { path: string; data: string }[] = [];\n\n for (const dirent of await fs.promises.readdir(cwd, { withFileTypes: true, recursive: true })) {\n if (!dirent.isFile()) continue;\n\n const relativePath = path.relative(cwd, path.join(dirent.parentPath, dirent.name));\n filePathSet.add(relativePath);\n\n const text = await fs.promises.readFile(path.join(dirent.parentPath, dirent.name), 'utf8');\n const isBinary = text.includes('\\uFFFD');\n if (isBinary) continue;\n\n const languageDefinition = findLanguageDefinitionByPath(dirent.name);\n if (!languageDefinition) continue;\n\n sourceCodeWithoutCommentFiles.push({\n path: dirent.name,\n data: languageDefinition.grammer ? removeCommentsInSourceCode(languageDefinition.grammer, text) : text,\n });\n }\n\n if (problemMarkdownFrontMatterLike.requiredSubmissionFilePaths) {\n const missingFilePaths = problemMarkdownFrontMatterLike.requiredSubmissionFilePaths\n .filter((p) => !filePathSet.has(p))\n .toSorted();\n\n if (missingFilePaths.length > 0) {\n return {\n decisionCode: DecisionCode.MISSING_REQUIRED_SUBMISSION_FILE_ERROR,\n feedbackMarkdown: `ファイルが不足しています。\n次のファイルを追加してから再度提出してください。\n\n${missingFilePaths.map((p) => `- \\`${p}\\``).join('\\n')}\n`,\n };\n }\n }\n\n const forbiddenFounds: { pattern: string; path: string; match: string }[] = [];\n\n for (const file of sourceCodeWithoutCommentFiles) {\n for (const pattern of problemMarkdownFrontMatterLike.forbiddenRegExpsInCode ?? []) {\n const re = new RegExp(pattern, 'g');\n const mathces = file.data.matchAll(re);\n for (const match of mathces) forbiddenFounds.push({ pattern: re.toString(), path: file.path, match: match[0] });\n }\n for (const pattern of problemMarkdownFrontMatterLike.forbiddenTextsInCode ?? []) {\n let p = 0;\n while (p < file.data.length) {\n const index = file.data.indexOf(pattern, p);\n if (index === -1) break;\n forbiddenFounds.push({ pattern, path: file.path, match: pattern });\n p = index + pattern.length;\n }\n }\n }\n\n if (forbiddenFounds.length > 0) {\n return {\n decisionCode: DecisionCode.FORBIDDEN_PATTERNS_IN_CODE_ERROR,\n feedbackMarkdown: `ソースコード中に禁止された文字列が含まれています。\nソースコードを修正してから再度提出してください。\n\n| ファイル | 禁止パターン | 文字列 |\n| -------- | ------------ | ------ |\n${forbiddenFounds.map((f) => `| \\`${f.path}\\` | \\`${f.pattern}\\` | \\`${f.match}\\` |`).join('\\n')}\n`,\n };\n }\n\n const missingRequiredPatterns: string[] = [];\n\n for (const pattern of problemMarkdownFrontMatterLike.requiredRegExpsInCode ?? []) {\n const re = new RegExp(pattern);\n const isFound = sourceCodeWithoutCommentFiles.some((f) => re.test(f.data));\n if (!isFound) missingRequiredPatterns.push(re.toString());\n }\n\n if (missingRequiredPatterns.length > 0) {\n return {\n decisionCode: DecisionCode.REQUIRED_PATTERNS_IN_CODE_ERROR,\n feedbackMarkdown: `ソースコード中に必要な文字列が含まれていません。\nソースコードを修正してから再度提出してください。\n\n${missingRequiredPatterns.map((p) => `- \\`${p}\\``).join('\\n')}\n`,\n };\n }\n\n return;\n}\n"],"mappings":"6RAUA,eAAsB,EACpB,EACA,EAIgF,CAChF,IAAM,EAAc,IAAI,IAClB,EAAkE,CAAC,EAEzE,IAAK,IAAM,KAAU,MAAMA,EAAAA,QAAG,SAAS,QAAQ,EAAK,CAAE,cAAe,GAAM,UAAW,EAAK,CAAC,EAAG,CAC7F,GAAI,CAAC,EAAO,OAAO,EAAG,SAEtB,IAAM,EAAeC,EAAAA,QAAK,SAAS,EAAKA,EAAAA,QAAK,KAAK,EAAO,WAAY,EAAO,IAAI,CAAC,EACjF,EAAY,IAAI,CAAY,EAE5B,IAAM,EAAO,MAAMD,EAAAA,QAAG,SAAS,SAASC,EAAAA,QAAK,KAAK,EAAO,WAAY,EAAO,IAAI,EAAG,MAAM,EAEzF,GADiB,EAAK,SAAS,GACpB,EAAG,SAEd,IAAM,EAAqBC,EAAAA,6BAA6B,EAAO,IAAI,EAC9D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F,EAGF,IAAM,EAAoC,CAAC,EAE3C,IAAK,IAAM,KAAW,EAA+B,uBAAyB,CAAC,EAAG,CAChF,IAAM,EAAK,IAAI,OAAO,CAAO,EACb,EAA8B,KAAM,GAAM,EAAG,KAAK,EAAE,IAAI,CAC7D,GAAG,EAAwB,KAAK,EAAG,SAAS,CAAC,CAC1D,CAEA,GAAI,EAAwB,OAAS,EACnC,MAAO,CACL,aAAcA,EAAAA,aAAa,gCAC3B,iBAAkB;;;EAGtB,EAAwB,IAAK,GAAM,OAAO,EAAE,GAAG,CAAC,CAAC,KAAK;CAAI,EAAE;CAE1D,CAIJ"}
|
|
@@ -1,2 +1,19 @@
|
|
|
1
|
-
import{
|
|
2
|
-
|
|
1
|
+
import{removeCommentsInSourceCode as e}from"./removeCommentsInSourceCode.js";import{DecisionCode as t}from"../types/decisionCode.js";import{findLanguageDefinitionByPath as n}from"./findLanguageDefinitionByPath.js";import r from"node:path";import i from"node:fs";async function a(a,o){let s=new Set,c=[];for(let t of await i.promises.readdir(a,{withFileTypes:!0,recursive:!0})){if(!t.isFile())continue;let o=r.relative(a,r.join(t.parentPath,t.name));s.add(o);let l=await i.promises.readFile(r.join(t.parentPath,t.name),`utf8`);if(l.includes(`�`))continue;let u=n(t.name);u&&c.push({path:t.name,data:u.grammer?e(u.grammer,l):l})}if(o.requiredSubmissionFilePaths){let e=o.requiredSubmissionFilePaths.filter(e=>!s.has(e)).toSorted();if(e.length>0)return{decisionCode:t.MISSING_REQUIRED_SUBMISSION_FILE_ERROR,feedbackMarkdown:`ファイルが不足しています。
|
|
2
|
+
次のファイルを追加してから再度提出してください。
|
|
3
|
+
|
|
4
|
+
${e.map(e=>`- \`${e}\``).join(`
|
|
5
|
+
`)}
|
|
6
|
+
`}}let l=[];for(let e of c){for(let t of o.forbiddenRegExpsInCode??[]){let n=new RegExp(t,`g`),r=e.data.matchAll(n);for(let t of r)l.push({pattern:n.toString(),path:e.path,match:t[0]})}for(let t of o.forbiddenTextsInCode??[]){let n=0;for(;n<e.data.length;){let r=e.data.indexOf(t,n);if(r===-1)break;l.push({pattern:t,path:e.path,match:t}),n=r+t.length}}}if(l.length>0)return{decisionCode:t.FORBIDDEN_PATTERNS_IN_CODE_ERROR,feedbackMarkdown:`ソースコード中に禁止された文字列が含まれています。
|
|
7
|
+
ソースコードを修正してから再度提出してください。
|
|
8
|
+
|
|
9
|
+
| ファイル | 禁止パターン | 文字列 |
|
|
10
|
+
| -------- | ------------ | ------ |
|
|
11
|
+
${l.map(e=>`| \`${e.path}\` | \`${e.pattern}\` | \`${e.match}\` |`).join(`
|
|
12
|
+
`)}
|
|
13
|
+
`};let u=[];for(let e of o.requiredRegExpsInCode??[]){let t=new RegExp(e);c.some(e=>t.test(e.data))||u.push(t.toString())}if(u.length>0)return{decisionCode:t.REQUIRED_PATTERNS_IN_CODE_ERROR,feedbackMarkdown:`ソースコード中に必要な文字列が含まれていません。
|
|
14
|
+
ソースコードを修正してから再度提出してください。
|
|
15
|
+
|
|
16
|
+
${u.map(e=>`- \`${e}\``).join(`
|
|
17
|
+
`)}
|
|
18
|
+
`}}export{a as judgeByStaticAnalysis};
|
|
19
|
+
//# sourceMappingURL=judgeByStaticAnalysis.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"judgeByStaticAnalysis.js","sources":["../../src/helpers/judgeByStaticAnalysis.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { DecisionCode } from '../types/decisionCode.js';\nimport type { ProblemMarkdownFrontMatter } from '../types/problem.js';\nimport type { TestCaseResult } from '../types/testCaseResult.js';\n\nimport { findLanguageDefinitionByPath } from './findLanguageDefinitionByPath.js';\nimport { removeCommentsInSourceCode } from './removeCommentsInSourceCode.js';\n\nexport async function judgeByStaticAnalysis(\n cwd: string,\n problemMarkdownFrontMatterLike: Pick<\n ProblemMarkdownFrontMatter,\n 'forbiddenRegExpsInCode' | 'forbiddenTextsInCode' | 'requiredRegExpsInCode' | 'requiredSubmissionFilePaths'\n >\n): Promise<Pick<TestCaseResult, 'decisionCode' | 'feedbackMarkdown'> | undefined> {\n const filePathSet = new Set<string>();\n const sourceCodeWithoutCommentFiles: { path: string; data: string }[] = [];\n\n for (const dirent of await fs.promises.readdir(cwd, { withFileTypes: true, recursive: true })) {\n if (!dirent.isFile()) continue;\n\n const relativePath = path.relative(cwd, path.join(dirent.parentPath, dirent.name));\n filePathSet.add(relativePath);\n\n const text = await fs.promises.readFile(path.join(dirent.parentPath, dirent.name), 'utf8');\n const isBinary = text.includes('\\uFFFD');\n if (isBinary) continue;\n\n const languageDefinition = findLanguageDefinitionByPath(dirent.name);\n if (!languageDefinition) continue;\n\n sourceCodeWithoutCommentFiles.push({\n path: dirent.name,\n data: languageDefinition.grammer ? removeCommentsInSourceCode(languageDefinition.grammer, text) : text,\n });\n }\n\n if (problemMarkdownFrontMatterLike.requiredSubmissionFilePaths) {\n const missingFilePaths = problemMarkdownFrontMatterLike.requiredSubmissionFilePaths\n .filter((p) => !filePathSet.has(p))\n .toSorted();\n\n if (missingFilePaths.length > 0) {\n return {\n decisionCode: DecisionCode.MISSING_REQUIRED_SUBMISSION_FILE_ERROR,\n feedbackMarkdown: `ファイルが不足しています。\n次のファイルを追加してから再度提出してください。\n\n${missingFilePaths.map((p) => `- \\`${p}\\``).join('\\n')}\n`,\n };\n }\n }\n\n const forbiddenFounds: { pattern: string; path: string; match: string }[] = [];\n\n for (const file of sourceCodeWithoutCommentFiles) {\n for (const pattern of problemMarkdownFrontMatterLike.forbiddenRegExpsInCode ?? []) {\n const re = new RegExp(pattern, 'g');\n const mathces = file.data.matchAll(re);\n for (const match of mathces) forbiddenFounds.push({ pattern: re.toString(), path: file.path, match: match[0] });\n }\n for (const pattern of problemMarkdownFrontMatterLike.forbiddenTextsInCode ?? []) {\n let p = 0;\n while (p < file.data.length) {\n const index = file.data.indexOf(pattern, p);\n if (index === -1) break;\n forbiddenFounds.push({ pattern, path: file.path, match: pattern });\n p = index + pattern.length;\n }\n }\n }\n\n if (forbiddenFounds.length > 0) {\n return {\n decisionCode: DecisionCode.FORBIDDEN_PATTERNS_IN_CODE_ERROR,\n feedbackMarkdown: `ソースコード中に禁止された文字列が含まれています。\nソースコードを修正してから再度提出してください。\n\n| ファイル | 禁止パターン | 文字列 |\n| -------- | ------------ | ------ |\n${forbiddenFounds.map((f) => `| \\`${f.path}\\` | \\`${f.pattern}\\` | \\`${f.match}\\` |`).join('\\n')}\n`,\n };\n }\n\n const missingRequiredPatterns: string[] = [];\n\n for (const pattern of problemMarkdownFrontMatterLike.requiredRegExpsInCode ?? []) {\n const re = new RegExp(pattern);\n const isFound = sourceCodeWithoutCommentFiles.some((f) => re.test(f.data));\n if (!isFound) missingRequiredPatterns.push(re.toString());\n }\n\n if (missingRequiredPatterns.length > 0) {\n return {\n decisionCode: DecisionCode.REQUIRED_PATTERNS_IN_CODE_ERROR,\n feedbackMarkdown: `ソースコード中に必要な文字列が含まれていません。\nソースコードを修正してから再度提出してください。\n\n${missingRequiredPatterns.map((p) => `- \\`${p}\\``).join('\\n')}\n`,\n };\n }\n\n return;\n}\n"],"names":["judgeByStaticAnalysis","_x","_x2","_judgeByStaticAnalysis","apply","this","arguments","_asyncToGenerator","_regenerator","m","_callee","cwd","problemMarkdownFrontMatterLike","_problemMarkdownFront3","filePathSet","sourceCodeWithoutCommentFiles","_iterator","_step","dirent","relativePath","text","languageDefinition","missingFilePaths","forbiddenFounds","_i","_sourceCodeWithoutCom","_problemMarkdownFront","_problemMarkdownFront2","file","_iterator2","_step2","pattern","re","mathces","_iterator4","_step4","match","_iterator3","_step3","_pattern","p","index","missingRequiredPatterns","_iterator5","_step5","_loop","_t","_t2","_t3","_t4","w","_context2","n","Set","_createForOfIteratorHelper","fs","promises","readdir","withFileTypes","recursive","v","s","done","value","isFile","a","path","relative","join","parentPath","name","add","readFile","includes","findLanguageDefinitionByPath","push","data","grammer","removeCommentsInSourceCode","e","f","requiredSubmissionFilePaths","filter","has","toSorted","length","decisionCode","DecisionCode","MISSING_REQUIRED_SUBMISSION_FILE_ERROR","feedbackMarkdown","concat","map","forbiddenRegExpsInCode","RegExp","matchAll","toString","err","forbiddenTextsInCode","indexOf","FORBIDDEN_PATTERNS_IN_CODE_ERROR","requiredRegExpsInCode","_context","some","test","d","_regeneratorValues","REQUIRED_PATTERNS_IN_CODE_ERROR"],"mappings":"yZAUA,SAAsBA,EAAqBC,EAAAC,GAAA,OAAAC,EAAAC,MAAAC,KAAAC,UAAA,CAkG1C,SAAAH,IAAA,OAAAA,EAAAI,EAAAC,IAAAC,EAlGM,SAAAC,EACLC,EACAC,GAGC,IAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAA,OAAAzC,IAAA0C,EAAA,SAAAC,GAAA,cAAAA,EAAAX,EAAAW,EAAAC,GAAA,KAAA,EAGyE,OADpEtC,EAAc,IAAIuC,IAClBtC,EAAkE,GAAE+B,EAAAQ,EAAAH,EAAAC,EAAA,EAE/CG,EAAGC,SAASC,QAAQ9C,EAAK,CAAE+C,eAAe,EAAMC,WAAW,IAAO,KAAA,EAAA3C,EAAA8B,EAAAK,EAAAS,GAAAT,EAAAX,EAAA,EAAAxB,EAAA6C,IAAA,KAAA,EAAA,IAAA5C,EAAAD,EAAAoC,KAAAU,KAAA,CAAAX,EAAAC,EAAA,EAAA,KAAA,CAA5E,IAANlC,EAAMD,EAAA8C,OACHC,SAAQ,CAAAb,EAAAC,EAAA,EAAA,KAAA,CAAA,OAAAD,EAAAc,EAAA,EAAA,GAAA,KAAA,EAGU,OADxB9C,EAAe+C,EAAKC,SAASxD,EAAKuD,EAAKE,KAAKlD,EAA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AA,KAAA,CAAA,OAAAD,EAAAqD,EAAAC,EAAA5D,KAAA,IAAA,KAAA,GAAAM,EAAAC,EAAA,GAAA,MAAA,KAAA,GAAAD,EAAAC,EAAA,GAAA,MAAA,KAAA,GAAAD,EAAAX,EAAA,GAAAS,EAAAE,EAAAS,EAAAjB,EAAAoC,EAAA9B,GAAA,KAAA,GAAA,OAAAE,EAAAX,EAAA,GAAAG,EAAAqC,IAAA7B,EAAA6B,EAAA,IAAA,KAAA,GAAA,KAGxDtC,EAAwB2C,OAAS,GAAC,CAAAlC,EAAAC,EAAA,GAAA,KAAA,CAAA,OAAAD,EAAAc,EAAA,EAC7B,CACLqB,aAAcC,EAAamB,gCAC3BjB,iBAAgB,yDAAAC,OAGpBhD,EAAwBiD,IAAI,SAACnD,GAAC,MAAA,MAAAkD,OAAYlD,EAAC,IAAA,GAAM4B,KAAK,MAAK,QAExD,KAAA,GAAA,OAAAjB,EAAAc,EAAA,GAAA,EAAAvD,EAAA,KAAA,CAAA,CAAA,GAAA,GAAA,GAAA,IAAA,CAAA,GAAA,GAAA,GAAA,IAAA,CAAA,EAAA,GAAA,GAAA,KAAA,KAIJN,MAAAC,KAAAC,UAAA"}
|
|
1
|
+
{"version":3,"file":"judgeByStaticAnalysis.js","names":[],"sources":["../../src/helpers/judgeByStaticAnalysis.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { DecisionCode } from '../types/decisionCode.js';\nimport type { ProblemMarkdownFrontMatter } from '../types/problem.js';\nimport type { TestCaseResult } from '../types/testCaseResult.js';\n\nimport { findLanguageDefinitionByPath } from './findLanguageDefinitionByPath.js';\nimport { removeCommentsInSourceCode } from './removeCommentsInSourceCode.js';\n\nexport async function judgeByStaticAnalysis(\n cwd: string,\n problemMarkdownFrontMatterLike: Pick<\n ProblemMarkdownFrontMatter,\n 'forbiddenRegExpsInCode' | 'forbiddenTextsInCode' | 'requiredRegExpsInCode' | 'requiredSubmissionFilePaths'\n >\n): Promise<Pick<TestCaseResult, 'decisionCode' | 'feedbackMarkdown'> | undefined> {\n const filePathSet = new Set<string>();\n const sourceCodeWithoutCommentFiles: { path: string; data: string }[] = [];\n\n for (const dirent of await fs.promises.readdir(cwd, { withFileTypes: true, recursive: true })) {\n if (!dirent.isFile()) continue;\n\n const relativePath = path.relative(cwd, path.join(dirent.parentPath, dirent.name));\n filePathSet.add(relativePath);\n\n const text = await fs.promises.readFile(path.join(dirent.parentPath, dirent.name), 'utf8');\n const isBinary = text.includes('\\uFFFD');\n if (isBinary) continue;\n\n const languageDefinition = findLanguageDefinitionByPath(dirent.name);\n if (!languageDefinition) continue;\n\n sourceCodeWithoutCommentFiles.push({\n path: dirent.name,\n data: languageDefinition.grammer ? removeCommentsInSourceCode(languageDefinition.grammer, text) : text,\n });\n }\n\n if (problemMarkdownFrontMatterLike.requiredSubmissionFilePaths) {\n const missingFilePaths = problemMarkdownFrontMatterLike.requiredSubmissionFilePaths\n .filter((p) => !filePathSet.has(p))\n .toSorted();\n\n if (missingFilePaths.length > 0) {\n return {\n decisionCode: DecisionCode.MISSING_REQUIRED_SUBMISSION_FILE_ERROR,\n feedbackMarkdown: `ファイルが不足しています。\n次のファイルを追加してから再度提出してください。\n\n${missingFilePaths.map((p) => `- \\`${p}\\``).join('\\n')}\n`,\n };\n }\n }\n\n const forbiddenFounds: { pattern: string; path: string; match: string }[] = [];\n\n for (const file of sourceCodeWithoutCommentFiles) {\n for (const pattern of problemMarkdownFrontMatterLike.forbiddenRegExpsInCode ?? []) {\n const re = new RegExp(pattern, 'g');\n const mathces = file.data.matchAll(re);\n for (const match of mathces) forbiddenFounds.push({ pattern: re.toString(), path: file.path, match: match[0] });\n }\n for (const pattern of problemMarkdownFrontMatterLike.forbiddenTextsInCode ?? []) {\n let p = 0;\n while (p < file.data.length) {\n const index = file.data.indexOf(pattern, p);\n if (index === -1) break;\n forbiddenFounds.push({ pattern, path: file.path, match: pattern });\n p = index + pattern.length;\n }\n }\n }\n\n if (forbiddenFounds.length > 0) {\n return {\n decisionCode: DecisionCode.FORBIDDEN_PATTERNS_IN_CODE_ERROR,\n feedbackMarkdown: `ソースコード中に禁止された文字列が含まれています。\nソースコードを修正してから再度提出してください。\n\n| ファイル | 禁止パターン | 文字列 |\n| -------- | ------------ | ------ |\n${forbiddenFounds.map((f) => `| \\`${f.path}\\` | \\`${f.pattern}\\` | \\`${f.match}\\` |`).join('\\n')}\n`,\n };\n }\n\n const missingRequiredPatterns: string[] = [];\n\n for (const pattern of problemMarkdownFrontMatterLike.requiredRegExpsInCode ?? []) {\n const re = new RegExp(pattern);\n const isFound = sourceCodeWithoutCommentFiles.some((f) => re.test(f.data));\n if (!isFound) missingRequiredPatterns.push(re.toString());\n }\n\n if (missingRequiredPatterns.length > 0) {\n return {\n decisionCode: DecisionCode.REQUIRED_PATTERNS_IN_CODE_ERROR,\n feedbackMarkdown: `ソースコード中に必要な文字列が含まれていません。\nソースコードを修正してから再度提出してください。\n\n${missingRequiredPatterns.map((p) => `- \\`${p}\\``).join('\\n')}\n`,\n };\n }\n\n return;\n}\n"],"mappings":"sQAUA,eAAsB,EACpB,EACA,EAIgF,CAChF,IAAM,EAAc,IAAI,IAClB,EAAkE,CAAC,EAEzE,IAAK,IAAM,KAAU,MAAM,EAAG,SAAS,QAAQ,EAAK,CAAE,cAAe,GAAM,UAAW,EAAK,CAAC,EAAG,CAC7F,GAAI,CAAC,EAAO,OAAO,EAAG,SAEtB,IAAM,EAAe,EAAK,SAAS,EAAK,EAAK,KAAK,EAAO,WAAY,EAAO,IAAI,CAAC,EACjF,EAAY,IAAI,CAAY,EAE5B,IAAM,EAAO,MAAM,EAAG,SAAS,SAAS,EAAK,KAAK,EAAO,WAAY,EAAO,IAAI,EAAG,MAAM,EAEzF,GADiB,EAAK,SAAS,GACpB,EAAG,SAEd,IAAM,EAAqB,EAA6B,EAAO,IAAI,EAC9D,GAEL,EAA8B,KAAK,CACjC,KAAM,EAAO,KACb,KAAM,EAAmB,QAAU,EAA2B,EAAmB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I,OAAO,CAAO,EACb,EAA8B,KAAM,GAAM,EAAG,KAAK,EAAE,IAAI,CAC7D,GAAG,EAAwB,KAAK,EAAG,SAAS,CAAC,CAC1D,CAEA,GAAI,EAAwB,OAAS,EACnC,MAAO,CACL,aAAc,EAAa,gCAC3B,iBAAkB;;;EAGtB,EAAwB,IAAK,GAAM,OAAO,EAAE,GAAG,CAAC,CAAC,KAAK;CAAI,EAAE;CAE1D,CAIJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
//# sourceMappingURL=parseArgs.cjs.map
|
|
1
|
+
"use strict";function e(e){let t=e[2]||void 0,n=e[3];try{return{cwd:t,params:n?JSON.parse(n):{}}}catch(e){throw Error(`bad params argument`,{cause:e})}}exports.parseArgs=e;
|
|
2
|
+
//# sourceMappingURL=parseArgs.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseArgs.cjs","sources":["../../src/helpers/parseArgs.ts"],"sourcesContent":["/**\n * Parse command line arguments in `judge.ts` or `debug.ts`.\n *\n * `cwd` is optional: when omitted, presets that support it may fall back to\n * judging against model answers under `<problemDir>/model_answers/*`.\n */\nexport function parseArgs(argv: readonly string[]): { cwd: string | undefined; params: unknown } {\n const cwd = argv[2] || undefined;\n const paramsJson = argv[3];\n\n try {\n return { cwd, params: paramsJson ? JSON.parse(paramsJson) : {} };\n } catch (error) {\n throw new Error('bad params argument', { cause: error });\n }\n}\n"],"
|
|
1
|
+
{"version":3,"file":"parseArgs.cjs","names":[],"sources":["../../src/helpers/parseArgs.ts"],"sourcesContent":["/**\n * Parse command line arguments in `judge.ts` or `debug.ts`.\n *\n * `cwd` is optional: when omitted, presets that support it may fall back to\n * judging against model answers under `<problemDir>/model_answers/*`.\n */\nexport function parseArgs(argv: readonly string[]): { cwd: string | undefined; params: unknown } {\n const cwd = argv[2] || undefined;\n const paramsJson = argv[3];\n\n try {\n return { cwd, params: paramsJson ? JSON.parse(paramsJson) : {} };\n } catch (error) {\n throw new Error('bad params argument', { cause: error });\n }\n}\n"],"mappings":"aAMA,SAAgB,EAAU,EAAuE,CAC/F,IAAM,EAAM,EAAK,IAAM,IAAA,GACjB,EAAa,EAAK,GAExB,GAAI,CACF,MAAO,CAAE,MAAK,OAAQ,EAAa,KAAK,MAAM,CAAU,EAAI,CAAC,CAAE,CACjE,OAAS,EAAO,CACd,MAAU,MAAM,sBAAuB,CAAE,MAAO,CAAM,CAAC,CACzD,CACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
2
|
-
//# sourceMappingURL=parseArgs.js.map
|
|
1
|
+
function e(e){let t=e[2]||void 0,n=e[3];try{return{cwd:t,params:n?JSON.parse(n):{}}}catch(e){throw Error(`bad params argument`,{cause:e})}}export{e as parseArgs};
|
|
2
|
+
//# sourceMappingURL=parseArgs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseArgs.js","sources":["../../src/helpers/parseArgs.ts"],"sourcesContent":["/**\n * Parse command line arguments in `judge.ts` or `debug.ts`.\n *\n * `cwd` is optional: when omitted, presets that support it may fall back to\n * judging against model answers under `<problemDir>/model_answers/*`.\n */\nexport function parseArgs(argv: readonly string[]): { cwd: string | undefined; params: unknown } {\n const cwd = argv[2] || undefined;\n const paramsJson = argv[3];\n\n try {\n return { cwd, params: paramsJson ? JSON.parse(paramsJson) : {} };\n } catch (error) {\n throw new Error('bad params argument', { cause: error });\n }\n}\n"],"
|
|
1
|
+
{"version":3,"file":"parseArgs.js","names":[],"sources":["../../src/helpers/parseArgs.ts"],"sourcesContent":["/**\n * Parse command line arguments in `judge.ts` or `debug.ts`.\n *\n * `cwd` is optional: when omitted, presets that support it may fall back to\n * judging against model answers under `<problemDir>/model_answers/*`.\n */\nexport function parseArgs(argv: readonly string[]): { cwd: string | undefined; params: unknown } {\n const cwd = argv[2] || undefined;\n const paramsJson = argv[3];\n\n try {\n return { cwd, params: paramsJson ? JSON.parse(paramsJson) : {} };\n } catch (error) {\n throw new Error('bad params argument', { cause: error });\n }\n}\n"],"mappings":"AAMA,SAAgB,EAAU,EAAuE,CAC/F,IAAM,EAAM,EAAK,IAAM,IAAA,GACjB,EAAa,EAAK,GAExB,GAAI,CACF,MAAO,CAAE,MAAK,OAAQ,EAAa,KAAK,MAAM,CAAU,EAAI,CAAC,CAAE,CACjE,OAAS,EAAO,CACd,MAAU,MAAM,sBAAuB,CAAE,MAAO,CAAM,CAAC,CACzD,CACF"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
1
|
+
"use strict";const e=`=`.repeat(72);function t(t){let n=t.map(e=>` ${e}`).join(`
|
|
2
|
+
`);console.warn(`\n${e}\n${n}\n${e}`)}exports.printDebugBanner=t;
|
|
3
|
+
//# sourceMappingURL=printDebugBanner.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printDebugBanner.cjs","sources":["../../src/helpers/printDebugBanner.ts"],"sourcesContent":["const BANNER_LINE = '='.repeat(72);\n\n/**\n * Print a prominent, multi-line banner to stderr so that debug-mode runs\n * (e.g., judging against model answers without an explicit cwd) are obvious.\n *\n * Written to stderr to avoid interfering with `printTestCaseResult` output on stdout.\n */\nexport function printDebugBanner(lines: readonly string[]): void {\n const body = lines.map((line) => ` ${line}`).join('\\n');\n console.warn(`\\n${BANNER_LINE}\\n${body}\\n${BANNER_LINE}`);\n}\n"],"
|
|
1
|
+
{"version":3,"file":"printDebugBanner.cjs","names":[],"sources":["../../src/helpers/printDebugBanner.ts"],"sourcesContent":["const BANNER_LINE = '='.repeat(72);\n\n/**\n * Print a prominent, multi-line banner to stderr so that debug-mode runs\n * (e.g., judging against model answers without an explicit cwd) are obvious.\n *\n * Written to stderr to avoid interfering with `printTestCaseResult` output on stdout.\n */\nexport function printDebugBanner(lines: readonly string[]): void {\n const body = lines.map((line) => ` ${line}`).join('\\n');\n console.warn(`\\n${BANNER_LINE}\\n${body}\\n${BANNER_LINE}`);\n}\n"],"mappings":"aAAA,MAAM,EAAc,IAAI,OAAO,EAAE,EAQjC,SAAgB,EAAiB,EAAgC,CAC/D,IAAM,EAAO,EAAM,IAAK,GAAS,KAAK,GAAM,CAAC,CAAC,KAAK;CAAI,EACvD,QAAQ,KAAK,KAAK,EAAY,IAAI,EAAK,IAAI,GAAa,CAC1D"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const e=`=`.repeat(72);function t(t){let n=t.map(e=>` ${e}`).join(`
|
|
2
|
+
`);console.warn(`\n${e}\n${n}\n${e}`)}export{t as printDebugBanner};
|
|
3
|
+
//# sourceMappingURL=printDebugBanner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printDebugBanner.js","sources":["../../src/helpers/printDebugBanner.ts"],"sourcesContent":["const BANNER_LINE = '='.repeat(72);\n\n/**\n * Print a prominent, multi-line banner to stderr so that debug-mode runs\n * (e.g., judging against model answers without an explicit cwd) are obvious.\n *\n * Written to stderr to avoid interfering with `printTestCaseResult` output on stdout.\n */\nexport function printDebugBanner(lines: readonly string[]): void {\n const body = lines.map((line) => ` ${line}`).join('\\n');\n console.warn(`\\n${BANNER_LINE}\\n${body}\\n${BANNER_LINE}`);\n}\n"],"
|
|
1
|
+
{"version":3,"file":"printDebugBanner.js","names":[],"sources":["../../src/helpers/printDebugBanner.ts"],"sourcesContent":["const BANNER_LINE = '='.repeat(72);\n\n/**\n * Print a prominent, multi-line banner to stderr so that debug-mode runs\n * (e.g., judging against model answers without an explicit cwd) are obvious.\n *\n * Written to stderr to avoid interfering with `printTestCaseResult` output on stdout.\n */\nexport function printDebugBanner(lines: readonly string[]): void {\n const body = lines.map((line) => ` ${line}`).join('\\n');\n console.warn(`\\n${BANNER_LINE}\\n${body}\\n${BANNER_LINE}`);\n}\n"],"mappings":"AAAA,MAAM,EAAc,IAAI,OAAO,EAAE,EAQjC,SAAgB,EAAiB,EAAgC,CAC/D,IAAM,EAAO,EAAM,IAAK,GAAS,KAAK,GAAM,CAAC,CAAC,KAAK;CAAI,EACvD,QAAQ,KAAK,KAAK,EAAY,IAAI,EAAK,IAAI,GAAa,CAC1D"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
//# sourceMappingURL=printTestCaseResult.cjs.map
|
|
1
|
+
"use strict";const e=require("../types/testCaseResult.cjs");function t(t){console.info(`${e.TEST_CASE_RESULT_PREFIX}${JSON.stringify(t)}`)}function n(e,t){let n=t.toString(`utf8`);return n.includes(`�`)?{path:e,encoding:`base64`,data:t.toString(`base64`)}:{path:e,data:n}}exports.encodeFileForTestCaseResult=n,exports.printTestCaseResult=t;
|
|
2
|
+
//# sourceMappingURL=printTestCaseResult.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printTestCaseResult.cjs","sources":["../../src/helpers/printTestCaseResult.ts"],"sourcesContent":["import type { TestCaseResult } from '../types/testCaseResult.js';\nimport { TEST_CASE_RESULT_PREFIX } from '../types/testCaseResult.js';\n\n/**\n * Print a test case result in a format that can be read by the judge server.\n */\nexport function printTestCaseResult(result: TestCaseResult): void {\n console.info(`${TEST_CASE_RESULT_PREFIX}${JSON.stringify(result)}`);\n}\n\nexport function encodeFileForTestCaseResult(\n path: string,\n data: Buffer\n): NonNullable<TestCaseResult['outputFiles']>[number] {\n const utf8Text = data.toString('utf8');\n const isBinary = utf8Text.includes('\\uFFFD');\n return isBinary ? { path, encoding: 'base64', data: data.toString('base64') } : { path, data: utf8Text };\n}\n"],"
|
|
1
|
+
{"version":3,"file":"printTestCaseResult.cjs","names":["TEST_CASE_RESULT_PREFIX"],"sources":["../../src/helpers/printTestCaseResult.ts"],"sourcesContent":["import type { TestCaseResult } from '../types/testCaseResult.js';\nimport { TEST_CASE_RESULT_PREFIX } from '../types/testCaseResult.js';\n\n/**\n * Print a test case result in a format that can be read by the judge server.\n */\nexport function printTestCaseResult(result: TestCaseResult): void {\n console.info(`${TEST_CASE_RESULT_PREFIX}${JSON.stringify(result)}`);\n}\n\nexport function encodeFileForTestCaseResult(\n path: string,\n data: Buffer\n): NonNullable<TestCaseResult['outputFiles']>[number] {\n const utf8Text = data.toString('utf8');\n const isBinary = utf8Text.includes('\\uFFFD');\n return isBinary ? { path, encoding: 'base64', data: data.toString('base64') } : { path, data: utf8Text };\n}\n"],"mappings":"4DAMA,SAAgB,EAAoB,EAA8B,CAChE,QAAQ,KAAK,GAAGA,EAAAA,0BAA0B,KAAK,UAAU,CAAM,GAAG,CACpE,CAEA,SAAgB,EACd,EACA,EACoD,CACpD,IAAM,EAAW,EAAK,SAAS,MAAM,EAErC,OADiB,EAAS,SAAS,GACrB,EAAI,CAAE,OAAM,SAAU,SAAU,KAAM,EAAK,SAAS,QAAQ,CAAE,EAAI,CAAE,OAAM,KAAM,CAAS,CACzG"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{TEST_CASE_RESULT_PREFIX as
|
|
2
|
-
//# sourceMappingURL=printTestCaseResult.js.map
|
|
1
|
+
import{TEST_CASE_RESULT_PREFIX as e}from"../types/testCaseResult.js";function t(t){console.info(`${e}${JSON.stringify(t)}`)}function n(e,t){let n=t.toString(`utf8`);return n.includes(`�`)?{path:e,encoding:`base64`,data:t.toString(`base64`)}:{path:e,data:n}}export{n as encodeFileForTestCaseResult,t as printTestCaseResult};
|
|
2
|
+
//# sourceMappingURL=printTestCaseResult.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printTestCaseResult.js","sources":["../../src/helpers/printTestCaseResult.ts"],"sourcesContent":["import type { TestCaseResult } from '../types/testCaseResult.js';\nimport { TEST_CASE_RESULT_PREFIX } from '../types/testCaseResult.js';\n\n/**\n * Print a test case result in a format that can be read by the judge server.\n */\nexport function printTestCaseResult(result: TestCaseResult): void {\n console.info(`${TEST_CASE_RESULT_PREFIX}${JSON.stringify(result)}`);\n}\n\nexport function encodeFileForTestCaseResult(\n path: string,\n data: Buffer\n): NonNullable<TestCaseResult['outputFiles']>[number] {\n const utf8Text = data.toString('utf8');\n const isBinary = utf8Text.includes('\\uFFFD');\n return isBinary ? { path, encoding: 'base64', data: data.toString('base64') } : { path, data: utf8Text };\n}\n"],"
|
|
1
|
+
{"version":3,"file":"printTestCaseResult.js","names":[],"sources":["../../src/helpers/printTestCaseResult.ts"],"sourcesContent":["import type { TestCaseResult } from '../types/testCaseResult.js';\nimport { TEST_CASE_RESULT_PREFIX } from '../types/testCaseResult.js';\n\n/**\n * Print a test case result in a format that can be read by the judge server.\n */\nexport function printTestCaseResult(result: TestCaseResult): void {\n console.info(`${TEST_CASE_RESULT_PREFIX}${JSON.stringify(result)}`);\n}\n\nexport function encodeFileForTestCaseResult(\n path: string,\n data: Buffer\n): NonNullable<TestCaseResult['outputFiles']>[number] {\n const utf8Text = data.toString('utf8');\n const isBinary = utf8Text.includes('\\uFFFD');\n return isBinary ? { path, encoding: 'base64', data: data.toString('base64') } : { path, data: utf8Text };\n}\n"],"mappings":"qEAMA,SAAgB,EAAoB,EAA8B,CAChE,QAAQ,KAAK,GAAG,IAA0B,KAAK,UAAU,CAAM,GAAG,CACpE,CAEA,SAAgB,EACd,EACA,EACoD,CACpD,IAAM,EAAW,EAAK,SAAS,MAAM,EAErC,OADiB,EAAS,SAAS,GACrB,EAAI,CAAE,OAAM,SAAU,SAAU,KAAM,EAAK,SAAS,QAAQ,CAAE,EAAI,CAAE,OAAM,KAAM,CAAS,CACzG"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
//# sourceMappingURL=readOutputFiles.cjs.map
|
|
1
|
+
"use strict";const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("./printTestCaseResult.cjs");let n=require("node:path");n=e.__toESM(n,1);let r=require("node:fs");r=e.__toESM(r,1);async function i(e,i){let a=[];for(let o of i)try{let i=await r.default.promises.readFile(n.default.join(e,o));a.push(t.encodeFileForTestCaseResult(o,i))}catch{}return a}exports.readOutputFiles=i;
|
|
2
|
+
//# sourceMappingURL=readOutputFiles.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readOutputFiles.cjs","sources":["../../src/helpers/readOutputFiles.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport type { TestCaseResult } from '../types/testCaseResult.js';\n\nimport { encodeFileForTestCaseResult } from './printTestCaseResult.js';\n\nexport async function readOutputFiles(\n cwd: string,\n outputFilePaths: readonly string[]\n): Promise<NonNullable<TestCaseResult['outputFiles']>> {\n const outputFiles: NonNullable<TestCaseResult['outputFiles']> = [];\n for (const filePath of outputFilePaths) {\n try {\n const buffer = await fs.promises.readFile(path.join(cwd, filePath));\n outputFiles.push(encodeFileForTestCaseResult(filePath, buffer));\n } catch {\n // file not found\n }\n }\n return outputFiles;\n}\n"],"
|
|
1
|
+
{"version":3,"file":"readOutputFiles.cjs","names":["fs","path","encodeFileForTestCaseResult"],"sources":["../../src/helpers/readOutputFiles.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport type { TestCaseResult } from '../types/testCaseResult.js';\n\nimport { encodeFileForTestCaseResult } from './printTestCaseResult.js';\n\nexport async function readOutputFiles(\n cwd: string,\n outputFilePaths: readonly string[]\n): Promise<NonNullable<TestCaseResult['outputFiles']>> {\n const outputFiles: NonNullable<TestCaseResult['outputFiles']> = [];\n for (const filePath of outputFilePaths) {\n try {\n const buffer = await fs.promises.readFile(path.join(cwd, filePath));\n outputFiles.push(encodeFileForTestCaseResult(filePath, buffer));\n } catch {\n // file not found\n }\n }\n return outputFiles;\n}\n"],"mappings":"+LAOA,eAAsB,EACpB,EACA,EACqD,CACrD,IAAM,EAA0D,CAAC,EACjE,IAAK,IAAM,KAAY,EACrB,GAAI,CACF,IAAM,EAAS,MAAMA,EAAAA,QAAG,SAAS,SAASC,EAAAA,QAAK,KAAK,EAAK,CAAQ,CAAC,EAClE,EAAY,KAAKC,EAAAA,4BAA4B,EAAU,CAAM,CAAC,CAChE,MAAQ,CAER,CAEF,OAAO,CACT"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=readOutputFiles.js.map
|
|
1
|
+
import{encodeFileForTestCaseResult as e}from"./printTestCaseResult.js";import t from"node:path";import n from"node:fs";async function r(r,i){let a=[];for(let o of i)try{let i=await n.promises.readFile(t.join(r,o));a.push(e(o,i))}catch{}return a}export{r as readOutputFiles};
|
|
2
|
+
//# sourceMappingURL=readOutputFiles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readOutputFiles.js","sources":["../../src/helpers/readOutputFiles.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport type { TestCaseResult } from '../types/testCaseResult.js';\n\nimport { encodeFileForTestCaseResult } from './printTestCaseResult.js';\n\nexport async function readOutputFiles(\n cwd: string,\n outputFilePaths: readonly string[]\n): Promise<NonNullable<TestCaseResult['outputFiles']>> {\n const outputFiles: NonNullable<TestCaseResult['outputFiles']> = [];\n for (const filePath of outputFilePaths) {\n try {\n const buffer = await fs.promises.readFile(path.join(cwd, filePath));\n outputFiles.push(encodeFileForTestCaseResult(filePath, buffer));\n } catch {\n // file not found\n }\n }\n return outputFiles;\n}\n"],"
|
|
1
|
+
{"version":3,"file":"readOutputFiles.js","names":[],"sources":["../../src/helpers/readOutputFiles.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport type { TestCaseResult } from '../types/testCaseResult.js';\n\nimport { encodeFileForTestCaseResult } from './printTestCaseResult.js';\n\nexport async function readOutputFiles(\n cwd: string,\n outputFilePaths: readonly string[]\n): Promise<NonNullable<TestCaseResult['outputFiles']>> {\n const outputFiles: NonNullable<TestCaseResult['outputFiles']> = [];\n for (const filePath of outputFilePaths) {\n try {\n const buffer = await fs.promises.readFile(path.join(cwd, filePath));\n outputFiles.push(encodeFileForTestCaseResult(filePath, buffer));\n } catch {\n // file not found\n }\n }\n return outputFiles;\n}\n"],"mappings":"uHAOA,eAAsB,EACpB,EACA,EACqD,CACrD,IAAM,EAA0D,CAAC,EACjE,IAAK,IAAM,KAAY,EACrB,GAAI,CACF,IAAM,EAAS,MAAM,EAAG,SAAS,SAAS,EAAK,KAAK,EAAK,CAAQ,CAAC,EAClE,EAAY,KAAK,EAA4B,EAAU,CAAM,CAAC,CAChE,MAAQ,CAER,CAEF,OAAO,CACT"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
//# sourceMappingURL=readProblemMarkdownFrontMatter.cjs.map
|
|
1
|
+
"use strict";const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("../types/problem.cjs");let n=require("node:path");n=e.__toESM(n,1);let r=require("node:fs");r=e.__toESM(r,1);let i=require("front-matter");i=e.__toESM(i,1);async function a(e){for(let a of await r.default.promises.readdir(e,{withFileTypes:!0})){if(!a.isFile()||!(a.name===`problem.md`||a.name.endsWith(`.problem.md`)))continue;let{attributes:e}=(0,i.default)(await r.default.promises.readFile(n.default.join(a.parentPath,a.name),`utf8`));return t.problemMarkdownFrontMatterSchema.parse(e)}throw Error(`problem markdown not found: ${e}`)}exports.readProblemMarkdownFrontMatter=a;
|
|
2
|
+
//# sourceMappingURL=readProblemMarkdownFrontMatter.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readProblemMarkdownFrontMatter.cjs","sources":["../../src/helpers/readProblemMarkdownFrontMatter.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport parseFrontMatter from 'front-matter';\n\nimport type { ProblemMarkdownFrontMatter } from '../types/problem.js';\nimport { problemMarkdownFrontMatterSchema } from '../types/problem.js';\n\nexport async function readProblemMarkdownFrontMatter(problemDir: string): Promise<ProblemMarkdownFrontMatter> {\n for (const dirent of await fs.promises.readdir(problemDir, { withFileTypes: true })) {\n if (!dirent.isFile()) continue;\n if (!(dirent.name === 'problem.md' || dirent.name.endsWith('.problem.md'))) continue;\n\n const markdown = await fs.promises.readFile(path.join(dirent.parentPath, dirent.name), 'utf8');\n\n const { attributes } = (parseFrontMatter as unknown as (markdown: string) => { attributes: unknown })(markdown);\n\n return problemMarkdownFrontMatterSchema.parse(attributes);\n }\n\n throw new Error(`problem markdown not found: ${problemDir}`);\n}\n"],"
|
|
1
|
+
{"version":3,"file":"readProblemMarkdownFrontMatter.cjs","names":["fs","path","problemMarkdownFrontMatterSchema"],"sources":["../../src/helpers/readProblemMarkdownFrontMatter.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport parseFrontMatter from 'front-matter';\n\nimport type { ProblemMarkdownFrontMatter } from '../types/problem.js';\nimport { problemMarkdownFrontMatterSchema } from '../types/problem.js';\n\nexport async function readProblemMarkdownFrontMatter(problemDir: string): Promise<ProblemMarkdownFrontMatter> {\n for (const dirent of await fs.promises.readdir(problemDir, { withFileTypes: true })) {\n if (!dirent.isFile()) continue;\n if (!(dirent.name === 'problem.md' || dirent.name.endsWith('.problem.md'))) continue;\n\n const markdown = await fs.promises.readFile(path.join(dirent.parentPath, dirent.name), 'utf8');\n\n const { attributes } = (parseFrontMatter as unknown as (markdown: string) => { attributes: unknown })(markdown);\n\n return problemMarkdownFrontMatterSchema.parse(attributes);\n }\n\n throw new Error(`problem markdown not found: ${problemDir}`);\n}\n"],"mappings":"yOAQA,eAAsB,EAA+B,EAAyD,CAC5G,IAAK,IAAM,KAAU,MAAMA,EAAAA,QAAG,SAAS,QAAQ,EAAY,CAAE,cAAe,EAAK,CAAC,EAAG,CAEnF,GADI,CAAC,EAAO,OAAO,GACf,EAAE,EAAO,OAAS,cAAgB,EAAO,KAAK,SAAS,aAAa,GAAI,SAI5E,GAAM,CAAE,eAAA,EAAA,EAAA,QAAA,CAA8F,MAF/EA,EAAAA,QAAG,SAAS,SAASC,EAAAA,QAAK,KAAK,EAAO,WAAY,EAAO,IAAI,EAAG,MAAM,CAEiB,EAE9G,OAAOC,EAAAA,iCAAiC,MAAM,CAAU,CAC1D,CAEA,MAAU,MAAM,+BAA+B,GAAY,CAC7D"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=readProblemMarkdownFrontMatter.js.map
|
|
1
|
+
import{problemMarkdownFrontMatterSchema as e}from"../types/problem.js";import t from"node:path";import n from"node:fs";import r from"front-matter";async function i(i){for(let a of await n.promises.readdir(i,{withFileTypes:!0})){if(!a.isFile()||!(a.name===`problem.md`||a.name.endsWith(`.problem.md`)))continue;let{attributes:i}=r(await n.promises.readFile(t.join(a.parentPath,a.name),`utf8`));return e.parse(i)}throw Error(`problem markdown not found: ${i}`)}export{i as readProblemMarkdownFrontMatter};
|
|
2
|
+
//# sourceMappingURL=readProblemMarkdownFrontMatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readProblemMarkdownFrontMatter.js","sources":["../../src/helpers/readProblemMarkdownFrontMatter.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport parseFrontMatter from 'front-matter';\n\nimport type { ProblemMarkdownFrontMatter } from '../types/problem.js';\nimport { problemMarkdownFrontMatterSchema } from '../types/problem.js';\n\nexport async function readProblemMarkdownFrontMatter(problemDir: string): Promise<ProblemMarkdownFrontMatter> {\n for (const dirent of await fs.promises.readdir(problemDir, { withFileTypes: true })) {\n if (!dirent.isFile()) continue;\n if (!(dirent.name === 'problem.md' || dirent.name.endsWith('.problem.md'))) continue;\n\n const markdown = await fs.promises.readFile(path.join(dirent.parentPath, dirent.name), 'utf8');\n\n const { attributes } = (parseFrontMatter as unknown as (markdown: string) => { attributes: unknown })(markdown);\n\n return problemMarkdownFrontMatterSchema.parse(attributes);\n }\n\n throw new Error(`problem markdown not found: ${problemDir}`);\n}\n"],"
|
|
1
|
+
{"version":3,"file":"readProblemMarkdownFrontMatter.js","names":[],"sources":["../../src/helpers/readProblemMarkdownFrontMatter.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport parseFrontMatter from 'front-matter';\n\nimport type { ProblemMarkdownFrontMatter } from '../types/problem.js';\nimport { problemMarkdownFrontMatterSchema } from '../types/problem.js';\n\nexport async function readProblemMarkdownFrontMatter(problemDir: string): Promise<ProblemMarkdownFrontMatter> {\n for (const dirent of await fs.promises.readdir(problemDir, { withFileTypes: true })) {\n if (!dirent.isFile()) continue;\n if (!(dirent.name === 'problem.md' || dirent.name.endsWith('.problem.md'))) continue;\n\n const markdown = await fs.promises.readFile(path.join(dirent.parentPath, dirent.name), 'utf8');\n\n const { attributes } = (parseFrontMatter as unknown as (markdown: string) => { attributes: unknown })(markdown);\n\n return problemMarkdownFrontMatterSchema.parse(attributes);\n }\n\n throw new Error(`problem markdown not found: ${problemDir}`);\n}\n"],"mappings":"mJAQA,eAAsB,EAA+B,EAAyD,CAC5G,IAAK,IAAM,KAAU,MAAM,EAAG,SAAS,QAAQ,EAAY,CAAE,cAAe,EAAK,CAAC,EAAG,CAEnF,GADI,CAAC,EAAO,OAAO,GACf,EAAE,EAAO,OAAS,cAAgB,EAAO,KAAK,SAAS,aAAa,GAAI,SAI5E,GAAM,CAAE,cAAgB,EAA8E,MAF/E,EAAG,SAAS,SAAS,EAAK,KAAK,EAAO,WAAY,EAAO,IAAI,EAAG,MAAM,CAEiB,EAE9G,OAAO,EAAiC,MAAM,CAAU,CAC1D,CAEA,MAAU,MAAM,+BAA+B,GAAY,CAC7D"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
//# sourceMappingURL=readTestCases.cjs.map
|
|
1
|
+
"use strict";const e=require("../_virtual/_rolldown/runtime.cjs");let t=require("node:path");t=e.__toESM(t,1);let n=require("node:fs");n=e.__toESM(n,1);const r=`_shared`;async function i(e){if(!n.default.existsSync(e))return[];let i=new Set,a=new Map,o=new Map,s=new Map,c=new Map;for(let r of await n.default.promises.readdir(e,{withFileTypes:!0}))if(r.isFile()){let{ext:e,name:s}=t.default.parse(r.name);if(e!==`.in`&&e!==`.out`)continue;let c=await n.default.promises.readFile(t.default.join(r.parentPath,r.name),`utf8`);i.add(s),e===`.in`&&a.set(s,c),e===`.out`&&o.set(s,c)}else if(r.isDirectory()){let{ext:e,name:n}=t.default.parse(r.name);if(e!==`.fin`&&e!==`.fout`)continue;i.add(n),e===`.fin`&&s.set(n,t.default.join(r.parentPath,r.name)),e===`.fout`&&c.set(n,t.default.join(r.parentPath,r.name))}let l=[...i].filter(e=>e!==r).toSorted().map(e=>({id:e,input:a.get(e),output:o.get(e),fileInputPath:s.get(e),fileOutputPath:c.get(e)}));return i.has(r)&&(l.shared={fileInputPath:s.get(r)}),l}exports.readTestCases=i;
|
|
2
|
+
//# sourceMappingURL=readTestCases.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readTestCases.cjs","sources":["../../src/helpers/readTestCases.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nconst SHARED_TEST_CASE_NAME = '_shared';\n\nexport async function readTestCases(directory: string): Promise<\n { id: string; input?: string; output?: string; fileInputPath?: string; fileOutputPath?: string }[] & {\n shared?: { fileInputPath?: string };\n }\n> {\n if (!fs.existsSync(directory)) return [];\n\n const idSet = new Set<string>();\n const idToInput = new Map<string, string>();\n const idToOutput = new Map<string, string>();\n const idToFileInputPath = new Map<string, string>();\n const idToFileOutputPath = new Map<string, string>();\n\n for (const dirent of await fs.promises.readdir(directory, { withFileTypes: true })) {\n if (dirent.isFile()) {\n const { ext, name } = path.parse(dirent.name);\n if (ext !== '.in' && ext !== '.out') continue;\n\n const text = await fs.promises.readFile(path.join(dirent.parentPath, dirent.name), 'utf8');\n\n idSet.add(name);\n if (ext === '.in') idToInput.set(name, text);\n if (ext === '.out') idToOutput.set(name, text);\n } else if (dirent.isDirectory()) {\n const { ext, name } = path.parse(dirent.name);\n if (ext !== '.fin' && ext !== '.fout') continue;\n\n idSet.add(name);\n if (ext === '.fin') idToFileInputPath.set(name, path.join(dirent.parentPath, dirent.name));\n if (ext === '.fout') idToFileOutputPath.set(name, path.join(dirent.parentPath, dirent.name));\n }\n }\n\n const testCases: Awaited<ReturnType<typeof readTestCases>> = [...idSet]\n .filter((id) => id !== SHARED_TEST_CASE_NAME)\n .toSorted()\n .map((id) => ({\n id,\n input: idToInput.get(id),\n output: idToOutput.get(id),\n fileInputPath: idToFileInputPath.get(id),\n fileOutputPath: idToFileOutputPath.get(id),\n }));\n\n if (idSet.has(SHARED_TEST_CASE_NAME)) {\n testCases.shared = { fileInputPath: idToFileInputPath.get(SHARED_TEST_CASE_NAME) };\n }\n\n return testCases;\n}\n"],"
|
|
1
|
+
{"version":3,"file":"readTestCases.cjs","names":["fs","path"],"sources":["../../src/helpers/readTestCases.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nconst SHARED_TEST_CASE_NAME = '_shared';\n\nexport async function readTestCases(directory: string): Promise<\n { id: string; input?: string; output?: string; fileInputPath?: string; fileOutputPath?: string }[] & {\n shared?: { fileInputPath?: string };\n }\n> {\n if (!fs.existsSync(directory)) return [];\n\n const idSet = new Set<string>();\n const idToInput = new Map<string, string>();\n const idToOutput = new Map<string, string>();\n const idToFileInputPath = new Map<string, string>();\n const idToFileOutputPath = new Map<string, string>();\n\n for (const dirent of await fs.promises.readdir(directory, { withFileTypes: true })) {\n if (dirent.isFile()) {\n const { ext, name } = path.parse(dirent.name);\n if (ext !== '.in' && ext !== '.out') continue;\n\n const text = await fs.promises.readFile(path.join(dirent.parentPath, dirent.name), 'utf8');\n\n idSet.add(name);\n if (ext === '.in') idToInput.set(name, text);\n if (ext === '.out') idToOutput.set(name, text);\n } else if (dirent.isDirectory()) {\n const { ext, name } = path.parse(dirent.name);\n if (ext !== '.fin' && ext !== '.fout') continue;\n\n idSet.add(name);\n if (ext === '.fin') idToFileInputPath.set(name, path.join(dirent.parentPath, dirent.name));\n if (ext === '.fout') idToFileOutputPath.set(name, path.join(dirent.parentPath, dirent.name));\n }\n }\n\n const testCases: Awaited<ReturnType<typeof readTestCases>> = [...idSet]\n .filter((id) => id !== SHARED_TEST_CASE_NAME)\n .toSorted()\n .map((id) => ({\n id,\n input: idToInput.get(id),\n output: idToOutput.get(id),\n fileInputPath: idToFileInputPath.get(id),\n fileOutputPath: idToFileOutputPath.get(id),\n }));\n\n if (idSet.has(SHARED_TEST_CASE_NAME)) {\n testCases.shared = { fileInputPath: idToFileInputPath.get(SHARED_TEST_CASE_NAME) };\n }\n\n return testCases;\n}\n"],"mappings":"wJAGA,MAAM,EAAwB,UAE9B,eAAsB,EAAc,EAIlC,CACA,GAAI,CAACA,EAAAA,QAAG,WAAW,CAAS,EAAG,MAAO,CAAC,EAEvC,IAAM,EAAQ,IAAI,IACZ,EAAY,IAAI,IAChB,EAAa,IAAI,IACjB,EAAoB,IAAI,IACxB,EAAqB,IAAI,IAE/B,IAAK,IAAM,KAAU,MAAMA,EAAAA,QAAG,SAAS,QAAQ,EAAW,CAAE,cAAe,EAAK,CAAC,EAC/E,GAAI,EAAO,OAAO,EAAG,CACnB,GAAM,CAAE,MAAK,QAASC,EAAAA,QAAK,MAAM,EAAO,IAAI,EAC5C,GAAI,IAAQ,OAAS,IAAQ,OAAQ,SAErC,IAAM,EAAO,MAAMD,EAAAA,QAAG,SAAS,SAASC,EAAAA,QAAK,KAAK,EAAO,WAAY,EAAO,IAAI,EAAG,MAAM,EAEzF,EAAM,IAAI,CAAI,EACV,IAAQ,OAAO,EAAU,IAAI,EAAM,CAAI,EACvC,IAAQ,QAAQ,EAAW,IAAI,EAAM,CAAI,CAC/C,MAAO,GAAI,EAAO,YAAY,EAAG,CAC/B,GAAM,CAAE,MAAK,QAASA,EAAAA,QAAK,MAAM,EAAO,IAAI,EAC5C,GAAI,IAAQ,QAAU,IAAQ,QAAS,SAEvC,EAAM,IAAI,CAAI,EACV,IAAQ,QAAQ,EAAkB,IAAI,EAAMA,EAAAA,QAAK,KAAK,EAAO,WAAY,EAAO,IAAI,CAAC,EACrF,IAAQ,SAAS,EAAmB,IAAI,EAAMA,EAAAA,QAAK,KAAK,EAAO,WAAY,EAAO,IAAI,CAAC,CAC7F,CAGF,IAAM,EAAuD,CAAC,GAAG,CAAK,CAAC,CACpE,OAAQ,GAAO,IAAO,CAAqB,CAAC,CAC5C,SAAS,CAAC,CACV,IAAK,IAAQ,CACZ,KACA,MAAO,EAAU,IAAI,CAAE,EACvB,OAAQ,EAAW,IAAI,CAAE,EACzB,cAAe,EAAkB,IAAI,CAAE,EACvC,eAAgB,EAAmB,IAAI,CAAE,CAC3C,EAAE,EAMJ,OAJI,EAAM,IAAI,CAAqB,IACjC,EAAU,OAAS,CAAE,cAAe,EAAkB,IAAI,CAAqB,CAAE,GAG5E,CACT"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
//# sourceMappingURL=readTestCases.js.map
|
|
1
|
+
import e from"node:path";import t from"node:fs";const n=`_shared`;async function r(r){if(!t.existsSync(r))return[];let i=new Set,a=new Map,o=new Map,s=new Map,c=new Map;for(let n of await t.promises.readdir(r,{withFileTypes:!0}))if(n.isFile()){let{ext:r,name:s}=e.parse(n.name);if(r!==`.in`&&r!==`.out`)continue;let c=await t.promises.readFile(e.join(n.parentPath,n.name),`utf8`);i.add(s),r===`.in`&&a.set(s,c),r===`.out`&&o.set(s,c)}else if(n.isDirectory()){let{ext:t,name:r}=e.parse(n.name);if(t!==`.fin`&&t!==`.fout`)continue;i.add(r),t===`.fin`&&s.set(r,e.join(n.parentPath,n.name)),t===`.fout`&&c.set(r,e.join(n.parentPath,n.name))}let l=[...i].filter(e=>e!==n).toSorted().map(e=>({id:e,input:a.get(e),output:o.get(e),fileInputPath:s.get(e),fileOutputPath:c.get(e)}));return i.has(n)&&(l.shared={fileInputPath:s.get(n)}),l}export{r as readTestCases};
|
|
2
|
+
//# sourceMappingURL=readTestCases.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readTestCases.js","sources":["../../src/helpers/readTestCases.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nconst SHARED_TEST_CASE_NAME = '_shared';\n\nexport async function readTestCases(directory: string): Promise<\n { id: string; input?: string; output?: string; fileInputPath?: string; fileOutputPath?: string }[] & {\n shared?: { fileInputPath?: string };\n }\n> {\n if (!fs.existsSync(directory)) return [];\n\n const idSet = new Set<string>();\n const idToInput = new Map<string, string>();\n const idToOutput = new Map<string, string>();\n const idToFileInputPath = new Map<string, string>();\n const idToFileOutputPath = new Map<string, string>();\n\n for (const dirent of await fs.promises.readdir(directory, { withFileTypes: true })) {\n if (dirent.isFile()) {\n const { ext, name } = path.parse(dirent.name);\n if (ext !== '.in' && ext !== '.out') continue;\n\n const text = await fs.promises.readFile(path.join(dirent.parentPath, dirent.name), 'utf8');\n\n idSet.add(name);\n if (ext === '.in') idToInput.set(name, text);\n if (ext === '.out') idToOutput.set(name, text);\n } else if (dirent.isDirectory()) {\n const { ext, name } = path.parse(dirent.name);\n if (ext !== '.fin' && ext !== '.fout') continue;\n\n idSet.add(name);\n if (ext === '.fin') idToFileInputPath.set(name, path.join(dirent.parentPath, dirent.name));\n if (ext === '.fout') idToFileOutputPath.set(name, path.join(dirent.parentPath, dirent.name));\n }\n }\n\n const testCases: Awaited<ReturnType<typeof readTestCases>> = [...idSet]\n .filter((id) => id !== SHARED_TEST_CASE_NAME)\n .toSorted()\n .map((id) => ({\n id,\n input: idToInput.get(id),\n output: idToOutput.get(id),\n fileInputPath: idToFileInputPath.get(id),\n fileOutputPath: idToFileOutputPath.get(id),\n }));\n\n if (idSet.has(SHARED_TEST_CASE_NAME)) {\n testCases.shared = { fileInputPath: idToFileInputPath.get(SHARED_TEST_CASE_NAME) };\n }\n\n return testCases;\n}\n"],"
|
|
1
|
+
{"version":3,"file":"readTestCases.js","names":[],"sources":["../../src/helpers/readTestCases.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nconst SHARED_TEST_CASE_NAME = '_shared';\n\nexport async function readTestCases(directory: string): Promise<\n { id: string; input?: string; output?: string; fileInputPath?: string; fileOutputPath?: string }[] & {\n shared?: { fileInputPath?: string };\n }\n> {\n if (!fs.existsSync(directory)) return [];\n\n const idSet = new Set<string>();\n const idToInput = new Map<string, string>();\n const idToOutput = new Map<string, string>();\n const idToFileInputPath = new Map<string, string>();\n const idToFileOutputPath = new Map<string, string>();\n\n for (const dirent of await fs.promises.readdir(directory, { withFileTypes: true })) {\n if (dirent.isFile()) {\n const { ext, name } = path.parse(dirent.name);\n if (ext !== '.in' && ext !== '.out') continue;\n\n const text = await fs.promises.readFile(path.join(dirent.parentPath, dirent.name), 'utf8');\n\n idSet.add(name);\n if (ext === '.in') idToInput.set(name, text);\n if (ext === '.out') idToOutput.set(name, text);\n } else if (dirent.isDirectory()) {\n const { ext, name } = path.parse(dirent.name);\n if (ext !== '.fin' && ext !== '.fout') continue;\n\n idSet.add(name);\n if (ext === '.fin') idToFileInputPath.set(name, path.join(dirent.parentPath, dirent.name));\n if (ext === '.fout') idToFileOutputPath.set(name, path.join(dirent.parentPath, dirent.name));\n }\n }\n\n const testCases: Awaited<ReturnType<typeof readTestCases>> = [...idSet]\n .filter((id) => id !== SHARED_TEST_CASE_NAME)\n .toSorted()\n .map((id) => ({\n id,\n input: idToInput.get(id),\n output: idToOutput.get(id),\n fileInputPath: idToFileInputPath.get(id),\n fileOutputPath: idToFileOutputPath.get(id),\n }));\n\n if (idSet.has(SHARED_TEST_CASE_NAME)) {\n testCases.shared = { fileInputPath: idToFileInputPath.get(SHARED_TEST_CASE_NAME) };\n }\n\n return testCases;\n}\n"],"mappings":"gDAGA,MAAM,EAAwB,UAE9B,eAAsB,EAAc,EAIlC,CACA,GAAI,CAAC,EAAG,WAAW,CAAS,EAAG,MAAO,CAAC,EAEvC,IAAM,EAAQ,IAAI,IACZ,EAAY,IAAI,IAChB,EAAa,IAAI,IACjB,EAAoB,IAAI,IACxB,EAAqB,IAAI,IAE/B,IAAK,IAAM,KAAU,MAAM,EAAG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&&(!n.removeStrings||!e.strings?.length))return t;let s=[],c=0;for(;c<t.length;){let r;for(let e of a){let a=e.openRegExp;a.lastIndex=c;let o=a.exec(t);o&&i(o,e,r,n)&&(r={grammar:e,match:o})}if(r){let i=r.match.index;if(!r.grammar.isComment&&n.removeStrings&&(i=u(t,r.match.index)),s.push(t.slice(c,i)),r.grammar.isComment){let e=r.grammar.closeRegExp;e.lastIndex=r.match.index+r.match[0].length;let n=e.exec(t);c=n?n.index+n[0].length:t.length}else{c=o(t,r.match.index,r.grammar);let i=t.slice(r.match.index,c);n.removeStrings?s.push(f(e,a,t,r.match.index,i)):s.push(i)}}else s.push(t.slice(c)),c=t.length}return s.join(``)}function r(e){return[...e.comments?.map(e=>({closeRegExp:a(e.close??/(?=\n)/g),isComment:!0,openRegExp:a(e.open)}))??[],...e.strings?.map(e=>({closeRegExp:a(e.close),isComment:!1,openRegExp:a(e.open)}))??[]]}function i(e,t,n,r){return!n||e.index<n.match.index?!0:e.index>n.match.index?!1:r.removeStrings&&n.grammar.isComment&&!t.isComment}function a(e){return new RegExp(e,e.flags.includes(`g`)?e.flags:`${e.flags}g`)}function o(e,t,n){if(e[t]==="`")return s(e,t);if(p(e,t))return c(e,t);let r=n.closeRegExp;r.lastIndex=t+1;let i=r.exec(e);return i?i.index+i[0].length:e.length}function s(e,t){let n=t+1;for(;n<e.length;){if(e[n]===`\\`){n+=2;continue}if(e[n]==="`")return n+1;if(e[n]===`$`&&e[n+1]===`{`){n=g(e,n+2,`}`,{slashStartsRegExp:!0}).endIndex+1;continue}n+=1}return e.length}function c(e,t){let n=l(e,t),r=t+n.length;for(;r<e.length;){if(e.startsWith(n,r))return r+n.length;if(e[r]===`{`&&e[r+1]===`{`){r+=2;continue}if(e[r]===`{`){r=g(e,r+1,`}`,{slashStartsRegExp:!1}).endIndex+1;continue}r+=e[r]===`\\`?2:1}return e.length}function l(e,t){let n=e.slice(t,t+3);return n===`'''`||n===`"""`?n:e[t]??``}function u(e,t){let n=d(e,t);return n?t-n.length:t}function d(e,t){if(e[t]!==`"`&&e[t]!==`'`)return;let n=t-1;for(;n>=0&&/[A-Za-z]/.test(e[n]??``);)--n;let r=e.slice(n+1,t);if(!(!r||!/^[bfru]+$/i.test(r))&&!(n>=0&&/[\dA-Za-z_]/.test(e[n]??``)))return r}function f(e,t,n,r,i){return i.startsWith("`")?m(e,t,i):p(n,r)?h(e,t,i):``}function p(e,t){return d(e,t)?.toLowerCase().includes(`f`)??!1}function m(e,t,r){let i=[],a=1;for(;a<r.length-1;){if(r[a]===`\\`){a+=2;continue}if(r[a]===`$`&&r[a+1]===`{`){let o=g(r,a+2,`}`,{slashStartsRegExp:!0});i.push(n(e,o.content,{removeStrings:!0},t)),a=o.endIndex+1;continue}a+=1}return i.join(`
|
|
2
|
+
`)}function h(e,t,r){let i=l(r,0).length,a=[],o=i;for(;o<r.length-i;){if(r[o]===`{`&&r[o+1]===`{`){o+=2;continue}if(r[o]===`{`){let i=g(r,o+1,`}`,{slashStartsRegExp:!1});a.push(n(e,i.content,{removeStrings:!0},t)),o=i.endIndex+1;continue}o+=r[o]===`\\`?2:1}return a.join(`
|
|
3
|
+
`)}function g(e,t,n,r){let i=1,a=t;for(;a<e.length;){let o=e[a];if(o===`"`||o===`'`||o==="`"){a=_(e,a);continue}if(r.slashStartsRegExp&&e[a]===`/`&&e[a+1]===`/`){a=y(e,a);continue}if(r.slashStartsRegExp&&e[a]===`/`&&e[a+1]===`*`){a=b(e,a);continue}if(r.slashStartsRegExp&&o===`/`){a=v(e,a);continue}if(o===`{`&&(i+=1),o===n&&(--i,i===0))return{content:e.slice(t,a),endIndex:a};a+=1}return{content:e.slice(t),endIndex:e.length}}function _(e,t){let n=l(e,t),r=t+n.length;for(;r<e.length;){if(e[r]===`\\`){r+=2;continue}if(e.startsWith(n,r))return r+n.length;r+=1}return r}function v(e,t){let n=t+1,r=!1;for(;n<e.length;){if(e[n]===`\\`){n+=2;continue}if(e[n]===`[`&&(r=!0),e[n]===`]`&&(r=!1),e[n]===`/`&&!r){for(n+=1;/[A-Za-z]/.test(e[n]??``);)n+=1;return n}if(e[n]===`
|
|
4
|
+
`)return t+1;n+=1}return t+1}function y(e,t){let n=e.indexOf(`
|
|
5
|
+
`,t+2);return n===-1?e.length:n}function b(e,t){let n=e.indexOf(`*/`,t+2);return n===-1?e.length:n+2}exports.removeCommentsAndStringsInSourceCode=t,exports.removeCommentsInSourceCode=e;
|
|
6
|
+
//# sourceMappingURL=removeCommentsInSourceCode.cjs.map
|