From 8a720df9b7fd7435eeb559c139b9062aa589e5e7 Mon Sep 17 00:00:00 2001 From: Ifeora Okechukwu Date: Sat, 8 Sep 2018 11:11:23 +0100 Subject: [PATCH] pre-release 0.1.2 --- .gitignore | 3 + dist/radixx.es2015.js | 2483 +++++++++ dist/radixx.es2015.js.map | 1 + dist/radixx.es2015.min.js | 14 + dist/radixx.es2015.min.js.map | 1 + dist/radixx.min.js | 12 +- package-lock.json | 8783 +++++++++++++++++++++++++++++++ package.json | 9 +- src/es/components/dispatcher.js | 948 +++- src/es/components/observable.js | 360 +- src/es/index.js | 64 +- src/es/utils/routines/basics.js | 158 +- src/es/utils/routines/extras.js | 119 +- src/radixx.es2015.js | 2062 -------- src/radixx.js | 11 - webpack.config.js | 27 +- 16 files changed, 12704 insertions(+), 2351 deletions(-) create mode 100644 .gitignore create mode 100644 dist/radixx.es2015.js create mode 100644 dist/radixx.es2015.js.map create mode 100644 dist/radixx.es2015.min.js create mode 100644 dist/radixx.es2015.min.js.map create mode 100644 package-lock.json delete mode 100644 src/radixx.es2015.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a26493a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# ignore dev files + +node_modules \ No newline at end of file diff --git a/dist/radixx.es2015.js b/dist/radixx.es2015.js new file mode 100644 index 0000000..9ab7054 --- /dev/null +++ b/dist/radixx.es2015.js @@ -0,0 +1,2483 @@ +/******/ (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, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // 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 = "./src/es/index.js"); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ "./node_modules/process/browser.js": +/*!*****************************************!*\ + !*** ./node_modules/process/browser.js ***! + \*****************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +// shim for using process in browser +var process = module.exports = {}; + +// cached from whatever global is present so that test runners that stub it +// don't break things. But we need to wrap it in a try catch in case it is +// wrapped in strict mode code which doesn't define any globals. It's inside a +// function because try/catches deoptimize in certain engines. + +var cachedSetTimeout; +var cachedClearTimeout; + +function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); +} +function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); +} +(function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } +} ()) +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + +} +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} + +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); +} + +process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; +process.prependListener = noop; +process.prependOnceListener = noop; + +process.listeners = function (name) { return [] } + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + + +/***/ }), + +/***/ "./node_modules/webpack/buildin/global.js": +/*!***********************************!*\ + !*** (webpack)/buildin/global.js ***! + \***********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +var g; + +// This works in non-strict mode +g = (function() { + return this; +})(); + +try { + // This works if eval is allowed (see CSP) + g = g || Function("return this")() || (1, eval)("this"); +} catch (e) { + // This works if the window reference is available + if (typeof window === "object") g = window; +} + +// g can still be undefined, but nothing to do about it... +// We return undefined, instead of nothing here, so it's +// easier to handle this case. if(!global) { ...} + +module.exports = g; + + +/***/ }), + +/***/ "./src/es/components/dispatcher.js": +/*!*****************************************!*\ + !*** ./src/es/components/dispatcher.js ***! + \*****************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Area = exports.Dispatcher = undefined; + +var _createClass = 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +var _arguments = arguments; + +var _basics = __webpack_require__(/*! ../utils/routines/basics.js */ "./src/es/utils/routines/basics.js"); + +var _extras = __webpack_require__(/*! ../utils/routines/extras.js */ "./src/es/utils/routines/extras.js"); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +try { + var ce = new _basics.wind.CustomEvent('test'); +} catch (e) { + + CEvent.prototype = _basics.wind.Object.create(w.Event && w.Event.prototype || {}); + _basics.wind.CustomEvent = null; + _basics.wind.CustomEvent = CEvent; +} + +var persistStore = _basics.wind.top !== _basics.wind || !_basics.wind.localStorage ? null : _basics.wind.localStorage; + +var sessStore = _basics.wind.top !== _basics.wind || !_basics.wind.sessionStorage ? _basics.wind.opera && !_basics.Hop.call(_basics.wind, 'opera') ? _basics.wind.opera.scriptStorage : {} : _basics.wind.sessionStorage; + +var mode = _basics.wind.document.documentMode || 0; + +var autoRehydrationOccured = false; + +var config = null; + +var watchers = []; + +var stores = {}; + +var storeKeys = []; + +var observers = {}; + +var _promises = {}; + +var waitQueue = []; + +var cachedStorageKeys = {}; + +var getAppOriginForPersist = function getAppOriginForPersist(cfg) { + return String(_basics.wind.location.origin + (cfg.localHostDev ? ':' + _basics.wind.document.documentElement.id : '')); +}; + +var generateTag = function generateTag(origin) { + + var _cdata = persistStore.getItem(origin); + + if (!(0, _basics.isNullOrUndefined)(_cdata)) { + + return getNormalized(_cdata); + } + + return String(Math.random()).replace('.', 'x_').substring(0, 11); +}; + +var defaultConfig = { + runtime: { + spaMode: true, + shutDownHref: '' + }, + persistenceEnabled: false, + autoRehydrate: false, + universalCoverage: false, + localHostDev: false +}; + +var triggerEvt = function triggerEvt(target, eType, detail, globale) { + var evt = new CustomEvent(eType, { + detail: detail, + cancelable: true, + bubbles: false + }); // a stub function - just in case + + var dispatch = function dispatch() { + return false; + }; + + if (!('target' in evt) && evt.cancelBubble === true) { + + target.setCapture(true); + } + + // set up cross-browser dispatch method. + dispatch = target[!('target' in evt) ? "fireEvent" : "dispatchEvent"]; + + // Including support for IE 8 here ;) + return dispatch.apply(target, !('target' in evt) ? ['on' + eType, evt] : [evt]); +}; + +var operationOnStoreSignal = function operationOnStoreSignal(fn, queueing, area, action) { + + // first, retrieve the very first state data and cache it + if (fn.$$history.length == 1 && !fn.$$initData) { + + fn.$$initData = fn.$$history[0]; + } + + // second, make sure that there is no future state to forth on + fn.$$history = fn.$$history.slice(0, fn.$$historyIndex + 1); + + // lets setup a place to store new state, also mark out the context of this call + var newStoreState = false, + len = void 0, + _key = void 0; + + // create a new state of the store data by applying a given + // store callback function to the current history head + + if (queueing === null) { + + if (action !== null) { + + newStoreState = action.actionData; + } else { + + newStoreState = fn.$$history[fn.$$historyIndex]; + } + + coverageNotifier.$$historyLocation = fn.$$historyIndex; + } else { + + newStoreState = fn.call(queueing, action, area.get()); + + coverageNotifier.$$historyLocation = null; + } + + if (typeof newStoreState == 'boolean' || newStoreState == undefined) { + + throw new TypeError("Radixx: Application State unavailable after signal to Dispatcher"); + + return; + } + + _key = area.put(newStoreState); + + coverageNotifier.$$currentStoreTitle = _key; + + if (action !== null) { + + if (action.source !== 'hydrate') { + ; + } + + triggerEvt(_basics.wind.document, 'storesignal', { + url: _basics.wind.location.href, + key: _key, + newValue: newStoreState, + source: _basics.wind, + aspect: action.actionKey, + type: action.actionType + }, _basics.wind); + + coverageNotifier.$$withAction = true; + + // add the new state to the history list and increment + // the index to match in place + len = fn.$$history.push(newStoreState); /* @TODO: use {action.actionType} as operation Annotation */ + + fn.$$historyIndex++; + + if (fn.$$history.length > 21) { + // can't undo/redo (either way) more than 21 moves at any time + + fn.$$history.unshift(); + } + } else { + + return newStoreState; + } +}; + +var getNormalized = function getNormalized(val) { + + if ((0, _basics.isNullOrUndefined)(val) || val === "null") return null; + + try { + return JSON.parse(val); + } catch (e) { + return String(val); + } +}; + +var setNormalized = function setNormalized(val) { + + if ((0, _basics.isNullOrUndefined)(val)) val = null; + + try { + return JSON.stringify(val); + } catch (e) { + + return String(val); + } +}; + +var getCurrentActionOnStack = function getCurrentActionOnStack() { + + var actionStack = operationOnStoreSignal.$$redoActionsStack; + + if (actionStack.lenth) { + return actionStack[actionStack.length - 1]; + } + + return null; +}; + +var coverageNotifier = function coverageNotifier(appState) { + + var currentAction = null; + + var _tag = coverageNotifier.$$tag; + + if (_arguments.callee.$$withAction === true) { + currentAction = getCurrentActionOnStack(); + _arguments.callee.$$withAction = null; + } + + if (!(0, _basics.isNullOrUndefined)(_tag) && persistStore !== null) { + + persistStore.setItem(_tag, setNormalized({ + state: appState, + action: currentAction, + title: _arguments.callee.$$currentStoreTitle, + historyLoc: _arguments.callee.$$historyLocation + })); + + _arguments.callee.$$historyLocation = null; + } +}; + +var fireWatchers = function fireWatchers(state, omitCallback) { + + var pos = void 0, + watcher = void 0; + + for (pos in watchers) { + if (_basics.Hop.call(watchers, pos)) { + watcher = watchers[pos]; + if (omitCallback) { + if (watcher.$$canOmit) { + continue; + }; + } + watcher.call(null, state); + } + } +}; + +var setAppState = function setAppState(appState) { + + (0, _basics.each)(appState, function (isolatedState, storeTitle) { + + var area = new Area(storeTitle); + + area.put(isolatedState); + }); + + fireWatchers(appState, true); +}; + +var getAppState = function getAppState() { + + var appStateData = {}; + var key = void 0; + var indexStart = void 0; + var indexEnd = void 0; + var values = void 0; + var _data = void 0; + + if ('key' in sessStore && typeof sessStore.key == 'function') { + + // We iterate this way so we can support IE 8 + other browsers + for (var i = 0; i < sessStore.length; i++) { + key = sessStore.key(i); + _data = sessStore.getItem(key); + + if (!_data) { + ; + } + + appStateData[key] = getNormalized(_data) || null; + } + } else { + + for (var i = 0; i < storeKeys.length; i++) { + + key = storeKeys[i]; + + if (cachedStorageKeys[key]) { + + indexStart = _basics.wind.name.indexOf(key); + + indexEnd = _basics.wind.name.indexOf('|', indexStart); + + values = _basics.wind.name.substring(indexStart, indexEnd).split(':=:') || ["", null]; + + _data = values[1]; + } + + appStateData[key] = getNormalized(_data) || null; + } + } + + return appStateData; +}; + +var handlePromises = function handlePromises() { + var promise = null; + var state = getAppState(); + + for (var _title2 in _promises) { + if (_basics.Hop.call(_promises, _title2)) { + promise = _promises[_title2]; + if (!promise.isResolved()) { + promise.resolve(); + } + delete _promises[_title2]; + } + } + + waitQueue.length = 0; + + fireWatchers(state); +}; + +var enforceCoverage = function enforceCoverage(e) { + + var _origin = _arguments.callee.$$origin; + var _tag = _arguments.callee.$$tag; + var _action = null; + var _state = null; + var _title = null; + var _hloc = null; + var _composedData = null; + var observer = null; + + // Detecting IE 8 to apply mild hack on event object + if ('remainingSpace' in sessStore) { + e.key = e.detail.key; + } + + if (!persistStore || _origin === e.key) { + // if we can't find the key in the array `storeKeys` + return; + } + + _composedData = getNormalized(persistStore.getItem(_tag)); + + if (_tag === e.key && (0, _basics.isNullOrUndefined)(_composedData)) { + return; + } + + _state = _composedData.state; + + _action = _composedData.action; + + _title = _composedData.title; + + _hloc = parseInt(_composedData.historyLoc); + + if (_action !== null) { + operationOnStoreSignal.$$redoActionsStack.push(_action); + } + + if (_hloc !== null) { + observer = observers[_title]; + if (observer) { + observer.$$historyIndex = _hloc; + if (_hloc === -1) { + observer.$$history.length = 0; + } + } + } + + if (_state) { + setTimeout(setAppState.bind(null, _state), 0); + } +}; + +var stateWatcher = function stateWatcher(e) { + + e = e || _basics.wind.event; + + if (storeKeys.includes(e.detail.key)) { + var storeTitle = e.detail.key; + var listeners = void 0; + + if (!(0, _basics.isNullOrUndefined)(observers[storeTitle])) { + + listeners = observers[storeTitle].$$store_listeners; + + for (var t = 0; t < listeners.length; t++) { + + listeners[t].call(stores[storeTitle], e.detail.type, e.detail.aspect); + } + } + } +}; + +/** + Though IE 9 to IE 11 supports the CustomEvent constructor, IE throws an error {Object doesn't support this action} + whenever it's used. This weird behaviour is fixed below + See: https://stackoverflow.com/questions/14358599/object-doesnt-support-this-action-ie9-with-customevent-initialization +*/ + +function CEvent(event, params) { + var t = void 0; + var evt = void 0; + var d = _basics.wind.document; + params = params || { bubbles: false, cancelable: false, detail: undefined }; + + try { + evt = d.createEvent('CustomEvent'); + evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); + } catch (e) { + evt = d.createEventObject(w.event); + evt.cancelBubble = !params.bubbles; + evt.returnValue = !params.cancelable; + + if (_typeof(params.detail) === "object") { + // set expando properties on event object + + /*for(t in params.detail){ + if((({}).hasOwnProperty.call(params.detail, t))){ + evt[t] = params.detail[t]; + } + }*/ + evt.detail = params.detail; + } + } + + return evt; +} + +function setupConfigSettings(config, hub) { + + if (config.universalCoverage) { + + config.persistenceEnabled = true; + } + + if (config.persistenceEnabled) { + + // prepare Origin + var _origin = getAppOriginForPersist(config); + + var _tag = generateTag(_origin); + + persistStore.setItem(_origin, _tag); + + enforceCoverage.$$origin = _origin; + + enforceCoverage.$$tag = _tag; + + coverageNotifier.$$canOmit = true; + + coverageNotifier.$$tag = _tag; + + hub.onDispatch(coverageNotifier); + } + + if (config.autoRehydrate === true) { + + var data = null; + + if (!(0, _basics.isNullOrUndefined)(enforceCoverage.$$tag) && persistStore) { + data = getNormalized(persistStore.getItem(enforceCoverage.$$tag)); + } + + if (data instanceof Object && data.state) { + setAppState(data.state); + this.updateAutoRehydrationState(); + } + } + + if (!config.runtime.spaMode) { + + if (typeof config.runtime.shutDownHref === 'string' && config.runtime.shutDownHref.length != 0) { + + _basics.wind.onbeforeunload = (0, _extras.$createBeforeTearDownCallback)(config); + + _basics.wind.onunload = (0, _extras.$createTearDownCallback)(hub); + } + } else { + + if (typeof config.runtime.shutDownHref === 'string' && config.runtime.shutDownHref.length != 0) { + + if (_basics.wind.addEventListener) { + _basics.wind.document.documentElement.addEventListener('click', (0, _extras.$createBeforeTearDownCallback)(config), false); + _basics.wind.document.addEventListener('click', (0, _extras.$createTearDownCallback)(hub), false); + } else { + _basics.wind.document.documentElement.attachEvent('onclick', (0, _extras.$createBeforeTearDownCallback)(config)); + _basics.wind.document.attachEvent('onclick', (0, _extras.$createTearDownCallback)(hub), false); + } + } + } +} + +var Area = function Area(key) { + + this.put = function (value) { + + /* + In IE 8-9, writing to sessionStorage is done asynchronously (other browsers write synchronously) + we need to fix this by using IE proprietary methods + See: https://www.nczonline.net/blog/2009/07/21/introduction-to-sessionstorage/ + */ + + var indexStart = void 0; + + var indexEnd = void 0; + + var isIE8Storage = 'remainingSpace' in sessStore && mode === 8; + + // Detecting IE 8 to enable forced sync + if (isIE8Storage) { + if (typeof sessStore.begin == 'function') { + sessStore.begin(); + } + } + + try { + + sessStore.setItem(key, setNormalized(value)); + } catch (e) { + + /* This is a fallback to support Opera Mini 4.4+ on Mobile */ + + if (cachedStorageKeys[key]) { + // we're in overwrite mode, so clear `key` out and push in update (below) + indexStart = _basics.wind.name.indexOf(key); + + indexEnd = _basics.wind.name.indexOf('|', indexStart); + + _basics.wind.name = _basics.wind.name.replace(_basics.wind.name.substring(indexStart, indexEnd), ''); + } + + if (_basics.wind.name === "") { + + _basics.wind.name = key + ':=:' + setNormalized(value) + '|'; + } else { + + _basics.wind.name += key + ':=:' + setNormalized(value) + '|'; + } + + cachedStorageKeys[key] = 1; + } + + if (isIE8Storage) { + if (typeof sessStore.commit == 'function') { + sessStore.commit(); + } + } + + return key; + }; + + this.get = function () { + + var indexStart = void 0, + indexEnd = void 0, + values = void 0; + + /* This is a fallback to support Opera Mini 4.4+ on Mobile */ + + try { + + return getNormalized(sessStore.getItem(key)) || null; + } catch (e) { + + if (cachedStorageKeys[key]) { + + indexStart = _basics.wind.name.indexOf(key); + + indexEnd = _basics.wind.name.indexOf('|', indexStart); + + values = _basics.wind.name.substring(indexStart, indexEnd).split(':=:') || [0, 0]; + + return getNormalized(values[1]) || null; + } + + return null; + } + }; + + this.del = function () { + + var indexStart = void 0; + + var indexEnd = void 0; + /* This is a fallback to support Opera Mini 4.4+ on Mobile */ + + try { + + return sessStore.removeItem(key); + } catch (e) { + + if (cachedStorageKeys[key]) { + + // we're in delete mode + indexStart = _basics.wind.name.indexOf(key); + + indexEnd = _basics.wind.name.indexOf('|', indexStart); + + _basics.wind.name = _basics.wind.name.replace(_basics.wind.name.substring(indexStart, indexEnd), ''); + + delete cachedStorageKeys[key]; + } + + return; + } + }; + + return this; +}; + +var Dispatcher = function () { + function Dispatcher() { + _classCallCheck(this, Dispatcher); + + this.middlewares = []; + + operationOnStoreSignal.$$undoActionsStack = []; + + operationOnStoreSignal.$$redoActionsStack = []; + } + + _createClass(Dispatcher, [{ + key: 'updateAutoRehydrationState', + value: function updateAutoRehydrationState() { + + autoRehydrationOccured = true; + } + }, { + key: 'getAutoRehydrationState', + value: function getAutoRehydrationState() { + + return autoRehydrationOccured; + } + }, { + key: 'setMiddleware', + value: function setMiddleware(middleware) { + + if (typeof middleware === 'function' + /*&& (middleware.length >= 2)*/) { + + return this.middlewares.push(middleware); + } + + throw new Error("Radixx: Inavlid Middleware Callback - Must be a Function with Parameters ( >= 2 )"); + } + }, { + key: 'hasMiddleware', + value: function hasMiddleware() { + + return this.middlewares.length > 0; + } + }, { + key: 'initCatchers', + value: function initCatchers(userConfig, hub) { + + if ((0, _basics.isNullOrUndefined)(config)) { + + config = (0, _basics.extend)(userConfig, defaultConfig); + + setupConfigSettings.apply(this, [config, hub]); + } + + if (_basics.wind.document.addEventListener) { + /* IE 9+, W3C browsers all expect the 'storage' event to be bound to the window */ + if (config.universalCoverage) { + _basics.wind.addEventListener('storage', enforceCoverage, false); + } + + _basics.wind.document.addEventListener('storesignal', stateWatcher, false); + } else if (_basics.wind.document.attachEvent) { + /* IE 8 expects the 'storage' event handler to be bound to the document + and not to the window */ + if (config.universalCoverage) { + _basics.wind.document.attachEvent('onstorage', enforceCoverage); + } + + _basics.wind.document.attachEvent('onstoresignal', stateWatcher); + } + } + }, { + key: 'getRegistration', + value: function getRegistration(title) { + + if (_basics.Hop.call(observers, title)) { + + return observers[title]; + } + + return {}; + } + }, { + key: 'register', + value: function register(title, observer, defaultStoreContainer) { + + if (_basics.Hop.call(observers, title)) { + + if ('$$history' in observers[title] && typeof observer.$$history == 'undefined') { + if (!stores[title]) { + // If the store doesn't have any change listeners registered + + throw new Error("Radixx: Cannot Overwrite existing store registration"); + + return; + } + + observer.$$history = observers[title].$$history; + observer.$$historyIndex = observers[title].$$historyIndex; + observer.$$store_listeners = observers[title].$$store_listeners; + observers[title] = observer; + } + } else { + + observer.$$store_listeners = []; + observer.$$history = [!!defaultStoreContainer ? defaultStoreContainer : []]; + observer.$$historyIndex = 0; + observers[title] = observer; + storeKeys.push(title); + } + + return true; + } + }, { + key: 'watch', + value: function watch(callback) { + + watchers.push(callback); + } + }, { + key: 'setStoreListener', + value: function setStoreListener(store, callback) { + + var title = store.getTitle(); + + if (!(0, _basics.isNullOrUndefined)(observers[title])) { + + if (typeof callback == "function") { + stores[title] = store; + observers[title].$$store_listeners.push(callback); + } + } + } + }, { + key: 'unsetStoreListener', + value: function unsetStoreListener(store, callback) { + + var title = store.getTitle(); + + if (!(0, _basics.isNullOrUndefined)(observers[title])) { + if (typeof callback == "function") { + + var pos = observers[title].$$store_listeners.indexOf(callback); + observers[title].$$store_listeners.splice(pos, 1); + } + } + } + }, { + key: 'signalUnique', + value: function signalUnique(hydrateAction) { + + if (hydrateAction.source != 'hydrate') { + return; + } + + // Pass this on to the event queue [await] + _basics.wind.setTimeout(handlePromises, 0); + + var stateArea = new Area(hydrateAction.target), + regFunc = observers[hydrateAction.target]; + + operationOnStoreSignal.$$redoActionsStack.length = 0; + + operationOnStoreSignal.$$redoActionsStack.push(hydrateAction); + + regFunc.$$history.length = 0; // clear out the store state since this is a hydrate call + + regFunc.historyIndex = -1; + + operationOnStoreSignal.apply(undefined, [regFunc, null, stateArea, hydrateAction]); + } + }, { + key: 'handleStoreMutation', + value: function handleStoreMutation(store, mutationType) { + + if (!mutationType) { + return; + } + + var storeTitle = store.getTitle(); + var isolatedState = {}; + var regFunc = this.getRegistration(storeTitle); + var stateArea = new Area(storeTitle); + + switch (mutationType) { + + case 'undo': + if (store.canUndo()) { + + --regFunc.$$historyIndex; + + isolatedState[storeTitle] = operationOnStoreSignal.apply(undefined, [regFunc, null, stateArea, null]); + + // Pass this on to the event queue + _basics.wind.setTimeout(fireWatchers.bind(null, isolatedState), 0); + + return true; + } + break; + case 'redo': + if (store.canRedo()) { + + ++regFunc.$$historyIndex; + + isolatedState[storeTitle] = operationOnStoreSignal.apply(undefined, [regFunc, null, stateArea, null]); + + // Pass this on to the event queue + _basics.wind.setTimeout(fireWatchers.bind(null, isolatedState), 0); + + return true; + } + break; + } + + return false; + } + }, { + key: 'deletePersistenceTagAndData', + value: function deletePersistenceTagAndData() { + + if ((0, _basics.isNullOrUndefined)(config)) { + + return false; + } + + var _origin = getAppOriginForPersist(config); + + var _tag = generateTag(_origin); + + persistStore.removeItem(_origin); + + persistStore.removeItem(_tag); + + return true; + } + }, { + key: 'rebuildStateFromActions', + value: function rebuildStateFromActions() { + + var actionsStack = operationOnStoreSignal.$$redoActionsStack; + + (0, _basics.each)(actionsStack, function (action, index) { + + var stateArea = void 0; + + for (title in observers) { + if (_basics.Hop.call(observers, title)) { + + stateArea = new Area(title); + + observers[title].call(action, stateArea.get()); + } + } + }, operationOnStoreSignal); + } + }, { + key: 'signal', + value: function signal(action) { + + var compactedFunc = null; + + var // this is the function that does the actual dispatch of the + baseDispatcher = function baseDispatcher(observers, dispatcher, action, prevState) { + + var title = void 0, + stateArea = null; + + operationOnStoreSignal.$$redoActionsStack.push(action); + + for (title in observers) { + if (_basics.Hop.call(observers, title)) { + + stateArea = new Area(title); + + operationOnStoreSignal.apply(undefined, [observers[title], dispatcher.queueing, stateArea, action]); + } + } + + return getAppState(); + }; + + var boundBaseDispatcher = baseDispatcher.bind(null, observers, this); + + var adjoiner = { + /*createActionObject:function(_data, _type){ + + return { + source:"", + actionType:_type, + actionData:_data, + actionKey:null + }; + },*/ + createDispatchResolver: function createDispatchResolver(_action) { + + return boundBaseDispatcher.bind(null, _action); + } + }; + + var _hasMiddleware = this.hasMiddleware(); + + // Some validation - just to make sure everything is okay + if (!(action.source in dispatchRegistry)) { + + return; + } + + // determine if there are middleware callbacks registered + if (_hasMiddleware) { + + // collapse all middleware callbacks into a single callback + compactedFunc = this.middlewares.concat(boundBaseDispatcher).reduceRight(function (bound, middleware) { + return middleware.bind(null, bound); + }); + } else { + + compactedFunc = boundBaseDispatcher; + } + + // Pass this on to the event queue + _basics.wind.setTimeout(handlePromises, 0); + + // begin cascading calls to the middlewares in turn + // from the last attached middleware all the way up + // to the first middleware until the action + // is finally dispatched + + if (!(0, _basics.isNullOrUndefined)(compactedFunc)) { + + compactedFunc.apply(_hasMiddleware ? adjoiner : null, [action, getAppState()]); + } + } + }, { + key: 'unregister', + value: function unregister(title) { + + var observer = void 0, + store = void 0, + index = void 0; + + if (!(0, _basics.isNullOrUndefined)(observers[title])) { + // initial clean-up + + observer = observers[title]; + store = stores[title]; + observer.$$store_listeners.length = 0; + observer.$$store_listeners = null; + observer.$$historyIndex = -1; + observer.$$history.length = 0; + observer.$$history = null; + + // more clean-up (freeing memory) + delete observers[title]; + observer = null; + + delete stores[title]; + store = null; + + index = storeKeys.indexOf(title); + + if (index != -1) { + storeKeys.splice(index, 1); + } + } + } + }]); + + return Dispatcher; +}(); + +exports.Dispatcher = Dispatcher; +exports.Area = Area; + +/***/ }), + +/***/ "./src/es/components/observable.js": +/*!*****************************************!*\ + !*** ./src/es/components/observable.js ***! + \*****************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.createActionInterface = exports.createStoreInterface = exports.isAppStateAutoRehydrated = exports.watchDispatcher = exports.setStoreObserver = exports.purgePersistStore = exports.mergeConfig = exports.setupShutdownCallback = exports.registerAction = exports.makeAggregator = exports.eachStore = undefined; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +var _basics = __webpack_require__(/*! ../utils/routines/basics.js */ "./src/es/utils/routines/basics.js"); + +var _dispatcher = __webpack_require__(/*! ./dispatcher.js */ "./src/es/components/dispatcher.js"); + +var _extras = __webpack_require__(/*! ../utils/routines/extras.js */ "./src/es/utils/routines/extras.js"); + +var $instance = null; + +var dispatchRegistry = {}; + +var getInstance = function getInstance() { + + if ($instance === null) { + + $instance = new _dispatcher.Dispatcher(); + } + + return $instance; +}; + +var getObjectPrototype = function getObjectPrototype(obj) { + if ('getPrototypeOf' in Object) { + return Object.getPrototypeOf(obj); + } else if ('__proto__' in obj) { + if (!Hop.call(obj, '__proto__')) { + return obj.__proto__; + } + } else if ('constructor' in obj) { + if (!Hop.call(obj, 'constructor')) { + return obj.constructor.prototype; + } + } + return obj; +}; + +var eachStore = function eachStore(fn, extractor, storeArray) { + + each(storeKeys, extractor.bind(storeArray = [], stores)); + + var callable = fn; + var prevIndex = storeArray.length - 1; + + var next = function next() { + + var returnVal = void 0; + + if (prevIndex >= 0) { + returnVal = Boolean(callable.call(null, storeArray[prevIndex--], next)); + } else { + callable = !0; + returnVal = callable; + } + + return returnVal; + }; + + next(); +}; + +var setActionVectors = function setActionVectors(object, vectors) { + + var _proto = getObjectPrototype(object); + var dispatcher = getInstance(); + var vector = null; + + for (var creator in vectors) { + if (Hop.call(vectors, creator)) { + vector = vectors[creator]; + _proto[creator] = createActionInterface(dispatcher, vector); + } + } + + return object; +}; + +var createStoreInterface = function createStoreInterface(dispatcher, method) { + + return function () { + var regFunc = void 0; + var area = void 0; + var argument = arguments.length ? arguments[0] : null; + + if (method == 'setChangeListener') { + + return dispatcher.setStoreListener(this, argument); + } + + if (method == 'unsetChangeListener') { + + return dispatcher.unsetStoreListener(this, argument); + } + + if (method == 'getState') { + + var value = void 0; + area = new _dispatcher.Area(this.getTitle()); + value = area.get(); + area = null; + + if (value === area) { + + regFunc = dispatcher.getRegistration(this.getTitle()); + + return regFunc.$$history.length && regFunc.$$history[0]; + } + + return typeof argument == 'string' && argument in value ? value[argument] : value; + } + + if (method == 'destroy') { + + var title = void 0, + index = void 0; + + if (title in stores) { + + delete stores[title]; + } + + area = new _dispatcher.Area(this.getTitle()); + + area.del(); + + return area = title = null; + } + + if (method == 'disconnect') { + + return dispatcher.unregister(this.getTitle()); + } + + if (method == 'hydrate') { + + if ((0, _basics.isNullOrUndefined)(argument)) { + return; + } + + return dispatcher.signalUnique({ + source: method, + target: this.getTitle(), + actionData: argument + }); + } + + if (method == 'getQuerySchema') { + + return {}; + } + + if (method == 'setQuerySchema') { + + return true; + } + + if (method == 'canUndo') { + + regFunc = dispatcher.getRegistration(this.getTitle()); + + return regFunc.$$historyIndex != 0; + } + + if (method == 'swapCallback') { + + return dispatcher.register(this.getTitle(), argument); + } + + if (method == 'canRedo') { + + regFunc = dispatcher.getRegistration(this.getTitle()); + + return regFunc.$$historyIndex !== regFunc.$$history.length - 1; + } + + if (method == 'undo') { + + return dispatcher.handleStoreMutation(this, method); + } + + if (method == 'redo') { + + return dispatcher.handleStoreMutation(this, method); + } + }; +}; + +var createActionInterface = function createActionInterface(dispatcher, vector) { + + if (!(vector instanceof Object)) { + + throw new TypeError('Invalid Action Creator Vector, expected [object] but found [' + (typeof vector === 'undefined' ? 'undefined' : _typeof(vector)) + ']'); + } + + return function (data, stateAspectKey) { + + // console.log('OUTER-FUNC: ', this.constructor.caller); + + var id = this.getId(); + + var typesBitMask = 0; + + if (!(0, _basics.isNullOrUndefined)(dispatchRegistry[id])) { + dispatchRegistry[id].actionTypes.push(vector); + } + + if (vector.actionDefinition instanceof Array) { + + each(vector.actionDefinition, function (definition) { + + typesBitMask |= Number(_extras.Values.isOfType(definition, data)); + }); + + if (!typesBitMask) { + + throw new TypeError('Action Data Invalid for action: [' + vector.type + ']'); + } + } else { + if (!_extras.Values.isOfType(vector.actionDefinition, data)) { + + throw new TypeError('Action Data Invalid for action: [' + vector.type + ']'); + } + } + + return dispatcher.signal({ + source: id, + actionType: vector.type, + actionKey: stateAspectKey || null, + actionData: data + }); + }; +}; + +var watchDispatcher = function watchDispatcher(callback) { + + var dispatcher = getInstance(); + + dispatcher.watch(callback); +}; + +var isAppStateAutoRehydrated = function isAppStateAutoRehydrated() { + + var dispatcher = getInstance(); + + return dispatcher.getAutoRehydrationState(); +}; + +var setupShutdownCallback = function setupShutdownCallback(callback, hub) { + + hub._ping = callback; +}; + +var mergeConfig = function mergeConfig(userConfig, hub) { + + var dispatcher = getInstance(); + + return dispatcher.initCatchers(userConfig, hub); +}; + +var purgePersistStore = function purgePersistStore() { + + dispatcher.deletePersistenceTagAndData(); +}; + +var registerAction = function registerAction() { + /* creates hex value e.g. '0ef352ab287f1' */ + var regId = Math.random().toString(16).substr(2, 13); + + dispatchRegistry[regId] = { actionTypes: [] }; + + return regId; +}; + +var makeAggregator = function makeAggregator() { + + return { + notifyAllStores: function notifyAllStores() { + /* + */ + } + }; +}; + +var setMiddlewareCallback = function setMiddlewareCallback(middlewareFunc) { + + var dispatcher = getInstance(); + + // HERE: using this try/catch for control flow and not defensive programming + try { + + dispatcher.getMiddleware(); + } catch (ex) { + + dispatcher.setMiddleware(middlewareFunc); + } +}; + +var setStoreObserver = function setStoreObserver(object, regFunc, defaultStateObj) { + + if (typeof regFunc !== "function") { + return null; + } + + var _proto = getObjectPrototype(object); + var dispatcher = getInstance(); + var title = object.getTitle(); + var method = null; + + dispatcher.register(title, regFunc, defaultStateObj); + + var methods = ['setChangeListener', 'unsetChangeListener', 'getState', 'disconnect', 'getQuerySchema', 'canRedo', 'canUndo', 'swapCallback', 'undo', 'redo', 'hydrate', 'destroy']; + + for (var c = 0; c < methods.length; c++) { + + method = methods[c]; + _proto[method] = createStoreInterface(dispatcher, method); + } +}; + +exports.eachStore = eachStore; +exports.makeAggregator = makeAggregator; +exports.registerAction = registerAction; +exports.setupShutdownCallback = setupShutdownCallback; +exports.mergeConfig = mergeConfig; +exports.purgePersistStore = purgePersistStore; +exports.setStoreObserver = setStoreObserver; +exports.watchDispatcher = watchDispatcher; +exports.isAppStateAutoRehydrated = isAppStateAutoRehydrated; +exports.createStoreInterface = createStoreInterface; +exports.createActionInterface = createActionInterface; + +/***/ }), + +/***/ "./src/es/index.js": +/*!*************************!*\ + !*** ./src/es/index.js ***! + \*************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.toString = exports.onShutdown = exports.onDispatch = exports.attachMiddleware = exports.eachStore = exports.configure = exports.requestAggregator = exports.isAppStateAutoRehydrated = exports.purgePersistentStorage = exports.makeActionCreators = exports.makeStore = exports.Payload = exports.Helpers = undefined; + +var _observable = __webpack_require__(/*! ./components/observable.js */ "./src/es/components/observable.js"); + +var observable = _interopRequireWildcard(_observable); + +var _extras = __webpack_require__(/*! ./utils/routines/extras.js */ "./src/es/utils/routines/extras.js"); + +var _helpers = __webpack_require__(/*! ./utils/helpers.js */ "./src/es/utils/helpers.js"); + +var _helpers2 = _interopRequireDefault(_helpers); + +var _primitiveCheckers = __webpack_require__(/*! ./utils/primitive-checkers.js */ "./src/es/utils/primitive-checkers.js"); + +var _primitiveCheckers2 = _interopRequireDefault(_primitiveCheckers); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +/*! + * @lib: Radixx + * @version: 0.1.2 + * @author: Ifeora Okechukwu + * @created: 30/12/2016 + * + * All Rights Reserved 2016 - 2018. + * Use, reproduction, distribution, and modification of this code is subject to the terms and + * conditions of the MIT license, available at http://www.opensource.org/licenses/mit-license.php + * + * @desc: Implementation of Facebooks' Flux Architecture with a Twist. [ ES6 ] + */ + +function toString() { + + return "[object RadixxHub]"; +} + +var makeStore = function makeStore(dataTitle, registerCallback, defaultStateObj) { + + function _store() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _extras.Store.apply(this, args); + } + + var storeObject = new _store(dataTitle); + + observable.setStoreObserver(storeObject, registerCallback, defaultStateObj); + + return storeObject; +}; + +var makeActionCreators = function makeActionCreators(vectors) { + function _action() { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + _extras.Action.apply(this, args); + } + + var actionObject = new _action(observable.registerAction()); + + return observable.setActionVectors(actionObject, vectors); +}; + +var purgePersistentStorage = function purgePersistentStorage() { + + observable.purgePersistStore(); +}; + +var eachStore = function eachStore(callback) { + + return observable.eachStore(callback, function (stores, key) { + + this.push(stores[key]); + }, null); +}; + +var _hub = { + eachStore: eachStore +}; + +var attachMiddleware = function attachMiddleware(callback) { + + return observable.setMiddlewareCallback(callback); +}; + +var isAppStateAutoRehydrated = function isAppStateAutoRehydrated() { + + return observable.isAppStateAutoRehydrated(); +}; + +var onDispatch = function onDispatch(handler) { + + if (typeof handler === 'function') { + + observable.watchDispatcher(handler); + } +}; + +var configure = function configure(config) { + + return observable.mergeConfig(config, _hub); +}; + +var onShutdown = function onShutdown(handler) { + + if (typeof handler === "function") { + + observable.setupShutdownCallback(handler, _hub); + } +}; + +var requestAggregator = function requestAggregator() { + + return observable.makeAggregator(); +}; + +exports.Helpers = _helpers2.default; +exports.Payload = _primitiveCheckers2.default; +exports.makeStore = makeStore; +exports.makeActionCreators = makeActionCreators; +exports.purgePersistentStorage = purgePersistentStorage; +exports.isAppStateAutoRehydrated = isAppStateAutoRehydrated; +exports.requestAggregator = requestAggregator; +exports.configure = configure; +exports.eachStore = eachStore; +exports.attachMiddleware = attachMiddleware; +exports.onDispatch = onDispatch; +exports.onShutdown = onShutdown; +exports.toString = toString; + +/***/ }), + +/***/ "./src/es/utils/helpers.js": +/*!*********************************!*\ + !*** ./src/es/utils/helpers.js ***! + \*********************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Helpers = undefined; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +var _basics = __webpack_require__(/*! ./routines/basics.js */ "./src/es/utils/routines/basics.js"); + +var Helpers = exports.Helpers = { + isEqual: function isEqual(former, latter) { + if (former === latter) { + return true; + } + + if ((typeof former === 'undefined' ? 'undefined' : _typeof(former)) !== 'object' || former === null || (typeof latter === 'undefined' ? 'undefined' : _typeof(latter)) !== 'object' || latter === null) { + return false; + } + + var keysA = _basics.wind.Object.keys(former); + var keysB = _basics.wind.Object.keys(latter); + + if (keysA.length !== keysB.length) { + return false; + } + + // Test for A's keys different from B. + var bHasOwnProperty = _basics.wind.hasOwnProperty.bind(latter); + for (var i = 0; i < keysA.length; i++) { + if (!bHasOwnProperty(keysA[i]) || former[keysA[i]] !== latter[keysA[i]]) { + return false; + } + } + } +}; + +/***/ }), + +/***/ "./src/es/utils/primitive-checkers.js": +/*!********************************************!*\ + !*** ./src/es/utils/primitive-checkers.js ***! + \********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Payload = undefined; + +var _basics = __webpack_require__(/*! ./routines/basics.js */ "./src/es/utils/routines/basics.js"); + +var Payload = exports.Payload = { + type: { + "array": "array", + "date": "date", + "string": "string", + "regexp": "regexp", + "boolean": "boolean", + "function": "function", + "object": "object", + "number": "number", + error: function error(value) { + + return value instanceof _basics.wind.Error || value instanceof _basics.wind.TypeError; + }, + nullable: function nullable(value) { + + return value === null || value === undefined; + }, + + "numeric": { + Int: function Int(value) { + return _basics.wind.isFinite(value) && value === _basics.wind.parseInt(value); + }, + Float: function Float(value) { + return _basics.wind.isFinite(value) && value === _basics.wind.parseFloat(value); + } + }, + any: function any(value) { + + return value !== null || value !== undefined; + } + } +}; + +/***/ }), + +/***/ "./src/es/utils/routines/basics.js": +/*!*****************************************!*\ + !*** ./src/es/utils/routines/basics.js ***! + \*****************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(process, global) { + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +var wind = 'undefined' !== typeof process && '[object process]' === {}.toString.call(process) || 'undefined' !== typeof navigator && navigator.product === 'ReactNative' ? global : typeof window !== "undefined" ? window : self; + +var Hop = {}.hasOwnProperty; + +var Slc = [].slice; + +var isNullOrUndefined = function isNullOrUndefined(obj) { + return obj == void 0; +}; + +var each = function each(obj, iterator, context) { + + if (context === undefined) { + + context = null; + } + + for (var prop in obj) { + if (Hop.call(obj, prop)) { + iterator.call(context, obj[prop], prop, obj); + } + } +}; + +/** + * + * @params + * @params + * @return + */ + +var extend = function extend(source, dest) { + + var merge = {}; + + for (var prop in dest) { + if (Hop.call(dest, prop)) { + + if (_typeof(dest[prop]) === "object" && dest[prop] !== null) { + merge[prop] = extend(source[prop], dest[prop]); + } else if (source && Hop.call(source, prop)) { + merge[prop] = source[prop]; + } else { + merge[prop] = dest[prop]; + } + } + } + + return merge; +}; + +var curry = function curry(func, args, context) { + return function () { + var _args = Slc.call(arguments); + return func.apply(context, args.concat(_args)); + }; +}; + +var futuresStates = { + STARTED: 0, + AWAIT: 1, + RESOLVED: 2, + REJECTED: 3 +}; + +var formatOptions = function formatOptions(opts) { + var options = {}, + _opts = String(opts).split(","); + each(_opts, function (key) { + options[key] = true; + }); + options.savedData = !1; + return options; +}; + +var Routines = function Routines(opts) { + var options = formatOptions(opts); + var fireStart = void 0; + var fireEnd = void 0; + var index = void 0; + var fired = void 0; + var firing = void 0; + var pending = []; + var queue = options.multiple && []; + + var fire = function fire(data) { + options.savedData = !fire.$decline && options.save && data; // save it only when we are not rejecting {fire.$decline != true}! + fired = true; + firing = true; // firing has begun! + index = fireStart || 0; + fireEnd = pending.length; + + for (fireStart = 0; index < fireEnd; index++) { + // @TODO: need to curry args instead of directly binding them #DONE + wind.setTimeout(curry(pending[index], data[1], data[0]) /*.bind(data[0], data[1])*/, 20); // fire asynchronously (Promises/A+ spec requirement) + } + + firing = false; // firing has ended! + + if (queue) { + // deal with the queue if it exists and has any contents... + if (queue.length) { + return fire(queue.shift()); // fire on the {queue} items recursively + } + // if queue is empty.... then end [flow of control] at this point! + } + + fire.$decline = false; + + if (options.savedData) { + if (options.unpack) { + // clear our {pending} list and free up some memeory!! + pending.length = 0; // saves the reference {pending} and does not replace it! + } + } + }; + + return { + add: function add() { + var len = 0; + if (pending) { + // if not disbaled + + var start = pending.length; + (function add(args) { + + each(args, function (arg) { + var type = typeof arg === 'undefined' ? 'undefined' : _typeof(arg); + + if (type == "function") { + len = pending.push(arg); + } else { + if (!!arg && arg.length && typeof arg != "string") { + // inspect recursively + add(Slc.call(arg)); + } + } + }); + })(Slc.call(arguments)); + + if (fired) { + // if we have already run the {pending} list of routines at least once, ... + if (options.join) { + fireStart = start; + fireEnd = len; // update info again... + fire.$decline = true; + fire(options.savedData); // fire with the saved data + this.disable(); + } + } + } + return len; + }, + hasFn: function hasFn(fn) { + var result = false; + each(pending, function (val) { + if (typeof fn === "function" && fn === val) result = true; + }, this); + return result; + }, + hasList: function hasList() { + return !!pending; // [false] only when the disabled(); method has been called!! + }, + fireWith: function fireWith() /* context, args */{ + if (pending && (!fired || queue)) { + var args = arguments.length && Slc.call(arguments) || [null, 0]; + + if (firing) { + // we are currently iterating on the {pending} list of routines + queue.push(args); // queue assets for recursive firing within {fire} function later + } else { + fire(args); + } + } + }, + disable: function disable() { + if (!options.savedData) { + pending = queue = undefined; + } + } + }; +}; + +// Futures constructor - Promises/A+ Spec Implementation (Influenced by jQuery though...) + +var Futures = function Futures() { + + var defTracks = { + resolve: ['done', 'RESOLVED', Routines(['join', 'save'])], + reject: ['fail', 'REJECTED', Routines(['join', 'save'])], + notify: ['progress', 'AWAIT', Routines(['join', 'multiple'])] + }; + + var self = this; + var keys = Object.keys(defTracks); + + var setter = function setter(fnName, arr, forPromise) { + var drop = fnName != "notify"; + if (!arr.length && !forPromise) return defTracks[fnName][2].fireWith; + return !forPromise ? function () { + if (self.state >= 0 && self.state <= 1) { + self.state = futuresStates[defTracks[fnName][1]]; + } + + defTracks[fnName][2].fireWith(self === this ? self : this, [].slice.call(arguments)); + + if (drop) { + defTracks[arr[0]][2].disable(); + defTracks[arr[1]][2].disable(); + switch (fnName) { + case "reject": + case "resolve": + self.state = futuresStates[defTracks[fnName][1]]; + break; + } + } + return true; + } : function () { + if (self.state >= 0 && self.state <= 1) { + defTracks[fnName][2].add.apply(self, Slc.call(arguments)); + } + return self; + }; + }; + + var i = 0; + var ax = keys.slice(); + var d = void 0; + var promise = {}; + + // using a closure to define all the functions on the fly... + + for (d in defTracks) { + if (Hop.call(defTracks, d)) { + keys.splice(i++, 1); + self[d] = setter(d, keys); + self[d + 'With'] = setter(d, []); + promise[defTracks[d][0]] = setter(d, [], true); + keys = ax.slice(); + } + } + + promise.state = futuresStates.STARTED; + + promise.always = function () { + return this.done.apply(self, arguments).fail.apply(self, arguments); + }; + + promise.promise = function (obj) { + if (obj && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) == "object" && !obj.length) { + for (var _i in promise) { + if (Hop.call(promise, _i)) { + obj[_i] = promise[_i]; + } + } + return obj; + } + return promise; + }; + + promise.then = function () /* fnDone, fnFail, fnProgress */{ + var ret = void 0; + var args = [].slice.call(arguments); + args.forEach(function (item, i) { + item = typeof item == "function" && item; + self[defTracks[keys[i]][0]](function () { + var rt = void 0; + try { + /* + Promises/A+ specifies that errors should be contained + and returned as value of rejected promise + */ + rt = item && item.apply(this, arguments); + } catch (e) { + rt = this.reject(e); + } finally { + if (rt && typeof rt.promise == "function") ret = rt.promise(); + } + }); + }); + return self.promise(ret); + }; + + promise.isResolved = function () { + return !defTracks['reject'][2].hasList(); + }; + promise.isRejected = function () { + return !defTracks['resolve'][2].hasList(); + }; + promise.pipe = promise.then; + + promise.promise(self); + + Futures.STARTED = futuresStates.STARTED; + Futures.AWAITING = futuresStates.AWAIT; + Futures.RESOLVED = futuresStates.RESOLVED; + Futures.REJECTED = futuresStates.REJECTED; + + /* avoid leaking memory with each call to Futures constructor!! */ + setter = ax = d = i = null; + + /* enforce {new} on constructor */ + return self instanceof Futures ? self : new Futures(); +}; + +exports.Hop = Hop; +exports.Slc = Slc; +exports.isNullOrUndefined = isNullOrUndefined; +exports.wind = wind; +exports.each = each; +exports.extend = extend; +exports.curry = curry; +exports.Futures = Futures; +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../../node_modules/process/browser.js */ "./node_modules/process/browser.js"), __webpack_require__(/*! ./../../../../node_modules/webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"))) + +/***/ }), + +/***/ "./src/es/utils/routines/extras.js": +/*!*****************************************!*\ + !*** ./src/es/utils/routines/extras.js ***! + \*****************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.$createTearDownCallback = exports.$createBeforeTearDownCallback = exports.Action = exports.Store = exports.Values = undefined; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +var _basics = __webpack_require__(/*! ./basics.js */ "./src/es/utils/routines/basics.js"); + +var __beforeunload = _basics.wind.onbeforeunload; + +var __unload = _basics.wind.onunload; + +var __hasDeactivated = false; + +var _checkAndKillEventPropagation = function _checkAndKillEventPropagation(event) { + if (event.type === 'click') { + if (event.stopPropagation) { + event.stopPropagation(); + } else { + event.cancelBubble = true; + } + } +}; + +var $createBeforeTearDownCallback = function $createBeforeTearDownCallback(config) { + return function (e) { + + // @See: https://greatgonzo.net/i-know-what-you-did-on-beforeunload/ + + /* + `lastActivatedNode` variable is used to track the DOM Node that last + had focus (or was clicked) just before the browser triggered the `beforeunload` event + */ + + var lastActivatedNode = _basics.wind.currentFocusElement // Mobile Browsers [ Custom Property ] + || e.explicitOriginalTarget // old/new Firefox + || e.srcDocument && e.srcDocument.activeElement // old Chrome/Safari + || e.currentTarget && e.currentTarget.document.activeElement // Sarafi/Chrome/Opera/IE + || e.srcElement || e.target; + + // if the "imaginary" user is logging out + var leaveMessage = "Are you sure you want to leave this page ?"; + + var isLogoff = typeof lastActivatedNode.hasAttribute == 'function' && lastActivatedNode.hasAttribute('data-href') && lastActivatedNode.getAttribute('data-href').includes(config.runtime.shutDownHref) || 'href' in lastActivatedNode && lastActivatedNode.href.includes(config.runtime.shutDownHref); + + var __timeOutCallback = function __timeOutCallback() { + + __hasDeactivated = __timeOutCallback.lock; + }; + + // console.log('Node: '+ lastActivatedNode); + + __timeOutCallback.lock = __hasDeactivated = true; + beforeUnloadTimer = _basics.wind.setTimeout(__timeOutCallback, 0); + + if (isLogoff) { + // IE/Firefox/Chrome 34+ + if (!!~e.type.indexOf('beforeunload')) { + e.returnValue = leaveMessage; + } else { + _confirm = _basics.wind.confirm && _basics.wind.confirm(leaveMessage); + + if (!_confirm) { + _checkAndKillEventPropagation(e); + } + } + } else { + _checkAndKillEventPropagation(e); + } + + /* if (isLogoff) isn't true, no beforeunload dialog is shown */ + return isLogoff ? (__timeOutCallback.lock = false) || leaveMessage : _basics.wind.clearTimeout(beforeUnloadTimer); + }; +}; + +var $createTearDownCallback = function $createTearDownCallback(hub) { + return function (e) { + + /* + This seems to be the best way to setup the `unload` event + listener to ensure that the load event is always fired even if the page + is loaded from the `bfcache` (Back-Forward-Cache) of the browser whenever + the back and/or forward buttons are used for navigation instead of links. + Registering it as a property of the `window` object sure works every time + */ + + if (!__hasDeactivated) { + + _basics.wind.setTimeout(function () { + + var appstate = {}; + + hub.eachStore(function (store, next) { + + var title = store.getTitle(); + + appstate[title] = store.getState(); + + store.disconnect(); + store.destroy(); + + next(); + }); + + if (typeof hub._ping == "function") { + + hub._ping.call(hub, appstate); + } + + if (e.type != 'click') { + __unload(e); + } + }, 0); + } + }; +}; + +var Values = { + typesMap: { + "number": Number, + "array": Array, + "object": Object, + "string": String, + "boolean": Boolean, + "date": Date, + "regexp": RegExp, + "function": Function + }, + isOfType: function isOfType(type, value) { + + var type = type.toLowerCase(); // hoisting + + if (typeof type === 'function') { + + return type(value); + } else if (typeof type === 'string' && type in this.typesMap) { + return (/^string|function$/.test(typeof value === 'undefined' ? 'undefined' : _typeof(value)) || Object(value) instanceof this.typesMap[type] + ); + } + + return false; + } +}; + +// Store Constructor +var Store = function () { + + var requirementTypes = ['graph-ql', 'rest']; + + var serviceRequirementsMap = {}; + + return function (title) { + + var that = this; + + this.getTitle = function () { + return title; + }; + + this.toJSON = function () { + return { + title: title + }; + }; + + this.makeTrait = function (callback) { + + if (typeof callback === 'function') { + for (var _len = arguments.length, argsLeft = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + argsLeft[_key - 1] = arguments[_key]; + } + + argsLeft.unshift(that); + + return callback.apply(undefined, argsLeft); + } + + return null; + }; + + this.toString = function () { + return "[object RadixxStore]"; + }; + }; +}(); + +// Action constructor +var Action = function () { + return function (id) { + + this.getId = function () { + return id; + }; + + this.toJSON = function () { + return { + id: id + }; + }; + + this.toString = function () { + return "[object RadixxActionCreator]"; + }; + }; +}(); + +exports.Values = Values; +exports.Store = Store; +exports.Action = Action; +exports.$createBeforeTearDownCallback = $createBeforeTearDownCallback; +exports.$createTearDownCallback = $createTearDownCallback; + +/***/ }) + +/******/ }); +//# sourceMappingURL=radixx.es2015.js.map \ No newline at end of file diff --git a/dist/radixx.es2015.js.map b/dist/radixx.es2015.js.map new file mode 100644 index 0000000..073f11c --- /dev/null +++ b/dist/radixx.es2015.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./node_modules/process/browser.js","webpack:///(webpack)/buildin/global.js","webpack:///./src/es/components/dispatcher.js","webpack:///./src/es/components/observable.js","webpack:///./src/es/index.js","webpack:///./src/es/utils/helpers.js","webpack:///./src/es/utils/primitive-checkers.js","webpack:///./src/es/utils/routines/basics.js","webpack:///./src/es/utils/routines/extras.js"],"names":["ce","wind","CustomEvent","e","CEvent","prototype","Object","create","w","Event","persistStore","top","localStorage","sessStore","sessionStorage","opera","Hop","call","scriptStorage","mode","document","documentMode","autoRehydrationOccured","config","watchers","stores","storeKeys","observers","_promises","waitQueue","cachedStorageKeys","getAppOriginForPersist","String","location","origin","cfg","localHostDev","documentElement","id","generateTag","_cdata","getItem","getNormalized","Math","random","replace","substring","defaultConfig","runtime","spaMode","shutDownHref","persistenceEnabled","autoRehydrate","universalCoverage","triggerEvt","target","eType","detail","globale","evt","cancelable","bubbles","dispatch","cancelBubble","setCapture","apply","operationOnStoreSignal","fn","queueing","area","action","$$history","length","$$initData","slice","$$historyIndex","newStoreState","len","_key","actionData","coverageNotifier","$$historyLocation","get","undefined","TypeError","put","$$currentStoreTitle","source","url","href","key","newValue","aspect","actionKey","type","actionType","$$withAction","push","unshift","val","JSON","parse","setNormalized","stringify","getCurrentActionOnStack","actionStack","$$redoActionsStack","lenth","currentAction","_tag","$$tag","arguments","callee","setItem","state","appState","title","historyLoc","fireWatchers","omitCallback","pos","watcher","$$canOmit","setAppState","isolatedState","storeTitle","Area","getAppState","appStateData","indexStart","indexEnd","values","_data","i","name","indexOf","split","handlePromises","promise","isResolved","resolve","enforceCoverage","_origin","$$origin","_action","_state","_title","_hloc","_composedData","observer","parseInt","setTimeout","bind","stateWatcher","event","includes","listeners","$$store_listeners","t","params","d","createEvent","initCustomEvent","createEventObject","returnValue","setupConfigSettings","hub","onDispatch","data","updateAutoRehydrationState","onbeforeunload","onunload","addEventListener","attachEvent","isIE8Storage","begin","value","commit","del","removeItem","Dispatcher","middlewares","$$undoActionsStack","middleware","Error","userConfig","defaultStoreContainer","callback","store","getTitle","splice","hydrateAction","stateArea","regFunc","historyIndex","mutationType","getRegistration","canUndo","canRedo","actionsStack","index","compactedFunc","baseDispatcher","dispatcher","prevState","boundBaseDispatcher","adjoiner","createDispatchResolver","_hasMiddleware","hasMiddleware","dispatchRegistry","concat","reduceRight","bound","$instance","getInstance","getObjectPrototype","getPrototypeOf","obj","__proto__","constructor","eachStore","extractor","storeArray","each","callable","prevIndex","next","returnVal","Boolean","setActionVectors","object","vectors","_proto","vector","creator","createActionInterface","createStoreInterface","method","argument","setStoreListener","unsetStoreListener","unregister","signalUnique","register","handleStoreMutation","stateAspectKey","getId","typesBitMask","actionTypes","actionDefinition","Array","definition","Number","Values","isOfType","signal","watchDispatcher","watch","isAppStateAutoRehydrated","getAutoRehydrationState","setupShutdownCallback","_ping","mergeConfig","initCatchers","purgePersistStore","deletePersistenceTagAndData","registerAction","regId","toString","substr","makeAggregator","notifyAllStores","setMiddlewareCallback","middlewareFunc","getMiddleware","ex","setMiddleware","setStoreObserver","defaultStateObj","methods","c","observable","makeStore","dataTitle","registerCallback","_store","args","Store","storeObject","makeActionCreators","Action","actionObject","purgePersistentStorage","_hub","attachMiddleware","handler","configure","onShutdown","requestAggregator","Helpers","Payload","isEqual","former","latter","keysA","keys","keysB","bHasOwnProperty","hasOwnProperty","error","nullable","Int","isFinite","Float","parseFloat","any","process","navigator","product","global","window","self","Slc","isNullOrUndefined","iterator","context","prop","extend","dest","merge","curry","func","_args","futuresStates","STARTED","AWAIT","RESOLVED","REJECTED","formatOptions","options","_opts","opts","savedData","Routines","fireStart","fireEnd","fired","firing","pending","queue","multiple","fire","$decline","save","shift","unpack","add","start","arg","join","disable","hasFn","result","hasList","fireWith","Futures","defTracks","reject","notify","setter","fnName","arr","forPromise","drop","ax","always","done","fail","then","ret","forEach","item","rt","isRejected","pipe","AWAITING","__beforeunload","__unload","__hasDeactivated","_checkAndKillEventPropagation","stopPropagation","$createBeforeTearDownCallback","lastActivatedNode","currentFocusElement","explicitOriginalTarget","srcDocument","activeElement","currentTarget","srcElement","leaveMessage","isLogoff","hasAttribute","getAttribute","__timeOutCallback","lock","beforeUnloadTimer","_confirm","confirm","clearTimeout","$createTearDownCallback","appstate","getState","disconnect","destroy","typesMap","Date","RegExp","Function","toLowerCase","test","requirementTypes","serviceRequirementsMap","that","toJSON","makeTrait","argsLeft"],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,kDAA0C,gCAAgC;AAC1E;AACA;;AAEA;AACA;AACA;AACA,gEAAwD,kBAAkB;AAC1E;AACA,yDAAiD,cAAc;AAC/D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iDAAyC,iCAAiC;AAC1E,wHAAgH,mBAAmB,EAAE;AACrI;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;;AAGA;AACA;;;;;;;;;;;;AClFA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;;;;AAIA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;A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;AACjBlY;AADiB,aAAP;AAAA,SAAd;;AAIA,aAAKuO,QAAL,GAAgB;AAAA,mBAAM,8BAAN;AAAA,SAAhB;AACH,KATiB;AAAA,CAAD,EAAjB;;QAYSf,M,GAAAA,M;QAAQkC,K,GAAAA,K;QAAOG,M,GAAAA,M;QAAQqG,6B,GAAAA,6B;QAA+BkB,uB,GAAAA,uB","file":"radixx.es2015.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/es/index.js\");\n","// shim for using process in browser\nvar process = module.exports = {};\n\n// cached from whatever global is present so that test runners that stub it\n// don't break things. But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals. It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\nfunction defaultSetTimout() {\n throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n throw new Error('clearTimeout has not been defined');\n}\n(function () {\n try {\n if (typeof setTimeout === 'function') {\n cachedSetTimeout = setTimeout;\n } else {\n cachedSetTimeout = defaultSetTimout;\n }\n } catch (e) {\n cachedSetTimeout = defaultSetTimout;\n }\n try {\n if (typeof clearTimeout === 'function') {\n cachedClearTimeout = clearTimeout;\n } else {\n cachedClearTimeout = defaultClearTimeout;\n }\n } catch (e) {\n cachedClearTimeout = defaultClearTimeout;\n }\n} ())\nfunction runTimeout(fun) {\n if (cachedSetTimeout === setTimeout) {\n //normal enviroments in sane situations\n return setTimeout(fun, 0);\n }\n // if setTimeout wasn't available but was latter defined\n if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n cachedSetTimeout = setTimeout;\n return setTimeout(fun, 0);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedSetTimeout(fun, 0);\n } catch(e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedSetTimeout.call(null, fun, 0);\n } catch(e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error\n return cachedSetTimeout.call(this, fun, 0);\n }\n }\n\n\n}\nfunction runClearTimeout(marker) {\n if (cachedClearTimeout === clearTimeout) {\n //normal enviroments in sane situations\n return clearTimeout(marker);\n }\n // if clearTimeout wasn't available but was latter defined\n if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n cachedClearTimeout = clearTimeout;\n return clearTimeout(marker);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedClearTimeout(marker);\n } catch (e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedClearTimeout.call(null, marker);\n } catch (e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.\n // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n return cachedClearTimeout.call(this, marker);\n }\n }\n\n\n\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n if (!draining || !currentQueue) {\n return;\n }\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = runTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n runClearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n runTimeout(drainQueue);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\nprocess.prependListener = noop;\nprocess.prependOnceListener = noop;\n\nprocess.listeners = function (name) { return [] }\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n","var g;\r\n\r\n// This works in non-strict mode\r\ng = (function() {\r\n\treturn this;\r\n})();\r\n\r\ntry {\r\n\t// This works if eval is allowed (see CSP)\r\n\tg = g || Function(\"return this\")() || (1, eval)(\"this\");\r\n} catch (e) {\r\n\t// This works if the window reference is available\r\n\tif (typeof window === \"object\") g = window;\r\n}\r\n\r\n// g can still be undefined, but nothing to do about it...\r\n// We return undefined, instead of nothing here, so it's\r\n// easier to handle this case. if(!global) { ...}\r\n\r\nmodule.exports = g;\r\n","import { wind, Hop, Futures, isNullOrUndefined, each, extend } from '../utils/routines/basics.js';\r\nimport { $createBeforeTearDownCallback, $createTearDownCallback } from '../utils/routines/extras.js';\r\n\r\n \r\ntry {\r\n const ce = new wind.CustomEvent('test');\r\n} catch(e) {\r\n\r\n CEvent.prototype = wind.Object.create(((w.Event && w.Event.prototype) || {}));\r\n wind.CustomEvent = null;\r\n wind.CustomEvent = CEvent;\r\n}\r\n\r\nconst persistStore = (wind.top !== wind || !wind.localStorage) ? null : wind.localStorage;\r\n\r\nconst sessStore = (wind.top !== wind || !wind.sessionStorage ? (wind.opera && !(Hop.call(wind, 'opera')) ? wind.opera.scriptStorage : {} ) : wind.sessionStorage);\r\n\r\nconst mode = wind.document.documentMode || 0;\r\n\r\nlet autoRehydrationOccured = false;\r\n\r\nlet config = null;\r\n\r\n const watchers = [\r\n\r\n];\r\n\r\n const stores = {\r\n\r\n};\r\n\r\n const storeKeys = [\r\n\r\n];\r\n\r\n const observers = {\r\n\r\n};\r\n\r\n const _promises = {\r\n\r\n};\r\n\r\n const waitQueue = [\r\n\r\n];\r\n\r\n const cachedStorageKeys = {\r\n\r\n};\r\n\r\nconst getAppOriginForPersist = cfg => String(wind.location.origin + (cfg.localHostDev ? ':'+wind.document.documentElement.id : ''));\r\n\r\nconst generateTag = origin => {\r\n\r\n\tconst _cdata = persistStore.getItem(origin);\r\n\t\r\n\tif(!isNullOrUndefined(_cdata)){\r\n\r\n\t\treturn getNormalized(_cdata);\r\n\t}\r\n\r\n\treturn String(Math.random()).replace('.','x_').substring(0, 11);\r\n};\r\n\r\nconst defaultConfig = {\r\n\t\truntime:{\r\n\t\t\tspaMode:true, \r\n\t\t\tshutDownHref:''\r\n\t\t},\r\n\t\tpersistenceEnabled:false,\r\n\t\tautoRehydrate:false,\r\n\t\tuniversalCoverage:false,\r\n\t\tlocalHostDev:false\r\n};\r\n\r\nconst triggerEvt = (target, eType, detail, globale) => {\r\n const evt = new CustomEvent(eType, {\r\n detail,\r\n cancelable:true,\r\n bubbles:false\r\n }); // a stub function - just in case\r\n\r\n let dispatch = () => false;\r\n\r\n if((!('target' in evt)) \r\n && evt.cancelBubble === true){\r\n\r\n target.setCapture(true);\r\n }\r\n\r\n // set up cross-browser dispatch method.\r\n dispatch = target[ (!('target' in evt) ? \"fireEvent\" : \"dispatchEvent\") ];\r\n\r\n // Including support for IE 8 here ;)\r\n return dispatch.apply(target, (!('target' in evt) ? [`on${eType}`, evt ] : [ evt ]));\r\n};\r\n\r\nconst operationOnStoreSignal = (fn, queueing, area, action) => { \r\n\r\n\t // first, retrieve the very first state data and cache it\r\n\t if(fn.$$history.length == 1 \r\n\t\t&& (!fn.$$initData)){\r\n\r\n\t \t\tfn.$$initData = fn.$$history[0];\r\n\t }\t\t\r\n\r\n\t // second, make sure that there is no future state to forth on\t\r\n\t fn.$$history = fn.$$history.slice(0, fn.$$historyIndex + 1);\r\n\t \r\n\t // lets setup a place to store new state, also mark out the context of this call\r\n\t let newStoreState = false, len, _key;\r\n\r\n\t // create a new state of the store data by applying a given\r\n\t // store callback function to the current history head\r\n\r\n\t if(queueing === null){\r\n\r\n\t \tif(action !== null){\r\n\r\n\t\t \tnewStoreState = action.actionData;\r\n\r\n\t\t }else{\r\n\r\n\t\t \tnewStoreState = fn.$$history[fn.$$historyIndex];\r\n\t\t }\r\n\r\n\t\t coverageNotifier.$$historyLocation = fn.$$historyIndex;\r\n\r\n\t }else{\r\n\t \t\r\n\t \tnewStoreState = fn.call(queueing, action, area.get());\r\n\r\n\t \tcoverageNotifier.$$historyLocation = null;\r\n\r\n\t }\r\n\r\n\t\tif(typeof newStoreState == 'boolean'\r\n\t\t\t|| newStoreState == undefined){\r\n\t\t\t\r\n\t\t\tthrow new TypeError(\"Radixx: Application State unavailable after signal to Dispatcher\");\t\t\r\n\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t_key = area.put(newStoreState);\r\n\r\n\t\tcoverageNotifier.$$currentStoreTitle = _key;\r\n\t \r\n\t if(action !== null){\r\n\r\n\t \tif(action.source !== 'hydrate'){\r\n \t\t\t\t;\r\n\t \t}\r\n\r\n\t \ttriggerEvt(\r\n\t\t\t\t\twind.document, \r\n\t\t\t\t\t'storesignal', \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\turl:wind.location.href,\r\n\t\t\t\t\t\tkey:_key,\r\n\t\t\t\t\t\tnewValue:newStoreState,\r\n\t\t\t\t\t\tsource:wind,\r\n\t\t\t\t\t\taspect:action.actionKey,\r\n\t\t\t\t\t\ttype:action.actionType\r\n\t\t\t\t\t}, \r\n\t\t\t\t\twind\r\n\t\t\t);\r\n\r\n\t \tcoverageNotifier.$$withAction = true;\r\n\r\n\t\t // add the new state to the history list and increment\r\n\t\t // the index to match in place\r\n\t\t len = fn.$$history.push(newStoreState); /* @TODO: use {action.actionType} as operation Annotation */\r\n\t\t \r\n\t\t fn.$$historyIndex++;\r\n\r\n\t\t if(fn.$$history.length > 21){ // can't undo/redo (either way) more than 21 moves at any time\r\n\r\n\t\t \t\tfn.$$history.unshift();\r\n\t\t }\r\n\r\n\t }else{\r\n\r\n\t \treturn newStoreState;\r\n \t}\r\n\t \r\n\t};\r\n\r\n const getNormalized = val => {\r\n\r\n\t \tif(isNullOrUndefined(val) || val === \"null\")\r\n\t \t\t return null;\r\n\r\n\t\ttry{\r\n\t\t\treturn JSON.parse(val);\r\n\t\t}catch(e){\r\n\t\t\treturn String(val);\r\n\t\t}\r\n\t};\r\n\r\n const setNormalized = val => {\r\n\r\n\t \tif(isNullOrUndefined(val)) \r\n\t \t\tval = null;\r\n\r\n\t\ttry{\r\n\t\t\treturn JSON.stringify(val);\r\n\t\t}catch(e){\r\n\r\n\t\t\treturn String(val);\r\n\t\t}\r\n\t};\r\n\r\n\tconst getCurrentActionOnStack = () => {\r\n\r\n\t\tconst actionStack = operationOnStoreSignal.$$redoActionsStack;\r\n\r\n\t\tif(actionStack.lenth){\r\n\t\t\treturn actionStack[actionStack.length - 1];\r\n\t\t}\r\n\r\n\t\treturn null;\r\n\t};\r\n\r\n const coverageNotifier = appState => {\r\n\t \r\n let currentAction = null;\r\n\t \r\n const _tag = coverageNotifier.$$tag;\r\n\r\n if(arguments.callee.$$withAction === true){\r\n\t\t\tcurrentAction = getCurrentActionOnStack();\r\n\t\t\targuments.callee.$$withAction = null;\r\n\t\t}\r\n\r\n if(!isNullOrUndefined(_tag)\r\n\t\t\t&& (persistStore !== null)){\r\n\r\n\t\t\tpersistStore.setItem(_tag, setNormalized({\r\n\t\t\t\t\t\tstate:appState, \r\n\t\t\t\t\t\taction:currentAction,\r\n\t\t\t\t\t\ttitle:arguments.callee.$$currentStoreTitle, \r\n\t\t\t\t\t\thistoryLoc:arguments.callee.$$historyLocation\r\n\t\t\t}));\r\n\r\n\t\t\targuments.callee.$$historyLocation = null;\r\n\t\t}\r\n };\r\n\r\n const fireWatchers = (state, omitCallback) => {\r\n\r\n\t\tlet pos, watcher;\r\n\r\n\t\tfor(pos in watchers){\r\n\t\t\tif(Hop.call(watchers, pos)){\r\n\t\t\t\twatcher = watchers[pos];\r\n\t\t\t\tif(omitCallback){\r\n\t\t\t\t\tif(watcher.$$canOmit){\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t};\r\n\t\t\t\t}\r\n\t\t\t\twatcher.call(null, state);\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\r\n\tconst setAppState = appState => {\r\n\r\n\t\t\teach(appState, (isolatedState, storeTitle) => {\r\n\r\n\t\t\t\tconst area = new Area(storeTitle);\r\n\r\n\t\t\t\tarea.put(isolatedState);\r\n\t\t\t\r\n\t\t\t});\r\n\r\n\t\t\tfireWatchers(appState, true);\r\n\t};\r\n\r\n const getAppState = () => {\r\n\r\n\t const appStateData = {};\r\n\t let key;\r\n\t let indexStart;\r\n\t let indexEnd;\r\n\t let values;\r\n\t let _data;\r\n\r\n\t if(('key' in sessStore) \r\n\t && (typeof sessStore.key == 'function')){\r\n\r\n\t // We iterate this way so we can support IE 8 + other browsers\r\n\t for(var i=0; i < sessStore.length; i++){\r\n\t key = sessStore.key(i);\r\n\t _data = sessStore.getItem(key);\r\n\t \r\n\t if(!_data){\r\n\t ;\r\n\t }\r\n\r\n\t appStateData[key] = getNormalized(_data) || null;\r\n\t }\r\n\t }else{\r\n\t \r\n\t \r\n\t for(var i = 0; i < storeKeys.length; i++){\r\n\t \r\n\t key = storeKeys[i];\r\n\t \r\n\t if(cachedStorageKeys[key]){\r\n\r\n\t indexStart = wind.name.indexOf(key);\r\n\r\n\t indexEnd = wind.name.indexOf('|', indexStart);\r\n\r\n\t values = (wind.name.substring(indexStart, indexEnd)).split(':=:') || [\"\", null];\r\n\r\n\t _data = values[1];\r\n\r\n\t }\r\n\r\n\t appStateData[key] = getNormalized(_data) || null;\r\n\t }\r\n\t }\r\n\r\n\t return appStateData;\r\n\t};\r\n\r\n\tconst handlePromises = () => {\r\n let promise = null;\r\n const state = getAppState();\r\n\r\n for(const title in _promises){\r\n\t\t\tif(Hop.call(_promises, title)){\r\n\t\t\t\tpromise = _promises[title];\r\n\t\t\t\tif(!promise.isResolved()){\r\n\t\t\t\t\tpromise.resolve();\r\n\t\t\t\t}\r\n\t\t\t\tdelete _promises[title];\r\n\t\t\t}\r\n\t\t}\r\n\r\n waitQueue.length = 0;\r\n\r\n fireWatchers(state);\r\n };\r\n\r\n\tconst enforceCoverage = e => {\r\n\r\n const _origin = arguments.callee.$$origin;\r\n const _tag = arguments.callee.$$tag;\r\n let _action = null;\r\n let _state = null;\r\n let _title = null;\r\n let _hloc = null;\r\n let _composedData = null;\r\n let observer = null;\r\n\r\n // Detecting IE 8 to apply mild hack on event object\r\n if(('remainingSpace' in sessStore)){\r\n\t\t\te.key = e.detail.key;\r\n\t\t}\r\n\r\n if(!persistStore\r\n\t\t\t|| _origin === e.key){ // if we can't find the key in the array `storeKeys`\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n _composedData = getNormalized(persistStore.getItem(_tag));\r\n\r\n if(_tag === e.key\r\n\t\t\t&& isNullOrUndefined(_composedData)){\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n _state = _composedData.state;\r\n\r\n _action = _composedData.action;\r\n\r\n _title = _composedData.title;\r\n\r\n _hloc = parseInt(_composedData.historyLoc);\r\n\r\n if(_action !== null){\r\n\t\t\toperationOnStoreSignal.$$redoActionsStack.push(_action);\r\n\t\t}\r\n\r\n if(_hloc !== null){\r\n\t\t\tobserver = observers[_title];\r\n\t\t\tif(observer){\r\n\t\t\t\tobserver.$$historyIndex = _hloc;\r\n\t\t\t\tif(_hloc === -1){\r\n\t\t\t\t\tobserver.$$history.length = 0;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n if(_state){\r\n\t\t\tsetTimeout(\r\n\t\t\t\tsetAppState.bind(null, _state)\r\n\t\t\t, 0); \r\n\t\t}\r\n };\r\n\r\n\tconst stateWatcher = e => {\r\n\r\n\t\te = e || wind.event;\r\n\r\n\t\tif(storeKeys.includes(e.detail.key)){\r\n const storeTitle = e.detail.key;\r\n let listeners;\r\n\r\n if(!isNullOrUndefined(observers[storeTitle])){\r\n\r\n\t\t\t\tlisteners = observers[storeTitle].$$store_listeners;\r\n\r\n\t\t\t\tfor(let t=0; t < listeners.length; t++){\r\n\t\t\t\t\t\t \t\t\t\r\n\t\t\t\t\tlisteners[t].call(stores[storeTitle], e.detail.type, e.detail.aspect);\r\n\t\t\t\t\t\t \r\n\t\t\t\t}\r\n\t\t\t}\r\n }\r\n\t};\r\n\r\n\t/**\r\n\t Though IE 9 to IE 11 supports the CustomEvent constructor, IE throws an error {Object doesn't support this action} \r\n\t whenever it's used. This weird behaviour is fixed below\r\n\t See: https://stackoverflow.com/questions/14358599/object-doesnt-support-this-action-ie9-with-customevent-initialization\r\n\t*/\r\n\r\n\tfunction CEvent ( event, params ) {\r\n\t let t;\r\n\t let evt;\r\n\t let d = wind.document;\r\n\t params = params || { bubbles: false, cancelable: false, detail: undefined };\r\n\t \r\n\t try{\r\n\t\t\t evt = d.createEvent( 'CustomEvent' );\r\n\t\t\t evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );\r\n\t\t\t}catch(e){\r\n\t\t\t evt = d.createEventObject(w.event);\r\n\t\t\t\t evt.cancelBubble = !params.bubbles;\r\n\t evt.returnValue = !params.cancelable;\r\n\t\t\t\t\r\n\t if(typeof params.detail === \"object\"){\r\n\t\t\t\t\t // set expando properties on event object\r\n\t\t\t\t\t\r\n\t /*for(t in params.detail){\r\n\t if((({}).hasOwnProperty.call(params.detail, t))){\r\n\t evt[t] = params.detail[t];\r\n\t }\r\n\t }*/\r\n\t\t\t\t\t evt.detail = params.detail;\r\n\t\t\t\t }\t\r\n\t\t\t}\r\n\t \r\n\t return evt;\r\n\t}\r\n\r\n\tfunction setupConfigSettings(config, hub){\r\n\r\n\t\t \tif(config.universalCoverage){\r\n\r\n\t\t \t\tconfig.persistenceEnabled = true;\r\n\t\t \t}\r\n\r\n\t\t \tif(config.persistenceEnabled){\r\n\r\n\t\t\t\t\t// prepare Origin \r\n\t\t\t\t\tconst _origin = getAppOriginForPersist(config);\r\n\r\n\t\t\t\t\tconst _tag = generateTag(_origin);\r\n\r\n\t\t\t\t\tpersistStore.setItem(_origin, _tag);\r\n\r\n\t\t\t\t\tenforceCoverage.$$origin = _origin;\r\n\r\n\t\t\t\t\tenforceCoverage.$$tag = _tag;\r\n\r\n\t\t\t\t\tcoverageNotifier.$$canOmit = true;\r\n\r\n\t\t\t\t\tcoverageNotifier.$$tag = _tag;\r\n\r\n\t\t\t\t\thub.onDispatch(coverageNotifier);\r\n\t\t\t}\r\n\r\n if(config.autoRehydrate === true){\r\n\t\t \r\n\t\t\t \tlet data = null;\r\n\t \r\n\t if(!isNullOrUndefined(enforceCoverage.$$tag) \r\n\t && persistStore){\r\n\t \tdata = getNormalized(persistStore.getItem(enforceCoverage.$$tag));\r\n\t\t\t \t}\r\n\t\t\t \r\n\t\t\t \tif(data instanceof Object \r\n\t && data.state){\r\n\t setAppState(data.state);\r\n\t this.updateAutoRehydrationState();\r\n \t}\r\n }\r\n\r\n\t\t\tif(!config.runtime.spaMode){\r\n\t\t\t\t\r\n\t\t\t\tif(typeof config.runtime.shutDownHref === 'string'\r\n\t\t\t\t\t&& config.runtime.shutDownHref.length != 0){\r\n\r\n\t\t\t\t\twind.onbeforeunload = $createBeforeTearDownCallback(config);\r\n\t\t\t\t\r\n\t\t\t\t\twind.onunload = $createTearDownCallback(hub);\r\n\t\t\t\t}\r\n\t\t\t}else{\r\n\r\n\t\t\t\tif(typeof config.runtime.shutDownHref === 'string'\r\n\t\t\t\t\t&& config.runtime.shutDownHref.length != 0){\r\n\r\n\t\t\t\t\tif(wind.addEventListener){\r\n\t\t\t\t\t\twind.document.documentElement.addEventListener('click', $createBeforeTearDownCallback(config), false);\r\n\t\t\t\t\t\twind.document.addEventListener('click', $createTearDownCallback(hub), false);\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\twind.document.documentElement.attachEvent('onclick', $createBeforeTearDownCallback(config));\r\n\t\t\t\t\t\twind.document.attachEvent('onclick', $createTearDownCallback(hub), false);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\r\n\t}\r\n\r\n\tconst Area = function(key){\r\n\r\n\t\t\tthis.put = value => {\r\n\t \r\n\t\t\t\t/* \r\n\t\t\t\t\tIn IE 8-9, writing to sessionStorage is done asynchronously (other browsers write synchronously)\r\n\t\t\t\t\twe need to fix this by using IE proprietary methods \r\n\t\t\t\t\tSee: https://www.nczonline.net/blog/2009/07/21/introduction-to-sessionstorage/ \r\n\t\t\t\t*/\r\n\r\n \t\tlet indexStart;\r\n\r\n \t\tlet indexEnd;\r\n\t\t\r\n \t\tconst isIE8Storage = ('remainingSpace' in sessStore) && (mode === 8);\r\n\r\n\t \t\t// Detecting IE 8 to enable forced sync\r\n\t\t\t\tif(isIE8Storage){\r\n\t\t\t\t\tif(typeof sessStore.begin == 'function'){\r\n\t\t\t\t\t\tsessStore.begin();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n \t\ttry{\r\n\r\n\t\t\t\t\tsessStore.setItem(key, setNormalized(value));\r\n\t\t\t\t\t\r\n\t\t\t\t}catch(e){\r\n\t\t\t\t\t\r\n\t\t\t\t\t/* This is a fallback to support Opera Mini 4.4+ on Mobile */\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(cachedStorageKeys[key]){\r\n\t\t\t\t\t\t// we're in overwrite mode, so clear `key` out and push in update (below)\r\n\t\t\t\t\t\tindexStart = wind.name.indexOf(key);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tindexEnd = wind.name.indexOf('|', indexStart);\r\n\r\n\t\t\t\t\t\twind.name = wind.name.replace(wind.name.substring(indexStart, indexEnd), '');\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif(wind.name === \"\"){\r\n\r\n\t\t\t\t\t\twind.name = `${key}:=:${setNormalized(value)}|`;\r\n\r\n\t\t\t\t\t}else{\r\n\r\n\t\t\t\t\t\twind.name += `${key}:=:${setNormalized(value)}|`;\r\n\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\tcachedStorageKeys[key] = 1;\r\n\t\t\t\t}\r\n\r\n \t\tif(isIE8Storage){\r\n\t\t\t\t\tif(typeof sessStore.commit == 'function'){\r\n\t\t\t\t\t\tsessStore.commit();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t return key;\r\n\t };\r\n\r\n\t\t\tthis.get = () => {\r\n\r\n\t\t\t\tlet indexStart, indexEnd, values;\r\n\t\t\t\t\r\n\t\t\t\t/* This is a fallback to support Opera Mini 4.4+ on Mobile */\r\n\t\t\t\t\r\n\t\t\t\ttry{\r\n\t\t\t\t\r\n\t\t\t\t\treturn getNormalized(sessStore.getItem(key)) || null;\r\n\t\t\t\t\t\r\n\t\t\t\t}catch(e){\r\n\t\t\t\t\r\n\t\t\t\t\tif(cachedStorageKeys[key]){\r\n\r\n\t\t\t\t\t\tindexStart = wind.name.indexOf(key);\r\n\r\n\t\t\t\t\t\tindexEnd = wind.name.indexOf('|', indexStart);\r\n\r\n\t\t\t\t\t\tvalues = (wind.name.substring(indexStart, indexEnd)).split(':=:') || [0, 0];\r\n\r\n\t\t\t\t\t\treturn getNormalized(values[1]) || null;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\treturn null;\r\n\t\t\t\t\t\r\n\t\t\t\t}\r\n\t\t\t};\r\n\r\n\t\t\tthis.del = () => {\r\n\r\n\t\t\t\t\tlet indexStart;\r\n\r\n\t\t\t\t\tlet indexEnd;\r\n\t\t\t\t\t/* This is a fallback to support Opera Mini 4.4+ on Mobile */\r\n\t\t\t\t\r\n\t\t\t\t\ttry{\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn sessStore.removeItem(key);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t}catch(e){\r\n\t\t\t\t\r\n\t\t\t\t\t\tif(cachedStorageKeys[key]){\r\n\r\n\t\t\t\t\t\t\t// we're in delete mode\r\n\t\t\t\t\t\t\tindexStart = wind.name.indexOf(key);\r\n\r\n\t\t\t\t\t\t\tindexEnd = wind.name.indexOf('|', indexStart);\r\n\r\n\t\t\t\t\t\t\twind.name = wind.name.replace(wind.name.substring(indexStart, indexEnd), '');\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tdelete cachedStorageKeys[key];\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t}\r\n\t\t\t};\r\n\r\n\t\t\treturn this;\r\n\t};\r\n\r\n\tclass Dispatcher {\r\n\r\n\t\tconstructor() {\r\n\r\n \tthis.middlewares = [];\r\n\r\n \toperationOnStoreSignal.$$undoActionsStack = [];\r\n\r\n \toperationOnStoreSignal.$$redoActionsStack = [];\r\n }\r\n\r\n updateAutoRehydrationState() {\r\n \r\n \tautoRehydrationOccured = true;\r\n }\r\n\r\n getAutoRehydrationState() {\r\n \r\n \treturn autoRehydrationOccured;\r\n }\r\n\r\n setMiddleware(middleware) {\r\n \r\n if(typeof middleware === 'function'\r\n /*&& (middleware.length >= 2)*/){\r\n\r\n return this.middlewares.push(middleware);\r\n }\r\n\r\n throw new Error(\"Radixx: Inavlid Middleware Callback - Must be a Function with Parameters ( >= 2 )\");\r\n\r\n }\r\n\r\n hasMiddleware() {\r\n \r\n return (this.middlewares.length > 0);\r\n\r\n }\r\n\r\n initCatchers(userConfig, hub) {\r\n\r\n \t\tif(isNullOrUndefined(config)){\r\n\r\n\t\t\t\t\tconfig = extend(userConfig, defaultConfig);\r\n\r\n\t\t\t\t\tsetupConfigSettings.apply(this, [config, hub]);\r\n \t\t}\r\n\r\n if(wind.document.addEventListener){\r\n /* IE 9+, W3C browsers all expect the 'storage' event to be bound to the window */\r\n if(config.universalCoverage){\r\n wind.addEventListener('storage', enforceCoverage, false);\r\n }\r\n\r\n wind.document.addEventListener('storesignal', stateWatcher, false);\r\n\r\n }else if(wind.document.attachEvent){\r\n /* IE 8 expects the 'storage' event handler to be bound to the document \r\n and not to the window */\r\n if(config.universalCoverage){\r\n wind.document.attachEvent('onstorage', enforceCoverage);\r\n }\r\n\r\n wind.document.attachEvent('onstoresignal', stateWatcher);\r\n }\r\n\r\n }\r\n\r\n getRegistration(title) {\r\n\r\n\t if(Hop.call(observers, title)){\r\n\t \r\n\t return observers[title];\r\n\t }\r\n\r\n\t return {};\r\n\t\t}\r\n\r\n\t\tregister(title, observer, defaultStoreContainer) {\r\n \r\n if(Hop.call(observers, title)){\r\n \r\n if('$$history' in observers[title]\r\n && typeof observer.$$history == 'undefined'){\r\n if(!stores[title]){ // If the store doesn't have any change listeners registered\r\n \r\n throw new Error(\"Radixx: Cannot Overwrite existing store registration\");\r\n \r\n return;\r\n }\r\n\r\n observer.$$history = observers[title].$$history;\r\n observer.$$historyIndex = observers[title].$$historyIndex;\r\n observer.$$store_listeners = observers[title].$$store_listeners;\r\n observers[title] = observer;\r\n }\r\n }else{\r\n\r\n observer.$$store_listeners = [];\r\n observer.$$history = [(\r\n !!defaultStoreContainer ? \r\n defaultStoreContainer :\r\n []\r\n )];\r\n observer.$$historyIndex = 0;\r\n observers[title] = observer;\r\n storeKeys.push(title);\r\n }\r\n \r\n return true;\r\n }\r\n\r\n watch(callback) {\r\n\r\n watchers.push(callback);\r\n }\r\n\r\n setStoreListener(store, callback) {\r\n\r\n \tconst title = store.getTitle();\r\n\r\n\t if(!isNullOrUndefined(observers[title])){\r\n\r\n\t if(typeof callback == \"function\"){\r\n\t stores[title] = store;\r\n\t observers[title].$$store_listeners.push(callback);\r\n\t }\r\n\t }\r\n }\r\n\r\n unsetStoreListener(store, callback) {\r\n\r\n\t const title = store.getTitle();\r\n\r\n\t if(!isNullOrUndefined(observers[title])){\r\n\t if(typeof callback == \"function\"){\r\n\r\n\t const pos = observers[title].$$store_listeners.indexOf(callback);\r\n\t observers[title].$$store_listeners.splice(pos, 1);\r\n\t }\r\n\t }\r\n\r\n }\r\n\r\n signalUnique(hydrateAction) {\r\n\r\n\t if(hydrateAction.source != 'hydrate'){\r\n\t return;\r\n\t }\r\n\r\n\t // Pass this on to the event queue [await]\r\n\t wind.setTimeout(handlePromises, 0);\r\n\r\n\t const stateArea = new Area(hydrateAction.target), regFunc = observers[hydrateAction.target];\r\n\r\n\t operationOnStoreSignal.$$redoActionsStack.length = 0;\r\n\r\n\t operationOnStoreSignal.$$redoActionsStack.push(hydrateAction);\r\n\r\n\t regFunc.$$history.length = 0; // clear out the store state since this is a hydrate call\r\n\r\n\t regFunc.historyIndex = -1;\r\n\r\n\t operationOnStoreSignal(...[\r\n\t\t\t\t\tregFunc, \r\n\t\t\t\t\tnull, \r\n\t\t\t\t\tstateArea,\r\n\t\t\t\t\thydrateAction\r\n\t\t\t\t]);\r\n\r\n }\r\n\r\n handleStoreMutation(store, mutationType) {\r\n\r\n\t if(!mutationType){\r\n\t return;\r\n\t }\r\n\r\n\t const storeTitle = store.getTitle();\r\n\t const isolatedState = {}; \r\n\t const regFunc = this.getRegistration(storeTitle);\r\n\t const stateArea = new Area(storeTitle);\r\n\r\n\t switch(mutationType){\r\n\r\n\t case 'undo':\r\n\t if(store.canUndo()){\r\n\t \r\n\t --regFunc.$$historyIndex;\r\n\r\n\t isolatedState[storeTitle] = operationOnStoreSignal(...[\r\n\t\t\t\t\t\t\t\t\tregFunc,\r\n\t\t\t\t\t\t\t\t\tnull,\r\n\t\t\t\t\t\t\t\t\tstateArea,\r\n\t\t\t\t\t\t\t\t\tnull\r\n\t\t\t\t\t\t\t\t]); \r\n\r\n\t // Pass this on to the event queue \r\n\t wind.setTimeout(fireWatchers.bind(null, isolatedState), 0);\r\n\r\n\t return true;\r\n\t }\r\n\t break;\r\n\t case 'redo':\r\n\t if(store.canRedo()){\r\n\r\n\t ++regFunc.$$historyIndex;\r\n\r\n\t isolatedState[storeTitle] = operationOnStoreSignal(...[\r\n\t\t\t\t\t\t\t\t\tregFunc,\r\n\t\t\t\t\t\t\t\t\tnull,\r\n\t\t\t\t\t\t\t\t\tstateArea,\r\n\t\t\t\t\t\t\t\t\tnull\r\n\t\t\t\t\t\t\t\t]);\r\n\r\n\t // Pass this on to the event queue \r\n\t wind.setTimeout(fireWatchers.bind(null, isolatedState), 0);\r\n\r\n\t return true;\r\n\r\n\t }\r\n\t break;\r\n\t }\r\n\r\n\t return false;\r\n }\r\n\r\n deletePersistenceTagAndData(){\r\n\r\n \tif(isNullOrUndefined(config)){\r\n\r\n \t\treturn false;\r\n \t}\r\n\r\n \tconst _origin = getAppOriginForPersist(config);\r\n\r\n\t\t\tconst _tag = generateTag(_origin);\r\n\r\n\t\t\tpersistStore.removeItem(_origin);\r\n\r\n\t\t\tpersistStore.removeItem(_tag);\r\n\r\n\t\t\treturn true;\r\n }\r\n\r\n rebuildStateFromActions() {\r\n\r\n\t const actionsStack = operationOnStoreSignal.$$redoActionsStack;\r\n\r\n\t each(actionsStack, (action, index) => {\r\n\r\n\t let stateArea;\r\n\r\n\t for(title in observers){\r\n\t if(Hop.call(observers, title)){\r\n\r\n\t stateArea = new Area(title);\r\n\r\n\t observers[title].call(action, stateArea.get());\r\n\t }\r\n\t }\r\n\r\n\t }, operationOnStoreSignal);\r\n }\r\n\r\n signal(action) {\r\n\r\n\t let compactedFunc = null;\r\n\r\n\t const // this is the function that does the actual dispatch of the \r\n\t baseDispatcher = (observers, dispatcher, action, prevState) => {\r\n\r\n\t\t\t\t\t\tlet title, stateArea = null; \r\n\r\n\t\t\t\t\t\toperationOnStoreSignal.$$redoActionsStack.push(action);\r\n\r\n\t\t\t\t\t\tfor(title in observers){\r\n\t\t\t\t\t\t\tif(Hop.call(observers, title)){\r\n\r\n\t\t\t\t\t\t\t\tstateArea = new Area(title);\r\n\r\n\t\t\t\t\t\t\t\toperationOnStoreSignal(...[\r\n\t observers[title], \r\n\t dispatcher.queueing, \r\n\t stateArea,\r\n\t action\r\n\t ]);\r\n\t\t\t\t\t\t\t}\t\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\treturn getAppState();\r\n\t\t\t\t};\r\n\r\n\t const boundBaseDispatcher = baseDispatcher.bind(null, observers, this);\r\n\r\n\t const adjoiner = {\r\n\t /*createActionObject:function(_data, _type){\r\n\t \r\n\t return {\r\n\t source:\"\",\r\n\t actionType:_type,\r\n\t actionData:_data,\r\n\t actionKey:null\r\n\t };\r\n\t },*/\r\n\t createDispatchResolver(_action) {\r\n\r\n\t return boundBaseDispatcher.bind(null, _action);\r\n\t }\r\n\t };\r\n\r\n\t const _hasMiddleware = this.hasMiddleware();\r\n\r\n\r\n\t // Some validation - just to make sure everything is okay\r\n\t if(!(action.source in dispatchRegistry)){\r\n\r\n\t return;\r\n\t }\r\n\r\n\t // determine if there are middleware callbacks registered\r\n\t if(_hasMiddleware){ \r\n\t \r\n\t // collapse all middleware callbacks into a single callback\r\n\t compactedFunc = this.middlewares.concat(\r\n\t boundBaseDispatcher\r\n\t ).reduceRight((bound, middleware) => middleware.bind(null,\r\n\t bound\r\n\t ));\r\n\r\n\t }else {\r\n\r\n\t compactedFunc = boundBaseDispatcher;\r\n\t }\r\n\r\n\t // Pass this on to the event queue \r\n\t wind.setTimeout(handlePromises, 0);\r\n\r\n\t // begin cascading calls to the middlewares in turn\r\n\t // from the last attached middleware all the way up\r\n\t // to the first middleware until the action\r\n\t // is finally dispatched\r\n\r\n\t if(!isNullOrUndefined(compactedFunc)){\r\n\r\n\t compactedFunc.apply(_hasMiddleware ? adjoiner : null, [action, getAppState()]);\r\n\r\n\t }\r\n\t\t}\r\n\r\n\t\tunregister(title) {\r\n\r\n\t let observer, store, index;\r\n\r\n\t if(!isNullOrUndefined(observers[title])){\r\n\t // initial clean-up\r\n\r\n\t observer = observers[title];\r\n\t store = stores[title];\r\n\t observer.$$store_listeners.length = 0;\r\n\t observer.$$store_listeners = null;\r\n\t observer.$$historyIndex = -1;\r\n\t observer.$$history.length = 0;\r\n\t observer.$$history = null;\r\n\t \r\n\t // more clean-up (freeing memory)\r\n\t delete observers[title];\r\n\t observer = null;\r\n\t \r\n\t delete stores[title];\r\n\t store = null;\r\n\r\n\t index = storeKeys.indexOf(title);\r\n\r\n\t if(index != -1){\r\n\t storeKeys.splice(index, 1);\r\n\t }\r\n\t }\r\n\t\t}\r\n\r\n\t} \r\n\r\nexport { Dispatcher, Area }","import { wind, isNullOrUndefined } from '../utils/routines/basics.js';\r\nimport { Dispatcher, Area } from './dispatcher.js';\r\nimport { Values } from '../utils/routines/extras.js';\r\n\r\n\r\n\t\tlet $instance = null;\r\n\r\n\t\tconst dispatchRegistry = {\r\n \r\n\t\t};\r\n\r\n\t\tconst getInstance = () => {\r\n\t\t\t\r\n\t\t\tif($instance === null){\r\n\r\n\t\t\t\t$instance = new Dispatcher();\r\n\t\t\t}\r\n\r\n\t\t\treturn $instance;\r\n\r\n\t\t};\r\n\r\n\t\tconst getObjectPrototype = obj => {\r\n\t\t\t\tif('getPrototypeOf' in Object){\r\n\t\t\t\t\treturn Object.getPrototypeOf(obj);\r\n\t\t\t\t}else if('__proto__' in obj){\r\n\t\t\t\t\tif(!(Hop.call(obj, '__proto__'))){\t\r\n\t\t\t\t\t\treturn (obj.__proto__);\r\n\t\t\t\t\t}\r\n\t\t\t\t}else if('constructor' in obj){\r\n\t\t\t\t\tif(!(Hop.call(obj, 'constructor'))){\t\r\n\t\t\t\t\t\treturn obj.constructor.prototype;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\treturn obj;\r\n\t\t};\r\n\r\n\t\tconst eachStore = function(fn, extractor, storeArray) {\r\n\r\n each(storeKeys, extractor.bind((storeArray = []), stores));\r\n\r\n let callable = fn;\r\n let prevIndex = storeArray.length - 1;\r\n\r\n const next = () => {\r\n\t\t\t\r\n\t\t\t\tlet returnVal;\r\n\r\n\t\t\t\tif(prevIndex >= 0){\t\r\n\t\t\t\t\treturnVal = Boolean(\r\n\t\t\t\t\t\tcallable.call(\r\n\t\t\t\t\t\t\t\tnull, \r\n\t\t\t\t\t\t\t\tstoreArray[prevIndex--], \r\n\t\t\t\t\t\t\t\tnext\r\n\t\t\t\t\t\t)\r\n\t\t\t\t\t);\r\n\t\t\t\t}else{\r\n\t\t\t\t\tcallable = !0;\r\n\t\t\t\t\treturnVal = callable;\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn returnVal;\r\n\t\t\t};\r\n\r\n next();\r\n };\r\n\r\n\t\tconst setActionVectors = function(object, vectors) {\r\n\r\n const _proto = getObjectPrototype(object);\r\n const dispatcher = getInstance();\r\n let vector = null;\r\n\r\n for(const creator in vectors){\r\n\t\t\t\tif(Hop.call(vectors, creator)){\r\n\t\t\t\t vector = vectors[creator];\t\r\n\t\t\t\t _proto[creator] = createActionInterface(dispatcher, vector);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n return object;\r\n };\r\n\r\n\t\tconst createStoreInterface = function(dispatcher, method) {\r\n\t\t\t\r\n\r\n\t\t\treturn function(){\r\n let regFunc;\r\n let area;\r\n const argument = arguments.length? arguments[0] : null;\r\n\r\n if(method == 'setChangeListener'){\r\n\r\n\t\t\t\t\treturn dispatcher.setStoreListener(this, argument);\r\n\t\t\t\t}\r\n\r\n if(method == 'unsetChangeListener'){\r\n\r\n\t\t\t\t\treturn dispatcher.unsetStoreListener(this, argument);\r\n\t\t\t\t}\r\n\r\n if(method == 'getState'){\r\n\r\n\t\t\t\t\tlet value;\r\n\t\t\t\t\tarea = new Area(this.getTitle());\r\n\t\t\t\t\tvalue = area.get();\r\n\t\t\t\t\tarea = null;\r\n\r\n\t\t\t\t\tif(value === area){\r\n\r\n\t\t\t\t\t\tregFunc = dispatcher.getRegistration(this.getTitle());\r\n\r\n\t\t\t\t\t\treturn (regFunc.$$history.length && regFunc.$$history[0]);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\treturn (typeof argument == 'string' && (argument in value)) ? value[argument] : value;\r\n\t\t\t\t}\r\n\r\n if(method == 'destroy'){\r\n\r\n\t\t\t\t\tlet title, index;\r\n\r\n\t\t\t\t\tif(title in stores){\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tdelete stores[title];\r\n\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tarea = new Area(this.getTitle());\r\n\r\n\t\t\t\t\tarea.del();\r\n\r\n\t\t\t\t\treturn (area = title = null);\r\n\t\t\t\t}\r\n\r\n if(method == 'disconnect'){\r\n\r\n\t\t\t\t\treturn dispatcher.unregister(this.getTitle());\r\n\t\t\t\t}\r\n\r\n if(method == 'hydrate'){\r\n\r\n\t\t\t\t\tif(isNullOrUndefined(argument)){\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\treturn dispatcher.signalUnique({\r\n\t\t\t\t\t\tsource:method,\r\n\t\t\t\t\t\ttarget:this.getTitle(),\r\n\t\t\t\t\t\tactionData:argument\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\r\n if(method == 'getQuerySchema'){\r\n\t\t\t\t\t\r\n\t\t\t\t\treturn {};\r\n\t\t\t\t}\r\n\r\n if(method == 'setQuerySchema'){\r\n\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\r\n if(method == 'canUndo'){\r\n\r\n\t\t\t\t\tregFunc = dispatcher.getRegistration(this.getTitle());\r\n\r\n\t\t\t\t\treturn (regFunc.$$historyIndex != 0);\r\n\t\t\t\t}\r\n\r\n if(method == 'swapCallback'){\r\n\r\n\t\t\t\t\treturn dispatcher.register(this.getTitle(), argument);\r\n\t\t\t\t}\r\n\r\n if(method == 'canRedo'){\r\n\t\t\t\t\t\r\n\t\t\t\t\tregFunc = dispatcher.getRegistration(this.getTitle());\r\n\r\n\t\t\t\t\treturn (regFunc.$$historyIndex !== regFunc.$$history.length - 1);\r\n\t\t\t\t}\r\n\r\n if(method == 'undo'){\r\n\r\n\t\t\t\t\treturn dispatcher.handleStoreMutation(this, method);\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t}\r\n\r\n if(method == 'redo'){\r\n\r\n\t\t\t\t\treturn dispatcher.handleStoreMutation(this, method);\r\n\r\n\t\t\t\t}\r\n }\r\n\t\t\t\r\n\t\t};\r\n\r\n\t\tconst createActionInterface = function(dispatcher, vector) {\r\n\t\t\t\r\n\t\t\tif(!(vector instanceof Object)){\r\n\r\n\t\t\t\tthrow new TypeError(`Invalid Action Creator Vector, expected [object] but found [${typeof(vector)}]`);\r\n\t\t\t}\r\n\r\n\t\t\treturn function(data, stateAspectKey){\r\n\r\n\t\t\t\t // console.log('OUTER-FUNC: ', this.constructor.caller);\r\n\r\n\t\t\t\tconst id = this.getId();\r\n\t\t\t\t\r\n\t\t\t\tlet typesBitMask = 0;\r\n\r\n\t\t\t\tif(!isNullOrUndefined(dispatchRegistry[id])){\r\n\t\t\t\t\tdispatchRegistry[id].actionTypes.push(\r\n\t\t\t\t\t\tvector\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tif(vector.actionDefinition instanceof Array){\r\n\t\t\t\t\t\r\n\t\t\t\t\teach(vector.actionDefinition, function(definition){\r\n\t\t\t\t\t\r\n\t\t\t\t\t\ttypesBitMask |= Number(Values.isOfType(definition, data));\r\n\t\r\n\t\t\t\t\t});\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(!typesBitMask){\r\n\t\t\t\t\t \r\n\t\t\t\t\t\tthrow new TypeError(`Action Data Invalid for action: [${vector.type}]`);\r\n\t\t\t\t \t}\r\n\t\t\t\t\r\n\t\t\t\t}else{\r\n\t\t\t\t\tif(!Values.isOfType(vector.actionDefinition, data)){\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tthrow new TypeError(`Action Data Invalid for action: [${vector.type}]`);\r\n\r\n\t\t\t\t\t}\t\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\treturn dispatcher.signal({\r\n\t\t\t\t\tsource:id,\r\n\t\t\t\t\tactionType:vector.type,\r\n\t\t\t\t\tactionKey:stateAspectKey || null,\r\n\t\t\t\t\tactionData:data\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t};\r\n\r\n\t\tconst watchDispatcher = function(callback) {\r\n\r\n\t\t\tconst dispatcher = getInstance();\r\n\r\n\t\t\tdispatcher.watch(callback);\r\n\t\t\t\t\t\r\n\t\t};\r\n\r\n\t\tconst isAppStateAutoRehydrated = function() {\r\n\r\n\t\t\tconst dispatcher = getInstance();\r\n\r\n\t\t\treturn dispatcher.getAutoRehydrationState();\r\n\r\n\t\t};\r\n\r\n\t\tconst setupShutdownCallback = function(callback, hub){\r\n\r\n\t\t\t\t\r\n\t\t\thub._ping = callback;\r\n\t\t\t\t\r\n\t\t};\r\n\r\n\t\tconst mergeConfig = function(userConfig, hub) {\r\n\r\n\t\t\tconst dispatcher = getInstance();\r\n\r\n\t\t\treturn dispatcher.initCatchers(userConfig, hub);\r\n\t\t};\r\n\r\n\t\tconst purgePersistStore = function() {\r\n\r\n\t\t\tdispatcher.deletePersistenceTagAndData();\r\n\r\n\t\t};\r\n\r\n\t\tconst registerAction = function() {\r\n\t\t\t/* creates hex value e.g. '0ef352ab287f1' */\r\n\t\t\tconst regId = Math.random().toString(16).substr(2, 13); \r\n\t\r\n\t\t\tdispatchRegistry[regId] = {actionTypes:[]};\r\n\r\n\t\t\treturn regId;\r\n\r\n\t\t};\r\n\r\n\t\tconst makeAggregator = function() {\r\n\r\n\t\t\t\treturn {\r\n\t\t\t\t\tnotifyAllStores() {\r\n\t\t\t\t\t\t/*\r\n\t\t\t\t\t\t*/\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\t\t};\r\n\r\n\t\tconst setMiddlewareCallback = function(middlewareFunc) {\r\n\r\n\t\t\tconst dispatcher = getInstance();\r\n\r\n\t\t\t// HERE: using this try/catch for control flow and not defensive programming\r\n\t\t\ttry{\r\n\r\n\t\t\t\tdispatcher.getMiddleware();\r\n\r\n\t\t\t}catch(ex){\r\n\r\n\t\t\t\tdispatcher.setMiddleware(\r\n\t\t\t\t\tmiddlewareFunc\r\n\t\t\t\t);\r\n\r\n\t\t\t}\r\n\r\n\t\t};\r\n\r\n\t\tconst setStoreObserver = function(object, regFunc, defaultStateObj) {\r\n \r\n if(typeof regFunc !== \"function\"){\r\n\t\t\t\treturn null;\r\n\t\t\t}\r\n\r\n const _proto = getObjectPrototype(object);\r\n const dispatcher = getInstance();\r\n const title = object.getTitle();\r\n let method = null;\r\n\r\n dispatcher.register(title, regFunc, defaultStateObj);\r\n\r\n const methods = [\r\n \t'setChangeListener', \r\n \t'unsetChangeListener', \r\n \t'getState', \r\n \t'disconnect', \r\n \t'getQuerySchema', \r\n \t'canRedo', \r\n \t'canUndo', \r\n \t'swapCallback', \r\n \t'undo', \r\n \t'redo', \r\n \t'hydrate', \r\n \t'destroy'\r\n \t];\r\n\r\n for(let c=0; c < methods.length; c++){\r\n\r\n\t\t\t\tmethod = methods[c];\r\n\t\t\t\t_proto[method] = createStoreInterface(dispatcher, method);\r\n\t\t\t}\r\n\t\t};\r\n\r\nexport { eachStore, makeAggregator, registerAction,setupShutdownCallback, mergeConfig, purgePersistStore, setStoreObserver, watchDispatcher, isAppStateAutoRehydrated, createStoreInterface, createActionInterface }","import * as observable from './components/observable.js';\r\nimport { Action, Store } from './utils/routines/extras.js';\r\nimport Helpers from './utils/helpers.js';\r\nimport Payload from './utils/primitive-checkers.js'\r\n\r\n /*!\r\n * @lib: Radixx\r\n * @version: 0.1.2\r\n * @author: Ifeora Okechukwu\r\n * @created: 30/12/2016\r\n *\r\n * All Rights Reserved 2016 - 2018.\r\n * Use, reproduction, distribution, and modification of this code is subject to the terms and\r\n * conditions of the MIT license, available at http://www.opensource.org/licenses/mit-license.php\r\n *\r\n * @desc: Implementation of Facebooks' Flux Architecture with a Twist. [ ES6 ]\r\n */\r\n\r\n\r\nfunction toString(){\r\n\r\n return \"[object RadixxHub]\";\r\n}\r\n\r\nconst makeStore = function(dataTitle, registerCallback, defaultStateObj){\r\n \r\n function _store(...args){\r\n Store.apply(this, args);\r\n }\r\n\r\n const storeObject = new _store(dataTitle);\r\n\r\n observable.setStoreObserver(storeObject, registerCallback, defaultStateObj);\r\n\r\n return storeObject;\r\n}\r\n\r\nconst makeActionCreators = function(vectors){\r\n function _action(...args){\r\n Action.apply(this, args);\r\n }\r\n\r\n const actionObject = new _action(observable.registerAction());\r\n\r\n return observable.setActionVectors(actionObject, vectors);\r\n}\r\n\r\nconst purgePersistentStorage = function(){\r\n \r\n observable.purgePersistStore();\r\n}\r\n\r\nconst eachStore = function(callback){\r\n \r\n return observable.eachStore(callback, function(stores, key){\r\n\r\n this.push(stores[key]);\r\n }, null);\r\n}\r\n\r\nlet _hub = {\r\n eachStore\r\n};\r\n\r\n\r\nconst attachMiddleware = function(callback) {\r\n\r\n return observable.setMiddlewareCallback(callback);\r\n}\r\n\r\nconst isAppStateAutoRehydrated = function() {\r\n\r\n return observable.isAppStateAutoRehydrated();\r\n}\r\n\r\nconst onDispatch = function(handler){\r\n \r\n if(typeof handler === 'function'){\r\n\r\n observable.watchDispatcher(handler);\r\n }\r\n}\r\n\r\nconst configure = function(config) {\r\n \r\n return observable.mergeConfig(config, _hub);\r\n}\r\n\r\nconst onShutdown = function(handler){\r\n\r\n if(typeof handler === \"function\"){\r\n\r\n observable.setupShutdownCallback(handler, _hub);\r\n }\r\n\r\n}\r\n\r\nconst requestAggregator = function() {\r\n\r\n return observable.makeAggregator();\r\n}\r\n\r\nexport { Helpers, Payload, makeStore, makeActionCreators, purgePersistentStorage, isAppStateAutoRehydrated, requestAggregator, configure, eachStore, attachMiddleware, onDispatch, onShutdown, toString }\r\n","import { wind } from './routines/basics.js';\r\n\r\nexport const Helpers = {\r\n isEqual(former, latter) {\r\n if (former === latter) {\r\n return true;\r\n }\r\n\r\n if (typeof former !== 'object' || former === null ||\r\n typeof latter !== 'object' || latter === null) {\r\n return false;\r\n }\r\n\r\n const keysA = wind.Object.keys(former);\r\n const keysB = wind.Object.keys(latter);\r\n\r\n if (keysA.length !== keysB.length) {\r\n return false;\r\n }\r\n\r\n // Test for A's keys different from B.\r\n const bHasOwnProperty = wind.hasOwnProperty.bind(latter);\r\n for (let i = 0; i < keysA.length; i++) {\r\n if (!bHasOwnProperty(keysA[i]) || former[keysA[i]] !== latter[keysA[i]]) {\r\n return false;\r\n }\r\n }\r\n }\r\n};\r\n","import { wind } from './routines/basics.js';\r\n\r\nexport const Payload = {\r\n type:{\r\n \"array\":\"array\",\r\n \"date\":\"date\",\r\n \"string\":\"string\",\r\n \"regexp\":\"regexp\",\r\n \"boolean\":\"boolean\",\r\n \"function\":\"function\",\r\n \"object\":\"object\",\r\n \"number\":\"number\",\r\n error(value) {\r\n\r\n return (value instanceof wind.Error || value instanceof wind.TypeError);\r\n },\r\n nullable(value) {\r\n\r\n return (value === null || value === undefined);\r\n },\r\n \"numeric\":{\r\n Int(value) {\r\n return wind.isFinite(value) && (value === wind.parseInt(value))\r\n },\r\n Float(value) {\r\n return wind.isFinite(value) && (value === wind.parseFloat(value))\r\n }\r\n },\r\n any(value) {\r\n \r\n return (value !== null || value !== undefined);\t \t\t\t\r\n }\r\n }\r\n};\r\n","\r\nconst wind = (('undefined' !== typeof process &&\r\n '[object process]' === ({}).toString.call(process)) ||\r\n ('undefined' !== typeof navigator && navigator.product === 'ReactNative')\r\n? global : typeof window !== \"undefined\" ? window : self);\r\n\r\nconst Hop = ({}).hasOwnProperty;\r\n\r\nconst Slc = ([]).slice;\r\n\r\nconst isNullOrUndefined = obj => obj == void 0;\r\n\r\n\r\nconst each = (obj, iterator, context) => {\r\n\t\r\n\tif(context === undefined){\r\n\r\n\t\t context = null;\r\n\t}\r\n\r\n\tfor(let prop in obj){\r\n\t\t if(Hop.call(obj, prop)){\r\n\t\t\t iterator.call(context, obj[prop], prop, obj);\r\n\t\t }\r\n\t}\r\n};\r\n\r\n/**\r\n *\r\n * @params\r\n * @params\r\n * @return\r\n */\r\n\r\nconst extend = (source, dest) => {\r\n\r\n\t let merge = {};\r\n\r\n\t for(let prop in dest){\r\n \t\tif(Hop.call(dest, prop)){\r\n\r\n \t\t\tif(typeof dest[prop] === \"object\"\r\n \t \t\t\t&& dest[prop] !== null){\r\n \t\t\t \tmerge[prop] = extend(source[prop], dest[prop]);\r\n \t\t\t }else if(source && Hop.call(source, prop)){\r\n \t\t\t \tmerge[prop] = source[prop];\r\n \t\t\t }else {\r\n \t\t\t \tmerge[prop] = dest[prop];\r\n \t\t\t }\r\n \t\t}\r\n\t }\r\n\r\n\treturn merge;\r\n};\r\n\r\nconst curry = (func, args, context) => function(){\r\n let _args = Slc.call(arguments);\r\n return func.apply(context, args.concat(_args)); \r\n};\r\n\r\nconst futuresStates = {\r\n STARTED:0,\r\n AWAIT:1,\r\n RESOLVED:2,\r\n REJECTED:3\r\n};\r\n\r\nconst formatOptions = opts => {\r\n const options = {}, _opts = String(opts).split(\",\");\r\n each(_opts, key => {\r\n options[key] = true;\r\n });\r\n options.savedData = !1;\r\n return options;\r\n};\r\n\r\nconst Routines = opts => {\r\n const options = formatOptions(opts);\r\n let fireStart;\r\n let fireEnd;\r\n let index;\r\n let fired;\r\n let firing;\r\n let pending = [];\r\n let queue = options.multiple && [];\r\n\r\n const fire = data => {\r\n options.savedData = !fire.$decline && options.save && data; // save it only when we are not rejecting {fire.$decline != true}!\r\n fired = true;\r\n firing = true; // firing has begun!\r\n index = fireStart || 0;\r\n fireEnd = pending.length;\r\n\t \r\n for(fireStart = 0; index < fireEnd; index++){\r\n // @TODO: need to curry args instead of directly binding them #DONE\r\n wind.setTimeout(curry(pending[index], data[1], data[0])/*.bind(data[0], data[1])*/, 20); // fire asynchronously (Promises/A+ spec requirement)\r\n }\r\n\t \r\n firing = false; // firing has ended!\r\n\r\n if(queue){ // deal with the queue if it exists and has any contents...\r\n if(queue.length){\r\n return fire(queue.shift()); // fire on the {queue} items recursively\r\n }\r\n // if queue is empty.... then end [flow of control] at this point!\r\n }\r\n\r\n fire.$decline = false;\r\n \r\n if(options.savedData){\r\n if(options.unpack){\r\n // clear our {pending} list and free up some memeory!!\r\n pending.length = 0; // saves the reference {pending} and does not replace it!\r\n }\r\n }\r\n };\r\n\r\n return {\r\n add() {\r\n let len = 0;\r\n if(pending){ // if not disbaled\r\n \r\n const start = pending.length;\r\n (function add(args){\r\n \r\n each(args, arg => {\r\n\t\t\t const type = typeof arg;\r\n \r\n if(type == \"function\"){\r\n \tlen = pending.push(arg);\r\n }else{\r\n if(!!arg && arg.length && typeof arg != \"string\"){\r\n \t // inspect recursively\r\n add(Slc.call(arg)); \r\n }\r\n }\r\n });\r\n \r\n }(Slc.call(arguments)));\r\n \r\n \r\n\t\t\tif( fired ){ // if we have already run the {pending} list of routines at least once, ...\r\n\t\t\t\t if(options.join){\r\n\t\t\t\t\t fireStart = start; \r\n\t\t\t\t\t fireEnd = len; // update info again...\r\n\t\t\t\t\t fire.$decline = true;\r\n\t\t\t\t\t fire( options.savedData ); // fire with the saved data \r\n\t\t\t\t\t this.disable();\r\n\t\t\t\t\t \r\n\t\t\t\t } \r\n\t\t\t}\r\n \r\n \r\n }\r\n return len;\r\n },\r\n hasFn(fn) {\r\n\t \tlet result = false;\r\n \teach(pending, val => {\r\n\t\t if(typeof fn === \"function\" && fn === val)\r\n\t\t\t result = true;\r\n\t\t}, this);\r\n\t\treturn result;\r\n },\r\n hasList() {\r\n return !!pending; // [false] only when the disabled(); method has been called!!\r\n },\r\n fireWith() /* context, args */{\r\n if(pending && (!fired || queue)){\r\n const args = arguments.length && Slc.call(arguments) || [null, 0];\r\n \r\n if(firing){ // we are currently iterating on the {pending} list of routines\r\n queue.push( args ); // queue assets for recursive firing within {fire} function later\r\n }else{\r\n fire( args );\r\n }\r\n }\r\n },\r\n disable() {\r\n\t if(!options.savedData){\r\n pending = queue = undefined;\r\n\t }\r\n }\r\n };\r\n};\r\n\r\n// Futures constructor - Promises/A+ Spec Implementation (Influenced by jQuery though...)\r\n\r\nlet Futures = function(){\r\n\r\n const defTracks = {\r\n resolve:['done', 'RESOLVED', Routines(['join', 'save'])],\r\n reject:['fail', 'REJECTED', Routines(['join','save'])],\r\n notify:['progress', 'AWAIT', Routines(['join', 'multiple'])]\r\n };\r\n\r\n const self = this;\r\n let keys = Object.keys(defTracks);\r\n\r\n let setter = (fnName, arr, forPromise) => {\r\n const drop = (fnName != \"notify\");\r\n if(!arr.length && !forPromise) return defTracks[fnName][2].fireWith;\r\n return (!forPromise)? function(){\r\n if(self.state >= 0 && self.state <=1){\r\n self.state = futuresStates[defTracks[fnName][1]];\r\n }\r\n\r\n defTracks[fnName][2].fireWith(self === this? self : this, [].slice.call(arguments));\r\n\r\n if(drop){\r\n\t\t\t defTracks[arr[0]][2].disable();\r\n defTracks[arr[1]][2].disable();\r\n\t\t\t switch(fnName){\t\r\n\t\t\t\t case \"reject\":\r\n\t\t\t\t case \"resolve\":\r\n\t\t\t\t self.state = futuresStates[defTracks[fnName][1]];\r\n\t\t\t\t break;\r\n\t\t\t }\t\r\n\t\t\t}\r\n return true;\r\n } : function(){\r\n if(self.state >= 0 && self.state <=1){\r\n defTracks[fnName][2].add.apply(self, Slc.call(arguments));\r\n }\r\n return self;\r\n } ;\r\n };\r\n\r\n let i = 0;\r\n let ax = keys.slice();\r\n let d;\r\n const promise = {};\r\n\r\n\r\n // using a closure to define all the functions on the fly...\r\n\r\n for(d in defTracks){\r\n if(Hop.call(defTracks, d)){\r\n keys.splice(i++, 1);\r\n self[d] = setter(d, keys);\r\n self[`${d}With`] = setter(d, []);\r\n promise[defTracks[d][0]] = setter(d, [], true);\r\n keys = ax.slice();\r\n }\r\n }\r\n\r\n promise.state = futuresStates.STARTED;\r\n\r\n promise.always = function(){\r\n return this.done.apply(self, arguments).fail.apply(self, arguments);\r\n };\r\n\r\n promise.promise = obj => {\r\n if(obj && typeof obj == \"object\" && !obj.length){\r\n for(const i in promise){\r\n if(Hop.call(promise, i)){\r\n obj[i] = promise[i];\r\n }\r\n }\r\n return obj;\r\n }\r\n return promise;\r\n };\r\n\r\n promise.then = function(/* fnDone, fnFail, fnProgress */){\r\n let ret;\r\n const args = [].slice.call(arguments);\r\n args.forEach((item, i) => {\r\n item = (typeof item == \"function\") && item;\r\n self[defTracks[keys[i]][0]](function(){\r\n\t\t\t\t\t\t\tlet rt;\r\n\t\t\t\t\t\t\ttry{ \r\n\t\t\t\t\t\t\t\t/*\r\n\t\t\t\t\t\t\t\t\tPromises/A+ specifies that errors should be contained\r\n\t\t\t\t\t\t\t\t\tand returned as value of rejected promise\r\n\t\t\t\t\t\t\t\t*/\r\n\t\t\t\t\t\t\t rt = item && item.apply(this, arguments);\r\n\t\t\t\t\t\t\t}catch(e){ \r\n\t\t\t\t\t\t\t rt = this.reject(e);\r\n\t\t\t\t\t\t\t}finally{\r\n\t\t\t\t\t\t\t if(rt && typeof rt.promise == \"function\")\r\n\t\t\t\t\t\t\t ret = rt.promise();\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t}\t \r\n });\r\n });\r\n return self.promise(ret);\r\n };\r\n\r\n promise.isResolved = () => !defTracks['reject'][2].hasList();\r\n promise.isRejected = () => !defTracks['resolve'][2].hasList();\r\n promise.pipe = promise.then;\r\n\r\n promise.promise(self);\r\n\r\n Futures.STARTED = futuresStates.STARTED;\r\n Futures.AWAITING = futuresStates.AWAIT;\r\n Futures.RESOLVED = futuresStates.RESOLVED;\r\n Futures.REJECTED = futuresStates.REJECTED;\r\n\r\n /* avoid leaking memory with each call to Futures constructor!! */\r\n setter = ax = d = i = null;\r\n\r\n /* enforce {new} on constructor */\r\n return (self instanceof Futures)? self : new Futures();\r\n};\r\n\r\nexport { Hop, Slc, isNullOrUndefined, wind, each, extend, curry, Futures }\r\n","import { wind } from './basics.js';\r\n\r\nlet __beforeunload = wind.onbeforeunload;\r\n\r\nlet __unload = wind.onunload;\r\n\r\nlet __hasDeactivated = false;\r\n\r\nlet _checkAndKillEventPropagation = event => {\r\n if(event.type === 'click'){\r\n if(event.stopPropagation){\r\n event.stopPropagation();\r\n }else{\r\n event.cancelBubble = true;\r\n }\r\n }\r\n};\r\n\r\nconst $createBeforeTearDownCallback = config => e => {\r\n \r\n // @See: https://greatgonzo.net/i-know-what-you-did-on-beforeunload/\r\n\r\n /* \r\n `lastActivatedNode` variable is used to track the DOM Node that last \r\n had focus (or was clicked) just before the browser triggered the `beforeunload` event \r\n */\r\n\r\n const lastActivatedNode = (wind.currentFocusElement // Mobile Browsers [ Custom Property ]\r\n || e.explicitOriginalTarget // old/new Firefox\r\n || (e.srcDocument && e.srcDocument.activeElement) // old Chrome/Safari\r\n || (e.currentTarget && e.currentTarget.document.activeElement) // Sarafi/Chrome/Opera/IE\r\n || e.srcElement\r\n || e.target);\r\n\r\n // if the \"imaginary\" user is logging out\r\n const leaveMessage = \"Are you sure you want to leave this page ?\";\r\n\r\n const isLogoff = ((typeof lastActivatedNode.hasAttribute == 'function' && lastActivatedNode.hasAttribute('data-href') && lastActivatedNode.getAttribute('data-href').includes(config.runtime.shutDownHref)) \r\n || (('href' in lastActivatedNode) && (lastActivatedNode.href.includes(config.runtime.shutDownHref))));\r\n\r\n const __timeOutCallback = () => {\r\n \r\n __hasDeactivated = __timeOutCallback.lock;\r\n\r\n };\r\n\r\n // console.log('Node: '+ lastActivatedNode);\r\n\r\n __timeOutCallback.lock = __hasDeactivated = true;\r\n beforeUnloadTimer = wind.setTimeout(__timeOutCallback, 0);\r\n\r\n if(isLogoff){ // IE/Firefox/Chrome 34+\r\n if(!!~e.type.indexOf('beforeunload')){\r\n e.returnValue = leaveMessage; \r\n }else{\r\n _confirm = wind.confirm && wind.confirm(leaveMessage);\r\n \r\n if(!_confirm){\r\n _checkAndKillEventPropagation(e);\r\n }\r\n }\r\n }else{\r\n _checkAndKillEventPropagation(e);\r\n }\r\n\r\n /* if (isLogoff) isn't true, no beforeunload dialog is shown */\r\n return ((isLogoff) ? ((__timeOutCallback.lock = false) || leaveMessage) : wind.clearTimeout(beforeUnloadTimer));\r\n};\r\n\r\nconst $createTearDownCallback = hub => e => {\r\n\r\n /*\r\n This seems to be the best way to setup the `unload` event \r\n listener to ensure that the load event is always fired even if the page\r\n is loaded from the `bfcache` (Back-Forward-Cache) of the browser whenever\r\n the back and/or forward buttons are used for navigation instead of links.\r\n Registering it as a property of the `window` object sure works every time\r\n */\r\n\r\n if(!__hasDeactivated){\r\n\r\n wind.setTimeout(() => {\r\n\r\n let appstate = {};\r\n \r\n hub.eachStore((store, next) => {\r\n\r\n const title = store.getTitle();\r\n\r\n appstate[title] = store.getState(); \r\n \r\n store.disconnect();\r\n store.destroy();\r\n\r\n next();\r\n\r\n });\r\n\r\n if(typeof hub._ping == \"function\"){\r\n\r\n hub._ping.call(hub, appstate);\r\n }\r\n\r\n if(e.type != 'click'){\r\n __unload(e);\r\n }\r\n\r\n }, 0);\r\n }\r\n};\r\n\r\nconst Values = {\r\n typesMap:{\r\n \"number\":Number,\r\n \"array\":Array,\r\n \"object\":Object,\r\n \"string\":String,\r\n \"boolean\":Boolean,\r\n \"date\":Date,\r\n \"regexp\":RegExp,\t\r\n \"function\":Function\r\n },\r\n isOfType(type, value) {\r\n\r\n var type = type.toLowerCase(); // hoisting\r\n\r\n if(typeof type === 'function'){\r\n\r\n return type(value);\r\n }\r\n\r\n else if(typeof type === 'string'\r\n && (type in this.typesMap)){\r\n return (/^string|function$/.test(typeof value)) \r\n || (Object(value) instanceof this.typesMap[type]);\r\n }\r\n\r\n return false;\r\n }\r\n};\r\n\r\n\r\n// Store Constructor\r\nconst Store = ((() => {\r\n\r\n\tlet requirementTypes = ['graph-ql', 'rest'];\r\n\r\n\tlet serviceRequirementsMap = {};\r\n\t\r\n\treturn function(title){\r\n\r\n\t\tconst that = this;\r\n\r\n\t\tthis.getTitle = () => title;\r\n\r\n\t\tthis.toJSON = () => ({\r\n title\r\n });\r\n\r\n\t\tthis.makeTrait = function(callback, ...argsLeft){\r\n\r\n if(typeof callback === 'function'){\r\n\r\n argsLeft.unshift(that);\r\n\r\n return callback(...argsLeft);\r\n }\r\n\r\n\t\t\t return null;\r\n\r\n\t\t};\r\n\r\n\t\tthis.toString = () => \"[object RadixxStore]\";\r\n\t}\t\r\n\r\n})());\r\n\r\n// Action constructor\r\nconst Action = ((() => function(id){\r\n\r\n this.getId = () => id;\r\n\r\n this.toJSON = () => ({\r\n id\r\n });\r\n\r\n this.toString = () => \"[object RadixxActionCreator]\";\r\n})());\r\n\r\n\r\nexport { Values, Store, Action, $createBeforeTearDownCallback, $createTearDownCallback }"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/radixx.es2015.min.js b/dist/radixx.es2015.min.js new file mode 100644 index 0000000..1b27f8f --- /dev/null +++ b/dist/radixx.es2015.min.js @@ -0,0 +1,14 @@ +!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){"use strict";(function(e,n){Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=void 0!==e&&"[object process]"==={}.toString.call(e)||"undefined"!=typeof navigator&&"ReactNative"===navigator.product?n:"undefined"!=typeof window?window:self,o={}.hasOwnProperty,a=[].slice,u=function(e,t,n){for(var r in void 0===n&&(n=null),e)o.call(e,r)&&t.call(n,e[r],r,e)},l=function(e,t,n){return function(){var r=a.call(arguments);return e.apply(n,t.concat(r))}},c={STARTED:0,AWAIT:1,RESOLVED:2,REJECTED:3},s=function(e){var t=function(e){var t={},n=String(e).split(",");return u(n,function(e){t[e]=!0}),t.savedData=!1,t}(e),n=void 0,o=void 0,c=void 0,s=void 0,f=void 0,d=[],p=t.multiple&&[],h=function e(r){for(t.savedData=!e.$decline&&t.save&&r,s=!0,f=!0,c=n||0,o=d.length,n=0;c=0&&n.state<=1&&t[e][2].add.apply(n,a.call(arguments)),n}:function(){if(n.state>=0&&n.state<=1&&(n.state=c[t[e][1]]),t[e][2].fireWith(n===this?n:this,[].slice.call(arguments)),o)switch(t[r[0]][2].disable(),t[r[1]][2].disable(),e){case"reject":case"resolve":n.state=c[t[e][1]]}return!0}:t[e][2].fireWith},l=0,f=i.slice(),d=void 0,p={};for(d in t)o.call(t,d)&&(i.splice(l++,1),n[d]=u(d,i),n[d+"With"]=u(d,[]),p[t[d][0]]=u(d,[],!0),i=f.slice());return p.state=c.STARTED,p.always=function(){return this.done.apply(n,arguments).fail.apply(n,arguments)},p.promise=function(e){if(e&&"object"==(void 0===e?"undefined":r(e))&&!e.length){for(var t in p)o.call(p,t)&&(e[t]=p[t]);return e}return p},p.then=function(){var e=void 0;return[].slice.call(arguments).forEach(function(r,o){r="function"==typeof r&&r,n[t[i[o]][0]](function(){var t=void 0;try{t=r&&r.apply(this,arguments)}catch(e){t=this.reject(e)}finally{t&&"function"==typeof t.promise&&(e=t.promise())}})}),n.promise(e)},p.isResolved=function(){return!t.reject[2].hasList()},p.isRejected=function(){return!t.resolve[2].hasList()},p.pipe=p.then,p.promise(n),e.STARTED=c.STARTED,e.AWAITING=c.AWAIT,e.RESOLVED=c.RESOLVED,e.REJECTED=c.REJECTED,u=f=d=l=null,n instanceof e?n:new e}}).call(this,n(4),n(5))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.$createTearDownCallback=t.$createBeforeTearDownCallback=t.Action=t.Store=t.Values=void 0;var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=n(0),o=(i.wind.onbeforeunload,i.wind.onunload),a=!1,u=function(e){"click"===e.type&&(e.stopPropagation?e.stopPropagation():e.cancelBubble=!0)},l={typesMap:{number:Number,array:Array,object:Object,string:String,boolean:Boolean,date:Date,regexp:RegExp,function:Function},isOfType:function(e,t){return"function"==typeof(e=e.toLowerCase())?e(t):"string"==typeof e&&e in this.typesMap&&(/^string|function$/.test(void 0===t?"undefined":r(t))||Object(t)instanceof this.typesMap[e])}},c=function(e){var t=this;this.getTitle=function(){return e},this.toJSON=function(){return{title:e}},this.makeTrait=function(e){if("function"==typeof e){for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i=0?Boolean(r.call(null,n[i--],e)):r=!0}()},t.makeAggregator=function(){return{notifyAllStores:function(){}}},t.registerAction=function(){var e=Math.random().toString(16).substr(2,13);return l[e]={actionTypes:[]},e},t.setupShutdownCallback=function(e,t){t._ping=e},t.mergeConfig=function(e,t){return c().initCatchers(e,t)},t.purgePersistStore=function(){dispatcher.deletePersistenceTagAndData()},t.setStoreObserver=function(e,t,n){if("function"!=typeof t)return null;var r=s(e),i=c(),o=e.getTitle(),a=null;i.register(o,t,n);for(var u=["setChangeListener","unsetChangeListener","getState","disconnect","getQuerySchema","canRedo","canUndo","swapCallback","undo","redo","hydrate","destroy"],l=0;l1)for(var n=1;n21&&e.$$history.unshift()},A=function(e){if((0,a.isNullOrUndefined)(e)||"null"===e)return null;try{return JSON.parse(e)}catch(t){return String(e)}},k=function(e){(0,a.isNullOrUndefined)(e)&&(e=null);try{return JSON.stringify(e)}catch(t){return String(e)}},E=function e(t){var n=null,r=e.$$tag;!0===o.callee.$$withAction&&(n=function(){var e=O.$$redoActionsStack;return e.lenth?e[e.length-1]:null}(),o.callee.$$withAction=null),(0,a.isNullOrUndefined)(r)||null===l||(l.setItem(r,k({state:t,action:n,title:o.callee.$$currentStoreTitle,historyLoc:o.callee.$$historyLocation})),o.callee.$$historyLocation=null)},D=function(e,t){var n=void 0,r=void 0;for(n in p)if(a.Hop.call(p,n)){if(r=p[n],t&&r.$$canOmit)continue;r.call(null,e)}},x=function(e){(0,a.each)(e,function(e,t){new L(t).put(e)}),D(e,!0)},_=function(){var e={},t=void 0,n=void 0,r=void 0,i=void 0;if("key"in c&&"function"==typeof c.key)for(var o=0;o= 2 )")}},{key:"hasMiddleware",value:function(){return this.middlewares.length>0}},{key:"initCatchers",value:function(e,t){(0,a.isNullOrUndefined)(d)&&(d=(0,a.extend)(e,T),function(e,t){if(e.universalCoverage&&(e.persistenceEnabled=!0),e.persistenceEnabled){var n=$(e),r=S(n);l.setItem(n,r),C.$$origin=n,C.$$tag=r,E.$$canOmit=!0,E.$$tag=r,t.onDispatch(E)}if(!0===e.autoRehydrate){var i=null;!(0,a.isNullOrUndefined)(C.$$tag)&&l&&(i=A(l.getItem(C.$$tag))),i instanceof Object&&i.state&&(x(i.state),this.updateAutoRehydrationState())}e.runtime.spaMode?"string"==typeof e.runtime.shutDownHref&&0!=e.runtime.shutDownHref.length&&(a.wind.addEventListener?(a.wind.document.documentElement.addEventListener("click",(0,u.$createBeforeTearDownCallback)(e),!1),a.wind.document.addEventListener("click",(0,u.$createTearDownCallback)(t),!1)):(a.wind.document.documentElement.attachEvent("onclick",(0,u.$createBeforeTearDownCallback)(e)),a.wind.document.attachEvent("onclick",(0,u.$createTearDownCallback)(t),!1))):"string"==typeof e.runtime.shutDownHref&&0!=e.runtime.shutDownHref.length&&(a.wind.onbeforeunload=(0,u.$createBeforeTearDownCallback)(e),a.wind.onunload=(0,u.$createTearDownCallback)(t))}.apply(this,[d,t])),a.wind.document.addEventListener?(d.universalCoverage&&a.wind.addEventListener("storage",C,!1),a.wind.document.addEventListener("storesignal",R,!1)):a.wind.document.attachEvent&&(d.universalCoverage&&a.wind.document.attachEvent("onstorage",C),a.wind.document.attachEvent("onstoresignal",R))}},{key:"getRegistration",value:function(e){return a.Hop.call(v,e)?v[e]:{}}},{key:"register",value:function(e,t,n){if(a.Hop.call(v,e)){if("$$history"in v[e]&&void 0===t.$$history){if(!h[e])throw new Error("Radixx: Cannot Overwrite existing store registration");t.$$history=v[e].$$history,t.$$historyIndex=v[e].$$historyIndex,t.$$store_listeners=v[e].$$store_listeners,v[e]=t}}else t.$$store_listeners=[],t.$$history=[n||[]],t.$$historyIndex=0,v[e]=t,y.push(e);return!0}},{key:"watch",value:function(e){p.push(e)}},{key:"setStoreListener",value:function(e,t){var n=e.getTitle();(0,a.isNullOrUndefined)(v[n])||"function"==typeof t&&(h[n]=e,v[n].$$store_listeners.push(t))}},{key:"unsetStoreListener",value:function(e,t){var n=e.getTitle();if(!(0,a.isNullOrUndefined)(v[n])&&"function"==typeof t){var r=v[n].$$store_listeners.indexOf(t);v[n].$$store_listeners.splice(r,1)}}},{key:"signalUnique",value:function(e){if("hydrate"==e.source){a.wind.setTimeout(j,0);var t=new L(e.target),n=v[e.target];O.$$redoActionsStack.length=0,O.$$redoActionsStack.push(e),n.$$history.length=0,n.historyIndex=-1,O.apply(void 0,[n,null,t,e])}}},{key:"handleStoreMutation",value:function(e,t){if(t){var n=e.getTitle(),r={},i=this.getRegistration(n),o=new L(n);switch(t){case"undo":if(e.canUndo())return--i.$$historyIndex,r[n]=O.apply(void 0,[i,null,o,null]),a.wind.setTimeout(D.bind(null,r),0),!0;break;case"redo":if(e.canRedo())return++i.$$historyIndex,r[n]=O.apply(void 0,[i,null,o,null]),a.wind.setTimeout(D.bind(null,r),0),!0}return!1}}},{key:"deletePersistenceTagAndData",value:function(){if((0,a.isNullOrUndefined)(d))return!1;var e=$(d),t=S(e);return l.removeItem(e),l.removeItem(t),!0}},{key:"rebuildStateFromActions",value:function(){var e=O.$$redoActionsStack;(0,a.each)(e,function(e,t){var n=void 0;for(title in v)a.Hop.call(v,title)&&(n=new L(title),v[title].call(e,n.get()))},O)}},{key:"signal",value:function(e){var t=null,n=function(e,t,n,r){var i=void 0,o=null;for(i in O.$$redoActionsStack.push(n),e)a.Hop.call(e,i)&&(o=new L(i),O.apply(void 0,[e[i],t.queueing,o,n]));return _()}.bind(null,v,this),r={createDispatchResolver:function(e){return n.bind(null,e)}},i=this.hasMiddleware();e.source in dispatchRegistry&&(t=i?this.middlewares.concat(n).reduceRight(function(e,t){return t.bind(null,e)}):n,a.wind.setTimeout(j,0),(0,a.isNullOrUndefined)(t)||t.apply(i?r:null,[e,_()]))}},{key:"unregister",value:function(e){var t=void 0,n=void 0;(0,a.isNullOrUndefined)(v[e])||(t=v[e],h[e],t.$$store_listeners.length=0,t.$$store_listeners=null,t.$$historyIndex=-1,t.$$history.length=0,t.$$history=null,delete v[e],t=null,delete h[e],null,-1!=(n=y.indexOf(e))&&y.splice(n,1))}}]),e}();t.Dispatcher=M,t.Area=L},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Helpers=void 0;var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=n(0);t.Helpers={isEqual:function(e,t){if(e===t)return!0;if("object"!==(void 0===e?"undefined":r(e))||null===e||"object"!==(void 0===t?"undefined":r(t))||null===t)return!1;var n=i.wind.Object.keys(e),o=i.wind.Object.keys(t);if(n.length!==o.length)return!1;for(var a=i.wind.hasOwnProperty.bind(t),u=0;u obj == void 0;\r\n\r\n\r\nconst each = (obj, iterator, context) => {\r\n\t\r\n\tif(context === undefined){\r\n\r\n\t\t context = null;\r\n\t}\r\n\r\n\tfor(let prop in obj){\r\n\t\t if(Hop.call(obj, prop)){\r\n\t\t\t iterator.call(context, obj[prop], prop, obj);\r\n\t\t }\r\n\t}\r\n};\r\n\r\n/**\r\n *\r\n * @params\r\n * @params\r\n * @return\r\n */\r\n\r\nconst extend = (source, dest) => {\r\n\r\n\t let merge = {};\r\n\r\n\t for(let prop in dest){\r\n \t\tif(Hop.call(dest, prop)){\r\n\r\n \t\t\tif(typeof dest[prop] === \"object\"\r\n \t \t\t\t&& dest[prop] !== null){\r\n \t\t\t \tmerge[prop] = extend(source[prop], dest[prop]);\r\n \t\t\t }else if(source && Hop.call(source, prop)){\r\n \t\t\t \tmerge[prop] = source[prop];\r\n \t\t\t }else {\r\n \t\t\t \tmerge[prop] = dest[prop];\r\n \t\t\t }\r\n \t\t}\r\n\t }\r\n\r\n\treturn merge;\r\n};\r\n\r\nconst curry = (func, args, context) => function(){\r\n let _args = Slc.call(arguments);\r\n return func.apply(context, args.concat(_args)); \r\n};\r\n\r\nconst futuresStates = {\r\n STARTED:0,\r\n AWAIT:1,\r\n RESOLVED:2,\r\n REJECTED:3\r\n};\r\n\r\nconst formatOptions = opts => {\r\n const options = {}, _opts = String(opts).split(\",\");\r\n each(_opts, key => {\r\n options[key] = true;\r\n });\r\n options.savedData = !1;\r\n return options;\r\n};\r\n\r\nconst Routines = opts => {\r\n const options = formatOptions(opts);\r\n let fireStart;\r\n let fireEnd;\r\n let index;\r\n let fired;\r\n let firing;\r\n let pending = [];\r\n let queue = options.multiple && [];\r\n\r\n const fire = data => {\r\n options.savedData = !fire.$decline && options.save && data; // save it only when we are not rejecting {fire.$decline != true}!\r\n fired = true;\r\n firing = true; // firing has begun!\r\n index = fireStart || 0;\r\n fireEnd = pending.length;\r\n\t \r\n for(fireStart = 0; index < fireEnd; index++){\r\n // @TODO: need to curry args instead of directly binding them #DONE\r\n wind.setTimeout(curry(pending[index], data[1], data[0])/*.bind(data[0], data[1])*/, 20); // fire asynchronously (Promises/A+ spec requirement)\r\n }\r\n\t \r\n firing = false; // firing has ended!\r\n\r\n if(queue){ // deal with the queue if it exists and has any contents...\r\n if(queue.length){\r\n return fire(queue.shift()); // fire on the {queue} items recursively\r\n }\r\n // if queue is empty.... then end [flow of control] at this point!\r\n }\r\n\r\n fire.$decline = false;\r\n \r\n if(options.savedData){\r\n if(options.unpack){\r\n // clear our {pending} list and free up some memeory!!\r\n pending.length = 0; // saves the reference {pending} and does not replace it!\r\n }\r\n }\r\n };\r\n\r\n return {\r\n add() {\r\n let len = 0;\r\n if(pending){ // if not disbaled\r\n \r\n const start = pending.length;\r\n (function add(args){\r\n \r\n each(args, arg => {\r\n\t\t\t const type = typeof arg;\r\n \r\n if(type == \"function\"){\r\n \tlen = pending.push(arg);\r\n }else{\r\n if(!!arg && arg.length && typeof arg != \"string\"){\r\n \t // inspect recursively\r\n add(Slc.call(arg)); \r\n }\r\n }\r\n });\r\n \r\n }(Slc.call(arguments)));\r\n \r\n \r\n\t\t\tif( fired ){ // if we have already run the {pending} list of routines at least once, ...\r\n\t\t\t\t if(options.join){\r\n\t\t\t\t\t fireStart = start; \r\n\t\t\t\t\t fireEnd = len; // update info again...\r\n\t\t\t\t\t fire.$decline = true;\r\n\t\t\t\t\t fire( options.savedData ); // fire with the saved data \r\n\t\t\t\t\t this.disable();\r\n\t\t\t\t\t \r\n\t\t\t\t } \r\n\t\t\t}\r\n \r\n \r\n }\r\n return len;\r\n },\r\n hasFn(fn) {\r\n\t \tlet result = false;\r\n \teach(pending, val => {\r\n\t\t if(typeof fn === \"function\" && fn === val)\r\n\t\t\t result = true;\r\n\t\t}, this);\r\n\t\treturn result;\r\n },\r\n hasList() {\r\n return !!pending; // [false] only when the disabled(); method has been called!!\r\n },\r\n fireWith() /* context, args */{\r\n if(pending && (!fired || queue)){\r\n const args = arguments.length && Slc.call(arguments) || [null, 0];\r\n \r\n if(firing){ // we are currently iterating on the {pending} list of routines\r\n queue.push( args ); // queue assets for recursive firing within {fire} function later\r\n }else{\r\n fire( args );\r\n }\r\n }\r\n },\r\n disable() {\r\n\t if(!options.savedData){\r\n pending = queue = undefined;\r\n\t }\r\n }\r\n };\r\n};\r\n\r\n// Futures constructor - Promises/A+ Spec Implementation (Influenced by jQuery though...)\r\n\r\nlet Futures = function(){\r\n\r\n const defTracks = {\r\n resolve:['done', 'RESOLVED', Routines(['join', 'save'])],\r\n reject:['fail', 'REJECTED', Routines(['join','save'])],\r\n notify:['progress', 'AWAIT', Routines(['join', 'multiple'])]\r\n };\r\n\r\n const self = this;\r\n let keys = Object.keys(defTracks);\r\n\r\n let setter = (fnName, arr, forPromise) => {\r\n const drop = (fnName != \"notify\");\r\n if(!arr.length && !forPromise) return defTracks[fnName][2].fireWith;\r\n return (!forPromise)? function(){\r\n if(self.state >= 0 && self.state <=1){\r\n self.state = futuresStates[defTracks[fnName][1]];\r\n }\r\n\r\n defTracks[fnName][2].fireWith(self === this? self : this, [].slice.call(arguments));\r\n\r\n if(drop){\r\n\t\t\t defTracks[arr[0]][2].disable();\r\n defTracks[arr[1]][2].disable();\r\n\t\t\t switch(fnName){\t\r\n\t\t\t\t case \"reject\":\r\n\t\t\t\t case \"resolve\":\r\n\t\t\t\t self.state = futuresStates[defTracks[fnName][1]];\r\n\t\t\t\t break;\r\n\t\t\t }\t\r\n\t\t\t}\r\n return true;\r\n } : function(){\r\n if(self.state >= 0 && self.state <=1){\r\n defTracks[fnName][2].add.apply(self, Slc.call(arguments));\r\n }\r\n return self;\r\n } ;\r\n };\r\n\r\n let i = 0;\r\n let ax = keys.slice();\r\n let d;\r\n const promise = {};\r\n\r\n\r\n // using a closure to define all the functions on the fly...\r\n\r\n for(d in defTracks){\r\n if(Hop.call(defTracks, d)){\r\n keys.splice(i++, 1);\r\n self[d] = setter(d, keys);\r\n self[`${d}With`] = setter(d, []);\r\n promise[defTracks[d][0]] = setter(d, [], true);\r\n keys = ax.slice();\r\n }\r\n }\r\n\r\n promise.state = futuresStates.STARTED;\r\n\r\n promise.always = function(){\r\n return this.done.apply(self, arguments).fail.apply(self, arguments);\r\n };\r\n\r\n promise.promise = obj => {\r\n if(obj && typeof obj == \"object\" && !obj.length){\r\n for(const i in promise){\r\n if(Hop.call(promise, i)){\r\n obj[i] = promise[i];\r\n }\r\n }\r\n return obj;\r\n }\r\n return promise;\r\n };\r\n\r\n promise.then = function(/* fnDone, fnFail, fnProgress */){\r\n let ret;\r\n const args = [].slice.call(arguments);\r\n args.forEach((item, i) => {\r\n item = (typeof item == \"function\") && item;\r\n self[defTracks[keys[i]][0]](function(){\r\n\t\t\t\t\t\t\tlet rt;\r\n\t\t\t\t\t\t\ttry{ \r\n\t\t\t\t\t\t\t\t/*\r\n\t\t\t\t\t\t\t\t\tPromises/A+ specifies that errors should be contained\r\n\t\t\t\t\t\t\t\t\tand returned as value of rejected promise\r\n\t\t\t\t\t\t\t\t*/\r\n\t\t\t\t\t\t\t rt = item && item.apply(this, arguments);\r\n\t\t\t\t\t\t\t}catch(e){ \r\n\t\t\t\t\t\t\t rt = this.reject(e);\r\n\t\t\t\t\t\t\t}finally{\r\n\t\t\t\t\t\t\t if(rt && typeof rt.promise == \"function\")\r\n\t\t\t\t\t\t\t ret = rt.promise();\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t}\t \r\n });\r\n });\r\n return self.promise(ret);\r\n };\r\n\r\n promise.isResolved = () => !defTracks['reject'][2].hasList();\r\n promise.isRejected = () => !defTracks['resolve'][2].hasList();\r\n promise.pipe = promise.then;\r\n\r\n promise.promise(self);\r\n\r\n Futures.STARTED = futuresStates.STARTED;\r\n Futures.AWAITING = futuresStates.AWAIT;\r\n Futures.RESOLVED = futuresStates.RESOLVED;\r\n Futures.REJECTED = futuresStates.REJECTED;\r\n\r\n /* avoid leaking memory with each call to Futures constructor!! */\r\n setter = ax = d = i = null;\r\n\r\n /* enforce {new} on constructor */\r\n return (self instanceof Futures)? self : new Futures();\r\n};\r\n\r\nexport { Hop, Slc, isNullOrUndefined, wind, each, extend, curry, Futures }\r\n","import { wind } from './basics.js';\r\n\r\nlet __beforeunload = wind.onbeforeunload;\r\n\r\nlet __unload = wind.onunload;\r\n\r\nlet __hasDeactivated = false;\r\n\r\nlet _checkAndKillEventPropagation = event => {\r\n if(event.type === 'click'){\r\n if(event.stopPropagation){\r\n event.stopPropagation();\r\n }else{\r\n event.cancelBubble = true;\r\n }\r\n }\r\n};\r\n\r\nconst $createBeforeTearDownCallback = config => e => {\r\n \r\n // @See: https://greatgonzo.net/i-know-what-you-did-on-beforeunload/\r\n\r\n /* \r\n `lastActivatedNode` variable is used to track the DOM Node that last \r\n had focus (or was clicked) just before the browser triggered the `beforeunload` event \r\n */\r\n\r\n const lastActivatedNode = (wind.currentFocusElement // Mobile Browsers [ Custom Property ]\r\n || e.explicitOriginalTarget // old/new Firefox\r\n || (e.srcDocument && e.srcDocument.activeElement) // old Chrome/Safari\r\n || (e.currentTarget && e.currentTarget.document.activeElement) // Sarafi/Chrome/Opera/IE\r\n || e.srcElement\r\n || e.target);\r\n\r\n // if the \"imaginary\" user is logging out\r\n const leaveMessage = \"Are you sure you want to leave this page ?\";\r\n\r\n const isLogoff = ((typeof lastActivatedNode.hasAttribute == 'function' && lastActivatedNode.hasAttribute('data-href') && lastActivatedNode.getAttribute('data-href').includes(config.runtime.shutDownHref)) \r\n || (('href' in lastActivatedNode) && (lastActivatedNode.href.includes(config.runtime.shutDownHref))));\r\n\r\n const __timeOutCallback = () => {\r\n \r\n __hasDeactivated = __timeOutCallback.lock;\r\n\r\n };\r\n\r\n // console.log('Node: '+ lastActivatedNode);\r\n\r\n __timeOutCallback.lock = __hasDeactivated = true;\r\n beforeUnloadTimer = wind.setTimeout(__timeOutCallback, 0);\r\n\r\n if(isLogoff){ // IE/Firefox/Chrome 34+\r\n if(!!~e.type.indexOf('beforeunload')){\r\n e.returnValue = leaveMessage; \r\n }else{\r\n _confirm = wind.confirm && wind.confirm(leaveMessage);\r\n \r\n if(!_confirm){\r\n _checkAndKillEventPropagation(e);\r\n }\r\n }\r\n }else{\r\n _checkAndKillEventPropagation(e);\r\n }\r\n\r\n /* if (isLogoff) isn't true, no beforeunload dialog is shown */\r\n return ((isLogoff) ? ((__timeOutCallback.lock = false) || leaveMessage) : wind.clearTimeout(beforeUnloadTimer));\r\n};\r\n\r\nconst $createTearDownCallback = hub => e => {\r\n\r\n /*\r\n This seems to be the best way to setup the `unload` event \r\n listener to ensure that the load event is always fired even if the page\r\n is loaded from the `bfcache` (Back-Forward-Cache) of the browser whenever\r\n the back and/or forward buttons are used for navigation instead of links.\r\n Registering it as a property of the `window` object sure works every time\r\n */\r\n\r\n if(!__hasDeactivated){\r\n\r\n wind.setTimeout(() => {\r\n\r\n let appstate = {};\r\n \r\n hub.eachStore((store, next) => {\r\n\r\n const title = store.getTitle();\r\n\r\n appstate[title] = store.getState(); \r\n \r\n store.disconnect();\r\n store.destroy();\r\n\r\n next();\r\n\r\n });\r\n\r\n if(typeof hub._ping == \"function\"){\r\n\r\n hub._ping.call(hub, appstate);\r\n }\r\n\r\n if(e.type != 'click'){\r\n __unload(e);\r\n }\r\n\r\n }, 0);\r\n }\r\n};\r\n\r\nconst Values = {\r\n typesMap:{\r\n \"number\":Number,\r\n \"array\":Array,\r\n \"object\":Object,\r\n \"string\":String,\r\n \"boolean\":Boolean,\r\n \"date\":Date,\r\n \"regexp\":RegExp,\t\r\n \"function\":Function\r\n },\r\n isOfType(type, value) {\r\n\r\n var type = type.toLowerCase(); // hoisting\r\n\r\n if(typeof type === 'function'){\r\n\r\n return type(value);\r\n }\r\n\r\n else if(typeof type === 'string'\r\n && (type in this.typesMap)){\r\n return (/^string|function$/.test(typeof value)) \r\n || (Object(value) instanceof this.typesMap[type]);\r\n }\r\n\r\n return false;\r\n }\r\n};\r\n\r\n\r\n// Store Constructor\r\nconst Store = ((() => {\r\n\r\n\tlet requirementTypes = ['graph-ql', 'rest'];\r\n\r\n\tlet serviceRequirementsMap = {};\r\n\t\r\n\treturn function(title){\r\n\r\n\t\tconst that = this;\r\n\r\n\t\tthis.getTitle = () => title;\r\n\r\n\t\tthis.toJSON = () => ({\r\n title\r\n });\r\n\r\n\t\tthis.makeTrait = function(callback, ...argsLeft){\r\n\r\n if(typeof callback === 'function'){\r\n\r\n argsLeft.unshift(that);\r\n\r\n return callback(...argsLeft);\r\n }\r\n\r\n\t\t\t return null;\r\n\r\n\t\t};\r\n\r\n\t\tthis.toString = () => \"[object RadixxStore]\";\r\n\t}\t\r\n\r\n})());\r\n\r\n// Action constructor\r\nconst Action = ((() => function(id){\r\n\r\n this.getId = () => id;\r\n\r\n this.toJSON = () => ({\r\n id\r\n });\r\n\r\n this.toString = () => \"[object RadixxActionCreator]\";\r\n})());\r\n\r\n\r\nexport { Values, Store, Action, $createBeforeTearDownCallback, $createTearDownCallback }","import * as observable from './components/observable.js';\r\nimport { Action, Store } from './utils/routines/extras.js';\r\nimport Helpers from './utils/helpers.js';\r\nimport Payload from './utils/primitive-checkers.js'\r\n\r\n /*!\r\n * @lib: Radixx\r\n * @version: 0.1.2\r\n * @author: Ifeora Okechukwu\r\n * @created: 30/12/2016\r\n *\r\n * All Rights Reserved 2016 - 2018.\r\n * Use, reproduction, distribution, and modification of this code is subject to the terms and\r\n * conditions of the MIT license, available at http://www.opensource.org/licenses/mit-license.php\r\n *\r\n * @desc: Implementation of Facebooks' Flux Architecture with a Twist. [ ES6 ]\r\n */\r\n\r\n\r\nfunction toString(){\r\n\r\n return \"[object RadixxHub]\";\r\n}\r\n\r\nconst makeStore = function(dataTitle, registerCallback, defaultStateObj){\r\n \r\n function _store(...args){\r\n Store.apply(this, args);\r\n }\r\n\r\n const storeObject = new _store(dataTitle);\r\n\r\n observable.setStoreObserver(storeObject, registerCallback, defaultStateObj);\r\n\r\n return storeObject;\r\n}\r\n\r\nconst makeActionCreators = function(vectors){\r\n function _action(...args){\r\n Action.apply(this, args);\r\n }\r\n\r\n const actionObject = new _action(observable.registerAction());\r\n\r\n return observable.setActionVectors(actionObject, vectors);\r\n}\r\n\r\nconst purgePersistentStorage = function(){\r\n \r\n observable.purgePersistStore();\r\n}\r\n\r\nconst eachStore = function(callback){\r\n \r\n return observable.eachStore(callback, function(stores, key){\r\n\r\n this.push(stores[key]);\r\n }, null);\r\n}\r\n\r\nlet _hub = {\r\n eachStore\r\n};\r\n\r\n\r\nconst attachMiddleware = function(callback) {\r\n\r\n return observable.setMiddlewareCallback(callback);\r\n}\r\n\r\nconst isAppStateAutoRehydrated = function() {\r\n\r\n return observable.isAppStateAutoRehydrated();\r\n}\r\n\r\nconst onDispatch = function(handler){\r\n \r\n if(typeof handler === 'function'){\r\n\r\n observable.watchDispatcher(handler);\r\n }\r\n}\r\n\r\nconst configure = function(config) {\r\n \r\n return observable.mergeConfig(config, _hub);\r\n}\r\n\r\nconst onShutdown = function(handler){\r\n\r\n if(typeof handler === \"function\"){\r\n\r\n observable.setupShutdownCallback(handler, _hub);\r\n }\r\n\r\n}\r\n\r\nconst requestAggregator = function() {\r\n\r\n return observable.makeAggregator();\r\n}\r\n\r\nexport { Helpers, Payload, makeStore, makeActionCreators, purgePersistentStorage, isAppStateAutoRehydrated, requestAggregator, configure, eachStore, attachMiddleware, onDispatch, onShutdown, toString }\r\n","import { wind, isNullOrUndefined } from '../utils/routines/basics.js';\r\nimport { Dispatcher, Area } from './dispatcher.js';\r\nimport { Values } from '../utils/routines/extras.js';\r\n\r\n\r\n\t\tlet $instance = null;\r\n\r\n\t\tconst dispatchRegistry = {\r\n \r\n\t\t};\r\n\r\n\t\tconst getInstance = () => {\r\n\t\t\t\r\n\t\t\tif($instance === null){\r\n\r\n\t\t\t\t$instance = new Dispatcher();\r\n\t\t\t}\r\n\r\n\t\t\treturn $instance;\r\n\r\n\t\t};\r\n\r\n\t\tconst getObjectPrototype = obj => {\r\n\t\t\t\tif('getPrototypeOf' in Object){\r\n\t\t\t\t\treturn Object.getPrototypeOf(obj);\r\n\t\t\t\t}else if('__proto__' in obj){\r\n\t\t\t\t\tif(!(Hop.call(obj, '__proto__'))){\t\r\n\t\t\t\t\t\treturn (obj.__proto__);\r\n\t\t\t\t\t}\r\n\t\t\t\t}else if('constructor' in obj){\r\n\t\t\t\t\tif(!(Hop.call(obj, 'constructor'))){\t\r\n\t\t\t\t\t\treturn obj.constructor.prototype;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\treturn obj;\r\n\t\t};\r\n\r\n\t\tconst eachStore = function(fn, extractor, storeArray) {\r\n\r\n each(storeKeys, extractor.bind((storeArray = []), stores));\r\n\r\n let callable = fn;\r\n let prevIndex = storeArray.length - 1;\r\n\r\n const next = () => {\r\n\t\t\t\r\n\t\t\t\tlet returnVal;\r\n\r\n\t\t\t\tif(prevIndex >= 0){\t\r\n\t\t\t\t\treturnVal = Boolean(\r\n\t\t\t\t\t\tcallable.call(\r\n\t\t\t\t\t\t\t\tnull, \r\n\t\t\t\t\t\t\t\tstoreArray[prevIndex--], \r\n\t\t\t\t\t\t\t\tnext\r\n\t\t\t\t\t\t)\r\n\t\t\t\t\t);\r\n\t\t\t\t}else{\r\n\t\t\t\t\tcallable = !0;\r\n\t\t\t\t\treturnVal = callable;\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn returnVal;\r\n\t\t\t};\r\n\r\n next();\r\n };\r\n\r\n\t\tconst setActionVectors = function(object, vectors) {\r\n\r\n const _proto = getObjectPrototype(object);\r\n const dispatcher = getInstance();\r\n let vector = null;\r\n\r\n for(const creator in vectors){\r\n\t\t\t\tif(Hop.call(vectors, creator)){\r\n\t\t\t\t vector = vectors[creator];\t\r\n\t\t\t\t _proto[creator] = createActionInterface(dispatcher, vector);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n return object;\r\n };\r\n\r\n\t\tconst createStoreInterface = function(dispatcher, method) {\r\n\t\t\t\r\n\r\n\t\t\treturn function(){\r\n let regFunc;\r\n let area;\r\n const argument = arguments.length? arguments[0] : null;\r\n\r\n if(method == 'setChangeListener'){\r\n\r\n\t\t\t\t\treturn dispatcher.setStoreListener(this, argument);\r\n\t\t\t\t}\r\n\r\n if(method == 'unsetChangeListener'){\r\n\r\n\t\t\t\t\treturn dispatcher.unsetStoreListener(this, argument);\r\n\t\t\t\t}\r\n\r\n if(method == 'getState'){\r\n\r\n\t\t\t\t\tlet value;\r\n\t\t\t\t\tarea = new Area(this.getTitle());\r\n\t\t\t\t\tvalue = area.get();\r\n\t\t\t\t\tarea = null;\r\n\r\n\t\t\t\t\tif(value === area){\r\n\r\n\t\t\t\t\t\tregFunc = dispatcher.getRegistration(this.getTitle());\r\n\r\n\t\t\t\t\t\treturn (regFunc.$$history.length && regFunc.$$history[0]);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\treturn (typeof argument == 'string' && (argument in value)) ? value[argument] : value;\r\n\t\t\t\t}\r\n\r\n if(method == 'destroy'){\r\n\r\n\t\t\t\t\tlet title, index;\r\n\r\n\t\t\t\t\tif(title in stores){\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tdelete stores[title];\r\n\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tarea = new Area(this.getTitle());\r\n\r\n\t\t\t\t\tarea.del();\r\n\r\n\t\t\t\t\treturn (area = title = null);\r\n\t\t\t\t}\r\n\r\n if(method == 'disconnect'){\r\n\r\n\t\t\t\t\treturn dispatcher.unregister(this.getTitle());\r\n\t\t\t\t}\r\n\r\n if(method == 'hydrate'){\r\n\r\n\t\t\t\t\tif(isNullOrUndefined(argument)){\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\treturn dispatcher.signalUnique({\r\n\t\t\t\t\t\tsource:method,\r\n\t\t\t\t\t\ttarget:this.getTitle(),\r\n\t\t\t\t\t\tactionData:argument\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\r\n if(method == 'getQuerySchema'){\r\n\t\t\t\t\t\r\n\t\t\t\t\treturn {};\r\n\t\t\t\t}\r\n\r\n if(method == 'setQuerySchema'){\r\n\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\r\n if(method == 'canUndo'){\r\n\r\n\t\t\t\t\tregFunc = dispatcher.getRegistration(this.getTitle());\r\n\r\n\t\t\t\t\treturn (regFunc.$$historyIndex != 0);\r\n\t\t\t\t}\r\n\r\n if(method == 'swapCallback'){\r\n\r\n\t\t\t\t\treturn dispatcher.register(this.getTitle(), argument);\r\n\t\t\t\t}\r\n\r\n if(method == 'canRedo'){\r\n\t\t\t\t\t\r\n\t\t\t\t\tregFunc = dispatcher.getRegistration(this.getTitle());\r\n\r\n\t\t\t\t\treturn (regFunc.$$historyIndex !== regFunc.$$history.length - 1);\r\n\t\t\t\t}\r\n\r\n if(method == 'undo'){\r\n\r\n\t\t\t\t\treturn dispatcher.handleStoreMutation(this, method);\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t}\r\n\r\n if(method == 'redo'){\r\n\r\n\t\t\t\t\treturn dispatcher.handleStoreMutation(this, method);\r\n\r\n\t\t\t\t}\r\n }\r\n\t\t\t\r\n\t\t};\r\n\r\n\t\tconst createActionInterface = function(dispatcher, vector) {\r\n\t\t\t\r\n\t\t\tif(!(vector instanceof Object)){\r\n\r\n\t\t\t\tthrow new TypeError(`Invalid Action Creator Vector, expected [object] but found [${typeof(vector)}]`);\r\n\t\t\t}\r\n\r\n\t\t\treturn function(data, stateAspectKey){\r\n\r\n\t\t\t\t // console.log('OUTER-FUNC: ', this.constructor.caller);\r\n\r\n\t\t\t\tconst id = this.getId();\r\n\t\t\t\t\r\n\t\t\t\tlet typesBitMask = 0;\r\n\r\n\t\t\t\tif(!isNullOrUndefined(dispatchRegistry[id])){\r\n\t\t\t\t\tdispatchRegistry[id].actionTypes.push(\r\n\t\t\t\t\t\tvector\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tif(vector.actionDefinition instanceof Array){\r\n\t\t\t\t\t\r\n\t\t\t\t\teach(vector.actionDefinition, function(definition){\r\n\t\t\t\t\t\r\n\t\t\t\t\t\ttypesBitMask |= Number(Values.isOfType(definition, data));\r\n\t\r\n\t\t\t\t\t});\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(!typesBitMask){\r\n\t\t\t\t\t \r\n\t\t\t\t\t\tthrow new TypeError(`Action Data Invalid for action: [${vector.type}]`);\r\n\t\t\t\t \t}\r\n\t\t\t\t\r\n\t\t\t\t}else{\r\n\t\t\t\t\tif(!Values.isOfType(vector.actionDefinition, data)){\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tthrow new TypeError(`Action Data Invalid for action: [${vector.type}]`);\r\n\r\n\t\t\t\t\t}\t\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\treturn dispatcher.signal({\r\n\t\t\t\t\tsource:id,\r\n\t\t\t\t\tactionType:vector.type,\r\n\t\t\t\t\tactionKey:stateAspectKey || null,\r\n\t\t\t\t\tactionData:data\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t};\r\n\r\n\t\tconst watchDispatcher = function(callback) {\r\n\r\n\t\t\tconst dispatcher = getInstance();\r\n\r\n\t\t\tdispatcher.watch(callback);\r\n\t\t\t\t\t\r\n\t\t};\r\n\r\n\t\tconst isAppStateAutoRehydrated = function() {\r\n\r\n\t\t\tconst dispatcher = getInstance();\r\n\r\n\t\t\treturn dispatcher.getAutoRehydrationState();\r\n\r\n\t\t};\r\n\r\n\t\tconst setupShutdownCallback = function(callback, hub){\r\n\r\n\t\t\t\t\r\n\t\t\thub._ping = callback;\r\n\t\t\t\t\r\n\t\t};\r\n\r\n\t\tconst mergeConfig = function(userConfig, hub) {\r\n\r\n\t\t\tconst dispatcher = getInstance();\r\n\r\n\t\t\treturn dispatcher.initCatchers(userConfig, hub);\r\n\t\t};\r\n\r\n\t\tconst purgePersistStore = function() {\r\n\r\n\t\t\tdispatcher.deletePersistenceTagAndData();\r\n\r\n\t\t};\r\n\r\n\t\tconst registerAction = function() {\r\n\t\t\t/* creates hex value e.g. '0ef352ab287f1' */\r\n\t\t\tconst regId = Math.random().toString(16).substr(2, 13); \r\n\t\r\n\t\t\tdispatchRegistry[regId] = {actionTypes:[]};\r\n\r\n\t\t\treturn regId;\r\n\r\n\t\t};\r\n\r\n\t\tconst makeAggregator = function() {\r\n\r\n\t\t\t\treturn {\r\n\t\t\t\t\tnotifyAllStores() {\r\n\t\t\t\t\t\t/*\r\n\t\t\t\t\t\t*/\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\t\t};\r\n\r\n\t\tconst setMiddlewareCallback = function(middlewareFunc) {\r\n\r\n\t\t\tconst dispatcher = getInstance();\r\n\r\n\t\t\t// HERE: using this try/catch for control flow and not defensive programming\r\n\t\t\ttry{\r\n\r\n\t\t\t\tdispatcher.getMiddleware();\r\n\r\n\t\t\t}catch(ex){\r\n\r\n\t\t\t\tdispatcher.setMiddleware(\r\n\t\t\t\t\tmiddlewareFunc\r\n\t\t\t\t);\r\n\r\n\t\t\t}\r\n\r\n\t\t};\r\n\r\n\t\tconst setStoreObserver = function(object, regFunc, defaultStateObj) {\r\n \r\n if(typeof regFunc !== \"function\"){\r\n\t\t\t\treturn null;\r\n\t\t\t}\r\n\r\n const _proto = getObjectPrototype(object);\r\n const dispatcher = getInstance();\r\n const title = object.getTitle();\r\n let method = null;\r\n\r\n dispatcher.register(title, regFunc, defaultStateObj);\r\n\r\n const methods = [\r\n \t'setChangeListener', \r\n \t'unsetChangeListener', \r\n \t'getState', \r\n \t'disconnect', \r\n \t'getQuerySchema', \r\n \t'canRedo', \r\n \t'canUndo', \r\n \t'swapCallback', \r\n \t'undo', \r\n \t'redo', \r\n \t'hydrate', \r\n \t'destroy'\r\n \t];\r\n\r\n for(let c=0; c < methods.length; c++){\r\n\r\n\t\t\t\tmethod = methods[c];\r\n\t\t\t\t_proto[method] = createStoreInterface(dispatcher, method);\r\n\t\t\t}\r\n\t\t};\r\n\r\nexport { eachStore, makeAggregator, registerAction,setupShutdownCallback, mergeConfig, purgePersistStore, setStoreObserver, watchDispatcher, isAppStateAutoRehydrated, createStoreInterface, createActionInterface }","// shim for using process in browser\nvar process = module.exports = {};\n\n// cached from whatever global is present so that test runners that stub it\n// don't break things. But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals. It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\nfunction defaultSetTimout() {\n throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n throw new Error('clearTimeout has not been defined');\n}\n(function () {\n try {\n if (typeof setTimeout === 'function') {\n cachedSetTimeout = setTimeout;\n } else {\n cachedSetTimeout = defaultSetTimout;\n }\n } catch (e) {\n cachedSetTimeout = defaultSetTimout;\n }\n try {\n if (typeof clearTimeout === 'function') {\n cachedClearTimeout = clearTimeout;\n } else {\n cachedClearTimeout = defaultClearTimeout;\n }\n } catch (e) {\n cachedClearTimeout = defaultClearTimeout;\n }\n} ())\nfunction runTimeout(fun) {\n if (cachedSetTimeout === setTimeout) {\n //normal enviroments in sane situations\n return setTimeout(fun, 0);\n }\n // if setTimeout wasn't available but was latter defined\n if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n cachedSetTimeout = setTimeout;\n return setTimeout(fun, 0);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedSetTimeout(fun, 0);\n } catch(e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedSetTimeout.call(null, fun, 0);\n } catch(e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error\n return cachedSetTimeout.call(this, fun, 0);\n }\n }\n\n\n}\nfunction runClearTimeout(marker) {\n if (cachedClearTimeout === clearTimeout) {\n //normal enviroments in sane situations\n return clearTimeout(marker);\n }\n // if clearTimeout wasn't available but was latter defined\n if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n cachedClearTimeout = clearTimeout;\n return clearTimeout(marker);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedClearTimeout(marker);\n } catch (e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedClearTimeout.call(null, marker);\n } catch (e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.\n // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n return cachedClearTimeout.call(this, marker);\n }\n }\n\n\n\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n if (!draining || !currentQueue) {\n return;\n }\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = runTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n runClearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n runTimeout(drainQueue);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\nprocess.prependListener = noop;\nprocess.prependOnceListener = noop;\n\nprocess.listeners = function (name) { return [] }\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n","var g;\r\n\r\n// This works in non-strict mode\r\ng = (function() {\r\n\treturn this;\r\n})();\r\n\r\ntry {\r\n\t// This works if eval is allowed (see CSP)\r\n\tg = g || Function(\"return this\")() || (1, eval)(\"this\");\r\n} catch (e) {\r\n\t// This works if the window reference is available\r\n\tif (typeof window === \"object\") g = window;\r\n}\r\n\r\n// g can still be undefined, but nothing to do about it...\r\n// We return undefined, instead of nothing here, so it's\r\n// easier to handle this case. if(!global) { ...}\r\n\r\nmodule.exports = g;\r\n","import { wind, Hop, Futures, isNullOrUndefined, each, extend } from '../utils/routines/basics.js';\r\nimport { $createBeforeTearDownCallback, $createTearDownCallback } from '../utils/routines/extras.js';\r\n\r\n \r\ntry {\r\n const ce = new wind.CustomEvent('test');\r\n} catch(e) {\r\n\r\n CEvent.prototype = wind.Object.create(((w.Event && w.Event.prototype) || {}));\r\n wind.CustomEvent = null;\r\n wind.CustomEvent = CEvent;\r\n}\r\n\r\nconst persistStore = (wind.top !== wind || !wind.localStorage) ? null : wind.localStorage;\r\n\r\nconst sessStore = (wind.top !== wind || !wind.sessionStorage ? (wind.opera && !(Hop.call(wind, 'opera')) ? wind.opera.scriptStorage : {} ) : wind.sessionStorage);\r\n\r\nconst mode = wind.document.documentMode || 0;\r\n\r\nlet autoRehydrationOccured = false;\r\n\r\nlet config = null;\r\n\r\n const watchers = [\r\n\r\n];\r\n\r\n const stores = {\r\n\r\n};\r\n\r\n const storeKeys = [\r\n\r\n];\r\n\r\n const observers = {\r\n\r\n};\r\n\r\n const _promises = {\r\n\r\n};\r\n\r\n const waitQueue = [\r\n\r\n];\r\n\r\n const cachedStorageKeys = {\r\n\r\n};\r\n\r\nconst getAppOriginForPersist = cfg => String(wind.location.origin + (cfg.localHostDev ? ':'+wind.document.documentElement.id : ''));\r\n\r\nconst generateTag = origin => {\r\n\r\n\tconst _cdata = persistStore.getItem(origin);\r\n\t\r\n\tif(!isNullOrUndefined(_cdata)){\r\n\r\n\t\treturn getNormalized(_cdata);\r\n\t}\r\n\r\n\treturn String(Math.random()).replace('.','x_').substring(0, 11);\r\n};\r\n\r\nconst defaultConfig = {\r\n\t\truntime:{\r\n\t\t\tspaMode:true, \r\n\t\t\tshutDownHref:''\r\n\t\t},\r\n\t\tpersistenceEnabled:false,\r\n\t\tautoRehydrate:false,\r\n\t\tuniversalCoverage:false,\r\n\t\tlocalHostDev:false\r\n};\r\n\r\nconst triggerEvt = (target, eType, detail, globale) => {\r\n const evt = new CustomEvent(eType, {\r\n detail,\r\n cancelable:true,\r\n bubbles:false\r\n }); // a stub function - just in case\r\n\r\n let dispatch = () => false;\r\n\r\n if((!('target' in evt)) \r\n && evt.cancelBubble === true){\r\n\r\n target.setCapture(true);\r\n }\r\n\r\n // set up cross-browser dispatch method.\r\n dispatch = target[ (!('target' in evt) ? \"fireEvent\" : \"dispatchEvent\") ];\r\n\r\n // Including support for IE 8 here ;)\r\n return dispatch.apply(target, (!('target' in evt) ? [`on${eType}`, evt ] : [ evt ]));\r\n};\r\n\r\nconst operationOnStoreSignal = (fn, queueing, area, action) => { \r\n\r\n\t // first, retrieve the very first state data and cache it\r\n\t if(fn.$$history.length == 1 \r\n\t\t&& (!fn.$$initData)){\r\n\r\n\t \t\tfn.$$initData = fn.$$history[0];\r\n\t }\t\t\r\n\r\n\t // second, make sure that there is no future state to forth on\t\r\n\t fn.$$history = fn.$$history.slice(0, fn.$$historyIndex + 1);\r\n\t \r\n\t // lets setup a place to store new state, also mark out the context of this call\r\n\t let newStoreState = false, len, _key;\r\n\r\n\t // create a new state of the store data by applying a given\r\n\t // store callback function to the current history head\r\n\r\n\t if(queueing === null){\r\n\r\n\t \tif(action !== null){\r\n\r\n\t\t \tnewStoreState = action.actionData;\r\n\r\n\t\t }else{\r\n\r\n\t\t \tnewStoreState = fn.$$history[fn.$$historyIndex];\r\n\t\t }\r\n\r\n\t\t coverageNotifier.$$historyLocation = fn.$$historyIndex;\r\n\r\n\t }else{\r\n\t \t\r\n\t \tnewStoreState = fn.call(queueing, action, area.get());\r\n\r\n\t \tcoverageNotifier.$$historyLocation = null;\r\n\r\n\t }\r\n\r\n\t\tif(typeof newStoreState == 'boolean'\r\n\t\t\t|| newStoreState == undefined){\r\n\t\t\t\r\n\t\t\tthrow new TypeError(\"Radixx: Application State unavailable after signal to Dispatcher\");\t\t\r\n\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t_key = area.put(newStoreState);\r\n\r\n\t\tcoverageNotifier.$$currentStoreTitle = _key;\r\n\t \r\n\t if(action !== null){\r\n\r\n\t \tif(action.source !== 'hydrate'){\r\n \t\t\t\t;\r\n\t \t}\r\n\r\n\t \ttriggerEvt(\r\n\t\t\t\t\twind.document, \r\n\t\t\t\t\t'storesignal', \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\turl:wind.location.href,\r\n\t\t\t\t\t\tkey:_key,\r\n\t\t\t\t\t\tnewValue:newStoreState,\r\n\t\t\t\t\t\tsource:wind,\r\n\t\t\t\t\t\taspect:action.actionKey,\r\n\t\t\t\t\t\ttype:action.actionType\r\n\t\t\t\t\t}, \r\n\t\t\t\t\twind\r\n\t\t\t);\r\n\r\n\t \tcoverageNotifier.$$withAction = true;\r\n\r\n\t\t // add the new state to the history list and increment\r\n\t\t // the index to match in place\r\n\t\t len = fn.$$history.push(newStoreState); /* @TODO: use {action.actionType} as operation Annotation */\r\n\t\t \r\n\t\t fn.$$historyIndex++;\r\n\r\n\t\t if(fn.$$history.length > 21){ // can't undo/redo (either way) more than 21 moves at any time\r\n\r\n\t\t \t\tfn.$$history.unshift();\r\n\t\t }\r\n\r\n\t }else{\r\n\r\n\t \treturn newStoreState;\r\n \t}\r\n\t \r\n\t};\r\n\r\n const getNormalized = val => {\r\n\r\n\t \tif(isNullOrUndefined(val) || val === \"null\")\r\n\t \t\t return null;\r\n\r\n\t\ttry{\r\n\t\t\treturn JSON.parse(val);\r\n\t\t}catch(e){\r\n\t\t\treturn String(val);\r\n\t\t}\r\n\t};\r\n\r\n const setNormalized = val => {\r\n\r\n\t \tif(isNullOrUndefined(val)) \r\n\t \t\tval = null;\r\n\r\n\t\ttry{\r\n\t\t\treturn JSON.stringify(val);\r\n\t\t}catch(e){\r\n\r\n\t\t\treturn String(val);\r\n\t\t}\r\n\t};\r\n\r\n\tconst getCurrentActionOnStack = () => {\r\n\r\n\t\tconst actionStack = operationOnStoreSignal.$$redoActionsStack;\r\n\r\n\t\tif(actionStack.lenth){\r\n\t\t\treturn actionStack[actionStack.length - 1];\r\n\t\t}\r\n\r\n\t\treturn null;\r\n\t};\r\n\r\n const coverageNotifier = appState => {\r\n\t \r\n let currentAction = null;\r\n\t \r\n const _tag = coverageNotifier.$$tag;\r\n\r\n if(arguments.callee.$$withAction === true){\r\n\t\t\tcurrentAction = getCurrentActionOnStack();\r\n\t\t\targuments.callee.$$withAction = null;\r\n\t\t}\r\n\r\n if(!isNullOrUndefined(_tag)\r\n\t\t\t&& (persistStore !== null)){\r\n\r\n\t\t\tpersistStore.setItem(_tag, setNormalized({\r\n\t\t\t\t\t\tstate:appState, \r\n\t\t\t\t\t\taction:currentAction,\r\n\t\t\t\t\t\ttitle:arguments.callee.$$currentStoreTitle, \r\n\t\t\t\t\t\thistoryLoc:arguments.callee.$$historyLocation\r\n\t\t\t}));\r\n\r\n\t\t\targuments.callee.$$historyLocation = null;\r\n\t\t}\r\n };\r\n\r\n const fireWatchers = (state, omitCallback) => {\r\n\r\n\t\tlet pos, watcher;\r\n\r\n\t\tfor(pos in watchers){\r\n\t\t\tif(Hop.call(watchers, pos)){\r\n\t\t\t\twatcher = watchers[pos];\r\n\t\t\t\tif(omitCallback){\r\n\t\t\t\t\tif(watcher.$$canOmit){\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t};\r\n\t\t\t\t}\r\n\t\t\t\twatcher.call(null, state);\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\r\n\tconst setAppState = appState => {\r\n\r\n\t\t\teach(appState, (isolatedState, storeTitle) => {\r\n\r\n\t\t\t\tconst area = new Area(storeTitle);\r\n\r\n\t\t\t\tarea.put(isolatedState);\r\n\t\t\t\r\n\t\t\t});\r\n\r\n\t\t\tfireWatchers(appState, true);\r\n\t};\r\n\r\n const getAppState = () => {\r\n\r\n\t const appStateData = {};\r\n\t let key;\r\n\t let indexStart;\r\n\t let indexEnd;\r\n\t let values;\r\n\t let _data;\r\n\r\n\t if(('key' in sessStore) \r\n\t && (typeof sessStore.key == 'function')){\r\n\r\n\t // We iterate this way so we can support IE 8 + other browsers\r\n\t for(var i=0; i < sessStore.length; i++){\r\n\t key = sessStore.key(i);\r\n\t _data = sessStore.getItem(key);\r\n\t \r\n\t if(!_data){\r\n\t ;\r\n\t }\r\n\r\n\t appStateData[key] = getNormalized(_data) || null;\r\n\t }\r\n\t }else{\r\n\t \r\n\t \r\n\t for(var i = 0; i < storeKeys.length; i++){\r\n\t \r\n\t key = storeKeys[i];\r\n\t \r\n\t if(cachedStorageKeys[key]){\r\n\r\n\t indexStart = wind.name.indexOf(key);\r\n\r\n\t indexEnd = wind.name.indexOf('|', indexStart);\r\n\r\n\t values = (wind.name.substring(indexStart, indexEnd)).split(':=:') || [\"\", null];\r\n\r\n\t _data = values[1];\r\n\r\n\t }\r\n\r\n\t appStateData[key] = getNormalized(_data) || null;\r\n\t }\r\n\t }\r\n\r\n\t return appStateData;\r\n\t};\r\n\r\n\tconst handlePromises = () => {\r\n let promise = null;\r\n const state = getAppState();\r\n\r\n for(const title in _promises){\r\n\t\t\tif(Hop.call(_promises, title)){\r\n\t\t\t\tpromise = _promises[title];\r\n\t\t\t\tif(!promise.isResolved()){\r\n\t\t\t\t\tpromise.resolve();\r\n\t\t\t\t}\r\n\t\t\t\tdelete _promises[title];\r\n\t\t\t}\r\n\t\t}\r\n\r\n waitQueue.length = 0;\r\n\r\n fireWatchers(state);\r\n };\r\n\r\n\tconst enforceCoverage = e => {\r\n\r\n const _origin = arguments.callee.$$origin;\r\n const _tag = arguments.callee.$$tag;\r\n let _action = null;\r\n let _state = null;\r\n let _title = null;\r\n let _hloc = null;\r\n let _composedData = null;\r\n let observer = null;\r\n\r\n // Detecting IE 8 to apply mild hack on event object\r\n if(('remainingSpace' in sessStore)){\r\n\t\t\te.key = e.detail.key;\r\n\t\t}\r\n\r\n if(!persistStore\r\n\t\t\t|| _origin === e.key){ // if we can't find the key in the array `storeKeys`\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n _composedData = getNormalized(persistStore.getItem(_tag));\r\n\r\n if(_tag === e.key\r\n\t\t\t&& isNullOrUndefined(_composedData)){\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n _state = _composedData.state;\r\n\r\n _action = _composedData.action;\r\n\r\n _title = _composedData.title;\r\n\r\n _hloc = parseInt(_composedData.historyLoc);\r\n\r\n if(_action !== null){\r\n\t\t\toperationOnStoreSignal.$$redoActionsStack.push(_action);\r\n\t\t}\r\n\r\n if(_hloc !== null){\r\n\t\t\tobserver = observers[_title];\r\n\t\t\tif(observer){\r\n\t\t\t\tobserver.$$historyIndex = _hloc;\r\n\t\t\t\tif(_hloc === -1){\r\n\t\t\t\t\tobserver.$$history.length = 0;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n if(_state){\r\n\t\t\tsetTimeout(\r\n\t\t\t\tsetAppState.bind(null, _state)\r\n\t\t\t, 0); \r\n\t\t}\r\n };\r\n\r\n\tconst stateWatcher = e => {\r\n\r\n\t\te = e || wind.event;\r\n\r\n\t\tif(storeKeys.includes(e.detail.key)){\r\n const storeTitle = e.detail.key;\r\n let listeners;\r\n\r\n if(!isNullOrUndefined(observers[storeTitle])){\r\n\r\n\t\t\t\tlisteners = observers[storeTitle].$$store_listeners;\r\n\r\n\t\t\t\tfor(let t=0; t < listeners.length; t++){\r\n\t\t\t\t\t\t \t\t\t\r\n\t\t\t\t\tlisteners[t].call(stores[storeTitle], e.detail.type, e.detail.aspect);\r\n\t\t\t\t\t\t \r\n\t\t\t\t}\r\n\t\t\t}\r\n }\r\n\t};\r\n\r\n\t/**\r\n\t Though IE 9 to IE 11 supports the CustomEvent constructor, IE throws an error {Object doesn't support this action} \r\n\t whenever it's used. This weird behaviour is fixed below\r\n\t See: https://stackoverflow.com/questions/14358599/object-doesnt-support-this-action-ie9-with-customevent-initialization\r\n\t*/\r\n\r\n\tfunction CEvent ( event, params ) {\r\n\t let t;\r\n\t let evt;\r\n\t let d = wind.document;\r\n\t params = params || { bubbles: false, cancelable: false, detail: undefined };\r\n\t \r\n\t try{\r\n\t\t\t evt = d.createEvent( 'CustomEvent' );\r\n\t\t\t evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );\r\n\t\t\t}catch(e){\r\n\t\t\t evt = d.createEventObject(w.event);\r\n\t\t\t\t evt.cancelBubble = !params.bubbles;\r\n\t evt.returnValue = !params.cancelable;\r\n\t\t\t\t\r\n\t if(typeof params.detail === \"object\"){\r\n\t\t\t\t\t // set expando properties on event object\r\n\t\t\t\t\t\r\n\t /*for(t in params.detail){\r\n\t if((({}).hasOwnProperty.call(params.detail, t))){\r\n\t evt[t] = params.detail[t];\r\n\t }\r\n\t }*/\r\n\t\t\t\t\t evt.detail = params.detail;\r\n\t\t\t\t }\t\r\n\t\t\t}\r\n\t \r\n\t return evt;\r\n\t}\r\n\r\n\tfunction setupConfigSettings(config, hub){\r\n\r\n\t\t \tif(config.universalCoverage){\r\n\r\n\t\t \t\tconfig.persistenceEnabled = true;\r\n\t\t \t}\r\n\r\n\t\t \tif(config.persistenceEnabled){\r\n\r\n\t\t\t\t\t// prepare Origin \r\n\t\t\t\t\tconst _origin = getAppOriginForPersist(config);\r\n\r\n\t\t\t\t\tconst _tag = generateTag(_origin);\r\n\r\n\t\t\t\t\tpersistStore.setItem(_origin, _tag);\r\n\r\n\t\t\t\t\tenforceCoverage.$$origin = _origin;\r\n\r\n\t\t\t\t\tenforceCoverage.$$tag = _tag;\r\n\r\n\t\t\t\t\tcoverageNotifier.$$canOmit = true;\r\n\r\n\t\t\t\t\tcoverageNotifier.$$tag = _tag;\r\n\r\n\t\t\t\t\thub.onDispatch(coverageNotifier);\r\n\t\t\t}\r\n\r\n if(config.autoRehydrate === true){\r\n\t\t \r\n\t\t\t \tlet data = null;\r\n\t \r\n\t if(!isNullOrUndefined(enforceCoverage.$$tag) \r\n\t && persistStore){\r\n\t \tdata = getNormalized(persistStore.getItem(enforceCoverage.$$tag));\r\n\t\t\t \t}\r\n\t\t\t \r\n\t\t\t \tif(data instanceof Object \r\n\t && data.state){\r\n\t setAppState(data.state);\r\n\t this.updateAutoRehydrationState();\r\n \t}\r\n }\r\n\r\n\t\t\tif(!config.runtime.spaMode){\r\n\t\t\t\t\r\n\t\t\t\tif(typeof config.runtime.shutDownHref === 'string'\r\n\t\t\t\t\t&& config.runtime.shutDownHref.length != 0){\r\n\r\n\t\t\t\t\twind.onbeforeunload = $createBeforeTearDownCallback(config);\r\n\t\t\t\t\r\n\t\t\t\t\twind.onunload = $createTearDownCallback(hub);\r\n\t\t\t\t}\r\n\t\t\t}else{\r\n\r\n\t\t\t\tif(typeof config.runtime.shutDownHref === 'string'\r\n\t\t\t\t\t&& config.runtime.shutDownHref.length != 0){\r\n\r\n\t\t\t\t\tif(wind.addEventListener){\r\n\t\t\t\t\t\twind.document.documentElement.addEventListener('click', $createBeforeTearDownCallback(config), false);\r\n\t\t\t\t\t\twind.document.addEventListener('click', $createTearDownCallback(hub), false);\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\twind.document.documentElement.attachEvent('onclick', $createBeforeTearDownCallback(config));\r\n\t\t\t\t\t\twind.document.attachEvent('onclick', $createTearDownCallback(hub), false);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\r\n\t}\r\n\r\n\tconst Area = function(key){\r\n\r\n\t\t\tthis.put = value => {\r\n\t \r\n\t\t\t\t/* \r\n\t\t\t\t\tIn IE 8-9, writing to sessionStorage is done asynchronously (other browsers write synchronously)\r\n\t\t\t\t\twe need to fix this by using IE proprietary methods \r\n\t\t\t\t\tSee: https://www.nczonline.net/blog/2009/07/21/introduction-to-sessionstorage/ \r\n\t\t\t\t*/\r\n\r\n \t\tlet indexStart;\r\n\r\n \t\tlet indexEnd;\r\n\t\t\r\n \t\tconst isIE8Storage = ('remainingSpace' in sessStore) && (mode === 8);\r\n\r\n\t \t\t// Detecting IE 8 to enable forced sync\r\n\t\t\t\tif(isIE8Storage){\r\n\t\t\t\t\tif(typeof sessStore.begin == 'function'){\r\n\t\t\t\t\t\tsessStore.begin();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n \t\ttry{\r\n\r\n\t\t\t\t\tsessStore.setItem(key, setNormalized(value));\r\n\t\t\t\t\t\r\n\t\t\t\t}catch(e){\r\n\t\t\t\t\t\r\n\t\t\t\t\t/* This is a fallback to support Opera Mini 4.4+ on Mobile */\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(cachedStorageKeys[key]){\r\n\t\t\t\t\t\t// we're in overwrite mode, so clear `key` out and push in update (below)\r\n\t\t\t\t\t\tindexStart = wind.name.indexOf(key);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tindexEnd = wind.name.indexOf('|', indexStart);\r\n\r\n\t\t\t\t\t\twind.name = wind.name.replace(wind.name.substring(indexStart, indexEnd), '');\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif(wind.name === \"\"){\r\n\r\n\t\t\t\t\t\twind.name = `${key}:=:${setNormalized(value)}|`;\r\n\r\n\t\t\t\t\t}else{\r\n\r\n\t\t\t\t\t\twind.name += `${key}:=:${setNormalized(value)}|`;\r\n\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\tcachedStorageKeys[key] = 1;\r\n\t\t\t\t}\r\n\r\n \t\tif(isIE8Storage){\r\n\t\t\t\t\tif(typeof sessStore.commit == 'function'){\r\n\t\t\t\t\t\tsessStore.commit();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t return key;\r\n\t };\r\n\r\n\t\t\tthis.get = () => {\r\n\r\n\t\t\t\tlet indexStart, indexEnd, values;\r\n\t\t\t\t\r\n\t\t\t\t/* This is a fallback to support Opera Mini 4.4+ on Mobile */\r\n\t\t\t\t\r\n\t\t\t\ttry{\r\n\t\t\t\t\r\n\t\t\t\t\treturn getNormalized(sessStore.getItem(key)) || null;\r\n\t\t\t\t\t\r\n\t\t\t\t}catch(e){\r\n\t\t\t\t\r\n\t\t\t\t\tif(cachedStorageKeys[key]){\r\n\r\n\t\t\t\t\t\tindexStart = wind.name.indexOf(key);\r\n\r\n\t\t\t\t\t\tindexEnd = wind.name.indexOf('|', indexStart);\r\n\r\n\t\t\t\t\t\tvalues = (wind.name.substring(indexStart, indexEnd)).split(':=:') || [0, 0];\r\n\r\n\t\t\t\t\t\treturn getNormalized(values[1]) || null;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\treturn null;\r\n\t\t\t\t\t\r\n\t\t\t\t}\r\n\t\t\t};\r\n\r\n\t\t\tthis.del = () => {\r\n\r\n\t\t\t\t\tlet indexStart;\r\n\r\n\t\t\t\t\tlet indexEnd;\r\n\t\t\t\t\t/* This is a fallback to support Opera Mini 4.4+ on Mobile */\r\n\t\t\t\t\r\n\t\t\t\t\ttry{\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn sessStore.removeItem(key);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t}catch(e){\r\n\t\t\t\t\r\n\t\t\t\t\t\tif(cachedStorageKeys[key]){\r\n\r\n\t\t\t\t\t\t\t// we're in delete mode\r\n\t\t\t\t\t\t\tindexStart = wind.name.indexOf(key);\r\n\r\n\t\t\t\t\t\t\tindexEnd = wind.name.indexOf('|', indexStart);\r\n\r\n\t\t\t\t\t\t\twind.name = wind.name.replace(wind.name.substring(indexStart, indexEnd), '');\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tdelete cachedStorageKeys[key];\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t}\r\n\t\t\t};\r\n\r\n\t\t\treturn this;\r\n\t};\r\n\r\n\tclass Dispatcher {\r\n\r\n\t\tconstructor() {\r\n\r\n \tthis.middlewares = [];\r\n\r\n \toperationOnStoreSignal.$$undoActionsStack = [];\r\n\r\n \toperationOnStoreSignal.$$redoActionsStack = [];\r\n }\r\n\r\n updateAutoRehydrationState() {\r\n \r\n \tautoRehydrationOccured = true;\r\n }\r\n\r\n getAutoRehydrationState() {\r\n \r\n \treturn autoRehydrationOccured;\r\n }\r\n\r\n setMiddleware(middleware) {\r\n \r\n if(typeof middleware === 'function'\r\n /*&& (middleware.length >= 2)*/){\r\n\r\n return this.middlewares.push(middleware);\r\n }\r\n\r\n throw new Error(\"Radixx: Inavlid Middleware Callback - Must be a Function with Parameters ( >= 2 )\");\r\n\r\n }\r\n\r\n hasMiddleware() {\r\n \r\n return (this.middlewares.length > 0);\r\n\r\n }\r\n\r\n initCatchers(userConfig, hub) {\r\n\r\n \t\tif(isNullOrUndefined(config)){\r\n\r\n\t\t\t\t\tconfig = extend(userConfig, defaultConfig);\r\n\r\n\t\t\t\t\tsetupConfigSettings.apply(this, [config, hub]);\r\n \t\t}\r\n\r\n if(wind.document.addEventListener){\r\n /* IE 9+, W3C browsers all expect the 'storage' event to be bound to the window */\r\n if(config.universalCoverage){\r\n wind.addEventListener('storage', enforceCoverage, false);\r\n }\r\n\r\n wind.document.addEventListener('storesignal', stateWatcher, false);\r\n\r\n }else if(wind.document.attachEvent){\r\n /* IE 8 expects the 'storage' event handler to be bound to the document \r\n and not to the window */\r\n if(config.universalCoverage){\r\n wind.document.attachEvent('onstorage', enforceCoverage);\r\n }\r\n\r\n wind.document.attachEvent('onstoresignal', stateWatcher);\r\n }\r\n\r\n }\r\n\r\n getRegistration(title) {\r\n\r\n\t if(Hop.call(observers, title)){\r\n\t \r\n\t return observers[title];\r\n\t }\r\n\r\n\t return {};\r\n\t\t}\r\n\r\n\t\tregister(title, observer, defaultStoreContainer) {\r\n \r\n if(Hop.call(observers, title)){\r\n \r\n if('$$history' in observers[title]\r\n && typeof observer.$$history == 'undefined'){\r\n if(!stores[title]){ // If the store doesn't have any change listeners registered\r\n \r\n throw new Error(\"Radixx: Cannot Overwrite existing store registration\");\r\n \r\n return;\r\n }\r\n\r\n observer.$$history = observers[title].$$history;\r\n observer.$$historyIndex = observers[title].$$historyIndex;\r\n observer.$$store_listeners = observers[title].$$store_listeners;\r\n observers[title] = observer;\r\n }\r\n }else{\r\n\r\n observer.$$store_listeners = [];\r\n observer.$$history = [(\r\n !!defaultStoreContainer ? \r\n defaultStoreContainer :\r\n []\r\n )];\r\n observer.$$historyIndex = 0;\r\n observers[title] = observer;\r\n storeKeys.push(title);\r\n }\r\n \r\n return true;\r\n }\r\n\r\n watch(callback) {\r\n\r\n watchers.push(callback);\r\n }\r\n\r\n setStoreListener(store, callback) {\r\n\r\n \tconst title = store.getTitle();\r\n\r\n\t if(!isNullOrUndefined(observers[title])){\r\n\r\n\t if(typeof callback == \"function\"){\r\n\t stores[title] = store;\r\n\t observers[title].$$store_listeners.push(callback);\r\n\t }\r\n\t }\r\n }\r\n\r\n unsetStoreListener(store, callback) {\r\n\r\n\t const title = store.getTitle();\r\n\r\n\t if(!isNullOrUndefined(observers[title])){\r\n\t if(typeof callback == \"function\"){\r\n\r\n\t const pos = observers[title].$$store_listeners.indexOf(callback);\r\n\t observers[title].$$store_listeners.splice(pos, 1);\r\n\t }\r\n\t }\r\n\r\n }\r\n\r\n signalUnique(hydrateAction) {\r\n\r\n\t if(hydrateAction.source != 'hydrate'){\r\n\t return;\r\n\t }\r\n\r\n\t // Pass this on to the event queue [await]\r\n\t wind.setTimeout(handlePromises, 0);\r\n\r\n\t const stateArea = new Area(hydrateAction.target), regFunc = observers[hydrateAction.target];\r\n\r\n\t operationOnStoreSignal.$$redoActionsStack.length = 0;\r\n\r\n\t operationOnStoreSignal.$$redoActionsStack.push(hydrateAction);\r\n\r\n\t regFunc.$$history.length = 0; // clear out the store state since this is a hydrate call\r\n\r\n\t regFunc.historyIndex = -1;\r\n\r\n\t operationOnStoreSignal(...[\r\n\t\t\t\t\tregFunc, \r\n\t\t\t\t\tnull, \r\n\t\t\t\t\tstateArea,\r\n\t\t\t\t\thydrateAction\r\n\t\t\t\t]);\r\n\r\n }\r\n\r\n handleStoreMutation(store, mutationType) {\r\n\r\n\t if(!mutationType){\r\n\t return;\r\n\t }\r\n\r\n\t const storeTitle = store.getTitle();\r\n\t const isolatedState = {}; \r\n\t const regFunc = this.getRegistration(storeTitle);\r\n\t const stateArea = new Area(storeTitle);\r\n\r\n\t switch(mutationType){\r\n\r\n\t case 'undo':\r\n\t if(store.canUndo()){\r\n\t \r\n\t --regFunc.$$historyIndex;\r\n\r\n\t isolatedState[storeTitle] = operationOnStoreSignal(...[\r\n\t\t\t\t\t\t\t\t\tregFunc,\r\n\t\t\t\t\t\t\t\t\tnull,\r\n\t\t\t\t\t\t\t\t\tstateArea,\r\n\t\t\t\t\t\t\t\t\tnull\r\n\t\t\t\t\t\t\t\t]); \r\n\r\n\t // Pass this on to the event queue \r\n\t wind.setTimeout(fireWatchers.bind(null, isolatedState), 0);\r\n\r\n\t return true;\r\n\t }\r\n\t break;\r\n\t case 'redo':\r\n\t if(store.canRedo()){\r\n\r\n\t ++regFunc.$$historyIndex;\r\n\r\n\t isolatedState[storeTitle] = operationOnStoreSignal(...[\r\n\t\t\t\t\t\t\t\t\tregFunc,\r\n\t\t\t\t\t\t\t\t\tnull,\r\n\t\t\t\t\t\t\t\t\tstateArea,\r\n\t\t\t\t\t\t\t\t\tnull\r\n\t\t\t\t\t\t\t\t]);\r\n\r\n\t // Pass this on to the event queue \r\n\t wind.setTimeout(fireWatchers.bind(null, isolatedState), 0);\r\n\r\n\t return true;\r\n\r\n\t }\r\n\t break;\r\n\t }\r\n\r\n\t return false;\r\n }\r\n\r\n deletePersistenceTagAndData(){\r\n\r\n \tif(isNullOrUndefined(config)){\r\n\r\n \t\treturn false;\r\n \t}\r\n\r\n \tconst _origin = getAppOriginForPersist(config);\r\n\r\n\t\t\tconst _tag = generateTag(_origin);\r\n\r\n\t\t\tpersistStore.removeItem(_origin);\r\n\r\n\t\t\tpersistStore.removeItem(_tag);\r\n\r\n\t\t\treturn true;\r\n }\r\n\r\n rebuildStateFromActions() {\r\n\r\n\t const actionsStack = operationOnStoreSignal.$$redoActionsStack;\r\n\r\n\t each(actionsStack, (action, index) => {\r\n\r\n\t let stateArea;\r\n\r\n\t for(title in observers){\r\n\t if(Hop.call(observers, title)){\r\n\r\n\t stateArea = new Area(title);\r\n\r\n\t observers[title].call(action, stateArea.get());\r\n\t }\r\n\t }\r\n\r\n\t }, operationOnStoreSignal);\r\n }\r\n\r\n signal(action) {\r\n\r\n\t let compactedFunc = null;\r\n\r\n\t const // this is the function that does the actual dispatch of the \r\n\t baseDispatcher = (observers, dispatcher, action, prevState) => {\r\n\r\n\t\t\t\t\t\tlet title, stateArea = null; \r\n\r\n\t\t\t\t\t\toperationOnStoreSignal.$$redoActionsStack.push(action);\r\n\r\n\t\t\t\t\t\tfor(title in observers){\r\n\t\t\t\t\t\t\tif(Hop.call(observers, title)){\r\n\r\n\t\t\t\t\t\t\t\tstateArea = new Area(title);\r\n\r\n\t\t\t\t\t\t\t\toperationOnStoreSignal(...[\r\n\t observers[title], \r\n\t dispatcher.queueing, \r\n\t stateArea,\r\n\t action\r\n\t ]);\r\n\t\t\t\t\t\t\t}\t\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\treturn getAppState();\r\n\t\t\t\t};\r\n\r\n\t const boundBaseDispatcher = baseDispatcher.bind(null, observers, this);\r\n\r\n\t const adjoiner = {\r\n\t /*createActionObject:function(_data, _type){\r\n\t \r\n\t return {\r\n\t source:\"\",\r\n\t actionType:_type,\r\n\t actionData:_data,\r\n\t actionKey:null\r\n\t };\r\n\t },*/\r\n\t createDispatchResolver(_action) {\r\n\r\n\t return boundBaseDispatcher.bind(null, _action);\r\n\t }\r\n\t };\r\n\r\n\t const _hasMiddleware = this.hasMiddleware();\r\n\r\n\r\n\t // Some validation - just to make sure everything is okay\r\n\t if(!(action.source in dispatchRegistry)){\r\n\r\n\t return;\r\n\t }\r\n\r\n\t // determine if there are middleware callbacks registered\r\n\t if(_hasMiddleware){ \r\n\t \r\n\t // collapse all middleware callbacks into a single callback\r\n\t compactedFunc = this.middlewares.concat(\r\n\t boundBaseDispatcher\r\n\t ).reduceRight((bound, middleware) => middleware.bind(null,\r\n\t bound\r\n\t ));\r\n\r\n\t }else {\r\n\r\n\t compactedFunc = boundBaseDispatcher;\r\n\t }\r\n\r\n\t // Pass this on to the event queue \r\n\t wind.setTimeout(handlePromises, 0);\r\n\r\n\t // begin cascading calls to the middlewares in turn\r\n\t // from the last attached middleware all the way up\r\n\t // to the first middleware until the action\r\n\t // is finally dispatched\r\n\r\n\t if(!isNullOrUndefined(compactedFunc)){\r\n\r\n\t compactedFunc.apply(_hasMiddleware ? adjoiner : null, [action, getAppState()]);\r\n\r\n\t }\r\n\t\t}\r\n\r\n\t\tunregister(title) {\r\n\r\n\t let observer, store, index;\r\n\r\n\t if(!isNullOrUndefined(observers[title])){\r\n\t // initial clean-up\r\n\r\n\t observer = observers[title];\r\n\t store = stores[title];\r\n\t observer.$$store_listeners.length = 0;\r\n\t observer.$$store_listeners = null;\r\n\t observer.$$historyIndex = -1;\r\n\t observer.$$history.length = 0;\r\n\t observer.$$history = null;\r\n\t \r\n\t // more clean-up (freeing memory)\r\n\t delete observers[title];\r\n\t observer = null;\r\n\t \r\n\t delete stores[title];\r\n\t store = null;\r\n\r\n\t index = storeKeys.indexOf(title);\r\n\r\n\t if(index != -1){\r\n\t storeKeys.splice(index, 1);\r\n\t }\r\n\t }\r\n\t\t}\r\n\r\n\t} \r\n\r\nexport { Dispatcher, Area }","import { wind } from './routines/basics.js';\r\n\r\nexport const Helpers = {\r\n isEqual(former, latter) {\r\n if (former === latter) {\r\n return true;\r\n }\r\n\r\n if (typeof former !== 'object' || former === null ||\r\n typeof latter !== 'object' || latter === null) {\r\n return false;\r\n }\r\n\r\n const keysA = wind.Object.keys(former);\r\n const keysB = wind.Object.keys(latter);\r\n\r\n if (keysA.length !== keysB.length) {\r\n return false;\r\n }\r\n\r\n // Test for A's keys different from B.\r\n const bHasOwnProperty = wind.hasOwnProperty.bind(latter);\r\n for (let i = 0; i < keysA.length; i++) {\r\n if (!bHasOwnProperty(keysA[i]) || former[keysA[i]] !== latter[keysA[i]]) {\r\n return false;\r\n }\r\n }\r\n }\r\n};\r\n","import { wind } from './routines/basics.js';\r\n\r\nexport const Payload = {\r\n type:{\r\n \"array\":\"array\",\r\n \"date\":\"date\",\r\n \"string\":\"string\",\r\n \"regexp\":\"regexp\",\r\n \"boolean\":\"boolean\",\r\n \"function\":\"function\",\r\n \"object\":\"object\",\r\n \"number\":\"number\",\r\n error(value) {\r\n\r\n return (value instanceof wind.Error || value instanceof wind.TypeError);\r\n },\r\n nullable(value) {\r\n\r\n return (value === null || value === undefined);\r\n },\r\n \"numeric\":{\r\n Int(value) {\r\n return wind.isFinite(value) && (value === wind.parseInt(value))\r\n },\r\n Float(value) {\r\n return wind.isFinite(value) && (value === wind.parseFloat(value))\r\n }\r\n },\r\n any(value) {\r\n \r\n return (value !== null || value !== undefined);\t \t\t\t\r\n }\r\n }\r\n};\r\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/radixx.min.js b/dist/radixx.min.js index c509bce..6954cd2 100644 --- a/dist/radixx.min.js +++ b/dist/radixx.min.js @@ -11,15 +11,5 @@ * @desc: Implementation of Facebooks' Flux Architecture with a Twist. */ - /** - * - * When using with TypeScript in the `tsconfig` - * - * { - "compilerOptions": { - "module": "es2015", - "allowSyntheticDefaultImports": true - } - } - */ + !function(t,e){"use strict";"object"==typeof exports&&"object"==typeof module?module.exports=e(t):"function"==typeof define&&define.amd?define("Radixx",[],function(){return e(t)}):"object"==typeof exports?exports.Radixx=e(t):t.Radixx=e(t)}("undefined"!=typeof process&&"[object process]"==={}.toString.call(process)||"undefined"!=typeof navigator&&"ReactNative"===navigator.product?global:"undefined"!=typeof window?window:self,function(t,e){var n={}.hasOwnProperty,r=(t.onbeforeunload,t.onunload),i=!1,o=function(t){},a=function(t){"click"===t.type&&(t.stopPropagation?t.stopPropagation():t.cancelBubble=!0)},c=function(t){return function(e){var n=window.currentFocusElement||e.explicitOriginalTarget||e.srcDocument&&e.srcDocument.activeElement||e.currentTarget&&e.currentTarget.document.activeElement||e.srcElement||e.target,r="Are you sure you want to leave this page ?",o="function"==typeof n.hasAttribute&&n.hasAttribute("data-href")&&n.getAttribute("data-href").indexOf(t.runtime.shutDownHref)>-1||"href"in n&&n.href.indexOf(t.runtime.shutDownHref)>-1,c=function(){i=c.lock};return c.lock=i=!0,beforeUnloadTimer=setTimeout(c,0),o?~e.type.indexOf("beforeunload")?e.returnValue=r:(_confirm=confirm(r),_confirm||a(e)):a(e),o?(c.lock=!1)||r:clearTimeout(beforeUnloadTimer)}},u=function(t){return function(e){i||setTimeout(function(){var n={};t.eachStore(function(t,e){var r=t.getTitle();n[r]=t.getState(),t.disconnect(),t.destroy(),e()}),o.call(t,n),"click"!=e.type&&r(e)},0)}},l={runtime:{spaMode:!0,shutDownHref:""},persistenceEnabled:!1,autoRehydrate:!1,universalCoverage:!1,localHostDev:!1},s=[].slice,f={typesMap:{number:Number,array:Array,object:Object,string:String,boolean:Boolean,date:Date,regexp:RegExp,function:Function},isOfType:function(t,e){return"function"==typeof(t=t.toLowerCase())?t(e):"string"==typeof t&&t in this.typesMap&&(/^string|function$/.test(typeof e)||Object(e)instanceof this.typesMap[t])}},p=function(t,r,i){i===e&&(i=null);for(var o in t)n.call(t,o)&&r.call(i,t[o],o,t)},h=function(t,e){var r={};for(var i in e)n.call(e,i)&&("object"==typeof e[i]&&null!==e[i]?r[i]=h(t[i],e[i]):t&&n.call(t,i)?r[i]=t[i]:r[i]=e[i]);return r},d=function(t,e,n){return function(){var r=s.call(arguments);return t.apply(n,e.concat(r))}};Array.prototype.forEach=Array.prototype.forEach||function(t,e){return p(this,t,e)},Array.prototype.reduceRight=Array.prototype.reduceRight||function(t){"use strict";if(null===this||void 0===this)throw new TypeError("Array.prototype.reduce called on null or undefined");if("function"!=typeof t)throw new TypeError(callback+" is not a function");var e,n=Object(this),r=(n.length>>>0)-1;if(arguments.length>=2)e=arguments[1];else{for(;r>=0&&!(r in n);)r--;if(r<0)throw new TypeError("Reduce of empty array with no initial value");e=n[r--]}for(;r>=0;r--)r in n&&(e=callback(e,n[r],r,n));return e},Function.prototype.bind=Function.prototype.bind||function(t){return d(this,[].slice(arguments,1),t)},function(t,n){"use strict";function r(r,i){var o;i=i||{bubbles:!1,cancelable:!1,detail:e};try{(o=n.createEvent("CustomEvent")).initCustomEvent(r,i.bubbles,i.cancelable,i.detail)}catch(e){(o=n.createEventObject(t.event)).cancelBubble=!i.bubbles,o.returnValue=!i.cancelable,"object"==typeof i.detail&&(o.detail=i.detail)}return o}try{new t.CustomEvent("test")}catch(e){r.prototype=Object.create(t.Event&&t.Event.prototype||{}),t.CustomEvent=null,t.CustomEvent=r}}(t,t.document),Object.create=Object.create||function(t,e){"use strict";if(null===t||!(t instanceof Object))throw TypeError("Object.create called on null or non-object argument");var r;function i(){}if(i.prototype=t,"object"==typeof e)for(r in e)n.call(e,r)&&(i[r]=e[r]);return new i},Object.keys=Object.keys||function(t){"use strict";if("object"==typeof t||"function"==typeof t){var e=[];for(var r in fuc)n.call(fuc,r)&&e.push(r);var i=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","prototypeIsEnumerable","constructor"];if(!ob.propertyIsEnumerable("toString"))for(var o=0;o=0&&r.state<=1&&e[t][2].add.apply(r,s.call(arguments)),r}:function(){if(r.state>=0&&r.state<=1&&(r.state=$[e[t][1]]),e[t][2].fireWith(r===this?r:this,[].slice.call(arguments)),o)switch(e[n[0]][2].disable(),e[n[1]][2].disable(),t){case"reject":case"resolve":r.state=$[e[t][1]]}return!0}:e[t][2].fireWith},a=0,c=i.slice(),u={};for(t in e)n.call(e,t)&&(i.splice(a++,1),r[t]=o(t,i),r[t+"With"]=o(t,[]),u[e[t][0]]=o(t,[],!0),i=c.slice());return u.state=$.STARTED,u.always=function(){return this.done.apply(r,arguments).fail.apply(r,arguments)},u.promise=function(t){if(t&&"object"==typeof t&&!t.length){for(var e in u)n.call(u,e)&&(t[e]=u[e]);return t}return u},u.then=function(){var t;return[].slice.call(arguments).forEach(function(n,o){n="function"==typeof n&&n,r[e[i[o]][0]](function(){var e;try{e=n&&n.apply(this,arguments)}catch(t){e=this.reject(t)}finally{e&&"function"==typeof e.promise&&(t=e.promise())}})}),r.promise(t)},u.isResolved=function(){return!e.reject[2].hasList()},u.isRejected=function(){return!e.resolve[2].hasList()},u.pipe=u.then,u.promise(r),m.STARTED=$.STARTED,m.AWAITING=$.AWAIT,m.RESOLVED=$.RESOLVED,m.REJECTED=$.REJECTED,o=c=t=a=null,r instanceof m?r:new m},b=function(r){var i=null,o=r.top===r&&r.localStorage?r.localStorage:null,a=r.top===r&&r.sessionStorage?r.sessionStorage:r.opera&&!n.call(r,"opera")?r.opera.scriptStorage:{},s=r.document.documentMode||0,d=!1,y={},g=[],$={},v=[],b={},w={},S=[],E={},T={},A=function(t){if("getPrototypeOf"in Object)return Object.getPrototypeOf(t);if("__proto__"in t){if(!n.call(t,"__proto__"))return t.__proto__}else if("constructor"in t&&!n.call(t,"constructor"))return t.constructor.prototype;return t},x=function(t){return void 0==t},O=function(t,n,i,o){1!=t.$$history.length||t.$$initData||(t.$$initData=t.$$history[0]),t.$$history=t.$$history.slice(0,t.$$historyIndex+1);var a,c,u,l,s,f=!1;if(null===n?(f=null!==o?o.actionData:t.$$history[t.$$historyIndex],_.$$historyLocation=t.$$historyIndex):(f=t.call(n,o,i.get()),_.$$historyLocation=null),"boolean"==typeof f||f==e)throw new TypeError("Radixx: Application State unavailable after signal to Dispatcher");if(a=i.put(f),_.$$currentStoreTitle=a,null===o)return f;o.source,c=r.document,u="storesignal",l={url:r.location.href,key:a,newValue:f,source:r,aspect:o.actionKey,type:o.actionType},"target"in(s=new CustomEvent(u,{detail:l,cancelable:!0,bubbles:!1}))||!0!==s.cancelBubble||c.setCapture(!0),c["target"in s?"dispatchEvent":"fireEvent"].apply(c,"target"in s?[s]:["on"+u,s]),_.$$withAction=!0,t.$$history.push(f),t.$$historyIndex++,t.$$history.length>21&&t.$$history.unshift()},I=function(t){return String(location.origin+(t.localHostDev?":"+document.documentElement.id:""))},R=function(t){var e=o.getItem(t);return x(e)?String(Math.random()).replace(".","x_").substring(0,11):j(e)},j=function(t){if(x(t)||"null"===t)return null;try{return JSON.parse(t)}catch(e){return String(t)}},k=function(t){x(t)&&(t=null);try{return JSON.stringify(t)}catch(e){return String(t)}},D=function(t){p(t,function(t,e){new L(e).put(t)}),M(t,!0)},C=function(){var t,e,n,i,o={};if("key"in a&&"function"==typeof a.key)for(var c=0;c-1){var e,n=t.detail.key;if(!x(b[n])){e=b[n].$$store_listeners;for(var i=0;i= 2 )")},V.prototype.hasMiddleware=function(){return this.middlewares.length>0},V.prototype.initCatchers=function(t){if(t.autoRehydrate){if(!x(F.$$tag)&&o)var e=j(o.getItem(F.$$tag));e instanceof Object&&e.state&&(D(e.state),this.updateAutoRehydrationState())}r.document.addEventListener?(t.universalCoverage&&r.addEventListener("storage",F,!1),r.document.addEventListener("storesignal",H,!1)):r.document.attachEvent&&(t.universalCoverage&&r.document.attachEvent("onstorage",F),r.document.attachEvent("onstoresignal",H))},V.prototype.getRegistration=function(t){return n.call(b,t)?b[t]:{}},V.prototype.register=function(t,e,r){if(n.call(b,t)){if("$$history"in b[t]&&void 0===e.$$history){if(!$[t])throw new Error("Radixx: Cannot Overwrite existing store registration");e.$$history=b[t].$$history,e.$$historyIndex=b[t].$$historyIndex,e.$$store_listeners=b[t].$$store_listeners,b[t]=e}}else e.$$store_listeners=[],e.$$history=[r||[]],e.$$historyIndex=0,b[t]=e,v.push(t);return!0},V.prototype.watch=function(t){g.push(t)},V.prototype.setStoreListener=function(t,e){var n=t.getTitle();x(b[n])||"function"==typeof e&&($[n]=t,b[n].$$store_listeners.push(e))},V.prototype.unsetStoreListener=function(t,e){var n=t.getTitle();if(!x(b[n])&&"function"==typeof e){var r=b[n].$$store_listeners.indexOf(e);b[n].$$store_listeners.splice(r,1)}},V.prototype.signalUnique=function(t){if("hydrate"==t.source){r.setTimeout(P,0);var e=new L(t.target),n=b[t.target];O.$$redoActionsStack.length=0,O.$$redoActionsStack.push(t),n.$$history.length=0,n.historyIndex=-1,O.apply(null,[n,null,e,t])}},V.prototype.handleStoreMutation=function(t,e){if(e){var n=t.getTitle(),i={},o=this.getRegistration(n),a=new L(n);switch(e){case"undo":if(t.canUndo())return--o.$$historyIndex,i[n]=O.apply(null,[o,null,a,null]),r.setTimeout(M.bind(null,i),0),!0;break;case"redo":if(t.canRedo())return++o.$$historyIndex,i[n]=O.apply(null,[o,null,a,null]),r.setTimeout(M.bind(null,i),0),!0}return!1}},V.prototype.rebuildStateFromActions=function(){var t=O.$$redoActionsStack;p(t,function(t,e){var r,i;for(i in b)n.call(b,i)&&(r=new L(i),b[i].call(t,r.get()))},O)},V.prototype.signal=function(t){var e=null,i=function(t,e,r,i){var o,a=null;O.$$redoActionsStack.push(r);for(o in t)n.call(t,o)&&(a=new L(o),O.apply(null,[t[o],e.queueing,a,r]));return C()}.bind(null,b,this),o={createDispatchResolver:function(t){return i.bind(null,t)}},a=this.hasMiddleware();t.source in E&&(e=a?this.middlewares.concat(i).reduceRight(function(t,e){return e.bind(null,t)}):i,r.setTimeout(P,0),x(e)||e.apply(a?o:null,[t,C()]))},V.prototype.unregister=function(t){var e,n;x(b[t])||(e=b[t],$[t],e.$$store_listeners.length=0,e.$$store_listeners=null,e.$$historyIndex=-1,e.$$history.length=0,e.$$history=null,delete b[t],e=null,delete $[t],null,-1!=(n=v.indexOf(t))&&v.splice(n,1))},V.prototype.queueing={await:function(t,e){for(var n=-1,r=t.length+n,i=null;++n-1?w[t[n]]:w[t[n]]=new m,"function"==typeof e&&i.then(e)}},{getInstance:function(){return null===i&&(i=new V),i},eachStore:function(t,e,n){p(v,e.bind(n=[],$));var r=t,i=n.length-1,o=function(){return i>=0?Boolean(r.call(null,n[i--],o)):r=!0};o()},setActionVectors:function(t,e){var r=A(t),i=this.getInstance(),o=null;for(var a in e)n.call(e,a)&&(o=e[a],r[a]=this.createActionInterface(i,o));return t},createStoreInterface:function(t,e){return function(){var n,r,i,o=arguments.length?arguments[0]:null;if("setChangeListener"==e)return t.setStoreListener(this,o);if("unsetChangeListener"==e)return t.unsetStoreListener(this,o);if("getState"==e)return(r=new L(this.getTitle()).get())===null?(n=t.getRegistration(this.getTitle())).$$history.length&&n.$$history[0]:"string"==typeof o&&o in r?r[o]:r;if("destroy"==e)return i in $&&delete $[i],new L(this.getTitle()).del(),null;if("disconnect"==e)return t.unregister(this.getTitle());if("hydrate"==e){if(x(o))return;return t.signalUnique({source:e,target:this.getTitle(),actionData:o})}return"getQuerySchema"==e?{}:"setQuerySchema"==e||("canUndo"==e?0!=(n=t.getRegistration(this.getTitle())).$$historyIndex:"swapCallback"==e?t.register(this.getTitle(),o):"canRedo"==e?(n=t.getRegistration(this.getTitle())).$$historyIndex!==n.$$history.length-1:"undo"==e?t.handleStoreMutation(this,e):"redo"==e?t.handleStoreMutation(this,e):void 0)}},createActionInterface:function(t,e){if(!(e instanceof Object))throw new TypeError("Invalid Action Creator Vector, expected [object] but found ["+typeof e+"]");return function(n,r){var i=this.getId(),o=0;if(x(E[i])||E[i].actionTypes.push(e),e.actionDefinition instanceof Array){if(p(e.actionDefinition,function(t){o|=Number(f.isOfType(t,n))}),!o)throw new TypeError("Action Data Invalid for action: ["+e.type+"]")}else if(!f.isOfType(e.actionDefinition,n))throw new TypeError("Action Data Invalid for action: ["+e.type+"]");return t.signal({source:i,actionType:e.type,actionKey:r||null,actionData:n})}},watchDispatcher:function(t){this.getInstance().watch(t)},isAppStateAutoRehydrated:function(){return this.getInstance().getAutoRehydrationState()},mergeConfig:function(e,n){var i=this.getInstance();if((y=h(e,l)).universalCoverage&&(y.persistenceEnabled=!0),y.runtime.spaMode?"string"==typeof y.runtime.shutDownHref&&0!=y.runtime.shutDownHref.length&&(r.addEventListener?(document.documentElement.addEventListener("click",c(y),!1),document.addEventListener("click",u(n),!1)):(document.documentElement.attachEvent("onclick",c(y)),document.attachEvent("onclick",u(n),!1))):"string"==typeof y.runtime.shutDownHref&&0!=y.runtime.shutDownHref.length&&(t.onbeforeunload=c(y),t.onunload=u(n)),y.persistenceEnabled){var a=I(y),s=R(a);o.setItem(a,s),F.$$origin=a,F.$$tag=s,_.$$canOmit=!0,_.$$tag=s,n.onDispatch(_)}return i.initCatchers(y),y},purgePersistStore:function(){var t=I(y),e=R(t);o.removeItem(t),o.removeItem(e)},registerAction:function(){var t=Math.random().toString(16).substr(2,13);return E[t]={actionTypes:[]},t},makeAggregator:function(){return{notifyAllStores:function(){}}},setMiddlewareCallback:function(t){var e=this.getInstance();try{e.getMiddleware()}catch(n){e.setMiddleware(t)}},setStoreObserver:function(t,e,n){if("function"!=typeof e)return null;var r=A(t),i=this.getInstance(),o=t.getTitle(),a=null;i.register(o,e,n);for(var c=["setChangeListener","unsetChangeListener","getState","disconnect","getQuerySchema","canRedo","canUndo","swapCallback","undo","redo","hydrate","destroy"],u=0;u= 8.5.0" + "node": "^6.14.0 || ^8.10.0 || >= 9.10.0" }, "main": "src/radixx.js", "browser": "dist/radixx.min.js", - "module":"dist/radixx.es2015.min.js", + "module": "dist/radixx.es2015.min.js", "unpkg": "dist/radixx.min.js", "jsdelivr": "dist/radixx.min.js", "jsnext:main": "src/radixx.module.js", diff --git a/src/es/components/dispatcher.js b/src/es/components/dispatcher.js index 922297d..02b264a 100644 --- a/src/es/components/dispatcher.js +++ b/src/es/components/dispatcher.js @@ -1,39 +1,6 @@ -import { wind } from '../utils/routines/basics.js'; - -/** - Though IE 9 to IE 11 supports the CustomEvent constructor, IE throws an error {Object doesn't support this action} - whenever it's used. This weird behaviour is fixed below - See: https://stackoverflow.com/questions/14358599/object-doesnt-support-this-action-ie9-with-customevent-initialization -*/ - -function CEvent ( event, params ) { - let t; - let evt; - let d = wind.document; - params = params || { bubbles: false, cancelable: false, detail: undefined }; - - try{ - evt = d.createEvent( 'CustomEvent' ); - evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail ); - }catch(e){ - evt = d.createEventObject(w.event); - evt.cancelBubble = !params.bubbles; - evt.returnValue = !params.cancelable; - - if(typeof params.detail === "object"){ - // set expando properties on event object - - /*for(t in params.detail){ - if((({}).hasOwnProperty.call(params.detail, t))){ - evt[t] = params.detail[t]; - } - }*/ - evt.detail = params.detail; - } - } - - return evt; -} +import { wind, Hop, Futures, isNullOrUndefined, each, extend } from '../utils/routines/basics.js'; +import { $createBeforeTearDownCallback, $createTearDownCallback } from '../utils/routines/extras.js'; + try { const ce = new wind.CustomEvent('test'); @@ -44,15 +11,15 @@ try { wind.CustomEvent = CEvent; } -let $instance = null; - const persistStore = (win.top !== win || !win.localStorage) ? null : win.localStorage; - const sessStore = (win.top !== win || !win.sessionStorage ? (win.opera && !(Hop.call(win, 'opera')) ? win.opera.scriptStorage : {} ) : win.sessionStorage); - const mode = win.document.documentMode || 0; - let autoRehydrationOccured = false; +const persistStore = (wind.top !== wind || !wind.localStorage) ? null : wind.localStorage; - let config = { +const sessStore = (wind.top !== wind || !wind.sessionStorage ? (wind.opera && !(Hop.call(wind, 'opera')) ? wind.opera.scriptStorage : {} ) : wind.sessionStorage); -}; +const mode = wind.document.documentMode || 0; + +let autoRehydrationOccured = false; + +let config = null; const watchers = [ @@ -78,32 +45,36 @@ let $instance = null; ]; - const dispatchRegistry = { - -}; - const cachedStorageKeys = { }; - const getObjectPrototype = obj => { - if('getPrototypeOf' in Object){ - return Object.getPrototypeOf(obj); - }else if('__proto__' in obj){ - if(!(Hop.call(obj, '__proto__'))){ - return (obj.__proto__); - } - }else if('constructor' in obj){ - if(!(Hop.call(obj, 'constructor'))){ - return obj.constructor.prototype; - } - } - return obj; - }; +const getAppOriginForPersist = cfg => String(wind.location.origin + (cfg.localHostDev ? ':'+wind.document.documentElement.id : '')); + +const generateTag = origin => { - const isNullOrUndefined = obj => obj == void 0; + const _cdata = persistStore.getItem(origin); + + if(!isNullOrUndefined(_cdata)){ - const triggerEvt = (target, eType, detail, globale) => { + return getNormalized(_cdata); + } + + return String(Math.random()).replace('.','x_').substring(0, 11); +}; + +const defaultConfig = { + runtime:{ + spaMode:true, + shutDownHref:'' + }, + persistenceEnabled:false, + autoRehydrate:false, + universalCoverage:false, + localHostDev:false +}; + +const triggerEvt = (target, eType, detail, globale) => { const evt = new CustomEvent(eType, { detail, cancelable:true, @@ -123,9 +94,9 @@ let $instance = null; // Including support for IE 8 here ;) return dispatch.apply(target, (!('target' in evt) ? [`on${eType}`, evt ] : [ evt ])); - }; +}; - const operationOnStoreSignal = (fn, queueing, area, action) => { +const operationOnStoreSignal = (fn, queueing, area, action) => { // first, retrieve the very first state data and cache it if(fn.$$history.length == 1 @@ -183,17 +154,17 @@ let $instance = null; } triggerEvt( - win.document, + wind.document, 'storesignal', { - url:win.location.href, + url:wind.location.href, key:_key, newValue:newStoreState, - source:win, + source:wind, aspect:action.actionKey, type:action.actionType }, - win + wind ); coverageNotifier.$$withAction = true; @@ -216,20 +187,6 @@ let $instance = null; }; - const getAppOriginForPersist = cfg => String(location.origin + (cfg.localHostDev? ':'+document.documentElement.id : '')); - - const generateTag = origin => { - - const _cdata = persistStore.getItem(origin); - - if(!isNullOrUndefined(_cdata)){ - - return getNormalized(_cdata); - } - - return String(Math.random()).replace('.','x_').substring(0, 11); - }; - const getNormalized = val => { if(isNullOrUndefined(val) || val === "null") @@ -253,4 +210,827 @@ let $instance = null; return String(val); } -}; + }; + + const getCurrentActionOnStack = () => { + + const actionStack = operationOnStoreSignal.$$redoActionsStack; + + if(actionStack.lenth){ + return actionStack[actionStack.length - 1]; + } + + return null; + }; + + const coverageNotifier = appState => { + + let currentAction = null; + + const _tag = coverageNotifier.$$tag; + + if(arguments.callee.$$withAction === true){ + currentAction = getCurrentActionOnStack(); + arguments.callee.$$withAction = null; + } + + if(!isNullOrUndefined(_tag) + && (persistStore !== null)){ + + persistStore.setItem(_tag, setNormalized({ + state:appState, + action:currentAction, + title:arguments.callee.$$currentStoreTitle, + historyLoc:arguments.callee.$$historyLocation + })); + + arguments.callee.$$historyLocation = null; + } + }; + + const fireWatchers = (state, omitCallback) => { + + let pos, watcher; + + for(pos in watchers){ + if(Hop.call(watchers, pos)){ + watcher = watchers[pos]; + if(omitCallback){ + if(watcher.$$canOmit){ + continue; + }; + } + watcher.call(null, state); + } + } + }; + + const setAppState = appState => { + + each(appState, (isolatedState, storeTitle) => { + + const area = new Area(storeTitle); + + area.put(isolatedState); + + }); + + fireWatchers(appState, true); + }; + + const getAppState = () => { + + const appStateData = {}; + let key; + let indexStart; + let indexEnd; + let values; + let _data; + + if(('key' in sessStore) + && (typeof sessStore.key == 'function')){ + + // We iterate this way so we can support IE 8 + other browsers + for(var i=0; i < sessStore.length; i++){ + key = sessStore.key(i); + _data = sessStore.getItem(key); + + if(!_data){ + ; + } + + appStateData[key] = getNormalized(_data) || null; + } + }else{ + + + for(var i = 0; i < storeKeys.length; i++){ + + key = storeKeys[i]; + + if(cachedStorageKeys[key]){ + + indexStart = wind.name.indexOf(key); + + indexEnd = wind.name.indexOf('|', indexStart); + + values = (wind.name.substring(indexStart, indexEnd)).split(':=:') || ["", null]; + + _data = values[1]; + + } + + appStateData[key] = getNormalized(_data) || null; + } + } + + return appStateData; + }; + + const handlePromises = () => { + let promise = null; + const state = getAppState(); + + for(const title in _promises){ + if(Hop.call(_promises, title)){ + promise = _promises[title]; + if(!promise.isResolved()){ + promise.resolve(); + } + delete _promises[title]; + } + } + + waitQueue.length = 0; + + fireWatchers(state); + }; + + const enforceCoverage = e => { + + const _origin = arguments.callee.$$origin; + const _tag = arguments.callee.$$tag; + let _action = null; + let _state = null; + let _title = null; + let _hloc = null; + let _composedData = null; + let observer = null; + + // Detecting IE 8 to apply mild hack on event object + if(('remainingSpace' in sessStore)){ + e.key = e.detail.key; + } + + if(!persistStore + || _origin === e.key){ // if we can't find the key in the array `storeKeys` + return; + } + + _composedData = getNormalized(persistStore.getItem(_tag)); + + if(_tag === e.key + && isNullOrUndefined(_composedData)){ + return; + } + + _state = _composedData.state; + + _action = _composedData.action; + + _title = _composedData.title; + + _hloc = parseInt(_composedData.historyLoc); + + if(_action !== null){ + operationOnStoreSignal.$$redoActionsStack.push(_action); + } + + if(_hloc !== null){ + observer = observers[_title]; + if(observer){ + observer.$$historyIndex = _hloc; + if(_hloc === -1){ + observer.$$history.length = 0; + } + } + } + + if(_state){ + setTimeout( + setAppState.bind(null, _state) + , 0); + } + }; + + const stateWatcher = e => { + + e = e || wind.event; + + if(storeKeys.includes(e.detail.key)){ + const storeTitle = e.detail.key; + let listeners; + + if(!isNullOrUndefined(observers[storeTitle])){ + + listeners = observers[storeTitle].$$store_listeners; + + for(let t=0; t < listeners.length; t++){ + + listeners[t].call(stores[storeTitle], e.detail.type, e.detail.aspect); + + } + } + } + }; + + /** + Though IE 9 to IE 11 supports the CustomEvent constructor, IE throws an error {Object doesn't support this action} + whenever it's used. This weird behaviour is fixed below + See: https://stackoverflow.com/questions/14358599/object-doesnt-support-this-action-ie9-with-customevent-initialization + */ + + function CEvent ( event, params ) { + let t; + let evt; + let d = wind.document; + params = params || { bubbles: false, cancelable: false, detail: undefined }; + + try{ + evt = d.createEvent( 'CustomEvent' ); + evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail ); + }catch(e){ + evt = d.createEventObject(w.event); + evt.cancelBubble = !params.bubbles; + evt.returnValue = !params.cancelable; + + if(typeof params.detail === "object"){ + // set expando properties on event object + + /*for(t in params.detail){ + if((({}).hasOwnProperty.call(params.detail, t))){ + evt[t] = params.detail[t]; + } + }*/ + evt.detail = params.detail; + } + } + + return evt; + } + + function setupConfigSettings(config, hub){ + + if(config.universalCoverage){ + + config.persistenceEnabled = true; + } + + if(config.persistenceEnabled){ + + // prepare Origin + const _origin = getAppOriginForPersist(config); + + const _tag = generateTag(_origin); + + persistStore.setItem(_origin, _tag); + + enforceCoverage.$$origin = _origin; + + enforceCoverage.$$tag = _tag; + + coverageNotifier.$$canOmit = true; + + coverageNotifier.$$tag = _tag; + + hub.onDispatch(coverageNotifier); + } + + if(config.autoRehydrate === true){ + + let data = null; + + if(!isNullOrUndefined(enforceCoverage.$$tag) + && persistStore){ + data = getNormalized(persistStore.getItem(enforceCoverage.$$tag)); + } + + if(data instanceof Object + && data.state){ + setAppState(data.state); + this.updateAutoRehydrationState(); + } + } + + if(!config.runtime.spaMode){ + + if(typeof config.runtime.shutDownHref === 'string' + && config.runtime.shutDownHref.length != 0){ + + wind.onbeforeunload = $createBeforeTearDownCallback(config); + + wind.onunload = $createTearDownCallback(hub); + } + }else{ + + if(typeof config.runtime.shutDownHref === 'string' + && config.runtime.shutDownHref.length != 0){ + + if(wind.addEventListener){ + wind.document.documentElement.addEventListener('click', $createBeforeTearDownCallback(config), false); + wind.document.addEventListener('click', $createTearDownCallback(hub), false); + }else{ + wind.document.documentElement.attachEvent('onclick', $createBeforeTearDownCallback(config)); + wind.document.attachEvent('onclick', $createTearDownCallback(hub), false); + } + } + } + + + } + + const Area = function(key){ + + this.put = value => { + + /* + In IE 8-9, writing to sessionStorage is done asynchronously (other browsers write synchronously) + we need to fix this by using IE proprietary methods + See: https://www.nczonline.net/blog/2009/07/21/introduction-to-sessionstorage/ + */ + + let indexStart; + + let indexEnd; + + const isIE8Storage = ('remainingSpace' in sessStore) && (mode === 8); + + // Detecting IE 8 to enable forced sync + if(isIE8Storage){ + if(typeof sessStore.begin == 'function'){ + sessStore.begin(); + } + } + + try{ + + sessStore.setItem(key, setNormalized(value)); + + }catch(e){ + + /* This is a fallback to support Opera Mini 4.4+ on Mobile */ + + if(cachedStorageKeys[key]){ + // we're in overwrite mode, so clear `key` out and push in update (below) + indexStart = wind.name.indexOf(key); + + indexEnd = wind.name.indexOf('|', indexStart); + + wind.name = wind.name.replace(wind.name.substring(indexStart, indexEnd), ''); + } + + if(wind.name === ""){ + + wind.name = `${key}:=:${setNormalized(value)}|`; + + }else{ + + wind.name += `${key}:=:${setNormalized(value)}|`; + + } + + cachedStorageKeys[key] = 1; + } + + if(isIE8Storage){ + if(typeof sessStore.commit == 'function'){ + sessStore.commit(); + } + } + + return key; + }; + + this.get = () => { + + let indexStart, indexEnd, values; + + /* This is a fallback to support Opera Mini 4.4+ on Mobile */ + + try{ + + return getNormalized(sessStore.getItem(key)) || null; + + }catch(e){ + + if(cachedStorageKeys[key]){ + + indexStart = wind.name.indexOf(key); + + indexEnd = wind.name.indexOf('|', indexStart); + + values = (wind.name.substring(indexStart, indexEnd)).split(':=:') || [0, 0]; + + return getNormalized(values[1]) || null; + } + + return null; + + } + }; + + this.del = () => { + + let indexStart; + + let indexEnd; + /* This is a fallback to support Opera Mini 4.4+ on Mobile */ + + try{ + + return sessStore.removeItem(key); + + }catch(e){ + + if(cachedStorageKeys[key]){ + + // we're in delete mode + indexStart = wind.name.indexOf(key); + + indexEnd = wind.name.indexOf('|', indexStart); + + wind.name = wind.name.replace(wind.name.substring(indexStart, indexEnd), ''); + + delete cachedStorageKeys[key]; + } + + return; + } + }; + + return this; + }; + + class Dispatcher { + + constructor() { + + this.middlewares = []; + + operationOnStoreSignal.$$undoActionsStack = []; + + operationOnStoreSignal.$$redoActionsStack = []; + } + + updateAutoRehydrationState() { + + autoRehydrationOccured = true; + } + + getAutoRehydrationState() { + + return autoRehydrationOccured; + } + + setMiddleware(middleware) { + + if(typeof middleware === 'function' + /*&& (middleware.length >= 2)*/){ + + return this.middlewares.push(middleware); + } + + throw new Error("Radixx: Inavlid Middleware Callback - Must be a Function with Parameters ( >= 2 )"); + + } + + hasMiddleware() { + + return (this.middlewares.length > 0); + + } + + initCatchers(userConfig, hub) { + + if(isNullOrUndefined(config)){ + + config = extend(userConfig, defaultConfig); + + setupConfigSettings.apply(this, [config, hub]); + } + + if(wind.document.addEventListener){ + /* IE 9+, W3C browsers all expect the 'storage' event to be bound to the window */ + if(config.universalCoverage){ + wind.addEventListener('storage', enforceCoverage, false); + } + + wind.document.addEventListener('storesignal', stateWatcher, false); + + }else if(wind.document.attachEvent){ + /* IE 8 expects the 'storage' event handler to be bound to the document + and not to the window */ + if(config.universalCoverage){ + wind.document.attachEvent('onstorage', enforceCoverage); + } + + wind.document.attachEvent('onstoresignal', stateWatcher); + } + + } + + getRegistration(title) { + + if(Hop.call(observers, title)){ + + return observers[title]; + } + + return {}; + } + + register(title, observer, defaultStoreContainer) { + + if(Hop.call(observers, title)){ + + if('$$history' in observers[title] + && typeof observer.$$history == 'undefined'){ + if(!stores[title]){ // If the store doesn't have any change listeners registered + + throw new Error("Radixx: Cannot Overwrite existing store registration"); + + return; + } + + observer.$$history = observers[title].$$history; + observer.$$historyIndex = observers[title].$$historyIndex; + observer.$$store_listeners = observers[title].$$store_listeners; + observers[title] = observer; + } + }else{ + + observer.$$store_listeners = []; + observer.$$history = [( + !!defaultStoreContainer ? + defaultStoreContainer : + [] + )]; + observer.$$historyIndex = 0; + observers[title] = observer; + storeKeys.push(title); + } + + return true; + } + + watch(callback) { + + watchers.push(callback); + } + + setStoreListener(store, callback) { + + const title = store.getTitle(); + + if(!isNullOrUndefined(observers[title])){ + + if(typeof callback == "function"){ + stores[title] = store; + observers[title].$$store_listeners.push(callback); + } + } + } + + unsetStoreListener(store, callback) { + + const title = store.getTitle(); + + if(!isNullOrUndefined(observers[title])){ + if(typeof callback == "function"){ + + const pos = observers[title].$$store_listeners.indexOf(callback); + observers[title].$$store_listeners.splice(pos, 1); + } + } + + } + + signalUnique(hydrateAction) { + + if(hydrateAction.source != 'hydrate'){ + return; + } + + // Pass this on to the event queue [await] + wind.setTimeout(handlePromises, 0); + + const stateArea = new Area(hydrateAction.target), regFunc = observers[hydrateAction.target]; + + operationOnStoreSignal.$$redoActionsStack.length = 0; + + operationOnStoreSignal.$$redoActionsStack.push(hydrateAction); + + regFunc.$$history.length = 0; // clear out the store state since this is a hydrate call + + regFunc.historyIndex = -1; + + operationOnStoreSignal(...[ + regFunc, + null, + stateArea, + hydrateAction + ]); + + } + + handleStoreMutation(store, mutationType) { + + if(!mutationType){ + return; + } + + const storeTitle = store.getTitle(); + const isolatedState = {}; + const regFunc = this.getRegistration(storeTitle); + const stateArea = new Area(storeTitle); + + switch(mutationType){ + + case 'undo': + if(store.canUndo()){ + + --regFunc.$$historyIndex; + + isolatedState[storeTitle] = operationOnStoreSignal(...[ + regFunc, + null, + stateArea, + null + ]); + + // Pass this on to the event queue + wind.setTimeout(fireWatchers.bind(null, isolatedState), 0); + + return true; + } + break; + case 'redo': + if(store.canRedo()){ + + ++regFunc.$$historyIndex; + + isolatedState[storeTitle] = operationOnStoreSignal(...[ + regFunc, + null, + stateArea, + null + ]); + + // Pass this on to the event queue + wind.setTimeout(fireWatchers.bind(null, isolatedState), 0); + + return true; + + } + break; + } + + return false; + } + + deletePersistenceTagAndData(){ + + if(isNullOrUndefined(config)){ + + return false; + } + + const _origin = getAppOriginForPersist(config); + + const _tag = generateTag(_origin); + + persistStore.removeItem(_origin); + + persistStore.removeItem(_tag); + + return true; + } + + rebuildStateFromActions() { + + const actionsStack = operationOnStoreSignal.$$redoActionsStack; + + each(actionsStack, (action, index) => { + + let stateArea; + + for(title in observers){ + if(Hop.call(observers, title)){ + + stateArea = new Area(title); + + observers[title].call(action, stateArea.get()); + } + } + + }, operationOnStoreSignal); + } + + signal(action) { + + let compactedFunc = null; + + const // this is the function that does the actual dispatch of the + baseDispatcher = (observers, dispatcher, action, prevState) => { + + let title, stateArea = null; + + operationOnStoreSignal.$$redoActionsStack.push(action); + + for(title in observers){ + if(Hop.call(observers, title)){ + + stateArea = new Area(title); + + operationOnStoreSignal(...[ + observers[title], + dispatcher.queueing, + stateArea, + action + ]); + } + } + + return getAppState(); + }; + + const boundBaseDispatcher = baseDispatcher.bind(null, observers, this); + + const adjoiner = { + /*createActionObject:function(_data, _type){ + + return { + source:"", + actionType:_type, + actionData:_data, + actionKey:null + }; + },*/ + createDispatchResolver(_action) { + + return boundBaseDispatcher.bind(null, _action); + } + }; + + const _hasMiddleware = this.hasMiddleware(); + + + // Some validation - just to make sure everything is okay + if(!(action.source in dispatchRegistry)){ + + return; + } + + // determine if there are middleware callbacks registered + if(_hasMiddleware){ + + // collapse all middleware callbacks into a single callback + compactedFunc = this.middlewares.concat( + boundBaseDispatcher + ).reduceRight((bound, middleware) => middleware.bind(null, + bound + )); + + }else { + + compactedFunc = boundBaseDispatcher; + } + + // Pass this on to the event queue + wind.setTimeout(handlePromises, 0); + + // begin cascading calls to the middlewares in turn + // from the last attached middleware all the way up + // to the first middleware until the action + // is finally dispatched + + if(!isNullOrUndefined(compactedFunc)){ + + compactedFunc.apply(_hasMiddleware ? adjoiner : null, [action, getAppState()]); + + } + } + + unregister(title) { + + let observer, store, index; + + if(!isNullOrUndefined(observers[title])){ + // initial clean-up + + observer = observers[title]; + store = stores[title]; + observer.$$store_listeners.length = 0; + observer.$$store_listeners = null; + observer.$$historyIndex = -1; + observer.$$history.length = 0; + observer.$$history = null; + + // more clean-up (freeing memory) + delete observers[title]; + observer = null; + + delete stores[title]; + store = null; + + index = storeKeys.indexOf(title); + + if(index != -1){ + storeKeys.splice(index, 1); + } + } + } + + } + +export { Dispatcher, Area } \ No newline at end of file diff --git a/src/es/components/observable.js b/src/es/components/observable.js index 312c8b4..aa02140 100644 --- a/src/es/components/observable.js +++ b/src/es/components/observable.js @@ -1,11 +1,359 @@ -import {wind, Futures, each, curry, _ping} from '../utils/routines/basics.js'; -import { Dispatcher, } from './dispatcher.js'; +import { wind, isNullOrUndefined } from '../utils/routines/basics.js'; +import { Dispatcher, Area } from './dispatcher.js'; import { Values } from '../utils/routines/extras.js'; -export function setStoreObserver(){ -} + let $instance = null; -export function setActionVectors(){ + const dispatchRegistry = { + + }; -} + const getInstance = () => { + + if($instance === null){ + + $instance = new Dispatcher(); + } + + return $instance; + + }; + + const getObjectPrototype = obj => { + if('getPrototypeOf' in Object){ + return Object.getPrototypeOf(obj); + }else if('__proto__' in obj){ + if(!(Hop.call(obj, '__proto__'))){ + return (obj.__proto__); + } + }else if('constructor' in obj){ + if(!(Hop.call(obj, 'constructor'))){ + return obj.constructor.prototype; + } + } + return obj; + }; + + const eachStore = function(fn, extractor, storeArray) { + + each(storeKeys, extractor.bind((storeArray = []), stores)); + + let callable = fn; + let prevIndex = storeArray.length - 1; + + const next = () => { + + let returnVal; + + if(prevIndex >= 0){ + returnVal = Boolean( + callable.call( + null, + storeArray[prevIndex--], + next + ) + ); + }else{ + callable = !0; + returnVal = callable; + } + + return returnVal; + }; + + next(); + }; + + const setActionVectors = function(object, vectors) { + + const _proto = getObjectPrototype(object); + const dispatcher = getInstance(); + let vector = null; + + for(const creator in vectors){ + if(Hop.call(vectors, creator)){ + vector = vectors[creator]; + _proto[creator] = createActionInterface(dispatcher, vector); + } + } + + return object; + }; + + const createStoreInterface = function(dispatcher, method) { + + + return function(){ + let regFunc; + let area; + const argument = arguments.length? arguments[0] : null; + + if(method == 'setChangeListener'){ + + return dispatcher.setStoreListener(this, argument); + } + + if(method == 'unsetChangeListener'){ + + return dispatcher.unsetStoreListener(this, argument); + } + + if(method == 'getState'){ + + let value; + area = new Area(this.getTitle()); + value = area.get(); + area = null; + + if(value === area){ + + regFunc = dispatcher.getRegistration(this.getTitle()); + + return (regFunc.$$history.length && regFunc.$$history[0]); + } + + return (typeof argument == 'string' && (argument in value)) ? value[argument] : value; + } + + if(method == 'destroy'){ + + let title, index; + + if(title in stores){ + + delete stores[title]; + + } + + area = new Area(this.getTitle()); + + area.del(); + + return (area = title = null); + } + + if(method == 'disconnect'){ + + return dispatcher.unregister(this.getTitle()); + } + + if(method == 'hydrate'){ + + if(isNullOrUndefined(argument)){ + return; + } + + return dispatcher.signalUnique({ + source:method, + target:this.getTitle(), + actionData:argument + }); + } + + if(method == 'getQuerySchema'){ + + return {}; + } + + if(method == 'setQuerySchema'){ + + return true; + } + + if(method == 'canUndo'){ + + regFunc = dispatcher.getRegistration(this.getTitle()); + + return (regFunc.$$historyIndex != 0); + } + + if(method == 'swapCallback'){ + + return dispatcher.register(this.getTitle(), argument); + } + + if(method == 'canRedo'){ + + regFunc = dispatcher.getRegistration(this.getTitle()); + + return (regFunc.$$historyIndex !== regFunc.$$history.length - 1); + } + + if(method == 'undo'){ + + return dispatcher.handleStoreMutation(this, method); + + } + + if(method == 'redo'){ + + return dispatcher.handleStoreMutation(this, method); + + } + } + + }; + + const createActionInterface = function(dispatcher, vector) { + + if(!(vector instanceof Object)){ + + throw new TypeError(`Invalid Action Creator Vector, expected [object] but found [${typeof(vector)}]`); + } + + return function(data, stateAspectKey){ + + // console.log('OUTER-FUNC: ', this.constructor.caller); + + const id = this.getId(); + + let typesBitMask = 0; + + if(!isNullOrUndefined(dispatchRegistry[id])){ + dispatchRegistry[id].actionTypes.push( + vector + ); + } + + if(vector.actionDefinition instanceof Array){ + + each(vector.actionDefinition, function(definition){ + + typesBitMask |= Number(Values.isOfType(definition, data)); + + }); + + if(!typesBitMask){ + + throw new TypeError(`Action Data Invalid for action: [${vector.type}]`); + } + + }else{ + if(!Values.isOfType(vector.actionDefinition, data)){ + + throw new TypeError(`Action Data Invalid for action: [${vector.type}]`); + + } + } + + return dispatcher.signal({ + source:id, + actionType:vector.type, + actionKey:stateAspectKey || null, + actionData:data + }); + } + }; + + const watchDispatcher = function(callback) { + + const dispatcher = getInstance(); + + dispatcher.watch(callback); + + }; + + const isAppStateAutoRehydrated = function() { + + const dispatcher = getInstance(); + + return dispatcher.getAutoRehydrationState(); + + }; + + const setupShutdownCallback = function(callback, hub){ + + + hub._ping = callback; + + }; + + const mergeConfig = function(userConfig, hub) { + + const dispatcher = getInstance(); + + return dispatcher.initCatchers(userConfig, hub); + }; + + const purgePersistStore = function() { + + dispatcher.deletePersistenceTagAndData(); + + }; + + const registerAction = function() { + /* creates hex value e.g. '0ef352ab287f1' */ + const regId = Math.random().toString(16).substr(2, 13); + + dispatchRegistry[regId] = {actionTypes:[]}; + + return regId; + + }; + + const makeAggregator = function() { + + return { + notifyAllStores() { + /* + */ + } + }; + }; + + const setMiddlewareCallback = function(middlewareFunc) { + + const dispatcher = getInstance(); + + // HERE: using this try/catch for control flow and not defensive programming + try{ + + dispatcher.getMiddleware(); + + }catch(ex){ + + dispatcher.setMiddleware( + middlewareFunc + ); + + } + + }; + + const setStoreObserver = function(object, regFunc, defaultStateObj) { + + if(typeof regFunc !== "function"){ + return null; + } + + const _proto = getObjectPrototype(object); + const dispatcher = getInstance(); + const title = object.getTitle(); + let method = null; + + dispatcher.register(title, regFunc, defaultStateObj); + + const methods = [ + 'setChangeListener', + 'unsetChangeListener', + 'getState', + 'disconnect', + 'getQuerySchema', + 'canRedo', + 'canUndo', + 'swapCallback', + 'undo', + 'redo', + 'hydrate', + 'destroy' + ]; + + for(let c=0; c < methods.length; c++){ + + method = methods[c]; + _proto[method] = createStoreInterface(dispatcher, method); + } + }; + +export { eachStore, makeAggregator, registerAction,setupShutdownCallback, mergeConfig, purgePersistStore, setStoreObserver, watchDispatcher, isAppStateAutoRehydrated, createStoreInterface, createActionInterface } \ No newline at end of file diff --git a/src/es/index.js b/src/es/index.js index 749aec7..5257661 100644 --- a/src/es/index.js +++ b/src/es/index.js @@ -3,12 +3,27 @@ import { Action, Store } from './utils/routines/extras.js'; import Helpers from './utils/helpers.js'; import Payload from './utils/primitive-checkers.js' + /*! + * @lib: Radixx + * @version: 0.1.2 + * @author: Ifeora Okechukwu + * @created: 30/12/2016 + * + * All Rights Reserved 2016 - 2018. + * Use, reproduction, distribution, and modification of this code is subject to the terms and + * conditions of the MIT license, available at http://www.opensource.org/licenses/mit-license.php + * + * @desc: Implementation of Facebooks' Flux Architecture with a Twist. [ ES6 ] + */ + + +function toString(){ -function toString(){ return "[object RadixxHub]"; } -function makeStore(dataTitle, registerCallback, defaultStateObj){ +const makeStore = function(dataTitle, registerCallback, defaultStateObj){ + function _store(...args){ Store.apply(this, args); } @@ -20,7 +35,7 @@ function makeStore(dataTitle, registerCallback, defaultStateObj){ return storeObject; } -function makeActionCreators(vectors){ +const makeActionCreators = function(vectors){ function _action(...args){ Action.apply(this, args); } @@ -30,52 +45,59 @@ function makeActionCreators(vectors){ return observable.setActionVectors(actionObject, vectors); } -function purgePersistentStorage(){ +const purgePersistentStorage = function(){ observable.purgePersistStore(); } -function eachStore(callback){ +const eachStore = function(callback){ return observable.eachStore(callback, function(stores, key){ + this.push(stores[key]); }, null); } -function configure(config) { - - let _hub = { - eachStore - }; - - observable.mergeConfig(config, _hub); -} +let _hub = { + eachStore +}; + -function attachMiddleware(callback) { +const attachMiddleware = function(callback) { - observable.setMiddlewareCallback(callback); + return observable.setMiddlewareCallback(callback); } -function isAppStateAutoRehydrated() { +const isAppStateAutoRehydrated = function() { return observable.isAppStateAutoRehydrated(); } -function onDispatch(handler){ +const onDispatch = function(handler){ if(typeof handler === 'function'){ - observable.watchDispatcher(handler); + observable.watchDispatcher(handler); } } -function onShutdown(){ +const configure = function(config) { + + return observable.mergeConfig(config, _hub); +} + +const onShutdown = function(handler){ + + if(typeof handler === "function"){ + + observable.setupShutdownCallback(handler, _hub); + } } -function requestAggregator() { +const requestAggregator = function() { return observable.makeAggregator(); } -export { Helpers, Payload, makeStore, makeActionCreators, purgePersistentStore, isAppStateAutoRehydrated, configure, eachStore, attachMiddleware, onDispatch, onShutdown, toString } +export { Helpers, Payload, makeStore, makeActionCreators, purgePersistentStorage, isAppStateAutoRehydrated, requestAggregator, configure, eachStore, attachMiddleware, onDispatch, onShutdown, toString } diff --git a/src/es/utils/routines/basics.js b/src/es/utils/routines/basics.js index 98128a5..0b02090 100644 --- a/src/es/utils/routines/basics.js +++ b/src/es/utils/routines/basics.js @@ -1,134 +1,17 @@ -let wind = (('undefined' !== typeof process && + +const wind = (('undefined' !== typeof process && '[object process]' === ({}).toString.call(process)) || ('undefined' !== typeof navigator && navigator.product === 'ReactNative') ? global : typeof window !== "undefined" ? window : self); -let Hop = ({}).hasOwnProperty; - -let Slc = ([]).slice; - -let __beforeunload = wind.onbeforeunload; - -let __unload = wind.onunload; - -let __hasDeactivated = false; - -let _ping = appState => { - - return; -}; - -let _checkAndKillEventPropagation = event => { - if(event.type === 'click'){ - if(event.stopPropagation){ - event.stopPropagation(); - }else{ - event.cancelBubble = true; - } - } -}; - -let $createBeforeTearDownCallback = config => e => { - // @See: https://greatgonzo.net/i-know-what-you-did-on-beforeunload/ - - /* - `lastActivatedNode` variable is used to track the DOM Node that last - had focus (or was clicked) just before the browser triggered the `beforeunload` event - */ - - const lastActivatedNode = (wind.currentFocusElement // Mobile Browsers [ Custom Property ] - || e.explicitOriginalTarget // old/new Firefox - || (e.srcDocument && e.srcDocument.activeElement) // old Chrome/Safari - || (e.currentTarget && e.currentTarget.document.activeElement) // Sarafi/Chrome/Opera/IE - || e.srcElement - || e.target); - - // if the "imaginary" user is logging out - const leaveMessage = "Are you sure you want to leave this page ?"; - - const isLogoff = ((typeof lastActivatedNode.hasAttribute == 'function' && lastActivatedNode.hasAttribute('data-href') && lastActivatedNode.getAttribute('data-href').includes(config.runtime.shutDownHref)) - || (('href' in lastActivatedNode) && (lastActivatedNode.href.includes(config.runtime.shutDownHref)))); - - const __timeOutCallback = () => { - - __hasDeactivated = __timeOutCallback.lock; - - }; - - // console.log('Node: '+ lastActivatedNode); - - __timeOutCallback.lock = __hasDeactivated = true; - beforeUnloadTimer = wind.setTimeout(__timeOutCallback, 0); +const Hop = ({}).hasOwnProperty; - if(isLogoff){ // IE/Firefox/Chrome 34+ - if(!!~e.type.indexOf('beforeunload')){ - e.returnValue = leaveMessage; - }else{ - _confirm = confirm && confirm(leaveMessage); - if(!_confirm){ - _checkAndKillEventPropagation(e); - } - } - }else{ - _checkAndKillEventPropagation(e); - } - - /* if (isLogoff) isn't true, no beforeunload dialog is shown */ - return ((isLogoff) ? ((__timeOutCallback.lock = false) || leaveMessage) : clearTimeout(beforeUnloadTimer)); -}; - -let $createTearDownCallback = hub => e => { - - /* - This seems to be the best way to setup the `unload` event - listener to ensure that the load event is always fired even if the page - is loaded from the `bfcache` (Back-Forward-Cache) of the browser whenever - the back and/or forward buttons are used for navigation instead of links. - Registering it as a property of the `window` object sure works every time - */ - - if(!__hasDeactivated){ - - setTimeout(() => { - - let appstate = {}; - - hub.eachStore((store, next) => { - - const title = store.getTitle(); +const Slc = ([]).slice; - appstate[title] = store.getState(); - - store.disconnect(); - store.destroy(); +const isNullOrUndefined = obj => obj == void 0; - next(); - }); - - _ping.call(hub, appstate); - - if(e.type != 'click'){ - __unload(e); - } - - }, 0); - } -}; - -let defaultConfig = { - runtime:{ - spaMode:true, - shutDownHref:'' - }, - persistenceEnabled:false, - autoRehydrate:false, - universalCoverage:false, - localHostDev:false -}; - - -let each = (obj, iterator, context) => { +const each = (obj, iterator, context) => { if(context === undefined){ @@ -148,28 +31,29 @@ let each = (obj, iterator, context) => { * @params * @return */ -let extend = (source, dest) => { + +const extend = (source, dest) => { let merge = {}; for(let prop in dest){ - if(Hop.call(dest, prop)){ - - if(typeof dest[prop] === "object" - && dest[prop] !== null){ - merge[prop] = extend(source[prop], dest[prop]); - }else if(source && Hop.call(source, prop)){ - merge[prop] = source[prop]; - }else { - merge[prop] = dest[prop]; - } - } + if(Hop.call(dest, prop)){ + + if(typeof dest[prop] === "object" + && dest[prop] !== null){ + merge[prop] = extend(source[prop], dest[prop]); + }else if(source && Hop.call(source, prop)){ + merge[prop] = source[prop]; + }else { + merge[prop] = dest[prop]; + } + } } return merge; }; -let curry = (func, args, context) => function(){ +const curry = (func, args, context) => function(){ let _args = Slc.call(arguments); return func.apply(context, args.concat(_args)); }; @@ -420,4 +304,4 @@ let Futures = function(){ return (self instanceof Futures)? self : new Futures(); }; -export { Hop, Slc, defaultConfig, wind, $createTearDownCallback, $createBeforeTearDownCallback, each, extend, curry, Futures, _ping } +export { Hop, Slc, isNullOrUndefined, wind, each, extend, curry, Futures } diff --git a/src/es/utils/routines/extras.js b/src/es/utils/routines/extras.js index e188e9d..906aff4 100644 --- a/src/es/utils/routines/extras.js +++ b/src/es/utils/routines/extras.js @@ -1,5 +1,115 @@ +import { wind } from './basics.js'; -export const Values = { +let __beforeunload = wind.onbeforeunload; + +let __unload = wind.onunload; + +let __hasDeactivated = false; + +let _checkAndKillEventPropagation = event => { + if(event.type === 'click'){ + if(event.stopPropagation){ + event.stopPropagation(); + }else{ + event.cancelBubble = true; + } + } +}; + +const $createBeforeTearDownCallback = config => e => { + + // @See: https://greatgonzo.net/i-know-what-you-did-on-beforeunload/ + + /* + `lastActivatedNode` variable is used to track the DOM Node that last + had focus (or was clicked) just before the browser triggered the `beforeunload` event + */ + + const lastActivatedNode = (wind.currentFocusElement // Mobile Browsers [ Custom Property ] + || e.explicitOriginalTarget // old/new Firefox + || (e.srcDocument && e.srcDocument.activeElement) // old Chrome/Safari + || (e.currentTarget && e.currentTarget.document.activeElement) // Sarafi/Chrome/Opera/IE + || e.srcElement + || e.target); + + // if the "imaginary" user is logging out + const leaveMessage = "Are you sure you want to leave this page ?"; + + const isLogoff = ((typeof lastActivatedNode.hasAttribute == 'function' && lastActivatedNode.hasAttribute('data-href') && lastActivatedNode.getAttribute('data-href').includes(config.runtime.shutDownHref)) + || (('href' in lastActivatedNode) && (lastActivatedNode.href.includes(config.runtime.shutDownHref)))); + + const __timeOutCallback = () => { + + __hasDeactivated = __timeOutCallback.lock; + + }; + + // console.log('Node: '+ lastActivatedNode); + + __timeOutCallback.lock = __hasDeactivated = true; + beforeUnloadTimer = wind.setTimeout(__timeOutCallback, 0); + + if(isLogoff){ // IE/Firefox/Chrome 34+ + if(!!~e.type.indexOf('beforeunload')){ + e.returnValue = leaveMessage; + }else{ + _confirm = wind.confirm && wind.confirm(leaveMessage); + + if(!_confirm){ + _checkAndKillEventPropagation(e); + } + } + }else{ + _checkAndKillEventPropagation(e); + } + + /* if (isLogoff) isn't true, no beforeunload dialog is shown */ + return ((isLogoff) ? ((__timeOutCallback.lock = false) || leaveMessage) : wind.clearTimeout(beforeUnloadTimer)); +}; + +const $createTearDownCallback = hub => e => { + + /* + This seems to be the best way to setup the `unload` event + listener to ensure that the load event is always fired even if the page + is loaded from the `bfcache` (Back-Forward-Cache) of the browser whenever + the back and/or forward buttons are used for navigation instead of links. + Registering it as a property of the `window` object sure works every time + */ + + if(!__hasDeactivated){ + + wind.setTimeout(() => { + + let appstate = {}; + + hub.eachStore((store, next) => { + + const title = store.getTitle(); + + appstate[title] = store.getState(); + + store.disconnect(); + store.destroy(); + + next(); + + }); + + if(typeof hub._ping == "function"){ + + hub._ping.call(hub, appstate); + } + + if(e.type != 'click'){ + __unload(e); + } + + }, 0); + } +}; + +const Values = { typesMap:{ "number":Number, "array":Array, @@ -29,7 +139,9 @@ export const Values = { } }; -export const Store = ((() => { + +// Store Constructor +const Store = ((() => { let requirementTypes = ['graph-ql', 'rest']; @@ -64,7 +176,7 @@ export const Store = ((() => { })()); // Action constructor -export const Action = ((() => function(id){ +const Action = ((() => function(id){ this.getId = () => id; @@ -76,3 +188,4 @@ export const Action = ((() => function(id){ })()); +export { Values, Store, Action, $createBeforeTearDownCallback, $createTearDownCallback } \ No newline at end of file diff --git a/src/radixx.es2015.js b/src/radixx.es2015.js deleted file mode 100644 index 4df1b46..0000000 --- a/src/radixx.es2015.js +++ /dev/null @@ -1,2062 +0,0 @@ - -// 'use strict'; Can't [use strict] mode cos i wish to use {void 0}/{arguments.callee} for checks - -const Hop = ({}).hasOwnProperty; - -const wind = (('undefined' !== typeof process && - '[object process]' === ({}).toString.call(process)) || - ('undefined' !== typeof navigator && navigator.product === 'ReactNative') -? global : typeof window !== "undefined" ? window : self); -const __beforeunload = wind.onbeforeunload; -const __unload = wind.onunload; -let __hasDeactivated = false; - -let _ping = appState => { - - return; -}; - -const _checkAndKillEventPropagation = event => { - if(event.type === 'click'){ - if(event.stopPropagation){ - event.stopPropagation(); - }else{ - event.cancelBubble = true; - } - } -}; - -const $createBeforeTearDownCallback = config => e => { - // @See: https://greatgonzo.net/i-know-what-you-did-on-beforeunload/ - - /* - `lastActivatedNode` variable is used to track the DOM Node that last - had focus (or was clicked) just before the browser triggered the `beforeunload` event - */ - - const lastActivatedNode = (window.currentFocusElement // Mobile Browsers [ Custom Property ] - || e.explicitOriginalTarget // old/new Firefox - || (e.srcDocument && e.srcDocument.activeElement) // old Chrome/Safari - || (e.currentTarget && e.currentTarget.document.activeElement) // Sarafi/Chrome/Opera/IE - || e.srcElement - || e.target); - - const // if the "imaginary" user is logging out - leaveMessage = "Are you sure you want to leave this page ?"; - - const isLogoff = ((typeof lastActivatedNode.hasAttribute == 'function' && lastActivatedNode.hasAttribute('data-href') && lastActivatedNode.getAttribute('data-href').includes(config.runtime.shutDownHref)) - || (('href' in lastActivatedNode) && (lastActivatedNode.href.includes(config.runtime.shutDownHref)))); - - const __timeOutCallback = () => { - - __hasDeactivated = __timeOutCallback.lock; - - }; - - // console.log('Node: '+ lastActivatedNode); - - __timeOutCallback.lock = __hasDeactivated = true; - beforeUnloadTimer = setTimeout(__timeOutCallback, 0); - - if(isLogoff){ // IE/Firefox/Chrome 34+ - if(!!~e.type.indexOf('beforeunload')){ - e.returnValue = leaveMessage; - }else{ - _confirm = confirm(leaveMessage); - if(!_confirm){ - _checkAndKillEventPropagation(e); - } - } - }else{ - _checkAndKillEventPropagation(e); - } - - /* if (isLogoff) isn't true, no beforeunload dialog is shown */ - return ((isLogoff) ? ((__timeOutCallback.lock = false) || leaveMessage) : clearTimeout(beforeUnloadTimer)); -}; - -const $createTearDownCallback = hub => e => { - - /* - This seems to be the best way to setup the `unload` event - listener to ensure that the load event is always fired even if the page - is loaded from the `bfcache` (Back-Forward-Cache) of the browser whenever - the back and/or forward buttons are used for navigation instead of links. - Registering it as a property of the `window` object sure works every time - */ - - if(!__hasDeactivated){ - - setTimeout(() => { - - const appstate = {}; - - hub.eachStore((store, next) => { - - const title = store.getTitle(); - - appstate[title] = store.getState(); - - store.disconnect(); - store.destroy(); - - next(); - - }); - - _ping.call(hub, appstate); - - if(e.type != 'click'){ - __unload(e); - } - - }, 0); - } - }; - -const _defaultConfig = { - runtime:{ - spaMode:true, shutDownHref:'' - }, - persistenceEnabled:false, - autoRehydrate:false, - universalCoverage:false, - localHostDev:false -}; - -const Slc = ([]).slice; - -const Values = { - typesMap:{ - "number":Number, - "array":Array, - "object":Object, - "string":String, - "boolean":Boolean, - "date":Date, - "regexp":RegExp, - "function":Function - }, - isOfType(type, value) { - - var type = type.toLowerCase(); // hoisting - - if(typeof type === 'function'){ - - return type(value); - } - - else if(typeof type === 'string' - && (type in this.typesMap)){ - return (/^string|function$/.test(typeof value)) - || (Object(value) instanceof this.typesMap[type]); - } - - return false; - } -}; - -const _each = (obj, iterator, context) => { - - if(context === undefined){ - - context = null; - } - - for(const prop in obj){ - if(Hop.call(obj, prop)){ - iterator.call(context, obj[prop], prop, obj); - } - } -}; - -const _extend = (source, dest) => { - - const merge = {}; - - for(const prop in dest){ - if(Hop.call(dest, prop)){ - - if(typeof dest[prop] === "object" - && dest[prop] !== null){ - merge[prop] = _extend(source[prop], dest[prop]); - }else if(source && Hop.call(source, prop)){ - merge[prop] = source[prop]; - }else { - merge[prop] = dest[prop]; - } - } - } - - return merge; -}; - -const _curry = (func, args, context) => function(){ - const _args = Slc.call(arguments); - return func.apply(context, args.concat(_args)); -}; - -Array.prototype.forEach = Array.prototype.forEach || function(fn, cxt){ - - return _each(this, fn, cxt); -}; - -Array.prototype.reduceRight = Array.prototype.reduceRight || function(fn /* initialValue */){ - if(null === this || 'undefined' === typeof this){ - throw new TypeError('Array.prototype.reduce called on null or undefined'); - } - - if('function' !== typeof fn){ - throw new TypeError(`${callback} is not a function`); - } - - const t = Object(this); - const len = t.length >>> 0; - let k = len - 1; - let value; - - if(arguments.length >= 2){ - - value = arguments[1]; - - } else { - - while(k >= 0 && !(k in t)){ - k--; - } - - if(k < 0){ - throw new TypeError('Reduce of empty array with no initial value') - } - - value = t[k--]; - } - - for(; k >= 0; k--){ - if(k in t){ - value = callback(value, t[k], k, t); - } - } - return value; -}; - -Function.prototype.bind = Function.prototype.bind || function(cxt /* ,args... */){ - - return _curry(this, [].slice(arguments, 1), cxt); -} - -/** - Though IE 9 to IE 11 supports the CustomEvent constructor, IE throws an error {Object doesn't support this action} - whenever it's used. This weird behaviour is fixed below - See: https://stackoverflow.com/questions/14358599/object-doesnt-support-this-action-ie9-with-customevent-initialization -*/ - -;(((w, d) => { - function CEvent ( event, params ) { - let t; - let evt; - params = params || { bubbles: false, cancelable: false, detail: undefined }; - try{ - evt = d.createEvent( 'CustomEvent' ); - evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail ); - }catch(e){ - evt = d.createEventObject(w.event); - evt.cancelBubble = !params.bubbles; - evt.returnValue = !params.cancelable; - if(typeof params.detail === "object"){ - // set expando properties on event object - - /*for(t in params.detail){ - if((({}).hasOwnProperty.call(params.detail, t))){ - evt[t] = params.detail[t]; - } - }*/ - evt.detail = params.detail; - } - } - return evt; - } - try { - const ce = new w.CustomEvent('test'); - } catch(e) { - - CEvent.prototype = Object.create(((w.Event && w.Event.prototype) || {})); - w.CustomEvent = null; - w.CustomEvent = CEvent; - } -}))(wind, wind.document); - -Object.create = Object.create || ((o, props) => { - if (o === null || !(o instanceof Object)) { - throw TypeError("Object.create called on null or non-object argument"); - } - - let prop; - function F(){} - F.prototype = o; - - if(typeof props === "object"){ - for(prop in props){ - if(Hop.call(props, prop)){ - F[prop] = props[prop]; - } - } - } - - return new F(); -}); - -Object.keys = Object.keys || (fu => { - if (typeof (fu) != 'object' - && typeof (fu) != 'function') { - return; - } - - const j = []; - for (const k in fuc) { - if(Hop.call(fuc, k)) { - j.push(k) - } - } - const l = !ob.propertyIsEnumerable('toString'); - - const m = [ - 'toString', - 'toLocaleString', - 'valueOf', - 'hasOwnProperty', - 'isPrototypeOf', - 'prototypeIsEnumerable', - 'constructor' - ]; - - if(l) { - for (const o of m) { - if(Hop.call(fuc, o)) { - j.push(o); - } - } - } - return j; -}); - -// Store constructor -const Store = ((() => { - - const requirementTypes = ['graph-ql', 'rest']; - - const serviceRequirementsMap = {}; - - return function(title){ - - const that = this; - - this.getTitle = () => title; - - this.toJSON = () => ({ - title - }); - - this.makeTrait = function(callback){ - - const argsLeft = Slc.call(arguments, 1); - - if(typeof callback === 'function'){ - - argsLeft.unshift(this); - - return callback(...argsLeft); - } - - return null; - - }; - - this.toString = () => "[object RadixxStore]"; - } - -})()); - -const // Action constructor -Action = ((() => function(id){ - - this.getId = () => id; - - this.toJSON = () => ({ - id - }); - - this.toString = () => "[object RadixxActionCreator]"; -})()); - -const futuresStates = { - STARTED:0, - AWAIT:1, - RESOLVED:2, - REJECTED:3 -}; - -const formatOptions = opts => { - const options = {}, _opts = String(opts).split(","); - _opts.forEach(key => { - options[key] = true; - }); - options.savedData = !1; - return options; -}; - -const Routines = opts => { - const options = formatOptions(opts); - let fireStart; - let fireEnd; - let index; - let fired; - let firing; - let pending = []; - let queue = options.multiple && []; - - const fire = data => { - options.savedData = !fire.$decline && options.save && data; // save it only when we are not rejecting {fire.$decline != true}! - fired = true; - firing = true; // firing has begun! - index = fireStart || 0; - fireEnd = pending.length; - for(fireStart = 0; index < fireEnd; index++){ - // @TODO: need to curry args instead of directly binding them #DONE - setTimeout(_curry(pending[index], data[1], data[0])/*.bind(data[0], data[1])*/, 20); // fire asynchronously (Promises/A+ spec requirement) - } - firing = false; // firing has ended! - - if(queue){ // deal with the queue if it exists and has any contents... - if(queue.length){ - return fire(queue.shift()); // fire on the {queue} items recursively - } - // if queue is empty.... then end [flow of control] at this point! - } - - fire.$decline = false; - - if(options.savedData){ - if(options.unpack){ - // clear our {pending} list and free up some memeory!! - pending.length = 0; // saves the reference {pending} and does not replace it! - } - } - }; - - return { - add() { - let len = 0; - if(pending){ // if not disbaled - - const start = pending.length; - (function add(args){ - - args.forEach(arg => { - const type = typeof arg; - - if(type == "function"){ - len = pending.push(arg); - }else{ - if(!!arg && arg.length && typeof arg != "string"){ - // inspect recursively - add(Slc.call(arg)); - } - } - }); - - }(Slc.call(arguments))); - - - if( fired ){ // if we have already run the {pending} list of routines at least once, ... - if(options.join){ - fireStart = start; - fireEnd = len; // update info again... - fire.$decline = true; - fire( options.savedData ); // fire with the saved data - this.disable(); - - } - } - - - } - return len; - }, - hasFn(fn) { - let result = false; - _each(pending, val => { - if(typeof fn === "function" && fn === val) - result = true; - }, this); - return result; - }, - hasList() { - return !!pending; // [false] only when the disabled(); method has been called!! - }, - fireWith() /* context, args */{ - if(pending && (!fired || queue)){ - const args = arguments.length && Slc.call(arguments) || [null, 0]; - - if(firing){ // we are currently iterating on the {pending} list of routines - queue.push( args ); // queue assets for recursive firing within {fire} function later - }else{ - fire( args ); - } - } - }, - disable() { - if(!options.savedData){ - pending = queue = undefined; - } - } - }; -}; - -const // Futures constructor - Promises/A+ Spec Implementation (Influenced by jQuery though...) -Futures = function(){ - const defTracks = { - resolve:['done', 'RESOLVED', Routines(['join', 'save'])], - reject:['fail', 'REJECTED', Routines(['join','save'])], - notify:['progress', 'AWAIT', Routines(['join', 'multiple'])] - }; - - const self = this; - let keys = Object.keys(defTracks); - - let setter = (fnName, arr, forPromise) => { - const drop = (fnName != "notify"); - if(!arr.length && !forPromise) return defTracks[fnName][2].fireWith; - return (!forPromise)? function(){ - if(self.state >= 0 && self.state <=1){ - self.state = futuresStates[defTracks[fnName][1]]; - } - - defTracks[fnName][2].fireWith(self === this? self : this, [].slice.call(arguments)); - - if(drop){ - defTracks[arr[0]][2].disable(); - defTracks[arr[1]][2].disable(); - switch(fnName){ - case "reject": - case "resolve": - self.state = futuresStates[defTracks[fnName][1]]; - break; - } - } - return true; - } : function(){ - if(self.state >= 0 && self.state <=1){ - defTracks[fnName][2].add.apply(self, Slc.call(arguments)); - } - return self; - } ; - }; - - let i = 0; - let ax = keys.slice(); - let d; - const promise = {}; - - - // using a closure to define all the functions on the fly... - - for(d in defTracks){ - if(Hop.call(defTracks, d)){ - keys.splice(i++, 1); - self[d] = setter(d, keys); - self[`${d}With`] = setter(d, []); - promise[defTracks[d][0]] = setter(d, [], true); - keys = ax.slice(); - } - } - - promise.state = futuresStates.STARTED; - - promise.always = function(){ - return this.done.apply(self, arguments).fail.apply(self, arguments); - }; - - promise.promise = obj => { - if(obj && typeof obj == "object" && !obj.length){ - for(const i in promise){ - if(Hop.call(promise, i)){ - obj[i] = promise[i]; - } - } - return obj; - } - return promise; - }; - - promise.then = function(/* fnDone, fnFail, fnProgress */){ - let ret; - const args = [].slice.call(arguments); - args.forEach((item, i) => { - item = (typeof item == "function") && item; - self[defTracks[keys[i]][0]](function(){ - let rt; - try{ - /* - Promises/A+ specifies that errors should be contained - and returned as value of rejected promise - */ - rt = item && item.apply(this, arguments); - }catch(e){ - rt = this.reject(e); - }finally{ - if(rt && typeof rt.promise == "function") - ret = rt.promise(); - } - }); - }); - return self.promise(ret); - }; - - promise.isResolved = () => !defTracks['reject'][2].hasList(); - promise.isRejected = () => !defTracks['resolve'][2].hasList(); - promise.pipe = promise.then; - - promise.promise(self); - - Futures.STARTED = futuresStates.STARTED; - Futures.AWAITING = futuresStates.AWAIT; - Futures.RESOLVED = futuresStates.RESOLVED; - Futures.REJECTED = futuresStates.REJECTED; - - /* avoid leaking memory with each call to Futures constructor!! */ - setter = ax = d = i = null; - - /* enforce {new} on constructor */ - return (self instanceof Futures)? self : new Futures(); -}; - -const Observable = ((win => { - let $instance = null; - const persistStore = (win.top !== win || !win.localStorage) ? null : win.localStorage; - const sessStore = (win.top !== win || !win.sessionStorage ? (win.opera && !(Hop.call(win, 'opera')) ? win.opera.scriptStorage : {} ) : win.sessionStorage); - const mode = win.document.documentMode || 0; - let autoRehydrationOccured = false; - - let config = { - -}; - - const watchers = [ - -]; - - const stores = { - -}; - - const storeKeys = [ - -]; - - const observers = { - -}; - - const _promises = { - -}; - - const waitQueue = [ - -]; - - const dispatchRegistry = { - -}; - - const cachedStorageKeys = { - -}; - - const getObjectPrototype = obj => { - if('getPrototypeOf' in Object){ - return Object.getPrototypeOf(obj); - }else if('__proto__' in obj){ - if(!(Hop.call(obj, '__proto__'))){ - return (obj.__proto__); - } - }else if('constructor' in obj){ - if(!(Hop.call(obj, 'constructor'))){ - return obj.constructor.prototype; - } - } - return obj; - }; - - const isNullOrUndefined = obj => obj == void 0; - - const triggerEvt = (target, eType, detail, globale) => { - const evt = new CustomEvent(eType, { - detail, - cancelable:true, - bubbles:false - }); // a stub function - just in case - - let dispatch = () => false; - - if((!('target' in evt)) - && evt.cancelBubble === true){ - - target.setCapture(true); - } - - // set up cross-browser dispatch method. - dispatch = target[ (!('target' in evt) ? "fireEvent" : "dispatchEvent") ]; - - // Including support for IE 8 here ;) - return dispatch.apply(target, (!('target' in evt) ? [`on${eType}`, evt ] : [ evt ])); - }; - - const operationOnStoreSignal = (fn, queueing, area, action) => { - - // first, retrieve the very first state data and cache it - if(fn.$$history.length == 1 - && (!fn.$$initData)){ - - fn.$$initData = fn.$$history[0]; - } - - // second, make sure that there is no future state to forth on - fn.$$history = fn.$$history.slice(0, fn.$$historyIndex + 1); - - // lets setup a place to store new state, also mark out the context of this call - let newStoreState = false, len, _key; - - // create a new state of the store data by applying a given - // store callback function to the current history head - - if(queueing === null){ - - if(action !== null){ - - newStoreState = action.actionData; - - }else{ - - newStoreState = fn.$$history[fn.$$historyIndex]; - } - - coverageNotifier.$$historyLocation = fn.$$historyIndex; - - }else{ - - newStoreState = fn.call(queueing, action, area.get()); - - coverageNotifier.$$historyLocation = null; - - } - - if(typeof newStoreState == 'boolean' - || newStoreState == undefined){ - - throw new TypeError("Radixx: Application State unavailable after signal to Dispatcher"); - - return; - } - - _key = area.put(newStoreState); - - coverageNotifier.$$currentStoreTitle = _key; - - if(action !== null){ - - if(action.source !== 'hydrate'){ - ; - } - - triggerEvt( - win.document, - 'storesignal', - { - url:win.location.href, - key:_key, - newValue:newStoreState, - source:win, - aspect:action.actionKey, - type:action.actionType - }, - win - ); - - coverageNotifier.$$withAction = true; - - // add the new state to the history list and increment - // the index to match in place - len = fn.$$history.push(newStoreState); /* @TODO: use {action.actionType} as operation Annotation */ - - fn.$$historyIndex++; - - if(fn.$$history.length > 21){ // can't undo/redo (either way) more than 21 moves at any time - - fn.$$history.unshift(); - } - - }else{ - - return newStoreState; - } - - }; - - const getAppOriginForPersist = cfg => String(location.origin + (cfg.localHostDev? ':'+document.documentElement.id : '')); - - const generateTag = origin => { - - const _cdata = persistStore.getItem(origin); - - if(!isNullOrUndefined(_cdata)){ - - return getNormalized(_cdata); - } - - return String(Math.random()).replace('.','x_').substring(0, 11); - }; - - const getNormalized = val => { - - if(isNullOrUndefined(val) || val === "null") - return null; - - try{ - return JSON.parse(val); - }catch(e){ - return String(val); - } - }; - - const setNormalized = val => { - - if(isNullOrUndefined(val)) - val = null; - - try{ - return JSON.stringify(val); - }catch(e){ - - return String(val); - } - }; - - const setAppState = appState => { - - _each(appState, (isolatedState, storeTitle) => { - - const area = new Area(storeTitle); - - area.put(isolatedState); - }); - - fireWatchers(appState, true); - }; - - const getAppState = () => { - const appStateData = {}; - let key; - let indexStart; - let indexEnd; - let values; - let _data; - - if(('key' in sessStore) - && (typeof sessStore.key == 'function')){ - - // We iterate this way so we can support IE 8 + other browsers - for(var i=0; i < sessStore.length; i++){ - key = sessStore.key(i); - _data = sessStore.getItem(key); - - if(!_data){ - ; - } - - appStateData[key] = getNormalized(_data) || null; - } - }else{ - - - for(var i = 0; i < storeKeys.length; i++){ - - key = storeKeys[i]; - - if(cachedStorageKeys[key]){ - - indexStart = win.name.indexOf(key); - - indexEnd = win.name.indexOf('|', indexStart); - - values = (win.name.substring(indexStart, indexEnd)).split(':=:') || ["", null]; - - _data = values[1]; - - } - - appStateData[key] = getNormalized(_data) || null; - } - } - - return appStateData; - }; - - const Area = function(key){ - - this.put = value => { - - /* - In IE 8-9, writing to sessionStorage is done asynchronously (other browsers write synchronously) - we need to fix this by using IE proprietary methods - See: https://www.nczonline.net/blog/2009/07/21/introduction-to-sessionstorage/ - */ - - let indexStart; - - let indexEnd; - - const isIE8Storage = ('remainingSpace' in sessStore) && (mode === 8); - - // Detecting IE 8 to enable forced sync - if(isIE8Storage){ - if(typeof sessStore.begin == 'function'){ - sessStore.begin(); - } - } - - try{ - - sessStore.setItem(key, setNormalized(value)); - - }catch(e){ - - /* This is a fallback to support Opera Mini 4.4+ on Mobile */ - - if(cachedStorageKeys[key]){ - // we're in overwrite mode, so clear `key` out and push in update (below) - indexStart = win.name.indexOf(key); - - indexEnd = win.name.indexOf('|', indexStart); - - win.name = win.name.replace(win.name.substring(indexStart, indexEnd), ''); - } - - if(win.name === ""){ - - win.name = `${key}:=:${setNormalized(value)}|`; - - }else{ - - win.name += `${key}:=:${setNormalized(value)}|`; - - } - - cachedStorageKeys[key] = 1; - } - - if(isIE8Storage){ - if(typeof sessStore.commit == 'function'){ - sessStore.commit(); - } - } - - return key; - }; - - this.get = () => { - - let indexStart, indexEnd, values; - - /* This is a fallback to support Opera Mini 4.4+ on Mobile */ - - try{ - - return getNormalized(sessStore.getItem(key)) || null; - - }catch(e){ - - if(cachedStorageKeys[key]){ - - indexStart = win.name.indexOf(key); - - indexEnd = win.name.indexOf('|', indexStart); - - values = (win.name.substring(indexStart, indexEnd)).split(':=:') || [0, 0]; - - return getNormalized(values[1]) || null; - } - - return null; - - } - }; - - this.del = () => { - - let indexStart, indexEnd; - /* This is a fallback to support Opera Mini 4.4+ on Mobile */ - - try{ - - return sessStore.removeItem(key); - - }catch(e){ - - if(cachedStorageKeys[key]){ - - // we're in delete mode - indexStart = win.name.indexOf(key); - - indexEnd = win.name.indexOf('|', indexStart); - - win.name = win.name.replace(win.name.substring(indexStart, indexEnd), ''); - - delete cachedStorageKeys[key]; - } - - return; - } - }; - - return this; - }; - - const getCurrentActionOnStack = () => { - - const actionStack = operationOnStoreSignal.$$redoActionsStack; - - if(actionStack.lenth){ - return actionStack[actionStack.length - 1]; - } - - return null; - }; - - const coverageNotifier = function(appState){ - - let currentAction = null; - - const _tag = coverageNotifier.$$tag; - - if(arguments.callee.$$withAction === true){ - currentAction = getCurrentActionOnStack(); - arguments.callee.$$withAction = null; - } - - if(!isNullOrUndefined(_tag) - && (persistStore !== null)){ - - persistStore.setItem(_tag, setNormalized({ - state:appState, - action:currentAction, - title:arguments.callee.$$currentStoreTitle, - historyLoc:arguments.callee.$$historyLocation - })); - - arguments.callee.$$historyLocation = null; - } - }, - - fireWatchers = (state, omitCallback) => { - - let pos, watcher; - - for(pos in watchers){ - if(Hop.call(watchers, pos)){ - watcher = watchers[pos]; - if(omitCallback){ - if(watcher.$$canOmit){ - continue; - }; - } - watcher.call(null, state); - } - } - }, - - handlePromises = () => { - let promise = null; - const state = getAppState(); - - for(const title in _promises){ - if(Hop.call(_promises, title)){ - promise = _promises[title]; - if(!promise.isResolved()){ - promise.resolve(); - } - delete _promises[title]; - } - } - - waitQueue.length = 0; - - fireWatchers(state); - }, - - enforceCoverage = function(e){ - const _origin = arguments.callee.$$origin; - const _tag = arguments.callee.$$tag; - let _action = null; - let _state = null; - let _title = null; - let _hloc = null; - let _composedData = null; - let observer = null; - - // Detecting IE 8 to apply mild hack on event object - if(('remainingSpace' in sessStore)){ - e.key = e.detail.key; - } - - if(!persistStore - || _origin === e.key){ // if we can't find the key in the array `storeKeys` - return; - } - - _composedData = getNormalized(persistStore.getItem(_tag)); - - if(_tag === e.key - && isNullOrUndefined(_composedData)){ - return; - } - - _state = _composedData.state; - - _action = _composedData.action; - - _title = _composedData.title; - - _hloc = parseInt(_composedData.historyLoc); - - if(_action !== null){ - operationOnStoreSignal.$$redoActionsStack.push(_action); - } - - if(_hloc !== null){ - observer = observers[_title]; - if(observer){ - observer.$$historyIndex = _hloc; - if(_hloc === -1){ - observer.$$history.length = 0; - } - } - } - - if(_state){ - setTimeout( - setAppState.bind(null, _state) - , 0); - } - }, - - stateWatcher = e => { - - e = e || win.event; - - if(storeKeys.includes(e.detail.key)){ - const storeTitle = e.detail.key; - let listeners; - - if(!isNullOrUndefined(observers[storeTitle])){ - - listeners = observers[storeTitle].$$store_listeners; - - for(let t=0; t < listeners.length; t++){ - - listeners[t].call(stores[storeTitle], e.detail.type, e.detail.aspect); - - } - } - } - }; - - class Dispatcher { - constructor() { - - this.middlewares = []; - - operationOnStoreSignal.$$undoActionsStack = []; - - operationOnStoreSignal.$$redoActionsStack = []; - } - - updateAutoRehydrationState() { - autoRehydrationOccured = true; - } - - getAutoRehydrationState() { - return autoRehydrationOccured; - } - - setMiddleware(middleware) { - - if(typeof middleware === 'function' - /*&& (middleware.length >= 2)*/){ - - return this.middlewares.push(middleware); - } - - throw new Error("Radixx: Inavlid Middleware Callback - Must be a Function with Parameters ( >= 2 )"); - - } - - hasMiddleware() { - - return (this.middlewares.length > 0); - - } - - initCatchers(config) { - - if(config.autoRehydrate === true){ - let data = null; - if(!isNullOrUndefined(enforceCoverage.$$tag) - && persistStore){ - data = getNormalized(persistStore.getItem(enforceCoverage.$$tag)); - } - if(data instanceof Object - && data.state){ - setAppState(data.state); - this.updateAutoRehydrationState(); - } - } - - if(win.document.addEventListener){ - /* IE 9+, W3C browsers all expect the 'storage' event to be bound to the window */ - if(config.universalCoverage){ - win.addEventListener('storage', enforceCoverage, false); - } - - win.document.addEventListener('storesignal', stateWatcher, false); - }else if(win.document.attachEvent){ - /* IE 8 expects the 'storage' event handler to be bound to the document - and not to the window */ - if(config.universalCoverage){ - win.document.attachEvent('onstorage', enforceCoverage); - } - - win.document.attachEvent('onstoresignal', stateWatcher); - } - - } - - getRegistration(title) { - - if(Hop.call(observers, title)){ - - return observers[title]; - } - - return {}; - } - - register(title, observer, defaultStoreContainer) { - - if(Hop.call(observers, title)){ - - if('$$history' in observers[title] - && typeof observer.$$history == 'undefined'){ - if(!stores[title]){ // If the store doesn't have any change listeners registered - - throw new Error("Radixx: Cannot Overwrite existing store registration"); - - return; - } - - observer.$$history = observers[title].$$history; - observer.$$historyIndex = observers[title].$$historyIndex; - observer.$$store_listeners = observers[title].$$store_listeners; - observers[title] = observer; - } - }else{ - - observer.$$store_listeners = []; - observer.$$history = [( - !!defaultStoreContainer ? - defaultStoreContainer : - [] - )]; - observer.$$historyIndex = 0; - observers[title] = observer; - storeKeys.push(title); - } - - return true; - } - - watch(callback) { - - watchers.push(callback); - } - - setStoreListener(store, callback) { - - const title = store.getTitle(); - - if(!isNullOrUndefined(observers[title])){ - if(typeof callback == "function"){ - stores[title] = store; - observers[title].$$store_listeners.push(callback); - } - } - } - - unsetStoreListener(store, callback) { - - const title = store.getTitle(); - - if(!isNullOrUndefined(observers[title])){ - if(typeof callback == "function"){ - const pos = observers[title].$$store_listeners.indexOf(callback); - observers[title].$$store_listeners.splice(pos, 1); - } - } - - } - - signalUnique(hydrateAction) { - - if(hydrateAction.source != 'hydrate'){ - return; - } - - // Pass this on to the event queue [await] - win.setTimeout(handlePromises, 0); - - const stateArea = new Area(hydrateAction.target), regFunc = observers[hydrateAction.target]; - - operationOnStoreSignal.$$redoActionsStack.length = 0; - - operationOnStoreSignal.$$redoActionsStack.push(hydrateAction); - - regFunc.$$history.length = 0; // clear out the store state since this is a hydrate call - - regFunc.historyIndex = -1; - - operationOnStoreSignal(...[ - regFunc, - null, - stateArea, - hydrateAction - ]); - - } - - handleStoreMutation(store, mutationType) { - - if(!mutationType){ - return; - } - - const storeTitle = store.getTitle(), isolatedState = {}, regFunc = this.getRegistration(storeTitle), stateArea = new Area(storeTitle); - - switch(mutationType){ - - case 'undo': - if(store.canUndo()){ - - --regFunc.$$historyIndex; - - isolatedState[storeTitle] = operationOnStoreSignal(...[ - regFunc, - null, - stateArea, - null - ]); - - // Pass this on to the event queue - win.setTimeout(fireWatchers.bind(null, isolatedState), 0); - - return true; - } - break; - case 'redo': - if(store.canRedo()){ - - ++regFunc.$$historyIndex; - - isolatedState[storeTitle] = operationOnStoreSignal(...[ - regFunc, - null, - stateArea, - null - ]); - - // Pass this on to the event queue - win.setTimeout(fireWatchers.bind(null, isolatedState), 0); - - return true; - - } - break; - } - - return false; - } - - rebuildStateFromActions() { - - const actionsStack = operationOnStoreSignal.$$redoActionsStack; - - _each(actionsStack, (action, index) => { - - let stateArea; - - for(title in observers){ - if(Hop.call(observers, title)){ - - stateArea = new Area(title); - - observers[title].call(action, stateArea.get()); - } - } - - }, operationOnStoreSignal); - } - - signal(action) { - let compactedFunc = null; - - const // this is the function that does the actual dispatch of the - baseDispatcher = (observers, dispatcher, action, prevState) => { - - let title, stateArea = null; - - operationOnStoreSignal.$$redoActionsStack.push(action); - - for(title in observers){ - if(Hop.call(observers, title)){ - - stateArea = new Area(title); - operationOnStoreSignal(...[ - observers[title], - dispatcher.queueing, - stateArea, - action - ]); - } - } - - return getAppState(); - }; - - const boundBaseDispatcher = baseDispatcher.bind(null, observers, this); - - const adjoiner = { - /*createActionObject:function(_data, _type){ - - return { - source:"", - actionType:_type, - actionData:_data, - actionKey:null - }; - },*/ - createDispatchResolver(_action) { - - return boundBaseDispatcher.bind(null, _action); - } - }; - - const _hasMiddleware = this.hasMiddleware(); - - - // Some validation - just to make sure everything is okay - if(!(action.source in dispatchRegistry)){ - - return; - } - - // determine if there are middleware callbacks registered - if(_hasMiddleware){ - - // collapse all middleware callbacks into a single callback - compactedFunc = this.middlewares.concat( - boundBaseDispatcher - ).reduceRight((bound, middleware) => middleware.bind(null, - bound - )); - - }else { - - compactedFunc = boundBaseDispatcher; - } - - // Pass this on to the event queue - win.setTimeout(handlePromises, 0); - - // begin cascading calls to the middlewares in turn - // from the last attached middleware all the way up - // to the first middleware until the action - // is finally dispatched - - if(!isNullOrUndefined(compactedFunc)){ - - compactedFunc.apply(_hasMiddleware ? adjoiner : null, [action, getAppState()]); - - } - } - - unregister(title) { - - let observer, store, index; - - if(!isNullOrUndefined(observers[title])){ - // initial clean-up - - observer = observers[title]; - store = stores[title]; - observer.$$store_listeners.length = 0; - observer.$$store_listeners = null; - observer.$$historyIndex = -1; - observer.$$history.length = 0; - observer.$$history = null; - - // more clean-up (freeing memory) - delete observers[title]; - observer = null; - - delete stores[title]; - store = null; - - index = storeKeys.indexOf(title); - - if(index != -1){ - storeKeys.splice(index, 1); - } - } - } - } - - Dispatcher.prototype.queueing = { - await(titleList, callback) { - let current = -1; - const len = (titleList.length + current); - let promise = null; - - while(++current < len){ - if(waitQueue.includes(titleList[current])){ - promise = _promises[titleList[current]]; - }else{ - promise = _promises[titleList[current]] = new Futures(); - } - - if(typeof callback == "function"){ - promise.then(callback); - } - } - } - }; - - return { - - getInstance() { - - if($instance === null){ - - $instance = new Dispatcher(); - } - - return $instance; - - }, - eachStore(fn, extractor, storeArray) { - _each(storeKeys, extractor.bind((storeArray = []), stores)); - - let callable = fn; - let prevIndex = storeArray.length - 1; - - const next = () => { - - let returnVal; - - if(prevIndex >= 0){ - returnVal = Boolean( - callable.call( - null, - storeArray[prevIndex--], - next - ) - ); - }else{ - callable = !0; - returnVal = callable; - } - - return returnVal; - }; - - next(); - }, - setActionVectors(object, vectors) { - const _proto = getObjectPrototype(object); - const dispatcher = this.getInstance(); - let vector = null; - - for(const creator in vectors){ - if(Hop.call(vectors, creator)){ - vector = vectors[creator]; - _proto[creator] = this.createActionInterface(dispatcher, vector); - } - } - - return object; - }, - createStoreInterface(dispatcher, method) { - - - return function(){ - let regFunc; - let area; - const argument = arguments.length? arguments[0] : null; - - if(method == 'setChangeListener'){ - - return dispatcher.setStoreListener(this, argument); - } - - if(method == 'unsetChangeListener'){ - - return dispatcher.unsetStoreListener(this, argument); - } - - if(method == 'getState'){ - - let value; - area = new Area(this.getTitle()); - value = area.get(); - area = null; - - if(value === area){ - - regFunc = dispatcher.getRegistration(this.getTitle()); - - return (regFunc.$$history.length && regFunc.$$history[0]); - } - - return (typeof argument == 'string' && (argument in value)) ? value[argument] : value; - } - - if(method == 'destroy'){ - - let title, index; - - if(title in stores){ - - delete stores[title]; - - } - - area = new Area(this.getTitle()); - - area.del(); - - return (area = title = null); - } - - if(method == 'disconnect'){ - - return dispatcher.unregister(this.getTitle()); - } - - if(method == 'hydrate'){ - - if(isNullOrUndefined(argument)){ - return; - } - - return dispatcher.signalUnique({ - source:method, - target:this.getTitle(), - actionData:argument - }); - } - - if(method == 'getQuerySchema'){ - - return {}; - } - - if(method == 'setQuerySchema'){ - - return true; - } - - if(method == 'canUndo'){ - - regFunc = dispatcher.getRegistration(this.getTitle()); - - return (regFunc.$$historyIndex != 0); - } - - if(method == 'swapCallback'){ - - return dispatcher.register(this.getTitle(), argument); - } - - if(method == 'canRedo'){ - - regFunc = dispatcher.getRegistration(this.getTitle()); - - return (regFunc.$$historyIndex !== regFunc.$$history.length - 1); - } - - if(method == 'undo'){ - - return dispatcher.handleStoreMutation(this, method); - - } - - if(method == 'redo'){ - - return dispatcher.handleStoreMutation(this, method); - - } - } - - }, - createActionInterface(dispatcher, vector) { - - if(!(vector instanceof Object)){ - - throw new TypeError(`Invalid Action Creator Vector, expected [object] but found [${typeof(vector)}]`); - } - - return function(data, stateAspectKey){ - - // console.log('OUTER-FUNC: ', this.constructor.caller); - - const id = this.getId(); - - let typesBitMask = 0; - - if(!isNullOrUndefined(dispatchRegistry[id])){ - dispatchRegistry[id].actionTypes.push( - vector - ); - } - - if(vector.actionDefinition instanceof Array){ - - _each(vector.actionDefinition, function(definition){ - - typesBitMask |= Number(Values.isOfType(definition, data)); - - }); - - if(!typesBitMask){ - - throw new TypeError(`Action Data Invalid for action: [${vector.type}]`); - } - - }else{ - if(!Values.isOfType(vector.actionDefinition, data)){ - - throw new TypeError(`Action Data Invalid for action: [${vector.type}]`); - - } - } - - return dispatcher.signal({ - source:id, - actionType:vector.type, - actionKey:stateAspectKey || null, - actionData:data - }); - } - }, - watchDispatcher(callback) { - - const dispatcher = this.getInstance(); - - dispatcher.watch(callback); - - }, - isAppStateAutoRehydrated() { - - const dispatcher = this.getInstance(); - - return dispatcher.getAutoRehydrationState(); - }, - mergeConfig(cfg, hub) { - - const dispatcher = this.getInstance(); - - config = _extend(cfg, _defaultConfig); - - if(config.universalCoverage){ - config.persistenceEnabled = true; - } - - if(!config.runtime.spaMode){ - - if(typeof config.runtime.shutDownHref === 'string' - && config.runtime.shutDownHref.length != 0){ - - wind.onbeforeunload = $createBeforeTearDownCallback(config); - - wind.onunload = $createTearDownCallback(hub); - } - }else{ - - if(typeof config.runtime.shutDownHref === 'string' - && config.runtime.shutDownHref.length != 0){ - - if(win.addEventListener){ - document.documentElement.addEventListener('click', $createBeforeTearDownCallback(config), false); - document.addEventListener('click', $createTearDownCallback(hub), false); - }else{ - document.documentElement.attachEvent('onclick', $createBeforeTearDownCallback(config)); - document.attachEvent('onclick', $createTearDownCallback(hub), false); - } - } - } - - if(config.persistenceEnabled){ - - // prepare Origin - const _origin = getAppOriginForPersist(config), _tag = generateTag(_origin); - - persistStore.setItem(_origin, _tag); - - enforceCoverage.$$origin = _origin; - - enforceCoverage.$$tag = _tag; - - coverageNotifier.$$canOmit = true; - - coverageNotifier.$$tag = _tag; - - hub.onDispatch(coverageNotifier); - } - - dispatcher.initCatchers(config); - - return config; - }, - purgePersistStore() { - - const _origin = getAppOriginForPersist(config); - - const _tag = generateTag(_origin); - - persistStore.removeItem(_origin); - - persistStore.removeItem(_tag); - - }, - registerAction() { - /* creates hex value e.g. '0ef352ab287f1' */ - const regId = Math.random().toString(16).substr(2, 13); - - dispatchRegistry[regId] = {actionTypes:[]}; - - return regId; - - }, - makeAggregator() { - - return { - notifyAllStores() { - /* - */ - } - }; - }, - setMiddlewareCallback(middlewareFunc) { - - const dispatcher = this.getInstance(); - - // HERE: using this try/catch for control flow and not defensive programming - try{ - - dispatcher.getMiddleware(); - - }catch(ex){ - - dispatcher.setMiddleware( - middlewareFunc - ); - - }finally { - - } - - }, - setStoreObserver(object, regFunc, defaultStateObj) { - if(typeof regFunc !== "function"){ - return null; - } - - const _proto = getObjectPrototype(object); - const dispatcher = this.getInstance(); - const title = object.getTitle(); - let method = null; - - dispatcher.register(title, regFunc, defaultStateObj); - - const methods = ['setChangeListener', 'unsetChangeListener', 'getState', 'disconnect', 'getQuerySchema', 'canRedo', 'canUndo', 'swapCallback', 'undo', 'redo', 'hydrate', 'destroy']; - - for(let c=0; c < methods.length; c++){ - method = methods[c]; - _proto[method] = this.createStoreInterface(dispatcher, method); - } - } - }; -})(wind)); - -class Hub { - constructor() { - - this.toString = () => "[object RadixxHub]" - - this.Helpers = { - isEqual(former, latter) { - if (former === latter) { - return true; - } - - if (typeof former !== 'object' || former === null || - typeof latter !== 'object' || latter === null) { - return false; - } - - const keysA = Object.keys(former); - const keysB = Object.keys(latter); - - if (keysA.length !== keysB.length) { - return false; - } - - // Test for A's keys different from B. - const bHasOwnProperty = hasOwnProperty.bind(latter); - for (let i = 0; i < keysA.length; i++) { - if (!bHasOwnProperty(keysA[i]) || former[keysA[i]] !== latter[keysA[i]]) { - return false; - } - } - } - }; - - this.Payload = { - type:{ - "array":"array", - "date":"date", - "string":"string", - "regexp":"regexp", - "boolean":"boolean", - "function":"function", - "object":"object", - "number":"number", - "error"(value) { - - return (value instanceof Error || value instanceof TypeError); - }, - "nullable"(value) { - - return (value === null || value === undefined); - }, - "numeric":{ - Int(value) { - return isFinite(value) && (value === parseInt(value)) - }, - Float(value) { - return isFinite(value) && (value === parseFloat(value)) - } - }, - "any"(value) { - - return (value !== null || value !== undefined); - } - } - }; - - } - - onShutdown(handler) { - - if(typeof handler === 'function'){ - - _ping = handler; - } - - } - - purgePersistentStorage() { - - Observable.purgePersistStore(); - } - - /*Hub.prototype.onError = function(handler){ - };*/ - - onDispatch(handler) { - - if(typeof handler === 'function'){ - - Observable.watchDispatcher(handler); - } - - } - - requestAggregator() { - - return Observable.makeAggregator(); - } - - eachStore(callback) { - - return Observable.eachStore(callback, function(stores, key){ - this.push(stores[key]); - }, null); - } - - makeActionCreators(vectors) { - - function _action(registrationId){ - Action.apply(this, Slc.call(arguments)); - } - - const actionObject = new _action(Observable.registerAction()); // Observable.registerAction(); - - return Observable.setActionVectors(actionObject, vectors); - } - - makeStore(dataTitle, registerCallback, defaultStateObj) { - - function _store(){ - Store.apply(this, Slc.call(arguments)); - } - - const storeObject = new _store(dataTitle); - - Observable.setStoreObserver(storeObject, registerCallback, defaultStateObj); - - return storeObject; - } - - attachMiddleware(callback) { - - Observable.setMiddlewareCallback(callback); - - } - - isAppStateAutoRehydrated() { - - return Observable.isAppStateAutoRehydrated(); - } - - configure(config) { - - Observable.mergeConfig(config, this); - - } -} - -Hub.prototype.constructor = Hub; - -export default new Hub( - -); diff --git a/src/radixx.js b/src/radixx.js index dce5187..b02af67 100644 --- a/src/radixx.js +++ b/src/radixx.js @@ -11,17 +11,6 @@ * @desc: Implementation of Facebooks' Flux Architecture with a Twist. */ - /** - * - * When using with TypeScript in the `tsconfig` - * - * { - "compilerOptions": { - "module": "es2015", - "allowSyntheticDefaultImports": true - } - } - */ !function(root, factory){ 'use strict'; diff --git a/webpack.config.js b/webpack.config.js index 56f62fc..771f013 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -3,22 +3,22 @@ var webpack = require('webpack'); var env = require('yargs').argv.env; // use --env with webpack 2 var pkg = require('./package.json'); -// var UglifyJsPlugin = webpack.optimize.UglifyJsPlugin; var libraryName = pkg.name, plugins = [], outputFile, mode; if (env === 'build') { - // plugins.push(new UglifyJsPlugin({ minimize: true })); + outputFile = libraryName + '.es2015.min.js'; mode = 'production'; -} else { +} else if(env === 'dev') { + outputFile = libraryName + '.es2015.js'; mode = 'development'; } module.exports = { mode: mode, - entry:path.resolve(__dirname, '/src/es/index.js'), + entry:path.resolve(__dirname, './src/es/index.js'), output:{ path: path.resolve(__dirname, './dist'), filename:outputFile/*, @@ -29,9 +29,9 @@ module.exports = { module:{ rules: [ { - test: /\.js$/, - loader: 'babel-loader', - exclude: /node_modules/ + test: /\.js$/, + loader: 'babel-loader', + exclude: /node_modules/ }/*, { test: /\.js$/, @@ -41,12 +41,17 @@ module.exports = { ] }, resolve: { - modules: [path.resolve('./node_modules'), path.resolve('./src')], - extensions: ['.json', '.js'] + modules: [ + path.resolve('./node_modules'), + path.resolve('./src') + ], + extensions: [ + '.json', + '.js' + ] }, performance: { hints: false }, - devtool: 'source-map'/*, - plugins: plugins */ + devtool: 'source-map' };