ui: @cordisjs/core instead of cordis

This commit is contained in:
undefined committed 2024-06-08 17:38:39 +08:00
1 parent d94d364abe
commit c05accf343
6 files changed
+12 -14

No files matched your search

+5 -2
View File
@@ -6,7 +6,6 @@ import log from 'fancy-log';
import fs from 'fs-extra'; import fs from 'fs-extra';
import { globbySync } from 'globby'; import { globbySync } from 'globby';
import gulp from 'gulp'; import gulp from 'gulp';
import { sum } from 'lodash';
import path from 'path'; import path from 'path';
import webpack, { Stats } from 'webpack'; import webpack, { Stats } from 'webpack';
import WebpackDevServer from 'webpack-dev-server'; import WebpackDevServer from 'webpack-dev-server';
@@ -68,16 +67,20 @@ async function runWebpack({
stats[key] = data.size; stats[key] = data.size;
} }
const statsPath = root('__bundleInfo'); const statsPath = root('__bundleInfo');
let oldTotal = 0;
let newTotal = 0;
if (fs.existsSync(statsPath)) { if (fs.existsSync(statsPath)) {
log('Compare to last production bundle:'); log('Compare to last production bundle:');
const oldStats = JSON.parse(await fs.readFile(statsPath, 'utf-8')) as Record<string, number>; const oldStats = JSON.parse(await fs.readFile(statsPath, 'utf-8')) as Record<string, number>;
for (const key in stats) oldStats[key] ||= 0; for (const key in stats) oldStats[key] ||= 0;
const entries: [filename: string, orig: number, curr: number][] = []; const entries: [filename: string, orig: number, curr: number][] = [];
for (const [key, value] of Object.entries(oldStats)) { for (const [key, value] of Object.entries(oldStats)) {
oldTotal += value;
newTotal += stats[key] || 0;
if (Math.abs((stats[key] || 0) - value) > 25) entries.push([key, value, stats[key] || 0]); if (Math.abs((stats[key] || 0) - value) > 25) entries.push([key, value, stats[key] || 0]);
} }
const sorted = entries.sort((i) => i[1] - i[2]); const sorted = entries.sort((i) => i[1] - i[2]);
sorted.push(['Total', sum(sorted.map((i) => i[1])), sum(sorted.map((i) => i[2]))]); sorted.push(['Total', oldTotal, newTotal]);
for (const entry of sorted) { for (const entry of sorted) {
const [name, orig, curr] = entry; const [name, orig, curr] = entry;
const diff = 100 * (curr - orig) / orig; const diff = 100 * (curr - orig) / orig;
@@ -20,8 +20,8 @@ ToolbarComponent.propTypes = {
export function ToolbarButtonComponent(props) { export function ToolbarButtonComponent(props) {
const { const {
activated, activated = false,
disabled, disabled = false,
onClick, onClick,
className, className,
children, children,
@@ -52,11 +52,6 @@ ToolbarButtonComponent.propTypes = {
children: PropTypes.node, children: PropTypes.node,
}; };
ToolbarButtonComponent.defaultProps = {
activated: false,
disabled: false,
};
export function ToolbarSplitComponent(props) { export function ToolbarSplitComponent(props) {
const { const {
className, className,
+2 -2
View File
@@ -1,9 +1,9 @@
import * as cordis from 'cordis'; import * as cordis from '@cordisjs/core';
import type { EventMap } from './api'; import type { EventMap } from './api';
export interface Events<C extends Context = Context> extends cordis.Events<C>, EventMap { } export interface Events<C extends Context = Context> extends cordis.Events<C>, EventMap { }
export type { Disposable, ScopeStatus, Plugin } from 'cordis'; export type { Disposable, ScopeStatus, Plugin } from '@cordisjs/core';
export interface Context { export interface Context {
[Context.events]: Events<this>; [Context.events]: Events<this>;
+1 -1
View File
@@ -28,7 +28,7 @@ console.log(
window.UiContext = JSON.parse(window.UiContext); window.UiContext = JSON.parse(window.UiContext);
window.UserContext = JSON.parse(window.UserContext); window.UserContext = JSON.parse(window.UserContext);
if (!UiContext.sentry_disable) { if (process.env.NODE_ENV === 'production' && !UiContext.sentry_disable) {
window.captureException = (e) => Sentry.captureException(e); window.captureException = (e) => Sentry.captureException(e);
Sentry.init({ Sentry.init({
dsn: UiContext.sentry_dsn || 'https://04d1d77b095231d55e1202bdc912ff16@sentry.hydro.ac/3', dsn: UiContext.sentry_dsn || 'https://04d1d77b095231d55e1202bdc912ff16@sentry.hydro.ac/3',
+1 -1
View File
@@ -15,6 +15,7 @@
}, },
"devDependencies": { "devDependencies": {
"@blueprintjs/core": "^5.10.3", "@blueprintjs/core": "^5.10.3",
"@cordisjs/core": "^3.16.2",
"@fontsource/dm-mono": "^5.0.20", "@fontsource/dm-mono": "^5.0.20",
"@fontsource/fira-code": "^5.0.18", "@fontsource/fira-code": "^5.0.18",
"@fontsource/inconsolata": "^5.0.18", "@fontsource/inconsolata": "^5.0.18",
@@ -50,7 +51,6 @@
"clean-webpack-plugin": "^4.0.0", "clean-webpack-plugin": "^4.0.0",
"clipboard": "^2.0.11", "clipboard": "^2.0.11",
"copy-webpack-plugin": "^12.0.2", "copy-webpack-plugin": "^12.0.2",
"cordis": "3.16.0",
"css-loader": "^6.11.0", "css-loader": "^6.11.0",
"diff": "^5.2.0", "diff": "^5.2.0",
"diff-dom": "^5.1.3", "diff-dom": "^5.1.3",
@@ -85,7 +85,7 @@ const page = new NamedPage('problem_files', () => {
async function handleClickRenameSelected(type) { async function handleClickRenameSelected(type) {
const selectedFiles = ensureAndGetSelectedFiles(type); const selectedFiles = ensureAndGetSelectedFiles(type);
if (!selectedFiles?.length) return; if (!selectedFiles?.length) return;
let onActionButton = (_: string) => false; // eslint-disable-line @typescript-eslint/no-unused-vars let onActionButton = (_: string) => false;
function Rename(props) { function Rename(props) {
const [original, setOriginal] = React.useState(''); const [original, setOriginal] = React.useState('');