the-react 1.0.4 → 1.0.6
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.
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/jsx-runtime/index.ts +16 -4
package/package.json
CHANGED
package/src/index.ts
CHANGED
package/src/jsx-runtime/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
JSX,
|
|
6
6
|
JSXElement,
|
|
7
7
|
JSXElementType
|
|
8
|
-
} from "
|
|
8
|
+
} from "./../types/jsx"
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Нормализует children в плоский массив JSX-элементов и строк.
|
|
@@ -93,9 +93,21 @@ function jsx<PropsType extends ComponentPropsType>(
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
function stableHash(obj: any): string {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
const computeHash = (str: string): string => {
|
|
97
|
+
let hash = 5381;
|
|
98
|
+
for (let i = 0; i < str.length; i++) {
|
|
99
|
+
hash = (hash * 33) ^ str.charCodeAt(i);
|
|
100
|
+
}
|
|
101
|
+
return (hash >>> 0).toString(16).slice(0, 8);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
try {
|
|
105
|
+
const json = JSON.stringify(obj, Object.keys(obj).sort());
|
|
106
|
+
return computeHash(json);
|
|
107
|
+
} catch (err) {
|
|
108
|
+
const fallbackStr = `error:${err ?? 'unknown'}:${typeof obj}:${String(obj)}`;
|
|
109
|
+
return computeHash(fallbackStr);
|
|
110
|
+
}
|
|
99
111
|
}
|
|
100
112
|
|
|
101
113
|
export type { JSX };
|