Skip to content

Commit c13da05

Browse files
update
1 parent be4a30f commit c13da05

File tree

4 files changed

+64
-51
lines changed

4 files changed

+64
-51
lines changed

chrome/public/bundle/hook.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3086,6 +3086,7 @@
30863086
return acc;
30873087
}, {}),
30883088
e: true,
3089+
_t: "Object",
30893090
};
30903091
}
30913092
}
@@ -3095,7 +3096,7 @@
30953096
try {
30963097
var type = getType(value);
30973098
var expandable = isObject(type);
3098-
if (type === 'Promise' && (value._value || value._reason)) {
3099+
if (type === "Promise" && (value.status === "fulfilled" || value.status === "rejected")) {
30993100
expandable = true;
31003101
}
31013102
if (expandable) {

chrome/public/bundle/proxy.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2986,6 +2986,7 @@
29862986
return acc;
29872987
}, {}),
29882988
e: true,
2989+
_t: "Object",
29892990
};
29902991
}
29912992
}
@@ -2995,7 +2996,7 @@
29952996
try {
29962997
var type = getType(value);
29972998
var expandable = isObject(type);
2998-
if (type === 'Promise' && (value._value || value._reason)) {
2999+
if (type === "Promise" && (value.status === "fulfilled" || value.status === "rejected")) {
29993000
expandable = true;
30003001
}
30013002
if (expandable) {

chrome/src/components/NodeValue.tsx

Lines changed: 58 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -52,67 +52,77 @@ export const NodeValue = ({
5252

5353
const t = chunkData?.t ?? item?.t;
5454

55+
const _t = chunkData?._t ?? item?._t;
56+
5557
const text = useMemo(() => {
56-
if (n) {
57-
return n;
58-
}
59-
if (t === "Array" || t === "Set" || t === "Map") {
60-
const re = getText("Array", data ?? []);
61-
if (t === "Set" || t === "Map") {
62-
if (Array.isArray(re)) {
63-
return (
64-
<>
65-
{t}
66-
{"(["}
67-
{re.map((i, index) => (
68-
<Fragment key={index}>
69-
{i}
70-
{index < re.length - 1 ? ", " : ""}
71-
</Fragment>
72-
))}
73-
{"])"}
74-
</>
75-
);
58+
const finalType = _t || t;
59+
const getTextElement = () => {
60+
if (n) {
61+
return n;
62+
}
63+
if (finalType === "Array" || finalType === "Set" || finalType === "Map") {
64+
const re = getText("Array", data ?? []);
65+
if (finalType === "Set" || finalType === "Map") {
66+
if (Array.isArray(re)) {
67+
return (
68+
<>
69+
{finalType}
70+
{"(["}
71+
{re.map((i, index) => (
72+
<Fragment key={index}>
73+
{i}
74+
{index < re.length - 1 ? ", " : ""}
75+
</Fragment>
76+
))}
77+
{"])"}
78+
</>
79+
);
80+
}
81+
return `${finalType}([${re}])`;
82+
} else {
83+
if (Array.isArray(re)) {
84+
return (
85+
<>
86+
{"["}
87+
{re.map((i, index) => (
88+
<Fragment key={index}>
89+
{i}
90+
{index < re.length - 1 ? ", " : ""}
91+
</Fragment>
92+
))}
93+
{"]"}
94+
</>
95+
);
96+
}
97+
return `[${re}]`;
7698
}
77-
return `${t}([${re}])`;
78-
} else {
99+
}
100+
if (finalType === "Iterable" || finalType === "Object") {
101+
const re = getText("Object", data ?? {});
79102
if (Array.isArray(re)) {
80103
return (
81104
<>
82-
{"["}
105+
{"{"}
83106
{re.map((i, index) => (
84107
<Fragment key={index}>
85108
{i}
86109
{index < re.length - 1 ? ", " : ""}
87110
</Fragment>
88111
))}
89-
{"]"}
112+
{"}"}
90113
</>
91114
);
92115
}
93-
return `[${re}]`;
94-
}
95-
}
96-
if (t === "Iterable" || t === "Object") {
97-
const re = getText("Object", data ?? {});
98-
if (Array.isArray(re)) {
99-
return (
100-
<>
101-
{"{"}
102-
{re.map((i, index) => (
103-
<Fragment key={index}>
104-
{i}
105-
{index < re.length - 1 ? ", " : ""}
106-
</Fragment>
107-
))}
108-
{"}"}
109-
</>
110-
);
116+
return `{${re}}`;
111117
}
112-
return `{${re}}`;
118+
};
119+
120+
if (t === "Promise" || t === "Module") {
121+
return <>[object {t} {getTextElement()}]</>;
113122
}
114-
return `[object ${t}]`;
115-
}, [t, n, data]);
123+
124+
return getTextElement();
125+
}, [t, n, data, _t]);
116126

117127
useEffect(() => {
118128
if (expand && item?.l === false && item.i && (!chunkData || chunkData.i !== item.i)) {
@@ -185,13 +195,13 @@ export const NodeValue = ({
185195
<div className="flex w-full my-0.5 items-center">
186196
<span className="text-transparent w-[1.5em] h-[1.5em] inline-block shrink-0">{StateIcon}</span>
187197
{prefix}
188-
<div className={`w-full relative flex pr-2`}>
198+
<div className={`w-full relative flex pr-2 line-clamp-1 break-all`}>
189199
<span className="flex-shrink-0 cursor-pointer select-none whitespace-nowrap" onContextMenu={onContextClick}>
190200
{name}
191201
</span>
192202
<span className="flex-shrink-0 pr-1">:</span>
193203
{currentIsEditable ? (
194-
<span className="hook-value-placeholder line-clamp-1 break-all relative">
204+
<span className="hook-value-placeholder relative line-clamp-1 break-all">
195205
<NodeValueChange item={item} chunkId={chunkId} hookIndex={hookIndex} path={name} type={type || ""} rootItem={rootItem} parentItem={parentItem}>
196206
{element}
197207
</NodeValueChange>
@@ -215,7 +225,7 @@ export const NodeValue = ({
215225
{StateIcon}
216226
</span>
217227
{prefix}
218-
<div className="max-w-full flex">
228+
<div className="max-w-full flex line-clamp-1 break-all">
219229
<span className="flex-shrink-0 cursor-pointer select-none whitespace-nowrap" onClick={() => setExpand(!expand)} onContextMenu={onContextClick}>
220230
{name}
221231
</span>

packages/core/src/data.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ const getTargetNode = (value: any, type: NodeValue["t"], deep = 3): NodeValue =>
190190
return acc;
191191
}, {}),
192192
e: true,
193+
_t: "Object",
193194
};
194195
}
195196
}
@@ -201,7 +202,7 @@ export const getNode = (value: any, deep = 3): NodeValue => {
201202

202203
let expandable = isObject(type);
203204

204-
if (type === 'Promise' && ((value as PromiseWithState<any>)._value || (value as PromiseWithState<any>)._reason)) {
205+
if (type === "Promise" && ((value as PromiseWithState<any>).status === "fulfilled" || (value as PromiseWithState<any>).status === "rejected")) {
205206
expandable = true;
206207
}
207208

0 commit comments

Comments
 (0)