From 9438874922a289ae3eb78e0792f0dc80d020cb51 Mon Sep 17 00:00:00 2001 From: Davor Hrg Date: Mon, 16 Oct 2023 09:18:24 +0200 Subject: [PATCH] move some srcs, separate extractDefaults func --- packages/worker/{ => src}/exportStlText.js | 0 packages/worker/src/extractDefaults.js | 19 +++++++++++++++ .../getParameterDefinitionsFromSource.js | 0 packages/worker/worker.js | 23 ++++--------------- 4 files changed, 23 insertions(+), 19 deletions(-) rename packages/worker/{ => src}/exportStlText.js (100%) create mode 100644 packages/worker/src/extractDefaults.js rename packages/worker/{ => src}/getParameterDefinitionsFromSource.js (100%) diff --git a/packages/worker/exportStlText.js b/packages/worker/src/exportStlText.js similarity index 100% rename from packages/worker/exportStlText.js rename to packages/worker/src/exportStlText.js diff --git a/packages/worker/src/extractDefaults.js b/packages/worker/src/extractDefaults.js new file mode 100644 index 0000000..bb6ed91 --- /dev/null +++ b/packages/worker/src/extractDefaults.js @@ -0,0 +1,19 @@ +export function extractDefaults(def){ + const params = {} + def.forEach(({ name, initial, default: def, type, values, captions }) =>{ + let val = def === undefined ? initial : def + if(type === 'choice' && values.indexOf(v=>v === val) === -1){ + // it is supported for choice to use default value from captions also + // but script will need the matching value + for(let i=0; i { const fromSource = getParameterDefinitionsFromSource(script) def = combineParameterDefinitions(fromSource, await scriptModule.getParameterDefinitions?.()) main = scriptModule.main - const params = {} - def.forEach(({ name, initial, default: def, type, values, captions }) =>{ - let val = def === undefined ? initial : def - if(type === 'choice' && values.indexOf(v=>v === val) === -1){ - // it is supported for choice to use default value from captions also - // but script will need the matching value - for(let i=0; i