@lvce-editor/ipc 7.4.0 → 8.0.1
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/browser.js +15 -10
- package/dist/index.js +4 -9
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -286,16 +286,11 @@ const waitForFirstMessage = async port => {
|
|
|
286
286
|
resolve,
|
|
287
287
|
promise
|
|
288
288
|
} = withResolvers();
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
};
|
|
293
|
-
const handleMessage = event => {
|
|
294
|
-
cleanup(event);
|
|
295
|
-
};
|
|
296
|
-
port.onmessage = handleMessage;
|
|
289
|
+
port.addEventListener('message', resolve, {
|
|
290
|
+
once: true
|
|
291
|
+
});
|
|
297
292
|
const event = await promise;
|
|
298
|
-
// @ts-
|
|
293
|
+
// @ts-ignore
|
|
299
294
|
return event.data;
|
|
300
295
|
};
|
|
301
296
|
|
|
@@ -370,7 +365,17 @@ class IpcChildWithWindow extends Ipc {
|
|
|
370
365
|
// ignore
|
|
371
366
|
}
|
|
372
367
|
onMessage(callback) {
|
|
373
|
-
|
|
368
|
+
const wrapped = event => {
|
|
369
|
+
const {
|
|
370
|
+
ports
|
|
371
|
+
} = event;
|
|
372
|
+
if (ports.length) {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
callback(event);
|
|
376
|
+
this._rawIpc.removeEventListener('message', wrapped);
|
|
377
|
+
};
|
|
378
|
+
this._rawIpc.addEventListener('message', wrapped);
|
|
374
379
|
}
|
|
375
380
|
}
|
|
376
381
|
const wrap$2 = window => {
|
package/dist/index.js
CHANGED
|
@@ -354,16 +354,11 @@ const waitForFirstMessage = async port => {
|
|
|
354
354
|
resolve,
|
|
355
355
|
promise
|
|
356
356
|
} = withResolvers();
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
};
|
|
361
|
-
const handleMessage = event => {
|
|
362
|
-
cleanup(event);
|
|
363
|
-
};
|
|
364
|
-
port.onmessage = handleMessage;
|
|
357
|
+
port.addEventListener('message', resolve, {
|
|
358
|
+
once: true
|
|
359
|
+
});
|
|
365
360
|
const event = await promise;
|
|
366
|
-
// @ts-
|
|
361
|
+
// @ts-ignore
|
|
367
362
|
return event.data;
|
|
368
363
|
};
|
|
369
364
|
|