Skip to content

Commit

Permalink
push rc9 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jmesrje committed Sep 21, 2024
1 parent 456e24c commit 64f5e02
Show file tree
Hide file tree
Showing 17 changed files with 121 additions and 108 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
run: wally install

- name: Generate sourcemap
run: argon sourcemap standalone.project.json --output sourcemap.json
run: rojo sourcemap standalone.project.json --output sourcemap.json

- name: Generate package types
run: wally-package-types --sourcemap sourcemap.json Packages
Expand All @@ -72,7 +72,7 @@ jobs:
run: stylua src/

- name: Build standalone
run: argon build standalone.project.json --output ./Standalone.rbxm
run: rojo build standalone.project.json --output ./Standalone.rbxm

- name: Draft release
uses: softprops/[email protected]
Expand Down
5 changes: 3 additions & 2 deletions dev.project.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"legacyScripts": false,
"emitLegacyScripts": false,
"name": "framework",
"tree": {
"$className": "DataModel",
Expand All @@ -14,6 +14,7 @@
}
},
"Tests": {
"$className": "Folder",
"Client": {
"$path": "tests/client"
},
Expand All @@ -23,4 +24,4 @@
}
}
}
}
}
File renamed without changes.
4 changes: 2 additions & 2 deletions docs/reference/worker.md → docs/api/cycle.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Worker
# Cycle

Responsible for handling actions on different threads concurrently

Expand All @@ -8,7 +8,7 @@ Responsible for handling actions on different threads concurrently

### `Connection` <Badge type="tip" text="read only" />

The connection of the worker.
The connection of the cycle.

- **RBXScriptSignal**

Expand Down
30 changes: 9 additions & 21 deletions docs/reference/index.md → docs/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ The current version of the framework.

### `Start`

Starts the framework and prepares all of the workers/controllers.
Starts the framework and prepares all of the cycles/controllers.

**Parameters**

- **loaded:** `{ Controller }`<br>
A list of already loaded controllers, should be from `.Load`

- **callback:** `(() -> ())?`<br>
Runs when the start process has finished

**Returns**

- **void**
Expand All @@ -46,17 +49,17 @@ This is where functions, properties, and methods are stored. Use this like a gen

---

### `Worker`
### `Cycle`

Creates a new worker for management of various tasks that happen continously in the background.
Creates a new cycle for management of various tasks that happen continously in the background.

**Parameters**

- **type:** `WorkerType`<br>
A designated worker type
- **type:** `CycleType`<br>
A designated cycle type

- **callback:** `(args: ...any) -> ()`<br>
The callback to run for the worker type
The callback to run for the cycle type

**Returns**

Expand All @@ -79,18 +82,3 @@ A function that runs for every module script, returning true will allow the modu
**Returns**

- **void**

---

### `OnStart`

Runs the provided callback function when the framework is completely started.

**Parameters**

- **callback:** `() -> ()`<br>
Callback function to run after the framework starts

**Returns**

- **void**
16 changes: 11 additions & 5 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
* * *

---
hide:

- navigation

* * *
---

# Changelog

Expand All @@ -15,6 +12,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Fixes `.Start` not being called in `Used` modules

### Changed

- Changes `Worker` to `Cycle`
- Changed docs style

## [9.0.0-rc8] - 2024-09-13

### Fixed
Expand Down
12 changes: 5 additions & 7 deletions docs/guides/controllers.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ local function Start()
print("Started!")
end
return Lumin.New({
return Lumin.New {
Init = Init,
Start = Start,
})
}
```

That is an example of the most minimal controller, that includes all of the required items. With this, you include as many other functions, methods, or properties as you please.
Expand All @@ -36,11 +36,9 @@ The functionality of these are explained in the [loading section.](#loading)

```mermaid
flowchart LR
A(Init) --> B{Pcall} --> C(Success) & D(Error)
E(Start)
C --> E
D --x E
E --> F(Finished)
A(Init) --> B{Pcall} -->
C(Start) --> D{Pcall} -->
F(Finished)
```

Above is a diagram of how every controller loads. Dependencies of controllers will become available after `Start` is called as seen in order below:
Expand Down
12 changes: 6 additions & 6 deletions docs/guides/workers.md → docs/guides/cycles.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# Workers
# Cycles

Workers are essentially lifecycle events like in any other framework. They allow for code to constantly run in the background without interupting anything that is in the main thread. Notable mentions include `PlayerAdded` and `PostSimulation`. The purpose of workers is so that we can introduce more safety while using the framework and run into less issues like race conditions or unexplainable errors. New workers cannot be created after `.Start` is finished.
Cycles are essentially lifecycle events like in any other framework. They allow for code to constantly run in the background without interupting anything that is in the main thread. Notable mentions include `PlayerAdded` and `PostSimulation`. The purpose of cycles is so that we can introduce more safety while using the framework and run into less issues like race conditions or unexplainable errors. New cycles cannot be created after `.Start` is finished.

## Usage

Usage of workers is very minimal and simple. Here's how to use one:
Usage of cycles is very minimal and simple. Here's how to use one:

```luau
local Frames = 0
Lumin.Worker("PostSimulation", function(deltaTime)
Lumin.Cycle("PostSimulation", function(deltaTime)
print(deltaTime)
print("Frame number", Frames += 1)
end)
```

The code above will print the amount of frames that have passed since the server started or the client joined entered the data model. It will also print the delta time for each frame.

## Worker Types
## Cycle Types

This is a list of all of the allowed worker types. It can be seen below.
This is a list of all of the allowed cycle types. It can be seen below.

- `PostSimulation`<br>
Fires every *frame* after the physics simulation has completed.
Expand Down
12 changes: 6 additions & 6 deletions docs/guides/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ local function Init()
print("Loaded second!")
end
return Lumin.New({
Uses = {MyController}
return Lumin.New {
Uses = { MyController }
Init = Init
})
}
```

#### Module 2
Expand All @@ -28,9 +28,9 @@ local function Init()
print("Loaded first!")
end
return Lumin.New({
return Lumin.New {
Init = Init,
})
}
```

## Loading
Expand All @@ -39,5 +39,5 @@ The load order differs from the default but not too much. Here's a diagram of it

```mermaid
flowchart TB
A(Uses MyController) -- Put module first in loading queue --> B(Init in used) -- Load dependency --> C(Init in loader) -- Dependencies are ready --> D(Finish)
A(Uses MyController) -- Put module first in loading queue --> B(Init in used) -- Load dependency --> C(Init in loader) -- Dependencies are ready --> D(Start in both) -- Loading completed --> E(Finish)
```
4 changes: 2 additions & 2 deletions docs/guides/networking.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Networking

There is no stock networking library that comes with the framework, so you can use any library you want to. For a default option, you can use [LuminNet](https://github.com/lumin-dev/LuminNet)
There is no stock networking library that comes with the framework, so you can use any library you want to. For a default option, you can use [Net](https://github.com/luminlabsdev/net) by Lumin.

We also recommend:

- **[ByteNet](https://github.com/ffrostfall/ByteNet)** - A networking library focused on hyper-optimization and the usage of buffers
- **[Zap](https://github.com/red-blox/zap)** - A CLI-based library that creates static .zap files for the most optimization
- **[Blink](https://github.com/1Axen/blink)** - A competitor to Zap which does similar things, but has support for studio and different API

But for basic networking, we recommend using LuminNet as the API is less bloated than libraries like BridgeNet or Red. Note that the optimizations of LuminNet are still well over default remote event benchmarks.
But for basic networking, we recommend using LuminNet as the API is less bloated than libraries like BridgeNet or Red. Note that the optimizations of LuminNet are still well over default remote event benchmarks.
14 changes: 7 additions & 7 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ local function Explode()
print("KABOOM!!!")
end
return Framework.New({
return Framework.New {
Explode = Explode,
})
}
```

Efficient and not verbose controller API, is very similar to vanilla modules and does not add any bloat.
Expand All @@ -36,10 +36,10 @@ local function Init()
Dependency.NuclearExplosion() -- This dependency loads first and in result is usable!
end
return Framework.New({
Uses = {Dependency},
return Framework.New {
Uses = { Dependency },
Init = Init,
})
}
```

Organizes your dependencies in an understandable way, so you can easily keep track of what your module uses.
Expand All @@ -55,9 +55,9 @@ local function Init()
end)
end
return Framework.New({
return Framework.New {
Init = Init,
})
}
```

Has a simple worker/lifecycle design that is readable and accessible at a glance.
Expand Down
14 changes: 14 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ repo_url: https://github.com/luminlabsdev/framework
repo_name: luminlabsdev/framework
copyright: Copyright &copy; 2021 - 2024 Lumin Labs & Contributors
edit_uri: edit/main/docs/
nav:
- Home: index.md
- Guides:
- Setup: guides/index.md
- Controllers: guides/controllers.md
- Dependencies: guides/dependencies.md
- Cycles: guides/cycles.md
- Networking: guides/networking.md
- API:
- Framework: api/index.md
- Controller: api/controller.md
- Cycle: api/cycle.md
- Install: installation.md
- Changelog: changelog.md
markdown_extensions:
- attr_list
- pymdownx.emoji:
Expand Down
4 changes: 2 additions & 2 deletions rokit.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[tools]
wally = "UpliftGames/[email protected]"
argon = "argon-rbx/[email protected]"
wally-package-types = "johnnymorganz/[email protected]"
stylua = "johnnymorganz/[email protected]"
lune = "lune-org/[email protected]"
lune = "lune-org/[email protected]"
rojo = "rojo-rbx/[email protected]"
2 changes: 1 addition & 1 deletion src/Storage.luau
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local Types = require(script.Parent.Types)
return {
Controllers = {} :: {Types.Controller<any>},
Workers = {} :: {Types.Worker},
Cycles = {} :: {Types.Cycle},
}
6 changes: 3 additions & 3 deletions src/Types.luau
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ export type Controller<T> = {
}?,
} & T

export type WorkerType =
export type CycleType =
"PostSimulation"
| "PreSimulation"
| "PreAnimation"
| "PreRender"
| "PlayerAdded"
| "PlayerRemoving"

export type Worker = {
export type Cycle = {
Connection: RBXScriptSignal,
Callback: (...any) -> (),
}

export type Storage = {
Controllers: {Controller<any>},
Workers: {Worker},
Cycles: {Cycle},
}

return {}
Loading

0 comments on commit 64f5e02

Please sign in to comment.