AmberCli.js 167 KB

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