AmberCli.js 166 KB

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