@mui/x-internals 8.0.0-beta.2 → 8.0.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.
- package/CHANGELOG.md +423 -96
- package/esm/rafThrottle/index.d.ts +1 -0
- package/esm/rafThrottle/index.js +1 -0
- package/esm/rafThrottle/rafThrottle.d.ts +16 -0
- package/esm/rafThrottle/rafThrottle.js +33 -0
- package/esm/types/MuiEvent.d.ts +5 -0
- package/esm/types/index.d.ts +1 -0
- package/esm/types/index.js +1 -0
- package/package.json +3 -11
- package/rafThrottle/index.d.ts +1 -0
- package/rafThrottle/index.js +16 -0
- package/rafThrottle/rafThrottle.d.ts +16 -0
- package/rafThrottle/rafThrottle.js +39 -0
- package/types/MuiEvent.d.ts +5 -0
- package/types/MuiEvent.js +5 -0
- package/types/index.d.ts +1 -0
- package/types/index.js +11 -0
- package/modern/EventManager/EventManager.d.ts +0 -29
- package/modern/EventManager/EventManager.js +0 -69
- package/modern/EventManager/index.d.ts +0 -2
- package/modern/EventManager/index.js +0 -1
- package/modern/fastArrayCompare/fastArrayCompare.d.ts +0 -12
- package/modern/fastArrayCompare/fastArrayCompare.js +0 -31
- package/modern/fastArrayCompare/index.d.ts +0 -1
- package/modern/fastArrayCompare/index.js +0 -1
- package/modern/fastMemo/fastMemo.d.ts +0 -1
- package/modern/fastMemo/fastMemo.js +0 -5
- package/modern/fastMemo/index.d.ts +0 -1
- package/modern/fastMemo/index.js +0 -1
- package/modern/fastObjectShallowCompare/fastObjectShallowCompare.d.ts +0 -5
- package/modern/fastObjectShallowCompare/fastObjectShallowCompare.js +0 -33
- package/modern/fastObjectShallowCompare/index.d.ts +0 -1
- package/modern/fastObjectShallowCompare/index.js +0 -1
- package/modern/forwardRef/forwardRef.d.ts +0 -4
- package/modern/forwardRef/forwardRef.js +0 -15
- package/modern/forwardRef/index.d.ts +0 -1
- package/modern/forwardRef/index.js +0 -1
- package/modern/hash/hash.d.ts +0 -6
- package/modern/hash/hash.js +0 -61
- package/modern/hash/index.d.ts +0 -1
- package/modern/hash/index.js +0 -1
- package/modern/isDeepEqual/index.d.ts +0 -1
- package/modern/isDeepEqual/index.js +0 -1
- package/modern/isDeepEqual/isDeepEqual.d.ts +0 -29
- package/modern/isDeepEqual/isDeepEqual.js +0 -124
- package/modern/isObjectEmpty/index.d.ts +0 -1
- package/modern/isObjectEmpty/index.js +0 -1
- package/modern/isObjectEmpty/isObjectEmpty.d.ts +0 -1
- package/modern/isObjectEmpty/isObjectEmpty.js +0 -7
- package/modern/package.json +0 -1
- package/modern/reactMajor/index.d.ts +0 -2
- package/modern/reactMajor/index.js +0 -2
- package/modern/slots/index.d.ts +0 -2
- package/modern/throttle/index.d.ts +0 -1
- package/modern/throttle/index.js +0 -1
- package/modern/throttle/throttle.d.ts +0 -4
- package/modern/throttle/throttle.js +0 -19
- package/modern/types/AppendKeys.d.ts +0 -11
- package/modern/types/AppendKeys.js +0 -1
- package/modern/types/DefaultizedProps.d.ts +0 -8
- package/modern/types/DefaultizedProps.js +0 -1
- package/modern/types/MakeOptional.d.ts +0 -7
- package/modern/types/MakeOptional.js +0 -1
- package/modern/types/MakeRequired.d.ts +0 -7
- package/modern/types/MakeRequired.js +0 -1
- package/modern/types/PrependKeys.d.ts +0 -11
- package/modern/types/PrependKeys.js +0 -1
- package/modern/types/RefObject.d.ts +0 -8
- package/modern/types/RefObject.js +0 -1
- package/modern/types/SlotComponentPropsFromProps.d.ts +0 -8
- package/modern/types/SlotComponentPropsFromProps.js +0 -1
- package/modern/types/index.d.ts +0 -7
- package/modern/types/index.js +0 -7
- package/modern/useResizeObserver/index.d.ts +0 -1
- package/modern/useResizeObserver/index.js +0 -1
- package/modern/useResizeObserver/useResizeObserver.d.ts +0 -2
- package/modern/useResizeObserver/useResizeObserver.js +0 -36
- package/modern/warning/index.d.ts +0 -1
- package/modern/warning/index.js +0 -1
- package/modern/warning/warning.d.ts +0 -13
- package/modern/warning/warning.js +0 -30
- package/tsconfig.build.tsbuildinfo +0 -1
- /package/{modern/slots/index.js → esm/types/MuiEvent.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./rafThrottle.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./rafThrottle.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface Cancelable {
|
|
2
|
+
clear(): void;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Creates a throttled function that only invokes `fn` at most once per animation frame.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const throttled = rafThrottle((value: number) => console.log(value));
|
|
10
|
+
* window.addEventListener('scroll', (e) => throttled(e.target.scrollTop));
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @param fn Callback function
|
|
14
|
+
* @return The `requestAnimationFrame` throttled function
|
|
15
|
+
*/
|
|
16
|
+
export declare function rafThrottle<T extends (...args: any[]) => any>(fn: T): T & Cancelable;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a throttled function that only invokes `fn` at most once per animation frame.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* const throttled = rafThrottle((value: number) => console.log(value));
|
|
7
|
+
* window.addEventListener('scroll', (e) => throttled(e.target.scrollTop));
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* @param fn Callback function
|
|
11
|
+
* @return The `requestAnimationFrame` throttled function
|
|
12
|
+
*/
|
|
13
|
+
export function rafThrottle(fn) {
|
|
14
|
+
let lastArgs;
|
|
15
|
+
let rafRef;
|
|
16
|
+
const later = () => {
|
|
17
|
+
rafRef = null;
|
|
18
|
+
fn(...lastArgs);
|
|
19
|
+
};
|
|
20
|
+
function throttled(...args) {
|
|
21
|
+
lastArgs = args;
|
|
22
|
+
if (!rafRef) {
|
|
23
|
+
rafRef = requestAnimationFrame(later);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
throttled.clear = () => {
|
|
27
|
+
if (rafRef) {
|
|
28
|
+
cancelAnimationFrame(rafRef);
|
|
29
|
+
rafRef = null;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
return throttled;
|
|
33
|
+
}
|
package/esm/types/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from "./AppendKeys.js";
|
|
|
2
2
|
export * from "./DefaultizedProps.js";
|
|
3
3
|
export * from "./MakeOptional.js";
|
|
4
4
|
export * from "./MakeRequired.js";
|
|
5
|
+
export * from "./MuiEvent.js";
|
|
5
6
|
export * from "./PrependKeys.js";
|
|
6
7
|
export * from "./RefObject.js";
|
|
7
8
|
export * from "./SlotComponentPropsFromProps.js";
|
package/esm/types/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from "./AppendKeys.js";
|
|
|
2
2
|
export * from "./DefaultizedProps.js";
|
|
3
3
|
export * from "./MakeOptional.js";
|
|
4
4
|
export * from "./MakeRequired.js";
|
|
5
|
+
export * from "./MuiEvent.js";
|
|
5
6
|
export * from "./PrependKeys.js";
|
|
6
7
|
export * from "./RefObject.js";
|
|
7
8
|
export * from "./SlotComponentPropsFromProps.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-internals",
|
|
3
|
-
"version": "8.0.0
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "Utility functions for the MUI X packages (internal use only).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"directory": "packages/x-internals"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@babel/runtime": "^7.
|
|
35
|
-
"@mui/utils": "^7.0.
|
|
34
|
+
"@babel/runtime": "^7.27.0",
|
|
35
|
+
"@mui/utils": "^7.0.2"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"react": "^17.0.0 || ^18.0.0 || ^19.0.0"
|
|
@@ -51,10 +51,6 @@
|
|
|
51
51
|
"import": {
|
|
52
52
|
"types": "./esm/index.d.ts",
|
|
53
53
|
"default": "./esm/index.js"
|
|
54
|
-
},
|
|
55
|
-
"mui-modern": {
|
|
56
|
-
"types": "./modern/index.d.ts",
|
|
57
|
-
"default": "./modern/index.js"
|
|
58
54
|
}
|
|
59
55
|
},
|
|
60
56
|
"./*": {
|
|
@@ -65,10 +61,6 @@
|
|
|
65
61
|
"import": {
|
|
66
62
|
"types": "./esm/*/index.d.ts",
|
|
67
63
|
"default": "./esm/*/index.js"
|
|
68
|
-
},
|
|
69
|
-
"mui-modern": {
|
|
70
|
-
"types": "./modern/*/index.d.ts",
|
|
71
|
-
"default": "./modern/*/index.js"
|
|
72
64
|
}
|
|
73
65
|
},
|
|
74
66
|
"./esm": null,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./rafThrottle.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _rafThrottle = require("./rafThrottle");
|
|
7
|
+
Object.keys(_rafThrottle).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _rafThrottle[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _rafThrottle[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface Cancelable {
|
|
2
|
+
clear(): void;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Creates a throttled function that only invokes `fn` at most once per animation frame.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const throttled = rafThrottle((value: number) => console.log(value));
|
|
10
|
+
* window.addEventListener('scroll', (e) => throttled(e.target.scrollTop));
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @param fn Callback function
|
|
14
|
+
* @return The `requestAnimationFrame` throttled function
|
|
15
|
+
*/
|
|
16
|
+
export declare function rafThrottle<T extends (...args: any[]) => any>(fn: T): T & Cancelable;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.rafThrottle = rafThrottle;
|
|
7
|
+
/**
|
|
8
|
+
* Creates a throttled function that only invokes `fn` at most once per animation frame.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const throttled = rafThrottle((value: number) => console.log(value));
|
|
13
|
+
* window.addEventListener('scroll', (e) => throttled(e.target.scrollTop));
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param fn Callback function
|
|
17
|
+
* @return The `requestAnimationFrame` throttled function
|
|
18
|
+
*/
|
|
19
|
+
function rafThrottle(fn) {
|
|
20
|
+
let lastArgs;
|
|
21
|
+
let rafRef;
|
|
22
|
+
const later = () => {
|
|
23
|
+
rafRef = null;
|
|
24
|
+
fn(...lastArgs);
|
|
25
|
+
};
|
|
26
|
+
function throttled(...args) {
|
|
27
|
+
lastArgs = args;
|
|
28
|
+
if (!rafRef) {
|
|
29
|
+
rafRef = requestAnimationFrame(later);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
throttled.clear = () => {
|
|
33
|
+
if (rafRef) {
|
|
34
|
+
cancelAnimationFrame(rafRef);
|
|
35
|
+
rafRef = null;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
return throttled;
|
|
39
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from "./AppendKeys.js";
|
|
|
2
2
|
export * from "./DefaultizedProps.js";
|
|
3
3
|
export * from "./MakeOptional.js";
|
|
4
4
|
export * from "./MakeRequired.js";
|
|
5
|
+
export * from "./MuiEvent.js";
|
|
5
6
|
export * from "./PrependKeys.js";
|
|
6
7
|
export * from "./RefObject.js";
|
|
7
8
|
export * from "./SlotComponentPropsFromProps.js";
|
package/types/index.js
CHANGED
|
@@ -47,6 +47,17 @@ Object.keys(_MakeRequired).forEach(function (key) {
|
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
|
+
var _MuiEvent = require("./MuiEvent");
|
|
51
|
+
Object.keys(_MuiEvent).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _MuiEvent[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _MuiEvent[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
50
61
|
var _PrependKeys = require("./PrependKeys");
|
|
51
62
|
Object.keys(_PrependKeys).forEach(function (key) {
|
|
52
63
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export type EventListener = (...args: any[]) => void;
|
|
2
|
-
export interface EventListenerOptions {
|
|
3
|
-
isFirst?: boolean;
|
|
4
|
-
}
|
|
5
|
-
interface EventListenerCollection {
|
|
6
|
-
/**
|
|
7
|
-
* List of listeners to run before the others
|
|
8
|
-
* They are run in the opposite order of the registration order
|
|
9
|
-
*/
|
|
10
|
-
highPriority: Map<EventListener, true>;
|
|
11
|
-
/**
|
|
12
|
-
* List of events to run after the high priority listeners
|
|
13
|
-
* They are run in the registration order
|
|
14
|
-
*/
|
|
15
|
-
regular: Map<EventListener, true>;
|
|
16
|
-
}
|
|
17
|
-
export declare class EventManager {
|
|
18
|
-
maxListeners: number;
|
|
19
|
-
warnOnce: boolean;
|
|
20
|
-
events: {
|
|
21
|
-
[eventName: string]: EventListenerCollection;
|
|
22
|
-
};
|
|
23
|
-
on(eventName: string, listener: EventListener, options?: EventListenerOptions): void;
|
|
24
|
-
removeListener(eventName: string, listener: EventListener): void;
|
|
25
|
-
removeAllListeners(): void;
|
|
26
|
-
emit(eventName: string, ...args: any[]): void;
|
|
27
|
-
once(eventName: string, listener: EventListener): void;
|
|
28
|
-
}
|
|
29
|
-
export {};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// Used https://gist.github.com/mudge/5830382 as a starting point.
|
|
2
|
-
// See https://github.com/browserify/events/blob/master/events.js for
|
|
3
|
-
// the Node.js (https://nodejs.org/api/events.html) polyfill used by webpack.
|
|
4
|
-
export class EventManager {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.maxListeners = 20;
|
|
7
|
-
this.warnOnce = false;
|
|
8
|
-
this.events = {};
|
|
9
|
-
}
|
|
10
|
-
on(eventName, listener, options = {}) {
|
|
11
|
-
let collection = this.events[eventName];
|
|
12
|
-
if (!collection) {
|
|
13
|
-
collection = {
|
|
14
|
-
highPriority: new Map(),
|
|
15
|
-
regular: new Map()
|
|
16
|
-
};
|
|
17
|
-
this.events[eventName] = collection;
|
|
18
|
-
}
|
|
19
|
-
if (options.isFirst) {
|
|
20
|
-
collection.highPriority.set(listener, true);
|
|
21
|
-
} else {
|
|
22
|
-
collection.regular.set(listener, true);
|
|
23
|
-
}
|
|
24
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
25
|
-
const collectionSize = collection.highPriority.size + collection.regular.size;
|
|
26
|
-
if (collectionSize > this.maxListeners && !this.warnOnce) {
|
|
27
|
-
this.warnOnce = true;
|
|
28
|
-
console.warn([`Possible EventEmitter memory leak detected. ${collectionSize} ${eventName} listeners added.`].join('\n'));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
removeListener(eventName, listener) {
|
|
33
|
-
if (this.events[eventName]) {
|
|
34
|
-
this.events[eventName].regular.delete(listener);
|
|
35
|
-
this.events[eventName].highPriority.delete(listener);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
removeAllListeners() {
|
|
39
|
-
this.events = {};
|
|
40
|
-
}
|
|
41
|
-
emit(eventName, ...args) {
|
|
42
|
-
const collection = this.events[eventName];
|
|
43
|
-
if (!collection) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const highPriorityListeners = Array.from(collection.highPriority.keys());
|
|
47
|
-
const regularListeners = Array.from(collection.regular.keys());
|
|
48
|
-
for (let i = highPriorityListeners.length - 1; i >= 0; i -= 1) {
|
|
49
|
-
const listener = highPriorityListeners[i];
|
|
50
|
-
if (collection.highPriority.has(listener)) {
|
|
51
|
-
listener.apply(this, args);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
for (let i = 0; i < regularListeners.length; i += 1) {
|
|
55
|
-
const listener = regularListeners[i];
|
|
56
|
-
if (collection.regular.has(listener)) {
|
|
57
|
-
listener.apply(this, args);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
once(eventName, listener) {
|
|
62
|
-
// eslint-disable-next-line consistent-this
|
|
63
|
-
const that = this;
|
|
64
|
-
this.on(eventName, function oneTimeListener(...args) {
|
|
65
|
-
that.removeListener(eventName, oneTimeListener);
|
|
66
|
-
listener.apply(that, args);
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { EventManager } from "./EventManager.js";
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A fast array comparison function that compares two arrays for equality.
|
|
3
|
-
*
|
|
4
|
-
* Assumes that the arrays are ordered and contain only primitive values.
|
|
5
|
-
*
|
|
6
|
-
* It is faster than `fastObjectShallowCompare` for arrays.
|
|
7
|
-
*
|
|
8
|
-
* Returns true for instance equality, even if inputs are not arrays.
|
|
9
|
-
*
|
|
10
|
-
* @returns true if arrays contain the same elements in the same order, false otherwise.
|
|
11
|
-
*/
|
|
12
|
-
export declare function fastArrayCompare<T extends any>(a: T, b: T): boolean;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A fast array comparison function that compares two arrays for equality.
|
|
3
|
-
*
|
|
4
|
-
* Assumes that the arrays are ordered and contain only primitive values.
|
|
5
|
-
*
|
|
6
|
-
* It is faster than `fastObjectShallowCompare` for arrays.
|
|
7
|
-
*
|
|
8
|
-
* Returns true for instance equality, even if inputs are not arrays.
|
|
9
|
-
*
|
|
10
|
-
* @returns true if arrays contain the same elements in the same order, false otherwise.
|
|
11
|
-
*/
|
|
12
|
-
export function fastArrayCompare(a, b) {
|
|
13
|
-
if (a === b) {
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
if (!Array.isArray(a) || !Array.isArray(b)) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
let i = a.length;
|
|
20
|
-
if (i !== b.length) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// eslint-disable-next-line no-plusplus
|
|
25
|
-
while (i--) {
|
|
26
|
-
if (a[i] !== b[i]) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { fastArrayCompare } from "./fastArrayCompare.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { fastArrayCompare } from "./fastArrayCompare.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function fastMemo<T>(component: T): T;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { fastMemo } from "./fastMemo.js";
|
package/modern/fastMemo/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { fastMemo } from "./fastMemo.js";
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
const is = Object.is;
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Fast shallow compare for objects.
|
|
5
|
-
* @returns true if objects are equal.
|
|
6
|
-
*/
|
|
7
|
-
export function fastObjectShallowCompare(a, b) {
|
|
8
|
-
if (a === b) {
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
if (!(a instanceof Object) || !(b instanceof Object)) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
let aLength = 0;
|
|
15
|
-
let bLength = 0;
|
|
16
|
-
|
|
17
|
-
/* eslint-disable guard-for-in */
|
|
18
|
-
for (const key in a) {
|
|
19
|
-
aLength += 1;
|
|
20
|
-
if (!is(a[key], b[key])) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
if (!(key in b)) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/* eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-unused-vars */
|
|
29
|
-
for (const _ in b) {
|
|
30
|
-
bLength += 1;
|
|
31
|
-
}
|
|
32
|
-
return aLength === bLength;
|
|
33
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { fastObjectShallowCompare } from "./fastObjectShallowCompare.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { fastObjectShallowCompare } from "./fastObjectShallowCompare.js";
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
export declare const forwardRef: <T, P = {}>(render: React.ForwardRefRenderFunction<T, P & {
|
|
3
|
-
ref: React.Ref<T>;
|
|
4
|
-
}>) => React.ForwardRefExoticComponent<P> | React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<T>>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import reactMajor from "../reactMajor/index.js";
|
|
3
|
-
|
|
4
|
-
// Compatibility shim that ensures stable props object for forwardRef components
|
|
5
|
-
// Fixes https://github.com/facebook/react/issues/31613
|
|
6
|
-
// We ensure that the ref is always present in the props object (even if that's not the case for older versions of React) to avoid the footgun of spreading props over the ref in the newer versions of React.
|
|
7
|
-
// Footgun: <Component ref={ref} {...props} /> will break past React 19, but the types will now warn us that we should use <Component {...props} ref={ref} /> instead.
|
|
8
|
-
export const forwardRef = render => {
|
|
9
|
-
if (reactMajor >= 19) {
|
|
10
|
-
const Component = props => render(props, props.ref ?? null);
|
|
11
|
-
Component.displayName = render.displayName ?? render.name;
|
|
12
|
-
return Component;
|
|
13
|
-
}
|
|
14
|
-
return /*#__PURE__*/React.forwardRef(render);
|
|
15
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./forwardRef.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./forwardRef.js";
|
package/modern/hash/hash.d.ts
DELETED
package/modern/hash/hash.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
const encoder = new TextEncoder();
|
|
2
|
-
|
|
3
|
-
// bufferLength must be a multiple of 4 to satisfy Int32Array constraints
|
|
4
|
-
let bufferLength = 2 * 1024;
|
|
5
|
-
let buffer = new ArrayBuffer(bufferLength);
|
|
6
|
-
let uint8View = new Uint8Array(buffer);
|
|
7
|
-
let int32View = new Int32Array(buffer);
|
|
8
|
-
export const hash = xxh;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Returns an xxh hash of `input` formatted as a decimal string.
|
|
12
|
-
*/
|
|
13
|
-
// prettier-ignore
|
|
14
|
-
function xxh(input) {
|
|
15
|
-
/* eslint-disable no-bitwise */
|
|
16
|
-
|
|
17
|
-
// Worst-case scenario: full string of 2-byte characters
|
|
18
|
-
const requiredLength = input.length * 2;
|
|
19
|
-
if (requiredLength > bufferLength) {
|
|
20
|
-
// buffer.resize() is only available in recent browsers, so we re-allocate
|
|
21
|
-
// a new and views
|
|
22
|
-
bufferLength = requiredLength + (4 - requiredLength % 4);
|
|
23
|
-
buffer = new ArrayBuffer(bufferLength);
|
|
24
|
-
uint8View = new Uint8Array(buffer);
|
|
25
|
-
int32View = new Int32Array(buffer);
|
|
26
|
-
}
|
|
27
|
-
const length8 = encoder.encodeInto(input, uint8View).written;
|
|
28
|
-
const seed = 0;
|
|
29
|
-
const len = length8 | 0;
|
|
30
|
-
let i = 0;
|
|
31
|
-
let h = (seed + len | 0) + 0x165667B1 | 0;
|
|
32
|
-
if (len < 16) {
|
|
33
|
-
for (; (i + 3 | 0) < len; i = i + 4 | 0) {
|
|
34
|
-
h = Math.imul(rotl32(h + Math.imul(int32View[i] | 0, 0xC2B2AE3D) | 0, 17) | 0, 0x27D4EB2F);
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
let v0 = seed + 0x24234428 | 0;
|
|
38
|
-
let v1 = seed + 0x85EBCA77 | 0;
|
|
39
|
-
let v2 = seed;
|
|
40
|
-
let v3 = seed - 0x9E3779B1 | 0;
|
|
41
|
-
for (; (i + 15 | 0) < len; i = i + 16 | 0) {
|
|
42
|
-
v0 = Math.imul(rotl32(v0 + Math.imul(int32View[i + 0 | 0] | 0, 0x85EBCA77) | 0, 13) | 0, 0x9E3779B1);
|
|
43
|
-
v1 = Math.imul(rotl32(v1 + Math.imul(int32View[i + 4 | 0] | 0, 0x85EBCA77) | 0, 13) | 0, 0x9E3779B1);
|
|
44
|
-
v2 = Math.imul(rotl32(v2 + Math.imul(int32View[i + 8 | 0] | 0, 0x85EBCA77) | 0, 13) | 0, 0x9E3779B1);
|
|
45
|
-
v3 = Math.imul(rotl32(v3 + Math.imul(int32View[i + 12 | 0] | 0, 0x85EBCA77) | 0, 13) | 0, 0x9E3779B1);
|
|
46
|
-
}
|
|
47
|
-
h = (((rotl32(v0, 1) | 0 + rotl32(v1, 7) | 0) + rotl32(v2, 12) | 0) + rotl32(v3, 18) | 0) + len | 0;
|
|
48
|
-
for (; (i + 3 | 0) < len; i = i + 4 | 0) {
|
|
49
|
-
h = Math.imul(rotl32(h + Math.imul(int32View[i] | 0, 0xC2B2AE3D) | 0, 17) | 0, 0x27D4EB2F);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
for (; i < len; i = i + 1 | 0) {
|
|
53
|
-
h = Math.imul(rotl32(h + Math.imul(uint8View[i] | 0, 0x165667B1) | 0, 11) | 0, 0x9E3779B1);
|
|
54
|
-
}
|
|
55
|
-
h = Math.imul(h ^ h >>> 15, 0x85EBCA77);
|
|
56
|
-
h = Math.imul(h ^ h >>> 13, 0xC2B2AE3D);
|
|
57
|
-
return ((h ^ h >>> 16) >>> 0).toString();
|
|
58
|
-
}
|
|
59
|
-
function rotl32(x, r) {
|
|
60
|
-
return x << r | x >>> 32 - r;
|
|
61
|
-
}
|
package/modern/hash/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./hash.js";
|
package/modern/hash/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./hash.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./isDeepEqual.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./isDeepEqual.js";
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Based on `fast-deep-equal`
|
|
3
|
-
*
|
|
4
|
-
* MIT License
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2017 Evgeny Poberezkin
|
|
7
|
-
*
|
|
8
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
10
|
-
* in the Software without restriction, including without limitation the rights
|
|
11
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
-
* furnished to do so, subject to the following conditions:
|
|
14
|
-
*
|
|
15
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
-
* copies or substantial portions of the Software.
|
|
17
|
-
*
|
|
18
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
-
* SOFTWARE.
|
|
25
|
-
*/
|
|
26
|
-
/**
|
|
27
|
-
* Check if two values are deeply equal.
|
|
28
|
-
*/
|
|
29
|
-
export declare function isDeepEqual<T>(actual: any, expected: T): actual is T;
|