Skip to content

Commit

Permalink
Merge pull request #26 from mcfly-io/feat-fuse
Browse files Browse the repository at this point in the history
  • Loading branch information
thaiat committed Feb 9, 2016
2 parents 2fc915c + 0c95328 commit b902ba7
Show file tree
Hide file tree
Showing 50 changed files with 1,556 additions and 238 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ shippable/
ehthumbs.db
Thumbs.db

# Cordova
platforms/
plugins/

# Visual Studio Code
.vscode/

Expand Down
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
loglevel=silent
loglevel=error
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ You then have access to the following sub generators:
* **yo mcfly-ng2:directive** (Creates a directive)
* **yo mcfly-ng2:interface** (Creates an interface)

> *NOTE:*
> When scaffolding a new target, the generator will ask you to choose between `web` or `fuse`.
> `web` is a normal web project
> `fuse` is a fusetools mobile app
You have access to the following npm scripts
* **npm run clean** (clean the `dist` folder)
Expand Down
29 changes: 24 additions & 5 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ module.exports = generators.Base.extend({
defaults: false
});

this.option('target', {
desc: 'The name of the default target',
type: String
});
// this.option('target', {
// desc: 'The name of the default target',
// type: String
// });
// ****** options *********

},
Expand Down Expand Up @@ -88,6 +88,7 @@ module.exports = generators.Base.extend({
this.appname = this.answers.appname ? this.mixins.dasherize(this.answers.appname) : this.mixins.dasherize(this.appname);
// To access answers later use this.answers.someAnswer;
this.answers.clientFolder = this.mixins.dasherize(this.answers.clientFolder);
this.answers.targetname = this.mixins.dasherize(this.answers.targetname);
done();
}.bind(this));
},
Expand All @@ -98,7 +99,7 @@ module.exports = generators.Base.extend({
this.config.set('appname', this.appname);
this.config.set('clientFolder', this.answers.clientFolder);
this.composeWith(this.mixins.getGeneratorShortname() + ':target', {
args: this.options.target ? [this.options.target] : null,
//args: this.options.target ? [this.options.target] : null,
options: {
clientFolder: this.config.get('clientFolder') // passing the client folder for first run
}
Expand Down Expand Up @@ -195,6 +196,24 @@ module.exports = generators.Base.extend({
this.destinationPath('protractor/browserExtension.js')
);

this.fs.copy(
this.templatePath('plugins/PostCompilePlugin.js'),
this.destinationPath('plugins/PostCompilePlugin.js')
);

this.fs.copy(
this.templatePath('fuse/fuse.d.ts'),
this.destinationPath('typings/fuse/fuse.d.ts')
);

['AngularBootstrap.js', 'AngularRenderer.js', 'bootstrap.ts', 'dom_adapter.ts', 'element.ts', 'fuse_location_strategy.ts', 'fuse_polyfills.ts', 'renderer.ts', 'vendor.ts', 'xhr.ts', 'zone.ts', 'zone_patch.ts']
.forEach(function(file) {
this.fs.copyTpl(
this.templatePath('fuse/' + file),
this.destinationPath('fuse/' + file)
);
}.bind(this));

},

conflicts: function() {
Expand Down
9 changes: 5 additions & 4 deletions generators/app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,30 @@
"pree2e": "npm run webdriver:update -- --standalone",
"e2e": "ts-node node_modules/.bin/protractor",
"e2e:live": "protractor --elementExplorer",
"fuse.preview": "fuse preview",
"fuse.ios": "fuse build --target=iOS --run",
"fuse.android": "fuse build --target=Android --run",
"fuse:preview": "cd dist/${TARGET-app}/${MODE-dev} && fuse preview",
"fuse:ios": "cd dist/${TARGET-app}/${MODE-dev} && fuse build --target=iOS --run",
"fuse:android": "cd dist/${TARGET-app}/${MODE-dev} && fuse build --target=Android --run",
"postinstall": "tsd install"
},
"dependencies": {
"angular2": "2.0.0-beta.3",
"es6-shim": "0.33.3",
"es7-reflect-metadata": "1.4.0",
"lodash": "^4.0.1",
"parse5": "1.3.2",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.0",
"zone.js": "0.5.11"
},
"devDependencies": {
"autoprefixer": "^6.3.1",
"browser-sync": "^2.10.1",
"copy-webpack-plugin": "^1.1.1",
"coveralls": "^2.11.6",
"css-loader": "^0.23.1",
"eslint": "^1.10.3",
"eslint-plugin-nodeca": "^1.0.3",
"file-loader": "^0.8.5",
"gulp-mux": "^0.2.24",
"html-loader": "^0.4.0",
"html-webpack-plugin": "^2.8.1",
"istanbul-instrumenter-loader": "^0.1.3",
Expand Down
39 changes: 39 additions & 0 deletions generators/app/templates/fuse/Angular.uno
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Uno;
using Uno.Collections;
using Fuse;
using Fuse.Scripting;
using Fuse.Reactive;

//namespace Fuse.Angular {

public class Angular: Fuse.Controls.Panel {

static bool isInitialized = false;

public Angular() {
if (!isInitialized) {
isInitialized = true;
var common = new JavaScript() {
File = new global::Uno.UX.BundleFileSource(import global::Uno.BundleFile("../dist/<%=targetname%>/dev/common.js"))
};
global::Uno.UX.Resource.SetGlobalKey(common, "common");
var vendor = new JavaScript() {
File = new global::Uno.UX.BundleFileSource(import global::Uno.BundleFile("../dist/<%=targetname%>/dev/vendor.js"))
};
global::Uno.UX.Resource.SetGlobalKey(vendor, "vendor");
var bundle = new JavaScript() {
File = new global::Uno.UX.BundleFileSource(import global::Uno.BundleFile("../dist/<%=targetname%>/dev/bundle.js"))
};
global::Uno.UX.Resource.SetGlobalKey(bundle, "bundle");
var AngularRenderer = new JavaScript() {
File = new global::Uno.UX.BundleFileSource(import global::Uno.BundleFile("AngularRenderer.js"))
};
global::Uno.UX.Resource.SetGlobalKey(AngularRenderer, "AngularRenderer");
}
var AngularBootstrap = new JavaScript() {
File = new global::Uno.UX.BundleFileSource(import global::Uno.BundleFile("AngularBootstrap.js"))
};
Behaviors.Add(AngularBootstrap);
}
}
//}
93 changes: 93 additions & 0 deletions generators/app/templates/fuse/AngularBootstrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
'use strict';
var Observable = require('FuseJS/Observable');
window.isFuse = true;
window.fusejs = window.fusejs || {
isFuse: true,
renderer: null,
requireCacheAfterVendor: {},
timers: [],
context: Observable() // {
//id: 'root',
//depth: 0,
//children: Observable()
//}
};

function debounce(fn, delay) {
return function() {
var self = this;
var args = arguments;
if (window.fusejs.timers.length > 0) {
for (var i = 0; i < window.fusejs.timers.length; i++) {
clearTimeout(window.fusejs.timers[i]);
}
window.fusejs.timers = [];
}
var timer = setTimeout(function() {
fn.apply(self, args);
}, delay);
window.fusejs.timers.push(timer);
};
}

function loadRenderer() {
if (!window.fusejs.angularRenderer) {
// window.context = {
// id: 'root',
// depth: 0,
// children: Observable()
// };
var AngularRendererClass = require('AngularRenderer');
window.fusejs.angularRenderer = new AngularRendererClass(window.fusejs.context);
require('common');
require('vendor');
window.fusejs.requireCacheAfterVendor = {};

for (var moduleId in window.requireCache) {
if (window.requireCache[moduleId]) {
window.fusejs.requireCacheAfterVendor[moduleId] = true;
}
}
}
}

function reloadBundle() {
/// BUNDLE: REFRESH ON EVERY CHANGE
if (window.clearWebpackCache) {
window.clearWebpackCache(window.fusejs.requireCacheAfterVendor);
}
require('bundle');
}

function bootstrapAngular() {
/// DISPOSE PREVIOUS APPLICATION : ON EVERY CHANGE
if (window.fusejs.angularRenderer) {
window.fusejs.angularRenderer.reset();
//window.fusejs.context.children.clear();
window.fusejs.context.clear();
if (window.fusejs.applicationRef) {
try {
window.fusejs.applicationRef.dispose();
} catch (err) {
}
}
}
/// BOOTSTRAP APPLICATION : ON EVERY CHANGE
return window.fusejs.bootstraper.bootstrap(window.fusejs.rootComponent);
}

function reloadAngular() {
window.isLoading = true;
loadRenderer();
reloadBundle();
bootstrapAngular().then(function(applicationRef) {
window.fusejs.applicationRef = applicationRef;
window.fusejs.angularRenderer.print();
});
}
try {
debounce(reloadAngular, 1000)();
} catch (err) {

}
module.exports = window.fusejs.context;
Loading

0 comments on commit b902ba7

Please sign in to comment.