Skip to content

Commit ac744e2

Browse files
hyperpolymathclaude
andcommitted
refactor: migrate Js.Float and Js.Console to modern APIs (35 occurrences)
Replace deprecated APIs: - Js.Console.log/error -> Console.log/error - Js.Float.toFixedWithPrecision -> Float.toFixedWithPrecision - Js.Float.isFinite -> Float.isFinite Part of #28. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5c92a0a commit ac744e2

File tree

14 files changed

+34
-34
lines changed

14 files changed

+34
-34
lines changed

src/app/devices/CoprocessorBridge.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ let formatResult = (domain: string, cmd: string, result: executionResult): strin
122122
`\n data: ${dataStr}${msgStr}` ++
123123
`\n cost: ${Belt.Int.toString(result.metrics.computeUnits)} cu / ` ++
124124
`${Belt.Int.toString(result.metrics.memoryBytes)} B / ` ++
125-
`${Js.Float.toFixedWithPrecision(result.metrics.energyJoules, ~digits=3)} J`
125+
`${Float.toFixedWithPrecision(result.metrics.energyJoules, ~digits=3)} J`
126126
}
127127

128128
// ---------------------------------------------------------------------------

src/app/devices/RouterDevice.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,13 +441,13 @@ let createRouterInterface = (container: Container.t, ipAddress: string): (unit =
441441

442442
// Format with units
443443
let upStr = if uploadSpeed.contents >= 1.0 {
444-
`${Js.Float.toFixedWithPrecision(uploadSpeed.contents, ~digits=1)} MB/s`
444+
`${Float.toFixedWithPrecision(uploadSpeed.contents, ~digits=1)} MB/s`
445445
} else {
446446
`${Belt.Int.toString(Belt.Float.toInt(uploadSpeed.contents *. 1024.0))} KB/s`
447447
}
448448

449449
let downStr = if downloadSpeed.contents >= 1.0 {
450-
`${Js.Float.toFixedWithPrecision(downloadSpeed.contents, ~digits=1)} MB/s`
450+
`${Float.toFixedWithPrecision(downloadSpeed.contents, ~digits=1)} MB/s`
451451
} else {
452452
`${Belt.Int.toString(Belt.Float.toInt(downloadSpeed.contents *. 1024.0))} KB/s`
453453
}

src/app/devices/Terminal.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ let listDirectory = (terminal: t, path: string, activeIp: string): string => {
105105
""
106106
}
107107
let sizeStr = if sizeMB >= 1.0 {
108-
` (${Js.Float.toFixedWithPrecision(sizeMB, ~digits=1)} MB)`
108+
` (${Float.toFixedWithPrecision(sizeMB, ~digits=1)} MB)`
109109
} else if sizeMB > 0.0 {
110110
let kb = sizeMB *. 1024.0
111111
` (${Belt.Int.toString(Belt.Float.toInt(kb))} KB)`

src/app/devices/UPSDevice.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ let createUPSInterface = (container: Container.t, ipAddress: string): int => {
162162

163163
// Battery percentage
164164
let batteryPercent = Text.make({
165-
"text": `${Js.Float.toFixedWithPrecision(upsState.batteryLevel, ~digits=1)}%`,
165+
"text": `${Float.toFixedWithPrecision(upsState.batteryLevel, ~digits=1)}%`,
166166
"style": {"fontSize": 14, "fill": 0xffffff, "fontFamily": "monospace", "fontWeight": "bold"},
167167
})
168168
Text.setX(batteryPercent, 330.0)
@@ -285,7 +285,7 @@ let createUPSInterface = (container: Container.t, ipAddress: string): int => {
285285
->Graphics.fill({"color": newBatteryColor})
286286

287287
// Update percentage
288-
Text.setText(batteryPercent, `${Js.Float.toFixedWithPrecision(currentState.batteryLevel, ~digits=1)}%`)
288+
Text.setText(batteryPercent, `${Float.toFixedWithPrecision(currentState.batteryLevel, ~digits=1)}%`)
289289
}, 500) // Update twice per second
290290

291291
intervalId

src/app/devices/common/DeviceWindow.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ let make = (
125125

126126
// Setup close button - use pointerdown for more reliable detection
127127
Graphics.on(closeBtn, "pointerdown", _ => {
128-
Js.Console.log("Close button clicked!")
128+
Console.log("Close button clicked!")
129129
// Call onClose callback if set
130130
switch windowState.onCloseCallback {
131131
| Some(callback) => callback()

src/app/enemies/DetectionSystem.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ let getRecentEvents = (system: t, ~count: int): array<string> => {
185185
let start = Math.Int.max(0, len - count)
186186
let recent = Belt.Array.slice(system.events, ~offset=start, ~len=len - start)
187187
recent->Belt.Array.map(e => {
188-
let timeStr = Js.Float.toFixedWithPrecision(e.timestamp, ~digits=1)
188+
let timeStr = Float.toFixedWithPrecision(e.timestamp, ~digits=1)
189189
`[${timeStr}s] ${sourceToString(e.source)} (+${Belt.Int.toString(Belt.Float.toInt(e.weight))})`
190190
})
191191
}
@@ -194,7 +194,7 @@ let getRecentEvents = (system: t, ~count: int): array<string> => {
194194
let formatStatus = (system: t): string => {
195195
let level = getAlertLevel(system)
196196
let levelStr = HUD.alertToString(level)
197-
let score = Js.Float.toFixedWithPrecision(system.alertScore, ~digits=1)
197+
let score = Float.toFixedWithPrecision(system.alertScore, ~digits=1)
198198
let suppressed = if system.suppressionActive {
199199
" [SUPPRESSED]"
200200
} else {

src/app/popups/PowerView.res

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,14 @@ module PowerNode = {
134134
// Boot the device
135135
if PowerManager.deviceHasPower(ipAddress) {
136136
PowerManager.bootDevice(ipAddress)
137-
Js.Console.log(`[PowerView] Booting device ${ipAddress}`)
137+
Console.log(`[PowerView] Booting device ${ipAddress}`)
138138
} else {
139-
Js.Console.log(`[PowerView] Cannot boot ${ipAddress} - no power available`)
139+
Console.log(`[PowerView] Cannot boot ${ipAddress} - no power available`)
140140
}
141141
} else {
142142
// Shutdown the device
143143
PowerManager.manualShutdownDevice(ipAddress)
144-
Js.Console.log(`[PowerView] Shutting down device ${ipAddress}`)
144+
Console.log(`[PowerView] Shutting down device ${ipAddress}`)
145145
}
146146
})
147147
}

src/app/proven/SafeAngle.res

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
// Create angle from atan2, guarding against non-finite inputs
88
let fromAtan2 = (~y: float, ~x: float): float => {
9-
if !Js.Float.isFinite(y) || !Js.Float.isFinite(x) {
9+
if !Float.isFinite(y) || !Float.isFinite(x) {
1010
0.0 // Default to 0 if inputs are invalid
1111
} else {
1212
Math.atan2(~y, ~x)
@@ -15,12 +15,12 @@ let fromAtan2 = (~y: float, ~x: float): float => {
1515

1616
// Normalize angle to [-PI, PI]
1717
let normalize = (angle: float): float => {
18-
if !Js.Float.isFinite(angle) {
18+
if !Float.isFinite(angle) {
1919
0.0
2020
} else {
2121
let pi = Math.Constants.pi
2222
let normalized = mod_float(angle +. pi, 2.0 *. pi) -. pi
23-
if !Js.Float.isFinite(normalized) {
23+
if !Float.isFinite(normalized) {
2424
0.0
2525
} else {
2626
normalized
@@ -35,7 +35,7 @@ let diff = (a: float, b: float): float => {
3535

3636
// Safe cosine (guards against NaN/Infinity)
3737
let cos = (angle: float): float => {
38-
if !Js.Float.isFinite(angle) {
38+
if !Float.isFinite(angle) {
3939
1.0 // Default to 1.0 if input is invalid
4040
} else {
4141
Math.cos(angle)
@@ -44,7 +44,7 @@ let cos = (angle: float): float => {
4444

4545
// Safe sine (guards against NaN/Infinity)
4646
let sin = (angle: float): float => {
47-
if !Js.Float.isFinite(angle) {
47+
if !Float.isFinite(angle) {
4848
0.0 // Default to 0.0 if input is invalid
4949
} else {
5050
Math.sin(angle)

src/app/screens/WorldScreen.res

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ module WorldDeviceIcon = {
311311
let ip = info.ipAddress
312312
let deviceX = x // Store device X position for proximity check
313313
Container.on(indicatorContainer, "pointertap", e => {
314-
Js.Console.log(`Power indicator clicked for ${ip}`)
314+
Console.log(`Power indicator clicked for ${ip}`)
315315
// Stop event from bubbling to device container
316316
Pixi.stopPropagation(e)
317317

@@ -325,21 +325,21 @@ module WorldDeviceIcon = {
325325
}
326326

327327
if !isNearby {
328-
Js.Console.log(`Too far from ${ip} - must be within ${Float.toString(interactionDistance)} units`)
328+
Console.log(`Too far from ${ip} - must be within ${Float.toString(interactionDistance)} units`)
329329
} else {
330330
let isShutdown = PowerManager.isDeviceShutdown(ip)
331331
if isShutdown {
332332
// Boot the device if it has power available
333333
if PowerManager.deviceHasPower(ip) {
334334
PowerManager.bootDevice(ip)
335-
Js.Console.log(`Booting device ${ip}`)
335+
Console.log(`Booting device ${ip}`)
336336
} else {
337-
Js.Console.log(`Cannot boot ${ip} - no power available`)
337+
Console.log(`Cannot boot ${ip} - no power available`)
338338
}
339339
} else {
340340
// Manually shutdown the device (won't auto-boot)
341341
PowerManager.manualShutdownDevice(ip)
342-
Js.Console.log(`Manually shutting down device ${ip}`)
342+
Console.log(`Manually shutting down device ${ip}`)
343343
}
344344
}
345345
})
@@ -630,15 +630,15 @@ let make = (): Navigation.appScreen => {
630630
// Debug button to open network view
631631
let debugButton = Button.make(~options={text: "Network View (Debug)", width: 180.0, height: 40.0}, ())
632632
Signal.connect(FancyButton.onPress(debugButton), () => {
633-
Js.Console.log("Network View button pressed!")
633+
Console.log("Network View button pressed!")
634634
switch GetEngine.get() {
635635
| Some(engine) =>
636636
let _ = Navigation.presentPopup(engine.navigation, NetworkDesktop.constructor)
637637
| None => ()
638638
}
639639
})
640640
Signal.connect(FancyButton.onDown(debugButton), () => {
641-
Js.Console.log("Network View button down!")
641+
Console.log("Network View button down!")
642642
})
643643
let _ = Container.addChild(container, FancyButton.toContainer(debugButton))
644644

@@ -752,7 +752,7 @@ let make = (): Navigation.appScreen => {
752752

753753
if !canOpen {
754754
// Device is shutdown - don't open, just log
755-
Js.Console.log(`Device ${wd.ipAddress} is shutdown - no power`)
755+
Console.log(`Device ${wd.ipAddress} is shutdown - no power`)
756756
} else {
757757
// Close existing window if any
758758
closeDeviceWindow()

src/app/screens/training/MoletaireTraining.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ let updateMoleStatus = (ts: trainingState): unit => {
452452
| Some(text) => {
453453
let mole = ts.mole
454454
let stateStr = Moletaire.stateToString(mole)
455-
let depthStr = Js.Float.toFixedWithPrecision(mole.depth, ~digits=1)
455+
let depthStr = Float.toFixedWithPrecision(mole.depth, ~digits=1)
456456
let hungerPct = Belt.Int.toString(Float.toInt(Moletaire.getHunger(mole) *. 100.0))
457457
let carryStr = switch mole.carriedItem {
458458
| Some(_) => " [USB]"

0 commit comments

Comments
 (0)