@devioarts/capacitor-mdns 0.0.3 → 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 (46) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/DevioartsCapacitorMdns.podspec +3 -3
  3. package/Package.swift +1 -1
  4. package/README.md +272 -101
  5. package/android/build.gradle +3 -9
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/java/com/devioarts/capacitor/mdns/AndroidNsdBackend.kt +145 -0
  8. package/android/src/main/java/com/devioarts/capacitor/mdns/MdnsOptions.kt +32 -0
  9. package/android/src/main/java/com/devioarts/capacitor/mdns/MdnsValidation.kt +26 -0
  10. package/android/src/main/java/com/devioarts/capacitor/mdns/NsdBackend.kt +59 -0
  11. package/android/src/main/java/com/devioarts/capacitor/mdns/mDNS.kt +496 -175
  12. package/android/src/main/java/com/devioarts/capacitor/mdns/mDNSPlugin.kt +85 -49
  13. package/dist/docs.json +313 -15
  14. package/dist/esm/definitions.d.ts +89 -16
  15. package/dist/esm/definitions.js.map +1 -1
  16. package/dist/esm/index.js +22 -1
  17. package/dist/esm/index.js.map +1 -1
  18. package/dist/esm/web.d.ts +8 -1
  19. package/dist/esm/web.js +35 -3
  20. package/dist/esm/web.js.map +1 -1
  21. package/dist/plugin.cjs.js +57 -4
  22. package/dist/plugin.cjs.js.map +1 -1
  23. package/dist/plugin.js +57 -4
  24. package/dist/plugin.js.map +1 -1
  25. package/docs/electron.md +91 -0
  26. package/docs/platform-setup.md +58 -0
  27. package/docs/playground.md +50 -0
  28. package/docs/runtime-behavior.md +80 -0
  29. package/electron/dist/plugin-settings.js +22 -0
  30. package/electron/dist/plugin-settings.js.map +1 -0
  31. package/electron/dist/plugin.cjs.js +774 -0
  32. package/electron/dist/plugin.cjs.js.map +1 -0
  33. package/electron/global.d.ts +2 -0
  34. package/electron/mdns-bridge.cjs +33 -4
  35. package/electron/mdns.ts +628 -107
  36. package/electron/rollup.config.mjs +22 -0
  37. package/electron/src/index.ts +2 -0
  38. package/electron/src/plugin-settings.ts +19 -0
  39. package/electron/tsconfig.json +21 -0
  40. package/electron/types-public/index.d.ts +47 -0
  41. package/ios/Sources/mDNSPlugin/mDNS.swift +481 -124
  42. package/ios/Sources/mDNSPlugin/mDNSPlugin.swift +85 -23
  43. package/ios/Tests/mDNSPluginTests/BridgeTests.swift +46 -0
  44. package/ios/Tests/mDNSPluginTests/MDNSTests.swift +490 -0
  45. package/package.json +55 -20
  46. package/ios/Tests/mDNSPluginTests/mDNSPluginTests.swift +0 -15
@@ -0,0 +1,22 @@
1
+ const external = ['bonjour-service', 'electron', 'node:events', 'node:net', 'node:path', 'node:url'];
2
+
3
+ export default [
4
+ {
5
+ input: 'electron/build/electron/src/index.js',
6
+ output: {
7
+ file: 'electron/dist/plugin.cjs.js',
8
+ format: 'cjs',
9
+ sourcemap: true,
10
+ },
11
+ external,
12
+ },
13
+ {
14
+ input: 'electron/build/electron/src/plugin-settings.js',
15
+ output: {
16
+ file: 'electron/dist/plugin-settings.js',
17
+ format: 'cjs',
18
+ sourcemap: true,
19
+ },
20
+ external,
21
+ },
22
+ ];
@@ -0,0 +1,2 @@
1
+ export { mDNS } from '../mdns';
2
+ export type { BonjourLike, MdnsOptions } from '../mdns';
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Metadata consumed by the capacitor-electron runtime generator (`npx cap-electron sync`).
3
+ *
4
+ * Import path for the JS layer: `@devioarts/capacitor-mdns/electron/settings`.
5
+ */
6
+ export const pluginSettings = {
7
+ pluginClass: 'mDNS',
8
+ pluginMethods: [
9
+ 'getPluginPlatform',
10
+ 'startBroadcast',
11
+ 'stopBroadcast',
12
+ 'discover',
13
+ 'watchServices',
14
+ 'stopWatching',
15
+ ] as const,
16
+ pluginEvents: ['serviceFound', 'serviceLost', 'watchError'] as const,
17
+ } as const;
18
+
19
+ export type PluginSettings = typeof pluginSettings;
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "allowSyntheticDefaultImports": true,
4
+ "declaration": true,
5
+ "esModuleInterop": true,
6
+ "lib": ["es2020"],
7
+ "module": "esnext",
8
+ "moduleResolution": "bundler",
9
+ "noImplicitAny": true,
10
+ "noUnusedLocals": true,
11
+ "noUnusedParameters": true,
12
+ "outDir": "build",
13
+ "rootDir": "..",
14
+ "sourceMap": true,
15
+ "skipLibCheck": true,
16
+ "strict": true,
17
+ "target": "ES2017",
18
+ "types": ["node"]
19
+ },
20
+ "include": ["src/**/*"]
21
+ }
@@ -0,0 +1,47 @@
1
+ import type Bonjour from 'bonjour-service';
2
+ import { EventEmitter } from 'node:events';
3
+ import type {
4
+ MdnsBroadcastOptions,
5
+ MdnsBroadcastResult,
6
+ MdnsDiscoverOptions,
7
+ MdnsDiscoverResult,
8
+ MdnsPluginPlatformResult,
9
+ MdnsStopResult,
10
+ MdnsWatchOptions,
11
+ MdnsWatchResult,
12
+ MdnsWatchStopResult,
13
+ } from '../../dist/esm/definitions';
14
+
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);
24
+ getPluginPlatform(): Promise<MdnsPluginPlatformResult>;
25
+ startBroadcast(options: MdnsBroadcastOptions): Promise<MdnsBroadcastResult>;
26
+ stopBroadcast(): Promise<MdnsStopResult>;
27
+ discover(options?: MdnsDiscoverOptions): Promise<MdnsDiscoverResult>;
28
+ watchServices(options: MdnsWatchOptions): Promise<MdnsWatchResult>;
29
+ stopWatching(): Promise<MdnsWatchStopResult>;
30
+ init(): void;
31
+ destroy(): Promise<void>;
32
+ }
33
+
34
+ export declare const pluginSettings: {
35
+ readonly pluginClass: 'mDNS';
36
+ readonly pluginMethods: readonly [
37
+ 'getPluginPlatform',
38
+ 'startBroadcast',
39
+ 'stopBroadcast',
40
+ 'discover',
41
+ 'watchServices',
42
+ 'stopWatching',
43
+ ];
44
+ readonly pluginEvents: readonly ['serviceFound', 'serviceLost', 'watchError'];
45
+ };
46
+
47
+ export type PluginSettings = typeof pluginSettings;