ruru
Version:
Grafast-flavoured GraphiQL distribution
2 lines • 4.45 kB
JavaScript
export const __webpack_esm_id__=6973;export const __webpack_esm_ids__=[6973];export const __webpack_esm_modules__={68175(e,t,i){function s(e,t,i){return Math.min(Math.max(e,t),i)}i.r(t),i.d(t,{MovingAverage:()=>n,SlidingWindowAverage:()=>r,clamp:()=>s});class n{constructor(){this._n=1,this._val=0}update(e){return this._val=this._val+(e-this._val)/this._n,this._n+=1,this._val}get value(){return this._val}}class r{constructor(e){this._n=0,this._val=0,this._values=[],this._index=0,this._sum=0,this._values=new Array(e),this._values.fill(0,0,e)}update(e){const t=this._values[this._index];return this._values[this._index]=e,this._index=(this._index+1)%this._values.length,this._sum-=t,this._sum+=e,this._n<this._values.length&&(this._n+=1),this._val=this._sum/this._n,this._val}get value(){return this._val}}},26973(e,t,i){i.r(t),i.d(t,{ILanguageFeatureDebounceService:()=>l,LanguageFeatureDebounceService:()=>f});var s=i(58053),n=i(27735),r=i(68175),a=i(63056),c=i(17531),o=i(35184),u=i(69570),_=i(54835),h=function(e,t){return function(i,s){t(i,s,e)}};const l=(0,o.createDecorator)("ILanguageFeatureDebounceService");var v;!function(e){const t=new WeakMap;let i=0;e.of=function(e){let s=t.get(e);return void 0===s&&(s=++i,t.set(e,s)),s}}(v||(v={}));class d{constructor(e){this._default=e}get(e){return this._default}update(e,t){return this._default}default(){return this._default}}class g{constructor(e,t,i,s,r,a){this._logService=e,this._name=t,this._registry=i,this._default=s,this._min=r,this._max=a,this._cache=new n.LRUCache(50,.7)}_key(e){return e.id+this._registry.all(e).reduce((e,t)=>(0,s.doHash)(v.of(t),e),0)}get(e){const t=this._key(e),i=this._cache.get(t);return i?(0,r.clamp)(i.value,this._min,this._max):this.default()}update(e,t){const i=this._key(e);let s=this._cache.get(i);s||(s=new r.SlidingWindowAverage(6),this._cache.set(i,s));const n=(0,r.clamp)(s.update(t),this._min,this._max);return(0,_.matchesScheme)(e.uri,"output")||this._logService.trace(`[DEBOUNCE: ${this._name}] for ${e.uri.toString()} is ${n}ms`),n}_overall(){const e=new r.MovingAverage;for(const[,t]of this._cache)e.update(t.value);return e.value}default(){const e=0|this._overall()||this._default;return(0,r.clamp)(e,this._min,this._max)}}let f=class{constructor(e,t){this._logService=e,this._data=new Map,this._isDev=t.isExtensionDevelopment||!t.isBuilt}for(e,t,i){const s=i?.min??50,n=i?.max??s**2,r=i?.key??void 0,a=`${v.of(e)},${s}${r?","+r:""}`;let c=this._data.get(a);return c||(this._isDev?(this._logService.debug(`[DEBOUNCE: ${t}] is disabled in developed mode`),c=new d(1.5*s)):c=new g(this._logService,t,e,0|this._overallAverage()||1.5*s,s,n),this._data.set(a,c)),c}_overallAverage(){const e=new r.MovingAverage;for(const t of this._data.values())e.update(t.default());return e.value}};f=function(e,t,i,s){var n,r=arguments.length,a=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,s);else for(var c=e.length-1;c>=0;c--)(n=e[c])&&(a=(r<3?n(a):r>3?n(t,i,a):n(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a}([h(0,u.ILogService),h(1,a.IEnvironmentService)],f),(0,c.registerSingleton)(l,f,1)},63056(e,t,i){i.r(t),i.d(t,{IEnvironmentService:()=>s});const s=(0,i(35184).createDecorator)("environmentService")},72015(e,t,i){i.r(t),i.d(t,{SyncDescriptor:()=>s});class s{constructor(e,t=[],i=!1){this.ctor=e,this.staticArguments=t,this.supportsDelayedInstantiation=i}}},17531(e,t,i){i.r(t),i.d(t,{getSingletonServiceDescriptors:()=>a,registerSingleton:()=>r});var s=i(72015);const n=[];function r(e,t,i){t instanceof s.SyncDescriptor||(t=new s.SyncDescriptor(t,[],Boolean(i))),n.push([e,t])}function a(){return n}},35184(e,t,i){var s;i.r(t),i.d(t,{IInstantiationService:()=>n,_util:()=>s,createDecorator:()=>r}),function(e){e.serviceIds=new Map,e.DI_TARGET="$di$target",e.DI_DEPENDENCIES="$di$dependencies",e.getServiceDependencies=function(t){return t[e.DI_DEPENDENCIES]||[]}}(s||(s={}));const n=r("instantiationService");function r(e){if(s.serviceIds.has(e))return s.serviceIds.get(e);const t=function(e,i,n){if(3!==arguments.length)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");!function(e,t,i){t[s.DI_TARGET]===t?t[s.DI_DEPENDENCIES].push({id:e,index:i}):(t[s.DI_DEPENDENCIES]=[{id:e,index:i}],t[s.DI_TARGET]=t)}(t,e,n)};return t.toString=()=>e,s.serviceIds.set(e,t),t}}};
//# sourceMappingURL=6973.js.map