@matter/general 0.16.1 → 0.16.2-alpha.0-20260114-b38c6b796
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/dist/cjs/net/Network.d.ts +2 -0
- package/dist/cjs/net/Network.d.ts.map +1 -1
- package/dist/cjs/net/Network.js +3 -0
- package/dist/cjs/net/Network.js.map +1 -1
- package/dist/cjs/net/RetrySchedule.d.ts +1 -1
- package/dist/cjs/net/ServerAddress.d.ts +52 -14
- package/dist/cjs/net/ServerAddress.d.ts.map +1 -1
- package/dist/cjs/net/ServerAddress.js +41 -6
- package/dist/cjs/net/ServerAddress.js.map +2 -2
- package/dist/cjs/net/ServerAddressSet.d.ts +65 -0
- package/dist/cjs/net/ServerAddressSet.d.ts.map +1 -0
- package/dist/cjs/net/ServerAddressSet.js +144 -0
- package/dist/cjs/net/ServerAddressSet.js.map +6 -0
- package/dist/cjs/net/dns-sd/MdnsSocket.d.ts +40 -0
- package/dist/cjs/net/dns-sd/MdnsSocket.d.ts.map +1 -0
- package/dist/cjs/net/dns-sd/MdnsSocket.js +164 -0
- package/dist/cjs/net/dns-sd/MdnsSocket.js.map +6 -0
- package/dist/cjs/net/dns-sd/index.d.ts +7 -0
- package/dist/cjs/net/dns-sd/index.d.ts.map +1 -0
- package/dist/cjs/net/dns-sd/index.js +24 -0
- package/dist/cjs/net/dns-sd/index.js.map +6 -0
- package/dist/cjs/net/index.d.ts +2 -0
- package/dist/cjs/net/index.d.ts.map +1 -1
- package/dist/cjs/net/index.js +2 -0
- package/dist/cjs/net/index.js.map +1 -1
- package/dist/cjs/time/TimeUnit.d.ts +4 -0
- package/dist/cjs/time/TimeUnit.d.ts.map +1 -1
- package/dist/cjs/time/TimeUnit.js +2 -0
- package/dist/cjs/time/TimeUnit.js.map +1 -1
- package/dist/cjs/time/Timestamp.d.ts +1 -1
- package/dist/cjs/time/Timestamp.d.ts.map +1 -1
- package/dist/cjs/time/Timestamp.js +1 -1
- package/dist/cjs/time/Timestamp.js.map +1 -1
- package/dist/cjs/util/Abort.d.ts +9 -0
- package/dist/cjs/util/Abort.d.ts.map +1 -1
- package/dist/cjs/util/Abort.js +20 -0
- package/dist/cjs/util/Abort.js.map +1 -1
- package/dist/cjs/util/Heap.d.ts +84 -0
- package/dist/cjs/util/Heap.d.ts.map +1 -0
- package/dist/cjs/util/Heap.js +286 -0
- package/dist/cjs/util/Heap.js.map +6 -0
- package/dist/cjs/util/Observable.d.ts +29 -6
- package/dist/cjs/util/Observable.d.ts.map +1 -1
- package/dist/cjs/util/Observable.js +40 -6
- package/dist/cjs/util/Observable.js.map +1 -1
- package/dist/cjs/util/Promises.d.ts +3 -0
- package/dist/cjs/util/Promises.d.ts.map +1 -1
- package/dist/cjs/util/Promises.js +33 -3
- package/dist/cjs/util/Promises.js.map +2 -2
- package/dist/cjs/util/Scheduler.d.ts +68 -0
- package/dist/cjs/util/Scheduler.d.ts.map +1 -0
- package/dist/cjs/util/Scheduler.js +207 -0
- package/dist/cjs/util/Scheduler.js.map +6 -0
- package/dist/cjs/util/Semaphore.d.ts +0 -4
- package/dist/cjs/util/Semaphore.d.ts.map +1 -1
- package/dist/cjs/util/Semaphore.js.map +1 -1
- package/dist/cjs/util/Set.d.ts.map +1 -1
- package/dist/cjs/util/Set.js +14 -8
- package/dist/cjs/util/Set.js.map +1 -1
- package/dist/cjs/util/index.d.ts +2 -0
- package/dist/cjs/util/index.d.ts.map +1 -1
- package/dist/cjs/util/index.js +2 -0
- package/dist/cjs/util/index.js.map +1 -1
- package/dist/esm/net/Network.d.ts +2 -0
- package/dist/esm/net/Network.d.ts.map +1 -1
- package/dist/esm/net/Network.js +3 -0
- package/dist/esm/net/Network.js.map +1 -1
- package/dist/esm/net/RetrySchedule.d.ts +1 -1
- package/dist/esm/net/ServerAddress.d.ts +52 -14
- package/dist/esm/net/ServerAddress.d.ts.map +1 -1
- package/dist/esm/net/ServerAddress.js +41 -6
- package/dist/esm/net/ServerAddress.js.map +2 -2
- package/dist/esm/net/ServerAddressSet.d.ts +65 -0
- package/dist/esm/net/ServerAddressSet.d.ts.map +1 -0
- package/dist/esm/net/ServerAddressSet.js +124 -0
- package/dist/esm/net/ServerAddressSet.js.map +6 -0
- package/dist/esm/net/dns-sd/MdnsSocket.d.ts +40 -0
- package/dist/esm/net/dns-sd/MdnsSocket.d.ts.map +1 -0
- package/dist/esm/net/dns-sd/MdnsSocket.js +149 -0
- package/dist/esm/net/dns-sd/MdnsSocket.js.map +6 -0
- package/dist/esm/net/dns-sd/index.d.ts +7 -0
- package/dist/esm/net/dns-sd/index.d.ts.map +1 -0
- package/dist/esm/net/dns-sd/index.js +7 -0
- package/dist/esm/net/dns-sd/index.js.map +6 -0
- package/dist/esm/net/index.d.ts +2 -0
- package/dist/esm/net/index.d.ts.map +1 -1
- package/dist/esm/net/index.js +2 -0
- package/dist/esm/net/index.js.map +1 -1
- package/dist/esm/time/TimeUnit.d.ts +4 -0
- package/dist/esm/time/TimeUnit.d.ts.map +1 -1
- package/dist/esm/time/TimeUnit.js +2 -0
- package/dist/esm/time/TimeUnit.js.map +1 -1
- package/dist/esm/time/Timestamp.d.ts +1 -1
- package/dist/esm/time/Timestamp.d.ts.map +1 -1
- package/dist/esm/time/Timestamp.js +1 -1
- package/dist/esm/time/Timestamp.js.map +1 -1
- package/dist/esm/util/Abort.d.ts +9 -0
- package/dist/esm/util/Abort.d.ts.map +1 -1
- package/dist/esm/util/Abort.js +20 -0
- package/dist/esm/util/Abort.js.map +1 -1
- package/dist/esm/util/Heap.d.ts +84 -0
- package/dist/esm/util/Heap.d.ts.map +1 -0
- package/dist/esm/util/Heap.js +266 -0
- package/dist/esm/util/Heap.js.map +6 -0
- package/dist/esm/util/Observable.d.ts +29 -6
- package/dist/esm/util/Observable.d.ts.map +1 -1
- package/dist/esm/util/Observable.js +40 -6
- package/dist/esm/util/Observable.js.map +1 -1
- package/dist/esm/util/Promises.d.ts +3 -0
- package/dist/esm/util/Promises.d.ts.map +1 -1
- package/dist/esm/util/Promises.js +33 -3
- package/dist/esm/util/Promises.js.map +2 -2
- package/dist/esm/util/Scheduler.d.ts +68 -0
- package/dist/esm/util/Scheduler.d.ts.map +1 -0
- package/dist/esm/util/Scheduler.js +187 -0
- package/dist/esm/util/Scheduler.js.map +6 -0
- package/dist/esm/util/Semaphore.d.ts +0 -4
- package/dist/esm/util/Semaphore.d.ts.map +1 -1
- package/dist/esm/util/Semaphore.js.map +1 -1
- package/dist/esm/util/Set.d.ts.map +1 -1
- package/dist/esm/util/Set.js +14 -8
- package/dist/esm/util/Set.js.map +1 -1
- package/dist/esm/util/index.d.ts +2 -0
- package/dist/esm/util/index.d.ts.map +1 -1
- package/dist/esm/util/index.js +2 -0
- package/dist/esm/util/index.js.map +1 -1
- package/package.json +2 -2
- package/src/net/Network.ts +2 -0
- package/src/net/RetrySchedule.ts +1 -1
- package/src/net/ServerAddress.ts +93 -19
- package/src/net/ServerAddressSet.ts +225 -0
- package/src/net/dns-sd/MdnsSocket.ts +203 -0
- package/src/net/dns-sd/index.ts +7 -0
- package/src/net/index.ts +2 -0
- package/src/time/TimeUnit.ts +5 -0
- package/src/time/Timestamp.ts +1 -1
- package/src/util/Abort.ts +25 -0
- package/src/util/Heap.ts +332 -0
- package/src/util/Observable.ts +74 -10
- package/src/util/Promises.ts +61 -4
- package/src/util/Scheduler.ts +185 -0
- package/src/util/Semaphore.ts +0 -5
- package/src/util/Set.ts +15 -8
- package/src/util/index.ts +2 -0
|
@@ -14,6 +14,8 @@ export declare class BindError extends NetworkError {
|
|
|
14
14
|
}
|
|
15
15
|
export declare class AddressInUseError extends BindError {
|
|
16
16
|
}
|
|
17
|
+
export declare class AddressUnreachableError extends NetworkError {
|
|
18
|
+
}
|
|
17
19
|
export declare const STANDARD_MATTER_PORT = 5540;
|
|
18
20
|
/**
|
|
19
21
|
* @see {@link MatterSpecification.v11.Core} § 11.11.4.4
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Network.d.ts","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C,YAAY,EAAE,MAAM,GAAG,YAAY,CAAC,uBAAuB,GAAG,SAAS,CAAC;IAC1F,QAAQ,CAAC,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC;IAEpE,KAAK;CAGd"}
|
package/dist/cjs/net/Network.js
CHANGED
|
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var Network_exports = {};
|
|
20
20
|
__export(Network_exports, {
|
|
21
21
|
AddressInUseError: () => AddressInUseError,
|
|
22
|
+
AddressUnreachableError: () => AddressUnreachableError,
|
|
22
23
|
BindError: () => BindError,
|
|
23
24
|
InterfaceType: () => InterfaceType,
|
|
24
25
|
Network: () => Network,
|
|
@@ -41,6 +42,8 @@ class BindError extends NetworkError {
|
|
|
41
42
|
}
|
|
42
43
|
class AddressInUseError extends BindError {
|
|
43
44
|
}
|
|
45
|
+
class AddressUnreachableError extends NetworkError {
|
|
46
|
+
}
|
|
44
47
|
const STANDARD_MATTER_PORT = 5540;
|
|
45
48
|
var InterfaceType = /* @__PURE__ */ ((InterfaceType2) => {
|
|
46
49
|
InterfaceType2[InterfaceType2["Unspecified"] = 0] = "Unspecified";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/net/Network.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,yBAA4B;AAN5B;AAAA;AAAA;AAAA;AAAA;AAUO,MAAM,qBAAqB,+BAAY;AAAC;AAExC,MAAM,gCAAgC,aAAa;AAAC;AAEpD,MAAM,kBAAkB,aAAa;AAAC;AAEtC,MAAM,0BAA0B,UAAU;AAAC;AAE3C,MAAM,uBAAuB;AAM7B,IAAK,gBAAL,kBAAKA,mBAAL;AAIH,EAAAA,8BAAA,iBAAc,KAAd;AAKA,EAAAA,8BAAA,UAAO,KAAP;AAKA,EAAAA,8BAAA,cAAW,KAAX;AAKA,EAAAA,8BAAA,cAAW,KAAX;AAKA,EAAAA,8BAAA,YAAS,KAAT;AAxBQ,SAAAA;AAAA,GAAA;AAuCL,MAAe,QAAQ;AAAA,EAK1B,MAAM,QAAQ;AAAA,EAEd;AACJ;",
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,yBAA4B;AAN5B;AAAA;AAAA;AAAA;AAAA;AAUO,MAAM,qBAAqB,+BAAY;AAAC;AAExC,MAAM,gCAAgC,aAAa;AAAC;AAEpD,MAAM,kBAAkB,aAAa;AAAC;AAEtC,MAAM,0BAA0B,UAAU;AAAC;AAE3C,MAAM,gCAAgC,aAAa;AAAC;AAEpD,MAAM,uBAAuB;AAM7B,IAAK,gBAAL,kBAAKA,mBAAL;AAIH,EAAAA,8BAAA,iBAAc,KAAd;AAKA,EAAAA,8BAAA,UAAO,KAAP;AAKA,EAAAA,8BAAA,cAAW,KAAX;AAKA,EAAAA,8BAAA,cAAW,KAAX;AAKA,EAAAA,8BAAA,YAAS,KAAT;AAxBQ,SAAAA;AAAA,GAAA;AAuCL,MAAe,QAAQ;AAAA,EAK1B,MAAM,QAAQ;AAAA,EAEd;AACJ;",
|
|
5
5
|
"names": ["InterfaceType"]
|
|
6
6
|
}
|
|
@@ -6,35 +6,73 @@
|
|
|
6
6
|
import { Diagnostic } from "#log/Diagnostic.js";
|
|
7
7
|
import { Duration } from "#time/Duration.js";
|
|
8
8
|
import { Timestamp } from "#time/Timestamp.js";
|
|
9
|
+
export interface AddressLifespan {
|
|
10
|
+
/**
|
|
11
|
+
* Beginning of lifespan
|
|
12
|
+
*/
|
|
13
|
+
discoveredAt: Timestamp;
|
|
14
|
+
/**
|
|
15
|
+
* Length of lifespan, if known
|
|
16
|
+
*/
|
|
17
|
+
ttl: Duration;
|
|
18
|
+
}
|
|
19
|
+
export interface AddressStatus extends Partial<AddressLifespan> {
|
|
20
|
+
/**
|
|
21
|
+
* Time of last successful access.
|
|
22
|
+
*/
|
|
23
|
+
healthyAt?: Timestamp;
|
|
24
|
+
/**
|
|
25
|
+
* Time of last unsuccessful access.
|
|
26
|
+
*/
|
|
27
|
+
unhealthyAt?: Timestamp;
|
|
28
|
+
/**
|
|
29
|
+
* DNS priority.
|
|
30
|
+
*/
|
|
31
|
+
priority?: number;
|
|
32
|
+
/**
|
|
33
|
+
* DNS weight.
|
|
34
|
+
*/
|
|
35
|
+
weight?: number;
|
|
36
|
+
}
|
|
9
37
|
export type ServerAddressUdp = {
|
|
10
38
|
type: "udp";
|
|
11
39
|
ip: string;
|
|
12
40
|
port: number;
|
|
13
|
-
};
|
|
41
|
+
} & AddressStatus;
|
|
14
42
|
export type ServerAddressTcp = {
|
|
15
43
|
type: "tcp";
|
|
16
44
|
ip: string;
|
|
17
45
|
port: number;
|
|
18
|
-
};
|
|
46
|
+
} & AddressStatus;
|
|
19
47
|
export type ServerAddressBle = {
|
|
20
48
|
type: "ble";
|
|
21
49
|
peripheralAddress: string;
|
|
22
|
-
};
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
discoveredAt: Timestamp;
|
|
26
|
-
/** Length of lifespan, if known (seconds) */
|
|
27
|
-
ttl: Duration;
|
|
28
|
-
}
|
|
29
|
-
export type ServerAddress = (ServerAddressUdp | ServerAddressTcp | ServerAddressBle) & Partial<Lifespan>;
|
|
30
|
-
export declare function ServerAddress(definition: ServerAddress.Definition): ServerAddress;
|
|
50
|
+
} & AddressStatus;
|
|
51
|
+
export type ServerAddress = ServerAddressUdp | ServerAddressTcp | ServerAddressBle;
|
|
52
|
+
export declare function ServerAddress(definition: ServerAddress): ServerAddress;
|
|
31
53
|
export declare namespace ServerAddress {
|
|
32
54
|
function urlFor(address: ServerAddress): string;
|
|
33
55
|
function diagnosticFor(address: ServerAddress): Diagnostic;
|
|
34
56
|
function isEqual(a: ServerAddress, b: ServerAddress): boolean;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Compute logical health of an address.
|
|
59
|
+
*
|
|
60
|
+
* This returns heathyAt/unhealthyAt values with unhealthyAt set to undefined if the address was more recently
|
|
61
|
+
* healthy.
|
|
62
|
+
*/
|
|
63
|
+
function healthOf(health: AddressStatus): AddressStatus;
|
|
64
|
+
/**
|
|
65
|
+
* Network address desirability from a Matter communication perspective.
|
|
66
|
+
*
|
|
67
|
+
* Lower values indicate higher preference. This is not a standard "happy eyeballs" ranking but works similarly.
|
|
68
|
+
*/
|
|
69
|
+
enum SelectionPreference {
|
|
70
|
+
IPV6_ULA = 0,
|
|
71
|
+
IPV6_LINK_LOCAL = 1,
|
|
72
|
+
IPV6 = 2,
|
|
73
|
+
IPV4 = 3,
|
|
74
|
+
NOT_IP = 3
|
|
38
75
|
}
|
|
76
|
+
function selectionPreferenceOf(address: ServerAddress): SelectionPreference;
|
|
39
77
|
}
|
|
40
78
|
//# sourceMappingURL=ServerAddress.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServerAddress.d.ts","sourceRoot":"","sources":["../../../src/net/ServerAddress.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"ServerAddress.d.ts","sourceRoot":"","sources":["../../../src/net/ServerAddress.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,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AAa,CAY7D;IAED;;;;OAIG;IACH,KAAY,mBAAmB;QAC3B,QAAQ,IAAA;QACR,eAAe,IAAA;QACf,IAAI,IAAA;QACJ,IAAI,IAAA;QACJ,MAAM,IAAI;KACb;IAED,SAAgB,qBAAqB,CAAC,OAAO,EAAE,aAAa,uBAkB3D;CACJ"}
|
|
@@ -23,7 +23,6 @@ __export(ServerAddress_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(ServerAddress_exports);
|
|
24
24
|
var import_Diagnostic = require("#log/Diagnostic.js");
|
|
25
25
|
var import_Duration = require("#time/Duration.js");
|
|
26
|
-
var import_TimeUnit = require("#time/TimeUnit.js");
|
|
27
26
|
/**
|
|
28
27
|
* @license
|
|
29
28
|
* Copyright 2022-2026 Matter.js Authors
|
|
@@ -31,9 +30,13 @@ var import_TimeUnit = require("#time/TimeUnit.js");
|
|
|
31
30
|
*/
|
|
32
31
|
function ServerAddress(definition) {
|
|
33
32
|
return {
|
|
33
|
+
ttl: void 0,
|
|
34
34
|
discoveredAt: void 0,
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
healthyAt: void 0,
|
|
36
|
+
unhealthyAt: void 0,
|
|
37
|
+
priority: void 0,
|
|
38
|
+
weight: void 0,
|
|
39
|
+
...definition
|
|
37
40
|
};
|
|
38
41
|
}
|
|
39
42
|
((ServerAddress2) => {
|
|
@@ -82,9 +85,41 @@ function ServerAddress(definition) {
|
|
|
82
85
|
return false;
|
|
83
86
|
}
|
|
84
87
|
ServerAddress2.isEqual = isEqual;
|
|
85
|
-
function
|
|
86
|
-
|
|
88
|
+
function healthOf(health) {
|
|
89
|
+
if (health.unhealthyAt === void 0) {
|
|
90
|
+
return health;
|
|
91
|
+
}
|
|
92
|
+
if (health.healthyAt !== void 0 && health.healthyAt > health.unhealthyAt) {
|
|
93
|
+
return {
|
|
94
|
+
healthyAt: health.healthyAt
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return health;
|
|
98
|
+
}
|
|
99
|
+
ServerAddress2.healthOf = healthOf;
|
|
100
|
+
let SelectionPreference;
|
|
101
|
+
((SelectionPreference2) => {
|
|
102
|
+
SelectionPreference2[SelectionPreference2["IPV6_ULA"] = 0] = "IPV6_ULA";
|
|
103
|
+
SelectionPreference2[SelectionPreference2["IPV6_LINK_LOCAL"] = 1] = "IPV6_LINK_LOCAL";
|
|
104
|
+
SelectionPreference2[SelectionPreference2["IPV6"] = 2] = "IPV6";
|
|
105
|
+
SelectionPreference2[SelectionPreference2["IPV4"] = 3] = "IPV4";
|
|
106
|
+
SelectionPreference2[SelectionPreference2["NOT_IP"] = 3] = "NOT_IP";
|
|
107
|
+
})(SelectionPreference = ServerAddress2.SelectionPreference || (ServerAddress2.SelectionPreference = {}));
|
|
108
|
+
function selectionPreferenceOf(address) {
|
|
109
|
+
if (!("ip" in address)) {
|
|
110
|
+
return 3 /* NOT_IP */;
|
|
111
|
+
}
|
|
112
|
+
if (address.ip.startsWith("fd")) {
|
|
113
|
+
return 0 /* IPV6_ULA */;
|
|
114
|
+
}
|
|
115
|
+
if (address.ip.startsWith("fe00")) {
|
|
116
|
+
return 1 /* IPV6_LINK_LOCAL */;
|
|
117
|
+
}
|
|
118
|
+
if (address.ip.includes(":")) {
|
|
119
|
+
return 2 /* IPV6 */;
|
|
120
|
+
}
|
|
121
|
+
return 3 /* IPV4 */;
|
|
87
122
|
}
|
|
88
|
-
ServerAddress2.
|
|
123
|
+
ServerAddress2.selectionPreferenceOf = selectionPreferenceOf;
|
|
89
124
|
})(ServerAddress || (ServerAddress = {}));
|
|
90
125
|
//# sourceMappingURL=ServerAddress.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/net/ServerAddress.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,wBAA2B;AAC3B,sBAAyB;
|
|
5
|
-
"names": ["ServerAddress"]
|
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-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { AddressStatus, ServerAddress } from "./ServerAddress.js";
|
|
7
|
+
/**
|
|
8
|
+
* A set of server addresses ordered by a comparator.
|
|
9
|
+
*/
|
|
10
|
+
export interface ServerAddressSet<T extends ServerAddress> {
|
|
11
|
+
/**
|
|
12
|
+
* Add an address.
|
|
13
|
+
*
|
|
14
|
+
* If the address alreay exists, returns the existing address to facilitate comparison by value. If not, returns
|
|
15
|
+
* the input address.
|
|
16
|
+
*/
|
|
17
|
+
add(address: T): T;
|
|
18
|
+
/**
|
|
19
|
+
* Delete an address.
|
|
20
|
+
*/
|
|
21
|
+
delete(address: T): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Replace the stored addresses.
|
|
24
|
+
*/
|
|
25
|
+
replace(newAddresses: Iterable<T>): void;
|
|
26
|
+
/**
|
|
27
|
+
* Test for existence of address.
|
|
28
|
+
*/
|
|
29
|
+
has(address: T): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The number of addresses.
|
|
32
|
+
*/
|
|
33
|
+
size: number;
|
|
34
|
+
/**
|
|
35
|
+
* Iterate.
|
|
36
|
+
*
|
|
37
|
+
* If you replace addresses during iteration only addresses not already produced will be covered by remaining
|
|
38
|
+
* iterations.
|
|
39
|
+
*/
|
|
40
|
+
[Symbol.iterator](): Iterator<T>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Create a new {@link ServerAddressSet}.
|
|
44
|
+
*/
|
|
45
|
+
export declare function ServerAddressSet<T extends ServerAddress>(initial?: Iterable<T>, comparator?: typeof ServerAddressSet.compareDesirability): ServerAddressSet<T>;
|
|
46
|
+
export declare namespace ServerAddressSet {
|
|
47
|
+
interface Comparator<T extends ServerAddress = ServerAddress> {
|
|
48
|
+
(addr1: T, addr2: T): number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Update a list of addresses with health information from another list.
|
|
52
|
+
*/
|
|
53
|
+
function copyHealth<T extends ServerAddress>(targetAddresses: Iterable<T>, sourceAddresses: Iterable<T>): T[];
|
|
54
|
+
/**
|
|
55
|
+
* Compare the "desirability" of two addresses for communication.
|
|
56
|
+
*/
|
|
57
|
+
function compareDesirability(a: ServerAddress, b: ServerAddress): number;
|
|
58
|
+
/**
|
|
59
|
+
* Compare the health of two addresses.
|
|
60
|
+
*
|
|
61
|
+
* Returns a negative number if a is healthier, positive if b is healthier and 0 if assessment is neutral.
|
|
62
|
+
*/
|
|
63
|
+
function compareHealth(a: AddressStatus, b: AddressStatus): number;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=ServerAddressSet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ServerAddressSet.d.ts","sourceRoot":"","sources":["../../../src/net/ServerAddressSet.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,aAAa;IACrD;;;;;OAKG;IACH,GAAG,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC;IAEnB;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC;IAE5B;;OAEG;IACH,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAEzC;;OAEG;IACH,GAAG,CAAC,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC;IAEzB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;;OAKG;IACH,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,aAAa,EACpD,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EACrB,UAAU,8CAAuC,uBA+EpD;AAED,yBAAiB,gBAAgB,CAAC;IAC9B,UAAiB,UAAU,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa;QAC/D,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC;KAChC;IAED;;OAEG;IACH,SAAgB,UAAU,CAAC,CAAC,SAAS,aAAa,EAAE,eAAe,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,QAAQ,CAAC,CAAC,CAAC,OAgB7G;IAED;;OAEG;IACH,SAAgB,mBAAmB,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,UAmBrE;IAED;;;;OAIG;IACH,SAAgB,aAAa,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,UAiC/D;CACJ"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var ServerAddressSet_exports = {};
|
|
20
|
+
__export(ServerAddressSet_exports, {
|
|
21
|
+
ServerAddressSet: () => ServerAddressSet
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(ServerAddressSet_exports);
|
|
24
|
+
var import_ServerAddress = require("./ServerAddress.js");
|
|
25
|
+
/**
|
|
26
|
+
* @license
|
|
27
|
+
* Copyright 2022-2026 Matter.js Authors
|
|
28
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
29
|
+
*/
|
|
30
|
+
function ServerAddressSet(initial, comparator = ServerAddressSet.compareDesirability) {
|
|
31
|
+
let version = 0;
|
|
32
|
+
let addresses;
|
|
33
|
+
const set = {
|
|
34
|
+
add(address) {
|
|
35
|
+
version++;
|
|
36
|
+
const key = import_ServerAddress.ServerAddress.urlFor(address);
|
|
37
|
+
const existing = addresses?.get(key);
|
|
38
|
+
if (existing) {
|
|
39
|
+
return existing;
|
|
40
|
+
}
|
|
41
|
+
if (!addresses) {
|
|
42
|
+
addresses = /* @__PURE__ */ new Map();
|
|
43
|
+
}
|
|
44
|
+
addresses.set(key, address);
|
|
45
|
+
return address;
|
|
46
|
+
},
|
|
47
|
+
delete(address) {
|
|
48
|
+
version++;
|
|
49
|
+
return addresses?.delete(import_ServerAddress.ServerAddress.urlFor(address)) ?? false;
|
|
50
|
+
},
|
|
51
|
+
has(address) {
|
|
52
|
+
return addresses?.has(import_ServerAddress.ServerAddress.urlFor(address)) ?? false;
|
|
53
|
+
},
|
|
54
|
+
replace(newAddresses) {
|
|
55
|
+
version++;
|
|
56
|
+
const oldAddresses = addresses;
|
|
57
|
+
addresses = /* @__PURE__ */ new Map();
|
|
58
|
+
for (const address of newAddresses) {
|
|
59
|
+
const key = import_ServerAddress.ServerAddress.urlFor(address);
|
|
60
|
+
addresses.set(key, oldAddresses?.get(key) ?? address);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
get size() {
|
|
64
|
+
return addresses?.size ?? 0;
|
|
65
|
+
},
|
|
66
|
+
*[Symbol.iterator]() {
|
|
67
|
+
const tried = /* @__PURE__ */ new Set();
|
|
68
|
+
all: while (true) {
|
|
69
|
+
const currentVersion = version;
|
|
70
|
+
const ordered = addresses ? [...addresses.entries()].map(([, address]) => address).sort(comparator) : [];
|
|
71
|
+
for (const address of ordered) {
|
|
72
|
+
const key = import_ServerAddress.ServerAddress.urlFor(address);
|
|
73
|
+
if (tried.has(key)) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
yield address;
|
|
77
|
+
if (currentVersion !== version) {
|
|
78
|
+
continue all;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
if (initial) {
|
|
86
|
+
set.replace(initial);
|
|
87
|
+
}
|
|
88
|
+
return set;
|
|
89
|
+
}
|
|
90
|
+
((ServerAddressSet2) => {
|
|
91
|
+
function copyHealth(targetAddresses, sourceAddresses) {
|
|
92
|
+
const output = [...targetAddresses];
|
|
93
|
+
nextTarget: for (let i = 0; i < output.length; i++) {
|
|
94
|
+
const target = output[i];
|
|
95
|
+
for (const source of sourceAddresses) {
|
|
96
|
+
if (import_ServerAddress.ServerAddress.isEqual(target, source)) {
|
|
97
|
+
if (source.healthyAt !== void 0 || source.unhealthyAt !== void 0) {
|
|
98
|
+
output[i] = { ...target, healthyAt: source.healthyAt, unhealthyAt: source.unhealthyAt };
|
|
99
|
+
}
|
|
100
|
+
continue nextTarget;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return output;
|
|
105
|
+
}
|
|
106
|
+
ServerAddressSet2.copyHealth = copyHealth;
|
|
107
|
+
function compareDesirability(a, b) {
|
|
108
|
+
const value = import_ServerAddress.ServerAddress.selectionPreferenceOf(a) - import_ServerAddress.ServerAddress.selectionPreferenceOf(b);
|
|
109
|
+
if (value) {
|
|
110
|
+
return value;
|
|
111
|
+
}
|
|
112
|
+
const relativeHealth = compareHealth(a, b);
|
|
113
|
+
if (relativeHealth) {
|
|
114
|
+
return relativeHealth;
|
|
115
|
+
}
|
|
116
|
+
if (a.priority !== void 0 && b.priority !== void 0) {
|
|
117
|
+
return b.priority - a.priority;
|
|
118
|
+
}
|
|
119
|
+
return 0;
|
|
120
|
+
}
|
|
121
|
+
ServerAddressSet2.compareDesirability = compareDesirability;
|
|
122
|
+
function compareHealth(a, b) {
|
|
123
|
+
const ha = import_ServerAddress.ServerAddress.healthOf(a);
|
|
124
|
+
const hb = import_ServerAddress.ServerAddress.healthOf(b);
|
|
125
|
+
if (ha.unhealthyAt) {
|
|
126
|
+
if (hb.unhealthyAt) {
|
|
127
|
+
return ha.unhealthyAt - hb.unhealthyAt;
|
|
128
|
+
}
|
|
129
|
+
return 1;
|
|
130
|
+
}
|
|
131
|
+
if (hb.unhealthyAt) {
|
|
132
|
+
return -1;
|
|
133
|
+
}
|
|
134
|
+
if (ha.healthyAt) {
|
|
135
|
+
if (hb.healthyAt) {
|
|
136
|
+
return hb.healthyAt - ha.healthyAt;
|
|
137
|
+
}
|
|
138
|
+
return -1;
|
|
139
|
+
}
|
|
140
|
+
return 0;
|
|
141
|
+
}
|
|
142
|
+
ServerAddressSet2.compareHealth = compareHealth;
|
|
143
|
+
})(ServerAddressSet || (ServerAddressSet = {}));
|
|
144
|
+
//# sourceMappingURL=ServerAddressSet.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/net/ServerAddressSet.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,2BAA6C;AAN7C;AAAA;AAAA;AAAA;AAAA;AAoDO,SAAS,iBACZ,SACA,aAAa,iBAAiB,qBAChC;AACE,MAAI,UAAU;AACd,MAAI;AAEJ,QAAM,MAA2B;AAAA,IAC7B,IAAI,SAAY;AACZ;AACA,YAAM,MAAM,mCAAc,OAAO,OAAO;AACxC,YAAM,WAAW,WAAW,IAAI,GAAG;AACnC,UAAI,UAAU;AACV,eAAO;AA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
"names": ["ServerAddressSet"]
|
|
6
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2026 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { DnsMessage, DnsMessageType } from "#codec/DnsCodec.js";
|
|
7
|
+
import { Network } from "#net/Network.js";
|
|
8
|
+
import { UdpMulticastServer } from "#net/udp/UdpMulticastServer.js";
|
|
9
|
+
import { Lifetime } from "#util/Lifetime.js";
|
|
10
|
+
import { AsyncObservable } from "#util/Observable.js";
|
|
11
|
+
/**
|
|
12
|
+
* Manages the UDP socket for other components that implement MDNS logic.
|
|
13
|
+
*/
|
|
14
|
+
export declare class MdnsSocket {
|
|
15
|
+
#private;
|
|
16
|
+
static create(network: Network, options?: {
|
|
17
|
+
enableIpv4?: boolean;
|
|
18
|
+
netInterface?: string;
|
|
19
|
+
lifetime?: Lifetime.Owner;
|
|
20
|
+
}): Promise<MdnsSocket>;
|
|
21
|
+
constructor(socket: UdpMulticastServer);
|
|
22
|
+
get network(): Network;
|
|
23
|
+
get supportsIpv4(): boolean;
|
|
24
|
+
get netInterface(): string | undefined;
|
|
25
|
+
get receipt(): AsyncObservable<[message: MdnsSocket.Message], void>;
|
|
26
|
+
send(message: Partial<DnsMessage> & {
|
|
27
|
+
messageType: DnsMessageType;
|
|
28
|
+
}, intf?: string, unicastDest?: string): Promise<void>;
|
|
29
|
+
close(): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
export declare namespace MdnsSocket {
|
|
32
|
+
interface Message extends DnsMessage {
|
|
33
|
+
sourceIp: string;
|
|
34
|
+
sourceIntf: string;
|
|
35
|
+
}
|
|
36
|
+
const BROADCAST_IPV4 = "224.0.0.251";
|
|
37
|
+
const BROADCAST_IPV6 = "ff02::fb";
|
|
38
|
+
const BROADCAST_PORT = 5353;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMapping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