From edb7ee9c836417013d600e315a11b78dc406469c Mon Sep 17 00:00:00 2001 From: alMukaafih Date: Tue, 3 Jun 2025 00:12:29 +0100 Subject: [PATCH] Update typings to @acode-app/types --- package-lock.json | 31 +++++-- package.json | 2 +- tsconfig.json | 17 +++- typings/acode.d.ts | 164 ------------------------------------- typings/editorFile.d.ts | 87 -------------------- typings/editorManager.d.ts | 50 ----------- typings/index.d.ts | 35 -------- typings/settings.d.ts | 26 ------ 8 files changed, 40 insertions(+), 372 deletions(-) delete mode 100644 typings/acode.d.ts delete mode 100644 typings/editorFile.d.ts delete mode 100644 typings/editorManager.d.ts delete mode 100644 typings/index.d.ts delete mode 100644 typings/settings.d.ts diff --git a/package-lock.json b/package-lock.json index f21ac09..524927d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "@types/ace": "^0.0.50", + "@acode-app/types": "^1.11.2", "html-tag-js": "^1.1.41" }, "devDependencies": { @@ -17,6 +17,16 @@ "jszip": "^3.10.1" } }, + "node_modules/@acode-app/types": { + "version": "1.11.2", + "resolved": "https://registry.npmjs.org/@acode-app/types/-/types-1.11.2.tgz", + "integrity": "sha512-/Ltw/AVkOmVBlp6zRnquQIpd6xbjjIxV0vwCNM7E6pcJcn5IZNcwVlQ2G1OKj2sPN4O9KO3krq09nY2KpyICpQ==", + "license": "MIT", + "dependencies": { + "@types/node": "^22.15.29", + "html-tag-js": "^1.8.1" + } + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.24.2", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.24.2.tgz", @@ -442,11 +452,14 @@ "node": ">=18" } }, - "node_modules/@types/ace": { - "version": "0.0.50", - "resolved": "https://registry.npmjs.org/@types/ace/-/ace-0.0.50.tgz", - "integrity": "sha512-kg6VGO7BX5tDnTK3Vhs4SZx7ILT8xG1i439GA/QSl5PQ4UKa7Jy1GW2dsRe0R3q8mH5/3LASGZ5fwaNuOAqutA==", - "license": "MIT" + "node_modules/@types/node": { + "version": "22.15.29", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.29.tgz", + "integrity": "sha512-LNdjOkUDlU1RZb8e1kOIUpN1qQUlzGkEtbVNo53vbrwDg5om6oduhm4SiUaPW5ASTXhAiP0jInWG8Qx9fVlOeQ==", + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } }, "node_modules/core-util-is": { "version": "1.0.3", @@ -600,6 +613,12 @@ "safe-buffer": "~5.1.0" } }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "license": "MIT" + }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", diff --git a/package.json b/package.json index 83406de..d91c9f2 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "author": "Acode Foundation", "license": "MIT", "dependencies": { - "@types/ace": "^0.0.50", + "@acode-app/types": "^1.11.2", "html-tag-js": "^1.1.41" }, "devDependencies": { diff --git a/tsconfig.json b/tsconfig.json index fabac5d..ef6c021 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,18 @@ "forceConsistentCasingInFileNames": true, "strict": true, "skipLibCheck": true, - "outDir": "dist" + "outDir": "dist", + "types": [ + "@acode-app/types" + ], + "paths": { + "acode/*": [ + "./node_modules/@acode-app/types/src/*" + ] + } }, - "exclude": ["./dist/**/*", "./postcss.config.js"] -} + "exclude": [ + "./dist/**/*", + "./postcss.config.js" + ] +} \ No newline at end of file diff --git a/typings/acode.d.ts b/typings/acode.d.ts deleted file mode 100644 index d765b69..0000000 --- a/typings/acode.d.ts +++ /dev/null @@ -1,164 +0,0 @@ -type Strings = string[]; -declare var acode: Acode; - - -interface WCPage extends HTMLElement { - on(event: 'hide' | 'show', cb: (this: WCPage) => void): void; - off(event: 'hide' | 'show', cb: (this: WCPage) => void): void; - - settitle(title: string): void; - - id: string; - - hide(): void; - show(): void; - - get body(): HTMLElement | null; - set body($el: HTMLElement | null); - - get innerHTML(): string; - set innerHTML(html: string); - - get textContent(): string | null; - set textContent(text: string); - - get lead(): HTMLElement; - set lead($el: HTMLElement); - - get header(): HTMLElement; - set header($el: HTMLElement); -} - -interface Input { - id: string; - required?: boolean; - type: string; - match?: RegExp; - value?: string; - placeholder?: string; - hints?: string; - name?: string; - disabled?: boolean; - readOnly?: boolean; - autofocus?: boolean; - hidden?: boolean; - onclick?: (event: Event) => void; - onchange?: (event: Event) => void; -} - - -interface Acode { - /** - * Define a module - * @param {string} name - * @param {Object|function} module - */ - define(name: string, module: any): void; - - require(module: string): any; - - exec(key: string, val: any): boolean | undefined; - - get exitAppMessage(): string | undefined; - - setLoadingMessage(message: string): void; - - setPluginInit( - id: string, - initFunction: (baseUrl: string, $page: WCPage, options?: any) => Promise, - settings?: any - ): void; - - getPluginSettings(id: string): any; - - setPluginUnmount(id: string, unmountFunction: () => void): void; - - /** - * @param {string} id plugin id - * @param {string} baseUrl local plugin url - * @param {WCPage} $page - */ - initPlugin(id: string, baseUrl: string, $page: WCPage, options?: any): Promise; - - unmountPlugin(id: string): void; - - registerFormatter(id: string, extensions: string[], format: () => Promise): void; - - unregisterFormatter(id: string): void; - - format(selectIfNull?: boolean): Promise; - - fsOperation(file: string): any; - - newEditorFile(filename: string, options?: any): void; - - // readonly formatters(): { id: string; name: string; exts: string[] }[]; - - /** - * @param {string[]} extensions - * @returns {Array<[id: string, name: string]>} options - */ - getFormatterFor(extensions: string[]): [id: string, name: string][]; - - alert(title: string, message: string, onhide: ()=>void): void; - - loader(title: string, message: string, cancel: { timeout: number,callback: ()=>void }): void; - - joinUrl(...args: string[]): string; - - addIcon(className: string, src: string): void; - - prompt( - message: string, - defaultValue: string, - type: 'textarea' | 'text' | 'number' | 'tel' | 'search' | 'email' | 'url', - options?: { - match: RegExp, - required: boolean, - placeholder: string, - test: (value: string)=>boolean - } - ): Promise; - - confirm(title: string, message: string): Promise; - - select( - title: string, - options: [string, string, string, boolean][] | string, - opts?: { - onCancel?: () => void; - onHide?: () => void; - hideOnSelect?: boolean; - textTransform?: boolean; - default?: string; - } | boolean - ): Promise; - - multiPrompt(title: string, inputs: Array, help: string): Promise; - - fileBrowser(mode: 'file' | 'folder' | 'both', info: string, doesOpenLast: boolean): Promise< - | { - name: string; - type: 'file'; - url: string; - } - | { - list: { - icon: string; - isDirectory: boolean; - isFile: boolean; - mime: string; - name: string; - type: 'file' | 'folder'; - uri: string; - url: string; - }[]; - scroll: number; - name: string; - type: 'folder'; - url: string; - } - >; - - toInternalUrl(url: string): Promise; -} diff --git a/typings/editorFile.d.ts b/typings/editorFile.d.ts deleted file mode 100644 index 97792fa..0000000 --- a/typings/editorFile.d.ts +++ /dev/null @@ -1,87 +0,0 @@ -//declare var EditorFile: EditorFile; - -declare class EditorFile { - focusedBefore: boolean; - focused: boolean; - loaded: boolean; - loading: boolean; - deletedFile: boolean; - session: AceAjax.IEditSession | null; - encoding: string; - readOnly: boolean; - markChanged: boolean; - - constructor(filename?: string, options?: FileOptions); - - get id(): string; - set id(value: string); - - get filename(): string; - set filename(value: string); - - get location(): string | null; - set location(value: string); - - get uri(): string; - set uri(value: string); - - get eol(): 'windows' | 'unix'; - - set eol(value: 'windows' | 'unix'); - - get editable(): boolean; - set editable(value: boolean); - - get isUnsaved(): boolean; - set isUnsaved(value: boolean); - - get name(): string; - - get cacheFile(): string; - - get icon(): string; - - get tab(): HTMLElement; - - get SAFMode(): SAFMode; - - writeToCache(): Promise; - - isChanged(): Promise; - - canRun(): Promise; - - readCanRun(): Promise; - - writeCanRun(cb: () => boolean | Promise): Promise; - - remove(force?: boolean): Promise; - - save(): Promise; - - saveAs(): Promise; - - setMode(mode?: string): void; - - makeActive(): void; - - removeActive(): void; - - openWith(): void; - - editWith(): void; - - share(): void; - - runAction(): void; - - run(): void; - - runFile(): void; - - render(): void; - - on(event: FileEvent, callback: () => void): void; - - off(event: FileEvent, callback: () => void): void; - } diff --git a/typings/editorManager.d.ts b/typings/editorManager.d.ts deleted file mode 100644 index e7bf639..0000000 --- a/typings/editorManager.d.ts +++ /dev/null @@ -1,50 +0,0 @@ -declare var editorManager: EditorManager; - -type FileEvent = "switch-file" | "rename-file" | "save-file" | "file-loaded" | "file-content-changed" | "add-folder" | "remove-folder" | "new-file" | "init-open-file-list" | "update"; - -interface EditorManager { - editor: AceAjax.Editor | null; - getFile(checkFor: string | number, type: "id" | "name" | "uri"): EditorFile; - addFile(file: EditorFile): void; - switchFile(id: string): void; - activeFile: EditorFile; - hasUnsavedFiles(): number | null; - files: Array; - container: HTMLElement; - isScrolling: boolean; - on(event: FileEvent, callback: () => void): void; - off(event: FileEvent, callback: () => void): void; - emit(event: FileEvent, ...args: any[]): any; -} - -type SAFMode = 'single' | 'tree' | null; - -interface CursorPosition { - row: number; - column: number; -} - -interface FoldOptions { - start: CursorPosition; - end: CursorPosition; - placeholder: string; - ranges: FoldOptions[]; -} - -type FileAction = 'VIEW' | 'EDIT' | 'SEND' | 'RUN'; - -interface FileOptions { - isUnsaved?: boolean; - render?: boolean; - id?: string; - uri?: string; - text?: string; - editable?: boolean; - deletedFile?: boolean; - SAFMode?: SAFMode; - encoding?: string; - cursorPos?: CursorPosition; - scrollLeft?: number; - scrollTop?: number; - folds?: FoldOptions[]; -} diff --git a/typings/index.d.ts b/typings/index.d.ts deleted file mode 100644 index a0e3f3f..0000000 --- a/typings/index.d.ts +++ /dev/null @@ -1,35 +0,0 @@ -/// -/// -/// -/// - -declare var ace: AceAjax.Ace; - -declare global { - interface Window { - toast(message: string, duration: number): void; - ASSETS_DIRECTORY: string; - CACHE_STORAGE: string; - DATA_STORAGE: string; - PLUGIN_DIR: string; - DOES_SUPPORT_THEME: boolean; - IS_FREE_VERSION: boolean; - KEYBINDING_FILE: string; - ANDROID_SDK_INT: number; - addedFolder: AddedFolder; - } -} - -interface AddedFolder { - url: string; - remove: () => void; - $node: HTMLElement; - reload: () => void; - listState: Map; - reloadOnResume: boolean; - saveState: boolean; - title: string; - id: string; - } - -export {}; diff --git a/typings/settings.d.ts b/typings/settings.d.ts deleted file mode 100644 index d0608bb..0000000 --- a/typings/settings.d.ts +++ /dev/null @@ -1,26 +0,0 @@ - -declare type fileBrowserSettings = { - showHiddenFiles: string; - sortByName: string; -}; - -declare type searchAndFindSettings = { - wrap: boolean; - caseSensitive: boolean; - regExp: boolean; -}; - -declare class Settings { - update( - settings?: { [key: string]: any } | boolean, - showToast?: boolean, - saveFile?: boolean - ): Promise; - reset(setting?: string): Promise; - on(event: `update:${string}` | `update:${string}:after` | 'reset', callback: () => void): void; - off(event: 'update' | 'reset', callback: () => void): void; - get(key: string): any; - - applyAnimationSetting(): Promise; - applyLangSetting(): Promise; -}