FCF - Full Stack Javascript Framework
OpenSource is a full stack development framework designed to simplify the development of WEB projects of various complexity levels.
It is based on unique technologies that open up new opportunities in development approaches with NODEJS.
修订版 | e737c803988c6a17277a7eccdedeb7fa6a1c1825 (tree) |
---|---|
时间 | 2021-07-12 13:05:25 |
作者 | v.o.markin |
Commiter | v.o.markin |
Added execution mode from file for ScriptExecutor
@@ -27,9 +27,9 @@ | ||
27 | 27 | var template = a_options.template.split("+")[0]; |
28 | 28 | var templateRender = new TemplateRender({ |
29 | 29 | template: a_options.template, |
30 | - route: a_options.route, | |
31 | - args: a_options.args, | |
32 | - state: a_options.state, | |
30 | + route: a_options.route, | |
31 | + args: a_options.args, | |
32 | + state: a_options.state, | |
33 | 33 | rawTemplate: a_options.rawTemplate |
34 | 34 | }); |
35 | 35 | var renderingBlocks = self._getRenderingBlocks(a_options.template, a_options.rawTemplate, a_options.aliases ? a_options.aliases : {}); |
@@ -83,7 +83,7 @@ | ||
83 | 83 | content += " id='" + a_options.args.fcfId + "' "; |
84 | 84 | content += " class=' fcfwrapper " + fcf.str(a_options.args.fcfClassInner) + " " + fcf.str(a_options.args.fcfClass) + "' " |
85 | 85 | content += a_options.args.fcfEvntid ? " fcfevntid='" + a_options.args.fcfEvntid + "'" : ""; |
86 | - | |
86 | + | |
87 | 87 | if (a_options.args.fcfStyle || a_options.args.fcfStyleInner) |
88 | 88 | content += " style='" + fcf.str(a_options.args.fcfStyleInner) + ";" + fcf.str(a_options.args.fcfStyle) + "' "; |
89 | 89 | if (typeof a_options.args.fcfAttributes == "object"){ |
@@ -105,7 +105,7 @@ | ||
105 | 105 | fcf.getContext().currentTemplate = {id: a_args.args.fcfId}; |
106 | 106 | let ov = fcf.NDetails.currentTemplate; |
107 | 107 | fcf.NDetails.currentTemplate = a_template; |
108 | - await fcf.scriptExecutor.execute(a_code, a_args, a_path, a_stringNumber, 0, true); | |
108 | + await fcf.scriptExecutor.execute(a_code, a_args, a_path, a_stringNumber, 0, true, true); | |
109 | 109 | fcf.NDetails.currentTemplate = ov; |
110 | 110 | } |
111 | 111 |
@@ -391,30 +391,30 @@ | ||
391 | 391 | ? JSON.stringify(avalibleMirrors) |
392 | 392 | : "undefined"; |
393 | 393 | result += ` <script>` |
394 | - result += ` let currentServer = fcf.parseUrl(window.location.href).server;` | |
395 | - result += ` let avalibleServers = fcf.append([], ${strValue}, [fcf.parseUrl("${fcf.application.getConfiguration().site}").server]);` | |
396 | - result += ` var check = ${JSON.stringify(fcf.uuid())};`; | |
397 | - result += ` let found = false;` | |
398 | - result += ` fcf.each(avalibleServers, function (a_key, a_server){` | |
399 | - result += ` let pos = currentServer.lastIndexOf(a_server);`; | |
400 | - result += ` if (pos == -1)`; | |
401 | - result += ` return;`; | |
402 | - result += ` if (pos != currentServer.length - a_server.length)`; | |
403 | - result += ` return;`; | |
404 | - result += ` if (pos != 0 && currentServer[pos-1] != ".")`; | |
405 | - result += ` return;`; | |
406 | - result += ` found = true;`; | |
407 | - result += ` var check = ${JSON.stringify(fcf.uuid())};`; | |
408 | - result += ` return false;`; | |
409 | - result += ` });`; | |
410 | - result += ` if (!found) { `; | |
411 | - result += ` var check = ${JSON.stringify(fcf.uuid())};`; | |
412 | - result += ` if(window.stop)`; | |
413 | - result += ` window.stop();`; | |
414 | - result += ` else if (document.execCommand)`; | |
415 | - result += ` document.execCommand("Stop", false);`; | |
416 | - result += ` }`; | |
417 | - result += ` </script>\n`; | |
394 | + result += `let currentServer = fcf.parseUrl(window.location.href).server;` | |
395 | + result += `let avalibleServers = fcf.append([], ${strValue}, [fcf.parseUrl("${fcf.application.getConfiguration().site}").server]);` | |
396 | + result += `var check = ${JSON.stringify(fcf.uuid())};`; | |
397 | + result += `let found = false;` | |
398 | + result += `fcf.each(avalibleServers, function (a_key, a_server){` | |
399 | + result += `let pos = currentServer.lastIndexOf(a_server);`; | |
400 | + result += `if (pos == -1)`; | |
401 | + result += `return;`; | |
402 | + result += `if (pos != currentServer.length - a_server.length)`; | |
403 | + result += `return;`; | |
404 | + result += `if (pos != 0 && currentServer[pos-1] != ".")`; | |
405 | + result += `return;`; | |
406 | + result += `found = true;`; | |
407 | + result += `var check = ${JSON.stringify(fcf.uuid())};`; | |
408 | + result += `return false;`; | |
409 | + result += `});`; | |
410 | + result += `if (!found) { `; | |
411 | + result += `var check = ${JSON.stringify(fcf.uuid())};`; | |
412 | + result += `if(window.stop)`; | |
413 | + result += `window.stop();`; | |
414 | + result += `else if (document.execCommand)`; | |
415 | + result += `document.execCommand("Stop", false);`; | |
416 | + result += `}`; | |
417 | + result += `</script>\n`; | |
418 | 418 | } |
419 | 419 | |
420 | 420 | result += fcf.str(fcf.application.getSystemVariable("fcf:htmlHeader")); |
@@ -3268,7 +3268,7 @@ | ||
3268 | 3268 | this._dataFuncStorage = {}; |
3269 | 3269 | } |
3270 | 3270 | |
3271 | - execute(a_code, a_args, a_file, a_startLine, a_startChar, a_async){ | |
3271 | + execute(a_code, a_args, a_file, a_startLine, a_startChar, a_async, a_executuFromFile){ | |
3272 | 3272 | let self = this; |
3273 | 3273 | let error = undefined; |
3274 | 3274 |
@@ -3290,12 +3290,36 @@ | ||
3290 | 3290 | func = self._funcStorage[a_file][a_startLine][a_startChar].func; |
3291 | 3291 | code = self._funcStorage[a_file][a_startLine][a_startChar].code; |
3292 | 3292 | } else { |
3293 | - code = "(" + (a_async ? "async" : "") + " function fcfinnerevalfunction(a_args){"; | |
3293 | + code = (!a_executuFromFile ? "(" : "" )+ (a_async ? "async" : "") + " function fcfinnerevalfunction(a_args){"; | |
3294 | 3294 | for(let key in a_args) |
3295 | 3295 | code += `let ${key} = a_args.${key};`; |
3296 | 3296 | code += a_code; |
3297 | - code += "})"; | |
3298 | - func = eval(code); | |
3297 | + code += "}"; | |
3298 | + code += !a_executuFromFile ? ")" : ""; | |
3299 | + if (fcf.isServer() && a_executuFromFile){ | |
3300 | + let srcFileStat = libFS.statSync(fcf.getPath(a_file)); | |
3301 | + let funcFilePath = `:cache/scripts/${encodeURIComponent(a_file)}_${a_startLine}_${a_startChar}.js`; | |
3302 | + let funcFileStat = undefined; | |
3303 | + try { funcFileStat = libFS.statSync(fcf.getPath(funcFilePath)); } catch(e) { } | |
3304 | + if (!funcFileStat || srcFileStat.mtime > funcFileStat.mtime) { | |
3305 | + let rescode = "module.exports = " + code; | |
3306 | + let errorWrite = undefined; | |
3307 | + try{ | |
3308 | + libFS.writeFileSync(fcf.getPath(funcFilePath), rescode, {encoding: 'utf8'}); | |
3309 | + }catch(e){ | |
3310 | + errorWrite = e; | |
3311 | + } | |
3312 | + | |
3313 | + if (errorWrite){ | |
3314 | + libFS.mkdirSync(fcf.getPath(":cache/scripts"), { recursive: true }); | |
3315 | + libFS.writeFileSync(fcf.getPath(funcFilePath), rescode, {encoding: 'utf8'}); | |
3316 | + } | |
3317 | + } | |
3318 | + func = require(fcf.getPath(funcFilePath)); | |
3319 | + } else { | |
3320 | + func = eval(code); | |
3321 | + } | |
3322 | + | |
3299 | 3323 | if (!self._funcStorage[a_file]) |
3300 | 3324 | self._funcStorage[a_file] = {}; |
3301 | 3325 | if (!self._funcStorage[a_file][a_startLine]) |
@@ -3401,7 +3425,7 @@ | ||
3401 | 3425 | let stack = a_error.stackArr ? a_error.stackArr : fcf.Exception.parseStack(a_error.stack); |
3402 | 3426 | let line = undefined; |
3403 | 3427 | for(let i = 0; i < stack.length; ++i){ |
3404 | - if(stack[i].file.indexOf("eval at") == 0 || stack[i].file.indexOf("fcfEvalTmpl7652492") == 0 || stack[i].function == "fcfinnerevalfunction"){ | |
3428 | + if(stack[i].file.indexOf("eval at") == 0 || stack[i].function == "fcfinnerevalfunction"){ | |
3405 | 3429 | line = parseInt(stack[i].line) + a_startLine; |
3406 | 3430 | break; |
3407 | 3431 | } |