Skip to content

Commit

Permalink
Make examples esm and add esm to node-ble (#422)
Browse files Browse the repository at this point in the history
  • Loading branch information
vilicvane authored Oct 31, 2023
1 parent ae74908 commit 9427879
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 18 deletions.
16 changes: 14 additions & 2 deletions packages/matter-node-ble.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,25 @@
"LICENSE",
"README.md"
],
"type": "module",
"main": "dist/cjs/ble/export.js",
"types": "dist/cjs/ble/export.d.ts",
"exports": {
"./package.json": "./package.json",
"./*": {
"types": "./dist/cjs/*/export.d.ts",
"default": "./dist/cjs/*/export.js"
"import": {
"types": "./dist/esm/*/export.d.ts",
"default": "./dist/esm/*/export.js"
},
"require": {
"types": "./dist/cjs/*/export.d.ts",
"default": "./dist/cjs/*/export.js"
}
},
"./require": {
"types": "./require/require.d.ts",
"import": "./require/require.mjs",
"require": "./require/require.cjs"
}
},
"typesVersions": {
Expand Down
4 changes: 4 additions & 0 deletions packages/matter-node-ble.js/require/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"main": "./require.cjs",
"module": "./require.mjs"
}
1 change: 1 addition & 0 deletions packages/matter-node-ble.js/require/require.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exports.require = require;
1 change: 1 addition & 0 deletions packages/matter-node-ble.js/require/require.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const require: NodeRequire;
3 changes: 3 additions & 0 deletions packages/matter-node-ble.js/require/require.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { createRequire } from "module";

export const require = createRequire(import.meta.url);
2 changes: 1 addition & 1 deletion packages/matter-node-ble.js/src/ble/BleBroadcaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { VendorId } from "@project-chip/matter.js/datatype";
import { Logger } from "@project-chip/matter.js/log";
import { ByteArray } from "@project-chip/matter.js/util";
import { BlenoBleServer } from "./BlenoBleServer";
import { BlenoBleServer } from "./BlenoBleServer.js";

const logger = Logger.get("BleBroadcaster");

Expand Down
12 changes: 6 additions & 6 deletions packages/matter-node-ble.js/src/ble/BleNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import { Ble } from "@project-chip/matter.js/ble";
import { InstanceBroadcaster, Scanner, TransportInterface } from "@project-chip/matter.js/common";
import { NetInterface } from "@project-chip/matter.js/net";
import { ByteArray } from "@project-chip/matter.js/util";
import { BleBroadcaster } from "./BleBroadcaster";
import { BlePeripheralInterface } from "./BlePeripheralInterface";
import { BleScanner } from "./BleScanner";
import { BlenoBleServer } from "./BlenoBleServer";
import { NobleBleCentralInterface } from "./NobleBleChannel";
import { NobleBleClient } from "./NobleBleClient";
import { BleBroadcaster } from "./BleBroadcaster.js";
import { BlePeripheralInterface } from "./BlePeripheralInterface.js";
import { BleScanner } from "./BleScanner.js";
import { BlenoBleServer } from "./BlenoBleServer.js";
import { NobleBleCentralInterface } from "./NobleBleChannel.js";
import { NobleBleClient } from "./NobleBleClient.js";

export type BleOptions = {
hciId?: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { Channel, Listener, TransportInterface } from "@project-chip/matter.js/common";
import { ByteArray } from "@project-chip/matter.js/util";
import { BlenoBleServer } from "./BlenoBleServer";
import { BlenoBleServer } from "./BlenoBleServer.js";

export class BlePeripheralInterface implements TransportInterface {
constructor(private readonly blenoServer: BlenoBleServer) {}
Expand Down
2 changes: 1 addition & 1 deletion packages/matter-node-ble.js/src/ble/BleScanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { VendorId } from "@project-chip/matter.js/datatype";
import { Logger } from "@project-chip/matter.js/log";
import { Time, Timer } from "@project-chip/matter.js/time";
import { ByteArray, createPromise } from "@project-chip/matter.js/util";
import { NobleBleClient } from "./NobleBleClient";
import { NobleBleClient } from "./NobleBleClient.js";

const logger = Logger.get("BleScanner");

Expand Down
3 changes: 2 additions & 1 deletion packages/matter-node-ble.js/src/ble/BlenoBleServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { require } from "@project-chip/matter-node-ble.js/require";
import {
BLE_MATTER_C1_CHARACTERISTIC_UUID,
BLE_MATTER_C2_CHARACTERISTIC_UUID,
Expand All @@ -18,7 +19,7 @@ import { Channel, InternalError } from "@project-chip/matter.js/common";
import { Logger } from "@project-chip/matter.js/log";
import { Time } from "@project-chip/matter.js/time";
import { ByteArray, createPromise } from "@project-chip/matter.js/util";
import { BleOptions } from "./BleNode";
import { BleOptions } from "./BleNode.js";

const logger = Logger.get("BlenoBleServer");
let Bleno: typeof import("@abandonware/bleno");
Expand Down
2 changes: 1 addition & 1 deletion packages/matter-node-ble.js/src/ble/NobleBleChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { Logger } from "@project-chip/matter.js/log";
import { NetInterface } from "@project-chip/matter.js/net";
import { Time } from "@project-chip/matter.js/time";
import { ByteArray, createPromise } from "@project-chip/matter.js/util";
import { BleScanner } from "./BleScanner";
import { BleScanner } from "./BleScanner.js";

const logger = Logger.get("BleChannel");

Expand Down
3 changes: 2 additions & 1 deletion packages/matter-node-ble.js/src/ble/NobleBleClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
*/

import type { Peripheral } from "@abandonware/noble";
import { require } from "@project-chip/matter-node-ble.js/require";
import { BLE_MATTER_SERVICE_UUID } from "@project-chip/matter.js/ble";
import { Logger } from "@project-chip/matter.js/log";
import { ByteArray } from "@project-chip/matter.js/util";
import { BleOptions } from "./BleNode";
import { BleOptions } from "./BleNode.js";

const logger = Logger.get("NobleBleClient");
let noble: typeof import("@abandonware/noble");
Expand Down
4 changes: 2 additions & 2 deletions packages/matter-node-ble.js/src/ble/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
*/

export * from "./BleBroadcaster.js";
export * from "./BleNode";
export * from "./BleScanner";
export * from "./BleNode.js";
export * from "./BleScanner.js";
2 changes: 1 addition & 1 deletion packages/matter-node-ble.js/src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "../../../tools/tsconfig.base.json",
"compilerOptions": {
"outDir": "../dist/cjs",
"outDir": "../dist/esm",
"types": ["node"]
},
"references": [{ "path": "../../matter.js/src" }],
Expand Down
1 change: 1 addition & 0 deletions packages/matter-node.js-examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"LICENSE",
"README.md"
],
"type": "module",
"publishConfig": {
"access": "public"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/matter-node.js-examples/src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "../../../tools/tsconfig.base.json",
"compilerOptions": {
"outDir": "../dist/cjs",
"outDir": "../dist/esm",
"types": ["node"]
},
"references": [{ "path": "../../matter-node.js/src" }, { "path": "../../matter-node-ble.js/src" }]
Expand Down

0 comments on commit 9427879

Please sign in to comment.