AmberCli.js 165 KB

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