AmberCli.js 133 KB

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