Module 760751

7,071 characters · in no known chunk
Dependencies
Source Raw
function(e,t,n){"use strict";let i;n.d(t,{A:()=>j}),n(321073);var r=n(17928),s=n(506774),a=n(228366),o=n(155718),l=n(194862),u=n(223273),c=n(885386),d=n(395671),_=n(174459),h=n(927813),f=n(403362),E=n(723702),p=n(935208),m=n(652215),g=n(705751);let A="GameStoreReportedGames",I=h.A.Millis.DAY,T=new l.A,S=Object.create(null),N=Object.create(null),C=s.w.get(A)??Object.create(null),y="",O=null,R=!1,v=null,b=!1,L="",D=[],w=[],P=new Map,M=h.A.Millis.HOUR,x=new Set,U=new Set,k=(0,E.isWindows)()?"win32":(0,E.isMac)()?"darwin":(0,E.isLinux)()?"linux":null;function G(e){return{id:e.id,name:e.name,executables:e.executables,overlayWarn:e.overlayWarn,overlayCompatibilityHook:e.overlayCompatibilityHook,overlay:e.overlay,hook:e.hook,aliases:e.aliases,supportsOutOfProcessOverlay:e.supportsOutOfProcessOverlay,themes:e.themes??[],icon:e.icon,thirdPartySkus:e.thirdPartySkus??[],cover_image_hash:e.cover_image_hash??void 0,content_classification:e.content_classification??void 0}}function V(e){return e.split(/[/\\]/).pop()}function F(e,t){null==S[t]&&(S[t]=[]),S[t].push(e)}function B(e){let t=e instanceof u.xg?G(e):e;for(let n of(T.set(e.id,t),F(t.id,t.name.toLowerCase()),e.aliases))F(t.id,n.toLowerCase());if((0,E.isDesktop)())for(let n of e.executables)N[n.name]=t.id}class H extends r.Ay.PersistedStore{static displayName="GameStore";static persistKey="GameStore";static migrations=[e=>null!=e?{detectableGamesEtag:e.detectableGamesEtag,detectableGames:e.detectableGames?.map(e=>G(new u.xg(e)))??[]}:{detectableGamesEtag:"",detectableGames:[]},e=>(0,E.isDesktop)()?e:{detectableGamesEtag:"",detectableGames:[]},()=>({detectableGamesEtag:"",detectableGames:[]}),e=>({...e,blocklistEtag:e.blocklistEtag??"",blocklistExecutables:e.blocklistExecutables??[],blocklistPatterns:e.blocklistPatterns??[]})];initialize(e){null!=e&&(null!=e.detectableGamesEtag&&(y=e.detectableGamesEtag),null!=e.blocklistEtag&&(L=e.blocklistEtag),null!=e.blocklistExecutables&&(D=e.blocklistExecutables),null!=e.blocklistPatterns&&(w=e.blocklistPatterns.map(e=>RegExp(e,"i"))),e.detectableGames?.forEach(e=>B(e)))}getState(){return(0,E.isDesktop)()?{detectableGamesEtag:y,detectableGames:T.values(),blocklistEtag:L,blocklistExecutables:D,blocklistPatterns:w.map(e=>e.source)}:{detectableGamesEtag:"",detectableGames:[],blocklistEtag:"",blocklistExecutables:[],blocklistPatterns:[]}}get games(){return T.values()}getDetectableGame(e){return T.get(p.default.cast(e))}searchGamesByName(e){if(null==e)return[];let t=e.toLowerCase();return Object.prototype.hasOwnProperty.call(S,t)?S[t]:[]}findGame(e,t){let n,i=this.getDetectableGame(e.id);if(null!=i)return i;if(null!=e.name)for(let i of this.searchGamesByName(e.name)){let r=this.getDetectableGame(i);if(null!=r){if(null!=t){t(r);continue}if(null!=e.exePath&&null!=r.executables){let t=e.exePath.split("/").filter(f.Vq).pop();if(r.executables.some(e=>e.name===t))return r}n=r}}if(null!=e.exePath){let t=e.exePath.split("/").filter(f.Vq).pop(),n=this.getGameByExecutable(t);if(null!=n)return n;let i=e.exePath.split("/").filter(f.Vq).slice(-2).join("/"),r=this.getGameByExecutable(i);if(null!=r)return r}return null!=n&&null!=e.name&&this.trackNameMatchFallback(e.name,n,e.exePath),n}getOfficialGame(e){let t;return null==e||null==(t=e.type===g.S7.GAME?e.id:e.linkedGames?.find(e=>e.type===o.Mh.OFFICIAL)?.id)?null:this.getDetectableGame(t)}getGameByApplication(e){let t,n=this.getDetectableGame(e.id);if(null!=n)return n;let i="none";if(null!=e.linkedGames)for(let n of e.linkedGames){let e=this.getDetectableGame(n.id);if(null!=e){i="linked_game",t=e;break}}if(null==t){let n=this.searchGamesByName(e.name).map(e=>this.getDetectableGame(e)).reverse()[0];null!=n&&(i="name",t=n)}return this.maybeTrackApplicationLookupFallthrough(e,i,t),t}isGameInDatabase(e){return null!=this.findGame(e)||void 0!==e.nativeProcessObserverId&&(0x80000000&e.nativeProcessObserverId)==0}get fetching(){return!0===i}get detectableGamesEtag(){return y}get blocklistEtag(){return L}get lastFetched(){return O}get hasAttemptedFetch(){return R}get detectableGamesTtl(){return I}canFetchDetectableGames(){return!0!==i&&(null==O||Date.now()>=O+I)}canFetchExecutableBlocklist(){return!b&&(null==v||Date.now()>=v+I)}getGameByExecutable(e){if(null==e)return;let t=N[e];return this.getDetectableGame(t)}shouldBlock(e){if(null==e.exePath||""===e.exePath)return!1;let t=e.exePath.toLowerCase();if(null!=e.id&&null!=k){let n=this.getDetectableGame(e.id);if(null!=n&&n.executables.some(e=>e.os===k&&t.endsWith(e.name.toLowerCase())))return!1}let n=D.find(e=>t.includes(e));if(null!=n)return this.maybeTrackBlock(e,"explicit_list",n),!0;let i=w.find(t=>t.test(e.exePath));return null!=i&&(this.maybeTrackBlock(e,"pattern_match",i.source),!0)}getBlockReason(e){if(null==e.exePath||""===e.exePath)return null;let t=e.exePath.toLowerCase(),n=D.find(e=>t.includes(e));if(null!=n)return{matchedExe:n,matchedPattern:null};let i=w.find(t=>t.test(e.exePath));return null!=i?{matchedExe:null,matchedPattern:i.source}:null}maybeTrackApplicationLookupFallthrough(e,t,n){let i=e.id;x.has(i)||(x.add(i),_.default.track(m.HAw.GAME_APPLICATION_LOOKUP_FALLTHROUGH,{application_id:i,application_name:e.name??null,match_type:t,matched_game_id:n?.id??null,matched_game_name:n?.name??null}))}trackNameMatchFallback(e,t,n){let i=e.toLowerCase();if(U.has(i))return;U.add(i);let r=null!=n&&""!==n;_.default.track(m.HAw.GAME_NAME_MATCH_FALLBACK,{matched_name:e,matched_game_id:t.id,exe_name:r?V(n)??null:null,had_exe_path:r})}maybeTrackBlock(e,t,n){let i=V(e.exePath)??"unknown",r=P.get(i),s=Date.now();(null==r||s-r>=M)&&(P.set(i,s),_.default.track(m.HAw.GAME_BLOCKLIST_TRIGGERED,{block_type:t,matched_entry:n,game_name:e.gameName??e.origGameName,executable_name:i}))}shouldReport(e){if(this.shouldBlock(e))return!1;let t=null!=this.findGame(e),n=null!=e.name&&null!=C[e.name];return c.tz.getSetting()&&!i&&!(t||n)}markGameReported(e){C[e]=!0,s.w.set(A,C)}}let j=new H(a.h,{OVERLAY_INITIALIZE:function(e){let{detectableApplications:t}=e;for(let e of(T.clear(),S=Object.create(null),N=Object.create(null),t))B(e)},GAMES_DATABASE_FETCH:function(){i=!0},GAMES_DATABASE_FETCH_FAIL:function(){i=!1,R=!0},GAMES_DATABASE_UPDATE:function(e){let{games:t,etag:n}=e;for(let e of(null!=n&&y!==n&&(T.clear(),S=Object.create(null),N=Object.create(null),y=n),t))B({id:e.id,name:e.name,executables:(e.executables??[]).map(d.lg),overlay:e.overlay??!1,overlayWarn:e.overlay_warn??!1,overlayCompatibilityHook:e.overlay_compatibility_hook??!1,hook:e.hook??!0,aliases:e.aliases??[],supportsOutOfProcessOverlay:d.Ay.supportsOutOfProcessOverlay(e.overlay_methods),themes:e.themes??[],icon:e.icon_hash??void 0,thirdPartySkus:e.third_party_skus??[],cover_image_hash:e.cover_image_hash??void 0,content_classification:e.content_classification??void 0});i=void 0,O=Date.now(),R=!0},GAMES_BLOCKLIST_FETCH:function(){b=!0},GAMES_BLOCKLIST_FETCH_FAIL:function(){b=!1},GAMES_BLOCKLIST_UPDATE:function(e){let{executables:t,patterns:n,etag:i}=e;null!=i&&L!==i&&(L=i,D=t.map(e=>e.toLowerCase()),w=n.map(e=>RegExp(e,"i"))),b=!1,v=Date.now()}})}