mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-04 08:30:39 +00:00
Fix more puter.js typescript types (#2181)
* Fix networking types * Fix os types * Fix UI types * Remove constructor in util.d.ts * Fix worker types * Fix puter.d.ts * Fix apps types * Change socket and tlssocket back to psocket and ptlssocket
This commit is contained in:
committed by
GitHub
parent
85c548d0d3
commit
dc827f90c4
Vendored
+8
-13
@@ -1,6 +1,6 @@
|
||||
import type { PaginationOptions, RequestCallbacks } from '../shared.d.ts';
|
||||
|
||||
export interface AppRecord {
|
||||
export interface App {
|
||||
uid: string;
|
||||
name: string;
|
||||
index_url: string;
|
||||
@@ -21,7 +21,7 @@ export interface AppListOptions extends PaginationOptions {
|
||||
icon_size?: null | 16 | 32 | 64 | 128 | 256 | 512;
|
||||
}
|
||||
|
||||
export interface CreateAppOptions extends RequestCallbacks<AppRecord> {
|
||||
export interface CreateAppOptions extends RequestCallbacks<App> {
|
||||
name: string;
|
||||
indexURL: string;
|
||||
title?: string;
|
||||
@@ -34,7 +34,7 @@ export interface CreateAppOptions extends RequestCallbacks<AppRecord> {
|
||||
dedupeName?: boolean;
|
||||
}
|
||||
|
||||
export interface UpdateAppAttributes extends RequestCallbacks<AppRecord> {
|
||||
export interface UpdateAppAttributes extends RequestCallbacks<App> {
|
||||
name?: string;
|
||||
indexURL?: string;
|
||||
title?: string;
|
||||
@@ -47,16 +47,11 @@ export interface UpdateAppAttributes extends RequestCallbacks<AppRecord> {
|
||||
}
|
||||
|
||||
export class Apps {
|
||||
constructor (context: { authToken?: string; APIOrigin: string; appID?: string });
|
||||
|
||||
setAuthToken (authToken: string): void;
|
||||
setAPIOrigin (APIOrigin: string): void;
|
||||
|
||||
list (options?: AppListOptions): Promise<AppRecord[]>;
|
||||
create (name: string, indexURL: string, title?: string): Promise<AppRecord>;
|
||||
create (options: CreateAppOptions): Promise<AppRecord>;
|
||||
update (name: string, attributes: UpdateAppAttributes): Promise<AppRecord>;
|
||||
get (name: string, options?: AppListOptions): Promise<AppRecord>;
|
||||
list (options?: AppListOptions): Promise<App[]>;
|
||||
create (name: string, indexURL: string, title?: string): Promise<App>;
|
||||
create (options: CreateAppOptions): Promise<App>;
|
||||
update (name: string, attributes: UpdateAppAttributes): Promise<App>;
|
||||
get (name: string, options?: AppListOptions): Promise<App>;
|
||||
delete (name: string): Promise<{ success?: boolean }>;
|
||||
getDeveloperProfile (options?: RequestCallbacks<Record<string, unknown>>): Promise<Record<string, unknown>>;
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ export class PSocket {
|
||||
close (): void;
|
||||
on (event: 'open', handler: () => void): void;
|
||||
on (event: 'data', handler: (buffer: Uint8Array) => void): void;
|
||||
on (event: 'error', handler: (reason: unknown) => void): void;
|
||||
on (event: 'error', handler: (reason: string) => void): void;
|
||||
on (event: 'close', handler: (hadError: boolean) => void): void;
|
||||
addListener (event: SocketEvent, handler: (...args: unknown[]) => void): void;
|
||||
}
|
||||
|
||||
Vendored
+2
-7
@@ -1,12 +1,7 @@
|
||||
import type { RequestCallbacks } from '../shared.d.ts';
|
||||
import type { AuthUser } from './auth.d.ts';
|
||||
import type { User } from './auth.d.ts';
|
||||
|
||||
export class OS {
|
||||
constructor (context: { authToken?: string; APIOrigin: string; appID?: string });
|
||||
|
||||
setAuthToken (authToken: string): void;
|
||||
setAPIOrigin (APIOrigin: string): void;
|
||||
|
||||
user (options?: RequestCallbacks<AuthUser> & { query?: Record<string, string> }): Promise<AuthUser>;
|
||||
user (options?: RequestCallbacks<User> & { query?: Record<string, string> }): Promise<User>;
|
||||
version (options?: RequestCallbacks<Record<string, unknown>>): Promise<Record<string, unknown>>;
|
||||
}
|
||||
|
||||
Vendored
+10
-7
@@ -1,4 +1,3 @@
|
||||
import type { RequestCallbacks } from '../shared.d.ts';
|
||||
import type { FSItem } from './fs-item.d.ts';
|
||||
|
||||
export interface AlertButton {
|
||||
@@ -36,8 +35,12 @@ export interface WindowOptions {
|
||||
|
||||
export interface LaunchAppOptions {
|
||||
name?: string;
|
||||
app_name?: string;
|
||||
args?: Record<string, unknown>;
|
||||
appInstanceID?: string;
|
||||
file_paths?: string[];
|
||||
items?: FSItem[];
|
||||
pseudonym?: string;
|
||||
callback?: (connection: AppConnection) => void;
|
||||
}
|
||||
|
||||
export interface ThemeData {
|
||||
@@ -90,17 +93,17 @@ export class AppConnection {
|
||||
}
|
||||
|
||||
export class UI {
|
||||
constructor (context: Record<string, unknown>, parameters: { appInstanceID?: string; parentInstanceID?: string });
|
||||
|
||||
alert (message?: string, buttons?: AlertButton[]): Promise<string>;
|
||||
prompt (message?: string, defaultValue?: string): Promise<string | null>;
|
||||
authenticateWithPuter (): Promise<unknown>;
|
||||
prompt (message?: string, placeholder?: string): Promise<string | null>;
|
||||
authenticateWithPuter (): Promise<void>;
|
||||
contextMenu (options: ContextMenuOptions): void;
|
||||
createWindow (options?: WindowOptions): void;
|
||||
exit (statusCode?: number): void;
|
||||
getLanguage (): Promise<string>;
|
||||
hideSpinner (): void;
|
||||
hideWindow (): void;
|
||||
showSpinner (): void;
|
||||
showWindow (): void;
|
||||
showColorPicker (defaultColor?: string | Record<string, unknown>): Promise<string>;
|
||||
showDirectoryPicker (options?: DirectoryPickerOptions): Promise<FSItem | FSItem[]>;
|
||||
showFontPicker (defaultFont?: string | Record<string, unknown>): Promise<{ fontFamily: string }>;
|
||||
@@ -127,7 +130,7 @@ export class UI {
|
||||
on (eventName: 'localeChanged', handler: (data: { language: string }) => void): void;
|
||||
on (eventName: 'themeChanged', handler: (data: ThemeData) => void): void;
|
||||
parentApp (): AppConnection | null;
|
||||
launchApp (appName?: string, args?: Record<string, unknown>): Promise<AppConnection>;
|
||||
launchApp (appName?: string, args?: Record<string, unknown>, callback?: (connection: AppConnection) => void): Promise<AppConnection>;
|
||||
launchApp (options: LaunchAppOptions): Promise<AppConnection>;
|
||||
|
||||
getEntriesFromDataTransferItems (dataTransferItems: DataTransferItemList, options?: { raw?: boolean }): Promise<Array<File | FileSystemEntry>>;
|
||||
|
||||
Vendored
-1
@@ -7,6 +7,5 @@ export class UtilRPC {
|
||||
}
|
||||
|
||||
export default class Util {
|
||||
constructor ();
|
||||
rpc: UtilRPC;
|
||||
}
|
||||
|
||||
-4
@@ -4,19 +4,15 @@ export interface WorkerInfo {
|
||||
file_path?: string;
|
||||
file_uid?: string;
|
||||
created_at?: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface WorkerDeployment {
|
||||
success: boolean;
|
||||
url: string;
|
||||
errors?: unknown[];
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export class WorkersHandler {
|
||||
constructor (authToken?: string);
|
||||
|
||||
create (workerName: string, filePath: string, appName?: string): Promise<WorkerDeployment>;
|
||||
delete (workerName: string): Promise<boolean>;
|
||||
exec (request: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
||||
|
||||
Vendored
+1
-5
@@ -15,8 +15,6 @@ import type Util from './modules/util.d.ts';
|
||||
import type { WorkersHandler } from './modules/workers.d.ts';
|
||||
import type { APICallLogger, APILoggingConfig, PuterEnvironment, ToolSchema } from './shared.d.ts';
|
||||
|
||||
export interface NetAPI extends Networking {}
|
||||
|
||||
export interface PuterArgs {
|
||||
[key: string]: unknown;
|
||||
}
|
||||
@@ -65,13 +63,11 @@ export class Puter {
|
||||
[key: string]: unknown;
|
||||
};
|
||||
|
||||
net: NetAPI;
|
||||
net: Networking;
|
||||
workers: WorkersHandler;
|
||||
|
||||
static FSItem: typeof FSItem;
|
||||
|
||||
constructor();
|
||||
|
||||
setAuthToken(authToken: string): void;
|
||||
resetAuthToken(): void;
|
||||
setAPIOrigin(APIOrigin: string): void;
|
||||
|
||||
Reference in New Issue
Block a user