| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275 |
-
- window._APP = {}
- var APP = window._APP
-
- // FILE:m_req
-
-
- window.ifn_obj = window.ifn_obj || { init_conf_join:[],iammod:[] }
-
- function get_mod(participants){
- if (!participants){
- participants = get_participants()
- }
- var k,v
- for (v of participants){
- if (v.role == "moderator"){
- clog("cui_mod_cd",[v],v.corner_data)
- return v
- }
- }
- }
- function get_participants(){
- return APP.store.getState()["features/base/participants"]
- }
-
-
-
- function get_local(participants){
- if (!participants){
- participants = get_participants()
- }
- var k,v
- for (v of participants){
- if (v.local){
- return v
- }
- }
- return APP.store.getState()["features/base/participants"]
- }
- function amimod() {
- try {
- return get_local().role == "moderator"
- } catch (e) {
- console.error("AM I MOD ERR: is evrything inited?",e)
- // clog("AM I MOD ERR: is evrything inited?",e)
- }
- }
-
-
-
- function Someone_Left_Handler(o){
- delete msto.participants[o.action.participant.id]
- }
-
-
- // reflow all your filmstrips
- function Someone_Left_or_Joined_Handler(o){
- try {
- APP.store.dispatch(window.glob_react.video_layout.setTileView(false))
- APP.store.dispatch(window.glob_react.rf_filmstrip.setFilmstripVisible(false))
- if (! $("#vspace_filmstrip_template").length){
- init_api6()
- }
- refresh_toolbars()
- mod_sort()
- new_move()
- dispatch_resize()
- } catch(err) {
- console.error("Someone_Left_or_Joined_Handler err:", err)
- }
- }
-
-
-
-
-
- // dispay moderator toolbar if you become moderator
- window.iammod = window.iammod || false
- function amimodnow(){
- var iammod = amimod()
- window.iammod = iammod
- if (iammod){
- run_ifn_cbs("iammod")
- refresh_toolbars()
- }
- }
-
-
-
-
- // run init callbacks after CONFERENCE_JOINED
- function cji(){
- if (window.init_m){
- // setTimeout(window.init_m())
- }
- if (ifn_obj && ifn_obj.init_conf_join){
- var k,v
- for ([k,v] of Object.entries(ifn_obj.init_conf_join)){
- v()
- }
- }
- }
- function run_ifn_cbs(cb_name,args){
- jlog("RCB","run_ifn_cbs")
-
- try {
-
-
- if (ifn_obj && ifn_obj[cb_name]){
- var k,v
- for ([k,v] of Object.entries(ifn_obj[cb_name])){
- v()
- }
- } else {}
-
- } catch (err) {
- clog("ifn_obj not glob_mx_cbs_err:",err)
- }
-
- }
-
-
- // safe to remove
- function stv(o,ta){
- clog(o,ta)
- }
-
- function SET_TOOLBOX_info(o,that){
- // clog("SET_TOOLBOX_info",o,that)
- clog("ti",o.action.type,o.action)
-
- }
-
- function share_vid_info(o,that,m = true){
- clog("svi",m,o.action.type,o)
-
- }
- qxi_match = {
- share_vid:{
- startsWith:"",
- includes:"SHARE",
- endsWith:"",
- // arr:["SET_TOOLBAR_HOVERED"],
- // arr:[],
- // arr_or:["PARTICIPANT_UPDATED","SET_LOADABLE_AVATAR_URL"],
- arr_or:["PARTICIPANT_JOINED","PARTICIPANT_LEFT"],
- },
- }
-
- // 2m_req.js?c=023?v=39:163 QXI PARTICIPANT_UPDATED
- // 2m_req.js?c=023?v=39:163 QXI SET_LOADABLE_AVATAR_URL
- function qxi_jnk_match(o,that,m,fn){
- var flag = "~"
- var flag0 = 0
- var rf = []
- rf.push(flag0)
- m.startsWith ? flag0 =!o.action.type.startsWith(m.startsWith) || flag0 : 0
- rf.push(flag0)
- m.includes ? flag0 = !o.action.type.includes(m.includes) || flag0 : 0
- rf.push(flag0)
- m.endsWith ? flag0 = !o.action.type.endsWith(m.endsWith) || flag0 : 0
- rf.push(flag0)
- m.arr ? flag0 = !m.arr.includes(o.action.type) || flag0 : 0
- m.arr_or ? flag0 = !m.arr_or.includes(o.action.type) && flag0 : 0
- rf.push(flag0)
- if (!flag0){
- fn(o,that)
- } else {
- // fn(o,that,!!0)
- }
- // clog("qxi_jnk_match",o.action.type,flag0,rf,m)
-
- }
-
- qxi_skip = [
- "SET_TOOLBAR_HOVERED",
- "SET_TOOLBOX_TIMEOUT",
- "SET_TOOLBOX_TIMEOUT_MS",
- "CLEAR_TOOLBOX_TIMEOUT",
- "SET_TOOLBOX_VISIBLE",
-
-
- "_ADD_AUDIO_ELEMENT",
- "REGISTER_SOUND",
- "SET_LOADABLE_AVATAR_URL",
-
- ]
-
- qxi_skip0 = [
- "SET_TOOLBAR_HOVERED",
- ]
- function run_qxi_cbs(key,o){
- jlog("RCB","run_qxi_cbs")
- var k,v
- // clog("RUN_HOOK_CB??",key,glob_mx.hook_cb[key])
- try {
- } catch (err) {
- clog("qxi_cb glob_mx_cbs_err:",err)
- }
-
- for ([k,v] of Object.entries(glob_mx.qxi_cb[key]|| {}) ) {
- // clog("RUN_HOOK_CB:",k,v)
- v(o)
- }
- }
-
- function qxi2(o){
- var k = o.action.type
- clog("qxi2",k,o)
- return
- var k = o.action.type
- glob_dbg.qxi_map.setD(k,0)
- // var k,v
- glob_dbg.qxi_map.set(k,glob_dbg.qxi_map.get(k) + 1)
-
-
- if (qxi_skip.includes(k)){
- return
- }
- clog("qxi2",k,o)
- }
-
-
- function qxi_event(o){
- var cb
- /*
- if (o.action.type == "CONFERENCE_JOINED"){
- clog("conf_joined x")
- }
- */
- run_qxi_cbs(o.action.type,o)
- /*
- cb = glob_mx.qxi_test[o.action.type]
- if (cb){
- cb(o)
- // SET_OVERFLOW_MENU_VISIBLE
- }
- */
- // glob_mx.qxi_test
-
- }
- function reg_qxi(action_type,cb){
- glob_mx.qxi_test[action_type] = cb
- }
-
- // window.glob_dbg.qxi_map = window.glob_dbg.qxi_map || new Map()
- // this is called with setTimeout so we can throw errors without wrecking everything
- function dev_middleware_listner(o) {
- if (!o.action.type){
- return
- }
- // /*
- if (o.action.type != "ENDPOINT_MESSAGE_RECEIVED"){
- // CONFERENCE_JOINED
- qxi2(o)
- qxi_event(o)
- // if (o.action.type.startsWith("SET_TOOLBOX_" || o.action.type == "TOGGLE_TOOLBOX_VISIBLE")){
- // SET_TOOLBOX_info(o,this)
- // }
- // if ()
- // qxi_jnk_match(o,this,qxi_match.share_vid,share_vid_info)
- // clog("QXI",o.action.type)
- }
- // */
-
-
-
- switch(o.action.type){
- case "PARTICIPANT_UPDATED":
- window.iammod ? 0 : amimodnow()
-
- break;
- case "PARTICIPANT_LEFT":
- setTimeout(Someone_Left_Handler,1,o)
- // setTimeout(Someone_Left_Handler,1000,o)
- case "PARTICIPANT_JOINED":
- setTimeout(Someone_Left_or_Joined_Handler,1,o)
- // setTimeout(Someone_Left_or_Joined_Handler,300,o)
- break;
- // case "SET_TILE_VIEW":
- // stv(o,[this,arguments])
- break;
- case "CONFERENCE_JOINED":
- setTimeout(cji,1)
- break;
-
- }
- }
-
- // SET_TOOLBOX_ENABLED
- // SET_TOOLBOX_
-
- // FILE:_m_utils
-
-
-
-
-
-
- if (!window.glob_mx){
- // window.glob_mx={}
- }
- function disp(o){
- APP.store.dispatch(o)
- }
-
-
- // default event handler this should match all events
- mhndlr_opt_null = {
- from: undefined,
- handler: "onAll",
- id: null,
- name: null,
- // "http://jitsi.org/jitmeet"
- ns: null,
- options: {matchBareFromJid: false, ignoreNamespaceFragment: false},
- type: null,
- user: true,
- cstr:"test"
- };
-
-
-
- mhndlr_opt_x = {
- cstr:"?",
- ns:"corner_mx",
- handler:mhndlr,
-
- }
-
-
- function add_handler_m(handler) {
- var phx = APP.connection.xmpp.connection._stropheConn.handlers[0].__proto__;
-
- var hxa=Object.create(phx)
- Object.assign(hxa,mhndlr_opt_null,handler)
- APP.connection.xmpp.connection._stropheConn.addHandlers.push(hxa)
- }
-
-
- function tmsgx(data,tag="div",attrs={}){
- // return
- var ns = {xmlns:"corner_mx"}
- var msg = $build("message",{ to: window.APP.conference._room.room.roomjid,
- type: 'groupchat',
- });
- var payload=JSON.stringify(data)
-
- Object.assign({},ns,attrs)
-
- msg.c(tag, payload,Object.assign({},ns,attrs)).up();
- // console.log("zzzz")
- APP.conference._room.room.connection.send(msg)
- }
-
-
-
- function tmsgx2(data,opt_arg={},attrs={}){
- // return
- dflt_opt = {
- tag:"code",
- type:"chat",
- to:window.APP.conference._room.room.roomjid,
- }
- var opt = Object.assign({},dflt_opt,opt_arg)
-
- var ns = {xmlns:"corner_mx"}
- var msg = $build("message",{ to: opt.to,
- type: opt.type,
- });
- var payload=JSON.stringify(data)
-
- Object.assign({},ns,attrs)
-
- msg.c(opt.tag, payload,Object.assign({},ns,attrs)).up();
- // console.log("zzzz")
- APP.conference._room.room.connection.send(msg)
- }
- function tmsgx3(data,opt_arg={},attrs={}){
- // return
- dflt_opt = {
- tag:"code",
- // type:"chat",
- to:window.APP.conference._room.room.roomjid,
- }
- var opt = Object.assign({},dflt_opt,opt_arg)
- clog("T:",data,opt,opt.type)
- if (!opt.type){
- clog("NO TYPE")
- opt.to == dflt_opt.to ? opt.type = "groupchat" : opt.type = "chat"
- }
- clog("T:",data,opt,opt.type)
-
- var ns = {xmlns:"corner_mx"}
- var msg = $build("message",{ to: opt.to,
- type: opt.type,
- // from: "nnnx@conference.jfidev.com/3db7bf15",
- // xtra: "nnnx@conference.jfidev.com/3db7bf15",
- });
- var payload
- if (typeof(data) == "string"){
- payload=data
-
- } else {
- payload=JSON.stringify(data)
-
- }
-
- Object.assign({},ns,attrs)
-
- msg.c(opt.tag, payload,Object.assign({},ns,attrs)).up();
- // console.log("zzzz")
- APP.conference._room.room.connection.send(msg)
- }
-
-
-
- function mhndlr_rld_dflt(a0,a1,a2,a3,a4){
- clog("mhndlr... dflt")
- return true
- }
- if (!window.mhndlr_rld){
- window.mhndlr_rld = mhndlr_rld_dflt
- }
- function mhndlr(a0,a1,a2,a3,a4){
- // clog("MH!")
- setTimeout(window.mhndlr_rld,1,this,a0,a1,a2,a3,a4)
- return true
- }
-
-
- function init_mx(){
- clog("INITMX")
- add_handler_m(mhndlr_opt_x)
- // add_handler_m(mhndlr_opt_x_all)
- }
-
- // init_mx will be called once we join th confrence
- ifn_obj.init_conf_join.push(init_mx)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- // FILE:m_utils
- // This file creates and syncs msto
- // msto is a recursive proxy that synchronizes itself between all meeting participants
- // you can get a clone of the object by typing jc(msto) into your dev console
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if (!window.glob_mx ){
- window.glob_mx={}
-
- glob_mx.prom = {}
- glob_mx.event_handlers = {}
- glob_mx.ws_event_handlers = {}
- glob_mx.flags = {}
- glob_mx.cb = {
- init_db:{}
- }
- glob_mx.hook_cb = {
-
- }
- glob_mx.qxi_cb = {}
- glob_mx.qxi_test = {
-
- }
-
- glob_mx.filmstrip_handlers = {}
- //glob_mx.filmstrip_handlers = glob_mx.filmstrip_handlers || {}
-
- }
- dlog = nop
-
-
- function match(mx,m,o){
- var k,v,k2,v2
- var r = 0
-
- for ([k,v] of Object.entries(m || {})){
- v2 = o[k]
-
- if (typeof(v) == "string" && typeof(v2) == "string") {
- r += !(v==v2)
- } else if (Array.isArray(v) && Array.isArray(v2)){
- r += !(isSubset_arr(v,v2))
- } else if (Array.isArray(v) && typeof(v2) == "string"){
- // r += !(isSubset_arr(v2,v))
- r += !v.includes(v2)
-
- } else if (Array.isArray(v2) && typeof(v) == "string"){
- r += !(v2.includes(v))
- }
- if (r){
- return !r
- }
- }
- return !r
- }
-
-
- function isSubset(subset,superset){
- for (var elem of subset) {
- if (!superset.includes(elem)) {
- return false;
- }
- }
- return true;
- }
-
- function isSubset_arr(subset,superset){
- for (var elem of subset) {
- if (Array.isArray(elem)){
-
- if (!new Set(elem).intersection(superset).size){
- return false
- }
- } else if (!superset.includes(elem)) {
- return false;
- }
- }
- return true;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- function dispatch_ws_events3(e,key){
- var k,v
- // let dlog =clog
- clog("dispatch_ws_events3",e,{that:this,e,key})
- // return
- // e.payload.etype ? 1 : e.payload.etype = "null"
- e.parsed.etype ? 1 : e.parsed.etype = "null"
- var mflag =0
- dlog("dispatch_events??",e,key)
-
- for ([k,v] of Object.entries(glob_mx.ws_event_handlers || {}) ) {
- dlog("dispatch_events:",k)
- if (v.m){
- // mflag = match({},v.m,e.payload)
- mflag = match({},v.m,e.parsed)
- mflag ? v.fn(e,key) : 1
- }
- }
- }
-
-
-
-
-
- function dispatch_ws_events(e,key){
- var k,v
- // let dlog =clog
- clog("dispatch_ws_events",{that:this,e,key})
- // return
- // e.payload.etype ? 1 : e.payload.etype = "null"
- e.parsed.etype ? 1 : e.parsed.etype = "null"
- var mflag =0
- dlog("dispatch_events??",e,key)
-
- for ([k,v] of Object.entries(glob_mx.ws_event_handlers || {}) ) {
- dlog("dispatch_events:",k)
- if (v.m){
- // mflag = match({},v.m,e.payload)
- mflag = match({},v.m,e.parsed)
- mflag ? v.fn(e,key) : 1
- }
- }
- }
-
-
-
- function dispatch_events(e,key){
- var k,v
- clog("dispatch_events_z",{that:this,e,key})
- e.parsed.etype ? 1 : e.parsed.etype = "null"
- var mflag =0
- dlog("dispatch_events??",e,key)
-
- for ([k,v] of Object.entries(glob_mx.event_handlers || {}) ) {
- dlog("dispatch_events:",k)
- if (v.m){
- mflag = match({},v.m,e.parsed)
- mflag ? v.fn(e) : 1
- }
- }
- }
-
-
- function run_cbs(key){
- jlog("RCB","run_cbs")
- var k,v
- dlog("RUN_CB??",key,glob_mx.cb[key])
-
- for ([k,v] of Object.entries(glob_mx.cb[key]|| {}) ) {
- dlog("RUN_CB:",k)
- v()
- }
- }
-
- function run_hook_cbs(key,o){
- jlog("RCB","run_hook_cbs")
- var k,v
- // dlog("RUN_HOOK_CB??",key,glob_mx.hook_cb[key])
-
- for ([k,v] of Object.entries(glob_mx.hook_cb[key]|| {}) ) {
- // dlog("RUN_HOOK_CB:",k)
- v(o)
- }
- }
-
-
-
-
-
- function wait(ms) {
- return new Promise(r => setTimeout(r, ms));
- }
-
- function attr_info(n){
- var k,v
- var ret ={}
- // clog(".")
- for (k in n.attributes){
- // clog(k)
- }
- // clog("~")
- for (k of n.attributes){
- // for (k of n.attributes){
- // clog(k)
- }
- // clog("--")
- for ([k,v] of Object.entries(n.attributes)){
- // clog(k,v,v+"+")
- // clog("+",[k,v],v)
- ret[v.name]= v.value
- // clog(typeof(k),typeof(v))
- }
- return ret
-
-
- }
-
-
-
-
-
-
- // ai.from.split((a0,a1,a2,a3)=>{clog({a0,a1,a2,a3});return "z"})
- // tmsgx3({type:"db_sync_request"})
- function mhndlr_rld(that,m){
- try {
- window.mx=m
- var n = m.querySelector(`code`)
- if (!n){return}
- var parsed = JSON.parse(n.innerHTML)
- var ai = attr_info(m)
- window.ai=ai
- // clog("FROM",ai.from == glob_mx.all_jids[0])
- // var id = ai.from.split().slice(-1)[0]
- var id = ai.from.split("/").pop()
-
- dlog("mhndlr_rld2",m,parsed,n,n.dataset)
- var o = parsed.payload
- switch (parsed.type){
- case "set_msg":
- pf._set_recv(o.path,o.key,o.val)
- window._set_recv_cb ? window._set_recv_cb({that:this,m,n,o,ai,id}): 0
- // window?._set_recv_cb?.({that:this,m,n,o,ai,id}) opt_chain
- break;
- case "event":
- dlog("~event~",parsed)
- dispatch_events({parsed,ai,m,that})
- break;
- case "msg_test":
- dlog("msg_test",parsed)
- break;
- case "db_sync_request":
- // tmsgx3({type:"db_sync_response",payload:pf.root})
- tmsgx3({type:"db_sync_response",payload:pf.root},{to:ai.from})
-
- dlog("db_sync_request",parsed)
- break;
- case "db_sync_response":
- if (id == glob_mx.local_id){
- dlog( "db_sync_response ...")
- break
-
- }
- if (glob_mx.prom.init_db_resolve){
- glob_mx.prom.init_db_resolve({aaa:"dsr",pl:parsed.payload})
-
- }
-
- dlog("db_sync_response",ai.from == glob_mx.local_id,ai.from,parsed)
- break;
-
- }
- /*
-
-
- if (parsed.type == "set_msg"){
- var o = parsed.payload
- pf._set_recv(o.path,o.key,o.val)
- }
- if (parsed.type == "msg_test"){
- clog("msg_test",parsed)
- }
- */
-
- } catch (err) {
- clog("mhndlr err:",err)
- }
- return true
- }
-
- isProxy = Symbol("isProxy")
-
-
- tlu = {
- object:"",
- string:true,
- number:true,
- undefined:true,
- boolean:true,
- }
-
-
-
- function type_info(o){
- var t
- var flags = {
- leaf:false,
- deep_not_prx:false,
- prx:false,
- isObj:false,
- isArr:false,
- els:false,
- }
- t = typeof(o)
- flags.t=t
- if (!(o === null)){
- flags.isArr = Array.isArray(o)
- flags.isObj = Object.prototype == o.__proto__
- }
-
- if (tlu[t] === true || o === null){
- flags.leaf = true
- } else if (t == "object" && o.__prx){
- flags.prx = true
- } else if (t == "object" && (flags.isArr || flags.isObj)){
- flags.prx = false
- flags.deep_not_prx = true
- } else {
- clog("ELSE")
- flags.els = true
- }
-
- return flags
-
- clog(t,flags)
- }
-
-
-
-
-
- function deep_prop_v0(o,p){
- try {
- var arr = jc(p)
- var ret = o
-
- while (arr.length){
- // clog("deep_prop",arr,ret)
- ret = ret[arr.shift()]
- }
- // clog("deep_prop ret",ret)
- return ret
- } catch(err){console.error("DEEP_PROP ERR:",err)}
- }
-
-
-
-
-
- delete Proxy_Factory
- {
-
- class Proxy_Factory {
- constructor(o,n="dflt"){
- this.db = o
- this.n = n
- this.hidden_props = ["add_proxy","_set","walker","walker_start","prxy","_sett","_sett2"]
- this._pub_cb =[]
- this.__prx = true
- this.SymPrx = Symbol("SymPrx")
- }
- init(o){
- // dlog("BP",this,this.baseProp,this.__proto__.baseProp,window.baseProp)
- this.root = o
- }
- sync(o){
- this.root = jc(o.root)
- o._pub_cb.push(this._set_recv.bind(this))
- }
- get prxy(){
- return this
- }
-
- _set(o,k,v,prx,a0){
- this.obj[k]=prx
- }
-
- _sett(o,k,v,prx,a0){
- dlog("_SETT",this,arguments)
- }
- _sett2(o,k,v,prx,a0){
- dlog("_SETT2",this,arguments)
- }
-
- set_pub(obj, prop, val,receiver){
- // dlog("qia_pub",obj, prop, val,receiver)
- // dlog("qia_pub2",this.n,obj.__path_arr, prop, jx(val))
- this._set_pub(obj.__path_arr, prop, jx(val))
-
- }
- _set_pub(path,key,val){
- var k,v
- // /*
-
- tmsgx({
- "type":"set_msg",
- "payload":{path,key,val},
- },"code")
- // */
- for (v of this._pub_cb){
- v(path,key,val)
-
- }
- }
-
- _set_recv(path,prop,val){
- // return
- var p = path
- var nprop = deep_prop_v0(this.root,p)
- var dpth = nprop.__dpth
- if (tlu[typeof(val)]){
- nprop._set(nprop,prop,val,val)
- } else {
- nprop._set(nprop,prop,val,new Proxy(val,this))
- nprop[prop].add_proxy(nprop,prop,val,dpth+1)
- }
- // var tf = {}
- // this.walker(nprop[prop],tf,dpth+2)
- this.walker(nprop[prop],{},dpth+2)
- }
-
- set(obj, prop, val,receiver){
- // dlog("prx_db set ",this,obj, prop, val,receiver,val.__prx)
- // clog("prx_db set ",{that:this,obj, prop, val,receiver},val.__prx)
- // clog("prx_db set ",obj.__path_arr)
- if (obj[prop] === val){
- return Reflect.set(...arguments)
- }
-
- this.set_pub(obj, prop, val,receiver)
- this.event_proc("set")
-
- if ("__prx" == prop){
- this.__prx=val
- return this.__prx
- }
-
- if (typeof(val) === "object" && val != null && !(val.__prx)){
- var ret = Reflect.set(...arguments)
- this.set_obj(obj, prop, val,receiver)
- return ret
- }
-
- return Reflect.set(...arguments)
- }
- get(obj, prop,receiver){
- // dlog("prx_db get ...",prop==isProxy,this,obj, prop,receiver)
- if (this.hidden_props.includes(prop)){
- switch (prop){
- case "add_proxy":
- return this.add_proxy.bind(this)
- break;
- case "prxy":
- return this
- case "_set":
- // dlog("_SET")
- // return this._set.bind({this})
- return this._set.bind({that:this,obj, prop,receiver})
- case "_sett":
- return this._sett.bind({that:this,obj, prop,receiver})
- case "_sett2":
- return this._sett2.bind({that:this})
- case "walker_start":
- return this.walker_start
- case "walker":
- return this.walker
- break;
- }
- }
-
- if (isProxy == prop){ return true }
- if ("__prx" == prop){ return this.__prx }
-
- return Reflect.get(...arguments)
- }
- add_proxy(o,k,v,dpth){
- // clog("~add_proxy~",o,k,v,dpth)
- // clog("~add_proxy~",o.__prx,o,k,v,dpth,xpath)
- var xpath = o.__path
- var apath = o.__path_arr
- this.event_proc("add_proxy")
- if (!apath){
- apath=[]
- }
-
- if (!xpath){
- xpath="ROOT!"
- }
-
- Object.defineProperty(v,"__path_arr",Object.assign({value:apath.concat(k),},this.baseProp))
- Object.defineProperty(v,"__path",Object.assign({value:xpath+":"+k,},this.baseProp))
- Object.defineProperty(v,"__dpth",Object.assign({value:dpth,},this.baseProp))
- // Object.defineProperty(v,"__dbg",Object.assign({value:{},},this.baseProp))
-
- }
- set_obj(obj, prop, val,receiver){
- var dpth = obj.__dpth
- var tf = {}
- this.walker(receiver,tf,dpth)
- }
-
- walker(o,tfo,dpth=0){
- // dlog("qia WALK",this)
- if (dpth > 7){
- console.error("MAX DEPTH")
- return
- }
- var k,v
- var tf
- for ([k,v] of Object.entries(o)){
- tf = type_info(v)
- if (tf.deep_not_prx){
- o._set(o,k,v,new Proxy(v,this.prxy))
- o[k].add_proxy(o,k,v,dpth)
- this.walker(o[k],tf,dpth+1)
- }
- }
- }
- walker_start(o,dpth){
- var tf = type_info(o)
- o.add_proxy({},[],o,-1)
- this.walker(o,tf,0)
- }
- event_proc(e){}
- }
- window.Proxy_Factory = Proxy_Factory
-
- Proxy_Factory.prototype.baseProp={
- writable: true,
- // enumerable: true,
- enumerable: false,
- configurable: true,
- }
- }
-
-
- function arr_match(m,o){
- var k,v
- var r = 0
- for ([k,v] of Object.entries(m || {})){
- if (o[k] != v.valueOf()){
- r += 1
- return !r
- }
-
- // for ([k,v] in m){
- // case
- // dlog(k,v)
- }
- return !r
- }
-
- permissions_def = {
- participants:{
- m:["participants"],
- fn(set_scope,match){
-
-
- // clog("FN....",match.fp,match.fp[1] == window.glob_mx.local_id)
- if (match.fp[1] != window.glob_mx.local_id)
- throw "permission err"
- return
- },
- }
- }
- //
- // msto.my_data.prxy.__proto__.__proto__.set.call(msto.my_data.prxy,msto.participants,"abc2",{})
- permissions_def__set = {
- participants:{
- m:["participants"],
- fn(set_scope,match){
-
-
- dlog("FN....",match.fp,match.fp[1] == window.glob_mx.local_id)
- if (match.fp[1] != window.glob_mx.local_id)
- // throw "permission err"
- return
- },
- }
- }
-
-
- {
- class Proxy_Permissions extends Proxy_Factory {
- constructor(a,a1){
- super(...arguments)
- }
- set(obj, prop, val,receiver){
- // clog("PRX_PERM",obj.__path_arr,prop)
- var k,v
- var r
- var matched
- var fp = obj.__path_arr.concat(prop)
- for ([k,v] of Object.entries(permissions_def)){
- matched = arr_match(v.m,fp)
- if (matched){
- r = v.fn({that:this,obj, prop, val,receiver},{fp,k,v}) || {}
- }
- // if (r.return)
- }
- // case
- // if (obj.__path_arr && obj.__path_arr.length){}
- return super.set(obj, prop, val,receiver)
- }
- _set(){
- // clog("Proxy_Permissions _set")
- super._set(...arguments)
- }
- }
- window.Proxy_Permissions = Proxy_Permissions
- }
-
-
- msto_z = {
- // private_local:{},
- // participant_local:{},
- conference:{},
- participants:{
- },
- }
-
-
-
-
-
- function pfnf(o){
- return function(resolve, reject){
- o.resolve=resolve
- o.reject=reject
- // clog(arguments)
- }
- }
-
-
-
-
-
-
-
-
- function init_db_cb(){
- }
- function init_sync_participant(){
- }
- function init_db(objx){
- var obj
- if (objx.participants){
- obj = objx
- } else {
- obj = objx.pl
- }
- // var obj = obj.pl
- clog("INIT DB...",objx,obj)
- pf = new Proxy_Permissions({},"pf")
- msto_prx = new Proxy(obj,pf)
- window.msto_prx0 =msto_prx
- // msto_prx = new Proxy(msto_z,pf)
- pf.init(msto_prx)
- msto_prx.walker_start(msto_prx)
-
- pf.root.participants[glob_mx.local_id] = {}
- glob_mx.flags.init_db = true
-
-
- window.msto= {
- participants:pf.root.participants,
- conference:pf.root.conference,
- my_data:pf.root.participants[glob_mx.local_id],
- private_local:{},
- set_listeners:{
-
- },
- }
- // var k,v
- clog("RUN_CB...")
- run_cbs("init_db")
- }
-
- function init_mu(persistent_mods){
- // .role == "moderator"
- // clog(">>>>>>>>>>>>>>>>>>>.. RUN_CB")
- var participants = get_participants()
- // clog(participants)
-
-
-
-
- var local = get_local(participants)
- if (window.glob_mx.local_id && persistent_mods && local.role=="moderator"){
- // if window.glob_mx.local_id
- // clog("no RUN_CB")
-
- return
- }
- window.glob_mx.local_id = local.id
- var k,v
- window.glob_mx.all_ids = []
- window.glob_mx.all_jids = []
- for (v of participants){
- window.glob_mx.all_ids.push(v.id)
- window.glob_mx.all_jids.push(`nnnx@conference.jfidev.com/${v.id}`)
- }
- var rr = {}
- var prom1 = new Promise(pfnf(rr));
- prom1.then(init_db)
- // setTimeout(rr.reject,2000,"RESP DB Timeout")
- // setTimeout(rr.resolve,4000,"RESP DB Timeout")
- // setTimeout(rr.resolve,4000,msto_z)
- // setTimeout(rr.resolve,4000,{aaa:"timedout",pl:msto_z})
- setTimeout(rr.resolve,5000,{aaa:"timedout",pl:msto_z})
-
- if (participants.length > 1){
- glob_mx.prom.init_db_resolve = rr.resolve
- tmsgx3({type:"db_sync_request"})
-
- } else {
- // glob_mx.prom.init_db_resolve(msto_z)
- rr.resolve(msto_z)
- // init_db()
-
- }
- }
-
-
-
-
- function create_db(){
-
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- function isident(){
- return JSON.stringify(pf.root) == JSON.stringify(pf2.root)
- }
-
-
-
- function init_mu_runner(){
- if (window.glob_mx.conf_joined){
- init_mu(...arguments)
- }
- }
-
-
- function init_mx2(){
- clog("INITMX3")
- window.glob_mx.conf_joined =1
- init_mu_runner()
- // add_handler_m(mhndlr)
- }
- window.init_mx2 = init_mx2
- // ifn_obj.init_conf_join.push(init_mx2)
-
- // init_mu_runner("auto")
- init_mu_runner("")
-
|