0.1.2-ts.1 • Published 2 years ago
@rbxts/sapphire v0.1.2-ts.1
sapphire
A lightweight module loader or a batteries included framework
Vision
- A simple, short module loader that can be extended into a fully fledged framework taking care of networking, logging, data, ECS system scheduling, etc.
- roblox-ts support
- By default can be as simple as:
local sapphire = require("@packages/sapphire")
local singletons = ...
sapphire()
.add_singletons(singletons)
.start()- Singletons don't have to require sapphire itself for anything:
local singleton = {}
function singleton.start()
end
return singleton- Singletons can have priority by specifying an optional
priorityproperty:
local singleton = {}
singleton.priority = 1234- Doesn't use any custom module loaders, depends on
require()to not sacrifice types:
local dependency = require("@singletons/dependency")- Can be extended with
.use(), which instantly runs a singleton that can add extra functionality:
type extension = {
start: (sapphire) -> (), -- extensions' `.start()` lifecycle is additionally called with the framework itself
lifecycles: { [string]: () -> () }, -- to add extra lifecycles to singletons
}
type use = (extension) -> builderlocal sapphire_lifecycles = require("@packages/sapphire_lifecycles")
local sapphire_net = require("@packages/sapphire_net")
sapphire()
.use(sapphire_lifecycles) -- Adds extra lifecycles
.use(sapphire_net) -- Initializes the networking library
-- Extensions are ran instantly! `sapphire_net` can use a `.heartbeat()` lifecycle if `sapphire_lifecycles` adds it, but also `sapphire_lifecycles` can't use any features from `sapphire_net`- If an extension needs complex functionality and doesn't need custom functionality or functionality that doesn't exist, it should use an existing libary. For example:
- A
sapphire_lifecyclesextension wouldn't need any complex functionality and wouldn't use any library - A
sapphire_netextension would be different from existing networking libraries and wouldn't use any networking library, but would use a library such asSquashto not re-implement serdes - A
sapphire_ecsorsapphire_dataextension wouldn't need any new functionality so it would use an existing library likeECRorkeyForm(in order)
- A
Todo
- Set up project
- Make basic, extensible module loader
- Add pre-built extensions:
sapphire_lifecycles- extra lifecycles forRunServiceandPlayerssapphire_logging- a nice logging library with a log historysapphire_net- optimized networking library that features defined (likeByteNet) events and undefined events, both with buffer serdes, albeit undefined events performing worse due to having to define types and lengths in the buffersapphire_data- batteries included wrapper for an existing data library likekeyFormsapphire_ecr- scheduler for ECR with nicetiessapphire_jecs- scheduler for JECS with niceties
- Testing
Note
Partially inspired by team-fireworks/ohmyprvd!
0.1.2-ts.1
2 years ago
0.1.1-ts.1
2 years ago