@@ -463,14 +463,21 @@ export default class SharedOpsUtil extends SharedUtil
463463 const code = fs . readFileSync ( fn , "utf8" ) ;
464464 let codeAttachments = "const attachments=op.attachments={" ;
465465 let codeAttachmentsInc = "" ;
466+ let staticAttachments = "static staticAttachments={" ;
466467 const dir = fs . readdirSync ( path . dirname ( fn ) ) ;
467468 for ( const i in dir )
468469 {
469470 if ( dir [ i ] . startsWith ( "att_inc_" ) )
470471 {
471472 codeAttachmentsInc += fs . readFileSync ( path . dirname ( fn ) + "/" + dir [ i ] , "utf8" ) ;
472473 }
473- if ( dir [ i ] === this . SUBPATCH_ATTACHMENT_PORTS )
474+ if ( dir [ i ] . startsWith ( "att_bin_" ) )
475+ {
476+ let varName = dir [ i ] . substr ( 8 , dir [ i ] . length - 8 ) ;
477+ varName = varName . replace ( / \. / g, "_" ) ;
478+ staticAttachments += "\"" + varName + "\":\"" + Buffer . from ( fs . readFileSync ( path . dirname ( fn ) + "/" + dir [ i ] ) ) . toString ( "base64" ) + "\"," ;
479+ }
480+ else if ( dir [ i ] === this . SUBPATCH_ATTACHMENT_PORTS )
474481 {
475482 if ( prepareForExport ) continue ;
476483 let varName = dir [ i ] . substr ( 4 , dir [ i ] . length - 4 ) ;
@@ -518,6 +525,7 @@ export default class SharedOpsUtil extends SharedUtil
518525 }
519526 }
520527
528+ staticAttachments += "};\n" ;
521529 codeAttachments += "};\n" ;
522530
523531 const codeHead = "\n\n// **************************************************************\n" +
@@ -527,8 +535,9 @@ export default class SharedOpsUtil extends SharedUtil
527535 "// **************************************************************\n\n" +
528536 opName + "= class extends CABLES.Op \n" +
529537 "{\n" +
538+ staticAttachments + "\n" +
530539 "constructor()\n" +
531- "{\nsuper(...arguments);\nconst op=this;\n" ;
540+ "{\nsuper(...arguments);\nconst op=this;\nconst staticAttachments=this.constructor.staticAttachments;\ n" ;
532541 let codeFoot = "\n}\n};\n\n" ;
533542
534543 if ( opId && ! prepareForExport ) codeFoot += "CABLES.OPS[\"" + opId + "\"]={f:" + opName + ",objName:\"" + opName + "\"};" ;
0 commit comments