Skip to content

Commit

Permalink
[BUGFIX beta] Updates Glimmer VM to 0.54.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Garrett committed Jun 22, 2020
1 parent 896750d commit 2bf857e
Show file tree
Hide file tree
Showing 35 changed files with 291 additions and 424 deletions.
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@
},
"devDependencies": {
"@babel/preset-env": "^7.9.5",
"@glimmer/compiler": "^0.53.0",
"@glimmer/compiler": "^0.54.0",
"@glimmer/env": "^0.1.7",
"@glimmer/interfaces": "^0.53.0",
"@glimmer/node": "^0.53.0",
"@glimmer/opcode-compiler": "^0.53.0",
"@glimmer/program": "^0.53.0",
"@glimmer/reference": "^0.53.0",
"@glimmer/runtime": "^0.53.0",
"@glimmer/validator": "^0.53.0",
"@glimmer/interfaces": "^0.54.0",
"@glimmer/node": "^0.54.0",
"@glimmer/opcode-compiler": "^0.54.0",
"@glimmer/program": "^0.54.0",
"@glimmer/reference": "^0.54.0",
"@glimmer/runtime": "^0.54.0",
"@glimmer/validator": "^0.54.0",
"@simple-dom/document": "^1.4.0",
"@types/qunit": "^2.9.1",
"@types/rsvp": "^4.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ export default abstract class AbstractManager<T, U> implements ComponentManager<
// noop
}

abstract getDestructor(bucket: T): Option<Destroyable>;
abstract getDestroyable(bucket: T): Option<Destroyable>;
}
22 changes: 7 additions & 15 deletions packages/@ember/-internals/glimmer/lib/component-managers/curly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
WithJitStaticLayout,
} from '@glimmer/interfaces';
import { RootReference, VersionedPathReference } from '@glimmer/reference';
import { PrimitiveReference } from '@glimmer/runtime';
import { PrimitiveReference, registerDestructor } from '@glimmer/runtime';
import { EMPTY_ARRAY, unwrapTemplate } from '@glimmer/util';
import { combine, Tag, validateTag, valueForTag } from '@glimmer/validator';
import { SimpleElement } from '@simple-dom/interface';
Expand Down Expand Up @@ -331,6 +331,10 @@ export default class CurlyComponentManager
instance: component,
template: state.template,
});

registerDestructor(bucket, () => {
environment.extra.debugRenderTree.willDestroy(bucket);
});
}

return bucket;
Expand Down Expand Up @@ -453,20 +457,8 @@ export default class CurlyComponentManager
}
}

getDestructor(bucket: ComponentStateBucket): Option<Destroyable> {
if (ENV._DEBUG_RENDER_TREE) {
return {
willDestroy() {
bucket.willDestroy();
},
destroy() {
bucket.environment.extra.debugRenderTree.willDestroy(bucket);
bucket.destroy();
},
};
} else {
return bucket;
}
getDestroyable(bucket: ComponentStateBucket): Option<Destroyable> {
return bucket;
}
}

Expand Down
40 changes: 10 additions & 30 deletions packages/@ember/-internals/glimmer/lib/component-managers/custom.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ENV } from '@ember/-internals/environment';
import { CUSTOM_TAG_FOR } from '@ember/-internals/metal';
import { Factory } from '@ember/-internals/owner';
import { HAS_NATIVE_PROXY } from '@ember/-internals/utils';
Expand All @@ -16,10 +17,9 @@ import {
WithJitStaticLayout,
} from '@glimmer/interfaces';
import { ComponentRootReference, PathReference } from '@glimmer/reference';
import { registerDestructor } from '@glimmer/runtime';
import { unwrapTemplate } from '@glimmer/util';
import { consumeTag, createTag, isConstTagged, Tag } from '@glimmer/validator';

import { ENV } from '@ember/-internals/environment';
import { EmberVMEnvironment } from '../environment';
import RuntimeResolver from '../resolver';
import { OwnedTemplate } from '../template';
Expand Down Expand Up @@ -285,6 +285,10 @@ export default class CustomComponentManager<ComponentInstance>
instance: component,
template: definition.template,
});

registerDestructor(bucket, () => {
env.extra.debugRenderTree.willDestroy(bucket);
});
}

return bucket;
Expand Down Expand Up @@ -337,28 +341,8 @@ export default class CustomComponentManager<ComponentInstance>
return new ComponentRootReference(delegate.getContext(component), env);
}

getDestructor(state: CustomComponentState<ComponentInstance>): Option<Destroyable> {
let destructor: Option<Destroyable> = null;

if (hasDestructors(state.delegate)) {
destructor = state;
}

if (ENV._DEBUG_RENDER_TREE) {
let inner = destructor;

destructor = {
destroy() {
state.env.extra.debugRenderTree.willDestroy(state);

if (inner) {
inner.destroy();
}
},
};
}

return destructor;
getDestroyable(bucket: CustomComponentState<ComponentInstance>): Option<Destroyable> {
return bucket;
}

getCapabilities({
Expand Down Expand Up @@ -406,13 +390,9 @@ export class CustomComponentState<ComponentInstance> {
public args: CapturedArguments,
public env: EmberVMEnvironment,
public namedArgsProxy?: {}
) {}

destroy() {
const { delegate, component } = this;

) {
if (hasDestructors(delegate)) {
delegate.destroyComponent(component);
registerDestructor(this, () => delegate.destroyComponent(component));
}
}
}
Expand Down
16 changes: 5 additions & 11 deletions packages/@ember/-internals/glimmer/lib/component-managers/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
VMArguments,
} from '@glimmer/interfaces';
import { ComponentRootReference, ConstReference, VersionedPathReference } from '@glimmer/reference';
import { registerDestructor } from '@glimmer/runtime';
import { CONSTANT_TAG, createTag, isConstTagged } from '@glimmer/validator';
import { EmberVMEnvironment } from '../environment';
import InternalComponentManager, { InternalDefinitionState } from './internal';
Expand Down Expand Up @@ -89,6 +90,8 @@ export default class InputComponentManager extends InternalComponentManager<Inpu
instance,
template: layout,
});

registerDestructor(instance, () => env.extra.debugRenderTree.willDestroy(state));
}

return state;
Expand Down Expand Up @@ -128,17 +131,8 @@ export default class InputComponentManager extends InternalComponentManager<Inpu
}
}

getDestructor(state: InputComponentState): Destroyable {
if (ENV._DEBUG_RENDER_TREE) {
return {
destroy() {
state.env.extra.debugRenderTree.willDestroy(state);
state.instance.destroy();
},
};
} else {
return state.instance;
}
getDestroyable(state: InputComponentState): Destroyable {
return state.instance;
}
}

Expand Down
32 changes: 12 additions & 20 deletions packages/@ember/-internals/glimmer/lib/component-managers/mount.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { ENV } from '@ember/-internals/environment';
import { generateControllerFactory } from '@ember/-internals/routing';
import { EMBER_ROUTING_MODEL_ARG } from '@ember/canary-features';
import EngineInstance from '@ember/engine/instance';
import { DEBUG } from '@glimmer/env';
import {
Bounds,
Expand All @@ -9,13 +13,8 @@ import {
WithJitDynamicLayout,
} from '@glimmer/interfaces';
import { ComponentRootReference, VersionedPathReference } from '@glimmer/reference';
import { registerDestructor } from '@glimmer/runtime';
import { CONSTANT_TAG, createTag, isConstTag, Tag } from '@glimmer/validator';

import { generateControllerFactory } from '@ember/-internals/routing';
import { EMBER_ROUTING_MODEL_ARG } from '@ember/canary-features';

import { ENV } from '@ember/-internals/environment';
import EngineInstance from '@ember/engine/instance';
import { TemplateFactory } from '../..';
import { EmberVMEnvironment } from '../environment';
import RuntimeResolver from '../resolver';
Expand Down Expand Up @@ -119,6 +118,11 @@ class MountManager extends AbstractManager<EngineState, EngineDefinitionState>
// set in getDynamicLayout
template: undefined,
});

registerDestructor(engine, () => {
environment.extra.debugRenderTree.willDestroy(controller);
environment.extra.debugRenderTree.willDestroy(bucket);
});
}

return bucket;
Expand All @@ -142,20 +146,8 @@ class MountManager extends AbstractManager<EngineState, EngineDefinitionState>
return tag;
}

getDestructor(bucket: EngineState): Option<Destroyable> {
let { engine, environment, controller } = bucket;

if (ENV._DEBUG_RENDER_TREE) {
return {
destroy() {
environment.extra.debugRenderTree.willDestroy(controller);
environment.extra.debugRenderTree.willDestroy(bucket);
engine.destroy();
},
};
} else {
return engine;
}
getDestroyable(bucket: EngineState): Option<Destroyable> {
return bucket.engine;
}

didRenderLayout(bucket: EngineState, bounds: Bounds): void {
Expand Down
26 changes: 13 additions & 13 deletions packages/@ember/-internals/glimmer/lib/component-managers/outlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
WithJitStaticLayout,
} from '@glimmer/interfaces';
import { ComponentRootReference, VersionedPathReference } from '@glimmer/reference';
import { EMPTY_ARGS } from '@glimmer/runtime';
import { EMPTY_ARGS, registerDestructor } from '@glimmer/runtime';
import { unwrapTemplate } from '@glimmer/util';
import { CONSTANT_TAG, createTag, Tag } from '@glimmer/validator';

Expand Down Expand Up @@ -125,6 +125,16 @@ class OutletComponentManager extends AbstractManager<OutletInstanceState, Outlet
instance: definition.controller,
template: definition.template,
});

registerDestructor(state, () => {
state.environment.extra.debugRenderTree.willDestroy(state);

if (state.engine) {
state.environment.extra.debugRenderTree.willDestroy(state.engine);
}

state.environment.extra.debugRenderTree.willDestroy(state.outlet!);
});
}

return state;
Expand Down Expand Up @@ -191,19 +201,9 @@ class OutletComponentManager extends AbstractManager<OutletInstanceState, Outlet
}
}

getDestructor(state: OutletInstanceState): Option<Destroyable> {
getDestroyable(state: OutletInstanceState): Option<Destroyable> {
if (ENV._DEBUG_RENDER_TREE) {
return {
destroy() {
state.environment.extra.debugRenderTree.willDestroy(state);

if (state.engine) {
state.environment.extra.debugRenderTree.willDestroy(state.engine);
}

state.environment.extra.debugRenderTree.willDestroy(state.outlet!);
},
};
return state;
} else {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
VMArguments,
WithJitStaticLayout,
} from '@glimmer/interfaces';
import { NULL_REFERENCE } from '@glimmer/runtime';
import { NULL_REFERENCE, registerDestructor } from '@glimmer/runtime';
import { unwrapTemplate } from '@glimmer/util';
import { CONSTANT_TAG, createTag } from '@glimmer/validator';
import { EmberVMEnvironment } from '../environment';
Expand Down Expand Up @@ -57,13 +57,19 @@ export default class TemplateOnlyComponentManager
): Option<DebugStateBucket> {
if (ENV._DEBUG_RENDER_TREE) {
let bucket = { environment };

environment.extra.debugRenderTree.create(bucket, {
type: 'component',
name: name,
args: args.capture(),
instance: null,
template,
});

registerDestructor(bucket, () => {
bucket.environment.extra.debugRenderTree.willDestroy(bucket!);
});

return bucket;
} else {
return null;
Expand All @@ -84,13 +90,9 @@ export default class TemplateOnlyComponentManager
}
}

getDestructor(bucket: Option<DebugStateBucket>) {
getDestroyable(bucket: Option<DebugStateBucket>) {
if (ENV._DEBUG_RENDER_TREE) {
return {
destroy() {
bucket!.environment.extra.debugRenderTree.willDestroy(bucket!);
},
};
return bucket;
} else {
return null;
}
Expand Down
Loading

0 comments on commit 2bf857e

Please sign in to comment.