Skip to content

Commit

Permalink
prepare op-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
steam0r committed Nov 27, 2024
1 parent d2cbe67 commit 7a22e4f
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
16 changes: 15 additions & 1 deletion shared/api/export/shared_export_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ export default class SharedExportService extends SharedUtil
if (opDoc.coreLibs) coreLibs = coreLibs.concat(opDoc.coreLibs);
}

if (subPatchOp.storage && subPatchOp.isSubPatchOp())
if (this._opsUtil.isSubPatchOp(subPatchOp))
{
const attBp = this._opsUtil.getSubPatchOpAttachment(opName);
if (attBp && attBp.ops && attBp.ops.length > 0)
Expand Down Expand Up @@ -939,6 +939,20 @@ export default class SharedExportService extends SharedUtil
return coreLibScripts;
}

_getDependencyUrls(dependencies)
{
const depLibScripts = [];
for (let l = 0; l < dependencies.length; l++)
{
const dep = dependencies[l];
const file = this._opsUtil.getOpAbsolutePath(dep.op);
const depScript = { "name": dep.name, "src": path.join(this.finalJsPath, dep.src), "type": dep.type };
if (dep.src.startsWith("http")) depScript.file = path.join(file, dep.src);
depLibScripts.push(depScript);
}
return depLibScripts;
}

_addAssets(proj, allFiles, options)
{
this._replaceAssetFilePathes(proj, options.handleAssets);
Expand Down
42 changes: 42 additions & 0 deletions shared/api/utils/shared_doc_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,44 @@ export default class SharedDocUtil extends SharedUtil
return coreLibs;
}

getProjectDependencies(project)
{
if (!project || !project.ops) return [];

let projectDependencies = {};
let usedOpsNames = {};
project.ops.forEach((op) =>
{
usedOpsNames[op.opId] = this._opsUtil.getOpNameById(op.opId);
});
usedOpsNames = Object.values(usedOpsNames);
const opDocs = this.getOpDocsForCollections(usedOpsNames);
for (let i = 0; i < opDocs.length; i++)
{
const opDoc = opDocs[i];
if (opDoc.dependencies)
{
const opDeps = opDoc.dependencies.filter((dep) => { return dep.type === "commonjs" || dep.type === "module"; });
for (let j = 0; j < opDeps.length; j++)
{
const lib = opDeps[j];
for (let k = 0; k < lib.src.length; k++)
{
const libName = k ? lib.name + "_" + (k + 1) : lib.name;
const src = lib.src[k];
projectDependencies[libName] = {
"name": libName,
"type": lib.type,
"src": src,
"op": opDoc.name
};
}
}
}
}
return Object.values(projectDependencies);
}

setOpLinks(str)
{
str = str || "";
Expand Down Expand Up @@ -509,6 +547,10 @@ export default class SharedDocUtil extends SharedUtil
{
docObj.coreLibs = js.coreLibs;
}
if (js.dependencies)
{
docObj.dependencies = js.dependencies;
}
if (js.issues)
{
docObj.issues = js.issues;
Expand Down
7 changes: 7 additions & 0 deletions shared/api/utils/shared_ops_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ export default class SharedOpsUtil extends SharedUtil
return opname.startsWith("Ops.Ui.SubPatch");
}

isSubPatchOp(op)
{
if (!op || !op.storage) return false;
if (op.storage.subPatchVer) return true;
return op.storage.blueprintVer > 1;
}

getOpAbsoluteJsonFilename(opName)
{
const p = this.getOpAbsolutePath(opName);
Expand Down

0 comments on commit 7a22e4f

Please sign in to comment.