Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-cosmos-renderer

Package Overview
Dependencies
Maintainers
1
Versions
180
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-cosmos-renderer - npm Package Compare versions

Comparing version 6.0.0-canary.95935ad.0 to 6.0.0-canary.9bbd672.0

3

dist/fixture/useSelect/useCreateFixtureState.js

@@ -31,3 +31,4 @@ import React, { useEffect } from 'react';

});
}, [args.options, defaultValue, selectName, setFixtureState]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [String(args.options), defaultValue, selectName, setFixtureState]);
}
import React from 'react';
import { getFixtureListFromWrappers, isInsideWindowIframe, } from 'react-cosmos-core';
import { DelayRender, getFixtureListFromWrappers, } from 'react-cosmos-core';
import { RendererSync } from './RendererSync.js';

@@ -8,5 +8,3 @@ export function FixtureLoaderConnect({ moduleWrappers, fixtureSelection, renderMessage, renderFixture, }) {

if (!fixtureSelection) {
return isInsideWindowIframe()
? null
: renderMessage('No fixture selected.');
return (React.createElement(DelayRender, { delay: 500 }, renderMessage('No fixture selected.')));
}

@@ -13,0 +11,0 @@ const { fixtureId } = fixtureSelection;

@@ -5,4 +5,3 @@ 'use client';

export function RendererSync({ children, fixtures }) {
const { searchParams, rendererId, rendererConnect, reloadRenderer, lazyItems, } = React.useContext(RendererContext);
const { fixtureId: selectedFixtureId } = searchParams;
const { params: { fixtureId: selectedFixtureId }, rendererId, rendererConnect, reloadRenderer, lazyItems, } = React.useContext(RendererContext);
const readyRef = React.useRef(false);

@@ -9,0 +8,0 @@ React.useEffect(() => {

@@ -5,17 +5,20 @@ 'use client';

export function ServerFixtureChangeListener({ children }) {
const { rendererId, rendererConnect, searchParams, setSearchParams } = React.useContext(RendererContext);
const { rendererId, rendererConnect, params, setParams } = React.useContext(RendererContext);
React.useEffect(() => rendererConnect.onMessage(msg => {
if (!searchParams.locked &&
if (!params.locked &&
msg.type === 'selectFixture' &&
msg.payload.rendererId === rendererId) {
const { fixtureId } = msg.payload;
setSearchParams({ fixtureId });
setParams({
fixtureId,
key: (params.key ?? 0) + 1,
});
}
else if (!searchParams.locked &&
else if (!params.locked &&
msg.type === 'unselectFixture' &&
msg.payload.rendererId === rendererId) {
setSearchParams({});
setParams({});
}
}), [rendererConnect, rendererId, searchParams.locked, setSearchParams]);
}), [params.key, params.locked, rendererConnect, rendererId, setParams]);
return React.createElement(React.Fragment, null, children);
}
import React from 'react';
import { ReactDecorator, StringRendererSearchParams, UserModuleWrappers } from 'react-cosmos-core';
import { ReactDecorator, RendererParams, UserModuleWrappers } from 'react-cosmos-core';
type Props = {
searchParams: StringRendererSearchParams;
params: RendererParams;
moduleWrappers: UserModuleWrappers;

@@ -9,3 +9,3 @@ globalDecorators?: ReactDecorator[];

};
export declare function ServerFixtureLoader({ searchParams, moduleWrappers, globalDecorators, renderMessage, }: Props): JSX.Element;
export declare function ServerFixtureLoader({ params, moduleWrappers, globalDecorators, renderMessage, }: Props): JSX.Element;
export {};
import React, { Suspense } from 'react';
import { decodeRendererSearchParams, } from 'react-cosmos-core';
import { FixtureModule } from '../fixtureModule/FixtureModule.js';

@@ -8,8 +7,8 @@ import { AsyncModuleLoader } from '../moduleLoaders/AsyncModuleLoader.js';

import { defaultRenderMessage } from './defaultRenderMessage.js';
export function ServerFixtureLoader({ searchParams, moduleWrappers, globalDecorators, renderMessage = defaultRenderMessage, }) {
const { fixtureId = null } = decodeRendererSearchParams(searchParams);
export function ServerFixtureLoader({ params, moduleWrappers, globalDecorators, renderMessage = defaultRenderMessage, }) {
const { fixtureId = null, key = 0 } = params;
const fixtureSelection = fixtureId && {
fixtureId,
initialFixtureState: {},
renderKey: 0,
renderKey: key,
};

@@ -16,0 +15,0 @@ return (React.createElement(ServerFixtureChangeListener, null,

import React from 'react';
import { RendererContext } from '../rendererConnect/RendererContext.js';
export function useFixtureSelection() {
const { rendererId, rendererConnect, searchParams } = React.useContext(RendererContext);
const { fixtureId: selectedFixtureId = null } = searchParams;
const { rendererId, rendererConnect, params } = React.useContext(RendererContext);
const { fixtureId: selectedFixtureId = null } = params;
const [selection, setSelection] = React.useState(() => selectedFixtureId && {

@@ -12,3 +12,3 @@ fixtureId: selectedFixtureId,

React.useEffect(() => rendererConnect.onMessage(msg => {
if (!searchParams.locked &&
if (!params.locked &&
msg.type === 'selectFixture' &&

@@ -25,3 +25,3 @@ msg.payload.rendererId === rendererId) {

}
else if (!searchParams.locked &&
else if (!params.locked &&
msg.type === 'unselectFixture' &&

@@ -31,4 +31,4 @@ msg.payload.rendererId === rendererId) {

}
}), [rendererConnect, rendererId, searchParams.locked]);
}), [params.locked, rendererConnect, rendererId]);
return selection;
}
import React from 'react';
import { FixtureList, RendererConnect, RendererSearchParams } from 'react-cosmos-core';
import { FixtureList, RendererConnect, RendererParams } from 'react-cosmos-core';
export type RendererContextValue = {
rendererId: string;
rendererConnect: RendererConnect;
searchParams: RendererSearchParams;
setSearchParams(nextParams: RendererSearchParams): void;
params: RendererParams;
setParams(nextParams: RendererParams): void;
reloadRenderer(): void;

@@ -9,0 +9,0 @@ lazyItems: FixtureList;

@@ -8,4 +8,4 @@ import React from 'react';

},
searchParams: {},
setSearchParams: () => { },
params: {},
setParams: () => { },
reloadRenderer: () => { },

@@ -12,0 +12,0 @@ lazyItems: {},

import React from 'react';
import { RendererConnect, RendererSearchParams } from 'react-cosmos-core';
import { RendererConnect, RendererParams } from 'react-cosmos-core';
export type Props = {

@@ -7,6 +7,6 @@ children: React.ReactNode;

rendererConnect: RendererConnect;
searchParams: RendererSearchParams;
setSearchParams(nextParams: RendererSearchParams): void;
params: RendererParams;
setParams(nextParams: RendererParams): void;
reloadRenderer(): void;
};
export declare function RendererProvider(props: Props): JSX.Element;

@@ -10,4 +10,4 @@ 'use client';

rendererConnect: props.rendererConnect,
searchParams: props.searchParams,
setSearchParams: props.setSearchParams,
params: props.params,
setParams: props.setParams,
reloadRenderer: props.reloadRenderer,

@@ -19,9 +19,9 @@ lazyItems,

lazyItems,
props.params,
props.reloadRenderer,
props.rendererConnect,
props.rendererId,
props.searchParams,
props.setSearchParams,
props.setParams,
]);
return (React.createElement(RendererContext.Provider, { value: value }, props.children));
}
{
"name": "react-cosmos-renderer",
"version": "6.0.0-canary.95935ad.0+95935ad",
"version": "6.0.0-canary.9bbd672.0+9bbd672",
"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.0.0-canary.95935ad.0+95935ad",
"react-cosmos-core": "6.0.0-canary.9bbd672.0+9bbd672",
"react-is": "^18.2.0"
},
"gitHead": "95935ad289b68fa1cf889feb98b90beb69931ad3"
"gitHead": "9bbd672cd6bd6c2955c8d7c527c6ef1e48d1684f"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc