graph-environment.js
/**
   Given a class name return a known class instance or create it 
   @param {string} className
   */
Given a class name return a known class instance or create it
Given a class name return a known class instance or create it
ensureClass(className) {
    var classInstance = this.getClass(className);
    if (!classInstance) {
      if ((typeof className == 'string') && className.match(/^[a-zA-Z0-9_]+$/)) {
        try { classInstance = eval(className); }
        catch(e) { 
          classInstance = class extends GraphObject{};
          Object.setPrototypeOf(classInstance.prototype, GraphObject.prototype);
          Object.setPrototypeOf(classInstance, GraphObject);
        }
        theGraphEnvironment.setClass(className, classInstance);
      } else {
        throw new Error(`ensureClass: invalid class name ${className}`);
      }
    }
    return (classInstance);
  }
ensureClass ( className ) { var classInstance = this . getClass ( className ) ; if ( ! classInstance ) { if ( ( typeof className == 'string' ) && className . match ( / ^[a-zA-Z0-9_]+$ / ) ) { try { classInstance = eval ( className ) ; } catch ( e ) { classInstance = class extends GraphObject { } ; Object . setPrototypeOf ( classInstance . prototype , GraphObject . prototype ) ; Object . setPrototypeOf ( classInstance , GraphObject ) ; } theGraphEnvironment . setClass ( className , classInstance ) ; } else { throw new Error ( ` ${ className } ` ) ; } } return ( classInstance ) ; }
Given a class name return a known class instance or create it
Given a class name return a known class instance or create it
// unknown class, define it // restrict the cache to this environment // window[className] = classInstance; //does the next step make sense given this?