New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-cosmos-renderer

Package Overview
Dependencies
Maintainers
1
Versions
189
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.1.2-canary.4cc91ba.0 to 6.1.2-canary.4d8d920.0

21

dist/fixtureModule/createFixtureNode.js
import React from 'react';
import { isElement } from 'react-is';
export function createFixtureNode(fixture) {
// Warning: In a React Server Components setup this function is called on the
// server. When a fixture module uses the 'use client' directive, the fixture
// arg received here will be a function wrapper regardless of the fixture
// module contents. In this scenario, the fixture module will be automatically
// rendered on the client side, where React expects a component default export.
// export will be a Promise wrapper (imbued with magical properties methinks).
// This results in the following limitation: In a React Server Components
// setup, Client fixtures have to export a single function component. They
// can't be multi fixtures and they can't export React elements directly.
return isFunctionFixture(fixture) ? (React.createElement(FixtureElement, { Component: fixture })) : (fixture);
return isNodeFixture(fixture) ? (fixture) : (React.createElement(FixtureElement, { Component: fixture }));
}
function isFunctionFixture(fixture) {
return typeof fixture === 'function';
function isNodeFixture(fixture) {
// If you're curious what the exact type of ReactNode is:
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/6fc4839a810335dee15374e6bc82dbbc2bbdff58/types/react/index.d.ts#L478-L489
return (fixture === undefined ||
fixture === null ||
typeof fixture === 'string' ||
typeof fixture === 'number' ||
typeof fixture === 'boolean' ||
Array.isArray(fixture) ||
// If you're curious what isElement checks:
// https://github.com/facebook/react/blob/1b0132c05acabae5aebd32c2cadddfb16bda70bc/packages/react-is/src/ReactIs.js#L108-L114
isElement(fixture));
}

@@ -16,0 +25,0 @@ function FixtureElement({ Component }) {

@@ -23,2 +23,11 @@ 'use client';

React.useEffect(() => {
rendererConnect.postMessage({
type: 'fixtureLoaded',
payload: {
rendererId,
fixture: props.fixtureItem,
},
});
}, [props.fixtureItem, rendererConnect, rendererId]);
React.useEffect(() => {
if (!isEqual(state.fixtureState, state.syncedFixtureState)) {

@@ -25,0 +34,0 @@ rendererConnect.postMessage({

@@ -1,2 +0,7 @@

import { RendererConnect } from 'react-cosmos-core';
import { RendererConnect, RendererResponse } from 'react-cosmos-core';
declare global {
interface Window {
cosmosRendererResponse?: (msg: RendererResponse) => void;
}
}
export declare function createWebSocketsConnect(url: string): RendererConnect;

@@ -20,2 +20,6 @@ import { rendererSocketMessage, } from 'react-cosmos-core';

}
// Allow headless browsers to capture renderer responses
if (window.cosmosRendererResponse) {
window.cosmosRendererResponse(rendererResponse);
}
},

@@ -22,0 +26,0 @@ onMessage(onMessage) {

{
"name": "react-cosmos-renderer",
"version": "6.1.2-canary.4cc91ba.0+4cc91ba",
"version": "6.1.2-canary.4d8d920.0+4d8d920",
"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.4cc91ba.0+4cc91ba",
"react-cosmos-core": "6.1.2-canary.4d8d920.0+4d8d920",
"react-is": "18.2.0"
},
"gitHead": "4cc91ba199e81a366a8bf8100c26a60d630f2a4e"
"gitHead": "4d8d920fff894c614453f728986f95d1b9bed3ad"
}
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