Socket
Socket
Sign inDemoInstall

alloy

Package Overview
Dependencies
Maintainers
4
Versions
269
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alloy - npm Package Compare versions

Comparing version 0.1.20 to 0.1.21

Alloy/builtins/dialogs.js

115

Alloy/commands/compile/compilerUtils.js

@@ -9,3 +9,5 @@ var U = require('../../utils'),

pro = require("../../uglify-js/uglify-js").uglify,
_ = require('../../lib/alloy/underscore')._;
_ = require('../../lib/alloy/underscore')._,
optimizer = require('./optimizer'),
CONST = require('../../common/constants');

@@ -61,3 +63,3 @@ ///////////////////////////////////////

compile: 'OS_ANDROID',
runtime: "TI.Platform.osname === 'android'"
runtime: "Ti.Platform.osname === 'android'"
},

@@ -92,3 +94,3 @@ ios: {

req = node.getAttribute('require'),
id = node.getAttribute('id') || state.defaultId || req || exports.generateUniqueId(),
id = node.getAttribute('id') || state.defaultId || exports.generateUniqueId(),
platform = node.getAttribute('platform'),

@@ -254,11 +256,5 @@ platformObj = {};

// validation
var indexXml = path.join(obj.dir.views,'index.xml');
if (!path.existsSync(indexXml)) {
U.die('Alloy project must have an index.xml at ' + indexXml);
}
U.ensureDir(obj.dir.resources);
U.ensureDir(obj.dir.resourcesAlloy);
if (path.existsSync(obj.dir.config)) {
exports.generateConfig(obj.dir.config, alloyConfig, obj.dir.resourcesAlloy);
}
exports.generateConfig(obj.dir.config, alloyConfig, obj.dir.resourcesAlloy);

@@ -271,7 +267,4 @@ // keep a copy of the config for this module

// TODO: instead of dumping this full JSON in every file, create a commonjs
// module for the config, then load it in each file. The loaded module
// can then be assigned to CFG$ (or whatever else we want to name it)
exports.generateConfig = function(configDir, alloyConfig, resourceAlloyDir) {
var cf = path.join(configDir,'config.json');
var cf = path.join(configDir,'config.'+CONST.FILE_EXT.CONFIG);
var o = {};

@@ -289,3 +282,3 @@

} else {
logger.warn('No "app/config/config.json" file found');
logger.warn('No "app/config/config."' + CONST.FILE_EXT.CONFIG + ' file found');
}

@@ -301,2 +294,10 @@

exports.loadController = function(file) {
if (path.existsSync(file)) {
return fs.readFileSync(file,'utf8');
} else {
return '';
}
};
exports.loadStyle = function(p) {

@@ -328,3 +329,3 @@ if (path.existsSync(p)) {

var pre = dot[1];
if (pre === 'Ti' || pre === 'Titanium') {
if (pre === 'Ti' || pre === 'Titanium' || pre === 'Alloy') {
return pre + name;

@@ -449,2 +450,84 @@ } else {

exports.processSourceCode = function(code, config, fn)
{
function show_copyright(comments) {
var ret = "";
for (var i = 0; i < comments.length; ++i) {
var c = comments[i];
if (c.type == "comment1") {
ret += "//" + c.value + "\n";
} else {
ret += "/*" + c.value + "*/";
}
}
return ret;
};
var c = jsp.tokenizer(code)();
// extract header copyright so we can preserve it (if at the top of the file)
var copyrights = show_copyright(c.comments_before);
var ast = jsp.parse(code);
var newCode = exports.formatAST(ast,config,fn);
return (copyrights ? copyrights + '\n' : '' ) + newCode;
};
exports.formatAST = function(ast,config,fn)
{
// use the general defaults from the uglify command line
var defines = {},
DEFINES,
config;
config = config || {};
config.deploytype = config.deploytype || 'development';
config.beautify = config.beautify || true;
DEFINES = {
OS_IOS : config.platform == 'ios',
OS_ANDROID: config.platform == 'android',
OS_MOBILEWEB: config.platform == 'mobileweb',
ENV_DEV: config.deploytype == 'development',
ENV_DEVELOPMENT: config.deploytype == 'development',
ENV_TEST: config.deploytype == 'test',
ENV_PROD: config.deploytype == 'production',
ENV_PRODUCTION: config.deploytype == 'production'
};
for (var k in DEFINES) {
defines[k] = [ "num", DEFINES[k] ? 1 : 0 ];
}
var isDev = config.deploytype === 'development';
var options =
{
ast: false,
consolidate: !isDev,
mangle: !isDev,
mangle_toplevel: false,
no_mangle_functions: false,
squeeze: !isDev,
make_seqs: !isDev,
dead_code: true,
unsafe: false,
defines: defines,
lift_vars: false,
codegen_options: {
ascii_only: false,
beautify: config.beautify,
indent_level: 4,
indent_start: 0,
quote_keys: false,
space_colon: false,
inline_script: false
},
make: false,
output: false,
except: ['Ti','Titanium','Alloy']
};
ast = pro.ast_mangle(ast,options); // get a new AST with mangled names
ast = optimizer.optimize(ast, DEFINES, fn); // optimize our titanium based code
ast = pro.ast_squeeze(ast); // get an AST with compression optimizations
return pro.gen_code(ast,options.codegen_options);
};
///////////////////////////////////////

@@ -451,0 +534,0 @@ ////////// private functions //////////

219

Alloy/commands/compile/index.js

@@ -11,5 +11,8 @@ var path = require('path'),

CompilerMakeFile = require('./CompilerMakeFile'),
CU = require('./compilerUtils');
CU = require('./compilerUtils'),
CONST = require('../../common/constants');
var alloyRoot = path.join(__dirname,'..','..'),
viewRegex = new RegExp('\\.' + CONST.FILE_EXT.VIEW + '$'),
modelRegex = new RegExp('\\.' + CONST.FILE_EXT.MODEL + '$'),
compileConfig = {};

@@ -22,4 +25,3 @@

var inputPath = args.length > 0 ? args[0] : U.resolveAppHome(),
alloyConfigPath = path.join(inputPath,'config','alloy.json'),
generatedCFG = '',
alloyConfigPath = path.join(inputPath,'config','alloy.' + CONST.FILE_EXT.CONFIG),
alloyConfig = {},

@@ -31,5 +33,8 @@ outputPath, tmpPath, compilerMakeFile;

U.die('inputPath "' + inputPath + '" does not exist');
} else if (!path.existsSync(path.join(inputPath,'views','index.' + CONST.FILE_EXT.VIEW))) {
U.die('inputPath has no views/index.' + CONST.FILE_EXT.VIEW + ' file.');
}
if (!program.outputPath) {
tmpPath = path.join(inputPath,'views','index.xml');
tmpPath = path.join(inputPath,'views','index.'+CONST.FILE_EXT.VIEW);
if (path.existsSync(tmpPath)) {

@@ -84,10 +89,16 @@ outputPath = path.join(inputPath,'..');

// Process all models
var models = processModels();
// Process all views, including all those belonging to widgets
var viewCollection = U.getWidgetDirectories(outputPath);
viewCollection.push({ dir: path.join(outputPath,'app') });
viewCollection.push({ dir: path.join(outputPath,CONST.ALLOY_DIR) });
_.each(viewCollection, function(collection) {
_.each(fs.readdirSync(path.join(collection.dir,'views')), function(view) {
if (/\.xml$/.test(view)) {
var basename = path.basename(view, '.xml');
parseView(basename, collection.dir, basename, collection.manifest);
//_.each(fs.readdirSync(path.join(collection.dir,'views')), function(view) {
_.each(wrench.readdirSyncRecursive(path.join(collection.dir,CONST.DIR.VIEW)), function(view) {
if (viewRegex.test(view)) {
console.log(view);
// var basename = path.basename(view, '.'+CONST.FILE_EXT.VIEW);
// parseView(basename, collection.dir, basename, collection.manifest);
parseView(view, collection.dir, collection.manifest);
}

@@ -98,9 +109,15 @@ });

// copy assets and libraries
U.copyAlloyDir(inputPath, ['assets','lib'], compileConfig.dir.resources);
U.copyAlloyDir(inputPath, 'vendor', path.join(compileConfig.dir.resources,'vendor'));
U.copyAlloyDir(inputPath, [CONST.DIR.ASSETS,CONST.DIR.LIB], compileConfig.dir.resources);
U.copyAlloyDir(inputPath, CONST.DIR.VENDOR, path.join(compileConfig.dir.resources,CONST.DIR.VENDOR));
// generate app.js
var appJS = path.join(compileConfig.dir.resources,"app.js");
var code = _.template(fs.readFileSync(path.join(alloyRoot,'template','app.js'),'utf8'),{});
code = U.processSourceCode(code, alloyConfig, 'app.js');
var code = _.template(fs.readFileSync(path.join(alloyRoot,'template','app.js'),'utf8'),{models:models});
try {
code = CU.processSourceCode(code, alloyConfig, 'app.js');
} catch(e) {
logger.error(code);
U.die(e);
}

@@ -127,23 +144,41 @@ // trigger our custom compiler makefile

///////////////////////////////////////
function parseView(viewName,dir,viewid,manifest) {
var template = {
viewCode: '',
controllerCode: '',
lifecycle: ''
};
var state = { parent: {} };
var vd = dir ? path.join(dir,'views') : compileConfig.dir.views;
var sd = dir ? path.join(dir,'styles') : compileConfig.dir.styles;
// function parseView(viewName,dir,viewId,manifest) {
function parseView(view,dir,manifest) {
// validate parameters
if (!view) { U.die('Undefined view passed to parseView()'); }
if (!dir) { U.die('Failed to parse view "' + view + '", no directory given'); }
var viewFile = path.join(vd,viewName+".xml");
if (!path.existsSync(viewFile)) {
logger.warn('No XML view file found for view ' + viewFile);
var basename = path.basename(view, '.'+CONST.FILE_EXT.VIEW);
dirname = path.dirname(view),
viewName = basename,
viewId = basename,
template = {
viewCode: '',
controllerCode: '',
onCreate: ''
},
state = { parent: {} },
files = {};
// create a list of file paths
_.each(['VIEW','STYLE','CONTROLLER'], function(fileType) {
var tmp = path.join(dir,CONST.DIR[fileType]);
if (dirname) { tmp = path.join(tmp,dirname); }
files[fileType] = path.join(tmp,viewName+'.'+CONST.FILE_EXT[fileType]);
});
files.COMPONENT = path.join(compileConfig.dir.resourcesAlloy,CONST.DIR.COMPONENT);
if (dirname) { files.COMPONENT = path.join(files.COMPONENT,dirname); }
files.COMPONENT = path.join(files.COMPONENT,viewName+'.js');
// validate view
if (!path.existsSync(files.VIEW)) {
logger.warn('No ' + CONST.FILE_EXT.VIEW + ' view file found for view ' + files.VIEW);
return;
}
var styleFile = path.join(sd,viewName+".json");
var styles = CU.loadStyle(styleFile);
state.styles = styles;
// Load the style and update the state
state.styles = CU.loadStyle(files.STYLE);
var xml = fs.readFileSync(viewFile,'utf8');
// read and parse the view file
var xml = fs.readFileSync(files.VIEW,'utf8');
var doc = new DOMParser().parseFromString(xml);

@@ -158,8 +193,9 @@

var docRoot = doc.documentElement;
var id = viewid || doc.documentElement.getAttribute('id') || viewName;
var id = viewId || doc.documentElement.getAttribute('id') || viewName;
// TODO: Can we move this out of the parseView() call?
if (viewName === 'index') {
template.viewCode += findAndLoadModels();
}
// handle component-level events
_.each(['onCreate'], function(evt) {
var attr = docRoot.getAttribute(evt);
template[evt] = attr ? attr + '($);\n' : '';
});

@@ -172,11 +208,11 @@ // Generate Titanium code from the markup

state,
i === 0 ? (viewid||viewName) : undefined,
i === 0 ? (viewId||viewName) : undefined,
i === 0);
}
template.controllerCode += generateController(viewName,dir,id);
template.controllerCode += CU.loadController(files.CONTROLLER);
// create commonjs module for this view/controller
// create component module code for this view/controller or widget
var code = _.template(fs.readFileSync(path.join(compileConfig.dir.template, 'component.js'), 'utf8'), template);
try {
code = U.processSourceCode(code, compileConfig.alloyConfig, viewName+'.js');
code = CU.processSourceCode(code, compileConfig.alloyConfig, files.COMPONENT);
} catch (e) {

@@ -187,23 +223,14 @@ logger.error(code);

// Write the view or widget to its runtime file
if (manifest) {
wrench.mkdirSyncRecursive(path.join(compileConfig.dir.resourcesAlloy, 'widgets', manifest.id, 'components'), 0777);
CU.copyWidgetAssets(path.join(dir,'assets'), compileConfig.dir.resources, manifest.id);
fs.writeFileSync(path.join(compileConfig.dir.resourcesAlloy, 'widgets', manifest.id, 'components', viewName + '.js'), code);
var widgetDir = dirname ? path.join(CONST.DIR.COMPONENT,dirname) : CONST.DIR.COMPONENT;
wrench.mkdirSyncRecursive(path.join(compileConfig.dir.resourcesAlloy, CONST.DIR.WIDGET, manifest.id, widgetDir), 0777);
CU.copyWidgetAssets(path.join(dir,CONST.DIR.ASSETS), compileConfig.dir.resources, manifest.id);
fs.writeFileSync(path.join(compileConfig.dir.resourcesAlloy, CONST.DIR.WIDGET, manifest.id, widgetDir, viewName + '.js'), code);
} else {
fs.writeFileSync(path.join(compileConfig.dir.resourcesAlloy, 'components', viewName + '.js'), code);
wrench.mkdirSyncRecursive(path.dirname(files.COMPONENT), 0777);
fs.writeFileSync(files.COMPONENT, code);
}
}
function generateController(name, dir, id) {
var controllerDir = dir ? path.join(dir,'controllers') : compileConfig.dir.controllers,
p = path.join(controllerDir,name+'.js'),
code = '';
if (path.existsSync(p)) {
return fs.readFileSync(p,'utf8');
} else {
return '';
}
}
function findModelMigrations(name) {

@@ -213,3 +240,3 @@ try {

var files = fs.readdirSync(migrationsDir);
var part = '_'+name+'.js';
var part = '_'+name+'.'+CONST.FILE_EXT.MIGRATION;

@@ -246,50 +273,48 @@ // look for our model

function findAndLoadModels() {
var f = compileConfig.dir.models;
var code = '';
if (!path.existsSync(f)) {
wrench.mkdirSyncRecursive(f, 777);
}
function processModels() {
var models = [];
var modelRuntimeDir = path.join(compileConfig.dir.resourcesAlloy,'models');
var modelTemplateFile = path.join(alloyRoot,'template','model.js');
U.ensureDir(compileConfig.dir.models);
var files = fs.readdirSync(f);
for (var c=0;c<files.length;c++) {
var file = files[c];
if (file.indexOf(".json")>0) {
var fpath = path.join(f,file);
var part = file.substring(0,file.length-5);
var modelJs = path.join(f,part+'.js');
// Make sure we havea runtime models directory
var modelFiles = fs.readdirSync(compileConfig.dir.models);
if (modelFiles.length > 0) {
U.ensureDir(modelRuntimeDir);
}
var jm = fs.readFileSync(fpath);
var js = "";
try {
var stats = fs.lstatSync(modelJs);
if (stats.isFile()) {
js = fs.readFileSync(modelJs,'utf8');
}
}
catch(E) { }
// process each model
_.each(modelFiles, function(modelFile) {
if (!modelRegex.test(modelFile)) {
logger.warn('Non-model file "' + modelFile + '" in models directory');
return;
}
var fullpath = path.join(compileConfig.dir.models,modelFile);
var basename = path.basename(fullpath, '.'+CONST.FILE_EXT.MODEL);
var modelJsFile = path.join(compileConfig.dir.models,basename+'.js');
var modelConfig = fs.readFileSync(fullpath);
var modelJs = 'function(Model){}';
var migrations = findModelMigrations(part);
var theid = U.properCase(part), theidc = U.properCase(part)+'Collection';
var symbol1 = CU.generateVarName(theid);
var symbol2 = CU.generateVarName(theidc);
var codegen = symbol1 + " = M$('"+ part +"',\n" +
jm + "\n" +
", function("+part+"){\n" +
js + "\n" +
"},\n" +
"[ " + migrations.join("\n,") + " ]\n" +
");\n";
codegen+=symbol2 + " = BC$.extend({model:" + symbol1 + "});\n";
codegen+=symbol2+".prototype.model = " + symbol1+";\n";
codegen+=symbol2+".prototype.config = " + symbol1+".prototype.config;\n";
code += codegen;
// grab any additional model code from corresponding JS file, if it exists
if (path.existsSync(modelJsFile)) {
modelJs = fs.readFileSync(modelJsFile,'utf8');
}
}
return code;
}
// generate model code based on model.js template and migrations
var code = _.template(fs.readFileSync(modelTemplateFile,'utf8'), {
basename: basename,
modelConfig: modelConfig,
modelJs: modelJs,
migrations: findModelMigrations(basename)
});
// write the model to the runtime file
var casedBasename = U.properCase(basename);
fs.writeFileSync(path.join(modelRuntimeDir,casedBasename+'.js'), code);
models.push(casedBasename);
});
return models;
};
function copyBuiltins() {

@@ -296,0 +321,0 @@ // this method will allow an app to do a require

@@ -42,7 +42,7 @@ // TODO: pass errors back to the calling function in the compile

// Check this for details: https://jira.appcelerator.org/browse/ALOY-80
var extraStyle = CU.createVariableStyle([
state.extraStyle = CU.createVariableStyle([
['masterView', subParents[0].symbol],
['detailView', subParents[1].symbol]
]);
var splitState = require('./default').parse(node, state, extraStyle);
var splitState = require('./default').parse(node, state);
code += splitState.code;

@@ -49,0 +49,0 @@

@@ -6,2 +6,3 @@ var jsp = require("../../uglify-js/uglify-js").parser,

U = require('../../utils.js'),
CU = require('./compilerUtils'),
_ = require("../../lib/alloy/underscore")._

@@ -123,3 +124,3 @@ ;

return U.formatAST(ast,config,fn);
return CU.formatAST(ast,config,fn);
}

@@ -126,0 +127,0 @@

@@ -5,3 +5,3 @@ var _ = require("../../lib/alloy/underscore")._,

// TODO: generate TARGETS array by reading the Alloy/commands/generate files
var TARGETS = ['controller', 'view', 'model', 'migration', 'vc', 'styles', 'widget'];
var TARGETS = ['component', 'controller', 'view', 'model', 'migration', 'styles', 'widget'];

@@ -31,5 +31,5 @@ function generate(args, program) {

// launch requested generator
(require('./' + target))(name, args.slice(2), program);
(require('./targets/' + target))(name, args.slice(2), program);
}
module.exports = generate;

@@ -94,3 +94,3 @@ var path = require('path'),

INDEX_XML = fs.readFileSync(path.join(defaultDir,'index.xml'),'utf8'),
INDEX_JSON = fs.readFileSync(path.join(defaultDir,'index.json'),'utf8'),
INDEX_JSON = fs.readFileSync(path.join(defaultDir,'index.tss'),'utf8'),
INDEX_C = fs.readFileSync(path.join(defaultDir,'index.js'),'utf8'),

@@ -128,3 +128,3 @@ README = fs.readFileSync(path.join(templateDir, 'README'),'utf8'),

fs.writeFileSync(path.join(appPath,'views','index.xml'),INDEX_XML,'utf-8');
fs.writeFileSync(path.join(appPath,'styles','index.json'),INDEX_JSON,'utf-8');
fs.writeFileSync(path.join(appPath,'styles','index.tss'),INDEX_JSON,'utf-8');
fs.writeFileSync(path.join(appPath,'controllers','index.js'),INDEX_C,'utf-8');

@@ -131,0 +131,0 @@ fs.writeFileSync(path.join(appPath,'config','alloy.json'),U.stringifyJSON(defaultConfig),'utf-8');

var colors = require('colors');
exports.DEBUG = 3;

@@ -5,0 +4,0 @@ exports.INFO = 2;

var _ = require("alloy/underscore")._,
Backbone = require("alloy/backbone"),
osname = Ti.Platform.osname,
SQLSync,
SQLSyncInit,
FileSysSync;
STR = require('alloy/string');
module.exports._ = _;
module.exports.Backbone = Backbone;
exports._ = _;
exports.Backbone = Backbone;
// TODO: we might want to eliminate this as all sync operations can be handles
// in the adapter-specific code
Backbone.Collection.notify = _.extend({}, Backbone.Events);

@@ -20,35 +19,15 @@

var type = (m.adapter ? m.adapter.type : null) || 'sql';
switch (type) {
case 'sql': {
SQLSync = require("alloy/sync/sql");
SQLSync.sync(model,method,opts);
break;
}
case 'filesystem': {
FileSysSync = require("alloy/sync/filesys");
FileSysSync.sync(model,method,opts);
break;
}
default: {
Ti.API.error("No sync adapter found for: "+type);
return;
}
}
require('alloy/sync/'+type).sync(model,method,opts);
// TODO: we might want to eliminate this as all sync operations can be handles
// in the adapter-specific code
Backbone.Collection.notify.trigger('sync', {method:method,model:model});
};
module.exports.M = function(name,config,modelFn,migrations) {
exports.M = function(name,config,modelFn,migrations) {
var type = (config.adapter ? config.adapter.type : null) || 'sql';
if (type === 'sql' && !SQLSyncInit) {
SQLSyncInit = true;
SQLSync.init();
}
var Model = Backbone.Model.extend( {
var adapter = require('alloy/sync/'+type);
var extendObj = {
defaults: config.defaults,
validate: function(attrs) {

@@ -66,18 +45,20 @@ if (typeof __validate !== 'undefined') {

}
});
if (migrations && migrations.length > 0) {
if (type == 'sql') {
SQLSync.migrate(migrations);
}
}
};
// cosntruct the model based on the current adapter type
if (migrations) { extendObj.migrations = migrations; }
if (_.isFunction(adapter.beforeModelCreate)) { config = adapter.beforeModelCreate(config) || config; }
var Model = Backbone.Model.extend(extendObj);
config.Model = Model; // needed for fetch operations to initialize the collection from persistent store
config.data = {}; // for localStorage or case where entire collection is needed to maintain store
Model.prototype.config = config;
modelFn(Model);
if (_.isFunction(adapter.afterModelCreate)) { adapter.afterModelCreate(Model); }
// execute any custom scripts on the model
Model = modelFn(Model) || Model;
return Model;
};
module.exports.A = function(t,type,parent) {
exports.A = function(t,type,parent) {
_.extend(t,Backbone.Events);

@@ -108,6 +89,6 @@

if (osname === 'android') {
if (OS_IOS) {
al(e, wcb);
} else {
al.call(t, e, wcb);
} else {
al(e, wcb);
}

@@ -123,6 +104,6 @@

if (osname === 'android') {
if (OS_IOS) {
rl(e, f);
} else {
rl.call(t, e, f);
} else {
rl(e, f);
}

@@ -140,1 +121,16 @@

exports.getWidget = function(id) {
return require('alloy/widgets/' + id + '/components/widget');
}
exports.getComponent = function(name) {
return require('alloy/components/' + name);
}
exports.getModel = function(name) {
return require('alloy/models/' + STR.ucfirst(name)).Model;
}
exports.getCollection = function(name) {
return require('alloy/models/' + STR.ucfirst(name)).Collection;
}

@@ -8,3 +8,3 @@ /**

function InitDB() {
function InitDB(config) {
if (!db) {

@@ -22,3 +22,3 @@ if (Ti.Platform.osname === 'mobileweb' || typeof Ti.Database === 'undefined') {

}
return db;
return {};
}

@@ -110,3 +110,3 @@

this.columns = model.config.columns;
var self = this;

@@ -241,5 +241,6 @@

module.exports.init = InitDB;
module.exports.migrate = Migrate;
module.exports.beforeModelCreate = InitDB;
module.exports.afterModelCreate = function(Model) {
Migrate(Model.migrations);
};
module.exports.sync = Sync;

@@ -6,3 +6,7 @@ /**

*/
require('alloy').CFG = require('alloy/CFG');
var Alloy = require('alloy'),
_ = require('alloy/underscore')._;
// TODO: Use AST to create these Alloy namespace shortcuts at compile time
Alloy.CFG = require('alloy/CFG');
(require('alloy/components/index')).create();

@@ -8,7 +8,4 @@ // TODO: Optimize out lifecycle events if they are not defined

M$ = Alloy.M,
BC$ = Alloy.Backbone.Collection,
Lifecycle = {};
BC$ = Alloy.Backbone.Collection;
<%= lifecycle %>
exports.create = function() {

@@ -51,5 +48,3 @@ var L$ = {},

if (_.isFunction(Lifecycle.beforeCreate)) {
Lifecycle.beforeCreate($);
}
<%= onCreate %>

@@ -62,7 +57,3 @@ // generated from view markup

if (_.isFunction(Lifecycle.afterCreate)) {
Lifecycle.afterCreate($);
}
return $;
};

@@ -13,3 +13,3 @@ // The island of misfit toys... for functions

_ = require("./lib/alloy/underscore")._,
optimizer = require('./optimizer.js')
CONST = require('./common/constants')
;

@@ -107,24 +107,4 @@

exports.processSourceCode = function(code, config, fn)
{
function show_copyright(comments) {
var ret = "";
for (var i = 0; i < comments.length; ++i) {
var c = comments[i];
if (c.type == "comment1") {
ret += "//" + c.value + "\n";
} else {
ret += "/*" + c.value + "*/";
}
}
return ret;
};
var c = jsp.tokenizer(code)();
// extract header copyright so we can preserve it (if at the top of the file)
var copyrights = show_copyright(c.comments_before);
var ast = jsp.parse(code);
var newCode = exports.formatAST(ast,config,fn);
return (copyrights ? copyrights + '\n' : '' ) + newCode;
};
exports.copyFileSync = function(srcFile, destFile)

@@ -196,18 +176,2 @@ {

exports.pad = function(x)
{
if (x < 10)
{
return '0' + x;
}
return x;
}
exports.generateMigrationFileName = function(t)
{
var d = new Date;
var s = String(d.getUTCFullYear()) + String(exports.pad(d.getUTCMonth())) + String(exports.pad(d.getUTCDate())) + String(exports.pad(d.getUTCHours())) + String(exports.pad(d.getUTCMinutes())) + String(d.getUTCMilliseconds())
return s + '_' + t + '.js';
}
exports.die = function(msg)

@@ -219,60 +183,3 @@ {

exports.formatAST = function(ast,config,fn)
{
// use the general defaults from the uglify command line
var defines = {},
DEFINES,
config;
config = config || {};
config.deploytype = config.deploytype || 'development';
config.beautify = config.beautify || true;
DEFINES = {
OS_IOS : config.platform == 'ios',
OS_ANDROID: config.platform == 'android',
OS_MOBILEWEB: config.platform == 'mobileweb',
ENV_DEV: config.deploytype == 'development',
ENV_DEVELOPMENT: config.deploytype == 'development',
ENV_TEST: config.deploytype == 'test',
ENV_PRODUCTION: config.deploytype == 'production'
};
for (var k in DEFINES) {
defines[k] = [ "num", DEFINES[k] ? 1 : 0 ];
}
var isDev = config.deploytype === 'development';
var options =
{
ast: false,
consolidate: !isDev,
mangle: !isDev,
mangle_toplevel: false,
no_mangle_functions: false,
squeeze: !isDev,
make_seqs: !isDev,
dead_code: true,
unsafe: false,
defines: defines,
lift_vars: false,
codegen_options: {
ascii_only: false,
beautify: config.beautify,
indent_level: 4,
indent_start: 0,
quote_keys: false,
space_colon: false,
inline_script: false
},
make: false,
output: false,
except: ['Ti','Titanium']
};
ast = pro.ast_mangle(ast,options); // get a new AST with mangled names
ast = optimizer.optimize(ast, DEFINES, fn); // optimize our titanium based code
ast = pro.ast_squeeze(ast); // get an AST with compression optimizations
return pro.gen_code(ast,options.codegen_options);
};

@@ -16,3 +16,3 @@ {

],
"version": "0.1.20",
"version": "0.1.21",
"author": "Appcelerator, Inc. <info@appcelerator.com>",

@@ -19,0 +19,0 @@ "maintainers": [

@@ -21,3 +21,3 @@ // Function to keep a Ti.TableView in sync with Backbone CRUD opperations

// listener for server to persistant store sync requests
$.BookCollection.notify.on('sync', function(e) {
Alloy.getCollection('Book').notify.on('sync', function(e) {
CRUDops[e.method](e.model);

@@ -29,6 +29,6 @@ });

// Use new on the generated classes to create the model or collection object.
var books = new $.BookCollection;
var books = new (Alloy.getCollection('Book'));
// CREATE - create a model
var book = new $.Book({book:"Jungle Book", author:"Kipling"});
// create a model
var book = new (Alloy.getModel('Book'))({book:"Jungle Book", author:"Kipling"});

@@ -41,4 +41,5 @@ // Add a model to a Backbone collection.

// READ - fetch triggers the CRUD read operation causing a sever to persistent store sync up.
// Fetch only returns models that are in the new state.
// fetch triggers the CRUD read operation causing a sever to persistent store sync up.
// Everything in the current Backbone model state will be overwritten with the
// fetched "server" state, triggering a "read" sync operation
books.fetch();

@@ -45,0 +46,0 @@

@@ -1,20 +0,19 @@

// attach a validation function to the model
__validate = function (key, value)
{
if (key == "book")
function(Model) {
Model.__validate = function (key, value)
{
if (value.length <= 0)
return false;
}
if (key == "author")
{
if (value.length <= 0)
return false;
}
return true;
};
if (key == "book")
{
if (value.length <= 0)
return false;
}
if (key == "author")
{
if (value.length <= 0)
return false;
}
return true;
};
return Model;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc