@cordy/electro 1.2.2 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +25 -20
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -511,32 +511,33 @@ var Feature = class {
|
|
|
511
511
|
initial: FeatureStatus.NONE,
|
|
512
512
|
name: `feature "${config.id}"`
|
|
513
513
|
});
|
|
514
|
+
const fid = config.id;
|
|
514
515
|
this.context = {
|
|
515
516
|
getService: () => {
|
|
516
|
-
throw new Error(
|
|
517
|
+
throw new Error(`[${fid}] ctx.getService() is not available — feature has not been initialized yet`);
|
|
517
518
|
},
|
|
518
519
|
getTask: () => {
|
|
519
|
-
throw new Error(
|
|
520
|
+
throw new Error(`[${fid}] ctx.getTask() is not available — feature has not been initialized yet`);
|
|
520
521
|
},
|
|
521
522
|
getFeature: () => {
|
|
522
|
-
throw new Error(
|
|
523
|
+
throw new Error(`[${fid}] ctx.getFeature() is not available — feature has not been initialized yet`);
|
|
523
524
|
},
|
|
524
525
|
events: {
|
|
525
526
|
publish: () => {
|
|
526
|
-
throw new Error(
|
|
527
|
+
throw new Error(`[${fid}] ctx.events.publish() is not available — feature has not been initialized yet`);
|
|
527
528
|
},
|
|
528
529
|
on: () => {
|
|
529
|
-
throw new Error(
|
|
530
|
+
throw new Error(`[${fid}] ctx.events.on() is not available — feature has not been initialized yet`);
|
|
530
531
|
}
|
|
531
532
|
},
|
|
532
533
|
getWindow: () => {
|
|
533
|
-
throw new Error(
|
|
534
|
+
throw new Error(`[${fid}] ctx.getWindow() is not available — feature has not been initialized yet`);
|
|
534
535
|
},
|
|
535
536
|
createView: () => {
|
|
536
|
-
throw new Error(
|
|
537
|
+
throw new Error(`[${fid}] ctx.createView() is not available — feature has not been initialized yet`);
|
|
537
538
|
},
|
|
538
539
|
getView: () => {
|
|
539
|
-
throw new Error(
|
|
540
|
+
throw new Error(`[${fid}] ctx.getView() is not available — feature has not been initialized yet`);
|
|
540
541
|
},
|
|
541
542
|
logger: this.logger,
|
|
542
543
|
signal: this.controller.signal
|
|
@@ -581,12 +582,6 @@ var Feature = class {
|
|
|
581
582
|
for (const dep of features) if (dep.serviceManager) deps.set(dep.id, dep.serviceManager);
|
|
582
583
|
const accessor = new ServiceAccessor(this.serviceManager, deps);
|
|
583
584
|
this.context.getService = ((name) => accessor.get(name));
|
|
584
|
-
this.serviceManager.startup();
|
|
585
|
-
this.taskManager = new TaskManager(this.context);
|
|
586
|
-
for (const task of this.config.tasks ?? []) this.taskManager.register(task);
|
|
587
|
-
this.context.getTask = ((name) => {
|
|
588
|
-
return new TaskHandle(this.taskManager.getTaskInstance(name), this.context);
|
|
589
|
-
});
|
|
590
585
|
const declaredDeps = new Set(this.config.dependencies ?? []);
|
|
591
586
|
this.context.getFeature = ((name) => {
|
|
592
587
|
if (!declaredDeps.has(name)) throw new Error(`Feature "${name}" is not a declared dependency of "${this.id}"`);
|
|
@@ -624,6 +619,12 @@ var Feature = class {
|
|
|
624
619
|
return inst.view();
|
|
625
620
|
};
|
|
626
621
|
}
|
|
622
|
+
this.serviceManager.startup();
|
|
623
|
+
this.taskManager = new TaskManager(this.context);
|
|
624
|
+
for (const task of this.config.tasks ?? []) this.taskManager.register(task);
|
|
625
|
+
this.context.getTask = ((name) => {
|
|
626
|
+
return new TaskHandle(this.taskManager.getTaskInstance(name), this.context);
|
|
627
|
+
});
|
|
627
628
|
}
|
|
628
629
|
};
|
|
629
630
|
|
|
@@ -712,8 +713,9 @@ var FeatureManager = class {
|
|
|
712
713
|
feature.transition(FeatureStatus.READY);
|
|
713
714
|
} catch (err) {
|
|
714
715
|
feature.transition(FeatureStatus.ERROR);
|
|
715
|
-
|
|
716
|
-
|
|
716
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
717
|
+
this.logger.error(id, `initialize failed: ${message}`);
|
|
718
|
+
if (feature.config.critical) throw new Error(`Critical feature "${id}" failed to initialize: ${message}`, { cause: err });
|
|
717
719
|
}
|
|
718
720
|
}
|
|
719
721
|
/**
|
|
@@ -738,8 +740,9 @@ var FeatureManager = class {
|
|
|
738
740
|
feature.transition(FeatureStatus.ACTIVATED);
|
|
739
741
|
} catch (err) {
|
|
740
742
|
feature.transition(FeatureStatus.ERROR);
|
|
741
|
-
|
|
742
|
-
|
|
743
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
744
|
+
this.logger.error(id, `activate failed: ${message}`);
|
|
745
|
+
if (feature.config.critical) throw new Error(`Critical feature "${id}" failed to activate: ${message}`, { cause: err });
|
|
743
746
|
}
|
|
744
747
|
}
|
|
745
748
|
/**
|
|
@@ -755,7 +758,8 @@ var FeatureManager = class {
|
|
|
755
758
|
feature.transition(FeatureStatus.DEACTIVATED);
|
|
756
759
|
} catch (err) {
|
|
757
760
|
feature.transition(FeatureStatus.ERROR);
|
|
758
|
-
|
|
761
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
762
|
+
this.logger.error(id, `deactivate failed: ${message}`);
|
|
759
763
|
}
|
|
760
764
|
}
|
|
761
765
|
async destroy(id) {
|
|
@@ -767,7 +771,8 @@ var FeatureManager = class {
|
|
|
767
771
|
feature.transition(FeatureStatus.DESTROYED);
|
|
768
772
|
} catch (err) {
|
|
769
773
|
feature.transition(FeatureStatus.ERROR);
|
|
770
|
-
|
|
774
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
775
|
+
this.logger.error(id, `destroy failed: ${message}`);
|
|
771
776
|
}
|
|
772
777
|
}
|
|
773
778
|
/** Public: re-activate a DEACTIVATED or ERROR feature. */
|