Skip to content

Commit

Permalink
Merge branch 'release/4.2.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirk Lüth authored and Dirk Lüth committed Feb 8, 2018
2 parents 914fecd + 4c52cf5 commit 28c3d38
Show file tree
Hide file tree
Showing 54 changed files with 304 additions and 252 deletions.
2 changes: 1 addition & 1 deletion dist/cache/dispose.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/demand.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/demand.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/handler/css.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/handler/html.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/handler/json.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/handler/legacy.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/handler/text.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugin/cookie.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugin/lzstring.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugin/sri.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "qoopido.demand",
"title": "Qoopido.demand",
"description": "Promise like module loader using XHR requests and localStorage caching to dynamically load JavaScript and CSS + dynamic dependency resolution + support for custom handlers",
"version": "4.2.7",
"version": "4.2.8",
"homepage": "https://github.com/dlueth/qoopido.demand",
"author": {
"name": "Dirk Lueth",
Expand Down
24 changes: 10 additions & 14 deletions src/abstract/handler.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
/* global
global, document, demand, provide, queue, processor, settings, setTimeout, clearTimeout, storage,
global, document, demand, provide, queue, processor, settings, setTimeout, clearTimeout,
NULL
*/

//=require constants.js

var abstractHandler = (function() {
function AbstractHandler() {
function abstractHandler() {

}
}

AbstractHandler.prototype = {
validate: NULL,
onPreRequest: NULL,
onPostRequest: NULL,
onPreProcess: NULL,
process: NULL
};

return AbstractHandler;
}());
abstractHandler.prototype = {
validate: NULL,
onPreRequest: NULL,
onPostRequest: NULL,
onPreProcess: NULL,
process: NULL
};
7 changes: 2 additions & 5 deletions src/abstract/uuid.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
/* global
global, document, demand, provide, queue, processor, settings, setTimeout, clearTimeout, storage,
global, document, demand, provide, queue, processor, settings, setTimeout, clearTimeout,
STRING_UNDEFINED,
objectDefineProperty,
validatorIsTypeOf,
functionUuid,
ClassDescriptor
*/

//=require constants.js
//=require shortcuts.js
//=require validator/isTypeOf.js
//=require function/uuid.js
//=require class/descriptor.js

function AbstractUuid() {
if(validatorIsTypeOf(this.uuid, STRING_UNDEFINED)) {
objectDefineProperty(this, 'uuid', new ClassDescriptor(functionUuid()));
this.define('uuid', functionUuid());
}

return this;
Expand Down
2 changes: 1 addition & 1 deletion src/class/dependency.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* global
global, document, demand, provide, queue, processor, settings, setTimeout, clearTimeout, storage,
global, document, demand, provide, queue, processor, settings, setTimeout, clearTimeout,
DEMAND_ID, MODULE_PREFIX_HANDLER, ERROR_LOAD, DEMAND_ID, PROVIDE_ID, PATH_ID, MOCK_PREFIX, NULL, TRUE, FALSE,
object,
regexMatchInternal, regexMatchParameter,
Expand Down
4 changes: 2 additions & 2 deletions src/class/descriptor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* global
global, document, demand, provide, queue, processor, settings, setTimeout, clearTimeout, storage,
global, document, demand, provide, queue, processor, settings, setTimeout, clearTimeout,
NULL
*/

Expand All @@ -13,4 +13,4 @@ function ClassDescriptor(value, writable, configurable, enumerable) {
configurable: !!configurable,
writable: !!writable
};
}
}
22 changes: 11 additions & 11 deletions src/class/failure.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* global
global, document, demand, provide, queue, processor, settings, setTimeout, clearTimeout, storage,
global, document, demand, provide, queue, processor, settings, setTimeout, clearTimeout,
DEMAND_ID,
functionToArray
*/
Expand All @@ -9,15 +9,15 @@

function ClassFailure(message, module, stack) {
var self = this;

self.message = message;

module && (self.module = module);
stack && (self.stack = functionToArray(stack));

return self;
}

ClassFailure.prototype = {
/* only for reference
message: NULL,
Expand All @@ -31,22 +31,22 @@ ClassFailure.prototype = {
if(self.stack) {
result = ClassFailure.traverse(self.stack, result, 1);
}

return result;
}
};

ClassFailure.traverse = function(stack, value, depth) {
var indention = new Array(depth + 1).join(' '),
i = 0, item;

for(; item = stack[i]; i++) {
value += '\n' + indention + '> ' + item.message + ' ' + (item.module ? '"' + item.module + '"' : '');

if(item.stack) {
value = ClassFailure.traverse(item.stack, value, depth + 1);
}
}

return value;
};
};
7 changes: 3 additions & 4 deletions src/class/loader.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* global
global, document, demand, provide, queue, processor, settings, setTimeout, clearTimeout, storage,
global, document, demand, provide, queue, processor, settings, setTimeout, clearTimeout,
DEMAND_ID, EVENT_PRE_REQUEST, EVENT_POST_REQUEST, ERROR_LOAD,
regexIsAbsoluteUri,
linkElement,
Expand All @@ -17,10 +17,9 @@
//=require class/xhr.js
//=require class/failure.js

var regexMatchEmptySearch = /^(?:\?|)$/;

function ClassLoader(dependency) {
var pattern;
var regexMatchEmptySearch = /^(?:\?|)$/,
pattern;

function resolve(response, type) {
if(!type || !dependency.handler.validate || dependency.handler.validate(type)) {
Expand Down
4 changes: 2 additions & 2 deletions src/class/pattern.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* global
global, document, demand, provide, queue, processor, settings, setTimeout, clearTimeout, storage,
global, document, demand, provide, queue, processor, settings, setTimeout, clearTimeout,
functionResolveUrl, functionEscapeRegex, functionIterate
*/

Expand Down Expand Up @@ -46,4 +46,4 @@ var ClassPattern = (function() {
};

return ClassPattern;
}());
}());
43 changes: 21 additions & 22 deletions src/class/pledge.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
/* global
global, document, demand, provide, queue, processor, settings, setTimeout, clearTimeout, storage,
global, document, demand, provide, queue, processor, settings, setTimeout, clearTimeout,
FUNCTION_EMPTY, NULL,
arrayPrototypeConcat,
functionDefer, functionUuid, functionToArray,
AbstractUuid
functionDefer, functionToArray,
ClassWeakmap
*/

//=require constants.js
//=require shortcuts.js
//=require function/defer.js
//=require function/uuid.js
//=require function/toArray.js
//=require abstract/uuid.js
//=require class/weakmap.js

var ClassPledge = (function() {
var PLEDGE_PENDING = 'pending',
PLEDGE_RESOLVED = 'resolved',
PLEDGE_REJECTED = 'rejected',
storage = {};
storage = new ClassWeakmap();

function resolve() {
storage[this.uuid].handle(PLEDGE_RESOLVED, arguments);
storage.get(this).handle(PLEDGE_RESOLVED, arguments);
}

function reject() {
storage[this.uuid].handle(PLEDGE_REJECTED, arguments);
storage.get(this).handle(PLEDGE_REJECTED, arguments);
}

function handle(state, parameter) {
var properties = storage[this.uuid],
var properties = storage.get(this),
pointer, result;

if(properties.state === PLEDGE_PENDING) {
Expand Down Expand Up @@ -76,12 +75,12 @@ var ClassPledge = (function() {
}

function ClassPledge(executor) {
var self = AbstractUuid.call(this);
var self = this;

storage[self.uuid] = { state: PLEDGE_PENDING, handle: handle.bind(self), value: NULL, resolved: [], rejected: [], count: 0 };
storage.set(this, { state: PLEDGE_PENDING, handle: handle.bind(self), value: NULL, resolved: [], rejected: [], count: 0 });

executor(resolve.bind(self), reject.bind(self));

return self;
}

Expand All @@ -93,7 +92,7 @@ var ClassPledge = (function() {
return this.then(alwaysListener, alwaysListener);
},
then: function(resolveListener, rejectListener) {
var properties = storage[this.uuid],
var properties = storage.get(this),
dfd = ClassPledge.defer();

resolveListener && properties[PLEDGE_RESOLVED].push({ handler: resolveListener, dfd: dfd });
Expand All @@ -106,13 +105,13 @@ var ClassPledge = (function() {
return dfd.pledge;
},
isPending: function() {
return storage[this.uuid].state === PLEDGE_PENDING;
return storage.get(this).state === PLEDGE_PENDING;
},
isResolved: function() {
return storage[this.uuid].state === PLEDGE_RESOLVED;
return storage.get(this).state === PLEDGE_RESOLVED;
},
isRejected: function() {
return storage[this.uuid].state === PLEDGE_REJECTED;
return storage.get(this).state === PLEDGE_REJECTED;
}
};

Expand All @@ -130,10 +129,10 @@ var ClassPledge = (function() {
ClassPledge.all = function(pledges) {
var dfd = ClassPledge.defer(),
properties, i = 0, pledge;

if(pledges.length) {
properties = (storage[functionUuid()] = { dfd: dfd, resolved: [], rejected: [], total: pledges.length, count: 0 })
properties = { dfd: dfd, resolved: [], rejected: [], total: pledges.length, count: 0 };

for(; pledge = pledges[i]; i++) {
observe(pledge, i, properties)
}
Expand All @@ -151,13 +150,13 @@ var ClassPledge = (function() {
for(; pledge = pledges[i]; i++) {
pledge.then(dfd.resolve, dfd.reject);
}

if(!pledges.length) {
dfd.resolve();
}

return dfd.pledge;
};

return ClassPledge.extends(AbstractUuid);
}());
return ClassPledge;
}());
Loading

0 comments on commit 28c3d38

Please sign in to comment.