diff --git a/ts/.gitignore b/ts/.gitignore deleted file mode 100644 index 379fd79..0000000 --- a/ts/.gitignore +++ /dev/null @@ -1,228 +0,0 @@ -# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore - -# Logs - -logs -_.log -npm-debug.log_ -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Caches - -.cache - -# Diagnostic reports (https://nodejs.org/api/report.html) - -report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json - -# Runtime data - -pids -_.pid -_.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover - -lib-cov - -# Coverage directory used by tools like istanbul - -coverage -*.lcov - -# nyc test coverage - -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) - -.grunt - -# Bower dependency directory (https://bower.io/) - -bower_components - -# node-waf configuration - -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) - -build/Release - -# Dependency directories - -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) - -web_modules/ - -# TypeScript cache - -*.tsbuildinfo - -# Optional npm cache directory - -.npm - -# Optional eslint cache - -.eslintcache - -# Optional stylelint cache - -.stylelintcache - -# Microbundle cache - -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history - -.node_repl_history - -# Output of 'npm pack' - -*.tgz - -# Yarn Integrity file - -.yarn-integrity - -# dotenv environment variable files - -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) - -.parcel-cache - -# Next.js build output - -.next -out - -# Nuxt.js build / generate output - -.nuxt -dist - -# Gatsby files - -# Comment in the public line in if your project uses Gatsby and not Next.js - -# https://nextjs.org/blog/next-9-1#public-directory-support - -# public - -# vuepress build output - -.vuepress/dist - -# vuepress v2.x temp and cache directory - -.temp - -# Docusaurus cache and generated files - -.docusaurus - -# Serverless directories - -.serverless/ - -# FuseBox cache - -.fusebox/ - -# DynamoDB Local files - -.dynamodb/ - -# TernJS port file - -.tern-port - -# Stores VSCode versions used for testing VSCode extensions - -.vscode-test - -# yarn v2 - -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* - -# IntelliJ based IDEs -.idea - -# Finder (MacOS) folder config -.DS_Store - -# Node.js -node_modules/ -npm-debug.log -yarn-error.log -.parcel-cache - -# Logs -logs/ -*.log -*.log.* - -# Dependency directories -jspm_packages/ - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# dotenv environment variables file -.env - -# MacOS -.DS_Store - -# Windows -Thumbs.db -ehthumbs.db - -# IDEs and editors -.vscode/ -.idea/ -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? - -# Other -*.bak -*.tmp - -# Build files -build/ -dist/ \ No newline at end of file diff --git a/ts/.npmignore b/ts/.npmignore deleted file mode 100644 index b0952e2..0000000 --- a/ts/.npmignore +++ /dev/null @@ -1,25 +0,0 @@ -# Dependency directories -node_modules/ -.parcel-cache/ - -src/ -test/ - -# Optional npm cache directory -.npm/ - -# Optional REPL history -.node_repl_history - -# Output directories -dist/ -build/ - -# Logs -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# OS-specific files -.DS_Store -Thumbs.db \ No newline at end of file diff --git a/ts/build.ts b/ts/build.ts deleted file mode 100644 index 2335614..0000000 --- a/ts/build.ts +++ /dev/null @@ -1,141 +0,0 @@ -import dts from "bun-plugin-dts"; -import { writeFileSync, readFileSync, readdirSync, existsSync } from "fs"; -import { resolve, relative } from "path"; -import { execSync } from "child_process"; -import type { BuildConfig } from "bun"; -import { join, relative } from "path"; - -const baseDir = "./src"; - -generateIndexes(baseDir, [ - { dir: "types", isTypes: true }, - { dir: "classes" }, - { dir: "functions" }, - { dir: "interfaces", isTypes: true }, -]); - -// Get Git commit count -const count = parseInt(execSync("git rev-list --count HEAD").toString().trim(), 10); - -// Compute MAJOR.MINOR.PATCH -const MAJOR = Math.floor(count / 10000); -const MINOR = Math.floor((count / 100) % 100); -const PATCH = count % 100; -const version = `${MAJOR}.${MINOR}.${PATCH}`; - -// Update package.json -const pkgPath = "./package.json"; -const pkg = JSON.parse(readFileSync(pkgPath, "utf-8")); -pkg.version = version; -writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n"); - -const minify = true; -const formats: Array = ["cjs", "esm"]; - -for (const format of formats) { - Bun.build({ - entrypoints: ["./src/index.ts"], - outdir: `./dist/`, - minify: minify, - target: "browser", - format: format, - plugins: [ - dts({ - output: { - noBanner: true, - }, - }), - ], - splitting: true, - naming: { - entry: `[name].${format}.js`, - chunk: "[name]-[hash].js", - asset: "[name]-[hash][ext]", - }, - }).catch((err) => { - console.error(err); - process.exit(1); - }); -} - -type IndexConfig = { - dir: string; - isTypes?: boolean; - subDirs?: string[]; -}; - -function generateIndexes(baseDir: string, configs: IndexConfig[]) { - function walk(dir: string): string[] { - let results: string[] = []; - for (const file of readdirSync(dir, { withFileTypes: true })) { - const fullPath = join(dir, file.name); - if (file.isDirectory()) { - results = results.concat(walk(fullPath)); - } else { - results.push(fullPath); - } - } - return results; - } - - let baseExports: string[] = []; - - for (const { dir, isTypes = false, subDirs = [] } of configs) { - const absDir = join(baseDir, dir); - const files = walk(absDir); - const imports = files - .map((file: string) => { - if (file.endsWith("index.ts")) return; - if (file.endsWith(".ts")) { - let relPath = "./" + relative(absDir, file).replace(/\\/g, "/").replace(/\.ts$/, ""); - return `export ${isTypes ? "type " : ""}* from "${relPath}";`; - } - }) - .filter(Boolean) - .join("\n"); - - const indexFileName = `index.ts`; - writeFileSync( - join(absDir, indexFileName), - `/** - * Automatically generated by the bundler. DO NOT EDIT! - */\n -${imports}` - ); - - // Add export from this index to baseDir index - const relPathToBase = "./" + relative(baseDir, join(absDir, indexFileName)).replace(/\\/g, "/").replace(/\.ts$/, ""); - baseExports.push(`export ${isTypes ? "type " : ""}* from "${relPathToBase}";`); - - if (subDirs.length > 0) { - let exports: string[] = []; - subDirs.forEach((subDir) => { - const indexPath = join(baseDir, subDir, "index.ts"); - if (existsSync(indexPath)) { - const relPath = "./" + relative(absDir, indexPath).replace(/\\/g, "/").replace(/\.ts$/, ""); - exports.push(`export ${isTypes ? "type " : ""}* from "${relPath}";`); - } - }); - if (exports.length > 0) { - writeFileSync( - join(absDir, "index.ts"), - `/** - * Automatically generated by the bundler. DO NOT EDIT! - */\n -${exports.join("\n")}` - ); - } - } - } - - // Write index.ts in baseDir - if (baseExports.length > 0) { - writeFileSync( - join(baseDir, "index.ts"), - `/** - * Automatically generated by the bundler. DO NOT EDIT! - */\n -${baseExports.join("\n")}` - ); - } -} diff --git a/ts/package-lock.json b/ts/package-lock.json deleted file mode 100644 index 0ffb610..0000000 --- a/ts/package-lock.json +++ /dev/null @@ -1,309 +0,0 @@ -{ - "name": "wxu", - "version": "0.0.84", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "wxu", - "version": "0.0.84", - "license": "GPL-3.0-only", - "dependencies": { - "webuix": "^0.0.18" - }, - "devDependencies": { - "@types/bun": "latest", - "bun-plugin-dts": "^0.3.0", - "tsc": "^2.0.4" - }, - "peerDependencies": { - "typescript": "^5.0.0" - } - }, - "node_modules/@types/bun": { - "version": "1.2.18", - "resolved": "https://registry.npmjs.org/@types/bun/-/bun-1.2.18.tgz", - "integrity": "sha512-Xf6RaWVheyemaThV0kUfaAUvCNokFr+bH8Jxp+tTZfx7dAPA8z9ePnP9S9+Vspzuxxx9JRAXhnyccRj3GyCMdQ==", - "dev": true, - "dependencies": { - "bun-types": "1.2.18" - } - }, - "node_modules/@types/node": { - "version": "24.0.13", - "dev": true, - "license": "MIT", - "dependencies": { - "undici-types": "~7.8.0" - } - }, - "node_modules/@types/react": { - "version": "19.1.8", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "csstype": "^3.0.2" - } - }, - "node_modules/ansi-regex": { - "version": "5.0.1", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/ansi-styles": { - "version": "4.3.0", - "dev": true, - "license": "MIT", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/bun-plugin-dts": { - "version": "0.3.0", - "dev": true, - "license": "MIT", - "dependencies": { - "common-path-prefix": "^3.0.0", - "dts-bundle-generator": "^9.5.1", - "get-tsconfig": "^4.8.1" - } - }, - "node_modules/bun-types": { - "version": "1.2.18", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/node": "*" - }, - "peerDependencies": { - "@types/react": "^19" - } - }, - "node_modules/cliui": { - "version": "8.0.1", - "dev": true, - "license": "ISC", - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.1", - "wrap-ansi": "^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/color-convert": { - "version": "2.0.1", - "dev": true, - "license": "MIT", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/color-name": { - "version": "1.1.4", - "dev": true, - "license": "MIT" - }, - "node_modules/common-path-prefix": { - "version": "3.0.0", - "dev": true, - "license": "ISC" - }, - "node_modules/csstype": { - "version": "3.1.3", - "dev": true, - "license": "MIT", - "peer": true - }, - "node_modules/dts-bundle-generator": { - "version": "9.5.1", - "dev": true, - "license": "MIT", - "dependencies": { - "typescript": ">=5.0.2", - "yargs": "^17.6.0" - }, - "bin": { - "dts-bundle-generator": "dist/bin/dts-bundle-generator.js" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/emoji-regex": { - "version": "8.0.0", - "dev": true, - "license": "MIT" - }, - "node_modules/escalade": { - "version": "3.2.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/get-caller-file": { - "version": "2.0.5", - "dev": true, - "license": "ISC", - "engines": { - "node": "6.* || 8.* || >= 10.*" - } - }, - "node_modules/get-tsconfig": { - "version": "4.10.1", - "dev": true, - "license": "MIT", - "dependencies": { - "resolve-pkg-maps": "^1.0.0" - }, - "funding": { - "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" - } - }, - "node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/require-directory": { - "version": "2.1.1", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/resolve-pkg-maps": { - "version": "1.0.0", - "dev": true, - "license": "MIT", - "funding": { - "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" - } - }, - "node_modules/string-width": { - "version": "4.2.3", - "dev": true, - "license": "MIT", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-ansi": { - "version": "6.0.1", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/tsc": { - "version": "2.0.4", - "dev": true, - "license": "MIT", - "bin": { - "tsc": "bin/tsc" - } - }, - "node_modules/typescript": { - "version": "5.8.3", - "license": "Apache-2.0", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - }, - "node_modules/undici-types": { - "version": "7.8.0", - "dev": true, - "license": "MIT" - }, - "node_modules/webuix": { - "version": "0.0.18", - "resolved": "https://registry.npmjs.org/webuix/-/webuix-0.0.18.tgz", - "integrity": "sha512-WbQAN+aFS7Yt/ga0fV1X1Ip68ZszAWm7zkJGSzPued7vG/DYfRnyKKEbxK6PqYE261CSHym7E7gU2Xgs7jSpGA==", - "peerDependencies": { - "typescript": "^5.0.0" - } - }, - "node_modules/wrap-ansi": { - "version": "7.0.0", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/y18n": { - "version": "5.0.8", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=10" - } - }, - "node_modules/yargs": { - "version": "17.7.2", - "dev": true, - "license": "MIT", - "dependencies": { - "cliui": "^8.0.1", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.3", - "y18n": "^5.0.5", - "yargs-parser": "^21.1.1" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/yargs-parser": { - "version": "21.1.1", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=12" - } - } - } -} diff --git a/ts/package.json b/ts/package.json deleted file mode 100644 index 5c15d4e..0000000 --- a/ts/package.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "wxu", - "version": "0.0.93", - "type": "module", - "description": "WXU TypeScript Package", - "source": "src/index.ts", - "main": "dist/index.cjs.js", - "module": "dist/index.esm.js", - "types": "dist/index.d.ts", - "scripts": { - "build": "bun run build.ts", - "upload": "bun run build && npm publish" - }, - "keywords": [], - "author": "", - "license": "GPL-3.0-only", - "devDependencies": { - "@types/bun": "latest", - "bun-plugin-dts": "^0.3.0", - "tsc": "^2.0.4" - }, - "peerDependencies": { - "typescript": "^5.0.0" - }, - "dependencies": { - "webuix": "^0.0.18" - } -} diff --git a/ts/src/classes/Context.ts b/ts/src/classes/Context.ts deleted file mode 100644 index d7d39f2..0000000 --- a/ts/src/classes/Context.ts +++ /dev/null @@ -1,140 +0,0 @@ -import { JavaObject } from "./JavaObject"; -import { ActivityThread } from "./android/app/ActivityThread"; - -export interface ContextWrapper { - getApplicationContext(): any; -} - -export interface ContextImpl extends ContextWrapper { - getPackageName(): string; - getDataDir(): any; - getCacheDir(): any; - getExternalCacheDir(): any; - getFilesDir(): any; - getSystemService(name: string): any; - getResources(): any; - getPackageManager(): any; - getContentResolver(): any; - getApplicationInfo(): any; - getAssets(): any; - getSharedPreferences(name: string, mode: number): any; -} - -/** - * Provides access to Android application context and common context-related operations. - * Wraps the underlying JavaObject interactions for easier use in JavaScript/TypeScript. - */ -export class Context implements ContextImpl { - private static _instance: Context; - private _context: ContextImpl; - - private constructor() { - const aThread = new ActivityThread(); - // ContextWrapper is basiclly `Context` - const application = aThread.currentActivityThread().getApplication(); - this._context = application.getApplicationContext() as ContextImpl; - } - - public getApplicationContext() { - return this; - } - - /** - * Gets the singleton instance of the Context wrapper - */ - public static get instance(): Context { - if (!Context._instance) { - Context._instance = new Context(); - } - return Context._instance; - } - - public getSharedPreferences(name: string, mode: number) { - return this._context.getSharedPreferences(name, mode); - } - - /** - * Gets the application's package name - */ - public getPackageName(): string { - return this._context.getPackageName(); - } - - /** - * Gets the application's data directory - */ - public getDataDir(): string { - return this._context.getDataDir(); - } - - /** - * Gets the application's cache directory - */ - public getCacheDir(): string { - return this._context.getCacheDir(); - } - - /** - * Gets the application's external cache directory (if available) - */ - public getExternalCacheDir(): string | null | undefined { - return this._context.getExternalCacheDir(); - } - - /** - * Gets the application's files directory - */ - public getFilesDir(): string { - return this._context.getFilesDir(); - } - - /** - * Gets the system service with the given name - * @param serviceName The name of the system service (e.g., "window", "power") - */ - public getSystemService(serviceName: string) { - return this._context.getSystemService(serviceName); - } - - /** - * Gets the resources object for the application - */ - public getResources() { - return this._context.getResources(); - } - - /** - * Gets the package manager - */ - public getPackageManager() { - return this._context.getPackageManager(); - } - - /** - * Gets the content resolver - */ - public getContentResolver() { - return this._context.getContentResolver(); - } - - /** - * Gets the application info - */ - public getApplicationInfo() { - return this._context.getApplicationInfo(); - } - - /** - * Gets the assets manager - */ - public getAssets() { - return this._context.getAssets(); - } - - /** - * Releases the underlying context resources - */ - public release(): void { - (this._context as unknown as JavaObject).release(); - } -} diff --git a/ts/src/classes/FsPermissionError.ts b/ts/src/classes/FsPermissionError.ts deleted file mode 100644 index bec474b..0000000 --- a/ts/src/classes/FsPermissionError.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { FsStreamError } from "./FsStreamError"; - -export class FsPermissionError extends FsStreamError { - constructor(streamType: "INPUT" | "OUTPUT") { - super( - `Unable to find the "window.Fs${streamType === "INPUT" ? "InputStream" : "OutputStream"}" interface. ` + - `Did you forget to add "wxu.permission.FS_${streamType}_STREAM" to your permissions inside config.json?`, - "PERMISSION_ERROR" - ); - } -} diff --git a/ts/src/classes/FsStreamError.ts b/ts/src/classes/FsStreamError.ts deleted file mode 100644 index 3d17258..0000000 --- a/ts/src/classes/FsStreamError.ts +++ /dev/null @@ -1,7 +0,0 @@ -// Error types for better error handling -export class FsStreamError extends Error { - constructor(message: string, public readonly code: string) { - super(message); - this.name = "FsStreamError"; - } -} diff --git a/ts/src/classes/JavaObject.ts b/ts/src/classes/JavaObject.ts deleted file mode 100644 index 3dbc473..0000000 --- a/ts/src/classes/JavaObject.ts +++ /dev/null @@ -1,252 +0,0 @@ -import type { Reflect } from "../types/Reflect"; - -/** - * Represents a bridge to interact with Java objects from JavaScript/TypeScript. - * - * The `JavaObject` class provides static and instance methods to create, manipulate, - * and release Java objects via a reflection interface, typically exposed by a - * global context (e.g., `wx:reflect` module). It supports calling methods, accessing - * fields, and creating Java proxies with JavaScript handlers. - * - * ## Usage - * - * - Instantiate with a Java class name and constructor arguments to create a new Java object. - * - Use `call` to invoke Java methods, `get` and `set` to access fields. - * - Use static methods for advanced operations or to create proxies. - * - * ## Static Members - * - * - `reflect`: The reflection interface for Java interop. - * - `proxyHandlers`: Internal map for proxy handler functions. - * - `nextProxyId`: Counter for generating unique proxy handler IDs. - * - * ## Instance Members - * - * - `classId`: The Java class identifier. - * - `objId`: The Java object identifier. - * - * ## Methods - * - * - `constructor(className, args)`: Creates a new Java object. - * - `call(method, args)`: Calls a Java method. - * - `get(field)`: Gets a Java field value. - * - `set(field, value)`: Sets a Java field value. - * - `release()`: Releases the Java object. - * - * ## Static Methods - * - * - `getClass(name)`: Gets a Java class ID. - * - `newInstance(classId, args)`: Creates a new Java object instance. - * - `callMethod(objId, method, args)`: Calls a method on a Java object. - * - `getField(objId, field)`: Gets a field value from a Java object. - * - `setField(objId, field, value)`: Sets a field value on a Java object. - * - `release(objId)`: Releases a Java object. - * - `fromObjId(objId)`: Creates a `JavaObject` from an existing object ID. - * - `createProxy(interfaceName, handler)`: Creates a Java proxy object with a JavaScript handler. - * - * @throws {Error} If the required global context or reflection module is not available. - * @throws {TypeError} For invalid arguments in methods. - */ -export class JavaObject { - public static reflect: Reflect | undefined; - public static proxyHandlers: Map; - public static nextProxyId: number; - public classId: any; - public objId: any; - - static { - if (typeof window["global"] === "undefined") { - throw new Error("JavaObject requires a global context with 'wx:reflect' module."); - } - - this.reflect = window.global.require("wx:reflect"); - this.proxyHandlers = new Map(); - this.nextProxyId = 0; - } - - public constructor(className: string | null, args: Array = []) { - if (typeof className === "undefined") { - throw new TypeError("Class name must be a non-empty string or null."); - } - - if (className) { - this.classId = JavaObject.getClass(className); - this.objId = JavaObject.newInstance(this.classId, args); - } - } - - public call(method: string, args: Array = []): string | null | undefined { - if (typeof method !== "string" || method.length === 0) { - throw new TypeError("Method name must be a non-empty string."); - } - - return JavaObject.callMethod(this.objId, method, args); - } - - public get(field: string): string | null | undefined { - if (typeof field !== "string" || field.length === 0) { - throw new TypeError("Field name must be a non-empty string."); - } - - return JavaObject.getField(this.objId, field); - } - - public set(field: string, value: string | boolean | number | null): void { - if (typeof field !== "string" || field.length === 0) { - throw new TypeError("Field name must be a non-empty string."); - } - - if (value === undefined) { - throw new TypeError("Value cannot be undefined."); - } - - JavaObject.setField(this.objId, field, value); - } - - public release(): void { - JavaObject.release(this.objId); - } - - public static getClass(name: string): string | null | undefined { - return this.reflect?.getClass(name); - } - - public static newInstance(classId: string, args: Array | null): string | null | undefined { - const jsonArgs = args == null ? "null" : JSON.stringify(args); - return this.reflect?.newInstance(classId, jsonArgs); - } - - public static callMethod(objId: string, method: string, args: Array | null): string | null | undefined { - const jsonArgs = args == null ? "[]" : JSON.stringify(args); - return this.reflect?.callMethod(objId, method, jsonArgs); - } - - public static callStaticMethod(objId: string, method: string, args: Array | null): string | null | undefined { - const jsonArgs = args == null ? "[]" : JSON.stringify(args); - return this.reflect?.callStaticMethod(objId, method, jsonArgs); - } - - public static getField(objId: string, field: string): string | null | undefined { - return this.reflect?.getField(objId, field); - } - - public static setField(objId: string, field: string, value: string | boolean | number | null): void { - this.reflect?.setField(objId, field, String(value)); - } - - public static release(objId: string): void { - this.reflect?.releaseObject(objId); - } - - public static fromObjId(objId: string | null | undefined): JavaObject { - const obj = new JavaObject(null); - obj.objId = objId; - return obj; - } - - public static createProxy(interfaceName, handler) { - const methodsMap = {}; - const handlerIds: Array = []; - - const allMethods = { - hashCode: () => 0, - equals: () => false, - toString: () => "[JavaScript Proxy]", - ...handler, - }; - - for (const methodName in allMethods) { - if (typeof allMethods[methodName] === "function") { - const methodId = `proxy_handler_${this.nextProxyId++}`; - methodsMap[methodName] = methodId; - handlerIds.push(methodId); - - this.proxyHandlers.set(methodId, (...args) => { - try { - return allMethods[methodName](...args); - } catch (e) { - console.error(`Error in proxy method ${methodName}:`, e); - if (methodName === "equals") return false; - return null; - } - }); - } - } - - const proxyId = this.reflect?.createProxy(interfaceName, JSON.stringify(methodsMap)); - - const proxy = JavaObject.fromObjId(proxyId); - - (proxy as any).releaseProxy = () => { - handlerIds.forEach((id) => this.proxyHandlers.delete(id)); - proxy.release(); - }; - - return proxy; - } - - public static create(className: string | JavaObject | null, args: any[] = []): T { - let javaObj: JavaObject; - - if (className instanceof JavaObject) { - javaObj = className; - } else if (className) { - javaObj = new JavaObject(className, args); - } else { - throw new TypeError("Must provide a class name or a JavaObject instance"); - } - - const autoWrap = (value: any) => { - if (value == null) { - return value; - } - - if (typeof value === "string") { - let objId = value; - - if (value.startsWith("ptr:")) { - objId = value.slice(4); - } - - if (objId.includes("wx_reflect_obj") || objId.match(/^[a-zA-Z0-9_]+$/)) { - try { - return this.create(JavaObject.fromObjId(objId)); - } catch (error) { - console.error(`Error wrapping Java object ${objId}:`, error); - return value; - } - } - } - - return value; - }; - - return new Proxy(javaObj, { - get(target, prop: string, receiver) { - if (prop === "release" || prop === "objId" || prop === "classId") { - return Reflect.get(target, prop, receiver); - } - - return (...args: any[]) => { - try { - const result = JavaObject.callMethod(target.objId, prop, args); - return autoWrap(result); - } catch (error) { - console.error(`Error calling method ${prop}:`, error); - throw error; - } - }; - }, - - set(target, prop: string, value) { - try { - JavaObject.setField(target.objId, prop, value); - return true; - } catch (error) { - console.error(`Error setting field ${prop}:`, error); - return false; - } - }, - }) as T; - } -} diff --git a/ts/src/classes/PseudoTerminal.ts b/ts/src/classes/PseudoTerminal.ts deleted file mode 100644 index 69f7d85..0000000 --- a/ts/src/classes/PseudoTerminal.ts +++ /dev/null @@ -1,86 +0,0 @@ -import { WXEventHandler } from "webuix"; -import type { Global, Pty, PtyInstance } from "../types"; - -export type EnvironmentVariables = { - [key: string]: string | null; -}; - -export class PseudoTerminal { - private readonly _instance: PtyInstance | null = null; - private readonly _shell: string; - private readonly _args: string[]; - private readonly _env: EnvironmentVariables; - private readonly _eventHandler: WXEventHandler | null = null; - - constructor(shell: string, args: Array, env: EnvironmentVariables) { - this._shell = shell; - this._args = args; - this._env = env; - - if (window._wxEventHandler instanceof WXEventHandler) { - this._eventHandler = window._wxEventHandler; - } else { - this._eventHandler = new WXEventHandler(); - } - - let impl: Pty | undefined; - try { - impl = window.global.require("wx:pty"); - } catch (error) { - console.error("Failed to load pty:", error); - return; - } - - if (!impl || typeof impl.start !== "function") { - console.error("Invalid pty implementation"); - return; - } - - const _args = JSON.stringify(this._args); - const _env = JSON.stringify(this._env); - - this._instance = impl.start(this._shell, _args, _env); - } - - public on(name: "data", callback: (data: string) => void): void; - public on( - name: "exit", - callback: (data: { code: number; signal?: string }) => void - ): void; - public on(name: "data" | "exit", callback: (data: any) => void): void { - const eventMap: Record<"data" | "exit", string> = { - data: "pty-data", - exit: "pty-exit", - }; - - const eventType: any = eventMap[name]; - if (!eventType) { - console.warn(`Unsupported event name: ${name}`); - return; - } - - if (!this._eventHandler) { - throw new Error("WXEventHandler is not initialized"); - } - - this._eventHandler.on(window, eventType, (event: any) => { - if (name === "data") { - callback(event?.wx as string); - } else if (name === "exit") { - callback(event?.wx as { code: number; signal?: string }); - } - }); - } - - public write(data: string): void { - this._instance?.write(data); - } - - public resize(cols: number, rows: number): void { - this._instance?.resize(cols, rows); - } - - public kill(): void { - this._instance?.kill(); - } -} diff --git a/ts/src/classes/SharedPreferences.ts b/ts/src/classes/SharedPreferences.ts deleted file mode 100644 index bf5adc7..0000000 --- a/ts/src/classes/SharedPreferences.ts +++ /dev/null @@ -1,146 +0,0 @@ -import { Context } from "./Context"; -import { JavaObject } from "./JavaObject"; - -export type PreferenceValue = boolean | number | string; - -export type ChangeListener = (key: string, prefs: SharedPreferences) => void; - -export class SharedPreferences { - #prefsId: any; - #editorId: any | null = null; - #listeners: Map = new Map(); - #listenerProxy: JavaObject | null = null; - - constructor(context: Context, name: string, mode: number = 0) { - if (!(context instanceof Context)) { - throw new TypeError("Context must be an instance of Context class."); - } - - this.#prefsId = context.getSharedPreferences(name, mode); - if (!this.#prefsId) { - throw new Error("Failed to get SharedPreferences instance."); - } - } - - #getEditor(): any { - if (!this.#editorId) { - this.#editorId = JavaObject.callMethod(this.#prefsId, "edit", []); - } - return this.#editorId; - } - - get(key: string, defaultValue: PreferenceValue): PreferenceValue { - const type = typeof defaultValue; - switch (type) { - case "boolean": - return JavaObject.callMethod(this.#prefsId, "getBoolean", [key, defaultValue]) == "true"; - case "number": - if (Number.isInteger(defaultValue)) { - const int = JavaObject.callMethod(this.#prefsId, "getInt", [key, defaultValue]); - const parsedInt = Number.parseInt(int!!); - if (Number.isNaN(parsedInt)) { - return defaultValue; - } - return parsedInt; - } - const float = JavaObject.callMethod(this.#prefsId, "getFloat", [key, defaultValue]); - const parsedFloat = Number.parseFloat(float!!); - if (Number.isNaN(parsedFloat)) { - return defaultValue; - } - return parsedFloat; - case "string": - return JavaObject.callMethod(this.#prefsId, "getString", [key, defaultValue]) as PreferenceValue; - default: - return JavaObject.callMethod(this.#prefsId, "getString", [key, String(defaultValue)]) as PreferenceValue; - } - } - - put(key: string, value: PreferenceValue): this { - const editor = this.#getEditor(); - const type = typeof value; - switch (type) { - case "boolean": - JavaObject.callMethod(editor, "putBoolean", [key, value]); - break; - case "number": - Number.isInteger(value) ? JavaObject.callMethod(editor, "putInt", [key, value]) : JavaObject.callMethod(editor, "putFloat", [key, value]); - break; - case "string": - JavaObject.callMethod(editor, "putString", [key, value]); - break; - default: - JavaObject.callMethod(editor, "putString", [key, String(value)]); - } - return this; - } - - remove(key: string): this { - JavaObject.callMethod(this.#getEditor(), "remove", [key]); - return this; - } - - clear(): this { - JavaObject.callMethod(this.#getEditor(), "clear", []); - return this; - } - - commit(): boolean { - if (!this.#editorId) return false; - const result = JavaObject.callMethod(this.#editorId, "commit", []); - this.#editorId = null; - return result == "true"; - } - - apply(): void { - if (!this.#editorId) return; - JavaObject.callMethod(this.#editorId, "apply", []); - this.#editorId = null; - } - - contains(key: string): boolean { - return JavaObject.callMethod(this.#prefsId, "contains", [key]) == "true"; - } - - // getAll(): Record { - // return JavaObject.callMethod(this.#prefsId, "getAll", []); - // } - - registerOnChangeListener(callback: ChangeListener): () => boolean { - if (typeof callback !== "function") { - throw new Error("Callback must be a function"); - } - - const listenerId = `listener_${Math.random().toString(36).substring(2, 9)}`; - this.#listeners.set(listenerId, callback); - - if (!this.#listenerProxy) { - const interfaceName = "android.content.SharedPreferences$OnSharedPreferenceChangeListener"; - this.#listenerProxy = JavaObject.createProxy(interfaceName, { - onSharedPreferenceChanged: (prefsId: any, key: string) => { - this.#listeners.forEach((listener) => { - try { - listener(key, this); - } catch (e) { - console.error("Error in preference change listener:", e); - } - }); - }, - }); - - JavaObject.callMethod(this.#prefsId, "registerOnSharedPreferenceChangeListener", [this.#listenerProxy.objId]); - } - - return () => this.unregisterOnChangeListener(listenerId); - } - - unregisterOnChangeListener(listenerId: string): boolean { - if (this.#listeners.delete(listenerId) && this.#listeners.size === 0 && this.#listenerProxy) { - JavaObject.callMethod(this.#prefsId, "unregisterOnSharedPreferenceChangeListener", [this.#listenerProxy.objId]); - (this.#listenerProxy as any)?.releaseProxy(); - this.#listenerProxy = null; - return true; - } - return false; - } -} diff --git a/ts/src/classes/android/app/ActivityThread.ts b/ts/src/classes/android/app/ActivityThread.ts deleted file mode 100644 index bc56d81..0000000 --- a/ts/src/classes/android/app/ActivityThread.ts +++ /dev/null @@ -1,30 +0,0 @@ -import type { ContextWrapper } from "../../Context"; -import { JavaObject } from "../../JavaObject"; - -export interface ActivityThreadImpl { - currentActivityThread(): ActivityThread; - getApplication(): ContextWrapper; - // getSystemContext(): any; - // getPackageManager(): any; - // getContentResolver(): any; - // getMainLooper(): any; - // getSystemService(name: string): any; - // getSystemUiContext(): any; - // getSystemUiService(name: string): any; -} - -export class ActivityThread implements ActivityThreadImpl { - private instance: ActivityThreadImpl; - - constructor() { - this.instance = JavaObject.create("android.app.ActivityThread"); - } - - currentActivityThread(): ActivityThread { - return this.instance.currentActivityThread(); - } - - getApplication() { - return this.instance.getApplication(); - } -} diff --git a/ts/src/classes/index.ts b/ts/src/classes/index.ts deleted file mode 100644 index 440650b..0000000 --- a/ts/src/classes/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Automatically generated by the bundler. DO NOT EDIT! - */ - -export * from "./JavaObject"; -export * from "./SharedPreferences"; -export * from "./Context"; -export * from "./PseudoTerminal"; -export * from "./FsStreamError"; -export * from "./FsPermissionError"; -export * from "./android/app/ActivityThread"; \ No newline at end of file diff --git a/ts/src/functions/index.ts b/ts/src/functions/index.ts deleted file mode 100644 index 7a94943..0000000 --- a/ts/src/functions/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Automatically generated by the bundler. DO NOT EDIT! - */ - -export * from "./openInputStream"; -export * from "./openOutputStream"; -export * from "./readTextFile"; -export * from "./readBinaryFile"; -export * from "./readJsonFile"; -export * from "./writeTextFile"; -export * from "./writeBinaryFile"; -export * from "./writeJsonFile"; \ No newline at end of file diff --git a/ts/src/functions/openInputStream.ts b/ts/src/functions/openInputStream.ts deleted file mode 100644 index 8371458..0000000 --- a/ts/src/functions/openInputStream.ts +++ /dev/null @@ -1,122 +0,0 @@ -import { FsPermissionError } from "../classes/FsPermissionError"; -import { FsStreamError } from "../classes/FsStreamError"; -import type { FsStreamInit } from "../interfaces/FsStreamInit"; - -// Default configuration for readable streams -export const fsStreamInit: FsStreamInit = { - headers: { - "Content-Type": "application/octet-stream", - }, -} as const; - -/** - * Opens an input stream for reading files from the filesystem - * @param path - The file path to read from - * @param init - Optional configuration for the readable stream - * @returns Promise that resolves to a Response object containing the file data - */ -export async function openInputStream(path: string, init: FsStreamInit = {}): Promise { - // Validate input parameters - if (typeof path !== "string") { - throw new TypeError("'path' must be a string"); - } - - if (typeof path === "string" && path.trim() === "") { - throw new Error("'path' cannot be empty"); - } - - // Check if the FsInputStream interface is available - if (!window.FsInputStream || typeof window.FsInputStream.postMessage !== "function") { - throw new FsPermissionError("INPUT"); - } - - const mergedInit: FsStreamInit = { - ...fsStreamInit, - ...init, - }; - - return new Promise((resolve, reject) => { - const chunks: Uint8Array[] = []; - let aborted = false; - let messageHandler: ((event: MessageEvent) => void) | null = null; - - const onAbort = (): void => { - aborted = true; - cleanup(); - reject(new DOMException("The operation was aborted.", "AbortError")); - }; - - // Handle abort signal - if (mergedInit.signal?.aborted) { - onAbort(); - return; - } - - mergedInit.signal?.addEventListener("abort", onAbort); - - const cleanup = (): void => { - if (mergedInit.signal) { - mergedInit.signal.removeEventListener("abort", onAbort); - } - if (messageHandler && window.FsInputStream) { - window.FsInputStream.removeEventListener("message", messageHandler); - window.FsInputStream.onmessage = null; - } - }; - - messageHandler = (event: MessageEvent): void => { - if (aborted) return; - - const msg: unknown = event.data; - - if (msg instanceof ArrayBuffer) { - chunks.push(new Uint8Array(msg)); - } else if (typeof msg === "string") { - cleanup(); - reject(new FsStreamError(msg, "STREAM_ERROR")); - return; - } else { - cleanup(); - reject(new FsStreamError("Received unexpected message type", "INVALID_MESSAGE")); - return; - } - - // Create the readable stream once we have data - try { - const stream = new ReadableStream({ - start(controller): void { - try { - for (const chunk of chunks) { - controller.enqueue(chunk); - } - controller.close(); - } catch (error) { - controller.error(error); - throw error; - } - }, - cancel(reason?: unknown): void { - console.warn("Stream canceled:", reason); - cleanup(); - }, - }); - - cleanup(); - resolve(new Response(stream, mergedInit)); - } catch (error) { - cleanup(); - reject(error instanceof Error ? error : new Error(String(error))); - } - }; - - // Set up message listener and send request - window.FsInputStream?.addEventListener("message", messageHandler); - - try { - window.FsInputStream?.postMessage(path); - } catch (error) { - cleanup(); - reject(new FsStreamError(`Failed to send message to FsInputStream: ${error}`, "POST_MESSAGE_ERROR")); - } - }); -} diff --git a/ts/src/functions/openOutputStream.ts b/ts/src/functions/openOutputStream.ts deleted file mode 100644 index 064b9b1..0000000 --- a/ts/src/functions/openOutputStream.ts +++ /dev/null @@ -1,120 +0,0 @@ -import { FsPermissionError } from "../classes/FsPermissionError"; -import { FsStreamError } from "../classes/FsStreamError"; - -/** - * Opens an output stream for writing files to the filesystem - * @param path - The file path to write to - * @returns WritableStream for writing data to the file - */ -export function openOutputStream(path: string): WritableStream { - // Validate input parameters - if (typeof path !== "string") { - throw new TypeError("'path' must be a string"); - } - - if (path.trim() === "") { - throw new Error("'path' cannot be empty"); - } - - // Check if the FsOutputStream interface is available - if (!window.FsOutputStream || typeof window.FsOutputStream.postMessage !== "function") { - throw new FsPermissionError("OUTPUT"); - } - - let pathSet = false; - let isAborted = false; - - /** - * Helper function to send a message and wait for a reply - */ - const postMessageWithReply = (message: string | (ArrayBuffer | ArrayBufferLike)): Promise => { - return new Promise((resolve, reject) => { - if (isAborted) { - reject(new DOMException("Stream has been aborted", "AbortError")); - return; - } - - const handler = (event: MessageEvent): void => { - const data: unknown = event.data; - - if (window.FsOutputStream) { - window.FsOutputStream.removeEventListener("message", handler); - } - - if (typeof data === "string") { - if (data.startsWith("Failed")) { - reject(new FsStreamError(data, "OPERATION_FAILED")); - } else { - resolve(data); - } - } else { - reject(new FsStreamError("Received non-string response", "INVALID_RESPONSE")); - } - }; - - if (!window.FsOutputStream) { - reject(new FsPermissionError("OUTPUT")); - return; - } - - window.FsOutputStream.addEventListener("message", handler); - - try { - window.FsOutputStream.postMessage(message); - } catch (error) { - window.FsOutputStream.removeEventListener("message", handler); - reject(new FsStreamError(`Failed to send message: ${error}`, "POST_MESSAGE_ERROR")); - } - }); - }; - - return new WritableStream({ - async start(): Promise { - try { - const reply = await postMessageWithReply(path); - if (reply !== "Path set") { - throw new FsStreamError(`Failed to set path: ${reply}`, "PATH_SET_FAILED"); - } - pathSet = true; - } catch (error) { - throw error instanceof FsStreamError ? error : new FsStreamError(`Failed to initialize output stream: ${error}`, "INIT_ERROR"); - } - }, - - async write(chunk: Uint8Array): Promise { - if (isAborted) { - throw new DOMException("Stream has been aborted", "AbortError"); - } - - if (!(chunk instanceof Uint8Array)) { - throw new TypeError("Chunk must be Uint8Array"); - } - - if (!pathSet) { - throw new FsStreamError("Path not set before writing chunk", "PATH_NOT_SET"); - } - - try { - await postMessageWithReply(chunk.buffer); - console.log(`Chunk written: ${chunk.length} bytes`); - } catch (error) { - throw error instanceof FsStreamError ? error : new FsStreamError(`Failed to write chunk: ${error}`, "WRITE_ERROR"); - } - }, - - async close(): Promise { - console.log("WritableStream closed"); - // await postMessageWithReply('CLOSE'); - }, - - abort(reason?: unknown): void { - isAborted = true; - console.warn("WritableStream aborted:", reason); - // try { - // postMessageWithReply('ABORT'); - // } catch (error) { - // console.warn('Failed to send abort message:', error); - // } - }, - }); -} diff --git a/ts/src/functions/readBinaryFile.ts b/ts/src/functions/readBinaryFile.ts deleted file mode 100644 index eaca01a..0000000 --- a/ts/src/functions/readBinaryFile.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { openInputStream } from "./openInputStream"; - -/** - * Reads a file as an array buffer using the input stream - * @param path - The file path to read - * @param signal - Optional abort signal - * @returns Promise that resolves to the file content as ArrayBuffer - */ -export async function readBinaryFile(path: string, signal?: AbortSignal): Promise { - const response = await openInputStream(path, { signal }); - return await response.arrayBuffer(); -} diff --git a/ts/src/functions/readJsonFile.ts b/ts/src/functions/readJsonFile.ts deleted file mode 100644 index a7686cf..0000000 --- a/ts/src/functions/readJsonFile.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { openInputStream } from "./openInputStream"; - -/** - * Reads and parses a JSON file from the specified path. - * @template T - The expected type of the parsed JSON object. - * @param path - The file path to read. - * @param encoding - The text encoding to use (default: 'utf-8'). - * @param signal - Optional AbortSignal to cancel the operation. - * @returns A promise that resolves to the parsed JSON object of type T. - */ -export async function readJsonFile(path: string, encoding: string = "utf-8", signal?: AbortSignal): Promise { - const response = await openInputStream(path, { signal }); - return await response.json(); -} diff --git a/ts/src/functions/readTextFile.ts b/ts/src/functions/readTextFile.ts deleted file mode 100644 index c513b97..0000000 --- a/ts/src/functions/readTextFile.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { openInputStream } from "./openInputStream"; - -/** - * Reads a file as text using the input stream - * @param path - The file path to read - * @param encoding - Text encoding (default: 'utf-8') - * @param signal - Optional abort signal - * @returns Promise that resolves to the file content as text - */ -export async function readTextFile(path: string, encoding: string = "utf-8", signal?: AbortSignal): Promise { - const response = await openInputStream(path, { signal }); - return await response.text(); -} diff --git a/ts/src/functions/writeBinaryFile.ts b/ts/src/functions/writeBinaryFile.ts deleted file mode 100644 index 7557765..0000000 --- a/ts/src/functions/writeBinaryFile.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { openOutputStream } from "./openOutputStream"; - -/** - * Writes binary data to a file using the output stream - * @param path - The file path to write to - * @param data - The binary data to write - */ -export async function writeBinaryFile(path: string, data: ArrayBuffer | Uint8Array): Promise { - const uint8Data = data instanceof ArrayBuffer ? new Uint8Array(data) : data; - - const stream = openOutputStream(path); - const writer = stream.getWriter(); - - try { - await writer.write(uint8Data); - } finally { - await writer.close(); - } -} diff --git a/ts/src/functions/writeJsonFile.ts b/ts/src/functions/writeJsonFile.ts deleted file mode 100644 index b74d651..0000000 --- a/ts/src/functions/writeJsonFile.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { writeTextFile } from "./writeTextFile"; - -/** - * Writes JSON data to a file using the output stream - * @param path - The file path to write to - * @param data - The JSON data to write` - */ -export async function writeJsonFile(path: string, data: any): Promise { - const json = JSON.stringify(data); - await writeTextFile(path, json); -} diff --git a/ts/src/functions/writeTextFile.ts b/ts/src/functions/writeTextFile.ts deleted file mode 100644 index 5e4dbca..0000000 --- a/ts/src/functions/writeTextFile.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { openOutputStream } from "./openOutputStream"; - -/** - * Writes text to a file using the output stream - * @param path - The file path to write to - * @param text - The text content to write - * @param encoding - Text encoding (default: 'utf-8') - */ -export async function writeTextFile(path: string, text: string, encoding: string = "utf-8"): Promise { - const encoder = new TextEncoder(); - const data = encoder.encode(text); - - const stream = openOutputStream(path); - const writer = stream.getWriter(); - - try { - await writer.write(data); - } finally { - await writer.close(); - } -} diff --git a/ts/src/index.ts b/ts/src/index.ts deleted file mode 100644 index 47f66a1..0000000 --- a/ts/src/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Automatically generated by the bundler. DO NOT EDIT! - */ - -export type * from "./types/index"; -export * from "./classes/index"; -export * from "./functions/index"; -export type * from "./interfaces/index"; \ No newline at end of file diff --git a/ts/src/interfaces/FsStreamInit.ts b/ts/src/interfaces/FsStreamInit.ts deleted file mode 100644 index b882bce..0000000 --- a/ts/src/interfaces/FsStreamInit.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface FsStreamInit extends ResponseInit { - signal?: AbortSignal; -} diff --git a/ts/src/interfaces/index.ts b/ts/src/interfaces/index.ts deleted file mode 100644 index bf442da..0000000 --- a/ts/src/interfaces/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -/** - * Automatically generated by the bundler. DO NOT EDIT! - */ - -export type * from "./FsStreamInit"; \ No newline at end of file diff --git a/ts/src/types/FileSystem.ts b/ts/src/types/FileSystem.ts deleted file mode 100644 index 989d429..0000000 --- a/ts/src/types/FileSystem.ts +++ /dev/null @@ -1,198 +0,0 @@ -import type { FileSystemInstance } from "./FileSystemInstance"; - -/** - * Defines a static-like interface for synchronous file system operations. - * This interface provides a direct way to interact with the file system from a - * sandboxed environment, like a WebView. All operations are synchronous and will - * block execution until they complete. It serves as a factory for creating - * FileSystemInstance objects and for performing operations on paths directly. - */ -export interface FileSystem { - /** - * Creates a new FileSystemInstance for a given path. This instance can then be - * used to perform operations on that specific file or directory. - * - * @param {string} path - The absolute path to the file or directory. - * @returns {FileSystemInstance | null} A new instance representing the path, - * or `null` if the path is invalid or inaccessible. - */ - newInstance(path: string): FileSystemInstance | null; - - /** - * Reads the entire content of a file at a given path as a UTF-8 string. - * - * @param {string} path - The path to the file to read. - * @returns {string | null} The content of the file as a string, or `null` if - * the file does not exist or cannot be read. - */ - readTextSync(path: string): string | null; - - /** - * Writes a string to a file at a given path, overwriting the file if it exists. - * - * @param {string} path - The path to the file to write to. - * @param {string} text - The string content to write to the file. - * @returns {void | null} Returns `null` if the operation fails. - */ - writeTextSync(path: string, text: string): void | null; - - /** - * Lists the files and directories in a given path. - * - * @param {string} path - The path of the directory to list. - * @param {string} [delimiter] - An optional delimiter to join the names. If not provided, - * the result might be a JSON array string or a newline-separated string. - * @returns {string | null} A string containing the names of the items in the directory, - * or `null` if the path is not a directory or an error occurs. - */ - listSync(path: string): string | null; - listSync(path: string, delimiter: string): string | null; - - /** - * Checks if a file or directory exists at the given path. - * - * @param {string} path - The path to check. - * @returns {boolean} `true` if the path exists, `false` otherwise. - */ - existsSync(path: string): boolean; - - /** - * Checks if the given path points to a regular file. - * - * @param {string} path - The path to check. - * @returns {boolean} `true` if the path is a file, `false` otherwise. - */ - isFileSync(path: string): boolean; - - /** - * Checks if the given path points to a directory. - * - * @param {string} path - The path to check. - * @returns {boolean} `true` if the path is a directory, `false` otherwise. - */ - isDirectorySync(path: string): boolean; - - /** - * Checks if the given path points to a symbolic link. - * - * @param {string} path - The path to check. - * @returns {boolean} `true` if the path is a symbolic link, `false` otherwise. - */ - isSymlinkSync(path: string): boolean; - - /** - * Checks if the given path points to a block device. - * - * @param {string} path - The path to check. - * @returns {boolean} `true` if the path is a block device, `false` otherwise. - */ - isBlockSync(path: string): boolean; - - /** - * Checks if the given path points to a named pipe (FIFO). - * - * @param {string} path - The path to check. - * @returns {boolean} `true` if the path is a named pipe, `false` otherwise. - */ - isNamedPipeSync(path: string): boolean; - - /** - * Checks if the given path points to a character device. - * - * @param {string} path - The path to check. - * @returns {boolean} `true` if the path is a character device, `false` otherwise. - */ - isCharacterSync(path: string): boolean; - - /** - * Checks if the file or directory at the given path is hidden. - * - * @param {string} path - The path to check. - * @returns {boolean} `true` if the path is hidden, `false` otherwise. - */ - isHiddenSync(path: string): boolean; - - /** - * Checks if the given path points to a socket. - * - * @param {string} path - The path to check. - * @returns {boolean} `true` if the path is a socket, `false` otherwise. - */ - isSocketSync(path: string): boolean; - - /** - * Creates a new directory. Fails if the parent directory does not exist. - * - * @param {string} path - The path of the directory to create. - * @returns {boolean} `true` if the directory was created, `false` otherwise. - */ - mkdirSync(path: string): boolean; - - /** - * Creates a directory, including any necessary but non-existent parent directories. - * - * @param {string} path - The path of the directory to create. - * @returns {boolean} `true` if the directories were created, `false` otherwise. - */ - mkdirsSync(path: string): boolean; - - /** - * Removes a file or an empty directory at the given path. - * - * @param {string} path - The path to remove. - * @returns {boolean} `true` if the removal was successful, `false` otherwise. - */ - rmSync(path: string): boolean; - - /** - * Returns the size of the file at the given path in bytes. - * - * @param {string} path - The path to the file. - * @returns {number | null} The size of the file in bytes, or `null` if it doesn't exist or is a directory. - */ - sizeSync(path: string): number | null; - - /** - * Renames or moves a file or directory. - * - * @param {string} path - The original path. - * @param {string} newPath - The new path. - * @returns {boolean} `true` if the operation was successful, `false` otherwise. - */ - renameSync(path: string, newPath: string): boolean; - - /** - * Copies a file from a source path to a destination path. - * - * @param {string} path - The source file path. - * @param {string} dest - The destination file path. - * @param {boolean} [overwrite=false] - If `true`, the destination file will be overwritten if it exists. - */ - copyFileSync(path: string, dest: string): void; - copyFileSync(path: string, dest: string, overwrite: boolean): void; - - /** - * Retrieves file status information, typically the last modification time as a Unix timestamp. - * - * @param {string} path - The path to the file or directory. - * @returns {number | null} The last modification time (e.g., in milliseconds since epoch), - * or `null` if the path does not exist. - */ - statSync(path: string): number | null; - - /** - * Creates a new, empty file at the specified path. - * - * @param {string} path - The path where the new file should be created. - * @returns {boolean} `true` if the file was created, `false` if it already exists or an error occurred. - */ - createNewFileSync(path: string): boolean; - - /** - * Checks if the application has execute permissions for the given path. - * - * @param {string} path - The path to check. - * @returns {boolean} `true` if the file is executable, `false` otherwise. - */ - canExecuteSync(path: string): boolean; -} diff --git a/ts/src/types/FileSystemInstance.ts b/ts/src/types/FileSystemInstance.ts deleted file mode 100644 index fc7c8a5..0000000 --- a/ts/src/types/FileSystemInstance.ts +++ /dev/null @@ -1,192 +0,0 @@ -/** - * Defines an interface representing an instance of a file or directory. - * The methods operate directly on the path associated with this instance. All - * operations are synchronous and will block execution until they complete. - */ -export interface FileSystemInstance { - /** - * Reads the entire content of the file associated with this instance. - * - * @returns {string | null} The content of the file as a UTF-8 string, or `null` if reading fails. - */ - readTextSync(): string | null; - - /** - * Writes a string to the file associated with this instance. - * - * @param {string} text - The content to write. - * @returns {void | null} Returns `null` if the operation fails. - */ - writeTextSync(text: string): void | null; - - /** - * Lists the files and directories if this instance represents a directory. - * - * @param {string} [delimiter] - An optional delimiter to join the names. - * @returns {string | null} A string containing the names of the items in the directory, - * or `null` if this instance is not a directory. - */ - listSync(): string | null; - listSync(delimiter: string): string | null; - - /** - * Checks if the file or directory of this instance exists. - * - * @returns {boolean} `true` if it exists, `false` otherwise. - */ - existsSync(): boolean; - - /** - * Checks if this instance represents a regular file. - * - * @returns {boolean} `true` if it is a file, `false` otherwise. - */ - isFileSync(): boolean; - - /** - * Checks if this instance represents a directory. - * - * @returns {boolean} `true` if it is a directory, `false` otherwise. - */ - isDirectorySync(): boolean; - - /** - * Checks if this instance represents a symbolic link. - * - * @returns {boolean} `true` if it is a symbolic link, `false` otherwise. - */ - isSymlinkSync(): boolean; - - /** - * Checks if this instance points to a block device. - * - * @returns {boolean} `true` if it is a block device, `false` otherwise. - */ - isBlockSync(): boolean; - - /** - * Checks if this instance points to a named pipe (FIFO). - * - * @returns {boolean} `true` if it is a named pipe, `false` otherwise. - */ - isNamedPipeSync(): boolean; - - /** - * Checks if this instance points to a character device. - * - * @returns {boolean} `true` if it is a character device, `false` otherwise. - */ - isCharacterSync(): boolean; - - /** - * Checks if the file or directory of this instance is hidden. - * - * @returns {boolean} `true` if it is hidden, `false` otherwise. - */ - isHiddenSync(): boolean; - - /** - * Checks if this instance points to a socket. - * - * @returns {boolean} `true` if it is a socket, `false` otherwise. - */ - isSocketSync(): boolean; - - /** - * Creates a directory at the path of this instance. - * - * @returns {boolean} `true` on success, `false` otherwise. - */ - mkdirSync(): boolean; - - /** - * Creates a directory at the path of this instance, including parent directories. - * - * @returns {boolean} `true` on success, `false` otherwise. - */ - mkdirsSync(): boolean; - - /** - * Removes the file or directory of this instance. - * - * @returns {boolean} `true` on success, `false` otherwise. - */ - rmSync(): boolean; - - /** - * Returns the size of the file of this instance in bytes. - * - * @returns {number | null} The size in bytes, or `null` if it's not a file. - */ - sizeSync(): number | null; - - /** - * Renames or moves the file or directory of this instance. - * - * @param {string} newPath - The new path for the file or directory. - * @returns {boolean} `true` on success, `false` otherwise. - */ - renameSync(newPath: string): boolean; - - /** - * Copies the file of this instance to a new destination. - * - * @param {string} dest - The destination file path. - * @param {boolean} [overwrite=false] - If `true`, overwrite the destination if it exists. - */ - copyFileSync(dest: string): void; - copyFileSync(dest: string, overwrite: boolean): void; - - /** - * Retrieves status information about the file of this instance. - * - * @returns {number | null} The last modification time (e.g., in milliseconds since epoch), - * or `null` on failure. - */ - statSync(): number | null; - - /** - * Creates a new, empty file at the path of this instance. - * - * @returns {boolean} `true` if the file was created, `false` if it already exists. - */ - createNewFileSync(): boolean; - - /** - * Checks if the application can execute the file of this instance. - * - * @returns {boolean} `true` if executable, `false` otherwise. - */ - canExecuteSync(): boolean; - - /** - * Checks if the application can write to the file of this instance. - * - * @returns {boolean} `true` if writable, `false` otherwise. - */ - canWriteSync(): boolean; - - /** - * Checks if the application can read the file of this instance. - * - * @returns {boolean} `true` if readable, `false` otherwise. - */ - canReadSync(): boolean; - - /** - * Changes the owner and group of the file or directory. - * - * @param {number} uid - The user ID. - * @param {number} gid - The group ID. - * @returns {boolean} `true` on success, `false` otherwise. - */ - chownSync(uid: number, gid: number): boolean; - - /** - * Changes the permissions of the file or directory (e.g., using octal notation). - * - * @param {number} mode - The permission mode. - * @returns {boolean} `true` on success, `false` otherwise. - */ - chmodSync(mode: number): boolean; -} diff --git a/ts/src/types/FsStreamInterface.ts b/ts/src/types/FsStreamInterface.ts deleted file mode 100644 index d5a2e5f..0000000 --- a/ts/src/types/FsStreamInterface.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Represents a stream-like interface for message-based communication. - * - * This interface provides methods for adding and removing event listeners for "message" events, - * sending messages, and handling incoming messages via an optional `onmessage` property. - * - * @remarks - * Implementations of this interface can be used to abstract communication channels such as - * web workers, sockets, or other message-based transports. - */ -export interface FsStreamInterface { - addEventListener(type: "message", listener: (event: MessageEvent) => void): void; - removeEventListener(type: "message", listener: (event: MessageEvent) => void): void; - postMessage(data: string | (ArrayBuffer | ArrayBufferLike)): void; - onmessage?: ((event: MessageEvent) => void) | null; -} diff --git a/ts/src/types/Module.ts b/ts/src/types/Module.ts deleted file mode 100644 index a417d2e..0000000 --- a/ts/src/types/Module.ts +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Defines an interface for retrieving path information specific - * to a Magisk module's environment. - * - * This interface is crucial for a module to dynamically locate its own files, - * access shared Magisk directories, and manage its configuration in the - * correct locations as dictated by the Magisk framework. - */ -export interface Module { - /** - * Gets the unique identifier of the module. - * This ID is defined in the module's `module.prop` file and is used as the - * directory name within the main Magisk modules directory. - * - * @example - * // returns "my-custom-module" - * const id = currentModule.getId(); - * - * @returns {string} The unique ID of this module. - */ - getId(): string; - - /** - * Gets the path to the main Magisk working directory, typically located at - * `/data/adb`. This directory contains core Magisk files, post-fs-data scripts, - * service scripts, and the modules directory. - * - * @returns {string} The absolute path to the Magisk `adb` directory. - */ - getAdbDir(): string; - - /** - * Gets the path to the directory where module configurations are stored. - * This is often a subdirectory within the module's own directory to keep - * user settings and configurations. - * - * @returns {string} The absolute path to the configuration directory. - */ - getConfigDir(): string; - - /** - * Gets the path to the configuration directory specific to this module. - * This provides a standardized location for the module to read and write its - * own settings, ensuring it doesn't conflict with other modules. - * This is typically `/data/adb/modules//config` or similar. - * - * @returns {string} The absolute path to this module's config directory. - */ - getModuleConfigDir(): string; - - /** - * Gets the path to the directory where all installed Magisk modules are located. - * This is the parent directory for all individual module folders. - * The standard path is `/data/adb/modules`. - * - * @returns {string} The absolute path to the main Magisk modules directory. - */ - getModulesDir(): string; - - /** - * Gets the path to the root directory of this specific module. - * All of the module's files (system replacements, scripts, assets) are - * contained within this directory. The path is typically - * `/data/adb/modules/`. - * - * @returns {string} The absolute path to this module's root directory. - */ - getModuleDir(): string; - - /** - * Gets the path to a directory that can be used to serve web content, - * if the module has a WebView component or a web-based UI. - * This would point to the directory containing the module's HTML, CSS, - * and JavaScript files. - * - * @returns {string} The absolute path to the module's web assets root directory. - */ - getWebRootDir(): string; - - /** - * Gets the path to the module's `system` directory. - * Files placed in this directory will systemlessly overlay the corresponding - * files in the device's actual `/system` partition. For example, a file at - * `/system/app/MyGreatApp.apk` would appear at `/system/app/MyGreatApp.apk`. - * - * @returns {string} The absolute path to the module's system overlay directory. - */ - getSystemDir(): string; - - /** - * Gets the path to the `module.prop` file for this module. - * This file contains critical metadata about the module, such as its `id`, - * `name`, `version`, `author`, and `description`. - * - * @returns {string} The absolute path to the `module.prop` file. - */ - getPropFile(): string; -} diff --git a/ts/src/types/PackageManager.ts b/ts/src/types/PackageManager.ts deleted file mode 100644 index 3902a92..0000000 --- a/ts/src/types/PackageManager.ts +++ /dev/null @@ -1,177 +0,0 @@ -/** - * Information about an installed Android application. - * - * This interface represents detailed metadata about an app package, - * including version info, directories, permissions, and various Android-specific settings. - */ -export interface WXApplicationInfo { - /** The unique package name identifier (e.g., "com.example.app") */ - packageName: string; - /** The internal name of the application */ - name: string | null; - /** The human-readable label/title shown to users */ - label: string | null; - /** The version name as a string (e.g., "1.2.3") */ - versionName: string | null; - /** The numeric version code for programmatic comparison */ - versionCode: number; - /** The non-localized label of the application */ - nonLocalizedLabel: string | null; - /** The app component factory class name (Android P+) */ - appComponentFactory: string | null; - /** The backup agent class name for app data backup */ - backupAgentName: string | null; - /** The app category (e.g., game, productivity) */ - category: number; - /** The main activity class name */ - className: string | null; - /** Compatible width limit in density-independent pixels */ - compatibleWidthLimitDp: number; - /** SDK version the app was compiled against (Android S+) */ - compileSdkVersion: number | null; - /** Codename of the SDK version (Android S+) */ - compileSdkVersionCodename: string | null; - /** Path to the app's private data directory */ - dataDir: string | null; - /** Description of the application */ - description: string | null; - /** Path to device-protected data directory */ - deviceProtectedDataDir: string | null; - /** Whether the application is enabled */ - enabled: boolean; - /** Various flags describing the application properties */ - flags: number; - /** Largest width limit in density-independent pixels */ - largestWidthLimitDp: number; - /** Activity name for managing app storage space */ - manageSpaceActivityName: string | null; - /** Minimum SDK version required by the app */ - minSdkVersion: number; - /** Path to the app's native library directory */ - nativeLibraryDir: string | null; - /** Permission required to access this app's components */ - permission: string | null; - /** Name of the process this app should run in */ - processName: string | null; - /** Path to the publicly accessible APK file */ - publicSourceDir: string | null; - /** Smallest screen width required in density-independent pixels */ - requiresSmallestWidthDp: number; - /** JSON string of shared library files */ - sharedLibraryFiles: string | null; - /** Path to the APK file */ - sourceDir: string | null; - /** UUID of the storage volume containing the app */ - storageUuid: string | null; - /** Target SDK version the app was designed for */ - targetSdkVersion: number; - /** Task affinity for activity grouping */ - taskAffinity: string | null; - /** Default theme resource ID */ - theme: number; - /** UI mode options */ - uiOptions: number; - /** User ID associated with this app */ - uid: number; - /** JSON string of split APK names */ - splitNames: string | null; - /** JSON string of split APK public source directories */ - splitPublicSourceDirs: string | null; - /** JSON string of split APK source directories */ - splitSourceDirs: string | null; -} - -/** - * Provides access to Android package management functionality. - * - * This interface allows you to query information about installed applications, - * retrieve app metadata, get application icons, and list installed packages. - * It's essential for building tools that need to inspect or manage Android apps. - */ -export interface PackageManager { - /** - * Gets detailed information about a specific application package. - * - * @param packageName The package name to look up (e.g., "com.example.app") - * @returns A JSON string containing WXApplicationInfo, or empty object "{}" if not found - */ - getApplicationInfo(packageName: string): string; - - /** - * Gets detailed information about a specific application package with flags. - * - * @param packageName The package name to look up - * @param flags Additional flags to control what information is retrieved - * @returns A JSON string containing WXApplicationInfo, or empty object "{}" if not found - */ - getApplicationInfo(packageName: string, flags: number): string; - - /** - * Gets detailed information about a specific application package with flags for a specific user. - * - * @param packageName The package name to look up - * @param flags Additional flags to control what information is retrieved - * @param userId The user ID to query packages for (useful for multi-user devices) - * @returns A JSON string containing WXApplicationInfo, or empty object "{}" if not found - */ - getApplicationInfo( - packageName: string, - flags: number, - userId: number - ): string; - - /** - * Gets a list of all installed package names on the device. - * - * @returns A JSON string containing an array of package names - */ - getInstalledPackages(): string; - - /** - * Gets a list of all installed package names with specific flags. - * - * @param flags Flags to filter which packages are included in the result - * @returns A JSON string containing an array of package names - */ - getInstalledPackages(flags: number): string; - - /** - * Gets a list of all installed package names for a specific user with flags. - * - * @param flags Flags to filter which packages are included in the result - * @param userId The user ID to query packages for - * @returns A JSON string containing an array of package names - */ - getInstalledPackages(flags: number, userId: number): string; - - /** - * Gets the application icon as a base64-encoded string. - * - * @param packageName The package name whose icon to retrieve - * @returns Base64-encoded image string, or null if the icon cannot be retrieved - */ - getApplicationIcon(packageName: string): string | null; - - /** - * Gets the application icon as a base64-encoded string with flags. - * - * @param packageName The package name whose icon to retrieve - * @param flags Additional flags for icon retrieval - * @returns Base64-encoded image string, or null if the icon cannot be retrieved - */ - getApplicationIcon(packageName: string, flags: number): string | null; - - /** - * Gets the application icon as a base64-encoded string for a specific user. - * - * @param packageName The package name whose icon to retrieve - * @param flags Additional flags for icon retrieval - * @param userId The user ID to query the icon for - * @returns Base64-encoded image string, or null if the icon cannot be retrieved - */ - getApplicationIcon( - packageName: string, - flags: number, - userId: number - ): string | null; -} diff --git a/ts/src/types/Process.ts b/ts/src/types/Process.ts deleted file mode 100644 index 2866aed..0000000 --- a/ts/src/types/Process.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Represents a running app or task in the system. - * - * This interface gives you basic info about a process — like what kind of rooting - * solution it's running under (on Android), whether it's still running, and where - * its app libraries are located. - * - * It's handy for building cross-platform tools or system monitors where you need - * to understand what's running on the device. - */ -export interface Process { - /** - * Returns the platform or rooting method this process is using on Android. - * Knowing this helps when you want to adjust behavior based on how root access is provided. - * - * You might see one of the following: - * - `'Magisk'`: A popular way to root Android without modifying the system partition. - * - `'KernelSU'`: Grants root by modifying the kernel itself; needs a special kernel. - * - `'KsuNext'`: An updated or custom version of KernelSU with better hiding and support. - * - `'APatch'`: A hybrid approach that mixes ideas from Magisk and KernelSU. - * - `'MKSU'`, `'SukiSU'`, `'RKSU'`: These are likely custom or forked root solutions. What they mean might depend on your setup. - * - `'NonRoot'`: The device isn't rooted or this process isn't running with root access. - * - `'Unknown'`: We couldn’t figure out what kind of platform this is. - * - * @returns {string} The name of the platform or rooting method. - */ - getPlatform(): string; - - /** - * Checks if this process is still running. - * - * @returns {boolean} `true` if it’s alive and active, `false` if it’s stopped or crashed. - */ - isAlive(): boolean; - - /** - * Gets the full path to the folder that holds this process's native libraries or binaries. - * This can be helpful if you need to load extra files, resources, or understand - * where the app is installed. - * - * @returns {string | null} The path to the app's library folder, or `null` if it can't be found - * (like if the process is dead or doesn't use a standard path). - */ - getApplicationLibraryDir(): string | null; -} diff --git a/ts/src/types/Pty.ts b/ts/src/types/Pty.ts deleted file mode 100644 index 44b3200..0000000 --- a/ts/src/types/Pty.ts +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Represents a pseudo-terminal (PTY) interface for starting terminal processes. - * - * @since v213 - */ -export interface Pty { - /** - * Starts a new PTY process with the specified shell, arguments, and environment variables. - * - * @param sh - The shell executable to run. - * @param argsJson - A JSON string representing the arguments to pass to the shell, or `null` if no arguments. - * @param envJson - A JSON string representing the environment variables, or `null` if no environment variables. - * @returns A {@link PtyInstance} representing the started PTY process, or `null` if the process could not be started. - */ - start( - sh: String, - argsJson: String | null, - envJson: String | null - ): PtyInstance | null; - - /** - * Starts a new PTY process with the specified shell, arguments, environment variables, and terminal size. - * - * @param sh - The shell executable to run. - * @param argsJson - A JSON string representing the arguments to pass to the shell. - * @param envJson - A JSON string representing the environment variables. - * @param cols - The number of columns for the terminal. - * @param rows - The number of rows for the terminal. - * @returns A {@link PtyInstance} representing the started PTY process, or `null` if the process could not be started. - */ - start( - sh: String, - argsJson: String, - envJson: String, - cols: number, - rows: number - ): PtyInstance | null; -} - -/** - * @internal - * - * Represents an instance of a pseudo-terminal (PTY). - * Provides methods to interact with the PTY, such as writing data, - * killing the process, and resizing the terminal window. - * - * @since v213 - */ -export interface PtyInstance { - /** - * Writes data to the PTY. - * @param data - The string data to be written to the terminal. - */ - write(data: String): void; - - /** - * Terminates the PTY process. - */ - kill(): void; - - /** - * Resizes the PTY terminal window. - * @param cols - The number of columns for the terminal. - * @param rows - The number of rows for the terminal. - */ - resize(cols: number, rows: number): void; -} diff --git a/ts/src/types/Reflect.ts b/ts/src/types/Reflect.ts deleted file mode 100644 index cd635ff..0000000 --- a/ts/src/types/Reflect.ts +++ /dev/null @@ -1,18 +0,0 @@ -export interface Reflect { - getClass(className: string): string | null; - newInstance(classId: string, argsJson: string | null): string | null; - callMethod( - objectId: string, - methodName: string, - argsJson: string | null - ): string | null; - callStaticMethod( - objectId: string, - methodName: string, - argsJson: string | null - ): string | null; - getField(objectId: string, fieldName: string): string | null; - setField(objectId: string, fieldName: string, value: string): boolean; - createProxy(interfaceName: string, methodsMapJson: string): string | null; - releaseObject(objectId: string): boolean; -} diff --git a/ts/src/types/global.ts b/ts/src/types/global.ts deleted file mode 100644 index 034db3e..0000000 --- a/ts/src/types/global.ts +++ /dev/null @@ -1,46 +0,0 @@ -import type { Module } from "./Module"; -import type { PackageManager } from "./PackageManager"; -import type { Process } from "./Process"; -import type { Pty } from "./Pty"; -import type { Reflect } from "./Reflect"; -import type { FileSystem } from "./FileSystem"; -import type { WXEventHandler } from "webuix"; -import type { FsStreamInterface } from "./FsStreamInterface"; - -export interface GlobalModules { - fs: FileSystem; - reflect: Reflect; - process: Process; - module: Module; - pty: Pty; - pm: PackageManager; -} - -export interface Global { - require(module: K | `wx:${K}`): GlobalModules[K] | undefined; -} - -export {}; - -declare global { - var _wxEventHandler: WXEventHandler | undefined | null; - - interface Window { - global: Global | null; - pm: PackageManager | null; - fs: FileSystem | null; - process: Process | null; - module: Module | null; - pty: Pty | null; - _wxEventHandler?: WXEventHandler | undefined | null; - FsInputStream?: FsStreamInterface; - FsOutputStream?: FsStreamInterface; - } -} - -declare module "webuix" { - interface WXEventMap { - ["pty-data"]: string; - ["pty-exit"]: number; - } -} diff --git a/ts/src/types/index.ts b/ts/src/types/index.ts deleted file mode 100644 index 7beaa42..0000000 --- a/ts/src/types/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Automatically generated by the bundler. DO NOT EDIT! - */ - -export type * from "./FileSystem"; -export type * from "./FileSystemInstance"; -export type * from "./Global"; -export type * from "./Module"; -export type * from "./PackageManager"; -export type * from "./Process"; -export type * from "./Pty"; -export type * from "./Reflect"; -export type * from "./FsStreamInterface"; \ No newline at end of file diff --git a/ts/tsconfig.json b/ts/tsconfig.json deleted file mode 100644 index dcb6145..0000000 --- a/ts/tsconfig.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "compilerOptions": { - // Enable latest features - "lib": ["ESNext", "DOM"], - "target": "ESNext", - "module": "ESNext", - "moduleDetection": "force", - "jsx": "react-jsx", - "allowJs": true, - - // Bundler mode - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, - "noEmit": true, - "noImplicitAny": false, - - // Best practices - "strict": true, - "skipLibCheck": true, - "noFallthroughCasesInSwitch": true, - - // Some stricter flags (disabled by default) - "noUnusedLocals": false, - "noUnusedParameters": false, - "noPropertyAccessFromIndexSignature": false - } -}