Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

feat(frontend): 用 @preact/signals 建立跨岛共享状态

longmeidao9134ddeab575
diff --git a/docs/FRONTEND.md b/docs/FRONTEND.md
index 95fb9fa88..551384973 100644
--- a/docs/FRONTEND.md
+++ b/docs/FRONTEND.md
@@ -14,6 +14,7 @@ Vite + TypeScript + Preact。迁移方式是 strangler:**遗留路由继续拥
| --- | --- |
| `frontend/src/islands.ts` | 挂载契约与注册表,构建入口 |
| `frontend/src/islands/*.tsx` | 每个 island 一个文件 |
+| `frontend/src/state/*.ts` | 跨岛共享状态,一份数据一个文件;`index.ts` 是登记处 |
| `frontend/src/api.ts` | 带 `AbortController` 的取数封装 |
| `frontend/src/legacy/*.d.ts` | `/js/core.js`、`/js/ui-components.js` 的手写类型 |
| `frontend/test/` | vitest 用例与遗留模块的桩 |
@@ -75,12 +76,63 @@ await ui.mountIsland('quality-goals', $('#stats'), props, {isCurrent: () => surf
打进去就会有两份实现,语义契约各走一份。只存在于 `app.js` 里的助手
(`javTitleHtml`、`srcBadge`、`openItem` 这类)作为 props 传进来,类型写在 island 自己的文件里。
+## 共享状态怎么写
+
+判据只有一条:**这份数据有没有第二个读者**。
+
+没有就用 hooks。展开、悬停、翻到第几页这些东西只属于一个岛,搬进 store 只是把本来
+局部的东西变成全局的。第一份 store 之所以存在,是因为高清版目标确实有两个读者:
+`/quality-goals` 整页列表要 `items`,`/data-cleanup` 上的「高清版」卡片只要一个
+`total`,为此另发了一次 `/api/quality-goals?limit=1`——同一个真相取两次,显示的数
+就可能对不上。
+
+有第二个读者就在 `frontend/src/state/` 建一个文件,规矩三条:
+
+1. **一份数据一个文件**,文件名就是它的名字,再在 `state/index.ts` 里登记。
+2. **只导出 `computed` 视图,不导出可写的 signal。** 写入只能通过该文件导出的函数,
+ 所以「谁改了它」在源码里数得出来;组件里直接赋值会抛 TypeError,不是靠约定。
+3. **取数归 store。** `ensureX()` 是「读一次就够」,已有数据直接给、并发调用合流成
+ 一个请求;`refreshX(signal?)` 是「重新取」,页面刷新和写完数据之后走它。
+
+```ts
+// frontend/src/state/quality-goals.ts
+const state = signal<QualityGoalsState>(BLANK); // 不导出
+export const qualityGoals = computed(() => state.value);
+export const qualityGoalsTotal = computed(() => state.value.data?.total ?? null);
+export async function refreshQualityGoals(abort?: AbortSignal) { /* 写 state.value */ }
+export async function ensureQualityGoals() { /* 有就给,没有才 refresh */ }
+```
+
+岛这边只是读:组件里读 `qualityGoals.value` 就自动订阅,数据之后再变这一屏自己重画,
+不需要重新 `mountIsland`。卸载时订阅跟着组件一起走(`test/islands.test.ts` 里有一条
+mount → unmount → 改 signal 的用例盯着这件事)。`mountIsland` 仍然会把 `{data, error}`
+作为 props 传进来——那是所有 island 共用的首屏契约——由 store 支撑的岛不看它们:
+同一份数据两个来源,刷新之后就会各说一套。
+
+首屏该用哪个函数看路由表:`/quality-goals` 是 `refresh:'reopen'`,刷新就是重新进这一页,
+所以它的 `load` 走 `refreshQualityGoals`,不吃缓存。
+
+**遗留层改完数据怎么通知岛**:产物上多导出一个 `refreshStore(name)`,用法和
+`mountIsland(name, ...)` 一样按名字来。
+
+```js
+const ui = await import('/dist/peach-ui.js');
+await ui.refreshStore('quality-goals'); // 挂着的那屏自己重画,不必重新挂载
+```
+
+它取数失败时不抛,只返回 `false`:失败已经落进 store 的错误态、显示在屏幕上了,而
+调用点在 `app.js` 里是 fire-and-forget,再抛一次只会变成没人接的 rejection。名字不在
+注册表里则立刻抛错——那是写错了,不是运行时状况。目前 `web/app.js` 还没有调用
+它——`/data-cleanup` 那张卡片接进来属于下一批迁移,本轮只把入口备好。
+
## 迁移下一个页面
先挑一个**数据来自单个 `/api/...` GET、容器不与别人共用、没有写操作和轮询**的页面。
1. `frontend/src/islands/<page>.tsx`:导出数据类型、props 类型、端点常量、`load<Page>()`
- 和组件。组件只接 `{...props, data, error}`,不自己取数。
+ 和组件。组件只接 `{...props, data, error}`,不自己取数。这份数据要是还有第二个
+ 读者,就按上一节把数据类型、端点和取数一起搬进 `frontend/src/state/<page>.ts`,
+ island 这边只剩 props、`load` 和组件。
2. `frontend/src/islands.ts`:在 `IslandContracts` 里登记类型,在 `REGISTRY` 里登记
`{load, component}`。类型不登记会直接编译不过。
3. `frontend/test/<page>.test.tsx`:用假 fetch 断言读数口径、空态、失败态与交互。
@@ -107,14 +159,17 @@ vendor 到 `web/vendor/` 的四个包(video.js、swiper、lucide-static、heal
| 依赖 | 为什么需要它 |
| --- | --- |
| `preact` | island 的渲染层。10 kB gzip 的运行时,配 `dangerouslySetInnerHTML` 能直接复用遗留层返回 HTML 的助手 |
+| `@preact/signals` | 跨岛共享状态的载体。组件读 `.value` 就订阅,数据变了只重画读它的那一屏,不用把状态提到某个共同祖先——岛之间没有共同祖先 |
| `vite` | 构建入口。库模式出单个 ES module,`external` + `output.paths` 把遗留模块留在外面 |
| `typescript` | 类型即契约:注册表、props 与端点响应都靠它在编译期拦住漂移 |
| `vitest` | 前端测试运行器。与 Vite 共用同一份配置解析,不必再维护第二套转译 |
| `happy-dom` | vitest 的 DOM 环境。断言的是真实 DOM 结构,比 jsdom 轻且启动快 |
-**`@preact/signals` 本轮没有装。** ADR-0022 把它写进技术栈,同一份决策里也写了
-「直接依赖数量要最小,每个依赖登记一句用途」。第一个迁过去的页面是只读单 GET,
-组件之间没有共享状态,装进来会是一个没有使用者的依赖——它是**被认可的状态原语,
-但要跟着第一个真需要它的页面进来**(追更、复核、批处理面板这类同时有写入和轮询的
-页面),届时在这张表里补一行用途。同理没有引入 `@testing-library/preact`:`preact`
-的 `render` 加 `querySelector` 已经够用,断言的本来就是真实 DOM。
+`@preact/signals` 钉在 2.11.1:它对 `preact` 的 peer 要求是 `>= 10.25.0`,和这里的
+10.29.8 对得上;运行时另外带一个 `@preact/signals-core`,是它自己的依赖,由 lockfile
+钉住,不进清单。产物因此从 17.7 kB 涨到 31.5 kB(gzip 6.6 → 10.6 kB):多出来的是
+`signals` + `signals-core` + `preact/hooks` 三份,最后一份以前不在包里——在这之前
+没有任何一个岛用过 hooks。
+
+没有引入 `@testing-library/preact`:`preact` 的 `render` 加 `querySelector` 已经够用,
+断言的本来就是真实 DOM。
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index cddfeaafd..c5ec52ebc 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -6,6 +6,7 @@
"": {
"name": "peach-frontend",
"dependencies": {
+ "@preact/signals": "2.11.1",
"preact": "10.29.8"
},
"devDependencies": {
@@ -35,6 +36,32 @@
"url": "https://github.com/sponsors/Boshen"
}
},
+ "node_modules/@preact/signals": {
+ "version": "2.11.1",
+ "resolved": "https://registry.npmjs.org/@preact/signals/-/signals-2.11.1.tgz",
+ "integrity": "sha512-uYoD+USkacTNU02kfCBkJEV7xabKTmA78W5pnT2GymsuGEC9n/ZO+UT4S96l0dIL6KLDk77VJyUFuOMBvftVHg==",
+ "license": "MIT",
+ "dependencies": {
+ "@preact/signals-core": "^1.14.4"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/preact"
+ },
+ "peerDependencies": {
+ "preact": ">= 10.25.0 || >=11.0.0-0"
+ }
+ },
+ "node_modules/@preact/signals-core": {
+ "version": "1.14.4",
+ "resolved": "https://registry.npmjs.org/@preact/signals-core/-/signals-core-1.14.4.tgz",
+ "integrity": "sha512-HNB6HYeYKhQbJ1aKl+YRjrS4+QWHLKX6qKoUsfS/m0vqzsVaEBiZiaKbG/e+NKk2ch5ALQr/ihWaMHxiCuuWHA==",
+ "license": "MIT",
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/preact"
+ }
+ },
"node_modules/@rolldown/binding-android-arm-eabi": {
"version": "1.2.6",
"resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.6.tgz",
diff --git a/frontend/package.json b/frontend/package.json
index 0f4947c02..27d3981b1 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -13,6 +13,7 @@
"test:watch": "vitest"
},
"dependencies": {
+ "@preact/signals": "2.11.1",
"preact": "10.29.8"
},
"devDependencies": {
diff --git a/frontend/src/api.ts b/frontend/src/api.ts
index d9b480056..4e5868181 100644
--- a/frontend/src/api.ts
+++ b/frontend/src/api.ts
@@ -26,6 +26,13 @@ const reasonOf = (payload: unknown): string => {
return '';
};
+/** 把抛出来的东西收敛成一句能显示给人看的原因。
+ *
+ * 一次取数失败会同时落到两处——`mountIsland` 的首屏状态和共享 store 的错误态——
+ * 两边显示的必须是同一句话,否则同一个失败会因为落在哪儿而说法不同。 */
+export const errorMessage = (cause: unknown): string =>
+ cause instanceof Error ? cause.message : String(cause);
+
/** GET 一个 `/api/...` 契约端点。`signal` 中止时抛出 `AbortError`,调用方据此放弃写 DOM。 */
export async function apiGet<T>(path: string, signal?: AbortSignal): Promise<T> {
const response = await fetch(path, {
diff --git a/frontend/src/islands.ts b/frontend/src/islands.ts
index d8849fba8..03dbf06e2 100644
--- a/frontend/src/islands.ts
+++ b/frontend/src/islands.ts
@@ -15,8 +15,16 @@
import { h, render } from 'preact';
import type { ComponentType } from 'preact';
+import { errorMessage } from './api';
import { QualityGoals, loadQualityGoals } from './islands/quality-goals';
-import type { QualityGoalsData, QualityGoalsProps } from './islands/quality-goals';
+import type { QualityGoalsProps } from './islands/quality-goals';
+import type { QualityGoalsData } from './state/quality-goals';
+
+/* 跨岛共享状态的入口一起从这里出去。遗留层拿到的是一个 bundle,它有两种用法:
+ * `mountIsland` 挂一屏,`refreshStore` 告诉已经挂着的那屏「数据变了」。
+ * 怎么写一个 store 见 `./state/index.ts` 和 `docs/FRONTEND.md`。 */
+export { refreshStore, storeNames } from './state';
+export type { StoreName } from './state';
/** 首屏取数的结果。`data` 与 `error` 恰有一个成立。 */
export interface IslandState<D> {
@@ -77,7 +85,7 @@ export async function mountIsland<N extends IslandName>(
state = { data: await island.load(props, mount.controller.signal), error: '' };
} catch (cause) {
if (mount.controller.signal.aborted) return;
- state = { data: null, error: cause instanceof Error ? cause.message : String(cause) };
+ state = { data: null, error: errorMessage(cause) };
}
// 期间被卸载或重新挂载:这一次的结果已经过期,不许往新内容上盖。
if (mounted.get(el) !== mount) return;
diff --git a/frontend/src/islands/quality-goals.tsx b/frontend/src/islands/quality-goals.tsx
index 4762e3787..1f017c4d4 100644
--- a/frontend/src/islands/quality-goals.tsx
+++ b/frontend/src/islands/quality-goals.tsx
@@ -4,35 +4,20 @@
* 没有写入端点、没有轮询,样式在 `web/app.css` 里已经是独立的 `.qualitylist`/
* `.qualityitem`。迁移它不需要动别的页面,也不需要动样式。
*
+ * 列表数据不在这个文件里:它是共享状态,住在 `../state/quality-goals`,因为数据管理页
+ * 的「高清版」卡片读的是同一个真相(原因见那个文件的开头)。这里只做两件
+ * 事——首屏取数由 `loadQualityGoals` 发起(`mountIsland` 等它落地才画),画的时候读
+ * `qualityGoals` 这个 signal,所以数据之后再变(遗留层写完通知、别处触发刷新)这一屏
+ * 自己就更新了,不用重新挂载。
+ *
* 遗留层那几个返回 HTML 的助手(番号标题、来源徽标)由 props 传进来,不在这里重写:
* 它们是全站语义契约的唯一实现,抄一份就会漂。等下一批页面迁移时再把它们提升成
* TS 组件,那时 props 一起收窄。 */
import { LOC, fmtDur, fmtSize } from '@peach/legacy/core';
import { emptyStateHtml, noteHtml } from '@peach/legacy/ui';
-import { apiGet } from '../api';
-import type { IslandState } from '../islands';
-
-/** `/api/quality-goals` 的单条目。字段与 `web_contract.q_quality_goals` 对齐。 */
-export interface QualityGoal {
- id: number;
- name: string;
- code: string | null;
- location: string;
- size: number | null;
- duration: number | null;
- reason: string | null;
- cost: string;
- has_thumb: boolean;
- has_cover: boolean;
-}
-
-export interface QualityGoalsData {
- total: number;
- items: QualityGoal[];
- offset: number;
- has_more: boolean;
-}
+import { qualityGoals, refreshQualityGoals } from '../state/quality-goals';
+import type { QualityGoal, QualityGoalsData } from '../state/quality-goals';
/** 仍由遗留层提供的能力。全是纯函数或导航,island 不持有它们的状态。 */
export interface QualityGoalsProps {
@@ -46,23 +31,25 @@ export interface QualityGoalsProps {
srcBadge(location: string, cost: string): string;
}
-/** 上限沿用遗留层的 200:服务端 `limit` 也钉在 200,再大只会被截。 */
-export const QUALITY_GOALS_URL = '/api/quality-goals?limit=200';
-
+/** 首屏取数。强制重取而不是吃缓存:`/quality-goals` 在路由表里是 `refresh:'reopen'`,
+ * 刷新这一页要的就是新数据。结果写进共享 store,返回值只是给 `mountIsland` 的落地信号。 */
export const loadQualityGoals = (
_props: QualityGoalsProps,
signal: AbortSignal,
-): Promise<QualityGoalsData> => apiGet<QualityGoalsData>(QUALITY_GOALS_URL, signal);
+): Promise<QualityGoalsData> => refreshQualityGoals(signal);
/** 封面优先用番号封面,没有就退回第 4 张海报,两者都取不到时把 img 摘掉。 */
const previewUrl = (item: QualityGoal): string => item.has_cover
? `/cover?code=${encodeURIComponent(item.code ?? '')}`
: `/poster?id=${item.id}&c=4`;
+/** 只接遗留助手,数据从 store 读。`mountIsland` 仍会把 `{data, error}` 传进来——那是所有
+ * island 共用的首屏契约——由 store 支撑的这一个不看它们:同一份数据两个来源,刷新之后
+ * 就会各说一套。 */
export function QualityGoals(
- { data, error, openItem, javTitleHtml, javDisplayName, srcBadge }:
- QualityGoalsProps & IslandState<QualityGoalsData>,
+ { openItem, javTitleHtml, javDisplayName, srcBadge }: QualityGoalsProps,
) {
+ const { data, error } = qualityGoals.value;
if (error) {
return (
<div
diff --git a/frontend/src/state/index.ts b/frontend/src/state/index.ts
new file mode 100644
index 000000000..bb5e262de
--- /dev/null
+++ b/frontend/src/state/index.ts
@@ -0,0 +1,46 @@
+/* 跨岛共享状态的登记处(ADR-0022)。
+ *
+ * 约定只有三条,都是为了让「这份数据现在是什么」永远只有一个答案:
+ *
+ * 1. **一份共享数据一个文件**,文件名就是它的名字。岛自己的临时状态(展开、悬停、
+ * 第几页)继续用 hooks,不进这里——那些东西没有第二个读者,搬进来只会让本来
+ * 局部的东西变全局。
+ * 2. **导出 `computed` 视图,不导出可写的 signal。** 写入只能通过该文件导出的函数,
+ * 所以「谁改了它」在源码里数得出来。组件里直接赋值会抛 TypeError。
+ * 3. **取数归 store。** `ensure` 是「读一次就够」,已有数据直接给;`refresh` 是
+ * 「重新取」,页面刷新和遗留层写完数据之后走它。
+ *
+ * 遗留层(`web/app.js`)改完数据要通知岛时,用下面的 `refreshStore(name)`:它按名字
+ * 拿 store,不需要知道函数名,和 `mountIsland(name, ...)` 同一种用法。挂载中的岛靠
+ * signal 自己重画,不需要被重新挂载一遍。 */
+import { refreshQualityGoals, resetQualityGoals } from './quality-goals';
+
+const STORES = {
+ 'quality-goals': { refresh: refreshQualityGoals, reset: resetQualityGoals },
+} as const;
+
+export type StoreName = keyof typeof STORES;
+
+/** 已登记的共享 store。遗留层与测试用它核对名字,不必知道注册表结构。 */
+export const storeNames = (): StoreName[] => Object.keys(STORES) as StoreName[];
+
+/** 让一份共享数据重新取一次。名字不认识时抛错,不静默什么都不做。
+ *
+ * 返回的 promise 在取数失败时**不**抛:失败已经落进 store 的错误态、显示在屏幕上了,
+ * 而调用点在遗留层是 fire-and-forget,再抛一次只会变成没人接的 rejection。 */
+export async function refreshStore(name: StoreName): Promise<boolean> {
+ const store = STORES[name] as { refresh(): Promise<unknown> } | undefined;
+ if (!store) throw new Error(`未登记的共享 store:${String(name)}`);
+ try {
+ await store.refresh();
+ return true;
+ } catch {
+ return false;
+ }
+}
+
+/** 把所有共享 store 清回未读状态。只给测试之间做隔离用,所以不从 `islands.ts` 再导出
+ * 一次——产物的对外接口只有遗留层真正要调的那几个。 */
+export function resetStores(): void {
+ for (const store of Object.values(STORES)) store.reset();
+}
diff --git a/frontend/src/state/quality-goals.ts b/frontend/src/state/quality-goals.ts
new file mode 100644
index 000000000..e594a2978
--- /dev/null
+++ b/frontend/src/state/quality-goals.ts
@@ -0,0 +1,106 @@
+/* 共享状态:高清版目标(`/api/quality-goals`)。
+ *
+ * 这份数据在界面上有两个读者,而且是两个不同的表面:
+ *
+ * - `/quality-goals` 整页列表(已迁成 island),要 `items`;
+ * - `/data-cleanup` 数据管理页上的「高清版」卡片(`N 个待升级`),只要一个 `total`,
+ * 为此单独发了 `/api/quality-goals?limit=1`。
+ *
+ * 同一个真相取两次,谁先谁后不定,两处显示的数就可能不一致。所以它归这里:一份
+ * 数据只有一个家,读者订阅同一个 signal,取数由下面这几个函数发起。数据管理页还在
+ * `web/app.js` 里,它接进来的方式是 `refreshStore()`(见 `./index.ts`),本轮不动它。
+ *
+ * 写入口只有 `refresh` / `ensure` / `reset` 三个。可写的 signal 不导出:组件拿到的是
+ * `computed` 视图,直接赋值在运行期就抛 TypeError,不是靠约定。 */
+import { computed, signal } from '@preact/signals';
+import type { ReadonlySignal } from '@preact/signals';
+
+import { apiGet, errorMessage } from '../api';
+
+/** `/api/quality-goals` 的单条目。字段与 `web_contract.q_quality_goals` 对齐。 */
+export interface QualityGoal {
+ id: number;
+ name: string;
+ code: string | null;
+ location: string;
+ size: number | null;
+ duration: number | null;
+ reason: string | null;
+ cost: string;
+ has_thumb: boolean;
+ has_cover: boolean;
+}
+
+export interface QualityGoalsData {
+ total: number;
+ items: QualityGoal[];
+ offset: number;
+ has_more: boolean;
+}
+
+/** `data` 与 `error` 恰有一个成立,和 island 首屏状态同一口径。 */
+export interface QualityGoalsState {
+ data: QualityGoalsData | null;
+ error: string;
+}
+
+/** 上限沿用遗留层的 200:服务端 `limit` 也钉在 200,再大只会被截。 */
+export const QUALITY_GOALS_URL = '/api/quality-goals?limit=200';
+
+const BLANK: QualityGoalsState = { data: null, error: '' };
+
+const state = signal<QualityGoalsState>(BLANK);
+
+/** 每次写入带一个序号:迟到的响应不许盖住比它更新的那一次。 */
+let issued = 0;
+/** `ensure` 的合流点。多个岛同时挂载时只发一个请求,而不是各发一个。 */
+let shared: Promise<QualityGoalsData> | null = null;
+
+/** 当前的读取结果。组件读它就自动订阅,数据变了自己重画,不必重新挂载。 */
+export const qualityGoals: ReadonlySignal<QualityGoalsState> = computed(() => state.value);
+
+/** 待升级总数;还没读到过是 `null`——那和「读到 0 个」是两件事,不能都显示成 0。 */
+export const qualityGoalsTotal: ReadonlySignal<number | null> = computed(
+ () => state.value.data?.total ?? null,
+);
+
+/** 丢掉已读到的一切,下一次 `ensure` 会重新取。测试之间用它隔离,遗留层不用。 */
+export function resetQualityGoals(): void {
+ issued += 1;
+ shared = null;
+ state.value = BLANK;
+}
+
+/** 强制重取一次。
+ *
+ * island 的首屏走这里而不是 `ensure`:`/quality-goals` 在路由表里是 `refresh:'reopen'`,
+ * 刷新就是重新进这一页,那时候要的是新数据,不是缓存。
+ *
+ * `abort` 归调用方所有(`mountIsland` 在卸载时中止它)。中止不写错误态:页面是被用户
+ * 换掉的,屏幕上那份数据仍然有效,标成失败反而是谎报。 */
+export async function refreshQualityGoals(abort?: AbortSignal): Promise<QualityGoalsData> {
+ const token = (issued += 1);
+ try {
+ const data = await apiGet<QualityGoalsData>(QUALITY_GOALS_URL, abort);
+ if (token === issued) state.value = { data, error: '' };
+ return data;
+ } catch (cause) {
+ if (!abort?.aborted && token === issued) {
+ state.value = { data: null, error: errorMessage(cause) };
+ }
+ throw cause;
+ }
+}
+
+/** 读一次就够的读者走这里:已经有数据就直接给,没有才取。
+ *
+ * 不收 `AbortSignal`:这个请求归 store,不归第一个碰上它的调用方。让 A 的离场中止掉
+ * B 也在等的那个请求,是把「共用」变成「谁先来谁负责」。 */
+export async function ensureQualityGoals(): Promise<QualityGoalsData> {
+ const cached = state.value.data;
+ if (cached) return cached;
+ if (!shared) {
+ shared = refreshQualityGoals().finally(() => { shared = null; });
+ }
+ return shared;
+}
diff --git a/frontend/test/helpers.ts b/frontend/test/helpers.ts
index b0e36466d..23dad448a 100644
--- a/frontend/test/helpers.ts
+++ b/frontend/test/helpers.ts
@@ -1,6 +1,8 @@
import { vi } from 'vitest';
-import type { QualityGoal, QualityGoalsData, QualityGoalsProps } from '../src/islands/quality-goals';
+import type { QualityGoalsProps } from '../src/islands/quality-goals';
+import { refreshQualityGoals } from '../src/state/quality-goals';
+import type { QualityGoal, QualityGoalsData } from '../src/state/quality-goals';
export const goal = (overrides: Partial<QualityGoal> = {}): QualityGoal => ({
id: 1,
@@ -23,18 +25,52 @@ export const payload = (items: QualityGoal[]): QualityGoalsData => ({
has_more: false,
});
-/** 遗留层传进来的那几个助手。测试里换成可辨认的最小实现,断言只看 island 是否用了它们。 */
+/** 遗留层传进来的那几个助手。测试里换成可辨认的最小实现,断言只看 island 是否用了它们。
+ *
+ * `javTitleHtml` 是 spy:它只在渲染时被调用,所以「组件有没有重画」可以直接数它的调用
+ * 次数,不必从 DOM 反推。 */
export const legacyProps = () => {
const openItem = vi.fn<(id: number) => void>();
+ const javTitleHtml = vi.fn<(item: QualityGoal) => string>(
+ item => `<strong class="javcode">${item.name}</strong>`,
+ );
const props: QualityGoalsProps = {
openItem,
- javTitleHtml: item => `<strong class="javcode">${item.name}</strong>`,
+ javTitleHtml,
javDisplayName: item => `名称 ${item.name}`,
srcBadge: (location, cost) => `<span class="src ${cost}" data-location="${location}"></span>`,
};
- return { ...props, openItem };
+ return { ...props, openItem, javTitleHtml };
};
+/** 一次就兑现的 fetch 替身。 */
+export const okFetch = (body: unknown) => vi.fn(async (_input: string, _init?: RequestInit) => (
+ { ok: true, status: 200, json: async () => body }
+));
+
+/** 服务端明确回了非 2xx;`message` 就是界面上该出现的那句话。 */
+export const failFetch = (status: number, message: string) => vi.fn(
+ async (_input: string, _init?: RequestInit) => (
+ { ok: false, status, json: async () => ({ message }) }
+ ),
+);
+
+/** 把共享 store 灌成「已经读到这些目标」。走 store 自己的写入口,不直接动 signal。 */
+export async function seedGoals(items: QualityGoal[]): Promise<void> {
+ vi.stubGlobal('fetch', okFetch(payload(items)));
+ await refreshQualityGoals();
+}
+
+/** 把共享 store 灌成失败态。`refresh` 会重新抛出,这里咽掉:调用点要的是那个状态。 */
+export async function seedGoalsError(message: string, status = 500): Promise<void> {
+ vi.stubGlobal('fetch', failFetch(status, message));
+ try {
+ await refreshQualityGoals();
+ } catch {
+ // 失败已经落进 store,正是这里要的结果。
+ }
+}
+
/** 一个可手动兑现的 fetch:island 的等待窗口本身就是被测行为,不能靠 setTimeout 猜。 */
export function deferredFetch(body: unknown) {
let settle = (): void => {};
diff --git a/frontend/test/islands.test.ts b/frontend/test/islands.test.ts
index f6adfd471..4f38c0174 100644
--- a/frontend/test/islands.test.ts
+++ b/frontend/test/islands.test.ts
@@ -1,8 +1,9 @@
import { afterEach, describe, expect, it, vi } from 'vitest';
import { islandNames, mountIsland, unmountIsland } from '../src/islands';
+import { resetStores } from '../src/state';
-import { deferredFetch, goal, legacyProps, payload } from './helpers';
+import { deferredFetch, goal, legacyProps, payload, seedGoals } from './helpers';
const container = () => {
const el = document.createElement('div');
@@ -14,6 +15,8 @@ const container = () => {
afterEach(() => {
document.body.innerHTML = '';
+ // 共享 store 是模块级的,会活过单个用例;不清就变成用例之间的隐藏耦合。
+ resetStores();
vi.unstubAllGlobals();
});
@@ -111,4 +114,24 @@ describe('unmountIsland', () => {
unmountIsland(el);
expect(el.querySelector('[data-skeleton]')).not.toBeNull();
});
+
+ it('卸载之后共享状态再变也不重画:订阅要跟着组件一起走', async () => {
+ vi.stubGlobal('fetch', vi.fn(async () => ({
+ ok: true, status: 200, json: async () => payload([goal({ id: 1, name: 'one.mp4' })]),
+ })));
+ const el = container();
+ const props = legacyProps();
+ await mountIsland('quality-goals', el, props);
+ expect(el.querySelectorAll('.qualityitem')).toHaveLength(1);
+ const painted = props.javTitleHtml.mock.calls.length;
+ expect(painted).toBeGreaterThan(0);
+
+ unmountIsland(el);
+ // 换一份完全不同的数据。还留着订阅的话,组件会为一个已经卸载的容器再画一次。
+ await seedGoals([goal({ id: 2, name: 'after.mp4' }), goal({ id: 3, name: 'more.mp4' })]);
+ expect(props.javTitleHtml.mock.calls.length, '卸载后组件仍在响应 signal,订阅泄漏了')
+ .toBe(painted);
+ expect(el.querySelector('.qualityitem')).toBeNull();
+ expect(el.textContent).not.toContain('after.mp4');
+ });
});
diff --git a/frontend/test/quality-goals.test.tsx b/frontend/test/quality-goals.test.tsx
index 126cc881f..00c4ab5b3 100644
--- a/frontend/test/quality-goals.test.tsx
+++ b/frontend/test/quality-goals.test.tsx
@@ -1,32 +1,38 @@
import { render } from 'preact';
import { afterEach, describe, expect, it, vi } from 'vitest';
-import {
- QUALITY_GOALS_URL, QualityGoals, loadQualityGoals,
-} from '../src/islands/quality-goals';
-import type { QualityGoalsData } from '../src/islands/quality-goals';
+import { QualityGoals, loadQualityGoals } from '../src/islands/quality-goals';
+import { QUALITY_GOALS_URL, resetQualityGoals } from '../src/state/quality-goals';
+import type { QualityGoal } from '../src/state/quality-goals';
-import { goal, legacyProps, payload } from './helpers';
+import { goal, legacyProps, payload, seedGoals, seedGoalsError } from './helpers';
-const mount = (data: QualityGoalsData | null, error = '') => {
+/** 画一遍当前的共享状态。数据不再由 props 传进来,所以先灌 store 再画。 */
+const show = () => {
const el = document.createElement('div');
document.body.append(el);
const props = legacyProps();
- render(<QualityGoals {...props} data={data} error={error} />, el);
+ render(<QualityGoals {...props} />, el);
return { el, props };
};
+const mountGoals = async (items: QualityGoal[]) => {
+ await seedGoals(items);
+ return show();
+};
+
afterEach(() => {
document.body.innerHTML = '';
+ resetQualityGoals();
vi.unstubAllGlobals();
});
describe('高清版目标列表', () => {
- it('每条目标一张卡片,读数走遗留层同一套格式化口径', () => {
- const { el } = mount(payload([goal({
+ it('每条目标一张卡片,读数走遗留层同一套格式化口径', async () => {
+ const { el } = await mountGoals([goal({
id: 42, name: 'one.mp4', location: '115', cost: 'metered',
duration: 3725, size: 2147483648, reason: '只有 720p',
- })]));
+ })]);
const item = el.querySelector('.qualityitem');
expect(item).not.toBeNull();
const cells = [...item!.querySelectorAll('p.mono > span')].map(node => node.textContent);
@@ -38,31 +44,31 @@ describe('高清版目标列表', () => {
expect([...item!.querySelectorAll('p')].at(-1)?.textContent).toBe('只有 720p');
});
- it('探测失败的时长显示占位,不显示 0 也不显示负数', () => {
- const { el } = mount(payload([goal({ duration: -1, size: 0 })]));
+ it('探测失败的时长显示占位,不显示 0 也不显示负数', async () => {
+ const { el } = await mountGoals([goal({ duration: -1, size: 0 })]);
const cells = [...el.querySelectorAll('p.mono > span')].map(node => node.textContent);
expect(cells).toEqual(['', '本地', '—', '0 MB']);
});
- it('有番号封面就用番号封面,否则退回海报', () => {
- const withCover = mount(payload([goal({ has_cover: true, code: 'ABC-123' })]));
+ it('有番号封面就用番号封面,否则退回海报', async () => {
+ const withCover = await mountGoals([goal({ has_cover: true, code: 'ABC-123' })]);
expect(withCover.el.querySelector('img')?.getAttribute('src'))
.toBe('/cover?code=ABC-123');
- const withoutCover = mount(payload([goal({ id: 7, has_cover: false })]));
+ const withoutCover = await mountGoals([goal({ id: 7, has_cover: false })]);
expect(withoutCover.el.querySelectorAll('img')[0]?.getAttribute('src'))
.toBe('/poster?id=7&c=4');
});
- it('封面取不到就把图摘掉,卡片其余部分照常显示', () => {
- const { el } = mount(payload([goal()]));
+ it('封面取不到就把图摘掉,卡片其余部分照常显示', async () => {
+ const { el } = await mountGoals([goal()]);
const image = el.querySelector('img')!;
image.dispatchEvent(new Event('error'));
expect(el.querySelector('img')).toBeNull();
expect(el.querySelector('.qualitycover')).not.toBeNull();
});
- it('封面和标题都能打开详情,无障碍名称用纯文本形态', () => {
- const { el, props } = mount(payload([goal({ id: 42 })]));
+ it('封面和标题都能打开详情,无障碍名称用纯文本形态', async () => {
+ const { el, props } = await mountGoals([goal({ id: 42 })]);
const cover = el.querySelector<HTMLButtonElement>('.qualitycover')!;
expect(cover.getAttribute('aria-label')).toBe('打开 名称 one.mp4');
cover.click();
@@ -70,19 +76,28 @@ describe('高清版目标列表', () => {
expect(props.openItem.mock.calls).toEqual([[42], [42]]);
});
- it('没有目标时用共享空态,不是一行灰字', () => {
- const { el } = mount(payload([]));
+ it('没有目标时用共享空态,不是一行灰字', async () => {
+ const { el } = await mountGoals([]);
expect(el.querySelector('[data-geist-empty-state]')).not.toBeNull();
expect(el.querySelector('.es-copy h3')?.textContent).toBe('没有标记中的高清版目标');
expect(el.querySelector('.qualityitem')).toBeNull();
});
- it('读取失败时把原因留在原位,用 error Note', () => {
- const { el } = mount(null, '请求失败(500)');
- const note = el.querySelector('.geist-note-error');
- expect(note?.textContent).toContain('请求失败(500)');
+ it('读取失败时把原因留在原位,用 error Note', async () => {
+ await seedGoalsError('请求失败(500)');
+ const { el } = show();
+ expect(el.querySelector('.geist-note-error')?.textContent).toContain('请求失败(500)');
expect(el.querySelector('[data-geist-empty-state]')).toBeNull();
});
+
+ it('共享状态变了就自己重画,不用重新挂载一遍', async () => {
+ const { el } = await mountGoals([goal({ id: 1, name: 'old.mp4' })]);
+ expect(el.textContent).toContain('old.mp4');
+ await seedGoals([goal({ id: 2, name: 'new.mp4' }), goal({ id: 3, name: 'also.mp4' })]);
+ expect(el.querySelectorAll('.qualityitem')).toHaveLength(2);
+ expect(el.textContent).toContain('new.mp4');
+ expect(el.textContent).not.toContain('old.mp4');
+ });
});
describe('loadQualityGoals', () => {
@@ -98,4 +113,15 @@ describe('loadQualityGoals', () => {
expect((fetched.mock.calls[0]?.[1] as RequestInit).signal).toBe(controller.signal);
expect((fetched.mock.calls[0]?.[1] as RequestInit).credentials).toBe('same-origin');
});
+
+ it('首屏一律重取:这一页的刷新就是重新进来一次,不能被缓存吃掉', async () => {
+ await seedGoals([goal({ id: 1, name: 'cached.mp4' })]);
+ const fetched = vi.fn(async (_input: string, _init?: RequestInit) => (
+ { ok: true, status: 200, json: async () => payload([goal({ id: 2, name: 'fresh.mp4' })]) }
+ ));
+ vi.stubGlobal('fetch', fetched);
+ const data = await loadQualityGoals(legacyProps(), new AbortController().signal);
+ expect(fetched).toHaveBeenCalledTimes(1);
+ expect(data.items[0]?.name).toBe('fresh.mp4');
+ });
});
diff --git a/frontend/test/state.test.ts b/frontend/test/state.test.ts
new file mode 100644
index 000000000..30fb69dc4
--- /dev/null
+++ b/frontend/test/state.test.ts
@@ -0,0 +1,144 @@
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+import { refreshStore, resetStores, storeNames } from '../src/state';
+import {
+ QUALITY_GOALS_URL, ensureQualityGoals, qualityGoals, qualityGoalsTotal,
+ refreshQualityGoals, resetQualityGoals,
+} from '../src/state/quality-goals';
+
+import { deferredFetch, failFetch, goal, okFetch, payload } from './helpers';
+
+afterEach(() => {
+ resetStores();
+ vi.unstubAllGlobals();
+});
+
+describe('共享 store 的写入口', () => {
+ it('导出的是只读视图:直接赋值在运行期就失败,不是靠约定', () => {
+ // @ts-expect-error 这条断言的目的就是「组件里写不了」既是类型错误也是运行期错误。
+ expect(() => { qualityGoals.value = { data: null, error: '改我' }; }).toThrow(TypeError);
+ expect(qualityGoals.value.error).toBe('');
+ });
+
+ it('登记的名字就是遗留层能刷新的名字', () => {
+ expect(storeNames()).toEqual(['quality-goals']);
+ });
+
+ it('未登记的名字立刻失败,不是静默什么都不做', async () => {
+ // @ts-expect-error 名字不在注册表里:运行期也要拦住。
+ await expect(refreshStore('nope')).rejects.toThrow('未登记的共享 store:nope');
+ });
+
+ it('遗留层按名字刷新,拿到的是「成功了没有」而不是异常', async () => {
+ vi.stubGlobal('fetch', okFetch(payload([goal({ id: 5 })])));
+ expect(await refreshStore('quality-goals')).toBe(true);
+ expect(qualityGoalsTotal.value).toBe(1);
+
+ vi.stubGlobal('fetch', failFetch(503, '账本正在维护'));
+ expect(await refreshStore('quality-goals'), '失败不抛:调用点在遗留层是 fire-and-forget')
+ .toBe(false);
+ expect(qualityGoals.value.error).toBe('账本正在维护');
+ });
+});
+
+describe('高清版目标 store', () => {
+ it('读到之前 total 是 null,不是 0:那和「一个都没有」是两件事', () => {
+ expect(qualityGoalsTotal.value).toBeNull();
+ expect(qualityGoals.value).toEqual({ data: null, error: '' });
+ });
+
+ it('取的是那个契约端点,结果落进 signal', async () => {
+ const fetched = okFetch(payload([goal({ id: 1 }), goal({ id: 2 })]));
+ vi.stubGlobal('fetch', fetched);
+ const data = await refreshQualityGoals();
+ expect(fetched.mock.calls[0]?.[0]).toBe(QUALITY_GOALS_URL);
+ expect(data.items).toHaveLength(2);
+ expect(qualityGoals.value.data?.items).toHaveLength(2);
+ expect(qualityGoalsTotal.value).toBe(2);
+ });
+
+ it('ensure 只取一次:第二个读者读到的是同一份,不再发请求', async () => {
+ const fetched = okFetch(payload([goal({ id: 3 })]));
+ vi.stubGlobal('fetch', fetched);
+ const first = await ensureQualityGoals();
+ const second = await ensureQualityGoals();
+ expect(fetched).toHaveBeenCalledTimes(1);
+ expect(second).toBe(first);
+ });
+
+ it('两个读者同时开口也只发一个请求', async () => {
+ const fetch = deferredFetch(payload([goal({ id: 4 })]));
+ fetch.install();
+ const both = Promise.all([ensureQualityGoals(), ensureQualityGoals()]);
+ fetch.resolve();
+ const [left, right] = await both;
+ expect(fetch.fetched).toHaveBeenCalledTimes(1);
+ expect(left).toBe(right);
+ });
+
+ it('refresh 无视缓存,ensure 之后仍然重取', async () => {
+ vi.stubGlobal('fetch', okFetch(payload([goal({ id: 1, name: 'old.mp4' })])));
+ await ensureQualityGoals();
+ const fetched = okFetch(payload([goal({ id: 2, name: 'new.mp4' })]));
+ vi.stubGlobal('fetch', fetched);
+ await refreshQualityGoals();
+ expect(fetched).toHaveBeenCalledTimes(1);
+ expect(qualityGoals.value.data?.items[0]?.name).toBe('new.mp4');
+ });
+
+ it('失败态换掉旧数据:屏幕上不能既说读取失败又列着上一次的结果', async () => {
+ vi.stubGlobal('fetch', okFetch(payload([goal({ id: 1 })])));
+ await refreshQualityGoals();
+ vi.stubGlobal('fetch', failFetch(409, '账本当前只能浏览'));
+ await expect(refreshQualityGoals()).rejects.toThrow('账本当前只能浏览');
+ expect(qualityGoals.value).toEqual({ data: null, error: '账本当前只能浏览' });
+ expect(qualityGoalsTotal.value).toBeNull();
+ });
+
+ it('失败之后 ensure 会再试一次,不把错误态当成缓存', async () => {
+ vi.stubGlobal('fetch', failFetch(500, '读取失败'));
+ await expect(ensureQualityGoals()).rejects.toThrow('读取失败');
+ const fetched = okFetch(payload([goal({ id: 9 })]));
+ vi.stubGlobal('fetch', fetched);
+ await ensureQualityGoals();
+ expect(fetched).toHaveBeenCalledTimes(1);
+ expect(qualityGoals.value.error).toBe('');
+ });
+
+ it('中止不写错误态:页面是被用户换掉的,不是读取失败', async () => {
+ vi.stubGlobal('fetch', okFetch(payload([goal({ id: 1 })])));
+ await refreshQualityGoals();
+ const pending = deferredFetch(payload([goal({ id: 2 })]));
+ pending.install();
+ const controller = new AbortController();
+ const refreshing = refreshQualityGoals(controller.signal);
+ controller.abort();
+ await expect(refreshing).rejects.toThrow();
+ expect(qualityGoals.value.error, '中止被记成失败就是谎报').toBe('');
+ expect(qualityGoals.value.data?.items[0]?.id).toBe(1);
+ });
+
+ it('迟到的响应盖不住比它更新的那一次', async () => {
+ const slow = deferredFetch(payload([goal({ id: 1, name: 'slow.mp4' })]));
+ slow.install();
+ const first = refreshQualityGoals();
+ const quick = deferredFetch(payload([goal({ id: 2, name: 'quick.mp4' })]));
+ quick.install();
+ const second = refreshQualityGoals();
+ quick.resolve();
+ await second;
+ slow.resolve();
+ await first;
+ expect(qualityGoals.value.data?.items[0]?.name).toBe('quick.mp4');
+ });
+
+ it('reset 把状态清回未读,下一次 ensure 重新取', async () => {
+ const fetched = okFetch(payload([goal({ id: 1 })]));
+ vi.stubGlobal('fetch', fetched);
+ await ensureQualityGoals();
+ resetQualityGoals();
+ expect(qualityGoals.value).toEqual({ data: null, error: '' });
+ await ensureQualityGoals();
+ expect(fetched).toHaveBeenCalledTimes(2);
+ });
+});
diff --git a/tests/test_frontend_build.py b/tests/test_frontend_build.py
index 879c6105c..485f86319 100644
--- a/tests/test_frontend_build.py
+++ b/tests/test_frontend_build.py
@@ -48,7 +48,9 @@ class IslandBundleTests(unittest.TestCase):
f"{name} 带了内容哈希,app.js 里写死的路径会指向不存在的文件")
def test_bundle_exports_the_mount_contract(self):
- for symbol in ("mountIsland", "unmountIsland", "islandNames"):
+ # `refreshStore` 是遗留层通知岛「共享数据变了」的入口(ADR-0022 里 signals 的
+ # 那一半)。它不在产物里,`web/app.js` 就只剩整屏重新挂载这一种刷新方式。
+ for symbol in ("mountIsland", "unmountIsland", "islandNames", "refreshStore"):
self.assertIn(f"as {symbol}", self.bundle, f"产物没有导出 {symbol}")
def test_bundle_keeps_the_legacy_modules_external(self):
@@ -155,12 +157,50 @@ class IslandSourceContractTests(unittest.TestCase):
self.assertIn(helper, self.source)
def test_the_endpoint_is_declared_once(self):
- self.assertIn("/api/quality-goals?limit=200", self.source)
+ """端点在前端只能有一个声明处,现在是那份共享 store。
+
+ 取数已经从 island 搬进 `frontend/src/state/quality-goals.ts`:`/manage` 的
+ 「高清版」卡片读的是同一个真相。所以这里扫整棵 `frontend/src`,而不是钉住
+ 某个文件——要拦的是「两个地方各写一遍这条 URL」,不是它住在哪儿。
+ """
+ sources = sorted(path for path in (FRONTEND / "src").rglob("*.ts*"))
+ declared = [path.name for path in sources
+ if "/api/quality-goals?limit=200" in path.read_text(encoding="utf-8")]
+ self.assertEqual(declared, ["quality-goals.ts"], f"端点声明在 {declared}")
# 扫整个 web 层:路由表已经从 `web_contract.py` 搬到 `web_router.py`,
# 前者只剩再导出。island 关心的是这条路由存在且只声明一次,不是它在哪个文件。
- declared = [path.name for path in sorted((ROOT / "src" / "peach").glob("web_*.py"))
- if "quality-goals" in path.read_text(encoding="utf-8")]
- self.assertEqual(len(declared), 1, f"quality-goals 声明在 {declared}")
+ routed = [path.name for path in sorted((ROOT / "src" / "peach").glob("web_*.py"))
+ if "quality-goals" in path.read_text(encoding="utf-8")]
+ self.assertEqual(len(routed), 1, f"quality-goals 声明在 {routed}")
+
+
+class SharedStateContractTests(unittest.TestCase):
+ """跨岛共享状态只有一个家(ADR-0022)。
+
+ 这两条门槛拦的是同一件事:共享数据长出第二个来源。运行期那一半由 vitest 盯着
+ (`test/state.test.ts` 断言直接赋值会抛 TypeError),这里盯的是源码布局——
+ 等到跑起来才发现两个岛各存一份,已经晚了。
+ """
+
+ def setUp(self):
+ self.state = FRONTEND / "src" / "state"
+ self.sources = sorted((FRONTEND / "src").rglob("*.ts*"))
+
+ def test_stores_expose_read_only_views(self):
+ """可写的 signal 不导出:写入只能走 store 自己的函数,「谁改了它」才数得出来。"""
+ for path in sorted(self.state.glob("*.ts")):
+ source = path.read_text(encoding="utf-8")
+ self.assertNotRegex(
+ source, r"export\s+(?:const|let)\s+\w+[^=\n]*=\s*signal\(",
+ f"{path.name} 导出了可写 signal,组件可以绕过写入函数直接赋值")
+
+ def test_signals_only_live_in_the_state_folder(self):
+ """岛自己的临时状态用 hooks。在别处 import signal,就是共享数据有了第二个家。"""
+ outside = [path.name for path in self.sources
+ if self.state not in path.parents
+ and "@preact/signals" in path.read_text(encoding="utf-8")]
+ self.assertEqual(outside, [],
+ f"{outside} 在 state/ 之外用了 signal:共享状态请建 store,局部状态用 hooks")
class VitestTests(unittest.TestCase):
diff --git a/web/dist/peach-ui.js b/web/dist/peach-ui.js
index fe4dfb8c9..126f53a10 100644
--- a/web/dist/peach-ui.js
+++ b/web/dist/peach-ui.js
@@ -1,12 +1,12 @@
import { LOC as e, fmtDur as t, fmtSize as n } from "/js/core.js";
import { emptyStateHtml as r, noteHtml as i } from "/js/ui-components.js";
//#region node_modules/preact/dist/preact.module.js
-var a, o, s, c, l, u, d, f, p, m, h, g, _, v, y = {}, b = [], x = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, S = Array.isArray;
-function C(e, t) {
+var a, o, s, c, l, u, d, f, p, m, h, g, _, v, y, b = {}, x = [], S = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, C = Array.isArray;
+function w(e, t) {
for (var n in t) e[n] = t[n];
return e;
}
-function w(e) {
+function ee(e) {
e && e.parentNode && e.parentNode.removeChild(e);
}
function T(e, t, n) {
@@ -44,42 +44,42 @@ function k(e, t) {
for (var n; t < e.__k.length; t++) if ((n = e.__k[t]) != null && n.__e != null) return n.__e;
return typeof e.type == "function" ? k(e) : null;
}
-function A(e) {
+function te(e) {
if (e.__P && e.__d) {
- var t = e.__v, n = t.__e, r = [], i = [], a = C({}, t);
- a.__v = t.__v + 1, o.vnode && o.vnode(a), V(e.__P, a, t, e.__n, e.__P.namespaceURI, 32 & t.__u ? [n] : null, r, n ?? k(t), !!(32 & t.__u), i), a.__v = t.__v, a.__.__k[a.__i] = a, U(r, a, i), t.__e = t.__ = null, a.__e != n && j(a);
+ var t = e.__v, n = t.__e, r = [], i = [], a = w({}, t);
+ a.__v = t.__v + 1, o.vnode && o.vnode(a), le(e.__P, a, t, e.__n, e.__P.namespaceURI, 32 & t.__u ? [n] : null, r, n ?? k(t), !!(32 & t.__u), i), a.__v = t.__v, a.__.__k[a.__i] = a, de(r, a, i), t.__e = t.__ = null, a.__e != n && A(a);
}
}
-function j(e) {
+function A(e) {
if ((e = e.__) != null && e.__c != null) return e.__e = e.__c.base = null, e.__k.some(function(t) {
if (t != null && t.__e != null) return e.__e = e.__c.base = t.__e;
- }), j(e);
+ }), A(e);
}
-function M(e) {
- (!e.__d && (e.__d = !0) && c.push(e) && !N.__r++ || l != o.debounceRendering) && ((l = o.debounceRendering) || u)(N);
+function j(e) {
+ (!e.__d && (e.__d = !0) && l.push(e) && !M.__r++ || u != o.debounceRendering) && ((u = o.debounceRendering) || d)(M);
}
-function N() {
+function M() {
try {
- for (var e, t = 1; c.length;) c.length > t && c.sort(d), e = c.shift(), t = c.length, A(e);
+ for (var e, t = 1; l.length;) l.length > t && l.sort(f), e = l.shift(), t = l.length, te(e);
} finally {
- c.length = N.__r = 0;
+ l.length = M.__r = 0;
}
}
-function P(e, t, n, r, i, a, o, s, c, l, u) {
- var d, f, p, m, h, g, _ = r && r.__k || b, v = t.length;
- for (c = F(n, t, _, c, v), d = 0; d < v; d++) (p = n.__k[d]) != null && (f = p.__i != -1 && _[p.__i] || y, p.__i = d, g = V(e, p, f, i, a, o, s, c, l, u), m = p.__e, p.ref && f.ref != p.ref && (f.ref && K(f.ref, null, p), u.push(p.ref, p.__c || m, p)), h == null && m != null && (h = m), 4 & p.__u ? (c = I(p, c, e), f.__e && (f.__e = null)) : typeof p.type == "function" && g !== void 0 ? c = g : m && (c = m.nextSibling), p.__u &= -7);
+function ne(e, t, n, r, i, a, o, s, c, l, u) {
+ var d, f, p, m, h, g, _ = r && r.__k || x, v = t.length;
+ for (c = re(n, t, _, c, v), d = 0; d < v; d++) (p = n.__k[d]) != null && (f = p.__i != -1 && _[p.__i] || b, p.__i = d, g = le(e, p, f, i, a, o, s, c, l, u), m = p.__e, p.ref && f.ref != p.ref && (f.ref && me(f.ref, null, p), u.push(p.ref, p.__c || m, p)), h == null && m != null && (h = m), 4 & p.__u ? (c = ie(p, c, e), f.__e && (f.__e = null)) : typeof p.type == "function" && g !== void 0 ? c = g : m && (c = m.nextSibling), p.__u &= -7);
return n.__e = h, c;
}
-function F(e, t, n, r, i) {
+function re(e, t, n, r, i) {
var a, o, s, c, l, u = n.length, d = u, f = 0;
- for (e.__k = Array(i), a = 0; a < i; a++) (o = t[a]) != null && typeof o != "boolean" && typeof o != "function" ? (typeof o == "string" || typeof o == "number" || typeof o == "bigint" || o.constructor == String ? o = e.__k[a] = E(null, o, null, null, null) : S(o) ? o = e.__k[a] = E(D, { children: o }, null, null, null) : o.constructor === void 0 && o.__b > 0 ? o = e.__k[a] = E(o.type, o.props, o.key, o.ref ? o.ref : null, o.__v) : e.__k[a] = o, c = a + f, o.__ = e, o.__b = e.__b + 1, s = null, (l = o.__i = L(o, n, c, d)) != -1 && (d--, (s = n[l]) && (s.__u |= 2)), s == null || s.__v == null ? (l == -1 && (i > u ? f-- : i < u && f++), typeof o.type != "function" && (o.__u |= 4)) : l != c && (l == c - 1 ? f-- : l == c + 1 ? f++ : (l > c ? f-- : f++, o.__u |= 4))) : e.__k[a] = null;
- if (d) for (a = 0; a < u; a++) (s = n[a]) != null && !(2 & s.__u) && (s.__e == r && (r = k(s)), q(s, s));
+ for (e.__k = Array(i), a = 0; a < i; a++) (o = t[a]) != null && typeof o != "boolean" && typeof o != "function" ? (typeof o == "string" || typeof o == "number" || typeof o == "bigint" || o.constructor == String ? o = e.__k[a] = E(null, o, null, null, null) : C(o) ? o = e.__k[a] = E(D, { children: o }, null, null, null) : o.constructor === void 0 && o.__b > 0 ? o = e.__k[a] = E(o.type, o.props, o.key, o.ref ? o.ref : null, o.__v) : e.__k[a] = o, c = a + f, o.__ = e, o.__b = e.__b + 1, s = null, (l = o.__i = ae(o, n, c, d)) != -1 && (d--, (s = n[l]) && (s.__u |= 2)), s == null || s.__v == null ? (l == -1 && (i > u ? f-- : i < u && f++), typeof o.type != "function" && (o.__u |= 4)) : l != c && (l == c - 1 ? f-- : l == c + 1 ? f++ : (l > c ? f-- : f++, o.__u |= 4))) : e.__k[a] = null;
+ if (d) for (a = 0; a < u; a++) (s = n[a]) != null && !(2 & s.__u) && (s.__e == r && (r = k(s)), he(s, s));
return r;
}
-function I(e, t, n) {
+function ie(e, t, n) {
var r, i;
if (typeof e.type == "function") {
- for (r = e.__k, i = 0; r && i < r.length; i++) r[i] && (r[i].__ = e, t = I(r[i], t, n));
+ for (r = e.__k, i = 0; r && i < r.length; i++) r[i] && (r[i].__ = e, t = ie(r[i], t, n));
return t;
}
e.__e != t && (t && e.type && !t.parentNode && (t = k(e)), t = n.insertBefore(e.__e, t || null));
@@ -88,7 +88,7 @@ function I(e, t, n) {
while (t != null && t.nodeType == 8);
return t;
}
-function L(e, t, n, r) {
+function ae(e, t, n, r) {
var i, a, o, s = e.key, c = e.type, l = t[n], u = l != null && !(2 & l.__u);
if (l === null && s == null || u && s == l.key && c == l.type) return n;
if (r > +!!u) {
@@ -96,18 +96,18 @@ function L(e, t, n, r) {
}
return -1;
}
-function R(e, t, n) {
- t[0] == "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" || x.test(t) ? n : n + "px";
+function oe(e, t, n) {
+ t[0] == "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" || S.test(t) ? n : n + "px";
}
-function z(e, t, n, r, i) {
+function se(e, t, n, r, i) {
var a, o;
n: if (t == "style") {
if (typeof n == "string") e.style.cssText = n;
else {
- if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || R(e.style, t, "");
- if (n) for (t in n) r && n[t] == r[t] || R(e.style, t, n[t]);
+ if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || oe(e.style, t, "");
+ if (n) for (t in n) r && n[t] == r[t] || oe(e.style, t, n[t]);
}
- } else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(h, "$1")), o = t.toLowerCase(), t = o in e || t == "onFocusOut" || t == "onFocusIn" ? o.slice(2) : t.slice(2), e.l ||= {}, e.l[t + a] = n, n ? r ? n[m] = r[m] : (n[m] = g, e.addEventListener(t, a ? v : _, a)) : e.removeEventListener(t, a ? v : _, a);
+ } else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(g, "$1")), o = t.toLowerCase(), t = o in e || t == "onFocusOut" || t == "onFocusIn" ? o.slice(2) : t.slice(2), e.l ||= {}, e.l[t + a] = n, n ? r ? n[h] = r[h] : (n[h] = _, e.addEventListener(t, a ? y : v, a)) : e.removeEventListener(t, a ? y : v, a);
else {
if (i == "http://www.w3.org/2000/svg") t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
else if (t != "width" && t != "height" && t != "href" && t != "list" && t != "form" && t != "tabIndex" && t != "download" && t != "rowSpan" && t != "colSpan" && t != "role" && t != "popover" && t in e) try {
@@ -117,57 +117,57 @@ function z(e, t, n, r, i) {
typeof n == "function" || (n == null || !1 === n && t[4] != "-" ? e.removeAttribute(t) : e.setAttribute(t, t == "popover" && n == 1 ? "" : n));
}
}
-function B(e) {
+function ce(e) {
return function(t) {
if (this.l) {
var n = this.l[t.type + e];
- if (t[p] == null) t[p] = g++;
- else if (t[p] < n[m]) return;
+ if (t[m] == null) t[m] = _++;
+ else if (t[m] < n[h]) return;
return n(o.event ? o.event(t) : t);
}
};
}
-function V(e, t, n, r, i, a, s, c, l, u) {
- var d, f, p, m, h, g, _, v, y, x, T, E, A, j, M, N, F = t.type;
+function le(e, t, n, r, i, a, s, c, l, u) {
+ var d, f, p, m, h, g, _, v, y, b, S, T, E, te, A, j, M = t.type;
if (t.constructor !== void 0) return null;
128 & n.__u && (l = !!(32 & n.__u), a = [c = t.__e = n.__e]), (d = o.__b) && d(t);
- n: if (typeof F == "function") {
+ n: if (typeof M == "function") {
f = s.length;
try {
- if (y = t.props, x = F.prototype && F.prototype.render, T = (d = F.contextType) && r[d.__c], E = d ? T ? T.props.value : d.__ : r, n.__c ? v = (p = t.__c = n.__c).__ = p.__E : (x ? t.__c = p = new F(y, E) : (t.__c = p = new O(y, E), p.constructor = F, p.render = J), T && T.sub(p), p.state || (p.state = {}), p.__n = r, m = p.__d = !0, p.__h = [], p._sb = []), x && p.__s == null && (p.__s = p.state), x && F.getDerivedStateFromProps != null && (p.__s == p.state && (p.__s = C({}, p.__s)), C(p.__s, F.getDerivedStateFromProps(y, p.__s))), h = p.props, g = p.state, p.__v = t, m) x && F.getDerivedStateFromProps == null && p.componentWillMount != null && p.componentWillMount(), x && p.componentDidMount != null && p.__h.push(p.componentDidMount);
+ if (y = t.props, b = M.prototype && M.prototype.render, S = (d = M.contextType) && r[d.__c], T = d ? S ? S.props.value : d.__ : r, n.__c ? v = (p = t.__c = n.__c).__ = p.__E : (b ? t.__c = p = new M(y, T) : (t.__c = p = new O(y, T), p.constructor = M, p.render = ge), S && S.sub(p), p.state || (p.state = {}), p.__n = r, m = p.__d = !0, p.__h = [], p._sb = []), b && p.__s == null && (p.__s = p.state), b && M.getDerivedStateFromProps != null && (p.__s == p.state && (p.__s = w({}, p.__s)), w(p.__s, M.getDerivedStateFromProps(y, p.__s))), h = p.props, g = p.state, p.__v = t, m) b && M.getDerivedStateFromProps == null && p.componentWillMount != null && p.componentWillMount(), b && p.componentDidMount != null && p.__h.push(p.componentDidMount);
else {
- if (x && F.getDerivedStateFromProps == null && y !== h && p.componentWillReceiveProps != null && p.componentWillReceiveProps(y, E), t.__v == n.__v || !p.__e && p.shouldComponentUpdate != null && !1 === p.shouldComponentUpdate(y, p.__s, E)) {
+ if (b && M.getDerivedStateFromProps == null && y !== h && p.componentWillReceiveProps != null && p.componentWillReceiveProps(y, T), t.__v == n.__v || !p.__e && p.shouldComponentUpdate != null && !1 === p.shouldComponentUpdate(y, p.__s, T)) {
t.__v != n.__v && (p.props = y, p.state = p.__s, p.__d = !1), t.__e = n.__e, t.__k = n.__k, t.__k.some(function(e) {
e && (e.__ = t);
- }), b.push.apply(p.__h, p._sb), p._sb = [], p.__h.length && s.push(p), c = k(n);
+ }), x.push.apply(p.__h, p._sb), p._sb = [], p.__h.length && s.push(p), c = k(n);
break n;
}
- p.componentWillUpdate != null && p.componentWillUpdate(y, p.__s, E), x && p.componentDidUpdate != null && p.__h.push(function() {
+ p.componentWillUpdate != null && p.componentWillUpdate(y, p.__s, T), b && p.componentDidUpdate != null && p.__h.push(function() {
p.componentDidUpdate(h, g, _);
});
}
- if (p.context = E, p.props = y, p.__P = e, p.__e = !1, A = o.__r, j = 0, x) p.state = p.__s, p.__d = !1, A && A(t), d = p.render(p.props, p.state, p.context), b.push.apply(p.__h, p._sb), p._sb = [];
+ if (p.context = T, p.props = y, p.__P = e, p.__e = !1, E = o.__r, te = 0, b) p.state = p.__s, p.__d = !1, E && E(t), d = p.render(p.props, p.state, p.context), x.push.apply(p.__h, p._sb), p._sb = [];
else do
- p.__d = !1, A && A(t), d = p.render(p.props, p.state, p.context), p.state = p.__s;
- while (p.__d && ++j < 25);
- p.state = p.__s, p.getChildContext != null && (r = C(C({}, r), p.getChildContext())), x && !m && p.getSnapshotBeforeUpdate != null && (_ = p.getSnapshotBeforeUpdate(h, g)), M = d != null && d.type === D && d.key == null ? W(d.props.children) : d, c = P(e, S(M) ? M : [M], t, n, r, i, a, s, c, l, u), p.base = t.__e, t.__u &= -161, p.__h.length && s.push(p), v && (p.__E = p.__ = null);
+ p.__d = !1, E && E(t), d = p.render(p.props, p.state, p.context), p.state = p.__s;
+ while (p.__d && ++te < 25);
+ p.state = p.__s, p.getChildContext != null && (r = w(w({}, r), p.getChildContext())), b && !m && p.getSnapshotBeforeUpdate != null && (_ = p.getSnapshotBeforeUpdate(h, g)), A = d != null && d.type === D && d.key == null ? fe(d.props.children) : d, c = ne(e, C(A) ? A : [A], t, n, r, i, a, s, c, l, u), p.base = t.__e, t.__u &= -161, p.__h.length && s.push(p), v && (p.__E = p.__ = null);
} catch (e) {
if (s.length = f, t.__v = null, l || a != null) {
if (e.then) {
for (t.__u |= l ? 160 : 128; c && c.nodeType == 8 && c.nextSibling;) c = c.nextSibling;
a != null && (a[a.indexOf(c)] = null), t.__e = c;
- } else if (a != null) for (N = a.length; N--;) w(a[N]);
+ } else if (a != null) for (j = a.length; j--;) ee(a[j]);
} else t.__e = n.__e;
- t.__k ??= n.__k || [], e.then || H(t), o.__e(e, t, n);
+ t.__k ??= n.__k || [], e.then || ue(t), o.__e(e, t, n);
}
- } else a == null && t.__v == n.__v ? (t.__k = n.__k, t.__e = n.__e) : c = t.__e = G(n.__e, t, n, r, i, a, s, l, u);
+ } else a == null && t.__v == n.__v ? (t.__k = n.__k, t.__e = n.__e) : c = t.__e = pe(n.__e, t, n, r, i, a, s, l, u);
return (d = o.diffed) && d(t), 128 & t.__u ? void 0 : c;
}
-function H(e) {
- e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(H));
+function ue(e) {
+ e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(ue));
}
-function U(e, t, n) {
- for (var r = 0; r < n.length; r++) K(n[r], n[++r], n[++r]);
+function de(e, t, n) {
+ for (var r = 0; r < n.length; r++) me(n[r], n[++r], n[++r]);
o.__c && o.__c(t, e), e.some(function(t) {
try {
e = t.__h, t.__h = [], e.some(function(e) {
@@ -178,11 +178,11 @@ function U(e, t, n) {
}
});
}
-function W(e) {
- return typeof e != "object" || !e || e.__b > 0 ? e : S(e) ? e.map(W) : e.constructor === void 0 ? C({}, e) : null;
+function fe(e) {
+ return typeof e != "object" || !e || e.__b > 0 ? e : C(e) ? e.map(fe) : e.constructor === void 0 ? w({}, e) : null;
}
-function G(e, t, n, r, i, s, c, l, u) {
- var d, f, p, m, h, g, _, v = n.props || y, b = t.props, x = t.type;
+function pe(e, t, n, r, i, s, c, l, u) {
+ var d, f, p, m, h, g, _, v = n.props || b, y = t.props, x = t.type;
if (x == "svg" ? i = "http://www.w3.org/2000/svg" : x == "math" ? i = "http://www.w3.org/1998/Math/MathML" : i ||= "http://www.w3.org/1999/xhtml", s != null) {
for (d = 0; d < s.length; d++) if ((h = s[d]) && "setAttribute" in h == !!x && (x ? h.localName == x : h.nodeType == 3)) {
e = h, s[d] = null;
@@ -190,21 +190,21 @@ function G(e, t, n, r, i, s, c, l, u) {
}
}
if (e == null) {
- if (x == null) return document.createTextNode(b);
- e = document.createElementNS(i, x, b.is && b), l &&= (o.__m && o.__m(t, s), !1), s = null;
+ if (x == null) return document.createTextNode(y);
+ e = document.createElementNS(i, x, y.is && y), l &&= (o.__m && o.__m(t, s), !1), s = null;
}
- if (x == null) v === b || l && e.data == b || (e.data = b);
+ if (x == null) v === y || l && e.data == y || (e.data = y);
else {
- if (s = x == "textarea" && b.defaultValue != null ? null : s && a.call(e.childNodes), !l && s != null) for (v = {}, d = 0; d < e.attributes.length; d++) v[(h = e.attributes[d]).name] = h.value;
- for (d in v) h = v[d], d == "dangerouslySetInnerHTML" ? p = h : d == "children" || d in b || d == "value" && "defaultValue" in b || d == "checked" && "defaultChecked" in b || z(e, d, null, h, i);
- for (d in b) h = b[d], d == "children" ? m = h : d == "dangerouslySetInnerHTML" ? f = h : d == "value" ? g = h : d == "checked" ? _ = h : l && typeof h != "function" || v[d] === h || z(e, d, h, v[d], i);
+ if (s = x == "textarea" && y.defaultValue != null ? null : s && a.call(e.childNodes), !l && s != null) for (v = {}, d = 0; d < e.attributes.length; d++) v[(h = e.attributes[d]).name] = h.value;
+ for (d in v) h = v[d], d == "dangerouslySetInnerHTML" ? p = h : d == "children" || d in y || d == "value" && "defaultValue" in y || d == "checked" && "defaultChecked" in y || se(e, d, null, h, i);
+ for (d in y) h = y[d], d == "children" ? m = h : d == "dangerouslySetInnerHTML" ? f = h : d == "value" ? g = h : d == "checked" ? _ = h : l && typeof h != "function" || v[d] === h || se(e, d, h, v[d], i);
if (f) l || p && (f.__html == p.__html || f.__html == e.innerHTML) || (e.innerHTML = f.__html), t.__k = [];
- else if (p && (e.innerHTML = ""), P(t.type == "template" ? e.content : e, S(m) ? m : [m], t, n, r, x == "foreignObject" ? "http://www.w3.org/1999/xhtml" : i, s, c, s ? s[0] : n.__k && k(n, 0), l, u), s != null) for (d = s.length; d--;) w(s[d]);
- l && x != "textarea" || (d = "value", x == "progress" && g == null ? e.removeAttribute("value") : g != null && (g !== e[d] || x == "progress" && !g || x == "option" && g != v[d]) && z(e, d, g, v[d], i), d = "checked", _ != null && _ != e[d] && z(e, d, _, v[d], i));
+ else if (p && (e.innerHTML = ""), ne(t.type == "template" ? e.content : e, C(m) ? m : [m], t, n, r, x == "foreignObject" ? "http://www.w3.org/1999/xhtml" : i, s, c, s ? s[0] : n.__k && k(n, 0), l, u), s != null) for (d = s.length; d--;) ee(s[d]);
+ l && x != "textarea" || (d = "value", x == "progress" && g == null ? e.removeAttribute("value") : g != null && (g !== e[d] || x == "progress" && !g || x == "option" && g != v[d]) && se(e, d, g, v[d], i), d = "checked", _ != null && _ != e[d] && se(e, d, _, v[d], i));
}
return e;
}
-function K(e, t, n) {
+function me(e, t, n) {
try {
if (typeof e == "function") {
var r = typeof e.__u == "function";
@@ -214,9 +214,9 @@ function K(e, t, n) {
o.__e(e, n);
}
}
-function q(e, t, n) {
+function he(e, t, n) {
var r, i;
- if (o.unmount && o.unmount(e), (r = e.ref) && (r.current && r.current != e.__e || K(r, null, t)), (r = e.__c) != null) {
+ if (o.unmount && o.unmount(e), (r = e.ref) && (r.current && r.current != e.__e || me(r, null, t)), (r = e.__c) != null) {
if (r.componentWillUnmount) try {
r.componentWillUnmount();
} catch (e) {
@@ -224,39 +224,41 @@ function q(e, t, n) {
}
r.base = r.__P = r.__n = null;
}
- if (r = e.__k) for (i = 0; i < r.length; i++) r[i] && q(r[i], t, n || typeof e.type != "function");
- n || w(e.__e), e.__c = e.__ = e.__e = void 0;
+ if (r = e.__k) for (i = 0; i < r.length; i++) r[i] && he(r[i], t, n || typeof e.type != "function");
+ n || ee(e.__e), e.__c = e.__ = e.__e = void 0;
}
-function J(e, t, n) {
+function ge(e, t, n) {
return this.constructor(e, n);
}
-function Y(e, t, n) {
+function _e(e, t, n) {
var r, i, s, c;
- t == document && (t = document.documentElement), o.__ && o.__(e, t), i = (r = typeof n == "function") ? null : n && n.__k || t.__k, s = [], c = [], V(t, e = (!r && n || t).__k = T(D, null, [e]), i || y, y, t.namespaceURI, !r && n ? [n] : i ? null : t.firstChild ? a.call(t.childNodes) : null, s, !r && n ? n : i ? i.__e : t.firstChild, r, c), U(s, e, c), e.props.children = null;
+ t == document && (t = document.documentElement), o.__ && o.__(e, t), i = (r = typeof n == "function") ? null : n && n.__k || t.__k, s = [], c = [], le(t, e = (!r && n || t).__k = T(D, null, [e]), i || b, b, t.namespaceURI, !r && n ? [n] : i ? null : t.firstChild ? a.call(t.childNodes) : null, s, !r && n ? n : i ? i.__e : t.firstChild, r, c), de(s, e, c), e.props.children = null;
}
-a = b.slice, o = { __e: function(e, t, n, r) {
+a = x.slice, o = { __e: function(e, t, n, r) {
for (var i, a, o; t = t.__;) if ((i = t.__c) && !i.__) try {
if ((a = i.constructor) && a.getDerivedStateFromError != null && (i.setState(a.getDerivedStateFromError(e)), o = i.__d), i.componentDidCatch != null && (i.componentDidCatch(e, r || {}), o = i.__d), o) return i.__E = i;
} catch (t) {
e = t;
}
throw e;
-} }, s = 0, O.prototype.setState = function(e, t) {
- var n = this.__s != null && this.__s != this.state ? this.__s : this.__s = C({}, this.state);
- typeof e == "function" && (e = e(C({}, n), this.props)), e && C(n, e), e != null && this.__v && (t && this._sb.push(t), M(this));
+} }, s = 0, c = function(e) {
+ return e != null && e.constructor === void 0;
+}, O.prototype.setState = function(e, t) {
+ var n = this.__s != null && this.__s != this.state ? this.__s : this.__s = w({}, this.state);
+ typeof e == "function" && (e = e(w({}, n), this.props)), e && w(n, e), e != null && this.__v && (t && this._sb.push(t), j(this));
}, O.prototype.forceUpdate = function(e) {
- this.__v && (this.__e = !0, e && this.__h.push(e), M(this));
-}, O.prototype.render = D, c = [], u = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, d = function(e, t) {
+ this.__v && (this.__e = !0, e && this.__h.push(e), j(this));
+}, O.prototype.render = D, l = [], d = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, f = function(e, t) {
return e.__v.__b - t.__v.__b;
-}, N.__r = 0, f = Math.random().toString(8), p = "__d" + f, m = "__a" + f, h = /(PointerCapture)$|Capture$/i, g = 0, _ = B(!1), v = B(!0);
+}, M.__r = 0, p = Math.random().toString(8), m = "__d" + p, h = "__a" + p, g = /(PointerCapture)$|Capture$/i, _ = 0, v = ce(!1), y = ce(!0);
//#endregion
//#region src/api.ts
-var ee = class extends Error {
+var ve = class extends Error {
status;
constructor(e, t) {
super(e), this.name = "ApiError", this.status = t;
}
-}, te = (e) => {
+}, ye = (e) => {
if (!e || typeof e != "object") return "";
let t = e;
for (let e of [
@@ -268,8 +270,8 @@ var ee = class extends Error {
if (typeof n == "string" && n) return n;
}
return "";
-};
-async function ne(e, t) {
+}, be = (e) => e instanceof Error ? e.message : String(e);
+async function xe(e, t) {
let n = await fetch(e, {
headers: { Accept: "application/json" },
credentials: "same-origin",
@@ -278,14 +280,547 @@ async function ne(e, t) {
try {
r = await n.json();
} catch {}
- if (!n.ok) throw new ee(te(r) || `请求失败(${n.status})`, n.status);
+ if (!n.ok) throw new ve(ye(r) || `请求失败(${n.status})`, n.status);
return r;
}
//#endregion
+//#region node_modules/preact/hooks/dist/hooks.module.js
+var Se, N, Ce, we, Te = 0, Ee = [], P = o, De = P.__b, Oe = P.__r, ke = P.diffed, Ae = P.__c, je = P.unmount, Me = P.__;
+function Ne(e, t) {
+ P.__h && P.__h(N, e, Te || t), Te = 0;
+ var n = N.__H || (N.__H = {
+ __: [],
+ __h: []
+ });
+ return e >= n.__.length && n.__.push({}), n.__[e];
+}
+function Pe(e, t) {
+ var n = Ne(Se++, 7);
+ return ze(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
+}
+function Fe() {
+ for (var e; e = Ee.shift();) {
+ var t = e.__H;
+ if (e.__P && t) try {
+ t.__h.some(F), t.__h.some(Re), t.__h = [];
+ } catch (n) {
+ t.__h = [], P.__e(n, e.__v);
+ }
+ }
+}
+P.__b = function(e) {
+ N = null, De && De(e);
+}, P.__ = function(e, t) {
+ e && t.__k && t.__k.__m && (e.__m = t.__k.__m), Me && Me(e, t);
+}, P.__r = function(e) {
+ Oe && Oe(e), Se = 0;
+ var t = (N = e.__c).__H;
+ t && (Ce === N ? (t.__h = [], N.__h = [], t.__.some(function(e) {
+ e.__N && (e.__ = e.__N), e.u = e.__N = void 0;
+ })) : (t.__h.some(F), t.__h.some(Re), t.__h = [], Se = 0)), Ce = N;
+}, P.diffed = function(e) {
+ ke && ke(e);
+ var t = e.__c;
+ t && t.__H && (t.__H.__h.length && (Ee.push(t) !== 1 && we === P.requestAnimationFrame || ((we = P.requestAnimationFrame) || Le)(Fe)), t.__H.__.some(function(e) {
+ e.u &&= (e.__H = e.u, void 0);
+ })), Ce = N = null;
+}, P.__c = function(e, t) {
+ t.some(function(e) {
+ try {
+ e.__h.some(F), e.__h = e.__h.filter(function(e) {
+ return !e.__ || Re(e);
+ });
+ } catch (n) {
+ t.some(function(e) {
+ e.__h &&= [];
+ }), t = [], P.__e(n, e.__v);
+ }
+ }), Ae && Ae(e, t);
+}, P.unmount = function(e) {
+ je && je(e);
+ var t, n = e.__c;
+ n && n.__H && (n.__H.__.some(function(e) {
+ try {
+ F(e);
+ } catch (e) {
+ t = e;
+ }
+ }), n.__H = void 0, t && P.__e(t, n.__v));
+};
+var Ie = typeof requestAnimationFrame == "function";
+function Le(e) {
+ var t, n = function() {
+ clearTimeout(r), Ie && cancelAnimationFrame(t), setTimeout(e);
+ }, r = setTimeout(n, 35);
+ Ie && (t = requestAnimationFrame(n));
+}
+function F(e) {
+ var t = N, n = e.__c;
+ typeof n == "function" && (e.__c = void 0, n()), N = t;
+}
+function Re(e) {
+ var t = N;
+ e.__c = e.__(), N = t;
+}
+function ze(e, t) {
+ return !e || e.length !== t.length || t.some(function(t, n) {
+ return t !== e[n];
+ });
+}
+//#endregion
+//#region node_modules/@preact/signals-core/dist/signals-core.module.js
+var Be = Symbol.for("preact-signals");
+function Ve() {
+ if (z > 1) z--;
+ else {
+ var e, t = !1;
+ for ((function() {
+ var e = V;
+ for (V = void 0; e !== void 0;) {
+ var t = e.S;
+ if (t.v === e.v) for (var n = t.t; n !== void 0; n = n.x) n.i === e.i && (n.i = t.i);
+ e = e.o;
+ }
+ })(); R !== void 0;) {
+ var n = R;
+ for (R = void 0, B++; n !== void 0;) {
+ var r = n.u;
+ if (n.u = void 0, n.f &= -3, !(8 & n.f) && Je(n)) try {
+ n.c();
+ } catch (n) {
+ t ||= (e = n, !0);
+ }
+ n = r;
+ }
+ }
+ if (B = 0, z--, t) throw e;
+ }
+}
+function He(e) {
+ if (z > 0) return e();
+ Ge = ++We, z++;
+ try {
+ return e();
+ } finally {
+ Ve();
+ }
+}
+var I, L = void 0;
+function Ue(e) {
+ var t = L, n = I;
+ L = void 0, I = void 0;
+ try {
+ return e();
+ } finally {
+ L = t, I = n;
+ }
+}
+var R = void 0, z = 0, B = 0, We = 0, Ge = 0, V = void 0, H = 0;
+function Ke(e) {
+ if (L !== void 0) {
+ var t = e.n;
+ if (t === void 0 || t.t !== L) return t = {
+ i: 0,
+ S: e,
+ p: L.s,
+ n: void 0,
+ t: L,
+ e: void 0,
+ x: void 0,
+ r: t
+ }, L.s !== void 0 && (L.s.n = t), L.s = t, e.n = t, 32 & L.f && e.S(t), t;
+ if (t.i === -1) return t.i = 0, t.n !== void 0 && (t.n.p = t.p, t.p !== void 0 && (t.p.n = t.n), t.p = L.s, t.n = void 0, L.s.n = t, L.s = t), t;
+ }
+}
+function U(e, t) {
+ this.v = e, this.i = 0, this.n = void 0, this.t = void 0, this.l = 0, this.W = t?.watched, this.Z = t?.unwatched, this.name = t?.name;
+}
+U.prototype.brand = Be, U.prototype.h = function() {
+ return !0;
+}, U.prototype.S = function(e) {
+ var t = this, n = this.t;
+ n !== e && e.e === void 0 && (e.x = n, this.t = e, n === void 0 ? Ue(function() {
+ var e;
+ (e = t.W) == null || e.call(t);
+ }) : n.e = e);
+}, U.prototype.U = function(e) {
+ var t = this;
+ if (this.t !== void 0) {
+ var n = e.e, r = e.x;
+ n !== void 0 && (n.x = r, e.e = void 0), r !== void 0 && (r.e = n, e.x = void 0), e === this.t && (this.t = r, r === void 0 && Ue(function() {
+ var e;
+ (e = t.Z) == null || e.call(t);
+ }));
+ }
+}, U.prototype.subscribe = function(e) {
+ var t = this;
+ return q(function() {
+ var n = t.value;
+ Ue(function() {
+ return e(n);
+ });
+ }, { name: "sub" });
+}, U.prototype.valueOf = function() {
+ return this.value;
+}, U.prototype.toString = function() {
+ return this.value + "";
+}, U.prototype.toJSON = function() {
+ return this.value;
+}, U.prototype.peek = function() {
+ var e = this;
+ return Ue(function() {
+ return e.value;
+ });
+}, Object.defineProperty(U.prototype, "value", {
+ get: function() {
+ var e = Ke(this);
+ return e !== void 0 && (e.i = this.i), this.v;
+ },
+ set: function(e) {
+ if (e !== this.v) {
+ if (B > 100) throw Error("Cycle detected");
+ (function(e) {
+ z !== 0 && B === 0 && e.l !== Ge && (e.l = Ge, V = {
+ S: e,
+ v: e.v,
+ i: e.i,
+ o: V
+ });
+ })(this), this.v = e, this.i++, H++, z++;
+ try {
+ for (var t = this.t; t !== void 0; t = t.x) t.t.N();
+ } finally {
+ Ve();
+ }
+ }
+ }
+});
+function qe(e, t) {
+ return new U(e, t);
+}
+function Je(e) {
+ for (var t = e.s; t !== void 0; t = t.n) if (t.S.i !== t.i || !t.S.h() || t.S.i !== t.i) return !0;
+ return !1;
+}
+function Ye(e) {
+ for (var t = e.s; t !== void 0; t = t.n) {
+ var n = t.S.n;
+ if (n !== void 0 && (t.r = n), t.S.n = t, t.i = -1, t.n === void 0) {
+ e.s = t;
+ break;
+ }
+ }
+}
+function Xe(e) {
+ for (var t = e.s, n = void 0; t !== void 0;) {
+ var r = t.p;
+ t.i === -1 ? (t.S.U(t), r !== void 0 && (r.n = t.n), t.n !== void 0 && (t.n.p = r)) : n = t, t.S.n = t.r, t.r !== void 0 && (t.r = void 0), t = r;
+ }
+ e.s = n;
+}
+function W(e, t) {
+ U.call(this, void 0, t), this.x = e, this.s = void 0, this.g = H - 1, this.f = 4;
+}
+W.prototype = new U(), W.prototype.h = function() {
+ if (this.f &= -3, 1 & this.f) return !1;
+ if ((36 & this.f) == 32 || (this.f &= -5, this.g === H)) return !0;
+ if (this.g = H, this.f |= 1, this.i > 0 && !Je(this)) return this.f &= -2, !0;
+ var e = L;
+ try {
+ Ye(this), L = this;
+ var t = this.x();
+ (16 & this.f || this.v !== t || this.i === 0) && (this.v = t, this.f &= -17, this.i++);
+ } catch (e) {
+ this.v = e, this.f |= 16, this.i++;
+ }
+ return L = e, Xe(this), this.f &= -2, !0;
+}, W.prototype.S = function(e) {
+ if (this.t === void 0) {
+ this.f |= 36;
+ for (var t = this.s; t !== void 0; t = t.n) t.S.S(t);
+ }
+ U.prototype.S.call(this, e);
+}, W.prototype.U = function(e) {
+ if (this.t !== void 0 && (U.prototype.U.call(this, e), this.t === void 0)) {
+ this.f &= -33;
+ for (var t = this.s; t !== void 0; t = t.n) t.S.U(t);
+ }
+}, W.prototype.N = function() {
+ if (!(2 & this.f)) {
+ this.f |= 6;
+ for (var e = this.t; e !== void 0; e = e.x) e.t.N();
+ }
+}, Object.defineProperty(W.prototype, "value", { get: function() {
+ if (1 & this.f) throw Error("Cycle detected");
+ var e = Ke(this);
+ if (this.h(), e !== void 0 && (e.i = this.i), 16 & this.f) throw this.v;
+ return this.v;
+} });
+function G(e, t) {
+ return new W(e, t);
+}
+function Ze(e) {
+ var t = e.m;
+ if (e.m = void 0, typeof t == "function") {
+ z++;
+ var n = L;
+ L = void 0;
+ try {
+ t();
+ } catch (t) {
+ throw e.f &= -2, e.f |= 8, Qe(e), t;
+ } finally {
+ L = n, Ve();
+ }
+ }
+}
+function Qe(e) {
+ for (var t = e.s; t !== void 0; t = t.n) t.S.U(t);
+ e.x = void 0, e.s = void 0, Ze(e);
+}
+function $e(e) {
+ if (L !== this) throw Error("Out-of-order effect");
+ Xe(this), L = e, this.f &= -2, 8 & this.f && Qe(this), Ve();
+}
+function K(e, t) {
+ this.x = e, this.m = void 0, this.s = void 0, this.u = void 0, this.f = 32, this.name = t?.name, I && I.push(this);
+}
+K.prototype.c = function() {
+ var e = this.S();
+ try {
+ if (8 & this.f || this.x === void 0) return;
+ var t = this.x();
+ typeof t == "function" && (this.m = t);
+ } finally {
+ e();
+ }
+}, K.prototype.S = function() {
+ if (1 & this.f) throw Error("Cycle detected");
+ this.f |= 1, this.f &= -9, Ze(this), Ye(this), z++;
+ var e = L;
+ return L = this, $e.bind(this, e);
+}, K.prototype.N = function() {
+ 2 & this.f || (this.f |= 2, this.u = R, R = this);
+}, K.prototype.d = function() {
+ this.f |= 8, 1 & this.f || Qe(this);
+}, K.prototype.dispose = function() {
+ this.d();
+};
+function q(e, t) {
+ var n = new K(e, t);
+ try {
+ n.c();
+ } catch (e) {
+ throw n.d(), e;
+ }
+ var r = n.d.bind(n);
+ return r[Symbol.dispose] = r, r;
+}
+//#endregion
+//#region node_modules/@preact/signals/dist/signals.module.js
+var et, J, tt = typeof window < "u" && !!window.__PREACT_SIGNALS_DEVTOOLS__, nt = [];
+q(function() {
+ et = this.N;
+})();
+function Y(e, t) {
+ o[e] = t.bind(null, o[e] || function() {});
+}
+function X(e) {
+ if (J) {
+ var t = J;
+ J = void 0, t();
+ }
+ J = e && e.S();
+}
+function rt(e) {
+ var t = this, n = e.data, r = at(n);
+ r.name = "ReactiveDom", r.value = n;
+ var i = Pe(function() {
+ for (var e = t, n = t.__v; n = n.__;) if (n.__c) {
+ n.__c.__$f |= 4;
+ break;
+ }
+ var i = G(function() {
+ var e = r.value.value;
+ return e === 0 ? 0 : !0 === e ? "" : e || "";
+ }), a = G(function() {
+ return !Array.isArray(i.value) && !c(i.value);
+ }), o = q(function() {
+ if (this.N = ct, a.value) {
+ var t = i.value;
+ e.__v && e.__v.__e && e.__v.__e.nodeType === 3 && (e.__v.__e.data = t);
+ }
+ }), s = t.__$u.d;
+ return t.__$u.d = function() {
+ o(), s.call(this);
+ }, [a, i];
+ }, []), a = i[0], o = i[1];
+ return a.value ? o.peek() : o.value;
+}
+rt.displayName = "ReactiveTextNode", Object.defineProperties(U.prototype, {
+ constructor: {
+ configurable: !0,
+ value: void 0
+ },
+ type: {
+ configurable: !0,
+ value: rt
+ },
+ props: {
+ configurable: !0,
+ get: function() {
+ var e = this;
+ return { data: { get value() {
+ return e.value;
+ } } };
+ }
+ },
+ __b: {
+ configurable: !0,
+ value: 1
+ }
+}), Y("__b", function(e, t) {
+ if (typeof t.type == "string") {
+ var n, r = t.props;
+ for (var i in r) if (i !== "children") {
+ var a = r[i];
+ a instanceof U && (n || (t.__np = n = {}), n[i] = a, r[i] = a.peek());
+ }
+ }
+ e(t);
+}), Y("__r", function(e, t) {
+ if (e(t), t.type !== D) {
+ X();
+ var n, r = t.__c;
+ r && (r.__$f &= -2, (n = r.__$u) === void 0 && (r.__$u = n = function(e, t) {
+ var n;
+ return q(function() {
+ n = this;
+ }, { name: t }), n.c = e, n;
+ }(function(e) {
+ return function() {
+ var t;
+ tt && ((t = this.y) == null || t.call(this)), e.__$f |= 1, e.setState({});
+ };
+ }(r), typeof t.type == "function" ? t.type.displayName || t.type.name : ""))), X(n);
+ }
+}), Y("__e", function(e, t, n, r) {
+ X(), e(t, n, r);
+}), Y("diffed", function(e, t) {
+ X();
+ var n;
+ if (typeof t.type == "string" && (n = t.__e)) {
+ var r = t.__np, i = t.props, a = n.U;
+ if (a) for (var o in a) {
+ var s = a[o];
+ s === void 0 || r && o in r || (s.d(), a[o] = void 0);
+ }
+ if (r) for (var c in a || (a = {}, n.U = a), r) {
+ var l = a[c], u = r[c];
+ l === void 0 ? (l = it(n, c, u, i), a[c] = l) : l.o(u, i);
+ }
+ }
+ e(t);
+});
+function it(e, t, n, r) {
+ var i = t in e && e.ownerSVGElement === void 0, a = qe(n);
+ return {
+ o: function(e, t) {
+ a.value = e, r = t;
+ },
+ d: q(function() {
+ this.N = ct;
+ var n = a.value.value;
+ r[t] !== n && (r[t] = n, i ? e[t] = n : n != null && (!1 !== n || t[4] === "-") ? e.setAttribute(t, n) : e.removeAttribute(t));
+ })
+ };
+}
+Y("unmount", function(e, t) {
+ if (typeof t.type == "string") {
+ var n = t.__e;
+ if (n) {
+ var r = n.U;
+ if (r) for (var i in n.U = void 0, r) {
+ var a = r[i];
+ a && a.d();
+ }
+ }
+ var o = t.__np;
+ if (o) {
+ var s = t.props;
+ for (var c in o) s[c] = o[c];
+ }
+ t.__np = void 0;
+ } else {
+ var l = t.__c;
+ if (l) {
+ var u = l.__$u;
+ u && (l.__$u = void 0, u.d());
+ }
+ }
+ e(t);
+}), Y("__h", function(e, t, n, r) {
+ r < 3 && (t.__$f |= 2), e(t, n, r);
+}), O.prototype.shouldComponentUpdate = function(e, t) {
+ if (this.__R) return !0;
+ var n = this.__$u, r = n && n.s !== void 0;
+ for (var i in t) return !0;
+ if (this.__f || typeof this.u == "boolean" && !0 === this.u) {
+ var a = 2 & this.__$f;
+ if (!(r || a || 4 & this.__$f) || 1 & this.__$f) return !0;
+ } else if (!(r || 4 & this.__$f) || 3 & this.__$f) return !0;
+ for (var o in e) if (o !== "__source" && e[o] !== this.props[o]) return !0;
+ for (var s in this.props) if (!(s in e)) return !0;
+ return !1;
+};
+function at(e, t) {
+ return Pe(function() {
+ return qe(e, t);
+ }, []);
+}
+var ot = function(e) {
+ queueMicrotask(function() {
+ queueMicrotask(e);
+ });
+};
+function st() {
+ He(function() {
+ for (var e; e = nt.shift();) et.call(e);
+ });
+}
+function ct() {
+ nt.push(this) === 1 && (o.requestAnimationFrame || ot)(st);
+}
+//#endregion
+//#region src/state/quality-goals.ts
+var lt = "/api/quality-goals?limit=200", ut = {
+ data: null,
+ error: ""
+}, Z = qe(ut), dt = 0, ft = G(() => Z.value);
+G(() => Z.value.data?.total ?? null);
+function pt() {
+ dt += 1, Z.value = ut;
+}
+async function mt(e) {
+ let t = dt += 1;
+ try {
+ let n = await xe(lt, e);
+ return t === dt && (Z.value = {
+ data: n,
+ error: ""
+ }), n;
+ } catch (n) {
+ throw !e?.aborted && t === dt && (Z.value = {
+ data: null,
+ error: be(n)
+ }), n;
+ }
+}
+//#endregion
//#region node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
-var re = 0;
+var ht = 0;
Array.isArray;
-function X(e, t, n, r, i, a) {
+function Q(e, t, n, r, i, a) {
t ||= {};
var s, c, l = t;
if ("ref" in l) for (c in l = {}, t) c == "ref" ? s = t[c] : l[c] = t[c];
@@ -300,7 +835,7 @@ function X(e, t, n, r, i, a) {
__e: null,
__c: null,
constructor: void 0,
- __v: --re,
+ __v: --ht,
__i: -1,
__u: 0,
__source: i,
@@ -311,73 +846,89 @@ function X(e, t, n, r, i, a) {
}
//#endregion
//#region src/islands/quality-goals.tsx
-var ie = "/api/quality-goals?limit=200", ae = (e, t) => ne(ie, t), oe = (e) => e.has_cover ? `/cover?code=${encodeURIComponent(e.code ?? "")}` : `/poster?id=${e.id}&c=4`;
-function se({ data: a, error: o, openItem: s, javTitleHtml: c, javDisplayName: l, srcBadge: u }) {
- if (o) return /* @__PURE__ */ X("div", {
+var gt = (e, t) => mt(t), _t = (e) => e.has_cover ? `/cover?code=${encodeURIComponent(e.code ?? "")}` : `/poster?id=${e.id}&c=4`;
+function vt({ openItem: a, javTitleHtml: o, javDisplayName: s, srcBadge: c }) {
+ let { data: l, error: u } = ft.value;
+ if (u) return /* @__PURE__ */ Q("div", {
class: "qualitylist",
- dangerouslySetInnerHTML: { __html: i(o, {
+ dangerouslySetInnerHTML: { __html: i(u, {
variant: "error",
label: "读取失败"
}) }
});
- let d = a?.items ?? [];
- return d.length ? /* @__PURE__ */ X("div", {
+ let d = l?.items ?? [];
+ return d.length ? /* @__PURE__ */ Q("div", {
class: "qualitylist",
- children: d.map((r) => /* @__PURE__ */ X("article", {
+ children: d.map((r) => /* @__PURE__ */ Q("article", {
class: "qualityitem",
- children: [/* @__PURE__ */ X("button", {
+ children: [/* @__PURE__ */ Q("button", {
class: "qualitycover",
type: "button",
- "aria-label": `打开 ${l(r)}`,
- onClick: () => s(r.id),
- children: /* @__PURE__ */ X("img", {
- src: oe(r),
+ "aria-label": `打开 ${s(r)}`,
+ onClick: () => a(r.id),
+ children: /* @__PURE__ */ Q("img", {
+ src: _t(r),
alt: "",
loading: "lazy",
onError: (e) => e.currentTarget.remove()
})
- }), /* @__PURE__ */ X("div", { children: [
- /* @__PURE__ */ X("h3", { children: /* @__PURE__ */ X("button", {
+ }), /* @__PURE__ */ Q("div", { children: [
+ /* @__PURE__ */ Q("h3", { children: /* @__PURE__ */ Q("button", {
type: "button",
"data-middle-truncate": !0,
- onClick: () => s(r.id),
- dangerouslySetInnerHTML: { __html: c(r) }
+ onClick: () => a(r.id),
+ dangerouslySetInnerHTML: { __html: o(r) }
}) }),
- /* @__PURE__ */ X("p", {
+ /* @__PURE__ */ Q("p", {
class: "mono",
children: [
- /* @__PURE__ */ X("span", {
+ /* @__PURE__ */ Q("span", {
style: "display:contents",
- dangerouslySetInnerHTML: { __html: u(r.location, r.cost) }
+ dangerouslySetInnerHTML: { __html: c(r.location, r.cost) }
}),
- /* @__PURE__ */ X("span", { children: e[r.location] ?? r.location }),
- /* @__PURE__ */ X("span", { children: t(r.duration) }),
- /* @__PURE__ */ X("span", { children: n(r.size ?? 0) })
+ /* @__PURE__ */ Q("span", { children: e[r.location] ?? r.location }),
+ /* @__PURE__ */ Q("span", { children: t(r.duration) }),
+ /* @__PURE__ */ Q("span", { children: n(r.size ?? 0) })
]
}),
- r.reason ? /* @__PURE__ */ X("p", { children: r.reason }) : null
+ r.reason ? /* @__PURE__ */ Q("p", { children: r.reason }) : null
] })]
}, r.id))
- }) : /* @__PURE__ */ X("div", {
+ }) : /* @__PURE__ */ Q("div", {
class: "qualitylist",
dangerouslySetInnerHTML: { __html: r("sparkles", "没有标记中的高清版目标", "现有版本都已满足条件,或还没有加入追踪。") }
});
}
//#endregion
+//#region src/state/index.ts
+var yt = { "quality-goals": {
+ refresh: mt,
+ reset: pt
+} }, bt = () => Object.keys(yt);
+async function xt(e) {
+ let t = yt[e];
+ if (!t) throw Error(`未登记的共享 store:${String(e)}`);
+ try {
+ return await t.refresh(), !0;
+ } catch {
+ return !1;
+ }
+}
+//#endregion
//#region src/islands.ts
-var Z = { "quality-goals": {
- load: ae,
- component: se
-} }, ce = () => Object.keys(Z), Q = /* @__PURE__ */ new Map();
-async function le(e, t, n, r = {}) {
- let i = Z[e];
+var St = { "quality-goals": {
+ load: gt,
+ component: vt
+} }, Ct = () => Object.keys(St), $ = /* @__PURE__ */ new Map();
+async function wt(e, t, n, r = {}) {
+ let i = St[e];
if (!i) throw Error(`未注册的 island:${String(e)}`);
- $(t);
+ Tt(t);
let a = {
controller: new AbortController(),
painted: !1
};
- Q.set(t, a);
+ $.set(t, a);
let o;
try {
o = {
@@ -388,23 +939,23 @@ async function le(e, t, n, r = {}) {
if (a.controller.signal.aborted) return;
o = {
data: null,
- error: e instanceof Error ? e.message : String(e)
+ error: be(e)
};
}
- if (Q.get(t) === a) {
+ if ($.get(t) === a) {
if (r.isCurrent && !r.isCurrent()) {
- Q.delete(t);
+ $.delete(t);
return;
}
- t.textContent = "", a.painted = !0, Y(T(i.component, {
+ t.textContent = "", a.painted = !0, _e(T(i.component, {
...n,
...o
}), t);
}
}
-function $(e) {
- let t = Q.get(e);
- t && (t.controller.abort(), Q.delete(e), t.painted && Y(null, e));
+function Tt(e) {
+ let t = $.get(e);
+ t && (t.controller.abort(), $.delete(e), t.painted && _e(null, e));
}
//#endregion
-export { ce as islandNames, le as mountIsland, $ as unmountIsland };
+export { Ct as islandNames, wt as mountIsland, xt as refreshStore, bt as storeNames, Tt as unmountIsland };