mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-24 06:35:39 +00:00
Expose two-way sync.
- Convert plugin DevSettings flag to settings panel feature - Remove server feature, always enable write API
This commit is contained in:
@@ -27,9 +27,6 @@ default = []
|
|||||||
# Turn on support for specifying glob ignore path rules in the project format.
|
# Turn on support for specifying glob ignore path rules in the project format.
|
||||||
unstable_glob_ignore_paths = []
|
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.
|
# Enable this feature to live-reload assets from the web UI.
|
||||||
dev_live_assets = []
|
dev_live_assets = []
|
||||||
|
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ function App:startSession(address, port, sessionOptions)
|
|||||||
self.serveSession = ServeSession.new({
|
self.serveSession = ServeSession.new({
|
||||||
apiContext = ApiContext.new(baseUrl),
|
apiContext = ApiContext.new(baseUrl),
|
||||||
openScriptsExternally = sessionOptions.openScriptsExternally,
|
openScriptsExternally = sessionOptions.openScriptsExternally,
|
||||||
|
twoWaySync = sessionOptions.twoWaySync,
|
||||||
})
|
})
|
||||||
|
|
||||||
self.serveSession:onStatusChanged(function(status, details)
|
self.serveSession:onStatusChanged(function(status, details)
|
||||||
|
|||||||
@@ -167,6 +167,7 @@ function ConnectPanel:render()
|
|||||||
|
|
||||||
local sessionOptions = {
|
local sessionOptions = {
|
||||||
openScriptsExternally = settings:get("openScriptsExternally"),
|
openScriptsExternally = settings:get("openScriptsExternally"),
|
||||||
|
twoWaySync = settings:get("twoWaySync"),
|
||||||
}
|
}
|
||||||
|
|
||||||
startSession(address, port, sessionOptions)
|
startSession(address, port, sessionOptions)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ local Roact = require(Rojo.Roact)
|
|||||||
|
|
||||||
local defaultSettings = {
|
local defaultSettings = {
|
||||||
openScriptsExternally = false,
|
openScriptsExternally = false,
|
||||||
|
twoWaySync = false,
|
||||||
}
|
}
|
||||||
|
|
||||||
local Settings = {}
|
local Settings = {}
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ function SettingsPanel:render()
|
|||||||
HorizontalAlignment = Enum.HorizontalAlignment.Center,
|
HorizontalAlignment = Enum.HorizontalAlignment.Center,
|
||||||
VerticalAlignment = Enum.VerticalAlignment.Center,
|
VerticalAlignment = Enum.VerticalAlignment.Center,
|
||||||
SortOrder = Enum.SortOrder.LayoutOrder,
|
SortOrder = Enum.SortOrder.LayoutOrder,
|
||||||
Padding = UDim.new(0, 8),
|
Padding = UDim.new(0, 16),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
Address = e(FitList, {
|
OpenScriptsExternally = e(FitList, {
|
||||||
containerProps = {
|
containerProps = {
|
||||||
LayoutOrder = 1,
|
LayoutOrder = 1,
|
||||||
BackgroundTransparency = 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, {
|
BackButton = e(FormButton, {
|
||||||
layoutOrder = 2,
|
layoutOrder = 4,
|
||||||
text = "Okay",
|
text = "Okay",
|
||||||
secondary = true,
|
secondary = true,
|
||||||
onClick = function()
|
onClick = function()
|
||||||
|
|||||||
@@ -25,14 +25,6 @@ local VALUES = {
|
|||||||
[Environment.Test] = true,
|
[Environment.Test] = true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UnstableTwoWaySync = {
|
|
||||||
type = "BoolValue",
|
|
||||||
values = {
|
|
||||||
[Environment.User] = false,
|
|
||||||
[Environment.Dev] = false,
|
|
||||||
[Environment.Test] = false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local CONTAINER_NAME = "RojoDevSettings" .. Config.codename
|
local CONTAINER_NAME = "RojoDevSettings" .. Config.codename
|
||||||
@@ -140,10 +132,6 @@ function DevSettings:shouldTypecheck()
|
|||||||
return getValue("TypecheckingEnabled")
|
return getValue("TypecheckingEnabled")
|
||||||
end
|
end
|
||||||
|
|
||||||
function DevSettings:twoWaySyncEnabled()
|
|
||||||
return getValue("UnstableTwoWaySync")
|
|
||||||
end
|
|
||||||
|
|
||||||
function _G.ROJO_DEV_CREATE()
|
function _G.ROJO_DEV_CREATE()
|
||||||
DevSettings:createDevSettings()
|
DevSettings:createDevSettings()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ ServeSession.Status = Status
|
|||||||
local validateServeOptions = t.strictInterface({
|
local validateServeOptions = t.strictInterface({
|
||||||
apiContext = t.table,
|
apiContext = t.table,
|
||||||
openScriptsExternally = t.boolean,
|
openScriptsExternally = t.boolean,
|
||||||
|
twoWaySync = t.boolean,
|
||||||
})
|
})
|
||||||
|
|
||||||
function ServeSession.new(options)
|
function ServeSession.new(options)
|
||||||
@@ -77,6 +78,7 @@ function ServeSession.new(options)
|
|||||||
__status = Status.NotStarted,
|
__status = Status.NotStarted,
|
||||||
__apiContext = options.apiContext,
|
__apiContext = options.apiContext,
|
||||||
__openScriptsExternally = options.openScriptsExternally,
|
__openScriptsExternally = options.openScriptsExternally,
|
||||||
|
__twoWaySync = options.twoWaySync,
|
||||||
__reconciler = reconciler,
|
__reconciler = reconciler,
|
||||||
__instanceMap = instanceMap,
|
__instanceMap = instanceMap,
|
||||||
__statusChangedCallback = nil,
|
__statusChangedCallback = nil,
|
||||||
@@ -158,7 +160,7 @@ function ServeSession:__onActiveScriptChanged(activeScript)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ServeSession:__onInstanceChanged(instance, propertyName)
|
function ServeSession:__onInstanceChanged(instance, propertyName)
|
||||||
if not DevSettings:twoWaySyncEnabled() then
|
if not self.__twoWaySync then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -43,9 +43,7 @@ impl Service for ApiService {
|
|||||||
self.handle_api_open(request)
|
self.handle_api_open(request)
|
||||||
}
|
}
|
||||||
|
|
||||||
(&Method::POST, "/api/write") if cfg!(feature = "unstable_two_way_sync") => {
|
(&Method::POST, "/api/write") => self.handle_api_write(request),
|
||||||
self.handle_api_write(request)
|
|
||||||
}
|
|
||||||
|
|
||||||
(_method, path) => json(
|
(_method, path) => json(
|
||||||
ErrorResponse::not_found(format!("Route not found: {}", path)),
|
ErrorResponse::not_found(format!("Route not found: {}", path)),
|
||||||
|
|||||||
Reference in New Issue
Block a user