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

react-cosmos-shared2

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-cosmos-shared2 - npm Package Compare versions

Comparing version 5.0.0-beta.5 to 5.0.0-beta.7

dist/FixtureLoader/FixtureCapture/classState/decorateFixtureRefs/index.d.ts

2

dist/build.js

@@ -7,3 +7,3 @@ "use strict";

exports.SERVER_MESSAGE_EVENT_NAME = void 0;
const SERVER_MESSAGE_EVENT_NAME = 'cosmos-build-message';
var SERVER_MESSAGE_EVENT_NAME = 'cosmos-build-message';
exports.SERVER_MESSAGE_EVENT_NAME = SERVER_MESSAGE_EVENT_NAME;

@@ -17,39 +17,36 @@ "use strict";

function getFixtureStateClassState(fixtureState, decoratorId) {
const {
classState
} = fixtureState;
return classState ? classState.filter(s => s.elementId.decoratorId === decoratorId) : [];
var classState = fixtureState.classState;
return classState ? classState.filter(function (s) {
return s.elementId.decoratorId === decoratorId;
}) : [];
}
function findFixtureStateClassState(fixtureState, elementId) {
const {
classState
} = fixtureState;
return classState && (0, _lodash.find)(classState, s => (0, _lodash.isEqual)(s.elementId, elementId));
var classState = fixtureState.classState;
return classState && (0, _lodash.find)(classState, function (s) {
return (0, _lodash.isEqual)(s.elementId, elementId);
});
}
function createFixtureStateClassState({
fixtureState,
elementId,
values,
componentName
}) {
const {
classState = []
} = fixtureState;
function createFixtureStateClassState(_ref) {
var fixtureState = _ref.fixtureState,
elementId = _ref.elementId,
values = _ref.values,
componentName = _ref.componentName;
var _fixtureState$classSt = fixtureState.classState,
classState = _fixtureState$classSt === void 0 ? [] : _fixtureState$classSt;
return (0, _util.replaceOrAddItem)(classState, createClassStateMatcher(elementId), {
elementId,
values,
componentName
elementId: elementId,
values: values,
componentName: componentName
});
}
function updateFixtureStateClassState({
fixtureState,
elementId,
values
}) {
const classStateItem = expectFixtureStateClassState(fixtureState, elementId);
function updateFixtureStateClassState(_ref2) {
var fixtureState = _ref2.fixtureState,
elementId = _ref2.elementId,
values = _ref2.values;
var classStateItem = expectFixtureStateClassState(fixtureState, elementId);
return (0, _util.updateItem)(fixtureState.classState, classStateItem, {
values
values: values
});

@@ -63,11 +60,13 @@ }

function createClassStateMatcher(elementId) {
return p => (0, _lodash.isEqual)(p.elementId, elementId);
return function (p) {
return (0, _lodash.isEqual)(p.elementId, elementId);
};
}
function expectFixtureStateClassState(fixtureState, elementId) {
const classStateItem = findFixtureStateClassState(fixtureState, elementId);
var classStateItem = findFixtureStateClassState(fixtureState, elementId);
if (!classStateItem) {
const elId = JSON.stringify(elementId);
throw new Error(`Fixture state class state missing for element "${elId}"`);
var elId = JSON.stringify(elementId);
throw new Error("Fixture state class state missing for element \"".concat(elId, "\""));
}

@@ -74,0 +73,0 @@

@@ -18,6 +18,8 @@ "use strict";

function createValues(obj) {
const values = {};
var values = {};
Object.keys(obj) // Ignore noise from attrs defined as undefined (eg. props.children is
// often `undefined` if element has no children)
.filter(key => obj[key] !== undefined).forEach(key => {
.filter(function (key) {
return obj[key] !== undefined;
}).forEach(function (key) {
values[key] = createValue(obj[key]);

@@ -32,3 +34,3 @@ });

type: 'primitive',
value
value: value
};

@@ -40,3 +42,5 @@ }

type: 'array',
values: value.map(v => createValue(v))
values: value.map(function (v) {
return createValue(v);
})
};

@@ -43,0 +47,0 @@ }

@@ -13,4 +13,4 @@ "use strict";

function extendWithValues(obj, values) {
const extendedObj = {};
Object.keys(values).forEach(key => {
var extendedObj = {};
Object.keys(values).forEach(function (key) {
extendedObj[key] = extendWithValue(obj[key], values[key]);

@@ -27,3 +27,3 @@ });

if (value.type === 'object') {
const baseObj = (0, _shared.isObject)(baseValue) ? baseValue : {};
var baseObj = (0, _shared.isObject)(baseValue) ? baseValue : {};
return extendWithValues(baseObj, value.values);

@@ -33,4 +33,6 @@ }

if (value.type === 'array') {
const baseArr = (0, _shared.isArray)(baseValue) ? baseValue : [];
return value.values.map((v, idx) => extendWithValue(baseArr[idx], v));
var baseArr = (0, _shared.isArray)(baseValue) ? baseValue : [];
return value.values.map(function (v, idx) {
return extendWithValue(baseArr[idx], v);
});
}

@@ -37,0 +39,0 @@

@@ -8,3 +8,3 @@ "use strict";

enumerable: true,
get: function () {
get: function get() {
return _shared.isString;

@@ -15,3 +15,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _shared.isNumber;

@@ -22,3 +22,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _shared.isBoolean;

@@ -29,3 +29,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _shared.isNull;

@@ -36,3 +36,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _shared.isPrimitiveValue;

@@ -43,3 +43,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _shared.isObject;

@@ -50,3 +50,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _shared.isArray;

@@ -57,3 +57,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _createValues.createValues;

@@ -64,3 +64,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _createValues.createValue;

@@ -71,3 +71,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _extendWithValues.extendWithValues;

@@ -78,3 +78,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _extendWithValues.extendWithValue;

@@ -85,3 +85,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _props.DEFAULT_RENDER_KEY;

@@ -92,3 +92,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _props.getFixtureStateProps;

@@ -99,3 +99,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _props.findFixtureStateProps;

@@ -106,3 +106,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _props.createFixtureStateProps;

@@ -113,3 +113,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _props.resetFixtureStateProps;

@@ -120,3 +120,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _props.updateFixtureStateProps;

@@ -127,3 +127,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _props.removeFixtureStateProps;

@@ -134,3 +134,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _classState.getFixtureStateClassState;

@@ -141,3 +141,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _classState.findFixtureStateClassState;

@@ -148,3 +148,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _classState.createFixtureStateClassState;

@@ -155,3 +155,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _classState.updateFixtureStateClassState;

@@ -162,3 +162,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _classState.removeFixtureStateClassState;

@@ -169,3 +169,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _values.findFixtureStateValue;

@@ -172,0 +172,0 @@ }

@@ -18,44 +18,41 @@ "use strict";

const DEFAULT_RENDER_KEY = 0;
var DEFAULT_RENDER_KEY = 0;
exports.DEFAULT_RENDER_KEY = DEFAULT_RENDER_KEY;
function getFixtureStateProps(fixtureState, decoratorId) {
const {
props
} = fixtureState;
return props ? props.filter(p => p.elementId.decoratorId === decoratorId) : [];
var props = fixtureState.props;
return props ? props.filter(function (p) {
return p.elementId.decoratorId === decoratorId;
}) : [];
}
function findFixtureStateProps(fixtureState, elementId) {
const {
props
} = fixtureState;
return props && (0, _lodash.find)(props, p => (0, _lodash.isEqual)(p.elementId, elementId));
var props = fixtureState.props;
return props && (0, _lodash.find)(props, function (p) {
return (0, _lodash.isEqual)(p.elementId, elementId);
});
}
function createFixtureStateProps({
fixtureState,
elementId,
values,
componentName
}) {
const {
props = []
} = fixtureState;
function createFixtureStateProps(_ref) {
var fixtureState = _ref.fixtureState,
elementId = _ref.elementId,
values = _ref.values,
componentName = _ref.componentName;
var _fixtureState$props = fixtureState.props,
props = _fixtureState$props === void 0 ? [] : _fixtureState$props;
return (0, _util.replaceOrAddItem)(props, createPropsMatcher(elementId), {
elementId,
values,
elementId: elementId,
values: values,
renderKey: DEFAULT_RENDER_KEY,
componentName
componentName: componentName
});
}
function resetFixtureStateProps({
fixtureState,
elementId,
values
}) {
const propsItem = expectFixtureStateProps(fixtureState, elementId);
function resetFixtureStateProps(_ref2) {
var fixtureState = _ref2.fixtureState,
elementId = _ref2.elementId,
values = _ref2.values;
var propsItem = expectFixtureStateProps(fixtureState, elementId);
return (0, _util.updateItem)(fixtureState.props, propsItem, {
values,
values: values,
renderKey: propsItem.renderKey + 1

@@ -65,10 +62,9 @@ });

function updateFixtureStateProps({
fixtureState,
elementId,
values
}) {
const propsItem = expectFixtureStateProps(fixtureState, elementId);
function updateFixtureStateProps(_ref3) {
var fixtureState = _ref3.fixtureState,
elementId = _ref3.elementId,
values = _ref3.values;
var propsItem = expectFixtureStateProps(fixtureState, elementId);
return (0, _util.updateItem)(fixtureState.props, propsItem, {
values
values: values
});

@@ -82,11 +78,13 @@ }

function createPropsMatcher(elementId) {
return p => (0, _lodash.isEqual)(p.elementId, elementId);
return function (p) {
return (0, _lodash.isEqual)(p.elementId, elementId);
};
}
function expectFixtureStateProps(fixtureState, elementId) {
const propsItem = findFixtureStateProps(fixtureState, elementId);
var propsItem = findFixtureStateProps(fixtureState, elementId);
if (!propsItem) {
const elId = JSON.stringify(elementId);
throw new Error(`Fixture state props missing for element "${elId}"`);
var elId = JSON.stringify(elementId);
throw new Error("Fixture state props missing for element \"".concat(elId, "\""));
}

@@ -93,0 +91,0 @@

@@ -9,6 +9,4 @@ "use strict";

function findFixtureStateValue(fixtureState, inputName) {
const {
values
} = fixtureState;
var values = fixtureState.values;
return values && values[inputName];
}

@@ -20,3 +20,5 @@ "use strict";

if (Array.isArray(node1) && Array.isArray(node2)) {
return node1.every((node, nodeIndex) => areNodesEqual(node, node2[nodeIndex], strictTypeCheck));
return node1.every(function (node, nodeIndex) {
return areNodesEqual(node, node2[nodeIndex], strictTypeCheck);
});
}

@@ -23,0 +25,0 @@

@@ -7,3 +7,3 @@ "use strict";

exports.getComponentName = getComponentName;
const componentNames = new WeakMap();
var componentNames = new WeakMap();

@@ -16,3 +16,3 @@ function getComponentName(type) {

if (!componentNames.has(type)) {
const name = type.displayName || type.name || '';
var name = type.displayName || type.name || '';
componentNames.set(type, name);

@@ -19,0 +19,0 @@ }

@@ -11,5 +11,5 @@ "use strict";

function getFixtureNamesByPath(fixtureExportsByPath) {
const fixtureNamesByPath = {};
Object.keys(fixtureExportsByPath).forEach(fixturePath => {
const fixtureExport = fixtureExportsByPath[fixturePath];
var fixtureNamesByPath = {};
Object.keys(fixtureExportsByPath).forEach(function (fixturePath) {
var fixtureExport = fixtureExportsByPath[fixturePath];
fixtureNamesByPath[fixturePath] = (0, _isMultiFixture.isMultiFixture)(fixtureExport) ? Object.keys(fixtureExport) : null;

@@ -16,0 +16,0 @@ });

@@ -8,2 +8,10 @@ "use strict";

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

@@ -20,5 +28,7 @@

function getDecoratorsForFixturePath(decoratorsByPath, fixturePath) {
return Object.keys(decoratorsByPath).filter(dPath => fixturePath.indexOf(`${getParentPath(dPath)}/`) === 0).reduce((acc, dPath) => _objectSpread({}, acc, {
[dPath]: decoratorsByPath[dPath]
}), {});
return Object.keys(decoratorsByPath).filter(function (dPath) {
return fixturePath.indexOf("".concat(getParentPath(dPath), "/")) === 0;
}).reduce(function (acc, dPath) {
return _objectSpread({}, acc, _defineProperty({}, dPath, decoratorsByPath[dPath]));
}, {});
}

@@ -33,7 +43,11 @@

function getSortedDecorators(decoratorsByPath) {
return sortPathsByDepthAsc(Object.keys(decoratorsByPath)).map(decoratorPath => decoratorsByPath[decoratorPath]);
return sortPathsByDepthAsc(Object.keys(decoratorsByPath)).map(function (decoratorPath) {
return decoratorsByPath[decoratorPath];
});
}
function sortPathsByDepthAsc(paths) {
return [...paths].sort((a, b) => getPathNestingLevel(a) - getPathNestingLevel(b) || a.localeCompare(b));
return _toConsumableArray(paths).sort(function (a, b) {
return getPathNestingLevel(a) - getPathNestingLevel(b) || a.localeCompare(b);
});
}

@@ -40,0 +54,0 @@

@@ -8,3 +8,3 @@ "use strict";

enumerable: true,
get: function () {
get: function get() {
return _areNodesEqual.areNodesEqual;

@@ -15,3 +15,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _getComponentName.getComponentName;

@@ -22,3 +22,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _getFixtureNamesByPath.getFixtureNamesByPath;

@@ -29,3 +29,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _isMultiFixture.isMultiFixture;

@@ -36,3 +36,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _isReactElement.isReactElement;

@@ -43,3 +43,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _getSortedDecoratorsForFixturePath.getSortedDecoratorsForFixturePath;

@@ -46,0 +46,0 @@ }

@@ -10,4 +10,6 @@ "use strict";

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function isMultiFixture(fixtureExport) {
return fixtureExport !== null && typeof fixtureExport === 'object' && !(0, _reactIs.isElement)(fixtureExport);
return fixtureExport !== null && _typeof(fixtureExport) === 'object' && !(0, _reactIs.isElement)(fixtureExport);
}

@@ -12,3 +12,3 @@ "use strict";

// initial state is read.
const RENDERER_MESSAGE_EVENT_NAME = 'cosmos-renderer-message';
var RENDERER_MESSAGE_EVENT_NAME = 'cosmos-renderer-message';
exports.RENDERER_MESSAGE_EVENT_NAME = RENDERER_MESSAGE_EVENT_NAME;

@@ -12,1 +12,3 @@ import { FixtureId } from './renderer';

export declare function parseRendererUrlQuery(query: string): RendererUrlParams;
export declare function parseUrlQuery<T extends {}>(query: string): T;
export declare function stringifyUrlQuery(params: {}): string;

@@ -10,2 +10,4 @@ "use strict";

exports.parseRendererUrlQuery = parseRendererUrlQuery;
exports.parseUrlQuery = parseUrlQuery;
exports.stringifyUrlQuery = stringifyUrlQuery;

@@ -17,3 +19,3 @@ var _queryString = _interopRequireDefault(require("query-string"));

function stringifyPlaygroundUrlQuery(urlParams) {
const encodedUrlParams = {};
var encodedUrlParams = {};

@@ -28,4 +30,4 @@ if (urlParams.fixtureId) {

function parsePlaygroundUrlQuery(query) {
const encodedUrlParams = parseUrlQuery(query);
const decoded = {};
var encodedUrlParams = parseUrlQuery(query);
var decoded = {};

@@ -40,3 +42,3 @@ if (encodedUrlParams.fixtureId) {

function stringifyRendererUrlQuery(urlParams) {
const encodedUrlParams = {};
var encodedUrlParams = {};

@@ -51,4 +53,4 @@ if (urlParams._fixtureId) {

function parseRendererUrlQuery(query) {
const encodedUrlParams = parseUrlQuery(query);
const decoded = {};
var encodedUrlParams = parseUrlQuery(query);
var decoded = {};

@@ -64,2 +66,6 @@ if (encodedUrlParams._fixtureId) {

return _queryString.default.parse(query);
}
function stringifyUrlQuery(params) {
return _queryString.default.stringify(params);
}

@@ -18,15 +18,23 @@ "use strict";

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function updateItem(items, item, update) {
const index = items.indexOf(item);
return [...items.slice(0, index), _objectSpread({}, item, {}, update), ...items.slice(index + 1)];
var index = items.indexOf(item);
return [].concat(_toConsumableArray(items.slice(0, index)), [_objectSpread({}, item, {}, update)], _toConsumableArray(items.slice(index + 1)));
}
function replaceOrAddItem(items, matcher, item) {
const index = (0, _lodash.findIndex)(items, matcher);
return index !== -1 ? [...items.slice(0, index), item, ...items.slice(index + 1)] : [...items, item];
var index = (0, _lodash.findIndex)(items, matcher);
return index !== -1 ? [].concat(_toConsumableArray(items.slice(0, index)), [item], _toConsumableArray(items.slice(index + 1))) : [].concat(_toConsumableArray(items), [item]);
}
function removeItemMatch(items, matcher) {
const index = (0, _lodash.findIndex)(items, matcher);
return index === -1 ? [...items] : [...items.slice(0, index), ...items.slice(index + 1)];
var index = (0, _lodash.findIndex)(items, matcher);
return index === -1 ? _toConsumableArray(items) : [].concat(_toConsumableArray(items.slice(0, index)), _toConsumableArray(items.slice(index + 1)));
}

@@ -8,3 +8,3 @@ "use strict";

enumerable: true,
get: function () {
get: function get() {
return _array.updateItem;

@@ -15,3 +15,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _array.replaceOrAddItem;

@@ -22,3 +22,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _array.removeItemMatch;

@@ -29,3 +29,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _uuid.uuid;

@@ -32,0 +32,0 @@ }

{
"name": "react-cosmos-shared2",
"version": "5.0.0-beta.5",
"version": "5.0.0-beta.7",
"description": "Code shared between Cosmos packages",

@@ -9,7 +9,8 @@ "repository": "https://github.com/react-cosmos/react-cosmos/tree/master/packages/react-cosmos-shared2",

"lodash": "^4.17.15",
"query-string": "^6.8.3",
"query-string": "5.1.1",
"react-element-to-jsx-string": "^14.1.0",
"react-is": "^16.10.2"
"react-is": "^16.10.2",
"socket.io-client": "2.2.0"
},
"gitHead": "49e16ed61420d919c99b53e0b618400c1a8446ee"
"gitHead": "358d896696581bc3aaf53c4ff10f840fc0555ab5"
}
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