goblin-laboratory 4.11.1 → 4.11.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "goblin-laboratory",
3
- "version": "4.11.1",
3
+ "version": "4.11.3",
4
4
  "description": "Laboratory",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -37,19 +37,18 @@
37
37
  },
38
38
  "devDependencies": {
39
39
  "aphrodite": "^2.2.2",
40
- "connected-react-router": "^6.3.2",
41
40
  "css-key": "^1.0.0",
42
41
  "@fortawesome/react-fontawesome": "^0.1.9",
43
42
  "history": "^4.6.1",
44
43
  "immutable": "4.0.0-rc.14",
45
44
  "linked-list": "^1.0.4",
46
45
  "obj-to-css": "^1.0.1",
46
+ "path-to-regexp": "^1.9.0",
47
47
  "prettier": "2.0.4",
48
48
  "prop-types": "^15.5.10",
49
49
  "react": "^17.0.1",
50
50
  "react-dom": "^17.0.1",
51
51
  "react-redux": "^8.1.3",
52
- "react-router": "^5.0.0",
53
52
  "redux-thunk": "^2.3.0",
54
53
  "safe-stable-stringify": "^2.5.0",
55
54
  "xcraft-core-shredder": "^5.3.0",
@@ -1,20 +1,14 @@
1
1
  import React from 'react';
2
2
  import ReactDOM from 'react-dom';
3
3
  import Root from 'goblin-laboratory/widgets/root';
4
- import {createHashHistory} from 'history';
5
- import {push} from 'connected-react-router/immutable';
6
4
  import configureStore from 'goblin-laboratory/widgets/store/store';
7
5
 
8
6
  class Renderer {
9
7
  constructor(send, options = {}) {
10
8
  this.send = send;
11
- this.push = push;
12
9
  this.options = options;
13
10
 
14
11
  this.history = undefined;
15
- if (this.options.useRouter !== false) {
16
- this.history = createHashHistory();
17
- }
18
12
 
19
13
  this._store = configureStore(
20
14
  window.__INITIAL_STATE__,
@@ -69,12 +63,7 @@ class Renderer {
69
63
  render = ReactDOM.hydrate;
70
64
  }
71
65
  render(
72
- <Root
73
- store={this.store}
74
- labId={labId}
75
- useRouter={this.options.useRouter !== false}
76
- history={this.history}
77
- />,
66
+ <Root store={this.store} labId={labId} history={this.history} />,
78
67
  rootElement
79
68
  );
80
69
  }
@@ -4,11 +4,7 @@ import React from 'react';
4
4
  import PropTypes from 'prop-types';
5
5
 
6
6
  import {Provider} from 'react-redux';
7
- import {ConnectedRouter} from 'connected-react-router/immutable';
8
7
  import Laboratory from '../laboratory/widget';
9
- import {withRoute} from '../with-route/with-route.js';
10
-
11
- const LabWithRoute = withRoute('/')(Laboratory);
12
8
 
13
9
  class Root extends React.PureComponent {
14
10
  getChildContext() {
@@ -27,23 +23,11 @@ class Root extends React.PureComponent {
27
23
  };
28
24
  }
29
25
 
30
- renderLabWithRouter() {
31
- const {history, labId} = this.props;
32
- return (
33
- <ConnectedRouter history={history}>
34
- <LabWithRoute id={labId} />
35
- </ConnectedRouter>
36
- );
37
- }
38
-
39
26
  renderLab() {
40
27
  return <Laboratory id={this.props.labId} />;
41
28
  }
42
29
 
43
30
  renderContent() {
44
- if (this.props.useRouter) {
45
- return this.renderLabWithRouter();
46
- }
47
31
  return this.renderLab();
48
32
  }
49
33
 
@@ -1,16 +1,13 @@
1
1
  import {applyMiddleware, compose, createStore} from 'redux';
2
- import {routerMiddleware} from 'connected-react-router/immutable';
3
2
  import thunk from 'redux-thunk';
4
3
  import middlewares from './middlewares';
5
4
 
6
- const rootReducer = require('goblin-laboratory/widgets/store/root-reducer')
7
- .default;
5
+ const rootReducer =
6
+ require('goblin-laboratory/widgets/store/root-reducer').default;
8
7
 
9
8
  export default function configureStore(initialState, history, send) {
10
- const {transitMiddleware, formMiddleware, questMiddleware} = middlewares(
11
- send
12
- );
13
- const routerHistory = routerMiddleware(history);
9
+ const {transitMiddleware, formMiddleware, questMiddleware} =
10
+ middlewares(send);
14
11
 
15
12
  const composeEnhancers =
16
13
  (process.env.NODE_ENV === 'development' &&
@@ -19,20 +16,14 @@ export default function configureStore(initialState, history, send) {
19
16
 
20
17
  const finalCreateStore = composeEnhancers(
21
18
  // Middleware you want to use in development:
22
- applyMiddleware(
23
- thunk,
24
- routerHistory,
25
- transitMiddleware,
26
- questMiddleware,
27
- formMiddleware
28
- )
19
+ applyMiddleware(thunk, transitMiddleware, questMiddleware, formMiddleware)
29
20
  )(createStore);
30
21
 
31
22
  const store = finalCreateStore(rootReducer, initialState);
32
23
  if (module.hot) {
33
24
  module.hot.accept('goblin-laboratory/widgets/store/root-reducer', () => {
34
- const nextRootReducer = require('goblin-laboratory/widgets/store/root-reducer')
35
- .default;
25
+ const nextRootReducer =
26
+ require('goblin-laboratory/widgets/store/root-reducer').default;
36
27
  store.replaceReducer(nextRootReducer);
37
28
  });
38
29
  }
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import _ from 'lodash';
3
3
  import PropTypes from 'prop-types';
4
4
  import Shredder from 'xcraft-core-shredder';
5
- import {push} from 'connected-react-router/immutable';
6
5
  import {flushToStyleTag} from 'aphrodite/no-important';
7
6
  import importer from 'goblin_importer';
8
7
  import shallowEqualShredder from './utils/shallowEqualShredder';
@@ -430,12 +429,8 @@ class Widget extends React.Component {
430
429
  this.context.store.dispatch(action);
431
430
  }
432
431
 
433
- nav(route, frontOnly) {
434
- if (frontOnly) {
435
- this.context.dispatch(push(route));
436
- } else {
437
- this.doFor(this.context.labId, 'nav', {route});
438
- }
432
+ nav(route) {
433
+ this.doFor(this.context.labId, 'nav', {route});
439
434
  }
440
435
 
441
436
  setBackendValue(path, value) {
@@ -0,0 +1,67 @@
1
+ import pathToRegexp from 'path-to-regexp';
2
+
3
+ const cache = {};
4
+ const cacheLimit = 10000;
5
+ let cacheCount = 0;
6
+
7
+ function compilePath(path, options) {
8
+ const cacheKey = `${options.end}${options.strict}${options.sensitive}`;
9
+ const pathCache = cache[cacheKey] || (cache[cacheKey] = {});
10
+
11
+ if (pathCache[path]) return pathCache[path];
12
+
13
+ const keys = [];
14
+ const regexp = pathToRegexp(path, keys, options);
15
+ const result = {regexp, keys};
16
+
17
+ if (cacheCount < cacheLimit) {
18
+ pathCache[path] = result;
19
+ cacheCount++;
20
+ }
21
+
22
+ return result;
23
+ }
24
+
25
+ /**
26
+ * Public API for matching a URL pathname to a path.
27
+ */
28
+ function matchPath(pathname, options = {}) {
29
+ if (typeof options === 'string' || Array.isArray(options)) {
30
+ options = {path: options};
31
+ }
32
+
33
+ const {path, exact = false, strict = false, sensitive = false} = options;
34
+
35
+ const paths = [].concat(path);
36
+
37
+ return paths.reduce((matched, path) => {
38
+ if (!path && path !== '') return null;
39
+ if (matched) return matched;
40
+
41
+ const {regexp, keys} = compilePath(path, {
42
+ end: exact,
43
+ strict,
44
+ sensitive,
45
+ });
46
+ const match = regexp.exec(pathname);
47
+
48
+ if (!match) return null;
49
+
50
+ const [url, ...values] = match;
51
+ const isExact = pathname === url;
52
+
53
+ if (exact && !isExact) return null;
54
+
55
+ return {
56
+ path, // the path used to match
57
+ url: path === '/' && url === '' ? '/' : url, // the matched portion of the URL
58
+ isExact, // whether or not we matched exactly
59
+ params: keys.reduce((memo, key, index) => {
60
+ memo[key.name] = values[index];
61
+ return memo;
62
+ }, {}),
63
+ };
64
+ }, null);
65
+ }
66
+
67
+ export default matchPath;
@@ -1,8 +1,8 @@
1
1
  import {connect} from 'react-redux';
2
2
  import Shredder from 'xcraft-core-shredder';
3
- import {matchPath} from 'react-router';
4
3
  import {getParameter} from '../../lib/helpers.js';
5
4
  import shallowEqualShredder from '../widget/utils/shallowEqualShredder.js';
5
+ import matchPath from './matchPath.js';
6
6
 
7
7
  export function withRoute(path, watchedParams, watchedSearchs, watchHash) {
8
8
  return connect(