Skip to content

Commit

Permalink
[FEATURE] Update Glimmer-VM to 0.45.0 (#18621)
Browse files Browse the repository at this point in the history
[FEATURE] Update Glimmer-VM to 0.45.0

Co-authored-by: Kris Selden <[email protected]>
  • Loading branch information
rwjblue and krisselden authored Jan 9, 2020
2 parents 08baa2f + 03e7132 commit d96d9aa
Show file tree
Hide file tree
Showing 136 changed files with 2,673 additions and 3,373 deletions.
9 changes: 7 additions & 2 deletions broccoli/packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ function glimmerTrees(entries) {
}
seen.add(name);

if (!name.startsWith('@glimmer/')) {
if (!name.startsWith('@glimmer/') && !name.startsWith('@simple-dom/')) {
continue;
}

Expand Down Expand Up @@ -284,7 +284,12 @@ module.exports.glimmerCompilerES = () => {
};

module.exports.glimmerES = function glimmerES(environment) {
let glimmerEntries = ['@glimmer/node', '@glimmer/opcode-compiler', '@glimmer/runtime'];
let glimmerEntries = [
'@glimmer/node',
'@simple-dom/document',
'@glimmer/opcode-compiler',
'@glimmer/runtime',
];

if (environment === 'development') {
let hasGlimmerDebug = true;
Expand Down
2 changes: 2 additions & 0 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const rollupPackage = require('./broccoli/rollup-package');
const minify = require('./broccoli/minify');
const debugTree = require('broccoli-debug').buildDebugCallback('ember-source:ember-cli-build');

Error.stackTraceLimit = Infinity;

const {
routerES,
jquery,
Expand Down
18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,16 @@
},
"devDependencies": {
"@babel/preset-env": "^7.7.7",
"@glimmer/compiler": "0.38.5-alpha.3",
"@glimmer/compiler": "0.45.3",
"@glimmer/env": "^0.1.7",
"@glimmer/interfaces": "0.38.5-alpha.3",
"@glimmer/node": "0.38.5-alpha.3",
"@glimmer/opcode-compiler": "0.38.5-alpha.3",
"@glimmer/program": "0.38.5-alpha.3",
"@glimmer/reference": "0.38.5-alpha.3",
"@glimmer/runtime": "0.38.5-alpha.3",
"@glimmer/interfaces": "0.45.3",
"@glimmer/node": "0.45.3",
"@glimmer/opcode-compiler": "0.45.3",
"@glimmer/program": "0.45.3",
"@glimmer/reference": "0.45.3",
"@glimmer/runtime": "0.45.3",
"@glimmer/validator": "0.45.3",
"@simple-dom/document": "^1.4.0",
"@types/qunit": "^2.5.4",
"@types/rsvp": "^4.0.3",
"@typescript-eslint/parser": "^2.15.0",
Expand All @@ -98,7 +100,7 @@
"broccoli-rollup": "^2.1.1",
"broccoli-source": "^3.0.0",
"broccoli-string-replace": "^0.1.2",
"broccoli-typescript-compiler": "^4.1.0",
"broccoli-typescript-compiler": "^4.2.0",
"broccoli-uglify-sourcemap": "^3.1.1",
"common-tags": "^1.8.0",
"core-js": "^2.6.5",
Expand Down
5 changes: 2 additions & 3 deletions packages/@ember/-internals/glimmer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ export { default as TextArea } from './lib/components/textarea';
export { default as LinkComponent } from './lib/components/link-to';
export { default as Component } from './lib/component';
export { default as Helper, helper } from './lib/helper';
export { default as Environment } from './lib/environment';
export { SafeString, escapeExpression, htmlSafe, isHTMLSafe } from './lib/utils/string';
export {
Renderer,
Expand Down Expand Up @@ -380,9 +379,9 @@ export { default as AbstractComponentManager } from './lib/component-managers/ab
// TODO just test these through public API
// a lot of these are testing how a problem was solved
// rather than the problem was solved
export { UpdatableReference, INVOKE } from './lib/utils/references';
export { default as iterableFor } from './lib/utils/iterable';
export { INVOKE } from './lib/helpers/mut';
export { default as OutletView } from './lib/views/outlet';
export { OutletState } from './lib/utils/outlet';
export { capabilities } from './lib/component-managers/custom';
export { setComponentManager, getComponentManager } from './lib/utils/custom-component-manager';
export { setModifierManager, getModifierManager } from './lib/utils/custom-modifier-manager';
Expand Down
81 changes: 45 additions & 36 deletions packages/@ember/-internals/glimmer/lib/compile-time-lookup.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,28 @@
import { OwnedTemplateMeta } from '@ember/-internals/views';
import {
CompilableTemplate,
CompileTimeLookup as ICompileTimeLookup,
CompileTimeComponent,
CompileTimeResolverDelegate,
ComponentCapabilities,
ComponentDefinition,
ComponentManager,
Option,
ProgramSymbolTable,
WithJitStaticLayout,
} from '@glimmer/interfaces';
import { ComponentDefinition, ComponentManager, WithStaticLayout } from '@glimmer/runtime';
import RuntimeResolver from './resolver';

interface StaticComponentManager<DefinitionState>
extends WithStaticLayout<any, DefinitionState, OwnedTemplateMeta, RuntimeResolver>,
ComponentManager<any, DefinitionState> {}
interface StaticComponentManager
extends WithJitStaticLayout<unknown, unknown, RuntimeResolver>,
ComponentManager<unknown, unknown> {}

export default class CompileTimeLookup implements ICompileTimeLookup<OwnedTemplateMeta> {
constructor(private resolver: RuntimeResolver) {}

getCapabilities(handle: number): ComponentCapabilities {
let definition = this.resolver.resolve<Option<ComponentDefinition>>(handle);
let { manager, state } = definition!;
return manager.getCapabilities(state);
}

getLayout<DefinitionState>(handle: number): Option<CompilableTemplate<ProgramSymbolTable>> {
const { manager, state } = this.resolver.resolve<
ComponentDefinition<DefinitionState, StaticComponentManager<DefinitionState>>
>(handle);
const capabilities = manager.getCapabilities(state);

if (capabilities.dynamicLayout) {
return null;
}
function isStaticComponentManager(
_manager: ComponentManager,
capabilities: ComponentCapabilities
): _manager is StaticComponentManager {
return !capabilities.dynamicLayout;
}

const invocation = manager.getLayout(state, this.resolver);
return {
// TODO: this seems weird, it already is compiled
compile() {
return invocation.handle;
},
symbolTable: invocation.symbolTable,
};
}
export default class CompileTimeResolver implements CompileTimeResolverDelegate<OwnedTemplateMeta> {
constructor(private resolver: RuntimeResolver) {}

lookupHelper(name: string, referrer: OwnedTemplateMeta): Option<number> {
return this.resolver.lookupHelper(name, referrer);
Expand All @@ -50,11 +32,38 @@ export default class CompileTimeLookup implements ICompileTimeLookup<OwnedTempla
return this.resolver.lookupModifier(name, referrer);
}

lookupComponentDefinition(name: string, referrer: OwnedTemplateMeta): Option<number> {
return this.resolver.lookupComponentHandle(name, referrer);
lookupComponent(name: string, referrer: OwnedTemplateMeta): Option<CompileTimeComponent> {
let definitionHandle = this.resolver.lookupComponentHandle(name, referrer);

if (definitionHandle === null) {
return null;
}

const { manager, state } = this.resolver.resolve<ComponentDefinition<unknown, unknown>>(
definitionHandle
);
const capabilities = manager.getCapabilities(state);

if (!isStaticComponentManager(manager, capabilities)) {
return {
handle: definitionHandle,
capabilities,
compilable: null,
};
}

return {
handle: definitionHandle,
capabilities,
compilable: manager.getJitStaticLayout(state, this.resolver),
};
}

lookupPartial(name: string, referrer: OwnedTemplateMeta): Option<number> {
return this.resolver.lookupPartial(name, referrer);
}

resolve(handle: number): OwnedTemplateMeta {
return this.resolver.resolve(handle);
}
}
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
import { ComponentCapabilities, Simple } from '@glimmer/interfaces';
import { Tag, VersionedPathReference } from '@glimmer/reference';
import {
Arguments,
Bounds,
ComponentCapabilities,
ComponentManager,
Destroyable,
DynamicScope,
ElementOperations,
Environment,
Option,
PreparedArguments,
} from '@glimmer/runtime';
import { Destroyable, Opaque, Option } from '@glimmer/util';
VMArguments,
} from '@glimmer/interfaces';
import { VersionedPathReference } from '@glimmer/reference';
import { Tag } from '@glimmer/validator';
import { SimpleElement } from '@simple-dom/interface';
import { EmberVMEnvironment } from '../environment';

// implements the ComponentManager interface as defined in glimmer:
// tslint:disable-next-line:max-line-length
// https://github.com/glimmerjs/glimmer-vm/blob/v0.24.0-beta.4/packages/%40glimmer/runtime/lib/component/interfaces.ts#L21

export default abstract class AbstractManager<T, U> implements ComponentManager<T, U> {
prepareArgs(_state: U, _args: Arguments): Option<PreparedArguments> {
prepareArgs(_state: U, _args: VMArguments): Option<PreparedArguments> {
return null;
}

abstract create(
env: Environment,
env: EmberVMEnvironment,
definition: U,
args: Arguments,
args: VMArguments,
dynamicScope: DynamicScope,
caller: VersionedPathReference<void | {}>,
hasDefaultBlock: boolean
): T;

abstract getSelf(component: T): VersionedPathReference<Opaque>;
abstract getSelf(component: T): VersionedPathReference<unknown>;
abstract getCapabilities(state: U): ComponentCapabilities;

didCreateElement(_component: T, _element: Simple.Element, _operations: ElementOperations): void {
didCreateElement(_component: T, _element: SimpleElement, _operations: ElementOperations): void {
// noop
}

Expand Down
Loading

0 comments on commit d96d9aa

Please sign in to comment.