Skip to content

Commit 886fe6b

Browse files
committed
I'm crushing your head!
1 parent 410b4f2 commit 886fe6b

5 files changed

Lines changed: 67 additions & 10 deletions

File tree

apps/Terminal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2703,7 +2703,8 @@ lines array (otherwise, the message gets printed onto the actor's screen.
27032703
//This is not a bug since it is perfectly "okay" (I think) to pass aribtrary objects
27042704
//*through* a pipeline... but not out the end of it.
27052705
if (out.toString instanceof Function){
2706-
out = out.toString();
2706+
if (out instanceof Uint8Array) out = `Uint8Array(${out.length})`;
2707+
else out = out.toString();
27072708
}
27082709
else {
27092710
log(out);
@@ -2715,7 +2716,6 @@ log(out);
27152716
}
27162717

27172718
let {didFmt, colors, pretty, isErr, isSuc, isWrn, isInf, noBr} = opts;
2718-
//log();
27192719
if (out == "" && out.isNL){
27202720
out=" \n ";
27212721
}

apps/media/VideoCutter.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/*9/3/25: Instead of generalizing this app to allow for multiple files, let's create a
2+
shell command that takes an arbitrary number of arguments that describe all of the
3+
clips from all of the various VideoCutter windows to assemble into a composite video.
4+
One of the arguments might be a file that has a syntax to define all the clips.
5+
We can also have a command that simply plays the clips in the specified order (including
6+
whatever relevant transitions there are between the clips).
7+
So we can remove the assembling logic from here and put it into the relevant command library
8+
(or into a separate file somewhere under mods/).
9+
*/
110
/*9/2/25: I want to enable the use of clips from arbitrary numbers of videos, and sequencing
211
them in arbitrary orders. Then we can work on transitions (fades, etc) between clips.
312
*/

coms/fs.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ argument, but it was more fun getting...)
137137

138138
async init(){//«
139139
let{args, no}=this;
140-
140+
this.binPipe = true;
141141
let s1 = args.shift();
142142
let s2 = args.shift();
143143
if (!(s1&&s2)){
@@ -227,11 +227,15 @@ doBrep(){//«
227227

228228
}//»
229229
run(){
230-
if (this.noStdin) this.doBrep();;
230+
if (this.noStdin) this.doBrep();
231231
}
232-
pipeDone(lines){
233-
this.err("PLEASE IMPLEMENT THE CORRECT PIPING LOGIC!!!");
234-
this.no();
232+
pipeDone(bytes){
233+
//This should be a Uint8Array. Need to update Com._pipeIn.
234+
//log(bytes);
235+
this.bytes = bytes;
236+
this.doBrep();
237+
//this.err("PLEASE IMPLEMENT THE CORRECT PIPING LOGIC!!!");
238+
//this.no();
235239
}
236240
/*
237241
pipeIn(val){//«

list.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
["README.md/2181","app",["3d",["index.html/1098"]],"apps",["Audio.js/4093","BinView.js/9814","Folder.js/11196","Help.js/979","MediaPlayer.js/2074","Music.js/4844","Terminal.js/97044","TextEdit.js/5301","WorkMan.js/3808","YourApp.js/418","dev",["GetPoint.js/551","Grok.js/14796","Poker.js/36551","Three.js/5119"],"games",["Arcade.js/12599"],"hw",["MidiCtl.js/3691"],"media",["2Cameras.js/3258","Camera.js/3673","MediaPlayer.js/16115","VideoCutter.js/44911"],"template",["Basic.js/489","Template.js/396","WebAudio.js/2877"],"util",["HTML.js/1428","ImageView.js/2703","Unicoder.js/16896"]],"coms",["audio.js/1766","esprima.js/171872","extra.js/10807","fs.js/28634","games",["cfr.js/115420","poker.js/107498","slum.js/71075","zhold",["poker1.js/25062"]],"mail.js/44010","shell.js/175037","template.js/336","test",["dummy.js/21"],"test.js/2086","yt.js/66863","zhold",["mail.js/22724"]],"desk",["index.html/1184"],"index.html/486","mods",["audio",["multi_freq_worklet.js/1502","random_walk_worklet.js/3039"],"games",["GBEmulator.js/9708","NESEmulator.js/222309","binjgb.wasm/87232"],"help",["shell.js/3591"],"hw",["midi.js/2323"],"lang",["shell.js/182539"],"term",["email.js/10406","less.js/19318","log.js/13292","vim.js/162675"],"util",["libwabt.js/1299054","math.js/12125","pretty.js/93856","showdown.js/87205","walt.js/204893","wasm.js/42764","wasmparser.js/34331","webmparser.js/58730"],"workers",["poker.js/37420"]],"node",["server.js/7792","svcs",["imap.js/17772","mount.js/16553","smtp.js/1359","template.js/1831","ws.js/2156","ytdl.js/11982"]],"shell",["index.html/959"],"sys",["config.js/8659","desk.js/217563","fs.js/66825","terminal.js/4300","three.js/3443","util.js/32614"],"www",["blog.css/181","desk.css/1831","docs",["blog-template.html/291","help.html/9104","what-it-is.html/4370"],"examples",["test.sh/66"],"favicon.ico/15086","lotw256.png/41075","lotw48.png/2966","stuff",["noise.html/1669"]]]
1+
["README.md/2181","app",["3d",["index.html/1098"]],"apps",["Audio.js/4093","BinView.js/9814","Folder.js/11196","Help.js/979","MediaPlayer.js/2074","Music.js/4844","Terminal.js/97107","TextEdit.js/5301","WorkMan.js/3808","YourApp.js/418","dev",["GetPoint.js/551","Grok.js/14796","Poker.js/36551","Three.js/5119"],"games",["Arcade.js/12599"],"hw",["MidiCtl.js/3691"],"media",["2Cameras.js/3258","Camera.js/3673","MediaPlayer.js/16115","VideoCutter.js/45541"],"template",["Basic.js/489","Template.js/396","WebAudio.js/2877"],"util",["HTML.js/1428","ImageView.js/2703","Unicoder.js/16896"]],"coms",["audio.js/1766","esprima.js/171872","extra.js/10807","fs.js/28766","games",["cfr.js/115420","poker.js/107498","slum.js/71075","zhold",["poker1.js/25062"]],"mail.js/44010","shell.js/175037","template.js/336","test",["dummy.js/21"],"test.js/2086","yt.js/66863","zhold",["mail.js/22724"]],"desk",["index.html/1184"],"index.html/486","mods",["audio",["multi_freq_worklet.js/1502","random_walk_worklet.js/3039"],"games",["GBEmulator.js/9708","NESEmulator.js/222309","binjgb.wasm/87232"],"help",["shell.js/3591"],"hw",["midi.js/2323"],"lang",["shell.js/184061"],"term",["email.js/10406","less.js/19318","log.js/13292","vim.js/162675"],"util",["libwabt.js/1299054","math.js/12125","pretty.js/93856","showdown.js/87205","walt.js/204893","wasm.js/42764","wasmparser.js/34331","webmparser.js/58730"],"workers",["poker.js/37420"]],"node",["server.js/7792","svcs",["imap.js/17772","mount.js/16553","smtp.js/1359","template.js/1831","ws.js/2156","ytdl.js/11982"]],"shell",["index.html/959"],"sys",["config.js/8659","desk.js/217563","fs.js/66825","terminal.js/4300","three.js/3443","util.js/32614"],"www",["blog.css/181","desk.css/1831","docs",["blog-template.html/291","help.html/9104","what-it-is.html/4370"],"examples",["test.sh/66"],"favicon.ico/15086","lotw256.png/41075","lotw48.png/2966","stuff",["noise.html/1669"]]]

mods/lang/shell.js

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,27 @@ the only command that seems to use them is com_wget (when sending output). In co
1010
com_brep only wants Uint8Array's in its piped input. But since
1111
I just radically changed piping logic (so that commands don't really need to implement anything),
1212
I commented out com_brep's prior pipeIn method (and replaced it with a pipeDone stub).
13+
14+
LET'S ALLOW FOR A this.binPipe flag that can be set in init, and that signals the pipeline
15+
to automatically translate all incoming data into binary data (e.g. Uint8Array).
16+
class Com's _pipeIn method will do the translation, and call the command's pipeIn method,
17+
and push it into a JS array. Upon getting the EOF, we can concatenate all of them into
18+
a single Uint8Array, using the method @VEJZPMWU, and then call the command's pipeDone method
19+
with the final Uint8Array. This method should be used by com_brep.
20+
21+
The problem for translating strings to Uint8Array's is that we need to do:
22+
23+
let reader = new FileReader();
24+
reader.onloadend = () => {
25+
//ArrayBuffer in: reader.result;
26+
let bytes = new Uint8Array(reader.result);
27+
}
28+
reader.readAsArrayBuffer("My string here har har ha ha hoo hoo");
29+
30+
So in other words, we need to do some kind of awaiting before sending it off to a command
31+
that has set 'this.binPipe = true'. We need to check for the this.binPipe flag @ZELMGSO,
32+
and then do a call to toBytes. The only real question is that whatever is coming into
33+
the pipe is a consistent type: strings or Uint8Arrays (or Blobs, etc).
1334
»*/
1435
/*CRITICAL BUG:«
1536
THIS RETURNS THE TEXT IN THE FORM OF A LINES ARRAY BECAUSE OF THIS IN fs.js:
@@ -69,6 +90,7 @@ const util = LOTW.api.util;
6990
const {
7091
strNum,
7192
isArr,
93+
isJSArr,
7294
isStr,
7395
isNum,
7496
isObj,
@@ -1216,8 +1238,11 @@ if (node) {//«
12161238
if (fullpath == "/dev/null") return true;
12171239
if (fullpath == "/dev/log"){
12181240
// console.log(val);
1219-
if (isArr(val)) {
1241+
if (isJSArr(val)) {
12201242
for (let v of val) console.log(v);
1243+
}
1244+
else {
1245+
console.log(val);
12211246
}
12221247
return true;
12231248
}
@@ -1418,6 +1443,8 @@ return;
14181443
let redir_lns = this.redirLines || this.envRedirLines;
14191444
//LPIRHSKF
14201445
if (!redir_lns && this.nextCom){
1446+
if (!this.nextCom.noPipe) this.nextCom._pipeIn(val);
1447+
/*«
14211448
let next_com = this.nextCom;
14221449
if (next_com) {//LSKDJSG: Simple commands define this
14231450
// if (next_com && next_com.pipeIn) {//LSKDJSG: Simple commands define this
@@ -1431,6 +1458,7 @@ return;
14311458
cwarn("Dropping output");
14321459
log(val);
14331460
}
1461+
»*/
14341462
return;
14351463
}
14361464
else if(!redir_lns && this.envPipeInCb){
@@ -1447,6 +1475,7 @@ log(val);
14471475
}
14481476
else {
14491477
let hold = redir_lns;
1478+
//VEJZPMWU
14501479
redir_lns = new Uint8Array(hold.length + val.length);
14511480
redir_lns.set(hold, 0);
14521481
redir_lns.set(val, hold.length);
@@ -1576,9 +1605,24 @@ be wrapped when output onto the terminal
15761605
}
15771606
return {lines: lnarr, colors: cols};
15781607
}//»
1608+
async #pipeBytesDone(){
1609+
let blob = new Blob(this.#lines);
1610+
let bytes = await util.toBytes(blob);
1611+
this.pipeDone(bytes);
1612+
}
15791613
_pipeIn(val){
15801614
if (isEOF(val)){
1581-
if (this.pipeDone) this.pipeDone(this.#lines);
1615+
if (this.pipeDone) {
1616+
//ZELMGSO
1617+
/*
1618+
let blob = new Blob(this.#lines);
1619+
let bytes = await util.toBytes(blob);
1620+
*/
1621+
if (this.binPipe){
1622+
this.#pipeBytesDone();
1623+
}
1624+
else this.pipeDone(this.#lines);
1625+
}
15821626
return;
15831627
}
15841628
if (this.pipeIn) this.pipeIn(val);

0 commit comments

Comments
 (0)