StikDebug/StikJIT/Utilities/TabConfiguration.swift
Huge_Black dca36d5c00
Heartbeat Rework + Mini Tool (#299)
* Heartbeat rework

* remove some debug loggings

* stik mini tool poc

* Saperate JITEnableContext into extensions and put each feature into their own files.
Fix local pairing file is removed after switched to external device by directly loading the remote device's pairing file in place.

* custom origin & xmlhttprequest

* Fix some memory leak

* allow background script access idevice (codes are from the old JSSupport branch)

Tests are not carried out but most of the js api should work.

Do we need to obfuscate some functions' name?

* Fix JITEnableContext singleton initializer race condition

* Fix instprox callback

---------

Co-authored-by: Stephen B <158498287+StephenDev0@users.noreply.github.com>
2025-12-14 11:35:32 -05:00

48 lines
1.5 KiB
Swift

import Foundation
enum TabConfiguration {
static let storageKey = "enabledTabIdentifiers"
static let maxSelectableTabs = 4
private static let coreIDs: [String] = ["home", "console", "scripts", "profiles", "deviceinfo", "tools"]
static var allowedIDs: [String] {
var ids = coreIDs
if FeatureFlags.showBetaTabs {
ids.append("processes")
ids.append("devicelibrary")
if FeatureFlags.isLocationSpoofingEnabled {
ids.append("location")
}
}
return ids
}
static let defaultIDs: [String] = ["home", "console", "scripts", "profiles"]
static let defaultRawValue = serialize(defaultIDs)
static func sanitize(raw: String) -> [String] {
let ids = raw
.split(separator: ",")
.map { String($0).trimmingCharacters(in: .whitespacesAndNewlines) }
return sanitize(ids: ids)
}
static func sanitize(ids: [String]) -> [String] {
var result: [String] = []
for id in ids {
guard allowedIDs.contains(id) else { continue }
if !result.contains(id) {
result.append(id)
}
if result.count == maxSelectableTabs {
break
}
}
if result.isEmpty {
result = defaultIDs
}
return result
}
static func serialize(_ ids: [String]) -> String {
sanitize(ids: ids).joined(separator: ",")
}
}