mobx-remotedev
Advanced tools
Comparing version 0.0.2-alpha-6 to 0.0.2-beta-1
@@ -80,5 +80,5 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
exports.__esModule = true; | ||
exports.setValue = undefined; | ||
exports.createAction = createAction; | ||
exports.getName = getName; | ||
exports.setValue = setValue; | ||
@@ -91,6 +91,36 @@ var _mobx = __webpack_require__(1); | ||
function createAction(name, isNative) { | ||
var getPayload = function getPayload(change) { | ||
var added = change.added; | ||
var addedCount = change.addedCount; | ||
var index = change.index; | ||
var removed = change.removed; | ||
var removedCount = change.removedCount; | ||
var object = change.object; | ||
return { | ||
type: isNative ? '@@' + name : name | ||
index: index, | ||
added: added && _mobx2.default.toJS(added), | ||
addedCount: addedCount, | ||
removed: removed && _mobx2.default.toJS(removed), | ||
removedCount: removedCount | ||
}; | ||
}; | ||
function createAction(name, change) { | ||
if (!change) { | ||
// is action | ||
return { type: name }; | ||
} | ||
var action = void 0; | ||
if (typeof change.newValue !== 'undefined') { | ||
var _action; | ||
action = (_action = {}, _action[change.name] = _mobx2.default.toJS(change.newValue), _action); | ||
} else { | ||
action = getPayload(change); | ||
} | ||
action.type = '@@' + name; | ||
return action; | ||
} | ||
@@ -106,3 +136,3 @@ | ||
function setValue(store, state) { | ||
var setValue = exports.setValue = _mobx2.default.action(function setValue(store, state) { | ||
if (store.importState) { | ||
@@ -115,3 +145,3 @@ store.importState(state); | ||
} | ||
} | ||
}); | ||
@@ -274,3 +304,2 @@ /***/ }, | ||
function schedule(name, action) { | ||
if (!scheduled[name] || stores[name].__isRemotedevAction) return; | ||
scheduled[name].push(function () { | ||
@@ -299,4 +328,4 @@ monitors[name].send(action, _mobx2.default.toJS(stores[name])); | ||
objName = (0, _utils.getName)(change.object || change.target); | ||
if (!scheduled[objName] || stores[objName].__isRemotedevAction) return; | ||
if (change.type === 'action') { | ||
if (change.target !== store) return; | ||
var action = (0, _utils.createAction)(change.name); | ||
@@ -306,3 +335,3 @@ if (change.arguments && change.arguments.length) action.arguments = change.arguments; | ||
} else if (change.type && _mobx2.default.isObservable(change.object)) { | ||
schedule(objName, (0, _utils.createAction)(change.type, true)); | ||
schedule(objName, (0, _utils.createAction)(change.type, change)); | ||
} | ||
@@ -309,0 +338,0 @@ } else if (change.spyReportEnd) { |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.RemoteDev=t():e.RemoteDev=t()}(this,function(){return function(e){function t(r){if(o[r])return o[r].exports;var n=o[r]={exports:{},id:r,loaded:!1};return e[r].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var o={};return t.m=e,t.c=o,t.p="",t(0)}([function(e,t,o){"use strict";e.exports=function(e){return e}}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("mobx")):"function"==typeof define&&define.amd?define(["mobx"],t):"object"==typeof exports?exports.RemoteDev=t(require("mobx")):e.RemoteDev=t(e.mobx)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";e.exports=n(4).default},function(t,n){t.exports=e},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!t)return{type:e};var n=void 0;if("undefined"!=typeof t.newValue){var r;r={},r[t.name]=a.default.toJS(t.newValue),n=r}else n=f(t);return n.type="@@"+e,n}function i(e){if(!e)return"";var t=a.default.extras.getDebugName(e),n=t.indexOf(".");return n===-1&&(n=void 0),t.substr(0,n)}t.__esModule=!0,t.setValue=void 0,t.createAction=o,t.getName=i;var u=n(1),a=r(u),f=function(e){var t=e.added,n=e.addedCount,r=e.index,o=e.removed,i=e.removedCount;e.object;return{index:r,added:t&&a.default.toJS(t),addedCount:n,removed:o&&a.default.toJS(o),removedCount:i}};t.setValue=a.default.action(function(e,t){e.importState?e.importState(t):Object.keys(t).forEach(function(n){e[n]=t[n]})})},function(e,t){function n(e,t){if("$"!==t)for(var n=r(t),o=0;o<n.length;o++)t=n[o].toString().replace(/\\"/g,'"'),e=e[t];return e}function r(e){for(var t,n=/(?:\.(\w+))|(?:\[(\d+)\])|(?:\["((?:[^\\"]|\\.)*)"\])/g,r=[];t=n.exec(e);)r.push(t[1]||t[2]||t[3]);return r}e.exports=n},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e,t){return"undefined"!=typeof window&&window.devToolsExtension?(s.default.isObservable(e)?(0,d.default)(e,t):"function"==typeof e?e=function(e){function n(){o(this,n);for(var r=arguments.length,u=Array(r),a=0;a<r;a++)u[a]=arguments[a];var f=i(this,e.call.apply(e,[this].concat(u)));return(0,d.default)(f,t),f}return u(n,e),n}(e):console.warn("Passed "+("undefined"==typeof e?"undefined":f(e))+" to mobx-remotedev, which is not an observable."),e):e}t.__esModule=!0,t.default=void 0;var f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},c=n(1),s=r(c),l=n(6),d=r(l);t.default=a},function(e,t,n){"use strict";t.__esModule=!0,t.dispatchMonitorAction=t.isMonitorAction=void 0;var r=n(7),o=n(2);t.isMonitorAction=function(e){return e.__isRemotedevAction===!0},t.dispatchMonitorAction=function(e){return function(t){"DISPATCH"===t.type&&"JUMP_TO_STATE"===t.payload.type&&(e.__isRemotedevAction=!0,(0,o.setValue)(e,(0,r.parse)(t.state)),e.__isRemotedevAction=!1)}}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){var n=c.default.extras.getDebugName(e);p[n]=e,v[n]=[];var r=window.devToolsExtension.connect(t);r.init(c.default.toJS(e)),r.subscribe((0,l.dispatchMonitorAction)(e)),y[n]=r}function i(e,t){v[e].push(function(){y[e].send(t,c.default.toJS(p[e]))})}function u(e){var t=v[e];if(t)for(;t.length;)t.shift()()}function a(e,t){if(o(e,t),!d){d=!0;var n=void 0;c.default.spy(function(e){if(e.spyReportStart){if("reaction"===e.type)return;if(n=(0,s.getName)(e.object||e.target),!v[n]||p[n].__isRemotedevAction)return;if("action"===e.type){var t=(0,s.createAction)(e.name);e.arguments&&e.arguments.length&&(t.arguments=e.arguments),i(n,t)}else e.type&&c.default.isObservable(e.object)&&i(n,(0,s.createAction)(e.type,e))}else e.spyReportEnd&&u(n)})}}t.__esModule=!0,t.default=a;var f=n(1),c=r(f),s=n(2),l=n(5),d=!1,p={},y={},v={}},function(e,t,n){e.exports=n(9)},function(e,t,n){var r=(n(3),n(10));t.decycle=function(e,t,n){"use strict";var o=[],i=[];return function u(e,a,f){var c,s,l,d=n?n(f||"",e):e;if(t.date&&d instanceof Date)return{$jsan:"d"+d.getTime()};if(t.regex&&d instanceof RegExp)return{$jsan:"r"+r.getRegexFlags(d)+","+d.source};if(t.function&&"function"==typeof d)return{$jsan:"f"+r.stringifyFunction(d,t.function)};if(t.undefined&&void 0===d)return{$jsan:"u"};if(t.error&&d instanceof Error)return{$jsan:"e"+d.message};if(d&&d.toJSON)return d.toJSON();if(!("object"!=typeof d||null===d||d instanceof Boolean||d instanceof Date||d instanceof Number||d instanceof RegExp||d instanceof String||d instanceof Error)){for(c=0;c<o.length;c+=1)if(o[c]===d)return{$jsan:i[c]};if(o.push(d),i.push(a),"[object Array]"===Object.prototype.toString.apply(d))for(l=[],c=0;c<d.length;c+=1)l[c]=u(d[c],a+"["+c+"]",c);else{l={};for(s in d)if(Object.prototype.hasOwnProperty.call(d,s)){var p=/^\w+$/.test(s)?"."+s:"["+JSON.stringify(s)+"]";l[s]="$jsan"===s?[u(d[s],a+p)]:u(d[s],a+p,s)}}return l}return d}(e,"$")},t.retrocycle=function(e){"use strict";return function t(n){var o,i,u;if(n&&"object"==typeof n)if("[object Array]"===Object.prototype.toString.apply(n))for(o=0;o<n.length;o+=1)i=n[o],i&&"object"==typeof i&&(i.$jsan?n[o]=r.restore(i.$jsan,e):t(i));else for(u in n)"$jsan"===u&&(n[u]=n[u][0]),"object"==typeof n[u]&&(i=n[u],i&&"object"==typeof i&&(i.$jsan?n[u]=r.restore(i.$jsan,e):t(i)))}(e),e}},function(e,t,n){var r=n(8);t.stringify=function(e,t,n,o){if(arguments.length<4)try{return 1===arguments.length?JSON.stringify(e):JSON.stringify.apply(JSON,arguments)}catch(i){}var u=o||!1;"boolean"==typeof u&&(u={date:u,"function":u,regex:u,undefined:u,error:u});var a=r.decycle(e,u,t);return 1===arguments.length?JSON.stringify(a):JSON.stringify(a,t,n)},t.parse=function(e,t){var n,o=/"\$jsan"/.test(e);return n=1===arguments.length?JSON.parse(e):JSON.parse(e,t),o&&(n=r.retrocycle(n)),n}},function(e,t,n){var r=n(3);t.getRegexFlags=function(e){var t="";return e.ignoreCase&&(t+="i"),e.global&&(t+="g"),e.multiline&&(t+="m"),t},t.stringifyFunction=function(e,t){if("function"==typeof t)return t(e);var n=e.toString(),r=n.match(/^[^{]*{|^[^=]*=>/),o=r?r[0]:"<function> ",i="}"===n[n.length-1]?"}":"";return o.replace(/\r\n|\n/g," ").replace(/\s+/g," ")+" /* ... */ "+i},t.restore=function(e,t){var n=e[0],o=e.slice(1);switch(n){case"$":return r(t,e);case"r":var i=o.indexOf(","),u=o.slice(0,i),a=o.slice(i+1);return RegExp(a,u);case"d":return new Date((+o));case"f":var f=function(){throw new Error("can't run jsan parsed function")};return f.toString=function(){return o},f;case"u":return;case"e":var c=new Error(o);return c.stack="Stack is unavailable for jsan parsed errors",c;default:return console.warn("unknown type",e),e}}}])}); |
'use strict'; | ||
if (process.env.NODE_ENV !== 'production') { | ||
if (process.env.NODE_ENV === 'development') { | ||
module.exports = require('./dev').default; // eslint-disable-line global-require | ||
@@ -5,0 +5,0 @@ } else { |
@@ -33,3 +33,2 @@ 'use strict'; | ||
function schedule(name, action) { | ||
if (!scheduled[name] || stores[name].__isRemotedevAction) return; | ||
scheduled[name].push(function () { | ||
@@ -58,4 +57,4 @@ monitors[name].send(action, _mobx2.default.toJS(stores[name])); | ||
objName = (0, _utils.getName)(change.object || change.target); | ||
if (!scheduled[objName] || stores[objName].__isRemotedevAction) return; | ||
if (change.type === 'action') { | ||
if (change.target !== store) return; | ||
var action = (0, _utils.createAction)(change.name); | ||
@@ -65,3 +64,3 @@ if (change.arguments && change.arguments.length) action.arguments = change.arguments; | ||
} else if (change.type && _mobx2.default.isObservable(change.object)) { | ||
schedule(objName, (0, _utils.createAction)(change.type, true)); | ||
schedule(objName, (0, _utils.createAction)(change.type, change)); | ||
} | ||
@@ -68,0 +67,0 @@ } else if (change.spyReportEnd) { |
'use strict'; | ||
exports.__esModule = true; | ||
exports.setValue = undefined; | ||
exports.createAction = createAction; | ||
exports.getName = getName; | ||
exports.setValue = setValue; | ||
@@ -14,6 +14,36 @@ var _mobx = require('mobx'); | ||
function createAction(name, isNative) { | ||
var getPayload = function getPayload(change) { | ||
var added = change.added; | ||
var addedCount = change.addedCount; | ||
var index = change.index; | ||
var removed = change.removed; | ||
var removedCount = change.removedCount; | ||
var object = change.object; | ||
return { | ||
type: isNative ? '@@' + name : name | ||
index: index, | ||
added: added && _mobx2.default.toJS(added), | ||
addedCount: addedCount, | ||
removed: removed && _mobx2.default.toJS(removed), | ||
removedCount: removedCount | ||
}; | ||
}; | ||
function createAction(name, change) { | ||
if (!change) { | ||
// is action | ||
return { type: name }; | ||
} | ||
var action = void 0; | ||
if (typeof change.newValue !== 'undefined') { | ||
var _action; | ||
action = (_action = {}, _action[change.name] = _mobx2.default.toJS(change.newValue), _action); | ||
} else { | ||
action = getPayload(change); | ||
} | ||
action.type = '@@' + name; | ||
return action; | ||
} | ||
@@ -29,3 +59,3 @@ | ||
function setValue(store, state) { | ||
var setValue = exports.setValue = _mobx2.default.action(function setValue(store, state) { | ||
if (store.importState) { | ||
@@ -38,2 +68,2 @@ store.importState(state); | ||
} | ||
} | ||
}); |
{ | ||
"name": "mobx-remotedev", | ||
"version": "0.0.2-alpha-6", | ||
"version": "0.0.2-beta-1", | ||
"description": "Remote debugging for mobx.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -1,2 +0,2 @@ | ||
if (process.env.NODE_ENV !== 'production') { | ||
if (process.env.NODE_ENV === 'development') { | ||
module.exports = require('./dev').default; // eslint-disable-line global-require | ||
@@ -3,0 +3,0 @@ } else { |
@@ -22,3 +22,2 @@ import mobx from 'mobx'; | ||
function schedule(name, action) { | ||
if (!scheduled[name] || stores[name].__isRemotedevAction) return; | ||
scheduled[name].push(() => { | ||
@@ -47,4 +46,4 @@ monitors[name].send(action, mobx.toJS(stores[name])); | ||
objName = getName(change.object || change.target); | ||
if (!scheduled[objName] || stores[objName].__isRemotedevAction) return; | ||
if (change.type === 'action') { | ||
if (change.target !== store) return; | ||
const action = createAction(change.name); | ||
@@ -54,3 +53,3 @@ if (change.arguments && change.arguments.length) action.arguments = change.arguments; | ||
} else if (change.type && mobx.isObservable(change.object)) { | ||
schedule(objName, createAction(change.type, true)); | ||
schedule(objName, createAction(change.type, change)); | ||
} | ||
@@ -57,0 +56,0 @@ } else if (change.spyReportEnd) { |
import mobx from 'mobx'; | ||
export function createAction(name, isNative) { | ||
const getPayload = (change) => { | ||
const { added, addedCount, index, removed, removedCount, object } = change; | ||
return { | ||
type: isNative ? `@@${name}` : name | ||
index, | ||
added: added && mobx.toJS(added), | ||
addedCount, | ||
removed: removed && mobx.toJS(removed), | ||
removedCount | ||
}; | ||
}; | ||
export function createAction(name, change) { | ||
if (!change) { // is action | ||
return { type: name }; | ||
} | ||
let action; | ||
if (typeof change.newValue !== 'undefined') { | ||
action = { [change.name]: mobx.toJS(change.newValue) }; | ||
} else { | ||
action = getPayload(change); | ||
} | ||
action.type = `@@${name}`; | ||
return action; | ||
} | ||
@@ -17,3 +38,3 @@ | ||
export function setValue(store, state) { | ||
export const setValue = mobx.action(function setValue(store, state) { | ||
if (store.importState) { | ||
@@ -26,2 +47,2 @@ store.importState(state); | ||
} | ||
} | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41716
775
2