@antv/layout 2.0.0-beta.1 → 2.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/layout",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0",
4
4
  "description": "graph layout algorithm",
5
5
  "main": "dist/index.min.js",
6
6
  "module": "lib/index.js",
@@ -62,6 +62,7 @@
62
62
  "@types/d3-force": "^3.0.4",
63
63
  "@types/d3-quadtree": "^2.0.6",
64
64
  "@types/dagre": "^0.7.52",
65
+ "@types/jest": "^30.0.0",
65
66
  "babel-loader": "^8.0.6",
66
67
  "eslint": "^7.32.0",
67
68
  "eslint-config-airbnb-base": "^14.2.1",
@@ -104,7 +105,8 @@
104
105
  "test:coverage:open": "open-cli coverage/lcov-report/index.html",
105
106
  "test:coverage": "jest --coverage",
106
107
  "test": "jest",
107
- "deploy": "npm --prefix site run build && gh-pages -d site/doc_build"
108
+ "deploy": "npm --prefix site run build && gh-pages -d site/doc_build",
109
+ "lint": "tsc --noEmit"
108
110
  },
109
111
  "publishConfig": {
110
112
  "access": "public",
@@ -56,23 +56,38 @@ export class Supervisor {
56
56
  * Resolve worker script path which works in both ESM and UMD environments
57
57
  */
58
58
  private resolveWorkerPath(): string {
59
- if (typeof import.meta !== 'undefined' && import.meta.url) {
60
- const currentUrl = new URL(import.meta.url);
61
- // e.g. `.../lib/runtime/supervisor.js` -> `.../lib/worker.js`
62
- const asRoot = currentUrl.href.replace(/\/runtime\/[^/]+\.js$/, '/worker.js');
63
- if (asRoot !== currentUrl.href) return asRoot;
64
- // Fallback: keep legacy behavior (same directory)
65
- return currentUrl.href.replace(/\/[^/]+\.js$/, '/worker.js');
66
- }
59
+ const scriptUrl = (() => {
60
+ if (typeof document === 'undefined') return null;
61
+
62
+ const currentScript = document.currentScript as HTMLScriptElement | null;
63
+ if (currentScript?.src) return currentScript.src;
67
64
 
68
- if (typeof document !== 'undefined') {
69
65
  const scripts = document.getElementsByTagName('script');
66
+
70
67
  for (let i = scripts.length - 1; i >= 0; i--) {
71
68
  const src = scripts[i].src;
72
- if (src && (src.includes('index.js') || src.includes('index.min.js'))) {
73
- return src.replace(/index(\.min)?\.js/, 'worker.js');
69
+ if (!src) continue;
70
+ if (src.includes('index.js') || src.includes('index.min.js')) {
71
+ return src;
74
72
  }
75
73
  }
74
+
75
+ return null;
76
+ })();
77
+
78
+ if (scriptUrl) {
79
+ if (scriptUrl.includes('index.js') || scriptUrl.includes('index.min.js')) {
80
+ const asIndex = scriptUrl.replace(/index(\.min)?\.(m?js)(\?.*)?$/, 'worker.js');
81
+ if (asIndex !== scriptUrl) return asIndex;
82
+ }
83
+
84
+ // e.g. `.../lib/runtime/supervisor.js` -> `.../lib/worker.js`
85
+ const asRoot = scriptUrl.replace(/\/runtime\/[^/]+\.(m?js)(\?.*)?$/, '/worker.js');
86
+ if (asRoot !== scriptUrl) return asRoot;
87
+
88
+ // Fallback: keep legacy behavior (same directory)
89
+ const asSibling = scriptUrl.replace(/\/[^/]+\.(m?js)(\?.*)?$/, '/worker.js');
90
+ if (asSibling !== scriptUrl) return asSibling;
76
91
  }
77
92
 
78
93
  return './worker.js';