@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.
- package/CHANGELOG.md +110 -0
- package/DevioartsCapacitorMdns.podspec +3 -3
- package/Package.swift +1 -1
- package/README.md +272 -101
- package/android/build.gradle +3 -9
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/devioarts/capacitor/mdns/AndroidNsdBackend.kt +145 -0
- package/android/src/main/java/com/devioarts/capacitor/mdns/MdnsOptions.kt +32 -0
- package/android/src/main/java/com/devioarts/capacitor/mdns/MdnsValidation.kt +26 -0
- package/android/src/main/java/com/devioarts/capacitor/mdns/NsdBackend.kt +59 -0
- package/android/src/main/java/com/devioarts/capacitor/mdns/mDNS.kt +496 -175
- package/android/src/main/java/com/devioarts/capacitor/mdns/mDNSPlugin.kt +85 -49
- package/dist/docs.json +313 -15
- package/dist/esm/definitions.d.ts +89 -16
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.js +22 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.d.ts +8 -1
- package/dist/esm/web.js +35 -3
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +57 -4
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +57 -4
- package/dist/plugin.js.map +1 -1
- package/docs/electron.md +91 -0
- package/docs/platform-setup.md +58 -0
- package/docs/playground.md +50 -0
- package/docs/runtime-behavior.md +80 -0
- package/electron/dist/plugin-settings.js +22 -0
- package/electron/dist/plugin-settings.js.map +1 -0
- package/electron/dist/plugin.cjs.js +774 -0
- package/electron/dist/plugin.cjs.js.map +1 -0
- package/electron/global.d.ts +2 -0
- package/electron/mdns-bridge.cjs +33 -4
- package/electron/mdns.ts +628 -107
- package/electron/rollup.config.mjs +22 -0
- package/electron/src/index.ts +2 -0
- package/electron/src/plugin-settings.ts +19 -0
- package/electron/tsconfig.json +21 -0
- package/electron/types-public/index.d.ts +47 -0
- package/ios/Sources/mDNSPlugin/mDNS.swift +481 -124
- package/ios/Sources/mDNSPlugin/mDNSPlugin.swift +85 -23
- package/ios/Tests/mDNSPluginTests/BridgeTests.swift +46 -0
- package/ios/Tests/mDNSPluginTests/MDNSTests.swift +490 -0
- package/package.json +55 -20
- package/ios/Tests/mDNSPluginTests/mDNSPluginTests.swift +0 -15
|
@@ -16,13 +16,13 @@ import org.json.JSONObject
|
|
|
16
16
|
* - Never reject for runtime errors; always resolve with { error, errorMessage }.
|
|
17
17
|
*
|
|
18
18
|
* Parameters (strict, no legacy):
|
|
19
|
-
* - startBroadcast: { type?: string, name?: string, port: number, txt?: Record<string,string> }
|
|
19
|
+
* - startBroadcast: { type?: string, name?: string, port: number, txt?: Record<string,string> }
|
|
20
20
|
* - stopBroadcast: {}
|
|
21
21
|
* - discover: { type?: string, name?: string, timeout?: number }
|
|
22
22
|
*
|
|
23
23
|
* Return shapes:
|
|
24
24
|
* - startBroadcast -> { publishing: boolean, name: string, error: boolean, errorMessage: string|null }
|
|
25
|
-
* - stopBroadcast -> { publishing:
|
|
25
|
+
* - stopBroadcast -> { publishing: boolean, error: boolean, errorMessage: string|null }
|
|
26
26
|
* - discover -> {
|
|
27
27
|
* error: boolean, errorMessage: string|null,
|
|
28
28
|
* servicesFound: number,
|
|
@@ -41,8 +41,7 @@ class mDNSPlugin : Plugin() {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
override fun handleOnDestroy() {
|
|
44
|
-
mdns.close()
|
|
45
|
-
scope.cancel()
|
|
44
|
+
mdns.close { scope.cancel() }
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
// ----------------------- Helpers -----------------------
|
|
@@ -58,8 +57,8 @@ class mDNSPlugin : Plugin() {
|
|
|
58
57
|
.put("error", error)
|
|
59
58
|
.put("errorMessage", jnull(msg))
|
|
60
59
|
|
|
61
|
-
private fun jsResultStop(error: Boolean, msg: String?): JSObject =
|
|
62
|
-
JSObject().put("publishing",
|
|
60
|
+
private fun jsResultStop(publishing: Boolean, error: Boolean, msg: String?): JSObject =
|
|
61
|
+
JSObject().put("publishing", publishing)
|
|
63
62
|
.put("error", error)
|
|
64
63
|
.put("errorMessage", jnull(msg))
|
|
65
64
|
|
|
@@ -70,39 +69,51 @@ class mDNSPlugin : Plugin() {
|
|
|
70
69
|
.put("servicesFound", services.length())
|
|
71
70
|
.put("services", services)
|
|
72
71
|
|
|
72
|
+
private fun serviceObject(s: mDNS.MdnsService): JSObject = JSObject().apply {
|
|
73
|
+
put("name", s.name)
|
|
74
|
+
put("type", s.type)
|
|
75
|
+
put("domain", "local.")
|
|
76
|
+
put("port", s.port)
|
|
77
|
+
put("hosts", JSONArray(s.hosts))
|
|
78
|
+
if (s.txt.isNotEmpty()) put("txt", JSObject().apply { s.txt.forEach { (k, v) -> put(k, v) } })
|
|
79
|
+
}
|
|
80
|
+
|
|
73
81
|
// ----------------------- API -----------------------
|
|
74
82
|
|
|
83
|
+
@PluginMethod
|
|
84
|
+
fun getPluginPlatform(call: PluginCall) {
|
|
85
|
+
call.resolve(JSObject().put("platform", "android"))
|
|
86
|
+
}
|
|
87
|
+
|
|
75
88
|
/**
|
|
76
89
|
* Start advertising a Bonjour/mDNS service.
|
|
77
90
|
* - type: default "_http._tcp."
|
|
78
|
-
* - name: default
|
|
91
|
+
* - name: default DevIOArtsMDNS
|
|
79
92
|
* - port: required (> 0)
|
|
80
93
|
*/
|
|
81
94
|
@PluginMethod
|
|
82
95
|
fun startBroadcast(call: PluginCall) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
} catch (t: Throwable) {
|
|
105
|
-
call.resolve(jsResultBroadcast(false, "", true, toErrorMessage(t)))
|
|
96
|
+
scope.launch {
|
|
97
|
+
try {
|
|
98
|
+
val type = MdnsValidation.type(MdnsOptions.string(call.data.opt("type"), "type"))
|
|
99
|
+
val name = MdnsValidation.name(MdnsOptions.string(call.data.opt("name"), "name")).ifEmpty { "DevIOArtsMDNS" }
|
|
100
|
+
val port = MdnsOptions.port(call.data.opt("port"))
|
|
101
|
+
val txt = MdnsOptions.txt(call.data.opt("txt"))
|
|
102
|
+
mdns.broadcast(
|
|
103
|
+
typeRaw = type,
|
|
104
|
+
name = name,
|
|
105
|
+
port = port,
|
|
106
|
+
txt = txt,
|
|
107
|
+
onSuccess = { published ->
|
|
108
|
+
call.resolve(jsResultBroadcast(true, published, false, null))
|
|
109
|
+
},
|
|
110
|
+
onError = { err ->
|
|
111
|
+
call.resolve(jsResultBroadcast(mdns.isPublishing, "", true, toErrorMessage(err)))
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
} catch (t: Throwable) {
|
|
115
|
+
call.resolve(jsResultBroadcast(mdns.isPublishing, "", true, toErrorMessage(t)))
|
|
116
|
+
}
|
|
106
117
|
}
|
|
107
118
|
}
|
|
108
119
|
|
|
@@ -112,10 +123,11 @@ class mDNSPlugin : Plugin() {
|
|
|
112
123
|
@PluginMethod
|
|
113
124
|
fun stopBroadcast(call: PluginCall) {
|
|
114
125
|
try {
|
|
115
|
-
mdns.stopBroadcast
|
|
116
|
-
|
|
126
|
+
mdns.stopBroadcast { publishing, error ->
|
|
127
|
+
call.resolve(jsResultStop(publishing, error != null, error?.let { toErrorMessage(it) }))
|
|
128
|
+
}
|
|
117
129
|
} catch (t: Throwable) {
|
|
118
|
-
call.resolve(jsResultStop(true, toErrorMessage(t)))
|
|
130
|
+
call.resolve(jsResultStop(true, true, toErrorMessage(t)))
|
|
119
131
|
}
|
|
120
132
|
}
|
|
121
133
|
|
|
@@ -127,29 +139,53 @@ class mDNSPlugin : Plugin() {
|
|
|
127
139
|
*/
|
|
128
140
|
@PluginMethod
|
|
129
141
|
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
142
|
scope.launch {
|
|
135
143
|
try {
|
|
144
|
+
val type = MdnsValidation.type(MdnsOptions.string(call.data.opt("type"), "type"))
|
|
145
|
+
val targetName = MdnsValidation.name(MdnsOptions.string(call.data.opt("name"), "name")).takeIf { it.isNotEmpty() }
|
|
146
|
+
val timeout = MdnsOptions.timeout(call.data.opt("timeout"))
|
|
136
147
|
val list = mdns.discover(type, targetName, timeout)
|
|
137
|
-
val arr = JSONArray(list.map {
|
|
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
|
-
val hosts = JSONArray()
|
|
143
|
-
s.hosts.forEach { hosts.put(it) }
|
|
144
|
-
put("hosts", hosts)
|
|
145
|
-
put("port", s.port)
|
|
146
|
-
// TXT not available via NSD -> omitted on Android
|
|
147
|
-
}
|
|
148
|
-
})
|
|
148
|
+
val arr = JSONArray(list.map { serviceObject(it) })
|
|
149
149
|
call.resolve(jsResultDiscover(false, null, arr))
|
|
150
150
|
} catch (t: Throwable) {
|
|
151
151
|
call.resolve(jsResultDiscover(true, toErrorMessage(t), JSONArray()))
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
+
|
|
156
|
+
@PluginMethod
|
|
157
|
+
fun watchServices(call: PluginCall) {
|
|
158
|
+
val types = call.getArray("types")
|
|
159
|
+
val raw = if (types == null) emptyList() else (0 until types.length()).map { types.opt(it) }
|
|
160
|
+
if (raw.isEmpty() || raw.any { it !is String }) {
|
|
161
|
+
call.resolve(JSObject().put("error", true).put("errorMessage", "Expected a nonempty array of service types").put("watchersStarted", 0))
|
|
162
|
+
return
|
|
163
|
+
}
|
|
164
|
+
scope.launch {
|
|
165
|
+
try {
|
|
166
|
+
val started = mdns.watchServices(raw.map { it as String }, object : mDNS.WatchListener {
|
|
167
|
+
override fun onServiceFound(service: mDNS.MdnsService) {
|
|
168
|
+
notifyListeners("serviceFound", JSObject().put("service", serviceObject(service)))
|
|
169
|
+
}
|
|
170
|
+
override fun onServiceLost(service: mDNS.MdnsService) {
|
|
171
|
+
notifyListeners("serviceLost", JSObject().put("service", serviceObject(service)))
|
|
172
|
+
}
|
|
173
|
+
override fun onError(type: String, message: String, watching: Boolean) {
|
|
174
|
+
notifyListeners("watchError", JSObject().put("type", type).put("errorMessage", message).put("watching", watching))
|
|
175
|
+
}
|
|
176
|
+
})
|
|
177
|
+
call.resolve(JSObject().put("error", false).put("errorMessage", JSONObject.NULL).put("watchersStarted", started))
|
|
178
|
+
} catch (t: Throwable) {
|
|
179
|
+
call.resolve(JSObject().put("error", true).put("errorMessage", toErrorMessage(t)).put("watchersStarted", 0))
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
@PluginMethod
|
|
185
|
+
fun stopWatching(call: PluginCall) {
|
|
186
|
+
scope.launch {
|
|
187
|
+
val error = mdns.stopWatching()
|
|
188
|
+
call.resolve(JSObject().put("watching", false).put("error", error != null).put("errorMessage", jnull(error?.message)))
|
|
189
|
+
}
|
|
190
|
+
}
|
|
155
191
|
}
|
package/dist/docs.json
CHANGED
|
@@ -13,6 +13,23 @@
|
|
|
13
13
|
}
|
|
14
14
|
],
|
|
15
15
|
"methods": [
|
|
16
|
+
{
|
|
17
|
+
"name": "getPluginPlatform",
|
|
18
|
+
"signature": "() => Promise<MdnsPluginPlatformResult>",
|
|
19
|
+
"parameters": [],
|
|
20
|
+
"returns": "Promise<MdnsPluginPlatformResult>",
|
|
21
|
+
"tags": [
|
|
22
|
+
{
|
|
23
|
+
"name": "returns",
|
|
24
|
+
"text": "Promise resolving to `MdnsPluginPlatformResult`."
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"docs": "Return the platform implementation currently serving plugin calls.",
|
|
28
|
+
"complexTypes": [
|
|
29
|
+
"MdnsPluginPlatformResult"
|
|
30
|
+
],
|
|
31
|
+
"slug": "getpluginplatform"
|
|
32
|
+
},
|
|
16
33
|
{
|
|
17
34
|
"name": "startBroadcast",
|
|
18
35
|
"signature": "(options: MdnsBroadcastOptions) => Promise<MdnsBroadcastResult>",
|
|
@@ -53,7 +70,7 @@
|
|
|
53
70
|
},
|
|
54
71
|
{
|
|
55
72
|
"name": "remarks",
|
|
56
|
-
"text": "The `publishing` flag may be `false` after a successful stop."
|
|
73
|
+
"text": "The `publishing` flag may be `false` after a successful stop.\nStopping is idempotent and is safe to call even if publishing never fully started."
|
|
57
74
|
}
|
|
58
75
|
],
|
|
59
76
|
"docs": "Stop advertising the currently registered service (no-op if none).",
|
|
@@ -84,7 +101,7 @@
|
|
|
84
101
|
},
|
|
85
102
|
{
|
|
86
103
|
"name": "remarks",
|
|
87
|
-
"text": "The result list is normalized across platforms.
|
|
104
|
+
"text": "The result list is normalized across platforms."
|
|
88
105
|
}
|
|
89
106
|
],
|
|
90
107
|
"docs": "Discover services of a given type and optionally filter by instance name.",
|
|
@@ -93,11 +110,122 @@
|
|
|
93
110
|
"MdnsDiscoverOptions"
|
|
94
111
|
],
|
|
95
112
|
"slug": "discover"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"name": "watchServices",
|
|
116
|
+
"signature": "(options: MdnsWatchOptions) => Promise<MdnsWatchResult>",
|
|
117
|
+
"parameters": [
|
|
118
|
+
{
|
|
119
|
+
"name": "options",
|
|
120
|
+
"docs": "",
|
|
121
|
+
"type": "MdnsWatchOptions"
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
"returns": "Promise<MdnsWatchResult>",
|
|
125
|
+
"tags": [],
|
|
126
|
+
"docs": "Continuously watch several service types. A valid call replaces the previous watch.\nRegister listeners before starting. Each resolved service emits `serviceFound` once;\ndisappearance emits `serviceLost` with its last snapshot. No loss is emitted for an\nunresolved service. Watching and one-shot discovery can run together.\nThanks to Idrimi for contributing the original continuous discovery feature (PR #7).",
|
|
127
|
+
"complexTypes": [
|
|
128
|
+
"MdnsWatchResult",
|
|
129
|
+
"MdnsWatchOptions"
|
|
130
|
+
],
|
|
131
|
+
"slug": "watchservices"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"name": "stopWatching",
|
|
135
|
+
"signature": "() => Promise<MdnsWatchStopResult>",
|
|
136
|
+
"parameters": [],
|
|
137
|
+
"returns": "Promise<MdnsWatchStopResult>",
|
|
138
|
+
"tags": [],
|
|
139
|
+
"docs": "Stop all watchers. No events from that watch are emitted after this resolves.",
|
|
140
|
+
"complexTypes": [
|
|
141
|
+
"MdnsWatchStopResult"
|
|
142
|
+
],
|
|
143
|
+
"slug": "stopwatching"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"name": "addListener",
|
|
147
|
+
"signature": "(eventName: 'serviceFound' | 'serviceLost', handler: (event: MdnsServiceEvent) => void) => Promise<PluginListenerHandle>",
|
|
148
|
+
"parameters": [
|
|
149
|
+
{
|
|
150
|
+
"name": "eventName",
|
|
151
|
+
"docs": "",
|
|
152
|
+
"type": "'serviceFound' | 'serviceLost'"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"name": "handler",
|
|
156
|
+
"docs": "",
|
|
157
|
+
"type": "(event: MdnsServiceEvent) => void"
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
"returns": "Promise<PluginListenerHandle>",
|
|
161
|
+
"tags": [],
|
|
162
|
+
"docs": "",
|
|
163
|
+
"complexTypes": [
|
|
164
|
+
"PluginListenerHandle",
|
|
165
|
+
"MdnsServiceEvent"
|
|
166
|
+
],
|
|
167
|
+
"slug": "addlistenerservicefound--servicelost-"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"name": "addListener",
|
|
171
|
+
"signature": "(eventName: 'watchError', handler: (event: MdnsWatchErrorEvent) => void) => Promise<PluginListenerHandle>",
|
|
172
|
+
"parameters": [
|
|
173
|
+
{
|
|
174
|
+
"name": "eventName",
|
|
175
|
+
"docs": "",
|
|
176
|
+
"type": "'watchError'"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"name": "handler",
|
|
180
|
+
"docs": "",
|
|
181
|
+
"type": "(event: MdnsWatchErrorEvent) => void"
|
|
182
|
+
}
|
|
183
|
+
],
|
|
184
|
+
"returns": "Promise<PluginListenerHandle>",
|
|
185
|
+
"tags": [],
|
|
186
|
+
"docs": "",
|
|
187
|
+
"complexTypes": [
|
|
188
|
+
"PluginListenerHandle",
|
|
189
|
+
"MdnsWatchErrorEvent"
|
|
190
|
+
],
|
|
191
|
+
"slug": "addlistenerwatcherror-"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"name": "removeAllListeners",
|
|
195
|
+
"signature": "() => Promise<void>",
|
|
196
|
+
"parameters": [],
|
|
197
|
+
"returns": "Promise<void>",
|
|
198
|
+
"tags": [],
|
|
199
|
+
"docs": "",
|
|
200
|
+
"complexTypes": [],
|
|
201
|
+
"slug": "removealllisteners"
|
|
96
202
|
}
|
|
97
203
|
],
|
|
98
204
|
"properties": []
|
|
99
205
|
},
|
|
100
206
|
"interfaces": [
|
|
207
|
+
{
|
|
208
|
+
"name": "MdnsPluginPlatformResult",
|
|
209
|
+
"slug": "mdnspluginplatformresult",
|
|
210
|
+
"docs": "Result of getPluginPlatform(). Useful for validating that calls are routed\nthrough the expected platform bridge.",
|
|
211
|
+
"tags": [
|
|
212
|
+
{
|
|
213
|
+
"name": "public"
|
|
214
|
+
}
|
|
215
|
+
],
|
|
216
|
+
"methods": [],
|
|
217
|
+
"properties": [
|
|
218
|
+
{
|
|
219
|
+
"name": "platform",
|
|
220
|
+
"tags": [],
|
|
221
|
+
"docs": "Platform implementation that produced this result.",
|
|
222
|
+
"complexTypes": [
|
|
223
|
+
"MdnsPluginPlatform"
|
|
224
|
+
],
|
|
225
|
+
"type": "MdnsPluginPlatform"
|
|
226
|
+
}
|
|
227
|
+
]
|
|
228
|
+
},
|
|
101
229
|
{
|
|
102
230
|
"name": "MdnsBroadcastResult",
|
|
103
231
|
"slug": "mdnsbroadcastresult",
|
|
@@ -133,7 +261,7 @@
|
|
|
133
261
|
{
|
|
134
262
|
"name": "publishing",
|
|
135
263
|
"tags": [],
|
|
136
|
-
"docs": "Whether
|
|
264
|
+
"docs": "Whether an advertiser is active, or may still be active after failed cleanup.",
|
|
137
265
|
"complexTypes": [],
|
|
138
266
|
"type": "boolean"
|
|
139
267
|
}
|
|
@@ -145,7 +273,7 @@
|
|
|
145
273
|
"docs": "Options for starting a Bonjour/mDNS advertisement.",
|
|
146
274
|
"tags": [
|
|
147
275
|
{
|
|
148
|
-
"text": "-
|
|
276
|
+
"text": "- Service types accept an optional trailing dot; results always include it.\n- Instance `name` should be short and human-readable; the OS may append `\" (n)\"` to ensure uniqueness.\n Electron rejects a name conflict instead of renaming the service.\n- Advertising TXT is supported on iOS, Android and Electron. Invalid input preserves the active advertisement.\n- Native implementations guard publish with a timeout and return `error: true` instead of\n leaving the Promise pending when the OS does not deliver a publish callback.\n- Only one advertisement is active at a time. Starting a new one stops the previous one first.",
|
|
149
277
|
"name": "remarks"
|
|
150
278
|
},
|
|
151
279
|
{
|
|
@@ -173,9 +301,9 @@
|
|
|
173
301
|
{
|
|
174
302
|
"name": "name",
|
|
175
303
|
"tags": [],
|
|
176
|
-
"docs": "Service instance name.",
|
|
304
|
+
"docs": "Service instance name (maximum 63 UTF-8 bytes). Defaults to `DevIOArtsMDNS`.",
|
|
177
305
|
"complexTypes": [],
|
|
178
|
-
"type": "string"
|
|
306
|
+
"type": "string | undefined"
|
|
179
307
|
},
|
|
180
308
|
{
|
|
181
309
|
"name": "port",
|
|
@@ -193,7 +321,7 @@
|
|
|
193
321
|
"name": "txt",
|
|
194
322
|
"tags": [
|
|
195
323
|
{
|
|
196
|
-
"text": "
|
|
324
|
+
"text": "Keys must be unique ignoring case, nonempty printable ASCII without `=`. Each `key=value` entry must fit in 255 UTF-8 bytes. The complete record is limited to 1300 bytes including length prefixes. Non-string values are rejected.",
|
|
197
325
|
"name": "remarks"
|
|
198
326
|
}
|
|
199
327
|
],
|
|
@@ -233,7 +361,7 @@
|
|
|
233
361
|
{
|
|
234
362
|
"name": "publishing",
|
|
235
363
|
"tags": [],
|
|
236
|
-
"docs": "
|
|
364
|
+
"docs": "False after confirmed stop; true when stopping failed and the advertiser may still be active.",
|
|
237
365
|
"complexTypes": [],
|
|
238
366
|
"type": "boolean"
|
|
239
367
|
}
|
|
@@ -274,7 +402,7 @@
|
|
|
274
402
|
{
|
|
275
403
|
"name": "services",
|
|
276
404
|
"tags": [],
|
|
277
|
-
"docs": "
|
|
405
|
+
"docs": "Resolved services with numeric addresses. Empty on error; partial results are discarded.",
|
|
278
406
|
"complexTypes": [
|
|
279
407
|
"MdnsService"
|
|
280
408
|
],
|
|
@@ -288,7 +416,7 @@
|
|
|
288
416
|
"docs": "Normalized description of a discovered Bonjour/mDNS service.\nReturned from {@link mDNSPlugin.discover}.",
|
|
289
417
|
"tags": [
|
|
290
418
|
{
|
|
291
|
-
"text": "- `hosts` contains resolved IPv4/IPv6 numeric addresses (no DNS names).\n-
|
|
419
|
+
"text": "- `hosts` contains resolved IPv4/IPv6 numeric addresses (no DNS names).\n- IPv4 addresses precede IPv6; order within each family follows discovery order.\n- Native IPv6 scope suffixes are preserved (`%<scope-id>` on iOS; the OS-provided scope on Android).\n Electron may return link-local IPv6 without a scope; callers must not assume every address is reachable.\n- Resolved TXT records are returned when present.\n- `domain` is typically `\"local.\"`.",
|
|
292
420
|
"name": "remarks"
|
|
293
421
|
},
|
|
294
422
|
{
|
|
@@ -321,7 +449,7 @@
|
|
|
321
449
|
{
|
|
322
450
|
"name": "port",
|
|
323
451
|
"tags": [],
|
|
324
|
-
"docs": "
|
|
452
|
+
"docs": "Port the service advertises.",
|
|
325
453
|
"complexTypes": [],
|
|
326
454
|
"type": "number"
|
|
327
455
|
},
|
|
@@ -333,10 +461,17 @@
|
|
|
333
461
|
"name": "example"
|
|
334
462
|
}
|
|
335
463
|
],
|
|
336
|
-
"docs": "Resolved numeric IP addresses
|
|
464
|
+
"docs": "Resolved numeric IP addresses, IPv4 first, then IPv6 with any available scope suffix.",
|
|
337
465
|
"complexTypes": [],
|
|
338
466
|
"type": "string[]"
|
|
339
467
|
},
|
|
468
|
+
{
|
|
469
|
+
"name": "hostname",
|
|
470
|
+
"tags": [],
|
|
471
|
+
"docs": "Host name when supplied by the platform, e.g. `\"my-device.local.\"`.",
|
|
472
|
+
"complexTypes": [],
|
|
473
|
+
"type": "string | undefined"
|
|
474
|
+
},
|
|
340
475
|
{
|
|
341
476
|
"name": "txt",
|
|
342
477
|
"tags": [
|
|
@@ -345,7 +480,7 @@
|
|
|
345
480
|
"name": "remarks"
|
|
346
481
|
}
|
|
347
482
|
],
|
|
348
|
-
"docs": "TXT dictionary (key → value).
|
|
483
|
+
"docs": "TXT dictionary (key → value).",
|
|
349
484
|
"complexTypes": [
|
|
350
485
|
"MdnsTxt"
|
|
351
486
|
],
|
|
@@ -359,7 +494,7 @@
|
|
|
359
494
|
"docs": "Options for Bonjour/mDNS discovery.",
|
|
360
495
|
"tags": [
|
|
361
496
|
{
|
|
362
|
-
"text": "- The `
|
|
497
|
+
"text": "- The `name` 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.\n- A valid new discovery replaces the previous request with an error on every platform.\n- Dots and hyphens are equivalent when matching names; returned names retain their advertised spelling.\n- Without a name filter, browsing continues for the entire timeout. With a filter it may finish once a matching IP address resolves.",
|
|
363
498
|
"name": "remarks"
|
|
364
499
|
},
|
|
365
500
|
{
|
|
@@ -404,7 +539,7 @@
|
|
|
404
539
|
"name": "defaultValue"
|
|
405
540
|
}
|
|
406
541
|
],
|
|
407
|
-
"docs": "Discovery timeout in milliseconds.",
|
|
542
|
+
"docs": "Discovery timeout in milliseconds. Finite numbers only; fractions are truncated and the delay is clamped to 0–2147483647.",
|
|
408
543
|
"complexTypes": [],
|
|
409
544
|
"type": "number | undefined"
|
|
410
545
|
},
|
|
@@ -421,10 +556,173 @@
|
|
|
421
556
|
"type": "boolean | undefined"
|
|
422
557
|
}
|
|
423
558
|
]
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
"name": "MdnsWatchResult",
|
|
562
|
+
"slug": "mdnswatchresult",
|
|
563
|
+
"docs": "Native browsers have been requested; later failures are reported through `watchError`.",
|
|
564
|
+
"tags": [],
|
|
565
|
+
"methods": [],
|
|
566
|
+
"properties": [
|
|
567
|
+
{
|
|
568
|
+
"name": "error",
|
|
569
|
+
"tags": [],
|
|
570
|
+
"docs": "",
|
|
571
|
+
"complexTypes": [],
|
|
572
|
+
"type": "boolean"
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
"name": "errorMessage",
|
|
576
|
+
"tags": [],
|
|
577
|
+
"docs": "",
|
|
578
|
+
"complexTypes": [],
|
|
579
|
+
"type": "string | null"
|
|
580
|
+
},
|
|
581
|
+
{
|
|
582
|
+
"name": "watchersStarted",
|
|
583
|
+
"tags": [],
|
|
584
|
+
"docs": "",
|
|
585
|
+
"complexTypes": [],
|
|
586
|
+
"type": "number"
|
|
587
|
+
}
|
|
588
|
+
]
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
"name": "MdnsWatchOptions",
|
|
592
|
+
"slug": "mdnswatchoptions",
|
|
593
|
+
"docs": "Options for continuous discovery on iOS, Android and Electron.",
|
|
594
|
+
"tags": [],
|
|
595
|
+
"methods": [],
|
|
596
|
+
"properties": [
|
|
597
|
+
{
|
|
598
|
+
"name": "types",
|
|
599
|
+
"tags": [],
|
|
600
|
+
"docs": "Nonempty list of service types. Trailing dots are optional; duplicates are merged.",
|
|
601
|
+
"complexTypes": [],
|
|
602
|
+
"type": "string[]"
|
|
603
|
+
}
|
|
604
|
+
]
|
|
605
|
+
},
|
|
606
|
+
{
|
|
607
|
+
"name": "MdnsWatchStopResult",
|
|
608
|
+
"slug": "mdnswatchstopresult",
|
|
609
|
+
"docs": "Stops watching independently of any active broadcast.",
|
|
610
|
+
"tags": [],
|
|
611
|
+
"methods": [],
|
|
612
|
+
"properties": [
|
|
613
|
+
{
|
|
614
|
+
"name": "error",
|
|
615
|
+
"tags": [],
|
|
616
|
+
"docs": "",
|
|
617
|
+
"complexTypes": [],
|
|
618
|
+
"type": "boolean"
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
"name": "errorMessage",
|
|
622
|
+
"tags": [],
|
|
623
|
+
"docs": "",
|
|
624
|
+
"complexTypes": [],
|
|
625
|
+
"type": "string | null"
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
"name": "watching",
|
|
629
|
+
"tags": [],
|
|
630
|
+
"docs": "",
|
|
631
|
+
"complexTypes": [],
|
|
632
|
+
"type": "boolean"
|
|
633
|
+
}
|
|
634
|
+
]
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
"name": "PluginListenerHandle",
|
|
638
|
+
"slug": "pluginlistenerhandle",
|
|
639
|
+
"docs": "",
|
|
640
|
+
"tags": [],
|
|
641
|
+
"methods": [],
|
|
642
|
+
"properties": [
|
|
643
|
+
{
|
|
644
|
+
"name": "remove",
|
|
645
|
+
"tags": [],
|
|
646
|
+
"docs": "",
|
|
647
|
+
"complexTypes": [],
|
|
648
|
+
"type": "() => Promise<void>"
|
|
649
|
+
}
|
|
650
|
+
]
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
"name": "MdnsServiceEvent",
|
|
654
|
+
"slug": "mdnsserviceevent",
|
|
655
|
+
"docs": "Both found and lost events contain a complete service snapshot, including `hosts`.",
|
|
656
|
+
"tags": [],
|
|
657
|
+
"methods": [],
|
|
658
|
+
"properties": [
|
|
659
|
+
{
|
|
660
|
+
"name": "service",
|
|
661
|
+
"tags": [],
|
|
662
|
+
"docs": "",
|
|
663
|
+
"complexTypes": [
|
|
664
|
+
"MdnsService"
|
|
665
|
+
],
|
|
666
|
+
"type": "MdnsService"
|
|
667
|
+
}
|
|
668
|
+
]
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
"name": "MdnsWatchErrorEvent",
|
|
672
|
+
"slug": "mdnswatcherrorevent",
|
|
673
|
+
"docs": "Browser failures stop the watch; exhausted service resolution retries leave it running.",
|
|
674
|
+
"tags": [],
|
|
675
|
+
"methods": [],
|
|
676
|
+
"properties": [
|
|
677
|
+
{
|
|
678
|
+
"name": "type",
|
|
679
|
+
"tags": [],
|
|
680
|
+
"docs": "",
|
|
681
|
+
"complexTypes": [],
|
|
682
|
+
"type": "string"
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
"name": "errorMessage",
|
|
686
|
+
"tags": [],
|
|
687
|
+
"docs": "",
|
|
688
|
+
"complexTypes": [],
|
|
689
|
+
"type": "string"
|
|
690
|
+
},
|
|
691
|
+
{
|
|
692
|
+
"name": "watching",
|
|
693
|
+
"tags": [],
|
|
694
|
+
"docs": "",
|
|
695
|
+
"complexTypes": [],
|
|
696
|
+
"type": "boolean"
|
|
697
|
+
}
|
|
698
|
+
]
|
|
424
699
|
}
|
|
425
700
|
],
|
|
426
701
|
"enums": [],
|
|
427
702
|
"typeAliases": [
|
|
703
|
+
{
|
|
704
|
+
"name": "MdnsPluginPlatform",
|
|
705
|
+
"slug": "mdnspluginplatform",
|
|
706
|
+
"docs": "Runtime implementation that handled a plugin call.",
|
|
707
|
+
"types": [
|
|
708
|
+
{
|
|
709
|
+
"text": "'ios'",
|
|
710
|
+
"complexTypes": []
|
|
711
|
+
},
|
|
712
|
+
{
|
|
713
|
+
"text": "'android'",
|
|
714
|
+
"complexTypes": []
|
|
715
|
+
},
|
|
716
|
+
{
|
|
717
|
+
"text": "'electron'",
|
|
718
|
+
"complexTypes": []
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
"text": "'web'",
|
|
722
|
+
"complexTypes": []
|
|
723
|
+
}
|
|
724
|
+
]
|
|
725
|
+
},
|
|
428
726
|
{
|
|
429
727
|
"name": "MdnsTxt",
|
|
430
728
|
"slug": "mdnstxt",
|