PageSourceSearch

https://cdn2.saby.ru/static/resources/LinkDecorator/DecorationData…?x_module=b06a69e4b10bcaec5c2773cab03a536d

js saby.ru collected 2026-10-01 10:38:34 UTC 15,522 bytes, 1 lines download raw bytes

1define("LinkDecorator/DecorationDataController",["react","Feature/feature","require","exports","Application/Env","LinkDecorator/helpers","Types/source","LinkDecorator/interface","Types/entity","WasabyLoader/ModulesLoader","RequireJsLoader/conduct","UI/Utils","Env/Env","Types/entity","Browser/Storage","UICommon/Deps"],(function(e,t,r,a,n,i,o,s,l,c,u,d,h,m,D,v){var p,f,_,g,y,k,P,L;Object.defineProperty(a,"__esModule",{value:!0}),p=function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=new class{constructor(){this._queue=[],this._numOfCurrentRequest=0,this.enqueue=(e,t)=>{if(30===this._numOfCurrentRequest)return new Promise((r=>this._queue.push({resolve:r,loadFunction:e,params:t})));this._numOfCurrentRequest+=1},this.dequeue=()=>{if(this._numOfCurrentRequest-=1,this._queue.length){this._numOfCurrentRequest+=1;const{resolve:e,loadFunction:t,params:r}=this._queue.shift();t(r).then((t=>e(t)))}}}};return t.default=r,t}(0,{}),f=p,_=function(e,t,r,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.buildFrameDecorationData=void 0;return t.buildFrameDecorationData=function(e){const t={type:a.IDecorationType.EXTRA_LARGE,location:a.ILinkType.INTERNAL,decorationType:a.IDecorationType.EXTRA_LARGE,title:e.title,icon:{type:a.IIconType.ICON,icon:"icon-Sabydoc",iconColor:"label"},contentTemplateName:e.contentTemplateName,contentTemplateOptions:e.contentTemplateOptions},n={version:a.IDecorationVersion.NEW,frameContent:!0,view:t};if((0,r.isLoaded)(e.contentTemplateName))return n;else return(0,r.loadAsync)(e.contentTemplateName).then((()=>n))},t}(0,{},c,s),g=_,y=function(e,t,r){"use strict";return Object.defineProperty(t,"__esModule",{value:!0}),t.isXlFragmentEnabled=t.XL_FRAGMENT_FEATURE=void 0,t.XL_FRAGMENT_FEATURE="link-xl-fragment",t.isXlFragmentEnabled=function(){const[e]=r.Feature.get([t.XL_FRAGMENT_FEATURE]);return Boolean(e)},t}(0,{},t),k=y,P=function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useForceRender=t.useMaybePromiseFactory=t.maybePromise=void 0;t.maybePromise=(e,t)=>{if(e instanceof Promise)return e.then(t);else return t(e)};const a={data:null,pending:!1,error:null};t.useMaybePromiseFactory=(e,n,i)=>{const o=(0,r.useRef)(a),s=(0,r.useRef)(),l=(0,t.useForceRender)();s.current=(0,r.useMemo)((()=>{if(o.current.invalidating)return;const t=e();if(!t)return o.current={data:null,pending:!1,error:null},null;if(!(t instanceof Promise))return o.current={data:t,pending:!1,error:null},t;o.current={data:null,pending:!0,error:null};const r=()=>s.current===t;return t.then((e=>{if(r())o.current={data:e,pending:!1,error:null},l()})).catch((e=>{if(r())o.current={data:null,pending:!1,error:e},l()})),t}),[e]);const c=(0,r.useCallback)((()=>{if(!o.current.invalidating)o.current={...o.current,invalidating:!0},l(),Promise.resolve(e()).then((e=>{o.current={data:e,pending:!1,error:null,invalidating:!1},l()})).catch((()=>{o.current={...o.current,invalidating:!1},l()}))}),[e]);return(0,r.useEffect)((()=>(null==n||n(c),()=>{null==i||i(c)})),[n,i,c]),(0,r.useEffect)((()=>()=>{s.current=null}),[]),[o.current.data,o.current.pending,o.current.error]};return t.useForceRender=()=>{const[e,t]=(0,r.useState)(0);return(0,r.useCallback)((()=>{t((e=>e+1))}),[])},t}(0,{},e),L=P,a.getErrorDecorationData=a.FRAME_DATA_PROVIDER=void 0;const T="linkDecorationCache",S="value",F="valueNoFrame",I="LinkDecorationTypes",R="linkStaticInfo",E="link_decorator_id",w="link_decorator_height",b="link_decorator_private_data",A="linkFrameData",C="linkFrameDataNesting",N="linkFrameDataFailed";a.FRAME_DATA_PROVIDER="DocsEditor/linkFrameData";const M=e=>(0,n.getStore)(T).get(e),O=(e,t)=>{(0,n.getStore)(T).set(e,t)},q=e=>{if(!M(e))O(e,new Map)},X=()=>{const e=(0,n.getStore)(T);let t=e.get(A);if(!t)t=new Map,e.set(A,t);return t},G=()=>{const e=(0,n.getStore)(T);let t=e.get(N);if(!t)t=new Set,e.set(N,t);return t},U=()=>{var e;return null!==(e=(0,n.getStore)(T).get(C))&&void 0!==e?e:0},z=e=>{(0,n.getStore)(T).set(C,e)};a.getErrorDecorationData=(e,t)=>{var r,a;const n="LinkDecorator/view:ErrorTemplate",i=null===(r=null==e?void 0:e.replace)||void 0===r?void 0:r.call(e,/^https?:\/\//i,""),o=e?null===(a=new URL(e))||void 0===a?void 0:a.hostname:"";return(0,c.loadAsync)(n).then((()=>({version:s.IDecorationVersion.NEW,view:{title:i,headerDetails:t===s.IDecorationType.EXTRA_LARGE&&o,location:s.ILinkType.EXTERNAL,subtitle:t===s.IDecorationType.MEDIUM&&o,footerDetails:t===s.IDecorationType.LARGE&&o,contentTemplateName:n,isError:!0}})))};class W extends m.ObservableMixin{constructor(){if(super(),this.sbisService=new o.SbisService({endpoint:{address:h.constants.decoratedLinkService+"?srv=1",contract:"LinkDecorator"}}),this._decorationDataPromises=new Map,this._linkStaticInfoPromises=new Map,this._frameDataPromises=new Map,this._frameDataListeners=new Set,this._frameDataNotificationScheduled=!1,this.isPrivateLink=(e,t)=>{var r,a;return e===s.IDecorationType.SMALL&&"user"===(null===(a=null===(r=null==t?void 0:t.view)||void 0===r?void 0:r.cachePolicy)||void 0===a?void 0:a.forwhom)},this._getLinkStaticInfo=e=>{const t=this._linkStaticInfoPromises.get(e);if(t)return t;const r=this.loadStaticInfo(e);return this._linkStaticInfoPromises.set(e,r),r},this._getDecorationDataPromise=(e,t,r)=>{var a,n;const i=null===(n=null===(a=this._decorationDataPromises.get(e))||void 0===a?void 0:a.get)||void 0===n?void 0:n.call(a,t);if(i)return i;const o=this.loadDecorationData.bind(this),s={link:e,type:t,decorationDataFromProps:r},l=f.default.enqueue(o,s),c=null!=l?l:this.loadDecorationData(s);return this._setDecorationDataPromise(e,t,c),c},this._setDecorationDataPromise=(e,t,r)=>{if(!this._decorationDataPromises.get(e))this._decorationDataPromises.set(e,new Map);if(!this._decorationDataPromises.get(e).get(t))this._decorationDataPromises.get(e).set(t,r)},this._clearDecorationCache=(e,t)=>{var r,a,n,i;const o=M(S);if(null===(r=o.get(e))||void 0===r||r.delete(t),O(S,o),null===(a=this._decorationDataPromises.get(e))||void 0===a||a.delete(t),t===s.IDecorationType.EXTRA_LARGE)null===(i=null===(n=M(F))||void 0===n?void 0:n.get(e))||void 0===i||i.delete(t),this._clearFrameData(e);this._updateLinkId(e)},this._getLinkWithId=e=>{var t,r,a,n;try{const i=new URL(e),o=null===(t=this._localStorage.getItem(E))||void 0===t?void 0:t[e];if("string"==typeof o)null===(a=null===(r=null==i?void 0:i.searchParams)||void 0===r?void 0:r.set)||void 0===a||a.call(r,E,o);return null!==(n=null==i?void 0:i.href)&&void 0!==n?n:e}catch(t){return e}},this._getLinkWithAnchor=e=>{try{if(!(0,i.isAnchorLink)(e))return e;const t=(0,i.isCurrentAnchorLink)(e),r=new URL(e);return r.searchParams.set("isCurrentDocument",String(t)),r.href}catch(t){return e}},this._updateLinkId=e=>{this._setLocalData(e,l.Guid.create(),E,20)},this._setLocalData=(e,t,r,a)=>{var n,i;try{const o=null!==(n=this._localStorage.getItem(r))&&void 0!==n?n:{};o[e]=t;const s=null!==(i=Object.keys(o))&&void 0!==i?i:[];if(s.length>a){const[e]=s;delete o[e]}this._localStorage.setItem(r,o)}catch(e){this._localStorage.removeItem(r)}},this._convertDecorationData=(e,t)=>{var r,a;
1if(!e||e.version===s.IDecorationVersion.NEW){if(e.view&&(!e.view.type||e.view.type!==t))e.view.type=t;return e}const{details:n,secondDetails:i}=null!==(r=e.linkInfo)&&void 0!==r?r:{},o={...e.title?{title:e.title}:{},...e.logo?{icon:e.logo}:{},...n?{subtitle:n}:{},...i?{headerDetails:i}:{},...null!==(a=e.linkInfo)&&void 0!==a?a:{},type:t},l={version:s.IDecorationVersion.NEW,view:o,...e.cardInfo?{action:e.cardInfo}:{},...o.hoverButtons?{hoverButtons:o.hoverButtons}:{}};return delete o.details,delete o.secondDetails,delete o.hoverButtons,l},h.constants.isBrowserPlatform)window.cachedMethods=window.cachedMethods||[],window.cachedMethods.push("LinkDecorator.Decorate");this._localStorage=new D.LocalStorage}loadDecorationData({link:e,type:t,decorationDataFromProps:r}){if(h.constants.isServerSide)return Promise.resolve();if(!W._checkDecorationProps(e,t))return Promise.resolve((0,a.getErrorDecorationData)(e,t));else return new Promise(((n,i)=>{const o=setTimeout((()=>{n((0,a.getErrorDecorationData)(e,t))}),25e3),s=new l.Record({adapter:"adapter.sbis",format:[{name:"link",type:"string"},{name:"type",type:"string"},{name:"new_decorate",type:"boolean"}]});let u=this._getLinkWithId(e);u=this._getLinkWithAnchor(e),s.set({link:u,type:t,new_decorate:!0}),this.sbisService.call("Decorate",{Params:s}).then((i=>{var o,s,l,u;const d=i.getRawData();if(!Object.keys(d).length){const r=(0,a.getErrorDecorationData)(e,t);return void n(r)}const h=this._convertDecorationData(d,t),m=[null===(o=null==h?void 0:h.view)||void 0===o?void 0:o.contentTemplateName,null===(s=null==h?void 0:h.view)||void 0===s?void 0:s.detailsTemplateName,null===(l=null==h?void 0:h.view)||void 0===l?void 0:l.secondDetailsTemplateName,null===(u=null==h?void 0:h.view)||void 0===u?void 0:u.thirdDetail
1sTemplateName,null==r?void 0:r.contentTemplateName,null==r?void 0:r.detailsTemplateName,null==r?void 0:r.secondDetailsTemplateName,null==r?void 0:r.thirdDetailsTemplateName];if(this.isPrivateLink(t,h))this._setPrivateLinkData(e,h);Promise.all(m.map((e=>e&&(0,c.loadAsync)(e)))).then((()=>n(h))).catch((()=>{var e;null===(e=null==h?void 0:h.view)||void 0===e||delete e.contentTemplateName,n(h)}))})).catch((e=>{d.Logger.warn("Сервис декорированных ссылок недоступен: "+e),i(e)})).finally((()=>{clearTimeout(o)}))}))}getStaticInfo({link:e}){if(!e){const e=new l.Model({format:{SizeTypes:{type:"string"},ClickController:{type:"string"},ClickControllerOption:{type:"string"},PreRenderController:{type:"string"}},adapter:"adapter.sbis"});return e.set({SizeTypes:[],ClickController:null,ClickControllerOption:null,PreRenderController:null}),e}q(R);const t=M(R).get(e);if(t)return t;else return this._getLinkStaticInfo(e).then((t=>{const r=M(R);return r.set(e,t),O(R,r),t})).catch((()=>{const e=new l.Record({adapter:"adapter.sbis",format:[{name:"SizeTypes",type:"array",kind:"string"},{name:"ClickController",type:"string"},{name:"ClickControllerOption",type:"string"},{name:"PreRenderController",type:"string"}]});return e.set({SizeTypes:[s.IDecorationType.HYPERLINK],ClickController:"",ClickControllerOption:"",PreRenderController:""}),e}))}getCachedDecorationData(e,t){var r;q(S);const a=null===(r=M(S).get(e))||void 0===r?void 0:r.get(t);return a?this._convertDecorationData(a,t):void 0}loadStaticInfo(e){const t=this._linkStaticInfoPromises.get(e);if(t)return t;const r=new l.Record({adapter:"adapter.sbis",format:[{name:"Link",type:"string"},{name:"new_decorate",type:"boolean"}]});r.set({Link:e,new_decorate:!0});const a=this.sbisService.call("GetStaticInfo",{Params:r}).then((async e=>{const t=null==e?void 0:e.getRow(),r=null==t?void 0:t.get("PreRenderController");if(r){if(((0,c.isLoaded)(r)?Promise.resolve(!0):await(0,c.loadAsync)(r))&&h.constants.isServerSide)(0,v.addPageDeps)([r])}return t})).catch((t=>(this._linkStaticInfoPromises.delete(e),d.Logger.warn("Сервис декорированных ссылок недоступен: "+t),Promise.reject(t))));return this._linkStaticInfoPromises.set(e,a),a}loadTypes(e){const t=this.getStaticInfo({link:e});if(t instanceof Promise)return t.then((e=>(null==e?void 0:e.get("SizeTypes"))||[]));else{return(null==t?void 0:t.get("SizeTypes"))||[]}}getDecorationData({link:e,type:t,decorationDataFromProps:r,frameDataLoaded:n,skipFrameData:i}){var o;const l=t===s.IDecorationType.EXTRA_LARGE&&!i;if(l&&n&&n.href===e)return this._setFrameData(e,n),(0,L.maybePromise)((0,g.buildFrameDecorationData)(n),(r=>this._cacheDecorationData(e,t,r)));if(h.constants.isServerSide)return Promise.resolve();if(!W._checkDecorationProps(e,t))return(0,a.getErrorDecorationData)(e,t);const c=this._getPrivateLinkData(e);if(t===s.IDecorationType.SMALL&&c)return c;const u=((e,t)=>e===s.IDecorationType.EXTRA_LARGE&&t?F:S)(t,i);q(u);const d=null===(o=M(u).get(e))||void 0===o?void 0:o.get(t);if(d)return this._markFrameDataFailed(e,this._convertDecorationData(d,t),l);if(l)return(0,L.maybePromise)(this.getFrameData(e),(a=>{if(!a)return this._getDecorationDataFromService(e,t,r,u).then((t=>this._markFrameDataFailed(e,t,l)));else return(0,L.maybePromise)((0,g.buildFrameDecorationData)(a),(r=>this._cacheDecorationData(e,t,r)))}));else return this._getDecorationDataFromService(e,t,r,u)}_markFrameDataFailed(e,t,r){if(!r||!t||t.frameContent||!this.isFrameDataFailed(e))return t;else return{...t,frameDataFailed:!0}}_getDecorationDataFromService(e,t,r,n){return this._getDecorationDataPromise(e,t,r).then((r=>this._cacheDecorationData(e,t,r,n))).catch((()=>(0,a.getErrorDecorationData)(e,t))).finally((()=>{f.default.dequeue()}))}_cacheDecorationData(e,t,r,a=S){q(a);let n=M(a);if(!n.has(e))n=n.set(e,new Map);return n.get(e).set(t,r),O(a,n),r}getFrameData(e){var t;const r=X();if(r.has(e))return null!==(t=r.get(e))&&void 0!==t?t:null;if(!u.ModulesManager.isModule(a.FRAME_DATA_PROVIDER))return null;const n=this._frameDataPromises.get(e);if(n)return n;if(!(0,k.isXlFragmentEnabled)())return null;const i=this._loadFrameData(e).finally((()=>{this._frameDataPromises.delete(e)}));return this._frameDataPromises.set(e,i),i}_loadFrameData(e){return z(U()+1),(0,c.loadAsync)(a.FRAME_DATA_PROVIDER).then((t=>t.load(e))).then((t=>{if(G().delete(e),this._setFrameData(e,t),t&&h.constants.isServerSide)(0,v.addPageDeps)([t.contentTemplateName]);return t})).catch((t=>
1(d.Logger.warn(`Не удалось загрузить документ для ссылки ${e}: ${t}`),G().add(e),null))).finally((()=>{z(U()-1)}))}isLoadingFrameData(){return U()>0}getCachedFrameData(e){return X().get(e)}subscribeFrameData(e){return this._frameDataListeners.add(e),()=>{this._frameDataListeners.delete(e)}}_notifyFrameData(){if(!this._frameDataNotificationScheduled)this._frameDataNotificationScheduled=!0,Promise.resolve().then((()=>{this._frameDataNotificationScheduled=!1,this._frameDataListeners.forEach((e=>{try{e()}catch(e){d.Logger.error("LinkDecorator: слушатель кэша документов завершился ошибкой",null,e)}}))}))}_setFrameData(e,t){X().set(e,t),this._notifyFrameData()}_clearFrameData(e){X().delete(e),G().delete(e),this._frameDataPromises.delete(e),this._notifyFrameData()}isFrameDataFailed(e){return G().has(e)}getTypes({link:e}){if(!e)return[];q(I);const t=M(I).get(e);if(t)return t;const r=this.loadTypes(e);if(r instanceof Promise)return r.then((t=>this._processSupportedSizeTypes(e,t))).catch((()=>[s.IDecorationType.HYPERLINK]));else return this._processSupportedSizeTypes(e,r)}_processSupportedSizeTypes(e,t){if(!t.includes(s.IDecorationType.HYPERLINK))t.unshift(s.IDecorationType.HYPERLINK);const r=M(I);return r.set(e,t),O(I,r),t}invalidate(e,t){if(!W._checkDecorationProps(e,t))return;const r=new l.Record({adapter:"adapter.sbis",format:[{name:"link",type:"string"},{name:"typesLink",type:"array",kind:"string"}]});r.set({link:e,typesLink:s.nonTextDecorationTypes}),this.sbisService.call("Invalidate",{Params:r}).then((()=>{this._clearDecorationCache(e,t),this._notify("decorationDataChanged",e,t)}))}getLinkHeight(e){var t;return null===(t=this._localStorage.getItem(w))||void 0===t?void 0:t[e]}setLinkHeight(e,t){this._setLocalData(e,t,w,1e4)}_getPrivateLinkData(e){var t;return null===(t=this._localStorage.getItem(b))||void 0===t?void 0:t[e]}_setPrivateLinkData(e,t){this._setLocalData(e,t,b,100)}}W._checkDecorationProps=(e,t)=>"string"==typeof e&&Boolean(e)&&s.nonTextDecorationTypes.includes(t);const j=new W;return a.default=j,a}));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.