Skip to content

Instantly share code, notes, and snippets.

@jasonLaster
Created August 9, 2019 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonLaster/09d0faa2e6356c7411c7d829b55de57d to your computer and use it in GitHub Desktop.
Save jasonLaster/09d0faa2e6356c7411c7d829b55de57d to your computer and use it in GitHub Desktop.
diff --git a/devtools/client/debugger/bin/module-manifest.json b/devtools/client/debugger/bin/module-manifest.json
index 4b502dfb3abb..9fd21fbb6a90 100644
--- a/devtools/client/debugger/bin/module-manifest.json
+++ b/devtools/client/debugger/bin/module-manifest.json
@@ -15,7 +15,7 @@
"byName": {},
"byBlocks": {},
"usedIds": {
- "1": 1
+ "0": 0
}
}
}
@@ -36,7 +36,7 @@
"byName": {},
"byBlocks": {},
"usedIds": {
- "1": 1
+ "0": 0
}
}
}
@@ -57,7 +57,7 @@
"byName": {},
"byBlocks": {},
"usedIds": {
- "1": 1
+ "0": 0
}
}
}
@@ -78,7 +78,7 @@
"byName": {},
"byBlocks": {},
"usedIds": {
- "1": 1
+ "0": 0
}
}
}
@@ -99,7 +99,7 @@
"byName": {},
"byBlocks": {},
"usedIds": {
- "1": 1
+ "0": 0
}
}
}
@@ -120,7 +120,7 @@
"byName": {},
"byBlocks": {},
"usedIds": {
- "1": 1
+ "0": 0
}
}
}
@@ -141,7 +141,7 @@
"byName": {},
"byBlocks": {},
"usedIds": {
- "1": 1
+ "0": 0
}
}
}
@@ -663,7 +663,8 @@
"../../babel-loader/lib/index.js?ignore=src/lib!../../../packages/devtools-wasm-dwarf/src/convertToJSON.js": 512,
"../../babel-loader/lib/index.js?ignore=src/lib!../../../packages/devtools-wasm-dwarf/src/wasmXScopes.js": 513,
"../../babel-loader/lib/index.js?ignore=src/lib!../../../packages/devtools-wasm-dwarf/src/wasmDwarfExpressions.js": 514,
- "../../babel-loader/lib/index.js?ignore=src/lib!../../../packages/devtools-source-map/src/utils/assetRootBrowser.js": 515
+ "../../babel-loader/lib/index.js?ignore=src/lib!../../../packages/devtools-source-map/src/utils/assetRootBrowser.js": 515,
+ "../../babel-loader/lib/index.js?ignore=src/lib!../../devtools-modules/src/async-store-helper.js": 516
},
"usedIds": {
"0": 0,
@@ -1181,7 +1182,8 @@
"512": 512,
"513": 513,
"514": 514,
- "515": 515
+ "515": 515,
+ "516": 516
}
},
"chunks": {
diff --git a/devtools/client/debugger/dist/parser-worker.js b/devtools/client/debugger/dist/parser-worker.js
index ae4f41cb051a..1cce730fdfa8 100644
--- a/devtools/client/debugger/dist/parser-worker.js
+++ b/devtools/client/debugger/dist/parser-worker.js
@@ -6597,27 +6597,27 @@ module.exports = {
/* 15 */
/***/ (function(module, exports) {
-var g;
-
-// This works in non-strict mode
-g = (function() {
- return this;
-})();
-
-try {
- // This works if eval is allowed (see CSP)
- g = g || Function("return this")() || (1,eval)("this");
-} catch(e) {
- // This works if the window reference is available
- if(typeof window === "object")
- g = window;
-}
-
-// g can still be undefined, but nothing to do about it...
-// We return undefined, instead of nothing here, so it's
-// easier to handle this case. if(!global) { ...}
-
-module.exports = g;
+var g;
+
+// This works in non-strict mode
+g = (function() {
+ return this;
+})();
+
+try {
+ // This works if eval is allowed (see CSP)
+ g = g || Function("return this")() || (1,eval)("this");
+} catch(e) {
+ // This works if the window reference is available
+ if(typeof window === "object")
+ g = window;
+}
+
+// g can still be undefined, but nothing to do about it...
+// We return undefined, instead of nothing here, so it's
+// easier to handle this case. if(!global) { ...}
+
+module.exports = g;
/***/ }),
@@ -7004,28 +7004,28 @@ module.exports = isObject;
/* 22 */
/***/ (function(module, exports) {
-module.exports = function(module) {
- if(!module.webpackPolyfill) {
- module.deprecate = function() {};
- module.paths = [];
- // module.parent = undefined by default
- if(!module.children) module.children = [];
- Object.defineProperty(module, "loaded", {
- enumerable: true,
- get: function() {
- return module.l;
- }
- });
- Object.defineProperty(module, "id", {
- enumerable: true,
- get: function() {
- return module.i;
- }
- });
- module.webpackPolyfill = 1;
- }
- return module;
-};
+module.exports = function(module) {
+ if(!module.webpackPolyfill) {
+ module.deprecate = function() {};
+ module.paths = [];
+ // module.parent = undefined by default
+ if(!module.children) module.children = [];
+ Object.defineProperty(module, "loaded", {
+ enumerable: true,
+ get: function() {
+ return module.l;
+ }
+ });
+ Object.defineProperty(module, "id", {
+ enumerable: true,
+ get: function() {
+ return module.i;
+ }
+ });
+ module.webpackPolyfill = 1;
+ }
+ return module;
+};
/***/ }),
@@ -8897,12 +8897,10 @@ function getVariables(dec) {
// NOTE: it's possible that an element is empty or has several variables
// e.g. const [, a] = arr
// e.g. const [{a, b }] = 2
- return dec.id.elements.filter(element => element).map(element => {
- return {
- name: t.isAssignmentPattern(element) ? element.left.name : element.name || element.argument && element.argument.name,
- location: element.loc
- };
- }).filter(({ name }) => name);
+ return dec.id.elements.filter(element => element).map(element => ({
+ name: t.isAssignmentPattern(element) ? element.left.name : element.name || element.argument && element.argument.name,
+ location: element.loc
+ })).filter(({ name }) => name);
}
return [{
@@ -17517,15 +17515,14 @@ function findScopes(scopes, location) {
break;
}
}
- return found.map(i => {
- return {
- type: i.type,
- displayName: i.displayName,
- start: i.start,
- end: i.end,
- bindings: i.bindings
- };
- });
+ return found.map(i => ({
+ type: i.type,
+ scopeKind: i.scopeKind,
+ displayName: i.displayName,
+ start: i.start,
+ end: i.end,
+ bindings: i.bindings
+ }));
}
function compareLocations(a, b) {
@@ -50329,18 +50326,17 @@ function toParsedScopes(children, sourceId) {
if (!children || children.length === 0) {
return undefined;
}
- return children.map(scope => {
+ return children.map(scope => ({
// Removing unneed information from TempScope such as parent reference.
// We also need to convert BabelLocation to the Location type.
- return {
- start: scope.loc.start,
- end: scope.loc.end,
- type: scope.type === "module" || scope.type === "function-body" ? "block" : scope.type,
- displayName: scope.displayName,
- bindings: scope.bindings,
- children: toParsedScopes(scope.children, sourceId)
- };
- });
+ start: scope.loc.start,
+ end: scope.loc.end,
+ type: scope.type === "module" || scope.type === "function-body" ? "block" : scope.type,
+ scopeKind: "",
+ displayName: scope.displayName,
+ bindings: scope.bindings,
+ children: toParsedScopes(scope.children, sourceId)
+ }));
}
function createTempScope(type, displayName, parent, loc) {
@@ -50460,10 +50456,7 @@ function createGlobalScope(ast, sourceId) {
end: fromBabelLocation(ast.loc.end, sourceId)
});
- return {
- global,
- lexical
- };
+ return { global, lexical };
}
const scopeCollectionVisitor = {
diff --git a/devtools/client/debugger/dist/vendors.js b/devtools/client/debugger/dist/vendors.js
index a779fa56106d..7940adb83de9 100644
--- a/devtools/client/debugger/dist/vendors.js
+++ b/devtools/client/debugger/dist/vendors.js
@@ -647,7 +647,7 @@ class Tree extends Component {
super(props);
this.state = {
- seen: new Set()
+ autoExpanded: new Set()
};
this.treeRef = _react2.default.createRef();
@@ -691,26 +691,36 @@ class Tree extends Component {
}
_autoExpand() {
- const { autoExpandDepth, autoExpandNodeChildrenLimit } = this.props;
- if (!autoExpandDepth) {
+ const {
+ autoExpandDepth,
+ autoExpandNodeChildrenLimit,
+ initiallyExpanded
+ } = this.props;
+
+ if (!autoExpandDepth && !initiallyExpanded) {
return;
}
// Automatically expand the first autoExpandDepth levels for new items. Do
// not use the usual DFS infrastructure because we don't want to ignore
- // collapsed nodes.
+ // collapsed nodes. Any initially expanded items will be expanded regardless
+ // of how deep they are.
const autoExpand = (item, currentDepth) => {
- if (currentDepth >= autoExpandDepth || this.state.seen.has(item)) {
+ const initial = initiallyExpanded && initiallyExpanded(item);
+
+ if (!initial && currentDepth >= autoExpandDepth) {
return;
}
const children = this.props.getChildren(item);
- if (autoExpandNodeChildrenLimit && children.length > autoExpandNodeChildrenLimit) {
+ if (!initial && autoExpandNodeChildrenLimit && children.length > autoExpandNodeChildrenLimit) {
return;
}
- this.props.onExpand(item);
- this.state.seen.add(item);
+ if (!this.state.autoExpanded.has(item)) {
+ this.props.onExpand(item);
+ this.state.autoExpanded.add(item);
+ }
const length = children.length;
for (let i = 0; i < length; i++) {
@@ -726,6 +736,14 @@ class Tree extends Component {
}
} else if (length != 0) {
autoExpand(roots[0], 0);
+
+ if (initiallyExpanded) {
+ for (let i = 1; i < length; i++) {
+ if (initiallyExpanded(roots[i])) {
+ autoExpand(roots[i], 0);
+ }
+ }
+ }
}
}
@@ -1481,6 +1499,7 @@ const KeyShortcuts = __webpack_require__(425);
const { ZoomKeys } = __webpack_require__(426);
const EventEmitter = __webpack_require__(65);
const asyncStorage = __webpack_require__(427);
+const asyncStoreHelper = __webpack_require__(516);
const SourceUtils = __webpack_require__(428);
const Telemetry = __webpack_require__(429);
const { getUnicodeHostname, getUnicodeUrlPath, getUnicodeUrl } = __webpack_require__(430);
@@ -1491,6 +1510,7 @@ module.exports = {
PrefsHelper,
ZoomKeys,
asyncStorage,
+ asyncStoreHelper,
EventEmitter,
SourceUtils,
Telemetry,
@@ -6137,6 +6157,66 @@ module.exports = PluralForm;
/***/ }),
+/***/ 516:
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
+
+
+
+const asyncStorage = __webpack_require__(427);
+
+/*
+ * asyncStoreHelper wraps asyncStorage so that it is easy to define project
+ * specific properties. It is similar to PrefsHelper.
+ *
+ * e.g.
+ * const asyncStore = asyncStoreHelper("r", {a: "_a"})
+ * asyncStore.a // => asyncStorage.getItem("r._a")
+ * asyncStore.a = 2 // => asyncStorage.setItem("r._a", 2)
+ */
+function asyncStoreHelper(root, mappings) {
+ let store = {};
+
+ function getMappingKey(key) {
+ return Array.isArray(mappings[key]) ? mappings[key][0] : mappings[key];
+ }
+
+ function getMappingDefaultValue(key) {
+ return Array.isArray(mappings[key]) ? mappings[key][1] : null;
+ }
+
+ Object.keys(mappings).map(key => Object.defineProperty(store, key, {
+ async get() {
+ const value = await asyncStorage.getItem(`${root}.${getMappingKey(key)}`);
+ return value || getMappingDefaultValue(key);
+ },
+ set(value) {
+ return asyncStorage.setItem(`${root}.${getMappingKey(key)}`, value);
+ }
+ }));
+
+ store = new Proxy(store, {
+ set: function (target, property, value, receiver) {
+ if (!mappings.hasOwnProperty(property)) {
+ throw new Error(`AsyncStore: ${property} is not defined in mappings`);
+ }
+
+ Reflect.set(...arguments);
+ return true;
+ }
+ });
+
+ return store;
+}
+
+module.exports = asyncStoreHelper;
+
+/***/ }),
+
/***/ 6:
/***/ (function(module, exports) {
diff --git a/devtools/client/debugger/packages/devtools-reps/src/object-inspector/components/ObjectInspector.js b/devtools/client/debugger/packages/devtools-reps/src/object-inspector/components/ObjectInspector.js
index e83672ae6d30..d4e6c8d8461f 100644
--- a/devtools/client/debugger/packages/devtools-reps/src/object-inspector/components/ObjectInspector.js
+++ b/devtools/client/debugger/packages/devtools-reps/src/object-inspector/components/ObjectInspector.js
@@ -119,6 +119,12 @@ class ObjectInspector extends Component<Props> {
}
}
}
+
+ for (const path of nextProps.expandedPaths) {
+ if (!nextProps.loadedProperties.has(path)) {
+ nextProps.nodeLo;
+ }
+ }
}
shouldComponentUpdate(nextProps: Props) {
@@ -194,6 +200,7 @@ class ObjectInspector extends Component<Props> {
return;
}
+ console.log(`>> setExpanded `, { item, expand });
const {
nodeExpand,
nodeCollapse,
diff --git a/devtools/client/debugger/packages/devtools-reps/src/object-inspector/reducer.js b/devtools/client/debugger/packages/devtools-reps/src/object-inspector/reducer.js
index cf75ea15dd04..3f545087e265 100644
--- a/devtools/client/debugger/packages/devtools-reps/src/object-inspector/reducer.js
+++ b/devtools/client/debugger/packages/devtools-reps/src/object-inspector/reducer.js
@@ -63,6 +63,10 @@ function reducer(
});
}
+ if (type == "EVALUATE_EXPRESSIONS") {
+ cloneState({ loadedProperties: new Map() });
+ }
+
// NOTE: we clear the state on resume because otherwise the scopes pane
// would be out of date. Bug 1514760
if (type === "RESUME" || type == "NAVIGATE") {
diff --git a/devtools/client/debugger/src/actions/expressions.js b/devtools/client/debugger/src/actions/expressions.js
index 2d757cad4799..1524dfd6052c 100644
--- a/devtools/client/debugger/src/actions/expressions.js
+++ b/devtools/client/debugger/src/actions/expressions.js
@@ -128,6 +128,7 @@ export function evaluateExpressions(cx: ThreadContext) {
frameId,
thread: cx.thread,
});
+
dispatch({ type: "EVALUATE_EXPRESSIONS", cx, inputs, results });
};
}
@@ -158,7 +159,7 @@ function evaluateExpression(cx: ThreadContext, expression: Expression) {
const frameId = getSelectedFrameId(getState(), cx.thread);
- return dispatch({
+ await dispatch({
type: "EVALUATE_EXPRESSION",
cx,
thread: cx.thread,
@@ -168,6 +169,8 @@ function evaluateExpression(cx: ThreadContext, expression: Expression) {
thread: cx.thread,
}),
});
+
+ // reLoadExpandedProperties();
};
}
diff --git a/devtools/client/shared/components/reps/reps.js b/devtools/client/shared/components/reps/reps.js
index 112a87a31318..e934976dcd74 100644
--- a/devtools/client/shared/components/reps/reps.js
+++ b/devtools/client/shared/components/reps/reps.js
@@ -2357,6 +2357,10 @@ function reducer(state = initialState(), action = {}) {
});
}
+ if (type == "EVALUATE_EXPRESSIONS") {
+ cloneState({ loadedProperties: new Map() });
+ }
+
// NOTE: we clear the state on resume because otherwise the scopes pane
// would be out of date. Bug 1514760
if (type === "RESUME" || type == "NAVIGATE") {
@@ -7015,6 +7019,7 @@ class ObjectInspector extends Component {
return;
}
+ console.log(`>> setExpanded `, { item, expand });
const {
nodeExpand,
nodeCollapse,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment