react-native-zeroconf 0.17.2 → 1.0.0-rc.1

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 (117) hide show
  1. package/NOTICE +2 -6
  2. package/README.md +1 -1
  3. package/android/CMakeLists.txt +64 -0
  4. package/android/build.gradle +1 -13
  5. package/android/generated/java/com/balthazargronon/RCTZeroconf/NativeZeroconfSpec.java +96 -0
  6. package/android/generated/jni/CMakeLists.txt +28 -0
  7. package/android/generated/jni/RNZeroconfSpec-generated.cpp +77 -0
  8. package/android/generated/jni/RNZeroconfSpec.h +31 -0
  9. package/android/generated/jni/react/renderer/components/RNZeroconfSpec/RNZeroconfSpecJSI.h +798 -0
  10. package/android/src/main/java/com/balthazargronon/RCTZeroconf/{ZeroconfModule.java → NsdHost.java} +97 -140
  11. package/android/src/main/java/com/balthazargronon/RCTZeroconf/NsdPayload.java +87 -0
  12. package/android/src/main/java/com/balthazargronon/RCTZeroconf/NsdPromise.java +40 -0
  13. package/android/src/main/java/com/balthazargronon/RCTZeroconf/Zeroconf.java +4 -6
  14. package/android/src/main/java/com/balthazargronon/RCTZeroconf/ZeroconfNativeSupport.java +60 -0
  15. package/android/src/main/java/com/balthazargronon/RCTZeroconf/ZeroconfOptions.java +15 -26
  16. package/android/src/main/java/com/balthazargronon/RCTZeroconf/ZeroconfReactPackage.java +5 -15
  17. package/android/src/main/java/com/balthazargronon/RCTZeroconf/nsd/NsdServiceImpl.java +90 -96
  18. package/android/src/main/jni/mdnsresponder/mDNSPosix/PosixDaemon.c +19 -1
  19. package/android/src/main/jni/mdnsresponder/mDNSPosix/mDNSPosix.c +104 -1
  20. package/android/src/main/jni/mdnsresponder/mDNSPosix/mDNSPosix.h +7 -0
  21. package/android/src/main/jni/mdnsresponder/mDNSShared/dnssd_clientshim.c +34 -9
  22. package/cpp/Backend.cpp +16 -0
  23. package/cpp/Backend.h +116 -0
  24. package/cpp/ZeroconfModule.cpp +280 -0
  25. package/cpp/ZeroconfModule.h +144 -0
  26. package/cpp/android/NsdBackend.cpp +462 -0
  27. package/cpp/android/NsdBackend.h +61 -0
  28. package/cpp/android/ZeroconfAndroidModule.cpp +49 -0
  29. package/cpp/android/ZeroconfAndroidModule.h +15 -0
  30. package/cpp/apple/DispatchExecutor.cpp +66 -0
  31. package/cpp/apple/DispatchExecutor.h +37 -0
  32. package/cpp/apple/LocalNetworkAccess.h +19 -0
  33. package/cpp/apple/LocalNetworkAccess.mm +87 -0
  34. package/cpp/dnssd/DnssdBackend.cpp +976 -0
  35. package/cpp/dnssd/DnssdBackend.h +114 -0
  36. package/cpp/dnssd/Executor.h +28 -0
  37. package/cpp/embedded/EmbeddedExecutor.cpp +124 -0
  38. package/cpp/embedded/EmbeddedExecutor.h +57 -0
  39. package/ios/ZeroconfOnLoad.mm +34 -0
  40. package/ios/generated/ReactCodegen/RNZeroconfSpec/RNZeroconfSpec-generated.mm +140 -0
  41. package/ios/generated/ReactCodegen/RNZeroconfSpec/RNZeroconfSpec.h +189 -0
  42. package/ios/generated/ReactCodegen/RNZeroconfSpecJSI.h +798 -0
  43. package/lib/module/NativeZeroconf.js +15 -0
  44. package/lib/module/NativeZeroconf.js.map +1 -0
  45. package/lib/module/bridge.js +124 -0
  46. package/lib/module/bridge.js.map +1 -0
  47. package/{dist → lib/module}/index.js +149 -149
  48. package/lib/module/index.js.map +1 -0
  49. package/lib/module/package.json +1 -0
  50. package/lib/module/types.js +24 -0
  51. package/lib/module/types.js.map +1 -0
  52. package/lib/typescript/package.json +1 -0
  53. package/lib/typescript/src/NativeZeroconf.d.ts +75 -0
  54. package/lib/typescript/src/NativeZeroconf.d.ts.map +1 -0
  55. package/lib/typescript/src/bridge.d.ts +22 -0
  56. package/lib/typescript/src/bridge.d.ts.map +1 -0
  57. package/lib/typescript/src/index.d.ts +111 -0
  58. package/lib/typescript/src/index.d.ts.map +1 -0
  59. package/lib/typescript/src/types.d.ts +175 -0
  60. package/lib/typescript/src/types.d.ts.map +1 -0
  61. package/package.json +65 -29
  62. package/react-native-zeroconf.podspec +2 -1
  63. package/react-native.config.js +17 -0
  64. package/src/NativeZeroconf.ts +120 -0
  65. package/src/bridge.ts +153 -0
  66. package/src/index.ts +607 -0
  67. package/{index.d.ts → src/types.ts} +5 -99
  68. package/windows/RNZeroconf/RNZeroconf.vcxproj +17 -2
  69. package/windows/RNZeroconf/RNZeroconf.vcxproj.filters +0 -6
  70. package/windows/RNZeroconf/ReactPackageProvider.cpp +23 -20
  71. package/windows/RNZeroconf/WindowsBackend.cpp +156 -0
  72. package/windows/RNZeroconf/WindowsBackend.h +13 -0
  73. package/windows/RNZeroconf/ZeroconfCore.cpp +2 -2
  74. package/windows/RNZeroconf/ZeroconfCore.h +2 -2
  75. package/windows/RNZeroconf/ZeroconfWindowsModule.cpp +22 -0
  76. package/windows/RNZeroconf/ZeroconfWindowsModule.h +14 -0
  77. package/android/src/main/java/com/balthazargronon/RCTZeroconf/ZeroConfImplFactory.java +0 -56
  78. package/android/src/main/java/com/balthazargronon/RCTZeroconf/dnssd/DnssdImpl.java +0 -654
  79. package/android/src/main/java/com/github/druk/dnssd/BaseListener.java +0 -33
  80. package/android/src/main/java/com/github/druk/dnssd/BrowseListener.java +0 -67
  81. package/android/src/main/java/com/github/druk/dnssd/DNSRecord.java +0 -47
  82. package/android/src/main/java/com/github/druk/dnssd/DNSSD.java +0 -650
  83. package/android/src/main/java/com/github/druk/dnssd/DNSSDEmbedded.java +0 -135
  84. package/android/src/main/java/com/github/druk/dnssd/DNSSDException.java +0 -66
  85. package/android/src/main/java/com/github/druk/dnssd/DNSSDRecordRegistrar.java +0 -55
  86. package/android/src/main/java/com/github/druk/dnssd/DNSSDRegistration.java +0 -54
  87. package/android/src/main/java/com/github/druk/dnssd/DNSSDService.java +0 -35
  88. package/android/src/main/java/com/github/druk/dnssd/DomainListener.java +0 -57
  89. package/android/src/main/java/com/github/druk/dnssd/InternalBrowseListener.java +0 -76
  90. package/android/src/main/java/com/github/druk/dnssd/InternalDNSSD.java +0 -870
  91. package/android/src/main/java/com/github/druk/dnssd/InternalDNSSDRecordRegistrar.java +0 -30
  92. package/android/src/main/java/com/github/druk/dnssd/InternalDNSSDRegistration.java +0 -34
  93. package/android/src/main/java/com/github/druk/dnssd/InternalDNSSDService.java +0 -29
  94. package/android/src/main/java/com/github/druk/dnssd/InternalDomainListener.java +0 -62
  95. package/android/src/main/java/com/github/druk/dnssd/InternalQueryListener.java +0 -61
  96. package/android/src/main/java/com/github/druk/dnssd/InternalRegisterListener.java +0 -51
  97. package/android/src/main/java/com/github/druk/dnssd/InternalResolveListener.java +0 -58
  98. package/android/src/main/java/com/github/druk/dnssd/NSClass.java +0 -16
  99. package/android/src/main/java/com/github/druk/dnssd/NSType.java +0 -58
  100. package/android/src/main/java/com/github/druk/dnssd/QueryListener.java +0 -54
  101. package/android/src/main/java/com/github/druk/dnssd/RegisterListener.java +0 -46
  102. package/android/src/main/java/com/github/druk/dnssd/RegisterRecordListener.java +0 -35
  103. package/android/src/main/java/com/github/druk/dnssd/ResolveListener.java +0 -55
  104. package/android/src/main/java/com/github/druk/dnssd/TXTRecord.java +0 -293
  105. package/android/src/main/jni/Android.mk +0 -73
  106. package/android/src/main/jni/Application.mk +0 -3
  107. package/android/src/main/jni/DNSSD.java.h +0 -290
  108. package/android/src/main/jni/JNISupport.c +0 -1140
  109. package/ios/RNZeroconf/RNNetServiceSerializer.h +0 -31
  110. package/ios/RNZeroconf/RNNetServiceSerializer.m +0 -84
  111. package/ios/RNZeroconf/RNZeroconf.h +0 -17
  112. package/ios/RNZeroconf/RNZeroconf.m +0 -1025
  113. package/ios/RNZeroconf.xcodeproj/project.pbxproj +0 -261
  114. package/ios/RNZeroconf.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  115. package/src/index.js +0 -563
  116. package/windows/RNZeroconf/RNZeroconf.cpp +0 -228
  117. package/windows/RNZeroconf/RNZeroconf.h +0 -70
@@ -0,0 +1,75 @@
1
+ import { type CodegenTypes, type TurboModule } from 'react-native';
2
+ export type TxtEntry = {
3
+ key: string;
4
+ value: string;
5
+ };
6
+ export type NativeService = {
7
+ name: string;
8
+ fullName: string;
9
+ host: string;
10
+ port: number;
11
+ addresses: string[];
12
+ txt: TxtEntry[];
13
+ };
14
+ export type NativeError = {
15
+ message: string;
16
+ code: string;
17
+ domain: string;
18
+ serviceName: string;
19
+ };
20
+ export type NativeResult = {
21
+ service?: NativeService;
22
+ error?: NativeError;
23
+ };
24
+ export type NativeAccessResult = {
25
+ status?: string;
26
+ error?: NativeError;
27
+ };
28
+ export type ScanEvent = {
29
+ scanId: string;
30
+ };
31
+ export type NameEvent = {
32
+ scanId: string;
33
+ name: string;
34
+ };
35
+ export type ResolvedEvent = {
36
+ scanId: string;
37
+ service: NativeService;
38
+ };
39
+ export type ErrorEvent = {
40
+ scanId: string;
41
+ error: NativeError;
42
+ };
43
+ export type NativeScanOptions = {
44
+ resolveTimeout?: number;
45
+ subtype?: string;
46
+ networkInterface?: string;
47
+ };
48
+ export type NativePublishOptions = {
49
+ subtypes?: string[];
50
+ networkInterface?: string;
51
+ };
52
+ export type NativeResolveOptions = {
53
+ timeout?: number;
54
+ networkInterface?: string;
55
+ };
56
+ export interface Spec extends TurboModule {
57
+ scan(scanId: string, type: string, protocol: string, domain: string, implType: string, options: NativeScanOptions): void;
58
+ stop(scanId: string, implType: string): void;
59
+ registerService(type: string, protocol: string, domain: string, name: string, port: number, txt: TxtEntry[], implType: string, options: NativePublishOptions): Promise<NativeResult>;
60
+ updateService(name: string, txt: TxtEntry[], implType: string): Promise<NativeResult>;
61
+ unregisterService(name: string, implType: string): Promise<NativeResult>;
62
+ resolveService(name: string, type: string, protocol: string, domain: string, implType: string, options: NativeResolveOptions): Promise<NativeResult>;
63
+ checkLocalNetworkAccess(type: string, timeout: number): Promise<NativeAccessResult>;
64
+ readonly onStart: CodegenTypes.EventEmitter<ScanEvent>;
65
+ readonly onStop: CodegenTypes.EventEmitter<ScanEvent>;
66
+ readonly onFound: CodegenTypes.EventEmitter<NameEvent>;
67
+ readonly onRemove: CodegenTypes.EventEmitter<NameEvent>;
68
+ readonly onResolved: CodegenTypes.EventEmitter<ResolvedEvent>;
69
+ readonly onError: CodegenTypes.EventEmitter<ErrorEvent>;
70
+ readonly onPublished: CodegenTypes.EventEmitter<NativeService>;
71
+ readonly onUnpublished: CodegenTypes.EventEmitter<NativeService>;
72
+ }
73
+ declare const _default: Spec | null;
74
+ export default _default;
75
+ //# sourceMappingURL=NativeZeroconf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeZeroconf.d.ts","sourceRoot":"","sources":["../../../src/NativeZeroconf.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuB,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAA;AAEvF,MAAM,MAAM,QAAQ,GAAG;IACrB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,GAAG,EAAE,QAAQ,EAAE,CAAA;CAChB,CAAA;AAGD,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAGD,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,KAAK,CAAC,EAAE,WAAW,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,WAAW,CAAA;CACpB,CAAA;AA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0 +1,22 @@
1
+ import type { ImplType, PublishedService, Service } from './types.js';
2
+ export type LocalNetworkAccess = 'granted' | 'denied' | 'unknown';
3
+ export type BridgeEvent = 'start' | 'stop' | 'found' | 'remove' | 'resolved' | 'error' | 'published' | 'unpublished';
4
+ export interface BridgePayload {
5
+ scanId?: string;
6
+ name?: string;
7
+ [key: string]: unknown;
8
+ }
9
+ export interface Bridge {
10
+ scan(scanId: string, type: string, protocol: string, domain: string, implType: ImplType, options: Record<string, unknown>): void;
11
+ stop(scanId: string, implType: ImplType): void;
12
+ registerService(type: string, protocol: string, domain: string, name: string, port: number, txt: Array<[string, string]>, implType: ImplType, options: Record<string, unknown>): Promise<PublishedService>;
13
+ updateService(name: string, txt: Array<[string, string]>, implType: ImplType): Promise<PublishedService>;
14
+ unregisterService(name: string, implType: ImplType): Promise<PublishedService | null>;
15
+ resolveService(name: string, type: string, protocol: string, domain: string, implType: ImplType, options: Record<string, unknown>): Promise<Omit<Service, 'ipv4' | 'ipv6'> | null>;
16
+ checkLocalNetworkAccess(type: string | null, timeout: number): Promise<LocalNetworkAccess>;
17
+ listen(event: BridgeEvent, handler: (payload: BridgePayload) => void): {
18
+ remove(): void;
19
+ };
20
+ }
21
+ export declare const getBridge: () => Bridge | null;
22
+ //# sourceMappingURL=bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../../src/bridge.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,OAAO,EAAiB,MAAM,YAAS,CAAA;AAEjF,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAA;AAEjE,MAAM,MAAM,WAAW,GACrB,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,WAAW,GAAG,aAAa,CAAA;AAI5F,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,M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OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC,CAAA;IAEjD,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAA;IAC1F,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,GAAG;QAAE,MAAM,IAAI,IAAI,CAAA;KAAE,CAAA;CAC1F;AA4FD,eAAO,MAAM,SAAS,QAAO,MAAM,GAAG,IAA6D,CAAA"}
@@ -0,0 +1,111 @@
1
+ import { EventEmitter } from 'events';
2
+ import { type LocalNetworkAccess } from './bridge.js';
3
+ import { ImplType, type LocalNetworkAccessOptions, type PublishedService, type PublishOptions, type ResolveOptions, type ScanOptions, type Service, type ServiceType, type ServiceTypesScanOptions, type UpdateOptions, type UseServiceTypesOptions, type UseServiceTypesResult, type UseZeroconfOptions, type UseZeroconfResult, type ZeroconfEvents } from './types.js';
4
+ export * from './types.js';
5
+ type Listener<E extends keyof ZeroconfEvents> = ZeroconfEvents[E];
6
+ interface Zeroconf {
7
+ on<E extends keyof ZeroconfEvents>(event: E, listener: Listener<E>): this;
8
+ once<E extends keyof ZeroconfEvents>(event: E, listener: Listener<E>): this;
9
+ addListener<E extends keyof ZeroconfEvents>(event: E, listener: Listener<E>): this;
10
+ removeListener<E extends keyof ZeroconfEvents>(event: E, listener: Listener<E>): this;
11
+ off<E extends keyof ZeroconfEvents>(event: E, listener: Listener<E>): this;
12
+ removeAllListeners(event?: keyof ZeroconfEvents): this;
13
+ listenerCount(event: keyof ZeroconfEvents): number;
14
+ }
15
+ /** Extends the `events` package EventEmitter */
16
+ declare class Zeroconf extends EventEmitter {
17
+ private _services;
18
+ private _serviceTypes;
19
+ private _scanningTypes;
20
+ private _publishedServices;
21
+ private _publishedImplTypes;
22
+ private _scanImplType;
23
+ private _scanId;
24
+ private _hasScanned;
25
+ private _dListeners;
26
+ constructor();
27
+ /**
28
+ * Add the native event listeners (called automatically in the constructor)
29
+ */
30
+ addDeviceListeners(): void;
31
+ /**
32
+ * Add a listener and get a function that removes it, handy in useEffect cleanups
33
+ */
34
+ subscribe<E extends keyof ZeroconfEvents>(event: E, listener: Listener<E>): () => void;
35
+ /**
36
+ * Scan events belong to the instance that started the scan. Instances that never scanned still receive
37
+ * every scan's events, as before multiple scans, and events without a scan id (publishing) go to everyone.
38
+ */
39
+ private _isOwnEvent;
40
+ /**
41
+ * Remove the native event listeners, call it when you are done with the instance
42
+ */
43
+ removeDeviceListeners(): void;
44
+ /**
45
+ * All the services found so far, keyed by name
46
+ */
47
+ getServices(): Record<string, Service>;
48
+ /**
49
+ * Service types found by `scanServiceTypes`
50
+ */
51
+ getServiceTypes(): ServiceType[];
52
+ /**
53
+ * Scan for the service types advertised on the network (_http._tcp, _ipp._tcp...), emits typeFound and typeRemove.
54
+ * On iOS, only types declared in NSBonjourServices can then be scanned.
55
+ * On iOS it requires the multicast entitlement. On Android with NSD and on Windows, services other apps publish on the same device are left out.
56
+ */
57
+ scanServiceTypes({ domain, implType, networkInterface }?: ServiceTypesScanOptions): void;
58
+ /**
59
+ * Scan for services, defaults to `_http._tcp.` on the `local.` domain
60
+ */
61
+ scan(options?: ScanOptions): void;
62
+ private _startScan;
63
+ /**
64
+ * Stop the current scan
65
+ * @param implType Android only, defaults to the implementation used by the last scan
66
+ */
67
+ stop(implType?: ImplType): void;
68
+ /**
69
+ * Checks the Local Network permission, resolves 'granted', 'denied' or 'unknown'.
70
+ * iOS: uses a service type from NSBonjourServices (the first one by default) and can show the permission prompt.
71
+ * Android: apps targeting Android 17 (API 37) need ACCESS_LOCAL_NETWORK on Android 17 devices, it is requested
72
+ * when missing unless request is false. 'granted' when there is nothing to grant.
73
+ */
74
+ checkLocalNetworkAccess({ type, protocol, timeout, request, }?: LocalNetworkAccessOptions): Promise<LocalNetworkAccess>;
75
+ /**
76
+ * Publish a service. Resolves with the published service once it is advertised, its name can differ
77
+ * from the requested one when that name is already taken. Rejects with a `ZeroconfError`.
78
+ */
79
+ publishService(options: PublishOptions): Promise<PublishedService>;
80
+ /**
81
+ * Replace the TXT record of a published service, resolves with the updated service.
82
+ * Android `NSD` has no update: the service is published again under the same name.
83
+ */
84
+ updateService(name: string, { txt, implType }?: UpdateOptions): Promise<PublishedService>;
85
+ /**
86
+ * Resolve one service by name without scanning, for a device found before.
87
+ * Resolves with the service, rejects with code 'TIMEOUT' when it doesn't answer in time.
88
+ */
89
+ resolveService(options: ResolveOptions): Promise<Service>;
90
+ /**
91
+ * Unpublish a service. Resolves once it is no longer advertised, rejects with a `ZeroconfError`
92
+ * (e.g. code `'NOT_PUBLISHED'`).
93
+ * @param implType Android only, defaults to the implementation the service was published with
94
+ */
95
+ unpublishService(name: string, implType?: ImplType): Promise<PublishedService | null>;
96
+ }
97
+ export default Zeroconf;
98
+ /**
99
+ * Scans while mounted and returns the resolved services. Scans again when the options change,
100
+ * stops and cleans up on unmount. Each hook runs its own scan, several can run at once.
101
+ *
102
+ * const { services, isScanning, error, stop, restart } = useZeroconf({ type: 'http' })
103
+ */
104
+ export declare function useZeroconf(options?: UseZeroconfOptions): UseZeroconfResult;
105
+ /**
106
+ * Lists the service types advertised on the network while mounted.
107
+ *
108
+ * const { serviceTypes, isScanning, error, stop, restart } = useServiceTypes()
109
+ */
110
+ export declare function useServiceTypes(options?: UseServiceTypesOptions): UseServiceTypesResult;
111
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAErC,OAAO,EAA8C,KAAK,kBAAkB,EAAE,MAAM,aAAU,CAAA;AAC9F,OAAO,EACL,QAAQ,EACR,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,cAAc,EACn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IAK5B;;;OAGG;IACH,cAAc,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC;IAazD;;;;OAIG;IACH,gBAAgB,CACd,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,QAAyD,GAClE,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;CAMpC;AAED,eAAe,QAAQ,CAAA;AAgEvB;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,iBAAiB,CA4B/E;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,sBAA2B,GAAG,qBAAqB,CAS3F"}
@@ -0,0 +1,175 @@
1
+ /** Android only: which discovery implementation to use */
2
+ export declare const ImplType: {
3
+ readonly NSD: "NSD";
4
+ readonly DNSSD: "DNSSD";
5
+ };
6
+ export type ImplType = (typeof ImplType)[keyof typeof ImplType];
7
+ export interface Service {
8
+ /** Human-readable service name */
9
+ name: string;
10
+ /** Full service name, e.g. `XeroxPrinter.local._http._tcp.` */
11
+ fullName: string;
12
+ /** Hostname, e.g. `XeroxPrinter.local.` */
13
+ host: string;
14
+ port: number;
15
+ /** IPv4 and IPv6 addresses, IPv4 first */
16
+ addresses: string[];
17
+ ipv4: string[];
18
+ ipv6: string[];
19
+ /** TXT record attributes */
20
+ txt: Record<string, string>;
21
+ }
22
+ type TxtValue = string | number | boolean;
23
+ /** TXT records as an object, or as [key, value] pairs to control the order */
24
+ export type TxtRecord = Record<string, TxtValue> | Array<[string, TxtValue]>;
25
+ export interface ScanOptions {
26
+ /** Service type without underscore, e.g. `'http'`. Defaults to `'http'` */
27
+ type?: string;
28
+ /** `'tcp'` or `'udp'`. Defaults to `'tcp'` */
29
+ protocol?: string;
30
+ /** Defaults to `'local.'` */
31
+ domain?: string;
32
+ /** Android only, defaults to `NSD` */
33
+ implType?: ImplType;
34
+ /**
35
+ * Seconds to try resolving each service before retrying once, then emitting an `error` with code `'TIMEOUT'`.
36
+ * Defaults to `5`. Android `NSD` before Android 14 can't retry a resolve, the error comes after twice this time
37
+ */
38
+ resolveTimeout?: number;
39
+ /** Only find services registered with this subtype, e.g. `'printer'` */
40
+ subtype?: string;
41
+ /**
42
+ * Network interface to scan on, e.g. `'en0'` on iOS or `'wlan0'` on Android. All of them by default.
43
+ * Android `NSD` needs Android 13 or later for it
44
+ */
45
+ networkInterface?: string;
46
+ }
47
+ export interface PublishOptions {
48
+ /** Service type without underscore, e.g. `'http'` */
49
+ type: string;
50
+ /** `'tcp'` or `'udp'` */
51
+ protocol: string;
52
+ /** Defaults to `'local.'` */
53
+ domain?: string;
54
+ /** Service name, should be unique on the network */
55
+ name: string;
56
+ port: number;
57
+ txt?: TxtRecord;
58
+ /** Android only, defaults to `NSD` */
59
+ implType?: ImplType;
60
+ /** Subtypes to register the service with, e.g. `['printer']` */
61
+ subtypes?: string[];
62
+ /** Network interface to publish on, all of them by default. Android `NSD` needs Android 13 or later for it */
63
+ networkInterface?: string;
64
+ }
65
+ export interface UpdateOptions {
66
+ /** The new TXT record, replaces the current one */
67
+ txt?: TxtRecord;
68
+ /** Android only, defaults to the implementation the service was published with */
69
+ implType?: ImplType;
70
+ }
71
+ export interface ResolveOptions {
72
+ /** Name of the service */
73
+ name: string;
74
+ /** Service type without underscore, e.g. `'http'`. Defaults to `'http'` */
75
+ type?: string;
76
+ /** Defaults to `'tcp'` */
77
+ protocol?: string;
78
+ /** Defaults to `'local.'` */
79
+ domain?: string;
80
+ /** Android only, defaults to `NSD` */
81
+ implType?: ImplType;
82
+ /** Seconds before rejecting with code `'TIMEOUT'`, defaults to `5` */
83
+ timeout?: number;
84
+ /** Network interface to resolve on, all of them by default */
85
+ networkInterface?: string;
86
+ }
87
+ /**
88
+ * Errors emitted by the `error` event
89
+ *
90
+ * - `DNSSD`: DNSServiceErrorType, on iOS and from Android's embedded mDNSResponder,
91
+ * e.g. `-65555` type missing from NSBonjourServices, `-65570` Local Network access denied
92
+ * - `NsdManager`: Android NsdManager failure code
93
+ * - `Windows`: Win32 / DNS_STATUS code from the Windows DNS-SD functions
94
+ * - `RNZeroconf`: the library's own errors, e.g. `'EXCEPTION'`, `'TIMEOUT'`, `'UNKNOWN_INTERFACE'`
95
+ */
96
+ export interface ZeroconfError extends Error {
97
+ code: number | string;
98
+ domain: 'DNSSD' | 'NsdManager' | 'RNZeroconf' | 'Windows';
99
+ /** The service the error is about, when there is one */
100
+ serviceName?: string;
101
+ }
102
+ export interface LocalNetworkAccessOptions {
103
+ /** Service type without underscore, must be listed in `NSBonjourServices`. Defaults to the first one listed */
104
+ type?: string;
105
+ /** Defaults to `'tcp'` */
106
+ protocol?: string;
107
+ /** iOS: seconds to wait for an answer, defaults to `5` */
108
+ timeout?: number;
109
+ /** Android: request `ACCESS_LOCAL_NETWORK` when it is missing, defaults to `true` */
110
+ request?: boolean;
111
+ }
112
+ /** Published services don't carry the address family fields */
113
+ export type PublishedService = Omit<Service, 'ipv4' | 'ipv6'>;
114
+ export interface ZeroconfEvents {
115
+ start: () => void;
116
+ stop: () => void;
117
+ /** Service found, before resolution */
118
+ found: (name: string) => void;
119
+ /** Service fully resolved with network info */
120
+ resolved: (service: Service) => void;
121
+ /** Service removed from the network */
122
+ remove: (name: string) => void;
123
+ /** Services or service types list changed */
124
+ update: () => void;
125
+ /** Service type found by `scanServiceTypes` */
126
+ typeFound: (serviceType: ServiceType) => void;
127
+ /** Service type no longer advertised, during `scanServiceTypes` */
128
+ typeRemove: (serviceType: ServiceType) => void;
129
+ error: (error: ZeroconfError) => void;
130
+ published: (service: PublishedService) => void;
131
+ unpublished: (service: PublishedService) => void;
132
+ }
133
+ /** A service type advertised on the network, e.g. `{ type: 'http', protocol: 'tcp' }` for `_http._tcp` */
134
+ export interface ServiceType {
135
+ type: string;
136
+ protocol: 'tcp' | 'udp';
137
+ }
138
+ export interface ServiceTypesScanOptions {
139
+ /** Defaults to `local.` */
140
+ domain?: string;
141
+ /** Android only, defaults to `ImplType.NSD`. With `NSD`, services other apps publish on the same phone are left out (this app's own are included), `DNSSD` includes them */
142
+ implType?: ImplType;
143
+ /** Network interface to list the types on, all of them by default */
144
+ networkInterface?: string;
145
+ }
146
+ export interface UseZeroconfOptions extends ScanOptions {
147
+ /** Scan only while true, defaults to `true` */
148
+ enabled?: boolean;
149
+ }
150
+ export interface UseZeroconfResult {
151
+ /** Resolved services, updated as they are found, resolved and removed */
152
+ services: Service[];
153
+ isScanning: boolean;
154
+ /** Last error, reset when a new scan starts */
155
+ error: ZeroconfError | null;
156
+ stop(): void;
157
+ /** Clears the services and scans again */
158
+ restart(): void;
159
+ }
160
+ export interface UseServiceTypesOptions extends ServiceTypesScanOptions {
161
+ /** Scan only while true, defaults to `true` */
162
+ enabled?: boolean;
163
+ }
164
+ export interface UseServiceTypesResult {
165
+ /** Service types advertised on the network, updated as they appear and disappear */
166
+ serviceTypes: ServiceType[];
167
+ isScanning: boolean;
168
+ /** Last error, reset when a new scan starts */
169
+ error: ZeroconfError | null;
170
+ stop(): void;
171
+ /** Clears the service types and scans again */
172
+ restart(): void;
173
+ }
174
+ export {};
175
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,eAAO,MAAM,QAAQ;;;CAGX,CAAA;AAEV,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAA;AAE/D,MAAM,WAAW,OAAO;IACtB,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAA;IAChB,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,0CAA0C;IAC1C,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,IAAI,EAAE,MAAM,E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ED,MAAM,WAAW,qBAAqB;IACpC,oFAAoF;IACpF,YAAY,EAAE,WAAW,EAAE,CAAA;IAC3B,UAAU,EAAE,OAAO,CAAA;IACnB,+CAA+C;IAC/C,KAAK,EAAE,aAAa,GAAG,IAAI,CAAA;IAC3B,IAAI,IAAI,IAAI,CAAA;IACZ,+CAA+C;IAC/C,OAAO,IAAI,IAAI,CAAA;CAChB"}
package/package.json CHANGED
@@ -1,15 +1,24 @@
1
1
  {
2
2
  "name": "react-native-zeroconf",
3
- "version": "0.17.2",
3
+ "version": "1.0.0-rc.1",
4
4
  "description": "A Zeroconf discovery utility for react-native",
5
- "main": "dist",
6
- "types": "index.d.ts",
5
+ "main": "./lib/module/index.js",
6
+ "types": "./lib/typescript/src/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "source": "./src/index.ts",
10
+ "types": "./lib/typescript/src/index.d.ts",
11
+ "default": "./lib/module/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
7
15
  "scripts": {
8
- "lint": "eslint src/*.js",
9
- "format": "prettier --write src/*.js",
10
- "build": "rm -rf dist && mkdir dist && babel src -o dist/index.js",
16
+ "lint": "eslint src",
17
+ "format": "prettier --write src",
18
+ "build": "bob build",
19
+ "prepack": "bob build",
11
20
  "test": "jest",
12
- "typecheck": "tsc -p test/types"
21
+ "typecheck": "tsc -p tsconfig.json && tsc -p test/types"
13
22
  },
14
23
  "repository": {
15
24
  "type": "git",
@@ -17,9 +26,9 @@
17
26
  },
18
27
  "files": [
19
28
  "src",
20
- "dist",
21
- "index.d.ts",
29
+ "lib",
22
30
  "android",
31
+ "android/generated",
23
32
  "!android/src/main/jni/mdnsresponder/mDNSWindows",
24
33
  "!android/src/main/jni/mdnsresponder/Clients",
25
34
  "!android/src/main/jni/mdnsresponder/android",
@@ -57,14 +66,18 @@
57
66
  "!android/src/main/jni/mdnsresponder/mDNSShared/mDNSResponder.8",
58
67
  "!android/build",
59
68
  "!android/.gradle",
69
+ "!android/src/androidTest",
60
70
  "windows",
61
71
  "!windows/**/*.user",
62
72
  "!windows/**/obj",
63
73
  "!windows/**/bin",
64
74
  "!windows/**/Generated Files",
65
75
  "ios",
76
+ "ios/generated",
77
+ "cpp",
66
78
  "react-native-zeroconf.podspec",
67
- "NOTICE"
79
+ "NOTICE",
80
+ "react-native.config.js"
68
81
  ],
69
82
  "keywords": [
70
83
  "react-component",
@@ -87,34 +100,25 @@
87
100
  },
88
101
  "peerDependencies": {
89
102
  "react": "*",
90
- "react-native": ">=0.60"
103
+ "react-native": ">=0.82"
91
104
  },
92
105
  "devDependencies": {
93
- "@babel/cli": "^7.23.0",
94
106
  "@babel/core": "^7.23.0",
95
107
  "@babel/preset-env": "^7.23.0",
96
- "@babel/preset-flow": "^7.23.0",
108
+ "@babel/preset-typescript": "^7",
109
+ "@types/events": "^3.0.3",
110
+ "@types/react": "^19.2.0",
97
111
  "babel-jest": "^29.6.3",
98
112
  "eslint": "^8.57.0",
99
113
  "eslint-config-prettier": "^9.1.0",
100
114
  "jest": "^29.6.3",
101
115
  "prettier": "^3.2.0",
102
- "react": "18.2.0",
103
- "react-test-renderer": "18.2.0",
104
- "typescript": "^5.4.0"
105
- },
106
- "babel": {
107
- "presets": [
108
- [
109
- "@babel/preset-env",
110
- {
111
- "targets": {
112
- "node": "14"
113
- }
114
- }
115
- ],
116
- "@babel/preset-flow"
117
- ]
116
+ "react": "19.2.3",
117
+ "react-native": "0.86.3",
118
+ "react-native-builder-bob": "^0.43.1",
119
+ "react-test-renderer": "19.2.3",
120
+ "typescript": "^5.4.0",
121
+ "typescript-eslint": "^8.71.0"
118
122
  },
119
123
  "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
120
124
  "jest": {
@@ -128,5 +132,37 @@
128
132
  "moduleNameMapper": {
129
133
  "^react-native$": "<rootDir>/test/helpers/mockReactNative.js"
130
134
  }
135
+ },
136
+ "react-native-builder-bob": {
137
+ "source": "src",
138
+ "output": "lib",
139
+ "targets": [
140
+ [
141
+ "module",
142
+ {
143
+ "esm": true
144
+ }
145
+ ],
146
+ [
147
+ "typescript",
148
+ {
149
+ "project": "tsconfig.build.json"
150
+ }
151
+ ],
152
+ "codegen"
153
+ ]
154
+ },
155
+ "codegenConfig": {
156
+ "name": "RNZeroconfSpec",
157
+ "type": "modules",
158
+ "jsSrcsDir": "src",
159
+ "outputDir": {
160
+ "ios": "ios/generated",
161
+ "android": "android/generated"
162
+ },
163
+ "android": {
164
+ "javaPackageName": "com.balthazargronon.RCTZeroconf"
165
+ },
166
+ "includesGeneratedCode": true
131
167
  }
132
168
  }
@@ -16,7 +16,8 @@ Pod::Spec.new do |s|
16
16
  s.tvos.deployment_target = '13.4'
17
17
 
18
18
  s.source = { :git => "https://github.com/balthazar/react-native-zeroconf.git", :tag => "#{s.version}" }
19
- s.source_files = "ios/**/*.{h,m}"
19
+ # The C++ module (cpp/), its Apple registration and the code generated from src/NativeZeroconf.ts (ios/generated)
20
+ s.source_files = "ios/**/*.{h,m,mm}", "cpp/*.{h,cpp}", "cpp/dnssd/*.{h,cpp}", "cpp/apple/*.{h,cpp,mm}"
20
21
  s.frameworks = 'Network'
21
22
 
22
23
  if respond_to?(:install_modules_dependencies, true)
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @type {import('@react-native-community/cli-types').UserDependencyConfig}
3
+ */
4
+ module.exports = {
5
+ dependency: {
6
+ platforms: {
7
+ android: {
8
+ // Codegen output is generated by bob build and shipped in the package
9
+ cmakeListsPath: 'generated/jni/CMakeLists.txt',
10
+ // The C++ module (cpp/android/ZeroconfAndroidModule), built by android/CMakeLists.txt
11
+ cxxModuleCMakeListsModuleName: 'react-native-zeroconf',
12
+ cxxModuleCMakeListsPath: 'CMakeLists.txt',
13
+ cxxModuleHeaderName: 'ZeroconfAndroidModule',
14
+ },
15
+ },
16
+ },
17
+ }