PageSourceSearch

https://aidark.net/classes.js

js aidark.net collected 2026-10-08 13:09:08 UTC 3,697 bytes, 110 lines download raw bytes

1class EditorFile
2{
3    /** @param {EditorFile} options */
4    constructor({name,content,hidden,language}){
5        this.name = name||'';
6        this.content = content||'';
7        this.hidden = hidden||false;
8        this.language = language||'';
9    }
10}
11class ChatSave {
12    /**
13        * @param {ChatSave} options 
14     */
15    constructor({ id, messages, editorFiles, suggestions, activeContact, timestamp }) {
16        this.id = id || new Date().getTime().toString();
17        this.messages = messages || [];
18        /** @type {EditorFile[]} */
19        this.editorFiles = editorFiles || [];
20        this.suggestions = suggestions || [];
21        /** @type {Contact} */
22        this.activeContact = activeContact || null;
23        this.timestamp = timestamp || new Date().toISOString();
24    }
25}
26
27/**
28 * Represents a variant of a message.
29 */
30class Variant {
31    /**
32     * @param {Variant} options
33     */
34    constructor(options) {
35        this.content = options.content || '';
36        this.contentFull = options.contentFull || '';
37        this.reasoning = options.reasoning || '';
38        this.finished = options.finished || false;
39        this.error = options.error || null;
40        /** @type {EditorFile[]} */
41        this.files = options.files || [];
42        this.model = options.model || '';
43        this.progress = options.progress || 0;
44        this.nosystem = options.nosystem || false;
45        this.apiUrl = options.apiUrl;
46        this.apiKey = options.apiKey;
47    }
48}
49
50class Message { 
51    /**
52     * Creates a new message.
53     * @param {Message} options - The options for the message.
54     */
55    constructor(options) {
56        this.id = Date.now();
57        this.role = options.role||'';
58        this.content = options.content||'';
59        this.contentFull = options.contentFull||'';
60        this.reasoning = options.reasoning||'';
61        this.error = options.error||null;
62        /** @type {EditorFile[]} */
63        this.files = options.files||[];
64        /** @type {Variant[]} */
65        this.variants = options.variants||[];
66        this.activeVariant = options.activeVariant||-1;
67        this.progress = options.progress || 0;
68        this.timestamp = new Date().toISOString();
69    }
70}
71class RoleContent {
72    /**
73     * @param {string} role 
74     * @param {string} content 
75     */
76    constructor(role, content) {
77        this.role = role;
78        this.content = content;
79    }
80}
81class Contact {
82    /**
83     * @param {Contact} options - The options for the contact.
84     */
85    constructor(options) {
86        this.name = options.name || 'Unknown';
87        this.suggestions = options.suggestions || [];
88        this.photo = options.photo || 'https://flowgpt.com/_next/image?url=' + encodeURIComponent('https://flow-prompt-covers.s3.us-west-1.amazonaws.com/icon/Lofi/i11.png') + '&w=256&q=75';
89        this.welcomeMessage = options.welcomeMessage || 'Hello! What kind of app would you like to create today?';
90        this.description = options.description || '';
91        this.autoselect = options.autoselect || false;
92        this.hidden = options.hidden || false;
93        this.keywords = options.keywords || [];
94        this.systemPrompt = options.systemPrompt || new RoleContent('system', '');
95        this.suggestions = options.suggestions || [];
96        this.category = options.category || '';
97        this.noPreview = options.noPreview || false;
98        this.isDefault = options.isDefault || false;
99        /** @type {Variant[]} */
100        this.variants = options.variants || [];
101        this.append = options.append || {};
102    }
103
104}
105
106if (typeof structuredClone !== 'function') {
107    structuredClone = function(obj) {
108      return JSON.parse(JSON.stringify(obj));
109    };
110  }

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.