Comparing version 1.0.2 to 1.0.3
@@ -1,528 +0,1 @@ | ||
/******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) { | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ i: moduleId, | ||
/******/ l: false, | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.l = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // define getter function for harmony exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 3); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var componentSchema_1 = __webpack_require__(1); | ||
var utils_1 = __webpack_require__(2); | ||
var snakecase = __webpack_require__(5); | ||
exports.COMPONENT_SCHEMA_OPTIONS = Symbol('COMPONENT_SCHEMA_OPTIONS'); | ||
var SchemaOptions = (function () { | ||
function SchemaOptions() { | ||
this.actionNamespace = true; | ||
this.uppercaseActions = true; | ||
this.updateState = true; | ||
} | ||
return SchemaOptions; | ||
}()); | ||
exports.SchemaOptions = SchemaOptions; | ||
function getSchemaOptions(schema) { | ||
componentSchema_1.assertComponentSchema(schema); | ||
return Object.assign({}, new SchemaOptions(), exports.globalOptions.schema, utils_1.getConstructorProp(schema, exports.COMPONENT_SCHEMA_OPTIONS)); | ||
} | ||
exports.getSchemaOptions = getSchemaOptions; | ||
function getActionName(key, schema) { | ||
var options = getSchemaOptions(schema); | ||
var actionName = key; | ||
var actionNamespace = schema.constructor.name; | ||
if (options.uppercaseActions) { | ||
actionName = snakecase(actionName).toUpperCase(); | ||
actionNamespace = snakecase(actionNamespace).toUpperCase(); | ||
} | ||
if (options.actionNamespace) { | ||
actionName = actionNamespace + '.' + actionName; | ||
} | ||
return actionName; | ||
} | ||
exports.getActionName = getActionName; | ||
var LogLevel; | ||
(function (LogLevel) { | ||
LogLevel[LogLevel["None"] = 0] = "None"; | ||
LogLevel[LogLevel["Verbose"] = 1] = "Verbose"; | ||
LogLevel[LogLevel["Debug"] = 2] = "Debug"; | ||
LogLevel[LogLevel["Silent"] = 10] = "Silent"; | ||
})(LogLevel = exports.LogLevel || (exports.LogLevel = {})); | ||
var GlobalOptions = (function () { | ||
function GlobalOptions() { | ||
this.logLevel = LogLevel.Silent; | ||
this.schema = new SchemaOptions(); | ||
} | ||
return GlobalOptions; | ||
}()); | ||
exports.GlobalOptions = GlobalOptions; | ||
exports.globalOptions = new GlobalOptions(); | ||
/***/ }), | ||
/* 1 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var options_1 = __webpack_require__(0); | ||
var utils_1 = __webpack_require__(2); | ||
var COMPONENT_SCHEMA = Symbol('COMPONENT_SCHEMA'); | ||
function component(ctorOrOptions) { | ||
if (typeof ctorOrOptions === 'function') { | ||
componentSchemaDecorator.call(undefined, ctorOrOptions); | ||
} | ||
else { | ||
return function (ctor) { return componentSchemaDecorator(ctor, ctorOrOptions); }; | ||
} | ||
} | ||
exports.component = component; | ||
function isComponentSchema(obj) { | ||
return utils_1.getConstructorProp(obj, COMPONENT_SCHEMA); | ||
} | ||
exports.isComponentSchema = isComponentSchema; | ||
function assertComponentSchema(obj) { | ||
if (!isComponentSchema(obj)) | ||
throw new Error("Invalid argument. " + "component" + " expected."); | ||
} | ||
exports.assertComponentSchema = assertComponentSchema; | ||
function componentSchemaDecorator(ctor, options) { | ||
if (utils_1.getArgumentNames(ctor).length) | ||
throw new Error('componentSchema classes must have a parameter-less constructor'); | ||
ctor[COMPONENT_SCHEMA] = true; | ||
ctor[options_1.COMPONENT_SCHEMA_OPTIONS] = options; | ||
} | ||
/***/ }), | ||
/* 2 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function getArgumentNames(func) { | ||
var FN_ARGS = /^function\s*?[^\(]*?\(\s*?([^\)]*?)\)/m; | ||
var CLASS_CTOR_ARGS = /^class[\s\S]*?constructor\s*?[^\(]*?\(\s*?([^\)]*?)\)/m; | ||
var functionArgsRegex = func.toString().match(FN_ARGS); | ||
var classArgsRegex = func.toString().match(CLASS_CTOR_ARGS); | ||
var args; | ||
if (classArgsRegex && classArgsRegex.length) { | ||
args = classArgsRegex[1]; | ||
} | ||
else if (functionArgsRegex && functionArgsRegex.length) { | ||
args = functionArgsRegex[1]; | ||
} | ||
else { | ||
return []; | ||
} | ||
args = args.split(',') | ||
.map(function (str) { return str.trim(); }) | ||
.filter(function (arg) { return arg !== ""; }); | ||
return args; | ||
} | ||
exports.getArgumentNames = getArgumentNames; | ||
function getPrototype(obj) { | ||
if (!obj) | ||
return undefined; | ||
return obj.prototype || obj.constructor.prototype; | ||
} | ||
exports.getPrototype = getPrototype; | ||
function getMethods(obj) { | ||
if (!obj) | ||
return undefined; | ||
var proto = getPrototype(obj); | ||
if (!proto) | ||
return undefined; | ||
var methods = {}; | ||
for (var _i = 0, _a = Object.keys(proto); _i < _a.length; _i++) { | ||
var key = _a[_i]; | ||
if (typeof proto[key] === 'function') | ||
methods[key] = proto[key]; | ||
} | ||
return methods; | ||
} | ||
exports.getMethods = getMethods; | ||
function getProp(obj, path) { | ||
if (typeof path === 'string') { | ||
path = path.replace(/\[|\]/g, '.').split('.').filter(function (token) { return typeof token === 'string' && token.trim() !== ''; }); | ||
} | ||
return path.reduce(function (result, key) { | ||
if (typeof result === 'object' && key) { | ||
return result[key.toString()]; | ||
} | ||
return undefined; | ||
}, obj); | ||
} | ||
exports.getProp = getProp; | ||
function getConstructorProp(obj, key) { | ||
return obj && obj.constructor && obj.constructor[key]; | ||
} | ||
exports.getConstructorProp = getConstructorProp; | ||
/***/ }), | ||
/* 3 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
module.exports = __webpack_require__(4); | ||
/***/ }), | ||
/* 4 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var componentSchema_1 = __webpack_require__(1); | ||
exports.component = componentSchema_1.component; | ||
var options_1 = __webpack_require__(0); | ||
exports.SchemaOptions = options_1.SchemaOptions; | ||
exports.GlobalOptions = options_1.GlobalOptions; | ||
exports.LogLevel = options_1.LogLevel; | ||
var reduxApp_1 = __webpack_require__(6); | ||
exports.ReduxApp = reduxApp_1.ReduxApp; | ||
/***/ }), | ||
/* 5 */ | ||
/***/ (function(module, exports) { | ||
module.exports = require("lodash.snakecase"); | ||
/***/ }), | ||
/* 6 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var redux_1 = __webpack_require__(7); | ||
var component_1 = __webpack_require__(8); | ||
var options_1 = __webpack_require__(0); | ||
var reducers_1 = __webpack_require__(10); | ||
var ReduxApp = (function () { | ||
function ReduxApp(appSchema) { | ||
var params = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
params[_i - 1] = arguments[_i]; | ||
} | ||
var dummyReducer = function () { }; | ||
this.store = redux_1.createStore.apply(void 0, [dummyReducer].concat(params)); | ||
var rootComponent = new component_1.Component(this.store, appSchema, []); | ||
this.root = rootComponent; | ||
var actualReducer = this.getReducer(rootComponent); | ||
this.store.replaceReducer(actualReducer); | ||
} | ||
ReduxApp.prototype.getReducer = function (component) { | ||
var rootReducer = component[component_1.REDUCER]; | ||
var subReducers = {}; | ||
for (var _i = 0, _a = Object.keys(component); _i < _a.length; _i++) { | ||
var key = _a[_i]; | ||
if (component[key] instanceof component_1.Component) { | ||
subReducers[key] = this.getReducer(component[key]); | ||
} | ||
} | ||
if (Object.keys(subReducers).length) { | ||
var combinedSubReducer = reducers_1.simpleCombineReducers(subReducers); | ||
return function (state, action) { | ||
var thisState = rootReducer(state, action); | ||
var subStates = combinedSubReducer(state, action); | ||
return __assign({}, thisState, subStates); | ||
}; | ||
} | ||
return rootReducer; | ||
}; | ||
ReduxApp.options = options_1.globalOptions; | ||
return ReduxApp; | ||
}()); | ||
exports.ReduxApp = ReduxApp; | ||
/***/ }), | ||
/* 7 */ | ||
/***/ (function(module, exports) { | ||
module.exports = require("redux"); | ||
/***/ }), | ||
/* 8 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var componentSchema_1 = __webpack_require__(1); | ||
var log_1 = __webpack_require__(9); | ||
var options_1 = __webpack_require__(0); | ||
var utils_1 = __webpack_require__(2); | ||
exports.REDUCER = Symbol('REDUCER'); | ||
var DISPOSE = Symbol('DISPOSE'); | ||
var Component = (function () { | ||
function Component(store, schema, path) { | ||
if (!componentSchema_1.isComponentSchema(schema)) | ||
throw new Error("Argument '" + "schema" + "' is not a component schema. Did you forget to use the decorator?"); | ||
this[DISPOSE] = []; | ||
createSelf(this, store, schema, path); | ||
createSubComponents(this, store, schema, path); | ||
log_1.debug("[Component] new " + schema.constructor.name + " component created. path: " + path.join('.')); | ||
} | ||
Component.prototype.disposeComponent = function () { | ||
var disposables = this[DISPOSE]; | ||
while (disposables.length) { | ||
var disposable = disposables.pop(); | ||
if (disposable && disposable.dispose) | ||
disposable.dispose(); | ||
} | ||
}; | ||
return Component; | ||
}()); | ||
exports.Component = Component; | ||
function createSelf(component, store, schema, path) { | ||
for (var _i = 0, _a = Object.keys(schema); _i < _a.length; _i++) { | ||
var key = _a[_i]; | ||
component[key] = schema[key]; | ||
} | ||
var proto = utils_1.getPrototype(component); | ||
var patchedProto = createActions(store.dispatch, schema); | ||
Object.assign(proto, patchedProto); | ||
component[exports.REDUCER] = createReducer(schema); | ||
var options = options_1.getSchemaOptions(schema); | ||
if (options.updateState) { | ||
var unsubscribe_1 = store.subscribe(function () { return updateState(component, store.getState(), path); }); | ||
component[DISPOSE].push({ dispose: function () { return unsubscribe_1(); } }); | ||
} | ||
} | ||
function createSubComponents(component, store, schema, path) { | ||
for (var _i = 0, _a = Object.keys(schema); _i < _a.length; _i++) { | ||
var key = _a[_i]; | ||
var subSchema = schema[key]; | ||
if (componentSchema_1.isComponentSchema(subSchema)) { | ||
component[key] = new Component(store, subSchema, path.concat([key])); | ||
} | ||
} | ||
} | ||
function createActions(dispatch, schema) { | ||
var methods = utils_1.getMethods(schema); | ||
if (!methods) | ||
return undefined; | ||
var outputActions = {}; | ||
Object.keys(methods).forEach(function (key) { | ||
outputActions[key] = function () { | ||
var payload = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
payload[_i] = arguments[_i]; | ||
} | ||
dispatch({ | ||
type: options_1.getActionName(key, schema), | ||
payload: payload | ||
}); | ||
}; | ||
}); | ||
return outputActions; | ||
} | ||
function createReducer(schema) { | ||
var methods = utils_1.getMethods(schema); | ||
var methodNames = {}; | ||
Object.keys(methods).forEach(function (methName) { | ||
var actionName = options_1.getActionName(methName, schema); | ||
methodNames[actionName] = methName; | ||
}); | ||
return function (state, action) { | ||
log_1.verbose("[reducer] reducer of: " + schema.constructor.name + ", action: " + action.type); | ||
if (state === undefined) { | ||
log_1.verbose('[reducer] state is undefined, returning initial value'); | ||
return schema; | ||
} | ||
var methodName = methodNames[action.type]; | ||
var actionReducer = methods[methodName]; | ||
if (!actionReducer) { | ||
log_1.verbose('[reducer] no matching action in this reducer, returning previous state'); | ||
return state; | ||
} | ||
var newState = Object.assign({}, state); | ||
actionReducer.call.apply(actionReducer, [newState].concat(action.payload)); | ||
log_1.verbose('[reducer] reducer invoked returning new state'); | ||
return newState; | ||
}; | ||
} | ||
function updateState(component, newGlobalState, path) { | ||
log_1.verbose('[updateState] updating component in path: ', path.join('.')); | ||
var self = component; | ||
var newScopedState = utils_1.getProp(newGlobalState, path); | ||
var propsDeleted = []; | ||
var propsAssigned = []; | ||
log_1.verbose('[updateState] store before: ', newScopedState); | ||
log_1.verbose('[updateState] component before: ', component); | ||
Object.keys(newScopedState).forEach(function (key) { | ||
if (self[key] !== newScopedState[key] && !(self[key] instanceof Component)) { | ||
self[key] = newScopedState[key]; | ||
propsAssigned.push(key); | ||
} | ||
}); | ||
Object.keys(component).forEach(function (key) { | ||
if (newScopedState[key] === undefined) { | ||
delete self[key]; | ||
propsDeleted.push(key); | ||
} | ||
}); | ||
if (propsDeleted.length || propsAssigned.length) { | ||
log_1.verbose('[updateState] store after: ', newScopedState); | ||
log_1.verbose('[updateState] component after: ', component); | ||
log_1.debug("[updateState] state of " + path.join('.') + " changed"); | ||
if (propsDeleted.length) { | ||
log_1.debug('[updateState] props deleted: ', propsDeleted); | ||
} | ||
else { | ||
log_1.verbose('[updateState] props deleted: ', propsDeleted); | ||
} | ||
if (propsAssigned.length) { | ||
log_1.debug('[updateState] props assigned: ', propsAssigned); | ||
} | ||
else { | ||
log_1.verbose('[updateState] props assigned: ', propsAssigned); | ||
} | ||
} | ||
else { | ||
log_1.verbose('[updateState] no change'); | ||
} | ||
} | ||
/***/ }), | ||
/* 9 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var options_1 = __webpack_require__(0); | ||
function debug(message) { | ||
var optionalParams = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
optionalParams[_i - 1] = arguments[_i]; | ||
} | ||
if (!shouldLog(options_1.LogLevel.Debug)) | ||
return; | ||
console.log.apply(console, ['[ReduxApp] [DEBUG] ' + message].concat(optionalParams)); | ||
} | ||
exports.debug = debug; | ||
function verbose(message) { | ||
var optionalParams = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
optionalParams[_i - 1] = arguments[_i]; | ||
} | ||
if (!shouldLog(options_1.LogLevel.Verbose)) | ||
return; | ||
console.log.apply(console, ['[ReduxApp] [VERBOSE] ' + message].concat(optionalParams)); | ||
} | ||
exports.verbose = verbose; | ||
function shouldLog(level) { | ||
if (options_1.globalOptions.logLevel === options_1.LogLevel.None) | ||
return false; | ||
if (options_1.globalOptions.logLevel > level) | ||
return false; | ||
return true; | ||
} | ||
/***/ }), | ||
/* 10 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function simpleCombineReducers(reducers) { | ||
var reducerKeys = Object.keys(reducers); | ||
return function combination(state, action) { | ||
if (state === void 0) { state = {}; } | ||
var hasChanged = false; | ||
var nextState = {}; | ||
for (var _i = 0, reducerKeys_1 = reducerKeys; _i < reducerKeys_1.length; _i++) { | ||
var key = reducerKeys_1[_i]; | ||
var reducer = reducers[key]; | ||
var previousStateForKey = state[key]; | ||
var nextStateForKey = reducer(previousStateForKey, action); | ||
nextState[key] = nextStateForKey; | ||
hasChanged = hasChanged || nextStateForKey !== previousStateForKey; | ||
} | ||
return hasChanged ? nextState : state; | ||
}; | ||
} | ||
exports.simpleCombineReducers = simpleCombineReducers; | ||
/***/ }) | ||
/******/ ]); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("redux-app",[],t):"object"==typeof exports?exports["redux-app"]=t():e["redux-app"]=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=3)}([function(e,t,n){"use strict";function o(e){return c.assertComponentSchema(e),Object.assign({},new s,t.globalOptions.schema,u.getConstructorProp(e,t.COMPONENT_SCHEMA_OPTIONS))}function r(e,t){var n=o(t),r=e,c=t.constructor.name;return n.uppercaseActions&&(r=i(r).toUpperCase(),c=i(c).toUpperCase()),n.actionNamespace&&(r=c+"."+r),r}Object.defineProperty(t,"__esModule",{value:!0});var c=n(1),u=n(2),i=n(5);t.COMPONENT_SCHEMA_OPTIONS=Symbol("COMPONENT_SCHEMA_OPTIONS");var s=function(){function e(){this.actionNamespace=!0,this.uppercaseActions=!0,this.updateState=!0}return e}();t.SchemaOptions=s,t.getSchemaOptions=o,t.getActionName=r;var a;!function(e){e[e.None=0]="None",e[e.Verbose=1]="Verbose",e[e.Debug=2]="Debug",e[e.Silent=10]="Silent"}(a=t.LogLevel||(t.LogLevel={}));var p=function(){function e(){this.logLevel=a.Silent,this.schema=new s}return e}();t.GlobalOptions=p,t.globalOptions=new p},function(e,t,n){"use strict";function o(e){if("function"!=typeof e)return function(t){return u(t,e)};u.call(void 0,e)}function r(e){return s.getConstructorProp(e,a)}function c(e){if(!r(e))throw new Error("Invalid argument. component expected.")}function u(e,t){if(s.getArgumentNames(e).length)throw new Error("componentSchema classes must have a parameter-less constructor");e[a]=!0,e[i.COMPONENT_SCHEMA_OPTIONS]=t}Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),s=n(2),a=Symbol("COMPONENT_SCHEMA");t.component=o,t.isComponentSchema=r,t.assertComponentSchema=c},function(e,t,n){"use strict";function o(e){var t,n=/^function\s*?[^\(]*?\(\s*?([^\)]*?)\)/m,o=/^class[\s\S]*?constructor\s*?[^\(]*?\(\s*?([^\)]*?)\)/m,r=e.toString().match(n),c=e.toString().match(o);if(c&&c.length)t=c[1];else{if(!r||!r.length)return[];t=r[1]}return t=t.split(",").map(function(e){return e.trim()}).filter(function(e){return""!==e})}function r(e){if(e)return e.prototype||e.constructor.prototype}function c(e){if(e){var t=r(e);if(t){for(var n={},o=0,c=Object.keys(t);o<c.length;o++){var u=c[o];"function"==typeof t[u]&&(n[u]=t[u])}return n}}}function u(e,t){return"string"==typeof t&&(t=t.replace(/\[|\]/g,".").split(".").filter(function(e){return"string"==typeof e&&""!==e.trim()})),t.reduce(function(e,t){if("object"==typeof e&&t)return e[t.toString()]},e)}function i(e,t){return e&&e.constructor&&e.constructor[t]}Object.defineProperty(t,"__esModule",{value:!0}),t.getArgumentNames=o,t.getPrototype=r,t.getMethods=c,t.getProp=u,t.getConstructorProp=i},function(e,t,n){e.exports=n(4)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(1);t.component=o.component;var r=n(0);t.SchemaOptions=r.SchemaOptions,t.GlobalOptions=r.GlobalOptions,t.LogLevel=r.LogLevel;var c=n(6);t.ReduxApp=c.ReduxApp},function(e,t){e.exports=require("lodash.snakecase")},function(e,t,n){"use strict";var o=this&&this.__assign||Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e};Object.defineProperty(t,"__esModule",{value:!0});var r=n(7),c=n(8),u=n(0),i=n(10),s=function(){function e(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var o=function(){};this.store=r.createStore.apply(void 0,[o].concat(t));var u=new c.Component(this.store,e,[]);this.root=u;var i=this.getReducer(u);this.store.replaceReducer(i)}return e.prototype.getReducer=function(e){for(var t=e[c.REDUCER],n={},r=0,u=Object.keys(e);r<u.length;r++){var s=u[r];e[s]instanceof c.Component&&(n[s]=this.getReducer(e[s]))}if(Object.keys(n).length){var a=i.simpleCombineReducers(n);return function(e,n){var r=t(e,n),c=a(e,n);return o({},r,c)}}return t},e.options=u.globalOptions,e}();t.ReduxApp=s},function(e,t){e.exports=require("redux")},function(e,t,n){"use strict";function o(e,n,o,r){for(var s=0,a=Object.keys(o);s<a.length;s++){var d=a[s];e[d]=o[d]}var v=f.getPrototype(e),g=c(n.dispatch,o);if(Object.assign(v,g),e[t.REDUCER]=u(o),p.getSchemaOptions(o).updateState){var h=n.subscribe(function(){return i(e,n.getState(),r)});e[l].push({dispose:function(){return h()}})}}function r(e,t,n,o){for(var r=0,c=Object.keys(n);r<c.length;r++){var u=c[r],i=n[u];s.isComponentSchema(i)&&(e[u]=new d(t,i,o.concat([u])))}}function c(e,t){var n=f.getMethods(t);if(n){var o={};return Object.keys(n).forEach(function(n){o[n]=function(){for(var o=[],r=0;r<arguments.length;r++)o[r]=arguments[r];e({type:p.getActionName(n,t),payload:o})}}),o}}function u(e){var t=f.getMethods(e),n={};return Object.keys(t).forEach(function(t){var o=p.getActionName(t,e);n[o]=t}),function(o,r){if(a.verbose("[reducer] reducer of: "+e.constructor.name+", action: "+r.type),void 0===o)return a.verbose("[reducer] state is undefined, returning initial value"),e;var c=n[r.type],u=t[c];if(!u)return a.verbose("[reducer] no matching action in this reducer, returning previous state"),o;var i=Object.assign({},o);return u.call.apply(u,[i].concat(r.payload)),a.verbose("[reducer] reducer invoked returning new state"),i}}function i(e,t,n){a.verbose("[updateState] updating component in path: ",n.join("."));var o=e,r=f.getProp(t,n),c=[],u=[];a.verbose("[updateState] store before: ",r),a.verbose("[updateState] component before: ",e),Object.keys(r).forEach(function(e){o[e]===r[e]||o[e]instanceof d||(o[e]=r[e],u.push(e))}),Object.keys(e).forEach(function(e){void 0===r[e]&&(delete o[e],c.push(e))}),c.length||u.length?(a.verbose("[updateState] store after: ",r),a.verbose("[updateState] component after: ",e),a.debug("[updateState] state of "+n.join(".")+" changed"),c.length?a.debug("[updateState] props deleted: ",c):a.verbose("[updateState] props deleted: ",c),u.length?a.debug("[updateState] props assigned: ",u):a.verbose("[updateState] props assigned: ",u)):a.verbose("[updateState] no change")}Object.defineProperty(t,"__esModule",{value:!0});var s=n(1),a=n(9),p=n(0),f=n(2);t.REDUCER=Symbol("REDUCER");var l=Symbol("DISPOSE"),d=function(){function e(e,t,n){if(!s.isComponentSchema(t))throw new Error("Argument 'schema' is not a component schema. Did you forget to use the decorator?");this[l]=[],o(this,e,t,n),r(this,e,t,n),a.debug("[Component] new "+t.constructor.name+" component created. path: "+n.join("."))}return e.prototype.disposeComponent=function(){for(var e=this[l];e.length;){var t=e.pop();t&&t.dispose&&t.dispose()}},e}();t.Component=d},function(e,t,n){"use strict";function o(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];c(u.LogLevel.Debug)&&console.log.apply(console,["[ReduxApp] [DEBUG] "+e].concat(t))}function r(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];c(u.LogLevel.Verbose)&&console.log.apply(console,["[ReduxApp] [VERBOSE] "+e].concat(t))}function c(e){return u.globalOptions.logLevel!==u.LogLevel.None&&!(u.globalOptions.logLevel>e)}Object.defineProperty(t,"__esModule",{value:!0});var u=n(0);t.debug=o,t.verbose=r},function(e,t,n){"use strict";function o(e){var t=Object.keys(e);return function(n,o){void 0===n&&(n={});for(var r=!1,c={},u=0,i=t;u<i.length;u++){var s=i[u],a=e[s],p=n[s],f=a(p,o);c[s]=f,r=r||f!==p}return r?c:n}}Object.defineProperty(t,"__esModule",{value:!0}),t.simpleCombineReducers=o}])}); |
{ | ||
"name": "redux-app", | ||
"version": "1.0.2", | ||
"description": "An attempt at a type-safe, DRY and OO redux", | ||
"version": "1.0.3", | ||
"description": "Type-safe, DRY and OO redux. Implemented with typescript.", | ||
"main": "dist/redux-app.min.js", | ||
@@ -6,0 +6,0 @@ "typings": "dist/index.d.ts", |
@@ -7,5 +7,9 @@ var path = require('path'); | ||
entry: ['./src/index.ts'], | ||
devtool: 'source-map', | ||
output: { | ||
path: path.resolve('./dist'), | ||
filename: 'redux-app.min.js' | ||
filename: 'redux-app.min.js', | ||
library: 'redux-app', | ||
libraryTarget: 'umd', | ||
umdNamedDefine: true | ||
}, | ||
@@ -21,3 +25,6 @@ externals: [nodeExternals()], | ||
modules: [path.resolve("./src"), "node_modules"] | ||
} | ||
}, | ||
plugins: [ | ||
new webpack.optimize.UglifyJsPlugin() | ||
] | ||
}; |
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
34845
615
3