zwave-js 15.2.0 → 15.2.1

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.
Files changed (46) hide show
  1. package/build/cjs/index_browser.js.map +2 -2
  2. package/build/cjs/lib/_version.d.ts +1 -1
  3. package/build/cjs/lib/_version.js +1 -1
  4. package/build/cjs/lib/_version.js.map +1 -1
  5. package/build/cjs/lib/driver/Driver.js +9 -7
  6. package/build/cjs/lib/driver/Driver.js.map +2 -2
  7. package/build/cjs/lib/driver/DriverMock.js +1 -1
  8. package/build/cjs/lib/driver/DriverMock.js.map +2 -2
  9. package/build/cjs/lib/driver/mDNSDiscovery/node.d.ts +3 -0
  10. package/build/cjs/lib/driver/mDNSDiscovery/node.js +97 -0
  11. package/build/cjs/lib/driver/mDNSDiscovery/node.js.map +7 -0
  12. package/build/cjs/lib/driver/mDNSDiscovery/stub.d.ts +3 -0
  13. package/build/cjs/lib/driver/mDNSDiscovery/stub.js +33 -0
  14. package/build/cjs/lib/driver/mDNSDiscovery/stub.js.map +7 -0
  15. package/build/cjs/lib/driver/mDNSDiscovery.d.ts +1 -1
  16. package/build/cjs/lib/driver/mDNSDiscovery.js +2 -70
  17. package/build/cjs/lib/driver/mDNSDiscovery.js.map +3 -3
  18. package/build/cjs/lib/zniffer/Zniffer.js +3 -3
  19. package/build/cjs/lib/zniffer/Zniffer.js.map +2 -2
  20. package/build/cjs/package.json +30 -1
  21. package/build/esm/index_browser.d.ts.map +1 -1
  22. package/build/esm/index_browser.js +1 -0
  23. package/build/esm/index_browser.js.map +1 -1
  24. package/build/esm/lib/_version.d.ts +1 -1
  25. package/build/esm/lib/_version.js +1 -1
  26. package/build/esm/lib/driver/Driver.d.ts.map +1 -1
  27. package/build/esm/lib/driver/Driver.js +10 -12
  28. package/build/esm/lib/driver/Driver.js.map +1 -1
  29. package/build/esm/lib/driver/DriverMock.js +1 -1
  30. package/build/esm/lib/driver/DriverMock.js.map +1 -1
  31. package/build/esm/lib/driver/mDNSDiscovery/node.d.ts +3 -0
  32. package/build/esm/lib/driver/mDNSDiscovery/node.d.ts.map +1 -0
  33. package/build/esm/lib/driver/mDNSDiscovery/node.js +70 -0
  34. package/build/esm/lib/driver/mDNSDiscovery/node.js.map +1 -0
  35. package/build/esm/lib/driver/mDNSDiscovery/stub.d.ts +3 -0
  36. package/build/esm/lib/driver/mDNSDiscovery/stub.d.ts.map +1 -0
  37. package/build/esm/lib/driver/mDNSDiscovery/stub.js +5 -0
  38. package/build/esm/lib/driver/mDNSDiscovery/stub.js.map +1 -0
  39. package/build/esm/lib/driver/mDNSDiscovery.d.ts +1 -1
  40. package/build/esm/lib/driver/mDNSDiscovery.d.ts.map +1 -1
  41. package/build/esm/lib/driver/mDNSDiscovery.js +1 -69
  42. package/build/esm/lib/driver/mDNSDiscovery.js.map +1 -1
  43. package/build/esm/lib/zniffer/Zniffer.js +3 -3
  44. package/build/esm/lib/zniffer/Zniffer.js.map +1 -1
  45. package/build/esm/package.json +30 -1
  46. package/package.json +39 -10
@@ -72,7 +72,7 @@ function createAndStartDriverWithMockPort(options = {}) {
72
72
  }
73
73
  __name(createAndStartDriverWithMockPort, "createAndStartDriverWithMockPort");
74
74
  async function createAndStartTestingDriver(options = {}) {
75
- const { beforeStartup, skipControllerIdentification = false, skipFirmwareIdentification = true, skipNodeInterview = false, loadConfiguration = true, fs = (await import("@zwave-js/core/bindings/fs/node")).fs, ...internalOptions } = options;
75
+ const { beforeStartup, skipControllerIdentification = false, skipFirmwareIdentification = true, skipNodeInterview = false, loadConfiguration = true, fs = (await import("#default_bindings/fs")).fs, ...internalOptions } = options;
76
76
  const testId = Math.round(Math.random() * 4294967295).toString(16).padStart(8, "0");
77
77
  if (skipControllerIdentification) {
78
78
  internalOptions.testingHooks ??= {};
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/driver/DriverMock.ts"],
4
- "sourcesContent": ["import type { ZWaveSerialStream } from \"@zwave-js/serial\";\nimport { MockPort } from \"@zwave-js/serial/mock\";\nimport type { FileSystem } from \"@zwave-js/shared/bindings\";\nimport { createDeferredPromise } from \"alcalzone-shared/deferred-promise\";\nimport { tmpdir } from \"node:os\";\nimport path from \"pathe\";\nimport { Driver } from \"./Driver.js\";\nimport type { PartialZWaveOptions, ZWaveOptions } from \"./ZWaveOptions.js\";\n\nexport interface CreateAndStartDriverWithMockPortResult {\n\tdriver: Driver;\n\tcontinueStartup: () => void;\n\tmockPort: MockPort;\n\tserial: ZWaveSerialStream;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface CreateAndStartDriverWithMockPortOptions {\n\t// portAddress: string;\n}\n\n/** Creates a real driver instance with a mocked serial port to enable end to end tests */\nexport function createAndStartDriverWithMockPort(\n\toptions:\n\t\t& Partial<CreateAndStartDriverWithMockPortOptions>\n\t\t& PartialZWaveOptions = {},\n): Promise<CreateAndStartDriverWithMockPortResult> {\n\tconst { ...driverOptions } = options;\n\treturn new Promise(async (resolve, _reject) => {\n\t\t// eslint-disable-next-line prefer-const\n\t\tlet driver: Driver;\n\t\tconst mockPort = new MockPort();\n\t\tconst bindingFactory = mockPort.factory();\n\t\t// let mockPort: MockPortBinding;\n\n\t\t// MockBinding.reset();\n\t\t// MockBinding.createPort(portAddress, {\n\t\t// \trecord: true,\n\t\t// \treadyData: new Uint8Array(),\n\t\t// });\n\n\t\t// This will be called when the driver has opened the serial port\n\t\tconst onSerialPortOpen = (\n\t\t\tserial: ZWaveSerialStream,\n\t\t): Promise<void> => {\n\t\t\t// // Extract the mock serial port\n\t\t\t// mockPort = MockBinding.getInstance(portAddress)!;\n\t\t\t// if (!mockPort) reject(new Error(\"Mock serial port is not open!\"));\n\n\t\t\t// And return the info to the calling code, giving it control over\n\t\t\t// continuing the driver startup.\n\t\t\tconst continuePromise = createDeferredPromise();\n\t\t\tresolve({\n\t\t\t\tdriver,\n\t\t\t\tmockPort,\n\t\t\t\tserial,\n\t\t\t\tcontinueStartup: () => continuePromise.resolve(),\n\t\t\t});\n\n\t\t\treturn continuePromise;\n\t\t};\n\n\t\t// Usually we don't want logs in these tests\n\t\tif (!driverOptions.logConfig) {\n\t\t\tdriverOptions.logConfig = {\n\t\t\t\tenabled: false,\n\t\t\t};\n\t\t}\n\n\t\tconst testingHooks: ZWaveOptions[\"testingHooks\"] = {\n\t\t\t...driverOptions.testingHooks,\n\t\t\tonSerialPortOpen,\n\t\t};\n\n\t\tdriver = new Driver(bindingFactory, {\n\t\t\t...driverOptions,\n\t\t\ttestingHooks,\n\t\t});\n\t\tawait driver.start();\n\t});\n}\n\nexport type CreateAndStartTestingDriverResult = Omit<\n\tCreateAndStartDriverWithMockPortResult,\n\t\"continueStartup\"\n>;\n\nexport interface CreateAndStartTestingDriverOptions {\n\tbeforeStartup: (\n\t\tmockPort: MockPort,\n\t\tserial: ZWaveSerialStream,\n\t) => void | Promise<void>;\n\t/**\n\t * Whether the controller identification should be skipped (default: false).\n\t * If not, a Mock controller must be available on the serial port.\n\t */\n\tskipControllerIdentification?: boolean;\n\t/**\n\t * Whether the node interview should be skipped (default: false).\n\t * If not, a Mock controller and/or mock nodes must be available on the serial port.\n\t */\n\tskipNodeInterview?: boolean;\n\n\t/**\n\t * Set this to true to skip checking if the controller is in bootloader, serial API, or CLI mode (default: true)\n\t */\n\tskipFirmwareIdentification?: boolean;\n\n\t/**\n\t * Whether configuration files should be loaded (default: true)\n\t */\n\tloadConfiguration?: boolean;\n\n\tportAddress: string;\n\tfs?: FileSystem;\n}\n\nexport async function createAndStartTestingDriver(\n\toptions:\n\t\t& Partial<CreateAndStartTestingDriverOptions>\n\t\t& PartialZWaveOptions = {},\n): Promise<CreateAndStartTestingDriverResult> {\n\tconst {\n\t\tbeforeStartup,\n\t\tskipControllerIdentification = false,\n\t\tskipFirmwareIdentification = true,\n\t\tskipNodeInterview = false,\n\t\tloadConfiguration = true,\n\t\tfs = (await import(\"@zwave-js/core/bindings/fs/node\")).fs,\n\t\t...internalOptions\n\t} = options;\n\n\t// Use a new fake serial port for each test\n\tconst testId = Math.round(Math.random() * 0xffffffff)\n\t\t.toString(16)\n\t\t.padStart(8, \"0\");\n\t// internalOptions.portAddress ??= `/tty/FAKE${testId}`;\n\n\tif (skipControllerIdentification) {\n\t\tinternalOptions.testingHooks ??= {};\n\t\tinternalOptions.testingHooks.skipControllerIdentification = true;\n\t}\n\tif (skipNodeInterview) {\n\t\tinternalOptions.testingHooks ??= {};\n\t\tinternalOptions.testingHooks.skipNodeInterview = true;\n\t}\n\tif (!loadConfiguration) {\n\t\tinternalOptions.testingHooks ??= {};\n\t\tinternalOptions.testingHooks.loadConfiguration = false;\n\t}\n\tif (skipFirmwareIdentification) {\n\t\tinternalOptions.testingHooks ??= {};\n\t\tinternalOptions.testingHooks.skipFirmwareIdentification = true;\n\t}\n\n\t// TODO: Make sure we delete this from time to time\n\tconst cacheDir = path.join(tmpdir(), \"zwave-js-test-cache\", testId);\n\n\tinternalOptions.storage ??= {};\n\tinternalOptions.storage.cacheDir = cacheDir;\n\n\tconst { driver, continueStartup, mockPort, serial } =\n\t\tawait createAndStartDriverWithMockPort(internalOptions);\n\n\tif (typeof beforeStartup === \"function\") {\n\t\tawait beforeStartup(mockPort, serial);\n\t}\n\n\t// Make sure the mock FS gets restored when the driver is destroyed\n\tconst originalDestroy = driver.destroy.bind(driver);\n\tdriver.destroy = async () => {\n\t\tawait originalDestroy();\n\t\tawait fs.deleteDir(cacheDir);\n\t};\n\n\treturn new Promise((resolve) => {\n\t\tdriver.once(\"driver ready\", () => {\n\t\t\tresolve({ driver, mockPort, serial });\n\t\t});\n\t\tcontinueStartup();\n\t});\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;;;;;AAAA,kBAAyB;AAEzB,8BAAsC;AACtC,qBAAuB;AACvB,mBAAiB;AACjB,oBAAuB;AAgBjB,SAAU,iCACf,UAEyB,CAAA,GAAE;AAE3B,QAAM,EAAE,GAAG,cAAa,IA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,kBAAgB,QAAQ,WAAW;AAEnC,QAAM,EAAE,QAAQ,iBAAiB,UAAU,OAAM,IAChD,MAAM,iCAAiC,eAAe;AAEvD,MAAI,OAAO,kBAAkB,YAAY;AACxC,UAAM,cAAc,UAAU,MAAM;EACrC;AAGA,QAAM,kBAAkB,OAAO,QAAQ,KAAK,MAAM;AAClD,SAAO,UAAU,YAAW;AAC3B,UAAM,gBAAe;AACrB,UAAM,GAAG,UAAU,QAAQ;EAC5B;AAEA,SAAO,IAAI,QAAQ,CAAC,YAAW;AAC9B,WAAO,KAAK,gBAAgB,MAAK;AAChC,cAAQ,EAAE,QAAQ,UAAU,OAAM,CAAE;IACrC,CAAC;AACD,oBAAe;EAChB,CAAC;AACF;AAhEsB;",
4
+ "sourcesContent": ["import type { ZWaveSerialStream } from \"@zwave-js/serial\";\nimport { MockPort } from \"@zwave-js/serial/mock\";\nimport type { FileSystem } from \"@zwave-js/shared/bindings\";\nimport { createDeferredPromise } from \"alcalzone-shared/deferred-promise\";\nimport { tmpdir } from \"node:os\";\nimport path from \"pathe\";\nimport { Driver } from \"./Driver.js\";\nimport type { PartialZWaveOptions, ZWaveOptions } from \"./ZWaveOptions.js\";\n\nexport interface CreateAndStartDriverWithMockPortResult {\n\tdriver: Driver;\n\tcontinueStartup: () => void;\n\tmockPort: MockPort;\n\tserial: ZWaveSerialStream;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface CreateAndStartDriverWithMockPortOptions {\n\t// portAddress: string;\n}\n\n/** Creates a real driver instance with a mocked serial port to enable end to end tests */\nexport function createAndStartDriverWithMockPort(\n\toptions:\n\t\t& Partial<CreateAndStartDriverWithMockPortOptions>\n\t\t& PartialZWaveOptions = {},\n): Promise<CreateAndStartDriverWithMockPortResult> {\n\tconst { ...driverOptions } = options;\n\treturn new Promise(async (resolve, _reject) => {\n\t\t// eslint-disable-next-line prefer-const\n\t\tlet driver: Driver;\n\t\tconst mockPort = new MockPort();\n\t\tconst bindingFactory = mockPort.factory();\n\t\t// let mockPort: MockPortBinding;\n\n\t\t// MockBinding.reset();\n\t\t// MockBinding.createPort(portAddress, {\n\t\t// \trecord: true,\n\t\t// \treadyData: new Uint8Array(),\n\t\t// });\n\n\t\t// This will be called when the driver has opened the serial port\n\t\tconst onSerialPortOpen = (\n\t\t\tserial: ZWaveSerialStream,\n\t\t): Promise<void> => {\n\t\t\t// // Extract the mock serial port\n\t\t\t// mockPort = MockBinding.getInstance(portAddress)!;\n\t\t\t// if (!mockPort) reject(new Error(\"Mock serial port is not open!\"));\n\n\t\t\t// And return the info to the calling code, giving it control over\n\t\t\t// continuing the driver startup.\n\t\t\tconst continuePromise = createDeferredPromise();\n\t\t\tresolve({\n\t\t\t\tdriver,\n\t\t\t\tmockPort,\n\t\t\t\tserial,\n\t\t\t\tcontinueStartup: () => continuePromise.resolve(),\n\t\t\t});\n\n\t\t\treturn continuePromise;\n\t\t};\n\n\t\t// Usually we don't want logs in these tests\n\t\tif (!driverOptions.logConfig) {\n\t\t\tdriverOptions.logConfig = {\n\t\t\t\tenabled: false,\n\t\t\t};\n\t\t}\n\n\t\tconst testingHooks: ZWaveOptions[\"testingHooks\"] = {\n\t\t\t...driverOptions.testingHooks,\n\t\t\tonSerialPortOpen,\n\t\t};\n\n\t\tdriver = new Driver(bindingFactory, {\n\t\t\t...driverOptions,\n\t\t\ttestingHooks,\n\t\t});\n\t\tawait driver.start();\n\t});\n}\n\nexport type CreateAndStartTestingDriverResult = Omit<\n\tCreateAndStartDriverWithMockPortResult,\n\t\"continueStartup\"\n>;\n\nexport interface CreateAndStartTestingDriverOptions {\n\tbeforeStartup: (\n\t\tmockPort: MockPort,\n\t\tserial: ZWaveSerialStream,\n\t) => void | Promise<void>;\n\t/**\n\t * Whether the controller identification should be skipped (default: false).\n\t * If not, a Mock controller must be available on the serial port.\n\t */\n\tskipControllerIdentification?: boolean;\n\t/**\n\t * Whether the node interview should be skipped (default: false).\n\t * If not, a Mock controller and/or mock nodes must be available on the serial port.\n\t */\n\tskipNodeInterview?: boolean;\n\n\t/**\n\t * Set this to true to skip checking if the controller is in bootloader, serial API, or CLI mode (default: true)\n\t */\n\tskipFirmwareIdentification?: boolean;\n\n\t/**\n\t * Whether configuration files should be loaded (default: true)\n\t */\n\tloadConfiguration?: boolean;\n\n\tportAddress: string;\n\tfs?: FileSystem;\n}\n\nexport async function createAndStartTestingDriver(\n\toptions:\n\t\t& Partial<CreateAndStartTestingDriverOptions>\n\t\t& PartialZWaveOptions = {},\n): Promise<CreateAndStartTestingDriverResult> {\n\tconst {\n\t\tbeforeStartup,\n\t\tskipControllerIdentification = false,\n\t\tskipFirmwareIdentification = true,\n\t\tskipNodeInterview = false,\n\t\tloadConfiguration = true,\n\t\tfs = (await import(\"#default_bindings/fs\")).fs,\n\t\t...internalOptions\n\t} = options;\n\n\t// Use a new fake serial port for each test\n\tconst testId = Math.round(Math.random() * 0xffffffff)\n\t\t.toString(16)\n\t\t.padStart(8, \"0\");\n\t// internalOptions.portAddress ??= `/tty/FAKE${testId}`;\n\n\tif (skipControllerIdentification) {\n\t\tinternalOptions.testingHooks ??= {};\n\t\tinternalOptions.testingHooks.skipControllerIdentification = true;\n\t}\n\tif (skipNodeInterview) {\n\t\tinternalOptions.testingHooks ??= {};\n\t\tinternalOptions.testingHooks.skipNodeInterview = true;\n\t}\n\tif (!loadConfiguration) {\n\t\tinternalOptions.testingHooks ??= {};\n\t\tinternalOptions.testingHooks.loadConfiguration = false;\n\t}\n\tif (skipFirmwareIdentification) {\n\t\tinternalOptions.testingHooks ??= {};\n\t\tinternalOptions.testingHooks.skipFirmwareIdentification = true;\n\t}\n\n\t// TODO: Make sure we delete this from time to time\n\tconst cacheDir = path.join(tmpdir(), \"zwave-js-test-cache\", testId);\n\n\tinternalOptions.storage ??= {};\n\tinternalOptions.storage.cacheDir = cacheDir;\n\n\tconst { driver, continueStartup, mockPort, serial } =\n\t\tawait createAndStartDriverWithMockPort(internalOptions);\n\n\tif (typeof beforeStartup === \"function\") {\n\t\tawait beforeStartup(mockPort, serial);\n\t}\n\n\t// Make sure the mock FS gets restored when the driver is destroyed\n\tconst originalDestroy = driver.destroy.bind(driver);\n\tdriver.destroy = async () => {\n\t\tawait originalDestroy();\n\t\tawait fs.deleteDir(cacheDir);\n\t};\n\n\treturn new Promise((resolve) => {\n\t\tdriver.once(\"driver ready\", () => {\n\t\t\tresolve({ driver, mockPort, serial });\n\t\t});\n\t\tcontinueStartup();\n\t});\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;;;;;AAAA,kBAAyB;AAEzB,8BAAsC;AACtC,qBAAuB;AACvB,mBAAiB;AACjB,oBAAuB;AAgBjB,SAAU,iCACf,UAEyB,CAAA,GAAE;AAE3B,QAAM,EAAE,GAAG,cAAa,IAAK;AAC7B,SAAO,IAAI,QAAQ,OAAO,SAAS,YAAW;AAE7C,QAAI;AACJ,UAAM,WAAW,IAAI,qBAAQ;AAC7B,UAAM,iBAAiB,SAAS,QAAO;AAUvC,UAAM,mBAAmB,wBACxB,WACkB;AAOlB,YAAM,sBAAkB,+CAAqB;AAC7C,cAAQ;QACP;QACA;QACA;QACA,iBAAiB,6BAAM,gBAAgB,QAAO,GAA7B;OACjB;AAED,aAAO;IACR,GAlByB;AAqBzB,QAAI,CAAC,cAAc,WAAW;AAC7B,oBAAc,YAAY;QACzB,SAAS;;IAEX;AAEA,UAAM,eAA6C;MAClD,GAAG,cAAc;MACjB;;AAGD,aAAS,IAAI,qBAAO,gBAAgB;MACnC,GAAG;MACH;KACA;AACD,UAAM,OAAO,MAAK;EACnB,CAAC;AACF;AA1DgB;AA+FhB,eAAsB,4BACrB,UAEyB,CAAA,GAAE;AAE3B,QAAM,EACL,eACA,+BAA+B,OAC/B,6BAA6B,MAC7B,oBAAoB,OACpB,oBAAoB,MACpB,MAAM,MAAM,OAAO,sBAAsB,GAAG,IAC5C,GAAG,gBAAe,IACf;AAGJ,QAAM,SAAS,KAAK,MAAM,KAAK,OAAM,IAAK,UAAU,EAClD,SAAS,EAAE,EACX,SAAS,GAAG,GAAG;AAGjB,MAAI,8BAA8B;AACjC,oBAAgB,iBAAiB,CAAA;AACjC,oBAAgB,aAAa,+BAA+B;EAC7D;AACA,MAAI,mBAAmB;AACtB,oBAAgB,iBAAiB,CAAA;AACjC,oBAAgB,aAAa,oBAAoB;EAClD;AACA,MAAI,CAAC,mBAAmB;AACvB,oBAAgB,iBAAiB,CAAA;AACjC,oBAAgB,aAAa,oBAAoB;EAClD;AACA,MAAI,4BAA4B;AAC/B,oBAAgB,iBAAiB,CAAA;AACjC,oBAAgB,aAAa,6BAA6B;EAC3D;AAGA,QAAM,WAAW,aAAAA,QAAK,SAAK,uBAAM,GAAI,uBAAuB,MAAM;AAElE,kBAAgB,YAAY,CAAA;AAC5B,kBAAgB,QAAQ,WAAW;AAEnC,QAAM,EAAE,QAAQ,iBAAiB,UAAU,OAAM,IAChD,MAAM,iCAAiC,eAAe;AAEvD,MAAI,OAAO,kBAAkB,YAAY;AACxC,UAAM,cAAc,UAAU,MAAM;EACrC;AAGA,QAAM,kBAAkB,OAAO,QAAQ,KAAK,MAAM;AAClD,SAAO,UAAU,YAAW;AAC3B,UAAM,gBAAe;AACrB,UAAM,GAAG,UAAU,QAAQ;EAC5B;AAEA,SAAO,IAAI,QAAQ,CAAC,YAAW;AAC9B,WAAO,KAAK,gBAAgB,MAAK;AAChC,cAAQ,EAAE,QAAQ,UAAU,OAAM,CAAE;IACrC,CAAC;AACD,oBAAe;EAChB,CAAC;AACF;AAhEsB;",
6
6
  "names": ["path"]
7
7
  }
@@ -0,0 +1,3 @@
1
+ import type { RemoteSerialPort } from "../mDNSDiscovery.js";
2
+ export declare function discoverRemoteSerialPorts(timeout?: number | false): Promise<RemoteSerialPort[] | undefined>;
3
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var node_exports = {};
31
+ __export(node_exports, {
32
+ discoverRemoteSerialPorts: () => discoverRemoteSerialPorts
33
+ });
34
+ module.exports = __toCommonJS(node_exports);
35
+ var import_shared = require("@zwave-js/shared");
36
+ var import_typeguards = require("alcalzone-shared/typeguards");
37
+ const domain = "_zwave._tcp.local";
38
+ async function discoverRemoteSerialPorts(timeout = 1e3) {
39
+ const { default: createMDNSServer } = await import("mdns-server");
40
+ const mdns = createMDNSServer({
41
+ reuseAddr: true,
42
+ loopback: false,
43
+ noInit: true,
44
+ ttl: 10
45
+ });
46
+ let timer;
47
+ return new Promise((resolve, reject) => {
48
+ mdns.on("response", (resp) => {
49
+ const matches = resp.answers.filter((n) => n.type === "PTR" && n.name === domain && typeof n.data === "string").map(({ data }) => {
50
+ return {
51
+ txt: resp.answers.find((n) => n.type === "TXT" && n.name === data) ?? resp.additionals.find((n) => n.type === "TXT" && n.name === data),
52
+ srv: resp.answers.find((n) => n.type === "SRV" && n.name === data) ?? resp.additionals.find((n) => n.type === "SRV" && n.name === data)
53
+ };
54
+ }).filter(({ srv }) => !!srv && (0, import_typeguards.isObject)(srv.data) && typeof srv.data.target === "string" && typeof srv.data.port === "number").map(({ txt, srv }) => {
55
+ const info = {};
56
+ if (!!txt && (0, import_typeguards.isArray)(txt.data)) {
57
+ const strings = txt.data.filter((d) => (0, import_shared.isUint8Array)(d)).map((d) => import_shared.Bytes.view(d).toString("utf8")).filter((d) => d.includes("="));
58
+ for (const string of strings) {
59
+ const [key, value] = string.split("=", 2);
60
+ info[key] = value;
61
+ }
62
+ }
63
+ const addr = srv.data;
64
+ const port = `tcp://${addr.target}:${addr.port}`;
65
+ return {
66
+ port,
67
+ info
68
+ };
69
+ });
70
+ if (matches.length) {
71
+ clearTimeout(timer);
72
+ resolve(matches);
73
+ }
74
+ });
75
+ mdns.on("ready", () => {
76
+ mdns.query([
77
+ { name: domain, type: "PTR" },
78
+ { name: domain, type: "SRV" },
79
+ { name: domain, type: "TXT" }
80
+ ]);
81
+ });
82
+ mdns.on("error", reject);
83
+ mdns.initServer();
84
+ if (typeof timeout === "number" && timeout > 0) {
85
+ timer = setTimeout(() => {
86
+ mdns.destroy();
87
+ resolve(void 0);
88
+ }, timeout);
89
+ }
90
+ });
91
+ }
92
+ __name(discoverRemoteSerialPorts, "discoverRemoteSerialPorts");
93
+ // Annotate the CommonJS export names for ESM import in node:
94
+ 0 && (module.exports = {
95
+ discoverRemoteSerialPorts
96
+ });
97
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/lib/driver/mDNSDiscovery/node.ts"],
4
+ "sourcesContent": ["import { Bytes, isUint8Array } from \"@zwave-js/shared\";\nimport { isArray, isObject } from \"alcalzone-shared/typeguards\";\nimport type { RemoteSerialPort } from \"../mDNSDiscovery.js\";\n\nconst domain = \"_zwave._tcp.local\";\n\nexport async function discoverRemoteSerialPorts(\n\ttimeout: number | false = 1000,\n): Promise<RemoteSerialPort[] | undefined> {\n\tconst { default: createMDNSServer } = await import(\"mdns-server\");\n\tconst mdns = createMDNSServer({\n\t\treuseAddr: true,\n\t\tloopback: false,\n\t\tnoInit: true,\n\t\tttl: 10,\n\t});\n\tlet timer: NodeJS.Timeout | undefined;\n\n\treturn new Promise((resolve, reject) => {\n\t\tmdns.on(\"response\", (resp) => {\n\t\t\tconst matches = resp.answers\n\t\t\t\t.filter(\n\t\t\t\t\t(n) =>\n\t\t\t\t\t\tn.type === \"PTR\"\n\t\t\t\t\t\t&& n.name === domain\n\t\t\t\t\t\t&& typeof n.data === \"string\",\n\t\t\t\t)\n\t\t\t\t.map(({ data }) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttxt: resp.answers.find(\n\t\t\t\t\t\t\t(n) => n.type === \"TXT\" && n.name === data,\n\t\t\t\t\t\t) ?? resp.additionals.find(\n\t\t\t\t\t\t\t(n) => n.type === \"TXT\" && n.name === data,\n\t\t\t\t\t\t),\n\t\t\t\t\t\tsrv: resp.answers.find(\n\t\t\t\t\t\t\t(n) => n.type === \"SRV\" && n.name === data,\n\t\t\t\t\t\t) ?? resp.additionals.find(\n\t\t\t\t\t\t\t(n) => n.type === \"SRV\" && n.name === data,\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t})\n\t\t\t\t.filter(\n\t\t\t\t\t({ srv }) =>\n\t\t\t\t\t\t!!srv\n\t\t\t\t\t\t&& isObject(srv.data)\n\t\t\t\t\t\t&& typeof srv.data.target === \"string\"\n\t\t\t\t\t\t&& typeof srv.data.port === \"number\",\n\t\t\t\t)\n\t\t\t\t.map(({ txt, srv }) => {\n\t\t\t\t\tconst info: Record<string, string> = {};\n\t\t\t\t\tif (!!txt && isArray(txt.data)) {\n\t\t\t\t\t\tconst strings = (txt.data as unknown[])\n\t\t\t\t\t\t\t.filter((d) => isUint8Array(d))\n\t\t\t\t\t\t\t.map((d) => Bytes.view(d).toString(\"utf8\"))\n\t\t\t\t\t\t\t.filter((d) => d.includes(\"=\"));\n\n\t\t\t\t\t\tfor (const string of strings) {\n\t\t\t\t\t\t\tconst [key, value] = string.split(\"=\", 2);\n\t\t\t\t\t\t\tinfo[key] = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tconst addr = srv!.data as { target: string; port: number };\n\t\t\t\t\tconst port = `tcp://${addr.target}:${addr.port}`;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tport,\n\t\t\t\t\t\tinfo,\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\tif (matches.length) {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\tresolve(matches);\n\t\t\t}\n\t\t});\n\n\t\tmdns.on(\"ready\", () => {\n\t\t\tmdns.query([\n\t\t\t\t{ name: domain, type: \"PTR\" },\n\t\t\t\t{ name: domain, type: \"SRV\" },\n\t\t\t\t{ name: domain, type: \"TXT\" },\n\t\t\t]);\n\t\t});\n\n\t\tmdns.on(\"error\", reject);\n\n\t\tmdns.initServer();\n\n\t\tif (typeof timeout === \"number\" && timeout > 0) {\n\t\t\ttimer = setTimeout(() => {\n\t\t\t\tmdns.destroy();\n\t\t\t\tresolve(undefined);\n\t\t\t}, timeout);\n\t\t}\n\t});\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;AAAA,oBAAoC;AACpC,wBAAkC;AAGlC,MAAM,SAAS;AAEf,eAAsB,0BACrB,UAA0B,KAAI;AAE9B,QAAM,EAAE,SAAS,iBAAgB,IAAK,MAAM,OAAO,aAAa;AAChE,QAAM,OAAO,iBAAiB;IAC7B,WAAW;IACX,UAAU;IACV,QAAQ;IACR,KAAK;GACL;AACD,MAAI;A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CAAC;AAEF,UAAI,QAAQ,QAAQ;AACnB,qBAAa,KAAK;AAClB,gBAAQ,OAAO;MAChB;IACD,CAAC;AAED,SAAK,GAAG,SAAS,MAAK;AACrB,WAAK,MAAM;QACV,EAAE,MAAM,QAAQ,MAAM,MAAK;QAC3B,EAAE,MAAM,QAAQ,MAAM,MAAK;QAC3B,EAAE,MAAM,QAAQ,MAAM,MAAK;OAC3B;IACF,CAAC;AAED,SAAK,GAAG,SAAS,MAAM;AAEvB,SAAK,WAAU;AAEf,QAAI,OAAO,YAAY,YAAY,UAAU,GAAG;AAC/C,cAAQ,WAAW,MAAK;AACvB,aAAK,QAAO;AACZ,gBAAQ,MAAS;MAClB,GAAG,OAAO;IACX;EACD,CAAC;AACF;AAzFsB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,3 @@
1
+ import type { RemoteSerialPort } from "../mDNSDiscovery.js";
2
+ export declare function discoverRemoteSerialPorts(_timeout?: number | false): Promise<RemoteSerialPort[] | undefined>;
3
+ //# sourceMappingURL=stub.d.ts.map
@@ -0,0 +1,33 @@
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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var stub_exports = {};
21
+ __export(stub_exports, {
22
+ discoverRemoteSerialPorts: () => discoverRemoteSerialPorts
23
+ });
24
+ module.exports = __toCommonJS(stub_exports);
25
+ function discoverRemoteSerialPorts(_timeout = 1e3) {
26
+ return Promise.resolve([]);
27
+ }
28
+ __name(discoverRemoteSerialPorts, "discoverRemoteSerialPorts");
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ discoverRemoteSerialPorts
32
+ });
33
+ //# sourceMappingURL=stub.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/lib/driver/mDNSDiscovery/stub.ts"],
4
+ "sourcesContent": ["import type { RemoteSerialPort } from \"../mDNSDiscovery.js\";\n\n// On other platforns than Node.js, we cannot use mDNS discovery\nexport function discoverRemoteSerialPorts(\n\t_timeout: number | false = 1000,\n): Promise<RemoteSerialPort[] | undefined> {\n\treturn Promise.resolve([]);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAEA;;;;;AACM,SAAU,0BACf,WAA2B,KAAI;AAE/B,SAAO,QAAQ,QAAQ,CAAA,CAAE;AAC1B;AAJgB;",
6
+ "names": []
7
+ }
@@ -1,6 +1,6 @@
1
+ export { discoverRemoteSerialPorts } from "#mdns_discovery";
1
2
  export interface RemoteSerialPort {
2
3
  port: string;
3
4
  info: Record<string, string>;
4
5
  }
5
- export declare function discoverRemoteSerialPorts(timeout?: number | false): Promise<RemoteSerialPort[] | undefined>;
6
6
  //# sourceMappingURL=mDNSDiscovery.d.ts.map
@@ -1,11 +1,8 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
6
  var __export = (target, all) => {
10
7
  for (var name in all)
11
8
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -18,78 +15,13 @@ var __copyProps = (to, from, except, desc) => {
18
15
  }
19
16
  return to;
20
17
  };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
19
  var mDNSDiscovery_exports = {};
31
20
  __export(mDNSDiscovery_exports, {
32
- discoverRemoteSerialPorts: () => discoverRemoteSerialPorts
21
+ discoverRemoteSerialPorts: () => import_mdns_discovery.discoverRemoteSerialPorts
33
22
  });
34
23
  module.exports = __toCommonJS(mDNSDiscovery_exports);
35
- var import_shared = require("@zwave-js/shared");
36
- var import_typeguards = require("alcalzone-shared/typeguards");
37
- var import_mdns_server = __toESM(require("mdns-server"), 1);
38
- const domain = "_zwave._tcp.local";
39
- function discoverRemoteSerialPorts(timeout = 1e3) {
40
- const mdns = (0, import_mdns_server.default)({
41
- reuseAddr: true,
42
- loopback: false,
43
- noInit: true,
44
- ttl: 10
45
- });
46
- let timer;
47
- return new Promise((resolve, reject) => {
48
- mdns.on("response", (resp) => {
49
- const matches = resp.answers.filter((n) => n.type === "PTR" && n.name === domain && typeof n.data === "string").map(({ data }) => {
50
- return {
51
- txt: resp.answers.find((n) => n.type === "TXT" && n.name === data) ?? resp.additionals.find((n) => n.type === "TXT" && n.name === data),
52
- srv: resp.answers.find((n) => n.type === "SRV" && n.name === data) ?? resp.additionals.find((n) => n.type === "SRV" && n.name === data)
53
- };
54
- }).filter(({ srv }) => !!srv && (0, import_typeguards.isObject)(srv.data) && typeof srv.data.target === "string" && typeof srv.data.port === "number").map(({ txt, srv }) => {
55
- const info = {};
56
- if (!!txt && (0, import_typeguards.isArray)(txt.data)) {
57
- const strings = txt.data.filter((d) => (0, import_shared.isUint8Array)(d)).map((d) => import_shared.Bytes.view(d).toString("utf8")).filter((d) => d.includes("="));
58
- for (const string of strings) {
59
- const [key, value] = string.split("=", 2);
60
- info[key] = value;
61
- }
62
- }
63
- const addr = srv.data;
64
- const port = `tcp://${addr.target}:${addr.port}`;
65
- return {
66
- port,
67
- info
68
- };
69
- });
70
- if (matches.length) {
71
- clearTimeout(timer);
72
- resolve(matches);
73
- }
74
- });
75
- mdns.on("ready", () => {
76
- mdns.query([
77
- { name: domain, type: "PTR" },
78
- { name: domain, type: "SRV" },
79
- { name: domain, type: "TXT" }
80
- ]);
81
- });
82
- mdns.on("error", reject);
83
- mdns.initServer();
84
- if (typeof timeout === "number" && timeout > 0) {
85
- timer = setTimeout(() => {
86
- mdns.destroy();
87
- resolve(void 0);
88
- }, timeout);
89
- }
90
- });
91
- }
92
- __name(discoverRemoteSerialPorts, "discoverRemoteSerialPorts");
24
+ var import_mdns_discovery = require("#mdns_discovery");
93
25
  // Annotate the CommonJS export names for ESM import in node:
94
26
  0 && (module.exports = {
95
27
  discoverRemoteSerialPorts
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/driver/mDNSDiscovery.ts"],
4
- "sourcesContent": ["import { Bytes, isUint8Array } from \"@zwave-js/shared\";\nimport { isArray, isObject } from \"alcalzone-shared/typeguards\";\nimport createMDNSServer from \"mdns-server\";\n\nexport interface RemoteSerialPort {\n\tport: string;\n\tinfo: Record<string, string>;\n}\n\nconst domain = \"_zwave._tcp.local\";\n\nexport function discoverRemoteSerialPorts(\n\ttimeout: number | false = 1000,\n): Promise<RemoteSerialPort[] | undefined> {\n\tconst mdns = createMDNSServer({\n\t\treuseAddr: true,\n\t\tloopback: false,\n\t\tnoInit: true,\n\t\tttl: 10,\n\t});\n\tlet timer: NodeJS.Timeout | undefined;\n\n\treturn new Promise((resolve, reject) => {\n\t\tmdns.on(\"response\", (resp) => {\n\t\t\tconst matches = resp.answers\n\t\t\t\t.filter(\n\t\t\t\t\t(n) =>\n\t\t\t\t\t\tn.type === \"PTR\"\n\t\t\t\t\t\t&& n.name === domain\n\t\t\t\t\t\t&& typeof n.data === \"string\",\n\t\t\t\t)\n\t\t\t\t.map(({ data }) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttxt: resp.answers.find(\n\t\t\t\t\t\t\t(n) => n.type === \"TXT\" && n.name === data,\n\t\t\t\t\t\t) ?? resp.additionals.find(\n\t\t\t\t\t\t\t(n) => n.type === \"TXT\" && n.name === data,\n\t\t\t\t\t\t),\n\t\t\t\t\t\tsrv: resp.answers.find(\n\t\t\t\t\t\t\t(n) => n.type === \"SRV\" && n.name === data,\n\t\t\t\t\t\t) ?? resp.additionals.find(\n\t\t\t\t\t\t\t(n) => n.type === \"SRV\" && n.name === data,\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t})\n\t\t\t\t.filter(\n\t\t\t\t\t({ srv }) =>\n\t\t\t\t\t\t!!srv\n\t\t\t\t\t\t&& isObject(srv.data)\n\t\t\t\t\t\t&& typeof srv.data.target === \"string\"\n\t\t\t\t\t\t&& typeof srv.data.port === \"number\",\n\t\t\t\t)\n\t\t\t\t.map(({ txt, srv }) => {\n\t\t\t\t\tconst info: Record<string, string> = {};\n\t\t\t\t\tif (!!txt && isArray(txt.data)) {\n\t\t\t\t\t\tconst strings = (txt.data as unknown[])\n\t\t\t\t\t\t\t.filter((d) => isUint8Array(d))\n\t\t\t\t\t\t\t.map((d) => Bytes.view(d).toString(\"utf8\"))\n\t\t\t\t\t\t\t.filter((d) => d.includes(\"=\"));\n\n\t\t\t\t\t\tfor (const string of strings) {\n\t\t\t\t\t\t\tconst [key, value] = string.split(\"=\", 2);\n\t\t\t\t\t\t\tinfo[key] = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tconst addr = srv!.data as { target: string; port: number };\n\t\t\t\t\tconst port = `tcp://${addr.target}:${addr.port}`;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tport,\n\t\t\t\t\t\tinfo,\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\tif (matches.length) {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\tresolve(matches);\n\t\t\t}\n\t\t});\n\n\t\tmdns.on(\"ready\", () => {\n\t\t\tmdns.query([\n\t\t\t\t{ name: domain, type: \"PTR\" },\n\t\t\t\t{ name: domain, type: \"SRV\" },\n\t\t\t\t{ name: domain, type: \"TXT\" },\n\t\t\t]);\n\t\t});\n\n\t\tmdns.on(\"error\", reject);\n\n\t\tmdns.initServer();\n\n\t\tif (typeof timeout === \"number\" && timeout > 0) {\n\t\t\ttimer = setTimeout(() => {\n\t\t\t\tmdns.destroy();\n\t\t\t\tresolve(undefined);\n\t\t\t}, timeout);\n\t\t}\n\t});\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;AAAA,oBAAoC;AACpC,wBAAkC;AAClC,yBAA6B;AAO7B,MAAM,SAAS;AAET,SAAU,0BACf,UAA0B,KAAI;AAE9B,QAAM,WAAO,mBAAAA,SAAiB;IAC7B,WAAW;IACX,UAAU;IACV,QAAQ;IACR,KAAK;GACL;AACD,MAAI;AAEJ,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAU;AACtC,SAAK,GAAG,YAAY,CAAC,SAAQ;AAC5B,YAAM,UAAU,KAAK,QACnB,OACA,CAAC,MACA,EAAE,SAAS,SACR,EAAE,SAAS,UACX,OAAO,EAAE,SAAS,QAAQ,EAE9B,IAAI,CAAC,EAAE,KAAI,MAAM;AACjB,eAAO;UACN,KAAK,KAAK,QAAQ,KACjB,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,SAAS,IAAI,KACtC,KAAK,YAAY,KACrB,CAAC,MAAM,EAAE,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;AAC/C,cAAQ,WAAW,MAAK;AACvB,aAAK,QAAO;AACZ,gBAAQ,MAAS;MAClB,GAAG,OAAO;IACX;EACD,CAAC;AACF;AAxFgB;",
6
- "names": ["createMDNSServer"]
4
+ "sourcesContent": ["export { discoverRemoteSerialPorts } from \"#mdns_discovery\";\n\nexport interface RemoteSerialPort {\n\tport: string;\n\tinfo: Record<string, string>;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;;;;;AAAA,4BAA0C;",
6
+ "names": []
7
7
  }
@@ -183,9 +183,9 @@ class Zniffer extends import_shared.TypedEventTarget {
183
183
  throw new import_core.ZWaveError("The Zniffer was destroyed. Create a new instance and initialize that one.", import_core.ZWaveErrorCodes.Driver_Destroyed);
184
184
  }
185
185
  this.bindings = {
186
- fs: this._options.host?.fs ?? (await import("@zwave-js/core/bindings/fs/node")).fs,
187
- serial: this._options.host?.serial ?? (await import("@zwave-js/serial/bindings/node")).serial,
188
- log: this._options.host?.log ?? (await import("@zwave-js/core/bindings/log/node")).log
186
+ fs: this._options.host?.fs ?? (await import("#default_bindings/fs")).fs,
187
+ serial: this._options.host?.serial ?? (await import("#default_bindings/serial")).serial,
188
+ log: this._options.host?.log ?? (await import("#default_bindings/log")).log
189
189
  };
190
190
  this._logContainer = this.bindings.log(this._options.logConfig);
191
191
  this.znifferLog = new import_Zniffer.ZnifferLogger(this, this._logContainer);