12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175 |
- "use strict";
- ( function( window ) {
- window.console && console.debug && console.debug( "loading vwf" );
- window.vwf = new function() {
- var application;
- var self = this;
- window.console && console.debug && console.debug( "creating vwf" );
-
-
-
-
-
-
-
- this.configuration = undefined;
-
-
-
-
-
- this.kutility = undefined;
-
-
-
-
-
- this.logger = undefined;
-
-
-
-
-
- this.modules = [];
-
-
-
-
-
-
- this.models = [];
-
-
-
-
-
-
- this.views = [];
-
-
-
-
-
- Object.defineProperty( this.models, "actual", {
- get: function() {
-
- var actual = this.map( function( model ) {
- return last( model );
- } );
-
- for ( var propertyName in this ) {
- if ( isNaN( Number( propertyName ) ) ) {
- actual[propertyName] = last( this[propertyName] );
- }
- }
-
- function last( model ) {
- while ( model.model ) model = model.model;
- return model;
- }
- return actual;
- }
- } );
-
-
-
-
-
- Object.defineProperty( this.views, "actual", {
- get: function() {
-
- var actual = this.map( function( model ) {
- return last( model );
- } );
-
- for ( var propertyName in this ) {
- if ( isNaN( Number( propertyName ) ) ) {
- actual[propertyName] = last( this[propertyName] );
- }
- }
-
- function last( model ) {
- while ( model.model ) model = model.model;
- return model;
- }
- return actual;
- }
- } );
-
-
-
-
-
-
- this.now = 0;
-
-
-
-
-
-
-
-
-
-
-
- this.sequence_ = undefined;
-
-
-
-
-
-
- this.client_ = undefined;
-
-
-
-
-
- this.moniker_ = undefined;
-
-
-
-
-
- this.tickable = {
-
-
- nodeIDs: [],
- };
-
-
-
-
- this.private = {};
-
-
-
-
-
-
-
- var components = this.private.components = {};
-
-
-
-
-
- var socket = this.private.socket = undefined;
-
-
-
-
-
-
-
-
- var vwf = this;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- this.loadConfiguration = async function(/* [ componentURI|componentObject ] { modelInitializers }
- { viewInitializers } */) {
- var args = Array.prototype.slice.call( arguments );
- if ( typeof args[0] != "object" || ! ( args[0] instanceof Array ) ) {
- application = args.shift();
- }
- var userLibraries = args.shift() || {};
- var applicationConfig = {};
- var callback = args.shift();
- var requireConfig = {
- baseUrl: '/',
- shim: {
-
- "vwf/model/aframe/addon/aframe-interpolation": {
- deps: [ "vwf/model/aframe/aframe-master" ]
- },
- "vwf/model/aframe/extras/aframe-extras.loaders": {
- deps: [ "vwf/model/aframe/aframe-master" ]
- },
- "vwf/model/aframe/addon/aframe-sun-sky": {
- deps: [ "vwf/model/aframe/aframe-master" ]
- },
- "vwf/model/aframe/extras/aframe-extras.controls.min": {
- deps: [ "vwf/model/aframe/aframe-master" ]
- },
- "vwf/model/aframe/addon/SkyShader": {
- deps: [ "vwf/model/aframe/aframe-master" ]
- },
- "vwf/model/aframe/addon/BVHLoader": {
- deps: [ "vwf/model/aframe/aframe-master" ]
- },
- "vwf/model/aframe/addon/TransformControls": {
- deps: [ "vwf/model/aframe/aframe-master" ]
- },
- "vwf/model/aframe/addon/THREE.MeshLine": {
- deps: [ "vwf/model/aframe/aframe-master" ]
- },
- "vwf/model/aframe/kframe/aframe-aabb-collider-component.min": {
- deps: [ "vwf/model/aframe/aframe-master" ]
- },
- "vwf/model/aframe/addon/aframe-components": {
- deps: [ "vwf/model/aframe/aframe-master",
- "vwf/model/aframe/extras/aframe-extras.loaders",
- "vwf/model/aframe/addon/aframe-sun-sky",
- "vwf/model/aframe/addon/SkyShader",
- "vwf/model/aframe/addon/BVHLoader",
- "vwf/model/aframe/addon/TransformControls",
- "vwf/model/aframe/addon/THREE.MeshLine",
- "vwf/model/aframe/kframe/aframe-aabb-collider-component.min"
- ]
- },
- "vwf/view/arjs/aframe-ar": {
- deps: [ "vwf/model/aframe/aframe-master" ]
- }
- }
- };
-
- var requireArray = [
- { library: "domReady", active: true },
- { library: "vwf/configuration", active: true },
- { library: "vwf/kernel/model", active: true },
- { library: "vwf/model/javascript", active: true },
- { library: "vwf/model/object", active: true },
- { library: "vwf/model/stage/log", active: true },
- { library: "vwf/model/ohm", active: true },
- { library: "vwf/model/osc", active: true },
-
- { library: "vwf/model/aframe/addon/aframe-components",
- linkedLibraries: [ "vwf/model/aframe/addon/SkyShader" ],
- active: false
- },
- { library: "vwf/model/aframe",
- linkedLibraries: [ "vwf/model/aframe/aframe-master",
- "vwf/model/aframe/extras/aframe-extras.loaders",
- "vwf/model/aframe/addon/aframe-interpolation",
- "vwf/model/aframe/addon/aframe-sun-sky",
- "vwf/model/aframe/addon/aframe-components",
- "vwf/model/aframe/addon/SkyShader",
- "vwf/model/aframe/extras/aframe-extras.controls.min",
- "vwf/model/aframe/addon/BVHLoader",
- "vwf/model/aframe/addon/TransformControls",
- "vwf/model/aframe/addon/THREE.MeshLine",
- "vwf/model/aframe/kframe/aframe-aabb-collider-component.min"
-
- ],
- active: false
- },
- { library: "vwf/model/aframeComponent", active: true },
- { library: "vwf/kernel/view", active: true },
- { library: "vwf/view/document", active: true },
- { library: "vwf/view/editor-new", active: false },
- { library: "vwf/view/webrtc",
-
- active: true
- },
- { library: "vwf/view/ohm", active: true },
- { library: "vwf/view/osc", active: true },
- { library: "vwf/view/aframe-ar-driver",
- linkedLibraries: [ "vwf/model/aframe/aframe-master"],
- active: false
- },
-
- { library: "vwf/view/aframe", active: true },
- { library: "vwf/model/aframe/aframe-master", active: false },
- { library: "vwf/model/aframe/extras/aframe-extras.loaders", active: false },
- { library: "vwf/model/aframe/addon/aframe-interpolation", active: false },
- { library: "vwf/model/aframe/addon/aframe-sun-sky", active: false },
- { library: "vwf/model/aframe/addon/aframe-components", active: false },
- { library: "vwf/model/aframe/addon/BVHLoader", active: false },
- { library: "vwf/model/aframe/addon/TransformControls", active: false },
- { library: "vwf/model/aframe/addon/THREE.MeshLine", active: false },
- { library: "vwf/model/aframe/kframe/aframe-aabb-collider-component.min", active: false },
-
-
-
-
- { library: "vwf/model/aframe/addon/SkyShader", active: false },
- { library: "vwf/model/aframe/extras/aframe-extras.controls.min", active: false },
- { library: "vwf/view/aframeComponent", active: true },
- { library: "vwf/kernel/utility", active: true },
- { library: "vwf/utility", active: true },
-
-
-
-
- ];
- var initializers = {
- model: [
- { library: "vwf/model/javascript", active: true },
- { library: "vwf/model/ohm", active: true },
- { library: "vwf/model/osc", active: true },
-
- { library: "vwf/model/aframe", active: true },
- { library: "vwf/model/aframeComponent", active: true },
- { library: "vwf/model/object", active: true }
- ],
- view: [
- { library: "vwf/view/aframe", active: true },
- { library: "vwf/view/aframeComponent", active: true },
- { library: "vwf/view/document", active: true },
- { library: "vwf/view/editor-new", active: false },
- { library: "vwf/view/ohm", active: true },
- { library: "vwf/view/osc", active: true },
- { library: "vwf/view/aframe-ar-driver", active: false },
- { library: "vwf/view/webrtc", active: true}
-
- ]
- };
- mapLibraryName(requireArray);
- mapLibraryName(initializers["model"]);
- mapLibraryName(initializers["view"]);
- function mapLibraryName(array) {
- for(var i=0;i<array.length;i++) {
- array[array[i].library] = array[i];
- }
- }
- function getActiveLibraries(libraryList, includeParameters) {
- var activeLibraryList = [];
- for(var i=0; i<libraryList.length; i++) {
- if(libraryList[i].active) {
- if(includeParameters) {
- var activeLibrary = {};
- activeLibrary[libraryList[i].library] = libraryList[i].parameters;
- activeLibraryList.push(activeLibrary);
- }
- else {
- activeLibraryList.push(libraryList[i].library);
- }
- }
- }
- return activeLibraryList;
- }
- let path = JSON.parse(localStorage.getItem('lcs_app')).path.public_path;
- let appName = JSON.parse(localStorage.getItem('lcs_app')).path.application.split(".").join("_");
- let dbPath = appName + '_config_yaml';
-
- let userDB = _LCSDB.user(_LCS_WORLD_USER.pub);
- userDB.get('worlds').get(path.slice(1)).get(dbPath).get('file').load(function(res) {
-
- var conf = "";
- if (res) {
- let config = YAML.parse(res);
- conf = config
- }
- let manualSettings = localStorage.getItem('lcs_app_manual_settings');
- if(manualSettings){
- let manualConf = JSON.parse(manualSettings);
- conf.model = manualConf.model;
- conf.view = manualConf.view;
- }
- let confPromise = new Promise((resolve, reject) => {
- resolve(conf);
- });
-
- confPromise.then(function(configLibraries) {
- if(configLibraries && typeof configLibraries == "object") {
- if (typeof configLibraries.configuration == "object") {
- applicationConfig = configLibraries.configuration;
- }
- Object.keys(configLibraries).forEach(function(libraryType) {
- if(libraryType == 'info' && configLibraries[libraryType]["title"])
- {
-
- document.querySelector('title').innerHTML = configLibraries[libraryType]["title"]
- }
- if(!userLibraries[libraryType]) {
- userLibraries[libraryType] = {};
- }
-
-
- Object.keys(configLibraries[libraryType]).forEach(function(libraryName) {
- var disabled = false;
- if(requireArray[libraryName] && requireArray[libraryName].disabledBy) {
- for(var i=0; i<requireArray[libraryName].disabledBy.length; i++) {
- Object.keys(userLibraries).forEach(function(userLibraryType) {
- Object.keys(userLibraries[userLibraryType]).forEach(function(userLibraryName) {
- if(requireArray[libraryName].disabledBy[i] == userLibraryName) {
- disabled = true;
- }
- })
- })
- }
- }
- if(!disabled) {
- if(userLibraries[libraryType][libraryName] == undefined) {
- userLibraries[libraryType][libraryName] = configLibraries[libraryType][libraryName];
- }
- else if(typeof userLibraries[libraryType][libraryName] == "object" && typeof configLibraries[libraryType][libraryName] == "object") {
- userLibraries[libraryType][libraryName] = Object.assign({}, configLibraries[libraryType][libraryName], userLibraries[libraryType][libraryName]);
-
- }
- }
- });
- });
- }
- }).then(function(){
- Object.keys(userLibraries).forEach(function(libraryType) {
- if(initializers[libraryType]) {
- Object.keys(userLibraries[libraryType]).forEach(function(libraryName) {
- if(requireArray[libraryName]) {
- requireArray[libraryName].active = true;
- initializers[libraryType][libraryName].active = true;
- if(userLibraries[libraryType][libraryName] && userLibraries[libraryType][libraryName] != "") {
- if(typeof initializers[libraryType][libraryName].parameters == "object") {
-
- initializers[libraryType][libraryName].parameters = Object.assign({}, initializers[libraryType][libraryName].parameters, userLibraries[libraryType][libraryName]);
-
-
- }
- else {
- initializers[libraryType][libraryName].parameters = userLibraries[libraryType][libraryName];
- }
- }
- if(requireArray[libraryName].linkedLibraries) {
- for(var i=0; i<requireArray[libraryName].linkedLibraries.length; i++) {
- requireArray[requireArray[libraryName].linkedLibraries[i]].active = true;
- }
- }
- }
- });
- }
- });
-
-
- if(Object.keys(userLibraries["model"]).length == 0 && Object.keys(userLibraries["view"]).length == 0) {
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
-
- require( requireConfig, getActiveLibraries(requireArray, false), function( ready ) {
-
- ready( async function() {
-
-
-
-
- require( "vwf/configuration" ).instance = require( "vwf/utility" ).merge(
- {}, require( "vwf/configuration" ).instance, applicationConfig );
-
-
-
-
-
- await vwf.initialize(application, getActiveLibraries(initializers["model"], true), getActiveLibraries(initializers["view"], true), callback);
-
- } );
-
- } );
- })
-
- },{wait: 200})
-
-
-
-
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- this.initialize = async function( /* [ componentURI|componentObject ] [ modelInitializers ]
- [ viewInitializers ] */ ) {
- var args = Array.prototype.slice.call( arguments );
-
-
-
- this.configuration = require( "vwf/configuration" ).active;
-
- this.kutility = require( "vwf/kernel/utility" );
-
- this.logger = require( "logger" ).for( "vwf", this );
-
-
-
-
-
-
- if ( typeof args[0] != "object" || ! ( args[0] instanceof Array ) ) {
- application = args.shift();
- }
-
- var modelInitializers = args.shift() || [];
-
- var viewInitializers = args.shift() || [];
- var callback = args.shift();
- var compatibilityStatus = { compatible: true, errors: {} };
-
-
- this.models.kernel = require( "vwf/kernel/model" ).create( vwf );
-
- modelInitializers.forEach( function( modelInitializer ) {
-
-
- if ( modelInitializer ) {
-
- if ( typeof modelInitializer == "object" && modelInitializer != null ) {
- var modelName = Object.keys( modelInitializer )[0];
- var modelArguments = modelInitializer[modelName];
- } else {
- var modelName = modelInitializer;
- var modelArguments = undefined;
- }
- var model = require( modelName ).create(
- this.models.kernel,
- [ require( "vwf/model/stage/log" ) ],
- {},
- [].concat( modelArguments || [] )
- );
- if ( model ) {
- this.models.push( model );
- this.models[modelName] = model;
- if ( modelName == "vwf/model/javascript" ) {
- this.models.javascript = model;
- while ( this.models.javascript.model ) this.models.javascript = this.models.javascript.model;
- }
- if ( modelName == "vwf/model/object" ) {
- this.models.object = model;
- while ( this.models.object.model ) this.models.object = this.models.object.model;
- }
-
- if(model.model.compatibilityStatus) {
- if(!model.model.compatibilityStatus.compatible) {
- compatibilityStatus.compatible = false;
- Object.assign(compatibilityStatus.errors, model.model.compatibilityStatus.errors);
-
- }
- }
- }
- }
- }, this );
-
-
-
- this.views.kernel = require( "vwf/kernel/view" ).create( vwf );
-
- viewInitializers.forEach( function( viewInitializer ) {
-
-
- if ( viewInitializer ) {
-
- if ( typeof viewInitializer == "object" && viewInitializer != null ) {
- var viewName = Object.keys( viewInitializer )[0];
- var viewArguments = viewInitializer[viewName];
- } else {
- var viewName = viewInitializer;
- var viewArguments = undefined;
- }
- if ( ! viewName.match( "^vwf/view/" ) ) {
- var view = this.modules[viewName];
- if ( view ) {
- var instance = new view();
- instance.state = this.models.actual["vwf/model/"+viewName] && this.models.actual["vwf/model/"+viewName].state || {};
- view.apply( instance, [ vwf ].concat( viewArguments || [] ) );
- this.views.push( instance );
- this.views[viewName] = instance;
- if(view.compatibilityStatus) {
- if(!view.compatibilityStatus.compatible) {
- compatibilityStatus.compatible = false;
- Object.assign(compatibilityStatus.errors, view.compatibilityStatus.errors);
-
- }
- }
- }
- } else {
- var modelPeer = this.models.actual[ viewName.replace( "vwf/view/", "vwf/model/" ) ];
- var view = require( viewName ).create(
- this.views.kernel,
- [],
- modelPeer && modelPeer.state || {},
- [].concat( viewArguments || [] )
- );
- if ( view ) {
- this.views.push( view );
- this.views[viewName] = view;
- if(view.compatibilityStatus) {
- if(!view.compatibilityStatus.compatible) {
- compatibilityStatus.compatible = false;
- Object.assign(compatibilityStatus.errors, view.compatibilityStatus.errors);
-
- }
- }
- }
- }
- }
- }, this );
-
- if(!(function() { return !this })()) {
- compatibilityStatus.compatible = false;
- Object.assign(compatibilityStatus.errors, {"ES5": "This browser is not compatible. VWF requires ECMAScript 5."});
-
- }
-
-
-
-
-
-
- if(callback) {
- callback(compatibilityStatus);
- }
-
- await _app.getApplicationState()
- .then(res => {self.ready( application, res)})
- };
-
-
- this.ready = function( component_uri_or_json_or_object, path ) {
-
-
- try {
- let objToRef = Object.assign({}, path);
- if(path.saveObject){
- if ( path.saveObject[ "queue" ] ) {
- if ( path.saveObject[ "queue" ][ "time" ] ) {
- objToRef.saveObject = {
- "init": true,
- "queue":{
- "time": path.saveObject[ "queue" ][ "time" ]
- }
- }
- }
- }
- }
-
-
- var options = {
-
-
-
- query: {
- pathname: window.location.pathname.slice( 1,
- window.location.pathname.lastIndexOf("/") ),
- appRoot: "./public",
- path: JSON.stringify(objToRef)
- },
-
-
-
-
- secure: window.location.protocol === "https:",
-
-
-
- reconnection: false,
- upgrade: false,
- transports: ['websocket']
- };
- if ( isSocketIO07() ) {
-
- var host = window._app.reflectorHost;
-
- socket = io.connect( host, options );
-
- } else {
- io.util.merge( options, {
-
-
- port: window.location.port ||
- ( window.location.protocol === "https:" ? 443 : 80 ),
-
- transports: [
- 'websocket',
- ],
-
-
-
- transportOptions: {
- "websocket": { timeout: 90000 },
- },
- } );
- socket = io.connect( undefined, options );
- }
- } catch ( e ) {
-
-
-
-
- this.dispatch();
- setInterval( function() {
- var fields = {
- time: vwf.now + 0.010,
- origin: "reflector",
- };
- queue.insert( fields, true );
- }, 10 );
- }
- if ( socket ) {
- socket.on('connect_error', function(err) {
- console.log(err);
- var errDiv = document.createElement("div");
- errDiv.innerHTML = "<div class='vwf-err' style='z-index: 10; position: absolute; top: 80px; right: 50px'>Connection error!" + err + "</div>";
- document.querySelector('body').appendChild(errDiv);
-
- });
- socket.on( "connect", function() {
- vwf.logger.infox( "-socket", "connected" );
- if ( isSocketIO07() ) {
- vwf.moniker_ = this.id;
- } else {
- vwf.moniker_ = this.transport.sessionid;
- }
- } );
-
-
-
-
-
-
-
- socket.on( "message", function( message ) {
-
- try {
- if ( isSocketIO07() ) {
- var fields = message;
- } else {
- var fields = JSON.parse( message );
- }
- fields.time = Number( fields.time );
-
- fields.origin = "reflector";
-
-
- queue.insert( fields, !fields.action );
-
-
-
-
-
-
-
- } catch ( e ) {
- vwf.logger.warn( fields.action, fields.node, fields.member, fields.parameters,
- "exception performing action:", require( "vwf/utility" ).exceptionMessage( e ) );
- }
- } );
- socket.on( "disconnect", function() {
- vwf.logger.infox( "-socket", "disconnected" );
-
- window.location = window.location.href;
- } );
- socket.on( "error", function() {
-
- document.querySelector('body').innerHTML = "<div class='vwf-err'>WebSockets connections are currently being blocked. Please check your proxy server settings.</div>";
-
- } );
- if ( !isSocketIO07() ) {
-
- socket.connect();
- }
- } else if ( component_uri_or_json_or_object ) {
-
-
-
-
-
-
- this.createNode( component_uri_or_json_or_object, "application" );
- } else {
-
- }
- };
-
-
- this.plan = function( nodeID, actionName, memberName, parameters, when, callback_async /* ( result ) */ ) {
- this.logger.debuggx( "plan", nodeID, actionName, memberName,
- parameters && parameters.length, when, callback_async && "callback" );
- var time = when > 0 ?
- Math.max( this.now, when ) :
- this.now + ( -when );
- var fields = {
- time: time,
- node: nodeID,
- action: actionName,
- member: memberName,
- parameters: parameters,
- client: this.client_,
- origin: "future",
-
- };
- queue.insert( fields );
- this.logger.debugu();
- };
-
-
-
-
-
- this.send = function( nodeID, actionName, memberName, parameters, when, callback_async /* ( result ) */ ) {
- this.logger.debuggx( "send", nodeID, actionName, memberName,
- parameters && parameters.length, when, callback_async && "callback" );
- var time = when > 0 ?
- Math.max( this.now, when ) :
- this.now + ( -when );
-
- var fields = {
- time: time,
- node: nodeID,
- action: actionName,
- member: memberName,
- parameters: require( "vwf/utility" ).transform( parameters, require( "vwf/utility" ).transforms.transit ),
-
- };
- if ( socket ) {
-
-
- var message = JSON.stringify( fields );
- socket.send( message );
-
- } else {
-
-
- fields.client = this.moniker_;
- fields.origin = "reflector";
- queue.insert( fields );
-
- }
- this.logger.debugu();
- };
-
-
-
-
- this.respond = function( nodeID, actionName, memberName, parameters, result ) {
- this.logger.debuggx( "respond", nodeID, actionName, memberName,
- parameters && parameters.length, "..." );
-
- var fields = {
-
- time: this.now,
- node: nodeID,
- action: actionName,
- member: memberName,
- parameters: require( "vwf/utility" ).transform( parameters, require( "vwf/utility" ).transforms.transit ),
- result: require( "vwf/utility" ).transform( result, require( "vwf/utility" ).transforms.transit ),
- };
- if ( socket ) {
-
- var message = JSON.stringify( fields );
- socket.send( message );
- } else {
-
- }
- this.logger.debugu();
- };
-
-
-
-
- this.receive = function( nodeID, actionName, memberName, parameters, respond, origin ) {
-
-
-
-
-
-
-
-
- var args = [], result;
- if ( nodeID || nodeID === 0 ) args.push( nodeID );
- if ( memberName ) args.push( memberName );
- if ( parameters ) args = args.concat( parameters );
- if(actionName == 'createChild')
- {
- console.log("create child!");
-
-
-
-
-
-
-
-
-
-
- }
-
- if ( environment( actionName, parameters ) ) {
- require( "vwf/configuration" ).environment = environment( actionName, parameters );
- } else if ( origin !== "reflector" || ! nodeID || nodes.existing[ nodeID ] ) {
- result = this[ actionName ] && this[ actionName ].apply( this, args );
- } else {
- this.logger.debugx( "receive", "ignoring reflector action on non-existent node", nodeID );
- result = undefined;
- }
-
- respond && this.respond( nodeID, actionName, memberName, parameters, result );
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- function environment( actionName, param ) {
- if ( actionName === "setState" && ! vwf.application() ) {
- var parameters = param;
- if (parameters[0].init){
- parameters = [JSON.parse(localStorage.getItem('lcs_app')).saveObject]
- }
- var applicationState = parameters && parameters[0];
- if ( applicationState && Object.keys( applicationState ).length === 1 &&
- applicationState.configuration && Object.keys( applicationState.configuration ).length === 1 ) {
- return applicationState.configuration.environment;
- }
- }
- return undefined;
- }
- };
-
-
-
-
-
-
- this.dispatch = function() {
- var fields;
-
-
- while ( fields = queue.pull() ) {
-
- if ( this.now != fields.time ) {
- this.sequence_ = undefined;
- this.client_ = undefined;
- this.now = fields.time;
- this.tock();
- }
-
- if ( fields.action ) {
- this.sequence_ = fields.sequence;
- this.client_ = fields.client;
- this.receive( fields.node, fields.action, fields.member, fields.parameters, fields.respond, fields.origin );
- }
- else {
- this.tick();
- }
- }
-
-
- if ( queue.ready() && this.now != queue.time ) {
- this.sequence_ = undefined;
- this.client_ = undefined;
- this.now = queue.time;
- this.tock();
- }
-
- };
-
-
-
-
- this.log = function() {
- this.respond( undefined, "log", undefined, undefined, arguments );
- }
-
-
-
-
-
-
- this.tick = function() {
-
- this.models.forEach( function( model ) {
- model.ticking && model.ticking( this.now );
- }, this );
-
- this.views.forEach( function( view ) {
- view.ticked && view.ticked( this.now );
- }, this );
-
- this.tickable.nodeIDs.forEach( function( nodeID ) {
- this.callMethod( nodeID, "tick", [ this.now ] );
- }, this );
- };
-
-
-
-
-
-
- this.tock = function() {
-
- this.views.forEach( function( view ) {
- view.tocked && view.tocked( this.now );
- }, this );
- };
-
-
-
-
-
-
-
-
-
- this.setState = function( appState, callback_async /* () */ ) {
- this.logger.debuggx( "setState" );
-
- var applicationState = appState;
- if (applicationState.init){
- applicationState = JSON.parse(localStorage.getItem('lcs_app')).saveObject
- }
- if ( applicationState.configuration ) {
- require( "vwf/configuration" ).instance = applicationState.configuration;
- }
-
- if ( applicationState.kernel ) {
- if ( applicationState.kernel.time !== undefined ) vwf.now = applicationState.kernel.time;
- }
-
- var nodes = applicationState.nodes || [];
- var annotations = applicationState.annotations || {};
- var nodeIndex = 0;
- async.forEachSeries( nodes, function( nodeComponent, each_callback_async /* ( err ) */ ) {
-
-
-
- var nodeAnnotation = nodes.length > 1 || applicationState.annotations ?
- annotations[nodeIndex] : "application";
- vwf.createNode( nodeComponent, nodeAnnotation, function( nodeID ) /* async */ {
- each_callback_async( undefined );
- } );
- nodeIndex++;
- }, function( err ) /* async */ {
-
-
- queue.filter( function( fields ) {
- if ( fields.origin === "reflector" && fields.sequence > vwf.sequence_ ) {
- return true;
- } else {
- vwf.logger.debugx( "setState", function() {
- return [ "removing", JSON.stringify( loggableFields( fields ) ), "from queue" ];
- } );
- }
- } );
-
- if ( applicationState.queue ) {
- queue.time = applicationState.queue.time;
- queue.insert( applicationState.queue.queue || [] );
- }
- callback_async && callback_async();
- } );
- this.logger.debugu();
- };
-
-
-
-
- this.getState = function( full, normalize ) {
- this.logger.debuggx( "getState", full, normalize );
-
- var applicationState = {
-
- configuration:
- require( "vwf/configuration" ).active,
-
- kernel: {
- time: vwf.now,
- },
-
- nodes: [
- this.getNode( "http://vwf.example.com/clients.vwf", full ),
- this.getNode( this.application(), full ),
- ],
-
- annotations: {
- 1: "application",
- },
-
- queue: {
- time: queue.time,
- queue: require( "vwf/utility" ).transform( queue.queue, queueTransitTransformation ),
- },
- };
-
- if ( normalize ) {
- applicationState = require( "vwf/utility" ).transform(
- applicationState, require( "vwf/utility" ).transforms.hash );
- }
-
- this.logger.debugu();
- return applicationState;
- };
-
-
-
-
- this.hashState = function() {
- this.logger.debuggx( "hashState" );
- var applicationState = this.getState( true, true );
-
- var hashn = this.hashNode( applicationState.nodes[0] );
-
- var hashq = "q" + Crypto.MD5( JSON.stringify( applicationState.queue ) ).toString().substring( 0, 16 );
-
- var hashk = "k" + Crypto.MD5( JSON.stringify( applicationState.kernel ) ).toString().substring( 0, 16 );
- this.logger.debugu();
-
- return hashn + ":" + hashq + ":" + hashk;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- this.createNode = function( nodeComponent, nodeAnnotation, baseURI, callback_async /* ( nodeID ) */ ) {
-
-
-
-
-
- if ( typeof nodeAnnotation == "function" || nodeAnnotation instanceof Function ) {
- callback_async = nodeAnnotation;
- baseURI = undefined;
- nodeAnnotation = undefined;
- } else if ( typeof baseURI == "function" || baseURI instanceof Function ) {
- callback_async = baseURI;
- baseURI = undefined;
- }
- this.logger.debuggx( "createNode", function() {
- return [ JSON.stringify( loggableComponent( nodeComponent ) ), nodeAnnotation ];
- } );
- var nodePatch;
- if ( componentIsDescriptor( nodeComponent ) && nodeComponent.patches ) {
- nodePatch = nodeComponent;
- nodeComponent = nodeComponent.patches;
- }
-
-
-
- var nodeURI, nodeDescriptor, nodeID;
- async.series( [
-
-
- function( series_callback_async /* ( err, results ) */ ) {
- if ( componentIsURI( nodeComponent ) ) {
-
-
- nodeURI = nodeComponent[0] == "/" ?
- nodeComponent : require( "vwf/utility" ).resolveURI( nodeComponent, baseURI );
-
-
- if ( ! components[nodeURI] ) {
- components[nodeURI] = [];
- loadComponent( nodeURI, undefined, function( nodeDescriptor ) /* async */ {
- nodeComponent = nodeDescriptor;
- series_callback_async(undefined, undefined);
- }, function( errorMessage ) {
- nodeComponent = undefined;
- series_callback_async( errorMessage, undefined );
- } );
-
-
- } else if ( components[nodeURI] instanceof Array ) {
-
- callback_async && components[nodeURI].push( callback_async );
-
-
- } else {
- if ( nodePatch ) {
- vwf.setNode( components[nodeURI], nodePatch, function( nodeID ) /* async */ {
- callback_async && callback_async( components[nodeURI] );
- } );
- } else {
- callback_async && callback_async( components[nodeURI] );
- }
- }
- } else {
- series_callback_async( undefined, undefined );
- }
- },
-
-
-
-
-
-
-
-
-
-
-
-
- function( series_callback_async /* ( err, results ) */ ) {
- if ( componentIsDescriptor( nodeComponent ) && nodeComponent.includes && componentIsURI( nodeComponent.includes ) ) {
- var prototypeURI = require( "vwf/utility" ).resolveURI( nodeComponent.includes, nodeURI || baseURI );
- loadComponent( prototypeURI, undefined, function( prototypeDescriptor ) /* async */ {
- prototypeDescriptor = resolvedDescriptor( prototypeDescriptor, prototypeURI );
- nodeComponent = mergeDescriptors( nodeComponent, prototypeDescriptor );
- series_callback_async( undefined, undefined );
- }, function( errorMessage ) {
- nodeComponent = undefined;
- series_callback_async( errorMessage, undefined );
- } );
- } else {
- series_callback_async( undefined, undefined );
- }
- },
-
-
- function( series_callback_async /* ( err, results ) */ ) {
- if ( componentIsDescriptor( nodeComponent ) ) {
- nodeDescriptor = nodeComponent;
-
- vwf.createChild( 0, nodeAnnotation, nodeDescriptor, nodeURI, function( nodeID ) /* async */ {
- nodeComponent = nodeID;
- series_callback_async( undefined, undefined );
- } );
-
- } else {
- series_callback_async( undefined, undefined );
- }
- },
-
- function( series_callback_async /* ( err, results ) */ ) {
- if ( componentIsID( nodeComponent ) || components[ nodeComponent ] instanceof Array ) {
- nodeID = nodeComponent;
- if ( nodePatch ) {
- vwf.setNode( nodeID, nodePatch, function( nodeID ) /* async */ {
- series_callback_async( undefined, undefined );
- } );
- } else {
- series_callback_async( undefined, undefined );
- }
- } else {
- series_callback_async( undefined, undefined );
- }
- },
- ], function( err, results ) /* async */ {
-
-
- if ( nodeURI ) {
- var callbacks_async = components[nodeURI];
- components[nodeURI] = nodeID;
- }
-
- callback_async && callback_async( nodeID );
-
- if ( nodeURI ) {
- callbacks_async.forEach( function( callback_async ) {
- callback_async && callback_async( nodeID );
- } );
- }
- } );
- this.logger.debugu();
- };
-
-
-
-
- this.deleteNode = function( nodeID ) {
- this.logger.debuggx( "deleteNode", nodeID );
-
-
- var parentID = this.parent( nodeID );
- if ( parentID !== 0 ) {
- var nodeIndex = this.children( parentID ).indexOf( nodeID );
- if ( nodeIndex < 0 ) {
- nodeIndex = undefined;
- }
- if ( this.models.kernel.enabled() ) {
- this.fireEvent( parentID, [ "children", "removed" ],
- [ nodeIndex, this.kutility.nodeReference( nodeID ) ] );
- }
- }
-
-
- Object.keys( components ).some( function( nodeURI ) {
- if ( components[nodeURI] == nodeID ) {
- delete components[nodeURI];
- return true;
- }
- } );
-
-
- this.models.forEach( function( model ) {
- model.deletingNode && model.deletingNode( nodeID );
- } );
-
- nodes.delete( nodeID );
-
-
- this.views.forEach( function( view ) {
- view.deletedNode && view.deletedNode( nodeID );
- } );
- this.logger.debugu();
- };
-
-
-
-
-
-
-
-
-
- this.setNode = function( nodeID, nodeComponent, callback_async /* ( nodeID ) */ ) {
- this.logger.debuggx( "setNode", function() {
- return [ nodeID, JSON.stringify( loggableComponent( nodeComponent ) ) ];
- } );
- var node = nodes.existing[nodeID];
-
- vwf.models.object.internals( nodeID, nodeComponent );
-
-
- vwf.models.kernel.disable();
-
-
-
-
- nodeComponent.properties && Object.keys( nodeComponent.properties ).forEach( function( propertyName ) {
- var propertyValue = nodeComponent.properties[ propertyName ];
-
-
-
-
- var creating = ! node.properties.has( propertyName );
-
-
- if ( valueHasAccessors( propertyValue ) && propertyValue.node ) {
- propertyValue = vwf.kutility.nodeReference( propertyValue.node );
- }
-
- if ( creating ) {
- vwf.createProperty( nodeID, propertyName, propertyValue );
- } else {
- vwf.setProperty( nodeID, propertyName, propertyValue );
- }
- } );
-
- nodeComponent.methods && Object.keys( nodeComponent.methods ).forEach( function( methodName ) {
- var methodHandler = nodeComponent.methods[ methodName ];
- var creating = ! node.methods.has( methodName );
-
- if ( creating ) {
- vwf.createMethod( nodeID, methodName, methodHandler.parameters, methodHandler.body );
- } else {
- vwf.setMethod( nodeID, methodName, methodHandler );
- }
- } );
-
- nodeComponent.events && Object.keys( nodeComponent.events ).forEach( function( eventName ) {
- var eventDescriptor = nodeComponent.events[ eventName ];
- var creating = ! node.events.has( eventName );
-
- if ( creating ) {
- vwf.createEvent( nodeID, eventName, eventDescriptor.parameters );
- vwf.setEvent( nodeID, eventName, eventDescriptor );
- } else {
- vwf.setEvent( nodeID, eventName, eventDescriptor );
- }
- } );
-
- vwf.models.kernel.enable();
- async.series( [
- function( series_callback_async /* ( err, results ) */ ) {
-
-
-
- async.forEach( Object.keys( nodeComponent.children || {} ), function( childName, each_callback_async /* ( err ) */ ) {
- var creating = ! nodeHasOwnChild.call( vwf, nodeID, childName );
- if ( creating ) {
- vwf.createChild( nodeID, childName, nodeComponent.children[childName], undefined, function( childID ) /* async */ {
- each_callback_async( undefined );
- } );
- } else {
- vwf.setNode( nodeComponent.children[childName].id || nodeComponent.children[childName].patches,
- nodeComponent.children[childName], function( childID ) /* async */ {
- each_callback_async( undefined );
- } );
- }
- }, function( err ) /* async */ {
- series_callback_async( err, undefined );
- } );
- },
- function( series_callback_async /* ( err, results ) */ ) {
-
-
-
-
-
- var scripts = nodeComponent.scripts ?
- [].concat( nodeComponent.scripts ) : [];
- var baseURI = vwf.uri( nodeID, true );
- async.map( scripts, function( script, map_callback_async /* ( err, result ) */ ) {
- if ( valueHasType( script ) ) {
- if ( script.source ) {
- loadScript( script.source, baseURI, function( scriptText ) /* async */ {
- map_callback_async( undefined, { text: scriptText, type: script.type } );
- }, function( errorMessage ) {
- map_callback_async( errorMessage, undefined );
- } );
- } else {
- map_callback_async( undefined, { text: script.text, type: script.type } );
- }
- } else {
- map_callback_async( undefined, { text: script, type: undefined } );
- }
- }, function( err, scripts ) /* async */ {
-
-
- vwf.models.kernel.disable();
-
- scripts.forEach( function( script ) {
- vwf.execute( nodeID, script.text, script.type );
- } );
-
- vwf.models.kernel.enable();
- series_callback_async( err, undefined );
- } );
- },
- ], function( err, results ) /* async */ {
- callback_async && callback_async( nodeID );
- } );
- this.logger.debugu();
- return nodeComponent;
- };
-
-
-
-
- this.getNode = function( nodeID, full, normalize ) {
- this.logger.debuggx( "getNode", nodeID, full );
- var node = nodes.existing[nodeID];
-
- var nodeComponent = {};
-
-
-
- var patches = this.models.object.patches( nodeID ),
- patched = false;
- if ( node.patchable ) {
- nodeComponent.patches = node.uri || nodeID;
- } else {
- nodeComponent.id = nodeID;
- }
-
-
- if ( full || ! node.patchable ) {
- var intrinsics = this.intrinsics( nodeID );
- var prototypeID = this.prototype( nodeID );
- if ( prototypeID === undefined ) {
- nodeComponent.extends = null;
- } else if ( prototypeID !== this.kutility.protoNodeURI ) {
- nodeComponent.extends = this.getNode( prototypeID );
- }
- nodeComponent.implements = this.behaviors( nodeID ).map( function( behaviorID ) {
- return this.getNode( behaviorID );
- }, this );
- nodeComponent.implements.length || delete nodeComponent.implements;
- if ( intrinsics.source !== undefined ) nodeComponent.source = intrinsics.source;
- if ( intrinsics.type !== undefined ) nodeComponent.type = intrinsics.type;
- }
-
- if ( full || ! node.patchable || patches.internals ) {
- var internals = this.models.object.internals( nodeID );
- nodeComponent.sequence = internals.sequence;
- nodeComponent.random = internals.random;
- }
-
-
- vwf.models.kernel.disable();
-
- if ( full || ! node.patchable ) {
-
- nodeComponent.properties = this.getProperties( nodeID );
- for ( var propertyName in nodeComponent.properties ) {
- var propertyValue = nodeComponent.properties[propertyName];
- if ( propertyValue === undefined ) {
- delete nodeComponent.properties[propertyName];
- } else if ( this.kutility.valueIsNodeReference( propertyValue ) ) {
-
- nodeComponent.properties[propertyName] = { node: propertyValue.id };
- }
- }
- } else if ( node.properties.changes ) {
-
- nodeComponent.properties = {};
- Object.keys( node.properties.changes ).forEach( function( propertyName ) {
- if ( node.properties.changes[ propertyName ] !== "removed" ) {
- var propertyValue = this.getProperty( nodeID, propertyName );
- if ( this.kutility.valueIsNodeReference( propertyValue ) ) {
-
- nodeComponent.properties[propertyName] = { node: propertyValue.id };
- } else {
- nodeComponent.properties[propertyName] = propertyValue;
- }
- }
- }, this );
- }
- if ( Object.keys( nodeComponent.properties ).length == 0 ) {
- delete nodeComponent.properties;
- } else {
- patched = true;
- }
-
- if ( full || ! node.patchable ) {
- Object.keys( node.methods.existing ).forEach( function( methodName ) {
- nodeComponent.methods = nodeComponent.methods || {};
- nodeComponent.methods[ methodName ] = this.getMethod( nodeID, methodName );
- patched = true;
- }, this );
- } else if ( node.methods.changes ) {
- Object.keys( node.methods.changes ).forEach( function( methodName ) {
- if ( node.methods.changes[ methodName ] !== "removed" ) {
- nodeComponent.methods = nodeComponent.methods || {};
- nodeComponent.methods[ methodName ] = this.getMethod( nodeID, methodName );
- patched = true;
- }
- }, this );
- }
-
- var events = full || ! node.patchable ?
- node.events.existing : node.events.changes;
- if ( events ) {
- Object.keys( events ).forEach( function( eventName ) {
- nodeComponent.events = nodeComponent.events || {};
- nodeComponent.events[ eventName ] = this.getEvent( nodeID, eventName );
- patched = true;
- }, this );
- }
-
- vwf.models.kernel.enable();
-
- nodeComponent.children = {};
- this.children( nodeID ).forEach( function( childID ) {
- nodeComponent.children[ this.name( childID ) ] = this.getNode( childID, full );
- }, this );
- for ( var childName in nodeComponent.children ) {
- if ( nodeComponent.children[childName] === undefined ) {
- delete nodeComponent.children[childName];
- }
- }
- if ( Object.keys( nodeComponent.children ).length == 0 ) {
- delete nodeComponent.children;
- } else {
- patched = true;
- }
-
-
-
- if ( normalize ) {
- nodeComponent = require( "vwf/utility" ).transform(
- nodeComponent, require( "vwf/utility" ).transforms.hash );
- }
- this.logger.debugu();
-
-
- if ( full || ! node.patchable || patched ) {
- return nodeComponent;
- } else if ( node.uri ) {
- return node.uri;
- } else {
- return undefined;
- }
- };
-
-
-
-
- this.hashNode = function( nodeID ) {
- this.logger.debuggx( "hashNode", typeof nodeID == "object" ? nodeID.id : nodeID );
- var nodeComponent = typeof nodeID == "object" ? nodeID : this.getNode( nodeID, true, true );
-
- var internal = { id: nodeComponent.id, source: nodeComponent.source, type: nodeComponent.type };
- internal.source === undefined && delete internal.source;
- internal.type === undefined && delete internal.type;
- var hashi = "i" + Crypto.MD5( JSON.stringify( internal ) ).toString().substring( 0, 16 );
-
- var properties = nodeComponent.properties || {};
- var hashp = Object.keys( properties ).length ?
- "p" + Crypto.MD5( JSON.stringify( properties ) ).toString().substring( 0, 16 ) : undefined;
-
- var children = nodeComponent.children || {};
- var hashc = Object.keys( children ).length ?
- "c" + Crypto.MD5( JSON.stringify( children ) ).toString().substring( 0, 16 ) : undefined;
- this.logger.debugu();
-
- return hashi + ( hashp ? "." + hashp : "" ) + ( hashc ? "/" + hashc : "" );
- };
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- this.createChild = function( nodeID, childName, childComponent, childURI, callback_async /* ( childID ) */ ) {
- this.logger.debuggx( "createChild", function() {
- return [ nodeID, childName, JSON.stringify( loggableComponent( childComponent ) ), childURI ];
- } );
- childComponent = normalizedComponent( childComponent );
- var child, childID, childIndex, childPrototypeID, childBehaviorIDs = [], deferredInitializations = {};
- var resolvedSource;
-
- var replicating = !! childComponent.id;
-
-
-
-
-
-
- if ( childComponent.id ) {
- childID = childComponent.id;
- childIndex = this.children( nodeID ).length;
- } else if ( nodeID === 0 ) {
- childID = childURI ||
- Crypto.MD5( JSON.stringify( childComponent ) ).toString();
- childIndex = childURI;
- } else {
- childID = nodeID + ":" + this.sequence( nodeID ) +
- ( this.configuration["randomize-ids"] ? "-" + ( "0" + Math.floor( this.random( nodeID ) * 100 ) ).slice( -2 ) : "" ) +
- ( this.configuration["humanize-ids"] ? "-" + childName.replace( /[^0-9A-Za-z_-]+/g, "-" ) : "" );
- childIndex = this.children( nodeID ).length;
- }
-
- child = nodes.create( childID, childPrototypeID, childBehaviorIDs, childURI, childName, nodeID );
-
-
-
-
-
- vwf.models.object.creatingNode( nodeID, childID, childPrototypeID, childBehaviorIDs,
- childComponent.source, childComponent.type, childIndex, childName );
-
- var baseURI = vwf.uri( childID, true );
-
- async.series( [
- function( series_callback_async /* ( err, results ) */ ) {
-
-
-
-
-
-
-
- if ( componentIsDescriptor( childComponent ) && childComponent.includes && componentIsURI( childComponent.includes ) ) {
- var prototypeURI = require( "vwf/utility" ).resolveURI( childComponent.includes, baseURI );
- var sync = true;
- loadComponent( prototypeURI, undefined, function( prototypeDescriptor ) /* async */ {
-
- prototypeDescriptor = resolvedDescriptor( prototypeDescriptor, prototypeURI );
-
- childComponent = mergeDescriptors( childComponent, prototypeDescriptor );
- if ( sync ) {
- queue.suspend( "before beginning " + childID );
- async.nextTick( async function() {
- await series_callback_async( undefined, undefined );
- queue.resume( "after beginning " + childID );
- } );
- } else {
- series_callback_async( undefined, undefined );
- }
- }, function( errorMessage ) {
- childComponent = undefined;
- series_callback_async( errorMessage, undefined );
- } );
- sync = false;
- } else {
- queue.suspend( "before beginning " + childID );
- async.nextTick( async function() {
- await series_callback_async( undefined, undefined );
- queue.resume( "after beginning " + childID );
- } );
- }
- },
- function( series_callback_async /* ( err, results ) */ ) {
-
-
- async.parallel( [
- function( parallel_callback_async /* ( err, results ) */ ) {
-
- if ( childComponent.extends !== null ) {
- var prototypeComponent = childComponent.extends || vwf.kutility.protoNodeURI;
- vwf.createNode( prototypeComponent, undefined, baseURI, function( prototypeID ) /* async */ {
- childPrototypeID = prototypeID;
- if ( ! childComponent.source ) {
- var prototype_intrinsics = vwf.intrinsics( prototypeID );
- if ( prototype_intrinsics.source ) {
- var prototype_uri = vwf.uri( prototypeID );
- var prototype_properties = vwf.getProperties( prototypeID );
- childComponent.source = require( "vwf/utility" ).resolveURI( prototype_intrinsics.source, prototype_uri );
- childComponent.type = prototype_intrinsics.type;
- childComponent.properties = childComponent.properties || {};
- Object.keys( prototype_properties ).forEach( function( prototype_property_name ) {
- if ( childComponent.properties[prototype_property_name] === undefined && prototype_property_name != "transform" ) {
- childComponent.properties[prototype_property_name] = prototype_properties[prototype_property_name];
- }
- } );
- }
- }
- parallel_callback_async( undefined, undefined );
- } );
- } else {
- childPrototypeID = undefined;
- parallel_callback_async( undefined, undefined );
- }
- },
- function( parallel_callback_async /* ( err, results ) */ ) {
-
- var behaviorComponents = childComponent.implements ?
- [].concat( childComponent.implements ) : [];
- async.map( behaviorComponents, function( behaviorComponent, map_callback_async /* ( err, result ) */ ) {
- vwf.createNode( behaviorComponent, undefined, baseURI, function( behaviorID ) /* async */ {
- map_callback_async( undefined, behaviorID );
- } );
- }, function( err, behaviorIDs ) /* async */ {
- childBehaviorIDs = behaviorIDs;
- parallel_callback_async( err, undefined );
- } );
- },
- ], function( err, results ) /* async */ {
- series_callback_async( err, undefined );
- } );
- },
- function( series_callback_async /* ( err, results ) */ ) {
-
- child = nodes.create( childID, childPrototypeID, childBehaviorIDs, childURI, childName, nodeID );
-
- if ( childID === vwf.kutility.protoNodeURI ) {
- child.events.create( namespaceEncodedName( [ "properties", "created" ] ) );
- child.events.create( namespaceEncodedName( [ "properties", "initialized" ] ) );
- child.events.create( namespaceEncodedName( [ "properties", "deleted" ] ) );
- child.events.create( namespaceEncodedName( [ "methods", "created" ] ) );
- child.events.create( namespaceEncodedName( [ "methods", "deleted" ] ) );
- child.events.create( namespaceEncodedName( [ "events", "created" ] ) );
- child.events.create( namespaceEncodedName( [ "events", "deleted" ] ) );
- child.events.create( namespaceEncodedName( [ "children", "added" ] ) );
- child.events.create( namespaceEncodedName( [ "children", "removed" ] ) );
- }
-
-
-
- vwf.models.object.creatingNode( nodeID, childID, childPrototypeID, childBehaviorIDs,
- childComponent.source, childComponent.type, childIndex, childName );
-
- resolvedSource = childComponent.source &&
- require( "vwf/utility" ).resolveURI( childComponent.source, baseURI );
-
-
- async.forEachSeries( vwf.models, function( model, each_callback_async /* ( err ) */ ) {
- var driver_ready = true;
- var timeoutID;
-
- model.creatingNode && model.creatingNode( nodeID, childID, childPrototypeID, childBehaviorIDs,
- resolvedSource, childComponent.type, childIndex, childName, function( ready ) /* async */ {
- if ( driver_ready && ! ready ) {
- suspend();
- } else if ( ! driver_ready && ready ) {
- resume();
- }
- function suspend() {
- queue.suspend( "while loading " + childComponent.source + " for " + childID + " in creatingNode" );
- timeoutID = window.setTimeout( function() { resume( "timeout loading " + childComponent.source ) }, vwf.configuration[ "load-timeout" ] * 1000 );
- driver_ready = false;
- }
- async function resume( err ) {
- window.clearTimeout( timeoutID );
- driver_ready = true;
- err && vwf.logger.warnx( "createChild", nodeID, childName + ":", err );
- await each_callback_async( err );
- queue.resume( "after loading " + childComponent.source + " for " + childID + " in creatingNode" );
- }
- } );
-
- driver_ready && each_callback_async( undefined );
- }, function( err ) /* async */ {
- series_callback_async( err, undefined );
- } );
- },
- function( series_callback_async /* ( err, results ) */ ) {
-
-
- async.forEachSeries( vwf.views, function( view, each_callback_async /* ( err ) */ ) {
- var driver_ready = true;
- var timeoutID;
- view.createdNode && view.createdNode( nodeID, childID, childPrototypeID, childBehaviorIDs,
- resolvedSource, childComponent.type, childIndex, childName, function( ready ) /* async */ {
- if ( driver_ready && ! ready ) {
- suspend();
- } else if ( ! driver_ready && ready ) {
- resume();
- }
- function suspend() {
- queue.suspend( "while loading " + childComponent.source + " for " + childID + " in createdNode" );
- timeoutID = window.setTimeout( function() { resume( "timeout loading " + childComponent.source ) }, vwf.configuration[ "load-timeout" ] * 1000 );
- driver_ready = false;
- }
- async function resume( err ) {
- window.clearTimeout( timeoutID );
- driver_ready = true;
- err && vwf.logger.warnx( "createChild", nodeID, childName + ":", err );
- await each_callback_async( err );
- queue.resume( "after loading " + childComponent.source + " for " + childID + " in createdNode" );
- }
- } );
- driver_ready && each_callback_async( undefined );
- }, function( err ) /* async */ {
- series_callback_async( err, undefined );
- } );
- },
- function( series_callback_async /* ( err, results ) */ ) {
-
- vwf.models.object.internals( childID, childComponent );
-
-
- replicating && vwf.models.kernel.disable();
-
-
-
- childComponent.properties && Object.keys( childComponent.properties ).forEach( function( propertyName ) {
- var propertyValue = childComponent.properties[ propertyName ];
- var value = propertyValue, get, set, create;
- if ( valueHasAccessors( propertyValue ) ) {
- value = propertyValue.node ? vwf.kutility.nodeReference( propertyValue.node ) : propertyValue.value;
- get = propertyValue.get;
- set = propertyValue.set;
- create = propertyValue.create;
- }
- // Is the property specification directing us to create a new property, or
- // initialize a property already defined on a prototype?
- // Create a new property if an explicit getter or setter are provided or if
- // the property is not defined on a prototype. Initialize the property when
- // the property is already defined on a prototype and no explicit getter or
- // setter are provided.
- var creating = create || // explicit create directive, or
- get !== undefined || set !== undefined || // explicit accessor, or
- ! child.properties.has( propertyName ); // not defined on prototype
- // Are we assigning the value here, or deferring assignment until the node
- // is constructed because setters will run?
- var assigning = value === undefined || // no value, or
- set === undefined && ( creating || ! nodePropertyHasSetter.call( vwf, childID, propertyName ) ) || // no setter, or
- replicating; // replicating previously-saved state (setters never run during replication)
- if ( ! assigning ) {
- deferredInitializations[propertyName] = value;
- value = undefined;
- }
-
- if ( creating ) {
- vwf.createProperty( childID, propertyName, value, get, set );
- } else {
- vwf.setProperty( childID, propertyName, value );
- }
- } );
- childComponent.methods && Object.keys( childComponent.methods ).forEach( function( methodName ) {
- var methodValue = childComponent.methods[ methodName ];
- if ( valueHasBody( methodValue ) ) {
- vwf.createMethod( childID, methodName, methodValue.parameters, methodValue.body );
- } else {
- vwf.createMethod( childID, methodName, undefined, methodValue );
- }
- } );
- childComponent.events && Object.keys( childComponent.events ).forEach( function( eventName ) {
- var eventValue = childComponent.events[ eventName ];
- if ( valueHasBody( eventValue ) ) {
- vwf.createEvent( childID, eventName, eventValue.parameters );
- vwf.setEvent( childID, eventName, eventValue );
- } else {
- vwf.createEvent( childID, eventName, undefined );
- }
- } );
-
- replicating && vwf.models.kernel.enable();
-
-
-
- async.forEach( Object.keys( childComponent.children || {} ), function( childName, each_callback_async /* ( err ) */ ) {
- var childValue = childComponent.children[childName];
- vwf.createChild( childID, childName, childValue, undefined, function( childID ) /* async */ {
- each_callback_async( undefined );
- } );
- }, function( err ) /* async */ {
- series_callback_async( err, undefined );
- } );
- },
- function( series_callback_async /* ( err, results ) */ ) {
-
-
-
-
-
- var scripts = childComponent.scripts ?
- [].concat( childComponent.scripts ) : [];
- async.map( scripts, function( script, map_callback_async /* ( err, result ) */ ) {
- if ( valueHasType( script ) ) {
- if ( script.source ) {
- loadScript( script.source, baseURI, function( scriptText ) /* async */ {
- map_callback_async( undefined, { text: scriptText, type: script.type } );
- }, function( errorMessage ) {
- map_callback_async( errorMessage, undefined );
- } );
- } else {
- map_callback_async( undefined, { text: script.text, type: script.type } );
- }
- } else {
- map_callback_async( undefined, { text: script, type: undefined } );
- }
- }, function( err, scripts ) /* async */ {
-
-
- vwf.models.kernel.capturingAsyncs( function() {
-
-
- replicating && vwf.models.kernel.disable();
-
- scripts.forEach( function( script ) {
- vwf.execute( childID, script.text, script.type );
- } );
-
-
- Object.keys( deferredInitializations ).forEach( function( propertyName ) {
- vwf.setProperty( childID, propertyName, deferredInitializations[propertyName] );
- } );
-
- if ( vwf.execute( childID, "Boolean( this.tick )" ) ) {
- vwf.tickable.nodeIDs.push( childID );
- }
-
- replicating && vwf.models.kernel.enable();
- }, function() {
-
-
-
-
-
-
-
- async.forEachSeries( vwf.prototypes( childID, true ).reverse().concat( childID ),
- function( childInitializingNodeID, each_callback_async /* err */ ) {
-
- vwf.models.kernel.capturingAsyncs( function() {
- vwf.models.forEach( function( model ) {
-
-
- replicating && vwf.models.kernel.disable();
-
-
-
-
-
-
-
-
-
-
-
- if ( childInitializingNodeID !== childID ) {
- model.initializingNodeFromPrototype &&
- model.initializingNodeFromPrototype( nodeID, childID, childInitializingNodeID );
- } else {
- model.initializingNode &&
- model.initializingNode( nodeID, childID, childPrototypeID, childBehaviorIDs,
- resolvedSource, childComponent.type, childIndex, childName );
- }
-
- replicating && vwf.models.kernel.enable();
- } );
- }, function() {
- each_callback_async( undefined );
- } );
- }, function( err ) /* async */ {
-
- vwf.views.forEach( function( view ) {
- view.initializedNode && view.initializedNode( nodeID, childID, childPrototypeID, childBehaviorIDs,
- resolvedSource, childComponent.type, childIndex, childName );
- } );
-
- nodes.initialize( childID );
-
- if ( ! replicating && nodeID !== 0 ) {
- vwf.fireEvent( nodeID, [ "children", "added" ],
- [ childIndex, vwf.kutility.nodeReference( childID ) ] );
- }
-
- if ( childID === vwf.application() ) {
- var progressbar= document.getElementById( "load-progressbar" );
- if (progressbar) {
-
- progressbar.classList.remove( "visible" );
- progressbar.classList.add( "not-visible" );
- progressbar.classList.add( "mdc-linear-progress--closed" );
-
- }
-
-
- }
- series_callback_async( err, undefined );
- } );
- } );
- } );
- },
- ], function( err, results ) /* async */ {
-
-
-
-
-
- if ( callback_async ) {
- queue.suspend( "before completing " + childID );
- async.nextTick( async function() {
- await callback_async( childID );
- queue.resume( "after completing " + childID );
- } );
- }
- } );
- this.logger.debugu();
- };
-
-
-
-
- this.deleteChild = function( nodeID, childName ) {
- var childID = this.children( nodeID ).filter( function( childID ) {
- return this.name( childID ) === childName;
- }, this )[0];
- if ( childID !== undefined ) {
- return this.deleteNode( childID );
- }
- }
-
-
-
-
- this.addChild = function( nodeID, childID, childName ) {
- this.logger.debuggx( "addChild", nodeID, childID, childName );
-
-
- this.models.forEach( function( model ) {
- model.addingChild && model.addingChild( nodeID, childID, childName );
- } );
-
-
- this.views.forEach( function( view ) {
- view.addedChild && view.addedChild( nodeID, childID, childName );
- } );
- this.logger.debugu();
- };
-
-
-
-
- this.removeChild = function( nodeID, childID ) {
- this.logger.debuggx( "removeChild", nodeID, childID );
-
-
- this.models.forEach( function( model ) {
- model.removingChild && model.removingChild( nodeID, childID );
- } );
-
-
- this.views.forEach( function( view ) {
- view.removedChild && view.removedChild( nodeID, childID );
- } );
- this.logger.debugu();
- };
-
-
-
-
-
-
- this.setProperties = function( nodeID, properties ) {
- this.logger.debuggx( "setProperties", nodeID, properties );
- var node = nodes.existing[nodeID];
- var entrants = this.setProperty.entrants;
-
- properties = this.models.reduceRight( function( intermediate_properties, model, index ) {
- var model_properties = {};
- if ( model.settingProperties ) {
- model_properties = model.settingProperties( nodeID, properties );
- } else if ( model.settingProperty ) {
- Object.keys( node.properties.existing ).forEach( function( propertyName ) {
- if ( properties[propertyName] !== undefined ) {
- var reentry = entrants[nodeID+'-'+propertyName] = { index: index };
- model_properties[propertyName] =
- model.settingProperty( nodeID, propertyName, properties[propertyName] );
- if ( vwf.models.kernel.blocked() ) {
- model_properties[propertyName] = undefined;
- }
- delete entrants[nodeID+'-'+propertyName];
- }
- } );
- }
- Object.keys( node.properties.existing ).forEach( function( propertyName ) {
- if ( model_properties[propertyName] !== undefined ) {
- intermediate_properties[propertyName] = model_properties[propertyName];
- } else if ( intermediate_properties[propertyName] === undefined ) {
- intermediate_properties[propertyName] = undefined;
- }
- } );
- return intermediate_properties;
- }, {} );
-
- if ( node.initialized && node.patchable ) {
- Object.keys( properties ).forEach( function( propertyName ) {
- node.properties.change( propertyName );
- } );
- }
-
- this.views.forEach( function( view ) {
- if ( view.satProperties ) {
- view.satProperties( nodeID, properties );
- } else if ( view.satProperty ) {
- for ( var propertyName in properties ) {
- view.satProperty( nodeID, propertyName, properties[propertyName] );
- }
- }
- } );
- this.logger.debugu();
- return properties;
- };
-
-
-
-
-
-
- this.getProperties = function( nodeID ) {
- this.logger.debuggx( "getProperties", nodeID );
- var node = nodes.existing[nodeID];
- var entrants = this.getProperty.entrants;
-
- var properties = this.models.reduceRight( function( intermediate_properties, model, index ) {
- var model_properties = {};
- if ( model.gettingProperties ) {
- model_properties = model.gettingProperties( nodeID, properties );
- } else if ( model.gettingProperty ) {
- Object.keys( node.properties.existing ).forEach( function( propertyName ) {
- var reentry = entrants[nodeID+'-'+propertyName] = { index: index };
- model_properties[propertyName] =
- model.gettingProperty( nodeID, propertyName, intermediate_properties[propertyName] );
- if ( vwf.models.kernel.blocked() ) {
- model_properties[propertyName] = undefined;
- }
- delete entrants[nodeID+'-'+propertyName];
- } );
- }
- Object.keys( node.properties.existing ).forEach( function( propertyName ) {
- if ( model_properties[propertyName] !== undefined ) {
- intermediate_properties[propertyName] = model_properties[propertyName];
- } else if ( intermediate_properties[propertyName] === undefined ) {
- intermediate_properties[propertyName] = undefined;
- }
- } );
- return intermediate_properties;
- }, {} );
-
- this.views.forEach( function( view ) {
- if ( view.gotProperties ) {
- view.gotProperties( nodeID, properties );
- } else if ( view.gotProperty ) {
- for ( var propertyName in properties ) {
- view.gotProperty( nodeID, propertyName, properties[propertyName] );
- }
- }
- } );
- this.logger.debugu();
- return properties;
- };
-
-
-
-
-
-
- this.createProperty = function( nodeID, propertyName, propertyValue, propertyGet, propertySet ) {
- this.logger.debuggx( "createProperty", function() {
- return [ nodeID, propertyName, JSON.stringify( loggableValue( propertyValue ) ),
- loggableScript( propertyGet ), loggableScript( propertySet ) ];
- } );
- var node = nodes.existing[nodeID];
-
- node.properties.create( propertyName, node.initialized && node.patchable );
-
-
- this.models.forEach( function( model ) {
- model.creatingProperty && model.creatingProperty( nodeID, propertyName, propertyValue,
- propertyGet, propertySet );
- } );
-
-
- this.views.forEach( function( view ) {
- view.createdProperty && view.createdProperty( nodeID, propertyName, propertyValue,
- propertyGet, propertySet );
- } );
-
- if ( this.models.kernel.enabled() ) {
- this.fireEvent( nodeID, [ "properties", "created" ], [ propertyName ] );
- }
- this.logger.debugu();
- return propertyValue;
- };
-
-
-
-
-
-
- this.setProperty = function( nodeID, propertyName, propertyValue ) {
- this.logger.debuggx( "setProperty", function() {
- return [ nodeID, propertyName, JSON.stringify( loggableValue( propertyValue ) ) ];
- } );
- var node = nodes.existing[nodeID];
-
-
-
- var entrants = this.setProperty.entrants;
- var entry = entrants[nodeID+'-'+propertyName] || {};
- var reentry = entrants[nodeID+'-'+propertyName] = {};
-
-
-
- if ( ! node.properties.has( propertyName ) || entry.creating ) {
- reentry.creating = true;
- var settingPropertyEtc = "creatingProperty";
- var satPropertyEtc = "createdProperty";
- node.properties.create( propertyName, node.initialized && node.patchable );
- } else if ( ! node.properties.hasOwn( propertyName ) || entry.initializing ) {
- reentry.initializing = true;
- var settingPropertyEtc = "initializingProperty";
- var satPropertyEtc = "initializedProperty";
- node.properties.create( propertyName, node.initialized && node.patchable );
- } else {
- var settingPropertyEtc = "settingProperty";
- var satPropertyEtc = "satProperty";
- }
-
-
- var outermost = entrants.assignments === undefined;
- if ( outermost ) {
- entrants.assignments = 0;
- }
-
-
-
-
-
- var reentered = ( entry.index !== undefined );
-
-
- var delegated = false, assigned = false;
-
-
-
- this.models.some( function( model, index ) {
-
-
-
- if ( ( ! reentered || index > entry.index ) && ! reentry.completed ) {
-
-
- reentry.index = index;
-
-
-
- var assignments = entrants.assignments;
-
- if ( ! delegated && ! assigned ) {
- var value = model[settingPropertyEtc] && model[settingPropertyEtc]( nodeID, propertyName, propertyValue );
- } else {
- model[settingPropertyEtc] && model[settingPropertyEtc]( nodeID, propertyName, undefined );
- }
-
-
-
- if ( this.models.kernel.blocked() ) {
- value = undefined;
- }
-
- if ( entrants.assignments !== assignments ) {
- delegated = true;
- }
-
- else if ( value !== undefined ) {
- entrants.assignments++;
- assigned = true;
- }
-
-
-
- if ( value !== undefined ) {
- propertyValue = value;
- }
-
-
-
- return settingPropertyEtc == "settingProperty" && ( delegated || assigned );
- }
- }, this );
-
- if ( assigned && node.initialized && node.patchable ) {
- node.properties.change( propertyName );
- }
-
-
-
-
-
-
- if ( assigned ) {
- this.views.forEach( function( view ) {
- view[satPropertyEtc] && view[satPropertyEtc]( nodeID, propertyName, propertyValue );
- } );
- }
- if ( reentered ) {
-
-
- entrants[nodeID+'-'+propertyName] = entry;
- entry.completed = true;
- } else {
-
-
- delete entrants[nodeID+'-'+propertyName];
-
-
- if ( this.models.kernel.enabled() ) {
- if ( settingPropertyEtc === "creatingProperty" ) {
- this.fireEvent( nodeID, [ "properties", "created" ], [ propertyName ] );
- } else if ( settingPropertyEtc === "initializingProperty" ) {
- this.fireEvent( nodeID, [ "properties", "initialized" ], [ propertyName ] );
- }
- }
- }
-
- if ( outermost ) {
- delete entrants.assignments;
- }
- this.logger.debugu();
- return propertyValue;
- };
- this.setProperty.entrants = {};
-
-
-
-
-
-
- this.getProperty = function( nodeID, propertyName, ignorePrototype ) {
- this.logger.debuggx( "getProperty", nodeID, propertyName );
- var propertyValue = undefined;
-
-
-
- var entrants = this.getProperty.entrants;
- var entry = entrants[nodeID+'-'+propertyName] || {};
- var reentry = entrants[nodeID+'-'+propertyName] = {};
-
-
- var outermost = entrants.retrievals === undefined;
- if ( outermost ) {
- entrants.retrievals = 0;
- }
-
-
-
-
-
- var reentered = ( entry.index !== undefined );
-
-
- var delegated = false, retrieved = false;
-
-
- this.models.some( function( model, index ) {
-
-
-
- if ( ( ! reentered || index > entry.index ) && ! reentry.completed ) {
-
-
- reentry.index = index;
-
-
-
- var retrievals = entrants.retrievals;
-
- var value = model.gettingProperty &&
- model.gettingProperty( nodeID, propertyName, propertyValue );
-
-
-
- if ( this.models.kernel.blocked() ) {
- value = undefined;
- }
-
- if ( entrants.retrievals !== retrievals ) {
- delegated = true;
- }
-
- else if ( value !== undefined ) {
- entrants.retrievals++;
- retrieved = true;
- }
-
- if ( value !== undefined ) {
- propertyValue = value;
- }
-
- return delegated || retrieved;
- }
- }, this );
- if ( reentered ) {
-
-
- entrants[nodeID+'-'+propertyName] = entry;
- entry.completed = true;
- } else {
-
-
- delete entrants[nodeID+'-'+propertyName];
-
-
- if ( propertyValue === undefined && ! ignorePrototype ) {
- this.behaviors( nodeID ).reverse().concat( this.prototype( nodeID ) ).
- some( function( prototypeID, prototypeIndex, prototypeArray ) {
- if ( prototypeIndex < prototypeArray.length - 1 ) {
- propertyValue = this.getProperty( prototypeID, propertyName, true );
- } else if ( prototypeID !== this.kutility.protoNodeURI ) {
- propertyValue = this.getProperty( prototypeID, propertyName );
- }
- return propertyValue !== undefined;
- }, this );
- }
-
- this.views.forEach( function( view ) {
- view.gotProperty && view.gotProperty( nodeID, propertyName, propertyValue );
- } );
- }
-
- if ( outermost ) {
- delete entrants.retrievals;
- }
- this.logger.debugu();
- return propertyValue;
- };
- this.getProperty.entrants = {};
-
-
-
-
- this.createMethod = function( nodeID, methodName, methodParameters, methodBody ) {
- this.logger.debuggx( "createMethod", function() {
- return [ nodeID, methodName, methodParameters, loggableScript( methodBody ) ];
- } );
- var node = nodes.existing[nodeID];
-
- node.methods.create( methodName, node.initialized && node.patchable );
-
-
- this.models.forEach( function( model ) {
- model.creatingMethod && model.creatingMethod( nodeID, methodName, methodParameters,
- methodBody );
- } );
-
-
- this.views.forEach( function( view ) {
- view.createdMethod && view.createdMethod( nodeID, methodName, methodParameters,
- methodBody );
- } );
-
- if ( this.models.kernel.enabled() ) {
- this.fireEvent( nodeID, [ "methods", "created" ], [ methodName ] );
- }
- this.logger.debugu();
- };
-
-
-
-
- this.setMethod = function( nodeID, methodName, methodHandler ) {
- this.logger.debuggx( "setMethod", function() {
- return [ nodeID, methodName ];
- } );
- var node = nodes.existing[nodeID];
- methodHandler = normalizedHandler( methodHandler );
- if ( ! node.methods.hasOwn( methodName ) ) {
-
-
- this.createMethod( nodeID, methodName, methodHandler.parameters, methodHandler.body );
- } else {
-
-
- this.models.some( function( model ) {
-
- var handler = model.settingMethod && model.settingMethod( nodeID, methodName, methodHandler );
-
- if ( handler !== undefined ) {
- methodHandler = require( "vwf/utility" ).merge( {}, handler );
- }
-
- return handler !== undefined;
- } );
-
- if ( node.initialized && node.patchable ) {
- node.methods.change( methodName );
- }
-
- this.views.forEach( function( view ) {
- view.satMethod && view.satMethod( nodeID, methodName, methodHandler );
- } );
- }
- this.logger.debugu();
- return methodHandler;
- };
-
-
-
-
- this.getMethod = function( nodeID, methodName ) {
- this.logger.debuggx( "getMethod", function() {
- return [ nodeID, methodName ];
- } );
- var node = nodes.existing[nodeID];
-
-
- var methodHandler = {};
- this.models.some( function( model ) {
-
- var handler = model.gettingMethod && model.gettingMethod( nodeID, methodName );
-
- if ( handler !== undefined ) {
- methodHandler = require( "vwf/utility" ).merge( {}, handler );
- }
-
- return handler !== undefined;
- } );
-
- this.views.forEach( function( view ) {
- view.gotMethod && view.gotMethod( nodeID, methodName, methodHandler );
- } );
- this.logger.debugu();
- return methodHandler;
- };
-
-
-
-
- this.callMethod = function( nodeID, methodName, methodParameters ) {
- this.logger.debuggx( "callMethod", function() {
- return [ nodeID, methodName, JSON.stringify( loggableValues( methodParameters ) ) ];
- } );
-
-
- var methodValue = undefined;
- this.models.some( function( model ) {
- methodValue = model.callingMethod && model.callingMethod( nodeID, methodName, methodParameters );
- return methodValue !== undefined;
- } );
-
- this.views.forEach( function( view ) {
- view.calledMethod && view.calledMethod( nodeID, methodName, methodParameters, methodValue );
- } );
- this.logger.debugu();
- return methodValue;
- };
-
-
-
-
- this.createEvent = function( nodeID, eventName, eventParameters ) {
- this.logger.debuggx( "createEvent", nodeID, eventName, eventParameters );
- var node = nodes.existing[nodeID];
-
- var encodedEventName = namespaceEncodedName( eventName );
-
- node.events.create( encodedEventName, node.initialized && node.patchable, eventParameters );
-
-
- this.models.forEach( function( model ) {
- model.creatingEvent && model.creatingEvent( nodeID, encodedEventName, eventParameters );
- } );
-
-
- this.views.forEach( function( view ) {
- view.createdEvent && view.createdEvent( nodeID, encodedEventName, eventParameters );
- } );
-
- if ( this.models.kernel.enabled() ) {
- this.fireEvent( nodeID, [ "events", "created" ], [ eventName ] );
- }
- this.logger.debugu();
- };
-
-
-
-
- this.setEvent = function( nodeID, eventName, eventDescriptor ) {
- this.logger.debuggx( "setEvent", function() {
- return [ nodeID, eventName ];
- } );
- var node = nodes.existing[nodeID];
-
-
- var encodedEventName = namespaceEncodedName( eventName );
- if ( ! node.events.hasOwn( encodedEventName ) ) {
-
-
- this.createEvent( nodeID, eventName, eventDescriptor.parameters );
- ( eventDescriptor.listeners || [] ).forEach( function( listener ) {
- return this.addEventListener( nodeID, eventName, listener, listener.context, listener.phases );
- }, this );
- } else {
-
- var event = node.events.existing[ encodedEventName ];
-
- eventDescriptor = {
- parameters: event.parameters ?
- event.parameters.slice() : [],
- listeners: ( eventDescriptor.listeners || [] ).map( function( listener ) {
- if ( event.listeners.hasOwn( listener.id ) ) {
- return this.setEventListener( nodeID, eventName, listener.id, listener );
- } else {
- return this.addEventListener( nodeID, eventName, listener, listener.context, listener.phases );
- }
- }, this ),
- };
- }
- this.logger.debugu();
- return eventDescriptor;
- };
-
-
-
-
- this.getEvent = function( nodeID, eventName ) {
- this.logger.debuggx( "getEvent", function() {
- return [ nodeID, eventName ];
- } );
- var node = nodes.existing[nodeID];
-
- var encodedEventName = namespaceEncodedName( eventName );
-
- var event = node.events.existing[ encodedEventName ];
-
-
- var eventDescriptor = {};
- if ( event.parameters ) {
- eventDescriptor.parameters = event.parameters.slice();
- }
- if ( event.listeners.existing.length ) {
- eventDescriptor.listeners = event.listeners.existing.map( function( eventListenerID ) {
- var listener = this.getEventListener( nodeID, eventName, eventListenerID );
- listener.id = eventListenerID;
- return listener;
- }, this );
- }
- this.logger.debugu();
- return eventDescriptor;
- };
-
-
-
-
- this.addEventListener = function( nodeID, eventName, eventHandler, eventContextID, eventPhases ) {
- this.logger.debuggx( "addEventListener", function() {
- return [ nodeID, eventName, loggableScript( eventHandler ),
- eventContextID, eventPhases ];
- } );
- var node = nodes.existing[nodeID];
-
- var encodedEventName = namespaceEncodedName( eventName );
-
- if ( ! node.events.hasOwn( encodedEventName ) ) {
- node.events.create( encodedEventName, node.initialized && node.patchable );
- }
-
- var event = node.events.existing[ encodedEventName ];
-
- eventHandler = normalizedHandler( eventHandler, event.parameters );
-
- var eventListenerID = eventHandler.id || this.sequence( nodeID );
- event.listeners.create( eventListenerID, node.initialized && node.patchable );
-
- this.models.forEach( function( model ) {
- model.addingEventListener &&
- model.addingEventListener( nodeID, encodedEventName, eventListenerID,
- eventHandler, eventContextID, eventPhases );
- } );
-
- this.views.forEach( function( view ) {
- view.addedEventListener &&
- view.addedEventListener( nodeID, encodedEventName, eventListenerID,
- eventHandler, eventContextID, eventPhases );
- } );
- this.logger.debugu();
- return eventListenerID;
- };
-
-
-
-
- this.removeEventListener = function( nodeID, eventName, eventListenerID ) {
- this.logger.debuggx( "removeEventListener", function() {
- return [ nodeID, eventName, loggableScript( eventListenerID ) ];
- } );
- var node = nodes.existing[nodeID];
-
- var encodedEventName = namespaceEncodedName( eventName );
-
- var event = node.events.existing[ encodedEventName ];
-
- event.listeners.delete( eventListenerID, node.initialized && node.patchable );
-
- this.models.forEach( function( model ) {
- model.removingEventListener &&
- model.removingEventListener( nodeID, encodedEventName, eventListenerID );
- } );
-
- this.views.forEach( function( view ) {
- view.removedEventListener &&
- view.removedEventListener( nodeID, encodedEventName, eventListenerID );
- } );
- this.logger.debugu();
- return eventListenerID;
- };
-
-
-
-
- this.setEventListener = function( nodeID, eventName, eventListenerID, eventListener ) {
- this.logger.debuggx( "setEventListener", function() {
- return [ nodeID, eventName, eventListenerID ];
- } );
- var node = nodes.existing[nodeID];
-
- var encodedEventName = namespaceEncodedName( eventName );
-
- var event = node.events.existing[ encodedEventName ];
-
- eventListener = normalizedHandler( eventListener, event.parameters );
-
- if ( node.initialized && node.patchable ) {
- event.listeners.change( eventListenerID );
- }
-
-
- this.models.some( function( model ) {
-
- var listener = model.settingEventListener &&
- model.settingEventListener( nodeID, encodedEventName, eventListenerID, eventListener );
-
- if ( listener !== undefined ) {
- eventListener = require( "vwf/utility" ).merge( {}, listener );
- }
-
- return listener !== undefined;
- } );
-
- this.views.forEach( function( view ) {
- view.satEventListener &&
- view.satEventListener( nodeID, encodedEventName, eventListenerID, eventListener );
- } );
- this.logger.debugu();
- return eventListener;
- };
-
-
-
-
- this.getEventListener = function( nodeID, eventName, eventListenerID ) {
- this.logger.debuggx( "getEventListener", function() {
- return [ nodeID, eventName, eventListenerID ];
- } );
-
- var encodedEventName = namespaceEncodedName( eventName );
-
-
- var eventListener = {};
- this.models.some( function( model ) {
-
- var listener = model.gettingEventListener &&
- model.gettingEventListener( nodeID, encodedEventName, eventListenerID );
-
- if ( listener !== undefined ) {
- eventListener = require( "vwf/utility" ).merge( {}, listener );
- }
-
- return listener !== undefined;
- } );
-
- this.views.forEach( function( view ) {
- view.gotEventListener &&
- view.gotEventListener( nodeID, encodedEventName, eventListenerID, eventListener );
- } );
- this.logger.debugu();
- return eventListener;
- };
-
-
-
-
- this.flushEventListeners = function( nodeID, eventName, eventContextID ) {
- this.logger.debuggx( "flushEventListeners", nodeID, eventName, eventContextID );
-
- var encodedEventName = namespaceEncodedName( eventName );
-
- var node = nodes.existing[ nodeID ];
- var event = node.events.existing[ encodedEventName ];
-
- this.models.forEach( function( model ) {
- var removedIds = model.flushingEventListeners &&
- model.flushingEventListeners( nodeID, encodedEventName, eventContextID );
-
-
-
- if ( removedIds && removedIds.length ) {
-
- removedIds.forEach( function( removedId ) {
- event.listeners.delete( removedId, node.initialized && node.patchable );
- } );
- }
- } );
-
- this.views.forEach( function( view ) {
- view.flushedEventListeners &&
- view.flushedEventListeners( nodeID, encodedEventName, eventContextID );
- } );
-
-
-
- this.logger.debugu();
- };
-
-
-
-
- this.fireEvent = function( nodeID, eventName, eventParameters ) {
- this.logger.debuggx( "fireEvent", function() {
- return [ nodeID, eventName, JSON.stringify( loggableValues( eventParameters ) ) ];
- } );
-
- var encodedEventName = namespaceEncodedName( eventName );
-
- var handled = this.models.reduce( function( handled, model ) {
- return model.firingEvent && model.firingEvent( nodeID, encodedEventName, eventParameters ) || handled;
- }, false );
-
- this.views.forEach( function( view ) {
- view.firedEvent && view.firedEvent( nodeID, encodedEventName, eventParameters );
- } );
- this.logger.debugu();
-
-
- return handled;
- };
-
-
-
-
-
-
-
-
- this.dispatchEvent = function( nodeID, eventName, eventParameters, eventNodeParameters ) {
- this.logger.debuggx( "dispatchEvent", function() {
- return [ nodeID, eventName, JSON.stringify( loggableValues( eventParameters ) ),
- JSON.stringify( loggableIndexedValues( eventNodeParameters ) ) ];
- } );
-
-
-
- eventParameters = eventParameters || [];
- eventNodeParameters = eventNodeParameters || {};
-
- var ancestorIDs = this.ancestors( nodeID );
- var lastAncestorID = "";
-
-
-
- var cascadedEventNodeParameters = {
- "": eventNodeParameters[""] || []
- };
-
-
- var targetEventParameters = undefined;
- var phase = undefined;
- var handled = false;
-
- phase = "capture";
- handled = handled || ancestorIDs.reverse().some( function( ancestorID ) {
- cascadedEventNodeParameters[ancestorID] = eventNodeParameters[ancestorID] ||
- cascadedEventNodeParameters[lastAncestorID];
- lastAncestorID = ancestorID;
- targetEventParameters =
- eventParameters.concat( cascadedEventNodeParameters[ancestorID], phase );
-
- targetEventParameters.phase = phase;
- return this.fireEvent( ancestorID, eventName, targetEventParameters );
- }, this );
-
- phase = undefined;
- cascadedEventNodeParameters[nodeID] = eventNodeParameters[nodeID] ||
- cascadedEventNodeParameters[lastAncestorID];
- targetEventParameters =
- eventParameters.concat( cascadedEventNodeParameters[nodeID], phase );
- handled = handled || this.fireEvent( nodeID, eventName, targetEventParameters );
-
- phase = undefined;
- handled = handled || ancestorIDs.reverse().some( function( ancestorID ) {
- targetEventParameters =
- eventParameters.concat( cascadedEventNodeParameters[ancestorID], phase );
- return this.fireEvent( ancestorID, eventName, targetEventParameters );
- }, this );
- this.logger.debugu();
- };
-
-
-
-
- this.execute = function( nodeID, scriptText, scriptType, callback_async /* result */ ) {
- this.logger.debuggx( "execute", function() {
- return [ nodeID, loggableScript( scriptText ), scriptType ];
- } );
-
- if ( ! scriptType && ( typeof scriptText == "string" || scriptText instanceof String ) ) {
- scriptType = "application/javascript";
- }
-
-
- var scriptValue = undefined;
-
-
- vwf.models.kernel.capturingAsyncs( function() {
- vwf.models.some( function( model ) {
- scriptValue = model.executing &&
- model.executing( nodeID, scriptText, scriptType );
- return scriptValue !== undefined;
- } );
-
- vwf.views.forEach( function( view ) {
- view.executed && view.executed( nodeID, scriptText, scriptType );
- } );
- }, function() {
- callback_async && callback_async( scriptValue );
- } );
- this.logger.debugu();
- return scriptValue;
- };
-
-
-
-
- this.random = function( nodeID ) {
- return this.models.object.random( nodeID );
- };
-
-
-
-
- this.seed = function( nodeID, seed ) {
- return this.models.object.seed( nodeID, seed );
- };
-
-
-
-
-
-
- this.time = function() {
- return this.now;
- };
-
-
-
-
-
-
-
- this.client = function() {
- return this.client_;
- };
-
-
-
-
-
-
- this.moniker = function() {
- return this.moniker_;
- };
-
-
-
-
- this.application = function( initializedOnly ) {
- var applicationID;
- Object.keys( nodes.globals ).forEach( function( globalID ) {
- var global = nodes.existing[ globalID ];
- if ( ( ! initializedOnly || global.initialized ) && global.name === "application" ) {
- applicationID = globalID;
- }
- }, this );
- return applicationID;
- };
-
-
-
-
- this.intrinsics = function( nodeID, result ) {
- return this.models.object.intrinsics( nodeID, result );
- };
-
-
-
-
- this.uri = function( nodeID, searchAncestors, initializedOnly ) {
- var uri = this.models.object.uri( nodeID );
- if ( searchAncestors ) {
- while ( ! uri && ( nodeID = this.parent( nodeID, initializedOnly ) ) ) {
- uri = this.models.object.uri( nodeID );
- }
- }
- return uri;
- };
-
-
-
-
- this.name = function( nodeID ) {
- return this.models.object.name( nodeID );
- };
-
-
-
-
- this.prototype = function( nodeID ) {
- return this.models.object.prototype( nodeID );
- };
-
-
-
-
- this.prototypes = function( nodeID, includeBehaviors ) {
- var prototypes = [];
- do {
-
- if ( includeBehaviors ) {
- var b = [].concat( this.behaviors( nodeID ) );
- Array.prototype.push.apply( prototypes, b.reverse() );
- }
-
- nodeID = this.prototype( nodeID );
-
- if ( nodeID ) {
- prototypes.push( nodeID );
- }
- } while ( nodeID );
- return prototypes;
- };
-
-
-
-
- this.behaviors = function( nodeID ) {
- return this.models.object.behaviors( nodeID );
- };
-
-
-
-
- this.globals = function( initializedOnly ) {
- var globals = {};
- Object.keys( nodes.globals ).forEach( function( globalID ) {
- if ( ! initializedOnly || nodes.existing[ globalID ].initialized ) {
- globals[ globalID ] = undefined;
- }
- }, this );
- return globals;
- };
-
-
-
-
- this.global = function( globalReference, initializedOnly ) {
- var globals = this.globals( initializedOnly );
-
-
- return matches( "uri" ) || matches( "name" );
-
- function matches( field ) {
- var matchingID;
- Object.keys( globals ).some( function( globalID ) {
- if ( nodes.existing[ globalID ][ field ] === globalReference ) {
- matchingID = globalID;
- return true;
- }
- } );
- return matchingID;
- }
- };
-
-
-
-
- this.root = function( nodeID, initializedOnly ) {
- var rootID;
-
-
-
-
- do {
- rootID = nodeID;
- nodeID = this.parent( nodeID, initializedOnly );
- } while ( nodeID );
-
-
- return nodeID === undefined ? undefined : rootID;
- };
-
-
-
-
- this.ancestors = function( nodeID, initializedOnly ) {
- var ancestors = [];
- nodeID = this.parent( nodeID, initializedOnly );
- while ( nodeID ) {
- ancestors.push( nodeID );
- nodeID = this.parent( nodeID, initializedOnly );
- }
- return ancestors;
- };
-
-
-
-
- this.parent = function( nodeID, initializedOnly ) {
- return this.models.object.parent( nodeID, initializedOnly );
- };
-
-
-
-
- this.children = function( nodeID, initializedOnly ) {
- if ( nodeID === undefined ) {
- this.logger.errorx( "children", "cannot retrieve children of nonexistent node" );
- return;
- }
- return this.models.object.children( nodeID, initializedOnly );
- };
-
-
-
-
- this.child = function( nodeID, childReference, initializedOnly ) {
- var children = this.children( nodeID, initializedOnly );
- if ( typeof childReference === "number" || childReference instanceof Number ) {
- return children[ childReference ];
- } else {
- return children.filter( function( childID ) {
- return childID && this.name( childID ) === childReference;
- }, this )[ 0 ];
- }
- };
-
-
-
-
- this.descendants = function( nodeID, initializedOnly ) {
- if ( nodeID === undefined ) {
- this.logger.errorx( "descendants", "cannot retrieve children of nonexistent node" );
- return;
- }
- var descendants = [];
- this.children( nodeID, initializedOnly ).forEach( function( childID ) {
- descendants.push( childID );
- childID && Array.prototype.push.apply( descendants, this.descendants( childID, initializedOnly ) );
- }, this );
- return descendants;
- };
-
-
-
-
- this.sequence = function( nodeID ) {
- return this.models.object.sequence( nodeID );
- };
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- this.find = function( nodeID, matchPattern, initializedOnly, callback /* ( matchID ) */ ) {
-
-
-
- if ( typeof initializedOnly == "function" || initializedOnly instanceof Function ) {
- callback = initializedOnly;
- initializedOnly = undefined;
- }
-
- var matchIDs = find.call( this, nodeID, matchPattern, initializedOnly );
-
-
- if ( callback ) {
- matchIDs.forEach( function( matchID ) {
- callback( matchID );
- } );
- } else {
- return matchIDs;
- }
- };
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- this.findClients = function( nodeID, matchPattern, callback /* ( matchID ) */ ) {
- this.logger.warn( "`kernel.findClients` is deprecated. Use " +
- "`kernel.find( nodeID, \"doc('http://vwf.example.com/clients.vwf')/pattern\" )`" +
- " instead." );
- var clientsMatchPattern = "doc('http://vwf.example.com/clients.vwf')" +
- ( matchPattern[0] === "/" ? "" : "/" ) + matchPattern;
- return this.find( nodeID || this.application(), clientsMatchPattern, callback );
- };
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- this.test = function( nodeID, matchPattern, testID, initializedOnly ) {
-
- var matchIDs = find.call( this, nodeID, matchPattern, initializedOnly );
-
- return matchIDs.some( function( matchID ) {
- return matchID == testID;
- } );
- };
-
- var isSocketIO07 = function() {
-
- return true
- }
-
-
- var loadComponent = async function( nodeURI, baseURI, callback_async /* nodeDescriptor */, errback_async /* errorMessage */ ) {
- if ( nodeURI == vwf.kutility.protoNodeURI ) {
- await callback_async( vwf.kutility.protoNodeDescriptor );
- } else if ( nodeURI.match( RegExp( "^data:application/json;base64," ) ) ) {
-
-
-
- await callback_async( JSON.parse( atob( nodeURI.substring( 29 ) ) ) );
- } else {
- queue.suspend( "while loading " + nodeURI );
- let fetchUrl = remappedURI( require( "vwf/utility" ).resolveURI( nodeURI, baseURI ) );
- let dbName = fetchUrl.replace(window.location.origin + '/', "").split(".").join("_") + '_yaml';
- const parseComp = async function(f) {
- let result = YAML.parse(f);
- let nativeObject = result;
-
-
- if(nativeObject) {
- await callback_async( nativeObject );
- queue.resume( "after loading " + nodeURI );
-
- } else {
-
- vwf.logger.warnx( "loadComponent", "error loading", nodeURI + ":", error );
- errback_async( error );
- queue.resume( "after loading " + nodeURI );
-
-
- }
- }
- var fileName = "";
- let userDB = _LCSDB.user(_LCS_WORLD_USER.pub);
-
- if(dbName.includes("vwf_example_com")){
-
- fileName = dbName;
- window._LCS_SYS_USER.get('proxy').get(fileName).get('file').load(function(r){
-
- parseComp(r);
- },{wait:200});
- } else {
- let worldName = dbName.split('/')[0];
-
- fileName = dbName.replace(worldName + '/', "");
- userDB.get('worlds').path(worldName).get(fileName).get('file').load(function(r){
-
- parseComp(r);
- },{wait:200});
- }
-
-
-
-
-
- }
- };
-
-
- var loadScript = async function( scriptURI, baseURI, callback_async /* scriptText */, errback_async /* errorMessage */ ) {
- if ( scriptURI.match( RegExp( "^data:application/javascript;base64," ) ) ) {
-
-
-
- await callback_async( atob( scriptURI.substring( 35 ) ) );
- } else {
- queue.suspend( "while loading " + scriptURI );
- let fetchUrl = remappedURI( require( "vwf/utility" ).resolveURI( scriptURI, baseURI ) );
- let dbName = fetchUrl.replace(window.location.origin + '/', "").split(".").join("_");
- const parseComp = async function(res) {
- let scriptText = res;
- try {
- await callback_async( scriptText );
- queue.resume( "after loading " + scriptURI );
- } catch (e) {
- vwf.logger.warnx( "loadScript", "error loading", scriptURI + ":", error );
- errback_async( error );
- queue.resume( "after loading " + scriptURI );
- }
- }
- let worldName = dbName.split('/')[0];
-
- var fileName = "";
- let userDB = _LCSDB.user(_LCS_WORLD_USER.pub);
- if(dbName.includes("vwf_example_com")){
-
- fileName = dbName;
- window._LCS_SYS_USER.get('proxy').get(fileName).get('file').load(function(r){
-
- parseComp(r);
- },{wait: 200});
-
- } else {
- fileName = dbName.replace(worldName + '/', "");
- userDB.get('worlds').path(worldName).get(fileName).get('file').load(function(r){
-
- parseComp(r);
-
- },{wait: 200});
- }
-
- }
- };
-
-
-
-
-
-
-
-
-
-
-
-
- var nodePropertyHasSetter = function( nodeID, propertyName ) {
- var node = this.models.javascript.nodes[nodeID];
- var setter = node.private.setters && node.private.setters[propertyName];
- return typeof setter == "function" || setter instanceof Function;
- };
-
-
-
-
-
-
-
-
-
-
-
-
- var nodePropertyHasOwnSetter = function( nodeID, propertyName ) {
- var node = this.models.javascript.nodes[nodeID];
- var setter = node.private.setters && node.private.setters.hasOwnProperty( propertyName ) && node.private.setters[propertyName];
- return typeof setter == "function" || setter instanceof Function;
- };
-
-
-
-
-
-
-
-
-
-
-
-
- var nodeHasChild = function( nodeID, childName ) {
- var node = this.models.javascript.nodes[nodeID];
- return childName in node.children;
- };
-
-
-
-
-
-
-
-
-
-
-
-
- var nodeHasOwnChild = function( nodeID, childName ) {
- var node = this.models.javascript.nodes[nodeID];
- var hasChild = false;
- if ( parseInt( childName ).toString() !== childName ) {
- hasChild = node.children.hasOwnProperty( childName );
- }
- else {
-
-
- for(var i=0, il=node.children.length; i<il;i++) {
- if(childName === node.children[i].name) {
- hasChild = true;
- }
- }
- }
- return hasChild;
- };
-
-
-
-
-
-
-
-
-
-
- var componentIsURI = function( candidate ) {
- return ( typeof candidate == "string" || candidate instanceof String ) && ! componentIsID( candidate );
- };
-
-
-
-
-
-
-
-
-
-
- var componentIsDescriptor = function( candidate ) {
- return typeof candidate == "object" && candidate != null && ! isPrimitive( candidate );
- };
-
-
-
-
-
-
-
-
-
-
- var componentIsID = function( candidate ) {
- return isPrimitive( candidate ) && vwf.models.object.exists( candidate ) &&
- ! ( components[candidate] instanceof Array );
- };
-
-
-
-
-
-
-
-
-
-
-
- var isPrimitive = function( candidate ) {
- switch ( typeof candidate ) {
- case "string":
- case "number":
- case "boolean":
- return true;
- case "object":
- return candidate instanceof String || candidate instanceof Number ||
- candidate instanceof Boolean;
- default:
- return false;
- }
- };
-
-
-
-
-
-
-
-
- var objectIsComponent = function( candidate ) {
- var componentAttributes = [
- "extends",
- "implements",
- "source",
- "type",
- "properties",
- "methods",
- "events",
- "children",
- "scripts",
- ];
- var isComponent = false;
- if ( typeof candidate == "object" && candidate != null ) {
- isComponent = componentAttributes.some( function( attributeName ) {
- return candidate.hasOwnProperty( attributeName );
- } );
- }
-
- return isComponent;
- };
-
-
-
-
-
-
-
-
-
- var valueHasAccessors = function( candidate ) {
- var accessorAttributes = [
- "get",
- "set",
- "value",
- "node",
- "create",
- "undefined",
- ];
- var hasAccessors = false;
- if ( typeof candidate == "object" && candidate != null ) {
- hasAccessors = accessorAttributes.some( function( attributeName ) {
- return candidate.hasOwnProperty( attributeName );
- } );
- }
-
- return hasAccessors;
- };
-
-
-
-
-
-
-
-
-
- var valueHasBody = function( candidate ) {
- var bodyAttributes = [
- "parameters",
- "body",
- "listeners",
- ];
- var hasBody = false;
- if ( typeof candidate == "object" && candidate != null ) {
- hasBody = bodyAttributes.some( function( attributeName ) {
- return candidate.hasOwnProperty( attributeName );
- } );
- }
-
- return hasBody;
- };
-
-
-
-
-
-
-
-
-
- var valueHasType = function( candidate ) {
- var typeAttributes = [
- "source",
- "text",
- "type",
- ];
- var hasType = false;
- if ( typeof candidate == "object" && candidate != null ) {
- hasType = typeAttributes.some( function( attributeName ) {
- return candidate.hasOwnProperty( attributeName );
- } );
- }
-
- return hasType;
- };
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var namespaceEncodedName = function( memberName ) {
- if ( typeof memberName === "object" && memberName instanceof Array ) {
- return ( memberName.length !== 1 ) ? "vwf$" + memberName.join( "$" ) : memberName[0];
- } else {
- return memberName;
- }
- };
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var normalizedComponent = function( component ) {
-
-
-
- if ( componentIsURI( component ) ) {
- if ( component.match( /\.vwf$/ ) ) {
- component = { extends: component };
- } else {
- component = { source: component };
- }
- } else if ( componentIsID( component ) ) {
- component = { extends: component };
- }
-
- if ( component.source && ! component.type ) {
- var match = component.source.match( /\.([^.]*)$/ );
- if ( match ) {
- switch ( match[1] ) {
- case "unity3d":
- component.type = "application/vnd.unity";
- break;
- case "dae":
- component.type = "model/vnd.collada+xml";
- break;
- }
- }
- }
-
- if ( component.type && ! component.extends ) {
- switch ( component.type ) {
- case "application/vnd.unity":
- component.extends = "http://vwf.example.com/scene.vwf";
- break;
- case "model/vnd.collada+xml":
- component.extends = "http://vwf.example.com/navscene.vwf";
- break;
- }
- }
- return component;
- };
-
-
-
-
-
-
-
-
-
- var normalizedHandler = function( handler, defaultParameters ) {
-
- if ( typeof handler !== "object" || handler instanceof Array ) {
- handler = { body: handler };
- } else if ( require( "vwf/configuration" ).active[ "preserve-script-closures" ] && ( typeof handler == "function" || handler instanceof Function ) ) {
- handler = { body: handler };
- }
-
-
- if ( ! handler.parameters && defaultParameters ) {
- handler.parameters = defaultParameters;
- }
-
-
- if ( handler.type === undefined ) {
- if ( typeof handler.body === "string" || handler.body instanceof String ) {
- handler.type = "application/javascript";
- }
- }
- return handler;
- };
-
-
-
-
-
-
-
-
- var loggableFields = function( fields ) {
- return require( "vwf/utility" ).transform( fields, require( "vwf/utility" ).transforms.transit );
- };
-
-
-
-
-
-
-
- var loggableComponent = function( component ) {
- return require( "vwf/utility" ).transform( component, loggableComponentTransformation );
- };
-
-
-
-
-
-
-
- var loggableValue = function( value ) {
- return require( "vwf/utility" ).transform( value, function( object, names, depth ) {
- object = require( "vwf/utility" ).transforms.transit( object, names, depth );
- return typeof object == "number" ? Number( object.toPrecision(5) ) : object;
- } );
- };
-
-
-
-
-
-
-
-
- var loggableValues = function( values ) {
- return loggableValue( values );
- };
-
-
-
-
-
-
-
-
- var loggableIndexedValues = function( values ) {
- return loggableValue( values );
- };
-
-
-
-
-
-
-
- var loggableScript = function( script ) {
- return ( script || "" ).replace( /\s+/g, " " ).substring( 0, 100 );
- };
-
-
-
-
-
-
- var remappedURI = function( uri ) {
- var match = uri.match( RegExp( "http://(vwf.example.com)/(.*)" ) );
- if ( match ) {
- uri = window.location.protocol + "//" + window.location.host +
- "/proxy/" + match[1] + "/" + match[2];
- }
- return uri;
- };
-
-
-
-
- var resolvedDescriptor = function( component, baseURI ) {
- return require( "vwf/utility" ).transform( component, resolvedDescriptorTransformationWithBaseURI );
- function resolvedDescriptorTransformationWithBaseURI( object, names, depth ) {
- return resolvedDescriptorTransformation.call( this, object, names, depth, baseURI );
- }
- };
-
-
-
-
-
-
-
- var queueTransitTransformation = function( object, names, depth ) {
- if ( depth == 0 ) {
-
-
-
- return object.filter( function( fields ) {
- return ! ( fields.origin === "reflector" && fields.sequence > vwf.sequence_ ) && fields.action;
- } ).sort( function( fieldsA, fieldsB ) {
- return fieldsA.sequence - fieldsB.sequence;
- } );
- } else if ( depth == 1 ) {
-
-
-
- var filtered = {};
- Object.keys( object ).filter( function( key ) {
- return key != "sequence";
- } ).forEach( function( key ) {
- filtered[key] = object[key];
- } );
- return filtered;
- }
- return object;
- };
-
-
-
-
-
- var loggableComponentTransformation = function( object, names, depth ) {
-
- var markers = descriptorMarkers( object, names, depth );
-
- switch ( markers.containerName ) {
- case "extends":
-
- if ( markers.memberIndex == 0 && componentIsDescriptor( object ) ) {
- return {};
- }
- break;
- case "implements":
-
- if ( markers.memberIndex == 0 && componentIsDescriptor( object ) ) {
- return {};
- }
- break;
- case "properties":
-
-
- if ( markers.memberIndex == 0 && ! valueHasAccessors( object ) ||
- markers.memberIndex == 1 && names[0] == "value" ) {
- return loggableValue( object );
- } else if ( markers.memberIndex == 1 && ( names[0] == "get" || names[0] == "set" ) ) {
- return "...";
- }
- break;
- case "methods":
-
- if ( markers.memberIndex == 0 && ! valueHasBody( object ) ||
- markers.memberIndex == 1 && names[0] == "body" ) {
- return "...";
- }
- break;
- case "events":
-
- break;
- case "children":
-
- if ( markers.memberIndex == 0 && componentIsDescriptor( object ) ) {
- return {};
- }
- break;
- case "scripts":
-
- if ( markers.memberIndex == 0 && ! valueHasType( object ) ||
- markers.memberIndex == 1 && names[0] == "text" ) {
- return "...";
- }
- break;
- }
- return object;
- };
-
-
-
-
-
- var resolvedDescriptorTransformation = function( object, names, depth, baseURI ) {
-
- var markers = descriptorMarkers( object, names, depth );
-
- switch ( markers.containerName ) {
- case "extends":
- case "implements":
- case "source":
- case "children":
- if ( markers.memberIndex == 0 && componentIsURI( object ) ) {
- return require( "vwf/utility" ).resolveURI( object, baseURI );
- }
- break;
- case "scripts":
- if ( markers.memberIndex == 1 && names[0] == "source" ) {
- return require( "vwf/utility" ).resolveURI( object, baseURI );
- }
- break;
- }
- return object;
- };
-
-
-
-
-
- var descriptorMarkers = function( object, names, depth ) {
-
- var componentIndex = names.length;
- while ( componentIndex > 2 && names[componentIndex-1] == "children" ) {
- componentIndex -= 2;
- }
-
-
-
-
-
-
-
-
-
- if ( componentIndex > 0 ) {
-
-
- var containerIndex = componentIndex - 1;
- var containerName = names[containerIndex];
-
- if ( containerName == "extends" ) {
- var memberIndex = containerIndex;
- var memberName = names[memberIndex];
- } else if ( containerName == "implements" ) {
- if ( containerIndex > 0 ) {
- if ( typeof names[containerIndex-1] == "number" ) {
- var memberIndex = containerIndex - 1;
- var memberName = names[memberIndex];
- } else {
- var memberIndex = containerIndex;
- var memberName = undefined;
- }
- } else if ( typeof object != "object" || ! ( object instanceof Array ) ) {
- var memberIndex = containerIndex;
- var memberName = undefined;
- }
- } else if ( containerName == "source" || containerName == "type" ) {
- var memberIndex = containerIndex;
- var memberName = names[memberIndex];
- } else if ( containerName == "properties" || containerName == "methods" || containerName == "events" ||
- containerName == "children" ) {
- if ( containerIndex > 0 ) {
- var memberIndex = containerIndex - 1;
- var memberName = names[memberIndex];
- }
-
- } else if ( containerName == "scripts" ) {
- if ( containerIndex > 0 ) {
- if ( typeof names[containerIndex-1] == "number" ) {
- var memberIndex = containerIndex - 1;
- var memberName = names[memberIndex];
- } else {
- var memberIndex = containerIndex;
- var memberName = undefined;
- }
- } else if ( typeof object != "object" || ! ( object instanceof Array ) ) {
- var memberIndex = containerIndex;
- var memberName = undefined;
- }
- } else {
- containerIndex = undefined;
- containerName = undefined;
- }
- }
- return {
- containerIndex: containerIndex,
- containerName: containerName,
- memberIndex: memberIndex,
- memberName: memberName,
- };
- };
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var find = function( nodeID, matchPattern, initializedOnly ) {
-
-
-
- var rootID = nodeID ? this.root( nodeID, initializedOnly ) :
- this.application( initializedOnly );
- return require( "vwf/utility" ).xpath.resolve( matchPattern, rootID, nodeID,
- resolverWithInitializedOnly, this );
-
- function resolverWithInitializedOnly( step, contextID, resolveAttributes ) {
- return xpathResolver.call( this, step, contextID, resolveAttributes, initializedOnly );
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var xpathResolver = function( step, contextID, resolveAttributes, initializedOnly ) {
- var resultIDs = [];
- switch ( step.axis ) {
-
-
- case "ancestor-or-self":
- resultIDs.push( contextID );
- Array.prototype.push.apply( resultIDs, this.ancestors( contextID, initializedOnly ) );
- break;
- case "ancestor":
- Array.prototype.push.apply( resultIDs, this.ancestors( contextID, initializedOnly ) );
- break;
- case "parent":
- var parentID = this.parent( contextID, initializedOnly );
- parentID && resultIDs.push( parentID );
- break;
- case "self":
- resultIDs.push( contextID );
- break;
- case "child":
- Array.prototype.push.apply( resultIDs,
- this.children( contextID, initializedOnly ).filter( function( childID ) {
- return childID;
- }, this )
- );
- break;
- case "descendant":
- Array.prototype.push.apply( resultIDs,
- this.descendants( contextID, initializedOnly ).filter( function( descendantID ) {
- return descendantID;
- }, this )
- );
- break;
- case "descendant-or-self":
- resultIDs.push( contextID );
- Array.prototype.push.apply( resultIDs,
- this.descendants( contextID, initializedOnly ).filter( function( descendantID ) {
- return descendantID;
- }, this )
- );
- break;
-
-
- case "attribute":
- if ( resolveAttributes ) {
- resultIDs.push( "@" + contextID );
- }
- break;
-
-
- }
- switch ( step.kind ) {
-
- case undefined:
- resultIDs = resultIDs.filter( function( resultID ) {
- if ( resultID[0] != "@" ) {
- return xpathNodeMatchesStep.call( this, resultID, step.name );
- } else {
- return xpathPropertyMatchesStep.call( this, resultID.slice( 1 ), step.name );
- }
- }, this );
- break;
-
- case "element":
-
-
-
-
-
- resultIDs = resultIDs.filter( function( resultID ) {
- return resultID[0] != "@" && xpathNodeMatchesStep.call( this, resultID, step.name, step.type );
- }, this );
- break;
-
- case "attribute":
- resultIDs = resultIDs.filter( function( resultID ) {
- return resultID[0] == "@" && xpathPropertyMatchesStep.call( this, resultID.slice( 1 ), step.name );
- }, this );
- break;
-
-
- case "doc":
- if ( this.root( contextID, initializedOnly ) ) {
- var globalID = this.global( step.name, initializedOnly );
- resultIDs = globalID ? [ globalID ] : [];
- } else {
- resultIDs = [];
- }
- break;
-
- case "node":
- break;
-
- default:
- resultIDs = [];
- break;
- }
- return resultIDs;
- }
-
-
-
-
-
-
-
-
-
-
- var xpathNodeMatchesStep = function( nodeID, name, type ) {
- if ( name && this.name( nodeID ) != name ) {
- return false;
- }
- var matches_type = ! type || this.uri( nodeID ) == type ||
- this.prototypes( nodeID, true ).some( function( prototypeID ) {
- return this.uri( prototypeID ) == type;
- }, this );
- return matches_type;
- }
-
-
-
-
-
-
-
-
-
- var xpathPropertyMatchesStep = function( nodeID, name ) {
- var properties = this.models.object.properties( nodeID );
- if ( name ) {
- return properties[name];
- } else {
- return Object.keys( properties ).some( function( propertyName ) {
- return properties[propertyName];
- }, this );
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var mergeDescriptors = function( nodeDescriptor, prototypeDescriptor ) {
- if ( nodeDescriptor.implements ) {
- prototypeDescriptor.implements = ( prototypeDescriptor.implements || [] ).
- concat( nodeDescriptor.implements );
- }
- if ( nodeDescriptor.source ) {
- prototypeDescriptor.source = nodeDescriptor.source;
- prototypeDescriptor.type = nodeDescriptor.type;
- }
- if ( nodeDescriptor.properties ) {
- prototypeDescriptor.properties = prototypeDescriptor.properties || {};
- for ( var propertyName in nodeDescriptor.properties ) {
- prototypeDescriptor.properties[propertyName] = nodeDescriptor.properties[propertyName];
- }
- }
- if ( nodeDescriptor.methods ) {
- prototypeDescriptor.methods = prototypeDescriptor.methods || {};
- for ( var methodName in nodeDescriptor.methods ) {
- prototypeDescriptor.methods[methodName] = nodeDescriptor.methods[methodName];
- }
- }
- if ( nodeDescriptor.events ) {
- prototypeDescriptor.events = prototypeDescriptor.events || {};
- for ( var eventName in nodeDescriptor.events ) {
- prototypeDescriptor.events[eventName] = nodeDescriptor.events[eventName];
- }
- }
- if ( nodeDescriptor.children ) {
- prototypeDescriptor.children = prototypeDescriptor.children || {};
- for ( var childName in nodeDescriptor.children ) {
- prototypeDescriptor.children[childName] = nodeDescriptor.children[childName];
- }
- }
- if ( nodeDescriptor.scripts ) {
- prototypeDescriptor.scripts = ( prototypeDescriptor.scripts || [] ).
- concat( nodeDescriptor.scripts );
- }
- return prototypeDescriptor;
- };
-
-
-
-
-
-
-
-
- var enumerable = function( value ) {
- return {
- value: value,
- enumerable: true,
- writable: false,
- configurable: false,
- };
- };
-
-
-
-
-
-
-
-
- var writable = function( value ) {
- return {
- value: value,
- enumerable: true,
- writable: true,
- configurable: false,
- };
- };
-
-
-
-
-
-
-
-
- var configurable = function( value ) {
- return {
- value: value,
- enumerable: true,
- writable: true,
- configurable: true,
- };
- };
-
-
-
- var keyedCollectionPrototype = {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- create: function( name, changes, value ) {
- if ( ! this.hasOwn( name ) ) {
- this.makeOwn( "existing" );
-
-
-
- Object.defineProperty( this.existing, name,
- configurable( value ? value : undefined ) );
- if ( changes ) {
- this.makeOwn( "changes" );
- if ( this.changes[ name ] !== "removed" ) {
- this.changes[ name ] = "added";
- } else {
- this.changes[ name ] = "changed";
- }
- if ( this.container && this.containerMember ) {
- this.container.change( this.containerMember );
- }
- }
- return true;
- }
- return false;
- },
-
-
-
-
-
-
-
-
- delete: function( name, changes ) {
- if ( this.hasOwn( name ) ) {
- delete this.existing[ name ];
- if ( changes ) {
- this.makeOwn( "changes" );
- if ( this.changes[ name ] !== "added" ) {
- this.changes[ name ] = "removed";
- } else {
- delete this.changes[ name ];
- }
- if ( this.container && this.containerMember ) {
- this.container.change( this.containerMember );
- }
- }
- return true;
- }
- return false;
- },
-
-
-
-
-
-
-
-
- change: function( name, value ) {
- if ( this.hasOwn( name ) ) {
- this.makeOwn( "changes" );
- if ( this.changes[ name ] !== "added" ) {
- this.changes[ name ] = value ?
- value : this.changes[ name ] || "changed";
- }
- if ( this.container && this.containerMember ) {
- this.container.change( this.containerMember );
- }
- return true;
- }
- return false;
- },
-
-
-
-
-
-
-
- has: function( name ) {
- return name in this.existing;
- },
-
-
-
-
-
-
-
-
-
-
-
-
-
- hasOwn: function( name ) {
- return Object.prototype.hasOwnProperty.call( this.existing, name );
- },
-
-
-
-
-
-
-
-
-
-
- makeOwn: function( fieldName ) {
- if ( ! this.hasOwnProperty( fieldName ) ) {
- if ( this[ fieldName ] instanceof Array ) {
- this[ fieldName ] = this[ fieldName ].slice();
- } else if ( typeof this[ fieldName ] === "object" && this[ fieldName ] !== null ) {
- this[ fieldName ] = Object.create( this[ fieldName ] );
- } else {
- this[ fieldName ] = this[ fieldName ];
- }
- }
- },
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- existing: Object.create( null
-
-
-
- ),
-
-
-
-
-
-
- changes: {
-
-
-
-
-
- },
-
-
-
-
-
-
-
-
- container: undefined,
-
-
-
- containerMember: undefined,
- };
-
-
- var indexedCollectionPrototype = {
-
-
-
-
-
-
-
-
-
-
-
- create: function( id, changes ) {
- if ( ! this.hasOwn( id ) ) {
- this.makeOwn( "existing" );
- this.existing.push( id );
- if ( changes ) {
- this.makeOwn( "changes" );
- var removedIndex = this.changes.removed ?
- this.changes.removed.indexOf( id ) : -1;
- if ( removedIndex < 0 ) {
- this.changes.added = this.changes.added || [];
- this.changes.added.push( id );
- } else {
- this.changes.removed.splice( removedIndex, 1 );
- this.changes.changed = this.changes.changed || [];
- this.changes.changed.push( id );
- }
- if ( this.container && this.containerMember ) {
- this.container.change( this.containerMember );
- }
- }
- return true;
- }
- return false;
- },
-
-
-
-
-
-
-
-
- delete: function( id, changes ) {
- if ( this.hasOwn( id ) ) {
- this.existing.splice( this.existing.indexOf( id ), 1 );
- if ( changes ) {
- this.makeOwn( "changes" );
- var addedIndex = this.changes.added ?
- this.changes.added.indexOf( id ) : -1;
- if ( addedIndex < 0 ) {
- this.changes.removed = this.changes.removed || [];
- this.changes.removed.push( id );
- } else {
- this.changes.added.splice( addedIndex, 1 );
- }
- if ( this.container && this.containerMember ) {
- this.container.change( this.containerMember );
- }
- }
- return true;
- }
- return false;
- },
-
-
-
-
-
-
-
-
- change: function( id ) {
- if ( this.hasOwn( id ) ) {
- this.makeOwn( "changes" );
- var addedIndex = this.changes.added ?
- this.changes.added.indexOf( id ) : -1;
- var changedIndex = this.changes.changed ?
- this.changes.changed.indexOf( id ) : -1;
- if ( addedIndex < 0 && changedIndex < 0 ) {
- this.changes.changed = this.changes.changed || [];
- this.changes.changed.push( id );
- }
- if ( this.container && this.containerMember ) {
- this.container.change( this.containerMember );
- }
- return true;
- }
- return false;
- },
-
-
-
-
-
-
-
-
-
- has: function( id ) {
- return this.hasOwn( id );
- },
-
-
-
-
-
-
-
- hasOwn: function( id ) {
- return this.existing ? this.existing.indexOf( id ) >= 0 : false;
- },
-
-
-
-
-
-
-
-
-
-
- makeOwn: function( fieldName ) {
- if ( ! this.hasOwnProperty( fieldName ) ) {
- if ( this[ fieldName ] instanceof Array ) {
- this[ fieldName ] = this[ fieldName ].slice();
- } else if ( typeof this[ fieldName ] === "object" && this[ fieldName ] !== null ) {
- this[ fieldName ] = Object.create( this[ fieldName ] );
- } else {
- this[ fieldName ] = this[ fieldName ];
- }
- }
- },
-
-
-
-
-
-
-
-
-
-
- existing: [
-
-
-
- ],
-
-
-
-
-
-
-
-
-
-
-
- changes: {
-
-
-
- },
-
-
-
-
-
-
-
-
- container: undefined,
-
-
-
- containerMember: undefined,
- };
-
- var eventCollectionPrototype = Object.create( keyedCollectionPrototype, {
- create: {
- value: function( name, changes, parameters ) {
- var value = parameters ? {
- parameters: parameters.slice(),
- } : {};
- value.listeners = Object.create( indexedCollectionPrototype, {
- container: enumerable( this ),
- containerMember: enumerable( name ),
- } );
- return keyedCollectionPrototype.create.call( this, name, changes, value );
- }
- },
- } );
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var nodes = {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- create: function( nodeID, prototypeID, behaviorIDs, nodeURI, nodeName, parentID ) {
-
- var self = this;
- var prototypeNode = behaviorIDs.reduce( function( prototypeNode, behaviorID ) {
- return self.proxy( prototypeNode, self.existing[behaviorID] );
- }, this.existing[prototypeID] );
-
- var parentNode = this.existing[parentID];
-
- if ( ! parentNode ) {
- this.globals[nodeID] = undefined;
- }
-
- return this.existing[nodeID] = {
-
-
-
-
-
-
-
- uri: nodeURI,
- name: nodeName,
-
-
-
-
-
-
-
-
-
- properties: Object.create( keyedCollectionPrototype, {
- existing: enumerable( Object.create( prototypeNode ?
- prototypeNode.properties.existing : null ) ),
- } ),
- methods: Object.create( keyedCollectionPrototype, {
- existing: enumerable( Object.create( prototypeNode ?
- prototypeNode.methods.existing : null ) ),
- } ),
- events: Object.create( eventCollectionPrototype, {
- existing: enumerable( Object.create( prototypeNode ?
- prototypeNode.events.existing : null ) ),
- } ),
-
-
- patchable: !! ( nodeURI ||
- parentNode && ! parentNode.initialized && parentNode.patchable ),
-
-
-
- initialized: false,
- };
-
-
-
- },
-
- initialize: function( nodeID ) {
- if ( this.existing[nodeID] ) {
- this.existing[nodeID].initialized = true;
- return true;
- }
- return false;
- },
-
- delete: function( nodeID ) {
- if ( this.existing[nodeID] ) {
- delete this.existing[nodeID];
- delete this.globals[nodeID];
- return true;
- }
- return false;
- },
-
-
-
-
-
- proxy: function( prototypeNode, behaviorNode ) {
- return {
- properties: {
- existing: Object.create(
- prototypeNode ? prototypeNode.properties.existing : null,
- propertyDescriptorsFor( behaviorNode.properties.existing )
- ),
- },
- methods: {
- existing: Object.create(
- prototypeNode ? prototypeNode.methods.existing : null,
- propertyDescriptorsFor( behaviorNode.methods.existing )
- ),
- },
- events: {
- existing: Object.create(
- prototypeNode ? prototypeNode.events.existing : null,
- propertyDescriptorsFor( behaviorNode.events.existing )
- ),
- },
- };
-
-
- function propertyDescriptorsFor( collectionExisting ) {
- return Object.keys( collectionExisting ).reduce(
- function( propertiesObject, memberName ) {
- propertiesObject[memberName] = {
- get: function() { return collectionExisting[memberName] },
- enumerable: true,
- };
- return propertiesObject;
- },
- {}
- );
- }
- },
-
- existing: {
-
-
-
-
-
-
- },
-
-
-
-
- globals: {
-
- },
- };
-
-
-
-
- var queue = this.private.queue = {
-
-
-
-
-
-
-
-
-
-
-
-
- insert: function( fields, chronic ) {
- var messages = fields instanceof Array ? fields : [ fields ];
- messages.forEach( function( fields ) {
-
- fields.sequence = ++this.sequence;
- this.queue.push( fields );
-
- if ( chronic ) {
- this.time = Math.max( this.time, fields.time );
- }
- }, this );
-
-
-
-
-
-
-
-
- this.queue.sort( function( a, b ) {
- if ( a.time != b.time ) {
- return a.time - b.time;
- } else if ( a.origin != "reflector" && b.origin == "reflector" ) {
- return -1;
- } else if ( a.origin == "reflector" && b.origin != "reflector" ) {
- return 1;
- } else {
- return a.sequence - b.sequence;
- }
- } );
-
-
-
- if ( chronic ) {
- vwf.dispatch();
- }
- },
-
-
-
-
-
- pull: function() {
- if ( this.suspension == 0 && this.queue.length > 0 && this.queue[0].time <= this.time ) {
- return this.queue.shift();
- }
- },
-
-
-
-
-
-
-
-
- filter: function( callback /* fields */ ) {
- this.queue = this.queue.filter( callback );
- },
-
-
-
-
-
- suspend: function( why ) {
- if ( this.suspension++ == 0 ) {
- vwf.logger.infox( "-queue#suspend", "suspending queue at time", vwf.now, why ? why : "" );
- return true;
- } else {
- vwf.logger.debugx( "-queue#suspend", "further suspending queue at time", vwf.now, why ? why : "" );
- return false;
- }
- },
-
-
-
-
-
-
-
-
-
- resume: function( why ) {
- if ( --this.suspension == 0 ) {
- vwf.logger.infox( "-queue#resume", "resuming queue at time", vwf.now, why ? why : "" );
- vwf.dispatch();
- return true;
- } else {
- vwf.logger.debugx( "-queue#resume", "partially resuming queue at time", vwf.now, why ? why : "" );
- return false;
- }
- },
-
-
-
-
-
- ready: function() {
- return this.suspension == 0;
- },
-
-
-
-
- time: 0,
-
-
-
- suspension: 0,
-
-
-
-
- sequence: 0,
-
-
-
- queue: [],
- };
- };
- } ) ( window );
|