@microsoft/fast-html 1.0.0-alpha.32 → 1.0.0-alpha.33

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.
@@ -165,4 +165,20 @@ export declare function getRootPropertyName(rootPropertyName: string | null, pat
165
165
  * @returns null, or a custom element name and attribute name
166
166
  */
167
167
  export declare function getChildrenMap(previousString: string | null): ChildrenMap | null;
168
+ /**
169
+ * Deeply compares two objects for equality.
170
+ *
171
+ * @param obj1 - First object to compare
172
+ * @param obj2 - Second object to compare
173
+ * @returns True if the objects are deeply equal, false otherwise
174
+ */
175
+ export declare function deepEqual(obj1: any, obj2: any): boolean;
176
+ /**
177
+ * Deeply merges the source object into the target object.
178
+ *
179
+ * @param target - The target object to merge into
180
+ * @param source - The source object to merge from
181
+ * @returns void
182
+ */
183
+ export declare function deepMerge(target: any, source: any): void;
168
184
  export {};
@@ -970,3 +970,104 @@ function getAttributeName(previousString) {
970
970
  }
971
971
  return attributeName;
972
972
  }
973
+ /**
974
+ * Deeply compares two objects for equality.
975
+ *
976
+ * @param obj1 - First object to compare
977
+ * @param obj2 - Second object to compare
978
+ * @returns True if the objects are deeply equal, false otherwise
979
+ */
980
+ export function deepEqual(obj1, obj2) {
981
+ if (Object.is(obj1, obj2)) {
982
+ return true;
983
+ }
984
+ if (obj1 == null || obj2 == null) {
985
+ return false;
986
+ }
987
+ const type1 = typeof obj1;
988
+ const type2 = typeof obj2;
989
+ if (type1 !== type2 || type1 !== "object") {
990
+ return false;
991
+ }
992
+ const isArray1 = Array.isArray(obj1);
993
+ const isArray2 = Array.isArray(obj2);
994
+ if (isArray1 !== isArray2) {
995
+ return false;
996
+ }
997
+ if (isArray1) {
998
+ const len = obj1.length;
999
+ if (len !== obj2.length) {
1000
+ return false;
1001
+ }
1002
+ for (let i = 0; i < len; i++) {
1003
+ if (!deepEqual(obj1[i], obj2[i])) {
1004
+ return false;
1005
+ }
1006
+ }
1007
+ return true;
1008
+ }
1009
+ const hasOwn = Object.prototype.hasOwnProperty;
1010
+ let keyCount = 0;
1011
+ for (const key in obj1) {
1012
+ if (hasOwn.call(obj1, key)) {
1013
+ keyCount++;
1014
+ if (!hasOwn.call(obj2, key) || !deepEqual(obj1[key], obj2[key])) {
1015
+ return false;
1016
+ }
1017
+ }
1018
+ }
1019
+ let obj2KeyCount = 0;
1020
+ for (const key in obj2) {
1021
+ if (hasOwn.call(obj2, key)) {
1022
+ obj2KeyCount++;
1023
+ }
1024
+ }
1025
+ return keyCount === obj2KeyCount;
1026
+ }
1027
+ /**
1028
+ * Deeply merges the source object into the target object.
1029
+ *
1030
+ * @param target - The target object to merge into
1031
+ * @param source - The source object to merge from
1032
+ * @returns void
1033
+ */
1034
+ export function deepMerge(target, source) {
1035
+ const hasOwn = Object.prototype.hasOwnProperty;
1036
+ for (const key in source) {
1037
+ if (!hasOwn.call(source, key)) {
1038
+ continue;
1039
+ }
1040
+ const sourceValue = source[key];
1041
+ if (sourceValue === void 0) {
1042
+ continue;
1043
+ }
1044
+ const targetValue = target[key];
1045
+ if (deepEqual(targetValue, sourceValue)) {
1046
+ continue;
1047
+ }
1048
+ const isSourceArray = Array.isArray(sourceValue);
1049
+ if (isSourceArray) {
1050
+ const isTargetArray = Array.isArray(targetValue);
1051
+ const clonedItems = sourceValue.map((item) => item && typeof item === "object" ? Object.assign({}, item) : item);
1052
+ if (isTargetArray) {
1053
+ // Use splice to maintain observable array tracking
1054
+ targetValue.splice(0, targetValue.length, ...clonedItems);
1055
+ }
1056
+ else {
1057
+ // Target isn't an array, replace it
1058
+ target[key] = clonedItems;
1059
+ }
1060
+ continue;
1061
+ }
1062
+ if (sourceValue && typeof sourceValue === "object") {
1063
+ if (!targetValue ||
1064
+ typeof targetValue !== "object" ||
1065
+ Array.isArray(targetValue)) {
1066
+ target[key] = {};
1067
+ }
1068
+ deepMerge(target[key], sourceValue);
1069
+ continue;
1070
+ }
1071
+ target[key] = sourceValue;
1072
+ }
1073
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/fast-html",
3
- "version": "1.0.0-alpha.32",
3
+ "version": "1.0.0-alpha.33",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Microsoft",
@@ -47,6 +47,10 @@
47
47
  "types": "./dist/dts/index.d.ts",
48
48
  "default": "./dist/esm/index.js"
49
49
  },
50
+ "./utilities.js": {
51
+ "types": "./dist/dts/components/utilities.d.ts",
52
+ "default": "./dist/esm/components/utilities.js"
53
+ },
50
54
  "./rules/*.yml": "./rules/*.yml",
51
55
  "./package.json": "./package.json"
52
56
  },
@@ -54,12 +58,12 @@
54
58
  "./dist/esm/index.js"
55
59
  ],
56
60
  "peerDependencies": {
57
- "@microsoft/fast-element": "^2.8.2"
61
+ "@microsoft/fast-element": "^2.8.3"
58
62
  },
59
63
  "devDependencies": {
60
64
  "@ast-grep/cli": "^0.37.0",
61
65
  "@microsoft/api-extractor": "^7.47.0",
62
- "@microsoft/fast-element": "^2.8.2",
66
+ "@microsoft/fast-element": "^2.8.3",
63
67
  "@types/express": "^4.17.21",
64
68
  "@types/node": "^17.0.17",
65
69
  "typescript": "~5.3.0"