AmberCli.js 166 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578
  1. define(["amber/boot", "amber_core/Kernel-Objects"], function($boot){"use strict";
  2. if(!$boot.nilAsReceiver)$boot.nilAsReceiver=$boot.nil;
  3. if(!("nilAsValue" in $boot))$boot.nilAsValue=$boot.nilAsReceiver;
  4. var $core=$boot.api,nil=$boot.nilAsValue,$nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
  5. if(!$boot.nilAsClass)$boot.nilAsClass=$boot.dnu;
  6. $core.addPackage("AmberCli");
  7. $core.packages["AmberCli"].innerEval = function (expr) { return eval(expr); };
  8. $core.packages["AmberCli"].transport = {"type":"amd","amdNamespace":"amber_cli"};
  9. $core.addClass("AmberCli", $globals.Object, [], "AmberCli");
  10. //>>excludeStart("ide", pragmas.excludeIdeData);
  11. $globals.AmberCli.comment="I am the Amber CLI (CommandLine Interface) tool which runs on Node.js.\x0a\x0aMy responsibility is to start different Amber programs like the FileServer or the Repl.\x0aWhich program to start is determined by the first commandline parameters passed to the AmberCli executable.\x0aUse `help` to get a list of all available options.\x0aAny further commandline parameters are passed to the specific program.\x0a\x0a## Commands\x0a\x0aNew commands can be added by creating a class side method in the `commands` protocol which takes one parameter.\x0aThis parameter is an array of all commandline options + values passed on to the program.\x0aAny `camelCaseCommand` is transformed into a commandline parameter of the form `camel-case-command` and vice versa.";
  12. //>>excludeEnd("ide");
  13. $core.addMethod(
  14. $core.method({
  15. selector: "commandLineSwitches",
  16. protocol: "commandline",
  17. fn: function (){
  18. var self=this,$self=this;
  19. var switches;
  20. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  21. return $core.withContext(function($ctx1) {
  22. //>>excludeEnd("ctx");
  23. switches=$recv($recv($self._class())._methodsInProtocol_("commands"))._collect_((function(each){
  24. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  25. return $core.withContext(function($ctx2) {
  26. //>>excludeEnd("ctx");
  27. return $recv(each)._selector();
  28. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  29. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  30. //>>excludeEnd("ctx");
  31. }));
  32. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  33. $ctx1.sendIdx["collect:"]=1;
  34. //>>excludeEnd("ctx");
  35. switches=$recv(switches)._select_((function(each){
  36. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  37. return $core.withContext(function($ctx2) {
  38. //>>excludeEnd("ctx");
  39. return $recv(each)._match_("^[^:]*:$");
  40. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  41. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)});
  42. //>>excludeEnd("ctx");
  43. }));
  44. switches=$recv(switches)._collect_((function(each){
  45. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  46. return $core.withContext(function($ctx2) {
  47. //>>excludeEnd("ctx");
  48. return $recv($recv($recv(each)._allButLast())._replace_with_("([A-Z])","-$1"))._asLowercase();
  49. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  50. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,3)});
  51. //>>excludeEnd("ctx");
  52. }));
  53. return switches;
  54. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  55. }, function($ctx1) {$ctx1.fill(self,"commandLineSwitches",{switches:switches},$globals.AmberCli.a$cls)});
  56. //>>excludeEnd("ctx");
  57. },
  58. //>>excludeStart("ide", pragmas.excludeIdeData);
  59. args: [],
  60. source: "commandLineSwitches\x0a\x09\x22Collect all methodnames from the 'commands' protocol of the class\x0a\x09 and select the ones with only one parameter.\x0a\x09 Then remove the ':' at the end of the name.\x0a\x09 Additionally all uppercase letters are made lowercase and preceded by a '-'.\x0a\x09 Example: fallbackPage: becomes --fallback-page.\x0a\x09 Return the Array containing the commandline switches.\x22\x0a\x09| switches |\x0a\x09switches := ((self class methodsInProtocol: 'commands') collect: [ :each | each selector]).\x0a\x09switches := switches select: [ :each | each match: '^[^:]*:$'].\x0a\x09switches :=switches collect: [ :each |\x0a\x09\x09(each allButLast replace: '([A-Z])' with: '-$1') asLowercase].\x0a\x09^ switches",
  61. referencedClasses: [],
  62. //>>excludeEnd("ide");
  63. messageSends: ["collect:", "methodsInProtocol:", "class", "selector", "select:", "match:", "asLowercase", "replace:with:", "allButLast"]
  64. }),
  65. $globals.AmberCli.a$cls);
  66. $core.addMethod(
  67. $core.method({
  68. selector: "config:",
  69. protocol: "commands",
  70. fn: function (args){
  71. var self=this,$self=this;
  72. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  73. return $core.withContext(function($ctx1) {
  74. //>>excludeEnd("ctx");
  75. $recv($recv($globals.Configurator)._new())._start();
  76. return self;
  77. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  78. }, function($ctx1) {$ctx1.fill(self,"config:",{args:args},$globals.AmberCli.a$cls)});
  79. //>>excludeEnd("ctx");
  80. },
  81. //>>excludeStart("ide", pragmas.excludeIdeData);
  82. args: ["args"],
  83. source: "config: args\x0a\x09Configurator new start",
  84. referencedClasses: ["Configurator"],
  85. //>>excludeEnd("ide");
  86. messageSends: ["start", "new"]
  87. }),
  88. $globals.AmberCli.a$cls);
  89. $core.addMethod(
  90. $core.method({
  91. selector: "handleArguments:",
  92. protocol: "commandline",
  93. fn: function (args){
  94. var self=this,$self=this;
  95. var selector;
  96. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  97. return $core.withContext(function($ctx1) {
  98. //>>excludeEnd("ctx");
  99. var $1;
  100. $1=$recv(args)._first();
  101. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  102. $ctx1.sendIdx["first"]=1;
  103. //>>excludeEnd("ctx");
  104. selector=$self._selectorForCommandLineSwitch_($1);
  105. $recv(args)._remove_($recv(args)._first());
  106. $self._perform_withArguments_(selector,$recv($globals.Array)._with_(args));
  107. return self;
  108. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  109. }, function($ctx1) {$ctx1.fill(self,"handleArguments:",{args:args,selector:selector},$globals.AmberCli.a$cls)});
  110. //>>excludeEnd("ctx");
  111. },
  112. //>>excludeStart("ide", pragmas.excludeIdeData);
  113. args: ["args"],
  114. source: "handleArguments: args\x0a\x09| selector |\x0a\x0a\x09selector := self selectorForCommandLineSwitch: (args first).\x0a\x09args remove: args first.\x0a\x09self perform: selector withArguments: (Array with: args)",
  115. referencedClasses: ["Array"],
  116. //>>excludeEnd("ide");
  117. messageSends: ["selectorForCommandLineSwitch:", "first", "remove:", "perform:withArguments:", "with:"]
  118. }),
  119. $globals.AmberCli.a$cls);
  120. $core.addMethod(
  121. $core.method({
  122. selector: "help:",
  123. protocol: "commands",
  124. fn: function (args){
  125. var self=this,$self=this;
  126. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  127. return $core.withContext(function($ctx1) {
  128. //>>excludeEnd("ctx");
  129. $recv($globals.Transcript)._show_("Available commands");
  130. $recv($self._commandLineSwitches())._do_((function(each){
  131. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  132. return $core.withContext(function($ctx2) {
  133. //>>excludeEnd("ctx");
  134. return $recv(console)._log_(each);
  135. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  136. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  137. //>>excludeEnd("ctx");
  138. }));
  139. return self;
  140. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  141. }, function($ctx1) {$ctx1.fill(self,"help:",{args:args},$globals.AmberCli.a$cls)});
  142. //>>excludeEnd("ctx");
  143. },
  144. //>>excludeStart("ide", pragmas.excludeIdeData);
  145. args: ["args"],
  146. source: "help: args\x0a\x09Transcript show: 'Available commands'.\x0a\x09self commandLineSwitches do: [ :each | console log: each ]",
  147. referencedClasses: ["Transcript"],
  148. //>>excludeEnd("ide");
  149. messageSends: ["show:", "do:", "commandLineSwitches", "log:"]
  150. }),
  151. $globals.AmberCli.a$cls);
  152. $core.addMethod(
  153. $core.method({
  154. selector: "init:",
  155. protocol: "commands",
  156. fn: function (args){
  157. var self=this,$self=this;
  158. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  159. return $core.withContext(function($ctx1) {
  160. //>>excludeEnd("ctx");
  161. $recv($recv($globals.Initer)._new())._start();
  162. return self;
  163. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  164. }, function($ctx1) {$ctx1.fill(self,"init:",{args:args},$globals.AmberCli.a$cls)});
  165. //>>excludeEnd("ctx");
  166. },
  167. //>>excludeStart("ide", pragmas.excludeIdeData);
  168. args: ["args"],
  169. source: "init: args\x0a\x09Initer new start",
  170. referencedClasses: ["Initer"],
  171. //>>excludeEnd("ide");
  172. messageSends: ["start", "new"]
  173. }),
  174. $globals.AmberCli.a$cls);
  175. $core.addMethod(
  176. $core.method({
  177. selector: "main",
  178. protocol: "startup",
  179. fn: function (){
  180. var self=this,$self=this;
  181. var args,packageJSON;
  182. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  183. return $core.withContext(function($ctx1) {
  184. //>>excludeEnd("ctx");
  185. var $7,$6,$5,$4,$3,$2,$1;
  186. var $early={};
  187. try {
  188. packageJSON=$recv(require)._value_("../package.json");
  189. $7=$recv(packageJSON)._version();
  190. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  191. $ctx1.sendIdx["version"]=1;
  192. //>>excludeEnd("ctx");
  193. $6="Welcome to Amber CLI version ".__comma($7);
  194. $5=$recv($6).__comma(" (Amber ");
  195. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  196. $ctx1.sendIdx[","]=5;
  197. //>>excludeEnd("ctx");
  198. $4=$recv($5).__comma($recv($globals.Smalltalk)._version());
  199. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  200. $ctx1.sendIdx[","]=4;
  201. //>>excludeEnd("ctx");
  202. $3=$recv($4).__comma(", NodeJS ");
  203. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  204. $ctx1.sendIdx[","]=3;
  205. //>>excludeEnd("ctx");
  206. $2=$recv($3).__comma($recv($recv(process)._versions())._node());
  207. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  208. $ctx1.sendIdx[","]=2;
  209. //>>excludeEnd("ctx");
  210. $1=$recv($2).__comma(").");
  211. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  212. $ctx1.sendIdx[","]=1;
  213. //>>excludeEnd("ctx");
  214. $recv($globals.Transcript)._show_($1);
  215. args=$recv(process)._argv();
  216. $recv(args)._removeFrom_to_((1),(2));
  217. $recv(args)._ifEmpty_ifNotEmpty_((function(){
  218. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  219. return $core.withContext(function($ctx2) {
  220. //>>excludeEnd("ctx");
  221. return $self._help_(nil);
  222. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  223. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  224. //>>excludeEnd("ctx");
  225. }),(function(){
  226. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  227. return $core.withContext(function($ctx2) {
  228. //>>excludeEnd("ctx");
  229. throw $early=[$self._handleArguments_(args)];
  230. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  231. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  232. //>>excludeEnd("ctx");
  233. }));
  234. return self;
  235. }
  236. catch(e) {if(e===$early)return e[0]; throw e}
  237. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  238. }, function($ctx1) {$ctx1.fill(self,"main",{args:args,packageJSON:packageJSON},$globals.AmberCli.a$cls)});
  239. //>>excludeEnd("ctx");
  240. },
  241. //>>excludeStart("ide", pragmas.excludeIdeData);
  242. args: [],
  243. source: "main\x0a\x09\x22Main entry point for Amber applications.\x0a\x09Parses commandline arguments and starts the according subprogram.\x22\x0a\x09| args packageJSON |\x0a\x09\x0a\x09packageJSON := require value: '../package.json'.\x0a\x09Transcript show: 'Welcome to Amber CLI version ', packageJSON version, ' (Amber ', Smalltalk version, ', NodeJS ', process versions node, ').'.\x0a\x0a\x09args := process argv.\x0a\x09\x22Remove the first args which contain the path to the node executable and the script file.\x22\x0a\x09args removeFrom: 1 to: 2.\x0a\x09\x0a\x09args\x0a\x09\x09ifEmpty: [self help: nil]\x0a\x09\x09ifNotEmpty: [^self handleArguments: args]",
  244. referencedClasses: ["Transcript", "Smalltalk"],
  245. //>>excludeEnd("ide");
  246. messageSends: ["value:", "show:", ",", "version", "node", "versions", "argv", "removeFrom:to:", "ifEmpty:ifNotEmpty:", "help:", "handleArguments:"]
  247. }),
  248. $globals.AmberCli.a$cls);
  249. $core.addMethod(
  250. $core.method({
  251. selector: "repl:",
  252. protocol: "commands",
  253. fn: function (args){
  254. var self=this,$self=this;
  255. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  256. return $core.withContext(function($ctx1) {
  257. //>>excludeEnd("ctx");
  258. return $recv($recv($globals.Repl)._new())._createInterface();
  259. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  260. }, function($ctx1) {$ctx1.fill(self,"repl:",{args:args},$globals.AmberCli.a$cls)});
  261. //>>excludeEnd("ctx");
  262. },
  263. //>>excludeStart("ide", pragmas.excludeIdeData);
  264. args: ["args"],
  265. source: "repl: args\x0a\x09^ Repl new createInterface",
  266. referencedClasses: ["Repl"],
  267. //>>excludeEnd("ide");
  268. messageSends: ["createInterface", "new"]
  269. }),
  270. $globals.AmberCli.a$cls);
  271. $core.addMethod(
  272. $core.method({
  273. selector: "selectorForCommandLineSwitch:",
  274. protocol: "commandline",
  275. fn: function (aSwitch){
  276. var self=this,$self=this;
  277. var command,selector;
  278. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  279. return $core.withContext(function($ctx1) {
  280. //>>excludeEnd("ctx");
  281. var $1;
  282. $1=$recv($self._commandLineSwitches())._includes_(aSwitch);
  283. if($core.assert($1)){
  284. selector=$recv($recv(aSwitch)._replace_with_("-[a-z]",(function(each){
  285. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  286. return $core.withContext(function($ctx2) {
  287. //>>excludeEnd("ctx");
  288. return $recv($recv(each)._second())._asUppercase();
  289. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  290. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)});
  291. //>>excludeEnd("ctx");
  292. }))).__comma(":");
  293. selector;
  294. } else {
  295. selector="help:";
  296. selector;
  297. }
  298. return selector;
  299. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  300. }, function($ctx1) {$ctx1.fill(self,"selectorForCommandLineSwitch:",{aSwitch:aSwitch,command:command,selector:selector},$globals.AmberCli.a$cls)});
  301. //>>excludeEnd("ctx");
  302. },
  303. //>>excludeStart("ide", pragmas.excludeIdeData);
  304. args: ["aSwitch"],
  305. source: "selectorForCommandLineSwitch: aSwitch\x0a\x09\x22Add ':' at the end and replace all occurences of a lowercase letter preceded by a '-' with the Uppercase letter.\x0a\x09 Example: fallback-page becomes fallbackPage:.\x0a\x09 If no correct selector is found return 'help:'\x22\x0a\x09 | command selector |\x0a\x0a\x09 (self commandLineSwitches includes: aSwitch)\x0a\x09 ifTrue: [ selector := (aSwitch replace: '-[a-z]' with: [ :each | each second asUppercase ]), ':']\x0a\x09 ifFalse: [ selector := 'help:' ].\x0a\x09^ selector",
  306. referencedClasses: [],
  307. //>>excludeEnd("ide");
  308. messageSends: ["ifTrue:ifFalse:", "includes:", "commandLineSwitches", ",", "replace:with:", "asUppercase", "second"]
  309. }),
  310. $globals.AmberCli.a$cls);
  311. $core.addMethod(
  312. $core.method({
  313. selector: "serve:",
  314. protocol: "commands",
  315. fn: function (args){
  316. var self=this,$self=this;
  317. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  318. return $core.withContext(function($ctx1) {
  319. //>>excludeEnd("ctx");
  320. return $recv($recv($globals.FileServer)._createServerWithArguments_(args))._start();
  321. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  322. }, function($ctx1) {$ctx1.fill(self,"serve:",{args:args},$globals.AmberCli.a$cls)});
  323. //>>excludeEnd("ctx");
  324. },
  325. //>>excludeStart("ide", pragmas.excludeIdeData);
  326. args: ["args"],
  327. source: "serve: args\x0a\x09^ (FileServer createServerWithArguments: args) start",
  328. referencedClasses: ["FileServer"],
  329. //>>excludeEnd("ide");
  330. messageSends: ["start", "createServerWithArguments:"]
  331. }),
  332. $globals.AmberCli.a$cls);
  333. $core.addMethod(
  334. $core.method({
  335. selector: "version:",
  336. protocol: "commands",
  337. fn: function (arguments_){
  338. var self=this,$self=this;
  339. return self;
  340. },
  341. //>>excludeStart("ide", pragmas.excludeIdeData);
  342. args: ["arguments"],
  343. source: "version: arguments",
  344. referencedClasses: [],
  345. //>>excludeEnd("ide");
  346. messageSends: []
  347. }),
  348. $globals.AmberCli.a$cls);
  349. $core.addClass("BaseFileManipulator", $globals.Object, ["path", "fs"], "AmberCli");
  350. $core.addMethod(
  351. $core.method({
  352. selector: "dirname",
  353. protocol: "private",
  354. fn: function (){
  355. var self=this,$self=this;
  356. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  357. return $core.withContext(function($ctx1) {
  358. //>>excludeEnd("ctx");
  359. return __dirname;
  360. return self;
  361. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  362. }, function($ctx1) {$ctx1.fill(self,"dirname",{},$globals.BaseFileManipulator)});
  363. //>>excludeEnd("ctx");
  364. },
  365. //>>excludeStart("ide", pragmas.excludeIdeData);
  366. args: [],
  367. source: "dirname\x0a\x09<inlineJS: 'return __dirname'>",
  368. referencedClasses: [],
  369. //>>excludeEnd("ide");
  370. messageSends: []
  371. }),
  372. $globals.BaseFileManipulator);
  373. $core.addMethod(
  374. $core.method({
  375. selector: "initialize",
  376. protocol: "initialization",
  377. fn: function (){
  378. var self=this,$self=this;
  379. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  380. return $core.withContext(function($ctx1) {
  381. //>>excludeEnd("ctx");
  382. (
  383. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  384. $ctx1.supercall = true,
  385. //>>excludeEnd("ctx");
  386. ($globals.BaseFileManipulator.superclass||$boot.nilAsClass).fn.prototype._initialize.apply($self, []));
  387. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  388. $ctx1.supercall = false;
  389. //>>excludeEnd("ctx");;
  390. $self["@path"]=$recv(require)._value_("path");
  391. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  392. $ctx1.sendIdx["value:"]=1;
  393. //>>excludeEnd("ctx");
  394. $self["@fs"]=$recv(require)._value_("fs");
  395. return self;
  396. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  397. }, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.BaseFileManipulator)});
  398. //>>excludeEnd("ctx");
  399. },
  400. //>>excludeStart("ide", pragmas.excludeIdeData);
  401. args: [],
  402. source: "initialize\x0a\x09super initialize.\x0a\x09path := require value: 'path'.\x0a\x09fs := require value: 'fs'",
  403. referencedClasses: [],
  404. //>>excludeEnd("ide");
  405. messageSends: ["initialize", "value:"]
  406. }),
  407. $globals.BaseFileManipulator);
  408. $core.addMethod(
  409. $core.method({
  410. selector: "rootDirname",
  411. protocol: "private",
  412. fn: function (){
  413. var self=this,$self=this;
  414. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  415. return $core.withContext(function($ctx1) {
  416. //>>excludeEnd("ctx");
  417. return $recv($self["@path"])._join_with_($self._dirname(),"..");
  418. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  419. }, function($ctx1) {$ctx1.fill(self,"rootDirname",{},$globals.BaseFileManipulator)});
  420. //>>excludeEnd("ctx");
  421. },
  422. //>>excludeStart("ide", pragmas.excludeIdeData);
  423. args: [],
  424. source: "rootDirname\x0a\x09^ path join: self dirname with: '..'",
  425. referencedClasses: [],
  426. //>>excludeEnd("ide");
  427. messageSends: ["join:with:", "dirname"]
  428. }),
  429. $globals.BaseFileManipulator);
  430. $core.addClass("Configurator", $globals.BaseFileManipulator, [], "AmberCli");
  431. $core.addMethod(
  432. $core.method({
  433. selector: "initialize",
  434. protocol: "initialization",
  435. fn: function (){
  436. var self=this,$self=this;
  437. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  438. return $core.withContext(function($ctx1) {
  439. //>>excludeEnd("ctx");
  440. (
  441. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  442. $ctx1.supercall = true,
  443. //>>excludeEnd("ctx");
  444. ($globals.Configurator.superclass||$boot.nilAsClass).fn.prototype._initialize.apply($self, []));
  445. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  446. $ctx1.supercall = false;
  447. //>>excludeEnd("ctx");;
  448. return self;
  449. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  450. }, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.Configurator)});
  451. //>>excludeEnd("ctx");
  452. },
  453. //>>excludeStart("ide", pragmas.excludeIdeData);
  454. args: [],
  455. source: "initialize\x0a\x09super initialize",
  456. referencedClasses: [],
  457. //>>excludeEnd("ide");
  458. messageSends: ["initialize"]
  459. }),
  460. $globals.Configurator);
  461. $core.addMethod(
  462. $core.method({
  463. selector: "start",
  464. protocol: "action",
  465. fn: function (){
  466. var self=this,$self=this;
  467. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  468. return $core.withContext(function($ctx1) {
  469. //>>excludeEnd("ctx");
  470. var $receiver;
  471. $self._writeConfigThenDo_((function(err){
  472. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  473. return $core.withContext(function($ctx2) {
  474. //>>excludeEnd("ctx");
  475. if(($receiver = err) == null || $receiver.a$nil){
  476. return $recv(process)._exit();
  477. } else {
  478. return $recv(process)._exit_((111));
  479. }
  480. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  481. }, function($ctx2) {$ctx2.fillBlock({err:err},$ctx1,1)});
  482. //>>excludeEnd("ctx");
  483. }));
  484. return self;
  485. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  486. }, function($ctx1) {$ctx1.fill(self,"start",{},$globals.Configurator)});
  487. //>>excludeEnd("ctx");
  488. },
  489. //>>excludeStart("ide", pragmas.excludeIdeData);
  490. args: [],
  491. source: "start\x0a\x09self writeConfigThenDo: [ :err | err\x0a\x09\x09ifNotNil: [ process exit: 111 ]\x0a\x09\x09ifNil: [ process exit ]]",
  492. referencedClasses: [],
  493. //>>excludeEnd("ide");
  494. messageSends: ["writeConfigThenDo:", "ifNotNil:ifNil:", "exit:", "exit"]
  495. }),
  496. $globals.Configurator);
  497. $core.addMethod(
  498. $core.method({
  499. selector: "writeConfigThenDo:",
  500. protocol: "action",
  501. fn: function (aBlock){
  502. var self=this,$self=this;
  503. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  504. return $core.withContext(function($ctx1) {
  505. //>>excludeEnd("ctx");
  506. $recv($recv($recv(require)._value_("amber-dev"))._configBuilder())._writeConfig_toFile_thenDo_($recv(process)._cwd(),"config.js",aBlock);
  507. return self;
  508. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  509. }, function($ctx1) {$ctx1.fill(self,"writeConfigThenDo:",{aBlock:aBlock},$globals.Configurator)});
  510. //>>excludeEnd("ctx");
  511. },
  512. //>>excludeStart("ide", pragmas.excludeIdeData);
  513. args: ["aBlock"],
  514. source: "writeConfigThenDo: aBlock\x0a\x09(require value: 'amber-dev') configBuilder\x0a\x09\x09writeConfig: process cwd\x0a\x09\x09toFile: 'config.js'\x0a\x09\x09thenDo: aBlock",
  515. referencedClasses: [],
  516. //>>excludeEnd("ide");
  517. messageSends: ["writeConfig:toFile:thenDo:", "configBuilder", "value:", "cwd"]
  518. }),
  519. $globals.Configurator);
  520. $core.addClass("FileServer", $globals.BaseFileManipulator, ["http", "url", "host", "port", "basePath", "util", "username", "password", "fallbackPage"], "AmberCli");
  521. //>>excludeStart("ide", pragmas.excludeIdeData);
  522. $globals.FileServer.comment="I am the Amber Smalltalk FileServer.\x0aMy runtime requirement is a functional Node.js executable.\x0a\x0aTo start a FileServer instance on port `4000` use the following code:\x0a\x0a FileServer new start\x0a\x0aA parameterized instance can be created with the following code:\x0a\x0a FileServer createServerWithArguments: options\x0a\x0aHere, `options` is an array of commandline style strings each followed by a value e.g. `#('--port', '6000', '--host', '0.0.0.0')`.\x0aA list of all available parameters can be printed to the commandline by passing `--help` as parameter.\x0aSee the `Options` section for further details on how options are mapped to instance methods.\x0a\x0aAfter startup FileServer checks if the directory layout required by Amber is present and logs a warning on absence.\x0a\x0a\x0a## Options\x0a\x0aEach option is of the form `--some-option-string` which is transformed into a selector of the format `someOptionString:`.\x0aThe trailing `--` gets removed, each `-[a-z]` gets transformed into the according uppercase letter, and a `:` is appended to create a selector which takes a single argument.\x0aAfterwards, the selector gets executed on the `FileServer` instance with the value following in the options array as parameter.\x0a\x0a## Adding new commandline parameters\x0a\x0aAdding new commandline parameters to `FileServer` is as easy as adding a new single parameter method to the `accessing` protocol.";
  523. //>>excludeEnd("ide");
  524. $core.addMethod(
  525. $core.method({
  526. selector: "base64Decode:",
  527. protocol: "private",
  528. fn: function (aString){
  529. var self=this,$self=this;
  530. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  531. return $core.withContext(function($ctx1) {
  532. //>>excludeEnd("ctx");
  533. return (new Buffer(aString, "base64").toString());
  534. return self;
  535. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  536. }, function($ctx1) {$ctx1.fill(self,"base64Decode:",{aString:aString},$globals.FileServer)});
  537. //>>excludeEnd("ctx");
  538. },
  539. //>>excludeStart("ide", pragmas.excludeIdeData);
  540. args: ["aString"],
  541. source: "base64Decode: aString\x0a\x09<inlineJS: 'return (new Buffer(aString, \x22base64\x22).toString())'>",
  542. referencedClasses: [],
  543. //>>excludeEnd("ide");
  544. messageSends: []
  545. }),
  546. $globals.FileServer);
  547. $core.addMethod(
  548. $core.method({
  549. selector: "basePath",
  550. protocol: "accessing",
  551. fn: function (){
  552. var self=this,$self=this;
  553. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  554. return $core.withContext(function($ctx1) {
  555. //>>excludeEnd("ctx");
  556. var $1,$receiver;
  557. $1=$self["@basePath"];
  558. if(($receiver = $1) == null || $receiver.a$nil){
  559. return $recv($self._class())._defaultBasePath();
  560. } else {
  561. return $1;
  562. }
  563. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  564. }, function($ctx1) {$ctx1.fill(self,"basePath",{},$globals.FileServer)});
  565. //>>excludeEnd("ctx");
  566. },
  567. //>>excludeStart("ide", pragmas.excludeIdeData);
  568. args: [],
  569. source: "basePath\x0a\x09^ basePath ifNil: [self class defaultBasePath]",
  570. referencedClasses: [],
  571. //>>excludeEnd("ide");
  572. messageSends: ["ifNil:", "defaultBasePath", "class"]
  573. }),
  574. $globals.FileServer);
  575. $core.addMethod(
  576. $core.method({
  577. selector: "basePath:",
  578. protocol: "accessing",
  579. fn: function (aString){
  580. var self=this,$self=this;
  581. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  582. return $core.withContext(function($ctx1) {
  583. //>>excludeEnd("ctx");
  584. $self["@basePath"]=aString;
  585. $self._validateBasePath();
  586. return self;
  587. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  588. }, function($ctx1) {$ctx1.fill(self,"basePath:",{aString:aString},$globals.FileServer)});
  589. //>>excludeEnd("ctx");
  590. },
  591. //>>excludeStart("ide", pragmas.excludeIdeData);
  592. args: ["aString"],
  593. source: "basePath: aString\x0a\x09basePath := aString.\x0a\x09self validateBasePath.",
  594. referencedClasses: [],
  595. //>>excludeEnd("ide");
  596. messageSends: ["validateBasePath"]
  597. }),
  598. $globals.FileServer);
  599. $core.addMethod(
  600. $core.method({
  601. selector: "checkDirectoryLayout",
  602. protocol: "initialization",
  603. fn: function (){
  604. var self=this,$self=this;
  605. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  606. return $core.withContext(function($ctx1) {
  607. //>>excludeEnd("ctx");
  608. var $1;
  609. $1=$recv($self["@fs"])._existsSync_($self._withBasePath_("index.html"));
  610. if(!$core.assert($1)){
  611. $recv(console)._warn_("Warning: project directory does not contain index.html.");
  612. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  613. $ctx1.sendIdx["warn:"]=1;
  614. //>>excludeEnd("ctx");
  615. $recv(console)._warn_(" You can specify the directory containing index.html with --base-path.");
  616. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  617. $ctx1.sendIdx["warn:"]=2;
  618. //>>excludeEnd("ctx");
  619. $recv(console)._warn_(" You can also specify a page to be served by default,");
  620. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  621. $ctx1.sendIdx["warn:"]=3;
  622. //>>excludeEnd("ctx");
  623. $recv(console)._warn_(" for all paths that do not map to a file, with --fallback-page.");
  624. }
  625. return self;
  626. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  627. }, function($ctx1) {$ctx1.fill(self,"checkDirectoryLayout",{},$globals.FileServer)});
  628. //>>excludeEnd("ctx");
  629. },
  630. //>>excludeStart("ide", pragmas.excludeIdeData);
  631. args: [],
  632. source: "checkDirectoryLayout\x0a\x09(fs existsSync:\x09(self withBasePath: 'index.html')) ifFalse: [\x0a\x09\x09console warn: 'Warning: project directory does not contain index.html.'.\x0a\x09\x09console warn: ' You can specify the directory containing index.html with --base-path.'.\x0a\x09\x09console warn: ' You can also specify a page to be served by default,'.\x0a\x09\x09console warn: ' for all paths that do not map to a file, with --fallback-page.'].",
  633. referencedClasses: [],
  634. //>>excludeEnd("ide");
  635. messageSends: ["ifFalse:", "existsSync:", "withBasePath:", "warn:"]
  636. }),
  637. $globals.FileServer);
  638. $core.addMethod(
  639. $core.method({
  640. selector: "fallbackPage",
  641. protocol: "accessing",
  642. fn: function (){
  643. var self=this,$self=this;
  644. return $self["@fallbackPage"];
  645. },
  646. //>>excludeStart("ide", pragmas.excludeIdeData);
  647. args: [],
  648. source: "fallbackPage\x0a\x09^ fallbackPage",
  649. referencedClasses: [],
  650. //>>excludeEnd("ide");
  651. messageSends: []
  652. }),
  653. $globals.FileServer);
  654. $core.addMethod(
  655. $core.method({
  656. selector: "fallbackPage:",
  657. protocol: "accessing",
  658. fn: function (aString){
  659. var self=this,$self=this;
  660. $self["@fallbackPage"]=aString;
  661. return self;
  662. },
  663. //>>excludeStart("ide", pragmas.excludeIdeData);
  664. args: ["aString"],
  665. source: "fallbackPage: aString\x0a\x09fallbackPage := aString",
  666. referencedClasses: [],
  667. //>>excludeEnd("ide");
  668. messageSends: []
  669. }),
  670. $globals.FileServer);
  671. $core.addMethod(
  672. $core.method({
  673. selector: "handleGETRequest:respondTo:",
  674. protocol: "request handling",
  675. fn: function (aRequest,aResponse){
  676. var self=this,$self=this;
  677. var uri,filename;
  678. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  679. return $core.withContext(function($ctx1) {
  680. //>>excludeEnd("ctx");
  681. var $1;
  682. uri=$recv($self["@url"])._parse_($recv(aRequest)._url());
  683. filename=$recv($self["@path"])._join_with_($self._basePath(),$recv(uri)._pathname());
  684. $recv($self["@fs"])._exists_do_(filename,(function(aBoolean){
  685. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  686. return $core.withContext(function($ctx2) {
  687. //>>excludeEnd("ctx");
  688. if($core.assert(aBoolean)){
  689. $1=$recv($recv($self["@fs"])._statSync_(filename))._isDirectory();
  690. if($core.assert($1)){
  691. return $self._respondDirectoryNamed_from_to_(filename,uri,aResponse);
  692. } else {
  693. return $self._respondFileNamed_to_(filename,aResponse);
  694. }
  695. } else {
  696. return $self._respondNotFoundTo_(aResponse);
  697. }
  698. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  699. }, function($ctx2) {$ctx2.fillBlock({aBoolean:aBoolean},$ctx1,1)});
  700. //>>excludeEnd("ctx");
  701. }));
  702. return self;
  703. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  704. }, function($ctx1) {$ctx1.fill(self,"handleGETRequest:respondTo:",{aRequest:aRequest,aResponse:aResponse,uri:uri,filename:filename},$globals.FileServer)});
  705. //>>excludeEnd("ctx");
  706. },
  707. //>>excludeStart("ide", pragmas.excludeIdeData);
  708. args: ["aRequest", "aResponse"],
  709. source: "handleGETRequest: aRequest respondTo: aResponse\x0a\x09| uri filename |\x0a\x09uri := url parse: aRequest url.\x0a\x09filename := path join: self basePath with: uri pathname.\x0a\x09fs exists: filename do: [:aBoolean |\x0a\x09\x09aBoolean\x0a\x09\x09\x09ifFalse: [self respondNotFoundTo: aResponse]\x0a\x09\x09\x09ifTrue: [(fs statSync: filename) isDirectory\x0a\x09\x09\x09\x09ifTrue: [self respondDirectoryNamed: filename from: uri to: aResponse]\x0a\x09\x09\x09\x09ifFalse: [self respondFileNamed: filename to: aResponse]]]",
  710. referencedClasses: [],
  711. //>>excludeEnd("ide");
  712. messageSends: ["parse:", "url", "join:with:", "basePath", "pathname", "exists:do:", "ifFalse:ifTrue:", "respondNotFoundTo:", "ifTrue:ifFalse:", "isDirectory", "statSync:", "respondDirectoryNamed:from:to:", "respondFileNamed:to:"]
  713. }),
  714. $globals.FileServer);
  715. $core.addMethod(
  716. $core.method({
  717. selector: "handleOPTIONSRequest:respondTo:",
  718. protocol: "request handling",
  719. fn: function (aRequest,aResponse){
  720. var self=this,$self=this;
  721. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  722. return $core.withContext(function($ctx1) {
  723. //>>excludeEnd("ctx");
  724. $recv(aResponse)._writeHead_options_((200),$globals.HashedCollection._newFromPairs_(["Access-Control-Allow-Origin","*","Access-Control-Allow-Methods","GET, PUT, POST, DELETE, OPTIONS","Access-Control-Allow-Headers","Content-Type, Accept","Content-Length",(0),"Access-Control-Max-Age",(10)]));
  725. $recv(aResponse)._end();
  726. return self;
  727. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  728. }, function($ctx1) {$ctx1.fill(self,"handleOPTIONSRequest:respondTo:",{aRequest:aRequest,aResponse:aResponse},$globals.FileServer)});
  729. //>>excludeEnd("ctx");
  730. },
  731. //>>excludeStart("ide", pragmas.excludeIdeData);
  732. args: ["aRequest", "aResponse"],
  733. source: "handleOPTIONSRequest: aRequest respondTo: aResponse\x0a\x09aResponse writeHead: 200 options: #{'Access-Control-Allow-Origin' -> '*'.\x0a\x09\x09\x09\x09\x09'Access-Control-Allow-Methods' -> 'GET, PUT, POST, DELETE, OPTIONS'.\x0a\x09\x09\x09\x09\x09'Access-Control-Allow-Headers' -> 'Content-Type, Accept'.\x0a\x09\x09\x09\x09\x09'Content-Length' -> 0.\x0a\x09\x09\x09\x09\x09'Access-Control-Max-Age' -> 10}.\x0a\x09aResponse end",
  734. referencedClasses: [],
  735. //>>excludeEnd("ide");
  736. messageSends: ["writeHead:options:", "end"]
  737. }),
  738. $globals.FileServer);
  739. $core.addMethod(
  740. $core.method({
  741. selector: "handlePUTRequest:respondTo:",
  742. protocol: "request handling",
  743. fn: function (aRequest,aResponse){
  744. var self=this,$self=this;
  745. var file,stream;
  746. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  747. return $core.withContext(function($ctx1) {
  748. //>>excludeEnd("ctx");
  749. var $1,$2,$3,$4;
  750. $1=$self._isAuthenticated_(aRequest);
  751. if(!$core.assert($1)){
  752. $self._respondAuthenticationRequiredTo_(aResponse);
  753. return nil;
  754. }
  755. file=".".__comma($recv(aRequest)._url());
  756. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  757. $ctx1.sendIdx[","]=1;
  758. //>>excludeEnd("ctx");
  759. stream=$recv($self["@fs"])._createWriteStream_(file);
  760. $recv(stream)._on_do_("error",(function(error){
  761. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  762. return $core.withContext(function($ctx2) {
  763. //>>excludeEnd("ctx");
  764. $2=console;
  765. $3="Error creating WriteStream for file ".__comma(file);
  766. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  767. $ctx2.sendIdx[","]=2;
  768. //>>excludeEnd("ctx");
  769. $recv($2)._warn_($3);
  770. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  771. $ctx2.sendIdx["warn:"]=1;
  772. //>>excludeEnd("ctx");
  773. $recv(console)._warn_(" Did you forget to create the necessary directory in your project (often /src)?");
  774. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  775. $ctx2.sendIdx["warn:"]=2;
  776. //>>excludeEnd("ctx");
  777. $recv(console)._warn_(" The exact error is: ".__comma(error));
  778. return $self._respondNotCreatedTo_(aResponse);
  779. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  780. }, function($ctx2) {$ctx2.fillBlock({error:error},$ctx1,2)});
  781. //>>excludeEnd("ctx");
  782. }));
  783. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  784. $ctx1.sendIdx["on:do:"]=1;
  785. //>>excludeEnd("ctx");
  786. $recv(stream)._on_do_("close",(function(){
  787. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  788. return $core.withContext(function($ctx2) {
  789. //>>excludeEnd("ctx");
  790. return $self._respondCreatedTo_(aResponse);
  791. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  792. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
  793. //>>excludeEnd("ctx");
  794. }));
  795. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  796. $ctx1.sendIdx["on:do:"]=2;
  797. //>>excludeEnd("ctx");
  798. $recv(aRequest)._setEncoding_("utf8");
  799. $recv(aRequest)._on_do_("data",(function(data){
  800. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  801. return $core.withContext(function($ctx2) {
  802. //>>excludeEnd("ctx");
  803. return $recv(stream)._write_(data);
  804. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  805. }, function($ctx2) {$ctx2.fillBlock({data:data},$ctx1,4)});
  806. //>>excludeEnd("ctx");
  807. }));
  808. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  809. $ctx1.sendIdx["on:do:"]=3;
  810. //>>excludeEnd("ctx");
  811. $recv(aRequest)._on_do_("end",(function(){
  812. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  813. return $core.withContext(function($ctx2) {
  814. //>>excludeEnd("ctx");
  815. $4=$recv(stream)._writable();
  816. if($core.assert($4)){
  817. return $recv(stream)._end();
  818. }
  819. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  820. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,5)});
  821. //>>excludeEnd("ctx");
  822. }));
  823. return self;
  824. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  825. }, function($ctx1) {$ctx1.fill(self,"handlePUTRequest:respondTo:",{aRequest:aRequest,aResponse:aResponse,file:file,stream:stream},$globals.FileServer)});
  826. //>>excludeEnd("ctx");
  827. },
  828. //>>excludeStart("ide", pragmas.excludeIdeData);
  829. args: ["aRequest", "aResponse"],
  830. source: "handlePUTRequest: aRequest respondTo: aResponse\x0a\x09| file stream |\x0a\x09(self isAuthenticated: aRequest)\x0a\x09\x09ifFalse: [self respondAuthenticationRequiredTo: aResponse. ^ nil].\x0a\x0a\x09file := '.', aRequest url.\x0a\x09stream := fs createWriteStream: file.\x0a\x0a\x09stream on: 'error' do: [:error |\x0a\x09\x09console warn: 'Error creating WriteStream for file ', file.\x0a\x09\x09console warn: ' Did you forget to create the necessary directory in your project (often /src)?'.\x0a\x09\x09console warn: ' The exact error is: ', error.\x0a\x09\x09self respondNotCreatedTo: aResponse].\x0a\x0a\x09stream on: 'close' do: [\x0a\x09\x09self respondCreatedTo: aResponse].\x0a\x0a\x09aRequest setEncoding: 'utf8'.\x0a\x09aRequest on: 'data' do: [:data |\x0a\x09\x09stream write: data].\x0a\x0a\x09aRequest on: 'end' do: [\x0a\x09\x09stream writable ifTrue: [stream end]]",
  831. referencedClasses: [],
  832. //>>excludeEnd("ide");
  833. messageSends: ["ifFalse:", "isAuthenticated:", "respondAuthenticationRequiredTo:", ",", "url", "createWriteStream:", "on:do:", "warn:", "respondNotCreatedTo:", "respondCreatedTo:", "setEncoding:", "write:", "ifTrue:", "writable", "end"]
  834. }),
  835. $globals.FileServer);
  836. $core.addMethod(
  837. $core.method({
  838. selector: "handleRequest:respondTo:",
  839. protocol: "request handling",
  840. fn: function (aRequest,aResponse){
  841. var self=this,$self=this;
  842. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  843. return $core.withContext(function($ctx1) {
  844. //>>excludeEnd("ctx");
  845. var $2,$1,$4,$3,$5;
  846. $2=$recv(aRequest)._method();
  847. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  848. $ctx1.sendIdx["method"]=1;
  849. //>>excludeEnd("ctx");
  850. $1=$recv($2).__eq("PUT");
  851. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  852. $ctx1.sendIdx["="]=1;
  853. //>>excludeEnd("ctx");
  854. if($core.assert($1)){
  855. $self._handlePUTRequest_respondTo_(aRequest,aResponse);
  856. }
  857. $4=$recv(aRequest)._method();
  858. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  859. $ctx1.sendIdx["method"]=2;
  860. //>>excludeEnd("ctx");
  861. $3=$recv($4).__eq("GET");
  862. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  863. $ctx1.sendIdx["="]=2;
  864. //>>excludeEnd("ctx");
  865. if($core.assert($3)){
  866. $self._handleGETRequest_respondTo_(aRequest,aResponse);
  867. }
  868. $5=$recv($recv(aRequest)._method()).__eq("OPTIONS");
  869. if($core.assert($5)){
  870. $self._handleOPTIONSRequest_respondTo_(aRequest,aResponse);
  871. }
  872. return self;
  873. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  874. }, function($ctx1) {$ctx1.fill(self,"handleRequest:respondTo:",{aRequest:aRequest,aResponse:aResponse},$globals.FileServer)});
  875. //>>excludeEnd("ctx");
  876. },
  877. //>>excludeStart("ide", pragmas.excludeIdeData);
  878. args: ["aRequest", "aResponse"],
  879. source: "handleRequest: aRequest respondTo: aResponse\x0a\x09aRequest method = 'PUT'\x0a\x09\x09ifTrue: [self handlePUTRequest: aRequest respondTo: aResponse].\x0a\x09aRequest method = 'GET'\x0a\x09\x09ifTrue:[self handleGETRequest: aRequest respondTo: aResponse].\x0a\x09aRequest method = 'OPTIONS'\x0a\x09\x09ifTrue:[self handleOPTIONSRequest: aRequest respondTo: aResponse]",
  880. referencedClasses: [],
  881. //>>excludeEnd("ide");
  882. messageSends: ["ifTrue:", "=", "method", "handlePUTRequest:respondTo:", "handleGETRequest:respondTo:", "handleOPTIONSRequest:respondTo:"]
  883. }),
  884. $globals.FileServer);
  885. $core.addMethod(
  886. $core.method({
  887. selector: "host",
  888. protocol: "accessing",
  889. fn: function (){
  890. var self=this,$self=this;
  891. return $self["@host"];
  892. },
  893. //>>excludeStart("ide", pragmas.excludeIdeData);
  894. args: [],
  895. source: "host\x0a\x09^ host",
  896. referencedClasses: [],
  897. //>>excludeEnd("ide");
  898. messageSends: []
  899. }),
  900. $globals.FileServer);
  901. $core.addMethod(
  902. $core.method({
  903. selector: "host:",
  904. protocol: "accessing",
  905. fn: function (hostname){
  906. var self=this,$self=this;
  907. $self["@host"]=hostname;
  908. return self;
  909. },
  910. //>>excludeStart("ide", pragmas.excludeIdeData);
  911. args: ["hostname"],
  912. source: "host: hostname\x0a\x09host := hostname",
  913. referencedClasses: [],
  914. //>>excludeEnd("ide");
  915. messageSends: []
  916. }),
  917. $globals.FileServer);
  918. $core.addMethod(
  919. $core.method({
  920. selector: "initialize",
  921. protocol: "initialization",
  922. fn: function (){
  923. var self=this,$self=this;
  924. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  925. return $core.withContext(function($ctx1) {
  926. //>>excludeEnd("ctx");
  927. var $1;
  928. (
  929. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  930. $ctx1.supercall = true,
  931. //>>excludeEnd("ctx");
  932. ($globals.FileServer.superclass||$boot.nilAsClass).fn.prototype._initialize.apply($self, []));
  933. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  934. $ctx1.supercall = false;
  935. //>>excludeEnd("ctx");;
  936. $self["@http"]=$self._require_("http");
  937. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  938. $ctx1.sendIdx["require:"]=1;
  939. //>>excludeEnd("ctx");
  940. $self["@util"]=$self._require_("util");
  941. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  942. $ctx1.sendIdx["require:"]=2;
  943. //>>excludeEnd("ctx");
  944. $self["@url"]=$self._require_("url");
  945. $1=$self._class();
  946. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  947. $ctx1.sendIdx["class"]=1;
  948. //>>excludeEnd("ctx");
  949. $self["@host"]=$recv($1)._defaultHost();
  950. $self["@port"]=$recv($self._class())._defaultPort();
  951. $self["@username"]=nil;
  952. $self["@password"]=nil;
  953. $self["@fallbackPage"]=nil;
  954. return self;
  955. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  956. }, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.FileServer)});
  957. //>>excludeEnd("ctx");
  958. },
  959. //>>excludeStart("ide", pragmas.excludeIdeData);
  960. args: [],
  961. source: "initialize\x0a\x09super initialize.\x0a\x09http := self require: 'http'.\x0a\x09util := self require: 'util'.\x0a\x09url := self require: 'url'.\x0a\x09host := self class defaultHost.\x0a\x09port := self class defaultPort.\x0a\x09username := nil.\x0a\x09password := nil.\x0a\x09fallbackPage := nil.",
  962. referencedClasses: [],
  963. //>>excludeEnd("ide");
  964. messageSends: ["initialize", "require:", "defaultHost", "class", "defaultPort"]
  965. }),
  966. $globals.FileServer);
  967. $core.addMethod(
  968. $core.method({
  969. selector: "isAuthenticated:",
  970. protocol: "private",
  971. fn: function (aRequest){
  972. var self=this,$self=this;
  973. var header,token,auth,parts;
  974. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  975. return $core.withContext(function($ctx1) {
  976. //>>excludeEnd("ctx");
  977. var $2,$1,$3,$4,$5,$8,$9,$7,$6,$receiver;
  978. var $early={};
  979. try {
  980. $2=$recv($self["@username"])._isNil();
  981. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  982. $ctx1.sendIdx["isNil"]=1;
  983. //>>excludeEnd("ctx");
  984. $1=$recv($2)._and_((function(){
  985. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  986. return $core.withContext(function($ctx2) {
  987. //>>excludeEnd("ctx");
  988. return $recv($self["@password"])._isNil();
  989. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  990. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  991. //>>excludeEnd("ctx");
  992. }));
  993. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  994. $ctx1.sendIdx["and:"]=1;
  995. //>>excludeEnd("ctx");
  996. if($core.assert($1)){
  997. return true;
  998. }
  999. $3=$recv($recv(aRequest)._headers())._at_("authorization");
  1000. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1001. $ctx1.sendIdx["at:"]=1;
  1002. //>>excludeEnd("ctx");
  1003. if(($receiver = $3) == null || $receiver.a$nil){
  1004. header="";
  1005. } else {
  1006. header=$3;
  1007. }
  1008. $recv(header)._ifEmpty_ifNotEmpty_((function(){
  1009. throw $early=[false];
  1010. }),(function(){
  1011. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1012. return $core.withContext(function($ctx2) {
  1013. //>>excludeEnd("ctx");
  1014. $4=$recv(header)._tokenize_(" ");
  1015. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1016. $ctx2.sendIdx["tokenize:"]=1;
  1017. //>>excludeEnd("ctx");
  1018. if(($receiver = $4) == null || $receiver.a$nil){
  1019. token="";
  1020. } else {
  1021. token=$4;
  1022. }
  1023. token;
  1024. $5=$recv(token)._at_((2));
  1025. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1026. $ctx2.sendIdx["at:"]=2;
  1027. //>>excludeEnd("ctx");
  1028. auth=$self._base64Decode_($5);
  1029. auth;
  1030. parts=$recv(auth)._tokenize_(":");
  1031. parts;
  1032. $8=$self["@username"];
  1033. $9=$recv(parts)._at_((1));
  1034. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1035. $ctx2.sendIdx["at:"]=3;
  1036. //>>excludeEnd("ctx");
  1037. $7=$recv($8).__eq($9);
  1038. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1039. $ctx2.sendIdx["="]=1;
  1040. //>>excludeEnd("ctx");
  1041. $6=$recv($7)._and_((function(){
  1042. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1043. return $core.withContext(function($ctx3) {
  1044. //>>excludeEnd("ctx");
  1045. return $recv($self["@password"]).__eq($recv(parts)._at_((2)));
  1046. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1047. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,7)});
  1048. //>>excludeEnd("ctx");
  1049. }));
  1050. if($core.assert($6)){
  1051. throw $early=[true];
  1052. } else {
  1053. throw $early=[false];
  1054. }
  1055. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1056. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,5)});
  1057. //>>excludeEnd("ctx");
  1058. }));
  1059. return self;
  1060. }
  1061. catch(e) {if(e===$early)return e[0]; throw e}
  1062. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1063. }, function($ctx1) {$ctx1.fill(self,"isAuthenticated:",{aRequest:aRequest,header:header,token:token,auth:auth,parts:parts},$globals.FileServer)});
  1064. //>>excludeEnd("ctx");
  1065. },
  1066. //>>excludeStart("ide", pragmas.excludeIdeData);
  1067. args: ["aRequest"],
  1068. source: "isAuthenticated: aRequest\x0a\x09\x22Basic HTTP Auth: http://stackoverflow.com/a/5957629/293175\x0a\x09 and https://gist.github.com/1686663\x22\x0a\x09| header token auth parts|\x0a\x0a\x09(username isNil and: [password isNil]) ifTrue: [^ true].\x0a\x0a\x09\x22get authentication header\x22\x0a\x09header := (aRequest headers at: 'authorization') ifNil:[''].\x0a\x09header\x0a\x09ifEmpty: [^ false]\x0a\x09ifNotEmpty: [\x0a\x09\x09\x22get authentication token\x22\x0a\x09\x09token := (header tokenize: ' ') ifNil:[''].\x0a\x09\x09\x22convert back from base64\x22\x0a\x09\x09auth := self base64Decode: (token at: 2).\x0a\x09\x09\x22split token at colon\x22\x0a\x09\x09parts := auth tokenize: ':'.\x0a\x0a\x09\x09((username = (parts at: 1)) and: [password = (parts at: 2)])\x0a\x09\x09\x09ifTrue: [^ true]\x0a\x09\x09\x09ifFalse: [^ false]\x0a\x09].",
  1069. referencedClasses: [],
  1070. //>>excludeEnd("ide");
  1071. messageSends: ["ifTrue:", "and:", "isNil", "ifNil:", "at:", "headers", "ifEmpty:ifNotEmpty:", "tokenize:", "base64Decode:", "ifTrue:ifFalse:", "="]
  1072. }),
  1073. $globals.FileServer);
  1074. $core.addMethod(
  1075. $core.method({
  1076. selector: "password:",
  1077. protocol: "accessing",
  1078. fn: function (aPassword){
  1079. var self=this,$self=this;
  1080. $self["@password"]=aPassword;
  1081. return self;
  1082. },
  1083. //>>excludeStart("ide", pragmas.excludeIdeData);
  1084. args: ["aPassword"],
  1085. source: "password: aPassword\x0a\x09password := aPassword.",
  1086. referencedClasses: [],
  1087. //>>excludeEnd("ide");
  1088. messageSends: []
  1089. }),
  1090. $globals.FileServer);
  1091. $core.addMethod(
  1092. $core.method({
  1093. selector: "port",
  1094. protocol: "accessing",
  1095. fn: function (){
  1096. var self=this,$self=this;
  1097. return $self["@port"];
  1098. },
  1099. //>>excludeStart("ide", pragmas.excludeIdeData);
  1100. args: [],
  1101. source: "port\x0a\x09^ port",
  1102. referencedClasses: [],
  1103. //>>excludeEnd("ide");
  1104. messageSends: []
  1105. }),
  1106. $globals.FileServer);
  1107. $core.addMethod(
  1108. $core.method({
  1109. selector: "port:",
  1110. protocol: "accessing",
  1111. fn: function (aNumber){
  1112. var self=this,$self=this;
  1113. $self["@port"]=aNumber;
  1114. return self;
  1115. },
  1116. //>>excludeStart("ide", pragmas.excludeIdeData);
  1117. args: ["aNumber"],
  1118. source: "port: aNumber\x0a\x09port := aNumber",
  1119. referencedClasses: [],
  1120. //>>excludeEnd("ide");
  1121. messageSends: []
  1122. }),
  1123. $globals.FileServer);
  1124. $core.addMethod(
  1125. $core.method({
  1126. selector: "require:",
  1127. protocol: "private",
  1128. fn: function (aModuleString){
  1129. var self=this,$self=this;
  1130. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1131. return $core.withContext(function($ctx1) {
  1132. //>>excludeEnd("ctx");
  1133. return $recv(require)._value_(aModuleString);
  1134. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1135. }, function($ctx1) {$ctx1.fill(self,"require:",{aModuleString:aModuleString},$globals.FileServer)});
  1136. //>>excludeEnd("ctx");
  1137. },
  1138. //>>excludeStart("ide", pragmas.excludeIdeData);
  1139. args: ["aModuleString"],
  1140. source: "require: aModuleString\x0a\x09\x22call to the require function\x22\x0a\x09^require value: aModuleString",
  1141. referencedClasses: [],
  1142. //>>excludeEnd("ide");
  1143. messageSends: ["value:"]
  1144. }),
  1145. $globals.FileServer);
  1146. $core.addMethod(
  1147. $core.method({
  1148. selector: "respondAuthenticationRequiredTo:",
  1149. protocol: "request handling",
  1150. fn: function (aResponse){
  1151. var self=this,$self=this;
  1152. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1153. return $core.withContext(function($ctx1) {
  1154. //>>excludeEnd("ctx");
  1155. $recv(aResponse)._writeHead_options_((401),$globals.HashedCollection._newFromPairs_(["WWW-Authenticate","Basic realm=\x22Secured Developer Area\x22"]));
  1156. $recv(aResponse)._write_("<html><body>Authentication needed</body></html>");
  1157. $recv(aResponse)._end();
  1158. return self;
  1159. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1160. }, function($ctx1) {$ctx1.fill(self,"respondAuthenticationRequiredTo:",{aResponse:aResponse},$globals.FileServer)});
  1161. //>>excludeEnd("ctx");
  1162. },
  1163. //>>excludeStart("ide", pragmas.excludeIdeData);
  1164. args: ["aResponse"],
  1165. source: "respondAuthenticationRequiredTo: aResponse\x0a\x09aResponse\x0a\x09\x09writeHead: 401 options: #{'WWW-Authenticate' -> 'Basic realm=\x22Secured Developer Area\x22'};\x0a\x09\x09write: '<html><body>Authentication needed</body></html>';\x0a\x09\x09end.",
  1166. referencedClasses: [],
  1167. //>>excludeEnd("ide");
  1168. messageSends: ["writeHead:options:", "write:", "end"]
  1169. }),
  1170. $globals.FileServer);
  1171. $core.addMethod(
  1172. $core.method({
  1173. selector: "respondCreatedTo:",
  1174. protocol: "request handling",
  1175. fn: function (aResponse){
  1176. var self=this,$self=this;
  1177. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1178. return $core.withContext(function($ctx1) {
  1179. //>>excludeEnd("ctx");
  1180. $recv(aResponse)._writeHead_options_((201),$globals.HashedCollection._newFromPairs_(["Content-Type","text/plain","Access-Control-Allow-Origin","*"]));
  1181. $recv(aResponse)._end();
  1182. return self;
  1183. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1184. }, function($ctx1) {$ctx1.fill(self,"respondCreatedTo:",{aResponse:aResponse},$globals.FileServer)});
  1185. //>>excludeEnd("ctx");
  1186. },
  1187. //>>excludeStart("ide", pragmas.excludeIdeData);
  1188. args: ["aResponse"],
  1189. source: "respondCreatedTo: aResponse\x0a\x09aResponse\x0a\x09\x09writeHead: 201 options: #{'Content-Type' -> 'text/plain'. 'Access-Control-Allow-Origin' -> '*'};\x0a\x09\x09end.",
  1190. referencedClasses: [],
  1191. //>>excludeEnd("ide");
  1192. messageSends: ["writeHead:options:", "end"]
  1193. }),
  1194. $globals.FileServer);
  1195. $core.addMethod(
  1196. $core.method({
  1197. selector: "respondDirectoryNamed:from:to:",
  1198. protocol: "request handling",
  1199. fn: function (aDirname,aUrl,aResponse){
  1200. var self=this,$self=this;
  1201. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1202. return $core.withContext(function($ctx1) {
  1203. //>>excludeEnd("ctx");
  1204. var $2,$1,$3,$5,$7,$6,$4,$receiver;
  1205. $2=$recv(aUrl)._pathname();
  1206. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1207. $ctx1.sendIdx["pathname"]=1;
  1208. //>>excludeEnd("ctx");
  1209. $1=$recv($2)._endsWith_("/");
  1210. if($core.assert($1)){
  1211. $3=$recv(aDirname).__comma("index.html");
  1212. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1213. $ctx1.sendIdx[","]=1;
  1214. //>>excludeEnd("ctx");
  1215. $self._respondFileNamed_to_($3,aResponse);
  1216. } else {
  1217. $5=$recv($recv(aUrl)._pathname()).__comma("/");
  1218. $7=$recv(aUrl)._search();
  1219. if(($receiver = $7) == null || $receiver.a$nil){
  1220. $6="";
  1221. } else {
  1222. $6=$7;
  1223. }
  1224. $4=$recv($5).__comma($6);
  1225. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1226. $ctx1.sendIdx[","]=2;
  1227. //>>excludeEnd("ctx");
  1228. $self._respondRedirect_to_($4,aResponse);
  1229. }
  1230. return self;
  1231. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1232. }, function($ctx1) {$ctx1.fill(self,"respondDirectoryNamed:from:to:",{aDirname:aDirname,aUrl:aUrl,aResponse:aResponse},$globals.FileServer)});
  1233. //>>excludeEnd("ctx");
  1234. },
  1235. //>>excludeStart("ide", pragmas.excludeIdeData);
  1236. args: ["aDirname", "aUrl", "aResponse"],
  1237. source: "respondDirectoryNamed: aDirname from: aUrl to: aResponse\x0a\x09(aUrl pathname endsWith: '/')\x0a\x09\x09ifTrue: [self respondFileNamed: aDirname, 'index.html' to: aResponse]\x0a\x09\x09ifFalse: [self respondRedirect: aUrl pathname, '/', (aUrl search ifNil: ['']) to: aResponse]",
  1238. referencedClasses: [],
  1239. //>>excludeEnd("ide");
  1240. messageSends: ["ifTrue:ifFalse:", "endsWith:", "pathname", "respondFileNamed:to:", ",", "respondRedirect:to:", "ifNil:", "search"]
  1241. }),
  1242. $globals.FileServer);
  1243. $core.addMethod(
  1244. $core.method({
  1245. selector: "respondFileNamed:to:",
  1246. protocol: "request handling",
  1247. fn: function (aFilename,aResponse){
  1248. var self=this,$self=this;
  1249. var type,filename;
  1250. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1251. return $core.withContext(function($ctx1) {
  1252. //>>excludeEnd("ctx");
  1253. var $1,$2,$3,$4;
  1254. filename=aFilename;
  1255. $recv($self["@fs"])._readFile_do_(filename,(function(ex,file){
  1256. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1257. return $core.withContext(function($ctx2) {
  1258. //>>excludeEnd("ctx");
  1259. $1=$recv(ex)._notNil();
  1260. if($core.assert($1)){
  1261. $2=console;
  1262. $3=$recv(filename).__comma(" does not exist");
  1263. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1264. $ctx2.sendIdx[","]=1;
  1265. //>>excludeEnd("ctx");
  1266. $recv($2)._log_($3);
  1267. return $self._respondNotFoundTo_(aResponse);
  1268. } else {
  1269. type=$recv($self._class())._mimeTypeFor_(filename);
  1270. type;
  1271. $4=$recv(type).__eq("application/javascript");
  1272. if($core.assert($4)){
  1273. type=$recv(type).__comma(";charset=utf-8");
  1274. type;
  1275. }
  1276. $recv(aResponse)._writeHead_options_((200),$globals.HashedCollection._newFromPairs_(["Content-Type",type]));
  1277. $recv(aResponse)._write_encoding_(file,"binary");
  1278. return $recv(aResponse)._end();
  1279. }
  1280. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1281. }, function($ctx2) {$ctx2.fillBlock({ex:ex,file:file},$ctx1,1)});
  1282. //>>excludeEnd("ctx");
  1283. }));
  1284. return self;
  1285. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1286. }, function($ctx1) {$ctx1.fill(self,"respondFileNamed:to:",{aFilename:aFilename,aResponse:aResponse,type:type,filename:filename},$globals.FileServer)});
  1287. //>>excludeEnd("ctx");
  1288. },
  1289. //>>excludeStart("ide", pragmas.excludeIdeData);
  1290. args: ["aFilename", "aResponse"],
  1291. source: "respondFileNamed: aFilename to: aResponse\x0a\x09| type filename |\x0a\x0a\x09filename := aFilename.\x0a\x0a\x09fs readFile: filename do: [:ex :file |\x0a\x09\x09ex notNil \x0a\x09\x09\x09ifTrue: [\x0a\x09\x09\x09\x09console log: filename, ' does not exist'.\x0a\x09\x09\x09\x09self respondNotFoundTo: aResponse]\x0a\x09\x09\x09ifFalse: [\x0a\x09\x09\x09\x09type := self class mimeTypeFor: filename.\x0a\x09\x09\x09\x09type = 'application/javascript'\x0a\x09\x09\x09\x09\x09ifTrue: [ type:=type,';charset=utf-8' ].\x0a\x09\x09\x09\x09aResponse \x0a\x09\x09\x09\x09\x09writeHead: 200 options: #{'Content-Type' -> type};\x0a\x09\x09\x09\x09\x09write: file encoding: 'binary';\x0a\x09\x09\x09\x09\x09end]]",
  1292. referencedClasses: [],
  1293. //>>excludeEnd("ide");
  1294. messageSends: ["readFile:do:", "ifTrue:ifFalse:", "notNil", "log:", ",", "respondNotFoundTo:", "mimeTypeFor:", "class", "ifTrue:", "=", "writeHead:options:", "write:encoding:", "end"]
  1295. }),
  1296. $globals.FileServer);
  1297. $core.addMethod(
  1298. $core.method({
  1299. selector: "respondInternalErrorTo:",
  1300. protocol: "request handling",
  1301. fn: function (aResponse){
  1302. var self=this,$self=this;
  1303. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1304. return $core.withContext(function($ctx1) {
  1305. //>>excludeEnd("ctx");
  1306. $recv(aResponse)._writeHead_options_((500),$globals.HashedCollection._newFromPairs_(["Content-Type","text/plain"]));
  1307. $recv(aResponse)._write_("500 Internal server error");
  1308. $recv(aResponse)._end();
  1309. return self;
  1310. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1311. }, function($ctx1) {$ctx1.fill(self,"respondInternalErrorTo:",{aResponse:aResponse},$globals.FileServer)});
  1312. //>>excludeEnd("ctx");
  1313. },
  1314. //>>excludeStart("ide", pragmas.excludeIdeData);
  1315. args: ["aResponse"],
  1316. source: "respondInternalErrorTo: aResponse\x0a\x09aResponse \x0a\x09\x09writeHead: 500 options: #{'Content-Type' -> 'text/plain'};\x0a\x09\x09write: '500 Internal server error';\x0a\x09\x09end",
  1317. referencedClasses: [],
  1318. //>>excludeEnd("ide");
  1319. messageSends: ["writeHead:options:", "write:", "end"]
  1320. }),
  1321. $globals.FileServer);
  1322. $core.addMethod(
  1323. $core.method({
  1324. selector: "respondNotCreatedTo:",
  1325. protocol: "request handling",
  1326. fn: function (aResponse){
  1327. var self=this,$self=this;
  1328. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1329. return $core.withContext(function($ctx1) {
  1330. //>>excludeEnd("ctx");
  1331. $recv(aResponse)._writeHead_options_((400),$globals.HashedCollection._newFromPairs_(["Content-Type","text/plain"]));
  1332. $recv(aResponse)._write_("File could not be created. Did you forget to create the src directory on the server?");
  1333. $recv(aResponse)._end();
  1334. return self;
  1335. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1336. }, function($ctx1) {$ctx1.fill(self,"respondNotCreatedTo:",{aResponse:aResponse},$globals.FileServer)});
  1337. //>>excludeEnd("ctx");
  1338. },
  1339. //>>excludeStart("ide", pragmas.excludeIdeData);
  1340. args: ["aResponse"],
  1341. source: "respondNotCreatedTo: aResponse\x0a\x09aResponse\x0a\x09\x09writeHead: 400 options: #{'Content-Type' -> 'text/plain'};\x0a\x09\x09write: 'File could not be created. Did you forget to create the src directory on the server?';\x0a\x09\x09end.",
  1342. referencedClasses: [],
  1343. //>>excludeEnd("ide");
  1344. messageSends: ["writeHead:options:", "write:", "end"]
  1345. }),
  1346. $globals.FileServer);
  1347. $core.addMethod(
  1348. $core.method({
  1349. selector: "respondNotFoundTo:",
  1350. protocol: "request handling",
  1351. fn: function (aResponse){
  1352. var self=this,$self=this;
  1353. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1354. return $core.withContext(function($ctx1) {
  1355. //>>excludeEnd("ctx");
  1356. var $2,$1;
  1357. $2=$self._fallbackPage();
  1358. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1359. $ctx1.sendIdx["fallbackPage"]=1;
  1360. //>>excludeEnd("ctx");
  1361. $1=$recv($2)._isNil();
  1362. if(!$core.assert($1)){
  1363. return $self._respondFileNamed_to_($self._fallbackPage(),aResponse);
  1364. }
  1365. $recv(aResponse)._writeHead_options_((404),$globals.HashedCollection._newFromPairs_(["Content-Type","text/html"]));
  1366. $recv(aResponse)._write_("<html><body><p>404 Not found</p>");
  1367. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1368. $ctx1.sendIdx["write:"]=1;
  1369. //>>excludeEnd("ctx");
  1370. $recv(aResponse)._write_("<p>Did you forget to put an index.html file into the directory which is served by \x22bin/amber serve\x22? To solve this you can:<ul>");
  1371. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1372. $ctx1.sendIdx["write:"]=2;
  1373. //>>excludeEnd("ctx");
  1374. $recv(aResponse)._write_("<li>create an index.html in the served directory.</li>");
  1375. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1376. $ctx1.sendIdx["write:"]=3;
  1377. //>>excludeEnd("ctx");
  1378. $recv(aResponse)._write_("<li>can also specify the location of a page to be served whenever path does not resolve to a file with the \x22--fallback-page\x22 option.</li>");
  1379. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1380. $ctx1.sendIdx["write:"]=4;
  1381. //>>excludeEnd("ctx");
  1382. $recv(aResponse)._write_("<li>change the directory to be served with the \x22--base-path\x22 option.</li>");
  1383. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1384. $ctx1.sendIdx["write:"]=5;
  1385. //>>excludeEnd("ctx");
  1386. $recv(aResponse)._write_("</ul></p></body></html>");
  1387. $recv(aResponse)._end();
  1388. return self;
  1389. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1390. }, function($ctx1) {$ctx1.fill(self,"respondNotFoundTo:",{aResponse:aResponse},$globals.FileServer)});
  1391. //>>excludeEnd("ctx");
  1392. },
  1393. //>>excludeStart("ide", pragmas.excludeIdeData);
  1394. args: ["aResponse"],
  1395. source: "respondNotFoundTo: aResponse\x0a\x09self fallbackPage isNil ifFalse: [^self respondFileNamed: self fallbackPage to: aResponse].\x0a\x09aResponse \x0a\x09\x09writeHead: 404 options: #{'Content-Type' -> 'text/html'};\x0a\x09\x09write: '<html><body><p>404 Not found</p>';\x0a\x09\x09write: '<p>Did you forget to put an index.html file into the directory which is served by \x22bin/amber serve\x22? To solve this you can:<ul>';\x0a\x09\x09write: '<li>create an index.html in the served directory.</li>';\x0a\x09\x09write: '<li>can also specify the location of a page to be served whenever path does not resolve to a file with the \x22--fallback-page\x22 option.</li>';\x0a\x09\x09write: '<li>change the directory to be served with the \x22--base-path\x22 option.</li>';\x0a\x09\x09write: '</ul></p></body></html>';\x0a\x09\x09end",
  1396. referencedClasses: [],
  1397. //>>excludeEnd("ide");
  1398. messageSends: ["ifFalse:", "isNil", "fallbackPage", "respondFileNamed:to:", "writeHead:options:", "write:", "end"]
  1399. }),
  1400. $globals.FileServer);
  1401. $core.addMethod(
  1402. $core.method({
  1403. selector: "respondOKTo:",
  1404. protocol: "request handling",
  1405. fn: function (aResponse){
  1406. var self=this,$self=this;
  1407. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1408. return $core.withContext(function($ctx1) {
  1409. //>>excludeEnd("ctx");
  1410. $recv(aResponse)._writeHead_options_((200),$globals.HashedCollection._newFromPairs_(["Content-Type","text/plain","Access-Control-Allow-Origin","*"]));
  1411. $recv(aResponse)._end();
  1412. return self;
  1413. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1414. }, function($ctx1) {$ctx1.fill(self,"respondOKTo:",{aResponse:aResponse},$globals.FileServer)});
  1415. //>>excludeEnd("ctx");
  1416. },
  1417. //>>excludeStart("ide", pragmas.excludeIdeData);
  1418. args: ["aResponse"],
  1419. source: "respondOKTo: aResponse\x0a\x09aResponse\x0a\x09\x09writeHead: 200 options: #{'Content-Type' -> 'text/plain'. 'Access-Control-Allow-Origin' -> '*'};\x0a\x09\x09end.",
  1420. referencedClasses: [],
  1421. //>>excludeEnd("ide");
  1422. messageSends: ["writeHead:options:", "end"]
  1423. }),
  1424. $globals.FileServer);
  1425. $core.addMethod(
  1426. $core.method({
  1427. selector: "respondRedirect:to:",
  1428. protocol: "request handling",
  1429. fn: function (aString,aResponse){
  1430. var self=this,$self=this;
  1431. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1432. return $core.withContext(function($ctx1) {
  1433. //>>excludeEnd("ctx");
  1434. $recv(aResponse)._writeHead_options_((303),$globals.HashedCollection._newFromPairs_(["Location",aString]));
  1435. $recv(aResponse)._end();
  1436. return self;
  1437. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1438. }, function($ctx1) {$ctx1.fill(self,"respondRedirect:to:",{aString:aString,aResponse:aResponse},$globals.FileServer)});
  1439. //>>excludeEnd("ctx");
  1440. },
  1441. //>>excludeStart("ide", pragmas.excludeIdeData);
  1442. args: ["aString", "aResponse"],
  1443. source: "respondRedirect: aString to: aResponse\x0a\x09aResponse\x0a\x09\x09writeHead: 303 options: #{'Location' -> aString};\x0a\x09\x09end.",
  1444. referencedClasses: [],
  1445. //>>excludeEnd("ide");
  1446. messageSends: ["writeHead:options:", "end"]
  1447. }),
  1448. $globals.FileServer);
  1449. $core.addMethod(
  1450. $core.method({
  1451. selector: "start",
  1452. protocol: "starting",
  1453. fn: function (){
  1454. var self=this,$self=this;
  1455. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1456. return $core.withContext(function($ctx1) {
  1457. //>>excludeEnd("ctx");
  1458. var $1,$2,$3,$4,$8,$7,$6,$10,$9,$5;
  1459. $self._checkDirectoryLayout();
  1460. $1=$recv($self["@http"])._createServer_((function(request,response){
  1461. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1462. return $core.withContext(function($ctx2) {
  1463. //>>excludeEnd("ctx");
  1464. return $self._handleRequest_respondTo_(request,response);
  1465. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1466. }, function($ctx2) {$ctx2.fillBlock({request:request,response:response},$ctx1,1)});
  1467. //>>excludeEnd("ctx");
  1468. }));
  1469. $recv($1)._on_do_("error",(function(error){
  1470. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1471. return $core.withContext(function($ctx2) {
  1472. //>>excludeEnd("ctx");
  1473. $2=console;
  1474. $3="Error starting server: ".__comma(error);
  1475. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1476. $ctx2.sendIdx[","]=1;
  1477. //>>excludeEnd("ctx");
  1478. return $recv($2)._log_($3);
  1479. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1480. $ctx2.sendIdx["log:"]=1;
  1481. //>>excludeEnd("ctx");
  1482. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1483. }, function($ctx2) {$ctx2.fillBlock({error:error},$ctx1,2)});
  1484. //>>excludeEnd("ctx");
  1485. }));
  1486. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1487. $ctx1.sendIdx["on:do:"]=1;
  1488. //>>excludeEnd("ctx");
  1489. $recv($1)._on_do_("listening",(function(){
  1490. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1491. return $core.withContext(function($ctx2) {
  1492. //>>excludeEnd("ctx");
  1493. $4=console;
  1494. $8=$self._host();
  1495. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1496. $ctx2.sendIdx["host"]=1;
  1497. //>>excludeEnd("ctx");
  1498. $7="Starting file server on http://".__comma($8);
  1499. $6=$recv($7).__comma(":");
  1500. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1501. $ctx2.sendIdx[","]=3;
  1502. //>>excludeEnd("ctx");
  1503. $10=$self._port();
  1504. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1505. $ctx2.sendIdx["port"]=1;
  1506. //>>excludeEnd("ctx");
  1507. $9=$recv($10)._asString();
  1508. $5=$recv($6).__comma($9);
  1509. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1510. $ctx2.sendIdx[","]=2;
  1511. //>>excludeEnd("ctx");
  1512. return $recv($4)._log_($5);
  1513. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1514. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
  1515. //>>excludeEnd("ctx");
  1516. }));
  1517. $recv($1)._listen_host_($self._port(),$self._host());
  1518. return self;
  1519. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1520. }, function($ctx1) {$ctx1.fill(self,"start",{},$globals.FileServer)});
  1521. //>>excludeEnd("ctx");
  1522. },
  1523. //>>excludeStart("ide", pragmas.excludeIdeData);
  1524. args: [],
  1525. source: "start\x0a\x09\x22Checks if required directory layout is present (issue warning if not).\x0a\x09 Afterwards start the server.\x22\x0a\x09self checkDirectoryLayout.\x0a\x09(http createServer: [:request :response |\x0a\x09 self handleRequest: request respondTo: response])\x0a\x09 on: 'error' do: [:error | console log: 'Error starting server: ', error];\x0a\x09 on: 'listening' do: [console log: 'Starting file server on http://', self host, ':', self port asString];\x0a\x09 listen: self port host: self host.",
  1526. referencedClasses: [],
  1527. //>>excludeEnd("ide");
  1528. messageSends: ["checkDirectoryLayout", "on:do:", "createServer:", "handleRequest:respondTo:", "log:", ",", "host", "asString", "port", "listen:host:"]
  1529. }),
  1530. $globals.FileServer);
  1531. $core.addMethod(
  1532. $core.method({
  1533. selector: "startOn:",
  1534. protocol: "starting",
  1535. fn: function (aPort){
  1536. var self=this,$self=this;
  1537. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1538. return $core.withContext(function($ctx1) {
  1539. //>>excludeEnd("ctx");
  1540. $self._port_(aPort);
  1541. $self._start();
  1542. return self;
  1543. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1544. }, function($ctx1) {$ctx1.fill(self,"startOn:",{aPort:aPort},$globals.FileServer)});
  1545. //>>excludeEnd("ctx");
  1546. },
  1547. //>>excludeStart("ide", pragmas.excludeIdeData);
  1548. args: ["aPort"],
  1549. source: "startOn: aPort\x0a\x09self port: aPort.\x0a\x09self start",
  1550. referencedClasses: [],
  1551. //>>excludeEnd("ide");
  1552. messageSends: ["port:", "start"]
  1553. }),
  1554. $globals.FileServer);
  1555. $core.addMethod(
  1556. $core.method({
  1557. selector: "username:",
  1558. protocol: "accessing",
  1559. fn: function (aUsername){
  1560. var self=this,$self=this;
  1561. $self["@username"]=aUsername;
  1562. return self;
  1563. },
  1564. //>>excludeStart("ide", pragmas.excludeIdeData);
  1565. args: ["aUsername"],
  1566. source: "username: aUsername\x0a\x09username := aUsername.",
  1567. referencedClasses: [],
  1568. //>>excludeEnd("ide");
  1569. messageSends: []
  1570. }),
  1571. $globals.FileServer);
  1572. $core.addMethod(
  1573. $core.method({
  1574. selector: "validateBasePath",
  1575. protocol: "private",
  1576. fn: function (){
  1577. var self=this,$self=this;
  1578. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1579. return $core.withContext(function($ctx1) {
  1580. //>>excludeEnd("ctx");
  1581. var $1,$2,$3,$4,$7,$6,$5,$8,$9,$receiver;
  1582. $1=$self["@fs"];
  1583. $2=$self._basePath();
  1584. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1585. $ctx1.sendIdx["basePath"]=1;
  1586. //>>excludeEnd("ctx");
  1587. $recv($1)._stat_then_($2,(function(err,stat){
  1588. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1589. return $core.withContext(function($ctx2) {
  1590. //>>excludeEnd("ctx");
  1591. if(($receiver = err) == null || $receiver.a$nil){
  1592. $3=$recv(stat)._isDirectory();
  1593. if(!$core.assert($3)){
  1594. $4=console;
  1595. $7=$self._basePath();
  1596. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1597. $ctx2.sendIdx["basePath"]=2;
  1598. //>>excludeEnd("ctx");
  1599. $6="Warning: --base-path parameter ".__comma($7);
  1600. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1601. $ctx2.sendIdx[","]=2;
  1602. //>>excludeEnd("ctx");
  1603. $5=$recv($6).__comma(" is not a directory.");
  1604. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1605. $ctx2.sendIdx[","]=1;
  1606. //>>excludeEnd("ctx");
  1607. return $recv($4)._warn_($5);
  1608. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1609. $ctx2.sendIdx["warn:"]=1;
  1610. //>>excludeEnd("ctx");
  1611. }
  1612. } else {
  1613. $8=console;
  1614. $9=$recv("Warning: path at --base-path parameter ".__comma($self._basePath())).__comma(" does not exist.");
  1615. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1616. $ctx2.sendIdx[","]=3;
  1617. //>>excludeEnd("ctx");
  1618. return $recv($8)._warn_($9);
  1619. }
  1620. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1621. }, function($ctx2) {$ctx2.fillBlock({err:err,stat:stat},$ctx1,1)});
  1622. //>>excludeEnd("ctx");
  1623. }));
  1624. return self;
  1625. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1626. }, function($ctx1) {$ctx1.fill(self,"validateBasePath",{},$globals.FileServer)});
  1627. //>>excludeEnd("ctx");
  1628. },
  1629. //>>excludeStart("ide", pragmas.excludeIdeData);
  1630. args: [],
  1631. source: "validateBasePath\x0a\x09\x22The basePath must be an existing directory. \x22\x0a\x09fs stat: self basePath then: [ :err :stat | err\x0a\x09\x09ifNil: [ stat isDirectory ifFalse: [ console warn: 'Warning: --base-path parameter ' , self basePath , ' is not a directory.' ]]\x0a\x09\x09ifNotNil: [ console warn: 'Warning: path at --base-path parameter ' , self basePath , ' does not exist.' ]].",
  1632. referencedClasses: [],
  1633. //>>excludeEnd("ide");
  1634. messageSends: ["stat:then:", "basePath", "ifNil:ifNotNil:", "ifFalse:", "isDirectory", "warn:", ","]
  1635. }),
  1636. $globals.FileServer);
  1637. $core.addMethod(
  1638. $core.method({
  1639. selector: "withBasePath:",
  1640. protocol: "private",
  1641. fn: function (aBaseRelativePath){
  1642. var self=this,$self=this;
  1643. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1644. return $core.withContext(function($ctx1) {
  1645. //>>excludeEnd("ctx");
  1646. return $recv($self["@path"])._join_with_($self._basePath(),aBaseRelativePath);
  1647. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1648. }, function($ctx1) {$ctx1.fill(self,"withBasePath:",{aBaseRelativePath:aBaseRelativePath},$globals.FileServer)});
  1649. //>>excludeEnd("ctx");
  1650. },
  1651. //>>excludeStart("ide", pragmas.excludeIdeData);
  1652. args: ["aBaseRelativePath"],
  1653. source: "withBasePath: aBaseRelativePath\x0a\x09\x22return a file path which is relative to the basePath.\x22\x0a\x09^ path join: self basePath with: aBaseRelativePath",
  1654. referencedClasses: [],
  1655. //>>excludeEnd("ide");
  1656. messageSends: ["join:with:", "basePath"]
  1657. }),
  1658. $globals.FileServer);
  1659. $core.addMethod(
  1660. $core.method({
  1661. selector: "writeData:toFileNamed:",
  1662. protocol: "private",
  1663. fn: function (data,aFilename){
  1664. var self=this,$self=this;
  1665. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1666. return $core.withContext(function($ctx1) {
  1667. //>>excludeEnd("ctx");
  1668. $recv(console)._log_(aFilename);
  1669. return self;
  1670. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1671. }, function($ctx1) {$ctx1.fill(self,"writeData:toFileNamed:",{data:data,aFilename:aFilename},$globals.FileServer)});
  1672. //>>excludeEnd("ctx");
  1673. },
  1674. //>>excludeStart("ide", pragmas.excludeIdeData);
  1675. args: ["data", "aFilename"],
  1676. source: "writeData: data toFileNamed: aFilename\x0a\x09console log: aFilename",
  1677. referencedClasses: [],
  1678. //>>excludeEnd("ide");
  1679. messageSends: ["log:"]
  1680. }),
  1681. $globals.FileServer);
  1682. $globals.FileServer.a$cls.iVarNames = ["mimeTypes"];
  1683. $core.addMethod(
  1684. $core.method({
  1685. selector: "commandLineSwitches",
  1686. protocol: "accessing",
  1687. fn: function (){
  1688. var self=this,$self=this;
  1689. var switches;
  1690. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1691. return $core.withContext(function($ctx1) {
  1692. //>>excludeEnd("ctx");
  1693. switches=$recv($self._methodsInProtocol_("accessing"))._collect_((function(each){
  1694. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1695. return $core.withContext(function($ctx2) {
  1696. //>>excludeEnd("ctx");
  1697. return $recv(each)._selector();
  1698. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1699. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  1700. //>>excludeEnd("ctx");
  1701. }));
  1702. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1703. $ctx1.sendIdx["collect:"]=1;
  1704. //>>excludeEnd("ctx");
  1705. switches=$recv(switches)._select_((function(each){
  1706. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1707. return $core.withContext(function($ctx2) {
  1708. //>>excludeEnd("ctx");
  1709. return $recv(each)._match_("^[^:]*:$");
  1710. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1711. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)});
  1712. //>>excludeEnd("ctx");
  1713. }));
  1714. switches=$recv(switches)._collect_((function(each){
  1715. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1716. return $core.withContext(function($ctx2) {
  1717. //>>excludeEnd("ctx");
  1718. return $recv($recv($recv($recv(each)._allButLast())._replace_with_("([A-Z])","-$1"))._asLowercase())._replace_with_("^([a-z])","--$1");
  1719. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1720. $ctx2.sendIdx["replace:with:"]=1;
  1721. //>>excludeEnd("ctx");
  1722. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1723. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,3)});
  1724. //>>excludeEnd("ctx");
  1725. }));
  1726. return switches;
  1727. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1728. }, function($ctx1) {$ctx1.fill(self,"commandLineSwitches",{switches:switches},$globals.FileServer.a$cls)});
  1729. //>>excludeEnd("ctx");
  1730. },
  1731. //>>excludeStart("ide", pragmas.excludeIdeData);
  1732. args: [],
  1733. source: "commandLineSwitches\x0a\x09\x22Collect all methodnames from the 'accessing' protocol\x0a\x09 and select the ones with only one parameter.\x0a\x09 Then remove the ':' at the end of the name\x0a\x09 and add a '--' at the beginning.\x0a\x09 Additionally all uppercase letters are made lowercase and preceded by a '-'.\x0a\x09 Example: fallbackPage: becomes --fallback-page.\x0a\x09 Return the Array containing the commandline switches.\x22\x0a\x09| switches |\x0a\x09switches := ((self methodsInProtocol: 'accessing') collect: [ :each | each selector]).\x0a\x09switches := switches select: [ :each | each match: '^[^:]*:$'].\x0a\x09switches :=switches collect: [ :each |\x0a\x09\x09(each allButLast replace: '([A-Z])' with: '-$1') asLowercase replace: '^([a-z])' with: '--$1' ].\x0a\x09^ switches",
  1734. referencedClasses: [],
  1735. //>>excludeEnd("ide");
  1736. messageSends: ["collect:", "methodsInProtocol:", "selector", "select:", "match:", "replace:with:", "asLowercase", "allButLast"]
  1737. }),
  1738. $globals.FileServer.a$cls);
  1739. $core.addMethod(
  1740. $core.method({
  1741. selector: "createServerWithArguments:",
  1742. protocol: "initialization",
  1743. fn: function (options){
  1744. var self=this,$self=this;
  1745. var server,popFront,front,optionName,optionValue,switches;
  1746. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1747. return $core.withContext(function($ctx1) {
  1748. //>>excludeEnd("ctx");
  1749. var $1,$2,$3,$4,$5,$6,$7,$8;
  1750. var $early={};
  1751. try {
  1752. switches=$self._commandLineSwitches();
  1753. server=$self._new();
  1754. $recv(options)._ifEmpty_((function(){
  1755. throw $early=[server];
  1756. }));
  1757. $1=$recv($recv(options)._size())._even();
  1758. if(!$core.assert($1)){
  1759. $recv(console)._log_("Using default parameters.");
  1760. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1761. $ctx1.sendIdx["log:"]=1;
  1762. //>>excludeEnd("ctx");
  1763. $2=console;
  1764. $3="Wrong commandline options or not enough arguments for: ".__comma(options);
  1765. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1766. $ctx1.sendIdx[","]=1;
  1767. //>>excludeEnd("ctx");
  1768. $recv($2)._log_($3);
  1769. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1770. $ctx1.sendIdx["log:"]=2;
  1771. //>>excludeEnd("ctx");
  1772. $4=console;
  1773. $5="Use any of the following ones: ".__comma(switches);
  1774. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1775. $ctx1.sendIdx[","]=2;
  1776. //>>excludeEnd("ctx");
  1777. $recv($4)._log_($5);
  1778. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1779. $ctx1.sendIdx["log:"]=3;
  1780. //>>excludeEnd("ctx");
  1781. return server;
  1782. }
  1783. popFront=(function(args){
  1784. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1785. return $core.withContext(function($ctx2) {
  1786. //>>excludeEnd("ctx");
  1787. front=$recv(args)._first();
  1788. front;
  1789. $recv(args)._remove_(front);
  1790. return front;
  1791. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1792. }, function($ctx2) {$ctx2.fillBlock({args:args},$ctx1,3)});
  1793. //>>excludeEnd("ctx");
  1794. });
  1795. $recv((function(){
  1796. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1797. return $core.withContext(function($ctx2) {
  1798. //>>excludeEnd("ctx");
  1799. return $recv(options)._notEmpty();
  1800. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1801. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,4)});
  1802. //>>excludeEnd("ctx");
  1803. }))._whileTrue_((function(){
  1804. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1805. return $core.withContext(function($ctx2) {
  1806. //>>excludeEnd("ctx");
  1807. optionName=$recv(popFront)._value_(options);
  1808. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1809. $ctx2.sendIdx["value:"]=1;
  1810. //>>excludeEnd("ctx");
  1811. optionName;
  1812. optionValue=$recv(popFront)._value_(options);
  1813. optionValue;
  1814. $6=$recv(switches)._includes_(optionName);
  1815. if($core.assert($6)){
  1816. optionName=$self._selectorForCommandLineSwitch_(optionName);
  1817. optionName;
  1818. return $recv(server)._perform_withArguments_(optionName,$recv($globals.Array)._with_(optionValue));
  1819. } else {
  1820. $7=console;
  1821. $8=$recv(optionName).__comma(" is not a valid commandline option");
  1822. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1823. $ctx2.sendIdx[","]=3;
  1824. //>>excludeEnd("ctx");
  1825. $recv($7)._log_($8);
  1826. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1827. $ctx2.sendIdx["log:"]=4;
  1828. //>>excludeEnd("ctx");
  1829. return $recv(console)._log_("Use any of the following ones: ".__comma(switches));
  1830. }
  1831. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1832. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,5)});
  1833. //>>excludeEnd("ctx");
  1834. }));
  1835. return server;
  1836. }
  1837. catch(e) {if(e===$early)return e[0]; throw e}
  1838. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1839. }, function($ctx1) {$ctx1.fill(self,"createServerWithArguments:",{options:options,server:server,popFront:popFront,front:front,optionName:optionName,optionValue:optionValue,switches:switches},$globals.FileServer.a$cls)});
  1840. //>>excludeEnd("ctx");
  1841. },
  1842. //>>excludeStart("ide", pragmas.excludeIdeData);
  1843. args: ["options"],
  1844. source: "createServerWithArguments: options\x0a\x09\x22If options are empty return a default FileServer instance.\x0a\x09 If options are given loop through them and set the passed in values\x0a\x09 on the FileServer instance.\x0a\x09 \x0a\x09 Commanline options map directly to methods in the 'accessing' protocol\x0a\x09 taking one parameter.\x0a\x09 Adding a method to this protocol makes it directly settable through\x0a\x09 command line options.\x0a\x09 \x22\x0a\x09| server popFront front optionName optionValue switches |\x0a\x0a\x09switches := self commandLineSwitches.\x0a\x0a\x09server := self new.\x0a\x0a\x09options ifEmpty: [^server].\x0a\x0a\x09(options size even) ifFalse: [\x0a\x09\x09console log: 'Using default parameters.'.\x0a\x09\x09console log: 'Wrong commandline options or not enough arguments for: ' , options.\x0a\x09\x09console log: 'Use any of the following ones: ', switches.\x0a\x09\x09^server].\x0a\x0a\x09popFront := [:args |\x0a\x09\x09front := args first.\x0a\x09\x09args remove: front.\x0a\x09\x09front].\x0a\x0a\x09[options notEmpty] whileTrue: [\x0a\x09\x09optionName := popFront value: options.\x0a\x09\x09optionValue := popFront value: options.\x0a\x0a\x09\x09(switches includes: optionName) ifTrue: [\x0a\x09\x09\x09optionName := self selectorForCommandLineSwitch: optionName.\x0a\x09\x09\x09server perform: optionName withArguments: (Array with: optionValue)]\x0a\x09\x09\x09ifFalse: [\x0a\x09\x09\x09\x09console log: optionName, ' is not a valid commandline option'.\x0a\x09\x09\x09\x09console log: 'Use any of the following ones: ', switches ]].\x0a\x09^ server.",
  1845. referencedClasses: ["Array"],
  1846. //>>excludeEnd("ide");
  1847. messageSends: ["commandLineSwitches", "new", "ifEmpty:", "ifFalse:", "even", "size", "log:", ",", "first", "remove:", "whileTrue:", "notEmpty", "value:", "ifTrue:ifFalse:", "includes:", "selectorForCommandLineSwitch:", "perform:withArguments:", "with:"]
  1848. }),
  1849. $globals.FileServer.a$cls);
  1850. $core.addMethod(
  1851. $core.method({
  1852. selector: "defaultBasePath",
  1853. protocol: "accessing",
  1854. fn: function (){
  1855. var self=this,$self=this;
  1856. return "./";
  1857. },
  1858. //>>excludeStart("ide", pragmas.excludeIdeData);
  1859. args: [],
  1860. source: "defaultBasePath\x0a\x09^ './'",
  1861. referencedClasses: [],
  1862. //>>excludeEnd("ide");
  1863. messageSends: []
  1864. }),
  1865. $globals.FileServer.a$cls);
  1866. $core.addMethod(
  1867. $core.method({
  1868. selector: "defaultHost",
  1869. protocol: "accessing",
  1870. fn: function (){
  1871. var self=this,$self=this;
  1872. return "127.0.0.1";
  1873. },
  1874. //>>excludeStart("ide", pragmas.excludeIdeData);
  1875. args: [],
  1876. source: "defaultHost\x0a\x09^ '127.0.0.1'",
  1877. referencedClasses: [],
  1878. //>>excludeEnd("ide");
  1879. messageSends: []
  1880. }),
  1881. $globals.FileServer.a$cls);
  1882. $core.addMethod(
  1883. $core.method({
  1884. selector: "defaultMimeTypes",
  1885. protocol: "accessing",
  1886. fn: function (){
  1887. var self=this,$self=this;
  1888. return $globals.HashedCollection._newFromPairs_(["%","application/x-trash","323","text/h323","abw","application/x-abiword","ai","application/postscript","aif","audio/x-aiff","aifc","audio/x-aiff","aiff","audio/x-aiff","alc","chemical/x-alchemy","art","image/x-jg","asc","text/plain","asf","video/x-ms-asf","asn","chemical/x-ncbi-asn1-spec","aso","chemical/x-ncbi-asn1-binary","asx","video/x-ms-asf","au","audio/basic","avi","video/x-msvideo","b","chemical/x-molconn-Z","bak","application/x-trash","bat","application/x-msdos-program","bcpio","application/x-bcpio","bib","text/x-bibtex","bin","application/octet-stream","bmp","image/x-ms-bmp","book","application/x-maker","bsd","chemical/x-crossfire","c","text/x-csrc","c++","text/x-c++src","c3d","chemical/x-chem3d","cac","chemical/x-cache","cache","chemical/x-cache","cascii","chemical/x-cactvs-binary","cat","application/vnd.ms-pki.seccat","cbin","chemical/x-cactvs-binary","cc","text/x-c++src","cdf","application/x-cdf","cdr","image/x-coreldraw","cdt","image/x-coreldrawtemplate","cdx","chemical/x-cdx","cdy","application/vnd.cinderella","cef","chemical/x-cxf","cer","chemical/x-cerius","chm","chemical/x-chemdraw","chrt","application/x-kchart","cif","chemical/x-cif","class","application/java-vm","cls","text/x-tex","cmdf","chemical/x-cmdf","cml","chemical/x-cml","cod","application/vnd.rim.cod","com","application/x-msdos-program","cpa","chemical/x-compass","cpio","application/x-cpio","cpp","text/x-c++src","cpt","image/x-corelphotopaint","crl","application/x-pkcs7-crl","crt","application/x-x509-ca-cert","csf","chemical/x-cache-csf","csh","text/x-csh","csm","chemical/x-csml","csml","chemical/x-csml","css","text/css","csv","text/comma-separated-values","ctab","chemical/x-cactvs-binary","ctx","chemical/x-ctx","cu","application/cu-seeme","cub","chemical/x-gaussian-cube","cxf","chemical/x-cxf","cxx","text/x-c++src","dat","chemical/x-mopac-input","dcr","application/x-director","deb","application/x-debian-package","dif","video/dv","diff","text/plain","dir","application/x-director","djv","image/vnd.djvu","djvu","image/vnd.djvu","dl","video/dl","dll","application/x-msdos-program","dmg","application/x-apple-diskimage","dms","application/x-dms","doc","application/msword","dot","application/msword","dv","video/dv","dvi","application/x-dvi","dx","chemical/x-jcamp-dx","dxr","application/x-director","emb","chemical/x-embl-dl-nucleotide","embl","chemical/x-embl-dl-nucleotide","ent","chemical/x-pdb","eps","application/postscript","etx","text/x-setext","exe","application/x-msdos-program","ez","application/andrew-inset","fb","application/x-maker","fbdoc","application/x-maker","fch","chemical/x-gaussian-checkpoint","fchk","chemical/x-gaussian-checkpoint","fig","application/x-xfig","flac","application/x-flac","fli","video/fli","fm","application/x-maker","frame","application/x-maker","frm","application/x-maker","gal","chemical/x-gaussian-log","gam","chemical/x-gamess-input","gamin","chemical/x-gamess-input","gau","chemical/x-gaussian-input","gcd","text/x-pcs-gcd","gcf","application/x-graphing-calculator","gcg","chemical/x-gcg8-sequence","gen","chemical/x-genbank","gf","application/x-tex-gf","gif","image/gif","gjc","chemical/x-gaussian-input","gjf","chemical/x-gaussian-input","gl","video/gl","gnumeric","application/x-gnumeric","gpt","chemical/x-mopac-graph","gsf","application/x-font","gsm","audio/x-gsm","gtar","application/x-gtar","h","text/x-chdr","h++","text/x-c++hdr","hdf","application/x-hdf","hh","text/x-c++hdr","hin","chemical/x-hin","hpp","text/x-c++hdr","hqx","application/mac-binhex40","hs","text/x-haskell","hta","application/hta","htc","text/x-component","htm","text/html","html","text/html","hxx","text/x-c++hdr","ica","application/x-ica","ice","x-conference/x-cooltalk","ico","image/x-icon","ics","text/calendar","icz","text/calendar","ief","image/ief","iges","model/iges","igs","model/iges","iii","application/x-iphone","inp","chemical/x-gamess-input","ins","application/x-internet-signup","iso","application/x-iso9660-image","isp","application/x-internet-signup","ist","chemical/x-isostar","istr","chemical/x-isostar","jad","text/vnd.sun.j2me.app-descriptor","jar","application/java-archive","java","text/x-java","jdx","chemical/x-jcamp-dx","jmz","application/x-jmol","jng","image/x-jng","jnlp","application/x-java-jnlp-file","jpe","image/jpeg","jpeg","image/jpeg","jpg","image/jpeg","js","application/javascript","kar","audio/midi","key","application/pgp-keys","kil","application/x-killustrator","kin","chemical/x-kinemage","kpr","application/x-kpresenter","kpt","application/x-kpresenter","ksp","application/x-kspread","kwd","application/x-kword","kwt","application/x-kword","latex","application/x-latex","lha","application/x-lha","lhs","text/x-literate-haskell","lsf","video/x-la-asf","lsx","video/x-la-asf","ltx","text/x-tex","lzh","application/x-lzh","lzx","application/x-lzx","m3u","audio/x-mpegurl","m4a","audio/mpeg","maker","application/x-maker","man","application/x-troff-man","mcif","chemical/x-mmcif","mcm","chemical/x-macmolecule","mdb","application/msaccess","me","application/x-troff-me","mesh","model/mesh","mid","audio/midi","midi","audio/midi","mif","application/x-mif","mm","application/x-freemind","mmd","chemical/x-macromodel-input","mmf","application/vnd.smaf","mml","text/mathml","mmod","chemical/x-macromodel-input","mng","video/x-mng","moc","text/x-moc","mol","chemical/x-mdl-molfile","mol2","chemical/x-mol2","moo","chemical/x-mopac-out","mop","chemical/x-mopac-input","mopcrt","chemical/x-mopac-input","mov","video/quicktime","movie","video/x-sgi-movie","mp2","audio/mpeg","mp3","audio/mpeg","mp4","video/mp4","mpc","chemical/x-mopac-input","mpe","video/mpeg","mpeg","video/mpeg","mpega","audio/mpeg","mpg","video/mpeg","mpga","audio/mpeg","ms","application/x-troff-ms","msh","model/mesh","msi","application/x-msi","mvb","chemical/x-mopac-vib","mxu","video/vnd.mpegurl","nb","application/mathematica","nc","application/x-netcdf","nwc","application/x-nwc","o","application/x-object","oda","application/oda","odb","application/vnd.oasis.opendocument.database","odc","application/vnd.oasis.opendocument.chart","odf","application/vnd.oasis.opendocument.formula","odg","application/vnd.oasis.opendocument.graphics","odi","application/vnd.oasis.opendocument.image","odm","application/vnd.oasis.opendocument.text-master","odp","application/vnd.oasis.opendocument.presentation","ods","application/vnd.oasis.opendocument.spreadsheet","odt","application/vnd.oasis.opendocument.text","ogg","application/ogg","old","application/x-trash","oth","application/vnd.oasis.opendocument.text-web","oza","application/x-oz-application","p","text/x-pascal","p7r","application/x-pkcs7-certreqresp","pac","application/x-ns-proxy-autoconfig","pas","text/x-pascal","pat","image/x-coreldrawpattern","pbm","image/x-portable-bitmap","pcf","application/x-font","pcf.Z","application/x-font","pcx","image/pcx","pdb","chemical/x-pdb","pdf","application/pdf","pfa","application/x-font","pfb","application/x-font","pgm","image/x-portable-graymap","pgn","application/x-chess-pgn","pgp","application/pgp-signature","pk","application/x-tex-pk","pl","text/x-perl","pls","audio/x-scpls","pm","text/x-perl","png","image/png","pnm","image/x-portable-anymap","pot","text/plain","ppm","image/x-portable-pixmap","pps","application/vnd.ms-powerpoint","ppt","application/vnd.ms-powerpoint","prf","application/pics-rules","prt","chemical/x-ncbi-asn1-ascii","ps","application/postscript","psd","image/x-photoshop","psp","text/x-psp","py","text/x-python","pyc","application/x-python-code","pyo","application/x-python-code","qt","video/quicktime","qtl","application/x-quicktimeplayer","ra","audio/x-realaudio","ram","audio/x-pn-realaudio","rar","application/rar","ras","image/x-cmu-raster","rd","chemical/x-mdl-rdfile","rdf","application/rdf+xml","rgb","image/x-rgb","rm","audio/x-pn-realaudio","roff","application/x-troff","ros","chemical/x-rosdal","rpm","application/x-redhat-package-manager","rss","application/rss+xml","rtf","text/rtf","rtx","text/richtext","rxn","chemical/x-mdl-rxnfile","sct","text/scriptlet","sd","chemical/x-mdl-sdfile","sd2","audio/x-sd2","sda","application/vnd.stardivision.draw","sdc","application/vnd.stardivision.calc","sdd","application/vnd.stardivision.impress","sdf","chemical/x-mdl-sdfile","sdp","application/vnd.stardivision.impress","sdw","application/vnd.stardivision.writer","ser","application/java-serialized-object","sgf","application/x-go-sgf","sgl","application/vnd.stardivision.writer-global","sh","text/x-sh","shar","application/x-shar","shtml","text/html","sid","audio/prs.sid","sik","application/x-trash","silo","model/mesh","sis","application/vnd.symbian.install","sit","application/x-stuffit","skd","application/x-koan","skm","application/x-koan","skp","application/x-koan","skt","application/x-koan","smf","application/vnd.stardivision.math","smi","application/smil","smil","application/smil","snd","audio/basic","spc","chemical/x-galactic-spc","spl","application/x-futuresplash","src","application/x-wais-source","stc","application/vnd.sun.xml.calc.template","std","application/vnd.sun.xml.draw.template","sti","application/vnd.sun.xml.impress.template","stl","application/vnd.ms-pki.stl","stw","application/vnd.sun.xml.writer.template","sty","text/x-tex","sv4cpio","application/x-sv4cpio","sv4crc","application/x-sv4crc","svg","image/svg+xml","svgz","image/svg+xml","sw","chemical/x-swissprot","swf","application/x-shockwave-flash","swfl","application/x-shockwave-flash","sxc","application/vnd.sun.xml.calc","sxd","application/vnd.sun.xml.draw","sxg","application/vnd.sun.xml.writer.global","sxi","application/vnd.sun.xml.impress","sxm","application/vnd.sun.xml.math","sxw","application/vnd.sun.xml.writer","t","application/x-troff","tar","application/x-tar","taz","application/x-gtar","tcl","text/x-tcl","tex","text/x-tex","texi","application/x-texinfo","texinfo","application/x-texinfo","text","text/plain","tgf","chemical/x-mdl-tgf","tgz","application/x-gtar","tif","image/tiff","tiff","image/tiff","tk","text/x-tcl","tm","text/texmacs","torrent","application/x-bittorrent","tr","application/x-troff","ts","text/texmacs","tsp","application/dsptype","tsv","text/tab-separated-values","txt","text/plain","udeb","application/x-debian-package","uls","text/iuls","ustar","application/x-ustar","val","chemical/x-ncbi-asn1-binary","vcd","application/x-cdlink","vcf","text/x-vcard","vcs","text/x-vcalendar","vmd","chemical/x-vmd","vms","chemical/x-vamas-iso14976","vor","application/vnd.stardivision.writer","vrm","x-world/x-vrml","vrml","x-world/x-vrml","vsd","application/vnd.visio","wad","application/x-doom","wav","audio/x-wav","wax","audio/x-ms-wax","wbmp","image/vnd.wap.wbmp","wbxml","application/vnd.wap.wbxml","wk","application/x-123","wm","video/x-ms-wm","wma","audio/x-ms-wma","wmd","application/x-ms-wmd","wml","text/vnd.wap.wml","wmlc","application/vnd.wap.wmlc","wmls","text/vnd.wap.wmlscript","wmlsc","application/vnd.wap.wmlscriptc","wmv","video/x-ms-wmv","wmx","video/x-ms-wmx","wmz","application/x-ms-wmz","wp5","application/wordperfect5.1","wpd","application/wordperfect","wrl","x-world/x-vrml","wsc","text/scriptlet","wvx","video/x-ms-wvx","wz","application/x-wingz","xbm","image/x-xbitmap","xcf","application/x-xcf","xht","application/xhtml+xml","xhtml","application/xhtml+xml","xlb","application/vnd.ms-excel","xls","application/vnd.ms-excel","xlt","application/vnd.ms-excel","xml","application/xml","xpi","application/x-xpinstall","xpm","image/x-xpixmap","xsl","application/xml","xtel","chemical/x-xtel","xul","application/vnd.mozilla.xul+xml","xwd","image/x-xwindowdump","xyz","chemical/x-xyz","zip","application/zip","zmt","chemical/x-mopac-input","~","application/x-trash"]);
  1889. },
  1890. //>>excludeStart("ide", pragmas.excludeIdeData);
  1891. args: [],
  1892. source: "defaultMimeTypes\x0a\x09^ #{\x0a\x09\x09'%' -> 'application/x-trash'.\x0a\x09\x09'323' -> 'text/h323'.\x0a\x09\x09'abw' -> 'application/x-abiword'.\x0a\x09\x09'ai' -> 'application/postscript'.\x0a\x09\x09'aif' -> 'audio/x-aiff'.\x0a\x09\x09'aifc' -> 'audio/x-aiff'.\x0a\x09\x09'aiff' -> 'audio/x-aiff'.\x0a\x09\x09'alc' -> 'chemical/x-alchemy'.\x0a\x09\x09'art' -> 'image/x-jg'.\x0a\x09\x09'asc' -> 'text/plain'.\x0a\x09\x09'asf' -> 'video/x-ms-asf'.\x0a\x09\x09'asn' -> 'chemical/x-ncbi-asn1-spec'.\x0a\x09\x09'aso' -> 'chemical/x-ncbi-asn1-binary'.\x0a\x09\x09'asx' -> 'video/x-ms-asf'.\x0a\x09\x09'au' -> 'audio/basic'.\x0a\x09\x09'avi' -> 'video/x-msvideo'.\x0a\x09\x09'b' -> 'chemical/x-molconn-Z'.\x0a\x09\x09'bak' -> 'application/x-trash'.\x0a\x09\x09'bat' -> 'application/x-msdos-program'.\x0a\x09\x09'bcpio' -> 'application/x-bcpio'.\x0a\x09\x09'bib' -> 'text/x-bibtex'.\x0a\x09\x09'bin' -> 'application/octet-stream'.\x0a\x09\x09'bmp' -> 'image/x-ms-bmp'.\x0a\x09\x09'book' -> 'application/x-maker'.\x0a\x09\x09'bsd' -> 'chemical/x-crossfire'.\x0a\x09\x09'c' -> 'text/x-csrc'.\x0a\x09\x09'c++' -> 'text/x-c++src'.\x0a\x09\x09'c3d' -> 'chemical/x-chem3d'.\x0a\x09\x09'cac' -> 'chemical/x-cache'.\x0a\x09\x09'cache' -> 'chemical/x-cache'.\x0a\x09\x09'cascii' -> 'chemical/x-cactvs-binary'.\x0a\x09\x09'cat' -> 'application/vnd.ms-pki.seccat'.\x0a\x09\x09'cbin' -> 'chemical/x-cactvs-binary'.\x0a\x09\x09'cc' -> 'text/x-c++src'.\x0a\x09\x09'cdf' -> 'application/x-cdf'.\x0a\x09\x09'cdr' -> 'image/x-coreldraw'.\x0a\x09\x09'cdt' -> 'image/x-coreldrawtemplate'.\x0a\x09\x09'cdx' -> 'chemical/x-cdx'.\x0a\x09\x09'cdy' -> 'application/vnd.cinderella'.\x0a\x09\x09'cef' -> 'chemical/x-cxf'.\x0a\x09\x09'cer' -> 'chemical/x-cerius'.\x0a\x09\x09'chm' -> 'chemical/x-chemdraw'.\x0a\x09\x09'chrt' -> 'application/x-kchart'.\x0a\x09\x09'cif' -> 'chemical/x-cif'.\x0a\x09\x09'class' -> 'application/java-vm'.\x0a\x09\x09'cls' -> 'text/x-tex'.\x0a\x09\x09'cmdf' -> 'chemical/x-cmdf'.\x0a\x09\x09'cml' -> 'chemical/x-cml'.\x0a\x09\x09'cod' -> 'application/vnd.rim.cod'.\x0a\x09\x09'com' -> 'application/x-msdos-program'.\x0a\x09\x09'cpa' -> 'chemical/x-compass'.\x0a\x09\x09'cpio' -> 'application/x-cpio'.\x0a\x09\x09'cpp' -> 'text/x-c++src'.\x0a\x09\x09'cpt' -> 'image/x-corelphotopaint'.\x0a\x09\x09'crl' -> 'application/x-pkcs7-crl'.\x0a\x09\x09'crt' -> 'application/x-x509-ca-cert'.\x0a\x09\x09'csf' -> 'chemical/x-cache-csf'.\x0a\x09\x09'csh' -> 'text/x-csh'.\x0a\x09\x09'csm' -> 'chemical/x-csml'.\x0a\x09\x09'csml' -> 'chemical/x-csml'.\x0a\x09\x09'css' -> 'text/css'.\x0a\x09\x09'csv' -> 'text/comma-separated-values'.\x0a\x09\x09'ctab' -> 'chemical/x-cactvs-binary'.\x0a\x09\x09'ctx' -> 'chemical/x-ctx'.\x0a\x09\x09'cu' -> 'application/cu-seeme'.\x0a\x09\x09'cub' -> 'chemical/x-gaussian-cube'.\x0a\x09\x09'cxf' -> 'chemical/x-cxf'.\x0a\x09\x09'cxx' -> 'text/x-c++src'.\x0a\x09\x09'dat' -> 'chemical/x-mopac-input'.\x0a\x09\x09'dcr' -> 'application/x-director'.\x0a\x09\x09'deb' -> 'application/x-debian-package'.\x0a\x09\x09'dif' -> 'video/dv'.\x0a\x09\x09'diff' -> 'text/plain'.\x0a\x09\x09'dir' -> 'application/x-director'.\x0a\x09\x09'djv' -> 'image/vnd.djvu'.\x0a\x09\x09'djvu' -> 'image/vnd.djvu'.\x0a\x09\x09'dl' -> 'video/dl'.\x0a\x09\x09'dll' -> 'application/x-msdos-program'.\x0a\x09\x09'dmg' -> 'application/x-apple-diskimage'.\x0a\x09\x09'dms' -> 'application/x-dms'.\x0a\x09\x09'doc' -> 'application/msword'.\x0a\x09\x09'dot' -> 'application/msword'.\x0a\x09\x09'dv' -> 'video/dv'.\x0a\x09\x09'dvi' -> 'application/x-dvi'.\x0a\x09\x09'dx' -> 'chemical/x-jcamp-dx'.\x0a\x09\x09'dxr' -> 'application/x-director'.\x0a\x09\x09'emb' -> 'chemical/x-embl-dl-nucleotide'.\x0a\x09\x09'embl' -> 'chemical/x-embl-dl-nucleotide'.\x0a\x09\x09'ent' -> 'chemical/x-pdb'.\x0a\x09\x09'eps' -> 'application/postscript'.\x0a\x09\x09'etx' -> 'text/x-setext'.\x0a\x09\x09'exe' -> 'application/x-msdos-program'.\x0a\x09\x09'ez' -> 'application/andrew-inset'.\x0a\x09\x09'fb' -> 'application/x-maker'.\x0a\x09\x09'fbdoc' -> 'application/x-maker'.\x0a\x09\x09'fch' -> 'chemical/x-gaussian-checkpoint'.\x0a\x09\x09'fchk' -> 'chemical/x-gaussian-checkpoint'.\x0a\x09\x09'fig' -> 'application/x-xfig'.\x0a\x09\x09'flac' -> 'application/x-flac'.\x0a\x09\x09'fli' -> 'video/fli'.\x0a\x09\x09'fm' -> 'application/x-maker'.\x0a\x09\x09'frame' -> 'application/x-maker'.\x0a\x09\x09'frm' -> 'application/x-maker'.\x0a\x09\x09'gal' -> 'chemical/x-gaussian-log'.\x0a\x09\x09'gam' -> 'chemical/x-gamess-input'.\x0a\x09\x09'gamin' -> 'chemical/x-gamess-input'.\x0a\x09\x09'gau' -> 'chemical/x-gaussian-input'.\x0a\x09\x09'gcd' -> 'text/x-pcs-gcd'.\x0a\x09\x09'gcf' -> 'application/x-graphing-calculator'.\x0a\x09\x09'gcg' -> 'chemical/x-gcg8-sequence'.\x0a\x09\x09'gen' -> 'chemical/x-genbank'.\x0a\x09\x09'gf' -> 'application/x-tex-gf'.\x0a\x09\x09'gif' -> 'image/gif'.\x0a\x09\x09'gjc' -> 'chemical/x-gaussian-input'.\x0a\x09\x09'gjf' -> 'chemical/x-gaussian-input'.\x0a\x09\x09'gl' -> 'video/gl'.\x0a\x09\x09'gnumeric' -> 'application/x-gnumeric'.\x0a\x09\x09'gpt' -> 'chemical/x-mopac-graph'.\x0a\x09\x09'gsf' -> 'application/x-font'.\x0a\x09\x09'gsm' -> 'audio/x-gsm'.\x0a\x09\x09'gtar' -> 'application/x-gtar'.\x0a\x09\x09'h' -> 'text/x-chdr'.\x0a\x09\x09'h++' -> 'text/x-c++hdr'.\x0a\x09\x09'hdf' -> 'application/x-hdf'.\x0a\x09\x09'hh' -> 'text/x-c++hdr'.\x0a\x09\x09'hin' -> 'chemical/x-hin'.\x0a\x09\x09'hpp' -> 'text/x-c++hdr'.\x0a\x09\x09'hqx' -> 'application/mac-binhex40'.\x0a\x09\x09'hs' -> 'text/x-haskell'.\x0a\x09\x09'hta' -> 'application/hta'.\x0a\x09\x09'htc' -> 'text/x-component'.\x0a\x09\x09'htm' -> 'text/html'.\x0a\x09\x09'html' -> 'text/html'.\x0a\x09\x09'hxx' -> 'text/x-c++hdr'.\x0a\x09\x09'ica' -> 'application/x-ica'.\x0a\x09\x09'ice' -> 'x-conference/x-cooltalk'.\x0a\x09\x09'ico' -> 'image/x-icon'.\x0a\x09\x09'ics' -> 'text/calendar'.\x0a\x09\x09'icz' -> 'text/calendar'.\x0a\x09\x09'ief' -> 'image/ief'.\x0a\x09\x09'iges' -> 'model/iges'.\x0a\x09\x09'igs' -> 'model/iges'.\x0a\x09\x09'iii' -> 'application/x-iphone'.\x0a\x09\x09'inp' -> 'chemical/x-gamess-input'.\x0a\x09\x09'ins' -> 'application/x-internet-signup'.\x0a\x09\x09'iso' -> 'application/x-iso9660-image'.\x0a\x09\x09'isp' -> 'application/x-internet-signup'.\x0a\x09\x09'ist' -> 'chemical/x-isostar'.\x0a\x09\x09'istr' -> 'chemical/x-isostar'.\x0a\x09\x09'jad' -> 'text/vnd.sun.j2me.app-descriptor'.\x0a\x09\x09'jar' -> 'application/java-archive'.\x0a\x09\x09'java' -> 'text/x-java'.\x0a\x09\x09'jdx' -> 'chemical/x-jcamp-dx'.\x0a\x09\x09'jmz' -> 'application/x-jmol'.\x0a\x09\x09'jng' -> 'image/x-jng'.\x0a\x09\x09'jnlp' -> 'application/x-java-jnlp-file'.\x0a\x09\x09'jpe' -> 'image/jpeg'.\x0a\x09\x09'jpeg' -> 'image/jpeg'.\x0a\x09\x09'jpg' -> 'image/jpeg'.\x0a\x09\x09'js' -> 'application/javascript'.\x0a\x09\x09'kar' -> 'audio/midi'.\x0a\x09\x09'key' -> 'application/pgp-keys'.\x0a\x09\x09'kil' -> 'application/x-killustrator'.\x0a\x09\x09'kin' -> 'chemical/x-kinemage'.\x0a\x09\x09'kpr' -> 'application/x-kpresenter'.\x0a\x09\x09'kpt' -> 'application/x-kpresenter'.\x0a\x09\x09'ksp' -> 'application/x-kspread'.\x0a\x09\x09'kwd' -> 'application/x-kword'.\x0a\x09\x09'kwt' -> 'application/x-kword'.\x0a\x09\x09'latex' -> 'application/x-latex'.\x0a\x09\x09'lha' -> 'application/x-lha'.\x0a\x09\x09'lhs' -> 'text/x-literate-haskell'.\x0a\x09\x09'lsf' -> 'video/x-la-asf'.\x0a\x09\x09'lsx' -> 'video/x-la-asf'.\x0a\x09\x09'ltx' -> 'text/x-tex'.\x0a\x09\x09'lzh' -> 'application/x-lzh'.\x0a\x09\x09'lzx' -> 'application/x-lzx'.\x0a\x09\x09'm3u' -> 'audio/x-mpegurl'.\x0a\x09\x09'm4a' -> 'audio/mpeg'.\x0a\x09\x09'maker' -> 'application/x-maker'.\x0a\x09\x09'man' -> 'application/x-troff-man'.\x0a\x09\x09'mcif' -> 'chemical/x-mmcif'.\x0a\x09\x09'mcm' -> 'chemical/x-macmolecule'.\x0a\x09\x09'mdb' -> 'application/msaccess'.\x0a\x09\x09'me' -> 'application/x-troff-me'.\x0a\x09\x09'mesh' -> 'model/mesh'.\x0a\x09\x09'mid' -> 'audio/midi'.\x0a\x09\x09'midi' -> 'audio/midi'.\x0a\x09\x09'mif' -> 'application/x-mif'.\x0a\x09\x09'mm' -> 'application/x-freemind'.\x0a\x09\x09'mmd' -> 'chemical/x-macromodel-input'.\x0a\x09\x09'mmf' -> 'application/vnd.smaf'.\x0a\x09\x09'mml' -> 'text/mathml'.\x0a\x09\x09'mmod' -> 'chemical/x-macromodel-input'.\x0a\x09\x09'mng' -> 'video/x-mng'.\x0a\x09\x09'moc' -> 'text/x-moc'.\x0a\x09\x09'mol' -> 'chemical/x-mdl-molfile'.\x0a\x09\x09'mol2' -> 'chemical/x-mol2'.\x0a\x09\x09'moo' -> 'chemical/x-mopac-out'.\x0a\x09\x09'mop' -> 'chemical/x-mopac-input'.\x0a\x09\x09'mopcrt' -> 'chemical/x-mopac-input'.\x0a\x09\x09'mov' -> 'video/quicktime'.\x0a\x09\x09'movie' -> 'video/x-sgi-movie'.\x0a\x09\x09'mp2' -> 'audio/mpeg'.\x0a\x09\x09'mp3' -> 'audio/mpeg'.\x0a\x09\x09'mp4' -> 'video/mp4'.\x0a\x09\x09'mpc' -> 'chemical/x-mopac-input'.\x0a\x09\x09'mpe' -> 'video/mpeg'.\x0a\x09\x09'mpeg' -> 'video/mpeg'.\x0a\x09\x09'mpega' -> 'audio/mpeg'.\x0a\x09\x09'mpg' -> 'video/mpeg'.\x0a\x09\x09'mpga' -> 'audio/mpeg'.\x0a\x09\x09'ms' -> 'application/x-troff-ms'.\x0a\x09\x09'msh' -> 'model/mesh'.\x0a\x09\x09'msi' -> 'application/x-msi'.\x0a\x09\x09'mvb' -> 'chemical/x-mopac-vib'.\x0a\x09\x09'mxu' -> 'video/vnd.mpegurl'.\x0a\x09\x09'nb' -> 'application/mathematica'.\x0a\x09\x09'nc' -> 'application/x-netcdf'.\x0a\x09\x09'nwc' -> 'application/x-nwc'.\x0a\x09\x09'o' -> 'application/x-object'.\x0a\x09\x09'oda' -> 'application/oda'.\x0a\x09\x09'odb' -> 'application/vnd.oasis.opendocument.database'.\x0a\x09\x09'odc' -> 'application/vnd.oasis.opendocument.chart'.\x0a\x09\x09'odf' -> 'application/vnd.oasis.opendocument.formula'.\x0a\x09\x09'odg' -> 'application/vnd.oasis.opendocument.graphics'.\x0a\x09\x09'odi' -> 'application/vnd.oasis.opendocument.image'.\x0a\x09\x09'odm' -> 'application/vnd.oasis.opendocument.text-master'.\x0a\x09\x09'odp' -> 'application/vnd.oasis.opendocument.presentation'.\x0a\x09\x09'ods' -> 'application/vnd.oasis.opendocument.spreadsheet'.\x0a\x09\x09'odt' -> 'application/vnd.oasis.opendocument.text'.\x0a\x09\x09'ogg' -> 'application/ogg'.\x0a\x09\x09'old' -> 'application/x-trash'.\x0a\x09\x09'oth' -> 'application/vnd.oasis.opendocument.text-web'.\x0a\x09\x09'oza' -> 'application/x-oz-application'.\x0a\x09\x09'p' -> 'text/x-pascal'.\x0a\x09\x09'p7r' -> 'application/x-pkcs7-certreqresp'.\x0a\x09\x09'pac' -> 'application/x-ns-proxy-autoconfig'.\x0a\x09\x09'pas' -> 'text/x-pascal'.\x0a\x09\x09'pat' -> 'image/x-coreldrawpattern'.\x0a\x09\x09'pbm' -> 'image/x-portable-bitmap'.\x0a\x09\x09'pcf' -> 'application/x-font'.\x0a\x09\x09'pcf.Z' -> 'application/x-font'.\x0a\x09\x09'pcx' -> 'image/pcx'.\x0a\x09\x09'pdb' -> 'chemical/x-pdb'.\x0a\x09\x09'pdf' -> 'application/pdf'.\x0a\x09\x09'pfa' -> 'application/x-font'.\x0a\x09\x09'pfb' -> 'application/x-font'.\x0a\x09\x09'pgm' -> 'image/x-portable-graymap'.\x0a\x09\x09'pgn' -> 'application/x-chess-pgn'.\x0a\x09\x09'pgp' -> 'application/pgp-signature'.\x0a\x09\x09'pk' -> 'application/x-tex-pk'.\x0a\x09\x09'pl' -> 'text/x-perl'.\x0a\x09\x09'pls' -> 'audio/x-scpls'.\x0a\x09\x09'pm' -> 'text/x-perl'.\x0a\x09\x09'png' -> 'image/png'.\x0a\x09\x09'pnm' -> 'image/x-portable-anymap'.\x0a\x09\x09'pot' -> 'text/plain'.\x0a\x09\x09'ppm' -> 'image/x-portable-pixmap'.\x0a\x09\x09'pps' -> 'application/vnd.ms-powerpoint'.\x0a\x09\x09'ppt' -> 'application/vnd.ms-powerpoint'.\x0a\x09\x09'prf' -> 'application/pics-rules'.\x0a\x09\x09'prt' -> 'chemical/x-ncbi-asn1-ascii'.\x0a\x09\x09'ps' -> 'application/postscript'.\x0a\x09\x09'psd' -> 'image/x-photoshop'.\x0a\x09\x09'psp' -> 'text/x-psp'.\x0a\x09\x09'py' -> 'text/x-python'.\x0a\x09\x09'pyc' -> 'application/x-python-code'.\x0a\x09\x09'pyo' -> 'application/x-python-code'.\x0a\x09\x09'qt' -> 'video/quicktime'.\x0a\x09\x09'qtl' -> 'application/x-quicktimeplayer'.\x0a\x09\x09'ra' -> 'audio/x-realaudio'.\x0a\x09\x09'ram' -> 'audio/x-pn-realaudio'.\x0a\x09\x09'rar' -> 'application/rar'.\x0a\x09\x09'ras' -> 'image/x-cmu-raster'.\x0a\x09\x09'rd' -> 'chemical/x-mdl-rdfile'.\x0a\x09\x09'rdf' -> 'application/rdf+xml'.\x0a\x09\x09'rgb' -> 'image/x-rgb'.\x0a\x09\x09'rm' -> 'audio/x-pn-realaudio'.\x0a\x09\x09'roff' -> 'application/x-troff'.\x0a\x09\x09'ros' -> 'chemical/x-rosdal'.\x0a\x09\x09'rpm' -> 'application/x-redhat-package-manager'.\x0a\x09\x09'rss' -> 'application/rss+xml'.\x0a\x09\x09'rtf' -> 'text/rtf'.\x0a\x09\x09'rtx' -> 'text/richtext'.\x0a\x09\x09'rxn' -> 'chemical/x-mdl-rxnfile'.\x0a\x09\x09'sct' -> 'text/scriptlet'.\x0a\x09\x09'sd' -> 'chemical/x-mdl-sdfile'.\x0a\x09\x09'sd2' -> 'audio/x-sd2'.\x0a\x09\x09'sda' -> 'application/vnd.stardivision.draw'.\x0a\x09\x09'sdc' -> 'application/vnd.stardivision.calc'.\x0a\x09\x09'sdd' -> 'application/vnd.stardivision.impress'.\x0a\x09\x09'sdf' -> 'chemical/x-mdl-sdfile'.\x0a\x09\x09'sdp' -> 'application/vnd.stardivision.impress'.\x0a\x09\x09'sdw' -> 'application/vnd.stardivision.writer'.\x0a\x09\x09'ser' -> 'application/java-serialized-object'.\x0a\x09\x09'sgf' -> 'application/x-go-sgf'.\x0a\x09\x09'sgl' -> 'application/vnd.stardivision.writer-global'.\x0a\x09\x09'sh' -> 'text/x-sh'.\x0a\x09\x09'shar' -> 'application/x-shar'.\x0a\x09\x09'shtml' -> 'text/html'.\x0a\x09\x09'sid' -> 'audio/prs.sid'.\x0a\x09\x09'sik' -> 'application/x-trash'.\x0a\x09\x09'silo' -> 'model/mesh'.\x0a\x09\x09'sis' -> 'application/vnd.symbian.install'.\x0a\x09\x09'sit' -> 'application/x-stuffit'.\x0a\x09\x09'skd' -> 'application/x-koan'.\x0a\x09\x09'skm' -> 'application/x-koan'.\x0a\x09\x09'skp' -> 'application/x-koan'.\x0a\x09\x09'skt' -> 'application/x-koan'.\x0a\x09\x09'smf' -> 'application/vnd.stardivision.math'.\x0a\x09\x09'smi' -> 'application/smil'.\x0a\x09\x09'smil' -> 'application/smil'.\x0a\x09\x09'snd' -> 'audio/basic'.\x0a\x09\x09'spc' -> 'chemical/x-galactic-spc'.\x0a\x09\x09'spl' -> 'application/x-futuresplash'.\x0a\x09\x09'src' -> 'application/x-wais-source'.\x0a\x09\x09'stc' -> 'application/vnd.sun.xml.calc.template'.\x0a\x09\x09'std' -> 'application/vnd.sun.xml.draw.template'.\x0a\x09\x09'sti' -> 'application/vnd.sun.xml.impress.template'.\x0a\x09\x09'stl' -> 'application/vnd.ms-pki.stl'.\x0a\x09\x09'stw' -> 'application/vnd.sun.xml.writer.template'.\x0a\x09\x09'sty' -> 'text/x-tex'.\x0a\x09\x09'sv4cpio' -> 'application/x-sv4cpio'.\x0a\x09\x09'sv4crc' -> 'application/x-sv4crc'.\x0a\x09\x09'svg' -> 'image/svg+xml'.\x0a\x09\x09'svgz' -> 'image/svg+xml'.\x0a\x09\x09'sw' -> 'chemical/x-swissprot'.\x0a\x09\x09'swf' -> 'application/x-shockwave-flash'.\x0a\x09\x09'swfl' -> 'application/x-shockwave-flash'.\x0a\x09\x09'sxc' -> 'application/vnd.sun.xml.calc'.\x0a\x09\x09'sxd' -> 'application/vnd.sun.xml.draw'.\x0a\x09\x09'sxg' -> 'application/vnd.sun.xml.writer.global'.\x0a\x09\x09'sxi' -> 'application/vnd.sun.xml.impress'.\x0a\x09\x09'sxm' -> 'application/vnd.sun.xml.math'.\x0a\x09\x09'sxw' -> 'application/vnd.sun.xml.writer'.\x0a\x09\x09't' -> 'application/x-troff'.\x0a\x09\x09'tar' -> 'application/x-tar'.\x0a\x09\x09'taz' -> 'application/x-gtar'.\x0a\x09\x09'tcl' -> 'text/x-tcl'.\x0a\x09\x09'tex' -> 'text/x-tex'.\x0a\x09\x09'texi' -> 'application/x-texinfo'.\x0a\x09\x09'texinfo' -> 'application/x-texinfo'.\x0a\x09\x09'text' -> 'text/plain'.\x0a\x09\x09'tgf' -> 'chemical/x-mdl-tgf'.\x0a\x09\x09'tgz' -> 'application/x-gtar'.\x0a\x09\x09'tif' -> 'image/tiff'.\x0a\x09\x09'tiff' -> 'image/tiff'.\x0a\x09\x09'tk' -> 'text/x-tcl'.\x0a\x09\x09'tm' -> 'text/texmacs'.\x0a\x09\x09'torrent' -> 'application/x-bittorrent'.\x0a\x09\x09'tr' -> 'application/x-troff'.\x0a\x09\x09'ts' -> 'text/texmacs'.\x0a\x09\x09'tsp' -> 'application/dsptype'.\x0a\x09\x09'tsv' -> 'text/tab-separated-values'.\x0a\x09\x09'txt' -> 'text/plain'.\x0a\x09\x09'udeb' -> 'application/x-debian-package'.\x0a\x09\x09'uls' -> 'text/iuls'.\x0a\x09\x09'ustar' -> 'application/x-ustar'.\x0a\x09\x09'val' -> 'chemical/x-ncbi-asn1-binary'.\x0a\x09\x09'vcd' -> 'application/x-cdlink'.\x0a\x09\x09'vcf' -> 'text/x-vcard'.\x0a\x09\x09'vcs' -> 'text/x-vcalendar'.\x0a\x09\x09'vmd' -> 'chemical/x-vmd'.\x0a\x09\x09'vms' -> 'chemical/x-vamas-iso14976'.\x0a\x09\x09'vor' -> 'application/vnd.stardivision.writer'.\x0a\x09\x09'vrm' -> 'x-world/x-vrml'.\x0a\x09\x09'vrml' -> 'x-world/x-vrml'.\x0a\x09\x09'vsd' -> 'application/vnd.visio'.\x0a\x09\x09'wad' -> 'application/x-doom'.\x0a\x09\x09'wav' -> 'audio/x-wav'.\x0a\x09\x09'wax' -> 'audio/x-ms-wax'.\x0a\x09\x09'wbmp' -> 'image/vnd.wap.wbmp'.\x0a\x09\x09'wbxml' -> 'application/vnd.wap.wbxml'.\x0a\x09\x09'wk' -> 'application/x-123'.\x0a\x09\x09'wm' -> 'video/x-ms-wm'.\x0a\x09\x09'wma' -> 'audio/x-ms-wma'.\x0a\x09\x09'wmd' -> 'application/x-ms-wmd'.\x0a\x09\x09'wml' -> 'text/vnd.wap.wml'.\x0a\x09\x09'wmlc' -> 'application/vnd.wap.wmlc'.\x0a\x09\x09'wmls' -> 'text/vnd.wap.wmlscript'.\x0a\x09\x09'wmlsc' -> 'application/vnd.wap.wmlscriptc'.\x0a\x09\x09'wmv' -> 'video/x-ms-wmv'.\x0a\x09\x09'wmx' -> 'video/x-ms-wmx'.\x0a\x09\x09'wmz' -> 'application/x-ms-wmz'.\x0a\x09\x09'wp5' -> 'application/wordperfect5.1'.\x0a\x09\x09'wpd' -> 'application/wordperfect'.\x0a\x09\x09'wrl' -> 'x-world/x-vrml'.\x0a\x09\x09'wsc' -> 'text/scriptlet'.\x0a\x09\x09'wvx' -> 'video/x-ms-wvx'.\x0a\x09\x09'wz' -> 'application/x-wingz'.\x0a\x09\x09'xbm' -> 'image/x-xbitmap'.\x0a\x09\x09'xcf' -> 'application/x-xcf'.\x0a\x09\x09'xht' -> 'application/xhtml+xml'.\x0a\x09\x09'xhtml' -> 'application/xhtml+xml'.\x0a\x09\x09'xlb' -> 'application/vnd.ms-excel'.\x0a\x09\x09'xls' -> 'application/vnd.ms-excel'.\x0a\x09\x09'xlt' -> 'application/vnd.ms-excel'.\x0a\x09\x09'xml' -> 'application/xml'.\x0a\x09\x09'xpi' -> 'application/x-xpinstall'.\x0a\x09\x09'xpm' -> 'image/x-xpixmap'.\x0a\x09\x09'xsl' -> 'application/xml'.\x0a\x09\x09'xtel' -> 'chemical/x-xtel'.\x0a\x09\x09'xul' -> 'application/vnd.mozilla.xul+xml'.\x0a\x09\x09'xwd' -> 'image/x-xwindowdump'.\x0a\x09\x09'xyz' -> 'chemical/x-xyz'.\x0a\x09\x09'zip' -> 'application/zip'.\x0a\x09\x09'zmt' -> 'chemical/x-mopac-input'.\x0a\x09\x09'~' -> 'application/x-trash'\x0a\x09}",
  1893. referencedClasses: [],
  1894. //>>excludeEnd("ide");
  1895. messageSends: []
  1896. }),
  1897. $globals.FileServer.a$cls);
  1898. $core.addMethod(
  1899. $core.method({
  1900. selector: "defaultPort",
  1901. protocol: "accessing",
  1902. fn: function (){
  1903. var self=this,$self=this;
  1904. return (4000);
  1905. },
  1906. //>>excludeStart("ide", pragmas.excludeIdeData);
  1907. args: [],
  1908. source: "defaultPort\x0a\x09^ 4000",
  1909. referencedClasses: [],
  1910. //>>excludeEnd("ide");
  1911. messageSends: []
  1912. }),
  1913. $globals.FileServer.a$cls);
  1914. $core.addMethod(
  1915. $core.method({
  1916. selector: "main",
  1917. protocol: "initialization",
  1918. fn: function (){
  1919. var self=this,$self=this;
  1920. var fileServer,args;
  1921. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1922. return $core.withContext(function($ctx1) {
  1923. //>>excludeEnd("ctx");
  1924. var $1;
  1925. var $early={};
  1926. try {
  1927. args=$recv(process)._argv();
  1928. $recv(args)._removeFrom_to_((1),(3));
  1929. $recv(args)._detect_ifNone_((function(each){
  1930. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1931. return $core.withContext(function($ctx2) {
  1932. //>>excludeEnd("ctx");
  1933. $1=$recv(each).__eq("--help");
  1934. if($core.assert($1)){
  1935. return $recv($globals.FileServer)._printHelp();
  1936. }
  1937. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1938. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  1939. //>>excludeEnd("ctx");
  1940. }),(function(){
  1941. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1942. return $core.withContext(function($ctx2) {
  1943. //>>excludeEnd("ctx");
  1944. fileServer=$recv($globals.FileServer)._createServerWithArguments_(args);
  1945. fileServer;
  1946. throw $early=[$recv(fileServer)._start()];
  1947. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1948. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
  1949. //>>excludeEnd("ctx");
  1950. }));
  1951. return self;
  1952. }
  1953. catch(e) {if(e===$early)return e[0]; throw e}
  1954. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1955. }, function($ctx1) {$ctx1.fill(self,"main",{fileServer:fileServer,args:args},$globals.FileServer.a$cls)});
  1956. //>>excludeEnd("ctx");
  1957. },
  1958. //>>excludeStart("ide", pragmas.excludeIdeData);
  1959. args: [],
  1960. source: "main\x0a\x09\x22Main entry point for Amber applications.\x0a\x09 Creates and starts a FileServer instance.\x22\x0a\x09| fileServer args |\x0a\x09args := process argv.\x0a\x09\x22Remove the first args which contain the path to the node executable and the script file.\x22\x0a\x09args removeFrom: 1 to: 3.\x0a\x0a\x09args detect: [ :each |\x0a\x09\x09(each = '--help') ifTrue: [FileServer printHelp]]\x0a\x09ifNone: [\x0a\x09\x09fileServer := FileServer createServerWithArguments: args.\x0a\x09\x09^ fileServer start]",
  1961. referencedClasses: ["FileServer"],
  1962. //>>excludeEnd("ide");
  1963. messageSends: ["argv", "removeFrom:to:", "detect:ifNone:", "ifTrue:", "=", "printHelp", "createServerWithArguments:", "start"]
  1964. }),
  1965. $globals.FileServer.a$cls);
  1966. $core.addMethod(
  1967. $core.method({
  1968. selector: "mimeTypeFor:",
  1969. protocol: "accessing",
  1970. fn: function (aString){
  1971. var self=this,$self=this;
  1972. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1973. return $core.withContext(function($ctx1) {
  1974. //>>excludeEnd("ctx");
  1975. return $recv($self._mimeTypes())._at_ifAbsent_($recv(aString)._replace_with_(".*[\x5c.]",""),(function(){
  1976. return "text/plain";
  1977. }));
  1978. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1979. }, function($ctx1) {$ctx1.fill(self,"mimeTypeFor:",{aString:aString},$globals.FileServer.a$cls)});
  1980. //>>excludeEnd("ctx");
  1981. },
  1982. //>>excludeStart("ide", pragmas.excludeIdeData);
  1983. args: ["aString"],
  1984. source: "mimeTypeFor: aString\x0a\x09^ self mimeTypes at: (aString replace: '.*[\x5c.]' with: '') ifAbsent: ['text/plain']",
  1985. referencedClasses: [],
  1986. //>>excludeEnd("ide");
  1987. messageSends: ["at:ifAbsent:", "mimeTypes", "replace:with:"]
  1988. }),
  1989. $globals.FileServer.a$cls);
  1990. $core.addMethod(
  1991. $core.method({
  1992. selector: "mimeTypes",
  1993. protocol: "accessing",
  1994. fn: function (){
  1995. var self=this,$self=this;
  1996. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1997. return $core.withContext(function($ctx1) {
  1998. //>>excludeEnd("ctx");
  1999. var $1,$receiver;
  2000. $1=$self["@mimeTypes"];
  2001. if(($receiver = $1) == null || $receiver.a$nil){
  2002. $self["@mimeTypes"]=$self._defaultMimeTypes();
  2003. return $self["@mimeTypes"];
  2004. } else {
  2005. return $1;
  2006. }
  2007. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2008. }, function($ctx1) {$ctx1.fill(self,"mimeTypes",{},$globals.FileServer.a$cls)});
  2009. //>>excludeEnd("ctx");
  2010. },
  2011. //>>excludeStart("ide", pragmas.excludeIdeData);
  2012. args: [],
  2013. source: "mimeTypes\x0a\x09^ mimeTypes ifNil: [mimeTypes := self defaultMimeTypes]",
  2014. referencedClasses: [],
  2015. //>>excludeEnd("ide");
  2016. messageSends: ["ifNil:", "defaultMimeTypes"]
  2017. }),
  2018. $globals.FileServer.a$cls);
  2019. $core.addMethod(
  2020. $core.method({
  2021. selector: "printHelp",
  2022. protocol: "accessing",
  2023. fn: function (){
  2024. var self=this,$self=this;
  2025. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2026. return $core.withContext(function($ctx1) {
  2027. //>>excludeEnd("ctx");
  2028. $recv(console)._log_("Available commandline options are:");
  2029. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2030. $ctx1.sendIdx["log:"]=1;
  2031. //>>excludeEnd("ctx");
  2032. $recv(console)._log_("--help");
  2033. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2034. $ctx1.sendIdx["log:"]=2;
  2035. //>>excludeEnd("ctx");
  2036. $recv($self._commandLineSwitches())._do_((function(each){
  2037. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2038. return $core.withContext(function($ctx2) {
  2039. //>>excludeEnd("ctx");
  2040. return $recv(console)._log_($recv(each).__comma(" <parameter>"));
  2041. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2042. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  2043. //>>excludeEnd("ctx");
  2044. }));
  2045. return self;
  2046. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2047. }, function($ctx1) {$ctx1.fill(self,"printHelp",{},$globals.FileServer.a$cls)});
  2048. //>>excludeEnd("ctx");
  2049. },
  2050. //>>excludeStart("ide", pragmas.excludeIdeData);
  2051. args: [],
  2052. source: "printHelp\x0a\x09console log: 'Available commandline options are:'.\x0a\x09console log: '--help'.\x0a\x09self commandLineSwitches do: [ :each |\x0a\x09\x09console log: each, ' <parameter>']",
  2053. referencedClasses: [],
  2054. //>>excludeEnd("ide");
  2055. messageSends: ["log:", "do:", "commandLineSwitches", ","]
  2056. }),
  2057. $globals.FileServer.a$cls);
  2058. $core.addMethod(
  2059. $core.method({
  2060. selector: "selectorForCommandLineSwitch:",
  2061. protocol: "accessing",
  2062. fn: function (aSwitch){
  2063. var self=this,$self=this;
  2064. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2065. return $core.withContext(function($ctx1) {
  2066. //>>excludeEnd("ctx");
  2067. var $1;
  2068. $1=$recv($recv(aSwitch)._replace_with_("^--",""))._replace_with_("-[a-z]",(function(each){
  2069. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2070. return $core.withContext(function($ctx2) {
  2071. //>>excludeEnd("ctx");
  2072. return $recv($recv(each)._second())._asUppercase();
  2073. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2074. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  2075. //>>excludeEnd("ctx");
  2076. }));
  2077. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2078. $ctx1.sendIdx["replace:with:"]=1;
  2079. //>>excludeEnd("ctx");
  2080. return $recv($1).__comma(":");
  2081. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2082. }, function($ctx1) {$ctx1.fill(self,"selectorForCommandLineSwitch:",{aSwitch:aSwitch},$globals.FileServer.a$cls)});
  2083. //>>excludeEnd("ctx");
  2084. },
  2085. //>>excludeStart("ide", pragmas.excludeIdeData);
  2086. args: ["aSwitch"],
  2087. source: "selectorForCommandLineSwitch: aSwitch\x0a\x09\x22Remove the trailing '--', add ':' at the end\x0a\x09 and replace all occurences of a lowercase letter preceded by a '-' with\x0a\x09 the Uppercase letter.\x0a\x09 Example: --fallback-page becomes fallbackPage:\x22\x0a\x09^ ((aSwitch replace: '^--' with: '')\x0a\x09\x09replace: '-[a-z]' with: [ :each | each second asUppercase ]), ':'",
  2088. referencedClasses: [],
  2089. //>>excludeEnd("ide");
  2090. messageSends: [",", "replace:with:", "asUppercase", "second"]
  2091. }),
  2092. $globals.FileServer.a$cls);
  2093. $core.addClass("Initer", $globals.BaseFileManipulator, ["childProcess", "nmPath"], "AmberCli");
  2094. $core.addMethod(
  2095. $core.method({
  2096. selector: "bowerInstallThenDo:",
  2097. protocol: "action",
  2098. fn: function (aBlock){
  2099. var self=this,$self=this;
  2100. var child;
  2101. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2102. return $core.withContext(function($ctx1) {
  2103. //>>excludeEnd("ctx");
  2104. var $1,$3,$2;
  2105. child=$recv($self["@childProcess"])._fork_args_($self._npmScriptForModule_named_("bower","bower"),["install"]);
  2106. $1=child;
  2107. $recv($1)._on_do_("error",aBlock);
  2108. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2109. $ctx1.sendIdx["on:do:"]=1;
  2110. //>>excludeEnd("ctx");
  2111. $recv($1)._on_do_("close",(function(code){
  2112. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2113. return $core.withContext(function($ctx2) {
  2114. //>>excludeEnd("ctx");
  2115. $3=$recv(code).__eq((0));
  2116. if($core.assert($3)){
  2117. $2=nil;
  2118. } else {
  2119. $2=code;
  2120. }
  2121. return $recv(aBlock)._value_($2);
  2122. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2123. }, function($ctx2) {$ctx2.fillBlock({code:code},$ctx1,1)});
  2124. //>>excludeEnd("ctx");
  2125. }));
  2126. return self;
  2127. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2128. }, function($ctx1) {$ctx1.fill(self,"bowerInstallThenDo:",{aBlock:aBlock,child:child},$globals.Initer)});
  2129. //>>excludeEnd("ctx");
  2130. },
  2131. //>>excludeStart("ide", pragmas.excludeIdeData);
  2132. args: ["aBlock"],
  2133. source: "bowerInstallThenDo: aBlock\x0a\x09| child |\x0a\x09child := childProcess\x0a\x09\x09fork: (self npmScriptForModule: 'bower' named: 'bower')\x0a\x09\x09args: #('install').\x0a\x09child\x0a\x09\x09on: 'error' do: aBlock;\x0a\x09\x09on: 'close' do: [ :code |\x0a\x09\x09\x09aBlock value: (code = 0 ifTrue: [ nil ] ifFalse: [ code ]) ]",
  2134. referencedClasses: [],
  2135. //>>excludeEnd("ide");
  2136. messageSends: ["fork:args:", "npmScriptForModule:named:", "on:do:", "value:", "ifTrue:ifFalse:", "="]
  2137. }),
  2138. $globals.Initer);
  2139. $core.addMethod(
  2140. $core.method({
  2141. selector: "finishMessage",
  2142. protocol: "action",
  2143. fn: function (){
  2144. var self=this,$self=this;
  2145. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2146. return $core.withContext(function($ctx1) {
  2147. //>>excludeEnd("ctx");
  2148. $recv(console)._log_([" ", "The project should now be set up.", " ", " "]._join_($recv($globals.String)._lf()));
  2149. $recv((function(){
  2150. }))._valueWithTimeout_((600));
  2151. return self;
  2152. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2153. }, function($ctx1) {$ctx1.fill(self,"finishMessage",{},$globals.Initer)});
  2154. //>>excludeEnd("ctx");
  2155. },
  2156. //>>excludeStart("ide", pragmas.excludeIdeData);
  2157. args: [],
  2158. source: "finishMessage\x0a\x09console log: (#(\x0a\x09\x09' '\x0a\x09\x09'The project should now be set up.'\x0a\x09\x09' '\x0a\x09\x09' '\x0a\x09) join: String lf).\x0a\x09[] valueWithTimeout: 600",
  2159. referencedClasses: ["String"],
  2160. //>>excludeEnd("ide");
  2161. messageSends: ["log:", "join:", "lf", "valueWithTimeout:"]
  2162. }),
  2163. $globals.Initer);
  2164. $core.addMethod(
  2165. $core.method({
  2166. selector: "gruntInitThenDo:",
  2167. protocol: "action",
  2168. fn: function (aBlock){
  2169. var self=this,$self=this;
  2170. var child,sanitizedTemplatePath;
  2171. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2172. return $core.withContext(function($ctx1) {
  2173. //>>excludeEnd("ctx");
  2174. var $1,$3,$2;
  2175. sanitizedTemplatePath=$recv($recv($recv($self["@path"])._join_with_($self["@nmPath"],"grunt-init-amber"))._replace_with_("\x5c\x5c","\x5c\x5c"))._replace_with_(":","\x5c:");
  2176. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2177. $ctx1.sendIdx["replace:with:"]=1;
  2178. //>>excludeEnd("ctx");
  2179. child=$recv($self["@childProcess"])._fork_args_($self._npmScriptForModule_named_("grunt-init","grunt-init"),[sanitizedTemplatePath]);
  2180. $1=child;
  2181. $recv($1)._on_do_("error",aBlock);
  2182. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2183. $ctx1.sendIdx["on:do:"]=1;
  2184. //>>excludeEnd("ctx");
  2185. $recv($1)._on_do_("close",(function(code){
  2186. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2187. return $core.withContext(function($ctx2) {
  2188. //>>excludeEnd("ctx");
  2189. $3=$recv(code).__eq((0));
  2190. if($core.assert($3)){
  2191. $2=nil;
  2192. } else {
  2193. $2=code;
  2194. }
  2195. return $recv(aBlock)._value_($2);
  2196. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2197. }, function($ctx2) {$ctx2.fillBlock({code:code},$ctx1,1)});
  2198. //>>excludeEnd("ctx");
  2199. }));
  2200. return self;
  2201. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2202. }, function($ctx1) {$ctx1.fill(self,"gruntInitThenDo:",{aBlock:aBlock,child:child,sanitizedTemplatePath:sanitizedTemplatePath},$globals.Initer)});
  2203. //>>excludeEnd("ctx");
  2204. },
  2205. //>>excludeStart("ide", pragmas.excludeIdeData);
  2206. args: ["aBlock"],
  2207. source: "gruntInitThenDo: aBlock\x0a\x09| child sanitizedTemplatePath |\x0a\x09sanitizedTemplatePath := ((path join: nmPath with: 'grunt-init-amber')\x0a\x09\x09replace: '\x5c\x5c' with: '\x5c\x5c') replace: ':' with: '\x5c:'.\x0a\x09child := childProcess\x0a\x09\x09fork: (self npmScriptForModule: 'grunt-init' named: 'grunt-init')\x0a\x09\x09args: {sanitizedTemplatePath}.\x0a\x09child\x0a\x09\x09on: 'error' do: aBlock;\x0a\x09\x09on: 'close' do: [ :code |\x0a\x09\x09\x09aBlock value: (code = 0 ifTrue: [ nil ] ifFalse: [ code ]) ]",
  2208. referencedClasses: [],
  2209. //>>excludeEnd("ide");
  2210. messageSends: ["replace:with:", "join:with:", "fork:args:", "npmScriptForModule:named:", "on:do:", "value:", "ifTrue:ifFalse:", "="]
  2211. }),
  2212. $globals.Initer);
  2213. $core.addMethod(
  2214. $core.method({
  2215. selector: "gruntThenDo:",
  2216. protocol: "action",
  2217. fn: function (aBlock){
  2218. var self=this,$self=this;
  2219. var child;
  2220. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2221. return $core.withContext(function($ctx1) {
  2222. //>>excludeEnd("ctx");
  2223. var $1,$3,$2;
  2224. child=$recv($self["@childProcess"])._fork_args_($self._npmScriptForModule_named_("grunt-cli","grunt"),["default", "devel"]);
  2225. $1=child;
  2226. $recv($1)._on_do_("error",aBlock);
  2227. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2228. $ctx1.sendIdx["on:do:"]=1;
  2229. //>>excludeEnd("ctx");
  2230. $recv($1)._on_do_("close",(function(code){
  2231. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2232. return $core.withContext(function($ctx2) {
  2233. //>>excludeEnd("ctx");
  2234. $3=$recv(code).__eq((0));
  2235. if($core.assert($3)){
  2236. $2=nil;
  2237. } else {
  2238. $2=code;
  2239. }
  2240. return $recv(aBlock)._value_($2);
  2241. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2242. }, function($ctx2) {$ctx2.fillBlock({code:code},$ctx1,1)});
  2243. //>>excludeEnd("ctx");
  2244. }));
  2245. return self;
  2246. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2247. }, function($ctx1) {$ctx1.fill(self,"gruntThenDo:",{aBlock:aBlock,child:child},$globals.Initer)});
  2248. //>>excludeEnd("ctx");
  2249. },
  2250. //>>excludeStart("ide", pragmas.excludeIdeData);
  2251. args: ["aBlock"],
  2252. source: "gruntThenDo: aBlock\x0a\x09| child |\x0a\x09child := childProcess\x0a\x09\x09fork: (self npmScriptForModule: 'grunt-cli' named: 'grunt')\x0a\x09\x09args: #('default' 'devel').\x0a\x09child\x0a\x09\x09on: 'error' do: aBlock;\x0a\x09\x09on: 'close' do: [ :code |\x0a\x09\x09\x09aBlock value: (code = 0 ifTrue: [ nil ] ifFalse: [ code ]) ]",
  2253. referencedClasses: [],
  2254. //>>excludeEnd("ide");
  2255. messageSends: ["fork:args:", "npmScriptForModule:named:", "on:do:", "value:", "ifTrue:ifFalse:", "="]
  2256. }),
  2257. $globals.Initer);
  2258. $core.addMethod(
  2259. $core.method({
  2260. selector: "initialize",
  2261. protocol: "initialization",
  2262. fn: function (){
  2263. var self=this,$self=this;
  2264. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2265. return $core.withContext(function($ctx1) {
  2266. //>>excludeEnd("ctx");
  2267. (
  2268. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2269. $ctx1.supercall = true,
  2270. //>>excludeEnd("ctx");
  2271. ($globals.Initer.superclass||$boot.nilAsClass).fn.prototype._initialize.apply($self, []));
  2272. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2273. $ctx1.supercall = false;
  2274. //>>excludeEnd("ctx");;
  2275. $self["@childProcess"]=$recv(require)._value_("child_process");
  2276. $self["@nmPath"]=$recv($self["@path"])._join_with_($self._rootDirname(),"node_modules");
  2277. return self;
  2278. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2279. }, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.Initer)});
  2280. //>>excludeEnd("ctx");
  2281. },
  2282. //>>excludeStart("ide", pragmas.excludeIdeData);
  2283. args: [],
  2284. source: "initialize\x0a\x09super initialize.\x0a\x09childProcess := require value: 'child_process'.\x0a\x09nmPath := path join: self rootDirname with: 'node_modules'",
  2285. referencedClasses: [],
  2286. //>>excludeEnd("ide");
  2287. messageSends: ["initialize", "value:", "join:with:", "rootDirname"]
  2288. }),
  2289. $globals.Initer);
  2290. $core.addMethod(
  2291. $core.method({
  2292. selector: "npmInstallThenDo:",
  2293. protocol: "action",
  2294. fn: function (aBlock){
  2295. var self=this,$self=this;
  2296. var child;
  2297. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2298. return $core.withContext(function($ctx1) {
  2299. //>>excludeEnd("ctx");
  2300. var $1;
  2301. child=$recv($self["@childProcess"])._exec_thenDo_("npm install",aBlock);
  2302. $1=$recv(child)._stdout();
  2303. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2304. $ctx1.sendIdx["stdout"]=1;
  2305. //>>excludeEnd("ctx");
  2306. $recv($1)._pipe_options_($recv(process)._stdout(),$globals.HashedCollection._newFromPairs_(["end",false]));
  2307. return self;
  2308. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2309. }, function($ctx1) {$ctx1.fill(self,"npmInstallThenDo:",{aBlock:aBlock,child:child},$globals.Initer)});
  2310. //>>excludeEnd("ctx");
  2311. },
  2312. //>>excludeStart("ide", pragmas.excludeIdeData);
  2313. args: ["aBlock"],
  2314. source: "npmInstallThenDo: aBlock\x0a\x09| child |\x0a\x09child := childProcess\x0a\x09\x09exec: 'npm install'\x0a\x09\x09thenDo: aBlock.\x0a\x09child stdout pipe: process stdout options: #{ 'end' -> false }",
  2315. referencedClasses: [],
  2316. //>>excludeEnd("ide");
  2317. messageSends: ["exec:thenDo:", "pipe:options:", "stdout"]
  2318. }),
  2319. $globals.Initer);
  2320. $core.addMethod(
  2321. $core.method({
  2322. selector: "npmScriptForModule:named:",
  2323. protocol: "npm",
  2324. fn: function (aString,anotherString){
  2325. var self=this,$self=this;
  2326. var modulePath,packageJson,binSection,scriptPath;
  2327. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2328. return $core.withContext(function($ctx1) {
  2329. //>>excludeEnd("ctx");
  2330. var $1,$3,$4,$2,$5;
  2331. $1=$self["@path"];
  2332. $3=$recv($globals.JSObjectProxy)._on_(require);
  2333. $4=$recv(aString).__comma("/package.json");
  2334. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2335. $ctx1.sendIdx[","]=1;
  2336. //>>excludeEnd("ctx");
  2337. $2=$recv($3)._resolve_($4);
  2338. modulePath=$recv($1)._dirname_($2);
  2339. packageJson=$recv($globals.Smalltalk)._readJSObject_($recv(require)._value_($recv(aString).__comma("/package.json")));
  2340. binSection=$recv(packageJson)._at_("bin");
  2341. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2342. $ctx1.sendIdx["at:"]=1;
  2343. //>>excludeEnd("ctx");
  2344. $5=$recv(binSection)._isString();
  2345. if($core.assert($5)){
  2346. scriptPath=binSection;
  2347. } else {
  2348. scriptPath=$recv(binSection)._at_(anotherString);
  2349. }
  2350. return $recv($self["@path"])._join_with_(modulePath,scriptPath);
  2351. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2352. }, function($ctx1) {$ctx1.fill(self,"npmScriptForModule:named:",{aString:aString,anotherString:anotherString,modulePath:modulePath,packageJson:packageJson,binSection:binSection,scriptPath:scriptPath},$globals.Initer)});
  2353. //>>excludeEnd("ctx");
  2354. },
  2355. //>>excludeStart("ide", pragmas.excludeIdeData);
  2356. args: ["aString", "anotherString"],
  2357. source: "npmScriptForModule: aString named: anotherString\x0a\x09| modulePath packageJson binSection scriptPath |\x0a\x09modulePath := path dirname: (\x0a\x09\x09(JSObjectProxy on: require)\x0a\x09\x09\x09resolve: aString, '/package.json').\x0a\x09packageJson := Smalltalk readJSObject: (\x0a\x09\x09require value: aString, '/package.json').\x0a\x09binSection := packageJson at: 'bin'.\x0a\x09scriptPath := binSection isString\x0a\x09\x09ifTrue: [ binSection ]\x0a\x09\x09ifFalse: [ binSection at: anotherString ].\x0a\x09^ path join: modulePath with: scriptPath",
  2358. referencedClasses: ["JSObjectProxy", "Smalltalk"],
  2359. //>>excludeEnd("ide");
  2360. messageSends: ["dirname:", "resolve:", "on:", ",", "readJSObject:", "value:", "at:", "ifTrue:ifFalse:", "isString", "join:with:"]
  2361. }),
  2362. $globals.Initer);
  2363. $core.addMethod(
  2364. $core.method({
  2365. selector: "start",
  2366. protocol: "action",
  2367. fn: function (){
  2368. var self=this,$self=this;
  2369. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2370. return $core.withContext(function($ctx1) {
  2371. //>>excludeEnd("ctx");
  2372. var $1,$2,$3,$4,$5,$6,$7,$receiver;
  2373. $self._gruntInitThenDo_((function(error){
  2374. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2375. return $core.withContext(function($ctx2) {
  2376. //>>excludeEnd("ctx");
  2377. if(($receiver = error) == null || $receiver.a$nil){
  2378. return $self._bowerInstallThenDo_((function(error2){
  2379. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2380. return $core.withContext(function($ctx3) {
  2381. //>>excludeEnd("ctx");
  2382. if(($receiver = error2) == null || $receiver.a$nil){
  2383. return $self._npmInstallThenDo_((function(error3){
  2384. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2385. return $core.withContext(function($ctx4) {
  2386. //>>excludeEnd("ctx");
  2387. if(($receiver = error3) == null || $receiver.a$nil){
  2388. return $self._gruntThenDo_((function(error4){
  2389. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2390. return $core.withContext(function($ctx5) {
  2391. //>>excludeEnd("ctx");
  2392. if(($receiver = error4) == null || $receiver.a$nil){
  2393. $self._finishMessage();
  2394. return $recv(process)._exit();
  2395. } else {
  2396. $7=console;
  2397. $recv($7)._log_("grunt exec error:");
  2398. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2399. $ctx5.sendIdx["log:"]=7;
  2400. //>>excludeEnd("ctx");
  2401. $recv($7)._log_(error4);
  2402. return $recv(process)._exit_((104));
  2403. }
  2404. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2405. }, function($ctx5) {$ctx5.fillBlock({error4:error4},$ctx4,10)});
  2406. //>>excludeEnd("ctx");
  2407. }));
  2408. } else {
  2409. $5=console;
  2410. $recv($5)._log_("npm install exec error:");
  2411. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2412. $ctx4.sendIdx["log:"]=5;
  2413. //>>excludeEnd("ctx");
  2414. $6=$recv($5)._log_(error3);
  2415. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2416. $ctx4.sendIdx["log:"]=6;
  2417. //>>excludeEnd("ctx");
  2418. $6;
  2419. return $recv(process)._exit_((103));
  2420. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2421. $ctx4.sendIdx["exit:"]=3;
  2422. //>>excludeEnd("ctx");
  2423. }
  2424. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2425. }, function($ctx4) {$ctx4.fillBlock({error3:error3},$ctx3,7)});
  2426. //>>excludeEnd("ctx");
  2427. }));
  2428. } else {
  2429. $3=console;
  2430. $recv($3)._log_("bower install exec error:");
  2431. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2432. $ctx3.sendIdx["log:"]=3;
  2433. //>>excludeEnd("ctx");
  2434. $4=$recv($3)._log_(error2);
  2435. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2436. $ctx3.sendIdx["log:"]=4;
  2437. //>>excludeEnd("ctx");
  2438. $4;
  2439. return $recv(process)._exit_((102));
  2440. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2441. $ctx3.sendIdx["exit:"]=2;
  2442. //>>excludeEnd("ctx");
  2443. }
  2444. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2445. }, function($ctx3) {$ctx3.fillBlock({error2:error2},$ctx2,4)});
  2446. //>>excludeEnd("ctx");
  2447. }));
  2448. } else {
  2449. $1=console;
  2450. $recv($1)._log_("grunt-init exec error:");
  2451. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2452. $ctx2.sendIdx["log:"]=1;
  2453. //>>excludeEnd("ctx");
  2454. $2=$recv($1)._log_(error);
  2455. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2456. $ctx2.sendIdx["log:"]=2;
  2457. //>>excludeEnd("ctx");
  2458. $2;
  2459. return $recv(process)._exit_((101));
  2460. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2461. $ctx2.sendIdx["exit:"]=1;
  2462. //>>excludeEnd("ctx");
  2463. }
  2464. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2465. }, function($ctx2) {$ctx2.fillBlock({error:error},$ctx1,1)});
  2466. //>>excludeEnd("ctx");
  2467. }));
  2468. return self;
  2469. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2470. }, function($ctx1) {$ctx1.fill(self,"start",{},$globals.Initer)});
  2471. //>>excludeEnd("ctx");
  2472. },
  2473. //>>excludeStart("ide", pragmas.excludeIdeData);
  2474. args: [],
  2475. source: "start\x0a\x09self gruntInitThenDo: [ :error | error\x0a\x09ifNotNil: [\x0a\x09\x09console log: 'grunt-init exec error:'; log: error.\x0a\x09\x09process exit: 101 ]\x0a\x09ifNil: [\x0a\x0a\x09self bowerInstallThenDo: [ :error2 | error2\x0a\x09ifNotNil: [\x0a\x09\x09console log: 'bower install exec error:'; log: error2.\x0a\x09\x09process exit: 102 ]\x0a\x09ifNil: [\x0a\x0a\x09self npmInstallThenDo: [ :error3 | error3\x0a\x09ifNotNil: [\x0a\x09\x09console log: 'npm install exec error:'; log: error3.\x0a\x09\x09process exit: 103 ]\x0a\x09ifNil: [\x0a\x0a\x09self gruntThenDo: [ :error4 | error4\x0a\x09ifNotNil: [\x0a\x09\x09console log: 'grunt exec error:'; log: error4.\x0a\x09\x09process exit: 104 ]\x0a\x09ifNil: [\x0a\x0a\x09self finishMessage.\x0a\x09process exit ]]]]]]]]",
  2476. referencedClasses: [],
  2477. //>>excludeEnd("ide");
  2478. messageSends: ["gruntInitThenDo:", "ifNotNil:ifNil:", "log:", "exit:", "bowerInstallThenDo:", "npmInstallThenDo:", "gruntThenDo:", "finishMessage", "exit"]
  2479. }),
  2480. $globals.Initer);
  2481. $core.addClass("Repl", $globals.Object, ["readline", "interface", "util", "session", "resultCount", "commands"], "AmberCli");
  2482. //>>excludeStart("ide", pragmas.excludeIdeData);
  2483. $globals.Repl.comment="I am a class representing a REPL (Read Evaluate Print Loop) and provide a command line interface to Amber Smalltalk.\x0aOn the prompt you can type Amber statements which will be evaluated after pressing <Enter>.\x0aThe evaluation is comparable with executing a 'DoIt' in a workspace.\x0a\x0aMy runtime requirement is a functional Node.js executable with working Readline support.";
  2484. //>>excludeEnd("ide");
  2485. $core.addMethod(
  2486. $core.method({
  2487. selector: "addVariableNamed:to:",
  2488. protocol: "private",
  2489. fn: function (aString,anObject){
  2490. var self=this,$self=this;
  2491. var newClass,newObject;
  2492. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2493. return $core.withContext(function($ctx1) {
  2494. //>>excludeEnd("ctx");
  2495. newClass=$self._subclass_withVariable_($recv(anObject)._class(),aString);
  2496. $self._encapsulateVariable_withValue_in_(aString,anObject,newClass);
  2497. newObject=$recv(newClass)._new();
  2498. $self._setPreviousVariablesFor_from_(newObject,anObject);
  2499. return newObject;
  2500. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2501. }, function($ctx1) {$ctx1.fill(self,"addVariableNamed:to:",{aString:aString,anObject:anObject,newClass:newClass,newObject:newObject},$globals.Repl)});
  2502. //>>excludeEnd("ctx");
  2503. },
  2504. //>>excludeStart("ide", pragmas.excludeIdeData);
  2505. args: ["aString", "anObject"],
  2506. source: "addVariableNamed: aString to: anObject\x0a\x09| newClass newObject |\x0a\x09newClass := self subclass: anObject class withVariable: aString.\x0a\x09self encapsulateVariable: aString withValue: anObject in: newClass.\x0a\x09newObject := newClass new.\x0a\x09self setPreviousVariablesFor: newObject from: anObject.\x0a\x09^ newObject",
  2507. referencedClasses: [],
  2508. //>>excludeEnd("ide");
  2509. messageSends: ["subclass:withVariable:", "class", "encapsulateVariable:withValue:in:", "new", "setPreviousVariablesFor:from:"]
  2510. }),
  2511. $globals.Repl);
  2512. $core.addMethod(
  2513. $core.method({
  2514. selector: "assignNewVariable:do:",
  2515. protocol: "private",
  2516. fn: function (buffer,aBlock){
  2517. var self=this,$self=this;
  2518. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2519. return $core.withContext(function($ctx1) {
  2520. //>>excludeEnd("ctx");
  2521. var $2,$3,$1,$receiver;
  2522. return $self._parseAssignment_do_(buffer,(function(name,expr){
  2523. var varName,value;
  2524. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2525. return $core.withContext(function($ctx2) {
  2526. //>>excludeEnd("ctx");
  2527. if(($receiver = name) == null || $receiver.a$nil){
  2528. varName=$self._nextResultName();
  2529. } else {
  2530. varName=name;
  2531. }
  2532. varName;
  2533. $self["@session"]=$self._addVariableNamed_to_(varName,$self["@session"]);
  2534. $self["@session"];
  2535. $recv((function(){
  2536. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2537. return $core.withContext(function($ctx3) {
  2538. //>>excludeEnd("ctx");
  2539. $2=$recv(varName).__comma(" := ");
  2540. if(($receiver = expr) == null || $receiver.a$nil){
  2541. $3=buffer;
  2542. } else {
  2543. $3=expr;
  2544. }
  2545. $1=$recv($2).__comma($3);
  2546. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2547. $ctx3.sendIdx[","]=1;
  2548. //>>excludeEnd("ctx");
  2549. value=$self._eval_on_($1,$self["@session"]);
  2550. return value;
  2551. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2552. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)});
  2553. //>>excludeEnd("ctx");
  2554. }))._on_do_($globals.Error,(function(e){
  2555. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2556. return $core.withContext(function($ctx3) {
  2557. //>>excludeEnd("ctx");
  2558. $recv($recv($globals.ConsoleErrorHandler)._new())._logError_(e);
  2559. value=nil;
  2560. return value;
  2561. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2562. }, function($ctx3) {$ctx3.fillBlock({e:e},$ctx2,5)});
  2563. //>>excludeEnd("ctx");
  2564. }));
  2565. return $recv(aBlock)._value_value_(varName,value);
  2566. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2567. }, function($ctx2) {$ctx2.fillBlock({name:name,expr:expr,varName:varName,value:value},$ctx1,1)});
  2568. //>>excludeEnd("ctx");
  2569. }));
  2570. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2571. }, function($ctx1) {$ctx1.fill(self,"assignNewVariable:do:",{buffer:buffer,aBlock:aBlock},$globals.Repl)});
  2572. //>>excludeEnd("ctx");
  2573. },
  2574. //>>excludeStart("ide", pragmas.excludeIdeData);
  2575. args: ["buffer", "aBlock"],
  2576. source: "assignNewVariable: buffer do: aBlock\x0a\x09\x22Assigns a new variable and calls the given block with the variable's name and value\x0a\x09 if buffer contains an assignment expression. If it doesn't the block is called with nil for\x0a\x09 both arguments.\x22\x0a\x09^ self parseAssignment: buffer do: [ :name :expr || varName value |\x0a\x09\x09varName := name ifNil: [self nextResultName].\x0a\x09\x09session := self addVariableNamed: varName to: session.\x0a\x09\x09[ value := self eval: varName, ' := ', (expr ifNil: [buffer]) on: session ]\x0a\x09\x09\x09on: Error\x0a\x09\x09\x09do: [ :e | ConsoleErrorHandler new logError: e. value := nil].\x0a\x09\x09aBlock value: varName value: value]",
  2577. referencedClasses: ["Error", "ConsoleErrorHandler"],
  2578. //>>excludeEnd("ide");
  2579. messageSends: ["parseAssignment:do:", "ifNil:", "nextResultName", "addVariableNamed:to:", "on:do:", "eval:on:", ",", "logError:", "new", "value:value:"]
  2580. }),
  2581. $globals.Repl);
  2582. $core.addMethod(
  2583. $core.method({
  2584. selector: "clearScreen",
  2585. protocol: "actions",
  2586. fn: function (){
  2587. var self=this,$self=this;
  2588. var esc,cls;
  2589. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2590. return $core.withContext(function($ctx1) {
  2591. //>>excludeEnd("ctx");
  2592. var $1;
  2593. esc=$recv($globals.String)._fromCharCode_((27));
  2594. $1=$recv($recv(esc).__comma("[2J")).__comma(esc);
  2595. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2596. $ctx1.sendIdx[","]=2;
  2597. //>>excludeEnd("ctx");
  2598. cls=$recv($1).__comma("[0;0f");
  2599. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2600. $ctx1.sendIdx[","]=1;
  2601. //>>excludeEnd("ctx");
  2602. $recv($recv(process)._stdout())._write_(cls);
  2603. $recv($self["@interface"])._prompt();
  2604. return self;
  2605. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2606. }, function($ctx1) {$ctx1.fill(self,"clearScreen",{esc:esc,cls:cls},$globals.Repl)});
  2607. //>>excludeEnd("ctx");
  2608. },
  2609. //>>excludeStart("ide", pragmas.excludeIdeData);
  2610. args: [],
  2611. source: "clearScreen\x0a\x09| esc cls |\x0a\x09esc := String fromCharCode: 27.\x0a\x09cls := esc, '[2J', esc, '[0;0f'.\x0a\x09process stdout write: cls.\x0a\x09interface prompt",
  2612. referencedClasses: ["String"],
  2613. //>>excludeEnd("ide");
  2614. messageSends: ["fromCharCode:", ",", "write:", "stdout", "prompt"]
  2615. }),
  2616. $globals.Repl);
  2617. $core.addMethod(
  2618. $core.method({
  2619. selector: "close",
  2620. protocol: "actions",
  2621. fn: function (){
  2622. var self=this,$self=this;
  2623. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2624. return $core.withContext(function($ctx1) {
  2625. //>>excludeEnd("ctx");
  2626. $recv($recv(process)._stdin())._destroy();
  2627. return self;
  2628. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2629. }, function($ctx1) {$ctx1.fill(self,"close",{},$globals.Repl)});
  2630. //>>excludeEnd("ctx");
  2631. },
  2632. //>>excludeStart("ide", pragmas.excludeIdeData);
  2633. args: [],
  2634. source: "close\x0a\x09process stdin destroy",
  2635. referencedClasses: [],
  2636. //>>excludeEnd("ide");
  2637. messageSends: ["destroy", "stdin"]
  2638. }),
  2639. $globals.Repl);
  2640. $core.addMethod(
  2641. $core.method({
  2642. selector: "commands",
  2643. protocol: "accessing",
  2644. fn: function (){
  2645. var self=this,$self=this;
  2646. return $self["@commands"];
  2647. },
  2648. //>>excludeStart("ide", pragmas.excludeIdeData);
  2649. args: [],
  2650. source: "commands\x0a\x09^ commands",
  2651. referencedClasses: [],
  2652. //>>excludeEnd("ide");
  2653. messageSends: []
  2654. }),
  2655. $globals.Repl);
  2656. $core.addMethod(
  2657. $core.method({
  2658. selector: "createInterface",
  2659. protocol: "actions",
  2660. fn: function (){
  2661. var self=this,$self=this;
  2662. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2663. return $core.withContext(function($ctx1) {
  2664. //>>excludeEnd("ctx");
  2665. $self["@interface"]=$recv($self["@readline"])._createInterface_stdout_($recv(process)._stdin(),$recv(process)._stdout());
  2666. $recv($self["@interface"])._on_do_("line",(function(buffer){
  2667. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2668. return $core.withContext(function($ctx2) {
  2669. //>>excludeEnd("ctx");
  2670. return $self._processLine_(buffer);
  2671. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2672. }, function($ctx2) {$ctx2.fillBlock({buffer:buffer},$ctx1,1)});
  2673. //>>excludeEnd("ctx");
  2674. }));
  2675. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2676. $ctx1.sendIdx["on:do:"]=1;
  2677. //>>excludeEnd("ctx");
  2678. $recv($self["@interface"])._on_do_("close",(function(){
  2679. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2680. return $core.withContext(function($ctx2) {
  2681. //>>excludeEnd("ctx");
  2682. return $self._close();
  2683. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2684. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  2685. //>>excludeEnd("ctx");
  2686. }));
  2687. $self._printWelcome();
  2688. $self._setupHotkeys();
  2689. $self._setPrompt();
  2690. $recv($self["@interface"])._prompt();
  2691. return self;
  2692. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2693. }, function($ctx1) {$ctx1.fill(self,"createInterface",{},$globals.Repl)});
  2694. //>>excludeEnd("ctx");
  2695. },
  2696. //>>excludeStart("ide", pragmas.excludeIdeData);
  2697. args: [],
  2698. source: "createInterface\x0a\x09interface := readline createInterface: process stdin stdout: process stdout.\x0a\x09interface on: 'line' do: [:buffer | self processLine: buffer].\x0a\x09interface on: 'close' do: [self close].\x0a\x09self printWelcome; setupHotkeys; setPrompt.\x0a\x09interface prompt",
  2699. referencedClasses: [],
  2700. //>>excludeEnd("ide");
  2701. messageSends: ["createInterface:stdout:", "stdin", "stdout", "on:do:", "processLine:", "close", "printWelcome", "setupHotkeys", "setPrompt", "prompt"]
  2702. }),
  2703. $globals.Repl);
  2704. $core.addMethod(
  2705. $core.method({
  2706. selector: "encapsulateVariable:withValue:in:",
  2707. protocol: "private",
  2708. fn: function (aString,anObject,aClass){
  2709. var self=this,$self=this;
  2710. var compiler;
  2711. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2712. return $core.withContext(function($ctx1) {
  2713. //>>excludeEnd("ctx");
  2714. var $1,$4,$3,$2,$5,$6;
  2715. compiler=$recv($globals.Compiler)._new();
  2716. $1=compiler;
  2717. $4=$recv(aString).__comma(": anObject ^ ");
  2718. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2719. $ctx1.sendIdx[","]=3;
  2720. //>>excludeEnd("ctx");
  2721. $3=$recv($4).__comma(aString);
  2722. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2723. $ctx1.sendIdx[","]=2;
  2724. //>>excludeEnd("ctx");
  2725. $2=$recv($3).__comma(" := anObject");
  2726. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2727. $ctx1.sendIdx[","]=1;
  2728. //>>excludeEnd("ctx");
  2729. $recv($1)._install_forClass_protocol_($2,aClass,"session");
  2730. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2731. $ctx1.sendIdx["install:forClass:protocol:"]=1;
  2732. //>>excludeEnd("ctx");
  2733. $5=compiler;
  2734. $6=$recv($recv(aString).__comma(" ^ ")).__comma(aString);
  2735. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2736. $ctx1.sendIdx[","]=4;
  2737. //>>excludeEnd("ctx");
  2738. $recv($5)._install_forClass_protocol_($6,aClass,"session");
  2739. return self;
  2740. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2741. }, function($ctx1) {$ctx1.fill(self,"encapsulateVariable:withValue:in:",{aString:aString,anObject:anObject,aClass:aClass,compiler:compiler},$globals.Repl)});
  2742. //>>excludeEnd("ctx");
  2743. },
  2744. //>>excludeStart("ide", pragmas.excludeIdeData);
  2745. args: ["aString", "anObject", "aClass"],
  2746. source: "encapsulateVariable: aString withValue: anObject in: aClass\x0a\x09\x22Add getter and setter for given variable to session.\x22\x0a\x09| compiler |\x0a\x09compiler := Compiler new.\x0a\x09compiler install: aString, ': anObject ^ ', aString, ' := anObject' forClass: aClass protocol: 'session'.\x0a\x09compiler install: aString, ' ^ ', aString forClass: aClass protocol: 'session'.",
  2747. referencedClasses: ["Compiler"],
  2748. //>>excludeEnd("ide");
  2749. messageSends: ["new", "install:forClass:protocol:", ","]
  2750. }),
  2751. $globals.Repl);
  2752. $core.addMethod(
  2753. $core.method({
  2754. selector: "eval:",
  2755. protocol: "actions",
  2756. fn: function (buffer){
  2757. var self=this,$self=this;
  2758. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2759. return $core.withContext(function($ctx1) {
  2760. //>>excludeEnd("ctx");
  2761. return $self._eval_on_(buffer,$recv($globals.DoIt)._new());
  2762. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2763. }, function($ctx1) {$ctx1.fill(self,"eval:",{buffer:buffer},$globals.Repl)});
  2764. //>>excludeEnd("ctx");
  2765. },
  2766. //>>excludeStart("ide", pragmas.excludeIdeData);
  2767. args: ["buffer"],
  2768. source: "eval: buffer\x0a\x09^ self eval: buffer on: DoIt new.",
  2769. referencedClasses: ["DoIt"],
  2770. //>>excludeEnd("ide");
  2771. messageSends: ["eval:on:", "new"]
  2772. }),
  2773. $globals.Repl);
  2774. $core.addMethod(
  2775. $core.method({
  2776. selector: "eval:on:",
  2777. protocol: "actions",
  2778. fn: function (buffer,anObject){
  2779. var self=this,$self=this;
  2780. var result;
  2781. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2782. return $core.withContext(function($ctx1) {
  2783. //>>excludeEnd("ctx");
  2784. var $1;
  2785. $recv(buffer)._ifNotEmpty_((function(){
  2786. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2787. return $core.withContext(function($ctx2) {
  2788. //>>excludeEnd("ctx");
  2789. return $recv((function(){
  2790. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2791. return $core.withContext(function($ctx3) {
  2792. //>>excludeEnd("ctx");
  2793. result=$recv($recv($globals.Compiler)._new())._evaluateExpression_on_(buffer,anObject);
  2794. return result;
  2795. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2796. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  2797. //>>excludeEnd("ctx");
  2798. }))._tryCatch_((function(e){
  2799. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2800. return $core.withContext(function($ctx3) {
  2801. //>>excludeEnd("ctx");
  2802. $1=$recv(e)._isSmalltalkError();
  2803. if($core.assert($1)){
  2804. return $recv(e)._resignal();
  2805. } else {
  2806. return $recv($recv(process)._stdout())._write_($recv(e)._jsStack());
  2807. }
  2808. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2809. }, function($ctx3) {$ctx3.fillBlock({e:e},$ctx2,3)});
  2810. //>>excludeEnd("ctx");
  2811. }));
  2812. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2813. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  2814. //>>excludeEnd("ctx");
  2815. }));
  2816. return result;
  2817. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2818. }, function($ctx1) {$ctx1.fill(self,"eval:on:",{buffer:buffer,anObject:anObject,result:result},$globals.Repl)});
  2819. //>>excludeEnd("ctx");
  2820. },
  2821. //>>excludeStart("ide", pragmas.excludeIdeData);
  2822. args: ["buffer", "anObject"],
  2823. source: "eval: buffer on: anObject\x0a\x09| result |\x0a\x09buffer ifNotEmpty: [\x0a\x09\x09[result := Compiler new evaluateExpression: buffer on: anObject]\x0a\x09\x09\x09tryCatch: [:e |\x0a\x09\x09\x09\x09e isSmalltalkError\x0a\x09\x09\x09\x09\x09ifTrue: [ e resignal ]\x0a\x09\x09\x09\x09\x09ifFalse: [ process stdout write: e jsStack ]]].\x0a\x09^ result",
  2824. referencedClasses: ["Compiler"],
  2825. //>>excludeEnd("ide");
  2826. messageSends: ["ifNotEmpty:", "tryCatch:", "evaluateExpression:on:", "new", "ifTrue:ifFalse:", "isSmalltalkError", "resignal", "write:", "stdout", "jsStack"]
  2827. }),
  2828. $globals.Repl);
  2829. $core.addMethod(
  2830. $core.method({
  2831. selector: "executeCommand:",
  2832. protocol: "private",
  2833. fn: function (aString){
  2834. var self=this,$self=this;
  2835. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2836. return $core.withContext(function($ctx1) {
  2837. //>>excludeEnd("ctx");
  2838. var $1;
  2839. var $early={};
  2840. try {
  2841. $recv($self._commands())._keysAndValuesDo_((function(names,cmd){
  2842. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2843. return $core.withContext(function($ctx2) {
  2844. //>>excludeEnd("ctx");
  2845. $1=$recv(names)._includes_(aString);
  2846. if($core.assert($1)){
  2847. $recv(cmd)._value();
  2848. throw $early=[true];
  2849. }
  2850. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2851. }, function($ctx2) {$ctx2.fillBlock({names:names,cmd:cmd},$ctx1,1)});
  2852. //>>excludeEnd("ctx");
  2853. }));
  2854. return false;
  2855. }
  2856. catch(e) {if(e===$early)return e[0]; throw e}
  2857. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2858. }, function($ctx1) {$ctx1.fill(self,"executeCommand:",{aString:aString},$globals.Repl)});
  2859. //>>excludeEnd("ctx");
  2860. },
  2861. //>>excludeStart("ide", pragmas.excludeIdeData);
  2862. args: ["aString"],
  2863. source: "executeCommand: aString\x0a\x09\x22Tries to process the given string as a command. Returns true if it was a command, false if not.\x22\x0a\x09self commands keysAndValuesDo: [:names :cmd |\x0a\x09\x09(names includes: aString) ifTrue: [\x0a\x09\x09\x09cmd value.\x0a\x09\x09\x09^ true]].\x0a\x09^ false",
  2864. referencedClasses: [],
  2865. //>>excludeEnd("ide");
  2866. messageSends: ["keysAndValuesDo:", "commands", "ifTrue:", "includes:", "value"]
  2867. }),
  2868. $globals.Repl);
  2869. $core.addMethod(
  2870. $core.method({
  2871. selector: "initialize",
  2872. protocol: "initialization",
  2873. fn: function (){
  2874. var self=this,$self=this;
  2875. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2876. return $core.withContext(function($ctx1) {
  2877. //>>excludeEnd("ctx");
  2878. (
  2879. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2880. $ctx1.supercall = true,
  2881. //>>excludeEnd("ctx");
  2882. ($globals.Repl.superclass||$boot.nilAsClass).fn.prototype._initialize.apply($self, []));
  2883. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2884. $ctx1.supercall = false;
  2885. //>>excludeEnd("ctx");;
  2886. $self["@session"]=$recv($globals.DoIt)._new();
  2887. $self["@readline"]=$recv(require)._value_("readline");
  2888. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2889. $ctx1.sendIdx["value:"]=1;
  2890. //>>excludeEnd("ctx");
  2891. $self["@util"]=$recv(require)._value_("util");
  2892. $self._setupCommands();
  2893. return self;
  2894. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2895. }, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.Repl)});
  2896. //>>excludeEnd("ctx");
  2897. },
  2898. //>>excludeStart("ide", pragmas.excludeIdeData);
  2899. args: [],
  2900. source: "initialize\x0a\x09super initialize.\x0a\x09session := DoIt new.\x0a\x09readline := require value: 'readline'.\x0a\x09util := require value: 'util'.\x0a\x09self setupCommands",
  2901. referencedClasses: ["DoIt"],
  2902. //>>excludeEnd("ide");
  2903. messageSends: ["initialize", "new", "value:", "setupCommands"]
  2904. }),
  2905. $globals.Repl);
  2906. $core.addMethod(
  2907. $core.method({
  2908. selector: "instanceVariableNamesFor:",
  2909. protocol: "private",
  2910. fn: function (aClass){
  2911. var self=this,$self=this;
  2912. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2913. return $core.withContext(function($ctx1) {
  2914. //>>excludeEnd("ctx");
  2915. var $1,$2,$receiver;
  2916. $1=$recv(aClass)._superclass();
  2917. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2918. $ctx1.sendIdx["superclass"]=1;
  2919. //>>excludeEnd("ctx");
  2920. if(($receiver = $1) == null || $receiver.a$nil){
  2921. return $recv(aClass)._instanceVariableNames();
  2922. } else {
  2923. $2=$recv(aClass)._instanceVariableNames();
  2924. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2925. $ctx1.sendIdx["instanceVariableNames"]=1;
  2926. //>>excludeEnd("ctx");
  2927. return $recv($2)._copyWithAll_($self._instanceVariableNamesFor_($recv(aClass)._superclass()));
  2928. }
  2929. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2930. }, function($ctx1) {$ctx1.fill(self,"instanceVariableNamesFor:",{aClass:aClass},$globals.Repl)});
  2931. //>>excludeEnd("ctx");
  2932. },
  2933. //>>excludeStart("ide", pragmas.excludeIdeData);
  2934. args: ["aClass"],
  2935. source: "instanceVariableNamesFor: aClass\x0a\x09\x22Yields all instance variable names for the given class, including inherited ones.\x22\x0a\x09^ aClass superclass\x0a\x09\x09ifNotNil: [\x0a\x09\x09\x09aClass instanceVariableNames copyWithAll: (self instanceVariableNamesFor: aClass superclass)]\x0a\x09\x09ifNil: [\x0a\x09\x09\x09aClass instanceVariableNames]",
  2936. referencedClasses: [],
  2937. //>>excludeEnd("ide");
  2938. messageSends: ["ifNotNil:ifNil:", "superclass", "copyWithAll:", "instanceVariableNames", "instanceVariableNamesFor:"]
  2939. }),
  2940. $globals.Repl);
  2941. $core.addMethod(
  2942. $core.method({
  2943. selector: "isIdentifier:",
  2944. protocol: "private",
  2945. fn: function (aString){
  2946. var self=this,$self=this;
  2947. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2948. return $core.withContext(function($ctx1) {
  2949. //>>excludeEnd("ctx");
  2950. return $recv(aString)._match_("^[a-z_]\x5cw*$"._asRegexp());
  2951. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2952. }, function($ctx1) {$ctx1.fill(self,"isIdentifier:",{aString:aString},$globals.Repl)});
  2953. //>>excludeEnd("ctx");
  2954. },
  2955. //>>excludeStart("ide", pragmas.excludeIdeData);
  2956. args: ["aString"],
  2957. source: "isIdentifier: aString\x0a\x09^ aString match: '^[a-z_]\x5cw*$' asRegexp",
  2958. referencedClasses: [],
  2959. //>>excludeEnd("ide");
  2960. messageSends: ["match:", "asRegexp"]
  2961. }),
  2962. $globals.Repl);
  2963. $core.addMethod(
  2964. $core.method({
  2965. selector: "isVariableDefined:",
  2966. protocol: "private",
  2967. fn: function (aString){
  2968. var self=this,$self=this;
  2969. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2970. return $core.withContext(function($ctx1) {
  2971. //>>excludeEnd("ctx");
  2972. return $recv($self._instanceVariableNamesFor_($recv($self["@session"])._class()))._includes_(aString);
  2973. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2974. }, function($ctx1) {$ctx1.fill(self,"isVariableDefined:",{aString:aString},$globals.Repl)});
  2975. //>>excludeEnd("ctx");
  2976. },
  2977. //>>excludeStart("ide", pragmas.excludeIdeData);
  2978. args: ["aString"],
  2979. source: "isVariableDefined: aString\x0a\x09^ (self instanceVariableNamesFor: session class) includes: aString",
  2980. referencedClasses: [],
  2981. //>>excludeEnd("ide");
  2982. messageSends: ["includes:", "instanceVariableNamesFor:", "class"]
  2983. }),
  2984. $globals.Repl);
  2985. $core.addMethod(
  2986. $core.method({
  2987. selector: "nextResultName",
  2988. protocol: "private",
  2989. fn: function (){
  2990. var self=this,$self=this;
  2991. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2992. return $core.withContext(function($ctx1) {
  2993. //>>excludeEnd("ctx");
  2994. var $1,$receiver;
  2995. $1=$self["@resultCount"];
  2996. if(($receiver = $1) == null || $receiver.a$nil){
  2997. $self["@resultCount"]=(1);
  2998. } else {
  2999. $self["@resultCount"]=$recv($self["@resultCount"]).__plus((1));
  3000. }
  3001. return "res".__comma($recv($self["@resultCount"])._asString());
  3002. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3003. }, function($ctx1) {$ctx1.fill(self,"nextResultName",{},$globals.Repl)});
  3004. //>>excludeEnd("ctx");
  3005. },
  3006. //>>excludeStart("ide", pragmas.excludeIdeData);
  3007. args: [],
  3008. source: "nextResultName\x0a\x09resultCount := resultCount\x0a \x09ifNotNil: [resultCount + 1]\x0a \x09ifNil: [1].\x0a ^ 'res', resultCount asString",
  3009. referencedClasses: [],
  3010. //>>excludeEnd("ide");
  3011. messageSends: ["ifNotNil:ifNil:", "+", ",", "asString"]
  3012. }),
  3013. $globals.Repl);
  3014. $core.addMethod(
  3015. $core.method({
  3016. selector: "onKeyPress:",
  3017. protocol: "private",
  3018. fn: function (key){
  3019. var self=this,$self=this;
  3020. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3021. return $core.withContext(function($ctx1) {
  3022. //>>excludeEnd("ctx");
  3023. var $1;
  3024. $1=$recv($recv(key)._ctrl())._and_((function(){
  3025. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3026. return $core.withContext(function($ctx2) {
  3027. //>>excludeEnd("ctx");
  3028. return $recv($recv(key)._name()).__eq("l");
  3029. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3030. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  3031. //>>excludeEnd("ctx");
  3032. }));
  3033. if($core.assert($1)){
  3034. $self._clearScreen();
  3035. }
  3036. return self;
  3037. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3038. }, function($ctx1) {$ctx1.fill(self,"onKeyPress:",{key:key},$globals.Repl)});
  3039. //>>excludeEnd("ctx");
  3040. },
  3041. //>>excludeStart("ide", pragmas.excludeIdeData);
  3042. args: ["key"],
  3043. source: "onKeyPress: key\x0a\x09(key ctrl and: [key name = 'l'])\x0a\x09\x09ifTrue: [self clearScreen]",
  3044. referencedClasses: [],
  3045. //>>excludeEnd("ide");
  3046. messageSends: ["ifTrue:", "and:", "ctrl", "=", "name", "clearScreen"]
  3047. }),
  3048. $globals.Repl);
  3049. $core.addMethod(
  3050. $core.method({
  3051. selector: "parseAssignment:do:",
  3052. protocol: "private",
  3053. fn: function (aString,aBlock){
  3054. var self=this,$self=this;
  3055. var assignment;
  3056. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3057. return $core.withContext(function($ctx1) {
  3058. //>>excludeEnd("ctx");
  3059. var $2,$1;
  3060. assignment=$recv($recv(aString)._tokenize_(":="))._collect_((function(s){
  3061. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3062. return $core.withContext(function($ctx2) {
  3063. //>>excludeEnd("ctx");
  3064. return $recv(s)._trimBoth();
  3065. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3066. }, function($ctx2) {$ctx2.fillBlock({s:s},$ctx1,1)});
  3067. //>>excludeEnd("ctx");
  3068. }));
  3069. $1=$recv($recv($recv(assignment)._size()).__eq((2)))._and_((function(){
  3070. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3071. return $core.withContext(function($ctx2) {
  3072. //>>excludeEnd("ctx");
  3073. $2=$recv(assignment)._first();
  3074. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3075. $ctx2.sendIdx["first"]=1;
  3076. //>>excludeEnd("ctx");
  3077. return $self._isIdentifier_($2);
  3078. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3079. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  3080. //>>excludeEnd("ctx");
  3081. }));
  3082. if($core.assert($1)){
  3083. return $recv(aBlock)._value_value_($recv(assignment)._first(),$recv(assignment)._last());
  3084. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3085. $ctx1.sendIdx["value:value:"]=1;
  3086. //>>excludeEnd("ctx");
  3087. } else {
  3088. return $recv(aBlock)._value_value_(nil,nil);
  3089. }
  3090. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3091. }, function($ctx1) {$ctx1.fill(self,"parseAssignment:do:",{aString:aString,aBlock:aBlock,assignment:assignment},$globals.Repl)});
  3092. //>>excludeEnd("ctx");
  3093. },
  3094. //>>excludeStart("ide", pragmas.excludeIdeData);
  3095. args: ["aString", "aBlock"],
  3096. source: "parseAssignment: aString do: aBlock\x0a\x09\x22Assigns a new variable if the given string is an assignment expression. Calls the given block with name and value.\x0a\x09 If the string is not one no variable will be assigned and the block will be called with nil for both arguments.\x22\x0a\x09| assignment |\x0a\x09assignment := (aString tokenize: ':=') collect: [:s | s trimBoth].\x0a\x09^ (assignment size = 2 and: [self isIdentifier: assignment first])\x0a\x09\x09ifTrue: [ aBlock value: assignment first value: assignment last ]\x0a\x09\x09ifFalse: [ aBlock value: nil value: nil ]",
  3097. referencedClasses: [],
  3098. //>>excludeEnd("ide");
  3099. messageSends: ["collect:", "tokenize:", "trimBoth", "ifTrue:ifFalse:", "and:", "=", "size", "isIdentifier:", "first", "value:value:", "last"]
  3100. }),
  3101. $globals.Repl);
  3102. $core.addMethod(
  3103. $core.method({
  3104. selector: "presentResultNamed:withValue:",
  3105. protocol: "private",
  3106. fn: function (varName,value){
  3107. var self=this,$self=this;
  3108. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3109. return $core.withContext(function($ctx1) {
  3110. //>>excludeEnd("ctx");
  3111. var $3,$2,$1;
  3112. $3=$recv($recv(varName).__comma(": ")).__comma($recv($recv(value)._class())._name());
  3113. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3114. $ctx1.sendIdx[","]=3;
  3115. //>>excludeEnd("ctx");
  3116. $2=$recv($3).__comma(" = ");
  3117. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3118. $ctx1.sendIdx[","]=2;
  3119. //>>excludeEnd("ctx");
  3120. $1=$recv($2).__comma($recv(value)._asString());
  3121. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3122. $ctx1.sendIdx[","]=1;
  3123. //>>excludeEnd("ctx");
  3124. $recv($globals.Transcript)._show_($1);
  3125. $recv($globals.Transcript)._cr();
  3126. $recv($self["@interface"])._prompt();
  3127. return self;
  3128. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3129. }, function($ctx1) {$ctx1.fill(self,"presentResultNamed:withValue:",{varName:varName,value:value},$globals.Repl)});
  3130. //>>excludeEnd("ctx");
  3131. },
  3132. //>>excludeStart("ide", pragmas.excludeIdeData);
  3133. args: ["varName", "value"],
  3134. source: "presentResultNamed: varName withValue: value\x0a\x09Transcript show: varName, ': ', value class name, ' = ', value asString; cr.\x0a\x09interface prompt",
  3135. referencedClasses: ["Transcript"],
  3136. //>>excludeEnd("ide");
  3137. messageSends: ["show:", ",", "name", "class", "asString", "cr", "prompt"]
  3138. }),
  3139. $globals.Repl);
  3140. $core.addMethod(
  3141. $core.method({
  3142. selector: "printWelcome",
  3143. protocol: "actions",
  3144. fn: function (){
  3145. var self=this,$self=this;
  3146. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3147. return $core.withContext(function($ctx1) {
  3148. //>>excludeEnd("ctx");
  3149. $recv($globals.Transcript)._show_("Type :q to exit.");
  3150. $recv($globals.Transcript)._cr();
  3151. return self;
  3152. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3153. }, function($ctx1) {$ctx1.fill(self,"printWelcome",{},$globals.Repl)});
  3154. //>>excludeEnd("ctx");
  3155. },
  3156. //>>excludeStart("ide", pragmas.excludeIdeData);
  3157. args: [],
  3158. source: "printWelcome\x0a\x09Transcript show: 'Type :q to exit.'; cr.",
  3159. referencedClasses: ["Transcript"],
  3160. //>>excludeEnd("ide");
  3161. messageSends: ["show:", "cr"]
  3162. }),
  3163. $globals.Repl);
  3164. $core.addMethod(
  3165. $core.method({
  3166. selector: "processLine:",
  3167. protocol: "private",
  3168. fn: function (buffer){
  3169. var self=this,$self=this;
  3170. var show;
  3171. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3172. return $core.withContext(function($ctx1) {
  3173. //>>excludeEnd("ctx");
  3174. var $1,$2;
  3175. show=(function(varName,value){
  3176. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3177. return $core.withContext(function($ctx2) {
  3178. //>>excludeEnd("ctx");
  3179. return $self._presentResultNamed_withValue_(varName,value);
  3180. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3181. }, function($ctx2) {$ctx2.fillBlock({varName:varName,value:value},$ctx1,1)});
  3182. //>>excludeEnd("ctx");
  3183. });
  3184. $1=$self._executeCommand_(buffer);
  3185. if(!$core.assert($1)){
  3186. $2=$self._isVariableDefined_(buffer);
  3187. if($core.assert($2)){
  3188. $recv(show)._value_value_(buffer,$recv($self["@session"])._perform_(buffer));
  3189. } else {
  3190. $self._assignNewVariable_do_(buffer,show);
  3191. }
  3192. }
  3193. return self;
  3194. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3195. }, function($ctx1) {$ctx1.fill(self,"processLine:",{buffer:buffer,show:show},$globals.Repl)});
  3196. //>>excludeEnd("ctx");
  3197. },
  3198. //>>excludeStart("ide", pragmas.excludeIdeData);
  3199. args: ["buffer"],
  3200. source: "processLine: buffer\x0a\x09\x22Processes lines entered through the readline interface.\x22\x0a\x09| show |\x0a\x09show := [:varName :value | self presentResultNamed: varName withValue: value].\x0a\x09(self executeCommand: buffer) ifFalse: [\x0a\x09\x09(self isVariableDefined: buffer)\x0a\x09\x09\x09ifTrue: [show value: buffer value: (session perform: buffer)]\x0a\x09\x09\x09ifFalse: [self assignNewVariable: buffer do: show]]",
  3201. referencedClasses: [],
  3202. //>>excludeEnd("ide");
  3203. messageSends: ["presentResultNamed:withValue:", "ifFalse:", "executeCommand:", "ifTrue:ifFalse:", "isVariableDefined:", "value:value:", "perform:", "assignNewVariable:do:"]
  3204. }),
  3205. $globals.Repl);
  3206. $core.addMethod(
  3207. $core.method({
  3208. selector: "prompt",
  3209. protocol: "accessing",
  3210. fn: function (){
  3211. var self=this,$self=this;
  3212. return "amber >> ";
  3213. },
  3214. //>>excludeStart("ide", pragmas.excludeIdeData);
  3215. args: [],
  3216. source: "prompt\x0a\x09^ 'amber >> '",
  3217. referencedClasses: [],
  3218. //>>excludeEnd("ide");
  3219. messageSends: []
  3220. }),
  3221. $globals.Repl);
  3222. $core.addMethod(
  3223. $core.method({
  3224. selector: "setPreviousVariablesFor:from:",
  3225. protocol: "private",
  3226. fn: function (newObject,oldObject){
  3227. var self=this,$self=this;
  3228. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3229. return $core.withContext(function($ctx1) {
  3230. //>>excludeEnd("ctx");
  3231. $recv($self._instanceVariableNamesFor_($recv(oldObject)._class()))._do_((function(each){
  3232. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3233. return $core.withContext(function($ctx2) {
  3234. //>>excludeEnd("ctx");
  3235. return $recv(newObject)._perform_withArguments_($recv(each).__comma(":"),[$recv(oldObject)._perform_(each)]);
  3236. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3237. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  3238. //>>excludeEnd("ctx");
  3239. }));
  3240. return self;
  3241. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3242. }, function($ctx1) {$ctx1.fill(self,"setPreviousVariablesFor:from:",{newObject:newObject,oldObject:oldObject},$globals.Repl)});
  3243. //>>excludeEnd("ctx");
  3244. },
  3245. //>>excludeStart("ide", pragmas.excludeIdeData);
  3246. args: ["newObject", "oldObject"],
  3247. source: "setPreviousVariablesFor: newObject from: oldObject\x0a\x09(self instanceVariableNamesFor: oldObject class) do: [:each |\x0a\x09\x09newObject perform: each, ':' withArguments: {oldObject perform: each}].",
  3248. referencedClasses: [],
  3249. //>>excludeEnd("ide");
  3250. messageSends: ["do:", "instanceVariableNamesFor:", "class", "perform:withArguments:", ",", "perform:"]
  3251. }),
  3252. $globals.Repl);
  3253. $core.addMethod(
  3254. $core.method({
  3255. selector: "setPrompt",
  3256. protocol: "actions",
  3257. fn: function (){
  3258. var self=this,$self=this;
  3259. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3260. return $core.withContext(function($ctx1) {
  3261. //>>excludeEnd("ctx");
  3262. $recv($self["@interface"])._setPrompt_($self._prompt());
  3263. return self;
  3264. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3265. }, function($ctx1) {$ctx1.fill(self,"setPrompt",{},$globals.Repl)});
  3266. //>>excludeEnd("ctx");
  3267. },
  3268. //>>excludeStart("ide", pragmas.excludeIdeData);
  3269. args: [],
  3270. source: "setPrompt\x0a\x09interface setPrompt: self prompt",
  3271. referencedClasses: [],
  3272. //>>excludeEnd("ide");
  3273. messageSends: ["setPrompt:", "prompt"]
  3274. }),
  3275. $globals.Repl);
  3276. $core.addMethod(
  3277. $core.method({
  3278. selector: "setupCommands",
  3279. protocol: "initialization",
  3280. fn: function (){
  3281. var self=this,$self=this;
  3282. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3283. return $core.withContext(function($ctx1) {
  3284. //>>excludeEnd("ctx");
  3285. var $2,$1;
  3286. $2=$recv([":q"]).__minus_gt((function(){
  3287. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3288. return $core.withContext(function($ctx2) {
  3289. //>>excludeEnd("ctx");
  3290. return $recv(process)._exit();
  3291. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3292. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  3293. //>>excludeEnd("ctx");
  3294. }));
  3295. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3296. $ctx1.sendIdx["->"]=1;
  3297. //>>excludeEnd("ctx");
  3298. $1=[$2,$recv([""]).__minus_gt((function(){
  3299. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3300. return $core.withContext(function($ctx2) {
  3301. //>>excludeEnd("ctx");
  3302. return $recv($self["@interface"])._prompt();
  3303. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3304. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  3305. //>>excludeEnd("ctx");
  3306. }))];
  3307. $self["@commands"]=$recv($globals.Dictionary)._from_($1);
  3308. return self;
  3309. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3310. }, function($ctx1) {$ctx1.fill(self,"setupCommands",{},$globals.Repl)});
  3311. //>>excludeEnd("ctx");
  3312. },
  3313. //>>excludeStart("ide", pragmas.excludeIdeData);
  3314. args: [],
  3315. source: "setupCommands\x0a\x09commands := Dictionary from: {\x0a\x09\x09{':q'} -> [process exit].\x0a\x09\x09{''} -> [interface prompt]}",
  3316. referencedClasses: ["Dictionary"],
  3317. //>>excludeEnd("ide");
  3318. messageSends: ["from:", "->", "exit", "prompt"]
  3319. }),
  3320. $globals.Repl);
  3321. $core.addMethod(
  3322. $core.method({
  3323. selector: "setupHotkeys",
  3324. protocol: "initialization",
  3325. fn: function (){
  3326. var self=this,$self=this;
  3327. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3328. return $core.withContext(function($ctx1) {
  3329. //>>excludeEnd("ctx");
  3330. var $receiver;
  3331. $recv($recv(process)._stdin())._on_do_("keypress",(function(s,key){
  3332. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3333. return $core.withContext(function($ctx2) {
  3334. //>>excludeEnd("ctx");
  3335. if(($receiver = key) == null || $receiver.a$nil){
  3336. return key;
  3337. } else {
  3338. return $self._onKeyPress_(key);
  3339. }
  3340. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3341. }, function($ctx2) {$ctx2.fillBlock({s:s,key:key},$ctx1,1)});
  3342. //>>excludeEnd("ctx");
  3343. }));
  3344. return self;
  3345. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3346. }, function($ctx1) {$ctx1.fill(self,"setupHotkeys",{},$globals.Repl)});
  3347. //>>excludeEnd("ctx");
  3348. },
  3349. //>>excludeStart("ide", pragmas.excludeIdeData);
  3350. args: [],
  3351. source: "setupHotkeys\x0a\x09process stdin on: 'keypress' do: [:s :key | key ifNotNil: [self onKeyPress: key]].",
  3352. referencedClasses: [],
  3353. //>>excludeEnd("ide");
  3354. messageSends: ["on:do:", "stdin", "ifNotNil:", "onKeyPress:"]
  3355. }),
  3356. $globals.Repl);
  3357. $core.addMethod(
  3358. $core.method({
  3359. selector: "subclass:withVariable:",
  3360. protocol: "private",
  3361. fn: function (aClass,varName){
  3362. var self=this,$self=this;
  3363. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3364. return $core.withContext(function($ctx1) {
  3365. //>>excludeEnd("ctx");
  3366. return $recv($recv($globals.ClassBuilder)._new())._addSubclassOf_named_instanceVariableNames_package_(aClass,$recv($self._subclassNameFor_(aClass))._asSymbol(),[varName],"Compiler-Core");
  3367. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3368. }, function($ctx1) {$ctx1.fill(self,"subclass:withVariable:",{aClass:aClass,varName:varName},$globals.Repl)});
  3369. //>>excludeEnd("ctx");
  3370. },
  3371. //>>excludeStart("ide", pragmas.excludeIdeData);
  3372. args: ["aClass", "varName"],
  3373. source: "subclass: aClass withVariable: varName\x0a\x09\x22Create subclass with new variable.\x22\x0a\x09^ ClassBuilder new\x0a\x09\x09addSubclassOf: aClass\x0a\x09\x09named: (self subclassNameFor: aClass) asSymbol\x0a\x09\x09instanceVariableNames: {varName}\x0a\x09\x09package: 'Compiler-Core'",
  3374. referencedClasses: ["ClassBuilder"],
  3375. //>>excludeEnd("ide");
  3376. messageSends: ["addSubclassOf:named:instanceVariableNames:package:", "new", "asSymbol", "subclassNameFor:"]
  3377. }),
  3378. $globals.Repl);
  3379. $core.addMethod(
  3380. $core.method({
  3381. selector: "subclassNameFor:",
  3382. protocol: "private",
  3383. fn: function (aClass){
  3384. var self=this,$self=this;
  3385. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3386. return $core.withContext(function($ctx1) {
  3387. //>>excludeEnd("ctx");
  3388. var $2,$1,$6,$5,$4,$3,$7,$receiver;
  3389. $2=$recv(aClass)._name();
  3390. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3391. $ctx1.sendIdx["name"]=1;
  3392. //>>excludeEnd("ctx");
  3393. $1=$recv($2)._matchesOf_("\x5cd+$");
  3394. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3395. $ctx1.sendIdx["matchesOf:"]=1;
  3396. //>>excludeEnd("ctx");
  3397. if(($receiver = $1) == null || $receiver.a$nil){
  3398. return $recv($recv(aClass)._name()).__comma("2");
  3399. } else {
  3400. var counter;
  3401. $6=$recv(aClass)._name();
  3402. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3403. $ctx1.sendIdx["name"]=2;
  3404. //>>excludeEnd("ctx");
  3405. $5=$recv($6)._matchesOf_("\x5cd+$");
  3406. $4=$recv($5)._first();
  3407. $3=$recv($4)._asNumber();
  3408. counter=$recv($3).__plus((1));
  3409. counter;
  3410. $7=$recv(aClass)._name();
  3411. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3412. $ctx1.sendIdx["name"]=3;
  3413. //>>excludeEnd("ctx");
  3414. return $recv($7)._replaceRegexp_with_("\x5cd+$"._asRegexp(),$recv(counter)._asString());
  3415. }
  3416. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3417. }, function($ctx1) {$ctx1.fill(self,"subclassNameFor:",{aClass:aClass},$globals.Repl)});
  3418. //>>excludeEnd("ctx");
  3419. },
  3420. //>>excludeStart("ide", pragmas.excludeIdeData);
  3421. args: ["aClass"],
  3422. source: "subclassNameFor: aClass\x0a\x09^ (aClass name matchesOf: '\x5cd+$')\x0a\x09\x09ifNotNil: [ | counter |\x0a\x09\x09\x09counter := (aClass name matchesOf: '\x5cd+$') first asNumber + 1.\x0a\x09\x09\x09aClass name replaceRegexp: '\x5cd+$' asRegexp with: counter asString]\x0a\x09\x09ifNil: [\x0a\x09\x09\x09aClass name, '2'].",
  3423. referencedClasses: [],
  3424. //>>excludeEnd("ide");
  3425. messageSends: ["ifNotNil:ifNil:", "matchesOf:", "name", "+", "asNumber", "first", "replaceRegexp:with:", "asRegexp", "asString", ","]
  3426. }),
  3427. $globals.Repl);
  3428. $core.addMethod(
  3429. $core.method({
  3430. selector: "main",
  3431. protocol: "initialization",
  3432. fn: function (){
  3433. var self=this,$self=this;
  3434. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3435. return $core.withContext(function($ctx1) {
  3436. //>>excludeEnd("ctx");
  3437. $recv($self._new())._createInterface();
  3438. return self;
  3439. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3440. }, function($ctx1) {$ctx1.fill(self,"main",{},$globals.Repl.a$cls)});
  3441. //>>excludeEnd("ctx");
  3442. },
  3443. //>>excludeStart("ide", pragmas.excludeIdeData);
  3444. args: [],
  3445. source: "main\x0a\x09self new createInterface",
  3446. referencedClasses: [],
  3447. //>>excludeEnd("ide");
  3448. messageSends: ["createInterface", "new"]
  3449. }),
  3450. $globals.Repl.a$cls);
  3451. });