This repository has been archived by the owner on Dec 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
58 changed files
with
4,298 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
return function(dependencies) | ||
local Roact = dependencies.Roact | ||
local ElementKind = dependencies.ElementKind | ||
local Markers = dependencies.Markers | ||
|
||
return { | ||
type = { | ||
kind = ElementKind.Host, | ||
className = "TextButton", | ||
}, | ||
props = { | ||
[Roact.Event.Activated] = Markers.AnonymousFunction, | ||
[Roact.Event.MouseButton1Click] = Markers.AnonymousFunction, | ||
[Roact.Change.AbsoluteSize] = Markers.AnonymousFunction, | ||
[Roact.Change.Visible] = Markers.AnonymousFunction, | ||
}, | ||
children = {}, | ||
} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
return function(dependencies) | ||
local Roact = dependencies.Roact | ||
local ElementKind = dependencies.ElementKind | ||
local Markers = dependencies.Markers | ||
|
||
return { | ||
type = { | ||
kind = ElementKind.Host, | ||
className = "Frame", | ||
}, | ||
props = {}, | ||
children = { | ||
{ | ||
type = { | ||
kind = ElementKind.Function, | ||
}, | ||
hostKey = "LabelA", | ||
props = { | ||
Text = "I am label A", | ||
}, | ||
children = {}, | ||
}, | ||
{ | ||
type = { | ||
kind = ElementKind.Function, | ||
}, | ||
hostKey = "LabelB", | ||
props = { | ||
Text = "I am label B", | ||
}, | ||
children = {}, | ||
}, | ||
}, | ||
} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
return function(dependencies) | ||
local Roact = dependencies.Roact | ||
local ElementKind = dependencies.ElementKind | ||
local Markers = dependencies.Markers | ||
|
||
return { | ||
type = { | ||
kind = ElementKind.Host, | ||
className = "Frame", | ||
}, | ||
props = { | ||
AnchorPoint = Vector2.new(0, 0.5), | ||
BackgroundColor3 = Color3.new(0.1, 0.2, 0.3), | ||
BackgroundTransparency = 0.205, | ||
ClipsDescendants = false, | ||
Size = UDim2.new(0.5, 0, 0.4, 1), | ||
SizeConstraint = Enum.SizeConstraint.RelativeXY, | ||
Visible = true, | ||
ZIndex = 5, | ||
}, | ||
children = {}, | ||
} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
return function(dependencies) | ||
local Roact = dependencies.Roact | ||
local ElementKind = dependencies.ElementKind | ||
local Markers = dependencies.Markers | ||
|
||
return { | ||
type = { | ||
kind = ElementKind.Host, | ||
className = "Frame", | ||
}, | ||
props = {}, | ||
children = { | ||
{ | ||
type = { | ||
kind = ElementKind.Stateful, | ||
componentName = "CoolComponent", | ||
}, | ||
hostKey = "Child", | ||
props = { | ||
label = { | ||
Text = "foo", | ||
}, | ||
}, | ||
children = {}, | ||
}, | ||
}, | ||
} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
local ReplicatedStorage = game:GetService("ReplicatedStorage") | ||
|
||
local Settings = require(script.Parent.Settings) | ||
|
||
local function SyncSnapshots(newSnapshots) | ||
local snapshotsFolder = ReplicatedStorage:FindFirstChild(Settings.SnapshotFolderName) | ||
|
||
if not snapshotsFolder then | ||
snapshotsFolder = Instance.new("Folder") | ||
snapshotsFolder.Name = Settings.SnapshotFolderName | ||
snapshotsFolder.Parent = ReplicatedStorage | ||
end | ||
|
||
for name, value in pairs(newSnapshots) do | ||
local snapshot = Instance.new("ModuleScript") | ||
snapshot.Name = name | ||
snapshot.Source = value | ||
snapshot.Parent = snapshotsFolder | ||
end | ||
end | ||
|
||
local function PluginEditMode(plugin) | ||
local isPluginDeactivated = false | ||
|
||
plugin.Deactivation:Connect(function() | ||
isPluginDeactivated = true | ||
end) | ||
|
||
while not isPluginDeactivated do | ||
local newSnapshots = plugin:GetSetting(Settings.PluginSettingName) | ||
|
||
if newSnapshots then | ||
SyncSnapshots(newSnapshots) | ||
plugin:SetSetting(Settings.PluginSettingName, false) | ||
end | ||
|
||
wait(Settings.SyncDelay) | ||
end | ||
end | ||
|
||
return PluginEditMode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
local ReplicatedStorage = game:GetService("ReplicatedStorage") | ||
|
||
local Settings = require(script.Parent.Settings) | ||
|
||
local function PluginRunMode(plugin) | ||
plugin.Unloading:Connect(function() | ||
local snapshotsFolder = ReplicatedStorage:FindFirstChild(Settings.SnapshotFolderName) | ||
|
||
local newSnapshots = {} | ||
|
||
if not snapshotsFolder then | ||
return | ||
end | ||
|
||
for _, snapshot in pairs(snapshotsFolder:GetChildren()) do | ||
if snapshot:IsA("StringValue") then | ||
newSnapshots[snapshot.Name] = snapshot.Value | ||
end | ||
end | ||
|
||
plugin:SetSetting(Settings.PluginSettingName, newSnapshots) | ||
end) | ||
end | ||
|
||
return PluginRunMode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
local function IndexError(_, key) | ||
local message = ("%q (%s) is not a valid member of Settings"):format( | ||
tostring(key), | ||
typeof(key) | ||
) | ||
|
||
error(message, 2) | ||
end | ||
|
||
return setmetatable({ | ||
SnapshotFolderName = "RoactSnapshots", | ||
PluginSettingName = "NewRoactSnapshots", | ||
SyncDelay = 1, | ||
}, { | ||
__index = IndexError, | ||
__newindex = IndexError, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
local RunService = game:GetService("RunService") | ||
|
||
local EditModeMain = require(script.EditModeMain) | ||
local RunModeMain = require(script.RunModeMain) | ||
|
||
if RunService:IsEdit() then | ||
EditModeMain(plugin) | ||
else | ||
if RunService:IsClient() then | ||
RunModeMain(plugin) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
-- luacheck: globals __LEMUR__ | ||
|
||
local ReplicatedStorage = game:GetService("ReplicatedStorage") | ||
|
||
local Roact = require(ReplicatedStorage.Roact) | ||
local TestEZ = require(ReplicatedStorage.TestEZ) | ||
|
||
Roact.setGlobalConfig({ | ||
["internalTypeChecks"] = true, | ||
["typeChecks"] = true, | ||
["elementTracing"] = true, | ||
["propValidation"] = true, | ||
}) | ||
local results = TestEZ.TestBootstrap:run(ReplicatedStorage.Roact, TestEZ.Reporters.TextReporter) | ||
|
||
local RoactSnapshots = ReplicatedStorage:WaitForChild("RoactSnapshots", 1) | ||
|
||
if not RoactSnapshots then | ||
return nil | ||
end | ||
|
||
for _, snapshot in pairs(RoactSnapshots:GetChildren()) do | ||
if snapshot:IsA("StringValue") then | ||
print(("Snapshot:::<|%s|><|=>%s<=|>"):format(snapshot.Name, snapshot.Value)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
local lfs = require("lfs") | ||
|
||
local ROJO_PROJECT_FILE = "place.project.json" | ||
local TEST_FILE = "bin/run-tests-snapshots.lua" | ||
|
||
local SNAPSHOTS_FOLDER = "RoactSnapshots" | ||
local TEST_PLACE_FILE_NAME = "temp-snapshot-place.rbxlx" | ||
|
||
local function writeSnapshotFile(name, content) | ||
lfs.mkdir(SNAPSHOTS_FOLDER) | ||
|
||
local fileName = name .. ".lua" | ||
local filePath = ("%s/%s"):format(SNAPSHOTS_FOLDER, fileName) | ||
|
||
print("Writing", filePath) | ||
|
||
local file = io.open(filePath, "w") | ||
file:write(content) | ||
file:close() | ||
end | ||
|
||
local function executeCommand(command) | ||
print(command) | ||
local handle = io.popen(command) | ||
local line = handle:read("*l") | ||
local output = {line} | ||
|
||
while line do | ||
line = handle:read("*l") | ||
table.insert(output, line) | ||
end | ||
|
||
handle:close() | ||
|
||
return table.concat(output, "\n") | ||
end | ||
|
||
print("Building test place") | ||
executeCommand(("rojo build %s -o %s"):format( | ||
ROJO_PROJECT_FILE, | ||
TEST_PLACE_FILE_NAME | ||
)) | ||
|
||
print("Running run-in-roblox") | ||
local output = executeCommand(("run-in-roblox %s -s %s -t 100"):format( | ||
TEST_PLACE_FILE_NAME, | ||
TEST_FILE | ||
)) | ||
|
||
print("Clean test place") | ||
os.remove(TEST_PLACE_FILE_NAME) | ||
|
||
print("Processing output...") | ||
|
||
local filteredOutput = output:gsub("\nSnapshot:::<|[%w_%-%.]+|><|=>.-<=|>", "") | ||
|
||
print(filteredOutput, "\n") | ||
|
||
for snapshotPattern in output:gmatch("Snapshot:::<|[%w_%-%.]+|><|=>.-<=|>") do | ||
local name = snapshotPattern:match("Snapshot:::<|([%w_%-%.]+)|>") | ||
local content = snapshotPattern:match("<|=>(.-)<=|>") | ||
|
||
writeSnapshotFile(name, content) | ||
end |
Oops, something went wrong.