Skip to content

Commit

Permalink
dir fix?
Browse files Browse the repository at this point in the history
  • Loading branch information
jlsnow301 committed Jun 30, 2024
1 parent cc2bb84 commit b8a64d4
Show file tree
Hide file tree
Showing 43 changed files with 427 additions and 463 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

2 changes: 1 addition & 1 deletion dist/assets.d.ts → dist/common/assets.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Middleware } from './common/redux';
import { Middleware } from './redux';

export declare const resolveAsset: (name: string) => string;
export declare const assetMiddleware: Middleware;
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions dist/common/events.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,27 @@ export declare class EventEmitter {
emit(name: string, ...params: any[]): void;
clear(): void;
}
export declare const globalEvents: EventEmitter;
export declare const setupGlobalEvents: (options?: {
ignoreWindowFocus?: boolean;
}) => void;
export declare function canStealFocus(node: HTMLElement): boolean;
export declare function addScrollableNode(node: HTMLElement): void;
export declare function removeScrollableNode(node: HTMLElement): void;
export declare class KeyEvent {
event: KeyboardEvent;
type: 'keydown' | 'keyup';
code: number;
ctrl: boolean;
shift: boolean;
alt: boolean;
repeat: boolean;
_str?: string;
constructor(e: KeyboardEvent, type: 'keydown' | 'keyup', repeat?: boolean);
hasModifierKeys(): boolean;
isModifierKey(): boolean;
isDown(): boolean;
isUp(): boolean;
toString(): string;
}
export {};
157 changes: 136 additions & 21 deletions dist/common/events.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,147 @@
var h = Object.defineProperty;
var c = (e, s, t) => s in e ? h(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t;
var n = (e, s, t) => c(e, typeof s != "symbol" ? s + "" : s, t);
class u {
var _ = Object.defineProperty;
var v = (t, e, s) => e in t ? _(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
var i = (t, e, s) => v(t, typeof e != "symbol" ? e + "" : e, s);
import { KEY_CTRL as F, KEY_SHIFT as L, KEY_ALT as b, KEY_F1 as K, KEY_F12 as S } from "./keycodes.js";
class C {
constructor() {
n(this, "listeners");
i(this, "listeners");
this.listeners = {};
}
on(s, t) {
this.listeners[s] = this.listeners[s] || [], this.listeners[s].push(t);
}
off(s, t) {
const r = this.listeners[s];
if (!r)
throw new Error(`There is no listeners for "${s}"`);
this.listeners[s] = r.filter((i) => i !== t);
}
emit(s, ...t) {
const r = this.listeners[s];
if (r)
for (let i = 0, l = r.length; i < l; i += 1) {
const o = r[i];
o(...t);
on(e, s) {
this.listeners[e] = this.listeners[e] || [], this.listeners[e].push(s);
}
off(e, s) {
const n = this.listeners[e];
if (!n)
throw new Error(`There is no listeners for "${e}"`);
this.listeners[e] = n.filter((l) => l !== s);
}
emit(e, ...s) {
const n = this.listeners[e];
if (n)
for (let l = 0, k = n.length; l < k; l += 1) {
const g = n[l];
g(...s);
}
}
clear() {
this.listeners = {};
}
}
const o = new C();
let m = !1;
const W = (t = {}) => {
m = !!t.ignoreWindowFocus;
};
let d, f = !0;
function u(t, e) {
if (m) {
f = !0;
return;
}
if (d && (clearTimeout(d), d = null), e) {
d = setTimeout(() => u(t));
return;
}
f !== t && (f = t, o.emit(t ? "window-focus" : "window-blur"), o.emit("window-focus-change", t));
}
let r = null;
function E(t) {
const e = String(t.tagName).toLowerCase();
return e === "input" || e === "textarea";
}
function T(t) {
a(), r = t, r.addEventListener("blur", a);
}
function a() {
r && (r.removeEventListener("blur", a), r = null);
}
let w = null, c = null;
const h = [];
function A(t) {
h.push(t);
}
function B(t) {
const e = h.indexOf(t);
e >= 0 && h.splice(e, 1);
}
function N(t) {
if (r || !f)
return;
const e = document.body;
for (; t && t !== e; ) {
if (h.includes(t)) {
if (t.contains(w))
return;
w = t, t.focus();
return;
}
t = t.parentElement;
}
}
window.addEventListener("mousemove", (t) => {
const e = t.target;
e !== c && (c = e, N(e));
});
window.addEventListener("focusin", (t) => {
c = null, w = t.target, u(!0), E(t.target) && T(t.target);
});
window.addEventListener("focusout", () => {
c = null, u(!1, !0);
});
window.addEventListener("blur", () => {
c = null, u(!1, !0);
});
window.addEventListener("beforeunload", () => {
u(!1);
});
const y = {};
class p {
constructor(e, s, n) {
i(this, "event");
i(this, "type");
i(this, "code");
i(this, "ctrl");
i(this, "shift");
i(this, "alt");
i(this, "repeat");
i(this, "_str");
this.event = e, this.type = s, this.code = e.keyCode, this.ctrl = e.ctrlKey, this.shift = e.shiftKey, this.alt = e.altKey, this.repeat = !!n;
}
hasModifierKeys() {
return this.ctrl || this.alt || this.shift;
}
isModifierKey() {
return this.code === F || this.code === L || this.code === b;
}
isDown() {
return this.type === "keydown";
}
isUp() {
return this.type === "keyup";
}
toString() {
return this._str ? this._str : (this._str = "", this.ctrl && (this._str += "Ctrl+"), this.alt && (this._str += "Alt+"), this.shift && (this._str += "Shift+"), this.code >= 48 && this.code <= 90 ? this._str += String.fromCharCode(this.code) : this.code >= K && this.code <= S ? this._str += "F" + (this.code - 111) : this._str += "[" + this.code + "]", this._str);
}
}
document.addEventListener("keydown", (t) => {
if (E(t.target))
return;
const e = t.keyCode, s = new p(t, "keydown", y[e]);
o.emit("keydown", s), o.emit("key", s), y[e] = !0;
});
document.addEventListener("keyup", (t) => {
if (E(t.target))
return;
const e = t.keyCode, s = new p(t, "keyup");
o.emit("keyup", s), o.emit("key", s), y[e] = !1;
});
export {
u as EventEmitter
C as EventEmitter,
p as KeyEvent,
A as addScrollableNode,
E as canStealFocus,
o as globalEvents,
B as removeScrollableNode,
W as setupGlobalEvents
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion dist/hotkeys.js → dist/common/hotkeys.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { KEY_ESCAPE as K, KEY_ENTER as E, KEY_SPACE as p, KEY_TAB as h, KEY_CTRL as d, KEY_SHIFT as g, KEY_UP as S, KEY_DOWN as Y, KEY_LEFT as _, KEY_RIGHT as b, KEY_F5 as B } from "./common/keycodes.js";
import { globalEvents as l } from "./events.js";
import { KEY_ESCAPE as K, KEY_ENTER as E, KEY_SPACE as p, KEY_TAB as h, KEY_CTRL as d, KEY_SHIFT as g, KEY_UP as S, KEY_DOWN as Y, KEY_LEFT as _, KEY_RIGHT as b, KEY_F5 as B } from "./keycodes.js";
const m = {}, c = [
K,
E,
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion dist/common/keys.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @url https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values
* @usage
* ```ts
* import { KEY } from 'tgui/common/keys';
* import { KEY } from 'tgui/keys';
*
* if (event.key === KEY.Enter) {
* // do something
Expand Down
2 changes: 1 addition & 1 deletion dist/components/BodyZoneSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var _ = (e, t, s) => t in e ? g(e, t, { enumerable: !0, configurable: !0, writab
var l = (e, t, s) => _(e, typeof t != "symbol" ? t + "" : t, s);
import { jsxs as d, jsx as h } from "react/jsx-runtime";
import { Component as v, createRef as $ } from "react";
import { resolveAsset as p } from "../assets.js";
import { resolveAsset as p } from "../common/assets.js";
import { Image as f } from "./Image.js";
var b = /* @__PURE__ */ ((e) => (e.Chest = "chest", e.Eyes = "eyes", e.Groin = "groin", e.Head = "head", e.LeftArm = "l_arm", e.LeftLeg = "l_leg", e.Mouth = "mouth", e.RightArm = "r_arm", e.RightLeg = "r_leg", e))(b || {});
const C = (e, t) => {
Expand Down
8 changes: 4 additions & 4 deletions dist/components/Box.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createElement as y } from "react";
import { classes as b } from "../common/react.js";
import { CSS_COLORS as u } from "../constants.js";
import { CSS_COLORS as b } from "../common/constants.js";
import { classes as u } from "../common/react.js";
function p(o) {
if (typeof o == "string")
return o.endsWith("px") ? parseFloat(o) / 12 + "rem" : o;
Expand All @@ -17,7 +17,7 @@ function x(o) {
return !a(o);
}
function a(o) {
return typeof o == "string" && u.includes(o);
return typeof o == "string" && b.includes(o);
}
const m = (o) => (t, i) => {
(typeof i == "number" || typeof i == "string") && (t[o] = i);
Expand Down Expand Up @@ -108,7 +108,7 @@ function S(o) {
}
function d(o) {
const t = o.textColor || o.color, i = o.backgroundColor;
return b([
return u([
a(t) && "color-" + t,
a(i) && "color-bg-" + i
]);
Expand Down
8 changes: 4 additions & 4 deletions dist/components/ByondUi.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { jsx as s } from "react/jsx-runtime";
import { Component as a, createRef as c } from "react";
import { shallowDiffers as r } from "../common/react.js";
import { debounce as a } from "../common/timer.js";
import { Component as c, createRef as m } from "react";
import { debounce as m } from "../common/timer.js";
import { computeBoxProps as l } from "./Box.js";
const o = [];
function h(t) {
Expand Down Expand Up @@ -37,10 +37,10 @@ function u(t) {
]
};
}
class U extends c {
class U extends a {
constructor(n) {
var e;
super(n), this.containerRef = m(), this.byondUiElement = h((e = n.params) == null ? void 0 : e.id), this.handleResize = a(() => {
super(n), this.containerRef = c(), this.byondUiElement = h((e = n.params) == null ? void 0 : e.id), this.handleResize = m(() => {
this.forceUpdate();
}, 100);
}
Expand Down
4 changes: 2 additions & 2 deletions dist/components/DmIcon.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { jsx as $ } from "react/jsx-runtime";
import { useState as R, useEffect as d } from "react";
import { resolveAsset as j } from "../assets.js";
import { fetchRetry as v } from "../http.js";
import { resolveAsset as j } from "../common/assets.js";
import { fetchRetry as v } from "../common/http.js";
import { Image as x } from "./Image.js";
let e;
function b(n) {
Expand Down
2 changes: 1 addition & 1 deletion dist/components/KeyListener.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component } from 'react';
import { KeyEvent } from '../events';
import { KeyEvent } from '../common/events';

type KeyListenerProps = Partial<{
onKey: (key: KeyEvent) => void;
Expand Down
2 changes: 1 addition & 1 deletion dist/components/KeyListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var t = Object.defineProperty;
var e = (s, o, p) => o in s ? t(s, o, { enumerable: !0, configurable: !0, writable: !0, value: p }) : s[o] = p;
var i = (s, o, p) => e(s, typeof o != "symbol" ? o + "" : o, p);
import { Component as r } from "react";
import { listenForKeyEvents as h } from "../hotkeys.js";
import { listenForKeyEvents as h } from "../common/hotkeys.js";
class d extends r {
constructor(p) {
super(p);
Expand Down
12 changes: 6 additions & 6 deletions dist/components/ProgressBar.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { jsxs as g, jsx as n } from "react/jsx-runtime";
import { keyOfMatchingRange as v, toFixed as y, scale as N, clamp01 as _ } from "../common/math.js";
import { CSS_COLORS as v } from "../common/constants.js";
import { keyOfMatchingRange as y, toFixed as N, scale as _, clamp01 as B } from "../common/math.js";
import { classes as m } from "../common/react.js";
import { CSS_COLORS as B } from "../constants.js";
import { s as o } from "../ProgressBar.module-BkAFfFy0.js";
import { computeBoxProps as S, computeBoxClassName as O } from "./Box.js";
function w(d) {
Expand All @@ -14,22 +14,22 @@ function w(d) {
ranges: h = {},
children: l,
...t
} = d, a = N(r, u, p), x = l !== void 0, s = C || v(r, h) || "default", e = S(t), c = [
} = d, a = _(r, u, p), x = l !== void 0, s = C || y(r, h) || "default", e = S(t), c = [
o.progressBar,
f,
O(t)
], i = {
width: _(a) * 100 + "%"
width: B(a) * 100 + "%"
};
return B.includes(s) || s === "default" ? c.push(o["color__" + s]) : (e.style = { ...e.style, borderColor: s }, i.backgroundColor = s), /* @__PURE__ */ g("div", { className: m(c), ...e, children: [
return v.includes(s) || s === "default" ? c.push(o["color__" + s]) : (e.style = { ...e.style, borderColor: s }, i.backgroundColor = s), /* @__PURE__ */ g("div", { className: m(c), ...e, children: [
/* @__PURE__ */ n(
"div",
{
className: m([o.fill, o.fill__animated]),
style: i
}
),
/* @__PURE__ */ n("div", { className: o.content, children: x ? l : y(a * 100) + "%" })
/* @__PURE__ */ n("div", { className: o.content, children: x ? l : N(a * 100) + "%" })
] });
}
export {
Expand Down
10 changes: 5 additions & 5 deletions dist/components/Section.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { jsxs as r, jsx as s } from "react/jsx-runtime";
import { forwardRef as S, useEffect as j } from "react";
import { classes as z, canRender as m } from "../common/react.js";
import { addScrollableNode as B, removeScrollableNode as H } from "../events.js";
import { addScrollableNode as z, removeScrollableNode as B } from "../common/events.js";
import { classes as H, canRender as m } from "../common/react.js";
import { s as t } from "../Section.module-CLVHJ4yA.js";
import { computeBoxClassName as T, computeBoxProps as y } from "./Box.js";
const q = S(
Expand All @@ -21,14 +21,14 @@ const q = S(
} = a, x = m(n) || m(c);
return j(() => {
if (l != null && l.current && !(!i && !e))
return B(l.current), () => {
l != null && l.current && H(l.current);
return z(l.current), () => {
l != null && l.current && B(l.current);
};
}, []), /* @__PURE__ */ r(
"div",
{
id: v || "",
className: z([
className: H([
t.section,
N && t.fill,
b && t.fitted,
Expand Down
2 changes: 1 addition & 1 deletion dist/components/TimeDisplay.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component as r } from "react";
import { formatTime as u } from "../format.js";
import { formatTime as u } from "../common/format.js";
function s(e) {
return typeof e == "number" && Number.isFinite(e) && !Number.isNaN(e);
}
Expand Down
Loading

0 comments on commit b8a64d4

Please sign in to comment.