AmberCli.js 165 KB

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