-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[REFACTOR] Refactors while integrating with Ember #993
Conversation
- Updates to the Runtime builds (`AotRuntime()`,`JitRuntime()`) - Can now accept an options hash as the first argument containing either the document or append/update operations. - Updates to the RuntimeEnvironmentDelegate: - Removed the `iterables` API, key for methods are now statically generated and entirely a concern of the IteratorImpl - Added `toIterator`, which allows the delegate to provide an `IteratorDelegate` for a given value. To keep things simpler and more performant, this is not yet a true browser delegate. This way, it matches the API of the (now internal) `IterationItem`. - Note for future: `key` and `memo` names are fairly confusing, maybe `memo` -> `index`? - Added `getPath` to allow Ember to provide a getter implementation, allowing `keyFor` to be fully pluggable. This will probably also be necessary for `RootReference` if we want to use the upstream version provided by Glimmer now, since it needs to use `get` to autotrack correctly. - Updates to `IterableImpl` - Added the `IteratorDelegate` interface (could maybe use a better name). This is the minimal API to let Ember provide all the different types of iterators it needs to (in particular, `EmberArray`, objects with `forEach`, and `{{each-in}}` iterators). - No more native iterables - we don't support `Symbol` yet, plus it's fairly redundant with `IteratorDelegate`. - Very simple `IteratorWrapper` class instead, which adds the key to the final iteration item internally. No more need to expose `keyFor` concerns to Ember, except `getPath`.
9ce08fc
to
3816858
Compare
…s, refactor delegate, add @glimmer/env to local build
* Add caching to PropertyReference * Add WILL_DROP, willDestroy capability * Fix opcode_compiler bug (staticComponent generation dropped positional) * Fix bug with iterable identity
55704ad
to
2528ecc
Compare
2528ecc
to
bc361e5
Compare
…the context of the delegate
This allows local tests to use DEBUG and test against errors and assertions. This commit also fixes a few assertions, some of which could not work for one reason or another, and some of which needed tweaking. In particular, `@glimmer/validator` need a tweak in DEBUG mode. Our current assumption is that by the first time you call `value` on a tag in a render, that tag's value should truly be locked down, and you should not be able to change it without a call to `dirty()` somewhere. This allows us to cache the value. We also use a trick to allow us to compute the value _once_ during `validate()` in production builds - We know the global $REVISION cannot possibly be less than the value of the tag, so we return it directly. However, this does mean that it _is_ valid to update the value of a tag between a false `validate()` and `value()`, and this is expected, as we have a number of cases where we do this. This commit introduces an assertion that throws if you attempt to update a tag to a more recent value after it has been locked in, and in DEBUG it prevents caching while revalidating in order to allow that brief period between a false `validate()` and a `value()` to not trigger this assertion.
|
||
# v0.45.0 | ||
|
||
* `@glimmer/runtime` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note to remind myself to copy this content into the changelog when we land / release this.
build/broccoli/build-tests.js
Outdated
let glimmerEnv = funnel('node_modules/@glimmer/env', { | ||
include: ['dist/amd/es5/*.{js,map}'], | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check if we can remove this?
super(env); | ||
|
||
if (DEBUG) { | ||
let name = debugName || fn.name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit unfortunate, we should try to figure out how we can thread through the invoked helper name here.
Seems totally fine to followup with this though...
compute() { | ||
this.computeTag = track(() => { | ||
this.computeValue = this.fn(this.args); | ||
}, DEBUG && `${this.env.getTemplatePathDebugContext(this)}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}, DEBUG && `${this.env.getTemplatePathDebugContext(this)}`); | |
}, DEBUG && this.env.getTemplatePathDebugContext(this)); |
): JitRuntimeContext { | ||
let env = new RuntimeEnvironment(document, new RuntimeEnvironmentDelegateImpl(delegate)); | ||
resolver: RuntimeResolverDelegate<R> = {}, | ||
delegate: EnvironmentDelegate<E> = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ideally we should try to make it so that the only thing in the system that is aware of the delegate setup that we are using is the environment. I don't particularly think that will make much difference here at the moment, but it does isolate unrelated parts of the system (like this one) from other future changes that we might make to the delegate.
tldr; lets pass the environment here instead of the delegate, but seems fine to do in a follow up...
@@ -35,6 +38,10 @@ export function associateDestructor(parent: object, child: Drop): void { | |||
associated.add(child); | |||
} | |||
|
|||
export function peekAssociated(parent: object): Option<Set<Drop>> { | |||
return LINKED.get(parent) || null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return LINKED_IN.get(parent) || null;
7b40e91
to
d73dde0
Compare
Changelog
Overall updates
@glimmer/env
to the build, usable from Ember as well.Updates to the Runtime builders (
AotRuntime()
,JitRuntime()
)either the document or append/update operations.
Updates to
Environment
DefaultEnvironment
willDestroy
to environment forWILL_DROP
(legacy sync drops)Updates to the
RuntimeEnvironmentDelegate
:EnvironmentDelegate
isInteractive
, equivalent of Ember's usage (should update?)extra
field, which is a generic type for the Environment. Thisallows the embedding environment to pass any extra values they need.
iterables
API, key for methods are now staticallygenerated and entirely a concern of the IteratorImpl
toIterator
, which allows the delegate to provide anIteratorDelegate
for a given value. To keep things simpler andmore performant, this is not yet a true browser delegate. This way,
it matches the API of the (now internal)
IterationItem
.key
andmemo
names are fairly confusing,maybe
memo
->index
?getPath
/setPath
to allow Ember to provide a getter/setterimplementation, allowing for PropertyReference to delegate property access,
along with
keyFor
in iterators.setTemplatePathDebugContext
/getTemplatePathDebugContext
. These areused to add debug context for paths in templates (e.g.
{{this.foo}}
or{{my-helper}}
) to the DebugRenderTree in Ember. Eventually they shouldbe removed, when the DebugRenderTree has been pulled upstream into Glimmer.
Updates to
IterableImpl
IteratorDelegate
interface (could maybe use a bettername). This is the minimal API to let Ember provide all the
different types of iterators it needs to (in particular,
EmberArray
, objects withforEach
, and{{each-in}}
iterators).Symbol
yet, plus it'sfairly redundant with
IteratorDelegate
.IteratorWrapper
class instead, which adds the keyto the final iteration item internally. No more need to expose
keyFor
concerns to Ember, exceptgetPath
.Updates to
@glimmer/runtime
WILL_DROP
to destroyables, andwillDestroy
to component managersUpdates to
@glimmer/reference
MapReference
UpdatableReference
, replaced withUpdatableRootReference
andIterationItemReference
and properties. Roots are unique, there are a few different types.
Properties are almost all the same.
env
, which allows them to delegateaccess, and setup debug context.
Updates to
@glimmer/validator
it up based on the embedding environment.
meta
system, now it's just a few WeakMaps.updating a tag with a more recent tag in a way that wouldn't bust the cache.