Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
instantiateReactComponent(elementToInstantiate) {
// console.log('instantiating react component', elementToInstantiate);
let instance;
let node = elementToInstantiate;
if (node === null || node === false) {
node = new ReactEmptyComponent(this.instantiateReactComponent);
} else if (typeof node === 'object') {
const element = node;
if (!(element && (typeof element.type === 'function' || typeof element.type === 'string'))) {
if (process.env.NODE_ENV !== 'production') {
if (element.type === null) {
invariant(false,
'Element type is invalid: expected a string (for built-in components) '
+ 'or a class/function (for composite components) but got: %s.%s',
element.type, getDeclarationErrorAddendum(element._owner));
} else {
invariant(false,
'Element type is invalid: expected a string (for built-in components) '
+ 'or a class/function (for composite components) but got: %s.%s',
typeof element.type, getDeclarationErrorAddendum(element._owner));
}
} else {
invariant(false);
}
}
// Special case string values
if (typeof element.type === 'string') {
setParent(texture, parent) {
if (parent instanceof THREE.Material) {
const { _materialSlot: slot } = texture.userData;
if (process.env.NODE_ENV !== 'production') {
this.validateParentSlot(parent, slot);
}
this.addToSlotOfMaterial(parent, slot, texture);
} else if (parent instanceof Uniform) { // Uniform as per the assert above
parent.setValue(texture);
} else {
invariant(false,
'Parent of a texture is not a material nor a uniform, it needs to be one of them.');
}
super.setParent(texture, parent);
}
export function usePixiAppCreator(props) {
const { app } = props;
invariant(app == null || app instanceof PIXI.Application, "Provided `app` has to be an instance of PIXI.Application");
const { options, width, height } = props;
const [appInstance, setAppInstance] = useState(null);
const canvasRef = useRef();
const canvas = getCanvas(props, canvasRef);
// Initialize pixi application on mount
useLayoutEffect(() => {
const unmount = createUnmount(ReactPixiFiberAsSecondaryRenderer);
const view = canvasRef.current;
const appInstance = app || createPixiApplication({ height, width, view, ...options });
setAppInstance(appInstance);
// Destroy pixi application on unmount
return () => {
refreshControl,
stickyHeaderIndices,
pagingEnabled,
/* eslint-disable */
keyboardDismissMode,
onScroll,
/* eslint-enable */
...other
} = this.props;
if (process.env.NODE_ENV !== 'production' && this.props.style) {
const style = StyleSheet.flatten(this.props.style);
const childLayoutProps = ['alignItems', 'justifyContent'].filter(
prop => style && style[prop] !== undefined
);
invariant(
childLayoutProps.length === 0,
`ScrollView child layout (${JSON.stringify(childLayoutProps)}) ` +
'must be applied through the contentContainerStyle prop.'
);
}
let contentSizeChangeProps = {};
if (onContentSizeChange) {
contentSizeChangeProps = {
onLayout: this._handleContentOnLayout
};
}
const hasStickyHeaderIndices = !horizontal && Array.isArray(stickyHeaderIndices);
const children =
hasStickyHeaderIndices || pagingEnabled
export function render(element, container, callback = undefined) {
invariant(
Container.prototype.isPrototypeOf(container),
'Invalid argument `container`, expected instance of `PIXI.Container`.'
)
let root = roots.get(container)
if (!root) {
// get the flushed fiber container
root = PixiFiber.createContainer(container)
roots.set(container, root)
}
// schedules a top level update
PixiFiber.updateContainer(element, root, undefined, callback)
// inject into react devtools
injectDevtools()
setNativeView(animatedView) {
if (this._animatedView === animatedView) {
return;
}
this._animatedView = animatedView;
const nativeViewTag = findNodeHandle(this._animatedView);
invariant(
nativeViewTag != null,
'Unable to locate attached view in the native tree'
);
this._connectAnimatedView(nativeViewTag);
}
removeAllListeners(eventType) {
invariant(eventType, 'eventType argument is required.');
const count = this.listeners(eventType).length;
if (this._nativeModule != null) {
this._nativeModule.removeListeners(count);
}
super.removeAllListeners(eventType);
}
removeSubscription(subscription) {
function assertFragmentMap(componentName, fragmentSpec) {
invariant(fragmentSpec && _typeof(fragmentSpec) === 'object', 'Could not create Relay Container for `%s`. ' + 'Expected a set of GraphQL fragments, got `%s` instead.', componentName, fragmentSpec);
for (var key in fragmentSpec) {
if (fragmentSpec.hasOwnProperty(key)) {
var fragment = fragmentSpec[key];
invariant(fragment && (_typeof(fragment) === 'object' || typeof fragment === 'function'), 'Could not create Relay Container for `%s`. ' + 'The value of fragment `%s` was expected to be a fragment, got `%s` instead.', componentName, key, fragment);
}
}
}
_getFrameMetrics = (
index: number,
): ?{
length: number,
offset: number,
index: number,
inLayout?: boolean,
} => {
const {
data,
getItem,
getItemCount,
getItemLayout,
keyExtractor,
} = this.props;
invariant(
getItemCount(data) > index,
'Tried to get frame for out of range index ' + index,
);
const item = getItem(data, index);
let frame = item && this._frames[keyExtractor(item, index)];
if (!frame || frame.index !== index) {
if (getItemLayout) {
frame = getItemLayout(data, index);
if (__DEV__) {
const frameType = PropTypes.shape({
length: PropTypes.number.isRequired,
offset: PropTypes.number.isRequired,
index: PropTypes.number.isRequired,
}).isRequired;
PropTypes.checkPropTypes(
{frame: frameType},
if (!(componentOrElement.render === null || typeof componentOrElement.render !== 'function')) {
if (process.env.NODE_ENV !== 'production') {
invariant(false, 'Component (with keys: %s) contains `render` method ' +
'but is not mounted', Object.keys(componentOrElement));
} else {
invariant(false);
}
}
if (process.env.NODE_ENV !== 'production') {
invariant(false,
'Element appears to be neither ReactComponent, ' +
'a THREE.js object, nor a HTMLCanvasElement (keys: %s)',
Object.keys(componentOrElement));
} else {
invariant(false);
}
return null;
}