mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-04 08:30:39 +00:00
51bac4486f
In the first pass I add a `register` method and update `defineComponent` so it calls `register` as well. This made it possible to create a proof-of-concept for registered classes. Additionally ExportService was added to expose registered classes to service scripts. This first pass works, but it would be better if all types of classes (components or otherwise) were registered via the same method.
25 lines
536 B
JavaScript
25 lines
536 B
JavaScript
import { Service } from "../definitions.js";
|
|
|
|
/**
|
|
* This service is responsible for exporting definitions to the
|
|
* service script SDK. This is the SDK that services provided by
|
|
* the backend will use.
|
|
*/
|
|
export class ExportService extends Service {
|
|
constructor () {
|
|
super();
|
|
this.exports_ = {};
|
|
}
|
|
|
|
register (name, definition) {
|
|
this.exports_[name] = definition;
|
|
}
|
|
|
|
get (name) {
|
|
if ( name ) {
|
|
return this.exports_[name];
|
|
}
|
|
return this.exports_;
|
|
}
|
|
}
|