@antv/layout 2.0.0-beta.1 → 2.0.0-beta.2

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.js CHANGED
@@ -4,7 +4,6 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Layout = {}));
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
8
7
  /******************************************************************************
9
8
  Copyright (c) Microsoft Corporation.
10
9
 
@@ -1664,23 +1663,37 @@
1664
1663
  * Resolve worker script path which works in both ESM and UMD environments
1665
1664
  */
1666
1665
  resolveWorkerPath() {
1667
- if (typeof ({ url: (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)) }) !== 'undefined' && (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href))) {
1668
- const currentUrl = new URL((typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)));
1669
- // e.g. `.../lib/runtime/supervisor.js` -> `.../lib/worker.js`
1670
- const asRoot = currentUrl.href.replace(/\/runtime\/[^/]+\.js$/, '/worker.js');
1671
- if (asRoot !== currentUrl.href)
1672
- return asRoot;
1673
- // Fallback: keep legacy behavior (same directory)
1674
- return currentUrl.href.replace(/\/[^/]+\.js$/, '/worker.js');
1675
- }
1676
- if (typeof document !== 'undefined') {
1666
+ const scriptUrl = (() => {
1667
+ if (typeof document === 'undefined')
1668
+ return null;
1669
+ const currentScript = document.currentScript;
1670
+ if (currentScript === null || currentScript === void 0 ? void 0 : currentScript.src)
1671
+ return currentScript.src;
1677
1672
  const scripts = document.getElementsByTagName('script');
1678
1673
  for (let i = scripts.length - 1; i >= 0; i--) {
1679
1674
  const src = scripts[i].src;
1680
- if (src && (src.includes('index.js') || src.includes('index.min.js'))) {
1681
- return src.replace(/index(\.min)?\.js/, 'worker.js');
1675
+ if (!src)
1676
+ continue;
1677
+ if (src.includes('index.js') || src.includes('index.min.js')) {
1678
+ return src;
1682
1679
  }
1683
1680
  }
1681
+ return null;
1682
+ })();
1683
+ if (scriptUrl) {
1684
+ if (scriptUrl.includes('index.js') || scriptUrl.includes('index.min.js')) {
1685
+ const asIndex = scriptUrl.replace(/index(\.min)?\.(m?js)(\?.*)?$/, 'worker.js');
1686
+ if (asIndex !== scriptUrl)
1687
+ return asIndex;
1688
+ }
1689
+ // e.g. `.../lib/runtime/supervisor.js` -> `.../lib/worker.js`
1690
+ const asRoot = scriptUrl.replace(/\/runtime\/[^/]+\.(m?js)(\?.*)?$/, '/worker.js');
1691
+ if (asRoot !== scriptUrl)
1692
+ return asRoot;
1693
+ // Fallback: keep legacy behavior (same directory)
1694
+ const asSibling = scriptUrl.replace(/\/[^/]+\.(m?js)(\?.*)?$/, '/worker.js');
1695
+ if (asSibling !== scriptUrl)
1696
+ return asSibling;
1684
1697
  }
1685
1698
  return './worker.js';
1686
1699
  }