@cedarjs/web 5.0.6 → 5.0.7-next.219

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.
Files changed (188) hide show
  1. package/dist/apollo/ApolloProviderWithFetchConfig.d.ts +15 -0
  2. package/dist/apollo/ApolloProviderWithFetchConfig.d.ts.map +1 -0
  3. package/dist/apollo/ApolloProviderWithFetchConfig.js +134 -0
  4. package/dist/apollo/CedarApolloProvider.d.ts +14 -0
  5. package/dist/apollo/CedarApolloProvider.d.ts.map +1 -0
  6. package/dist/apollo/CedarApolloProvider.js +35 -0
  7. package/dist/apollo/ErrorBoundary.d.ts +13 -0
  8. package/dist/apollo/ErrorBoundary.d.ts.map +1 -0
  9. package/dist/apollo/ErrorBoundary.js +13 -0
  10. package/dist/{cjs/apollo/suspense.d.ts → apollo/apolloLinkTypes.d.ts} +22 -22
  11. package/dist/apollo/apolloLinkTypes.d.ts.map +1 -0
  12. package/dist/apollo/fragmentRegistry.d.ts +25 -0
  13. package/dist/apollo/fragmentRegistry.d.ts.map +1 -1
  14. package/dist/apollo/fragmentRegistry.js +19 -1
  15. package/dist/apollo/index.d.ts +50 -70
  16. package/dist/apollo/index.d.ts.map +1 -1
  17. package/dist/apollo/index.js +2 -184
  18. package/dist/apollo/suspense.d.ts +16 -7
  19. package/dist/apollo/suspense.d.ts.map +1 -1
  20. package/dist/apollo/suspense.js +9 -26
  21. package/dist/bins/cedar.js +14 -0
  22. package/dist/bins/cfw.js +14 -0
  23. package/dist/bins/cross-env.js +8 -0
  24. package/dist/bins/msw.js +6 -0
  25. package/dist/bins/redwood.js +14 -0
  26. package/dist/bins/storybook.js +27 -0
  27. package/dist/bins/tsc.js +8 -0
  28. package/dist/bundled/apollo-upload-client.js +2899 -1
  29. package/dist/components/FetchConfigProvider.d.ts +3 -2
  30. package/dist/components/FetchConfigProvider.d.ts.map +1 -1
  31. package/dist/components/cell/CellErrorBoundary.d.ts +3 -2
  32. package/dist/components/cell/CellErrorBoundary.d.ts.map +1 -1
  33. package/dist/components/cell/cellTypes.d.ts +17 -4
  34. package/dist/components/cell/cellTypes.d.ts.map +1 -1
  35. package/dist/components/cell/createCell.d.ts +1 -7
  36. package/dist/components/cell/createCell.d.ts.map +1 -1
  37. package/dist/components/cell/createCell.js +22 -3
  38. package/dist/components/cell/createFragmentCell.d.ts +19 -0
  39. package/dist/components/cell/createFragmentCell.d.ts.map +1 -0
  40. package/dist/components/cell/createFragmentCell.js +73 -0
  41. package/dist/components/cell/createSuspendingCell.d.ts.map +1 -1
  42. package/dist/components/cell/createSuspendingCell.js +12 -3
  43. package/dist/global.web-auto-imports.d.ts +0 -16
  44. package/dist/global.web-auto-imports.d.ts.map +1 -1
  45. package/dist/index.d.ts +5 -2
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +5 -3
  48. package/package.json +48 -106
  49. package/dist/apollo/typeOverride.d.ts +0 -21
  50. package/dist/apollo/typeOverride.d.ts.map +0 -1
  51. package/dist/cjs/apollo/fragmentRegistry.d.ts +0 -43
  52. package/dist/cjs/apollo/fragmentRegistry.d.ts.map +0 -1
  53. package/dist/cjs/apollo/fragmentRegistry.js +0 -75
  54. package/dist/cjs/apollo/index.d.ts +0 -76
  55. package/dist/cjs/apollo/index.d.ts.map +0 -1
  56. package/dist/cjs/apollo/index.js +0 -218
  57. package/dist/cjs/apollo/links.d.ts +0 -27
  58. package/dist/cjs/apollo/links.d.ts.map +0 -1
  59. package/dist/cjs/apollo/links.js +0 -122
  60. package/dist/cjs/apollo/sseLink.d.ts +0 -29
  61. package/dist/cjs/apollo/sseLink.d.ts.map +0 -1
  62. package/dist/cjs/apollo/sseLink.js +0 -120
  63. package/dist/cjs/apollo/suspense.d.ts.map +0 -1
  64. package/dist/cjs/apollo/suspense.js +0 -127
  65. package/dist/cjs/apollo/typeOverride.d.ts +0 -21
  66. package/dist/cjs/apollo/typeOverride.d.ts.map +0 -1
  67. package/dist/cjs/apollo/typeOverride.js +0 -16
  68. package/dist/cjs/apollo/useCache.d.ts +0 -22
  69. package/dist/cjs/apollo/useCache.d.ts.map +0 -1
  70. package/dist/cjs/apollo/useCache.js +0 -49
  71. package/dist/cjs/bins/cedar.d.ts +0 -9
  72. package/dist/cjs/bins/cedar.d.ts.map +0 -1
  73. package/dist/cjs/bins/cedar.js +0 -36
  74. package/dist/cjs/bins/cfw.d.ts +0 -3
  75. package/dist/cjs/bins/cfw.d.ts.map +0 -1
  76. package/dist/cjs/bins/cfw.js +0 -36
  77. package/dist/cjs/bins/cross-env.d.ts +0 -3
  78. package/dist/cjs/bins/cross-env.d.ts.map +0 -1
  79. package/dist/cjs/bins/cross-env.js +0 -30
  80. package/dist/cjs/bins/msw.d.ts +0 -3
  81. package/dist/cjs/bins/msw.d.ts.map +0 -1
  82. package/dist/cjs/bins/msw.js +0 -28
  83. package/dist/cjs/bins/redwood.d.ts +0 -9
  84. package/dist/cjs/bins/redwood.d.ts.map +0 -1
  85. package/dist/cjs/bins/redwood.js +0 -36
  86. package/dist/cjs/bins/storybook.d.ts +0 -3
  87. package/dist/cjs/bins/storybook.d.ts.map +0 -1
  88. package/dist/cjs/bins/storybook.js +0 -49
  89. package/dist/cjs/bins/tsc.d.ts +0 -3
  90. package/dist/cjs/bins/tsc.d.ts.map +0 -1
  91. package/dist/cjs/bins/tsc.js +0 -30
  92. package/dist/cjs/bundled/apollo-upload-client.d.ts +0 -3
  93. package/dist/cjs/bundled/apollo-upload-client.d.ts.map +0 -1
  94. package/dist/cjs/bundled/apollo-upload-client.js +0 -2925
  95. package/dist/cjs/components/DevFatalErrorPage.d.ts +0 -21
  96. package/dist/cjs/components/DevFatalErrorPage.d.ts.map +0 -1
  97. package/dist/cjs/components/DevFatalErrorPage.js +0 -552
  98. package/dist/cjs/components/FatalErrorBoundary.d.ts +0 -24
  99. package/dist/cjs/components/FatalErrorBoundary.d.ts.map +0 -1
  100. package/dist/cjs/components/FatalErrorBoundary.js +0 -63
  101. package/dist/cjs/components/FetchConfigProvider.d.ts +0 -25
  102. package/dist/cjs/components/FetchConfigProvider.d.ts.map +0 -1
  103. package/dist/cjs/components/FetchConfigProvider.js +0 -80
  104. package/dist/cjs/components/GraphQLHooksProvider.d.ts +0 -45
  105. package/dist/cjs/components/GraphQLHooksProvider.d.ts.map +0 -1
  106. package/dist/cjs/components/GraphQLHooksProvider.js +0 -135
  107. package/dist/cjs/components/MetaTags.d.ts +0 -52
  108. package/dist/cjs/components/MetaTags.d.ts.map +0 -1
  109. package/dist/cjs/components/MetaTags.js +0 -68
  110. package/dist/cjs/components/Metadata.d.ts +0 -9
  111. package/dist/cjs/components/Metadata.d.ts.map +0 -1
  112. package/dist/cjs/components/Metadata.js +0 -94
  113. package/dist/cjs/components/PortalHead.d.ts +0 -4
  114. package/dist/cjs/components/PortalHead.d.ts.map +0 -1
  115. package/dist/cjs/components/PortalHead.js +0 -59
  116. package/dist/cjs/components/RedwoodProvider.d.ts +0 -9
  117. package/dist/cjs/components/RedwoodProvider.d.ts.map +0 -1
  118. package/dist/cjs/components/RedwoodProvider.js +0 -57
  119. package/dist/cjs/components/ServerInject.d.ts +0 -26
  120. package/dist/cjs/components/ServerInject.d.ts.map +0 -1
  121. package/dist/cjs/components/ServerInject.js +0 -75
  122. package/dist/cjs/components/cell/CellCacheContext.d.ts +0 -20
  123. package/dist/cjs/components/cell/CellCacheContext.d.ts.map +0 -1
  124. package/dist/cjs/components/cell/CellCacheContext.js +0 -53
  125. package/dist/cjs/components/cell/CellErrorBoundary.d.ts +0 -25
  126. package/dist/cjs/components/cell/CellErrorBoundary.d.ts.map +0 -1
  127. package/dist/cjs/components/cell/CellErrorBoundary.js +0 -66
  128. package/dist/cjs/components/cell/cellTypes.d.ts +0 -152
  129. package/dist/cjs/components/cell/cellTypes.d.ts.map +0 -1
  130. package/dist/cjs/components/cell/cellTypes.js +0 -16
  131. package/dist/cjs/components/cell/createCell.d.ts +0 -10
  132. package/dist/cjs/components/cell/createCell.d.ts.map +0 -1
  133. package/dist/cjs/components/cell/createCell.js +0 -165
  134. package/dist/cjs/components/cell/createCell.test.js +0 -351
  135. package/dist/cjs/components/cell/createServerCell.d.ts +0 -15
  136. package/dist/cjs/components/cell/createServerCell.d.ts.map +0 -1
  137. package/dist/cjs/components/cell/createServerCell.js +0 -91
  138. package/dist/cjs/components/cell/createSuspendingCell.d.ts +0 -11
  139. package/dist/cjs/components/cell/createSuspendingCell.d.ts.map +0 -1
  140. package/dist/cjs/components/cell/createSuspendingCell.js +0 -152
  141. package/dist/cjs/components/cell/createSuspendingCell.test.js +0 -115
  142. package/dist/cjs/components/cell/isCellEmpty.d.ts +0 -41
  143. package/dist/cjs/components/cell/isCellEmpty.d.ts.map +0 -1
  144. package/dist/cjs/components/cell/isCellEmpty.js +0 -35
  145. package/dist/cjs/components/htmlTags.d.ts +0 -52
  146. package/dist/cjs/components/htmlTags.d.ts.map +0 -1
  147. package/dist/cjs/components/htmlTags.js +0 -88
  148. package/dist/cjs/config.d.ts +0 -2
  149. package/dist/cjs/config.d.ts.map +0 -1
  150. package/dist/cjs/config.js +0 -6
  151. package/dist/cjs/global.web-auto-imports.d.ts +0 -30
  152. package/dist/cjs/global.web-auto-imports.d.ts.map +0 -1
  153. package/dist/cjs/global.web-auto-imports.js +0 -16
  154. package/dist/cjs/graphql.d.ts +0 -23
  155. package/dist/cjs/graphql.d.ts.map +0 -1
  156. package/dist/cjs/graphql.js +0 -36
  157. package/dist/cjs/index.d.ts +0 -19
  158. package/dist/cjs/index.d.ts.map +0 -1
  159. package/dist/cjs/index.js +0 -69
  160. package/dist/cjs/package.json +0 -1
  161. package/dist/cjs/routeHooks.types.d.ts +0 -12
  162. package/dist/cjs/routeHooks.types.d.ts.map +0 -1
  163. package/dist/cjs/routeHooks.types.js +0 -16
  164. package/dist/cjs/server/MiddlewareRequest.d.ts +0 -28
  165. package/dist/cjs/server/MiddlewareRequest.d.ts.map +0 -1
  166. package/dist/cjs/server/MiddlewareRequest.js +0 -71
  167. package/dist/cjs/server/MiddlewareResponse.d.ts +0 -44
  168. package/dist/cjs/server/MiddlewareResponse.d.ts.map +0 -1
  169. package/dist/cjs/server/MiddlewareResponse.js +0 -130
  170. package/dist/cjs/server/middleware.d.ts +0 -17
  171. package/dist/cjs/server/middleware.d.ts.map +0 -1
  172. package/dist/cjs/server/middleware.js +0 -24
  173. package/dist/cjs/server/request.d.ts +0 -2
  174. package/dist/cjs/server/request.d.ts.map +0 -1
  175. package/dist/cjs/server/request.js +0 -34
  176. package/dist/cjs/streamUtils/useDocumentReady.d.ts +0 -11
  177. package/dist/cjs/streamUtils/useDocumentReady.d.ts.map +0 -1
  178. package/dist/cjs/streamUtils/useDocumentReady.js +0 -41
  179. package/dist/cjs/toast/index.d.ts +0 -3
  180. package/dist/cjs/toast/index.d.ts.map +0 -1
  181. package/dist/cjs/toast/index.js +0 -41
  182. package/dist/components/GraphQLHooksProvider.d.ts +0 -45
  183. package/dist/components/GraphQLHooksProvider.d.ts.map +0 -1
  184. package/dist/components/GraphQLHooksProvider.js +0 -94
  185. package/dist/components/cell/createCell.test.js +0 -328
  186. package/dist/components/cell/createSuspendingCell.test.js +0 -92
  187. package/dist/package.json +0 -1
  188. /package/dist/apollo/{typeOverride.js → apolloLinkTypes.js} +0 -0
@@ -1,152 +0,0 @@
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 createSuspendingCell_exports = {};
30
- __export(createSuspendingCell_exports, {
31
- createSuspendingCell: () => createSuspendingCell
32
- });
33
- module.exports = __toCommonJS(createSuspendingCell_exports);
34
- var import_react = __toESM(require("react"), 1);
35
- var import_hooks = require("@apollo/client/react/hooks/hooks.cjs");
36
- var import_GraphQLHooksProvider = require("../GraphQLHooksProvider.js");
37
- var import_CellErrorBoundary = require("./CellErrorBoundary.js");
38
- var import_isCellEmpty = require("./isCellEmpty.js");
39
- function createSuspendingCell(createCellProps) {
40
- const {
41
- QUERY,
42
- beforeQuery = (props) => ({
43
- // By default, we assume that the props are the gql-variables.
44
- variables: props,
45
- /**
46
- * We're duplicating these props here due to a suspected bug in Apollo Client v3.5.4
47
- * (it doesn't seem to be respecting `defaultOptions` in `RedwoodApolloProvider`.)
48
- *
49
- * @see {@link https://github.com/apollographql/apollo-client/issues/9105}
50
- */
51
- fetchPolicy: "cache-and-network",
52
- notifyOnNetworkStatusChange: true
53
- }),
54
- afterQuery = (data) => ({ ...data }),
55
- isEmpty = import_isCellEmpty.isDataEmpty,
56
- Loading,
57
- Failure,
58
- Empty,
59
- Success,
60
- displayName = "Cell"
61
- } = createCellProps;
62
- function SuspendingSuccess(props) {
63
- const { queryRef, suspenseQueryResult, userProps } = props;
64
- const { data, networkStatus } = (0, import_GraphQLHooksProvider.useReadQuery)(queryRef);
65
- const afterQueryData = afterQuery(data);
66
- const queryResultWithNetworkStatus = {
67
- ...suspenseQueryResult,
68
- networkStatus
69
- };
70
- if (isEmpty(data, { isDataEmpty: import_isCellEmpty.isDataEmpty }) && Empty) {
71
- return /* @__PURE__ */ import_react.default.createElement(
72
- Empty,
73
- {
74
- ...userProps,
75
- ...afterQueryData,
76
- queryResult: queryResultWithNetworkStatus
77
- }
78
- );
79
- }
80
- return /* @__PURE__ */ import_react.default.createElement(
81
- Success,
82
- {
83
- ...afterQueryData,
84
- ...userProps,
85
- queryResult: queryResultWithNetworkStatus
86
- }
87
- );
88
- }
89
- SuspendingSuccess.displayName = displayName;
90
- return (props) => {
91
- const { children: _, ...variables } = props;
92
- const options = beforeQuery(variables);
93
- const query = typeof QUERY === "function" ? QUERY(options) : QUERY;
94
- const [queryRef, other] = (0, import_GraphQLHooksProvider.useBackgroundQuery)(query, options);
95
- const client = (0, import_hooks.useApolloClient)();
96
- const suspenseQueryResult = {
97
- client,
98
- ...other,
99
- called: !!queryRef
100
- };
101
- const FailureComponent = ({ error, resetErrorBoundary }) => {
102
- if (!Failure) {
103
- if (error) {
104
- throw error;
105
- }
106
- throw new Error("Unreachable code: FailureComponent without a Failure");
107
- }
108
- const queryResultWithErrorReset = {
109
- ...suspenseQueryResult,
110
- refetch: (variables2) => {
111
- resetErrorBoundary();
112
- return suspenseQueryResult.refetch?.(variables2);
113
- }
114
- };
115
- return /* @__PURE__ */ import_react.default.createElement(
116
- Failure,
117
- {
118
- error,
119
- errorCode: error?.graphQLErrors?.[0]?.extensions?.["code"],
120
- queryResult: queryResultWithErrorReset
121
- }
122
- );
123
- };
124
- const wrapInSuspenseIfLoadingPresent = (suspendingSuccessElement, LoadingComponent) => {
125
- if (!LoadingComponent) {
126
- return suspendingSuccessElement;
127
- }
128
- return /* @__PURE__ */ import_react.default.createElement(
129
- import_react.Suspense,
130
- {
131
- fallback: /* @__PURE__ */ import_react.default.createElement(LoadingComponent, { ...props, queryResult: suspenseQueryResult })
132
- },
133
- suspendingSuccessElement
134
- );
135
- };
136
- return /* @__PURE__ */ import_react.default.createElement(import_CellErrorBoundary.CellErrorBoundary, { renderFallback: FailureComponent }, wrapInSuspenseIfLoadingPresent(
137
- /* @__PURE__ */ import_react.default.createElement(
138
- SuspendingSuccess,
139
- {
140
- userProps: props,
141
- queryRef,
142
- suspenseQueryResult
143
- }
144
- ),
145
- Loading
146
- ));
147
- };
148
- }
149
- // Annotate the CommonJS export names for ESM import in node:
150
- 0 && (module.exports = {
151
- createSuspendingCell
152
- });
@@ -1,115 +0,0 @@
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 __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (let key of __getOwnPropNames(from))
11
- if (!__hasOwnProp.call(to, key) && key !== except)
12
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- }
14
- return to;
15
- };
16
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
- var import_react = __toESM(require("react"), 1);
25
- var import_dev = require("@apollo/client/dev");
26
- var import_react2 = require("@testing-library/react");
27
- var import_vitest = require("vitest");
28
- var import_GraphQLHooksProvider = require("../GraphQLHooksProvider.js");
29
- var import_createSuspendingCell = require("./createSuspendingCell.js");
30
- import_vitest.vi.mock("@apollo/client/react/hooks/hooks.cjs", () => {
31
- return {
32
- useApolloClient: import_vitest.vi.fn()
33
- };
34
- });
35
- (0, import_vitest.describe)("createSuspendingCell", () => {
36
- (0, import_vitest.beforeAll)(() => {
37
- globalThis.RWJS_ENV = {
38
- RWJS_EXP_STREAMING_SSR: true
39
- };
40
- (0, import_dev.loadDevMessages)();
41
- (0, import_dev.loadErrorMessages)();
42
- });
43
- const mockedUseBgQuery = (() => {
44
- return ["mocked-query-ref", { refetch: import_vitest.vi.fn(), fetchMore: import_vitest.vi.fn() }];
45
- });
46
- const mockedQueryHook = () => ({ data: {} });
47
- (0, import_vitest.test)("Renders a static Success component", () => {
48
- const TestCell = (0, import_createSuspendingCell.createSuspendingCell)({
49
- // @ts-expect-error - Purposefully using a plain string here.
50
- QUERY: "query TestQuery { answer }",
51
- Success: () => /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, "Great success!")
52
- });
53
- (0, import_react2.render)(
54
- /* @__PURE__ */ import_react.default.createElement(
55
- import_GraphQLHooksProvider.GraphQLHooksProvider,
56
- {
57
- useBackgroundQuery: mockedUseBgQuery,
58
- useReadQuery: mockedQueryHook
59
- },
60
- /* @__PURE__ */ import_react.default.createElement(TestCell, null)
61
- )
62
- );
63
- import_react2.screen.getByText(/^Great success!$/);
64
- });
65
- (0, import_vitest.test)("Renders Success with data", () => {
66
- const TestCell = (0, import_createSuspendingCell.createSuspendingCell)({
67
- // @ts-expect-error - Purposefully using a plain string here.
68
- QUERY: "query TestQuery { answer }",
69
- Success: ({ answer }) => /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("dl", null, /* @__PURE__ */ import_react.default.createElement("dt", null, "What's the meaning of life?"), /* @__PURE__ */ import_react.default.createElement("dd", null, answer)))
70
- });
71
- const myUseQueryHook = (() => {
72
- return { data: { answer: 42 } };
73
- });
74
- (0, import_react2.render)(
75
- /* @__PURE__ */ import_react.default.createElement(
76
- import_GraphQLHooksProvider.GraphQLHooksProvider,
77
- {
78
- useReadQuery: myUseQueryHook,
79
- useBackgroundQuery: mockedUseBgQuery
80
- },
81
- /* @__PURE__ */ import_react.default.createElement(TestCell, null)
82
- )
83
- );
84
- import_react2.screen.getByText(/^What's the meaning of life\?$/);
85
- import_react2.screen.getByText(/^42$/);
86
- });
87
- (0, import_vitest.test)("Renders Success if any of the fields have data (i.e. not just the first)", () => {
88
- const TestCell = (0, import_createSuspendingCell.createSuspendingCell)({
89
- // @ts-expect-error - Purposefully using a plain string here.
90
- QUERY: "query TestQuery { users { name } posts { title } }",
91
- Empty: () => /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, "No users or posts"),
92
- Success: ({ users, posts }) => /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", null, users.length > 0 ? /* @__PURE__ */ import_react.default.createElement("ul", null, users.map(({ name }) => /* @__PURE__ */ import_react.default.createElement("li", { key: name }, name))) : "no users"), /* @__PURE__ */ import_react.default.createElement("div", null, posts.length > 0 ? /* @__PURE__ */ import_react.default.createElement("ul", null, posts.map(({ title }) => /* @__PURE__ */ import_react.default.createElement("li", { key: title }, title))) : "no posts"))
93
- });
94
- const myReadQueryHook = (() => {
95
- return {
96
- data: {
97
- users: [],
98
- posts: [{ title: "bazinga" }, { title: "kittens" }]
99
- }
100
- };
101
- });
102
- (0, import_react2.render)(
103
- /* @__PURE__ */ import_react.default.createElement(
104
- import_GraphQLHooksProvider.GraphQLHooksProvider,
105
- {
106
- useReadQuery: myReadQueryHook,
107
- useBackgroundQuery: mockedUseBgQuery
108
- },
109
- /* @__PURE__ */ import_react.default.createElement(TestCell, null)
110
- )
111
- );
112
- import_react2.screen.getByText(/bazinga/);
113
- import_react2.screen.getByText(/kittens/);
114
- });
115
- });
@@ -1,41 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,35 +0,0 @@
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 __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var isCellEmpty_exports = {};
20
- __export(isCellEmpty_exports, {
21
- isDataEmpty: () => isDataEmpty
22
- });
23
- module.exports = __toCommonJS(isCellEmpty_exports);
24
- function isDataEmpty(data) {
25
- return !data || Object.values(data).every((fieldValue) => {
26
- return fieldValue === null || isFieldEmptyArray(fieldValue);
27
- });
28
- }
29
- function isFieldEmptyArray(field) {
30
- return Array.isArray(field) && field.length === 0;
31
- }
32
- // Annotate the CommonJS export names for ESM import in node:
33
- 0 && (module.exports = {
34
- isDataEmpty
35
- });
@@ -1,52 +0,0 @@
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
@@ -1 +0,0 @@
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,GAAI,SAAS;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,GAAI,UAAU,SAAS,sBA6BvC,CAAA"}
@@ -1,88 +0,0 @@
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 htmlTags_exports = {};
30
- __export(htmlTags_exports, {
31
- Css: () => Css,
32
- Meta: () => Meta
33
- });
34
- module.exports = __toCommonJS(htmlTags_exports);
35
- var import_react = __toESM(require("react"), 1);
36
- var import_react2 = require("react");
37
- const extractCssFromAssetMap = () => {
38
- if (typeof window !== "undefined") {
39
- return window.__REDWOOD__ASSET_MAP?.css;
40
- }
41
- return void 0;
42
- };
43
- const extractMetaFromAssetMap = () => {
44
- if (typeof window !== "undefined") {
45
- return window.__REDWOOD__ASSET_MAP?.meta;
46
- }
47
- return void 0;
48
- };
49
- function addSlashIfNeeded(path) {
50
- if (path.startsWith("http") || path.startsWith("/")) {
51
- return path;
52
- } else {
53
- return "/" + path;
54
- }
55
- }
56
- const Css = ({ css }) => {
57
- const cssLinks = (css || extractCssFromAssetMap() || []).map(addSlashIfNeeded);
58
- return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, cssLinks.map((cssLink, index) => {
59
- return /* @__PURE__ */ import_react.default.createElement("link", { rel: "stylesheet", key: `css-${index}`, href: `${cssLink}` });
60
- }));
61
- };
62
- const Meta = ({ tags }) => {
63
- const metaTags = tags || extractMetaFromAssetMap() || [];
64
- return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, metaTags.map((tag, index) => {
65
- if (!tag) {
66
- return null;
67
- }
68
- if (isTitleTag(tag)) {
69
- return /* @__PURE__ */ import_react.default.createElement(import_react2.Fragment, { key: "title" }, /* @__PURE__ */ import_react.default.createElement("title", null, tag.title), /* @__PURE__ */ import_react.default.createElement("meta", { property: "og:title", content: tag.title }));
70
- }
71
- if (otherTag(tag)) {
72
- const { tagType: TagName, ...rest } = tag;
73
- return /* @__PURE__ */ import_react.default.createElement(TagName, { key: `meta-${index}`, ...rest });
74
- }
75
- return /* @__PURE__ */ import_react.default.createElement("meta", { key: `meta-${index}`, ...tag });
76
- }));
77
- };
78
- const isTitleTag = (tag) => {
79
- return "title" in tag;
80
- };
81
- const otherTag = (tag) => {
82
- return "tagType" in tag;
83
- };
84
- // Annotate the CommonJS export names for ESM import in node:
85
- 0 && (module.exports = {
86
- Css,
87
- Meta
88
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":""}
@@ -1,6 +0,0 @@
1
- "use strict";
2
- globalThis.RWJS_API_GRAPHQL_URL = RWJS_ENV.RWJS_API_GRAPHQL_URL;
3
- globalThis.RWJS_API_URL = RWJS_ENV.RWJS_API_URL;
4
- globalThis.__REDWOOD__APP_TITLE = RWJS_ENV.__REDWOOD__APP_TITLE;
5
- globalThis.RWJS_EXP_STREAMING_SSR = RWJS_ENV.RWJS_EXP_STREAMING_SSR;
6
- globalThis.RWJS_EXP_RSC = RWJS_ENV.RWJS_EXP_RSC;
@@ -1,30 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,16 +0,0 @@
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 global_web_auto_imports_exports = {};
16
- module.exports = __toCommonJS(global_web_auto_imports_exports);
@@ -1,23 +0,0 @@
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 document GraphQL query or mutation to get the operation name for
20
- * @returns empty string if no operation name could be found
21
- */
22
- export declare function getOperationName(document: DocumentNode): string;
23
- //# sourceMappingURL=graphql.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../src/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,YAAY,EAAE,MAAM,SAAS,CAAA;AAEjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,UAWtD"}
@@ -1,36 +0,0 @@
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 __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var graphql_exports = {};
20
- __export(graphql_exports, {
21
- getOperationName: () => getOperationName
22
- });
23
- module.exports = __toCommonJS(graphql_exports);
24
- var import_graphql = require("graphql");
25
- function getOperationName(document) {
26
- for (const definition of document.definitions) {
27
- if (definition.kind === import_graphql.Kind.OPERATION_DEFINITION && definition.name?.value) {
28
- return definition.name.value;
29
- }
30
- }
31
- return "";
32
- }
33
- // Annotate the CommonJS export names for ESM import in node:
34
- 0 && (module.exports = {
35
- getOperationName
36
- });
@@ -1,19 +0,0 @@
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 { Helmet } from '@dr.pogodin/react-helmet';
14
- export { Helmet as Head, Helmet };
15
- export * from './components/htmlTags.js';
16
- export * from './routeHooks.types.js';
17
- export * from './components/ServerInject.js';
18
- export type { TypedDocumentNode } from './components/GraphQLHooksProvider.js';
19
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
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,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,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"}