react-cosmos-renderer
Advanced tools
Comparing version 6.1.2-canary.fbe721b.0 to 6.2.0
@@ -0,4 +1,4 @@ | ||
export * from './fixture/ClassStateMock.js'; | ||
export * from './fixture/FixtureCapture/FixtureCapture.js'; | ||
export * from './fixture/FixtureContext.js'; | ||
export * from './fixture/Viewport.js'; | ||
export * from './fixture/useFixtureInput/useFixtureInput.js'; | ||
@@ -9,2 +9,3 @@ export * from './fixture/useFixtureInput/useValue.js'; | ||
export * from './fixture/useFixtureState.js'; | ||
export * from './fixture/Viewport.js'; | ||
export * from './fixtureLoaders/ClientFixtureLoader.js'; | ||
@@ -11,0 +12,0 @@ export * from './rendererConnect/RendererContext.js'; |
@@ -0,4 +1,4 @@ | ||
export * from './fixture/ClassStateMock.js'; | ||
export * from './fixture/FixtureCapture/FixtureCapture.js'; | ||
export * from './fixture/FixtureContext.js'; | ||
export * from './fixture/Viewport.js'; | ||
export * from './fixture/useFixtureInput/useFixtureInput.js'; | ||
@@ -9,2 +9,3 @@ export * from './fixture/useFixtureInput/useValue.js'; | ||
export * from './fixture/useFixtureState.js'; | ||
export * from './fixture/Viewport.js'; | ||
export * from './fixtureLoaders/ClientFixtureLoader.js'; | ||
@@ -11,0 +12,0 @@ export * from './rendererConnect/RendererContext.js'; |
export declare function getChildrenPath(elPath: string): string; | ||
export declare function isRootPath(elPath: string): boolean; | ||
export declare function isRootPath(elPath: string): elPath is ""; |
@@ -5,6 +5,7 @@ import React from 'react'; | ||
fixture: ReactFixture; | ||
fixtureOptions: {}; | ||
userDecoratorModules: ReactDecoratorModule[]; | ||
globalDecorators?: ReactDecorator[]; | ||
}; | ||
export declare function DecoratedFixture({ fixture, userDecoratorModules, globalDecorators, }: Props): React.ReactElement<any, string | React.JSXElementConstructor<any>>; | ||
export declare function DecoratedFixture({ fixture, fixtureOptions, userDecoratorModules, globalDecorators, }: Props): React.ReactElement<any, string | React.JSXElementConstructor<any>>; | ||
export {}; |
@@ -5,10 +5,10 @@ import React, { useMemo } from 'react'; | ||
import { decorateFixture } from './decorateFixture.js'; | ||
export function DecoratedFixture({ fixture, userDecoratorModules, globalDecorators = [], }) { | ||
export function DecoratedFixture({ fixture, fixtureOptions, userDecoratorModules, globalDecorators = [], }) { | ||
return useMemo(() => { | ||
const decorators = [ | ||
...globalDecorators, | ||
...userDecoratorModules.map(m => m.default), | ||
...userDecoratorModules.map(m => m.default).flat(), | ||
]; | ||
return decorateFixture(React.createElement(FixtureCapture, { decoratorId: "root" }, createFixtureNode(fixture)), decorators); | ||
}, [fixture, globalDecorators, userDecoratorModules]); | ||
return decorateFixture(React.createElement(FixtureCapture, { decoratorId: "root" }, createFixtureNode(fixture)), fixtureOptions, decorators); | ||
}, [fixture, fixtureOptions, globalDecorators, userDecoratorModules]); | ||
} |
import React from 'react'; | ||
import { ReactDecorator } from 'react-cosmos-core'; | ||
export declare function decorateFixture(fixtureNode: React.ReactNode, decorators: ReactDecorator[]): React.ReactElement; | ||
export declare function decorateFixture(fixtureNode: React.ReactNode, fixtureOptions: {}, decorators: ReactDecorator[]): React.ReactElement; |
import React from 'react'; | ||
export function decorateFixture(fixtureNode, decorators) { | ||
return (React.createElement(React.Fragment, null, [...decorators].reverse().reduce((prevElement, Decorator) => (React.createElement(Decorator, null, prevElement)), fixtureNode))); | ||
export function decorateFixture(fixtureNode, fixtureOptions, decorators) { | ||
return (React.createElement(React.Fragment, null, [...decorators].reverse().reduce((prevElement, Decorator) => (React.createElement(Decorator, { options: fixtureOptions }, prevElement)), fixtureNode))); | ||
} |
@@ -1,2 +0,1 @@ | ||
/// <reference types="react/experimental" /> | ||
import React from 'react'; | ||
@@ -14,3 +13,3 @@ import { FixtureId, FixtureState, ReactDecorator, ReactDecoratorModule, ReactFixtureModule } from 'react-cosmos-core'; | ||
}; | ||
export declare function FixtureModule({ fixtureModule, decoratorModules, globalDecorators, fixtureId, initialFixtureState, renderKey, lazy, renderMessage, }: Props): string | number | boolean | Iterable<React.ReactNode> | React.PromiseLikeOfReactNode | React.JSX.Element | null | undefined; | ||
export declare function FixtureModule({ fixtureModule, decoratorModules, globalDecorators, fixtureId, initialFixtureState, renderKey, lazy, renderMessage, }: Props): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<React.AwaitedReactNode> | React.JSX.Element | null | undefined; | ||
export {}; |
import React from 'react'; | ||
import { getFixtureFromExport, getFixtureItemFromExport, stringifyFixtureId, } from 'react-cosmos-core'; | ||
import { getFixtureFromExport, getFixtureItemFromExport, pickSerializableValues, stringifyFixtureId, } from 'react-cosmos-core'; | ||
import { DecoratedFixture } from './DecoratedFixture.js'; | ||
@@ -9,7 +9,9 @@ import { FixtureProvider } from './FixtureProvider.js'; | ||
const fixture = getFixtureFromExport(fixtureModule.default, fixtureId.name); | ||
const { options = {} } = fixtureModule; | ||
const serializableOptions = React.useMemo(() => pickSerializableValues(options), [options]); | ||
if (typeof fixture === 'undefined') { | ||
return renderMessage(`Invalid fixture name: ${fixtureId.name}`); | ||
} | ||
return (React.createElement(FixtureProvider, { key: fixtureKey, fixtureId: fixtureId, initialFixtureState: initialFixtureState, fixtureItem: fixtureItem, lazy: lazy }, | ||
React.createElement(DecoratedFixture, { fixture: fixture, userDecoratorModules: decoratorModules, globalDecorators: globalDecorators }))); | ||
return (React.createElement(FixtureProvider, { key: fixtureKey, fixtureId: fixtureId, initialFixtureState: initialFixtureState, fixtureItem: fixtureItem, fixtureOptions: serializableOptions, lazy: lazy }, | ||
React.createElement(DecoratedFixture, { fixture: fixture, fixtureOptions: options, userDecoratorModules: decoratorModules, globalDecorators: globalDecorators }))); | ||
} |
@@ -8,2 +8,3 @@ import React from 'react'; | ||
fixtureItem: FixtureListItem; | ||
fixtureOptions: {}; | ||
lazy: boolean; | ||
@@ -10,0 +11,0 @@ }; |
@@ -28,5 +28,6 @@ 'use client'; | ||
fixture: props.fixtureItem, | ||
fixtureOptions: props.fixtureOptions, | ||
}, | ||
}); | ||
}, [props.fixtureItem, rendererConnect, rendererId]); | ||
}, [props.fixtureItem, props.fixtureOptions, rendererConnect, rendererId]); | ||
React.useEffect(() => { | ||
@@ -33,0 +34,0 @@ if (!isEqual(state.fixtureState, state.syncedFixtureState)) { |
{ | ||
"name": "react-cosmos-renderer", | ||
"version": "6.1.2-canary.fbe721b.0+fbe721b", | ||
"version": "6.2.0", | ||
"description": "React Cosmos Renderer", | ||
@@ -15,6 +15,6 @@ "repository": "https://github.com/react-cosmos/react-cosmos/tree/main/packages/react-cosmos-renderer", | ||
"lodash-es": "4.17.21", | ||
"react-cosmos-core": "6.1.2-canary.fbe721b.0+fbe721b", | ||
"react-is": "18.2.0" | ||
"react-cosmos-core": "^6.2.0", | ||
"react-is": "18.3.1" | ||
}, | ||
"gitHead": "fbe721b177adcb666317b6d1f4e4890d85de269b" | ||
"gitHead": "965bf0e13230324699560be6eabb642c51c6d945" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
76640
9334
112
1637
1
0
1
+ Addedjs-base64@3.7.7(transitive)
+ Addedreact-cosmos-core@6.2.0(transitive)
+ Addedreact-is@18.3.1(transitive)
- Removedreact-is@18.2.0(transitive)
Updatedreact-cosmos-core@^6.2.0
Updatedreact-is@18.3.1