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

amo

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amo - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

dist/amo.cjs.js

840

dist/amo.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.AMO = factory());
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.AMO = factory());
}(this, (function () { 'use strict';
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var regux = createCommonjsModule(function (module, exports) {
(function (global, factory) {
module.exports = factory();
}(commonjsGlobal, (function () {
var handleComputed = ( function () {
// wrap the computed getter;
function wrapGet( get ) {
return function ( context ) {
return get.call( context, context.data );
};
}
// wrap the computed setter;
function wrapSet( set ) {
return function ( context, value ) {
set.call( context, value, context.data );
return value;
};
}
var regux = createCommonjsModule(function (module, exports) {
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.regux = factory());
}(commonjsGlobal, (function () { 'use strict';
return function ( computed ) {
if ( !computed ) {
return;
}
var parsedComputed = {};
var handle, pair, type;
for ( var i in computed ) {
handle = computed[ i ];
type = typeof handle;
var handleComputed = ( function () {
// wrap the computed getter;
function wrapGet( get ) {
return function ( context ) {
return get.call( context, context.data );
};
}
// wrap the computed setter;
function wrapSet( set ) {
return function ( context, value ) {
set.call( context, value, context.data );
return value;
};
}
if ( handle.type === 'expression' ) {
parsedComputed[ i ] = handle;
continue;
}
if ( type !== 'string' ) {
pair = parsedComputed[ i ] = { type: 'expression' };
if ( type === 'function' ) {
pair.get = wrapGet( handle );
} else {
if ( handle.get ) {
pair.get = wrapGet( handle.get );
}
if ( handle.set ) {
pair.set = wrapSet( handle.set );
}
}
}
}
return parsedComputed;
};
} )();
return function ( computed ) {
if ( !computed ) {
return;
}
var parsedComputed = {};
var handle, pair, type;
for ( var i in computed ) {
handle = computed[ i ];
type = typeof handle;
// generate computed properties from getters
var makeComputed = function ( target, getters ) {
Object.assign( target.computed || {}, handleComputed( getters ) );
};
if ( handle.type === 'expression' ) {
parsedComputed[ i ] = handle;
continue;
}
if ( type !== 'string' ) {
pair = parsedComputed[ i ] = { type: 'expression' };
if ( type === 'function' ) {
pair.get = wrapGet( handle );
} else {
if ( handle.get ) {
pair.get = wrapGet( handle.get );
}
if ( handle.set ) {
pair.set = wrapSet( handle.set );
}
}
}
}
return parsedComputed;
};
} )();
var Scheduler = function Scheduler() {
this.t = null;
this.tasks = [];
};
Scheduler.prototype.add = function add ( task ) {
this.tasks.push( task );
};
Scheduler.prototype.run = function run ( main ) {
var this$1 = this;
// generate computed properties from getters
var makeComputed = function ( target, getters ) {
Object.assign( target.computed || {}, handleComputed( getters ) );
};
if ( this.t ) {
clearTimeout( this.t );
}
var Scheduler = function Scheduler() {
this.t = null;
this.tasks = [];
};
Scheduler.prototype.add = function add ( task ) {
this.tasks.push( task );
};
Scheduler.prototype.run = function run ( main ) {
var this$1 = this;
this.t = setTimeout( function () {
main();
if ( this.t ) {
clearTimeout( this.t );
}
this$1.tasks.forEach( function ( task, i ) {
if ( typeof task === 'function' ) {
task();
this$1.tasks[ i ] = null;
}
} );
this$1.tasks.length = 0;
}, 0 );
};
this.t = setTimeout( function () {
main();
// Credits: vue/vuex
this$1.tasks.forEach( function ( task, i ) {
if ( typeof task === 'function' ) {
task();
this$1.tasks[ i ] = null;
}
} );
this$1.tasks.length = 0;
}, 0 );
};
var devtoolsPlugin = function () { return function (store) {
var devtools = window && window.__REO_DEVTOOLS_HOOK__;
// Credits: vue/vuex
if ( !devtools ) {
return;
}
var devtoolsPlugin = function () { return function (store) {
var devtools = window && window.__REO_DEVTOOLS_HOOK__;
store._devtools = devtools;
if ( !devtools ) {
return;
}
devtools.emit( 'reo:init', store );
devtools.on( 'reo:travel-to-state', function (state) {
store.replaceState( state );
} );
devtools.on( 'reo:silent-travel-to-state', function (state) {
store.replaceState( state, {
silent: true
} );
} );
store._devtools = devtools;
store.subscribe( function ( action, state ) {
devtools.emit( 'reo:reducer', action, state );
} );
devtools.emit( 'reo:init', store );
devtools.on( 'reo:travel-to-state', function (state) {
store.replaceState( state );
} );
devtools.on( 'reo:silent-travel-to-state', function (state) {
store.replaceState( state, {
silent: true
} );
} );
store.subscribeViewUpdate( function () {
devtools.emit( 'reo:view-updated' );
} );
}; };
store.subscribe( function ( action, state ) {
devtools.emit( 'reo:reducer', action, state );
} );
var Store = function Store( ref ) {
var this$1 = this;
if ( ref === void 0 ) ref = {};
var modules = ref.modules; if ( modules === void 0 ) modules = {};
var actions = ref.actions; if ( actions === void 0 ) actions = {};
var plugins = ref.plugins; if ( plugins === void 0 ) plugins = [];
store.subscribeViewUpdate( function () {
devtools.emit( 'reo:view-updated' );
} );
}; };
Object.assign( this, {
_state: {},
_reducers: {},
_modules: modules,
_getters: {},
_actions: actions,
_plugins: plugins,
_subscribers: [],
_viewUpdateSubscribers: [],
scheduler: new Scheduler(),
} );
var Store = function Store( ref ) {
var this$1 = this;
if ( ref === void 0 ) { ref = {}; }
var modules = ref.modules; if ( modules === void 0 ) { modules = {}; }
var actions = ref.actions; if ( actions === void 0 ) { actions = {}; }
var plugins = ref.plugins; if ( plugins === void 0 ) { plugins = []; }
// register modules
Object.keys( modules )
.forEach( function (name) { return this$1.registerModule( name, modules[ name ] ); } );
Object.assign( this, {
_state: {},
_reducers: {},
_modules: modules,
_getters: {},
_actions: actions,
_plugins: plugins,
_subscribers: [],
_viewUpdateSubscribers: [],
scheduler: new Scheduler(),
} );
// execute devtools manually
devtoolsPlugin()( this );
// execute other plugins
plugins.forEach( function (plugin) { return this$1.use( plugin ); } );
};
Store.prototype.use = function use ( plugin ) {
plugin( this );
};
Store.prototype.replaceState = function replaceState ( newState, ref ) {
if ( ref === void 0 ) ref = {};
var silent = ref.silent; if ( silent === void 0 ) silent = false;
// register modules
Object.keys( modules )
.forEach( function (name) { return this$1.registerModule( name, modules[ name ] ); } );
this._state = newState;
// execute devtools manually
devtoolsPlugin()( this );
// execute other plugins
plugins.forEach( function (plugin) { return this$1.use( plugin ); } );
};
Store.prototype.use = function use ( plugin ) {
plugin( this );
};
Store.prototype.replaceState = function replaceState ( newState, ref ) {
if ( ref === void 0 ) { ref = {}; }
var silent = ref.silent; if ( silent === void 0 ) { silent = false; }
if ( !silent ) {
this.syncView();
}
};
Store.prototype.getState = function getState () {
return this._state;
};
Store.prototype.getGetters = function getGetters () {
return this._getters;
};
Store.prototype.nextTick = function nextTick ( fn ) {
this.scheduler.add( fn );
};
Store.prototype.dispatch = function dispatch ( type, payload ) {
var this$1 = this;
this._state = newState;
var action;
if ( !silent ) {
this.syncView();
}
};
Store.prototype.getState = function getState () {
return this._state;
};
Store.prototype.getGetters = function getGetters () {
return this._getters;
};
Store.prototype.nextTick = function nextTick ( fn ) {
this.scheduler.add( fn );
};
Store.prototype.dispatch = function dispatch ( type, payload ) {
var this$1 = this;
if ( typeof type === 'string' ) {
action = { type: type, payload: payload };
} else if ( isValidMutation( type ) ) {
action = type;
} else {
return console.error( 'invalid dispatch params', arguments );
}
var action;
var act = this._actions[ action.type ];
if ( typeof type === 'string' ) {
action = { type: type, payload: payload };
} else if ( isValidMutation( type ) ) {
action = type;
} else {
return console.error( 'invalid dispatch params', arguments );
}
if ( typeof act !== 'function' ) {
return console.error( 'action', action.type, 'not found' );
}
var act = this._actions[ action.type ];
return act( {
getState: this.getState.bind( this ),
state: this.getState(),
get: function (key) {
var getters = this$1.getGetters();
var getterFn = getters[ key ];
if ( typeof getterFn !== 'function' ) {
return;
}
if ( typeof act !== 'function' ) {
return console.error( 'action', action.type, 'not found' );
}
return getterFn( this$1.getState() );
},
commit: this.commit.bind( this ),
dispatch: this.dispatch.bind( this ),
nextTick: this.nextTick.bind( this ),
}, action.payload );
};
Store.prototype.commit = function commit ( type, payload ) {
var this$1 = this;
return act( {
getState: this.getState.bind( this ),
state: this.getState(),
get: function (key) {
var getters = this$1.getGetters();
var getterFn = getters[ key ];
if ( typeof getterFn !== 'function' ) {
return;
}
var mutation;
return getterFn( this$1.getState() );
},
commit: this.commit.bind( this ),
dispatch: this.dispatch.bind( this ),
nextTick: this.nextTick.bind( this ),
}, action.payload );
};
Store.prototype.commit = function commit ( type, payload ) {
var this$1 = this;
// e.g. mutation -> { type: 'foo', payload: 'bar' }
if ( typeof type === 'string' ) {
mutation = { type: type, payload: payload };
} else if ( isValidMutation( type ) ) {
mutation = type;
} else {
return console.error( 'invalid commit params', arguments );
}
var mutation;
var reducer = this._reducers[ mutation.type ];
if ( typeof reducer === 'function' ) {
var state = this.getState();
var moduleState = typeof reducer.key === 'undefined' ? state : state[ reducer.key ];
// e.g. mutation -> { type: 'foo', payload: 'bar' }
if ( typeof type === 'string' ) {
mutation = { type: type, payload: payload };
} else if ( isValidMutation( type ) ) {
mutation = type;
} else {
return console.error( 'invalid commit params', arguments );
}
reducer( moduleState, mutation.payload );
var reducer = this._reducers[ mutation.type ];
if ( typeof reducer === 'function' ) {
var state = this.getState();
var moduleState = typeof reducer.key === 'undefined' ? state : state[ reducer.key ];
// notify subscribers state has been changed
this._applySubscribers( mutation, state );
reducer( moduleState, mutation.payload );
this.scheduler.run( function () { return this$1.syncView(); } );
} else {
console.error( 'reducer', mutation.type, 'not found' );
}
};
Store.prototype.syncView = function syncView () {
this._host.forEach( function (h) { return h.$update(); } );
this._viewUpdateSubscribers.forEach( function (fn) { return fn(); } );
};
Store.prototype.host = function host ( target ) {
if ( !this._host ) {
this._host = [];
}
this._host.push( target );
};
Store.prototype.subscribe = function subscribe ( fn ) {
if ( typeof fn !== 'function' ) {
return;
}
// notify subscribers state has been changed
this._applySubscribers( mutation, state );
this._subscribers.push( fn );
};
Store.prototype.subscribeViewUpdate = function subscribeViewUpdate ( fn ) {
if ( typeof fn !== 'function' ) {
return;
}
this.scheduler.run( function () { return this$1.syncView(); } );
} else {
console.error( 'reducer', mutation.type, 'not found' );
}
};
Store.prototype.syncView = function syncView () {
this._host.$update();
this._viewUpdateSubscribers.forEach( function (fn) { return fn(); } );
};
Store.prototype.host = function host ( target ) {
this._host = target;
};
Store.prototype.subscribe = function subscribe ( fn ) {
if ( typeof fn !== 'function' ) {
return;
}
this._viewUpdateSubscribers.push( fn );
};
Store.prototype.registerModule = function registerModule ( name, module ) {
if ( name === void 0 ) name = '';
if ( module === void 0 ) module = {};
this._subscribers.push( fn );
};
Store.prototype.subscribeViewUpdate = function subscribeViewUpdate ( fn ) {
if ( typeof fn !== 'function' ) {
return;
}
if ( !name ) {
return console.error( 'Please provide a name when register module' );
}
this._viewUpdateSubscribers.push( fn );
};
Store.prototype.registerModule = function registerModule ( name, module ) {
if ( name === void 0 ) { name = ''; }
if ( module === void 0 ) { module = {}; }
// attach module state to root state
this._state[ name ] = module.state || {};
if ( !name ) {
return console.error( 'Please provide a name when register module' );
}
var reducers = module.reducers || {};
for ( var j in reducers ) {
reducers[ j ].key = name;
}
// attach module state to root state
this._state[ name ] = module.state || {};
reducers = addNSForReducers( reducers, name );
var reducers = module.reducers || {};
for ( var j in reducers ) {
reducers[ j ].key = name;
}
// attach module reducers to root reducers
Object.assign( this._reducers, reducers );
};
Store.prototype.registerActions = function registerActions ( actions ) {
if ( actions === void 0 ) actions = {};
reducers = addNSForReducers( reducers, name );
Object.assign( this._actions, actions );
};
Store.prototype.registerGetters = function registerGetters ( getters ) {
if ( getters === void 0 ) getters = {};
// attach module reducers to root reducers
Object.assign( this._reducers, reducers );
};
Store.prototype.registerActions = function registerActions ( actions ) {
if ( actions === void 0 ) { actions = {}; }
Object.assign( this._getters, getters );
};
Store.prototype._applySubscribers = function _applySubscribers ( mutation, state ) {
var subscribers = this._subscribers;
Object.assign( this._actions, actions );
};
Store.prototype.registerGetters = function registerGetters ( getters ) {
if ( getters === void 0 ) { getters = {}; }
for ( var i = 0, len = subscribers.length; i < len; i++ ) {
var subscriber = subscribers[ i ];
subscriber( mutation, state );
}
};
Object.assign( this._getters, getters );
};
Store.prototype._applySubscribers = function _applySubscribers ( mutation, state ) {
var subscribers = this._subscribers;
function addNSForReducers( reducers, ns ) {
var tmp = {};
Object.keys( reducers ).forEach( function (key) {
tmp[ (ns + "/" + key) ] = reducers[ key ];
} );
return tmp;
}
for ( var i = 0, len = subscribers.length; i < len; i++ ) {
var subscriber = subscribers[ i ];
subscriber( mutation, state );
}
};
function isValidMutation( mutation ) {
return typeof mutation.type !== 'undefined';
}
function addNSForReducers( reducers, ns ) {
var tmp = {};
Object.keys( reducers ).forEach( function (key) {
tmp[ (ns + "/" + key) ] = reducers[ key ];
} );
return tmp;
}
function isStore( ins ) {
return ins && ins instanceof Store;
}
function isValidMutation( mutation ) {
return typeof mutation.type !== 'undefined';
}
/* eslint-disable no-loop-func */
function isStore( ins ) {
return ins && ins instanceof Store;
}
var regux = function (Component) {
// one store in Component scope
var store;
Component.implement( {
events: {
$config: function $config() {
if ( isStore( this.store ) ) {
if ( store ) {
// store already exists
console.warn( 'store already exists' );
console.warn( 'old store:', store );
console.warn( 'new store:', this.store );
console.warn( 'new store will be used' );
}
/* eslint-disable no-loop-func */
// save store
store = this.store;
store.host( this );
delete this.store;
}
var regux = function (Component) {
// one store in Component scope
var store;
Component.implement( {
events: {
$config: function $config() {
if ( isStore( this.store ) ) {
if ( store ) {
// store already exists
console.warn( 'store already exists' );
console.warn( 'old store:', store );
console.warn( 'new store:', this.store );
console.warn( 'new store will be used' );
}
// save store
store = this.store;
store.host( this );
delete this.store;
}
if ( !store ) {
return console.warn( 'store not found' );
}
if ( !store ) {
return console.warn( 'store not found' );
}
this.$store = store;
this.commit = store.commit.bind( store );
this.dispatch = store.dispatch.bind( store );
this.nextTick = store.nextTick.bind( store );
this.$store = store;
this.commit = store.commit.bind( store );
this.dispatch = store.dispatch.bind( store );
this.nextTick = store.nextTick.bind( store );
var commonGetters = store.getGetters();
var commonGetters = store.getGetters();
var ref = this;
var getters = ref.getters; if ( getters === void 0 ) getters = {};
Object.keys( getters ).forEach( function (key) {
var getter = getters[ key ];
var ref = this;
var getters = ref.getters; if ( getters === void 0 ) { getters = {}; }
Object.keys( getters ).forEach( function (key) {
var getter = getters[ key ];
// if getter is string, try getting it from commonGetters
if ( typeof getter === 'string' ) {
getter = commonGetters[ getter ];
}
// if getter is string, try getting it from commonGetters
if ( typeof getter === 'string' ) {
getter = commonGetters[ getter ];
}
if ( typeof getter === 'function' ) {
getters[ key ] = function () {
return getter( store.getState() );
};
}
} );
makeComputed( this, getters );
}
}
} );
};
if ( typeof getter === 'function' ) {
getters[ key ] = function () {
return getter( store.getState() );
};
}
} );
makeComputed( this, getters );
}
}
} );
};
regux.Store = Store;
regux.Store = Store;
return regux;
return regux;
})));
});
})));
});
var logger = createCommonjsModule(function (module, exports) {
(function (global, factory) {
module.exports = factory();
}(commonjsGlobal, (function () {
// Credits: fcomb/redux-logger
var logger = createCommonjsModule(function (module, exports) {
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.logger = factory());
}(commonjsGlobal, (function () { 'use strict';
function createLogger( ref ) {
if ( ref === void 0 ) ref = {};
var collapsed = ref.collapsed; if ( collapsed === void 0 ) collapsed = true;
var transformer = ref.transformer; if ( transformer === void 0 ) transformer = function (state) { return state; };
var mutationTransformer = ref.mutationTransformer; if ( mutationTransformer === void 0 ) mutationTransformer = function (mut) { return mut; };
// Credits: fcomb/redux-logger
return function (store) {
var prevState = JSON.parse( JSON.stringify( store.getState() ) );
store.subscribe( function ( mutation, state ) {
var nextState = JSON.parse( JSON.stringify( state ) );
var time = new Date();
var formattedTime = " @ " + (pad( time.getHours(), 2 )) + ":" + (pad( time.getMinutes(), 2 )) + ":" + (pad( time.getSeconds(), 2 )) + "." + (pad( time.getMilliseconds(), 3 ));
var message = "commit " + (mutation.type) + formattedTime;
function createLogger( ref ) {
if ( ref === void 0 ) { ref = {}; }
var collapsed = ref.collapsed; if ( collapsed === void 0 ) { collapsed = true; }
var transformer = ref.transformer; if ( transformer === void 0 ) { transformer = function (state) { return state; }; }
var mutationTransformer = ref.mutationTransformer; if ( mutationTransformer === void 0 ) { mutationTransformer = function (mut) { return mut; }; }
if ( collapsed ) {
console.groupCollapsed( message );
} else {
console.group( message );
}
return function (store) {
var prevState = JSON.parse( JSON.stringify( store.getState() ) );
store.subscribe( function ( mutation, state ) {
var nextState = JSON.parse( JSON.stringify( state ) );
var time = new Date();
var formattedTime = " @ " + (pad( time.getHours(), 2 )) + ":" + (pad( time.getMinutes(), 2 )) + ":" + (pad( time.getSeconds(), 2 )) + "." + (pad( time.getMilliseconds(), 3 ));
var message = "commit " + (mutation.type) + formattedTime;
console.log( '%c prev state', 'color: #9E9E9E; font-weight: bold', transformer( prevState ) );
console.log( '%c commit', 'color: #03A9F4; font-weight: bold', mutationTransformer( mutation ) );
console.log( '%c next state', 'color: #4CAF50; font-weight: bold', transformer( nextState ) );
if ( collapsed ) {
console.groupCollapsed( message );
} else {
console.group( message );
}
console.groupEnd( message );
console.log( '%c prev state', 'color: #9E9E9E; font-weight: bold', transformer( prevState ) );
console.log( '%c commit', 'color: #03A9F4; font-weight: bold', mutationTransformer( mutation ) );
console.log( '%c next state', 'color: #4CAF50; font-weight: bold', transformer( nextState ) );
prevState = nextState;
} );
};
}
console.groupEnd( message );
function repeat( str, times ) {
return ( new Array( times + 1 ) ).join( str );
}
prevState = nextState;
} );
};
}
function pad( num, maxLength ) {
return repeat( '0', maxLength - num.toString().length ) + num;
}
function repeat( str, times ) {
return ( new Array( times + 1 ) ).join( str );
}
return createLogger;
function pad( num, maxLength ) {
return repeat( '0', maxLength - num.toString().length ) + num;
}
})));
});
return createLogger;
var App =
/*#__PURE__*/
function () {
function App() {
_classCallCheck(this, App);
})));
});
var store = new regux.Store();
var App = function App() {
var store = new regux.Store();
if ( process.env.NODE_ENV === 'development' ) {
store.use( logger() );
}
this._store = store;
};
App.prototype.getStore = function getStore () {
return this._store;
};
App.prototype.use = function use ( Component ) {
Component.use( regux );
};
App.prototype.model = function model ( m ) {
if ( m === void 0 ) m = {};
{
store.use(logger());
}
var name = m.name;
this._store = store;
}
if ( !name ) {
return console.error( 'Please provide name for model', m );
}
_createClass(App, [{
key: "getStore",
value: function getStore() {
return this._store;
}
}, {
key: "use",
value: function use(Component) {
Component.use(regux);
}
}, {
key: "model",
value: function model() {
var m = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var name = m.name;
var store = this.getStore();
store.registerModule( name, m );
};
App.prototype.getters = function getters ( getters ) {
var store = this.getStore();
store.registerGetters( getters );
};
App.prototype.actions = function actions ( actions ) {
if ( actions === void 0 ) actions = {};
if (!name) {
return console.error('Please provide name for model', m);
}
var store = this.getStore();
store.registerActions( actions );
};
App.prototype.start = function start ( App, selector ) {
return new App( {
store: this.getStore(),
} ).$inject( document.querySelector( selector ) );
};
var store = this.getStore();
store.registerModule(name, m);
}
}, {
key: "getters",
value: function getters(_getters) {
var store = this.getStore();
store.registerGetters(_getters);
}
}, {
key: "actions",
value: function actions() {
var _actions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var index = function() {
return new App();
};
var store = this.getStore();
store.registerActions(_actions);
}
}, {
key: "start",
value: function start(App, selector) {
return new App({
store: this.getStore()
}).$inject(document.querySelector(selector));
}
}]);
return index;
return App;
}();
function index () {
return new App();
}
return index;
})));

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.AMO=e()}(this,function(){"use strict";function t(t,e){return e={exports:{}},t(e,e.exports),e.exports}var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},o=t(function(t,o){!function(e,n){"object"==typeof o&&"undefined"!=typeof t?t.exports=n():"function"==typeof define&&define.amd?define(n):e.regux=n()}(e,function(){function t(t,e){var o={};return Object.keys(t).forEach(function(n){o[e+"/"+n]=t[n]}),o}function e(t){return"undefined"!=typeof t.type}function o(t){return t&&t instanceof c}var n=function(){function t(t){return function(e){return t.call(e,e.data)}}function e(t){return function(e,o){return t.call(e,o,e.data),o}}return function(o){if(o){var n,r,i,s={};for(var c in o)n=o[c],i=typeof n,"expression"!==n.type?"string"!==i&&(r=s[c]={type:"expression"},"function"===i?r.get=t(n):(n.get&&(r.get=t(n.get)),n.set&&(r.set=e(n.set)))):s[c]=n;return s}}}(),r=function(t,e){Object.assign(t.computed||{},n(e))},i=function(){this.t=null,this.tasks=[]};i.prototype.add=function(t){this.tasks.push(t)},i.prototype.run=function(t){var e=this;this.t&&clearTimeout(this.t),this.t=setTimeout(function(){t(),e.tasks.forEach(function(t,o){"function"==typeof t&&(t(),e.tasks[o]=null)}),e.tasks.length=0},0)};var s=function(){return function(t){var e=window&&window.__REO_DEVTOOLS_HOOK__;e&&(t._devtools=e,e.emit("reo:init",t),e.on("reo:travel-to-state",function(e){t.replaceState(e)}),e.on("reo:silent-travel-to-state",function(e){t.replaceState(e,{silent:!0})}),t.subscribe(function(t,o){e.emit("reo:reducer",t,o)}),t.subscribeViewUpdate(function(){e.emit("reo:view-updated")}))}},c=function(t){var e=this;void 0===t&&(t={});var o=t.modules;void 0===o&&(o={});var n=t.actions;void 0===n&&(n={});var r=t.plugins;void 0===r&&(r=[]),Object.assign(this,{_state:{},_reducers:{},_modules:o,_getters:{},_actions:n,_plugins:r,_subscribers:[],_viewUpdateSubscribers:[],scheduler:new i}),Object.keys(o).forEach(function(t){return e.registerModule(t,o[t])}),s()(this),r.forEach(function(t){return e.use(t)})};c.prototype.use=function(t){t(this)},c.prototype.replaceState=function(t,e){void 0===e&&(e={});var o=e.silent;void 0===o&&(o=!1),this._state=t,o||this.syncView()},c.prototype.getState=function(){return this._state},c.prototype.getGetters=function(){return this._getters},c.prototype.nextTick=function(t){this.scheduler.add(t)},c.prototype.dispatch=function(t,o){var n,r=this;if("string"==typeof t)n={type:t,payload:o};else{if(!e(t))return console.error("invalid dispatch params",arguments);n=t}var i=this._actions[n.type];return"function"!=typeof i?console.error("action",n.type,"not found"):i({getState:this.getState.bind(this),state:this.getState(),get:function(t){var e=r.getGetters(),o=e[t];if("function"==typeof o)return o(r.getState())},commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),nextTick:this.nextTick.bind(this)},n.payload)},c.prototype.commit=function(t,o){var n,r=this;if("string"==typeof t)n={type:t,payload:o};else{if(!e(t))return console.error("invalid commit params",arguments);n=t}var i=this._reducers[n.type];if("function"==typeof i){var s=this.getState(),c="undefined"==typeof i.key?s:s[i.key];i(c,n.payload),this._applySubscribers(n,s),this.scheduler.run(function(){return r.syncView()})}else console.error("reducer",n.type,"not found")},c.prototype.syncView=function(){this._host.$update(),this._viewUpdateSubscribers.forEach(function(t){return t()})},c.prototype.host=function(t){this._host=t},c.prototype.subscribe=function(t){"function"==typeof t&&this._subscribers.push(t)},c.prototype.subscribeViewUpdate=function(t){"function"==typeof t&&this._viewUpdateSubscribers.push(t)},c.prototype.registerModule=function(e,o){if(void 0===e&&(e=""),void 0===o&&(o={}),!e)return console.error("Please provide a name when register module");this._state[e]=o.state||{};var n=o.reducers||{};for(var r in n)n[r].key=e;n=t(n,e),Object.assign(this._reducers,n)},c.prototype.registerActions=function(t){void 0===t&&(t={}),Object.assign(this._actions,t)},c.prototype.registerGetters=function(t){void 0===t&&(t={}),Object.assign(this._getters,t)},c.prototype._applySubscribers=function(t,e){for(var o=this._subscribers,n=0,r=o.length;n<r;n++){var i=o[n];i(t,e)}};var u=function(t){var e;t.implement({events:{$config:function(){if(o(this.store)&&(e&&(console.warn("store already exists"),console.warn("old store:",e),console.warn("new store:",this.store),console.warn("new store will be used")),e=this.store,e.host(this),delete this.store),!e)return console.warn("store not found");this.$store=e,this.commit=e.commit.bind(e),this.dispatch=e.dispatch.bind(e),this.nextTick=e.nextTick.bind(e);var t=e.getGetters(),n=this,i=n.getters;void 0===i&&(i={}),Object.keys(i).forEach(function(o){var n=i[o];"string"==typeof n&&(n=t[n]),"function"==typeof n&&(i[o]=function(){return n(e.getState())})}),r(this,i)}}})};return u.Store=c,u})}),n=t(function(t,o){!function(e,n){"object"==typeof o&&"undefined"!=typeof t?t.exports=n():"function"==typeof define&&define.amd?define(n):e.logger=n()}(e,function(){function t(t){void 0===t&&(t={});var e=t.collapsed;void 0===e&&(e=!0);var n=t.transformer;void 0===n&&(n=function(t){return t});var r=t.mutationTransformer;return void 0===r&&(r=function(t){return t}),function(t){var i=JSON.parse(JSON.stringify(t.getState()));t.subscribe(function(t,s){var c=JSON.parse(JSON.stringify(s)),u=new Date,f=" @ "+o(u.getHours(),2)+":"+o(u.getMinutes(),2)+":"+o(u.getSeconds(),2)+"."+o(u.getMilliseconds(),3),a="commit "+t.type+f;e?console.groupCollapsed(a):console.group(a),console.log("%c prev state","color: #9E9E9E; font-weight: bold",n(i)),console.log("%c commit","color: #03A9F4; font-weight: bold",r(t)),console.log("%c next state","color: #4CAF50; font-weight: bold",n(c)),console.groupEnd(a),i=c})}}function e(t,e){return new Array(e+1).join(t)}function o(t,o){return e("0",o-t.toString().length)+t}return t})}),r=function(){var t=new o.Store;"development"===process.env.NODE_ENV&&t.use(n()),this._store=t};r.prototype.getStore=function(){return this._store},r.prototype.use=function(t){t.use(o)},r.prototype.model=function(t){void 0===t&&(t={});var e=t.name;if(!e)return console.error("Please provide name for model",t);var o=this.getStore();o.registerModule(e,t)},r.prototype.getters=function t(t){var e=this.getStore();e.registerGetters(t)},r.prototype.actions=function t(t){void 0===t&&(t={});var e=this.getStore();e.registerActions(t)},r.prototype.start=function(t,e){return new t({store:this.getStore()}).$inject(document.querySelector(e))};var i=function(){return new r};return i});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.AMO=e()}(this,function(){"use strict";function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function e(t,e){return t(e={exports:{}},e.exports),e.exports}var n=e(function(t,e){t.exports=function(){var t=function(){function t(t){return function(e){return t.call(e,e.data)}}function e(t){return function(e,n){return t.call(e,n,e.data),n}}return function(n){if(n){var o,r,i,s={};for(var c in n)o=n[c],i=typeof o,"expression"!==o.type?"string"!==i&&(r=s[c]={type:"expression"},"function"===i?r.get=t(o):(o.get&&(r.get=t(o.get)),o.set&&(r.set=e(o.set)))):s[c]=o;return s}}}(),e=function(){this.t=null,this.tasks=[]};e.prototype.add=function(t){this.tasks.push(t)},e.prototype.run=function(t){var e=this;this.t&&clearTimeout(this.t),this.t=setTimeout(function(){t(),e.tasks.forEach(function(t,n){"function"==typeof t&&(t(),e.tasks[n]=null)}),e.tasks.length=0},0)};var n=function(t){var n=this;void 0===t&&(t={});var o=t.modules;void 0===o&&(o={});var r=t.actions;void 0===r&&(r={});var i,s,c=t.plugins;void 0===c&&(c=[]),Object.assign(this,{_state:{},_reducers:{},_modules:o,_getters:{},_actions:r,_plugins:c,_subscribers:[],_viewUpdateSubscribers:[],scheduler:new e}),Object.keys(o).forEach(function(t){return n.registerModule(t,o[t])}),i=this,(s=window&&window.__REO_DEVTOOLS_HOOK__)&&(i._devtools=s,s.emit("reo:init",i),s.on("reo:travel-to-state",function(t){i.replaceState(t)}),s.on("reo:silent-travel-to-state",function(t){i.replaceState(t,{silent:!0})}),i.subscribe(function(t,e){s.emit("reo:reducer",t,e)}),i.subscribeViewUpdate(function(){s.emit("reo:view-updated")})),c.forEach(function(t){return n.use(t)})};function o(t){return void 0!==t.type}n.prototype.use=function(t){t(this)},n.prototype.replaceState=function(t,e){void 0===e&&(e={});var n=e.silent;void 0===n&&(n=!1),this._state=t,n||this.syncView()},n.prototype.getState=function(){return this._state},n.prototype.getGetters=function(){return this._getters},n.prototype.nextTick=function(t){this.scheduler.add(t)},n.prototype.dispatch=function(t,e){var n,r=this;if("string"==typeof t)n={type:t,payload:e};else{if(!o(t))return console.error("invalid dispatch params",arguments);n=t}var i=this._actions[n.type];return"function"!=typeof i?console.error("action",n.type,"not found"):i({getState:this.getState.bind(this),state:this.getState(),get:function(t){var e=r.getGetters(),n=e[t];if("function"==typeof n)return n(r.getState())},commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),nextTick:this.nextTick.bind(this)},n.payload)},n.prototype.commit=function(t,e){var n,r=this;if("string"==typeof t)n={type:t,payload:e};else{if(!o(t))return console.error("invalid commit params",arguments);n=t}var i=this._reducers[n.type];if("function"==typeof i){var s=this.getState(),c=void 0===i.key?s:s[i.key];i(c,n.payload),this._applySubscribers(n,s),this.scheduler.run(function(){return r.syncView()})}else console.error("reducer",n.type,"not found")},n.prototype.syncView=function(){this._host.forEach(function(t){return t.$update()}),this._viewUpdateSubscribers.forEach(function(t){return t()})},n.prototype.host=function(t){this._host||(this._host=[]),this._host.push(t)},n.prototype.subscribe=function(t){"function"==typeof t&&this._subscribers.push(t)},n.prototype.subscribeViewUpdate=function(t){"function"==typeof t&&this._viewUpdateSubscribers.push(t)},n.prototype.registerModule=function(t,e){if(void 0===t&&(t=""),void 0===e&&(e={}),!t)return console.error("Please provide a name when register module");this._state[t]=e.state||{};var n=e.reducers||{};for(var o in n)n[o].key=t;n=function(t,e){var n={};return Object.keys(t).forEach(function(o){n[e+"/"+o]=t[o]}),n}(n,t),Object.assign(this._reducers,n)},n.prototype.registerActions=function(t){void 0===t&&(t={}),Object.assign(this._actions,t)},n.prototype.registerGetters=function(t){void 0===t&&(t={}),Object.assign(this._getters,t)},n.prototype._applySubscribers=function(t,e){for(var n=this._subscribers,o=0,r=n.length;o<r;o++){var i=n[o];i(t,e)}};var r=function(e){var o;e.implement({events:{$config:function(){var e;if((e=this.store)&&e instanceof n&&(o&&(console.warn("store already exists"),console.warn("old store:",o),console.warn("new store:",this.store),console.warn("new store will be used")),(o=this.store).host(this),delete this.store),!o)return console.warn("store not found");this.$store=o,this.commit=o.commit.bind(o),this.dispatch=o.dispatch.bind(o),this.nextTick=o.nextTick.bind(o);var r=o.getGetters(),i=this.getters;void 0===i&&(i={}),Object.keys(i).forEach(function(t){var e=i[t];"string"==typeof e&&(e=r[e]),"function"==typeof e&&(i[t]=function(){return e(o.getState())})}),function(e,n){Object.assign(e.computed||{},t(n))}(this,i)}}})};return r.Store=n,r}()}),o=(e(function(t,e){t.exports=function(){function t(t,e){return n="0",o=e-t.toString().length,new Array(o+1).join(n)+t;var n,o}return function(e){void 0===e&&(e={});var n=e.collapsed;void 0===n&&(n=!0);var o=e.transformer;void 0===o&&(o=function(t){return t});var r=e.mutationTransformer;return void 0===r&&(r=function(t){return t}),function(e){var i=JSON.parse(JSON.stringify(e.getState()));e.subscribe(function(e,s){var c=JSON.parse(JSON.stringify(s)),u=new Date,a=" @ "+t(u.getHours(),2)+":"+t(u.getMinutes(),2)+":"+t(u.getSeconds(),2)+"."+t(u.getMilliseconds(),3),f="commit "+e.type+a;n?console.groupCollapsed(f):console.group(f),console.log("%c prev state","color: #9E9E9E; font-weight: bold",o(i)),console.log("%c commit","color: #03A9F4; font-weight: bold",r(e)),console.log("%c next state","color: #4CAF50; font-weight: bold",o(c)),console.groupEnd(f),i=c})}}}()}),function(){function e(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var t=new n.Store;this._store=t}var o,r,i;return o=e,(r=[{key:"getStore",value:function(){return this._store}},{key:"use",value:function(t){t.use(n)}},{key:"model",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.name;if(!e)return console.error("Please provide name for model",t);this.getStore().registerModule(e,t)}},{key:"getters",value:function(t){this.getStore().registerGetters(t)}},{key:"actions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.getStore().registerActions(t)}},{key:"start",value:function(t,e){return new t({store:this.getStore()}).$inject(document.querySelector(e))}}])&&t(o.prototype,r),i&&t(o,i),e}());return function(){return new o}});
//# sourceMappingURL=amo.min.js.map
{
"name": "amo",
"version": "0.0.6",
"main": "dist/amo.js",
"version": "0.0.7",
"main": "dist/amo.cjs.js",
"unpkg": "dist/amo.js",
"module": "dist/amo.es.js",
"scripts": {
"dist": "bili ./src/index.js -d dist -n amo --format umd --module-name AMO --compress",
"build": "bili ./src/index.js -d dist -n amo --format cjs,es,umd,umd-min --module-name AMO",
"dev": "nodemon -x \"npm run dist\" --watch src"
},
"files": [
"dist"
],
"repository": {

@@ -16,6 +21,8 @@ "url": "git@github.com:fengzilong/amo.git",

"devDependencies": {
"bili": "^0.8.0",
"onchange": "^3.2.0",
"regux": "0.1.6"
"bili": "3.4.2",
"onchange": "^3.2.0"
},
"dependencies": {
"regux": "^0.1.7"
}
}

Sorry, the diff of this file is not supported yet

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