mirror of
https://github.com/k1tbyte/Wand-Enhancer.git
synced 2026-08-29 05:01:53 +00:00
a0b3968d33
Reorganize the panel around product capabilities and integrate the remote i18n feature from origin/master into the new structure. - Restructure src into capability features (app, trainer, library, remote-session, appearance, shared); move the bridge to bridge/src. - Add lingui-based UI localization and wrap remaining user-facing strings (Trans / msg macros); fix the 'END В·' mojibake. - Port WeMod cheat-metadata i18n: capture the access token from the snapshot's renderer in the bridge and fetch localized trainer_meta in remote-session.i18n; guarantee snapshot sync on token failure. - Wire vitest to the app's lingui/preact pipeline (mergeConfig).
65 lines
1.2 KiB
TypeScript
Vendored
65 lines
1.2 KiB
TypeScript
Vendored
function isRecord(value) {
|
|
return typeof value === 'object' && value !== null;
|
|
}
|
|
|
|
function safeString(value, fallback = '') {
|
|
return typeof value === 'string' && value.length ? value : fallback;
|
|
}
|
|
|
|
function firstString(...values) {
|
|
for (const value of values) {
|
|
if (typeof value !== 'string') {
|
|
continue;
|
|
}
|
|
|
|
const trimmed = value.trim();
|
|
if (trimmed.length > 0) {
|
|
return trimmed;
|
|
}
|
|
}
|
|
|
|
return '';
|
|
}
|
|
|
|
function cloneValue(value) {
|
|
if (Array.isArray(value)) {
|
|
return value.map(cloneValue);
|
|
}
|
|
|
|
if (!isRecord(value)) {
|
|
return value;
|
|
}
|
|
|
|
const result = {};
|
|
for (const [key, entry] of Object.entries(value)) {
|
|
result[key] = cloneValue(entry);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
function isValidPort(value) {
|
|
return Number.isFinite(value) && value > 0 && value < 65536;
|
|
}
|
|
|
|
function toStringId(value) {
|
|
if (typeof value === 'string' && value.trim()) {
|
|
return value.trim();
|
|
}
|
|
|
|
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
return String(value);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
module.exports = {
|
|
cloneValue,
|
|
firstString,
|
|
isRecord,
|
|
isValidPort,
|
|
safeString,
|
|
toStringId,
|
|
};
|