File tree 2 files changed +26
-2
lines changed
2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -66,4 +66,4 @@ export default function useHandleMessageEvent() {
66
66
} ;
67
67
68
68
return handleMessageEvent ;
69
- }
69
+ }
Original file line number Diff line number Diff line change @@ -35,6 +35,30 @@ setInterval(() => {
35
35
}
36
36
} , LOGWAIT ) ;
37
37
38
+ // Helper function to handle p5.Font objects
39
+ function handleP5Font ( obj ) {
40
+ // Check for p5.Font instances in multiple ways
41
+ if (
42
+ ( obj &&
43
+ obj . constructor &&
44
+ ( obj . constructor . name === 'Font' ||
45
+ obj . constructor . name === 'p5.Font' ) ) ||
46
+ ( window . p5 && obj instanceof window . p5 . Font )
47
+ ) {
48
+ return {
49
+ _isP5Font : true ,
50
+ name : obj . name ,
51
+ path : obj . path ,
52
+ face : {
53
+ family : obj . face ?. family ,
54
+ style : obj . face ?. style ,
55
+ weight : obj . face ?. weight
56
+ }
57
+ } ;
58
+ }
59
+ return obj ;
60
+ }
61
+
38
62
function handleMessageEvent ( e ) {
39
63
// maybe don't need this?? idk!
40
64
if ( window . origin !== e . origin ) return ;
@@ -44,7 +68,7 @@ function handleMessageEvent(e) {
44
68
const decodedMessages = messages . map ( ( message ) => Decode ( message . log ) ) ;
45
69
decodedMessages . forEach ( ( message ) => {
46
70
const { data : args } = message ;
47
- const { result, error } = evaluateExpression ( args ) ;
71
+ const { result, error } = evaluateExpression ( args . map ( handleP5Font ) ) ;
48
72
const resultMessages = [
49
73
{ log : Encode ( { method : error ? 'error' : 'result' , data : [ result ] } ) }
50
74
] ;
You can’t perform that action at this time.
0 commit comments