shinkansen-pantograph 1.0.20 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ npm run pre-commit
package/babel.config.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const debug = require('debug')
2
2
 
3
- const log = debug('shinkansen:pantograph')
3
+ const log = debug('shinkansen-pantograph')
4
4
 
5
5
  const {
6
6
  env: {
package/index.js CHANGED
@@ -1,2 +1,7 @@
1
- //
1
+ const debug = require('debug')
2
+
3
+ const log = debug('shinkansen-pantograph')
4
+
5
+ log('`pantograph` is awake')
6
+
2
7
  module.exports = require('./lib')
package/lib/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"Pantograph",{enumerable:true,get:function get(){return _pantograph["default"];}});var _pantograph=_interopRequireDefault(require("./pantograph"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj};}
1
+ "use strict";require("core-js/modules/es.object.define-property.js");Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"Pantograph",{enumerable:true,get:function get(){return _pantograph["default"];}});var _pantograph=_interopRequireDefault(require("./pantograph"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj};}
@@ -1 +1 @@
1
- "use strict";require("core-js/modules/es.object.define-property");Object.defineProperty(exports,"__esModule",{value:true});exports.redirectToAlpha=redirectToAlpha;exports.redirectToOmega=redirectToOmega;exports.redirectToEmbark=redirectToEmbark;exports.redirectToDebark=redirectToDebark;exports.redirectToConfirm=redirectToConfirm;exports.redirect=redirect;exports.redirectFromAlpha=redirectFromAlpha;exports.redirectFromOmega=redirectFromOmega;exports.redirectFromEmbark=redirectFromEmbark;exports.redirectFromDebark=redirectFromDebark;exports.redirectFromConfirm=redirectFromConfirm;exports.graphite=graphite;exports["default"]=void 0;var _debug=_interopRequireDefault(require("debug"));var _shinkansenRails=require("shinkansen-rails");var _shinkansenSignals=require("shinkansen-signals");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}var log=(0,_debug["default"])('shinkansen:pantograph');var ALPHA={ERROR:'ALPHA_ERROR',ROUTE:'ALPHA_ROUTE',MOUNT:'ALPHA_MOUNT',FETCH:'ALPHA_FETCH',STORE:'ALPHA_STORE',QUERY:'ALPHA_QUERY',CHANGE:'ALPHA_CHANGE',SUBMIT:'ALPHA_SUBMIT'};var OMEGA={ERROR:'OMEGA_ERROR',ROUTE:'OMEGA_ROUTE',MOUNT:'OMEGA_MOUNT',FETCH:'OMEGA_FETCH',STORE:'OMEGA_STORE',QUERY:'OMEGA_QUERY',CHANGE:'OMEGA_CHANGE',SUBMIT:'OMEGA_SUBMIT'};var EMBARK={ERROR:'EMBARK_ERROR',ROUTE:'EMBARK_ROUTE',MOUNT:'EMBARK_MOUNT',FETCH:'EMBARK_FETCH',STORE:'EMBARK_STORE',CHANGE:'EMBARK_CHANGE',SUBMIT:'EMBARK_SUBMIT'};var DEBARK={ERROR:'DEBARK_ERROR',ROUTE:'DEBARK_ROUTE',MOUNT:'DEBARK_MOUNT',FETCH:'DEBARK_FETCH',STORE:'DEBARK_STORE',CHANGE:'DEBARK_CHANGE',SUBMIT:'DEBARK_SUBMIT'};var CONFIRM={ERROR:'CONFIRM_ERROR',ROUTE:'CONFIRM_ROUTE',MOUNT:'CONFIRM_MOUNT',FETCH:'CONFIRM_FETCH',STORE:'CONFIRM_STORE',CHANGE:'CONFIRM_CHANGE',SUBMIT:'CONFIRM_SUBMIT'};var ACTION={};var STATE={};var HISTORY={push:function push(){},getCurrentLocation:function getCurrentLocation(){return{};}};function redirectToAlpha(_ref){var alpha=_ref.alpha,history=_ref.history;log('redirectToAlpha');var pathname=_shinkansenRails.Rails.to(_defineProperty({},_shinkansenSignals.Signals.ALPHA,alpha),_shinkansenSignals.Signals.ALPHA_PATTERN);var _history$getCurrentLo=history.getCurrentLocation(),currentPathname=_history$getCurrentLo.pathname;if(pathname!==currentPathname)history.push(pathname);}function redirectToOmega(_ref2){var _Rails$to2;var alpha=_ref2.alpha,omega=_ref2.omega,history=_ref2.history;log('redirectToOmega');var pathname=_shinkansenRails.Rails.to((_Rails$to2={},_defineProperty(_Rails$to2,_shinkansenSignals.Signals.ALPHA,alpha),_defineProperty(_Rails$to2,_shinkansenSignals.Signals.OMEGA,omega),_Rails$to2),_shinkansenSignals.Signals.OMEGA_PATTERN);var _history$getCurrentLo2=history.getCurrentLocation(),currentPathname=_history$getCurrentLo2.pathname;if(pathname!==currentPathname)history.push(pathname);}function redirectToEmbark(_ref3){var embark=_ref3.embark,history=_ref3.history;log('redirectToEmbark');var pathname=_shinkansenRails.Rails.to(_defineProperty({},_shinkansenSignals.Signals.EMBARK,embark),_shinkansenSignals.Signals.EMBARK_PATTERN);var _history$getCurrentLo3=history.getCurrentLocation(),currentPathname=_history$getCurrentLo3.pathname;if(pathname!==currentPathname)history.push(pathname);}function redirectToDebark(_ref4){var debark=_ref4.debark,history=_ref4.history;log('redirectToDebark');var pathname=_shinkansenRails.Rails.to(_defineProperty({},_shinkansenSignals.Signals.DEBARK,debark),_shinkansenSignals.Signals.DEBARK_PATTERN);var _history$getCurrentLo4=history.getCurrentLocation(),currentPathname=_history$getCurrentLo4.pathname;if(pathname!==currentPathname)history.push(pathname);}function redirectToConfirm(_ref5){var confirm=_ref5.confirm,history=_ref5.history;log('redirectToDebark');var pathname=_shinkansenRails.Rails.to(_defineProperty({},_shinkansenSignals.Signals.CONFIRM,confirm),_shinkansenSignals.Signals.CONFIRM_PATTERN);var _history$getCurrentLo5=history.getCurrentLocation(),currentPathname=_history$getCurrentLo5.pathname;if(pathname!==currentPathname)history.push(pathname);}function redirect(_ref6){var _ref6$redirect=_ref6.redirect;_ref6$redirect=_ref6$redirect===void 0?{}:_ref6$redirect;var alpha=_ref6$redirect[_shinkansenSignals.Signals.ALPHA],omega=_ref6$redirect[_shinkansenSignals.Signals.OMEGA],embark=_ref6$redirect[_shinkansenSignals.Signals.EMBARK],debark=_ref6$redirect[_shinkansenSignals.Signals.DEBARK],confirm=_ref6$redirect[_shinkansenSignals.Signals.CONFIRM],history=_ref6.history;log('redirect()');if(alpha&&omega){redirectToOmega({alpha:alpha,omega:omega,history:history});}else if(embark){redirectToEmbark({embark:embark,history:history});}else if(debark){redirectToDebark({debark:debark,history:history});}else if(confirm){redirectToDebark({confirm:confirm,history:history});}else if(alpha){redirectToAlpha({alpha:alpha,history:history});}else if(omega){throw Error('Pantograph encountered a route error in `redirect()`');}}function redirectFromAlpha(_ref7){var _ref7$state=_ref7.state;_ref7$state=_ref7$state===void 0?{}:_ref7$state;var _ref7$state$Signals$A=_ref7$state[_shinkansenSignals.Signals.ALPHA];_ref7$state$Signals$A=_ref7$state$Signals$A===void 0?{}:_ref7$state$Signals$A;var route=_ref7$state$Signals$A.redirect,history=_ref7.history;log('redirectFromAlpha()');if(route)redirect({redirect:route,history:history});}function redirectFromOmega(_ref8){var _ref8$state=_ref8.state;_ref8$state=_ref8$state===void 0?{}:_ref8$state;var _ref8$state$Signals$O=_ref8$state[_shinkansenSignals.Signals.OMEGA];_ref8$state$Signals$O=_ref8$state$Signals$O===void 0?{}:_ref8$state$Signals$O;var route=_ref8$state$Signals$O.redirect,history=_ref8.history;log('redirectFromOmega()');if(route)redirect({redirect:route,history:history});}function redirectFromEmbark(_ref9){var _ref9$state=_ref9.state;_ref9$state=_ref9$state===void 0?{}:_ref9$state;var _ref9$state$Signals$E=_ref9$state[_shinkansenSignals.Signals.EMBARK];_ref9$state$Signals$E=_ref9$state$Signals$E===void 0?{}:_ref9$state$Signals$E;var route=_ref9$state$Signals$E.redirect,history=_ref9.history;log('redirectFromEmbark()');if(route)redirect({redirect:route,history:history});}function redirectFromDebark(_ref10){var _ref10$state=_ref10.state;_ref10$state=_ref10$state===void 0?{}:_ref10$state;var _ref10$state$Signals$=_ref10$state[_shinkansenSignals.Signals.DEBARK];_ref10$state$Signals$=_ref10$state$Signals$===void 0?{}:_ref10$state$Signals$;var route=_ref10$state$Signals$.redirect,history=_ref10.history;log('redirectFromDebark()');if(route)redirect({redirect:route,history:history});}function redirectFromConfirm(_ref11){var _ref11$state=_ref11.state;_ref11$state=_ref11$state===void 0?{}:_ref11$state;var _ref11$state$Signals$=_ref11$state[_shinkansenSignals.Signals.CONFIRM];_ref11$state$Signals$=_ref11$state$Signals$===void 0?{}:_ref11$state$Signals$;var route=_ref11$state$Signals$.redirect,history=_ref11.history;log('redirectFromConfirm()');if(route)redirect({redirect:route,history:history});}function graphite(_ref12){var _ref12$action=_ref12.action;_ref12$action=_ref12$action===void 0?ACTION:_ref12$action;var type=_ref12$action.type,_ref12$state=_ref12.state,state=_ref12$state===void 0?STATE:_ref12$state,_ref12$history=_ref12.history,history=_ref12$history===void 0?HISTORY:_ref12$history;switch(type){case OMEGA.ROUTE:redirectFromOmega({state:state,history:history});break;case EMBARK.ROUTE:redirectFromEmbark({state:state,history:history});break;case DEBARK.ROUTE:redirectFromDebark({state:state,history:history});break;case CONFIRM.ROUTE:redirectFromDebark({state:state,history:history});break;case ALPHA.ROUTE:redirectFromAlpha({state:state,history:history});break;}}var Pantograph=function(){function Pantograph(){_classCallCheck(this,Pantograph);}_createClass(Pantograph,null,[{key:"ALPHA",get:function get(){return ALPHA;}},{key:"OMEGA",get:function get(){return OMEGA;}},{key:"EMBARK",get:function get(){return EMBARK;}},{key:"DEBARK",get:function get(){return DEBARK;}},{key:"CONFIRM",get:function get(){return CONFIRM;}}]);return Pantograph;}();exports["default"]=Pantograph;_defineProperty(Pantograph,"graphite",graphite);
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.redirectToAlpha=redirectToAlpha;exports.redirectToOmega=redirectToOmega;exports.redirectToEmbark=redirectToEmbark;exports.redirectToDebark=redirectToDebark;exports.redirectToConfirm=redirectToConfirm;exports.redirectTo=redirectTo;exports.redirectFromAlpha=redirectFromAlpha;exports.redirectFromOmega=redirectFromOmega;exports.redirectFromEmbark=redirectFromEmbark;exports.redirectFromDebark=redirectFromDebark;exports.redirectFromConfirm=redirectFromConfirm;exports.graphite=graphite;exports["default"]=void 0;require("core-js/modules/es.object.freeze.js");require("core-js/modules/es.object.define-property.js");var _debug=_interopRequireDefault(require("debug"));var _shinkansenRails=require("shinkansen-rails");var _shinkansenSignals=require("shinkansen-signals");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}var log=(0,_debug["default"])('shinkansen-pantograph');var ALPHA={ERROR:'ALPHA_ERROR',ROUTE:'ALPHA_ROUTE',MOUNT:'ALPHA_MOUNT',FETCH:'ALPHA_FETCH',STORE:'ALPHA_STORE',QUERY:'ALPHA_QUERY',CHANGE:'ALPHA_CHANGE',SUBMIT:'ALPHA_SUBMIT'};var OMEGA={ERROR:'OMEGA_ERROR',ROUTE:'OMEGA_ROUTE',MOUNT:'OMEGA_MOUNT',FETCH:'OMEGA_FETCH',STORE:'OMEGA_STORE',QUERY:'OMEGA_QUERY',CHANGE:'OMEGA_CHANGE',SUBMIT:'OMEGA_SUBMIT'};var EMBARK={ERROR:'EMBARK_ERROR',ROUTE:'EMBARK_ROUTE',MOUNT:'EMBARK_MOUNT',FETCH:'EMBARK_FETCH',STORE:'EMBARK_STORE',CHANGE:'EMBARK_CHANGE',SUBMIT:'EMBARK_SUBMIT'};var DEBARK={ERROR:'DEBARK_ERROR',ROUTE:'DEBARK_ROUTE',MOUNT:'DEBARK_MOUNT',FETCH:'DEBARK_FETCH',STORE:'DEBARK_STORE',CHANGE:'DEBARK_CHANGE',SUBMIT:'DEBARK_SUBMIT'};var CONFIRM={ERROR:'CONFIRM_ERROR',ROUTE:'CONFIRM_ROUTE',MOUNT:'CONFIRM_MOUNT',FETCH:'CONFIRM_FETCH',STORE:'CONFIRM_STORE',CHANGE:'CONFIRM_CHANGE',SUBMIT:'CONFIRM_SUBMIT'};var ACTION={};var STATE={};var HISTORY={push:function push(){},getCurrentLocation:function getCurrentLocation(){return{};}};function redirectToAlpha(_ref){var alpha=_ref.alpha,history=_ref.history;log('redirectToAlpha');var pathname=_shinkansenRails.Rails.to(_defineProperty({},_shinkansenSignals.Signals.ALPHA,alpha),_shinkansenSignals.Signals.ALPHA_PATTERN);var _history$getCurrentLo=history.getCurrentLocation(),currentPathname=_history$getCurrentLo.pathname;if(pathname!==currentPathname)history.push(pathname);}function redirectToOmega(_ref2){var _Rails$to2;var alpha=_ref2.alpha,omega=_ref2.omega,history=_ref2.history;log('redirectToOmega');var pathname=_shinkansenRails.Rails.to((_Rails$to2={},_defineProperty(_Rails$to2,_shinkansenSignals.Signals.ALPHA,alpha),_defineProperty(_Rails$to2,_shinkansenSignals.Signals.OMEGA,omega),_Rails$to2),_shinkansenSignals.Signals.OMEGA_PATTERN);var _history$getCurrentLo2=history.getCurrentLocation(),currentPathname=_history$getCurrentLo2.pathname;if(pathname!==currentPathname)history.push(pathname);}function redirectToEmbark(_ref3){var embark=_ref3.embark,history=_ref3.history;log('redirectToEmbark');var pathname=_shinkansenRails.Rails.to(_defineProperty({},_shinkansenSignals.Signals.EMBARK,embark),_shinkansenSignals.Signals.EMBARK_PATTERN);var _history$getCurrentLo3=history.getCurrentLocation(),currentPathname=_history$getCurrentLo3.pathname;if(pathname!==currentPathname)history.push(pathname);}function redirectToDebark(_ref4){var debark=_ref4.debark,history=_ref4.history;log('redirectToDebark');var pathname=_shinkansenRails.Rails.to(_defineProperty({},_shinkansenSignals.Signals.DEBARK,debark),_shinkansenSignals.Signals.DEBARK_PATTERN);var _history$getCurrentLo4=history.getCurrentLocation(),currentPathname=_history$getCurrentLo4.pathname;if(pathname!==currentPathname)history.push(pathname);}function redirectToConfirm(_ref5){var confirm=_ref5.confirm,history=_ref5.history;log('redirectToDebark');var pathname=_shinkansenRails.Rails.to(_defineProperty({},_shinkansenSignals.Signals.CONFIRM,confirm),_shinkansenSignals.Signals.CONFIRM_PATTERN);var _history$getCurrentLo5=history.getCurrentLocation(),currentPathname=_history$getCurrentLo5.pathname;if(pathname!==currentPathname)history.push(pathname);}function redirectTo(_ref6){var _ref6$redirect=_ref6.redirect;_ref6$redirect=_ref6$redirect===void 0?{}:_ref6$redirect;var alpha=_ref6$redirect[_shinkansenSignals.Signals.ALPHA],omega=_ref6$redirect[_shinkansenSignals.Signals.OMEGA],embark=_ref6$redirect[_shinkansenSignals.Signals.EMBARK],debark=_ref6$redirect[_shinkansenSignals.Signals.DEBARK],confirm=_ref6$redirect[_shinkansenSignals.Signals.CONFIRM],history=_ref6.history;log('`redirectTo`');if(alpha&&omega){redirectToOmega({alpha:alpha,omega:omega,history:history});}else if(embark){redirectToEmbark({embark:embark,history:history});}else if(debark){redirectToDebark({debark:debark,history:history});}else if(confirm){redirectToDebark({confirm:confirm,history:history});}else if(alpha){redirectToAlpha({alpha:alpha,history:history});}else if(omega){throw Error('Pantograph encountered a route error in `redirectTo()`');}}function redirectFromAlpha(_ref7){var _ref7$state=_ref7.state;_ref7$state=_ref7$state===void 0?{}:_ref7$state;var _ref7$state$Signals$A=_ref7$state[_shinkansenSignals.Signals.ALPHA];_ref7$state$Signals$A=_ref7$state$Signals$A===void 0?{}:_ref7$state$Signals$A;var redirect=_ref7$state$Signals$A.redirect,history=_ref7.history;log('redirectFromAlpha()');if(redirect)redirectTo({redirect:redirect,history:history});}function redirectFromOmega(_ref8){var _ref8$state=_ref8.state;_ref8$state=_ref8$state===void 0?{}:_ref8$state;var _ref8$state$Signals$O=_ref8$state[_shinkansenSignals.Signals.OMEGA];_ref8$state$Signals$O=_ref8$state$Signals$O===void 0?{}:_ref8$state$Signals$O;var redirect=_ref8$state$Signals$O.redirect,history=_ref8.history;log('redirectFromOmega()');if(redirect)redirectTo({redirect:redirect,history:history});}function redirectFromEmbark(_ref9){var _ref9$state=_ref9.state;_ref9$state=_ref9$state===void 0?{}:_ref9$state;var _ref9$state$Signals$E=_ref9$state[_shinkansenSignals.Signals.EMBARK];_ref9$state$Signals$E=_ref9$state$Signals$E===void 0?{}:_ref9$state$Signals$E;var redirect=_ref9$state$Signals$E.redirect,history=_ref9.history;log('redirectFromEmbark()');if(redirect)redirectTo({redirect:redirect,history:history});}function redirectFromDebark(_ref10){var _ref10$state=_ref10.state;_ref10$state=_ref10$state===void 0?{}:_ref10$state;var _ref10$state$Signals$=_ref10$state[_shinkansenSignals.Signals.DEBARK];_ref10$state$Signals$=_ref10$state$Signals$===void 0?{}:_ref10$state$Signals$;var redirect=_ref10$state$Signals$.redirect,history=_ref10.history;log('redirectFromDebark()');if(redirect)redirectTo({redirect:redirect,history:history});}function redirectFromConfirm(_ref11){var _ref11$state=_ref11.state;_ref11$state=_ref11$state===void 0?{}:_ref11$state;var _ref11$state$Signals$=_ref11$state[_shinkansenSignals.Signals.CONFIRM];_ref11$state$Signals$=_ref11$state$Signals$===void 0?{}:_ref11$state$Signals$;var redirect=_ref11$state$Signals$.redirect,history=_ref11.history;log('redirectFromConfirm()');if(redirect)redirectTo({redirect:redirect,history:history});}function graphite(_ref12){var _ref12$action=_ref12.action;_ref12$action=_ref12$action===void 0?ACTION:_ref12$action;var type=_ref12$action.type,_ref12$state=_ref12.state,state=_ref12$state===void 0?STATE:_ref12$state,_ref12$history=_ref12.history,history=_ref12$history===void 0?HISTORY:_ref12$history;switch(type){case OMEGA.ROUTE:redirectFromOmega({state:state,history:history});break;case EMBARK.ROUTE:redirectFromEmbark({state:state,history:history});break;case DEBARK.ROUTE:redirectFromDebark({state:state,history:history});break;case CONFIRM.ROUTE:redirectFromDebark({state:state,history:history});break;case ALPHA.ROUTE:redirectFromAlpha({state:state,history:history});break;}}var Pantograph=function(){function Pantograph(){_classCallCheck(this,Pantograph);}_createClass(Pantograph,null,[{key:"ALPHA",get:function get(){return ALPHA;}},{key:"OMEGA",get:function get(){return OMEGA;}},{key:"EMBARK",get:function get(){return EMBARK;}},{key:"DEBARK",get:function get(){return DEBARK;}},{key:"CONFIRM",get:function get(){return CONFIRM;}}]);return Pantograph;}();_defineProperty(Pantograph,"graphite",graphite);var _default=Object.freeze(Pantograph);exports["default"]=_default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shinkansen-pantograph",
3
- "version": "1.0.20",
3
+ "version": "1.1.1",
4
4
  "description": "Shinkansen Pantograph",
5
5
  "keywords": [
6
6
  "Shinkansen",
@@ -24,7 +24,7 @@
24
24
  "scripts": {
25
25
  "prepublishOnly": "cross-env NODE_ENV=production npm run build",
26
26
  "prebuild": "npm run clean",
27
- "build": "npm run babel",
27
+ "build": "cross-env DEBUG=shinkansen-pantograph npm run babel",
28
28
  "build:watch": "npm run babel:watch",
29
29
  "clean": "rimraf lib",
30
30
  "babel": "babel src -d lib",
@@ -35,43 +35,33 @@
35
35
  "pre-commit": "npm run lint && npm test && npm run build && git add lib"
36
36
  },
37
37
  "dependencies": {
38
- "debug": "^4.2.0"
38
+ "debug": "^4.3.2"
39
39
  },
40
40
  "devDependencies": {
41
- "@babel/cli": "^7.12.1",
42
- "@babel/core": "^7.12.3",
43
- "@babel/eslint-parser": "^7.12.1",
44
- "@babel/plugin-proposal-class-properties": "^7.12.1",
45
- "@babel/plugin-proposal-export-default-from": "^7.12.1",
46
- "@babel/preset-env": "^7.12.1",
47
- "@babel/register": "^7.12.1",
48
- "babel-loader": "^8.1.0",
49
- "babel-plugin-module-resolver": "^4.0.0",
50
- "chai": "^4.2.0",
51
- "core-js": "^3.6.5",
52
- "cross-env": "^7.0.2",
53
- "eslint": "^7.11.0",
54
- "eslint-config-standard": "^14.1.1",
55
- "eslint-import-resolver-babel-module": "^5.2.0",
56
- "eslint-plugin-import": "^2.22.1",
41
+ "@babel/cli": "^7.15.4",
42
+ "@babel/core": "^7.15.5",
43
+ "@babel/eslint-parser": "^7.15.4",
44
+ "@babel/plugin-proposal-class-properties": "^7.14.5",
45
+ "@babel/plugin-proposal-export-default-from": "^7.14.5",
46
+ "@babel/preset-env": "^7.15.6",
47
+ "@babel/register": "^7.15.3",
48
+ "babel-loader": "^8.2.2",
49
+ "babel-plugin-module-resolver": "^4.1.0",
50
+ "chai": "^4.3.4",
51
+ "core-js": "^3.17.3",
52
+ "cross-env": "^7.0.3",
53
+ "eslint": "^7.32.0",
54
+ "eslint-config-standard": "^16.0.3",
55
+ "eslint-import-resolver-babel-module": "^5.3.1",
56
+ "eslint-plugin-import": "^2.24.2",
57
57
  "eslint-plugin-node": "^11.1.0",
58
- "eslint-plugin-promise": "^4.2.1",
59
- "eslint-plugin-standard": "^4.0.1",
60
- "husky": "^4.3.0",
61
- "mocha": "^8.2.0",
58
+ "eslint-plugin-promise": "^5.1.0",
59
+ "husky": "^7.0.2",
60
+ "mocha": "^9.1.1",
62
61
  "rimraf": "^3.0.2",
63
- "shinkansen-rails": "1.0.16",
64
- "shinkansen-signals": "1.0.16",
65
- "sinon": "^9.2.0",
66
- "sinon-chai": "^3.5.0"
67
- },
68
- "peerDependencies": {
69
- "shinkansen-rails": "1.0.16",
70
- "shinkansen-signals": "1.0.16"
71
- },
72
- "husky": {
73
- "hooks": {
74
- "pre-commit": "npm run pre-commit"
75
- }
62
+ "shinkansen-rails": "1.0.18",
63
+ "shinkansen-signals": "1.1.2",
64
+ "sinon": "^11.1.2",
65
+ "sinon-chai": "^3.7.0"
76
66
  }
77
67
  }
@@ -8,7 +8,7 @@ import {
8
8
  Signals
9
9
  } from 'shinkansen-signals'
10
10
 
11
- const log = debug('shinkansen:pantograph')
11
+ const log = debug('shinkansen-pantograph')
12
12
 
13
13
  const ALPHA = {
14
14
  ERROR: 'ALPHA_ERROR',
@@ -126,7 +126,7 @@ export function redirectToConfirm ({ confirm, history }) {
126
126
  if (pathname !== currentPathname) history.push(pathname)
127
127
  }
128
128
 
129
- export function redirect ({
129
+ export function redirectTo ({
130
130
  redirect: {
131
131
  [Signals.ALPHA]: alpha,
132
132
  [Signals.OMEGA]: omega,
@@ -136,7 +136,7 @@ export function redirect ({
136
136
  } = {},
137
137
  history
138
138
  }) {
139
- log('redirect()')
139
+ log('`redirectTo`')
140
140
 
141
141
  if (alpha && omega) {
142
142
  redirectToOmega({ alpha, omega, history })
@@ -149,38 +149,38 @@ export function redirect ({
149
149
  } else if (alpha) { // can appear on its own
150
150
  redirectToAlpha({ alpha, history })
151
151
  } else if (omega) { // can not appear on its own
152
- throw Error('Pantograph encountered a route error in `redirect()`')
152
+ throw Error('Pantograph encountered a route error in `redirectTo()`')
153
153
  }
154
154
  }
155
155
 
156
- export function redirectFromAlpha ({ state: { [Signals.ALPHA]: { redirect: route } = {} } = {}, history }) {
156
+ export function redirectFromAlpha ({ state: { [Signals.ALPHA]: { redirect } = {} } = {}, history }) {
157
157
  log('redirectFromAlpha()')
158
158
 
159
- if (route) redirect({ redirect: route, history })
159
+ if (redirect) redirectTo({ redirect, history })
160
160
  }
161
161
 
162
- export function redirectFromOmega ({ state: { [Signals.OMEGA]: { redirect: route } = {} } = {}, history }) {
162
+ export function redirectFromOmega ({ state: { [Signals.OMEGA]: { redirect } = {} } = {}, history }) {
163
163
  log('redirectFromOmega()')
164
164
 
165
- if (route) redirect({ redirect: route, history })
165
+ if (redirect) redirectTo({ redirect, history })
166
166
  }
167
167
 
168
- export function redirectFromEmbark ({ state: { [Signals.EMBARK]: { redirect: route } = {} } = {}, history }) {
168
+ export function redirectFromEmbark ({ state: { [Signals.EMBARK]: { redirect } = {} } = {}, history }) {
169
169
  log('redirectFromEmbark()')
170
170
 
171
- if (route) redirect({ redirect: route, history })
171
+ if (redirect) redirectTo({ redirect, history })
172
172
  }
173
173
 
174
- export function redirectFromDebark ({ state: { [Signals.DEBARK]: { redirect: route } = {} } = {}, history }) {
174
+ export function redirectFromDebark ({ state: { [Signals.DEBARK]: { redirect } = {} } = {}, history }) {
175
175
  log('redirectFromDebark()')
176
176
 
177
- if (route) redirect({ redirect: route, history })
177
+ if (redirect) redirectTo({ redirect, history })
178
178
  }
179
179
 
180
- export function redirectFromConfirm ({ state: { [Signals.CONFIRM]: { redirect: route } = {} } = {}, history }) {
180
+ export function redirectFromConfirm ({ state: { [Signals.CONFIRM]: { redirect } = {} } = {}, history }) {
181
181
  log('redirectFromConfirm()')
182
182
 
183
- if (route) redirect({ redirect: route, history })
183
+ if (redirect) redirectTo({ redirect, history })
184
184
  }
185
185
 
186
186
  export function graphite ({ action: { type } = ACTION, state = STATE, history = HISTORY }) {
@@ -203,10 +203,10 @@ export function graphite ({ action: { type } = ACTION, state = STATE, history =
203
203
  }
204
204
  }
205
205
 
206
- export default class Pantograph {
207
- /**
208
- * Getters ensure that these fields are read-only
209
- */
206
+ /**
207
+ * Getters without setters ensure that these fields are read-only
208
+ */
209
+ class Pantograph {
210
210
  static get ALPHA () {
211
211
  return ALPHA
212
212
  }
@@ -229,3 +229,8 @@ export default class Pantograph {
229
229
 
230
230
  static graphite = graphite
231
231
  }
232
+
233
+ /**
234
+ * As does `freeze`
235
+ */
236
+ export default Object.freeze(Pantograph)