Skip to content

Commit

Permalink
DCdiffer, roughly, wire Con* and remove their {#key}
Browse files Browse the repository at this point in the history
  • Loading branch information
stylehouse committed May 12, 2023
1 parent 32b358b commit 358b75b
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 30 deletions.
106 changes: 86 additions & 20 deletions src/lib/Co.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@ export function toCon (d) {
else {
// start resolving the first Con//Con
toCon_resolve(d)
// now all C may have .y.D previous self
// difference everything, including notifying parents of gone children
let diff = DCdiffer(C)

// a list of all -Con
C.c.visit = d.visit

// a list of all C**
C.c.visit = diff.visit
C.c.wake = diff.wake
// give them all an incrementing version
// < individuated by changes
let D = d.D
let version = (D && D.c.version || 0) + 1
for (let Co of d.visit) {
for (let Co of C.c.visit) {
Co.c.version = version
}

Expand All @@ -45,7 +50,7 @@ function toCon_resolve (d) {
toCon_newConz(d)
// then they, just before doing that themselves, are here:

if (d.resolving.length) {
if (1 || d.resolving.length) {
let names = d.resolving.map(
d => d.t + (d.C.c.Cont && d.C.c.Cont.sc.Ct ? ':'+d.C.c.Cont.sc.Ct : '')
)
Expand All @@ -59,8 +64,6 @@ function toCon_resolve (d) {
d.resolving.map(d => {
d.D = d.C.y.D
})

if (C.t == 'toCon') console.log("Given:\n"+threelevelprint(C))
}

// now we have d.resolving[d+]
Expand All @@ -69,6 +72,65 @@ function toCon_resolve (d) {
}
}

function DCdiffer (C) {
// list of everything, to update sip_dispatch
let visit = []
let wake = []
inlace(C,{
all:(C,q) => {
let uC = C.y.up
let D = C.y.D
if (C.c.el) {
// can only have el=2 already, meaning new
// wake new things parent (usu -Conz)
wake.push(uC || C)
// look no further
return 1
}
if (!D) {
console.log("!D|el: "+printaC(C))
return
}
if (C.c.removals) {
// C/* need to vanish
C.c.el = 8
wake.push(C)
}
// compare data
//if (C.sc.Ct == 'oyce') debugger
if (!heq(capture_sc(D.sc),capture_sc(C.sc))) {
C.c.el = 3
wake.push(C)
}
}
})
inlace(C,{
all:(C,q) => {
visit.push(C)
//if (C.t == 'A') console.log("Given:\n"+threelevelprint(C))
}
})

console.log("Wake:\n"+wake.map(C => printaC(C)).join("\n"))
return {visit,wake}
}
function heq(s,c) {
return Object.keys(s).length == Object.keys(c).length
&& !Object.keys(s).some(k => s[k] != c[k])
}
function capture_sc(s:Object) {
let h = {}
for (let k in s) {
if (k == 'z') continue
let v = s[k]
if (v && typeof v == 'object') {
if (v instanceof TheC) continue
}
h[k] = v
}
return h
}

// the q pile visits all C**, wrt D**
// including C between those in the d pile (which are only the -Con)
function DCresolve (c) {
Expand Down Expand Up @@ -132,25 +194,28 @@ function i_tz (N) {
function threelevelprint (C) {
if (!C) return "null"
let N = []
let sip = C => C.c.ip ? C.c.ip.join('.') : ''
inlace(C,{all:(C,d) => {
let sipdom = d.up && sip(d.up.s)
let sipsay = sip(C)
if (sipsay && sipdom && sipsay.startsWith(sipdom)) sipsay = sipsay.slice(sipdom.length)
if (C.c.removals) {
sipsay += " --"+C.c.removals.map(C => C.t).join(',')
}
let scsay = C.sc.Ct ? "%Ct="+C.sc.Ct : ''
if (C.y.D) scsay += '%D'
N.push(
new Array(d.d).fill(' ').join('')
+
C.t+"\t-"+C.c.pi+"\t"+sipsay+"\t"+scsay
)
let uC = d.up?.s
let indent = new Array(d.d).fill(' ').join('')
N.push(indent + printaC(C,uC))
if (d.d > 2) return 1
}})
return N.join("\n")
}
function printaC (C,uC) {
let sip = C => C.c.ip ? C.c.ip.join('.') : ''
let sipdom = uC && sip(uC)
let sipsay = sip(C)
if (sipsay && sipdom && sipsay.startsWith(sipdom)) sipsay = sipsay.slice(sipdom.length)
if (C.c.el) sipsay += " el="+C.c.el
if (C.c.removals) {
sipsay += " --"+C.c.removals.map(C => C.t).join(',')
}
let scsay = C.sc.Ct ? "%Ct="+C.sc.Ct : ''
if (C.y.D) scsay += '%D'

return C.t+"\t-"+C.c.pi+"\t"+sipsay+"\t"+scsay
}

// defines an adder of d.C or its C.c.$pi=C/*
function DCpartor (nodepi) {
Expand Down Expand Up @@ -353,6 +418,7 @@ export class sip_dispatch {
}

o (sip) {
if (typeof sip == 'object') sip = sip.c.ip.join('.')
let Con = this.sip_C[sip]
if (!Con) throw "!sip: "+sip
// send it a replacement C
Expand Down
2 changes: 0 additions & 2 deletions src/lib/pi/Con.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@

<c_sip style="font-size:70%"> {sip} </c_sip>
<revision style="color:darkcyan; text-decoration:underline">{quee}</revision>
{#key quee}
{#each o_(C) as n}
<span style="display:inline-block; vertical-align: middle; border:2px solid gainsboro; border-right:none; padding: 0 3px; margin: 0 3px; border-radius: 3px;">
<svelte:component this={pis[n.c.pi]} C={n}/>
</span>
{/each}
{/key}
12 changes: 10 additions & 2 deletions src/lib/pi/Cont.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
<script lang="ts">
import { onMount } from 'svelte'
import {sip_wiree} from '$lib/Co'
export let C
let {sym,Ct,say} = C.sc
sip_wiree(C, v => {
C = v
})
let sym,Ct,say
function upto() {
({sym,Ct,say} = C.sc)
}
$: upto(C)
let wrapper
onMount((e,t,c) => {
Expand All @@ -13,9 +21,9 @@
})
</script>


<div bind:this={wrapper}>
{#if sym} <span style="color:cornsilk">{sym}</span>{/if}
{#if Ct} <s_Ct style="color:gainsboro">{Ct}</s_Ct>{/if}
{#if say} <span style="color:darkcyan"> {say} </span>{/if}

</div>
14 changes: 10 additions & 4 deletions src/lib/pi/Conz.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@
<script lang="ts">
import { scale } from 'svelte/transition'
import {o_} from '$lib/St'
import {sip_wiree} from '$lib/Co'
import Con from '$lib/pi/Con.svelte'
export let C
let nodules = o_(C)
let update = 0
sip_wiree(C, v => {
C = v
})
let nodules
function upto() {
nodules = o_(C)
}
$: upto(C)
</script>



{#if nodules.length}
<nodules style="display:inline-block; vertical-align: middle; border:1px solid gainsboro; border-right:none; padding: 0 3px; margin: 0 3px; border-radius: 3px;">
{#each nodules as n}
Expand Down
7 changes: 5 additions & 2 deletions src/routes/Code.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@
$: moment, sipd.sync()
function busybusy () {
sipd.o('1')
for (let n of con.c.wake) {
sipd.o(n)
}
//sipd.o('1')
//sipd.o('1.2')
sipd.o('1.2.1.2.2')
//sipd.o('1.2.1.2.2')
// < ping only the -Cont etc? only -Con subscribe so far
//sipd.o('1.2.1.2.2.1',refresh)
}
Expand Down

0 comments on commit 358b75b

Please sign in to comment.