naystack 1.2.0 → 1.2.1
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/client/index.cjs.js +60 -5
- package/dist/client/index.d.mts +1 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.esm.js +59 -2
- package/dist/graphql/index.cjs.js +0 -55
- package/dist/graphql/index.d.mts +0 -4
- package/dist/graphql/index.d.ts +0 -4
- package/dist/graphql/index.esm.js +0 -57
- package/package.json +2 -2
package/dist/client/index.cjs.js
CHANGED
|
@@ -30,9 +30,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/client/index.ts
|
|
31
31
|
var client_exports = {};
|
|
32
32
|
__export(client_exports, {
|
|
33
|
+
Injector: () => Injector,
|
|
33
34
|
TokenContext: () => TokenContext,
|
|
34
35
|
getApolloWrapper: () => getApolloWrapper,
|
|
35
36
|
getEmailAuthUtils: () => getEmailAuthUtils,
|
|
37
|
+
getGraphQLQuery: () => getGraphQLQuery,
|
|
36
38
|
getHandleImageUpload: () => getHandleImageUpload,
|
|
37
39
|
getInstagramAuthorizationURLSetup: () => getInstagramAuthorizationURLSetup,
|
|
38
40
|
setupSEO: () => setupSEO,
|
|
@@ -220,11 +222,62 @@ var getHandleImageUpload = (route) => ({
|
|
|
220
222
|
);
|
|
221
223
|
};
|
|
222
224
|
|
|
223
|
-
// src/
|
|
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");
|
|
224
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
|
+
// src/client/hooks.ts
|
|
277
|
+
var import_react4 = require("react");
|
|
225
278
|
function useVisibility(onVisible) {
|
|
226
|
-
const visibilityRef = (0,
|
|
227
|
-
(0,
|
|
279
|
+
const visibilityRef = (0, import_react4.useRef)(null);
|
|
280
|
+
(0, import_react4.useEffect)(() => {
|
|
228
281
|
if (!onVisible) return;
|
|
229
282
|
const observer = new IntersectionObserver(
|
|
230
283
|
(entries) => {
|
|
@@ -253,8 +306,8 @@ function useVisibility(onVisible) {
|
|
|
253
306
|
return visibilityRef;
|
|
254
307
|
}
|
|
255
308
|
function useBreakpoint(query) {
|
|
256
|
-
const [matches, setMatches] = (0,
|
|
257
|
-
(0,
|
|
309
|
+
const [matches, setMatches] = (0, import_react4.useState)(null);
|
|
310
|
+
(0, import_react4.useEffect)(() => {
|
|
258
311
|
if (typeof window === "undefined") return;
|
|
259
312
|
const media = window.matchMedia(query);
|
|
260
313
|
setMatches(media.matches);
|
|
@@ -290,9 +343,11 @@ var setupSEO = (SEO) => (title, description, image) => ({
|
|
|
290
343
|
});
|
|
291
344
|
// Annotate the CommonJS export names for ESM import in node:
|
|
292
345
|
0 && (module.exports = {
|
|
346
|
+
Injector,
|
|
293
347
|
TokenContext,
|
|
294
348
|
getApolloWrapper,
|
|
295
349
|
getEmailAuthUtils,
|
|
350
|
+
getGraphQLQuery,
|
|
296
351
|
getHandleImageUpload,
|
|
297
352
|
getInstagramAuthorizationURLSetup,
|
|
298
353
|
setupSEO,
|
package/dist/client/index.d.mts
CHANGED
|
@@ -2,6 +2,7 @@ export { getEmailAuthUtils, useLoginWithEmail, useLogout, useSignUpWithEmail } f
|
|
|
2
2
|
export { getInstagramAuthorizationURLSetup } from '../auth/instagram/client.mjs';
|
|
3
3
|
export { ImageUploadResponseType, getHandleImageUpload } from '../file/client.mjs';
|
|
4
4
|
export { TokenContext, getApolloWrapper, tokenContext, useAuthMutation, useAuthQuery, useToken } from '../graphql/client.mjs';
|
|
5
|
+
export { Injector, getGraphQLQuery } from '../graphql/server.mjs';
|
|
5
6
|
export { useBreakpoint, useVisibility } from './hooks.mjs';
|
|
6
7
|
export { setupSEO } from './seo.mjs';
|
|
7
8
|
import '@apollo/client';
|
package/dist/client/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { getEmailAuthUtils, useLoginWithEmail, useLogout, useSignUpWithEmail } f
|
|
|
2
2
|
export { getInstagramAuthorizationURLSetup } from '../auth/instagram/client.js';
|
|
3
3
|
export { ImageUploadResponseType, getHandleImageUpload } from '../file/client.js';
|
|
4
4
|
export { TokenContext, getApolloWrapper, tokenContext, useAuthMutation, useAuthQuery, useToken } from '../graphql/client.js';
|
|
5
|
+
export { Injector, getGraphQLQuery } from '../graphql/server.js';
|
|
5
6
|
export { useBreakpoint, useVisibility } from './hooks.js';
|
|
6
7
|
export { setupSEO } from './seo.js';
|
|
7
8
|
import '@apollo/client';
|
package/dist/client/index.esm.js
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
ApolloNextAppProvider,
|
|
13
13
|
InMemoryCache
|
|
14
14
|
} from "@apollo/client-integration-nextjs";
|
|
15
|
-
import
|
|
15
|
+
import React2, {
|
|
16
16
|
createContext,
|
|
17
17
|
useCallback,
|
|
18
18
|
useContext,
|
|
@@ -43,7 +43,7 @@ var getApolloWrapper = ({
|
|
|
43
43
|
credentials: "include"
|
|
44
44
|
}).then((res) => res.json()).then((data) => setToken(data.accessToken));
|
|
45
45
|
}, []);
|
|
46
|
-
return /* @__PURE__ */
|
|
46
|
+
return /* @__PURE__ */ React2.createElement(ApolloNextAppProvider, { makeClient }, /* @__PURE__ */ React2.createElement(TokenContext, { value: { token, setToken } }, children));
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
49
|
function useToken() {
|
|
@@ -184,6 +184,61 @@ var getHandleImageUpload = (route) => ({
|
|
|
184
184
|
);
|
|
185
185
|
};
|
|
186
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
|
+
|
|
187
242
|
// src/client/hooks.ts
|
|
188
243
|
import { useEffect as useEffect2, useRef, useState as useState2 } from "react";
|
|
189
244
|
function useVisibility(onVisible) {
|
|
@@ -253,9 +308,11 @@ var setupSEO = (SEO) => (title, description, image) => ({
|
|
|
253
308
|
publisher: SEO.siteName
|
|
254
309
|
});
|
|
255
310
|
export {
|
|
311
|
+
Injector,
|
|
256
312
|
TokenContext,
|
|
257
313
|
getApolloWrapper,
|
|
258
314
|
getEmailAuthUtils,
|
|
315
|
+
getGraphQLQuery,
|
|
259
316
|
getHandleImageUpload,
|
|
260
317
|
getInstagramAuthorizationURLSetup,
|
|
261
318
|
setupSEO,
|
|
@@ -540,10 +540,8 @@ var graphql_exports = {};
|
|
|
540
540
|
__export(graphql_exports, {
|
|
541
541
|
FieldLibrary: () => FieldLibrary,
|
|
542
542
|
GQLError: () => GQLError,
|
|
543
|
-
Injector: () => Injector,
|
|
544
543
|
QueryLibrary: () => QueryLibrary,
|
|
545
544
|
field: () => field,
|
|
546
|
-
getGraphQLQuery: () => getGraphQLQuery,
|
|
547
545
|
initGraphQLServer: () => initGraphQLServer,
|
|
548
546
|
query: () => query
|
|
549
547
|
});
|
|
@@ -617,57 +615,6 @@ async function initGraphQLServer({
|
|
|
617
615
|
};
|
|
618
616
|
}
|
|
619
617
|
|
|
620
|
-
// src/graphql/server.tsx
|
|
621
|
-
var import_client = require("@apollo/client");
|
|
622
|
-
var import_client_integration_nextjs = require("@apollo/client-integration-nextjs");
|
|
623
|
-
var import_headers = require("next/headers");
|
|
624
|
-
var import_react = require("react");
|
|
625
|
-
function Injector({
|
|
626
|
-
fetch,
|
|
627
|
-
Component,
|
|
628
|
-
props
|
|
629
|
-
}) {
|
|
630
|
-
return /* @__PURE__ */ React.createElement(import_react.Suspense, { fallback: /* @__PURE__ */ React.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ React.createElement(InjectorSuspensed, { Component, fetch, props }));
|
|
631
|
-
}
|
|
632
|
-
async function InjectorSuspensed({
|
|
633
|
-
fetch,
|
|
634
|
-
Component,
|
|
635
|
-
props
|
|
636
|
-
}) {
|
|
637
|
-
const data = await fetch();
|
|
638
|
-
return /* @__PURE__ */ React.createElement(Component, { loading: false, ...props || {}, data });
|
|
639
|
-
}
|
|
640
|
-
var getGraphQLQuery = ({ uri }) => {
|
|
641
|
-
const getClient = () => {
|
|
642
|
-
return new import_client.ApolloClient({
|
|
643
|
-
cache: new import_client.InMemoryCache(),
|
|
644
|
-
link: new import_client.HttpLink({
|
|
645
|
-
uri
|
|
646
|
-
})
|
|
647
|
-
});
|
|
648
|
-
};
|
|
649
|
-
const { query: queryApollo } = (0, import_client_integration_nextjs.registerApolloClient)(getClient);
|
|
650
|
-
return async (_query, options) => {
|
|
651
|
-
const res = await queryApollo({
|
|
652
|
-
query: _query,
|
|
653
|
-
variables: options?.variables,
|
|
654
|
-
context: {
|
|
655
|
-
headers: {
|
|
656
|
-
Cookie: options?.noCookie ? void 0 : await (0, import_headers.cookies)()
|
|
657
|
-
},
|
|
658
|
-
fetchOptions: {
|
|
659
|
-
cache: options?.revalidate === void 0 ? "force-cache" : void 0,
|
|
660
|
-
next: {
|
|
661
|
-
revalidate: options?.revalidate,
|
|
662
|
-
tags: options?.tags
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
});
|
|
667
|
-
return res.data;
|
|
668
|
-
};
|
|
669
|
-
};
|
|
670
|
-
|
|
671
618
|
// src/graphql/utils.ts
|
|
672
619
|
var import_type_graphql2 = require("type-graphql");
|
|
673
620
|
function query(fn, options) {
|
|
@@ -762,10 +709,8 @@ function FieldLibrary(type, queries) {
|
|
|
762
709
|
0 && (module.exports = {
|
|
763
710
|
FieldLibrary,
|
|
764
711
|
GQLError,
|
|
765
|
-
Injector,
|
|
766
712
|
QueryLibrary,
|
|
767
713
|
field,
|
|
768
|
-
getGraphQLQuery,
|
|
769
714
|
initGraphQLServer,
|
|
770
715
|
query
|
|
771
716
|
});
|
package/dist/graphql/index.d.mts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
export { GQLError } from './errors.mjs';
|
|
2
2
|
export { initGraphQLServer } from './init.mjs';
|
|
3
|
-
export { Injector, getGraphQLQuery } from './server.mjs';
|
|
4
3
|
export { AuthorizedContext, Context } from './types.mjs';
|
|
5
4
|
export { FieldLibrary, QueryLibrary, field, query } from './utils.mjs';
|
|
6
5
|
import 'graphql/error';
|
|
7
6
|
import '@apollo/server';
|
|
8
7
|
import 'next/server';
|
|
9
8
|
import 'type-graphql';
|
|
10
|
-
import 'react';
|
|
11
|
-
import '@apollo/client';
|
|
12
|
-
import '@graphql-typed-document-node/core';
|
|
13
9
|
import 'graphql';
|
package/dist/graphql/index.d.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
export { GQLError } from './errors.js';
|
|
2
2
|
export { initGraphQLServer } from './init.js';
|
|
3
|
-
export { Injector, getGraphQLQuery } from './server.js';
|
|
4
3
|
export { AuthorizedContext, Context } from './types.js';
|
|
5
4
|
export { FieldLibrary, QueryLibrary, field, query } from './utils.js';
|
|
6
5
|
import 'graphql/error';
|
|
7
6
|
import '@apollo/server';
|
|
8
7
|
import 'next/server';
|
|
9
8
|
import 'type-graphql';
|
|
10
|
-
import 'react';
|
|
11
|
-
import '@apollo/client';
|
|
12
|
-
import '@graphql-typed-document-node/core';
|
|
13
9
|
import 'graphql';
|
|
@@ -602,61 +602,6 @@ async function initGraphQLServer({
|
|
|
602
602
|
};
|
|
603
603
|
}
|
|
604
604
|
|
|
605
|
-
// src/graphql/server.tsx
|
|
606
|
-
import {
|
|
607
|
-
ApolloClient,
|
|
608
|
-
HttpLink,
|
|
609
|
-
InMemoryCache
|
|
610
|
-
} from "@apollo/client";
|
|
611
|
-
import { registerApolloClient } from "@apollo/client-integration-nextjs";
|
|
612
|
-
import { cookies } from "next/headers";
|
|
613
|
-
import { Suspense } from "react";
|
|
614
|
-
function Injector({
|
|
615
|
-
fetch,
|
|
616
|
-
Component,
|
|
617
|
-
props
|
|
618
|
-
}) {
|
|
619
|
-
return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ React.createElement(InjectorSuspensed, { Component, fetch, props }));
|
|
620
|
-
}
|
|
621
|
-
async function InjectorSuspensed({
|
|
622
|
-
fetch,
|
|
623
|
-
Component,
|
|
624
|
-
props
|
|
625
|
-
}) {
|
|
626
|
-
const data = await fetch();
|
|
627
|
-
return /* @__PURE__ */ React.createElement(Component, { loading: false, ...props || {}, data });
|
|
628
|
-
}
|
|
629
|
-
var getGraphQLQuery = ({ uri }) => {
|
|
630
|
-
const getClient = () => {
|
|
631
|
-
return new ApolloClient({
|
|
632
|
-
cache: new InMemoryCache(),
|
|
633
|
-
link: new HttpLink({
|
|
634
|
-
uri
|
|
635
|
-
})
|
|
636
|
-
});
|
|
637
|
-
};
|
|
638
|
-
const { query: queryApollo } = registerApolloClient(getClient);
|
|
639
|
-
return async (_query, options) => {
|
|
640
|
-
const res = await queryApollo({
|
|
641
|
-
query: _query,
|
|
642
|
-
variables: options?.variables,
|
|
643
|
-
context: {
|
|
644
|
-
headers: {
|
|
645
|
-
Cookie: options?.noCookie ? void 0 : await cookies()
|
|
646
|
-
},
|
|
647
|
-
fetchOptions: {
|
|
648
|
-
cache: options?.revalidate === void 0 ? "force-cache" : void 0,
|
|
649
|
-
next: {
|
|
650
|
-
revalidate: options?.revalidate,
|
|
651
|
-
tags: options?.tags
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
});
|
|
656
|
-
return res.data;
|
|
657
|
-
};
|
|
658
|
-
};
|
|
659
|
-
|
|
660
605
|
// src/graphql/utils.ts
|
|
661
606
|
import {
|
|
662
607
|
Arg,
|
|
@@ -759,10 +704,8 @@ function FieldLibrary(type, queries) {
|
|
|
759
704
|
export {
|
|
760
705
|
FieldLibrary,
|
|
761
706
|
GQLError,
|
|
762
|
-
Injector,
|
|
763
707
|
QueryLibrary,
|
|
764
708
|
field,
|
|
765
|
-
getGraphQLQuery,
|
|
766
709
|
initGraphQLServer,
|
|
767
710
|
query
|
|
768
711
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "naystack",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
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",
|
|
@@ -79,11 +79,11 @@
|
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@eslint/eslintrc": "^3.3.1",
|
|
82
|
+
"@graphql-typed-document-node/core": "^3.2.0",
|
|
82
83
|
"@types/cloudflare-turnstile": "^0.2.2",
|
|
83
84
|
"@types/jsonwebtoken": "^9.0.7",
|
|
84
85
|
"@types/node": "^24.5.2",
|
|
85
86
|
"@types/react": "^19.2",
|
|
86
|
-
"@graphql-typed-document-node/core": "^3.2.0",
|
|
87
87
|
"@types/react-dom": "^19.2",
|
|
88
88
|
"dotenv": "^17.2.2",
|
|
89
89
|
"eslint": "^9.26.0",
|