-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[experiment]: Demo app for glimmer-next renderer #20711
Draft
lifeart
wants to merge
23
commits into
emberjs:main
Choose a base branch
from
lifeart:demo-app
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 14 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
b88ce4b
demo-app
lifeart 7da51d5
+
lifeart ef64ae2
+
lifeart 248aaaa
sample component managers
lifeart 31f7374
+
lifeart 070794d
reuse tracked data from gxt
lifeart 29ac367
+
lifeart efa1163
+
lifeart 87a7472
+
lifeart 511e886
destroyable
lifeart c6d7d20
query params working
lifeart f8ffb26
support input
lifeart 70ead93
+
lifeart 571fd62
+
lifeart ff9ba28
+
lifeart aa7e20c
?
lifeart 5bbc717
+
lifeart 2e87bc2
isTracking
lifeart ec30635
+
lifeart a9e1f56
attempt to run tests
lifeart 54354f7
+
lifeart e5d57e1
bump deps
lifeart 90bf7d3
fix helper registration tests
lifeart File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 5 additions & 2 deletions
7
packages/@ember/-internals/glimmer/lib/helpers/internal-helper.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import type { InternalOwner } from '@ember/-internals/owner'; | ||
import type { Helper, HelperDefinitionState } from '@glimmer/interfaces'; | ||
import { setInternalHelperManager } from '@glimmer/manager'; | ||
// import { setInternalHelperManager } from '@glimmer/manager'; | ||
|
||
export function internalHelper(helper: Helper<InternalOwner>): HelperDefinitionState { | ||
return setInternalHelperManager(helper, {}); | ||
return function () { | ||
console.log('internal helper', this, [...arguments]); | ||
return helper(...arguments); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import { precompileTemplate } from '@ember/template-compilation'; | ||
export default precompileTemplate('', { | ||
moduleName: 'packages/@ember/-internals/glimmer/lib/templates/empty.hbs', | ||
strictMode: true, | ||
}); | ||
import { hbs } from '@lifeart/gxt'; | ||
export default function emptyTemplate() { | ||
return hbs``; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 16 additions & 25 deletions
41
packages/@ember/-internals/glimmer/lib/templates/link-to.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,21 @@ | ||
import { precompileTemplate } from '@ember/template-compilation'; | ||
import { on } from '@ember/modifier'; | ||
import { hbs } from '@lifeart/gxt'; | ||
|
||
export default precompileTemplate( | ||
`<a | ||
{{!-- for compatibility --}} | ||
id={{this.id}} | ||
class={{this.class}} | ||
export default function LinkToTemplate() { | ||
return hbs`<a | ||
{{!-- for compatibility --}} | ||
id={{this.id}} | ||
class={{this.class}} | ||
|
||
{{!-- deprecated attribute bindings --}} | ||
role={{this.role}} | ||
title={{this.title}} | ||
rel={{this.rel}} | ||
tabindex={{this.tabindex}} | ||
target={{this.target}} | ||
{{!-- deprecated attribute bindings --}} | ||
role={{this.role}} | ||
title={{this.title}} | ||
rel={{this.rel}} | ||
tabindex={{this.tabindex}} | ||
target={{this.target}} | ||
|
||
...attributes | ||
...attributes | ||
|
||
href={{this.href}} | ||
href={{this.href}} | ||
|
||
{{on 'click' this.click}} | ||
>{{yield}}</a>`, | ||
{ | ||
moduleName: 'packages/@ember/-internals/glimmer/lib/templates/link-to.hbs', | ||
strictMode: true, | ||
scope() { | ||
return { on }; | ||
}, | ||
} | ||
); | ||
{{on 'click' this.click}} >{{yield}}</a>`; | ||
} |
71 changes: 71 additions & 0 deletions
71
packages/@ember/-internals/glimmer/lib/templates/outlet-helper-component.gts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { Component, cell } from '@lifeart/gxt'; | ||
|
||
interface State { | ||
outlets: { | ||
main: State | undefined, | ||
}, | ||
render: { | ||
template(): () => unknown, | ||
controller: unknown, | ||
name: string, | ||
} | ||
} | ||
|
||
export default class OutletHelper extends Component { | ||
get state() { | ||
return this.args.state().outlets.main || this.args.state(); | ||
} | ||
get nextState() { | ||
return () => { | ||
return this.hasNext; | ||
} | ||
} | ||
get hasNext() { | ||
return this.state.outlets.main; | ||
} | ||
get canRender() { | ||
return !!this?.state?.render; | ||
} | ||
get MyComponent() { | ||
|
||
const state = this.state; | ||
const render = state.render; | ||
const tpl = render.template(); | ||
if (tpl.instance) { | ||
tpl.renderCell.update(render.model); | ||
return tpl.instance.template; | ||
} | ||
const renderCell = cell(render.model); | ||
// console.log('render.model', render.model); | ||
const args = { | ||
get model() { | ||
return renderCell.value; | ||
} | ||
} | ||
|
||
render.controller['args'] = args; | ||
// render.controller.model = render.model; | ||
const tplComponentInstance = new tpl(args); | ||
tplComponentInstance.template = tplComponentInstance.template.bind(render.controller); | ||
// we need to provide stable refs here to avoid re-renders | ||
tpl.instance = tplComponentInstance; | ||
tpl.renderCell = renderCell; | ||
return tplComponentInstance.template; | ||
} | ||
get model() { | ||
const state = this.state; | ||
const render = state.render; | ||
console.log('getModel', render.model); | ||
return render.model; | ||
} | ||
<template> | ||
{{#if this.canRender}} | ||
<this.MyComponent @model={{this.model}}> | ||
{{#if this.hasNext}} | ||
<OutletHelper @state={{this.nextState}} @root={{false}} /> | ||
{{/if}} | ||
</this.MyComponent> | ||
|
||
{{/if}} | ||
</template> | ||
} |
20 changes: 13 additions & 7 deletions
20
packages/@ember/-internals/glimmer/lib/templates/outlet.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
import { precompileTemplate } from '@ember/template-compilation'; | ||
import { hbs } from '@lifeart/gxt'; | ||
import { outletHelper } from '../syntax/outlet'; | ||
import Outlet from './outlet-helper-component'; | ||
|
||
export default precompileTemplate(`{{component (outletHelper)}}`, { | ||
moduleName: 'packages/@ember/-internals/glimmer/lib/templates/outlet.hbs', | ||
strictMode: true, | ||
scope() { | ||
return { outletHelper }; | ||
}, | ||
}); | ||
|
||
export default (owner) => { | ||
console.log('outlet factory', owner); | ||
globalThis.owner = owner; | ||
return function(args) { | ||
console.log('outlet', this, owner, ...arguments); | ||
return hbs`{{#let (component Outlet state=(args.state)) as |Outlet|}} | ||
<div>[main outlet template]<Outlet /></div> | ||
{{/let}}`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,22 @@ | ||
import { precompileTemplate } from '@ember/template-compilation'; | ||
export default precompileTemplate(`{{component this}}`, { | ||
moduleName: 'packages/@ember/-internals/glimmer/lib/templates/root.hbs', | ||
strictMode: true, | ||
}); | ||
import { hbs, $_fin } from '@lifeart/gxt'; | ||
export default function(owner) { | ||
console.log('root-template init', owner); | ||
return function(rootState) { | ||
// console.log('root-template - render', [this], [...arguments]); | ||
// temp1.root.template | ||
// console.log(...arguments); | ||
// return function() { | ||
// console.log(...arguments); | ||
// return $_fin([...rootState.root.template()], this); | ||
// } | ||
// debugger; | ||
const state = rootState.root.ref; | ||
console.log('rootState', state); | ||
return hbs` | ||
{{log 'root-template-create' this rootState}} | ||
{{#let (component rootState.root.template state=state root=true) as |Layout|}} | ||
<Layout /> | ||
{{/let}} | ||
`; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
why comment this out?
If we need to re-define the implementation, I think that could happen in this PR (like, if it's copying from glimmer-next, for example)