@burdenoff/fe-libs 2026.1028.5 → 2026.1028.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,18 @@
1
+ import { AiCreditStatus } from './productAiCredits';
2
+ export interface UseAiCreditStatusOptions {
3
+ /** Workspace to read. Defaults to the shell's active workspace. */
4
+ workspaceId?: string;
5
+ /** False skips the read entirely, for a product that does not meter AI. */
6
+ enabled?: boolean;
7
+ /** Injected reader, for tests. Defaults to `fetchAiCreditStatus`. */
8
+ read?: (productKey: string, workspaceId?: string) => Promise<AiCreditStatus | null>;
9
+ }
10
+ export interface AiCreditStatusState {
11
+ /** The last successful read, or null when unknown. */
12
+ status: AiCreditStatus | null;
13
+ /** True until the first read settles. */
14
+ loading: boolean;
15
+ /** Read the balance again now. */
16
+ refresh: () => Promise<void>;
17
+ }
18
+ export declare function useAiCreditStatus(productKey: string, options?: UseAiCreditStatusOptions): AiCreditStatusState;
@@ -0,0 +1,40 @@
1
+ import { quotaExhaustedEventName as e } from "./quota.js";
2
+ import { fetchAiCreditStatus as t } from "./productAiCredits.js";
3
+ import { aiCreditsUpdatedEventName as n } from "./aiCredits.js";
4
+ import { useCallback as r, useEffect as i, useRef as a, useState as o } from "react";
5
+ //#region src/shared/assistant/useAiCreditStatus.ts
6
+ function s(s, c = {}) {
7
+ let { workspaceId: l, enabled: u = !0, read: d = t } = c, [f, p] = o(null), [m, h] = o(u), g = a(0), _ = r(async () => {
8
+ if (!u || !s) return;
9
+ let e = ++g.current, t = await d(s, l);
10
+ e === g.current && (p(t), h(!1));
11
+ }, [
12
+ u,
13
+ s,
14
+ l,
15
+ d
16
+ ]);
17
+ return i(() => {
18
+ if (!u || !s) {
19
+ p(null), h(!1);
20
+ return;
21
+ }
22
+ if (h(!0), _(), typeof window > "u") return;
23
+ let t = () => {
24
+ _();
25
+ }, r = n(s), i = e(s);
26
+ return window.addEventListener(r, t), window.addEventListener(i, t), () => {
27
+ window.removeEventListener(r, t), window.removeEventListener(i, t), g.current += 1;
28
+ };
29
+ }, [
30
+ u,
31
+ s,
32
+ _
33
+ ]), {
34
+ status: f,
35
+ loading: m,
36
+ refresh: _
37
+ };
38
+ }
39
+ //#endregion
40
+ export { s as useAiCreditStatus };
@@ -50,3 +50,13 @@ export declare function useAssistantChromeLabels(): {
50
50
  * every product.
51
51
  */
52
52
  export declare function useAssistantDisclaimerLabel(): string;
53
+ /**
54
+ * The AI-credit balance line shown before an AI action (BOFF-3732). Platform
55
+ * shell labels, so one seed in the `workspaces` dictionary translates them for
56
+ * every product.
57
+ */
58
+ export declare function useAiCreditBalanceLabels(): {
59
+ remaining: (count: string) => string;
60
+ unlimited: string;
61
+ exhausted: string;
62
+ };
@@ -53,5 +53,13 @@ function n() {
53
53
  function r() {
54
54
  return e()("assistantChrome.aiDisclaimer", "AI can make mistakes. Check important details.");
55
55
  }
56
+ function i() {
57
+ let t = e();
58
+ return {
59
+ remaining: (e) => t("assistantChrome.aiCreditsRemaining", "{{count}} AI credits left", { count: e }),
60
+ unlimited: t("assistantChrome.aiCreditsUnlimited", "Unlimited AI credits on this plan"),
61
+ exhausted: t("assistantChrome.aiCreditsExhausted", "No AI credits left. AI actions resume next cycle or after an upgrade.")
62
+ };
63
+ }
56
64
  //#endregion
57
- export { n as useAssistantChromeLabels, r as useAssistantDisclaimerLabel, t as useWorkflowAssistantLabels };
65
+ export { i as useAiCreditBalanceLabels, n as useAssistantChromeLabels, r as useAssistantDisclaimerLabel, t as useWorkflowAssistantLabels };