AmberCli.js 164 KB

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