123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002 |
- "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: '/',
- waitSeconds: 0,
- shim: {
-
- "vwf/model/aframe/addon/aframe-interpolation": {
- deps: [ "vwf/model/aframe/aframe-master.min" ]
- },
- "vwf/model/aframe/extras/aframe-extras.loaders": {
- deps: [ "vwf/model/aframe/aframe-master.min" ]
- },
- "vwf/model/aframe/addon/aframe-sun-sky": {
- deps: [ "vwf/model/aframe/aframe-master.min" ]
- },
- "vwf/model/aframe/extras/aframe-extras.controls.min": {
- deps: [ "vwf/model/aframe/aframe-master.min" ]
- },
- "vwf/model/aframe/addon/SkyShader": {
- deps: [ "vwf/model/aframe/aframe-master.min" ]
- },
- "vwf/model/aframe/addon/BVHLoader": {
- deps: [ "vwf/model/aframe/aframe-master.min" ]
- },
- "vwf/model/aframe/addon/TransformControls": {
- deps: [ "vwf/model/aframe/aframe-master.min" ]
- },
- "vwf/model/aframe/addon/THREE.MeshLine": {
- deps: [ "vwf/model/aframe/aframe-master.min" ]
- },
- "vwf/model/aframe/kframe/aframe-aabb-collider-component.min": {
- deps: [ "vwf/model/aframe/aframe-master.min" ]
- },
- "vwf/model/aframe/addon/aframe-components": {
- deps: [ "vwf/model/aframe/aframe-master.min",
- "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.min" ]
- }
- }
- };
-
- 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.min",
- "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/view/document", active: true },
- { library: "vwf/model/aframeComponent", active: true },
- { library: "vwf/kernel/view", 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.min"],
- active: false
- },
-
- { library: "vwf/view/aframe", active: true },
- { library: "vwf/model/aframe/aframe-master.min", 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/document", active: true },
- { library: "vwf/view/aframe", active: true },
- { library: "vwf/view/aframeComponent", 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').once(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( function() {
-
-
-
-
- require( "vwf/configuration" ).instance = require( "vwf/utility" ).merge(
- {}, require( "vwf/configuration" ).instance, applicationConfig );
-
-
-
-
-
- vwf.initialize(application, getActiveLibraries(initializers["model"], true), getActiveLibraries(initializers["view"], true), callback);
-
- } );
-
- } );
- })
-
- })
-
-
-
-
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 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 => {return _app.chooseConnection(res)})
- .then(res => {self.ready( application, res)})
- };
-
-
- this.ready = function( component_uri_or_json_or_object, path ) {
-
-
- if (_app.isLuminary){
-
- vwf.namespace_ = _app.luminary.namespace;
- vwf.moniker_ = _app.luminary.clientID;
- console.log('namespace: ' + vwf.namespace_, ' for client: ' + vwf.moniker_);
-
-
- var heartbeat = _LCSDB.get(vwf.namespace_).get('heartbeat');
- if(_app.isLuminaryGlobalHB && _app.luminaryGlobalHBPath ) {
- let hbPath = _app.luminaryGlobalHBPath.split('/');
- var heartbeat = _LCSDB;
- hbPath.forEach(el=>{
- heartbeat = heartbeat.get(el);
- })
- }
- _app.luminary.subscribeOnHeartbeat(heartbeat);
- _app.luminary.subscribeOnMessages();
-
-
- } else {
-
- _app.reflectorClient.connect(component_uri_or_json_or_object, path);
- }
- };
-
-
- 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(_app.isLuminary){
- _app.luminary.stampExternalMessage(fields);
- } else if ( _app.reflectorClient.socket ) {
-
-
- var message = JSON.stringify( fields );
- _app.reflectorClient.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(_app.isLuminary){
- _app.luminary.stampExternalMessage(fields);
- } else if ( _app.reflectorClient.socket ) {
-
- var message = JSON.stringify( fields );
- _app.reflectorClient.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( function() {
- 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( function() {
- 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;
- }
- function resume( err ) {
- window.clearTimeout( timeoutID );
- driver_ready = true;
- err && vwf.logger.warnx( "createChild", nodeID, childName + ":", err );
- 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.forEach( 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;
- }
- function resume( err ) {
- window.clearTimeout( timeoutID );
- driver_ready = true;
- err && vwf.logger.warnx( "createChild", nodeID, childName + ":", err );
- 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( function() {
- 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 loadComponent = function( nodeURI, baseURI, callback_async /* nodeDescriptor */, errback_async /* errorMessage */ ) {
- if ( nodeURI == vwf.kutility.protoNodeURI ) {
- callback_async( vwf.kutility.protoNodeDescriptor );
- } else if ( nodeURI.match( RegExp( "^data:application/json;base64," ) ) ) {
-
-
-
- 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 = function(f) {
- let result = YAML.parse(f);
- let nativeObject = result;
-
-
- if(nativeObject) {
- 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').once(comp=>{
- parseComp (comp);
- })
-
-
-
-
-
- } else {
- let worldName = dbName.split('/')[0];
-
- fileName = dbName.replace(worldName + '/', "");
- userDB.get('worlds').path(worldName).get(fileName).get('file').once(comp=>{
- parseComp (comp);
- })
-
-
-
-
-
- }
-
-
-
-
-
- }
- };
-
-
- var loadScript = function( scriptURI, baseURI, callback_async /* scriptText */, errback_async /* errorMessage */ ) {
- if ( scriptURI.match( RegExp( "^data:application/javascript;base64," ) ) ) {
-
-
-
- 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 = function(res) {
- let scriptText = res;
- try {
- 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').once(comp=>{
- parseComp (comp);
- })
-
-
-
-
-
- } else {
- fileName = dbName.replace(worldName + '/', "");
- userDB.get('worlds').path(worldName).get(fileName).get('file').once(comp=>{
- parseComp (comp);
- })
-
-
-
-
-
- }
-
- }
- };
-
-
-
-
-
-
-
-
-
-
-
-
- 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 );
|