/**
 * Extension.js
 *
 * Copyright 2013, Moxiecode Systems AB
 * Released under GPL License.
 *
 * License: http://www.plupload.com/license
 * Contributing: http://www.plupload.com/contributing
 */

/*jshint smarttabs:true, undef:true, unused:true, latedef:true, curly:true, bitwise:true, scripturl:true, browser:true */
/*global define:true */

(function() {
	var type = "@type@";
	var modules = [@modules@];

	var extensions = ["o"];
	for (var i in modules) {
		extensions.push("runtime/" + type + "/" + modules[i]);
	}

	define("runtime/" + type + "/extensions", extensions, function(o) {
		var extObj = {};
		o.each(Array.prototype.slice.call(arguments, 1), function(ext, i) {
			var name = modules[i].replace(/^[\s\S]+?\/([^\/]+)$/, '$1');
			extObj[name] = ext;
		});
		return extObj;
	});
}());

@@ -4,17 +4,17 @@
 %0A * 
-E
+e
 xtension
 .js%0A
@@ -9,16 +9,17 @@
 xtension
+s
 .js%0A *%0A 
@@ -360,79 +360,244 @@
  %7B%0A%09
-var type = %22@type@%22;%0A%09var modules = %5B@modules@%5D;%0A%0A%09var extensions = %5B%22o
+// when compiled dynamically @type@ and @modules@ will be replaced correspondingly with runtime type and modules to extend%0A%09var type = %22@type@%22;%0A%09var modules = %5B@modules@%5D;%0A%0A%09// define dependecies for extensions hash%0A%09var deps = %5B%22Basic
 %22%5D;%0A
@@ -628,25 +628,19 @@
 %7B%0A%09%09
-extension
+dep
 s.push(%22
 runt
@@ -635,16 +635,22 @@
 s.push(%22
+moxie/
 runtime/
@@ -726,25 +726,19 @@
 sions%22, 
-extension
+dep
 s, funct
@@ -745,101 +745,196 @@
 ion(
-o
+Basic
 ) %7B%0A%09%09
-var extObj = %7B%7D;%0A%09%09o.each(Array.prototype.slice.call(arguments, 1), function(ext, i) %7B
+// strip of Basic%0A%09%09var modules = %5B%5D.slice.call(arguments, 1);%0A%09%09%0A%09%09// generate extensions hash%0A%09%09var extensions = %7B%7D;%0A%09%09Basic.each(, function(ext, i) %7B%0A%09%09%09// extract class name
 %0A%09%09%09
@@ -997,22 +997,58 @@
 1');%0A%09%09%09
-extObj
+// class name / extension id%0A%09%09%09extensions
 %5Bname%5D =
@@ -1059,16 +1059,17 @@
 ;%0A%09%09%7D);%0A
+%0A
 %09%09return
@@ -1076,11 +1076,15 @@
  ext
-Obj
+ensions
 ;%0A%09%7D

Fix and clarify hash generator template for runtime extensions.