@devfellowship/components 0.1.0 → 1.1.0

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/hooks.cjs CHANGED
@@ -33,6 +33,8 @@ __export(hooks_exports, {
33
33
  AuthContext: () => AuthContext,
34
34
  toast: () => toast,
35
35
  useAuth: () => useAuth,
36
+ useIframeAuth: () => useIframeAuth,
37
+ useIframeNavigate: () => useIframeNavigate,
36
38
  useIsMobile: () => useIsMobile,
37
39
  useSession: () => useSession,
38
40
  useToast: () => useToast
@@ -163,11 +165,42 @@ var useSession = () => {
163
165
  const { session } = useAuth();
164
166
  return session;
165
167
  };
168
+
169
+ // src/hooks/use-iframe-auth.ts
170
+ var import_react3 = require("react");
171
+
172
+ // src/components/iframe/iframe-context.tsx
173
+ var import_react2 = require("react");
174
+ var IframeContext = (0, import_react2.createContext)({
175
+ token: null,
176
+ userId: null,
177
+ ready: false
178
+ });
179
+
180
+ // src/hooks/use-iframe-auth.ts
181
+ function useIframeAuth() {
182
+ const ctx = (0, import_react3.useContext)(IframeContext);
183
+ return { token: ctx.token, userId: ctx.userId, ready: ctx.ready };
184
+ }
185
+
186
+ // src/hooks/use-iframe-navigate.ts
187
+ var import_react4 = require("react");
188
+ function useIframeNavigate() {
189
+ return (0, import_react4.useCallback)((path) => {
190
+ if (!window.parent || window.parent === window) return;
191
+ window.parent.postMessage(
192
+ { type: "DFL_NAVIGATE", path },
193
+ "*"
194
+ );
195
+ }, []);
196
+ }
166
197
  // Annotate the CommonJS export names for ESM import in node:
167
198
  0 && (module.exports = {
168
199
  AuthContext,
169
200
  toast,
170
201
  useAuth,
202
+ useIframeAuth,
203
+ useIframeNavigate,
171
204
  useIsMobile,
172
205
  useSession,
173
206
  useToast
package/dist/hooks.d.cts CHANGED
@@ -32,4 +32,12 @@ declare function useToast(): {
32
32
  toasts: ToastProps[];
33
33
  };
34
34
 
35
- export { type ToastProps, type ToastVariant, toast, useIsMobile, useToast };
35
+ declare function useIframeAuth(): {
36
+ token: string | null;
37
+ userId: string | null;
38
+ ready: boolean;
39
+ };
40
+
41
+ declare function useIframeNavigate(): (path: string) => void;
42
+
43
+ export { type ToastProps, type ToastVariant, toast, useIframeAuth, useIframeNavigate, useIsMobile, useToast };
package/dist/hooks.d.ts CHANGED
@@ -32,4 +32,12 @@ declare function useToast(): {
32
32
  toasts: ToastProps[];
33
33
  };
34
34
 
35
- export { type ToastProps, type ToastVariant, toast, useIsMobile, useToast };
35
+ declare function useIframeAuth(): {
36
+ token: string | null;
37
+ userId: string | null;
38
+ ready: boolean;
39
+ };
40
+
41
+ declare function useIframeNavigate(): (path: string) => void;
42
+
43
+ export { type ToastProps, type ToastVariant, toast, useIframeAuth, useIframeNavigate, useIsMobile, useToast };
package/dist/hooks.js CHANGED
@@ -130,10 +130,41 @@ var useSession = () => {
130
130
  const { session } = useAuth();
131
131
  return session;
132
132
  };
133
+
134
+ // src/hooks/use-iframe-auth.ts
135
+ import { useContext as useContext2 } from "react";
136
+
137
+ // src/components/iframe/iframe-context.tsx
138
+ import { createContext as createContext2 } from "react";
139
+ var IframeContext = createContext2({
140
+ token: null,
141
+ userId: null,
142
+ ready: false
143
+ });
144
+
145
+ // src/hooks/use-iframe-auth.ts
146
+ function useIframeAuth() {
147
+ const ctx = useContext2(IframeContext);
148
+ return { token: ctx.token, userId: ctx.userId, ready: ctx.ready };
149
+ }
150
+
151
+ // src/hooks/use-iframe-navigate.ts
152
+ import { useCallback as useCallback2 } from "react";
153
+ function useIframeNavigate() {
154
+ return useCallback2((path) => {
155
+ if (!window.parent || window.parent === window) return;
156
+ window.parent.postMessage(
157
+ { type: "DFL_NAVIGATE", path },
158
+ "*"
159
+ );
160
+ }, []);
161
+ }
133
162
  export {
134
163
  AuthContext,
135
164
  toast,
136
165
  useAuth,
166
+ useIframeAuth,
167
+ useIframeNavigate,
137
168
  useIsMobile,
138
169
  useSession,
139
170
  useToast