-
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #501 from Gaurav0/glimmer2
Upgrade to Glimmer 2
- Loading branch information
Showing
16 changed files
with
204 additions
and
86 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import Ember from "ember"; | ||
import GistController from "../mixins/gist-controller"; | ||
|
||
export default Ember.Controller.extend(GistController, {}); |
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,53 +1,4 @@ | ||
import Ember from "ember"; | ||
import GistController from "../mixins/gist-controller"; | ||
|
||
const { inject, RSVP, run } = Ember; | ||
|
||
export default Ember.Controller.extend({ | ||
fastboot: inject.service(), | ||
|
||
queryParams: ['numColumns', 'fullScreen', 'route', 'openFiles', 'fileTreeShown'], | ||
numColumns: 1, | ||
fullScreen: false, | ||
openFiles: "", | ||
fileTreeShown: true, | ||
route: undefined, | ||
applicationUrl: undefined, | ||
unsaved: true, | ||
|
||
init(...args) { | ||
this._super(...args); | ||
if (!this.get('fastboot.isFastBoot')) { | ||
this.setupWindowUpdate(); | ||
} | ||
}, | ||
|
||
actions: { | ||
transitionQueryParams(queryParams) { | ||
return this.transitionToRoute({ queryParams: queryParams }).then(() => { | ||
return RSVP.resolve(queryParams); | ||
}); | ||
} | ||
}, | ||
|
||
setupWindowUpdate: function() { | ||
// TODO: this in a controller seems suspect, rather this should likely be | ||
// part of some handshake, to ensure no races exist. This should likley not | ||
// be something a controller would handle - (SP) | ||
window.addEventListener('message', (m) => { | ||
run(() => { | ||
if(typeof m.data==='object' && 'setAppUrl' in m.data) { | ||
if (!this.get('isDestroyed')) { | ||
if (window.messagesWaiting > 0) { | ||
window.messagesWaiting = 0; | ||
} | ||
const newRoute = m.data.setAppUrl || '/'; | ||
this.setProperties({ | ||
applicationUrl: newRoute, | ||
route: newRoute === "/" ? undefined : newRoute | ||
}); | ||
} | ||
} | ||
}); | ||
}); | ||
} | ||
}); | ||
export default Ember.Controller.extend(GistController, {}); |
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,53 @@ | ||
import Ember from "ember"; | ||
|
||
const { inject, RSVP, run } = Ember; | ||
|
||
export default Ember.Mixin.create({ | ||
fastboot: inject.service(), | ||
|
||
queryParams: ['numColumns', 'fullScreen', 'route', 'openFiles', 'fileTreeShown'], | ||
numColumns: 1, | ||
fullScreen: false, | ||
openFiles: "", | ||
fileTreeShown: true, | ||
route: undefined, | ||
applicationUrl: undefined, | ||
unsaved: true, | ||
|
||
init(...args) { | ||
this._super(...args); | ||
if (!this.get('fastboot.isFastBoot')) { | ||
this.setupWindowUpdate(); | ||
} | ||
}, | ||
|
||
actions: { | ||
transitionQueryParams(queryParams) { | ||
return this.transitionToRoute({ queryParams: queryParams }).then(() => { | ||
return RSVP.resolve(queryParams); | ||
}); | ||
} | ||
}, | ||
|
||
setupWindowUpdate: function() { | ||
// TODO: this in a controller seems suspect, rather this should likely be | ||
// part of some handshake, to ensure no races exist. This should likley not | ||
// be something a controller would handle - (SP) | ||
window.addEventListener('message', (m) => { | ||
run(() => { | ||
if(typeof m.data==='object' && 'setAppUrl' in m.data) { | ||
if (!this.get('isDestroyed')) { | ||
if (window.messagesWaiting > 0) { | ||
window.messagesWaiting = 0; | ||
} | ||
const newRoute = m.data.setAppUrl || '/'; | ||
this.setProperties({ | ||
applicationUrl: newRoute, | ||
route: newRoute === "/" ? undefined : newRoute | ||
}); | ||
} | ||
} | ||
}); | ||
}); | ||
} | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,86 @@ | ||
export default function(babel, _options) { | ||
var options = _options || {}; | ||
|
||
function htmlbarsInlineCompilerPlugin(babel) { | ||
var t = babel.types; | ||
|
||
var replaceNodeWithPrecompiledTemplate = function(node, template) { | ||
var compiledTemplateString = "Ember.HTMLBars.compile(`" + template + "`)"; | ||
|
||
// Prefer calling replaceWithSourceString if it is present. | ||
// this prevents a deprecation warning in Babel 5.6.7+. | ||
// | ||
// TODO: delete the fallback once we only support babel >= 5.6.7. | ||
if (node.replaceWithSourceString) { | ||
node.replaceWithSourceString(compiledTemplateString); | ||
} else { | ||
return compiledTemplateString; | ||
} | ||
}; | ||
|
||
|
||
return new babel.Transformer('htmlbars-inline-precompile', { | ||
ImportDeclaration: function(node, parent, scope, file) { | ||
if (t.isLiteral(node.source, { value: "htmlbars-inline-precompile" })) { | ||
var first = node.specifiers && node.specifiers[0]; | ||
if (t.isImportDefaultSpecifier(first)) { | ||
file.importSpecifier = first.local.name; | ||
} else { | ||
var input = file.code; | ||
var usedImportStatement = input.slice(node.start, node.end); | ||
var msg = "Only `import hbs from 'htmlbars-inline-precompile'` is supported. You used: `" + usedImportStatement + "`"; | ||
throw file.errorWithNode(node, msg); | ||
} | ||
|
||
// Prefer calling dangerouslyRemove instead of remove (if present) to | ||
// suppress a deprecation warning. | ||
// | ||
// TODO: delete the fallback once we only support babel >= 5.5.0. | ||
if (typeof this.dangerouslyRemove === 'function') { | ||
this.dangerouslyRemove(); | ||
} else { | ||
this.remove(); | ||
} | ||
} | ||
}, | ||
|
||
CallExpression: function(node, parent, scope, file) { | ||
if (t.isIdentifier(node.callee, { name: file.importSpecifier })) { | ||
var argumentErrorMsg = "hbs should be invoked with a single argument: the template string"; | ||
if (node.arguments.length !== 1) { | ||
throw file.errorWithNode(node, argumentErrorMsg); | ||
} | ||
|
||
var template = node.arguments[0].value; | ||
if (typeof template !== "string") { | ||
throw file.errorWithNode(node, argumentErrorMsg); | ||
} | ||
|
||
return replaceNodeWithPrecompiledTemplate(this, template); | ||
} | ||
}, | ||
|
||
TaggedTemplateExpression: function(node, parent, scope, file) { | ||
if (t.isIdentifier(node.tag, { name: file.importSpecifier })) { | ||
if (node.quasi.expressions.length) { | ||
throw file.errorWithNode(node, "placeholders inside a tagged template string are not supported"); | ||
} | ||
|
||
var template = node.quasi.quasis.map(function(quasi) { | ||
return quasi.value.cooked; | ||
}).join(""); | ||
|
||
return replaceNodeWithPrecompiledTemplate(this, template); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
// used by broccoli-babel-transpiler to bust the cache when | ||
// the template compiler being used changes | ||
htmlbarsInlineCompilerPlugin.cacheKey = function() { | ||
return options.cacheKey; | ||
}; | ||
|
||
return htmlbarsInlineCompilerPlugin; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"version": "0.10.7", | ||
"version": "0.11.0", | ||
"EmberENV": { | ||
"FEATURES": {} | ||
}, | ||
|
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
Oops, something went wrong.