Skip to content

Commit 7b724e5

Browse files
fix: issues
1 parent 86e8103 commit 7b724e5

File tree

3 files changed

+55
-54
lines changed

3 files changed

+55
-54
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
"com.foxdebug.acode.rk.exec.proot": {},
4141
"com.foxdebug.acode.rk.exec.terminal": {},
4242
"com.foxdebug.acode.rk.customtabs": {},
43-
"com.foxdebug.acode.rk.auth": {},
4443
"com.foxdebug.acode.rk.plugin.plugincontext": {}
4544
},
4645
"platforms": [

src/lib/loadPlugin.js

Lines changed: 54 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,66 +5,69 @@ import Url from "utils/Url";
55
import actionStack from "./actionStack";
66

77
export default async function loadPlugin(pluginId, justInstalled = false) {
8-
const baseUrl = await helpers.toInternalUri(Url.join(PLUGIN_DIR, pluginId));
9-
const cacheFile = Url.join(CACHE_STORAGE, pluginId);
8+
const baseUrl = await helpers.toInternalUri(Url.join(PLUGIN_DIR, pluginId));
9+
const cacheFile = Url.join(CACHE_STORAGE, pluginId);
1010

11-
const pluginJson = await fsOperation(
12-
Url.join(PLUGIN_DIR, pluginId, "plugin.json"),
13-
).readFile("json");
11+
const pluginJson = await fsOperation(
12+
Url.join(PLUGIN_DIR, pluginId, "plugin.json"),
13+
).readFile("json");
1414

15-
let mainUrl;
16-
if (
17-
await fsOperation(Url.join(PLUGIN_DIR, pluginId, pluginJson.main)).exists()
18-
) {
19-
mainUrl = Url.join(baseUrl, pluginJson.main);
20-
} else {
21-
mainUrl = Url.join(baseUrl, "main.js");
22-
}
15+
let mainUrl;
16+
if (
17+
await fsOperation(Url.join(PLUGIN_DIR, pluginId, pluginJson.main)).exists()
18+
) {
19+
mainUrl = Url.join(baseUrl, pluginJson.main);
20+
} else {
21+
mainUrl = Url.join(baseUrl, "main.js");
22+
}
2323

24-
return new Promise((resolve, reject) => {
25-
const $script = <script src={mainUrl}></script>;
24+
return new Promise((resolve, reject) => {
25+
const $script = <script src={mainUrl}></script>;
2626

27-
$script.onerror = (error) => {
28-
reject(
29-
new Error(
30-
`Failed to load script for plugin ${pluginId}: ${error.message || error}`,
31-
),
32-
);
33-
};
27+
$script.onerror = (error) => {
28+
reject(
29+
new Error(
30+
`Failed to load script for plugin ${pluginId}: ${error.message || error}`,
31+
),
32+
);
33+
};
3434

35-
$script.onload = async () => {
36-
const $page = Page("Plugin");
37-
$page.show = () => {
38-
actionStack.push({
39-
id: pluginId,
40-
action: $page.hide,
41-
});
35+
$script.onload = async () => {
36+
const $page = Page("Plugin");
37+
$page.show = () => {
38+
actionStack.push({
39+
id: pluginId,
40+
action: $page.hide,
41+
});
4242

43-
app.append($page);
44-
};
43+
app.append($page);
44+
};
4545

46-
$page.onhide = function () {
47-
actionStack.remove(pluginId);
48-
};
46+
$page.onhide = function () {
47+
actionStack.remove(pluginId);
48+
};
4949

50-
try {
51-
if (!(await fsOperation(cacheFile).exists())) {
52-
await fsOperation(CACHE_STORAGE).createFile(pluginId);
53-
}
50+
try {
51+
if (!(await fsOperation(cacheFile).exists())) {
52+
await fsOperation(CACHE_STORAGE).createFile(pluginId);
53+
}
5454

55-
await acode.initPlugin(pluginId, baseUrl, $page, {
56-
cacheFileUrl: await helpers.toInternalUri(cacheFile),
57-
cacheFile: fsOperation(cacheFile),
58-
firstInit: justInstalled,
59-
ctx: await PluginContext.generate(pluginId, pluginJson),
60-
});
55+
await acode.initPlugin(pluginId, baseUrl, $page, {
56+
cacheFileUrl: await helpers.toInternalUri(cacheFile),
57+
cacheFile: fsOperation(cacheFile),
58+
firstInit: justInstalled,
59+
ctx: await PluginContext.generate(
60+
pluginId,
61+
JSON.stringify(pluginJson),
62+
),
63+
});
6164

62-
resolve();
63-
} catch (error) {
64-
reject(error);
65-
}
66-
};
65+
resolve();
66+
} catch (error) {
67+
reject(error);
68+
}
69+
};
6770

68-
document.head.append($script);
69-
});
71+
document.head.append($script);
72+
});
7073
}

src/plugins/pluginContext/www/PluginContext.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ const PluginContext = (function () {
4444
const uuid = await requestToken(pluginId);
4545
return new _PluginContext(pluginId, uuid);
4646
} catch (err) {
47-
console.error(
47+
console.warn(
4848
`PluginContext generation failed for pluginId ${pluginId}:`,
49-
err,
5049
);
5150
return null;
5251
}

0 commit comments

Comments
 (0)