summaryrefslogtreecommitdiff
path: root/sdk/host.js
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-03-27 21:23:27 +0200
committerMinteck <contact@minteck.org>2022-03-27 21:23:27 +0200
commit9ce177d037d0aec26d51cfcba5a091155aebbfc6 (patch)
treed3bc54df6ccd675e07713fe37cc641fca427cd69 /sdk/host.js
downloadalicorn-9ce177d037d0aec26d51cfcba5a091155aebbfc6.tar.gz
alicorn-9ce177d037d0aec26d51cfcba5a091155aebbfc6.tar.bz2
alicorn-9ce177d037d0aec26d51cfcba5a091155aebbfc6.zip
Initial commit
Diffstat (limited to 'sdk/host.js')
-rw-r--r--sdk/host.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/sdk/host.js b/sdk/host.js
new file mode 100644
index 0000000..4d76832
--- /dev/null
+++ b/sdk/host.js
@@ -0,0 +1,42 @@
+AlicornSDK = {};
+AlicornSDKInternal = {};
+
+class AlicornSDKError extends Error {
+ constructor(props) {
+ super(props);
+ }
+}
+
+AlicornSDKInternal["checkWindow"] = (w) => {
+ if (w === null) {
+ throw new AlicornSDKError("Cannot make SDK call before window is initialized");
+ }
+}
+
+AlicornSDKInternal["resolveWindow"] = (w) => {
+ let wr = null
+ wr = WindowManager.stack.filter(i => i.id.substring(7).split("-app-")[0] === w)[0]
+
+ return wr;
+}
+
+AlicornSDK["close"] = (_window) => {
+ AlicornSDKInternal.checkWindow(_window);
+ let w = AlicornSDKInternal.resolveWindow(_window);
+
+ WindowManager.queueClose(w);
+}
+
+AlicornSDK["ready"] = (_window) => {
+ AlicornSDKInternal.checkWindow(_window);
+ let w = AlicornSDKInternal.resolveWindow(_window);
+
+ w.classList.remove("loading");
+}
+
+AlicornSDK["keyboard"] = (_window, data) => {
+ AlicornSDKInternal.checkWindow(_window);
+ let w = AlicornSDKInternal.resolveWindow(_window);
+
+ KeyboardShortcutHandler(data);
+} \ No newline at end of file