-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This release is primarily focused around experimentation with jspm configuration.
- Loading branch information
1 parent
f936d5a
commit cd2b886
Showing
17 changed files
with
443 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
node_modules | ||
jspm_packages | ||
bower_components | ||
dist | ||
.idea | ||
.DS_STORE |
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,7 +1,5 @@ | ||
System.config({ | ||
"paths": { | ||
"*": "*.js", | ||
"~/*": "lib/*.js" | ||
"*": "*.js" | ||
} | ||
}); | ||
|
||
}); |
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,54 @@ | ||
define(["exports"], function (exports) { | ||
"use strict"; | ||
|
||
exports.normalize = normalize; | ||
exports.getAnnotation = getAnnotation; | ||
exports.getAllAnnotations = getAllAnnotations; | ||
exports.addAnnotation = addAnnotation; | ||
function normalize(fn) { | ||
if (typeof fn.annotations === "function") { | ||
fn.annotations = fn.annotations(); | ||
} | ||
} | ||
|
||
function getAnnotation(fn, annotationType) { | ||
var annotations = fn.annotations, i, ii, annotation; | ||
|
||
if (annotations === undefined) { | ||
return null; | ||
} | ||
|
||
for (i = 0, ii = annotations.length; i < ii; ++i) { | ||
annotation = annotations[i]; | ||
|
||
if (annotation instanceof annotationType) { | ||
return annotation; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
function getAllAnnotations(fn, annotationType) { | ||
var annotations = fn.annotations, found = [], i, ii, annotation; | ||
|
||
if (annotations === undefined) { | ||
return found; | ||
} | ||
|
||
for (i = 0, ii = annotations.length; i < ii; ++i) { | ||
annotation = annotations[i]; | ||
|
||
if (annotation instanceof annotationType) { | ||
found.push(annotation); | ||
} | ||
} | ||
|
||
return found; | ||
} | ||
|
||
function addAnnotation(fn, annotation) { | ||
var annotations = fn.annotations || (fn.annotations = []); | ||
annotations.push(annotation); | ||
} | ||
}); |
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,10 @@ | ||
define(["exports", "./origin", "./resource-type", "./annotations"], function (exports, _origin, _resourceType, _annotations) { | ||
"use strict"; | ||
|
||
exports.Origin = _origin.Origin; | ||
exports.ResourceType = _resourceType.ResourceType; | ||
exports.getAnnotation = _annotations.getAnnotation; | ||
exports.getAllAnnotations = _annotations.getAllAnnotations; | ||
exports.addAnnotation = _annotations.addAnnotation; | ||
exports.normalize = _annotations.normalize; | ||
}); |
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,46 @@ | ||
define(["exports"], function (exports) { | ||
"use strict"; | ||
|
||
function ensureType(value) { | ||
if (value instanceof Origin) { | ||
return value; | ||
} | ||
|
||
return new Origin(value); | ||
} | ||
|
||
var Origin = (function () { | ||
var Origin = function Origin(moduleId, moduleMember) { | ||
this.moduleId = moduleId; | ||
this.moduleMember = moduleMember; | ||
}; | ||
|
||
Origin.get = function (fn) { | ||
var origin = fn.__origin__; | ||
|
||
if (origin !== undefined) { | ||
return origin; | ||
} | ||
|
||
if (typeof fn.origin === "function") { | ||
return fn.__origin__ = ensureType(fn.origin()); | ||
} | ||
|
||
if (fn.origin !== undefined) { | ||
return fn.__origin__ = ensureType(fn.origin); | ||
} | ||
|
||
return null; | ||
}; | ||
|
||
Origin.set = function (fn, origin) { | ||
if (Origin.get(fn) === null) { | ||
fn.__origin__ = origin; | ||
} | ||
}; | ||
|
||
return Origin; | ||
})(); | ||
|
||
exports.Origin = Origin; | ||
}); |
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,19 @@ | ||
define(["exports"], function (exports) { | ||
"use strict"; | ||
|
||
var ResourceType = (function () { | ||
var ResourceType = function ResourceType() {}; | ||
|
||
ResourceType.prototype.load = function (container, target) { | ||
return this; | ||
}; | ||
|
||
ResourceType.prototype.register = function (registry, name) { | ||
throw new Error("All descendents of \"ResourceType\" must implement the \"register\" method."); | ||
}; | ||
|
||
return ResourceType; | ||
})(); | ||
|
||
exports.ResourceType = ResourceType; | ||
}); |
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,52 @@ | ||
"use strict"; | ||
|
||
exports.normalize = normalize; | ||
exports.getAnnotation = getAnnotation; | ||
exports.getAllAnnotations = getAllAnnotations; | ||
exports.addAnnotation = addAnnotation; | ||
function normalize(fn) { | ||
if (typeof fn.annotations === "function") { | ||
fn.annotations = fn.annotations(); | ||
} | ||
} | ||
|
||
function getAnnotation(fn, annotationType) { | ||
var annotations = fn.annotations, i, ii, annotation; | ||
|
||
if (annotations === undefined) { | ||
return null; | ||
} | ||
|
||
for (i = 0, ii = annotations.length; i < ii; ++i) { | ||
annotation = annotations[i]; | ||
|
||
if (annotation instanceof annotationType) { | ||
return annotation; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
function getAllAnnotations(fn, annotationType) { | ||
var annotations = fn.annotations, found = [], i, ii, annotation; | ||
|
||
if (annotations === undefined) { | ||
return found; | ||
} | ||
|
||
for (i = 0, ii = annotations.length; i < ii; ++i) { | ||
annotation = annotations[i]; | ||
|
||
if (annotation instanceof annotationType) { | ||
found.push(annotation); | ||
} | ||
} | ||
|
||
return found; | ||
} | ||
|
||
function addAnnotation(fn, annotation) { | ||
var annotations = fn.annotations || (fn.annotations = []); | ||
annotations.push(annotation); | ||
} |
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,8 @@ | ||
"use strict"; | ||
|
||
exports.Origin = require("./origin").Origin; | ||
exports.ResourceType = require("./resource-type").ResourceType; | ||
exports.getAnnotation = require("./annotations").getAnnotation; | ||
exports.getAllAnnotations = require("./annotations").getAllAnnotations; | ||
exports.addAnnotation = require("./annotations").addAnnotation; | ||
exports.normalize = require("./annotations").normalize; |
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,44 @@ | ||
"use strict"; | ||
|
||
function ensureType(value) { | ||
if (value instanceof Origin) { | ||
return value; | ||
} | ||
|
||
return new Origin(value); | ||
} | ||
|
||
var Origin = (function () { | ||
var Origin = function Origin(moduleId, moduleMember) { | ||
this.moduleId = moduleId; | ||
this.moduleMember = moduleMember; | ||
}; | ||
|
||
Origin.get = function (fn) { | ||
var origin = fn.__origin__; | ||
|
||
if (origin !== undefined) { | ||
return origin; | ||
} | ||
|
||
if (typeof fn.origin === "function") { | ||
return fn.__origin__ = ensureType(fn.origin()); | ||
} | ||
|
||
if (fn.origin !== undefined) { | ||
return fn.__origin__ = ensureType(fn.origin); | ||
} | ||
|
||
return null; | ||
}; | ||
|
||
Origin.set = function (fn, origin) { | ||
if (Origin.get(fn) === null) { | ||
fn.__origin__ = origin; | ||
} | ||
}; | ||
|
||
return Origin; | ||
})(); | ||
|
||
exports.Origin = Origin; |
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,17 @@ | ||
"use strict"; | ||
|
||
var ResourceType = (function () { | ||
var ResourceType = function ResourceType() {}; | ||
|
||
ResourceType.prototype.load = function (container, target) { | ||
return this; | ||
}; | ||
|
||
ResourceType.prototype.register = function (registry, name) { | ||
throw new Error("All descendents of \"ResourceType\" must implement the \"register\" method."); | ||
}; | ||
|
||
return ResourceType; | ||
})(); | ||
|
||
exports.ResourceType = ResourceType; |
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,81 @@ | ||
/** | ||
* Normalizes a function's annotation representation. | ||
* | ||
* @method normalize | ||
* @param {Function} fn The function whose annotations may require normalization. | ||
* @for export | ||
*/ | ||
export function normalize(fn){ | ||
if(typeof fn.annotations === 'function'){ | ||
fn.annotations = fn.annotations(); | ||
} | ||
} | ||
|
||
/** | ||
* Searches a function's metadata for an annotation of a particular type. | ||
* | ||
* @method getAnnotation | ||
* @param {Function} fn The function whose annotations are being inspected. | ||
* @param {Function} annotationType The annotation type to look for. | ||
* @return {Object} Returns an instance of the specified annotation type if found; otherwise null. | ||
* @for export | ||
*/ | ||
export function getAnnotation(fn, annotationType){ | ||
var annotations = fn.annotations, | ||
i, ii, annotation; | ||
|
||
if(annotations === undefined){ | ||
return null; | ||
} | ||
|
||
for(i = 0, ii = annotations.length; i < ii; ++i){ | ||
annotation = annotations[i]; | ||
|
||
if(annotation instanceof annotationType){ | ||
return annotation; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
/** | ||
* Searches a function's metadata for all annotations of a particular type. | ||
* | ||
* @method getAllAnnotations | ||
* @param {Function} fn The function whose annotations are being inspected. | ||
* @param {Function} annotationType The annotation type to look for. | ||
* @return {Array} Returns an array of the specified annotation type. | ||
* @for export | ||
*/ | ||
export function getAllAnnotations(fn, annotationType){ | ||
var annotations = fn.annotations, | ||
found = [], i, ii, annotation; | ||
|
||
if(annotations === undefined){ | ||
return found; | ||
} | ||
|
||
for(i = 0, ii = annotations.length; i < ii; ++i){ | ||
annotation = annotations[i]; | ||
|
||
if(annotation instanceof annotationType){ | ||
found.push(annotation); | ||
} | ||
} | ||
|
||
return found; | ||
} | ||
|
||
/** | ||
* Adds metadata to a function. | ||
* | ||
* @method addAnnotation | ||
* @param {Function} fn The function being tagged with metadata. | ||
* @param {Object} annotation The annotation instance to add. | ||
* @for export | ||
*/ | ||
export function addAnnotation(fn, annotation){ | ||
var annotations = fn.annotations || (fn.annotations = []); | ||
annotations.push(annotation); | ||
} |
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,3 @@ | ||
export {Origin} from './origin'; | ||
export {ResourceType} from './resource-type'; | ||
export {getAnnotation, getAllAnnotations, addAnnotation, normalize} from './annotations'; |
Oops, something went wrong.