Skip to content

Commit 44f7f11

Browse files
authored
Merge pull request #10 from typetorch/live-reload-changed-signal
Live reload (0.5.5): watch the local payload through each script's Ch…
2 parents 0b0b4f6 + 901d179 commit 44f7f11

5 files changed

Lines changed: 26 additions & 6 deletions

File tree

‎README.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ payload uploaded by `typetorch deploy`) with LoadAsset, mounts it side by side w
88
without a restart; it holds the stable remotes, the `/tt` chat commands, the signed settings and the fleet reports.
99
Changing the kernel itself needs a place update and new servers (`typetorch kernel deploy`, or `tt kernel deploy`).
1010

11-
Version 0.5.4, kernel API 1 (`src/shared/Constants.luau`: `KERNEL_VERSION`, `KERNEL_API`).
11+
Version 0.5.5, kernel API 1 (`src/shared/Constants.luau`: `KERNEL_VERSION`, `KERNEL_API`).
1212

1313
## Where it fits
1414

@@ -124,7 +124,9 @@ under "Owners and owner switches" below.
124124
(the TypeTorch Studio plugin sets it while it syncs Rojo into the playtest's server), a change to the local payload
125125
(a script's `Source`, a name, an instance added or removed) reloads a fresh clone of it 0.4 s after the last change,
126126
as Reload does. Changes made while the attribute is off are dropped. `lune run scripts/smoke-kernel.luau
127-
--studio-local` covers it.
127+
--studio-local` covers it. 0.5.5: the payload is watched through each script's `Changed` (property name) signal;
128+
`GetPropertyChangedSignal("Source")` needs the PluginOrOpenCloud capability a game Script lacks, so 0.5.4 warned
129+
"live reload is off" in every playtest.
128130
- Bad deploys are safe (0.3.2):
129131
- **Health window:** a failed `onStart` (the framework reports it with `api:reportError`) or 3 errors from the new
130132
generation's own scripts within 30 s of ready roll the server back. Errors from outside the generation never

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@typetorch/kernel",
3-
"version": "0.5.4",
3+
"version": "0.5.5",
44
"description": "TypeTorch kernel: the small Luau loader baked into the place (boot, branches, hot swaps, stable remotes, /tt).",
55
"license": "MIT",
66
"repository": {

‎scripts/smoke-kernel.luau‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ local SIGNALS = {
207207
ChildRemoved = true,
208208
DescendantAdded = true,
209209
DescendantRemoving = true,
210+
-- 0.5.5: a script's Source is watched through Changed (a game Script may not use GetPropertyChangedSignal("Source"))
211+
Changed = true,
210212
}
211213
local firedToServer = {} -- 0.3.2 `--client`: every RemoteEvent:FireServer call ({ remote name, args... })
212214
local kicked = {} -- names of players Kick was called on
@@ -298,6 +300,11 @@ instanceMeta.__newindex = function(self, key, value)
298300
if changed and was ~= value then
299301
changed:Fire()
300302
end
303+
-- Roblox's Changed carries the property name; `Source` reaches a game Script only this way (0.5.5)
304+
local anyChanged = inner.signals.Changed
305+
if anyChanged and was ~= value then
306+
anyChanged:Fire(key)
307+
end
301308
if key == "Enabled" and value == true and was ~= true and inner.props.ClassName == "Script" then
302309
onScriptEnabled(self)
303310
elseif key == "Enabled" and value == false and was == true and inner.props.ClassName == "Script" then

‎src/server/Kernel.server.luau‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4380,10 +4380,21 @@ local function watchLocalPayload()
43804380
local function changed()
43814381
changedAt = os.clock()
43824382
end
4383+
-- 0.5.5: a game Script may not touch `Source` (GetPropertyChangedSignal("Source") and reading it both need the
4384+
-- PluginOrOpenCloud capability, so 0.5.4 warned "live reload is off" on every playtest), but `Changed` still
4385+
-- reports the property name: a script's Source and Name are watched through it, other instances through Name.
43834386
local function watch(instance: Instance)
4384-
table.insert(connections, instance:GetPropertyChangedSignal("Name"):Connect(changed))
43854387
if instance:IsA("LuaSourceContainer") then
4386-
table.insert(connections, instance:GetPropertyChangedSignal("Source"):Connect(changed))
4388+
table.insert(
4389+
connections,
4390+
instance.Changed:Connect(function(property)
4391+
if property == "Source" or property == "Name" then
4392+
changed()
4393+
end
4394+
end)
4395+
)
4396+
else
4397+
table.insert(connections, instance:GetPropertyChangedSignal("Name"):Connect(changed))
43874398
end
43884399
end
43894400
local function rewire()

‎src/shared/Constants.luau‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ return {
77
-- The single version source: package.json "version" must match (typetorch kernel deploy checks). The build (git
88
-- commit) and content hash are stamped by kernel deploy as attributes on ServerScriptService.TypeTorchKernel
99
-- (KernelCommit, KernelHash); see status().kernelBuild.
10-
KERNEL_VERSION = "0.5.4",
10+
KERNEL_VERSION = "0.5.5",
1111

1212
-- The kernel's DataStore: durable heads, deployments, private records, events, and (0.3.8) the signed settings.
1313
DATASTORE = "TypeTorch",

0 commit comments

Comments
 (0)