From 4e38ec584c4502b0ef4db7ad8e5028efc560004a Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 26 Sep 2023 10:52:32 -0400 Subject: [PATCH 1/2] fix(bindgen): duplicate JsonCompatible imports for inputs, outputs --- src/bindgen/typescript/function-module.js | 8 -------- src/bindgen/typescript/types-require-import.js | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/bindgen/typescript/function-module.js b/src/bindgen/typescript/function-module.js index 83dfb8974..cc39c8faa 100644 --- a/src/bindgen/typescript/function-module.js +++ b/src/bindgen/typescript/function-module.js @@ -39,7 +39,6 @@ function functionModule (srcOutputDir, forNode, interfaceJson, modulePascalCase, let functionContent = `import {\n` const usedInterfaceTypes = new Set() let needMountDirs = false - let needJsonCompatible = false const pipelineComponents = ['inputs', 'outputs', 'parameters'] pipelineComponents.forEach((pipelineComponent) => { interfaceJson[pipelineComponent].forEach((value) => { @@ -49,10 +48,6 @@ function functionModule (srcOutputDir, forNode, interfaceJson, modulePascalCase, needMountDirs = true return } - if (interfaceType === 'JsonCompatible' && pipelineComponent === 'inputs') { - needJsonCompatible = true - return - } if (!(pipelineComponent === 'inputs' && interfaceType === 'BinaryStream')) { usedInterfaceTypes.add(interfaceType) } @@ -65,9 +60,6 @@ function functionModule (srcOutputDir, forNode, interfaceJson, modulePascalCase, functionContent += ' InterfaceTypes,\n' functionContent += ' PipelineOutput,\n' functionContent += ' PipelineInput,\n' - if (needJsonCompatible) { - functionContent += ' JsonCompatible,\n' - } if (forNode) { functionContent += ' runPipelineNode\n' } else { diff --git a/src/bindgen/typescript/types-require-import.js b/src/bindgen/typescript/types-require-import.js index 25660a34a..5f8e78930 100644 --- a/src/bindgen/typescript/types-require-import.js +++ b/src/bindgen/typescript/types-require-import.js @@ -1,3 +1,3 @@ -const typesRequireImport = ['Image', 'Mesh', 'PolyData', 'TextFile', 'BinaryFile', 'TextFile', 'BinaryFile'] +const typesRequireImport = ['Image', 'Mesh', 'PolyData', 'TextFile', 'BinaryFile', 'TextFile', 'BinaryFile', 'JsonCompatible'] export default typesRequireImport From 3ff0d7385b3812f72b03720dc2a4dd32e5835bc4 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 26 Sep 2023 10:59:23 -0400 Subject: [PATCH 2/2] fix(bindgen): skip files in function module output counts --- src/bindgen/typescript/function-module.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/bindgen/typescript/function-module.js b/src/bindgen/typescript/function-module.js index cc39c8faa..e593f7a7b 100644 --- a/src/bindgen/typescript/function-module.js +++ b/src/bindgen/typescript/function-module.js @@ -323,7 +323,9 @@ function functionModule (srcOutputDir, forNode, interfaceJson, modulePascalCase, } } functionContent += '\n' - outputCount++ + if (!interfaceType.includes('File')) { + outputCount++ + } } else { functionContent += ` args.push(${camel}.toString())\n\n` } @@ -428,10 +430,11 @@ function functionModule (srcOutputDir, forNode, interfaceJson, modulePascalCase, if (!forNode) { functionContent += ' webWorker: usedWebWorker as Worker,\n' } - interfaceJson.outputs.forEach((output, index) => { + outputCount = 0 + interfaceJson.outputs.forEach((output) => { const camel = camelCase(output.name) const interfaceType = interfaceJsonTypeToInterfaceType.get(output.type) - const outputIndex = haveArray ? `${camel}Index` : index.toString() + const outputIndex = haveArray ? `${camel}Index` : outputCount.toString() if (interfaceType.includes('TextStream') || interfaceType.includes('BinaryStream')) { if (haveArray) { const isArray = output.itemsExpectedMax > 1 @@ -457,6 +460,9 @@ function functionModule (srcOutputDir, forNode, interfaceJson, modulePascalCase, functionContent += ` ${camel}: outputs[${outputIndex}].data as ${interfaceType},\n` } } + if (!interfaceType.includes('File')) { + outputCount++ + } }) functionContent += ' }\n' functionContent += ' return result\n'