Skip to content

Commit d35416d

Browse files
committed
Merge branch 'master' into apollo
2 parents e81a778 + 46a13ca commit d35416d

File tree

13 files changed

+1930
-128
lines changed

13 files changed

+1930
-128
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ This is a standalone app for debugging React Native apps:
1414

1515
## Installation
1616

17-
The prebuilt binaries can be found on the [releases](https://github.com/jhen0409/react-native-debugger/releases) page.
17+
To install the app, you can download a prebuilt binary from the [release page](https://github.com/jhen0409/react-native-debugger/releases).
1818

1919
For **macOS**, you can use [Homebrew Cask](https://caskroom.github.io) to install:
2020

2121
```bash
2222
$ brew update && brew cask install react-native-debugger
2323
```
2424

25+
This puts `React Native Debugger.app` in your `/applications/` folder.
26+
2527
## Documentation
2628

2729
* [Getting Started](docs/getting-started.md)

app/middlewares/delta/DeltaPatcher.js

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*
77
* @format
8-
*/
8+
*/
99

1010
import { checkFetchExists, patchFetchPolyfill } from './patchFetchPolyfill';
1111

@@ -29,10 +29,10 @@ import { checkFetchExists, patchFetchPolyfill } from './patchFetchPolyfill';
2929
export default class DeltaPatcher {
3030
constructor() {
3131
this._lastBundle = {
32+
id: undefined,
3233
pre: new Map(),
3334
post: new Map(),
3435
modules: new Map(),
35-
id: undefined,
3636
};
3737
this._initialized = false;
3838
this._lastNumModifiedFiles = 0;
@@ -54,35 +54,65 @@ export default class DeltaPatcher {
5454
* Applies a Delta Bundle to the current bundle.
5555
*/
5656
applyDelta(deltaBundle) {
57+
const isOld = deltaBundle.id;
5758
// Make sure that the first received delta is a fresh one.
58-
if (!this._initialized && !deltaBundle.reset) {
59+
if (isOld ? !this._initialized && !deltaBundle.reset :
60+
!this._initialized && !deltaBundle.base) {
5961
throw new Error('DeltaPatcher should receive a fresh Delta when being initialized');
6062
}
6163

6264
this._initialized = true;
6365

6466
// Reset the current delta when we receive a fresh delta.
65-
if (deltaBundle.reset) {
67+
if (deltaBundle.reset && isOld) {
6668
this._lastBundle = {
6769
pre: new Map(),
6870
post: new Map(),
6971
modules: new Map(),
7072
id: undefined,
7173
};
74+
} else if (deltaBundle.base) {
75+
this._lastBundle = {
76+
id: deltaBundle.revisionId,
77+
pre: deltaBundle.pre,
78+
post: deltaBundle.post,
79+
modules: new Map(deltaBundle.modules),
80+
};
81+
}
82+
83+
this._lastNumModifiedFiles = isOld ?
84+
deltaBundle.pre.size + deltaBundle.post.size + deltaBundle.delta.size :
85+
deltaBundle.modules.length;
86+
87+
if (deltaBundle.deleted) {
88+
this._lastNumModifiedFiles += deltaBundle.deleted.length;
7289
}
7390

74-
this._lastNumModifiedFiles =
75-
deltaBundle.pre.size + deltaBundle.post.size + deltaBundle.delta.size;
91+
this._lastBundle.id = isOld ? deltaBundle.id : deltaBundle.revisionId;
7692

7793
if (this._lastNumModifiedFiles > 0) {
7894
this._lastModifiedDate = new Date();
7995
}
8096

81-
this._patchMap(this._lastBundle.pre, deltaBundle.pre);
82-
this._patchMap(this._lastBundle.post, deltaBundle.post);
83-
this._patchMap(this._lastBundle.modules, deltaBundle.delta);
97+
if (isOld) {
98+
this._patchMap(this._lastBundle.pre, deltaBundle.pre);
99+
this._patchMap(this._lastBundle.post, deltaBundle.post);
100+
this._patchMap(this._lastBundle.modules, deltaBundle.delta);
101+
102+
this._lastBundle.id = deltaBundle.id;
103+
} else {
104+
for (const [key, value] of deltaBundle.modules) {
105+
this._lastBundle.modules.set(key, value);
106+
}
84107

85-
this._lastBundle.id = deltaBundle.id;
108+
if (deltaBundle.deleted) {
109+
for (const id of deltaBundle.deleted) {
110+
this._lastBundle.modules.delete(id);
111+
}
112+
}
113+
114+
this._lastBundle.id = deltaBundle.revisionId;
115+
}
86116

87117
return this;
88118
}
@@ -105,11 +135,15 @@ export default class DeltaPatcher {
105135
return this._lastModifiedDate;
106136
}
107137

108-
getAllModules() {
109-
return [].concat(
138+
getAllModules(isOld) {
139+
return isOld ? [].concat(
110140
Array.from(this._lastBundle.pre.values()),
111141
Array.from(this._lastBundle.modules.values()),
112142
Array.from(this._lastBundle.post.values())
143+
) : [].concat(
144+
[this._lastBundle.pre],
145+
Array.from(this._lastBundle.modules.values()),
146+
[this._lastBundle.post]
113147
);
114148
}
115149

app/middlewares/delta/deltaUrlToBlobUrl.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ export default async function deltaUrlToBlobUrl(deltaUrl) {
2626
const data = await fetch(deltaUrl + deltaBundleId);
2727
const bundle = await data.json();
2828

29-
const deltaPatcher = client.applyDelta({
29+
const isOld = bundle.id;
30+
31+
const deltaPatcher = client.applyDelta(isOld ? {
3032
id: bundle.id,
3133
pre: new Map(bundle.pre),
3234
post: new Map(bundle.post),
3335
delta: new Map(bundle.delta),
3436
reset: bundle.reset,
35-
});
37+
} : bundle);
3638

3739
const cachedBundle = cachedBundleUrls.get(deltaUrl);
3840

@@ -49,7 +51,7 @@ export default async function deltaUrlToBlobUrl(deltaUrl) {
4951

5052
// To make Source Maps work correctly, we need to add a newline between
5153
// modules.
52-
const blobContent = deltaPatcher.getAllModules().map(module => `${module}\n`);
54+
const blobContent = deltaPatcher.getAllModules(isOld).map(module => `${module}\n`);
5355

5456
// Build the blob with the whole JS bundle.
5557
const blob = new Blob(blobContent, {

app/worker/reduxAPI.js

Lines changed: 49 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,22 @@ import {
77
generateId,
88
stringify,
99
getSeralizeParameter,
10-
} from 'remotedev-utils';
11-
import importState from 'remotedev-utils/lib/importState';
10+
} from 'redux-devtools-core/lib/utils';
11+
import importState from 'redux-devtools-core/lib/utils/importState';
1212
import {
1313
getLocalFilter,
1414
isFiltered,
1515
filterStagedActions,
1616
filterState,
17-
} from 'remotedev-utils/lib/filters';
17+
} from 'redux-devtools-core/lib/utils/filters';
1818

1919
function configureStore(next, subscriber, options) {
2020
return instrument(subscriber, options)(next);
2121
}
2222

23-
const instances = { /* [id]: { name, store, ... } */ };
23+
const instances = {
24+
/* [id]: { name, store, ... } */
25+
};
2426

2527
let lastAction;
2628
let isExcess;
@@ -34,9 +36,12 @@ function getLiftedState(store, filters) {
3436

3537
function relay(type, state, instance, action, nextActionId) {
3638
const {
37-
filters, predicate,
38-
stateSanitizer, actionSanitizer,
39-
serializeState, serializeAction,
39+
filters,
40+
predicate,
41+
stateSanitizer,
42+
actionSanitizer,
43+
serializeState,
44+
serializeAction,
4045
} = instance;
4146

4247
const message = {
@@ -45,12 +50,21 @@ function relay(type, state, instance, action, nextActionId) {
4550
name: instance.name,
4651
};
4752
if (state) {
48-
message.payload = type === 'ERROR' ?
49-
state :
50-
stringify(
51-
filterState(state, type, filters, stateSanitizer, actionSanitizer, nextActionId, predicate),
52-
serializeState
53-
);
53+
message.payload =
54+
type === 'ERROR'
55+
? state
56+
: stringify(
57+
filterState(
58+
state,
59+
type,
60+
filters,
61+
stateSanitizer,
62+
actionSanitizer,
63+
nextActionId,
64+
predicate
65+
),
66+
serializeState
67+
);
5468
}
5569
if (type === 'ACTION') {
5670
message.action = stringify(
@@ -103,9 +117,9 @@ function exportState({ id: instanceId, store, serializeState }) {
103117
type: 'EXPORT',
104118
payload: stringify(payload, serializeState),
105119
committedState:
106-
typeof liftedState.committedState !== 'undefined' ?
107-
stringify(liftedState.committedState, serializeState) :
108-
undefined,
120+
typeof liftedState.committedState !== 'undefined'
121+
? stringify(liftedState.committedState, serializeState)
122+
: undefined,
109123
instanceId,
110124
},
111125
});
@@ -228,16 +242,14 @@ export default function devToolsEnhancer(options = {}) {
228242
const serializeAction = getSeralizeParameter(options, 'serializeAction');
229243

230244
return next => (reducer, initialState) => {
231-
const store = configureStore(
232-
next, monitorReducer, {
233-
maxAge,
234-
shouldCatchErrors,
235-
shouldHotReload,
236-
shouldRecordChanges,
237-
shouldStartLocked,
238-
pauseActionType,
239-
}
240-
)(reducer, initialState);
245+
const store = configureStore(next, monitorReducer, {
246+
maxAge,
247+
shouldCatchErrors,
248+
shouldHotReload,
249+
shouldRecordChanges,
250+
shouldStartLocked,
251+
pauseActionType,
252+
})(reducer, initialState);
241253

242254
instances[id] = {
243255
name: name || id,
@@ -266,20 +278,17 @@ export default function devToolsEnhancer(options = {}) {
266278
};
267279
}
268280

269-
const preEnhancer = instanceId => next =>
270-
(reducer, initialState, enhancer) => {
271-
const store = next(reducer, initialState, enhancer);
281+
const preEnhancer = instanceId => next => (reducer, initialState, enhancer) => {
282+
const store = next(reducer, initialState, enhancer);
272283

273-
if (instances[instanceId]) {
274-
instances[instanceId].store = store;
275-
}
276-
return {
277-
...store,
278-
dispatch: (action) => (
279-
locked ? action : store.dispatch(action)
280-
),
281-
};
284+
if (instances[instanceId]) {
285+
instances[instanceId].store = store;
286+
}
287+
return {
288+
...store,
289+
dispatch: action => (locked ? action : store.dispatch(action)),
282290
};
291+
};
283292

284293
devToolsEnhancer.updateStore = (newStore, instanceId) => {
285294
console.warn(
@@ -309,7 +318,8 @@ devToolsEnhancer.updateStore = (newStore, instanceId) => {
309318
const compose = options => (...funcs) => (...args) => {
310319
const instanceId = generateId(options.instanceId);
311320
return [preEnhancer(instanceId), ...funcs].reduceRight(
312-
(composed, f) => f(composed), devToolsEnhancer({ ...options, instanceId })(...args)
321+
(composed, f) => f(composed),
322+
devToolsEnhancer({ ...options, instanceId })(...args)
313323
);
314324
};
315325

app/worker/remotedev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Edit from https://github.com/zalmoxisus/remotedev/blob/master/src/devTools.js
22

33
import { stringify, parse } from 'jsan';
4-
import { generateId, getActionsArray } from 'remotedev-utils';
4+
import { generateId, getActionsArray } from 'redux-devtools-core/lib/utils';
55

66
let listenerAdded;
77
const listeners = {};

auto_updater.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"url": "https://github.com/jhen0409/react-native-debugger/releases/download/v0.8.1/rn-debugger-macos-x64.zip",
3-
"name": "v0.8.1",
4-
"notes": "1. Do notify before autoUpdater.checkForUpdates\n2. Rename defaultRNPackagerPorts as correct config field name"
2+
"url": "https://github.com/jhen0409/react-native-debugger/releases/download/v0.8.3/rn-debugger-macos-x64.zip",
3+
"name": "v0.8.3",
4+
"notes": "1. Support dark mode title bar for macOS\n2. Fixed to work with RN 0.58+"
55
}

dist/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-debugger",
3-
"version": "0.8.1",
3+
"version": "0.8.3",
44
"productName": "React Native Debugger",
55
"description": "The standalone app for React Native Debugger, with React DevTools / Redux DevTools",
66
"main": "main.js",
@@ -14,7 +14,7 @@
1414
"adbkit": "^2.11.0",
1515
"apollo-client-devtools": "2.1.7-alpha.2",
1616
"electron-store": "^1.2.0",
17-
"react-devtools-core": "^3.4.0"
17+
"react-devtools-core": "^3.4.3"
1818
},
1919
"optionalDependencies": {
2020
"electron-named-image": "^1.0.4"

0 commit comments

Comments
 (0)