-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
18 changed files
with
223 additions
and
112 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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"version": "independent", | ||
"packages": ["packages/*", "e2e/*"], | ||
"packages": ["packages/*", "packages/examples/*", "e2e/*"], | ||
"npmClient": "yarn" | ||
} |
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
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
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
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 |
---|---|---|
|
@@ -24,7 +24,8 @@ | |
], | ||
"devDependencies": { | ||
"ast-types": "^0.14.2", | ||
"react-reconciler": "0.26.0", | ||
"react-reconciler-26": "npm:[email protected]", | ||
"react-reconciler-31": "npm:[email protected]", | ||
"recast": "^0.23.9" | ||
} | ||
} |
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 |
---|---|---|
@@ -1,46 +1,11 @@ | ||
/* eslint-disable import/extensions */ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import Reconciler from 'react-reconciler/cjs/react-reconciler.production.min.js'; | ||
|
||
import propsEqual from './propsEqual'; | ||
import React from 'react'; | ||
import createRendererForReact19 from './reconciler-31'; | ||
import createRendererForReact18AndLess from './reconciler-26'; | ||
|
||
const emptyObject = {}; | ||
const isReact19 = React.version.startsWith('19'); | ||
|
||
const createRenderer = ({ | ||
appendChild, | ||
appendChildToContainer, | ||
commitTextUpdate, | ||
commitUpdate, | ||
createInstance, | ||
createTextInstance, | ||
insertBefore, | ||
removeChild, | ||
removeChildFromContainer, | ||
resetAfterCommit, | ||
}) => { | ||
return Reconciler({ | ||
appendChild, | ||
appendChildToContainer, | ||
appendInitialChild: appendChild, | ||
createInstance, | ||
createTextInstance, | ||
insertBefore, | ||
commitUpdate, | ||
commitTextUpdate, | ||
removeChild, | ||
removeChildFromContainer, | ||
resetAfterCommit, | ||
shouldSetTextContent: () => false, | ||
finalizeInitialChildren: () => false, | ||
getPublicInstance: (instance) => instance, | ||
getRootHostContext: () => emptyObject, | ||
getChildHostContext: () => emptyObject, | ||
prepareForCommit() {}, | ||
clearContainer() {}, | ||
resetTextContent() {}, | ||
prepareUpdate: (element, type, oldProps, newProps) => | ||
!propsEqual(oldProps, newProps), | ||
}); | ||
}; | ||
|
||
export default createRenderer; | ||
export default isReact19 | ||
? createRendererForReact19 | ||
: createRendererForReact18AndLess; |
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,46 @@ | ||
/* eslint-disable import/extensions */ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import Reconciler from 'react-reconciler-26/cjs/react-reconciler.production.min.js'; | ||
|
||
import propsEqual from './propsEqual'; | ||
|
||
const emptyObject = {}; | ||
|
||
const createRenderer = ({ | ||
appendChild, | ||
appendChildToContainer, | ||
commitTextUpdate, | ||
commitUpdate, | ||
createInstance, | ||
createTextInstance, | ||
insertBefore, | ||
removeChild, | ||
removeChildFromContainer, | ||
resetAfterCommit, | ||
}) => { | ||
return Reconciler({ | ||
appendChild, | ||
appendChildToContainer, | ||
appendInitialChild: appendChild, | ||
createInstance, | ||
createTextInstance, | ||
insertBefore, | ||
commitUpdate, | ||
commitTextUpdate, | ||
removeChild, | ||
removeChildFromContainer, | ||
resetAfterCommit, | ||
shouldSetTextContent: () => false, | ||
finalizeInitialChildren: () => false, | ||
getPublicInstance: (instance) => instance, | ||
getRootHostContext: () => emptyObject, | ||
getChildHostContext: () => emptyObject, | ||
prepareForCommit() {}, | ||
clearContainer() {}, | ||
resetTextContent() {}, | ||
prepareUpdate: (element, type, oldProps, newProps) => | ||
!propsEqual(oldProps, newProps), | ||
}); | ||
}; | ||
|
||
export default createRenderer; |
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,93 @@ | ||
/* eslint-disable import/extensions */ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
|
||
import Reconciler from 'react-reconciler-31/cjs/react-reconciler.production.js'; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
diegomura
Author
Owner
|
||
import { | ||
ConcurrentRoot, | ||
DefaultEventPriority, | ||
} from 'react-reconciler-31/cjs/react-reconciler-constants.production.js'; | ||
|
||
import propsEqual from './propsEqual'; | ||
|
||
const emptyObject = {}; | ||
|
||
const logRecoverableError = console.error; | ||
|
||
const createRenderer = ({ | ||
appendChild, | ||
appendChildToContainer, | ||
commitTextUpdate, | ||
commitUpdate, | ||
createInstance, | ||
createTextInstance, | ||
insertBefore, | ||
removeChild, | ||
removeChildFromContainer, | ||
resetAfterCommit, | ||
}) => { | ||
const _commitUpdate = (instance, type, oldProps, newProps) => { | ||
if (propsEqual(oldProps, newProps)) return; | ||
commitUpdate(instance, null, type, oldProps, newProps); | ||
}; | ||
|
||
const reconciler = Reconciler({ | ||
supportsMutation: true, | ||
isPrimaryRenderer: false, | ||
warnsIfNotActing: false, | ||
appendInitialChild: appendChild, | ||
createInstance, | ||
createTextInstance, | ||
finalizeInitialChildren: () => false, | ||
getPublicInstance: (instance) => instance, | ||
prepareForCommit() {}, | ||
clearContainer() {}, | ||
resetAfterCommit, | ||
resetTextContent() {}, | ||
getRootHostContext: () => emptyObject, | ||
getChildHostContext: () => emptyObject, | ||
shouldSetTextContent: () => false, | ||
noTimeout: -1, | ||
useSyncScheduling: true, | ||
appendChild, | ||
appendChildToContainer, | ||
insertBefore, | ||
removeChild, | ||
removeChildFromContainer, | ||
commitTextUpdate, | ||
commitUpdate: _commitUpdate, | ||
getCurrentUpdatePriority: () => DefaultEventPriority, | ||
setCurrentUpdatePriority: () => {}, | ||
resolveUpdatePriority: () => DefaultEventPriority, | ||
shouldAttemptEagerTransition: () => false, | ||
requestPostPaintCallback: () => {}, | ||
maySuspendCommit: () => false, | ||
}); | ||
|
||
const createContainer = (container) => { | ||
return reconciler.createContainer( | ||
container, | ||
ConcurrentRoot, // tag | ||
null, // hydration callbacks | ||
false, // isStrictMode | ||
null, // concurrentUpdatesByDefaultOverride | ||
'', // identifierPrefix | ||
logRecoverableError, // onUncaughtError | ||
logRecoverableError, // onCaughtError | ||
logRecoverableError, // onRecoverableError | ||
null, // transitionCallbacks | ||
); | ||
}; | ||
|
||
const updateContainer = (doc, mountNode, parentComponent, callback) => { | ||
reconciler.updateContainerSync(doc, mountNode, parentComponent, callback); | ||
reconciler.flushSyncWork(); | ||
}; | ||
|
||
return { | ||
...reconciler, | ||
createContainer, | ||
updateContainer, | ||
}; | ||
}; | ||
|
||
export default createRenderer; |
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
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
Oops, something went wrong.
IIRC this won't work in dev since React package expects the development bundle for e.g. fast refresh, debugging etc