Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleitnick authored Nov 25, 2023
2 parents 6369904 + 3c6124c commit 2fbd7c3
Show file tree
Hide file tree
Showing 58 changed files with 4,375 additions and 155 deletions.
27 changes: 27 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"jsx": true,
"useJSXTextNode": true,
"ecmaVersion": 2018,
"sourceType": "module",
"project": "./tsconfig.json"
},
"ignorePatterns": [
"/out"
],
"plugins": [
"@typescript-eslint",
"roblox-ts",
"prettier"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:roblox-ts/recommended",
"plugin:prettier/recommended"
],
"rules": {
"prettier/prettier": "warn"
}
}
8 changes: 4 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Aftman
uses: ok-nick/setup-aftman@v0
Expand All @@ -28,9 +28,9 @@ jobs:
name: Styling
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: JohnnyMorganz/stylua-action@v2
- uses: actions/checkout@v4
- uses: JohnnyMorganz/stylua-action@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: v0.16.0
version: v0.18.2
args: --check ./modules
6 changes: 3 additions & 3 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
name: Build and deploy docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: "16"
node-version: 18
- run: npm i -g moonwave@latest
- name: Publish
run: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
*.zip
packages/*/Packages
/node_modules
/include
/out
/build
/Packages
/test/Packages
Expand Down
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"printWidth": 120,
"tabWidth": 4,
"trailingComma": "all",
"useTabs": true
}
12 changes: 12 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"[lua]": {
"editor.defaultFormatter": "JohnnyMorganz.stylua",
"editor.formatOnSave": true,
},
"[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.formatOnSave": true
},
"editor.codeActionsOnSave": {
"source.addMissingImports": true,
"source.organizeImports": true,
"source.fixAll.eslint": true
},
"eslint.run": "onType",
"eslint.format.enable": true,
"files.eol": "\n"
}
60 changes: 31 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
[![CI](https://github.com/Sleitnick/RbxUtil/actions/workflows/ci.yaml/badge.svg)](https://github.com/Sleitnick/RbxUtil/actions/workflows/ci.yaml)
[![Docs](https://github.com/Sleitnick/RbxUtil/actions/workflows/docs.yaml/badge.svg)](https://github.com/Sleitnick/RbxUtil/actions/workflows/docs.yaml)

# RbxUtil

| Module | Dependency | Description |
| -- | -- | -- |
| [Comm](https://sleitnick.github.io/RbxUtil/api/Comm) | `Comm = "sleitnick/[email protected]"` | Comm library for remote communication |
| [Component](https://sleitnick.github.io/RbxUtil/api/Component) | `Component = "sleitnick/[email protected]"` | Component class |
| [Concur](https://sleitnick.github.io/RbxUtil/api/Concur) | `Concur = "sleitnick/[email protected]"` | Concurrent task handler |
| [EnumList](https://sleitnick.github.io/RbxUtil/api/EnumList) | `EnumList = "sleitnick/[email protected]"` | Enum List class |
| [Input](https://sleitnick.github.io/RbxUtil/api/Input) | `Input = "sleitnick/[email protected]"` | Basic input classes |
| [Loader](https://sleitnick.github.io/RbxUtil/api/Loader) | `Loader = "sleitnick/[email protected]"` | Requires all modules within a given instance |
| [Log](https://sleitnick.github.io/RbxUtil/api/Log) | `Log = "sleitnick/[email protected]"` | Log class for logging to PlayFab |
| [Net](https://sleitnick.github.io/RbxUtil/api/Net) | `Net = "sleitnick/[email protected]"` | Static networking module |
| [Option](https://sleitnick.github.io/RbxUtil/api/Option) | `Option = "sleitnick/[email protected]"` | Represent optional values in Lua |
| [PID](https://sleitnick.github.io/RbxUtil/api/PID) | `PID = "sleitnick/[email protected]"` | PID Controller class |
| [Quaternion](https://sleitnick.github.io/RbxUtil/api/Quaternion) | `Quaternion = "sleitnick/[email protected]"` | Quaternion class |
| [Ser](https://sleitnick.github.io/RbxUtil/api/Ser) | `Ser = "sleitnick/[email protected]"` | Ser class for serialization and deserialization |
| [Shake](https://sleitnick.github.io/RbxUtil/api/Shake) | `Shake = "sleitnick/[email protected]"` | Shake class for making things shake |
| [Signal](https://sleitnick.github.io/RbxUtil/api/Signal) | `Signal = "sleitnick/[email protected]"` | Signal class |
| [Silo](https://sleitnick.github.io/RbxUtil/api/Silo) | `Silo = "sleitnick/[email protected]"` | State container class |
| [Streamable](https://sleitnick.github.io/RbxUtil/api/Streamable) | `Streamable = "sleitnick/[email protected]"` | Streamable class and StreamableUtil |
| [Symbol](https://sleitnick.github.io/RbxUtil/api/Symbol) | `Symbol = "sleitnick/[email protected]"` | Symbol |
| [TableUtil](https://sleitnick.github.io/RbxUtil/api/TableUtil) | `TableUtil = "sleitnick/[email protected]"` | Table utility functions |
| [TaskQueue](https://sleitnick.github.io/RbxUtil/api/TaskQueue) | `TaskQueue = "sleitnick/[email protected]"` | Batches tasks that occur on the same execution step |
| [Timer](https://sleitnick.github.io/RbxUtil/api/Timer) | `Timer = "sleitnick/[email protected]"` | Timer class |
| [Trove](https://sleitnick.github.io/RbxUtil/api/Trove) | `Trove = "sleitnick/[email protected]"` | Trove class for tracking and cleaning up objects |
| [WaitFor](https://sleitnick.github.io/RbxUtil/api/WaitFor) | `WaitFor = "sleitnick/[email protected]"` | WaitFor class for awaiting instances |
[![CI](https://github.com/Sleitnick/RbxUtil/actions/workflows/ci.yaml/badge.svg)](https://github.com/Sleitnick/RbxUtil/actions/workflows/ci.yaml)
[![Docs](https://github.com/Sleitnick/RbxUtil/actions/workflows/docs.yaml/badge.svg)](https://github.com/Sleitnick/RbxUtil/actions/workflows/docs.yaml)

# RbxUtil

| Module | Dependency | Description |
| -- | -- | -- |
| [Comm](https://sleitnick.github.io/RbxUtil/api/Comm) | `Comm = "sleitnick/[email protected]"` | Comm library for remote communication |
| [Component](https://sleitnick.github.io/RbxUtil/api/Component) | `Component = "sleitnick/[email protected]"` | Component class |
| [Concur](https://sleitnick.github.io/RbxUtil/api/Concur) | `Concur = "sleitnick/[email protected]"` | Concurrent task handler |
| [EnumList](https://sleitnick.github.io/RbxUtil/api/EnumList) | `EnumList = "sleitnick/[email protected]"` | Enum List class |
| [Input](https://sleitnick.github.io/RbxUtil/api/Input) | `Input = "sleitnick/[email protected]"` | Basic input classes |
| [Loader](https://sleitnick.github.io/RbxUtil/api/Loader) | `Loader = "sleitnick/[email protected]"` | Requires all modules within a given instance |
| [Log](https://sleitnick.github.io/RbxUtil/api/Log) | `Log = "sleitnick/[email protected]"` | Log class for logging to PlayFab |
| [Net](https://sleitnick.github.io/RbxUtil/api/Net) | `Net = "sleitnick/[email protected]"` | Static networking module |
| [Option](https://sleitnick.github.io/RbxUtil/api/Option) | `Option = "sleitnick/[email protected]"` | Represent optional values in Lua |
| [PID](https://sleitnick.github.io/RbxUtil/api/PID) | `PID = "sleitnick/[email protected]"` | PID Controller class |
| [Quaternion](https://sleitnick.github.io/RbxUtil/api/Quaternion) | `Quaternion = "sleitnick/[email protected]"` | Quaternion class |
| [Sequent](https://sleitnick.github.io/RbxUtil/api/Sequent) | `Sequent = "sleitnick/[email protected]"` | Sequent class |
| [Ser](https://sleitnick.github.io/RbxUtil/api/Ser) | `Ser = "sleitnick/[email protected]"` | Ser class for serialization and deserialization |
| [Shake](https://sleitnick.github.io/RbxUtil/api/Shake) | `Shake = "sleitnick/[email protected]"` | Shake class for making things shake |
| [Signal](https://sleitnick.github.io/RbxUtil/api/Signal) | `Signal = "sleitnick/[email protected]"` | Signal class |
| [Silo](https://sleitnick.github.io/RbxUtil/api/Silo) | `Silo = "sleitnick/[email protected]"` | State container class |
| [Streamable](https://sleitnick.github.io/RbxUtil/api/Streamable) | `Streamable = "sleitnick/[email protected]"` | Streamable class and StreamableUtil |
| [Symbol](https://sleitnick.github.io/RbxUtil/api/Symbol) | `Symbol = "sleitnick/[email protected]"` | Symbol |
| [TableUtil](https://sleitnick.github.io/RbxUtil/api/TableUtil) | `TableUtil = "sleitnick/[email protected]"` | Table utility functions |
| [TaskQueue](https://sleitnick.github.io/RbxUtil/api/TaskQueue) | `TaskQueue = "sleitnick/[email protected]"` | Batches tasks that occur on the same execution step |
| [Timer](https://sleitnick.github.io/RbxUtil/api/Timer) | `Timer = "sleitnick/[email protected]"` | Timer class |
| [Tree](https://sleitnick.github.io/RbxUtil/api/Tree) | `Tree = "sleitnick/[email protected]"` | Utility functions for accessing instances in the game hierarchy |
| [Trove](https://sleitnick.github.io/RbxUtil/api/Trove) | `Trove = "sleitnick/[email protected]"` | Trove class for tracking and cleaning up objects |
| [WaitFor](https://sleitnick.github.io/RbxUtil/api/WaitFor) | `WaitFor = "sleitnick/[email protected]"` | WaitFor class for awaiting instances |
2 changes: 1 addition & 1 deletion aftman.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
tools = { rojo = "rojo-rbx/rojo@7.2.1" , run-in-roblox = "rojo-rbx/[email protected]" , wally = "UpliftGames/[email protected].1" , selene = "Kampfkarren/[email protected]" , stylua = "JohnnyMorganz/StyLua@0.17.1" }
tools = { rojo = "rojo-rbx/rojo@7.3.0" , run-in-roblox = "rojo-rbx/[email protected]" , wally = "UpliftGames/[email protected].2" , selene = "Kampfkarren/[email protected]" , stylua = "JohnnyMorganz/StyLua@0.18.2" }
12 changes: 12 additions & 0 deletions default.project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
"$className": "ReplicatedStorage",
"Test": {
"$path": "test"
},
"modules": {
"$path": "out"
},
"rbxts_include": {
"$path": "include",
"node_modules": {
"$className": "Folder",
"@rbxts": {
"$path": "node_modules/@rbxts"
}
}
}
}
}
Expand Down
57 changes: 57 additions & 0 deletions docs/ts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
sidebar_position: 2
---

# TypeScript

Some modules can be used in [roblox-ts](https://roblox-ts.com/). These modules live within their own `@rbxutil` NPM org.

For a full listing of the available NPM packages, visit the [RbxUtil NPM org](https://www.npmjs.com/org/rbxutil).

## Installation

Installing modules works like any other roblox-ts package, except that the prefix will be `@rbxutil`. For instance, to install the quaternion library, run the following command:

```bash
$ npm install @rbxutil/quaternion
```

## Configuration

In order for modules from `@rbxutil` to work, two changes will need to be made:
1. Add the modules to the Rojo project file
1. Expose the types to TypeScript

### Rojo Project

In the `default.project.json` file, add the `@rbxutil` directory into ReplicatedStorage, right alongside `@rbxts`:

```json
"node_modules": {
"$className": "Folder",
"@rbxts": {
"$path": "node_modules/@rbxts"
},
"@rbxutil": {
"$path": "node_modules/@rbxutil"
}
}
```

### Types Configuration

In the `tsconfig.json` file, add the `@rbxutil` directory to the types list. The `@rbxts` org should already be there:

```json
"typeRoots": ["node_modules/@rbxts", "node_modules/@rbxutil"]
```

## Different Org

In order to avoid naming conflicts and namespace cluttering, RbxUtil modules will be placed in their own NPM org (`@rbxutil`). This has been done out of respect for roblox-ts package developers and to allow RbxUtil to grow unbounded by the current default org packages.

For example, there is already a Signal package within the default `@rbxts` org. Also, RbxUtil has many generic names, such as Log and Shake. While these are named to convey their meaning easily, it is best to not clutter the `@rbxts` org with a vast array of such names from a single repository. This naming issue is not an issue for Wally, as Wally uses the author's name as the namespace.

## Contributing

If you find any types that are incorrect, missing, or broken, please feel free to open up a GitHub Issue and/or pull request to address and fix these issues.
37 changes: 17 additions & 20 deletions modules/comm/Client/ClientRemoteProperty.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,24 @@ function ClientRemoteProperty.new(
self._ready = false
self._value = nil
self.Changed = Signal.new()
self._readyPromise = self:OnReady():andThen(function()
self._readyPromise = nil
self.Changed:Fire(self._value)
self._changed = self._rs:Connect(function(value)
if value == self._value then
return
end
self._value = value
self._rs:Fire()

local resolveOnReadyPromise
self._readyPromise = Promise.new(function(resolve)
resolveOnReadyPromise = resolve
end)
self._changed = self._rs:Connect(function(value)
local changed = value ~= self._value
self._value = value
if not self._ready then
self._ready = true
resolveOnReadyPromise(value)
end
if changed then
self.Changed:Fire(value)
end)
end
end)
self._rs:Fire()

return self
end

Expand Down Expand Up @@ -86,16 +92,7 @@ end
```
]=]
function ClientRemoteProperty:OnReady()
if self._ready then
return Promise.resolve(self._value)
end
return Promise.fromEvent(self._rs, function(value)
self._value = value
self._ready = true
return true
end):andThen(function()
return self._value
end)
return self._readyPromise
end

--[=[
Expand Down
2 changes: 1 addition & 1 deletion modules/comm/wally.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "sleitnick/comm"
description = "Comm library for remote communication"
version = "0.3.1"
version = "0.3.2"
license = "MIT"
authors = ["Stephen Leitnick"]
registry = "https://github.com/UpliftGames/wally-index"
Expand Down
Loading

0 comments on commit 2fbd7c3

Please sign in to comment.