@@ -13,7 +13,7 @@ import path from './lib/path.js';
13
13
import Util from './modules/Util.js' ;
14
14
import Drivers from './modules/Drivers.js' ;
15
15
import putility from '@heyputer/putility' ;
16
- import { FSHostService } from './services/FSHost .js' ;
16
+ import { FSRelayService } from './services/FSRelay .js' ;
17
17
import { FilesystemService } from './services/Filesystem.js' ;
18
18
import { APIAccessService } from './services/APIAccess.js' ;
19
19
import { XDIncomingService } from './services/XDIncoming.js' ;
@@ -69,8 +69,10 @@ window.puter = (function() {
69
69
// "modules" in puter.js are external interfaces for the developer
70
70
this . modules_ = [ ] ;
71
71
// "services" in puter.js are used by modules and may interact with each other
72
- const context = new putility . libs . context . Context ( ) ;
72
+ const context = new putility . libs . context . Context ( )
73
+ . follow ( this , [ 'env' , 'util' ] ) ;
73
74
this . services = new putility . system . ServiceManager ( { context } ) ;
75
+ this . context = context ;
74
76
context . services = this . services ;
75
77
76
78
// Holds the query parameters found in the current URL
@@ -148,12 +150,12 @@ window.puter = (function() {
148
150
this . APIOrigin = 'https://api.' + URLParams . get ( 'puter.domain' ) ;
149
151
}
150
152
153
+ this . services . register ( 'no-puter-yet' , NoPuterYetService ) ;
154
+ this . services . register ( 'filesystem' , FilesystemService ) ;
155
+ this . services . register ( 'api-access' , APIAccessService ) ;
156
+ this . services . register ( 'xd-incoming' , XDIncomingService ) ;
151
157
if ( this . env !== 'app' ) {
152
- this . services . register ( 'no-puter-yet' , NoPuterYetService ) ;
153
- this . services . register ( 'filesystem' , FilesystemService ) ;
154
- this . services . register ( 'api-access' , APIAccessService ) ;
155
- this . services . register ( 'xd-incoming' , XDIncomingService ) ;
156
- // this.services.register('fs-host', FSHostService);
158
+ this . services . register ( 'fs-relay' , FSRelayService ) ;
157
159
}
158
160
159
161
// When api-access is initialized, bind `.authToken` and
@@ -162,15 +164,18 @@ window.puter = (function() {
162
164
await this . services . wait_for_init ( [ 'api-access' ] ) ;
163
165
const svc_apiAccess = this . services . get ( 'api-access' ) ;
164
166
165
- svc_apiAccess . authToken = this . authToken ;
166
- svc_apiAccess . APIOrigin = this . APIOrigin ;
167
- [ 'authToken' , 'APIOrigin' ] . forEach ( key => {
168
- Object . defineProperty ( this , key , {
167
+ svc_apiAccess . auth_token = this . authToken ;
168
+ svc_apiAccess . api_origin = this . APIOrigin ;
169
+ [
170
+ [ 'authToken' , 'auth_token' ] ,
171
+ [ 'APIOrigin' , 'api_origin' ] ,
172
+ ] . forEach ( ( [ k1 , k2 ] ) => {
173
+ Object . defineProperty ( this , k1 , {
169
174
get ( ) {
170
- return svc_apiAccess [ key ] ;
175
+ return svc_apiAccess [ k2 ] ;
171
176
} ,
172
177
set ( v ) {
173
- svc_apiAccess [ key ] = v ;
178
+ svc_apiAccess [ k2 ] = v ;
174
179
return true ;
175
180
}
176
181
} ) ;
@@ -243,7 +248,7 @@ window.puter = (function() {
243
248
new OS ( this . authToken , this . APIOrigin , this . appID , this . env ) ) ;
244
249
// FileSystem
245
250
this . registerModule ( 'fs' ,
246
- new PuterJSFileSystemModule ( this . authToken , this . APIOrigin , this . appID , this . env ) ) ;
251
+ new PuterJSFileSystemModule ( this . authToken , this . APIOrigin , this . appID , this . context ) ) ;
247
252
// UI
248
253
this . registerModule ( 'ui' ,
249
254
new UI ( this . appInstanceID , this . parentInstanceID , this . appID , this . env , this . util ) ) ;
0 commit comments