openchad-react 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,246 @@
1
+ import * as React$1 from 'react';
2
+ import React__default, { Dispatch, SetStateAction } from 'react';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import { LucideIcon } from 'lucide-react';
5
+
6
+ /**
7
+ * The setter function type - identical to React's useState setter
8
+ */
9
+ type GlobalSetter<T> = Dispatch<SetStateAction<T>>;
10
+ /**
11
+ * The return type of useGlobal - a tuple like useState
12
+ * [data, setData]
13
+ */
14
+ type UseGlobalReturn<T> = readonly [T, GlobalSetter<T>];
15
+
16
+ /**
17
+ * Folder utilities returned as the third element
18
+ */
19
+ interface FolderUtils {
20
+ /** Create the folder if it doesn't exist */
21
+ create: (folder: string) => Promise<void>;
22
+ /** Check if a folder exists */
23
+ isExists: (folder: string) => Promise<boolean>;
24
+ /** Get only subfolders (items ending with '/') */
25
+ folders: string[];
26
+ /** Get only files (items not ending with '/') */
27
+ files: string[];
28
+ path: string;
29
+ }
30
+ /**
31
+ * The return type of useFolder - a tuple
32
+ * [contents, exists, { refresh, create }]
33
+ */
34
+ type UseFolderReturn = readonly [string[], boolean, FolderUtils];
35
+
36
+ /**
37
+ * The setter function type - identical to React's useState setter
38
+ */
39
+ type FileSetter = Dispatch<SetStateAction<string>>;
40
+ /**
41
+ * File utilities returned as the third element
42
+ */
43
+ interface FileUtils {
44
+ /** Force refresh the file content from disk */
45
+ refresh: () => Promise<void>;
46
+ /** Get file modification time */
47
+ getMtime: () => Promise<number>;
48
+ }
49
+ /**
50
+ * The return type of useFile - a tuple like useState
51
+ * [content, setContent, exists, { refresh, getMtime }]
52
+ */
53
+ type UseFileReturn = readonly [string, FileSetter, boolean, FileUtils];
54
+
55
+ /**
56
+ * The setter function type - identical to React's useState setter
57
+ */
58
+ type DatabaseSetter<T> = Dispatch<SetStateAction<T>>;
59
+ /**
60
+ * Query utilities returned as the third element
61
+ */
62
+ interface DatabaseUtils {
63
+ query: (sql: string) => Promise<unknown>;
64
+ ready: boolean;
65
+ }
66
+ /**
67
+ * The return type of useDatabase - a tuple like useState
68
+ * [data, setData, { query }]
69
+ */
70
+ type UseDatabaseReturn<T> = readonly [T, DatabaseSetter<T>, DatabaseUtils];
71
+
72
+ type LayoutType = "horizontal" | "vertical" | "grid2x2" | "triple" | "triple-left" | "triple-right" | "triple-top" | "triple-bottom" | "single";
73
+
74
+ interface ITab {
75
+ iconOverride: string | null;
76
+ defaultIcon: React.ComponentType<{
77
+ className: string;
78
+ }>;
79
+ IconOverrideComponent: ({ className }: {
80
+ className: string;
81
+ }) => React.ReactNode;
82
+ icon: ({ className }: {
83
+ className: string;
84
+ }) => React.ReactNode;
85
+ title: string | null;
86
+ layout: string;
87
+ hasChildren: boolean;
88
+ children: string[];
89
+ group: string | null;
90
+ size: number[];
91
+ childrenProps: Record<string, {
92
+ title: string | null;
93
+ appname: string;
94
+ icon: string;
95
+ data: any;
96
+ }>;
97
+ }
98
+
99
+ interface SettingItem {
100
+ key: string;
101
+ value: any;
102
+ type: "string" | "int" | "float" | "boolean" | "array";
103
+ source: string;
104
+ section: string;
105
+ default_value: any;
106
+ updated_at: string;
107
+ }
108
+
109
+ interface Model {
110
+ id?: string | null;
111
+ name?: string | null;
112
+ backend?: string;
113
+ modelType?: string[];
114
+ modelPath?: string;
115
+ mmproj?: string | null;
116
+ fileName?: string | null;
117
+ apiBase?: string | null;
118
+ isLoaded?: boolean;
119
+ isLocal?: boolean;
120
+ lastError?: string | null;
121
+ }
122
+ interface AppInfo {
123
+ appname: string;
124
+ useWorkspace: () => {
125
+ workspace: string;
126
+ setWorkspace: (workspace: string) => void;
127
+ };
128
+ tabId: string;
129
+ appId: string;
130
+ useActiveTabId: () => string;
131
+ useTitle: () => string | null;
132
+ setTitle: (title: string) => void;
133
+ settings: Record<string, SettingItem>;
134
+ useNotchVisible: () => boolean;
135
+ useTheme: () => {
136
+ theme: string;
137
+ layout: string;
138
+ };
139
+ useTab: () => ITab;
140
+ addTab: (tabs: {
141
+ app: string;
142
+ data?: Record<string, any>;
143
+ }[] | {
144
+ app: string;
145
+ data?: Record<string, any>;
146
+ }, layout?: string) => string[];
147
+ closeTab: () => void;
148
+ detachTab: () => void;
149
+ useTool: () => (tool: string, parameters: Record<string, any>) => Promise<any>;
150
+ useTabDatabase: <T>(tb: string, options?: {
151
+ initialValue?: T | undefined;
152
+ }) => UseDatabaseReturn<T>;
153
+ useModel: () => UseDatabaseReturn<Model>;
154
+ getAvailableModels: () => Promise<Model[]>;
155
+ useGlobal: <T>(name: string, options?: {
156
+ initialValue?: T;
157
+ }) => UseGlobalReturn<T>;
158
+ useFile: (filename: string, options?: {
159
+ initialValue?: string;
160
+ baseDir?: string;
161
+ width?: number;
162
+ height?: number;
163
+ quality?: number;
164
+ bitrate?: string;
165
+ resolution?: string;
166
+ fps?: number;
167
+ thumbnail?: boolean;
168
+ thumb_time?: string;
169
+ format?: string;
170
+ download?: boolean;
171
+ }) => UseFileReturn;
172
+ useFolder: (path: string, options?: {
173
+ baseDir?: string;
174
+ }) => UseFolderReturn;
175
+ pyInvoke: <T = any>(label: string, data?: Record<string, unknown> | ArrayBufferLike | Blob | ArrayBufferView, timeout?: number) => Promise<T | void | AsyncGenerator<T, void, unknown>>;
176
+ }
177
+
178
+ interface Tab {
179
+ appname: string;
180
+ data: any;
181
+ App: React__default.ComponentType<AppInfo>;
182
+ }
183
+ interface DefaultTab {
184
+ layout: LayoutType;
185
+ icon: string;
186
+ tabs: Tab[];
187
+ }
188
+ interface AppsProps {
189
+ defaultTab: DefaultTab;
190
+ appRegistry?: Record<string, React__default.ComponentType<AppInfo>>;
191
+ iconRegistry?: Record<string, LucideIcon>;
192
+ size?: number[];
193
+ }
194
+ declare function Container({ Apps }: {
195
+ Apps: AppsProps;
196
+ }): react_jsx_runtime.JSX.Element;
197
+
198
+ declare function usePython(): {
199
+ pyInvoke: <T = any>(label: string, data?: Record<string, unknown> | ArrayBufferLike | Blob | ArrayBufferView, timeout?: number) => Promise<T | void | AsyncGenerator<T, void, unknown>>;
200
+ isStreamReady: boolean;
201
+ };
202
+
203
+ declare function useElementSize<T extends HTMLElement>(): readonly [React$1.RefObject<T | null>, {
204
+ width: number;
205
+ height: number;
206
+ overflowX: boolean;
207
+ overflowY: boolean;
208
+ aspectRatio: string;
209
+ }];
210
+
211
+ interface MessageState {
212
+ title: string | null;
213
+ activeId: string;
214
+ errorMsg: string;
215
+ isStreaming: boolean;
216
+ initialized: boolean;
217
+ context: string;
218
+ }
219
+
220
+ declare function generateIdFromString(input: string): string;
221
+ declare const useTool: <T>() => (tool: string, parameters: Record<string, any>) => Promise<void | T | AsyncGenerator<T, void, unknown>>;
222
+ declare const useDatabase: <T>(tb: string, options?: {
223
+ initialValue?: T;
224
+ }) => UseDatabaseReturn<T>;
225
+ declare const useFile: (filename: string, options?: {
226
+ initialValue?: string;
227
+ baseDir?: string;
228
+ width?: number;
229
+ height?: number;
230
+ quality?: number;
231
+ bitrate?: string;
232
+ resolution?: string;
233
+ fps?: number;
234
+ thumbnail?: boolean;
235
+ thumb_time?: string;
236
+ format?: string;
237
+ download?: boolean;
238
+ }) => UseFileReturn;
239
+ declare const useFolder: (path: string, options?: {
240
+ baseDir?: string;
241
+ }) => UseFolderReturn;
242
+ declare const useGlobal: <T = Record<string, unknown>>(tb: string, options?: {
243
+ initialValue?: T;
244
+ }) => UseGlobalReturn<T>;
245
+
246
+ export { type AppInfo, type AppsProps, Container, type MessageState, generateIdFromString, useDatabase, useElementSize, useFile, useFolder, useGlobal, usePython, useTool };
@@ -0,0 +1,246 @@
1
+ import * as React$1 from 'react';
2
+ import React__default, { Dispatch, SetStateAction } from 'react';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import { LucideIcon } from 'lucide-react';
5
+
6
+ /**
7
+ * The setter function type - identical to React's useState setter
8
+ */
9
+ type GlobalSetter<T> = Dispatch<SetStateAction<T>>;
10
+ /**
11
+ * The return type of useGlobal - a tuple like useState
12
+ * [data, setData]
13
+ */
14
+ type UseGlobalReturn<T> = readonly [T, GlobalSetter<T>];
15
+
16
+ /**
17
+ * Folder utilities returned as the third element
18
+ */
19
+ interface FolderUtils {
20
+ /** Create the folder if it doesn't exist */
21
+ create: (folder: string) => Promise<void>;
22
+ /** Check if a folder exists */
23
+ isExists: (folder: string) => Promise<boolean>;
24
+ /** Get only subfolders (items ending with '/') */
25
+ folders: string[];
26
+ /** Get only files (items not ending with '/') */
27
+ files: string[];
28
+ path: string;
29
+ }
30
+ /**
31
+ * The return type of useFolder - a tuple
32
+ * [contents, exists, { refresh, create }]
33
+ */
34
+ type UseFolderReturn = readonly [string[], boolean, FolderUtils];
35
+
36
+ /**
37
+ * The setter function type - identical to React's useState setter
38
+ */
39
+ type FileSetter = Dispatch<SetStateAction<string>>;
40
+ /**
41
+ * File utilities returned as the third element
42
+ */
43
+ interface FileUtils {
44
+ /** Force refresh the file content from disk */
45
+ refresh: () => Promise<void>;
46
+ /** Get file modification time */
47
+ getMtime: () => Promise<number>;
48
+ }
49
+ /**
50
+ * The return type of useFile - a tuple like useState
51
+ * [content, setContent, exists, { refresh, getMtime }]
52
+ */
53
+ type UseFileReturn = readonly [string, FileSetter, boolean, FileUtils];
54
+
55
+ /**
56
+ * The setter function type - identical to React's useState setter
57
+ */
58
+ type DatabaseSetter<T> = Dispatch<SetStateAction<T>>;
59
+ /**
60
+ * Query utilities returned as the third element
61
+ */
62
+ interface DatabaseUtils {
63
+ query: (sql: string) => Promise<unknown>;
64
+ ready: boolean;
65
+ }
66
+ /**
67
+ * The return type of useDatabase - a tuple like useState
68
+ * [data, setData, { query }]
69
+ */
70
+ type UseDatabaseReturn<T> = readonly [T, DatabaseSetter<T>, DatabaseUtils];
71
+
72
+ type LayoutType = "horizontal" | "vertical" | "grid2x2" | "triple" | "triple-left" | "triple-right" | "triple-top" | "triple-bottom" | "single";
73
+
74
+ interface ITab {
75
+ iconOverride: string | null;
76
+ defaultIcon: React.ComponentType<{
77
+ className: string;
78
+ }>;
79
+ IconOverrideComponent: ({ className }: {
80
+ className: string;
81
+ }) => React.ReactNode;
82
+ icon: ({ className }: {
83
+ className: string;
84
+ }) => React.ReactNode;
85
+ title: string | null;
86
+ layout: string;
87
+ hasChildren: boolean;
88
+ children: string[];
89
+ group: string | null;
90
+ size: number[];
91
+ childrenProps: Record<string, {
92
+ title: string | null;
93
+ appname: string;
94
+ icon: string;
95
+ data: any;
96
+ }>;
97
+ }
98
+
99
+ interface SettingItem {
100
+ key: string;
101
+ value: any;
102
+ type: "string" | "int" | "float" | "boolean" | "array";
103
+ source: string;
104
+ section: string;
105
+ default_value: any;
106
+ updated_at: string;
107
+ }
108
+
109
+ interface Model {
110
+ id?: string | null;
111
+ name?: string | null;
112
+ backend?: string;
113
+ modelType?: string[];
114
+ modelPath?: string;
115
+ mmproj?: string | null;
116
+ fileName?: string | null;
117
+ apiBase?: string | null;
118
+ isLoaded?: boolean;
119
+ isLocal?: boolean;
120
+ lastError?: string | null;
121
+ }
122
+ interface AppInfo {
123
+ appname: string;
124
+ useWorkspace: () => {
125
+ workspace: string;
126
+ setWorkspace: (workspace: string) => void;
127
+ };
128
+ tabId: string;
129
+ appId: string;
130
+ useActiveTabId: () => string;
131
+ useTitle: () => string | null;
132
+ setTitle: (title: string) => void;
133
+ settings: Record<string, SettingItem>;
134
+ useNotchVisible: () => boolean;
135
+ useTheme: () => {
136
+ theme: string;
137
+ layout: string;
138
+ };
139
+ useTab: () => ITab;
140
+ addTab: (tabs: {
141
+ app: string;
142
+ data?: Record<string, any>;
143
+ }[] | {
144
+ app: string;
145
+ data?: Record<string, any>;
146
+ }, layout?: string) => string[];
147
+ closeTab: () => void;
148
+ detachTab: () => void;
149
+ useTool: () => (tool: string, parameters: Record<string, any>) => Promise<any>;
150
+ useTabDatabase: <T>(tb: string, options?: {
151
+ initialValue?: T | undefined;
152
+ }) => UseDatabaseReturn<T>;
153
+ useModel: () => UseDatabaseReturn<Model>;
154
+ getAvailableModels: () => Promise<Model[]>;
155
+ useGlobal: <T>(name: string, options?: {
156
+ initialValue?: T;
157
+ }) => UseGlobalReturn<T>;
158
+ useFile: (filename: string, options?: {
159
+ initialValue?: string;
160
+ baseDir?: string;
161
+ width?: number;
162
+ height?: number;
163
+ quality?: number;
164
+ bitrate?: string;
165
+ resolution?: string;
166
+ fps?: number;
167
+ thumbnail?: boolean;
168
+ thumb_time?: string;
169
+ format?: string;
170
+ download?: boolean;
171
+ }) => UseFileReturn;
172
+ useFolder: (path: string, options?: {
173
+ baseDir?: string;
174
+ }) => UseFolderReturn;
175
+ pyInvoke: <T = any>(label: string, data?: Record<string, unknown> | ArrayBufferLike | Blob | ArrayBufferView, timeout?: number) => Promise<T | void | AsyncGenerator<T, void, unknown>>;
176
+ }
177
+
178
+ interface Tab {
179
+ appname: string;
180
+ data: any;
181
+ App: React__default.ComponentType<AppInfo>;
182
+ }
183
+ interface DefaultTab {
184
+ layout: LayoutType;
185
+ icon: string;
186
+ tabs: Tab[];
187
+ }
188
+ interface AppsProps {
189
+ defaultTab: DefaultTab;
190
+ appRegistry?: Record<string, React__default.ComponentType<AppInfo>>;
191
+ iconRegistry?: Record<string, LucideIcon>;
192
+ size?: number[];
193
+ }
194
+ declare function Container({ Apps }: {
195
+ Apps: AppsProps;
196
+ }): react_jsx_runtime.JSX.Element;
197
+
198
+ declare function usePython(): {
199
+ pyInvoke: <T = any>(label: string, data?: Record<string, unknown> | ArrayBufferLike | Blob | ArrayBufferView, timeout?: number) => Promise<T | void | AsyncGenerator<T, void, unknown>>;
200
+ isStreamReady: boolean;
201
+ };
202
+
203
+ declare function useElementSize<T extends HTMLElement>(): readonly [React$1.RefObject<T | null>, {
204
+ width: number;
205
+ height: number;
206
+ overflowX: boolean;
207
+ overflowY: boolean;
208
+ aspectRatio: string;
209
+ }];
210
+
211
+ interface MessageState {
212
+ title: string | null;
213
+ activeId: string;
214
+ errorMsg: string;
215
+ isStreaming: boolean;
216
+ initialized: boolean;
217
+ context: string;
218
+ }
219
+
220
+ declare function generateIdFromString(input: string): string;
221
+ declare const useTool: <T>() => (tool: string, parameters: Record<string, any>) => Promise<void | T | AsyncGenerator<T, void, unknown>>;
222
+ declare const useDatabase: <T>(tb: string, options?: {
223
+ initialValue?: T;
224
+ }) => UseDatabaseReturn<T>;
225
+ declare const useFile: (filename: string, options?: {
226
+ initialValue?: string;
227
+ baseDir?: string;
228
+ width?: number;
229
+ height?: number;
230
+ quality?: number;
231
+ bitrate?: string;
232
+ resolution?: string;
233
+ fps?: number;
234
+ thumbnail?: boolean;
235
+ thumb_time?: string;
236
+ format?: string;
237
+ download?: boolean;
238
+ }) => UseFileReturn;
239
+ declare const useFolder: (path: string, options?: {
240
+ baseDir?: string;
241
+ }) => UseFolderReturn;
242
+ declare const useGlobal: <T = Record<string, unknown>>(tb: string, options?: {
243
+ initialValue?: T;
244
+ }) => UseGlobalReturn<T>;
245
+
246
+ export { type AppInfo, type AppsProps, Container, type MessageState, generateIdFromString, useDatabase, useElementSize, useFile, useFolder, useGlobal, usePython, useTool };