@cedarjs/web 0.0.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/LICENSE +21 -0
- package/README.md +33 -0
- package/apollo/index.js +2 -0
- package/apollo/package.json +4 -0
- package/dist/apollo/fragmentRegistry.d.ts +43 -0
- package/dist/apollo/fragmentRegistry.d.ts.map +1 -0
- package/dist/apollo/fragmentRegistry.js +39 -0
- package/dist/apollo/index.d.ts +77 -0
- package/dist/apollo/index.d.ts.map +1 -0
- package/dist/apollo/index.js +198 -0
- package/dist/apollo/links.d.ts +27 -0
- package/dist/apollo/links.d.ts.map +1 -0
- package/dist/apollo/links.js +94 -0
- package/dist/apollo/sseLink.d.ts +29 -0
- package/dist/apollo/sseLink.d.ts.map +1 -0
- package/dist/apollo/sseLink.js +94 -0
- package/dist/apollo/suspense.d.ts +59 -0
- package/dist/apollo/suspense.d.ts.map +1 -0
- package/dist/apollo/suspense.js +113 -0
- package/dist/apollo/typeOverride.d.ts +21 -0
- package/dist/apollo/typeOverride.d.ts.map +1 -0
- package/dist/apollo/typeOverride.js +0 -0
- package/dist/apollo/useCache.d.ts +22 -0
- package/dist/apollo/useCache.d.ts.map +1 -0
- package/dist/apollo/useCache.js +25 -0
- package/dist/bins/cross-env.d.ts +3 -0
- package/dist/bins/cross-env.d.ts.map +1 -0
- package/dist/bins/msw.d.ts +3 -0
- package/dist/bins/msw.d.ts.map +1 -0
- package/dist/bins/redwood.d.ts +9 -0
- package/dist/bins/redwood.d.ts.map +1 -0
- package/dist/bins/rwfw.d.ts +3 -0
- package/dist/bins/rwfw.d.ts.map +1 -0
- package/dist/bins/storybook.d.ts +3 -0
- package/dist/bins/storybook.d.ts.map +1 -0
- package/dist/bins/tsc.d.ts +3 -0
- package/dist/bins/tsc.d.ts.map +1 -0
- package/dist/bundled/apollo-upload-client.d.ts +3 -0
- package/dist/bundled/apollo-upload-client.d.ts.map +1 -0
- package/dist/bundled/apollo-upload-client.js +4 -0
- package/dist/cjs/apollo/fragmentRegistry.d.ts +43 -0
- package/dist/cjs/apollo/fragmentRegistry.d.ts.map +1 -0
- package/dist/cjs/apollo/fragmentRegistry.js +75 -0
- package/dist/cjs/apollo/index.d.ts +77 -0
- package/dist/cjs/apollo/index.d.ts.map +1 -0
- package/dist/cjs/apollo/index.js +216 -0
- package/dist/cjs/apollo/links.d.ts +27 -0
- package/dist/cjs/apollo/links.d.ts.map +1 -0
- package/dist/cjs/apollo/links.js +122 -0
- package/dist/cjs/apollo/sseLink.d.ts +29 -0
- package/dist/cjs/apollo/sseLink.d.ts.map +1 -0
- package/dist/cjs/apollo/sseLink.js +120 -0
- package/dist/cjs/apollo/suspense.d.ts +59 -0
- package/dist/cjs/apollo/suspense.d.ts.map +1 -0
- package/dist/cjs/apollo/suspense.js +127 -0
- package/dist/cjs/apollo/typeOverride.d.ts +21 -0
- package/dist/cjs/apollo/typeOverride.d.ts.map +1 -0
- package/dist/cjs/apollo/typeOverride.js +16 -0
- package/dist/cjs/apollo/useCache.d.ts +22 -0
- package/dist/cjs/apollo/useCache.d.ts.map +1 -0
- package/dist/cjs/apollo/useCache.js +49 -0
- package/dist/cjs/bins/cross-env.d.ts +3 -0
- package/dist/cjs/bins/cross-env.d.ts.map +1 -0
- package/dist/cjs/bins/cross-env.js +30 -0
- package/dist/cjs/bins/msw.d.ts +3 -0
- package/dist/cjs/bins/msw.d.ts.map +1 -0
- package/dist/cjs/bins/msw.js +28 -0
- package/dist/cjs/bins/redwood.d.ts +9 -0
- package/dist/cjs/bins/redwood.d.ts.map +1 -0
- package/dist/cjs/bins/redwood.js +36 -0
- package/dist/cjs/bins/rwfw.d.ts +3 -0
- package/dist/cjs/bins/rwfw.d.ts.map +1 -0
- package/dist/cjs/bins/rwfw.js +36 -0
- package/dist/cjs/bins/storybook.d.ts +3 -0
- package/dist/cjs/bins/storybook.d.ts.map +1 -0
- package/dist/cjs/bins/storybook.js +49 -0
- package/dist/cjs/bins/tsc.d.ts +3 -0
- package/dist/cjs/bins/tsc.d.ts.map +1 -0
- package/dist/cjs/bins/tsc.js +30 -0
- package/dist/cjs/bundled/apollo-upload-client.d.ts +3 -0
- package/dist/cjs/bundled/apollo-upload-client.d.ts.map +1 -0
- package/dist/cjs/bundled/apollo-upload-client.js +2474 -0
- package/dist/cjs/components/DevFatalErrorPage.d.ts +21 -0
- package/dist/cjs/components/DevFatalErrorPage.d.ts.map +1 -0
- package/dist/cjs/components/DevFatalErrorPage.js +436 -0
- package/dist/cjs/components/FatalErrorBoundary.d.ts +24 -0
- package/dist/cjs/components/FatalErrorBoundary.d.ts.map +1 -0
- package/dist/cjs/components/FatalErrorBoundary.js +63 -0
- package/dist/cjs/components/FetchConfigProvider.d.ts +25 -0
- package/dist/cjs/components/FetchConfigProvider.d.ts.map +1 -0
- package/dist/cjs/components/FetchConfigProvider.js +80 -0
- package/dist/cjs/components/GraphQLHooksProvider.d.ts +45 -0
- package/dist/cjs/components/GraphQLHooksProvider.d.ts.map +1 -0
- package/dist/cjs/components/GraphQLHooksProvider.js +135 -0
- package/dist/cjs/components/MetaTags.d.ts +52 -0
- package/dist/cjs/components/MetaTags.d.ts.map +1 -0
- package/dist/cjs/components/MetaTags.js +69 -0
- package/dist/cjs/components/Metadata.d.ts +9 -0
- package/dist/cjs/components/Metadata.d.ts.map +1 -0
- package/dist/cjs/components/Metadata.js +95 -0
- package/dist/cjs/components/PortalHead.d.ts +4 -0
- package/dist/cjs/components/PortalHead.d.ts.map +1 -0
- package/dist/cjs/components/PortalHead.js +59 -0
- package/dist/cjs/components/RedwoodProvider.d.ts +9 -0
- package/dist/cjs/components/RedwoodProvider.d.ts.map +1 -0
- package/dist/cjs/components/RedwoodProvider.js +58 -0
- package/dist/cjs/components/ServerInject.d.ts +26 -0
- package/dist/cjs/components/ServerInject.d.ts.map +1 -0
- package/dist/cjs/components/ServerInject.js +75 -0
- package/dist/cjs/components/cell/CellCacheContext.d.ts +20 -0
- package/dist/cjs/components/cell/CellCacheContext.d.ts.map +1 -0
- package/dist/cjs/components/cell/CellCacheContext.js +53 -0
- package/dist/cjs/components/cell/CellErrorBoundary.d.ts +25 -0
- package/dist/cjs/components/cell/CellErrorBoundary.d.ts.map +1 -0
- package/dist/cjs/components/cell/CellErrorBoundary.js +66 -0
- package/dist/cjs/components/cell/cellTypes.d.ts +152 -0
- package/dist/cjs/components/cell/cellTypes.d.ts.map +1 -0
- package/dist/cjs/components/cell/cellTypes.js +16 -0
- package/dist/cjs/components/cell/createCell.d.ts +10 -0
- package/dist/cjs/components/cell/createCell.d.ts.map +1 -0
- package/dist/cjs/components/cell/createCell.js +165 -0
- package/dist/cjs/components/cell/createCell.test.js +351 -0
- package/dist/cjs/components/cell/createServerCell.d.ts +15 -0
- package/dist/cjs/components/cell/createServerCell.d.ts.map +1 -0
- package/dist/cjs/components/cell/createServerCell.js +91 -0
- package/dist/cjs/components/cell/createSuspendingCell.d.ts +11 -0
- package/dist/cjs/components/cell/createSuspendingCell.d.ts.map +1 -0
- package/dist/cjs/components/cell/createSuspendingCell.js +152 -0
- package/dist/cjs/components/cell/createSuspendingCell.test.js +115 -0
- package/dist/cjs/components/cell/isCellEmpty.d.ts +41 -0
- package/dist/cjs/components/cell/isCellEmpty.d.ts.map +1 -0
- package/dist/cjs/components/cell/isCellEmpty.js +35 -0
- package/dist/cjs/components/htmlTags.d.ts +52 -0
- package/dist/cjs/components/htmlTags.d.ts.map +1 -0
- package/dist/cjs/components/htmlTags.js +88 -0
- package/dist/cjs/config.d.ts +2 -0
- package/dist/cjs/config.d.ts.map +1 -0
- package/dist/cjs/config.js +6 -0
- package/dist/cjs/entry/index.js +39 -0
- package/dist/cjs/global.web-auto-imports.d.ts +30 -0
- package/dist/cjs/global.web-auto-imports.d.ts.map +1 -0
- package/dist/cjs/global.web-auto-imports.js +16 -0
- package/dist/cjs/graphql.d.ts +24 -0
- package/dist/cjs/graphql.d.ts.map +1 -0
- package/dist/cjs/graphql.js +36 -0
- package/dist/cjs/index.d.ts +20 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +80 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/routeHooks.types.d.ts +12 -0
- package/dist/cjs/routeHooks.types.d.ts.map +1 -0
- package/dist/cjs/routeHooks.types.js +16 -0
- package/dist/cjs/server/MiddlewareRequest.d.ts +28 -0
- package/dist/cjs/server/MiddlewareRequest.d.ts.map +1 -0
- package/dist/cjs/server/MiddlewareRequest.js +71 -0
- package/dist/cjs/server/MiddlewareResponse.d.ts +44 -0
- package/dist/cjs/server/MiddlewareResponse.d.ts.map +1 -0
- package/dist/cjs/server/MiddlewareResponse.js +130 -0
- package/dist/cjs/server/middleware.d.ts +17 -0
- package/dist/cjs/server/middleware.d.ts.map +1 -0
- package/dist/cjs/server/middleware.js +24 -0
- package/dist/cjs/server/request.d.ts +2 -0
- package/dist/cjs/server/request.d.ts.map +1 -0
- package/dist/cjs/server/request.js +34 -0
- package/dist/cjs/streamUtils/useDocumentReady.d.ts +11 -0
- package/dist/cjs/streamUtils/useDocumentReady.d.ts.map +1 -0
- package/dist/cjs/streamUtils/useDocumentReady.js +41 -0
- package/dist/cjs/toast/index.d.ts +3 -0
- package/dist/cjs/toast/index.d.ts.map +1 -0
- package/dist/cjs/toast/index.js +41 -0
- package/dist/components/DevFatalErrorPage.d.ts +21 -0
- package/dist/components/DevFatalErrorPage.d.ts.map +1 -0
- package/dist/components/DevFatalErrorPage.js +402 -0
- package/dist/components/FatalErrorBoundary.d.ts +24 -0
- package/dist/components/FatalErrorBoundary.d.ts.map +1 -0
- package/dist/components/FatalErrorBoundary.js +29 -0
- package/dist/components/FetchConfigProvider.d.ts +25 -0
- package/dist/components/FetchConfigProvider.d.ts.map +1 -0
- package/dist/components/FetchConfigProvider.js +43 -0
- package/dist/components/GraphQLHooksProvider.d.ts +45 -0
- package/dist/components/GraphQLHooksProvider.d.ts.map +1 -0
- package/dist/components/GraphQLHooksProvider.js +94 -0
- package/dist/components/MetaTags.d.ts +52 -0
- package/dist/components/MetaTags.d.ts.map +1 -0
- package/dist/components/MetaTags.js +35 -0
- package/dist/components/Metadata.d.ts +9 -0
- package/dist/components/Metadata.d.ts.map +1 -0
- package/dist/components/Metadata.js +61 -0
- package/dist/components/PortalHead.d.ts +4 -0
- package/dist/components/PortalHead.d.ts.map +1 -0
- package/dist/components/PortalHead.js +29 -0
- package/dist/components/RedwoodProvider.d.ts +9 -0
- package/dist/components/RedwoodProvider.d.ts.map +1 -0
- package/dist/components/RedwoodProvider.js +24 -0
- package/dist/components/ServerInject.d.ts +26 -0
- package/dist/components/ServerInject.d.ts.map +1 -0
- package/dist/components/ServerInject.js +37 -0
- package/dist/components/cell/CellCacheContext.d.ts +20 -0
- package/dist/components/cell/CellCacheContext.d.ts.map +1 -0
- package/dist/components/cell/CellCacheContext.js +18 -0
- package/dist/components/cell/CellErrorBoundary.d.ts +25 -0
- package/dist/components/cell/CellErrorBoundary.d.ts.map +1 -0
- package/dist/components/cell/CellErrorBoundary.js +32 -0
- package/dist/components/cell/cellTypes.d.ts +152 -0
- package/dist/components/cell/cellTypes.d.ts.map +1 -0
- package/dist/components/cell/cellTypes.js +0 -0
- package/dist/components/cell/createCell.d.ts +10 -0
- package/dist/components/cell/createCell.d.ts.map +1 -0
- package/dist/components/cell/createCell.js +131 -0
- package/dist/components/cell/createCell.test.js +328 -0
- package/dist/components/cell/createServerCell.d.ts +15 -0
- package/dist/components/cell/createServerCell.d.ts.map +1 -0
- package/dist/components/cell/createServerCell.js +57 -0
- package/dist/components/cell/createSuspendingCell.d.ts +11 -0
- package/dist/components/cell/createSuspendingCell.d.ts.map +1 -0
- package/dist/components/cell/createSuspendingCell.js +118 -0
- package/dist/components/cell/createSuspendingCell.test.js +92 -0
- package/dist/components/cell/isCellEmpty.d.ts +41 -0
- package/dist/components/cell/isCellEmpty.d.ts.map +1 -0
- package/dist/components/cell/isCellEmpty.js +11 -0
- package/dist/components/htmlTags.d.ts +52 -0
- package/dist/components/htmlTags.d.ts.map +1 -0
- package/dist/components/htmlTags.js +53 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +5 -0
- package/dist/entry/index.d.ts +1 -0
- package/dist/entry/index.js +16 -0
- package/dist/global.web-auto-imports.d.ts +30 -0
- package/dist/global.web-auto-imports.d.ts.map +1 -0
- package/dist/global.web-auto-imports.js +0 -0
- package/dist/graphql.d.ts +24 -0
- package/dist/graphql.d.ts.map +1 -0
- package/dist/graphql.js +12 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/package.json +1 -0
- package/dist/routeHooks.types.d.ts +12 -0
- package/dist/routeHooks.types.d.ts.map +1 -0
- package/dist/routeHooks.types.js +0 -0
- package/dist/server/MiddlewareRequest.d.ts +28 -0
- package/dist/server/MiddlewareRequest.d.ts.map +1 -0
- package/dist/server/MiddlewareRequest.js +46 -0
- package/dist/server/MiddlewareResponse.d.ts +44 -0
- package/dist/server/MiddlewareResponse.d.ts.map +1 -0
- package/dist/server/MiddlewareResponse.js +95 -0
- package/dist/server/middleware.d.ts +17 -0
- package/dist/server/middleware.d.ts.map +1 -0
- package/dist/server/middleware.js +2 -0
- package/dist/server/request.d.ts +2 -0
- package/dist/server/request.d.ts.map +1 -0
- package/dist/server/request.js +12 -0
- package/dist/streamUtils/useDocumentReady.d.ts +11 -0
- package/dist/streamUtils/useDocumentReady.d.ts.map +1 -0
- package/dist/streamUtils/useDocumentReady.js +17 -0
- package/dist/toast/index.d.ts +3 -0
- package/dist/toast/index.d.ts.map +1 -0
- package/dist/toast/index.js +5 -0
- package/package.json +193 -0
- package/src/entry/index.jsx +29 -0
- package/toast/index.js +2 -0
- package/toast/package.json +4 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React, { Suspense } from "react";
|
|
2
|
+
import { isDataEmpty } from "./isCellEmpty.js";
|
|
3
|
+
function createServerCell(createCellProps) {
|
|
4
|
+
const {
|
|
5
|
+
data: dataFn,
|
|
6
|
+
isEmpty = isDataEmpty,
|
|
7
|
+
Loading,
|
|
8
|
+
Failure,
|
|
9
|
+
Empty,
|
|
10
|
+
Success,
|
|
11
|
+
displayName = "Cell"
|
|
12
|
+
} = createCellProps;
|
|
13
|
+
async function SuspendingSuccess(props) {
|
|
14
|
+
const { children: _, ...variables } = props;
|
|
15
|
+
const FailureComponent = ({ error }) => {
|
|
16
|
+
if (!Failure) {
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
const queryResultWithRefetch = {
|
|
20
|
+
refetch: (variables2) => {
|
|
21
|
+
return dataFn(variables2);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
return /* @__PURE__ */ React.createElement(Failure, { error, queryResult: queryResultWithRefetch });
|
|
25
|
+
};
|
|
26
|
+
try {
|
|
27
|
+
const data = await dataFn(variables);
|
|
28
|
+
if (isEmpty(data, { isDataEmpty }) && Empty) {
|
|
29
|
+
return /* @__PURE__ */ React.createElement(Empty, { ...props, ...data });
|
|
30
|
+
}
|
|
31
|
+
return /* @__PURE__ */ React.createElement(Success, { ...data, ...props });
|
|
32
|
+
} catch (error) {
|
|
33
|
+
return /* @__PURE__ */ React.createElement(FailureComponent, { error });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
SuspendingSuccess.displayName = displayName;
|
|
37
|
+
return (props) => {
|
|
38
|
+
const wrapInSuspenseIfLoadingPresent = (suspendingSuccessElement, LoadingComponent) => {
|
|
39
|
+
if (!LoadingComponent) {
|
|
40
|
+
return suspendingSuccessElement;
|
|
41
|
+
}
|
|
42
|
+
return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(LoadingComponent, { ...props }) }, suspendingSuccessElement);
|
|
43
|
+
};
|
|
44
|
+
return (
|
|
45
|
+
// TODO(RSC): Do we always want a client side error boundary? If so, this
|
|
46
|
+
// is where we'd add it
|
|
47
|
+
// <CellErrorBoundary renderFallback={FailureComponent}>
|
|
48
|
+
/* @__PURE__ */ React.createElement(React.Fragment, null, wrapInSuspenseIfLoadingPresent(
|
|
49
|
+
/* @__PURE__ */ React.createElement(SuspendingSuccess, { ...props }),
|
|
50
|
+
Loading
|
|
51
|
+
))
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
createServerCell
|
|
57
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { CreateCellProps } from './cellTypes.js';
|
|
3
|
+
type AnyObj = Record<string, unknown>;
|
|
4
|
+
/**
|
|
5
|
+
* Creates a Cell ~~ with Apollo Client only ~~
|
|
6
|
+
* using the hooks useBackgroundQuery and useReadQuery
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
export declare function createSuspendingCell<CellProps extends AnyObj, CellVariables extends AnyObj>(createCellProps: CreateCellProps<AnyObj, CellVariables>): React.FC<CellProps>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=createSuspendingCell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSuspendingCell.d.ts","sourceRoot":"","sources":["../../../src/components/cell/createSuspendingCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAYvC,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,gBAAgB,CAAA;AAGvB,KAAK,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AACrC;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,SAAS,MAAM,EACxB,aAAa,SAAS,MAAM,EAE5B,eAAe,EAAE,eAAe,CAAC,MAAM,EAAE,aAAa,CAAC,GACtD,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC,CAqIrB"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import React, { Suspense } from "react";
|
|
2
|
+
import { useApolloClient } from "@apollo/client/react/hooks/hooks.cjs";
|
|
3
|
+
import { useBackgroundQuery, useReadQuery } from "../GraphQLHooksProvider.js";
|
|
4
|
+
import { CellErrorBoundary } from "./CellErrorBoundary.js";
|
|
5
|
+
import { isDataEmpty } from "./isCellEmpty.js";
|
|
6
|
+
function createSuspendingCell(createCellProps) {
|
|
7
|
+
const {
|
|
8
|
+
QUERY,
|
|
9
|
+
beforeQuery = (props) => ({
|
|
10
|
+
// By default, we assume that the props are the gql-variables.
|
|
11
|
+
variables: props,
|
|
12
|
+
/**
|
|
13
|
+
* We're duplicating these props here due to a suspected bug in Apollo Client v3.5.4
|
|
14
|
+
* (it doesn't seem to be respecting `defaultOptions` in `RedwoodApolloProvider`.)
|
|
15
|
+
*
|
|
16
|
+
* @see {@link https://github.com/apollographql/apollo-client/issues/9105}
|
|
17
|
+
*/
|
|
18
|
+
fetchPolicy: "cache-and-network",
|
|
19
|
+
notifyOnNetworkStatusChange: true
|
|
20
|
+
}),
|
|
21
|
+
afterQuery = (data) => ({ ...data }),
|
|
22
|
+
isEmpty = isDataEmpty,
|
|
23
|
+
Loading,
|
|
24
|
+
Failure,
|
|
25
|
+
Empty,
|
|
26
|
+
Success,
|
|
27
|
+
displayName = "Cell"
|
|
28
|
+
} = createCellProps;
|
|
29
|
+
function SuspendingSuccess(props) {
|
|
30
|
+
const { queryRef, suspenseQueryResult, userProps } = props;
|
|
31
|
+
const { data, networkStatus } = useReadQuery(queryRef);
|
|
32
|
+
const afterQueryData = afterQuery(data);
|
|
33
|
+
const queryResultWithNetworkStatus = {
|
|
34
|
+
...suspenseQueryResult,
|
|
35
|
+
networkStatus
|
|
36
|
+
};
|
|
37
|
+
if (isEmpty(data, { isDataEmpty }) && Empty) {
|
|
38
|
+
return /* @__PURE__ */ React.createElement(
|
|
39
|
+
Empty,
|
|
40
|
+
{
|
|
41
|
+
...userProps,
|
|
42
|
+
...afterQueryData,
|
|
43
|
+
queryResult: queryResultWithNetworkStatus
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
return /* @__PURE__ */ React.createElement(
|
|
48
|
+
Success,
|
|
49
|
+
{
|
|
50
|
+
...afterQueryData,
|
|
51
|
+
...userProps,
|
|
52
|
+
queryResult: queryResultWithNetworkStatus
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
SuspendingSuccess.displayName = displayName;
|
|
57
|
+
return (props) => {
|
|
58
|
+
const { children: _, ...variables } = props;
|
|
59
|
+
const options = beforeQuery(variables);
|
|
60
|
+
const query = typeof QUERY === "function" ? QUERY(options) : QUERY;
|
|
61
|
+
const [queryRef, other] = useBackgroundQuery(query, options);
|
|
62
|
+
const client = useApolloClient();
|
|
63
|
+
const suspenseQueryResult = {
|
|
64
|
+
client,
|
|
65
|
+
...other,
|
|
66
|
+
called: !!queryRef
|
|
67
|
+
};
|
|
68
|
+
const FailureComponent = ({ error, resetErrorBoundary }) => {
|
|
69
|
+
if (!Failure) {
|
|
70
|
+
if (error) {
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
throw new Error("Unreachable code: FailureComponent without a Failure");
|
|
74
|
+
}
|
|
75
|
+
const queryResultWithErrorReset = {
|
|
76
|
+
...suspenseQueryResult,
|
|
77
|
+
refetch: (variables2) => {
|
|
78
|
+
resetErrorBoundary();
|
|
79
|
+
return suspenseQueryResult.refetch?.(variables2);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
return /* @__PURE__ */ React.createElement(
|
|
83
|
+
Failure,
|
|
84
|
+
{
|
|
85
|
+
error,
|
|
86
|
+
errorCode: error?.graphQLErrors?.[0]?.extensions?.["code"],
|
|
87
|
+
queryResult: queryResultWithErrorReset
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
const wrapInSuspenseIfLoadingPresent = (suspendingSuccessElement, LoadingComponent) => {
|
|
92
|
+
if (!LoadingComponent) {
|
|
93
|
+
return suspendingSuccessElement;
|
|
94
|
+
}
|
|
95
|
+
return /* @__PURE__ */ React.createElement(
|
|
96
|
+
Suspense,
|
|
97
|
+
{
|
|
98
|
+
fallback: /* @__PURE__ */ React.createElement(LoadingComponent, { ...props, queryResult: suspenseQueryResult })
|
|
99
|
+
},
|
|
100
|
+
suspendingSuccessElement
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
return /* @__PURE__ */ React.createElement(CellErrorBoundary, { renderFallback: FailureComponent }, wrapInSuspenseIfLoadingPresent(
|
|
104
|
+
/* @__PURE__ */ React.createElement(
|
|
105
|
+
SuspendingSuccess,
|
|
106
|
+
{
|
|
107
|
+
userProps: props,
|
|
108
|
+
queryRef,
|
|
109
|
+
suspenseQueryResult
|
|
110
|
+
}
|
|
111
|
+
),
|
|
112
|
+
Loading
|
|
113
|
+
));
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export {
|
|
117
|
+
createSuspendingCell
|
|
118
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { loadErrorMessages, loadDevMessages } from "@apollo/client/dev";
|
|
3
|
+
import { render, screen } from "@testing-library/react";
|
|
4
|
+
import { vi, describe, beforeAll, test } from "vitest";
|
|
5
|
+
import { GraphQLHooksProvider } from "../GraphQLHooksProvider.js";
|
|
6
|
+
import { createSuspendingCell } from "./createSuspendingCell.js";
|
|
7
|
+
vi.mock("@apollo/client/react/hooks/hooks.cjs", () => {
|
|
8
|
+
return {
|
|
9
|
+
useApolloClient: vi.fn()
|
|
10
|
+
};
|
|
11
|
+
});
|
|
12
|
+
describe("createSuspendingCell", () => {
|
|
13
|
+
beforeAll(() => {
|
|
14
|
+
globalThis.RWJS_ENV = {
|
|
15
|
+
RWJS_EXP_STREAMING_SSR: true
|
|
16
|
+
};
|
|
17
|
+
loadDevMessages();
|
|
18
|
+
loadErrorMessages();
|
|
19
|
+
});
|
|
20
|
+
const mockedUseBgQuery = () => {
|
|
21
|
+
return ["mocked-query-ref", { refetch: vi.fn(), fetchMore: vi.fn() }];
|
|
22
|
+
};
|
|
23
|
+
const mockedQueryHook = () => ({ data: {} });
|
|
24
|
+
test("Renders a static Success component", () => {
|
|
25
|
+
const TestCell = createSuspendingCell({
|
|
26
|
+
// @ts-expect-error - Purposefully using a plain string here.
|
|
27
|
+
QUERY: "query TestQuery { answer }",
|
|
28
|
+
Success: () => /* @__PURE__ */ React.createElement(React.Fragment, null, "Great success!")
|
|
29
|
+
});
|
|
30
|
+
render(
|
|
31
|
+
/* @__PURE__ */ React.createElement(
|
|
32
|
+
GraphQLHooksProvider,
|
|
33
|
+
{
|
|
34
|
+
useBackgroundQuery: mockedUseBgQuery,
|
|
35
|
+
useReadQuery: mockedQueryHook
|
|
36
|
+
},
|
|
37
|
+
/* @__PURE__ */ React.createElement(TestCell, null)
|
|
38
|
+
)
|
|
39
|
+
);
|
|
40
|
+
screen.getByText(/^Great success!$/);
|
|
41
|
+
});
|
|
42
|
+
test("Renders Success with data", () => {
|
|
43
|
+
const TestCell = createSuspendingCell({
|
|
44
|
+
// @ts-expect-error - Purposefully using a plain string here.
|
|
45
|
+
QUERY: "query TestQuery { answer }",
|
|
46
|
+
Success: ({ answer }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("dl", null, /* @__PURE__ */ React.createElement("dt", null, "What's the meaning of life?"), /* @__PURE__ */ React.createElement("dd", null, answer)))
|
|
47
|
+
});
|
|
48
|
+
const myUseQueryHook = () => {
|
|
49
|
+
return { data: { answer: 42 } };
|
|
50
|
+
};
|
|
51
|
+
render(
|
|
52
|
+
/* @__PURE__ */ React.createElement(
|
|
53
|
+
GraphQLHooksProvider,
|
|
54
|
+
{
|
|
55
|
+
useReadQuery: myUseQueryHook,
|
|
56
|
+
useBackgroundQuery: mockedUseBgQuery
|
|
57
|
+
},
|
|
58
|
+
/* @__PURE__ */ React.createElement(TestCell, null)
|
|
59
|
+
)
|
|
60
|
+
);
|
|
61
|
+
screen.getByText(/^What's the meaning of life\?$/);
|
|
62
|
+
screen.getByText(/^42$/);
|
|
63
|
+
});
|
|
64
|
+
test("Renders Success if any of the fields have data (i.e. not just the first)", () => {
|
|
65
|
+
const TestCell = createSuspendingCell({
|
|
66
|
+
// @ts-expect-error - Purposefully using a plain string here.
|
|
67
|
+
QUERY: "query TestQuery { users { name } posts { title } }",
|
|
68
|
+
Empty: () => /* @__PURE__ */ React.createElement(React.Fragment, null, "No users or posts"),
|
|
69
|
+
Success: ({ users, posts }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", null, users.length > 0 ? /* @__PURE__ */ React.createElement("ul", null, users.map(({ name }) => /* @__PURE__ */ React.createElement("li", { key: name }, name))) : "no users"), /* @__PURE__ */ React.createElement("div", null, posts.length > 0 ? /* @__PURE__ */ React.createElement("ul", null, posts.map(({ title }) => /* @__PURE__ */ React.createElement("li", { key: title }, title))) : "no posts"))
|
|
70
|
+
});
|
|
71
|
+
const myReadQueryHook = () => {
|
|
72
|
+
return {
|
|
73
|
+
data: {
|
|
74
|
+
users: [],
|
|
75
|
+
posts: [{ title: "bazinga" }, { title: "kittens" }]
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
render(
|
|
80
|
+
/* @__PURE__ */ React.createElement(
|
|
81
|
+
GraphQLHooksProvider,
|
|
82
|
+
{
|
|
83
|
+
useReadQuery: myReadQueryHook,
|
|
84
|
+
useBackgroundQuery: mockedUseBgQuery
|
|
85
|
+
},
|
|
86
|
+
/* @__PURE__ */ React.createElement(TestCell, null)
|
|
87
|
+
)
|
|
88
|
+
);
|
|
89
|
+
screen.getByText(/bazinga/);
|
|
90
|
+
screen.getByText(/kittens/);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { DataObject } from './cellTypes.js';
|
|
2
|
+
/**
|
|
3
|
+
* The default `isEmpty` implementation checks if any of the fields are `null`
|
|
4
|
+
* or an empty array.
|
|
5
|
+
*
|
|
6
|
+
* Consider the following queries. The former returns an object, the latter a list:
|
|
7
|
+
*
|
|
8
|
+
* ```js
|
|
9
|
+
* export const QUERY = gql`
|
|
10
|
+
* post {
|
|
11
|
+
* title
|
|
12
|
+
* }
|
|
13
|
+
* `
|
|
14
|
+
*
|
|
15
|
+
* export const QUERY = gql`
|
|
16
|
+
* posts {
|
|
17
|
+
* title
|
|
18
|
+
* }
|
|
19
|
+
* `
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* If either are "empty", they return:
|
|
23
|
+
*
|
|
24
|
+
* ```js
|
|
25
|
+
* {
|
|
26
|
+
* data: {
|
|
27
|
+
* post: null
|
|
28
|
+
* }
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* {
|
|
32
|
+
* data: {
|
|
33
|
+
* posts: []
|
|
34
|
+
* }
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* Note that the latter can return `null` as well depending on the SDL (`posts: [Post!]`).
|
|
39
|
+
*/
|
|
40
|
+
export declare function isDataEmpty(data?: DataObject): boolean;
|
|
41
|
+
//# sourceMappingURL=isCellEmpty.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isCellEmpty.d.ts","sourceRoot":"","sources":["../../../src/components/cell/isCellEmpty.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE,UAAU,WAO5C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function isDataEmpty(data) {
|
|
2
|
+
return !data || Object.values(data).every((fieldValue) => {
|
|
3
|
+
return fieldValue === null || isFieldEmptyArray(fieldValue);
|
|
4
|
+
});
|
|
5
|
+
}
|
|
6
|
+
function isFieldEmptyArray(field) {
|
|
7
|
+
return Array.isArray(field) && field.length === 0;
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
isDataEmpty
|
|
11
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** CSS is a specialised metatag */
|
|
3
|
+
export declare const Css: ({ css }: {
|
|
4
|
+
css: string[];
|
|
5
|
+
}) => React.JSX.Element;
|
|
6
|
+
/**
|
|
7
|
+
* <title>My Page</title>
|
|
8
|
+
*/
|
|
9
|
+
interface Title {
|
|
10
|
+
title: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* <meta name="author" content="Chris Mills" />
|
|
14
|
+
*/
|
|
15
|
+
interface NameContent {
|
|
16
|
+
name: string;
|
|
17
|
+
content: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* <meta property="og:image"
|
|
21
|
+
* content="https://.../opengraph-logo.png" />
|
|
22
|
+
*/
|
|
23
|
+
interface OpenGraph {
|
|
24
|
+
property: string;
|
|
25
|
+
content: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* <meta http-equiv="refresh" content="30">
|
|
29
|
+
*/
|
|
30
|
+
interface HttpEquiv {
|
|
31
|
+
httpEquiv: string;
|
|
32
|
+
content: string;
|
|
33
|
+
}
|
|
34
|
+
/***
|
|
35
|
+
* <meta some-attribute="some-value" />
|
|
36
|
+
*/
|
|
37
|
+
interface Custom {
|
|
38
|
+
[name: string]: unknown;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* <link rel="canonical" href="https://example.com" />
|
|
42
|
+
*/
|
|
43
|
+
interface Other extends Custom {
|
|
44
|
+
tagType: string;
|
|
45
|
+
}
|
|
46
|
+
export type TagDescriptor = Title | NameContent | OpenGraph | HttpEquiv | Custom | Other;
|
|
47
|
+
interface MetaProps {
|
|
48
|
+
tags: TagDescriptor[] | undefined;
|
|
49
|
+
}
|
|
50
|
+
export declare const Meta: ({ tags }: MetaProps) => React.JSX.Element;
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=htmlTags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"htmlTags.d.ts","sourceRoot":"","sources":["../../src/components/htmlTags.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAkCzB,mCAAmC;AACnC,eAAO,MAAM,GAAG,YAAa;IAAE,GAAG,EAAE,MAAM,EAAE,CAAA;CAAE,sBAY7C,CAAA;AAED;;GAEG;AACH,UAAU,KAAK;IACb,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;GAGG;AACH,UAAU,SAAS;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,UAAU,SAAS;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,UAAU,MAAM;IACd,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;CACxB;AAED;;GAEG;AACH,UAAU,KAAM,SAAQ,MAAM;IAC5B,OAAO,EAAE,MAAM,CAAA;CAChB;AAOD,MAAM,MAAM,aAAa,GACrB,KAAK,GAEL,WAAW,GACX,SAAS,GACT,SAAS,GAET,MAAM,GACN,KAAK,CAAA;AAET,UAAU,SAAS;IACjB,IAAI,EAAE,aAAa,EAAE,GAAG,SAAS,CAAA;CAClC;AAED,eAAO,MAAM,IAAI,aAAc,SAAS,sBA6BvC,CAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Fragment } from "react";
|
|
3
|
+
const extractCssFromAssetMap = () => {
|
|
4
|
+
if (typeof window !== "undefined") {
|
|
5
|
+
return window.__REDWOOD__ASSET_MAP?.css;
|
|
6
|
+
}
|
|
7
|
+
return void 0;
|
|
8
|
+
};
|
|
9
|
+
const extractMetaFromAssetMap = () => {
|
|
10
|
+
if (typeof window !== "undefined") {
|
|
11
|
+
return window.__REDWOOD__ASSET_MAP?.meta;
|
|
12
|
+
}
|
|
13
|
+
return void 0;
|
|
14
|
+
};
|
|
15
|
+
function addSlashIfNeeded(path) {
|
|
16
|
+
if (path.startsWith("http") || path.startsWith("/")) {
|
|
17
|
+
return path;
|
|
18
|
+
} else {
|
|
19
|
+
return "/" + path;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const Css = ({ css }) => {
|
|
23
|
+
const cssLinks = (css || extractCssFromAssetMap() || []).map(addSlashIfNeeded);
|
|
24
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, cssLinks.map((cssLink, index) => {
|
|
25
|
+
return /* @__PURE__ */ React.createElement("link", { rel: "stylesheet", key: `css-${index}`, href: `${cssLink}` });
|
|
26
|
+
}));
|
|
27
|
+
};
|
|
28
|
+
const Meta = ({ tags }) => {
|
|
29
|
+
const metaTags = tags || extractMetaFromAssetMap() || [];
|
|
30
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, metaTags.map((tag, index) => {
|
|
31
|
+
if (!tag) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
if (isTitleTag(tag)) {
|
|
35
|
+
return /* @__PURE__ */ React.createElement(Fragment, { key: "title" }, /* @__PURE__ */ React.createElement("title", null, tag.title), /* @__PURE__ */ React.createElement("meta", { property: "og:title", content: tag.title }));
|
|
36
|
+
}
|
|
37
|
+
if (otherTag(tag)) {
|
|
38
|
+
const { tagType: TagName, ...rest } = tag;
|
|
39
|
+
return /* @__PURE__ */ React.createElement(TagName, { key: `meta-${index}`, ...rest });
|
|
40
|
+
}
|
|
41
|
+
return /* @__PURE__ */ React.createElement("meta", { key: `meta-${index}`, ...tag });
|
|
42
|
+
}));
|
|
43
|
+
};
|
|
44
|
+
const isTitleTag = (tag) => {
|
|
45
|
+
return "title" in tag;
|
|
46
|
+
};
|
|
47
|
+
const otherTag = (tag) => {
|
|
48
|
+
return "tagType" in tag;
|
|
49
|
+
};
|
|
50
|
+
export {
|
|
51
|
+
Css,
|
|
52
|
+
Meta
|
|
53
|
+
};
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":""}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
globalThis.RWJS_API_GRAPHQL_URL = RWJS_ENV.RWJS_API_GRAPHQL_URL;
|
|
2
|
+
globalThis.RWJS_API_URL = RWJS_ENV.RWJS_API_URL;
|
|
3
|
+
globalThis.__REDWOOD__APP_TITLE = RWJS_ENV.__REDWOOD__APP_TITLE;
|
|
4
|
+
globalThis.RWJS_EXP_STREAMING_SSR = RWJS_ENV.RWJS_EXP_STREAMING_SSR;
|
|
5
|
+
globalThis.RWJS_EXP_RSC = RWJS_ENV.RWJS_EXP_RSC;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { hydrateRoot, createRoot } from "react-dom/client";
|
|
3
|
+
import App from "~redwood-app-root";
|
|
4
|
+
import Routes from "~redwood-app-routes";
|
|
5
|
+
const redwoodAppElement = document.getElementById("redwood-app");
|
|
6
|
+
if (redwoodAppElement.children?.length > 0) {
|
|
7
|
+
hydrateRoot(
|
|
8
|
+
redwoodAppElement,
|
|
9
|
+
/* @__PURE__ */ React.createElement(App, null, /* @__PURE__ */ React.createElement(Routes, null))
|
|
10
|
+
);
|
|
11
|
+
} else {
|
|
12
|
+
const root = createRoot(redwoodAppElement);
|
|
13
|
+
root.render(
|
|
14
|
+
/* @__PURE__ */ React.createElement(App, null, /* @__PURE__ */ React.createElement(Routes, null))
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type _React from 'react';
|
|
2
|
+
import type { DocumentNode } from 'graphql';
|
|
3
|
+
declare global {
|
|
4
|
+
const gql: (source: string | TemplateStringsArray | readonly string[], ...args: any[]) => DocumentNode;
|
|
5
|
+
type React = typeof _React;
|
|
6
|
+
interface Window {
|
|
7
|
+
/** URL or absolute path to the GraphQL serverless function */
|
|
8
|
+
RWJS_API_GRAPHQL_URL: string;
|
|
9
|
+
/** URL or absolute path to serverless functions */
|
|
10
|
+
RWJS_API_URL: string;
|
|
11
|
+
__REDWOOD__APP_TITLE: string;
|
|
12
|
+
}
|
|
13
|
+
type GraphQLOperationVariables = Record<string, any>;
|
|
14
|
+
interface QueryOperationResult<TData = any, TVariables = GraphQLOperationVariables> {
|
|
15
|
+
data: TData | undefined;
|
|
16
|
+
loading: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface MutationOperationResult<TData, TVariables> {
|
|
19
|
+
}
|
|
20
|
+
interface GraphQLQueryHookOptions<TData, TVariables> {
|
|
21
|
+
variables?: TVariables;
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}
|
|
24
|
+
export interface GraphQLMutationHookOptions<TData, TVariables> {
|
|
25
|
+
variables?: TVariables;
|
|
26
|
+
onCompleted?: (data: TData) => void;
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=global.web-auto-imports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global.web-auto-imports.d.ts","sourceRoot":"","sources":["../src/global.web-auto-imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,OAAO,CAAA;AAE/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAK3C,OAAO,CAAC,MAAM,CAAC;IAMb,MAAM,GAAG,EAAE,CACT,MAAM,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS,MAAM,EAAE,EACzD,GAAG,IAAI,EAAE,GAAG,EAAE,KACX,YAAY,CAAA;IAIjB,KAAK,KAAK,GAAG,OAAO,MAAM,CAAA;IAE1B,UAAU,MAAM;QACd,8DAA8D;QAC9D,oBAAoB,EAAE,MAAM,CAAA;QAC5B,mDAAmD;QACnD,YAAY,EAAE,MAAM,CAAA;QACpB,oBAAoB,EAAE,MAAM,CAAA;KAC7B;IAED,KAAK,yBAAyB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAIpD,UAAU,oBAAoB,CAC5B,KAAK,GAAG,GAAG,EACX,UAAU,GAAG,yBAAyB;QAEtC,IAAI,EAAE,KAAK,GAAG,SAAS,CAAA;QACvB,OAAO,EAAE,OAAO,CAAA;KAGjB;IAID,UAAU,uBAAuB,CAAC,KAAK,EAAE,UAAU;KAAI;IAGvD,UAAU,uBAAuB,CAAC,KAAK,EAAE,UAAU;QACjD,SAAS,CAAC,EAAE,UAAU,CAAA;QACtB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KACnB;IAED,MAAM,WAAW,0BAA0B,CAAC,KAAK,EAAE,UAAU;QAC3D,SAAS,CAAC,EAAE,UAAU,CAAA;QACtB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI,CAAA;QACnC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KACnB;CACF"}
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type DocumentNode } from 'graphql';
|
|
2
|
+
/**
|
|
3
|
+
* Given a query like the one below this function will return
|
|
4
|
+
* `FindBlogPostQuery`
|
|
5
|
+
*
|
|
6
|
+
* ```
|
|
7
|
+
* export const QUERY = gql`
|
|
8
|
+
* query FindBlogPostQuery($id: Int!) {
|
|
9
|
+
* blogPost: post(id: $id) {
|
|
10
|
+
* id
|
|
11
|
+
* title
|
|
12
|
+
* body
|
|
13
|
+
* createdAt
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
* `
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @param {DocumentNode} document
|
|
20
|
+
* graphql query or mutation to get the operation name for
|
|
21
|
+
* @returns {string} empty string if no operation name could be found
|
|
22
|
+
*/
|
|
23
|
+
export declare function getOperationName(document: DocumentNode): string;
|
|
24
|
+
//# sourceMappingURL=graphql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../src/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,YAAY,EAAE,MAAM,SAAS,CAAA;AAEjD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,UAWtD"}
|
package/dist/graphql.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Kind } from "graphql";
|
|
2
|
+
function getOperationName(document) {
|
|
3
|
+
for (const definition of document.definitions) {
|
|
4
|
+
if (definition.kind === Kind.OPERATION_DEFINITION && definition.name?.value) {
|
|
5
|
+
return definition.name.value;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return "";
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
getOperationName
|
|
12
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import './global.web-auto-imports.js';
|
|
2
|
+
import './config.js';
|
|
3
|
+
export { FatalErrorBoundary } from './components/FatalErrorBoundary.js';
|
|
4
|
+
export { FetchConfigProvider, useFetchConfig, } from './components/FetchConfigProvider.js';
|
|
5
|
+
export { GraphQLHooksProvider, useQuery, useMutation, useSubscription, } from './components/GraphQLHooksProvider.js';
|
|
6
|
+
export * from './components/cell/CellCacheContext.js';
|
|
7
|
+
export { createCell } from './components/cell/createCell.js';
|
|
8
|
+
export type { CellProps, CellFailureProps, CellLoadingProps, CellSuccessProps, CellSuccessData, } from './components/cell/cellTypes.js';
|
|
9
|
+
export * from './graphql.js';
|
|
10
|
+
export * from './components/RedwoodProvider.js';
|
|
11
|
+
export * from './components/MetaTags.js';
|
|
12
|
+
export * from './components/Metadata.js';
|
|
13
|
+
import * as helmetPkg from 'react-helmet-async';
|
|
14
|
+
declare const Helmet: typeof helmetPkg.Helmet;
|
|
15
|
+
export { Helmet as Head, Helmet };
|
|
16
|
+
export * from './components/htmlTags.js';
|
|
17
|
+
export * from './routeHooks.types.js';
|
|
18
|
+
export * from './components/ServerInject.js';
|
|
19
|
+
export type { TypedDocumentNode } from './components/GraphQLHooksProvider.js';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,8BAA8B,CAAA;AACrC,OAAO,aAAa,CAAA;AAEpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAA;AAEvE,OAAO,EACL,mBAAmB,EACnB,cAAc,GACf,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EACL,oBAAoB,EACpB,QAAQ,EACR,WAAW,EACX,eAAe,GAChB,MAAM,sCAAsC,CAAA;AAE7C,cAAc,uCAAuC,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAE5D,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,GAChB,MAAM,gCAAgC,CAAA;AAEvC,cAAc,cAAc,CAAA;AAE5B,cAAc,iCAAiC,CAAA;AAE/C,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAE/C,QAAA,MAAQ,MAAM,yBAAc,CAAA;AAC5B,OAAO,EAAE,MAAM,IAAI,IAAI,EAAE,MAAM,EAAE,CAAA;AAEjC,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AAErC,cAAc,8BAA8B,CAAA;AAE5C,YAAY,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import "./global.web-auto-imports.js";
|
|
2
|
+
import "./config.js";
|
|
3
|
+
import { FatalErrorBoundary } from "./components/FatalErrorBoundary.js";
|
|
4
|
+
import {
|
|
5
|
+
FetchConfigProvider,
|
|
6
|
+
useFetchConfig
|
|
7
|
+
} from "./components/FetchConfigProvider.js";
|
|
8
|
+
import {
|
|
9
|
+
GraphQLHooksProvider,
|
|
10
|
+
useQuery,
|
|
11
|
+
useMutation,
|
|
12
|
+
useSubscription
|
|
13
|
+
} from "./components/GraphQLHooksProvider.js";
|
|
14
|
+
export * from "./components/cell/CellCacheContext.js";
|
|
15
|
+
import { createCell } from "./components/cell/createCell.js";
|
|
16
|
+
export * from "./graphql.js";
|
|
17
|
+
export * from "./components/RedwoodProvider.js";
|
|
18
|
+
export * from "./components/MetaTags.js";
|
|
19
|
+
export * from "./components/Metadata.js";
|
|
20
|
+
import * as helmetPkg from "react-helmet-async";
|
|
21
|
+
const { Helmet } = helmetPkg;
|
|
22
|
+
export * from "./components/htmlTags.js";
|
|
23
|
+
export * from "./routeHooks.types.js";
|
|
24
|
+
export * from "./components/ServerInject.js";
|
|
25
|
+
export {
|
|
26
|
+
FatalErrorBoundary,
|
|
27
|
+
FetchConfigProvider,
|
|
28
|
+
GraphQLHooksProvider,
|
|
29
|
+
Helmet as Head,
|
|
30
|
+
Helmet,
|
|
31
|
+
createCell,
|
|
32
|
+
useFetchConfig,
|
|
33
|
+
useMutation,
|
|
34
|
+
useQuery,
|
|
35
|
+
useSubscription
|
|
36
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TagDescriptor } from './components/htmlTags.js';
|
|
2
|
+
export type RouteHookOutput = {
|
|
3
|
+
meta: TagDescriptor[];
|
|
4
|
+
};
|
|
5
|
+
export interface RouteHookEvent {
|
|
6
|
+
params: Record<string, string>;
|
|
7
|
+
headers: Headers;
|
|
8
|
+
query: Record<string, string | string[] | undefined>;
|
|
9
|
+
appRouteHook?: RouteHookOutput;
|
|
10
|
+
}
|
|
11
|
+
export type MetaHook = (event: RouteHookEvent) => Promise<TagDescriptor[] | TagDescriptor> | TagDescriptor[] | TagDescriptor;
|
|
12
|
+
//# sourceMappingURL=routeHooks.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routeHooks.types.d.ts","sourceRoot":"","sources":["../src/routeHooks.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAE7D,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,aAAa,EAAE,CAAA;CACtB,CAAA;AACD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9B,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAA;IAGpD,YAAY,CAAC,EAAE,eAAe,CAAA;CAC/B;AAED,MAAM,MAAM,QAAQ,GAAG,CACrB,KAAK,EAAE,cAAc,KAClB,OAAO,CAAC,aAAa,EAAE,GAAG,aAAa,CAAC,GAAG,aAAa,EAAE,GAAG,aAAa,CAAA"}
|
|
File without changes
|