AmberCli.deploy.js 55 KB

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