pinokiod 2.15.7 → 2.15.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/kernel/api/index.js +20 -9
- package/kernel/bin/index.js +0 -7
- package/kernel/shell.js +1 -4
- package/kernel/shells.js +63 -7
- package/kernel/sysinfo.js +5 -8
- package/package.json +2 -2
- package/server/public/mark.min.js +7 -0
- package/server/public/style.css +26 -0
- package/server/views/editor.ejs +21 -3
- package/server/views/fullscreen_editor.ejs +27 -4
- package/server/views/index.ejs +10 -6
package/kernel/api/index.js
CHANGED
|
@@ -104,8 +104,6 @@ class Api {
|
|
|
104
104
|
// 1. set the "stop" flag for the uri, so the next execution in the queue for the uri will NOT queue another task
|
|
105
105
|
// 2. stream a message closing the socket
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
|
|
109
107
|
let requestPath = this.filePath(req.params.uri)
|
|
110
108
|
|
|
111
109
|
|
|
@@ -715,6 +713,19 @@ class Api {
|
|
|
715
713
|
}
|
|
716
714
|
|
|
717
715
|
|
|
716
|
+
if (result && result.error) {
|
|
717
|
+
this.ondata({
|
|
718
|
+
id: request.path,
|
|
719
|
+
type: "error",
|
|
720
|
+
data: result.response,
|
|
721
|
+
event: result.error,
|
|
722
|
+
rpc,
|
|
723
|
+
rawrpc
|
|
724
|
+
})
|
|
725
|
+
return
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
|
|
718
729
|
|
|
719
730
|
if (result && rpc.returns) {
|
|
720
731
|
// set the scope variable from the return value
|
|
@@ -879,13 +890,13 @@ class Api {
|
|
|
879
890
|
for(let name in this.listeners) {
|
|
880
891
|
this.listeners[name](packet)
|
|
881
892
|
}
|
|
882
|
-
if (packet.type === 'error') {
|
|
883
|
-
this.stop({
|
|
884
|
-
params: {
|
|
885
|
-
uri: packet.id
|
|
886
|
-
}
|
|
887
|
-
})
|
|
888
|
-
}
|
|
893
|
+
// if (packet.type === 'error') {
|
|
894
|
+
// this.stop({
|
|
895
|
+
// params: {
|
|
896
|
+
// uri: packet.id
|
|
897
|
+
// }
|
|
898
|
+
// })
|
|
899
|
+
// }
|
|
889
900
|
}
|
|
890
901
|
listen(name, ondata) {
|
|
891
902
|
this.listeners[name] = ondata
|
package/kernel/bin/index.js
CHANGED
|
@@ -149,9 +149,6 @@ class Bin {
|
|
|
149
149
|
}
|
|
150
150
|
}).filter(x => x)
|
|
151
151
|
|
|
152
|
-
|
|
153
|
-
console.log("****** envs", JSON.stringify(envs, null, 2))
|
|
154
|
-
|
|
155
152
|
// 2. Merge module envs
|
|
156
153
|
let e = {}
|
|
157
154
|
for(let env of envs) {
|
|
@@ -175,8 +172,6 @@ class Bin {
|
|
|
175
172
|
return file.endsWith(".js") && file !== "index.js" && file !== "cmake.js"
|
|
176
173
|
})
|
|
177
174
|
|
|
178
|
-
console.log({ modfiles })
|
|
179
|
-
|
|
180
175
|
|
|
181
176
|
this.mods = []
|
|
182
177
|
for(let filename of modfiles) {
|
|
@@ -188,7 +183,6 @@ class Bin {
|
|
|
188
183
|
let name = path.basename(filename, ".js")
|
|
189
184
|
this.mods.push({ name, mod })
|
|
190
185
|
}
|
|
191
|
-
console.log(">> this.mods = ", this.mods)
|
|
192
186
|
// inject kernel
|
|
193
187
|
for(let i=0; i<this.mods.length; i++) {
|
|
194
188
|
this.mods[i].mod.kernel = this.kernel
|
|
@@ -203,7 +197,6 @@ class Bin {
|
|
|
203
197
|
}
|
|
204
198
|
this.mod[mod.name] = mod.mod
|
|
205
199
|
}
|
|
206
|
-
console.log(">> this.mod", this.mod)
|
|
207
200
|
|
|
208
201
|
|
|
209
202
|
|
package/kernel/shell.js
CHANGED
|
@@ -89,8 +89,6 @@ class Shell {
|
|
|
89
89
|
// 2. env
|
|
90
90
|
// default env
|
|
91
91
|
|
|
92
|
-
console.log(">>>>> process.env=", JSON.stringify(process.env, null, 2))
|
|
93
|
-
|
|
94
92
|
this.env = Object.assign({}, process.env)
|
|
95
93
|
// If the user has set PYTHONPATH, unset it.
|
|
96
94
|
if (this.env.PYTHONPATH) {
|
|
@@ -113,6 +111,7 @@ class Shell {
|
|
|
113
111
|
}
|
|
114
112
|
|
|
115
113
|
this.env.CMAKE_OBJECT_PATH_MAX = 1024
|
|
114
|
+
this.env.PYTORCH_ENABLE_MPS_FALLBACK = 1
|
|
116
115
|
|
|
117
116
|
// First override this.env with system env
|
|
118
117
|
let system_env = await Environment.get(this.kernel.homedir)
|
|
@@ -656,8 +655,6 @@ class Shell {
|
|
|
656
655
|
|
|
657
656
|
config.env = this.env
|
|
658
657
|
|
|
659
|
-
console.log("CONFIG.ENV", JSON.stringify(config.env, null, 2))
|
|
660
|
-
|
|
661
658
|
if (!this.ptyProcess) {
|
|
662
659
|
// ptyProcess doesn't exist => create
|
|
663
660
|
this.done = false
|
package/kernel/shells.js
CHANGED
|
@@ -28,9 +28,7 @@ class Shells {
|
|
|
28
28
|
*/
|
|
29
29
|
async launch(params, options, ondata) {
|
|
30
30
|
// iterate through all the envs
|
|
31
|
-
console.log("------- params.env before", JSON.stringify(params.env, null, 2))
|
|
32
31
|
params.env = this.kernel.bin.envs(params.env)
|
|
33
|
-
console.log("------- params.env after", JSON.stringify(params.env, null, 2))
|
|
34
32
|
|
|
35
33
|
let exec_path = (params.path ? params.path : ".") // use the current path if not specified
|
|
36
34
|
let cwd = (options && options.cwd ? options.cwd : this.kernel.homedir) // if cwd exists, use it. Otherwise the cwd is pinokio home folder (~/pinokio)
|
|
@@ -39,7 +37,56 @@ class Shells {
|
|
|
39
37
|
if (options) params.group = options.group // set group
|
|
40
38
|
|
|
41
39
|
let m
|
|
40
|
+
|
|
41
|
+
// if error doesn't exist, add default "error:" event
|
|
42
|
+
if (!params.on) {
|
|
43
|
+
params.on = []
|
|
44
|
+
}
|
|
45
|
+
// default error
|
|
46
|
+
params.on.push({
|
|
47
|
+
event: "/error:/i",
|
|
48
|
+
debug: true
|
|
49
|
+
})
|
|
50
|
+
let errors = new Set()
|
|
42
51
|
let response = await sh.start(params, async (stream) => {
|
|
52
|
+
/*
|
|
53
|
+
{
|
|
54
|
+
method: "shell.run",
|
|
55
|
+
params: {
|
|
56
|
+
message,
|
|
57
|
+
on: [{
|
|
58
|
+
event: <regex>,
|
|
59
|
+
<done|kill|debug>: true
|
|
60
|
+
}],
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
*/
|
|
64
|
+
// if (params.error && Array.isArray(params.error)) {
|
|
65
|
+
// for(let handler of params.error) {
|
|
66
|
+
// if (handler.event) {
|
|
67
|
+
// let matches = /^\/(.+)\/([dgimsuy]*)$/gs.exec(handler.event)
|
|
68
|
+
// if (!/g/.test(matches[2])) {
|
|
69
|
+
// matches[2] += "g" // if g option is not included, include it (need it for matchAll)
|
|
70
|
+
// }
|
|
71
|
+
// let re = new RegExp(matches[1], matches[2])
|
|
72
|
+
// let line = stream.cleaned.replaceAll(/[\r\n]/g, "")
|
|
73
|
+
// //let rendered_event = [...stream.cleaned.matchAll(re)]
|
|
74
|
+
//
|
|
75
|
+
// let rendered_event = [...line.matchAll(re)]
|
|
76
|
+
// // 3. if the rendered expression is truthy, run the "run" script
|
|
77
|
+
// if (rendered_event.length > 0) {
|
|
78
|
+
//
|
|
79
|
+
// // if error matched, shouldn't move forard
|
|
80
|
+
//// error = rendered_event
|
|
81
|
+
// console.log({ rendered_event })
|
|
82
|
+
// for(let e of rendered_event) {
|
|
83
|
+
// errors.add(e[0])
|
|
84
|
+
// }
|
|
85
|
+
//
|
|
86
|
+
// }
|
|
87
|
+
// }
|
|
88
|
+
// }
|
|
89
|
+
// }
|
|
43
90
|
if (params.on && Array.isArray(params.on)) {
|
|
44
91
|
for(let handler of params.on) {
|
|
45
92
|
// regexify
|
|
@@ -66,6 +113,11 @@ class Shells {
|
|
|
66
113
|
m = rendered_event[0]
|
|
67
114
|
sh.continue()
|
|
68
115
|
}
|
|
116
|
+
if (handler.debug) {
|
|
117
|
+
for(let e of rendered_event) {
|
|
118
|
+
errors.add(e[0])
|
|
119
|
+
}
|
|
120
|
+
}
|
|
69
121
|
}
|
|
70
122
|
// } else if (handler.pattern === "url") {
|
|
71
123
|
// let re = /https?:\/\/[a-zA-Z0-9.:]+/g
|
|
@@ -89,11 +141,16 @@ class Shells {
|
|
|
89
141
|
}
|
|
90
142
|
ondata(stream)
|
|
91
143
|
})
|
|
92
|
-
console.log("shell ended", { id: sh.id, response, stdout: response, event: m })
|
|
93
144
|
|
|
145
|
+
if (errors.size > 0) {
|
|
146
|
+
// don't return if there's an error
|
|
147
|
+
console.log("errors", Array.from(errors))
|
|
148
|
+
return { id: sh.id, response, stdout: response, event: m, error: Array.from(errors) }
|
|
149
|
+
} else {
|
|
150
|
+
// need to make a request
|
|
151
|
+
return { id: sh.id, response, stdout: response, event: m }
|
|
152
|
+
}
|
|
94
153
|
|
|
95
|
-
// need to make a request
|
|
96
|
-
return { id: sh.id, response, stdout: response, event: m }
|
|
97
154
|
}
|
|
98
155
|
async start(params, options, ondata) {
|
|
99
156
|
params.persistent = true
|
|
@@ -203,14 +260,13 @@ class Shells {
|
|
|
203
260
|
let info = this.shells.map((s) => {
|
|
204
261
|
return { id: s.id, group: s.group, cmd: s.cmd }
|
|
205
262
|
})
|
|
206
|
-
console.log("reset", this.shells.length, JSON.stringify(info, null, 2))
|
|
207
263
|
if (this.shells) {
|
|
208
264
|
let shells = []
|
|
209
265
|
for(let i=0; i<this.shells.length; i++) {
|
|
210
266
|
shells.push(this.shells[i])
|
|
211
267
|
}
|
|
212
268
|
for(let shell of shells) {
|
|
213
|
-
console.log("[Kill]", { id: shell.id, group: shell.group, cmd: shell.cmd })
|
|
269
|
+
console.log("[Kill Shell]", { id: shell.id, group: shell.group, cmd: shell.cmd })
|
|
214
270
|
shell.kill("", true)
|
|
215
271
|
}
|
|
216
272
|
}
|
package/kernel/sysinfo.js
CHANGED
|
@@ -101,14 +101,11 @@ class Sysinfo {
|
|
|
101
101
|
cmd = "env"
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
console.log(
|
|
109
|
-
console.log("############### DEBUGGING ENV FINISH")
|
|
110
|
-
|
|
111
|
-
|
|
104
|
+
// console.log("############### DEBUGGING ENV")
|
|
105
|
+
// let _res = await this.kernel.bin.exec({ message: cmd, conda: { skip: true } }, (stream) => {
|
|
106
|
+
// })
|
|
107
|
+
// console.log(_res)
|
|
108
|
+
// console.log("############### DEBUGGING ENV FINISH")
|
|
112
109
|
|
|
113
110
|
let res = await this.kernel.bin.exec({ message: cmd }, (stream) => {
|
|
114
111
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pinokiod",
|
|
3
|
-
"version": "2.15.
|
|
3
|
+
"version": "2.15.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"key-store": "^1.2.0",
|
|
41
41
|
"kleur": "^4.1.5",
|
|
42
42
|
"lodash": "^4.17.21",
|
|
43
|
-
"lproxy": "^0.0.
|
|
43
|
+
"lproxy": "^0.0.13",
|
|
44
44
|
"marked": "^5.0.1",
|
|
45
45
|
"mime-types": "^2.1.35",
|
|
46
46
|
"multer": "^1.4.5-lts.1",
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*!***************************************************
|
|
2
|
+
* mark.js v8.6.0
|
|
3
|
+
* https://github.com/julmot/mark.js
|
|
4
|
+
* Copyright (c) 2014–2017, Julian Motz
|
|
5
|
+
* Released under the MIT license https://git.io/vwTVl
|
|
6
|
+
*****************************************************/
|
|
7
|
+
"use strict";function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var _extends=Object.assign||function(a){for(var b=1;b<arguments.length;b++){var c=arguments[b];for(var d in c)Object.prototype.hasOwnProperty.call(c,d)&&(a[d]=c[d])}return a},_createClass=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a};!function(a,b,c){"function"==typeof define&&define.amd?define([],function(){return a(b,c)}):"object"===("undefined"==typeof module?"undefined":_typeof(module))&&module.exports?module.exports=a(b,c):a(b,c)}(function(a,b){var c=function(){function c(b){_classCallCheck(this,c),this.ctx=b,this.ie=!1;var d=a.navigator.userAgent;(d.indexOf("MSIE")>-1||d.indexOf("Trident")>-1)&&(this.ie=!0)}return _createClass(c,[{key:"log",value:function a(b){var c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"debug",a=this.opt.log;this.opt.debug&&"object"===("undefined"==typeof a?"undefined":_typeof(a))&&"function"==typeof a[c]&&a[c]("mark.js: "+b)}},{key:"escapeStr",value:function(a){return a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}},{key:"createRegExp",value:function(a){return a=this.escapeStr(a),Object.keys(this.opt.synonyms).length&&(a=this.createSynonymsRegExp(a)),this.opt.ignoreJoiners&&(a=this.setupIgnoreJoinersRegExp(a)),this.opt.diacritics&&(a=this.createDiacriticsRegExp(a)),a=this.createMergedBlanksRegExp(a),this.opt.ignoreJoiners&&(a=this.createIgnoreJoinersRegExp(a)),a=this.createAccuracyRegExp(a)}},{key:"createSynonymsRegExp",value:function(a){var b=this.opt.synonyms,c=this.opt.caseSensitive?"":"i";for(var d in b)if(b.hasOwnProperty(d)){var e=b[d],f=this.escapeStr(d),g=this.escapeStr(e);a=a.replace(new RegExp("("+f+"|"+g+")","gm"+c),"("+f+"|"+g+")")}return a}},{key:"setupIgnoreJoinersRegExp",value:function(a){return a.replace(/[^(|)\\]/g,function(a,b,c){var d=c.charAt(b+1);return/[(|)\\]/.test(d)||""===d?a:a+"\0"})}},{key:"createIgnoreJoinersRegExp",value:function(a){return a.split("\0").join("[\\u00ad|\\u200b|\\u200c|\\u200d]?")}},{key:"createDiacriticsRegExp",value:function(a){var b=this.opt.caseSensitive?"":"i",c=this.opt.caseSensitive?["aàáâãäåāąă","AÀÁÂÃÄÅĀĄĂ","cçćč","CÇĆČ","dđď","DĐĎ","eèéêëěēę","EÈÉÊËĚĒĘ","iìíîïī","IÌÍÎÏĪ","lł","LŁ","nñňń","NÑŇŃ","oòóôõöøō","OÒÓÔÕÖØŌ","rř","RŘ","sšśș","SŠŚȘ","tťț","TŤȚ","uùúûüůū","UÙÚÛÜŮŪ","yÿý","YŸÝ","zžżź","ZŽŻŹ"]:["aÀÁÂÃÄÅàáâãäåĀāąĄăĂ","cÇçćĆčČ","dđĐďĎ","eÈÉÊËèéêëěĚĒēęĘ","iÌÍÎÏìíîïĪī","lłŁ","nÑñňŇńŃ","oÒÓÔÕÖØòóôõöøŌō","rřŘ","sŠšśŚșȘ","tťŤțȚ","uÙÚÛÜùúûüůŮŪū","yŸÿýÝ","zŽžżŻźŹ"],d=[];return a.split("").forEach(function(e){c.every(function(c){if(c.indexOf(e)!==-1){if(d.indexOf(c)>-1)return!1;a=a.replace(new RegExp("["+c+"]","gm"+b),"["+c+"]"),d.push(c)}return!0})}),a}},{key:"createMergedBlanksRegExp",value:function(a){return a.replace(/[\s]+/gim,"[\\s]+")}},{key:"createAccuracyRegExp",value:function(a){var b=this,c=this.opt.accuracy,d="string"==typeof c?c:c.value,e="string"==typeof c?[]:c.limiters,f="";switch(e.forEach(function(a){f+="|"+b.escapeStr(a)}),d){case"partially":default:return"()("+a+")";case"complementary":return"()([^\\s"+f+"]*"+a+"[^\\s"+f+"]*)";case"exactly":return"(^|\\s"+f+")("+a+")(?=$|\\s"+f+")"}}},{key:"getSeparatedKeywords",value:function(a){var b=this,c=[];return a.forEach(function(a){b.opt.separateWordSearch?a.split(" ").forEach(function(a){a.trim()&&c.indexOf(a)===-1&&c.push(a)}):a.trim()&&c.indexOf(a)===-1&&c.push(a)}),{keywords:c.sort(function(a,b){return b.length-a.length}),length:c.length}}},{key:"getTextNodes",value:function(a){var b=this,c="",d=[];this.iterator.forEachNode(NodeFilter.SHOW_TEXT,function(a){d.push({start:c.length,end:(c+=a.textContent).length,node:a})},function(a){return b.matchesExclude(a.parentNode,!0)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},function(){a({value:c,nodes:d})})}},{key:"matchesExclude",value:function(a,b){var c=this.opt.exclude.concat(["script","style","title","head","html"]);return b&&(c=c.concat(["*[data-markjs='true']"])),d.matches(a,c)}},{key:"wrapRangeInTextNode",value:function(a,c,d){var e=this.opt.element?this.opt.element:"mark",f=a.splitText(c),g=f.splitText(d-c),h=b.createElement(e);return h.setAttribute("data-markjs","true"),this.opt.className&&h.setAttribute("class",this.opt.className),h.textContent=f.textContent,f.parentNode.replaceChild(h,f),g}},{key:"wrapRangeInMappedTextNode",value:function(a,b,c,d,e){var f=this;a.nodes.every(function(g,h){var i=a.nodes[h+1];if("undefined"==typeof i||i.start>b){var j=function(){var i=b-g.start,j=(c>g.end?g.end:c)-g.start;if(d(g.node)){g.node=f.wrapRangeInTextNode(g.node,i,j);var k=a.value.substr(0,g.start),l=a.value.substr(j+g.start);if(a.value=k+l,a.nodes.forEach(function(b,c){c>=h&&(a.nodes[c].start>0&&c!==h&&(a.nodes[c].start-=j),a.nodes[c].end-=j)}),c-=j,e(g.node.previousSibling,g.start),!(c>g.end))return{v:!1};b=g.end}}();if("object"===("undefined"==typeof j?"undefined":_typeof(j)))return j.v}return!0})}},{key:"wrapMatches",value:function(a,b,c,d,e){var f=this,g=0===b?0:b+1;this.getTextNodes(function(b){b.nodes.forEach(function(b){b=b.node;for(var e=void 0;null!==(e=a.exec(b.textContent))&&""!==e[g];)if(c(e[g],b)){var h=e.index;if(0!==g)for(var i=1;i<g;i++)h+=e[i].length;b=f.wrapRangeInTextNode(b,h,h+e[g].length),d(b.previousSibling),a.lastIndex=0}}),e()})}},{key:"wrapMatchesAcrossElements",value:function(a,b,c,d,e){var f=this,g=0===b?0:b+1;this.getTextNodes(function(b){for(var h=void 0;null!==(h=a.exec(b.value))&&""!==h[g];){var i=h.index;if(0!==g)for(var j=1;j<g;j++)i+=h[j].length;var k=i+h[g].length;f.wrapRangeInMappedTextNode(b,i,k,function(a){return c(h[g],a)},function(b,c){a.lastIndex=c,d(b)})}e()})}},{key:"unwrapMatches",value:function(a){for(var c=a.parentNode,d=b.createDocumentFragment();a.firstChild;)d.appendChild(a.removeChild(a.firstChild));c.replaceChild(d,a),this.ie?this.normalizeTextNode(c):c.normalize()}},{key:"normalizeTextNode",value:function(a){if(a){if(3===a.nodeType)for(;a.nextSibling&&3===a.nextSibling.nodeType;)a.nodeValue+=a.nextSibling.nodeValue,a.parentNode.removeChild(a.nextSibling);else this.normalizeTextNode(a.firstChild);this.normalizeTextNode(a.nextSibling)}}},{key:"markRegExp",value:function(a,b){var c=this;this.opt=b,this.log('Searching with expression "'+a+'"');var d=0,e="wrapMatches",f=function(a){d++,c.opt.each(a)};this.opt.acrossElements&&(e="wrapMatchesAcrossElements"),this[e](a,this.opt.ignoreGroups,function(a,b){return c.opt.filter(b,a,d)},f,function(){0===d&&c.opt.noMatch(a),c.opt.done(d)})}},{key:"mark",value:function(a,b){var c=this;this.opt=b;var d=0,e="wrapMatches",f=this.getSeparatedKeywords("string"==typeof a?[a]:a),g=f.keywords,h=f.length,i=this.opt.caseSensitive?"":"i",j=function a(b){var f=new RegExp(c.createRegExp(b),"gm"+i),j=0;c.log('Searching with expression "'+f+'"'),c[e](f,1,function(a,e){return c.opt.filter(e,b,d,j)},function(a){j++,d++,c.opt.each(a)},function(){0===j&&c.opt.noMatch(b),g[h-1]===b?c.opt.done(d):a(g[g.indexOf(b)+1])})};this.opt.acrossElements&&(e="wrapMatchesAcrossElements"),0===h?this.opt.done(d):j(g[0])}},{key:"unmark",value:function(a){var b=this;this.opt=a;var c=this.opt.element?this.opt.element:"*";c+="[data-markjs]",this.opt.className&&(c+="."+this.opt.className),this.log('Removal selector "'+c+'"'),this.iterator.forEachNode(NodeFilter.SHOW_ELEMENT,function(a){b.unwrapMatches(a)},function(a){var e=d.matches(a,c),f=b.matchesExclude(a,!1);return!e||f?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},this.opt.done)}},{key:"opt",set:function(b){this._opt=_extends({},{element:"",className:"",exclude:[],iframes:!1,separateWordSearch:!0,diacritics:!0,synonyms:{},accuracy:"partially",acrossElements:!1,caseSensitive:!1,ignoreJoiners:!1,ignoreGroups:0,each:function(){},noMatch:function(){},filter:function(){return!0},done:function(){},debug:!1,log:a.console},b)},get:function(){return this._opt}},{key:"iterator",get:function(){return this._iterator||(this._iterator=new d(this.ctx,this.opt.iframes,this.opt.exclude)),this._iterator}}]),c}(),d=function(){function a(b){var c=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],d=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];_classCallCheck(this,a),this.ctx=b,this.iframes=c,this.exclude=d}return _createClass(a,[{key:"getContexts",value:function(){var a=void 0,c=[];return a="undefined"!=typeof this.ctx&&this.ctx?NodeList.prototype.isPrototypeOf(this.ctx)?Array.prototype.slice.call(this.ctx):Array.isArray(this.ctx)?this.ctx:"string"==typeof this.ctx?Array.prototype.slice.call(b.querySelectorAll(this.ctx)):[this.ctx]:[],a.forEach(function(a){var b=c.filter(function(b){return b.contains(a)}).length>0;c.indexOf(a)!==-1||b||c.push(a)}),c}},{key:"getIframeContents",value:function(a,b){var c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},d=void 0;try{var e=a.contentWindow;if(d=e.document,!e||!d)throw new Error("iframe inaccessible")}catch(a){c()}d&&b(d)}},{key:"onIframeReady",value:function(a,b,c){var d=this;try{!function(){var e=a.contentWindow,f="about:blank",g="complete",h=function(){var b=a.getAttribute("src").trim(),c=e.location.href;return c===f&&b!==f&&b},i=function(){var e=function e(){try{h()||(a.removeEventListener("load",e),d.getIframeContents(a,b,c))}catch(a){c()}};a.addEventListener("load",e)};e.document.readyState===g?h()?i():d.getIframeContents(a,b,c):i()}()}catch(a){c()}}},{key:"waitForIframes",value:function(a,b){var c=this,d=0;this.forEachIframe(a,function(){return!0},function(a){d++,c.waitForIframes(a.querySelector("html"),function(){--d||b()})},function(a){a||b()})}},{key:"forEachIframe",value:function(b,c,d){var e=this,f=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){},g=b.querySelectorAll("iframe"),h=g.length,i=0;g=Array.prototype.slice.call(g);var j=function(){--h<=0&&f(i)};h||j(),g.forEach(function(b){a.matches(b,e.exclude)?j():e.onIframeReady(b,function(a){c(b)&&(i++,d(a)),j()},j)})}},{key:"createIterator",value:function(a,c,d){return b.createNodeIterator(a,c,d,!1)}},{key:"createInstanceOnIframe",value:function(b){return new a(b.querySelector("html"),this.iframes)}},{key:"compareNodeIframe",value:function(a,b,c){var d=a.compareDocumentPosition(c),e=Node.DOCUMENT_POSITION_PRECEDING;if(d&e){if(null===b)return!0;var f=b.compareDocumentPosition(c),g=Node.DOCUMENT_POSITION_FOLLOWING;if(f&g)return!0}return!1}},{key:"getIteratorNode",value:function(a){var b=a.previousNode(),c=void 0;return c=null===b?a.nextNode():a.nextNode()&&a.nextNode(),{prevNode:b,node:c}}},{key:"checkIframeFilter",value:function(a,b,c,d){var e=!1,f=!1;return d.forEach(function(a,b){a.val===c&&(e=b,f=a.handled)}),this.compareNodeIframe(a,b,c)?(e!==!1||f?e===!1||f||(d[e].handled=!0):d.push({val:c,handled:!0}),!0):(e===!1&&d.push({val:c,handled:!1}),!1)}},{key:"handleOpenIframes",value:function(a,b,c,d){var e=this;a.forEach(function(a){a.handled||e.getIframeContents(a.val,function(a){e.createInstanceOnIframe(a).forEachNode(b,c,d)})})}},{key:"iterateThroughNodes",value:function(a,b,c,d,e){for(var f=this,g=this.createIterator(b,a,d),h=[],i=[],j=void 0,k=void 0,l=function(){var a=f.getIteratorNode(g);return k=a.prevNode,j=a.node};l();)this.iframes&&this.forEachIframe(b,function(a){return f.checkIframeFilter(j,k,a,h)},function(b){f.createInstanceOnIframe(b).forEachNode(a,c,d)}),i.push(j);i.forEach(function(a){c(a)}),this.iframes&&this.handleOpenIframes(h,a,c,d),e()}},{key:"forEachNode",value:function(a,b,c){var d=this,e=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){},f=this.getContexts(),g=f.length;g||e(),f.forEach(function(f){var h=function(){d.iterateThroughNodes(a,f,b,c,function(){--g<=0&&e()})};d.iframes?d.waitForIframes(f,h):h()})}}],[{key:"matches",value:function(a,b){var c="string"==typeof b?[b]:b,d=a.matches||a.matchesSelector||a.msMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.webkitMatchesSelector;if(d){var e=!1;return c.every(function(b){return!d.call(a,b)||(e=!0,!1)}),e}return!1}}]),a}();return a.Mark=function(a){var b=this,d=new c(a);return this.mark=function(a,c){return d.mark(a,c),b},this.markRegExp=function(a,c){return d.markRegExp(a,c),b},this.unmark=function(a){return d.unmark(a),b},this},a.Mark},window,document);
|
package/server/public/style.css
CHANGED
|
@@ -1593,3 +1593,29 @@ footer.status {
|
|
|
1593
1593
|
.btn.red {
|
|
1594
1594
|
background: brown !important;
|
|
1595
1595
|
}
|
|
1596
|
+
|
|
1597
|
+
#error-screen {
|
|
1598
|
+
position: absolute;
|
|
1599
|
+
top: 0;
|
|
1600
|
+
left: 0;
|
|
1601
|
+
bottom: 0;
|
|
1602
|
+
right: 0;
|
|
1603
|
+
z-index: 100000000;
|
|
1604
|
+
}
|
|
1605
|
+
#error-screen pre {
|
|
1606
|
+
padding: 20px;
|
|
1607
|
+
box-sizing: border-box;
|
|
1608
|
+
width: 100%;
|
|
1609
|
+
height: 100%;
|
|
1610
|
+
margin: 0;
|
|
1611
|
+
background: royalblue;
|
|
1612
|
+
color: white;
|
|
1613
|
+
overflow: auto;
|
|
1614
|
+
}
|
|
1615
|
+
mark{
|
|
1616
|
+
background: red;
|
|
1617
|
+
color: white;
|
|
1618
|
+
padding: 5px;
|
|
1619
|
+
display: inline-block;
|
|
1620
|
+
margin: 5px 0;
|
|
1621
|
+
}
|
package/server/views/editor.ejs
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
<script src="/waitmodal.js"></script>
|
|
24
24
|
<script src="/notifyinput.js"></script>
|
|
25
25
|
<script src="/report.js"></script>
|
|
26
|
+
<script src="/mark.min.js"></script>
|
|
26
27
|
<link href="/xterm.min.css" rel="stylesheet" />
|
|
27
28
|
<link href="/css/fontawesome.min.css" rel="stylesheet">
|
|
28
29
|
<link href="/css/solid.min.css" rel="stylesheet">
|
|
@@ -307,6 +308,7 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
307
308
|
this.socket.close()
|
|
308
309
|
document.querySelector(".run .play").classList.remove("hidden")
|
|
309
310
|
document.querySelector(".run .stop").classList.add("hidden")
|
|
311
|
+
|
|
310
312
|
} else if (packet.type === 'connect') {
|
|
311
313
|
// document.querySelector(".terminal-container").classList.remove("hidden")
|
|
312
314
|
const message = "..........Connected!\r\n"
|
|
@@ -464,13 +466,14 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
464
466
|
text: `${packet.data}`,
|
|
465
467
|
})
|
|
466
468
|
} else if (packet.type === "error") {
|
|
469
|
+
debugger
|
|
467
470
|
// n.Noty({
|
|
468
471
|
// text: `${packet.data}`,
|
|
469
472
|
// type: "error"
|
|
470
473
|
// })
|
|
471
|
-
this.socket.close()
|
|
472
|
-
|
|
473
|
-
reloadMemory()
|
|
474
|
+
// this.socket.close()
|
|
475
|
+
//// refreshParent(packet)
|
|
476
|
+
// reloadMemory()
|
|
474
477
|
//document.querySelector("footer").innerHTML = `<b><i class="fa-solid fa-triangle-exclamation"></i> ERROR</b><pre>${packet.data}</pre>`
|
|
475
478
|
document.querySelector("footer .content").innerHTML = document.querySelector("footer .content").innerHTML + `<pre class='error'>${packet.data}</pre>`
|
|
476
479
|
// document.querySelector("footer .toggle-expand i").className = "fa-solid fa-circle-chevron-down"
|
|
@@ -481,6 +484,18 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
481
484
|
document.querySelector(".run .starting").classList.add("hidden")
|
|
482
485
|
document.querySelector(".run .stop").classList.add("hidden")
|
|
483
486
|
|
|
487
|
+
document.querySelector("#error-screen").classList.remove("hidden")
|
|
488
|
+
document.querySelector("#error-screen pre").textContent = packet.data
|
|
489
|
+
let instance = new Mark(document.querySelector("#error-screen pre"), {
|
|
490
|
+
separateWordSearch: false,
|
|
491
|
+
accuracy: "exactly"
|
|
492
|
+
})
|
|
493
|
+
console.log("instance", instance)
|
|
494
|
+
console.log("EVENT", packet.event)
|
|
495
|
+
instance.mark(packet.event)
|
|
496
|
+
let element = document.querySelector("mark")
|
|
497
|
+
element.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
498
|
+
|
|
484
499
|
} else if (packet.type === "event") {
|
|
485
500
|
if (packet.data === "stop") {
|
|
486
501
|
document.querySelector("footer").innerHTML = "<b>Ready</b>"
|
|
@@ -865,5 +880,8 @@ const reloadMemory = async () => {
|
|
|
865
880
|
<footer><b>Ready</b></footer>
|
|
866
881
|
<% } %>
|
|
867
882
|
<% } %>
|
|
883
|
+
<div id='error-screen' class='hidden'>
|
|
884
|
+
<pre></pre>
|
|
885
|
+
</div>
|
|
868
886
|
</body>
|
|
869
887
|
</html>
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
<script src="/waitmodal.js"></script>
|
|
26
26
|
<script src="/notifyinput.js"></script>
|
|
27
27
|
<script src="/report.js"></script>
|
|
28
|
+
<script src="/mark.min.js"></script>
|
|
28
29
|
<link href="/xterm.min.css" rel="stylesheet" />
|
|
29
30
|
<link href="/css/fontawesome.min.css" rel="stylesheet">
|
|
30
31
|
<link href="/css/solid.min.css" rel="stylesheet">
|
|
@@ -41,7 +42,6 @@ html {
|
|
|
41
42
|
height: 100%;
|
|
42
43
|
overflow: hidden;
|
|
43
44
|
}
|
|
44
|
-
|
|
45
45
|
body {
|
|
46
46
|
height: 100%;
|
|
47
47
|
overflow: hidden;
|
|
@@ -192,6 +192,7 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
192
192
|
rows: this.term.rows,
|
|
193
193
|
}
|
|
194
194
|
}, async (packet) => {
|
|
195
|
+
console.log({ packet })
|
|
195
196
|
if (packet.type === 'start') {
|
|
196
197
|
refreshParent(packet)
|
|
197
198
|
reloadMemory()
|
|
@@ -425,9 +426,12 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
425
426
|
// text: `${packet.data}`,
|
|
426
427
|
// type: "error"
|
|
427
428
|
// })
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
429
|
+
|
|
430
|
+
// this.socket.close()
|
|
431
|
+
// refreshParent(packet)
|
|
432
|
+
// reloadMemory()
|
|
433
|
+
|
|
434
|
+
|
|
431
435
|
|
|
432
436
|
document.querySelector("footer .content").innerHTML = document.querySelector("footer .content").innerHTML + `<pre class='error'>${packet.data}</pre>`
|
|
433
437
|
// document.querySelector("footer .toggle-expand i").className = "fa-solid fa-circle-chevron-down"
|
|
@@ -438,6 +442,22 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
438
442
|
document.querySelector(".run .starting").classList.add("hidden")
|
|
439
443
|
document.querySelector(".run .stop").classList.add("hidden")
|
|
440
444
|
|
|
445
|
+
|
|
446
|
+
document.querySelector("#error-screen").classList.remove("hidden")
|
|
447
|
+
document.querySelector("#error-screen pre").textContent = packet.data
|
|
448
|
+
let instance = new Mark(document.querySelector("#error-screen pre"), {
|
|
449
|
+
separateWordSearch: false,
|
|
450
|
+
accuracy: "exactly"
|
|
451
|
+
})
|
|
452
|
+
console.log("instance", instance)
|
|
453
|
+
console.log("EVENT", packet.event)
|
|
454
|
+
instance.mark(packet.event)
|
|
455
|
+
let element = document.querySelector("mark")
|
|
456
|
+
element.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
|
|
441
461
|
} else if (packet.type === "event") {
|
|
442
462
|
if (packet.data === "stop") {
|
|
443
463
|
document.querySelector("footer").innerHTML = "<b>Ready</b>"
|
|
@@ -798,5 +818,8 @@ const reloadMemory = async () => {
|
|
|
798
818
|
<footer><b>Ready</b></footer>
|
|
799
819
|
<% } %>
|
|
800
820
|
<% } %>
|
|
821
|
+
<div id='error-screen' class='hidden'>
|
|
822
|
+
<pre></pre>
|
|
823
|
+
</div>
|
|
801
824
|
</body>
|
|
802
825
|
</html>
|
package/server/views/index.ejs
CHANGED
|
@@ -1006,12 +1006,16 @@ if (document.querySelector("#cloudflare")) {
|
|
|
1006
1006
|
})
|
|
1007
1007
|
}
|
|
1008
1008
|
<% } %>
|
|
1009
|
-
document.querySelector("#back")
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1009
|
+
if (document.querySelector("#back")) {
|
|
1010
|
+
document.querySelector("#back").addEventListener("click", (e) => {
|
|
1011
|
+
history.back()
|
|
1012
|
+
})
|
|
1013
|
+
}
|
|
1014
|
+
if (document.querySelector("#forward")) {
|
|
1015
|
+
document.querySelector("#forward").addEventListener("click", (e) => {
|
|
1016
|
+
history.forward()
|
|
1017
|
+
})
|
|
1018
|
+
}
|
|
1015
1019
|
document.querySelector("#genlog").addEventListener("click", (e) => {
|
|
1016
1020
|
e.preventDefault()
|
|
1017
1021
|
e.stopPropagation()
|