@webiny/app 0.0.0-unstable.fcdad0bc61 → 0.0.0-unstable.fdd9228b5d

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 (203) hide show
  1. package/App.d.ts +26 -0
  2. package/App.js +95 -0
  3. package/App.js.map +1 -0
  4. package/AppContainer.d.ts +23 -0
  5. package/AppContainer.js +9 -0
  6. package/AppContainer.js.map +1 -0
  7. package/apollo-client/InMemoryCache.d.ts +3 -2
  8. package/apollo-client/InMemoryCache.js +17 -76
  9. package/apollo-client/InMemoryCache.js.map +1 -1
  10. package/apollo-client/IntrospectionFragmentMatcher.d.ts +11 -0
  11. package/apollo-client/IntrospectionFragmentMatcher.js +45 -0
  12. package/apollo-client/IntrospectionFragmentMatcher.js.map +1 -0
  13. package/components/Image.d.ts +3 -3
  14. package/components/Image.js +12 -32
  15. package/components/Image.js.map +1 -1
  16. package/components/Routes.d.ts +2 -2
  17. package/components/Routes.js +21 -34
  18. package/components/Routes.js.map +1 -1
  19. package/components/View.d.ts +1 -1
  20. package/components/View.js +15 -37
  21. package/components/View.js.map +1 -1
  22. package/components/index.js +3 -20
  23. package/components/index.js.map +1 -1
  24. package/config/RouterConfig/Route.d.ts +30 -0
  25. package/config/RouterConfig/Route.js +42 -0
  26. package/config/RouterConfig/Route.js.map +1 -0
  27. package/config/RouterConfig.d.ts +32 -0
  28. package/config/RouterConfig.js +18 -0
  29. package/config/RouterConfig.js.map +1 -0
  30. package/config.d.ts +1 -1
  31. package/config.js +8 -16
  32. package/config.js.map +1 -1
  33. package/contexts/Ui/index.d.ts +4 -8
  34. package/contexts/Ui/index.js +29 -89
  35. package/contexts/Ui/index.js.map +1 -1
  36. package/core/DebounceRender.d.ts +12 -0
  37. package/core/DebounceRender.js +31 -0
  38. package/core/DebounceRender.js.map +1 -0
  39. package/core/Plugin.d.ts +8 -0
  40. package/core/Plugin.js +14 -0
  41. package/core/Plugin.js.map +1 -0
  42. package/core/Plugins.d.ts +15 -0
  43. package/core/Plugins.js +39 -0
  44. package/core/Plugins.js.map +1 -0
  45. package/core/Provider.d.ts +8 -0
  46. package/core/Provider.js +18 -0
  47. package/core/Provider.js.map +1 -0
  48. package/core/Routes.d.ts +6 -0
  49. package/core/Routes.js +34 -0
  50. package/core/Routes.js.map +1 -0
  51. package/core/createProvider.d.ts +10 -0
  52. package/core/createProvider.js +9 -0
  53. package/core/createProvider.js.map +1 -0
  54. package/core/createProviderPlugin.d.ts +8 -0
  55. package/core/createProviderPlugin.js +17 -0
  56. package/core/createProviderPlugin.js.map +1 -0
  57. package/hooks/useAutocomplete/index.js +2 -12
  58. package/hooks/useAutocomplete/index.js.map +1 -1
  59. package/hooks/useAutocomplete/useAutocomplete.d.ts +1 -1
  60. package/hooks/useAutocomplete/useAutocomplete.js +10 -25
  61. package/hooks/useAutocomplete/useAutocomplete.js.map +1 -1
  62. package/hooks/useDataList/functions/getData.js +3 -15
  63. package/hooks/useDataList/functions/getData.js.map +1 -1
  64. package/hooks/useDataList/functions/getError.js +3 -15
  65. package/hooks/useDataList/functions/getError.js.map +1 -1
  66. package/hooks/useDataList/functions/getMeta.js +3 -15
  67. package/hooks/useDataList/functions/getMeta.js.map +1 -1
  68. package/hooks/useDataList/functions/index.js +4 -30
  69. package/hooks/useDataList/functions/index.js.map +1 -1
  70. package/hooks/useDataList/functions/searchDataByKey.js +5 -16
  71. package/hooks/useDataList/functions/searchDataByKey.js.map +1 -1
  72. package/hooks/useDataList/index.js +2 -12
  73. package/hooks/useDataList/index.js.map +1 -1
  74. package/hooks/useDataList/useDataList.d.ts +2 -2
  75. package/hooks/useDataList/useDataList.js +82 -107
  76. package/hooks/useDataList/useDataList.js.map +1 -1
  77. package/hooks/useDataList/utils/index.js +3 -22
  78. package/hooks/useDataList/utils/index.js.map +1 -1
  79. package/hooks/useDataList/utils/prepareLoadListParams.d.ts +1 -2
  80. package/hooks/useDataList/utils/prepareLoadListParams.js +33 -43
  81. package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -1
  82. package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js +11 -16
  83. package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js.map +1 -1
  84. package/hooks/useDataList/utils/types.d.ts +21 -15
  85. package/hooks/useDataList/utils/types.js +2 -4
  86. package/hooks/useDataList/utils/types.js.map +1 -1
  87. package/hooks/useHandler.js +13 -14
  88. package/hooks/useHandler.js.map +1 -1
  89. package/hooks/useHandlers.d.ts +3 -3
  90. package/hooks/useHandlers.js +14 -21
  91. package/hooks/useHandlers.js.map +1 -1
  92. package/hooks/useRegisterLegacyPlugin.d.ts +2 -0
  93. package/hooks/useRegisterLegacyPlugin.js +11 -0
  94. package/hooks/useRegisterLegacyPlugin.js.map +1 -0
  95. package/hooks/useUi.d.ts +1 -1
  96. package/hooks/useUi.js +5 -14
  97. package/hooks/useUi.js.map +1 -1
  98. package/i18n/i18n.js +6 -20
  99. package/i18n/i18n.js.map +1 -1
  100. package/i18n/index.js +2 -14
  101. package/i18n/index.js.map +1 -1
  102. package/index.d.ts +14 -1
  103. package/index.js +18 -35
  104. package/index.js.map +1 -1
  105. package/package.json +25 -30
  106. package/plugins/AddQuerySelectionPlugin.d.ts +9 -2
  107. package/plugins/AddQuerySelectionPlugin.js +64 -124
  108. package/plugins/AddQuerySelectionPlugin.js.map +1 -1
  109. package/plugins/ApolloCacheObjectIdPlugin.js +13 -50
  110. package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -1
  111. package/plugins/ApolloDynamicLink.d.ts +3 -2
  112. package/plugins/ApolloDynamicLink.js +20 -72
  113. package/plugins/ApolloDynamicLink.js.map +1 -1
  114. package/plugins/ApolloLinkPlugin.d.ts +1 -1
  115. package/plugins/ApolloLinkPlugin.js +19 -60
  116. package/plugins/ApolloLinkPlugin.js.map +1 -1
  117. package/plugins/ConsoleLinkPlugin.js +21 -58
  118. package/plugins/ConsoleLinkPlugin.js.map +1 -1
  119. package/plugins/LocaleHeaderLinkPlugin.d.ts +1 -6
  120. package/plugins/LocaleHeaderLinkPlugin.js +24 -69
  121. package/plugins/LocaleHeaderLinkPlugin.js.map +1 -1
  122. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.d.ts +1 -1
  123. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +41 -72
  124. package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -1
  125. package/plugins/NetworkErrorLinkPlugin/StyledComponents.d.ts +8 -4
  126. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +76 -19
  127. package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -1
  128. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.d.ts +1 -1
  129. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +24 -31
  130. package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -1
  131. package/plugins/NetworkErrorLinkPlugin.js +24 -59
  132. package/plugins/NetworkErrorLinkPlugin.js.map +1 -1
  133. package/plugins/OmitTypenameLinkPlugin.js +13 -47
  134. package/plugins/OmitTypenameLinkPlugin.js.map +1 -1
  135. package/plugins/RoutePlugin.d.ts +1 -1
  136. package/plugins/RoutePlugin.js +13 -50
  137. package/plugins/RoutePlugin.js.map +1 -1
  138. package/plugins/TenantHeaderLinkPlugin.d.ts +1 -6
  139. package/plugins/TenantHeaderLinkPlugin.js +31 -77
  140. package/plugins/TenantHeaderLinkPlugin.js.map +1 -1
  141. package/plugins/ViewPlugin.d.ts +1 -1
  142. package/plugins/ViewPlugin.js +16 -55
  143. package/plugins/ViewPlugin.js.map +1 -1
  144. package/plugins/image.d.ts +1 -1
  145. package/plugins/image.js +55 -94
  146. package/plugins/image.js.map +1 -1
  147. package/plugins/index.d.ts +3 -3
  148. package/plugins/index.js +34 -78
  149. package/plugins/index.js.map +1 -1
  150. package/react-butterfiles/Files.d.ts +69 -0
  151. package/react-butterfiles/Files.js +227 -0
  152. package/react-butterfiles/Files.js.map +1 -0
  153. package/react-butterfiles/index.d.ts +2 -0
  154. package/react-butterfiles/index.js +4 -0
  155. package/react-butterfiles/index.js.map +1 -0
  156. package/react-butterfiles/utils/generateId.d.ts +1 -0
  157. package/react-butterfiles/utils/generateId.js +5 -0
  158. package/react-butterfiles/utils/generateId.js.map +1 -0
  159. package/react-butterfiles/utils/readFileContent.d.ts +1 -0
  160. package/react-butterfiles/utils/readFileContent.js +15 -0
  161. package/react-butterfiles/utils/readFileContent.js.map +1 -0
  162. package/renderApp.d.ts +2 -0
  163. package/renderApp.js +9 -0
  164. package/renderApp.js.map +1 -0
  165. package/types.d.ts +24 -27
  166. package/types.js +12 -11
  167. package/types.js.map +1 -1
  168. package/utils/createGenericContext.d.ts +13 -0
  169. package/utils/createGenericContext.js +25 -0
  170. package/utils/createGenericContext.js.map +1 -0
  171. package/utils/createHashing.d.ts +2 -0
  172. package/utils/createHashing.js +18 -0
  173. package/utils/createHashing.js.map +1 -0
  174. package/utils/getApiUrl.d.ts +1 -0
  175. package/utils/getApiUrl.js +5 -0
  176. package/utils/getApiUrl.js.map +1 -0
  177. package/utils/getGqlApiUrl.d.ts +1 -0
  178. package/utils/getGqlApiUrl.js +6 -0
  179. package/utils/getGqlApiUrl.js.map +1 -0
  180. package/utils/getHeadlessCmsGqlApiUrl.d.ts +5 -0
  181. package/utils/getHeadlessCmsGqlApiUrl.js +12 -0
  182. package/utils/getHeadlessCmsGqlApiUrl.js.map +1 -0
  183. package/utils/getLocaleCode.d.ts +6 -0
  184. package/utils/getLocaleCode.js +33 -0
  185. package/utils/getLocaleCode.js.map +1 -0
  186. package/utils/getPrerenderId.d.ts +6 -0
  187. package/utils/getPrerenderId.js +5 -0
  188. package/utils/getPrerenderId.js.map +1 -0
  189. package/utils/getTenantId.d.ts +6 -0
  190. package/utils/getTenantId.js +45 -0
  191. package/utils/getTenantId.js.map +1 -0
  192. package/utils/index.d.ts +10 -0
  193. package/utils/index.js +12 -0
  194. package/utils/index.js.map +1 -0
  195. package/utils/isLocalhost.d.ts +1 -0
  196. package/utils/isLocalhost.js +7 -0
  197. package/utils/isLocalhost.js.map +1 -0
  198. package/utils/isPrerendering.d.ts +1 -0
  199. package/utils/isPrerendering.js +5 -0
  200. package/utils/isPrerendering.js.map +1 -0
  201. package/utils/legacyPluginToReactComponent.d.ts +7 -0
  202. package/utils/legacyPluginToReactComponent.js +14 -0
  203. package/utils/legacyPluginToReactComponent.js.map +1 -0
@@ -1,20 +1,19 @@
1
- "use strict";
1
+ import { useRef, useEffect } from "react";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useHandler = useHandler;
3
+ /**
4
+ * TODO: figure out any types.
5
+ */
7
6
 
8
- var _react = require("react");
9
-
10
- function useHandler(props, factory) {
11
- var propsRef = (0, _react.useRef)(props);
12
- var handlerRef = (0, _react.useRef)(function () {
13
- var handler = factory(propsRef.current);
14
- return handler.apply(void 0, arguments);
7
+ export function useHandler(props, factory) {
8
+ const propsRef = useRef(props);
9
+ const handlerRef = useRef((...args) => {
10
+ const handler = factory(propsRef.current);
11
+ return handler(...args);
15
12
  });
16
- (0, _react.useEffect)(function () {
13
+ useEffect(() => {
17
14
  propsRef.current = props;
18
15
  });
19
16
  return handlerRef.current;
20
- }
17
+ }
18
+
19
+ //# sourceMappingURL=useHandler.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useHandler","props","factory","propsRef","useRef","handlerRef","handler","current","useEffect"],"sources":["useHandler.ts"],"sourcesContent":["import { useRef, useEffect } from \"react\";\n\n/**\n * TODO: figure out any types.\n */\ninterface Props {\n [key: string]: any;\n}\ninterface Factory {\n (...args: any): any;\n}\nexport function useHandler(props: Props, factory: Factory) {\n const propsRef = useRef(props);\n\n const handlerRef = useRef((...args: any) => {\n const handler = factory(propsRef.current);\n return handler(...args);\n });\n\n useEffect(() => {\n propsRef.current = props;\n });\n\n return handlerRef.current;\n}\n"],"mappings":";;;;;;;AAAA;;AAWO,SAASA,UAAT,CAAoBC,KAApB,EAAkCC,OAAlC,EAAoD;EACvD,IAAMC,QAAQ,GAAG,IAAAC,aAAA,EAAOH,KAAP,CAAjB;EAEA,IAAMI,UAAU,GAAG,IAAAD,aAAA,EAAO,YAAkB;IACxC,IAAME,OAAO,GAAGJ,OAAO,CAACC,QAAQ,CAACI,OAAV,CAAvB;IACA,OAAOD,OAAO,MAAP,mBAAP;EACH,CAHkB,CAAnB;EAKA,IAAAE,gBAAA,EAAU,YAAM;IACZL,QAAQ,CAACI,OAAT,GAAmBN,KAAnB;EACH,CAFD;EAIA,OAAOI,UAAU,CAACE,OAAlB;AACH"}
1
+ {"version":3,"names":["useRef","useEffect","useHandler","props","factory","propsRef","handlerRef","args","handler","current"],"sources":["useHandler.ts"],"sourcesContent":["import { useRef, useEffect } from \"react\";\n\n/**\n * TODO: figure out any types.\n */\ninterface Props {\n [key: string]: any;\n}\ninterface Factory {\n (...args: any): any;\n}\nexport function useHandler(props: Props, factory: Factory) {\n const propsRef = useRef(props);\n\n const handlerRef = useRef((...args: any) => {\n const handler = factory(propsRef.current);\n return handler(...args);\n });\n\n useEffect(() => {\n propsRef.current = props;\n });\n\n return handlerRef.current;\n}\n"],"mappings":"AAAA,SAASA,MAAM,EAAEC,SAAS,QAAQ,OAAO;;AAEzC;AACA;AACA;;AAOA,OAAO,SAASC,UAAUA,CAACC,KAAY,EAAEC,OAAgB,EAAE;EACvD,MAAMC,QAAQ,GAAGL,MAAM,CAACG,KAAK,CAAC;EAE9B,MAAMG,UAAU,GAAGN,MAAM,CAAC,CAAC,GAAGO,IAAS,KAAK;IACxC,MAAMC,OAAO,GAAGJ,OAAO,CAACC,QAAQ,CAACI,OAAO,CAAC;IACzC,OAAOD,OAAO,CAAC,GAAGD,IAAI,CAAC;EAC3B,CAAC,CAAC;EAEFN,SAAS,CAAC,MAAM;IACZI,QAAQ,CAACI,OAAO,GAAGN,KAAK;EAC5B,CAAC,CAAC;EAEF,OAAOG,UAAU,CAACG,OAAO;AAC7B","ignoreList":[]}
@@ -1,10 +1,10 @@
1
- declare type HandlerProps = {
1
+ type HandlerProps = {
2
2
  [key: string]: any;
3
3
  };
4
- declare type HandlerFactories = {
4
+ type HandlerFactories = {
5
5
  [key: string]: (props: HandlerProps) => (...params: any[]) => any;
6
6
  };
7
- declare type Handlers = {
7
+ type Handlers = {
8
8
  [K in keyof HandlerFactories]: (...params: any[]) => any;
9
9
  };
10
10
  export declare function useHandlers<H = Handlers>(props: HandlerProps, factories: HandlerFactories): H;
@@ -1,30 +1,23 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useHandlers = useHandlers;
7
-
8
- var _react = require("react");
9
-
10
- function useHandlers(props, factories) {
11
- var propsRef = (0, _react.useRef)(props);
12
- var handlersRef = (0, _react.useRef)(function () {
13
- var names = Object.keys(factories);
14
- return names.reduce(function (handlers, name) {
1
+ import { useRef, useEffect } from "react";
2
+ export function useHandlers(props, factories) {
3
+ const propsRef = useRef(props);
4
+ const handlersRef = useRef((() => {
5
+ const names = Object.keys(factories);
6
+ return names.reduce((handlers, name) => {
15
7
  /**
16
8
  * TODO: figure out args types
17
9
  */
18
- handlers[name] = function () {
19
- var handler = factories[name](propsRef.current);
20
- return handler.apply(void 0, arguments);
10
+ handlers[name] = (...args) => {
11
+ const handler = factories[name](propsRef.current);
12
+ return handler(...args);
21
13
  };
22
-
23
14
  return handlers;
24
15
  }, {});
25
- }());
26
- (0, _react.useEffect)(function () {
16
+ })());
17
+ useEffect(() => {
27
18
  propsRef.current = props;
28
19
  });
29
20
  return handlersRef.current;
30
- }
21
+ }
22
+
23
+ //# sourceMappingURL=useHandlers.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useHandlers","props","factories","propsRef","useRef","handlersRef","names","Object","keys","reduce","handlers","name","handler","current","useEffect"],"sources":["useHandlers.ts"],"sourcesContent":["import { useRef, useEffect } from \"react\";\n\ntype HandlerProps = { [key: string]: any };\ntype HandlerFactories = { [key: string]: (props: HandlerProps) => (...params: any[]) => any };\ntype Handlers = {\n [K in keyof HandlerFactories]: (...params: any[]) => any;\n};\n\nexport function useHandlers<H = Handlers>(props: HandlerProps, factories: HandlerFactories) {\n const propsRef = useRef(props);\n\n const handlersRef = useRef(\n (() => {\n const names = Object.keys(factories);\n return names.reduce((handlers, name) => {\n /**\n * TODO: figure out args types\n */\n handlers[name] = (...args: any) => {\n const handler = factories[name](propsRef.current);\n return handler(...args);\n };\n return handlers;\n }, {} as Record<string, any>);\n })()\n );\n\n useEffect(() => {\n propsRef.current = props;\n });\n\n return handlersRef.current as H;\n}\n"],"mappings":";;;;;;;AAAA;;AAQO,SAASA,WAAT,CAAmCC,KAAnC,EAAwDC,SAAxD,EAAqF;EACxF,IAAMC,QAAQ,GAAG,IAAAC,aAAA,EAAOH,KAAP,CAAjB;EAEA,IAAMI,WAAW,GAAG,IAAAD,aAAA,EACf,YAAM;IACH,IAAME,KAAK,GAAGC,MAAM,CAACC,IAAP,CAAYN,SAAZ,CAAd;IACA,OAAOI,KAAK,CAACG,MAAN,CAAa,UAACC,QAAD,EAAWC,IAAX,EAAoB;MACpC;AAChB;AACA;MACgBD,QAAQ,CAACC,IAAD,CAAR,GAAiB,YAAkB;QAC/B,IAAMC,OAAO,GAAGV,SAAS,CAACS,IAAD,CAAT,CAAgBR,QAAQ,CAACU,OAAzB,CAAhB;QACA,OAAOD,OAAO,MAAP,mBAAP;MACH,CAHD;;MAIA,OAAOF,QAAP;IACH,CATM,EASJ,EATI,CAAP;EAUH,CAZD,EADgB,CAApB;EAgBA,IAAAI,gBAAA,EAAU,YAAM;IACZX,QAAQ,CAACU,OAAT,GAAmBZ,KAAnB;EACH,CAFD;EAIA,OAAOI,WAAW,CAACQ,OAAnB;AACH"}
1
+ {"version":3,"names":["useRef","useEffect","useHandlers","props","factories","propsRef","handlersRef","names","Object","keys","reduce","handlers","name","args","handler","current"],"sources":["useHandlers.ts"],"sourcesContent":["import { useRef, useEffect } from \"react\";\n\ntype HandlerProps = { [key: string]: any };\ntype HandlerFactories = { [key: string]: (props: HandlerProps) => (...params: any[]) => any };\ntype Handlers = {\n [K in keyof HandlerFactories]: (...params: any[]) => any;\n};\n\nexport function useHandlers<H = Handlers>(props: HandlerProps, factories: HandlerFactories) {\n const propsRef = useRef(props);\n\n const handlersRef = useRef(\n (() => {\n const names = Object.keys(factories);\n return names.reduce((handlers, name) => {\n /**\n * TODO: figure out args types\n */\n handlers[name] = (...args: any) => {\n const handler = factories[name](propsRef.current);\n return handler(...args);\n };\n return handlers;\n }, {} as Record<string, any>);\n })()\n );\n\n useEffect(() => {\n propsRef.current = props;\n });\n\n return handlersRef.current as H;\n}\n"],"mappings":"AAAA,SAASA,MAAM,EAAEC,SAAS,QAAQ,OAAO;AAQzC,OAAO,SAASC,WAAWA,CAAeC,KAAmB,EAAEC,SAA2B,EAAE;EACxF,MAAMC,QAAQ,GAAGL,MAAM,CAACG,KAAK,CAAC;EAE9B,MAAMG,WAAW,GAAGN,MAAM,CACtB,CAAC,MAAM;IACH,MAAMO,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACL,SAAS,CAAC;IACpC,OAAOG,KAAK,CAACG,MAAM,CAAC,CAACC,QAAQ,EAAEC,IAAI,KAAK;MACpC;AAChB;AACA;MACgBD,QAAQ,CAACC,IAAI,CAAC,GAAG,CAAC,GAAGC,IAAS,KAAK;QAC/B,MAAMC,OAAO,GAAGV,SAAS,CAACQ,IAAI,CAAC,CAACP,QAAQ,CAACU,OAAO,CAAC;QACjD,OAAOD,OAAO,CAAC,GAAGD,IAAI,CAAC;MAC3B,CAAC;MACD,OAAOF,QAAQ;IACnB,CAAC,EAAE,CAAC,CAAwB,CAAC;EACjC,CAAC,EAAE,CACP,CAAC;EAEDV,SAAS,CAAC,MAAM;IACZI,QAAQ,CAACU,OAAO,GAAGZ,KAAK;EAC5B,CAAC,CAAC;EAEF,OAAOG,WAAW,CAACS,OAAO;AAC9B","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import { type Plugin } from "@webiny/plugins/types";
2
+ export declare function useRegisterLegacyPlugin<TPlugin extends Plugin>(plugin: TPlugin): void;
@@ -0,0 +1,11 @@
1
+ import { useRef } from "react";
2
+ import { plugins } from "@webiny/plugins";
3
+ export function useRegisterLegacyPlugin(plugin) {
4
+ const pluginRegistered = useRef(false);
5
+ if (!pluginRegistered.current) {
6
+ pluginRegistered.current = true;
7
+ plugins.register(plugin);
8
+ }
9
+ }
10
+
11
+ //# sourceMappingURL=useRegisterLegacyPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useRef","plugins","useRegisterLegacyPlugin","plugin","pluginRegistered","current","register"],"sources":["useRegisterLegacyPlugin.tsx"],"sourcesContent":["import { useRef } from \"react\";\nimport { plugins } from \"@webiny/plugins\";\nimport { type Plugin } from \"@webiny/plugins/types\";\n\nexport function useRegisterLegacyPlugin<TPlugin extends Plugin>(plugin: TPlugin) {\n const pluginRegistered = useRef<boolean>(false);\n if (!pluginRegistered.current) {\n pluginRegistered.current = true;\n plugins.register(plugin);\n }\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,OAAO;AAC9B,SAASC,OAAO,QAAQ,iBAAiB;AAGzC,OAAO,SAASC,uBAAuBA,CAAyBC,MAAe,EAAE;EAC7E,MAAMC,gBAAgB,GAAGJ,MAAM,CAAU,KAAK,CAAC;EAC/C,IAAI,CAACI,gBAAgB,CAACC,OAAO,EAAE;IAC3BD,gBAAgB,CAACC,OAAO,GAAG,IAAI;IAC/BJ,OAAO,CAACK,QAAQ,CAACH,MAAM,CAAC;EAC5B;AACJ","ignoreList":[]}
package/hooks/useUi.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { UiContextValue } from "../contexts/Ui";
1
+ import type { UiContextValue } from "../contexts/Ui";
2
2
  export declare const useUi: () => UiContextValue;
package/hooks/useUi.js CHANGED
@@ -1,16 +1,7 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useUi = void 0;
7
-
8
- var _react = require("react");
9
-
10
- var _Ui = require("./../contexts/Ui");
11
-
12
- var useUi = function useUi() {
13
- return (0, _react.useContext)(_Ui.UiContext);
1
+ import { useContext } from "react";
2
+ import { UiContext } from "../contexts/Ui";
3
+ export const useUi = () => {
4
+ return useContext(UiContext);
14
5
  };
15
6
 
16
- exports.useUi = useUi;
7
+ //# sourceMappingURL=useUi.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useUi","useContext","UiContext"],"sources":["useUi.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { UiContext, UiContextValue } from \"./../contexts/Ui\";\n\nexport const useUi = () => {\n return useContext(UiContext) as UiContextValue;\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEO,IAAMA,KAAK,GAAG,SAARA,KAAQ,GAAM;EACvB,OAAO,IAAAC,iBAAA,EAAWC,aAAX,CAAP;AACH,CAFM"}
1
+ {"version":3,"names":["useContext","UiContext","useUi"],"sources":["useUi.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport type { UiContextValue } from \"~/contexts/Ui\";\nimport { UiContext } from \"~/contexts/Ui\";\n\nexport const useUi = () => {\n return useContext(UiContext) as UiContextValue;\n};\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,OAAO;AAElC,SAASC,SAAS;AAElB,OAAO,MAAMC,KAAK,GAAGA,CAAA,KAAM;EACvB,OAAOF,UAAU,CAACC,SAAS,CAAC;AAChC,CAAC","ignoreList":[]}
package/i18n/i18n.js CHANGED
@@ -1,21 +1,7 @@
1
- "use strict";
1
+ import i18n, { defaultProcessor, defaultModifiers } from "@webiny/i18n";
2
+ import reactProcessor from "@webiny/i18n-react";
3
+ i18n.registerProcessors([defaultProcessor, reactProcessor]);
4
+ i18n.registerModifiers(defaultModifiers);
5
+ export default i18n;
2
6
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- exports.default = void 0;
11
-
12
- var _i18n = _interopRequireWildcard(require("@webiny/i18n"));
13
-
14
- var _i18nReact = _interopRequireDefault(require("@webiny/i18n-react"));
15
-
16
- _i18n.default.registerProcessors([_i18n.defaultProcessor, _i18nReact.default]);
17
-
18
- _i18n.default.registerModifiers(_i18n.defaultModifiers);
19
-
20
- var _default = _i18n.default;
21
- exports.default = _default;
7
+ //# sourceMappingURL=i18n.js.map
package/i18n/i18n.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["i18n","registerProcessors","defaultProcessor","reactProcessor","registerModifiers","defaultModifiers"],"sources":["i18n.ts"],"sourcesContent":["import i18n, { defaultProcessor, defaultModifiers } from \"@webiny/i18n\";\nimport reactProcessor from \"@webiny/i18n-react\";\n\ni18n.registerProcessors([defaultProcessor, reactProcessor]);\ni18n.registerModifiers(defaultModifiers);\n\nexport default i18n;\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAEAA,aAAA,CAAKC,kBAAL,CAAwB,CAACC,sBAAD,EAAmBC,kBAAnB,CAAxB;;AACAH,aAAA,CAAKI,iBAAL,CAAuBC,sBAAvB;;eAEeL,a"}
1
+ {"version":3,"names":["i18n","defaultProcessor","defaultModifiers","reactProcessor","registerProcessors","registerModifiers"],"sources":["i18n.ts"],"sourcesContent":["import i18n, { defaultProcessor, defaultModifiers } from \"@webiny/i18n\";\nimport reactProcessor from \"@webiny/i18n-react\";\n\ni18n.registerProcessors([defaultProcessor, reactProcessor]);\ni18n.registerModifiers(defaultModifiers);\n\nexport default i18n;\n"],"mappings":"AAAA,OAAOA,IAAI,IAAIC,gBAAgB,EAAEC,gBAAgB,QAAQ,cAAc;AACvE,OAAOC,cAAc,MAAM,oBAAoB;AAE/CH,IAAI,CAACI,kBAAkB,CAAC,CAACH,gBAAgB,EAAEE,cAAc,CAAC,CAAC;AAC3DH,IAAI,CAACK,iBAAiB,CAACH,gBAAgB,CAAC;AAExC,eAAeF,IAAI","ignoreList":[]}
package/i18n/index.js CHANGED
@@ -1,15 +1,3 @@
1
- "use strict";
1
+ export { default as i18n } from "./i18n";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- Object.defineProperty(exports, "i18n", {
9
- enumerable: true,
10
- get: function get() {
11
- return _i18n.default;
12
- }
13
- });
14
-
15
- var _i18n = _interopRequireDefault(require("./i18n"));
3
+ //# sourceMappingURL=index.js.map
package/i18n/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default as i18n } from \"./i18n\";\n"],"mappings":";;;;;;;;;;;;;;AAAA"}
1
+ {"version":3,"names":["default","i18n"],"sources":["index.ts"],"sourcesContent":["export { default as i18n } from \"./i18n\";\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,IAAI","ignoreList":[]}
package/index.d.ts CHANGED
@@ -1,4 +1,17 @@
1
1
  export { AddQuerySelectionPlugin } from "./plugins/AddQuerySelectionPlugin";
2
2
  export { ApolloLinkPlugin } from "./plugins/ApolloLinkPlugin";
3
3
  export { RoutePlugin } from "./plugins/RoutePlugin";
4
- export { ApolloCacheObjectIdPlugin } from "./plugins/ApolloCacheObjectIdPlugin";
4
+ export { ApolloCacheObjectIdPlugin, type ApolloCacheObject } from "./plugins/ApolloCacheObjectIdPlugin";
5
+ export * from "@webiny/react-composition";
6
+ export type { HigherOrderComponent, ComposeProps, ComposableFC } from "@webiny/react-composition";
7
+ export * from "./App";
8
+ export * from "./AppContainer";
9
+ export type { AppProps } from "./App";
10
+ export * from "./core/Plugins";
11
+ export * from "./core/Plugin";
12
+ export * from "./core/Provider";
13
+ export * from "./core/DebounceRender";
14
+ export * from "./core/createProvider";
15
+ export * from "./core/createProviderPlugin";
16
+ export * from "./renderApp";
17
+ export * from "./utils/createGenericContext";
package/index.js CHANGED
@@ -1,37 +1,20 @@
1
- "use strict";
1
+ export { AddQuerySelectionPlugin } from "./plugins/AddQuerySelectionPlugin";
2
+ export { ApolloLinkPlugin } from "./plugins/ApolloLinkPlugin";
3
+ export { RoutePlugin } from "./plugins/RoutePlugin";
4
+ export { ApolloCacheObjectIdPlugin } from "./plugins/ApolloCacheObjectIdPlugin";
2
5
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "AddQuerySelectionPlugin", {
7
- enumerable: true,
8
- get: function get() {
9
- return _AddQuerySelectionPlugin.AddQuerySelectionPlugin;
10
- }
11
- });
12
- Object.defineProperty(exports, "ApolloCacheObjectIdPlugin", {
13
- enumerable: true,
14
- get: function get() {
15
- return _ApolloCacheObjectIdPlugin.ApolloCacheObjectIdPlugin;
16
- }
17
- });
18
- Object.defineProperty(exports, "ApolloLinkPlugin", {
19
- enumerable: true,
20
- get: function get() {
21
- return _ApolloLinkPlugin.ApolloLinkPlugin;
22
- }
23
- });
24
- Object.defineProperty(exports, "RoutePlugin", {
25
- enumerable: true,
26
- get: function get() {
27
- return _RoutePlugin.RoutePlugin;
28
- }
29
- });
6
+ // Composition - we re-export this for ease of use
7
+ export * from "@webiny/react-composition";
8
+ // App framework
9
+ export * from "./App";
10
+ export * from "./AppContainer";
11
+ export * from "./core/Plugins";
12
+ export * from "./core/Plugin";
13
+ export * from "./core/Provider";
14
+ export * from "./core/DebounceRender";
15
+ export * from "./core/createProvider";
16
+ export * from "./core/createProviderPlugin";
17
+ export * from "./renderApp";
18
+ export * from "./utils/createGenericContext";
30
19
 
31
- var _AddQuerySelectionPlugin = require("./plugins/AddQuerySelectionPlugin");
32
-
33
- var _ApolloLinkPlugin = require("./plugins/ApolloLinkPlugin");
34
-
35
- var _RoutePlugin = require("./plugins/RoutePlugin");
36
-
37
- var _ApolloCacheObjectIdPlugin = require("./plugins/ApolloCacheObjectIdPlugin");
20
+ //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { AddQuerySelectionPlugin } from \"./plugins/AddQuerySelectionPlugin\";\nexport { ApolloLinkPlugin } from \"./plugins/ApolloLinkPlugin\";\nexport { RoutePlugin } from \"./plugins/RoutePlugin\";\nexport { ApolloCacheObjectIdPlugin } from \"./plugins/ApolloCacheObjectIdPlugin\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA"}
1
+ {"version":3,"names":["AddQuerySelectionPlugin","ApolloLinkPlugin","RoutePlugin","ApolloCacheObjectIdPlugin"],"sources":["index.ts"],"sourcesContent":["export { AddQuerySelectionPlugin } from \"./plugins/AddQuerySelectionPlugin\";\nexport { ApolloLinkPlugin } from \"./plugins/ApolloLinkPlugin\";\nexport { RoutePlugin } from \"./plugins/RoutePlugin\";\nexport {\n ApolloCacheObjectIdPlugin,\n type ApolloCacheObject\n} from \"./plugins/ApolloCacheObjectIdPlugin\";\n\n// Composition - we re-export this for ease of use\nexport * from \"@webiny/react-composition\";\nexport type { HigherOrderComponent, ComposeProps, ComposableFC } from \"@webiny/react-composition\";\n\n// App framework\nexport * from \"./App\";\nexport * from \"./AppContainer\";\nexport type { AppProps } from \"./App\";\nexport * from \"./core/Plugins\";\nexport * from \"./core/Plugin\";\nexport * from \"./core/Provider\";\nexport * from \"./core/DebounceRender\";\nexport * from \"./core/createProvider\";\nexport * from \"./core/createProviderPlugin\";\nexport * from \"./renderApp\";\nexport * from \"./utils/createGenericContext\";\n"],"mappings":"AAAA,SAASA,uBAAuB;AAChC,SAASC,gBAAgB;AACzB,SAASC,WAAW;AACpB,SACIC,yBAAyB;;AAI7B;AACA,cAAc,2BAA2B;AAGzC;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/app",
3
- "version": "0.0.0-unstable.fcdad0bc61",
3
+ "version": "0.0.0-unstable.fdd9228b5d",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,15 +15,15 @@
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
17
  "@apollo/react-hooks": "3.1.5",
18
- "@babel/runtime": "7.19.0",
19
- "@emotion/styled": "10.3.0",
20
- "@types/react": "17.0.39",
21
- "@types/web": "0.0.61",
22
- "@webiny/i18n": "0.0.0-unstable.fcdad0bc61",
23
- "@webiny/i18n-react": "0.0.0-unstable.fcdad0bc61",
24
- "@webiny/plugins": "0.0.0-unstable.fcdad0bc61",
25
- "@webiny/react-router": "0.0.0-unstable.fcdad0bc61",
26
- "@webiny/ui": "0.0.0-unstable.fcdad0bc61",
18
+ "@emotion/styled": "11.10.6",
19
+ "@types/react": "18.2.79",
20
+ "@webiny/i18n": "0.0.0-unstable.fdd9228b5d",
21
+ "@webiny/i18n-react": "0.0.0-unstable.fdd9228b5d",
22
+ "@webiny/plugins": "0.0.0-unstable.fdd9228b5d",
23
+ "@webiny/react-composition": "0.0.0-unstable.fdd9228b5d",
24
+ "@webiny/react-properties": "0.0.0-unstable.fdd9228b5d",
25
+ "@webiny/react-router": "0.0.0-unstable.fdd9228b5d",
26
+ "@webiny/ui": "0.0.0-unstable.fdd9228b5d",
27
27
  "apollo-cache": "1.3.5",
28
28
  "apollo-cache-inmemory": "1.6.6",
29
29
  "apollo-client": "2.6.10",
@@ -33,43 +33,38 @@
33
33
  "apollo-link-http-common": "0.2.16",
34
34
  "apollo-utilities": "1.3.4",
35
35
  "boolean": "3.2.0",
36
- "graphql": "15.8.0",
36
+ "bytes": "3.1.2",
37
+ "graphql": "15.9.0",
37
38
  "invariant": "2.2.4",
38
39
  "lodash": "4.17.21",
39
- "nanoid": "3.3.4",
40
- "react": "17.0.2",
41
- "react-dom": "17.0.2",
40
+ "minimatch": "5.1.6",
41
+ "nanoid": "3.3.8",
42
+ "react": "18.2.0",
43
+ "react-dom": "18.2.0",
44
+ "ts-invariant": "0.10.3",
42
45
  "warning": "4.0.3"
43
46
  },
44
47
  "devDependencies": {
45
- "@babel/cli": "^7.19.3",
46
- "@babel/core": "^7.19.3",
47
- "@babel/plugin-proposal-class-properties": "^7.18.6",
48
- "@babel/preset-env": "^7.19.4",
49
- "@babel/preset-react": "^7.18.6",
50
- "@babel/preset-typescript": "^7.18.6",
51
- "@types/warning": "^3.0.0",
52
- "@webiny/cli": "^0.0.0-unstable.fcdad0bc61",
53
- "@webiny/project-utils": "^0.0.0-unstable.fcdad0bc61",
54
- "babel-plugin-lodash": "^3.3.4",
55
- "rimraf": "^3.0.2",
56
- "typescript": "4.7.4"
48
+ "@types/lodash": "4.17.13",
49
+ "@types/warning": "3.0.0",
50
+ "@webiny/project-utils": "0.0.0-unstable.fdd9228b5d",
51
+ "rimraf": "6.0.1",
52
+ "typescript": "5.3.3"
57
53
  },
58
54
  "publishConfig": {
59
55
  "access": "public",
60
56
  "directory": "dist"
61
57
  },
62
58
  "scripts": {
63
- "build": "yarn webiny run build",
64
- "watch": "yarn webiny run watch"
59
+ "build": "node ../cli/bin.js run build",
60
+ "watch": "node ../cli/bin.js run watch"
65
61
  },
66
62
  "adio": {
67
63
  "ignore": {
68
64
  "dependencies": [
69
- "@types/web",
70
65
  "react-dom"
71
66
  ]
72
67
  }
73
68
  },
74
- "gitHead": "40d639c3665e384a5e2d26674d43ce26f3295e8c"
69
+ "gitHead": "fdd9228b5d2636463e8a34b6e0d26eea1e29c01d"
75
70
  }
@@ -1,6 +1,11 @@
1
1
  import { ApolloLink } from "apollo-link";
2
- import { DocumentNode } from "graphql";
2
+ import type { DocumentNode } from "graphql";
3
3
  import { ApolloLinkPlugin } from "./ApolloLinkPlugin";
4
+ declare module "graphql" {
5
+ interface DocumentNode {
6
+ __webiny__: Set<string>;
7
+ }
8
+ }
4
9
  interface Config {
5
10
  operationName: string;
6
11
  selectionPath: string;
@@ -10,6 +15,8 @@ export declare class AddQuerySelectionPlugin extends ApolloLinkPlugin {
10
15
  private readonly config;
11
16
  constructor(config: Config);
12
17
  createLink(): ApolloLink;
13
- addSelectionToQuery(operationName: string, query: DocumentNode): void;
18
+ addSelectionToQuery(operationName: string, document: DocumentNode): void;
19
+ private isProcessed;
20
+ private markProcessed;
14
21
  }
15
22
  export {};
@@ -1,132 +1,72 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.AddQuerySelectionPlugin = void 0;
9
-
10
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
-
12
- var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
13
-
14
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
-
16
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
-
18
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
19
-
20
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
21
-
22
- var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
23
-
24
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
25
-
26
- var _apolloLink = require("apollo-link");
27
-
28
- var _ApolloLinkPlugin2 = require("./ApolloLinkPlugin");
29
-
30
- var AddQuerySelectionPlugin = /*#__PURE__*/function (_ApolloLinkPlugin) {
31
- (0, _inherits2.default)(AddQuerySelectionPlugin, _ApolloLinkPlugin);
32
-
33
- var _super = (0, _createSuper2.default)(AddQuerySelectionPlugin);
34
-
35
- function AddQuerySelectionPlugin(config) {
36
- var _this;
37
-
38
- (0, _classCallCheck2.default)(this, AddQuerySelectionPlugin);
39
- _this = _super.call(this);
40
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "config", void 0);
41
- _this.config = config;
42
- return _this;
1
+ import { ApolloLink } from "apollo-link";
2
+ import { ApolloLinkPlugin } from "./ApolloLinkPlugin";
3
+ export class AddQuerySelectionPlugin extends ApolloLinkPlugin {
4
+ constructor(config) {
5
+ super();
6
+ this.config = config;
43
7
  }
44
-
45
- (0, _createClass2.default)(AddQuerySelectionPlugin, [{
46
- key: "createLink",
47
- value: function createLink() {
48
- var _this2 = this;
49
-
50
- return new _apolloLink.ApolloLink(function (operation, forward) {
51
- if (operation.operationName !== _this2.config.operationName) {
52
- return forward(operation);
53
- }
54
-
55
- _this2.addSelectionToQuery(operation.operationName, operation.query);
56
-
8
+ createLink() {
9
+ return new ApolloLink((operation, forward) => {
10
+ if (operation.operationName !== this.config.operationName) {
57
11
  return forward(operation);
58
- });
59
- }
60
- }, {
61
- key: "addSelectionToQuery",
62
- value: function addSelectionToQuery(operationName, query) {
63
- var _tree;
64
-
65
- if (operationName !== this.config.operationName) {
66
- return;
67
12
  }
13
+ this.addSelectionToQuery(operation.operationName, operation.query);
14
+ return forward(operation);
15
+ });
16
+ }
17
+ addSelectionToQuery(operationName, document) {
18
+ if (operationName !== this.config.operationName) {
19
+ return;
20
+ }
68
21
 
69
- var _this$config = this.config,
70
- addSelection = _this$config.addSelection,
71
- selectionPath = _this$config.selectionPath; // TODO: check if the selection is already in the query and don't add it again if not necessary.
72
-
73
- var firstQueryDefinition = query.definitions[0];
74
-
75
- if (!firstQueryDefinition) {
76
- return;
77
- } else if (!firstQueryDefinition.selectionSet) {
78
- return;
79
- }
80
-
81
- var tree = firstQueryDefinition.selectionSet.selections;
82
- var fields = selectionPath.split(".");
83
-
84
- var _iterator = (0, _createForOfIteratorHelper2.default)(fields),
85
- _step;
86
-
87
- try {
88
- fieldLoop: for (_iterator.s(); !(_step = _iterator.n()).done;) {
89
- var field = _step.value;
90
-
91
- var _iterator2 = (0, _createForOfIteratorHelper2.default)(tree),
92
- _step2;
93
-
94
- try {
95
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
96
- var selection = _step2.value;
97
-
98
- if (!selection.selectionSet) {
99
- continue;
100
- }
101
-
102
- if (selection.name.value === field) {
103
- tree = selection.selectionSet.selections;
104
- continue fieldLoop;
105
- }
106
- } // If we get here, it means we didn't find the necessary selection
107
-
108
- } catch (err) {
109
- _iterator2.e(err);
110
- } finally {
111
- _iterator2.f();
112
- }
113
-
114
- return;
22
+ // If this plugin already processed the given document (documents are always passed by reference),
23
+ // then we don't want to apply the selection again, to avoid adding duplicate selections.
24
+ if (this.isProcessed(document)) {
25
+ return;
26
+ }
27
+ this.markProcessed(document);
28
+ const {
29
+ addSelection,
30
+ selectionPath
31
+ } = this.config;
32
+ const firstQueryDefinition = document.definitions[0];
33
+ if (!firstQueryDefinition) {
34
+ return;
35
+ } else if (!firstQueryDefinition.selectionSet) {
36
+ return;
37
+ }
38
+ let tree = firstQueryDefinition.selectionSet.selections;
39
+ const fields = selectionPath.split(".");
40
+ fieldLoop: for (const field of fields) {
41
+ for (const selection of tree) {
42
+ if (!selection.selectionSet) {
43
+ continue;
44
+ }
45
+ if (selection.name.value === field) {
46
+ tree = selection.selectionSet.selections;
47
+ continue fieldLoop;
115
48
  }
116
- } catch (err) {
117
- _iterator.e(err);
118
- } finally {
119
- _iterator.f();
120
49
  }
121
- /**
122
- * We must cast because there are a lot of types that are not intertwined and TS is complaining
123
- */
124
-
125
-
126
- (_tree = tree).push.apply(_tree, (0, _toConsumableArray2.default)(addSelection.definitions[0].selectionSet.selections));
50
+ // If we get here, it means we didn't find the necessary selection
51
+ return;
127
52
  }
128
- }]);
129
- return AddQuerySelectionPlugin;
130
- }(_ApolloLinkPlugin2.ApolloLinkPlugin);
53
+ /**
54
+ * We must cast because there are a lot of types that are not intertwined and TS is complaining
55
+ */
56
+ tree.push(...addSelection.definitions[0].selectionSet.selections);
57
+ }
58
+ isProcessed(document) {
59
+ if (!document.hasOwnProperty("__webiny__")) {
60
+ document.__webiny__ = new Set();
61
+ }
62
+ return document.__webiny__.has(this.cacheKey);
63
+ }
64
+ markProcessed(document) {
65
+ if (!document.hasOwnProperty("__webiny__")) {
66
+ document.__webiny__ = new Set();
67
+ }
68
+ document.__webiny__.add(this.cacheKey);
69
+ }
70
+ }
131
71
 
132
- exports.AddQuerySelectionPlugin = AddQuerySelectionPlugin;
72
+ //# sourceMappingURL=AddQuerySelectionPlugin.js.map