Skip to content

Commit 728e658

Browse files
committed
static attachments
1 parent 680dd16 commit 728e658

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

shared/api/utils/shared_ops_util.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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 + "\"};";

shared/shared_constants.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@
106106
"subtitles": [
107107
".srt",
108108
".vtt"
109+
],
110+
"opdependency": [
111+
"*"
109112
]
110113
},
111114
"EDITABLE_FILETYPES": [
@@ -122,4 +125,4 @@
122125
"leave_patch": "Leave Patch"
123126
}
124127
}
125-
}
128+
}

0 commit comments

Comments
 (0)