From 790e3bdffc43564372108cfd7a7b7710da41176d Mon Sep 17 00:00:00 2001 From: KernelDeimos Date: Tue, 22 Apr 2025 15:21:36 -0400 Subject: [PATCH] dev: puter.call Instead of puter.drivers.call, make it puter.call. This is accomplished by allowing puter.js modules to mutate the `puter` object on initialization. Support for an optional `_init` method, similar to backend services, is added to Puter modules to help with this. --- src/puter-js/src/index.js | 1 + src/puter-js/src/modules/Drivers.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/puter-js/src/index.js b/src/puter-js/src/index.js index e4014f2df..dc59a90d8 100644 --- a/src/puter-js/src/index.js +++ b/src/puter-js/src/index.js @@ -416,6 +416,7 @@ export default window.puter = (function() { const instance = new cls(this.context, parameters); this.modules_.push(name); this[name] = instance; + if ( instance._init ) instance._init({ puter: this }); } updateSubmodules() { diff --git a/src/puter-js/src/modules/Drivers.js b/src/puter-js/src/modules/Drivers.js index 7e63875b0..8a587caea 100644 --- a/src/puter-js/src/modules/Drivers.js +++ b/src/puter-js/src/modules/Drivers.js @@ -109,6 +109,10 @@ class Drivers { get: () => this.APIOrigin, }); } + + _init ({ puter }) { + puter.call = this.call.bind(this); + } /** * Sets a new authentication token and resets the socket connection with the updated token, if applicable.