Skip to content

Commit

Permalink
Merge branch 'zwave-js:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
dlm31 authored Dec 13, 2024
2 parents 347c4c1 + c80a52d commit 0d6435f
Show file tree
Hide file tree
Showing 45 changed files with 187 additions and 823 deletions.
8 changes: 5 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"image": "mcr.microsoft.com/devcontainers/javascript-node:0-18",
"containerEnv": {
"YARN_ENABLE_GLOBAL_CACHE": "false", // Avoids cross-link issues due to different filesystems between /home and /workspaces
"COREPACK_ENABLE_DOWNLOAD_PROMPT": "0" // Avoids interactive prompt causing container creation to hang
// Avoids cross-link issues due to different filesystems between /home and /workspaces
"YARN_GLOBAL_FOLDER": "/workspaces/node-zwave-js/.yarn/global",
"YARN_ENABLE_GLOBAL_CACHE": "false",
// Avoids interactive prompt causing container creation to hang
"COREPACK_ENABLE_DOWNLOAD_PROMPT": "0"
},

"updateContentCommand": "sudo corepack enable && yarn && yarn bootstrap",
"customizations": {
"vscode": {
Expand Down
16 changes: 11 additions & 5 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# Commands to start on workspace startup
# For reference, these env variables are set in the project settings:
# - YARN_CACHE_FOLDER=".yarn/cache"
# - YARN_ENABLE_GLOBAL_CACHE="false"
env:
# Avoids cross-link issues due to different filesystems between /home and /workspaces
YARN_GLOBAL_FOLDER: '.yarn/global'
YARN_CACHE_FOLDER: '.yarn/cache'
YARN_ENABLE_GLOBAL_CACHE: 'false'
# Avoids interactive prompt causing container creation to hang
COREPACK_ENABLE_DOWNLOAD_PROMPT: '0'

tasks:
- init: |
yarn install
yarn build
corepack enable
yarn
yarn bootstrap
command: |
bash .gitpod/setup-git.sh
gp sync-done prepare
Expand Down
2 changes: 0 additions & 2 deletions packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
"@types/js-levenshtein": "^1.1.3",
"@types/json-logic-js": "^2.0.7",
"@types/node": "^18.19.63",
"@types/proxyquire": "^1.3.31",
"@types/semver": "^7.5.8",
"@types/sinon": "^17.0.3",
"@types/xml2js": "^0.4.14",
Expand All @@ -86,7 +85,6 @@
"js-levenshtein": "^1.1.6",
"ky": "^1.7.2",
"peggy": "^3.0.2",
"proxyquire": "^2.1.3",
"sinon": "^19.0.2",
"ts-pegjs": "patch:ts-pegjs@npm%3A4.2.1#~/.yarn/patches/ts-pegjs-npm-4.2.1-0f567a1059.patch",
"tsx": "^4.19.2",
Expand Down
16 changes: 16 additions & 0 deletions packages/core/src/bindings/db/jsonl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { JsonlDB } from "@alcalzone/jsonl-db";
import {
type Database,
type DatabaseFactory,
type DatabaseOptions,
} from "@zwave-js/shared/bindings";

/** An implementation of the Database bindings for Node.js based on JsonlDB */
export const db: DatabaseFactory = {
createInstance<V>(
filename: string,
options?: DatabaseOptions<V>,
): Database<V> {
return new JsonlDB(filename, options);
},
};
2 changes: 1 addition & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export * from "./test/assertZWaveError.js";
export type * from "./traits/index.js";
export * from "./util/_Types.js";
export * from "./util/compareVersions.js";
export { deflateSync } from "./util/compression.js";
export { deflateSync, gunzipSync } from "./util/compression.js";
export * from "./util/config.js";
export * from "./util/crc.js";
export * from "./util/date.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/index_browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export * from "./registries/Scales.js";
export * from "./registries/Sensors.js";
export type * from "./traits/index.js";
export type * from "./util/_Types.js";
export { deflateSync } from "./util/compression.js";
export { deflateSync, gunzipSync } from "./util/compression.js";
export * from "./util/config.js";
export * from "./util/crc.js";
export * from "./util/graph.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/index_safe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export * from "./registries/Scales.js";
export * from "./registries/Sensors.js";
export type * from "./traits/index.js";
export * from "./util/_Types.js";
export { deflateSync } from "./util/compression.js";
export { deflateSync, gunzipSync } from "./util/compression.js";
export * from "./util/config.js";
export * from "./util/crc.js";
export * from "./util/graph.js";
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/util/compression.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { deflateSync as defflateSync } from "fflate";
import { deflateSync as defflateSync, gunzipSync as fgunzipSync } from "fflate";

export function deflateSync(data: Uint8Array): Uint8Array {
return defflateSync(data);
}

export function gunzipSync(data: Uint8Array): Uint8Array {
return fgunzipSync(data);
}
4 changes: 2 additions & 2 deletions packages/core/src/values/CacheBackedMap.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { JsonlDB } from "@alcalzone/jsonl-db";
import { type Database } from "@zwave-js/shared/bindings";

export interface CacheBackedMapKeys<K extends string | number> {
/** The common prefix all keys start with */
Expand All @@ -12,7 +12,7 @@ export interface CacheBackedMapKeys<K extends string | number> {
/** Wrapper class which allows storing a Map as a subset of a JsonlDB */
export class CacheBackedMap<K extends string | number, V> implements Map<K, V> {
constructor(
private readonly cache: JsonlDB<any>,
private readonly cache: Database<any>,
private readonly cacheKeys: CacheBackedMapKeys<K>,
) {
this.map = new Map();
Expand Down
14 changes: 8 additions & 6 deletions packages/core/src/values/ValueDB.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { JsonlDB } from "@alcalzone/jsonl-db";
import { TypedEventTarget } from "@zwave-js/shared";
import { type Database } from "@zwave-js/shared/bindings";
import type { CommandClasses } from "../definitions/CommandClasses.js";
import {
ZWaveError,
Expand Down Expand Up @@ -106,8 +106,8 @@ export class ValueDB extends TypedEventTarget<ValueDBEventCallbacks> {
*/
public constructor(
nodeId: number,
valueDB: JsonlDB,
metadataDB: JsonlDB<ValueMetadata>,
valueDB: Database<unknown>,
metadataDB: Database<ValueMetadata>,
ownKeys?: Set<string>,
) {
super();
Expand All @@ -119,8 +119,8 @@ export class ValueDB extends TypedEventTarget<ValueDBEventCallbacks> {
}

private nodeId: number;
private _db: JsonlDB<unknown>;
private _metadata: JsonlDB<ValueMetadata>;
private _db: Database<unknown>;
private _metadata: Database<ValueMetadata>;
private _index: Set<string>;

private buildIndex(): Set<string> {
Expand Down Expand Up @@ -603,7 +603,9 @@ function compareDBKeyFast(
}

/** Extracts an index for each node from one or more JSONL DBs */
export function indexDBsByNode(databases: JsonlDB[]): Map<number, Set<string>> {
export function indexDBsByNode(
databases: Database<unknown>[],
): Map<number, Set<string>> {
const indexes = new Map<number, Set<string>>();
for (const db of databases) {
for (const key of db.keys()) {
Expand Down
2 changes: 0 additions & 2 deletions packages/serial/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ export * from "./parsers/ZnifferSerialFrame.js";
export * from "./plumbing/Faucet.js";
export type * from "./serialport/Bindings.js";
export * from "./serialport/LegacyBindingWrapper.js";
export * from "./serialport/NodeSerialPort.js";
export * from "./serialport/NodeSocket.js";
export * from "./serialport/ZWaveSerialPortImplementation.js";
export * from "./serialport/ZWaveSerialStream.js";
export * from "./serialport/ZWaveSocketOptions.js";
Expand Down
2 changes: 0 additions & 2 deletions packages/serial/src/index_mock.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export * from "./mock/MockPort.js";
export * from "./mock/SerialPortBindingMock.js";
export * from "./mock/SerialPortMock.js";
Loading

0 comments on commit 0d6435f

Please sign in to comment.