@matter/general 0.16.0-alpha.0-20251006-3fe1e7c57 → 0.16.0-alpha.0-20251011-d8942d7d5
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/codec/Base64Codec.js +2 -2
- package/dist/cjs/codec/Base64Codec.js.map +1 -1
- package/dist/cjs/environment/Environment.d.ts +12 -12
- package/dist/cjs/environment/Environment.d.ts.map +1 -1
- package/dist/cjs/environment/Environment.js.map +1 -1
- package/dist/cjs/environment/Environmental.d.ts +16 -2
- package/dist/cjs/environment/Environmental.d.ts.map +1 -1
- package/dist/cjs/log/Logger.js +1 -1
- package/dist/cjs/net/Network.d.ts +4 -0
- package/dist/cjs/net/Network.d.ts.map +1 -1
- package/dist/cjs/net/Network.js +6 -0
- package/dist/cjs/net/Network.js.map +1 -1
- package/dist/cjs/net/ServerAddress.d.ts +1 -0
- package/dist/cjs/net/ServerAddress.d.ts.map +1 -1
- package/dist/cjs/net/ServerAddress.js +13 -0
- package/dist/cjs/net/ServerAddress.js.map +1 -1
- package/dist/cjs/net/http/HttpEndpoint.d.ts +53 -0
- package/dist/cjs/net/http/HttpEndpoint.d.ts.map +1 -0
- package/dist/cjs/net/http/HttpEndpoint.js +22 -0
- package/dist/cjs/net/http/HttpEndpoint.js.map +6 -0
- package/dist/cjs/net/http/HttpEndpointFactory.d.ts +23 -0
- package/dist/cjs/net/http/HttpEndpointFactory.d.ts.map +1 -0
- package/dist/cjs/net/http/HttpEndpointFactory.js +39 -0
- package/dist/cjs/net/http/HttpEndpointFactory.js.map +6 -0
- package/dist/cjs/net/http/HttpEndpointGroup.d.ts +17 -0
- package/dist/cjs/net/http/HttpEndpointGroup.d.ts.map +1 -0
- package/dist/cjs/net/http/HttpEndpointGroup.js +56 -0
- package/dist/cjs/net/http/HttpEndpointGroup.js.map +6 -0
- package/dist/cjs/net/http/HttpService.d.ts +20 -0
- package/dist/cjs/net/http/HttpService.d.ts.map +1 -0
- package/dist/cjs/net/http/HttpService.js +83 -0
- package/dist/cjs/net/http/HttpService.js.map +6 -0
- package/dist/cjs/net/http/HttpSharedEndpoint.d.ts +16 -0
- package/dist/cjs/net/http/HttpSharedEndpoint.d.ts.map +1 -0
- package/dist/cjs/net/http/HttpSharedEndpoint.js +92 -0
- package/dist/cjs/net/http/HttpSharedEndpoint.js.map +6 -0
- package/dist/cjs/net/http/index.d.ts +11 -0
- package/dist/cjs/net/http/index.d.ts.map +1 -0
- package/dist/cjs/net/http/index.js +28 -0
- package/dist/cjs/net/http/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/net/mqtt/MqttEndpoint.d.ts +39 -0
- package/dist/cjs/net/mqtt/MqttEndpoint.d.ts.map +1 -0
- package/dist/cjs/net/mqtt/MqttEndpoint.js +36 -0
- package/dist/cjs/net/mqtt/MqttEndpoint.js.map +6 -0
- package/dist/cjs/net/mqtt/MqttEndpointFactory.d.ts +15 -0
- package/dist/cjs/net/mqtt/MqttEndpointFactory.d.ts.map +1 -0
- package/dist/cjs/net/mqtt/MqttEndpointFactory.js +31 -0
- package/dist/cjs/net/mqtt/MqttEndpointFactory.js.map +6 -0
- package/dist/cjs/net/mqtt/MqttService.d.ts +19 -0
- package/dist/cjs/net/mqtt/MqttService.d.ts.map +1 -0
- package/dist/cjs/net/mqtt/MqttService.js +52 -0
- package/dist/cjs/net/mqtt/MqttService.js.map +6 -0
- package/dist/cjs/net/mqtt/index.d.ts +9 -0
- package/dist/cjs/net/mqtt/index.d.ts.map +1 -0
- package/dist/cjs/net/mqtt/index.js +26 -0
- package/dist/cjs/net/mqtt/index.js.map +6 -0
- package/dist/cjs/net/udp/UdpChannel.d.ts +31 -2
- package/dist/cjs/net/udp/UdpChannel.d.ts.map +1 -1
- package/dist/cjs/net/udp/UdpMulticastServer.d.ts.map +1 -1
- package/dist/cjs/net/udp/UdpMulticastServer.js +6 -3
- package/dist/cjs/net/udp/UdpMulticastServer.js.map +1 -1
- package/dist/cjs/storage/StorageService.d.ts +5 -1
- package/dist/cjs/storage/StorageService.d.ts.map +1 -1
- package/dist/cjs/storage/StorageService.js +6 -1
- package/dist/cjs/storage/StorageService.js.map +1 -1
- package/dist/cjs/time/Duration.d.ts +1 -1
- package/dist/cjs/util/Abort.d.ts +4 -1
- package/dist/cjs/util/Abort.d.ts.map +1 -1
- package/dist/cjs/util/Abort.js +19 -3
- package/dist/cjs/util/Abort.js.map +1 -1
- package/dist/cjs/util/Construction.d.ts +1 -1
- package/dist/cjs/util/Multiplex.js +1 -1
- package/dist/cjs/util/Multiplex.js.map +1 -1
- package/dist/cjs/util/String.d.ts +5 -1
- package/dist/cjs/util/String.d.ts.map +1 -1
- package/dist/cjs/util/String.js +16 -0
- package/dist/cjs/util/String.js.map +1 -1
- package/dist/esm/codec/Base64Codec.js +2 -2
- package/dist/esm/codec/Base64Codec.js.map +1 -1
- package/dist/esm/environment/Environment.d.ts +12 -12
- package/dist/esm/environment/Environment.d.ts.map +1 -1
- package/dist/esm/environment/Environment.js.map +1 -1
- package/dist/esm/environment/Environmental.d.ts +16 -2
- package/dist/esm/environment/Environmental.d.ts.map +1 -1
- package/dist/esm/log/Logger.js +1 -1
- package/dist/esm/net/Network.d.ts +4 -0
- package/dist/esm/net/Network.d.ts.map +1 -1
- package/dist/esm/net/Network.js +6 -0
- package/dist/esm/net/Network.js.map +1 -1
- package/dist/esm/net/ServerAddress.d.ts +1 -0
- package/dist/esm/net/ServerAddress.d.ts.map +1 -1
- package/dist/esm/net/ServerAddress.js +13 -0
- package/dist/esm/net/ServerAddress.js.map +1 -1
- package/dist/esm/net/http/HttpEndpoint.d.ts +53 -0
- package/dist/esm/net/http/HttpEndpoint.d.ts.map +1 -0
- package/dist/esm/net/http/HttpEndpoint.js +6 -0
- package/dist/esm/net/http/HttpEndpoint.js.map +6 -0
- package/dist/esm/net/http/HttpEndpointFactory.d.ts +23 -0
- package/dist/esm/net/http/HttpEndpointFactory.d.ts.map +1 -0
- package/dist/esm/net/http/HttpEndpointFactory.js +19 -0
- package/dist/esm/net/http/HttpEndpointFactory.js.map +6 -0
- package/dist/esm/net/http/HttpEndpointGroup.d.ts +17 -0
- package/dist/esm/net/http/HttpEndpointGroup.d.ts.map +1 -0
- package/dist/esm/net/http/HttpEndpointGroup.js +36 -0
- package/dist/esm/net/http/HttpEndpointGroup.js.map +6 -0
- package/dist/esm/net/http/HttpService.d.ts +20 -0
- package/dist/esm/net/http/HttpService.d.ts.map +1 -0
- package/dist/esm/net/http/HttpService.js +63 -0
- package/dist/esm/net/http/HttpService.js.map +6 -0
- package/dist/esm/net/http/HttpSharedEndpoint.d.ts +16 -0
- package/dist/esm/net/http/HttpSharedEndpoint.d.ts.map +1 -0
- package/dist/esm/net/http/HttpSharedEndpoint.js +72 -0
- package/dist/esm/net/http/HttpSharedEndpoint.js.map +6 -0
- package/dist/esm/net/http/index.d.ts +11 -0
- package/dist/esm/net/http/index.d.ts.map +1 -0
- package/dist/esm/net/http/index.js +11 -0
- package/dist/esm/net/http/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/net/mqtt/MqttEndpoint.d.ts +39 -0
- package/dist/esm/net/mqtt/MqttEndpoint.d.ts.map +1 -0
- package/dist/esm/net/mqtt/MqttEndpoint.js +16 -0
- package/dist/esm/net/mqtt/MqttEndpoint.js.map +6 -0
- package/dist/esm/net/mqtt/MqttEndpointFactory.d.ts +15 -0
- package/dist/esm/net/mqtt/MqttEndpointFactory.d.ts.map +1 -0
- package/dist/esm/net/mqtt/MqttEndpointFactory.js +11 -0
- package/dist/esm/net/mqtt/MqttEndpointFactory.js.map +6 -0
- package/dist/esm/net/mqtt/MqttService.d.ts +19 -0
- package/dist/esm/net/mqtt/MqttService.d.ts.map +1 -0
- package/dist/esm/net/mqtt/MqttService.js +32 -0
- package/dist/esm/net/mqtt/MqttService.js.map +6 -0
- package/dist/esm/net/mqtt/index.d.ts +9 -0
- package/dist/esm/net/mqtt/index.d.ts.map +1 -0
- package/dist/esm/net/mqtt/index.js +9 -0
- package/dist/esm/net/mqtt/index.js.map +6 -0
- package/dist/esm/net/udp/UdpChannel.d.ts +31 -2
- package/dist/esm/net/udp/UdpChannel.d.ts.map +1 -1
- package/dist/esm/net/udp/UdpMulticastServer.d.ts.map +1 -1
- package/dist/esm/net/udp/UdpMulticastServer.js +6 -3
- package/dist/esm/net/udp/UdpMulticastServer.js.map +1 -1
- package/dist/esm/storage/StorageService.d.ts +5 -1
- package/dist/esm/storage/StorageService.d.ts.map +1 -1
- package/dist/esm/storage/StorageService.js +6 -1
- package/dist/esm/storage/StorageService.js.map +1 -1
- package/dist/esm/time/Duration.d.ts +1 -1
- package/dist/esm/util/Abort.d.ts +4 -1
- package/dist/esm/util/Abort.d.ts.map +1 -1
- package/dist/esm/util/Abort.js +19 -3
- package/dist/esm/util/Abort.js.map +1 -1
- package/dist/esm/util/Construction.d.ts +1 -1
- package/dist/esm/util/Multiplex.js +1 -1
- package/dist/esm/util/Multiplex.js.map +1 -1
- package/dist/esm/util/String.d.ts +5 -1
- package/dist/esm/util/String.d.ts.map +1 -1
- package/dist/esm/util/String.js +16 -0
- package/dist/esm/util/String.js.map +1 -1
- package/package.json +2 -2
- package/src/codec/Base64Codec.ts +2 -2
- package/src/environment/Environment.ts +15 -15
- package/src/environment/Environmental.ts +17 -2
- package/src/log/Logger.ts +1 -1
- package/src/net/Network.ts +4 -0
- package/src/net/ServerAddress.ts +16 -0
- package/src/net/http/HttpEndpoint.ts +60 -0
- package/src/net/http/HttpEndpointFactory.ts +27 -0
- package/src/net/http/HttpEndpointGroup.ts +43 -0
- package/src/net/http/HttpService.ts +75 -0
- package/src/net/http/HttpSharedEndpoint.ts +88 -0
- package/src/net/http/index.ts +11 -0
- package/src/net/index.ts +2 -0
- package/src/net/mqtt/MqttEndpoint.ts +50 -0
- package/src/net/mqtt/MqttEndpointFactory.ts +17 -0
- package/src/net/mqtt/MqttService.ts +40 -0
- package/src/net/mqtt/index.ts +9 -0
- package/src/net/udp/UdpChannel.ts +35 -2
- package/src/net/udp/UdpMulticastServer.ts +3 -0
- package/src/storage/StorageService.ts +14 -1
- package/src/time/Duration.ts +1 -1
- package/src/util/Abort.ts +28 -4
- package/src/util/Construction.ts +2 -2
- package/src/util/Multiplex.ts +1 -1
- package/src/util/String.ts +25 -6
|
@@ -0,0 +1,83 @@
|
|
|
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 HttpService_exports = {};
|
|
20
|
+
__export(HttpService_exports, {
|
|
21
|
+
HttpService: () => HttpService
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(HttpService_exports);
|
|
24
|
+
var import_Environmental = require("#environment/Environmental.js");
|
|
25
|
+
var import_MatterError = require("#MatterError.js");
|
|
26
|
+
var import_AppAddress = require("#net/AppAddress.js");
|
|
27
|
+
var import_HttpEndpointFactory = require("./HttpEndpointFactory.js");
|
|
28
|
+
var import_HttpEndpointGroup = require("./HttpEndpointGroup.js");
|
|
29
|
+
var import_HttpSharedEndpoint = require("./HttpSharedEndpoint.js");
|
|
30
|
+
/**
|
|
31
|
+
* @license
|
|
32
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
33
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
34
|
+
*/
|
|
35
|
+
class HttpService {
|
|
36
|
+
#factory;
|
|
37
|
+
#endpoints = {};
|
|
38
|
+
constructor(factory) {
|
|
39
|
+
this.#factory = factory;
|
|
40
|
+
}
|
|
41
|
+
async create(...addresses) {
|
|
42
|
+
if (addresses.length === 1) {
|
|
43
|
+
return this.#forAddress(addresses[0]);
|
|
44
|
+
}
|
|
45
|
+
const endpoints = Array();
|
|
46
|
+
try {
|
|
47
|
+
for (const address of addresses) {
|
|
48
|
+
endpoints.push(await this.#forAddress(address));
|
|
49
|
+
}
|
|
50
|
+
} catch (e) {
|
|
51
|
+
await Promise.allSettled(endpoints.map((endpoint) => endpoint.close()));
|
|
52
|
+
throw e;
|
|
53
|
+
}
|
|
54
|
+
return new import_HttpEndpointGroup.HttpEndpointGroup(endpoints);
|
|
55
|
+
}
|
|
56
|
+
async #forAddress(address) {
|
|
57
|
+
const addr = import_AppAddress.AppAddress.for(address);
|
|
58
|
+
if (addr.appProtocol !== "http" && addr.appProtocol !== "ws") {
|
|
59
|
+
throw new import_MatterError.ImplementationError(`Unsupported address ${addr} for HTTP endpoint`);
|
|
60
|
+
}
|
|
61
|
+
const key = JSON.stringify(addr.transport);
|
|
62
|
+
let endpoint = this.#endpoints[key];
|
|
63
|
+
if (endpoint) {
|
|
64
|
+
if (endpoint.isTls !== addr.isTls) {
|
|
65
|
+
const addrIs = addr.isTls ? "encrypted" : "unencrypted";
|
|
66
|
+
const endpointIs = endpoint.isTls ? "encrypted" : "unencrypted";
|
|
67
|
+
throw new import_MatterError.ImplementationError(
|
|
68
|
+
`Service address ${addr} is ${addrIs} but existing endpoint is ${endpointIs}`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
endpoint = new import_HttpSharedEndpoint.HttpSharedEndpoint(addr.isTls, () => this.#factory.create({ address }));
|
|
73
|
+
this.#endpoints[key] = endpoint;
|
|
74
|
+
}
|
|
75
|
+
return await endpoint.use();
|
|
76
|
+
}
|
|
77
|
+
static [import_Environmental.Environmental.create](env) {
|
|
78
|
+
const instance = new HttpService(env.get(import_HttpEndpointFactory.HttpEndpointFactory));
|
|
79
|
+
env.set(HttpService, instance);
|
|
80
|
+
return instance;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=HttpService.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/net/http/HttpService.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,2BAA8B;AAC9B,yBAAoC;AACpC,wBAA2B;AAE3B,iCAAoC;AACpC,+BAAkC;AAClC,gCAAmC;AAbnC;AAAA;AAAA;AAAA;AAAA;AAkBO,MAAM,YAAY;AAAA,EACrB;AAAA,EACA,aAAa,CAAC;AAAA,EAEd,YAAY,SAA8B;AACtC,SAAK,WAAW;AAAA,EACpB;AAAA,EAEA,MAAM,UAAU,WAAoC;AAChD,QAAI,UAAU,WAAW,GAAG;AACxB,aAAO,KAAK,YAAY,UAAU,CAAC,CAAC;AAAA,IACxC;AAEA,UAAM,YAAY,MAAoB;AAEtC,QAAI;AACA,iBAAW,WAAW,WAAW;AAC7B,kBAAU,KAAK,MAAM,KAAK,YAAY,OAAO,CAAC;AAAA,MAClD;AAAA,IACJ,SAAS,GAAG;AACR,YAAM,QAAQ,WAAW,UAAU,IAAI,cAAY,SAAS,MAAM,CAAC,CAAC;AACpE,YAAM;AAAA,IACV;AAEA,WAAO,IAAI,2CAAkB,SAAS;AAAA,EAC1C;AAAA,EAEA,MAAM,YAAY,SAAgC;AAC9C,UAAM,OAAO,6BAAW,IAAI,OAAO;AACnC,QAAI,KAAK,gBAAgB,UAAU,KAAK,gBAAgB,MAAM;AAC1D,YAAM,IAAI,uCAAoB,uBAAuB,IAAI,oBAAoB;AAAA,IACjF;AAEA,UAAM,MAAM,KAAK,UAAU,KAAK,SAAS;AACzC,QAAI,WAAW,KAAK,WAAW,GAAG;AAClC,QAAI,UAAU;AACV,UAAI,SAAS,UAAU,KAAK,OAAO;AAC/B,cAAM,SAAS,KAAK,QAAQ,cAAc;AAC1C,cAAM,aAAa,SAAS,QAAQ,cAAc;AAClD,cAAM,IAAI;AAAA,UACN,mBAAmB,IAAI,OAAO,MAAM,6BAA6B,UAAU;AAAA,QAC/E;AAAA,MACJ;AAAA,IACJ,OAAO;AACH,iBAAW,IAAI,6CAAmB,KAAK,OAAO,MAAM,KAAK,SAAS,OAAO,EAAE,QAAQ,CAAC,CAAC;AACrF,WAAK,WAAW,GAAG,IAAI;AAAA,IAC3B;AAEA,WAAO,MAAM,SAAS,IAAI;AAAA,EAC9B;AAAA,EAEA,QAAQ,mCAAc,MAAM,EAAE,KAAkB;AAC5C,UAAM,WAAW,IAAI,YAAY,IAAI,IAAI,8CAAmB,CAAC;AAC7D,QAAI,IAAI,aAAa,QAAQ;AAC7B,WAAO;AAAA,EACX;AACJ;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { HttpEndpoint } from "./HttpEndpoint.js";
|
|
7
|
+
/**
|
|
8
|
+
* Shared access to a single underlying HTTP endpoint.
|
|
9
|
+
*/
|
|
10
|
+
export declare class HttpSharedEndpoint {
|
|
11
|
+
#private;
|
|
12
|
+
constructor(isTls: boolean, create: () => Promise<HttpEndpoint>);
|
|
13
|
+
get isTls(): boolean;
|
|
14
|
+
use(): Promise<HttpEndpoint>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=HttpSharedEndpoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpSharedEndpoint.d.ts","sourceRoot":"","sources":["../../../../src/net/http/HttpSharedEndpoint.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjD;;GAEG;AACH,qBAAa,kBAAkB;;gBAMf,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC;IAK/D,IAAI,KAAK,YAER;IAEK,GAAG;CA0DZ"}
|
|
@@ -0,0 +1,92 @@
|
|
|
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 HttpSharedEndpoint_exports = {};
|
|
20
|
+
__export(HttpSharedEndpoint_exports, {
|
|
21
|
+
HttpSharedEndpoint: () => HttpSharedEndpoint
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(HttpSharedEndpoint_exports);
|
|
24
|
+
var import_Logger = require("#log/Logger.js");
|
|
25
|
+
/**
|
|
26
|
+
* @license
|
|
27
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
28
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
29
|
+
*/
|
|
30
|
+
const logger = import_Logger.Logger.get("HttpSharedEntpoint");
|
|
31
|
+
class HttpSharedEndpoint {
|
|
32
|
+
#create;
|
|
33
|
+
#target;
|
|
34
|
+
#instances = /* @__PURE__ */ new Set();
|
|
35
|
+
#isTls;
|
|
36
|
+
constructor(isTls, create) {
|
|
37
|
+
this.#isTls = isTls;
|
|
38
|
+
this.#create = create;
|
|
39
|
+
}
|
|
40
|
+
get isTls() {
|
|
41
|
+
return this.#isTls;
|
|
42
|
+
}
|
|
43
|
+
async use() {
|
|
44
|
+
if (this.#target === void 0) {
|
|
45
|
+
this.#target = this.#createTarget();
|
|
46
|
+
}
|
|
47
|
+
await this.#target;
|
|
48
|
+
const instance = {
|
|
49
|
+
http: void 0,
|
|
50
|
+
ws: void 0,
|
|
51
|
+
close: async () => {
|
|
52
|
+
this.#instances.delete(instance);
|
|
53
|
+
if (!this.#instances.size) {
|
|
54
|
+
try {
|
|
55
|
+
await (await this.#target)?.close();
|
|
56
|
+
} catch (e) {
|
|
57
|
+
logger.error("Error closing HTTP endpoint", e);
|
|
58
|
+
} finally {
|
|
59
|
+
this.#target = void 0;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
this.#instances.add(instance);
|
|
65
|
+
return instance;
|
|
66
|
+
}
|
|
67
|
+
async #createTarget() {
|
|
68
|
+
const target = await this.#create();
|
|
69
|
+
target.http = async (request) => {
|
|
70
|
+
for (const instance of this.#instances) {
|
|
71
|
+
const response = await instance.http?.(request);
|
|
72
|
+
if (response) {
|
|
73
|
+
return response;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
target.ws = async (request, connect) => {
|
|
78
|
+
let connected = false;
|
|
79
|
+
for (const instance of this.#instances) {
|
|
80
|
+
await instance.ws?.(request, async () => {
|
|
81
|
+
connected = true;
|
|
82
|
+
return connect();
|
|
83
|
+
});
|
|
84
|
+
if (connected) {
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
return target;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=HttpSharedEndpoint.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/net/http/HttpSharedEndpoint.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,oBAAuB;AANvB;AAAA;AAAA;AAAA;AAAA;AASA,MAAM,SAAS,qBAAO,IAAI,oBAAoB;AAKvC,MAAM,mBAAmB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA,aAAa,oBAAI,IAAkB;AAAA,EACnC;AAAA,EAEA,YAAY,OAAgB,QAAqC;AAC7D,SAAK,SAAS;AACd,SAAK,UAAU;AAAA,EACnB;AAAA,EAEA,IAAI,QAAQ;AACR,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,MAAM,MAAM;AACR,QAAI,KAAK,YAAY,QAAW;AAC5B,WAAK,UAAU,KAAK,cAAc;AAAA,IACtC;AAEA,UAAM,KAAK;AAEX,UAAM,WAAyB;AAAA,MAC3B,MAAM;AAAA,MACN,IAAI;AAAA,MAEJ,OAAO,YAAY;AACf,aAAK,WAAW,OAAO,QAAQ;AAC/B,YAAI,CAAC,KAAK,WAAW,MAAM;AACvB,cAAI;AACA,mBAAO,MAAM,KAAK,UAAU,MAAM;AAAA,UACtC,SAAS,GAAG;AACR,mBAAO,MAAM,+BAA+B,CAAC;AAAA,UACjD,UAAE;AACE,iBAAK,UAAU;AAAA,UACnB;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAEA,SAAK,WAAW,IAAI,QAAQ;AAE5B,WAAO;AAAA,EACX;AAAA,EAEA,MAAM,gBAAgB;AAClB,UAAM,SAAS,MAAM,KAAK,QAAQ;AAElC,WAAO,OAAO,OAAM,YAAW;AAC3B,iBAAW,YAAY,KAAK,YAAY;AACpC,cAAM,WAAW,MAAM,SAAS,OAAO,OAAO;AAC9C,YAAI,UAAU;AACV,iBAAO;AAAA,QACX;AAAA,MACJ;AAAA,IACJ;AAEA,WAAO,KAAK,OAAO,SAAS,YAAY;AACpC,UAAI,YAAY;AAChB,iBAAW,YAAY,KAAK,YAAY;AACpC,cAAM,SAAS,KAAK,SAAS,YAAY;AACrC,sBAAY;AACZ,iBAAO,QAAQ;AAAA,QACnB,CAAC;AAED,YAAI,WAAW;AACX;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAEA,WAAO;AAAA,EACX;AACJ;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export * from "./HttpEndpoint.js";
|
|
7
|
+
export * from "./HttpEndpointFactory.js";
|
|
8
|
+
export * from "./HttpEndpointGroup.js";
|
|
9
|
+
export * from "./HttpService.js";
|
|
10
|
+
export * from "./HttpSharedEndpoint.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/net/http/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var http_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(http_exports);
|
|
18
|
+
__reExport(http_exports, require("./HttpEndpoint.js"), module.exports);
|
|
19
|
+
__reExport(http_exports, require("./HttpEndpointFactory.js"), module.exports);
|
|
20
|
+
__reExport(http_exports, require("./HttpEndpointGroup.js"), module.exports);
|
|
21
|
+
__reExport(http_exports, require("./HttpService.js"), module.exports);
|
|
22
|
+
__reExport(http_exports, require("./HttpSharedEndpoint.js"), module.exports);
|
|
23
|
+
/**
|
|
24
|
+
* @license
|
|
25
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
26
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
27
|
+
*/
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
package/dist/cjs/net/index.d.ts
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
export * from "./AppAddress.js";
|
|
7
7
|
export * from "./Channel.js";
|
|
8
8
|
export * from "./ConnectionlessTransport.js";
|
|
9
|
+
export * from "./http/index.js";
|
|
9
10
|
export * from "./mock/index.js";
|
|
11
|
+
export * from "./mqtt/index.js";
|
|
10
12
|
export * from "./Network.js";
|
|
11
13
|
export * from "./RetrySchedule.js";
|
|
12
14
|
export * from "./ServerAddress.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/net/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/net/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC"}
|
package/dist/cjs/net/index.js
CHANGED
|
@@ -18,7 +18,9 @@ module.exports = __toCommonJS(net_exports);
|
|
|
18
18
|
__reExport(net_exports, require("./AppAddress.js"), module.exports);
|
|
19
19
|
__reExport(net_exports, require("./Channel.js"), module.exports);
|
|
20
20
|
__reExport(net_exports, require("./ConnectionlessTransport.js"), module.exports);
|
|
21
|
+
__reExport(net_exports, require("./http/index.js"), module.exports);
|
|
21
22
|
__reExport(net_exports, require("./mock/index.js"), module.exports);
|
|
23
|
+
__reExport(net_exports, require("./mqtt/index.js"), module.exports);
|
|
22
24
|
__reExport(net_exports, require("./Network.js"), module.exports);
|
|
23
25
|
__reExport(net_exports, require("./RetrySchedule.js"), module.exports);
|
|
24
26
|
__reExport(net_exports, require("./ServerAddress.js"), module.exports);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/net/index.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAMA,wBAAc,4BANd;AAOA,wBAAc,yBAPd;AAQA,wBAAc,yCARd;AASA,wBAAc,4BATd;AAUA,wBAAc,
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAMA,wBAAc,4BANd;AAOA,wBAAc,yBAPd;AAQA,wBAAc,yCARd;AASA,wBAAc,4BATd;AAUA,wBAAc,4BAVd;AAWA,wBAAc,4BAXd;AAYA,wBAAc,yBAZd;AAaA,wBAAc,+BAbd;AAcA,wBAAc,+BAdd;AAeA,wBAAc,2BAfd;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Environment } from "#environment/Environment.js";
|
|
7
|
+
import { AppAddress } from "#net/AppAddress.js";
|
|
8
|
+
import { Abort } from "#util/Abort.js";
|
|
9
|
+
import { Bytes } from "#util/Bytes.js";
|
|
10
|
+
import { MaybePromise } from "#util/Promises.js";
|
|
11
|
+
export interface MqttEndpoint {
|
|
12
|
+
subscribe(topic: string, options?: MqttEndpoint.SubscriptionOptions): AsyncIterableIterator<MqttEndpoint.Message, void, void>;
|
|
13
|
+
publish(message: MqttEndpoint.Message): Promise<void>;
|
|
14
|
+
close(): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export declare namespace MqttEndpoint {
|
|
17
|
+
interface Message {
|
|
18
|
+
topic: string;
|
|
19
|
+
payload: Bytes | string | null;
|
|
20
|
+
retain?: boolean;
|
|
21
|
+
contentType?: string;
|
|
22
|
+
responseTopic?: string;
|
|
23
|
+
correlationData?: Bytes;
|
|
24
|
+
qos?: 0 | 1 | 2;
|
|
25
|
+
}
|
|
26
|
+
function Message(message: Message): Message;
|
|
27
|
+
interface ConnectionOptions {
|
|
28
|
+
address: AppAddress.Definition;
|
|
29
|
+
environment?: Environment;
|
|
30
|
+
will?: Message;
|
|
31
|
+
onUp?: (endpoint: MqttEndpoint) => MaybePromise<void>;
|
|
32
|
+
onDown?: (endpoint: MqttEndpoint) => MaybePromise<void>;
|
|
33
|
+
}
|
|
34
|
+
interface SubscriptionOptions {
|
|
35
|
+
noLocal?: boolean;
|
|
36
|
+
abort?: Abort.Signal;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=MqttEndpoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MqttEndpoint.d.ts","sourceRoot":"","sources":["../../../../src/net/mqtt/MqttEndpoint.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,WAAW,YAAY;IACzB,SAAS,CACL,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,YAAY,CAAC,mBAAmB,GAC3C,qBAAqB,CAAC,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC3D,OAAO,CAAC,OAAO,EAAE,YAAY,CAAC,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,yBAAiB,YAAY,CAAC;IAC1B,UAAiB,OAAO;QACpB,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,CAAC;QAC/B,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,eAAe,CAAC,EAAE,KAAK,CAAC;QACxB,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;KACnB;IAED,SAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,WAEvC;IAED,UAAiB,iBAAiB;QAC9B,OAAO,EAAE,UAAU,CAAC,UAAU,CAAC;QAC/B,WAAW,CAAC,EAAE,WAAW,CAAC;QAC1B,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,YAAY,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;QACtD,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,YAAY,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;KAC3D;IAED,UAAiB,mBAAmB;QAChC,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC;KACxB;CACJ"}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 MqttEndpoint_exports = {};
|
|
20
|
+
__export(MqttEndpoint_exports, {
|
|
21
|
+
MqttEndpoint: () => MqttEndpoint
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(MqttEndpoint_exports);
|
|
24
|
+
/**
|
|
25
|
+
* @license
|
|
26
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
27
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
28
|
+
*/
|
|
29
|
+
var MqttEndpoint;
|
|
30
|
+
((MqttEndpoint2) => {
|
|
31
|
+
function Message(message) {
|
|
32
|
+
return message;
|
|
33
|
+
}
|
|
34
|
+
MqttEndpoint2.Message = Message;
|
|
35
|
+
})(MqttEndpoint || (MqttEndpoint = {}));
|
|
36
|
+
//# sourceMappingURL=MqttEndpoint.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/net/mqtt/MqttEndpoint.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBO,IAAU;AAAA,CAAV,CAAUA,kBAAV;AAWI,WAAS,QAAQ,SAAkB;AACtC,WAAO;AAAA,EACX;AAFO,EAAAA,cAAS;AAAA,GAXH;",
|
|
5
|
+
"names": ["MqttEndpoint"]
|
|
6
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { MqttEndpoint } from "./MqttEndpoint.js";
|
|
7
|
+
/**
|
|
8
|
+
* Connects to an MQTT broker.
|
|
9
|
+
*
|
|
10
|
+
* MQTT adapters should implement this class. Clients should access via {@link MqttService}.
|
|
11
|
+
*/
|
|
12
|
+
export declare abstract class MqttEndpointFactory {
|
|
13
|
+
abstract connect(options: MqttEndpoint.ConnectionOptions): Promise<MqttEndpoint>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=MqttEndpointFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MqttEndpointFactory.d.ts","sourceRoot":"","sources":["../../../../src/net/mqtt/MqttEndpointFactory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD;;;;GAIG;AACH,8BAAsB,mBAAmB;IACrC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,YAAY,CAAC,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC;CACnF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
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 MqttEndpointFactory_exports = {};
|
|
20
|
+
__export(MqttEndpointFactory_exports, {
|
|
21
|
+
MqttEndpointFactory: () => MqttEndpointFactory
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(MqttEndpointFactory_exports);
|
|
24
|
+
/**
|
|
25
|
+
* @license
|
|
26
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
27
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
28
|
+
*/
|
|
29
|
+
class MqttEndpointFactory {
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=MqttEndpointFactory.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Environment } from "#environment/Environment.js";
|
|
7
|
+
import { Environmental } from "#environment/Environmental.js";
|
|
8
|
+
import { MqttEndpoint } from "./MqttEndpoint.js";
|
|
9
|
+
import { MqttEndpointFactory } from "./MqttEndpointFactory.js";
|
|
10
|
+
/**
|
|
11
|
+
* Provides connections to MQTT brokers.
|
|
12
|
+
*/
|
|
13
|
+
export declare class MqttService {
|
|
14
|
+
#private;
|
|
15
|
+
constructor(factory: MqttEndpointFactory);
|
|
16
|
+
static [Environmental.create](env: Environment): MqttService;
|
|
17
|
+
connect(options: MqttEndpoint.ConnectionOptions): Promise<MqttEndpoint>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=MqttService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MqttService.d.ts","sourceRoot":"","sources":["../../../../src/net/mqtt/MqttService.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAG9D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;GAEG;AACH,qBAAa,WAAW;;gBAGR,OAAO,EAAE,mBAAmB;IAIxC,MAAM,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,WAAW;IAO9C,OAAO,CAAC,OAAO,EAAE,YAAY,CAAC,iBAAiB;CASlD"}
|
|
@@ -0,0 +1,52 @@
|
|
|
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 MqttService_exports = {};
|
|
20
|
+
__export(MqttService_exports, {
|
|
21
|
+
MqttService: () => MqttService
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(MqttService_exports);
|
|
24
|
+
var import_Environmental = require("#environment/Environmental.js");
|
|
25
|
+
var import_MatterError = require("#MatterError.js");
|
|
26
|
+
var import_AppAddress = require("#net/AppAddress.js");
|
|
27
|
+
var import_MqttEndpointFactory = require("./MqttEndpointFactory.js");
|
|
28
|
+
/**
|
|
29
|
+
* @license
|
|
30
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
31
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
32
|
+
*/
|
|
33
|
+
class MqttService {
|
|
34
|
+
#factory;
|
|
35
|
+
constructor(factory) {
|
|
36
|
+
this.#factory = factory;
|
|
37
|
+
}
|
|
38
|
+
static [import_Environmental.Environmental.create](env) {
|
|
39
|
+
const factory = env.get(import_MqttEndpointFactory.MqttEndpointFactory);
|
|
40
|
+
const instance = new this(factory);
|
|
41
|
+
env.set(MqttService, instance);
|
|
42
|
+
return instance;
|
|
43
|
+
}
|
|
44
|
+
connect(options) {
|
|
45
|
+
const addr = import_AppAddress.AppAddress.for(options.address);
|
|
46
|
+
if (addr.appProtocol !== "mqtt") {
|
|
47
|
+
throw new import_MatterError.ImplementationError(`Unsupported address ${addr} for MQTT connection`);
|
|
48
|
+
}
|
|
49
|
+
return this.#factory.connect(options);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=MqttService.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/net/mqtt/MqttService.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,2BAA8B;AAC9B,yBAAoC;AACpC,wBAA2B;AAE3B,iCAAoC;AAXpC;AAAA;AAAA;AAAA;AAAA;AAgBO,MAAM,YAAY;AAAA,EACrB;AAAA,EAEA,YAAY,SAA8B;AACtC,SAAK,WAAW;AAAA,EACpB;AAAA,EAEA,QAAQ,mCAAc,MAAM,EAAE,KAAkB;AAC5C,UAAM,UAAU,IAAI,IAAI,8CAAmB;AAC3C,UAAM,WAAW,IAAI,KAAK,OAAO;AACjC,QAAI,IAAI,aAAa,QAAQ;AAC7B,WAAO;AAAA,EACX;AAAA,EAEA,QAAQ,SAAyC;AAC7C,UAAM,OAAO,6BAAW,IAAI,QAAQ,OAAO;AAE3C,QAAI,KAAK,gBAAgB,QAAQ;AAC7B,YAAM,IAAI,uCAAoB,uBAAuB,IAAI,sBAAsB;AAAA,IACnF;AAEA,WAAO,KAAK,SAAS,QAAQ,OAAO;AAAA,EACxC;AACJ;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/net/mqtt/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var mqtt_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(mqtt_exports);
|
|
18
|
+
__reExport(mqtt_exports, require("./MqttEndpoint.js"), module.exports);
|
|
19
|
+
__reExport(mqtt_exports, require("./MqttEndpointFactory.js"), module.exports);
|
|
20
|
+
__reExport(mqtt_exports, require("./MqttService.js"), module.exports);
|
|
21
|
+
/**
|
|
22
|
+
* @license
|
|
23
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
24
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
25
|
+
*/
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -8,12 +8,41 @@ import { ChannelType } from "../Channel.js";
|
|
|
8
8
|
import { ConnectionlessTransport } from "../ConnectionlessTransport.js";
|
|
9
9
|
/** @see {@link MatterSpecification.v12.Core} § 4.4.4 */
|
|
10
10
|
export declare const MAX_UDP_MESSAGE_SIZE: number;
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* UDP socket address type.
|
|
13
|
+
*
|
|
14
|
+
* "udp4" and "udp6" are IPv4 and IPv6 exclusively. "udp" binds both IPv4 and IPv6 addresses.
|
|
15
|
+
*/
|
|
16
|
+
export type UdpSocketType = "udp" | "udp4" | "udp6";
|
|
12
17
|
export interface UdpChannelOptions {
|
|
13
|
-
|
|
18
|
+
/**
|
|
19
|
+
* UDP channel type. "udp4" and "udp6" mean IPv4 and IPv6 respectively. "udp" is dual-mode IPv4/IPv6.
|
|
20
|
+
*/
|
|
14
21
|
type: UdpSocketType;
|
|
22
|
+
/**
|
|
23
|
+
* The port to listen on. undefined or 0 directs the operating system to select an open port.
|
|
24
|
+
*/
|
|
25
|
+
listeningPort?: number;
|
|
26
|
+
/**
|
|
27
|
+
* The address to listen on, either a hostname or IP address in correct format based on {@link type}.
|
|
28
|
+
*
|
|
29
|
+
* undefined directs the operating system to listen on all addresses on the port. "0.0.0.0" is wildcard IPv4 and
|
|
30
|
+
* "::" is wildcard IPv6.
|
|
31
|
+
*
|
|
32
|
+
* "0.0.0.0" is not allowed if {@link type} is "udp".
|
|
33
|
+
*/
|
|
15
34
|
listeningAddress?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Specifies a specific network interface.
|
|
37
|
+
*
|
|
38
|
+
* This is required for multicast sockets.
|
|
39
|
+
*/
|
|
16
40
|
netInterface?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Address+port pairs are normally may normally only be opened by a single socket. This allows shared access to a
|
|
43
|
+
* port.
|
|
44
|
+
*/
|
|
45
|
+
reuseAddress?: boolean;
|
|
17
46
|
}
|
|
18
47
|
export interface UdpChannel {
|
|
19
48
|
maxPayloadSize: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UdpChannel.d.ts","sourceRoot":"","sources":["../../../../src/net/udp/UdpChannel.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAExE,wDAAwD;AACxD,eAAO,MAAM,oBAAoB,QAAY,CAAC;AAE9C,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"UdpChannel.d.ts","sourceRoot":"","sources":["../../../../src/net/udp/UdpChannel.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAExE,wDAAwD;AACxD,eAAO,MAAM,oBAAoB,QAAY,CAAC;AAE9C;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAEpD,MAAM,WAAW,iBAAiB;IAC9B;;OAEG;IACH,IAAI,EAAE,aAAa,CAAC;IAEpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,UAAU;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACnD,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACpD,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,QAAQ,GAAG,uBAAuB,CAAC,QAAQ,CAAC;IACxE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,IAAI,IAAI,MAAM,CAAC;IACnB,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1D;AAED,yBAAiB,UAAU,CAAC;IACxB,UAAiB,QAAQ;QACrB,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;KAChG;CACJ"}
|