on main help sign in
add error catching to graph, bump version
39c101cJohn Hyde
README.md+1
@@ -35,6 +35,7 @@ Regardless of what you run to develop, Vite will hot-reload code changes as you
35 2. `|mount %astrolabe` to mount it.
35 2. `|mount %astrolabe` to mount it.
36 3. Set `ASTROLABE_DESK` in `.env.local` if the path to your desk is different.
36 3. Set `ASTROLABE_DESK` in `.env.local` if the path to your desk is different.
373. Create and upload `glob-http`, if applicable (see below)
373. Create and upload `glob-http`, if applicable (see below)
38+4. Bump the `version` in `desk.docket-0`.
383. Install the desk
393. Install the desk
39 1. From the `ui` folder: `npm run install:desk`
40 1. From the `ui` folder: `npm run install:desk`
40 2. From the distribution ship's dojo: `:treaty|unpublish %astrolabe`
41 2. From the distribution ship's dojo: `:treaty|unpublish %astrolabe`
desk/app/astrolabe.hoon+31−14
@@ -6,15 +6,12 @@
6 $% state-0
6 $% state-0
7 state-1
7 state-1
8 state-2
8 state-2
9+ state-3
9 ==
10 ==
10+$ state-0
11+$ state-0
11 $: %0
12 $: %0
12 spa=spawned
13 spa=spawned
13 ==
14 ==
14−+$ fropoints-1
15− $: fopoints=opoints :: forward ordered points
16− ropoints=opoints :: reversed ordered points, e.g. .~palnet-sampel
17− ==
18+$ state-1
15+$ state-1
19 $: %1
16 $: %1
20 fropoints-1
17 fropoints-1
@@ -24,12 +21,22 @@
24 spam=spawn-mip
21 spam=spawn-mip
25 fropoints-1
22 fropoints-1
26 ==
23 ==
24++$ state-3
25+ $: %3
26+ prev-spo=(map ship ship) :: so we know who the old sponsor was when sponsor changes
27+ spam=spawn-mip
28+ fropoints-1
29+ ==
27::
30::
31++$ fropoints-1
32+ $: fopoints=opoints :: forward ordered points
33+ ropoints=opoints :: reversed ordered points, e.g. .~palnet-sampel
34+ ==
28+$ spawned (jug ship ship)
35+$ spawned (jug ship ship)
29+$ card card:agent:gall
36+$ card card:agent:gall
30--
37--
31%- agent:dbug
38%- agent:dbug
32−=| state-2
39+=| state-3
33=* state -
40=* state -
34^- agent:gall
41^- agent:gall
35=<
42=<
@@ -49,9 +56,9 @@
49 ^- (quip card _this)
56 ^- (quip card _this)
50 =/ old !<(versioned-state old-state)
57 =/ old !<(versioned-state old-state)
51 =^ cards-01 old
58 =^ cards-01 old
52− ?. ?=(?(%0 %1) -.old) `old
59+ ?. ?=(?(%0 %1 %2) -.old) `old
53 (on-naive-state:hc get-nas:hc)
60 (on-naive-state:hc get-nas:hc)
54− ?> ?=(%2 -.old)
61+ ?> ?=(%3 -.old)
55 [cards-01 this(state old)]
62 [cards-01 this(state old)]
56++ on-poke on-poke:def
63++ on-poke on-poke:def
57++ on-watch on-watch:def
64++ on-watch on-watch:def
@@ -147,17 +154,27 @@
147 |= [child=ship nas=^state:naive]
154 |= [child=ship nas=^state:naive]
148 ^- _state
155 ^- _state
149 =/ =npoint (get-npoint-from-nas child nas)
156 =/ =npoint (get-npoint-from-nas child nas)
150− =. spam
151− =/ parent (^sein:title child)
157+ =/ parent (^sein:title child)
152− ?: =(parent child) spam
158+ ?: =(parent child) state
153− ?: (is-npoint-locked npoint) spam
159+ ?: (is-npoint-locked npoint) state
154− =/ pdata (pdata:smel (pmeta:smel child npoint) ~)
160+ =/ pdata (pdata:smel (pmeta:smel child npoint) ~)
155− =* spo sponsor.net.npoint
161+ =* spo sponsor.net.npoint
156− =? spam &(has.spo !=(parent who.spo))
162+ =/ spo-not-par &(has.spo !=(parent who.spo))
163+ =? state spo-not-par
164+ =/ prev (~(get by prev-spo) child)
165+ =? spam &(?=(^ prev) !=(u.prev who.spo))
166+ (~(del bi spam) u.prev child)
167+ =. prev-spo
168+ %+ ~(put by prev-spo)
169+ child
170+ who.spo
171+ =. spam
157 %^ ~(put bi-meta spam)
172 %^ ~(put bi-meta spam)
158 who.spo
173 who.spo
159 child
174 child
160 pdata
175 pdata
176+ state
177+ =. spam
161 %^ ~(put bi-meta spam)
178 %^ ~(put bi-meta spam)
162 parent
179 parent
163 child
180 child
desk/desk.docket-0+2−2
@@ -2,9 +2,9 @@
2 info+'Your guide to the Urbit constellations'
2 info+'Your guide to the Urbit constellations'
3 color+0x1f.243c
3 color+0x1f.243c
4 image+'https://raw.githubusercontent.com/johnhyde/astrolabe/main/ui/src/assets/astrolabe-tile.svg'
4 image+'https://raw.githubusercontent.com/johnhyde/astrolabe/main/ui/src/assets/astrolabe-tile.svg'
5− glob-http+['https://s3.us-east-2.amazonaws.com/warkgnall.com/urbit/astrolabe/globs/glob-0v2.jtc81.6iedn.re59t.n1mo1.9e0k8.glob' 0v2.jtc81.6iedn.re59t.n1mo1.9e0k8]
5+ glob-http+['https://s3.us-east-2.amazonaws.com/warkgnall.com/urbit/astrolabe/globs/glob-0v2.9eih9.a77pv.83cmp.gc70u.ev4q7.glob' 0v2.9eih9.a77pv.83cmp.gc70u.ev4q7]
6 base+'astrolabe'
6 base+'astrolabe'
7− version+[0 3 4]
7+ version+[0 3 5]
8 website+'https://github.com/johnhyde/astrolabe'
8 website+'https://github.com/johnhyde/astrolabe'
9 license+'MIT'
9 license+'MIT'
10==
10==
ui/src/lib/graph.ts+101−89
@@ -252,105 +252,113 @@ export function populateGraph(g: Graph, chartData: ChartPoint[], bySponsor: bool
252 if (itsYou) {
252 if (itsYou) {
253 g.setNodeAttribute(gPatp, 'color', colors.YOUR_GAL);
253 g.setNodeAttribute(gPatp, 'color', colors.YOUR_GAL);
254 }
254 }
255+ try {
255− g.addNode(sPatp, {
256+ g.addNode(sPatp, {
256− label: sPatp,
257+ label: sPatp,
257− size: starSize,
258+ size: starSize,
258− color: itsYou ? colors.YOU : colors.GOLDT2,
259+ color: itsYou ? colors.YOU : colors.GOLDT2,
259− x: starX,
260+ x: starX,
260− y: starY,
261+ y: starY,
261− zIndex: 8,
262+ zIndex: 8,
262− });
263− if (lastStarArm == arm) {
264− g.addEdge(sPatp, lastStarPatp, {
265− color: colors.LGREY,
266− size: 0.1,
267− zIndex: 7,
268− });
269− } else {
270− g.addEdge(sPatp, gPatp, {
271− color: colors.LGREY,
272− size: 0.2,
273− zIndex: 9,
274 });
263 });
264+ if (lastStarArm == arm) {
265+ g.addEdge(sPatp, lastStarPatp, {
266+ color: colors.LGREY,
267+ size: 0.1,
268+ zIndex: 7,
269+ });
270+ } else {
271+ g.addEdge(sPatp, gPatp, {
272+ color: colors.LGREY,
273+ size: 0.2,
274+ zIndex: 9,
275− }
275+ });
276+ }
276− lastStarArm = arm;
277+ lastStarArm = arm;
277− lastStarPatp = sPatp;
278+ lastStarPatp = sPatp;
278− if (star.sponsor) {
279+ if (star.sponsor) {
279− sponsorEdges.push([sPatp, star.sponsor, {
280+ sponsorEdges.push([sPatp, star.sponsor, {
280− color: colors.GREEN,
281+ color: colors.GREEN,
281− size: 0.2,
282+ size: 0.2,
282− zIndex: 11,
283+ zIndex: 11,
283− }]);
284+ }]);
284− }
285−
286− const planets = star[subsKey] || [];
287− const numPlanets = planets.length;
288− // const maxPlanetDistance = starSize * 1.6 * 4000 * 64;
289− const maxPlanetDistance = minDistanceBetweenStars * 0.45;
290− const minPlanetDistance = maxPlanetDistance / 4;
291− const {
292− coords: planetCoords,
293− numArms: numPlanetArms,
294− minDistanceBetween: minDistanceBetweenPlanets,
295− } = arrangePointsInSpirals(numPlanets,
296− {
297− maxDistance: maxPlanetDistance,
298− minDistance: minPlanetDistance,
299− startX: starX,
300− startY: starY,
301− maxArms: 30,
302− makeSingleArmCircle: true,
303− });
304− let lastPlanetArm = null;
305− let lastPlanetPatp = null;
306− planets.forEach((planet, pi) => {
307− const pPatp = planet.patp;
308− const [planetX, planetY] = planetCoords[pi].coords;
309− const arm = planetCoords[pi].arm;
310− const planetSize = Math.sqrt(Math.min(minPlanetDistance, minDistanceBetweenPlanets)) / 1300;
311− const planetEdgeSize = planetSize / 3;
312− const itsYou = pPatp === '~' + window.ship;
313− if (itsYou) {
314− g.setNodeAttribute(sPatp, 'color', colors.YOUR_STAR);
315− g.setNodeAttribute(gPatp, 'color', colors.YOUR_GAL);
316 }
285 }
317− try {
286+
318− g.addNode(pPatp, {
287+ const planets = star[subsKey] || [];
319− label: pPatp,
288+ const numPlanets = planets.length;
320− size: planetSize,
289+ // const maxPlanetDistance = starSize * 1.6 * 4000 * 64;
321− color: itsYou ? colors.YOU : (planet.dominion == 'l2' ? colors.GREEN : colors.BLUE),
290+ const maxPlanetDistance = minDistanceBetweenStars * 0.45;
322− x: planetX,
291+ const minPlanetDistance = maxPlanetDistance / 4;
323− y: planetY,
292+ const {
324− zIndex: 6,
293+ coords: planetCoords,
294+ numArms: numPlanetArms,
295+ minDistanceBetween: minDistanceBetweenPlanets,
296+ } = arrangePointsInSpirals(numPlanets,
297+ {
298+ maxDistance: maxPlanetDistance,
299+ minDistance: minPlanetDistance,
300+ startX: starX,
301+ startY: starY,
302+ maxArms: 30,
303+ makeSingleArmCircle: true,
325 });
304 });
326− if (lastPlanetArm == arm) {
305+ let lastPlanetArm = null;
327− g.addEdge(pPatp, lastPlanetPatp, {
306+ let lastPlanetPatp = null;
328− color: colors.DGREY,
307+ planets.forEach((planet, pi) => {
308+ const pPatp = planet.patp;
309+ const [planetX, planetY] = planetCoords[pi].coords;
310+ const arm = planetCoords[pi].arm;
311+ const planetSize = Math.sqrt(Math.min(minPlanetDistance, minDistanceBetweenPlanets)) / 1300;
329− size: planetEdgeSize,
312+ const planetEdgeSize = planetSize / 3;
313+ const itsYou = pPatp === '~' + window.ship;
314+ if (itsYou) {
315+ g.setNodeAttribute(sPatp, 'color', colors.YOUR_STAR);
316+ g.setNodeAttribute(gPatp, 'color', colors.YOUR_GAL);
317+ }
318+ try {
319+ g.addNode(pPatp, {
320+ label: pPatp,
321+ size: planetSize,
322+ color: itsYou ? colors.YOU : (planet.dominion == 'l2' ? colors.GREEN : colors.BLUE),
323+ x: planetX,
324+ y: planetY,
330− zIndex: 5,
325+ zIndex: 6,
331 });
326 });
332− } else {
327+ if (lastPlanetArm == arm) {
333− if (numPlanetArms == 1) {
334− g.addEdge(pPatp, sPatp, {
328+ g.addEdge(pPatp, lastPlanetPatp, {
335 color: colors.DGREY,
329 color: colors.DGREY,
336 size: planetEdgeSize,
330 size: planetEdgeSize,
337 zIndex: 5,
331 zIndex: 5,
338 });
332 });
333+ } else {
334+ if (numPlanetArms == 1) {
335+ g.addEdge(pPatp, sPatp, {
336+ color: colors.DGREY,
337+ size: planetEdgeSize,
338+ zIndex: 5,
339+ });
340+ }
339 }
341 }
342+ if (planet.sponsor) {
343+ sponsorEdges.push([pPatp, planet.sponsor, {
344+ color: colors.GREEN,
345+ size: planetEdgeSize,
346+ zIndex: 11,
347+ }]);
348+ }
349+ lastPlanetArm = arm;
350+ lastPlanetPatp = pPatp;
351+ } catch (e) {
352+ let msg = `Couldn't add ${pPatp} to the graph`;
353+ console.error(msg, e);
354+ alertMe(msg + '\n' + e.message);
340 }
355 }
341− if (planet.sponsor) {
342− sponsorEdges.push([pPatp, planet.sponsor, {
343− color: colors.GREEN,
344− size: planetEdgeSize,
345− zIndex: 11,
346− }]);
356+ });
347− }
348− } catch (e) {
357+ } catch (e) {
349− console.error(`Couldn't add ${pPatp} to the graph`, e);
358+ let msg = `Couldn't add ${sPatp} to the graph`;
350− }
359+ console.error(msg, e);
351− lastPlanetArm = arm;
360+ alertMe(msg + '\n' + e.message);
352− lastPlanetPatp = pPatp;
353− });
361+ }
354 });
362 });
355 });
363 });
356 sponsorEdges.forEach(([point, sponsor, attrs]) => {
364 sponsorEdges.forEach(([point, sponsor, attrs]) => {
@@ -361,3 +369,7 @@ export function populateGraph(g: Graph, chartData: ChartPoint[], bySponsor: bool
361 }
369 }
362 return g;
370 return g;
363}
371}
372+
373+function alertMe(msg: string) {
374+ alert('Encountered an error, please tell ~midlev-mindyr: ' + msg);
375+}