mirror of
https://github.com/littensy/charm.git
synced 2026-10-20 17:51:37 +00:00
fix: set strict flags if RunService.IsStudio is true
This commit is contained in:
parent
573533058f
commit
d09fb5536b
4 changed files with 10 additions and 10 deletions
|
|
@ -602,7 +602,7 @@ Charm exposes the following global flags to customize behavior:
|
|||
| frozen | `true`\* | Enforces data immutability by deep-freezing tables passed to signals, excluding objects with metatables. |
|
||||
| trackInnerEffects | `true` | Whether nested effects should be tracked and cleaned up when the parent effect re-runs. This should only be disabled to debug issues during migration. |
|
||||
|
||||
The `strict` and `frozen` flags are automatically enabled in Roblox Studio and other development environments where the Luau optimization level is `O1` or lower.
|
||||
The `strict` and `frozen` flags are automatically enabled in Roblox Studio.
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
4
packages/charm/src/index.d.ts
vendored
4
packages/charm/src/index.d.ts
vendored
|
|
@ -50,12 +50,12 @@ export const flags: {
|
|||
/**
|
||||
* Enforces synchronous, non-yielding behavior in signals and effects.
|
||||
* Also enables state validation in Charm Sync to catch sync errors early.
|
||||
* Enabled if the optimization level is below 2, which is true in studio.
|
||||
* Enabled by default in Roblox Studio.
|
||||
*/
|
||||
strict: boolean;
|
||||
/**
|
||||
* Enforces immutability of tables by deep-freezing table values. Enabled
|
||||
* if the optimization level is below 2, which is true in studio.
|
||||
* by default in Roblox Studio.
|
||||
*/
|
||||
frozen: boolean;
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -68,22 +68,22 @@ local batchDepth = 0
|
|||
-- Dependencies accessed during this time will link to the active subscriber.
|
||||
local activeSub: ReactiveNode?
|
||||
|
||||
local function isO2(): boolean
|
||||
return debug.info(1, "n") ~= "isO2"
|
||||
local function isStudio(): boolean
|
||||
return game ~= nil and game:GetService("RunService"):IsStudio()
|
||||
end
|
||||
|
||||
local flags = {
|
||||
--[[
|
||||
Enforces synchronous, non-yielding behavior in signals and effects.
|
||||
Also enables state validation in Charm Sync to catch sync errors early.
|
||||
Enabled if the optimization level is below 2, which is true in studio.
|
||||
Enabled by default in Roblox Studio.
|
||||
]]
|
||||
strict = not isO2(),
|
||||
strict = isStudio(),
|
||||
--[[
|
||||
Enforces immutability of tables by deep-freezing table values. Enabled
|
||||
if the optimization level is below 2, which is true in studio.
|
||||
by default in Roblox Studio.
|
||||
]]
|
||||
frozen = not isO2(),
|
||||
frozen = isStudio(),
|
||||
--[[
|
||||
Whether parent effects should track inner effects and clean them up
|
||||
when the parent effect re-runs. This is usually desirable, but can be
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[tools]
|
||||
wally = "UpliftGames/wally@0.3.2"
|
||||
rojo = "rojo-rbx/rojo@7.6.1"
|
||||
rojo = "rojo-rbx/rojo@7.7.0-rc.1"
|
||||
stylua = "johnnymorganz/stylua@2.5.2"
|
||||
luau-lsp = "johnnymorganz/luau-lsp@1.68.1"
|
||||
lute = "luau-lang/lute@1.0.0"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue