First commit

This commit is contained in:
2025-12-25 11:16:59 +01:00
commit 0c5ca09a63
720 changed files with 329234 additions and 0 deletions

View File

@@ -0,0 +1,146 @@
/*
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 );
}
}

View File

@@ -0,0 +1,84 @@
/*
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 processManagerAdd from "./processManager.add.js";
import processManagerUpdate from "./processManager.update.js";
import processManagerPromise from "./processManager.promise.js";
import debugManager from "../debugManager.js";
export default class processManager{
add = new processManagerAdd();
update = new processManagerUpdate();
promise = new processManagerPromise();
debugger = new debugManager();
process( content ) {
var message = JSON.parse( content.data );
switch( message.type ) {
case "promise":
this.promise.process( message );
break;
case "clientUpdate":
this.update.process( message );
break;
case "addObject":
this.add.process( message );
break;
case "debug":
console.log( "debug", message,this.mode );
//if( this.mode == "debug" ) {
this.debugger.processDebugMessage( message );
//}
break;
case "logClient":
console.log( "----------------- Log client", this.application.selector, message );
break;
default:
}
}
}

View File

@@ -0,0 +1,44 @@
/*
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';
export default class processManagerPromise{
process( message ) {
var promise = this.promiseManager.getPromiseByID( message.id );
this.promiseManager.addMessage( message );
promise.resolve();
var object = message.data;
if( object && typeof object == "object" && !Array.isArray( object ) ) {
var className = tools.getClassNameByObject( object );
if( promise.object.debug | document.debugALL ) {
console.log( "%c recieved message: ", "background: #8bc34a;", this.port, message, className );
}
}
}
}

View File

@@ -0,0 +1,170 @@
/*
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 unify from '../../unify/unify.js';
export default class processManagerUpdate{
process( message ) {
var object = message.data;
var className = tools.getClassNameByObject( object );
console.log("--------------------- recieved message: " + className + " : "+ message.type +"---------------------");
switch( className ) {
case "collection":
this.parseCollection( message );
break;
default:
this.parseObject( message );
}
console.log("--------------------- /recieved message: " + className + " ----------------------");
}
filter( objects ) {
var objectCollection = new collection();
objectCollection.set( this.core.objects );
objectCollection.filter( "type", "renderCollection" );
objectCollection.filter( "custom", function( object ){
var collection = object.getCollection();
if( collection.applicationPathString == applicationPathString ) {
return true;
}
});
return objectCollection.rows;
}
fetchRenderCollections( renderCollections ) {
for( var c = 0; c < renderCollections.length; c++ ) {
var renderCollection = renderCollections[c];
console.log( "renderCollection", renderCollection );
renderCollection.clear();
renderCollection.fetch();
}
}
logRenderCollection( message, objectCollection ) {
console.log( "parse collection", message );
console.log( "search renderCollection", objectCollection );
}
parseCollection( message ) {
var applicationPath = message.applicationPath;
//var objectCollection = this.core.getObjectByPath( applicationPath );
var collectionName = applicationPath[ 0 ];
var applicationPathString = applicationPath.join("/");
var renderCollections = this.filter( this.core.objects );
this.fetchRenderCollections( renderCollections );
this.logRenderCollection( message, objectCollection );
}
getObject( message ) {
var entry = tools.parseObject( message.data );
var className = tools.getClassNameByEntry( entry );
var object = tools.getObjectByEntry( entry );
unify.extend( object );
return object;
}
callMethod( application, eventName, object ) {
application[ "server" + tools.CamelCase( eventName ) ]( object );
}
filterApplication( objects, className, id ) {
var objectCollection = new collection();
objectCollection.set( objects );
objectCollection.filter( "class", className );
objectCollection.filter( "id", id );
var application = objectCollection.getFirstRow();
return application;
}
parseObject( message ) {
var object = this.getObject( message );
// Can be optimized client->core
var className = object.getClassName();
var id = object.id;
var eventName = message.eventName;
this.filterApplication( this.core.objects, className, id )
application.serialize( object );
this.callMethod( application, eventName, object );
this.logRecieveMessage( message );
}
}