diff --git a/browser-manifest.json b/browser-manifest.json index c9dad73..ab08464 100644 --- a/browser-manifest.json +++ b/browser-manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "Pocket Bird", "description": "It's a pet bird in your browser, what more could you want?", - "version": "2025.11.3.34", + "version": "2025.11.3.37", "homepage_url": "https://idreesinc.com", "icons": { "48": "images/icons/transparent/48x48x1.png", diff --git a/dist/birb.js b/dist/birb.js index de3a838..13a3c30 100644 --- a/dist/birb.js +++ b/dist/birb.js @@ -1012,8 +1012,43 @@ } } + class ObsidianContext extends Context { + + /** + * @override + * @returns {boolean} + */ + isContextActive() { + // @ts-expect-error + return typeof app !== "undefined" && typeof app.vault !== "undefined"; + } + + /** + * @override + * @returns {Promise} + */ + async getSaveData() { + log("Loading save data from Obsidian plugin storage unimplemented"); + return {}; + } + + /** + * @override + * @param {BirbSaveData} saveData + */ + async putSaveData(saveData) { + log("Saving data to Obsidian plugin storage unimplemented"); + } + + /** @override */ + resetSaveData() { + log("Resetting save data in Obsidian plugin storage unimplemented"); + } + } + const CONTEXTS = [ new UserScriptContext(), + new ObsidianContext(), new BrowserExtensionContext(), new LocalContext() ]; @@ -1025,7 +1060,7 @@ } } error("No applicable context found, defaulting to LocalContext"); - return CONTEXTS[0]; + return new LocalContext(); } /** @@ -1867,7 +1902,7 @@ insertModal(`${birdBirb()} Mode`, message); }), new Separator(), - new MenuItem("2025.11.3.34", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.3.34"); }, false), + new MenuItem("2025.11.3.37", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.3.37"); }, false), ]; const styleElement = document.createElement("style"); diff --git a/dist/extension.zip b/dist/extension.zip index b2ae768..9fa6640 100644 Binary files a/dist/extension.zip and b/dist/extension.zip differ diff --git a/dist/extension/birb.js b/dist/extension/birb.js index de3a838..13a3c30 100644 --- a/dist/extension/birb.js +++ b/dist/extension/birb.js @@ -1012,8 +1012,43 @@ } } + class ObsidianContext extends Context { + + /** + * @override + * @returns {boolean} + */ + isContextActive() { + // @ts-expect-error + return typeof app !== "undefined" && typeof app.vault !== "undefined"; + } + + /** + * @override + * @returns {Promise} + */ + async getSaveData() { + log("Loading save data from Obsidian plugin storage unimplemented"); + return {}; + } + + /** + * @override + * @param {BirbSaveData} saveData + */ + async putSaveData(saveData) { + log("Saving data to Obsidian plugin storage unimplemented"); + } + + /** @override */ + resetSaveData() { + log("Resetting save data in Obsidian plugin storage unimplemented"); + } + } + const CONTEXTS = [ new UserScriptContext(), + new ObsidianContext(), new BrowserExtensionContext(), new LocalContext() ]; @@ -1025,7 +1060,7 @@ } } error("No applicable context found, defaulting to LocalContext"); - return CONTEXTS[0]; + return new LocalContext(); } /** @@ -1867,7 +1902,7 @@ insertModal(`${birdBirb()} Mode`, message); }), new Separator(), - new MenuItem("2025.11.3.34", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.3.34"); }, false), + new MenuItem("2025.11.3.37", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.3.37"); }, false), ]; const styleElement = document.createElement("style"); diff --git a/dist/extension/manifest.json b/dist/extension/manifest.json index c9dad73..ab08464 100644 --- a/dist/extension/manifest.json +++ b/dist/extension/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "Pocket Bird", "description": "It's a pet bird in your browser, what more could you want?", - "version": "2025.11.3.34", + "version": "2025.11.3.37", "homepage_url": "https://idreesinc.com", "icons": { "48": "images/icons/transparent/48x48x1.png", diff --git a/dist/obsidian/main.js b/dist/obsidian/main.js index de3a838..13a3c30 100644 --- a/dist/obsidian/main.js +++ b/dist/obsidian/main.js @@ -1012,8 +1012,43 @@ } } + class ObsidianContext extends Context { + + /** + * @override + * @returns {boolean} + */ + isContextActive() { + // @ts-expect-error + return typeof app !== "undefined" && typeof app.vault !== "undefined"; + } + + /** + * @override + * @returns {Promise} + */ + async getSaveData() { + log("Loading save data from Obsidian plugin storage unimplemented"); + return {}; + } + + /** + * @override + * @param {BirbSaveData} saveData + */ + async putSaveData(saveData) { + log("Saving data to Obsidian plugin storage unimplemented"); + } + + /** @override */ + resetSaveData() { + log("Resetting save data in Obsidian plugin storage unimplemented"); + } + } + const CONTEXTS = [ new UserScriptContext(), + new ObsidianContext(), new BrowserExtensionContext(), new LocalContext() ]; @@ -1025,7 +1060,7 @@ } } error("No applicable context found, defaulting to LocalContext"); - return CONTEXTS[0]; + return new LocalContext(); } /** @@ -1867,7 +1902,7 @@ insertModal(`${birdBirb()} Mode`, message); }), new Separator(), - new MenuItem("2025.11.3.34", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.3.34"); }, false), + new MenuItem("2025.11.3.37", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.3.37"); }, false), ]; const styleElement = document.createElement("style"); diff --git a/dist/obsidian/manifest.json b/dist/obsidian/manifest.json index c0d5d22..4220a9a 100644 --- a/dist/obsidian/manifest.json +++ b/dist/obsidian/manifest.json @@ -1,7 +1,7 @@ { "id": "pocket-bird", "name": "Pocket Bird", - "version": "2025.11.3.34", + "version": "2025.11.3.37", "minAppVersion": "0.15.0", "description": "It's a pet bird in your Obsidian, what more could you want?", "author": "Idrees Hassan", diff --git a/dist/userscript/birb.user.js b/dist/userscript/birb.user.js index 7304587..e64c82a 100644 --- a/dist/userscript/birb.user.js +++ b/dist/userscript/birb.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Pocket Bird // @namespace https://idreesinc.com -// @version 2025.11.3.34 +// @version 2025.11.3.37 // @description It's a bird that hops around your web browser, the future is here // @author Idrees // @downloadURL https://github.com/IdreesInc/Pocket-Bird/raw/refs/heads/main/dist/userscript/birb.user.js @@ -1026,8 +1026,43 @@ } } + class ObsidianContext extends Context { + + /** + * @override + * @returns {boolean} + */ + isContextActive() { + // @ts-expect-error + return typeof app !== "undefined" && typeof app.vault !== "undefined"; + } + + /** + * @override + * @returns {Promise} + */ + async getSaveData() { + log("Loading save data from Obsidian plugin storage unimplemented"); + return {}; + } + + /** + * @override + * @param {BirbSaveData} saveData + */ + async putSaveData(saveData) { + log("Saving data to Obsidian plugin storage unimplemented"); + } + + /** @override */ + resetSaveData() { + log("Resetting save data in Obsidian plugin storage unimplemented"); + } + } + const CONTEXTS = [ new UserScriptContext(), + new ObsidianContext(), new BrowserExtensionContext(), new LocalContext() ]; @@ -1039,7 +1074,7 @@ } } error("No applicable context found, defaulting to LocalContext"); - return CONTEXTS[0]; + return new LocalContext(); } /** @@ -1881,7 +1916,7 @@ insertModal(`${birdBirb()} Mode`, message); }), new Separator(), - new MenuItem("2025.11.3.34", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.3.34"); }, false), + new MenuItem("2025.11.3.37", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.3.37"); }, false), ]; const styleElement = document.createElement("style"); diff --git a/obsidian-manifest.json b/obsidian-manifest.json index c0d5d22..4220a9a 100644 --- a/obsidian-manifest.json +++ b/obsidian-manifest.json @@ -1,7 +1,7 @@ { "id": "pocket-bird", "name": "Pocket Bird", - "version": "2025.11.3.34", + "version": "2025.11.3.37", "minAppVersion": "0.15.0", "description": "It's a pet bird in your Obsidian, what more could you want?", "author": "Idrees Hassan", diff --git a/src/context.js b/src/context.js index 25b8ecf..d3ada8e 100644 --- a/src/context.js +++ b/src/context.js @@ -174,8 +174,43 @@ class BrowserExtensionContext extends Context { } } +class ObsidianContext extends Context { + + /** + * @override + * @returns {boolean} + */ + isContextActive() { + // @ts-expect-error + return typeof app !== "undefined" && typeof app.vault !== "undefined"; + } + + /** + * @override + * @returns {Promise} + */ + async getSaveData() { + log("Loading save data from Obsidian plugin storage unimplemented"); + return {}; + } + + /** + * @override + * @param {BirbSaveData} saveData + */ + async putSaveData(saveData) { + log("Saving data to Obsidian plugin storage unimplemented"); + } + + /** @override */ + resetSaveData() { + log("Resetting save data in Obsidian plugin storage unimplemented"); + } +} + const CONTEXTS = [ new UserScriptContext(), + new ObsidianContext(), new BrowserExtensionContext(), new LocalContext() ]; @@ -187,5 +222,5 @@ export function getContext() { } } error("No applicable context found, defaulting to LocalContext"); - return CONTEXTS[0]; + return new LocalContext(); } \ No newline at end of file