@ikas/storefront 2.0.0-alpha.2 → 2.0.0-alpha.21

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 (178) hide show
  1. package/build/__generated__/global-types.d.ts +10 -2
  2. package/build/__generated__/global-types.js +1 -1
  3. package/build/analytics/facebookPixel.js +1 -1
  4. package/build/analytics/googleTagManager.js +1 -1
  5. package/build/analytics/head/index.js +1 -1
  6. package/build/analytics/ikas.js +1 -1
  7. package/build/api/apollo.js +1 -1
  8. package/build/api/blog/__generated__/getBlog.d.ts +14 -16
  9. package/build/api/blog/__generated__/listBlog.d.ts +14 -16
  10. package/build/api/blog/__generated__/listBlogCategory.d.ts +14 -16
  11. package/build/api/blog/__generated__/listBlogMetaData.d.ts +14 -16
  12. package/build/api/brand/__generated__/listProductBrand.d.ts +3 -3
  13. package/build/api/cart/__generated__/getCart.d.ts +2 -4
  14. package/build/api/cart/__generated__/saveItemToCart.d.ts +2 -4
  15. package/build/api/category/__generated__/listCategory.d.ts +3 -3
  16. package/build/api/checkout/__generated__/getCheckoutById.d.ts +2 -4
  17. package/build/api/checkout/__generated__/getOrder.d.ts +5 -11
  18. package/build/api/checkout/__generated__/listCheckoutSettings.d.ts +1 -1
  19. package/build/api/checkout/index.js +1 -1
  20. package/build/api/customer/__generated__/createOrderRefundRequest.d.ts +5 -11
  21. package/build/api/customer/__generated__/customerLogin.d.ts +12 -5
  22. package/build/api/customer/__generated__/customerSocialLogin.d.ts +161 -0
  23. package/build/api/customer/__generated__/getCustomerOrders.d.ts +5 -11
  24. package/build/api/customer/__generated__/getMyCustomer.d.ts +4 -5
  25. package/build/api/customer/__generated__/registerCustomer.d.ts +12 -5
  26. package/build/api/customer/__generated__/saveMyCustomer.d.ts +12 -5
  27. package/build/api/customer/index.d.ts +5 -0
  28. package/build/api/customer/index.js +1 -1
  29. package/build/api/customer-review/__generated__/listCustomerReviews.d.ts +14 -16
  30. package/build/api/raffle/__generated__/getRafflesByCustomerId.d.ts +3 -0
  31. package/build/api/raffle/__generated__/listRaffle.d.ts +14 -16
  32. package/build/api/raffle/__generated__/saveRaffleParticipant.d.ts +2 -2
  33. package/build/api/raffle/index.d.ts +1 -1
  34. package/build/api/raffle/index.js +1 -1
  35. package/build/api/variant-type/__generated__/listVariantType.d.ts +3 -7
  36. package/build/components/checkout/components/address-form/index.js +1 -1
  37. package/build/components/checkout/components/address-form/model.d.ts +8 -0
  38. package/build/components/checkout/components/cart-summary/cart-item/index.js +1 -1
  39. package/build/components/checkout/components/cart-summary/index.js +1 -1
  40. package/build/components/checkout/components/step-container/index.js +1 -1
  41. package/build/components/checkout/index.js +1 -1
  42. package/build/components/checkout/model.d.ts +2 -0
  43. package/build/components/checkout/model.js +1 -1
  44. package/build/components/checkout/steps/step-payment/payment-gateways/index.js +1 -1
  45. package/build/components/checkout/steps/step-payment/payment-gateways/installments/index.js +1 -1
  46. package/build/components/checkout/steps/step-shipping/index.js +1 -1
  47. package/build/components/checkout/steps/step-success/index.js +1 -1
  48. package/build/components/index.d.ts +1 -1
  49. package/build/components/page/ThemeComponent.js +1 -1
  50. package/build/components/page/head.js +1 -1
  51. package/build/components/page/index.js +1 -1
  52. package/build/components/page-editor/ThemeComponentEditor.d.ts +0 -3
  53. package/build/components/page-editor/ThemeComponentEditor.js +1 -1
  54. package/build/components/page-editor/index.d.ts +3 -1
  55. package/build/components/page-editor/index.js +1 -1
  56. package/build/components/page-editor/loader/index.d.ts +5 -1
  57. package/build/components/page-editor/loader/index.js +1 -1
  58. package/build/components/page-editor/loader/style.module.scss.js +1 -1
  59. package/build/components/page-editor/model.d.ts +6 -4
  60. package/build/components/page-editor/model.js +1 -1
  61. package/build/ext/@apollo/client/cache/inmemory/entityStore.js +1 -1
  62. package/build/ext/@apollo/client/cache/inmemory/inMemoryCache.js +1 -1
  63. package/build/ext/@apollo/client/cache/inmemory/policies.js +1 -1
  64. package/build/ext/@apollo/client/cache/inmemory/readFromStore.js +1 -1
  65. package/build/ext/@apollo/client/cache/inmemory/writeToStore.js +1 -1
  66. package/build/ext/@apollo/client/core/ApolloClient.js +1 -1
  67. package/build/ext/@apollo/client/core/LocalState.js +1 -1
  68. package/build/ext/@apollo/client/core/ObservableQuery.js +1 -1
  69. package/build/ext/@apollo/client/core/QueryManager.js +1 -1
  70. package/build/ext/@apollo/client/errors/index.js +1 -1
  71. package/build/ext/@apollo/client/ext/tslib/tslib.es6.js +15 -0
  72. package/build/ext/@apollo/client/link/context/index.js +1 -1
  73. package/build/ext/@apollo/client/link/core/ApolloLink.js +1 -1
  74. package/build/ext/@apollo/client/link/error/index.js +1 -1
  75. package/build/ext/@apollo/client/link/http/HttpLink.js +1 -1
  76. package/build/ext/@apollo/client/link/http/createHttpLink.js +1 -1
  77. package/build/ext/@apollo/client/link/http/selectHttpOptionsAndBody.js +1 -1
  78. package/build/ext/@apollo/client/link/utils/createOperation.js +1 -1
  79. package/build/ext/@apollo/client/utilities/common/mergeDeep.js +1 -1
  80. package/build/ext/@apollo/client/utilities/graphql/fragments.js +1 -1
  81. package/build/ext/@apollo/client/utilities/graphql/transform.js +1 -1
  82. package/build/ext/@apollo/client/utilities/observables/Concast.js +1 -1
  83. package/build/ext/ts-invariant/ext/tslib/tslib.es6.js +15 -0
  84. package/build/ext/ts-invariant/lib/invariant.esm.js +1 -1
  85. package/build/ext/tslib/tslib.es6.js +1 -1
  86. package/build/ikas.js +67 -2
  87. package/build/index.d.ts +1 -0
  88. package/build/index.js +1 -1
  89. package/build/models/data/blog/index.js +1 -1
  90. package/build/models/data/brand/index.js +1 -1
  91. package/build/models/data/category/index.js +1 -1
  92. package/build/models/data/checkout/index.js +1 -1
  93. package/build/models/data/checkout-settings/index.d.ts +1 -1
  94. package/build/models/data/checkout-settings/index.js +1 -1
  95. package/build/models/data/customer/address/index.d.ts +4 -1
  96. package/build/models/data/customer/address/index.js +1 -1
  97. package/build/models/data/image/index.js +1 -1
  98. package/build/models/data/index.d.ts +1 -0
  99. package/build/models/data/language/index.d.ts +6 -0
  100. package/build/models/data/order/address/index.d.ts +2 -1
  101. package/build/models/data/order/address/index.js +1 -1
  102. package/build/models/data/order/index.js +1 -1
  103. package/build/models/data/order/line-item/variant/index.js +1 -1
  104. package/build/models/data/product/index.js +1 -1
  105. package/build/models/data/product-filter/index.js +1 -1
  106. package/build/models/data/product-option-set/index.d.ts +4 -0
  107. package/build/models/data/product-option-set/index.js +1 -1
  108. package/build/models/data/raffle/index.d.ts +2 -1
  109. package/build/models/data/raffle/index.js +1 -1
  110. package/build/models/data/slider/index.d.ts +5 -0
  111. package/build/models/data/slider/index.js +1 -0
  112. package/build/models/theme/component/index.d.ts +9 -0
  113. package/build/models/theme/component/index.js +1 -1
  114. package/build/models/theme/component/prop/index.d.ts +21 -0
  115. package/build/models/theme/component/prop/index.js +1 -1
  116. package/build/models/theme/custom-data/index.d.ts +20 -1
  117. package/build/models/theme/custom-data/index.js +1 -1
  118. package/build/models/theme/settings/color/index.d.ts +14 -0
  119. package/build/models/theme/settings/color/index.js +1 -0
  120. package/build/models/theme/settings/{prop/favicon → favicon}/index.d.ts +0 -0
  121. package/build/models/theme/settings/{prop/favicon → favicon}/index.js +0 -0
  122. package/build/models/theme/settings/font-family/index.d.ts +5 -0
  123. package/build/models/theme/settings/font-family/index.js +1 -0
  124. package/build/models/theme/settings/index.d.ts +4 -2
  125. package/build/models/theme/settings/index.js +1 -1
  126. package/build/models/ui/product-detail/index.js +1 -1
  127. package/build/models/ui/product-list/index.d.ts +1 -1
  128. package/build/models/ui/product-list/index.js +1 -1
  129. package/build/models/ui/validator/form/account-info.js +1 -1
  130. package/build/models/ui/validator/form/address.js +1 -1
  131. package/build/models/ui/validator/form/register.js +1 -1
  132. package/build/pages/checkout.js +1 -1
  133. package/build/pages/editor.d.ts +4 -3
  134. package/build/pages/editor.js +1 -1
  135. package/build/providers/page-data-get.d.ts +1 -1
  136. package/build/providers/page-data-get.js +1 -1
  137. package/build/providers/page-data-init.d.ts +3 -1
  138. package/build/providers/page-data-init.js +1 -1
  139. package/build/providers/page-data-next.d.ts +2 -1
  140. package/build/providers/page-data-next.js +1 -1
  141. package/build/providers/prop-value/custom.d.ts +1 -0
  142. package/build/providers/prop-value/custom.js +1 -1
  143. package/build/providers/prop-value/slider.d.ts +11 -0
  144. package/build/providers/prop-value/slider.js +1 -0
  145. package/build/scripts/generators/api/index.d.ts +3 -3
  146. package/build/scripts/generators/api/index.js +1 -0
  147. package/build/scripts/generators/api/info.d.ts +4 -4
  148. package/build/scripts/generators/api/info.js +1 -0
  149. package/build/scripts/generators/components/index.d.ts +4 -4
  150. package/build/scripts/generators/components/index.js +1 -0
  151. package/build/scripts/generators/config/content.d.ts +4 -3
  152. package/build/scripts/generators/config/content.js +1 -0
  153. package/build/scripts/generators/config/index.d.ts +6 -6
  154. package/build/scripts/generators/config/index.js +1 -0
  155. package/build/scripts/generators/index.d.ts +7 -0
  156. package/build/scripts/generators/pages/index.d.ts +4 -4
  157. package/build/scripts/generators/pages/index.js +1 -0
  158. package/build/scripts/generators/pages/info.js +1 -0
  159. package/build/scripts/generators/store/content.js +1 -0
  160. package/build/scripts/generators/store/index.d.ts +2 -2
  161. package/build/scripts/generators/store/index.js +1 -0
  162. package/build/scripts/generators/theme/index.d.ts +4 -4
  163. package/build/scripts/generators/theme/index.js +1 -0
  164. package/build/scripts/generators/types/index.d.ts +15 -0
  165. package/build/scripts/generators/types/index.js +1 -0
  166. package/build/store/cart.d.ts +6 -7
  167. package/build/store/cart.js +1 -1
  168. package/build/store/customer.d.ts +19 -0
  169. package/build/store/customer.js +1 -1
  170. package/build/storefront/index.d.ts +5 -3
  171. package/build/storefront/index.js +1 -1
  172. package/build/utils/fs.d.ts +2 -2
  173. package/build/utils/fs.js +1 -0
  174. package/build/utils/google-fonts.d.ts +2 -0
  175. package/build/utils/google-fonts.js +1 -0
  176. package/package.json +8 -7
  177. package/build/models/theme/settings/prop/color/index.d.ts +0 -7
  178. package/build/models/theme/settings/prop/color/index.js +0 -1
@@ -1,2 +1,6 @@
1
1
  import * as React from "react";
2
- export declare const IkasEditorComponentLoader: React.FC;
2
+ declare type Props = {
3
+ isFullPage?: boolean;
4
+ };
5
+ export declare const IkasEditorComponentLoader: React.FC<Props>;
6
+ export {};
@@ -1 +1 @@
1
- import*as e from"react";import r from"./style.module.scss.js";var t=function(){return e.createElement("div",{className:r.Container},e.createElement("div",{className:r.loader}))};export{t as IkasEditorComponentLoader};
1
+ import*as e from"react";import a from"./style.module.scss.js";var r=function(r){var t=r.isFullPage;return e.createElement("div",{className:[a.Container,t?a.fullPage:""].join(" ")},e.createElement("div",{className:a.loader}))};export{r as IkasEditorComponentLoader};
@@ -1 +1 @@
1
- import e from'../../../ext/style-inject/dist/style-inject.es.js';var n={Container:"style-module_Container__1eB6f",loader:"style-module_loader__1ahiK",load8:"style-module_load8__1jjFg"};e(".style-module_Container__1eB6f {\n width: 100%;\n height: 300px;\n background-color: white;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n.style-module_Container__1eB6f .style-module_loader__1ahiK,\n.style-module_Container__1eB6f .style-module_loader__1ahiK:after {\n border-radius: 50%;\n width: 5em;\n height: 5em;\n}\n.style-module_Container__1eB6f .style-module_loader__1ahiK {\n font-size: 6px;\n position: relative;\n text-indent: -9999em;\n border-top: 0.5em solid rgba(255, 255, 255, 0.2);\n border-right: 0.5em solid rgba(255, 255, 255, 0.2);\n border-bottom: 0.5em solid rgba(255, 255, 255, 0.2);\n border-left: 0.5em solid black;\n -webkit-transform: translateZ(0);\n -ms-transform: translateZ(0);\n transform: translateZ(0);\n -webkit-animation: style-module_load8__1jjFg 1.1s infinite linear;\n animation: style-module_load8__1jjFg 1.1s infinite linear;\n}\n@-webkit-keyframes style-module_load8__1jjFg {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n@keyframes style-module_load8__1jjFg {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}");export{n as default};
1
+ import e from'../../../ext/style-inject/dist/style-inject.es.js';var n={Container:"style-module_Container__1eB6f",fullPage:"style-module_fullPage__3P2Pz",loader:"style-module_loader__1ahiK",load8:"style-module_load8__1jjFg"};e(".style-module_Container__1eB6f {\n width: 100%;\n height: 300px;\n background-color: white;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n.style-module_Container__1eB6f.style-module_fullPage__3P2Pz {\n height: 100vh;\n}\n.style-module_Container__1eB6f .style-module_loader__1ahiK,\n.style-module_Container__1eB6f .style-module_loader__1ahiK:after {\n border-radius: 50%;\n width: 5em;\n height: 5em;\n}\n.style-module_Container__1eB6f .style-module_loader__1ahiK {\n font-size: 6px;\n position: relative;\n text-indent: -9999em;\n border-top: 0.5em solid rgba(255, 255, 255, 0.2);\n border-right: 0.5em solid rgba(255, 255, 255, 0.2);\n border-bottom: 0.5em solid rgba(255, 255, 255, 0.2);\n border-left: 0.5em solid black;\n -webkit-transform: translateZ(0);\n -ms-transform: translateZ(0);\n transform: translateZ(0);\n -webkit-animation: style-module_load8__1jjFg 1.1s infinite linear;\n animation: style-module_load8__1jjFg 1.1s infinite linear;\n}\n@-webkit-keyframes style-module_load8__1jjFg {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n@keyframes style-module_load8__1jjFg {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}");export{n as default};
@@ -1,7 +1,7 @@
1
1
  import { NextRouter } from "next/router.js";
2
2
  import { IkasThemePage, IkasThemePageComponent, IkasTheme, IkasThemeComponent } from "../../models";
3
3
  import { IkasPageDataProvider } from "../../providers/page-data-get";
4
- import { IkasThemePageSpecification } from "../../models/theme/page";
4
+ import { IkasThemePageSpecification, IkasThemePageType } from "../../models/theme/page";
5
5
  export default class IkasPageEditorViewModel {
6
6
  theme?: IkasTheme | null;
7
7
  page?: IkasThemePage | null;
@@ -12,7 +12,6 @@ export default class IkasPageEditorViewModel {
12
12
  locale: string;
13
13
  translations?: Record<string, any>;
14
14
  pageParams: Record<string, any>;
15
- queryParams: Record<string, any>;
16
15
  apiKey?: string | null;
17
16
  pageDataProvider?: IkasPageDataProvider | null;
18
17
  router: NextRouter;
@@ -26,8 +25,10 @@ export default class IkasPageEditorViewModel {
26
25
  onClick: (id: string) => void;
27
26
  onMouseOver: (id: string) => void;
28
27
  onMouseLeave: (id: string) => void;
28
+ onPageChange: (url: string) => Promise<void>;
29
+ getVariantIdFromParams(productId: string, queryParamsStr: string): Promise<string | undefined>;
29
30
  sendMessage: (type: BridgeMessageType, data?: any) => void;
30
- getPagePropValues: () => Promise<void>;
31
+ getPagePropValues: (theme: IkasTheme, pageType: IkasThemePageType, pageParams: Record<string, any>) => Promise<IkasPageDataProvider>;
31
32
  setComponentRef: (element: React.ElementType, component: IkasThemePageComponent) => void;
32
33
  isScrolledIntoView: (el: HTMLElement) => boolean;
33
34
  handleUpdateFrameData: (data: any) => Promise<void>;
@@ -61,5 +62,6 @@ export declare enum BridgeMessageType {
61
62
  SET_SELECTED_COMPONENT = "SET_SELECTED_COMPONENT",
62
63
  SET_HOVERED_COMPONENT = "SET_HOVERED_COMPONENT",
63
64
  SCROLL_TO_COMPONENT = "SCROLL_TO_COMPONENT",
64
- UPDATE_THEME_SETTINGS = "UPDATE_THEME_SETTINGS"
65
+ UPDATE_THEME_SETTINGS = "UPDATE_THEME_SETTINGS",
66
+ EDITOR_PAGE_CHANGE = "EDITOR_PAGE_CHANGE"
65
67
  }
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t}from'../../ext/tslib/tslib.es6.js';import{makeAutoObservable as o,runInAction as n}from"mobx";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import{IkasTheme as i}from"../../models/theme/theme.js";import{IkasThemePageType as r}from"../../models/theme/page/index.js";import{IkasThemePageComponent as s}from"../../models/theme/page/component/index.js";import{IkasThemeComponent as a}from"../../models/theme/component/index.js";import{IkasThemeComponentPropType as d}from"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import{IkasThemeSettings as p}from"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{IkasPageDataProvider as m}from"../../providers/page-data-get.js";import{IkasPageDataInit as l}from"../../providers/page-data-init.js";import"../../api/blog/index.js";import"../../api/brand/index.js";import"../../api/cart/index.js";import"../../api/category/index.js";import"../../api/checkout/index.js";import"../../api/city/index.js";import"../../api/country/index.js";import"../../api/customer/index.js";import"../../api/customer-review/index.js";import"../../api/district/index.js";import"../../api/html-meta-data/index.js";import"../../api/merchant/index.js";import"../../api/product-search/index.js";import{apollo as u}from"../../api/apollo.js";import"../../api/favorite-product/index.js";import"../../api/contact-form/index.js";import"../../api/state/index.js";import"../../api/product-option-set/index.js";import"../../api/raffle/index.js";import"../../api/back-in-stock-reminder/index.js";import{IkasStorefrontConfig as c}from"../../storefront/index.js";import{IkasStorefront as h}from"../../models/data/storefront/index.js";var f,g=function(){function g(g){var P=this;this.theme=null,this.page=null,this.selectedPageComponentId=null,this.hoveredPageComponentId=null,this.componentRefs={},this.isLoading=!1,this.locale="en",this.pageParams={},this.queryParams={},this.apiKey=null,this.pageDataProvider=null,this.startMessaging=function(){window.addEventListener("message",P.onMessage,!1),P.sendMessage(f.FRAME_DID_LOAD,"0.2.0")},this.onMessage=function(o){return e(P,void 0,void 0,(function(){var e,n;return t(this,(function(t){switch(t.label){case 0:switch(e=o.data.type,n=o.data.data,e){case f.UPDATE_FRAME_DATA:return[3,1];case f.UPDATE_PROP_VALUE:return[3,3];case f.UPDATE_PAGE_PARAMS:return[3,5];case f.UPDATE_PAGE_COMPONENT_ORDER:return[3,7];case f.ADD_COMPONENT:return[3,9];case f.DELETE_COMPONENT:return[3,10];case f.UPDATE_COMPONENT:return[3,11];case f.ADD_PAGE_COMPONENT:return[3,12];case f.DELETE_PAGE_COMPONENT:return[3,14];case f.SET_SELECTED_COMPONENT:return[3,15];case f.SET_HOVERED_COMPONENT:return[3,16];case f.SCROLL_TO_COMPONENT:return[3,17];case f.UPDATE_THEME_SETTINGS:return[3,18]}return[3,19];case 1:return[4,this.handleUpdateFrameData(n)];case 2:case 4:case 6:case 8:case 13:return t.sent(),[3,20];case 3:return[4,this.handleUpdatePropValue(n)];case 5:return[4,this.handleUpdatePageParams(n)];case 7:return[4,this.handleUpdatePageComponentOrder(n)];case 9:return this.handleAddNewComponent(n),[3,20];case 10:return this.handleDeleteComponent(n),[3,20];case 11:return this.handleUpdateComponent(n),[3,20];case 12:return[4,this.handleAddNewPageComponent(n)];case 14:return this.handleDeletePageComponent(n),[3,20];case 15:return this.handleSetSelectedComponent(n),[3,20];case 16:return this.handleSetHoveredComponent(n),[3,20];case 17:return this.handleScrollToComponent(n),[3,20];case 18:return this.updateThemeSettings(n),[3,20];case 19:return[3,20];case 20:return[2]}}))}))},this.onClick=function(e){P.sendMessage(f.COMPONENT_CLICK,{componentId:e})},this.onMouseOver=function(e){P.sendMessage(f.COMPONENT_MOUSE_OVER,{componentId:e})},this.onMouseLeave=function(e){P.sendMessage(f.COMPONENT_MOUSE_LEAVE,{componentId:e})},this.sendMessage=function(e,t){window.parent.postMessage({type:e,data:t},"*")},this.getPagePropValues=function(){return e(P,void 0,void 0,(function(){var e,o,i,s,a,d=this;return t(this,(function(t){switch(t.label){case 0:return e=new m(this.theme,this.pageParams,null===(o=this.page)||void 0===o?void 0:o.type),((null===(i=this.pageParams)||void 0===i?void 0:i.blogId)||(null===(s=this.pageParams)||void 0===s?void 0:s.blogCategoryId))&&(e.possiblePageTypes=[r.BLOG,r.BLOG_CATEGORY]),(null===(a=this.pageParams)||void 0===a?void 0:a.raffleId)&&(e.possiblePageTypes=[r.RAFFLE_DETAIL]),this.isLoading=!0,[4,e.getPageData()];case 1:return t.sent(),e.pageSpecificData&&l.setPageSpecificData(JSON.stringify(e.pageSpecificData),this.page.type,!0),e.pageComponentPropValues=l.initPropValues(JSON.stringify(e.pageComponentPropValues),this.router,JSON.stringify(this.theme.settings),!1),n((function(){d.pageDataProvider=e,d.isLoading=!1})),[2]}}))}))},this.setComponentRef=function(e,t){P.componentRefs[t.id]=e},this.isScrolledIntoView=function(e){var t=e.getBoundingClientRect(),o=t.top,n=t.bottom;return o<window.innerHeight&&n>=0&&n<window.innerHeight&&o>0},this.handleUpdateFrameData=function(o){return e(P,void 0,void 0,(function(){var e,n,r,s=this;return t(this,(function(t){switch(t.label){case 0:return this.theme=new i(o.theme),this.page=this.theme.pages.find((function(e){return e.id===o.selectedPage.id})),this.pageParams=o.pageParams,this.queryParams=o.queryParams,this.apiKey=o.apiKey,this.locale=o.locale||"en",this.translations=o.translations||void 0,(e=o.storefront)&&(n=new h(e),r=n.routings.find((function(e){return e.locale===s.locale})),c.storefrontId=n.id,c.storefrontRoutingId=null==r?void 0:r.id,n.mainStorefrontThemeId&&(c.storefrontThemeId=n.mainStorefrontThemeId),n.salesChannelId&&(c.salesChannelId=n.salesChannelId),(null==r?void 0:r.priceListId)&&(c.priceListId=r.priceListId),c.routings=n.routings,c.stockPreference=this.theme.settings.stockPreference),this.translations&&(c.translations=this.translations),c.isEditor=!0,u.createApolloClient(this.apiKey||void 0),window.editorApiKey=o.apiKey,[4,this.getPagePropValues()];case 1:return t.sent(),[2]}}))}))},this.handleUpdatePropValue=function(o){return e(P,void 0,void 0,(function(){var e,i,r,s,a,p,m,u,c=this;return t(this,(function(t){switch(t.label){case 0:return e=o.propName,i=o.value,(r=null===(m=null===(p=this.selectedComponent)||void 0===p?void 0:p.props)||void 0===m?void 0:m.find((function(t){return t.name===e})))&&this.selectedPageComponent?(s=null===(u=this.pageDataProvider)||void 0===u?void 0:u.pageComponentPropValues.find((function(e){return e.pageComponent.id===c.selectedPageComponentId})),this.selectedPageComponent.propValues[e]=i,this.pageDataProvider?[4,this.pageDataProvider.getPageComponentPropValue(this.selectedPageComponent,r)]:[2]):[2];case 1:return a=t.sent(),n((function(){s&&(s.propValues[e]=a,r.type===d.CUSTOM?l.initCustomDataPropValue(r,a,s,c.router,c.theme.settings,!0):r.type===d.COMPONENT?l.initComponentPropValue(r,a,s,c.router,c.theme.settings,!0):r.type===d.COMPONENT_LIST&&l.initComponentListPropValue(r,a,s,c.router,c.theme.settings,!0))})),[2]}}))}))},this.handleUpdatePageParams=function(o){return e(P,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return this.pageParams=o.pageParams,this.queryParams=o.queryParams,[4,this.getPagePropValues()];case 1:return e.sent(),[2]}}))}))},this.handleUpdatePageComponentOrder=function(o){return e(P,void 0,void 0,(function(){return t(this,(function(e){return this.specification?this.specification.components=o.pageComponents.map((function(e){return new s(e)})):this.page.components=o.pageComponents.map((function(e){return new s(e)})),[2]}))}))},this.handleAddNewComponent=function(e){var t,o=new a(e.component);null===(t=P.theme)||void 0===t||t.components.push(o)},this.handleDeleteComponent=function(e){var t,o;(null===(t=P.theme)||void 0===t?void 0:t.components)&&(P.theme.components=P.theme.components.filter((function(t){return t.id!==e.componentId})));var n=P.pageComponents.filter((function(t){return t.componentId!==e.componentId}))||[];P.specification&&P.specification.components&&(P.specification.components=n),!P.specification&&(null===(o=P.page)||void 0===o?void 0:o.components)&&(P.page.components=n)},this.handleUpdateComponent=function(e){var t=P.theme.components.findIndex((function(t){return t.id===e.component.id}));-1!==t&&(P.theme.components[t]=new a(e.component))},this.handleAddNewPageComponent=function(o){return e(P,void 0,void 0,(function(){var e,i,r=this;return t(this,(function(t){switch(t.label){case 0:return e=new s(o.pageComponent),this.pageComponents.some((function(t){return t.id===e.id}))?[2]:[4,this.pageDataProvider.getPageComponentPropValues(e)];case 1:return i=t.sent(),n((function(){i.component.props.filter((function(e){return e.type===d.CUSTOM})).forEach((function(e){l.initCustomDataPropValue(e,i.propValues[e.name],i,r.router,r.theme.settings,!0)})),r.pageDataProvider.pageComponentPropValues.push(i),r.pageComponents.push(e)})),[2]}}))}))},this.handleDeletePageComponent=function(e){P.specification?P.specification.components=P.pageComponents.filter((function(t){return t.id!==e.pageComponentId})):P.page.components=P.pageComponents.filter((function(t){return t.id!==e.pageComponentId}))},this.handleSetSelectedComponent=function(e){P.selectedPageComponentId=e.componentId},this.handleSetHoveredComponent=function(e){P.hoveredPageComponentId=e.componentId},this.handleScrollToComponent=function(e){var t=e.componentId,o=P.componentRefs[t];o&&(P.isScrolledIntoView(o)||window.scrollTo({top:o.offsetTop,behavior:"smooth"}))},this.updateThemeSettings=function(e){var t=e.settings;P.theme&&(P.theme.settings=new p(t))},this.router=g,o(this),this.startMessaging()}return Object.defineProperty(g.prototype,"specification",{get:function(){var e,t,o,n,i,s,a,d=this,p=this.page;return(null==p?void 0:p.type)===r.PRODUCT&&(a=null===(e=p.specifications)||void 0===e?void 0:e.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.productId)}))),(null==p?void 0:p.type)===r.CATEGORY&&(a=null===(t=p.specifications)||void 0===t?void 0:t.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.categoryId)}))),(null==p?void 0:p.type)===r.BRAND&&(a=null===(o=p.specifications)||void 0===o?void 0:o.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.brandId)}))),(null==p?void 0:p.type)===r.BLOG&&(a=null===(n=p.specifications)||void 0===n?void 0:n.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.blogId)}))),(null==p?void 0:p.type)===r.BLOG_CATEGORY&&(a=null===(i=p.specifications)||void 0===i?void 0:i.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.blogCategoryId)}))),(null==p?void 0:p.type)===r.RAFFLE_DETAIL&&(a=null===(s=p.specifications)||void 0===s?void 0:s.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.raffleId)}))),a},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"pageComponents",{get:function(){var e;return this.specification?this.specification.components:(null===(e=this.page)||void 0===e?void 0:e.components)||[]},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"selectedPageComponent",{get:function(){var e=this;return this.pageComponents.find((function(t){return t.id===e.selectedPageComponentId}))},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"selectedComponent",{get:function(){var e,t=this;return null===(e=this.theme)||void 0===e?void 0:e.components.find((function(e){var o;return e.id===(null===(o=t.selectedPageComponent)||void 0===o?void 0:o.componentId)}))},enumerable:!1,configurable:!0}),g}();!function(e){e.FRAME_DID_LOAD="FRAME_DID_LOAD",e.UPDATE_FRAME_DATA="UPDATE_FRAME_DATA",e.UPDATE_PROP_VALUE="UPDATE_PROP_VALUE",e.UPDATE_PAGE_PARAMS="UPDATE_PAGE_PARAMS",e.UPDATE_PAGE_COMPONENT_ORDER="UPDATE_PAGE_COMPONENT_ORDER",e.ADD_COMPONENT="ADD_COMPONENT",e.DELETE_COMPONENT="DELETE_COMPONENT",e.UPDATE_COMPONENT="UPDATE_COMPONENT",e.ADD_PAGE_COMPONENT="ADD_PAGE_COMPONENT",e.DELETE_PAGE_COMPONENT="DELETE_PAGE_COMPONENT",e.COMPONENT_MOUSE_OVER="COMPONENT_MOUSE_OVER",e.COMPONENT_MOUSE_LEAVE="COMPONENT_MOUSE_LEAVE",e.COMPONENT_CLICK="COMPONENT_CLICK",e.SET_SELECTED_COMPONENT="SET_SELECTED_COMPONENT",e.SET_HOVERED_COMPONENT="SET_HOVERED_COMPONENT",e.SCROLL_TO_COMPONENT="SCROLL_TO_COMPONENT",e.UPDATE_THEME_SETTINGS="UPDATE_THEME_SETTINGS"}(f||(f={}));export{f as BridgeMessageType,g as default};
1
+ import{__awaiter as e,__generator as t}from'../../ext/tslib/tslib.es6.js';import{makeAutoObservable as n,runInAction as i}from"mobx";import{IkasBlogMetadataTargetType as o}from"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import{IkasHTMLMetaDataTargetType as a}from"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import{IkasTheme as r}from"../../models/theme/theme.js";import{IkasThemePageType as s}from"../../models/theme/page/index.js";import{IkasThemePageComponent as d}from"../../models/theme/page/component/index.js";import{IkasThemeComponent as p}from"../../models/theme/component/index.js";import{IkasThemeComponentPropType as u}from"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import{IkasThemeSettings as l}from"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{IkasPageDataProvider as c}from"../../providers/page-data-get.js";import{IkasPageDataInit as m}from"../../providers/page-data-init.js";import{IkasBlogAPI as h}from"../../api/blog/index.js";import"../../api/brand/index.js";import"../../api/cart/index.js";import"../../api/category/index.js";import"../../api/checkout/index.js";import"../../api/city/index.js";import"../../api/country/index.js";import"../../api/customer/index.js";import"../../api/customer-review/index.js";import"../../api/district/index.js";import{IkasHTMLMetaDataAPI as g}from"../../api/html-meta-data/index.js";import"../../api/merchant/index.js";import{IkasProductSearchAPI as f}from"../../api/product-search/index.js";import{apollo as P}from"../../api/apollo.js";import"../../api/favorite-product/index.js";import"../../api/contact-form/index.js";import"../../api/state/index.js";import"../../api/product-option-set/index.js";import{IkasRaffleAPI as E}from"../../api/raffle/index.js";import"../../api/back-in-stock-reminder/index.js";import{IkasStorefrontConfig as v}from"../../storefront/index.js";import{IkasStorefront as O}from"../../models/data/storefront/index.js";var C,T=function(){function T(f){var T=this;this.theme=null,this.page=null,this.selectedPageComponentId=null,this.hoveredPageComponentId=null,this.componentRefs={},this.isLoading=!1,this.locale="en",this.pageParams={},this.apiKey=null,this.pageDataProvider=null,this.startMessaging=function(){window.addEventListener("message",T.onMessage,!1),T.sendMessage(C.FRAME_DID_LOAD,"2.0.0")},this.onMessage=function(n){return e(T,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:switch(e=n.data.type,i=n.data.data,e){case C.UPDATE_FRAME_DATA:return[3,1];case C.UPDATE_PROP_VALUE:return[3,3];case C.UPDATE_PAGE_PARAMS:return[3,5];case C.UPDATE_PAGE_COMPONENT_ORDER:return[3,7];case C.ADD_COMPONENT:return[3,9];case C.DELETE_COMPONENT:return[3,10];case C.UPDATE_COMPONENT:return[3,11];case C.ADD_PAGE_COMPONENT:return[3,12];case C.DELETE_PAGE_COMPONENT:return[3,14];case C.SET_SELECTED_COMPONENT:return[3,15];case C.SET_HOVERED_COMPONENT:return[3,16];case C.SCROLL_TO_COMPONENT:return[3,17];case C.UPDATE_THEME_SETTINGS:return[3,18]}return[3,19];case 1:return[4,this.handleUpdateFrameData(i)];case 2:case 4:case 6:case 8:case 13:return t.sent(),[3,20];case 3:return[4,this.handleUpdatePropValue(i)];case 5:return[4,this.handleUpdatePageParams(i)];case 7:return[4,this.handleUpdatePageComponentOrder(i)];case 9:return this.handleAddNewComponent(i),[3,20];case 10:return this.handleDeleteComponent(i),[3,20];case 11:return this.handleUpdateComponent(i),[3,20];case 12:return[4,this.handleAddNewPageComponent(i)];case 14:return this.handleDeletePageComponent(i),[3,20];case 15:return this.handleSetSelectedComponent(i),[3,20];case 16:return this.handleSetHoveredComponent(i),[3,20];case 17:return this.handleScrollToComponent(i),[3,20];case 18:return this.updateThemeSettings(i),[3,20];case 19:return[3,20];case 20:return[2]}}))}))},this.onClick=function(e){T.sendMessage(C.COMPONENT_CLICK,{componentId:e})},this.onMouseOver=function(e){T.sendMessage(C.COMPONENT_MOUSE_OVER,{componentId:e})},this.onMouseLeave=function(e){T.sendMessage(C.COMPONENT_MOUSE_LEAVE,{componentId:e})},this.onPageChange=function(n){return e(T,void 0,void 0,(function(){var e,r,d,p,u,l,c,m,f,P=this;return t(this,(function(t){switch(t.label){case 0:return e=n.slice(1),r=e.split("?"),e=r[0],d=r[1],this.pageParams={},n.startsWith("/account/orders/")?p=s.ORDER_DETAIL:n.startsWith("/account/orders")?p=s.ORDERS:n.startsWith("/account/addresses")?p=s.ADDRESSES:n.startsWith("/account/favorite-products")?p=s.FAVORITE_PRODUCTS:n.startsWith("/account/forgot-password")?p=s.FORGOT_PASSWORD:n.startsWith("/account/login")?p=s.LOGIN:n.startsWith("/account/raffles")?p=s.RAFFLE_ACCOUNT:n.startsWith("/account/recover-password")?p=s.RECOVER_PASSWORD:n.startsWith("/account/register")?p=s.REGISTER:n.startsWith("/account")?p=s.ACCOUNT:n.startsWith("/blog/")?p=s.BLOG:n.startsWith("/blog")?p=s.BLOG_INDEX:n.startsWith("/pages")?(p=s.CUSTOM,this.pageParams={slug:e.split("/")[1]}):p=n.startsWith("/raffle/")?s.RAFFLE_DETAIL:n.startsWith("/raffle")?s.RAFFLE:n.startsWith("/404")?s.NOT_FOUND:n.startsWith("/cart")?s.CART:n.startsWith("/checkout")?s.CHECKOUT:"/"===n?s.INDEX:n.startsWith("/search")?s.SEARCH:s.PRODUCT,console.log("page change",p),p!==s.PRODUCT?[3,6]:[4,g.listHTMLMetaData(e)];case 1:return(l=t.sent()).length?(c=l[0]).targetType!==a.PRODUCT?[3,3]:[4,this.getVariantIdFromParams(c.targetId,d)]:[3,5];case 2:return u=t.sent(),this.pageParams={productId:c.targetId,variantId:u,slug:e},[3,4];case 3:if(c.targetType===a.CATEGORY)p=s.CATEGORY,this.pageParams={categoryId:c.targetId,slug:e};else{if(c.targetType!==a.BRAND)return[2];p=s.BRAND,this.pageParams={brandId:c.targetId,slug:e}}t.label=4;case 4:return[3,6];case 5:return[2];case 6:return p!==s.BLOG?[3,8]:[4,h.listBlogMetaData(e)];case 7:if(!(l=t.sent()).length)return[2];if((c=l[0]).targetType===o.BLOG)this.pageParams={blogId:c.targetId,slug:e};else{if(c.targetType!==o.BLOG_CATEGORY)return[2];p=s.BLOG_CATEGORY,this.pageParams={blogCategoryId:c.targetId,slug:e}}t.label=8;case 8:return p!==s.RAFFLE_DETAIL?[3,10]:[4,E.listRaffleMetaData(e)];case 9:if(!(l=t.sent()).length)return[2];c=l[0],this.pageParams={raffleId:c.targetId,slug:e},t.label=10;case 10:return[4,this.getPagePropValues(this.theme,p,this.pageParams)];case 11:return m=t.sent(),i((function(){var e,t;v.store.currentPageType=p,P.pageDataProvider=m,p===s.CUSTOM?P.page=null===(e=P.theme)||void 0===e?void 0:e.pages.find((function(e){return e.type===p&&e.slug===P.pageParams.slug})):P.page=null===(t=P.theme)||void 0===t?void 0:t.pages.find((function(e){return e.type===p})),requestAnimationFrame((function(){document.body.scrollTop=0,document.scrollingElement&&(document.scrollingElement.scrollTop=0)}))})),this.sendMessage(C.EDITOR_PAGE_CHANGE,{pageType:p,pageParams:this.pageParams,pageSpecificData:(null===(f=this.pageDataProvider)||void 0===f?void 0:f.pageSpecificData)||null}),[2]}}))}))},this.sendMessage=function(e,t){window.parent.postMessage({type:e,data:JSON.parse(JSON.stringify(t))},"*")},this.getPagePropValues=function(n,i,o){return e(T,void 0,void 0,(function(){var e,a,r;return t(this,(function(t){switch(t.label){case 0:return e=new c(n,o,i),(o.blogId||o.blogCategoryId)&&(e.possiblePageTypes=[s.BLOG,s.BLOG_CATEGORY]),o.raffleId&&(e.possiblePageTypes=[s.RAFFLE_DETAIL]),[4,e.getPageData()];case 1:return t.sent(),e.pageSpecificData&&(m.setPageSpecificData(JSON.stringify(e.pageSpecificData),i,!0),i===s.PRODUCT&&m.pageSpecificData&&(a=m.pageSpecificData,(r=a.product.variants.find((function(e){return e.id===o.variantId})))&&(a.selectedVariantValues=r.variantValues))),e.pageComponentPropValues=m.initPropValues(JSON.stringify(e.pageComponentPropValues),this.router,JSON.stringify(n.settings),!1),[2,e]}}))}))},this.setComponentRef=function(e,t){T.componentRefs[t.id]=e},this.isScrolledIntoView=function(e){var t=e.getBoundingClientRect(),n=t.top,i=t.bottom;return n<window.innerHeight&&i>=0&&i<window.innerHeight&&n>0},this.handleUpdateFrameData=function(n){return e(T,void 0,void 0,(function(){var e,i,o,a,s=this;return t(this,(function(t){switch(t.label){case 0:return this.theme=new r(n.theme),this.page=this.theme.pages.find((function(e){return e.id===n.selectedPage.id})),this.pageParams=n.pageParams,this.apiKey=n.apiKey,this.locale=n.locale||"en",this.translations=n.translations||void 0,this.page?((e=n.storefront)&&(i=new O(e),o=i.routings.find((function(e){return e.locale===s.locale})),v.storefrontId=i.id,v.storefrontRoutingId=null==o?void 0:o.id,i.mainStorefrontThemeId&&(v.storefrontThemeId=i.mainStorefrontThemeId),i.salesChannelId&&(v.salesChannelId=i.salesChannelId),(null==o?void 0:o.priceListId)&&(v.priceListId=o.priceListId),v.routings=i.routings,v.stockPreference=this.theme.settings.stockPreference),this.translations&&(v.translations=this.translations),v.isEditor=!0,P.createApolloClient(this.apiKey||void 0),window.editorApiKey=n.apiKey,this.isLoading=!0,[4,this.getPagePropValues(this.theme,this.page.type,this.pageParams||{})]):[2];case 1:return a=t.sent(),this.pageDataProvider=a,this.isLoading=!1,[2]}}))}))},this.handleUpdatePropValue=function(n){return e(T,void 0,void 0,(function(){var e,o,a,r,s,d,p,l,c=this;return t(this,(function(t){switch(t.label){case 0:return e=n.propName,o=n.value,(a=null===(p=null===(d=this.selectedComponent)||void 0===d?void 0:d.props)||void 0===p?void 0:p.find((function(t){return t.name===e})))&&this.selectedPageComponent?(r=null===(l=this.pageDataProvider)||void 0===l?void 0:l.pageComponentPropValues.find((function(e){return e.pageComponent.id===c.selectedPageComponentId})),this.selectedPageComponent.propValues[e]=o,this.pageDataProvider?[4,this.pageDataProvider.getPageComponentPropValue(this.selectedPageComponent,a)]:[2]):[2];case 1:return s=t.sent(),[4,this.pageDataProvider.setLinkSlugs()];case 2:return t.sent(),i((function(){r&&(r.propValues[e]=s,a.type===u.CUSTOM?m.initCustomDataPropValue(a,s,r,c.router,c.theme.settings,!0):a.type===u.COMPONENT?m.initComponentPropValue(a,s,r,c.router,c.theme.settings,!0):a.type===u.COMPONENT_LIST?m.initComponentListPropValue(a,s,r,c.router,c.theme.settings,!0):a.type===u.PRODUCT_DETAIL?m.initProductDetailPropValue(a,s,r,c.router):a.type===u.CATEGORY?m.initCategoryPropValue(a,s,r):a.type===u.BRAND?m.initBrandPropValue(a,s,r):a.type===u.BLOG?m.initBlogPropValue(a,s,r):a.type===u.BLOG_CATEGORY?m.initBlogCategoryPropValue(a,s,r):a.type===u.RAFFLE?m.initRafflePropValue(a,s,r):a.type!==u.LINK&&a.type!==u.LIST_OF_LINK||m.initLinkPropValue(a,s,r))})),[2]}}))}))},this.handleUpdatePageParams=function(n){return e(T,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.pageParams=n.pageParams,this.isLoading=!0,[4,this.getPagePropValues(this.theme,this.page.type,this.pageParams||{})];case 1:return e=t.sent(),this.pageDataProvider=e,this.isLoading=!1,[2]}}))}))},this.handleUpdatePageComponentOrder=function(n){return e(T,void 0,void 0,(function(){return t(this,(function(e){return this.specification?this.specification.components=n.pageComponents.map((function(e){return new d(e)})):this.page.components=n.pageComponents.map((function(e){return new d(e)})),[2]}))}))},this.handleAddNewComponent=function(e){var t,n=new p(e.component);null===(t=T.theme)||void 0===t||t.components.push(n)},this.handleDeleteComponent=function(e){var t,n;(null===(t=T.theme)||void 0===t?void 0:t.components)&&(T.theme.components=T.theme.components.filter((function(t){return t.id!==e.componentId})));var i=T.pageComponents.filter((function(t){return t.componentId!==e.componentId}))||[];T.specification&&T.specification.components&&(T.specification.components=i),!T.specification&&(null===(n=T.page)||void 0===n?void 0:n.components)&&(T.page.components=i)},this.handleUpdateComponent=function(e){var t=T.theme.components.findIndex((function(t){return t.id===e.component.id}));-1!==t&&(T.theme.components[t]=new p(e.component))},this.handleAddNewPageComponent=function(n){return e(T,void 0,void 0,(function(){var e,o,a=this;return t(this,(function(t){switch(t.label){case 0:return e=new d(n.pageComponent),this.pageComponents.some((function(t){return t.id===e.id}))?[2]:[4,this.pageDataProvider.getPageComponentPropValues(e)];case 1:return o=t.sent(),i((function(){o.component.props.filter((function(e){return e.type===u.CUSTOM})).forEach((function(e){m.initCustomDataPropValue(e,o.propValues[e.name],o,a.router,a.theme.settings,!0)})),a.pageDataProvider.pageComponentPropValues.push(o),a.pageComponents.push(e)})),[2]}}))}))},this.handleDeletePageComponent=function(e){T.specification?T.specification.components=T.pageComponents.filter((function(t){return t.id!==e.pageComponentId})):T.page.components=T.pageComponents.filter((function(t){return t.id!==e.pageComponentId}))},this.handleSetSelectedComponent=function(e){T.selectedPageComponentId=e.componentId},this.handleSetHoveredComponent=function(e){T.hoveredPageComponentId=e.componentId},this.handleScrollToComponent=function(e){var t=e.componentId,n=T.componentRefs[t];n&&(T.isScrolledIntoView(n)||window.scrollTo({top:n.offsetTop,behavior:"smooth"}))},this.updateThemeSettings=function(e){var t=e.settings;T.theme&&(T.theme.settings=new l(t))},this.router=f,n(this),this.startMessaging()}return Object.defineProperty(T.prototype,"specification",{get:function(){var e,t,n,i,o,a,r,d=this,p=this.page;return(null==p?void 0:p.type)===s.PRODUCT&&(r=null===(e=p.specifications)||void 0===e?void 0:e.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.productId)}))),(null==p?void 0:p.type)===s.CATEGORY&&(r=null===(t=p.specifications)||void 0===t?void 0:t.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.categoryId)}))),(null==p?void 0:p.type)===s.BRAND&&(r=null===(n=p.specifications)||void 0===n?void 0:n.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.brandId)}))),(null==p?void 0:p.type)===s.BLOG&&(r=null===(i=p.specifications)||void 0===i?void 0:i.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.blogId)}))),(null==p?void 0:p.type)===s.BLOG_CATEGORY&&(r=null===(o=p.specifications)||void 0===o?void 0:o.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.blogCategoryId)}))),(null==p?void 0:p.type)===s.RAFFLE_DETAIL&&(r=null===(a=p.specifications)||void 0===a?void 0:a.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.raffleId)}))),r},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"pageComponents",{get:function(){var e;return this.specification?this.specification.components:(null===(e=this.page)||void 0===e?void 0:e.components)||[]},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"selectedPageComponent",{get:function(){var e=this;return this.pageComponents.find((function(t){return t.id===e.selectedPageComponentId}))},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"selectedComponent",{get:function(){var e,t=this;return null===(e=this.theme)||void 0===e?void 0:e.components.find((function(e){var n;return e.id===(null===(n=t.selectedPageComponent)||void 0===n?void 0:n.componentId)}))},enumerable:!1,configurable:!0}),T.prototype.getVariantIdFromParams=function(n,i){return e(this,void 0,void 0,(function(){var e,o,a,r,s,d,p;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e=new URLSearchParams("?"+i),[4,f.searchProducts({productIdList:[n],priceListId:v.priceListId,salesChannelId:v.salesChannelId})];case 1:return(null==(o=t.sent())?void 0:o.data.length)?(a=o.data[0],r=a.variantTypes.map((function(e){return e.variantType.slug})),s=[],r.forEach((function(t,n){var i=a.variantTypes[n],o=e.get(t);if(o){var r=i.variantType.values.find((function(e){return e.slug===o}));r&&s.push(r)}})),(d=a.variants.find((function(e){return e.variantValues.every((function(e){return s.some((function(t){return t.id===e.id}))}))})))?[2,d.id]:[3,3]):[2];case 2:return p=t.sent(),console.error(p),[3,3];case 3:return[2]}}))}))},T}();!function(e){e.FRAME_DID_LOAD="FRAME_DID_LOAD",e.UPDATE_FRAME_DATA="UPDATE_FRAME_DATA",e.UPDATE_PROP_VALUE="UPDATE_PROP_VALUE",e.UPDATE_PAGE_PARAMS="UPDATE_PAGE_PARAMS",e.UPDATE_PAGE_COMPONENT_ORDER="UPDATE_PAGE_COMPONENT_ORDER",e.ADD_COMPONENT="ADD_COMPONENT",e.DELETE_COMPONENT="DELETE_COMPONENT",e.UPDATE_COMPONENT="UPDATE_COMPONENT",e.ADD_PAGE_COMPONENT="ADD_PAGE_COMPONENT",e.DELETE_PAGE_COMPONENT="DELETE_PAGE_COMPONENT",e.COMPONENT_MOUSE_OVER="COMPONENT_MOUSE_OVER",e.COMPONENT_MOUSE_LEAVE="COMPONENT_MOUSE_LEAVE",e.COMPONENT_CLICK="COMPONENT_CLICK",e.SET_SELECTED_COMPONENT="SET_SELECTED_COMPONENT",e.SET_HOVERED_COMPONENT="SET_HOVERED_COMPONENT",e.SCROLL_TO_COMPONENT="SCROLL_TO_COMPONENT",e.UPDATE_THEME_SETTINGS="UPDATE_THEME_SETTINGS",e.EDITOR_PAGE_CHANGE="EDITOR_PAGE_CHANGE"}(C||(C={}));export{C as BridgeMessageType,T as default};
@@ -1 +1 @@
1
- import{__assign as t,__rest as e,__extends as r}from"../../../../tslib/tslib.es6.js";import{dep as i}from"../../../../optimism/lib/bundle.esm.js";import o from"../../../../@wry/equality/lib/equality.esm.js";import"../../../../ts-invariant/lib/invariant.esm.js";import{isReference as n,makeReference as s}from"../../utilities/graphql/storeUtils.js";import"../../utilities/graphql/transform.js";import{DeepMerger as a}from"../../utilities/common/mergeDeep.js";import"../../utilities/observables/Observable.js";import{maybeDeepFreeze as c}from"../../utilities/common/maybeDeepFreeze.js";import"../../utilities/observables/Concast.js";import{canUseWeakMap as u}from"../../utilities/common/canUse.js";import{hasOwn as p,fieldNameFromStoreName as f}from"./helpers.js";import{Trie as h}from"../../../../@wry/trie/lib/trie.esm.js";var l=Object.create(null),d=function(){return l},y=Object.create(null),m=function(){function r(t,e){var r=this;this.policies=t,this.group=e,this.data=Object.create(null),this.rootIds=Object.create(null),this.refs=Object.create(null),this.getFieldValue=function(t,e){return c(n(t)?r.get(t.__ref,e):t&&t[e])},this.canRead=function(t){return n(t)?r.has(t.__ref):"object"==typeof t},this.toReference=function(t,e){if("string"==typeof t)return s(t);if(n(t))return t;var i=r.policies.identify(t)[0];if(i){var o=s(i);return e&&r.merge(i,t),o}}}return r.prototype.toObject=function(){return t({},this.data)},r.prototype.has=function(t){return void 0!==this.lookup(t,!0)},r.prototype.get=function(t,e){if(this.group.depend(t,e),p.call(this.data,t)){var r=this.data[t];if(r&&p.call(r,e))return r[e]}return"__typename"===e&&p.call(this.policies.rootTypenamesById,t)?this.policies.rootTypenamesById[t]:this instanceof b?this.parent.get(t,e):void 0},r.prototype.lookup=function(t,e){return e&&this.group.depend(t,"__exists"),p.call(this.data,t)?this.data[t]:this instanceof b?this.parent.lookup(t,e):this.policies.rootTypenamesById[t]?Object.create(null):void 0},r.prototype.merge=function(t,e){var r=this,i=this.lookup(t),o=new a(j).merge(i,e);if(this.data[t]=o,o!==i&&(delete this.refs[t],this.group.caching)){var n=Object.create(null);i||(n.__exists=1),Object.keys(e).forEach((function(t){if(!i||i[t]!==o[t]){n[t]=1;var e=f(t);e===t||r.policies.hasKeyArgs(o.__typename,e)||(n[e]=1),void 0!==o[t]||r instanceof b||delete o[t]}})),Object.keys(n).forEach((function(e){return r.group.dirty(t,e)}))}},r.prototype.modify=function(e,r){var i=this,o=this.lookup(e);if(o){var a=Object.create(null),u=!1,p=!0,h={DELETE:l,INVALIDATE:y,isReference:n,toReference:this.toReference,canRead:this.canRead,readField:function(t,r){return i.policies.readField("string"==typeof t?{fieldName:t,from:r||s(e)}:t,{store:i})}};if(Object.keys(o).forEach((function(n){var s=f(n),m=o[n];if(void 0!==m){var g="function"==typeof r?r:r[n]||r[s];if(g){var v=g===d?l:g(c(m),t(t({},h),{fieldName:s,storeFieldName:n,storage:i.getStorage(e,n)}));v===y?i.group.dirty(e,n):(v===l&&(v=void 0),v!==m&&(a[n]=v,u=!0,m=v))}void 0!==m&&(p=!1)}})),u)return this.merge(e,a),p&&(this instanceof b?this.data[e]=void 0:delete this.data[e],this.group.dirty(e,"__exists")),!0}return!1},r.prototype.delete=function(t,e,r){var i,o=this.lookup(t);if(o){var n=this.getFieldValue(o,"__typename"),s=e&&r?this.policies.getStoreFieldName({typename:n,fieldName:e,args:r}):e;return this.modify(t,s?((i={})[s]=d,i):d)}return!1},r.prototype.evict=function(t){var e=!1;return t.id&&(p.call(this.data,t.id)&&(e=this.delete(t.id,t.fieldName,t.args)),this instanceof b&&(e=this.parent.evict(t)||e),(t.fieldName||e)&&this.group.dirty(t.id,t.fieldName||"__exists")),e},r.prototype.clear=function(){this.replace(null)},r.prototype.extract=function(){var t=this,e=this.toObject(),r=[];return this.getRootIdSet().forEach((function(e){p.call(t.policies.rootTypenamesById,e)||r.push(e)})),r.length&&(e.__META={extraRootIds:r.sort()}),e},r.prototype.replace=function(t){var r=this;if(Object.keys(this.data).forEach((function(e){t&&p.call(t,e)||r.delete(e)})),t){var i=t.__META,o=e(t,["__META"]);Object.keys(o).forEach((function(t){r.merge(t,o[t])})),i&&i.extraRootIds.forEach(this.retain,this)}},r.prototype.retain=function(t){return this.rootIds[t]=(this.rootIds[t]||0)+1},r.prototype.release=function(t){if(this.rootIds[t]>0){var e=--this.rootIds[t];return e||delete this.rootIds[t],e}return 0},r.prototype.getRootIdSet=function(t){return void 0===t&&(t=new Set),Object.keys(this.rootIds).forEach(t.add,t),this instanceof b?this.parent.getRootIdSet(t):Object.keys(this.policies.rootTypenamesById).forEach(t.add,t),t},r.prototype.gc=function(){var t=this,e=this.getRootIdSet(),r=this.toObject();e.forEach((function(i){p.call(r,i)&&(Object.keys(t.findChildRefIds(i)).forEach(e.add,e),delete r[i])}));var i=Object.keys(r);if(i.length){for(var o=this;o instanceof b;)o=o.parent;i.forEach((function(t){return o.delete(t)}))}return i},r.prototype.findChildRefIds=function(t){if(!p.call(this.refs,t)){var e=this.refs[t]=Object.create(null),r=new Set([this.data[t]]),i=function(t){return null!==t&&"object"==typeof t};r.forEach((function(t){n(t)?e[t.__ref]=!0:i(t)&&Object.values(t).filter(i).forEach(r.add,r)}))}return this.refs[t]},r.prototype.makeCacheKey=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this.group.keyMaker.lookupArray(t)},r}(),g=function(){function t(t){this.caching=t,this.d=null,this.keyMaker=new h(u),this.d=t?i():null}return t.prototype.depend=function(t,e){if(this.d){this.d(v(t,e));var r=f(e);r!==e&&this.d(v(t,r))}},t.prototype.dirty=function(t,e){this.d&&this.d.dirty(v(t,e))},t}();function v(t,e){return e+"#"+t}!function(t){var e=function(t){function e(e){var r=e.policies,i=e.resultCaching,o=void 0===i||i,n=e.seed,s=t.call(this,r,new g(o))||this;return s.storageTrie=new h(u),s.sharedLayerGroup=new g(o),n&&s.replace(n),s}return r(e,t),e.prototype.addLayer=function(t,e){return new b(t,this,e,this.sharedLayerGroup)},e.prototype.removeLayer=function(){return this},e.prototype.getStorage=function(){return this.storageTrie.lookupArray(arguments)},e}(t);t.Root=e}(m||(m={}));var b=function(e){function i(t,r,i,o){var n=e.call(this,r.policies,o)||this;return n.id=t,n.parent=r,n.replay=i,n.group=o,i(n),n}return r(i,e),i.prototype.addLayer=function(t,e){return new i(t,this,e,this.group)},i.prototype.removeLayer=function(t){var e=this,r=this.parent.removeLayer(t);return t===this.id?(this.group.caching&&Object.keys(this.data).forEach((function(t){e.data[t]!==r.lookup(t)&&e.delete(t)})),r):r===this.parent?this:r.addLayer(this.id,this.replay)},i.prototype.toObject=function(){return t(t({},this.parent.toObject()),this.data)},i.prototype.findChildRefIds=function(r){var i=this.parent.findChildRefIds(r);return p.call(this.data,r)?t(t({},i),e.prototype.findChildRefIds.call(this,r)):i},i.prototype.getStorage=function(){for(var t=this.parent;t.parent;)t=t.parent;return t.getStorage.apply(t,arguments)},i}(m);function j(t,e,r){var i=t[r],n=e[r];return o(i,n)?i:n}function O(t){return!!(t instanceof m&&t.group.caching)}export{m as EntityStore,O as supportsResultCaching};
1
+ import{__assign as t,__rest as e,__extends as r}from'../../ext/tslib/tslib.es6.js';import{dep as i}from"../../../../optimism/lib/bundle.esm.js";import o from"../../../../@wry/equality/lib/equality.esm.js";import"../../../../ts-invariant/lib/invariant.esm.js";import{isReference as n,makeReference as s}from"../../utilities/graphql/storeUtils.js";import"../../utilities/graphql/transform.js";import{DeepMerger as a}from"../../utilities/common/mergeDeep.js";import"../../utilities/observables/Observable.js";import{maybeDeepFreeze as c}from"../../utilities/common/maybeDeepFreeze.js";import"../../utilities/observables/Concast.js";import{canUseWeakMap as u}from"../../utilities/common/canUse.js";import{hasOwn as p,fieldNameFromStoreName as f}from"./helpers.js";import{Trie as h}from"../../../../@wry/trie/lib/trie.esm.js";var l=Object.create(null),d=function(){return l},y=Object.create(null),m=function(){function r(t,e){var r=this;this.policies=t,this.group=e,this.data=Object.create(null),this.rootIds=Object.create(null),this.refs=Object.create(null),this.getFieldValue=function(t,e){return c(n(t)?r.get(t.__ref,e):t&&t[e])},this.canRead=function(t){return n(t)?r.has(t.__ref):"object"==typeof t},this.toReference=function(t,e){if("string"==typeof t)return s(t);if(n(t))return t;var i=r.policies.identify(t)[0];if(i){var o=s(i);return e&&r.merge(i,t),o}}}return r.prototype.toObject=function(){return t({},this.data)},r.prototype.has=function(t){return void 0!==this.lookup(t,!0)},r.prototype.get=function(t,e){if(this.group.depend(t,e),p.call(this.data,t)){var r=this.data[t];if(r&&p.call(r,e))return r[e]}return"__typename"===e&&p.call(this.policies.rootTypenamesById,t)?this.policies.rootTypenamesById[t]:this instanceof b?this.parent.get(t,e):void 0},r.prototype.lookup=function(t,e){return e&&this.group.depend(t,"__exists"),p.call(this.data,t)?this.data[t]:this instanceof b?this.parent.lookup(t,e):this.policies.rootTypenamesById[t]?Object.create(null):void 0},r.prototype.merge=function(t,e){var r=this,i=this.lookup(t),o=new a(j).merge(i,e);if(this.data[t]=o,o!==i&&(delete this.refs[t],this.group.caching)){var n=Object.create(null);i||(n.__exists=1),Object.keys(e).forEach((function(t){if(!i||i[t]!==o[t]){n[t]=1;var e=f(t);e===t||r.policies.hasKeyArgs(o.__typename,e)||(n[e]=1),void 0!==o[t]||r instanceof b||delete o[t]}})),Object.keys(n).forEach((function(e){return r.group.dirty(t,e)}))}},r.prototype.modify=function(e,r){var i=this,o=this.lookup(e);if(o){var a=Object.create(null),u=!1,p=!0,h={DELETE:l,INVALIDATE:y,isReference:n,toReference:this.toReference,canRead:this.canRead,readField:function(t,r){return i.policies.readField("string"==typeof t?{fieldName:t,from:r||s(e)}:t,{store:i})}};if(Object.keys(o).forEach((function(n){var s=f(n),m=o[n];if(void 0!==m){var g="function"==typeof r?r:r[n]||r[s];if(g){var v=g===d?l:g(c(m),t(t({},h),{fieldName:s,storeFieldName:n,storage:i.getStorage(e,n)}));v===y?i.group.dirty(e,n):(v===l&&(v=void 0),v!==m&&(a[n]=v,u=!0,m=v))}void 0!==m&&(p=!1)}})),u)return this.merge(e,a),p&&(this instanceof b?this.data[e]=void 0:delete this.data[e],this.group.dirty(e,"__exists")),!0}return!1},r.prototype.delete=function(t,e,r){var i,o=this.lookup(t);if(o){var n=this.getFieldValue(o,"__typename"),s=e&&r?this.policies.getStoreFieldName({typename:n,fieldName:e,args:r}):e;return this.modify(t,s?((i={})[s]=d,i):d)}return!1},r.prototype.evict=function(t){var e=!1;return t.id&&(p.call(this.data,t.id)&&(e=this.delete(t.id,t.fieldName,t.args)),this instanceof b&&(e=this.parent.evict(t)||e),(t.fieldName||e)&&this.group.dirty(t.id,t.fieldName||"__exists")),e},r.prototype.clear=function(){this.replace(null)},r.prototype.extract=function(){var t=this,e=this.toObject(),r=[];return this.getRootIdSet().forEach((function(e){p.call(t.policies.rootTypenamesById,e)||r.push(e)})),r.length&&(e.__META={extraRootIds:r.sort()}),e},r.prototype.replace=function(t){var r=this;if(Object.keys(this.data).forEach((function(e){t&&p.call(t,e)||r.delete(e)})),t){var i=t.__META,o=e(t,["__META"]);Object.keys(o).forEach((function(t){r.merge(t,o[t])})),i&&i.extraRootIds.forEach(this.retain,this)}},r.prototype.retain=function(t){return this.rootIds[t]=(this.rootIds[t]||0)+1},r.prototype.release=function(t){if(this.rootIds[t]>0){var e=--this.rootIds[t];return e||delete this.rootIds[t],e}return 0},r.prototype.getRootIdSet=function(t){return void 0===t&&(t=new Set),Object.keys(this.rootIds).forEach(t.add,t),this instanceof b?this.parent.getRootIdSet(t):Object.keys(this.policies.rootTypenamesById).forEach(t.add,t),t},r.prototype.gc=function(){var t=this,e=this.getRootIdSet(),r=this.toObject();e.forEach((function(i){p.call(r,i)&&(Object.keys(t.findChildRefIds(i)).forEach(e.add,e),delete r[i])}));var i=Object.keys(r);if(i.length){for(var o=this;o instanceof b;)o=o.parent;i.forEach((function(t){return o.delete(t)}))}return i},r.prototype.findChildRefIds=function(t){if(!p.call(this.refs,t)){var e=this.refs[t]=Object.create(null),r=new Set([this.data[t]]),i=function(t){return null!==t&&"object"==typeof t};r.forEach((function(t){n(t)?e[t.__ref]=!0:i(t)&&Object.values(t).filter(i).forEach(r.add,r)}))}return this.refs[t]},r.prototype.makeCacheKey=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this.group.keyMaker.lookupArray(t)},r}(),g=function(){function t(t){this.caching=t,this.d=null,this.keyMaker=new h(u),this.d=t?i():null}return t.prototype.depend=function(t,e){if(this.d){this.d(v(t,e));var r=f(e);r!==e&&this.d(v(t,r))}},t.prototype.dirty=function(t,e){this.d&&this.d.dirty(v(t,e))},t}();function v(t,e){return e+"#"+t}!function(t){var e=function(t){function e(e){var r=e.policies,i=e.resultCaching,o=void 0===i||i,n=e.seed,s=t.call(this,r,new g(o))||this;return s.storageTrie=new h(u),s.sharedLayerGroup=new g(o),n&&s.replace(n),s}return r(e,t),e.prototype.addLayer=function(t,e){return new b(t,this,e,this.sharedLayerGroup)},e.prototype.removeLayer=function(){return this},e.prototype.getStorage=function(){return this.storageTrie.lookupArray(arguments)},e}(t);t.Root=e}(m||(m={}));var b=function(e){function i(t,r,i,o){var n=e.call(this,r.policies,o)||this;return n.id=t,n.parent=r,n.replay=i,n.group=o,i(n),n}return r(i,e),i.prototype.addLayer=function(t,e){return new i(t,this,e,this.group)},i.prototype.removeLayer=function(t){var e=this,r=this.parent.removeLayer(t);return t===this.id?(this.group.caching&&Object.keys(this.data).forEach((function(t){e.data[t]!==r.lookup(t)&&e.delete(t)})),r):r===this.parent?this:r.addLayer(this.id,this.replay)},i.prototype.toObject=function(){return t(t({},this.parent.toObject()),this.data)},i.prototype.findChildRefIds=function(r){var i=this.parent.findChildRefIds(r);return p.call(this.data,r)?t(t({},i),e.prototype.findChildRefIds.call(this,r)):i},i.prototype.getStorage=function(){for(var t=this.parent;t.parent;)t=t.parent;return t.getStorage.apply(t,arguments)},i}(m);function j(t,e,r){var i=t[r],n=e[r];return o(i,n)?i:n}function _(t){return!!(t instanceof m&&t.group.caching)}export{m as EntityStore,_ as supportsResultCaching};
@@ -1 +1 @@
1
- import{__extends as t,__assign as i}from"../../../../tslib/tslib.es6.js";import{wrap as a,dep as e}from"../../../../optimism/lib/bundle.esm.js";import{ApolloCache as r}from"../core/cache.js";import{MissingFieldError as o}from"../core/types/common.js";import"../../../../ts-invariant/lib/invariant.esm.js";import{isReference as s}from"../../utilities/graphql/storeUtils.js";import{addTypenameToDocument as c}from"../../utilities/graphql/transform.js";import"../../utilities/common/mergeDeep.js";import"../../utilities/observables/Observable.js";import"../../utilities/observables/Concast.js";import{StoreReader as n}from"./readFromStore.js";import{StoreWriter as p}from"./writeToStore.js";import{EntityStore as m,supportsResultCaching as h}from"./entityStore.js";import{makeVar as d,forgetCache as u}from"./reactiveVars.js";import{Policies as f,defaultDataIdFromObject as l}from"./policies.js";import{hasOwn as y}from"./helpers.js";var b={dataIdFromObject:l,addTypename:!0,resultCaching:!0,typePolicies:{}},v=function(r){function l(t){void 0===t&&(t={});var o=r.call(this)||this;return o.watches=new Set,o.typenameDocumentCache=new Map,o.makeVar=d,o.txCount=0,o.maybeBroadcastWatch=a((function(t,i){return o.broadcastWatch.call(o,t,!!i)}),{makeCacheKey:function(t){var i=t.optimistic?o.optimisticData:o.data;if(h(i)){var a=t.optimistic,e=t.rootId,r=t.variables;return i.makeCacheKey(t.query,t.callback,JSON.stringify({optimistic:a,rootId:e,variables:r}))}}}),o.watchDep=e(),o.config=i(i({},b),t),o.addTypename=!!o.config.addTypename,o.policies=new f({cache:o,dataIdFromObject:o.config.dataIdFromObject,possibleTypes:o.config.possibleTypes,typePolicies:o.config.typePolicies}),o.data=new m.Root({policies:o.policies,resultCaching:o.config.resultCaching}),o.optimisticData=o.data,o.storeWriter=new p(o,o.storeReader=new n({cache:o,addTypename:o.addTypename})),o}return t(l,r),l.prototype.restore=function(t){return t&&this.data.replace(t),this},l.prototype.extract=function(t){return void 0===t&&(t=!1),(t?this.optimisticData:this.data).extract()},l.prototype.read=function(t){var i=t.returnPartialData,a=void 0!==i&&i;try{return this.storeReader.diffQueryAgainstStore({store:t.optimistic?this.optimisticData:this.data,query:t.query,variables:t.variables,rootId:t.rootId,config:this.config,returnPartialData:a}).result||null}catch(t){if(t instanceof o)return null;throw t}},l.prototype.write=function(t){try{return++this.txCount,this.storeWriter.writeToStore({store:this.data,query:t.query,result:t.result,dataId:t.dataId,variables:t.variables})}finally{--this.txCount||!1===t.broadcast||this.broadcastWatches()}},l.prototype.modify=function(t){if(y.call(t,"id")&&!t.id)return!1;var i=t.optimistic?this.optimisticData:this.data;try{return++this.txCount,i.modify(t.id||"ROOT_QUERY",t.fields)}finally{--this.txCount||!1===t.broadcast||this.broadcastWatches()}},l.prototype.diff=function(t){return this.storeReader.diffQueryAgainstStore({store:t.optimistic?this.optimisticData:this.data,rootId:t.id||"ROOT_QUERY",query:t.query,variables:t.variables,returnPartialData:t.returnPartialData,config:this.config})},l.prototype.watch=function(t){var i=this;return this.watches.add(t),t.immediate&&this.maybeBroadcastWatch(t),function(){i.watches.delete(t)&&!i.watches.size&&u(i),i.watchDep.dirty(t),i.maybeBroadcastWatch.forget(t)}},l.prototype.gc=function(){return this.optimisticData.gc()},l.prototype.retain=function(t,i){return(i?this.optimisticData:this.data).retain(t)},l.prototype.release=function(t,i){return(i?this.optimisticData:this.data).release(t)},l.prototype.identify=function(t){return s(t)?t.__ref:this.policies.identify(t)[0]},l.prototype.evict=function(t){if(!t.id){if(y.call(t,"id"))return!1;t=i(i({},t),{id:"ROOT_QUERY"})}try{return++this.txCount,this.optimisticData.evict(t)}finally{--this.txCount||!1===t.broadcast||this.broadcastWatches()}},l.prototype.reset=function(){return this.data.clear(),this.optimisticData=this.data,this.broadcastWatches(),Promise.resolve()},l.prototype.removeOptimistic=function(t){var i=this.optimisticData.removeLayer(t);i!==this.optimisticData&&(this.optimisticData=i,this.broadcastWatches())},l.prototype.performTransaction=function(t,i){var a=this,e=function(i){var e=a,r=e.data,o=e.optimisticData;++a.txCount,i&&(a.data=a.optimisticData=i);try{t(a)}finally{--a.txCount,a.data=r,a.optimisticData=o}},r=!1;"string"==typeof i?(this.optimisticData=this.optimisticData.addLayer(i,e),r=!0):null===i?e(this.data):e(),this.broadcastWatches(r)},l.prototype.transformDocument=function(t){if(this.addTypename){var i=this.typenameDocumentCache.get(t);return i||(i=c(t),this.typenameDocumentCache.set(t,i),this.typenameDocumentCache.set(i,i)),i}return t},l.prototype.broadcastWatches=function(t){var i=this;this.txCount||this.watches.forEach((function(a){return i.maybeBroadcastWatch(a,t)}))},l.prototype.broadcastWatch=function(t,i){this.watchDep.dirty(t),this.watchDep(t);var a=this.diff({query:t.query,variables:t.variables,optimistic:t.optimistic});t.optimistic&&i&&(a.fromOptimisticTransaction=!0),t.callback(a)},l}(r);export{v as InMemoryCache};
1
+ import{__extends as t,__assign as i}from'../../ext/tslib/tslib.es6.js';import{wrap as a,dep as e}from"../../../../optimism/lib/bundle.esm.js";import{ApolloCache as r}from"../core/cache.js";import{MissingFieldError as o}from"../core/types/common.js";import"../../../../ts-invariant/lib/invariant.esm.js";import{isReference as s}from"../../utilities/graphql/storeUtils.js";import{addTypenameToDocument as c}from"../../utilities/graphql/transform.js";import"../../utilities/common/mergeDeep.js";import"../../utilities/observables/Observable.js";import"../../utilities/observables/Concast.js";import{StoreReader as n}from"./readFromStore.js";import{StoreWriter as p}from"./writeToStore.js";import{EntityStore as m,supportsResultCaching as h}from"./entityStore.js";import{makeVar as d,forgetCache as u}from"./reactiveVars.js";import{Policies as l,defaultDataIdFromObject as f}from"./policies.js";import{hasOwn as y}from"./helpers.js";var b={dataIdFromObject:f,addTypename:!0,resultCaching:!0,typePolicies:{}},v=function(r){function f(t){void 0===t&&(t={});var o=r.call(this)||this;return o.watches=new Set,o.typenameDocumentCache=new Map,o.makeVar=d,o.txCount=0,o.maybeBroadcastWatch=a((function(t,i){return o.broadcastWatch.call(o,t,!!i)}),{makeCacheKey:function(t){var i=t.optimistic?o.optimisticData:o.data;if(h(i)){var a=t.optimistic,e=t.rootId,r=t.variables;return i.makeCacheKey(t.query,t.callback,JSON.stringify({optimistic:a,rootId:e,variables:r}))}}}),o.watchDep=e(),o.config=i(i({},b),t),o.addTypename=!!o.config.addTypename,o.policies=new l({cache:o,dataIdFromObject:o.config.dataIdFromObject,possibleTypes:o.config.possibleTypes,typePolicies:o.config.typePolicies}),o.data=new m.Root({policies:o.policies,resultCaching:o.config.resultCaching}),o.optimisticData=o.data,o.storeWriter=new p(o,o.storeReader=new n({cache:o,addTypename:o.addTypename})),o}return t(f,r),f.prototype.restore=function(t){return t&&this.data.replace(t),this},f.prototype.extract=function(t){return void 0===t&&(t=!1),(t?this.optimisticData:this.data).extract()},f.prototype.read=function(t){var i=t.returnPartialData,a=void 0!==i&&i;try{return this.storeReader.diffQueryAgainstStore({store:t.optimistic?this.optimisticData:this.data,query:t.query,variables:t.variables,rootId:t.rootId,config:this.config,returnPartialData:a}).result||null}catch(t){if(t instanceof o)return null;throw t}},f.prototype.write=function(t){try{return++this.txCount,this.storeWriter.writeToStore({store:this.data,query:t.query,result:t.result,dataId:t.dataId,variables:t.variables})}finally{--this.txCount||!1===t.broadcast||this.broadcastWatches()}},f.prototype.modify=function(t){if(y.call(t,"id")&&!t.id)return!1;var i=t.optimistic?this.optimisticData:this.data;try{return++this.txCount,i.modify(t.id||"ROOT_QUERY",t.fields)}finally{--this.txCount||!1===t.broadcast||this.broadcastWatches()}},f.prototype.diff=function(t){return this.storeReader.diffQueryAgainstStore({store:t.optimistic?this.optimisticData:this.data,rootId:t.id||"ROOT_QUERY",query:t.query,variables:t.variables,returnPartialData:t.returnPartialData,config:this.config})},f.prototype.watch=function(t){var i=this;return this.watches.add(t),t.immediate&&this.maybeBroadcastWatch(t),function(){i.watches.delete(t)&&!i.watches.size&&u(i),i.watchDep.dirty(t),i.maybeBroadcastWatch.forget(t)}},f.prototype.gc=function(){return this.optimisticData.gc()},f.prototype.retain=function(t,i){return(i?this.optimisticData:this.data).retain(t)},f.prototype.release=function(t,i){return(i?this.optimisticData:this.data).release(t)},f.prototype.identify=function(t){return s(t)?t.__ref:this.policies.identify(t)[0]},f.prototype.evict=function(t){if(!t.id){if(y.call(t,"id"))return!1;t=i(i({},t),{id:"ROOT_QUERY"})}try{return++this.txCount,this.optimisticData.evict(t)}finally{--this.txCount||!1===t.broadcast||this.broadcastWatches()}},f.prototype.reset=function(){return this.data.clear(),this.optimisticData=this.data,this.broadcastWatches(),Promise.resolve()},f.prototype.removeOptimistic=function(t){var i=this.optimisticData.removeLayer(t);i!==this.optimisticData&&(this.optimisticData=i,this.broadcastWatches())},f.prototype.performTransaction=function(t,i){var a=this,e=function(i){var e=a,r=e.data,o=e.optimisticData;++a.txCount,i&&(a.data=a.optimisticData=i);try{t(a)}finally{--a.txCount,a.data=r,a.optimisticData=o}},r=!1;"string"==typeof i?(this.optimisticData=this.optimisticData.addLayer(i,e),r=!0):null===i?e(this.data):e(),this.broadcastWatches(r)},f.prototype.transformDocument=function(t){if(this.addTypename){var i=this.typenameDocumentCache.get(t);return i||(i=c(t),this.typenameDocumentCache.set(t,i),this.typenameDocumentCache.set(i,i)),i}return t},f.prototype.broadcastWatches=function(t){var i=this;this.txCount||this.watches.forEach((function(a){return i.maybeBroadcastWatch(a,t)}))},f.prototype.broadcastWatch=function(t,i){this.watchDep.dirty(t),this.watchDep(t);var a=this.diff({query:t.query,variables:t.variables,optimistic:t.optimistic});t.optimistic&&i&&(a.fromOptimisticTransaction=!0),t.callback(a)},f}(r);export{v as InMemoryCache};
@@ -1 +1 @@
1
- import{__assign as e,__rest as t}from"../../../../tslib/tslib.es6.js";import"../../../../optimism/lib/bundle.esm.js";import{invariant as i,InvariantError as r}from"../../../../ts-invariant/lib/invariant.esm.js";import{getFragmentFromSelection as o}from"../../utilities/graphql/fragments.js";import{getTypenameFromResult as n,argumentsObjectFromField as a,storeKeyNameFromField as s,getStoreKeyName as p,isReference as l,isField as c}from"../../utilities/graphql/storeUtils.js";import"../../utilities/graphql/transform.js";import"../../utilities/common/mergeDeep.js";import"../../utilities/observables/Observable.js";import"../../utilities/observables/Concast.js";import{canUseWeakMap as y}from"../../utilities/common/canUse.js";import{compact as u}from"../../utilities/common/compact.js";import{hasOwn as f,TypeOrFieldNameRegExp as d,selectionSetMatchesResult as m,fieldNameFromStoreName as h,storeValueIsStoreObject as v}from"./helpers.js";import{cacheSlot as g}from"./reactiveVars.js";import{Trie as b}from"../../../../@wry/trie/lib/trie.esm.js";function j(e){return void 0!==e.args?e.args:e.field?a(e.field,e.variables):null}var O=function(e,t){var i=e.__typename,r=e.id,o=e._id;if("string"==typeof i&&(t&&(t.keyObject=void 0!==r?{id:r}:void 0!==o?{_id:o}:void 0),void 0===r&&(r=o),void 0!==r))return i+":"+("number"==typeof r||"string"==typeof r?r:JSON.stringify(r))},T=function(){},S=function(e,t){return t.fieldName},F=function(e,t,i){return(0,i.mergeObjects)(e,t)},P=function(e,t){return t},N=function(){function r(t){this.config=t,this.typePolicies=Object.create(null),this.toBeAdded=Object.create(null),this.supertypeMap=new Map,this.fuzzySubtypes=new Map,this.rootIdsByTypename=Object.create(null),this.rootTypenamesById=Object.create(null),this.usingPossibleTypes=!1,this.config=e({dataIdFromObject:O},t),this.cache=this.config.cache,this.setRootTypename("Query"),this.setRootTypename("Mutation"),this.setRootTypename("Subscription"),t.possibleTypes&&this.addPossibleTypes(t.possibleTypes),t.typePolicies&&this.addTypePolicies(t.typePolicies)}return r.prototype.identify=function(e,t,i){var r=t&&i?n(e,t,i):e.__typename;if(r===this.rootTypenamesById.ROOT_QUERY)return["ROOT_QUERY"];for(var o,a={typename:r,selectionSet:t,fragmentMap:i},s=r&&this.getTypePolicy(r),p=s&&s.keyFn||this.config.dataIdFromObject;p;){var l=p(e,a);if(!Array.isArray(l)){o=l;break}p=E(l)}return o=o&&String(o),a.keyObject?[o,a.keyObject]:[o]},r.prototype.addTypePolicies=function(e){var i=this;Object.keys(e).forEach((function(r){var o=e[r],n=o.queryType,a=o.mutationType,s=o.subscriptionType,p=t(o,["queryType","mutationType","subscriptionType"]);n&&i.setRootTypename("Query",r),a&&i.setRootTypename("Mutation",r),s&&i.setRootTypename("Subscription",r),f.call(i.toBeAdded,r)?i.toBeAdded[r].push(p):i.toBeAdded[r]=[p]}))},r.prototype.updateTypePolicy=function(e,t){var i=this,r=this.getTypePolicy(e),o=t.keyFields,n=t.fields;function a(e,t){e.merge="function"==typeof t?t:!0===t?F:!1===t?P:e.merge}a(r,t.merge),r.keyFn=!1===o?T:Array.isArray(o)?E(o):"function"==typeof o?o:r.keyFn,n&&Object.keys(n).forEach((function(t){var r=i.getFieldPolicy(e,t,!0),o=n[t];if("function"==typeof o)r.read=o;else{var s=o.keyArgs,p=o.read,l=o.merge;r.keyFn=!1===s?S:Array.isArray(s)?A(s):"function"==typeof s?s:r.keyFn,"function"==typeof p&&(r.read=p),a(r,l)}r.read&&r.merge&&(r.keyFn=r.keyFn||S)}))},r.prototype.setRootTypename=function(e,t){void 0===t&&(t=e);var r="ROOT_"+e.toUpperCase(),o=this.rootTypenamesById[r];t!==o&&("production"===process.env.NODE_ENV?i(!o||o===e,1):i(!o||o===e,"Cannot change root "+e+" __typename more than once"),o&&delete this.rootIdsByTypename[o],this.rootIdsByTypename[t]=r,this.rootTypenamesById[r]=t)},r.prototype.addPossibleTypes=function(e){var t=this;this.usingPossibleTypes=!0,Object.keys(e).forEach((function(i){t.getSupertypeSet(i,!0),e[i].forEach((function(e){t.getSupertypeSet(e,!0).add(i);var r=e.match(d);r&&r[0]===e||t.fuzzySubtypes.set(e,new RegExp(e))}))}))},r.prototype.getTypePolicy=function(e){var i=this;if(!f.call(this.typePolicies,e)){var r=this.typePolicies[e]=Object.create(null);r.fields=Object.create(null);var o=this.supertypeMap.get(e);o&&o.size&&o.forEach((function(e){var o=i.getTypePolicy(e),n=o.fields,a=t(o,["fields"]);Object.assign(r,a),Object.assign(r.fields,n)}))}var n=this.toBeAdded[e];return n&&n.length&&this.updateTypePolicy(e,u.apply(void 0,n.splice(0))),this.typePolicies[e]},r.prototype.getFieldPolicy=function(e,t,i){if(e){var r=this.getTypePolicy(e).fields;return r[t]||i&&(r[t]=Object.create(null))}},r.prototype.getSupertypeSet=function(e,t){var i=this.supertypeMap.get(e);return!i&&t&&this.supertypeMap.set(e,i=new Set),i},r.prototype.fragmentMatches=function(e,t,r,o){var n=this;if(!e.typeCondition)return!0;if(!t)return!1;var a=e.typeCondition.name.value;if(t===a)return!0;if(this.usingPossibleTypes&&this.supertypeMap.has(a))for(var s=this.getSupertypeSet(t,!0),p=[s],l=function(e){var t=n.getSupertypeSet(e,!1);t&&t.size&&p.indexOf(t)<0&&p.push(t)},c=!(!r||!this.fuzzySubtypes.size),y=!1,u=0;u<p.length;++u){var f=p[u];if(f.has(a))return s.has(a)||(y&&("production"===process.env.NODE_ENV||i.warn("Inferring subtype "+t+" of supertype "+a)),s.add(a)),!0;f.forEach(l),c&&u===p.length-1&&m(e.selectionSet,r,o)&&(c=!1,y=!0,this.fuzzySubtypes.forEach((function(e,i){var r=t.match(e);r&&r[0]===t&&l(i)})))}return!1},r.prototype.hasKeyArgs=function(e,t){var i=this.getFieldPolicy(e,t,!1);return!(!i||!i.keyFn)},r.prototype.getStoreFieldName=function(e){var t,i=e.typename,r=e.fieldName,o=this.getFieldPolicy(i,r,!1),n=o&&o.keyFn;if(n&&i)for(var a={typename:i,fieldName:r,field:e.field||null,variables:e.variables},l=j(e);n;){var c=n(l,a);if(!Array.isArray(c)){t=c||r;break}n=A(c)}return void 0===t&&(t=e.field?s(e.field,e.variables):p(r,j(e))),r===h(t)?t:r+":"+t},r.prototype.readField=function(e,t){var i=e.from;if(i&&(e.field||e.fieldName)){if(void 0===e.typename){var r=t.store.getFieldValue(i,"__typename");r&&(e.typename=r)}var o=this.getStoreFieldName(e),n=h(o),a=t.store.getFieldValue(i,o),s=this.getFieldPolicy(e.typename,n,!1),p=s&&s.read;if(p){var c=_(this,i,e,t,t.store.getStorage(l(i)?i.__ref:i,o));return g.withValue(this.cache,p,[a,c])}return a}},r.prototype.getMergeFunction=function(e,t,i){var r=this.getFieldPolicy(e,t,!1),o=r&&r.merge;return!o&&i&&(o=(r=this.getTypePolicy(i))&&r.merge),o},r.prototype.runMergeFunction=function(e,t,i,r,o){var n=i.field,a=i.typename,s=i.merge;return s===F?k(r.store.getFieldValue)(e,t):s===P?t:s(e,t,_(this,void 0,{typename:a,fieldName:n.name.value,field:n,variables:r.variables},r,o||Object.create(null)))},r}();function _(t,i,r,o,n){var a=t.getStoreFieldName(r),s=h(a),p=r.variables||o.variables,c=o.store,y=c.getFieldValue,u=c.toReference,f=c.canRead;return{args:j(r),field:r.field||null,fieldName:s,storeFieldName:a,variables:p,isReference:l,toReference:u,storage:n,cache:t.cache,canRead:f,readField:function(r,n){var a="string"==typeof r?{fieldName:r,from:n}:e({},r);return void 0===a.from&&(a.from=i),void 0===a.variables&&(a.variables=p),t.readField(a,o)},mergeObjects:k(y)}}function k(t){return function(i,o){if(Array.isArray(i)||Array.isArray(o))throw"production"===process.env.NODE_ENV?new r(2):new r("Cannot automatically merge arrays");if(i&&"object"==typeof i&&o&&"object"==typeof o){var n=t(i,"__typename"),a=t(o,"__typename");return!(n&&a&&n!==a)&&v(i)&&v(o)?e(e({},i),o):o}return o}}function A(e){return function(t,i){return t?i.fieldName+":"+JSON.stringify(R(t,e,!1)):i.fieldName}}function E(e){var t=new b(y);return function(i,r){var o;if(r.selectionSet&&r.fragmentMap){var n=t.lookupArray([r.selectionSet,r.fragmentMap]);o=n.aliasMap||(n.aliasMap=M(r.selectionSet,r.fragmentMap))}var a=r.keyObject=R(i,e,!0,o);return r.typename+":"+JSON.stringify(a)}}function M(e,t){var i=Object.create(null),r=new Set([e]);return r.forEach((function(e){e.selections.forEach((function(e){if(c(e)){if(e.alias){var n=e.alias.value,a=e.name.value;if(a!==n)(i.aliases||(i.aliases=Object.create(null)))[a]=n}if(e.selectionSet)(i.subsets||(i.subsets=Object.create(null)))[e.name.value]=M(e.selectionSet,t)}else{var s=o(e,t);s&&r.add(s.selectionSet)}}))})),i}function R(e,t,r,o){var n,a=Object.create(null);return t.forEach((function(t){if(Array.isArray(t)){if("string"==typeof n){var s=o&&o.subsets,p=s&&s[n];a[n]=R(e[n],t,r,p)}}else{var l=o&&o.aliases,c=l&&l[t]||t;f.call(e,c)?a[n=t]=e[c]:("production"===process.env.NODE_ENV?i(!r,3):i(!r,"Missing field '"+c+"' while computing key fields"),n=void 0)}})),a}export{N as Policies,O as defaultDataIdFromObject};
1
+ import{__assign as e,__rest as t}from'../../ext/tslib/tslib.es6.js';import"../../../../optimism/lib/bundle.esm.js";import{invariant as i,InvariantError as r}from"../../../../ts-invariant/lib/invariant.esm.js";import{getFragmentFromSelection as o}from"../../utilities/graphql/fragments.js";import{getTypenameFromResult as n,argumentsObjectFromField as a,storeKeyNameFromField as s,getStoreKeyName as p,isReference as l,isField as c}from"../../utilities/graphql/storeUtils.js";import"../../utilities/graphql/transform.js";import"../../utilities/common/mergeDeep.js";import"../../utilities/observables/Observable.js";import"../../utilities/observables/Concast.js";import{canUseWeakMap as y}from"../../utilities/common/canUse.js";import{compact as u}from"../../utilities/common/compact.js";import{hasOwn as f,TypeOrFieldNameRegExp as d,selectionSetMatchesResult as m,fieldNameFromStoreName as h,storeValueIsStoreObject as v}from"./helpers.js";import{cacheSlot as g}from"./reactiveVars.js";import{Trie as b}from"../../../../@wry/trie/lib/trie.esm.js";function j(e){return void 0!==e.args?e.args:e.field?a(e.field,e.variables):null}var O=function(e,t){var i=e.__typename,r=e.id,o=e._id;if("string"==typeof i&&(t&&(t.keyObject=void 0!==r?{id:r}:void 0!==o?{_id:o}:void 0),void 0===r&&(r=o),void 0!==r))return i+":"+("number"==typeof r||"string"==typeof r?r:JSON.stringify(r))},T=function(){},S=function(e,t){return t.fieldName},F=function(e,t,i){return(0,i.mergeObjects)(e,t)},P=function(e,t){return t},N=function(){function r(t){this.config=t,this.typePolicies=Object.create(null),this.toBeAdded=Object.create(null),this.supertypeMap=new Map,this.fuzzySubtypes=new Map,this.rootIdsByTypename=Object.create(null),this.rootTypenamesById=Object.create(null),this.usingPossibleTypes=!1,this.config=e({dataIdFromObject:O},t),this.cache=this.config.cache,this.setRootTypename("Query"),this.setRootTypename("Mutation"),this.setRootTypename("Subscription"),t.possibleTypes&&this.addPossibleTypes(t.possibleTypes),t.typePolicies&&this.addTypePolicies(t.typePolicies)}return r.prototype.identify=function(e,t,i){var r=t&&i?n(e,t,i):e.__typename;if(r===this.rootTypenamesById.ROOT_QUERY)return["ROOT_QUERY"];for(var o,a={typename:r,selectionSet:t,fragmentMap:i},s=r&&this.getTypePolicy(r),p=s&&s.keyFn||this.config.dataIdFromObject;p;){var l=p(e,a);if(!Array.isArray(l)){o=l;break}p=E(l)}return o=o&&String(o),a.keyObject?[o,a.keyObject]:[o]},r.prototype.addTypePolicies=function(e){var i=this;Object.keys(e).forEach((function(r){var o=e[r],n=o.queryType,a=o.mutationType,s=o.subscriptionType,p=t(o,["queryType","mutationType","subscriptionType"]);n&&i.setRootTypename("Query",r),a&&i.setRootTypename("Mutation",r),s&&i.setRootTypename("Subscription",r),f.call(i.toBeAdded,r)?i.toBeAdded[r].push(p):i.toBeAdded[r]=[p]}))},r.prototype.updateTypePolicy=function(e,t){var i=this,r=this.getTypePolicy(e),o=t.keyFields,n=t.fields;function a(e,t){e.merge="function"==typeof t?t:!0===t?F:!1===t?P:e.merge}a(r,t.merge),r.keyFn=!1===o?T:Array.isArray(o)?E(o):"function"==typeof o?o:r.keyFn,n&&Object.keys(n).forEach((function(t){var r=i.getFieldPolicy(e,t,!0),o=n[t];if("function"==typeof o)r.read=o;else{var s=o.keyArgs,p=o.read,l=o.merge;r.keyFn=!1===s?S:Array.isArray(s)?A(s):"function"==typeof s?s:r.keyFn,"function"==typeof p&&(r.read=p),a(r,l)}r.read&&r.merge&&(r.keyFn=r.keyFn||S)}))},r.prototype.setRootTypename=function(e,t){void 0===t&&(t=e);var r="ROOT_"+e.toUpperCase(),o=this.rootTypenamesById[r];t!==o&&("production"===process.env.NODE_ENV?i(!o||o===e,1):i(!o||o===e,"Cannot change root "+e+" __typename more than once"),o&&delete this.rootIdsByTypename[o],this.rootIdsByTypename[t]=r,this.rootTypenamesById[r]=t)},r.prototype.addPossibleTypes=function(e){var t=this;this.usingPossibleTypes=!0,Object.keys(e).forEach((function(i){t.getSupertypeSet(i,!0),e[i].forEach((function(e){t.getSupertypeSet(e,!0).add(i);var r=e.match(d);r&&r[0]===e||t.fuzzySubtypes.set(e,new RegExp(e))}))}))},r.prototype.getTypePolicy=function(e){var i=this;if(!f.call(this.typePolicies,e)){var r=this.typePolicies[e]=Object.create(null);r.fields=Object.create(null);var o=this.supertypeMap.get(e);o&&o.size&&o.forEach((function(e){var o=i.getTypePolicy(e),n=o.fields,a=t(o,["fields"]);Object.assign(r,a),Object.assign(r.fields,n)}))}var n=this.toBeAdded[e];return n&&n.length&&this.updateTypePolicy(e,u.apply(void 0,n.splice(0))),this.typePolicies[e]},r.prototype.getFieldPolicy=function(e,t,i){if(e){var r=this.getTypePolicy(e).fields;return r[t]||i&&(r[t]=Object.create(null))}},r.prototype.getSupertypeSet=function(e,t){var i=this.supertypeMap.get(e);return!i&&t&&this.supertypeMap.set(e,i=new Set),i},r.prototype.fragmentMatches=function(e,t,r,o){var n=this;if(!e.typeCondition)return!0;if(!t)return!1;var a=e.typeCondition.name.value;if(t===a)return!0;if(this.usingPossibleTypes&&this.supertypeMap.has(a))for(var s=this.getSupertypeSet(t,!0),p=[s],l=function(e){var t=n.getSupertypeSet(e,!1);t&&t.size&&p.indexOf(t)<0&&p.push(t)},c=!(!r||!this.fuzzySubtypes.size),y=!1,u=0;u<p.length;++u){var f=p[u];if(f.has(a))return s.has(a)||(y&&("production"===process.env.NODE_ENV||i.warn("Inferring subtype "+t+" of supertype "+a)),s.add(a)),!0;f.forEach(l),c&&u===p.length-1&&m(e.selectionSet,r,o)&&(c=!1,y=!0,this.fuzzySubtypes.forEach((function(e,i){var r=t.match(e);r&&r[0]===t&&l(i)})))}return!1},r.prototype.hasKeyArgs=function(e,t){var i=this.getFieldPolicy(e,t,!1);return!(!i||!i.keyFn)},r.prototype.getStoreFieldName=function(e){var t,i=e.typename,r=e.fieldName,o=this.getFieldPolicy(i,r,!1),n=o&&o.keyFn;if(n&&i)for(var a={typename:i,fieldName:r,field:e.field||null,variables:e.variables},l=j(e);n;){var c=n(l,a);if(!Array.isArray(c)){t=c||r;break}n=A(c)}return void 0===t&&(t=e.field?s(e.field,e.variables):p(r,j(e))),r===h(t)?t:r+":"+t},r.prototype.readField=function(e,t){var i=e.from;if(i&&(e.field||e.fieldName)){if(void 0===e.typename){var r=t.store.getFieldValue(i,"__typename");r&&(e.typename=r)}var o=this.getStoreFieldName(e),n=h(o),a=t.store.getFieldValue(i,o),s=this.getFieldPolicy(e.typename,n,!1),p=s&&s.read;if(p){var c=_(this,i,e,t,t.store.getStorage(l(i)?i.__ref:i,o));return g.withValue(this.cache,p,[a,c])}return a}},r.prototype.getMergeFunction=function(e,t,i){var r=this.getFieldPolicy(e,t,!1),o=r&&r.merge;return!o&&i&&(o=(r=this.getTypePolicy(i))&&r.merge),o},r.prototype.runMergeFunction=function(e,t,i,r,o){var n=i.field,a=i.typename,s=i.merge;return s===F?k(r.store.getFieldValue)(e,t):s===P?t:s(e,t,_(this,void 0,{typename:a,fieldName:n.name.value,field:n,variables:r.variables},r,o||Object.create(null)))},r}();function _(t,i,r,o,n){var a=t.getStoreFieldName(r),s=h(a),p=r.variables||o.variables,c=o.store,y=c.getFieldValue,u=c.toReference,f=c.canRead;return{args:j(r),field:r.field||null,fieldName:s,storeFieldName:a,variables:p,isReference:l,toReference:u,storage:n,cache:t.cache,canRead:f,readField:function(r,n){var a="string"==typeof r?{fieldName:r,from:n}:e({},r);return void 0===a.from&&(a.from=i),void 0===a.variables&&(a.variables=p),t.readField(a,o)},mergeObjects:k(y)}}function k(t){return function(i,o){if(Array.isArray(i)||Array.isArray(o))throw"production"===process.env.NODE_ENV?new r(2):new r("Cannot automatically merge arrays");if(i&&"object"==typeof i&&o&&"object"==typeof o){var n=t(i,"__typename"),a=t(o,"__typename");return!(n&&a&&n!==a)&&v(i)&&v(o)?e(e({},i),o):o}return o}}function A(e){return function(t,i){return t?i.fieldName+":"+JSON.stringify(R(t,e,!1)):i.fieldName}}function E(e){var t=new b(y);return function(i,r){var o;if(r.selectionSet&&r.fragmentMap){var n=t.lookupArray([r.selectionSet,r.fragmentMap]);o=n.aliasMap||(n.aliasMap=M(r.selectionSet,r.fragmentMap))}var a=r.keyObject=R(i,e,!0,o);return r.typename+":"+JSON.stringify(a)}}function M(e,t){var i=Object.create(null),r=new Set([e]);return r.forEach((function(e){e.selections.forEach((function(e){if(c(e)){if(e.alias){var n=e.alias.value,a=e.name.value;if(a!==n)(i.aliases||(i.aliases=Object.create(null)))[a]=n}if(e.selectionSet)(i.subsets||(i.subsets=Object.create(null)))[e.name.value]=M(e.selectionSet,t)}else{var s=o(e,t);s&&r.add(s.selectionSet)}}))})),i}function R(e,t,r,o){var n,a=Object.create(null);return t.forEach((function(t){if(Array.isArray(t)){if("string"==typeof n){var s=o&&o.subsets,p=s&&s[n];a[n]=R(e[n],t,r,p)}}else{var l=o&&o.aliases,c=l&&l[t]||t;f.call(e,c)?a[n=t]=e[c]:("production"===process.env.NODE_ENV?i(!r,3):i(!r,"Missing field '"+c+"' while computing key fields"),n=void 0)}})),a}export{N as Policies,O as defaultDataIdFromObject};
@@ -1 +1 @@
1
- import{__assign as e}from"../../../../tslib/tslib.es6.js";import{wrap as t}from"../../../../optimism/lib/bundle.esm.js";import{InvariantError as r,invariant as i}from"../../../../ts-invariant/lib/invariant.esm.js";import{shouldInclude as n}from"../../utilities/graphql/directives.js";import{createFragmentMap as s,getFragmentFromSelection as o}from"../../utilities/graphql/fragments.js";import{getDefaultValues as c,getQueryDefinition as a,getMainDefinition as l,getFragmentDefinitions as u}from"../../utilities/graphql/getFromAST.js";import{isReference as p,makeReference as f,isField as m,resultKeyNameFromField as y}from"../../utilities/graphql/storeUtils.js";import{addTypenameToDocument as d}from"../../utilities/graphql/transform.js";import{mergeDeepArray as v}from"../../utilities/common/mergeDeep.js";import"../../utilities/observables/Observable.js";import{maybeDeepFreeze as h}from"../../utilities/common/maybeDeepFreeze.js";import"../../utilities/observables/Concast.js";import{supportsResultCaching as S}from"./entityStore.js";import{getTypenameFromStoreObject as g}from"./helpers.js";import{MissingFieldError as b}from"../core/types/common.js";function j(e,t){return new b(e.message,t.path.slice(),t.query,t.clientOnly,t.variables)}var O=function(){function g(r){var i=this;this.config=r,this.executeSelectionSet=t((function(e){return i.execSelectionSetImpl(e)}),{keyArgs:function(e){return[e.selectionSet,e.objectOrReference,e.context]},makeCacheKey:function(e,t,r){if(S(r.store))return r.store.makeCacheKey(e,p(t)?t.__ref:t,r.varString)}}),this.knownResults=new WeakMap,this.executeSubSelectedArray=t((function(e){return i.execSubSelectedArrayImpl(e)}),{makeCacheKey:function(e){var t=e.field,r=e.array,i=e.context;if(S(i.store))return i.store.makeCacheKey(t,r,i.varString)}}),this.config=e({addTypename:!0},r)}return g.prototype.diffQueryAgainstStore=function(t){var r=t.store,i=t.query,n=t.rootId,o=void 0===n?"ROOT_QUERY":n,p=t.variables,m=t.returnPartialData,y=void 0===m||m,d=this.config.cache.policies;p=e(e({},c(a(i))),p);var v=this.executeSelectionSet({selectionSet:l(i).selectionSet,objectOrReference:f(o),context:{store:r,query:i,policies:d,variables:p,varString:JSON.stringify(p),fragmentMap:s(u(i)),path:[],clientOnly:!1}}),h=v.missing&&v.missing.length>0;if(h&&!y)throw v.missing[0];return{result:v.result,missing:v.missing,complete:!h}},g.prototype.isFresh=function(e,t,r,i){if(S(i.store)&&this.knownResults.get(e)===r){var n=this.executeSelectionSet.peek(r,t,i);if(n&&e===n.result)return!0}return!1},g.prototype.execSelectionSetImpl=function(e){var t=this,s=e.selectionSet,c=e.objectOrReference,a=e.context;if(p(c)&&!a.policies.rootTypenamesById[c.__ref]&&!a.store.has(c.__ref))return{result:{},missing:[j("production"===process.env.NODE_ENV?new r(4):new r("Dangling reference to missing "+c.__ref+" object"),a)]};var l=a.variables,u=a.policies,f=a.store,S=[],g={result:null},b=f.getFieldValue(c,"__typename");function O(){return g.missing||(g.missing=[])}function _(e){var t;return e.missing&&(t=O()).push.apply(t,e.missing),e.result}this.config.addTypename&&"string"==typeof b&&!u.rootIdsByTypename[b]&&S.push({__typename:b});var E=new Set(s.selections);return E.forEach((function(e){var s;if(n(e,l))if(m(e)){var f=u.readField({fieldName:e.name.value,field:e,variables:a.variables,from:c},a),v=y(e);a.path.push(v);var g=a.clientOnly;a.clientOnly=g||!(!e.directives||!e.directives.some((function(e){return"client"===e.name.value}))),void 0===f?d.added(e)||O().push(j("production"===process.env.NODE_ENV?new r(5):new r("Can't find field '"+e.name.value+"' on "+(p(c)?c.__ref+" object":"object "+JSON.stringify(c,null,2))),a)):Array.isArray(f)?f=_(t.executeSubSelectedArray({field:e,array:f,context:a})):e.selectionSet?null!=f&&(f=_(t.executeSelectionSet({selectionSet:e.selectionSet,objectOrReference:f,context:a}))):"production"!==process.env.NODE_ENV&&(x(a.store,e,f),h(f)),void 0!==f&&S.push(((s={})[v]=f,s)),a.clientOnly=g,i(a.path.pop()===v)}else{var N=o(e,a.fragmentMap);N&&u.fragmentMatches(N,b)&&N.selectionSet.selections.forEach(E.add,E)}})),g.result=v(S),"production"!==process.env.NODE_ENV&&Object.freeze(g.result),this.knownResults.set(g.result,s),g},g.prototype.execSubSelectedArrayImpl=function(e){var t,r=this,n=e.field,s=e.array,o=e.context;function c(e,r){return e.missing&&(t=t||[]).push.apply(t,e.missing),i(o.path.pop()===r),e.result}return n.selectionSet&&(s=s.filter(o.store.canRead)),s=s.map((function(e,t){return null===e?null:(o.path.push(t),Array.isArray(e)?c(r.executeSubSelectedArray({field:n,array:e,context:o}),t):n.selectionSet?c(r.executeSelectionSet({selectionSet:n.selectionSet,objectOrReference:e,context:o}),t):("production"!==process.env.NODE_ENV&&x(o.store,n,e),i(o.path.pop()===t),e))})),"production"!==process.env.NODE_ENV&&Object.freeze(s),{result:s,missing:t}},g}();function x(e,t,r){if(!t.selectionSet){var n=new Set([r]);n.forEach((function(r){r&&"object"==typeof r&&("production"===process.env.NODE_ENV?i(!p(r),6):i(!p(r),"Missing selection set for object of type "+g(e,r)+" returned for query field "+t.name.value),Object.values(r).forEach(n.add,n))}))}}export{O as StoreReader};
1
+ import{__assign as e}from'../../ext/tslib/tslib.es6.js';import{wrap as t}from"../../../../optimism/lib/bundle.esm.js";import{InvariantError as r,invariant as i}from"../../../../ts-invariant/lib/invariant.esm.js";import{shouldInclude as n}from"../../utilities/graphql/directives.js";import{createFragmentMap as s,getFragmentFromSelection as o}from"../../utilities/graphql/fragments.js";import{getDefaultValues as c,getQueryDefinition as a,getMainDefinition as l,getFragmentDefinitions as u}from"../../utilities/graphql/getFromAST.js";import{isReference as p,makeReference as f,isField as m,resultKeyNameFromField as d}from"../../utilities/graphql/storeUtils.js";import{addTypenameToDocument as y}from"../../utilities/graphql/transform.js";import{mergeDeepArray as v}from"../../utilities/common/mergeDeep.js";import"../../utilities/observables/Observable.js";import{maybeDeepFreeze as h}from"../../utilities/common/maybeDeepFreeze.js";import"../../utilities/observables/Concast.js";import{supportsResultCaching as S}from"./entityStore.js";import{getTypenameFromStoreObject as g}from"./helpers.js";import{MissingFieldError as b}from"../core/types/common.js";function j(e,t){return new b(e.message,t.path.slice(),t.query,t.clientOnly,t.variables)}var O=function(){function g(r){var i=this;this.config=r,this.executeSelectionSet=t((function(e){return i.execSelectionSetImpl(e)}),{keyArgs:function(e){return[e.selectionSet,e.objectOrReference,e.context]},makeCacheKey:function(e,t,r){if(S(r.store))return r.store.makeCacheKey(e,p(t)?t.__ref:t,r.varString)}}),this.knownResults=new WeakMap,this.executeSubSelectedArray=t((function(e){return i.execSubSelectedArrayImpl(e)}),{makeCacheKey:function(e){var t=e.field,r=e.array,i=e.context;if(S(i.store))return i.store.makeCacheKey(t,r,i.varString)}}),this.config=e({addTypename:!0},r)}return g.prototype.diffQueryAgainstStore=function(t){var r=t.store,i=t.query,n=t.rootId,o=void 0===n?"ROOT_QUERY":n,p=t.variables,m=t.returnPartialData,d=void 0===m||m,y=this.config.cache.policies;p=e(e({},c(a(i))),p);var v=this.executeSelectionSet({selectionSet:l(i).selectionSet,objectOrReference:f(o),context:{store:r,query:i,policies:y,variables:p,varString:JSON.stringify(p),fragmentMap:s(u(i)),path:[],clientOnly:!1}}),h=v.missing&&v.missing.length>0;if(h&&!d)throw v.missing[0];return{result:v.result,missing:v.missing,complete:!h}},g.prototype.isFresh=function(e,t,r,i){if(S(i.store)&&this.knownResults.get(e)===r){var n=this.executeSelectionSet.peek(r,t,i);if(n&&e===n.result)return!0}return!1},g.prototype.execSelectionSetImpl=function(e){var t=this,s=e.selectionSet,c=e.objectOrReference,a=e.context;if(p(c)&&!a.policies.rootTypenamesById[c.__ref]&&!a.store.has(c.__ref))return{result:{},missing:[j("production"===process.env.NODE_ENV?new r(4):new r("Dangling reference to missing "+c.__ref+" object"),a)]};var l=a.variables,u=a.policies,f=a.store,S=[],g={result:null},b=f.getFieldValue(c,"__typename");function O(){return g.missing||(g.missing=[])}function x(e){var t;return e.missing&&(t=O()).push.apply(t,e.missing),e.result}this.config.addTypename&&"string"==typeof b&&!u.rootIdsByTypename[b]&&S.push({__typename:b});var E=new Set(s.selections);return E.forEach((function(e){var s;if(n(e,l))if(m(e)){var f=u.readField({fieldName:e.name.value,field:e,variables:a.variables,from:c},a),v=d(e);a.path.push(v);var g=a.clientOnly;a.clientOnly=g||!(!e.directives||!e.directives.some((function(e){return"client"===e.name.value}))),void 0===f?y.added(e)||O().push(j("production"===process.env.NODE_ENV?new r(5):new r("Can't find field '"+e.name.value+"' on "+(p(c)?c.__ref+" object":"object "+JSON.stringify(c,null,2))),a)):Array.isArray(f)?f=x(t.executeSubSelectedArray({field:e,array:f,context:a})):e.selectionSet?null!=f&&(f=x(t.executeSelectionSet({selectionSet:e.selectionSet,objectOrReference:f,context:a}))):"production"!==process.env.NODE_ENV&&(_(a.store,e,f),h(f)),void 0!==f&&S.push(((s={})[v]=f,s)),a.clientOnly=g,i(a.path.pop()===v)}else{var N=o(e,a.fragmentMap);N&&u.fragmentMatches(N,b)&&N.selectionSet.selections.forEach(E.add,E)}})),g.result=v(S),"production"!==process.env.NODE_ENV&&Object.freeze(g.result),this.knownResults.set(g.result,s),g},g.prototype.execSubSelectedArrayImpl=function(e){var t,r=this,n=e.field,s=e.array,o=e.context;function c(e,r){return e.missing&&(t=t||[]).push.apply(t,e.missing),i(o.path.pop()===r),e.result}return n.selectionSet&&(s=s.filter(o.store.canRead)),s=s.map((function(e,t){return null===e?null:(o.path.push(t),Array.isArray(e)?c(r.executeSubSelectedArray({field:n,array:e,context:o}),t):n.selectionSet?c(r.executeSelectionSet({selectionSet:n.selectionSet,objectOrReference:e,context:o}),t):("production"!==process.env.NODE_ENV&&_(o.store,n,e),i(o.path.pop()===t),e))})),"production"!==process.env.NODE_ENV&&Object.freeze(s),{result:s,missing:t}},g}();function _(e,t,r){if(!t.selectionSet){var n=new Set([r]);n.forEach((function(r){r&&"object"==typeof r&&("production"===process.env.NODE_ENV?i(!p(r),6):i(!p(r),"Missing selection set for object of type "+g(e,r)+" returned for query field "+t.name.value),Object.values(r).forEach(n.add,n))}))}}export{O as StoreReader};
@@ -1 +1 @@
1
- import{__assign as e}from"../../../../tslib/tslib.es6.js";import{InvariantError as t,invariant as r}from"../../../../ts-invariant/lib/invariant.esm.js";import i from"../../../../@wry/equality/lib/equality.esm.js";import{shouldInclude as n,hasDirectives as o}from"../../utilities/graphql/directives.js";import{createFragmentMap as a,getFragmentFromSelection as s}from"../../utilities/graphql/fragments.js";import{getOperationDefinition as l,getDefaultValues as c,getFragmentDefinitions as u}from"../../utilities/graphql/getFromAST.js";import{isReference as p,getTypenameFromResult as f,isField as m,resultKeyNameFromField as g,makeReference as d}from"../../utilities/graphql/storeUtils.js";import"../../utilities/graphql/transform.js";import"../../utilities/common/mergeDeep.js";import"../../utilities/observables/Observable.js";import{cloneDeep as v}from"../../utilities/common/cloneDeep.js";import"../../utilities/observables/Concast.js";import{makeProcessedFieldsMerger as h,storeValueIsStoreObject as y,fieldNameFromStoreName as b}from"./helpers.js";var S=function(){function S(e,t){this.cache=e,this.reader=t}return S.prototype.writeToStore=function(r){var i=r.query,n=r.result,o=r.dataId,s=r.store,f=r.variables,m=l(i),g=h();f=e(e({},c(m)),f);var d=this.processSelectionSet({result:n||Object.create(null),dataId:o,selectionSet:m.selectionSet,mergeTree:{map:new Map},context:{store:s,written:Object.create(null),merge:function(e,t){return g.merge(e,t)},variables:f,varString:JSON.stringify(f),fragmentMap:a(u(i))}});if(!p(d))throw"production"===process.env.NODE_ENV?new t(7):new t("Could not identify object "+JSON.stringify(n));return s.retain(d.__ref),d},S.prototype.processSelectionSet=function(e){var a=this,l=e.dataId,c=e.result,u=e.selectionSet,v=e.context,h=e.mergeTree,y=this.cache.policies,S=y.identify(c,u,v.fragmentMap),j=S[0],N=S[1];if("string"==typeof(l=l||j)){var O=v.written[l]||(v.written[l]=[]),F=d(l);if(O.indexOf(u)>=0)return F;if(O.push(u),this.reader&&this.reader.isFresh(c,F,u,v))return F}var M=Object.create(null);N&&(M=v.merge(M,N));var V=l&&y.rootTypenamesById[l]||f(c,u,v.fragmentMap)||l&&v.store.get(l,"__typename");"string"==typeof V&&(M.__typename=V);var A=new Set(u.selections);if(A.forEach((function(e){var r;if(n(e,v.variables))if(m(e)){var i=g(e),l=c[i];if(void 0!==l){var u=y.getStoreFieldName({typename:V,fieldName:e.name.value,field:e,variables:v.variables}),p=_(h,u),f=a.processFieldValue(l,e,v,p),d=e.selectionSet&&v.store.getFieldValue(f,"__typename")||void 0,b=y.getMergeFunction(V,e.name.value,d);b?p.info={field:e,typename:V,merge:b}:w(h,u),M=v.merge(M,((r={})[u]=f,r))}else if(y.usingPossibleTypes&&!o(["defer","client"],e))throw"production"===process.env.NODE_ENV?new t(8):new t("Missing field '"+i+"' in "+JSON.stringify(c,null,2).substring(0,100))}else{var S=s(e,v.fragmentMap);S&&y.fragmentMatches(S,V,c,v.variables)&&S.selectionSet.selections.forEach(A.add,A)}})),"string"==typeof l){var D=d(l);if(h.map.size&&(M=this.applyMerges(h,D,M,v)),"production"!==process.env.NODE_ENV){var q=new Set;A.forEach((function(e){m(e)&&e.selectionSet&&q.add(e.name.value)}));Object.keys(M).forEach((function(e){(function(e){return q.has(b(e))})(e)&&!function(e){var t=h.map.get(e);return Boolean(t&&t.info&&t.info.merge)}(e)&&function(e,t,n,o){var a=function(e){var t=o.getFieldValue(e,n);return"object"==typeof t&&t},s=a(e);if(!s)return;var l=a(t);if(!l)return;if(p(s))return;if(i(s,l))return;if(Object.keys(s).every((function(e){return void 0!==o.getFieldValue(l,e)})))return;var c=o.getFieldValue(e,"__typename")||o.getFieldValue(t,"__typename"),u=b(n),f=c+"."+u;if(E.has(f))return;E.add(f);var m=[];Array.isArray(s)||Array.isArray(l)||[s,l].forEach((function(e){var t=o.getFieldValue(e,"__typename");"string"!=typeof t||m.includes(t)||m.push(t)}));"production"===process.env.NODE_ENV||r.warn("Cache data may be lost when replacing the "+u+" field of a "+c+" object.\n\nTo address this problem (which is not a bug in Apollo Client), "+(m.length?"either ensure all objects of type "+m.join(" and ")+" have an ID or a custom merge function, or ":"")+"define a custom merge function for the "+f+" field, so InMemoryCache can safely merge these objects:\n\n existing: "+JSON.stringify(s).slice(0,1e3)+"\n incoming: "+JSON.stringify(l).slice(0,1e3)+"\n\nFor more information about these options, please refer to the documentation:\n\n * Ensuring entity objects have IDs: https://go.apollo.dev/c/generating-unique-identifiers\n * Defining custom merge functions: https://go.apollo.dev/c/merging-non-normalized-objects\n")}(D,M,e,v.store)}))}return v.store.merge(l,M),D}return M},S.prototype.processFieldValue=function(e,t,r,i){var n=this;return t.selectionSet&&null!==e?Array.isArray(e)?e.map((function(e,o){var a=n.processFieldValue(e,t,r,_(i,o));return w(i,o),a})):this.processSelectionSet({result:e,selectionSet:t.selectionSet,context:r,mergeTree:i}):"production"===process.env.NODE_ENV?e:v(e)},S.prototype.applyMerges=function(t,i,n,o,a){var s,l=this;if(t.map.size&&!p(n)){var c,u=Array.isArray(n)||!p(i)&&!y(i)?void 0:i,f=n;u&&!a&&(a=[p(u)?u.__ref:u]);var m=function(e,t){return Array.isArray(e)?"number"==typeof t?e[t]:void 0:o.store.getFieldValue(e,String(t))};t.map.forEach((function(e,t){a&&a.push(t);var i=m(u,t),n=m(f,t),s=l.applyMerges(e,i,n,o,a);s!==n&&(c=c||new Map).set(t,s),a&&r(a.pop()===t)})),c&&(n=Array.isArray(f)?f.slice(0):e({},f),c.forEach((function(e,t){n[t]=e})))}return t.info?this.cache.policies.runMergeFunction(i,n,t.info,o,a&&(s=o.store).getStorage.apply(s,a)):n},S}(),j=[];function _(e,t){var r=e.map;return r.has(t)||r.set(t,j.pop()||{map:new Map}),r.get(t)}function w(e,t){var r=e.map,i=r.get(t);!i||i.info||i.map.size||(j.push(i),r.delete(t))}var E=new Set;export{S as StoreWriter};
1
+ import{__assign as e}from'../../ext/tslib/tslib.es6.js';import{InvariantError as t,invariant as r}from"../../../../ts-invariant/lib/invariant.esm.js";import i from"../../../../@wry/equality/lib/equality.esm.js";import{shouldInclude as n,hasDirectives as o}from"../../utilities/graphql/directives.js";import{createFragmentMap as a,getFragmentFromSelection as s}from"../../utilities/graphql/fragments.js";import{getOperationDefinition as l,getDefaultValues as c,getFragmentDefinitions as u}from"../../utilities/graphql/getFromAST.js";import{isReference as p,getTypenameFromResult as f,isField as m,resultKeyNameFromField as g,makeReference as d}from"../../utilities/graphql/storeUtils.js";import"../../utilities/graphql/transform.js";import"../../utilities/common/mergeDeep.js";import"../../utilities/observables/Observable.js";import{cloneDeep as v}from"../../utilities/common/cloneDeep.js";import"../../utilities/observables/Concast.js";import{makeProcessedFieldsMerger as h,storeValueIsStoreObject as y,fieldNameFromStoreName as b}from"./helpers.js";var S=function(){function S(e,t){this.cache=e,this.reader=t}return S.prototype.writeToStore=function(r){var i=r.query,n=r.result,o=r.dataId,s=r.store,f=r.variables,m=l(i),g=h();f=e(e({},c(m)),f);var d=this.processSelectionSet({result:n||Object.create(null),dataId:o,selectionSet:m.selectionSet,mergeTree:{map:new Map},context:{store:s,written:Object.create(null),merge:function(e,t){return g.merge(e,t)},variables:f,varString:JSON.stringify(f),fragmentMap:a(u(i))}});if(!p(d))throw"production"===process.env.NODE_ENV?new t(7):new t("Could not identify object "+JSON.stringify(n));return s.retain(d.__ref),d},S.prototype.processSelectionSet=function(e){var a=this,l=e.dataId,c=e.result,u=e.selectionSet,v=e.context,h=e.mergeTree,y=this.cache.policies,S=y.identify(c,u,v.fragmentMap),j=S[0],N=S[1];if("string"==typeof(l=l||j)){var O=v.written[l]||(v.written[l]=[]),F=d(l);if(O.indexOf(u)>=0)return F;if(O.push(u),this.reader&&this.reader.isFresh(c,F,u,v))return F}var M=Object.create(null);N&&(M=v.merge(M,N));var V=l&&y.rootTypenamesById[l]||f(c,u,v.fragmentMap)||l&&v.store.get(l,"__typename");"string"==typeof V&&(M.__typename=V);var A=new Set(u.selections);if(A.forEach((function(e){var r;if(n(e,v.variables))if(m(e)){var i=g(e),l=c[i];if(void 0!==l){var u=y.getStoreFieldName({typename:V,fieldName:e.name.value,field:e,variables:v.variables}),p=_(h,u),f=a.processFieldValue(l,e,v,p),d=e.selectionSet&&v.store.getFieldValue(f,"__typename")||void 0,b=y.getMergeFunction(V,e.name.value,d);b?p.info={field:e,typename:V,merge:b}:w(h,u),M=v.merge(M,((r={})[u]=f,r))}else if(y.usingPossibleTypes&&!o(["defer","client"],e))throw"production"===process.env.NODE_ENV?new t(8):new t("Missing field '"+i+"' in "+JSON.stringify(c,null,2).substring(0,100))}else{var S=s(e,v.fragmentMap);S&&y.fragmentMatches(S,V,c,v.variables)&&S.selectionSet.selections.forEach(A.add,A)}})),"string"==typeof l){var D=d(l);if(h.map.size&&(M=this.applyMerges(h,D,M,v)),"production"!==process.env.NODE_ENV){var q=new Set;A.forEach((function(e){m(e)&&e.selectionSet&&q.add(e.name.value)}));Object.keys(M).forEach((function(e){(function(e){return q.has(b(e))})(e)&&!function(e){var t=h.map.get(e);return Boolean(t&&t.info&&t.info.merge)}(e)&&function(e,t,n,o){var a=function(e){var t=o.getFieldValue(e,n);return"object"==typeof t&&t},s=a(e);if(!s)return;var l=a(t);if(!l)return;if(p(s))return;if(i(s,l))return;if(Object.keys(s).every((function(e){return void 0!==o.getFieldValue(l,e)})))return;var c=o.getFieldValue(e,"__typename")||o.getFieldValue(t,"__typename"),u=b(n),f=c+"."+u;if(E.has(f))return;E.add(f);var m=[];Array.isArray(s)||Array.isArray(l)||[s,l].forEach((function(e){var t=o.getFieldValue(e,"__typename");"string"!=typeof t||m.includes(t)||m.push(t)}));"production"===process.env.NODE_ENV||r.warn("Cache data may be lost when replacing the "+u+" field of a "+c+" object.\n\nTo address this problem (which is not a bug in Apollo Client), "+(m.length?"either ensure all objects of type "+m.join(" and ")+" have an ID or a custom merge function, or ":"")+"define a custom merge function for the "+f+" field, so InMemoryCache can safely merge these objects:\n\n existing: "+JSON.stringify(s).slice(0,1e3)+"\n incoming: "+JSON.stringify(l).slice(0,1e3)+"\n\nFor more information about these options, please refer to the documentation:\n\n * Ensuring entity objects have IDs: https://go.apollo.dev/c/generating-unique-identifiers\n * Defining custom merge functions: https://go.apollo.dev/c/merging-non-normalized-objects\n")}(D,M,e,v.store)}))}return v.store.merge(l,M),D}return M},S.prototype.processFieldValue=function(e,t,r,i){var n=this;return t.selectionSet&&null!==e?Array.isArray(e)?e.map((function(e,o){var a=n.processFieldValue(e,t,r,_(i,o));return w(i,o),a})):this.processSelectionSet({result:e,selectionSet:t.selectionSet,context:r,mergeTree:i}):"production"===process.env.NODE_ENV?e:v(e)},S.prototype.applyMerges=function(t,i,n,o,a){var s,l=this;if(t.map.size&&!p(n)){var c,u=Array.isArray(n)||!p(i)&&!y(i)?void 0:i,f=n;u&&!a&&(a=[p(u)?u.__ref:u]);var m=function(e,t){return Array.isArray(e)?"number"==typeof t?e[t]:void 0:o.store.getFieldValue(e,String(t))};t.map.forEach((function(e,t){a&&a.push(t);var i=m(u,t),n=m(f,t),s=l.applyMerges(e,i,n,o,a);s!==n&&(c=c||new Map).set(t,s),a&&r(a.pop()===t)})),c&&(n=Array.isArray(f)?f.slice(0):e({},f),c.forEach((function(e,t){n[t]=e})))}return t.info?this.cache.policies.runMergeFunction(i,n,t.info,o,a&&(s=o.store).getStorage.apply(s,a)):n},S}(),j=[];function _(e,t){var r=e.map;return r.has(t)||r.set(t,j.pop()||{map:new Map}),r.get(t)}function w(e,t){var r=e.map,i=r.get(t);!i||i.info||i.map.size||(j.push(i),r.delete(t))}var E=new Set;export{S as StoreWriter};
@@ -1 +1 @@
1
- import{__assign as e}from"../../../tslib/tslib.es6.js";import{InvariantError as t,invariant as r}from"../../../ts-invariant/lib/invariant.esm.js";import{ApolloLink as o}from"../link/core/ApolloLink.js";import{execute as i}from"../link/core/execute.js";import"../utilities/graphql/transform.js";import"../utilities/common/mergeDeep.js";import"../utilities/observables/Observable.js";import"../utilities/observables/Concast.js";import{compact as s}from"../utilities/common/compact.js";import{version as n}from"../version.js";import{HttpLink as a}from"../link/http/HttpLink.js";import{QueryManager as c}from"./QueryManager.js";import{LocalState as l}from"./LocalState.js";var u=!1;function h(t,r){return s(t,r,r.variables&&{variables:e(e({},t.variables),r.variables)})}var p=function(){function s(e){var i=this;this.defaultOptions={},this.resetStoreCallbacks=[],this.clearStoreCallbacks=[];var s=e.uri,h=e.credentials,p=e.headers,f=e.cache,d=e.ssrMode,y=void 0!==d&&d,m=e.ssrForceFetchDelay,b=void 0===m?0:m,v=e.connectToDevTools,w=void 0===v?"object"==typeof window&&!window.__APOLLO_CLIENT__&&"production"!==process.env.NODE_ENV:v,k=e.queryDeduplication,g=void 0===k||k,O=e.defaultOptions,S=e.assumeImmutableResults,q=void 0!==S&&S,_=e.resolvers,M=e.typeDefs,Q=e.fragmentMatcher,F=e.name,C=e.version,j=e.link;if(j||(j=s?new a({uri:s,credentials:h,headers:p}):o.empty()),!f)throw"production"===process.env.NODE_ENV?new t(9):new t("To initialize Apollo Client, you must specify a 'cache' property in the options object. \nFor more information, please visit: https://go.apollo.dev/c/docs");if(this.link=j,this.cache=f,this.disableNetworkFetches=y||b>0,this.queryDeduplication=g,this.defaultOptions=O||{},this.typeDefs=M,b&&setTimeout((function(){return i.disableNetworkFetches=!1}),b),this.watchQuery=this.watchQuery.bind(this),this.query=this.query.bind(this),this.mutate=this.mutate.bind(this),this.resetStore=this.resetStore.bind(this),this.reFetchObservableQueries=this.reFetchObservableQueries.bind(this),w&&"object"==typeof window&&(window.__APOLLO_CLIENT__=this),!u&&"production"!==process.env.NODE_ENV&&(u=!0,"undefined"!=typeof window&&window.document&&window.top===window.self&&!window.__APOLLO_DEVTOOLS_GLOBAL_HOOK__)){var L=window.navigator,P=L&&L.userAgent,D=void 0;"string"==typeof P&&(P.indexOf("Chrome/")>-1?D="https://chrome.google.com/webstore/detail/apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm":P.indexOf("Firefox/")>-1&&(D="https://addons.mozilla.org/en-US/firefox/addon/apollo-developer-tools/")),D&&r.log("Download the Apollo DevTools for a better development experience: "+D)}this.version=n,this.localState=new l({cache:f,client:this,resolvers:_,fragmentMatcher:Q}),this.queryManager=new c({cache:this.cache,link:this.link,queryDeduplication:g,ssrMode:y,clientAwareness:{name:F,version:C},localState:this.localState,assumeImmutableResults:q,onBroadcast:w?function(){i.devToolsHookCb&&i.devToolsHookCb({action:{},state:{queries:i.queryManager.getQueryStore(),mutations:i.queryManager.mutationStore||{}},dataWithOptimisticResults:i.cache.extract(!0)})}:void 0})}return s.prototype.stop=function(){this.queryManager.stop()},s.prototype.watchQuery=function(t){return this.defaultOptions.watchQuery&&(t=h(this.defaultOptions.watchQuery,t)),!this.disableNetworkFetches||"network-only"!==t.fetchPolicy&&"cache-and-network"!==t.fetchPolicy||(t=e(e({},t),{fetchPolicy:"cache-first"})),this.queryManager.watchQuery(t)},s.prototype.query=function(t){return this.defaultOptions.query&&(t=h(this.defaultOptions.query,t)),"production"===process.env.NODE_ENV?r("cache-and-network"!==t.fetchPolicy,10):r("cache-and-network"!==t.fetchPolicy,"The cache-and-network fetchPolicy does not work with client.query, because client.query can only return a single result. Please use client.watchQuery to receive multiple results from the cache and the network, or consider using a different fetchPolicy, such as cache-first or network-only."),this.disableNetworkFetches&&"network-only"===t.fetchPolicy&&(t=e(e({},t),{fetchPolicy:"cache-first"})),this.queryManager.query(t)},s.prototype.mutate=function(e){return this.defaultOptions.mutate&&(e=h(this.defaultOptions.mutate,e)),this.queryManager.mutate(e)},s.prototype.subscribe=function(e){return this.queryManager.startGraphQLSubscription(e)},s.prototype.readQuery=function(e,t){return void 0===t&&(t=!1),this.cache.readQuery(e,t)},s.prototype.readFragment=function(e,t){return void 0===t&&(t=!1),this.cache.readFragment(e,t)},s.prototype.writeQuery=function(e){this.cache.writeQuery(e),this.queryManager.broadcastQueries()},s.prototype.writeFragment=function(e){this.cache.writeFragment(e),this.queryManager.broadcastQueries()},s.prototype.__actionHookForDevTools=function(e){this.devToolsHookCb=e},s.prototype.__requestRaw=function(e){return i(this.link,e)},s.prototype.resetStore=function(){var e=this;return Promise.resolve().then((function(){return e.queryManager.clearStore()})).then((function(){return Promise.all(e.resetStoreCallbacks.map((function(e){return e()})))})).then((function(){return e.reFetchObservableQueries()}))},s.prototype.clearStore=function(){var e=this;return Promise.resolve().then((function(){return e.queryManager.clearStore()})).then((function(){return Promise.all(e.clearStoreCallbacks.map((function(e){return e()})))}))},s.prototype.onResetStore=function(e){var t=this;return this.resetStoreCallbacks.push(e),function(){t.resetStoreCallbacks=t.resetStoreCallbacks.filter((function(t){return t!==e}))}},s.prototype.onClearStore=function(e){var t=this;return this.clearStoreCallbacks.push(e),function(){t.clearStoreCallbacks=t.clearStoreCallbacks.filter((function(t){return t!==e}))}},s.prototype.reFetchObservableQueries=function(e){return this.queryManager.reFetchObservableQueries(e)},s.prototype.extract=function(e){return this.cache.extract(e)},s.prototype.restore=function(e){return this.cache.restore(e)},s.prototype.addResolvers=function(e){this.localState.addResolvers(e)},s.prototype.setResolvers=function(e){this.localState.setResolvers(e)},s.prototype.getResolvers=function(){return this.localState.getResolvers()},s.prototype.setLocalStateFragmentMatcher=function(e){this.localState.setFragmentMatcher(e)},s.prototype.setLink=function(e){this.link=this.queryManager.link=e},s}();export{p as ApolloClient,h as mergeOptions};
1
+ import{__assign as e}from'../ext/tslib/tslib.es6.js';import{InvariantError as t,invariant as r}from"../../../ts-invariant/lib/invariant.esm.js";import{ApolloLink as o}from"../link/core/ApolloLink.js";import{execute as i}from"../link/core/execute.js";import"../utilities/graphql/transform.js";import"../utilities/common/mergeDeep.js";import"../utilities/observables/Observable.js";import"../utilities/observables/Concast.js";import{compact as s}from"../utilities/common/compact.js";import{version as n}from"../version.js";import{HttpLink as a}from"../link/http/HttpLink.js";import{QueryManager as c}from"./QueryManager.js";import{LocalState as l}from"./LocalState.js";var u=!1;function h(t,r){return s(t,r,r.variables&&{variables:e(e({},t.variables),r.variables)})}var p=function(){function s(e){var i=this;this.defaultOptions={},this.resetStoreCallbacks=[],this.clearStoreCallbacks=[];var s=e.uri,h=e.credentials,p=e.headers,f=e.cache,d=e.ssrMode,y=void 0!==d&&d,m=e.ssrForceFetchDelay,b=void 0===m?0:m,v=e.connectToDevTools,w=void 0===v?"object"==typeof window&&!window.__APOLLO_CLIENT__&&"production"!==process.env.NODE_ENV:v,k=e.queryDeduplication,g=void 0===k||k,O=e.defaultOptions,S=e.assumeImmutableResults,q=void 0!==S&&S,_=e.resolvers,M=e.typeDefs,Q=e.fragmentMatcher,F=e.name,C=e.version,j=e.link;if(j||(j=s?new a({uri:s,credentials:h,headers:p}):o.empty()),!f)throw"production"===process.env.NODE_ENV?new t(9):new t("To initialize Apollo Client, you must specify a 'cache' property in the options object. \nFor more information, please visit: https://go.apollo.dev/c/docs");if(this.link=j,this.cache=f,this.disableNetworkFetches=y||b>0,this.queryDeduplication=g,this.defaultOptions=O||{},this.typeDefs=M,b&&setTimeout((function(){return i.disableNetworkFetches=!1}),b),this.watchQuery=this.watchQuery.bind(this),this.query=this.query.bind(this),this.mutate=this.mutate.bind(this),this.resetStore=this.resetStore.bind(this),this.reFetchObservableQueries=this.reFetchObservableQueries.bind(this),w&&"object"==typeof window&&(window.__APOLLO_CLIENT__=this),!u&&"production"!==process.env.NODE_ENV&&(u=!0,"undefined"!=typeof window&&window.document&&window.top===window.self&&!window.__APOLLO_DEVTOOLS_GLOBAL_HOOK__)){var L=window.navigator,P=L&&L.userAgent,D=void 0;"string"==typeof P&&(P.indexOf("Chrome/")>-1?D="https://chrome.google.com/webstore/detail/apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm":P.indexOf("Firefox/")>-1&&(D="https://addons.mozilla.org/en-US/firefox/addon/apollo-developer-tools/")),D&&r.log("Download the Apollo DevTools for a better development experience: "+D)}this.version=n,this.localState=new l({cache:f,client:this,resolvers:_,fragmentMatcher:Q}),this.queryManager=new c({cache:this.cache,link:this.link,queryDeduplication:g,ssrMode:y,clientAwareness:{name:F,version:C},localState:this.localState,assumeImmutableResults:q,onBroadcast:w?function(){i.devToolsHookCb&&i.devToolsHookCb({action:{},state:{queries:i.queryManager.getQueryStore(),mutations:i.queryManager.mutationStore||{}},dataWithOptimisticResults:i.cache.extract(!0)})}:void 0})}return s.prototype.stop=function(){this.queryManager.stop()},s.prototype.watchQuery=function(t){return this.defaultOptions.watchQuery&&(t=h(this.defaultOptions.watchQuery,t)),!this.disableNetworkFetches||"network-only"!==t.fetchPolicy&&"cache-and-network"!==t.fetchPolicy||(t=e(e({},t),{fetchPolicy:"cache-first"})),this.queryManager.watchQuery(t)},s.prototype.query=function(t){return this.defaultOptions.query&&(t=h(this.defaultOptions.query,t)),"production"===process.env.NODE_ENV?r("cache-and-network"!==t.fetchPolicy,10):r("cache-and-network"!==t.fetchPolicy,"The cache-and-network fetchPolicy does not work with client.query, because client.query can only return a single result. Please use client.watchQuery to receive multiple results from the cache and the network, or consider using a different fetchPolicy, such as cache-first or network-only."),this.disableNetworkFetches&&"network-only"===t.fetchPolicy&&(t=e(e({},t),{fetchPolicy:"cache-first"})),this.queryManager.query(t)},s.prototype.mutate=function(e){return this.defaultOptions.mutate&&(e=h(this.defaultOptions.mutate,e)),this.queryManager.mutate(e)},s.prototype.subscribe=function(e){return this.queryManager.startGraphQLSubscription(e)},s.prototype.readQuery=function(e,t){return void 0===t&&(t=!1),this.cache.readQuery(e,t)},s.prototype.readFragment=function(e,t){return void 0===t&&(t=!1),this.cache.readFragment(e,t)},s.prototype.writeQuery=function(e){this.cache.writeQuery(e),this.queryManager.broadcastQueries()},s.prototype.writeFragment=function(e){this.cache.writeFragment(e),this.queryManager.broadcastQueries()},s.prototype.__actionHookForDevTools=function(e){this.devToolsHookCb=e},s.prototype.__requestRaw=function(e){return i(this.link,e)},s.prototype.resetStore=function(){var e=this;return Promise.resolve().then((function(){return e.queryManager.clearStore()})).then((function(){return Promise.all(e.resetStoreCallbacks.map((function(e){return e()})))})).then((function(){return e.reFetchObservableQueries()}))},s.prototype.clearStore=function(){var e=this;return Promise.resolve().then((function(){return e.queryManager.clearStore()})).then((function(){return Promise.all(e.clearStoreCallbacks.map((function(e){return e()})))}))},s.prototype.onResetStore=function(e){var t=this;return this.resetStoreCallbacks.push(e),function(){t.resetStoreCallbacks=t.resetStoreCallbacks.filter((function(t){return t!==e}))}},s.prototype.onClearStore=function(e){var t=this;return this.clearStoreCallbacks.push(e),function(){t.clearStoreCallbacks=t.clearStoreCallbacks.filter((function(t){return t!==e}))}},s.prototype.reFetchObservableQueries=function(e){return this.queryManager.reFetchObservableQueries(e)},s.prototype.extract=function(e){return this.cache.extract(e)},s.prototype.restore=function(e){return this.cache.restore(e)},s.prototype.addResolvers=function(e){this.localState.addResolvers(e)},s.prototype.setResolvers=function(e){this.localState.setResolvers(e)},s.prototype.getResolvers=function(){return this.localState.getResolvers()},s.prototype.setLocalStateFragmentMatcher=function(e){this.localState.setFragmentMatcher(e)},s.prototype.setLink=function(e){this.link=this.queryManager.link=e},s}();export{p as ApolloClient,h as mergeOptions};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t,__assign as r}from"../../../tslib/tslib.es6.js";import{invariant as o}from"../../../ts-invariant/lib/invariant.esm.js";import{hasDirectives as i,shouldInclude as n}from"../utilities/graphql/directives.js";import{createFragmentMap as s}from"../utilities/graphql/fragments.js";import{getMainDefinition as a,getFragmentDefinitions as u}from"../utilities/graphql/getFromAST.js";import{resultKeyNameFromField as l,argumentsObjectFromField as c,isField as v,isInlineFragment as h}from"../utilities/graphql/storeUtils.js";import{removeClientSetsFromDocument as p,buildQueryFromSelectionSet as m}from"../utilities/graphql/transform.js";import{mergeDeep as f,mergeDeepArray as d}from"../utilities/common/mergeDeep.js";import"../utilities/observables/Observable.js";import"../utilities/observables/Concast.js";import"../cache/core/cache.js";import"../cache/inmemory/inMemoryCache.js";import{cacheSlot as y}from"../cache/inmemory/reactiveVars.js";import"../cache/inmemory/policies.js";import{visit as g,BREAK as b}from"../../../graphql/language/visitor.mjs.js";var S=function(){function S(e){var t=e.cache,r=e.client,o=e.resolvers,i=e.fragmentMatcher;this.cache=t,r&&(this.client=r),o&&this.addResolvers(o),i&&this.setFragmentMatcher(i)}return S.prototype.addResolvers=function(e){var t=this;this.resolvers=this.resolvers||{},Array.isArray(e)?e.forEach((function(e){t.resolvers=f(t.resolvers,e)})):this.resolvers=f(this.resolvers,e)},S.prototype.setResolvers=function(e){this.resolvers={},this.addResolvers(e)},S.prototype.getResolvers=function(){return this.resolvers||{}},S.prototype.runResolvers=function(o){var i=o.document,n=o.remoteResult,s=o.context,a=o.variables,u=o.onlyRunForcedResolvers,l=void 0!==u&&u;return e(this,void 0,void 0,(function(){return t(this,(function(e){return i?[2,this.resolveDocument(i,n.data,s,a,this.fragmentMatcher,l).then((function(e){return r(r({},n),{data:e.result})}))]:[2,n]}))}))},S.prototype.setFragmentMatcher=function(e){this.fragmentMatcher=e},S.prototype.getFragmentMatcher=function(){return this.fragmentMatcher},S.prototype.clientQuery=function(e){return i(["client"],e)&&this.resolvers?e:null},S.prototype.serverQuery=function(e){return p(e)},S.prototype.prepareContext=function(e){var t=this.cache;return r(r({},e),{cache:t,getCacheKey:function(e){return t.identify(e)}})},S.prototype.addExportedVariables=function(o,i,n){return void 0===i&&(i={}),void 0===n&&(n={}),e(this,void 0,void 0,(function(){return t(this,(function(e){return o?[2,this.resolveDocument(o,this.buildRootValueFromCache(o,i)||{},this.prepareContext(n),i).then((function(e){return r(r({},i),e.exportedVariables)}))]:[2,r({},i)]}))}))},S.prototype.shouldForceResolvers=function(e){var t=!1;return g(e,{Directive:{enter:function(e){if("client"===e.name.value&&e.arguments&&(t=e.arguments.some((function(e){return"always"===e.name.value&&"BooleanValue"===e.value.kind&&!0===e.value.value}))))return b}}}),t},S.prototype.buildRootValueFromCache=function(e,t){return this.cache.diff({query:m(e),variables:t,returnPartialData:!0,optimistic:!1}).result},S.prototype.resolveDocument=function(o,i,n,l,c,v){return void 0===n&&(n={}),void 0===l&&(l={}),void 0===c&&(c=function(){return!0}),void 0===v&&(v=!1),e(this,void 0,void 0,(function(){var e,h,p,m,f,d,y,g,b;return t(this,(function(t){return e=a(o),h=u(o),p=s(h),m=e.operation,f=m?m.charAt(0).toUpperCase()+m.slice(1):"Query",y=(d=this).cache,g=d.client,b={fragmentMap:p,context:r(r({},n),{cache:y,client:g}),variables:l,fragmentMatcher:c,defaultOperationType:f,exportedVariables:{},onlyRunForcedResolvers:v},[2,this.resolveSelectionSet(e.selectionSet,i,b).then((function(e){return{result:e,exportedVariables:b.exportedVariables}}))]}))}))},S.prototype.resolveSelectionSet=function(r,i,s){return e(this,void 0,void 0,(function(){var a,u,c,p,m,f=this;return t(this,(function(y){return a=s.fragmentMap,u=s.context,c=s.variables,p=[i],m=function(r){return e(f,void 0,void 0,(function(){var e,m;return t(this,(function(t){return n(r,c)?v(r)?[2,this.resolveField(r,i,s).then((function(e){var t;void 0!==e&&p.push(((t={})[l(r)]=e,t))}))]:(h(r)?e=r:(e=a[r.name.value],"production"===process.env.NODE_ENV?o(e,11):o(e,"No fragment named "+r.name.value)),e&&e.typeCondition&&(m=e.typeCondition.name.value,s.fragmentMatcher(i,m,u))?[2,this.resolveSelectionSet(e.selectionSet,i,s).then((function(e){p.push(e)}))]:[2]):[2]}))}))},[2,Promise.all(r.selections.map(m)).then((function(){return d(p)}))]}))}))},S.prototype.resolveField=function(r,o,i){return e(this,void 0,void 0,(function(){var e,n,s,a,u,v,h,p,m,f=this;return t(this,(function(t){return e=i.variables,n=r.name.value,s=l(r),a=n!==s,u=o[s]||o[n],v=Promise.resolve(u),i.onlyRunForcedResolvers&&!this.shouldForceResolvers(r)||(h=o.__typename||i.defaultOperationType,(p=this.resolvers&&this.resolvers[h])&&(m=p[a?n:s])&&(v=Promise.resolve(y.withValue(this.cache,m,[o,c(r,e),i.context,{field:r,fragmentMap:i.fragmentMap}])))),[2,v.then((function(e){return void 0===e&&(e=u),r.directives&&r.directives.forEach((function(t){"export"===t.name.value&&t.arguments&&t.arguments.forEach((function(t){"as"===t.name.value&&"StringValue"===t.value.kind&&(i.exportedVariables[t.value.value]=e)}))})),r.selectionSet?null==e?e:Array.isArray(e)?f.resolveSubSelectedArray(r,e,i):r.selectionSet?f.resolveSelectionSet(r.selectionSet,e,i):void 0:e}))]}))}))},S.prototype.resolveSubSelectedArray=function(e,t,r){var o=this;return Promise.all(t.map((function(t){return null===t?null:Array.isArray(t)?o.resolveSubSelectedArray(e,t,r):e.selectionSet?o.resolveSelectionSet(e.selectionSet,t,r):void 0})))},S}();export{S as LocalState};
1
+ import{__awaiter as e,__assign as t,__generator as r}from'../ext/tslib/tslib.es6.js';import{invariant as o}from"../../../ts-invariant/lib/invariant.esm.js";import{hasDirectives as i,shouldInclude as n}from"../utilities/graphql/directives.js";import{createFragmentMap as s}from"../utilities/graphql/fragments.js";import{getMainDefinition as a,getFragmentDefinitions as u}from"../utilities/graphql/getFromAST.js";import{resultKeyNameFromField as l,argumentsObjectFromField as c,isField as v,isInlineFragment as h}from"../utilities/graphql/storeUtils.js";import{removeClientSetsFromDocument as p,buildQueryFromSelectionSet as m}from"../utilities/graphql/transform.js";import{mergeDeep as f,mergeDeepArray as d}from"../utilities/common/mergeDeep.js";import"../utilities/observables/Observable.js";import"../utilities/observables/Concast.js";import"../cache/core/cache.js";import"../cache/inmemory/inMemoryCache.js";import{cacheSlot as y}from"../cache/inmemory/reactiveVars.js";import"../cache/inmemory/policies.js";import{visit as g,BREAK as b}from"../../../graphql/language/visitor.mjs.js";var S=function(){function S(e){var t=e.cache,r=e.client,o=e.resolvers,i=e.fragmentMatcher;this.cache=t,r&&(this.client=r),o&&this.addResolvers(o),i&&this.setFragmentMatcher(i)}return S.prototype.addResolvers=function(e){var t=this;this.resolvers=this.resolvers||{},Array.isArray(e)?e.forEach((function(e){t.resolvers=f(t.resolvers,e)})):this.resolvers=f(this.resolvers,e)},S.prototype.setResolvers=function(e){this.resolvers={},this.addResolvers(e)},S.prototype.getResolvers=function(){return this.resolvers||{}},S.prototype.runResolvers=function(o){var i=o.document,n=o.remoteResult,s=o.context,a=o.variables,u=o.onlyRunForcedResolvers,l=void 0!==u&&u;return e(this,void 0,void 0,(function(){return r(this,(function(e){return i?[2,this.resolveDocument(i,n.data,s,a,this.fragmentMatcher,l).then((function(e){return t(t({},n),{data:e.result})}))]:[2,n]}))}))},S.prototype.setFragmentMatcher=function(e){this.fragmentMatcher=e},S.prototype.getFragmentMatcher=function(){return this.fragmentMatcher},S.prototype.clientQuery=function(e){return i(["client"],e)&&this.resolvers?e:null},S.prototype.serverQuery=function(e){return p(e)},S.prototype.prepareContext=function(e){var r=this.cache;return t(t({},e),{cache:r,getCacheKey:function(e){return r.identify(e)}})},S.prototype.addExportedVariables=function(o,i,n){return void 0===i&&(i={}),void 0===n&&(n={}),e(this,void 0,void 0,(function(){return r(this,(function(e){return o?[2,this.resolveDocument(o,this.buildRootValueFromCache(o,i)||{},this.prepareContext(n),i).then((function(e){return t(t({},i),e.exportedVariables)}))]:[2,t({},i)]}))}))},S.prototype.shouldForceResolvers=function(e){var t=!1;return g(e,{Directive:{enter:function(e){if("client"===e.name.value&&e.arguments&&(t=e.arguments.some((function(e){return"always"===e.name.value&&"BooleanValue"===e.value.kind&&!0===e.value.value}))))return b}}}),t},S.prototype.buildRootValueFromCache=function(e,t){return this.cache.diff({query:m(e),variables:t,returnPartialData:!0,optimistic:!1}).result},S.prototype.resolveDocument=function(o,i,n,l,c,v){return void 0===n&&(n={}),void 0===l&&(l={}),void 0===c&&(c=function(){return!0}),void 0===v&&(v=!1),e(this,void 0,void 0,(function(){var e,h,p,m,f,d,y,g,b;return r(this,(function(r){return e=a(o),h=u(o),p=s(h),m=e.operation,f=m?m.charAt(0).toUpperCase()+m.slice(1):"Query",y=(d=this).cache,g=d.client,b={fragmentMap:p,context:t(t({},n),{cache:y,client:g}),variables:l,fragmentMatcher:c,defaultOperationType:f,exportedVariables:{},onlyRunForcedResolvers:v},[2,this.resolveSelectionSet(e.selectionSet,i,b).then((function(e){return{result:e,exportedVariables:b.exportedVariables}}))]}))}))},S.prototype.resolveSelectionSet=function(t,i,s){return e(this,void 0,void 0,(function(){var a,u,c,p,m,f=this;return r(this,(function(y){return a=s.fragmentMap,u=s.context,c=s.variables,p=[i],m=function(t){return e(f,void 0,void 0,(function(){var e,m;return r(this,(function(r){return n(t,c)?v(t)?[2,this.resolveField(t,i,s).then((function(e){var r;void 0!==e&&p.push(((r={})[l(t)]=e,r))}))]:(h(t)?e=t:(e=a[t.name.value],"production"===process.env.NODE_ENV?o(e,11):o(e,"No fragment named "+t.name.value)),e&&e.typeCondition&&(m=e.typeCondition.name.value,s.fragmentMatcher(i,m,u))?[2,this.resolveSelectionSet(e.selectionSet,i,s).then((function(e){p.push(e)}))]:[2]):[2]}))}))},[2,Promise.all(t.selections.map(m)).then((function(){return d(p)}))]}))}))},S.prototype.resolveField=function(t,o,i){return e(this,void 0,void 0,(function(){var e,n,s,a,u,v,h,p,m,f=this;return r(this,(function(r){return e=i.variables,n=t.name.value,s=l(t),a=n!==s,u=o[s]||o[n],v=Promise.resolve(u),i.onlyRunForcedResolvers&&!this.shouldForceResolvers(t)||(h=o.__typename||i.defaultOperationType,(p=this.resolvers&&this.resolvers[h])&&(m=p[a?n:s])&&(v=Promise.resolve(y.withValue(this.cache,m,[o,c(t,e),i.context,{field:t,fragmentMap:i.fragmentMap}])))),[2,v.then((function(e){return void 0===e&&(e=u),t.directives&&t.directives.forEach((function(t){"export"===t.name.value&&t.arguments&&t.arguments.forEach((function(t){"as"===t.name.value&&"StringValue"===t.value.kind&&(i.exportedVariables[t.value.value]=e)}))})),t.selectionSet?null==e?e:Array.isArray(e)?f.resolveSubSelectedArray(t,e,i):t.selectionSet?f.resolveSelectionSet(t.selectionSet,e,i):void 0:e}))]}))}))},S.prototype.resolveSubSelectedArray=function(e,t,r){var o=this;return Promise.all(t.map((function(t){return null===t?null:Array.isArray(t)?o.resolveSubSelectedArray(e,t,r):e.selectionSet?o.resolveSelectionSet(e.selectionSet,t,r):void 0})))},S}();export{S as LocalState};
@@ -1 +1 @@
1
- import{__extends as e,__assign as r}from"../../../tslib/tslib.es6.js";import{invariant as t}from"../../../ts-invariant/lib/invariant.esm.js";import s from"../../../@wry/equality/lib/equality.esm.js";import{NetworkStatus as o,isNetworkRequestInFlight as i}from"./networkStatus.js";import{getOperationDefinition as n}from"../utilities/graphql/getFromAST.js";import"../utilities/graphql/transform.js";import"../utilities/common/mergeDeep.js";import"../utilities/observables/Observable.js";import{cloneDeep as a}from"../utilities/common/cloneDeep.js";import{iterateObserversSafely as u}from"../utilities/observables/iteration.js";import"../utilities/observables/Concast.js";import{isNonEmptyArray as l}from"../utilities/common/arrays.js";import{Reobserver as c}from"./Reobserver.js";import h from"../../../zen-observable/index.js";var p=!1,v=function(h){function v(e){var t=e.queryManager,s=e.queryInfo,i=e.options,a=h.call(this,(function(e){return a.onSubscribe(e)}))||this;a.observers=new Set,a.subscriptions=new Set,a.observer={next:function(e){(a.lastError||a.isDifferentFromLastResult(e))&&(a.updateLastResult(e),u(a.observers,"next",e))},error:function(e){a.updateLastResult(r(r({},a.lastResult),{error:e,errors:e.graphQLErrors,networkStatus:o.error,loading:!1})),u(a.observers,"error",a.lastError=e)}},a.isTornDown=!1,a.options=i,a.queryId=t.generateQueryId();var l=n(i.query);return a.queryName=l&&l.name&&l.name.value,a.queryManager=t,a.queryInfo=s,a}return e(v,h),Object.defineProperty(v.prototype,"variables",{get:function(){return this.options.variables},enumerable:!1,configurable:!0}),v.prototype.result=function(){var e=this;return new Promise((function(r,t){var s={next:function(t){r(t),e.observers.delete(s),e.observers.size||e.queryManager.removeQuery(e.queryId),setTimeout((function(){o.unsubscribe()}),0)},error:t},o=e.subscribe(s)}))},v.prototype.getCurrentResult=function(e){void 0===e&&(e=!0);var t=this.lastResult,s=this.queryInfo.networkStatus||t&&t.networkStatus||o.ready,n=r(r({},t),{loading:i(s),networkStatus:s});if(this.isTornDown)return n;var a=this.options.fetchPolicy,u=void 0===a?"cache-first":a;if("no-cache"===u||"network-only"===u)delete n.partial;else if(!n.data||!this.queryManager.transform(this.options.query).hasForcedResolvers){var l=this.queryInfo.getDiff();n.data=l.complete||this.options.returnPartialData?l.result:void 0,l.complete?(n.networkStatus!==o.loading||"cache-first"!==u&&"cache-only"!==u||(n.networkStatus=o.ready,n.loading=!1),delete n.partial):n.partial=!0}return e&&this.updateLastResult(n),n},v.prototype.isDifferentFromLastResult=function(e){return!s(this.lastResultSnapshot,e)},v.prototype.getLastResult=function(){return this.lastResult},v.prototype.getLastError=function(){return this.lastError},v.prototype.resetLastResults=function(){delete this.lastResult,delete this.lastResultSnapshot,delete this.lastError,this.isTornDown=!1},v.prototype.resetQueryStoreErrors=function(){this.queryManager.resetErrors(this.queryId)},v.prototype.refetch=function(e){var t={pollInterval:0},i=this.options.fetchPolicy;return"no-cache"!==i&&"cache-and-network"!==i&&(t.fetchPolicy="network-only",t.nextFetchPolicy=i||"cache-first"),e&&!s(this.options.variables,e)&&(t.variables=this.options.variables=r(r({},this.options.variables),e)),this.newReobserver(!1).reobserve(t,o.refetch)},v.prototype.fetchMore=function(e){var s=this,i=r(r({},e.query?e:r(r(r({},this.options),e),{variables:r(r({},this.options.variables),e.variables)})),{fetchPolicy:"no-cache"}),n=this.queryManager.generateQueryId();return i.notifyOnNetworkStatusChange&&(this.queryInfo.networkStatus=o.fetchMore,this.observe()),this.queryManager.fetchQuery(n,i,o.fetchMore).then((function(r){var o=r.data,n=e.updateQuery;return n?("production"===process.env.NODE_ENV||p||("production"===process.env.NODE_ENV||t.warn("The updateQuery callback for fetchMore is deprecated, and will be removed\nin the next major version of Apollo Client.\n\nPlease convert updateQuery functions to field policies with appropriate\nread and merge functions, or use/adapt a helper function (such as\nconcatPagination, offsetLimitPagination, or relayStylePagination) from\n@apollo/client/utilities.\n\nThe field policy system handles pagination more effectively than a\nhand-written updateQuery function, and you only need to define the policy\nonce, rather than every time you call fetchMore."),p=!0),s.updateQuery((function(e){return n(e,{fetchMoreResult:o,variables:i.variables})}))):s.queryManager.cache.writeQuery({query:i.query,variables:i.variables,data:o}),r})).finally((function(){s.queryManager.stopQuery(n),s.reobserve()}))},v.prototype.subscribeToMore=function(e){var r=this,s=this.queryManager.startGraphQLSubscription({query:e.document,variables:e.variables,context:e.context}).subscribe({next:function(t){var s=e.updateQuery;s&&r.updateQuery((function(e,r){var o=r.variables;return s(e,{subscriptionData:t,variables:o})}))},error:function(r){e.onError?e.onError(r):"production"===process.env.NODE_ENV||t.error("Unhandled GraphQL subscription error",r)}});return this.subscriptions.add(s),function(){r.subscriptions.delete(s)&&s.unsubscribe()}},v.prototype.setOptions=function(e){return this.reobserve(e)},v.prototype.setVariables=function(e){if(s(this.variables,e))return this.observers.size?this.result():Promise.resolve();if(this.options.variables=e,!this.observers.size)return Promise.resolve();var r=this.options.fetchPolicy,t=void 0===r?"cache-first":r,i={fetchPolicy:t,variables:e};return"cache-first"!==t&&"no-cache"!==t&&"network-only"!==t&&(i.fetchPolicy="cache-and-network",i.nextFetchPolicy=t),this.reobserve(i,o.setVariables)},v.prototype.updateQuery=function(e){var r,t=this.queryManager,s=e(t.cache.diff({query:this.options.query,variables:this.variables,previousResult:null===(r=this.lastResult)||void 0===r?void 0:r.data,returnPartialData:!0,optimistic:!1}).result,{variables:this.variables});s&&(t.cache.writeQuery({query:this.options.query,data:s,variables:this.variables}),t.broadcastQueries())},v.prototype.startPolling=function(e){this.getReobserver().updateOptions({pollInterval:e})},v.prototype.stopPolling=function(){this.reobserver&&this.reobserver.updateOptions({pollInterval:0})},v.prototype.updateLastResult=function(e){var r=this.lastResult;return this.lastResult=e,this.lastResultSnapshot=this.queryManager.assumeImmutableResults?e:a(e),l(e.errors)||delete this.lastError,r},v.prototype.onSubscribe=function(e){var r=this;if(e===this.observer)return function(){};try{var t=e._subscription._observer;t&&!t.error&&(t.error=b)}catch(e){}var s=!this.observers.size;return this.observers.add(e),this.lastError?e.error&&e.error(this.lastError):this.lastResult&&e.next&&e.next(this.lastResult),s&&this.reobserve().catch((function(e){})),function(){r.observers.delete(e)&&!r.observers.size&&r.tearDownQuery()}},v.prototype.getReobserver=function(){return this.reobserver||(this.reobserver=this.newReobserver(!0))},v.prototype.newReobserver=function(e){var t=this,s=this.queryManager,o=this.queryId;return s.setObservableQuery(this),new c(this.observer,e?this.options:r({},this.options),(function(e,r){return s.setObservableQuery(t),s.fetchQueryObservable(o,e,r)}),!s.ssrMode&&function(){return!i(t.queryInfo.networkStatus)})},v.prototype.reobserve=function(e,r){return this.isTornDown=!1,this.getReobserver().reobserve(e,r)},v.prototype.observe=function(){this.observer.next(this.getCurrentResult(!1))},v.prototype.hasObservers=function(){return this.observers.size>0},v.prototype.tearDownQuery=function(){this.isTornDown||(this.reobserver&&(this.reobserver.stop(),delete this.reobserver),delete this.options.context,this.subscriptions.forEach((function(e){return e.unsubscribe()})),this.subscriptions.clear(),this.queryManager.stopQuery(this.queryId),this.observers.clear(),this.isTornDown=!0)},v}(h);function b(e){"production"===process.env.NODE_ENV||t.error("Unhandled error",e.message,e.stack)}export{v as ObservableQuery};
1
+ import{__extends as e,__assign as r}from'../ext/tslib/tslib.es6.js';import{invariant as t}from"../../../ts-invariant/lib/invariant.esm.js";import s from"../../../@wry/equality/lib/equality.esm.js";import{NetworkStatus as o,isNetworkRequestInFlight as i}from"./networkStatus.js";import{getOperationDefinition as n}from"../utilities/graphql/getFromAST.js";import"../utilities/graphql/transform.js";import"../utilities/common/mergeDeep.js";import"../utilities/observables/Observable.js";import{cloneDeep as a}from"../utilities/common/cloneDeep.js";import{iterateObserversSafely as u}from"../utilities/observables/iteration.js";import"../utilities/observables/Concast.js";import{isNonEmptyArray as l}from"../utilities/common/arrays.js";import{Reobserver as c}from"./Reobserver.js";import h from"../../../zen-observable/index.js";var p=!1,v=function(h){function v(e){var t=e.queryManager,s=e.queryInfo,i=e.options,a=h.call(this,(function(e){return a.onSubscribe(e)}))||this;a.observers=new Set,a.subscriptions=new Set,a.observer={next:function(e){(a.lastError||a.isDifferentFromLastResult(e))&&(a.updateLastResult(e),u(a.observers,"next",e))},error:function(e){a.updateLastResult(r(r({},a.lastResult),{error:e,errors:e.graphQLErrors,networkStatus:o.error,loading:!1})),u(a.observers,"error",a.lastError=e)}},a.isTornDown=!1,a.options=i,a.queryId=t.generateQueryId();var l=n(i.query);return a.queryName=l&&l.name&&l.name.value,a.queryManager=t,a.queryInfo=s,a}return e(v,h),Object.defineProperty(v.prototype,"variables",{get:function(){return this.options.variables},enumerable:!1,configurable:!0}),v.prototype.result=function(){var e=this;return new Promise((function(r,t){var s={next:function(t){r(t),e.observers.delete(s),e.observers.size||e.queryManager.removeQuery(e.queryId),setTimeout((function(){o.unsubscribe()}),0)},error:t},o=e.subscribe(s)}))},v.prototype.getCurrentResult=function(e){void 0===e&&(e=!0);var t=this.lastResult,s=this.queryInfo.networkStatus||t&&t.networkStatus||o.ready,n=r(r({},t),{loading:i(s),networkStatus:s});if(this.isTornDown)return n;var a=this.options.fetchPolicy,u=void 0===a?"cache-first":a;if("no-cache"===u||"network-only"===u)delete n.partial;else if(!n.data||!this.queryManager.transform(this.options.query).hasForcedResolvers){var l=this.queryInfo.getDiff();n.data=l.complete||this.options.returnPartialData?l.result:void 0,l.complete?(n.networkStatus!==o.loading||"cache-first"!==u&&"cache-only"!==u||(n.networkStatus=o.ready,n.loading=!1),delete n.partial):n.partial=!0}return e&&this.updateLastResult(n),n},v.prototype.isDifferentFromLastResult=function(e){return!s(this.lastResultSnapshot,e)},v.prototype.getLastResult=function(){return this.lastResult},v.prototype.getLastError=function(){return this.lastError},v.prototype.resetLastResults=function(){delete this.lastResult,delete this.lastResultSnapshot,delete this.lastError,this.isTornDown=!1},v.prototype.resetQueryStoreErrors=function(){this.queryManager.resetErrors(this.queryId)},v.prototype.refetch=function(e){var t={pollInterval:0},i=this.options.fetchPolicy;return"no-cache"!==i&&"cache-and-network"!==i&&(t.fetchPolicy="network-only",t.nextFetchPolicy=i||"cache-first"),e&&!s(this.options.variables,e)&&(t.variables=this.options.variables=r(r({},this.options.variables),e)),this.newReobserver(!1).reobserve(t,o.refetch)},v.prototype.fetchMore=function(e){var s=this,i=r(r({},e.query?e:r(r(r({},this.options),e),{variables:r(r({},this.options.variables),e.variables)})),{fetchPolicy:"no-cache"}),n=this.queryManager.generateQueryId();return i.notifyOnNetworkStatusChange&&(this.queryInfo.networkStatus=o.fetchMore,this.observe()),this.queryManager.fetchQuery(n,i,o.fetchMore).then((function(r){var o=r.data,n=e.updateQuery;return n?("production"===process.env.NODE_ENV||p||("production"===process.env.NODE_ENV||t.warn("The updateQuery callback for fetchMore is deprecated, and will be removed\nin the next major version of Apollo Client.\n\nPlease convert updateQuery functions to field policies with appropriate\nread and merge functions, or use/adapt a helper function (such as\nconcatPagination, offsetLimitPagination, or relayStylePagination) from\n@apollo/client/utilities.\n\nThe field policy system handles pagination more effectively than a\nhand-written updateQuery function, and you only need to define the policy\nonce, rather than every time you call fetchMore."),p=!0),s.updateQuery((function(e){return n(e,{fetchMoreResult:o,variables:i.variables})}))):s.queryManager.cache.writeQuery({query:i.query,variables:i.variables,data:o}),r})).finally((function(){s.queryManager.stopQuery(n),s.reobserve()}))},v.prototype.subscribeToMore=function(e){var r=this,s=this.queryManager.startGraphQLSubscription({query:e.document,variables:e.variables,context:e.context}).subscribe({next:function(t){var s=e.updateQuery;s&&r.updateQuery((function(e,r){var o=r.variables;return s(e,{subscriptionData:t,variables:o})}))},error:function(r){e.onError?e.onError(r):"production"===process.env.NODE_ENV||t.error("Unhandled GraphQL subscription error",r)}});return this.subscriptions.add(s),function(){r.subscriptions.delete(s)&&s.unsubscribe()}},v.prototype.setOptions=function(e){return this.reobserve(e)},v.prototype.setVariables=function(e){if(s(this.variables,e))return this.observers.size?this.result():Promise.resolve();if(this.options.variables=e,!this.observers.size)return Promise.resolve();var r=this.options.fetchPolicy,t=void 0===r?"cache-first":r,i={fetchPolicy:t,variables:e};return"cache-first"!==t&&"no-cache"!==t&&"network-only"!==t&&(i.fetchPolicy="cache-and-network",i.nextFetchPolicy=t),this.reobserve(i,o.setVariables)},v.prototype.updateQuery=function(e){var r,t=this.queryManager,s=e(t.cache.diff({query:this.options.query,variables:this.variables,previousResult:null===(r=this.lastResult)||void 0===r?void 0:r.data,returnPartialData:!0,optimistic:!1}).result,{variables:this.variables});s&&(t.cache.writeQuery({query:this.options.query,data:s,variables:this.variables}),t.broadcastQueries())},v.prototype.startPolling=function(e){this.getReobserver().updateOptions({pollInterval:e})},v.prototype.stopPolling=function(){this.reobserver&&this.reobserver.updateOptions({pollInterval:0})},v.prototype.updateLastResult=function(e){var r=this.lastResult;return this.lastResult=e,this.lastResultSnapshot=this.queryManager.assumeImmutableResults?e:a(e),l(e.errors)||delete this.lastError,r},v.prototype.onSubscribe=function(e){var r=this;if(e===this.observer)return function(){};try{var t=e._subscription._observer;t&&!t.error&&(t.error=b)}catch(e){}var s=!this.observers.size;return this.observers.add(e),this.lastError?e.error&&e.error(this.lastError):this.lastResult&&e.next&&e.next(this.lastResult),s&&this.reobserve().catch((function(e){})),function(){r.observers.delete(e)&&!r.observers.size&&r.tearDownQuery()}},v.prototype.getReobserver=function(){return this.reobserver||(this.reobserver=this.newReobserver(!0))},v.prototype.newReobserver=function(e){var t=this,s=this.queryManager,o=this.queryId;return s.setObservableQuery(this),new c(this.observer,e?this.options:r({},this.options),(function(e,r){return s.setObservableQuery(t),s.fetchQueryObservable(o,e,r)}),!s.ssrMode&&function(){return!i(t.queryInfo.networkStatus)})},v.prototype.reobserve=function(e,r){return this.isTornDown=!1,this.getReobserver().reobserve(e,r)},v.prototype.observe=function(){this.observer.next(this.getCurrentResult(!1))},v.prototype.hasObservers=function(){return this.observers.size>0},v.prototype.tearDownQuery=function(){this.isTornDown||(this.reobserver&&(this.reobserver.stop(),delete this.reobserver),delete this.options.context,this.subscriptions.forEach((function(e){return e.unsubscribe()})),this.subscriptions.clear(),this.queryManager.stopQuery(this.queryId),this.observers.clear(),this.isTornDown=!0)},v}(h);function b(e){"production"===process.env.NODE_ENV||t.error("Unhandled error",e.message,e.stack)}export{v as ObservableQuery};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t,__assign as r}from"../../../tslib/tslib.es6.js";import{InvariantError as o,invariant as i}from"../../../ts-invariant/lib/invariant.esm.js";import n from"../../../@wry/equality/lib/equality.esm.js";import"../link/core/ApolloLink.js";import{execute as a}from"../link/core/execute.js";import{hasClientExports as s}from"../utilities/graphql/directives.js";import{getOperationName as u,getDefaultValues as c,getOperationDefinition as l}from"../utilities/graphql/getFromAST.js";import{removeConnectionDirectiveFromDocument as h}from"../utilities/graphql/transform.js";import"../utilities/common/mergeDeep.js";import"../utilities/observables/Observable.js";import{asyncMap as p}from"../utilities/observables/asyncMap.js";import{Concast as f}from"../utilities/observables/Concast.js";import{isNonEmptyArray as y}from"../utilities/common/arrays.js";import{graphQLResultHasError as d}from"../utilities/common/errorHandling.js";import{canUseWeakMap as v}from"../utilities/common/canUse.js";import{ApolloError as m,isApolloError as b}from"../errors/index.js";import{ObservableQuery as g}from"./ObservableQuery.js";import{NetworkStatus as w,isNetworkRequestInFlight as q}from"./networkStatus.js";import{LocalState as Q}from"./LocalState.js";import{shouldWriteResult as k,QueryInfo as E}from"./QueryInfo.js";import O from"../../../zen-observable/index.js";var S=Object.prototype.hasOwnProperty,P=function(){function P(e){var t=e.cache,r=e.link,o=e.queryDeduplication,i=void 0!==o&&o,n=e.onBroadcast,a=e.ssrMode,s=void 0!==a&&a,u=e.clientAwareness,c=void 0===u?{}:u,l=e.localState,h=e.assumeImmutableResults;this.clientAwareness={},this.queries=new Map,this.fetchCancelFns=new Map,this.transformCache=new(v?WeakMap:Map),this.queryIdCounter=1,this.requestIdCounter=1,this.mutationIdCounter=1,this.inFlightLinkObservables=new Map,this.cache=t,this.link=r,this.queryDeduplication=i,this.clientAwareness=c,this.localState=l||new Q({cache:t}),this.ssrMode=s,this.assumeImmutableResults=!!h,(this.onBroadcast=n)&&(this.mutationStore=Object.create(null))}return P.prototype.stop=function(){var e=this;this.queries.forEach((function(t,r){e.stopQueryNoBroadcast(r)})),this.cancelPendingFetches("production"===process.env.NODE_ENV?new o(12):new o("QueryManager stopped while query was in flight"))},P.prototype.cancelPendingFetches=function(e){this.fetchCancelFns.forEach((function(t){return t(e)})),this.fetchCancelFns.clear()},P.prototype.mutate=function(o){var n=o.mutation,a=o.variables,s=o.optimisticResponse,u=o.updateQueries,c=o.refetchQueries,l=void 0===c?[]:c,h=o.awaitRefetchQueries,p=void 0!==h&&h,f=o.update,v=o.errorPolicy,b=void 0===v?"none":v,g=o.fetchPolicy,w=o.context,q=void 0===w?{}:w;return e(this,void 0,void 0,(function(){var e,o,c;return t(this,(function(t){switch(t.label){case 0:return"production"===process.env.NODE_ENV?i(n,13):i(n,"mutation option is required. You must specify your GraphQL document in the mutation option."),"production"===process.env.NODE_ENV?i(!g||"no-cache"===g,14):i(!g||"no-cache"===g,"Mutations only support a 'no-cache' fetchPolicy. If you don't want to disable the cache, remove your fetchPolicy setting to proceed with the default mutation behavior."),e=this.generateMutationId(),n=this.transform(n).document,a=this.getVariables(n,a),this.transform(n).hasClientExports?[4,this.localState.addExportedVariables(n,a,q)]:[3,2];case 1:a=t.sent(),t.label=2;case 2:return o=this.mutationStore&&(this.mutationStore[e]={mutation:n,variables:a,loading:!0,error:null}),s&&this.markMutationOptimistic(s,{mutationId:e,document:n,variables:a,errorPolicy:b,updateQueries:u,update:f}),this.broadcastQueries(),c=this,[2,new Promise((function(t,i){var h,v;c.getObservableFromLink(n,r(r({},q),{optimisticResponse:s}),a,!1).subscribe({next:function(t){if(d(t)&&"none"===b)v=new m({graphQLErrors:t.errors});else{if(o&&(o.loading=!1,o.error=null),"no-cache"!==g)try{c.markMutationResult({mutationId:e,result:t,document:n,variables:a,errorPolicy:b,updateQueries:u,update:f})}catch(e){return void(v=new m({networkError:e}))}h=t}},error:function(t){o&&(o.loading=!1,o.error=t),s&&c.cache.removeOptimistic(e),c.broadcastQueries(),i(new m({networkError:t}))},complete:function(){if(v&&o&&(o.loading=!1,o.error=v),s&&c.cache.removeOptimistic(e),c.broadcastQueries(),v)i(v);else{"function"==typeof l&&(l=l(h));var r=[];y(l)&&l.forEach((function(e){if("string"==typeof e)c.queries.forEach((function(t){var o=t.observableQuery;o&&o.queryName===e&&r.push(o.refetch())}));else{var t={query:e.query,variables:e.variables,fetchPolicy:"network-only"};e.context&&(t.context=e.context),r.push(c.query(t))}})),Promise.all(p?r:[]).then((function(){"ignore"===b&&h&&d(h)&&delete h.errors,t(h)}),i)}}})}))]}}))}))},P.prototype.markMutationResult=function(e,t){var r=this;if(void 0===t&&(t=this.cache),k(e.result,e.errorPolicy)){var o=[{result:e.result.data,dataId:"ROOT_MUTATION",query:e.document,variables:e.variables}],i=e.updateQueries;i&&this.queries.forEach((function(n,a){var s=n.observableQuery,c=s&&s.queryName;if(c&&S.call(i,c)){var l=i[c],h=r.queries.get(a),p=h.document,f=h.variables,y=t.diff({query:p,variables:f,returnPartialData:!0,optimistic:!1}),d=y.result;if(y.complete&&d){var v=l(d,{mutationResult:e.result,queryName:p&&u(p)||void 0,queryVariables:f});v&&o.push({result:v,dataId:"ROOT_QUERY",query:p,variables:f})}}})),t.performTransaction((function(t){o.forEach((function(e){return t.write(e)}));var r=e.update;r&&r(t,e.result)}),null)}},P.prototype.markMutationOptimistic=function(e,t){var o=this,n="function"==typeof e?e(t.variables):e;return this.cache.recordOptimisticTransaction((function(e){try{o.markMutationResult(r(r({},t),{result:{data:n}}),e)}catch(e){"production"===process.env.NODE_ENV||i.error(e)}}),t.mutationId)},P.prototype.fetchQuery=function(e,t,r){return this.fetchQueryObservable(e,t,r).promise},P.prototype.getQueryStore=function(){var e=Object.create(null);return this.queries.forEach((function(t,r){e[r]={variables:t.variables,networkStatus:t.networkStatus,networkError:t.networkError,graphQLErrors:t.graphQLErrors}})),e},P.prototype.resetErrors=function(e){var t=this.queries.get(e);t&&(t.networkError=void 0,t.graphQLErrors=[])},P.prototype.transform=function(e){var t=this.transformCache;if(!t.has(e)){var r=this.cache.transformDocument(e),o=h(this.cache.transformForLink(r)),i=this.localState.clientQuery(r),n=o&&this.localState.serverQuery(o),a={document:r,hasClientExports:s(r),hasForcedResolvers:this.localState.shouldForceResolvers(r),clientQuery:i,serverQuery:n,defaultVars:c(l(r))},u=function(e){e&&!t.has(e)&&t.set(e,a)};u(e),u(r),u(i),u(n)}return t.get(e)},P.prototype.getVariables=function(e,t){return r(r({},this.transform(e).defaultVars),t)},P.prototype.watchQuery=function(e){void 0===(e=r(r({},e),{variables:this.getVariables(e.query,e.variables)})).notifyOnNetworkStatusChange&&(e.notifyOnNetworkStatusChange=!1);var t=new E(this.cache),o=new g({queryManager:this,queryInfo:t,options:e});return this.queries.set(o.queryId,t),t.init({document:e.query,observableQuery:o,variables:e.variables}),o},P.prototype.query=function(e){var t=this;"production"===process.env.NODE_ENV?i(e.query,15):i(e.query,"query option is required. You must specify your GraphQL document in the query option."),"production"===process.env.NODE_ENV?i("Document"===e.query.kind,16):i("Document"===e.query.kind,'You must wrap the query string in a "gql" tag.'),"production"===process.env.NODE_ENV?i(!e.returnPartialData,17):i(!e.returnPartialData,"returnPartialData option only supported on watchQuery."),"production"===process.env.NODE_ENV?i(!e.pollInterval,18):i(!e.pollInterval,"pollInterval option only supported on watchQuery.");var r=this.generateQueryId();return this.fetchQuery(r,e).finally((function(){return t.stopQuery(r)}))},P.prototype.generateQueryId=function(){return String(this.queryIdCounter++)},P.prototype.generateRequestId=function(){return this.requestIdCounter++},P.prototype.generateMutationId=function(){return String(this.mutationIdCounter++)},P.prototype.stopQueryInStore=function(e){this.stopQueryInStoreNoBroadcast(e),this.broadcastQueries()},P.prototype.stopQueryInStoreNoBroadcast=function(e){var t=this.queries.get(e);t&&t.stop()},P.prototype.clearStore=function(){return this.cancelPendingFetches("production"===process.env.NODE_ENV?new o(19):new o("Store reset while query was in flight (not completed in link chain)")),this.queries.forEach((function(e){e.observableQuery?e.networkStatus=w.loading:e.stop()})),this.mutationStore&&(this.mutationStore=Object.create(null)),this.cache.reset()},P.prototype.resetStore=function(){var e=this;return this.clearStore().then((function(){return e.reFetchObservableQueries()}))},P.prototype.reFetchObservableQueries=function(e){var t=this;void 0===e&&(e=!1);var r=[];return this.queries.forEach((function(o,i){var n=o.observableQuery;if(n&&n.hasObservers()){var a=n.options.fetchPolicy;n.resetLastResults(),"cache-only"===a||!e&&"standby"===a||r.push(n.refetch()),t.getQuery(i).setDiff(null)}})),this.broadcastQueries(),Promise.all(r)},P.prototype.setObservableQuery=function(e){this.getQuery(e.queryId).setObservableQuery(e)},P.prototype.startGraphQLSubscription=function(e){var t=this,r=e.query,o=e.fetchPolicy,i=e.errorPolicy,n=e.variables,a=e.context,s=void 0===a?{}:a;r=this.transform(r).document,n=this.getVariables(r,n);var u=function(e){return t.getObservableFromLink(r,s,e,!1).map((function(n){if("no-cache"!==o&&(k(n,i)&&t.cache.write({query:r,result:n.data,dataId:"ROOT_SUBSCRIPTION",variables:e}),t.broadcastQueries()),d(n))throw new m({graphQLErrors:n.errors});return n}))};if(this.transform(r).hasClientExports){var c=this.localState.addExportedVariables(r,n,s).then(u);return new O((function(e){var t=null;return c.then((function(r){return t=r.subscribe(e)}),e.error),function(){return t&&t.unsubscribe()}}))}return u(n)},P.prototype.stopQuery=function(e){this.stopQueryNoBroadcast(e),this.broadcastQueries()},P.prototype.stopQueryNoBroadcast=function(e){this.stopQueryInStoreNoBroadcast(e),this.removeQuery(e)},P.prototype.removeQuery=function(e){this.fetchCancelFns.delete(e),this.getQuery(e).stop(),this.queries.delete(e)},P.prototype.broadcastQueries=function(){this.onBroadcast&&this.onBroadcast(),this.queries.forEach((function(e){return e.notify()}))},P.prototype.getLocalState=function(){return this.localState},P.prototype.getObservableFromLink=function(e,t,o,i){var n,s,c=this;void 0===i&&(i=null!==(n=null==t?void 0:t.queryDeduplication)&&void 0!==n?n:this.queryDeduplication);var l=this.transform(e).serverQuery;if(l){var h=this.inFlightLinkObservables,y=this.link,d={query:l,variables:o,operationName:u(l)||void 0,context:this.prepareContext(r(r({},t),{forceFetch:!i}))};if(t=d.context,i){var v=h.get(l)||new Map;h.set(l,v);var m=JSON.stringify(o);if(!(s=v.get(m))){var b=new f([a(y,d)]);v.set(m,s=b),b.cleanup((function(){v.delete(m)&&v.size<1&&h.delete(l)}))}}else s=new f([a(y,d)])}else s=new f([O.of({data:{}})]),t=this.prepareContext(t);var g=this.transform(e).clientQuery;return g&&(s=p(s,(function(e){return c.localState.runResolvers({document:g,remoteResult:e,context:t,variables:o})}))),s},P.prototype.getResultsFromLink=function(e,t,r){var o=e.lastRequestId;return p(this.getObservableFromLink(e.document,r.context,r.variables),(function(i){var n=y(i.errors);if(o>=e.lastRequestId){if(n&&"none"===r.errorPolicy)throw e.markError(new m({graphQLErrors:i.errors}));e.markResult(i,r,t),e.markReady()}var a={data:i.data,loading:!1,networkStatus:e.networkStatus||w.ready};return n&&"ignore"!==r.errorPolicy&&(a.errors=i.errors),a}),(function(t){var r=b(t)?t:new m({networkError:t});throw o>=e.lastRequestId&&e.markError(r),r}))},P.prototype.fetchQueryObservable=function(e,t,r){var o=this;void 0===r&&(r=w.loading);var i=this.transform(t.query).document,n=this.getVariables(i,t.variables),a=this.getQuery(e),s=a.networkStatus,u=t.fetchPolicy,c=void 0===u?"cache-first":u,l=t.errorPolicy,h=void 0===l?"none":l,p=t.returnPartialData,y=void 0!==p&&p,d=t.notifyOnNetworkStatusChange,v=void 0!==d&&d,m=t.context,b=void 0===m?{}:m;("cache-first"===c||"cache-and-network"===c||"network-only"===c||"no-cache"===c)&&v&&"number"==typeof s&&s!==r&&q(r)&&("cache-first"!==c&&(c="cache-and-network"),y=!0);var g=Object.assign({},t,{query:i,variables:n,fetchPolicy:c,errorPolicy:h,returnPartialData:y,notifyOnNetworkStatusChange:v,context:b}),Q=function(e){return g.variables=e,o.fetchQueryByPolicy(a,g,r)};this.fetchCancelFns.set(e,(function(e){Promise.resolve().then((function(){return k.cancel(e)}))}));var k=new f(this.transform(g.query).hasClientExports?this.localState.addExportedVariables(g.query,g.variables,g.context).then(Q):Q(g.variables));return k.cleanup((function(){o.fetchCancelFns.delete(e);var r=t.nextFetchPolicy;r&&(t.nextFetchPolicy=void 0,t.fetchPolicy="function"==typeof r?r.call(t,t.fetchPolicy||"cache-first"):r)})),k},P.prototype.fetchQueryByPolicy=function(e,t,o){var a=this,s=t.query,u=t.variables,c=t.fetchPolicy,l=t.errorPolicy,h=t.returnPartialData,p=t.context;e.init({document:s,variables:u,lastRequestId:this.generateRequestId(),networkStatus:o});var f=function(){return e.getDiff(u)},d=function(t,o){void 0===o&&(o=e.networkStatus||w.loading);var c=t.result;"production"===process.env.NODE_ENV||!y(t.missing)||n(c,{})||h||"production"===process.env.NODE_ENV||i.warn("Missing cache result fields: "+t.missing.map((function(e){return e.path.join(".")})).join(", "),t.missing);var l=function(e){return O.of(r({data:e,loading:q(o),networkStatus:o},t.complete?null:{partial:!0}))};return a.transform(s).hasForcedResolvers?a.localState.runResolvers({document:s,remoteResult:{data:c},context:p,variables:u,onlyRunForcedResolvers:!0}).then((function(e){return l(e.data)})):l(c)},v=function(t){return a.getResultsFromLink(e,t,{variables:u,context:p,fetchPolicy:c,errorPolicy:l})};switch(c){default:case"cache-first":return(m=f()).complete?[d(m,e.markReady())]:h?[d(m),v(!0)]:[v(!0)];case"cache-and-network":var m;return(m=f()).complete||h?[d(m),v(!0)]:[v(!0)];case"cache-only":return[d(f(),e.markReady())];case"network-only":return[v(!0)];case"no-cache":return[v(!1)];case"standby":return[]}},P.prototype.getQuery=function(e){return e&&!this.queries.has(e)&&this.queries.set(e,new E(this.cache)),this.queries.get(e)},P.prototype.prepareContext=function(e){void 0===e&&(e={});var t=this.localState.prepareContext(e);return r(r({},t),{clientAwareness:this.clientAwareness})},P}();export{P as QueryManager};
1
+ import{__awaiter as e,__generator as t,__assign as r}from'../ext/tslib/tslib.es6.js';import{InvariantError as o,invariant as i}from"../../../ts-invariant/lib/invariant.esm.js";import n from"../../../@wry/equality/lib/equality.esm.js";import"../link/core/ApolloLink.js";import{execute as a}from"../link/core/execute.js";import{hasClientExports as s}from"../utilities/graphql/directives.js";import{getOperationName as u,getDefaultValues as c,getOperationDefinition as l}from"../utilities/graphql/getFromAST.js";import{removeConnectionDirectiveFromDocument as h}from"../utilities/graphql/transform.js";import"../utilities/common/mergeDeep.js";import"../utilities/observables/Observable.js";import{asyncMap as p}from"../utilities/observables/asyncMap.js";import{Concast as f}from"../utilities/observables/Concast.js";import{isNonEmptyArray as y}from"../utilities/common/arrays.js";import{graphQLResultHasError as d}from"../utilities/common/errorHandling.js";import{canUseWeakMap as v}from"../utilities/common/canUse.js";import{ApolloError as m,isApolloError as b}from"../errors/index.js";import{ObservableQuery as g}from"./ObservableQuery.js";import{NetworkStatus as w,isNetworkRequestInFlight as q}from"./networkStatus.js";import{LocalState as Q}from"./LocalState.js";import{shouldWriteResult as k,QueryInfo as E}from"./QueryInfo.js";import O from"../../../zen-observable/index.js";var S=Object.prototype.hasOwnProperty,P=function(){function P(e){var t=e.cache,r=e.link,o=e.queryDeduplication,i=void 0!==o&&o,n=e.onBroadcast,a=e.ssrMode,s=void 0!==a&&a,u=e.clientAwareness,c=void 0===u?{}:u,l=e.localState,h=e.assumeImmutableResults;this.clientAwareness={},this.queries=new Map,this.fetchCancelFns=new Map,this.transformCache=new(v?WeakMap:Map),this.queryIdCounter=1,this.requestIdCounter=1,this.mutationIdCounter=1,this.inFlightLinkObservables=new Map,this.cache=t,this.link=r,this.queryDeduplication=i,this.clientAwareness=c,this.localState=l||new Q({cache:t}),this.ssrMode=s,this.assumeImmutableResults=!!h,(this.onBroadcast=n)&&(this.mutationStore=Object.create(null))}return P.prototype.stop=function(){var e=this;this.queries.forEach((function(t,r){e.stopQueryNoBroadcast(r)})),this.cancelPendingFetches("production"===process.env.NODE_ENV?new o(12):new o("QueryManager stopped while query was in flight"))},P.prototype.cancelPendingFetches=function(e){this.fetchCancelFns.forEach((function(t){return t(e)})),this.fetchCancelFns.clear()},P.prototype.mutate=function(o){var n=o.mutation,a=o.variables,s=o.optimisticResponse,u=o.updateQueries,c=o.refetchQueries,l=void 0===c?[]:c,h=o.awaitRefetchQueries,p=void 0!==h&&h,f=o.update,v=o.errorPolicy,b=void 0===v?"none":v,g=o.fetchPolicy,w=o.context,q=void 0===w?{}:w;return e(this,void 0,void 0,(function(){var e,o,c;return t(this,(function(t){switch(t.label){case 0:return"production"===process.env.NODE_ENV?i(n,13):i(n,"mutation option is required. You must specify your GraphQL document in the mutation option."),"production"===process.env.NODE_ENV?i(!g||"no-cache"===g,14):i(!g||"no-cache"===g,"Mutations only support a 'no-cache' fetchPolicy. If you don't want to disable the cache, remove your fetchPolicy setting to proceed with the default mutation behavior."),e=this.generateMutationId(),n=this.transform(n).document,a=this.getVariables(n,a),this.transform(n).hasClientExports?[4,this.localState.addExportedVariables(n,a,q)]:[3,2];case 1:a=t.sent(),t.label=2;case 2:return o=this.mutationStore&&(this.mutationStore[e]={mutation:n,variables:a,loading:!0,error:null}),s&&this.markMutationOptimistic(s,{mutationId:e,document:n,variables:a,errorPolicy:b,updateQueries:u,update:f}),this.broadcastQueries(),c=this,[2,new Promise((function(t,i){var h,v;c.getObservableFromLink(n,r(r({},q),{optimisticResponse:s}),a,!1).subscribe({next:function(t){if(d(t)&&"none"===b)v=new m({graphQLErrors:t.errors});else{if(o&&(o.loading=!1,o.error=null),"no-cache"!==g)try{c.markMutationResult({mutationId:e,result:t,document:n,variables:a,errorPolicy:b,updateQueries:u,update:f})}catch(e){return void(v=new m({networkError:e}))}h=t}},error:function(t){o&&(o.loading=!1,o.error=t),s&&c.cache.removeOptimistic(e),c.broadcastQueries(),i(new m({networkError:t}))},complete:function(){if(v&&o&&(o.loading=!1,o.error=v),s&&c.cache.removeOptimistic(e),c.broadcastQueries(),v)i(v);else{"function"==typeof l&&(l=l(h));var r=[];y(l)&&l.forEach((function(e){if("string"==typeof e)c.queries.forEach((function(t){var o=t.observableQuery;o&&o.queryName===e&&r.push(o.refetch())}));else{var t={query:e.query,variables:e.variables,fetchPolicy:"network-only"};e.context&&(t.context=e.context),r.push(c.query(t))}})),Promise.all(p?r:[]).then((function(){"ignore"===b&&h&&d(h)&&delete h.errors,t(h)}),i)}}})}))]}}))}))},P.prototype.markMutationResult=function(e,t){var r=this;if(void 0===t&&(t=this.cache),k(e.result,e.errorPolicy)){var o=[{result:e.result.data,dataId:"ROOT_MUTATION",query:e.document,variables:e.variables}],i=e.updateQueries;i&&this.queries.forEach((function(n,a){var s=n.observableQuery,c=s&&s.queryName;if(c&&S.call(i,c)){var l=i[c],h=r.queries.get(a),p=h.document,f=h.variables,y=t.diff({query:p,variables:f,returnPartialData:!0,optimistic:!1}),d=y.result;if(y.complete&&d){var v=l(d,{mutationResult:e.result,queryName:p&&u(p)||void 0,queryVariables:f});v&&o.push({result:v,dataId:"ROOT_QUERY",query:p,variables:f})}}})),t.performTransaction((function(t){o.forEach((function(e){return t.write(e)}));var r=e.update;r&&r(t,e.result)}),null)}},P.prototype.markMutationOptimistic=function(e,t){var o=this,n="function"==typeof e?e(t.variables):e;return this.cache.recordOptimisticTransaction((function(e){try{o.markMutationResult(r(r({},t),{result:{data:n}}),e)}catch(e){"production"===process.env.NODE_ENV||i.error(e)}}),t.mutationId)},P.prototype.fetchQuery=function(e,t,r){return this.fetchQueryObservable(e,t,r).promise},P.prototype.getQueryStore=function(){var e=Object.create(null);return this.queries.forEach((function(t,r){e[r]={variables:t.variables,networkStatus:t.networkStatus,networkError:t.networkError,graphQLErrors:t.graphQLErrors}})),e},P.prototype.resetErrors=function(e){var t=this.queries.get(e);t&&(t.networkError=void 0,t.graphQLErrors=[])},P.prototype.transform=function(e){var t=this.transformCache;if(!t.has(e)){var r=this.cache.transformDocument(e),o=h(this.cache.transformForLink(r)),i=this.localState.clientQuery(r),n=o&&this.localState.serverQuery(o),a={document:r,hasClientExports:s(r),hasForcedResolvers:this.localState.shouldForceResolvers(r),clientQuery:i,serverQuery:n,defaultVars:c(l(r))},u=function(e){e&&!t.has(e)&&t.set(e,a)};u(e),u(r),u(i),u(n)}return t.get(e)},P.prototype.getVariables=function(e,t){return r(r({},this.transform(e).defaultVars),t)},P.prototype.watchQuery=function(e){void 0===(e=r(r({},e),{variables:this.getVariables(e.query,e.variables)})).notifyOnNetworkStatusChange&&(e.notifyOnNetworkStatusChange=!1);var t=new E(this.cache),o=new g({queryManager:this,queryInfo:t,options:e});return this.queries.set(o.queryId,t),t.init({document:e.query,observableQuery:o,variables:e.variables}),o},P.prototype.query=function(e){var t=this;"production"===process.env.NODE_ENV?i(e.query,15):i(e.query,"query option is required. You must specify your GraphQL document in the query option."),"production"===process.env.NODE_ENV?i("Document"===e.query.kind,16):i("Document"===e.query.kind,'You must wrap the query string in a "gql" tag.'),"production"===process.env.NODE_ENV?i(!e.returnPartialData,17):i(!e.returnPartialData,"returnPartialData option only supported on watchQuery."),"production"===process.env.NODE_ENV?i(!e.pollInterval,18):i(!e.pollInterval,"pollInterval option only supported on watchQuery.");var r=this.generateQueryId();return this.fetchQuery(r,e).finally((function(){return t.stopQuery(r)}))},P.prototype.generateQueryId=function(){return String(this.queryIdCounter++)},P.prototype.generateRequestId=function(){return this.requestIdCounter++},P.prototype.generateMutationId=function(){return String(this.mutationIdCounter++)},P.prototype.stopQueryInStore=function(e){this.stopQueryInStoreNoBroadcast(e),this.broadcastQueries()},P.prototype.stopQueryInStoreNoBroadcast=function(e){var t=this.queries.get(e);t&&t.stop()},P.prototype.clearStore=function(){return this.cancelPendingFetches("production"===process.env.NODE_ENV?new o(19):new o("Store reset while query was in flight (not completed in link chain)")),this.queries.forEach((function(e){e.observableQuery?e.networkStatus=w.loading:e.stop()})),this.mutationStore&&(this.mutationStore=Object.create(null)),this.cache.reset()},P.prototype.resetStore=function(){var e=this;return this.clearStore().then((function(){return e.reFetchObservableQueries()}))},P.prototype.reFetchObservableQueries=function(e){var t=this;void 0===e&&(e=!1);var r=[];return this.queries.forEach((function(o,i){var n=o.observableQuery;if(n&&n.hasObservers()){var a=n.options.fetchPolicy;n.resetLastResults(),"cache-only"===a||!e&&"standby"===a||r.push(n.refetch()),t.getQuery(i).setDiff(null)}})),this.broadcastQueries(),Promise.all(r)},P.prototype.setObservableQuery=function(e){this.getQuery(e.queryId).setObservableQuery(e)},P.prototype.startGraphQLSubscription=function(e){var t=this,r=e.query,o=e.fetchPolicy,i=e.errorPolicy,n=e.variables,a=e.context,s=void 0===a?{}:a;r=this.transform(r).document,n=this.getVariables(r,n);var u=function(e){return t.getObservableFromLink(r,s,e,!1).map((function(n){if("no-cache"!==o&&(k(n,i)&&t.cache.write({query:r,result:n.data,dataId:"ROOT_SUBSCRIPTION",variables:e}),t.broadcastQueries()),d(n))throw new m({graphQLErrors:n.errors});return n}))};if(this.transform(r).hasClientExports){var c=this.localState.addExportedVariables(r,n,s).then(u);return new O((function(e){var t=null;return c.then((function(r){return t=r.subscribe(e)}),e.error),function(){return t&&t.unsubscribe()}}))}return u(n)},P.prototype.stopQuery=function(e){this.stopQueryNoBroadcast(e),this.broadcastQueries()},P.prototype.stopQueryNoBroadcast=function(e){this.stopQueryInStoreNoBroadcast(e),this.removeQuery(e)},P.prototype.removeQuery=function(e){this.fetchCancelFns.delete(e),this.getQuery(e).stop(),this.queries.delete(e)},P.prototype.broadcastQueries=function(){this.onBroadcast&&this.onBroadcast(),this.queries.forEach((function(e){return e.notify()}))},P.prototype.getLocalState=function(){return this.localState},P.prototype.getObservableFromLink=function(e,t,o,i){var n,s,c=this;void 0===i&&(i=null!==(n=null==t?void 0:t.queryDeduplication)&&void 0!==n?n:this.queryDeduplication);var l=this.transform(e).serverQuery;if(l){var h=this.inFlightLinkObservables,y=this.link,d={query:l,variables:o,operationName:u(l)||void 0,context:this.prepareContext(r(r({},t),{forceFetch:!i}))};if(t=d.context,i){var v=h.get(l)||new Map;h.set(l,v);var m=JSON.stringify(o);if(!(s=v.get(m))){var b=new f([a(y,d)]);v.set(m,s=b),b.cleanup((function(){v.delete(m)&&v.size<1&&h.delete(l)}))}}else s=new f([a(y,d)])}else s=new f([O.of({data:{}})]),t=this.prepareContext(t);var g=this.transform(e).clientQuery;return g&&(s=p(s,(function(e){return c.localState.runResolvers({document:g,remoteResult:e,context:t,variables:o})}))),s},P.prototype.getResultsFromLink=function(e,t,r){var o=e.lastRequestId;return p(this.getObservableFromLink(e.document,r.context,r.variables),(function(i){var n=y(i.errors);if(o>=e.lastRequestId){if(n&&"none"===r.errorPolicy)throw e.markError(new m({graphQLErrors:i.errors}));e.markResult(i,r,t),e.markReady()}var a={data:i.data,loading:!1,networkStatus:e.networkStatus||w.ready};return n&&"ignore"!==r.errorPolicy&&(a.errors=i.errors),a}),(function(t){var r=b(t)?t:new m({networkError:t});throw o>=e.lastRequestId&&e.markError(r),r}))},P.prototype.fetchQueryObservable=function(e,t,r){var o=this;void 0===r&&(r=w.loading);var i=this.transform(t.query).document,n=this.getVariables(i,t.variables),a=this.getQuery(e),s=a.networkStatus,u=t.fetchPolicy,c=void 0===u?"cache-first":u,l=t.errorPolicy,h=void 0===l?"none":l,p=t.returnPartialData,y=void 0!==p&&p,d=t.notifyOnNetworkStatusChange,v=void 0!==d&&d,m=t.context,b=void 0===m?{}:m;("cache-first"===c||"cache-and-network"===c||"network-only"===c||"no-cache"===c)&&v&&"number"==typeof s&&s!==r&&q(r)&&("cache-first"!==c&&(c="cache-and-network"),y=!0);var g=Object.assign({},t,{query:i,variables:n,fetchPolicy:c,errorPolicy:h,returnPartialData:y,notifyOnNetworkStatusChange:v,context:b}),Q=function(e){return g.variables=e,o.fetchQueryByPolicy(a,g,r)};this.fetchCancelFns.set(e,(function(e){Promise.resolve().then((function(){return k.cancel(e)}))}));var k=new f(this.transform(g.query).hasClientExports?this.localState.addExportedVariables(g.query,g.variables,g.context).then(Q):Q(g.variables));return k.cleanup((function(){o.fetchCancelFns.delete(e);var r=t.nextFetchPolicy;r&&(t.nextFetchPolicy=void 0,t.fetchPolicy="function"==typeof r?r.call(t,t.fetchPolicy||"cache-first"):r)})),k},P.prototype.fetchQueryByPolicy=function(e,t,o){var a=this,s=t.query,u=t.variables,c=t.fetchPolicy,l=t.errorPolicy,h=t.returnPartialData,p=t.context;e.init({document:s,variables:u,lastRequestId:this.generateRequestId(),networkStatus:o});var f=function(){return e.getDiff(u)},d=function(t,o){void 0===o&&(o=e.networkStatus||w.loading);var c=t.result;"production"===process.env.NODE_ENV||!y(t.missing)||n(c,{})||h||"production"===process.env.NODE_ENV||i.warn("Missing cache result fields: "+t.missing.map((function(e){return e.path.join(".")})).join(", "),t.missing);var l=function(e){return O.of(r({data:e,loading:q(o),networkStatus:o},t.complete?null:{partial:!0}))};return a.transform(s).hasForcedResolvers?a.localState.runResolvers({document:s,remoteResult:{data:c},context:p,variables:u,onlyRunForcedResolvers:!0}).then((function(e){return l(e.data)})):l(c)},v=function(t){return a.getResultsFromLink(e,t,{variables:u,context:p,fetchPolicy:c,errorPolicy:l})};switch(c){default:case"cache-first":return(m=f()).complete?[d(m,e.markReady())]:h?[d(m),v(!0)]:[v(!0)];case"cache-and-network":var m;return(m=f()).complete||h?[d(m),v(!0)]:[v(!0)];case"cache-only":return[d(f(),e.markReady())];case"network-only":return[v(!0)];case"no-cache":return[v(!1)];case"standby":return[]}},P.prototype.getQuery=function(e){return e&&!this.queries.has(e)&&this.queries.set(e,new E(this.cache)),this.queries.get(e)},P.prototype.prepareContext=function(e){void 0===e&&(e={});var t=this.localState.prepareContext(e);return r(r({},t),{clientAwareness:this.clientAwareness})},P}();export{P as QueryManager};
@@ -1 +1 @@
1
- import{__extends as r}from"../../../tslib/tslib.es6.js";import"../../../ts-invariant/lib/invariant.esm.js";import"../utilities/graphql/transform.js";import"../utilities/common/mergeDeep.js";import"../utilities/observables/Observable.js";import"../utilities/observables/Concast.js";import{isNonEmptyArray as o}from"../utilities/common/arrays.js";function t(r){return r.hasOwnProperty("graphQLErrors")}var s=function(t){function s(r){var e,i,n=r.graphQLErrors,a=r.networkError,m=r.errorMessage,p=r.extraInfo,l=t.call(this,m)||this;return l.graphQLErrors=n||[],l.networkError=a||null,l.message=m||(i="",o((e=l).graphQLErrors)&&e.graphQLErrors.forEach((function(r){var o=r?r.message:"Error message not found.";i+=o+"\n"})),e.networkError&&(i+=e.networkError.message+"\n"),i=i.replace(/\n$/,"")),l.extraInfo=p,l.__proto__=s.prototype,l}return r(s,t),s}(Error);export{s as ApolloError,t as isApolloError};
1
+ import{__extends as r}from'../ext/tslib/tslib.es6.js';import"../../../ts-invariant/lib/invariant.esm.js";import"../utilities/graphql/transform.js";import"../utilities/common/mergeDeep.js";import"../utilities/observables/Observable.js";import"../utilities/observables/Concast.js";import{isNonEmptyArray as o}from"../utilities/common/arrays.js";function t(r){return r.hasOwnProperty("graphQLErrors")}var e=function(t){function e(r){var s,i,n=r.graphQLErrors,a=r.networkError,m=r.errorMessage,p=r.extraInfo,l=t.call(this,m)||this;return l.graphQLErrors=n||[],l.networkError=a||null,l.message=m||(i="",o((s=l).graphQLErrors)&&s.graphQLErrors.forEach((function(r){var o=r?r.message:"Error message not found.";i+=o+"\n"})),s.networkError&&(i+=s.networkError.message+"\n"),i=i.replace(/\n$/,"")),l.extraInfo=p,l.__proto__=e.prototype,l}return r(e,t),e}(Error);export{e as ApolloError,t as isApolloError};
@@ -0,0 +1,15 @@
1
+ /*! *****************************************************************************
2
+ Copyright (c) Microsoft Corporation.
3
+
4
+ Permission to use, copy, modify, and/or distribute this software for any
5
+ purpose with or without fee is hereby granted.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
+ PERFORMANCE OF THIS SOFTWARE.
14
+ ***************************************************************************** */
15
+ var t=function(n,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var r in n)n.hasOwnProperty(r)&&(t[r]=n[r])},t(n,r)};function n(n,r){function e(){this.constructor=n}t(n,r),n.prototype=null===r?Object.create(r):(e.prototype=r.prototype,new e)}var r=function(){return r=Object.assign||function(t){for(var n,r=1,e=arguments.length;r<e;r++)for(var o in n=arguments[r])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},r.apply(this,arguments)};function e(t,n){var r={};for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&n.indexOf(e)<0&&(r[e]=t[e]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(e=Object.getOwnPropertySymbols(t);o<e.length;o++)n.indexOf(e[o])<0&&Object.prototype.propertyIsEnumerable.call(t,e[o])&&(r[e[o]]=t[e[o]])}return r}function o(t,n,r,e){return new(r||(r=Promise))((function(o,a){function c(t){try{l(e.next(t))}catch(t){a(t)}}function u(t){try{l(e.throw(t))}catch(t){a(t)}}function l(t){var n;t.done?o(t.value):(n=t.value,n instanceof r?n:new r((function(t){t(n)}))).then(c,u)}l((e=e.apply(t,n||[])).next())}))}function a(t,n){var r,e,o,a,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;c;)try{if(r=1,e&&(o=2&a[0]?e.return:a[0]?e.throw||((o=e.return)&&o.call(e),0):e.next)&&!(o=o.call(e,a[1])).done)return o;switch(e=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,e=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!(o=c.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(6===a[0]&&c.label<o[1]){c.label=o[1],o=a;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(a);break}o[2]&&c.ops.pop(),c.trys.pop();continue}a=n.call(t,c)}catch(t){a=[6,t],e=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function c(){for(var t=0,n=0,r=arguments.length;n<r;n++)t+=arguments[n].length;var e=Array(t),o=0;for(n=0;n<r;n++)for(var a=arguments[n],c=0,u=a.length;c<u;c++,o++)e[o]=a[c];return e}export{r as __assign,o as __awaiter,n as __extends,a as __generator,e as __rest,c as __spreadArrays};
@@ -1 +1 @@
1
- import{__rest as e}from"../../../../tslib/tslib.es6.js";import{ApolloLink as t}from"../core/ApolloLink.js";import"../../../../ts-invariant/lib/invariant.esm.js";import"../../utilities/graphql/transform.js";import"../../utilities/common/mergeDeep.js";import"../../utilities/observables/Observable.js";import"../../utilities/observables/Concast.js";import r from"../../../../zen-observable/index.js";function i(i){return new t((function(t,n){var o=e(t,[]);return new r((function(e){var r;return Promise.resolve(o).then((function(e){return i(e,t.getContext())})).then(t.setContext).then((function(){r=n(t).subscribe({next:e.next.bind(e),error:e.error.bind(e),complete:e.complete.bind(e)})})).catch(e.error.bind(e)),function(){r&&r.unsubscribe()}}))}))}export{i as setContext};
1
+ import{__rest as e}from'../../ext/tslib/tslib.es6.js';import{ApolloLink as t}from"../core/ApolloLink.js";import"../../../../ts-invariant/lib/invariant.esm.js";import"../../utilities/graphql/transform.js";import"../../utilities/common/mergeDeep.js";import"../../utilities/observables/Observable.js";import"../../utilities/observables/Concast.js";import r from"../../../../zen-observable/index.js";function i(i){return new t((function(t,n){var o=e(t,[]);return new r((function(e){var r;return Promise.resolve(o).then((function(e){return i(e,t.getContext())})).then(t.setContext).then((function(){r=n(t).subscribe({next:e.next.bind(e),error:e.error.bind(e),complete:e.complete.bind(e)})})).catch(e.error.bind(e)),function(){r&&r.unsubscribe()}}))}))}export{i as setContext};