Skip to content

Commit 3d5db86

Browse files
committed
I'm crushing your head!
1 parent 3a930bd commit 3d5db86

4 files changed

Lines changed: 85 additions & 27 deletions

File tree

apps/Terminal.js

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,20 @@ inputs. Also of relevance is the bit @WZZKUDJK that takes the valueOf() of each
5252
character, which is necessary for password mode chars to return the "real" string rather
5353
than, e.g. "********".
5454
» */
55+
/*10/6/25: Can we put 'IMPORT_COM_LIBS=<...>' into .env? «
56+
57+
The environment logic is in initLibs @SXFHFMG.
58+
So from there we can look for IMPORT_COM_LIBS, and do auto-loading from there. But just underneath
59+
that point in initLibs, we have:
60+
61+
if (dev_mode){
62+
let rv = await this.ShellMod.util.doImports(ADD_COMS, cwarn);
63+
}
64+
65+
So this gives us a nice pathway in which to change everything up from an ad-hoc,
66+
dev-centric workflow to a more systematic one.
67+
68+
»*/
5569
/*5/6/25: Just put the shell into mods/lang/shell.js.«
5670
Now need to figure out how to deal with the onreload situation:
5771
1) In normal REPL mode, we might want to reload the terminal app (this file) or the shell
@@ -2671,29 +2685,31 @@ fmtLinesSync(arr, startx){//«
26712685
}
26722686
//»
26732687

2674-
async respInit(addMessage){//«
2688+
async initLibs(addMessage){//«
26752689

26762690
let init_prompt = `LOTW shell`;
26772691
if (!Desk.isFake) init_prompt +=`\x20(${this.winid.replace("_","#")})`
26782692
if (admin_mode){
26792693
init_prompt+=`\nAdmin mode: true`;
26802694
}
26812695
if (addMessage) init_prompt = `${init_prompt}\n${addMessage}`;
2696+
//SXFHFMG
26822697
let env_file_path = `${this.cur_dir}/.env`;
26832698
let env_lines = await env_file_path.toLines();
26842699
if (env_lines) {
26852700
let rv = this.ShellMod.util.addToEnv(env_lines, this.env, {if_export: true});
2686-
// let rv = add_to_env(env_lines, this.env, {if_export: true});
26872701
if (rv.length){
26882702
init_prompt+=`\n${env_file_path}:\n`+rv.join("\n");
26892703
}
2704+
if (this.env.IMPORT_COM_LIBS) {
2705+
let add_com_libs = this.env.IMPORT_COM_LIBS.split(",");
2706+
if (add_com_libs){
2707+
let rv = await this.ShellMod.util.doImports(add_com_libs, cwarn);
2708+
if (rv) init_prompt += "\nImported libs: "+rv;
2709+
}
2710+
}
26902711
}
26912712

2692-
if (dev_mode){
2693-
let rv = await this.ShellMod.util.doImports(ADD_COMS, cwarn);
2694-
// let rv = await do_imports(ADD_COMS, cwarn);
2695-
if (rv) init_prompt += "\nImported libs: "+rv;
2696-
}
26972713
this.response(init_prompt);
26982714

26992715
}//»
@@ -3725,7 +3741,7 @@ async onappinit(appargs={}){//«
37253741
this.Win.noKbReload = appargs.noKbReload;
37263742
}
37273743
await this.initHistory(termBuffer);
3728-
await this.respInit(addMessage);
3744+
await this.initLibs(addMessage);
37293745
this.didInit = true;
37303746
this.sleeping = false;
37313747
this.isFocused = true;

coms/net/fs.js

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ root: {
3434
".read": false,
3535
".write": false,
3636
37-
LOTWFS: {
37+
LOTW_FS: {
3838
3939
"$ghid": {
40-
session_id: {
41-
'.validate": "newData.isString() && newData.val().length >= 4"
40+
session_ids: { // Register a unique session id here upon local initialization
41+
".validate": "!root.child($ghid).child('session_ids')[newData.val()]"
4242
},
43-
old_session_ids: {
44-
".validate": "!root.child($ghid).child('old_session_ids')[newData.val()]"
43+
cur_session_id: {
44+
'.validate": "newData.isString() && newData.val().length >= 4"
4545
},
4646
nodes: {
4747
".indexOn" = ["parId", "path"],
@@ -101,6 +101,32 @@ OTHER_NS: {
101101
}
102102
103103
Also: Let's await on update.
104+
»*/
105+
106+
/*10/6/25: Persistent session ids«
107+
108+
Let's do persistent 24 bit session ids (4 chars, ~16M possible). This is instead of
109+
jumping through all the hoops of constantly changing them. Only upon the first
110+
usage of the database in a client instance (local database initialization) do
111+
we need to secure a unique id. We just need to keep a little bit of local
112+
state, such as an object in e.g. APPDATA_PATH/netfs/sid.
113+
114+
Now we can do these 2 operations in a row, wrapped in a Promise:
115+
1) get_next_id
116+
2) increment_next_id
117+
118+
We know that if another session id is set between these 2 steps, then
119+
increment_next_id won't work, and we won't have any gaps in the ids.
120+
121+
const SESS_ID_BYTE_LEN = 3; // 4 ascii chars long
122+
const get_sess_id = () => {
123+
let sess_id = (crypto.getRandomValues(new Uint8Array(SESS_ID_BYTE_LEN))).toBase64()
124+
.replace(/\+/g, '-')
125+
.replace(/\x2f/g, '_')
126+
.replace(/=+$/, '');
127+
return sess_id;
128+
};
129+
104130
»*/
105131
/*10/5/25: Session ids«
106132
Let's get a crypto-secure 24bit value as Base64 (4 ascii characters), and call set_session
@@ -274,23 +300,12 @@ coms/fs.js (for file moving, copying, etc).
274300
const{globals}=LOTW;
275301
const {fsMod: fs, fbase}=globals;
276302
const {USERS_TYPE, APPDATA_PATH} = globals.fs;
303+
const {config: firebaseConfig} = globals.firebase;
277304
const {Com} = globals.ShellMod.comClasses;
278305
const{mkdv, mk, isArr,isStr,isEOF,isErr,log,jlog,cwarn,cerr}=LOTW.api.util;
279306
const{root, mount_tree}=fs;
280307
const {fs: fsapi}=LOTW.api;
281308
//const {popup} = globals.popup;
282-
283-
//Firebase«
284-
const firebaseConfig = {
285-
apiKey: "AIzaSyCEEMw3b1_bWj-OxM9oMKlKhkTTWxbIhlI",
286-
authDomain: "linuxontheweb.firebaseapp.com",
287-
databaseURL: "https://linuxontheweb.firebaseio.com",
288-
projectId: "linuxontheweb",
289-
storageBucket: "linuxontheweb.firebasestorage.app",
290-
messagingSenderId: "668423415088",
291-
appId: "1:668423415088:web:979b40c704cab2322ed4f5"
292-
};
293-
//»
294309
//Database
295310

296311
import {initializeApp} from "firebase_app";
@@ -321,7 +336,6 @@ increment,
321336
enableLogging
322337
} from "firebase_database";
323338

324-
325339
//»
326340

327341
//Var«
@@ -1834,6 +1848,9 @@ export {coms, onkill};
18341848

18351849
//»
18361850

1851+
cwarn("Firebase config");
1852+
log(firebaseConfig);
1853+
18371854
/*«
18381855
goog_but.onclick=async()=>{//«
18391856
is_active = true;
@@ -1867,3 +1884,14 @@ goog_but.onclick=async()=>{//«
18671884
</button>
18681885
<br><br>
18691886
»*/
1887+
/*«
1888+
const firebaseConfig = {
1889+
apiKey: "AIzaSyCEEMw3b1_bWj-OxM9oMKlKhkTTWxbIhlI",
1890+
authDomain: "linuxontheweb.firebaseapp.com",
1891+
databaseURL: "https://linuxontheweb.firebaseio.com",
1892+
projectId: "linuxontheweb",
1893+
storageBucket: "linuxontheweb.firebasestorage.app",
1894+
messagingSenderId: "668423415088",
1895+
appId: "1:668423415088:web:979b40c704cab2322ed4f5"
1896+
};
1897+
»*/

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/11255","Help.js/979","MediaPlayer.js/2074","Music.js/4844","Terminal.js/100352","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/12602"],"hw",["MidiCtl.js/3691"],"media",["2Cameras.js/3258","Camera.js/3673","MediaPlayer.js/16115","VideoCutter.js/61912"],"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/11295","fs.js/28722","games",["cfr.js/115420","poker.js/107498","slum.js/71075","zhold",["poker1.js/25062"]],"mail.js/44068","net",["fs.js/43978"],"shell.js/175037","template.js/336","test",["dummy.js/21"],"test.js/2026","yt.js/66863","zhold",["mail.js/22724"]],"desk",["index.html/1436"],"index.html/486","login",["index.html/11711"],"mods",["audio",["multi_freq_worklet.js/1502","random_walk_worklet.js/3039"],"games",["GBEmulator.js/9655","NESEmulator.js/222309","binjgb.wasm/87232"],"help",["shell.js/3591"],"hw",["midi.js/2323"],"lang",["shell.js/185316"],"term",["email.js/10406","less.js/19318","log.js/13292","vim.js/162926"],"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/7969","svcs",["imap.js/17772","mount.js/16553","smtp.js/1359","template.js/1831","ws.js/2156","ytdl.js/11982"]],"shell",["index.html/1211"],"sys",["config.js/9501","desk.js/219678","fs.js/72746","terminal.js/4307","three.js/3443","util.js/33015"],"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/11255","Help.js/979","MediaPlayer.js/2074","Music.js/4844","Terminal.js/100824","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/12602"],"hw",["MidiCtl.js/3691"],"media",["2Cameras.js/3258","Camera.js/3673","MediaPlayer.js/16115","VideoCutter.js/61912"],"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/11295","fs.js/28722","games",["cfr.js/115420","poker.js/107498","slum.js/71075","zhold",["poker1.js/25062"]],"mail.js/44068","net",["fs.js/45041"],"shell.js/175037","template.js/336","test",["dummy.js/21"],"test.js/2026","yt.js/66863","zhold",["mail.js/22724"]],"desk",["index.html/1436"],"index.html/486","login",["index.html/11711"],"mods",["audio",["multi_freq_worklet.js/1502","random_walk_worklet.js/3039"],"games",["GBEmulator.js/9655","NESEmulator.js/222309","binjgb.wasm/87232"],"help",["shell.js/3591"],"hw",["midi.js/2323"],"lang",["shell.js/185316"],"term",["email.js/10406","less.js/19318","log.js/13292","vim.js/162926"],"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/7969","svcs",["imap.js/17772","mount.js/16553","smtp.js/1359","template.js/1831","ws.js/2156","ytdl.js/11982"]],"shell",["index.html/1211"],"sys",["config.js/9931","desk.js/219678","fs.js/72746","terminal.js/4307","three.js/3443","util.js/33015"],"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"]]]

sys/config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,17 @@ const VIM_MODES={
430430
REF_MODE: 12,
431431
};
432432
//»
433+
//Firebase«
434+
const FIREBASE_CONFIG = {
435+
apiKey: "AIzaSyCEEMw3b1_bWj-OxM9oMKlKhkTTWxbIhlI",
436+
authDomain: "linuxontheweb.firebaseapp.com",
437+
databaseURL: "https://linuxontheweb.firebaseio.com",
438+
projectId: "linuxontheweb",
439+
storageBucket: "linuxontheweb.firebasestorage.app",
440+
messagingSenderId: "668423415088",
441+
appId: "1:668423415088:web:979b40c704cab2322ed4f5"
442+
};
443+
//»
433444
export const globals = {//«
434445
workers:{
435446
// faust: new Worker("/wasm/faust.js"),
@@ -473,6 +484,9 @@ css:{
473484
},
474485
BEWARE_RED,
475486
},
487+
firebase: {
488+
config: FIREBASE_CONFIG
489+
},
476490
fs: {
477491
FS_PREF,
478492
FS_TYPE,

0 commit comments

Comments
 (0)