@@ -174,13 +174,18 @@ class ReviveCache {
174
174
175
175
const reviveCache = new ReviveCache ( 1000 )
176
176
177
- export function stringify ( data ) {
177
+ const replacers = {
178
+ internal : replacerForInternal ,
179
+ user : replaceForUser ,
180
+ }
181
+
182
+ export function stringify ( data , target : keyof typeof replacers = 'internal' ) {
178
183
// Create a fresh cache for each serialization
179
184
encodeCache . clear ( )
180
- return stringifyCircularAutoChunks ( data , replacer )
185
+ return stringifyCircularAutoChunks ( data , replacers [ target ] )
181
186
}
182
187
183
- function replacer ( key ) {
188
+ function replacerForInternal ( key ) {
184
189
// @ts -ignore
185
190
const val = this [ key ]
186
191
const type = typeof val
@@ -244,6 +249,29 @@ function replacer (key) {
244
249
return sanitize ( val )
245
250
}
246
251
252
+ // @TODO revive from backend to have more data to the clipboard
253
+ function replaceForUser ( key ) {
254
+ // @ts -ignore
255
+ let val = this [ key ]
256
+ const type = typeof val
257
+ if ( val ?. _custom && 'value' in val . _custom ) {
258
+ val = val . _custom . value
259
+ }
260
+ if ( type !== 'object' ) {
261
+ if ( val === UNDEFINED ) {
262
+ return undefined
263
+ } else if ( val === INFINITY ) {
264
+ return Infinity
265
+ } else if ( val === NEGATIVE_INFINITY ) {
266
+ return - Infinity
267
+ } else if ( val === NAN ) {
268
+ return NaN
269
+ }
270
+ return val
271
+ }
272
+ return sanitize ( val )
273
+ }
274
+
247
275
export function getCustomMapDetails ( val ) {
248
276
const list = [ ]
249
277
val . forEach (
@@ -706,7 +734,7 @@ export function copyToClipboard (state) {
706
734
if ( typeof state !== 'object' ) {
707
735
text = String ( state )
708
736
} else {
709
- text = stringify ( state )
737
+ text = stringify ( state , 'user' )
710
738
}
711
739
712
740
navigator . clipboard . writeText ( text )
0 commit comments