UNPKG

@yuebai008/cli

Version:

Command line interface for rapid qg-minigame development

1 lines 22.8 kB
import*as i18n from"../../../../core/i18n/i18n.js";import{assertNotNullOrUndefined}from"../../../../core/platform/platform.js";import*as SDK from"../../../../core/sdk/sdk.js";import*as Bindings from"../../../../models/bindings/bindings.js";const UIStrings={PrefetchFailedIneligibleRedirect:"The prefetch was redirected, but the redirect URL is not eligible for prefetch.",PrefetchFailedInvalidRedirect:"The prefetch was redirected, but there was a problem with the redirect.",PrefetchFailedMIMENotSupported:"The prefetch failed because the response's Content-Type header was not supported.",PrefetchFailedNetError:"The prefetch failed because of a network error.",PrefetchFailedNon2XX:"The prefetch failed because of a non-2xx HTTP response status code.",PrefetchFailedPerPageLimitExceeded:"The prefetch was not performed because the initiating page already has too many prefetches ongoing.",PrefetchIneligibleRetryAfter:"A previous prefetch to the origin got a HTTP 503 response with an Retry-After header that has not elapsed yet.",PrefetchIsPrivacyDecoy:"The URL was not eligible to be prefetched because there was a registered service worker or cross-site cookies for that origin, but the prefetch was put on the network anyways and not used, to disguise that the user had some kind of previous relationship with the origin.",PrefetchIsStale:"Too much time elapsed between the prefetch and usage, so the prefetch was discarded.",PrefetchNotEligibleBrowserContextOffTheRecord:"The prefetch was not performed because the browser is in Incognito or Guest mode.",PrefetchNotEligibleDataSaverEnabled:"The prefetch was not performed because the operating system is in Data Saver mode.",PrefetchNotEligibleExistingProxy:"The URL is not eligible to be prefetched, because in the default network context it is configured to use a proxy server.",PrefetchNotEligibleHostIsNonUnique:"The URL was not eligible to be prefetched because its host was not unique (e.g., a non publicly routable IP address or a hostname which is not registry-controlled), but the prefetch was required to be proxied.",PrefetchNotEligibleNonDefaultStoragePartition:"The URL was not eligible to be prefetched because it uses a non-default storage partition.",PrefetchNotEligibleSameSiteCrossOriginPrefetchRequiredProxy:"The URL was not eligible to be prefetched because the default network context cannot be configured to use the prefetch proxy for a same-site cross-origin prefetch request.",PrefetchNotEligibleSchemeIsNotHttps:"The URL was not eligible to be prefetched because its scheme was not https:.",PrefetchNotEligibleUserHasCookies:"The URL was not eligible to be prefetched because it was cross-site, but the user had cookies for that origin.",PrefetchNotEligibleUserHasServiceWorker:"The URL was not eligible to be prefetched because there was a registered service worker for that origin, which is currently not supported.",PrefetchNotUsedCookiesChanged:"The prefetch was not used because it was a cross-site prefetch, and cookies were added for that URL while the prefetch was ongoing, so the prefetched response is now out-of-date.",PrefetchProxyNotAvailable:"A network error was encountered when trying to set up a connection to the prefetching proxy.",PrefetchNotUsedProbeFailed:"The prefetch was blocked by your Internet Service Provider or network administrator.",PrefetchEvicted:"The prefetch was discarded for a newer prefetch because |kPrefetchNewLimits| is enabled",PrefetchNotEligibleBatterySaverEnabled:"The prefetch was not performed because the Battery Saver setting was enabled.",PrefetchNotEligiblePreloadingDisabled:"The prefetch was not performed because preloading was disabled.",prerenderFinalStatusLowEndDevice:"The prerender was not performed because this device does not have enough total system memory to support prerendering.",prerenderFinalStatusInvalidSchemeRedirect:"The prerendering navigation failed because it redirected to a URL whose scheme was not http: or https:.",prerenderFinalStatusInvalidSchemeNavigation:"The URL was not eligible to be prerendered because its scheme was not http: or https:.",prerenderFinalStatusNavigationRequestBlockedByCsp:"The prerendering navigation was blocked by a Content Security Policy.",prerenderFinalStatusMainFrameNavigation:"The prerendered page navigated itself to another URL, which is currently not supported.",prerenderFinalStatusMojoBinderPolicy:"The prerendered page used a forbidden JavaScript API that is currently not supported. (Internal Mojo interface: {PH1})",prerenderFinalStatusRendererProcessCrashed:"The prerendered page crashed.",prerenderFinalStatusRendererProcessKilled:"The prerendered page was killed.",prerenderFinalStatusDownload:"The prerendered page attempted to initiate a download, which is currently not supported.",prerenderFinalStatusNavigationBadHttpStatus:"The prerendering navigation failed because of a non-2xx HTTP response status code.",prerenderFinalStatusClientCertRequested:"The prerendering navigation required a HTTP client certificate.",prerenderFinalStatusNavigationRequestNetworkError:"The prerendering navigation encountered a network error.",prerenderFinalStatusMaxNumOfRunningPrerendersExceeded:"The prerender was not performed because the initiating page already has too many prerenders ongoing. Remove other speculation rules to enable further prerendering.",prerenderFinalStatusSslCertificateError:"The prerendering navigation failed because of an invalid SSL certificate.",prerenderFinalStatusLoginAuthRequested:"The prerendering navigation required HTTP authentication, which is currently not supported.",prerenderFinalStatusUaChangeRequiresReload:"Changing User Agent occured in prerendering navigation.",prerenderFinalStatusBlockedByClient:"Some resource load was blocked.",prerenderFinalStatusAudioOutputDeviceRequested:"The prerendered page requested audio output, which is currently not supported.",prerenderFinalStatusMixedContent:"The prerendered page contained mixed content.",prerenderFinalStatusTriggerBackgrounded:"The initiating page was backgrounded, so the prerendered page was discarded.",prerenderFinalStatusMemoryLimitExceeded:"The prerender was not performed because the browser exceeded the prerendering memory limit.",prerenderFinalStatusFailToGetMemoryUsage:"The prerender was not performed because the browser encountered an internal error attempting to determine current memory usage.",prerenderFinalStatusDataSaverEnabled:"The prerender was not performed because the user requested that the browser use less data.",prerenderFinalStatusHasEffectiveUrl:"The initiating page cannot perform prerendering, because it has an effective URL that is different from its normal URL. (For example, the New Tab Page, or hosted apps.)",prerenderFinalStatusTimeoutBackgrounded:"The initiating page was backgrounded for a long time, so the prerendered page was discarded.",prerenderFinalStatusCrossSiteRedirectInInitialNavigation:"The prerendering navigation failed because the prerendered URL redirected to a cross-site URL.",prerenderFinalStatusCrossSiteNavigationInInitialNavigation:"The prerendering navigation failed because it targeted a cross-site URL.",prerenderFinalStatusSameSiteCrossOriginRedirectNotOptInInInitialNavigation:"The prerendering navigation failed because the prerendered URL redirected to a cross-origin same-site URL, but the destination response did not include the appropriate Supports-Loading-Mode header.",prerenderFinalStatusSameSiteCrossOriginNavigationNotOptInInInitialNavigation:"The prerendering navigation failed because it was to a cross-origin same-site URL, but the destination response did not include the appropriate Supports-Loading-Mode header.",prerenderFinalStatusActivationNavigationParameterMismatch:"The prerender was not used because during activation time, different navigation parameters (e.g., HTTP headers) were calculated than during the original prerendering navigation request.",prerenderFinalStatusPrimaryMainFrameRendererProcessCrashed:"The initiating page crashed.",prerenderFinalStatusPrimaryMainFrameRendererProcessKilled:"The initiating page was killed.",prerenderFinalStatusActivationFramePolicyNotCompatible:"The prerender was not used because the sandboxing flags or permissions policy of the initiating page was not compatible with those of the prerendering page.",prerenderFinalStatusPreloadingDisabled:"The prerender was not performed because the user disabled preloading in their browser settings.",prerenderFinalStatusBatterySaverEnabled:"The prerender was not performed because the user requested that the browser use less battery.",prerenderFinalStatusActivatedDuringMainFrameNavigation:"Prerendered page activated during initiating page's main frame navigation.",prerenderFinalStatusCrossSiteRedirectInMainFrameNavigation:"The prerendered page navigated to a URL which redirected to a cross-site URL.",prerenderFinalStatusCrossSiteNavigationInMainFrameNavigation:"The prerendered page navigated to a cross-site URL.",prerenderFinalStatusSameSiteCrossOriginRedirectNotOptInInMainFrameNavigation:"The prerendered page navigated to a URL which redirected to a cross-origin same-site URL, but the destination response did not include the appropriate Supports-Loading-Mode header.",prerenderFinalStatusSameSiteCrossOriginNavigationNotOptInInMainFrameNavigation:"The prerendered page navigated to a cross-origin same-site URL, but the destination response did not include the appropriate Supports-Loading-Mode header.",prerenderFinalStatusMemoryPressureOnTrigger:"The prerender was not performed because the browser was under critical memory pressure.",prerenderFinalStatusMemoryPressureAfterTriggered:"The prerendered page was unloaded because the browser came under critical memory pressure.",prerenderFinalStatusPrerenderingDisabledByDevTools:"The prerender was not performed because DevTools has been used to disable prerendering.",prerenderFinalStatusResourceLoadBlockedByClient:"Some resource load was blocked.",prerenderFinalStatusSpeculationRuleRemoved:"Unknown",statusNotTriggered:"Not triggered",statusPending:"Pending",statusRunning:"Running",statusReady:"Ready",statusSuccess:"Success",statusFailure:"Failure"},str_=i18n.i18n.registerUIStrings("panels/application/preloading/components/PreloadingString.ts",UIStrings),i18nLazyString=i18n.i18n.getLazilyComputedLocalizedString.bind(void 0,str_),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_);export const PrefetchReasonDescription={PrefetchFailedIneligibleRedirect:{name:i18nLazyString(UIStrings.PrefetchFailedIneligibleRedirect)},PrefetchFailedInvalidRedirect:{name:i18nLazyString(UIStrings.PrefetchFailedInvalidRedirect)},PrefetchFailedMIMENotSupported:{name:i18nLazyString(UIStrings.PrefetchFailedMIMENotSupported)},PrefetchFailedNetError:{name:i18nLazyString(UIStrings.PrefetchFailedNetError)},PrefetchFailedNon2XX:{name:i18nLazyString(UIStrings.PrefetchFailedNon2XX)},PrefetchFailedPerPageLimitExceeded:{name:i18nLazyString(UIStrings.PrefetchFailedPerPageLimitExceeded)},PrefetchIneligibleRetryAfter:{name:i18nLazyString(UIStrings.PrefetchIneligibleRetryAfter)},PrefetchIsPrivacyDecoy:{name:i18nLazyString(UIStrings.PrefetchIsPrivacyDecoy)},PrefetchIsStale:{name:i18nLazyString(UIStrings.PrefetchIsStale)},PrefetchNotEligibleBrowserContextOffTheRecord:{name:i18nLazyString(UIStrings.PrefetchNotEligibleBrowserContextOffTheRecord)},PrefetchNotEligibleDataSaverEnabled:{name:i18nLazyString(UIStrings.PrefetchNotEligibleDataSaverEnabled)},PrefetchNotEligibleExistingProxy:{name:i18nLazyString(UIStrings.PrefetchNotEligibleExistingProxy)},PrefetchNotEligibleHostIsNonUnique:{name:i18nLazyString(UIStrings.PrefetchNotEligibleHostIsNonUnique)},PrefetchNotEligibleNonDefaultStoragePartition:{name:i18nLazyString(UIStrings.PrefetchNotEligibleNonDefaultStoragePartition)},PrefetchNotEligibleSameSiteCrossOriginPrefetchRequiredProxy:{name:i18nLazyString(UIStrings.PrefetchNotEligibleSameSiteCrossOriginPrefetchRequiredProxy)},PrefetchNotEligibleSchemeIsNotHttps:{name:i18nLazyString(UIStrings.PrefetchNotEligibleSchemeIsNotHttps)},PrefetchNotEligibleUserHasCookies:{name:i18nLazyString(UIStrings.PrefetchNotEligibleUserHasCookies)},PrefetchNotEligibleUserHasServiceWorker:{name:i18nLazyString(UIStrings.PrefetchNotEligibleUserHasServiceWorker)},PrefetchNotUsedCookiesChanged:{name:i18nLazyString(UIStrings.PrefetchNotUsedCookiesChanged)},PrefetchProxyNotAvailable:{name:i18nLazyString(UIStrings.PrefetchProxyNotAvailable)},PrefetchNotUsedProbeFailed:{name:i18nLazyString(UIStrings.PrefetchNotUsedProbeFailed)},PrefetchEvicted:{name:i18nLazyString(UIStrings.PrefetchEvicted)},PrefetchNotEligibleBatterySaverEnabled:{name:i18nLazyString(UIStrings.PrefetchNotEligibleBatterySaverEnabled)},PrefetchNotEligiblePreloadingDisabled:{name:i18nLazyString(UIStrings.PrefetchNotEligiblePreloadingDisabled)}};export function prefetchFailureReason({prefetchStatus:e}){switch(e){case null:case"PrefetchNotStarted":case"PrefetchNotFinishedInTime":case"PrefetchResponseUsed":case"PrefetchAllowed":case"PrefetchHeldback":case"PrefetchSuccessfulButNotUsed":return null;case"PrefetchFailedIneligibleRedirect":return PrefetchReasonDescription.PrefetchFailedIneligibleRedirect.name();case"PrefetchFailedInvalidRedirect":return PrefetchReasonDescription.PrefetchFailedInvalidRedirect.name();case"PrefetchFailedMIMENotSupported":return PrefetchReasonDescription.PrefetchFailedMIMENotSupported.name();case"PrefetchFailedNetError":return PrefetchReasonDescription.PrefetchFailedNetError.name();case"PrefetchFailedNon2XX":return PrefetchReasonDescription.PrefetchFailedNon2XX.name();case"PrefetchFailedPerPageLimitExceeded":return PrefetchReasonDescription.PrefetchFailedPerPageLimitExceeded.name();case"PrefetchIneligibleRetryAfter":return PrefetchReasonDescription.PrefetchIneligibleRetryAfter.name();case"PrefetchEvicted":return PrefetchReasonDescription.PrefetchEvicted.name();case"PrefetchIsPrivacyDecoy":return PrefetchReasonDescription.PrefetchIsPrivacyDecoy.name();case"PrefetchIsStale":return PrefetchReasonDescription.PrefetchIsStale.name();case"PrefetchNotEligibleBrowserContextOffTheRecord":return PrefetchReasonDescription.PrefetchNotEligibleBrowserContextOffTheRecord.name();case"PrefetchNotEligibleDataSaverEnabled":return PrefetchReasonDescription.PrefetchNotEligibleDataSaverEnabled.name();case"PrefetchNotEligibleExistingProxy":return PrefetchReasonDescription.PrefetchNotEligibleExistingProxy.name();case"PrefetchNotEligibleHostIsNonUnique":return PrefetchReasonDescription.PrefetchNotEligibleHostIsNonUnique.name();case"PrefetchNotEligibleNonDefaultStoragePartition":return PrefetchReasonDescription.PrefetchNotEligibleNonDefaultStoragePartition.name();case"PrefetchNotEligibleSameSiteCrossOriginPrefetchRequiredProxy":return PrefetchReasonDescription.PrefetchNotEligibleSameSiteCrossOriginPrefetchRequiredProxy.name();case"PrefetchNotEligibleSchemeIsNotHttps":return PrefetchReasonDescription.PrefetchNotEligibleSchemeIsNotHttps.name();case"PrefetchNotEligibleUserHasCookies":return PrefetchReasonDescription.PrefetchNotEligibleUserHasCookies.name();case"PrefetchNotEligibleUserHasServiceWorker":return PrefetchReasonDescription.PrefetchNotEligibleUserHasServiceWorker.name();case"PrefetchNotUsedCookiesChanged":return PrefetchReasonDescription.PrefetchNotUsedCookiesChanged.name();case"PrefetchProxyNotAvailable":return PrefetchReasonDescription.PrefetchProxyNotAvailable.name();case"PrefetchNotUsedProbeFailed":return PrefetchReasonDescription.PrefetchNotUsedProbeFailed.name();case"PrefetchNotEligibleBatterySaverEnabled":return PrefetchReasonDescription.PrefetchNotEligibleBatterySaverEnabled.name();case"PrefetchNotEligiblePreloadingDisabled":return PrefetchReasonDescription.PrefetchNotEligiblePreloadingDisabled.name();default:return i18n.i18n.lockedString(`Unknown failure reason: ${e}`)}}export function prerenderFailureReason(e){switch(e.prerenderStatus){case null:case"Activated":return null;case"Destroyed":case"DidFailLoad":case"Stop":case"ActivatedWithAuxiliaryBrowsingContexts":return i18n.i18n.lockedString("Unknown");case"LowEndDevice":return i18nString(UIStrings.prerenderFinalStatusLowEndDevice);case"InvalidSchemeRedirect":return i18nString(UIStrings.prerenderFinalStatusInvalidSchemeRedirect);case"InvalidSchemeNavigation":return i18nString(UIStrings.prerenderFinalStatusInvalidSchemeNavigation);case"InProgressNavigation":case"TriggerDestroyed":case"NavigationNotCommitted":case"ActivatedBeforeStarted":case"InactivePageRestriction":case"StartFailed":case"ActivatedInBackground":case"ActivationNavigationDestroyedBeforeSuccess":return i18n.i18n.lockedString("Internal error");case"NavigationRequestBlockedByCsp":return i18nString(UIStrings.prerenderFinalStatusNavigationRequestBlockedByCsp);case"MainFrameNavigation":return i18nString(UIStrings.prerenderFinalStatusMainFrameNavigation);case"MojoBinderPolicy":return assertNotNullOrUndefined(e.disallowedMojoInterface),i18nString(UIStrings.prerenderFinalStatusMojoBinderPolicy,{PH1:e.disallowedMojoInterface});case"RendererProcessCrashed":return i18nString(UIStrings.prerenderFinalStatusRendererProcessCrashed);case"RendererProcessKilled":return i18nString(UIStrings.prerenderFinalStatusRendererProcessKilled);case"Download":return i18nString(UIStrings.prerenderFinalStatusDownload);case"NavigationBadHttpStatus":return i18nString(UIStrings.prerenderFinalStatusNavigationBadHttpStatus);case"ClientCertRequested":return i18nString(UIStrings.prerenderFinalStatusClientCertRequested);case"NavigationRequestNetworkError":return i18nString(UIStrings.prerenderFinalStatusNavigationRequestNetworkError);case"MaxNumOfRunningPrerendersExceeded":return i18nString(UIStrings.prerenderFinalStatusMaxNumOfRunningPrerendersExceeded);case"CancelAllHostsForTesting":case"EmbedderHostDisallowed":case"TabClosedByUserGesture":case"TabClosedWithoutUserGesture":case"PreloadingUnsupportedByWebContents":throw new Error("unreachable");case"SslCertificateError":return i18nString(UIStrings.prerenderFinalStatusSslCertificateError);case"LoginAuthRequested":return i18nString(UIStrings.prerenderFinalStatusLoginAuthRequested);case"UaChangeRequiresReload":return i18nString(UIStrings.prerenderFinalStatusUaChangeRequiresReload);case"BlockedByClient":return i18nString(UIStrings.prerenderFinalStatusBlockedByClient);case"AudioOutputDeviceRequested":return i18nString(UIStrings.prerenderFinalStatusAudioOutputDeviceRequested);case"MixedContent":return i18nString(UIStrings.prerenderFinalStatusMixedContent);case"TriggerBackgrounded":return i18nString(UIStrings.prerenderFinalStatusTriggerBackgrounded);case"MemoryLimitExceeded":return i18nString(UIStrings.prerenderFinalStatusMemoryLimitExceeded);case"FailToGetMemoryUsage":return i18nString(UIStrings.prerenderFinalStatusFailToGetMemoryUsage);case"DataSaverEnabled":return i18nString(UIStrings.prerenderFinalStatusDataSaverEnabled);case"HasEffectiveUrl":return i18nString(UIStrings.prerenderFinalStatusHasEffectiveUrl);case"TimeoutBackgrounded":return i18nString(UIStrings.prerenderFinalStatusTimeoutBackgrounded);case"CrossSiteRedirectInInitialNavigation":return i18nString(UIStrings.prerenderFinalStatusCrossSiteRedirectInInitialNavigation);case"CrossSiteNavigationInInitialNavigation":return i18nString(UIStrings.prerenderFinalStatusCrossSiteNavigationInInitialNavigation);case"SameSiteCrossOriginRedirectNotOptInInInitialNavigation":return i18nString(UIStrings.prerenderFinalStatusSameSiteCrossOriginRedirectNotOptInInInitialNavigation);case"SameSiteCrossOriginNavigationNotOptInInInitialNavigation":return i18nString(UIStrings.prerenderFinalStatusSameSiteCrossOriginNavigationNotOptInInInitialNavigation);case"ActivationNavigationParameterMismatch":return i18nString(UIStrings.prerenderFinalStatusActivationNavigationParameterMismatch);case"PrimaryMainFrameRendererProcessCrashed":return i18nString(UIStrings.prerenderFinalStatusPrimaryMainFrameRendererProcessCrashed);case"PrimaryMainFrameRendererProcessKilled":return i18nString(UIStrings.prerenderFinalStatusPrimaryMainFrameRendererProcessKilled);case"ActivationFramePolicyNotCompatible":return i18nString(UIStrings.prerenderFinalStatusActivationFramePolicyNotCompatible);case"PreloadingDisabled":return i18nString(UIStrings.prerenderFinalStatusPreloadingDisabled);case"BatterySaverEnabled":return i18nString(UIStrings.prerenderFinalStatusBatterySaverEnabled);case"ActivatedDuringMainFrameNavigation":return i18nString(UIStrings.prerenderFinalStatusActivatedDuringMainFrameNavigation);case"CrossSiteRedirectInMainFrameNavigation":return i18nString(UIStrings.prerenderFinalStatusCrossSiteRedirectInMainFrameNavigation);case"CrossSiteNavigationInMainFrameNavigation":return i18nString(UIStrings.prerenderFinalStatusCrossSiteNavigationInMainFrameNavigation);case"SameSiteCrossOriginRedirectNotOptInInMainFrameNavigation":return i18nString(UIStrings.prerenderFinalStatusSameSiteCrossOriginRedirectNotOptInInMainFrameNavigation);case"SameSiteCrossOriginNavigationNotOptInInMainFrameNavigation":return i18nString(UIStrings.prerenderFinalStatusSameSiteCrossOriginNavigationNotOptInInMainFrameNavigation);case"MemoryPressureOnTrigger":return i18nString(UIStrings.prerenderFinalStatusMemoryPressureOnTrigger);case"MemoryPressureAfterTriggered":return i18nString(UIStrings.prerenderFinalStatusMemoryPressureAfterTriggered);case"PrerenderingDisabledByDevTools":return i18nString(UIStrings.prerenderFinalStatusPrerenderingDisabledByDevTools);case"ResourceLoadBlockedByClient":return i18nString(UIStrings.prerenderFinalStatusResourceLoadBlockedByClient);case"SpeculationRuleRemoved":return i18nString(UIStrings.prerenderFinalStatusSpeculationRuleRemoved);default:return i18n.i18n.lockedString(`Unknown failure reason: ${e.prerenderStatus}`)}}export function ruleSetLocationShort(e,r){const t=void 0===e.url?r:e.url;return Bindings.ResourceUtils.displayNameForURL(t)}export function action({key:e}){switch(e.action){case"Prefetch":return i18n.i18n.lockedString("prefetch");case"Prerender":return i18n.i18n.lockedString("prerender")}}export function status(e){switch(e){case"NotTriggered":return i18nString(UIStrings.statusNotTriggered);case"Pending":return i18nString(UIStrings.statusPending);case"Running":return i18nString(UIStrings.statusRunning);case"Ready":return i18nString(UIStrings.statusReady);case"Success":return i18nString(UIStrings.statusSuccess);case"Failure":return i18nString(UIStrings.statusFailure);case"NotSupported":return i18n.i18n.lockedString("Internal error")}}export function composedStatus(e){const r=status(e.status);if("Failure"!==e.status)return r;switch(e.action){case"Prefetch":return r+" - "+(prefetchFailureReason(e)??i18n.i18n.lockedString("Internal error"));case"Prerender":{const t=prerenderFailureReason(e);return assertNotNullOrUndefined(t),r+" - "+t}}}