Bun, Inferno->React migration (#22529)

Re-creation of https://github.com/Aurorastation/Aurora.3/pull/21046 to
skip merge conflict hell. Brings us modern TGUI.

**ALTERNATE TITLE: TGUI HELLSCAPE PR
ABANDON ALL HOPE YE WHO ENTER HERE**

- [x] Migrate build tools (javascript -> typescript, bun for package
management).
- [x] Upgrade all TGUI dependencies and associated root files to
TG-congruent versions (axios, babel, dompurify, eslint, highlight,
marked, prettier, sass, source-map, stacktrace-parser, typescript).
- [x] InfernoJS -> React migrations
- [x] React cleanup and polish (migrate all remaining .js files to
appropriate .ts or .tsx filetype, all remaining hooks, linting, error
corrections, etc.)
- [ ] Test all remaining TGUI interfaces
This commit is contained in:
Batrachophreno
2026-06-05 09:55:22 -04:00
committed by GitHub
parent a52729c105
commit 0d92359da7
930 changed files with 23130 additions and 50520 deletions
+15 -7
View File
@@ -10,7 +10,7 @@
* * timeout - The timeout of the alert, after which the modal will close and qdel itself. Set to zero for no timeout.
* * autofocus - The bool that controls if this alert should grab window focus.
*/
/proc/tgui_alert(mob/user, message = "", title, list/buttons = list("Ok"), timeout = 0, autofocus = TRUE)
/proc/tgui_alert(mob/user, message = "", title, list/buttons = list("Ok"), timeout = 0, autofocus = TRUE, ui_state = GLOB.always_state)
if (!user)
user = usr
if (!istype(user))
@@ -18,7 +18,11 @@
var/client/client = user
user = client.mob
else
return
return null
if(isnull(user.client))
return null
// A gentle nudge - you should not be using TGUI alert for anything other than a simple message.
if(length(buttons) > 3)
log_tgui(user, "Error: TGUI Alert initiated with too many buttons. Use a list.", "TguiAlert")
@@ -29,7 +33,7 @@
return alert(user, message, title, buttons[1], buttons[2])
if(length(buttons) == 3)
return alert(user, message, title, buttons[1], buttons[2], buttons[3])
var/datum/tgui_alert/alert = new(user, message, title, buttons, timeout, autofocus)
var/datum/tgui_alert/alert = new(user, message, title, buttons, timeout, autofocus, ui_state)
alert.ui_interact(user)
alert.wait()
if (alert)
@@ -59,19 +63,23 @@
var/autofocus
/// Boolean field describing if the tgui_alert was closed by the user.
var/closed
/// The TGUI UI state that will be returned in ui_state(). Default: always_state
var/datum/ui_state/state
/datum/tgui_alert/New(mob/user, message, title, list/buttons, timeout, autofocus)
/datum/tgui_alert/New(mob/user, message, title, list/buttons, timeout, autofocus, ui_state)
src.autofocus = autofocus
src.buttons = buttons.Copy()
src.message = message
src.title = title
src.state = ui_state
if (timeout)
src.timeout = timeout
start_time = world.time
QDEL_IN(src, timeout)
/datum/tgui_alert/Destroy(force, ...)
/datum/tgui_alert/Destroy(force)
SStgui.close_uis(src)
state = null
buttons?.Cut()
return ..()
@@ -94,7 +102,7 @@
closed = TRUE
/datum/tgui_alert/ui_state(mob/user)
return GLOB.always_state
return state
/datum/tgui_alert/ui_static_data(mob/user)
var/list/data = list()
@@ -112,7 +120,7 @@
data["timeout"] = CLAMP01((timeout - (world.time - start_time) - 1 SECONDS) / (timeout - 1 SECONDS))
return data
/datum/tgui_alert/ui_act(action, list/params)
/datum/tgui_alert/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if (.)
return
+139
View File
@@ -0,0 +1,139 @@
/**
* ### tgui_input_checkbox
* Opens a window with a list of checkboxes and returns a list of selected choices.
*
* user - The mob to display the window to
* message - The message inside the window
* title - The title of the window
* list/items - The list of items to display
* min_checked - The minimum number of checkboxes that must be checked (defaults to 1)
* max_checked - The maximum number of checkboxes that can be checked (optional)
* timeout - The timeout for the input (optional)
*/
/proc/tgui_input_checkboxes(mob/user, message, title = "Select", list/items, min_checked = 1, max_checked = 50, timeout = 0, ui_state = GLOB.always_state)
if (!user)
user = usr
if(!length(items))
return null
if (!istype(user))
if (istype(user, /client))
var/client/client = user
user = client.mob
else
return null
if(isnull(user.client))
return null
if(!user.client.prefs.tgui_inputs)
return input(user, message, title) as null|anything in items
var/datum/tgui_checkbox_input/input = new(user, message, title, items, min_checked, max_checked, timeout, ui_state)
input.ui_interact(user)
input.wait()
if (input)
. = input.choices
qdel(input)
/// Window for tgui_input_checkboxes
/datum/tgui_checkbox_input
/// Title of the window
var/title
/// Message to display
var/message
/// List of items to display
var/list/items
/// List of selected items
var/list/choices
/// Time when the input was created
var/start_time
/// Timeout for the input
var/timeout
/// Whether the input was closed
var/closed
/// Minimum number of checkboxes that must be checked
var/min_checked
/// Maximum number of checkboxes that can be checked
var/max_checked
/// The TGUI UI state that will be returned in ui_state(). Default: always_state
var/datum/ui_state/state
/datum/tgui_checkbox_input/New(mob/user, message, title, list/items, min_checked, max_checked, timeout, ui_state)
src.title = title
src.message = message
src.items = items.Copy()
src.min_checked = min_checked
src.max_checked = max_checked
src.state = ui_state
if (timeout)
src.timeout = timeout
start_time = world.time
QDEL_IN(src, timeout)
/datum/tgui_checkbox_input/Destroy(force)
SStgui.close_uis(src)
state = null
items?.Cut()
return ..()
/datum/tgui_checkbox_input/proc/wait()
while (!closed && !QDELETED(src))
stoplag(1)
/datum/tgui_checkbox_input/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "CheckboxInput")
ui.open()
/datum/tgui_checkbox_input/ui_close(mob/user)
. = ..()
closed = TRUE
/datum/tgui_checkbox_input/ui_state(mob/user)
return state
/datum/tgui_checkbox_input/ui_data(mob/user)
var/list/data = list()
if(timeout)
data["timeout"] = CLAMP01((timeout - (world.time - start_time) - 1 SECONDS) / (timeout - 1 SECONDS))
return data
/datum/tgui_checkbox_input/ui_static_data(mob/user)
var/list/data = list()
data["items"] = items
data["min_checked"] = min_checked
data["max_checked"] = max_checked
data["large_buttons"] = user.client.prefs.tgui_buttons_large
data["message"] = message
data["swapped_buttons"] = user.client.prefs.tgui_inputs_swapped
data["title"] = title
return data
/datum/tgui_checkbox_input/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if (.)
return
switch(action)
if("submit")
var/list/selections = params["entry"]
if(length(selections) >= min_checked && length(selections) <= max_checked)
set_choices(selections)
closed = TRUE
SStgui.close_uis(src)
return TRUE
if("cancel")
closed = TRUE
SStgui.close_uis(src)
return TRUE
return FALSE
/datum/tgui_checkbox_input/proc/set_choices(list/selections)
src.choices = selections.Copy()
+126
View File
@@ -0,0 +1,126 @@
/**
* Creates a TGUI window with a key input. Returns the user's response as a full key with modifiers, eg ShiftK.
*
* This proc should be used to create windows for key entry that the caller will wait for a response from.
* If tgui fancy chat is turned off: Will return a normal input.
*
* Arguments:
* * user - The user to show the number input to.
* * message - The content of the number input, shown in the body of the TGUI window.
* * title - The title of the number input modal, shown on the top of the TGUI window.
* * default - The default (or current) key, shown as a placeholder.
*/
/proc/tgui_input_keycombo(mob/user = usr, message, title = "Key Input", default = 0, timeout = 0, ui_state = GLOB.always_state)
if (!istype(user))
if (istype(user, /client))
var/client/client = user
user = client.mob
else
return null
if (isnull(user.client))
return null
// Client does NOT have tgui_input on: Returns regular input
if(!user.client.prefs.tgui_inputs)
var/input_key = input(user, message, title + "(Modifiers are TGUI only, sorry!)", default) as null|text
return input_key[1]
var/datum/tgui_input_keycombo/key_input = new(user, message, title, default, timeout, ui_state)
key_input.ui_interact(user)
key_input.wait()
if (key_input)
. = key_input.entry
qdel(key_input)
/**
* # tgui_input_keycombo
*
* Datum used for instantiating and using a TGUI-controlled key input that prompts the user with
* a message and listens for key presses.
*/
/datum/tgui_input_keycombo
/// Boolean field describing if the tgui_input_number was closed by the user.
var/closed
/// The default (or current) value, shown as a default. Users can press reset with this.
var/default
/// The entry that the user has return_typed in.
var/entry
/// The prompt's body, if any, of the TGUI window.
var/message
/// The time at which the number input was created, for displaying timeout progress.
var/start_time
/// The lifespan of the number input, after which the window will close and delete itself.
var/timeout
/// The title of the TGUI window
var/title
/// The TGUI UI state that will be returned in ui_state(). Default: always_state
var/datum/ui_state/state
/datum/tgui_input_keycombo/New(mob/user, message, title, default, timeout, ui_state)
src.default = default
src.message = message
src.title = title
src.state = ui_state
if (timeout)
src.timeout = timeout
start_time = world.time
QDEL_IN(src, timeout)
/datum/tgui_input_keycombo/Destroy(force)
SStgui.close_uis(src)
state = null
return ..()
/**
* Waits for a user's response to the tgui_input_keycombo's prompt before returning. Returns early if
* the window was closed by the user.
*/
/datum/tgui_input_keycombo/proc/wait()
while (!entry && !closed && !QDELETED(src))
stoplag(1)
/datum/tgui_input_keycombo/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "KeyComboModal")
ui.open()
/datum/tgui_input_keycombo/ui_close(mob/user)
. = ..()
closed = TRUE
/datum/tgui_input_keycombo/ui_state(mob/user)
return state
/datum/tgui_input_keycombo/ui_static_data(mob/user)
var/list/data = list()
data["init_value"] = default // Default is a reserved keyword
data["large_buttons"] = user.client.prefs.tgui_buttons_large
data["message"] = message
data["swapped_buttons"] = user.client.prefs.tgui_inputs_swapped
data["title"] = title
return data
/datum/tgui_input_keycombo/ui_data(mob/user)
var/list/data = list()
if(timeout)
data["timeout"] = CLAMP01((timeout - (world.time - start_time) - 1 SECONDS) / (timeout - 1 SECONDS))
return data
/datum/tgui_input_keycombo/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if (.)
return
switch(action)
if("submit")
set_entry(params["entry"])
closed = TRUE
SStgui.close_uis(src)
return TRUE
if("cancel")
closed = TRUE
SStgui.close_uis(src)
return TRUE
/datum/tgui_input_keycombo/proc/set_entry(entry)
src.entry = entry
+26 -10
View File
@@ -10,21 +10,28 @@
* * default - If an option is already preselected on the UI. Current values, etc.
* * timeout - The timeout of the input box, after which the menu will close and qdel itself. Set to zero for no timeout.
*/
/proc/tgui_input_list(mob/user, message, title = "Select", list/items, default, timeout = 0)
/proc/tgui_input_list(mob/user, message, title = "Select", list/items, default, timeout = 0, ui_state = GLOB.always_state)
if (!user)
user = usr
if(!length(items))
return
return null
if (!istype(user))
if (istype(user, /client))
var/client/client = user
user = client.mob
else
return
return null
if(isnull(user.client))
return null
/// Client does NOT have tgui_input on: Returns regular input
if(!user.client.prefs.tgui_inputs)
return input(user, message, title, default) as null|anything in items
var/datum/tgui_list_input/input = new(user, message, title, items, default, timeout)
var/datum/tgui_list_input/input = new(user, message, title, items, default, timeout, ui_state)
if(input.invalid)
qdel(input)
return
input.ui_interact(user)
input.wait()
if (input)
@@ -56,13 +63,18 @@
var/timeout
/// Boolean field describing if the tgui_list_input was closed by the user.
var/closed
/// The TGUI UI state that will be returned in ui_state(). Default: always_state
var/datum/ui_state/state
/// Whether the tgui list input is invalid or not (i.e. due to all list entries being null)
var/invalid = FALSE
/datum/tgui_list_input/New(mob/user, message, title, list/items, default, timeout)
/datum/tgui_list_input/New(mob/user, message, title, list/items, default, timeout, ui_state)
src.title = title
src.message = message
src.items = list()
src.items_map = list()
src.default = default
src.state = ui_state
var/list/repeat_items = list()
// Gets rid of illegal characters
var/static/regex/whitelistedWords = regex(@{"([^\u0020-\u8000]+)"})
@@ -74,13 +86,17 @@
string_key = avoid_assoc_duplicate_keys(string_key, repeat_items)
src.items += string_key
src.items_map[string_key] = i
if(length(src.items) == 0)
invalid = TRUE
if (timeout)
src.timeout = timeout
start_time = world.time
QDEL_IN(src, timeout)
/datum/tgui_list_input/Destroy(force, ...)
/datum/tgui_list_input/Destroy(force)
SStgui.close_uis(src)
state = null
items?.Cut()
items_map?.Cut()
return ..()
@@ -96,7 +112,7 @@
/datum/tgui_list_input/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "ListInputModal")
ui = new(user, src, "ListInputWindow")
ui.open()
/datum/tgui_list_input/ui_close(mob/user)
@@ -104,15 +120,15 @@
closed = TRUE
/datum/tgui_list_input/ui_state(mob/user)
return GLOB.always_state
return state
/datum/tgui_list_input/ui_static_data(mob/user)
var/list/data = list()
data["init_value"] = default || items[1]
data["items"] = items
data["large_buttons"] = user.client.prefs.tgui_buttons_large
data["swapped_buttons"] = user.client.prefs.tgui_inputs_swapped
data["message"] = message
data["swapped_buttons"] = user.client.prefs.tgui_inputs_swapped
data["title"] = title
return data
@@ -122,7 +138,7 @@
data["timeout"] = clamp((timeout - (world.time - start_time) - 1 SECONDS) / (timeout - 1 SECONDS), 0, 1)
return data
/datum/tgui_list_input/ui_act(action, list/params)
/datum/tgui_list_input/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if (.)
return
+11 -7
View File
@@ -15,7 +15,7 @@
* * timeout - The timeout of the number input, after which the modal will close and qdel itself. Set to zero for no timeout.
* * round_value - whether the inputted number is rounded down into an integer.
*/
/proc/tgui_input_number(mob/user, message, title = "Number Input", default = 0, max_value = 10000, min_value = 0, timeout = 0, round_value = TRUE)
/proc/tgui_input_number(mob/user, message, title = "Number Input", default = 0, max_value = 10000, min_value = 0, timeout = 0, round_value = TRUE, ui_state = GLOB.always_state)
if (!user)
user = usr
if (!istype(user))
@@ -30,7 +30,7 @@
if(!user.client.prefs.tgui_inputs)
var/input_number = input(user, message, title, default) as null|num
return clamp(round_value ? round(input_number) : input_number, min_value, max_value)
var/datum/tgui_input_number/number_input = new(user, message, title, default, max_value, min_value, timeout, round_value)
var/datum/tgui_input_number/number_input = new(user, message, title, default, max_value, min_value, timeout, round_value, ui_state)
number_input.ui_interact(user)
number_input.wait()
if (number_input)
@@ -64,14 +64,17 @@
var/timeout
/// The title of the TGUI window
var/title
/// The TGUI UI state that will be returned in ui_state(). Default: always_state
var/datum/ui_state/state
/datum/tgui_input_number/New(mob/user, message, title, default, max_value, min_value, timeout, round_value)
/datum/tgui_input_number/New(mob/user, message, title, default, max_value, min_value, timeout, round_value, ui_state)
src.default = default
src.max_value = max_value
src.message = message
src.min_value = min_value
src.title = title
src.round_value = round_value
src.state = ui_state
if (timeout)
src.timeout = timeout
start_time = world.time
@@ -87,8 +90,9 @@
if(default > max_value)
CRASH("Default value is greater than max value.")
/datum/tgui_input_number/Destroy(force, ...)
/datum/tgui_input_number/Destroy(force)
SStgui.close_uis(src)
state = null
return ..()
/**
@@ -110,7 +114,7 @@
closed = TRUE
/datum/tgui_input_number/ui_state(mob/user)
return GLOB.always_state
return state
/datum/tgui_input_number/ui_static_data(mob/user)
if (!user.client)
@@ -119,10 +123,10 @@
var/list/data = list()
data["init_value"] = default // Default is a reserved keyword
data["large_buttons"] = user.client.prefs.tgui_buttons_large
data["swapped_buttons"] = user.client.prefs.tgui_inputs_swapped
data["max_value"] = max_value
data["message"] = message
data["min_value"] = min_value
data["swapped_buttons"] = user.client.prefs.tgui_inputs_swapped
data["title"] = title
data["round_value"] = round_value
return data
@@ -133,7 +137,7 @@
data["timeout"] = CLAMP01((timeout - (world.time - start_time) - 1 SECONDS) / (timeout - 1 SECONDS))
return data
/datum/tgui_input_number/ui_act(action, list/params)
/datum/tgui_input_number/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if (.)
return
@@ -48,7 +48,6 @@
sleep(3 SECONDS)
window.initialize(
strict_mode = TRUE,
fancy = TRUE,
inline_css = file("tgui/public/tgui-say.bundle.css"),
inline_js = file("tgui/public/tgui-say.bundle.js"),
);
+10 -6
View File
@@ -10,12 +10,12 @@
* * message - The content of the text input, shown in the body of the TGUI window.
* * title - The title of the text input modal, shown on the top of the TGUI window.
* * default - The default (or current) value, shown as a placeholder.
* * max_length - Specifies a max length for input. MAX_MESSAGE_LEN is default (1024)
* * max_length - Specifies a max length for input. MAX_MESSAGE_LEN is default (4096)
* * multiline - Bool that determines if the input box is much larger. Good for large messages, laws, etc.
* * encode - Toggling this determines if input is filtered via html_encode. Setting this to FALSE gives raw input.
* * timeout - The timeout of the textbox, after which the modal will close and qdel itself. Set to zero for no timeout.
*/
/proc/tgui_input_text(mob/user, message = "", title = "Text Input", default, max_length = MAX_MESSAGE_LEN, multiline = FALSE, encode = TRUE, timeout = 0)
/proc/tgui_input_text(mob/user, message = "", title = "Text Input", default, max_length = MAX_MESSAGE_LEN, multiline = FALSE, encode = TRUE, timeout = 0, ui_state = GLOB.always_state)
if (!user)
user = usr
if (!istype(user))
@@ -39,7 +39,7 @@
return input(user, message, title, default) as message|null
else
return input(user, message, title, default) as text|null
var/datum/tgui_input_text/text_input = new(user, message, title, default, max_length, multiline, encode, timeout)
var/datum/tgui_input_text/text_input = new(user, message, title, default, max_length, multiline, encode, timeout, ui_state)
text_input.ui_interact(user)
text_input.wait()
if (text_input)
@@ -73,21 +73,25 @@
var/timeout
/// The title of the TGUI window
var/title
/// The TGUI UI state that will be returned in ui_state(). Default: always_state
var/datum/ui_state/state
/datum/tgui_input_text/New(mob/user, message, title, default, max_length, multiline, encode, timeout)
/datum/tgui_input_text/New(mob/user, message, title, default, max_length, multiline, encode, timeout, ui_state)
src.default = default
src.encode = encode
src.max_length = max_length
src.message = message
src.multiline = multiline
src.title = title
src.state = ui_state
if (timeout)
src.timeout = timeout
start_time = world.time
QDEL_IN(src, timeout)
/datum/tgui_input_text/Destroy(force, ...)
/datum/tgui_input_text/Destroy(force)
SStgui.close_uis(src)
state = null
return ..()
/**
@@ -131,7 +135,7 @@
data["timeout"] = CLAMP01((timeout - (world.time - start_time) - 1 SECONDS) / (timeout - 1 SECONDS))
return data
/datum/tgui_input_text/ui_act(action, list/params)
/datum/tgui_input_text/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if (.)
return