/* global Editor */
var Fs = require('fire-fs');
var Ipc = require('ipc');
var CodeEditor = require('./editor.js');
var enginePath = Editor.url( 'app://utils/api/engine' );
var editorPath = Editor.url( 'app://utils/api/editor-framework' );
var assetdbPath = Editor.url( 'app://utils/api/asset-db');
var runtimePath = Editor.runtimePath;

require('./firedoc-helper.js').generateBuiltin(enginePath, editorPath, assetdbPath);

document.addEventListener('DOMContentLoaded', function(event) {
  var url = Editor.argv.url;
  var path = Editor.argv.path;

  var editor = new CodeEditor(path, url);

  Fs.readFile(path, function (err, buf) {
    editor.aceEditor.setValue(buf.toString('utf8'), -1);
  });

  Ipc.on('panel:open', function (argv) {
    var url = argv.url;
    var path = argv.path;
    Fs.readFile(path, function (err, buf) {
      editor.aceEditor.setValue(buf.toString('utf8'), -1);
    });
  });

});

@@ -1,8 +1,36 @@
+(() =%3E %7B%0A  'use strict';%0A%0A  
 /* globa
@@ -41,19 +41,23 @@
 itor */%0A
-var
+  const
  Fs = re
@@ -74,19 +74,23 @@
 e-fs');%0A
-var
+  const
  Ipc = r
@@ -104,19 +104,23 @@
 'ipc');%0A
-var
+  const
  CodeEdi
@@ -149,19 +149,24 @@
 r.js');%0A
-var
+%0A  const
  engineP
@@ -211,19 +211,23 @@
 ine' );%0A
-var
+  const
  editorP
@@ -282,19 +282,23 @@
 ork' );%0A
-var
+  const
  assetdb
@@ -349,47 +349,11 @@
 ');%0A
-var runtimePath = Editor.runtimePath;%0A%0A
+%0A  
 requ
@@ -434,16 +434,18 @@
 Path);%0A%0A
+  
 document
@@ -486,31 +486,23 @@
 d', 
-function(event) %7B%0A  var
+() =%3E %7B%0A    let
  url
@@ -523,19 +523,21 @@
 .url;%0A  
-var
+  let
  path = 
@@ -557,19 +557,21 @@
 ath;%0A%0A  
-var
+  let
  editor 
@@ -600,16 +600,18 @@
  url);%0A%0A
+  
   Fs.rea
@@ -617,33 +617,24 @@
 adFile(path,
- function
  (err, buf) 
@@ -629,26 +629,31 @@
  (err, buf) 
-%7B%0A
+=%3E %7B%0A  
     editor.a
@@ -697,23 +697,27 @@
 ), -1);%0A
+  
   %7D);%0A%0A
+  
   Ipc.on
@@ -728,40 +728,36 @@
 nel:
-ope
+ru
 n', 
-function (
 argv
-)
+ =%3E
  %7B%0A    
-var
+  // let
  url
@@ -777,11 +777,13 @@
     
-var
+  let
  pat
@@ -797,20 +797,23 @@
 v.path;%0A
+%0A
     
+  
 Fs.readF
@@ -825,17 +825,8 @@
 ath,
- function
  (er
@@ -833,18 +833,23 @@
 r, buf) 
-%7B%0A
+=%3E %7B%0A  
       ed
@@ -907,19 +907,31 @@
     
+  
 %7D);%0A  
+ 
+ 
 %7D);%0A%0A
+  
 %7D);%0A
+%7D)();%0A

fix dbl-click not open script when code-editor exists