浏览代码

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.
KernelDeimos 1 月之前
父节点
当前提交
790e3bdffc
共有 2 个文件被更改,包括 5 次插入0 次删除
  1. 1 0
      src/puter-js/src/index.js
  2. 4 0
      src/puter-js/src/modules/Drivers.js

+ 1 - 0
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() {

+ 4 - 0
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.