Files

26 lines
2.2 KiB
JavaScript

import fs from 'node:fs';import crypto from 'node:crypto';
const b='work/trilium',out=b+'/phase7';fs.mkdirSync(out,{recursive:true});
const input=(process.env.TRILIUM_PHASE7_INPUT||'work/trilium-gitea/updates/2026-09-05/phase7-input')+'/layout_commons.js';
let ui=fs.readFileSync(input,'utf8');const oldui=ui;
const replacements=[
['title:"Wrap text"','title:"글자 둘러싸기"'],
['Related settings','관련 설정'],
['Color scheme for code blocks in text notes','텍스트 노트의 코드 블록 색상'],
['Color scheme for code notes','코드 노트 색상'],
['message:"Geolocation not supported."','message:"위치 정보를 지원하지 않습니다."'],
['f=r.message||(d===1?"permission denied":d===2?"position unavailable":"timeout")','f=d===1?"위치 정보 접근 권한이 없습니다":d===2?"위치를 확인할 수 없습니다":d===3?"위치 확인 시간이 초과되었습니다":(r.message||"위치를 확인하지 못했습니다")'],
['message:"Geolocation error: "','message:"위치 정보 오류: "'],
['id:"geo-new-note",title:"New note"','id:"geo-new-note",title:"새 노트"'],
['label:"Zoom"','label:"확대 비율"'],
['label:"New geo note"','label:"지도에 새 노트 추가"'],
['pt.post("llm/chat",{title:"Note Chat"','pt.post("llm/chat",{title:"노트와 대화"']
];
for(const[from,to]of replacements){if(!ui.includes(from))throw Error('Patch point missing '+from);ui=ui.replaceAll(from,to);}
fs.writeFileSync(out+'/layout_commons.js',ui);
let main=fs.readFileSync(b+'/phase6/main.cjs','utf8');const oldmain=main;
const prefix='jg=`assets/v${CR.version}-ko-20260913-r5`';if(main.split(prefix).length!==2)throw Error('Cache prefix mismatch');
main=main.replace(prefix,'jg=`assets/v${CR.version}-ko-20260913-r6`');fs.writeFileSync(out+'/main.cjs',main);
const hash=s=>crypto.createHash('sha256').update(s).digest('hex');
fs.writeFileSync(out+'/manifest.json',JSON.stringify({previousMainSha256:hash(oldmain),previousLayoutSha256:hash(oldui),files:Object.fromEntries(['main.cjs','layout_commons.js'].map(n=>[n,hash(fs.readFileSync(out+'/'+n))]))},null,2));
fs.writeFileSync(out+'/changes.json',JSON.stringify(replacements,null,2));console.log({patchRules:replacements.length});