File tree 3 files changed +52
-2
lines changed 3 files changed +52
-2
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,13 @@ export default function useHandleMessageEvent() {
14
14
) => {
15
15
if ( typeof obj !== 'object' || obj === null ) return obj ;
16
16
17
+ if ( obj && obj . constructor && obj . constructor . name === 'p5.Font' ) {
18
+ return {
19
+ _type : 'p5.Font' ,
20
+ name : obj . name || 'Font'
21
+ } ;
22
+ }
23
+
17
24
if ( depth >= maxDepth ) {
18
25
if ( seen . has ( obj ) ) return '[Circular Reference]' ;
19
26
}
Original file line number Diff line number Diff line change @@ -27,8 +27,35 @@ function notifyListener(message) {
27
27
if ( listener ) listener ( message ) ;
28
28
}
29
29
30
+ // Helper function to handle p5.Font objects
31
+ const handleP5Font = ( obj ) => {
32
+ if ( obj && obj . constructor && obj . constructor . name === 'p5.Font' ) {
33
+ return {
34
+ _type : 'p5.Font' ,
35
+ name : obj . name || 'Font'
36
+ } ;
37
+ }
38
+ return obj ;
39
+ } ;
40
+
41
+ // Message processing logic to handle nested objects and arrays
42
+ const processMessage = ( message ) => {
43
+ if ( typeof message === 'object' && message !== null ) {
44
+ if ( Array . isArray ( message ) ) {
45
+ return message . map ( processMessage ) ;
46
+ }
47
+ return Object . fromEntries (
48
+ Object . entries ( message ) . map ( ( [ key , value ] ) => [
49
+ key ,
50
+ processMessage ( handleP5Font ( value ) )
51
+ ] )
52
+ ) ;
53
+ }
54
+ return message ;
55
+ } ;
56
+
30
57
function notifyFrames ( message ) {
31
- const rawMessage = JSON . parse ( JSON . stringify ( message ) ) ;
58
+ const rawMessage = processMessage ( message ) ;
32
59
Object . keys ( frames ) . forEach ( ( frameId ) => {
33
60
const { frame, origin } = frames [ frameId ] ;
34
61
if ( frame && frame . postMessage ) {
Original file line number Diff line number Diff line change @@ -17,11 +17,27 @@ window.objectPaths[blobPath] = 'index.html';
17
17
18
18
window . loopProtect = loopProtect ;
19
19
20
+ // Helper function to handle p5.Font objects
21
+ const handleP5Font = ( obj ) => {
22
+ if ( obj && obj . constructor && obj . constructor . name === 'p5.Font' ) {
23
+ return {
24
+ _type : 'p5.Font' ,
25
+ name : obj . name || 'Font'
26
+ } ;
27
+ }
28
+ return obj ;
29
+ } ;
30
+
20
31
const consoleBuffer = [ ] ;
21
32
const LOGWAIT = 500 ;
22
33
Hook ( window . console , ( log ) => {
34
+ // Process p5.Font objects in logs
35
+ const processedLog = {
36
+ ...log ,
37
+ data : log . data ? log . data . map ( handleP5Font ) : log . data
38
+ } ;
23
39
consoleBuffer . push ( {
24
- log
40
+ log : processedLog
25
41
} ) ;
26
42
} ) ;
27
43
setInterval ( ( ) => {
You can’t perform that action at this time.
0 commit comments