Skip to content

Commit 386fb44

Browse files
committed
update
update update dependencies
1 parent 7621dab commit 386fb44

7 files changed

Lines changed: 19 additions & 26 deletions

File tree

src/Metro/PositioningEngine.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import Network, {
2323
import initSlots from './utils/initSlots'
2424
import getPositions from './utils/getPositions'
2525
import {
26-
SourceOrTarget,
2726
SlotPoints,
2827
} from './utils/types'
2928

@@ -33,7 +32,7 @@ import costFunction from './optimization/costFunction'
3332

3433
const GAP_BETWEEN_PARALLEL = 0 // 0 - none, 1 - line width
3534

36-
const SOURCE_TARGET = Object.freeze(['source', 'target'] as SourceOrTarget[])
35+
const SOURCE_TARGET = ['source', 'target'] as const
3736

3837
interface ChildrenFuncParams {
3938
getSpanSlotsScaled: PositioningEngine['getSpanSlotsScaled'],
@@ -66,13 +65,9 @@ class PositioningEngine extends PureComponent<Props> {
6665
this.optimize()
6766
}
6867

69-
private getPlatformSlot(platform: Platform) {
70-
return this.platformSlots.get(platform) || null
71-
}
72-
7368
// center is 0, (-1, 0, 1 or -0.5, 0.5 ...)
7469
private getPlatformSlotPosition(platform: Platform, route: Route) {
75-
const map = this.getPlatformSlot(platform)
70+
const map = this.platformSlots.get(platform)
7671
if (!map) {
7772
return 0
7873
}
@@ -132,9 +127,6 @@ class PositioningEngine extends PureComponent<Props> {
132127
}
133128
}
134129

135-
private getFirstWhisker = (platform: Platform) =>
136-
this.props.getPlatformWhiskers(platform).values().next().value
137-
138130
private updateBatches = () => {
139131
// console.time('batches')
140132

@@ -287,13 +279,14 @@ class PositioningEngine extends PureComponent<Props> {
287279

288280
private getPlatformSlotPoints = (platform: Platform) => {
289281
const pos = this.props.getPlatformPosition(platform)
290-
const value = this.getFirstWhisker(platform)
282+
// get first whisker
283+
const value = this.props.getPlatformWhiskers(platform).values().next().value
291284
if (pos.equals(value)) {
292285
// TODO WTF
293286
return pos
294287
}
295288

296-
const slots = this.getPlatformSlot(platform)
289+
const slots = this.platformSlots.get(platform)
297290
if (!slots) {
298291
return pos
299292
}

src/Metro/Spans.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, {
22
useState,
3-
useCallback,
43
memo,
54
} from 'react'
65
import styled from 'styled-components'
@@ -79,7 +78,7 @@ const Spans = ({
7978
}: Props) => {
8079
const [pathsInner, setPathsInner] = useState<SVGGElement | null>(null)
8180

82-
const getControlPoints = useCallback((span: Span) => {
81+
const getControlPoints = (span: Span) => {
8382
const { source, target } = span
8483
const sourcePos = getPlatformPosition(source)
8584
const targetPos = getPlatformPosition(target)
@@ -129,9 +128,9 @@ const Spans = ({
129128
const curves = math.split(controlPoints, CURVE_SPLIT_NUM)
130129
const [head, ...tail] = curves.map(pa => math.offsetPath(pa, offset))
131130
return [head, ...tail.map(arr => arr.slice(1))]
132-
}, [getPlatformPosition, getPlatformWhiskers, getSpanSlotsScaled, getSpanOffset])
131+
}
133132

134-
const makePath = useCallback((span: Span) => {
133+
const makePath = (span: Span) => {
135134
const {
136135
routes,
137136
source,
@@ -191,7 +190,7 @@ const Spans = ({
191190
// }
192191
// pool.outerEdgeBindings.set(span, bezier)
193192
return [bezier]
194-
}, [detailedE, lineRules, getControlPoints])
193+
}
195194

196195
const outerStrokeWidth = lineWidth
197196
const innerStrokeWidth = lineWidth / 2

src/Metro/Transfers.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function getBestTriplet(sourcePositionArr: Point[], targetPositionArr: Point[],
7575

7676
function getBestCombo(sourcePos: Point | Point[], targetPos: Point | Point[], thirdPos: Point | null) {
7777
if (!Array.isArray(sourcePos) && !Array.isArray(targetPos)) {
78-
return [sourcePos, targetPos, thirdPos] as Pair<Point> | Triple<Point>
78+
return [sourcePos, targetPos, thirdPos] as const
7979
}
8080

8181
const sourcePositionArr = castArray(sourcePos)
@@ -127,7 +127,7 @@ const Transfers = ({
127127
}: Props) => {
128128
const [transfersInner, setTransfersInner] = useState<SVGGElement | null>(null)
129129

130-
const getThirdPosition = useCallback((transfer: Transfer) => {
130+
const getThirdPosition = (transfer: Transfer) => {
131131
const { source, target } = transfer
132132
const scp = stationCircumpoints.get(source.station)
133133
const includes = scp && scp.includes(source) && scp.includes(target)
@@ -136,15 +136,15 @@ const Transfers = ({
136136
}
137137
const third = difference(scp, [source, target])[0] || undefined
138138
return getPlatformPosition(third)
139-
}, [stationCircumpoints, getPlatformPosition])
139+
}
140140

141-
const getPositions = useCallback((transfer: Transfer) => {
141+
const getPositions = (transfer: Transfer) => {
142142
const { source, target } = transfer
143143
const sourcePos = getPlatformSlotPoints(source)
144144
const targetPos = getPlatformSlotPoints(target)
145145
const thirdPos = getThirdPosition(transfer)
146146
return getBestCombo(sourcePos, targetPos, thirdPos)
147-
}, [getPlatformSlotPoints, getThirdPosition])
147+
}
148148

149149
const setFeaturedPlatformsMem = useCallback((transfer: Transfer) => {
150150
const feat = getFeaturedPlatforms(transfer)

src/Metro/optimization/costFunction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export default ({
7272

7373
distances[span.id] = sourcePoint.distanceTo(targetPoint)
7474

75-
const arr = [sourcePoint, targetPoint] as [Point, Point]
75+
const arr = [sourcePoint, targetPoint] as const
7676

7777
for (let j = i + 1; j < numSpans; ++j) {
7878
const otherSpan = spans[j]

src/Metro/utils/makeWhiskers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
} from '../../network'
1818

1919
type Bound = 'inbound' | 'outbound'
20-
const SPAN_PROPS = Object.freeze(['inbound', 'outbound'] as Bound[])
20+
const SPAN_PROPS = ['inbound', 'outbound'] as const
2121

2222
type Positions = {
2323
[P in Bound]: Point

src/utils/math/vector.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Point, point } from 'leaflet'
22
import { isArbitrarilySmall as isNumberSmall } from '.'
33

4-
export type Ray = [Point, Point]
5-
type Segment = [Point, Point]
4+
export type Ray = Readonly<[Point, Point]>
5+
type Segment = Readonly<[Point, Point]>
66

77
enum Orientation {
88
COLLINEAR,

webpack/rules.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const getCssLoader = global => global ? 'css-loader' : {
1616
localIdentName: '[path]___[name]__[local]___[hash:base64:5]',
1717
},
1818
importLoaders: 1,
19+
localsConvention: 'asIs',
1920
},
2021
}
2122

0 commit comments

Comments
 (0)