You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
define("ember-animated/-private/ember-scheduler",["exports","ember-animated/-private/scheduler","ember-animated"],function(_exports,_scheduler,_emberAnimated){"use strict";Object.defineProperty(_exports,"__esModule",{value: true});_exports.task=task;_exports.timeout=timeout;_exports.Task=_exports.TaskProperty=void0;function_defineProperty(obj,key,value){if(keyinobj){Object.defineProperty(obj,key,{value: value,enumerable: true,configurable: true,writable: true});}else{obj[key]=value;}returnobj;}functiontask(taskFn){lettp=_computed(function(propertyName){returnnewTask(this,taskFn,tp,propertyName);});Object.setPrototypeOf(tp,TaskProperty.prototype);returntp;}function_computed(fn){if(!true){returnEmber.computed(fn);}letcp=function(proto,key){if(cp.setup!==undefined){cp.setup(proto,key);}returnEmber.computed(fn)(...arguments);};Ember._setClassicDecorator(cp);returncp;}lethandlerCounter=0;letBaseTaskProperty;if(true){BaseTaskProperty=class{};}else{BaseTaskProperty=Ember.ComputedProperty;}classTaskPropertyextendsBaseTaskProperty{constructor(...args){super(...args);_defineProperty(this,"_bufferPolicy",void0);_defineProperty(this,"_observes",void0);}restartable(){this._bufferPolicy=cancelAllButLast;returnthis;}drop(){this._bufferPolicy=drop;returnthis;}observes(...deps){this._observes=deps;returnthis;}setup(proto,taskName){// @ts-ignore: depending on the ember version we may or may not have a super// method.if(super.setup){// @ts-ignoresuper.setup(...arguments);}if(this._observes){lethandlerName=`_ember_animated_handler_${handlerCounter++}`;proto[handlerName]=function(){lettask=this.get(taskName);Ember.run.scheduleOnce('actions',task,'_safePerform');};for(leti=0;i<this._observes.length;++i){letname=this._observes[i];addObserver(proto,name,null,handlerName);}}}}_exports.TaskProperty=TaskProperty;letpriv=newWeakMap();functiongetPriv(task){returnpriv.get(task);}classTask{constructor(context,implementation,taskProperty,name){_defineProperty(this,"concurrency",0);_defineProperty(this,"isRunning",false);priv.set(this,{
context,
implementation,instances: [],
taskProperty,
name
});}perform(...args){letself=this;letprivSelf=getPriv(this);letcontext=privSelf.context;letimplementation=privSelf.implementation;letpolicy=privSelf.taskProperty._bufferPolicy;if(context.isDestroyed){thrownewError(`Tried to perform task ${privSelf.name} on an already destroyed object`);}cleanupOnDestroy(context,this);return(0,_scheduler.spawn)(function*(){if(true/* DEBUG */){(0,_scheduler.logErrors)(error=>{(0,_emberAnimated.microwait)().then(()=>{throwerror;});});}try{self._addInstance((0,_scheduler.current)());if(policy){letmaybeWait=policy(self,privSelf);if(maybeWait){yieldmaybeWait;}}letfinalValue=yield*withRunLoop(implementation.call(context, ...args));returnfinalValue;}finally{Ember.run.join(()=>{self._removeInstance((0,_scheduler.current)());});}});}cancelAll(){getPriv(this).instances.forEach(i=>(0,_scheduler.stop)(i));}_addInstance(i){getPriv(this).instances.push(i);Ember.set(this,'isRunning',true);Ember.set(this,'concurrency',this.concurrency+1);}_removeInstance(i){letinstances=getPriv(this).instances;instances.splice(instances.indexOf(i),1);Ember.set(this,'concurrency',this.concurrency-1);Ember.set(this,'isRunning',this.concurrency>0);}_safePerform(){let{
context
}=getPriv(this);if(!context.isDestroyed){this.perform();}}}// cribbed from machty's ember-concurrency_exports.Task=Task;functioncleanupOnDestroy(owner,object){if(!owner.willDestroy){// we're running in non Ember object (possibly in a test mock)return;}if(!owner.willDestroy.__ember_processes_destroyers__){letoldWillDestroy=owner.willDestroy;letdisposers=[];owner.willDestroy=function(){for(leti=0,l=disposers.length;i<l;i++){disposers[i]();}oldWillDestroy.apply(owner,arguments);};/* eslint-disable-next-line @typescript-eslint/camelcase */owner.willDestroy.__ember_processes_destroyers__=disposers;}owner.willDestroy.__ember_processes_destroyers__.push(()=>{try{object.cancelAll();}catch(err){if(err.message!=='TaskCancelation'){throwerr;}}});}functioncancelAllButLast(_task,privTask){letinstances=privTask.instances;for(leti=0;i<instances.length-1;i++){(0,_scheduler.stop)(instances[i]);}}functiondrop(_task,privTask){letinstances=privTask.instances;for(leti=1;i<instances.length;i++){(0,_scheduler.stop)(instances[i]);}}function*withRunLoop(generator){letstate;letthrew;letnextValue;letfulfilled=true;while(true){Ember.run.join(()=>{try{if(fulfilled){state=generator.next(nextValue);}else{state=generator.throw(nextValue);}}catch(err){threw=err;}});if(threw){throwthrew;}if(state.done){returnstate.value;}try{nextValue=yieldstate.value;fulfilled=true;}catch(err){nextValue=err;fulfilled=false;}}}functiontimeout(ms){returnnewEmber.RSVP.Promise(resolve=>setTimeout(resolve,ms));}});
Notice that addObserver used on line 91 is not defined anywhere. It should have been rewritten to Ember.addObserver.
The text was updated successfully, but these errors were encountered:
miguelcobain
changed the title
ReferenceError: addObserver is not defined after 7.20.2 updateReferenceError: addObserver is not defined after 7.20.2 update
May 29, 2020
I'm working on a fix for this, basically the change we made in babel-plugin-ember-modules-api-polyfill avoids modifying any AST nodes that start with TS. Unfortunately (addObserver as any)(...) is a TSAsAnyExpression and still would require modification.
The addObserver import isn't being defined in the resulting transpiled code.
Here's an example that happened in my case with ember-animated.
Original file: https://github.com/ember-animation/ember-animated/blob/v0.10.1/addon/-private/ember-scheduler.ts
result:
Notice that
addObserver
used on line 91 is not defined anywhere. It should have been rewritten toEmber.addObserver
.cc @rwjblue
The text was updated successfully, but these errors were encountered: