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

stent

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stent - npm Package Compare versions

Comparing version 3.5.6 to 3.5.7

2

CHANGELOG.md

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

## 3.5.3, 3.5.4, 3.5.5, 3.5.6
## 3.5.3, 3.5.4, 3.5.5, 3.5.6, 3.5.7

@@ -3,0 +3,0 @@ Changes in DevTools extension.

@@ -62,14 +62,33 @@ 'use strict';

it('should dispatch a `onMachineCreated` message and serialize the machine', function () {
var Component = function Component() {
return _react3.default.createElement(
'p',
null,
'Hello world'
);
};
_.Machine.create('Foo', {
state: { name: 'idle', answer: 42 },
state: { name: 'idle' },
transitions: {
idle: {
run: 'running',
obj: { name: 'bar', data: [{ answer: 42 }] },
func: function func() {},
gen: /*#__PURE__*/regeneratorRuntime.mark(function gen() {
return regeneratorRuntime.wrap(function gen$(_context) {
save: /*#__PURE__*/regeneratorRuntime.mark(function save() {
return regeneratorRuntime.wrap(function save$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return { name: 'fetching' };
case 2:
_context.t0 = this;
_context.next = 5;
return (0, _helpers.call)(api);
case 5:
_context.t1 = _context.sent;
_context.t0.success.call(_context.t0, _context.t1);
case 7:
case 'end':

@@ -79,7 +98,16 @@ return _context.stop();

}
}, gen, this);
}, save, this);
})
},
fetching: {
success: function success(state, answer) {
return { name: 'idle', answer: answer };
}
}
}
});
(0, _react.connect)(Component).with('Foo').map(function (machine) {
return {};
});
expect(window.top.postMessage).to.be.calledWith({

@@ -90,18 +118,31 @@ time: sinon.match.number,

meta: { middlewares: 1 },
machines: [{ name: 'Foo', state: { answer: 42, name: 'idle' } }],
machines: [{ name: "Foo", state: { name: "idle" } }],
machine: {
func: { __func: '<anonymous>' },
gen: { __func: '<anonymous>' },
obj: { __func: '<anonymous>' },
run: { __func: '<anonymous>' },
isIdle: { __func: '<anonymous>' },
name: 'Foo',
state: { name: 'idle', answer: 42 },
transitions: {
idle: {
func: { __func: 'func' },
gen: { __func: 'gen' },
obj: { data: [{ answer: 42 }], name: 'bar' },
run: 'running'
"name": "Foo",
"state": {
"name": "idle"
},
"transitions": {
"idle": {
"save": {
"__func": "save"
}
},
"fetching": {
"success": {
"__func": "success"
}
}
},
"isIdle": {
"__func": "<anonymous>"
},
"save": {
"__func": "<anonymous>"
},
"isFetching": {
"__func": "<anonymous>"
},
"success": {
"__func": "<anonymous>"
}

@@ -108,0 +149,0 @@ }

@@ -49,3 +49,6 @@ 'use strict';

var sanitize = function sanitize(something) {
var showErrorInConsole = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var result;
try {

@@ -59,2 +62,5 @@ result = JSON.parse(_circularJson2.default.stringify(something, function (key, value) {

} catch (error) {
if (showErrorInConsole) {
console.log(error);
}
result = null;

@@ -71,2 +77,5 @@ }

var DevTools = {
__sanitize: sanitize,
__formatYielded: formatYielded,
__message: message,
__api: function __api(m) {

@@ -73,0 +82,0 @@ Machine = m;

{
"name": "stent",
"version": "3.5.6",
"version": "3.5.7",
"description": "Stent is combining the ideas of redux with the concept of state machines",

@@ -5,0 +5,0 @@ "main": "lib",

@@ -44,13 +44,22 @@ import { Machine } from '../../';

it('should dispatch a `onMachineCreated` message and serialize the machine', function () {
const Component = () => <p>Hello world</p>;
Machine.create('Foo', {
state: { name: 'idle', answer: 42 },
state: { name: 'idle' },
transitions: {
idle: {
run: 'running',
obj: { name: 'bar', data: [{ answer: 42 }] },
func: function() {},
gen: function * () {}
save: function*() {
yield { name: 'fetching' };
this.success(yield call(api));
}
},
fetching: {
success(state, answer) {
return { name: 'idle', answer };
}
}
}
});
connectReactComponent(Component).with('Foo').map(machine => ({}));
expect(window.top.postMessage).to.be.calledWith({

@@ -61,18 +70,31 @@ time: sinon.match.number,

meta: { middlewares: 1 },
machines: [{ name: 'Foo', state: { answer: 42, name: 'idle' } }],
machines: [{ name: "Foo", state: { name: "idle" } }],
machine: {
func: { __func: '<anonymous>' },
gen: { __func: '<anonymous>' },
obj: { __func: '<anonymous>' },
run: { __func: '<anonymous>' },
isIdle: { __func: '<anonymous>' },
name: 'Foo',
state: { name: 'idle', answer: 42 },
transitions: {
idle: {
func: { __func: 'func' },
gen: { __func: 'gen' },
obj: { data: [{ answer: 42 }], name: 'bar' },
run: 'running'
"name": "Foo",
"state": {
"name": "idle"
},
"transitions": {
"idle": {
"save": {
"__func": "save"
}
},
"fetching": {
"success": {
"__func": "success"
}
}
},
"isIdle": {
"__func": "<anonymous>"
},
"save": {
"__func": "<anonymous>"
},
"isFetching": {
"__func": "<anonymous>"
},
"success": {
"__func": "<anonymous>"
}

@@ -79,0 +101,0 @@ }

@@ -36,4 +36,5 @@ import CircularJSON from 'circular-json';

}
const sanitize = something => {
const sanitize = (something, showErrorInConsole = false) => {
var result;
try {

@@ -47,2 +48,5 @@ result = JSON.parse(CircularJSON.stringify(something, function (key, value) {

} catch(error) {
if (showErrorInConsole) {
console.log(error);
}
result = null;

@@ -59,2 +63,5 @@ }

const DevTools = {
__sanitize: sanitize,
__formatYielded: formatYielded,
__message: message,
__api(m) {

@@ -61,0 +68,0 @@ Machine = m;

@@ -50,3 +50,6 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.stentDevTools = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

var sanitize = function sanitize(something) {
var showErrorInConsole = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var result;
try {

@@ -60,2 +63,5 @@ result = JSON.parse(_circularJson2.default.stringify(something, function (key, value) {

} catch (error) {
if (showErrorInConsole) {
console.log(error);
}
result = null;

@@ -72,2 +78,5 @@ }

var DevTools = {
__sanitize: sanitize,
__formatYielded: formatYielded,
__message: message,
__api: function __api(m) {

@@ -74,0 +83,0 @@ Machine = m;

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

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.stentDevTools=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){"use strict";exports.__esModule=true;var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};var _circularJson=require("circular-json");var _circularJson2=_interopRequireDefault(_circularJson);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var Machine;var message=function message(data){if(window&&window.top&&window.top.postMessage){var machines=Object.keys(Machine.machines).map(function(name){return{name:name,state:sanitize(Machine.machines[name].state)}});window.top.postMessage(_extends({source:"stent",time:(new Date).getTime(),machines:machines},data),"*")}else{console.error("There is no window.postMessage available")}};var formatYielded=function formatYielded(yielded){var y=yielded;if(yielded&&yielded.__type==="call"){var funcName=yielded.func.name;if(funcName===""){funcName="<anonymous>"}try{y=JSON.parse(JSON.stringify(yielded))}catch(error){y={__type:"call"}}y.func=funcName}return y};var sanitize=function sanitize(something){var result;try{result=JSON.parse(_circularJson2.default.stringify(something,function(key,value){if(typeof value==="function"){return{__func:value.name===""?"<anonymous>":value.name}}return value}))}catch(error){result=null}return result};var getMetaInfo=function getMetaInfo(meta){return Object.assign({},meta,{middlewares:Machine.middlewares.length})};var DevTools={__api:function __api(m){Machine=m},onMachineCreated:function onMachineCreated(machine){message({type:"onMachineCreated",machine:sanitize(machine),meta:getMetaInfo()})},onActionDispatched:function onActionDispatched(actionName){for(var _len=arguments.length,args=Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key]}message({type:"onActionDispatched",actionName:actionName,args:sanitize(args),machine:sanitize(this),meta:getMetaInfo()})},onActionProcessed:function onActionProcessed(actionName){for(var _len2=arguments.length,args=Array(_len2>1?_len2-1:0),_key2=1;_key2<_len2;_key2++){args[_key2-1]=arguments[_key2]}message({type:"onActionProcessed",actionName:actionName,args:sanitize(args),machine:sanitize(this),meta:getMetaInfo()})},onStateWillChange:function onStateWillChange(){message({type:"onStateWillChange",machine:sanitize(this),meta:getMetaInfo()})},onStateChanged:function onStateChanged(){message({type:"onStateChanged",machine:sanitize(this),meta:getMetaInfo()})},onGeneratorStep:function onGeneratorStep(yielded){message({type:"onGeneratorStep",yielded:formatYielded(yielded),meta:getMetaInfo()})},onMachineConnected:function onMachineConnected(machines,meta){message({type:"onMachineConnected",meta:getMetaInfo(_extends({},meta,{machines:sanitize(machines)}))})},onMachineDisconnected:function onMachineDisconnected(machines,meta){message({type:"onMachineDisconnected",meta:getMetaInfo(_extends({},meta,{machines:sanitize(machines)}))})},onMiddlewareRegister:function onMiddlewareRegister(){message({pageRefresh:true})}};exports.default=DevTools;module.exports=exports["default"]},{"circular-json":2}],2:[function(require,module,exports){var specialChar="~",safeSpecialChar="\\x"+("0"+specialChar.charCodeAt(0).toString(16)).slice(-2),escapedSafeSpecialChar="\\"+safeSpecialChar,specialCharRG=new RegExp(safeSpecialChar,"g"),safeSpecialCharRG=new RegExp(escapedSafeSpecialChar,"g"),safeStartWithSpecialCharRG=new RegExp("(?:^|([^\\\\]))"+escapedSafeSpecialChar),indexOf=[].indexOf||function(v){for(var i=this.length;i--&&this[i]!==v;);return i},$String=String;function generateReplacer(value,replacer,resolve){var inspect=!!replacer,path=[],all=[value],seen=[value],mapp=[resolve?specialChar:"[Circular]"],last=value,lvl=1,i,fn;if(inspect){fn=typeof replacer==="object"?function(key,value){return key!==""&&replacer.indexOf(key)<0?void 0:value}:replacer}return function(key,value){if(inspect)value=fn.call(this,key,value);if(key!==""){if(last!==this){i=lvl-indexOf.call(all,this)-1;lvl-=i;all.splice(lvl,all.length);path.splice(lvl-1,path.length);last=this}if(typeof value==="object"&&value){if(indexOf.call(all,value)<0){all.push(last=value)}lvl=all.length;i=indexOf.call(seen,value);if(i<0){i=seen.push(value)-1;if(resolve){path.push((""+key).replace(specialCharRG,safeSpecialChar));mapp[i]=specialChar+path.join(specialChar)}else{mapp[i]=mapp[0]}}else{value=mapp[i]}}else{if(typeof value==="string"&&resolve){value=value.replace(safeSpecialChar,escapedSafeSpecialChar).replace(specialChar,safeSpecialChar)}}}return value}}function retrieveFromPath(current,keys){for(var i=0,length=keys.length;i<length;current=current[keys[i++].replace(safeSpecialCharRG,specialChar)]);return current}function generateReviver(reviver){return function(key,value){var isString=typeof value==="string";if(isString&&value.charAt(0)===specialChar){return new $String(value.slice(1))}if(key==="")value=regenerate(value,value,{});if(isString)value=value.replace(safeStartWithSpecialCharRG,"$1"+specialChar).replace(escapedSafeSpecialChar,safeSpecialChar);return reviver?reviver.call(this,key,value):value}}function regenerateArray(root,current,retrieve){for(var i=0,length=current.length;i<length;i++){current[i]=regenerate(root,current[i],retrieve)}return current}function regenerateObject(root,current,retrieve){for(var key in current){if(current.hasOwnProperty(key)){current[key]=regenerate(root,current[key],retrieve)}}return current}function regenerate(root,current,retrieve){return current instanceof Array?regenerateArray(root,current,retrieve):current instanceof $String?current.length?retrieve.hasOwnProperty(current)?retrieve[current]:retrieve[current]=retrieveFromPath(root,current.split(specialChar)):root:current instanceof Object?regenerateObject(root,current,retrieve):current}function stringifyRecursion(value,replacer,space,doNotResolve){return JSON.stringify(value,generateReplacer(value,replacer,!doNotResolve),space)}function parseRecursion(text,reviver){return JSON.parse(text,generateReviver(reviver))}this.stringify=stringifyRecursion;this.parse=parseRecursion},{}]},{},[1])(1)});
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.stentDevTools=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){"use strict";exports.__esModule=true;var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};var _circularJson=require("circular-json");var _circularJson2=_interopRequireDefault(_circularJson);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var Machine;var message=function message(data){if(window&&window.top&&window.top.postMessage){var machines=Object.keys(Machine.machines).map(function(name){return{name:name,state:sanitize(Machine.machines[name].state)}});window.top.postMessage(_extends({source:"stent",time:(new Date).getTime(),machines:machines},data),"*")}else{console.error("There is no window.postMessage available")}};var formatYielded=function formatYielded(yielded){var y=yielded;if(yielded&&yielded.__type==="call"){var funcName=yielded.func.name;if(funcName===""){funcName="<anonymous>"}try{y=JSON.parse(JSON.stringify(yielded))}catch(error){y={__type:"call"}}y.func=funcName}return y};var sanitize=function sanitize(something){var showErrorInConsole=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var result;try{result=JSON.parse(_circularJson2.default.stringify(something,function(key,value){if(typeof value==="function"){return{__func:value.name===""?"<anonymous>":value.name}}return value}))}catch(error){if(showErrorInConsole){console.log(error)}result=null}return result};var getMetaInfo=function getMetaInfo(meta){return Object.assign({},meta,{middlewares:Machine.middlewares.length})};var DevTools={__sanitize:sanitize,__formatYielded:formatYielded,__message:message,__api:function __api(m){Machine=m},onMachineCreated:function onMachineCreated(machine){message({type:"onMachineCreated",machine:sanitize(machine),meta:getMetaInfo()})},onActionDispatched:function onActionDispatched(actionName){for(var _len=arguments.length,args=Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key]}message({type:"onActionDispatched",actionName:actionName,args:sanitize(args),machine:sanitize(this),meta:getMetaInfo()})},onActionProcessed:function onActionProcessed(actionName){for(var _len2=arguments.length,args=Array(_len2>1?_len2-1:0),_key2=1;_key2<_len2;_key2++){args[_key2-1]=arguments[_key2]}message({type:"onActionProcessed",actionName:actionName,args:sanitize(args),machine:sanitize(this),meta:getMetaInfo()})},onStateWillChange:function onStateWillChange(){message({type:"onStateWillChange",machine:sanitize(this),meta:getMetaInfo()})},onStateChanged:function onStateChanged(){message({type:"onStateChanged",machine:sanitize(this),meta:getMetaInfo()})},onGeneratorStep:function onGeneratorStep(yielded){message({type:"onGeneratorStep",yielded:formatYielded(yielded),meta:getMetaInfo()})},onMachineConnected:function onMachineConnected(machines,meta){message({type:"onMachineConnected",meta:getMetaInfo(_extends({},meta,{machines:sanitize(machines)}))})},onMachineDisconnected:function onMachineDisconnected(machines,meta){message({type:"onMachineDisconnected",meta:getMetaInfo(_extends({},meta,{machines:sanitize(machines)}))})},onMiddlewareRegister:function onMiddlewareRegister(){message({pageRefresh:true})}};exports.default=DevTools;module.exports=exports["default"]},{"circular-json":2}],2:[function(require,module,exports){var specialChar="~",safeSpecialChar="\\x"+("0"+specialChar.charCodeAt(0).toString(16)).slice(-2),escapedSafeSpecialChar="\\"+safeSpecialChar,specialCharRG=new RegExp(safeSpecialChar,"g"),safeSpecialCharRG=new RegExp(escapedSafeSpecialChar,"g"),safeStartWithSpecialCharRG=new RegExp("(?:^|([^\\\\]))"+escapedSafeSpecialChar),indexOf=[].indexOf||function(v){for(var i=this.length;i--&&this[i]!==v;);return i},$String=String;function generateReplacer(value,replacer,resolve){var inspect=!!replacer,path=[],all=[value],seen=[value],mapp=[resolve?specialChar:"[Circular]"],last=value,lvl=1,i,fn;if(inspect){fn=typeof replacer==="object"?function(key,value){return key!==""&&replacer.indexOf(key)<0?void 0:value}:replacer}return function(key,value){if(inspect)value=fn.call(this,key,value);if(key!==""){if(last!==this){i=lvl-indexOf.call(all,this)-1;lvl-=i;all.splice(lvl,all.length);path.splice(lvl-1,path.length);last=this}if(typeof value==="object"&&value){if(indexOf.call(all,value)<0){all.push(last=value)}lvl=all.length;i=indexOf.call(seen,value);if(i<0){i=seen.push(value)-1;if(resolve){path.push((""+key).replace(specialCharRG,safeSpecialChar));mapp[i]=specialChar+path.join(specialChar)}else{mapp[i]=mapp[0]}}else{value=mapp[i]}}else{if(typeof value==="string"&&resolve){value=value.replace(safeSpecialChar,escapedSafeSpecialChar).replace(specialChar,safeSpecialChar)}}}return value}}function retrieveFromPath(current,keys){for(var i=0,length=keys.length;i<length;current=current[keys[i++].replace(safeSpecialCharRG,specialChar)]);return current}function generateReviver(reviver){return function(key,value){var isString=typeof value==="string";if(isString&&value.charAt(0)===specialChar){return new $String(value.slice(1))}if(key==="")value=regenerate(value,value,{});if(isString)value=value.replace(safeStartWithSpecialCharRG,"$1"+specialChar).replace(escapedSafeSpecialChar,safeSpecialChar);return reviver?reviver.call(this,key,value):value}}function regenerateArray(root,current,retrieve){for(var i=0,length=current.length;i<length;i++){current[i]=regenerate(root,current[i],retrieve)}return current}function regenerateObject(root,current,retrieve){for(var key in current){if(current.hasOwnProperty(key)){current[key]=regenerate(root,current[key],retrieve)}}return current}function regenerate(root,current,retrieve){return current instanceof Array?regenerateArray(root,current,retrieve):current instanceof $String?current.length?retrieve.hasOwnProperty(current)?retrieve[current]:retrieve[current]=retrieveFromPath(root,current.split(specialChar)):root:current instanceof Object?regenerateObject(root,current,retrieve):current}function stringifyRecursion(value,replacer,space,doNotResolve){return JSON.stringify(value,generateReplacer(value,replacer,!doNotResolve),space)}function parseRecursion(text,reviver){return JSON.parse(text,generateReviver(reviver))}this.stringify=stringifyRecursion;this.parse=parseRecursion},{}]},{},[1])(1)});

Sorry, the diff of this file is not supported yet

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