Skip to content

Commit da8a354

Browse files
update
1 parent 886a092 commit da8a354

File tree

6 files changed

+534
-1
lines changed

6 files changed

+534
-1
lines changed

chrome/public/bundle/bundle-dev.js

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5965,6 +5965,7 @@
59655965
return r ? r[ReactiveFlags.IS_REF] === true : false;
59665966
}
59675967

5968+
var nodeValueSymbol = Symbol.for("devtool-node-value");
59685969
var isInBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
59695970
var emptyConstructor = {}.constructor;
59705971
var id = 1;
@@ -6017,6 +6018,7 @@
60176018
value !== "WeakMap" &&
60186019
value !== "WeakSet");
60196020
};
6021+
// serialized any obj to devtool protocol obj
60206022
var getTargetNode = function (value, type, deep) {
60216023
if (deep === void 0) { deep = 3; }
60226024
var existId = valueToIdMap.get(value);
@@ -6037,6 +6039,7 @@
60376039
// full deep to load
60386040
if (deep === 0) {
60396041
return {
6042+
s: nodeValueSymbol,
60406043
i: currentId,
60416044
t: type,
60426045
_t: wrapperType,
@@ -6049,6 +6052,7 @@
60496052
else {
60506053
if (type === "Array") {
60516054
return {
6055+
s: nodeValueSymbol,
60526056
i: currentId,
60536057
t: type,
60546058
_t: wrapperType,
@@ -6058,6 +6062,7 @@
60586062
}
60596063
else if (type === "Iterable") {
60606064
return {
6065+
s: nodeValueSymbol,
60616066
i: currentId,
60626067
t: type,
60636068
_t: wrapperType,
@@ -6067,6 +6072,7 @@
60676072
}
60686073
else if (type === "Map") {
60696074
return {
6075+
s: nodeValueSymbol,
60706076
i: currentId,
60716077
t: type,
60726078
_t: wrapperType,
@@ -6083,6 +6089,7 @@
60836089
}
60846090
else if (type === "Set") {
60856091
return {
6092+
s: nodeValueSymbol,
60866093
i: currentId,
60876094
t: type,
60886095
_t: wrapperType,
@@ -6092,6 +6099,7 @@
60926099
}
60936100
else if (type === "Object") {
60946101
return {
6102+
s: nodeValueSymbol,
60956103
i: currentId,
60966104
t: type,
60976105
_t: wrapperType,
@@ -6105,6 +6113,7 @@
61056113
}
61066114
else if (type === "ReactElement") {
61076115
return {
6116+
s: nodeValueSymbol,
61086117
i: currentId,
61096118
t: type,
61106119
_t: wrapperType,
@@ -6118,6 +6127,7 @@
61186127
}
61196128
else {
61206129
return {
6130+
s: nodeValueSymbol,
61216131
i: currentId,
61226132
t: type,
61236133
_t: wrapperType || "Object",
@@ -6160,6 +6170,7 @@
61606170
valueToIdMap.set(value, currentId);
61616171
if (type === "Element") {
61626172
return {
6173+
s: nodeValueSymbol,
61636174
i: currentId,
61646175
t: type,
61656176
_t: wrapperType,
@@ -6169,6 +6180,7 @@
61696180
}
61706181
if (type === "Error") {
61716182
return {
6183+
s: nodeValueSymbol,
61726184
i: currentId,
61736185
t: type,
61746186
_t: wrapperType,
@@ -6178,6 +6190,7 @@
61786190
}
61796191
if (typeof value === "object" && value !== null) {
61806192
return {
6193+
s: nodeValueSymbol,
61816194
i: currentId,
61826195
t: type,
61836196
_t: wrapperType,
@@ -6187,6 +6200,7 @@
61876200
}
61886201
else {
61896202
return {
6203+
s: nodeValueSymbol,
61906204
i: currentId,
61916205
t: type,
61926206
_t: wrapperType,
@@ -6198,13 +6212,97 @@
61986212
}
61996213
catch (e) {
62006214
return {
6215+
s: nodeValueSymbol,
62016216
i: NaN,
62026217
t: "ReadError",
62036218
v: "Read data error: " + e.message,
62046219
e: false,
62056220
};
62066221
}
62076222
};
6223+
var getObj = function (value) {
6224+
var _a = value || {}, t = _a.t, v = _a.v, i = _a.i, s = _a.s;
6225+
if (!s || s !== nodeValueSymbol) {
6226+
return value;
6227+
}
6228+
// If we have the original object cached, return it
6229+
if (idToValueMap.has(i)) {
6230+
return idToValueMap.get(i);
6231+
}
6232+
switch (t) {
6233+
case "Array":
6234+
return v.map(getObj);
6235+
case "Iterable":
6236+
return v.map(getObj);
6237+
case "Map": {
6238+
var map_1 = new Map();
6239+
v.forEach(function (entry) {
6240+
var _a = entry.v, key = _a[0], val = _a[1];
6241+
map_1.set(getObj(key), getObj(val));
6242+
});
6243+
return map_1;
6244+
}
6245+
case "Set": {
6246+
var set_1 = new Set();
6247+
v.forEach(function (item) {
6248+
set_1.add(getObj(item));
6249+
});
6250+
return set_1;
6251+
}
6252+
case "Object":
6253+
case "ReactElement":
6254+
case "Module": {
6255+
var obj_1 = {};
6256+
Object.keys(v).forEach(function (key) {
6257+
obj_1[key] = getObj(v[key]);
6258+
});
6259+
return obj_1;
6260+
}
6261+
case "String":
6262+
return v;
6263+
case "Number":
6264+
return Number(v);
6265+
case "Boolean":
6266+
return v === "true" || v === true;
6267+
case "Date":
6268+
return new Date(v);
6269+
case "Null":
6270+
return null;
6271+
case "Undefined":
6272+
return undefined;
6273+
case "Function":
6274+
case "AsyncFunction":
6275+
case "GeneratorFunction":
6276+
// Cannot reconstruct functions, return a placeholder or the string representation
6277+
return v;
6278+
case "Symbol":
6279+
return Symbol(v);
6280+
case "RegExp": {
6281+
// v is like "/pattern/flags"
6282+
var match = String(v).match(/^\/(.*)\/([gimsuy]*)$/);
6283+
if (match) {
6284+
return new RegExp(match[1], match[2]);
6285+
}
6286+
return new RegExp(v);
6287+
}
6288+
case "Promise":
6289+
// Cannot reconstruct promises, return the value representation
6290+
return v;
6291+
case "Element":
6292+
// DOM elements cannot be reconstructed from string, return the string representation
6293+
return v;
6294+
case "Error":
6295+
return new Error(v);
6296+
case "WeakMap":
6297+
case "WeakSet":
6298+
// WeakMap/WeakSet cannot be reconstructed
6299+
return v;
6300+
case "ReadError":
6301+
return new Error(v);
6302+
default:
6303+
return v;
6304+
}
6305+
};
62086306
var getNodeFromId = function (id) {
62096307
var value = idToValueMap.get(id);
62106308
if (value) {
@@ -9474,6 +9572,12 @@
94749572
data.map(function (item) { return _this._notify({ type: exports.DevToolMessageEnum.record, data: item }); });
94759573
this._notify({ type: exports.DevToolMessageEnum.record, data: true });
94769574
};
9575+
DevToolCore.prototype.getNode = function (v) {
9576+
return getNode(v);
9577+
};
9578+
DevToolCore.prototype.getObj = function (v) {
9579+
return getObj(v);
9580+
};
94779581
// TODO support multiple connect agent
94789582
DevToolCore.prototype.connect = function () {
94799583
if (this._enabled)
@@ -9549,6 +9653,7 @@
95499653
exports.getMockFiberFromElement = getMockFiberFromElement;
95509654
exports.getNode = getNode;
95519655
exports.getNodeFromId = getNodeFromId;
9656+
exports.getObj = getObj;
95529657
exports.getPlainNodeByFiber = getPlainNodeByFiber;
95539658
exports.getPlainNodeIdByFiber = getPlainNodeIdByFiber;
95549659
exports.getProps = getProps;

0 commit comments

Comments
 (0)