@lvce-editor/iframe-worker 3.3.0 → 3.4.0

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.
@@ -267,14 +267,14 @@ const readyMessage = 'ready';
267
267
  const getData$2 = event => {
268
268
  return event.data;
269
269
  };
270
- const listen$6 = () => {
270
+ const listen$7 = () => {
271
271
  // @ts-ignore
272
272
  if (typeof WorkerGlobalScope === 'undefined') {
273
273
  throw new TypeError('module is not in web worker scope');
274
274
  }
275
275
  return globalThis;
276
276
  };
277
- const signal$6 = global => {
277
+ const signal$7 = global => {
278
278
  global.postMessage(readyMessage);
279
279
  };
280
280
  class IpcChildWithModuleWorker extends Ipc {
@@ -300,7 +300,7 @@ class IpcChildWithModuleWorker extends Ipc {
300
300
  this._rawIpc.addEventListener('message', callback);
301
301
  }
302
302
  }
303
- const wrap$d = global => {
303
+ const wrap$e = global => {
304
304
  return new IpcChildWithModuleWorker(global);
305
305
  };
306
306
  const withResolvers = () => {
@@ -325,10 +325,10 @@ const waitForFirstMessage = async port => {
325
325
  // @ts-ignore
326
326
  return event.data;
327
327
  };
328
- const listen$5 = async () => {
329
- const parentIpcRaw = listen$6();
330
- signal$6(parentIpcRaw);
331
- const parentIpc = wrap$d(parentIpcRaw);
328
+ const listen$6 = async () => {
329
+ const parentIpcRaw = listen$7();
330
+ signal$7(parentIpcRaw);
331
+ const parentIpc = wrap$e(parentIpcRaw);
332
332
  const firstMessage = await waitForFirstMessage(parentIpc);
333
333
  if (firstMessage.method !== 'initialize') {
334
334
  throw new IpcError('unexpected first message');
@@ -373,13 +373,13 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
373
373
  this._rawIpc.start();
374
374
  }
375
375
  }
376
- const wrap$c = port => {
376
+ const wrap$d = port => {
377
377
  return new IpcChildWithModuleWorkerAndMessagePort(port);
378
378
  };
379
379
  const IpcChildWithModuleWorkerAndMessagePort$1 = {
380
380
  __proto__: null,
381
- listen: listen$5,
382
- wrap: wrap$c
381
+ listen: listen$6,
382
+ wrap: wrap$d
383
383
  };
384
384
 
385
385
  const Two = '2.0';
@@ -404,9 +404,6 @@ let id = 0;
404
404
  const create$3 = () => {
405
405
  return ++id;
406
406
  };
407
- const warn = (...args) => {
408
- console.warn(...args);
409
- };
410
407
  const registerPromise = () => {
411
408
  const id = create$3();
412
409
  const {
@@ -419,16 +416,6 @@ const registerPromise = () => {
419
416
  promise
420
417
  };
421
418
  };
422
- const resolve = (id, response) => {
423
- const fn = get(id);
424
- if (!fn) {
425
- console.log(response);
426
- warn(`callback ${id} may already be disposed`);
427
- return;
428
- }
429
- fn(response);
430
- remove(id);
431
- };
432
419
  const create$2$1 = (method, params) => {
433
420
  const {
434
421
  id,
@@ -576,6 +563,19 @@ const unwrapJsonRpcResult = responseMessage => {
576
563
  }
577
564
  throw new JsonRpcError('unexpected response message');
578
565
  };
566
+ const warn = (...args) => {
567
+ console.warn(...args);
568
+ };
569
+ const resolve = (id, response) => {
570
+ const fn = get(id);
571
+ if (!fn) {
572
+ console.log(response);
573
+ warn(`callback ${id} may already be disposed`);
574
+ return;
575
+ }
576
+ fn(response);
577
+ remove(id);
578
+ };
579
579
  const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
580
580
  const getErrorType = prettyError => {
581
581
  if (prettyError && prettyError.type) {
@@ -989,13 +989,16 @@ const getDefaultBaseUrl = webView => {
989
989
  }
990
990
  return '';
991
991
  };
992
- const getWebViewBaseUrl = webView => {
992
+ const getWebViewBaseUrl = (webView, locationOrigin) => {
993
993
  const defaultBaseUrl = getDefaultBaseUrl(webView);
994
+ if (defaultBaseUrl.startsWith(locationOrigin)) {
995
+ return defaultBaseUrl.slice(locationOrigin.length);
996
+ }
994
997
  return defaultBaseUrl;
995
998
  };
996
999
 
997
1000
  const getIframeSrc$1 = (webView, locationOrigin, assetDir) => {
998
- const baseUrl = getWebViewBaseUrl(webView);
1001
+ const baseUrl = getWebViewBaseUrl(webView, locationOrigin);
999
1002
  const srcHtml = getWebViewHtml(baseUrl, locationOrigin, webView.elements, assetDir);
1000
1003
  if (srcHtml) {
1001
1004
  const blobUrl = getBlobUrl(srcHtml, 'text/html');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/iframe-worker",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "description": "Web Worker to manage creation and lifecycle of iframes in Lvce Editor",
5
5
  "main": "dist/iframeWorkerMain.js",
6
6
  "type": "module",