@devioarts/capacitor-mdns 0.0.2
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.
- package/DevioartsCapacitorMdns.podspec +17 -0
- package/Package.swift +28 -0
- package/README.md +248 -0
- package/android/build.gradle +64 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/devioarts/capacitor/mdns/mDNS.kt +221 -0
- package/android/src/main/java/com/devioarts/capacitor/mdns/mDNSPlugin.kt +157 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +457 -0
- package/dist/esm/definitions.d.ts +190 -0
- package/dist/esm/definitions.js +3 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +17 -0
- package/dist/esm/web.js +41 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +55 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +58 -0
- package/dist/plugin.js.map +1 -0
- package/electron/global.d.ts +28 -0
- package/electron/mdns-bridge.cjs +29 -0
- package/electron/mdns.ts +267 -0
- package/ios/Sources/mDNSPlugin/mDNS.swift +436 -0
- package/ios/Sources/mDNSPlugin/mDNSPlugin.swift +125 -0
- package/ios/Tests/mDNSPluginTests/mDNSPluginTests.swift +15 -0
- package/package.json +96 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
package com.devioarts.capacitor.mdns
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.*
|
|
4
|
+
import com.getcapacitor.annotation.CapacitorPlugin
|
|
5
|
+
import com.getcapacitor.PluginMethod
|
|
6
|
+
import kotlinx.coroutines.*
|
|
7
|
+
import org.json.JSONArray
|
|
8
|
+
import org.json.JSONObject
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Capacitor Android bridge for the mDNS plugin.
|
|
12
|
+
*
|
|
13
|
+
* Responsibilities:
|
|
14
|
+
* - Own a single instance of the mDNS manager (Android NSD wrapper).
|
|
15
|
+
* - Translate Capacitor calls (JS) to Kotlin calls and normalize results.
|
|
16
|
+
* - Never reject for runtime errors; always resolve with { error, errorMessage }.
|
|
17
|
+
*
|
|
18
|
+
* Parameters (strict, no legacy):
|
|
19
|
+
* - startBroadcast: { type?: string, name?: string, port: number, txt?: Record<string,string> } // txt ignored by Android
|
|
20
|
+
* - stopBroadcast: {}
|
|
21
|
+
* - discover: { type?: string, name?: string, timeout?: number }
|
|
22
|
+
*
|
|
23
|
+
* Return shapes:
|
|
24
|
+
* - startBroadcast -> { publishing: boolean, name: string, error: boolean, errorMessage: string|null }
|
|
25
|
+
* - stopBroadcast -> { publishing: false, error: boolean, errorMessage: string|null }
|
|
26
|
+
* - discover -> {
|
|
27
|
+
* error: boolean, errorMessage: string|null,
|
|
28
|
+
* servicesFound: number,
|
|
29
|
+
* services: Array<{ name, type, domain: "local.", port, hosts?: string[] }>
|
|
30
|
+
* }
|
|
31
|
+
*/
|
|
32
|
+
@CapacitorPlugin(name = "mDNS")
|
|
33
|
+
class mDNSPlugin : Plugin() {
|
|
34
|
+
|
|
35
|
+
private val scope = MainScope()
|
|
36
|
+
private lateinit var mdns: mDNS
|
|
37
|
+
|
|
38
|
+
override fun load() {
|
|
39
|
+
val ctx = context ?: throw IllegalStateException("No Android context")
|
|
40
|
+
mdns = mDNS(ctx, scope)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
override fun handleOnDestroy() {
|
|
44
|
+
mdns.close()
|
|
45
|
+
scope.cancel()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ----------------------- Helpers -----------------------
|
|
49
|
+
|
|
50
|
+
private fun toErrorMessage(t: Throwable?): String =
|
|
51
|
+
t?.message ?: "Unknown error"
|
|
52
|
+
|
|
53
|
+
private fun jnull(msg: String?): Any = msg ?: JSONObject.NULL
|
|
54
|
+
|
|
55
|
+
private fun jsResultBroadcast(publishing: Boolean, name: String, error: Boolean, msg: String?): JSObject =
|
|
56
|
+
JSObject().put("publishing", publishing)
|
|
57
|
+
.put("name", name)
|
|
58
|
+
.put("error", error)
|
|
59
|
+
.put("errorMessage", jnull(msg))
|
|
60
|
+
|
|
61
|
+
private fun jsResultStop(error: Boolean, msg: String?): JSObject =
|
|
62
|
+
JSObject().put("publishing", false)
|
|
63
|
+
.put("error", error)
|
|
64
|
+
.put("errorMessage", jnull(msg))
|
|
65
|
+
|
|
66
|
+
private fun jsResultDiscover(error: Boolean, msg: String?, services: JSONArray): JSObject =
|
|
67
|
+
JSObject()
|
|
68
|
+
.put("error", error)
|
|
69
|
+
.put("errorMessage", jnull(msg))
|
|
70
|
+
.put("servicesFound", services.length())
|
|
71
|
+
.put("services", services)
|
|
72
|
+
|
|
73
|
+
// ----------------------- API -----------------------
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Start advertising a Bonjour/mDNS service.
|
|
77
|
+
* - type: default "_http._tcp."
|
|
78
|
+
* - name: default packageName
|
|
79
|
+
* - port: required (> 0)
|
|
80
|
+
*/
|
|
81
|
+
@PluginMethod
|
|
82
|
+
fun startBroadcast(call: PluginCall) {
|
|
83
|
+
val type = call.getString("type") ?: "_http._tcp."
|
|
84
|
+
val name = call.getString("name") ?: (context?.packageName ?: "DevIOArtsMDNS")
|
|
85
|
+
val port = call.getInt("port") ?: 0
|
|
86
|
+
|
|
87
|
+
if (port <= 0) {
|
|
88
|
+
call.resolve(jsResultBroadcast(false, "", true, "Missing/invalid port"))
|
|
89
|
+
return
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
mdns.broadcast(
|
|
94
|
+
typeRaw = type,
|
|
95
|
+
name = name,
|
|
96
|
+
port = port,
|
|
97
|
+
onSuccess = { published ->
|
|
98
|
+
call.resolve(jsResultBroadcast(true, published, false, null))
|
|
99
|
+
},
|
|
100
|
+
onError = { err ->
|
|
101
|
+
call.resolve(jsResultBroadcast(false, "", true, toErrorMessage(err)))
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
} catch (t: Throwable) {
|
|
105
|
+
call.resolve(jsResultBroadcast(false, "", true, toErrorMessage(t)))
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Stop advertising the currently registered service.
|
|
111
|
+
*/
|
|
112
|
+
@PluginMethod
|
|
113
|
+
fun stopBroadcast(call: PluginCall) {
|
|
114
|
+
try {
|
|
115
|
+
mdns.stopBroadcast()
|
|
116
|
+
call.resolve(jsResultStop(false, null))
|
|
117
|
+
} catch (t: Throwable) {
|
|
118
|
+
call.resolve(jsResultStop(true, toErrorMessage(t)))
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Discover services of a given type and optional name filter (exact/prefix, normalized).
|
|
124
|
+
* - type: default "_http._tcp."
|
|
125
|
+
* - name: optional filter
|
|
126
|
+
* - timeout: default 3000
|
|
127
|
+
*/
|
|
128
|
+
@PluginMethod
|
|
129
|
+
fun discover(call: PluginCall) {
|
|
130
|
+
val type = call.getString("type") ?: "_http._tcp."
|
|
131
|
+
val targetName = call.getString("name")
|
|
132
|
+
val timeout = call.getInt("timeout") ?: 3000
|
|
133
|
+
|
|
134
|
+
scope.launch {
|
|
135
|
+
try {
|
|
136
|
+
val list = mdns.discover(type, targetName, timeout)
|
|
137
|
+
val arr = JSONArray(list.map { s ->
|
|
138
|
+
JSObject().apply {
|
|
139
|
+
put("name", s.name)
|
|
140
|
+
put("type", s.type) // Android returns full type with dot
|
|
141
|
+
put("domain", "local.") // NSD is mDNS only
|
|
142
|
+
// normalize hosts to [] or [addr]
|
|
143
|
+
val hosts = JSONArray()
|
|
144
|
+
val addr = s.host
|
|
145
|
+
if (!addr.isNullOrEmpty()) hosts.put(addr)
|
|
146
|
+
put("hosts", hosts)
|
|
147
|
+
put("port", s.port)
|
|
148
|
+
// TXT not available via NSD -> omitted on Android
|
|
149
|
+
}
|
|
150
|
+
})
|
|
151
|
+
call.resolve(jsResultDiscover(false, null, arr))
|
|
152
|
+
} catch (t: Throwable) {
|
|
153
|
+
call.resolve(jsResultDiscover(true, toErrorMessage(t), JSONArray()))
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
File without changes
|
package/dist/docs.json
ADDED
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "mDNSPlugin",
|
|
4
|
+
"slug": "mdnsplugin",
|
|
5
|
+
"docs": "Public API surface of the Capacitor mDNS plugin.",
|
|
6
|
+
"tags": [
|
|
7
|
+
{
|
|
8
|
+
"text": "```ts\nimport { mDNS } from 'capacitor-mdns';\n\n// Start advertising\nawait mDNS.startBroadcast({ type: '_http._tcp.', name: 'my.app.id', port: 9235 });\n\n// Discover services\nconst { services } = await mDNS.discover({ type: '_http._tcp.', timeout: 3000 });\n\n// Stop advertising\nawait mDNS.stopBroadcast();\n```",
|
|
9
|
+
"name": "example"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "public"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"methods": [
|
|
16
|
+
{
|
|
17
|
+
"name": "startBroadcast",
|
|
18
|
+
"signature": "(options: MdnsBroadcastOptions) => Promise<MdnsBroadcastResult>",
|
|
19
|
+
"parameters": [
|
|
20
|
+
{
|
|
21
|
+
"name": "options",
|
|
22
|
+
"docs": "- {@link MdnsBroadcastOptions}",
|
|
23
|
+
"type": "MdnsBroadcastOptions"
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"returns": "Promise<MdnsBroadcastResult>",
|
|
27
|
+
"tags": [
|
|
28
|
+
{
|
|
29
|
+
"name": "param",
|
|
30
|
+
"text": "options - {@link MdnsBroadcastOptions}"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "returns",
|
|
34
|
+
"text": "Promise resolving to `MdnsBroadcastResult` (`true` on success)."
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"docs": "Start advertising a Bonjour/mDNS service.",
|
|
38
|
+
"complexTypes": [
|
|
39
|
+
"MdnsBroadcastResult",
|
|
40
|
+
"MdnsBroadcastOptions"
|
|
41
|
+
],
|
|
42
|
+
"slug": "startbroadcast"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "stopBroadcast",
|
|
46
|
+
"signature": "() => Promise<MdnsStopResult>",
|
|
47
|
+
"parameters": [],
|
|
48
|
+
"returns": "Promise<MdnsStopResult>",
|
|
49
|
+
"tags": [
|
|
50
|
+
{
|
|
51
|
+
"name": "returns",
|
|
52
|
+
"text": "Promise resolving to `MdnsStopResult`."
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"name": "remarks",
|
|
56
|
+
"text": "The `publishing` flag may be `false` after a successful stop."
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"docs": "Stop advertising the currently registered service (no-op if none).",
|
|
60
|
+
"complexTypes": [
|
|
61
|
+
"MdnsStopResult"
|
|
62
|
+
],
|
|
63
|
+
"slug": "stopbroadcast"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"name": "discover",
|
|
67
|
+
"signature": "(options?: MdnsDiscoverOptions | undefined) => Promise<MdnsDiscoverResult>",
|
|
68
|
+
"parameters": [
|
|
69
|
+
{
|
|
70
|
+
"name": "options",
|
|
71
|
+
"docs": "- {@link MdnsDiscoverOptions}",
|
|
72
|
+
"type": "MdnsDiscoverOptions | undefined"
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
"returns": "Promise<MdnsDiscoverResult>",
|
|
76
|
+
"tags": [
|
|
77
|
+
{
|
|
78
|
+
"name": "param",
|
|
79
|
+
"text": "options - {@link MdnsDiscoverOptions}"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"name": "returns",
|
|
83
|
+
"text": "Promise resolving to `MdnsDiscoverResult`."
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"name": "remarks",
|
|
87
|
+
"text": "The result list is normalized across platforms. On Android, `txt` is typically absent."
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
"docs": "Discover services of a given type and optionally filter by instance name.",
|
|
91
|
+
"complexTypes": [
|
|
92
|
+
"MdnsDiscoverResult",
|
|
93
|
+
"MdnsDiscoverOptions"
|
|
94
|
+
],
|
|
95
|
+
"slug": "discover"
|
|
96
|
+
}
|
|
97
|
+
],
|
|
98
|
+
"properties": []
|
|
99
|
+
},
|
|
100
|
+
"interfaces": [
|
|
101
|
+
{
|
|
102
|
+
"name": "MdnsBroadcastResult",
|
|
103
|
+
"slug": "mdnsbroadcastresult",
|
|
104
|
+
"docs": "Result of startBroadcast(). Indicates whether advertising is active\nand the final service name. On failure, `error` is true and `errorMessage`\ndescribes the issue.",
|
|
105
|
+
"tags": [
|
|
106
|
+
{
|
|
107
|
+
"name": "public"
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
"methods": [],
|
|
111
|
+
"properties": [
|
|
112
|
+
{
|
|
113
|
+
"name": "error",
|
|
114
|
+
"tags": [],
|
|
115
|
+
"docs": "True if the operation failed.",
|
|
116
|
+
"complexTypes": [],
|
|
117
|
+
"type": "boolean"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"name": "errorMessage",
|
|
121
|
+
"tags": [],
|
|
122
|
+
"docs": "Error description or null on success.",
|
|
123
|
+
"complexTypes": [],
|
|
124
|
+
"type": "string | null"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"name": "name",
|
|
128
|
+
"tags": [],
|
|
129
|
+
"docs": "Final (possibly uniquified) service instance name. Empty on failure.",
|
|
130
|
+
"complexTypes": [],
|
|
131
|
+
"type": "string"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"name": "publishing",
|
|
135
|
+
"tags": [],
|
|
136
|
+
"docs": "Whether the advertiser is currently active.",
|
|
137
|
+
"complexTypes": [],
|
|
138
|
+
"type": "boolean"
|
|
139
|
+
}
|
|
140
|
+
]
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"name": "MdnsBroadcastOptions",
|
|
144
|
+
"slug": "mdnsbroadcastoptions",
|
|
145
|
+
"docs": "Options for starting a Bonjour/mDNS advertisement.",
|
|
146
|
+
"tags": [
|
|
147
|
+
{
|
|
148
|
+
"text": "- The `type` **must** end with a dot (`.`). If omitted, the implementation appends it.\n- Instance `name` should be short and human-readable; the OS may append `\" (n)\"` to ensure uniqueness.\n- Android NSD does not expose TXT records to other apps; advertising TXT is supported on iOS.",
|
|
149
|
+
"name": "remarks"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"name": "public"
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
"methods": [],
|
|
156
|
+
"properties": [
|
|
157
|
+
{
|
|
158
|
+
"name": "type",
|
|
159
|
+
"tags": [
|
|
160
|
+
{
|
|
161
|
+
"text": "`\"_http._tcp.\"`",
|
|
162
|
+
"name": "defaultValue"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"text": "`\"_myapp._tcp.\"`",
|
|
166
|
+
"name": "example"
|
|
167
|
+
}
|
|
168
|
+
],
|
|
169
|
+
"docs": "Service type (including the trailing dot).",
|
|
170
|
+
"complexTypes": [],
|
|
171
|
+
"type": "string | undefined"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"name": "name",
|
|
175
|
+
"tags": [],
|
|
176
|
+
"docs": "Service instance name.",
|
|
177
|
+
"complexTypes": [],
|
|
178
|
+
"type": "string"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"name": "port",
|
|
182
|
+
"tags": [
|
|
183
|
+
{
|
|
184
|
+
"text": "Must be a positive integer (1–65535).",
|
|
185
|
+
"name": "remarks"
|
|
186
|
+
}
|
|
187
|
+
],
|
|
188
|
+
"docs": "TCP port to advertise.",
|
|
189
|
+
"complexTypes": [],
|
|
190
|
+
"type": "number"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"name": "txt",
|
|
194
|
+
"tags": [
|
|
195
|
+
{
|
|
196
|
+
"text": "May be ignored on Android due to platform limitations.",
|
|
197
|
+
"name": "remarks"
|
|
198
|
+
}
|
|
199
|
+
],
|
|
200
|
+
"docs": "Optional TXT key–value pairs (UTF-8 strings).",
|
|
201
|
+
"complexTypes": [
|
|
202
|
+
"MdnsTxt"
|
|
203
|
+
],
|
|
204
|
+
"type": "MdnsTxt"
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"name": "MdnsStopResult",
|
|
210
|
+
"slug": "mdnsstopresult",
|
|
211
|
+
"docs": "Result of stopBroadcast(). Indicates whether the advertiser is active\nafter the call (normally false) and includes error information.",
|
|
212
|
+
"tags": [
|
|
213
|
+
{
|
|
214
|
+
"name": "public"
|
|
215
|
+
}
|
|
216
|
+
],
|
|
217
|
+
"methods": [],
|
|
218
|
+
"properties": [
|
|
219
|
+
{
|
|
220
|
+
"name": "error",
|
|
221
|
+
"tags": [],
|
|
222
|
+
"docs": "True if an error occurred while stopping.",
|
|
223
|
+
"complexTypes": [],
|
|
224
|
+
"type": "boolean"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"name": "errorMessage",
|
|
228
|
+
"tags": [],
|
|
229
|
+
"docs": "Error description or null on success.",
|
|
230
|
+
"complexTypes": [],
|
|
231
|
+
"type": "string | null"
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
"name": "publishing",
|
|
235
|
+
"tags": [],
|
|
236
|
+
"docs": "Whether the advertiser remains active (should be false on success).",
|
|
237
|
+
"complexTypes": [],
|
|
238
|
+
"type": "boolean"
|
|
239
|
+
}
|
|
240
|
+
]
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"name": "MdnsDiscoverResult",
|
|
244
|
+
"slug": "mdnsdiscoverresult",
|
|
245
|
+
"docs": "Result of discover(). Contains normalized services and error information.",
|
|
246
|
+
"tags": [
|
|
247
|
+
{
|
|
248
|
+
"name": "public"
|
|
249
|
+
}
|
|
250
|
+
],
|
|
251
|
+
"methods": [],
|
|
252
|
+
"properties": [
|
|
253
|
+
{
|
|
254
|
+
"name": "error",
|
|
255
|
+
"tags": [],
|
|
256
|
+
"docs": "True if discovery encountered an error (partial results may still be present).",
|
|
257
|
+
"complexTypes": [],
|
|
258
|
+
"type": "boolean"
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"name": "errorMessage",
|
|
262
|
+
"tags": [],
|
|
263
|
+
"docs": "Error description or null when no error occurred.",
|
|
264
|
+
"complexTypes": [],
|
|
265
|
+
"type": "string | null"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
"name": "servicesFound",
|
|
269
|
+
"tags": [],
|
|
270
|
+
"docs": "Convenience count equal to services.length.",
|
|
271
|
+
"complexTypes": [],
|
|
272
|
+
"type": "number"
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
"name": "services",
|
|
276
|
+
"tags": [],
|
|
277
|
+
"docs": "Normalized list of discovered services.",
|
|
278
|
+
"complexTypes": [
|
|
279
|
+
"MdnsService"
|
|
280
|
+
],
|
|
281
|
+
"type": "MdnsService[]"
|
|
282
|
+
}
|
|
283
|
+
]
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
"name": "MdnsService",
|
|
287
|
+
"slug": "mdnsservice",
|
|
288
|
+
"docs": "Normalized description of a discovered Bonjour/mDNS service.\nReturned from {@link mDNSPlugin.discover}.",
|
|
289
|
+
"tags": [
|
|
290
|
+
{
|
|
291
|
+
"text": "- `hosts` contains resolved IPv4/IPv6 numeric addresses (no DNS names).\n- iOS returns `txt` when present. Android (NSD) does not expose TXT records via public APIs,\n so `txt` is usually omitted on Android.\n- `domain` is typically `\"local.\"`.",
|
|
292
|
+
"name": "remarks"
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
"name": "public"
|
|
296
|
+
}
|
|
297
|
+
],
|
|
298
|
+
"methods": [],
|
|
299
|
+
"properties": [
|
|
300
|
+
{
|
|
301
|
+
"name": "name",
|
|
302
|
+
"tags": [],
|
|
303
|
+
"docs": "Instance name of the service (may be uniqued by the OS, e.g. \"My App (2)\").",
|
|
304
|
+
"complexTypes": [],
|
|
305
|
+
"type": "string"
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
"name": "type",
|
|
309
|
+
"tags": [],
|
|
310
|
+
"docs": "Full service type including the trailing dot, e.g. `\"_http._tcp.\"`.",
|
|
311
|
+
"complexTypes": [],
|
|
312
|
+
"type": "string"
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
"name": "domain",
|
|
316
|
+
"tags": [],
|
|
317
|
+
"docs": "Service domain; typically `\"local.\"`.",
|
|
318
|
+
"complexTypes": [],
|
|
319
|
+
"type": "string"
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
"name": "port",
|
|
323
|
+
"tags": [],
|
|
324
|
+
"docs": "TCP port the service advertises.",
|
|
325
|
+
"complexTypes": [],
|
|
326
|
+
"type": "number"
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
"name": "hosts",
|
|
330
|
+
"tags": [
|
|
331
|
+
{
|
|
332
|
+
"text": "`[\"192.168.1.42\", \"fe80::1234:abcd:...\"]`",
|
|
333
|
+
"name": "example"
|
|
334
|
+
}
|
|
335
|
+
],
|
|
336
|
+
"docs": "Resolved numeric IP addresses (IPv4/IPv6).",
|
|
337
|
+
"complexTypes": [],
|
|
338
|
+
"type": "string[]"
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
"name": "txt",
|
|
342
|
+
"tags": [
|
|
343
|
+
{
|
|
344
|
+
"text": "Not all services publish TXT data.",
|
|
345
|
+
"name": "remarks"
|
|
346
|
+
}
|
|
347
|
+
],
|
|
348
|
+
"docs": "TXT dictionary (key → value). Usually present on iOS; Android NSD does not populate this.",
|
|
349
|
+
"complexTypes": [
|
|
350
|
+
"MdnsTxt"
|
|
351
|
+
],
|
|
352
|
+
"type": "MdnsTxt"
|
|
353
|
+
}
|
|
354
|
+
]
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
"name": "MdnsDiscoverOptions",
|
|
358
|
+
"slug": "mdnsdiscoveroptions",
|
|
359
|
+
"docs": "Options for Bonjour/mDNS discovery.",
|
|
360
|
+
"tags": [
|
|
361
|
+
{
|
|
362
|
+
"text": "- The `id` filter matches the normalized name and also accepts prefix matches\n (to handle OS-added `\" (n)\"` suffixes).\n- When `useNW` is `true` on iOS, discovery uses `NWBrowser` for better P2P behavior.",
|
|
363
|
+
"name": "remarks"
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
"name": "public"
|
|
367
|
+
}
|
|
368
|
+
],
|
|
369
|
+
"methods": [],
|
|
370
|
+
"properties": [
|
|
371
|
+
{
|
|
372
|
+
"name": "type",
|
|
373
|
+
"tags": [
|
|
374
|
+
{
|
|
375
|
+
"text": "`\"_http._tcp.\"`",
|
|
376
|
+
"name": "defaultValue"
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
"text": "`\"_comm._tcp.\"`",
|
|
380
|
+
"name": "example"
|
|
381
|
+
}
|
|
382
|
+
],
|
|
383
|
+
"docs": "Service type (including the trailing dot).",
|
|
384
|
+
"complexTypes": [],
|
|
385
|
+
"type": "string | undefined"
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
"name": "name",
|
|
389
|
+
"tags": [
|
|
390
|
+
{
|
|
391
|
+
"text": "`\"MyAppName\"`",
|
|
392
|
+
"name": "example"
|
|
393
|
+
}
|
|
394
|
+
],
|
|
395
|
+
"docs": "Optional instance name filter (prefix-safe).",
|
|
396
|
+
"complexTypes": [],
|
|
397
|
+
"type": "string | undefined"
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
"name": "timeout",
|
|
401
|
+
"tags": [
|
|
402
|
+
{
|
|
403
|
+
"text": "`3000`",
|
|
404
|
+
"name": "defaultValue"
|
|
405
|
+
}
|
|
406
|
+
],
|
|
407
|
+
"docs": "Discovery timeout in milliseconds.",
|
|
408
|
+
"complexTypes": [],
|
|
409
|
+
"type": "number | undefined"
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
"name": "useNW",
|
|
413
|
+
"tags": [
|
|
414
|
+
{
|
|
415
|
+
"text": "`true`",
|
|
416
|
+
"name": "defaultValue"
|
|
417
|
+
}
|
|
418
|
+
],
|
|
419
|
+
"docs": "iOS-only hint to use `NWBrowser` instead of `NetServiceBrowser`.",
|
|
420
|
+
"complexTypes": [],
|
|
421
|
+
"type": "boolean | undefined"
|
|
422
|
+
}
|
|
423
|
+
]
|
|
424
|
+
}
|
|
425
|
+
],
|
|
426
|
+
"enums": [],
|
|
427
|
+
"typeAliases": [
|
|
428
|
+
{
|
|
429
|
+
"name": "MdnsTxt",
|
|
430
|
+
"slug": "mdnstxt",
|
|
431
|
+
"docs": "Key–value map for TXT records of a Bonjour/mDNS service.\nValues are UTF-8 strings; binary payloads are not supported by this API.",
|
|
432
|
+
"types": [
|
|
433
|
+
{
|
|
434
|
+
"text": "Record<string, string>",
|
|
435
|
+
"complexTypes": [
|
|
436
|
+
"Record"
|
|
437
|
+
]
|
|
438
|
+
}
|
|
439
|
+
]
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
"name": "Record",
|
|
443
|
+
"slug": "record",
|
|
444
|
+
"docs": "Construct a type with a set of properties K of type T",
|
|
445
|
+
"types": [
|
|
446
|
+
{
|
|
447
|
+
"text": "{\r\n [P in K]: T;\r\n}",
|
|
448
|
+
"complexTypes": [
|
|
449
|
+
"K",
|
|
450
|
+
"T"
|
|
451
|
+
]
|
|
452
|
+
}
|
|
453
|
+
]
|
|
454
|
+
}
|
|
455
|
+
],
|
|
456
|
+
"pluginConfigs": []
|
|
457
|
+
}
|