@xyo-network/os-runtime 3.0.6 → 3.0.7

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.
@@ -1081,6 +1081,7 @@ declare class EventBus implements EventBusInterface {
1081
1081
  private _archivist;
1082
1082
  private connections;
1083
1083
  private publisherCallbacks;
1084
+ private startMutex;
1084
1085
  get archivist(): _xyo_network_archivist_model.ArchivistInstance<_xylabs_object.BaseParamsFields & {
1085
1086
  account?: _xyo_network_account.AccountInstance | "random";
1086
1087
  addToResolvers?: boolean;
@@ -1104,7 +1105,7 @@ declare class EventBus implements EventBusInterface {
1104
1105
  } & _xyo_network_payload_model.PayloadFields>;
1105
1106
  addConnection(connection: EventBusConnectionInterface): EventBusPubSubConnectionInterface<string, _xyo_network_os_model.SubscribableEventListeners, _xyo_network_os_model.PublisherEventListenerEventData>;
1106
1107
  removeConnection(connectionId: string): void;
1107
- start(storeName?: string): Promise<void>;
1108
+ start(storeName?: string): Promise<this>;
1108
1109
  private handlePublisherAdd;
1109
1110
  private handlePublisherRemove;
1110
1111
  }
@@ -1561,7 +1562,7 @@ interface XyOsParams<TManifest extends PackageManifest = PackageManifest> extend
1561
1562
  declare class XyOs extends XyOsContextBase<XyOsParams> implements XyOsContext {
1562
1563
  protected _exposedNode: NodeInstance | undefined;
1563
1564
  protected _exposedNodeOuter: NodeInstance | undefined;
1564
- protected _kernel: KernelExternal | undefined;
1565
+ protected _kernel: KernelExternal;
1565
1566
  protected _locator: ModuleFactoryLocator;
1566
1567
  protected dappRegistrationService: DappRegistrationService;
1567
1568
  private stackManager;
@@ -18,10 +18,11 @@ var RunningDappAccessCache = class {
18
18
 
19
19
  // src/classes/cache/RunningDappCache.ts
20
20
  import { assertEx as assertEx19 } from "@xylabs/assert";
21
- import { Mutex as Mutex2 } from "async-mutex";
21
+ import { Mutex as Mutex3 } from "async-mutex";
22
22
 
23
23
  // src/XyOs.ts
24
24
  import { assertEx as assertEx12 } from "@xylabs/assert";
25
+ import { boot } from "@xyo-network/bios";
25
26
  import { Kernel } from "@xyo-network/kernel";
26
27
  import { ModuleFactoryLocator as ModuleFactoryLocator5 } from "@xyo-network/module-factory-locator";
27
28
 
@@ -72,6 +73,7 @@ import {
72
73
  isPubSubConnections
73
74
  } from "@xyo-network/os-model";
74
75
  import { PayloadBuilder } from "@xyo-network/payload-builder";
76
+ import { Mutex } from "async-mutex";
75
77
  import { v4 as uuid } from "uuid";
76
78
  var EventBus = class {
77
79
  // Internal Archivist to store event data
@@ -80,6 +82,7 @@ var EventBus = class {
80
82
  connections = {};
81
83
  // Store all publisher callbacks for later removal
82
84
  publisherCallbacks = {};
85
+ startMutex = new Mutex();
83
86
  get archivist() {
84
87
  return asArchivistInstance(
85
88
  assertEx2(this._archivist, () => "Archivist not found. Did you forget to call start()?"),
@@ -108,27 +111,34 @@ var EventBus = class {
108
111
  delete this.connections[connectionId];
109
112
  }
110
113
  async start(storeName = "EventBusArchivist") {
111
- this._archivist = await MemoryArchivist.create({
112
- config: {
113
- name: storeName,
114
- schema: MemoryArchivistConfigSchema
114
+ return await this.startMutex.runExclusive(async () => {
115
+ if (this._archivist) {
116
+ console.warn("EventBus already started");
117
+ return this;
115
118
  }
116
- });
117
- this.archivist.on("inserted", ({ payloads }) => {
118
- const eventBusEvent = payloads.find(isEventBusEvent);
119
- if (!eventBusEvent) return;
120
- for (const connectionId in this.connections) {
121
- const connection = this.connections[connectionId];
122
- if (isPubSubConnections(connection) && connection.subscribableEvents) {
123
- for (const [eventName, callback] of connection.subscribableEvents.entries()) {
124
- if (eventName !== eventBusEvent.name) continue;
125
- if (callback) {
126
- const forgettable = async () => await callback({ payloads });
127
- forget(forgettable());
119
+ this._archivist = await MemoryArchivist.create({
120
+ config: {
121
+ name: storeName,
122
+ schema: MemoryArchivistConfigSchema
123
+ }
124
+ });
125
+ this.archivist.on("inserted", ({ payloads }) => {
126
+ const eventBusEvent = payloads.find(isEventBusEvent);
127
+ if (!eventBusEvent) return;
128
+ for (const connectionId in this.connections) {
129
+ const connection = this.connections[connectionId];
130
+ if (isPubSubConnections(connection) && connection.subscribableEvents) {
131
+ for (const [eventName, callback] of connection.subscribableEvents.entries()) {
132
+ if (eventName !== eventBusEvent.name) continue;
133
+ if (callback) {
134
+ const forgettable = async () => await callback({ payloads });
135
+ forget(forgettable());
136
+ }
128
137
  }
129
138
  }
130
139
  }
131
- }
140
+ });
141
+ return this;
132
142
  });
133
143
  }
134
144
  handlePublisherAdd(connection) {
@@ -748,9 +758,9 @@ var dapp_window_manifest_default = {
748
758
  import { assertEx as assertEx7 } from "@xylabs/assert";
749
759
  import { BaseEmitter as BaseEmitter2 } from "@xyo-network/module-abstract";
750
760
  import { ModuleFactoryLocator } from "@xyo-network/module-factory-locator";
751
- import { Mutex } from "async-mutex";
761
+ import { Mutex as Mutex2 } from "async-mutex";
752
762
  var XyOsContextBase = class extends BaseEmitter2 {
753
- _bootMutex = new Mutex();
763
+ _bootMutex = new Mutex2();
754
764
  _platformLocator;
755
765
  _root;
756
766
  get bios() {
@@ -1999,6 +2009,13 @@ var XyOs = class _XyOs extends XyOsContextBase {
1999
2009
  console.warn("XyOs:boot", wallet.address);
2000
2010
  const fullLocator = this._locator.merge(locator);
2001
2011
  return await this._bootMutex.runExclusive(async () => {
2012
+ await this.eventBus.start();
2013
+ if (this.kernel?.status === "created") {
2014
+ await this.kernel.boot(await boot(), { locator: fullLocator });
2015
+ }
2016
+ if (this.kernel?.status !== "booted") {
2017
+ throw new Error("Kernel not booted");
2018
+ }
2002
2019
  assertEx12(this._root === void 0, () => "XyOs already booted");
2003
2020
  const [root] = await _XyOs.monitor(async () => await loadOsNode(wallet, fullLocator), { name: "Load XyOs" });
2004
2021
  this._root = root;
@@ -2637,7 +2654,7 @@ var createDappContext = async (dapp, context, allowedNames, xnsNodeUrl, xnsNetwo
2637
2654
  };
2638
2655
 
2639
2656
  // src/classes/cache/RunningDappCache.ts
2640
- var findOrCreateMutex = new Mutex2();
2657
+ var findOrCreateMutex = new Mutex3();
2641
2658
  var RunningDappCache = class _RunningDappCache {
2642
2659
  static _cache = {};
2643
2660
  static async findOrCreate(dapp, xyOs, allowedNames, xnsNodeUrl, xnsNetwork) {