@mohasinac/appkit 3.6.3 → 3.6.4
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.
- package/dist/react/hooks/realtime-event-constants.d.ts +50 -0
- package/dist/react/hooks/realtime-event-constants.js +36 -0
- package/dist/react/hooks/useRealtimeEvent.d.ts +2 -35
- package/dist/react/hooks/useRealtimeEvent.js +7 -21
- package/dist/react/index.d.ts +4 -2
- package/dist/react/index.js +8 -1
- package/package.json +1 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { JsonValue } from "../../schemas/types";
|
|
2
|
+
/**
|
|
3
|
+
* Plain constants + types shared between client hooks (useRealtimeEvent) and
|
|
4
|
+
* server-side RTDB writers (e.g. src/app/api/auth/event/init/route.ts).
|
|
5
|
+
*
|
|
6
|
+
* Deliberately NOT in a "use client" file. useRealtimeEvent.ts is "use
|
|
7
|
+
* client" (it uses React hooks), and Next.js's server bundler replaces every
|
|
8
|
+
* export of a "use client" module with an opaque client-reference when a
|
|
9
|
+
* server module imports it directly — including plain, non-React constants
|
|
10
|
+
* like RTDBPayloadStatus. A server route importing RTDBPayloadStatus.PENDING
|
|
11
|
+
* from the old location got `undefined` at runtime, which Firebase RTDB's
|
|
12
|
+
* `.set()` rejects outright ("value argument contains undefined in property
|
|
13
|
+
* ...status"), silently breaking every RTDB-backed realtime event (Google
|
|
14
|
+
* OAuth popup flow, payment event bridge, chat) in production. Confirmed via
|
|
15
|
+
* live Vercel logs 2026-08-17.
|
|
16
|
+
*/
|
|
17
|
+
export declare const RealtimeEventType: {
|
|
18
|
+
readonly AUTH: "auth";
|
|
19
|
+
readonly PAYMENT: "payment";
|
|
20
|
+
readonly CHAT: "chat";
|
|
21
|
+
readonly BID: "bid";
|
|
22
|
+
readonly BULK: "bulk";
|
|
23
|
+
};
|
|
24
|
+
export type RealtimeEventType = (typeof RealtimeEventType)[keyof typeof RealtimeEventType];
|
|
25
|
+
export declare const RealtimeEventStatus: {
|
|
26
|
+
readonly IDLE: "idle";
|
|
27
|
+
readonly SUBSCRIBING: "subscribing";
|
|
28
|
+
readonly PENDING: "pending";
|
|
29
|
+
readonly SUCCESS: "success";
|
|
30
|
+
readonly FAILED: "failed";
|
|
31
|
+
readonly TIMEOUT: "timeout";
|
|
32
|
+
};
|
|
33
|
+
export type RealtimeEventStatus = (typeof RealtimeEventStatus)[keyof typeof RealtimeEventStatus];
|
|
34
|
+
export declare const RTDBPayloadStatus: {
|
|
35
|
+
readonly PENDING: "pending";
|
|
36
|
+
readonly SUCCESS: "success";
|
|
37
|
+
readonly FAILED: "failed";
|
|
38
|
+
readonly ERROR: "error";
|
|
39
|
+
};
|
|
40
|
+
export interface RTDBEventPayload {
|
|
41
|
+
status: (typeof RTDBPayloadStatus)[keyof typeof RTDBPayloadStatus];
|
|
42
|
+
error?: string;
|
|
43
|
+
[key: string]: JsonValue | undefined;
|
|
44
|
+
}
|
|
45
|
+
export interface RealtimeEventMessages {
|
|
46
|
+
tokenFailure?: string;
|
|
47
|
+
connectionLost?: string;
|
|
48
|
+
timedOut?: string;
|
|
49
|
+
failure?: string;
|
|
50
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plain constants + types shared between client hooks (useRealtimeEvent) and
|
|
3
|
+
* server-side RTDB writers (e.g. src/app/api/auth/event/init/route.ts).
|
|
4
|
+
*
|
|
5
|
+
* Deliberately NOT in a "use client" file. useRealtimeEvent.ts is "use
|
|
6
|
+
* client" (it uses React hooks), and Next.js's server bundler replaces every
|
|
7
|
+
* export of a "use client" module with an opaque client-reference when a
|
|
8
|
+
* server module imports it directly — including plain, non-React constants
|
|
9
|
+
* like RTDBPayloadStatus. A server route importing RTDBPayloadStatus.PENDING
|
|
10
|
+
* from the old location got `undefined` at runtime, which Firebase RTDB's
|
|
11
|
+
* `.set()` rejects outright ("value argument contains undefined in property
|
|
12
|
+
* ...status"), silently breaking every RTDB-backed realtime event (Google
|
|
13
|
+
* OAuth popup flow, payment event bridge, chat) in production. Confirmed via
|
|
14
|
+
* live Vercel logs 2026-08-17.
|
|
15
|
+
*/
|
|
16
|
+
export const RealtimeEventType = {
|
|
17
|
+
AUTH: "auth",
|
|
18
|
+
PAYMENT: "payment",
|
|
19
|
+
CHAT: "chat",
|
|
20
|
+
BID: "bid",
|
|
21
|
+
BULK: "bulk",
|
|
22
|
+
};
|
|
23
|
+
export const RealtimeEventStatus = {
|
|
24
|
+
IDLE: "idle",
|
|
25
|
+
SUBSCRIBING: "subscribing",
|
|
26
|
+
PENDING: "pending",
|
|
27
|
+
SUCCESS: "success",
|
|
28
|
+
FAILED: "failed",
|
|
29
|
+
TIMEOUT: "timeout",
|
|
30
|
+
};
|
|
31
|
+
export const RTDBPayloadStatus = {
|
|
32
|
+
PENDING: "pending",
|
|
33
|
+
SUCCESS: "success",
|
|
34
|
+
FAILED: "failed",
|
|
35
|
+
ERROR: "error",
|
|
36
|
+
};
|
|
@@ -1,39 +1,6 @@
|
|
|
1
|
-
import type { JsonValue } from "../../schemas/types";
|
|
2
1
|
import { type IClientRealtimeProvider } from "../../contracts/client-realtime";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
readonly PAYMENT: "payment";
|
|
6
|
-
readonly CHAT: "chat";
|
|
7
|
-
readonly BID: "bid";
|
|
8
|
-
readonly BULK: "bulk";
|
|
9
|
-
};
|
|
10
|
-
export type RealtimeEventType = (typeof RealtimeEventType)[keyof typeof RealtimeEventType];
|
|
11
|
-
export declare const RealtimeEventStatus: {
|
|
12
|
-
readonly IDLE: "idle";
|
|
13
|
-
readonly SUBSCRIBING: "subscribing";
|
|
14
|
-
readonly PENDING: "pending";
|
|
15
|
-
readonly SUCCESS: "success";
|
|
16
|
-
readonly FAILED: "failed";
|
|
17
|
-
readonly TIMEOUT: "timeout";
|
|
18
|
-
};
|
|
19
|
-
export type RealtimeEventStatus = (typeof RealtimeEventStatus)[keyof typeof RealtimeEventStatus];
|
|
20
|
-
export declare const RTDBPayloadStatus: {
|
|
21
|
-
readonly PENDING: "pending";
|
|
22
|
-
readonly SUCCESS: "success";
|
|
23
|
-
readonly FAILED: "failed";
|
|
24
|
-
readonly ERROR: "error";
|
|
25
|
-
};
|
|
26
|
-
export interface RTDBEventPayload {
|
|
27
|
-
status: (typeof RTDBPayloadStatus)[keyof typeof RTDBPayloadStatus];
|
|
28
|
-
error?: string;
|
|
29
|
-
[key: string]: JsonValue | undefined;
|
|
30
|
-
}
|
|
31
|
-
export interface RealtimeEventMessages {
|
|
32
|
-
tokenFailure?: string;
|
|
33
|
-
connectionLost?: string;
|
|
34
|
-
timedOut?: string;
|
|
35
|
-
failure?: string;
|
|
36
|
-
}
|
|
2
|
+
import { RealtimeEventType, RealtimeEventStatus, RTDBPayloadStatus, type RTDBEventPayload, type RealtimeEventMessages } from "./realtime-event-constants";
|
|
3
|
+
export { RealtimeEventType, RealtimeEventStatus, RTDBPayloadStatus, type RTDBEventPayload, type RealtimeEventMessages, };
|
|
37
4
|
export interface UseRealtimeEventConfig<TData = undefined> {
|
|
38
5
|
type: RealtimeEventType;
|
|
39
6
|
rtdbPath: string;
|
|
@@ -2,27 +2,13 @@
|
|
|
2
2
|
import { normalizeError } from "../../errors/normalize";
|
|
3
3
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
4
|
import { getClientRealtimeProvider, } from "../../contracts/client-realtime";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
export const RealtimeEventStatus = {
|
|
13
|
-
IDLE: "idle",
|
|
14
|
-
SUBSCRIBING: "subscribing",
|
|
15
|
-
PENDING: "pending",
|
|
16
|
-
SUCCESS: "success",
|
|
17
|
-
FAILED: "failed",
|
|
18
|
-
TIMEOUT: "timeout",
|
|
19
|
-
};
|
|
20
|
-
export const RTDBPayloadStatus = {
|
|
21
|
-
PENDING: "pending",
|
|
22
|
-
SUCCESS: "success",
|
|
23
|
-
FAILED: "failed",
|
|
24
|
-
ERROR: "error",
|
|
25
|
-
};
|
|
5
|
+
import { RealtimeEventType, RealtimeEventStatus, RTDBPayloadStatus, } from "./realtime-event-constants";
|
|
6
|
+
// Re-exported for existing client import paths — the canonical definitions
|
|
7
|
+
// now live in realtime-event-constants.ts (a plain, non-"use client" module)
|
|
8
|
+
// so server code can import them without hitting the client-reference
|
|
9
|
+
// substitution Next.js applies to "use client" module exports. See that
|
|
10
|
+
// file's comment for the full story.
|
|
11
|
+
export { RealtimeEventType, RealtimeEventStatus, RTDBPayloadStatus, };
|
|
26
12
|
const DEFAULT_TIMEOUT_MS = 3 * 60 * 1000;
|
|
27
13
|
const DEFAULT_MESSAGES = {
|
|
28
14
|
tokenFailure: "Failed to initialize realtime tracking.",
|
package/dist/react/index.d.ts
CHANGED
|
@@ -52,5 +52,7 @@ export { useModalStack } from "./useModalStack";
|
|
|
52
52
|
export type { ModalEntry } from "./useModalStack";
|
|
53
53
|
export { ErrorBoundary } from "./ErrorBoundary";
|
|
54
54
|
export type { ErrorBoundaryProps } from "./ErrorBoundary";
|
|
55
|
-
export { useRealtimeEvent
|
|
56
|
-
export type {
|
|
55
|
+
export { useRealtimeEvent } from "./hooks/useRealtimeEvent";
|
|
56
|
+
export type { UseRealtimeEventConfig, UseRealtimeEventReturn, } from "./hooks/useRealtimeEvent";
|
|
57
|
+
export { RealtimeEventType, RealtimeEventStatus, RTDBPayloadStatus, } from "./hooks/realtime-event-constants";
|
|
58
|
+
export type { RTDBEventPayload, RealtimeEventMessages, RealtimeEventType as RealtimeEventTypeValue, RealtimeEventStatus as RealtimeEventStatusValue, } from "./hooks/realtime-event-constants";
|
package/dist/react/index.js
CHANGED
|
@@ -53,4 +53,11 @@ export { useModalStack } from "./useModalStack";
|
|
|
53
53
|
// Error boundary
|
|
54
54
|
export { ErrorBoundary } from "./ErrorBoundary";
|
|
55
55
|
// Realtime event bridge
|
|
56
|
-
|
|
56
|
+
// RealtimeEventType/RealtimeEventStatus/RTDBPayloadStatus/RTDBEventPayload/
|
|
57
|
+
// RealtimeEventMessages come from realtime-event-constants.ts (plain module,
|
|
58
|
+
// no "use client") rather than useRealtimeEvent.ts directly — server code
|
|
59
|
+
// importing these via the main @mohasinac/appkit barrel needs the real
|
|
60
|
+
// values, not the client-reference placeholder Next.js substitutes for
|
|
61
|
+
// "use client" module exports.
|
|
62
|
+
export { useRealtimeEvent } from "./hooks/useRealtimeEvent";
|
|
63
|
+
export { RealtimeEventType, RealtimeEventStatus, RTDBPayloadStatus, } from "./hooks/realtime-event-constants";
|