Browse Source

PluggableExporter, using recipe, exportAll pulled up

Herbert Vojčík 11 years ago
parent
commit
c7c5bc7d3a
3 changed files with 773 additions and 716 deletions
  1. 263 250
      js/Importer-Exporter.deploy.js
  2. 330 307
      js/Importer-Exporter.js
  3. 180 159
      st/Importer-Exporter.st

+ 263 - 250
js/Importer-Exporter.deploy.js

@@ -65,29 +65,185 @@ messageSends: ["stream:", "new"]}),
 smalltalk.ChunkParser.klass);
 
 
-smalltalk.addClass('Exporter', smalltalk.Object, [], 'Importer-Exporter');
+smalltalk.addClass('Importer', smalltalk.Object, [], 'Importer-Exporter');
 smalltalk.addMethod(
 smalltalk.method({
-selector: "classNameFor:",
-fn: function (aClass){
+selector: "import:",
+fn: function (aStream){
 var self=this;
+var chunk,result,parser,lastEmpty;
+function $ChunkParser(){return smalltalk.ChunkParser||(typeof ChunkParser=="undefined"?nil:ChunkParser)}
+function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
 return smalltalk.withContext(function($ctx1) { 
-var $2,$3,$1;
-$2=_st(aClass)._isMetaclass();
-if(smalltalk.assert($2)){
-$1=_st(_st(_st(aClass)._instanceClass())._name()).__comma(".klass");
-} else {
-$3=_st(aClass)._isNil();
-if(smalltalk.assert($3)){
-$1="nil";
+var $1,$2;
+parser=_st($ChunkParser())._on_(aStream);
+lastEmpty=false;
+_st((function(){
+return smalltalk.withContext(function($ctx2) {
+chunk=_st(parser)._nextChunk();
+chunk;
+return _st(chunk)._isNil();
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileFalse_((function(){
+return smalltalk.withContext(function($ctx2) {
+$1=_st(chunk)._isEmpty();
+if(smalltalk.assert($1)){
+lastEmpty=true;
+return lastEmpty;
 } else {
-$1=_st(aClass)._name();
+result=_st(_st($Compiler())._new())._evaluateExpression_(chunk);
+result;
+$2=lastEmpty;
+if(smalltalk.assert($2)){
+lastEmpty=false;
+lastEmpty;
+return _st(result)._scanFrom_(parser);
 };
 };
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
+return self}, function($ctx1) {$ctx1.fill(self,"import:",{aStream:aStream,chunk:chunk,result:result,parser:parser,lastEmpty:lastEmpty},smalltalk.Importer)})},
+messageSends: ["on:", "whileFalse:", "ifTrue:ifFalse:", "evaluateExpression:", "new", "ifTrue:", "scanFrom:", "isEmpty", "nextChunk", "isNil"]}),
+smalltalk.Importer);
+
+
+
+smalltalk.addClass('PackageHandler', smalltalk.Object, [], 'Importer-Exporter');
+smalltalk.addMethod(
+smalltalk.method({
+selector: "ajaxPutAt:data:",
+fn: function (aURL,aString){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+_st(jQuery)._ajax_options_(aURL,smalltalk.HashedCollection._from_(["type".__minus_gt("PUT"),"data".__minus_gt(aString),"contentType".__minus_gt("text/plain;charset=UTF-8"),"error".__minus_gt((function(xhr){
+return smalltalk.withContext(function($ctx2) {
+return self._error_(_st(_st(_st("Commiting ".__comma(aURL)).__comma(" failed with reason: \x22")).__comma(_st(xhr)._responseText())).__comma("\x22"));
+}, function($ctx2) {$ctx2.fillBlock({xhr:xhr},$ctx1)})}))]));
+return self}, function($ctx1) {$ctx1.fill(self,"ajaxPutAt:data:",{aURL:aURL,aString:aString},smalltalk.PackageHandler)})},
+messageSends: ["ajax:options:", "->", "error:", ",", "responseText"]}),
+smalltalk.PackageHandler);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "commit:",
+fn: function (aPackage){
+var self=this;
+function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
+function $Exporter(){return smalltalk.Exporter||(typeof Exporter=="undefined"?nil:Exporter)}
+function $StrippedExporter(){return smalltalk.StrippedExporter||(typeof StrippedExporter=="undefined"?nil:StrippedExporter)}
+function $ChunkExporter(){return smalltalk.ChunkExporter||(typeof ChunkExporter=="undefined"?nil:ChunkExporter)}
+return smalltalk.withContext(function($ctx1) { 
+_st([_st($Exporter()).__minus_gt(_st(_st(_st(_st(aPackage)._commitPathJs()).__comma("/")).__comma(_st(aPackage)._name())).__comma(".js")),_st($StrippedExporter()).__minus_gt(_st(_st(_st(_st(aPackage)._commitPathJs()).__comma("/")).__comma(_st(aPackage)._name())).__comma(".deploy.js")),_st($ChunkExporter()).__minus_gt(_st(_st(_st(_st(aPackage)._commitPathSt()).__comma("/")).__comma(_st(aPackage)._name())).__comma(".st"))])._do_displayingProgress_((function(commitStrategy){
+var fileContents;
+return smalltalk.withContext(function($ctx2) {
+fileContents=_st($String())._streamContents_((function(stream){
+return smalltalk.withContext(function($ctx3) {
+return _st(_st(_st(commitStrategy)._key())._new())._exportPackage_on_(aPackage,stream);
+}, function($ctx3) {$ctx3.fillBlock({stream:stream},$ctx2)})}));
+fileContents;
+return self._ajaxPutAt_data_(_st(commitStrategy)._value(),fileContents);
+}, function($ctx2) {$ctx2.fillBlock({commitStrategy:commitStrategy,fileContents:fileContents},$ctx1)})}),"Committing package ".__comma(_st(aPackage)._name()));
+return self}, function($ctx1) {$ctx1.fill(self,"commit:",{aPackage:aPackage},smalltalk.PackageHandler)})},
+messageSends: ["do:displayingProgress:", "streamContents:", "exportPackage:on:", "new", "key", "ajaxPutAt:data:", "value", ",", "name", "->", "commitPathJs", "commitPathSt"]}),
+smalltalk.PackageHandler);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "loadPackage:prefix:",
+fn: function (packageName,aString){
+var self=this;
+var url;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+url=_st(_st(_st("/".__comma(aString)).__comma("/js/")).__comma(packageName)).__comma(".js");
+_st(jQuery)._ajax_options_(url,smalltalk.HashedCollection._from_(["type".__minus_gt("GET"),"dataType".__minus_gt("script"),"complete".__minus_gt((function(jqXHR,textStatus){
+return smalltalk.withContext(function($ctx2) {
+$1=_st(_st(jqXHR)._readyState()).__eq((4));
+if(smalltalk.assert($1)){
+return self._setupPackageNamed_prefix_(packageName,aString);
+};
+}, function($ctx2) {$ctx2.fillBlock({jqXHR:jqXHR,textStatus:textStatus},$ctx1)})})),"error".__minus_gt((function(){
+return smalltalk.withContext(function($ctx2) {
+return _st(window)._alert_("Could not load package at: ".__comma(url));
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))]));
+return self}, function($ctx1) {$ctx1.fill(self,"loadPackage:prefix:",{packageName:packageName,aString:aString,url:url},smalltalk.PackageHandler)})},
+messageSends: [",", "ajax:options:", "->", "ifTrue:", "setupPackageNamed:prefix:", "=", "readyState", "alert:"]}),
+smalltalk.PackageHandler);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "loadPackages:prefix:",
+fn: function (aCollection,aString){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+_st(aCollection)._do_((function(each){
+return smalltalk.withContext(function($ctx2) {
+return self._loadPackage_prefix_(each,aString);
+}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
+return self}, function($ctx1) {$ctx1.fill(self,"loadPackages:prefix:",{aCollection:aCollection,aString:aString},smalltalk.PackageHandler)})},
+messageSends: ["do:", "loadPackage:prefix:"]}),
+smalltalk.PackageHandler);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "setupPackageNamed:prefix:",
+fn: function (packageName,aString){
+var self=this;
+function $Package(){return smalltalk.Package||(typeof Package=="undefined"?nil:Package)}
+return smalltalk.withContext(function($ctx1) { 
+var $1,$2;
+$1=_st($Package())._named_(packageName);
+_st($1)._setupClasses();
+_st($1)._commitPathJs_(_st("/".__comma(aString)).__comma("/js"));
+$2=_st($1)._commitPathSt_(_st("/".__comma(aString)).__comma("/st"));
+return self}, function($ctx1) {$ctx1.fill(self,"setupPackageNamed:prefix:",{packageName:packageName,aString:aString},smalltalk.PackageHandler)})},
+messageSends: ["setupClasses", "named:", "commitPathJs:", ",", "commitPathSt:"]}),
+smalltalk.PackageHandler);
+
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "loadPackages:prefix:",
+fn: function (aCollection,aString){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=_st(self._new())._loadPackages_prefix_(aCollection,aString);
 return $1;
-}, function($ctx1) {$ctx1.fill(self,"classNameFor:",{aClass:aClass},smalltalk.Exporter)})},
-messageSends: ["ifTrue:ifFalse:", ",", "name", "instanceClass", "isNil", "isMetaclass"]}),
-smalltalk.Exporter);
+}, function($ctx1) {$ctx1.fill(self,"loadPackages:prefix:",{aCollection:aCollection,aString:aString},smalltalk.PackageHandler.klass)})},
+messageSends: ["loadPackages:prefix:", "new"]}),
+smalltalk.PackageHandler.klass);
+
+
+smalltalk.addClass('PluggableExporter', smalltalk.Object, [], 'Importer-Exporter');
+smalltalk.addMethod(
+smalltalk.method({
+selector: "export:usingRecipe:on:",
+fn: function (anObject,anArray,aStream){
+var self=this;
+var args;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+args=[anObject,aStream];
+_st(anArray)._do_((function(each){
+var val;
+return smalltalk.withContext(function($ctx2) {
+val=_st(each)._value();
+val;
+$1=_st(val).__eq_eq(each);
+if(smalltalk.assert($1)){
+var selection;
+selection=_st(_st(_st(each)._first())._key())._perform_withArguments_(_st(_st(each)._first())._value(),[anObject]);
+selection;
+return _st(selection)._do_((function(eachPart){
+return smalltalk.withContext(function($ctx3) {
+return self._export_usingRecipe_on_(eachPart,_st(each)._allButFirst(),aStream);
+}, function($ctx3) {$ctx3.fillBlock({eachPart:eachPart},$ctx2)})}));
+} else {
+return _st(_st(each)._key())._perform_withArguments_(val,args);
+};
+}, function($ctx2) {$ctx2.fillBlock({each:each,val:val},$ctx1)})}));
+return self}, function($ctx1) {$ctx1.fill(self,"export:usingRecipe:on:",{anObject:anObject,anArray:anArray,aStream:aStream,args:args},smalltalk.PluggableExporter)})},
+messageSends: ["do:", "value", "ifFalse:ifTrue:", "perform:withArguments:", "key", "first", "export:usingRecipe:on:", "allButFirst", "=="]}),
+smalltalk.PluggableExporter);
 
 smalltalk.addMethod(
 smalltalk.method({
@@ -106,28 +262,45 @@ return self._exportPackage_on_(pkg,stream);
 }, function($ctx3) {$ctx3.fillBlock({pkg:pkg},$ctx2)})}));
 }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1)})}));
 return $1;
-}, function($ctx1) {$ctx1.fill(self,"exportAll",{},smalltalk.Exporter)})},
+}, function($ctx1) {$ctx1.fill(self,"exportAll",{},smalltalk.PluggableExporter)})},
 messageSends: ["streamContents:", "do:", "exportPackage:on:", "packages", "current"]}),
-smalltalk.Exporter);
+smalltalk.PluggableExporter);
 
 smalltalk.addMethod(
 smalltalk.method({
-selector: "exportClass:on:",
-fn: function (aClass,aStream){
+selector: "exportPackage:on:",
+fn: function (aPackage,aStream){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-self._exportDefinitionOf_on_(aClass,aStream);
-_st(self._ownMethodsOfClass_(aClass))._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-return self._exportMethod_on_(each,aStream);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-self._exportMetaDefinitionOf_on_(aClass,aStream);
-_st(self._ownMethodsOfMetaClass_(aClass))._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-return self._exportMethod_on_(each,aStream);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-return self}, function($ctx1) {$ctx1.fill(self,"exportClass:on:",{aClass:aClass,aStream:aStream},smalltalk.Exporter)})},
-messageSends: ["exportDefinitionOf:on:", "do:", "exportMethod:on:", "ownMethodsOfClass:", "exportMetaDefinitionOf:on:", "ownMethodsOfMetaClass:"]}),
+self._export_usingRecipe_on_(aPackage,self._recipe(),aStream);
+return self}, function($ctx1) {$ctx1.fill(self,"exportPackage:on:",{aPackage:aPackage,aStream:aStream},smalltalk.PluggableExporter)})},
+messageSends: ["export:usingRecipe:on:", "recipe"]}),
+smalltalk.PluggableExporter);
+
+
+
+smalltalk.addClass('Exporter', smalltalk.PluggableExporter, [], 'Importer-Exporter');
+smalltalk.addMethod(
+smalltalk.method({
+selector: "classNameFor:",
+fn: function (aClass){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $2,$3,$1;
+$2=_st(aClass)._isMetaclass();
+if(smalltalk.assert($2)){
+$1=_st(_st(_st(aClass)._instanceClass())._name()).__comma(".klass");
+} else {
+$3=_st(aClass)._isNil();
+if(smalltalk.assert($3)){
+$1="nil";
+} else {
+$1=_st(aClass)._name();
+};
+};
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"classNameFor:",{aClass:aClass},smalltalk.Exporter)})},
+messageSends: ["ifTrue:ifFalse:", ",", "name", "instanceClass", "isNil", "isMetaclass"]}),
 smalltalk.Exporter);
 
 smalltalk.addMethod(
@@ -235,27 +408,6 @@ return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:on:",{aMethod:aMeth
 messageSends: ["nextPutAll:", "lf", ",", "asJavascript", "selector", "category", "compiledSource", "fn", "arguments", "source", "messageSends", "referencedClasses", "classNameFor:", "methodClass"]}),
 smalltalk.Exporter);
 
-smalltalk.addMethod(
-smalltalk.method({
-selector: "exportPackage:on:",
-fn: function (package_,stream){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
-self._exportPackagePrologueOf_on_(package_,stream);
-self._exportPackageDefinitionOf_on_(package_,stream);
-_st(self._ownClassesOfPackage_(package_))._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-return self._exportClass_on_(each,stream);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-_st(self._extensionMethodsOfPackage_(package_))._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-return self._exportMethod_on_(each,stream);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-self._exportPackageEpilogueOf_on_(package_,stream);
-return self}, function($ctx1) {$ctx1.fill(self,"exportPackage:on:",{package_:package_,stream:stream},smalltalk.Exporter)})},
-messageSends: ["exportPackagePrologueOf:on:", "exportPackageDefinitionOf:on:", "do:", "exportClass:on:", "ownClassesOfPackage:", "exportMethod:on:", "extensionMethodsOfPackage:", "exportPackageEpilogueOf:on:"]}),
-smalltalk.Exporter);
-
 smalltalk.addMethod(
 smalltalk.method({
 selector: "exportPackageDefinitionOf:on:",
@@ -376,6 +528,19 @@ return $1;
 messageSends: ["ownMethodsOfClass:", "class"]}),
 smalltalk.Exporter);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "recipe",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=[self.__minus_gt("exportPackagePrologueOf:on:"),self.__minus_gt("exportPackageDefinitionOf:on:"),[self.__minus_gt("ownClassesOfPackage:"),self.__minus_gt("exportDefinitionOf:on:"),[self.__minus_gt("ownMethodsOfClass:"),self.__minus_gt("exportMethod:on:")],self.__minus_gt("exportMetaDefinitionOf:on:"),[self.__minus_gt("ownMethodsOfMetaClass:"),self.__minus_gt("exportMethod:on:")]],[self.__minus_gt("extensionMethodsOfPackage:"),self.__minus_gt("exportMethod:on:")],self.__minus_gt("exportPackageEpilogueOf:on:")];
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"recipe",{},smalltalk.Exporter)})},
+messageSends: ["->"]}),
+smalltalk.Exporter);
+
 
 
 smalltalk.addClass('ChunkExporter', smalltalk.Exporter, [], 'Importer-Exporter');
@@ -417,47 +582,31 @@ smalltalk.ChunkExporter);
 
 smalltalk.addMethod(
 smalltalk.method({
-selector: "exportCategory:on:",
+selector: "exportCategoryEpilogueOf:on:",
 fn: function (category,aStream){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-var $1,$2,$3,$4;
+var $1,$2;
 $1=aStream;
-_st($1)._nextPutAll_("!".__comma(self._classNameFor_(_st(category)._at_("class"))));
-$2=_st($1)._nextPutAll_(_st(" methodsFor: '".__comma(_st(category)._at_("name"))).__comma("'!"));
-_st(_st(_st(category)._at_("methods"))._sorted_((function(a,b){
-return smalltalk.withContext(function($ctx2) {
-return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
-}, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})})))._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-return self._exportMethod_on_(each,aStream);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-$3=aStream;
-_st($3)._nextPutAll_(" !");
-_st($3)._lf();
-$4=_st($3)._lf();
-return self}, function($ctx1) {$ctx1.fill(self,"exportCategory:on:",{category:category,aStream:aStream},smalltalk.ChunkExporter)})},
-messageSends: ["nextPutAll:", ",", "classNameFor:", "at:", "do:", "exportMethod:on:", "sorted:", "<=", "selector", "lf"]}),
+_st($1)._nextPutAll_(" !");
+_st($1)._lf();
+$2=_st($1)._lf();
+return self}, function($ctx1) {$ctx1.fill(self,"exportCategoryEpilogueOf:on:",{category:category,aStream:aStream},smalltalk.ChunkExporter)})},
+messageSends: ["nextPutAll:", "lf"]}),
 smalltalk.ChunkExporter);
 
 smalltalk.addMethod(
 smalltalk.method({
-selector: "exportClass:on:",
-fn: function (aClass,aStream){
+selector: "exportCategoryPrologueOf:on:",
+fn: function (category,aStream){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-self._exportDefinitionOf_on_(aClass,aStream);
-_st(self._ownCategoriesOfClass_(aClass))._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-return self._exportCategory_on_(each,aStream);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-self._exportMetaDefinitionOf_on_(aClass,aStream);
-_st(self._ownCategoriesOfMetaClass_(aClass))._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-return self._exportCategory_on_(each,aStream);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-return self}, function($ctx1) {$ctx1.fill(self,"exportClass:on:",{aClass:aClass,aStream:aStream},smalltalk.ChunkExporter)})},
-messageSends: ["exportDefinitionOf:on:", "do:", "exportCategory:on:", "ownCategoriesOfClass:", "exportMetaDefinitionOf:on:", "ownCategoriesOfMetaClass:"]}),
+var $1,$2;
+$1=aStream;
+_st($1)._nextPutAll_("!".__comma(self._classNameFor_(_st(category)._at_("class"))));
+$2=_st($1)._nextPutAll_(_st(" methodsFor: '".__comma(_st(category)._at_("name"))).__comma("'!"));
+return self}, function($ctx1) {$ctx1.fill(self,"exportCategoryPrologueOf:on:",{category:category,aStream:aStream},smalltalk.ChunkExporter)})},
+messageSends: ["nextPutAll:", ",", "classNameFor:", "at:"]}),
 smalltalk.ChunkExporter);
 
 smalltalk.addMethod(
@@ -547,25 +696,6 @@ return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:on:",{aMethod:aMeth
 messageSends: ["lf", "nextPutAll:", "chunkEscape:", "source"]}),
 smalltalk.ChunkExporter);
 
-smalltalk.addMethod(
-smalltalk.method({
-selector: "exportPackage:on:",
-fn: function (package_,stream){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
-self._exportPackageDefinitionOf_on_(package_,stream);
-_st(self._ownClassesOfPackage_(package_))._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-return self._exportClass_on_(each,stream);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-_st(self._extensionCategoriesOfPackage_(package_))._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-return self._exportCategory_on_(each,stream);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-return self}, function($ctx1) {$ctx1.fill(self,"exportPackage:on:",{package_:package_,stream:stream},smalltalk.ChunkExporter)})},
-messageSends: ["exportPackageDefinitionOf:on:", "do:", "exportClass:on:", "ownClassesOfPackage:", "exportCategory:on:", "extensionCategoriesOfPackage:"]}),
-smalltalk.ChunkExporter);
-
 smalltalk.addMethod(
 smalltalk.method({
 selector: "exportPackageDefinitionOf:on:",
@@ -622,6 +752,22 @@ return $2;
 messageSends: ["name", "new", "do:", "protocolsDo:", "ifTrue:", "at:put:", "match:", ",", "addAll:", "collect:", "->", "at:", "sorted:", "<=", "keys", "class", "sortedClasses:", "classes", "current"]}),
 smalltalk.ChunkExporter);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "methodsOfCategory:",
+fn: function (category){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=_st(_st(category)._at_("methods"))._sorted_((function(a,b){
+return smalltalk.withContext(function($ctx2) {
+return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
+}, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})}));
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"methodsOfCategory:",{category:category},smalltalk.ChunkExporter)})},
+messageSends: ["sorted:", "<=", "selector", "at:"]}),
+smalltalk.ChunkExporter);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "ownCategoriesOfClass:",
@@ -664,6 +810,21 @@ return $1;
 messageSends: ["ownCategoriesOfClass:", "class"]}),
 smalltalk.ChunkExporter);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "recipe",
+fn: function (){
+var self=this;
+var exportCategoryRecipe;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+exportCategoryRecipe=[self.__minus_gt("exportCategoryPrologueOf:on:"),[self.__minus_gt("methodsOfCategory:"),self.__minus_gt("exportMethod:on:")],self.__minus_gt("exportCategoryEpilogueOf:on:")];
+$1=[self.__minus_gt("exportPackageDefinitionOf:on:"),[self.__minus_gt("ownClassesOfPackage:"),self.__minus_gt("exportDefinitionOf:on:"),_st([self.__minus_gt("ownCategoriesOfClass:")]).__comma(exportCategoryRecipe),self.__minus_gt("exportMetaDefinitionOf:on:"),_st([self.__minus_gt("ownCategoriesOfMetaClass:")]).__comma(exportCategoryRecipe)],_st([self.__minus_gt("extensionCategoriesOfPackage:")]).__comma(exportCategoryRecipe)];
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"recipe",{exportCategoryRecipe:exportCategoryRecipe},smalltalk.ChunkExporter)})},
+messageSends: ["->", ","]}),
+smalltalk.ChunkExporter);
+
 
 
 smalltalk.addClass('StrippedExporter', smalltalk.Exporter, [], 'Importer-Exporter');
@@ -724,154 +885,6 @@ messageSends: ["nextPutAll:", "lf", ",", "asJavascript", "selector", "compiledSo
 smalltalk.StrippedExporter);
 
 
-
-smalltalk.addClass('Importer', smalltalk.Object, [], 'Importer-Exporter');
-smalltalk.addMethod(
-smalltalk.method({
-selector: "import:",
-fn: function (aStream){
-var self=this;
-var chunk,result,parser,lastEmpty;
-function $ChunkParser(){return smalltalk.ChunkParser||(typeof ChunkParser=="undefined"?nil:ChunkParser)}
-function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
-return smalltalk.withContext(function($ctx1) { 
-var $1,$2;
-parser=_st($ChunkParser())._on_(aStream);
-lastEmpty=false;
-_st((function(){
-return smalltalk.withContext(function($ctx2) {
-chunk=_st(parser)._nextChunk();
-chunk;
-return _st(chunk)._isNil();
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileFalse_((function(){
-return smalltalk.withContext(function($ctx2) {
-$1=_st(chunk)._isEmpty();
-if(smalltalk.assert($1)){
-lastEmpty=true;
-return lastEmpty;
-} else {
-result=_st(_st($Compiler())._new())._evaluateExpression_(chunk);
-result;
-$2=lastEmpty;
-if(smalltalk.assert($2)){
-lastEmpty=false;
-lastEmpty;
-return _st(result)._scanFrom_(parser);
-};
-};
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
-return self}, function($ctx1) {$ctx1.fill(self,"import:",{aStream:aStream,chunk:chunk,result:result,parser:parser,lastEmpty:lastEmpty},smalltalk.Importer)})},
-messageSends: ["on:", "whileFalse:", "ifTrue:ifFalse:", "evaluateExpression:", "new", "ifTrue:", "scanFrom:", "isEmpty", "nextChunk", "isNil"]}),
-smalltalk.Importer);
-
-
-
-smalltalk.addClass('PackageHandler', smalltalk.Object, [], 'Importer-Exporter');
-smalltalk.addMethod(
-smalltalk.method({
-selector: "ajaxPutAt:data:",
-fn: function (aURL,aString){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
-_st(jQuery)._ajax_options_(aURL,smalltalk.HashedCollection._from_(["type".__minus_gt("PUT"),"data".__minus_gt(aString),"contentType".__minus_gt("text/plain;charset=UTF-8"),"error".__minus_gt((function(xhr){
-return smalltalk.withContext(function($ctx2) {
-return self._error_(_st(_st(_st("Commiting ".__comma(aURL)).__comma(" failed with reason: \x22")).__comma(_st(xhr)._responseText())).__comma("\x22"));
-}, function($ctx2) {$ctx2.fillBlock({xhr:xhr},$ctx1)})}))]));
-return self}, function($ctx1) {$ctx1.fill(self,"ajaxPutAt:data:",{aURL:aURL,aString:aString},smalltalk.PackageHandler)})},
-messageSends: ["ajax:options:", "->", "error:", ",", "responseText"]}),
-smalltalk.PackageHandler);
-
-smalltalk.addMethod(
-smalltalk.method({
-selector: "commit:",
-fn: function (aPackage){
-var self=this;
-function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
-function $Exporter(){return smalltalk.Exporter||(typeof Exporter=="undefined"?nil:Exporter)}
-function $StrippedExporter(){return smalltalk.StrippedExporter||(typeof StrippedExporter=="undefined"?nil:StrippedExporter)}
-function $ChunkExporter(){return smalltalk.ChunkExporter||(typeof ChunkExporter=="undefined"?nil:ChunkExporter)}
-return smalltalk.withContext(function($ctx1) { 
-_st([_st($Exporter()).__minus_gt(_st(_st(_st(_st(aPackage)._commitPathJs()).__comma("/")).__comma(_st(aPackage)._name())).__comma(".js")),_st($StrippedExporter()).__minus_gt(_st(_st(_st(_st(aPackage)._commitPathJs()).__comma("/")).__comma(_st(aPackage)._name())).__comma(".deploy.js")),_st($ChunkExporter()).__minus_gt(_st(_st(_st(_st(aPackage)._commitPathSt()).__comma("/")).__comma(_st(aPackage)._name())).__comma(".st"))])._do_displayingProgress_((function(commitStrategy){
-var fileContents;
-return smalltalk.withContext(function($ctx2) {
-fileContents=_st($String())._streamContents_((function(stream){
-return smalltalk.withContext(function($ctx3) {
-return _st(_st(_st(commitStrategy)._key())._new())._exportPackage_on_(aPackage,stream);
-}, function($ctx3) {$ctx3.fillBlock({stream:stream},$ctx2)})}));
-fileContents;
-return self._ajaxPutAt_data_(_st(commitStrategy)._value(),fileContents);
-}, function($ctx2) {$ctx2.fillBlock({commitStrategy:commitStrategy,fileContents:fileContents},$ctx1)})}),"Committing package ".__comma(_st(aPackage)._name()));
-return self}, function($ctx1) {$ctx1.fill(self,"commit:",{aPackage:aPackage},smalltalk.PackageHandler)})},
-messageSends: ["do:displayingProgress:", "streamContents:", "exportPackage:on:", "new", "key", "ajaxPutAt:data:", "value", ",", "name", "->", "commitPathJs", "commitPathSt"]}),
-smalltalk.PackageHandler);
-
-smalltalk.addMethod(
-smalltalk.method({
-selector: "loadPackage:prefix:",
-fn: function (packageName,aString){
-var self=this;
-var url;
-return smalltalk.withContext(function($ctx1) { 
-var $1;
-url=_st(_st(_st("/".__comma(aString)).__comma("/js/")).__comma(packageName)).__comma(".js");
-_st(jQuery)._ajax_options_(url,smalltalk.HashedCollection._from_(["type".__minus_gt("GET"),"dataType".__minus_gt("script"),"complete".__minus_gt((function(jqXHR,textStatus){
-return smalltalk.withContext(function($ctx2) {
-$1=_st(_st(jqXHR)._readyState()).__eq((4));
-if(smalltalk.assert($1)){
-return self._setupPackageNamed_prefix_(packageName,aString);
-};
-}, function($ctx2) {$ctx2.fillBlock({jqXHR:jqXHR,textStatus:textStatus},$ctx1)})})),"error".__minus_gt((function(){
-return smalltalk.withContext(function($ctx2) {
-return _st(window)._alert_("Could not load package at: ".__comma(url));
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))]));
-return self}, function($ctx1) {$ctx1.fill(self,"loadPackage:prefix:",{packageName:packageName,aString:aString,url:url},smalltalk.PackageHandler)})},
-messageSends: [",", "ajax:options:", "->", "ifTrue:", "setupPackageNamed:prefix:", "=", "readyState", "alert:"]}),
-smalltalk.PackageHandler);
-
-smalltalk.addMethod(
-smalltalk.method({
-selector: "loadPackages:prefix:",
-fn: function (aCollection,aString){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
-_st(aCollection)._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-return self._loadPackage_prefix_(each,aString);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-return self}, function($ctx1) {$ctx1.fill(self,"loadPackages:prefix:",{aCollection:aCollection,aString:aString},smalltalk.PackageHandler)})},
-messageSends: ["do:", "loadPackage:prefix:"]}),
-smalltalk.PackageHandler);
-
-smalltalk.addMethod(
-smalltalk.method({
-selector: "setupPackageNamed:prefix:",
-fn: function (packageName,aString){
-var self=this;
-function $Package(){return smalltalk.Package||(typeof Package=="undefined"?nil:Package)}
-return smalltalk.withContext(function($ctx1) { 
-var $1,$2;
-$1=_st($Package())._named_(packageName);
-_st($1)._setupClasses();
-_st($1)._commitPathJs_(_st("/".__comma(aString)).__comma("/js"));
-$2=_st($1)._commitPathSt_(_st("/".__comma(aString)).__comma("/st"));
-return self}, function($ctx1) {$ctx1.fill(self,"setupPackageNamed:prefix:",{packageName:packageName,aString:aString},smalltalk.PackageHandler)})},
-messageSends: ["setupClasses", "named:", "commitPathJs:", ",", "commitPathSt:"]}),
-smalltalk.PackageHandler);
-
-
-smalltalk.addMethod(
-smalltalk.method({
-selector: "loadPackages:prefix:",
-fn: function (aCollection,aString){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
-var $1;
-$1=_st(self._new())._loadPackages_prefix_(aCollection,aString);
-return $1;
-}, function($ctx1) {$ctx1.fill(self,"loadPackages:prefix:",{aCollection:aCollection,aString:aString},smalltalk.PackageHandler.klass)})},
-messageSends: ["loadPackages:prefix:", "new"]}),
-smalltalk.PackageHandler.klass);
-
 smalltalk.addMethod(
 smalltalk.method({
 selector: "commit",

+ 330 - 307
js/Importer-Exporter.js

@@ -81,35 +81,227 @@ referencedClasses: []
 smalltalk.ChunkParser.klass);
 
 
-smalltalk.addClass('Exporter', smalltalk.Object, [], 'Importer-Exporter');
-smalltalk.Exporter.comment="I am responsible for outputting Amber code into a JavaScript string.\x0a\x0aThe generated output is enough to reconstruct the exported data, including Smalltalk source code and other metadata.\x0a\x0a## Use case\x0a\x0aI am typically used to save code outside of the Amber runtime (committing to disk, etc.).\x0a\x0a## API\x0a\x0aUse `#exportAll`, `#exportClass:` or `#exportPackage:` methods.";
+smalltalk.addClass('Importer', smalltalk.Object, [], 'Importer-Exporter');
+smalltalk.Importer.comment="I can import Amber code from a string in the chunk format.\x0a\x0a## API\x0a\x0a    Importer new import: aString";
 smalltalk.addMethod(
 smalltalk.method({
-selector: "classNameFor:",
-category: 'private',
-fn: function (aClass){
+selector: "import:",
+category: 'fileIn',
+fn: function (aStream){
 var self=this;
+var chunk,result,parser,lastEmpty;
+function $ChunkParser(){return smalltalk.ChunkParser||(typeof ChunkParser=="undefined"?nil:ChunkParser)}
+function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
 return smalltalk.withContext(function($ctx1) { 
-var $2,$3,$1;
-$2=_st(aClass)._isMetaclass();
-if(smalltalk.assert($2)){
-$1=_st(_st(_st(aClass)._instanceClass())._name()).__comma(".klass");
-} else {
-$3=_st(aClass)._isNil();
-if(smalltalk.assert($3)){
-$1="nil";
+var $1,$2;
+parser=_st($ChunkParser())._on_(aStream);
+lastEmpty=false;
+_st((function(){
+return smalltalk.withContext(function($ctx2) {
+chunk=_st(parser)._nextChunk();
+chunk;
+return _st(chunk)._isNil();
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileFalse_((function(){
+return smalltalk.withContext(function($ctx2) {
+$1=_st(chunk)._isEmpty();
+if(smalltalk.assert($1)){
+lastEmpty=true;
+return lastEmpty;
 } else {
-$1=_st(aClass)._name();
+result=_st(_st($Compiler())._new())._evaluateExpression_(chunk);
+result;
+$2=lastEmpty;
+if(smalltalk.assert($2)){
+lastEmpty=false;
+lastEmpty;
+return _st(result)._scanFrom_(parser);
 };
 };
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
+return self}, function($ctx1) {$ctx1.fill(self,"import:",{aStream:aStream,chunk:chunk,result:result,parser:parser,lastEmpty:lastEmpty},smalltalk.Importer)})},
+args: ["aStream"],
+source: "import: aStream\x0a\x09| chunk result parser lastEmpty |\x0a\x09parser := ChunkParser on: aStream.\x0a\x09lastEmpty := false.\x0a\x09[chunk := parser nextChunk.\x0a\x09chunk isNil] whileFalse: [\x0a\x09\x09chunk isEmpty\x0a\x09\x09\x09ifTrue: [lastEmpty := true]\x0a\x09\x09\x09ifFalse: [\x0a\x09\x09\x09\x09result := Compiler new evaluateExpression: chunk.\x0a\x09\x09\x09\x09lastEmpty\x0a\x09\x09\x09\x09\x09\x09ifTrue: [\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09lastEmpty := false.\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09result scanFrom: parser]]]",
+messageSends: ["on:", "whileFalse:", "ifTrue:ifFalse:", "evaluateExpression:", "new", "ifTrue:", "scanFrom:", "isEmpty", "nextChunk", "isNil"],
+referencedClasses: ["ChunkParser", "Compiler"]
+}),
+smalltalk.Importer);
+
+
+
+smalltalk.addClass('PackageHandler', smalltalk.Object, [], 'Importer-Exporter');
+smalltalk.PackageHandler.comment="I am responsible for handling package loading and committing.\x0a\x0aI should not be used directly. Instead, use the corresponding `Package` methods.";
+smalltalk.addMethod(
+smalltalk.method({
+selector: "ajaxPutAt:data:",
+category: 'private',
+fn: function (aURL,aString){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+_st(jQuery)._ajax_options_(aURL,smalltalk.HashedCollection._from_(["type".__minus_gt("PUT"),"data".__minus_gt(aString),"contentType".__minus_gt("text/plain;charset=UTF-8"),"error".__minus_gt((function(xhr){
+return smalltalk.withContext(function($ctx2) {
+return self._error_(_st(_st(_st("Commiting ".__comma(aURL)).__comma(" failed with reason: \x22")).__comma(_st(xhr)._responseText())).__comma("\x22"));
+}, function($ctx2) {$ctx2.fillBlock({xhr:xhr},$ctx1)})}))]));
+return self}, function($ctx1) {$ctx1.fill(self,"ajaxPutAt:data:",{aURL:aURL,aString:aString},smalltalk.PackageHandler)})},
+args: ["aURL", "aString"],
+source: "ajaxPutAt: aURL data: aString\x0a\x09jQuery\x0a\x09\x09ajax: aURL \x0a\x09\x09options: #{ \x0a\x09\x09\x09'type' -> 'PUT'.\x0a\x09\x09\x09'data' -> aString.\x0a\x09\x09\x09'contentType' -> 'text/plain;charset=UTF-8'.\x0a\x09\x09\x09'error' -> [ :xhr | self error: 'Commiting ' , aURL , ' failed with reason: \x22' , (xhr responseText) , '\x22'] }",
+messageSends: ["ajax:options:", "->", "error:", ",", "responseText"],
+referencedClasses: []
+}),
+smalltalk.PackageHandler);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "commit:",
+category: 'committing',
+fn: function (aPackage){
+var self=this;
+function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
+function $Exporter(){return smalltalk.Exporter||(typeof Exporter=="undefined"?nil:Exporter)}
+function $StrippedExporter(){return smalltalk.StrippedExporter||(typeof StrippedExporter=="undefined"?nil:StrippedExporter)}
+function $ChunkExporter(){return smalltalk.ChunkExporter||(typeof ChunkExporter=="undefined"?nil:ChunkExporter)}
+return smalltalk.withContext(function($ctx1) { 
+_st([_st($Exporter()).__minus_gt(_st(_st(_st(_st(aPackage)._commitPathJs()).__comma("/")).__comma(_st(aPackage)._name())).__comma(".js")),_st($StrippedExporter()).__minus_gt(_st(_st(_st(_st(aPackage)._commitPathJs()).__comma("/")).__comma(_st(aPackage)._name())).__comma(".deploy.js")),_st($ChunkExporter()).__minus_gt(_st(_st(_st(_st(aPackage)._commitPathSt()).__comma("/")).__comma(_st(aPackage)._name())).__comma(".st"))])._do_displayingProgress_((function(commitStrategy){
+var fileContents;
+return smalltalk.withContext(function($ctx2) {
+fileContents=_st($String())._streamContents_((function(stream){
+return smalltalk.withContext(function($ctx3) {
+return _st(_st(_st(commitStrategy)._key())._new())._exportPackage_on_(aPackage,stream);
+}, function($ctx3) {$ctx3.fillBlock({stream:stream},$ctx2)})}));
+fileContents;
+return self._ajaxPutAt_data_(_st(commitStrategy)._value(),fileContents);
+}, function($ctx2) {$ctx2.fillBlock({commitStrategy:commitStrategy,fileContents:fileContents},$ctx1)})}),"Committing package ".__comma(_st(aPackage)._name()));
+return self}, function($ctx1) {$ctx1.fill(self,"commit:",{aPackage:aPackage},smalltalk.PackageHandler)})},
+args: ["aPackage"],
+source: "commit: aPackage\x0a\x09{ \x0a\x09\x09Exporter -> (aPackage commitPathJs, '/', aPackage name, '.js').\x0a\x09\x09StrippedExporter -> (aPackage commitPathJs, '/', aPackage name, '.deploy.js').\x0a\x09\x09ChunkExporter -> (aPackage commitPathSt, '/', aPackage name, '.st')\x0a\x09} \x0a\x09\x09do: [ :commitStrategy|| fileContents |\x0a\x09\x09\x09fileContents := String streamContents: [ :stream |\x0a\x09\x09\x09\x09commitStrategy key new exportPackage: aPackage on: stream ].\x0a\x09\x09\x09self ajaxPutAt: commitStrategy value data: fileContents ]\x0a\x09\x09displayingProgress: 'Committing package ', aPackage name",
+messageSends: ["do:displayingProgress:", "streamContents:", "exportPackage:on:", "new", "key", "ajaxPutAt:data:", "value", ",", "name", "->", "commitPathJs", "commitPathSt"],
+referencedClasses: ["String", "Exporter", "StrippedExporter", "ChunkExporter"]
+}),
+smalltalk.PackageHandler);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "loadPackage:prefix:",
+category: 'loading',
+fn: function (packageName,aString){
+var self=this;
+var url;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+url=_st(_st(_st("/".__comma(aString)).__comma("/js/")).__comma(packageName)).__comma(".js");
+_st(jQuery)._ajax_options_(url,smalltalk.HashedCollection._from_(["type".__minus_gt("GET"),"dataType".__minus_gt("script"),"complete".__minus_gt((function(jqXHR,textStatus){
+return smalltalk.withContext(function($ctx2) {
+$1=_st(_st(jqXHR)._readyState()).__eq((4));
+if(smalltalk.assert($1)){
+return self._setupPackageNamed_prefix_(packageName,aString);
+};
+}, function($ctx2) {$ctx2.fillBlock({jqXHR:jqXHR,textStatus:textStatus},$ctx1)})})),"error".__minus_gt((function(){
+return smalltalk.withContext(function($ctx2) {
+return _st(window)._alert_("Could not load package at: ".__comma(url));
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))]));
+return self}, function($ctx1) {$ctx1.fill(self,"loadPackage:prefix:",{packageName:packageName,aString:aString,url:url},smalltalk.PackageHandler)})},
+args: ["packageName", "aString"],
+source: "loadPackage: packageName prefix: aString\x0a\x09| url |\x0a\x09url := '/', aString, '/js/', packageName, '.js'.\x0a\x09jQuery\x0a\x09\x09ajax: url\x0a\x09\x09options: #{\x0a\x09\x09\x09'type' -> 'GET'.\x0a\x09\x09\x09'dataType' -> 'script'.\x0a\x09\x09\x09'complete' -> [ :jqXHR :textStatus |\x0a\x09\x09\x09\x09jqXHR readyState = 4\x0a\x09\x09\x09\x09\x09ifTrue: [ self setupPackageNamed: packageName prefix: aString ] ].\x0a\x09\x09\x09'error' -> [ window alert: 'Could not load package at: ', url ]\x0a\x09\x09}",
+messageSends: [",", "ajax:options:", "->", "ifTrue:", "setupPackageNamed:prefix:", "=", "readyState", "alert:"],
+referencedClasses: []
+}),
+smalltalk.PackageHandler);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "loadPackages:prefix:",
+category: 'loading',
+fn: function (aCollection,aString){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+_st(aCollection)._do_((function(each){
+return smalltalk.withContext(function($ctx2) {
+return self._loadPackage_prefix_(each,aString);
+}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
+return self}, function($ctx1) {$ctx1.fill(self,"loadPackages:prefix:",{aCollection:aCollection,aString:aString},smalltalk.PackageHandler)})},
+args: ["aCollection", "aString"],
+source: "loadPackages: aCollection prefix: aString\x0a\x09aCollection do: [ :each |\x0a\x09\x09self loadPackage: each prefix: aString ]",
+messageSends: ["do:", "loadPackage:prefix:"],
+referencedClasses: []
+}),
+smalltalk.PackageHandler);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "setupPackageNamed:prefix:",
+category: 'private',
+fn: function (packageName,aString){
+var self=this;
+function $Package(){return smalltalk.Package||(typeof Package=="undefined"?nil:Package)}
+return smalltalk.withContext(function($ctx1) { 
+var $1,$2;
+$1=_st($Package())._named_(packageName);
+_st($1)._setupClasses();
+_st($1)._commitPathJs_(_st("/".__comma(aString)).__comma("/js"));
+$2=_st($1)._commitPathSt_(_st("/".__comma(aString)).__comma("/st"));
+return self}, function($ctx1) {$ctx1.fill(self,"setupPackageNamed:prefix:",{packageName:packageName,aString:aString},smalltalk.PackageHandler)})},
+args: ["packageName", "aString"],
+source: "setupPackageNamed: packageName prefix: aString\x0a\x0a\x09(Package named: packageName)\x0a\x09\x09setupClasses;\x0a\x09\x09commitPathJs: '/', aString, '/js';\x0a\x09\x09commitPathSt: '/', aString, '/st'",
+messageSends: ["setupClasses", "named:", "commitPathJs:", ",", "commitPathSt:"],
+referencedClasses: ["Package"]
+}),
+smalltalk.PackageHandler);
+
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "loadPackages:prefix:",
+category: 'loading',
+fn: function (aCollection,aString){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=_st(self._new())._loadPackages_prefix_(aCollection,aString);
 return $1;
-}, function($ctx1) {$ctx1.fill(self,"classNameFor:",{aClass:aClass},smalltalk.Exporter)})},
-args: ["aClass"],
-source: "classNameFor: aClass\x0a\x09^aClass isMetaclass\x0a\x09\x09ifTrue: [aClass instanceClass name, '.klass']\x0a\x09\x09ifFalse: [\x0a\x09\x09aClass isNil\x0a\x09\x09\x09ifTrue: ['nil']\x0a\x09\x09\x09ifFalse: [aClass name]]",
-messageSends: ["ifTrue:ifFalse:", ",", "name", "instanceClass", "isNil", "isMetaclass"],
+}, function($ctx1) {$ctx1.fill(self,"loadPackages:prefix:",{aCollection:aCollection,aString:aString},smalltalk.PackageHandler.klass)})},
+args: ["aCollection", "aString"],
+source: "loadPackages: aCollection prefix: aString\x0a\x09^ self new loadPackages: aCollection prefix: aString",
+messageSends: ["loadPackages:prefix:", "new"],
 referencedClasses: []
 }),
-smalltalk.Exporter);
+smalltalk.PackageHandler.klass);
+
+
+smalltalk.addClass('PluggableExporter', smalltalk.Object, [], 'Importer-Exporter');
+smalltalk.addMethod(
+smalltalk.method({
+selector: "export:usingRecipe:on:",
+category: 'fileOut',
+fn: function (anObject,anArray,aStream){
+var self=this;
+var args;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+args=[anObject,aStream];
+_st(anArray)._do_((function(each){
+var val;
+return smalltalk.withContext(function($ctx2) {
+val=_st(each)._value();
+val;
+$1=_st(val).__eq_eq(each);
+if(smalltalk.assert($1)){
+var selection;
+selection=_st(_st(_st(each)._first())._key())._perform_withArguments_(_st(_st(each)._first())._value(),[anObject]);
+selection;
+return _st(selection)._do_((function(eachPart){
+return smalltalk.withContext(function($ctx3) {
+return self._export_usingRecipe_on_(eachPart,_st(each)._allButFirst(),aStream);
+}, function($ctx3) {$ctx3.fillBlock({eachPart:eachPart},$ctx2)})}));
+} else {
+return _st(_st(each)._key())._perform_withArguments_(val,args);
+};
+}, function($ctx2) {$ctx2.fillBlock({each:each,val:val},$ctx1)})}));
+return self}, function($ctx1) {$ctx1.fill(self,"export:usingRecipe:on:",{anObject:anObject,anArray:anArray,aStream:aStream,args:args},smalltalk.PluggableExporter)})},
+args: ["anObject", "anArray", "aStream"],
+source: "export: anObject usingRecipe: anArray on: aStream\x0a\x09| args |\x0a\x09args := { anObject. aStream }.\x0a\x09anArray do: [ :each | | val |\x0a\x09\x09val := each value.\x0a\x09\x09val == each\x0a\x09\x09\x09ifFalse: [ \x22association\x22\x0a\x09\x09\x09\x09each key perform: val withArguments: args ]\x0a\x09\x09\x09ifTrue: [ \x22sub-array\x22\x0a\x09\x09\x09\x09| selection |\x0a\x09\x09\x09\x09selection := each first key perform: each first value withArguments: { anObject }.\x0a\x09\x09\x09\x09selection do: [ :eachPart |\x09self export: eachPart usingRecipe: each allButFirst on: aStream ]]]",
+messageSends: ["do:", "value", "ifFalse:ifTrue:", "perform:withArguments:", "key", "first", "export:usingRecipe:on:", "allButFirst", "=="],
+referencedClasses: []
+}),
+smalltalk.PluggableExporter);
 
 smalltalk.addMethod(
 smalltalk.method({
@@ -129,35 +321,58 @@ return self._exportPackage_on_(pkg,stream);
 }, function($ctx3) {$ctx3.fillBlock({pkg:pkg},$ctx2)})}));
 }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1)})}));
 return $1;
-}, function($ctx1) {$ctx1.fill(self,"exportAll",{},smalltalk.Exporter)})},
+}, function($ctx1) {$ctx1.fill(self,"exportAll",{},smalltalk.PluggableExporter)})},
 args: [],
 source: "exportAll\x0a\x09\x22Export all packages in the system.\x22\x0a\x0a\x09^String streamContents: [:stream |\x0a\x09\x09Smalltalk current packages do: [:pkg |\x0a\x09\x09self exportPackage: pkg on: stream]]",
 messageSends: ["streamContents:", "do:", "exportPackage:on:", "packages", "current"],
 referencedClasses: ["Smalltalk", "String"]
 }),
-smalltalk.Exporter);
+smalltalk.PluggableExporter);
 
 smalltalk.addMethod(
 smalltalk.method({
-selector: "exportClass:on:",
+selector: "exportPackage:on:",
 category: 'fileOut',
-fn: function (aClass,aStream){
+fn: function (aPackage,aStream){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-self._exportDefinitionOf_on_(aClass,aStream);
-_st(self._ownMethodsOfClass_(aClass))._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-return self._exportMethod_on_(each,aStream);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-self._exportMetaDefinitionOf_on_(aClass,aStream);
-_st(self._ownMethodsOfMetaClass_(aClass))._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-return self._exportMethod_on_(each,aStream);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-return self}, function($ctx1) {$ctx1.fill(self,"exportClass:on:",{aClass:aClass,aStream:aStream},smalltalk.Exporter)})},
-args: ["aClass", "aStream"],
-source: "exportClass: aClass on: aStream\x0a\x09\x22Export a single class. Subclasses override these methods.\x22\x0a\x0a\x09self exportDefinitionOf: aClass on: aStream.\x0a\x09(self ownMethodsOfClass: aClass) do: [ :each |\x0a\x09\x09self exportMethod: each on: aStream\x0a\x09].\x0a\x09self exportMetaDefinitionOf: aClass on: aStream.\x0a\x09(self ownMethodsOfMetaClass: aClass) do: [ :each |\x0a\x09\x09self exportMethod: each on: aStream\x0a\x09].",
-messageSends: ["exportDefinitionOf:on:", "do:", "exportMethod:on:", "ownMethodsOfClass:", "exportMetaDefinitionOf:on:", "ownMethodsOfMetaClass:"],
+self._export_usingRecipe_on_(aPackage,self._recipe(),aStream);
+return self}, function($ctx1) {$ctx1.fill(self,"exportPackage:on:",{aPackage:aPackage,aStream:aStream},smalltalk.PluggableExporter)})},
+args: ["aPackage", "aStream"],
+source: "exportPackage: aPackage on: aStream\x0a\x09self export: aPackage usingRecipe: self recipe on: aStream",
+messageSends: ["export:usingRecipe:on:", "recipe"],
+referencedClasses: []
+}),
+smalltalk.PluggableExporter);
+
+
+
+smalltalk.addClass('Exporter', smalltalk.PluggableExporter, [], 'Importer-Exporter');
+smalltalk.Exporter.comment="I am responsible for outputting Amber code into a JavaScript string.\x0a\x0aThe generated output is enough to reconstruct the exported data, including Smalltalk source code and other metadata.\x0a\x0a## Use case\x0a\x0aI am typically used to save code outside of the Amber runtime (committing to disk, etc.).\x0a\x0a## API\x0a\x0aUse `#exportAll`, `#exportClass:` or `#exportPackage:` methods.";
+smalltalk.addMethod(
+smalltalk.method({
+selector: "classNameFor:",
+category: 'private',
+fn: function (aClass){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $2,$3,$1;
+$2=_st(aClass)._isMetaclass();
+if(smalltalk.assert($2)){
+$1=_st(_st(_st(aClass)._instanceClass())._name()).__comma(".klass");
+} else {
+$3=_st(aClass)._isNil();
+if(smalltalk.assert($3)){
+$1="nil";
+} else {
+$1=_st(aClass)._name();
+};
+};
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"classNameFor:",{aClass:aClass},smalltalk.Exporter)})},
+args: ["aClass"],
+source: "classNameFor: aClass\x0a\x09^aClass isMetaclass\x0a\x09\x09ifTrue: [aClass instanceClass name, '.klass']\x0a\x09\x09ifFalse: [\x0a\x09\x09aClass isNil\x0a\x09\x09\x09ifTrue: ['nil']\x0a\x09\x09\x09ifFalse: [aClass name]]",
+messageSends: ["ifTrue:ifFalse:", ",", "name", "instanceClass", "isNil", "isMetaclass"],
 referencedClasses: []
 }),
 smalltalk.Exporter);
@@ -282,32 +497,6 @@ referencedClasses: []
 }),
 smalltalk.Exporter);
 
-smalltalk.addMethod(
-smalltalk.method({
-selector: "exportPackage:on:",
-category: 'fileOut',
-fn: function (package_,stream){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
-self._exportPackagePrologueOf_on_(package_,stream);
-self._exportPackageDefinitionOf_on_(package_,stream);
-_st(self._ownClassesOfPackage_(package_))._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-return self._exportClass_on_(each,stream);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-_st(self._extensionMethodsOfPackage_(package_))._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-return self._exportMethod_on_(each,stream);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-self._exportPackageEpilogueOf_on_(package_,stream);
-return self}, function($ctx1) {$ctx1.fill(self,"exportPackage:on:",{package_:package_,stream:stream},smalltalk.Exporter)})},
-args: ["package", "stream"],
-source: "exportPackage: package on: stream\x0a\x09\x22Export a given package.\x22\x0a\x0a\x09self exportPackagePrologueOf: package on: stream.\x0a\x09self exportPackageDefinitionOf: package on: stream.\x0a\x0a\x09(self ownClassesOfPackage: package) do: [:each |\x0a\x09\x09self exportClass: each on: stream\x0a\x09].\x0a\x09(self extensionMethodsOfPackage: package) do: [ :each |\x0a\x09\x09self exportMethod: each on: stream\x0a\x09].\x0a\x09self exportPackageEpilogueOf: package on: stream",
-messageSends: ["exportPackagePrologueOf:on:", "exportPackageDefinitionOf:on:", "do:", "exportClass:on:", "ownClassesOfPackage:", "exportMethod:on:", "extensionMethodsOfPackage:", "exportPackageEpilogueOf:on:"],
-referencedClasses: []
-}),
-smalltalk.Exporter);
-
 smalltalk.addMethod(
 smalltalk.method({
 selector: "exportPackageDefinitionOf:on:",
@@ -463,6 +652,24 @@ referencedClasses: []
 }),
 smalltalk.Exporter);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "recipe",
+category: 'fileOut',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=[self.__minus_gt("exportPackagePrologueOf:on:"),self.__minus_gt("exportPackageDefinitionOf:on:"),[self.__minus_gt("ownClassesOfPackage:"),self.__minus_gt("exportDefinitionOf:on:"),[self.__minus_gt("ownMethodsOfClass:"),self.__minus_gt("exportMethod:on:")],self.__minus_gt("exportMetaDefinitionOf:on:"),[self.__minus_gt("ownMethodsOfMetaClass:"),self.__minus_gt("exportMethod:on:")]],[self.__minus_gt("extensionMethodsOfPackage:"),self.__minus_gt("exportMethod:on:")],self.__minus_gt("exportPackageEpilogueOf:on:")];
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"recipe",{},smalltalk.Exporter)})},
+args: [],
+source: "recipe\x0a\x09\x22Export a given package.\x22\x0a\x0a\x09^{\x0a\x09\x09self -> #exportPackagePrologueOf:on:.\x0a\x09\x09self -> #exportPackageDefinitionOf:on:.\x0a\x09\x09{\x0a\x09\x09\x09self -> #ownClassesOfPackage:.\x0a\x09\x09\x09self -> #exportDefinitionOf:on:.\x0a\x09\x09\x09{\x0a\x09\x09\x09\x09self -> #ownMethodsOfClass:.\x0a\x09\x09\x09\x09self -> #exportMethod:on: }.\x0a\x09\x09\x09self -> #exportMetaDefinitionOf:on:.\x0a\x09\x09\x09{\x0a\x09\x09\x09\x09self -> #ownMethodsOfMetaClass:.\x0a\x09\x09\x09\x09self -> #exportMethod:on: } }.\x0a\x09\x09{\x0a\x09\x09\x09self -> #extensionMethodsOfPackage:.\x0a\x09\x09\x09self -> #exportMethod:on: }.\x0a\x09\x09self -> #exportPackageEpilogueOf:on:\x0a\x09}",
+messageSends: ["->"],
+referencedClasses: []
+}),
+smalltalk.Exporter);
+
 
 
 smalltalk.addClass('ChunkExporter', smalltalk.Exporter, [], 'Importer-Exporter');
@@ -515,55 +722,39 @@ smalltalk.ChunkExporter);
 
 smalltalk.addMethod(
 smalltalk.method({
-selector: "exportCategory:on:",
+selector: "exportCategoryEpilogueOf:on:",
 category: 'private',
 fn: function (category,aStream){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-var $1,$2,$3,$4;
+var $1,$2;
 $1=aStream;
-_st($1)._nextPutAll_("!".__comma(self._classNameFor_(_st(category)._at_("class"))));
-$2=_st($1)._nextPutAll_(_st(" methodsFor: '".__comma(_st(category)._at_("name"))).__comma("'!"));
-_st(_st(_st(category)._at_("methods"))._sorted_((function(a,b){
-return smalltalk.withContext(function($ctx2) {
-return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
-}, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})})))._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-return self._exportMethod_on_(each,aStream);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-$3=aStream;
-_st($3)._nextPutAll_(" !");
-_st($3)._lf();
-$4=_st($3)._lf();
-return self}, function($ctx1) {$ctx1.fill(self,"exportCategory:on:",{category:category,aStream:aStream},smalltalk.ChunkExporter)})},
+_st($1)._nextPutAll_(" !");
+_st($1)._lf();
+$2=_st($1)._lf();
+return self}, function($ctx1) {$ctx1.fill(self,"exportCategoryEpilogueOf:on:",{category:category,aStream:aStream},smalltalk.ChunkExporter)})},
 args: ["category", "aStream"],
-source: "exportCategory: category on: aStream\x0a\x09\x22Issue #143: sort methods alphabetically\x22\x0a\x0a\x09aStream\x0a\x09\x09nextPutAll: '!', (self classNameFor: (category at: #class));\x0a\x09\x09nextPutAll: ' methodsFor: ''', (category at: #name), '''!'.\x0a\x09\x09((category at: #methods) sorted: [:a :b | a selector <= b selector]) do: [:each |\x0a\x09\x09\x09\x09self exportMethod: each on: aStream].\x0a\x09aStream nextPutAll: ' !'; lf; lf",
-messageSends: ["nextPutAll:", ",", "classNameFor:", "at:", "do:", "exportMethod:on:", "sorted:", "<=", "selector", "lf"],
+source: "exportCategoryEpilogueOf: category on: aStream\x0a\x09aStream nextPutAll: ' !'; lf; lf",
+messageSends: ["nextPutAll:", "lf"],
 referencedClasses: []
 }),
 smalltalk.ChunkExporter);
 
 smalltalk.addMethod(
 smalltalk.method({
-selector: "exportClass:on:",
-category: 'fileOut',
-fn: function (aClass,aStream){
+selector: "exportCategoryPrologueOf:on:",
+category: 'private',
+fn: function (category,aStream){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-self._exportDefinitionOf_on_(aClass,aStream);
-_st(self._ownCategoriesOfClass_(aClass))._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-return self._exportCategory_on_(each,aStream);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-self._exportMetaDefinitionOf_on_(aClass,aStream);
-_st(self._ownCategoriesOfMetaClass_(aClass))._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-return self._exportCategory_on_(each,aStream);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-return self}, function($ctx1) {$ctx1.fill(self,"exportClass:on:",{aClass:aClass,aStream:aStream},smalltalk.ChunkExporter)})},
-args: ["aClass", "aStream"],
-source: "exportClass: aClass on: aStream\x0a\x09\x22Export a single class. Subclasses override these methods.\x22\x0a\x0a\x09self exportDefinitionOf: aClass on: aStream.\x0a\x09(self ownCategoriesOfClass: aClass) do: [ :each |\x0a\x09\x09self exportCategory: each on: aStream\x0a\x09].\x0a\x09self exportMetaDefinitionOf: aClass on: aStream.\x0a\x09(self ownCategoriesOfMetaClass: aClass) do: [ :each |\x0a\x09\x09self exportCategory: each on: aStream\x0a\x09].",
-messageSends: ["exportDefinitionOf:on:", "do:", "exportCategory:on:", "ownCategoriesOfClass:", "exportMetaDefinitionOf:on:", "ownCategoriesOfMetaClass:"],
+var $1,$2;
+$1=aStream;
+_st($1)._nextPutAll_("!".__comma(self._classNameFor_(_st(category)._at_("class"))));
+$2=_st($1)._nextPutAll_(_st(" methodsFor: '".__comma(_st(category)._at_("name"))).__comma("'!"));
+return self}, function($ctx1) {$ctx1.fill(self,"exportCategoryPrologueOf:on:",{category:category,aStream:aStream},smalltalk.ChunkExporter)})},
+args: ["category", "aStream"],
+source: "exportCategoryPrologueOf: category on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: '!', (self classNameFor: (category at: #class));\x0a\x09\x09nextPutAll: ' methodsFor: ''', (category at: #name), '''!'",
+messageSends: ["nextPutAll:", ",", "classNameFor:", "at:"],
 referencedClasses: []
 }),
 smalltalk.ChunkExporter);
@@ -670,30 +861,6 @@ referencedClasses: []
 }),
 smalltalk.ChunkExporter);
 
-smalltalk.addMethod(
-smalltalk.method({
-selector: "exportPackage:on:",
-category: 'fileOut',
-fn: function (package_,stream){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
-self._exportPackageDefinitionOf_on_(package_,stream);
-_st(self._ownClassesOfPackage_(package_))._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-return self._exportClass_on_(each,stream);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-_st(self._extensionCategoriesOfPackage_(package_))._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-return self._exportCategory_on_(each,stream);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-return self}, function($ctx1) {$ctx1.fill(self,"exportPackage:on:",{package_:package_,stream:stream},smalltalk.ChunkExporter)})},
-args: ["package", "stream"],
-source: "exportPackage: package on: stream\x0a\x09\x22Export a given package.\x22\x0a\x0a\x09self exportPackageDefinitionOf: package on: stream.\x0a\x0a\x09(self ownClassesOfPackage: package) do: [:each |\x0a\x09\x09self exportClass: each on: stream\x0a\x09].\x0a\x09(self extensionCategoriesOfPackage: package) do: [ :each |\x0a\x09\x09self exportCategory: each on: stream\x0a\x09]",
-messageSends: ["exportPackageDefinitionOf:on:", "do:", "exportClass:on:", "ownClassesOfPackage:", "exportCategory:on:", "extensionCategoriesOfPackage:"],
-referencedClasses: []
-}),
-smalltalk.ChunkExporter);
-
 smalltalk.addMethod(
 smalltalk.method({
 selector: "exportPackageDefinitionOf:on:",
@@ -760,6 +927,27 @@ referencedClasses: ["OrderedCollection", "Dictionary", "Smalltalk", "Package"]
 }),
 smalltalk.ChunkExporter);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "methodsOfCategory:",
+category: 'private',
+fn: function (category){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=_st(_st(category)._at_("methods"))._sorted_((function(a,b){
+return smalltalk.withContext(function($ctx2) {
+return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
+}, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})}));
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"methodsOfCategory:",{category:category},smalltalk.ChunkExporter)})},
+args: ["category"],
+source: "methodsOfCategory: category\x0a\x09\x22Issue #143: sort methods alphabetically\x22\x0a\x0a\x09^(category at: #methods) sorted: [:a :b | a selector <= b selector]",
+messageSends: ["sorted:", "<=", "selector", "at:"],
+referencedClasses: []
+}),
+smalltalk.ChunkExporter);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "ownCategoriesOfClass:",
@@ -812,6 +1000,26 @@ referencedClasses: []
 }),
 smalltalk.ChunkExporter);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "recipe",
+category: 'fileOut',
+fn: function (){
+var self=this;
+var exportCategoryRecipe;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+exportCategoryRecipe=[self.__minus_gt("exportCategoryPrologueOf:on:"),[self.__minus_gt("methodsOfCategory:"),self.__minus_gt("exportMethod:on:")],self.__minus_gt("exportCategoryEpilogueOf:on:")];
+$1=[self.__minus_gt("exportPackageDefinitionOf:on:"),[self.__minus_gt("ownClassesOfPackage:"),self.__minus_gt("exportDefinitionOf:on:"),_st([self.__minus_gt("ownCategoriesOfClass:")]).__comma(exportCategoryRecipe),self.__minus_gt("exportMetaDefinitionOf:on:"),_st([self.__minus_gt("ownCategoriesOfMetaClass:")]).__comma(exportCategoryRecipe)],_st([self.__minus_gt("extensionCategoriesOfPackage:")]).__comma(exportCategoryRecipe)];
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"recipe",{exportCategoryRecipe:exportCategoryRecipe},smalltalk.ChunkExporter)})},
+args: [],
+source: "recipe\x0a\x09\x22Export a given package.\x22\x0a\x0a\x09| exportCategoryRecipe |\x0a\x09exportCategoryRecipe := {\x0a\x09\x09self -> #exportCategoryPrologueOf:on:.\x0a\x09\x09{\x0a\x09\x09\x09self -> #methodsOfCategory:.\x0a\x09\x09\x09self -> #exportMethod:on: }.\x0a\x09\x09self -> #exportCategoryEpilogueOf:on: }.\x0a\x0a\x09^{\x0a\x09\x09self -> #exportPackageDefinitionOf:on:.\x0a\x09\x09{\x0a\x09\x09\x09self -> #ownClassesOfPackage:.\x0a\x09\x09\x09self -> #exportDefinitionOf:on:.\x0a\x09\x09\x09{ self -> #ownCategoriesOfClass: }, exportCategoryRecipe.\x0a\x09\x09\x09self -> #exportMetaDefinitionOf:on:.\x0a\x09\x09\x09{ self -> #ownCategoriesOfMetaClass: }, exportCategoryRecipe }.\x0a\x09\x09{ self -> #extensionCategoriesOfPackage: }, exportCategoryRecipe\x0a\x09}",
+messageSends: ["->", ","],
+referencedClasses: []
+}),
+smalltalk.ChunkExporter);
+
 
 
 smalltalk.addClass('StrippedExporter', smalltalk.Exporter, [], 'Importer-Exporter');
@@ -883,191 +1091,6 @@ referencedClasses: []
 smalltalk.StrippedExporter);
 
 
-
-smalltalk.addClass('Importer', smalltalk.Object, [], 'Importer-Exporter');
-smalltalk.Importer.comment="I can import Amber code from a string in the chunk format.\x0a\x0a## API\x0a\x0a    Importer new import: aString";
-smalltalk.addMethod(
-smalltalk.method({
-selector: "import:",
-category: 'fileIn',
-fn: function (aStream){
-var self=this;
-var chunk,result,parser,lastEmpty;
-function $ChunkParser(){return smalltalk.ChunkParser||(typeof ChunkParser=="undefined"?nil:ChunkParser)}
-function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
-return smalltalk.withContext(function($ctx1) { 
-var $1,$2;
-parser=_st($ChunkParser())._on_(aStream);
-lastEmpty=false;
-_st((function(){
-return smalltalk.withContext(function($ctx2) {
-chunk=_st(parser)._nextChunk();
-chunk;
-return _st(chunk)._isNil();
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileFalse_((function(){
-return smalltalk.withContext(function($ctx2) {
-$1=_st(chunk)._isEmpty();
-if(smalltalk.assert($1)){
-lastEmpty=true;
-return lastEmpty;
-} else {
-result=_st(_st($Compiler())._new())._evaluateExpression_(chunk);
-result;
-$2=lastEmpty;
-if(smalltalk.assert($2)){
-lastEmpty=false;
-lastEmpty;
-return _st(result)._scanFrom_(parser);
-};
-};
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
-return self}, function($ctx1) {$ctx1.fill(self,"import:",{aStream:aStream,chunk:chunk,result:result,parser:parser,lastEmpty:lastEmpty},smalltalk.Importer)})},
-args: ["aStream"],
-source: "import: aStream\x0a\x09| chunk result parser lastEmpty |\x0a\x09parser := ChunkParser on: aStream.\x0a\x09lastEmpty := false.\x0a\x09[chunk := parser nextChunk.\x0a\x09chunk isNil] whileFalse: [\x0a\x09\x09chunk isEmpty\x0a\x09\x09\x09ifTrue: [lastEmpty := true]\x0a\x09\x09\x09ifFalse: [\x0a\x09\x09\x09\x09result := Compiler new evaluateExpression: chunk.\x0a\x09\x09\x09\x09lastEmpty\x0a\x09\x09\x09\x09\x09\x09ifTrue: [\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09lastEmpty := false.\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09result scanFrom: parser]]]",
-messageSends: ["on:", "whileFalse:", "ifTrue:ifFalse:", "evaluateExpression:", "new", "ifTrue:", "scanFrom:", "isEmpty", "nextChunk", "isNil"],
-referencedClasses: ["ChunkParser", "Compiler"]
-}),
-smalltalk.Importer);
-
-
-
-smalltalk.addClass('PackageHandler', smalltalk.Object, [], 'Importer-Exporter');
-smalltalk.PackageHandler.comment="I am responsible for handling package loading and committing.\x0a\x0aI should not be used directly. Instead, use the corresponding `Package` methods.";
-smalltalk.addMethod(
-smalltalk.method({
-selector: "ajaxPutAt:data:",
-category: 'private',
-fn: function (aURL,aString){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
-_st(jQuery)._ajax_options_(aURL,smalltalk.HashedCollection._from_(["type".__minus_gt("PUT"),"data".__minus_gt(aString),"contentType".__minus_gt("text/plain;charset=UTF-8"),"error".__minus_gt((function(xhr){
-return smalltalk.withContext(function($ctx2) {
-return self._error_(_st(_st(_st("Commiting ".__comma(aURL)).__comma(" failed with reason: \x22")).__comma(_st(xhr)._responseText())).__comma("\x22"));
-}, function($ctx2) {$ctx2.fillBlock({xhr:xhr},$ctx1)})}))]));
-return self}, function($ctx1) {$ctx1.fill(self,"ajaxPutAt:data:",{aURL:aURL,aString:aString},smalltalk.PackageHandler)})},
-args: ["aURL", "aString"],
-source: "ajaxPutAt: aURL data: aString\x0a\x09jQuery\x0a\x09\x09ajax: aURL \x0a\x09\x09options: #{ \x0a\x09\x09\x09'type' -> 'PUT'.\x0a\x09\x09\x09'data' -> aString.\x0a\x09\x09\x09'contentType' -> 'text/plain;charset=UTF-8'.\x0a\x09\x09\x09'error' -> [ :xhr | self error: 'Commiting ' , aURL , ' failed with reason: \x22' , (xhr responseText) , '\x22'] }",
-messageSends: ["ajax:options:", "->", "error:", ",", "responseText"],
-referencedClasses: []
-}),
-smalltalk.PackageHandler);
-
-smalltalk.addMethod(
-smalltalk.method({
-selector: "commit:",
-category: 'committing',
-fn: function (aPackage){
-var self=this;
-function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
-function $Exporter(){return smalltalk.Exporter||(typeof Exporter=="undefined"?nil:Exporter)}
-function $StrippedExporter(){return smalltalk.StrippedExporter||(typeof StrippedExporter=="undefined"?nil:StrippedExporter)}
-function $ChunkExporter(){return smalltalk.ChunkExporter||(typeof ChunkExporter=="undefined"?nil:ChunkExporter)}
-return smalltalk.withContext(function($ctx1) { 
-_st([_st($Exporter()).__minus_gt(_st(_st(_st(_st(aPackage)._commitPathJs()).__comma("/")).__comma(_st(aPackage)._name())).__comma(".js")),_st($StrippedExporter()).__minus_gt(_st(_st(_st(_st(aPackage)._commitPathJs()).__comma("/")).__comma(_st(aPackage)._name())).__comma(".deploy.js")),_st($ChunkExporter()).__minus_gt(_st(_st(_st(_st(aPackage)._commitPathSt()).__comma("/")).__comma(_st(aPackage)._name())).__comma(".st"))])._do_displayingProgress_((function(commitStrategy){
-var fileContents;
-return smalltalk.withContext(function($ctx2) {
-fileContents=_st($String())._streamContents_((function(stream){
-return smalltalk.withContext(function($ctx3) {
-return _st(_st(_st(commitStrategy)._key())._new())._exportPackage_on_(aPackage,stream);
-}, function($ctx3) {$ctx3.fillBlock({stream:stream},$ctx2)})}));
-fileContents;
-return self._ajaxPutAt_data_(_st(commitStrategy)._value(),fileContents);
-}, function($ctx2) {$ctx2.fillBlock({commitStrategy:commitStrategy,fileContents:fileContents},$ctx1)})}),"Committing package ".__comma(_st(aPackage)._name()));
-return self}, function($ctx1) {$ctx1.fill(self,"commit:",{aPackage:aPackage},smalltalk.PackageHandler)})},
-args: ["aPackage"],
-source: "commit: aPackage\x0a\x09{ \x0a\x09\x09Exporter -> (aPackage commitPathJs, '/', aPackage name, '.js').\x0a\x09\x09StrippedExporter -> (aPackage commitPathJs, '/', aPackage name, '.deploy.js').\x0a\x09\x09ChunkExporter -> (aPackage commitPathSt, '/', aPackage name, '.st')\x0a\x09} \x0a\x09\x09do: [ :commitStrategy|| fileContents |\x0a\x09\x09\x09fileContents := String streamContents: [ :stream |\x0a\x09\x09\x09\x09commitStrategy key new exportPackage: aPackage on: stream ].\x0a\x09\x09\x09self ajaxPutAt: commitStrategy value data: fileContents ]\x0a\x09\x09displayingProgress: 'Committing package ', aPackage name",
-messageSends: ["do:displayingProgress:", "streamContents:", "exportPackage:on:", "new", "key", "ajaxPutAt:data:", "value", ",", "name", "->", "commitPathJs", "commitPathSt"],
-referencedClasses: ["String", "Exporter", "StrippedExporter", "ChunkExporter"]
-}),
-smalltalk.PackageHandler);
-
-smalltalk.addMethod(
-smalltalk.method({
-selector: "loadPackage:prefix:",
-category: 'loading',
-fn: function (packageName,aString){
-var self=this;
-var url;
-return smalltalk.withContext(function($ctx1) { 
-var $1;
-url=_st(_st(_st("/".__comma(aString)).__comma("/js/")).__comma(packageName)).__comma(".js");
-_st(jQuery)._ajax_options_(url,smalltalk.HashedCollection._from_(["type".__minus_gt("GET"),"dataType".__minus_gt("script"),"complete".__minus_gt((function(jqXHR,textStatus){
-return smalltalk.withContext(function($ctx2) {
-$1=_st(_st(jqXHR)._readyState()).__eq((4));
-if(smalltalk.assert($1)){
-return self._setupPackageNamed_prefix_(packageName,aString);
-};
-}, function($ctx2) {$ctx2.fillBlock({jqXHR:jqXHR,textStatus:textStatus},$ctx1)})})),"error".__minus_gt((function(){
-return smalltalk.withContext(function($ctx2) {
-return _st(window)._alert_("Could not load package at: ".__comma(url));
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))]));
-return self}, function($ctx1) {$ctx1.fill(self,"loadPackage:prefix:",{packageName:packageName,aString:aString,url:url},smalltalk.PackageHandler)})},
-args: ["packageName", "aString"],
-source: "loadPackage: packageName prefix: aString\x0a\x09| url |\x0a\x09url := '/', aString, '/js/', packageName, '.js'.\x0a\x09jQuery\x0a\x09\x09ajax: url\x0a\x09\x09options: #{\x0a\x09\x09\x09'type' -> 'GET'.\x0a\x09\x09\x09'dataType' -> 'script'.\x0a\x09\x09\x09'complete' -> [ :jqXHR :textStatus |\x0a\x09\x09\x09\x09jqXHR readyState = 4\x0a\x09\x09\x09\x09\x09ifTrue: [ self setupPackageNamed: packageName prefix: aString ] ].\x0a\x09\x09\x09'error' -> [ window alert: 'Could not load package at: ', url ]\x0a\x09\x09}",
-messageSends: [",", "ajax:options:", "->", "ifTrue:", "setupPackageNamed:prefix:", "=", "readyState", "alert:"],
-referencedClasses: []
-}),
-smalltalk.PackageHandler);
-
-smalltalk.addMethod(
-smalltalk.method({
-selector: "loadPackages:prefix:",
-category: 'loading',
-fn: function (aCollection,aString){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
-_st(aCollection)._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-return self._loadPackage_prefix_(each,aString);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-return self}, function($ctx1) {$ctx1.fill(self,"loadPackages:prefix:",{aCollection:aCollection,aString:aString},smalltalk.PackageHandler)})},
-args: ["aCollection", "aString"],
-source: "loadPackages: aCollection prefix: aString\x0a\x09aCollection do: [ :each |\x0a\x09\x09self loadPackage: each prefix: aString ]",
-messageSends: ["do:", "loadPackage:prefix:"],
-referencedClasses: []
-}),
-smalltalk.PackageHandler);
-
-smalltalk.addMethod(
-smalltalk.method({
-selector: "setupPackageNamed:prefix:",
-category: 'private',
-fn: function (packageName,aString){
-var self=this;
-function $Package(){return smalltalk.Package||(typeof Package=="undefined"?nil:Package)}
-return smalltalk.withContext(function($ctx1) { 
-var $1,$2;
-$1=_st($Package())._named_(packageName);
-_st($1)._setupClasses();
-_st($1)._commitPathJs_(_st("/".__comma(aString)).__comma("/js"));
-$2=_st($1)._commitPathSt_(_st("/".__comma(aString)).__comma("/st"));
-return self}, function($ctx1) {$ctx1.fill(self,"setupPackageNamed:prefix:",{packageName:packageName,aString:aString},smalltalk.PackageHandler)})},
-args: ["packageName", "aString"],
-source: "setupPackageNamed: packageName prefix: aString\x0a\x0a\x09(Package named: packageName)\x0a\x09\x09setupClasses;\x0a\x09\x09commitPathJs: '/', aString, '/js';\x0a\x09\x09commitPathSt: '/', aString, '/st'",
-messageSends: ["setupClasses", "named:", "commitPathJs:", ",", "commitPathSt:"],
-referencedClasses: ["Package"]
-}),
-smalltalk.PackageHandler);
-
-
-smalltalk.addMethod(
-smalltalk.method({
-selector: "loadPackages:prefix:",
-category: 'loading',
-fn: function (aCollection,aString){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
-var $1;
-$1=_st(self._new())._loadPackages_prefix_(aCollection,aString);
-return $1;
-}, function($ctx1) {$ctx1.fill(self,"loadPackages:prefix:",{aCollection:aCollection,aString:aString},smalltalk.PackageHandler.klass)})},
-args: ["aCollection", "aString"],
-source: "loadPackages: aCollection prefix: aString\x0a\x09^ self new loadPackages: aCollection prefix: aString",
-messageSends: ["loadPackages:prefix:", "new"],
-referencedClasses: []
-}),
-smalltalk.PackageHandler.klass);
-
 smalltalk.addMethod(
 smalltalk.method({
 selector: "commit",

+ 180 - 159
st/Importer-Exporter.st

@@ -48,23 +48,124 @@ on: aStream
 	^self new stream: aStream
 ! !
 
-Object subclass: #Exporter
+Object subclass: #Importer
 	instanceVariableNames: ''
 	package: 'Importer-Exporter'!
-!Exporter commentStamp!
-I am responsible for outputting Amber code into a JavaScript string.
+!Importer commentStamp!
+I can import Amber code from a string in the chunk format.
 
-The generated output is enough to reconstruct the exported data, including Smalltalk source code and other metadata.
+## API
 
-## Use case
+    Importer new import: aString!
 
-I am typically used to save code outside of the Amber runtime (committing to disk, etc.).
+!Importer methodsFor: 'fileIn'!
 
-## API
+import: aStream
+	| chunk result parser lastEmpty |
+	parser := ChunkParser on: aStream.
+	lastEmpty := false.
+	[chunk := parser nextChunk.
+	chunk isNil] whileFalse: [
+		chunk isEmpty
+			ifTrue: [lastEmpty := true]
+			ifFalse: [
+				result := Compiler new evaluateExpression: chunk.
+				lastEmpty
+						ifTrue: [
+									lastEmpty := false.
+									result scanFrom: parser]]]
+! !
 
-Use `#exportAll`, `#exportClass:` or `#exportPackage:` methods.!
+Object subclass: #PackageHandler
+	instanceVariableNames: ''
+	package: 'Importer-Exporter'!
+!PackageHandler commentStamp!
+I am responsible for handling package loading and committing.
 
-!Exporter methodsFor: 'fileOut'!
+I should not be used directly. Instead, use the corresponding `Package` methods.!
+
+!PackageHandler methodsFor: 'committing'!
+
+commit: aPackage
+	{ 
+		Exporter -> (aPackage commitPathJs, '/', aPackage name, '.js').
+		StrippedExporter -> (aPackage commitPathJs, '/', aPackage name, '.deploy.js').
+		ChunkExporter -> (aPackage commitPathSt, '/', aPackage name, '.st')
+	} 
+		do: [ :commitStrategy|| fileContents |
+			fileContents := String streamContents: [ :stream |
+				commitStrategy key new exportPackage: aPackage on: stream ].
+			self ajaxPutAt: commitStrategy value data: fileContents ]
+		displayingProgress: 'Committing package ', aPackage name
+! !
+
+!PackageHandler methodsFor: 'loading'!
+
+loadPackage: packageName prefix: aString
+	| url |
+	url := '/', aString, '/js/', packageName, '.js'.
+	jQuery
+		ajax: url
+		options: #{
+			'type' -> 'GET'.
+			'dataType' -> 'script'.
+			'complete' -> [ :jqXHR :textStatus |
+				jqXHR readyState = 4
+					ifTrue: [ self setupPackageNamed: packageName prefix: aString ] ].
+			'error' -> [ window alert: 'Could not load package at: ', url ]
+		}
+!
+
+loadPackages: aCollection prefix: aString
+	aCollection do: [ :each |
+		self loadPackage: each prefix: aString ]
+! !
+
+!PackageHandler methodsFor: 'private'!
+
+ajaxPutAt: aURL data: aString
+	jQuery
+		ajax: aURL 
+		options: #{ 
+			'type' -> 'PUT'.
+			'data' -> aString.
+			'contentType' -> 'text/plain;charset=UTF-8'.
+			'error' -> [ :xhr | self error: 'Commiting ' , aURL , ' failed with reason: "' , (xhr responseText) , '"'] }
+!
+
+setupPackageNamed: packageName prefix: aString
+
+	(Package named: packageName)
+		setupClasses;
+		commitPathJs: '/', aString, '/js';
+		commitPathSt: '/', aString, '/st'
+! !
+
+!PackageHandler class methodsFor: 'loading'!
+
+loadPackages: aCollection prefix: aString
+	^ self new loadPackages: aCollection prefix: aString
+! !
+
+Object subclass: #PluggableExporter
+	instanceVariableNames: ''
+	package: 'Importer-Exporter'!
+
+!PluggableExporter methodsFor: 'fileOut'!
+
+export: anObject usingRecipe: anArray on: aStream
+	| args |
+	args := { anObject. aStream }.
+	anArray do: [ :each | | val |
+		val := each value.
+		val == each
+			ifFalse: [ "association"
+				each key perform: val withArguments: args ]
+			ifTrue: [ "sub-array"
+				| selection |
+				selection := each first key perform: each first value withArguments: { anObject }.
+				selection do: [ :eachPart |	self export: eachPart usingRecipe: each allButFirst on: aStream ]]]
+!
 
 exportAll
 	"Export all packages in the system."
@@ -74,32 +175,49 @@ exportAll
 		self exportPackage: pkg on: stream]]
 !
 
-exportClass: aClass on: aStream
-	"Export a single class. Subclasses override these methods."
-
-	self exportDefinitionOf: aClass on: aStream.
-	(self ownMethodsOfClass: aClass) do: [ :each |
-		self exportMethod: each on: aStream
-	].
-	self exportMetaDefinitionOf: aClass on: aStream.
-	(self ownMethodsOfMetaClass: aClass) do: [ :each |
-		self exportMethod: each on: aStream
-	].
-!
+exportPackage: aPackage on: aStream
+	self export: aPackage usingRecipe: self recipe on: aStream
+! !
 
-exportPackage: package on: stream
-	"Export a given package."
+PluggableExporter subclass: #Exporter
+	instanceVariableNames: ''
+	package: 'Importer-Exporter'!
+!Exporter commentStamp!
+I am responsible for outputting Amber code into a JavaScript string.
 
-	self exportPackagePrologueOf: package on: stream.
-	self exportPackageDefinitionOf: package on: stream.
+The generated output is enough to reconstruct the exported data, including Smalltalk source code and other metadata.
+
+## Use case
+
+I am typically used to save code outside of the Amber runtime (committing to disk, etc.).
+
+## API
 
-	(self ownClassesOfPackage: package) do: [:each |
-		self exportClass: each on: stream
-	].
-	(self extensionMethodsOfPackage: package) do: [ :each |
-		self exportMethod: each on: stream
-	].
-	self exportPackageEpilogueOf: package on: stream
+Use `#exportAll`, `#exportClass:` or `#exportPackage:` methods.!
+
+!Exporter methodsFor: 'fileOut'!
+
+recipe
+	"Export a given package."
+
+	^{
+		self -> #exportPackagePrologueOf:on:.
+		self -> #exportPackageDefinitionOf:on:.
+		{
+			self -> #ownClassesOfPackage:.
+			self -> #exportDefinitionOf:on:.
+			{
+				self -> #ownMethodsOfClass:.
+				self -> #exportMethod:on: }.
+			self -> #exportMetaDefinitionOf:on:.
+			{
+				self -> #ownMethodsOfMetaClass:.
+				self -> #exportMethod:on: } }.
+		{
+			self -> #extensionMethodsOfPackage:.
+			self -> #exportMethod:on: }.
+		self -> #exportPackageEpilogueOf:on:
+	}
 ! !
 
 !Exporter methodsFor: 'private'!
@@ -231,30 +349,27 @@ I do not output any compiled code.!
 
 !ChunkExporter methodsFor: 'fileOut'!
 
-exportClass: aClass on: aStream
-	"Export a single class. Subclasses override these methods."
-
-	self exportDefinitionOf: aClass on: aStream.
-	(self ownCategoriesOfClass: aClass) do: [ :each |
-		self exportCategory: each on: aStream
-	].
-	self exportMetaDefinitionOf: aClass on: aStream.
-	(self ownCategoriesOfMetaClass: aClass) do: [ :each |
-		self exportCategory: each on: aStream
-	].
-!
-
-exportPackage: package on: stream
+recipe
 	"Export a given package."
 
-	self exportPackageDefinitionOf: package on: stream.
-
-	(self ownClassesOfPackage: package) do: [:each |
-		self exportClass: each on: stream
-	].
-	(self extensionCategoriesOfPackage: package) do: [ :each |
-		self exportCategory: each on: stream
-	]
+	| exportCategoryRecipe |
+	exportCategoryRecipe := {
+		self -> #exportCategoryPrologueOf:on:.
+		{
+			self -> #methodsOfCategory:.
+			self -> #exportMethod:on: }.
+		self -> #exportCategoryEpilogueOf:on: }.
+
+	^{
+		self -> #exportPackageDefinitionOf:on:.
+		{
+			self -> #ownClassesOfPackage:.
+			self -> #exportDefinitionOf:on:.
+			{ self -> #ownCategoriesOfClass: }, exportCategoryRecipe.
+			self -> #exportMetaDefinitionOf:on:.
+			{ self -> #ownCategoriesOfMetaClass: }, exportCategoryRecipe }.
+		{ self -> #extensionCategoriesOfPackage: }, exportCategoryRecipe
+	}
 ! !
 
 !ChunkExporter methodsFor: 'private'!
@@ -274,15 +389,14 @@ classNameFor: aClass
 			ifFalse: [aClass name]]
 !
 
-exportCategory: category on: aStream
-	"Issue #143: sort methods alphabetically"
+exportCategoryEpilogueOf: category on: aStream
+	aStream nextPutAll: ' !!'; lf; lf
+!
 
+exportCategoryPrologueOf: category on: aStream
 	aStream
 		nextPutAll: '!!', (self classNameFor: (category at: #class));
-		nextPutAll: ' methodsFor: ''', (category at: #name), '''!!'.
-		((category at: #methods) sorted: [:a :b | a selector <= b selector]) do: [:each |
-				self exportMethod: each on: aStream].
-	aStream nextPutAll: ' !!'; lf; lf
+		nextPutAll: ' methodsFor: ''', (category at: #name), '''!!'
 !
 
 exportDefinitionOf: aClass on: aStream
@@ -348,6 +462,12 @@ extensionCategoriesOfPackage: package
 	^result
 !
 
+methodsOfCategory: category
+	"Issue #143: sort methods alphabetically"
+
+	^(category at: #methods) sorted: [:a :b | a selector <= b selector]
+!
+
 ownCategoriesOfClass: aClass
 	"Issue #143: sort protocol alphabetically"
 
@@ -406,105 +526,6 @@ exportMethod: aMethod on: aStream
 		nextPutAll: ');';lf;lf
 ! !
 
-Object subclass: #Importer
-	instanceVariableNames: ''
-	package: 'Importer-Exporter'!
-!Importer commentStamp!
-I can import Amber code from a string in the chunk format.
-
-## API
-
-    Importer new import: aString!
-
-!Importer methodsFor: 'fileIn'!
-
-import: aStream
-	| chunk result parser lastEmpty |
-	parser := ChunkParser on: aStream.
-	lastEmpty := false.
-	[chunk := parser nextChunk.
-	chunk isNil] whileFalse: [
-		chunk isEmpty
-			ifTrue: [lastEmpty := true]
-			ifFalse: [
-				result := Compiler new evaluateExpression: chunk.
-				lastEmpty
-						ifTrue: [
-									lastEmpty := false.
-									result scanFrom: parser]]]
-! !
-
-Object subclass: #PackageHandler
-	instanceVariableNames: ''
-	package: 'Importer-Exporter'!
-!PackageHandler commentStamp!
-I am responsible for handling package loading and committing.
-
-I should not be used directly. Instead, use the corresponding `Package` methods.!
-
-!PackageHandler methodsFor: 'committing'!
-
-commit: aPackage
-	{ 
-		Exporter -> (aPackage commitPathJs, '/', aPackage name, '.js').
-		StrippedExporter -> (aPackage commitPathJs, '/', aPackage name, '.deploy.js').
-		ChunkExporter -> (aPackage commitPathSt, '/', aPackage name, '.st')
-	} 
-		do: [ :commitStrategy|| fileContents |
-			fileContents := String streamContents: [ :stream |
-				commitStrategy key new exportPackage: aPackage on: stream ].
-			self ajaxPutAt: commitStrategy value data: fileContents ]
-		displayingProgress: 'Committing package ', aPackage name
-! !
-
-!PackageHandler methodsFor: 'loading'!
-
-loadPackage: packageName prefix: aString
-	| url |
-	url := '/', aString, '/js/', packageName, '.js'.
-	jQuery
-		ajax: url
-		options: #{
-			'type' -> 'GET'.
-			'dataType' -> 'script'.
-			'complete' -> [ :jqXHR :textStatus |
-				jqXHR readyState = 4
-					ifTrue: [ self setupPackageNamed: packageName prefix: aString ] ].
-			'error' -> [ window alert: 'Could not load package at: ', url ]
-		}
-!
-
-loadPackages: aCollection prefix: aString
-	aCollection do: [ :each |
-		self loadPackage: each prefix: aString ]
-! !
-
-!PackageHandler methodsFor: 'private'!
-
-ajaxPutAt: aURL data: aString
-	jQuery
-		ajax: aURL 
-		options: #{ 
-			'type' -> 'PUT'.
-			'data' -> aString.
-			'contentType' -> 'text/plain;charset=UTF-8'.
-			'error' -> [ :xhr | self error: 'Commiting ' , aURL , ' failed with reason: "' , (xhr responseText) , '"'] }
-!
-
-setupPackageNamed: packageName prefix: aString
-
-	(Package named: packageName)
-		setupClasses;
-		commitPathJs: '/', aString, '/js';
-		commitPathSt: '/', aString, '/st'
-! !
-
-!PackageHandler class methodsFor: 'loading'!
-
-loadPackages: aCollection prefix: aString
-	^ self new loadPackages: aCollection prefix: aString
-! !
-
 !Package methodsFor: '*Importer-Exporter'!
 
 commit