ui: update polyfill

This commit is contained in:
undefined committed 2024-06-29 22:46:54 +08:00
1 parent 4ebd4235a5
commit 979b8ce5af
7 files changed
+44 -13

No files matched your search

+2 -2
View File
@@ -23,7 +23,7 @@ const {
list,
targets,
} = compat({
targets: '> 0.5%, chrome 80',
targets: '> 1%, chrome 70, firefox 60, safari 16, ios_saf 16, not ie 11, not op_mini all',
modules: [
'core-js/stable',
],
@@ -290,7 +290,7 @@ export default async function (env: { watch?: boolean, production?: boolean, mea
rewriteSources: (source) => source.replace('@hydrooj/ui-default/../../node_modules/', ''),
},
release: (process.env.CI && isNew) ? {
name: version,
name: `hydro-web@${version}`,
uploadLegacySourcemaps: root('public'),
} : {},
}),
@@ -11,10 +11,7 @@ const CustomSelectAutoComplete = React.forwardRef<any, any>((props, ref) => (
<AutoComplete<DefaultProps>
ref={ref as any}
fetchItems={(keys) => props.data.filter((i) => (i._id ? keys.includes(i._id) : keys.includes(i)))}
queryItems={(query) => props.data.filter((i) => (i.name
? i.name.toLowerCase().match(query.toLowerCase())
: i.toString().toLowerCase().match(query.toLowerCase())
))}
queryItems={(query) => props.data.filter((i) => (i.name || i).toString().toLowerCase().includes(query.toLowerCase()))}
itemText={(item) => `${item.name || item}`}
itemKey={(item) => `${item._id?.toString() || item.name || item}`}
renderItem={(item) => `${item.name || item}`}
+4 -2
View File
@@ -31,10 +31,12 @@ console.log(
window.UiContext = JSON.parse(window.UiContext);
window.UserContext = JSON.parse(window.UserContext);
if (process.env.NODE_ENV === 'production' && !UiContext.sentry_disable) {
window.captureException = (e) => Sentry.captureException(e);
window.captureException = (e) => {
if (!e.isUserFacingError) Sentry.captureException(e);
};
Sentry.init({
dsn: UiContext.sentry_dsn || 'https://2f95d53751e08c74c1af1c4b93ccaff7@sentry.hydro.ac/2',
release: process.env.VERSION,
release: `hydro-web@${process.env.VERSION}`,
integrations: [
Sentry.browserTracingIntegration(),
Sentry.replayIntegration(),
+12
View File
@@ -17,6 +17,18 @@ if (window.MediaQueryList && !MediaQueryList.prototype.addEventListener) {
MediaQueryList.prototype.addListener(listener);
};
}
if (typeof window['WeakRef'] === 'undefined') {
// @ts-ignore
window.WeakRef = (function (wm) {
function WeakRef(target) {
wm.set(this, target);
}
WeakRef.prototype.deref = function () {
return wm.get(this);
};
return WeakRef;
}(new WeakMap()));
}
if (!(window.matchMedia('all').addListener || window.matchMedia('all').addEventListener)) {
const localMatchMedia = window.matchMedia;
const hasMediaQueries = localMatchMedia('only all').matches;
+9 -2
View File
@@ -82,7 +82,8 @@ export const zIndexManager = {
};
export const request = {
async ajax(options: Record<string, any>) {
ajax(options: Record<string, any>) {
const stack = new Error().stack;
return new Promise<any>((resolve, reject) => {
$
.ajax({
@@ -96,9 +97,12 @@ export const request = {
if (textStatus === 'abort') {
const err = new Error(i18n('Aborted')) as any;
err.aborted = true;
err.isUserFacingError = true;
reject(err);
} else if (jqXHR.readyState === 0) {
reject(new Error(i18n('Network error')));
const err = new Error(i18n('Network error')) as any;
err.isUserFacingError = true;
reject(err);
} else if (typeof jqXHR.responseJSON === 'object' && jqXHR.responseJSON.error) {
const { error } = jqXHR.responseJSON;
if (error.params) {
@@ -117,6 +121,9 @@ export const request = {
}
})
.done(resolve);
}).catch((e: Error) => {
e.stack = stack;
throw e;
});
},