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

react-cosmos-core

Package Overview
Dependencies
Maintainers
0
Versions
252
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-cosmos-core - npm Package Compare versions

Comparing version 6.1.2-canary.0d0e717.0 to 6.1.2-canary.15db638.0

dist/utils/data.d.ts

3

dist/fixtureState/createValues.d.ts

@@ -1,3 +0,4 @@

import { FixtureStateValue, FixtureStateValues, ObjectData } from './types.js';
import { ObjectData } from '../utils/data.js';
import { FixtureStateValue, FixtureStateValues } from './types.js';
export declare function createValues(obj: ObjectData): FixtureStateValues;
export declare function createValue(data: unknown): FixtureStateValue;
import { isElement } from 'react-is';
import { isArray, isObject, isPrimitiveData } from './shared.js';
import { isArray, isObject, isPrimitiveData, } from '../utils/data.js';
export function createValues(obj) {

@@ -35,2 +35,5 @@ const values = {};

function stringifyUnserializableData(data) {
if (typeof data === 'function') {
return stringifyFunction(data);
}
// NOTE: We used to use the react-element-to-jsx-string package but it added

@@ -41,1 +44,10 @@ // bloat and complicated ESM support. We might go back to something similar

}
const emptyFnRegex = /^\(\) => \{.+\}$/s;
function stringifyFunction(data) {
// This clears space from empty function bodies. It originates as a fix for
// Vitest tests that needed to create deterministic fixture state values, but
// it cleans up how stringified functions look in the Cosmos UI as well.
// Potential improvement: Remove all extra indentation from function bodies
// to match the root-level function header indentation.
return String(data).replace(emptyFnRegex, '() => {}');
}

@@ -1,3 +0,4 @@

import { FixtureStateValue, FixtureStateValues, ObjectData } from './types.js';
import { ObjectData } from '../utils/data.js';
import { FixtureStateValue, FixtureStateValues } from './types.js';
export declare function extendWithValues(obj: ObjectData, values: FixtureStateValues): ObjectData;
export declare function extendWithValue(data: unknown, value: FixtureStateValue): unknown;

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

import { isArray, isObject } from './shared.js';
import { isArray, isObject } from '../utils/data.js';
// Use fixture state for serializable values and fall back to base values

@@ -3,0 +3,0 @@ export function extendWithValues(obj, values) {

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

import { PrimitiveData } from '../utils/data.js';
import { StateUpdater } from '../utils/state.js';

@@ -11,5 +12,2 @@ export type FixtureDecoratorId = string;

};
export type PrimitiveData = string | number | boolean | null | undefined;
export type ObjectData = Record<string, unknown>;
export type ArrayData = unknown[];
export type FixtureStatePrimitiveValue = {

@@ -16,0 +14,0 @@ type: 'primitive';

@@ -33,9 +33,10 @@ export * from './fixtureState/classState.js';

export * from './utils/array.js';
export * from './utils/data.js';
export * from './utils/keys.js';
export * from './utils/queryString.js';
export * from './utils/react/ClassStateMock.js';
export * from './utils/react/areNodesEqual.js';
export * from './utils/react/DelayRender.js';
export * from './utils/react/areNodesEqual.js';
export * from './utils/react/getComponentName.js';
export * from './utils/react/isReactElement.js';
export * from './utils/serializable.js';
export * from './utils/state.js';

@@ -42,0 +43,0 @@ export * from './utils/string.js';

@@ -33,9 +33,10 @@ export * from './fixtureState/classState.js';

export * from './utils/array.js';
export * from './utils/data.js';
export * from './utils/keys.js';
export * from './utils/queryString.js';
export * from './utils/react/ClassStateMock.js';
export * from './utils/react/areNodesEqual.js';
export * from './utils/react/DelayRender.js';
export * from './utils/react/areNodesEqual.js';
export * from './utils/react/getComponentName.js';
export * from './utils/react/isReactElement.js';
export * from './utils/serializable.js';
export * from './utils/state.js';

@@ -42,0 +43,0 @@ export * from './utils/string.js';

@@ -61,2 +61,3 @@ import { FixtureState } from '../fixtureState/types.js';

fixture: FixtureListItem;
fixtureOptions: {};
};

@@ -63,0 +64,0 @@ };

@@ -5,3 +5,9 @@ import { isElement } from 'react-is';

typeof fixtureExport === 'object' &&
!isElement(fixtureExport));
!isElement(fixtureExport) &&
// With React Server Components, fixture exports of Client fixtures are
// wrapped in a Promise. The React ComponentType union does include
// PromiseLikeOfReactNode but for some reason it's impossible do type
// narrowing or use a type predicate function.
// @ts-ignore Sadly, we resort to the "cause I said so" type assertion
typeof fixtureExport.then !== 'function');
}

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

import { ComponentType, FunctionComponent, ReactNode } from 'react';
import { ComponentType, ReactNode } from 'react';
type FixtureMap<FixtureType> = {

@@ -8,2 +8,3 @@ [fixtureName: string]: FixtureType;

default: FixtureExport<FixtureType>;
options?: {};
};

@@ -16,3 +17,3 @@ type ModuleWrapper<ModuleType> = {

};
export type ReactFixture = ReactNode | FunctionComponent;
export type ReactFixture = ReactNode | ComponentType;
export type ReactFixtureMap = FixtureMap<ReactFixture>;

@@ -23,8 +24,9 @@ export type ReactFixtureExport = FixtureExport<ReactFixture>;

export type LazyReactFixtureWrapper = LazyModuleWrapper<ReactFixtureModule>;
export type ReactDecoratorProps = {
export type DecoratorProps<T = {}> = {
children: ReactNode;
options: T;
};
export type ReactDecorator = ComponentType<ReactDecoratorProps>;
export type ReactDecorator<T = {}> = ComponentType<DecoratorProps<T>>;
export type ReactDecoratorModule = {
default: ReactDecorator;
default: ReactDecorator<any>;
};

@@ -31,0 +33,0 @@ export type ReactDecoratorWrapper = ModuleWrapper<ReactDecoratorModule>;

{
"name": "react-cosmos-core",
"version": "6.1.2-canary.0d0e717.0+0d0e717",
"version": "6.1.2-canary.15db638.0+15db638",
"description": "React Cosmos Core",

@@ -13,5 +13,5 @@ "repository": "https://github.com/react-cosmos/react-cosmos/tree/main/packages/react-cosmos-core",

"lodash-es": "4.17.21",
"react-is": "18.2.0"
"react-is": "18.3.1"
},
"gitHead": "0d0e717b5045febfbaf2bc8e9c840094859d49a4"
"gitHead": "15db6389056d322dd3df5012262cfd620867e49b"
}
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