naystack 1.2.2 → 1.2.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.
@@ -30,10 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/auth/email/client.ts
31
31
  var client_exports = {};
32
32
  __export(client_exports, {
33
- getEmailAuthUtils: () => getEmailAuthUtils,
34
- useLoginWithEmail: () => useLoginWithEmail,
35
- useLogout: () => useLogout,
36
- useSignUpWithEmail: () => useSignUpWithEmail
33
+ getEmailAuthUtils: () => getEmailAuthUtils
37
34
  });
38
35
  module.exports = __toCommonJS(client_exports);
39
36
  var import_react2 = require("react");
@@ -48,7 +45,7 @@ var TokenContext = (0, import_react.createContext)({
48
45
  });
49
46
 
50
47
  // src/auth/email/client.ts
51
- function useSignUpWithEmail(endpoint) {
48
+ var useSignUpWithEmail = (endpoint) => () => {
52
49
  const { setToken } = (0, import_react2.useContext)(TokenContext);
53
50
  return (0, import_react2.useCallback)(
54
51
  async (data) => {
@@ -66,8 +63,8 @@ function useSignUpWithEmail(endpoint) {
66
63
  },
67
64
  [setToken]
68
65
  );
69
- }
70
- function useLoginWithEmail(endpoint) {
66
+ };
67
+ var useLoginWithEmail = (endpoint) => () => {
71
68
  const { setToken } = (0, import_react2.useContext)(TokenContext);
72
69
  return (0, import_react2.useCallback)(
73
70
  async (data) => {
@@ -85,8 +82,8 @@ function useLoginWithEmail(endpoint) {
85
82
  },
86
83
  [setToken]
87
84
  );
88
- }
89
- function useLogout(endpoint) {
85
+ };
86
+ var useLogout = (endpoint) => () => {
90
87
  const { setToken } = (0, import_react2.useContext)(TokenContext);
91
88
  return (0, import_react2.useCallback)(
92
89
  async (data) => {
@@ -99,18 +96,15 @@ function useLogout(endpoint) {
99
96
  },
100
97
  [setToken]
101
98
  );
102
- }
99
+ };
103
100
  function getEmailAuthUtils(endpoint) {
104
101
  return {
105
- useSignUp: () => useSignUpWithEmail(endpoint),
106
- useLogin: () => useLoginWithEmail(endpoint),
107
- useLogout: () => useLogout(endpoint)
102
+ useSignUp: useSignUpWithEmail(endpoint),
103
+ useLogin: useLoginWithEmail(endpoint),
104
+ useLogout: useLogout(endpoint)
108
105
  };
109
106
  }
110
107
  // Annotate the CommonJS export names for ESM import in node:
111
108
  0 && (module.exports = {
112
- getEmailAuthUtils,
113
- useLoginWithEmail,
114
- useLogout,
115
- useSignUpWithEmail
109
+ getEmailAuthUtils
116
110
  });
@@ -1,10 +1,7 @@
1
- declare function useSignUpWithEmail(endpoint: string): (data: object) => Promise<string | null>;
2
- declare function useLoginWithEmail(endpoint: string): (data: object) => Promise<string | null>;
3
- declare function useLogout(endpoint: string): (data?: object) => Promise<void>;
4
1
  declare function getEmailAuthUtils(endpoint: string): {
5
2
  useSignUp: () => (data: object) => Promise<string | null>;
6
3
  useLogin: () => (data: object) => Promise<string | null>;
7
4
  useLogout: () => (data?: object) => Promise<void>;
8
5
  };
9
6
 
10
- export { getEmailAuthUtils, useLoginWithEmail, useLogout, useSignUpWithEmail };
7
+ export { getEmailAuthUtils };
@@ -1,10 +1,7 @@
1
- declare function useSignUpWithEmail(endpoint: string): (data: object) => Promise<string | null>;
2
- declare function useLoginWithEmail(endpoint: string): (data: object) => Promise<string | null>;
3
- declare function useLogout(endpoint: string): (data?: object) => Promise<void>;
4
1
  declare function getEmailAuthUtils(endpoint: string): {
5
2
  useSignUp: () => (data: object) => Promise<string | null>;
6
3
  useLogin: () => (data: object) => Promise<string | null>;
7
4
  useLogout: () => (data?: object) => Promise<void>;
8
5
  };
9
6
 
10
- export { getEmailAuthUtils, useLoginWithEmail, useLogout, useSignUpWithEmail };
7
+ export { getEmailAuthUtils };
@@ -25,7 +25,7 @@ var TokenContext = createContext({
25
25
  });
26
26
 
27
27
  // src/auth/email/client.ts
28
- function useSignUpWithEmail(endpoint) {
28
+ var useSignUpWithEmail = (endpoint) => () => {
29
29
  const { setToken } = useContext2(TokenContext);
30
30
  return useCallback2(
31
31
  async (data) => {
@@ -43,8 +43,8 @@ function useSignUpWithEmail(endpoint) {
43
43
  },
44
44
  [setToken]
45
45
  );
46
- }
47
- function useLoginWithEmail(endpoint) {
46
+ };
47
+ var useLoginWithEmail = (endpoint) => () => {
48
48
  const { setToken } = useContext2(TokenContext);
49
49
  return useCallback2(
50
50
  async (data) => {
@@ -62,8 +62,8 @@ function useLoginWithEmail(endpoint) {
62
62
  },
63
63
  [setToken]
64
64
  );
65
- }
66
- function useLogout(endpoint) {
65
+ };
66
+ var useLogout = (endpoint) => () => {
67
67
  const { setToken } = useContext2(TokenContext);
68
68
  return useCallback2(
69
69
  async (data) => {
@@ -76,17 +76,14 @@ function useLogout(endpoint) {
76
76
  },
77
77
  [setToken]
78
78
  );
79
- }
79
+ };
80
80
  function getEmailAuthUtils(endpoint) {
81
81
  return {
82
- useSignUp: () => useSignUpWithEmail(endpoint),
83
- useLogin: () => useLoginWithEmail(endpoint),
84
- useLogout: () => useLogout(endpoint)
82
+ useSignUp: useSignUpWithEmail(endpoint),
83
+ useLogin: useLoginWithEmail(endpoint),
84
+ useLogout: useLogout(endpoint)
85
85
  };
86
86
  }
87
87
  export {
88
- getEmailAuthUtils,
89
- useLoginWithEmail,
90
- useLogout,
91
- useSignUpWithEmail
88
+ getEmailAuthUtils
92
89
  };
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,267 +15,22 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/client/index.ts
31
21
  var client_exports = {};
32
22
  __export(client_exports, {
33
- Injector: () => Injector,
34
- TokenContext: () => TokenContext,
35
- getApolloWrapper: () => getApolloWrapper,
36
- getEmailAuthUtils: () => getEmailAuthUtils,
37
- getGraphQLQuery: () => getGraphQLQuery,
38
- getHandleImageUpload: () => getHandleImageUpload,
39
- getInstagramAuthorizationURLSetup: () => getInstagramAuthorizationURLSetup,
40
23
  setupSEO: () => setupSEO,
41
- tokenContext: () => tokenContext,
42
- useAuthMutation: () => useAuthMutation,
43
- useAuthQuery: () => useAuthQuery,
44
24
  useBreakpoint: () => useBreakpoint,
45
- useLoginWithEmail: () => useLoginWithEmail,
46
- useLogout: () => useLogout,
47
- useSignUpWithEmail: () => useSignUpWithEmail,
48
- useToken: () => useToken,
49
25
  useVisibility: () => useVisibility
50
26
  });
51
27
  module.exports = __toCommonJS(client_exports);
52
28
 
53
- // src/auth/email/client.ts
54
- var import_react2 = require("react");
55
-
56
- // src/graphql/client.tsx
57
- var import_client = require("@apollo/client");
58
- var import_client_integration_nextjs = require("@apollo/client-integration-nextjs");
59
- var import_react = __toESM(require("react"));
60
- var TokenContext = (0, import_react.createContext)({
61
- token: null,
62
- setToken: () => null
63
- });
64
- var getApolloWrapper = ({
65
- graphqlUri,
66
- cacheConfig,
67
- authEndpoint
68
- }) => {
69
- function makeClient() {
70
- return new import_client_integration_nextjs.ApolloClient({
71
- cache: new import_client_integration_nextjs.InMemoryCache(cacheConfig),
72
- link: new import_client.HttpLink({
73
- uri: graphqlUri
74
- })
75
- });
76
- }
77
- return ({ children }) => {
78
- const [token, setToken] = (0, import_react.useState)(null);
79
- (0, import_react.useEffect)(() => {
80
- fetch(authEndpoint, {
81
- credentials: "include"
82
- }).then((res) => res.json()).then((data) => setToken(data.accessToken));
83
- }, []);
84
- return /* @__PURE__ */ import_react.default.createElement(import_client_integration_nextjs.ApolloNextAppProvider, { makeClient }, /* @__PURE__ */ import_react.default.createElement(TokenContext, { value: { token, setToken } }, children));
85
- };
86
- };
87
- function useToken() {
88
- const { token } = (0, import_react.useContext)(TokenContext);
89
- return token;
90
- }
91
- var tokenContext = (token) => {
92
- if (!token) return void 0;
93
- return {
94
- headers: {
95
- authorization: `Bearer ${token}`
96
- },
97
- credentials: `omit`
98
- };
99
- };
100
- function useAuthQuery(query, variables) {
101
- const token = useToken();
102
- const [fetch2, result] = (0, import_client.useLazyQuery)(query);
103
- const [calledVars, setCalledVars] = (0, import_react.useState)();
104
- (0, import_react.useEffect)(() => {
105
- if (token && variables && calledVars !== JSON.stringify(variables)) {
106
- setCalledVars(JSON.stringify(variables));
107
- void fetch2({
108
- variables,
109
- context: tokenContext(token),
110
- fetchPolicy: "no-cache"
111
- });
112
- }
113
- }, [fetch2, token, variables, calledVars]);
114
- const reFetch = (0, import_react.useCallback)(
115
- (v) => fetch2({
116
- variables: v,
117
- context: tokenContext(token),
118
- fetchPolicy: "no-cache"
119
- }),
120
- [fetch2, token]
121
- );
122
- return [reFetch, result];
123
- }
124
- function useAuthMutation(mutation, options) {
125
- const token = useToken();
126
- const [mutate, result] = (0, import_client.useMutation)(mutation, options);
127
- const method = (0, import_react.useCallback)(
128
- (variables) => mutate({
129
- variables,
130
- context: tokenContext(token)
131
- }),
132
- [token]
133
- );
134
- return [method, result];
135
- }
136
-
137
- // src/auth/email/client.ts
138
- function useSignUpWithEmail(endpoint) {
139
- const { setToken } = (0, import_react2.useContext)(TokenContext);
140
- return (0, import_react2.useCallback)(
141
- async (data) => {
142
- const res = await fetch(endpoint, {
143
- method: "POST",
144
- body: JSON.stringify(data),
145
- credentials: "include"
146
- });
147
- if (res.ok) {
148
- const data2 = await res.json();
149
- setToken(data2.accessToken);
150
- return null;
151
- }
152
- return res.text();
153
- },
154
- [setToken]
155
- );
156
- }
157
- function useLoginWithEmail(endpoint) {
158
- const { setToken } = (0, import_react2.useContext)(TokenContext);
159
- return (0, import_react2.useCallback)(
160
- async (data) => {
161
- const res = await fetch(endpoint, {
162
- method: "PUT",
163
- body: JSON.stringify(data),
164
- credentials: "include"
165
- });
166
- if (res.ok) {
167
- const data2 = await res.json();
168
- setToken(data2.accessToken);
169
- return null;
170
- }
171
- return res.text();
172
- },
173
- [setToken]
174
- );
175
- }
176
- function useLogout(endpoint) {
177
- const { setToken } = (0, import_react2.useContext)(TokenContext);
178
- return (0, import_react2.useCallback)(
179
- async (data) => {
180
- setToken(null);
181
- await fetch(endpoint, {
182
- method: "DELETE",
183
- credentials: "include",
184
- body: JSON.stringify(data)
185
- });
186
- },
187
- [setToken]
188
- );
189
- }
190
- function getEmailAuthUtils(endpoint) {
191
- return {
192
- useSignUp: () => useSignUpWithEmail(endpoint),
193
- useLogin: () => useLoginWithEmail(endpoint),
194
- useLogout: () => useLogout(endpoint)
195
- };
196
- }
197
-
198
- // src/auth/instagram/client.ts
199
- var getInstagramAuthorizationURLSetup = (clientId, redirectURL) => (token) => `https://www.instagram.com/oauth/authorize?client_id=${clientId}&response_type=code&enable_fb_login=0&force_authentication=1&scope=instagram_business_basic&state=${token}&redirect_uri=${redirectURL}`;
200
-
201
- // src/file/client.ts
202
- var getHandleImageUpload = (route) => ({
203
- file,
204
- type,
205
- token,
206
- data,
207
- sync
208
- }) => {
209
- const formData = new FormData();
210
- formData.append("type", type);
211
- if (file) formData.append("file", file);
212
- if (sync) formData.append("sync", sync.toString());
213
- if (data) formData.append("data", JSON.stringify(data));
214
- return fetch(route, {
215
- method: "PUT",
216
- body: formData,
217
- headers: {
218
- Authorization: `Bearer ${token}`
219
- }
220
- }).then(
221
- async (res) => await res.json() || null
222
- );
223
- };
224
-
225
- // src/graphql/server.tsx
226
- var import_client3 = require("@apollo/client");
227
- var import_client_integration_nextjs2 = require("@apollo/client-integration-nextjs");
228
- var import_headers = require("next/headers");
229
- var import_react3 = require("react");
230
- function Injector({
231
- fetch: fetch2,
232
- Component,
233
- props
234
- }) {
235
- return /* @__PURE__ */ React.createElement(import_react3.Suspense, { fallback: /* @__PURE__ */ React.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ React.createElement(InjectorSuspensed, { Component, fetch: fetch2, props }));
236
- }
237
- async function InjectorSuspensed({
238
- fetch: fetch2,
239
- Component,
240
- props
241
- }) {
242
- const data = await fetch2();
243
- return /* @__PURE__ */ React.createElement(Component, { loading: false, ...props || {}, data });
244
- }
245
- var getGraphQLQuery = ({ uri }) => {
246
- const getClient = () => {
247
- return new import_client3.ApolloClient({
248
- cache: new import_client3.InMemoryCache(),
249
- link: new import_client3.HttpLink({
250
- uri
251
- })
252
- });
253
- };
254
- const { query: queryApollo } = (0, import_client_integration_nextjs2.registerApolloClient)(getClient);
255
- return async (_query, options) => {
256
- const res = await queryApollo({
257
- query: _query,
258
- variables: options?.variables,
259
- context: {
260
- headers: {
261
- Cookie: options?.noCookie ? void 0 : await (0, import_headers.cookies)()
262
- },
263
- fetchOptions: {
264
- cache: options?.revalidate === void 0 ? "force-cache" : void 0,
265
- next: {
266
- revalidate: options?.revalidate,
267
- tags: options?.tags
268
- }
269
- }
270
- }
271
- });
272
- return res.data;
273
- };
274
- };
275
-
276
29
  // src/client/hooks.ts
277
- var import_react4 = require("react");
30
+ var import_react = require("react");
278
31
  function useVisibility(onVisible) {
279
- const visibilityRef = (0, import_react4.useRef)(null);
280
- (0, import_react4.useEffect)(() => {
32
+ const visibilityRef = (0, import_react.useRef)(null);
33
+ (0, import_react.useEffect)(() => {
281
34
  if (!onVisible) return;
282
35
  const observer = new IntersectionObserver(
283
36
  (entries) => {
@@ -306,8 +59,8 @@ function useVisibility(onVisible) {
306
59
  return visibilityRef;
307
60
  }
308
61
  function useBreakpoint(query) {
309
- const [matches, setMatches] = (0, import_react4.useState)(null);
310
- (0, import_react4.useEffect)(() => {
62
+ const [matches, setMatches] = (0, import_react.useState)(null);
63
+ (0, import_react.useEffect)(() => {
311
64
  if (typeof window === "undefined") return;
312
65
  const media = window.matchMedia(query);
313
66
  setMatches(media.matches);
@@ -343,21 +96,7 @@ var setupSEO = (SEO) => (title, description, image) => ({
343
96
  });
344
97
  // Annotate the CommonJS export names for ESM import in node:
345
98
  0 && (module.exports = {
346
- Injector,
347
- TokenContext,
348
- getApolloWrapper,
349
- getEmailAuthUtils,
350
- getGraphQLQuery,
351
- getHandleImageUpload,
352
- getInstagramAuthorizationURLSetup,
353
99
  setupSEO,
354
- tokenContext,
355
- useAuthMutation,
356
- useAuthQuery,
357
100
  useBreakpoint,
358
- useLoginWithEmail,
359
- useLogout,
360
- useSignUpWithEmail,
361
- useToken,
362
101
  useVisibility
363
102
  });
@@ -1,12 +1,4 @@
1
- export { getEmailAuthUtils, useLoginWithEmail, useLogout, useSignUpWithEmail } from '../auth/email/client.mjs';
2
- export { getInstagramAuthorizationURLSetup } from '../auth/instagram/client.mjs';
3
- export { ImageUploadResponseType, getHandleImageUpload } from '../file/client.mjs';
4
- export { TokenContext, getApolloWrapper, tokenContext, useAuthMutation, useAuthQuery, useToken } from '../graphql/client.mjs';
5
- export { Injector, getGraphQLQuery } from '../graphql/server.mjs';
6
1
  export { useBreakpoint, useVisibility } from './hooks.mjs';
7
2
  export { setupSEO } from './seo.mjs';
8
- import '@apollo/client';
9
- import '@apollo/client/cache';
10
- import '@graphql-typed-document-node/core';
11
3
  import 'react';
12
4
  import 'next';
@@ -1,12 +1,4 @@
1
- export { getEmailAuthUtils, useLoginWithEmail, useLogout, useSignUpWithEmail } from '../auth/email/client.js';
2
- export { getInstagramAuthorizationURLSetup } from '../auth/instagram/client.js';
3
- export { ImageUploadResponseType, getHandleImageUpload } from '../file/client.js';
4
- export { TokenContext, getApolloWrapper, tokenContext, useAuthMutation, useAuthQuery, useToken } from '../graphql/client.js';
5
- export { Injector, getGraphQLQuery } from '../graphql/server.js';
6
1
  export { useBreakpoint, useVisibility } from './hooks.js';
7
2
  export { setupSEO } from './seo.js';
8
- import '@apollo/client';
9
- import '@apollo/client/cache';
10
- import '@graphql-typed-document-node/core';
11
3
  import 'react';
12
4
  import 'next';
@@ -1,249 +1,8 @@
1
- // src/auth/email/client.ts
2
- import { useCallback as useCallback2, useContext as useContext2 } from "react";
3
-
4
- // src/graphql/client.tsx
5
- import {
6
- HttpLink,
7
- useLazyQuery,
8
- useMutation
9
- } from "@apollo/client";
10
- import {
11
- ApolloClient,
12
- ApolloNextAppProvider,
13
- InMemoryCache
14
- } from "@apollo/client-integration-nextjs";
15
- import React2, {
16
- createContext,
17
- useCallback,
18
- useContext,
19
- useEffect,
20
- useState
21
- } from "react";
22
- var TokenContext = createContext({
23
- token: null,
24
- setToken: () => null
25
- });
26
- var getApolloWrapper = ({
27
- graphqlUri,
28
- cacheConfig,
29
- authEndpoint
30
- }) => {
31
- function makeClient() {
32
- return new ApolloClient({
33
- cache: new InMemoryCache(cacheConfig),
34
- link: new HttpLink({
35
- uri: graphqlUri
36
- })
37
- });
38
- }
39
- return ({ children }) => {
40
- const [token, setToken] = useState(null);
41
- useEffect(() => {
42
- fetch(authEndpoint, {
43
- credentials: "include"
44
- }).then((res) => res.json()).then((data) => setToken(data.accessToken));
45
- }, []);
46
- return /* @__PURE__ */ React2.createElement(ApolloNextAppProvider, { makeClient }, /* @__PURE__ */ React2.createElement(TokenContext, { value: { token, setToken } }, children));
47
- };
48
- };
49
- function useToken() {
50
- const { token } = useContext(TokenContext);
51
- return token;
52
- }
53
- var tokenContext = (token) => {
54
- if (!token) return void 0;
55
- return {
56
- headers: {
57
- authorization: `Bearer ${token}`
58
- },
59
- credentials: `omit`
60
- };
61
- };
62
- function useAuthQuery(query, variables) {
63
- const token = useToken();
64
- const [fetch2, result] = useLazyQuery(query);
65
- const [calledVars, setCalledVars] = useState();
66
- useEffect(() => {
67
- if (token && variables && calledVars !== JSON.stringify(variables)) {
68
- setCalledVars(JSON.stringify(variables));
69
- void fetch2({
70
- variables,
71
- context: tokenContext(token),
72
- fetchPolicy: "no-cache"
73
- });
74
- }
75
- }, [fetch2, token, variables, calledVars]);
76
- const reFetch = useCallback(
77
- (v) => fetch2({
78
- variables: v,
79
- context: tokenContext(token),
80
- fetchPolicy: "no-cache"
81
- }),
82
- [fetch2, token]
83
- );
84
- return [reFetch, result];
85
- }
86
- function useAuthMutation(mutation, options) {
87
- const token = useToken();
88
- const [mutate, result] = useMutation(mutation, options);
89
- const method = useCallback(
90
- (variables) => mutate({
91
- variables,
92
- context: tokenContext(token)
93
- }),
94
- [token]
95
- );
96
- return [method, result];
97
- }
98
-
99
- // src/auth/email/client.ts
100
- function useSignUpWithEmail(endpoint) {
101
- const { setToken } = useContext2(TokenContext);
102
- return useCallback2(
103
- async (data) => {
104
- const res = await fetch(endpoint, {
105
- method: "POST",
106
- body: JSON.stringify(data),
107
- credentials: "include"
108
- });
109
- if (res.ok) {
110
- const data2 = await res.json();
111
- setToken(data2.accessToken);
112
- return null;
113
- }
114
- return res.text();
115
- },
116
- [setToken]
117
- );
118
- }
119
- function useLoginWithEmail(endpoint) {
120
- const { setToken } = useContext2(TokenContext);
121
- return useCallback2(
122
- async (data) => {
123
- const res = await fetch(endpoint, {
124
- method: "PUT",
125
- body: JSON.stringify(data),
126
- credentials: "include"
127
- });
128
- if (res.ok) {
129
- const data2 = await res.json();
130
- setToken(data2.accessToken);
131
- return null;
132
- }
133
- return res.text();
134
- },
135
- [setToken]
136
- );
137
- }
138
- function useLogout(endpoint) {
139
- const { setToken } = useContext2(TokenContext);
140
- return useCallback2(
141
- async (data) => {
142
- setToken(null);
143
- await fetch(endpoint, {
144
- method: "DELETE",
145
- credentials: "include",
146
- body: JSON.stringify(data)
147
- });
148
- },
149
- [setToken]
150
- );
151
- }
152
- function getEmailAuthUtils(endpoint) {
153
- return {
154
- useSignUp: () => useSignUpWithEmail(endpoint),
155
- useLogin: () => useLoginWithEmail(endpoint),
156
- useLogout: () => useLogout(endpoint)
157
- };
158
- }
159
-
160
- // src/auth/instagram/client.ts
161
- var getInstagramAuthorizationURLSetup = (clientId, redirectURL) => (token) => `https://www.instagram.com/oauth/authorize?client_id=${clientId}&response_type=code&enable_fb_login=0&force_authentication=1&scope=instagram_business_basic&state=${token}&redirect_uri=${redirectURL}`;
162
-
163
- // src/file/client.ts
164
- var getHandleImageUpload = (route) => ({
165
- file,
166
- type,
167
- token,
168
- data,
169
- sync
170
- }) => {
171
- const formData = new FormData();
172
- formData.append("type", type);
173
- if (file) formData.append("file", file);
174
- if (sync) formData.append("sync", sync.toString());
175
- if (data) formData.append("data", JSON.stringify(data));
176
- return fetch(route, {
177
- method: "PUT",
178
- body: formData,
179
- headers: {
180
- Authorization: `Bearer ${token}`
181
- }
182
- }).then(
183
- async (res) => await res.json() || null
184
- );
185
- };
186
-
187
- // src/graphql/server.tsx
188
- import {
189
- ApolloClient as ApolloClient2,
190
- HttpLink as HttpLink2,
191
- InMemoryCache as InMemoryCache2
192
- } from "@apollo/client";
193
- import { registerApolloClient } from "@apollo/client-integration-nextjs";
194
- import { cookies } from "next/headers";
195
- import { Suspense } from "react";
196
- function Injector({
197
- fetch: fetch2,
198
- Component,
199
- props
200
- }) {
201
- return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ React.createElement(InjectorSuspensed, { Component, fetch: fetch2, props }));
202
- }
203
- async function InjectorSuspensed({
204
- fetch: fetch2,
205
- Component,
206
- props
207
- }) {
208
- const data = await fetch2();
209
- return /* @__PURE__ */ React.createElement(Component, { loading: false, ...props || {}, data });
210
- }
211
- var getGraphQLQuery = ({ uri }) => {
212
- const getClient = () => {
213
- return new ApolloClient2({
214
- cache: new InMemoryCache2(),
215
- link: new HttpLink2({
216
- uri
217
- })
218
- });
219
- };
220
- const { query: queryApollo } = registerApolloClient(getClient);
221
- return async (_query, options) => {
222
- const res = await queryApollo({
223
- query: _query,
224
- variables: options?.variables,
225
- context: {
226
- headers: {
227
- Cookie: options?.noCookie ? void 0 : await cookies()
228
- },
229
- fetchOptions: {
230
- cache: options?.revalidate === void 0 ? "force-cache" : void 0,
231
- next: {
232
- revalidate: options?.revalidate,
233
- tags: options?.tags
234
- }
235
- }
236
- }
237
- });
238
- return res.data;
239
- };
240
- };
241
-
242
1
  // src/client/hooks.ts
243
- import { useEffect as useEffect2, useRef, useState as useState2 } from "react";
2
+ import { useEffect, useRef, useState } from "react";
244
3
  function useVisibility(onVisible) {
245
4
  const visibilityRef = useRef(null);
246
- useEffect2(() => {
5
+ useEffect(() => {
247
6
  if (!onVisible) return;
248
7
  const observer = new IntersectionObserver(
249
8
  (entries) => {
@@ -272,8 +31,8 @@ function useVisibility(onVisible) {
272
31
  return visibilityRef;
273
32
  }
274
33
  function useBreakpoint(query) {
275
- const [matches, setMatches] = useState2(null);
276
- useEffect2(() => {
34
+ const [matches, setMatches] = useState(null);
35
+ useEffect(() => {
277
36
  if (typeof window === "undefined") return;
278
37
  const media = window.matchMedia(query);
279
38
  setMatches(media.matches);
@@ -308,21 +67,7 @@ var setupSEO = (SEO) => (title, description, image) => ({
308
67
  publisher: SEO.siteName
309
68
  });
310
69
  export {
311
- Injector,
312
- TokenContext,
313
- getApolloWrapper,
314
- getEmailAuthUtils,
315
- getGraphQLQuery,
316
- getHandleImageUpload,
317
- getInstagramAuthorizationURLSetup,
318
70
  setupSEO,
319
- tokenContext,
320
- useAuthMutation,
321
- useAuthQuery,
322
71
  useBreakpoint,
323
- useLoginWithEmail,
324
- useLogout,
325
- useSignUpWithEmail,
326
- useToken,
327
72
  useVisibility
328
73
  };
@@ -25,7 +25,6 @@ __export(server_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(server_exports);
27
27
  var import_client = require("@apollo/client");
28
- var import_client_integration_nextjs = require("@apollo/client-integration-nextjs");
29
28
  var import_headers = require("next/headers");
30
29
  var import_react = require("react");
31
30
  function Injector({
@@ -44,17 +43,14 @@ async function InjectorSuspensed({
44
43
  return /* @__PURE__ */ React.createElement(Component, { loading: false, ...props || {}, data });
45
44
  }
46
45
  var getGraphQLQuery = ({ uri }) => {
47
- const getClient = () => {
48
- return new import_client.ApolloClient({
49
- cache: new import_client.InMemoryCache(),
50
- link: new import_client.HttpLink({
51
- uri
52
- })
53
- });
54
- };
55
- const { query: queryApollo } = (0, import_client_integration_nextjs.registerApolloClient)(getClient);
46
+ const client = new import_client.ApolloClient({
47
+ cache: new import_client.InMemoryCache(),
48
+ link: new import_client.HttpLink({
49
+ uri
50
+ })
51
+ });
56
52
  return async (_query, options) => {
57
- const res = await queryApollo({
53
+ const res = await client.query({
58
54
  query: _query,
59
55
  variables: options?.variables,
60
56
  context: {
@@ -4,7 +4,6 @@ import {
4
4
  HttpLink,
5
5
  InMemoryCache
6
6
  } from "@apollo/client";
7
- import { registerApolloClient } from "@apollo/client-integration-nextjs";
8
7
  import { cookies } from "next/headers";
9
8
  import { Suspense } from "react";
10
9
  function Injector({
@@ -23,17 +22,14 @@ async function InjectorSuspensed({
23
22
  return /* @__PURE__ */ React.createElement(Component, { loading: false, ...props || {}, data });
24
23
  }
25
24
  var getGraphQLQuery = ({ uri }) => {
26
- const getClient = () => {
27
- return new ApolloClient({
28
- cache: new InMemoryCache(),
29
- link: new HttpLink({
30
- uri
31
- })
32
- });
33
- };
34
- const { query: queryApollo } = registerApolloClient(getClient);
25
+ const client = new ApolloClient({
26
+ cache: new InMemoryCache(),
27
+ link: new HttpLink({
28
+ uri
29
+ })
30
+ });
35
31
  return async (_query, options) => {
36
- const res = await queryApollo({
32
+ const res = await client.query({
37
33
  query: _query,
38
34
  variables: options?.variables,
39
35
  context: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "naystack",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "A stack built with Next + GraphQL + S3 + Auth",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -9,7 +9,7 @@
9
9
  "dist"
10
10
  ],
11
11
  "scripts": {
12
- "build": "tsup"
12
+ "build": "NODE_OPTIONS='--max-old-space-size=16384' tsup"
13
13
  },
14
14
  "exports": {
15
15
  "./auth": {
@@ -27,6 +27,31 @@
27
27
  "import": "./dist/graphql/index.esm.js",
28
28
  "require": "./dist/graphql/index.cjs.js"
29
29
  },
30
+ "./graphql/client": {
31
+ "types": "./dist/graphql/client.d.ts",
32
+ "import": "./dist/graphql/client.esm.js",
33
+ "require": "./dist/graphql/client.cjs.js"
34
+ },
35
+ "./auth/email/client": {
36
+ "types": "./dist/auth/email/client.d.ts",
37
+ "import": "./dist/auth/email/client.esm.js",
38
+ "require": "./dist/auth/email/client.cjs.js"
39
+ },
40
+ "./auth/instagram/client": {
41
+ "types": "./dist/auth/instagram/client.d.ts",
42
+ "import": "./dist/auth/instagram/client.esm.js",
43
+ "require": "./dist/auth/instagram/client.cjs.js"
44
+ },
45
+ "./file/client": {
46
+ "types": "./dist/file/client.d.ts",
47
+ "import": "./dist/file/client.esm.js",
48
+ "require": "./dist/file/client.cjs.js"
49
+ },
50
+ "./graphql/server": {
51
+ "types": "./dist/graphql/server.d.ts",
52
+ "import": "./dist/graphql/server.esm.js",
53
+ "require": "./dist/graphql/server.cjs.js"
54
+ },
30
55
  "./client": {
31
56
  "types": "./dist/client/index.d.ts",
32
57
  "import": "./dist/client/index.esm.js",