Skip to content

Commit f93d7d9

Browse files
committed
[gephi-lite] Clarified layout types
Details: - Renames "sync" as "oneshot" (especially since these layouts now can be async functions) - Renames "worker" as "continuous" (especially since a bunch of these don't actually run on a worker)
1 parent e5dcfa5 commit f93d7d9

File tree

12 files changed

+110
-95
lines changed

12 files changed

+110
-95
lines changed

packages/gephi-lite/src/core/layouts/collection/circlePack.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import Graph from "graphology";
22
import circlepack from "graphology-layout/circlepack";
33

4-
import { SyncLayout } from "../types";
4+
import { OneShotLayout } from "../types";
55

66
export const CirclePackLayout = {
77
id: "circlePack",
8-
type: "sync",
8+
type: "oneshot",
99
description: true,
1010
parameters: [
1111
{
@@ -37,4 +37,4 @@ export const CirclePackLayout = {
3737
hierarchyAttributes: groupingField ? [groupingField] : [],
3838
});
3939
},
40-
} as SyncLayout<{ scale?: number; groupingField?: string; center?: number }>;
40+
} as OneShotLayout<{ scale?: number; groupingField?: string; center?: number }>;

packages/gephi-lite/src/core/layouts/collection/circular.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import circular, { CircularLayoutOptions } from "graphology-layout/circular";
22

3-
import { LayoutMapping, SyncLayout } from "../types";
3+
import { LayoutMapping, OneShotLayout } from "../types";
44

55
export const CircularLayout = {
66
id: "circular",
7-
type: "sync",
7+
type: "oneshot",
88
description: true,
99
parameters: [
1010
{
@@ -22,4 +22,4 @@ export const CircularLayout = {
2222
},
2323
],
2424
run: (graph, options) => circular(graph, options?.settings) as unknown as LayoutMapping,
25-
} as SyncLayout<CircularLayoutOptions>;
25+
} as OneShotLayout<CircularLayoutOptions>;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import ForceSupervisor, { ForceLayoutSupervisorParameters } from "graphology-layout-force/worker";
22

3-
import { WorkerLayout } from "../types";
3+
import { ContinuousLayout } from "../types";
44

55
export const ForceLayout = {
66
id: "force",
7-
type: "worker",
7+
type: "continuous",
88
supervisor: ForceSupervisor,
99
parameters: [
1010
{ id: "attraction", type: "number", description: true, defaultValue: 0.0005, min: 0, step: 0.0001 },
@@ -13,4 +13,4 @@ export const ForceLayout = {
1313
{ id: "inertia", type: "number", description: true, defaultValue: 0.6, min: 0, max: 1, step: 0.1 },
1414
{ id: "maxMove", type: "number", description: true, defaultValue: 200 },
1515
],
16-
} as WorkerLayout<ForceLayoutSupervisorParameters>;
16+
} as ContinuousLayout<ForceLayoutSupervisorParameters>;

packages/gephi-lite/src/core/layouts/collection/forceAtlas2.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import RAW_FA2_DEFAULT_SETTINGS from "graphology-layout-forceatlas2/defaults";
66
import FA2Layout from "graphology-layout-forceatlas2/worker";
77

88
import { GuessSettingsIcon } from "../../../components/common-icons";
9-
import { WorkerLayout } from "../types";
9+
import { ContinuousLayout } from "../types";
1010

1111
const FA2_DEFAULT_SETTINGS = RAW_FA2_DEFAULT_SETTINGS as Required<ForceAtlas2Settings>;
1212

1313
export const ForceAtlas2Layout = {
1414
id: "fa2",
15-
type: "worker",
15+
type: "continuous",
1616
supervisor: FA2Layout,
1717
buttons: [
1818
{
@@ -88,4 +88,4 @@ export const ForceAtlas2Layout = {
8888
required: false,
8989
},
9090
],
91-
} as WorkerLayout<ForceAtlas2LayoutParameters>;
91+
} as ContinuousLayout<ForceAtlas2LayoutParameters>;

packages/gephi-lite/src/core/layouts/collection/geographic.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { MapIcon } from "../../../components/common-icons";
44
import { GeoProjectionType, applyGeoProjection } from "../../../utils/geo-projections";
55
import { appearanceActions } from "../../appearance";
66
import { EVENTS, emitter } from "../../context/eventsContext";
7-
import { LayoutMapping, SyncLayout } from "../types";
7+
import { LayoutMapping, OneShotLayout } from "../types";
88

99
const LAT_RE = /^(lat|latitude|y_?coord)$/i;
1010
const LNG_RE = /^(lng|lon|long|longitude|x_?coord)$/i;
@@ -120,7 +120,7 @@ function inferGeographicSettings(dataGraph: DataGraph): Partial<GeographicLayout
120120

121121
export const GeographicLayout = {
122122
id: "geographic",
123-
type: "sync",
123+
type: "oneshot",
124124
description: true,
125125
hideReset: true,
126126
inferSettings: inferGeographicSettings,
@@ -176,4 +176,4 @@ export const GeographicLayout = {
176176
},
177177
],
178178
run: runGeographic,
179-
} as SyncLayout<GeographicLayoutSettings>;
179+
} as OneShotLayout<GeographicLayoutSettings>;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import NoverlapLayoutSUpervisor, { NoverlapLayoutSupervisorParameters } from "graphology-layout-noverlap/worker";
22

3-
import { WorkerLayout } from "../types";
3+
import { ContinuousLayout } from "../types";
44

55
export const NoverlapLayout = {
66
id: "noverlap",
7-
type: "worker",
7+
type: "continuous",
88
description: true,
99
supervisor: NoverlapLayoutSUpervisor,
1010
parameters: [
@@ -14,4 +14,4 @@ export const NoverlapLayout = {
1414
{ id: "ratio", type: "number", description: true, defaultValue: 1 },
1515
{ id: "speed", type: "number", description: true, defaultValue: 3 },
1616
],
17-
} as WorkerLayout<NoverlapLayoutSupervisorParameters>;
17+
} as ContinuousLayout<NoverlapLayoutSupervisorParameters>;

packages/gephi-lite/src/core/layouts/collection/random.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import random, { RandomLayoutOptions } from "graphology-layout/random";
22

3-
import { LayoutMapping, SyncLayout } from "../types";
3+
import { LayoutMapping, OneShotLayout } from "../types";
44

55
export const RandomLayout = {
66
id: "random",
7-
type: "sync",
7+
type: "oneshot",
88
description: true,
99
parameters: [
1010
{
@@ -21,4 +21,4 @@ export const RandomLayout = {
2121
},
2222
],
2323
run: (graph, options) => random(graph, options?.settings) as unknown as LayoutMapping,
24-
} as SyncLayout<RandomLayoutOptions>;
24+
} as OneShotLayout<RandomLayoutOptions>;

packages/gephi-lite/src/core/layouts/collection/script.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { isNil, isObject } from "lodash";
55
import { codeToFunction } from "../../../utils/functions";
66
import { graphDatasetAtom } from "../../graph";
77
import { dataGraphToFullGraph } from "../../graph/utils";
8-
import { LayoutMapping, LayoutScriptFunction, SyncLayout } from "../types";
8+
import { LayoutMapping, LayoutScriptFunction, OneShotLayout } from "../types";
99

1010
// definition of a custom layout function
1111
const nodeCoordinatesCustomFn =
@@ -18,7 +18,7 @@ const nodeCoordinatesCustomFn =
1818

1919
export const ScriptLayout = {
2020
id: "script",
21-
type: "sync",
21+
type: "oneshot",
2222
description: true,
2323
parameters: [
2424
{
@@ -63,6 +63,6 @@ export const ScriptLayout = {
6363
});
6464
return res;
6565
},
66-
} as SyncLayout<{
66+
} as OneShotLayout<{
6767
script?: (id: string, attributes: ItemData, index: number, graph: Graph) => { x: number; y: number };
6868
}>;

0 commit comments

Comments
 (0)