@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,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
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
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var ServerInject_exports = {};
|
|
30
|
+
__export(ServerInject_exports, {
|
|
31
|
+
ServerHtmlContext: () => ServerHtmlContext,
|
|
32
|
+
ServerHtmlProvider: () => ServerHtmlProvider,
|
|
33
|
+
ServerInjectedHtml: () => ServerInjectedHtml,
|
|
34
|
+
createInjector: () => createInjector,
|
|
35
|
+
useServerInsertedHTML: () => useServerInsertedHTML
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(ServerInject_exports);
|
|
38
|
+
var import_react = __toESM(require("react"), 1);
|
|
39
|
+
const ServerHtmlContext = (0, import_react.createContext)(() => {
|
|
40
|
+
});
|
|
41
|
+
const createInjector = () => {
|
|
42
|
+
const injectionState = /* @__PURE__ */ new Set([]);
|
|
43
|
+
const injectToPage = (renderCallback) => {
|
|
44
|
+
injectionState.add(renderCallback);
|
|
45
|
+
};
|
|
46
|
+
return { injectToPage, injectionState };
|
|
47
|
+
};
|
|
48
|
+
const ServerHtmlProvider = ServerHtmlContext.Provider;
|
|
49
|
+
const ServerInjectedHtml = ({
|
|
50
|
+
injectionState
|
|
51
|
+
}) => {
|
|
52
|
+
const serverInsertedHtml = [];
|
|
53
|
+
for (const callback of injectionState) {
|
|
54
|
+
serverInsertedHtml.push(callback());
|
|
55
|
+
injectionState.delete(callback);
|
|
56
|
+
}
|
|
57
|
+
const fragmentId = (0, import_react.useId)();
|
|
58
|
+
return serverInsertedHtml.map((html, i) => {
|
|
59
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.Fragment, { key: `rw-server-inserted-${fragmentId}-${i}` }, html);
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
function useServerInsertedHTML(callback) {
|
|
63
|
+
const addInsertedServerHTMLCallback = (0, import_react.useContext)(ServerHtmlContext);
|
|
64
|
+
if (addInsertedServerHTMLCallback) {
|
|
65
|
+
addInsertedServerHTMLCallback(callback);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
+
0 && (module.exports = {
|
|
70
|
+
ServerHtmlContext,
|
|
71
|
+
ServerHtmlProvider,
|
|
72
|
+
ServerInjectedHtml,
|
|
73
|
+
createInjector,
|
|
74
|
+
useServerInsertedHTML
|
|
75
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DocumentNode } from 'graphql';
|
|
3
|
+
export interface QueryInfo {
|
|
4
|
+
query: DocumentNode;
|
|
5
|
+
variables?: Record<string, unknown>;
|
|
6
|
+
renderLoading?: boolean;
|
|
7
|
+
hasProcessed: boolean;
|
|
8
|
+
data?: unknown;
|
|
9
|
+
}
|
|
10
|
+
export interface CellCacheState {
|
|
11
|
+
queryCache: Record<string, QueryInfo | undefined>;
|
|
12
|
+
}
|
|
13
|
+
interface Props {
|
|
14
|
+
queryCache: Record<string, QueryInfo | undefined>;
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
}
|
|
17
|
+
export declare const CellCacheContextProvider: ({ queryCache, children }: Props) => React.JSX.Element;
|
|
18
|
+
export declare function useCellCacheContext(): CellCacheState;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=CellCacheContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CellCacheContext.d.ts","sourceRoot":"","sources":["../../../../src/components/cell/CellCacheContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAA;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE3C,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,YAAY,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,YAAY,EAAE,OAAO,CAAA;IACrB,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC,CAAA;CAClD;AAID,UAAU,KAAK;IACb,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC,CAAA;IACjD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B;AAED,eAAO,MAAM,wBAAwB,6BAA8B,KAAK,sBAMvE,CAAA;AAED,wBAAgB,mBAAmB,mBAUlC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
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
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var CellCacheContext_exports = {};
|
|
30
|
+
__export(CellCacheContext_exports, {
|
|
31
|
+
CellCacheContextProvider: () => CellCacheContextProvider,
|
|
32
|
+
useCellCacheContext: () => useCellCacheContext
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(CellCacheContext_exports);
|
|
35
|
+
var import_react = __toESM(require("react"), 1);
|
|
36
|
+
const CellCacheContext = (0, import_react.createContext)(void 0);
|
|
37
|
+
const CellCacheContextProvider = ({ queryCache, children }) => {
|
|
38
|
+
return /* @__PURE__ */ import_react.default.createElement(CellCacheContext.Provider, { value: { queryCache } }, children);
|
|
39
|
+
};
|
|
40
|
+
function useCellCacheContext() {
|
|
41
|
+
const context = (0, import_react.useContext)(CellCacheContext);
|
|
42
|
+
if (!context) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
"useCellCacheContext must be used within a CellCacheContextProvider"
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
return context;
|
|
48
|
+
}
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
CellCacheContextProvider,
|
|
52
|
+
useCellCacheContext
|
|
53
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { CellFailureProps } from './cellTypes.js';
|
|
3
|
+
export type FallbackProps = {
|
|
4
|
+
error: QueryOperationResult['error'];
|
|
5
|
+
resetErrorBoundary: () => void;
|
|
6
|
+
};
|
|
7
|
+
export type CellErrorBoundaryProps = {
|
|
8
|
+
renderFallback: (fbProps: FallbackProps) => React.ReactElement<CellFailureProps>;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
};
|
|
11
|
+
interface ErrState {
|
|
12
|
+
hasError: boolean;
|
|
13
|
+
error?: QueryOperationResult['error'];
|
|
14
|
+
}
|
|
15
|
+
export declare class CellErrorBoundary extends React.Component<CellErrorBoundaryProps, ErrState> {
|
|
16
|
+
constructor(props: CellErrorBoundaryProps);
|
|
17
|
+
static getDerivedStateFromError(error: Error): {
|
|
18
|
+
hasError: boolean;
|
|
19
|
+
error: Error;
|
|
20
|
+
};
|
|
21
|
+
componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
|
|
22
|
+
render(): React.ReactNode;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=CellErrorBoundary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CellErrorBoundary.d.ts","sourceRoot":"","sources":["../../../../src/components/cell/CellErrorBoundary.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEtD,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAA;IACpC,kBAAkB,EAAE,MAAM,IAAI,CAAA;CAC/B,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IAGnC,cAAc,EAAE,CACd,OAAO,EAAE,aAAa,KACnB,KAAK,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAA;IACzC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CAAA;AAED,UAAU,QAAQ;IAChB,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAA;CACtC;AAED,qBAAa,iBAAkB,SAAQ,KAAK,CAAC,SAAS,CACpD,sBAAsB,EACtB,QAAQ,CACT;gBACa,KAAK,EAAE,sBAAsB;IAKzC,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK;;;;IAI5C,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS;IAQ1D,MAAM;CAgBP"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var CellErrorBoundary_exports = {};
|
|
31
|
+
__export(CellErrorBoundary_exports, {
|
|
32
|
+
CellErrorBoundary: () => CellErrorBoundary
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(CellErrorBoundary_exports);
|
|
35
|
+
var import_react = __toESM(require("react"), 1);
|
|
36
|
+
class CellErrorBoundary extends import_react.default.Component {
|
|
37
|
+
constructor(props) {
|
|
38
|
+
super(props);
|
|
39
|
+
this.state = { hasError: false };
|
|
40
|
+
}
|
|
41
|
+
static getDerivedStateFromError(error) {
|
|
42
|
+
return { hasError: true, error };
|
|
43
|
+
}
|
|
44
|
+
componentDidCatch(error, errorInfo) {
|
|
45
|
+
console.log("Cell failure: ", {
|
|
46
|
+
error,
|
|
47
|
+
errorInfo
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
render() {
|
|
51
|
+
const { renderFallback } = this.props;
|
|
52
|
+
if (this.state.hasError) {
|
|
53
|
+
return renderFallback({
|
|
54
|
+
error: this.state.error,
|
|
55
|
+
resetErrorBoundary: () => {
|
|
56
|
+
this.setState({ hasError: false, error: void 0 });
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return this.props.children;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
CellErrorBoundary
|
|
66
|
+
});
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { ComponentProps, JSXElementConstructor } from 'react';
|
|
2
|
+
import type { ApolloClient, NetworkStatus, OperationVariables, QueryRef, UseBackgroundQueryResult } from '@apollo/client';
|
|
3
|
+
import type { DocumentNode } from 'graphql';
|
|
4
|
+
import type { A, L, O, U } from 'ts-toolbelt';
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* If the Cell has a `beforeQuery` function, then the variables are not required,
|
|
8
|
+
* but instead the arguments of the `beforeQuery` function are required.
|
|
9
|
+
*
|
|
10
|
+
* If the Cell does not have a `beforeQuery` function, then the variables are required.
|
|
11
|
+
*
|
|
12
|
+
* Note that a query that doesn't take any variables is defined as {[x: string]: never}
|
|
13
|
+
* The ternary at the end makes sure we don't include it, otherwise it won't allow merging any
|
|
14
|
+
* other custom props from the Success component.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
type CellPropsVariables<Cell, GQLVariables> = Cell extends {
|
|
18
|
+
beforeQuery: (...args: any[]) => any;
|
|
19
|
+
} ? Parameters<Cell['beforeQuery']>[0] extends unknown ? Record<string, unknown> : Parameters<Cell['beforeQuery']>[0] : GQLVariables extends Record<string, never> ? unknown : GQLVariables;
|
|
20
|
+
/**
|
|
21
|
+
* Cell component props which is the combination of query variables and Success props.
|
|
22
|
+
*/
|
|
23
|
+
export type CellProps<CellSuccess extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>, GQLResult, CellType, GQLVariables> = A.Compute<Omit<ComponentProps<CellSuccess>, keyof CellPropsVariables<CellType, GQLVariables> | keyof GQLResult | 'updating' | 'queryResult'> & CellPropsVariables<CellType, GQLVariables>>;
|
|
24
|
+
type InputVarProps<T> = T extends {
|
|
25
|
+
[key: string]: never;
|
|
26
|
+
} ? unknown : T;
|
|
27
|
+
export type CellLoadingProps<TVariables extends OperationVariables = any> = {
|
|
28
|
+
queryResult?: NonSuspenseCellQueryResult<TVariables, any> | SuspenseCellQueryResult;
|
|
29
|
+
} & InputVarProps<TVariables>;
|
|
30
|
+
export type CellFailureProps<TVariables extends OperationVariables = any> = {
|
|
31
|
+
queryResult?: NonSuspenseCellQueryResult<TVariables, any> | SuspenseCellQueryResult;
|
|
32
|
+
error?: QueryOperationResult['error'] | Error;
|
|
33
|
+
/**
|
|
34
|
+
* @see {@link https://www.apollographql.com/docs/apollo-server/data/errors/#error-codes}
|
|
35
|
+
*/
|
|
36
|
+
errorCode?: string;
|
|
37
|
+
updating?: boolean;
|
|
38
|
+
} & InputVarProps<TVariables>;
|
|
39
|
+
type Guaranteed<T> = {
|
|
40
|
+
[K in keyof T]-?: NonNullable<T[K]>;
|
|
41
|
+
};
|
|
42
|
+
type KeyCount<T extends object> = L.Length<U.ListOf<O.SelectKeys<T, any>>>;
|
|
43
|
+
type ConditionallyGuaranteed<T extends object> = KeyCount<T> extends 1 ? Guaranteed<T> : T;
|
|
44
|
+
/**
|
|
45
|
+
* @params TData = Type of data based on your graphql query. This can be imported from 'types/graphql'
|
|
46
|
+
* @example
|
|
47
|
+
* import type { FindPosts } from 'types/graphql'
|
|
48
|
+
*
|
|
49
|
+
* const { post }: CellSuccessData<FindPosts> = props
|
|
50
|
+
*/
|
|
51
|
+
export type CellSuccessData<TData = any> = ConditionallyGuaranteed<Omit<TData, '__typename'>>;
|
|
52
|
+
/**
|
|
53
|
+
* @MARK not sure about this partial, but we need to do this for tests and storybook.
|
|
54
|
+
*
|
|
55
|
+
* `updating` is just `loading` renamed; since Cells default to stale-while-refetch,
|
|
56
|
+
* this prop lets users render something like a spinner to show that a request is in-flight.
|
|
57
|
+
*/
|
|
58
|
+
export type CellSuccessProps<TData = any, TVariables extends OperationVariables = any> = {
|
|
59
|
+
queryResult?: NonSuspenseCellQueryResult<TVariables, TData> | SuspenseCellQueryResult;
|
|
60
|
+
updating?: boolean;
|
|
61
|
+
} & InputVarProps<TVariables> & A.Compute<CellSuccessData<TData>>;
|
|
62
|
+
/**
|
|
63
|
+
* A coarse type for the `data` prop returned by `useQuery`.
|
|
64
|
+
*
|
|
65
|
+
* ```js
|
|
66
|
+
* {
|
|
67
|
+
* data: {
|
|
68
|
+
* post: { ... }
|
|
69
|
+
* }
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export type DataObject = {
|
|
74
|
+
[key: string]: unknown;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* The main interface.
|
|
78
|
+
*/
|
|
79
|
+
export interface CreateCellProps<CellProps, CellVariables> {
|
|
80
|
+
/**
|
|
81
|
+
* The GraphQL syntax tree to execute or function to call that returns it.
|
|
82
|
+
* If `QUERY` is a function, it's called with the result of `beforeQuery`.
|
|
83
|
+
*/
|
|
84
|
+
QUERY: DocumentNode | ((variables: Record<string, unknown>) => DocumentNode);
|
|
85
|
+
/**
|
|
86
|
+
* Parse `props` into query variables. Most of the time `props` are appropriate variables as is.
|
|
87
|
+
*/
|
|
88
|
+
beforeQuery?: ((props: CellProps) => {
|
|
89
|
+
variables: CellVariables;
|
|
90
|
+
}) | (() => {
|
|
91
|
+
variables: CellVariables;
|
|
92
|
+
});
|
|
93
|
+
/**
|
|
94
|
+
* Sanitize the data returned from the query.
|
|
95
|
+
*/
|
|
96
|
+
afterQuery?: (data: DataObject) => DataObject;
|
|
97
|
+
/**
|
|
98
|
+
* How to decide if the result of a query should render the `Empty` component.
|
|
99
|
+
* The default implementation checks that the first field isn't `null` or an empty array.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
*
|
|
103
|
+
* In the example below, only `users` is checked:
|
|
104
|
+
*
|
|
105
|
+
* ```js
|
|
106
|
+
* export const QUERY = gql`
|
|
107
|
+
* users {
|
|
108
|
+
* name
|
|
109
|
+
* }
|
|
110
|
+
* posts {
|
|
111
|
+
* title
|
|
112
|
+
* }
|
|
113
|
+
* `
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
isEmpty?: (response: DataObject, options: {
|
|
117
|
+
isDataEmpty: (data: DataObject) => boolean;
|
|
118
|
+
}) => boolean;
|
|
119
|
+
/**
|
|
120
|
+
* If the query's in flight and there's no stale data, render this.
|
|
121
|
+
*/
|
|
122
|
+
Loading?: React.FC<CellLoadingProps & Partial<CellProps>>;
|
|
123
|
+
/**
|
|
124
|
+
* If something went wrong, render this.
|
|
125
|
+
*/
|
|
126
|
+
Failure?: React.FC<CellFailureProps & Partial<CellProps>>;
|
|
127
|
+
/**
|
|
128
|
+
* If no data was returned, render this.
|
|
129
|
+
*/
|
|
130
|
+
Empty?: React.FC<CellSuccessProps & Partial<CellProps>>;
|
|
131
|
+
/**
|
|
132
|
+
* If data was returned, render this.
|
|
133
|
+
*/
|
|
134
|
+
Success: React.FC<CellSuccessProps & Partial<CellProps>>;
|
|
135
|
+
/**
|
|
136
|
+
* What to call the Cell. Defaults to the filename.
|
|
137
|
+
*/
|
|
138
|
+
displayName?: string;
|
|
139
|
+
}
|
|
140
|
+
export type SuspendingSuccessProps = React.PropsWithChildren<Record<string, unknown>> & {
|
|
141
|
+
queryRef: QueryRef<DataObject>;
|
|
142
|
+
suspenseQueryResult: SuspenseCellQueryResult<DataObject, any>;
|
|
143
|
+
userProps: Record<string, any>;
|
|
144
|
+
};
|
|
145
|
+
export type NonSuspenseCellQueryResult<TVariables extends OperationVariables = any, TData = any> = Partial<Omit<QueryOperationResult<TData, TVariables>, 'loading' | 'error' | 'data'>>;
|
|
146
|
+
export interface SuspenseCellQueryResult<_TData = any, _TVariables extends OperationVariables = any> extends UseBackgroundQueryResult {
|
|
147
|
+
client: ApolloClient<any>;
|
|
148
|
+
networkStatus?: NetworkStatus;
|
|
149
|
+
called: boolean;
|
|
150
|
+
}
|
|
151
|
+
export {};
|
|
152
|
+
//# sourceMappingURL=cellTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cellTypes.d.ts","sourceRoot":"","sources":["../../../../src/components/cell/cellTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAA;AAElE,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,QAAQ,EACR,wBAAwB,EACzB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,aAAa,CAAA;AAE7C;;;;;;;;;;;GAWG;AACH,KAAK,kBAAkB,CAAC,IAAI,EAAE,YAAY,IAAI,IAAI,SAAS;IACzD,WAAW,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;CACrC,GACG,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,OAAO,GAChD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACvB,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,GACpC,YAAY,SAAS,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GACxC,OAAO,GACP,YAAY,CAAA;AAClB;;GAEG;AAEH,MAAM,MAAM,S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B,CACtC,MAAM,GAAG,GAAG,EACZ,WAAW,SAAS,kBAAkB,GAAG,GAAG,CAC5C,SAAQ,wBAAwB;IAChC,MAAM,EAAE,YAAY,CAAC,GAAG,CAAC,CAAA;IAEzB,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B,MAAM,EAAE,OAAO,CAAA;CAChB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var cellTypes_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(cellTypes_exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { CreateCellProps } from './cellTypes.js';
|
|
3
|
+
import { createSuspendingCell } from './createSuspendingCell.js';
|
|
4
|
+
export declare const createCell: typeof createSuspendingCell | typeof createNonSuspendingCell;
|
|
5
|
+
/**
|
|
6
|
+
* Creates a Cell out of a GraphQL query and components that track to its lifecycle.
|
|
7
|
+
*/
|
|
8
|
+
declare function createNonSuspendingCell<CellProps extends Record<string, unknown>, CellVariables extends Record<string, unknown>>({ QUERY, beforeQuery, afterQuery, isEmpty, Loading, Failure, Empty, Success, displayName, }: CreateCellProps<CellProps, CellVariables>): React.FC<CellProps>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=createCell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createCell.d.ts","sourceRoot":"","sources":["../../../../src/components/cell/createCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAUzB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAIhE,eAAO,MAAM,UAAU,8DAEI,CAAA;AAE3B;;GAEG;AACH,iBAAS,uBAAuB,CAC9B,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7C,EACA,KAAK,EACL,WAWE,EACF,UAA2B,EAC3B,OAAqB,EACrB,OAA+B,EAC/B,OAAO,EACP,KAAK,EACL,OAAO,EACP,WAAoB,GACrB,EAAE,eAAe,CAAC,SAAS,EAAE,aAAa,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC,CAuIjE"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
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
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var createCell_exports = {};
|
|
30
|
+
__export(createCell_exports, {
|
|
31
|
+
createCell: () => createCell
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(createCell_exports);
|
|
34
|
+
var import_react = __toESM(require("react"), 1);
|
|
35
|
+
var import_fragmentRegistry = require("../../apollo/fragmentRegistry.js");
|
|
36
|
+
var import_graphql = require("../../graphql.js");
|
|
37
|
+
var import_GraphQLHooksProvider = require("../GraphQLHooksProvider.js");
|
|
38
|
+
var import_CellCacheContext = require("./CellCacheContext.js");
|
|
39
|
+
var import_createSuspendingCell = require("./createSuspendingCell.js");
|
|
40
|
+
var import_isCellEmpty = require("./isCellEmpty.js");
|
|
41
|
+
const createCell = RWJS_ENV.RWJS_EXP_STREAMING_SSR ? import_createSuspendingCell.createSuspendingCell : createNonSuspendingCell;
|
|
42
|
+
function createNonSuspendingCell({
|
|
43
|
+
QUERY,
|
|
44
|
+
beforeQuery = (props) => ({
|
|
45
|
+
// By default, we assume that the props are the gql-variables.
|
|
46
|
+
variables: props,
|
|
47
|
+
/**
|
|
48
|
+
* We're duplicating these props here due to a suspected bug in Apollo Client v3.5.4
|
|
49
|
+
* (it doesn't seem to be respecting `defaultOptions` in `RedwoodApolloProvider`.)
|
|
50
|
+
*
|
|
51
|
+
* @see {@link https://github.com/apollographql/apollo-client/issues/9105}
|
|
52
|
+
*/
|
|
53
|
+
fetchPolicy: "cache-and-network",
|
|
54
|
+
notifyOnNetworkStatusChange: true
|
|
55
|
+
}),
|
|
56
|
+
afterQuery = (data) => data,
|
|
57
|
+
isEmpty = import_isCellEmpty.isDataEmpty,
|
|
58
|
+
Loading = () => /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, "Loading..."),
|
|
59
|
+
Failure,
|
|
60
|
+
Empty,
|
|
61
|
+
Success,
|
|
62
|
+
displayName = "Cell"
|
|
63
|
+
}) {
|
|
64
|
+
function NamedCell(props) {
|
|
65
|
+
const { children: _, ...variables } = props;
|
|
66
|
+
const options = beforeQuery(variables);
|
|
67
|
+
const query = typeof QUERY === "function" ? QUERY(options) : QUERY;
|
|
68
|
+
let {
|
|
69
|
+
// eslint-disable-next-line prefer-const
|
|
70
|
+
error,
|
|
71
|
+
loading,
|
|
72
|
+
data,
|
|
73
|
+
...queryResult
|
|
74
|
+
} = (0, import_GraphQLHooksProvider.useQuery)(query, options);
|
|
75
|
+
if (globalThis.__REDWOOD__PRERENDERING) {
|
|
76
|
+
const { queryCache } = (0, import_CellCacheContext.useCellCacheContext)();
|
|
77
|
+
const operationName = (0, import_graphql.getOperationName)(query);
|
|
78
|
+
const transformedQuery = import_fragmentRegistry.fragmentRegistry.transform(query);
|
|
79
|
+
let cacheKey;
|
|
80
|
+
if (operationName) {
|
|
81
|
+
cacheKey = operationName + "_" + JSON.stringify(variables);
|
|
82
|
+
} else {
|
|
83
|
+
const cellName = displayName === "Cell" ? "the cell" : displayName;
|
|
84
|
+
throw new Error(
|
|
85
|
+
`The gql query in ${cellName} is missing an operation name. Something like FindBlogPostQuery in \`query FindBlogPostQuery($id: Int!)\``
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
const queryInfo = queryCache[cacheKey];
|
|
89
|
+
if (queryInfo?.renderLoading) {
|
|
90
|
+
loading = true;
|
|
91
|
+
} else {
|
|
92
|
+
if (queryInfo?.hasProcessed) {
|
|
93
|
+
loading = false;
|
|
94
|
+
data = queryInfo.data;
|
|
95
|
+
queryResult = { variables };
|
|
96
|
+
} else {
|
|
97
|
+
queryCache[cacheKey] ||= {
|
|
98
|
+
query: transformedQuery,
|
|
99
|
+
variables: options.variables,
|
|
100
|
+
hasProcessed: false
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (error) {
|
|
106
|
+
if (Failure) {
|
|
107
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
108
|
+
Failure,
|
|
109
|
+
{
|
|
110
|
+
error,
|
|
111
|
+
errorCode: (
|
|
112
|
+
// Use the ad-hoc QueryResultWithErrorCode type to access the errorCode
|
|
113
|
+
queryResult.errorCode ?? error.graphQLErrors?.[0]?.extensions?.["code"]
|
|
114
|
+
),
|
|
115
|
+
...props,
|
|
116
|
+
updating: loading,
|
|
117
|
+
queryResult
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
} else {
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
} else if (data) {
|
|
124
|
+
const afterQueryData = afterQuery(data);
|
|
125
|
+
if (isEmpty(data, { isDataEmpty: import_isCellEmpty.isDataEmpty }) && Empty) {
|
|
126
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
127
|
+
Empty,
|
|
128
|
+
{
|
|
129
|
+
...props,
|
|
130
|
+
...afterQueryData,
|
|
131
|
+
updating: loading,
|
|
132
|
+
queryResult
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
} else {
|
|
136
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
137
|
+
Success,
|
|
138
|
+
{
|
|
139
|
+
...props,
|
|
140
|
+
...afterQueryData,
|
|
141
|
+
updating: loading,
|
|
142
|
+
queryResult
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
} else if (loading) {
|
|
147
|
+
return /* @__PURE__ */ import_react.default.createElement(Loading, { ...props, queryResult });
|
|
148
|
+
} else {
|
|
149
|
+
console.warn(
|
|
150
|
+
`If you're using Apollo Client, check for its debug logs here in the console, which may help explain the error.`
|
|
151
|
+
);
|
|
152
|
+
throw new Error(
|
|
153
|
+
"Cannot render Cell: reached an unexpected state where the query succeeded but `data` is `null`. If this happened in Storybook, your query could be missing fields; otherwise this is most likely a GraphQL caching bug. Note that adding an `id` field to all the fields on your query may fix the issue."
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
NamedCell.displayName = displayName;
|
|
158
|
+
return (props) => {
|
|
159
|
+
return /* @__PURE__ */ import_react.default.createElement(NamedCell, { ...props });
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
163
|
+
0 && (module.exports = {
|
|
164
|
+
createCell
|
|
165
|
+
});
|