2 Commits

Author SHA1 Message Date
4ac19b8be0 fix: update index.js & index.d.ts 2025-05-26 17:20:03 +10:00
072a1584a0 feat: add list files command 2025-05-26 15:02:41 +10:00
4 changed files with 13 additions and 3 deletions

1
index.d.ts vendored
View File

@ -4,6 +4,7 @@
/* auto-generated by NAPI-RS */
export declare function hasBackendForPath(path: string): boolean
export declare function listFiles(path: string): Array<string>
export declare function callAltThreadFunc(callback: (...args: any[]) => any): void
export declare function generateManifest(dir: string, progress: (...args: any[]) => any, log: (...args: any[]) => any, callback: (...args: any[]) => any): void
export declare function generateRootCa(): Array<string>

View File

@ -310,9 +310,10 @@ if (!nativeBinding) {
throw new Error(`Failed to load native binding`)
}
const { hasBackendForPath, callAltThreadFunc, generateManifest, generateRootCa, generateClientCertificate, verifyClientCertificate, signNonce, verifyNonce } = nativeBinding
const { hasBackendForPath, listFiles, callAltThreadFunc, generateManifest, generateRootCa, generateClientCertificate, verifyClientCertificate, signNonce, verifyNonce } = nativeBinding
module.exports.hasBackendForPath = hasBackendForPath
module.exports.listFiles = listFiles
module.exports.callAltThreadFunc = callAltThreadFunc
module.exports.generateManifest = generateManifest
module.exports.generateRootCa = generateRootCa

View File

@ -1,6 +1,6 @@
{
"name": "@drop-oss/droplet",
"version": "1.0.0",
"version": "1.1.1",
"main": "index.js",
"types": "index.d.ts",
"napi": {
@ -42,6 +42,6 @@
},
"packageManager": "yarn@4.7.0",
"repository": {
"url": "https://github.com/Drop-OSS/droplet"
"url": "git+https://github.com/Drop-OSS/droplet.git"
}
}

View File

@ -110,3 +110,11 @@ pub fn has_backend_for_path(path: String) -> bool {
has_backend
}
#[napi]
pub fn list_files(path: String) -> Vec<String> {
let path = Path::new(&path);
let backend = create_backend_for_path(path).unwrap();
let files = backend.list_files(path);
files.into_iter().map(|e| e.relative_filename).collect()
}