-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dont hang local x = function
assignments (Take 2)
#600
Conversation
Codecov ReportBase: 97.30% // Head: 97.30% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## main #600 +/- ##
=======================================
Coverage 97.30% 97.30%
=======================================
Files 14 14
Lines 5639 5639
=======================================
Hits 5487 5487
Misses 152 152
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
This comment was marked as outdated.
This comment was marked as outdated.
could we extend this to function call assignments as well? local furryAndFidelity9 = getFurriesAndFidelitiesNames(
context,
creamedFurriesAndFidelitiesNames,
parentType2,
selectionSet2
) |
@matthargett this is the related issue: #506 I'm still using |
PR has been on hold because I need to decide whether to accept the new diff on neovim code in comparison test |
FWIW, the Neovim diff looks great to me! ;) |
This comment was marked as outdated.
This comment was marked as outdated.
…revent-hang-func
Repo Comparison Testdiff --git ORI/neovim/runtime/lua/vim/lsp.lua ALT/neovim/runtime/lua/vim/lsp.lua
index cfd6c93..134a009 100644
--- ORI/neovim/runtime/lua/vim/lsp.lua
+++ ALT/neovim/runtime/lua/vim/lsp.lua
@@ -1557,15 +1557,21 @@ end
--- Notify all attached clients that a buffer has changed.
local text_document_did_change_handler
do
- text_document_did_change_handler =
- function(_, bufnr, changedtick, firstline, lastline, new_lastline)
- -- Detach (nvim_buf_attach) via returning True to on_lines if no clients are attached
- if tbl_isempty(all_buffer_active_clients[bufnr] or {}) then
- return true
- end
- util.buf_versions[bufnr] = changedtick
- changetracking.send_changes(bufnr, firstline, lastline, new_lastline)
+ text_document_did_change_handler = function(
+ _,
+ bufnr,
+ changedtick,
+ firstline,
+ lastline,
+ new_lastline
+ )
+ -- Detach (nvim_buf_attach) via returning True to on_lines if no clients are attached
+ if tbl_isempty(all_buffer_active_clients[bufnr] or {}) then
+ return true
end
+ util.buf_versions[bufnr] = changedtick
+ changetracking.send_changes(bufnr, firstline, lastline, new_lastline)
+ end
end
---@private
diff --git ORI/CorePackages/modules/React-9c8468d8-8a7220fd/src/ReactHooks.lua ALT/CorePackages/modules/React-9c8468d8-8a7220fd/src/ReactHooks.lua
index 89095cf..c2292f9 100644
--- ORI/CorePackages/modules/React-9c8468d8-8a7220fd/src/ReactHooks.lua
+++ ALT/CorePackages/modules/React-9c8468d8-8a7220fd/src/ReactHooks.lua
@@ -151,11 +151,14 @@ exports.useMemo = function<T...>(create: () -> T..., deps: Array<any> | nil): T.
return dispatcher.useMemo(create, deps)
end
-exports.useImperativeHandle =
- function<T>(ref: { current: T | nil } | ((inst: T | nil) -> any) | nil, create: () -> T, deps: Array<any> | nil): ()
- local dispatcher = resolveDispatcher()
- return dispatcher.useImperativeHandle(ref, create, deps)
- end
+exports.useImperativeHandle = function<T>(
+ ref: { current: T | nil } | ((inst: T | nil) -> any) | nil,
+ create: () -> T,
+ deps: Array<any> | nil
+): ()
+ local dispatcher = resolveDispatcher()
+ return dispatcher.useImperativeHandle(ref, create, deps)
+end
exports.useDebugValue = function<T>(value: T, formatterFn: ((value: T) -> any)?): ()
if _G.__DEV__ then
diff --git ORI/CorePackages/modules/ReactReconciler-9c8468d8-8a7220fd/src/ReactFiberCompleteWork.new.lua ALT/CorePackages/modules/ReactReconciler-9c8468d8-8a7220fd/src/ReactFiberCompleteWork.new.lua
index 9143223..1e04d5f 100644
--- ORI/CorePackages/modules/ReactReconciler-9c8468d8-8a7220fd/src/ReactFiberCompleteWork.new.lua
+++ ALT/CorePackages/modules/ReactReconciler-9c8468d8-8a7220fd/src/ReactFiberCompleteWork.new.lua
@@ -217,39 +217,43 @@ local updateHostText
if supportsMutation then
-- Mutation mode
- appendAllChildren =
- function(parent: Instance, workInProgress: Fiber, needsVisibilityToggle: boolean, isHidden: boolean)
- -- We only have the top Fiber that was created but we need recurse down its
- -- children to find all the terminal nodes.
- local node = workInProgress.child
- while node ~= nil do
- if node.tag == HostComponent or node.tag == HostText then
- appendInitialChild(parent, node.stateNode)
- elseif enableFundamentalAPI and node.tag == FundamentalComponent then
- appendInitialChild(parent, node.stateNode.instance)
- elseif node.tag == HostPortal then
- -- If we have a portal child, then we don't want to traverse
- -- down its children. Instead, we'll get insertions from each child in
- -- the portal directly.
- elseif node.child ~= nil then
- node.child.return_ = node
- node = node.child
- continue
- end
- if node == workInProgress then
+ appendAllChildren = function(
+ parent: Instance,
+ workInProgress: Fiber,
+ needsVisibilityToggle: boolean,
+ isHidden: boolean
+ )
+ -- We only have the top Fiber that was created but we need recurse down its
+ -- children to find all the terminal nodes.
+ local node = workInProgress.child
+ while node ~= nil do
+ if node.tag == HostComponent or node.tag == HostText then
+ appendInitialChild(parent, node.stateNode)
+ elseif enableFundamentalAPI and node.tag == FundamentalComponent then
+ appendInitialChild(parent, node.stateNode.instance)
+ elseif node.tag == HostPortal then
+ -- If we have a portal child, then we don't want to traverse
+ -- down its children. Instead, we'll get insertions from each child in
+ -- the portal directly.
+ elseif node.child ~= nil then
+ node.child.return_ = node
+ node = node.child
+ continue
+ end
+ if node == workInProgress then
+ return
+ end
+ while node.sibling == nil do
+ if node.return_ == nil or node.return_ == workInProgress then
return
end
- while node.sibling == nil do
- if node.return_ == nil or node.return_ == workInProgress then
- return
- end
- node = node.return_
- end
- -- ROBLOX FIXME Luau: Luau doesn't understand loop predicates above results in node.sibling ~= nil
- (node.sibling :: Fiber).return_ = node.return_
- node = node.sibling
+ node = node.return_
end
+ -- ROBLOX FIXME Luau: Luau doesn't understand loop predicates above results in node.sibling ~= nil
+ (node.sibling :: Fiber).return_ = node.return_
+ node = node.sibling
end
+ end
updateHostContainer = function(current: nil | Fiber, workInProgress: Fiber)
-- Noop
@@ -297,95 +301,99 @@ if supportsMutation then
end
elseif supportsPersistence then
-- Persistent host tree mode
- appendAllChildren =
- function(parent: Instance, workInProgress: Fiber, needsVisibilityToggle: boolean, isHidden: boolean)
- unimplemented("appendAllChildren")
- -- -- We only have the top Fiber that was created but we need recurse down its
- -- -- children to find all the terminal nodes.
- -- local node = workInProgress.child
- -- while (node ~= nil)
- -- -- eslint-disable-next-line no-labels
- -- branches: if node.tag == HostComponent)
- -- local instance = node.stateNode
- -- if needsVisibilityToggle and isHidden)
- -- -- This child is inside a timed out tree. Hide it.
- -- local props = node.memoizedProps
- -- local type = node.type
- -- instance = cloneHiddenInstance(instance, type, props, node)
- -- end
- -- appendInitialChild(parent, instance)
- -- } else if node.tag == HostText)
- -- local instance = node.stateNode
- -- if needsVisibilityToggle and isHidden)
- -- -- This child is inside a timed out tree. Hide it.
- -- local text = node.memoizedProps
- -- instance = cloneHiddenTextInstance(instance, text, node)
- -- end
- -- appendInitialChild(parent, instance)
- -- } else if enableFundamentalAPI and node.tag == FundamentalComponent)
- -- local instance = node.stateNode.instance
- -- if needsVisibilityToggle and isHidden)
- -- -- This child is inside a timed out tree. Hide it.
- -- local props = node.memoizedProps
- -- local type = node.type
- -- instance = cloneHiddenInstance(instance, type, props, node)
- -- end
- -- appendInitialChild(parent, instance)
- -- } else if node.tag == HostPortal)
- -- -- If we have a portal child, then we don't want to traverse
- -- -- down its children. Instead, we'll get insertions from each child in
- -- -- the portal directly.
- -- } else if node.tag == SuspenseComponent)
- -- if (node.flags & Update) ~= NoFlags)
- -- -- Need to toggle the visibility of the primary children.
- -- local newIsHidden = node.memoizedState ~= nil
- -- if newIsHidden)
- -- local primaryChildParent = node.child
- -- if primaryChildParent ~= nil)
- -- if primaryChildParent.child ~= nil)
- -- primaryChildParent.child.return = primaryChildParent
- -- appendAllChildren(
- -- parent,
- -- primaryChildParent,
- -- true,
- -- newIsHidden,
- -- )
- -- end
- -- local fallbackChildParent = primaryChildParent.sibling
- -- if fallbackChildParent ~= nil)
- -- fallbackChildParent.return = node
- -- node = fallbackChildParent
- -- continue
- -- end
- -- end
- -- end
- -- end
- -- if node.child ~= nil)
- -- -- Continue traversing like normal
- -- node.child.return = node
- -- node = node.child
- -- continue
- -- end
- -- } else if node.child ~= nil)
- -- node.child.return = node
- -- node = node.child
- -- continue
- -- end
- -- -- $FlowFixMe This is correct but Flow is confused by the labeled break.
- -- node = (node: Fiber)
- -- if node == workInProgress)
- -- return
- -- end
- -- while (node.sibling == nil)
- -- if node.return == nil or node.return == workInProgress)
- -- return
- -- end
- -- node = node.return
- -- end
- -- node.sibling.return = node.return
- -- node = node.sibling
- -- end
- end
+ appendAllChildren = function(
+ parent: Instance,
+ workInProgress: Fiber,
+ needsVisibilityToggle: boolean,
+ isHidden: boolean
+ )
+ unimplemented("appendAllChildren")
+ -- -- We only have the top Fiber that was created but we need recurse down its
+ -- -- children to find all the terminal nodes.
+ -- local node = workInProgress.child
+ -- while (node ~= nil)
+ -- -- eslint-disable-next-line no-labels
+ -- branches: if node.tag == HostComponent)
+ -- local instance = node.stateNode
+ -- if needsVisibilityToggle and isHidden)
+ -- -- This child is inside a timed out tree. Hide it.
+ -- local props = node.memoizedProps
+ -- local type = node.type
+ -- instance = cloneHiddenInstance(instance, type, props, node)
+ -- end
+ -- appendInitialChild(parent, instance)
+ -- } else if node.tag == HostText)
+ -- local instance = node.stateNode
+ -- if needsVisibilityToggle and isHidden)
+ -- -- This child is inside a timed out tree. Hide it.
+ -- local text = node.memoizedProps
+ -- instance = cloneHiddenTextInstance(instance, text, node)
+ -- end
+ -- appendInitialChild(parent, instance)
+ -- } else if enableFundamentalAPI and node.tag == FundamentalComponent)
+ -- local instance = node.stateNode.instance
+ -- if needsVisibilityToggle and isHidden)
+ -- -- This child is inside a timed out tree. Hide it.
+ -- local props = node.memoizedProps
+ -- local type = node.type
+ -- instance = cloneHiddenInstance(instance, type, props, node)
+ -- end
+ -- appendInitialChild(parent, instance)
+ -- } else if node.tag == HostPortal)
+ -- -- If we have a portal child, then we don't want to traverse
+ -- -- down its children. Instead, we'll get insertions from each child in
+ -- -- the portal directly.
+ -- } else if node.tag == SuspenseComponent)
+ -- if (node.flags & Update) ~= NoFlags)
+ -- -- Need to toggle the visibility of the primary children.
+ -- local newIsHidden = node.memoizedState ~= nil
+ -- if newIsHidden)
+ -- local primaryChildParent = node.child
+ -- if primaryChildParent ~= nil)
+ -- if primaryChildParent.child ~= nil)
+ -- primaryChildParent.child.return = primaryChildParent
+ -- appendAllChildren(
+ -- parent,
+ -- primaryChildParent,
+ -- true,
+ -- newIsHidden,
+ -- )
+ -- end
+ -- local fallbackChildParent = primaryChildParent.sibling
+ -- if fallbackChildParent ~= nil)
+ -- fallbackChildParent.return = node
+ -- node = fallbackChildParent
+ -- continue
+ -- end
+ -- end
+ -- end
+ -- end
+ -- if node.child ~= nil)
+ -- -- Continue traversing like normal
+ -- node.child.return = node
+ -- node = node.child
+ -- continue
+ -- end
+ -- } else if node.child ~= nil)
+ -- node.child.return = node
+ -- node = node.child
+ -- continue
+ -- end
+ -- -- $FlowFixMe This is correct but Flow is confused by the labeled break.
+ -- node = (node: Fiber)
+ -- if node == workInProgress)
+ -- return
+ -- end
+ -- while (node.sibling == nil)
+ -- if node.return == nil or node.return == workInProgress)
+ -- return
+ -- end
+ -- node = node.return
+ -- end
+ -- node.sibling.return = node.return
+ -- node = node.sibling
+ -- end
+ end
-- An unfortunate fork of appendAllChildren because we have two different parent types.
local function appendAllChildrenToContainer(
diff --git ORI/CorePackages/modules/ReactReconciler-9c8468d8-8a7220fd/src/ReactFiberNewContext.new.lua ALT/CorePackages/modules/ReactReconciler-9c8468d8-8a7220fd/src/ReactFiberNewContext.new.lua
index efef0c6..bccbd36 100644
--- ORI/CorePackages/modules/ReactReconciler-9c8468d8-8a7220fd/src/ReactFiberNewContext.new.lua
+++ ALT/CorePackages/modules/ReactReconciler-9c8468d8-8a7220fd/src/ReactFiberNewContext.new.lua
@@ -186,159 +186,166 @@ exports.scheduleWorkOnParentPath = function(parent: Fiber | nil, renderLanes: La
end
end
-exports.propagateContextChange =
- function<T>(workInProgress: Fiber, context: ReactContext<T>, changedBits: number, renderLanes: Lanes): ()
- local fiber = workInProgress.child
- if fiber ~= nil then
- -- Set the return pointer of the child to the work-in-progress fiber.
- fiber.return_ = workInProgress
- end
- while fiber ~= nil do
- local nextFiber
-
- -- Visit this fiber.
- local list = fiber.dependencies
- if list ~= nil then
- nextFiber = fiber.child
-
- local dependency = list.firstContext
- while dependency ~= nil do
- -- Check if the context matches.
- if
- dependency.context == context
- -- ROBLOX performance: unstable observedBits is removed in React 18
- and bit32.band(dependency.observedBits, changedBits) ~= 0
- then
- -- Match! Schedule an update on this fiber.
-
- if fiber.tag == ClassComponent then
- -- Schedule a force update on the work-in-progress.
- local update = createUpdate(NoTimestamp, pickArbitraryLane(renderLanes))
- update.tag = ForceUpdate
- -- TODO: Because we don't have a work-in-progress, this will add the
- -- update to the current fiber, too, which means it will persist even if
- -- this render is thrown away. Since it's a race condition, not sure it's
- -- worth fixing.
-
- -- Inlined `enqueueUpdate` to remove interleaved update check
- local updateQueue = fiber.updateQueue
- if updateQueue == nil then
- -- Only occurs if the fiber has been unmounted.
+exports.propagateContextChange = function<T>(
+ workInProgress: Fiber,
+ context: ReactContext<T>,
+ changedBits: number,
+ renderLanes: Lanes
+): ()
+ local fiber = workInProgress.child
+ if fiber ~= nil then
+ -- Set the return pointer of the child to the work-in-progress fiber.
+ fiber.return_ = workInProgress
+ end
+ while fiber ~= nil do
+ local nextFiber
+
+ -- Visit this fiber.
+ local list = fiber.dependencies
+ if list ~= nil then
+ nextFiber = fiber.child
+
+ local dependency = list.firstContext
+ while dependency ~= nil do
+ -- Check if the context matches.
+ if
+ dependency.context == context
+ -- ROBLOX performance: unstable observedBits is removed in React 18
+ and bit32.band(dependency.observedBits, changedBits) ~= 0
+ then
+ -- Match! Schedule an update on this fiber.
+
+ if fiber.tag == ClassComponent then
+ -- Schedule a force update on the work-in-progress.
+ local update = createUpdate(NoTimestamp, pickArbitraryLane(renderLanes))
+ update.tag = ForceUpdate
+ -- TODO: Because we don't have a work-in-progress, this will add the
+ -- update to the current fiber, too, which means it will persist even if
+ -- this render is thrown away. Since it's a race condition, not sure it's
+ -- worth fixing.
+
+ -- Inlined `enqueueUpdate` to remove interleaved update check
+ local updateQueue = fiber.updateQueue
+ if updateQueue == nil then
+ -- Only occurs if the fiber has been unmounted.
+ else
+ local sharedQueue: SharedQueue<any> = (updateQueue :: any).shared
+ local pending = sharedQueue.pending
+ if pending == nil then
+ -- This is the first update. Create a circular list.
+ update.next = update
else
- local sharedQueue: SharedQueue<any> = (updateQueue :: any).shared
- local pending = sharedQueue.pending
- if pending == nil then
- -- This is the first update. Create a circular list.
- update.next = update
- else
- update.next = pending.next
- pending.next = update
- end
- sharedQueue.pending = update
+ update.next = pending.next
+ pending.next = update
end
+ sharedQueue.pending = update
end
+ end
- -- ROBLOX performance: inline mergeLanes(fiber.lanes, renderLanes)
- fiber.lanes = bit32.bor(fiber.lanes, renderLanes)
- local alternate = fiber.alternate
- if alternate ~= nil then
- -- ROBLOX performance: inline mergeLanes(alternate.lanes, renderLanes)
- alternate.lanes = bit32.bor(alternate.lanes, renderLanes)
- end
- exports.scheduleWorkOnParentPath(fiber.return_, renderLanes)
+ -- ROBLOX performance: inline mergeLanes(fiber.lanes, renderLanes)
+ fiber.lanes = bit32.bor(fiber.lanes, renderLanes)
+ local alternate = fiber.alternate
+ if alternate ~= nil then
+ -- ROBLOX performance: inline mergeLanes(alternate.lanes, renderLanes)
+ alternate.lanes = bit32.bor(alternate.lanes, renderLanes)
+ end
+ exports.scheduleWorkOnParentPath(fiber.return_, renderLanes)
- -- Mark the updated lanes on the list, too.
- -- ROBLOX performance: inline mergeLanes(list.lanes, renderLanes)
- list.lanes = bit32.bor(list.lanes, renderLanes)
+ -- Mark the updated lanes on the list, too.
+ -- ROBLOX performance: inline mergeLanes(list.lanes, renderLanes)
+ list.lanes = bit32.bor(list.lanes, renderLanes)
- -- Since we already found a match, we can stop traversing the
- -- dependency list.
- break
- end
- dependency = dependency.next
- end
- elseif fiber.tag == ContextProvider then
- -- Don't scan deeper if this is a matching provider
- if fiber.type == workInProgress.type then
- nextFiber = nil
- else
- nextFiber = fiber.child
+ -- Since we already found a match, we can stop traversing the
+ -- dependency list.
+ break
end
- -- ROBLOX performance: eliminate always-false compare in tab switching hot path
- -- elseif
- -- enableSuspenseServerRenderer and
- -- fiber.tag == DehydratedFragment
- -- then
- -- -- If a dehydrated suspense boundary is in this subtree, we don't know
- -- -- if it will have any context consumers in it. The best we can do is
- -- -- mark it as having updates.
- -- local parentSuspense = fiber.return_
- -- if parentSuspense == nil then
- -- error("We just came from a parent so we must have had a parent. This is a bug in React.")
- -- end
- -- parentSuspense.lanes = mergeLanes(parentSuspense.lanes, renderLanes)
- -- local alternate = parentSuspense.alternate
- -- if alternate ~= nil then
- -- alternate.lanes = mergeLanes(alternate.lanes, renderLanes)
- -- end
- -- -- This is intentionally passing this fiber as the parent
- -- -- because we want to schedule this fiber as having work
- -- -- on its children. We'll use the childLanes on
- -- -- this fiber to indicate that a context has changed.
- -- exports.scheduleWorkOnParentPath(parentSuspense, renderLanes)
- -- nextFiber = fiber.sibling
+ dependency = dependency.next
+ end
+ elseif fiber.tag == ContextProvider then
+ -- Don't scan deeper if this is a matching provider
+ if fiber.type == workInProgress.type then
+ nextFiber = nil
else
- -- Traverse down.
nextFiber = fiber.child
end
+ -- ROBLOX performance: eliminate always-false compare in tab switching hot path
+ -- elseif
+ -- enableSuspenseServerRenderer and
+ -- fiber.tag == DehydratedFragment
+ -- then
+ -- -- If a dehydrated suspense boundary is in this subtree, we don't know
+ -- -- if it will have any context consumers in it. The best we can do is
+ -- -- mark it as having updates.
+ -- local parentSuspense = fiber.return_
+ -- if parentSuspense == nil then
+ -- error("We just came from a parent so we must have had a parent. This is a bug in React.")
+ -- end
+ -- parentSuspense.lanes = mergeLanes(parentSuspense.lanes, renderLanes)
+ -- local alternate = parentSuspense.alternate
+ -- if alternate ~= nil then
+ -- alternate.lanes = mergeLanes(alternate.lanes, renderLanes)
+ -- end
+ -- -- This is intentionally passing this fiber as the parent
+ -- -- because we want to schedule this fiber as having work
+ -- -- on its children. We'll use the childLanes on
+ -- -- this fiber to indicate that a context has changed.
+ -- exports.scheduleWorkOnParentPath(parentSuspense, renderLanes)
+ -- nextFiber = fiber.sibling
+ else
+ -- Traverse down.
+ nextFiber = fiber.child
+ end
- if nextFiber ~= nil then
- -- Set the return pointer of the child to the work-in-progress fiber.
- nextFiber.return_ = fiber
- else
- -- No child. Traverse to next sibling.
- nextFiber = fiber
- while nextFiber ~= nil do
- if nextFiber == workInProgress then
- -- We're back to the root of this subtree. Exit.
- nextFiber = nil
- break
- end
- local sibling = nextFiber.sibling
- if sibling ~= nil then
- -- Set the return pointer of the sibling to the work-in-progress fiber.
- sibling.return_ = nextFiber.return_
- nextFiber = sibling
- break
- end
- -- No more siblings. Traverse up.
- nextFiber = nextFiber.return_
+ if nextFiber ~= nil then
+ -- Set the return pointer of the child to the work-in-progress fiber.
+ nextFiber.return_ = fiber
+ else
+ -- No child. Traverse to next sibling.
+ nextFiber = fiber
+ while nextFiber ~= nil do
+ if nextFiber == workInProgress then
+ -- We're back to the root of this subtree. Exit.
+ nextFiber = nil
+ break
end
+ local sibling = nextFiber.sibling
+ if sibling ~= nil then
+ -- Set the return pointer of the sibling to the work-in-progress fiber.
+ sibling.return_ = nextFiber.return_
+ nextFiber = sibling
+ break
+ end
+ -- No more siblings. Traverse up.
+ nextFiber = nextFiber.return_
end
- fiber = nextFiber
end
+ fiber = nextFiber
end
+end
-- deviation: third argument added to eliminate cycle
-exports.prepareToReadContext =
- function(workInProgress: Fiber, renderLanes: Lanes, markWorkInProgressReceivedUpdate: () -> ()): ()
- currentlyRenderingFiber = workInProgress
- lastContextDependency = nil
- lastContextWithAllBitsObserved = nil
-
- local dependencies = workInProgress.dependencies
- if dependencies ~= nil then
- local firstContext = dependencies.firstContext
- if firstContext ~= nil then
- if includesSomeLane(dependencies.lanes, renderLanes) then
- -- Context list has a pending update. Mark that this fiber performed work.
- markWorkInProgressReceivedUpdate()
- end
- -- Reset the work-in-progress list
- dependencies.firstContext = nil
+exports.prepareToReadContext = function(
+ workInProgress: Fiber,
+ renderLanes: Lanes,
+ markWorkInProgressReceivedUpdate: () -> ()
+): ()
+ currentlyRenderingFiber = workInProgress
+ lastContextDependency = nil
+ lastContextWithAllBitsObserved = nil
+
+ local dependencies = workInProgress.dependencies
+ if dependencies ~= nil then
+ local firstContext = dependencies.firstContext
+ if firstContext ~= nil then
+ if includesSomeLane(dependencies.lanes, renderLanes) then
+ -- Context list has a pending update. Mark that this fiber performed work.
+ markWorkInProgressReceivedUpdate()
end
+ -- Reset the work-in-progress list
+ dependencies.firstContext = nil
end
end
+end
exports.readContext = function<T>(context: ReactContext<T>, observedBits: nil | number | boolean): T
if _G.__DEV__ then
diff --git ORI/CorePackages/modules/ReactReconciler-9c8468d8-8a7220fd/src/ReactFiberReconciler.new.lua ALT/CorePackages/modules/ReactReconciler-9c8468d8-8a7220fd/src/ReactFiberReconciler.new.lua
index 04660f2..57b5213 100644
--- ORI/CorePackages/modules/ReactReconciler-9c8468d8-8a7220fd/src/ReactFiberReconciler.new.lua
+++ ALT/CorePackages/modules/ReactReconciler-9c8468d8-8a7220fd/src/ReactFiberReconciler.new.lua
@@ -288,79 +288,83 @@ exports.createContainer = function(
return createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks)
end
-exports.updateContainer =
- function(element: ReactNodeList, container: OpaqueRoot, parentComponent, callback: Function?): Lane
- if _G.__DEV__ then
- onScheduleRoot(container, element)
- end
- local current = container.current
- local eventTime = requestEventTime()
- if _G.__DEV__ then
- -- deviation: use TestEZ's __TESTEZ_RUNNING_TEST__ (no jest global)
- -- $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
- if _G.__TESTEZ_RUNNING_TEST__ then
- warnIfUnmockedScheduler(current)
- warnIfNotScopedWithMatchingAct(current)
- end
+exports.updateContainer = function(
+ element: ReactNodeList,
+ container: OpaqueRoot,
+ parentComponent,
+ callback: Function?
+): Lane
+ if _G.__DEV__ then
+ onScheduleRoot(container, element)
+ end
+ local current = container.current
+ local eventTime = requestEventTime()
+ if _G.__DEV__ then
+ -- deviation: use TestEZ's __TESTEZ_RUNNING_TEST__ (no jest global)
+ -- $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
+ if _G.__TESTEZ_RUNNING_TEST__ then
+ warnIfUnmockedScheduler(current)
+ warnIfNotScopedWithMatchingAct(current)
end
- local lane = requestUpdateLane(current)
+ end
+ local lane = requestUpdateLane(current)
- if enableSchedulingProfiler then
- markRenderScheduled(lane)
- end
+ if enableSchedulingProfiler then
+ markRenderScheduled(lane)
+ end
- local context = getContextForSubtree(parentComponent)
- if container.context == nil then
- container.context = context
- else
- container.pendingContext = context
+ local context = getContextForSubtree(parentComponent)
+ if container.context == nil then
+ container.context = context
+ else
+ container.pendingContext = context
+ end
+
+ if _G.__DEV__ then
+ if ReactCurrentFiberIsRendering and ReactCurrentFiber.current ~= nil and not didWarnAboutNestedUpdates then
+ didWarnAboutNestedUpdates = true
+ console.error(
+ "Render methods should be a pure function of props and state; "
+ .. "triggering nested component updates from render is not allowed. "
+ .. "If necessary, trigger nested updates in componentDidUpdate.\n\n"
+ .. "Check the render method of %s.",
+ getComponentName((ReactCurrentFiber.current :: any).type) or "Unknown"
+ )
end
+ end
+
+ local update = createUpdate(eventTime, lane)
+ -- deviation: We need to set element to a placeholder so that it gets
+ -- removed from previous state when merging tables
+ if element == nil then
+ element = Object.None
+ end
+ -- Caution: React DevTools currently depends on this property
+ -- being called "element".
+ update.payload = {
+ element = element,
+ }
+ -- deviation: no undefined, so not needed
+ -- callback = callback == undefined ? nil : callback
+ if callback ~= nil then
if _G.__DEV__ then
- if ReactCurrentFiberIsRendering and ReactCurrentFiber.current ~= nil and not didWarnAboutNestedUpdates then
- didWarnAboutNestedUpdates = true
+ if typeof(callback) ~= "function" then
console.error(
- "Render methods should be a pure function of props and state; "
- .. "triggering nested component updates from render is not allowed. "
- .. "If necessary, trigger nested updates in componentDidUpdate.\n\n"
- .. "Check the render method of %s.",
- getComponentName((ReactCurrentFiber.current :: any).type) or "Unknown"
+ "render(...): Expected the last optional `callback` argument to be a "
+ .. "function. Instead received: %s.",
+ tostring(callback)
)
end
end
+ update.callback = callback
+ end
- local update = createUpdate(eventTime, lane)
- -- deviation: We need to set element to a placeholder so that it gets
- -- removed from previous state when merging tables
- if element == nil then
- element = Object.None
- end
- -- Caution: React DevTools currently depends on this property
- -- being called "element".
- update.payload = {
- element = element,
- }
-
- -- deviation: no undefined, so not needed
- -- callback = callback == undefined ? nil : callback
- if callback ~= nil then
- if _G.__DEV__ then
- if typeof(callback) ~= "function" then
- console.error(
- "render(...): Expected the last optional `callback` argument to be a "
- .. "function. Instead received: %s.",
- tostring(callback)
- )
- end
- end
- update.callback = callback
- end
-
- enqueueUpdate(current, update)
- scheduleUpdateOnFiber(current, lane, eventTime)
+ enqueueUpdate(current, update)
+ scheduleUpdateOnFiber(current, lane, eventTime)
- return lane
- end
+ return lane
+end
-- FIXME: WIP
exports.batchedEventUpdates = batchedEventUpdates
@@ -670,24 +674,28 @@ if _G.__DEV__ then
scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp)
end
end
- overrideHookStateRenamePath =
- function(fiber: Fiber, id: number, oldPath: Array<string | number>, newPath: Array<string | number>)
- local hook = findHook(fiber, id)
- if hook ~= nil then
- local newState = copyWithRename(hook.memoizedState, oldPath, newPath)
- hook.memoizedState = newState
- hook.baseState = newState
-
- -- We aren't actually adding an update to the queue,
- -- because there is no update we can add for useReducer hooks that won't trigger an error.
- -- (There's no appropriate action type for DevTools overrides.)
- -- As a result though, React will see the scheduled update as a noop and bailout.
- -- Shallow cloning props works as a workaround for now to bypass the bailout check.
- fiber.memoizedProps = Object.assign({}, fiber.memoizedProps)
-
- scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp)
- end
+ overrideHookStateRenamePath = function(
+ fiber: Fiber,
+ id: number,
+ oldPath: Array<string | number>,
+ newPath: Array<string | number>
+ )
+ local hook = findHook(fiber, id)
+ if hook ~= nil then
+ local newState = copyWithRename(hook.memoizedState, oldPath, newPath)
+ hook.memoizedState = newState
+ hook.baseState = newState
+
+ -- We aren't actually adding an update to the queue,
+ -- because there is no update we can add for useReducer hooks that won't trigger an error.
+ -- (There's no appropriate action type for DevTools overrides.)
+ -- As a result though, React will see the scheduled update as a noop and bailout.
+ -- Shallow cloning props works as a workaround for now to bypass the bailout check.
+ fiber.memoizedProps = Object.assign({}, fiber.memoizedProps)
+
+ scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp)
end
+ end
-- Support DevTools props for function components, forwardRef, memo, host components, etc.
overrideProps = function(fiber: Fiber, path: Array<string | number>, value: any)
diff --git ORI/CorePackages/modules/ReactReconciler-9c8468d8-8a7220fd/src/ReactFiberWorkLoop.new.lua ALT/CorePackages/modules/ReactReconciler-9c8468d8-8a7220fd/src/ReactFiberWorkLoop.new.lua
index 6436454..7be588f 100644
--- ORI/CorePackages/modules/ReactReconciler-9c8468d8-8a7220fd/src/ReactFiberWorkLoop.new.lua
+++ ALT/CorePackages/modules/ReactReconciler-9c8468d8-8a7220fd/src/ReactFiberWorkLoop.new.lua
@@ -2552,17 +2552,21 @@ mod.commitMutationEffectsImpl = function(fiber: Fiber, root: FiberRoot, renderPr
end
end
-mod.commitMutationEffectsDeletions =
- function(deletions: Array<Fiber>, fiber: Fiber, root: FiberRoot, renderPriorityLevel)
- -- ROBLOX performance: align to React 18, which ditches the __DEV__ branch and use of invokeGuardedCallback
- for _, childToDelete in deletions do
- -- ROBLOX FIXME Luau: CLI-49835, "Function only returns 1 value, 2 are required"
- local ok, error_ = xpcall(commitDeletion, describeError, root, childToDelete, fiber, renderPriorityLevel)
- if not ok then
- exports.captureCommitPhaseError(childToDelete, fiber, error_)
- end
+mod.commitMutationEffectsDeletions = function(
+ deletions: Array<Fiber>,
+ fiber: Fiber,
+ root: FiberRoot,
+ renderPriorityLevel
+)
+ -- ROBLOX performance: align to React 18, which ditches the __DEV__ branch and use of invokeGuardedCallback
+ for _, childToDelete in deletions do
+ -- ROBLOX FIXME Luau: CLI-49835, "Function only returns 1 value, 2 are required"
+ local ok, error_ = xpcall(commitDeletion, describeError, root, childToDelete, fiber, renderPriorityLevel)
+ if not ok then
+ exports.captureCommitPhaseError(childToDelete, fiber, error_)
end
end
+end
exports.schedulePassiveEffectCallback = function()
if not rootDoesHavePassiveEffects then
diff --git ORI/CorePackages/modules/ReactRoblox-9c8468d8-8a7220fd/src/client/ReactRobloxHostConfig.lua ALT/CorePackages/modules/ReactRoblox-9c8468d8-8a7220fd/src/client/ReactRobloxHostConfig.lua
index 3d820dc..8ba11f2 100644
--- ORI/CorePackages/modules/ReactRoblox-9c8468d8-8a7220fd/src/client/ReactRobloxHostConfig.lua
+++ ALT/CorePackages/modules/ReactRoblox-9c8468d8-8a7220fd/src/client/ReactRobloxHostConfig.lua
@@ -258,23 +258,26 @@ exports.getRootHostContext = function(rootContainerInstance: Container): HostCon
-- return namespace
end
-exports.getChildHostContext =
- function(parentHostContext: HostContext, type: string, rootContainerInstance: Container): HostContext
- -- ROBLOX deviation: unclear on the purpose here just yet, might be fine to
- -- just return parent's hostContext for now
- return parentHostContext
- -- if _G.__DEV__ then
- -- local parentHostContextDev = ((parentHostContext: any): HostContextDev)
- -- local namespace = getChildNamespace(parentHostContextDev.namespace, type)
- -- local ancestorInfo = updatedAncestorInfo(
- -- parentHostContextDev.ancestorInfo,
- -- type,
- -- )
- -- return {namespace, ancestorInfo}
- -- end
- -- local parentNamespace = ((parentHostContext: any): HostContextProd)
- -- return getChildNamespace(parentNamespace, type)
- end
+exports.getChildHostContext = function(
+ parentHostContext: HostContext,
+ type: string,
+ rootContainerInstance: Container
+): HostContext
+ -- ROBLOX deviation: unclear on the purpose here just yet, might be fine to
+ -- just return parent's hostContext for now
+ return parentHostContext
+ -- if _G.__DEV__ then
+ -- local parentHostContextDev = ((parentHostContext: any): HostContextDev)
+ -- local namespace = getChildNamespace(parentHostContextDev.namespace, type)
+ -- local ancestorInfo = updatedAncestorInfo(
+ -- parentHostContextDev.ancestorInfo,
+ -- type,
+ -- )
+ -- return {namespace, ancestorInfo}
+ -- end
+ -- local parentNamespace = ((parentHostContext: any): HostContextProd)
+ -- return getChildNamespace(parentNamespace, type)
+end
exports.getPublicInstance = function(instance: Instance): any
return instance
diff --git ORI/CorePackages/modules/Scheduler-9c8468d8-8a7220fd/src/Tracing.lua ALT/CorePackages/modules/Scheduler-9c8468d8-8a7220fd/src/Tracing.lua
index 4effdd3..dced0ba 100644
--- ORI/CorePackages/modules/Scheduler-9c8468d8-8a7220fd/src/Tracing.lua
+++ ALT/CorePackages/modules/Scheduler-9c8468d8-8a7220fd/src/Tracing.lua
@@ -219,129 +219,131 @@ exports.unstable_trace = function(name: string, timestamp: number, callback: Fun
return returnValue
end
-exports.unstable_wrap =
- function(callback: Function, threadID: number): any -- ROLBOX deviation: any, since __call doesn't map to Function
- -- ROBLOX: default argument value
- if threadID == nil then
- threadID = DEFAULT_THREAD_ID
- end
-
- if not enableSchedulerTracing then
- return callback
- end
+exports.unstable_wrap = function(
+ callback: Function,
+ threadID: number
+): any -- ROLBOX deviation: any, since __call doesn't map to Function
+ -- ROBLOX: default argument value
+ if threadID == nil then
+ threadID = DEFAULT_THREAD_ID
+ end
- local wrappedInteractions = interactionsRef.current
+ if not enableSchedulerTracing then
+ return callback
+ end
- local subscriber = subscriberRef.current
- if subscriber ~= nil then
- subscriber.onWorkScheduled(wrappedInteractions, threadID)
- end
+ local wrappedInteractions = interactionsRef.current
- -- Update the pending async work count for the current interactions.
- -- Update after calling subscribers in case of error.
- for _, interaction in wrappedInteractions do
- interaction.__count += 1
- end
+ local subscriber = subscriberRef.current
+ if subscriber ~= nil then
+ subscriber.onWorkScheduled(wrappedInteractions, threadID)
+ end
- local hasRun = false
+ -- Update the pending async work count for the current interactions.
+ -- Update after calling subscribers in case of error.
+ for _, interaction in wrappedInteractions do
+ interaction.__count += 1
+ end
- local function _wrapped(self, ...)
- local prevInteractions = interactionsRef.current
- interactionsRef.current = wrappedInteractions
+ local hasRun = false
- subscriber = subscriberRef.current
+ local function _wrapped(self, ...)
+ local prevInteractions = interactionsRef.current
+ interactionsRef.current = wrappedInteractions
- -- ROBLOX try
- local ok, result = pcall(function(...)
- local returnValue
+ subscriber = subscriberRef.current
- -- ROBLOX try 2
- local ok2, result2 = pcall(function()
- if subscriber ~= nil then
- subscriber.onWorkStarted(wrappedInteractions, threadID)
- end
- end)
- -- ROBLOX finally 2
- -- ROBLOX try 3
- local ok3, result3 = pcall(function(...)
- returnValue = callback(...)
- end, ...)
- -- ROBLOX finally 3
- interactionsRef.current = prevInteractions
+ -- ROBLOX try
+ local ok, result = pcall(function(...)
+ local returnValue
+ -- ROBLOX try 2
+ local ok2, result2 = pcall(function()
if subscriber ~= nil then
- subscriber.onWorkStopped(wrappedInteractions, threadID)
+ subscriber.onWorkStarted(wrappedInteractions, threadID)
end
-
- if not ok3 then
- error(result3)
- end
-
- if not ok2 then
- error(result2)
- end
-
- return returnValue
+ end)
+ -- ROBLOX finally 2
+ -- ROBLOX try 3
+ local ok3, result3 = pcall(function(...)
+ returnValue = callback(...)
end, ...)
+ -- ROBLOX finally 3
+ interactionsRef.current = prevInteractions
- -- ROBLOX finally {
- if not hasRun then
- -- We only expect a wrapped function to be executed once,
- -- But in the event that it's executed more than once–
- -- Only decrement the outstanding interaction counts once.
- hasRun = true
-
- -- Update pending async counts for all wrapped interactions.
- -- If this was the last scheduled async work for any of them,
- -- Mark them as completed.
- for _, interaction in wrappedInteractions do
- interaction.__count -= 1
-
- if subscriber ~= nil and interaction.__count == 0 then
- subscriber.onInteractionScheduledWorkCompleted(interaction)
- end
- end
+ if subscriber ~= nil then
+ subscriber.onWorkStopped(wrappedInteractions, threadID)
end
- if not ok then
- error(result)
+ if not ok3 then
+ error(result3)
end
- return result
- end
+ if not ok2 then
+ error(result2)
+ end
- local _cancel = function()
- subscriber = subscriberRef.current
+ return returnValue
+ end, ...)
+
+ -- ROBLOX finally {
+ if not hasRun then
+ -- We only expect a wrapped function to be executed once,
+ -- But in the event that it's executed more than once–
+ -- Only decrement the outstanding interaction counts once.
+ hasRun = true
- local ok, result = pcall(function()
- if subscriber ~= nil then
- subscriber.onWorkCanceled(wrappedInteractions, threadID)
- end
- end)
- --ROBLOX finally {
-- Update pending async counts for all wrapped interactions.
-- If this was the last scheduled async work for any of them,
-- Mark them as completed.
for _, interaction in wrappedInteractions do
interaction.__count -= 1
- if subscriber and interaction.__count == 0 then
+ if subscriber ~= nil and interaction.__count == 0 then
subscriber.onInteractionScheduledWorkCompleted(interaction)
end
end
+ end
- if not ok then
- error(result)
- end
+ if not ok then
+ error(result)
end
- local wrapped = {}
- setmetatable(wrapped, {
- __call = _wrapped,
- })
- wrapped.cancel = _cancel
+ return result
+ end
+
+ local _cancel = function()
+ subscriber = subscriberRef.current
- return wrapped
+ local ok, result = pcall(function()
+ if subscriber ~= nil then
+ subscriber.onWorkCanceled(wrappedInteractions, threadID)
+ end
+ end)
+ --ROBLOX finally {
+ -- Update pending async counts for all wrapped interactions.
+ -- If this was the last scheduled async work for any of them,
+ -- Mark them as completed.
+ for _, interaction in wrappedInteractions do
+ interaction.__count -= 1
+
+ if subscriber and interaction.__count == 0 then
+ subscriber.onInteractionScheduledWorkCompleted(interaction)
+ end
+ end
+
+ if not ok then
+ error(result)
+ end
end
+ local wrapped = {}
+ setmetatable(wrapped, {
+ __call = _wrapped,
+ })
+ wrapped.cancel = _cancel
+
+ return wrapped
+end
+
return exports
|
Extension on #512
Closes #595