mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-21 21:44:40 +03:00
* perf(i18n): bundle only English eagerly, lazy-load other locales on demand The entry bundle previously inlined all 19 locales (11 MB minified, 2.4 MB gzip) via the virtual @intlify messages module. Now only en (plus tool-level en files) is compiled into the entry; every other locale becomes its own lazy chunk fetched the first time it is selected, with vue-i18n falling back to English until the messages arrive. VITE_AVAILABLE_LOCALES now filters the locales offered at runtime instead of trimming the build; unlisted locale chunks are emitted but never fetched. Also adds shims for *.yml default imports and @tabler/icons-vue per-icon deep imports (used by the follow-up icon-loading commit). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RKAJuYi4dP1mwsjPi4v5Ea * perf(tools): load tool icons lazily and parallelize boot config fetches The eager tool-metadata glob pulled ~460 static icon component modules into the entry graph. Tool definitions now reference their icon via defineAsyncComponent + per-icon dynamic import, and an advancedChunks group merges all of them into a single lazy 'tool-icons' chunk fetched off the critical path when the menu/home first renders. Exact same glyphs as before. Entry-graph components (navbar, layouts, ToolCard, copy buttons, command palette, home) switch from runtime icon packages to build-time-inlined ~icons/tabler imports so no static reference drags the icon chunk into the entry bundle. src/tools/index.ts also fetched tools-filter.json and external-tools.json sequentially under top-level await, blocking first render on two serial round-trips; they are now fetched in parallel. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RKAJuYi4dP1mwsjPi4v5Ea * perf(pwa): precache only the app shell, cache chunks and wasm on demand The service worker precached every JS chunk and WASM binary — 1,679 files, ~162 MB — on first visit, saturating bandwidth while the page was trying to become interactive. Precache is now limited to the shell (css/html) with CacheFirst runtime caching for same-origin hashed scripts, workers and wasm, so offline support covers everything the user has actually opened. VITE_PWA_FULL_PRECACHE=true restores the previous cache-everything behavior for self-hosted full-offline deployments. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RKAJuYi4dP1mwsjPi4v5Ea * perf(menu): eliminate layout thrash in sider and category animations The sider show/hide animates CSS width, which re-laid-out all ~460 menu items plus the page content on every frame; category expand/collapse animates grid-template-rows with the same cost. Two changes cut the per-frame work: - content-visibility: auto on each category container so offscreen categories skip layout and paint entirely during animations - the sider scroll content is pinned to the expanded width, so the width transition clips the menu instead of re-wrapping every item per frame Measured with the Long Animation Frames API (dev mode, full hide+show cycle): 4 long frames totalling ~395 ms before, 2 totalling ~236 ms after; animation frames after the initial commit now stay under 50 ms. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RKAJuYi4dP1mwsjPi4v5Ea * perf(deps): replace moment with date-fns in countdown and alarm tools moment was only used by three tools, each pulling its ~70 KB gzip bundle into their chunks while date-fns (already a dependency) covers the same needs tree-shaken. Also fixes a latent bug: moment's mutating add()/set() modified the shared 'now' ref on every computed evaluation, so the deadline could drift by one duration per re-render; date-fns operations are immutable. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RKAJuYi4dP1mwsjPi4v5Ea * perf(deps): replace lodash with es-toolkit Full CJS lodash (~70 KB gzip, no tree-shaking) was in the entry graph via the tools store and shared composables, plus four lodash.* micro-packages. es-toolkit provides the same functions as tree-shakeable ESM: - import _ from 'lodash' -> import * as _ from 'es-toolkit/compat' (namespace member access tree-shakes under Rolldown) - the 20 _.chain pipelines are rewritten as plain array/object operations or es-toolkit calls (es-toolkit has no chain, deliberately) - lodash.defaultsdeep/flattendeep/last/mergewith micro-packages replaced with es-toolkit core/compat equivalents - lodash's RecursiveArray type is declared locally in generate-tree.ts - files whose only lodash use was inside a rewritten chain lose the dependency entirely Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RKAJuYi4dP1mwsjPi4v5Ea * fix: catch lodash usages the codemod missed (.js/.tsx files, bare _() wrapper) outputFormatter.js and diff-viewer.models.tsx were outside the codemod's *.ts/*.vue glob, and otp.service.ts used the implicit-chain _(...) wrapper form that the _. usage regex didn't match (its import was wrongly removed). Both builds still passed because pnpm's hoisted store made 'lodash' resolvable even after removal from package.json. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RKAJuYi4dP1mwsjPi4v5Ea * perf(boot): drop the splash screen and parallelize the settings fetch The splash screen existed to cover a multi-second blank period while the old 13 MB entry bundle parsed; with the startup payload at ~3 MB the app shell paints fast enough to render directly (measurements in the PR description). Removes vite-plugin-splash-screen entirely. tools-settings.json was fetched under top-level await in main.ts, serially after the config fetches in src/tools/index.ts. It now lives in a sibling async module so all three optional config fetches share one round-trip. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RKAJuYi4dP1mwsjPi4v5Ea * fix: defer preload-error reload so it cannot abort an in-flight navigation Firefox fires vite:preloadError for module preloads cancelled by a user navigation (NS_BINDING_ABORTED), and the immediate location.reload() raced and aborted that navigation. With the tool icons now loading via dynamic imports there are ~460 preloads in flight at startup, which made the race deterministic in the date-time-converter Playwright specs on firefox. Deferring the reload by a tick resolves it: if the page is genuinely navigating away its timers die with the document; on a real chunk-load failure the reload still happens. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RKAJuYi4dP1mwsjPi4v5Ea * fix(types): satisfy the vitest tsconfig typecheck pnpm typecheck runs vue-tsc against tsconfig.vitest.json, which lacks the unplugin-vue-i18n type shim and infers stricter unions: - tools/index.ts: type the fetch fallbacks so Promise.all doesn't widen filterConfig to 'ToolsFilter | {}' - i18n.plugin.ts: collapse es-toolkit merge's recursive mapped type before it reaches vue-i18n's generics (TS2589), watch the locale through the getter, and cast the messages record - generate-tree.ts: drop flattenDeep/RecursiveArray for a plain spread — child output is already joined strings, so there was only one level to flatten Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RKAJuYi4dP1mwsjPi4v5Ea * perf(bundle): cut startup payload from ~1 MB to ~560 KB gzip Four eager-loading leaks accounted for almost half the startup JS: - Font Awesome (298 KB gzip): main.ts registered the entire solid icon set via library.add(fas) although only the pomodoro timer uses it. The six icons it needs are now registered inside the tool's lazy chunk. - tool-icons chunk (67 KB gzip): rolldown's advancedChunks defaults to includeDependenciesRecursively, which captured shared helpers into the icon chunk and made entry chunks statically depend on it, dragging the whole lazy icon set back into the startup payload. Disabled per-group. - markdown-it + entities + dompurify (~50 KB gzip): eagerly reachable via three paths — the external-tools mapping in tools/index.ts (now a conditional dynamic import), vue-markdown-render in tool.layout.vue and Home.custom.vue (now defineAsyncComponent). - demo gallery routes: registered behind a runtime env check the bundler cannot eliminate; now a conditional dynamic import gated on import.meta.env.DEV so production builds drop it entirely. Startup JS: 3.2 MB -> 1.92 MB raw, ~1.05 MB -> 562 KB gzip. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RKAJuYi4dP1mwsjPi4v5Ea * fix(lint): drop redundant spread flagged by oxlint Object.values already returns a fresh array, so it can be pushed into directly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RKAJuYi4dP1mwsjPi4v5Ea --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
24 lines
734 B
TypeScript
24 lines
734 B
TypeScript
import * as _ from 'es-toolkit/compat';
|
|
import { describe, expect, it } from 'vitest';
|
|
import { booleanToHumanReadable, isNotThrowing } from './boolean';
|
|
|
|
describe('boolean utils', () => {
|
|
describe('isNotThrowing', () => {
|
|
it('should return if the call throws or false otherwise', () => {
|
|
expect(isNotThrowing(_.noop)).to.eql(true);
|
|
expect(
|
|
isNotThrowing(() => {
|
|
throw new Error('message');
|
|
}),
|
|
).to.eql(false);
|
|
});
|
|
});
|
|
|
|
describe('booleanToHumanReadable', () => {
|
|
it('should return "Yes" if the value is true and "No" otherwise', () => {
|
|
expect(booleanToHumanReadable(true)).to.eql('Yes');
|
|
expect(booleanToHumanReadable(false)).to.eql('No');
|
|
});
|
|
});
|
|
});
|