fix: update npm dependencies, fix misc issues (#38257)

Update all npm dependencies and fix discovered issues.

Co-authored-by: bircni <bircni@icloud.com>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Giteabot
2026-06-29 03:59:14 -07:00
committed by GitHub
parent e68ee61879
commit 07b18467c0
10 changed files with 1306 additions and 1806 deletions
+5 -10
View File
@@ -1,15 +1,10 @@
import {trN} from './i18n.ts';
import {getCurrentLocale} from '../utils.ts';
vi.mock('../utils.ts', () => ({getCurrentLocale: vi.fn()}));
test('trN', () => {
vi.mocked(getCurrentLocale).mockReturnValue('en-US');
expect(trN(0, '%d job', '%d jobs')).toEqual('0 jobs');
expect(trN(1, '%d job', '%d jobs')).toEqual('1 job');
expect(trN(2, '%d job', '%d jobs')).toEqual('2 jobs');
expect(trN(1000, '%d job', '%d jobs')).toEqual('1000 jobs');
expect(trN(0, '%d job', '%d jobs', {lang: 'en-US'})).toEqual('0 jobs');
expect(trN(1, '%d job', '%d jobs', {lang: 'en-US'})).toEqual('1 job');
expect(trN(2, '%d job', '%d jobs', {lang: 'en-US'})).toEqual('2 jobs');
expect(trN(1000, '%d job', '%d jobs', {lang: 'en-US'})).toEqual('1000 jobs');
// languages without a distinct singular always use the plural form
vi.mocked(getCurrentLocale).mockReturnValue('zh-CN');
expect(trN(1, '%d job', '%d jobs')).toEqual('1 jobs');
expect(trN(1, '%d job', '%d jobs', {lang: 'zh-CN'})).toEqual('1 jobs');
});
+2 -2
View File
@@ -1,7 +1,7 @@
import {getCurrentLocale} from '../utils.ts';
/** frontend `Locale.TrN`: pick the `_1` or `_n` form for `count` and interpolate `%d` */
export function trN(count: number, form1: string, formN: string): string {
const form = new Intl.PluralRules(getCurrentLocale()).select(count) === 'one' ? form1 : formN;
export function trN(count: number, form1: string, formN: string, {lang = getCurrentLocale()}: {lang?: string} = {}): string {
const form = new Intl.PluralRules(lang).select(count) === 'one' ? form1 : formN;
return form.replace('%d', String(count));
}
@@ -1,15 +1,11 @@
import type {FrontendRenderFunc} from '../plugin.ts';
import {initSwaggerUI} from '../swagger.ts';
// HINT: SWAGGER-CSS-IMPORT: this import is also necessary when swagger is used as a frontend external render
// But it can't share the same CSS file with the standalone page: it triggers our Vite manifest parser's bug
// Although single top-level "await import(css)" can work, it requires es2022.
// Otherwise, single function-level "await import(css)" can't work due to Vite's dependency analysis and bundling.
// HINT: SWAGGER-CSS-IMPORT: these styles are for the render only.
import '../../../css/swagger-render.css';
export const frontendRender: FrontendRenderFunc = async (opts): Promise<boolean> => {
try {
await import('../../../css/swagger-render.css');
await initSwaggerUI(opts.container, {specText: opts.contentString()});
return true;
} catch (error) {