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ser v5.39.0.\n * Original file: /npm/rete-task-plugin@0.3.0/build/task-plugin.common.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","export class Task {\n\n    constructor(inputs, component, worker) {\n        this.inputs = inputs;\n        this.component = component;\n        this.worker = worker;\n        this.next = [];\n        this.outputData = null;\n        this.closed = [];\n\n        this.getInputs('option').forEach(key => {\n            this.inputs[key].forEach(con => {\n                con.task.next.push({ key: con.key, task: this });\n            })\n        });\n    }\n\n    getInputs(type) {\n        return Object.keys(this.inputs)\n            .filter(key => this.inputs[key][0])\n            .filter(key => this.inputs[key][0].type === type)\n    }\n\n    reset() {\n        this.outputData = null;\n    }\n\n    async run(data, needReset = true, garbage = [], propagate = true) {\n        if (needReset)\n            garbage.push(this);\n        \n        if (!this.outputData) {\n            var inputs = {};\n\n            await Promise.all(this.getInputs('output').map(async key => {\n                inputs[key] = await Promise.all(this.inputs[key].map(async con => {\n                    if (con) {\n                        await con.task.run(data, false, garbage, false);\n                        return con.task.outputData[con.key];\n                    }\n                }));\n            }));\n\n            this.outputData = await this.worker(this, inputs, data);\n\n            if (propagate)\n                await Promise.all(\n                    this.next\n                        .filter(f => !this.closed.includes(f.key))\n                        .map(async f => \n                            await f.task.run(data, false, garbage)\n                        )\n                );\n        }\n        \n        if (needReset)\n            garbage.map(t => t.reset());\n    }\n  \n    clone(root = true, oldTask, newTask) {\n        const inputs = Object.assign({}, this.inputs);\n\n        if (root) // prevent of adding this task to `next` property of predecessor\n            this.getInputs('option').map(key => delete inputs[key]);\n        else // replace old tasks with new copies\n            Object.keys(inputs).map(key => {\n                inputs[key] = inputs[key].map(con => ({\n                    ...con,\n                    task: con.task === oldTask ? newTask : con.task\n                }));\n            });\n    \n        const task = new Task(inputs, this.component, this.worker);\n\n        // manually add a copies of follow tasks\n        task.next = this.next.map(n => ({ key: n.key, task: n.task.clone(false, this, task)}));\n    \n        return task;\n    }\n}","import { Task } from './task';\n\nfunction install(editor) {\n        \n    editor.on('componentregister', component => {\n        if (!component.task)\n            throw 'Task plugin requires a task property in component';\n        if (component.task.outputs.constructor !== Object)\n            throw 'The \"outputs\" field must be an object whose keys correspond to the Output\\'s keys';\n        \n        const taskWorker = component.worker;\n        const taskOptions = component.task;\n\n        component.worker = (node, inputs, outputs) => {\n            const task = new Task(inputs, component, (ctx, inps, data) => {\n                return taskWorker.call(ctx, node, inps, data);\n            });\n\n            if (taskOptions.init) taskOptions.init(task, node);\n            \n            Object.keys(taskOptions.outputs).map(key => {\n                outputs[key] = { type: taskOptions.outputs[key], key, task }\n            });\n        }\n\n    });\n}\n\nexport { Task } from './task';\nexport default {\n    name: 'task-plugin',\n    install\n}"]}