wip:milestone 0 fixes
Some checks failed
CI/CD Pipeline / unit-tests (push) Failing after 1m16s
CI/CD Pipeline / integration-tests (push) Failing after 2m32s
CI/CD Pipeline / lint (push) Successful in 5m22s
CI/CD Pipeline / e2e-tests (push) Has been skipped
CI/CD Pipeline / build (push) Has been skipped

This commit is contained in:
2026-03-15 12:35:42 +02:00
parent 6708cf28a7
commit cffdf8af86
61266 changed files with 4511646 additions and 1938 deletions

View File

@@ -0,0 +1,76 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.EventManager = void 0;
// Used https://gist.github.com/mudge/5830382 as a starting point.
// See https://github.com/browserify/events/blob/master/events.js for
// the Node.js (https://nodejs.org/api/events.html) polyfill used by webpack.
class EventManager {
constructor() {
this.maxListeners = 20;
this.warnOnce = false;
this.events = {};
}
on(eventName, listener, options = {}) {
let collection = this.events[eventName];
if (!collection) {
collection = {
highPriority: new Map(),
regular: new Map()
};
this.events[eventName] = collection;
}
if (options.isFirst) {
collection.highPriority.set(listener, true);
} else {
collection.regular.set(listener, true);
}
if (process.env.NODE_ENV !== 'production') {
const collectionSize = collection.highPriority.size + collection.regular.size;
if (collectionSize > this.maxListeners && !this.warnOnce) {
this.warnOnce = true;
console.warn([`Possible EventEmitter memory leak detected. ${collectionSize} ${eventName} listeners added.`].join('\n'));
}
}
}
removeListener(eventName, listener) {
if (this.events[eventName]) {
this.events[eventName].regular.delete(listener);
this.events[eventName].highPriority.delete(listener);
}
}
removeAllListeners() {
this.events = {};
}
emit(eventName, ...args) {
const collection = this.events[eventName];
if (!collection) {
return;
}
const highPriorityListeners = Array.from(collection.highPriority.keys());
const regularListeners = Array.from(collection.regular.keys());
for (let i = highPriorityListeners.length - 1; i >= 0; i -= 1) {
const listener = highPriorityListeners[i];
if (collection.highPriority.has(listener)) {
listener.apply(this, args);
}
}
for (let i = 0; i < regularListeners.length; i += 1) {
const listener = regularListeners[i];
if (collection.regular.has(listener)) {
listener.apply(this, args);
}
}
}
once(eventName, listener) {
// eslint-disable-next-line consistent-this
const that = this;
this.on(eventName, function oneTimeListener(...args) {
that.removeListener(eventName, oneTimeListener);
listener.apply(that, args);
});
}
}
exports.EventManager = EventManager;

View File

@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Store = void 0;
class Store {
static create(value) {
return new Store(value);
}
constructor(_value) {
this.value = void 0;
this.listeners = void 0;
this.subscribe = fn => {
this.listeners.add(fn);
return () => {
this.listeners.delete(fn);
};
};
this.getSnapshot = () => {
return this.value;
};
this.update = value => {
this.value = value;
this.listeners.forEach(l => l(value));
};
this.value = _value;
this.listeners = new Set();
}
}
exports.Store = Store;

View File

@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View File

@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.FinalizationRegistryBasedCleanupTracking = void 0;
class FinalizationRegistryBasedCleanupTracking {
constructor() {
this.registry = new FinalizationRegistry(unsubscribe => {
if (typeof unsubscribe === 'function') {
unsubscribe();
}
});
}
register(object, unsubscribe, unregisterToken) {
this.registry.register(object, unsubscribe, unregisterToken);
}
unregister(unregisterToken) {
this.registry.unregister(unregisterToken);
}
// eslint-disable-next-line class-methods-use-this
reset() {}
}
exports.FinalizationRegistryBasedCleanupTracking = FinalizationRegistryBasedCleanupTracking;

View File

@@ -0,0 +1,45 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.TimerBasedCleanupTracking = void 0;
// If no effect ran after this amount of time, we assume that the render was not committed by React
const CLEANUP_TIMER_LOOP_MILLIS = 1000;
class TimerBasedCleanupTracking {
constructor(timeout = CLEANUP_TIMER_LOOP_MILLIS) {
this.timeouts = new Map();
this.cleanupTimeout = CLEANUP_TIMER_LOOP_MILLIS;
this.cleanupTimeout = timeout;
}
register(object, unsubscribe, unregisterToken) {
if (!this.timeouts) {
this.timeouts = new Map();
}
const timeout = setTimeout(() => {
if (typeof unsubscribe === 'function') {
unsubscribe();
}
this.timeouts.delete(unregisterToken.cleanupToken);
}, this.cleanupTimeout);
this.timeouts.set(unregisterToken.cleanupToken, timeout);
}
unregister(unregisterToken) {
const timeout = this.timeouts.get(unregisterToken.cleanupToken);
if (timeout) {
this.timeouts.delete(unregisterToken.cleanupToken);
clearTimeout(timeout);
}
}
reset() {
if (this.timeouts) {
this.timeouts.forEach((value, key) => {
this.unregister({
cleanupToken: key
});
});
this.timeouts = undefined;
}
}
}
exports.TimerBasedCleanupTracking = TimerBasedCleanupTracking;

View File

@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createControllablePromise = createControllablePromise;
function createControllablePromise() {
let resolve;
let reject;
const promise = new Promise((_resolve, _reject) => {
resolve = _resolve;
reject = _reject;
});
promise.resolve = resolve;
promise.reject = reject;
return promise;
}

View File

@@ -0,0 +1,122 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.unstable_resetCreateSelectorCache = exports.createSelectorMemoized = exports.createSelector = void 0;
var _reselect = require("reselect");
var _warning = require("./warning");
const cacheContainer = {
cache: new WeakMap()
};
const missingInstanceIdWarning = (0, _warning.buildWarning)(['MUI: A selector was called without passing the instance ID, which may impact the performance of the grid.', 'To fix, call it with `apiRef`, e.g. `mySelector(apiRef)`, or pass the instance ID explicitly, e.g. `mySelector(state, apiRef.current.instanceId)`.']);
function checkIsAPIRef(value) {
return 'current' in value && 'instanceId' in value.current;
}
const DEFAULT_INSTANCE_ID = {
id: 'default'
};
const createSelector = (a, b, c, d, e, f, ...rest) => {
if (rest.length > 0) {
throw new Error('Unsupported number of selectors');
}
let selector;
if (a && b && c && d && e && f) {
selector = (stateOrApiRef, instanceIdParam) => {
const isAPIRef = checkIsAPIRef(stateOrApiRef);
const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
const va = a(state, instanceId);
const vb = b(state, instanceId);
const vc = c(state, instanceId);
const vd = d(state, instanceId);
const ve = e(state, instanceId);
return f(va, vb, vc, vd, ve);
};
} else if (a && b && c && d && e) {
selector = (stateOrApiRef, instanceIdParam) => {
const isAPIRef = checkIsAPIRef(stateOrApiRef);
const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
const va = a(state, instanceId);
const vb = b(state, instanceId);
const vc = c(state, instanceId);
const vd = d(state, instanceId);
return e(va, vb, vc, vd);
};
} else if (a && b && c && d) {
selector = (stateOrApiRef, instanceIdParam) => {
const isAPIRef = checkIsAPIRef(stateOrApiRef);
const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
const va = a(state, instanceId);
const vb = b(state, instanceId);
const vc = c(state, instanceId);
return d(va, vb, vc);
};
} else if (a && b && c) {
selector = (stateOrApiRef, instanceIdParam) => {
const isAPIRef = checkIsAPIRef(stateOrApiRef);
const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
const va = a(state, instanceId);
const vb = b(state, instanceId);
return c(va, vb);
};
} else if (a && b) {
selector = (stateOrApiRef, instanceIdParam) => {
const isAPIRef = checkIsAPIRef(stateOrApiRef);
const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
const va = a(state, instanceId);
return b(va);
};
} else {
throw new Error('Missing arguments');
}
// We use this property to detect if the selector was created with createSelector
// or it's only a simple function the receives the state and returns part of it.
selector.acceptsApiRef = true;
return selector;
};
exports.createSelector = createSelector;
const createSelectorMemoized = (...args) => {
const selector = (...selectorArgs) => {
const [stateOrApiRef, instanceId] = selectorArgs;
const isAPIRef = checkIsAPIRef(stateOrApiRef);
const cacheKey = isAPIRef ? stateOrApiRef.current.instanceId : instanceId ?? DEFAULT_INSTANCE_ID;
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
if (process.env.NODE_ENV !== 'production') {
if (cacheKey.id === 'default') {
missingInstanceIdWarning();
}
}
const {
cache
} = cacheContainer;
if (cache.get(cacheKey) && cache.get(cacheKey)?.get(args)) {
// We pass the cache key because the called selector might have as
// dependency another selector created with this `createSelector`.
return cache.get(cacheKey)?.get(args)(state, cacheKey);
}
const newSelector = (0, _reselect.createSelector)(...args);
if (!cache.get(cacheKey)) {
cache.set(cacheKey, new Map());
}
cache.get(cacheKey)?.set(args, newSelector);
return newSelector(state, cacheKey);
};
// We use this property to detect if the selector was created with createSelector
// or it's only a simple function the receives the state and returns part of it.
selector.acceptsApiRef = true;
return selector;
};
// eslint-disable-next-line @typescript-eslint/naming-convention
exports.createSelectorMemoized = createSelectorMemoized;
const unstable_resetCreateSelectorCache = () => {
cacheContainer.cache = new WeakMap();
};
exports.unstable_resetCreateSelectorCache = unstable_resetCreateSelectorCache;

View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.doesSupportPreventScroll = doesSupportPreventScroll;
// Based on https://stackoverflow.com/a/59518678
let cachedSupportsPreventScroll;
function doesSupportPreventScroll() {
if (cachedSupportsPreventScroll === undefined) {
document.createElement('div').focus({
get preventScroll() {
cachedSupportsPreventScroll = true;
return false;
}
});
}
return cachedSupportsPreventScroll;
}

View File

@@ -0,0 +1,79 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.findParentElementFromClassName = findParentElementFromClassName;
exports.getActiveElement = void 0;
exports.getGridCellElement = getGridCellElement;
exports.getGridColumnHeaderElement = getGridColumnHeaderElement;
exports.getGridRowElement = getGridRowElement;
exports.getRowEl = getRowEl;
exports.isEventTargetInPortal = isEventTargetInPortal;
exports.isGridCellRoot = isGridCellRoot;
exports.isGridHeaderCellRoot = isGridHeaderCellRoot;
exports.isOverflown = isOverflown;
var _gridClasses = require("../constants/gridClasses");
function isOverflown(element) {
return element.scrollHeight > element.clientHeight || element.scrollWidth > element.clientWidth;
}
function findParentElementFromClassName(elem, className) {
return elem.closest(`.${className}`);
}
function getRowEl(cell) {
if (!cell) {
return null;
}
return findParentElementFromClassName(cell, _gridClasses.gridClasses.row);
}
// TODO remove
function isGridCellRoot(elem) {
return elem != null && elem.classList.contains(_gridClasses.gridClasses.cell);
}
function isGridHeaderCellRoot(elem) {
return elem != null && elem.classList.contains(_gridClasses.gridClasses.columnHeader);
}
function escapeOperandAttributeSelector(operand) {
return operand.replace(/["\\]/g, '\\$&');
}
function getGridColumnHeaderElement(root, field) {
return root.querySelector(`[role="columnheader"][data-field="${escapeOperandAttributeSelector(field)}"]`);
}
function getGridRowElementSelector(id) {
return `.${_gridClasses.gridClasses.row}[data-id="${escapeOperandAttributeSelector(String(id))}"]`;
}
function getGridRowElement(root, id) {
return root.querySelector(getGridRowElementSelector(id));
}
function getGridCellElement(root, {
id,
field
}) {
const rowSelector = getGridRowElementSelector(id);
const cellSelector = `.${_gridClasses.gridClasses.cell}[data-field="${escapeOperandAttributeSelector(field)}"]`;
const selector = `${rowSelector} ${cellSelector}`;
return root.querySelector(selector);
}
// https://www.abeautifulsite.net/posts/finding-the-active-element-in-a-shadow-root/
const getActiveElement = (root = document) => {
const activeEl = root.activeElement;
if (!activeEl) {
return null;
}
if (activeEl.shadowRoot) {
return getActiveElement(activeEl.shadowRoot);
}
return activeEl;
};
exports.getActiveElement = getActiveElement;
function isEventTargetInPortal(event) {
if (
// The target is not an element when triggered by a Select inside the cell
// See https://github.com/mui/material-ui/issues/10534
event.target.nodeType === 1 && !event.currentTarget.contains(event.target)) {
return true;
}
return false;
}

View File

@@ -0,0 +1,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.exportAs = exportAs;
/**
* I have hesitated to use https://github.com/eligrey/FileSaver.js.
* If we get bug reports that this project solves, we should consider using it.
*
* Related resources.
* https://blog.logrocket.com/programmatic-file-downloads-in-the-browser-9a5186298d5c/
* https://github.com/mbrn/filefy/blob/ec4ed0b7415d93be7158c23029f2ea1fa0b8e2d9/src/core/BaseBuilder.ts
* https://unpkg.com/browse/@progress/kendo-file-saver@1.0.7/dist/es/save-as.js
* https://github.com/ag-grid/ag-grid/blob/9565c219b6210aa85fa833c929d0728f9d163a91/community-modules/csv-export/src/csvExport/downloader.ts
*/
function exportAs(blob, extension = 'csv', filename = document.title || 'untitled') {
const fullName = `${filename}.${extension}`;
// Test download attribute first
// https://github.com/eligrey/FileSaver.js/issues/193
if ('download' in HTMLAnchorElement.prototype) {
// Create an object URL for the blob object
const url = URL.createObjectURL(blob);
// Create a new anchor element
const a = document.createElement('a');
a.href = url;
a.download = fullName;
// Programmatically trigger a click on the anchor element
// Useful if you want the download to happen automatically
// Without attaching the anchor element to the DOM
a.click();
// https://github.com/eligrey/FileSaver.js/issues/205
setTimeout(() => {
URL.revokeObjectURL(url);
});
return;
}
throw new Error('MUI: exportAs not supported');
}

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.fastMemo = fastMemo;
var React = _interopRequireWildcard(require("react"));
var _fastObjectShallowCompare = require("./fastObjectShallowCompare");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function fastMemo(component) {
return /*#__PURE__*/React.memo(component, _fastObjectShallowCompare.fastObjectShallowCompare);
}

View File

@@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.fastObjectShallowCompare = fastObjectShallowCompare;
const is = Object.is;
function fastObjectShallowCompare(a, b) {
if (a === b) {
return true;
}
if (!(a instanceof Object) || !(b instanceof Object)) {
return false;
}
let aLength = 0;
let bLength = 0;
/* eslint-disable no-restricted-syntax */
/* eslint-disable guard-for-in */
for (const key in a) {
aLength += 1;
if (!is(a[key], b[key])) {
return false;
}
if (!(key in b)) {
return false;
}
}
/* eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-unused-vars */
for (const _ in b) {
bLength += 1;
}
/* eslint-enable no-restricted-syntax */
/* eslint-enable guard-for-in */
return aLength === bLength;
}

View File

@@ -0,0 +1,20 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getGridLocalization = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
const getGridLocalization = (gridTranslations, coreTranslations) => ({
components: {
MuiDataGrid: {
defaultProps: {
localeText: (0, _extends2.default)({}, gridTranslations, {
MuiTablePagination: coreTranslations?.components?.MuiTablePagination?.defaultProps || {}
})
}
}
}
});
exports.getGridLocalization = getGridLocalization;

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getPublicApiRef = getPublicApiRef;
function getPublicApiRef(apiRef) {
return {
current: apiRef.current.getPublicApi()
};
}

View File

@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View File

@@ -0,0 +1,52 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isPageKeys = exports.isNavigationKey = exports.isMultipleKey = exports.isKeyboardEvent = exports.isHomeOrEndKeys = exports.isHideMenuKey = exports.isEscapeKey = exports.isEnterKey = exports.isDeleteKeys = exports.isCellExitEditModeKeys = exports.isCellEnterEditModeKeys = exports.isCellEditCommitKeys = exports.isArrowKeys = exports.GRID_MULTIPLE_SELECTION_KEYS = exports.GRID_CELL_EXIT_EDIT_MODE_KEYS = exports.GRID_CELL_EDIT_COMMIT_KEYS = void 0;
exports.isPrintableKey = isPrintableKey;
exports.isTabKey = exports.isSpaceKey = void 0;
const isEscapeKey = key => key === 'Escape'; // TODO remove
exports.isEscapeKey = isEscapeKey;
const isEnterKey = key => key === 'Enter'; // TODO remove
exports.isEnterKey = isEnterKey;
const isTabKey = key => key === 'Tab'; // TODO remove
exports.isTabKey = isTabKey;
const isSpaceKey = key => key === ' ';
exports.isSpaceKey = isSpaceKey;
const isArrowKeys = key => key.indexOf('Arrow') === 0;
exports.isArrowKeys = isArrowKeys;
const isHomeOrEndKeys = key => key === 'Home' || key === 'End';
exports.isHomeOrEndKeys = isHomeOrEndKeys;
const isPageKeys = key => key.indexOf('Page') === 0;
exports.isPageKeys = isPageKeys;
const isDeleteKeys = key => key === 'Delete' || key === 'Backspace';
// Non printable keys have a name, e.g. "ArrowRight", see the whole list:
// https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values
// So event.key.length === 1 is often enough.
//
// However, we also need to ignore shortcuts, for example: select all:
// - Windows: Ctrl+A, event.ctrlKey is true
// - macOS: ⌘ Command+A, event.metaKey is true
exports.isDeleteKeys = isDeleteKeys;
function isPrintableKey(event) {
return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
}
const GRID_MULTIPLE_SELECTION_KEYS = exports.GRID_MULTIPLE_SELECTION_KEYS = ['Meta', 'Control', 'Shift'];
const GRID_CELL_EXIT_EDIT_MODE_KEYS = exports.GRID_CELL_EXIT_EDIT_MODE_KEYS = ['Enter', 'Escape', 'Tab'];
const GRID_CELL_EDIT_COMMIT_KEYS = exports.GRID_CELL_EDIT_COMMIT_KEYS = ['Enter', 'Tab'];
const isMultipleKey = key => GRID_MULTIPLE_SELECTION_KEYS.indexOf(key) > -1;
exports.isMultipleKey = isMultipleKey;
const isCellEnterEditModeKeys = event => isEnterKey(event.key) || isDeleteKeys(event.key) || isPrintableKey(event);
exports.isCellEnterEditModeKeys = isCellEnterEditModeKeys;
const isCellExitEditModeKeys = key => GRID_CELL_EXIT_EDIT_MODE_KEYS.indexOf(key) > -1;
exports.isCellExitEditModeKeys = isCellExitEditModeKeys;
const isCellEditCommitKeys = key => GRID_CELL_EDIT_COMMIT_KEYS.indexOf(key) > -1;
exports.isCellEditCommitKeys = isCellEditCommitKeys;
const isNavigationKey = key => isHomeOrEndKeys(key) || isArrowKeys(key) || isPageKeys(key) || isSpaceKey(key);
exports.isNavigationKey = isNavigationKey;
const isKeyboardEvent = event => !!event.key;
exports.isKeyboardEvent = isKeyboardEvent;
const isHideMenuKey = key => isTabKey(key) || isEscapeKey(key);
exports.isHideMenuKey = isHideMenuKey;

View File

@@ -0,0 +1,189 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.clamp = void 0;
exports.deepClone = deepClone;
exports.escapeRegExp = escapeRegExp;
exports.isDeepEqual = isDeepEqual;
exports.isFunction = isFunction;
exports.isNumber = isNumber;
exports.isObject = isObject;
exports.localStorageAvailable = localStorageAvailable;
exports.randomNumberBetween = randomNumberBetween;
function isNumber(value) {
return typeof value === 'number' && !Number.isNaN(value);
}
function isFunction(value) {
return typeof value === 'function';
}
function isObject(value) {
return typeof value === 'object' && value !== null;
}
function localStorageAvailable() {
try {
// Incognito mode might reject access to the localStorage for security reasons.
// window isn't defined on Node.js
// https://stackoverflow.com/questions/16427636/check-if-localstorage-is-available
const key = '__some_random_key_you_are_not_going_to_use__';
window.localStorage.setItem(key, key);
window.localStorage.removeItem(key);
return true;
} catch (err) {
return false;
}
}
function escapeRegExp(value) {
return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
}
/**
* Follows the CSS specification behavior for min and max
* If min > max, then the min have priority
*/
const clamp = (value, min, max) => Math.max(min, Math.min(max, value));
/**
* Based on `fast-deep-equal`
*
* MIT License
*
* Copyright (c) 2017 Evgeny Poberezkin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* We only type the public interface to avoid dozens of `as` in the function.
*/
exports.clamp = clamp;
function isDeepEqual(a, b) {
if (a === b) {
return true;
}
if (a && b && typeof a === 'object' && typeof b === 'object') {
if (a.constructor !== b.constructor) {
return false;
}
if (Array.isArray(a)) {
const length = a.length;
if (length !== b.length) {
return false;
}
for (let i = 0; i < length; i += 1) {
if (!isDeepEqual(a[i], b[i])) {
return false;
}
}
return true;
}
if (a instanceof Map && b instanceof Map) {
if (a.size !== b.size) {
return false;
}
const entriesA = Array.from(a.entries());
for (let i = 0; i < entriesA.length; i += 1) {
if (!b.has(entriesA[i][0])) {
return false;
}
}
for (let i = 0; i < entriesA.length; i += 1) {
const entryA = entriesA[i];
if (!isDeepEqual(entryA[1], b.get(entryA[0]))) {
return false;
}
}
return true;
}
if (a instanceof Set && b instanceof Set) {
if (a.size !== b.size) {
return false;
}
const entries = Array.from(a.entries());
for (let i = 0; i < entries.length; i += 1) {
if (!b.has(entries[i][0])) {
return false;
}
}
return true;
}
if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
const length = a.length;
if (length !== b.length) {
return false;
}
for (let i = 0; i < length; i += 1) {
if (a[i] !== b[i]) {
return false;
}
}
return true;
}
if (a.constructor === RegExp) {
return a.source === b.source && a.flags === b.flags;
}
if (a.valueOf !== Object.prototype.valueOf) {
return a.valueOf() === b.valueOf();
}
if (a.toString !== Object.prototype.toString) {
return a.toString() === b.toString();
}
const keys = Object.keys(a);
const length = keys.length;
if (length !== Object.keys(b).length) {
return false;
}
for (let i = 0; i < length; i += 1) {
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) {
return false;
}
}
for (let i = 0; i < length; i += 1) {
const key = keys[i];
if (!isDeepEqual(a[key], b[key])) {
return false;
}
}
return true;
}
// true if both NaN, false otherwise
// eslint-disable-next-line no-self-compare
return a !== a && b !== b;
}
// Pseudo random number. See https://stackoverflow.com/a/47593316
function mulberry32(a) {
return () => {
/* eslint-disable */
let t = a += 0x6d2b79f5;
t = Math.imul(t ^ t >>> 15, t | 1);
t ^= t + Math.imul(t ^ t >>> 7, t | 61);
return ((t ^ t >>> 14) >>> 0) / 4294967296;
/* eslint-enable */
};
}
function randomNumberBetween(seed, min, max) {
const random = mulberry32(seed);
return () => min + (max - min) * random();
}
function deepClone(obj) {
if (typeof structuredClone === 'function') {
return structuredClone(obj);
}
return JSON.parse(JSON.stringify(obj));
}

View File

@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.wrapWithWarningOnCall = exports.buildWarning = void 0;
const buildWarning = (message, gravity = 'warning') => {
let alreadyWarned = false;
const cleanMessage = Array.isArray(message) ? message.join('\n') : message;
return () => {
if (!alreadyWarned) {
alreadyWarned = true;
if (gravity === 'error') {
console.error(cleanMessage);
} else {
console.warn(cleanMessage);
}
}
};
};
exports.buildWarning = buildWarning;
const wrapWithWarningOnCall = (method, message) => {
if (process.env.NODE_ENV === 'production') {
return method;
}
const warning = buildWarning(message);
return (...args) => {
warning();
return method(...args);
};
};
exports.wrapWithWarningOnCall = wrapWithWarningOnCall;