Comparing version 0.1.14 to 0.2.0
@@ -23,3 +23,6 @@ /* | ||
var BugPackApi = {}; | ||
/** | ||
* @constructor | ||
*/ | ||
var BugPackApi = function() {}; | ||
@@ -26,0 +29,0 @@ |
@@ -18,3 +18,2 @@ /* | ||
var BugPackSourceProcessor = require('./BugPackSourceProcessor'); | ||
var BugPackPackage = require('./BugPackPackage'); | ||
var BugPackRegistry = require('./BugPackRegistry'); | ||
@@ -21,0 +20,0 @@ var BugPackRegistryFile = require('./BugPackRegistryFile'); |
@@ -9,80 +9,91 @@ /* | ||
//------------------------------------------------------------------------------- | ||
// Declare Class | ||
// Context | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @constructor | ||
* @param {string} key | ||
*/ | ||
var BugPackKey = function(key) { | ||
require('./BugPackFix').fix(module, "./BugPackKey", function(module) { | ||
var keyParts = key.split('.'); | ||
var packageName = ""; | ||
var exportName = keyParts.pop(); | ||
if (keyParts.length > 0) { | ||
packageName = keyParts.join('.'); | ||
} | ||
//------------------------------------------------------------------------------- | ||
// Declare Class | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @private | ||
* @type {string} | ||
* @constructor | ||
* @param {string} key | ||
*/ | ||
this.exportName = exportName; | ||
var BugPackKey = function(key) { | ||
//------------------------------------------------------------------------------- | ||
// Private Properties | ||
//------------------------------------------------------------------------------- | ||
var keyParts = key.split('.'); | ||
var packageName = ""; | ||
var exportName = keyParts.pop(); | ||
if (keyParts.length > 0) { | ||
packageName = keyParts.join('.'); | ||
} | ||
/** | ||
* @private | ||
* @type {string} | ||
*/ | ||
this.exportName = exportName; | ||
/** | ||
* @private | ||
* @type {string} | ||
*/ | ||
this.key = key; | ||
/** | ||
* @private | ||
* @type {string} | ||
*/ | ||
this.packageName = packageName; | ||
}; | ||
//------------------------------------------------------------------------------- | ||
// Getters and Setters | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @private | ||
* @type {string} | ||
* @return {string} | ||
*/ | ||
this.key = key; | ||
BugPackKey.prototype.getExportName = function() { | ||
return this.exportName; | ||
}; | ||
/** | ||
* @private | ||
* @type {string} | ||
* @return {string} | ||
*/ | ||
this.packageName = packageName; | ||
}; | ||
BugPackKey.prototype.getKey = function() { | ||
return this.key; | ||
}; | ||
/** | ||
* @return {string} | ||
*/ | ||
BugPackKey.prototype.getPackageName = function() { | ||
return this.packageName; | ||
}; | ||
//------------------------------------------------------------------------------- | ||
// Getters and Setters | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @return {string} | ||
*/ | ||
BugPackKey.prototype.getExportName = function() { | ||
return this.exportName; | ||
}; | ||
//------------------------------------------------------------------------------- | ||
// Convenience Methods | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @return {string} | ||
*/ | ||
BugPackKey.prototype.getKey = function() { | ||
return this.key; | ||
}; | ||
/** | ||
* @return {boolean} | ||
*/ | ||
BugPackKey.prototype.isWildCard = function() { | ||
return (this.exportName === "*"); | ||
}; | ||
/** | ||
* @return {string} | ||
*/ | ||
BugPackKey.prototype.getPackageName = function() { | ||
return this.packageName; | ||
}; | ||
//------------------------------------------------------------------------------- | ||
// Exports | ||
//------------------------------------------------------------------------------- | ||
//------------------------------------------------------------------------------- | ||
// Convenience Methods | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @return {boolean} | ||
*/ | ||
BugPackKey.prototype.isWildCard = function() { | ||
return (this.exportName === "*"); | ||
}; | ||
//------------------------------------------------------------------------------- | ||
// Exports | ||
//------------------------------------------------------------------------------- | ||
module.exports = BugPackKey; | ||
module.exports = BugPackKey; | ||
}); |
@@ -9,105 +9,116 @@ /* | ||
//------------------------------------------------------------------------------- | ||
// Requires | ||
// Context | ||
//------------------------------------------------------------------------------- | ||
var BugPackPackage = require('./BugPackPackage'); | ||
require('./BugPackFix').fix(module, "./BugPackLibrary", function(module) { | ||
//------------------------------------------------------------------------------- | ||
// Requires | ||
//------------------------------------------------------------------------------- | ||
//------------------------------------------------------------------------------- | ||
// Declare Class | ||
//------------------------------------------------------------------------------- | ||
var BugPackPackage = require('./BugPackPackage'); | ||
/** | ||
* @constructor | ||
*/ | ||
var BugPackLibrary = function() { | ||
//------------------------------------------------------------------------------- | ||
// Declare Class | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @private | ||
* @type {BugPackPackage} | ||
* @constructor | ||
*/ | ||
this.corePackage = new BugPackPackage(""); | ||
var BugPackLibrary = function() { | ||
//------------------------------------------------------------------------------- | ||
// Private Properties | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @private | ||
* @type {BugPackPackage} | ||
*/ | ||
this.corePackage = new BugPackPackage(""); | ||
/** | ||
* @private | ||
* @type {Object} | ||
*/ | ||
this.packages = {}; | ||
}; | ||
//------------------------------------------------------------------------------- | ||
// Public Methods | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @private | ||
* @type {Object} | ||
* @param {string} packageName | ||
* @return {BugPackPackage} | ||
*/ | ||
this.packages = {}; | ||
}; | ||
BugPackLibrary.prototype.createPackage = function(packageName) { | ||
var _this = this; | ||
var packageParts = packageName.split("."); | ||
var currentPackageString = ""; | ||
var first = true; | ||
var parentPackage = this.corePackage; | ||
packageParts.forEach(function(packagePart) { | ||
if (first) { | ||
first = false; | ||
} else { | ||
currentPackageString += "."; | ||
} | ||
currentPackageString += packagePart; | ||
if (!_this.hasPackage(currentPackageString)) { | ||
var bugPackPackage = new BugPackPackage(currentPackageString); | ||
_this.packages[bugPackPackage.getName()] = bugPackPackage; | ||
parentPackage.addSubPackage(bugPackPackage); | ||
parentPackage = bugPackPackage; | ||
} | ||
}); | ||
return parentPackage; | ||
}; | ||
/** | ||
* @param {string} packageName | ||
* @return {BugPackPackage} | ||
*/ | ||
BugPackLibrary.prototype.getPackage = function(packageName) { | ||
if (packageName === "") { | ||
return this.corePackage; | ||
} else if (this.hasPackage(packageName)) { | ||
return this.packages[packageName]; | ||
} | ||
return null; | ||
}; | ||
//------------------------------------------------------------------------------- | ||
// Public Methods | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @param {string} packageName | ||
* @return {BugPackPackage} | ||
*/ | ||
BugPackLibrary.prototype.createPackage = function(packageName) { | ||
var _this = this; | ||
var packageParts = packageName.split("."); | ||
var currentPackageString = ""; | ||
var first = true; | ||
var parentPackage = this.corePackage; | ||
packageParts.forEach(function(packagePart) { | ||
if (first) { | ||
first = false; | ||
/** | ||
* @param {string} packageName | ||
* @return {boolean} | ||
*/ | ||
BugPackLibrary.prototype.hasPackage = function(packageName) { | ||
if (packageName === "") { | ||
return true; | ||
} else { | ||
currentPackageString += "."; | ||
return Object.prototype.hasOwnProperty.call(this.packages, packageName); | ||
} | ||
currentPackageString += packagePart; | ||
if (!_this.hasPackage(currentPackageString)) { | ||
var bugPackPackage = new BugPackPackage(currentPackageString); | ||
_this.packages[bugPackPackage.getName()] = bugPackPackage; | ||
parentPackage.addSubPackage(bugPackPackage); | ||
parentPackage = bugPackPackage; | ||
}; | ||
/** | ||
* @param {string} packageName | ||
* @param {string} exportName | ||
* @param {*} bugPackExport | ||
*/ | ||
BugPackLibrary.prototype.registerExport = function(packageName, exportName, bugPackExport) { | ||
var bugPackPackage = this.getPackage(packageName); | ||
if (!bugPackPackage) { | ||
bugPackPackage = this.createPackage(packageName); | ||
} | ||
}); | ||
return parentPackage; | ||
}; | ||
bugPackPackage.export(exportName, bugPackExport); | ||
}; | ||
/** | ||
* @param {string} packageName | ||
* @return {BugPackPackage} | ||
*/ | ||
BugPackLibrary.prototype.getPackage = function(packageName) { | ||
if (packageName === "") { | ||
return this.corePackage; | ||
} else if (this.hasPackage(packageName)) { | ||
return this.packages[packageName]; | ||
} | ||
return null; | ||
}; | ||
/** | ||
* @param {string} packageName | ||
* @return {boolean} | ||
*/ | ||
BugPackLibrary.prototype.hasPackage = function(packageName) { | ||
if (packageName === "") { | ||
return true; | ||
} else { | ||
return Object.prototype.hasOwnProperty.call(this.packages, packageName); | ||
} | ||
}; | ||
//------------------------------------------------------------------------------- | ||
// Exports | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @param {string} packageName | ||
* @param {string} exportName | ||
* @param {*} bugPackExport | ||
*/ | ||
BugPackLibrary.prototype.registerExport = function(packageName, exportName, bugPackExport) { | ||
var bugPackPackage = this.getPackage(packageName); | ||
if (!bugPackPackage) { | ||
bugPackPackage = this.createPackage(packageName); | ||
} | ||
bugPackPackage.export(exportName, bugPackExport); | ||
}; | ||
//------------------------------------------------------------------------------- | ||
// Exports | ||
//------------------------------------------------------------------------------- | ||
module.exports = BugPackLibrary; | ||
module.exports = BugPackLibrary; | ||
}); |
@@ -9,159 +9,170 @@ /* | ||
//------------------------------------------------------------------------------- | ||
// Declare Class | ||
// Context | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @constructor | ||
* @param {string} name | ||
*/ | ||
var BugPackPackage = function(name) { | ||
require('./BugPackFix').fix(module, "./BugPackPackage", function(module) { | ||
/** | ||
* @private | ||
* @type {Object} | ||
*/ | ||
this.exports = {}; | ||
//------------------------------------------------------------------------------- | ||
// Declare Class | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @private | ||
* @type {string} | ||
* @constructor | ||
* @param {string} name | ||
*/ | ||
this.name = name; | ||
var BugPackPackage = function(name) { | ||
/** | ||
* @private | ||
* @type {Array.<BugPackPackage>} | ||
*/ | ||
this.subPackages = []; | ||
}; | ||
//------------------------------------------------------------------------------- | ||
// Private Properties | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @private | ||
* @type {Object} | ||
*/ | ||
this.exports = {}; | ||
//------------------------------------------------------------------------------- | ||
// Getters and Setters | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @private | ||
* @type {string} | ||
*/ | ||
this.name = name; | ||
/** | ||
* @return {Object} | ||
*/ | ||
BugPackPackage.prototype.getExports = function() { | ||
return this.exports; | ||
}; | ||
/** | ||
* @private | ||
* @type {Array.<BugPackPackage>} | ||
*/ | ||
this.subPackages = []; | ||
}; | ||
/** | ||
* @return {string} | ||
*/ | ||
BugPackPackage.prototype.getName = function() { | ||
return this.name; | ||
}; | ||
/** | ||
* @return {Array.<BugPackPackage>} | ||
*/ | ||
BugPackPackage.prototype.getSubPackages = function() { | ||
return this.subPackages; | ||
}; | ||
//------------------------------------------------------------------------------- | ||
// Getters and Setters | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @return {Object} | ||
*/ | ||
BugPackPackage.prototype.getExports = function() { | ||
return this.exports; | ||
}; | ||
//------------------------------------------------------------------------------- | ||
// Public Methods | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @return {string} | ||
*/ | ||
BugPackPackage.prototype.getName = function() { | ||
return this.name; | ||
}; | ||
/** | ||
* @param {BugPackPackage} bugPackPackage | ||
*/ | ||
BugPackPackage.prototype.addSubPackage = function(bugPackPackage) { | ||
this.subPackages.push(bugPackPackage); | ||
}; | ||
/** | ||
* @return {Array.<BugPackPackage>} | ||
*/ | ||
BugPackPackage.prototype.getSubPackages = function() { | ||
return this.subPackages; | ||
}; | ||
/** | ||
* @param {string} exportName | ||
* @param {*} bugPackExport | ||
*/ | ||
BugPackPackage.prototype.export = function(exportName, bugPackExport) { | ||
if (!this.hasExport(exportName)) { | ||
this.addExport(exportName, bugPackExport); | ||
} else { | ||
Error.stackTraceLimit = Infinity; | ||
throw new Error("Package '" + this.name + "' already has export '" + exportName + "'"); | ||
} | ||
}; | ||
/** | ||
* @param {string} exportName | ||
* @return {*} | ||
*/ | ||
BugPackPackage.prototype.require = function(exportName) { | ||
if (this.hasExport(exportName)) { | ||
return this.getExport(exportName); | ||
} else { | ||
Error.stackTraceLimit = Infinity; | ||
throw new Error("Could not find export '" + exportName + "' in package '" + this.name + "'"); | ||
} | ||
}; | ||
//------------------------------------------------------------------------------- | ||
// Public Methods | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @param {BugPackPackage} bugPackPackage | ||
*/ | ||
BugPackPackage.prototype.addSubPackage = function(bugPackPackage) { | ||
this.subPackages.push(bugPackPackage); | ||
}; | ||
//------------------------------------------------------------------------------- | ||
// Private Methods | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @param {string} exportName | ||
* @param {*} bugPackExport | ||
*/ | ||
BugPackPackage.prototype.export = function(exportName, bugPackExport) { | ||
if (!this.hasExport(exportName)) { | ||
this.addExport(exportName, bugPackExport); | ||
} else { | ||
Error.stackTraceLimit = Infinity; | ||
throw new Error("Package '" + this.name + "' already has export '" + exportName + "'"); | ||
} | ||
}; | ||
/** | ||
* @private | ||
* @param {string} exportName | ||
* @param {*} bugPackExport | ||
*/ | ||
BugPackPackage.prototype.addExport = function(exportName, bugPackExport) { | ||
this.markExport(exportName, bugPackExport); | ||
this.exports[exportName] = bugPackExport; | ||
}; | ||
/** | ||
* @param {string} exportName | ||
* @return {*} | ||
*/ | ||
BugPackPackage.prototype.require = function(exportName) { | ||
if (this.hasExport(exportName)) { | ||
return this.getExport(exportName); | ||
} else { | ||
Error.stackTraceLimit = Infinity; | ||
throw new Error("Could not find export '" + exportName + "' in package '" + this.name + "'"); | ||
} | ||
}; | ||
/** | ||
* @private | ||
* @param {string} exportName | ||
* @return {*} | ||
*/ | ||
BugPackPackage.prototype.getExport = function(exportName) { | ||
if (this.hasExport(exportName)) { | ||
return this.exports[exportName]; | ||
} | ||
return null; | ||
}; | ||
/** | ||
* @private | ||
* @return {boolean} | ||
*/ | ||
BugPackPackage.prototype.hasExport = function(exportName) { | ||
return Object.prototype.hasOwnProperty.call(this.exports, exportName); | ||
}; | ||
//------------------------------------------------------------------------------- | ||
// Private Methods | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @private | ||
* @param {string} exportName | ||
* @param {*} bugPackExport | ||
*/ | ||
BugPackPackage.prototype.markExport = function(exportName, bugPackExport) { | ||
if (bugPackExport !== null && bugPackExport !== undefined) { | ||
if (!bugPackExport._bugPack) { | ||
Object.defineProperty(bugPackExport, "_bugPack", { | ||
value : { | ||
packageName: this.name, | ||
exportName: exportName, | ||
bugPackKey: this.name ? this.name + "." + exportName : exportName | ||
}, | ||
writable : false, | ||
enumerable : false, | ||
configurable : false | ||
}); | ||
} else { | ||
Error.stackTraceLimit = Infinity; | ||
throw new Error("Trying to mark a bugpack export that is already marked. Are you exporting the same value more than once?"); | ||
/** | ||
* @private | ||
* @param {string} exportName | ||
* @param {*} bugPackExport | ||
*/ | ||
BugPackPackage.prototype.addExport = function(exportName, bugPackExport) { | ||
this.markExport(exportName, bugPackExport); | ||
this.exports[exportName] = bugPackExport; | ||
}; | ||
/** | ||
* @private | ||
* @param {string} exportName | ||
* @return {*} | ||
*/ | ||
BugPackPackage.prototype.getExport = function(exportName) { | ||
if (this.hasExport(exportName)) { | ||
return this.exports[exportName]; | ||
} | ||
} | ||
}; | ||
return null; | ||
}; | ||
/** | ||
* @private | ||
* @return {boolean} | ||
*/ | ||
BugPackPackage.prototype.hasExport = function(exportName) { | ||
return Object.prototype.hasOwnProperty.call(this.exports, exportName); | ||
}; | ||
//------------------------------------------------------------------------------- | ||
// Exports | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @private | ||
* @param {string} exportName | ||
* @param {*} bugPackExport | ||
*/ | ||
BugPackPackage.prototype.markExport = function(exportName, bugPackExport) { | ||
if (bugPackExport !== null && bugPackExport !== undefined) { | ||
if (!bugPackExport._bugPack) { | ||
Object.defineProperty(bugPackExport, "_bugPack", { | ||
value : { | ||
packageName: this.name, | ||
exportName: exportName, | ||
bugPackKey: this.name ? this.name + "." + exportName : exportName | ||
}, | ||
writable : false, | ||
enumerable : false, | ||
configurable : false | ||
}); | ||
} else { | ||
Error.stackTraceLimit = Infinity; | ||
throw new Error("Trying to mark a bugpack export that is already marked. Are you exporting the same value more than once?"); | ||
} | ||
} | ||
}; | ||
module.exports = BugPackPackage; | ||
//------------------------------------------------------------------------------- | ||
// Exports | ||
//------------------------------------------------------------------------------- | ||
module.exports = BugPackPackage; | ||
}); |
@@ -28,2 +28,6 @@ /* | ||
//------------------------------------------------------------------------------- | ||
// Private Properties | ||
//------------------------------------------------------------------------------- | ||
/** | ||
@@ -30,0 +34,0 @@ * @private |
@@ -9,196 +9,207 @@ /* | ||
//------------------------------------------------------------------------------- | ||
// Declare Class | ||
// Context | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @constructor | ||
* @param {BugPackSource} bugPackSource | ||
* @param {BugPackContext} bugPackContext | ||
*/ | ||
var BugPackSourceProcessor = function(bugPackSource, bugPackContext) { | ||
require('./BugPackFix').fix(module, "./BugPackSourceProcessor", function(module) { | ||
//------------------------------------------------------------------------------- | ||
// Declare Class | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @private | ||
* @type {BugPackSource} | ||
* @constructor | ||
* @param {BugPackSource} bugPackSource | ||
* @param {BugPackContext} bugPackContext | ||
*/ | ||
this.bugPackSource = bugPackSource; | ||
var BugPackSourceProcessor = function(bugPackSource, bugPackContext) { | ||
//------------------------------------------------------------------------------- | ||
// Private Properties | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @private | ||
* @type {BugPackSource} | ||
*/ | ||
this.bugPackSource = bugPackSource; | ||
/** | ||
* @private | ||
* @type {BugPackContext} | ||
*/ | ||
this.bugPackContext = bugPackContext; | ||
/** | ||
* @private | ||
* @type boolean} | ||
*/ | ||
this.processed = false; | ||
/** | ||
* @private | ||
* @type {Array} | ||
*/ | ||
this.processedCallbacks = []; | ||
/** | ||
* @private | ||
* @type {boolean} | ||
*/ | ||
this.processingStarted = false; | ||
}; | ||
//------------------------------------------------------------------------------- | ||
// Getters and Setters | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @private | ||
* @type {BugPackContext} | ||
* @return {BugPackSource} | ||
*/ | ||
this.bugPackContext = bugPackContext; | ||
BugPackSourceProcessor.prototype.getBugPackSource = function() { | ||
return this.bugPackSource; | ||
}; | ||
//------------------------------------------------------------------------------- | ||
// Public Methods | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* @private | ||
* @type boolean} | ||
* @param {function(Error=)} callback | ||
*/ | ||
this.processed = false; | ||
BugPackSourceProcessor.prototype.addProcessedCallback = function(callback) { | ||
this.processedCallbacks.push(callback); | ||
}; | ||
/** | ||
* @private | ||
* @type {Array} | ||
* @return {boolean} | ||
*/ | ||
this.processedCallbacks = []; | ||
BugPackSourceProcessor.prototype.hasProcessed = function() { | ||
return this.processed; | ||
}; | ||
/** | ||
* @private | ||
* @type {boolean} | ||
* @return {boolean} | ||
*/ | ||
this.processingStarted = false; | ||
}; | ||
BugPackSourceProcessor.prototype.hasProcessingStarted = function() { | ||
return this.processingStarted; | ||
}; | ||
/** | ||
* | ||
*/ | ||
BugPackSourceProcessor.prototype.process = function() { | ||
if (!this.processed && !this.processingStarted) { | ||
this.processingStarted = true; | ||
this.processSource(); | ||
} | ||
}; | ||
//------------------------------------------------------------------------------- | ||
// Getters and Setters | ||
//------------------------------------------------------------------------------- | ||
/** | ||
* | ||
*/ | ||
BugPackSourceProcessor.prototype.processSync = function() { | ||
if (!this.processed) { | ||
this.processSourceSync(); | ||
} | ||
}; | ||
/** | ||
* @return {BugPackSource} | ||
*/ | ||
BugPackSourceProcessor.prototype.getBugPackSource = function() { | ||
return this.bugPackSource; | ||
}; | ||
//------------------------------------------------------------------------------- | ||
// Private Methods | ||
//------------------------------------------------------------------------------- | ||
//------------------------------------------------------------------------------- | ||
// Public Methods | ||
//------------------------------------------------------------------------------- | ||
//TODO BRN: This class is super tightly coupled with BugPackContext and really ugly. Figure out how to cleanly break this apart. | ||
/** | ||
* @param {function(Error=)} callback | ||
*/ | ||
BugPackSourceProcessor.prototype.addProcessedCallback = function(callback) { | ||
this.processedCallbacks.push(callback); | ||
}; | ||
/** | ||
* @private | ||
*/ | ||
BugPackSourceProcessor.prototype.loadBugPackSource = function() { | ||
var _this = this; | ||
if (!this.bugPackSource.hasLoaded()) { | ||
this.bugPackSource.addLoadCallback(function(error) { | ||
_this.processingComplete(error); | ||
}); | ||
if (!this.bugPackSource.hasLoadStarted()) { | ||
this.bugPackContext.getBugPackApi().setCurrentContext(this.bugPackContext); | ||
this.bugPackSource.load(); | ||
} | ||
} else { | ||
this.processingComplete(); | ||
} | ||
}; | ||
/** | ||
* @return {boolean} | ||
*/ | ||
BugPackSourceProcessor.prototype.hasProcessed = function() { | ||
return this.processed; | ||
}; | ||
/** | ||
* @private | ||
*/ | ||
BugPackSourceProcessor.prototype.loadBugPackSourceSync = function() { | ||
if (!this.bugPackSource.hasLoaded()) { | ||
if (!this.bugPackSource.hasLoadStarted()) { | ||
this.bugPackContext.getBugPackApi().setCurrentContext(this.bugPackContext); | ||
this.bugPackSource.loadSync(); | ||
} | ||
} | ||
}; | ||
/** | ||
* @return {boolean} | ||
*/ | ||
BugPackSourceProcessor.prototype.hasProcessingStarted = function() { | ||
return this.processingStarted; | ||
}; | ||
/** | ||
* | ||
*/ | ||
BugPackSourceProcessor.prototype.process = function() { | ||
if (!this.processed && !this.processingStarted) { | ||
this.processingStarted = true; | ||
this.processSource(); | ||
} | ||
}; | ||
/** | ||
* | ||
*/ | ||
BugPackSourceProcessor.prototype.processSync = function() { | ||
if (!this.processed) { | ||
this.processSourceSync(); | ||
} | ||
}; | ||
//------------------------------------------------------------------------------- | ||
// Private Methods | ||
//------------------------------------------------------------------------------- | ||
//TODO BRN: This class is super tightly coupled with BugPackContext and really ugly. Figure out how to cleanly break this apart. | ||
/** | ||
* @private | ||
*/ | ||
BugPackSourceProcessor.prototype.loadBugPackSource = function() { | ||
var _this = this; | ||
if (!this.bugPackSource.hasLoaded()) { | ||
this.bugPackSource.addLoadCallback(function(error) { | ||
_this.processingComplete(error); | ||
}); | ||
if (!this.bugPackSource.hasLoadStarted()) { | ||
this.bugPackContext.getBugPackApi().setCurrentContext(this.bugPackContext); | ||
this.bugPackSource.load(); | ||
/** | ||
* @private | ||
* @param {Error=} error | ||
*/ | ||
BugPackSourceProcessor.prototype.processingComplete = function(error) { | ||
if (!this.processed) { | ||
this.processed = true; | ||
this.processedCallbacks.forEach(function (processedCallback) { | ||
processedCallback(error); | ||
}); | ||
this.processedCallbacks = []; | ||
} | ||
} else { | ||
this.processingComplete(); | ||
} | ||
}; | ||
}; | ||
/** | ||
* @private | ||
*/ | ||
BugPackSourceProcessor.prototype.loadBugPackSourceSync = function() { | ||
if (!this.bugPackSource.hasLoaded()) { | ||
if (!this.bugPackSource.hasLoadStarted()) { | ||
this.bugPackContext.getBugPackApi().setCurrentContext(this.bugPackContext); | ||
this.bugPackSource.loadSync(); | ||
/** | ||
* @private | ||
*/ | ||
BugPackSourceProcessor.prototype.processSource = function() { | ||
var _this = this; | ||
var registryEntry = this.bugPackContext.getRegistry().getEntryBySourceFilePath(this.bugPackSource.getSourceFilePath()); | ||
var requiredExports = registryEntry.getRequires(); | ||
if (requiredExports.length > 0) { | ||
var loadedExportsCount = 0; | ||
requiredExports.forEach(function(requiredExport) { | ||
_this.bugPackContext.processExport(requiredExport, function(error) { | ||
if (!error) { | ||
loadedExportsCount++; | ||
if (loadedExportsCount === requiredExports.length) { | ||
_this.loadBugPackSource(); | ||
} | ||
} else { | ||
_this.processingComplete(error); | ||
} | ||
}); | ||
}); | ||
} else { | ||
this.loadBugPackSource(); | ||
} | ||
} | ||
}; | ||
}; | ||
/** | ||
* @private | ||
* @param {Error=} error | ||
*/ | ||
BugPackSourceProcessor.prototype.processingComplete = function(error) { | ||
if (!this.processed) { | ||
this.processed = true; | ||
this.processedCallbacks.forEach(function (processedCallback) { | ||
processedCallback(error); | ||
}); | ||
this.processedCallbacks = []; | ||
} | ||
}; | ||
/** | ||
* @private | ||
*/ | ||
BugPackSourceProcessor.prototype.processSourceSync = function() { | ||
var _this = this; | ||
var registryEntry = this.bugPackContext.getRegistry().getEntryBySourceFilePath(this.bugPackSource.getSourceFilePath()); | ||
var requiredExports = registryEntry.getRequires(); | ||
/** | ||
* @private | ||
*/ | ||
BugPackSourceProcessor.prototype.processSource = function() { | ||
var _this = this; | ||
var registryEntry = this.bugPackContext.getRegistry().getEntryBySourceFilePath(this.bugPackSource.getSourceFilePath()); | ||
var requiredExports = registryEntry.getRequires(); | ||
if (requiredExports.length > 0) { | ||
var loadedExportsCount = 0; | ||
requiredExports.forEach(function(requiredExport) { | ||
_this.bugPackContext.processExport(requiredExport, function(error) { | ||
if (!error) { | ||
loadedExportsCount++; | ||
if (loadedExportsCount === requiredExports.length) { | ||
_this.loadBugPackSource(); | ||
} | ||
} else { | ||
_this.processingComplete(error); | ||
} | ||
}); | ||
_this.bugPackContext.processExportSync(requiredExport); | ||
}); | ||
} else { | ||
this.loadBugPackSource(); | ||
} | ||
}; | ||
this.loadBugPackSourceSync(); | ||
}; | ||
/** | ||
* @private | ||
*/ | ||
BugPackSourceProcessor.prototype.processSourceSync = function() { | ||
var _this = this; | ||
var registryEntry = this.bugPackContext.getRegistry().getEntryBySourceFilePath(this.bugPackSource.getSourceFilePath()); | ||
var requiredExports = registryEntry.getRequires(); | ||
requiredExports.forEach(function(requiredExport) { | ||
_this.bugPackContext.processExportSync(requiredExport); | ||
}); | ||
this.loadBugPackSourceSync(); | ||
}; | ||
//------------------------------------------------------------------------------- | ||
// Exports | ||
//------------------------------------------------------------------------------- | ||
//------------------------------------------------------------------------------- | ||
// Exports | ||
//------------------------------------------------------------------------------- | ||
module.exports = BugPackSourceProcessor; | ||
module.exports = BugPackSourceProcessor; | ||
}); |
{ | ||
"name": "bugpack", | ||
"version": "0.1.14", | ||
"version": "0.2.0", | ||
"description": "Package manager and loader to help make browser and node js package loading consistent and easier", | ||
@@ -5,0 +5,0 @@ "main": "./lib/BugPackApi.js", |
@@ -17,3 +17,3 @@ # bugpack | ||
Latest Version `0.1.13` | ||
Latest Version `0.1.14` | ||
@@ -48,4 +48,4 @@ NOTE: This documentation is still being written. If you click on a link and it | ||
https://s3.amazonaws.com/public-airbug/bugpack-0.1.13.js | ||
https://s3.amazonaws.com/public-airbug/bugpack-0.1.13.min.js | ||
https://s3.amazonaws.com/public-airbug/bugpack-0.1.14.js | ||
https://s3.amazonaws.com/public-airbug/bugpack-0.1.14.min.js | ||
@@ -62,3 +62,3 @@ | ||
```html | ||
<script type="text/javascript" src="https://s3.amazonaws.com/public-airbug/bugpack-0.1.13.min.js"></script> | ||
<script type="text/javascript" src="https://s3.amazonaws.com/public-airbug/bugpack-0.1.14.min.js"></script> | ||
``` | ||
@@ -80,3 +80,3 @@ | ||
```html | ||
<script type="text/javascript" src="https://s3.amazonaws.com/public-airbug/bugpack-0.1.13.js"></script> | ||
<script type="text/javascript" src="https://s3.amazonaws.com/public-airbug/bugpack-0.1.14.js"></script> | ||
<script type="text/javascript"> | ||
@@ -83,0 +83,0 @@ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
77830
15
2104
0