@ikas/storefront 2.0.0-alpha.9 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/__generated__/global-types.d.ts +9 -2
- package/build/__generated__/global-types.js +1 -1
- package/build/analytics/facebookPixel.js +1 -1
- package/build/analytics/googleTagManager.js +1 -1
- package/build/analytics/head/index.js +1 -1
- package/build/analytics/ikas.js +1 -1
- package/build/api/apollo.js +1 -1
- package/build/api/blog/__generated__/getBlog.d.ts +14 -16
- package/build/api/blog/__generated__/listBlog.d.ts +14 -16
- package/build/api/blog/__generated__/listBlogCategory.d.ts +14 -16
- package/build/api/blog/__generated__/listBlogMetaData.d.ts +14 -16
- package/build/api/brand/__generated__/listProductBrand.d.ts +3 -3
- package/build/api/cart/__generated__/getCart.d.ts +2 -4
- package/build/api/cart/__generated__/saveItemToCart.d.ts +2 -4
- package/build/api/category/__generated__/listCategory.d.ts +3 -3
- package/build/api/checkout/__generated__/getCheckoutById.d.ts +2 -4
- package/build/api/checkout/__generated__/getOrder.d.ts +5 -11
- package/build/api/checkout/__generated__/listCheckoutSettings.d.ts +1 -1
- package/build/api/checkout/index.js +1 -1
- package/build/api/customer/__generated__/createOrderRefundRequest.d.ts +5 -11
- package/build/api/customer/__generated__/customerLogin.d.ts +12 -5
- package/build/api/customer/__generated__/customerSocialLogin.d.ts +161 -0
- package/build/api/customer/__generated__/getCustomerOrders.d.ts +5 -11
- package/build/api/customer/__generated__/getMyCustomer.d.ts +4 -5
- package/build/api/customer/__generated__/registerCustomer.d.ts +12 -5
- package/build/api/customer/__generated__/saveMyCustomer.d.ts +12 -5
- package/build/api/customer/index.d.ts +5 -0
- package/build/api/customer/index.js +1 -1
- package/build/api/customer-review/__generated__/listCustomerReviews.d.ts +14 -16
- package/build/api/product-option-set/index.js +1 -1
- package/build/api/raffle/__generated__/listRaffle.d.ts +14 -16
- package/build/api/raffle/__generated__/saveRaffleParticipant.d.ts +2 -2
- package/build/api/raffle/index.js +1 -1
- package/build/api/variant-type/__generated__/listVariantType.d.ts +3 -7
- package/build/components/checkout/components/address-form/index.js +1 -1
- package/build/components/checkout/components/address-form/model.d.ts +8 -0
- package/build/components/checkout/components/cart-summary/cart-item/index.js +1 -1
- package/build/components/checkout/components/cart-summary/index.js +1 -1
- package/build/components/checkout/components/cart-summary/style.module.scss.js +1 -1
- package/build/components/checkout/components/step-container/index.js +1 -1
- package/build/components/checkout/index.js +1 -1
- package/build/components/checkout/model.d.ts +2 -0
- package/build/components/checkout/model.js +1 -1
- package/build/components/checkout/steps/step-payment/payment-gateways/index.js +1 -1
- package/build/components/checkout/steps/step-payment/payment-gateways/installments/index.js +1 -1
- package/build/components/checkout/steps/step-shipping/index.js +1 -1
- package/build/components/checkout/steps/step-success/index.js +1 -1
- package/build/components/index.d.ts +1 -1
- package/build/components/page/ThemeComponent.js +1 -1
- package/build/components/page/head.js +1 -1
- package/build/components/page/index.js +1 -1
- package/build/components/page-editor/ThemeComponentEditor.d.ts +0 -3
- package/build/components/page-editor/ThemeComponentEditor.js +1 -1
- package/build/components/page-editor/index.d.ts +3 -1
- package/build/components/page-editor/index.js +1 -1
- package/build/components/page-editor/loader/index.d.ts +5 -1
- package/build/components/page-editor/loader/index.js +1 -1
- package/build/components/page-editor/loader/style.module.scss.js +1 -1
- package/build/components/page-editor/model.d.ts +8 -4
- package/build/components/page-editor/model.js +1 -1
- package/build/ext/@apollo/client/cache/inmemory/entityStore.js +1 -1
- package/build/ext/@apollo/client/cache/inmemory/inMemoryCache.js +1 -1
- package/build/ext/@apollo/client/cache/inmemory/policies.js +1 -1
- package/build/ext/@apollo/client/cache/inmemory/readFromStore.js +1 -1
- package/build/ext/@apollo/client/cache/inmemory/writeToStore.js +1 -1
- package/build/ext/@apollo/client/core/ApolloClient.js +1 -1
- package/build/ext/@apollo/client/core/LocalState.js +1 -1
- package/build/ext/@apollo/client/core/ObservableQuery.js +1 -1
- package/build/ext/@apollo/client/core/QueryManager.js +1 -1
- package/build/ext/@apollo/client/errors/index.js +1 -1
- package/build/ext/@apollo/client/ext/tslib/tslib.es6.js +15 -0
- package/build/ext/@apollo/client/link/context/index.js +1 -1
- package/build/ext/@apollo/client/link/core/ApolloLink.js +1 -1
- package/build/ext/@apollo/client/link/error/index.js +1 -1
- package/build/ext/@apollo/client/link/http/HttpLink.js +1 -1
- package/build/ext/@apollo/client/link/http/createHttpLink.js +1 -1
- package/build/ext/@apollo/client/link/http/selectHttpOptionsAndBody.js +1 -1
- package/build/ext/@apollo/client/link/utils/createOperation.js +1 -1
- package/build/ext/@apollo/client/utilities/common/mergeDeep.js +1 -1
- package/build/ext/@apollo/client/utilities/graphql/fragments.js +1 -1
- package/build/ext/@apollo/client/utilities/graphql/transform.js +1 -1
- package/build/ext/@apollo/client/utilities/observables/Concast.js +1 -1
- package/build/ext/ts-invariant/ext/tslib/tslib.es6.js +15 -0
- package/build/ext/ts-invariant/lib/invariant.esm.js +1 -1
- package/build/ext/tslib/tslib.es6.js +1 -1
- package/build/ikas.js +67 -2
- package/build/index.js +1 -1
- package/build/models/data/blog/index.js +1 -1
- package/build/models/data/brand/index.js +1 -1
- package/build/models/data/category/index.js +1 -1
- package/build/models/data/checkout/index.js +1 -1
- package/build/models/data/checkout-settings/index.d.ts +1 -1
- package/build/models/data/checkout-settings/index.js +1 -1
- package/build/models/data/customer/address/index.d.ts +4 -1
- package/build/models/data/customer/address/index.js +1 -1
- package/build/models/data/image/index.js +1 -1
- package/build/models/data/index.d.ts +1 -0
- package/build/models/data/language/index.d.ts +6 -0
- package/build/models/data/order/address/index.d.ts +2 -1
- package/build/models/data/order/address/index.js +1 -1
- package/build/models/data/order/line-item/variant/index.js +1 -1
- package/build/models/data/product/index.js +1 -1
- package/build/models/data/product-filter/index.js +1 -1
- package/build/models/data/product-option-set/index.d.ts +4 -0
- package/build/models/data/product-option-set/index.js +1 -1
- package/build/models/data/raffle/index.d.ts +1 -1
- package/build/models/data/raffle/index.js +1 -1
- package/build/models/data/slider/index.d.ts +5 -0
- package/build/models/data/slider/index.js +1 -0
- package/build/models/theme/component/index.d.ts +9 -0
- package/build/models/theme/component/index.js +1 -1
- package/build/models/theme/component/prop/index.d.ts +21 -0
- package/build/models/theme/component/prop/index.js +1 -1
- package/build/models/theme/custom-data/index.d.ts +20 -1
- package/build/models/theme/custom-data/index.js +1 -1
- package/build/models/theme/settings/color/index.d.ts +14 -0
- package/build/models/theme/settings/color/index.js +1 -0
- package/build/models/theme/settings/{prop/favicon → favicon}/index.d.ts +0 -0
- package/build/models/theme/settings/{prop/favicon → favicon}/index.js +0 -0
- package/build/models/theme/settings/font-family/index.d.ts +5 -0
- package/build/models/theme/settings/font-family/index.js +1 -0
- package/build/models/theme/settings/index.d.ts +4 -2
- package/build/models/theme/settings/index.js +1 -1
- package/build/models/ui/product-detail/index.js +1 -1
- package/build/models/ui/product-list/index.d.ts +1 -1
- package/build/models/ui/product-list/index.js +1 -1
- package/build/models/ui/validator/form/account-info.js +1 -1
- package/build/models/ui/validator/form/address.js +1 -1
- package/build/models/ui/validator/form/register.js +1 -1
- package/build/pages/checkout.js +1 -1
- package/build/pages/editor.d.ts +4 -3
- package/build/pages/editor.js +1 -1
- package/build/providers/page-data-get.d.ts +1 -1
- package/build/providers/page-data-get.js +1 -1
- package/build/providers/page-data-init.d.ts +3 -1
- package/build/providers/page-data-init.js +1 -1
- package/build/providers/page-data-next.d.ts +2 -1
- package/build/providers/page-data-next.js +1 -1
- package/build/providers/prop-value/custom.d.ts +1 -0
- package/build/providers/prop-value/custom.js +1 -1
- package/build/providers/prop-value/slider.d.ts +11 -0
- package/build/providers/prop-value/slider.js +1 -0
- package/build/scripts/generators/components/index.js +1 -1
- package/build/scripts/generators/config/content.d.ts +2 -3
- package/build/scripts/generators/config/content.js +1 -1
- package/build/scripts/generators/config/index.js +1 -1
- package/build/scripts/generators/index.d.ts +1 -0
- package/build/scripts/generators/pages/index.js +1 -1
- package/build/scripts/generators/store/index.js +1 -1
- package/build/scripts/generators/theme/index.js +1 -1
- package/build/scripts/generators/types/index.d.ts +15 -0
- package/build/scripts/generators/types/index.js +1 -0
- package/build/store/cart.d.ts +6 -7
- package/build/store/cart.js +1 -1
- package/build/store/customer.d.ts +19 -0
- package/build/store/customer.js +1 -1
- package/build/storefront/index.d.ts +5 -3
- package/build/storefront/index.js +1 -1
- package/build/utils/fs.js +1 -1
- package/build/utils/google-fonts.d.ts +2 -0
- package/build/utils/google-fonts.js +1 -0
- package/package.json +9 -9
- package/build/models/theme/settings/prop/color/index.d.ts +0 -7
- package/build/models/theme/settings/prop/color/index.js +0 -1
|
@@ -8,13 +8,10 @@ declare type Props = {
|
|
|
8
8
|
export declare class ThemeEditorComponent extends React.Component<Props> {
|
|
9
9
|
ref: React.RefObject<HTMLDivElement>;
|
|
10
10
|
error: any;
|
|
11
|
-
disposer?: () => void;
|
|
12
11
|
state: {
|
|
13
12
|
hasError: boolean;
|
|
14
13
|
};
|
|
15
14
|
constructor(props: Props);
|
|
16
|
-
componentDidMount(): void;
|
|
17
|
-
componentWillUnmount(): void;
|
|
18
15
|
static getDerivedStateFromError(error: any): {
|
|
19
16
|
hasError: boolean;
|
|
20
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__extends as e,__assign as o}from'../../ext/tslib/tslib.es6.js';import*as t from"react";import r from"./error/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import{IkasCheckout as i}from"../../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{IkasOrderLineItem as n}from"../../models/data/order/line-item/index.js";import{
|
|
1
|
+
import{__extends as e,__assign as o}from'../../ext/tslib/tslib.es6.js';import*as t from"react";import r from"./error/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import{IkasCheckout as i}from"../../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{IkasOrderLineItem as n}from"../../models/data/order/line-item/index.js";import{makeObservable as a,computed as s}from"mobx";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"../../models/theme/theme.js";import{IkasThemePageType as m}from"../../models/theme/page/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"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{IkasStorefrontConfig as p}from"../../storefront/index.js";import{IkasCheckoutSettings as l}from"../../models/data/checkout-settings/index.js";import u from"../checkout/index.js";import{IkasCart as c}from"../../models/data/cart/index.js";import{IkasPageDataInit as f}from"../../providers/page-data-init.js";import{Observer as v}from"mobx-react-lite";var j=function(j){function g(e){var o=j.call(this,e)||this;return o.state={hasError:!1},o.onMouseEnter=function(){var e=o.props,t=e.vm,r=e.pageComponent;t.onMouseOver(r.id)},o.onMouseLeave=function(){var e=o.props,t=e.vm,r=e.pageComponent;t.onMouseLeave(r.id)},o.onClick=function(){var e=o.props,t=e.vm,r=e.pageComponent;t.onClick(r.id)},o.ref=t.createRef(),a(o,{pageComponentPropValue:s,propValues:s,isSelected:s,isHovered:s,hasNullValue:s,rendered:s,Component:s}),o}return e(g,j),g.getDerivedStateFromError=function(e){return console.error(e),{hasError:!0}},Object.defineProperty(g.prototype,"pageComponentPropValue",{get:function(){var e=this.props,o=e.vm,t=e.pageComponent;return o.pageDataProvider.pageComponentPropValues.find((function(e){return e.pageComponent.id===t.id}))},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"propValues",{get:function(){var e,t,r=this.props.vm,a=null===(e=this.pageComponentPropValue)||void 0===e?void 0:e.propValues;(null===(t=r.page)||void 0===t?void 0:t.type)===m.CHECKOUT&&(a={checkout:new i({cart:new c({items:[new n({currencyCode:"TRY",finalPrice:100,finalPriceWithQuantity:100,price:100,priceWithQuantity:100,quantity:1})]})}),checkoutSettings:new l,merchantSettings:null,customizationProps:o({},a),returnPolicy:"",privacyPolicy:"",termsOfService:""});return a},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"isSelected",{get:function(){var e=this.props,o=e.vm,t=e.pageComponent;return o.selectedPageComponentId===t.id},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"isHovered",{get:function(){var e=this.props,o=e.vm,t=e.pageComponent;return o.hoveredPageComponentId===t.id},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"hasNullValue",{get:function(){var e,o=this;return!!(null===(e=this.pageComponentPropValue)||void 0===e?void 0:e.component.props.some((function(e){var t;if(e.isRequired){var r=(o.propValues||{})[e.name],i=null===(t=o.pageComponentPropValue)||void 0===t?void 0:t.component.props.find((function(o){return o.id===e.requiredPropId}));if(i){var n=(o.propValues||{})[i.name];if(i.type===d.BOOLEAN&&!n||i.type===d.CUSTOM&&n!==e.requiredEnumOptionValue)return!1}return null===r||null==r}})))},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"rendered",{get:function(){var e,i,n=this.Component,a=this.props.vm,s=p.store;return this.hasNullValue||this.state.hasError?t.createElement(r,{name:null===(e=this.pageComponentPropValue)||void 0===e?void 0:e.component.displayName}):t.createElement(n,o({},this.propValues,{store:s,settings:null===(i=a.theme)||void 0===i?void 0:i.settings,pageSpecificData:f.pageSpecificData}))},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"Component",{get:function(){var e,o=this.props,t=o.vm,r=o.pageComponent,i=p.currentPageComponents;if(!i)return null;var n=i[r.componentId];return(null===(e=t.page)||void 0===e?void 0:e.type)===m.CHECKOUT&&(n=u),n},enumerable:!1,configurable:!0}),g.prototype.render=function(){var e=this;return t.createElement(v,null,(function(){var o;return e.state.hasError?t.createElement("div",{ref:e.ref,style:{position:"relative"},onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave,onClick:e.onClick},t.createElement(r,{name:null===(o=e.pageComponentPropValue)||void 0===o?void 0:o.component.displayName}),";"):p.currentPageComponents?t.createElement("div",{ref:e.ref,style:{position:"relative"},onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave},e.rendered):(console.error("Components for the page not found."),null)}))},g}(t.Component);export{j as ThemeEditorComponent};
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
2
|
+
import { WithRouterProps } from "next/dist/client/with-router";
|
|
3
|
+
declare const _default: React.ComponentType<import("next/dist/client/with-router").ExcludeRouterProps<WithRouterProps>>;
|
|
4
|
+
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{__extends as e}from'../../ext/tslib/tslib.es6.js';import*as t from"react";import{Observer as o}from"mobx-react-lite";import{withRouter as n}from"next/router.js";import{ThemeEditorComponent as r}from"./ThemeComponentEditor.js";import i from"./model.js";import{IkasPageHead as a}from"../page/head.js";import{IkasEditorComponentLoader as m}from"./loader/index.js";import{reaction as l,makeObservable as p,computed as s}from"mobx";import{getGoogleFontHref as d}from"../../utils/google-fonts.js";var u=n(function(n){function u(e){var t=n.call(this,e)||this;return t.interceptClickEvent=function(e){var t=e.target;"A"===t.tagName&&(t.getAttribute("href"),e.preventDefault())},t.handleRouteChangeStart=function(e,o){throw t.vm.onPageChange(e),""},t.injectFontScript=function(){var e;if(null===(e=t.vm.theme)||void 0===e?void 0:e.settings.fontFamily.name){var o=t.vm.theme.settings.fontFamily,n=document.getElementById("ikas-font");n&&n.remove();var r=d(o);if(r){var i=document.createElement("link");i.setAttribute("id","ikas-font"),i.setAttribute("rel","stylesheet"),i.setAttribute("href",r),document.getElementsByTagName("head")[0].appendChild(i),document.body.style.setProperty("font-family","'".concat(o.name,'\', -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'),"important")}}else document.body.style.setProperty("font-family",'-apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif')},t.vm=new i(e.router),p(t,{headerPageComponent:s,footerPageComponent:s,otherComponents:s}),t}return e(u,n),u.prototype.componentDidMount=function(){var e=this;this.props.router.events.on("routeChangeStart",this.handleRouteChangeStart),document.addEventListener&&document.addEventListener("click",this.interceptClickEvent),this.disposer&&this.disposer(),this.disposer=l((function(){var t;return null===(t=e.vm.theme)||void 0===t?void 0:t.settings}),(function(){var t;null===(t=e.vm.theme)||void 0===t||t.settings.colors.map((function(e){return document.documentElement.style.setProperty(e.key,e.color)})),e.injectFontScript()}))},u.prototype.componentWillUnmount=function(){this.props.router.events.off("routeChangeStart",this.handleRouteChangeStart),document.removeEventListener("click",this.interceptClickEvent),this.disposer&&this.disposer()},Object.defineProperty(u.prototype,"headerPageComponent",{get:function(){var e,t=this.vm;return null===(e=t.pageComponents)||void 0===e?void 0:e.find((function(e){var o,n;return e.componentId===(null===(n=null===(o=t.theme)||void 0===o?void 0:o.headerComponent)||void 0===n?void 0:n.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"footerPageComponent",{get:function(){var e,t=this.vm;return null===(e=t.pageComponents)||void 0===e?void 0:e.find((function(e){var o,n;return e.componentId===(null===(n=null===(o=t.theme)||void 0===o?void 0:o.footerComponent)||void 0===n?void 0:n.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"otherComponents",{get:function(){var e,t=this.vm;return null===(e=t.pageComponents)||void 0===e?void 0:e.filter((function(e){var o,n,r,i;return e.componentId!==(null===(n=null===(o=t.theme)||void 0===o?void 0:o.headerComponent)||void 0===n?void 0:n.id)&&e.componentId!==(null===(i=null===(r=t.theme)||void 0===r?void 0:r.footerComponent)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),u.prototype.render=function(){var e=this,n=this.vm;return t.createElement(o,null,(function(){var o;return n.isLoading?t.createElement(m,{isFullPage:!0}):t.createElement(t.Fragment,null,!!n.page&&t.createElement(a,{pageType:n.page.type,pageTitle:n.page.pageTitle,pageDescription:n.page.description}),t.createElement("div",{style:c},t.createElement("div",null,!!e.headerPageComponent&&t.createElement(r,{key:e.headerPageComponent.id,vm:n,pageComponent:e.headerPageComponent}),null===(o=e.otherComponents)||void 0===o?void 0:o.map((function(e){return t.createElement(r,{key:e.id,vm:n,pageComponent:e})}))),!!e.footerPageComponent&&t.createElement(r,{key:e.footerPageComponent.id,vm:n,pageComponent:e.footerPageComponent})))}))},u}(t.Component)),c={minHeight:"100vh",width:"100vw",display:"flex",flexDirection:"column",justifyContent:"space-between"};export{u as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import
|
|
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,11 +25,14 @@ 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<
|
|
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>;
|
|
35
|
+
handleUpdateThemeJson: (data: any) => Promise<void>;
|
|
34
36
|
handleUpdatePropValue: (data: any) => Promise<void>;
|
|
35
37
|
handleUpdatePageParams: (data: any) => Promise<void>;
|
|
36
38
|
handleUpdatePageComponentOrder: (data: any) => Promise<void>;
|
|
@@ -47,6 +49,7 @@ export default class IkasPageEditorViewModel {
|
|
|
47
49
|
export declare enum BridgeMessageType {
|
|
48
50
|
FRAME_DID_LOAD = "FRAME_DID_LOAD",
|
|
49
51
|
UPDATE_FRAME_DATA = "UPDATE_FRAME_DATA",
|
|
52
|
+
UPDATE_THEME_JSON = "UPDATE_THEME_JSON",
|
|
50
53
|
UPDATE_PROP_VALUE = "UPDATE_PROP_VALUE",
|
|
51
54
|
UPDATE_PAGE_PARAMS = "UPDATE_PAGE_PARAMS",
|
|
52
55
|
UPDATE_PAGE_COMPONENT_ORDER = "UPDATE_PAGE_COMPONENT_ORDER",
|
|
@@ -61,5 +64,6 @@ export declare enum BridgeMessageType {
|
|
|
61
64
|
SET_SELECTED_COMPONENT = "SET_SELECTED_COMPONENT",
|
|
62
65
|
SET_HOVERED_COMPONENT = "SET_HOVERED_COMPONENT",
|
|
63
66
|
SCROLL_TO_COMPONENT = "SCROLL_TO_COMPONENT",
|
|
64
|
-
UPDATE_THEME_SETTINGS = "UPDATE_THEME_SETTINGS"
|
|
67
|
+
UPDATE_THEME_SETTINGS = "UPDATE_THEME_SETTINGS",
|
|
68
|
+
EDITOR_PAGE_CHANGE = "EDITOR_PAGE_CHANGE"
|
|
65
69
|
}
|
|
@@ -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 E}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 P}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 T,C=function(){function C(f){var C=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",C.onMessage,!1),C.sendMessage(T.FRAME_DID_LOAD,"2.0.0")},this.onMessage=function(n){return e(C,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 T.UPDATE_FRAME_DATA:return[3,1];case T.UPDATE_THEME_JSON:return[3,3];case T.UPDATE_PROP_VALUE:return[3,5];case T.UPDATE_PAGE_PARAMS:return[3,7];case T.UPDATE_PAGE_COMPONENT_ORDER:return[3,9];case T.ADD_COMPONENT:return[3,11];case T.DELETE_COMPONENT:return[3,12];case T.UPDATE_COMPONENT:return[3,13];case T.ADD_PAGE_COMPONENT:return[3,14];case T.DELETE_PAGE_COMPONENT:return[3,16];case T.SET_SELECTED_COMPONENT:return[3,17];case T.SET_HOVERED_COMPONENT:return[3,18];case T.SCROLL_TO_COMPONENT:return[3,19];case T.UPDATE_THEME_SETTINGS:return[3,20]}return[3,21];case 1:return[4,this.handleUpdateFrameData(i)];case 2:case 4:case 6:case 8:case 10:case 15:return t.sent(),[3,22];case 3:return[4,this.handleUpdateThemeJson(i)];case 5:return[4,this.handleUpdatePropValue(i)];case 7:return[4,this.handleUpdatePageParams(i)];case 9:return[4,this.handleUpdatePageComponentOrder(i)];case 11:return this.handleAddNewComponent(i),[3,22];case 12:return this.handleDeleteComponent(i),[3,22];case 13:return this.handleUpdateComponent(i),[3,22];case 14:return[4,this.handleAddNewPageComponent(i)];case 16:return this.handleDeletePageComponent(i),[3,22];case 17:return this.handleSetSelectedComponent(i),[3,22];case 18:return this.handleSetHoveredComponent(i),[3,22];case 19:return this.handleScrollToComponent(i),[3,22];case 20:return this.updateThemeSettings(i),[3,22];case 21:return[3,22];case 22:return[2]}}))}))},this.onClick=function(e){C.sendMessage(T.COMPONENT_CLICK,{componentId:e})},this.onMouseOver=function(e){C.sendMessage(T.COMPONENT_MOUSE_OVER,{componentId:e})},this.onMouseLeave=function(e){C.sendMessage(T.COMPONENT_MOUSE_LEAVE,{componentId:e})},this.onPageChange=function(n){return e(C,void 0,void 0,(function(){var e,r,d,p,u,l,c,m,f,E=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,P.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,E.pageDataProvider=m,p===s.CUSTOM?E.page=null===(e=E.theme)||void 0===e?void 0:e.pages.find((function(e){return e.type===p&&e.slug===E.pageParams.slug})):E.page=null===(t=E.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(T.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(C,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){C.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(C,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.priceListId=void 0,v.routings=i.routings,v.stockPreference=this.theme.settings.stockPreference),this.translations&&(v.translations=this.translations),v.isEditor=!0,E.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.handleUpdateThemeJson=function(n){return e(C,void 0,void 0,(function(){return t(this,(function(e){return this.theme=new r(n.theme),[2]}))}))},this.handleUpdatePropValue=function(n){return e(C,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(C,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(C,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=C.theme)||void 0===t||t.components.push(n)},this.handleDeleteComponent=function(e){var t,n;(null===(t=C.theme)||void 0===t?void 0:t.components)&&(C.theme.components=C.theme.components.filter((function(t){return t.id!==e.componentId})));var i=C.pageComponents.filter((function(t){return t.componentId!==e.componentId}))||[];C.specification&&C.specification.components&&(C.specification.components=i),!C.specification&&(null===(n=C.page)||void 0===n?void 0:n.components)&&(C.page.components=i)},this.handleUpdateComponent=function(e){var t=C.theme.components.findIndex((function(t){return t.id===e.component.id}));-1!==t&&(C.theme.components[t]=new p(e.component))},this.handleAddNewPageComponent=function(n){return e(C,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){C.specification?C.specification.components=C.pageComponents.filter((function(t){return t.id!==e.pageComponentId})):C.page.components=C.pageComponents.filter((function(t){return t.id!==e.pageComponentId}))},this.handleSetSelectedComponent=function(e){C.selectedPageComponentId=e.componentId},this.handleSetHoveredComponent=function(e){C.hoveredPageComponentId=e.componentId},this.handleScrollToComponent=function(e){var t=e.componentId,n=C.componentRefs[t];n&&(C.isScrolledIntoView(n)||window.scrollTo({top:n.offsetTop,behavior:"smooth"}))},this.updateThemeSettings=function(e){var t=e.settings;C.theme&&(C.theme.settings=new l(t))},this.router=f,n(this),this.startMessaging()}return Object.defineProperty(C.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(C.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(C.prototype,"selectedPageComponent",{get:function(){var e=this;return this.pageComponents.find((function(t){return t.id===e.selectedPageComponentId}))},enumerable:!1,configurable:!0}),Object.defineProperty(C.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}),C.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]}}))}))},C}();!function(e){e.FRAME_DID_LOAD="FRAME_DID_LOAD",e.UPDATE_FRAME_DATA="UPDATE_FRAME_DATA",e.UPDATE_THEME_JSON="UPDATE_THEME_JSON",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"}(T||(T={}));export{T as BridgeMessageType,C as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as t,__rest as e,__extends as r}from
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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,
|
|
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
|
|
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};
|