Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

router: remove debug from dependencies #714

Merged
merged 2 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/fluxible-router/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## 2.0.0

* Remove `debug` as dependency [#714]
* Add es build to npm package [#710]
* Move `addons/HistoryWithHash` to the root folder [#710]
* Remove `wrappedElement` ref from `handleHistory` and `handleRoute` [#696]
* Update `fluxible-addons-react` to 1.0.0 [#667]

## 1.4.0

* [#566] Support React 16
Expand Down
1 change: 0 additions & 1 deletion packages/fluxible-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
],
"dependencies": {
"@babel/runtime": "^7.14.0",
"debug": "^2.0.0",
"fluxible-addons-react": "^1.0.0-beta.0",
"hoist-non-react-statics": "^3.3.2",
"prop-types": "^15.7.2",
Expand Down
6 changes: 0 additions & 6 deletions packages/fluxible-router/src/createNavLinkComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@
import React from 'react';
import PropTypes from 'prop-types';
import { FluxibleComponentContext } from 'fluxible-addons-react';
import Debug from 'debug';
import RouteStore from './RouteStore';
import navigateAction from './navigateAction';

var debug = Debug('NavLink');

var __DEV__ = process.env.NODE_ENV !== 'production';

function objectWithoutProperties(obj, keys) {
Expand Down Expand Up @@ -236,7 +233,6 @@ class NavLink extends React.Component {
return true;
}
dispatchNavAction (e) {
debug('dispatchNavAction: action=NAVIGATE', this.props.href);
if (this.props.stopPropagation) {
e.stopPropagation();
}
Expand Down Expand Up @@ -272,8 +268,6 @@ class NavLink extends React.Component {
var navType = this.props.replaceState ? 'replacestate' : 'click';
var context = this.props.context || this.context;

debug('dispatchNavAction: execute navigateAction', this.props.href, navType, navParams);

context.executeAction(navigateAction, {
type: navType,
url: clientState.relativeHref,
Expand Down
16 changes: 1 addition & 15 deletions packages/fluxible-router/src/handleHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
/* eslint-disable react/display-name */
import React from 'react';
import PropTypes from 'prop-types';
import Debug from 'debug';
import { FluxibleComponentContext } from 'fluxible-addons-react';
import handleRoute from './handleRoute';
import navigateAction from './navigateAction';
import History from './History';
import hoistNonReactStatics from 'hoist-non-react-statics';

const debug = Debug('FluxibleRouter:handleHistory');

var TYPE_CLICK = 'click';
var TYPE_PAGELOAD = 'pageload';
var TYPE_REPLACESTATE = 'replacestate';
Expand Down Expand Up @@ -109,7 +106,6 @@ function handleHistory(Component, opts) {
var urlFromState = this.props.currentRoute && this.props.currentRoute.url;

if ((urlFromHistory !== urlFromState)) {
debug('pageload navigate to actual route', urlFromHistory, urlFromState);
this.context.executeAction(navigateAction, {
type: TYPE_PAGELOAD,
url: urlFromHistory
Expand Down Expand Up @@ -141,7 +137,6 @@ function handleHistory(Component, opts) {
}

_onHistoryChange(e) {
debug('history listener invoked', e);
if (this._ignorePageLoadPopstate) {
// 1) e.state (null) and history.state (not null)
// -- this is popstate triggered on pageload in Safari browser.
Expand All @@ -154,9 +149,8 @@ function handleHistory(Component, opts) {
// _onHistoryChange gets invoked in componentDidMount()
var stateFromHistory = this._history.getState();
var isPageloadPopstate = (e.state === null) && !!stateFromHistory;
debug('history listener detecting pageload popstate', e.state, stateFromHistory);

if (isPageloadPopstate) {
debug('history listener skipped pageload popstate');
return;
}
}
Expand Down Expand Up @@ -193,8 +187,6 @@ function handleHistory(Component, opts) {

var pageTitle = navParams.pageTitle || null;

debug('history listener url, currentUrl:', url, currentUrl, this.props);

if (!confirmResult) {
// Pushes the previous history state back on top to set the correct url
this._history.pushState(historyState, pageTitle, currentUrl);
Expand All @@ -221,14 +213,12 @@ function handleHistory(Component, opts) {
// reduce unused replaceState
// also prevent IOS Safari reset scroll position to 0 with universal link bar showing
if (historyState.scroll && historyState.scroll.x === scrollX && historyState.scroll.y === scrollY) {
debug('skip updating scrolling position with same position', historyState.scroll);
return;
}
historyState.scroll = {
x: scrollX,
y: scrollY
};
debug('remember scroll position', historyState.scroll);
this._history.replaceState(historyState);
}

Expand All @@ -241,8 +231,6 @@ function handleHistory(Component, opts) {
}

componentDidUpdate(prevProps, prevState) {
debug('component did update', prevState, this.props);

var nav = this.props.currentNavigate || {};
var navType = nav.type || TYPE_DEFAULT;
var navParams = nav.params || {};
Expand All @@ -267,7 +255,6 @@ function handleHistory(Component, opts) {
} else {
if (options.enableScroll) {
window.scrollTo(0, 0);
debug('on click navigation, reset scroll position to (0, 0)');
}
if (options.saveScrollInState) {
historyState.scroll = {x: 0, y: 0};
Expand All @@ -284,7 +271,6 @@ function handleHistory(Component, opts) {
if (options.enableScroll) {
historyState = (this._history.getState && this._history.getState()) || {};
var scroll = (historyState && historyState.scroll) || {};
debug('on popstate navigation, restore scroll position to ', scroll);
window.scrollTo(scroll.x || 0, scroll.y || 0);
}
break;
Expand Down
8 changes: 0 additions & 8 deletions packages/fluxible-router/src/navigateAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
* Copyright 2015, Yahoo! Inc.
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
*/
import Debug from 'debug';

const debug = Debug('navigateAction');

function navigateAction (context, payload, done) {
var routeStore = context.getStore('RouteStore');

Expand All @@ -17,7 +13,6 @@ function navigateAction (context, payload, done) {
navigate.routeName = null;
}

debug('dispatching NAVIGATE_START', navigate);
context.dispatch('NAVIGATE_START', navigate);

if (!routeStore.getCurrentRoute) {
Expand All @@ -44,7 +39,6 @@ function navigateAction (context, payload, done) {

var action = route.action;
if (!action) {
debug('route has no action, dispatching without calling action');
context.dispatch('NAVIGATE_SUCCESS', completionPayload);
done();
return;
Expand All @@ -55,7 +49,6 @@ function navigateAction (context, payload, done) {
}

if (!action || 'function' !== typeof action) {
debug('action cannot be resolved');
completionPayload.error = {
statusCode: 500,
message: 'Action for ' + payload.url + ' can not be resolved'
Expand All @@ -65,7 +58,6 @@ function navigateAction (context, payload, done) {
return;
}

debug('executing route action');
context.executeAction(action, route, function (err) {
if (err) {
completionPayload.error = {
Expand Down