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

react-cosmos-core

Package Overview
Dependencies
Maintainers
1
Versions
253
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.0.0-canary.f5c981a.0 to 6.0.0-canary.f61f2b6.0

dist/fixtureState/classStateTypes.d.ts

21

dist/fixtureState/classState.d.ts

@@ -1,6 +0,7 @@

import { FixtureDecoratorId, FixtureElementId, FixtureState, FixtureStateClassState, FixtureStateValues } from './types.js';
export declare function getFixtureStateClassState(fixtureState: FixtureState, decoratorId: FixtureDecoratorId): FixtureStateClassState[];
export declare function findFixtureStateClassState(fixtureState: FixtureState, elementId: FixtureElementId): void | FixtureStateClassState;
type CreateFixtureStateClassStateArgs = {
fixtureState: FixtureState;
import { ClassStateFixtureState, ClassStateFixtureStateItem } from './classStateTypes.js';
import { FixtureDecoratorId, FixtureElementId, FixtureStateValues } from './types.js';
export declare function filterClassStateFixtureState(classStateFs: ClassStateFixtureState | undefined, decoratorId: FixtureDecoratorId): ClassStateFixtureState;
export declare function findClassStateFixtureStateItem(classStateFs: ClassStateFixtureState | undefined, elementId: FixtureElementId): void | ClassStateFixtureStateItem;
type CreateClassStateFixtureStateArgs = {
classStateFs: ClassStateFixtureState | undefined;
elementId: FixtureElementId;

@@ -10,3 +11,3 @@ values: FixtureStateValues;

};
export declare function createFixtureStateClassState({ fixtureState, elementId, values, componentName, }: CreateFixtureStateClassStateArgs): {
export declare function createClassStateFixtureStateItem({ classStateFs, elementId, values, componentName, }: CreateClassStateFixtureStateArgs): {
elementId: FixtureElementId;

@@ -16,9 +17,9 @@ values: FixtureStateValues;

}[];
type UpdateFixtureStateClassStateArgs = {
fixtureState: FixtureState;
type UpdateClassStateFixtureStateArgs = {
classStateFs: ClassStateFixtureState | undefined;
elementId: FixtureElementId;
values: FixtureStateValues;
};
export declare function updateFixtureStateClassState({ fixtureState, elementId, values, }: UpdateFixtureStateClassStateArgs): FixtureStateClassState[];
export declare function removeFixtureStateClassState(fixtureState: FixtureState, elementId: FixtureElementId): FixtureStateClassState[];
export declare function updateClassStateFixtureStateItem({ classStateFs, elementId, values, }: UpdateClassStateFixtureStateArgs): ClassStateFixtureStateItem[];
export declare function removeClassStateFixtureStateItem(classStateFs: ClassStateFixtureState | undefined, elementId: FixtureElementId): ClassStateFixtureStateItem[];
export {};
import { find, isEqual } from 'lodash-es';
import { removeItemMatch, replaceOrAddItem, updateItem, } from '../utils/array.js';
export function getFixtureStateClassState(fixtureState, decoratorId) {
const { classState } = fixtureState;
return classState
? classState.filter(s => s.elementId.decoratorId === decoratorId)
export function filterClassStateFixtureState(classStateFs, decoratorId) {
return classStateFs
? classStateFs.filter(s => s.elementId.decoratorId === decoratorId)
: [];
}
export function findFixtureStateClassState(fixtureState, elementId) {
const { classState } = fixtureState;
return classState && find(classState, s => isEqual(s.elementId, elementId));
export function findClassStateFixtureStateItem(classStateFs, elementId) {
return (classStateFs && find(classStateFs, s => isEqual(s.elementId, elementId)));
}
export function createFixtureStateClassState({ fixtureState, elementId, values, componentName, }) {
const { classState = [] } = fixtureState;
return replaceOrAddItem(classState, createClassStateMatcher(elementId), {
elementId,
values,
componentName,
});
export function createClassStateFixtureStateItem({ classStateFs, elementId, values, componentName, }) {
return replaceOrAddItem(classStateFs ?? [], createClassStateMatcher(elementId), { elementId, values, componentName });
}
export function updateFixtureStateClassState({ fixtureState, elementId, values, }) {
const classStateItem = expectFixtureStateClassState(fixtureState, elementId);
return updateItem(fixtureState.classState, classStateItem, {
values,
});
export function updateClassStateFixtureStateItem({ classStateFs, elementId, values, }) {
const item = expectClassStateItem(classStateFs, elementId);
return updateItem(classStateFs, item, { values });
}
export function removeFixtureStateClassState(fixtureState, elementId) {
return removeItemMatch(fixtureState.classState || [], createClassStateMatcher(elementId));
export function removeClassStateFixtureStateItem(classStateFs, elementId) {
return removeItemMatch(classStateFs ?? [], createClassStateMatcher(elementId));
}

@@ -33,9 +24,9 @@ function createClassStateMatcher(elementId) {

}
function expectFixtureStateClassState(fixtureState, elementId) {
const classStateItem = findFixtureStateClassState(fixtureState, elementId);
if (!classStateItem) {
function expectClassStateItem(classStateFs, elementId) {
const item = findClassStateFixtureStateItem(classStateFs, elementId);
if (!item) {
const elId = JSON.stringify(elementId);
throw new Error(`Fixture state class state missing for element "${elId}"`);
}
return classStateItem;
return item;
}

@@ -1,7 +0,8 @@

import { FixtureDecoratorId, FixtureElementId, FixtureRenderKey, FixtureState, FixtureStateProps, FixtureStateValues } from './types.js';
export declare const DEFAULT_RENDER_KEY: FixtureRenderKey;
export declare function getFixtureStateProps(fixtureState: FixtureState, decoratorId: FixtureDecoratorId): FixtureStateProps[];
export declare function findFixtureStateProps(fixtureState: FixtureState, elementId: FixtureElementId): void | FixtureStateProps;
type CreateFixtureStatePropsArgs = {
fixtureState: FixtureState;
import { PropsFixtureState, PropsFixtureStateItem, PropsFixtureStateRenderKey } from './propsTypes.js';
import { FixtureDecoratorId, FixtureElementId, FixtureStateValues } from './types.js';
export declare const DEFAULT_RENDER_KEY: PropsFixtureStateRenderKey;
export declare function filterPropsFixtureState(propsFs: PropsFixtureState | undefined, decoratorId: FixtureDecoratorId): PropsFixtureState;
export declare function findPropsFixtureStateItem(propsFs: PropsFixtureState | undefined, elementId: FixtureElementId): void | PropsFixtureStateItem;
type CreatePropsFixtureStateArgs = {
propsFs: PropsFixtureState | undefined;
elementId: FixtureElementId;

@@ -11,3 +12,3 @@ values: FixtureStateValues;

};
export declare function createFixtureStateProps({ fixtureState, elementId, values, componentName, }: CreateFixtureStatePropsArgs): {
export declare function createPropsFixtureStateItem({ propsFs, elementId, values, componentName, }: CreatePropsFixtureStateArgs): {
elementId: FixtureElementId;

@@ -18,15 +19,15 @@ values: FixtureStateValues;

}[];
type ResetFixtureStatePropsArgs = {
fixtureState: FixtureState;
type ResetPropsFixtureStateItemArgs = {
propsFs: PropsFixtureState | undefined;
elementId: FixtureElementId;
values: FixtureStateValues;
};
export declare function resetFixtureStateProps({ fixtureState, elementId, values, }: ResetFixtureStatePropsArgs): FixtureStateProps[];
type UpdateFixtureStatePropsArgs = {
fixtureState: FixtureState;
export declare function resetPropsFixtureStateItem({ propsFs, elementId, values, }: ResetPropsFixtureStateItemArgs): PropsFixtureStateItem[];
type UpdatePropsFixtureStateItemArgs = {
propsFs: PropsFixtureState | undefined;
elementId: FixtureElementId;
values: FixtureStateValues;
};
export declare function updateFixtureStateProps({ fixtureState, elementId, values, }: UpdateFixtureStatePropsArgs): FixtureStateProps[];
export declare function removeFixtureStateProps(fixtureState: FixtureState, elementId: FixtureElementId): FixtureStateProps[];
export declare function updatePropsFixtureStateItem({ propsFs, elementId, values, }: UpdatePropsFixtureStateItemArgs): PropsFixtureStateItem[];
export declare function removePropsFixtureStateItem(propsFs: PropsFixtureState | undefined, elementId: FixtureElementId): PropsFixtureStateItem[];
export {};
import { find, isEqual } from 'lodash-es';
import { removeItemMatch, replaceOrAddItem, updateItem, } from '../utils/array.js';
export const DEFAULT_RENDER_KEY = 0;
export function getFixtureStateProps(fixtureState, decoratorId) {
const { props } = fixtureState;
return props
? props.filter(p => p.elementId.decoratorId === decoratorId)
export function filterPropsFixtureState(propsFs, decoratorId) {
return propsFs
? propsFs.filter(p => p.elementId.decoratorId === decoratorId)
: [];
}
export function findFixtureStateProps(fixtureState, elementId) {
const { props } = fixtureState;
return props && find(props, p => isEqual(p.elementId, elementId));
export function findPropsFixtureStateItem(propsFs, elementId) {
return propsFs && find(propsFs, p => isEqual(p.elementId, elementId));
}
export function createFixtureStateProps({ fixtureState, elementId, values, componentName, }) {
const { props = [] } = fixtureState;
return replaceOrAddItem(props, createPropsMatcher(elementId), {
export function createPropsFixtureStateItem({ propsFs, elementId, values, componentName, }) {
return replaceOrAddItem(propsFs ?? [], createPropsMatcher(elementId), {
elementId,

@@ -23,17 +20,15 @@ values,

}
export function resetFixtureStateProps({ fixtureState, elementId, values, }) {
const propsItem = expectFixtureStateProps(fixtureState, elementId);
return updateItem(fixtureState.props, propsItem, {
export function resetPropsFixtureStateItem({ propsFs, elementId, values, }) {
const item = expectPropsItem(propsFs, elementId);
return updateItem(propsFs, item, {
values,
renderKey: propsItem.renderKey + 1,
renderKey: item.renderKey + 1,
});
}
export function updateFixtureStateProps({ fixtureState, elementId, values, }) {
const propsItem = expectFixtureStateProps(fixtureState, elementId);
return updateItem(fixtureState.props, propsItem, {
values,
});
export function updatePropsFixtureStateItem({ propsFs, elementId, values, }) {
const item = expectPropsItem(propsFs, elementId);
return updateItem(propsFs, item, { values });
}
export function removeFixtureStateProps(fixtureState, elementId) {
return removeItemMatch(fixtureState.props || [], createPropsMatcher(elementId));
export function removePropsFixtureStateItem(propsFs, elementId) {
return removeItemMatch(propsFs ?? [], createPropsMatcher(elementId));
}

@@ -43,9 +38,9 @@ function createPropsMatcher(elementId) {

}
function expectFixtureStateProps(fixtureState, elementId) {
const propsItem = findFixtureStateProps(fixtureState, elementId);
if (!propsItem) {
function expectPropsItem(propsFs, elementId) {
const item = findPropsFixtureStateItem(propsFs, elementId);
if (!item) {
const elId = JSON.stringify(elementId);
throw new Error(`Fixture state props missing for element "${elId}"`);
}
return propsItem;
return item;
}

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

import { StateUpdater } from '../utils/types.js';
import { StateUpdater } from '../utils/state.js';
export type FixtureDecoratorId = string;

@@ -29,32 +29,3 @@ export type FixtureElementId = {

export type FixtureStateValues = Record<string, FixtureStateValue>;
export type FixtureRenderKey = number;
export type FixtureStateProps = {
elementId: FixtureElementId;
values: FixtureStateValues;
renderKey: FixtureRenderKey;
componentName: string;
};
export type FixtureStateClassState = {
elementId: FixtureElementId;
values: FixtureStateValues;
componentName: string;
};
export type FixtureStateStandardControl = {
type: 'standard';
defaultValue: FixtureStateValue;
currentValue: FixtureStateValue;
};
export type FixtureStateSelectControl = {
type: 'select';
options: string[];
defaultValue: string;
currentValue: string;
};
export type FixtureStateControl = FixtureStateStandardControl | FixtureStateSelectControl;
export type FixtureStateControls = Record<string, FixtureStateControl>;
export type FixtureState = {
props?: FixtureStateProps[];
classState?: FixtureStateClassState[];
controls?: FixtureStateControls;
} & Record<string, unknown>;
export type FixtureState = Record<string, unknown>;
export type SetFixtureState = (update: StateUpdater<FixtureState>) => unknown;
export * from './fixtureState/classState.js';
export * from './fixtureState/controls.js';
export * from './fixtureState/classStateTypes.js';
export * from './fixtureState/controlsTypes.js';
export * from './fixtureState/createValues.js';
export * from './fixtureState/extendWithValues.js';
export * from './fixtureState/fixtureState.js';
export * from './fixtureState/props.js';
export * from './fixtureState/propsTypes.js';
export * from './fixtureState/types.js';
export * from './fixtureState/viewport.js';
export * from './fixtureTree/createFixtureTree/index.js';

@@ -35,6 +39,6 @@ export * from './fixtureTree/flattenFixtureTree.js';

export * from './utils/react/isReactElement.js';
export * from './utils/state.js';
export * from './utils/string.js';
export * from './utils/tree.js';
export * from './utils/types.js';
export * from './utils/uuid.js';
export * from './utils/window.js';
export * from './fixtureState/classState.js';
export * from './fixtureState/controls.js';
export * from './fixtureState/classStateTypes.js';
export * from './fixtureState/controlsTypes.js';
export * from './fixtureState/createValues.js';
export * from './fixtureState/extendWithValues.js';
export * from './fixtureState/fixtureState.js';
export * from './fixtureState/props.js';
export * from './fixtureState/propsTypes.js';
export * from './fixtureState/types.js';
export * from './fixtureState/viewport.js';
export * from './fixtureTree/createFixtureTree/index.js';

@@ -35,6 +39,6 @@ export * from './fixtureTree/flattenFixtureTree.js';

export * from './utils/react/isReactElement.js';
export * from './utils/state.js';
export * from './utils/string.js';
export * from './utils/tree.js';
export * from './utils/types.js';
export * from './utils/uuid.js';
export * from './utils/window.js';

@@ -8,3 +8,4 @@ export function registerPlaygroundShortcuts(runCommand) {

function handleWindowKeyDown(e) {
if (isEditing()) {
// Allow meta key shortcuts to work when focused on input fields
if (isEditing() && !e.metaKey) {
return;

@@ -14,17 +15,20 @@ }

const metaKey = e.metaKey || e.ctrlKey;
if (keyChar === 'P' && metaKey) {
if (keyChar === 'K' && metaKey) {
run(e, 'searchFixtures');
}
else if (keyChar === 'L' && metaKey && e.shiftKey) {
else if (keyChar === 'L') {
run(e, 'toggleFixtureList');
}
else if (keyChar === 'K' && metaKey && e.shiftKey) {
else if (keyChar === 'P') {
run(e, 'toggleControlPanel');
}
else if (keyChar === 'F' && metaKey && e.shiftKey) {
else if (keyChar === 'F') {
run(e, 'goFullScreen');
}
else if (keyChar === 'E' && metaKey && e.shiftKey) {
else if (keyChar === 'E') {
run(e, 'editFixture');
}
else if (keyChar === 'R') {
run(e, 'reloadRenderer');
}
}

@@ -31,0 +35,0 @@ return () => {

{
"name": "react-cosmos-core",
"version": "6.0.0-canary.f5c981a.0+f5c981a",
"version": "6.0.0-canary.f61f2b6.0+f61f2b6",
"description": "React Cosmos Core",

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

"dependencies": {
"js-base64": "3.7.5",
"js-base64": "3.7.6",
"lodash-es": "4.17.21",
"react-is": "18.2.0"
},
"gitHead": "f5c981ab25d4b15c5ea7b9fb7e2834dc1d623f72"
"gitHead": "f61f2b67cdad2c362b79c55dae23b84f65e83691"
}
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