forked from ScratchAddons/ScratchAddons
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdeclare-scratchaddons-object.js
43 lines (34 loc) · 1.13 KB
/
declare-scratchaddons-object.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import globalStateProxy from "./imports/global-state.js";
import localStateProxy from "./imports/local-state.js";
import BackgroundLocalizationProvider from "./l10n.js";
window.scratchAddons = {};
// Store addon objects for persistent scripts
scratchAddons.addonObjects = [];
// Store event targets for addon.* API events
scratchAddons.eventTargets = {
auth: [],
settings: [],
self: [],
};
// Event target for local background page events
scratchAddons.localEvents = new EventTarget();
// Load manifests into memory
scratchAddons.manifests = [];
// Other files may add their own global methods here so that addon-api files can access them
scratchAddons.methods = {};
scratchAddons.l10n = new BackgroundLocalizationProvider();
// Can't load translations here.
scratchAddons.globalState = globalStateProxy;
console.log(
"%cscratchAddons.globalState",
"font-weight: bold;",
"initialized:\n",
JSON.parse(JSON.stringify(scratchAddons.globalState))
);
scratchAddons.localState = localStateProxy;
console.log(
"%cscratchAddons.localState",
"font-weight: bold;",
"initialized:\n",
JSON.parse(JSON.stringify(scratchAddons.localState))
);