/* Copyright (c) 2020, 2023, The Unified Company. This code is part of Unify. This program is free software; you can redistribute it and/or modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE, as published by the Free Software Foundation. See the GNU AFFERO GENERAL PUBLIC LICENSE, for more details. https://unifyjs.org */ import tools from '../../unify/tools.js'; import unify from '../../unify/unify.js'; //import unParsedObjects from '../unparsed.js' export default class processManagerAdd{ createPath( sourcePath, random = false ) { var currentPath = "../cache/platforms/" + document.config.os + "/" + document.config.device + "/" + document.config.tint + "/" + sourcePath; if( random ) { currentPath += "?disableCache=" + Math.random(); } return currentPath; } async createObject( objectData ) { if( document.mode == "development" ) { var currentPath = "../" + this.createPath( objectData.__sourcePath, true ); console.log("loading???", currentPath); var newImport = await import( currentPath ); var object = new newImport.default(); } else { var currentPath = this.createPath( objectData.__sourcePath ); //var object = new unParsedObjects[currentPath](); } return object; } configureObject( object, applicationPath, objectData ) { var core = document.cores[0]; var propertyName = applicationPath.shift(); var parent = core.getObjectByPath( applicationPath ); unify.extend( object ); object.serialize( objectData ); object.propertyName = propertyName; object.dynamic = true; object.parent = parent; parent[ propertyName ] = object; } logObject( message ) { var className = tools.getClassNameByObject( message.data ); var type = message.type; console.log("--------------------- recieved message: " + className + " : "+ type +"---------------------"); } parseObject( object ) { var core = document.cores[0]; core.executeMethods = true; core.parse( object ); object.show(); } setObjectID( object ) { if( !object.id ) { console.log("debug", this); object.id = object.getChildren().length; } } async process( message ) { var objectData = tools.getFirstChild( message.data ); this.logObject( message ); var object = await this.createObject( objectData ); var applicationPath = message.applicationPath; this.configureObject( object, applicationPath, objectData ); this.setObjectID( object ); this.parseObject( object ); } }