Skip to content

Commit

Permalink
chore: make global instance lazy load
Browse files Browse the repository at this point in the history
  • Loading branch information
windingwind committed Dec 31, 2024
1 parent 91e2a57 commit 58b016b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,16 @@ export class BasicTool {
disableZLog: false,
prefix: "",
},
debug: ToolkitGlobal.getInstance()?.debugBridge || {
disableDebugBridgePassword: false,
password: "",
// We will remove this in the future, for now just let it be lazy loaded.
get debug() {
if (this._debug) {
return this._debug;
}
this._debug = ToolkitGlobal.getInstance()?.debugBridge || {
disableDebugBridgePassword: false,
password: "",
};
return this._debug;
},
api: {
pluginID: "[email protected]",
Expand Down Expand Up @@ -451,6 +458,7 @@ export interface BasicOptions {
disableDebugBridgePassword: boolean;
password: string;
};
_debug?: BasicOptions["debug"];
api: {
pluginID: string;
};
Expand Down
1 change: 1 addition & 0 deletions src/managers/toolkitGlobal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class ToolkitGlobal {
* @param instance ToolkitGlobal instance
*/
function initializeModules(instance: ToolkitGlobal) {
new BasicTool().log("Initializing ToolkitGlobal modules");
setModule(instance, "prompt", {
_ready: false,
instance: undefined,
Expand Down
3 changes: 3 additions & 0 deletions src/utils/debugBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import ToolkitGlobal from "../managers/toolkitGlobal.js";
/**
* Debug bridge.
*
* @deprecated Since this is a temporary solution for debugging, it is not recommended to use.
* The zotero-plugin-scaffold no longer need this.
*
* @remarks
* Global variables: Zotero, window(main window).
*
Expand Down
4 changes: 4 additions & 0 deletions src/utils/pluginBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { BasicTool } from "../basic.js";

/**
* Plugin bridge. Install plugin from zotero://plugin
*
* @deprecated Since this is a temporary solution for debugging, it is not recommended to use.
* The zotero-plugin-scaffold no longer need this.
*
* @example
* Install plugin from url, with minimal Zotero version requirement.
* ```text
Expand Down

0 comments on commit 58b016b

Please sign in to comment.