From 745bec927f6d3604eab9a4b0d393285d81f0843a Mon Sep 17 00:00:00 2001 From: Paul Abbott Date: Thu, 29 Apr 2021 23:37:56 -0400 Subject: [PATCH 1/3] added types --- package.json | 3 +- types/index.d.ts | 142 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 types/index.d.ts diff --git a/package.json b/package.json index 7bbf98f..b301c66 100644 --- a/package.json +++ b/package.json @@ -38,5 +38,6 @@ "bugs": { "url": "https://github.com/becvert/cordova-plugin-zeroconf/issues" }, - "homepage": "https://github.com/becvert/cordova-plugin-zeroconf" + "homepage": "https://github.com/becvert/cordova-plugin-zeroconf", + "types": "./types/index.d.ts" } \ No newline at end of file diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 0000000..17f9b6e --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,142 @@ +// Type definitions for Apache Cordova Zeroconf (mDNS) plugin +// Project: https://github.com/becvert/cordova-plugin-zeroconf + +declare namespace ZeroConfPlugin { + interface TxtRecord { + [key: string]: string + } + + /* service : { + 'domain' : 'local.', + 'type' : '_http._tcp.', + 'name': 'Becvert\'s iPad', + 'port' : 80, + 'hostname' : 'ipad-of-becvert.local', + 'ipv4Addresses' : [ '192.168.1.125' ], + 'ipv6Addresses' : [ '2001:0:5ef5:79fb:10cb:1dbf:3f57:feb0' ], + 'txtRecord' : { + 'foo' : 'bar' + } */ + interface Service { + domain: string; + type: string; + name: string; + port: number; + hostname: string; + ipv4Addresses: Array; + ipv6Addresses: Array; + txtRecord: TxtRecord; + } + + interface Result { + /** added, resolved, registered */ + action: string; + service: Service; + } + + interface ZeroConf { + /** This plugin allows you to browse and publish ZeroConf/Bonjour/mDNS services from applications developed using PhoneGap/Cordova 3.0 or newer and Ionic's Capacitor. */ + + /** any, ipv6 or ipv4 */ + registerAddressFamily: string; + /** any, ipv6 or ipv4 */ + watchAddressFamily: string; + + /** + * Returns this device's hostname. + * @param successCallback The callback that is called when the plugin returns the hostname. + * @param errorCallback A callback that is called when errors happen. + */ + getHostname( + successCallback: (hostname: string) => void, + errorCallback?: (error: string) => void): void; + + /** + * Publishes a new service. + * @param type + * @param domain + * @param name + * @param port + * @param txtRecord + * @param successCallback The callback that is called when the plugin completes successully. + * @param errorCallback A callback that is called when errors happen. + */ + register( + type: string, + domain: string, + name: string, + port: number, + txtRecord: TxtRecord, + successCallback: (result: Result) => void, + errorCallback?: (error: string) => void): void; + + /** + * Unregisters a service. + * @param type + * @param domain + * @param name + * @param successCallback The callback that is called when the plugin completes successully. + * @param errorCallback A callback that is called when errors happen. + */ + unregister( + type: string, + domain: string, + name: string, + successCallback: () => void, + errorCallback?: (error: string) => void): void; + + /** + * Unregisters all published services. + * @param successCallback The callback that is called when the plugin completes successully. + * @param errorCallback A callback that is called when errors happen. + */ + stop( + successCallback: () => void, + errorCallback?: (error: string) => void): void; + + /** + * Starts watching for services of the specified type. + * @param type + * @param domain + * @param successCallback The callback that is called when the plugin completes successully. Also called whenever a new service is discovered or resolved. + * @param errorCallback A callback that is called when errors happen. + */ + watch( + type: string, + domain: string, + successCallback: (result: Result) => void, + errorCallback?: (error: string) => void): void; + + /** + * Stops watching for services of the specified type. + * @param type + * @param domain + * @param successCallback The callback that is called when the plugin completes successully. Also called whenever a new service is discovered or resolved. + * @param errorCallback A callback that is called when errors happen. + */ + unwatch( + type: string, + domain: string, + successCallback: () => void, + errorCallback?: (error: string) => void): void; + + + /** + * Closes the service browser and stops watching. + * @param successCallback The callback that is called when the plugin completes successully. + * @param errorCallback A callback that is called when errors happen. + */ + close( + successCallback: () => void, + errorCallback?: (error: string) => void): void; + + /** + * Re-initializes the entire plugin, which resets the browsers and services. Use this if the WiFi network has changed while the app is running. + * @param successCallback The callback that is called when the plugin completes successully. + * @param errorCallback A callback that is called when errors happen. + */ + reInit( + successCallback: () => void, + errorCallback?: (error: string) => void): void; + } +} From 6bfcac68974a2cef42e56287ab161c9f1e88dd25 Mon Sep 17 00:00:00 2001 From: Paul Abbott Date: Wed, 7 Dec 2022 19:29:44 +0000 Subject: [PATCH 2/3] Remove dependency "cordova-plugin-add-swift-support" and it is supported by cordova now. --- plugin.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugin.xml b/plugin.xml index 46ac0da..835a8ec 100644 --- a/plugin.xml +++ b/plugin.xml @@ -37,11 +37,10 @@ - + - From f16dc55835545dfa0730bdc565f625644f927083 Mon Sep 17 00:00:00 2001 From: Paul Abbott Date: Wed, 7 Dec 2022 20:17:05 +0000 Subject: [PATCH 3/3] add SwiftVersion preference default (can override at project level config.xml if needed) --- plugin.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin.xml b/plugin.xml index 835a8ec..396c82e 100644 --- a/plugin.xml +++ b/plugin.xml @@ -36,6 +36,7 @@ +