AmberCli.js 160 KB

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