From c05accf34393345fd6f1cf9f016e38d67403706b Mon Sep 17 00:00:00 2001 From: undefined Date: Sat, 8 Jun 2024 17:38:39 +0800 Subject: [PATCH] ui: @cordisjs/core instead of cordis --- packages/ui-default/build/main.ts | 7 +++++-- .../components/scratchpad/ToolbarComponent.jsx | 9 ++------- packages/ui-default/context.ts | 4 ++-- packages/ui-default/entry.js | 2 +- packages/ui-default/package.json | 2 +- packages/ui-default/pages/problem_files.page.tsx | 2 +- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/packages/ui-default/build/main.ts b/packages/ui-default/build/main.ts index 2ed520bea..0c9fb5ffa 100644 --- a/packages/ui-default/build/main.ts +++ b/packages/ui-default/build/main.ts @@ -6,7 +6,6 @@ import log from 'fancy-log'; import fs from 'fs-extra'; import { globbySync } from 'globby'; import gulp from 'gulp'; -import { sum } from 'lodash'; import path from 'path'; import webpack, { Stats } from 'webpack'; import WebpackDevServer from 'webpack-dev-server'; @@ -68,16 +67,20 @@ async function runWebpack({ stats[key] = data.size; } const statsPath = root('__bundleInfo'); + let oldTotal = 0; + let newTotal = 0; if (fs.existsSync(statsPath)) { log('Compare to last production bundle:'); const oldStats = JSON.parse(await fs.readFile(statsPath, 'utf-8')) as Record; for (const key in stats) oldStats[key] ||= 0; const entries: [filename: string, orig: number, curr: number][] = []; 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]); } 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) { const [name, orig, curr] = entry; const diff = 100 * (curr - orig) / orig; diff --git a/packages/ui-default/components/scratchpad/ToolbarComponent.jsx b/packages/ui-default/components/scratchpad/ToolbarComponent.jsx index 35b49b67f..7c959fd0d 100644 --- a/packages/ui-default/components/scratchpad/ToolbarComponent.jsx +++ b/packages/ui-default/components/scratchpad/ToolbarComponent.jsx @@ -20,8 +20,8 @@ ToolbarComponent.propTypes = { export function ToolbarButtonComponent(props) { const { - activated, - disabled, + activated = false, + disabled = false, onClick, className, children, @@ -52,11 +52,6 @@ ToolbarButtonComponent.propTypes = { children: PropTypes.node, }; -ToolbarButtonComponent.defaultProps = { - activated: false, - disabled: false, -}; - export function ToolbarSplitComponent(props) { const { className, diff --git a/packages/ui-default/context.ts b/packages/ui-default/context.ts index e9582823d..7391ce1a3 100644 --- a/packages/ui-default/context.ts +++ b/packages/ui-default/context.ts @@ -1,9 +1,9 @@ -import * as cordis from 'cordis'; +import * as cordis from '@cordisjs/core'; import type { EventMap } from './api'; export interface Events extends cordis.Events, EventMap { } -export type { Disposable, ScopeStatus, Plugin } from 'cordis'; +export type { Disposable, ScopeStatus, Plugin } from '@cordisjs/core'; export interface Context { [Context.events]: Events; diff --git a/packages/ui-default/entry.js b/packages/ui-default/entry.js index 5716ed4bf..a9f838e58 100644 --- a/packages/ui-default/entry.js +++ b/packages/ui-default/entry.js @@ -28,7 +28,7 @@ console.log( window.UiContext = JSON.parse(window.UiContext); 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); Sentry.init({ dsn: UiContext.sentry_dsn || 'https://04d1d77b095231d55e1202bdc912ff16@sentry.hydro.ac/3', diff --git a/packages/ui-default/package.json b/packages/ui-default/package.json index 1f87cdefb..077d83cdc 100644 --- a/packages/ui-default/package.json +++ b/packages/ui-default/package.json @@ -15,6 +15,7 @@ }, "devDependencies": { "@blueprintjs/core": "^5.10.3", + "@cordisjs/core": "^3.16.2", "@fontsource/dm-mono": "^5.0.20", "@fontsource/fira-code": "^5.0.18", "@fontsource/inconsolata": "^5.0.18", @@ -50,7 +51,6 @@ "clean-webpack-plugin": "^4.0.0", "clipboard": "^2.0.11", "copy-webpack-plugin": "^12.0.2", - "cordis": "3.16.0", "css-loader": "^6.11.0", "diff": "^5.2.0", "diff-dom": "^5.1.3", diff --git a/packages/ui-default/pages/problem_files.page.tsx b/packages/ui-default/pages/problem_files.page.tsx index c33569d17..885a62a33 100644 --- a/packages/ui-default/pages/problem_files.page.tsx +++ b/packages/ui-default/pages/problem_files.page.tsx @@ -85,7 +85,7 @@ const page = new NamedPage('problem_files', () => { async function handleClickRenameSelected(type) { const selectedFiles = ensureAndGetSelectedFiles(type); if (!selectedFiles?.length) return; - let onActionButton = (_: string) => false; // eslint-disable-line @typescript-eslint/no-unused-vars + let onActionButton = (_: string) => false; function Rename(props) { const [original, setOriginal] = React.useState('');