@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.
@@ -1,6 +1,6 @@
1
1
  import { feasibleTreeWithLayer } from './feasible-tree.js';
2
2
  import { networkSimplex } from './network-simplex.js';
3
- import { longestPath, longestPathWithLayer } from './util.js';
3
+ import { longestPathWithLayer, longestPath } from './util.js';
4
4
 
5
5
  /*
6
6
  * Assigns a rank to each node in the input graph that respects the "minlen"
@@ -1,7 +1,7 @@
1
1
  import { __awaiter } from '../../node_modules/tslib/tslib.es6.js';
2
2
  import { applySingleNodeLayout } from '../../util/common.js';
3
3
  import '../../node_modules/@antv/expr/dist/index.esm.js';
4
- import { formatFn, formatNodeSizeFn } from '../../util/format.js';
4
+ import { formatNodeSizeFn, formatFn } from '../../util/format.js';
5
5
  import { orderByDegree, orderBySorter } from '../../util/order.js';
6
6
  import { normalizeViewport } from '../../util/viewport.js';
7
7
  import { BaseLayout } from '../base-layout.js';
package/lib/index.d.ts CHANGED
@@ -40,11 +40,11 @@ export { AntVDagreLayoutOptions } from './algorithm/antv-dagre/types.js';
40
40
  export { CircularLayoutOptions } from './algorithm/circular/types.js';
41
41
  export { ComboCombinedLayoutOptions } from './algorithm/combo-combined/types.js';
42
42
  export { ConcentricLayoutOptions } from './algorithm/concentric/types.js';
43
- export { D3ForceLayoutOptions } from './algorithm/d3-force/types.js';
44
43
  export { D3Force3DLayoutOptions } from './algorithm/d3-force-3d/types.js';
44
+ export { D3ForceLayoutOptions } from './algorithm/d3-force/types.js';
45
45
  export { DagreLayoutOptions } from './algorithm/dagre/types.js';
46
- export { ForceLayoutOptions } from './algorithm/force/types.js';
47
46
  export { ForceAtlas2LayoutOptions } from './algorithm/force-atlas2/types.js';
47
+ export { ForceLayoutOptions } from './algorithm/force/types.js';
48
48
  export { FruchtermanLayoutOptions } from './algorithm/fruchterman/types.js';
49
49
  export { GridLayoutOptions } from './algorithm/grid/types.js';
50
50
  export { MDSLayoutOptions } from './algorithm/mds/types.js';
@@ -49,23 +49,37 @@ class Supervisor {
49
49
  * Resolve worker script path which works in both ESM and UMD environments
50
50
  */
51
51
  resolveWorkerPath() {
52
- if (typeof import.meta !== 'undefined' && import.meta.url) {
53
- const currentUrl = new URL(import.meta.url);
54
- // e.g. `.../lib/runtime/supervisor.js` -> `.../lib/worker.js`
55
- const asRoot = currentUrl.href.replace(/\/runtime\/[^/]+\.js$/, '/worker.js');
56
- if (asRoot !== currentUrl.href)
57
- return asRoot;
58
- // Fallback: keep legacy behavior (same directory)
59
- return currentUrl.href.replace(/\/[^/]+\.js$/, '/worker.js');
60
- }
61
- if (typeof document !== 'undefined') {
52
+ const scriptUrl = (() => {
53
+ if (typeof document === 'undefined')
54
+ return null;
55
+ const currentScript = document.currentScript;
56
+ if (currentScript === null || currentScript === void 0 ? void 0 : currentScript.src)
57
+ return currentScript.src;
62
58
  const scripts = document.getElementsByTagName('script');
63
59
  for (let i = scripts.length - 1; i >= 0; i--) {
64
60
  const src = scripts[i].src;
65
- if (src && (src.includes('index.js') || src.includes('index.min.js'))) {
66
- return src.replace(/index(\.min)?\.js/, 'worker.js');
61
+ if (!src)
62
+ continue;
63
+ if (src.includes('index.js') || src.includes('index.min.js')) {
64
+ return src;
67
65
  }
68
66
  }
67
+ return null;
68
+ })();
69
+ if (scriptUrl) {
70
+ if (scriptUrl.includes('index.js') || scriptUrl.includes('index.min.js')) {
71
+ const asIndex = scriptUrl.replace(/index(\.min)?\.(m?js)(\?.*)?$/, 'worker.js');
72
+ if (asIndex !== scriptUrl)
73
+ return asIndex;
74
+ }
75
+ // e.g. `.../lib/runtime/supervisor.js` -> `.../lib/worker.js`
76
+ const asRoot = scriptUrl.replace(/\/runtime\/[^/]+\.(m?js)(\?.*)?$/, '/worker.js');
77
+ if (asRoot !== scriptUrl)
78
+ return asRoot;
79
+ // Fallback: keep legacy behavior (same directory)
80
+ const asSibling = scriptUrl.replace(/\/[^/]+\.(m?js)(\?.*)?$/, '/worker.js');
81
+ if (asSibling !== scriptUrl)
82
+ return asSibling;
69
83
  }
70
84
  return './worker.js';
71
85
  }
@@ -1 +1 @@
1
- {"version":3,"file":"supervisor.js","sources":["../../src/runtime/src/runtime/supervisor.ts"],"sourcesContent":[null],"names":[],"mappings":";;;MAIa,UAAU,CAAA;AAAvB,IAAA,WAAA,GAAA;QACU,IAAA,CAAA,MAAM,GAAkB,IAAI;QAC5B,IAAA,CAAA,SAAS,GAAgC,IAAI;IAyEvD;AAvEE;;AAEG;AACG,IAAA,OAAO,CACX,QAAgB,EAChB,IAAe,EACf,OAAoB,EAAA;;AAEpB,YAAA,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;AAChB,gBAAA,MAAM,IAAI,CAAC,UAAU,EAAE;AACxB,YAAA;AAED,YAAA,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;AACnB,gBAAA,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC;AAC9C,YAAA;AAED,YAAA,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC;QAC9D,CAAC,CAAA;AAAA,IAAA;AAED;;AAEG;IACH,OAAO,GAAA;QACL,IAAI,IAAI,CAAC,SAAS,EAAE;AAClB,YAAA,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE;AACzB,QAAA;QACD,IAAI,IAAI,CAAC,MAAM,EAAE;AACf,YAAA,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE;AACvB,YAAA,IAAI,CAAC,MAAM,GAAG,IAAI;AAClB,YAAA,IAAI,CAAC,SAAS,GAAG,IAAI;AACtB,QAAA;IACH;AAEA;;AAEG;IACW,UAAU,GAAA;;AACtB,YAAA,MAAM,UAAU,GAAG,IAAI,CAAC,iBAAiB,EAAE;AAE3C,YAAA,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,UAAU,CAAC,QAAQ,CA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AAAE,oBAAA,OAAO,OAAO;AAC1C,YAAA;;YAGD,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,kCAAkC,EAAE,YAAY,CAAC;YAClF,IAAI,MAAM,KAAK,SAAS;AAAE,gBAAA,OAAO,MAAM;;YAGvC,MAAM,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,yBAAyB,EAAE,YAAY,CAAC;YAC5E,IAAI,SAAS,KAAK,SAAS;AAAE,gBAAA,OAAO,SAAS;AAC9C,QAAA;AAED,QAAA,OAAO,aAAa;IACtB;AACD;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { evaluateExpression } from './expr.js';
2
- import { isSize, parseSize } from './size.js';
2
+ import { parseSize, isSize } from './size.js';
3
3
  import isNil from '../node_modules/@antv/util/esm/lodash/is-nil.js';
4
4
  import isString from '../node_modules/@antv/util/esm/lodash/is-string.js';
5
5
  import isNumber from '../node_modules/@antv/util/esm/lodash/is-number.js';
package/lib/worker.js CHANGED
@@ -1452,23 +1452,37 @@ class Supervisor {
1452
1452
  * Resolve worker script path which works in both ESM and UMD environments
1453
1453
  */
1454
1454
  resolveWorkerPath() {
1455
- if (typeof import.meta !== 'undefined' && import.meta.url) {
1456
- const currentUrl = new URL(import.meta.url);
1457
- // e.g. `.../lib/runtime/supervisor.js` -> `.../lib/worker.js`
1458
- const asRoot = currentUrl.href.replace(/\/runtime\/[^/]+\.js$/, '/worker.js');
1459
- if (asRoot !== currentUrl.href)
1460
- return asRoot;
1461
- // Fallback: keep legacy behavior (same directory)
1462
- return currentUrl.href.replace(/\/[^/]+\.js$/, '/worker.js');
1463
- }
1464
- if (typeof document !== 'undefined') {
1455
+ const scriptUrl = (() => {
1456
+ if (typeof document === 'undefined')
1457
+ return null;
1458
+ const currentScript = document.currentScript;
1459
+ if (currentScript === null || currentScript === void 0 ? void 0 : currentScript.src)
1460
+ return currentScript.src;
1465
1461
  const scripts = document.getElementsByTagName('script');
1466
1462
  for (let i = scripts.length - 1; i >= 0; i--) {
1467
1463
  const src = scripts[i].src;
1468
- if (src && (src.includes('index.js') || src.includes('index.min.js'))) {
1469
- return src.replace(/index(\.min)?\.js/, 'worker.js');
1464
+ if (!src)
1465
+ continue;
1466
+ if (src.includes('index.js') || src.includes('index.min.js')) {
1467
+ return src;
1470
1468
  }
1471
1469
  }
1470
+ return null;
1471
+ })();
1472
+ if (scriptUrl) {
1473
+ if (scriptUrl.includes('index.js') || scriptUrl.includes('index.min.js')) {
1474
+ const asIndex = scriptUrl.replace(/index(\.min)?\.(m?js)(\?.*)?$/, 'worker.js');
1475
+ if (asIndex !== scriptUrl)
1476
+ return asIndex;
1477
+ }
1478
+ // e.g. `.../lib/runtime/supervisor.js` -> `.../lib/worker.js`
1479
+ const asRoot = scriptUrl.replace(/\/runtime\/[^/]+\.(m?js)(\?.*)?$/, '/worker.js');
1480
+ if (asRoot !== scriptUrl)
1481
+ return asRoot;
1482
+ // Fallback: keep legacy behavior (same directory)
1483
+ const asSibling = scriptUrl.replace(/\/[^/]+\.(m?js)(\?.*)?$/, '/worker.js');
1484
+ if (asSibling !== scriptUrl)
1485
+ return asSibling;
1472
1486
  }
1473
1487
  return './worker.js';
1474
1488
  }