Commit 9f1023bb authored by Pouya Kary's avatar Pouya Kary

implemented compiler options into file format

parent e0ee283e
......@@ -24,6 +24,19 @@
compilerOutputFormat: 'regexp',
}
//
// ─── BASIC FILE FORMAT FOR LOADING OLDER FILES ──────────────────────────────────
//
const compileOptionsBaseOptions = {
target: 'es6',
format: 'regexp',
}
const emptyBaseFileJSON = {
compilerOptions: Object.assign({ }, compileOptionsBaseOptions )
}
//
// ─── ELECTRON LOADS ─────────────────────────────────────────────────────────────
//
......
......@@ -14,7 +14,13 @@
function onNewFile ( force = false ) {
if ( !( checkForSavingChanges( ) || force ) ) return;
currentFile = Object.assign({ }, defaultFileObject)
currentFile =
Object.assign({ }, defaultFileObject)
currentFile.compilerOptions =
Object.assign({ }, compileOptionsBaseOptions )
renderCompilerOptionsView( )
updateWorkspaceWithNewXML( defaultFileXML )
}
......
......@@ -35,17 +35,6 @@
'Untitled.orchestra' : path.basename( currentFile.path )
}
//
// ─── LOAD NEW FILE ──────────────────────────────────────────────────────────────
//
function loadFile ( fileJSONString ) {
const fileJSON = JSON.parse( fileJSONString )
// setupWorkspaceWithNewFile( fileJSON.workspaceXML );
playgroundEditor.setValue( fileJSON.playgroundText )
}
//
// ─── SERIALIZE FILE ─────────────────────────────────────────────────────────────
//
......@@ -54,6 +43,10 @@
return JSON.stringify({
workspaceXML: serializeWorkspaceIntoXML( ),
playgroundText: playgroundEditor.getValue( ),
compilerOptions: {
target: currentFile.compilerECMAScriptTarget,
format: currentFile.compilerOutputFormat,
}
})}
//
......@@ -81,7 +74,8 @@
setFileDirty( false )
new Log( "Saved!" )
}
})}
})
}
//
// ─── OPEN FILE ──────────────────────────────────────────────────────────────────
......@@ -95,24 +89,40 @@
return
}
try {
let fileJSON = JSON.parse( fileJSONString )
if ( fileJSON.workspaceXML !== undefined && fileJSON.workspaceXML !== null ) {
updateWorkspaceWithNewXML( fileJSON.workspaceXML )
currentFile.path = filePath
setFileDirty( true )
}
if ( fileJSON.playgroundText !== undefined && fileJSON.playgroundText !== '' )
playgroundEditor.setValue( fileJSON.playgroundText )
loadFileIntoWindow( fileJSONString, filePath )
})}
new Log( "Opened!" )
//
// ─── LOAD FILE INTO WINDOW ──────────────────────────────────────────────────────
//
function loadFileIntoWindow ( fileJSONString, filePath ) {
try {
const fileJSON =
Object.assign( emptyBaseFileJSON, JSON.parse( fileJSONString ) )
} catch ( error ) {
report( `Could not load the file because of a broken file problem.${ error }` )
// workspace
if ( fileJSON.workspaceXML !== undefined && fileJSON.workspaceXML !== null ) {
updateWorkspaceWithNewXML( fileJSON.workspaceXML )
currentFile.path = filePath
setFileDirty( true )
}
})}
// playground
if ( fileJSON.playgroundText !== undefined && fileJSON.playgroundText !== '' )
playgroundEditor.setValue( fileJSON.playgroundText )
// compiler configs
currentFile.compilerECMAScriptTarget = fileJSON.compilerOptions.target
currentFile.compilerOutputFormat = fileJSON.compilerOptions.format
renderCompilerOptionsView( )
new Log( "Opened!" )
} catch ( error ) {
report( `Could not load the file because of a broken file problem.${ error }` )
}
}
//
// ─── EXPORT SVG IMAGE ───────────────────────────────────────────────────────────
......
......@@ -66,6 +66,15 @@
}, 400 )
}
//
// ─── RENDER COMPILER OPTIONS VIEW ───────────────────────────────────────────────
//
function renderCompilerOptionsView ( ) {
activateTargetButton( )
activateFormatButton( )
}
//
// ─── REFRESH ACTIVATED FLAGS VIEW ───────────────────────────────────────────────
//
......
{"workspaceXML":"<xml xmlns=\"http://www.w3.org/1999/xhtml\"><block type=\"compose\" id=\"HZBT=HUf4sfO6:y.PGvp\" deletable=\"false\" x=\"80\" y=\"80\"><statement name=\"blocks\"><block type=\"line_start\" id=\"BljS~P|r@}*?xo1yl@d*\"><next><block type=\"one_or_more\" id=\"WaU/kqv*)SME8JD#[Mb}\"><statement name=\"blocks\"><block type=\"one_of\" id=\"Zj=#I?3))4OdKfdycMRC\"><statement name=\"blocks\"><block type=\"option\" id=\"@Du#s1?6rY~)kRJex4mi\"><statement name=\"blocks\"><block type=\"encode\" id=\"/Qh1TYMC0rhp+bD]`|Ec\"><field name=\"text\">\\b</field></block></statement><next><block type=\"option\" id=\"1+c}G?NW*deWUGEFbn?*\"><statement name=\"blocks\"><block type=\"encode\" id=\"xI+yRZ2v@]ml~WO)uf)#\"><field name=\"text\">\\B</field></block></statement><next><block type=\"option\" id=\"tuMB;OZ/9MaPZ*f0XoTQ\"><statement name=\"blocks\"><block type=\"encode\" id=\"/DH[uE+y@66yd9dwSt}b\"><field name=\"text\">^</field></block></statement><next><block type=\"option\" id=\"~[1Ex6-`uSOI`asod_b6\"><statement name=\"blocks\"><block type=\"encode\" id=\"l;Wps7d:ISV9bCk^g2;i\"><field name=\"text\">$</field></block></statement></block></next></block></next></block></next></block></statement></block></statement><next><block type=\"line_end\" id=\"04)(64_G@`pY?*o}:!BU\"></block></next></block></next></block></statement></block></xml>","playgroundText":""}
\ No newline at end of file
{"workspaceXML":"<xml xmlns=\"http://www.w3.org/1999/xhtml\"><block type=\"compose\" id=\"HZBT=HUf4sfO6:y.PGvp\" deletable=\"false\" x=\"179\" y=\"50\"><statement name=\"blocks\"><block type=\"line_start\" id=\"BljS~P|r@}*?xo1yl@d*\"><next><block type=\"one_or_more\" id=\"WaU/kqv*)SME8JD#[Mb}\"><statement name=\"blocks\"><block type=\"one_of\" id=\"Zj=#I?3))4OdKfdycMRC\"><statement name=\"blocks\"><block type=\"option\" id=\"@Du#s1?6rY~)kRJex4mi\"><statement name=\"blocks\"><block type=\"encode\" id=\"/Qh1TYMC0rhp+bD]`|Ec\"><field name=\"text\">\\b</field></block></statement><next><block type=\"option\" id=\"1+c}G?NW*deWUGEFbn?*\"><statement name=\"blocks\"><block type=\"encode\" id=\"xI+yRZ2v@]ml~WO)uf)#\"><field name=\"text\">\\B</field></block></statement><next><block type=\"option\" id=\"tuMB;OZ/9MaPZ*f0XoTQ\"><statement name=\"blocks\"><block type=\"encode\" id=\"/DH[uE+y@66yd9dwSt}b\"><field name=\"text\">^</field></block></statement><next><block type=\"option\" id=\"~[1Ex6-`uSOI`asod_b6\"><statement name=\"blocks\"><block type=\"encode\" id=\"l;Wps7d:ISV9bCk^g2;i\"><field name=\"text\">$</field></block></statement></block></next></block></next></block></next></block></statement></block></statement><next><block type=\"line_end\" id=\"04)(64_G@`pY?*o}:!BU\"></block></next></block></next></block></statement></block></xml>","playgroundText":"","compilerOptions":{"target":"es6","format":"regexp"}}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment