From 74bcaee8e01018ae307c348297f539a556082b07 Mon Sep 17 00:00:00 2001
From: Jake <jake.read@cba.mit.edu>
Date: Sat, 15 Jun 2019 16:36:17 -0400
Subject: [PATCH] traces through, multilayer link, recursiveness, but need to
unf- view-inside-view-inside ...
---
bootstrap.js | 1 -
hunks/view.js | 121 ++++++++++++++++++++++++++++----------------------
view/vptch.js | 1 +
3 files changed, 68 insertions(+), 55 deletions(-)
diff --git a/bootstrap.js b/bootstrap.js
index 9306abe..d6e8dcd 100644
--- a/bootstrap.js
+++ b/bootstrap.js
@@ -77,7 +77,6 @@ window.onload = () => {
let nview = view.defs.find((cnd) =>{
return (cnd.type === 'view' && cnd.name !== 'tlview')
})
- view.globalOrganize()
view.zoomExtents()
nview.hunk.refresh()
})
diff --git a/hunks/view.js b/hunks/view.js
index cc036c5..ad86527 100644
--- a/hunks/view.js
+++ b/hunks/view.js
@@ -375,7 +375,7 @@ function View() {
// trace should return, for an output, the next input.
// if the input is a link, it should try to traverse
let trace = (output) => {
- console.log(`tracing from ${output.name} in ${output.parent.name}`)
+ console.log(`tracing from ${output.name} in hunk ${output.parent.name} in view ${this.name}`)
// ok, traces through links / heirarchy, returning final destination
// of *connected* links
if (output.connections.length !== 1) {
@@ -383,14 +383,17 @@ function View() {
return false
}
let next = output.connections[0]
+ console.log(`TRACE: NEXT:`, next)
if (next.parent.type === 'link') {
// this is the heirarchy dive
let thru = next.parent.reciprocalLink
+ console.log(`TRACE: NEXT: LINK`, thru)
if (thru) {
// a mirror,
let otp = thru.outputs[next.ind]
if (otp) {
- trace(otp)
+ // return / recurse
+ return trace(otp)
} else {
console.log('found link, but no output on the other side')
return false
@@ -438,14 +441,14 @@ function View() {
// well, ya didn't know it, but you're here to write a graph traversal scheme
// one must start somewhere,
// let's find the links of the output's parent
- for(let df of opv.defs){
- if(df.type === 'link'){
+ for (let df of opv.defs) {
+ if (df.type === 'link') {
console.log(`BUILD: find link ${df.name}`)
let dfr = df.reciprocalLink
- if(dfr){
+ if (dfr) {
console.log(`BUILD: find reciprocal link ${dfr.name} for ${df.name}`)
// that's one traverse, let's check
- if(dfr.parentView === ipv){
+ if (dfr.parentView === ipv) {
// this is the 'other side'
// let's add that side first ... bottom - up
let opList = dfr.states[3].value
@@ -490,64 +493,74 @@ function View() {
this.globalOrganize = () => {
- console.log("GO KICKOFF ORGANIZING PARTY")
+ console.log("GO: KICKOFF ORGANIZING PARTY")
// this is a request made:
/*
(1) when any view refreshes,
(2) when we load a new patch
(3) when we load a new system
- - this doesn't change topology
- - this just sets up links' visual relationships, ok ok ?
+ (4) when we build a route with .buildRoute(output, input)
+ - this doesn't change topologies, or make any requests to managers,
+ - it just organizes visually
*/
- // the code for a lower-level view,
- let links = []
- for (let df of defs) {
- // but links are the way home, so
- if (df.type === 'link') {
- links.push(df)
- }
- }
- // and
- if (links.length > 0) {
- console.log(`GO finds ${links.length} links`)
- for (let lk of links) {
- console.log('GO tracing')
- // 1th output of a link is mgrmsgs to its manager
- let viewDef = trace(lk.outputs[1]).parent
- // if we found a view at the end of the trace,
- if (viewDef && !lk.reciprocalView && !lk.isWrappedOn) {
- lk.wrapon(viewDef)
- viewDef.unwrap()
- } else {
- // no op
- } // and if the view is refreshed ...
- if (viewDef.hunk.hasRefreshed) {
- // find the interior link (by search for ol state)
- let oind = lk.states.find((cnd) => {
- return cnd.name === 'otherLink'
- }).value
- if (!oind) throw new Error('cannot find link oind state for hookup')
- // doth it ?
- let internalLink = viewDef.hunk.defs[oind]
- if (internalLink) {
- if (internalLink.type !== 'link') throw new Error('link mixup alert')
- // hook em up
- lk.reciprocalLink = internalLink
- internalLink.reciprocalLink = lk
- // and do,
- internalLink.edgecase()
- // still logging these, bc it's nice 2 kno
- console.log(`GO cn link ${lk.name} to ${internalLink.name}`)
- } else {
- console.error("organizing ... cannot find a reciprocal link")
+ // we need to recurse here,
+ let recursor = (scope, order) => {
+ console.log(`GO: recurses ${scope.name} at ${order}`)
+ // scope is a view (hunk)
+ // order is nth- level down tree, with us (toplevel) at root 0
+ console.log(`GO: scope defs, tl defs`)
+ for(let df of scope.defs){
+ console.log(`GO: df over ${df.name} in ${scope.name}`)
+ // edgecased is a block to not walk back-up heirarchy,
+ if(df.type === 'link' && df.grouptype !== 'edgecased'){
+ // find recirprocal view relationship via trace, which returns an input, thru links,
+ // given some output
+ console.log(`GO: TRACELOG FROM ${df.name}`)
+ let rvi = trace(df.outputs[1])
+ console.log(`GO: TRACELOG RETURNS`, rvi)
+ if(rvi){
+ // we have ah link definition, and ah view definition, connected by routing,
+ // so we are safe to do
+ let rvd = rvi.parent
+ // if the rvd is a manager, this is the bottom level -> a link thru to a manager,
+ if(rvd.type === 'manager') continue
+ // mark,
+ if (order % 2) $(rvd.hunk.dom).css('background-color', '#d6d6d6')
+ // and,
+ console.log(`GO: wrap ${df.name} around ${rvd.name}`)
+ df.wrapon(rvd)
+ rvd.unwrap()
+ // now, if we have ll data,
+ if(rvd.hunk.hasRefreshed){
+ // find the interior link (by search for ol state)
+ let oind = df.states.find((cnd) => {
+ return cnd.name === 'otherLink'
+ }).value
+ if (!oind) throw new Error('cannot find link oind state for hookup')
+ // doth it ?
+ let internalLink = rvd.hunk.defs[oind]
+ if (internalLink) {
+ if (internalLink.type !== 'link') throw new Error('link mixup alert')
+ // hook em up
+ df.reciprocalLink = internalLink
+ internalLink.reciprocalLink = df
+ // and do,
+ internalLink.edgecase()
+ // still logging these, bc it's nice 2 kno
+ console.log(`GO cn link ${df.name} to ${internalLink.name}`)
+ // done w/ internal, now we can
+ recursor(rvd.hunk, order ++)
+ } else {
+ console.error("organizing ... cannot find a reciprocal link")
+ }
+ }
}
}
}
+ // and roll zerbraHeirarchy in here also, using order ...
}
-
- if (this.isTopLevel) {
- this.zebraHeirarchy()
- }
+ // kickoff w/
+ recursor(this, 1)
}
this.zebraHeirarchy = () => {
diff --git a/view/vptch.js b/view/vptch.js
index c12eca6..0bfccad 100644
--- a/view/vptch.js
+++ b/view/vptch.js
@@ -213,6 +213,7 @@ function PatchSet(View, MsgBox) {
mergeHunkList(patch).then((defs) => {
// (4) then we can follow on adding links,
mergeLinkList(patch).then(() => {
+ view.tlv.globalOrganize()
resolve(defs)
}).catch((errmsg) => {
// link catch
--
GitLab