diff --git a/doc/devmeta/track-comments.md b/doc/devmeta/track-comments.md
index 1c373262..260d7f33 100644
--- a/doc/devmeta/track-comments.md
+++ b/doc/devmeta/track-comments.md
@@ -57,3 +57,6 @@ Comments beginning with `// track:`. See
It may be applicable to write an iterator in the
future, or something will come up that require
these to be handled with a modular approach instead.
+- `track: checkpoint`
+ A location where some statement about the state of the
+ software must hold true.
diff --git a/src/backend/src/services/BaseService.js b/src/backend/src/services/BaseService.js
index 83ba918a..1b169fae 100644
--- a/src/backend/src/services/BaseService.js
+++ b/src/backend/src/services/BaseService.js
@@ -16,11 +16,11 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
-const { AdvancedBase } = require("../../../putility");
+const { concepts } = require("@heyputer/putility");
const NOOP = async () => {};
-class BaseService extends AdvancedBase {
+class BaseService extends concepts.Service {
constructor (service_resources, ...a) {
const { services, config, my_config, name, args } = service_resources;
super(service_resources, ...a);
diff --git a/src/gui/src/UI/UIDesktop.js b/src/gui/src/UI/UIDesktop.js
index 8a0ea744..d78170b3 100644
--- a/src/gui/src/UI/UIDesktop.js
+++ b/src/gui/src/UI/UIDesktop.js
@@ -1022,6 +1022,12 @@ async function UIDesktop(options){
// adjust window container to take into account the toolbar height
$('.window-container').css('top', window.toolbar_height);
+ // track: checkpoint
+ //-----------------------------
+ // GUI is ready to launch apps!
+ //-----------------------------
+
+ globalThis.services.emit('gui:ready');
//--------------------------------------------------------------------------------------
// Determine if an app was launched from URL
diff --git a/src/gui/src/definitions.js b/src/gui/src/definitions.js
index 8e5911ed..7f928bca 100644
--- a/src/gui/src/definitions.js
+++ b/src/gui/src/definitions.js
@@ -17,9 +17,13 @@
* along with this program. If not, see .
*/
-import { AdvancedBase } from "@heyputer/putility";
+import { concepts, AdvancedBase } from "@heyputer/putility";
-export class Service {
+export class Service extends concepts.Service {
+ // TODO: Service todo items
+ static TODO = [
+ 'consolidate with BaseService from backend'
+ ];
construct (o) {
this.$puter = {};
for ( const k in o ) this.$puter[k] = o[k];
@@ -28,6 +32,7 @@ export class Service {
}
init (...a) {
if ( ! this._init ) return;
+ this.services = a[0].services;
return this._init(...a)
}
};
diff --git a/src/gui/src/initgui.js b/src/gui/src/initgui.js
index df190778..0506994e 100644
--- a/src/gui/src/initgui.js
+++ b/src/gui/src/initgui.js
@@ -55,6 +55,11 @@ const launch_services = async function (options) {
const services_m_ = {};
globalThis.services = {
get: (name) => services_m_[name],
+ emit: (id, args) => {
+ for (const [_, instance] of services_l_) {
+ instance.__on(id, args ?? []);
+ }
+ }
};
const register = (name, instance) => {
services_l_.push([name, instance]);
diff --git a/src/gui/src/services/ProcessService.js b/src/gui/src/services/ProcessService.js
index 08683772..b210a6b6 100644
--- a/src/gui/src/services/ProcessService.js
+++ b/src/gui/src/services/ProcessService.js
@@ -22,6 +22,10 @@ import { InitProcess, Service } from "../definitions.js";
const NULL_UUID = '00000000-0000-0000-0000-000000000000';
export class ProcessService extends Service {
+ static INITRC = [
+ 'test-emu'
+ ];
+
async _init () {
this.processes = [];
this.processes_map = new Map();
@@ -33,6 +37,19 @@ export class ProcessService extends Service {
this.register_(root);
}
+ ['__on_gui:ready'] () {
+ const svc_exec = this.services.get('exec');
+ for ( let spec of ProcessService.INITRC ) {
+ if ( typeof spec === 'string' ) {
+ spec = { name: spec };
+ }
+
+ svc_exec.launchApp({
+ app_name: spec.name,
+ });
+ }
+ }
+
get_init () {
return this.processes_map.get(NULL_UUID);
}
diff --git a/src/putility/index.js b/src/putility/index.js
index ce7be26a..74835bcd 100644
--- a/src/putility/index.js
+++ b/src/putility/index.js
@@ -17,10 +17,14 @@
* along with this program. If not, see .
*/
const { AdvancedBase } = require('./src/AdvancedBase');
+const { Service } = require('./src/concepts/Service');
module.exports = {
AdvancedBase,
libs: {
promise: require('./src/libs/promise'),
},
+ concepts: {
+ Service,
+ },
};
diff --git a/src/putility/src/concepts/Service.js b/src/putility/src/concepts/Service.js
new file mode 100644
index 00000000..023beb78
--- /dev/null
+++ b/src/putility/src/concepts/Service.js
@@ -0,0 +1,26 @@
+const { AdvancedBase } = require("../AdvancedBase");
+
+const NOOP = async () => {};
+
+/**
+ * Service will be incrementally updated to consolidate
+ * BaseService in Puter's backend with Service in Puter's frontend,
+ * becoming the common base for both and a useful utility in general.
+ */
+class Service extends AdvancedBase {
+ async __on (id, args) {
+ const handler = this.__get_event_handler(id);
+
+ return await handler(id, ...args);
+ }
+
+ __get_event_handler (id) {
+ return this[`__on_${id}`]?.bind?.(this)
+ || this.constructor[`__on_${id}`]?.bind?.(this.constructor)
+ || NOOP;
+ }
+}
+
+module.exports = {
+ Service,
+};