@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/dist/index.js +26 -13
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/worker.js +2 -2
- package/dist/worker.js.map +1 -1
- package/lib/algorithm/antv-dagre/rank/index.js +1 -1
- package/lib/algorithm/concentric/index.js +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/runtime/supervisor.js +26 -12
- package/lib/runtime/supervisor.js.map +1 -1
- package/lib/util/format.js +1 -1
- package/lib/worker.js +26 -12
- package/lib/worker.js.map +1 -1
- package/package.json +4 -2
- package/src/runtime/supervisor.ts +26 -11
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { feasibleTreeWithLayer } from './feasible-tree.js';
|
|
2
2
|
import { networkSimplex } from './network-simplex.js';
|
|
3
|
-
import {
|
|
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 {
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
57
|
-
return
|
|
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
|
|
66
|
-
|
|
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;
|
|
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;IAwFvD;AAtFE;;AAEG;AACG,IAAA,OAAO,CACX,QAAg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AS;AAC9C,QAAA;AAED,QAAA,OAAO,aAAa;IACtB;AACD;;;;"}
|
package/lib/util/format.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { evaluateExpression } from './expr.js';
|
|
2
|
-
import {
|
|
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
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
const
|
|
1459
|
-
if (
|
|
1460
|
-
return
|
|
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
|
|
1469
|
-
|
|
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
|
}
|