feat: pre-warn user of any enka error

This commit is contained in:
2026-04-10 12:37:08 +07:00 Unverified
parent 0e9da93667
commit a9410ba2e0
5 changed files with 291 additions and 153 deletions
+22
View File
@@ -1,5 +1,11 @@
"use client";
declare global {
interface Window {
icc: IccMutator;
}
}
import {
createContext,
use,
@@ -17,12 +23,17 @@ type SharedStates = Partial<{
"rubgram.services": string[];
"tl.deleteMode": boolean;
inspect: Record<string, string>;
// nf(Not Found) and showcase(Not In Showcase) is error dialog that opens guide
warning: "showcase" | "nf" | "guide" | "private";
"warning.uid": string;
"warning.src": "submit" | "input";
_raw: Record<string, unknown>;
}>;
type SharedSignals = {
beforeSubmit?: undefined;
sync?: undefined;
warningSolved?: undefined;
} & SharedStates;
type IccMutator = {
@@ -105,6 +116,9 @@ export default function IccProvider({
active: true,
});
if (typeof window !== "undefined" && location.hostname === "localhost")
window.icc = contextValue.current;
return <IccContext value={contextValue.current}>{children}</IccContext>;
}
@@ -185,4 +199,12 @@ export const shared = {
});
}, [v]);
},
emit<K extends keyof SharedSignals>(
key: K,
...data: SharedSignals[K] extends undefined ? [] : [SharedSignals[K]]
) {
const comms = use(IccContext);
comms.emit(key, ...data);
},
};