Skip to content

Commit

Permalink
Sync with unnamed.games version (#2)
Browse files Browse the repository at this point in the history
* Fix project name

* Remove nonstrict

* Pull latest changes from ungms/base

* Create aftman.toml

* Update Maid LinkToInstance and fix edge cases

* `emitLegacyScripts: false`

* Add automatic publishing to wally

* Bump version to 2.1.0

* Explicitly set secrets

* Cleanup wally.toml
  • Loading branch information
devSparkle committed Jul 29, 2024
1 parent 949d04e commit e341ddb
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 10 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/roblox.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "Roblox"

on:
push:
paths:
- "wally.toml"

jobs:
workflow:
uses: ungms/.github/.github/workflows/roblox.yml@main

secrets:
WALLY_AUTH: ${{ secrets.WALLY_AUTH }}
permissions:
contents: write
3 changes: 3 additions & 0 deletions aftman.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[tools]
rojo = "rojo-rbx/[email protected]"
wally = "upliftgames/[email protected]"
3 changes: 2 additions & 1 deletion default.project.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "devsparkle/maid",
"name": "maid",
"emitLegacyScripts": false,
"tree": {
"$path": "src/MaidClass.luau"
}
Expand Down
43 changes: 38 additions & 5 deletions src/MaidClass.luau
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
--!nonstrict
--// Initialization

local PlayerService = game:GetService("Players")
local CollectionService = game:GetService("CollectionService")

--[=[
@class Maid
:::tip Overture
This class can be required through Overture using:
```lua
local MaidClass = Overture:LoadLibrary("MaidClass")
```
:::
]=]
local Maid = {}
Maid.__index = Maid
Expand All @@ -16,6 +25,10 @@ Maid.__index = Maid
type MaidTask = () -> () | Instance | RBXScriptConnection | Maid | thread
type Maid = typeof(setmetatable({_Tasks = {}:: {MaidTask}}, Maid))

--// Variables

local TRACKING_TAG = "MaidLinkToInstance"

--// Functions

--[=[
Expand Down Expand Up @@ -45,9 +58,26 @@ end
:::
]=]
function Maid:LinkToInstance(Object: Instance)
self:GiveTask(Object.Destroying:Connect(function()
self:DoCleaning()
end))
if Object:IsA("Player") then
self:GiveTask(PlayerService.PlayerRemoving:Connect(function(RemovingPlayer)
if RemovingPlayer == Object then
self:DoCleaning()
end
end))
else
Object:AddTag(TRACKING_TAG)

self:GiveTask(CollectionService:GetInstanceRemovedSignal(TRACKING_TAG):Connect(function(RemovedInstance)
if RemovedInstance == Object then
self:DoCleaning()
end
end))

self:GiveTask(Object.Destroying:Connect(function()
self:DoCleaning()
Object:RemoveTag(TRACKING_TAG)
end))
end
end

--[=[
Expand Down Expand Up @@ -87,7 +117,10 @@ function Maid:DoCleaning()
if TaskType == "RBXScriptConnection" or (IsTable and Task.Disconnect) then
Task:Disconnect()
elseif TaskType == "thread" then
coroutine.close(Task)
xpcall(task.cancel, function(e)
local callerName = debug.info(4,"n")
warn(debug.traceback(`Maid could not cancel thread for "{callerName or "Unknown Function"}": {e}`))
end, Task)
elseif TaskType == "Instance" or (IsTable and Task.Destroy) then
Task:Destroy()
else
Expand Down
6 changes: 2 additions & 4 deletions wally.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
[package]
name = "devsparkle/maid"
description = "A hassle-free Roblox library to manage object cleanup!"
version = "2.0.1"
version = "2.1.0"
license = "MIT"
registry = "https://github.com/UpliftGames/wally-index"
realm = "shared"

[dependencies]
registry = "https://github.com/UpliftGames/wally-index"

0 comments on commit e341ddb

Please sign in to comment.