From 36ba836ddf7905cea44ba8784f534b4a3ddc319e Mon Sep 17 00:00:00 2001 From: James <119134081+2jammers@users.noreply.github.com> Date: Sun, 15 Dec 2024 15:42:46 -0600 Subject: [PATCH] 0.3.0-rc2 --- .../pull_request_template.md | 0 .github/workflows/release.yml | 35 +++++++------------ README.md | 7 ++-- dev.project.json | 12 ++----- docs/changelog.md | 15 +++++--- pesde.toml | 4 +-- src/Apply.luau | 2 +- src/Computed.luau | 18 +++------- src/Logs.luau | 5 --- src/New.luau | 2 +- src/Spring.luau | 8 +++-- src/State.luau | 3 +- standalone.project.json | 11 +++--- tests/client/UI.client.luau | 25 ++++++------- tests/client/components/Background.luau | 6 ++-- tests/client/useTheme.luau | 24 ------------- tests/server/Test.server.luau | 33 ----------------- tests/shared/Theme.luau | 25 ------------- 18 files changed, 63 insertions(+), 172 deletions(-) rename .github/{ => PULL_REQUEST_TEMPLATE}/pull_request_template.md (100%) delete mode 100644 tests/client/useTheme.luau delete mode 100644 tests/server/Test.server.luau delete mode 100644 tests/shared/Theme.luau diff --git a/.github/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md similarity index 100% rename from .github/pull_request_template.md rename to .github/PULL_REQUEST_TEMPLATE/pull_request_template.md diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cae36ca..50e5b63 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,16 +11,13 @@ permissions: id-token: write jobs: - bump: - name: Bump Versions + changelog: + name: Changelog runs-on: ubuntu-latest outputs: release-body: ${{ steps.update-changelog.outputs.release-notes }} steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - ref: 'main' + - uses: actions/checkout@v4 - name: Update changelog id: update-changelog @@ -38,31 +35,26 @@ jobs: build: name: Build runs-on: ubuntu-latest - needs: bump + needs: changelog steps: - - name: Checkout Repository - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - name: Setup Pesde uses: 2jammers/setup-pesde@v0.3.0 with: - cache: 'true' - pesde-version: 'v0.5.1+registry.0.1.0' + cache: true - name: Install dependencies run: pesde install - - name: Generate sourcemap - run: rojo sourcemap standalone.project.json --output sourcemap.json - - name: Format code run: stylua src/ - - name: Build standalone + - name: Standalone build run: rojo build standalone.project.json --output ./Standalone.rbxm - - name: Draft release - uses: softprops/action-gh-release@v2.2.0 + - name: Standalone release + uses: softprops/action-gh-release@v2.0.9 with: tag_name: ${{ github.ref_name }} name: ${{ github.ref_name }} @@ -70,22 +62,21 @@ jobs: generate_release_notes: true body: | ## Changelog - ${{ needs.bump.outputs.release-body }} + ${{ needs.changelog.outputs.release-body }} files: | ./Standalone.rbxm package: name: Package runs-on: ubuntu-latest - needs: bump + needs: changelog steps: - - name: Checkout repository - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - name: Setup Pesde uses: 2jammers/setup-pesde@v0.3.0 with: - pesde-version: 'v0.5.1+registry.0.1.0' + cache: true token: '${{ secrets.PESDE_TOKEN }}' - name: Publish diff --git a/README.md b/README.md index 5dc4d38..4217f42 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,8 @@ A light, fast, and efficient UI framework that has a small learning curve. In order to use **lumin/ui** you must have the following dependencies installed: -* [`pesde@v0.5.1+registry.0.1.0^`](https://github.com/pesde-pkg/pesde) -* [`rojo@v7.4.4^`](https://github.com/rojo-rbx/rojo) +* [`pesde@^0.5.1`](https://github.com/pesde-pkg/pesde) +* [`rojo@^7.4.4`](https://github.com/rojo-rbx/rojo) ## Usage @@ -34,8 +34,7 @@ New "ScreenGui" { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0.5, 0.5), Size = UDim2.fromOffset(100, 100), - ZIndex = 1, - + ZIndex = 1,small Event("Activated", function() print("Button clicked!") end) diff --git a/dev.project.json b/dev.project.json index 4a382bc..d7e5658 100644 --- a/dev.project.json +++ b/dev.project.json @@ -1,10 +1,10 @@ { "emitLegacyScripts": false, - "name": "ui-framework", + "name": "ui", "tree": { "$className": "DataModel", "ReplicatedStorage": { - "ui-framework": { + "ui": { "$className": "Folder", "src": { "$path": "src" @@ -14,13 +14,7 @@ } }, "tests": { - "$className": "Folder", - "Client": { - "$path": "tests/client" - }, - "Server": { - "$path": "tests/server" - } + "$path": "tests" } } } diff --git a/docs/changelog.md b/docs/changelog.md index 831094c..ab632fc 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -7,9 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -## [0.3.0-rc1] - 2024-12-15 +### Fixed -## [0.3.0] - 2024-12-15 +- Fixed possible bugs +- Minified longer code +- Improved memory usage + +### Removed + +- Removed old log types + +## [0.3.0-rc1] - 2024-12-15 ### Added @@ -121,5 +129,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Released [Aegis](/)! [unreleased]: https://github.com/lumin-org/ui/compare/v0.3.0-rc1...HEAD -[0.3.0-rc1]: https://github.com/lumin-org/ui/compare/v0.3.0...v0.3.0-rc1 -[0.3.0]: https://github.com/lumin-org/ui/compare/494ed6244654f0eb7886177eff2f6c86520cb742...v0.3.0 +[0.3.0-rc1]: https://github.com/lumin-org/ui/compare/494ed6244654f0eb7886177eff2f6c86520cb742...v0.3.0-rc1 diff --git a/pesde.toml b/pesde.toml index e12b2c8..ac99bcf 100644 --- a/pesde.toml +++ b/pesde.toml @@ -1,6 +1,6 @@ name = "lumin/ui" -version = "0.3.0-rc1" -description = "A small, fast, and efficient UI framework that has a small learning curve" +version = "0.3.0-rc2" +description = "A light, fast, and efficient UI framework that has a small learning curve" authors = ["2jammers"] repository = "https://github.com/lumin-org/ui" license = "MIT" diff --git a/src/Apply.luau b/src/Apply.luau index 28497fe..21577fd 100644 --- a/src/Apply.luau +++ b/src/Apply.luau @@ -10,7 +10,7 @@ return function(instance: Instance, property: any, value: any) if PropType == "number" then -- If the property is a modifier if ValueType == "function" then -- If the value is an action (value :: Types.Action)(instance) - else -- If the value is an instance + elseif ValueType == "userdata" then -- If the value is anything else, it's an instance value.Parent = instance value.Name = property end diff --git a/src/Computed.luau b/src/Computed.luau index ab3621d..6693f4b 100644 --- a/src/Computed.luau +++ b/src/Computed.luau @@ -4,6 +4,7 @@ local Types = require(Root.Types) local Debugger = require(Root.Parent.roblox_packages.debugger) local Class = {} +Class.__index = Class -- Functions @@ -22,7 +23,7 @@ end local function Listener(self: Types.Computed) return function() - self._Value = self._Processor(Use) + self._Value = self._Processor(Use) -- Set the value of the computed to the processed value if self._Instances ~= nil then for prop, instance in self._Instances do @@ -42,27 +43,16 @@ function Class.Get(self: Types.Computed): any end function Class._Bind(self: Types.Computed, prop: string, instance: Instance) - if self._Instances == nil then - self._Instances = {} - end - (self._Instances :: {})[prop] = instance; (instance :: any)[prop] = self._Value end --[=[ - Destroys the compute object. + Destroys the compute object, but not the state dependencies. [Open Documentation](https://lumin-org.github.io/ui/api/computed/#destroy) ]=] function Class.Destroy(self: Types.Computed) - if self._Dependencies then - for dependency: any, disconnect: any in self._Dependencies do - disconnect() - self._Dependencies[dependency] = nil - end - end - table.clear(self :: any) setmetatable(self :: any, nil) end @@ -78,7 +68,7 @@ return function( processor: (use: (value: Types.State | any) -> ()) -> (), dependencies: { Types.State | Types.Spring }? ): Types.ComputedExport - local self = setmetatable({}, { __index = Class }) + local self = setmetatable({}, Class) self._Type = "Computed" self._Processor = processor diff --git a/src/Logs.luau b/src/Logs.luau index 9400e39..444f1af 100644 --- a/src/Logs.luau +++ b/src/Logs.luau @@ -1,11 +1,6 @@ return { - IncompatibleType = "Data type '%s' is incompatible", NotAnimatable = "%s is not an animatable object type", - FailedCreation = "%s could not be created; '%s'", - AlreadyExists = "Item '%s' already exists", - InvalidType = "Expected type %s; got '%s'", - InvalidKey = "Expected valid key type; got '%s'", InvalidClass = "'%s' is not an instance class name", InvalidPropOrEvent = "'%s' is not a property/event of the %s class", } diff --git a/src/New.luau b/src/New.luau index cc12416..d3a1bb3 100644 --- a/src/New.luau +++ b/src/New.luau @@ -37,7 +37,7 @@ return function(class: string) end end else - Debugger.Fatal("FailedCreation", class, New) + Debugger.Fatal("InvalidClass", class) end return New diff --git a/src/Spring.luau b/src/Spring.luau index c2c79bd..117f0a9 100644 --- a/src/Spring.luau +++ b/src/Spring.luau @@ -5,6 +5,8 @@ local Spr = require(Root.Parent.roblox_packages.spr) local Types = require(Root.Types) local Class = {} +Class.__index = Class + local Animatable = { "boolean", "number", @@ -22,8 +24,8 @@ local Animatable = { -- Functions function Class._Bind(self: Types.Spring, prop: string, instance: Instance) - (instance :: any)[prop] = self._Goal:Get() -- Set the prop of the instance to the initial goal - table.insert(self._Instances, instance) + table.insert(self._Instances, instance) + ;(instance :: any)[prop] = self._Goal:Get() -- Set the prop of the instance to the initial goal self._Goal:Listen(function(new) -- When the goal changes, set the target to the new value Spr.target(instance, self._Damping, self._Frequency, { [prop] = new, @@ -75,7 +77,7 @@ return function(goal: Types.State, damping: number?, frequency: number?): Types. Debugger.Assert(table.find(Animatable, typeof((goal :: any):Get())), "NotAnimatable", typeof((goal :: any):Get())) Debugger.Assert(type(goal) == "table" and goal._Type == "State", "InvalidType", "State", type(goal)) - local self = setmetatable({}, { __index = Class }) + local self = setmetatable({}, Class) self._Type = "Spring" self._Damping = damping or 1 diff --git a/src/State.luau b/src/State.luau index a571b78..b3191d5 100644 --- a/src/State.luau +++ b/src/State.luau @@ -4,6 +4,7 @@ local Types = require(Root.Types) local Debugger = require(Root.Parent.roblox_packages.debugger) local Class = {} +Class.__index = Class -- Functions @@ -83,7 +84,7 @@ end return function(initial: any): Types.StateExport Debugger.Assert(type(initial) ~= "table", "InvalidType", "any", "table") - local self = setmetatable({}, { __index = Class }) + local self = setmetatable({}, Class) self._Type = "State" self._Value = initial diff --git a/standalone.project.json b/standalone.project.json index 0920761..d540e79 100644 --- a/standalone.project.json +++ b/standalone.project.json @@ -3,13 +3,10 @@ "tree": { "$className": "Folder", "src": { - "$className": "Folder", - "init": { - "$path": "src" - }, - "roblox_packages": { - "$path": "roblox_packages" - } + "$path": "src" + }, + "roblox_packages": { + "$path": "roblox_packages" } } } diff --git a/tests/client/UI.client.luau b/tests/client/UI.client.luau index b173a55..0557ca7 100644 --- a/tests/client/UI.client.luau +++ b/tests/client/UI.client.luau @@ -1,22 +1,20 @@ --- SERVICES > +-- Variables local ReplicatedStorage = game:GetService("ReplicatedStorage") local Players = game:GetService("Players") --- FOLDERS > -local Package = ReplicatedStorage["ui-framework"] +local Package = ReplicatedStorage.ui --- DEPENDENCIES > -local Framework = require(Package.src) +local UI = require(Package.src) local MyComponent = require(script.Parent.components.Background) --- VARIABLES > local Player = Players.LocalPlayer -local New = Framework.New -local Event = Framework.Event -local Changed = Framework.Changed -local State = Framework.State("Hello") -local Goal = Framework.State(UDim2.fromScale(0.5, 1)) -local Spring = Framework.Spring(Goal :: any, 0.5, 5) +local New = UI.New +local Event = UI.Event +local Changed = UI.Changed +local Tags = UI.Tags +local State = UI.State("Hello") +local Goal = UI.State(UDim2.fromScale(0.5, 1)) +local Spring = UI.Spring(Goal :: any, 0.5, 5) local c = 1 -- UI @@ -54,13 +52,12 @@ New "ScreenGui" { print(new) end), - Text = "Test", + Text = State, Position = UDim2.fromScale(0.5, 0.2), Size = UDim2.fromOffset(100, 100), ZIndex = 3, }, } - task.wait(10) State:Set("TEST!!!") diff --git a/tests/client/components/Background.luau b/tests/client/components/Background.luau index ef7038e..dade489 100644 --- a/tests/client/components/Background.luau +++ b/tests/client/components/Background.luau @@ -2,13 +2,13 @@ local ReplicatedStorage = game:GetService("ReplicatedStorage") -- FOLDERS > -local Package = ReplicatedStorage["ui-framework"] +local Package = ReplicatedStorage.ui -- DEPENDENCIES > -local Framework = require(Package.src) +local UI = require(Package.src) -- VARIABLES > -local New = Framework.New +local New = UI.New type Background = { Color: Color3, diff --git a/tests/client/useTheme.luau b/tests/client/useTheme.luau deleted file mode 100644 index 1afe45a..0000000 --- a/tests/client/useTheme.luau +++ /dev/null @@ -1,24 +0,0 @@ -if not plugin then - return -end - --- // Services -local ReplicatedStorage = game:GetService("ReplicatedStorage") -local Studio = settings().Studio - --- // Folders -local Packages = ReplicatedStorage.Packages - --- // Dependencies -local Framework = require(Packages["ui-framework"]) - --- // Variables -local StudioTheme = Framework.Value(Studio.Theme) - --- // Event Listeners -Studio.ThemeChanged:Connect(function() - StudioTheme:Set(Studio.Theme) -end) - --- // Returning -return StudioTheme diff --git a/tests/server/Test.server.luau b/tests/server/Test.server.luau deleted file mode 100644 index e0945bb..0000000 --- a/tests/server/Test.server.luau +++ /dev/null @@ -1,33 +0,0 @@ --- -- // Services --- local ReplicatedStorage = game:GetService("ReplicatedStorage") - --- -- // Folders --- local Packages = ReplicatedStorage.Packages - --- -- // Dependencies --- local Framework = require(Packages["ui-framework"]) - --- -- // Variables --- local new = Aegis.new --- local state = Aegis.state --- local spring = Aegis.spring - --- local MyState = state(Vector3.new(0, 5, 0)) --- local CustomSpring = spring({ --- State = MyState, --- }) - --- new("Part", { --- Color = Color3.fromRGB(77, 75, 75), --- TopSurface = Enum.SurfaceType.Smooth, --- BottomSurface = Enum.SurfaceType.Smooth, --- Size = Vector3.new(4, 4, 4), --- Anchored = true, --- Parent = workspace, --- Position = CustomSpring, --- }) - --- while task.wait(1) do --- MyState:Set(Vector3.new(0, math.random(5, 10), 0)) --- print("animating") --- end diff --git a/tests/shared/Theme.luau b/tests/shared/Theme.luau deleted file mode 100644 index a698285..0000000 --- a/tests/shared/Theme.luau +++ /dev/null @@ -1,25 +0,0 @@ -type Theme = { - BackgroundMain: Color3, - BackgroundAlt: Color3, - Accent1: Color3, - InnversedMain: Color3, -} - -return { - Light = { - BackgroundMain = Color3.fromHex("#faf4ed"), - BackgroundAlt = Color3.fromHex("#fffaf3"), - - InnversedMain = Color3.fromHex("#575279"), - - Accent1 = Color3.fromHex("#ff8547"), - } :: Theme, - Dark = { - BackgroundMain = Color3.fromHex("#191724"), - BackgroundAlt = Color3.fromHex("#1f1d2e"), - - InnversedMain = Color3.fromHex("#e0def4"), - - Accent1 = Color3.fromHex("#ff8547"), - } :: Theme, -}