@dawidzawada/bonjour-zeroconf 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/BonjourZeroconf.podspec +30 -0
  2. package/LICENSE +20 -0
  3. package/README.md +35 -0
  4. package/android/CMakeLists.txt +24 -0
  5. package/android/build.gradle +128 -0
  6. package/android/gradle.properties +5 -0
  7. package/android/src/main/AndroidManifest.xml +2 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  9. package/android/src/main/java/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourZeroconf+AddressResolver.kt +182 -0
  10. package/android/src/main/java/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourZeroconf+Listeners.kt +45 -0
  11. package/android/src/main/java/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourZeroconf.kt +183 -0
  12. package/android/src/main/java/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourZeroconfPackage.kt +22 -0
  13. package/ios/AddressResolverError.swift +20 -0
  14. package/ios/BonjourZeroconf+AddressResolver.swift +133 -0
  15. package/ios/BonjourZeroconf+Listeners.swift +26 -0
  16. package/ios/BonjourZeroconf.swift +201 -0
  17. package/ios/LocalNetworkAuthorization.swift +66 -0
  18. package/ios/LocalNetworkPermission+Listeners.swift +14 -0
  19. package/ios/LocalNetworkPermission.swift +41 -0
  20. package/ios/ServiceCache.swift +30 -0
  21. package/ios/Utils/Loggy.swift +37 -0
  22. package/lib/module/index.js +9 -0
  23. package/lib/module/index.js.map +1 -0
  24. package/lib/module/package.json +1 -0
  25. package/lib/module/permissions.ios.js +23 -0
  26. package/lib/module/permissions.ios.js.map +1 -0
  27. package/lib/module/permissions.js +9 -0
  28. package/lib/module/permissions.js.map +1 -0
  29. package/lib/module/specs/BonjourFail.js +9 -0
  30. package/lib/module/specs/BonjourFail.js.map +1 -0
  31. package/lib/module/specs/BonjourListener.js +2 -0
  32. package/lib/module/specs/BonjourListener.js.map +1 -0
  33. package/lib/module/specs/BonjourZeroconf.nitro.js +4 -0
  34. package/lib/module/specs/BonjourZeroconf.nitro.js.map +1 -0
  35. package/lib/module/specs/LocalNetworkPermission.nitro.js +4 -0
  36. package/lib/module/specs/LocalNetworkPermission.nitro.js.map +1 -0
  37. package/lib/module/specs/ScanResult.js +2 -0
  38. package/lib/module/specs/ScanResult.js.map +1 -0
  39. package/lib/module/useIsScanning.js +19 -0
  40. package/lib/module/useIsScanning.js.map +1 -0
  41. package/lib/typescript/package.json +1 -0
  42. package/lib/typescript/src/index.d.ts +9 -0
  43. package/lib/typescript/src/index.d.ts.map +1 -0
  44. package/lib/typescript/src/permissions.d.ts +3 -0
  45. package/lib/typescript/src/permissions.d.ts.map +1 -0
  46. package/lib/typescript/src/permissions.ios.d.ts +3 -0
  47. package/lib/typescript/src/permissions.ios.d.ts.map +1 -0
  48. package/lib/typescript/src/specs/BonjourFail.d.ts +6 -0
  49. package/lib/typescript/src/specs/BonjourFail.d.ts.map +1 -0
  50. package/lib/typescript/src/specs/BonjourListener.d.ts +4 -0
  51. package/lib/typescript/src/specs/BonjourListener.d.ts.map +1 -0
  52. package/lib/typescript/src/specs/BonjourZeroconf.nitro.d.ts +19 -0
  53. package/lib/typescript/src/specs/BonjourZeroconf.nitro.d.ts.map +1 -0
  54. package/lib/typescript/src/specs/LocalNetworkPermission.nitro.d.ts +9 -0
  55. package/lib/typescript/src/specs/LocalNetworkPermission.nitro.d.ts.map +1 -0
  56. package/lib/typescript/src/specs/ScanResult.d.ts +8 -0
  57. package/lib/typescript/src/specs/ScanResult.d.ts.map +1 -0
  58. package/lib/typescript/src/useIsScanning.d.ts +2 -0
  59. package/lib/typescript/src/useIsScanning.d.ts.map +1 -0
  60. package/nitro.json +20 -0
  61. package/nitrogen/generated/android/c++/JBonjourFail.hpp +62 -0
  62. package/nitrogen/generated/android/c++/JBonjourListener.hpp +68 -0
  63. package/nitrogen/generated/android/c++/JFunc_void.hpp +74 -0
  64. package/nitrogen/generated/android/c++/JFunc_void_BonjourFail.hpp +76 -0
  65. package/nitrogen/generated/android/c++/JFunc_void_bool.hpp +74 -0
  66. package/nitrogen/generated/android/c++/JFunc_void_std__vector_ScanResult_.hpp +97 -0
  67. package/nitrogen/generated/android/c++/JHybridBonjourZeroconfSpec.cpp +96 -0
  68. package/nitrogen/generated/android/c++/JHybridBonjourZeroconfSpec.hpp +69 -0
  69. package/nitrogen/generated/android/c++/JScanOptions.hpp +57 -0
  70. package/nitrogen/generated/android/c++/JScanResult.hpp +74 -0
  71. package/nitrogen/generated/android/dawidzawada_bonjourzeroconf+autolinking.cmake +82 -0
  72. package/nitrogen/generated/android/dawidzawada_bonjourzeroconf+autolinking.gradle +27 -0
  73. package/nitrogen/generated/android/dawidzawada_bonjourzeroconfOnLoad.cpp +52 -0
  74. package/nitrogen/generated/android/dawidzawada_bonjourzeroconfOnLoad.hpp +25 -0
  75. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourFail.kt +22 -0
  76. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourListener.kt +42 -0
  77. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void.kt +80 -0
  78. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void_BonjourFail.kt +80 -0
  79. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void_bool.kt +80 -0
  80. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void_std__vector_ScanResult_.kt +80 -0
  81. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/HybridBonjourZeroconfSpec.kt +90 -0
  82. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/ScanOptions.kt +38 -0
  83. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/ScanResult.kt +50 -0
  84. package/nitrogen/generated/android/kotlin/com/margelo/nitro/dawidzawada/bonjourzeroconf/dawidzawada_bonjourzeroconfOnLoad.kt +35 -0
  85. package/nitrogen/generated/ios/BonjourZeroconf+autolinking.rb +60 -0
  86. package/nitrogen/generated/ios/BonjourZeroconf-Swift-Cxx-Bridge.cpp +90 -0
  87. package/nitrogen/generated/ios/BonjourZeroconf-Swift-Cxx-Bridge.hpp +282 -0
  88. package/nitrogen/generated/ios/BonjourZeroconf-Swift-Cxx-Umbrella.hpp +65 -0
  89. package/nitrogen/generated/ios/BonjourZeroconfAutolinking.mm +41 -0
  90. package/nitrogen/generated/ios/BonjourZeroconfAutolinking.swift +40 -0
  91. package/nitrogen/generated/ios/c++/HybridBonjourZeroconfSpecSwift.cpp +11 -0
  92. package/nitrogen/generated/ios/c++/HybridBonjourZeroconfSpecSwift.hpp +120 -0
  93. package/nitrogen/generated/ios/c++/HybridLocalNetworkPermissionSpecSwift.cpp +11 -0
  94. package/nitrogen/generated/ios/c++/HybridLocalNetworkPermissionSpecSwift.hpp +87 -0
  95. package/nitrogen/generated/ios/swift/BonjourFail.swift +44 -0
  96. package/nitrogen/generated/ios/swift/BonjourListener.swift +47 -0
  97. package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  98. package/nitrogen/generated/ios/swift/Func_void_BonjourFail.swift +47 -0
  99. package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
  100. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
  101. package/nitrogen/generated/ios/swift/Func_void_std__vector_ScanResult_.swift +47 -0
  102. package/nitrogen/generated/ios/swift/HybridBonjourZeroconfSpec.swift +60 -0
  103. package/nitrogen/generated/ios/swift/HybridBonjourZeroconfSpec_cxx.swift +203 -0
  104. package/nitrogen/generated/ios/swift/HybridLocalNetworkPermissionSpec.swift +57 -0
  105. package/nitrogen/generated/ios/swift/HybridLocalNetworkPermissionSpec_cxx.swift +155 -0
  106. package/nitrogen/generated/ios/swift/ScanOptions.swift +48 -0
  107. package/nitrogen/generated/ios/swift/ScanResult.swift +149 -0
  108. package/nitrogen/generated/shared/c++/BonjourFail.hpp +63 -0
  109. package/nitrogen/generated/shared/c++/BonjourListener.hpp +75 -0
  110. package/nitrogen/generated/shared/c++/HybridBonjourZeroconfSpec.cpp +26 -0
  111. package/nitrogen/generated/shared/c++/HybridBonjourZeroconfSpec.hpp +80 -0
  112. package/nitrogen/generated/shared/c++/HybridLocalNetworkPermissionSpec.cpp +22 -0
  113. package/nitrogen/generated/shared/c++/HybridLocalNetworkPermissionSpec.hpp +66 -0
  114. package/nitrogen/generated/shared/c++/ScanOptions.hpp +75 -0
  115. package/nitrogen/generated/shared/c++/ScanResult.hpp +92 -0
  116. package/package.json +169 -0
  117. package/src/index.ts +22 -0
  118. package/src/permissions.ios.ts +27 -0
  119. package/src/permissions.ts +7 -0
  120. package/src/specs/BonjourFail.ts +5 -0
  121. package/src/specs/BonjourListener.ts +3 -0
  122. package/src/specs/BonjourZeroconf.nitro.ts +20 -0
  123. package/src/specs/LocalNetworkPermission.nitro.ts +7 -0
  124. package/src/specs/ScanResult.ts +7 -0
  125. package/src/useIsScanning.ts +17 -0
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=ScanResult.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["specs/ScanResult.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ import { useEffect, useState } from 'react';
4
+ import { Scanner } from "./index.js";
5
+ export const useIsScanning = () => {
6
+ const [scanRunning, setScanRunning] = useState(false);
7
+ useEffect(() => {
8
+ const {
9
+ remove
10
+ } = Scanner.listenForScanState(scanning => {
11
+ setScanRunning(scanning);
12
+ });
13
+ return () => {
14
+ remove();
15
+ };
16
+ }, []);
17
+ return scanRunning;
18
+ };
19
+ //# sourceMappingURL=useIsScanning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useState","Scanner","useIsScanning","scanRunning","setScanRunning","remove","listenForScanState","scanning"],"sourceRoot":"../../src","sources":["useIsScanning.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,OAAO,QAAQ,YAAS;AAEjC,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAM;EACjC,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGJ,QAAQ,CAAC,KAAK,CAAC;EAErDD,SAAS,CAAC,MAAM;IACd,MAAM;MAAEM;IAAO,CAAC,GAAGJ,OAAO,CAACK,kBAAkB,CAAEC,QAAQ,IAAK;MAC1DH,cAAc,CAACG,QAAQ,CAAC;IAC1B,CAAC,CAAC;IACF,OAAO,MAAM;MACXF,MAAM,CAAC,CAAC;IACV,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOF,WAAW;AACpB,CAAC","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,9 @@
1
+ import type { BonjourZeroconf } from './specs/BonjourZeroconf.nitro';
2
+ import { useIsScanning } from './useIsScanning';
3
+ import { type ScanResult } from './specs/ScanResult';
4
+ import { type ScanOptions } from './specs/BonjourZeroconf.nitro';
5
+ import { BonjourFail } from './specs/BonjourFail';
6
+ import { requestLocalNetworkPermission, useLocalNetworkPermission } from './permissions';
7
+ export declare const Scanner: BonjourZeroconf;
8
+ export { useIsScanning, requestLocalNetworkPermission, useLocalNetworkPermission, BonjourFail, type ScanResult, type ScanOptions, };
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EACL,6BAA6B,EAC7B,yBAAyB,EAC1B,MAAM,eAAe,CAAC;AAEvB,eAAO,MAAM,OAAO,iBACiD,CAAC;AAEtE,OAAO,EACL,aAAa,EACb,6BAA6B,EAC7B,yBAAyB,EACzB,WAAW,EACX,KAAK,UAAU,EACf,KAAK,WAAW,GACjB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const requestLocalNetworkPermission: () => Promise<boolean>;
2
+ export declare const useLocalNetworkPermission: () => (boolean | (() => Promise<boolean>))[];
3
+ //# sourceMappingURL=permissions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../../src/permissions.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6BAA6B,wBAEzC,CAAC;AAEF,eAAO,MAAM,yBAAyB,8CAErC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const requestLocalNetworkPermission: () => Promise<boolean>;
2
+ export declare const useLocalNetworkPermission: () => (boolean | (() => Promise<boolean>))[];
3
+ //# sourceMappingURL=permissions.ios.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissions.ios.d.ts","sourceRoot":"","sources":["../../../src/permissions.ios.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,6BAA6B,wBAEzC,CAAC;AAEF,eAAO,MAAM,yBAAyB,8CAarC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare enum BonjourFail {
2
+ RESOLVE_FAILED = 0,
3
+ EXTRACTION_FAILED = 1,
4
+ DISCOVERY_FAILED = 2
5
+ }
6
+ //# sourceMappingURL=BonjourFail.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BonjourFail.d.ts","sourceRoot":"","sources":["../../../../src/specs/BonjourFail.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,cAAc,IAAA;IACd,iBAAiB,IAAA;IACjB,gBAAgB,IAAA;CACjB"}
@@ -0,0 +1,4 @@
1
+ export interface BonjourListener {
2
+ remove: () => void;
3
+ }
4
+ //# sourceMappingURL=BonjourListener.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BonjourListener.d.ts","sourceRoot":"","sources":["../../../../src/specs/BonjourListener.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB"}
@@ -0,0 +1,19 @@
1
+ import type { HybridObject } from 'react-native-nitro-modules';
2
+ import type { BonjourFail } from './BonjourFail';
3
+ import type { BonjourListener } from './BonjourListener';
4
+ import type { ScanResult } from './ScanResult';
5
+ export interface ScanOptions {
6
+ addressResolveTimeout?: number;
7
+ }
8
+ export interface BonjourZeroconf extends HybridObject<{
9
+ ios: 'swift';
10
+ android: 'kotlin';
11
+ }> {
12
+ readonly isScanning: boolean;
13
+ scan(type: string, domain: string, options?: ScanOptions): void;
14
+ stop(): void;
15
+ listenForScanResults(onResult: (results: ScanResult[]) => void): BonjourListener;
16
+ listenForScanState(onChange: (isScanning: boolean) => void): BonjourListener;
17
+ listenForScanFail(onFail: (fail: BonjourFail) => void): BonjourListener;
18
+ }
19
+ //# sourceMappingURL=BonjourZeroconf.nitro.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BonjourZeroconf.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/BonjourZeroconf.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,WAAW,WAAW;IAC1B,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,eACf,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC;IACzD,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAChE,IAAI,IAAI,IAAI,CAAC;IACb,oBAAoB,CAClB,QAAQ,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,IAAI,GACxC,eAAe,CAAC;IACnB,kBAAkB,CAAC,QAAQ,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,GAAG,eAAe,CAAC;IAC7E,iBAAiB,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,GAAG,eAAe,CAAC;CACzE"}
@@ -0,0 +1,9 @@
1
+ import type { HybridObject } from 'react-native-nitro-modules';
2
+ import type { BonjourListener } from './BonjourListener';
3
+ export interface LocalNetworkPermission extends HybridObject<{
4
+ ios: 'swift';
5
+ }> {
6
+ requestPermission(): Promise<boolean>;
7
+ listenForPermission(onChange: (granted: boolean) => void): BonjourListener;
8
+ }
9
+ //# sourceMappingURL=LocalNetworkPermission.nitro.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalNetworkPermission.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/LocalNetworkPermission.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,WAAW,sBAAuB,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,OAAO,CAAA;CAAE,CAAC;IAC5E,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACtC,mBAAmB,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,GAAG,eAAe,CAAC;CAC5E"}
@@ -0,0 +1,8 @@
1
+ export interface ScanResult {
2
+ name: string;
3
+ ipv4?: string;
4
+ ipv6?: string;
5
+ hostname?: string;
6
+ port?: number;
7
+ }
8
+ //# sourceMappingURL=ScanResult.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScanResult.d.ts","sourceRoot":"","sources":["../../../../src/specs/ScanResult.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
@@ -0,0 +1,2 @@
1
+ export declare const useIsScanning: () => boolean;
2
+ //# sourceMappingURL=useIsScanning.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIsScanning.d.ts","sourceRoot":"","sources":["../../../src/useIsScanning.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,eAazB,CAAC"}
package/nitro.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "cxxNamespace": ["dawidzawada_bonjourzeroconf"],
3
+ "ios": {
4
+ "iosModuleName": "BonjourZeroconf"
5
+ },
6
+ "android": {
7
+ "androidNamespace": ["dawidzawada", "bonjourzeroconf"],
8
+ "androidCxxLibName": "dawidzawada_bonjourzeroconf"
9
+ },
10
+ "autolinking": {
11
+ "BonjourZeroconf": {
12
+ "swift": "BonjourZeroconf",
13
+ "kotlin": "BonjourZeroconf"
14
+ },
15
+ "LocalNetworkPermission": {
16
+ "swift": "LocalNetworkPermission"
17
+ }
18
+ },
19
+ "ignorePaths": ["node_modules"]
20
+ }
@@ -0,0 +1,62 @@
1
+ ///
2
+ /// JBonjourFail.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include "BonjourFail.hpp"
12
+
13
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf {
14
+
15
+ using namespace facebook;
16
+
17
+ /**
18
+ * The C++ JNI bridge between the C++ enum "BonjourFail" and the the Kotlin enum "BonjourFail".
19
+ */
20
+ struct JBonjourFail final: public jni::JavaClass<JBonjourFail> {
21
+ public:
22
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourFail;";
23
+
24
+ public:
25
+ /**
26
+ * Convert this Java/Kotlin-based enum to the C++ enum BonjourFail.
27
+ */
28
+ [[maybe_unused]]
29
+ [[nodiscard]]
30
+ BonjourFail toCpp() const {
31
+ static const auto clazz = javaClassStatic();
32
+ static const auto fieldOrdinal = clazz->getField<int>("value");
33
+ int ordinal = this->getFieldValue(fieldOrdinal);
34
+ return static_cast<BonjourFail>(ordinal);
35
+ }
36
+
37
+ public:
38
+ /**
39
+ * Create a Java/Kotlin-based enum with the given C++ enum's value.
40
+ */
41
+ [[maybe_unused]]
42
+ static jni::alias_ref<JBonjourFail> fromCpp(BonjourFail value) {
43
+ static const auto clazz = javaClassStatic();
44
+ static const auto fieldRESOLVE_FAILED = clazz->getStaticField<JBonjourFail>("RESOLVE_FAILED");
45
+ static const auto fieldEXTRACTION_FAILED = clazz->getStaticField<JBonjourFail>("EXTRACTION_FAILED");
46
+ static const auto fieldDISCOVERY_FAILED = clazz->getStaticField<JBonjourFail>("DISCOVERY_FAILED");
47
+
48
+ switch (value) {
49
+ case BonjourFail::RESOLVE_FAILED:
50
+ return clazz->getStaticFieldValue(fieldRESOLVE_FAILED);
51
+ case BonjourFail::EXTRACTION_FAILED:
52
+ return clazz->getStaticFieldValue(fieldEXTRACTION_FAILED);
53
+ case BonjourFail::DISCOVERY_FAILED:
54
+ return clazz->getStaticFieldValue(fieldDISCOVERY_FAILED);
55
+ default:
56
+ std::string stringValue = std::to_string(static_cast<int>(value));
57
+ throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
58
+ }
59
+ }
60
+ };
61
+
62
+ } // namespace margelo::nitro::dawidzawada_bonjourzeroconf
@@ -0,0 +1,68 @@
1
+ ///
2
+ /// JBonjourListener.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include "BonjourListener.hpp"
12
+
13
+ #include "JFunc_void.hpp"
14
+ #include <functional>
15
+
16
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf {
17
+
18
+ using namespace facebook;
19
+
20
+ /**
21
+ * The C++ JNI bridge between the C++ struct "BonjourListener" and the the Kotlin data class "BonjourListener".
22
+ */
23
+ struct JBonjourListener final: public jni::JavaClass<JBonjourListener> {
24
+ public:
25
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/dawidzawada/bonjourzeroconf/BonjourListener;";
26
+
27
+ public:
28
+ /**
29
+ * Convert this Java/Kotlin-based struct to the C++ struct BonjourListener by copying all values to C++.
30
+ */
31
+ [[maybe_unused]]
32
+ [[nodiscard]]
33
+ BonjourListener toCpp() const {
34
+ static const auto clazz = javaClassStatic();
35
+ static const auto fieldRemove = clazz->getField<JFunc_void::javaobject>("remove");
36
+ jni::local_ref<JFunc_void::javaobject> remove = this->getFieldValue(fieldRemove);
37
+ return BonjourListener(
38
+ [&]() -> std::function<void()> {
39
+ if (remove->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
40
+ auto downcast = jni::static_ref_cast<JFunc_void_cxx::javaobject>(remove);
41
+ return downcast->cthis()->getFunction();
42
+ } else {
43
+ auto removeRef = jni::make_global(remove);
44
+ return [removeRef]() -> void {
45
+ return removeRef->invoke();
46
+ };
47
+ }
48
+ }()
49
+ );
50
+ }
51
+
52
+ public:
53
+ /**
54
+ * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
55
+ */
56
+ [[maybe_unused]]
57
+ static jni::local_ref<JBonjourListener::javaobject> fromCpp(const BonjourListener& value) {
58
+ using JSignature = JBonjourListener(jni::alias_ref<JFunc_void::javaobject>);
59
+ static const auto clazz = javaClassStatic();
60
+ static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
61
+ return create(
62
+ clazz,
63
+ JFunc_void_cxx::fromCpp(value.remove)
64
+ );
65
+ }
66
+ };
67
+
68
+ } // namespace margelo::nitro::dawidzawada_bonjourzeroconf
@@ -0,0 +1,74 @@
1
+ ///
2
+ /// JFunc_void.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include <functional>
12
+
13
+ #include <functional>
14
+
15
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf {
16
+
17
+ using namespace facebook;
18
+
19
+ /**
20
+ * Represents the Java/Kotlin callback `() -> Unit`.
21
+ * This can be passed around between C++ and Java/Kotlin.
22
+ */
23
+ struct JFunc_void: public jni::JavaClass<JFunc_void> {
24
+ public:
25
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void;";
26
+
27
+ public:
28
+ /**
29
+ * Invokes the function this `JFunc_void` instance holds through JNI.
30
+ */
31
+ void invoke() const {
32
+ static const auto method = javaClassStatic()->getMethod<void()>("invoke");
33
+ method(self());
34
+ }
35
+ };
36
+
37
+ /**
38
+ * An implementation of Func_void that is backed by a C++ implementation (using `std::function<...>`)
39
+ */
40
+ struct JFunc_void_cxx final: public jni::HybridClass<JFunc_void_cxx, JFunc_void> {
41
+ public:
42
+ static jni::local_ref<JFunc_void::javaobject> fromCpp(const std::function<void()>& func) {
43
+ return JFunc_void_cxx::newObjectCxxArgs(func);
44
+ }
45
+
46
+ public:
47
+ /**
48
+ * Invokes the C++ `std::function<...>` this `JFunc_void_cxx` instance holds.
49
+ */
50
+ void invoke_cxx() {
51
+ _func();
52
+ }
53
+
54
+ public:
55
+ [[nodiscard]]
56
+ inline const std::function<void()>& getFunction() const {
57
+ return _func;
58
+ }
59
+
60
+ public:
61
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void_cxx;";
62
+ static void registerNatives() {
63
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_cxx::invoke_cxx)});
64
+ }
65
+
66
+ private:
67
+ explicit JFunc_void_cxx(const std::function<void()>& func): _func(func) { }
68
+
69
+ private:
70
+ friend HybridBase;
71
+ std::function<void()> _func;
72
+ };
73
+
74
+ } // namespace margelo::nitro::dawidzawada_bonjourzeroconf
@@ -0,0 +1,76 @@
1
+ ///
2
+ /// JFunc_void_BonjourFail.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include <functional>
12
+
13
+ #include "BonjourFail.hpp"
14
+ #include <functional>
15
+ #include "JBonjourFail.hpp"
16
+
17
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf {
18
+
19
+ using namespace facebook;
20
+
21
+ /**
22
+ * Represents the Java/Kotlin callback `(fail: BonjourFail) -> Unit`.
23
+ * This can be passed around between C++ and Java/Kotlin.
24
+ */
25
+ struct JFunc_void_BonjourFail: public jni::JavaClass<JFunc_void_BonjourFail> {
26
+ public:
27
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void_BonjourFail;";
28
+
29
+ public:
30
+ /**
31
+ * Invokes the function this `JFunc_void_BonjourFail` instance holds through JNI.
32
+ */
33
+ void invoke(BonjourFail fail) const {
34
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JBonjourFail> /* fail */)>("invoke");
35
+ method(self(), JBonjourFail::fromCpp(fail));
36
+ }
37
+ };
38
+
39
+ /**
40
+ * An implementation of Func_void_BonjourFail that is backed by a C++ implementation (using `std::function<...>`)
41
+ */
42
+ struct JFunc_void_BonjourFail_cxx final: public jni::HybridClass<JFunc_void_BonjourFail_cxx, JFunc_void_BonjourFail> {
43
+ public:
44
+ static jni::local_ref<JFunc_void_BonjourFail::javaobject> fromCpp(const std::function<void(BonjourFail /* fail */)>& func) {
45
+ return JFunc_void_BonjourFail_cxx::newObjectCxxArgs(func);
46
+ }
47
+
48
+ public:
49
+ /**
50
+ * Invokes the C++ `std::function<...>` this `JFunc_void_BonjourFail_cxx` instance holds.
51
+ */
52
+ void invoke_cxx(jni::alias_ref<JBonjourFail> fail) {
53
+ _func(fail->toCpp());
54
+ }
55
+
56
+ public:
57
+ [[nodiscard]]
58
+ inline const std::function<void(BonjourFail /* fail */)>& getFunction() const {
59
+ return _func;
60
+ }
61
+
62
+ public:
63
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void_BonjourFail_cxx;";
64
+ static void registerNatives() {
65
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_BonjourFail_cxx::invoke_cxx)});
66
+ }
67
+
68
+ private:
69
+ explicit JFunc_void_BonjourFail_cxx(const std::function<void(BonjourFail /* fail */)>& func): _func(func) { }
70
+
71
+ private:
72
+ friend HybridBase;
73
+ std::function<void(BonjourFail /* fail */)> _func;
74
+ };
75
+
76
+ } // namespace margelo::nitro::dawidzawada_bonjourzeroconf
@@ -0,0 +1,74 @@
1
+ ///
2
+ /// JFunc_void_bool.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include <functional>
12
+
13
+ #include <functional>
14
+
15
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf {
16
+
17
+ using namespace facebook;
18
+
19
+ /**
20
+ * Represents the Java/Kotlin callback `(isScanning: Boolean) -> Unit`.
21
+ * This can be passed around between C++ and Java/Kotlin.
22
+ */
23
+ struct JFunc_void_bool: public jni::JavaClass<JFunc_void_bool> {
24
+ public:
25
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void_bool;";
26
+
27
+ public:
28
+ /**
29
+ * Invokes the function this `JFunc_void_bool` instance holds through JNI.
30
+ */
31
+ void invoke(bool isScanning) const {
32
+ static const auto method = javaClassStatic()->getMethod<void(jboolean /* isScanning */)>("invoke");
33
+ method(self(), isScanning);
34
+ }
35
+ };
36
+
37
+ /**
38
+ * An implementation of Func_void_bool that is backed by a C++ implementation (using `std::function<...>`)
39
+ */
40
+ struct JFunc_void_bool_cxx final: public jni::HybridClass<JFunc_void_bool_cxx, JFunc_void_bool> {
41
+ public:
42
+ static jni::local_ref<JFunc_void_bool::javaobject> fromCpp(const std::function<void(bool /* isScanning */)>& func) {
43
+ return JFunc_void_bool_cxx::newObjectCxxArgs(func);
44
+ }
45
+
46
+ public:
47
+ /**
48
+ * Invokes the C++ `std::function<...>` this `JFunc_void_bool_cxx` instance holds.
49
+ */
50
+ void invoke_cxx(jboolean isScanning) {
51
+ _func(static_cast<bool>(isScanning));
52
+ }
53
+
54
+ public:
55
+ [[nodiscard]]
56
+ inline const std::function<void(bool /* isScanning */)>& getFunction() const {
57
+ return _func;
58
+ }
59
+
60
+ public:
61
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void_bool_cxx;";
62
+ static void registerNatives() {
63
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_bool_cxx::invoke_cxx)});
64
+ }
65
+
66
+ private:
67
+ explicit JFunc_void_bool_cxx(const std::function<void(bool /* isScanning */)>& func): _func(func) { }
68
+
69
+ private:
70
+ friend HybridBase;
71
+ std::function<void(bool /* isScanning */)> _func;
72
+ };
73
+
74
+ } // namespace margelo::nitro::dawidzawada_bonjourzeroconf
@@ -0,0 +1,97 @@
1
+ ///
2
+ /// JFunc_void_std__vector_ScanResult_.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include <functional>
12
+
13
+ #include "ScanResult.hpp"
14
+ #include <vector>
15
+ #include <functional>
16
+ #include "JScanResult.hpp"
17
+ #include <string>
18
+ #include <optional>
19
+
20
+ namespace margelo::nitro::dawidzawada_bonjourzeroconf {
21
+
22
+ using namespace facebook;
23
+
24
+ /**
25
+ * Represents the Java/Kotlin callback `(results: Array<ScanResult>) -> Unit`.
26
+ * This can be passed around between C++ and Java/Kotlin.
27
+ */
28
+ struct JFunc_void_std__vector_ScanResult_: public jni::JavaClass<JFunc_void_std__vector_ScanResult_> {
29
+ public:
30
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void_std__vector_ScanResult_;";
31
+
32
+ public:
33
+ /**
34
+ * Invokes the function this `JFunc_void_std__vector_ScanResult_` instance holds through JNI.
35
+ */
36
+ void invoke(const std::vector<ScanResult>& results) const {
37
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JArrayClass<JScanResult>> /* results */)>("invoke");
38
+ method(self(), [&]() {
39
+ size_t __size = results.size();
40
+ jni::local_ref<jni::JArrayClass<JScanResult>> __array = jni::JArrayClass<JScanResult>::newArray(__size);
41
+ for (size_t __i = 0; __i < __size; __i++) {
42
+ const auto& __element = results[__i];
43
+ auto __elementJni = JScanResult::fromCpp(__element);
44
+ __array->setElement(__i, *__elementJni);
45
+ }
46
+ return __array;
47
+ }());
48
+ }
49
+ };
50
+
51
+ /**
52
+ * An implementation of Func_void_std__vector_ScanResult_ that is backed by a C++ implementation (using `std::function<...>`)
53
+ */
54
+ struct JFunc_void_std__vector_ScanResult__cxx final: public jni::HybridClass<JFunc_void_std__vector_ScanResult__cxx, JFunc_void_std__vector_ScanResult_> {
55
+ public:
56
+ static jni::local_ref<JFunc_void_std__vector_ScanResult_::javaobject> fromCpp(const std::function<void(const std::vector<ScanResult>& /* results */)>& func) {
57
+ return JFunc_void_std__vector_ScanResult__cxx::newObjectCxxArgs(func);
58
+ }
59
+
60
+ public:
61
+ /**
62
+ * Invokes the C++ `std::function<...>` this `JFunc_void_std__vector_ScanResult__cxx` instance holds.
63
+ */
64
+ void invoke_cxx(jni::alias_ref<jni::JArrayClass<JScanResult>> results) {
65
+ _func([&]() {
66
+ size_t __size = results->size();
67
+ std::vector<ScanResult> __vector;
68
+ __vector.reserve(__size);
69
+ for (size_t __i = 0; __i < __size; __i++) {
70
+ auto __element = results->getElement(__i);
71
+ __vector.push_back(__element->toCpp());
72
+ }
73
+ return __vector;
74
+ }());
75
+ }
76
+
77
+ public:
78
+ [[nodiscard]]
79
+ inline const std::function<void(const std::vector<ScanResult>& /* results */)>& getFunction() const {
80
+ return _func;
81
+ }
82
+
83
+ public:
84
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/dawidzawada/bonjourzeroconf/Func_void_std__vector_ScanResult__cxx;";
85
+ static void registerNatives() {
86
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_std__vector_ScanResult__cxx::invoke_cxx)});
87
+ }
88
+
89
+ private:
90
+ explicit JFunc_void_std__vector_ScanResult__cxx(const std::function<void(const std::vector<ScanResult>& /* results */)>& func): _func(func) { }
91
+
92
+ private:
93
+ friend HybridBase;
94
+ std::function<void(const std::vector<ScanResult>& /* results */)> _func;
95
+ };
96
+
97
+ } // namespace margelo::nitro::dawidzawada_bonjourzeroconf