/* 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 ESA Software Community License - Strong Copyleft LICENSE, as published by the ESA. See the ESA Software Community License - Strong Copyleft LICENSE, for more details. https://unifyjs.org */ import fs from 'fs'; import path from 'path'; import tools from '../unify/tools.js'; import Console from '../server/console.js'; import simplePath from '../unify/simplePath.js'; var __dirname = path.resolve(); global.path = path; export default class moduleLoader{ parseNewFiles = true; files = new Array(); constructor( os, device, tint ) { this.createPlatformCachePath(); this.setDirectory( os, device, tint ); } createPlatformCachePath() { this.pathToPlatforms = new simplePath(); this.pathToPlatforms.beginWithSlash = false; this.pathToPlatforms.endWithSlash = true; this.pathToPlatforms.add( "framework" ) this.pathToPlatforms.add( "cache" ) this.pathToPlatforms.add( "platforms" ) } setDirectory( os, device, tint ) { if( tint ) { this.absolutePath = this.pathToPlatforms.clone(); this.absolutePath.add( os ); this.absolutePath.add( device ); this.absolutePath.add( tint ); } else { this.absolutePath = this.pathToPlatforms.clone(); this.absolutePath.add( global.os ); this.absolutePath.add( global.device ); this.absolutePath.add( global.tint ); } this.absolutePath.endWithSlash = true; this.absolutePath.absolute = true; } async loadModulesFromFiles( directory, core, client ) { this.client = client; this.core = core; var path = this.absolutePath.clone(); path.add( directory ); var files = await fs.readdirSync( path.resolve() + "/" ); for(var c = 0; c