@componentor/fs 3.0.20 → 3.0.22

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.d.mts CHANGED
@@ -232,6 +232,8 @@ declare class VFSFileSystem {
232
232
  * The readyPromise will resolve once OPFS mode is ready, but init()
233
233
  * will reject with the corruption error to inform the caller. */
234
234
  private handleCorruptVFS;
235
+ /** Initialize the async-relay worker. Called after sync-relay signals ready. */
236
+ private initAsyncRelay;
235
237
  /** Start as leader — tell sync-relay to init VFS engine + OPFS handle */
236
238
  private startAsLeader;
237
239
  /** Start as follower — connect to leader via service worker port brokering */
package/dist/index.js CHANGED
@@ -1381,6 +1381,7 @@ var VFSFileSystem = class {
1381
1381
  const msg = e.data;
1382
1382
  if (msg.type === "ready") {
1383
1383
  this.isReady = true;
1384
+ this.initAsyncRelay();
1384
1385
  this.resolveReady();
1385
1386
  if (!this.isFollower) {
1386
1387
  this.initLeaderBroker();
@@ -1405,23 +1406,6 @@ var VFSFileSystem = class {
1405
1406
  }
1406
1407
  }
1407
1408
  };
1408
- if (this.hasSAB) {
1409
- this.asyncWorker.postMessage({
1410
- type: "init-leader",
1411
- asyncSab: this.asyncSab,
1412
- wakeSab: this.sab
1413
- });
1414
- } else {
1415
- const mc = new MessageChannel();
1416
- this.asyncWorker.postMessage(
1417
- { type: "init-port", port: mc.port1 },
1418
- [mc.port1]
1419
- );
1420
- this.syncWorker.postMessage(
1421
- { type: "async-port", port: mc.port2 },
1422
- [mc.port2]
1423
- );
1424
- }
1425
1409
  this.acquireLeaderLock();
1426
1410
  }
1427
1411
  /** Use Web Locks API for leader election. The tab that acquires the lock is
@@ -1516,6 +1500,26 @@ var VFSFileSystem = class {
1516
1500
  this._mode = "opfs";
1517
1501
  this.sendOPFSInit();
1518
1502
  }
1503
+ /** Initialize the async-relay worker. Called after sync-relay signals ready. */
1504
+ initAsyncRelay() {
1505
+ if (this.hasSAB) {
1506
+ this.asyncWorker.postMessage({
1507
+ type: "init-leader",
1508
+ asyncSab: this.asyncSab,
1509
+ wakeSab: this.sab
1510
+ });
1511
+ } else {
1512
+ const mc = new MessageChannel();
1513
+ this.asyncWorker.postMessage(
1514
+ { type: "init-port", port: mc.port1 },
1515
+ [mc.port1]
1516
+ );
1517
+ this.syncWorker.postMessage(
1518
+ { type: "async-port", port: mc.port2 },
1519
+ [mc.port2]
1520
+ );
1521
+ }
1522
+ }
1519
1523
  /** Start as leader — tell sync-relay to init VFS engine + OPFS handle */
1520
1524
  startAsLeader() {
1521
1525
  this.isFollower = false;