diff --git a/core/scope.js b/core/scope.js index 625e5921b838b16ad9163bcd9d02d813302ab311..5797bee3a37030a81af2eb2491379d25acd20f3f 100644 --- a/core/scope.js +++ b/core/scope.js @@ -285,7 +285,8 @@ export default function Scope(wrapper, tlv) { // new plane every time! // handle to our context's container (the link) let ldef = context.exterior() - if (!ldef) throw new Error("no apparent link container for this context") + // this can happen, when i.e. upstairs is resetting / refreshing ... ? + if (!ldef) return //throw new Error("no apparent link container for this context") // things should now be redrawn, blocks.redrawDef(ldef) } @@ -301,7 +302,7 @@ export default function Scope(wrapper, tlv) { } // that-which-is-wrapped-around-us let ldef = context.exterior() - if (!ldef) throw new Error("no apparent link container for this context, close meaningless, que?") + if (!ldef) return // throw new Error("no apparent link container for this context, close meaningless, que?") // ok, cleanup the context, blocks.wipeContext(context) // she gone, burn the letters diff --git a/hunks/view.js b/hunks/view.js index befbed59d8afd83db8bdc119f4ed4a33578340ee..7802136c284ec00cb952c30b5f87b79f85ed008d 100644 --- a/hunks/view.js +++ b/hunks/view.js @@ -1295,7 +1295,7 @@ export default function View() { // this is really kind of ah let traceClone = (trace) => { let nt = [] - for (let t of nt) { + for (let t of trace) { nt.push({ entrance: t.entrance, exit: t.exit @@ -1304,7 +1304,8 @@ export default function View() { return nt } - this.buildRoute = (opdef, ipdef) => { + this.buildRoute = (opdef, ipdef, debug) => { + debug = true // *doesn't handle* but could: half-existing routes, etc ? return new Promise(async (resolve, reject) => { // already exists ? @@ -1328,6 +1329,7 @@ export default function View() { // ok, we are now going to try to build a route between *contexts* // mapping a trace of links between them, let recursor = (context, entrance, trace) => { + if(debug) console.log('BR Recurse', context, entrance) for (let df of context.defs) { if (df.type === 'link' && df !== entrance) { if (df.thru()) { @@ -1342,9 +1344,11 @@ export default function View() { // if this is it, trace building is complete, if (df.thru().context == ipdef.parent.context) { // other branches will run to completion, route will remain... - route = uniquetrace + if(debug) console.log('ROUTE COMPLETE') + route = traceClone(uniquetrace) } else { - recursor(df.thru().context, df.thru(), traceClone(trace)) + if(debug) console.log('RECURSE WITHIN') + recursor(df.thru().context, df.thru(), traceClone(uniquetrace)) } } else { // @@ -1355,7 +1359,7 @@ export default function View() { // kickoff, recursor(opdef.parent.context, null, []) // ok, once this runs to completion, we should have - console.log('route', route) + if(debug) console.log('BR: ROUTE IS', route) // presuming we will be able to build a route, we should pick a type // it's more likely that higher level languages will have a broader set of // type conversions, and at the moment systems are typically higher level at higher orders @@ -1374,6 +1378,7 @@ export default function View() { let gateway = route[0].entrance // the first link, let gatelist = gateway.states[2].value gatelist += `, at_${gateway.outputs.length} (${type})` + if(debug) console.log('BR: OPEN GATEWAY') await gateway.context.requestStateChange(gateway.states[2], gatelist) // cover interiors, for (let p = 0; p < route.length - 1; p++) { @@ -1382,10 +1387,13 @@ export default function View() { let context = route[p].exit.context let exl = exit.states[3].value exl += `, at_${exit.outputs.length} (${type})` + if(debug) console.log('BR: OPEN NEXT EXIT') await context.requestStateChange(exit.states[3], exl) let enl = entrance.states[2].value enl += `, at_${entrance.inputs.length} (${type})` - await context.requestStateChange(entrance.states[3], enl) + if(debug) console.log('BR: OPEN NEXT ENTRANCE') + await context.requestStateChange(entrance.states[2], enl) + if(debug) console.log('BR: CONNECT') await context.requestAddLink(exit.outputs[exit.outputs.length - 1], entrance.inputs[entrance.inputs.length - 1]) } // cover exit case @@ -1400,12 +1408,16 @@ export default function View() { two: probably more robust: write replaceDef in such a way that existing ptrs stay all gucci gucci ok, ok, party, burrito, etc. */ + if(debug) console.log('BR: OPEN PORTHOLE') await ipdef.parent.context.requestStateChange(porthole.states[3], portlist) //console.warn('porthole', porthole.outputs[porthole.outputs.length - 1], ipdef) + if(debug) console.log('BR: WIRE PORT') await ipdef.parent.context.requestAddLink(porthole.outputs[porthole.outputs.length - 1], ipdef) // to avoid piping data into the void, we can do this last -> //console.log('gateway', opdef, gateway.inputs[gateway.inputs.length - 1]) + if(debug) console.log('BR: WIRE GATEWAY') await gateway.context.requestAddLink(opdef, gateway.inputs[gateway.inputs.length - 1]) + if(debug) console.log('BR: SUCCESS') resolve() } catch (err) { reject(err)