AmberCli.js 89 KB

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