@zwave-js/config 14.3.10 → 15.0.0-beta.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 (76) hide show
  1. package/build/cjs/ConfigManager.d.ts +9 -3
  2. package/build/cjs/ConfigManager.js +42 -20
  3. package/build/cjs/ConfigManager.js.map +2 -2
  4. package/build/cjs/JsonTemplate.d.ts +2 -1
  5. package/build/cjs/JsonTemplate.js +16 -17
  6. package/build/cjs/JsonTemplate.js.map +3 -3
  7. package/build/cjs/Logger.d.ts +2 -2
  8. package/build/cjs/Logger.js.map +2 -2
  9. package/build/cjs/Manufacturers.d.ts +2 -1
  10. package/build/cjs/Manufacturers.js +8 -9
  11. package/build/cjs/Manufacturers.js.map +3 -3
  12. package/build/cjs/_version.d.ts +1 -1
  13. package/build/cjs/_version.js +1 -1
  14. package/build/cjs/_version.js.map +1 -1
  15. package/build/cjs/devices/DeviceConfig.d.ts +3 -2
  16. package/build/cjs/devices/DeviceConfig.js +34 -35
  17. package/build/cjs/devices/DeviceConfig.js.map +3 -3
  18. package/build/cjs/index.d.ts +1 -0
  19. package/build/cjs/index.js.map +1 -1
  20. package/build/cjs/index_safe.d.ts +1 -0
  21. package/build/cjs/index_safe.js.map +1 -1
  22. package/build/cjs/traits.d.ts +11 -0
  23. package/build/cjs/traits.js +17 -0
  24. package/build/cjs/traits.js.map +7 -0
  25. package/build/cjs/utils.d.ts +2 -1
  26. package/build/cjs/utils.js +13 -14
  27. package/build/cjs/utils.js.map +3 -3
  28. package/build/esm/ConfigManager.d.ts +9 -3
  29. package/build/esm/ConfigManager.d.ts.map +1 -1
  30. package/build/esm/ConfigManager.js +42 -19
  31. package/build/esm/ConfigManager.js.map +1 -1
  32. package/build/esm/JsonTemplate.d.ts +2 -1
  33. package/build/esm/JsonTemplate.d.ts.map +1 -1
  34. package/build/esm/JsonTemplate.js +13 -14
  35. package/build/esm/JsonTemplate.js.map +1 -1
  36. package/build/esm/Logger.d.ts +2 -2
  37. package/build/esm/Logger.d.ts.map +1 -1
  38. package/build/esm/Logger.js.map +1 -1
  39. package/build/esm/Manufacturers.d.ts +2 -1
  40. package/build/esm/Manufacturers.d.ts.map +1 -1
  41. package/build/esm/Manufacturers.js +7 -8
  42. package/build/esm/Manufacturers.js.map +1 -1
  43. package/build/esm/_version.d.ts +1 -1
  44. package/build/esm/_version.d.ts.map +1 -1
  45. package/build/esm/_version.js +1 -1
  46. package/build/esm/_version.js.map +1 -1
  47. package/build/esm/devices/DeviceConfig.d.ts +3 -2
  48. package/build/esm/devices/DeviceConfig.d.ts.map +1 -1
  49. package/build/esm/devices/DeviceConfig.js +25 -26
  50. package/build/esm/devices/DeviceConfig.js.map +1 -1
  51. package/build/esm/index.d.ts +1 -0
  52. package/build/esm/index.d.ts.map +1 -1
  53. package/build/esm/index_safe.d.ts +1 -0
  54. package/build/esm/index_safe.d.ts.map +1 -1
  55. package/build/esm/traits.d.ts +11 -0
  56. package/build/esm/traits.d.ts.map +1 -0
  57. package/build/esm/traits.js +2 -0
  58. package/build/esm/traits.js.map +1 -0
  59. package/build/esm/utils.d.ts +2 -1
  60. package/build/esm/utils.d.ts.map +1 -1
  61. package/build/esm/utils.js +16 -14
  62. package/build/esm/utils.js.map +1 -1
  63. package/config/README.md +1 -1
  64. package/config/devices/0x0005/pe653.json +1 -1
  65. package/config/devices/0x003b/be469zp.json +1 -1
  66. package/config/devices/0x0090/hc620.json +1 -1
  67. package/config/devices/0x0098/ct100.json +2 -2
  68. package/config/devices/0x0098/ct101.json +1 -1
  69. package/config/devices/0x0098/ct200x.json +1 -1
  70. package/config/devices/0x0287/iblindsv3.json +1 -1
  71. package/config/devices/0x031e/vzw31-sn.json +1 -1
  72. package/config/devices/0x0344/he-zw-therm-fl2.json +1 -1
  73. package/config/devices/0x0441/ibt4zwave.json +1 -1
  74. package/config/devices/0x045a/Z-CM-V01.json +1 -1
  75. package/config/devices/templates/master_template.json +1 -1
  76. package/package.json +15 -16
@@ -43,8 +43,7 @@ var import_core2 = require("@zwave-js/core");
43
43
  var import_shared = require("@zwave-js/shared");
44
44
  var import_typeguards = require("alcalzone-shared/typeguards");
45
45
  var import_json5 = __toESM(require("json5"), 1);
46
- var import_promises = __toESM(require("node:fs/promises"), 1);
47
- var import_node_path = __toESM(require("node:path"), 1);
46
+ var import_pathe = __toESM(require("pathe"), 1);
48
47
  var import_gt = __toESM(require("semver/functions/gt.js"), 1);
49
48
  var import_JsonTemplate = require("../JsonTemplate.js");
50
49
  var import_utils = require("../utils.js");
@@ -56,23 +55,23 @@ var import_ConditionalPrimitive = require("./ConditionalPrimitive.js");
56
55
  var import_DeviceMetadata = require("./DeviceMetadata.js");
57
56
  var import_EndpointConfig = require("./EndpointConfig.js");
58
57
  var import_ParamInformation = require("./ParamInformation.js");
59
- const embeddedDevicesDir = import_node_path.default.join(import_utils.configDir, "devices");
60
- const fulltextIndexPath = import_node_path.default.join(embeddedDevicesDir, "fulltext_index.json");
58
+ const embeddedDevicesDir = import_pathe.default.join(import_utils.configDir, "devices");
59
+ const fulltextIndexPath = import_pathe.default.join(embeddedDevicesDir, "fulltext_index.json");
61
60
  function getDevicesPaths(configDir2) {
62
- const devicesDir = import_node_path.default.join(configDir2, "devices");
63
- const indexPath = import_node_path.default.join(devicesDir, "index.json");
61
+ const devicesDir = import_pathe.default.join(configDir2, "devices");
62
+ const indexPath = import_pathe.default.join(devicesDir, "index.json");
64
63
  return { devicesDir, indexPath };
65
64
  }
66
65
  __name(getDevicesPaths, "getDevicesPaths");
67
- async function hasChangedDeviceFiles(devicesRoot, dir, lastChange) {
68
- const filesAndDirs = await import_promises.default.readdir(dir);
66
+ async function hasChangedDeviceFiles(fs, devicesRoot, dir, lastChange) {
67
+ const filesAndDirs = await fs.readDir(dir);
69
68
  for (const f of filesAndDirs) {
70
- const fullPath = import_node_path.default.join(dir, f);
71
- const stat = await import_promises.default.stat(fullPath);
69
+ const fullPath = import_pathe.default.join(dir, f);
70
+ const stat = await fs.stat(fullPath);
72
71
  if ((dir !== devicesRoot || f !== "index.json") && (stat.isFile() || stat.isDirectory()) && stat.mtime > lastChange) {
73
72
  return true;
74
73
  } else if (stat.isDirectory()) {
75
- if (await hasChangedDeviceFiles(devicesRoot, fullPath, lastChange)) {
74
+ if (await hasChangedDeviceFiles(fs, devicesRoot, fullPath, lastChange)) {
76
75
  return true;
77
76
  }
78
77
  }
@@ -80,15 +79,15 @@ async function hasChangedDeviceFiles(devicesRoot, dir, lastChange) {
80
79
  return false;
81
80
  }
82
81
  __name(hasChangedDeviceFiles, "hasChangedDeviceFiles");
83
- async function generateIndex(devicesDir, isEmbedded, extractIndexEntries, logger) {
82
+ async function generateIndex(fs, devicesDir, isEmbedded, extractIndexEntries, logger) {
84
83
  const index = [];
85
84
  (0, import_JsonTemplate.clearTemplateCache)();
86
- const configFiles = await (0, import_shared.enumFilesRecursive)(devicesDir, (file) => file.endsWith(".json") && !file.endsWith("index.json") && !file.includes("/templates/") && !file.includes("\\templates\\"));
85
+ const configFiles = await (0, import_shared.enumFilesRecursive)(fs, devicesDir, (file) => file.endsWith(".json") && !file.endsWith("index.json") && !file.includes("/templates/") && !file.includes("\\templates\\"));
87
86
  const fallbackDirs = devicesDir !== embeddedDevicesDir ? [embeddedDevicesDir] : void 0;
88
87
  for (const file of configFiles) {
89
- const relativePath = import_node_path.default.relative(devicesDir, file).replaceAll("\\", "/");
88
+ const relativePath = import_pathe.default.relative(devicesDir, file).replaceAll("\\", "/");
90
89
  try {
91
- const config = await DeviceConfig.from(file, isEmbedded, {
90
+ const config = await DeviceConfig.from(fs, file, isEmbedded, {
92
91
  rootDir: devicesDir,
93
92
  fallbackDirs,
94
93
  relative: true
@@ -105,7 +104,7 @@ async function generateIndex(devicesDir, isEmbedded, extractIndexEntries, logger
105
104
  }));
106
105
  } catch (e) {
107
106
  const message = `Error parsing config file ${relativePath}: ${e.message}`;
108
- if (process.env.NODE_ENV === "test" || !!process.env.CI) {
107
+ if (process.env.NODE_ENV === "test" || !!(0, import_shared.getenv)("CI")) {
109
108
  throw new import_core.ZWaveError(message, import_core.ZWaveErrorCodes.Config_Invalid);
110
109
  } else {
111
110
  logger?.print(message, "error");
@@ -115,15 +114,15 @@ async function generateIndex(devicesDir, isEmbedded, extractIndexEntries, logger
115
114
  return index;
116
115
  }
117
116
  __name(generateIndex, "generateIndex");
118
- async function loadDeviceIndexShared(devicesDir, indexPath, extractIndexEntries, logger) {
119
- let needsUpdate = !await (0, import_shared.pathExists)(indexPath);
117
+ async function loadDeviceIndexShared(fs, devicesDir, indexPath, extractIndexEntries, logger) {
118
+ let needsUpdate = !await (0, import_shared.pathExists)(fs, indexPath);
120
119
  let index;
121
120
  let mtimeIndex;
122
121
  if (!needsUpdate) {
123
122
  try {
124
- const fileContents = await import_promises.default.readFile(indexPath, "utf8");
123
+ const fileContents = await (0, import_shared.readTextFile)(fs, indexPath, "utf8");
125
124
  index = import_json5.default.parse(fileContents);
126
- mtimeIndex = (await import_promises.default.stat(indexPath)).mtime;
125
+ mtimeIndex = (await fs.stat(indexPath)).mtime;
127
126
  } catch {
128
127
  logger?.print("Error while parsing index file - regenerating...", "warn");
129
128
  needsUpdate = true;
@@ -135,15 +134,15 @@ async function loadDeviceIndexShared(devicesDir, indexPath, extractIndexEntries,
135
134
  }
136
135
  }
137
136
  if (!needsUpdate) {
138
- needsUpdate = await hasChangedDeviceFiles(devicesDir, devicesDir, mtimeIndex);
137
+ needsUpdate = await hasChangedDeviceFiles(fs, devicesDir, devicesDir, mtimeIndex);
139
138
  if (needsUpdate) {
140
139
  logger?.print("Device configuration files on disk changed - regenerating index...", "verbose");
141
140
  }
142
141
  }
143
142
  if (needsUpdate) {
144
- index = await generateIndex(devicesDir, true, extractIndexEntries, logger);
143
+ index = await generateIndex(fs, devicesDir, true, extractIndexEntries, logger);
145
144
  try {
146
- await import_promises.default.writeFile(import_node_path.default.join(indexPath), `// This file is auto-generated. DO NOT edit it by hand if you don't know what you're doing!"
145
+ await (0, import_shared.writeTextFile)(fs, import_pathe.default.join(indexPath), `// This file is auto-generated. DO NOT edit it by hand if you don't know what you're doing!"
147
146
  ${(0, import_shared.stringify)(index, " ")}
148
147
  `, "utf8");
149
148
  logger?.print("Device index regenerated", "verbose");
@@ -154,8 +153,8 @@ ${(0, import_shared.stringify)(index, " ")}
154
153
  return index;
155
154
  }
156
155
  __name(loadDeviceIndexShared, "loadDeviceIndexShared");
157
- async function generatePriorityDeviceIndex(deviceConfigPriorityDir, logger) {
158
- return (await generateIndex(deviceConfigPriorityDir, false, (config) => config.devices.map((dev) => ({
156
+ async function generatePriorityDeviceIndex(fs, deviceConfigPriorityDir, logger) {
157
+ return (await generateIndex(fs, deviceConfigPriorityDir, false, (config) => config.devices.map((dev) => ({
159
158
  manufacturerId: (0, import_shared.formatId)(config.manufacturerId.toString(16)),
160
159
  manufacturer: config.manufacturer,
161
160
  label: config.label,
@@ -168,13 +167,13 @@ async function generatePriorityDeviceIndex(deviceConfigPriorityDir, logger) {
168
167
  ...entry,
169
168
  // The generated index makes the filenames relative to the given directory
170
169
  // but we need them to be absolute
171
- filename: import_node_path.default.join(deviceConfigPriorityDir, filename)
170
+ filename: import_pathe.default.join(deviceConfigPriorityDir, filename)
172
171
  }));
173
172
  }
174
173
  __name(generatePriorityDeviceIndex, "generatePriorityDeviceIndex");
175
- async function loadDeviceIndexInternal(logger, externalConfigDir) {
174
+ async function loadDeviceIndexInternal(fs, logger, externalConfigDir) {
176
175
  const { devicesDir, indexPath } = getDevicesPaths(externalConfigDir || import_utils.configDir);
177
- return loadDeviceIndexShared(devicesDir, indexPath, (config) => config.devices.map((dev) => ({
176
+ return loadDeviceIndexShared(fs, devicesDir, indexPath, (config) => config.devices.map((dev) => ({
178
177
  manufacturerId: (0, import_shared.formatId)(config.manufacturerId.toString(16)),
179
178
  manufacturer: config.manufacturer,
180
179
  label: config.label,
@@ -185,8 +184,8 @@ async function loadDeviceIndexInternal(logger, externalConfigDir) {
185
184
  })), logger);
186
185
  }
187
186
  __name(loadDeviceIndexInternal, "loadDeviceIndexInternal");
188
- async function loadFulltextDeviceIndexInternal(logger) {
189
- return loadDeviceIndexShared(embeddedDevicesDir, fulltextIndexPath, (config) => config.devices.map((dev) => ({
187
+ async function loadFulltextDeviceIndexInternal(fs, logger) {
188
+ return loadDeviceIndexShared(fs, embeddedDevicesDir, fulltextIndexPath, (config) => config.devices.map((dev) => ({
190
189
  manufacturerId: (0, import_shared.formatId)(config.manufacturerId.toString(16)),
191
190
  manufacturer: config.manufacturer,
192
191
  label: config.label,
@@ -212,10 +211,10 @@ class ConditionalDeviceConfig {
212
211
  static {
213
212
  __name(this, "ConditionalDeviceConfig");
214
213
  }
215
- static async from(filename, isEmbedded, options) {
214
+ static async from(fs, filename, isEmbedded, options) {
216
215
  const { relative, rootDir } = options;
217
- const relativePath = relative ? import_node_path.default.relative(rootDir, filename).replaceAll("\\", "/") : filename;
218
- const json = await (0, import_JsonTemplate.readJsonWithTemplate)(filename, [
216
+ const relativePath = relative ? import_pathe.default.relative(rootDir, filename).replaceAll("\\", "/") : filename;
217
+ const json = await (0, import_JsonTemplate.readJsonWithTemplate)(fs, filename, [
219
218
  options.rootDir,
220
219
  ...options.fallbackDirs ?? []
221
220
  ]);
@@ -350,8 +349,8 @@ class DeviceConfig {
350
349
  static {
351
350
  __name(this, "DeviceConfig");
352
351
  }
353
- static async from(filename, isEmbedded, options) {
354
- const ret = await ConditionalDeviceConfig.from(filename, isEmbedded, options);
352
+ static async from(fs, filename, isEmbedded, options) {
353
+ const ret = await ConditionalDeviceConfig.from(fs, filename, isEmbedded, options);
355
354
  return ret.evaluate(options.deviceId);
356
355
  }
357
356
  constructor(filename, isEmbedded, manufacturer, manufacturerId, label, description, devices, firmwareVersion, preferred, endpoints, associations, paramInformation, proprietary, compat, metadata) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/devices/DeviceConfig.ts"],
4
- "sourcesContent": ["import { ZWaveError, ZWaveErrorCodes } from \"@zwave-js/core\";\nimport { digest } from \"@zwave-js/core\";\nimport {\n\tBytes,\n\ttype JSONObject,\n\tenumFilesRecursive,\n\tformatId,\n\tnum2hex,\n\tpadVersion,\n\tpathExists,\n\tpick,\n\tstringify,\n} from \"@zwave-js/shared\";\nimport { isArray, isObject } from \"alcalzone-shared/typeguards\";\nimport JSON5 from \"json5\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport semverGt from \"semver/functions/gt.js\";\nimport { clearTemplateCache, readJsonWithTemplate } from \"../JsonTemplate.js\";\nimport type { ConfigLogger } from \"../Logger.js\";\nimport { configDir } from \"../utils.js\";\nimport { hexKeyRegex4Digits, throwInvalidConfig } from \"../utils_safe.js\";\nimport {\n\ttype AssociationConfig,\n\tConditionalAssociationConfig,\n} from \"./AssociationConfig.js\";\nimport { type CompatConfig, ConditionalCompatConfig } from \"./CompatConfig.js\";\nimport { evaluateDeep, validateCondition } from \"./ConditionalItem.js\";\nimport {\n\ttype ConditionalPrimitive,\n\tparseConditionalPrimitive,\n} from \"./ConditionalPrimitive.js\";\nimport {\n\tConditionalDeviceMetadata,\n\ttype DeviceMetadata,\n} from \"./DeviceMetadata.js\";\nimport {\n\tConditionalEndpointConfig,\n\ttype EndpointConfig,\n} from \"./EndpointConfig.js\";\nimport {\n\ttype ConditionalParamInfoMap,\n\ttype ParamInfoMap,\n\ttype ParamInformation,\n\tparseConditionalParamInformationMap,\n} from \"./ParamInformation.js\";\nimport type { DeviceID, FirmwareVersionRange } from \"./shared.js\";\n\nexport interface DeviceConfigIndexEntry {\n\tmanufacturerId: string;\n\tproductType: string;\n\tproductId: string;\n\tfirmwareVersion: FirmwareVersionRange;\n\tpreferred?: true;\n\trootDir?: string;\n\tfilename: string;\n}\n\nexport interface FulltextDeviceConfigIndexEntry {\n\tmanufacturerId: string;\n\tmanufacturer: string;\n\tlabel: string;\n\tdescription: string;\n\tproductType: string;\n\tproductId: string;\n\tfirmwareVersion: FirmwareVersionRange;\n\tpreferred?: true;\n\trootDir?: string;\n\tfilename: string;\n}\n\nexport const embeddedDevicesDir = path.join(configDir, \"devices\");\nconst fulltextIndexPath = path.join(embeddedDevicesDir, \"fulltext_index.json\");\n\nexport function getDevicesPaths(configDir: string): {\n\tdevicesDir: string;\n\tindexPath: string;\n} {\n\tconst devicesDir = path.join(configDir, \"devices\");\n\tconst indexPath = path.join(devicesDir, \"index.json\");\n\treturn { devicesDir, indexPath };\n}\n\nexport type DeviceConfigIndex = DeviceConfigIndexEntry[];\nexport type FulltextDeviceConfigIndex = FulltextDeviceConfigIndexEntry[];\n\nasync function hasChangedDeviceFiles(\n\tdevicesRoot: string,\n\tdir: string,\n\tlastChange: Date,\n): Promise<boolean> {\n\t// Check if there are any files BUT index.json that were changed\n\t// or directories that were modified\n\tconst filesAndDirs = await fs.readdir(dir);\n\tfor (const f of filesAndDirs) {\n\t\tconst fullPath = path.join(dir, f);\n\n\t\tconst stat = await fs.stat(fullPath);\n\t\tif (\n\t\t\t(dir !== devicesRoot || f !== \"index.json\")\n\t\t\t&& (stat.isFile() || stat.isDirectory())\n\t\t\t&& stat.mtime > lastChange\n\t\t) {\n\t\t\treturn true;\n\t\t} else if (stat.isDirectory()) {\n\t\t\t// we need to go deeper!\n\t\t\tif (\n\t\t\t\tawait hasChangedDeviceFiles(devicesRoot, fullPath, lastChange)\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n * Read all device config files from a given directory and return them as index entries.\n * Does not update the index itself.\n */\nasync function generateIndex<T extends Record<string, unknown>>(\n\tdevicesDir: string,\n\tisEmbedded: boolean,\n\textractIndexEntries: (config: DeviceConfig) => T[],\n\tlogger?: ConfigLogger,\n): Promise<(T & { filename: string; rootDir?: string })[]> {\n\tconst index: (T & { filename: string; rootDir?: string })[] = [];\n\n\tclearTemplateCache();\n\tconst configFiles = await enumFilesRecursive(\n\t\tdevicesDir,\n\t\t(file) =>\n\t\t\tfile.endsWith(\".json\")\n\t\t\t&& !file.endsWith(\"index.json\")\n\t\t\t&& !file.includes(\"/templates/\")\n\t\t\t&& !file.includes(\"\\\\templates\\\\\"),\n\t);\n\n\t// Add the embedded devices dir as a fallback if necessary\n\tconst fallbackDirs = devicesDir !== embeddedDevicesDir\n\t\t? [embeddedDevicesDir]\n\t\t: undefined;\n\n\tfor (const file of configFiles) {\n\t\tconst relativePath = path\n\t\t\t.relative(devicesDir, file)\n\t\t\t.replaceAll(\"\\\\\", \"/\");\n\t\t// Try parsing the file\n\t\ttry {\n\t\t\tconst config = await DeviceConfig.from(file, isEmbedded, {\n\t\t\t\trootDir: devicesDir,\n\t\t\t\tfallbackDirs,\n\t\t\t\trelative: true,\n\t\t\t});\n\t\t\t// Add the file to the index\n\t\t\tindex.push(\n\t\t\t\t...extractIndexEntries(config).map((entry) => {\n\t\t\t\t\tconst ret: T & { filename: string; rootDir?: string } = {\n\t\t\t\t\t\t...entry,\n\t\t\t\t\t\tfilename: relativePath,\n\t\t\t\t\t};\n\t\t\t\t\t// Only add the root dir to the index if necessary\n\t\t\t\t\tif (devicesDir !== embeddedDevicesDir) {\n\t\t\t\t\t\tret.rootDir = devicesDir;\n\t\t\t\t\t}\n\t\t\t\t\treturn ret;\n\t\t\t\t}),\n\t\t\t);\n\t\t} catch (e) {\n\t\t\tconst message = `Error parsing config file ${relativePath}: ${\n\t\t\t\t(e as Error).message\n\t\t\t}`;\n\t\t\t// Crash hard during tests, just print an error when in production systems.\n\t\t\t// A user could have changed a config file\n\t\t\tif (process.env.NODE_ENV === \"test\" || !!process.env.CI) {\n\t\t\t\tthrow new ZWaveError(message, ZWaveErrorCodes.Config_Invalid);\n\t\t\t} else {\n\t\t\t\tlogger?.print(message, \"error\");\n\t\t\t}\n\t\t}\n\t}\n\n\treturn index;\n}\n\nasync function loadDeviceIndexShared<T extends Record<string, unknown>>(\n\tdevicesDir: string,\n\tindexPath: string,\n\textractIndexEntries: (config: DeviceConfig) => T[],\n\tlogger?: ConfigLogger,\n): Promise<(T & { filename: string })[]> {\n\t// The index file needs to be regenerated if it does not exist\n\tlet needsUpdate = !(await pathExists(indexPath));\n\tlet index: (T & { filename: string })[] | undefined;\n\tlet mtimeIndex: Date | undefined;\n\t// ...or if cannot be parsed\n\tif (!needsUpdate) {\n\t\ttry {\n\t\t\tconst fileContents = await fs.readFile(indexPath, \"utf8\");\n\t\t\tindex = JSON5.parse(fileContents);\n\t\t\tmtimeIndex = (await fs.stat(indexPath)).mtime;\n\t\t} catch {\n\t\t\tlogger?.print(\n\t\t\t\t\"Error while parsing index file - regenerating...\",\n\t\t\t\t\"warn\",\n\t\t\t);\n\t\t\tneedsUpdate = true;\n\t\t} finally {\n\t\t\tif (!index) {\n\t\t\t\tlogger?.print(\n\t\t\t\t\t\"Index file was malformed - regenerating...\",\n\t\t\t\t\t\"warn\",\n\t\t\t\t);\n\t\t\t\tneedsUpdate = true;\n\t\t\t}\n\t\t}\n\t}\n\n\t// ...or if there were any changes in the file system\n\tif (!needsUpdate) {\n\t\tneedsUpdate = await hasChangedDeviceFiles(\n\t\t\tdevicesDir,\n\t\t\tdevicesDir,\n\t\t\tmtimeIndex!,\n\t\t);\n\t\tif (needsUpdate) {\n\t\t\tlogger?.print(\n\t\t\t\t\"Device configuration files on disk changed - regenerating index...\",\n\t\t\t\t\"verbose\",\n\t\t\t);\n\t\t}\n\t}\n\n\tif (needsUpdate) {\n\t\t// Read all files from disk and generate an index\n\t\tindex = await generateIndex(\n\t\t\tdevicesDir,\n\t\t\ttrue,\n\t\t\textractIndexEntries,\n\t\t\tlogger,\n\t\t);\n\t\t// Save the index to disk\n\t\ttry {\n\t\t\tawait fs.writeFile(\n\t\t\t\tpath.join(indexPath),\n\t\t\t\t`// This file is auto-generated. DO NOT edit it by hand if you don't know what you're doing!\"\n${stringify(index, \"\\t\")}\n`,\n\t\t\t\t\"utf8\",\n\t\t\t);\n\t\t\tlogger?.print(\"Device index regenerated\", \"verbose\");\n\t\t} catch (e) {\n\t\t\tlogger?.print(\n\t\t\t\t`Writing the device index to disk failed: ${\n\t\t\t\t\t(e as Error).message\n\t\t\t\t}`,\n\t\t\t\t\"error\",\n\t\t\t);\n\t\t}\n\t}\n\n\treturn index!;\n}\n\n/**\n * @internal\n * Loads the index file to quickly access the device configs.\n * Transparently handles updating the index if necessary\n */\nexport async function generatePriorityDeviceIndex(\n\tdeviceConfigPriorityDir: string,\n\tlogger?: ConfigLogger,\n): Promise<DeviceConfigIndex> {\n\treturn (\n\t\tawait generateIndex(\n\t\t\tdeviceConfigPriorityDir,\n\t\t\tfalse,\n\t\t\t(config) =>\n\t\t\t\tconfig.devices.map((dev) => ({\n\t\t\t\t\tmanufacturerId: formatId(\n\t\t\t\t\t\tconfig.manufacturerId.toString(16),\n\t\t\t\t\t),\n\t\t\t\t\tmanufacturer: config.manufacturer,\n\t\t\t\t\tlabel: config.label,\n\t\t\t\t\tproductType: formatId(dev.productType),\n\t\t\t\t\tproductId: formatId(dev.productId),\n\t\t\t\t\tfirmwareVersion: config.firmwareVersion,\n\t\t\t\t\t...(config.preferred ? { preferred: true as const } : {}),\n\t\t\t\t\trootDir: deviceConfigPriorityDir,\n\t\t\t\t})),\n\t\t\tlogger,\n\t\t)\n\t).map(({ filename, ...entry }) => ({\n\t\t...entry,\n\t\t// The generated index makes the filenames relative to the given directory\n\t\t// but we need them to be absolute\n\t\tfilename: path.join(deviceConfigPriorityDir, filename),\n\t}));\n}\n\n/**\n * @internal\n * Loads the index file to quickly access the device configs.\n * Transparently handles updating the index if necessary\n */\nexport async function loadDeviceIndexInternal(\n\tlogger?: ConfigLogger,\n\texternalConfigDir?: string,\n): Promise<DeviceConfigIndex> {\n\tconst { devicesDir, indexPath } = getDevicesPaths(\n\t\texternalConfigDir || configDir,\n\t);\n\n\treturn loadDeviceIndexShared(\n\t\tdevicesDir,\n\t\tindexPath,\n\t\t(config) =>\n\t\t\tconfig.devices.map((dev) => ({\n\t\t\t\tmanufacturerId: formatId(config.manufacturerId.toString(16)),\n\t\t\t\tmanufacturer: config.manufacturer,\n\t\t\t\tlabel: config.label,\n\t\t\t\tproductType: formatId(dev.productType),\n\t\t\t\tproductId: formatId(dev.productId),\n\t\t\t\tfirmwareVersion: config.firmwareVersion,\n\t\t\t\t...(config.preferred ? { preferred: true as const } : {}),\n\t\t\t})),\n\t\tlogger,\n\t);\n}\n\n/**\n * @internal\n * Loads the full text index file to quickly search the device configs.\n * Transparently handles updating the index if necessary\n */\nexport async function loadFulltextDeviceIndexInternal(\n\tlogger?: ConfigLogger,\n): Promise<FulltextDeviceConfigIndex> {\n\t// This method is not meant to operate with the external device index!\n\treturn loadDeviceIndexShared(\n\t\tembeddedDevicesDir,\n\t\tfulltextIndexPath,\n\t\t(config) =>\n\t\t\tconfig.devices.map((dev) => ({\n\t\t\t\tmanufacturerId: formatId(config.manufacturerId.toString(16)),\n\t\t\t\tmanufacturer: config.manufacturer,\n\t\t\t\tlabel: config.label,\n\t\t\t\tdescription: config.description,\n\t\t\t\tproductType: formatId(dev.productType),\n\t\t\t\tproductId: formatId(dev.productId),\n\t\t\t\tfirmwareVersion: config.firmwareVersion,\n\t\t\t\t...(config.preferred ? { preferred: true as const } : {}),\n\t\t\t\trootDir: embeddedDevicesDir,\n\t\t\t})),\n\t\tlogger,\n\t);\n}\n\nfunction isHexKeyWith4Digits(val: any): val is string {\n\treturn typeof val === \"string\" && hexKeyRegex4Digits.test(val);\n}\n\nconst firmwareVersionRegex = /^\\d{1,3}\\.\\d{1,3}(\\.\\d{1,3})?$/;\nfunction isFirmwareVersion(val: any): val is string {\n\treturn (\n\t\ttypeof val === \"string\"\n\t\t&& firmwareVersionRegex.test(val)\n\t\t&& val\n\t\t\t.split(\".\")\n\t\t\t.map((str) => parseInt(str, 10))\n\t\t\t.every((num) => num >= 0 && num <= 255)\n\t);\n}\n\n/** This class represents a device config entry whose conditional settings have not been evaluated yet */\nexport class ConditionalDeviceConfig {\n\tpublic static async from(\n\t\tfilename: string,\n\t\tisEmbedded: boolean,\n\t\toptions: {\n\t\t\trootDir: string;\n\t\t\tfallbackDirs?: string[];\n\t\t\trelative?: boolean;\n\t\t},\n\t): Promise<ConditionalDeviceConfig> {\n\t\tconst { relative, rootDir } = options;\n\n\t\tconst relativePath = relative\n\t\t\t? path.relative(rootDir, filename).replaceAll(\"\\\\\", \"/\")\n\t\t\t: filename;\n\t\tconst json = await readJsonWithTemplate(filename, [\n\t\t\toptions.rootDir,\n\t\t\t...(options.fallbackDirs ?? []),\n\t\t]);\n\t\treturn new ConditionalDeviceConfig(relativePath, isEmbedded, json);\n\t}\n\n\tpublic constructor(\n\t\tfilename: string,\n\t\tisEmbedded: boolean,\n\t\tdefinition: JSONObject,\n\t) {\n\t\tthis.filename = filename;\n\t\tthis.isEmbedded = isEmbedded;\n\n\t\tif (!isHexKeyWith4Digits(definition.manufacturerId)) {\n\t\t\tthrowInvalidConfig(\n\t\t\t\t`device`,\n\t\t\t\t`packages/config/config/devices/${filename}:\nmanufacturer id must be a lowercase hexadecimal number with 4 digits`,\n\t\t\t);\n\t\t}\n\t\tthis.manufacturerId = parseInt(definition.manufacturerId, 16);\n\n\t\tfor (const prop of [\"manufacturer\", \"label\", \"description\"] as const) {\n\t\t\tthis[prop] = parseConditionalPrimitive(\n\t\t\t\tfilename,\n\t\t\t\t\"string\",\n\t\t\t\tprop,\n\t\t\t\tdefinition[prop],\n\t\t\t);\n\t\t}\n\n\t\tif (\n\t\t\t!isArray(definition.devices)\n\t\t\t|| !(definition.devices as any[]).every(\n\t\t\t\t(dev: unknown) =>\n\t\t\t\t\tisObject(dev)\n\t\t\t\t\t&& isHexKeyWith4Digits(dev.productType)\n\t\t\t\t\t&& isHexKeyWith4Digits(dev.productId),\n\t\t\t)\n\t\t) {\n\t\t\tthrowInvalidConfig(\n\t\t\t\t`device`,\n\t\t\t\t`packages/config/config/devices/${filename}:\ndevices is malformed (not an object or type/id that is not a lowercase 4-digit hex key)`,\n\t\t\t);\n\t\t}\n\t\tthis.devices = (definition.devices as any[]).map(\n\t\t\t({ productType, productId }) => ({\n\t\t\t\tproductType: parseInt(productType, 16),\n\t\t\t\tproductId: parseInt(productId, 16),\n\t\t\t}),\n\t\t);\n\n\t\tif (\n\t\t\t!isObject(definition.firmwareVersion)\n\t\t\t|| !isFirmwareVersion(definition.firmwareVersion.min)\n\t\t\t|| !isFirmwareVersion(definition.firmwareVersion.max)\n\t\t) {\n\t\t\tthrowInvalidConfig(\n\t\t\t\t`device`,\n\t\t\t\t`packages/config/config/devices/${filename}:\nfirmwareVersion is malformed or invalid. Must be x.y or x.y.z where x, y, and z are integers between 0 and 255`,\n\t\t\t);\n\t\t} else {\n\t\t\tconst { min, max } = definition.firmwareVersion;\n\t\t\tif (semverGt(padVersion(min), padVersion(max))) {\n\t\t\t\tthrowInvalidConfig(\n\t\t\t\t\t`device`,\n\t\t\t\t\t`packages/config/config/devices/${filename}:\nfirmwareVersion.min ${min} must not be greater than firmwareVersion.max ${max}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.firmwareVersion = { min, max };\n\t\t}\n\n\t\tif (\n\t\t\tdefinition.preferred != undefined\n\t\t\t&& definition.preferred !== true\n\t\t) {\n\t\t\tthrowInvalidConfig(\n\t\t\t\t`device`,\n\t\t\t\t`packages/config/config/devices/${filename}:\npreferred must be true or omitted`,\n\t\t\t);\n\t\t}\n\t\tthis.preferred = !!definition.preferred;\n\n\t\tif (definition.endpoints != undefined) {\n\t\t\tconst endpoints = new Map<number, ConditionalEndpointConfig>();\n\t\t\tif (!isObject(definition.endpoints)) {\n\t\t\t\tthrowInvalidConfig(\n\t\t\t\t\t`device`,\n\t\t\t\t\t`packages/config/config/devices/${filename}:\nendpoints is not an object`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tfor (const [key, ep] of Object.entries(definition.endpoints)) {\n\t\t\t\tif (!/^\\d+$/.test(key)) {\n\t\t\t\t\tthrowInvalidConfig(\n\t\t\t\t\t\t`device`,\n\t\t\t\t\t\t`packages/config/config/devices/${filename}:\nfound non-numeric endpoint index \"${key}\" in endpoints`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst epIndex = parseInt(key, 10);\n\t\t\t\tendpoints.set(\n\t\t\t\t\tepIndex,\n\t\t\t\t\tnew ConditionalEndpointConfig(this, epIndex, ep as any),\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.endpoints = endpoints;\n\t\t}\n\n\t\tif (definition.associations != undefined) {\n\t\t\tconst associations = new Map<\n\t\t\t\tnumber,\n\t\t\t\tConditionalAssociationConfig\n\t\t\t>();\n\t\t\tif (!isObject(definition.associations)) {\n\t\t\t\tthrowInvalidConfig(\n\t\t\t\t\t`device`,\n\t\t\t\t\t`packages/config/config/devices/${filename}:\nassociations is not an object`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tfor (\n\t\t\t\tconst [key, assocDefinition] of Object.entries(\n\t\t\t\t\tdefinition.associations,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tif (!/^[1-9][0-9]*$/.test(key)) {\n\t\t\t\t\tthrowInvalidConfig(\n\t\t\t\t\t\t`device`,\n\t\t\t\t\t\t`packages/config/config/devices/${filename}:\nfound non-numeric group id \"${key}\" in associations`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst keyNum = parseInt(key, 10);\n\t\t\t\tassociations.set(\n\t\t\t\t\tkeyNum,\n\t\t\t\t\tnew ConditionalAssociationConfig(\n\t\t\t\t\t\tfilename,\n\t\t\t\t\t\tkeyNum,\n\t\t\t\t\t\tassocDefinition as any,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.associations = associations;\n\t\t}\n\n\t\tif (definition.paramInformation != undefined) {\n\t\t\tthis.paramInformation = parseConditionalParamInformationMap(\n\t\t\t\tdefinition,\n\t\t\t\tthis,\n\t\t\t);\n\t\t}\n\n\t\tif (definition.proprietary != undefined) {\n\t\t\tif (!isObject(definition.proprietary)) {\n\t\t\t\tthrowInvalidConfig(\n\t\t\t\t\t`device`,\n\t\t\t\t\t`packages/config/config/devices/${filename}:\nproprietary is not an object`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.proprietary = definition.proprietary;\n\t\t}\n\n\t\tif (definition.compat != undefined) {\n\t\t\tif (\n\t\t\t\tisArray(definition.compat)\n\t\t\t\t&& definition.compat.every((item: any) => isObject(item))\n\t\t\t) {\n\t\t\t\t// Make sure all conditions are valid\n\t\t\t\tfor (const entry of definition.compat) {\n\t\t\t\t\tvalidateCondition(\n\t\t\t\t\t\tfilename,\n\t\t\t\t\t\tentry,\n\t\t\t\t\t\t`At least one entry of compat contains an`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tthis.compat = definition.compat.map(\n\t\t\t\t\t(item: any) => new ConditionalCompatConfig(filename, item),\n\t\t\t\t);\n\t\t\t} else if (isObject(definition.compat)) {\n\t\t\t\tthis.compat = new ConditionalCompatConfig(\n\t\t\t\t\tfilename,\n\t\t\t\t\tdefinition.compat,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrowInvalidConfig(\n\t\t\t\t\t`device`,\n\t\t\t\t\t`packages/config/config/devices/${filename}:\ncompat must be an object or any array of conditional objects`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (definition.metadata != undefined) {\n\t\t\tif (!isObject(definition.metadata)) {\n\t\t\t\tthrowInvalidConfig(\n\t\t\t\t\t`device`,\n\t\t\t\t\t`packages/config/config/devices/${filename}:\nmetadata is not an object`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.metadata = new ConditionalDeviceMetadata(\n\t\t\t\tfilename,\n\t\t\t\tdefinition.metadata,\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic readonly filename: string;\n\n\tpublic readonly manufacturer!: ConditionalPrimitive<string>;\n\tpublic readonly manufacturerId: number;\n\tpublic readonly label!: ConditionalPrimitive<string>;\n\tpublic readonly description!: ConditionalPrimitive<string>;\n\tpublic readonly devices: readonly {\n\t\tproductType: number;\n\t\tproductId: number;\n\t}[];\n\tpublic readonly firmwareVersion: FirmwareVersionRange;\n\t/** Mark this configuration as preferred over other config files with an overlapping firmware range */\n\tpublic readonly preferred: boolean;\n\tpublic readonly endpoints?: ReadonlyMap<number, ConditionalEndpointConfig>;\n\tpublic readonly associations?: ReadonlyMap<\n\t\tnumber,\n\t\tConditionalAssociationConfig\n\t>;\n\tpublic readonly paramInformation?: ConditionalParamInfoMap;\n\t/**\n\t * Contains manufacturer-specific support information for the\n\t * ManufacturerProprietary CC\n\t */\n\tpublic readonly proprietary?: Record<string, unknown>;\n\t/** Contains compatibility options */\n\tpublic readonly compat?:\n\t\t| ConditionalCompatConfig\n\t\t| ConditionalCompatConfig[];\n\t/** Contains instructions and other metadata for the device */\n\tpublic readonly metadata?: ConditionalDeviceMetadata;\n\n\t/** Whether this is an embedded configuration or not */\n\tpublic readonly isEmbedded: boolean;\n\n\tpublic evaluate(deviceId?: DeviceID): DeviceConfig {\n\t\treturn new DeviceConfig(\n\t\t\tthis.filename,\n\t\t\tthis.isEmbedded,\n\t\t\tevaluateDeep(this.manufacturer, deviceId),\n\t\t\tthis.manufacturerId,\n\t\t\tevaluateDeep(this.label, deviceId),\n\t\t\tevaluateDeep(this.description, deviceId),\n\t\t\tthis.devices,\n\t\t\tthis.firmwareVersion,\n\t\t\tthis.preferred,\n\t\t\tevaluateDeep(this.endpoints, deviceId),\n\t\t\tevaluateDeep(this.associations, deviceId),\n\t\t\tevaluateDeep(this.paramInformation, deviceId),\n\t\t\tthis.proprietary,\n\t\t\tevaluateDeep(this.compat, deviceId),\n\t\t\tevaluateDeep(this.metadata, deviceId),\n\t\t);\n\t}\n}\n\nexport class DeviceConfig {\n\tpublic static async from(\n\t\tfilename: string,\n\t\tisEmbedded: boolean,\n\t\toptions: {\n\t\t\trootDir: string;\n\t\t\tfallbackDirs?: string[];\n\t\t\trelative?: boolean;\n\t\t\tdeviceId?: DeviceID;\n\t\t},\n\t): Promise<DeviceConfig> {\n\t\tconst ret = await ConditionalDeviceConfig.from(\n\t\t\tfilename,\n\t\t\tisEmbedded,\n\t\t\toptions,\n\t\t);\n\t\treturn ret.evaluate(options.deviceId);\n\t}\n\n\tpublic constructor(\n\t\tfilename: string,\n\t\tisEmbedded: boolean,\n\t\tmanufacturer: string,\n\t\tmanufacturerId: number,\n\t\tlabel: string,\n\t\tdescription: string,\n\t\tdevices: readonly {\n\t\t\tproductType: number;\n\t\t\tproductId: number;\n\t\t}[],\n\t\tfirmwareVersion: FirmwareVersionRange,\n\t\tpreferred: boolean,\n\t\tendpoints?: ReadonlyMap<number, EndpointConfig>,\n\t\tassociations?: ReadonlyMap<number, AssociationConfig>,\n\t\tparamInformation?: ParamInfoMap,\n\t\tproprietary?: Record<string, unknown>,\n\t\tcompat?: CompatConfig,\n\t\tmetadata?: DeviceMetadata,\n\t) {\n\t\tthis.filename = filename;\n\t\tthis.isEmbedded = isEmbedded;\n\t\tthis.manufacturer = manufacturer;\n\t\tthis.manufacturerId = manufacturerId;\n\t\tthis.label = label;\n\t\tthis.description = description;\n\t\tthis.devices = devices;\n\t\tthis.firmwareVersion = firmwareVersion;\n\t\tthis.preferred = preferred;\n\t\tthis.endpoints = endpoints;\n\t\tthis.associations = associations;\n\t\tthis.paramInformation = paramInformation;\n\t\tthis.proprietary = proprietary;\n\t\tthis.compat = compat;\n\t\tthis.metadata = metadata;\n\t}\n\n\tpublic readonly filename: string;\n\t/** Whether this is an embedded configuration or not */\n\tpublic readonly isEmbedded: boolean;\n\tpublic readonly manufacturer: string;\n\tpublic readonly manufacturerId: number;\n\tpublic readonly label: string;\n\tpublic readonly description: string;\n\tpublic readonly devices: readonly {\n\t\tproductType: number;\n\t\tproductId: number;\n\t}[];\n\tpublic readonly firmwareVersion: FirmwareVersionRange;\n\t/** Mark this configuration as preferred over other config files with an overlapping firmware range */\n\tpublic readonly preferred: boolean;\n\tpublic readonly endpoints?: ReadonlyMap<number, EndpointConfig>;\n\tpublic readonly associations?: ReadonlyMap<number, AssociationConfig>;\n\tpublic readonly paramInformation?: ParamInfoMap;\n\t/**\n\t * Contains manufacturer-specific support information for the\n\t * ManufacturerProprietary CC\n\t */\n\tpublic readonly proprietary?: Record<string, unknown>;\n\t/** Contains compatibility options */\n\tpublic readonly compat?: CompatConfig;\n\t/** Contains instructions and other metadata for the device */\n\tpublic readonly metadata?: DeviceMetadata;\n\n\t/** Returns the association config for a given endpoint */\n\tpublic getAssociationConfigForEndpoint(\n\t\tendpointIndex: number,\n\t\tgroup: number,\n\t): AssociationConfig | undefined {\n\t\tif (endpointIndex === 0) {\n\t\t\t// The root endpoint's associations may be configured separately or as part of \"endpoints\"\n\t\t\treturn (\n\t\t\t\tthis.associations?.get(group)\n\t\t\t\t\t?? this.endpoints?.get(0)?.associations?.get(group)\n\t\t\t);\n\t\t} else {\n\t\t\t// The other endpoints can only have a configuration as part of \"endpoints\"\n\t\t\treturn this.endpoints?.get(endpointIndex)?.associations?.get(group);\n\t\t}\n\t}\n\n\tprivate getHashable(): Uint8Array {\n\t\t// We only need to compare the information that is persisted elsewhere:\n\t\t// - config parameters\n\t\t// - functional association settings\n\t\t// - CC-related compat flags\n\n\t\tlet hashable: Record<string, any> = {\n\t\t\t// endpoints: {\n\t\t\t// \tassociations: {},\n\t\t\t// \tparamInformation: []\n\t\t\t// },\n\t\t\t// proprietary: {},\n\t\t\t// compat: {},\n\t\t};\n\n\t\tconst sortObject = (obj: Record<string, any>) => {\n\t\t\tconst ret: Record<string, any> = {};\n\t\t\tfor (const key of Object.keys(obj).sort()) {\n\t\t\t\tret[key] = obj[key];\n\t\t\t}\n\t\t\treturn ret;\n\t\t};\n\n\t\tconst cloneAssociationConfig = (a: AssociationConfig) => {\n\t\t\treturn sortObject(\n\t\t\t\tpick(a, [\"maxNodes\", \"multiChannel\", \"isLifeline\"]),\n\t\t\t);\n\t\t};\n\t\tconst cloneAssociationMap = (\n\t\t\ttarget: Record<string, any>,\n\t\t\tmap: ReadonlyMap<number, AssociationConfig> | undefined,\n\t\t) => {\n\t\t\tif (!map || !map.size) return;\n\t\t\ttarget.associations = {};\n\t\t\tfor (const [key, value] of map) {\n\t\t\t\ttarget.associations[key] = cloneAssociationConfig(value);\n\t\t\t}\n\t\t\ttarget.associations = sortObject(target.associations);\n\t\t};\n\n\t\tconst cloneParamInformationMap = (\n\t\t\ttarget: Record<string, any>,\n\t\t\tmap: ParamInfoMap | undefined,\n\t\t) => {\n\t\t\tif (!map || !map.size) return;\n\t\t\tconst getParamKey = (param: ParamInformation) =>\n\t\t\t\t`${param.parameterNumber}${\n\t\t\t\t\tparam.valueBitMask ? `[${num2hex(param.valueBitMask)}]` : \"\"\n\t\t\t\t}`;\n\t\t\ttarget.paramInformation = [...map.values()].sort((a, b) =>\n\t\t\t\tgetParamKey(a).localeCompare(getParamKey(b))\n\t\t\t);\n\t\t};\n\n\t\t// Clone associations and param information on the root (ep 0) and endpoints\n\t\t{\n\t\t\tlet ep0: Record<string, any> = {};\n\t\t\tcloneAssociationMap(ep0, this.associations);\n\t\t\tcloneParamInformationMap(ep0, this.paramInformation);\n\t\t\tep0 = sortObject(ep0);\n\n\t\t\tif (Object.keys(ep0).length > 0) {\n\t\t\t\thashable.endpoints ??= {};\n\t\t\t\thashable.endpoints[0] = ep0;\n\t\t\t}\n\t\t}\n\n\t\tif (this.endpoints) {\n\t\t\tfor (const [index, endpoint] of this.endpoints) {\n\t\t\t\tlet ep: Record<string, any> = {};\n\n\t\t\t\tcloneAssociationMap(ep, endpoint.associations);\n\t\t\t\tcloneParamInformationMap(ep, endpoint.paramInformation);\n\n\t\t\t\tep = sortObject(ep);\n\n\t\t\t\tif (Object.keys(ep).length > 0) {\n\t\t\t\t\thashable.endpoints ??= {};\n\t\t\t\t\thashable.endpoints[index] = ep;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Clone proprietary config\n\t\tif (this.proprietary && Object.keys(this.proprietary).length > 0) {\n\t\t\thashable.proprietary = sortObject({ ...this.proprietary });\n\t\t}\n\n\t\t// Clone relevant compat flags\n\t\tif (this.compat) {\n\t\t\tlet c: Record<string, any> = {};\n\n\t\t\t// Copy some simple flags over\n\t\t\tfor (\n\t\t\t\tconst prop of [\n\t\t\t\t\t\"forceSceneControllerGroupCount\",\n\t\t\t\t\t\"mapRootReportsToEndpoint\",\n\t\t\t\t\t\"mapBasicSet\",\n\t\t\t\t\t\"preserveRootApplicationCCValueIDs\",\n\t\t\t\t\t\"preserveEndpoints\",\n\t\t\t\t\t\"removeEndpoints\",\n\t\t\t\t\t\"treatMultilevelSwitchSetAsEvent\",\n\t\t\t\t] as const\n\t\t\t) {\n\t\t\t\tif (this.compat[prop] != undefined) {\n\t\t\t\t\tc[prop] = this.compat[prop];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Copy other, more complex flags\n\t\t\tif (this.compat.overrideQueries) {\n\t\t\t\tc.overrideQueries = Object.fromEntries(\n\t\t\t\t\tthis.compat.overrideQueries[\"overrides\"],\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (this.compat.addCCs) {\n\t\t\t\tc.addCCs = Object.fromEntries(\n\t\t\t\t\t[...this.compat.addCCs].map(([ccId, def]) => [\n\t\t\t\t\t\tccId,\n\t\t\t\t\t\tObject.fromEntries(def.endpoints),\n\t\t\t\t\t]),\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (this.compat.removeCCs) {\n\t\t\t\tc.removeCCs = Object.fromEntries(this.compat.removeCCs);\n\t\t\t}\n\t\t\tif (this.compat.treatSetAsReport) {\n\t\t\t\tc.treatSetAsReport = [...this.compat.treatSetAsReport].sort();\n\t\t\t}\n\n\t\t\tc = sortObject(c);\n\t\t\tif (Object.keys(c).length > 0) {\n\t\t\t\thashable.compat = c;\n\t\t\t}\n\t\t}\n\n\t\thashable = sortObject(hashable);\n\n\t\treturn Bytes.from(JSON.stringify(hashable), \"utf8\");\n\t}\n\n\t/**\n\t * Returns a hash code that can be used to check whether a device config has changed enough to require a re-interview.\n\t */\n\tpublic getHash(\n\t\talgorithm: \"md5\" | \"sha-256\" = \"sha-256\",\n\t): Promise<Uint8Array> {\n\t\t// Figure out what to hash\n\t\tconst buffer = this.getHashable();\n\n\t\t// And create a hash from it. This does not need to be cryptographically secure, just good enough to detect changes.\n\t\treturn digest(algorithm, buffer);\n\t}\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAAA,kBAA4C;AAC5C,IAAAA,eAAuB;AACvB,oBAUO;AACP,wBAAkC;AAClC,mBAAkB;AAClB,sBAAe;AACf,uBAAiB;AACjB,gBAAqB;AACrB,0BAAyD;AAEzD,mBAA0B;AAC1B,wBAAuD;AACvD,+BAGO;AACP,0BAA2D;AAC3D,6BAAgD;AAChD,kCAGO;AACP,4BAGO;AACP,4BAGO;AACP,8BAKO;AA0BA,MAAM,qBAAqB,iBAAAC,QAAK,KAAK,wBAAW,SAAS;AAChE,MAAM,oBAAoB,iBAAAA,QAAK,KAAK,oBAAoB,qBAAqB;AAEvE,SAAU,gBAAgBC,YAAiB;AAIhD,QAAM,aAAa,iBAAAD,QAAK,KAAKC,YAAW,SAAS;AACjD,QAAM,YAAY,iBAAAD,QAAK,KAAK,YAAY,YAAY;AACpD,SAAO,EAAE,YAAY,UAAS;AAC/B;AAPgB;AAYhB,eAAe,sBACd,aACA,KACA,YAAgB;AAIhB,QAAM,eAAe,MAAM,gBAAAE,QAAG,QAAQ,GAAG;AACzC,aAAW,KAAK,cAAc;AAC7B,UAAM,WAAW,iBAAAF,QAAK,KAAK,KAAK,CAAC;AAEjC,UAAM,OAAO,MAAM,gBAAAE,QAAG,KAAK,QAAQ;AACnC,SACE,QAAQ,eAAe,MAAM,kBAC1B,KAAK,OAAM,KAAM,KAAK,YAAW,MAClC,KAAK,QAAQ,YACf;AACD,aAAO;IACR,WAAW,KAAK,YAAW,GAAI;AAE9B,UACC,MAAM,sBAAsB,aAAa,UAAU,UAAU,GAC5D;AACD,eAAO;MACR;IACD;EACD;AACA,SAAO;AACR;AA5Be;AAkCf,eAAe,cACd,YACA,Y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QAC3B;MACD;AAGA,UAAI,KAAK,OAAO,iBAAiB;AAChC,UAAE,kBAAkB,OAAO,YAC1B,KAAK,OAAO,gBAAgB,WAAW,CAAC;MAE1C;AACA,UAAI,KAAK,OAAO,QAAQ;AACvB,UAAE,SAAS,OAAO,YACjB,CAAC,GAAG,KAAK,OAAO,MAAM,EAAE,IAAI,CAAC,CAAC,MAAM,GAAG,MAAM;UAC5C;UACA,OAAO,YAAY,IAAI,SAAS;SAChC,CAAC;MAEJ;AACA,UAAI,KAAK,OAAO,WAAW;AAC1B,UAAE,YAAY,OAAO,YAAY,KAAK,OAAO,SAAS;MACvD;AACA,UAAI,KAAK,OAAO,kBAAkB;AACjC,UAAE,mBAAmB,CAAC,GAAG,KAAK,OAAO,gBAAgB,EAAE,KAAI;MAC5D;AAEA,UAAI,WAAW,CAAC;AAChB,UAAI,OAAO,KAAK,CAAC,EAAE,SAAS,GAAG;AAC9B,iBAAS,SAAS;MACnB;IACD;AAEA,eAAW,WAAW,QAAQ;AAE9B,WAAO,oBAAM,KAAK,KAAK,UAAU,QAAQ,GAAG,MAAM;EACnD;;;;EAKO,QACN,YAA+B,WAAS;AAGxC,UAAM,SAAS,KAAK,YAAW;AAG/B,eAAO,qBAAO,WAAW,MAAM;EAChC;;",
6
- "names": ["import_core", "path", "configDir", "fs", "JSON5", "semverGt"]
4
+ "sourcesContent": ["import { ZWaveError, ZWaveErrorCodes } from \"@zwave-js/core\";\nimport { digest } from \"@zwave-js/core\";\nimport {\n\tBytes,\n\ttype JSONObject,\n\tenumFilesRecursive,\n\tformatId,\n\tgetenv,\n\tnum2hex,\n\tpadVersion,\n\tpathExists,\n\tpick,\n\treadTextFile,\n\tstringify,\n\twriteTextFile,\n} from \"@zwave-js/shared\";\nimport {\n\ttype ReadFile,\n\ttype ReadFileSystemInfo,\n\ttype WriteFile,\n} from \"@zwave-js/shared/bindings\";\nimport { isArray, isObject } from \"alcalzone-shared/typeguards\";\nimport JSON5 from \"json5\";\nimport path from \"pathe\";\nimport semverGt from \"semver/functions/gt.js\";\nimport { clearTemplateCache, readJsonWithTemplate } from \"../JsonTemplate.js\";\nimport type { ConfigLogger } from \"../Logger.js\";\nimport { configDir } from \"../utils.js\";\nimport { hexKeyRegex4Digits, throwInvalidConfig } from \"../utils_safe.js\";\nimport {\n\ttype AssociationConfig,\n\tConditionalAssociationConfig,\n} from \"./AssociationConfig.js\";\nimport { type CompatConfig, ConditionalCompatConfig } from \"./CompatConfig.js\";\nimport { evaluateDeep, validateCondition } from \"./ConditionalItem.js\";\nimport {\n\ttype ConditionalPrimitive,\n\tparseConditionalPrimitive,\n} from \"./ConditionalPrimitive.js\";\nimport {\n\tConditionalDeviceMetadata,\n\ttype DeviceMetadata,\n} from \"./DeviceMetadata.js\";\nimport {\n\tConditionalEndpointConfig,\n\ttype EndpointConfig,\n} from \"./EndpointConfig.js\";\nimport {\n\ttype ConditionalParamInfoMap,\n\ttype ParamInfoMap,\n\ttype ParamInformation,\n\tparseConditionalParamInformationMap,\n} from \"./ParamInformation.js\";\nimport type { DeviceID, FirmwareVersionRange } from \"./shared.js\";\n\nexport interface DeviceConfigIndexEntry {\n\tmanufacturerId: string;\n\tproductType: string;\n\tproductId: string;\n\tfirmwareVersion: FirmwareVersionRange;\n\tpreferred?: true;\n\trootDir?: string;\n\tfilename: string;\n}\n\nexport interface FulltextDeviceConfigIndexEntry {\n\tmanufacturerId: string;\n\tmanufacturer: string;\n\tlabel: string;\n\tdescription: string;\n\tproductType: string;\n\tproductId: string;\n\tfirmwareVersion: FirmwareVersionRange;\n\tpreferred?: true;\n\trootDir?: string;\n\tfilename: string;\n}\n\nexport const embeddedDevicesDir = path.join(configDir, \"devices\");\nconst fulltextIndexPath = path.join(embeddedDevicesDir, \"fulltext_index.json\");\n\nexport function getDevicesPaths(configDir: string): {\n\tdevicesDir: string;\n\tindexPath: string;\n} {\n\tconst devicesDir = path.join(configDir, \"devices\");\n\tconst indexPath = path.join(devicesDir, \"index.json\");\n\treturn { devicesDir, indexPath };\n}\n\nexport type DeviceConfigIndex = DeviceConfigIndexEntry[];\nexport type FulltextDeviceConfigIndex = FulltextDeviceConfigIndexEntry[];\n\nasync function hasChangedDeviceFiles(\n\tfs: ReadFileSystemInfo,\n\tdevicesRoot: string,\n\tdir: string,\n\tlastChange: Date,\n): Promise<boolean> {\n\t// Check if there are any files BUT index.json that were changed\n\t// or directories that were modified\n\tconst filesAndDirs = await fs.readDir(dir);\n\tfor (const f of filesAndDirs) {\n\t\tconst fullPath = path.join(dir, f);\n\n\t\tconst stat = await fs.stat(fullPath);\n\t\tif (\n\t\t\t(dir !== devicesRoot || f !== \"index.json\")\n\t\t\t&& (stat.isFile() || stat.isDirectory())\n\t\t\t&& stat.mtime > lastChange\n\t\t) {\n\t\t\treturn true;\n\t\t} else if (stat.isDirectory()) {\n\t\t\t// we need to go deeper!\n\t\t\tif (\n\t\t\t\tawait hasChangedDeviceFiles(\n\t\t\t\t\tfs,\n\t\t\t\t\tdevicesRoot,\n\t\t\t\t\tfullPath,\n\t\t\t\t\tlastChange,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n * Read all device config files from a given directory and return them as index entries.\n * Does not update the index itself.\n */\nasync function generateIndex<T extends Record<string, unknown>>(\n\tfs: ReadFileSystemInfo & ReadFile,\n\tdevicesDir: string,\n\tisEmbedded: boolean,\n\textractIndexEntries: (config: DeviceConfig) => T[],\n\tlogger?: ConfigLogger,\n): Promise<(T & { filename: string; rootDir?: string })[]> {\n\tconst index: (T & { filename: string; rootDir?: string })[] = [];\n\n\tclearTemplateCache();\n\tconst configFiles = await enumFilesRecursive(\n\t\tfs,\n\t\tdevicesDir,\n\t\t(file) =>\n\t\t\tfile.endsWith(\".json\")\n\t\t\t&& !file.endsWith(\"index.json\")\n\t\t\t&& !file.includes(\"/templates/\")\n\t\t\t&& !file.includes(\"\\\\templates\\\\\"),\n\t);\n\n\t// Add the embedded devices dir as a fallback if necessary\n\tconst fallbackDirs = devicesDir !== embeddedDevicesDir\n\t\t? [embeddedDevicesDir]\n\t\t: undefined;\n\n\tfor (const file of configFiles) {\n\t\tconst relativePath = path\n\t\t\t.relative(devicesDir, file)\n\t\t\t.replaceAll(\"\\\\\", \"/\");\n\t\t// Try parsing the file\n\t\ttry {\n\t\t\tconst config = await DeviceConfig.from(\n\t\t\t\tfs,\n\t\t\t\tfile,\n\t\t\t\tisEmbedded,\n\t\t\t\t{\n\t\t\t\t\trootDir: devicesDir,\n\t\t\t\t\tfallbackDirs,\n\t\t\t\t\trelative: true,\n\t\t\t\t},\n\t\t\t);\n\t\t\t// Add the file to the index\n\t\t\tindex.push(\n\t\t\t\t...extractIndexEntries(config).map((entry) => {\n\t\t\t\t\tconst ret: T & { filename: string; rootDir?: string } = {\n\t\t\t\t\t\t...entry,\n\t\t\t\t\t\tfilename: relativePath,\n\t\t\t\t\t};\n\t\t\t\t\t// Only add the root dir to the index if necessary\n\t\t\t\t\tif (devicesDir !== embeddedDevicesDir) {\n\t\t\t\t\t\tret.rootDir = devicesDir;\n\t\t\t\t\t}\n\t\t\t\t\treturn ret;\n\t\t\t\t}),\n\t\t\t);\n\t\t} catch (e) {\n\t\t\tconst message = `Error parsing config file ${relativePath}: ${\n\t\t\t\t(e as Error).message\n\t\t\t}`;\n\t\t\t// Crash hard during tests, just print an error when in production systems.\n\t\t\t// A user could have changed a config file\n\t\t\tif (process.env.NODE_ENV === \"test\" || !!getenv(\"CI\")) {\n\t\t\t\tthrow new ZWaveError(message, ZWaveErrorCodes.Config_Invalid);\n\t\t\t} else {\n\t\t\t\tlogger?.print(message, \"error\");\n\t\t\t}\n\t\t}\n\t}\n\n\treturn index;\n}\n\nasync function loadDeviceIndexShared<T extends Record<string, unknown>>(\n\tfs: ReadFileSystemInfo & ReadFile & WriteFile,\n\tdevicesDir: string,\n\tindexPath: string,\n\textractIndexEntries: (config: DeviceConfig) => T[],\n\tlogger?: ConfigLogger,\n): Promise<(T & { filename: string })[]> {\n\t// The index file needs to be regenerated if it does not exist\n\tlet needsUpdate = !(await pathExists(fs, indexPath));\n\tlet index: (T & { filename: string })[] | undefined;\n\tlet mtimeIndex: Date | undefined;\n\t// ...or if cannot be parsed\n\tif (!needsUpdate) {\n\t\ttry {\n\t\t\tconst fileContents = await readTextFile(fs, indexPath, \"utf8\");\n\t\t\tindex = JSON5.parse(fileContents);\n\t\t\tmtimeIndex = (await fs.stat(indexPath)).mtime;\n\t\t} catch {\n\t\t\tlogger?.print(\n\t\t\t\t\"Error while parsing index file - regenerating...\",\n\t\t\t\t\"warn\",\n\t\t\t);\n\t\t\tneedsUpdate = true;\n\t\t} finally {\n\t\t\tif (!index) {\n\t\t\t\tlogger?.print(\n\t\t\t\t\t\"Index file was malformed - regenerating...\",\n\t\t\t\t\t\"warn\",\n\t\t\t\t);\n\t\t\t\tneedsUpdate = true;\n\t\t\t}\n\t\t}\n\t}\n\n\t// ...or if there were any changes in the file system\n\tif (!needsUpdate) {\n\t\tneedsUpdate = await hasChangedDeviceFiles(\n\t\t\tfs,\n\t\t\tdevicesDir,\n\t\t\tdevicesDir,\n\t\t\tmtimeIndex!,\n\t\t);\n\t\tif (needsUpdate) {\n\t\t\tlogger?.print(\n\t\t\t\t\"Device configuration files on disk changed - regenerating index...\",\n\t\t\t\t\"verbose\",\n\t\t\t);\n\t\t}\n\t}\n\n\tif (needsUpdate) {\n\t\t// Read all files from disk and generate an index\n\t\tindex = await generateIndex(\n\t\t\tfs,\n\t\t\tdevicesDir,\n\t\t\ttrue,\n\t\t\textractIndexEntries,\n\t\t\tlogger,\n\t\t);\n\t\t// Save the index to disk\n\t\ttry {\n\t\t\tawait writeTextFile(\n\t\t\t\tfs,\n\t\t\t\tpath.join(indexPath),\n\t\t\t\t`// This file is auto-generated. DO NOT edit it by hand if you don't know what you're doing!\"\n${stringify(index, \"\\t\")}\n`,\n\t\t\t\t\"utf8\",\n\t\t\t);\n\t\t\tlogger?.print(\"Device index regenerated\", \"verbose\");\n\t\t} catch (e) {\n\t\t\tlogger?.print(\n\t\t\t\t`Writing the device index to disk failed: ${\n\t\t\t\t\t(e as Error).message\n\t\t\t\t}`,\n\t\t\t\t\"error\",\n\t\t\t);\n\t\t}\n\t}\n\n\treturn index!;\n}\n\n/**\n * @internal\n * Loads the index file to quickly access the device configs.\n * Transparently handles updating the index if necessary\n */\nexport async function generatePriorityDeviceIndex(\n\tfs: ReadFileSystemInfo & ReadFile,\n\tdeviceConfigPriorityDir: string,\n\tlogger?: ConfigLogger,\n): Promise<DeviceConfigIndex> {\n\treturn (\n\t\tawait generateIndex(\n\t\t\tfs,\n\t\t\tdeviceConfigPriorityDir,\n\t\t\tfalse,\n\t\t\t(config) =>\n\t\t\t\tconfig.devices.map((dev) => ({\n\t\t\t\t\tmanufacturerId: formatId(\n\t\t\t\t\t\tconfig.manufacturerId.toString(16),\n\t\t\t\t\t),\n\t\t\t\t\tmanufacturer: config.manufacturer,\n\t\t\t\t\tlabel: config.label,\n\t\t\t\t\tproductType: formatId(dev.productType),\n\t\t\t\t\tproductId: formatId(dev.productId),\n\t\t\t\t\tfirmwareVersion: config.firmwareVersion,\n\t\t\t\t\t...(config.preferred ? { preferred: true as const } : {}),\n\t\t\t\t\trootDir: deviceConfigPriorityDir,\n\t\t\t\t})),\n\t\t\tlogger,\n\t\t)\n\t).map(({ filename, ...entry }) => ({\n\t\t...entry,\n\t\t// The generated index makes the filenames relative to the given directory\n\t\t// but we need them to be absolute\n\t\tfilename: path.join(deviceConfigPriorityDir, filename),\n\t}));\n}\n\n/**\n * @internal\n * Loads the index file to quickly access the device configs.\n * Transparently handles updating the index if necessary\n */\nexport async function loadDeviceIndexInternal(\n\tfs: ReadFileSystemInfo & ReadFile & WriteFile,\n\tlogger?: ConfigLogger,\n\texternalConfigDir?: string,\n): Promise<DeviceConfigIndex> {\n\tconst { devicesDir, indexPath } = getDevicesPaths(\n\t\texternalConfigDir || configDir,\n\t);\n\n\treturn loadDeviceIndexShared(\n\t\tfs,\n\t\tdevicesDir,\n\t\tindexPath,\n\t\t(config) =>\n\t\t\tconfig.devices.map((dev) => ({\n\t\t\t\tmanufacturerId: formatId(config.manufacturerId.toString(16)),\n\t\t\t\tmanufacturer: config.manufacturer,\n\t\t\t\tlabel: config.label,\n\t\t\t\tproductType: formatId(dev.productType),\n\t\t\t\tproductId: formatId(dev.productId),\n\t\t\t\tfirmwareVersion: config.firmwareVersion,\n\t\t\t\t...(config.preferred ? { preferred: true as const } : {}),\n\t\t\t})),\n\t\tlogger,\n\t);\n}\n\n/**\n * @internal\n * Loads the full text index file to quickly search the device configs.\n * Transparently handles updating the index if necessary\n */\nexport async function loadFulltextDeviceIndexInternal(\n\tfs: ReadFileSystemInfo & ReadFile & WriteFile,\n\tlogger?: ConfigLogger,\n): Promise<FulltextDeviceConfigIndex> {\n\t// This method is not meant to operate with the external device index!\n\treturn loadDeviceIndexShared(\n\t\tfs,\n\t\tembeddedDevicesDir,\n\t\tfulltextIndexPath,\n\t\t(config) =>\n\t\t\tconfig.devices.map((dev) => ({\n\t\t\t\tmanufacturerId: formatId(config.manufacturerId.toString(16)),\n\t\t\t\tmanufacturer: config.manufacturer,\n\t\t\t\tlabel: config.label,\n\t\t\t\tdescription: config.description,\n\t\t\t\tproductType: formatId(dev.productType),\n\t\t\t\tproductId: formatId(dev.productId),\n\t\t\t\tfirmwareVersion: config.firmwareVersion,\n\t\t\t\t...(config.preferred ? { preferred: true as const } : {}),\n\t\t\t\trootDir: embeddedDevicesDir,\n\t\t\t})),\n\t\tlogger,\n\t);\n}\n\nfunction isHexKeyWith4Digits(val: any): val is string {\n\treturn typeof val === \"string\" && hexKeyRegex4Digits.test(val);\n}\n\nconst firmwareVersionRegex = /^\\d{1,3}\\.\\d{1,3}(\\.\\d{1,3})?$/;\nfunction isFirmwareVersion(val: any): val is string {\n\treturn (\n\t\ttypeof val === \"string\"\n\t\t&& firmwareVersionRegex.test(val)\n\t\t&& val\n\t\t\t.split(\".\")\n\t\t\t.map((str) => parseInt(str, 10))\n\t\t\t.every((num) => num >= 0 && num <= 255)\n\t);\n}\n\n/** This class represents a device config entry whose conditional settings have not been evaluated yet */\nexport class ConditionalDeviceConfig {\n\tpublic static async from(\n\t\tfs: ReadFileSystemInfo & ReadFile,\n\t\tfilename: string,\n\t\tisEmbedded: boolean,\n\t\toptions: {\n\t\t\trootDir: string;\n\t\t\tfallbackDirs?: string[];\n\t\t\trelative?: boolean;\n\t\t},\n\t): Promise<ConditionalDeviceConfig> {\n\t\tconst { relative, rootDir } = options;\n\n\t\tconst relativePath = relative\n\t\t\t? path.relative(rootDir, filename).replaceAll(\"\\\\\", \"/\")\n\t\t\t: filename;\n\t\tconst json = await readJsonWithTemplate(\n\t\t\tfs,\n\t\t\tfilename,\n\t\t\t[\n\t\t\t\toptions.rootDir,\n\t\t\t\t...(options.fallbackDirs ?? []),\n\t\t\t],\n\t\t);\n\t\treturn new ConditionalDeviceConfig(relativePath, isEmbedded, json);\n\t}\n\n\tpublic constructor(\n\t\tfilename: string,\n\t\tisEmbedded: boolean,\n\t\tdefinition: JSONObject,\n\t) {\n\t\tthis.filename = filename;\n\t\tthis.isEmbedded = isEmbedded;\n\n\t\tif (!isHexKeyWith4Digits(definition.manufacturerId)) {\n\t\t\tthrowInvalidConfig(\n\t\t\t\t`device`,\n\t\t\t\t`packages/config/config/devices/${filename}:\nmanufacturer id must be a lowercase hexadecimal number with 4 digits`,\n\t\t\t);\n\t\t}\n\t\tthis.manufacturerId = parseInt(definition.manufacturerId, 16);\n\n\t\tfor (const prop of [\"manufacturer\", \"label\", \"description\"] as const) {\n\t\t\tthis[prop] = parseConditionalPrimitive(\n\t\t\t\tfilename,\n\t\t\t\t\"string\",\n\t\t\t\tprop,\n\t\t\t\tdefinition[prop],\n\t\t\t);\n\t\t}\n\n\t\tif (\n\t\t\t!isArray(definition.devices)\n\t\t\t|| !(definition.devices as any[]).every(\n\t\t\t\t(dev: unknown) =>\n\t\t\t\t\tisObject(dev)\n\t\t\t\t\t&& isHexKeyWith4Digits(dev.productType)\n\t\t\t\t\t&& isHexKeyWith4Digits(dev.productId),\n\t\t\t)\n\t\t) {\n\t\t\tthrowInvalidConfig(\n\t\t\t\t`device`,\n\t\t\t\t`packages/config/config/devices/${filename}:\ndevices is malformed (not an object or type/id that is not a lowercase 4-digit hex key)`,\n\t\t\t);\n\t\t}\n\t\tthis.devices = (definition.devices as any[]).map(\n\t\t\t({ productType, productId }) => ({\n\t\t\t\tproductType: parseInt(productType, 16),\n\t\t\t\tproductId: parseInt(productId, 16),\n\t\t\t}),\n\t\t);\n\n\t\tif (\n\t\t\t!isObject(definition.firmwareVersion)\n\t\t\t|| !isFirmwareVersion(definition.firmwareVersion.min)\n\t\t\t|| !isFirmwareVersion(definition.firmwareVersion.max)\n\t\t) {\n\t\t\tthrowInvalidConfig(\n\t\t\t\t`device`,\n\t\t\t\t`packages/config/config/devices/${filename}:\nfirmwareVersion is malformed or invalid. Must be x.y or x.y.z where x, y, and z are integers between 0 and 255`,\n\t\t\t);\n\t\t} else {\n\t\t\tconst { min, max } = definition.firmwareVersion;\n\t\t\tif (semverGt(padVersion(min), padVersion(max))) {\n\t\t\t\tthrowInvalidConfig(\n\t\t\t\t\t`device`,\n\t\t\t\t\t`packages/config/config/devices/${filename}:\nfirmwareVersion.min ${min} must not be greater than firmwareVersion.max ${max}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.firmwareVersion = { min, max };\n\t\t}\n\n\t\tif (\n\t\t\tdefinition.preferred != undefined\n\t\t\t&& definition.preferred !== true\n\t\t) {\n\t\t\tthrowInvalidConfig(\n\t\t\t\t`device`,\n\t\t\t\t`packages/config/config/devices/${filename}:\npreferred must be true or omitted`,\n\t\t\t);\n\t\t}\n\t\tthis.preferred = !!definition.preferred;\n\n\t\tif (definition.endpoints != undefined) {\n\t\t\tconst endpoints = new Map<number, ConditionalEndpointConfig>();\n\t\t\tif (!isObject(definition.endpoints)) {\n\t\t\t\tthrowInvalidConfig(\n\t\t\t\t\t`device`,\n\t\t\t\t\t`packages/config/config/devices/${filename}:\nendpoints is not an object`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tfor (const [key, ep] of Object.entries(definition.endpoints)) {\n\t\t\t\tif (!/^\\d+$/.test(key)) {\n\t\t\t\t\tthrowInvalidConfig(\n\t\t\t\t\t\t`device`,\n\t\t\t\t\t\t`packages/config/config/devices/${filename}:\nfound non-numeric endpoint index \"${key}\" in endpoints`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst epIndex = parseInt(key, 10);\n\t\t\t\tendpoints.set(\n\t\t\t\t\tepIndex,\n\t\t\t\t\tnew ConditionalEndpointConfig(this, epIndex, ep as any),\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.endpoints = endpoints;\n\t\t}\n\n\t\tif (definition.associations != undefined) {\n\t\t\tconst associations = new Map<\n\t\t\t\tnumber,\n\t\t\t\tConditionalAssociationConfig\n\t\t\t>();\n\t\t\tif (!isObject(definition.associations)) {\n\t\t\t\tthrowInvalidConfig(\n\t\t\t\t\t`device`,\n\t\t\t\t\t`packages/config/config/devices/${filename}:\nassociations is not an object`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tfor (\n\t\t\t\tconst [key, assocDefinition] of Object.entries(\n\t\t\t\t\tdefinition.associations,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tif (!/^[1-9][0-9]*$/.test(key)) {\n\t\t\t\t\tthrowInvalidConfig(\n\t\t\t\t\t\t`device`,\n\t\t\t\t\t\t`packages/config/config/devices/${filename}:\nfound non-numeric group id \"${key}\" in associations`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst keyNum = parseInt(key, 10);\n\t\t\t\tassociations.set(\n\t\t\t\t\tkeyNum,\n\t\t\t\t\tnew ConditionalAssociationConfig(\n\t\t\t\t\t\tfilename,\n\t\t\t\t\t\tkeyNum,\n\t\t\t\t\t\tassocDefinition as any,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.associations = associations;\n\t\t}\n\n\t\tif (definition.paramInformation != undefined) {\n\t\t\tthis.paramInformation = parseConditionalParamInformationMap(\n\t\t\t\tdefinition,\n\t\t\t\tthis,\n\t\t\t);\n\t\t}\n\n\t\tif (definition.proprietary != undefined) {\n\t\t\tif (!isObject(definition.proprietary)) {\n\t\t\t\tthrowInvalidConfig(\n\t\t\t\t\t`device`,\n\t\t\t\t\t`packages/config/config/devices/${filename}:\nproprietary is not an object`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.proprietary = definition.proprietary;\n\t\t}\n\n\t\tif (definition.compat != undefined) {\n\t\t\tif (\n\t\t\t\tisArray(definition.compat)\n\t\t\t\t&& definition.compat.every((item: any) => isObject(item))\n\t\t\t) {\n\t\t\t\t// Make sure all conditions are valid\n\t\t\t\tfor (const entry of definition.compat) {\n\t\t\t\t\tvalidateCondition(\n\t\t\t\t\t\tfilename,\n\t\t\t\t\t\tentry,\n\t\t\t\t\t\t`At least one entry of compat contains an`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tthis.compat = definition.compat.map(\n\t\t\t\t\t(item: any) => new ConditionalCompatConfig(filename, item),\n\t\t\t\t);\n\t\t\t} else if (isObject(definition.compat)) {\n\t\t\t\tthis.compat = new ConditionalCompatConfig(\n\t\t\t\t\tfilename,\n\t\t\t\t\tdefinition.compat,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrowInvalidConfig(\n\t\t\t\t\t`device`,\n\t\t\t\t\t`packages/config/config/devices/${filename}:\ncompat must be an object or any array of conditional objects`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (definition.metadata != undefined) {\n\t\t\tif (!isObject(definition.metadata)) {\n\t\t\t\tthrowInvalidConfig(\n\t\t\t\t\t`device`,\n\t\t\t\t\t`packages/config/config/devices/${filename}:\nmetadata is not an object`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.metadata = new ConditionalDeviceMetadata(\n\t\t\t\tfilename,\n\t\t\t\tdefinition.metadata,\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic readonly filename: string;\n\n\tpublic readonly manufacturer!: ConditionalPrimitive<string>;\n\tpublic readonly manufacturerId: number;\n\tpublic readonly label!: ConditionalPrimitive<string>;\n\tpublic readonly description!: ConditionalPrimitive<string>;\n\tpublic readonly devices: readonly {\n\t\tproductType: number;\n\t\tproductId: number;\n\t}[];\n\tpublic readonly firmwareVersion: FirmwareVersionRange;\n\t/** Mark this configuration as preferred over other config files with an overlapping firmware range */\n\tpublic readonly preferred: boolean;\n\tpublic readonly endpoints?: ReadonlyMap<number, ConditionalEndpointConfig>;\n\tpublic readonly associations?: ReadonlyMap<\n\t\tnumber,\n\t\tConditionalAssociationConfig\n\t>;\n\tpublic readonly paramInformation?: ConditionalParamInfoMap;\n\t/**\n\t * Contains manufacturer-specific support information for the\n\t * ManufacturerProprietary CC\n\t */\n\tpublic readonly proprietary?: Record<string, unknown>;\n\t/** Contains compatibility options */\n\tpublic readonly compat?:\n\t\t| ConditionalCompatConfig\n\t\t| ConditionalCompatConfig[];\n\t/** Contains instructions and other metadata for the device */\n\tpublic readonly metadata?: ConditionalDeviceMetadata;\n\n\t/** Whether this is an embedded configuration or not */\n\tpublic readonly isEmbedded: boolean;\n\n\tpublic evaluate(deviceId?: DeviceID): DeviceConfig {\n\t\treturn new DeviceConfig(\n\t\t\tthis.filename,\n\t\t\tthis.isEmbedded,\n\t\t\tevaluateDeep(this.manufacturer, deviceId),\n\t\t\tthis.manufacturerId,\n\t\t\tevaluateDeep(this.label, deviceId),\n\t\t\tevaluateDeep(this.description, deviceId),\n\t\t\tthis.devices,\n\t\t\tthis.firmwareVersion,\n\t\t\tthis.preferred,\n\t\t\tevaluateDeep(this.endpoints, deviceId),\n\t\t\tevaluateDeep(this.associations, deviceId),\n\t\t\tevaluateDeep(this.paramInformation, deviceId),\n\t\t\tthis.proprietary,\n\t\t\tevaluateDeep(this.compat, deviceId),\n\t\t\tevaluateDeep(this.metadata, deviceId),\n\t\t);\n\t}\n}\n\nexport class DeviceConfig {\n\tpublic static async from(\n\t\tfs: ReadFileSystemInfo & ReadFile,\n\t\tfilename: string,\n\t\tisEmbedded: boolean,\n\t\toptions: {\n\t\t\trootDir: string;\n\t\t\tfallbackDirs?: string[];\n\t\t\trelative?: boolean;\n\t\t\tdeviceId?: DeviceID;\n\t\t},\n\t): Promise<DeviceConfig> {\n\t\tconst ret = await ConditionalDeviceConfig.from(\n\t\t\tfs,\n\t\t\tfilename,\n\t\t\tisEmbedded,\n\t\t\toptions,\n\t\t);\n\t\treturn ret.evaluate(options.deviceId);\n\t}\n\n\tpublic constructor(\n\t\tfilename: string,\n\t\tisEmbedded: boolean,\n\t\tmanufacturer: string,\n\t\tmanufacturerId: number,\n\t\tlabel: string,\n\t\tdescription: string,\n\t\tdevices: readonly {\n\t\t\tproductType: number;\n\t\t\tproductId: number;\n\t\t}[],\n\t\tfirmwareVersion: FirmwareVersionRange,\n\t\tpreferred: boolean,\n\t\tendpoints?: ReadonlyMap<number, EndpointConfig>,\n\t\tassociations?: ReadonlyMap<number, AssociationConfig>,\n\t\tparamInformation?: ParamInfoMap,\n\t\tproprietary?: Record<string, unknown>,\n\t\tcompat?: CompatConfig,\n\t\tmetadata?: DeviceMetadata,\n\t) {\n\t\tthis.filename = filename;\n\t\tthis.isEmbedded = isEmbedded;\n\t\tthis.manufacturer = manufacturer;\n\t\tthis.manufacturerId = manufacturerId;\n\t\tthis.label = label;\n\t\tthis.description = description;\n\t\tthis.devices = devices;\n\t\tthis.firmwareVersion = firmwareVersion;\n\t\tthis.preferred = preferred;\n\t\tthis.endpoints = endpoints;\n\t\tthis.associations = associations;\n\t\tthis.paramInformation = paramInformation;\n\t\tthis.proprietary = proprietary;\n\t\tthis.compat = compat;\n\t\tthis.metadata = metadata;\n\t}\n\n\tpublic readonly filename: string;\n\t/** Whether this is an embedded configuration or not */\n\tpublic readonly isEmbedded: boolean;\n\tpublic readonly manufacturer: string;\n\tpublic readonly manufacturerId: number;\n\tpublic readonly label: string;\n\tpublic readonly description: string;\n\tpublic readonly devices: readonly {\n\t\tproductType: number;\n\t\tproductId: number;\n\t}[];\n\tpublic readonly firmwareVersion: FirmwareVersionRange;\n\t/** Mark this configuration as preferred over other config files with an overlapping firmware range */\n\tpublic readonly preferred: boolean;\n\tpublic readonly endpoints?: ReadonlyMap<number, EndpointConfig>;\n\tpublic readonly associations?: ReadonlyMap<number, AssociationConfig>;\n\tpublic readonly paramInformation?: ParamInfoMap;\n\t/**\n\t * Contains manufacturer-specific support information for the\n\t * ManufacturerProprietary CC\n\t */\n\tpublic readonly proprietary?: Record<string, unknown>;\n\t/** Contains compatibility options */\n\tpublic readonly compat?: CompatConfig;\n\t/** Contains instructions and other metadata for the device */\n\tpublic readonly metadata?: DeviceMetadata;\n\n\t/** Returns the association config for a given endpoint */\n\tpublic getAssociationConfigForEndpoint(\n\t\tendpointIndex: number,\n\t\tgroup: number,\n\t): AssociationConfig | undefined {\n\t\tif (endpointIndex === 0) {\n\t\t\t// The root endpoint's associations may be configured separately or as part of \"endpoints\"\n\t\t\treturn (\n\t\t\t\tthis.associations?.get(group)\n\t\t\t\t\t?? this.endpoints?.get(0)?.associations?.get(group)\n\t\t\t);\n\t\t} else {\n\t\t\t// The other endpoints can only have a configuration as part of \"endpoints\"\n\t\t\treturn this.endpoints?.get(endpointIndex)?.associations?.get(group);\n\t\t}\n\t}\n\n\tprivate getHashable(): Uint8Array {\n\t\t// We only need to compare the information that is persisted elsewhere:\n\t\t// - config parameters\n\t\t// - functional association settings\n\t\t// - CC-related compat flags\n\n\t\tlet hashable: Record<string, any> = {\n\t\t\t// endpoints: {\n\t\t\t// \tassociations: {},\n\t\t\t// \tparamInformation: []\n\t\t\t// },\n\t\t\t// proprietary: {},\n\t\t\t// compat: {},\n\t\t};\n\n\t\tconst sortObject = (obj: Record<string, any>) => {\n\t\t\tconst ret: Record<string, any> = {};\n\t\t\tfor (const key of Object.keys(obj).sort()) {\n\t\t\t\tret[key] = obj[key];\n\t\t\t}\n\t\t\treturn ret;\n\t\t};\n\n\t\tconst cloneAssociationConfig = (a: AssociationConfig) => {\n\t\t\treturn sortObject(\n\t\t\t\tpick(a, [\"maxNodes\", \"multiChannel\", \"isLifeline\"]),\n\t\t\t);\n\t\t};\n\t\tconst cloneAssociationMap = (\n\t\t\ttarget: Record<string, any>,\n\t\t\tmap: ReadonlyMap<number, AssociationConfig> | undefined,\n\t\t) => {\n\t\t\tif (!map || !map.size) return;\n\t\t\ttarget.associations = {};\n\t\t\tfor (const [key, value] of map) {\n\t\t\t\ttarget.associations[key] = cloneAssociationConfig(value);\n\t\t\t}\n\t\t\ttarget.associations = sortObject(target.associations);\n\t\t};\n\n\t\tconst cloneParamInformationMap = (\n\t\t\ttarget: Record<string, any>,\n\t\t\tmap: ParamInfoMap | undefined,\n\t\t) => {\n\t\t\tif (!map || !map.size) return;\n\t\t\tconst getParamKey = (param: ParamInformation) =>\n\t\t\t\t`${param.parameterNumber}${\n\t\t\t\t\tparam.valueBitMask ? `[${num2hex(param.valueBitMask)}]` : \"\"\n\t\t\t\t}`;\n\t\t\ttarget.paramInformation = [...map.values()].sort((a, b) =>\n\t\t\t\tgetParamKey(a).localeCompare(getParamKey(b))\n\t\t\t);\n\t\t};\n\n\t\t// Clone associations and param information on the root (ep 0) and endpoints\n\t\t{\n\t\t\tlet ep0: Record<string, any> = {};\n\t\t\tcloneAssociationMap(ep0, this.associations);\n\t\t\tcloneParamInformationMap(ep0, this.paramInformation);\n\t\t\tep0 = sortObject(ep0);\n\n\t\t\tif (Object.keys(ep0).length > 0) {\n\t\t\t\thashable.endpoints ??= {};\n\t\t\t\thashable.endpoints[0] = ep0;\n\t\t\t}\n\t\t}\n\n\t\tif (this.endpoints) {\n\t\t\tfor (const [index, endpoint] of this.endpoints) {\n\t\t\t\tlet ep: Record<string, any> = {};\n\n\t\t\t\tcloneAssociationMap(ep, endpoint.associations);\n\t\t\t\tcloneParamInformationMap(ep, endpoint.paramInformation);\n\n\t\t\t\tep = sortObject(ep);\n\n\t\t\t\tif (Object.keys(ep).length > 0) {\n\t\t\t\t\thashable.endpoints ??= {};\n\t\t\t\t\thashable.endpoints[index] = ep;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Clone proprietary config\n\t\tif (this.proprietary && Object.keys(this.proprietary).length > 0) {\n\t\t\thashable.proprietary = sortObject({ ...this.proprietary });\n\t\t}\n\n\t\t// Clone relevant compat flags\n\t\tif (this.compat) {\n\t\t\tlet c: Record<string, any> = {};\n\n\t\t\t// Copy some simple flags over\n\t\t\tfor (\n\t\t\t\tconst prop of [\n\t\t\t\t\t\"forceSceneControllerGroupCount\",\n\t\t\t\t\t\"mapRootReportsToEndpoint\",\n\t\t\t\t\t\"mapBasicSet\",\n\t\t\t\t\t\"preserveRootApplicationCCValueIDs\",\n\t\t\t\t\t\"preserveEndpoints\",\n\t\t\t\t\t\"removeEndpoints\",\n\t\t\t\t\t\"treatMultilevelSwitchSetAsEvent\",\n\t\t\t\t] as const\n\t\t\t) {\n\t\t\t\tif (this.compat[prop] != undefined) {\n\t\t\t\t\tc[prop] = this.compat[prop];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Copy other, more complex flags\n\t\t\tif (this.compat.overrideQueries) {\n\t\t\t\tc.overrideQueries = Object.fromEntries(\n\t\t\t\t\tthis.compat.overrideQueries[\"overrides\"],\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (this.compat.addCCs) {\n\t\t\t\tc.addCCs = Object.fromEntries(\n\t\t\t\t\t[...this.compat.addCCs].map(([ccId, def]) => [\n\t\t\t\t\t\tccId,\n\t\t\t\t\t\tObject.fromEntries(def.endpoints),\n\t\t\t\t\t]),\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (this.compat.removeCCs) {\n\t\t\t\tc.removeCCs = Object.fromEntries(this.compat.removeCCs);\n\t\t\t}\n\t\t\tif (this.compat.treatSetAsReport) {\n\t\t\t\tc.treatSetAsReport = [...this.compat.treatSetAsReport].sort();\n\t\t\t}\n\n\t\t\tc = sortObject(c);\n\t\t\tif (Object.keys(c).length > 0) {\n\t\t\t\thashable.compat = c;\n\t\t\t}\n\t\t}\n\n\t\thashable = sortObject(hashable);\n\n\t\treturn Bytes.from(JSON.stringify(hashable), \"utf8\");\n\t}\n\n\t/**\n\t * Returns a hash code that can be used to check whether a device config has changed enough to require a re-interview.\n\t */\n\tpublic getHash(\n\t\talgorithm: \"md5\" | \"sha-256\" = \"sha-256\",\n\t): Promise<Uint8Array> {\n\t\t// Figure out what to hash\n\t\tconst buffer = this.getHashable();\n\n\t\t// And create a hash from it. This does not need to be cryptographically secure, just good enough to detect changes.\n\t\treturn digest(algorithm, buffer);\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAAA,kBAA4C;AAC5C,IAAAA,eAAuB;AACvB,oBAaO;AAMP,wBAAkC;AAClC,mBAAkB;AAClB,mBAAiB;AACjB,gBAAqB;AACrB,0BAAyD;AAEzD,mBAA0B;AAC1B,wBAAuD;AACvD,+BAGO;AACP,0BAA2D;AAC3D,6BAAgD;AAChD,kCAGO;AACP,4BAGO;AACP,4BAGO;AACP,8BAKO;AA0BA,MAAM,qBAAqB,aAAAC,QAAK,KAAK,wBAAW,SAAS;AAChE,MAAM,oBAAoB,aAAAA,QAAK,KAAK,oBAAoB,qBAAqB;AAEvE,SAAU,gBAAgBC,YAAiB;AAIhD,QAAM,aAAa,aAAAD,QAAK,KAAKC,YAAW,SAAS;AACjD,QAAM,YAAY,aAAAD,QAAK,KAAK,YAAY,YAAY;AACpD,SAAO,EAAE,YAAY,UAAS;AAC/B;AAPgB;AAYhB,eAAe,sBACd,IACA,aACA,KACA,YAAgB;AAIhB,QAAM,eAAe,MAAM,GAAG,QAAQ,GAAG;AACzC,aAAW,KAAK,cAAc;AAC7B,UAAM,WAAW,aAAAA,QAAK,KAAK,KAAK,CAAC;AAEjC,UAAM,OA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C7B;MACD;IACD;AAGA,QAAI,KAAK,eAAe,OAAO,KAAK,KAAK,WAAW,EAAE,SAAS,GAAG;AACjE,eAAS,cAAc,WAAW,EAAE,GAAG,KAAK,YAAW,CAAE;IAC1D;AAGA,QAAI,KAAK,QAAQ;AAChB,UAAI,IAAyB,CAAA;AAG7B,iBACO,QAAQ;QACb;QACA;QACA;QACA;QACA;QACA;QACA;SAEA;AACD,YAAI,KAAK,OAAO,IAAI,KAAK,QAAW;AACnC,YAAE,IAAI,IAAI,KAAK,OAAO,IAAI;QAC3B;MACD;AAGA,UAAI,KAAK,OAAO,iBAAiB;AAChC,UAAE,kBAAkB,OAAO,YAC1B,KAAK,OAAO,gBAAgB,WAAW,CAAC;MAE1C;AACA,UAAI,KAAK,OAAO,QAAQ;AACvB,UAAE,SAAS,OAAO,YACjB,CAAC,GAAG,KAAK,OAAO,MAAM,EAAE,IAAI,CAAC,CAAC,MAAM,GAAG,MAAM;UAC5C;UACA,OAAO,YAAY,IAAI,SAAS;SAChC,CAAC;MAEJ;AACA,UAAI,KAAK,OAAO,WAAW;AAC1B,UAAE,YAAY,OAAO,YAAY,KAAK,OAAO,SAAS;MACvD;AACA,UAAI,KAAK,OAAO,kBAAkB;AACjC,UAAE,mBAAmB,CAAC,GAAG,KAAK,OAAO,gBAAgB,EAAE,KAAI;MAC5D;AAEA,UAAI,WAAW,CAAC;AAChB,UAAI,OAAO,KAAK,CAAC,EAAE,SAAS,GAAG;AAC9B,iBAAS,SAAS;MACnB;IACD;AAEA,eAAW,WAAW,QAAQ;AAE9B,WAAO,oBAAM,KAAK,KAAK,UAAU,QAAQ,GAAG,MAAM;EACnD;;;;EAKO,QACN,YAA+B,WAAS;AAGxC,UAAM,SAAS,KAAK,YAAW;AAG/B,eAAO,qBAAO,WAAW,MAAM;EAChC;;",
6
+ "names": ["import_core", "path", "configDir", "JSON5", "semverGt"]
7
7
  }
@@ -9,4 +9,5 @@ export * from "./devices/DeviceMetadata.js";
9
9
  export * from "./devices/EndpointConfig.js";
10
10
  export * from "./devices/ParamInformation.js";
11
11
  export * from "./devices/shared.js";
12
+ export type * from "./traits.js";
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["/* eslint-disable @typescript-eslint/consistent-type-exports */\nexport * from \"./ConfigManager.js\";\nexport * from \"./Logger_safe.js\";\nexport * from \"./Manufacturers.js\";\nexport { PACKAGE_VERSION } from \"./_version.js\";\nexport * from \"./devices/AssociationConfig.js\";\nexport * from \"./devices/CompatConfig.js\";\nexport * from \"./devices/DeviceConfig.js\";\nexport * from \"./devices/DeviceMetadata.js\";\nexport * from \"./devices/EndpointConfig.js\";\nexport * from \"./devices/ParamInformation.js\";\nexport * from \"./devices/shared.js\";\n"],
4
+ "sourcesContent": ["/* eslint-disable @typescript-eslint/consistent-type-exports */\nexport * from \"./ConfigManager.js\";\nexport * from \"./Logger_safe.js\";\nexport * from \"./Manufacturers.js\";\nexport { PACKAGE_VERSION } from \"./_version.js\";\nexport * from \"./devices/AssociationConfig.js\";\nexport * from \"./devices/CompatConfig.js\";\nexport * from \"./devices/DeviceConfig.js\";\nexport * from \"./devices/DeviceMetadata.js\";\nexport * from \"./devices/EndpointConfig.js\";\nexport * from \"./devices/ParamInformation.js\";\nexport * from \"./devices/shared.js\";\nexport type * from \"./traits.js\";\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;AACA,wBAAc,+BADd;AAEA,wBAAc,6BAFd;AAGA,wBAAc,+BAHd;AAIA,qBAAgC;AAChC,wBAAc,2CALd;AAMA,wBAAc,sCANd;AAOA,wBAAc,sCAPd;AAQA,wBAAc,wCARd;AASA,wBAAc,wCATd;AAUA,wBAAc,0CAVd;AAWA,wBAAc,gCAXd;",
6
6
  "names": []
7
7
  }
@@ -1,3 +1,4 @@
1
1
  export * from "./Logger_safe.js";
2
2
  export { PACKAGE_VERSION } from "./_version.js";
3
+ export type * from "./traits.js";
3
4
  //# sourceMappingURL=index_safe.d.ts.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index_safe.ts"],
4
- "sourcesContent": ["/* @forbiddenImports external */\n\nexport * from \"./Logger_safe.js\";\nexport { PACKAGE_VERSION } from \"./_version.js\";\n"],
4
+ "sourcesContent": ["/* @forbiddenImports external */\n\nexport * from \"./Logger_safe.js\";\nexport { PACKAGE_VERSION } from \"./_version.js\";\nexport type * from \"./traits.js\";\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;AAEA,+BAAc,6BAFd;AAGA,qBAAgC;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,11 @@
1
+ import { type DeviceConfig } from "./devices/DeviceConfig.js";
2
+ /** Allows querying device configuration for a node */
3
+ export interface GetDeviceConfig {
4
+ getDeviceConfig(nodeId: number): DeviceConfig | undefined;
5
+ }
6
+ /** Allows looking up Z-Wave manufacturers by manufacturer ID */
7
+ export interface LookupManufacturer {
8
+ /** Looks up the name of the manufacturer with the given ID in the configuration DB */
9
+ lookupManufacturer(manufacturerId: number): string | undefined;
10
+ }
11
+ //# sourceMappingURL=traits.d.ts.map
@@ -0,0 +1,17 @@
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var traits_exports = {};
16
+ module.exports = __toCommonJS(traits_exports);
17
+ //# sourceMappingURL=traits.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../esm/traits.js"],
4
+ "sourcesContent": ["export {};\n//# sourceMappingURL=traits.js.map"],
5
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -1,3 +1,4 @@
1
+ import { type CopyFile, type ManageDirectory, type ReadFile, type ReadFileSystemInfo, type WriteFile } from "@zwave-js/shared/bindings";
1
2
  import type { ConfigLogger } from "./Logger.js";
2
3
  import type { DeviceConfigIndexEntry } from "./devices/DeviceConfig.js";
3
4
  /** The absolute path of the embedded configuration directory */
@@ -14,6 +15,6 @@ export type SyncExternalConfigDirResult = {
14
15
  /**
15
16
  * Synchronizes or updates the external config directory and returns whether the directory is in a state that can be used
16
17
  */
17
- export declare function syncExternalConfigDir(extConfigDir: string, logger: ConfigLogger): Promise<SyncExternalConfigDirResult>;
18
+ export declare function syncExternalConfigDir(fs: ManageDirectory & ReadFileSystemInfo & ReadFile & CopyFile & WriteFile, extConfigDir: string, logger: ConfigLogger): Promise<SyncExternalConfigDirResult>;
18
19
  export declare function versionInRange(version: string, min: string, max: string): boolean;
19
20
  //# sourceMappingURL=utils.d.ts.map
@@ -37,20 +37,19 @@ __export(utils_exports, {
37
37
  });
38
38
  module.exports = __toCommonJS(utils_exports);
39
39
  var __import_meta_url = typeof document === "undefined" ? new (require("url".replace("", ""))).URL("file:" + __filename).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
40
+ const import_meta = {};
40
41
  var import_shared = require("@zwave-js/shared");
41
- var import_promises = __toESM(require("node:fs/promises"), 1);
42
- var import_node_module = require("node:module");
43
- var import_node_path = __toESM(require("node:path"), 1);
42
+ var import_node_url = require("node:url");
43
+ var import_pathe = __toESM(require("pathe"), 1);
44
44
  var import_gte = __toESM(require("semver/functions/gte.js"), 1);
45
45
  var import_inc = __toESM(require("semver/functions/inc.js"), 1);
46
46
  var import_lte = __toESM(require("semver/functions/lte.js"), 1);
47
47
  var import_satisfies = __toESM(require("semver/functions/satisfies.js"), 1);
48
48
  var import_valid = __toESM(require("semver/functions/valid.js"), 1);
49
49
  var import_version = require("./_version.js");
50
- const require2 = (0, import_node_module.createRequire)(__import_meta_url);
51
- const configDir = import_node_path.default.resolve(import_node_path.default.dirname(require2.resolve("@zwave-js/config/package.json")), "config");
50
+ const configDir = __import_meta_url.startsWith("file:") ? import_pathe.default.join(import_pathe.default.dirname((0, import_node_url.fileURLToPath)(__import_meta_url)), __import_meta_url.endsWith("src/utils.ts") ? ".." : "../..", "config") : import_meta.resolve("/config");
52
51
  function getExternalConfigDirEnvVariable() {
53
- return process.env.ZWAVEJS_EXTERNAL_CONFIG;
52
+ return (0, import_shared.getenv)("ZWAVEJS_EXTERNAL_CONFIG");
54
53
  }
55
54
  __name(getExternalConfigDirEnvVariable, "getExternalConfigDirEnvVariable");
56
55
  function getDeviceEntryPredicate(manufacturerId, productType, productId, firmwareVersion) {
@@ -68,22 +67,22 @@ function getDeviceEntryPredicate(manufacturerId, productType, productId, firmwar
68
67
  };
69
68
  }
70
69
  __name(getDeviceEntryPredicate, "getDeviceEntryPredicate");
71
- async function syncExternalConfigDir(extConfigDir, logger) {
70
+ async function syncExternalConfigDir(fs, extConfigDir, logger) {
72
71
  if (!extConfigDir)
73
72
  return { success: false };
74
73
  try {
75
- await import_promises.default.mkdir(extConfigDir, { recursive: true });
74
+ await fs.ensureDir(extConfigDir);
76
75
  } catch {
77
76
  logger.print(`Synchronizing external config dir failed - directory could not be created`, "error");
78
77
  return { success: false };
79
78
  }
80
- const externalVersionFilename = import_node_path.default.join(extConfigDir, "version");
79
+ const externalVersionFilename = import_pathe.default.join(extConfigDir, "version");
81
80
  const currentVersion = import_version.PACKAGE_VERSION;
82
81
  const supportedRange = `>=${currentVersion} <${(0, import_inc.default)(currentVersion, "patch")}`;
83
82
  let wipe = false;
84
83
  let externalVersion;
85
84
  try {
86
- externalVersion = await import_promises.default.readFile(externalVersionFilename, "utf8");
85
+ externalVersion = await (0, import_shared.readTextFile)(fs, externalVersionFilename, "utf8");
87
86
  if (!(0, import_valid.default)(externalVersion)) {
88
87
  wipe = true;
89
88
  } else if (!(0, import_satisfies.default)(externalVersion, supportedRange, {
@@ -98,10 +97,10 @@ async function syncExternalConfigDir(extConfigDir, logger) {
98
97
  return { success: true, version: externalVersion };
99
98
  try {
100
99
  logger.print(`Synchronizing external config dir ${extConfigDir}...`);
101
- await import_promises.default.rm(extConfigDir, { recursive: true, force: true });
102
- await import_promises.default.mkdir(extConfigDir, { recursive: true });
103
- await (0, import_shared.copyFilesRecursive)(configDir, extConfigDir, (src) => src.endsWith(".json"));
104
- await import_promises.default.writeFile(externalVersionFilename, currentVersion, "utf8");
100
+ await fs.deleteDir(extConfigDir);
101
+ await fs.ensureDir(extConfigDir);
102
+ await (0, import_shared.copyFilesRecursive)(fs, configDir, extConfigDir, (src) => src.endsWith(".json"));
103
+ await (0, import_shared.writeTextFile)(fs, externalVersionFilename, currentVersion, "utf8");
105
104
  externalVersion = currentVersion;
106
105
  } catch {
107
106
  logger.print(`Synchronizing external config dir failed - using embedded config`, "error");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils.ts", "../../../../node_modules/.store/@alcalzone-esm2cjs-npm-1.4.1-18ec443a54/package/shims/import.meta.url/shim.js"],
4
- "sourcesContent": ["import { copyFilesRecursive, formatId, padVersion } from \"@zwave-js/shared\";\nimport fs from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport semverGte from \"semver/functions/gte.js\";\nimport semverInc from \"semver/functions/inc.js\";\nimport semverLte from \"semver/functions/lte.js\";\nimport semverSatisfies from \"semver/functions/satisfies.js\";\nimport semverValid from \"semver/functions/valid.js\";\nimport type { ConfigLogger } from \"./Logger.js\";\nimport { PACKAGE_VERSION } from \"./_version.js\";\nimport type { DeviceConfigIndexEntry } from \"./devices/DeviceConfig.js\";\n\nconst require = createRequire(import.meta.url);\n\n/** The absolute path of the embedded configuration directory */\nexport const configDir = path.resolve(\n\tpath.dirname(require.resolve(\"@zwave-js/config/package.json\")),\n\t\"config\",\n);\n\n/** The (optional) absolute path of an external configuration directory */\nexport function getExternalConfigDirEnvVariable(): string | undefined {\n\treturn process.env.ZWAVEJS_EXTERNAL_CONFIG;\n}\n\nexport function getDeviceEntryPredicate(\n\tmanufacturerId: number,\n\tproductType: number,\n\tproductId: number,\n\tfirmwareVersion?: string,\n): (entry: DeviceConfigIndexEntry) => boolean {\n\treturn (entry) => {\n\t\tif (entry.manufacturerId !== formatId(manufacturerId)) return false;\n\t\tif (entry.productType !== formatId(productType)) return false;\n\t\tif (entry.productId !== formatId(productId)) return false;\n\t\tif (firmwareVersion != undefined) {\n\t\t\t// A firmware version was given, only look at files with a matching firmware version\n\t\t\treturn (\n\t\t\t\tsemverLte(\n\t\t\t\t\tpadVersion(entry.firmwareVersion.min),\n\t\t\t\t\tpadVersion(firmwareVersion),\n\t\t\t\t)\n\t\t\t\t&& semverGte(\n\t\t\t\t\tpadVersion(entry.firmwareVersion.max),\n\t\t\t\t\tpadVersion(firmwareVersion),\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\treturn true;\n\t};\n}\n\nexport type SyncExternalConfigDirResult =\n\t| {\n\t\tsuccess: false;\n\t}\n\t| {\n\t\tsuccess: true;\n\t\tversion: string;\n\t};\n\n/**\n * Synchronizes or updates the external config directory and returns whether the directory is in a state that can be used\n */\nexport async function syncExternalConfigDir(\n\textConfigDir: string,\n\tlogger: ConfigLogger,\n): Promise<SyncExternalConfigDirResult> {\n\tif (!extConfigDir) return { success: false };\n\n\t// Make sure the config dir exists\n\ttry {\n\t\tawait fs.mkdir(extConfigDir, { recursive: true });\n\t} catch {\n\t\tlogger.print(\n\t\t\t`Synchronizing external config dir failed - directory could not be created`,\n\t\t\t\"error\",\n\t\t);\n\t\treturn { success: false };\n\t}\n\n\tconst externalVersionFilename = path.join(extConfigDir, \"version\");\n\tconst currentVersion = PACKAGE_VERSION;\n\tconst supportedRange = `>=${currentVersion} <${\n\t\tsemverInc(\n\t\t\tcurrentVersion,\n\t\t\t\"patch\",\n\t\t)\n\t}`;\n\n\t// We remember the config version that was copied there in a file called \"version\"\n\t// If that either...\n\t// ...isn't there,\n\t// ...can't be read,\n\t// ...doesn't contain a matching version (>= current && nightly)\n\t// wipe the external config dir and recreate it\n\tlet wipe = false;\n\tlet externalVersion: string | undefined;\n\ttry {\n\t\texternalVersion = await fs.readFile(externalVersionFilename, \"utf8\");\n\t\tif (!semverValid(externalVersion)) {\n\t\t\twipe = true;\n\t\t} else if (\n\t\t\t!semverSatisfies(externalVersion, supportedRange, {\n\t\t\t\tincludePrerelease: true,\n\t\t\t})\n\t\t) {\n\t\t\twipe = true;\n\t\t}\n\t} catch {\n\t\twipe = true;\n\t}\n\n\t// Nothing to wipe, the external dir is good to go\n\tif (!wipe) return { success: true, version: externalVersion! };\n\n\t// Wipe and override the external dir\n\ttry {\n\t\tlogger.print(`Synchronizing external config dir ${extConfigDir}...`);\n\t\tawait fs.rm(extConfigDir, { recursive: true, force: true });\n\t\tawait fs.mkdir(extConfigDir, { recursive: true });\n\t\tawait copyFilesRecursive(\n\t\t\tconfigDir,\n\t\t\textConfigDir,\n\t\t\t(src) => src.endsWith(\".json\"),\n\t\t);\n\t\tawait fs.writeFile(externalVersionFilename, currentVersion, \"utf8\");\n\t\texternalVersion = currentVersion;\n\t} catch {\n\t\t// Something went wrong\n\t\tlogger.print(\n\t\t\t`Synchronizing external config dir failed - using embedded config`,\n\t\t\t\"error\",\n\t\t);\n\t\treturn { success: false };\n\t}\n\n\treturn { success: true, version: externalVersion };\n}\n\nexport function versionInRange(\n\tversion: string,\n\tmin: string,\n\tmax: string,\n): boolean {\n\treturn (\n\t\tsemverGte(padVersion(version), padVersion(min))\n\t\t&& semverLte(padVersion(version), padVersion(max))\n\t);\n}\n", "export const __import_meta_url =\n typeof document === 'undefined' ? new (require('url'.replace('', '')).URL)('file:' + __filename).href :\n (document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href)\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;ACAO,IAAM,oBACX,OAAO,aAAa,cAAc,KAAK,QAAQ,MAAM,QAAQ,IAAI,EAAE,CAAC,GAAE,IAAK,UAAU,UAAU,EAAE,OAC9F,SAAS,iBAAiB,SAAS,cAAc,OAAO,IAAI,IAAI,WAAW,SAAS,OAAO,EAAE;ADFlG,oBAAyD;AACzD,sBAAe;AACf,yBAA8B;AAC9B,uBAAiB;AACjB,iBAAsB;AACtB,iBAAsB;AACtB,iBAAsB;AACtB,uBAA4B;AAC5B,mBAAwB;AAExB,qBAAgC;AAGhC,MAAMA,eAAU,kCAAc,iBAAe;AAGtC,MAAM,YAAY,iBAAAC,QAAK,QAC7B,iBAAAA,QAAK,QAAQD,SAAQ,QAAQ,+BAA+B,CAAC,GAC7D,QAAQ;AAIH,SAAU,kCAA+B;AAC9C,SAAO,QAAQ,IAAI;AACpB;AAFgB;AAIV,SAAU,wBACf,gBACA,aACA,WACA,iBAAwB;AAExB,SAAO,CAAC,UAAS;AAChB,QAAI,MAAM,uBAAmB,wBAAS,cAAc;AAAG,aAAO;AAC9D,QAAI,MAAM,oBAAgB,wBAAS,WAAW;AAAG,aAAO;AACxD,QAAI,MAAM,kBAAc,wBAAS,SAAS;AAAG,aAAO;AACpD,QAAI,mBAAmB,QAAW;AAEjC,iBACC,WAAAE,aACC,0BAAW,MAAM,gBAAgB,GAAG,OACpC,0BAAW,eAAe,CAAC,SAEzB,WAAAC,aACF,0BAAW,MAAM,gBAAgB,GAAG,OACpC,0BAAW,eAAe,CAAC;IAG9B;AACA,WAAO;EACR;AACD;AAzBgB;AAuChB,eAAsB,sBACrB,cACA,QAAoB;AAEpB,MAAI,CAAC;AAAc,WAAO,EAAE,SAAS,MAAK;AAG1C,MAAI;AACH,UAAM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- "names": ["require", "path", "semverLte", "semverGte", "fs", "semverInc", "semverValid", "semverSatisfies"]
4
+ "sourcesContent": ["import {\n\tcopyFilesRecursive,\n\tformatId,\n\tgetenv,\n\tpadVersion,\n\treadTextFile,\n\twriteTextFile,\n} from \"@zwave-js/shared\";\nimport {\n\ttype CopyFile,\n\ttype ManageDirectory,\n\ttype ReadFile,\n\ttype ReadFileSystemInfo,\n\ttype WriteFile,\n} from \"@zwave-js/shared/bindings\";\nimport { fileURLToPath } from \"node:url\";\nimport path from \"pathe\";\nimport semverGte from \"semver/functions/gte.js\";\nimport semverInc from \"semver/functions/inc.js\";\nimport semverLte from \"semver/functions/lte.js\";\nimport semverSatisfies from \"semver/functions/satisfies.js\";\nimport semverValid from \"semver/functions/valid.js\";\nimport type { ConfigLogger } from \"./Logger.js\";\nimport { PACKAGE_VERSION } from \"./_version.js\";\nimport type { DeviceConfigIndexEntry } from \"./devices/DeviceConfig.js\";\n\n/** The absolute path of the embedded configuration directory */\nexport const configDir = import.meta.url.startsWith(\"file:\")\n\t? path.join(\n\t\tpath.dirname(fileURLToPath(import.meta.url)),\n\t\timport.meta.url.endsWith(\"src/utils.ts\")\n\t\t\t? \"..\"\n\t\t\t: \"../..\",\n\t\t\"config\",\n\t)\n\t: import.meta.resolve(\"/config\");\n\n/** The (optional) absolute path of an external configuration directory */\nexport function getExternalConfigDirEnvVariable(): string | undefined {\n\treturn getenv(\"ZWAVEJS_EXTERNAL_CONFIG\");\n}\n\nexport function getDeviceEntryPredicate(\n\tmanufacturerId: number,\n\tproductType: number,\n\tproductId: number,\n\tfirmwareVersion?: string,\n): (entry: DeviceConfigIndexEntry) => boolean {\n\treturn (entry) => {\n\t\tif (entry.manufacturerId !== formatId(manufacturerId)) return false;\n\t\tif (entry.productType !== formatId(productType)) return false;\n\t\tif (entry.productId !== formatId(productId)) return false;\n\t\tif (firmwareVersion != undefined) {\n\t\t\t// A firmware version was given, only look at files with a matching firmware version\n\t\t\treturn (\n\t\t\t\tsemverLte(\n\t\t\t\t\tpadVersion(entry.firmwareVersion.min),\n\t\t\t\t\tpadVersion(firmwareVersion),\n\t\t\t\t)\n\t\t\t\t&& semverGte(\n\t\t\t\t\tpadVersion(entry.firmwareVersion.max),\n\t\t\t\t\tpadVersion(firmwareVersion),\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\treturn true;\n\t};\n}\n\nexport type SyncExternalConfigDirResult =\n\t| {\n\t\tsuccess: false;\n\t}\n\t| {\n\t\tsuccess: true;\n\t\tversion: string;\n\t};\n\n/**\n * Synchronizes or updates the external config directory and returns whether the directory is in a state that can be used\n */\nexport async function syncExternalConfigDir(\n\tfs: ManageDirectory & ReadFileSystemInfo & ReadFile & CopyFile & WriteFile,\n\textConfigDir: string,\n\tlogger: ConfigLogger,\n): Promise<SyncExternalConfigDirResult> {\n\tif (!extConfigDir) return { success: false };\n\n\t// Make sure the config dir exists\n\ttry {\n\t\tawait fs.ensureDir(extConfigDir);\n\t} catch {\n\t\tlogger.print(\n\t\t\t`Synchronizing external config dir failed - directory could not be created`,\n\t\t\t\"error\",\n\t\t);\n\t\treturn { success: false };\n\t}\n\n\tconst externalVersionFilename = path.join(extConfigDir, \"version\");\n\tconst currentVersion = PACKAGE_VERSION;\n\tconst supportedRange = `>=${currentVersion} <${\n\t\tsemverInc(\n\t\t\tcurrentVersion,\n\t\t\t\"patch\",\n\t\t)\n\t}`;\n\n\t// We remember the config version that was copied there in a file called \"version\"\n\t// If that either...\n\t// ...isn't there,\n\t// ...can't be read,\n\t// ...doesn't contain a matching version (>= current && nightly)\n\t// wipe the external config dir and recreate it\n\tlet wipe = false;\n\tlet externalVersion: string | undefined;\n\ttry {\n\t\texternalVersion = await readTextFile(\n\t\t\tfs,\n\t\t\texternalVersionFilename,\n\t\t\t\"utf8\",\n\t\t);\n\t\tif (!semverValid(externalVersion)) {\n\t\t\twipe = true;\n\t\t} else if (\n\t\t\t!semverSatisfies(externalVersion, supportedRange, {\n\t\t\t\tincludePrerelease: true,\n\t\t\t})\n\t\t) {\n\t\t\twipe = true;\n\t\t}\n\t} catch {\n\t\twipe = true;\n\t}\n\n\t// Nothing to wipe, the external dir is good to go\n\tif (!wipe) return { success: true, version: externalVersion! };\n\n\t// Wipe and override the external dir\n\ttry {\n\t\tlogger.print(`Synchronizing external config dir ${extConfigDir}...`);\n\t\tawait fs.deleteDir(extConfigDir);\n\t\tawait fs.ensureDir(extConfigDir);\n\t\tawait copyFilesRecursive(\n\t\t\tfs,\n\t\t\tconfigDir,\n\t\t\textConfigDir,\n\t\t\t(src) => src.endsWith(\".json\"),\n\t\t);\n\t\tawait writeTextFile(\n\t\t\tfs,\n\t\t\texternalVersionFilename,\n\t\t\tcurrentVersion,\n\t\t\t\"utf8\",\n\t\t);\n\t\texternalVersion = currentVersion;\n\t} catch {\n\t\t// Something went wrong\n\t\tlogger.print(\n\t\t\t`Synchronizing external config dir failed - using embedded config`,\n\t\t\t\"error\",\n\t\t);\n\t\treturn { success: false };\n\t}\n\n\treturn { success: true, version: externalVersion };\n}\n\nexport function versionInRange(\n\tversion: string,\n\tmin: string,\n\tmax: string,\n): boolean {\n\treturn (\n\t\tsemverGte(padVersion(version), padVersion(min))\n\t\t&& semverLte(padVersion(version), padVersion(max))\n\t);\n}\n", "export const __import_meta_url =\n typeof document === 'undefined' ? new (require('url'.replace('', '')).URL)('file:' + __filename).href :\n (document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href)\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;ACAO,IAAM,oBACX,OAAO,aAAa,cAAc,KAAK,QAAQ,MAAM,QAAQ,IAAI,EAAE,CAAC,GAAE,IAAK,UAAU,UAAU,EAAE,OAC9F,SAAS,iBAAiB,SAAS,cAAc,OAAO,IAAI,IAAI,WAAW,SAAS,OAAO,EAAE;ADFlG;AAAA,oBAOO;AAQP,sBAA8B;AAC9B,mBAAiB;AACjB,iBAAsB;AACtB,iBAAsB;AACtB,iBAAs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C,SAAgB,iBAAiB,gBAAgB;MACjD,mBAAmB;KACnB,GACA;AACD,aAAO;IACR;EACD,QAAQ;AACP,WAAO;EACR;AAGA,MAAI,CAAC;AAAM,WAAO,EAAE,SAAS,MAAM,SAAS,gBAAgB;AAG5D,MAAI;AACH,WAAO,MAAM,qCAAqC,YAAY,KAAK;AACnE,UAAM,GAAG,UAAU,YAAY;AAC/B,UAAM,GAAG,UAAU,YAAY;AAC/B,cAAM,kCACL,IACA,WACA,cACA,CAAC,QAAQ,IAAI,SAAS,OAAO,CAAC;AAE/B,cAAM,6BACL,IACA,yBACA,gBACA,MAAM;AAEP,sBAAkB;EACnB,QAAQ;AAEP,WAAO,MACN,oEACA,OAAO;AAER,WAAO,EAAE,SAAS,MAAK;EACxB;AAEA,SAAO,EAAE,SAAS,MAAM,SAAS,gBAAe;AACjD;AArFsB;AAuFhB,SAAU,eACf,SACA,KACA,KAAW;AAEX,aACC,WAAAH,aAAU,0BAAW,OAAO,OAAG,0BAAW,GAAG,CAAC,SAC3C,WAAAD,aAAU,0BAAW,OAAO,OAAG,0BAAW,GAAG,CAAC;AAEnD;AATgB;",
6
+ "names": ["path", "semverLte", "semverGte", "semverInc", "semverValid", "semverSatisfies"]
7
7
  }
@@ -1,16 +1,22 @@
1
- import { ZWaveLogContainer } from "@zwave-js/core";
1
+ import { type LogContainer } from "@zwave-js/core";
2
+ import { type FileSystem } from "@zwave-js/shared/bindings";
2
3
  import { type ManufacturersMap } from "./Manufacturers.js";
3
4
  import { ConditionalDeviceConfig, type DeviceConfig, type DeviceConfigIndex, type FulltextDeviceConfigIndex } from "./devices/DeviceConfig.js";
4
5
  export interface ConfigManagerOptions {
5
- logContainer?: ZWaveLogContainer;
6
+ bindings?: FileSystem;
7
+ logContainer?: LogContainer;
6
8
  deviceConfigPriorityDir?: string;
7
9
  deviceConfigExternalDir?: string;
8
10
  }
9
11
  export declare class ConfigManager {
10
12
  constructor(options?: ConfigManagerOptions);
13
+ private _fs;
14
+ private getFS;
11
15
  private _configVersion;
12
16
  get configVersion(): string;
13
- private logger;
17
+ private _logContainer;
18
+ private _logger;
19
+ private getLogger;
14
20
  private _manufacturers;
15
21
  get manufacturers(): ManufacturersMap;
16
22
  private deviceConfigPriorityDir;