android: do not put js file directly

This commit is contained in:
pengfei.zhou
2023-03-29 10:50:35 +08:00
committed by jingpeng
parent 9c19a76cf8
commit 9a6ae9b6ef
12 changed files with 88 additions and 37 deletions

View File

@@ -1,4 +1,6 @@
const fs = require("fs");
const path = require("path");
const crypto = require("crypto");
async function work() {
const imageDts = await fs.promises.readFile("src/image.d.ts", "utf-8");
@@ -13,6 +15,24 @@ ${indexDts
${imageDts}
`;
await fs.promises.writeFile("index.d.ts", content);
const files = [
"bundle/doric-lib.js",
"bundle/doric-sandbox.js",
"bundle/doric-web.js",
"bundle/doric-web.html",
];
const androidAssets = "../doric-android/doric/src/main/assets";
for (let file of files) {
const md5 = crypto.createHash("md5");
md5.update(path.basename(file));
const name = md5.digest("hex").toLowerCase();
const data = await fs.promises.readFile(file);
const temp = new Uint8Array(data.buffer);
for (let i = 0; i < temp.length; i++) {
temp[i] = 0xff - temp[i];
}
await fs.promises.writeFile(path.resolve(androidAssets, name), data);
}
}
work();