@devioarts/capacitor-mdns 0.1.0 → 0.2.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 (43) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/DevioartsCapacitorMdns.podspec +3 -3
  3. package/Package.swift +1 -1
  4. package/README.md +221 -37
  5. package/android/build.gradle +3 -9
  6. package/android/src/main/java/com/devioarts/capacitor/mdns/AndroidNsdBackend.kt +145 -0
  7. package/android/src/main/java/com/devioarts/capacitor/mdns/MdnsOptions.kt +32 -0
  8. package/android/src/main/java/com/devioarts/capacitor/mdns/MdnsValidation.kt +26 -0
  9. package/android/src/main/java/com/devioarts/capacitor/mdns/NsdBackend.kt +59 -0
  10. package/android/src/main/java/com/devioarts/capacitor/mdns/mDNS.kt +467 -243
  11. package/android/src/main/java/com/devioarts/capacitor/mdns/mDNSPlugin.kt +80 -57
  12. package/dist/docs.json +250 -14
  13. package/dist/esm/definitions.d.ts +64 -17
  14. package/dist/esm/definitions.js.map +1 -1
  15. package/dist/esm/index.js +22 -2
  16. package/dist/esm/index.js.map +1 -1
  17. package/dist/esm/web.d.ts +6 -1
  18. package/dist/esm/web.js +23 -0
  19. package/dist/esm/web.js.map +1 -1
  20. package/dist/plugin.cjs.js +45 -2
  21. package/dist/plugin.cjs.js.map +1 -1
  22. package/dist/plugin.js +45 -2
  23. package/dist/plugin.js.map +1 -1
  24. package/docs/electron.md +29 -3
  25. package/docs/platform-setup.md +6 -0
  26. package/docs/playground.md +33 -2
  27. package/docs/runtime-behavior.md +68 -2
  28. package/electron/dist/plugin-settings.js +10 -3
  29. package/electron/dist/plugin-settings.js.map +1 -1
  30. package/electron/dist/plugin.cjs.js +519 -89
  31. package/electron/dist/plugin.cjs.js.map +1 -1
  32. package/electron/mdns-bridge.cjs +25 -2
  33. package/electron/mdns.ts +514 -81
  34. package/electron/rollup.config.mjs +1 -1
  35. package/electron/src/index.ts +1 -0
  36. package/electron/src/plugin-settings.ts +10 -3
  37. package/electron/types-public/index.d.ts +25 -3
  38. package/ios/Sources/mDNSPlugin/mDNS.swift +407 -117
  39. package/ios/Sources/mDNSPlugin/mDNSPlugin.swift +77 -24
  40. package/ios/Tests/mDNSPluginTests/BridgeTests.swift +46 -0
  41. package/ios/Tests/mDNSPluginTests/MDNSTests.swift +490 -0
  42. package/package.json +11 -4
  43. package/ios/Tests/mDNSPluginTests/mDNSPluginTests.swift +0 -9
@@ -1,4 +1,4 @@
1
- const external = ['bonjour-service', 'electron'];
1
+ const external = ['bonjour-service', 'electron', 'node:events', 'node:net', 'node:path', 'node:url'];
2
2
 
3
3
  export default [
4
4
  {
@@ -1 +1,2 @@
1
1
  export { mDNS } from '../mdns';
2
+ export type { BonjourLike, MdnsOptions } from '../mdns';
@@ -1,12 +1,19 @@
1
1
  /**
2
- * Metadata consumed by the capacitor-electron runtime generator (`npm run update`).
2
+ * Metadata consumed by the capacitor-electron runtime generator (`npx cap-electron sync`).
3
3
  *
4
4
  * Import path for the JS layer: `@devioarts/capacitor-mdns/electron/settings`.
5
5
  */
6
6
  export const pluginSettings = {
7
7
  pluginClass: 'mDNS',
8
- pluginMethods: ['getPluginPlatform', 'startBroadcast', 'stopBroadcast', 'discover'] as const,
9
- pluginEvents: [] as const,
8
+ pluginMethods: [
9
+ 'getPluginPlatform',
10
+ 'startBroadcast',
11
+ 'stopBroadcast',
12
+ 'discover',
13
+ 'watchServices',
14
+ 'stopWatching',
15
+ ] as const,
16
+ pluginEvents: ['serviceFound', 'serviceLost', 'watchError'] as const,
10
17
  } as const;
11
18
 
12
19
  export type PluginSettings = typeof pluginSettings;
@@ -1,3 +1,5 @@
1
+ import type Bonjour from 'bonjour-service';
2
+ import { EventEmitter } from 'node:events';
1
3
  import type {
2
4
  MdnsBroadcastOptions,
3
5
  MdnsBroadcastResult,
@@ -5,21 +7,41 @@ import type {
5
7
  MdnsDiscoverResult,
6
8
  MdnsPluginPlatformResult,
7
9
  MdnsStopResult,
10
+ MdnsWatchOptions,
11
+ MdnsWatchResult,
12
+ MdnsWatchStopResult,
8
13
  } from '../../dist/esm/definitions';
9
14
 
10
- export declare class mDNS {
15
+ export type BonjourLike = Pick<Bonjour, 'publish' | 'find' | 'destroy'>;
16
+ export interface MdnsOptions {
17
+ publishTimeoutMs?: number;
18
+ stopTimeoutMs?: number;
19
+ /** Exact trusted renderer origins, e.g. http://localhost:5173. */
20
+ trustedOrigins?: string[];
21
+ }
22
+ export declare class mDNS extends EventEmitter {
23
+ constructor(bonjour?: BonjourLike, options?: MdnsOptions);
11
24
  getPluginPlatform(): Promise<MdnsPluginPlatformResult>;
12
25
  startBroadcast(options: MdnsBroadcastOptions): Promise<MdnsBroadcastResult>;
13
26
  stopBroadcast(): Promise<MdnsStopResult>;
14
27
  discover(options?: MdnsDiscoverOptions): Promise<MdnsDiscoverResult>;
28
+ watchServices(options: MdnsWatchOptions): Promise<MdnsWatchResult>;
29
+ stopWatching(): Promise<MdnsWatchStopResult>;
15
30
  init(): void;
16
31
  destroy(): Promise<void>;
17
32
  }
18
33
 
19
34
  export declare const pluginSettings: {
20
35
  readonly pluginClass: 'mDNS';
21
- readonly pluginMethods: readonly ['getPluginPlatform', 'startBroadcast', 'stopBroadcast', 'discover'];
22
- readonly pluginEvents: readonly [];
36
+ readonly pluginMethods: readonly [
37
+ 'getPluginPlatform',
38
+ 'startBroadcast',
39
+ 'stopBroadcast',
40
+ 'discover',
41
+ 'watchServices',
42
+ 'stopWatching',
43
+ ];
44
+ readonly pluginEvents: readonly ['serviceFound', 'serviceLost', 'watchError'];
23
45
  };
24
46
 
25
47
  export type PluginSettings = typeof pluginSettings;