Comparing version 0.1.13 to 0.2.0
require([ | ||
"Underscore", | ||
"underscore", | ||
"hr/hr", | ||
@@ -4,0 +4,0 @@ "hr/args", |
@@ -24,3 +24,3 @@ define([ | ||
render: function() { | ||
hr.Resources.load("codes", this.options.code).always(_.bind(function(content) { | ||
hr.Resources.load("codes", this.options.code).done(_.bind(function(content) { | ||
this.code = content; | ||
@@ -27,0 +27,0 @@ this.$el.html(hljs.highlightAuto(this.code).value); |
@@ -193,13 +193,17 @@ // Requires | ||
"text": path.resolve(vendors_path, "require-text"), | ||
"Underscore": path.resolve(vendors_path, "underscore"), | ||
"jQuery": path.resolve(vendors_path, "jquery"), | ||
"hr/hr": path.resolve(vendors_path, "hr"), | ||
"hr/args": path.resolve(config.base, "hr-args") | ||
"underscore": path.resolve(vendors_path, "underscore"), | ||
"jquery": path.resolve(vendors_path, "jquery"), | ||
"q": path.resolve(vendors_path, "Q"), | ||
"hr/hr": path.resolve(vendors_path, "hr"), | ||
"hr/args": path.resolve(config.base, "hr-args") | ||
}), | ||
shim: _.extend(config.shim || {}, { | ||
'Underscore': { | ||
'underscore': { | ||
exports: '_' | ||
}, | ||
'jQuery': { | ||
'jquery': { | ||
exports: '$' | ||
}, | ||
'q': { | ||
exports: 'Q' | ||
} | ||
@@ -206,0 +210,0 @@ }), |
@@ -5,3 +5,3 @@ { | ||
"description": "Client-side framework for structured applications.", | ||
"version": "0.1.13", | ||
"version": "0.2.0", | ||
"keywords": [ | ||
@@ -8,0 +8,0 @@ "clientside" |
@@ -1,2 +0,2 @@ | ||
define(function(args) { | ||
define(function() { | ||
var Config = { | ||
@@ -10,3 +10,3 @@ // Revision | ||
// Hr version | ||
"version": "0.1.8", | ||
"version": "0.2.0", | ||
@@ -13,0 +13,0 @@ // Log level |
define([ | ||
"q", | ||
"hr/shims", | ||
"hr/configs", | ||
"hr/core/class", | ||
"hr/core/view", | ||
"hr/core/application", | ||
"hr/core/head", | ||
"hr/core/history", | ||
"hr/core/router", | ||
"hr/core/model", | ||
"hr/core/collection", | ||
"hr/core/list", | ||
"hr/class", | ||
"hr/view", | ||
"hr/application", | ||
"hr/head", | ||
"hr/history", | ||
"hr/router", | ||
"hr/model", | ||
"hr/collection", | ||
"hr/list", | ||
"hr/logger", | ||
"hr/requests", | ||
"hr/urls", | ||
"hr/storage", | ||
"hr/cache", | ||
"hr/template", | ||
"hr/resources", | ||
"hr/queue", | ||
"hr/i18n", | ||
"hr/views" | ||
], function(Q, shims, configs, | ||
Class, View, Application, Head, History, Router, Model, Collection, ListView, | ||
Logger, Requests, Urls, Storage, Cache, Template, Resources, Queue, I18n, views) { | ||
"hr/utils/logger", | ||
"hr/utils/requests", | ||
"hr/utils/urls", | ||
"hr/utils/storage", | ||
"hr/utils/cache", | ||
"hr/utils/template", | ||
"hr/utils/resources", | ||
"hr/utils/deferred", | ||
"hr/utils/queue", | ||
"hr/utils/i18n", | ||
"hr/utils/views", | ||
"hr/vendors/underscore-more" | ||
], function(shims, configs, | ||
Class, View, Application, Head, History, Router, Model, Collection, ListView, | ||
Logger, Requests, Urls, Storage, Cache, Template, Resources, Deferred, Queue, I18n, views) { | ||
Q.onerror = function(err) { | ||
Logger.logging.error(err); | ||
}; | ||
var hr = { | ||
@@ -49,3 +53,2 @@ configs: configs, | ||
Resources: Resources, | ||
Deferred: Deferred, | ||
Queue: Queue, | ||
@@ -72,6 +75,4 @@ I18n: I18n, | ||
}; | ||
window.hr = hr; | ||
return hr; | ||
}) |
@@ -8,4 +8,5 @@ ({ | ||
paths: { | ||
'Underscore': '../vendors/underscore', | ||
'jQuery': '../vendors/jquery', | ||
'underscore': '../vendors/underscore', | ||
'jquery': '../vendors/jquery', | ||
'q': '../vendors/q', | ||
'text': '../vendors/require-text', | ||
@@ -15,9 +16,16 @@ 'hr': './', | ||
shim: { | ||
'Underscore': { | ||
'underscore': { | ||
exports: '_' | ||
}, | ||
'jQuery': { | ||
'q': { | ||
exports: 'Q' | ||
}, | ||
'jquery': { | ||
exports: '$' | ||
} | ||
}, | ||
wrap: { | ||
'start': "(function() {", | ||
'end': "}());" | ||
} | ||
}) |
120
src/shims.js
@@ -1,2 +0,5 @@ | ||
define(function() { | ||
define([ | ||
"underscore", | ||
"jquery", | ||
], function(_, $) { | ||
if(!Function.prototype.bind) { | ||
@@ -11,3 +14,118 @@ Function.prototype.bind = function(newThis) { | ||
var arrays, basicObjects, deepClone, deepExtend, deepExtendCouple, isBasicObject, sum, removeHtml, | ||
__slice = [].slice; | ||
deepClone = function(obj) { | ||
var func, isArr; | ||
if (!_.isObject(obj) || _.isFunction(obj)) { | ||
return obj; | ||
} | ||
if (_.isDate(obj)) { | ||
return new Date(obj.getTime()); | ||
} | ||
if (_.isRegExp(obj)) { | ||
return new RegExp(obj.source, obj.toString().replace(/.*\//, "")); | ||
} | ||
isArr = _.isArray(obj || _.isArguments(obj)); | ||
func = function(memo, value, key) { | ||
if (isArr) { | ||
memo.push(deepClone(value)); | ||
} else { | ||
memo[key] = deepClone(value); | ||
} | ||
return memo; | ||
}; | ||
return _.reduce(obj, func, isArr ? [] : {}); | ||
}; | ||
isBasicObject = function(object) { | ||
return (object != null && (object.prototype === {}.prototype || object.prototype === Object.prototype) && _.isObject(object) && !_.isArray(object) && !_.isFunction(object) && !_.isDate(object) && !_.isRegExp(object) && !_.isArguments(object)); | ||
}; | ||
basicObjects = function(object) { | ||
return _.filter(_.keys(object), function(key) { | ||
return isBasicObject(object[key]); | ||
}); | ||
}; | ||
arrays = function(object) { | ||
return _.filter(_.keys(object), function(key) { | ||
return _.isArray(object[key]); | ||
}); | ||
}; | ||
deepExtendCouple = function(destination, source, maxDepth) { | ||
var combine, recurse, sharedArrayKey, sharedArrayKeys, sharedObjectKey, sharedObjectKeys, _i, _j, _len, _len1; | ||
if (maxDepth == null) { | ||
maxDepth = 20; | ||
} | ||
if (maxDepth <= 0) { | ||
console.warn('_.deepExtend(): Maximum depth of recursion hit.'); | ||
return _.extend(destination, source); | ||
} | ||
sharedObjectKeys = _.intersection(basicObjects(destination), basicObjects(source)); | ||
recurse = function(key) { | ||
return source[key] = deepExtendCouple(destination[key], source[key], maxDepth - 1); | ||
}; | ||
for (_i = 0, _len = sharedObjectKeys.length; _i < _len; _i++) { | ||
sharedObjectKey = sharedObjectKeys[_i]; | ||
recurse(sharedObjectKey); | ||
} | ||
sharedArrayKeys = _.intersection(arrays(destination), arrays(source)); | ||
combine = function(key) { | ||
return source[key]; | ||
// Replace array and not replaced | ||
//return source[key] = _.union(destination[key], source[key]); | ||
}; | ||
for (_j = 0, _len1 = sharedArrayKeys.length; _j < _len1; _j++) { | ||
sharedArrayKey = sharedArrayKeys[_j]; | ||
combine(sharedArrayKey); | ||
} | ||
return _.extend(destination, source); | ||
}; | ||
deepExtend = function() { | ||
var finalObj, maxDepth, objects, _i; | ||
objects = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), maxDepth = arguments[_i++]; | ||
if (!_.isNumber(maxDepth)) { | ||
objects.push(maxDepth); | ||
maxDepth = 20; | ||
} | ||
if (objects.length <= 1) { | ||
return objects[0]; | ||
} | ||
if (maxDepth <= 0) { | ||
return _.extend.apply(this, objects); | ||
} | ||
finalObj = objects.shift(); | ||
while (objects.length > 0) { | ||
finalObj = deepExtendCouple(finalObj, deepClone(objects.shift()), maxDepth); | ||
} | ||
return finalObj; | ||
}; | ||
sum = function(obj) { | ||
if (!$.isArray(obj) || obj.length == 0) return 0; | ||
return _.reduce(obj, function(sum, n) { | ||
return sum += n; | ||
}); | ||
}; | ||
removeHtml = function(t) { | ||
return $("<div>").html(t).text(); | ||
}, | ||
_.mixin({ | ||
deepClone: deepClone, | ||
isBasicObject: isBasicObject, | ||
basicObjects: basicObjects, | ||
arrays: arrays, | ||
deepExtend: deepExtend, | ||
sum: sum, | ||
removeHtml: removeHtml | ||
}); | ||
return _; | ||
return {}; | ||
}); |
Sorry, the diff of this file is too big to display
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
7
1011373
128
26287
2
17