File size: 769 Bytes
ac5ecb6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import SafeteansLLM from './safeteans-llm';

class App {
 constructor({ el, data, methods, created }) {
    // Create the LLM instance
    this.llm = new SafeteansLLM();

    // Mount the root component
    this.render([{
      el: el,
      data: data,
      methods: methods,
      created: created,
    }]);
 }

 render({ el, data, methods, created }) {
    // Create the element
    const element = createElement(el);

    // Set the data and methods
    Object.keys(data).forEach(key => element.dataset[key] = data[key]);
    Object.keys(methods).forEach(key => element[key] = methods[key]);

    // Set the created callback
    if (created) created(element);

    // Append the element to the body
    document.body.appendChild(element);
 }
}

export default App;