2984fab606909e16083d98c4581fd484.js 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626
  1. "no use strict";
  2. !(function(window) {
  3. if (typeof window.window != "undefined" && window.document)
  4. return;
  5. if (window.require && window.define)
  6. return;
  7. if (!window.console) {
  8. window.console = function() {
  9. var msgs = Array.prototype.slice.call(arguments, 0);
  10. postMessage({type: "log", data: msgs});
  11. };
  12. window.console.error =
  13. window.console.warn =
  14. window.console.log =
  15. window.console.trace = window.console;
  16. }
  17. window.window = window;
  18. window.ace = window;
  19. window.onerror = function(message, file, line, col, err) {
  20. postMessage({type: "error", data: {
  21. message: message,
  22. data: err && err.data,
  23. file: file,
  24. line: line,
  25. col: col,
  26. stack: err && err.stack
  27. }});
  28. };
  29. window.normalizeModule = function(parentId, moduleName) {
  30. // normalize plugin requires
  31. if (moduleName.indexOf("!") !== -1) {
  32. var chunks = moduleName.split("!");
  33. return window.normalizeModule(parentId, chunks[0]) + "!" + window.normalizeModule(parentId, chunks[1]);
  34. }
  35. // normalize relative requires
  36. if (moduleName.charAt(0) == ".") {
  37. var base = parentId.split("/").slice(0, -1).join("/");
  38. moduleName = (base ? base + "/" : "") + moduleName;
  39. while (moduleName.indexOf(".") !== -1 && previous != moduleName) {
  40. var previous = moduleName;
  41. moduleName = moduleName.replace(/^\.\//, "").replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
  42. }
  43. }
  44. return moduleName;
  45. };
  46. window.require = function require(parentId, id) {
  47. if (!id) {
  48. id = parentId;
  49. parentId = null;
  50. }
  51. if (!id.charAt)
  52. throw new Error("worker.js require() accepts only (parentId, id) as arguments");
  53. id = window.normalizeModule(parentId, id);
  54. var module = window.require.modules[id];
  55. if (module) {
  56. if (!module.initialized) {
  57. module.initialized = true;
  58. module.exports = module.factory().exports;
  59. }
  60. return module.exports;
  61. }
  62. if (!window.require.tlns)
  63. return console.log("unable to load " + id);
  64. var path = resolveModuleId(id, window.require.tlns);
  65. if (path.slice(-3) != ".js") path += ".js";
  66. window.require.id = id;
  67. window.require.modules[id] = {}; // prevent infinite loop on broken modules
  68. importScripts(path);
  69. return window.require(parentId, id);
  70. };
  71. function resolveModuleId(id, paths) {
  72. var testPath = id, tail = "";
  73. while (testPath) {
  74. var alias = paths[testPath];
  75. if (typeof alias == "string") {
  76. return alias + tail;
  77. } else if (alias) {
  78. return alias.location.replace(/\/*$/, "/") + (tail || alias.main || alias.name);
  79. } else if (alias === false) {
  80. return "";
  81. }
  82. var i = testPath.lastIndexOf("/");
  83. if (i === -1) break;
  84. tail = testPath.substr(i) + tail;
  85. testPath = testPath.slice(0, i);
  86. }
  87. return id;
  88. }
  89. window.require.modules = {};
  90. window.require.tlns = {};
  91. window.define = function(id, deps, factory) {
  92. if (arguments.length == 2) {
  93. factory = deps;
  94. if (typeof id != "string") {
  95. deps = id;
  96. id = window.require.id;
  97. }
  98. } else if (arguments.length == 1) {
  99. factory = id;
  100. deps = [];
  101. id = window.require.id;
  102. }
  103. if (typeof factory != "function") {
  104. window.require.modules[id] = {
  105. exports: factory,
  106. initialized: true
  107. };
  108. return;
  109. }
  110. if (!deps.length)
  111. // If there is no dependencies, we inject "require", "exports" and
  112. // "module" as dependencies, to provide CommonJS compatibility.
  113. deps = ["require", "exports", "module"];
  114. var req = function(childId) {
  115. return window.require(id, childId);
  116. };
  117. window.require.modules[id] = {
  118. exports: {},
  119. factory: function() {
  120. var module = this;
  121. var returnExports = factory.apply(this, deps.slice(0, factory.length).map(function(dep) {
  122. switch (dep) {
  123. // Because "require", "exports" and "module" aren't actual
  124. // dependencies, we must handle them seperately.
  125. case "require": return req;
  126. case "exports": return module.exports;
  127. case "module": return module;
  128. // But for all other dependencies, we can just go ahead and
  129. // require them.
  130. default: return req(dep);
  131. }
  132. }));
  133. if (returnExports)
  134. module.exports = returnExports;
  135. return module;
  136. }
  137. };
  138. };
  139. window.define.amd = {};
  140. window.require.tlns = {};
  141. window.initBaseUrls = function initBaseUrls(topLevelNamespaces) {
  142. for (var i in topLevelNamespaces)
  143. this.require.tlns[i] = topLevelNamespaces[i];
  144. };
  145. window.initSender = function initSender() {
  146. var EventEmitter = window.require("ace/lib/event_emitter").EventEmitter;
  147. var oop = window.require("ace/lib/oop");
  148. var Sender = function() {};
  149. (function() {
  150. oop.implement(this, EventEmitter);
  151. this.callback = function(data, callbackId) {
  152. postMessage({
  153. type: "call",
  154. id: callbackId,
  155. data: data
  156. });
  157. };
  158. this.emit = function(name, data) {
  159. postMessage({
  160. type: "event",
  161. name: name,
  162. data: data
  163. });
  164. };
  165. }).call(Sender.prototype);
  166. return new Sender();
  167. };
  168. var main = window.main = null;
  169. var sender = window.sender = null;
  170. window.onmessage = function(e) {
  171. var msg = e.data;
  172. if (msg.event && sender) {
  173. sender._signal(msg.event, msg.data);
  174. }
  175. else if (msg.command) {
  176. if (main[msg.command])
  177. main[msg.command].apply(main, msg.args);
  178. else if (window[msg.command])
  179. window[msg.command].apply(window, msg.args);
  180. else
  181. throw new Error("Unknown command:" + msg.command);
  182. }
  183. else if (msg.init) {
  184. window.initBaseUrls(msg.tlns);
  185. sender = window.sender = window.initSender();
  186. var clazz = this.require(msg.module)[msg.classname];
  187. main = window.main = new clazz(sender);
  188. }
  189. };
  190. })(this);
  191. ace.define("ace/lib/oop",[], function(require, exports, module){"use strict";
  192. exports.inherits = function (ctor, superCtor) {
  193. ctor.super_ = superCtor;
  194. ctor.prototype = Object.create(superCtor.prototype, {
  195. constructor: {
  196. value: ctor,
  197. enumerable: false,
  198. writable: true,
  199. configurable: true
  200. }
  201. });
  202. };
  203. exports.mixin = function (obj, mixin) {
  204. for (var key in mixin) {
  205. obj[key] = mixin[key];
  206. }
  207. return obj;
  208. };
  209. exports.implement = function (proto, mixin) {
  210. exports.mixin(proto, mixin);
  211. };
  212. });
  213. ace.define("ace/apply_delta",[], function(require, exports, module){"use strict";
  214. function throwDeltaError(delta, errorText) {
  215. console.log("Invalid Delta:", delta);
  216. throw "Invalid Delta: " + errorText;
  217. }
  218. function positionInDocument(docLines, position) {
  219. return position.row >= 0 && position.row < docLines.length &&
  220. position.column >= 0 && position.column <= docLines[position.row].length;
  221. }
  222. function validateDelta(docLines, delta) {
  223. if (delta.action != "insert" && delta.action != "remove")
  224. throwDeltaError(delta, "delta.action must be 'insert' or 'remove'");
  225. if (!(delta.lines instanceof Array))
  226. throwDeltaError(delta, "delta.lines must be an Array");
  227. if (!delta.start || !delta.end)
  228. throwDeltaError(delta, "delta.start/end must be an present");
  229. var start = delta.start;
  230. if (!positionInDocument(docLines, delta.start))
  231. throwDeltaError(delta, "delta.start must be contained in document");
  232. var end = delta.end;
  233. if (delta.action == "remove" && !positionInDocument(docLines, end))
  234. throwDeltaError(delta, "delta.end must contained in document for 'remove' actions");
  235. var numRangeRows = end.row - start.row;
  236. var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0));
  237. if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars)
  238. throwDeltaError(delta, "delta.range must match delta lines");
  239. }
  240. exports.applyDelta = function (docLines, delta, doNotValidate) {
  241. var row = delta.start.row;
  242. var startColumn = delta.start.column;
  243. var line = docLines[row] || "";
  244. switch (delta.action) {
  245. case "insert":
  246. var lines = delta.lines;
  247. if (lines.length === 1) {
  248. docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
  249. }
  250. else {
  251. var args = [row, 1].concat(delta.lines);
  252. docLines.splice.apply(docLines, args);
  253. docLines[row] = line.substring(0, startColumn) + docLines[row];
  254. docLines[row + delta.lines.length - 1] += line.substring(startColumn);
  255. }
  256. break;
  257. case "remove":
  258. var endColumn = delta.end.column;
  259. var endRow = delta.end.row;
  260. if (row === endRow) {
  261. docLines[row] = line.substring(0, startColumn) + line.substring(endColumn);
  262. }
  263. else {
  264. docLines.splice(row, endRow - row + 1, line.substring(0, startColumn) + docLines[endRow].substring(endColumn));
  265. }
  266. break;
  267. }
  268. };
  269. });
  270. ace.define("ace/lib/event_emitter",[], function(require, exports, module){"use strict";
  271. var EventEmitter = {};
  272. var stopPropagation = function () { this.propagationStopped = true; };
  273. var preventDefault = function () { this.defaultPrevented = true; };
  274. EventEmitter._emit =
  275. EventEmitter._dispatchEvent = function (eventName, e) {
  276. this._eventRegistry || (this._eventRegistry = {});
  277. this._defaultHandlers || (this._defaultHandlers = {});
  278. var listeners = this._eventRegistry[eventName] || [];
  279. var defaultHandler = this._defaultHandlers[eventName];
  280. if (!listeners.length && !defaultHandler)
  281. return;
  282. if (typeof e != "object" || !e)
  283. e = {};
  284. if (!e.type)
  285. e.type = eventName;
  286. if (!e.stopPropagation)
  287. e.stopPropagation = stopPropagation;
  288. if (!e.preventDefault)
  289. e.preventDefault = preventDefault;
  290. listeners = listeners.slice();
  291. for (var i = 0; i < listeners.length; i++) {
  292. listeners[i](e, this);
  293. if (e.propagationStopped)
  294. break;
  295. }
  296. if (defaultHandler && !e.defaultPrevented)
  297. return defaultHandler(e, this);
  298. };
  299. EventEmitter._signal = function (eventName, e) {
  300. var listeners = (this._eventRegistry || {})[eventName];
  301. if (!listeners)
  302. return;
  303. listeners = listeners.slice();
  304. for (var i = 0; i < listeners.length; i++)
  305. listeners[i](e, this);
  306. };
  307. EventEmitter.once = function (eventName, callback) {
  308. var _self = this;
  309. this.on(eventName, function newCallback() {
  310. _self.off(eventName, newCallback);
  311. callback.apply(null, arguments);
  312. });
  313. if (!callback) {
  314. return new Promise(function (resolve) {
  315. callback = resolve;
  316. });
  317. }
  318. };
  319. EventEmitter.setDefaultHandler = function (eventName, callback) {
  320. var handlers = this._defaultHandlers;
  321. if (!handlers)
  322. handlers = this._defaultHandlers = { _disabled_: {} };
  323. if (handlers[eventName]) {
  324. var old = handlers[eventName];
  325. var disabled = handlers._disabled_[eventName];
  326. if (!disabled)
  327. handlers._disabled_[eventName] = disabled = [];
  328. disabled.push(old);
  329. var i = disabled.indexOf(callback);
  330. if (i != -1)
  331. disabled.splice(i, 1);
  332. }
  333. handlers[eventName] = callback;
  334. };
  335. EventEmitter.removeDefaultHandler = function (eventName, callback) {
  336. var handlers = this._defaultHandlers;
  337. if (!handlers)
  338. return;
  339. var disabled = handlers._disabled_[eventName];
  340. if (handlers[eventName] == callback) {
  341. if (disabled)
  342. this.setDefaultHandler(eventName, disabled.pop());
  343. }
  344. else if (disabled) {
  345. var i = disabled.indexOf(callback);
  346. if (i != -1)
  347. disabled.splice(i, 1);
  348. }
  349. };
  350. EventEmitter.on =
  351. EventEmitter.addEventListener = function (eventName, callback, capturing) {
  352. this._eventRegistry = this._eventRegistry || {};
  353. var listeners = this._eventRegistry[eventName];
  354. if (!listeners)
  355. listeners = this._eventRegistry[eventName] = [];
  356. if (listeners.indexOf(callback) == -1)
  357. listeners[capturing ? "unshift" : "push"](callback);
  358. return callback;
  359. };
  360. EventEmitter.off =
  361. EventEmitter.removeListener =
  362. EventEmitter.removeEventListener = function (eventName, callback) {
  363. this._eventRegistry = this._eventRegistry || {};
  364. var listeners = this._eventRegistry[eventName];
  365. if (!listeners)
  366. return;
  367. var index = listeners.indexOf(callback);
  368. if (index !== -1)
  369. listeners.splice(index, 1);
  370. };
  371. EventEmitter.removeAllListeners = function (eventName) {
  372. if (!eventName)
  373. this._eventRegistry = this._defaultHandlers = undefined;
  374. if (this._eventRegistry)
  375. this._eventRegistry[eventName] = undefined;
  376. if (this._defaultHandlers)
  377. this._defaultHandlers[eventName] = undefined;
  378. };
  379. exports.EventEmitter = EventEmitter;
  380. });
  381. ace.define("ace/range",[], function(require, exports, module){"use strict";
  382. var Range = /** @class */ (function () {
  383. function Range(startRow, startColumn, endRow, endColumn) {
  384. this.start = {
  385. row: startRow,
  386. column: startColumn
  387. };
  388. this.end = {
  389. row: endRow,
  390. column: endColumn
  391. };
  392. }
  393. Range.prototype.isEqual = function (range) {
  394. return this.start.row === range.start.row &&
  395. this.end.row === range.end.row &&
  396. this.start.column === range.start.column &&
  397. this.end.column === range.end.column;
  398. };
  399. Range.prototype.toString = function () {
  400. return ("Range: [" + this.start.row + "/" + this.start.column +
  401. "] -> [" + this.end.row + "/" + this.end.column + "]");
  402. };
  403. Range.prototype.contains = function (row, column) {
  404. return this.compare(row, column) == 0;
  405. };
  406. Range.prototype.compareRange = function (range) {
  407. var cmp, end = range.end, start = range.start;
  408. cmp = this.compare(end.row, end.column);
  409. if (cmp == 1) {
  410. cmp = this.compare(start.row, start.column);
  411. if (cmp == 1) {
  412. return 2;
  413. }
  414. else if (cmp == 0) {
  415. return 1;
  416. }
  417. else {
  418. return 0;
  419. }
  420. }
  421. else if (cmp == -1) {
  422. return -2;
  423. }
  424. else {
  425. cmp = this.compare(start.row, start.column);
  426. if (cmp == -1) {
  427. return -1;
  428. }
  429. else if (cmp == 1) {
  430. return 42;
  431. }
  432. else {
  433. return 0;
  434. }
  435. }
  436. };
  437. Range.prototype.comparePoint = function (p) {
  438. return this.compare(p.row, p.column);
  439. };
  440. Range.prototype.containsRange = function (range) {
  441. return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
  442. };
  443. Range.prototype.intersects = function (range) {
  444. var cmp = this.compareRange(range);
  445. return (cmp == -1 || cmp == 0 || cmp == 1);
  446. };
  447. Range.prototype.isEnd = function (row, column) {
  448. return this.end.row == row && this.end.column == column;
  449. };
  450. Range.prototype.isStart = function (row, column) {
  451. return this.start.row == row && this.start.column == column;
  452. };
  453. Range.prototype.setStart = function (row, column) {
  454. if (typeof row == "object") {
  455. this.start.column = row.column;
  456. this.start.row = row.row;
  457. }
  458. else {
  459. this.start.row = row;
  460. this.start.column = column;
  461. }
  462. };
  463. Range.prototype.setEnd = function (row, column) {
  464. if (typeof row == "object") {
  465. this.end.column = row.column;
  466. this.end.row = row.row;
  467. }
  468. else {
  469. this.end.row = row;
  470. this.end.column = column;
  471. }
  472. };
  473. Range.prototype.inside = function (row, column) {
  474. if (this.compare(row, column) == 0) {
  475. if (this.isEnd(row, column) || this.isStart(row, column)) {
  476. return false;
  477. }
  478. else {
  479. return true;
  480. }
  481. }
  482. return false;
  483. };
  484. Range.prototype.insideStart = function (row, column) {
  485. if (this.compare(row, column) == 0) {
  486. if (this.isEnd(row, column)) {
  487. return false;
  488. }
  489. else {
  490. return true;
  491. }
  492. }
  493. return false;
  494. };
  495. Range.prototype.insideEnd = function (row, column) {
  496. if (this.compare(row, column) == 0) {
  497. if (this.isStart(row, column)) {
  498. return false;
  499. }
  500. else {
  501. return true;
  502. }
  503. }
  504. return false;
  505. };
  506. Range.prototype.compare = function (row, column) {
  507. if (!this.isMultiLine()) {
  508. if (row === this.start.row) {
  509. return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
  510. }
  511. }
  512. if (row < this.start.row)
  513. return -1;
  514. if (row > this.end.row)
  515. return 1;
  516. if (this.start.row === row)
  517. return column >= this.start.column ? 0 : -1;
  518. if (this.end.row === row)
  519. return column <= this.end.column ? 0 : 1;
  520. return 0;
  521. };
  522. Range.prototype.compareStart = function (row, column) {
  523. if (this.start.row == row && this.start.column == column) {
  524. return -1;
  525. }
  526. else {
  527. return this.compare(row, column);
  528. }
  529. };
  530. Range.prototype.compareEnd = function (row, column) {
  531. if (this.end.row == row && this.end.column == column) {
  532. return 1;
  533. }
  534. else {
  535. return this.compare(row, column);
  536. }
  537. };
  538. Range.prototype.compareInside = function (row, column) {
  539. if (this.end.row == row && this.end.column == column) {
  540. return 1;
  541. }
  542. else if (this.start.row == row && this.start.column == column) {
  543. return -1;
  544. }
  545. else {
  546. return this.compare(row, column);
  547. }
  548. };
  549. Range.prototype.clipRows = function (firstRow, lastRow) {
  550. if (this.end.row > lastRow)
  551. var end = { row: lastRow + 1, column: 0 };
  552. else if (this.end.row < firstRow)
  553. var end = { row: firstRow, column: 0 };
  554. if (this.start.row > lastRow)
  555. var start = { row: lastRow + 1, column: 0 };
  556. else if (this.start.row < firstRow)
  557. var start = { row: firstRow, column: 0 };
  558. return Range.fromPoints(start || this.start, end || this.end);
  559. };
  560. Range.prototype.extend = function (row, column) {
  561. var cmp = this.compare(row, column);
  562. if (cmp == 0)
  563. return this;
  564. else if (cmp == -1)
  565. var start = { row: row, column: column };
  566. else
  567. var end = { row: row, column: column };
  568. return Range.fromPoints(start || this.start, end || this.end);
  569. };
  570. Range.prototype.isEmpty = function () {
  571. return (this.start.row === this.end.row && this.start.column === this.end.column);
  572. };
  573. Range.prototype.isMultiLine = function () {
  574. return (this.start.row !== this.end.row);
  575. };
  576. Range.prototype.clone = function () {
  577. return Range.fromPoints(this.start, this.end);
  578. };
  579. Range.prototype.collapseRows = function () {
  580. if (this.end.column == 0)
  581. return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row - 1), 0);
  582. else
  583. return new Range(this.start.row, 0, this.end.row, 0);
  584. };
  585. Range.prototype.toScreenRange = function (session) {
  586. var screenPosStart = session.documentToScreenPosition(this.start);
  587. var screenPosEnd = session.documentToScreenPosition(this.end);
  588. return new Range(screenPosStart.row, screenPosStart.column, screenPosEnd.row, screenPosEnd.column);
  589. };
  590. Range.prototype.moveBy = function (row, column) {
  591. this.start.row += row;
  592. this.start.column += column;
  593. this.end.row += row;
  594. this.end.column += column;
  595. };
  596. return Range;
  597. }());
  598. Range.fromPoints = function (start, end) {
  599. return new Range(start.row, start.column, end.row, end.column);
  600. };
  601. Range.comparePoints = function (p1, p2) {
  602. return p1.row - p2.row || p1.column - p2.column;
  603. };
  604. exports.Range = Range;
  605. });
  606. ace.define("ace/anchor",[], function(require, exports, module){"use strict";
  607. var oop = require("./lib/oop");
  608. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  609. var Anchor = /** @class */ (function () {
  610. function Anchor(doc, row, column) {
  611. this.$onChange = this.onChange.bind(this);
  612. this.attach(doc);
  613. if (typeof row != "number")
  614. this.setPosition(row.row, row.column);
  615. else
  616. this.setPosition(row, column);
  617. }
  618. Anchor.prototype.getPosition = function () {
  619. return this.$clipPositionToDocument(this.row, this.column);
  620. };
  621. Anchor.prototype.getDocument = function () {
  622. return this.document;
  623. };
  624. Anchor.prototype.onChange = function (delta) {
  625. if (delta.start.row == delta.end.row && delta.start.row != this.row)
  626. return;
  627. if (delta.start.row > this.row)
  628. return;
  629. var point = $getTransformedPoint(delta, { row: this.row, column: this.column }, this.$insertRight);
  630. this.setPosition(point.row, point.column, true);
  631. };
  632. Anchor.prototype.setPosition = function (row, column, noClip) {
  633. var pos;
  634. if (noClip) {
  635. pos = {
  636. row: row,
  637. column: column
  638. };
  639. }
  640. else {
  641. pos = this.$clipPositionToDocument(row, column);
  642. }
  643. if (this.row == pos.row && this.column == pos.column)
  644. return;
  645. var old = {
  646. row: this.row,
  647. column: this.column
  648. };
  649. this.row = pos.row;
  650. this.column = pos.column;
  651. this._signal("change", {
  652. old: old,
  653. value: pos
  654. });
  655. };
  656. Anchor.prototype.detach = function () {
  657. this.document.off("change", this.$onChange);
  658. };
  659. Anchor.prototype.attach = function (doc) {
  660. this.document = doc || this.document;
  661. this.document.on("change", this.$onChange);
  662. };
  663. Anchor.prototype.$clipPositionToDocument = function (row, column) {
  664. var pos = {};
  665. if (row >= this.document.getLength()) {
  666. pos.row = Math.max(0, this.document.getLength() - 1);
  667. pos.column = this.document.getLine(pos.row).length;
  668. }
  669. else if (row < 0) {
  670. pos.row = 0;
  671. pos.column = 0;
  672. }
  673. else {
  674. pos.row = row;
  675. pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
  676. }
  677. if (column < 0)
  678. pos.column = 0;
  679. return pos;
  680. };
  681. return Anchor;
  682. }());
  683. Anchor.prototype.$insertRight = false;
  684. oop.implement(Anchor.prototype, EventEmitter);
  685. function $pointsInOrder(point1, point2, equalPointsInOrder) {
  686. var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column;
  687. return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter);
  688. }
  689. function $getTransformedPoint(delta, point, moveIfEqual) {
  690. var deltaIsInsert = delta.action == "insert";
  691. var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row);
  692. var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column);
  693. var deltaStart = delta.start;
  694. var deltaEnd = deltaIsInsert ? deltaStart : delta.end; // Collapse insert range.
  695. if ($pointsInOrder(point, deltaStart, moveIfEqual)) {
  696. return {
  697. row: point.row,
  698. column: point.column
  699. };
  700. }
  701. if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) {
  702. return {
  703. row: point.row + deltaRowShift,
  704. column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0)
  705. };
  706. }
  707. return {
  708. row: deltaStart.row,
  709. column: deltaStart.column
  710. };
  711. }
  712. exports.Anchor = Anchor;
  713. });
  714. ace.define("ace/document",[], function(require, exports, module){"use strict";
  715. var oop = require("./lib/oop");
  716. var applyDelta = require("./apply_delta").applyDelta;
  717. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  718. var Range = require("./range").Range;
  719. var Anchor = require("./anchor").Anchor;
  720. var Document = /** @class */ (function () {
  721. function Document(textOrLines) {
  722. this.$lines = [""];
  723. if (textOrLines.length === 0) {
  724. this.$lines = [""];
  725. }
  726. else if (Array.isArray(textOrLines)) {
  727. this.insertMergedLines({ row: 0, column: 0 }, textOrLines);
  728. }
  729. else {
  730. this.insert({ row: 0, column: 0 }, textOrLines);
  731. }
  732. }
  733. Document.prototype.setValue = function (text) {
  734. var len = this.getLength() - 1;
  735. this.remove(new Range(0, 0, len, this.getLine(len).length));
  736. this.insert({ row: 0, column: 0 }, text || "");
  737. };
  738. Document.prototype.getValue = function () {
  739. return this.getAllLines().join(this.getNewLineCharacter());
  740. };
  741. Document.prototype.createAnchor = function (row, column) {
  742. return new Anchor(this, row, column);
  743. };
  744. Document.prototype.$detectNewLine = function (text) {
  745. var match = text.match(/^.*?(\r\n|\r|\n)/m);
  746. this.$autoNewLine = match ? match[1] : "\n";
  747. this._signal("changeNewLineMode");
  748. };
  749. Document.prototype.getNewLineCharacter = function () {
  750. switch (this.$newLineMode) {
  751. case "windows":
  752. return "\r\n";
  753. case "unix":
  754. return "\n";
  755. default:
  756. return this.$autoNewLine || "\n";
  757. }
  758. };
  759. Document.prototype.setNewLineMode = function (newLineMode) {
  760. if (this.$newLineMode === newLineMode)
  761. return;
  762. this.$newLineMode = newLineMode;
  763. this._signal("changeNewLineMode");
  764. };
  765. Document.prototype.getNewLineMode = function () {
  766. return this.$newLineMode;
  767. };
  768. Document.prototype.isNewLine = function (text) {
  769. return (text == "\r\n" || text == "\r" || text == "\n");
  770. };
  771. Document.prototype.getLine = function (row) {
  772. return this.$lines[row] || "";
  773. };
  774. Document.prototype.getLines = function (firstRow, lastRow) {
  775. return this.$lines.slice(firstRow, lastRow + 1);
  776. };
  777. Document.prototype.getAllLines = function () {
  778. return this.getLines(0, this.getLength());
  779. };
  780. Document.prototype.getLength = function () {
  781. return this.$lines.length;
  782. };
  783. Document.prototype.getTextRange = function (range) {
  784. return this.getLinesForRange(range).join(this.getNewLineCharacter());
  785. };
  786. Document.prototype.getLinesForRange = function (range) {
  787. var lines;
  788. if (range.start.row === range.end.row) {
  789. lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)];
  790. }
  791. else {
  792. lines = this.getLines(range.start.row, range.end.row);
  793. lines[0] = (lines[0] || "").substring(range.start.column);
  794. var l = lines.length - 1;
  795. if (range.end.row - range.start.row == l)
  796. lines[l] = lines[l].substring(0, range.end.column);
  797. }
  798. return lines;
  799. };
  800. Document.prototype.insertLines = function (row, lines) {
  801. console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead.");
  802. return this.insertFullLines(row, lines);
  803. };
  804. Document.prototype.removeLines = function (firstRow, lastRow) {
  805. console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead.");
  806. return this.removeFullLines(firstRow, lastRow);
  807. };
  808. Document.prototype.insertNewLine = function (position) {
  809. console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead.");
  810. return this.insertMergedLines(position, ["", ""]);
  811. };
  812. Document.prototype.insert = function (position, text) {
  813. if (this.getLength() <= 1)
  814. this.$detectNewLine(text);
  815. return this.insertMergedLines(position, this.$split(text));
  816. };
  817. Document.prototype.insertInLine = function (position, text) {
  818. var start = this.clippedPos(position.row, position.column);
  819. var end = this.pos(position.row, position.column + text.length);
  820. this.applyDelta({
  821. start: start,
  822. end: end,
  823. action: "insert",
  824. lines: [text]
  825. }, true);
  826. return this.clonePos(end);
  827. };
  828. Document.prototype.clippedPos = function (row, column) {
  829. var length = this.getLength();
  830. if (row === undefined) {
  831. row = length;
  832. }
  833. else if (row < 0) {
  834. row = 0;
  835. }
  836. else if (row >= length) {
  837. row = length - 1;
  838. column = undefined;
  839. }
  840. var line = this.getLine(row);
  841. if (column == undefined)
  842. column = line.length;
  843. column = Math.min(Math.max(column, 0), line.length);
  844. return { row: row, column: column };
  845. };
  846. Document.prototype.clonePos = function (pos) {
  847. return { row: pos.row, column: pos.column };
  848. };
  849. Document.prototype.pos = function (row, column) {
  850. return { row: row, column: column };
  851. };
  852. Document.prototype.$clipPosition = function (position) {
  853. var length = this.getLength();
  854. if (position.row >= length) {
  855. position.row = Math.max(0, length - 1);
  856. position.column = this.getLine(length - 1).length;
  857. }
  858. else {
  859. position.row = Math.max(0, position.row);
  860. position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length);
  861. }
  862. return position;
  863. };
  864. Document.prototype.insertFullLines = function (row, lines) {
  865. row = Math.min(Math.max(row, 0), this.getLength());
  866. var column = 0;
  867. if (row < this.getLength()) {
  868. lines = lines.concat([""]);
  869. column = 0;
  870. }
  871. else {
  872. lines = [""].concat(lines);
  873. row--;
  874. column = this.$lines[row].length;
  875. }
  876. this.insertMergedLines({ row: row, column: column }, lines);
  877. };
  878. Document.prototype.insertMergedLines = function (position, lines) {
  879. var start = this.clippedPos(position.row, position.column);
  880. var end = {
  881. row: start.row + lines.length - 1,
  882. column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length
  883. };
  884. this.applyDelta({
  885. start: start,
  886. end: end,
  887. action: "insert",
  888. lines: lines
  889. });
  890. return this.clonePos(end);
  891. };
  892. Document.prototype.remove = function (range) {
  893. var start = this.clippedPos(range.start.row, range.start.column);
  894. var end = this.clippedPos(range.end.row, range.end.column);
  895. this.applyDelta({
  896. start: start,
  897. end: end,
  898. action: "remove",
  899. lines: this.getLinesForRange({ start: start, end: end })
  900. });
  901. return this.clonePos(start);
  902. };
  903. Document.prototype.removeInLine = function (row, startColumn, endColumn) {
  904. var start = this.clippedPos(row, startColumn);
  905. var end = this.clippedPos(row, endColumn);
  906. this.applyDelta({
  907. start: start,
  908. end: end,
  909. action: "remove",
  910. lines: this.getLinesForRange({ start: start, end: end })
  911. }, true);
  912. return this.clonePos(start);
  913. };
  914. Document.prototype.removeFullLines = function (firstRow, lastRow) {
  915. firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1);
  916. lastRow = Math.min(Math.max(0, lastRow), this.getLength() - 1);
  917. var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0;
  918. var deleteLastNewLine = lastRow < this.getLength() - 1;
  919. var startRow = (deleteFirstNewLine ? firstRow - 1 : firstRow);
  920. var startCol = (deleteFirstNewLine ? this.getLine(startRow).length : 0);
  921. var endRow = (deleteLastNewLine ? lastRow + 1 : lastRow);
  922. var endCol = (deleteLastNewLine ? 0 : this.getLine(endRow).length);
  923. var range = new Range(startRow, startCol, endRow, endCol);
  924. var deletedLines = this.$lines.slice(firstRow, lastRow + 1);
  925. this.applyDelta({
  926. start: range.start,
  927. end: range.end,
  928. action: "remove",
  929. lines: this.getLinesForRange(range)
  930. });
  931. return deletedLines;
  932. };
  933. Document.prototype.removeNewLine = function (row) {
  934. if (row < this.getLength() - 1 && row >= 0) {
  935. this.applyDelta({
  936. start: this.pos(row, this.getLine(row).length),
  937. end: this.pos(row + 1, 0),
  938. action: "remove",
  939. lines: ["", ""]
  940. });
  941. }
  942. };
  943. Document.prototype.replace = function (range, text) {
  944. if (!(range instanceof Range))
  945. range = Range.fromPoints(range.start, range.end);
  946. if (text.length === 0 && range.isEmpty())
  947. return range.start;
  948. if (text == this.getTextRange(range))
  949. return range.end;
  950. this.remove(range);
  951. var end;
  952. if (text) {
  953. end = this.insert(range.start, text);
  954. }
  955. else {
  956. end = range.start;
  957. }
  958. return end;
  959. };
  960. Document.prototype.applyDeltas = function (deltas) {
  961. for (var i = 0; i < deltas.length; i++) {
  962. this.applyDelta(deltas[i]);
  963. }
  964. };
  965. Document.prototype.revertDeltas = function (deltas) {
  966. for (var i = deltas.length - 1; i >= 0; i--) {
  967. this.revertDelta(deltas[i]);
  968. }
  969. };
  970. Document.prototype.applyDelta = function (delta, doNotValidate) {
  971. var isInsert = delta.action == "insert";
  972. if (isInsert ? delta.lines.length <= 1 && !delta.lines[0]
  973. : !Range.comparePoints(delta.start, delta.end)) {
  974. return;
  975. }
  976. if (isInsert && delta.lines.length > 20000) {
  977. this.$splitAndapplyLargeDelta(delta, 20000);
  978. }
  979. else {
  980. applyDelta(this.$lines, delta, doNotValidate);
  981. this._signal("change", delta);
  982. }
  983. };
  984. Document.prototype.$safeApplyDelta = function (delta) {
  985. var docLength = this.$lines.length;
  986. if (delta.action == "remove" && delta.start.row < docLength && delta.end.row < docLength
  987. || delta.action == "insert" && delta.start.row <= docLength) {
  988. this.applyDelta(delta);
  989. }
  990. };
  991. Document.prototype.$splitAndapplyLargeDelta = function (delta, MAX) {
  992. var lines = delta.lines;
  993. var l = lines.length - MAX + 1;
  994. var row = delta.start.row;
  995. var column = delta.start.column;
  996. for (var from = 0, to = 0; from < l; from = to) {
  997. to += MAX - 1;
  998. var chunk = lines.slice(from, to);
  999. chunk.push("");
  1000. this.applyDelta({
  1001. start: this.pos(row + from, column),
  1002. end: this.pos(row + to, column = 0),
  1003. action: delta.action,
  1004. lines: chunk
  1005. }, true);
  1006. }
  1007. delta.lines = lines.slice(from);
  1008. delta.start.row = row + from;
  1009. delta.start.column = column;
  1010. this.applyDelta(delta, true);
  1011. };
  1012. Document.prototype.revertDelta = function (delta) {
  1013. this.$safeApplyDelta({
  1014. start: this.clonePos(delta.start),
  1015. end: this.clonePos(delta.end),
  1016. action: (delta.action == "insert" ? "remove" : "insert"),
  1017. lines: delta.lines.slice()
  1018. });
  1019. };
  1020. Document.prototype.indexToPosition = function (index, startRow) {
  1021. var lines = this.$lines || this.getAllLines();
  1022. var newlineLength = this.getNewLineCharacter().length;
  1023. for (var i = startRow || 0, l = lines.length; i < l; i++) {
  1024. index -= lines[i].length + newlineLength;
  1025. if (index < 0)
  1026. return { row: i, column: index + lines[i].length + newlineLength };
  1027. }
  1028. return { row: l - 1, column: index + lines[l - 1].length + newlineLength };
  1029. };
  1030. Document.prototype.positionToIndex = function (pos, startRow) {
  1031. var lines = this.$lines || this.getAllLines();
  1032. var newlineLength = this.getNewLineCharacter().length;
  1033. var index = 0;
  1034. var row = Math.min(pos.row, lines.length);
  1035. for (var i = startRow || 0; i < row; ++i)
  1036. index += lines[i].length + newlineLength;
  1037. return index + pos.column;
  1038. };
  1039. Document.prototype.$split = function (text) {
  1040. return text.split(/\r\n|\r|\n/);
  1041. };
  1042. return Document;
  1043. }());
  1044. Document.prototype.$autoNewLine = "";
  1045. Document.prototype.$newLineMode = "auto";
  1046. oop.implement(Document.prototype, EventEmitter);
  1047. exports.Document = Document;
  1048. });
  1049. ace.define("ace/lib/deep_copy",[], function(require, exports, module){exports.deepCopy = function deepCopy(obj) {
  1050. if (typeof obj !== "object" || !obj)
  1051. return obj;
  1052. var copy;
  1053. if (Array.isArray(obj)) {
  1054. copy = [];
  1055. for (var key = 0; key < obj.length; key++) {
  1056. copy[key] = deepCopy(obj[key]);
  1057. }
  1058. return copy;
  1059. }
  1060. if (Object.prototype.toString.call(obj) !== "[object Object]")
  1061. return obj;
  1062. copy = {};
  1063. for (var key in obj)
  1064. copy[key] = deepCopy(obj[key]);
  1065. return copy;
  1066. };
  1067. });
  1068. ace.define("ace/lib/lang",[], function(require, exports, module){"use strict";
  1069. exports.last = function (a) {
  1070. return a[a.length - 1];
  1071. };
  1072. exports.stringReverse = function (string) {
  1073. return string.split("").reverse().join("");
  1074. };
  1075. exports.stringRepeat = function (string, count) {
  1076. var result = '';
  1077. while (count > 0) {
  1078. if (count & 1)
  1079. result += string;
  1080. if (count >>= 1)
  1081. string += string;
  1082. }
  1083. return result;
  1084. };
  1085. var trimBeginRegexp = /^\s\s*/;
  1086. var trimEndRegexp = /\s\s*$/;
  1087. exports.stringTrimLeft = function (string) {
  1088. return string.replace(trimBeginRegexp, '');
  1089. };
  1090. exports.stringTrimRight = function (string) {
  1091. return string.replace(trimEndRegexp, '');
  1092. };
  1093. exports.copyObject = function (obj) {
  1094. var copy = {};
  1095. for (var key in obj) {
  1096. copy[key] = obj[key];
  1097. }
  1098. return copy;
  1099. };
  1100. exports.copyArray = function (array) {
  1101. var copy = [];
  1102. for (var i = 0, l = array.length; i < l; i++) {
  1103. if (array[i] && typeof array[i] == "object")
  1104. copy[i] = this.copyObject(array[i]);
  1105. else
  1106. copy[i] = array[i];
  1107. }
  1108. return copy;
  1109. };
  1110. exports.deepCopy = require("./deep_copy").deepCopy;
  1111. exports.arrayToMap = function (arr) {
  1112. var map = {};
  1113. for (var i = 0; i < arr.length; i++) {
  1114. map[arr[i]] = 1;
  1115. }
  1116. return map;
  1117. };
  1118. exports.createMap = function (props) {
  1119. var map = Object.create(null);
  1120. for (var i in props) {
  1121. map[i] = props[i];
  1122. }
  1123. return map;
  1124. };
  1125. exports.arrayRemove = function (array, value) {
  1126. for (var i = 0; i <= array.length; i++) {
  1127. if (value === array[i]) {
  1128. array.splice(i, 1);
  1129. }
  1130. }
  1131. };
  1132. exports.escapeRegExp = function (str) {
  1133. return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
  1134. };
  1135. exports.escapeHTML = function (str) {
  1136. return ("" + str).replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
  1137. };
  1138. exports.getMatchOffsets = function (string, regExp) {
  1139. var matches = [];
  1140. string.replace(regExp, function (str) {
  1141. matches.push({
  1142. offset: arguments[arguments.length - 2],
  1143. length: str.length
  1144. });
  1145. });
  1146. return matches;
  1147. };
  1148. exports.deferredCall = function (fcn) {
  1149. var timer = null;
  1150. var callback = function () {
  1151. timer = null;
  1152. fcn();
  1153. };
  1154. var deferred = function (timeout) {
  1155. deferred.cancel();
  1156. timer = setTimeout(callback, timeout || 0);
  1157. return deferred;
  1158. };
  1159. deferred.schedule = deferred;
  1160. deferred.call = function () {
  1161. this.cancel();
  1162. fcn();
  1163. return deferred;
  1164. };
  1165. deferred.cancel = function () {
  1166. clearTimeout(timer);
  1167. timer = null;
  1168. return deferred;
  1169. };
  1170. deferred.isPending = function () {
  1171. return timer;
  1172. };
  1173. return deferred;
  1174. };
  1175. exports.delayedCall = function (fcn, defaultTimeout) {
  1176. var timer = null;
  1177. var callback = function () {
  1178. timer = null;
  1179. fcn();
  1180. };
  1181. var _self = function (timeout) {
  1182. if (timer == null)
  1183. timer = setTimeout(callback, timeout || defaultTimeout);
  1184. };
  1185. _self.delay = function (timeout) {
  1186. timer && clearTimeout(timer);
  1187. timer = setTimeout(callback, timeout || defaultTimeout);
  1188. };
  1189. _self.schedule = _self;
  1190. _self.call = function () {
  1191. this.cancel();
  1192. fcn();
  1193. };
  1194. _self.cancel = function () {
  1195. timer && clearTimeout(timer);
  1196. timer = null;
  1197. };
  1198. _self.isPending = function () {
  1199. return timer;
  1200. };
  1201. return _self;
  1202. };
  1203. exports.supportsLookbehind = function () {
  1204. try {
  1205. new RegExp('(?<=.)');
  1206. }
  1207. catch (e) {
  1208. return false;
  1209. }
  1210. return true;
  1211. };
  1212. exports.skipEmptyMatch = function (line, last, supportsUnicodeFlag) {
  1213. return supportsUnicodeFlag && line.codePointAt(last) > 0xffff ? 2 : 1;
  1214. };
  1215. });
  1216. ace.define("ace/worker/mirror",[], function(require, exports, module) {
  1217. "use strict";
  1218. var Document = require("../document").Document;
  1219. var lang = require("../lib/lang");
  1220. var Mirror = exports.Mirror = function(sender) {
  1221. this.sender = sender;
  1222. var doc = this.doc = new Document("");
  1223. var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
  1224. var _self = this;
  1225. sender.on("change", function(e) {
  1226. var data = e.data;
  1227. if (data[0].start) {
  1228. doc.applyDeltas(data);
  1229. } else {
  1230. for (var i = 0; i < data.length; i += 2) {
  1231. var d, err;
  1232. if (Array.isArray(data[i+1])) {
  1233. d = {action: "insert", start: data[i], lines: data[i+1]};
  1234. } else {
  1235. d = {action: "remove", start: data[i], end: data[i+1]};
  1236. }
  1237. if ((d.action == "insert" ? d.start : d.end).row >= doc.$lines.length) {
  1238. err = new Error("Invalid delta");
  1239. err.data = {
  1240. path: _self.$path,
  1241. linesLength: doc.$lines.length,
  1242. start: d.start,
  1243. end: d.end
  1244. };
  1245. throw err;
  1246. }
  1247. doc.applyDelta(d, true);
  1248. }
  1249. }
  1250. if (_self.$timeout)
  1251. return deferredUpdate.schedule(_self.$timeout);
  1252. _self.onUpdate();
  1253. });
  1254. };
  1255. (function() {
  1256. this.$timeout = 500;
  1257. this.setTimeout = function(timeout) {
  1258. this.$timeout = timeout;
  1259. };
  1260. this.setValue = function(value) {
  1261. this.doc.setValue(value);
  1262. this.deferredUpdate.schedule(this.$timeout);
  1263. };
  1264. this.getValue = function(callbackId) {
  1265. this.sender.callback(this.doc.getValue(), callbackId);
  1266. };
  1267. this.onUpdate = function() {
  1268. };
  1269. this.isPending = function() {
  1270. return this.deferredUpdate.isPending();
  1271. };
  1272. }).call(Mirror.prototype);
  1273. });
  1274. ace.define("ace/mode/json/json_parse",[], function(require, exports, module) {
  1275. "use strict";
  1276. var at, // The index of the current character
  1277. ch, // The current character
  1278. escapee = {
  1279. '"': '"',
  1280. '\\': '\\',
  1281. '/': '/',
  1282. b: '\b',
  1283. f: '\f',
  1284. n: '\n',
  1285. r: '\r',
  1286. t: '\t'
  1287. },
  1288. text,
  1289. error = function (m) {
  1290. throw {
  1291. name: 'SyntaxError',
  1292. message: m,
  1293. at: at,
  1294. text: text
  1295. };
  1296. },
  1297. next = function (c) {
  1298. if (c && c !== ch) {
  1299. error("Expected '" + c + "' instead of '" + ch + "'");
  1300. }
  1301. ch = text.charAt(at);
  1302. at += 1;
  1303. return ch;
  1304. },
  1305. number = function () {
  1306. var number,
  1307. string = '';
  1308. if (ch === '-') {
  1309. string = '-';
  1310. next('-');
  1311. }
  1312. while (ch >= '0' && ch <= '9') {
  1313. string += ch;
  1314. next();
  1315. }
  1316. if (ch === '.') {
  1317. string += '.';
  1318. while (next() && ch >= '0' && ch <= '9') {
  1319. string += ch;
  1320. }
  1321. }
  1322. if (ch === 'e' || ch === 'E') {
  1323. string += ch;
  1324. next();
  1325. if (ch === '-' || ch === '+') {
  1326. string += ch;
  1327. next();
  1328. }
  1329. while (ch >= '0' && ch <= '9') {
  1330. string += ch;
  1331. next();
  1332. }
  1333. }
  1334. number = +string;
  1335. if (isNaN(number)) {
  1336. error("Bad number");
  1337. } else {
  1338. return number;
  1339. }
  1340. },
  1341. string = function () {
  1342. var hex,
  1343. i,
  1344. string = '',
  1345. uffff;
  1346. if (ch === '"') {
  1347. while (next()) {
  1348. if (ch === '"') {
  1349. next();
  1350. return string;
  1351. } else if (ch === '\\') {
  1352. next();
  1353. if (ch === 'u') {
  1354. uffff = 0;
  1355. for (i = 0; i < 4; i += 1) {
  1356. hex = parseInt(next(), 16);
  1357. if (!isFinite(hex)) {
  1358. break;
  1359. }
  1360. uffff = uffff * 16 + hex;
  1361. }
  1362. string += String.fromCharCode(uffff);
  1363. } else if (typeof escapee[ch] === 'string') {
  1364. string += escapee[ch];
  1365. } else {
  1366. break;
  1367. }
  1368. } else if (ch == "\n" || ch == "\r") {
  1369. break;
  1370. } else {
  1371. string += ch;
  1372. }
  1373. }
  1374. }
  1375. error("Bad string");
  1376. },
  1377. white = function () {
  1378. while (ch && ch <= ' ') {
  1379. next();
  1380. }
  1381. },
  1382. word = function () {
  1383. switch (ch) {
  1384. case 't':
  1385. next('t');
  1386. next('r');
  1387. next('u');
  1388. next('e');
  1389. return true;
  1390. case 'f':
  1391. next('f');
  1392. next('a');
  1393. next('l');
  1394. next('s');
  1395. next('e');
  1396. return false;
  1397. case 'n':
  1398. next('n');
  1399. next('u');
  1400. next('l');
  1401. next('l');
  1402. return null;
  1403. }
  1404. error("Unexpected '" + ch + "'");
  1405. },
  1406. value, // Place holder for the value function.
  1407. array = function () {
  1408. var array = [];
  1409. if (ch === '[') {
  1410. next('[');
  1411. white();
  1412. if (ch === ']') {
  1413. next(']');
  1414. return array; // empty array
  1415. }
  1416. while (ch) {
  1417. array.push(value());
  1418. white();
  1419. if (ch === ']') {
  1420. next(']');
  1421. return array;
  1422. }
  1423. next(',');
  1424. white();
  1425. }
  1426. }
  1427. error("Bad array");
  1428. },
  1429. object = function () {
  1430. var key,
  1431. object = {};
  1432. if (ch === '{') {
  1433. next('{');
  1434. white();
  1435. if (ch === '}') {
  1436. next('}');
  1437. return object; // empty object
  1438. }
  1439. while (ch) {
  1440. key = string();
  1441. white();
  1442. next(':');
  1443. if (Object.hasOwnProperty.call(object, key)) {
  1444. error('Duplicate key "' + key + '"');
  1445. }
  1446. object[key] = value();
  1447. white();
  1448. if (ch === '}') {
  1449. next('}');
  1450. return object;
  1451. }
  1452. next(',');
  1453. white();
  1454. }
  1455. }
  1456. error("Bad object");
  1457. };
  1458. value = function () {
  1459. white();
  1460. switch (ch) {
  1461. case '{':
  1462. return object();
  1463. case '[':
  1464. return array();
  1465. case '"':
  1466. return string();
  1467. case '-':
  1468. return number();
  1469. default:
  1470. return ch >= '0' && ch <= '9' ? number() : word();
  1471. }
  1472. };
  1473. return function (source, reviver) {
  1474. var result;
  1475. text = source;
  1476. at = 0;
  1477. ch = ' ';
  1478. result = value();
  1479. white();
  1480. if (ch) {
  1481. error("Syntax error");
  1482. }
  1483. return typeof reviver === 'function' ? function walk(holder, key) {
  1484. var k, v, value = holder[key];
  1485. if (value && typeof value === 'object') {
  1486. for (k in value) {
  1487. if (Object.hasOwnProperty.call(value, k)) {
  1488. v = walk(value, k);
  1489. if (v !== undefined) {
  1490. value[k] = v;
  1491. } else {
  1492. delete value[k];
  1493. }
  1494. }
  1495. }
  1496. }
  1497. return reviver.call(holder, key, value);
  1498. }({'': result}, '') : result;
  1499. };
  1500. });
  1501. ace.define("ace/mode/json_worker",[], function(require, exports, module) {
  1502. "use strict";
  1503. var oop = require("../lib/oop");
  1504. var Mirror = require("../worker/mirror").Mirror;
  1505. var parse = require("./json/json_parse");
  1506. var JsonWorker = exports.JsonWorker = function(sender) {
  1507. Mirror.call(this, sender);
  1508. this.setTimeout(200);
  1509. };
  1510. oop.inherits(JsonWorker, Mirror);
  1511. (function() {
  1512. this.onUpdate = function() {
  1513. var value = this.doc.getValue();
  1514. var errors = [];
  1515. try {
  1516. if (value)
  1517. parse(value);
  1518. } catch (e) {
  1519. var pos = this.doc.indexToPosition(e.at-1);
  1520. errors.push({
  1521. row: pos.row,
  1522. column: pos.column,
  1523. text: e.message,
  1524. type: "error"
  1525. });
  1526. }
  1527. this.sender.emit("annotate", errors);
  1528. };
  1529. }).call(JsonWorker.prototype);
  1530. });