forked from enviPath/enviPy
Current Dev State
This commit is contained in:
19
static/js/ketcher2/node_modules/redux-logger/LICENSE
generated
vendored
Normal file
19
static/js/ketcher2/node_modules/redux-logger/LICENSE
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
Copyright (c) 2016 Eugene Rodionov
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
296
static/js/ketcher2/node_modules/redux-logger/README.md
generated
vendored
Normal file
296
static/js/ketcher2/node_modules/redux-logger/README.md
generated
vendored
Normal file
@ -0,0 +1,296 @@
|
||||
# Logger for Redux
|
||||
[](https://www.npmjs.com/package/redux-logger)
|
||||
[](https://www.npmjs.com/package/redux-logger)
|
||||
[](https://travis-ci.org/evgenyrodionov/redux-logger)
|
||||
|
||||

|
||||
|
||||
## Table of contents
|
||||
* [Install](#install)
|
||||
* [Usage](#usage)
|
||||
* [Options](#options)
|
||||
* [Recipes](#recipes)
|
||||
* [Log only in development](#log-only-in-development)
|
||||
* [Log everything except actions with certain type](#log-everything-except-actions-with-certain-type)
|
||||
* [Collapse actions with certain type](#collapse-actions-with-certain-type)
|
||||
* [Transform Immutable (without `combineReducers`)](#transform-immutable-without-combinereducers)
|
||||
* [Transform Immutable (with `combineReducers`)](#transform-immutable-with-combinereducers)
|
||||
* [Log batched actions](#log-batched-actions)
|
||||
* [To Do](#to-do)
|
||||
* [Known issues](#known-issues) (with `react-native` only at this moment)
|
||||
* [License](#license)
|
||||
|
||||
## Install
|
||||
`npm i --save redux-logger`
|
||||
|
||||
## Usage
|
||||
```javascript
|
||||
import { applyMiddleware, createStore } from 'redux';
|
||||
|
||||
// Logger with default options
|
||||
import logger from 'redux-logger'
|
||||
const store = createStore(
|
||||
reducer,
|
||||
applyMiddleware(logger)
|
||||
)
|
||||
|
||||
// Note passing middleware as the third argument requires redux@>=3.1.0
|
||||
```
|
||||
|
||||
Or you can create your own logger with custom [options](https://github.com/evgenyrodionov/redux-logger#options):
|
||||
```javascript
|
||||
import { applyMiddleware, createStore } from 'redux';
|
||||
import { createLogger } from 'redux-logger'
|
||||
|
||||
const logger = createLogger({
|
||||
// ...options
|
||||
});
|
||||
|
||||
const store = createStore(
|
||||
reducer,
|
||||
applyMiddleware(logger)
|
||||
);
|
||||
```
|
||||
|
||||
Note: logger **must be** the last middleware in chain, otherwise it will log thunk and promise, not actual actions ([#20](https://github.com/evgenyrodionov/redux-logger/issues/20)).
|
||||
|
||||
## Options
|
||||
```javascript
|
||||
{
|
||||
predicate, // if specified this function will be called before each action is processed with this middleware.
|
||||
collapsed, // takes a Boolean or optionally a Function that receives `getState` function for accessing current store state and `action` object as parameters. Returns `true` if the log group should be collapsed, `false` otherwise.
|
||||
duration = false: Boolean, // print the duration of each action?
|
||||
timestamp = true: Boolean, // print the timestamp with each action?
|
||||
|
||||
level = 'log': 'log' | 'console' | 'warn' | 'error' | 'info', // console's level
|
||||
colors: ColorsObject, // colors for title, prev state, action and next state: https://github.com/evgenyrodionov/redux-logger/blob/master/src/defaults.js#L12-L18
|
||||
titleFormatter, // Format the title used when logging actions.
|
||||
|
||||
stateTransformer, // Transform state before print. Eg. convert Immutable object to plain JSON.
|
||||
actionTransformer, // Transform action before print. Eg. convert Immutable object to plain JSON.
|
||||
errorTransformer, // Transform error before print. Eg. convert Immutable object to plain JSON.
|
||||
|
||||
logger = console: LoggerObject, // implementation of the `console` API.
|
||||
logErrors = true: Boolean, // should the logger catch, log, and re-throw errors?
|
||||
|
||||
diff = false: Boolean, // (alpha) show diff between states?
|
||||
diffPredicate // (alpha) filter function for showing states diff, similar to `predicate`
|
||||
}
|
||||
```
|
||||
|
||||
### Options description
|
||||
|
||||
#### __level (String | Function | Object)__
|
||||
Level of `console`. `warn`, `error`, `info` or [else](https://developer.mozilla.org/en/docs/Web/API/console).
|
||||
|
||||
It can be a function `(action: Object) => level: String`.
|
||||
|
||||
It can be an object with level string for: `prevState`, `action`, `nextState`, `error`
|
||||
|
||||
It can be an object with getter functions: `prevState`, `action`, `nextState`, `error`. Useful if you want to print
|
||||
message based on specific state or action. Set any of them to `false` if you want to hide it.
|
||||
|
||||
* `prevState(prevState: Object) => level: String`
|
||||
* `action(action: Object) => level: String`
|
||||
* `nextState(nextState: Object) => level: String`
|
||||
* `error(error: Any, prevState: Object) => level: String`
|
||||
|
||||
*Default: `log`*
|
||||
|
||||
#### __duration (Boolean)__
|
||||
Print duration of each action?
|
||||
|
||||
*Default: `false`*
|
||||
|
||||
#### __timestamp (Boolean)__
|
||||
Print timestamp with each action?
|
||||
|
||||
*Default: `true`*
|
||||
|
||||
#### __colors (Object)__
|
||||
Object with color getter functions: `title`, `prevState`, `action`, `nextState`, `error`. Useful if you want to paint
|
||||
message based on specific state or action. Set any of them to `false` if you want to show plain message without colors.
|
||||
|
||||
* `title(action: Object) => color: String`
|
||||
* `prevState(prevState: Object) => color: String`
|
||||
* `action(action: Object) => color: String`
|
||||
* `nextState(nextState: Object) => color: String`
|
||||
* `error(error: Any, prevState: Object) => color: String`
|
||||
|
||||
#### __logger (Object)__
|
||||
Implementation of the `console` API. Useful if you are using a custom, wrapped version of `console`.
|
||||
|
||||
*Default: `console`*
|
||||
|
||||
#### __logErrors (Boolean)__
|
||||
Should the logger catch, log, and re-throw errors? This makes it clear which action triggered the error but makes "break
|
||||
on error" in dev tools harder to use, as it breaks on re-throw rather than the original throw location.
|
||||
|
||||
*Default: `true`*
|
||||
|
||||
#### __collapsed = (getState: Function, action: Object, logEntry: Object) => Boolean__
|
||||
Takes a boolean or optionally a function that receives `getState` function for accessing current store state and `action` object as parameters. Returns `true` if the log group should be collapsed, `false` otherwise.
|
||||
|
||||
*Default: `false`*
|
||||
|
||||
#### __predicate = (getState: Function, action: Object) => Boolean__
|
||||
If specified this function will be called before each action is processed with this middleware.
|
||||
Receives `getState` function for accessing current store state and `action` object as parameters. Returns `true` if action should be logged, `false` otherwise.
|
||||
|
||||
*Default: `null` (always log)*
|
||||
|
||||
#### __stateTransformer = (state: Object) => state__
|
||||
Transform state before print. Eg. convert Immutable object to plain JSON.
|
||||
|
||||
*Default: identity function*
|
||||
|
||||
#### __actionTransformer = (action: Object) => action__
|
||||
Transform action before print. Eg. convert Immutable object to plain JSON.
|
||||
|
||||
*Default: identity function*
|
||||
|
||||
#### __errorTransformer = (error: Any) => error__
|
||||
Transform error before print.
|
||||
|
||||
*Default: identity function*
|
||||
|
||||
#### __titleFormatter = (action: Object, time: String?, took: Number?) => title__
|
||||
Format the title used for each action.
|
||||
|
||||
*Default: prints something like `action @ ${time} ${action.type} (in ${took.toFixed(2)} ms)`*
|
||||
|
||||
#### __diff (Boolean)__
|
||||
Show states diff.
|
||||
|
||||
*Default: `false`*
|
||||
|
||||
#### __diffPredicate = (getState: Function, action: Object) => Boolean__
|
||||
Filter states diff for certain cases.
|
||||
|
||||
*Default: `undefined`*
|
||||
|
||||
## Recipes
|
||||
### Log only in development
|
||||
```javascript
|
||||
const middlewares = [];
|
||||
|
||||
if (process.env.NODE_ENV === `development`) {
|
||||
const { logger } = require(`redux-logger`);
|
||||
|
||||
middlewares.push(logger);
|
||||
}
|
||||
|
||||
const store = compose(applyMiddleware(...middlewares))(createStore)(reducer);
|
||||
```
|
||||
|
||||
### Log everything except actions with certain type
|
||||
```javascript
|
||||
createLogger({
|
||||
predicate: (getState, action) => action.type !== AUTH_REMOVE_TOKEN
|
||||
});
|
||||
```
|
||||
|
||||
### Collapse actions with certain type
|
||||
```javascript
|
||||
createLogger({
|
||||
collapsed: (getState, action) => action.type === FORM_CHANGE
|
||||
});
|
||||
```
|
||||
|
||||
### Collapse actions that don't have errors
|
||||
```javascript
|
||||
createLogger({
|
||||
collapsed: (getState, action, logEntry) => !logEntry.error
|
||||
});
|
||||
```
|
||||
|
||||
### Transform Immutable (without `combineReducers`)
|
||||
```javascript
|
||||
import { Iterable } from 'immutable';
|
||||
|
||||
const stateTransformer = (state) => {
|
||||
if (Iterable.isIterable(state)) return state.toJS();
|
||||
else return state;
|
||||
};
|
||||
|
||||
const logger = createLogger({
|
||||
stateTransformer,
|
||||
});
|
||||
```
|
||||
|
||||
### Transform Immutable (with `combineReducers`)
|
||||
```javascript
|
||||
const logger = createLogger({
|
||||
stateTransformer: (state) => {
|
||||
let newState = {};
|
||||
|
||||
for (var i of Object.keys(state)) {
|
||||
if (Immutable.Iterable.isIterable(state[i])) {
|
||||
newState[i] = state[i].toJS();
|
||||
} else {
|
||||
newState[i] = state[i];
|
||||
}
|
||||
};
|
||||
|
||||
return newState;
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Log batched actions
|
||||
Thanks to [@smashercosmo](https://github.com/smashercosmo)
|
||||
```javascript
|
||||
import { createLogger } from 'redux-logger';
|
||||
|
||||
const actionTransformer = action => {
|
||||
if (action.type === 'BATCHING_REDUCER.BATCH') {
|
||||
action.payload.type = action.payload.map(next => next.type).join(' => ');
|
||||
return action.payload;
|
||||
}
|
||||
|
||||
return action;
|
||||
};
|
||||
|
||||
const level = 'info';
|
||||
|
||||
const logger = {};
|
||||
|
||||
for (const method in console) {
|
||||
if (typeof console[method] === 'function') {
|
||||
logger[method] = console[method].bind(console);
|
||||
}
|
||||
}
|
||||
|
||||
logger[level] = function levelFn(...args) {
|
||||
const lastArg = args.pop();
|
||||
|
||||
if (Array.isArray(lastArg)) {
|
||||
return lastArg.forEach(item => {
|
||||
console[level].apply(console, [...args, item]);
|
||||
});
|
||||
}
|
||||
|
||||
console[level].apply(console, arguments);
|
||||
};
|
||||
|
||||
export default createLogger({
|
||||
level,
|
||||
actionTransformer,
|
||||
logger
|
||||
});
|
||||
```
|
||||
|
||||
## To Do
|
||||
- [x] Update eslint config to [airbnb's](https://www.npmjs.com/package/eslint-config-airbnb)
|
||||
- [ ] Clean up code, because it's very messy, to be honest
|
||||
- [ ] Write tests
|
||||
- [ ] Node.js support
|
||||
- [ ] React-native support
|
||||
|
||||
Feel free to create PR for any of those tasks!
|
||||
|
||||
## Known issues
|
||||
* Performance issues in react-native ([#32](https://github.com/evgenyrodionov/redux-logger/issues/32))
|
||||
|
||||
## License
|
||||
MIT
|
||||
1
static/js/ketcher2/node_modules/redux-logger/dist/redux-logger.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/redux-logger/dist/redux-logger.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
116
static/js/ketcher2/node_modules/redux-logger/package.json
generated
vendored
Normal file
116
static/js/ketcher2/node_modules/redux-logger/package.json
generated
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
{
|
||||
"_from": "redux-logger@3.0.6",
|
||||
"_id": "redux-logger@3.0.6",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-91VZZvMJjzyIYExEnPC69XeCdL8=",
|
||||
"_location": "/redux-logger",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "redux-logger@3.0.6",
|
||||
"name": "redux-logger",
|
||||
"escapedName": "redux-logger",
|
||||
"rawSpec": "3.0.6",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "3.0.6"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#DEV:/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/redux-logger/-/redux-logger-3.0.6.tgz",
|
||||
"_shasum": "f7555966f3098f3c88604c449cf0baf5778274bf",
|
||||
"_spec": "redux-logger@3.0.6",
|
||||
"_where": "/home/manfred/enviPath/ketcher2/ketcher",
|
||||
"author": {
|
||||
"name": "Eugene Rodionov",
|
||||
"url": "https://github.com/theaqua"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/theaqua/redux-logger/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"deep-diff": "^0.3.5"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Logger for Redux",
|
||||
"devDependencies": {
|
||||
"babel-core": "^6.24.0",
|
||||
"babel-plugin-external-helpers": "^6.22.0",
|
||||
"babel-plugin-transform-inline-environment-variables": "6.8.0",
|
||||
"babel-preset-es2015": "^6.24.0",
|
||||
"chai": "3.5.0",
|
||||
"codecov": "1.0.1",
|
||||
"eslint": "^3.19.0",
|
||||
"eslint-config-airbnb": "^14.1.0",
|
||||
"eslint-plugin-import": "^2.2.0",
|
||||
"eslint-plugin-jsx-a11y": "^4.0.0",
|
||||
"eslint-plugin-react": "^6.10.3",
|
||||
"http-server": "0.9.0",
|
||||
"husky": "^0.13.2",
|
||||
"mocha": "3.1.2",
|
||||
"nyc": "9.0.1",
|
||||
"redux": "^3.6.0",
|
||||
"rimraf": "^2.6.1",
|
||||
"rollup": "^0.41.6",
|
||||
"rollup-plugin-babel": "^2.7.1",
|
||||
"rollup-plugin-commonjs": "^8.0.2",
|
||||
"rollup-plugin-node-resolve": "^3.0.0",
|
||||
"rollup-plugin-uglify": "^1.0.2",
|
||||
"sinon": "^1.17.7"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "airbnb",
|
||||
"rules": {
|
||||
"no-console": "off"
|
||||
},
|
||||
"env": {
|
||||
"browser": true,
|
||||
"mocha": true
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"src"
|
||||
],
|
||||
"homepage": "https://github.com/theaqua/redux-logger#readme",
|
||||
"keywords": [
|
||||
"redux",
|
||||
"logger",
|
||||
"redux-logger",
|
||||
"middleware"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "dist/redux-logger.js",
|
||||
"name": "redux-logger",
|
||||
"nyc": {
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"spec",
|
||||
"example",
|
||||
"lib",
|
||||
"dist",
|
||||
"coverage",
|
||||
"rollup.config.js"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/theaqua/redux-logger.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rollup -c",
|
||||
"clean": "rimraf dist",
|
||||
"coverage": "nyc report",
|
||||
"coverage:html": "nyc report --reporter=html && http-server -p 8077 ./coverage -o",
|
||||
"coverage:production": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
|
||||
"lint": "eslint src",
|
||||
"precommit": "npm test",
|
||||
"prepublish": "npm run clean && npm test && npm run build",
|
||||
"spec": "nyc --all --silent --require babel-core/register mocha --plugins transform-inline-environment-variables --recursive spec/*.spec.js",
|
||||
"spec:watch": "npm run spec -- --watch",
|
||||
"test": "npm run lint && npm run spec"
|
||||
},
|
||||
"version": "3.0.6"
|
||||
}
|
||||
140
static/js/ketcher2/node_modules/redux-logger/src/core.js
generated
vendored
Normal file
140
static/js/ketcher2/node_modules/redux-logger/src/core.js
generated
vendored
Normal file
@ -0,0 +1,140 @@
|
||||
import { formatTime } from './helpers';
|
||||
import diffLogger from './diff';
|
||||
|
||||
/**
|
||||
* Get log level string based on supplied params
|
||||
*
|
||||
* @param {string | function | object} level - console[level]
|
||||
* @param {object} action - selected action
|
||||
* @param {array} payload - selected payload
|
||||
* @param {string} type - log entry type
|
||||
*
|
||||
* @returns {string} level
|
||||
*/
|
||||
function getLogLevel(level, action, payload, type) {
|
||||
switch (typeof level) {
|
||||
case 'object':
|
||||
return typeof level[type] === 'function' ? level[type](...payload) : level[type];
|
||||
case 'function':
|
||||
return level(action);
|
||||
default:
|
||||
return level;
|
||||
}
|
||||
}
|
||||
|
||||
function defaultTitleFormatter(options) {
|
||||
const { timestamp, duration } = options;
|
||||
|
||||
return (action, time, took) => {
|
||||
const parts = ['action'];
|
||||
|
||||
parts.push(`%c${String(action.type)}`);
|
||||
if (timestamp) parts.push(`%c@ ${time}`);
|
||||
if (duration) parts.push(`%c(in ${took.toFixed(2)} ms)`);
|
||||
|
||||
return parts.join(' ');
|
||||
};
|
||||
}
|
||||
|
||||
function printBuffer(buffer, options) {
|
||||
const {
|
||||
logger,
|
||||
actionTransformer,
|
||||
titleFormatter = defaultTitleFormatter(options),
|
||||
collapsed,
|
||||
colors,
|
||||
level,
|
||||
diff,
|
||||
} = options;
|
||||
|
||||
const isUsingDefaultFormatter = typeof options.titleFormatter === 'undefined';
|
||||
|
||||
buffer.forEach((logEntry, key) => {
|
||||
const { started, startedTime, action, prevState, error } = logEntry;
|
||||
let { took, nextState } = logEntry;
|
||||
const nextEntry = buffer[key + 1];
|
||||
|
||||
if (nextEntry) {
|
||||
nextState = nextEntry.prevState;
|
||||
took = nextEntry.started - started;
|
||||
}
|
||||
|
||||
// Message
|
||||
const formattedAction = actionTransformer(action);
|
||||
const isCollapsed = typeof collapsed === 'function'
|
||||
? collapsed(() => nextState, action, logEntry)
|
||||
: collapsed;
|
||||
|
||||
const formattedTime = formatTime(startedTime);
|
||||
const titleCSS = colors.title ? `color: ${colors.title(formattedAction)};` : '';
|
||||
const headerCSS = ['color: gray; font-weight: lighter;'];
|
||||
headerCSS.push(titleCSS);
|
||||
if (options.timestamp) headerCSS.push('color: gray; font-weight: lighter;');
|
||||
if (options.duration) headerCSS.push('color: gray; font-weight: lighter;');
|
||||
const title = titleFormatter(formattedAction, formattedTime, took);
|
||||
|
||||
// Render
|
||||
try {
|
||||
if (isCollapsed) {
|
||||
if (colors.title && isUsingDefaultFormatter) {
|
||||
logger.groupCollapsed(`%c ${title}`, ...headerCSS);
|
||||
} else logger.groupCollapsed(title);
|
||||
} else if (colors.title && isUsingDefaultFormatter) {
|
||||
logger.group(`%c ${title}`, ...headerCSS);
|
||||
} else {
|
||||
logger.group(title);
|
||||
}
|
||||
} catch (e) {
|
||||
logger.log(title);
|
||||
}
|
||||
|
||||
const prevStateLevel = getLogLevel(level, formattedAction, [prevState], 'prevState');
|
||||
const actionLevel = getLogLevel(level, formattedAction, [formattedAction], 'action');
|
||||
const errorLevel = getLogLevel(level, formattedAction, [error, prevState], 'error');
|
||||
const nextStateLevel = getLogLevel(level, formattedAction, [nextState], 'nextState');
|
||||
|
||||
if (prevStateLevel) {
|
||||
if (colors.prevState) {
|
||||
const styles = `color: ${colors.prevState(prevState)}; font-weight: bold`;
|
||||
|
||||
logger[prevStateLevel]('%c prev state', styles, prevState);
|
||||
} else logger[prevStateLevel]('prev state', prevState);
|
||||
}
|
||||
|
||||
if (actionLevel) {
|
||||
if (colors.action) {
|
||||
const styles = `color: ${colors.action(formattedAction)}; font-weight: bold`;
|
||||
|
||||
logger[actionLevel]('%c action ', styles, formattedAction);
|
||||
} else logger[actionLevel]('action ', formattedAction);
|
||||
}
|
||||
|
||||
if (error && errorLevel) {
|
||||
if (colors.error) {
|
||||
const styles = `color: ${colors.error(error, prevState)}; font-weight: bold;`;
|
||||
|
||||
logger[errorLevel]('%c error ', styles, error);
|
||||
} else logger[errorLevel]('error ', error);
|
||||
}
|
||||
|
||||
if (nextStateLevel) {
|
||||
if (colors.nextState) {
|
||||
const styles = `color: ${colors.nextState(nextState)}; font-weight: bold`;
|
||||
|
||||
logger[nextStateLevel]('%c next state', styles, nextState);
|
||||
} else logger[nextStateLevel]('next state', nextState);
|
||||
}
|
||||
|
||||
if (diff) {
|
||||
diffLogger(prevState, nextState, logger, isCollapsed);
|
||||
}
|
||||
|
||||
try {
|
||||
logger.groupEnd();
|
||||
} catch (e) {
|
||||
logger.log('—— log end ——');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export default printBuffer;
|
||||
24
static/js/ketcher2/node_modules/redux-logger/src/defaults.js
generated
vendored
Normal file
24
static/js/ketcher2/node_modules/redux-logger/src/defaults.js
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
export default {
|
||||
level: 'log',
|
||||
logger: console,
|
||||
logErrors: true,
|
||||
collapsed: undefined,
|
||||
predicate: undefined,
|
||||
duration: false,
|
||||
timestamp: true,
|
||||
stateTransformer: state => state,
|
||||
actionTransformer: action => action,
|
||||
errorTransformer: error => error,
|
||||
colors: {
|
||||
title: () => 'inherit',
|
||||
prevState: () => '#9E9E9E',
|
||||
action: () => '#03A9F4',
|
||||
nextState: () => '#4CAF50',
|
||||
error: () => '#F20404',
|
||||
},
|
||||
diff: false,
|
||||
diffPredicate: undefined,
|
||||
|
||||
// Deprecated options
|
||||
transformer: undefined,
|
||||
};
|
||||
73
static/js/ketcher2/node_modules/redux-logger/src/diff.js
generated
vendored
Normal file
73
static/js/ketcher2/node_modules/redux-logger/src/diff.js
generated
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
import differ from 'deep-diff';
|
||||
|
||||
// https://github.com/flitbit/diff#differences
|
||||
const dictionary = {
|
||||
E: {
|
||||
color: '#2196F3',
|
||||
text: 'CHANGED:',
|
||||
},
|
||||
N: {
|
||||
color: '#4CAF50',
|
||||
text: 'ADDED:',
|
||||
},
|
||||
D: {
|
||||
color: '#F44336',
|
||||
text: 'DELETED:',
|
||||
},
|
||||
A: {
|
||||
color: '#2196F3',
|
||||
text: 'ARRAY:',
|
||||
},
|
||||
};
|
||||
|
||||
export function style(kind) {
|
||||
return `color: ${dictionary[kind].color}; font-weight: bold`;
|
||||
}
|
||||
|
||||
export function render(diff) {
|
||||
const { kind, path, lhs, rhs, index, item } = diff;
|
||||
|
||||
switch (kind) {
|
||||
case 'E':
|
||||
return [path.join('.'), lhs, '→', rhs];
|
||||
case 'N':
|
||||
return [path.join('.'), rhs];
|
||||
case 'D':
|
||||
return [path.join('.')];
|
||||
case 'A':
|
||||
return [`${path.join('.')}[${index}]`, item];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export default function diffLogger(prevState, newState, logger, isCollapsed) {
|
||||
const diff = differ(prevState, newState);
|
||||
|
||||
try {
|
||||
if (isCollapsed) {
|
||||
logger.groupCollapsed('diff');
|
||||
} else {
|
||||
logger.group('diff');
|
||||
}
|
||||
} catch (e) {
|
||||
logger.log('diff');
|
||||
}
|
||||
|
||||
if (diff) {
|
||||
diff.forEach((elem) => {
|
||||
const { kind } = elem;
|
||||
const output = render(elem);
|
||||
|
||||
logger.log(`%c ${dictionary[kind].text}`, style(kind), ...output);
|
||||
});
|
||||
} else {
|
||||
logger.log('—— no diff ——');
|
||||
}
|
||||
|
||||
try {
|
||||
logger.groupEnd();
|
||||
} catch (e) {
|
||||
logger.log('—— diff end —— ');
|
||||
}
|
||||
}
|
||||
11
static/js/ketcher2/node_modules/redux-logger/src/helpers.js
generated
vendored
Normal file
11
static/js/ketcher2/node_modules/redux-logger/src/helpers.js
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
export const repeat = (str, times) => (new Array(times + 1)).join(str);
|
||||
|
||||
export const pad = (num, maxLength) => repeat('0', maxLength - num.toString().length) + num;
|
||||
|
||||
export const formatTime = time => `${pad(time.getHours(), 2)}:${pad(time.getMinutes(), 2)}:${pad(time.getSeconds(), 2)}.${pad(time.getMilliseconds(), 3)}`;
|
||||
|
||||
// Use performance API if it's available in order to get better precision
|
||||
export const timer =
|
||||
(typeof performance !== 'undefined' && performance !== null) && typeof performance.now === 'function' ?
|
||||
performance :
|
||||
Date;
|
||||
126
static/js/ketcher2/node_modules/redux-logger/src/index.js
generated
vendored
Normal file
126
static/js/ketcher2/node_modules/redux-logger/src/index.js
generated
vendored
Normal file
@ -0,0 +1,126 @@
|
||||
import printBuffer from './core';
|
||||
import { timer } from './helpers';
|
||||
import defaults from './defaults';
|
||||
/* eslint max-len: ["error", 110, { "ignoreComments": true }] */
|
||||
/**
|
||||
* Creates logger with following options
|
||||
*
|
||||
* @namespace
|
||||
* @param {object} options - options for logger
|
||||
* @param {string | function | object} options.level - console[level]
|
||||
* @param {boolean} options.duration - print duration of each action?
|
||||
* @param {boolean} options.timestamp - print timestamp with each action?
|
||||
* @param {object} options.colors - custom colors
|
||||
* @param {object} options.logger - implementation of the `console` API
|
||||
* @param {boolean} options.logErrors - should errors in action execution be caught, logged, and re-thrown?
|
||||
* @param {boolean} options.collapsed - is group collapsed?
|
||||
* @param {boolean} options.predicate - condition which resolves logger behavior
|
||||
* @param {function} options.stateTransformer - transform state before print
|
||||
* @param {function} options.actionTransformer - transform action before print
|
||||
* @param {function} options.errorTransformer - transform error before print
|
||||
*
|
||||
* @returns {function} logger middleware
|
||||
*/
|
||||
function createLogger(options = {}) {
|
||||
const loggerOptions = Object.assign({}, defaults, options);
|
||||
|
||||
const {
|
||||
logger,
|
||||
stateTransformer,
|
||||
errorTransformer,
|
||||
predicate,
|
||||
logErrors,
|
||||
diffPredicate,
|
||||
} = loggerOptions;
|
||||
|
||||
// Return if 'console' object is not defined
|
||||
if (typeof logger === 'undefined') {
|
||||
return () => next => action => next(action);
|
||||
}
|
||||
|
||||
// Detect if 'createLogger' was passed directly to 'applyMiddleware'.
|
||||
if (options.getState && options.dispatch) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(`[redux-logger] redux-logger not installed. Make sure to pass logger instance as middleware:
|
||||
// Logger with default options
|
||||
import { logger } from 'redux-logger'
|
||||
const store = createStore(
|
||||
reducer,
|
||||
applyMiddleware(logger)
|
||||
)
|
||||
// Or you can create your own logger with custom options http://bit.ly/redux-logger-options
|
||||
import createLogger from 'redux-logger'
|
||||
const logger = createLogger({
|
||||
// ...options
|
||||
});
|
||||
const store = createStore(
|
||||
reducer,
|
||||
applyMiddleware(logger)
|
||||
)
|
||||
`);
|
||||
|
||||
return () => next => action => next(action);
|
||||
}
|
||||
|
||||
const logBuffer = [];
|
||||
|
||||
return ({ getState }) => next => (action) => {
|
||||
// Exit early if predicate function returns 'false'
|
||||
if (typeof predicate === 'function' && !predicate(getState, action)) {
|
||||
return next(action);
|
||||
}
|
||||
|
||||
const logEntry = {};
|
||||
|
||||
logBuffer.push(logEntry);
|
||||
|
||||
logEntry.started = timer.now();
|
||||
logEntry.startedTime = new Date();
|
||||
logEntry.prevState = stateTransformer(getState());
|
||||
logEntry.action = action;
|
||||
|
||||
let returnedValue;
|
||||
if (logErrors) {
|
||||
try {
|
||||
returnedValue = next(action);
|
||||
} catch (e) {
|
||||
logEntry.error = errorTransformer(e);
|
||||
}
|
||||
} else {
|
||||
returnedValue = next(action);
|
||||
}
|
||||
|
||||
logEntry.took = timer.now() - logEntry.started;
|
||||
logEntry.nextState = stateTransformer(getState());
|
||||
|
||||
const diff = loggerOptions.diff && typeof diffPredicate === 'function'
|
||||
? diffPredicate(getState, action)
|
||||
: loggerOptions.diff;
|
||||
|
||||
printBuffer(logBuffer, Object.assign({}, loggerOptions, { diff }));
|
||||
logBuffer.length = 0;
|
||||
|
||||
if (logEntry.error) throw logEntry.error;
|
||||
return returnedValue;
|
||||
};
|
||||
}
|
||||
|
||||
// eslint-disable-next-line consistent-return
|
||||
const defaultLogger = ({ dispatch, getState } = {}) => {
|
||||
if (typeof dispatch === 'function' || typeof getState === 'function') {
|
||||
return createLogger()({ dispatch, getState });
|
||||
}
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(`
|
||||
[redux-logger v3] BREAKING CHANGE
|
||||
[redux-logger v3] Since 3.0.0 redux-logger exports by default logger with default settings.
|
||||
[redux-logger v3] Change
|
||||
[redux-logger v3] import createLogger from 'redux-logger'
|
||||
[redux-logger v3] to
|
||||
[redux-logger v3] import { createLogger } from 'redux-logger'
|
||||
`);
|
||||
};
|
||||
|
||||
export { defaults, createLogger, defaultLogger as logger };
|
||||
|
||||
export default defaultLogger;
|
||||
Reference in New Issue
Block a user