react-cosmos-core 7.2.0 → 7.2.1-canary.0004fe7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/fixtureState/classState.d.ts +4 -4
  2. package/dist/fixtureState/classState.js +2 -2
  3. package/dist/fixtureState/classStateTypes.d.ts +1 -1
  4. package/dist/fixtureState/createValues.d.ts +2 -2
  5. package/dist/fixtureState/createValues.js +1 -1
  6. package/dist/fixtureState/extendWithValues.d.ts +2 -2
  7. package/dist/fixtureState/fixtureState.d.ts +1 -1
  8. package/dist/fixtureState/inputsTypes.d.ts +1 -1
  9. package/dist/fixtureState/props.d.ts +5 -5
  10. package/dist/fixtureState/props.js +2 -2
  11. package/dist/fixtureState/propsTypes.d.ts +1 -1
  12. package/dist/fixtureState/types.d.ts +2 -2
  13. package/dist/fixtureTree/createFixtureTree/collapseFixtureDirs.d.ts +1 -1
  14. package/dist/fixtureTree/createFixtureTree/collapseFixtureDirs.js +1 -2
  15. package/dist/fixtureTree/createFixtureTree/collapseIndexes.d.ts +1 -1
  16. package/dist/fixtureTree/createFixtureTree/collapseNamedIndexes.d.ts +1 -1
  17. package/dist/fixtureTree/createFixtureTree/collapseOuterDirs.d.ts +1 -1
  18. package/dist/fixtureTree/createFixtureTree/createRawFixtureTree.d.ts +2 -2
  19. package/dist/fixtureTree/createFixtureTree/createRawFixtureTree.js +9 -15
  20. package/dist/fixtureTree/createFixtureTree/hideFixtureSuffix.d.ts +1 -1
  21. package/dist/fixtureTree/createFixtureTree/index.d.ts +3 -3
  22. package/dist/fixtureTree/flattenFixtureTree.d.ts +2 -2
  23. package/dist/fixtureTree/types.d.ts +1 -1
  24. package/dist/index.d.ts +3 -0
  25. package/dist/index.js +3 -0
  26. package/dist/playground/playgroundParams.d.ts +1 -1
  27. package/dist/playground/playgroundQueryString.d.ts +1 -1
  28. package/dist/renderer/rendererConnect.d.ts +3 -3
  29. package/dist/renderer/rendererQueryString.d.ts +1 -1
  30. package/dist/renderer/rendererUrl.d.ts +2 -2
  31. package/dist/renderer/rendererUrl.js +1 -1
  32. package/dist/userModules/getFixtureFromExport.d.ts +1 -1
  33. package/dist/userModules/getFixtureList.d.ts +2 -2
  34. package/dist/userModules/getSortedDecoratorsForFixturePath.d.ts +1 -1
  35. package/dist/userModules/isMultiFixture.d.ts +1 -1
  36. package/dist/userModules/stringifyFixtureId.d.ts +1 -1
  37. package/dist/userModules/userModuleTypes.d.ts +1 -1
  38. package/dist/utils/array.js +2 -3
  39. package/dist/utils/data.js +4 -2
  40. package/dist/utils/isEqual.d.ts +15 -0
  41. package/dist/utils/isEqual.js +61 -0
  42. package/dist/utils/mapValues.d.ts +1 -0
  43. package/dist/utils/mapValues.js +3 -0
  44. package/dist/utils/pathUtils.d.ts +2 -0
  45. package/dist/utils/pathUtils.js +35 -0
  46. package/dist/utils/react/areNodesEqual.d.ts +1 -1
  47. package/dist/utils/react/areNodesEqual.js +22 -5
  48. package/dist/utils/react/getComponentName.d.ts +1 -1
  49. package/dist/utils/react/isReactElement.d.ts +1 -1
  50. package/dist/utils/serializable.js +1 -1
  51. package/dist/utils/window.js +1 -1
  52. package/package.json +3 -4
  53. package/tsconfig.build.tsbuildinfo +1 -0
  54. package/dist/tsconfig.build.tsbuildinfo +0 -1
@@ -1,5 +1,5 @@
1
- import { ClassStateFixtureState, ClassStateFixtureStateItem } from './classStateTypes.js';
2
- import { FixtureDecoratorId, FixtureElementId, FixtureStateValues } from './types.js';
1
+ import type { ClassStateFixtureState, ClassStateFixtureStateItem } from './classStateTypes.js';
2
+ import type { FixtureDecoratorId, FixtureElementId, FixtureStateValues } from './types.js';
3
3
  export declare function filterClassStateFixtureState(classStateFs: ClassStateFixtureState | undefined, decoratorId: FixtureDecoratorId): ClassStateFixtureState;
4
4
  export declare function findClassStateFixtureStateItem(classStateFs: ClassStateFixtureState | undefined, elementId: FixtureElementId): void | ClassStateFixtureStateItem;
5
5
  type CreateClassStateFixtureStateArgs = {
@@ -8,7 +8,7 @@ type CreateClassStateFixtureStateArgs = {
8
8
  values: FixtureStateValues;
9
9
  componentName: string;
10
10
  };
11
- export declare function createClassStateFixtureStateItem({ classStateFs, elementId, values, componentName, }: CreateClassStateFixtureStateArgs): {
11
+ export declare function createClassStateFixtureStateItem({ classStateFs, elementId, values, componentName }: CreateClassStateFixtureStateArgs): {
12
12
  elementId: FixtureElementId;
13
13
  values: FixtureStateValues;
14
14
  componentName: string;
@@ -18,6 +18,6 @@ type UpdateClassStateFixtureStateArgs = {
18
18
  elementId: FixtureElementId;
19
19
  values: FixtureStateValues;
20
20
  };
21
- export declare function updateClassStateFixtureStateItem({ classStateFs, elementId, values, }: UpdateClassStateFixtureStateArgs): ClassStateFixtureStateItem[];
21
+ export declare function updateClassStateFixtureStateItem({ classStateFs, elementId, values }: UpdateClassStateFixtureStateArgs): ClassStateFixtureStateItem[];
22
22
  export declare function removeClassStateFixtureStateItem(classStateFs: ClassStateFixtureState | undefined, elementId: FixtureElementId): ClassStateFixtureStateItem[];
23
23
  export {};
@@ -1,12 +1,12 @@
1
- import { find, isEqual } from 'lodash-es';
2
1
  import { removeItemMatch, replaceOrAddItem, updateItem, } from '../utils/array.js';
2
+ import { isEqual } from '../utils/isEqual.js';
3
3
  export function filterClassStateFixtureState(classStateFs, decoratorId) {
4
4
  return classStateFs
5
5
  ? classStateFs.filter(s => s.elementId.decoratorId === decoratorId)
6
6
  : [];
7
7
  }
8
8
  export function findClassStateFixtureStateItem(classStateFs, elementId) {
9
- return (classStateFs && find(classStateFs, s => isEqual(s.elementId, elementId)));
9
+ return (classStateFs && classStateFs.find(s => isEqual(s.elementId, elementId)));
10
10
  }
11
11
  export function createClassStateFixtureStateItem({ classStateFs, elementId, values, componentName, }) {
12
12
  return replaceOrAddItem(classStateFs ?? [], createClassStateMatcher(elementId), { elementId, values, componentName });
@@ -1,4 +1,4 @@
1
- import { FixtureElementId, FixtureStateValues } from './types.js';
1
+ import type { FixtureElementId, FixtureStateValues } from './types.js';
2
2
  export type ClassStateFixtureStateItem = {
3
3
  elementId: FixtureElementId;
4
4
  values: FixtureStateValues;
@@ -1,4 +1,4 @@
1
- import { ObjectData } from '../utils/data.js';
2
- import { FixtureStateValue, FixtureStateValues } from './types.js';
1
+ import type { ObjectData } from '../utils/data.js';
2
+ import type { FixtureStateValue, FixtureStateValues } from './types.js';
3
3
  export declare function createValues(obj: ObjectData): FixtureStateValues;
4
4
  export declare function createValue(data: unknown): FixtureStateValue;
@@ -1,5 +1,5 @@
1
1
  import { isValidElement } from 'react';
2
- import { isArray, isObject, isPrimitiveData, } from '../utils/data.js';
2
+ import { isArray, isObject, isPrimitiveData } from '../utils/data.js';
3
3
  export function createValues(obj) {
4
4
  const values = {};
5
5
  Object.keys(obj).forEach(key => {
@@ -1,4 +1,4 @@
1
- import { ObjectData } from '../utils/data.js';
2
- import { FixtureStateValue, FixtureStateValues } from './types.js';
1
+ import type { ObjectData } from '../utils/data.js';
2
+ import type { FixtureStateValue, FixtureStateValues } from './types.js';
3
3
  export declare function extendWithValues(obj: ObjectData, values: FixtureStateValues): ObjectData;
4
4
  export declare function extendWithValue(data: unknown, value: FixtureStateValue): unknown;
@@ -1,4 +1,4 @@
1
- import { FixtureState } from './types.js';
1
+ import type { FixtureState } from './types.js';
2
2
  export type FixtureStateUpdater<T> = (prevState: T | undefined) => T;
3
3
  export type FixtureStateChange<T> = T | FixtureStateUpdater<T>;
4
4
  export declare function fixtureStateByName<T>(fixtureState: FixtureState, name: string): T | undefined;
@@ -1,4 +1,4 @@
1
- import { FixtureStateValue } from './types.js';
1
+ import type { FixtureStateValue } from './types.js';
2
2
  export type StandardInputFixtureState = {
3
3
  type: 'standard';
4
4
  defaultValue: FixtureStateValue;
@@ -1,5 +1,5 @@
1
- import { PropsFixtureState, PropsFixtureStateItem, PropsFixtureStateRenderKey } from './propsTypes.js';
2
- import { FixtureDecoratorId, FixtureElementId, FixtureStateValues } from './types.js';
1
+ import type { PropsFixtureState, PropsFixtureStateItem, PropsFixtureStateRenderKey } from './propsTypes.js';
2
+ import type { FixtureDecoratorId, FixtureElementId, FixtureStateValues } from './types.js';
3
3
  export declare const DEFAULT_RENDER_KEY: PropsFixtureStateRenderKey;
4
4
  export declare function filterPropsFixtureState(propsFs: PropsFixtureState | undefined, decoratorId: FixtureDecoratorId): PropsFixtureState;
5
5
  export declare function findPropsFixtureStateItem(propsFs: PropsFixtureState | undefined, elementId: FixtureElementId): void | PropsFixtureStateItem;
@@ -9,7 +9,7 @@ type CreatePropsFixtureStateArgs = {
9
9
  values: FixtureStateValues;
10
10
  componentName: string;
11
11
  };
12
- export declare function createPropsFixtureStateItem({ propsFs, elementId, values, componentName, }: CreatePropsFixtureStateArgs): {
12
+ export declare function createPropsFixtureStateItem({ propsFs, elementId, values, componentName }: CreatePropsFixtureStateArgs): {
13
13
  elementId: FixtureElementId;
14
14
  values: FixtureStateValues;
15
15
  renderKey: number;
@@ -20,12 +20,12 @@ type ResetPropsFixtureStateItemArgs = {
20
20
  elementId: FixtureElementId;
21
21
  values: FixtureStateValues;
22
22
  };
23
- export declare function resetPropsFixtureStateItem({ propsFs, elementId, values, }: ResetPropsFixtureStateItemArgs): PropsFixtureStateItem[];
23
+ export declare function resetPropsFixtureStateItem({ propsFs, elementId, values }: ResetPropsFixtureStateItemArgs): PropsFixtureStateItem[];
24
24
  type UpdatePropsFixtureStateItemArgs = {
25
25
  propsFs: PropsFixtureState | undefined;
26
26
  elementId: FixtureElementId;
27
27
  values: FixtureStateValues;
28
28
  };
29
- export declare function updatePropsFixtureStateItem({ propsFs, elementId, values, }: UpdatePropsFixtureStateItemArgs): PropsFixtureStateItem[];
29
+ export declare function updatePropsFixtureStateItem({ propsFs, elementId, values }: UpdatePropsFixtureStateItemArgs): PropsFixtureStateItem[];
30
30
  export declare function removePropsFixtureStateItem(propsFs: PropsFixtureState | undefined, elementId: FixtureElementId): PropsFixtureStateItem[];
31
31
  export {};
@@ -1,5 +1,5 @@
1
- import { find, isEqual } from 'lodash-es';
2
1
  import { removeItemMatch, replaceOrAddItem, updateItem, } from '../utils/array.js';
2
+ import { isEqual } from '../utils/isEqual.js';
3
3
  export const DEFAULT_RENDER_KEY = 0;
4
4
  export function filterPropsFixtureState(propsFs, decoratorId) {
5
5
  return propsFs
@@ -7,7 +7,7 @@ export function filterPropsFixtureState(propsFs, decoratorId) {
7
7
  : [];
8
8
  }
9
9
  export function findPropsFixtureStateItem(propsFs, elementId) {
10
- return propsFs && find(propsFs, p => isEqual(p.elementId, elementId));
10
+ return propsFs && propsFs.find(p => isEqual(p.elementId, elementId));
11
11
  }
12
12
  export function createPropsFixtureStateItem({ propsFs, elementId, values, componentName, }) {
13
13
  return replaceOrAddItem(propsFs ?? [], createPropsMatcher(elementId), {
@@ -1,4 +1,4 @@
1
- import { FixtureElementId, FixtureStateValues } from './types.js';
1
+ import type { FixtureElementId, FixtureStateValues } from './types.js';
2
2
  export type PropsFixtureStateRenderKey = number;
3
3
  export type PropsFixtureStateItem = {
4
4
  elementId: FixtureElementId;
@@ -1,5 +1,5 @@
1
- import { PrimitiveData } from '../utils/data.js';
2
- import { StateUpdater } from '../utils/state.js';
1
+ import type { PrimitiveData } from '../utils/data.js';
2
+ import type { StateUpdater } from '../utils/state.js';
3
3
  export type FixtureDecoratorId = string;
4
4
  export type FixtureElementId = {
5
5
  decoratorId: string;
@@ -1,2 +1,2 @@
1
- import { FixtureTreeNode } from '../types.js';
1
+ import type { FixtureTreeNode } from '../types.js';
2
2
  export declare function collapseFixtureDirs(treeNode: FixtureTreeNode, fixturesDir: string): FixtureTreeNode;
@@ -1,11 +1,10 @@
1
- import { omit } from 'lodash-es';
2
1
  export function collapseFixtureDirs(treeNode, fixturesDir) {
3
2
  const { data, children } = treeNode;
4
3
  if (data.type !== 'fileDir' || !children)
5
4
  return treeNode;
6
5
  const collapsableDirNode = children[fixturesDir];
7
6
  if (collapsableDirNode && collapsableDirNode.data.type === 'fileDir') {
8
- const otherChildren = omit(children, fixturesDir);
7
+ const { [fixturesDir]: _, ...otherChildren } = children;
9
8
  const innerChildren = collapsableDirNode.children;
10
9
  // Make sure children of the collapsed dir don't overlap with children of
11
10
  // the parent dir
@@ -1,2 +1,2 @@
1
- import { FixtureTreeNode } from '../types.js';
1
+ import type { FixtureTreeNode } from '../types.js';
2
2
  export declare function collapseIndexes(treeNode: FixtureTreeNode): FixtureTreeNode;
@@ -1,2 +1,2 @@
1
- import { FixtureTreeNode } from '../types.js';
1
+ import type { FixtureTreeNode } from '../types.js';
2
2
  export declare function collapseNamedIndexes(treeNode: FixtureTreeNode): FixtureTreeNode;
@@ -1,2 +1,2 @@
1
- import { FixtureTreeNode } from '../types.js';
1
+ import type { FixtureTreeNode } from '../types.js';
2
2
  export declare function collapseOuterDirs(treeNode: FixtureTreeNode): FixtureTreeNode;
@@ -1,3 +1,3 @@
1
- import { FixtureList } from '../../userModules/fixtureTypes.js';
2
- import { FixtureTreeNode } from '../types.js';
1
+ import type { FixtureList } from '../../userModules/fixtureTypes.js';
2
+ import type { FixtureTreeNode } from '../types.js';
3
3
  export declare function createRawFixtureTree(fixtures: FixtureList): FixtureTreeNode;
@@ -1,4 +1,3 @@
1
- import { get, set } from 'lodash-es';
2
1
  import { addTreeNodeChild } from '../../utils/tree.js';
3
2
  import { removeFixtureNameExtension } from '../fixtureUtils.js';
4
3
  export function createRawFixtureTree(fixtures) {
@@ -41,19 +40,14 @@ function parseFixturePath(fixturePath) {
41
40
  function injectNode(rootNode, parents, childName, childNode) {
42
41
  if (parents.length === 0)
43
42
  return addTreeNodeChild(rootNode, childName, childNode);
44
- let curParentDepth = 1;
45
- let curParent;
46
- do {
47
- const curParents = parents.slice(0, curParentDepth);
48
- const curPath = curParents.map(p => `children["${p}"]`).join('.');
49
- curParent = get(rootNode, curPath);
50
- if (!curParent) {
51
- curParent = {
52
- data: { type: 'fileDir' },
53
- };
54
- set(rootNode, curPath, curParent);
43
+ let curNode = rootNode;
44
+ for (const dirName of parents) {
45
+ if (!curNode.children)
46
+ curNode.children = {};
47
+ if (!curNode.children[dirName]) {
48
+ curNode.children[dirName] = { data: { type: 'fileDir' } };
55
49
  }
56
- curParentDepth += 1;
57
- } while (curParentDepth <= parents.length);
58
- addTreeNodeChild(curParent, childName, childNode);
50
+ curNode = curNode.children[dirName];
51
+ }
52
+ addTreeNodeChild(curNode, childName, childNode);
59
53
  }
@@ -1,2 +1,2 @@
1
- import { FixtureTreeNode } from '../types.js';
1
+ import type { FixtureTreeNode } from '../types.js';
2
2
  export declare function hideFixtureSuffix(treeNode: FixtureTreeNode, suffix: string): FixtureTreeNode;
@@ -1,6 +1,6 @@
1
- import { FixtureList } from '../../userModules/fixtureTypes.js';
2
- import { FixtureTreeNode } from '../types.js';
3
- export declare function createFixtureTree({ fixtures, fixturesDir, fixtureFileSuffix, }: {
1
+ import type { FixtureList } from '../../userModules/fixtureTypes.js';
2
+ import type { FixtureTreeNode } from '../types.js';
3
+ export declare function createFixtureTree({ fixtures, fixturesDir, fixtureFileSuffix }: {
4
4
  fixtures: FixtureList;
5
5
  fixturesDir: string;
6
6
  fixtureFileSuffix: string;
@@ -1,5 +1,5 @@
1
- import { FixtureId } from '../userModules/fixtureTypes.js';
2
- import { FixtureTreeNode } from './types.js';
1
+ import type { FixtureId } from '../userModules/fixtureTypes.js';
2
+ import type { FixtureTreeNode } from './types.js';
3
3
  export type FlatFixtureTreeItem = {
4
4
  fileName: string;
5
5
  fixtureId: FixtureId;
@@ -1,4 +1,4 @@
1
- import { TreeNode } from '../utils/tree.js';
1
+ import type { TreeNode } from '../utils/tree.js';
2
2
  export type FixtureTreeNode = TreeNode<{
3
3
  type: 'fileDir';
4
4
  } | {
package/dist/index.d.ts CHANGED
@@ -32,6 +32,9 @@ export * from './userModules/stringifyFixtureId.js';
32
32
  export * from './userModules/userModuleTypes.js';
33
33
  export * from './utils/array.js';
34
34
  export * from './utils/data.js';
35
+ export * from './utils/isEqual.js';
36
+ export * from './utils/mapValues.js';
37
+ export * from './utils/pathUtils.js';
35
38
  export * from './utils/keys.js';
36
39
  export * from './utils/queryString.js';
37
40
  export * from './utils/react/areNodesEqual.js';
package/dist/index.js CHANGED
@@ -32,6 +32,9 @@ export * from './userModules/stringifyFixtureId.js';
32
32
  export * from './userModules/userModuleTypes.js';
33
33
  export * from './utils/array.js';
34
34
  export * from './utils/data.js';
35
+ export * from './utils/isEqual.js';
36
+ export * from './utils/mapValues.js';
37
+ export * from './utils/pathUtils.js';
35
38
  export * from './utils/keys.js';
36
39
  export * from './utils/queryString.js';
37
40
  export * from './utils/react/areNodesEqual.js';
@@ -1,4 +1,4 @@
1
- import { FixtureId } from '../userModules/fixtureTypes.js';
1
+ import type { FixtureId } from '../userModules/fixtureTypes.js';
2
2
  export type PlaygroundParams = {
3
3
  fixture?: FixtureId;
4
4
  };
@@ -1,3 +1,3 @@
1
- import { PlaygroundParams } from './playgroundParams.js';
1
+ import type { PlaygroundParams } from './playgroundParams.js';
2
2
  export declare function buildPlaygroundQueryString(params: PlaygroundParams): string;
3
3
  export declare function parsePlaygroundQueryString(query: string): PlaygroundParams;
@@ -1,6 +1,6 @@
1
- import { FixtureState } from '../fixtureState/types.js';
2
- import { NotificationItem, TimedNotificationItem } from '../playground/notifications.js';
3
- import { FixtureId, FixtureList, FixtureListItem } from '../userModules/fixtureTypes.js';
1
+ import type { FixtureState } from '../fixtureState/types.js';
2
+ import type { NotificationItem, TimedNotificationItem } from '../playground/notifications.js';
3
+ import type { FixtureId, FixtureList, FixtureListItem } from '../userModules/fixtureTypes.js';
4
4
  export type RendererId = string;
5
5
  export type PingRenderersRequest = {
6
6
  type: 'pingRenderers';
@@ -1,4 +1,4 @@
1
- import { FixtureId } from '../userModules/fixtureTypes.js';
1
+ import type { FixtureId } from '../userModules/fixtureTypes.js';
2
2
  type RendererParams = {
3
3
  fixtureId?: FixtureId;
4
4
  locked?: boolean;
@@ -1,5 +1,5 @@
1
- import { CosmosMode } from '../server/serverTypes.js';
2
- import { FixtureId } from '../userModules/fixtureTypes.js';
1
+ import type { CosmosMode } from '../server/serverTypes.js';
2
+ import type { FixtureId } from '../userModules/fixtureTypes.js';
3
3
  export type CosmosRendererUrl = null | string | {
4
4
  dev: string;
5
5
  export: string;
@@ -39,7 +39,7 @@ function hostOnlyUrl(url) {
39
39
  const { protocol, pathname } = new URL(url);
40
40
  return (protocol === 'http:' || protocol === 'https:') && pathname === '/';
41
41
  }
42
- catch (err) {
42
+ catch {
43
43
  return false;
44
44
  }
45
45
  }
@@ -1,2 +1,2 @@
1
- import { ReactFixture, ReactFixtureExport } from './userModuleTypes.js';
1
+ import type { ReactFixture, ReactFixtureExport } from './userModuleTypes.js';
2
2
  export declare function getFixtureFromExport(fixtureExport: ReactFixtureExport, fixtureName?: string): void | ReactFixture;
@@ -1,5 +1,5 @@
1
- import { FixtureList, FixtureListItem } from './fixtureTypes.js';
2
- import { ByPath, ReactFixtureExport, UserModuleWrappers } from './userModuleTypes.js';
1
+ import type { FixtureList, FixtureListItem } from './fixtureTypes.js';
2
+ import type { ByPath, ReactFixtureExport, UserModuleWrappers } from './userModuleTypes.js';
3
3
  export declare function getFixtureListFromWrappers(wrappers: UserModuleWrappers): FixtureList;
4
4
  export declare function getFixtureListFromExports(exports: ByPath<ReactFixtureExport>): {
5
5
  [x: string]: FixtureListItem;
@@ -1,2 +1,2 @@
1
- import { ByPath } from './userModuleTypes.js';
1
+ import type { ByPath } from './userModuleTypes.js';
2
2
  export declare function getSortedDecoratorsForFixturePath<T>(fixturePath: string, decoratorsByPath: ByPath<T>): T[];
@@ -1,2 +1,2 @@
1
- import { ReactFixtureExport, ReactFixtureMap } from './userModuleTypes.js';
1
+ import type { ReactFixtureExport, ReactFixtureMap } from './userModuleTypes.js';
2
2
  export declare function isMultiFixture(fixtureExport: ReactFixtureExport): fixtureExport is ReactFixtureMap;
@@ -1,2 +1,2 @@
1
- import { FixtureId } from './fixtureTypes.js';
1
+ import type { FixtureId } from './fixtureTypes.js';
2
2
  export declare function stringifyFixtureId(fixtureId: FixtureId): string;
@@ -1,4 +1,4 @@
1
- import { ComponentType, ReactNode } from 'react';
1
+ import type { ComponentType, ReactNode } from 'react';
2
2
  type FixtureMap<FixtureType> = {
3
3
  [fixtureName: string]: FixtureType;
4
4
  };
@@ -1,4 +1,3 @@
1
- import { findIndex } from 'lodash-es';
2
1
  export function updateItem(items, item, update) {
3
2
  const index = items.indexOf(item);
4
3
  return [
@@ -8,13 +7,13 @@ export function updateItem(items, item, update) {
8
7
  ];
9
8
  }
10
9
  export function replaceOrAddItem(items, matcher, item) {
11
- const index = findIndex(items, matcher);
10
+ const index = items.findIndex(matcher);
12
11
  return index !== -1
13
12
  ? [...items.slice(0, index), item, ...items.slice(index + 1)]
14
13
  : [...items, item];
15
14
  }
16
15
  export function removeItemMatch(items, matcher) {
17
- const index = findIndex(items, matcher);
16
+ const index = items.findIndex(matcher);
18
17
  return index === -1
19
18
  ? [...items]
20
19
  : [...items.slice(0, index), ...items.slice(index + 1)];
@@ -1,4 +1,3 @@
1
- import { isPlainObject } from 'lodash-es';
2
1
  import { isValidElement } from 'react';
3
2
  export function isString(value) {
4
3
  return typeof value === 'string';
@@ -23,7 +22,10 @@ export function isPrimitiveData(data) {
23
22
  isUndefined(data));
24
23
  }
25
24
  export function isObject(data) {
26
- return isPlainObject(data) && !isValidElement(data);
25
+ if (data === null || typeof data !== 'object' || isValidElement(data))
26
+ return false;
27
+ const proto = Object.getPrototypeOf(data);
28
+ return proto === Object.prototype || proto === null;
27
29
  }
28
30
  export function isArray(data) {
29
31
  return Array.isArray(data);
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Deep equality for the subset of values that appear in react-cosmos
3
+ * fixture state, props, and element IDs.
4
+ *
5
+ * Handles: primitives (NaN and +0/-0 are treated as equal), Date, RegExp,
6
+ * Map, Set, arrays, and plain objects (enumerable own keys only).
7
+ *
8
+ * Not handled — do not rely on correct results for these:
9
+ * - Circular references (will stack overflow).
10
+ * - Sets containing non-primitives (compared by identity, not structure).
11
+ * - Symbol-keyed properties (ignored).
12
+ * - TypedArrays / ArrayBuffer / Error / arguments objects (fall through
13
+ * to the plain-object branch).
14
+ */
15
+ export declare function isEqual(a: unknown, b: unknown): boolean;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Deep equality for the subset of values that appear in react-cosmos
3
+ * fixture state, props, and element IDs.
4
+ *
5
+ * Handles: primitives (NaN and +0/-0 are treated as equal), Date, RegExp,
6
+ * Map, Set, arrays, and plain objects (enumerable own keys only).
7
+ *
8
+ * Not handled — do not rely on correct results for these:
9
+ * - Circular references (will stack overflow).
10
+ * - Sets containing non-primitives (compared by identity, not structure).
11
+ * - Symbol-keyed properties (ignored).
12
+ * - TypedArrays / ArrayBuffer / Error / arguments objects (fall through
13
+ * to the plain-object branch).
14
+ */
15
+ export function isEqual(a, b) {
16
+ if (a === b || (Number.isNaN(a) && Number.isNaN(b)))
17
+ return true;
18
+ if (a === null ||
19
+ b === null ||
20
+ typeof a !== 'object' ||
21
+ typeof b !== 'object')
22
+ return false;
23
+ if (a.constructor !== b.constructor)
24
+ return false;
25
+ if (a instanceof Date)
26
+ return a.getTime() === b.getTime();
27
+ if (a instanceof RegExp)
28
+ return a.source === b.source && a.flags === b.flags;
29
+ if (a instanceof Map) {
30
+ const mb = b;
31
+ if (a.size !== mb.size)
32
+ return false;
33
+ for (const [key, val] of a) {
34
+ if (!mb.has(key) || !isEqual(val, mb.get(key)))
35
+ return false;
36
+ }
37
+ return true;
38
+ }
39
+ if (a instanceof Set) {
40
+ const sb = b;
41
+ if (a.size !== sb.size)
42
+ return false;
43
+ for (const val of a) {
44
+ if (!sb.has(val))
45
+ return false;
46
+ }
47
+ return true;
48
+ }
49
+ if (Array.isArray(a)) {
50
+ const arrB = b;
51
+ if (a.length !== arrB.length)
52
+ return false;
53
+ return a.every((val, i) => isEqual(val, arrB[i]));
54
+ }
55
+ const keysA = Object.keys(a);
56
+ const keysB = Object.keys(b);
57
+ if (keysA.length !== keysB.length)
58
+ return false;
59
+ return keysA.every(key => Object.hasOwn(b, key) &&
60
+ isEqual(a[key], b[key]));
61
+ }
@@ -0,0 +1 @@
1
+ export declare function mapValues<T, R>(obj: Record<string, T>, fn: (value: T, key: string) => R): Record<string, R>;
@@ -0,0 +1,3 @@
1
+ export function mapValues(obj, fn) {
2
+ return Object.fromEntries(Object.entries(obj).map(([k, v]) => [k, fn(v, k)]));
3
+ }
@@ -0,0 +1,2 @@
1
+ export declare function getByPath<T extends object>(obj: T, path: string): unknown;
2
+ export declare function setByPath<T extends object>(obj: T, path: string, value: unknown): T;
@@ -0,0 +1,35 @@
1
+ export function getByPath(obj, path) {
2
+ let cur = obj;
3
+ for (const key of parsePath(path)) {
4
+ if (cur === null || cur === undefined)
5
+ return undefined;
6
+ cur = cur[key];
7
+ }
8
+ return cur;
9
+ }
10
+ export function setByPath(obj, path, value) {
11
+ const keys = parsePath(path);
12
+ function set(current, index) {
13
+ if (index === keys.length)
14
+ return value;
15
+ const key = keys[index];
16
+ const cur = current;
17
+ const next = set(cur?.[key], index + 1);
18
+ if (Array.isArray(current)) {
19
+ const copy = [...current];
20
+ copy[key] = next;
21
+ return copy;
22
+ }
23
+ return { ...cur, [key]: next };
24
+ }
25
+ return set(obj, 0);
26
+ }
27
+ // Parse paths like "props.children[0].props.children"
28
+ // into segments like ["props", "children", 0, "props", "children"]
29
+ function parsePath(path) {
30
+ return path
31
+ .replace(/\[(\d+)]/g, '.$1') // [0] → .0
32
+ .split('.')
33
+ .filter(s => s !== '')
34
+ .map(s => (/^\d+$/.test(s) ? Number(s) : s));
35
+ }
@@ -1,2 +1,2 @@
1
- import { ReactNode } from 'react';
1
+ import type { ReactNode } from 'react';
2
2
  export declare function areNodesEqual(node1: ReactNode, node2: ReactNode, strictTypeCheck: boolean): boolean;
@@ -1,4 +1,5 @@
1
- import { isEqual, isEqualWith } from 'lodash-es';
1
+ import { isObject } from '../data.js';
2
+ import { isEqual } from '../isEqual.js';
2
3
  import { getComponentName } from './getComponentName.js';
3
4
  import { isReactElement } from './isReactElement.js';
4
5
  export function areNodesEqual(node1, node2, strictTypeCheck) {
@@ -29,9 +30,25 @@ function areArrayNodesEqual(node1, node2, strictTypeCheck) {
29
30
  return node1.every((node, nodeIndex) => areNodesEqual(node, node2[nodeIndex], strictTypeCheck));
30
31
  }
31
32
  function arePropsEqual(object1, object2) {
32
- if (!isEqual(Object.keys(object1), Object.keys(object2)))
33
+ const keys1 = Object.keys(object1);
34
+ const keys2 = Object.keys(object2);
35
+ if (keys1.length !== keys2.length)
33
36
  return false;
34
- return Object.keys(object1).every(key => isEqualWith(object1[key], object2[key], (value1, value2) => typeof value1 === 'function' && typeof value2 === 'function'
35
- ? value1 === value2 || value1.toString() === value2.toString()
36
- : isEqual(value1, value2)));
37
+ return keys1.every(key => Object.prototype.hasOwnProperty.call(object2, key) &&
38
+ arePropValuesEqual(object1[key], object2[key]));
39
+ }
40
+ // Recurse into plain objects and arrays so that functions at any depth are
41
+ // compared by their source code, not by reference. This makes prop comparison
42
+ // resilient to HMR, which creates fresh function instances on every reload.
43
+ function arePropValuesEqual(value1, value2) {
44
+ if (typeof value1 === 'function' && typeof value2 === 'function')
45
+ return value1 === value2 || value1.toString() === value2.toString();
46
+ if (isObject(value1) && isObject(value2))
47
+ return arePropsEqual(value1, value2);
48
+ if (Array.isArray(value1) && Array.isArray(value2)) {
49
+ if (value1.length !== value2.length)
50
+ return false;
51
+ return value1.every((v, i) => arePropValuesEqual(v, value2[i]));
52
+ }
53
+ return isEqual(value1, value2);
37
54
  }
@@ -1,2 +1,2 @@
1
- import { ComponentType } from 'react';
1
+ import type { ComponentType } from 'react';
2
2
  export declare function getComponentName(type: string | ComponentType): string;
@@ -1,4 +1,4 @@
1
- import { ReactElement, ReactNode } from 'react';
1
+ import type { ReactElement, ReactNode } from 'react';
2
2
  export type ReactElementWithChildren = ReactElement<{
3
3
  children?: ReactNode | Function;
4
4
  [key: string]: unknown;
@@ -1,6 +1,6 @@
1
1
  import { isArray, isObject, isPrimitiveData } from './data.js';
2
2
  export function pickSerializableValues(object) {
3
- return Object.fromEntries(Object.entries(object).filter(([k, v]) => isSerializable(v)));
3
+ return Object.fromEntries(Object.entries(object).filter(([, v]) => isSerializable(v)));
4
4
  }
5
5
  export function isSerializable(data) {
6
6
  if (isObject(data))
@@ -2,7 +2,7 @@ export function isInsideWindowIframe() {
2
2
  try {
3
3
  return window.self !== window.parent;
4
4
  }
5
- catch (e) {
5
+ catch {
6
6
  return true;
7
7
  }
8
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-cosmos-core",
3
- "version": "7.2.0",
3
+ "version": "7.2.1-canary.0004fe7.0+0004fe7",
4
4
  "description": "React Cosmos Core",
5
5
  "repository": "https://github.com/react-cosmos/react-cosmos/tree/main/packages/react-cosmos-core",
6
6
  "license": "MIT",
@@ -8,11 +8,10 @@
8
8
  "sideEffects": false,
9
9
  "main": "./dist/index.js",
10
10
  "dependencies": {
11
- "js-base64": "3.7.8",
12
- "lodash-es": "4.17.23"
11
+ "js-base64": "3.7.8"
13
12
  },
14
13
  "peerDependencies": {
15
14
  "react": ">=18"
16
15
  },
17
- "gitHead": "c1f63d79b3235011fb9f1a919378b95a59fff02e"
16
+ "gitHead": "0004fe756e5584e482ea2acd8a2e7d29cdac2675"
18
17
  }
@@ -0,0 +1 @@
1
+ {"version":"7.0.0-dev.20260417.1","root":["./src/index.ts","./src/fixtureState/classState.ts","./src/fixtureState/classStateTypes.ts","./src/fixtureState/createValues.ts","./src/fixtureState/extendWithValues.ts","./src/fixtureState/fixtureState.ts","./src/fixtureState/inputsTypes.ts","./src/fixtureState/props.ts","./src/fixtureState/propsTypes.ts","./src/fixtureState/types.ts","./src/fixtureState/viewport.ts","./src/fixtureTree/fixtureUtils.ts","./src/fixtureTree/flattenFixtureTree.tsx","./src/fixtureTree/types.ts","./src/fixtureTree/createFixtureTree/collapseFixtureDirs.ts","./src/fixtureTree/createFixtureTree/collapseIndexes.ts","./src/fixtureTree/createFixtureTree/collapseNamedIndexes.ts","./src/fixtureTree/createFixtureTree/collapseOuterDirs.ts","./src/fixtureTree/createFixtureTree/createRawFixtureTree.ts","./src/fixtureTree/createFixtureTree/hideFixtureSuffix.ts","./src/fixtureTree/createFixtureTree/index.ts","./src/message/serverMessage.ts","./src/message/socketMessage.ts","./src/playground/notifications.ts","./src/playground/playgroundParams.ts","./src/playground/playgroundQueryString.ts","./src/playground/registerPlaygroundShortcuts.ts","./src/plugin/cosmosPluginConfig.ts","./src/renderer/rendererConfig.ts","./src/renderer/rendererConnect.ts","./src/renderer/rendererQueryString.ts","./src/renderer/rendererUrl.ts","./src/server/serverTypes.ts","./src/userModules/fixtureTypes.ts","./src/userModules/getFixtureFromExport.ts","./src/userModules/getFixtureList.ts","./src/userModules/getSortedDecoratorsForFixturePath.ts","./src/userModules/isMultiFixture.ts","./src/userModules/stringifyFixtureId.ts","./src/userModules/userModuleTypes.ts","./src/utils/array.ts","./src/utils/data.ts","./src/utils/isEqual.ts","./src/utils/keys.ts","./src/utils/mapValues.ts","./src/utils/pathUtils.ts","./src/utils/queryString.ts","./src/utils/serializable.ts","./src/utils/state.ts","./src/utils/string.ts","./src/utils/tree.ts","./src/utils/uuid.ts","./src/utils/window.ts","./src/utils/react/DelayRender.tsx","./src/utils/react/areNodesEqual.ts","./src/utils/react/getComponentName.ts","./src/utils/react/isReactElement.ts"]}
@@ -1 +0,0 @@
1
- {"root":["../src/index.ts","../src/fixturestate/classstate.ts","../src/fixturestate/classstatetypes.ts","../src/fixturestate/createvalues.ts","../src/fixturestate/extendwithvalues.ts","../src/fixturestate/fixturestate.ts","../src/fixturestate/inputstypes.ts","../src/fixturestate/props.ts","../src/fixturestate/propstypes.ts","../src/fixturestate/types.ts","../src/fixturestate/viewport.ts","../src/fixturetree/fixtureutils.ts","../src/fixturetree/flattenfixturetree.tsx","../src/fixturetree/types.ts","../src/fixturetree/createfixturetree/collapsefixturedirs.ts","../src/fixturetree/createfixturetree/collapseindexes.ts","../src/fixturetree/createfixturetree/collapsenamedindexes.ts","../src/fixturetree/createfixturetree/collapseouterdirs.ts","../src/fixturetree/createfixturetree/createrawfixturetree.ts","../src/fixturetree/createfixturetree/hidefixturesuffix.ts","../src/fixturetree/createfixturetree/index.ts","../src/message/servermessage.ts","../src/message/socketmessage.ts","../src/playground/notifications.ts","../src/playground/playgroundparams.ts","../src/playground/playgroundquerystring.ts","../src/playground/registerplaygroundshortcuts.ts","../src/plugin/cosmospluginconfig.ts","../src/renderer/rendererconfig.ts","../src/renderer/rendererconnect.ts","../src/renderer/rendererquerystring.ts","../src/renderer/rendererurl.ts","../src/server/servertypes.ts","../src/usermodules/fixturetypes.ts","../src/usermodules/getfixturefromexport.ts","../src/usermodules/getfixturelist.ts","../src/usermodules/getsorteddecoratorsforfixturepath.ts","../src/usermodules/ismultifixture.ts","../src/usermodules/stringifyfixtureid.ts","../src/usermodules/usermoduletypes.ts","../src/utils/array.ts","../src/utils/data.ts","../src/utils/keys.ts","../src/utils/querystring.ts","../src/utils/serializable.ts","../src/utils/state.ts","../src/utils/string.ts","../src/utils/tree.ts","../src/utils/uuid.ts","../src/utils/window.ts","../src/utils/react/delayrender.tsx","../src/utils/react/arenodesequal.ts","../src/utils/react/getcomponentname.ts","../src/utils/react/isreactelement.ts"],"version":"5.9.3"}