homey-api 3.16.1 → 3.17.0

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.
@@ -5782,12 +5782,6 @@ export class Util {
5782
5782
 
5783
5783
  static encodeUrlSearchParams(params: object): string;
5784
5784
 
5785
- static deepEqual(
5786
- a: any,
5787
-
5788
- b: any,
5789
- ): boolean;
5790
-
5791
5785
  static fetch(
5792
5786
  args: string,
5793
5787
 
@@ -5829,12 +5823,6 @@ export class Util {
5829
5823
  static serializeQueryObject(queryObject: object): string;
5830
5824
 
5831
5825
  static encodeUrlSearchParams(params: object): string;
5832
-
5833
- static deepEqual(
5834
- a: any,
5835
-
5836
- b: any,
5837
- ): boolean;
5838
5826
  }
5839
5827
 
5840
5828
  export class APIDefinition {}
@@ -9212,12 +9200,6 @@ export class Util {
9212
9200
 
9213
9201
  static encodeUrlSearchParams(params: object): string;
9214
9202
 
9215
- static deepEqual(
9216
- a: any,
9217
-
9218
- b: any,
9219
- ): boolean;
9220
-
9221
9203
  static fetch(
9222
9204
  args: string,
9223
9205
 
@@ -9259,12 +9241,6 @@ export class Util {
9259
9241
  static serializeQueryObject(queryObject: object): string;
9260
9242
 
9261
9243
  static encodeUrlSearchParams(params: object): string;
9262
-
9263
- static deepEqual(
9264
- a: any,
9265
-
9266
- b: any,
9267
- ): boolean;
9268
9244
  }
9269
9245
 
9270
9246
  export namespace HomeyAPIV3Cloud {
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  const EventEmitter = require('../../EventEmitter');
4
- const Util = require('../../Util');
5
4
 
6
5
  /**
7
6
  * A superclass for all CRUD Items.
@@ -95,43 +94,14 @@ class Item extends EventEmitter {
95
94
  }
96
95
 
97
96
  __update(properties) {
98
- const oldValues = {};
99
- const newValues = {};
100
- const changedKeys = [];
101
-
102
97
  for (const [key, value] of Object.entries(properties)) {
103
98
  if (key === 'id') continue;
104
-
105
- if (!Util.deepEqual(this[key], value)) {
106
- oldValues[key] = Util.deepClone(this[key]);
107
- newValues[key] = Util.deepClone(value);
108
- changedKeys.push(key);
109
-
110
- this[key] = value;
111
- }
99
+ this[key] = value;
112
100
  }
113
101
 
114
102
  this.__lastUpdated = new Date();
115
103
 
116
- if (changedKeys.length === 0) {
117
- return {
118
- oldValues,
119
- newValues,
120
- changedKeys,
121
- };
122
- }
123
-
124
- this.emit('update', properties, {
125
- oldValues,
126
- newValues,
127
- changedKeys,
128
- });
129
-
130
- return {
131
- oldValues,
132
- newValues,
133
- changedKeys,
134
- };
104
+ this.emit('update', properties);
135
105
  }
136
106
 
137
107
  __delete() {
@@ -531,19 +531,8 @@ class Manager extends EventEmitter {
531
531
 
532
532
  if (this.__cache[ItemClass.ID][props.id]) {
533
533
  const item = this.__cache[ItemClass.ID][props.id];
534
- const {
535
- oldValues,
536
- newValues,
537
- changedKeys,
538
- } = item.__update(props);
539
-
540
- if (changedKeys.length === 0) return;
541
-
542
- return this.emit(event, item, {
543
- oldValues,
544
- newValues,
545
- changedKeys,
546
- });
534
+ item.__update(props);
535
+ return this.emit(event, item);
547
536
  }
548
537
 
549
538
  break;
package/lib/Util.js CHANGED
@@ -338,92 +338,6 @@ class Util {
338
338
  return encodedPairs.join('&');
339
339
  }
340
340
 
341
- /**
342
- * Deep equality check between two values.
343
- * @param {any} a
344
- * @param {any} b
345
- * @returns {boolean}
346
- */
347
- static deepEqual(a, b) {
348
- if (a === b) return true;
349
-
350
- if (
351
- typeof a !== 'object' ||
352
- typeof b !== 'object' ||
353
- a === null ||
354
- b === null
355
- ) {
356
- return false;
357
- }
358
-
359
- const keysA = Object.keys(a);
360
- const keysB = Object.keys(b);
361
-
362
- if (keysA.length !== keysB.length) return false;
363
-
364
- for (const key of keysA) {
365
- if (!keysB.includes(key) || !this.deepEqual(a[key], b[key])) {
366
- return false;
367
- }
368
- }
369
-
370
- return true;
371
- }
372
-
373
- static deepClone(value) {
374
- // Use native structuredClone when available
375
- if (typeof structuredClone === 'function') {
376
- return structuredClone(value);
377
- }
378
-
379
- const seen = new WeakMap();
380
-
381
- function clone(val) {
382
- if (val === null || typeof val !== 'object') {
383
- return val;
384
- }
385
-
386
- if (seen.has(val)) {
387
- return seen.get(val);
388
- }
389
-
390
- if (val instanceof Date) {
391
- return new Date(val);
392
- }
393
-
394
- if (val instanceof Map) {
395
- const map = new Map();
396
- seen.set(val, map);
397
- val.forEach((v, k) => map.set(clone(k), clone(v)));
398
- return map;
399
- }
400
-
401
- if (val instanceof Set) {
402
- const set = new Set();
403
- seen.set(val, set);
404
- val.forEach(v => set.add(clone(v)));
405
- return set;
406
- }
407
-
408
- if (Array.isArray(val)) {
409
- const arr = [];
410
- seen.set(val, arr);
411
- val.forEach((v, i) => arr[i] = clone(v));
412
- return arr;
413
- }
414
-
415
- const obj = {};
416
- seen.set(val, obj);
417
- Object.keys(val).forEach(key => {
418
- obj[key] = clone(val[key]);
419
- });
420
-
421
- return obj;
422
- }
423
-
424
- return clone(value);
425
- }
426
-
427
341
  }
428
342
 
429
343
  module.exports = Util;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homey-api",
3
- "version": "3.16.1",
3
+ "version": "3.17.0",
4
4
  "description": "Homey API",
5
5
  "main": "index.js",
6
6
  "license": "SEE LICENSE",