Browse Source

templating changes

master
jfinn 10 months ago
parent
commit
1d22e5ea67
6 changed files with 1744 additions and 140 deletions
  1. 13
    91
      js_client/jsync_lib.js
  2. 1695
    0
      js_client/jsync_lib.old.js
  3. 0
    0
      js_client/jsync_lib0.old.js
  4. 16
    6
      js_client/jsync_lib_template.js
  5. 20
    5
      make.py
  6. 0
    38
      old.make.py

+ 13
- 91
js_client/jsync_lib.js View File

@@ -1,5 +1,11 @@
1 1
 "use strict";
2 2
 
3
+// makestache template info 
4
+// the following string tells my make scripts its fine to overwtite this the library would have had a template str in the middle of the str
5
+// BUILT_FILE_OVERWRITE_ALLOWED
6
+//  ... C:\ws\repos\jitsi_main\jsync\jsyncdb\js_client\jsync_lib.js
7
+// /* */ 
8
+
3 9
 (function (){
4 10
 var isProxy,tlu,msto_z
5 11
 var pf,msto_prx
@@ -383,16 +389,7 @@ window.glob_u.ws.fns.onclose = function onclose(event){
383 389
 	clog("WS_CLOSE",{that:this,readyState:this.readyState,args:[...arguments]})
384 390
 	// glob_u.ws.sockets.ws1.params.ord.run_cbs("WS_CLOSE:",{event,that:this})
385 391
 	glob_u.ws.sockets[this.params.socket_name].params.ord.run_cbs("WS_CLOSE:",{event,that:this})
386
-	let  timeout0 = this.params.timeout0 || 100
387
-	let timeout_multi = this.params.timeout_multi || 3000
388
-	let t =timeout_multi
389
-	// let now = Date.now()
390
-	if (this.params.HAS_OPENED && timeout_multi<Date.now()-this.params.OPEN_TIME){
391
-		t=timeout0
392
-	}
393
-	// clog(":TIME:",now,this.params.OPEN_TIME,now-this.params.OPEN_TIME)
394
-	this.params.HAS_OPENED = 0
395
-	setTimeout(this.params.fns.reconnect,t)
392
+	setTimeout(this.params.fns.reconnect,1000)
396 393
 }
397 394
 
398 395
 window.glob_u.ws.fns.onmessage = function onmessage(event){
@@ -409,10 +406,8 @@ window.glob_u.ws.fns.onerror = function onerror(event){
409 406
 
410 407
 }
411 408
 window.glob_u.ws.fns.onopen = function onopen(event){
412
-	this.params.HAS_OPENED = 1
413
-	this.params.OPEN_TIME = Date.now()
414 409
 
415
-	clog("WS_OPEN???",{that:this,args:[...arguments]},{on_open_once:this.on_open_once,on_open_cbs:this.params.on_open_cbs})
410
+	// clog("WS_OPEN???",{that:this,args:[...arguments]},{on_open_once:this.on_open_once,on_open_cbs:this.params.on_open_cbs})
416 411
 	// glob_u.ws.sockets.ws1.params.ord.run_cbs("WS_OPEN:",{event,that:this})
417 412
 	glob_u.ws.sockets[this.params.socket_name].params.ord.run_cbs("WS_OPEN:",{event,that:this})
418 413
 	return
@@ -473,19 +468,6 @@ window.glob_u.ws.fns.ws_fns_factory = function ws_fns_factory(socket_opts){
473 468
 	return fns
474 469
 }
475 470
 
476
-Object.defineProperty(window,'a',{
477
-    get: function(){
478
-        console.log('windowProperty is being get...',arguments);
479
-        glob_u.ws.sockets.ws1.send(`{"a":2.01}`)
480
-        return 'windowProperty'
481
-    },
482
-
483
-    set: function(val){
484
-        console.log('windowProperty is being set',arguments);
485
-    },
486
-
487
-    configurable: true,
488
-});
489 471
 
490 472
 function connect_ws(o= {}){
491 473
 	// clog("connect_ws:",o,jc(o))
@@ -501,19 +483,7 @@ function connect_ws(o= {}){
501 483
 		return
502 484
 
503 485
 	}
504
-	var old_url = o.url
505
-	// location.protocol == "https:" ? clog("HTTPS") : clog("HTTP?")
506
-	// let vx1
507
-	// let vx1;location.protocol == "https:" ?  vx1 = "HTTPS" : vx1 = "HTTP?"
508
-	// clog("VAR DECS",vx1)
509
-	// o.url = "ws://127.0.0.1:5000/djc_srv/ws/chat/"
510
-	// o.url = "ws://127.0.0.1:5000/djc_srv/ws/chat"
511
-	// o.url = "ws://127.0.0.1:5000/echo_c1"
512
-	// o.url = `ws://${location.hostname}:5000/echo_c1?HELLO__________________________________________________________________________=1`
513
-	// o.url = `ws://${location.hostname}:5000/echo_c1${location.search}`
514
-	// o.url = `ws://${location.hostname}:5000/echo_c1?HELLO+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=1`
515
-	clog("new WebSocket(o.url)",o,o.url,old_url)
516
-	// var socket = new WebSocket(o.url,["PROTOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO"])
486
+
517 487
 	var socket = new WebSocket(o.url)
518 488
 	socket.on_open_once = []
519 489
 	socket.pre_init_msgs = []
@@ -563,11 +533,6 @@ function create_ws_ord(){
563 533
 window.glob_u.ws.fns.dispatch = function dispatch(o,obj_x,info){
564 534
 	var event = o.event
565 535
 	// socket = o.that
566
-	if (event.data == "::CLOSE::"){
567
-		clog("comand_CLOSE!!!")
568
-		o.that.close()
569
-	}
570
-	// clog(":event.data:",event.data,[this,o,obj_x,info])
571 536
 	var data = JSON.parse(event.data)
572 537
 	// clog("WS_dispatch",data,socket.params.ord,data["CLIENT_KEY"])
573 538
 	// clog("trc:sto:ws_rec",data.CLIENT_KEY,data.sto_event_type,data)
@@ -610,34 +575,6 @@ function ws_reload(){
610 575
 
611 576
 
612 577
 function get_room_name(){
613
-	// return 
614
-	var s=location.search
615
-	// if s[0]=="?"){}
616
-	s[0]=="?" ?  s = s.slice(1):0
617
-	var param
618
-	for (param of s.split("&")){
619
-
620
-		let kv = param.split("=")
621
-		if (kv[0]=="room"){
622
-			return kv[1]
623
-		}
624
-		clog("::",param,kv)
625
-		// clog("::",param,kv,"")
626
-	}
627
-
628
-	// var 
629
-	return "room_name"
630
-	var room_name=location.pathname.match(/\/loc.([^\/]*)\//)
631
-	if (room_name){
632
-		room_name = room_name[1]
633
-	} else {
634
-	room_name = location.pathname.split("/").pop()
635
-
636
-	}
637
-	return room_name
638
-
639
-}
640
-function get_room_name_old(){
641 578
 
642 579
 	var room_name=location.pathname.match(/\/loc.([^\/]*)\//)
643 580
 	if (room_name){
@@ -754,22 +691,14 @@ function mhndlr_rld_2(_o,scope,info){
754 691
 				if (glob_u.prom.init_db_resolve.resolved_inited == 2){
755 692
 
756 693
 				tmsgx4({sto_event_type:"db_sync_response",payload:jc(pf.root),request_from:parsed.from,request_rn_from:parsed.request_rn,"CLIENT_KEY":"ws_sto"})
757
-				clog("SENDING!@#$%^&*(")
758 694
 				}
759 695
 
760 696
 			break;
761 697
 			case "db_sync_response":
762 698
 
763
-			// clog("PROC db_sync_response",parsed,_o)
764
-
765 699
 					if (glob_u.prom.init_db_resolve && parsed.request_rn_from  == glob_u.prom.init_db_resolve.rn){
766
-			// clog("::PROC db_sync_response::",parsed,_o)
767 700
 						glob_u.prom.init_db_resolve({aaa:"dsr",pl:parsed.payload})
768
-					} else {
769
-			// clog("NO PROC::PROC db_sync_response::",parsed,_o)
770
-
771 701
 					}
772
-			clog("::PROC db_sync_response::",glob_u.prom.init_db_resolve.rn==parsed.request_rn_from,glob_u.prom.init_db_resolve.rn,parsed.request_rn_from,parsed,_o)
773 702
 				// clog("db_sync_response",parsed)
774 703
 			break;
775 704
 
@@ -1366,7 +1295,6 @@ function handle_pre_init_msgs(){
1366 1295
 }
1367 1296
 
1368 1297
 function ws_sto_connected(a,b){
1369
-	// clog("")
1370 1298
 
1371 1299
 	glob_u.cb.ws.run_cbs("WS_MSTO_INITED")
1372 1300
 
@@ -1617,24 +1545,17 @@ ensure_jsync_id_is_set(sessionStorage,"jsync_session")
1617 1545
 
1618 1546
 // TODO:Fix bug caused by a user disconnecting before the connection is properly established
1619 1547
 function connection_info_handler(o,scope,info){
1620
-	// clog("**************************************************************8:",o,scope,info)
1621 1548
 	if (o.data.sto_event_type=="connection_info"){
1622
-	clog("connection_info_handler:",o,scope,info)
1549
+	// clog("connection_info_handler:",o,scope,info)
1623 1550
 		glob_u.data.group_name = o.data.group_name
1624 1551
 		glob_u.data.channel_name = o.data.channel_name
1625 1552
 		clog("jsyncdb connected","room name:",glob_u.data.group_name)
1626 1553
 	} else if (o.data.sto_event_type=="user_disconnected"){
1627
-	clog("user_disconnected_handler:",o,scope,info)
1628
-
1629 1554
 	var last_conn =1
1630 1555
 	var k,v
1631 1556
 	var ws_conn_data = jc(msto.ws_channels[o.data.channel_name])
1632 1557
 	delete msto.ws_channels[o.data.channel_name]
1633 1558
 		for ([k,v] of Object.entries(msto.ws_channels)){
1634
-		clog("ERR!",{channel_name:jc(o.data.channel_name),ws_channels:jc(msto.ws_channels),z:{o,data:o.data}})
1635
-		clog("ERR?",k,v,ws_conn_data)
1636
-		clog("ERR??",jc(msto.ws_channels))
1637
-		clog("ERR???",jc(o.data))
1638 1559
 		if (v.id == ws_conn_data.id){
1639 1560
 			last_conn = 0
1640 1561
 		}
@@ -1682,14 +1603,15 @@ glob_u.fns.get_session_sto_id = get_session_sto_id
1682 1603
 // console.log("??...")
1683 1604
 
1684 1605
 
1685
-// clog("?????")
1606
+// clog("???")
1686 1607
 // 
1687 1608
 
1688 1609
 
1689 1610
 
1611
+
1690 1612
 // glob_u.fns.get_room_name=get_room_name
1691 1613
 // window.ds_test=ds_test
1692 1614
 // glob_u.fns.ds_test=ds_test
1693 1615
 // window.msto_prx=msto_prx
1694 1616
 
1695
-})()
1617
+})()

+ 1695
- 0
js_client/jsync_lib.old.js
File diff suppressed because it is too large
View File


js_client/jsync_lib0.js → js_client/jsync_lib0.old.js View File


+ 16
- 6
js_client/jsync_lib_template.js View File

@@ -1,5 +1,14 @@
1 1
 "use strict";
2 2
 
3
+// makestache template info {{{makestache_template_info}}}
4
+// the following string tells my make scripts its fine to overwtite this the library would have had a template str in the middle of the str
5
+// BUILT_FILE_{{{"makestache_template"}}}OVERWRITE_ALLOWED
6
+// {{{out_file_hint>jsync_lib*js}}} ... {{{output_filename}}}
7
+{{#is_makestache_template}}
8
+THIS_FILE_IS_A_MAKESTACHE_TEMPLATE
9
+{{/is_makestache_template}}
10
+// /* */ 
11
+
3 12
 (function (){
4 13
 var isProxy,tlu,msto_z
5 14
 var pf,msto_prx
@@ -7,23 +16,24 @@ var pf,msto_prx
7 16
 
8 17
 // jsync:dep.js
9 18
 // ------------------------------------------------------------------------------------------------
10
-{{{jsync_dep}}}
19
+{{{jsync_dep*js}}}
11 20
 // jsync:ord.js
12 21
 // ------------------------------------------------------------------------------------------------
13
-{{{jsync_ord}}}
22
+{{{jsync_ord*js}}}
14 23
 // jsync:ws.js
15 24
 // ------------------------------------------------------------------------------------------------
16
-{{{jsync_ws}}}
25
+{{{jsync_ws*js}}}
17 26
 // jsync:sto.js
18 27
 // ------------------------------------------------------------------------------------------------
19
-{{{jsync_sto}}}
28
+{{{jsync_sto*js}}}
20 29
 // jsync:init.js
21 30
 // ------------------------------------------------------------------------------------------------
22
-{{{jsync_init}}}
31
+{{{jsync_init*js}}}
23 32
 
24 33
 // jsync:test.js
25 34
 // ------------------------------------------------------------------------------------------------
26
-{{{jsync_test}}}
35
+{{{jsync_test*js}}}
36
+
27 37
 
28 38
 
29 39
 

+ 20
- 5
make.py View File

@@ -91,7 +91,7 @@ def is_template_file(file_name):
91 91
 		p("\t\\t\tFILE ERR:::",file_name)
92 92
 		p("")
93 93
 
94
-	p("LRN",len(ftxt))
94
+	# p("LRN",len(ftxt))
95 95
 	return r
96 96
 
97 97
 
@@ -134,8 +134,8 @@ def parse(ftxt):
134 134
 	os.chdir(tglob["OUT_DIR"])
135 135
 
136 136
 	# dbg_out
137
-	wfile("mgen1.js",out)
138
-	wfile("mgen2.js",out2)
137
+	# wfile("mgen1.js",out)
138
+	# wfile("mgen2.js",out2)
139 139
 	p()
140 140
 	if mdict["output_ok"]:
141 141
 		p(mdict["outfile"]["_path"])
@@ -222,11 +222,18 @@ def dev_main():
222 222
 
223 223
 
224 224
 	o = {}
225
+	p("checking files...")
225 226
 	# for en in os.scandir(r"C:\ws\repos\script_utils\makestache"):
226 227
 	for en in os.scandir():
227 228
 		if isfile(en):
228 229
 			o[en] = is_template_file(en)
229
-			p([en],isfile(en))
230
+			# p([en],isfile(en))
231
+			# p(en.name,en.path)
232
+			if (o[en]["is_template"]):
233
+				p(":",en.path,"TEMPLATE")
234
+			else:
235
+				p(en.path)
236
+			# p(en.path,"is_template:",bool(o[en]["is_template"]))
230 237
 			r'''
231 238
 			for en2 in dir(en):
232 239
 				if en2[:2]=="__":
@@ -251,9 +258,17 @@ tglob["OUT_DIR"] = r"C:\ws\repos\script_utils\makestache\test_out"
251 258
 tglob["IN_DIR"] = r"C:\ws\repos\script_utils\makestache\test_src"
252 259
 tglob["OUT_DIR"] = r"C:\ws\repos\script_utils\makestache\test_src"
253 260
 
261
+tglob["IN_DIR"]  = os.path.abspath(r"./js_client")
262
+tglob["OUT_DIR"] = os.path.abspath(r"./js_client")
254 263
 
255 264
 
256
-
265
+orig_dir = os.getcwd()
257 266
 
258 267
 
259 268
 dev_main()
269
+os.chdir(orig_dir)
270
+
271
+# this should exist only on the authors computer (it copies make.py to here so i can run make.py twice and get any file changes)
272
+if os.path.isfile("udep.bat"):
273
+	os.system("udep.bat")
274
+

+ 0
- 38
old.make.py View File

@@ -1,38 +0,0 @@
1
-import chevron
2
-
3
-
4
-
5
-files={
6
-"jsync_dep"  : "jsync_dep.js",
7
-"jsync_ord"  : "jsync_ord.js",
8
-"jsync_ws"   : "jsync_ws.js",
9
-"jsync_sto"  : "jsync_sto.js",
10
-"jsync_test" : "jsync_test.js",
11
-"jsync_test2" : "jsync_test2.js",
12
-"jsync_init" : "jsync_init.js",
13
-}
14
-
15
-def wfile(file_name,out):
16
-	f = open(file_name,"w")
17
-	f.write(out)
18
-	f.close()
19
-def rfile(file_name):
20
-	f = open(file_name,"r")
21
-	ftxt = f.read()
22
-	f.close()
23
-	return ftxt
24
-
25
-# C:\bspace\repos\jc4\ign4\indx\jsyncdb\jsync_lib_template.js
26
-def run_now():
27
-	path = r"C:\bspace\repos\jc4\ign4\indx\jsyncdb" + "\\"
28
-	files2 = {}
29
-	for k,v in files.items():
30
-		ftxt = rfile(path+v)
31
-		files2[k] = ftxt
32
-	template = rfile(path+"jsync_lib_template.js")
33
-	out = chevron.render(template,files2)
34
-	# wfile("jsync_lib_out.js",out)
35
-	wfile(path+"jsync_lib.js",out)
36
-
37
-# run_now()
38
-print("This was the old file I used to render the template the new one should keep all (or) most logic in the template")

Loading…
Cancel
Save