repo stringclasses 302
values | file_path stringlengths 18 241 | language stringclasses 2
values | file_type stringclasses 4
values | code stringlengths 76 697k | tokens int64 10 271k |
|---|---|---|---|---|---|
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/core/src/client/core.ts | roblox-ts | .ts | import { RunService } from "@rbxts/services";
import { DEFAULT_CONFIG } from "../shared/config";
import { getRemotes } from "../shared/network";
import { ReadonlyDeep } from "../shared/util/data";
import { ClientDispatcher } from "./dispatcher";
import { ClientRegistry } from "./registry";
import { ClientConfig } from ... | 433 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/core/src/client/util.ts | roblox-ts | .ts | import { t } from "@rbxts/t";
import { CommandShortcut, ShortcutContext } from "../shared";
const key = Enum.KeyCode;
const modifierKeys = new Map<Enum.KeyCode, string>([
[key.LeftAlt, "Alt"],
[key.RightAlt, "Alt"],
[key.LeftControl, "Ctrl"],
[key.RightControl, "Ctrl"],
[key.LeftShift, "Shift"],
[key.RightShift,... | 267 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/core/src/server/core.ts | roblox-ts | .ts | import { RunService } from "@rbxts/services";
import { DEFAULT_CONFIG } from "../shared/config";
import { getRemotes } from "../shared/network";
import { ReadonlyDeep } from "../shared/util/data";
import { ServerDispatcher } from "./dispatcher";
import { ServerRegistry } from "./registry";
import { ServerConfig } from ... | 392 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/core/src/server/registry.ts | roblox-ts | .ts | import { Players } from "@rbxts/services";
import {
CenturionLogLevel,
CommandOptions,
GroupOptions,
RegistryPath,
} from "../shared";
import {
BaseCommand,
CommandGroup,
ExecutableCommand,
} from "../shared/core/command";
import { BaseRegistry } from "../shared/core/registry";
import { SyncData } from "../share... | 653 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/core/src/shared/builtin/types/primitives.ts | roblox-ts | .ts | import { t } from "@rbxts/t";
import { CenturionType } from ".";
import { BaseRegistry, TransformResult, TypeBuilder } from "../../core";
const transformToNumber = (text: string) => {
const num = tonumber(text);
if (num === undefined) {
return TransformResult.err<number>(`Invalid number: ${text}`);
}
return Tra... | 366 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/core/src/shared/builtin/types/team.ts | roblox-ts | .ts | import { Teams } from "@rbxts/services";
import { CenturionType } from ".";
import { BaseRegistry, TransformResult, TypeBuilder } from "../../core";
const teamType = TypeBuilder.create<Team>(CenturionType.Team)
.transform((text) => {
const team = Teams.FindFirstChild(text);
if (team === undefined || !classIs(team... | 146 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/core/src/shared/core/registry.ts | roblox-ts | .ts | import { Signal } from "@rbxts/beacon";
import { t } from "@rbxts/t";
import {
ArgumentType,
CommandCallback,
CommandGuard,
CommandOptions,
GroupOptions,
RegisterOptions,
SharedConfig,
} from "../types";
import { ReadonlyDeep } from "../util/data";
import { CenturionLogger } from "../util/log";
import {
BaseCom... | 3,954 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/core/src/shared/network.ts | roblox-ts | .ts | import { RunService } from "@rbxts/services";
import { CommandContextData, CommandOptions, GroupOptions } from "./types";
type NetworkInstances = Pick<
CreatableInstances,
"RemoteEvent" | "RemoteFunction"
>;
function getRemote<T extends keyof NetworkInstances>(
className: T,
name: string,
): NetworkInstances[T] {... | 352 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/app/centurion-app.tsx | roblox-ts | .tsx | import { CenturionClient } from "@rbxts/centurion";
import { splitString } from "@rbxts/centurion/out/shared/util/string";
import { UserInputService } from "@rbxts/services";
import Vide, { derive } from "@rbxts/vide";
import { Suggestions, Terminal } from "../components";
import { Group } from "../components/ui/group"... | 516 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/components/history/history-line.tsx | roblox-ts | .tsx | import { HistoryEntry } from "@rbxts/centurion";
import Vide, { Derivable, derive } from "@rbxts/vide";
import { HISTORY_TEXT_SIZE } from "../../constants/text";
import { px } from "../../hooks/use-px";
import { options } from "../../store";
import { Frame } from "../ui/frame";
import { Group } from "../ui/group";
impo... | 615 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/components/history/history-list.tsx | roblox-ts | .tsx | import { HistoryEntry } from "@rbxts/centurion";
import Vide, {
Derivable,
derive,
effect,
For,
read,
source,
} from "@rbxts/vide";
import { HISTORY_TEXT_SIZE } from "../../constants/text";
import { px } from "../../hooks/use-px";
import { options } from "../../store";
import { HistoryData, HistoryLineData } from... | 454 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/components/suggestions/badge.tsx | roblox-ts | .tsx | import Vide, { Derivable, InstanceAttributes } from "@rbxts/vide";
import { px } from "../../hooks/use-px";
import { options } from "../../store";
import { Frame } from "../ui/frame";
import { Text } from "../ui/text";
interface BadgeProps {
anchor?: Derivable<Vector2>;
size?: Derivable<UDim2>;
position?: Derivable... | 308 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/components/suggestions/main-suggestion.tsx | roblox-ts | .tsx | import Vide, { Derivable, derive, read, source, spring } from "@rbxts/vide";
import {
SUGGESTION_TEXT_SIZE,
SUGGESTION_TITLE_TEXT_SIZE,
} from "../../constants/text";
import { px } from "../../hooks/use-px";
import { mouseOverInterface, options } from "../../store";
import { Suggestion } from "../../types";
import { ... | 1,412 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/components/suggestions/suggestion-list.tsx | roblox-ts | .tsx | import { ArrayUtil } from "@rbxts/centurion/out/shared/util/data";
import Vide, { Derivable, derive, For, read } from "@rbxts/vide";
import { SUGGESTION_TEXT_SIZE } from "../../constants/text";
import { px } from "../../hooks/use-px";
import { mouseOverInterface, options } from "../../store";
import { Suggestion } from... | 602 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/components/suggestions/suggestions.tsx | roblox-ts | .tsx | import { TextService } from "@rbxts/services";
import Vide, {
cleanup,
Derivable,
derive,
read,
source,
spring,
} from "@rbxts/vide";
import { SUGGESTION_TEXT_SIZE } from "../../constants/text";
import { useClient } from "../../hooks/use-client";
import { px } from "../../hooks/use-px";
import { updateText } from... | 651 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/components/terminal/suggestion.ts | roblox-ts | .ts | import {
ArgumentOptions,
BaseRegistry,
CommandOptions,
ListArgumentType,
RegistryPath,
SingleArgumentType,
} from "@rbxts/centurion";
import { ReadonlyDeep } from "@rbxts/centurion/out/shared/util/data";
import { Players } from "@rbxts/services";
import { ArgumentSuggestion, CommandSuggestion } from "../../types... | 1,034 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/components/terminal/terminal-text-field/suggestion.ts | roblox-ts | .ts | import { BaseRegistry } from "@rbxts/centurion";
import {
commandArgIndex,
currentCommandPath,
currentTextPart,
terminalArgIndex,
} from "../../../store";
import { Suggestion } from "../../../types";
import { formatPartsAsPath, getArgumentNames } from "../../../utils/command";
function replaceTextPart(text: string... | 652 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/components/terminal/terminal-text-field/terminal-text-field.tsx | roblox-ts | .tsx | import { UserInputService } from "@rbxts/services";
import Vide, { Derivable, effect, read, source } from "@rbxts/vide";
import { useClient } from "../../../hooks/use-client";
import { useEvent } from "../../../hooks/use-event";
import { px } from "../../../hooks/use-px";
import { updateText, useTextBox } from "../../.... | 1,551 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/components/terminal/terminal.tsx | roblox-ts | .tsx | import { ArgumentOptions, HistoryEntry, RegistryPath } from "@rbxts/centurion";
import { ArrayUtil, ReadonlyDeep } from "@rbxts/centurion/out/shared/util/data";
import { splitString } from "@rbxts/centurion/out/shared/util/string";
import Vide, { Derivable, derive, read, source, spring } from "@rbxts/vide";
import { HI... | 2,018 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/components/ui/frame.tsx | roblox-ts | .tsx | import Vide, {
ActionAttributes,
Derivable,
InferEnumNames,
InstanceAttributes,
} from "@rbxts/vide";
export interface FrameProps<T extends Instance = Frame>
extends ActionAttributes<T> {
size?: Derivable<UDim2>;
position?: Derivable<UDim2>;
anchor?: Derivable<Vector2>;
rotation?: Derivable<number>;
backgrou... | 322 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/components/ui/group.tsx | roblox-ts | .tsx | import Vide, { Derivable } from "@rbxts/vide";
import { FrameProps } from "./frame";
interface GroupProps
extends Omit<FrameProps, "backgroundTransparency" | "backgroundColor"> {
name?: Derivable<string>;
anchor?: Derivable<Vector2>;
position?: Derivable<UDim2>;
size?: Derivable<UDim2>;
rotation?: Derivable<numb... | 263 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/components/ui/layer.tsx | roblox-ts | .tsx | import Vide, { Derivable } from "@rbxts/vide";
import { IS_EDIT } from "../../constants/util";
import { Group } from "./group";
interface LayerProps extends Vide.PropsWithChildren {
name?: Derivable<string>;
visible?: Derivable<boolean>;
displayOrder?: Derivable<number>;
}
export function Layer({ name, visible, di... | 182 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/components/ui/outline.tsx | roblox-ts | .tsx | import Vide, { Derivable, derive, read } from "@rbxts/vide";
import { px } from "../../hooks/use-px";
import { Group } from "./group";
interface OutlineProps {
outlineTransparency?: Derivable<number>;
innerColor?: Derivable<Color3>;
outerColor?: Derivable<Color3>;
innerTransparency?: Derivable<number>;
outerTrans... | 712 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/components/ui/padding.tsx | roblox-ts | .tsx | import Vide, { Derivable } from "@rbxts/vide";
interface Props {
all?: Derivable<UDim>;
left?: Derivable<UDim>;
right?: Derivable<UDim>;
top?: Derivable<UDim>;
bottom?: Derivable<UDim>;
}
export function Padding({ all, left, right, top, bottom }: Props) {
return (
<uipadding
PaddingLeft={left ?? all}
Pa... | 127 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/components/ui/scrolling-frame.tsx | roblox-ts | .tsx | import Vide, { Derivable, InferEnumNames } from "@rbxts/vide";
import { FrameProps } from "./frame";
export interface ScrollingFrameProps extends FrameProps<ScrollingFrame> {
automaticSize?: InferEnumNames<Enum.AutomaticSize>;
automaticCanvasSize?: InferEnumNames<Enum.AutomaticSize>;
scrollingDirection?: InferEnumN... | 401 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/components/ui/text-field.tsx | roblox-ts | .tsx | import Vide, { Derivable, read } from "@rbxts/vide";
import { options } from "../../store";
import { TextProps } from "./text";
interface TextFieldProps extends TextProps<TextBox> {
text?: Derivable<string>;
placeholderText?: Derivable<string>;
placeholderColor?: Derivable<Color3>;
clearTextOnFocus?: Derivable<boo... | 432 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/components/ui/text.tsx | roblox-ts | .tsx | import Vide, { Derivable, InferEnumNames, read } from "@rbxts/vide";
import { px } from "../../hooks/use-px";
import { options } from "../../store";
import { FrameProps } from "./frame";
export interface TextProps<T extends Instance = TextLabel>
extends FrameProps<T> {
font?: Derivable<Font>;
text?: Derivable<strin... | 461 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/constants/options.ts | roblox-ts | .ts | import { GuiService } from "@rbxts/services";
import { DefaultPalette } from "../palette";
import { InterfaceOptions } from "../types";
export const DEFAULT_INTERFACE_OPTIONS: InterfaceOptions = {
anchor: new Vector2(),
position: (px) =>
UDim2.fromOffset(px(16), px(8) + GuiService.GetGuiInset()[0].Y),
size: (px) ... | 219 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/constants/util.ts | roblox-ts | .ts | import { RunService } from "@rbxts/services";
export const IS_EDIT = RunService.IsStudio() && !RunService.IsRunning();
| 29 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/hooks/use-client.ts | roblox-ts | .ts | import { CenturionClient } from "@rbxts/centurion";
import { source } from "@rbxts/vide";
const clientState = source<CenturionClient>();
export function useClient(client?: CenturionClient) {
const value = clientState();
if (value !== undefined) return value;
assert(client !== undefined, "No client has been set.")... | 87 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/hooks/use-event.ts | roblox-ts | .ts | import { cleanup } from "@rbxts/vide";
type EventLike<T extends Callback = Callback> =
| { Connect(callback: T): ConnectionLike }
| { connect(callback: T): ConnectionLike }
| { subscribe(callback: T): ConnectionLike };
type ConnectionLike =
| { Disconnect(): void }
| { disconnect(): void }
| (() => void);
cons... | 431 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/hooks/use-px.ts | roblox-ts | .ts | import { Workspace } from "@rbxts/services";
import { cleanup, source } from "@rbxts/vide";
const BASE_RESOLUTION = new Vector2(1280, 832);
const MIN_SCALE = 0.5;
const DOMINANT_AXIS = 0.5;
const scale = source(1);
/**
* Assigns a call signature to an object.
*
* @param callback The function to assign.
* @param ... | 458 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/hooks/use-text-box.ts | roblox-ts | .ts | import { source } from "@rbxts/vide";
const ref = source<TextBox>();
export function updateText(text: string) {
const textBox = ref();
if (textBox === undefined) return;
textBox.Text = text;
textBox.CursorPosition = text.size() + 1;
}
export function useTextBox(textBox: TextBox) {
ref(textBox);
}
| 73 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/store.ts | roblox-ts | .ts | import { ImmutableRegistryPath } from "@rbxts/centurion";
import { source } from "@rbxts/vide";
import { DEFAULT_INTERFACE_OPTIONS } from "./constants/options";
import { Suggestion } from "./types";
export const visible = source(false);
export const options = source(DEFAULT_INTERFACE_OPTIONS);
export const mouseOverIn... | 160 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/types.ts | roblox-ts | .ts | import { CommandShortcut, HistoryEntry } from "@rbxts/centurion";
import { ScaleFunction } from "./hooks/use-px";
import { InterfacePalette } from "./palette";
export interface InterfaceOptions {
anchor: Vector2;
position: UDim2 | ((px: ScaleFunction) => UDim2);
size: UDim2 | ((px: ScaleFunction) => UDim2);
displa... | 260 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/utils/command.ts | roblox-ts | .ts | import {
BaseRegistry,
ImmutableRegistryPath,
RegistryPath,
} from "@rbxts/centurion";
import { BaseCommand } from "@rbxts/centurion/out/shared/core/command";
import { IS_EDIT } from "../constants/util";
export function formatPartsAsPath(parts: string[]) {
return parts.join("/").lower();
}
export function getVali... | 446 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/packages/ui/src/utils/suggestion.ts | roblox-ts | .ts | import { BaseRegistry } from "@rbxts/centurion";
import {
commandArgIndex,
currentCommandPath,
currentSuggestion,
currentTextPart,
terminalArgIndex,
} from "../store";
import { Suggestion } from "../types";
import { formatPartsAsPath, getArgumentNames } from "./command";
export function getAutocompletedText(
tex... | 781 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/test/src/client/main.client.ts | roblox-ts | .ts | import { Centurion, CenturionLogLevel } from "@rbxts/centurion";
import { CenturionUI } from "@rbxts/centurion-ui";
const client = Centurion.client({
logLevel: CenturionLogLevel.Debug,
});
client.registry.synced.Connect((synced, incoming) => {
print("Synced:", synced, "Incoming:", incoming);
});
client
.start()
... | 116 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/test/src/server/commands/admin.ts | roblox-ts | .ts | import {
Centurion,
CenturionType,
Command,
CommandContext,
Group,
Register,
} from "@rbxts/centurion";
import { addAdmin, removeAdmin } from "../permissions";
@Register({
groups: [
{
name: "admin",
description: "Commands for managing admins",
},
],
})
@Group("admin")
export class AdminCommand {
@Co... | 287 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/test/src/server/commands/damage.ts | roblox-ts | .ts | import {
CenturionType,
Command,
CommandContext,
Register,
} from "@rbxts/centurion";
@Register()
export class DamageCommand {
@Command({
name: "damage",
description: "Damages a player",
arguments: [
{
name: "player",
description: "Player to damage",
type: CenturionType.Player,
},
{
... | 271 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/test/src/server/commands/duration.ts | roblox-ts | .ts | import {
CenturionType,
Command,
CommandContext,
Register,
} from "@rbxts/centurion";
@Register()
export class DurationCommand {
@Command({
name: "duration",
description: "Prints the duration in seconds",
arguments: [
{
name: "duration",
description: "The duration to print",
type: CenturionTy... | 119 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/test/src/server/commands/echo.ts | roblox-ts | .ts | import {
CenturionType,
Command,
CommandContext,
Register,
} from "@rbxts/centurion";
@Register()
export class EchoCommand {
@Command({
name: "echo",
description: "Prints the given text",
arguments: [
{
name: "text",
description: "The text to print",
type: CenturionType.String,
suggestion... | 136 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/test/src/server/commands/info.ts | roblox-ts | .ts | import {
CenturionType,
Command,
CommandContext,
Group,
Register,
} from "@rbxts/centurion";
@Register({
groups: [
{
name: "info",
description: "View info about a user or the server",
},
{
name: "user",
description: "View info about a user",
parent: ["info"],
},
{
name: "server",
d... | 276 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/test/src/server/commands/kick.ts | roblox-ts | .ts | import {
CenturionType,
Command,
CommandContext,
Register,
} from "@rbxts/centurion";
@Register()
export class KickCommand {
@Command({
name: "kick",
description: "Kicks a player",
arguments: [
{
name: "player",
description: "Player to kick",
type: CenturionType.Player,
},
{
name: "... | 171 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/test/src/server/commands/kill.ts | roblox-ts | .ts | import {
CenturionType,
Command,
CommandContext,
Register,
} from "@rbxts/centurion";
import { Players } from "@rbxts/services";
@Register()
export class KillCommand {
@Command({
name: "kill",
description: "Kill players",
arguments: [
{
name: "players",
description: "Players to kill",
type: C... | 225 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/test/src/server/main.server.ts | roblox-ts | .ts | import { Centurion, CenturionLogLevel } from "@rbxts/centurion";
import { Players } from "@rbxts/services";
import { addAdmin, isAdmin, removeAdmin } from "./permissions";
let firstPlayer = true;
Players.PlayerAdded.Connect((player) => {
// Give the first player admin permissions
if (firstPlayer) {
addAdmin(player... | 178 |
paradoxuum/centurion | paradoxuum-centurion-8565c4e/test/src/test/spec.server.ts | roblox-ts | .ts | declare const _G: Map<unknown, unknown>;
_G.set("NOCOLOR", true);
import { runCLI } from "@rbxts/jest";
import { ReplicatedStorage } from "@rbxts/services";
function getTests(root: Instance) {
const folder = root.WaitForChild("TS").WaitForChild("__tests__");
assert(
classIs(folder, "Folder"),
"Could not find _... | 200 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-async-callback/use-async-callback.ts | roblox-ts | .ts | import { useCallback, useRef, useState } from "@rbxts/react";
import { useUnmountEffect } from "../use-unmount-effect";
export type AsyncState<T> =
| {
status: PromiseConstructor["Status"]["Started"];
message?: undefined;
value?: undefined;
}
| {
status: PromiseConstructor["Status"]["Resolved"];
me... | 414 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-async-effect/use-async-effect.ts | roblox-ts | .ts | import { useEffect } from "@rbxts/react";
/**
* Runs an async effect and cancels the promise when unmounting the effect.
* Note that effects paused by `await` still run while cancelled, so prefer
* to use promise chaining instead.
* @param effect The async effect to run.
* @param deps The dependencies to run the ... | 122 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-async/use-async.ts | roblox-ts | .ts | import { useEffect } from "@rbxts/react";
import { AsyncState, useAsyncCallback } from "../use-async-callback";
type AsyncStateTuple<T extends AsyncState<unknown>> = LuaTuple<
[result: T["value"], status: T["status"], message: T["message"]]
>;
/**
* Returns a tuple containing the result and status of a promise. Whe... | 203 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-binding-listener/use-binding-listener.ts | roblox-ts | .ts | import { Binding, useEffect, useMemo } from "@rbxts/react";
import { useLatestCallback } from "../use-latest-callback";
import { getBindingApi, isBinding } from "../utils/binding";
/**
* Subscribes to a binding and calls the given listener when the binding
* updates. If the value passed is not a binding, the listene... | 247 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-binding-state/use-binding-state.ts | roblox-ts | .ts | import { Binding, useState } from "@rbxts/react";
import { useBindingListener } from "../use-binding-listener";
import { getBindingValue } from "../utils/binding";
/**
* Returns the value of a binding. If the binding updates, the component will
* be re-rendered. Non-binding values will be returned as-is.
* @param b... | 135 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-camera/use-camera.ts | roblox-ts | .ts | import { useState } from "@rbxts/react";
import { Workspace } from "@rbxts/services";
import { useEventListener } from "../use-event-listener";
/**
* Returns the current camera. Updates when the current camera changes.
* @returns A camera instance.
*/
export function useCamera() {
const [camera, setCamera] = useSt... | 116 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-composed-ref/use-composed-ref.ts | roblox-ts | .ts | import { useMemo } from "@rbxts/react";
import { useLatestCallback } from "../use-latest-callback";
export type RefFunction<T> = (rbx?: T) => void;
/**
* Composes multiple ref functions into a single ref function and memoizes
* the result.
*
* To prevent excess ref calls, the composed ref is only created once on ... | 314 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-debounce-callback/use-debounce-callback.ts | roblox-ts | .ts | import { useMemo } from "@rbxts/react";
import { DebounceOptions, Debounced, debounce } from "@rbxts/set-timeout";
import { useLatest } from "../use-latest";
import { useUnmountEffect } from "../use-unmount-effect";
export interface UseDebounceOptions extends DebounceOptions {
/**
* The amount of time to wait befor... | 462 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-debounce-effect/use-debounce-effect.ts | roblox-ts | .ts | import { useEffect } from "@rbxts/react";
import { UseDebounceOptions, useDebounceCallback } from "../use-debounce-callback";
import { useUpdate } from "../use-update";
import { useUpdateEffect } from "../use-update-effect";
/**
* Creates a debounced effect that delays invoking `effect` until after `wait`
* seconds ... | 231 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-debounce-state/use-debounce-state.ts | roblox-ts | .ts | import { Dispatch, SetStateAction, useState } from "@rbxts/react";
import { UseDebounceOptions, useDebounceCallback } from "../use-debounce-callback";
/**
* Delays updating `state` until after `wait` seconds have elapsed since the
* last time the debounced function was invoked. Set to the most recently passed
* `st... | 225 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-defer-callback/use-defer-callback.ts | roblox-ts | .ts | import { useCallback, useRef } from "@rbxts/react";
import { RunService } from "@rbxts/services";
import { useLatest } from "../use-latest";
/**
* Defers a callback to be executed on the next Heartbeat frame. Consecutive
* calls to the returned `execute` function will cancel the previous call.
* @param callback The... | 238 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-defer-effect/use-defer-effect.ts | roblox-ts | .ts | import { useEffect } from "@rbxts/react";
import { useDeferCallback } from "../use-defer-callback";
/**
* Like `useEffect`, but the callback is deferred to the next Heartbeat frame.
* @param callback The callback to run
* @param dependencies Optional dependencies to trigger the effect
*/
export function useDeferEf... | 117 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-event-listener/use-event-listener.ts | roblox-ts | .ts | import { useEffect } from "@rbxts/react";
import { useLatest } from "../use-latest";
interface EventListenerOptions {
/**
* Whether the event should be connected or not. Defaults to `true`.
*/
connected?: boolean;
/**
* Whether the event should be disconnected after the first invocation.
* Defaults to `fals... | 733 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-interval/use-interval.ts | roblox-ts | .ts | import { useCallback, useEffect, useRef } from "@rbxts/react";
import { setInterval } from "@rbxts/set-timeout";
import { useLatestCallback } from "../use-latest-callback";
export interface UseIntervalOptions {
/**
* Whether the callback should run immediately when the interval is set.
* Defaults to `false`.
*/... | 285 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-key-press/use-key-press.ts | roblox-ts | .ts | import { InferEnumNames, useEffect, useMemo, useState } from "@rbxts/react";
import { ContextActionService, HttpService, UserInputService } from "@rbxts/services";
import { useEventListener } from "../use-event-listener";
/**
* A single key code name.
*/
export type KeyCode = InferEnumNames<Enum.KeyCode>;
/**
* A ... | 963 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-latest-callback/use-latest-callback.ts | roblox-ts | .ts | import { useCallback, useRef } from "@rbxts/react";
/**
* Returns a memoized callback that wraps the latest version of the input
* callback.
* @param callback The callback to memoize.
* @returns The memoized callback.
*/
export function useLatestCallback<T extends Callback>(callback: T): T {
const callbackRef = ... | 104 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-latest/use-latest.ts | roblox-ts | .ts | import { useMemo, useRef } from "@rbxts/react";
import { Predicate, isStrictEqual } from "../use-previous";
/**
* Returns a mutable ref that points to the latest value of the input.
*
* Takes an optional `predicate` function as the second argument that receives
* the previous and current value. If the predicate re... | 167 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-lifetime/use-lifetime.ts | roblox-ts | .ts | import { useBinding, useEffect } from "@rbxts/react";
import { RunService } from "@rbxts/services";
import { useEventListener } from "../use-event-listener";
/**
* Returns the lifetime of the component in seconds. Updates every frame on
* the Heartbeat event.
*
* If the dependency array is provided, the lifetime t... | 181 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-motion/use-motion.ts | roblox-ts | .ts | import type { Binding } from "@rbxts/react";
import { useBinding, useEffect, useMemo } from "@rbxts/react";
import type { Motion, MotionGoal } from "@rbxts/ripple";
import { createMotion } from "@rbxts/ripple";
import { RunService } from "@rbxts/services";
const callbacks = new Set<(dt: number) => void>();
let connect... | 340 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-mount-effect/use-mount-effect.ts | roblox-ts | .ts | import { EffectCallback, useEffect } from "@rbxts/react";
/**
* Runs a callback when the component is mounted.
* @param callback The callback to run.
*/
export function useMountEffect(callback: EffectCallback) {
useEffect(callback, []);
}
| 52 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-mouse/use-mouse.ts | roblox-ts | .ts | import { Binding, useBinding, useMemo } from "@rbxts/react";
import { UserInputService } from "@rbxts/services";
import { useEventListener } from "../use-event-listener";
import { useMountEffect } from "../use-mount-effect";
/**
* Returns a binding to the mouse position.
* @param listener Optional listener to be cal... | 232 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-previous/use-previous.ts | roblox-ts | .ts | import { useMemo, useRef } from "@rbxts/react";
export type Predicate<T> = (previous: T | undefined, current: T) => boolean;
export const isStrictEqual = (a: unknown, b: unknown) => a === b;
/**
* Returns the most recent value from the previous render. Returns `undefined`
* on the first render.
*
* Takes an opti... | 252 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-tagged/use-tagged.ts | roblox-ts | .ts | import { useState } from "@rbxts/react";
import { useEventListener } from "../use-event-listener";
import { CollectionService } from "@rbxts/services";
/**
* Wrapper around `CollectionService` that provides a list of `Instance` under the given `tag`.
*
* This list is updated as `Instance` are added and removed. You... | 307 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-throttle-callback/use-throttle-callback.ts | roblox-ts | .ts | import { useMemo } from "@rbxts/react";
import { Debounced, ThrottleOptions, throttle } from "@rbxts/set-timeout";
import { UseDebounceResult } from "../use-debounce-callback";
import { useLatest } from "../use-latest";
import { useUnmountEffect } from "../use-unmount-effect";
export interface UseThrottleOptions exten... | 378 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-throttle-effect/use-throttle-effect.ts | roblox-ts | .ts | import { useEffect } from "@rbxts/react";
import { UseThrottleOptions, useThrottleCallback } from "../use-throttle-callback";
import { useUpdate } from "../use-update";
import { useUpdateEffect } from "../use-update-effect";
/**
* Creates a throttled effect that only runs at most once per every `wait`
* seconds.
*
... | 219 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-throttle-state/use-throttle-state.ts | roblox-ts | .ts | import { Dispatch, SetStateAction, useState } from "@rbxts/react";
import { UseThrottleOptions, useThrottleCallback } from "../use-throttle-callback";
/**
* Creates a throttled state that only updates at most once per every `wait`
* seconds. Set to the most recently passed `state` after each interval.
*
* See [Dav... | 206 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-timeout/use-timeout.ts | roblox-ts | .ts | import { useCallback, useEffect, useRef } from "@rbxts/react";
import { setTimeout } from "@rbxts/set-timeout";
import { useLatestCallback } from "../use-latest-callback";
/**
* Sets a timeout that runs the callback function after `delay` seconds. If
* `delay` is `undefined`, the timeout is cleared. If the delay cha... | 208 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-timer/use-timer.ts | roblox-ts | .ts | import { Binding, useBinding, useCallback, useRef } from "@rbxts/react";
import { RunService } from "@rbxts/services";
import { useEventListener } from "../use-event-listener";
export interface Timer {
/**
* A binding that represents the current value of the timer.
*/
readonly value: Binding<number>;
/**
* St... | 361 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-unmount-effect/use-unmount-effect.ts | roblox-ts | .ts | import { useEffect } from "@rbxts/react";
import { useLatest } from "../use-latest";
/**
* Calls the callback when the component unmounts.
* @param callback The callback to call.
*/
export function useUnmountEffect(callback: () => void) {
const callbackRef = useLatest(callback);
useEffect(() => {
return () => ... | 86 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-update-effect/use-update-effect.ts | roblox-ts | .ts | import { useEffect, useRef } from "@rbxts/react";
/**
* Runs a callback when the component is re-rendered. Does not run on the
* first render.
* @param effect The callback to run.
* @param dependencies The dependencies to watch for changes.
*/
export function useUpdateEffect(effect: () => (() => void) | void, dep... | 122 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-update/use-update.ts | roblox-ts | .ts | import { useCallback, useState } from "@rbxts/react";
/**
* Returns a function that can be used to force a component to update. The
* function is recreated on the next render if called. This makes it useful as
* a dependency for other hooks.
* @returns A function that forces a rerender.
*/
export function useUpda... | 97 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/use-viewport/use-viewport.ts | roblox-ts | .ts | import { useBinding, useEffect } from "@rbxts/react";
import { useCamera } from "../use-camera";
/**
* Returns the current viewport size of the camera.
* @param listener Optional listener to be called when the viewport changes.
* @returns A binding to the viewport size.
*/
export function useViewport(listener?: (v... | 179 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/utils/binding.ts | roblox-ts | .ts | import { Binding, createBinding, joinBindings } from "@rbxts/react";
import { lerp } from "./math";
export interface BindingApi<T> {
subscribe: (callback: (newValue: T) => void) => () => void;
update: (newValue: T) => void;
getValue: () => T;
}
export interface Lerpable<T> {
Lerp: (this: T, to: T, alpha: number) ... | 1,286 |
littensy/pretty-react-hooks | littensy-pretty-react-hooks-d8fe499/src/utils/hoarcekat.tsx | roblox-ts | .tsx | import { createRoot } from "@rbxts/react-roblox";
import React, { StrictMode } from "@rbxts/react";
/**
* Returns a function that can be used as a Hoarcekat story. This function will
* mount the given component to the target instance and unmount it when the
* story is unmounted.
* @param TestComponent The componen... | 177 |
roblox-ts/types | roblox-ts-types-7be00b4/src/constants.ts | roblox-ts | .ts | import path from "path";
export const INCLUDE_FOLDER_PATH = path.join(__dirname, "..", "include");
export const GENERATED_FOLDER_PATH = path.join(INCLUDE_FOLDER_PATH, "generated");
export const TSCONFIG_PATH = path.join(INCLUDE_FOLDER_PATH, "tsconfig.json");
export const CUSTOM_DEFITIONS_PATH = path.join(INCLUDE_FOLDE... | 1,276 |
littensy/charm-example | littensy-charm-example-07db0be/src/client/__stories__/button.story.tsx | roblox-ts | .tsx | import Vide, { mount } from "@rbxts/vide";
import { Button } from "client/components/button";
import { px } from "client/composables/use-px";
export = (target: Instance) => {
return mount(() => {
return (
<Button
text="Hello, world!"
anchor={new Vector2(0.5, 0.5)}
position={new UDim2(0.5, 0, 0.5, 0)}... | 138 |
littensy/charm-example | littensy-charm-example-07db0be/src/client/app/app.tsx | roblox-ts | .tsx | import Vide from "@rbxts/vide";
import { Money } from "client/components/money";
import { TapHere } from "client/components/tap-here";
import { usePx } from "client/composables/use-px";
export function App() {
usePx();
return (
<screengui>
<Money />
<TapHere />
</screengui>
);
}
| 88 |
littensy/charm-example | littensy-charm-example-07db0be/src/client/app/mount.client.tsx | roblox-ts | .tsx | import { Players } from "@rbxts/services";
import Vide, { mount } from "@rbxts/vide";
import { App } from "./app";
mount(() => <App />, Players.LocalPlayer.WaitForChild("PlayerGui"));
| 48 |
littensy/charm-example | littensy-charm-example-07db0be/src/client/components/button.tsx | roblox-ts | .tsx | import Vide, { Derivable, source, spring } from "@rbxts/vide";
import { px } from "client/composables/use-px";
interface ButtonProps {
onClick?: () => void;
text?: Derivable<string>;
anchor?: Derivable<Vector2>;
position?: Derivable<UDim2>;
size?: Derivable<UDim2>;
native?: Vide.InstanceAttributes<TextButton>;
... | 406 |
littensy/charm-example | littensy-charm-example-07db0be/src/client/components/money.tsx | roblox-ts | .tsx | import Vide from "@rbxts/vide";
import { useMoney } from "client/composables/use-money";
import { px } from "client/composables/use-px";
export function Money() {
const money = useMoney();
return (
<textbutton
Text={() => `$${money()}`}
TextSize={() => px(32)}
AnchorPoint={new Vector2(1, 1)}
Position=... | 168 |
littensy/charm-example | littensy-charm-example-07db0be/src/client/components/tap-here.tsx | roblox-ts | .tsx | import Vide from "@rbxts/vide";
import { px } from "client/composables/use-px";
import { remotes } from "shared/remotes";
import { Button } from "./button";
export function TapHere() {
return (
<Button
onClick={() => remotes.tap()}
text="Tap here!"
anchor={new Vector2(1, 1)}
position={() => new UDim2(1... | 160 |
littensy/charm-example | littensy-charm-example-07db0be/src/client/composables/use-event.ts | roblox-ts | .ts | import { cleanup } from "@rbxts/vide";
/**
* Connects a callback to an event and disconnects it when the component is unmounted.
*
* @param event The event to connect to.
* @param callback The callback to connect.
*/
export function useEvent<T extends Callback>(event: RBXScriptSignal<T>, callback: T) {
const con... | 89 |
littensy/charm-example | littensy-charm-example-07db0be/src/client/composables/use-money.ts | roblox-ts | .ts | import { Players } from "@rbxts/services";
import { useAtom } from "@rbxts/vide-charm";
import { getPlayerData } from "shared/store/datastore";
export function useMoney() {
return useAtom(() => {
const data = getPlayerData(Players.LocalPlayer.Name);
return data ? data.money : 0;
});
}
| 75 |
littensy/charm-example | littensy-charm-example-07db0be/src/client/composables/use-px.ts | roblox-ts | .ts | import { Workspace } from "@rbxts/services";
import { source } from "@rbxts/vide";
import { useEvent } from "./use-event";
const BASE_RESOLUTION = new Vector2(1280, 832);
const MIN_SCALE = 0.5;
const DOMINANT_AXIS = 0.5;
const scale = source(1);
/**
* Assigns a call signature to an object.
*
* @param callback Th... | 435 |
littensy/charm-example | littensy-charm-example-07db0be/src/server/lib/datastore.server.ts | roblox-ts | .ts | import { effect } from "@rbxts/charm";
import { createCollection } from "@rbxts/lapis";
import { Players } from "@rbxts/services";
import { t } from "@rbxts/t";
import { deletePlayerData, getPlayerData, PlayerData, setPlayerData } from "shared/store/datastore";
const defaultData: PlayerData = {
money: 0,
};
const co... | 333 |
littensy/charm-example | littensy-charm-example-07db0be/src/server/lib/leaderstats.server.ts | roblox-ts | .ts | import { observe, subscribe } from "@rbxts/charm";
import { Players } from "@rbxts/services";
import { datastore, getPlayerData } from "shared/store/datastore";
observe(datastore.players, (_, name) => {
const player = Players.FindFirstChild(name);
if (!player) {
return;
}
const leaderstats = new Instance("Fold... | 162 |
littensy/charm-example | littensy-charm-example-07db0be/src/shared/remotes/index.ts | roblox-ts | .ts | import { SyncPayload } from "@rbxts/charm-sync";
import { Client, createRemotes, remote, Server } from "@rbxts/remo";
import { GlobalAtoms } from "shared/store/sync/atoms";
export const remotes = createRemotes({
sync: remote<Client, [payload: SyncPayload<GlobalAtoms>]>(),
init: remote<Server>(),
tap: remote<Server>... | 88 |
littensy/charm-example | littensy-charm-example-07db0be/src/shared/store/datastore.ts | roblox-ts | .ts | import { atom } from "@rbxts/charm";
export interface PlayerData {
readonly money: number;
}
type PlayerDataMap = {
readonly [K in string]?: PlayerData;
};
export const datastore = {
players: atom<PlayerDataMap>({}),
};
export function getPlayerData(id: string) {
return datastore.players()[id];
}
export functi... | 195 |
littensy/charm-example | littensy-charm-example-07db0be/src/shared/store/sync/sync.client.ts | roblox-ts | .ts | import { client } from "@rbxts/charm-sync";
import { remotes } from "shared/remotes";
import { atoms } from "./atoms";
const syncer = client({ atoms });
remotes.sync.connect((payload) => {
syncer.sync(payload);
});
remotes.init();
| 60 |
littensy/charm-example | littensy-charm-example-07db0be/src/shared/store/sync/sync.server.ts | roblox-ts | .ts | import { server } from "@rbxts/charm-sync";
import { remotes } from "shared/remotes";
import { atoms } from "./atoms";
import { filterPayload } from "./utils/filter-payload";
const syncer = server({ atoms });
syncer.connect((player, payload) => {
remotes.sync(player, filterPayload(player, payload));
});
remotes.in... | 93 |
littensy/charm-example | littensy-charm-example-07db0be/src/shared/store/sync/utils/filter-payload.ts | roblox-ts | .ts | import { SyncPayload } from "@rbxts/charm-sync";
import { GlobalAtoms } from "../atoms";
/**
* Filters the payload to only include the player's data.
*
* @param player The player to send the payload to.
* @param payload The payload to filter.
* @returns A new payload that only includes the player's data.
*/
exp... | 211 |
littensy/charm-example | littensy-charm-example-07db0be/src/shared/store/sync/utils/flatten-atoms.ts | roblox-ts | .ts | import { AtomMap } from "@rbxts/charm-sync";
type NestedAtomMap = {
readonly [K in string]: AtomMap;
};
type FlattenNestedAtoms<T extends NestedAtomMap> = {
readonly [K in keyof T as `${string & K}/${string & keyof T[K]}`]: T[K][Extract<keyof T[K], string>];
};
/**
* Assigns unique prefixes to each atom and flatt... | 237 |
roblox-ts/roblox-ts.com | roblox-ts-roblox-ts.com-b07e032/src/pages/index.tsx | roblox-ts | .tsx | import Link from "@docusaurus/Link";
import useBaseUrl from "@docusaurus/useBaseUrl";
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import CodeBlock from "@theme/CodeBlock";
import Layout from "@theme/Layout";
import React from "react";
import styles from "./styles.module.css";
const EXAMPLE_COD... | 976 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.