MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / PluginInclude

Function PluginInclude

src/pages/plugin/plugin.js:35–587  ·  view source on GitHub ↗
(
	id,
	onInstall,
	onUninstall,
	installOnRender,
)

Source from the content-addressed store, hash-verified

33 * @param {boolean} [installOnRender]
34 */
35export default async function PluginInclude(
36 id,
37 onInstall,
38 onUninstall,
39 installOnRender,
40) {
41 if ($lastPluginPage) {
42 $lastPluginPage.hide();
43 }
44
45 const $page = Page(strings["plugin"]);
46 let installed = await fsOperation(PLUGIN_DIR, id).exists();
47 let plugin = {};
48 let currentVersion = "";
49 let purchased = false;
50 let cancelled = false;
51 let update = false;
52 let isPaid = false;
53 let price;
54 let product;
55 let purchaseToken;
56 let $settingsIcon;
57 let minVersionCode = -1;
58 let isSupported = true;
59 let unsupportedEditor;
60 let refundHandlerSet = false;
61 let purchaseHandlerSet = false;
62
63 actionStack.push({
64 id: "plugin",
65 action: $page.hide,
66 });
67
68 $page.onhide = function () {
69 hideAd();
70 actionStack.remove("plugin");
71 loader.removeTitleLoader();
72 cancelled = true;
73 $lastPluginPage = null;
74 cleanups.forEach((cleanup) => {
75 try {
76 cleanup();
77 } catch {}
78 });
79 };
80
81 $lastPluginPage = $page;
82 app.append($page);
83 helpers.showAd();
84
85 try {
86 if (installed) {
87 const manifest = Url.join(PLUGIN_DIR, id, "plugin.json");
88 const installedPlugin = await fsOperation(manifest)
89 .readFile("json")
90 .catch((err) => {
91 alert(`Failed to load plugin metadata: ${manifest}`);
92 console.error(err);

Callers

nothing calls this directly

Calls 15

hideAdFunction · 0.90
PageFunction · 0.85
fsOperationFunction · 0.85
alertFunction · 0.85
isPluginEditorSupportedFunction · 0.85
isValidSourceFunction · 0.85
appendMethod · 0.80
renderFunction · 0.70
getPurchaseFunction · 0.70
existsMethod · 0.65
hideMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected