@flamework-experimental/core 2.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +66 -0
  2. package/flamework.build +17 -0
  3. package/out/dependency.d.ts +18 -0
  4. package/out/dependency.luau +32 -0
  5. package/out/flamework.d.ts +78 -0
  6. package/out/flamework.luau +138 -0
  7. package/out/index.d.ts +28 -0
  8. package/out/init.luau +40 -0
  9. package/out/injectable.d.ts +13 -0
  10. package/out/injectable.luau +23 -0
  11. package/out/lifecycle/lifecycleInterfaces.d.ts +94 -0
  12. package/out/lifecycle/lifecycleInterfaces.luau +55 -0
  13. package/out/lifecycle/lifecyclePlugin.d.ts +85 -0
  14. package/out/lifecycle/lifecyclePlugin.luau +424 -0
  15. package/out/modding.d.ts +171 -0
  16. package/out/modding.luau +66 -0
  17. package/out/module/defaultModule.d.ts +5 -0
  18. package/out/module/defaultModule.luau +28 -0
  19. package/out/module/module.d.ts +78 -0
  20. package/out/module/module.luau +811 -0
  21. package/out/module/moduleBuilder.d.ts +88 -0
  22. package/out/module/moduleBuilder.luau +169 -0
  23. package/out/module/moduleDefinition.d.ts +105 -0
  24. package/out/module/moduleDefinition.luau +79 -0
  25. package/out/module/moduleHooks.d.ts +23 -0
  26. package/out/module/moduleHooks.luau +19 -0
  27. package/out/module/providerRegistration.d.ts +22 -0
  28. package/out/module/providerRegistration.luau +80 -0
  29. package/out/module/scopes.d.ts +40 -0
  30. package/out/module/scopes.luau +159 -0
  31. package/out/plugin/pluginDefinition.d.ts +128 -0
  32. package/out/plugin/pluginDefinition.luau +61 -0
  33. package/out/prelude.d.ts +8 -0
  34. package/out/prelude.luau +14 -0
  35. package/out/provider.d.ts +27 -0
  36. package/out/provider.luau +26 -0
  37. package/out/reflect.d.ts +60 -0
  38. package/out/reflect.luau +310 -0
  39. package/out/serialization/types.d.ts +86 -0
  40. package/out/serialization/types.luau +9 -0
  41. package/out/utility/constructors.d.ts +4 -0
  42. package/out/utility/constructors.luau +12 -0
  43. package/out/utility/convertConciseDependencyInfo.d.ts +5 -0
  44. package/out/utility/convertConciseDependencyInfo.luau +29 -0
  45. package/out/utility/getClassImplements.d.ts +7 -0
  46. package/out/utility/getClassImplements.luau +27 -0
  47. package/out/utility/getClassesInPath.d.ts +23 -0
  48. package/out/utility/getClassesInPath.luau +91 -0
  49. package/out/utility/globs.d.ts +9 -0
  50. package/out/utility/globs.luau +64 -0
  51. package/out/utility/metadata.d.ts +12 -0
  52. package/out/utility/metadata.luau +43 -0
  53. package/out/utility/pathRoot.d.ts +17 -0
  54. package/out/utility/pathRoot.luau +105 -0
  55. package/out/utility/recycleThread.d.ts +1 -0
  56. package/out/utility/recycleThread.luau +31 -0
  57. package/out/utility/runtimeConfig.d.ts +59 -0
  58. package/out/utility/runtimeConfig.luau +25 -0
  59. package/out/utility/tsImport.d.ts +6 -0
  60. package/out/utility/tsImport.luau +15 -0
  61. package/out/utility/types.d.ts +16 -0
  62. package/out/utility/types.luau +22 -0
  63. package/out/utility/writable.d.ts +4 -0
  64. package/out/utility/writable.luau +2 -0
  65. package/package.json +33 -0
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # Flamework
2
+
3
+ Flamework is an extensible framework for roblox-ts designed around portable, isolated and testable modules.
4
+
5
+ ## Documentation
6
+
7
+ **[docs/](docs/README.md)** -- start there. A ten-part guide that builds up from a working entry
8
+ point to plugins and project layout, plus reference material:
9
+
10
+ | | |
11
+ |---|---|
12
+ | [Guide](docs/README.md#guide) | Getting started, modules, providers, lifecycle events, components, networking, macros, plugins, project structure, migrating from v1. |
13
+ | [Internals](docs/reference/internals.md) | What the transformer does to your code and what the runtime does with the result. |
14
+ | [Transformer plugins](docs/reference/transformer-plugins.md) | Adding macro types of your own. |
15
+
16
+ The Flamework website documents v1, most of which no longer applies:
17
+
18
+ https://flamework.fireboltofdeath.dev/docs/introduction
19
+
20
+ ## Development
21
+
22
+ This repository is a [Bun](https://bun.sh) workspace. It also needs
23
+ [Lune](https://lune-org.github.io/docs) on `PATH` to run the runtime specs.
24
+
25
+ ```sh
26
+ bun install
27
+ bun run build # builds every package in dependency order
28
+ bun run test # build + transformer tests + runtime specs
29
+ bun run lint
30
+ ```
31
+
32
+ ### Packages
33
+
34
+ | Package | Description |
35
+ |---|---|
36
+ | `packages/core` | Modules, dependency injection, plugins and lifecycle events |
37
+ | `packages/components` | CollectionService components, built on the core plugin system |
38
+ | `packages/networking` | Remote events and functions |
39
+ | `packages/testing` | In-place tests: sections, cleanup, a bindable and a remote to run them, a cloud entry; and `flamework-test`, the CLI that runs them in Roblox Studio on this machine or through Open Cloud (`cli/`) |
40
+ | `packages/transformer` | The roblox-ts transformer |
41
+ | `packages/transformer-plugin` | Public API for writing transformer plugins |
42
+ | `packages/specs` | Runtime specs, compiled by `rbxtsc` and executed under Lune |
43
+
44
+ ### Tests
45
+
46
+ Two suites, both run by `bun run test`:
47
+
48
+ - **Transformer tests** (`bun run test:unit`) compile a fixture project with the real `rbxtsc` and
49
+ assert on the emitted Luau — guard generation, identifiers, nested macros and the plugin system.
50
+ - **Runtime specs** (`bun run test:runtime`) execute compiled `@flamework-experimental/core`, `components` and
51
+ `networking` under Lune using the harness in [`tests/runtime`](tests/runtime), which models
52
+ roblox-ts's `TS.import` tree over the filesystem and stubs the Roblox API surface Flamework
53
+ touches (Instances, attributes, CollectionService, RemoteEvents, Players, signals, `task`,
54
+ `Enum`, and a `Heartbeat` pump so `Promise.delay` -- and therefore request timeouts -- runs).
55
+ They cover dependency injection, modules, hooks and the per-frame lifecycle events, component
56
+ construction, dependencies and streaming, and both halves of networking: events, functions,
57
+ middleware and the generated guards.
58
+
59
+ They run twice, once as `Server` and once as `Client`, because realm-dependent code paths --
60
+ `@Provider`'s metadata, component streaming, and the client/server halves of networking -- differ
61
+ between them. Where a spec asserts something realm-specific, running it from both sides is what
62
+ proves the two agree: a function receives on `$name` and sends on `@name` from the server and the
63
+ mirror image from the client, so the pair of runs pins the wire format down from both ends.
64
+
65
+ Specs live in [`packages/specs`](packages/specs) and are compiled by `rbxtsc` like any other
66
+ Flamework consumer, so they exercise the transformer and the runtime together.
@@ -0,0 +1,17 @@
1
+ {
2
+ "version": 1,
3
+ "flameworkVersion": "2.0.0-alpha.0",
4
+ "identifiers": {
5
+ "@flamework-experimental/core:out/module/module@Module": "$:module/module@Module",
6
+ "@flamework-experimental/core:out/lifecycle/lifecyclePlugin@LifecycleProvider": "$:lifecycle/lifecyclePlugin@LifecycleProvider",
7
+ "@flamework-experimental/core:out/lifecycle/lifecyclePlugin@LifecyclePluginOptions": "$:lifecycle/lifecyclePlugin@LifecyclePluginOptions",
8
+ "@flamework-experimental/core:out/lifecycle/lifecycleInterfaces@OnInit": "$:lifecycle/lifecycleInterfaces@OnInit",
9
+ "@flamework-experimental/core:out/lifecycle/lifecycleInterfaces@OnStart": "$:lifecycle/lifecycleInterfaces@OnStart",
10
+ "@flamework-experimental/core:out/lifecycle/lifecycleInterfaces@OnTick": "$:lifecycle/lifecycleInterfaces@OnTick",
11
+ "@flamework-experimental/core:out/lifecycle/lifecycleInterfaces@OnRender": "$:lifecycle/lifecycleInterfaces@OnRender",
12
+ "@flamework-experimental/core:out/lifecycle/lifecycleInterfaces@OnPhysics": "$:lifecycle/lifecycleInterfaces@OnPhysics",
13
+ "@flamework-experimental/core:out/lifecycle/lifecycleInterfaces@OnExtinguished": "$:lifecycle/lifecycleInterfaces@OnExtinguished"
14
+ },
15
+ "idGenerationMode": "full",
16
+ "identifierPrefix": "$"
17
+ }
@@ -0,0 +1,18 @@
1
+ import type { Modding } from "./modding";
2
+ import type { Module } from "./module/module";
3
+ /**
4
+ * Resolves a dependency from a module.
5
+ *
6
+ * Given a module, it resolves there. Otherwise it resolves from the default module: the first root
7
+ * module ignited in this realm, or the one ignited with `{ default: true }`.
8
+ *
9
+ * This is for code that has no constructor to inject through -- a UI component, a script, a callback
10
+ * handed to something outside Flamework. Inside a provider, take a constructor parameter instead:
11
+ * it declares the dependency where it can be read, and it orders construction.
12
+ *
13
+ * Raises if no module was given and none has been ignited yet, or if the default has since been
14
+ * extinguished.
15
+ *
16
+ * @metadata macro
17
+ */
18
+ export declare function Dependency<T>(module?: Module, info?: string | Modding.Target.DependencyConcise<T>): T;
@@ -0,0 +1,32 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ local getDefaultModule = TS.import(script, script.Parent, "module", "defaultModule").getDefaultModule
4
+ --[[
5
+ *
6
+ * Resolves a dependency from a module.
7
+ *
8
+ * Given a module, it resolves there. Otherwise it resolves from the default module: the first root
9
+ * module ignited in this realm, or the one ignited with `{ default: true }`.
10
+ *
11
+ * This is for code that has no constructor to inject through -- a UI component, a script, a callback
12
+ * handed to something outside Flamework. Inside a provider, take a constructor parameter instead:
13
+ * it declares the dependency where it can be read, and it orders construction.
14
+ *
15
+ * Raises if no module was given and none has been ignited yet, or if the default has since been
16
+ * extinguished.
17
+ *
18
+ * @metadata macro
19
+
20
+ ]]
21
+ local function Dependency(module, info)
22
+ if module == nil then
23
+ module = getDefaultModule()
24
+ if module == nil then
25
+ error("Dependency<T>() was called before any module was ignited", 2)
26
+ end
27
+ end
28
+ return module.resolveDependency(info)
29
+ end
30
+ return {
31
+ Dependency = Dependency,
32
+ }
@@ -0,0 +1,78 @@
1
+ import { t } from "@rbxts/t";
2
+ import { Modding } from "./modding";
3
+ import { AbstractConstructor } from "./utility/constructors";
4
+ import { ModuleBuilder } from "./module/moduleBuilder";
5
+ import { PluginDefinition, type PluginTarget } from "./plugin/pluginDefinition";
6
+ import { Serialization } from "./serialization/types";
7
+ export declare namespace Flamework {
8
+ /**
9
+ * Creates a new Module which is the core functionality of Flamework.
10
+ *
11
+ * Every module starts with `LifecyclePlugin` included. `disableDefaultLifecycle()` on the builder
12
+ * leaves it out, and including one built with `createLifecyclePlugin` takes its place.
13
+ */
14
+ function createModule(): ModuleBuilder;
15
+ /**
16
+ * Creates a plugin: a setup function, run once per ignition of every module that includes it,
17
+ * which registers providers, hooks and observers into that module. See {@link PluginTarget} for
18
+ * what it can do. `name` labels the plugin in error messages.
19
+ */
20
+ function createPlugin(name: string, setup: (target: PluginTarget) => void): PluginDefinition;
21
+ /**
22
+ * The scopes this build is compiled with: `scopes.active` in `flamework.config.json`, which
23
+ * usually comes from the environment. `"*"` in the list stands for every scope.
24
+ */
25
+ function activeScopes(): readonly string[];
26
+ /**
27
+ * Whether a scope is active in this build. What an entry point asks before igniting a module
28
+ * that only exists for that scope.
29
+ */
30
+ function isScopeActive(scope: string): boolean;
31
+ /** @hidden */
32
+ function _implements<T>(object: unknown, id: string): object is T;
33
+ /**
34
+ * Retrieve the identifier for the specified type.
35
+ *
36
+ * @metadata macro {@link id intrinsic-inline}
37
+ */
38
+ function id<T>(id?: Modding.Target.Id<T>): string;
39
+ /**
40
+ * Inlines an environment variable at compile time: the call becomes the variable's value as a
41
+ * string literal, read from `.env`, `.env.local` and the process environment when the compiler
42
+ * started, or `undefined` when it is not set. With a fallback -- a string literal -- that is
43
+ * inlined instead, and the result is a `string`.
44
+ *
45
+ * For deployment values -- a place id, a build channel, a version -- and not for secrets: the
46
+ * value is written into the emitted Luau, where anyone with the place can read it.
47
+ *
48
+ * @metadata macro {@link value intrinsic-inline}
49
+ */
50
+ function env<N extends string, F extends string | undefined = undefined>(name: N, fallback?: F, value?: Modding.Intrinsic<"env", [N, F], F extends string ? string : string | undefined>): F extends string ? string : string | undefined;
51
+ /**
52
+ * Check if the constructor implements the specified interface.
53
+ *
54
+ * @metadata macro {@link _implements intrinsic-flamework-rewrite}
55
+ */
56
+ function implements<T>(object: AbstractConstructor, id?: Modding.Target.Id<T>): boolean;
57
+ /**
58
+ * Check if object implements the specified interface.
59
+ *
60
+ * @metadata macro {@link _implements intrinsic-flamework-rewrite}
61
+ */
62
+ function implements<T>(object: unknown, id?: Modding.Target.Id<T>): object is T;
63
+ /**
64
+ * Creates a type guard from any arbitrary type.
65
+ *
66
+ * @metadata macro
67
+ */
68
+ function createGuard<T>(meta?: Modding.Target.Guard<T>): t.check<T>;
69
+ /**
70
+ * Creates a serializer for `T`. The encode and decode code is generated from the type at compile
71
+ * time: plain `buffer` reads and writes, at constant offsets wherever the layout is fixed, with
72
+ * nothing describing the type left in the output. Instances and `unknown` values travel alongside
73
+ * the buffer as blobs.
74
+ *
75
+ * @metadata macro
76
+ */
77
+ function createSerializer<T>(meta?: Modding.Intrinsic<"serializer", [T], Serialization.Serializer<T>>): Serialization.Serializer<T>;
78
+ }
@@ -0,0 +1,138 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ local Reflect = TS.import(script, script.Parent, "reflect").Reflect
4
+ local ModuleBuilder = TS.import(script, script.Parent, "module", "moduleBuilder").ModuleBuilder
5
+ local PluginDefinition = TS.import(script, script.Parent, "plugin", "pluginDefinition").PluginDefinition
6
+ local LifecyclePlugin = TS.import(script, script.Parent, "lifecycle", "lifecyclePlugin").LifecyclePlugin
7
+ local _scopes = TS.import(script, script.Parent, "module", "scopes")
8
+ local getActiveScopes = _scopes.getActiveScopes
9
+ local isScopeActiveInBuild = _scopes.isScopeActive
10
+ local Flamework = {}
11
+ do
12
+ local _container = Flamework
13
+ --[[
14
+ *
15
+ * Creates a new Module which is the core functionality of Flamework.
16
+ *
17
+ * Every module starts with `LifecyclePlugin` included. `disableDefaultLifecycle()` on the builder
18
+ * leaves it out, and including one built with `createLifecyclePlugin` takes its place.
19
+
20
+ ]]
21
+ local function createModule()
22
+ return ModuleBuilder.new():setDebugName(2):includePlugin(LifecyclePlugin)
23
+ end
24
+ _container.createModule = createModule
25
+ --[[
26
+ *
27
+ * Creates a plugin: a setup function, run once per ignition of every module that includes it,
28
+ * which registers providers, hooks and observers into that module. See {@link PluginTarget} for
29
+ * what it can do. `name` labels the plugin in error messages.
30
+
31
+ ]]
32
+ local function createPlugin(name, setup)
33
+ return PluginDefinition.new(name, setup)
34
+ end
35
+ _container.createPlugin = createPlugin
36
+ --[[
37
+ *
38
+ * The scopes this build is compiled with: `scopes.active` in `flamework.config.json`, which
39
+ * usually comes from the environment. `"*"` in the list stands for every scope.
40
+
41
+ ]]
42
+ local function activeScopes()
43
+ return getActiveScopes()
44
+ end
45
+ _container.activeScopes = activeScopes
46
+ --[[
47
+ *
48
+ * Whether a scope is active in this build. What an entry point asks before igniting a module
49
+ * that only exists for that scope.
50
+
51
+ ]]
52
+ local function isScopeActive(scope)
53
+ return isScopeActiveInBuild(scope)
54
+ end
55
+ _container.isScopeActive = isScopeActive
56
+ --* @hidden
57
+ local function _implements(object, id)
58
+ local _exp = Reflect.getMetadatas(object, "flamework:implements")
59
+ -- ▼ ReadonlyArray.some ▼
60
+ local _result = false
61
+ local _callback = function(impl)
62
+ local _impl = impl
63
+ local _id = id
64
+ return table.find(_impl, _id) ~= nil
65
+ end
66
+ for _k, _v in _exp do
67
+ if _callback(_v, _k - 1, _exp) then
68
+ _result = true
69
+ break
70
+ end
71
+ end
72
+ -- ▲ ReadonlyArray.some ▲
73
+ return _result
74
+ end
75
+ _container._implements = _implements
76
+ --[[
77
+ *
78
+ * Retrieve the identifier for the specified type.
79
+ *
80
+ * @metadata macro {@link id intrinsic-inline}
81
+
82
+ ]]
83
+ --[[
84
+ *
85
+ * Inlines an environment variable at compile time: the call becomes the variable's value as a
86
+ * string literal, read from `.env`, `.env.local` and the process environment when the compiler
87
+ * started, or `undefined` when it is not set. With a fallback -- a string literal -- that is
88
+ * inlined instead, and the result is a `string`.
89
+ *
90
+ * For deployment values -- a place id, a build channel, a version -- and not for secrets: the
91
+ * value is written into the emitted Luau, where anyone with the place can read it.
92
+ *
93
+ * @metadata macro {@link value intrinsic-inline}
94
+
95
+ ]]
96
+ --[[
97
+ *
98
+ * Check if the constructor implements the specified interface.
99
+ *
100
+ * @metadata macro {@link _implements intrinsic-flamework-rewrite}
101
+
102
+ ]]
103
+ --[[
104
+ *
105
+ * Check if object implements the specified interface.
106
+ *
107
+ * @metadata macro {@link _implements intrinsic-flamework-rewrite}
108
+
109
+ ]]
110
+ --[[
111
+ *
112
+ * Creates a type guard from any arbitrary type.
113
+ *
114
+ * @metadata macro
115
+
116
+ ]]
117
+ local function createGuard(meta)
118
+ return meta
119
+ end
120
+ _container.createGuard = createGuard
121
+ --[[
122
+ *
123
+ * Creates a serializer for `T`. The encode and decode code is generated from the type at compile
124
+ * time: plain `buffer` reads and writes, at constant offsets wherever the layout is fixed, with
125
+ * nothing describing the type left in the output. Instances and `unknown` values travel alongside
126
+ * the buffer as blobs.
127
+ *
128
+ * @metadata macro
129
+
130
+ ]]
131
+ local function createSerializer(meta)
132
+ return meta
133
+ end
134
+ _container.createSerializer = createSerializer
135
+ end
136
+ return {
137
+ Flamework = Flamework,
138
+ }
package/out/index.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ export { Flamework } from "./flamework";
2
+ export { Modding } from "./modding";
3
+ export { Reflect } from "./reflect";
4
+ export { Provider } from "./provider";
5
+ export { Injectable } from "./injectable";
6
+ export { Dependency } from "./dependency";
7
+ export { Serialization } from "./serialization/types";
8
+ export type { ProviderDecoratorConfig } from "./provider";
9
+ export type { InjectableDecoratorConfig } from "./injectable";
10
+ export { ModuleDefinition } from "./module/moduleDefinition";
11
+ export { ModuleBuilder } from "./module/moduleBuilder";
12
+ export { HookPriority } from "./module/moduleHooks";
13
+ export type { Module, ProviderLookup } from "./module/module";
14
+ export type { IgniteOptions, InjectionContext, ModuleProvider, ModuleState, PluginInclusion, ProviderConfig, ProviderRegistrationOptions, } from "./module/moduleDefinition";
15
+ export type { HookOptions } from "./module/moduleHooks";
16
+ export { describeConditions, holdsCondition, holdsEveryCondition, __setActiveScopes } from "./module/scopes";
17
+ export type { ScopeCondition } from "./module/scopes";
18
+ export { PluginDefinition } from "./plugin/pluginDefinition";
19
+ export { LifecyclePlugin, LifecycleProvider, createLifecyclePlugin } from "./lifecycle/lifecyclePlugin";
20
+ export type { LifecyclePluginOptions } from "./lifecycle/lifecyclePlugin";
21
+ export type { InterfaceConfiguration, InterfaceContext, InterfaceTargetKind, PluginTarget, } from "./plugin/pluginDefinition";
22
+ export type { OnExtinguished, OnInit, OnPhysics, OnRender, OnStart, OnTick } from "./lifecycle/lifecycleInterfaces";
23
+ export { getClassesInPath, importModule, requireModulesInPath } from "./utility/getClassesInPath";
24
+ export { getClassesInGlob, getGlobPaths } from "./utility/globs";
25
+ export { getPathRoot, resolveRbxPath, __setPathRoot } from "./utility/pathRoot";
26
+ export { getRuntimeConfig } from "./utility/runtimeConfig";
27
+ export type { ComponentsRuntimeConfig, CoreRuntimeConfig, NetworkingRuntimeConfig, RuntimeConfig, ScopesRuntimeConfig, TestingRuntimeConfig, } from "./utility/runtimeConfig";
28
+ export type { AbstractConstructor, Constructor } from "./utility/constructors";
package/out/init.luau ADDED
@@ -0,0 +1,40 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ local exports = {}
4
+ exports.Flamework = TS.import(script, script, "flamework").Flamework
5
+ exports.Modding = TS.import(script, script, "modding").Modding
6
+ exports.Reflect = TS.import(script, script, "reflect").Reflect
7
+ exports.Provider = TS.import(script, script, "provider").Provider
8
+ exports.Injectable = TS.import(script, script, "injectable").Injectable
9
+ exports.Dependency = TS.import(script, script, "dependency").Dependency
10
+ -- Modules
11
+ exports.ModuleDefinition = TS.import(script, script, "module", "moduleDefinition").ModuleDefinition
12
+ exports.ModuleBuilder = TS.import(script, script, "module", "moduleBuilder").ModuleBuilder
13
+ exports.HookPriority = TS.import(script, script, "module", "moduleHooks").HookPriority
14
+ -- Scopes
15
+ local _scopes = TS.import(script, script, "module", "scopes")
16
+ exports.describeConditions = _scopes.describeConditions
17
+ exports.holdsCondition = _scopes.holdsCondition
18
+ exports.holdsEveryCondition = _scopes.holdsEveryCondition
19
+ exports.__setActiveScopes = _scopes.__setActiveScopes
20
+ -- Plugins
21
+ exports.PluginDefinition = TS.import(script, script, "plugin", "pluginDefinition").PluginDefinition
22
+ local _lifecyclePlugin = TS.import(script, script, "lifecycle", "lifecyclePlugin")
23
+ exports.LifecyclePlugin = _lifecyclePlugin.LifecyclePlugin
24
+ exports.LifecycleProvider = _lifecyclePlugin.LifecycleProvider
25
+ exports.createLifecyclePlugin = _lifecyclePlugin.createLifecyclePlugin
26
+ -- Lifecycle events
27
+ -- Utilities that plugins need in order to implement path-based registration.
28
+ local _getClassesInPath = TS.import(script, script, "utility", "getClassesInPath")
29
+ exports.getClassesInPath = _getClassesInPath.getClassesInPath
30
+ exports.importModule = _getClassesInPath.importModule
31
+ exports.requireModulesInPath = _getClassesInPath.requireModulesInPath
32
+ local _globs = TS.import(script, script, "utility", "globs")
33
+ exports.getClassesInGlob = _globs.getClassesInGlob
34
+ exports.getGlobPaths = _globs.getGlobPaths
35
+ local _pathRoot = TS.import(script, script, "utility", "pathRoot")
36
+ exports.getPathRoot = _pathRoot.getPathRoot
37
+ exports.resolveRbxPath = _pathRoot.resolveRbxPath
38
+ exports.__setPathRoot = _pathRoot.__setPathRoot
39
+ exports.getRuntimeConfig = TS.import(script, script, "utility", "runtimeConfig").getRuntimeConfig
40
+ return exports
@@ -0,0 +1,13 @@
1
+ export interface InjectableDecoratorConfig {
2
+ }
3
+ /**
4
+ * Marks a class as constructible through a module's dependency injection, without registering it as
5
+ * a provider.
6
+ *
7
+ * Use this for classes created with `Module.createClassInstance`: they get constructor injection
8
+ * and lifecycle events like a provider, but are not registered by `registerProviders` and cannot be
9
+ * resolved by id.
10
+ *
11
+ * @metadata reflect identifier flamework:dependencies flamework:implements flamework:parameters injectable
12
+ */
13
+ export declare function Injectable(config?: InjectableDecoratorConfig): (constructor: object) => void;
@@ -0,0 +1,23 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ local Reflect = TS.import(script, script.Parent, "reflect").Reflect
4
+ --[[
5
+ *
6
+ * Marks a class as constructible through a module's dependency injection, without registering it as
7
+ * a provider.
8
+ *
9
+ * Use this for classes created with `Module.createClassInstance`: they get constructor injection
10
+ * and lifecycle events like a provider, but are not registered by `registerProviders` and cannot be
11
+ * resolved by id.
12
+ *
13
+ * @metadata reflect identifier flamework:dependencies flamework:implements flamework:parameters injectable
14
+
15
+ ]]
16
+ local function Injectable(config)
17
+ return function(constructor)
18
+ Reflect.defineMetadata(constructor, "flamework:injectableConfig", config)
19
+ end
20
+ end
21
+ return {
22
+ Injectable = Injectable,
23
+ }
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Hook into the OnInit lifecycle event.
3
+ *
4
+ * `onInit` runs during ignition, after every provider has been constructed and before any `onStart`,
5
+ * in dependency order. It may return a Promise, which delays the initialisation of everything after
6
+ * it until the Promise settles; a rejection fails ignition.
7
+ *
8
+ * This is where setup that must be complete before other providers start belongs.
9
+ *
10
+ * A component implements it too. `Components` runs a component's `onInit` itself, synchronously,
11
+ * right after construction and before the component can be seen anywhere -- before `getComponent`
12
+ * hands it back, before another component receives it through a link, before an added listener
13
+ * hears of it. A Promise it returns is not waited for there, and a raise fails the construction.
14
+ */
15
+ export interface OnInit {
16
+ /**
17
+ * Called once during ignition, in dependency order, before any `onStart`. On a component, once
18
+ * right after construction, before anything can see the component.
19
+ *
20
+ * Yielding or returning a Promise delays the providers after this one, so keep it short.
21
+ *
22
+ * @hideinherited
23
+ */
24
+ onInit(): void | Promise<void>;
25
+ }
26
+ /**
27
+ * Hook into the OnStart lifecycle event.
28
+ *
29
+ * A component implements it too: `Components` starts a component on its own thread once it is
30
+ * attached -- and not before ignition has finished, so one built during ignition starts once
31
+ * every provider has.
32
+ */
33
+ export interface OnStart {
34
+ /**
35
+ * This function will be called after the current module has been initialized.
36
+ * This function will be called asynchronously.
37
+ *
38
+ * @hideinherited
39
+ */
40
+ onStart(): void;
41
+ }
42
+ /**
43
+ * Hook into the OnTick lifecycle event.
44
+ * Equivalent to: RunService.Heartbeat (the same point of the frame as PostSimulation in a running
45
+ * game, and it also fires in edit mode and in Open Cloud tasks, where PostSimulation does not).
46
+ */
47
+ export interface OnTick {
48
+ /**
49
+ * Called every frame, after physics.
50
+ *
51
+ * @hideinherited
52
+ */
53
+ onTick(dt: number): void;
54
+ }
55
+ /**
56
+ * Hook into the OnPhysics lifecycle event.
57
+ * Equivalent to: RunService.PreSimulation
58
+ */
59
+ export interface OnPhysics {
60
+ /**
61
+ * Called every frame, before physics.
62
+ *
63
+ * @param dt The time since the previous frame.
64
+ * @param time The elapsed game time, as returned by `time()`.
65
+ * @hideinherited
66
+ */
67
+ onPhysics(dt: number, time: number): void;
68
+ }
69
+ /**
70
+ * Hook into the OnRender lifecycle event.
71
+ * Equivalent to: RunService.PreRender
72
+ *
73
+ * @client
74
+ */
75
+ export interface OnRender {
76
+ /**
77
+ * Called every frame, before rendering.
78
+ * Only fires on the client.
79
+ *
80
+ * @hideinherited
81
+ */
82
+ onRender(dt: number): void;
83
+ }
84
+ /**
85
+ * Runs when this module is terminated.
86
+ *
87
+ * It's not strictly required, but this can be convenient in code that must be run in tests or UI.
88
+ */
89
+ export interface OnExtinguished {
90
+ /**
91
+ * Runs when this module is terminated.
92
+ */
93
+ onExtinguished(): void;
94
+ }
@@ -0,0 +1,55 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ --[[
3
+ *
4
+ * Hook into the OnInit lifecycle event.
5
+ *
6
+ * `onInit` runs during ignition, after every provider has been constructed and before any `onStart`,
7
+ * in dependency order. It may return a Promise, which delays the initialisation of everything after
8
+ * it until the Promise settles; a rejection fails ignition.
9
+ *
10
+ * This is where setup that must be complete before other providers start belongs.
11
+ *
12
+ * A component implements it too. `Components` runs a component's `onInit` itself, synchronously,
13
+ * right after construction and before the component can be seen anywhere -- before `getComponent`
14
+ * hands it back, before another component receives it through a link, before an added listener
15
+ * hears of it. A Promise it returns is not waited for there, and a raise fails the construction.
16
+
17
+ ]]
18
+ --[[
19
+ *
20
+ * Hook into the OnStart lifecycle event.
21
+ *
22
+ * A component implements it too: `Components` starts a component on its own thread once it is
23
+ * attached -- and not before ignition has finished, so one built during ignition starts once
24
+ * every provider has.
25
+
26
+ ]]
27
+ --[[
28
+ *
29
+ * Hook into the OnTick lifecycle event.
30
+ * Equivalent to: RunService.Heartbeat (the same point of the frame as PostSimulation in a running
31
+ * game, and it also fires in edit mode and in Open Cloud tasks, where PostSimulation does not).
32
+
33
+ ]]
34
+ --[[
35
+ *
36
+ * Hook into the OnPhysics lifecycle event.
37
+ * Equivalent to: RunService.PreSimulation
38
+
39
+ ]]
40
+ --[[
41
+ *
42
+ * Hook into the OnRender lifecycle event.
43
+ * Equivalent to: RunService.PreRender
44
+ *
45
+ * @client
46
+
47
+ ]]
48
+ --[[
49
+ *
50
+ * Runs when this module is terminated.
51
+ *
52
+ * It's not strictly required, but this can be convenient in code that must be run in tests or UI.
53
+
54
+ ]]
55
+ return nil