AmberCli.deploy.js 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986
  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 command;
  34. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  35. return smalltalk.withContext(function($ctx1) {
  36. command=_st(self)._selectorForCommandLineSwitch_(_st(args)._first());
  37. _st(args)._remove_(_st(args)._first());
  38. _st(self)._perform_withArguments_(command,_st($Array())._with_(args));
  39. return self}, function($ctx1) {$ctx1.fill(self,"handleArguments:",{args:args,command:command},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. return smalltalk.withContext(function($ctx1) {
  95. var $1;
  96. $1=_st(_st(aSwitch)._replace_with_("-[a-z]",(function(each){
  97. return smalltalk.withContext(function($ctx2) {
  98. return _st(_st(each)._second())._asUppercase();
  99. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}))).__comma(":");
  100. return $1;
  101. }, function($ctx1) {$ctx1.fill(self,"selectorForCommandLineSwitch:",{aSwitch:aSwitch},smalltalk.AmberCli.klass)})},
  102. messageSends: [",", "replace:with:", "asUppercase", "second"]}),
  103. smalltalk.AmberCli.klass);
  104. smalltalk.addMethod(
  105. smalltalk.method({
  106. selector: "serve:",
  107. fn: function (args){
  108. var self=this;
  109. function $FileServer(){return smalltalk.FileServer||(typeof FileServer=="undefined"?nil:FileServer)}
  110. return smalltalk.withContext(function($ctx1) {
  111. var $1;
  112. $1=_st(_st($FileServer())._createServerWithArguments_(args))._start();
  113. return $1;
  114. }, function($ctx1) {$ctx1.fill(self,"serve:",{args:args},smalltalk.AmberCli.klass)})},
  115. messageSends: ["start", "createServerWithArguments:"]}),
  116. smalltalk.AmberCli.klass);
  117. smalltalk.addClass('FileServer', smalltalk.Object, ['path', 'http', 'fs', 'url', 'host', 'port', 'basePath', 'util', 'username', 'password', 'fallbackPage'], 'AmberCli');
  118. smalltalk.addMethod(
  119. smalltalk.method({
  120. selector: "base64Decode:",
  121. fn: function (aString){
  122. var self=this;
  123. return smalltalk.withContext(function($ctx1) {
  124. return (new Buffer(aString, 'base64').toString());
  125. return self}, function($ctx1) {$ctx1.fill(self,"base64Decode:",{aString:aString},smalltalk.FileServer)})},
  126. messageSends: []}),
  127. smalltalk.FileServer);
  128. smalltalk.addMethod(
  129. smalltalk.method({
  130. selector: "basePath",
  131. fn: function (){
  132. var self=this;
  133. return smalltalk.withContext(function($ctx1) {
  134. var $2,$1;
  135. $2=self["@basePath"];
  136. if(($receiver = $2) == nil || $receiver == undefined){
  137. $1="./";
  138. } else {
  139. $1=$2;
  140. };
  141. return $1;
  142. }, function($ctx1) {$ctx1.fill(self,"basePath",{},smalltalk.FileServer)})},
  143. messageSends: ["ifNil:"]}),
  144. smalltalk.FileServer);
  145. smalltalk.addMethod(
  146. smalltalk.method({
  147. selector: "basePath:",
  148. fn: function (aString){
  149. var self=this;
  150. return smalltalk.withContext(function($ctx1) {
  151. self["@basePath"]=aString;
  152. return self}, function($ctx1) {$ctx1.fill(self,"basePath:",{aString:aString},smalltalk.FileServer)})},
  153. messageSends: []}),
  154. smalltalk.FileServer);
  155. smalltalk.addMethod(
  156. smalltalk.method({
  157. selector: "checkDirectoryLayout",
  158. fn: function (){
  159. var self=this;
  160. return smalltalk.withContext(function($ctx1) {
  161. var $1,$2,$3;
  162. $1=_st(self["@fs"])._existsSync_(_st(_st(self)._basePath()).__comma("index.html"));
  163. if(! smalltalk.assert($1)){
  164. _st(console)._warn_("Warning: project directory does not contain index.html");
  165. };
  166. $2=_st(self["@fs"])._existsSync_(_st(_st(self)._basePath()).__comma("st"));
  167. if(! smalltalk.assert($2)){
  168. _st(console)._warn_("Warning: project directory is missing an \x22st\x22 directory");
  169. };
  170. $3=_st(self["@fs"])._existsSync_(_st(_st(self)._basePath()).__comma("js"));
  171. if(! smalltalk.assert($3)){
  172. _st(console)._warn_("Warning: project directory is missing a \x22js\x22 directory");
  173. };
  174. return self}, function($ctx1) {$ctx1.fill(self,"checkDirectoryLayout",{},smalltalk.FileServer)})},
  175. messageSends: ["ifFalse:", "warn:", "existsSync:", ",", "basePath"]}),
  176. smalltalk.FileServer);
  177. smalltalk.addMethod(
  178. smalltalk.method({
  179. selector: "fallbackPage",
  180. fn: function (){
  181. var self=this;
  182. return smalltalk.withContext(function($ctx1) {
  183. var $1;
  184. $1=self["@fallbackPage"];
  185. return $1;
  186. }, function($ctx1) {$ctx1.fill(self,"fallbackPage",{},smalltalk.FileServer)})},
  187. messageSends: []}),
  188. smalltalk.FileServer);
  189. smalltalk.addMethod(
  190. smalltalk.method({
  191. selector: "fallbackPage:",
  192. fn: function (aString){
  193. var self=this;
  194. return smalltalk.withContext(function($ctx1) {
  195. self["@fallbackPage"]=aString;
  196. return self}, function($ctx1) {$ctx1.fill(self,"fallbackPage:",{aString:aString},smalltalk.FileServer)})},
  197. messageSends: []}),
  198. smalltalk.FileServer);
  199. smalltalk.addMethod(
  200. smalltalk.method({
  201. selector: "handleGETRequest:respondTo:",
  202. fn: function (aRequest,aResponse){
  203. var self=this;
  204. var uri,filename;
  205. return smalltalk.withContext(function($ctx1) {
  206. var $1;
  207. uri=_st(_st(self["@url"])._parse_(_st(aRequest)._url()))._pathname();
  208. filename=_st(self["@path"])._join_with_(_st(self)._basePath(),uri);
  209. _st(self["@fs"])._exists_do_(filename,(function(aBoolean){
  210. return smalltalk.withContext(function($ctx2) {
  211. $1=aBoolean;
  212. if(smalltalk.assert($1)){
  213. return _st(self)._respondFileNamed_to_(filename,aResponse);
  214. } else {
  215. return _st(self)._respondNotFoundTo_(aResponse);
  216. };
  217. }, function($ctx2) {$ctx2.fillBlock({aBoolean:aBoolean},$ctx1)})}));
  218. return self}, function($ctx1) {$ctx1.fill(self,"handleGETRequest:respondTo:",{aRequest:aRequest,aResponse:aResponse,uri:uri,filename:filename},smalltalk.FileServer)})},
  219. messageSends: ["pathname", "parse:", "url", "join:with:", "basePath", "exists:do:", "ifFalse:ifTrue:", "respondNotFoundTo:", "respondFileNamed:to:"]}),
  220. smalltalk.FileServer);
  221. smalltalk.addMethod(
  222. smalltalk.method({
  223. selector: "handleOPTIONSRequest:respondTo:",
  224. fn: function (aRequest,aResponse){
  225. var self=this;
  226. return smalltalk.withContext(function($ctx1) {
  227. _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))]));
  228. _st(aResponse)._end();
  229. return self}, function($ctx1) {$ctx1.fill(self,"handleOPTIONSRequest:respondTo:",{aRequest:aRequest,aResponse:aResponse},smalltalk.FileServer)})},
  230. messageSends: ["writeHead:options:", "->", "end"]}),
  231. smalltalk.FileServer);
  232. smalltalk.addMethod(
  233. smalltalk.method({
  234. selector: "handlePUTRequest:respondTo:",
  235. fn: function (aRequest,aResponse){
  236. var self=this;
  237. var file,stream;
  238. return smalltalk.withContext(function($ctx1) {
  239. var $1,$2;
  240. $1=_st(self)._isAuthenticated_(aRequest);
  241. if(! smalltalk.assert($1)){
  242. _st(self)._respondAuthenticationRequiredTo_(aResponse);
  243. return nil;
  244. };
  245. file=_st(".").__comma(_st(aRequest)._url());
  246. stream=_st(self["@fs"])._createWriteStream_(file);
  247. _st(stream)._on_do_("error",(function(error){
  248. return smalltalk.withContext(function($ctx2) {
  249. _st(console)._warn_(_st("Error creating WriteStream for file ").__comma(file));
  250. _st(console)._warn_(" Did you forget to create the necessary js/ or st/ directory in your project?");
  251. _st(console)._warn_(_st(" The exact error is: ").__comma(error));
  252. return _st(self)._respondNotCreatedTo_(aResponse);
  253. }, function($ctx2) {$ctx2.fillBlock({error:error},$ctx1)})}));
  254. _st(stream)._on_do_("close",(function(){
  255. return smalltalk.withContext(function($ctx2) {
  256. return _st(self)._respondCreatedTo_(aResponse);
  257. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  258. _st(aRequest)._setEncoding_("utf8");
  259. _st(aRequest)._on_do_("data",(function(data){
  260. return smalltalk.withContext(function($ctx2) {
  261. return _st(stream)._write_(data);
  262. }, function($ctx2) {$ctx2.fillBlock({data:data},$ctx1)})}));
  263. _st(aRequest)._on_do_("end",(function(){
  264. return smalltalk.withContext(function($ctx2) {
  265. $2=_st(stream)._writable();
  266. if(smalltalk.assert($2)){
  267. return _st(stream)._end();
  268. };
  269. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  270. return self}, function($ctx1) {$ctx1.fill(self,"handlePUTRequest:respondTo:",{aRequest:aRequest,aResponse:aResponse,file:file,stream:stream},smalltalk.FileServer)})},
  271. messageSends: ["ifFalse:", "respondAuthenticationRequiredTo:", "isAuthenticated:", ",", "url", "createWriteStream:", "on:do:", "warn:", "respondNotCreatedTo:", "respondCreatedTo:", "setEncoding:", "write:", "ifTrue:", "end", "writable"]}),
  272. smalltalk.FileServer);
  273. smalltalk.addMethod(
  274. smalltalk.method({
  275. selector: "handleRequest:respondTo:",
  276. fn: function (aRequest,aResponse){
  277. var self=this;
  278. return smalltalk.withContext(function($ctx1) {
  279. var $1,$2,$3;
  280. $1=_st(_st(aRequest)._method()).__eq("PUT");
  281. if(smalltalk.assert($1)){
  282. _st(self)._handlePUTRequest_respondTo_(aRequest,aResponse);
  283. };
  284. $2=_st(_st(aRequest)._method()).__eq("GET");
  285. if(smalltalk.assert($2)){
  286. _st(self)._handleGETRequest_respondTo_(aRequest,aResponse);
  287. };
  288. $3=_st(_st(aRequest)._method()).__eq("OPTIONS");
  289. if(smalltalk.assert($3)){
  290. _st(self)._handleOPTIONSRequest_respondTo_(aRequest,aResponse);
  291. };
  292. return self}, function($ctx1) {$ctx1.fill(self,"handleRequest:respondTo:",{aRequest:aRequest,aResponse:aResponse},smalltalk.FileServer)})},
  293. messageSends: ["ifTrue:", "handlePUTRequest:respondTo:", "=", "method", "handleGETRequest:respondTo:", "handleOPTIONSRequest:respondTo:"]}),
  294. smalltalk.FileServer);
  295. smalltalk.addMethod(
  296. smalltalk.method({
  297. selector: "host",
  298. fn: function (){
  299. var self=this;
  300. return smalltalk.withContext(function($ctx1) {
  301. var $1;
  302. $1=self["@host"];
  303. return $1;
  304. }, function($ctx1) {$ctx1.fill(self,"host",{},smalltalk.FileServer)})},
  305. messageSends: []}),
  306. smalltalk.FileServer);
  307. smalltalk.addMethod(
  308. smalltalk.method({
  309. selector: "host:",
  310. fn: function (hostname){
  311. var self=this;
  312. return smalltalk.withContext(function($ctx1) {
  313. self["@host"]=hostname;
  314. return self}, function($ctx1) {$ctx1.fill(self,"host:",{hostname:hostname},smalltalk.FileServer)})},
  315. messageSends: []}),
  316. smalltalk.FileServer);
  317. smalltalk.addMethod(
  318. smalltalk.method({
  319. selector: "initialize",
  320. fn: function (){
  321. var self=this;
  322. return smalltalk.withContext(function($ctx1) {
  323. smalltalk.Object.fn.prototype._initialize.apply(_st(self), []);
  324. self["@path"]=_st(self)._require_("path");
  325. self["@http"]=_st(self)._require_("http");
  326. self["@fs"]=_st(self)._require_("fs");
  327. self["@util"]=_st(self)._require_("util");
  328. self["@url"]=_st(self)._require_("url");
  329. self["@host"]=_st(_st(self)._class())._defaultHost();
  330. self["@port"]=_st(_st(self)._class())._defaultPort();
  331. self["@username"]=nil;
  332. self["@password"]=nil;
  333. self["@fallbackPage"]=nil;
  334. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.FileServer)})},
  335. messageSends: ["initialize", "require:", "defaultHost", "class", "defaultPort"]}),
  336. smalltalk.FileServer);
  337. smalltalk.addMethod(
  338. smalltalk.method({
  339. selector: "isAuthenticated:",
  340. fn: function (aRequest){
  341. var self=this;
  342. var header,token,auth,parts;
  343. return smalltalk.withContext(function($ctx1) {
  344. var $1,$2,$3,$4,$5;
  345. $1=_st(_st(self["@username"])._isNil())._and_((function(){
  346. return smalltalk.withContext(function($ctx2) {
  347. return _st(self["@password"])._isNil();
  348. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  349. if(smalltalk.assert($1)){
  350. return true;
  351. };
  352. $2=_st(_st(aRequest)._headers())._at_("authorization");
  353. if(($receiver = $2) == nil || $receiver == undefined){
  354. header="";
  355. } else {
  356. header=$2;
  357. };
  358. $3=_st(header)._isEmpty();
  359. if(smalltalk.assert($3)){
  360. return false;
  361. } else {
  362. $4=_st(header)._tokenize_(" ");
  363. if(($receiver = $4) == nil || $receiver == undefined){
  364. token="";
  365. } else {
  366. token=$4;
  367. };
  368. token;
  369. auth=_st(self)._base64Decode_(_st(token)._at_((2)));
  370. auth;
  371. parts=_st(auth)._tokenize_(":");
  372. parts;
  373. $5=_st(_st(self["@username"]).__eq(_st(parts)._at_((1))))._and_((function(){
  374. return smalltalk.withContext(function($ctx2) {
  375. return _st(self["@password"]).__eq(_st(parts)._at_((2)));
  376. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  377. if(smalltalk.assert($5)){
  378. return true;
  379. } else {
  380. return false;
  381. };
  382. };
  383. return self}, function($ctx1) {$ctx1.fill(self,"isAuthenticated:",{aRequest:aRequest,header:header,token:token,auth:auth,parts:parts},smalltalk.FileServer)})},
  384. messageSends: ["ifTrue:", "and:", "isNil", "ifNil:", "at:", "headers", "ifTrue:ifFalse:", "tokenize:", "base64Decode:", "=", "isEmpty"]}),
  385. smalltalk.FileServer);
  386. smalltalk.addMethod(
  387. smalltalk.method({
  388. selector: "password:",
  389. fn: function (aPassword){
  390. var self=this;
  391. return smalltalk.withContext(function($ctx1) {
  392. self["@password"]=aPassword;
  393. return self}, function($ctx1) {$ctx1.fill(self,"password:",{aPassword:aPassword},smalltalk.FileServer)})},
  394. messageSends: []}),
  395. smalltalk.FileServer);
  396. smalltalk.addMethod(
  397. smalltalk.method({
  398. selector: "port",
  399. fn: function (){
  400. var self=this;
  401. return smalltalk.withContext(function($ctx1) {
  402. var $1;
  403. $1=self["@port"];
  404. return $1;
  405. }, function($ctx1) {$ctx1.fill(self,"port",{},smalltalk.FileServer)})},
  406. messageSends: []}),
  407. smalltalk.FileServer);
  408. smalltalk.addMethod(
  409. smalltalk.method({
  410. selector: "port:",
  411. fn: function (aNumber){
  412. var self=this;
  413. return smalltalk.withContext(function($ctx1) {
  414. self["@port"]=aNumber;
  415. return self}, function($ctx1) {$ctx1.fill(self,"port:",{aNumber:aNumber},smalltalk.FileServer)})},
  416. messageSends: []}),
  417. smalltalk.FileServer);
  418. smalltalk.addMethod(
  419. smalltalk.method({
  420. selector: "require:",
  421. fn: function (aModuleString){
  422. var self=this;
  423. return smalltalk.withContext(function($ctx1) {
  424. var $1;
  425. $1=_st(require)._value_(aModuleString);
  426. return $1;
  427. }, function($ctx1) {$ctx1.fill(self,"require:",{aModuleString:aModuleString},smalltalk.FileServer)})},
  428. messageSends: ["value:"]}),
  429. smalltalk.FileServer);
  430. smalltalk.addMethod(
  431. smalltalk.method({
  432. selector: "respondAuthenticationRequiredTo:",
  433. fn: function (aResponse){
  434. var self=this;
  435. return smalltalk.withContext(function($ctx1) {
  436. var $1,$2;
  437. $1=aResponse;
  438. _st($1)._writeHead_options_((401),smalltalk.HashedCollection._fromPairs_([_st("WWW-Authenticate").__minus_gt("Basic realm=\x22Secured Developer Area\x22")]));
  439. _st($1)._write_("<html><body>Authentication needed</body></html>");
  440. $2=_st($1)._end();
  441. return self}, function($ctx1) {$ctx1.fill(self,"respondAuthenticationRequiredTo:",{aResponse:aResponse},smalltalk.FileServer)})},
  442. messageSends: ["writeHead:options:", "->", "write:", "end"]}),
  443. smalltalk.FileServer);
  444. smalltalk.addMethod(
  445. smalltalk.method({
  446. selector: "respondCreatedTo:",
  447. fn: function (aResponse){
  448. var self=this;
  449. return smalltalk.withContext(function($ctx1) {
  450. var $1,$2;
  451. $1=aResponse;
  452. _st($1)._writeHead_options_((201),smalltalk.HashedCollection._fromPairs_([_st("Content-Type").__minus_gt("text/plain"),_st("Access-Control-Allow-Origin").__minus_gt("*")]));
  453. $2=_st($1)._end();
  454. return self}, function($ctx1) {$ctx1.fill(self,"respondCreatedTo:",{aResponse:aResponse},smalltalk.FileServer)})},
  455. messageSends: ["writeHead:options:", "->", "end"]}),
  456. smalltalk.FileServer);
  457. smalltalk.addMethod(
  458. smalltalk.method({
  459. selector: "respondFileNamed:to:",
  460. fn: function (aFilename,aResponse){
  461. var self=this;
  462. var type,filename;
  463. return smalltalk.withContext(function($ctx1) {
  464. var $1,$2,$3,$4,$5;
  465. filename=aFilename;
  466. $1=_st(_st(self["@fs"])._statSync_(aFilename))._isDirectory();
  467. if(smalltalk.assert($1)){
  468. filename=_st(filename).__comma("index.html");
  469. filename;
  470. };
  471. _st(self["@fs"])._readFile_do_(filename,(function(ex,file){
  472. return smalltalk.withContext(function($ctx2) {
  473. $2=_st(ex)._notNil();
  474. if(smalltalk.assert($2)){
  475. _st(console)._log_(_st(filename).__comma(" does not exist"));
  476. return _st(self)._respondInternalErrorTo_(aResponse);
  477. } else {
  478. type=_st(_st(self)._class())._mimeTypeFor_(filename);
  479. type;
  480. $3=_st(type).__eq("application/javascript");
  481. if(smalltalk.assert($3)){
  482. type=_st(type).__comma(";charset=utf-8");
  483. type;
  484. };
  485. $4=aResponse;
  486. _st($4)._writeHead_options_((200),smalltalk.HashedCollection._fromPairs_([_st("Content-Type").__minus_gt(type)]));
  487. _st($4)._write_encoding_(file,"binary");
  488. $5=_st($4)._end();
  489. return $5;
  490. };
  491. }, function($ctx2) {$ctx2.fillBlock({ex:ex,file:file},$ctx1)})}));
  492. return self}, function($ctx1) {$ctx1.fill(self,"respondFileNamed:to:",{aFilename:aFilename,aResponse:aResponse,type:type,filename:filename},smalltalk.FileServer)})},
  493. messageSends: ["ifTrue:", ",", "isDirectory", "statSync:", "readFile:do:", "ifTrue:ifFalse:", "log:", "respondInternalErrorTo:", "mimeTypeFor:", "class", "=", "writeHead:options:", "->", "write:encoding:", "end", "notNil"]}),
  494. smalltalk.FileServer);
  495. smalltalk.addMethod(
  496. smalltalk.method({
  497. selector: "respondInternalErrorTo:",
  498. fn: function (aResponse){
  499. var self=this;
  500. return smalltalk.withContext(function($ctx1) {
  501. var $1,$2;
  502. $1=aResponse;
  503. _st($1)._writeHead_options_((500),smalltalk.HashedCollection._fromPairs_([_st("Content-Type").__minus_gt("text/plain")]));
  504. _st($1)._write_("500 Internal server error");
  505. $2=_st($1)._end();
  506. return self}, function($ctx1) {$ctx1.fill(self,"respondInternalErrorTo:",{aResponse:aResponse},smalltalk.FileServer)})},
  507. messageSends: ["writeHead:options:", "->", "write:", "end"]}),
  508. smalltalk.FileServer);
  509. smalltalk.addMethod(
  510. smalltalk.method({
  511. selector: "respondNotCreatedTo:",
  512. fn: function (aResponse){
  513. var self=this;
  514. return smalltalk.withContext(function($ctx1) {
  515. var $1,$2;
  516. $1=aResponse;
  517. _st($1)._writeHead_options_((400),smalltalk.HashedCollection._fromPairs_([_st("Content-Type").__minus_gt("text/plain")]));
  518. _st($1)._write_("File could not be created. Did you forget to create the st/js directories on the server?");
  519. $2=_st($1)._end();
  520. return self}, function($ctx1) {$ctx1.fill(self,"respondNotCreatedTo:",{aResponse:aResponse},smalltalk.FileServer)})},
  521. messageSends: ["writeHead:options:", "->", "write:", "end"]}),
  522. smalltalk.FileServer);
  523. smalltalk.addMethod(
  524. smalltalk.method({
  525. selector: "respondNotFoundTo:",
  526. fn: function (aResponse){
  527. var self=this;
  528. return smalltalk.withContext(function($ctx1) {
  529. var $1,$2,$3,$4;
  530. $1=_st(_st(self)._fallbackPage())._isNil();
  531. if(! smalltalk.assert($1)){
  532. $2=_st(self)._respondFileNamed_to_(_st(self)._fallbackPage(),aResponse);
  533. return $2;
  534. };
  535. $3=aResponse;
  536. _st($3)._writeHead_options_((404),smalltalk.HashedCollection._fromPairs_([_st("Content-Type").__minus_gt("text/plain")]));
  537. _st($3)._write_("404 Not found");
  538. $4=_st($3)._end();
  539. return self}, function($ctx1) {$ctx1.fill(self,"respondNotFoundTo:",{aResponse:aResponse},smalltalk.FileServer)})},
  540. messageSends: ["ifFalse:", "respondFileNamed:to:", "fallbackPage", "isNil", "writeHead:options:", "->", "write:", "end"]}),
  541. smalltalk.FileServer);
  542. smalltalk.addMethod(
  543. smalltalk.method({
  544. selector: "respondOKTo:",
  545. fn: function (aResponse){
  546. var self=this;
  547. return smalltalk.withContext(function($ctx1) {
  548. var $1,$2;
  549. $1=aResponse;
  550. _st($1)._writeHead_options_((200),smalltalk.HashedCollection._fromPairs_([_st("Content-Type").__minus_gt("text/plain"),_st("Access-Control-Allow-Origin").__minus_gt("*")]));
  551. $2=_st($1)._end();
  552. return self}, function($ctx1) {$ctx1.fill(self,"respondOKTo:",{aResponse:aResponse},smalltalk.FileServer)})},
  553. messageSends: ["writeHead:options:", "->", "end"]}),
  554. smalltalk.FileServer);
  555. smalltalk.addMethod(
  556. smalltalk.method({
  557. selector: "start",
  558. fn: function (){
  559. var self=this;
  560. return smalltalk.withContext(function($ctx1) {
  561. var $1,$2;
  562. _st(self)._checkDirectoryLayout();
  563. $1=_st(self["@http"])._createServer_((function(request,response){
  564. return smalltalk.withContext(function($ctx2) {
  565. return _st(self)._handleRequest_respondTo_(request,response);
  566. }, function($ctx2) {$ctx2.fillBlock({request:request,response:response},$ctx1)})}));
  567. _st($1)._on_do_("error",(function(error){
  568. return smalltalk.withContext(function($ctx2) {
  569. return _st(console)._log_(_st("Error starting server: ").__comma(error));
  570. }, function($ctx2) {$ctx2.fillBlock({error:error},$ctx1)})}));
  571. _st($1)._on_do_("listening",(function(){
  572. return smalltalk.withContext(function($ctx2) {
  573. return _st(console)._log_(_st(_st(_st("Starting file server on ").__comma(_st(self)._host())).__comma(":")).__comma(_st(_st(self)._port())._asString()));
  574. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  575. $2=_st($1)._listen_host_(_st(self)._port(),_st(self)._host());
  576. return self}, function($ctx1) {$ctx1.fill(self,"start",{},smalltalk.FileServer)})},
  577. messageSends: ["checkDirectoryLayout", "on:do:", "log:", ",", "createServer:", "handleRequest:respondTo:", "asString", "port", "host", "listen:host:"]}),
  578. smalltalk.FileServer);
  579. smalltalk.addMethod(
  580. smalltalk.method({
  581. selector: "startOn:",
  582. fn: function (aPort){
  583. var self=this;
  584. return smalltalk.withContext(function($ctx1) {
  585. _st(self)._port_(aPort);
  586. _st(self)._start();
  587. return self}, function($ctx1) {$ctx1.fill(self,"startOn:",{aPort:aPort},smalltalk.FileServer)})},
  588. messageSends: ["port:", "start"]}),
  589. smalltalk.FileServer);
  590. smalltalk.addMethod(
  591. smalltalk.method({
  592. selector: "username:",
  593. fn: function (aUsername){
  594. var self=this;
  595. return smalltalk.withContext(function($ctx1) {
  596. self["@username"]=aUsername;
  597. return self}, function($ctx1) {$ctx1.fill(self,"username:",{aUsername:aUsername},smalltalk.FileServer)})},
  598. messageSends: []}),
  599. smalltalk.FileServer);
  600. smalltalk.addMethod(
  601. smalltalk.method({
  602. selector: "writeData:toFileNamed:",
  603. fn: function (data,aFilename){
  604. var self=this;
  605. return smalltalk.withContext(function($ctx1) {
  606. _st(console)._log_(aFilename);
  607. return self}, function($ctx1) {$ctx1.fill(self,"writeData:toFileNamed:",{data:data,aFilename:aFilename},smalltalk.FileServer)})},
  608. messageSends: ["log:"]}),
  609. smalltalk.FileServer);
  610. smalltalk.FileServer.klass.iVarNames = ['mimeTypes'];
  611. smalltalk.addMethod(
  612. smalltalk.method({
  613. selector: "commandLineSwitches",
  614. fn: function (){
  615. var self=this;
  616. var switches;
  617. return smalltalk.withContext(function($ctx1) {
  618. var $1;
  619. switches=_st(_st(self)._methodsInProtocol_("accessing"))._collect_((function(each){
  620. return smalltalk.withContext(function($ctx2) {
  621. return _st(each)._selector();
  622. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  623. switches=_st(switches)._select_((function(each){
  624. return smalltalk.withContext(function($ctx2) {
  625. return _st(each)._match_("^[^:]*:$");
  626. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  627. switches=_st(switches)._collect_((function(each){
  628. return smalltalk.withContext(function($ctx2) {
  629. return _st(_st(_st(_st(each)._allButLast())._replace_with_("([A-Z])","-$1"))._asLowercase())._replace_with_("^([a-z])","--$1");
  630. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  631. $1=switches;
  632. return $1;
  633. }, function($ctx1) {$ctx1.fill(self,"commandLineSwitches",{switches:switches},smalltalk.FileServer.klass)})},
  634. messageSends: ["collect:", "selector", "methodsInProtocol:", "select:", "match:", "replace:with:", "asLowercase", "allButLast"]}),
  635. smalltalk.FileServer.klass);
  636. smalltalk.addMethod(
  637. smalltalk.method({
  638. selector: "createServerWithArguments:",
  639. fn: function (options){
  640. var self=this;
  641. var server,popFront,front,optionName,optionValue,switches;
  642. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  643. return smalltalk.withContext(function($ctx1) {
  644. var $1,$2,$3,$4,$5;
  645. var $early={};
  646. try {
  647. switches=_st(self)._commandLineSwitches();
  648. server=_st(self)._new();
  649. _st(options)._ifEmpty_((function(){
  650. return smalltalk.withContext(function($ctx2) {
  651. $1=server;
  652. throw $early=[$1];
  653. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  654. $2=_st(_st(options)._size())._even();
  655. if(! smalltalk.assert($2)){
  656. _st(console)._log_("Using default parameters.");
  657. _st(console)._log_(_st("Wrong commandline options or not enough arguments for: ").__comma(options));
  658. _st(console)._log_(_st("Use any of the following ones: ").__comma(switches));
  659. $3=server;
  660. return $3;
  661. };
  662. popFront=(function(args){
  663. return smalltalk.withContext(function($ctx2) {
  664. front=_st(args)._first();
  665. front;
  666. _st(args)._remove_(front);
  667. return front;
  668. }, function($ctx2) {$ctx2.fillBlock({args:args},$ctx1)})});
  669. _st((function(){
  670. return smalltalk.withContext(function($ctx2) {
  671. return _st(options)._notEmpty();
  672. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileTrue_((function(){
  673. return smalltalk.withContext(function($ctx2) {
  674. optionName=_st(popFront)._value_(options);
  675. optionName;
  676. optionValue=_st(popFront)._value_(options);
  677. optionValue;
  678. $4=_st(switches)._includes_(optionName);
  679. if(smalltalk.assert($4)){
  680. optionName=_st(self)._selectorForCommandLineSwitch_(optionName);
  681. optionName;
  682. return _st(server)._perform_withArguments_(optionName,_st($Array())._with_(optionValue));
  683. } else {
  684. _st(console)._log_(_st(optionName).__comma(" is not a valid commandline option"));
  685. return _st(console)._log_(_st("Use any of the following ones: ").__comma(switches));
  686. };
  687. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  688. $5=server;
  689. return $5;
  690. }
  691. catch(e) {if(e===$early)return e[0]; throw e}
  692. }, function($ctx1) {$ctx1.fill(self,"createServerWithArguments:",{options:options,server:server,popFront:popFront,front:front,optionName:optionName,optionValue:optionValue,switches:switches},smalltalk.FileServer.klass)})},
  693. messageSends: ["commandLineSwitches", "new", "ifEmpty:", "ifFalse:", "log:", ",", "even", "size", "first", "remove:", "whileTrue:", "value:", "ifTrue:ifFalse:", "selectorForCommandLineSwitch:", "perform:withArguments:", "with:", "includes:", "notEmpty"]}),
  694. smalltalk.FileServer.klass);
  695. smalltalk.addMethod(
  696. smalltalk.method({
  697. selector: "defaultHost",
  698. fn: function (){
  699. var self=this;
  700. return smalltalk.withContext(function($ctx1) {
  701. return "127.0.0.1";
  702. }, function($ctx1) {$ctx1.fill(self,"defaultHost",{},smalltalk.FileServer.klass)})},
  703. messageSends: []}),
  704. smalltalk.FileServer.klass);
  705. smalltalk.addMethod(
  706. smalltalk.method({
  707. selector: "defaultMimeTypes",
  708. fn: function (){
  709. var self=this;
  710. return smalltalk.withContext(function($ctx1) {
  711. var $1;
  712. $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")]);
  713. return $1;
  714. }, function($ctx1) {$ctx1.fill(self,"defaultMimeTypes",{},smalltalk.FileServer.klass)})},
  715. messageSends: ["->"]}),
  716. smalltalk.FileServer.klass);
  717. smalltalk.addMethod(
  718. smalltalk.method({
  719. selector: "defaultPort",
  720. fn: function (){
  721. var self=this;
  722. return smalltalk.withContext(function($ctx1) {
  723. var $1;
  724. $1=(4000);
  725. return $1;
  726. }, function($ctx1) {$ctx1.fill(self,"defaultPort",{},smalltalk.FileServer.klass)})},
  727. messageSends: []}),
  728. smalltalk.FileServer.klass);
  729. smalltalk.addMethod(
  730. smalltalk.method({
  731. selector: "main",
  732. fn: function (){
  733. var self=this;
  734. var fileServer,args;
  735. function $FileServer(){return smalltalk.FileServer||(typeof FileServer=="undefined"?nil:FileServer)}
  736. return smalltalk.withContext(function($ctx1) {
  737. var $1,$2;
  738. var $early={};
  739. try {
  740. args=_st(process)._argv();
  741. _st(args)._removeFrom_to_((1),(3));
  742. _st(args)._detect_ifNone_((function(each){
  743. return smalltalk.withContext(function($ctx2) {
  744. $1=_st(each).__eq("--help");
  745. if(smalltalk.assert($1)){
  746. return _st($FileServer())._printHelp();
  747. };
  748. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  749. return smalltalk.withContext(function($ctx2) {
  750. fileServer=_st($FileServer())._createServerWithArguments_(args);
  751. fileServer;
  752. $2=_st(fileServer)._start();
  753. throw $early=[$2];
  754. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  755. return self}
  756. catch(e) {if(e===$early)return e[0]; throw e}
  757. }, function($ctx1) {$ctx1.fill(self,"main",{fileServer:fileServer,args:args},smalltalk.FileServer.klass)})},
  758. messageSends: ["argv", "removeFrom:to:", "detect:ifNone:", "ifTrue:", "printHelp", "=", "createServerWithArguments:", "start"]}),
  759. smalltalk.FileServer.klass);
  760. smalltalk.addMethod(
  761. smalltalk.method({
  762. selector: "mimeTypeFor:",
  763. fn: function (aString){
  764. var self=this;
  765. return smalltalk.withContext(function($ctx1) {
  766. var $1;
  767. $1=_st(_st(self)._mimeTypes())._at_ifAbsent_(_st(aString)._replace_with_(".*[\x5c.]",""),(function(){
  768. return smalltalk.withContext(function($ctx2) {
  769. return "text/plain";
  770. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  771. return $1;
  772. }, function($ctx1) {$ctx1.fill(self,"mimeTypeFor:",{aString:aString},smalltalk.FileServer.klass)})},
  773. messageSends: ["at:ifAbsent:", "replace:with:", "mimeTypes"]}),
  774. smalltalk.FileServer.klass);
  775. smalltalk.addMethod(
  776. smalltalk.method({
  777. selector: "mimeTypes",
  778. fn: function (){
  779. var self=this;
  780. return smalltalk.withContext(function($ctx1) {
  781. var $2,$1;
  782. $2=self["@mimeTypes"];
  783. if(($receiver = $2) == nil || $receiver == undefined){
  784. self["@mimeTypes"]=_st(self)._defaultMimeTypes();
  785. $1=self["@mimeTypes"];
  786. } else {
  787. $1=$2;
  788. };
  789. return $1;
  790. }, function($ctx1) {$ctx1.fill(self,"mimeTypes",{},smalltalk.FileServer.klass)})},
  791. messageSends: ["ifNil:", "defaultMimeTypes"]}),
  792. smalltalk.FileServer.klass);
  793. smalltalk.addMethod(
  794. smalltalk.method({
  795. selector: "printHelp",
  796. fn: function (){
  797. var self=this;
  798. return smalltalk.withContext(function($ctx1) {
  799. _st(console)._log_("Available commandline options are:");
  800. _st(console)._log_("--help");
  801. _st(_st(self)._commandLineSwitches())._do_((function(each){
  802. return smalltalk.withContext(function($ctx2) {
  803. return _st(console)._log_(_st(each).__comma(" <parameter>"));
  804. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  805. return self}, function($ctx1) {$ctx1.fill(self,"printHelp",{},smalltalk.FileServer.klass)})},
  806. messageSends: ["log:", "do:", ",", "commandLineSwitches"]}),
  807. smalltalk.FileServer.klass);
  808. smalltalk.addMethod(
  809. smalltalk.method({
  810. selector: "selectorForCommandLineSwitch:",
  811. fn: function (aSwitch){
  812. var self=this;
  813. return smalltalk.withContext(function($ctx1) {
  814. var $1;
  815. $1=_st(_st(_st(aSwitch)._replace_with_("^--",""))._replace_with_("-[a-z]",(function(each){
  816. return smalltalk.withContext(function($ctx2) {
  817. return _st(_st(each)._second())._asUppercase();
  818. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}))).__comma(":");
  819. return $1;
  820. }, function($ctx1) {$ctx1.fill(self,"selectorForCommandLineSwitch:",{aSwitch:aSwitch},smalltalk.FileServer.klass)})},
  821. messageSends: [",", "replace:with:", "asUppercase", "second"]}),
  822. smalltalk.FileServer.klass);
  823. smalltalk.addClass('Repl', smalltalk.Object, ['readline', 'interface', 'util'], 'AmberCli');
  824. smalltalk.addMethod(
  825. smalltalk.method({
  826. selector: "close",
  827. fn: function (){
  828. var self=this;
  829. return smalltalk.withContext(function($ctx1) {
  830. _st(_st(process)._stdin())._destroy();
  831. return self}, function($ctx1) {$ctx1.fill(self,"close",{},smalltalk.Repl)})},
  832. messageSends: ["destroy", "stdin"]}),
  833. smalltalk.Repl);
  834. smalltalk.addMethod(
  835. smalltalk.method({
  836. selector: "createInterface",
  837. fn: function (){
  838. var self=this;
  839. return smalltalk.withContext(function($ctx1) {
  840. self["@interface"]=_st(self["@readline"])._createInterface_stdout_(_st(process)._stdin(),_st(process)._stdout());
  841. _st(self["@interface"])._on_do_("line",(function(buffer){
  842. return smalltalk.withContext(function($ctx2) {
  843. return _st(self)._eval_(buffer);
  844. }, function($ctx2) {$ctx2.fillBlock({buffer:buffer},$ctx1)})}));
  845. _st(self["@interface"])._on_do_("close",(function(){
  846. return smalltalk.withContext(function($ctx2) {
  847. return _st(self)._close();
  848. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  849. _st(self)._setPrompt();
  850. _st(self["@interface"])._prompt();
  851. return self}, function($ctx1) {$ctx1.fill(self,"createInterface",{},smalltalk.Repl)})},
  852. messageSends: ["createInterface:stdout:", "stdin", "stdout", "on:do:", "eval:", "close", "setPrompt", "prompt"]}),
  853. smalltalk.Repl);
  854. smalltalk.addMethod(
  855. smalltalk.method({
  856. selector: "eval:",
  857. fn: function (buffer){
  858. var self=this;
  859. var result;
  860. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  861. function $Transcript(){return smalltalk.Transcript||(typeof Transcript=="undefined"?nil:Transcript)}
  862. function $ErrorHandler(){return smalltalk.ErrorHandler||(typeof ErrorHandler=="undefined"?nil:ErrorHandler)}
  863. return smalltalk.withContext(function($ctx1) {
  864. var $1,$2;
  865. $1=_st(buffer)._isEmpty();
  866. if(! smalltalk.assert($1)){
  867. _st(self)._try_catch_((function(){
  868. return smalltalk.withContext(function($ctx2) {
  869. result=_st(_st($Compiler())._new())._evaluateExpression_(buffer);
  870. result;
  871. return _st($Transcript())._show_(result);
  872. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(function(e){
  873. return smalltalk.withContext(function($ctx2) {
  874. $2=_st(e)._isSmalltalkError();
  875. if(smalltalk.assert($2)){
  876. return _st(_st($ErrorHandler())._new())._handleError_(e);
  877. } else {
  878. return _st(_st(process)._stdout())._write_(_st(e)._jsStack());
  879. };
  880. }, function($ctx2) {$ctx2.fillBlock({e:e},$ctx1)})}));
  881. };
  882. _st(self["@interface"])._prompt();
  883. return self}, function($ctx1) {$ctx1.fill(self,"eval:",{buffer:buffer,result:result},smalltalk.Repl)})},
  884. messageSends: ["ifFalse:", "try:catch:", "evaluateExpression:", "new", "show:", "ifTrue:ifFalse:", "handleError:", "write:", "jsStack", "stdout", "isSmalltalkError", "isEmpty", "prompt"]}),
  885. smalltalk.Repl);
  886. smalltalk.addMethod(
  887. smalltalk.method({
  888. selector: "initialize",
  889. fn: function (){
  890. var self=this;
  891. return smalltalk.withContext(function($ctx1) {
  892. smalltalk.Object.fn.prototype._initialize.apply(_st(self), []);
  893. self["@readline"]=_st(require)._value_("readline");
  894. self["@util"]=_st(require)._value_("util");
  895. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.Repl)})},
  896. messageSends: ["initialize", "value:"]}),
  897. smalltalk.Repl);
  898. smalltalk.addMethod(
  899. smalltalk.method({
  900. selector: "prompt",
  901. fn: function (){
  902. var self=this;
  903. return smalltalk.withContext(function($ctx1) {
  904. return "amber >> ";
  905. }, function($ctx1) {$ctx1.fill(self,"prompt",{},smalltalk.Repl)})},
  906. messageSends: []}),
  907. smalltalk.Repl);
  908. smalltalk.addMethod(
  909. smalltalk.method({
  910. selector: "setPrompt",
  911. fn: function (){
  912. var self=this;
  913. return smalltalk.withContext(function($ctx1) {
  914. _st(self["@interface"])._setPrompt_(_st(self)._prompt());
  915. return self}, function($ctx1) {$ctx1.fill(self,"setPrompt",{},smalltalk.Repl)})},
  916. messageSends: ["setPrompt:", "prompt"]}),
  917. smalltalk.Repl);
  918. smalltalk.addMethod(
  919. smalltalk.method({
  920. selector: "main",
  921. fn: function (){
  922. var self=this;
  923. return smalltalk.withContext(function($ctx1) {
  924. _st(_st(self)._new())._createInterface();
  925. return self}, function($ctx1) {$ctx1.fill(self,"main",{},smalltalk.Repl.klass)})},
  926. messageSends: ["createInterface", "new"]}),
  927. smalltalk.Repl.klass);