Expose two-way sync.

- Convert plugin DevSettings flag to settings panel feature
- Remove server feature, always enable write API
This commit is contained in:
Lucien Greathouse
2020-03-18 10:39:40 -07:00
parent 1601e6d26e
commit 2a46df1110
8 changed files with 48 additions and 22 deletions

View File

@@ -27,9 +27,6 @@ default = []
# Turn on support for specifying glob ignore path rules in the project format.
unstable_glob_ignore_paths = []
# Turn on the server half of Rojo's unstable two-way sync feature.
unstable_two_way_sync = []
# Enable this feature to live-reload assets from the web UI.
dev_live_assets = []

View File

@@ -114,6 +114,7 @@ function App:startSession(address, port, sessionOptions)
self.serveSession = ServeSession.new({
apiContext = ApiContext.new(baseUrl),
openScriptsExternally = sessionOptions.openScriptsExternally,
twoWaySync = sessionOptions.twoWaySync,
})
self.serveSession:onStatusChanged(function(status, details)

View File

@@ -167,6 +167,7 @@ function ConnectPanel:render()
local sessionOptions = {
openScriptsExternally = settings:get("openScriptsExternally"),
twoWaySync = settings:get("twoWaySync"),
}
startSession(address, port, sessionOptions)

View File

@@ -8,6 +8,7 @@ local Roact = require(Rojo.Roact)
local defaultSettings = {
openScriptsExternally = false,
twoWaySync = false,
}
local Settings = {}

View File

@@ -24,10 +24,10 @@ function SettingsPanel:render()
HorizontalAlignment = Enum.HorizontalAlignment.Center,
VerticalAlignment = Enum.VerticalAlignment.Center,
SortOrder = Enum.SortOrder.LayoutOrder,
Padding = UDim.new(0, 8),
Padding = UDim.new(0, 16),
}),
Address = e(FitList, {
OpenScriptsExternally = e(FitList, {
containerProps = {
LayoutOrder = 1,
BackgroundTransparency = 1,
@@ -65,8 +65,46 @@ function SettingsPanel:render()
}),
}),
TwoWaySync = e(FitList, {
containerProps = {
LayoutOrder = 2,
BackgroundTransparency = 1,
},
layoutProps = {
Padding = UDim.new(0, 4),
FillDirection = Enum.FillDirection.Horizontal,
HorizontalAlignment = Enum.HorizontalAlignment.Left,
VerticalAlignment = Enum.VerticalAlignment.Center,
},
}, {
Label = e(FitText, {
Kind = "TextLabel",
LayoutOrder = 1,
BackgroundTransparency = 1,
TextXAlignment = Enum.TextXAlignment.Left,
Font = theme.MainFont,
TextSize = 16,
Text = "Two-Way Sync (Experimental!)",
TextColor3 = theme.Text1,
}),
Padding = e("Frame", {
Size = UDim2.new(0, 8, 0, 0),
BackgroundTransparency = 1,
LayoutOrder = 2,
}),
Input = e(Checkbox, {
layoutOrder = 3,
checked = settings:get("twoWaySync"),
onChange = function(newValue)
settings:set("twoWaySync", not settings:get("twoWaySync"))
end,
}),
}),
BackButton = e(FormButton, {
layoutOrder = 2,
layoutOrder = 4,
text = "Okay",
secondary = true,
onClick = function()

View File

@@ -25,14 +25,6 @@ local VALUES = {
[Environment.Test] = true,
},
},
UnstableTwoWaySync = {
type = "BoolValue",
values = {
[Environment.User] = false,
[Environment.Dev] = false,
[Environment.Test] = false,
},
},
}
local CONTAINER_NAME = "RojoDevSettings" .. Config.codename
@@ -140,10 +132,6 @@ function DevSettings:shouldTypecheck()
return getValue("TypecheckingEnabled")
end
function DevSettings:twoWaySyncEnabled()
return getValue("UnstableTwoWaySync")
end
function _G.ROJO_DEV_CREATE()
DevSettings:createDevSettings()
end

View File

@@ -46,6 +46,7 @@ ServeSession.Status = Status
local validateServeOptions = t.strictInterface({
apiContext = t.table,
openScriptsExternally = t.boolean,
twoWaySync = t.boolean,
})
function ServeSession.new(options)
@@ -77,6 +78,7 @@ function ServeSession.new(options)
__status = Status.NotStarted,
__apiContext = options.apiContext,
__openScriptsExternally = options.openScriptsExternally,
__twoWaySync = options.twoWaySync,
__reconciler = reconciler,
__instanceMap = instanceMap,
__statusChangedCallback = nil,
@@ -158,7 +160,7 @@ function ServeSession:__onActiveScriptChanged(activeScript)
end
function ServeSession:__onInstanceChanged(instance, propertyName)
if not DevSettings:twoWaySyncEnabled() then
if not self.__twoWaySync then
return
end

View File

@@ -43,9 +43,7 @@ impl Service for ApiService {
self.handle_api_open(request)
}
(&Method::POST, "/api/write") if cfg!(feature = "unstable_two_way_sync") => {
self.handle_api_write(request)
}
(&Method::POST, "/api/write") => self.handle_api_write(request),
(_method, path) => json(
ErrorResponse::not_found(format!("Route not found: {}", path)),