1
0

AmberCli.deploy.js 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995
  1. smalltalk.addPackage('AmberCli');
  2. smalltalk.addClass('AmberCli', smalltalk.Object, [], 'AmberCli');
  3. smalltalk.addMethod(
  4. smalltalk.method({
  5. selector: "commandLineSwitches",
  6. fn: function (){
  7. var self=this;
  8. var switches;
  9. return smalltalk.withContext(function($ctx1) {
  10. var $1;
  11. switches=_st(_st(_st(self)._class())._methodsInProtocol_("commands"))._collect_((function(each){
  12. return smalltalk.withContext(function($ctx2) {
  13. return _st(each)._selector();
  14. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  15. switches=_st(switches)._select_((function(each){
  16. return smalltalk.withContext(function($ctx2) {
  17. return _st(each)._match_("^[^:]*:$");
  18. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  19. switches=_st(switches)._collect_((function(each){
  20. return smalltalk.withContext(function($ctx2) {
  21. return _st(_st(_st(each)._allButLast())._replace_with_("([A-Z])","-$1"))._asLowercase();
  22. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  23. $1=switches;
  24. return $1;
  25. }, function($ctx1) {$ctx1.fill(self,"commandLineSwitches",{switches:switches},smalltalk.AmberCli.klass)})},
  26. messageSends: ["collect:", "selector", "methodsInProtocol:", "class", "select:", "match:", "asLowercase", "replace:with:", "allButLast"]}),
  27. smalltalk.AmberCli.klass);
  28. smalltalk.addMethod(
  29. smalltalk.method({
  30. selector: "handleArguments:",
  31. fn: function (args){
  32. var self=this;
  33. var selector;
  34. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  35. return smalltalk.withContext(function($ctx1) {
  36. selector=_st(self)._selectorForCommandLineSwitch_(_st(args)._first());
  37. _st(args)._remove_(_st(args)._first());
  38. _st(self)._perform_withArguments_(selector,_st($Array())._with_(args));
  39. return self}, function($ctx1) {$ctx1.fill(self,"handleArguments:",{args:args,selector:selector},smalltalk.AmberCli.klass)})},
  40. messageSends: ["selectorForCommandLineSwitch:", "first", "remove:", "perform:withArguments:", "with:"]}),
  41. smalltalk.AmberCli.klass);
  42. smalltalk.addMethod(
  43. smalltalk.method({
  44. selector: "help:",
  45. fn: function (args){
  46. var self=this;
  47. return smalltalk.withContext(function($ctx1) {
  48. _st(console)._log_("Available Commands:");
  49. _st(_st(self)._commandLineSwitches())._do_((function(each){
  50. return smalltalk.withContext(function($ctx2) {
  51. return _st(console)._log_(each);
  52. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  53. return self}, function($ctx1) {$ctx1.fill(self,"help:",{args:args},smalltalk.AmberCli.klass)})},
  54. messageSends: ["log:", "do:", "commandLineSwitches"]}),
  55. smalltalk.AmberCli.klass);
  56. smalltalk.addMethod(
  57. smalltalk.method({
  58. selector: "main",
  59. fn: function (){
  60. var self=this;
  61. var args;
  62. return smalltalk.withContext(function($ctx1) {
  63. var $1,$2;
  64. args=_st(process)._argv();
  65. _st(args)._removeFrom_to_((1),(3));
  66. $1=_st(args)._isEmpty();
  67. if(smalltalk.assert($1)){
  68. _st(self)._help_(nil);
  69. } else {
  70. $2=_st(self)._handleArguments_(args);
  71. return $2;
  72. };
  73. return self}, function($ctx1) {$ctx1.fill(self,"main",{args:args},smalltalk.AmberCli.klass)})},
  74. messageSends: ["argv", "removeFrom:to:", "ifTrue:ifFalse:", "help:", "handleArguments:", "isEmpty"]}),
  75. smalltalk.AmberCli.klass);
  76. smalltalk.addMethod(
  77. smalltalk.method({
  78. selector: "repl:",
  79. fn: function (args){
  80. var self=this;
  81. function $Repl(){return smalltalk.Repl||(typeof Repl=="undefined"?nil:Repl)}
  82. return smalltalk.withContext(function($ctx1) {
  83. var $1;
  84. $1=_st(_st($Repl())._new())._createInterface();
  85. return $1;
  86. }, function($ctx1) {$ctx1.fill(self,"repl:",{args:args},smalltalk.AmberCli.klass)})},
  87. messageSends: ["createInterface", "new"]}),
  88. smalltalk.AmberCli.klass);
  89. smalltalk.addMethod(
  90. smalltalk.method({
  91. selector: "selectorForCommandLineSwitch:",
  92. fn: function (aSwitch){
  93. var self=this;
  94. var command,selector;
  95. return smalltalk.withContext(function($ctx1) {
  96. var $1,$2;
  97. $1=_st(_st(self)._commandLineSwitches())._includes_(aSwitch);
  98. if(smalltalk.assert($1)){
  99. selector=_st(_st(aSwitch)._replace_with_("-[a-z]",(function(each){
  100. return smalltalk.withContext(function($ctx2) {
  101. return _st(_st(each)._second())._asUppercase();
  102. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}))).__comma(":");
  103. selector;
  104. } else {
  105. selector="help:";
  106. selector;
  107. };
  108. $2=selector;
  109. return $2;
  110. }, function($ctx1) {$ctx1.fill(self,"selectorForCommandLineSwitch:",{aSwitch:aSwitch,command:command,selector:selector},smalltalk.AmberCli.klass)})},
  111. messageSends: ["ifTrue:ifFalse:", ",", "replace:with:", "asUppercase", "second", "includes:", "commandLineSwitches"]}),
  112. smalltalk.AmberCli.klass);
  113. smalltalk.addMethod(
  114. smalltalk.method({
  115. selector: "serve:",
  116. fn: function (args){
  117. var self=this;
  118. function $FileServer(){return smalltalk.FileServer||(typeof FileServer=="undefined"?nil:FileServer)}
  119. return smalltalk.withContext(function($ctx1) {
  120. var $1;
  121. $1=_st(_st($FileServer())._createServerWithArguments_(args))._start();
  122. return $1;
  123. }, function($ctx1) {$ctx1.fill(self,"serve:",{args:args},smalltalk.AmberCli.klass)})},
  124. messageSends: ["start", "createServerWithArguments:"]}),
  125. smalltalk.AmberCli.klass);
  126. smalltalk.addClass('FileServer', smalltalk.Object, ['path', 'http', 'fs', 'url', 'host', 'port', 'basePath', 'util', 'username', 'password', 'fallbackPage'], 'AmberCli');
  127. smalltalk.addMethod(
  128. smalltalk.method({
  129. selector: "base64Decode:",
  130. fn: function (aString){
  131. var self=this;
  132. return smalltalk.withContext(function($ctx1) {
  133. return (new Buffer(aString, 'base64').toString());
  134. return self}, function($ctx1) {$ctx1.fill(self,"base64Decode:",{aString:aString},smalltalk.FileServer)})},
  135. messageSends: []}),
  136. smalltalk.FileServer);
  137. smalltalk.addMethod(
  138. smalltalk.method({
  139. selector: "basePath",
  140. fn: function (){
  141. var self=this;
  142. return smalltalk.withContext(function($ctx1) {
  143. var $2,$1;
  144. $2=self["@basePath"];
  145. if(($receiver = $2) == nil || $receiver == undefined){
  146. $1="./";
  147. } else {
  148. $1=$2;
  149. };
  150. return $1;
  151. }, function($ctx1) {$ctx1.fill(self,"basePath",{},smalltalk.FileServer)})},
  152. messageSends: ["ifNil:"]}),
  153. smalltalk.FileServer);
  154. smalltalk.addMethod(
  155. smalltalk.method({
  156. selector: "basePath:",
  157. fn: function (aString){
  158. var self=this;
  159. return smalltalk.withContext(function($ctx1) {
  160. self["@basePath"]=aString;
  161. return self}, function($ctx1) {$ctx1.fill(self,"basePath:",{aString:aString},smalltalk.FileServer)})},
  162. messageSends: []}),
  163. smalltalk.FileServer);
  164. smalltalk.addMethod(
  165. smalltalk.method({
  166. selector: "checkDirectoryLayout",
  167. fn: function (){
  168. var self=this;
  169. return smalltalk.withContext(function($ctx1) {
  170. var $1,$2,$3;
  171. $1=_st(self["@fs"])._existsSync_(_st(_st(self)._basePath()).__comma("index.html"));
  172. if(! smalltalk.assert($1)){
  173. _st(console)._warn_("Warning: project directory does not contain index.html");
  174. };
  175. $2=_st(self["@fs"])._existsSync_(_st(_st(self)._basePath()).__comma("st"));
  176. if(! smalltalk.assert($2)){
  177. _st(console)._warn_("Warning: project directory is missing an \x22st\x22 directory");
  178. };
  179. $3=_st(self["@fs"])._existsSync_(_st(_st(self)._basePath()).__comma("js"));
  180. if(! smalltalk.assert($3)){
  181. _st(console)._warn_("Warning: project directory is missing a \x22js\x22 directory");
  182. };
  183. return self}, function($ctx1) {$ctx1.fill(self,"checkDirectoryLayout",{},smalltalk.FileServer)})},
  184. messageSends: ["ifFalse:", "warn:", "existsSync:", ",", "basePath"]}),
  185. smalltalk.FileServer);
  186. smalltalk.addMethod(
  187. smalltalk.method({
  188. selector: "fallbackPage",
  189. fn: function (){
  190. var self=this;
  191. return smalltalk.withContext(function($ctx1) {
  192. var $1;
  193. $1=self["@fallbackPage"];
  194. return $1;
  195. }, function($ctx1) {$ctx1.fill(self,"fallbackPage",{},smalltalk.FileServer)})},
  196. messageSends: []}),
  197. smalltalk.FileServer);
  198. smalltalk.addMethod(
  199. smalltalk.method({
  200. selector: "fallbackPage:",
  201. fn: function (aString){
  202. var self=this;
  203. return smalltalk.withContext(function($ctx1) {
  204. self["@fallbackPage"]=aString;
  205. return self}, function($ctx1) {$ctx1.fill(self,"fallbackPage:",{aString:aString},smalltalk.FileServer)})},
  206. messageSends: []}),
  207. smalltalk.FileServer);
  208. smalltalk.addMethod(
  209. smalltalk.method({
  210. selector: "handleGETRequest:respondTo:",
  211. fn: function (aRequest,aResponse){
  212. var self=this;
  213. var uri,filename;
  214. return smalltalk.withContext(function($ctx1) {
  215. var $1;
  216. uri=_st(_st(self["@url"])._parse_(_st(aRequest)._url()))._pathname();
  217. filename=_st(self["@path"])._join_with_(_st(self)._basePath(),uri);
  218. _st(self["@fs"])._exists_do_(filename,(function(aBoolean){
  219. return smalltalk.withContext(function($ctx2) {
  220. $1=aBoolean;
  221. if(smalltalk.assert($1)){
  222. return _st(self)._respondFileNamed_to_(filename,aResponse);
  223. } else {
  224. return _st(self)._respondNotFoundTo_(aResponse);
  225. };
  226. }, function($ctx2) {$ctx2.fillBlock({aBoolean:aBoolean},$ctx1)})}));
  227. return self}, function($ctx1) {$ctx1.fill(self,"handleGETRequest:respondTo:",{aRequest:aRequest,aResponse:aResponse,uri:uri,filename:filename},smalltalk.FileServer)})},
  228. messageSends: ["pathname", "parse:", "url", "join:with:", "basePath", "exists:do:", "ifFalse:ifTrue:", "respondNotFoundTo:", "respondFileNamed:to:"]}),
  229. smalltalk.FileServer);
  230. smalltalk.addMethod(
  231. smalltalk.method({
  232. selector: "handleOPTIONSRequest:respondTo:",
  233. fn: function (aRequest,aResponse){
  234. var self=this;
  235. return smalltalk.withContext(function($ctx1) {
  236. _st(aResponse)._writeHead_options_((200),smalltalk.HashedCollection._fromPairs_([_st("Access-Control-Allow-Origin").__minus_gt("*"),_st("Access-Control-Allow-Methods").__minus_gt("GET, PUT, POST, DELETE, OPTIONS"),_st("Access-Control-Allow-Headers").__minus_gt("Content-Type, Accept"),_st("Content-Length").__minus_gt((0)),_st("Access-Control-Max-Age").__minus_gt((10))]));
  237. _st(aResponse)._end();
  238. return self}, function($ctx1) {$ctx1.fill(self,"handleOPTIONSRequest:respondTo:",{aRequest:aRequest,aResponse:aResponse},smalltalk.FileServer)})},
  239. messageSends: ["writeHead:options:", "->", "end"]}),
  240. smalltalk.FileServer);
  241. smalltalk.addMethod(
  242. smalltalk.method({
  243. selector: "handlePUTRequest:respondTo:",
  244. fn: function (aRequest,aResponse){
  245. var self=this;
  246. var file,stream;
  247. return smalltalk.withContext(function($ctx1) {
  248. var $1,$2;
  249. $1=_st(self)._isAuthenticated_(aRequest);
  250. if(! smalltalk.assert($1)){
  251. _st(self)._respondAuthenticationRequiredTo_(aResponse);
  252. return nil;
  253. };
  254. file=_st(".").__comma(_st(aRequest)._url());
  255. stream=_st(self["@fs"])._createWriteStream_(file);
  256. _st(stream)._on_do_("error",(function(error){
  257. return smalltalk.withContext(function($ctx2) {
  258. _st(console)._warn_(_st("Error creating WriteStream for file ").__comma(file));
  259. _st(console)._warn_(" Did you forget to create the necessary js/ or st/ directory in your project?");
  260. _st(console)._warn_(_st(" The exact error is: ").__comma(error));
  261. return _st(self)._respondNotCreatedTo_(aResponse);
  262. }, function($ctx2) {$ctx2.fillBlock({error:error},$ctx1)})}));
  263. _st(stream)._on_do_("close",(function(){
  264. return smalltalk.withContext(function($ctx2) {
  265. return _st(self)._respondCreatedTo_(aResponse);
  266. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  267. _st(aRequest)._setEncoding_("utf8");
  268. _st(aRequest)._on_do_("data",(function(data){
  269. return smalltalk.withContext(function($ctx2) {
  270. return _st(stream)._write_(data);
  271. }, function($ctx2) {$ctx2.fillBlock({data:data},$ctx1)})}));
  272. _st(aRequest)._on_do_("end",(function(){
  273. return smalltalk.withContext(function($ctx2) {
  274. $2=_st(stream)._writable();
  275. if(smalltalk.assert($2)){
  276. return _st(stream)._end();
  277. };
  278. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  279. return self}, function($ctx1) {$ctx1.fill(self,"handlePUTRequest:respondTo:",{aRequest:aRequest,aResponse:aResponse,file:file,stream:stream},smalltalk.FileServer)})},
  280. messageSends: ["ifFalse:", "respondAuthenticationRequiredTo:", "isAuthenticated:", ",", "url", "createWriteStream:", "on:do:", "warn:", "respondNotCreatedTo:", "respondCreatedTo:", "setEncoding:", "write:", "ifTrue:", "end", "writable"]}),
  281. smalltalk.FileServer);
  282. smalltalk.addMethod(
  283. smalltalk.method({
  284. selector: "handleRequest:respondTo:",
  285. fn: function (aRequest,aResponse){
  286. var self=this;
  287. return smalltalk.withContext(function($ctx1) {
  288. var $1,$2,$3;
  289. $1=_st(_st(aRequest)._method()).__eq("PUT");
  290. if(smalltalk.assert($1)){
  291. _st(self)._handlePUTRequest_respondTo_(aRequest,aResponse);
  292. };
  293. $2=_st(_st(aRequest)._method()).__eq("GET");
  294. if(smalltalk.assert($2)){
  295. _st(self)._handleGETRequest_respondTo_(aRequest,aResponse);
  296. };
  297. $3=_st(_st(aRequest)._method()).__eq("OPTIONS");
  298. if(smalltalk.assert($3)){
  299. _st(self)._handleOPTIONSRequest_respondTo_(aRequest,aResponse);
  300. };
  301. return self}, function($ctx1) {$ctx1.fill(self,"handleRequest:respondTo:",{aRequest:aRequest,aResponse:aResponse},smalltalk.FileServer)})},
  302. messageSends: ["ifTrue:", "handlePUTRequest:respondTo:", "=", "method", "handleGETRequest:respondTo:", "handleOPTIONSRequest:respondTo:"]}),
  303. smalltalk.FileServer);
  304. smalltalk.addMethod(
  305. smalltalk.method({
  306. selector: "host",
  307. fn: function (){
  308. var self=this;
  309. return smalltalk.withContext(function($ctx1) {
  310. var $1;
  311. $1=self["@host"];
  312. return $1;
  313. }, function($ctx1) {$ctx1.fill(self,"host",{},smalltalk.FileServer)})},
  314. messageSends: []}),
  315. smalltalk.FileServer);
  316. smalltalk.addMethod(
  317. smalltalk.method({
  318. selector: "host:",
  319. fn: function (hostname){
  320. var self=this;
  321. return smalltalk.withContext(function($ctx1) {
  322. self["@host"]=hostname;
  323. return self}, function($ctx1) {$ctx1.fill(self,"host:",{hostname:hostname},smalltalk.FileServer)})},
  324. messageSends: []}),
  325. smalltalk.FileServer);
  326. smalltalk.addMethod(
  327. smalltalk.method({
  328. selector: "initialize",
  329. fn: function (){
  330. var self=this;
  331. return smalltalk.withContext(function($ctx1) {
  332. smalltalk.Object.fn.prototype._initialize.apply(_st(self), []);
  333. self["@path"]=_st(self)._require_("path");
  334. self["@http"]=_st(self)._require_("http");
  335. self["@fs"]=_st(self)._require_("fs");
  336. self["@util"]=_st(self)._require_("util");
  337. self["@url"]=_st(self)._require_("url");
  338. self["@host"]=_st(_st(self)._class())._defaultHost();
  339. self["@port"]=_st(_st(self)._class())._defaultPort();
  340. self["@username"]=nil;
  341. self["@password"]=nil;
  342. self["@fallbackPage"]=nil;
  343. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.FileServer)})},
  344. messageSends: ["initialize", "require:", "defaultHost", "class", "defaultPort"]}),
  345. smalltalk.FileServer);
  346. smalltalk.addMethod(
  347. smalltalk.method({
  348. selector: "isAuthenticated:",
  349. fn: function (aRequest){
  350. var self=this;
  351. var header,token,auth,parts;
  352. return smalltalk.withContext(function($ctx1) {
  353. var $1,$2,$3,$4,$5;
  354. $1=_st(_st(self["@username"])._isNil())._and_((function(){
  355. return smalltalk.withContext(function($ctx2) {
  356. return _st(self["@password"])._isNil();
  357. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  358. if(smalltalk.assert($1)){
  359. return true;
  360. };
  361. $2=_st(_st(aRequest)._headers())._at_("authorization");
  362. if(($receiver = $2) == nil || $receiver == undefined){
  363. header="";
  364. } else {
  365. header=$2;
  366. };
  367. $3=_st(header)._isEmpty();
  368. if(smalltalk.assert($3)){
  369. return false;
  370. } else {
  371. $4=_st(header)._tokenize_(" ");
  372. if(($receiver = $4) == nil || $receiver == undefined){
  373. token="";
  374. } else {
  375. token=$4;
  376. };
  377. token;
  378. auth=_st(self)._base64Decode_(_st(token)._at_((2)));
  379. auth;
  380. parts=_st(auth)._tokenize_(":");
  381. parts;
  382. $5=_st(_st(self["@username"]).__eq(_st(parts)._at_((1))))._and_((function(){
  383. return smalltalk.withContext(function($ctx2) {
  384. return _st(self["@password"]).__eq(_st(parts)._at_((2)));
  385. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  386. if(smalltalk.assert($5)){
  387. return true;
  388. } else {
  389. return false;
  390. };
  391. };
  392. return self}, function($ctx1) {$ctx1.fill(self,"isAuthenticated:",{aRequest:aRequest,header:header,token:token,auth:auth,parts:parts},smalltalk.FileServer)})},
  393. messageSends: ["ifTrue:", "and:", "isNil", "ifNil:", "at:", "headers", "ifTrue:ifFalse:", "tokenize:", "base64Decode:", "=", "isEmpty"]}),
  394. smalltalk.FileServer);
  395. smalltalk.addMethod(
  396. smalltalk.method({
  397. selector: "password:",
  398. fn: function (aPassword){
  399. var self=this;
  400. return smalltalk.withContext(function($ctx1) {
  401. self["@password"]=aPassword;
  402. return self}, function($ctx1) {$ctx1.fill(self,"password:",{aPassword:aPassword},smalltalk.FileServer)})},
  403. messageSends: []}),
  404. smalltalk.FileServer);
  405. smalltalk.addMethod(
  406. smalltalk.method({
  407. selector: "port",
  408. fn: function (){
  409. var self=this;
  410. return smalltalk.withContext(function($ctx1) {
  411. var $1;
  412. $1=self["@port"];
  413. return $1;
  414. }, function($ctx1) {$ctx1.fill(self,"port",{},smalltalk.FileServer)})},
  415. messageSends: []}),
  416. smalltalk.FileServer);
  417. smalltalk.addMethod(
  418. smalltalk.method({
  419. selector: "port:",
  420. fn: function (aNumber){
  421. var self=this;
  422. return smalltalk.withContext(function($ctx1) {
  423. self["@port"]=aNumber;
  424. return self}, function($ctx1) {$ctx1.fill(self,"port:",{aNumber:aNumber},smalltalk.FileServer)})},
  425. messageSends: []}),
  426. smalltalk.FileServer);
  427. smalltalk.addMethod(
  428. smalltalk.method({
  429. selector: "require:",
  430. fn: function (aModuleString){
  431. var self=this;
  432. return smalltalk.withContext(function($ctx1) {
  433. var $1;
  434. $1=_st(require)._value_(aModuleString);
  435. return $1;
  436. }, function($ctx1) {$ctx1.fill(self,"require:",{aModuleString:aModuleString},smalltalk.FileServer)})},
  437. messageSends: ["value:"]}),
  438. smalltalk.FileServer);
  439. smalltalk.addMethod(
  440. smalltalk.method({
  441. selector: "respondAuthenticationRequiredTo:",
  442. fn: function (aResponse){
  443. var self=this;
  444. return smalltalk.withContext(function($ctx1) {
  445. var $1,$2;
  446. $1=aResponse;
  447. _st($1)._writeHead_options_((401),smalltalk.HashedCollection._fromPairs_([_st("WWW-Authenticate").__minus_gt("Basic realm=\x22Secured Developer Area\x22")]));
  448. _st($1)._write_("<html><body>Authentication needed</body></html>");
  449. $2=_st($1)._end();
  450. return self}, function($ctx1) {$ctx1.fill(self,"respondAuthenticationRequiredTo:",{aResponse:aResponse},smalltalk.FileServer)})},
  451. messageSends: ["writeHead:options:", "->", "write:", "end"]}),
  452. smalltalk.FileServer);
  453. smalltalk.addMethod(
  454. smalltalk.method({
  455. selector: "respondCreatedTo:",
  456. fn: function (aResponse){
  457. var self=this;
  458. return smalltalk.withContext(function($ctx1) {
  459. var $1,$2;
  460. $1=aResponse;
  461. _st($1)._writeHead_options_((201),smalltalk.HashedCollection._fromPairs_([_st("Content-Type").__minus_gt("text/plain"),_st("Access-Control-Allow-Origin").__minus_gt("*")]));
  462. $2=_st($1)._end();
  463. return self}, function($ctx1) {$ctx1.fill(self,"respondCreatedTo:",{aResponse:aResponse},smalltalk.FileServer)})},
  464. messageSends: ["writeHead:options:", "->", "end"]}),
  465. smalltalk.FileServer);
  466. smalltalk.addMethod(
  467. smalltalk.method({
  468. selector: "respondFileNamed:to:",
  469. fn: function (aFilename,aResponse){
  470. var self=this;
  471. var type,filename;
  472. return smalltalk.withContext(function($ctx1) {
  473. var $1,$2,$3,$4,$5;
  474. filename=aFilename;
  475. $1=_st(_st(self["@fs"])._statSync_(aFilename))._isDirectory();
  476. if(smalltalk.assert($1)){
  477. filename=_st(filename).__comma("index.html");
  478. filename;
  479. };
  480. _st(self["@fs"])._readFile_do_(filename,(function(ex,file){
  481. return smalltalk.withContext(function($ctx2) {
  482. $2=_st(ex)._notNil();
  483. if(smalltalk.assert($2)){
  484. _st(console)._log_(_st(filename).__comma(" does not exist"));
  485. return _st(self)._respondInternalErrorTo_(aResponse);
  486. } else {
  487. type=_st(_st(self)._class())._mimeTypeFor_(filename);
  488. type;
  489. $3=_st(type).__eq("application/javascript");
  490. if(smalltalk.assert($3)){
  491. type=_st(type).__comma(";charset=utf-8");
  492. type;
  493. };
  494. $4=aResponse;
  495. _st($4)._writeHead_options_((200),smalltalk.HashedCollection._fromPairs_([_st("Content-Type").__minus_gt(type)]));
  496. _st($4)._write_encoding_(file,"binary");
  497. $5=_st($4)._end();
  498. return $5;
  499. };
  500. }, function($ctx2) {$ctx2.fillBlock({ex:ex,file:file},$ctx1)})}));
  501. return self}, function($ctx1) {$ctx1.fill(self,"respondFileNamed:to:",{aFilename:aFilename,aResponse:aResponse,type:type,filename:filename},smalltalk.FileServer)})},
  502. messageSends: ["ifTrue:", ",", "isDirectory", "statSync:", "readFile:do:", "ifTrue:ifFalse:", "log:", "respondInternalErrorTo:", "mimeTypeFor:", "class", "=", "writeHead:options:", "->", "write:encoding:", "end", "notNil"]}),
  503. smalltalk.FileServer);
  504. smalltalk.addMethod(
  505. smalltalk.method({
  506. selector: "respondInternalErrorTo:",
  507. fn: function (aResponse){
  508. var self=this;
  509. return smalltalk.withContext(function($ctx1) {
  510. var $1,$2;
  511. $1=aResponse;
  512. _st($1)._writeHead_options_((500),smalltalk.HashedCollection._fromPairs_([_st("Content-Type").__minus_gt("text/plain")]));
  513. _st($1)._write_("500 Internal server error");
  514. $2=_st($1)._end();
  515. return self}, function($ctx1) {$ctx1.fill(self,"respondInternalErrorTo:",{aResponse:aResponse},smalltalk.FileServer)})},
  516. messageSends: ["writeHead:options:", "->", "write:", "end"]}),
  517. smalltalk.FileServer);
  518. smalltalk.addMethod(
  519. smalltalk.method({
  520. selector: "respondNotCreatedTo:",
  521. fn: function (aResponse){
  522. var self=this;
  523. return smalltalk.withContext(function($ctx1) {
  524. var $1,$2;
  525. $1=aResponse;
  526. _st($1)._writeHead_options_((400),smalltalk.HashedCollection._fromPairs_([_st("Content-Type").__minus_gt("text/plain")]));
  527. _st($1)._write_("File could not be created. Did you forget to create the st/js directories on the server?");
  528. $2=_st($1)._end();
  529. return self}, function($ctx1) {$ctx1.fill(self,"respondNotCreatedTo:",{aResponse:aResponse},smalltalk.FileServer)})},
  530. messageSends: ["writeHead:options:", "->", "write:", "end"]}),
  531. smalltalk.FileServer);
  532. smalltalk.addMethod(
  533. smalltalk.method({
  534. selector: "respondNotFoundTo:",
  535. fn: function (aResponse){
  536. var self=this;
  537. return smalltalk.withContext(function($ctx1) {
  538. var $1,$2,$3,$4;
  539. $1=_st(_st(self)._fallbackPage())._isNil();
  540. if(! smalltalk.assert($1)){
  541. $2=_st(self)._respondFileNamed_to_(_st(self)._fallbackPage(),aResponse);
  542. return $2;
  543. };
  544. $3=aResponse;
  545. _st($3)._writeHead_options_((404),smalltalk.HashedCollection._fromPairs_([_st("Content-Type").__minus_gt("text/plain")]));
  546. _st($3)._write_("404 Not found");
  547. $4=_st($3)._end();
  548. return self}, function($ctx1) {$ctx1.fill(self,"respondNotFoundTo:",{aResponse:aResponse},smalltalk.FileServer)})},
  549. messageSends: ["ifFalse:", "respondFileNamed:to:", "fallbackPage", "isNil", "writeHead:options:", "->", "write:", "end"]}),
  550. smalltalk.FileServer);
  551. smalltalk.addMethod(
  552. smalltalk.method({
  553. selector: "respondOKTo:",
  554. fn: function (aResponse){
  555. var self=this;
  556. return smalltalk.withContext(function($ctx1) {
  557. var $1,$2;
  558. $1=aResponse;
  559. _st($1)._writeHead_options_((200),smalltalk.HashedCollection._fromPairs_([_st("Content-Type").__minus_gt("text/plain"),_st("Access-Control-Allow-Origin").__minus_gt("*")]));
  560. $2=_st($1)._end();
  561. return self}, function($ctx1) {$ctx1.fill(self,"respondOKTo:",{aResponse:aResponse},smalltalk.FileServer)})},
  562. messageSends: ["writeHead:options:", "->", "end"]}),
  563. smalltalk.FileServer);
  564. smalltalk.addMethod(
  565. smalltalk.method({
  566. selector: "start",
  567. fn: function (){
  568. var self=this;
  569. return smalltalk.withContext(function($ctx1) {
  570. var $1,$2;
  571. _st(self)._checkDirectoryLayout();
  572. $1=_st(self["@http"])._createServer_((function(request,response){
  573. return smalltalk.withContext(function($ctx2) {
  574. return _st(self)._handleRequest_respondTo_(request,response);
  575. }, function($ctx2) {$ctx2.fillBlock({request:request,response:response},$ctx1)})}));
  576. _st($1)._on_do_("error",(function(error){
  577. return smalltalk.withContext(function($ctx2) {
  578. return _st(console)._log_(_st("Error starting server: ").__comma(error));
  579. }, function($ctx2) {$ctx2.fillBlock({error:error},$ctx1)})}));
  580. _st($1)._on_do_("listening",(function(){
  581. return smalltalk.withContext(function($ctx2) {
  582. return _st(console)._log_(_st(_st(_st("Starting file server on ").__comma(_st(self)._host())).__comma(":")).__comma(_st(_st(self)._port())._asString()));
  583. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  584. $2=_st($1)._listen_host_(_st(self)._port(),_st(self)._host());
  585. return self}, function($ctx1) {$ctx1.fill(self,"start",{},smalltalk.FileServer)})},
  586. messageSends: ["checkDirectoryLayout", "on:do:", "log:", ",", "createServer:", "handleRequest:respondTo:", "asString", "port", "host", "listen:host:"]}),
  587. smalltalk.FileServer);
  588. smalltalk.addMethod(
  589. smalltalk.method({
  590. selector: "startOn:",
  591. fn: function (aPort){
  592. var self=this;
  593. return smalltalk.withContext(function($ctx1) {
  594. _st(self)._port_(aPort);
  595. _st(self)._start();
  596. return self}, function($ctx1) {$ctx1.fill(self,"startOn:",{aPort:aPort},smalltalk.FileServer)})},
  597. messageSends: ["port:", "start"]}),
  598. smalltalk.FileServer);
  599. smalltalk.addMethod(
  600. smalltalk.method({
  601. selector: "username:",
  602. fn: function (aUsername){
  603. var self=this;
  604. return smalltalk.withContext(function($ctx1) {
  605. self["@username"]=aUsername;
  606. return self}, function($ctx1) {$ctx1.fill(self,"username:",{aUsername:aUsername},smalltalk.FileServer)})},
  607. messageSends: []}),
  608. smalltalk.FileServer);
  609. smalltalk.addMethod(
  610. smalltalk.method({
  611. selector: "writeData:toFileNamed:",
  612. fn: function (data,aFilename){
  613. var self=this;
  614. return smalltalk.withContext(function($ctx1) {
  615. _st(console)._log_(aFilename);
  616. return self}, function($ctx1) {$ctx1.fill(self,"writeData:toFileNamed:",{data:data,aFilename:aFilename},smalltalk.FileServer)})},
  617. messageSends: ["log:"]}),
  618. smalltalk.FileServer);
  619. smalltalk.FileServer.klass.iVarNames = ['mimeTypes'];
  620. smalltalk.addMethod(
  621. smalltalk.method({
  622. selector: "commandLineSwitches",
  623. fn: function (){
  624. var self=this;
  625. var switches;
  626. return smalltalk.withContext(function($ctx1) {
  627. var $1;
  628. switches=_st(_st(self)._methodsInProtocol_("accessing"))._collect_((function(each){
  629. return smalltalk.withContext(function($ctx2) {
  630. return _st(each)._selector();
  631. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  632. switches=_st(switches)._select_((function(each){
  633. return smalltalk.withContext(function($ctx2) {
  634. return _st(each)._match_("^[^:]*:$");
  635. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  636. switches=_st(switches)._collect_((function(each){
  637. return smalltalk.withContext(function($ctx2) {
  638. return _st(_st(_st(_st(each)._allButLast())._replace_with_("([A-Z])","-$1"))._asLowercase())._replace_with_("^([a-z])","--$1");
  639. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  640. $1=switches;
  641. return $1;
  642. }, function($ctx1) {$ctx1.fill(self,"commandLineSwitches",{switches:switches},smalltalk.FileServer.klass)})},
  643. messageSends: ["collect:", "selector", "methodsInProtocol:", "select:", "match:", "replace:with:", "asLowercase", "allButLast"]}),
  644. smalltalk.FileServer.klass);
  645. smalltalk.addMethod(
  646. smalltalk.method({
  647. selector: "createServerWithArguments:",
  648. fn: function (options){
  649. var self=this;
  650. var server,popFront,front,optionName,optionValue,switches;
  651. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  652. return smalltalk.withContext(function($ctx1) {
  653. var $1,$2,$3,$4,$5;
  654. var $early={};
  655. try {
  656. switches=_st(self)._commandLineSwitches();
  657. server=_st(self)._new();
  658. _st(options)._ifEmpty_((function(){
  659. return smalltalk.withContext(function($ctx2) {
  660. $1=server;
  661. throw $early=[$1];
  662. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  663. $2=_st(_st(options)._size())._even();
  664. if(! smalltalk.assert($2)){
  665. _st(console)._log_("Using default parameters.");
  666. _st(console)._log_(_st("Wrong commandline options or not enough arguments for: ").__comma(options));
  667. _st(console)._log_(_st("Use any of the following ones: ").__comma(switches));
  668. $3=server;
  669. return $3;
  670. };
  671. popFront=(function(args){
  672. return smalltalk.withContext(function($ctx2) {
  673. front=_st(args)._first();
  674. front;
  675. _st(args)._remove_(front);
  676. return front;
  677. }, function($ctx2) {$ctx2.fillBlock({args:args},$ctx1)})});
  678. _st((function(){
  679. return smalltalk.withContext(function($ctx2) {
  680. return _st(options)._notEmpty();
  681. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileTrue_((function(){
  682. return smalltalk.withContext(function($ctx2) {
  683. optionName=_st(popFront)._value_(options);
  684. optionName;
  685. optionValue=_st(popFront)._value_(options);
  686. optionValue;
  687. $4=_st(switches)._includes_(optionName);
  688. if(smalltalk.assert($4)){
  689. optionName=_st(self)._selectorForCommandLineSwitch_(optionName);
  690. optionName;
  691. return _st(server)._perform_withArguments_(optionName,_st($Array())._with_(optionValue));
  692. } else {
  693. _st(console)._log_(_st(optionName).__comma(" is not a valid commandline option"));
  694. return _st(console)._log_(_st("Use any of the following ones: ").__comma(switches));
  695. };
  696. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  697. $5=server;
  698. return $5;
  699. }
  700. catch(e) {if(e===$early)return e[0]; throw e}
  701. }, function($ctx1) {$ctx1.fill(self,"createServerWithArguments:",{options:options,server:server,popFront:popFront,front:front,optionName:optionName,optionValue:optionValue,switches:switches},smalltalk.FileServer.klass)})},
  702. messageSends: ["commandLineSwitches", "new", "ifEmpty:", "ifFalse:", "log:", ",", "even", "size", "first", "remove:", "whileTrue:", "value:", "ifTrue:ifFalse:", "selectorForCommandLineSwitch:", "perform:withArguments:", "with:", "includes:", "notEmpty"]}),
  703. smalltalk.FileServer.klass);
  704. smalltalk.addMethod(
  705. smalltalk.method({
  706. selector: "defaultHost",
  707. fn: function (){
  708. var self=this;
  709. return smalltalk.withContext(function($ctx1) {
  710. return "127.0.0.1";
  711. }, function($ctx1) {$ctx1.fill(self,"defaultHost",{},smalltalk.FileServer.klass)})},
  712. messageSends: []}),
  713. smalltalk.FileServer.klass);
  714. smalltalk.addMethod(
  715. smalltalk.method({
  716. selector: "defaultMimeTypes",
  717. fn: function (){
  718. var self=this;
  719. return smalltalk.withContext(function($ctx1) {
  720. var $1;
  721. $1=smalltalk.HashedCollection._fromPairs_([_st("%").__minus_gt("application/x-trash"),_st("323").__minus_gt("text/h323"),_st("abw").__minus_gt("application/x-abiword"),_st("ai").__minus_gt("application/postscript"),_st("aif").__minus_gt("audio/x-aiff"),_st("aifc").__minus_gt("audio/x-aiff"),_st("aiff").__minus_gt("audio/x-aiff"),_st("alc").__minus_gt("chemical/x-alchemy"),_st("art").__minus_gt("image/x-jg"),_st("asc").__minus_gt("text/plain"),_st("asf").__minus_gt("video/x-ms-asf"),_st("asn").__minus_gt("chemical/x-ncbi-asn1-spec"),_st("aso").__minus_gt("chemical/x-ncbi-asn1-binary"),_st("asx").__minus_gt("video/x-ms-asf"),_st("au").__minus_gt("audio/basic"),_st("avi").__minus_gt("video/x-msvideo"),_st("b").__minus_gt("chemical/x-molconn-Z"),_st("bak").__minus_gt("application/x-trash"),_st("bat").__minus_gt("application/x-msdos-program"),_st("bcpio").__minus_gt("application/x-bcpio"),_st("bib").__minus_gt("text/x-bibtex"),_st("bin").__minus_gt("application/octet-stream"),_st("bmp").__minus_gt("image/x-ms-bmp"),_st("book").__minus_gt("application/x-maker"),_st("bsd").__minus_gt("chemical/x-crossfire"),_st("c").__minus_gt("text/x-csrc"),_st("c++").__minus_gt("text/x-c++src"),_st("c3d").__minus_gt("chemical/x-chem3d"),_st("cac").__minus_gt("chemical/x-cache"),_st("cache").__minus_gt("chemical/x-cache"),_st("cascii").__minus_gt("chemical/x-cactvs-binary"),_st("cat").__minus_gt("application/vnd.ms-pki.seccat"),_st("cbin").__minus_gt("chemical/x-cactvs-binary"),_st("cc").__minus_gt("text/x-c++src"),_st("cdf").__minus_gt("application/x-cdf"),_st("cdr").__minus_gt("image/x-coreldraw"),_st("cdt").__minus_gt("image/x-coreldrawtemplate"),_st("cdx").__minus_gt("chemical/x-cdx"),_st("cdy").__minus_gt("application/vnd.cinderella"),_st("cef").__minus_gt("chemical/x-cxf"),_st("cer").__minus_gt("chemical/x-cerius"),_st("chm").__minus_gt("chemical/x-chemdraw"),_st("chrt").__minus_gt("application/x-kchart"),_st("cif").__minus_gt("chemical/x-cif"),_st("class").__minus_gt("application/java-vm"),_st("cls").__minus_gt("text/x-tex"),_st("cmdf").__minus_gt("chemical/x-cmdf"),_st("cml").__minus_gt("chemical/x-cml"),_st("cod").__minus_gt("application/vnd.rim.cod"),_st("com").__minus_gt("application/x-msdos-program"),_st("cpa").__minus_gt("chemical/x-compass"),_st("cpio").__minus_gt("application/x-cpio"),_st("cpp").__minus_gt("text/x-c++src"),_st("cpt").__minus_gt("image/x-corelphotopaint"),_st("crl").__minus_gt("application/x-pkcs7-crl"),_st("crt").__minus_gt("application/x-x509-ca-cert"),_st("csf").__minus_gt("chemical/x-cache-csf"),_st("csh").__minus_gt("text/x-csh"),_st("csm").__minus_gt("chemical/x-csml"),_st("csml").__minus_gt("chemical/x-csml"),_st("css").__minus_gt("text/css"),_st("csv").__minus_gt("text/comma-separated-values"),_st("ctab").__minus_gt("chemical/x-cactvs-binary"),_st("ctx").__minus_gt("chemical/x-ctx"),_st("cu").__minus_gt("application/cu-seeme"),_st("cub").__minus_gt("chemical/x-gaussian-cube"),_st("cxf").__minus_gt("chemical/x-cxf"),_st("cxx").__minus_gt("text/x-c++src"),_st("dat").__minus_gt("chemical/x-mopac-input"),_st("dcr").__minus_gt("application/x-director"),_st("deb").__minus_gt("application/x-debian-package"),_st("dif").__minus_gt("video/dv"),_st("diff").__minus_gt("text/plain"),_st("dir").__minus_gt("application/x-director"),_st("djv").__minus_gt("image/vnd.djvu"),_st("djvu").__minus_gt("image/vnd.djvu"),_st("dl").__minus_gt("video/dl"),_st("dll").__minus_gt("application/x-msdos-program"),_st("dmg").__minus_gt("application/x-apple-diskimage"),_st("dms").__minus_gt("application/x-dms"),_st("doc").__minus_gt("application/msword"),_st("dot").__minus_gt("application/msword"),_st("dv").__minus_gt("video/dv"),_st("dvi").__minus_gt("application/x-dvi"),_st("dx").__minus_gt("chemical/x-jcamp-dx"),_st("dxr").__minus_gt("application/x-director"),_st("emb").__minus_gt("chemical/x-embl-dl-nucleotide"),_st("embl").__minus_gt("chemical/x-embl-dl-nucleotide"),_st("ent").__minus_gt("chemical/x-pdb"),_st("eps").__minus_gt("application/postscript"),_st("etx").__minus_gt("text/x-setext"),_st("exe").__minus_gt("application/x-msdos-program"),_st("ez").__minus_gt("application/andrew-inset"),_st("fb").__minus_gt("application/x-maker"),_st("fbdoc").__minus_gt("application/x-maker"),_st("fch").__minus_gt("chemical/x-gaussian-checkpoint"),_st("fchk").__minus_gt("chemical/x-gaussian-checkpoint"),_st("fig").__minus_gt("application/x-xfig"),_st("flac").__minus_gt("application/x-flac"),_st("fli").__minus_gt("video/fli"),_st("fm").__minus_gt("application/x-maker"),_st("frame").__minus_gt("application/x-maker"),_st("frm").__minus_gt("application/x-maker"),_st("gal").__minus_gt("chemical/x-gaussian-log"),_st("gam").__minus_gt("chemical/x-gamess-input"),_st("gamin").__minus_gt("chemical/x-gamess-input"),_st("gau").__minus_gt("chemical/x-gaussian-input"),_st("gcd").__minus_gt("text/x-pcs-gcd"),_st("gcf").__minus_gt("application/x-graphing-calculator"),_st("gcg").__minus_gt("chemical/x-gcg8-sequence"),_st("gen").__minus_gt("chemical/x-genbank"),_st("gf").__minus_gt("application/x-tex-gf"),_st("gif").__minus_gt("image/gif"),_st("gjc").__minus_gt("chemical/x-gaussian-input"),_st("gjf").__minus_gt("chemical/x-gaussian-input"),_st("gl").__minus_gt("video/gl"),_st("gnumeric").__minus_gt("application/x-gnumeric"),_st("gpt").__minus_gt("chemical/x-mopac-graph"),_st("gsf").__minus_gt("application/x-font"),_st("gsm").__minus_gt("audio/x-gsm"),_st("gtar").__minus_gt("application/x-gtar"),_st("h").__minus_gt("text/x-chdr"),_st("h++").__minus_gt("text/x-c++hdr"),_st("hdf").__minus_gt("application/x-hdf"),_st("hh").__minus_gt("text/x-c++hdr"),_st("hin").__minus_gt("chemical/x-hin"),_st("hpp").__minus_gt("text/x-c++hdr"),_st("hqx").__minus_gt("application/mac-binhex40"),_st("hs").__minus_gt("text/x-haskell"),_st("hta").__minus_gt("application/hta"),_st("htc").__minus_gt("text/x-component"),_st("htm").__minus_gt("text/html"),_st("html").__minus_gt("text/html"),_st("hxx").__minus_gt("text/x-c++hdr"),_st("ica").__minus_gt("application/x-ica"),_st("ice").__minus_gt("x-conference/x-cooltalk"),_st("ico").__minus_gt("image/x-icon"),_st("ics").__minus_gt("text/calendar"),_st("icz").__minus_gt("text/calendar"),_st("ief").__minus_gt("image/ief"),_st("iges").__minus_gt("model/iges"),_st("igs").__minus_gt("model/iges"),_st("iii").__minus_gt("application/x-iphone"),_st("inp").__minus_gt("chemical/x-gamess-input"),_st("ins").__minus_gt("application/x-internet-signup"),_st("iso").__minus_gt("application/x-iso9660-image"),_st("isp").__minus_gt("application/x-internet-signup"),_st("ist").__minus_gt("chemical/x-isostar"),_st("istr").__minus_gt("chemical/x-isostar"),_st("jad").__minus_gt("text/vnd.sun.j2me.app-descriptor"),_st("jar").__minus_gt("application/java-archive"),_st("java").__minus_gt("text/x-java"),_st("jdx").__minus_gt("chemical/x-jcamp-dx"),_st("jmz").__minus_gt("application/x-jmol"),_st("jng").__minus_gt("image/x-jng"),_st("jnlp").__minus_gt("application/x-java-jnlp-file"),_st("jpe").__minus_gt("image/jpeg"),_st("jpeg").__minus_gt("image/jpeg"),_st("jpg").__minus_gt("image/jpeg"),_st("js").__minus_gt("application/javascript"),_st("kar").__minus_gt("audio/midi"),_st("key").__minus_gt("application/pgp-keys"),_st("kil").__minus_gt("application/x-killustrator"),_st("kin").__minus_gt("chemical/x-kinemage"),_st("kpr").__minus_gt("application/x-kpresenter"),_st("kpt").__minus_gt("application/x-kpresenter"),_st("ksp").__minus_gt("application/x-kspread"),_st("kwd").__minus_gt("application/x-kword"),_st("kwt").__minus_gt("application/x-kword"),_st("latex").__minus_gt("application/x-latex"),_st("lha").__minus_gt("application/x-lha"),_st("lhs").__minus_gt("text/x-literate-haskell"),_st("lsf").__minus_gt("video/x-la-asf"),_st("lsx").__minus_gt("video/x-la-asf"),_st("ltx").__minus_gt("text/x-tex"),_st("lzh").__minus_gt("application/x-lzh"),_st("lzx").__minus_gt("application/x-lzx"),_st("m3u").__minus_gt("audio/x-mpegurl"),_st("m4a").__minus_gt("audio/mpeg"),_st("maker").__minus_gt("application/x-maker"),_st("man").__minus_gt("application/x-troff-man"),_st("mcif").__minus_gt("chemical/x-mmcif"),_st("mcm").__minus_gt("chemical/x-macmolecule"),_st("mdb").__minus_gt("application/msaccess"),_st("me").__minus_gt("application/x-troff-me"),_st("mesh").__minus_gt("model/mesh"),_st("mid").__minus_gt("audio/midi"),_st("midi").__minus_gt("audio/midi"),_st("mif").__minus_gt("application/x-mif"),_st("mm").__minus_gt("application/x-freemind"),_st("mmd").__minus_gt("chemical/x-macromodel-input"),_st("mmf").__minus_gt("application/vnd.smaf"),_st("mml").__minus_gt("text/mathml"),_st("mmod").__minus_gt("chemical/x-macromodel-input"),_st("mng").__minus_gt("video/x-mng"),_st("moc").__minus_gt("text/x-moc"),_st("mol").__minus_gt("chemical/x-mdl-molfile"),_st("mol2").__minus_gt("chemical/x-mol2"),_st("moo").__minus_gt("chemical/x-mopac-out"),_st("mop").__minus_gt("chemical/x-mopac-input"),_st("mopcrt").__minus_gt("chemical/x-mopac-input"),_st("mov").__minus_gt("video/quicktime"),_st("movie").__minus_gt("video/x-sgi-movie"),_st("mp2").__minus_gt("audio/mpeg"),_st("mp3").__minus_gt("audio/mpeg"),_st("mp4").__minus_gt("video/mp4"),_st("mpc").__minus_gt("chemical/x-mopac-input"),_st("mpe").__minus_gt("video/mpeg"),_st("mpeg").__minus_gt("video/mpeg"),_st("mpega").__minus_gt("audio/mpeg"),_st("mpg").__minus_gt("video/mpeg"),_st("mpga").__minus_gt("audio/mpeg"),_st("ms").__minus_gt("application/x-troff-ms"),_st("msh").__minus_gt("model/mesh"),_st("msi").__minus_gt("application/x-msi"),_st("mvb").__minus_gt("chemical/x-mopac-vib"),_st("mxu").__minus_gt("video/vnd.mpegurl"),_st("nb").__minus_gt("application/mathematica"),_st("nc").__minus_gt("application/x-netcdf"),_st("nwc").__minus_gt("application/x-nwc"),_st("o").__minus_gt("application/x-object"),_st("oda").__minus_gt("application/oda"),_st("odb").__minus_gt("application/vnd.oasis.opendocument.database"),_st("odc").__minus_gt("application/vnd.oasis.opendocument.chart"),_st("odf").__minus_gt("application/vnd.oasis.opendocument.formula"),_st("odg").__minus_gt("application/vnd.oasis.opendocument.graphics"),_st("odi").__minus_gt("application/vnd.oasis.opendocument.image"),_st("odm").__minus_gt("application/vnd.oasis.opendocument.text-master"),_st("odp").__minus_gt("application/vnd.oasis.opendocument.presentation"),_st("ods").__minus_gt("application/vnd.oasis.opendocument.spreadsheet"),_st("odt").__minus_gt("application/vnd.oasis.opendocument.text"),_st("ogg").__minus_gt("application/ogg"),_st("old").__minus_gt("application/x-trash"),_st("oth").__minus_gt("application/vnd.oasis.opendocument.text-web"),_st("oza").__minus_gt("application/x-oz-application"),_st("p").__minus_gt("text/x-pascal"),_st("p7r").__minus_gt("application/x-pkcs7-certreqresp"),_st("pac").__minus_gt("application/x-ns-proxy-autoconfig"),_st("pas").__minus_gt("text/x-pascal"),_st("pat").__minus_gt("image/x-coreldrawpattern"),_st("pbm").__minus_gt("image/x-portable-bitmap"),_st("pcf").__minus_gt("application/x-font"),_st("pcf.Z").__minus_gt("application/x-font"),_st("pcx").__minus_gt("image/pcx"),_st("pdb").__minus_gt("chemical/x-pdb"),_st("pdf").__minus_gt("application/pdf"),_st("pfa").__minus_gt("application/x-font"),_st("pfb").__minus_gt("application/x-font"),_st("pgm").__minus_gt("image/x-portable-graymap"),_st("pgn").__minus_gt("application/x-chess-pgn"),_st("pgp").__minus_gt("application/pgp-signature"),_st("pk").__minus_gt("application/x-tex-pk"),_st("pl").__minus_gt("text/x-perl"),_st("pls").__minus_gt("audio/x-scpls"),_st("pm").__minus_gt("text/x-perl"),_st("png").__minus_gt("image/png"),_st("pnm").__minus_gt("image/x-portable-anymap"),_st("pot").__minus_gt("text/plain"),_st("ppm").__minus_gt("image/x-portable-pixmap"),_st("pps").__minus_gt("application/vnd.ms-powerpoint"),_st("ppt").__minus_gt("application/vnd.ms-powerpoint"),_st("prf").__minus_gt("application/pics-rules"),_st("prt").__minus_gt("chemical/x-ncbi-asn1-ascii"),_st("ps").__minus_gt("application/postscript"),_st("psd").__minus_gt("image/x-photoshop"),_st("psp").__minus_gt("text/x-psp"),_st("py").__minus_gt("text/x-python"),_st("pyc").__minus_gt("application/x-python-code"),_st("pyo").__minus_gt("application/x-python-code"),_st("qt").__minus_gt("video/quicktime"),_st("qtl").__minus_gt("application/x-quicktimeplayer"),_st("ra").__minus_gt("audio/x-realaudio"),_st("ram").__minus_gt("audio/x-pn-realaudio"),_st("rar").__minus_gt("application/rar"),_st("ras").__minus_gt("image/x-cmu-raster"),_st("rd").__minus_gt("chemical/x-mdl-rdfile"),_st("rdf").__minus_gt("application/rdf+xml"),_st("rgb").__minus_gt("image/x-rgb"),_st("rm").__minus_gt("audio/x-pn-realaudio"),_st("roff").__minus_gt("application/x-troff"),_st("ros").__minus_gt("chemical/x-rosdal"),_st("rpm").__minus_gt("application/x-redhat-package-manager"),_st("rss").__minus_gt("application/rss+xml"),_st("rtf").__minus_gt("text/rtf"),_st("rtx").__minus_gt("text/richtext"),_st("rxn").__minus_gt("chemical/x-mdl-rxnfile"),_st("sct").__minus_gt("text/scriptlet"),_st("sd").__minus_gt("chemical/x-mdl-sdfile"),_st("sd2").__minus_gt("audio/x-sd2"),_st("sda").__minus_gt("application/vnd.stardivision.draw"),_st("sdc").__minus_gt("application/vnd.stardivision.calc"),_st("sdd").__minus_gt("application/vnd.stardivision.impress"),_st("sdf").__minus_gt("chemical/x-mdl-sdfile"),_st("sdp").__minus_gt("application/vnd.stardivision.impress"),_st("sdw").__minus_gt("application/vnd.stardivision.writer"),_st("ser").__minus_gt("application/java-serialized-object"),_st("sgf").__minus_gt("application/x-go-sgf"),_st("sgl").__minus_gt("application/vnd.stardivision.writer-global"),_st("sh").__minus_gt("text/x-sh"),_st("shar").__minus_gt("application/x-shar"),_st("shtml").__minus_gt("text/html"),_st("sid").__minus_gt("audio/prs.sid"),_st("sik").__minus_gt("application/x-trash"),_st("silo").__minus_gt("model/mesh"),_st("sis").__minus_gt("application/vnd.symbian.install"),_st("sit").__minus_gt("application/x-stuffit"),_st("skd").__minus_gt("application/x-koan"),_st("skm").__minus_gt("application/x-koan"),_st("skp").__minus_gt("application/x-koan"),_st("skt").__minus_gt("application/x-koan"),_st("smf").__minus_gt("application/vnd.stardivision.math"),_st("smi").__minus_gt("application/smil"),_st("smil").__minus_gt("application/smil"),_st("snd").__minus_gt("audio/basic"),_st("spc").__minus_gt("chemical/x-galactic-spc"),_st("spl").__minus_gt("application/x-futuresplash"),_st("src").__minus_gt("application/x-wais-source"),_st("stc").__minus_gt("application/vnd.sun.xml.calc.template"),_st("std").__minus_gt("application/vnd.sun.xml.draw.template"),_st("sti").__minus_gt("application/vnd.sun.xml.impress.template"),_st("stl").__minus_gt("application/vnd.ms-pki.stl"),_st("stw").__minus_gt("application/vnd.sun.xml.writer.template"),_st("sty").__minus_gt("text/x-tex"),_st("sv4cpio").__minus_gt("application/x-sv4cpio"),_st("sv4crc").__minus_gt("application/x-sv4crc"),_st("svg").__minus_gt("image/svg+xml"),_st("svgz").__minus_gt("image/svg+xml"),_st("sw").__minus_gt("chemical/x-swissprot"),_st("swf").__minus_gt("application/x-shockwave-flash"),_st("swfl").__minus_gt("application/x-shockwave-flash"),_st("sxc").__minus_gt("application/vnd.sun.xml.calc"),_st("sxd").__minus_gt("application/vnd.sun.xml.draw"),_st("sxg").__minus_gt("application/vnd.sun.xml.writer.global"),_st("sxi").__minus_gt("application/vnd.sun.xml.impress"),_st("sxm").__minus_gt("application/vnd.sun.xml.math"),_st("sxw").__minus_gt("application/vnd.sun.xml.writer"),_st("t").__minus_gt("application/x-troff"),_st("tar").__minus_gt("application/x-tar"),_st("taz").__minus_gt("application/x-gtar"),_st("tcl").__minus_gt("text/x-tcl"),_st("tex").__minus_gt("text/x-tex"),_st("texi").__minus_gt("application/x-texinfo"),_st("texinfo").__minus_gt("application/x-texinfo"),_st("text").__minus_gt("text/plain"),_st("tgf").__minus_gt("chemical/x-mdl-tgf"),_st("tgz").__minus_gt("application/x-gtar"),_st("tif").__minus_gt("image/tiff"),_st("tiff").__minus_gt("image/tiff"),_st("tk").__minus_gt("text/x-tcl"),_st("tm").__minus_gt("text/texmacs"),_st("torrent").__minus_gt("application/x-bittorrent"),_st("tr").__minus_gt("application/x-troff"),_st("ts").__minus_gt("text/texmacs"),_st("tsp").__minus_gt("application/dsptype"),_st("tsv").__minus_gt("text/tab-separated-values"),_st("txt").__minus_gt("text/plain"),_st("udeb").__minus_gt("application/x-debian-package"),_st("uls").__minus_gt("text/iuls"),_st("ustar").__minus_gt("application/x-ustar"),_st("val").__minus_gt("chemical/x-ncbi-asn1-binary"),_st("vcd").__minus_gt("application/x-cdlink"),_st("vcf").__minus_gt("text/x-vcard"),_st("vcs").__minus_gt("text/x-vcalendar"),_st("vmd").__minus_gt("chemical/x-vmd"),_st("vms").__minus_gt("chemical/x-vamas-iso14976"),_st("vor").__minus_gt("application/vnd.stardivision.writer"),_st("vrm").__minus_gt("x-world/x-vrml"),_st("vrml").__minus_gt("x-world/x-vrml"),_st("vsd").__minus_gt("application/vnd.visio"),_st("wad").__minus_gt("application/x-doom"),_st("wav").__minus_gt("audio/x-wav"),_st("wax").__minus_gt("audio/x-ms-wax"),_st("wbmp").__minus_gt("image/vnd.wap.wbmp"),_st("wbxml").__minus_gt("application/vnd.wap.wbxml"),_st("wk").__minus_gt("application/x-123"),_st("wm").__minus_gt("video/x-ms-wm"),_st("wma").__minus_gt("audio/x-ms-wma"),_st("wmd").__minus_gt("application/x-ms-wmd"),_st("wml").__minus_gt("text/vnd.wap.wml"),_st("wmlc").__minus_gt("application/vnd.wap.wmlc"),_st("wmls").__minus_gt("text/vnd.wap.wmlscript"),_st("wmlsc").__minus_gt("application/vnd.wap.wmlscriptc"),_st("wmv").__minus_gt("video/x-ms-wmv"),_st("wmx").__minus_gt("video/x-ms-wmx"),_st("wmz").__minus_gt("application/x-ms-wmz"),_st("wp5").__minus_gt("application/wordperfect5.1"),_st("wpd").__minus_gt("application/wordperfect"),_st("wrl").__minus_gt("x-world/x-vrml"),_st("wsc").__minus_gt("text/scriptlet"),_st("wvx").__minus_gt("video/x-ms-wvx"),_st("wz").__minus_gt("application/x-wingz"),_st("xbm").__minus_gt("image/x-xbitmap"),_st("xcf").__minus_gt("application/x-xcf"),_st("xht").__minus_gt("application/xhtml+xml"),_st("xhtml").__minus_gt("application/xhtml+xml"),_st("xlb").__minus_gt("application/vnd.ms-excel"),_st("xls").__minus_gt("application/vnd.ms-excel"),_st("xlt").__minus_gt("application/vnd.ms-excel"),_st("xml").__minus_gt("application/xml"),_st("xpi").__minus_gt("application/x-xpinstall"),_st("xpm").__minus_gt("image/x-xpixmap"),_st("xsl").__minus_gt("application/xml"),_st("xtel").__minus_gt("chemical/x-xtel"),_st("xul").__minus_gt("application/vnd.mozilla.xul+xml"),_st("xwd").__minus_gt("image/x-xwindowdump"),_st("xyz").__minus_gt("chemical/x-xyz"),_st("zip").__minus_gt("application/zip"),_st("zmt").__minus_gt("chemical/x-mopac-input"),_st("~").__minus_gt("application/x-trash")]);
  722. return $1;
  723. }, function($ctx1) {$ctx1.fill(self,"defaultMimeTypes",{},smalltalk.FileServer.klass)})},
  724. messageSends: ["->"]}),
  725. smalltalk.FileServer.klass);
  726. smalltalk.addMethod(
  727. smalltalk.method({
  728. selector: "defaultPort",
  729. fn: function (){
  730. var self=this;
  731. return smalltalk.withContext(function($ctx1) {
  732. var $1;
  733. $1=(4000);
  734. return $1;
  735. }, function($ctx1) {$ctx1.fill(self,"defaultPort",{},smalltalk.FileServer.klass)})},
  736. messageSends: []}),
  737. smalltalk.FileServer.klass);
  738. smalltalk.addMethod(
  739. smalltalk.method({
  740. selector: "main",
  741. fn: function (){
  742. var self=this;
  743. var fileServer,args;
  744. function $FileServer(){return smalltalk.FileServer||(typeof FileServer=="undefined"?nil:FileServer)}
  745. return smalltalk.withContext(function($ctx1) {
  746. var $1,$2;
  747. var $early={};
  748. try {
  749. args=_st(process)._argv();
  750. _st(args)._removeFrom_to_((1),(3));
  751. _st(args)._detect_ifNone_((function(each){
  752. return smalltalk.withContext(function($ctx2) {
  753. $1=_st(each).__eq("--help");
  754. if(smalltalk.assert($1)){
  755. return _st($FileServer())._printHelp();
  756. };
  757. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  758. return smalltalk.withContext(function($ctx2) {
  759. fileServer=_st($FileServer())._createServerWithArguments_(args);
  760. fileServer;
  761. $2=_st(fileServer)._start();
  762. throw $early=[$2];
  763. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  764. return self}
  765. catch(e) {if(e===$early)return e[0]; throw e}
  766. }, function($ctx1) {$ctx1.fill(self,"main",{fileServer:fileServer,args:args},smalltalk.FileServer.klass)})},
  767. messageSends: ["argv", "removeFrom:to:", "detect:ifNone:", "ifTrue:", "printHelp", "=", "createServerWithArguments:", "start"]}),
  768. smalltalk.FileServer.klass);
  769. smalltalk.addMethod(
  770. smalltalk.method({
  771. selector: "mimeTypeFor:",
  772. fn: function (aString){
  773. var self=this;
  774. return smalltalk.withContext(function($ctx1) {
  775. var $1;
  776. $1=_st(_st(self)._mimeTypes())._at_ifAbsent_(_st(aString)._replace_with_(".*[\x5c.]",""),(function(){
  777. return smalltalk.withContext(function($ctx2) {
  778. return "text/plain";
  779. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  780. return $1;
  781. }, function($ctx1) {$ctx1.fill(self,"mimeTypeFor:",{aString:aString},smalltalk.FileServer.klass)})},
  782. messageSends: ["at:ifAbsent:", "replace:with:", "mimeTypes"]}),
  783. smalltalk.FileServer.klass);
  784. smalltalk.addMethod(
  785. smalltalk.method({
  786. selector: "mimeTypes",
  787. fn: function (){
  788. var self=this;
  789. return smalltalk.withContext(function($ctx1) {
  790. var $2,$1;
  791. $2=self["@mimeTypes"];
  792. if(($receiver = $2) == nil || $receiver == undefined){
  793. self["@mimeTypes"]=_st(self)._defaultMimeTypes();
  794. $1=self["@mimeTypes"];
  795. } else {
  796. $1=$2;
  797. };
  798. return $1;
  799. }, function($ctx1) {$ctx1.fill(self,"mimeTypes",{},smalltalk.FileServer.klass)})},
  800. messageSends: ["ifNil:", "defaultMimeTypes"]}),
  801. smalltalk.FileServer.klass);
  802. smalltalk.addMethod(
  803. smalltalk.method({
  804. selector: "printHelp",
  805. fn: function (){
  806. var self=this;
  807. return smalltalk.withContext(function($ctx1) {
  808. _st(console)._log_("Available commandline options are:");
  809. _st(console)._log_("--help");
  810. _st(_st(self)._commandLineSwitches())._do_((function(each){
  811. return smalltalk.withContext(function($ctx2) {
  812. return _st(console)._log_(_st(each).__comma(" <parameter>"));
  813. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  814. return self}, function($ctx1) {$ctx1.fill(self,"printHelp",{},smalltalk.FileServer.klass)})},
  815. messageSends: ["log:", "do:", ",", "commandLineSwitches"]}),
  816. smalltalk.FileServer.klass);
  817. smalltalk.addMethod(
  818. smalltalk.method({
  819. selector: "selectorForCommandLineSwitch:",
  820. fn: function (aSwitch){
  821. var self=this;
  822. return smalltalk.withContext(function($ctx1) {
  823. var $1;
  824. $1=_st(_st(_st(aSwitch)._replace_with_("^--",""))._replace_with_("-[a-z]",(function(each){
  825. return smalltalk.withContext(function($ctx2) {
  826. return _st(_st(each)._second())._asUppercase();
  827. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}))).__comma(":");
  828. return $1;
  829. }, function($ctx1) {$ctx1.fill(self,"selectorForCommandLineSwitch:",{aSwitch:aSwitch},smalltalk.FileServer.klass)})},
  830. messageSends: [",", "replace:with:", "asUppercase", "second"]}),
  831. smalltalk.FileServer.klass);
  832. smalltalk.addClass('Repl', smalltalk.Object, ['readline', 'interface', 'util'], 'AmberCli');
  833. smalltalk.addMethod(
  834. smalltalk.method({
  835. selector: "close",
  836. fn: function (){
  837. var self=this;
  838. return smalltalk.withContext(function($ctx1) {
  839. _st(_st(process)._stdin())._destroy();
  840. return self}, function($ctx1) {$ctx1.fill(self,"close",{},smalltalk.Repl)})},
  841. messageSends: ["destroy", "stdin"]}),
  842. smalltalk.Repl);
  843. smalltalk.addMethod(
  844. smalltalk.method({
  845. selector: "createInterface",
  846. fn: function (){
  847. var self=this;
  848. return smalltalk.withContext(function($ctx1) {
  849. self["@interface"]=_st(self["@readline"])._createInterface_stdout_(_st(process)._stdin(),_st(process)._stdout());
  850. _st(self["@interface"])._on_do_("line",(function(buffer){
  851. return smalltalk.withContext(function($ctx2) {
  852. return _st(self)._eval_(buffer);
  853. }, function($ctx2) {$ctx2.fillBlock({buffer:buffer},$ctx1)})}));
  854. _st(self["@interface"])._on_do_("close",(function(){
  855. return smalltalk.withContext(function($ctx2) {
  856. return _st(self)._close();
  857. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  858. _st(self)._setPrompt();
  859. _st(self["@interface"])._prompt();
  860. return self}, function($ctx1) {$ctx1.fill(self,"createInterface",{},smalltalk.Repl)})},
  861. messageSends: ["createInterface:stdout:", "stdin", "stdout", "on:do:", "eval:", "close", "setPrompt", "prompt"]}),
  862. smalltalk.Repl);
  863. smalltalk.addMethod(
  864. smalltalk.method({
  865. selector: "eval:",
  866. fn: function (buffer){
  867. var self=this;
  868. var result;
  869. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  870. function $Transcript(){return smalltalk.Transcript||(typeof Transcript=="undefined"?nil:Transcript)}
  871. function $ErrorHandler(){return smalltalk.ErrorHandler||(typeof ErrorHandler=="undefined"?nil:ErrorHandler)}
  872. return smalltalk.withContext(function($ctx1) {
  873. var $1,$2;
  874. $1=_st(buffer)._isEmpty();
  875. if(! smalltalk.assert($1)){
  876. _st(self)._try_catch_((function(){
  877. return smalltalk.withContext(function($ctx2) {
  878. result=_st(_st($Compiler())._new())._evaluateExpression_(buffer);
  879. result;
  880. return _st($Transcript())._show_(result);
  881. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(function(e){
  882. return smalltalk.withContext(function($ctx2) {
  883. $2=_st(e)._isSmalltalkError();
  884. if(smalltalk.assert($2)){
  885. return _st(_st($ErrorHandler())._new())._handleError_(e);
  886. } else {
  887. return _st(_st(process)._stdout())._write_(_st(e)._jsStack());
  888. };
  889. }, function($ctx2) {$ctx2.fillBlock({e:e},$ctx1)})}));
  890. };
  891. _st(self["@interface"])._prompt();
  892. return self}, function($ctx1) {$ctx1.fill(self,"eval:",{buffer:buffer,result:result},smalltalk.Repl)})},
  893. messageSends: ["ifFalse:", "try:catch:", "evaluateExpression:", "new", "show:", "ifTrue:ifFalse:", "handleError:", "write:", "jsStack", "stdout", "isSmalltalkError", "isEmpty", "prompt"]}),
  894. smalltalk.Repl);
  895. smalltalk.addMethod(
  896. smalltalk.method({
  897. selector: "initialize",
  898. fn: function (){
  899. var self=this;
  900. return smalltalk.withContext(function($ctx1) {
  901. smalltalk.Object.fn.prototype._initialize.apply(_st(self), []);
  902. self["@readline"]=_st(require)._value_("readline");
  903. self["@util"]=_st(require)._value_("util");
  904. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.Repl)})},
  905. messageSends: ["initialize", "value:"]}),
  906. smalltalk.Repl);
  907. smalltalk.addMethod(
  908. smalltalk.method({
  909. selector: "prompt",
  910. fn: function (){
  911. var self=this;
  912. return smalltalk.withContext(function($ctx1) {
  913. return "amber >> ";
  914. }, function($ctx1) {$ctx1.fill(self,"prompt",{},smalltalk.Repl)})},
  915. messageSends: []}),
  916. smalltalk.Repl);
  917. smalltalk.addMethod(
  918. smalltalk.method({
  919. selector: "setPrompt",
  920. fn: function (){
  921. var self=this;
  922. return smalltalk.withContext(function($ctx1) {
  923. _st(self["@interface"])._setPrompt_(_st(self)._prompt());
  924. return self}, function($ctx1) {$ctx1.fill(self,"setPrompt",{},smalltalk.Repl)})},
  925. messageSends: ["setPrompt:", "prompt"]}),
  926. smalltalk.Repl);
  927. smalltalk.addMethod(
  928. smalltalk.method({
  929. selector: "main",
  930. fn: function (){
  931. var self=this;
  932. return smalltalk.withContext(function($ctx1) {
  933. _st(_st(self)._new())._createInterface();
  934. return self}, function($ctx1) {$ctx1.fill(self,"main",{},smalltalk.Repl.klass)})},
  935. messageSends: ["createInterface", "new"]}),
  936. smalltalk.Repl.klass);