Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jeparlefrancais committed Jan 23, 2024
0 parents commit f73582a
Show file tree
Hide file tree
Showing 56 changed files with 1,800 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .darklua.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"process": [
{
"rule": "convert_require",
"current": {
"name": "path",
"sources": {
"@pkg": "node_modules/.luau-aliases"
}
},
"target": {
"name": "roblox",
"rojo_sourcemap": "./sourcemap.json",
"indexing_style": "wait_for_child"
}
},
"compute_expression",
"remove_unused_if_branch",
"remove_unused_while",
"filter_after_early_return",
"remove_nil_declaration",
"remove_empty_do"
]
}
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
* text eol=lf

*.gif binary
*.ico binary
*.jpg binary
*.png binary
35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Release

on: workflow_dispatch

jobs:
publish-package:
name: Publish package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Enable corepack
run: corepack enable

- uses: actions/setup-node@v3
with:
node-version: latest
cache: yarn
cache-dependency-path: yarn.lock

- name: Install packages
run: yarn install --immutable

- name: Run npmluau
run: yarn run prepare

- name: Authenticate yarn
run: |-
yarn config set npmAlwaysAuth true
yarn config set npmAuthToken $NPM_AUTH_TOKEN
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish to npm
run: yarn workspaces foreach --all --no-private npm publish --access public --tolerate-republish
42 changes: 42 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Tests

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
name: Run tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: Roblox/setup-foreman@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Enable Corepack
run: corepack enable

- uses: actions/setup-node@v3
with:
node-version: "latest"
cache: "yarn"
cache-dependency-path: "yarn.lock"

- name: Install packages
run: yarn install --immutable

- name: Run npmluau
run: yarn run prepare

- name: Run linter
run: yarn run lint:selene

- name: Verify code style
run: yarn run style-check
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/site
/*.rbxl
/*.rbxlx
/*.rbxl.lock
/*.rbxlx.lock
/*.rbxm
/*.rbxmx

/jest.lua
/roblox
/node_modules

/.yarn

build/
test-places/

/globalTypes.d.lua

**/sourcemap.json
6 changes: 6 additions & 0 deletions .luau-analyze.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"luau-lsp.require.mode": "relativeToFile",
"luau-lsp.require.directoryAliases": {
"@pkg": "node_modules/.luau-aliases"
}
}
8 changes: 8 additions & 0 deletions .luaurc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"languageMode": "strict",
"lintErrors": true,
"lint": {
"*": true,
"LocalShadow": false
}
}
36 changes: 36 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/.github/
/.vscode/
/scripts/
/docs/

/roblox
/build

.gitattributes
CHANGELOG.md

.yarn

.darklua*
.luau-analyze.json
.luaurc
foreman.toml
selene.toml
selene_definitions.yml
stylua.toml
.styluaignore

/globalTypes.d.lua
**/sourcemap.json
*.project.json

**/__tests__
**/*.test.lua
**/jest.config.lua

**/*.rbxl
**/*.rbxlx
**/*.rbxl.lock
**/*.rbxlx.lock
**/*.rbxm
**/*.rbxmx
4 changes: 4 additions & 0 deletions .styluaignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/node_modules
/roblox

**/*.d.lua
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"luau-lsp.require.directoryAliases": {
"@pkg": "node_modules/.luau-aliases"
}
}
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Sea of Voices

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# React Lua Hooks

This project consists of two main packages that contains [react-lua](https://github.com/jsdotlua/react-lua) hooks.

- [Lua hooks](packages/react-lua-hooks/README.md#content): general-purpose collection of hooks for [react-lua](https://github.com/jsdotlua/react-lua)
- [Roblox hooks](packages/react-roblox-hooks/README.md#content): hooks specifically made for Roblox development

# Installation

Add these packages to your dependencies:

```bash
yarn add @seaofvoices/react-lua-hooks
yarn add @seaofvoices/react-roblox-hooks
```

Or if you are using `npm`:

```bash
npm install @seaofvoices/react-lua-hooks
npm install @seaofvoices/react-roblox-hooks
```

# Content

- [Lua hooks](packages/react-lua-hooks/README.md#content)
- [useDefaultState](packages/react-lua-hooks/README.md#usedefaultstate)
- [usePrevious](packages/react-lua-hooks/README.md#useprevious)
- [usePreviousDistinct](packages/react-lua-hooks/README.md#usepreviousdistinct)
- [useToggle](packages/react-lua-hooks/README.md#usetoggle)
- [useUnmount](packages/react-lua-hooks/README.md#useunmount)
- [useDebouncedState](packages/react-lua-hooks/README.md#usedebouncedstate)
- [useThrottledState](packages/react-lua-hooks/README.md#usethrottledstate)
- [Roblox hooks](packages/react-roblox-hooks/README.md#content)
- [useService](packages/react-roblox-hooks/README.md#useservice)
- [useCamera](packages/react-roblox-hooks/README.md#usecamera)
- [useCameraCFrame](packages/react-roblox-hooks/README.md#usecameracframe)
- [useEvent](packages/react-roblox-hooks/README.md#useevent)
- [useGuiObjectSizeBinding](packages/react-roblox-hooks/README.md#useguiobjectsizebinding)
- [useLocalPlayer](packages/react-roblox-hooks/README.md#uselocalplayer)
- [useObjectLocation](packages/react-roblox-hooks/README.md#useobjectlocation)
- [usePropertyChange](packages/react-roblox-hooks/README.md#usepropertychange)
- [useTaggedInstances](packages/react-roblox-hooks/README.md#usetaggedinstances)
- [useTextSize](packages/react-roblox-hooks/README.md#usetextsize)
- [useViewportSize](packages/react-roblox-hooks/README.md#useviewportsize)

# Other Lua Environments Support

If you would like to use this library on a Lua environment where it is currently incompatible, open an issue (or comment on an existing one) to request the appropriate modifications.

The library uses [darklua](https://github.com/seaofvoices/darklua) to process its code.
7 changes: 7 additions & 0 deletions foreman.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[tools]
rojo = { github = "rojo-rbx/rojo", version = "=7.3.0" }
selene = { github = "Kampfkarren/selene", version = "=0.25.0" }
stylua = { github = "JohnnyMorganz/styLua", version = "=0.18.2" }
darklua = { github = "seaofvoices/darklua", version = "=0.11.3" }
luau-lsp = { github = "JohnnyMorganz/luau-lsp", version = "=1.27.0" }
run-in-roblox = { github = "rojo-rbx/run-in-roblox", version = "=0.3.0" }
21 changes: 21 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "workspace",
"private": true,
"workspaces": [
"packages/*"
],
"scripts": {
"prepare": "npmluau",
"lint": "sh ./scripts/analyze.sh && selene packages",
"lint:luau": "sh ./scripts/analyze.sh",
"lint:selene": "selene packages",
"format": "stylua .",
"style-check": "stylua . --check",
"verify-pack": "yarn workspaces foreach -A --no-private pack --dry-run",
"clean": "rm -rf node_modules"
},
"devDependencies": {
"npmluau": "^0.1.1"
},
"packageManager": "[email protected]"
}
5 changes: 5 additions & 0 deletions packages/react-lua-hooks/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## 0.1.0

* Initial version
Loading

0 comments on commit f73582a

Please sign in to comment.