fix(est): retain unchanged JDL content
This commit is contained in:
+17
-1
@@ -1,8 +1,17 @@
|
||||
// JDLCHK.dll field declarations: 4e926c..4fb010; EST writer e44f28/e4739c/e541ec.
|
||||
const { pack, unpack } = require("./archive.cjs");
|
||||
const { createHash } = require("node:crypto");
|
||||
const { cp949 } = require("./export-estx.cjs");
|
||||
const schema = require("./jdl-schema.json");
|
||||
const decoder = new TextDecoder("euc-kr", { fatal: true });
|
||||
function fingerprint(project) {
|
||||
const { originalJdlState, id, ...content } = project;
|
||||
return createHash("sha256").update(JSON.stringify(content)).digest("hex");
|
||||
}
|
||||
function markOriginal(project) {
|
||||
project.originalJdlState = fingerprint(project);
|
||||
return project;
|
||||
}
|
||||
const num = (v) => {
|
||||
const n = Number(v || 0);
|
||||
if (!Number.isFinite(n)) throw Error("JDL 수치 오류");
|
||||
@@ -55,6 +64,13 @@ function parse(name, bytes) {
|
||||
});
|
||||
}
|
||||
function output(project) {
|
||||
if (project.originalJdl && project.originalJdlState === fingerprint(project))
|
||||
return {
|
||||
bytes: Buffer.from(project.originalJdl, "base64"),
|
||||
warnings: [
|
||||
"변경되지 않은 원본 JDL을 그대로 내보냅니다. 원본 검사 DLL 인증은 확인하지 않았습니다.",
|
||||
],
|
||||
};
|
||||
const tables = Object.fromEntries(Object.keys(schema).map((k) => [k, []])),
|
||||
warnings = [],
|
||||
map = new Map();
|
||||
@@ -327,4 +343,4 @@ function read(bytes, project) {
|
||||
};
|
||||
return project;
|
||||
}
|
||||
module.exports = { output, read, parse };
|
||||
module.exports = { output, read, parse, markOriginal };
|
||||
|
||||
Reference in New Issue
Block a user