Skip to content

Commit

Permalink
Fix some bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
wx-miniprogram committed Sep 9, 2022
1 parent d875ca3 commit 73ad582
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
19 changes: 8 additions & 11 deletions src/backgrounds/decoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,16 @@ if (process.env.ALL) {
decoders.set(Decoders.ONLINE, OnlineDecoder);
}

function getDecoderCode(name: string): [Decoders, string, string] {
let decoder = /wasm/.test(name)
? Decoders.WASM
: /js/.test(name)
? Decoders.JS
: Decoders.ONLINE;
let config = name.split("::");
function getDecoderCode(code: string): [Decoders, string, string] {
let decoder = /wasm/.test(code) ? Decoders.WASM : Decoders.ONLINE;
let info = code.split("::");
let engineID, annotation;
if (config.length == 2) {
engineID = config[0];
annotation = config[1];

if (info.length == 2) {
engineID = info[0];
annotation = info[1];
} else {
engineID = config[0];
engineID = info[0];
annotation = "";
}

Expand Down
1 change: 1 addition & 0 deletions src/decoder/cdecoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default class Decoder extends EventTarget implements IDecoder {

this.#dataloader = new DataLoader(inputTool);
this.#tokenDecoder = new TokenDecoder(this.#dataloader, solution);
this.#tokenDecoder.addEventListener('clear', this.clear.bind(this));

try {
this.#decoder = new Module["Decoder"]();
Expand Down
9 changes: 3 additions & 6 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,17 @@ let webpackConfig = manifests.map((manifest) => {
// List of files to be copied.
let copyPatterns = [
{from: `./src/manifests/manifest_${manifest}.json`, to: "./manifest.json", transform(content) {
let data = JSON.parse(content);
if (mode == 'development') {
let data = JSON.parse(content);
delete data['key'];
return JSON.stringify(data);
}

if (old && manifest == 'decoder') {
let data = JSON.parse(content);
data["minimum_chrome_version"] = "45";
data["content_security_policy"]["extension_page"] = "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'";
data["content_security_policy"]["extension_page"] = data["content_security_policy"]["extension_pages"];
delete data["content_security_policy"]["extension_pages"];
return JSON.stringify(data);
}
return content;
return JSON.stringify(data);
}},
{from: "./src/asset", to: "."},
]
Expand Down

0 comments on commit 73ad582

Please sign in to comment.