mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-01 11:33:41 +03:00
Merge branch 'release/next-js' into release/next-userspace
This commit is contained in:
commit
5f24254793
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:9812a52d34be0d6d47ca60b23d3386e7db296ff61fac7c4b1f33a35806f8cb7c
|
||||
size 9751012
|
||||
oid sha256:ec80a42446a1d80974f32bf87283435547441cb7ea3fcd340711df2ce6cbec81
|
||||
size 9146390
|
||||
|
@ -5,7 +5,7 @@
|
||||
/- glob
|
||||
/+ default-agent, verb, dbug
|
||||
|%
|
||||
++ hash 0v9flom.311gv.90jce.591n4.d09bf
|
||||
++ hash 0v8buag.lcoib.dupqj.iprqk.spvqf
|
||||
+$ state-0 [%0 hash=@uv glob=(unit (each glob:glob tid=@ta))]
|
||||
+$ all-states
|
||||
$% state-0
|
||||
|
@ -1,5 +1,5 @@
|
||||
/- *settings
|
||||
/+ verb, dbug, default-agent
|
||||
/+ verb, dbug, default-agent, agentio
|
||||
|%
|
||||
+$ card card:agent:gall
|
||||
+$ versioned-state
|
||||
@ -20,10 +20,14 @@
|
||||
+* this .
|
||||
do ~(. +> bol)
|
||||
def ~(. (default-agent this %|) bol)
|
||||
io ~(. agentio bol)
|
||||
::
|
||||
++ on-init
|
||||
^- (quip card _this)
|
||||
`this
|
||||
=^ cards state
|
||||
(put-entry:do %tutorial %seen b+|)
|
||||
[cards this]
|
||||
|
||||
::
|
||||
++ on-save !>(state)
|
||||
::
|
||||
|
@ -21,7 +21,7 @@
|
||||
|^ :- %kiln-merge
|
||||
^- $@(~ [syd=desk her=ship sud=desk cas=case gem=?(germ %auto)])
|
||||
?- arg
|
||||
~ ((slog (turn help-text |=(=@t leaf+(trip t)))) ~)
|
||||
~ ((slog (turn `wain`help-text |=(=@t leaf+(trip t)))) ~)
|
||||
[@ @ ~]
|
||||
=+(arg [sud ?.(=(our her) her (sein:title p.bek now her)) sud (opt-case da+now) gem])
|
||||
::
|
||||
|
15
pkg/arvo/lib/gcp.hoon
Normal file
15
pkg/arvo/lib/gcp.hoon
Normal file
@ -0,0 +1,15 @@
|
||||
/- *gcp
|
||||
|%
|
||||
++ token-to-json
|
||||
|= =token
|
||||
^- json
|
||||
=, enjs:format
|
||||
%+ frond %gcp-token
|
||||
%: pairs
|
||||
[%'accessKey' s+access-key.token]
|
||||
:- %'expiresIn'
|
||||
%- numb
|
||||
(div (mul 1.000 expires-in.token) ~s1)
|
||||
~
|
||||
==
|
||||
--
|
@ -354,7 +354,7 @@
|
||||
[%| p.res]
|
||||
:- %&
|
||||
~? > debug %parsed-good
|
||||
((cury tab-list-hoon sut) hoon.p.res)
|
||||
((cury tab-list-hoon sut) hoon:`pile:clay`p.res)
|
||||
::
|
||||
:: Generators
|
||||
++ tab-generators
|
||||
|
@ -5,75 +5,59 @@
|
||||
++ pile-rule
|
||||
|= pax=path
|
||||
%- full
|
||||
%+ ifix [gay gay]
|
||||
%+ cook |=(pile +<)
|
||||
;~ pfix
|
||||
%+ ifix
|
||||
:_ gay
|
||||
:: parse optional /? and ignore
|
||||
::
|
||||
;~ pose
|
||||
(cold ~ ;~(plug fas wut gap dem gap))
|
||||
(easy ~)
|
||||
;~(plug gay (punt ;~(plug fas wut gap dem gap)))
|
||||
|^
|
||||
;~ plug
|
||||
%+ cook (bake zing (list (list taut)))
|
||||
%+ rune hep
|
||||
(most ;~(plug com gaw) taut-rule)
|
||||
::
|
||||
%+ cook (bake zing (list (list taut)))
|
||||
%+ rune lus
|
||||
(most ;~(plug com gaw) taut-rule)
|
||||
::
|
||||
%+ rune tis
|
||||
;~(plug sym ;~(pfix gap fas (more fas urs:ab)))
|
||||
::
|
||||
%+ rune cen
|
||||
;~(plug sym ;~(pfix gap ;~(pfix cen sym)))
|
||||
::
|
||||
%+ rune buc
|
||||
;~ (glue gap)
|
||||
sym
|
||||
;~(pfix cen sym)
|
||||
;~(pfix cen sym)
|
||||
==
|
||||
::
|
||||
;~ plug
|
||||
;~ pose
|
||||
;~ sfix
|
||||
%+ cook |=((list (list taut)) (zing +<))
|
||||
%+ more gap
|
||||
;~ pfix ;~(plug fas hep gap)
|
||||
(most ;~(plug com gaw) taut-rule)
|
||||
==
|
||||
gap
|
||||
==
|
||||
(easy ~)
|
||||
==
|
||||
::
|
||||
;~ pose
|
||||
;~ sfix
|
||||
%+ cook |=((list (list taut)) (zing +<))
|
||||
%+ more gap
|
||||
;~ pfix ;~(plug fas lus gap)
|
||||
(most ;~(plug com gaw) taut-rule)
|
||||
==
|
||||
gap
|
||||
==
|
||||
(easy ~)
|
||||
==
|
||||
::
|
||||
;~ pose
|
||||
;~ sfix
|
||||
%+ cook |=((list [face=term =path]) +<)
|
||||
%+ more gap
|
||||
;~ pfix ;~(plug fas tis gap)
|
||||
%+ cook |=([term path] +<)
|
||||
;~(plug sym ;~(pfix ;~(plug gap fas) (more fas urs:ab)))
|
||||
==
|
||||
gap
|
||||
==
|
||||
(easy ~)
|
||||
==
|
||||
::
|
||||
;~ pose
|
||||
;~ sfix
|
||||
%+ cook |=((list [face=term =mark =path]) +<)
|
||||
%+ more gap
|
||||
;~ pfix ;~(plug fas tar gap)
|
||||
%+ cook |=([term mark path] +<)
|
||||
;~ plug
|
||||
sym
|
||||
;~(pfix ;~(plug gap cen) sym)
|
||||
;~(pfix ;~(plug gap fas) (more fas urs:ab))
|
||||
==
|
||||
==
|
||||
gap
|
||||
==
|
||||
(easy ~)
|
||||
==
|
||||
::
|
||||
%+ cook |=(huz=(list hoon) `hoon`tssg+huz)
|
||||
(most gap tall:(vang & pax))
|
||||
%+ rune tar
|
||||
;~ (glue gap)
|
||||
sym
|
||||
;~(pfix cen sym)
|
||||
;~(pfix fas (more fas urs:ab))
|
||||
==
|
||||
::
|
||||
%+ stag %tssg
|
||||
(most gap tall:(vang & pax))
|
||||
==
|
||||
::
|
||||
++ pant
|
||||
|* fel=^rule
|
||||
;~(pose fel (easy ~))
|
||||
::
|
||||
++ mast
|
||||
|* [bus=^rule fel=^rule]
|
||||
;~(sfix (more bus fel) bus)
|
||||
::
|
||||
++ rune
|
||||
|* [bus=^rule fel=^rule]
|
||||
%- pant
|
||||
%+ mast gap
|
||||
;~(pfix fas bus gap fel)
|
||||
--
|
||||
::
|
||||
++ taut-rule
|
||||
%+ cook |=(taut +<)
|
||||
|
@ -468,9 +468,9 @@
|
||||
(strand-fail %build-mark >arg< ~)
|
||||
?> =(%dais p.r.u.riot)
|
||||
(pure:m !<(dais:clay q.r.u.riot))
|
||||
:: +build-cast: build a mark conversion gate ($tube)
|
||||
:: +build-tube: build a mark conversion gate ($tube)
|
||||
::
|
||||
++ build-cast
|
||||
++ build-tube
|
||||
|= [[=ship =desk =case] =mars:clay]
|
||||
=* arg +<
|
||||
=/ m (strand ,tube:clay)
|
||||
@ -478,10 +478,37 @@
|
||||
;< =riot:clay bind:m
|
||||
(warp ship desk ~ %sing %c case /[a.mars]/[b.mars])
|
||||
?~ riot
|
||||
(strand-fail %build-cast >arg< ~)
|
||||
(strand-fail %build-tube >arg< ~)
|
||||
?> =(%tube p.r.u.riot)
|
||||
(pure:m !<(tube:clay q.r.u.riot))
|
||||
::
|
||||
:: +build-nave: build a mark definition to a $nave
|
||||
::
|
||||
++ build-nave
|
||||
|= [[=ship =desk =case] mak=mark]
|
||||
=* arg +<
|
||||
=/ m (strand ,vase)
|
||||
^- form:m
|
||||
;< =riot:clay bind:m
|
||||
(warp ship desk ~ %sing %b case /[mak])
|
||||
?~ riot
|
||||
(strand-fail %build-nave >arg< ~)
|
||||
?> =(%nave p.r.u.riot)
|
||||
(pure:m q.r.u.riot)
|
||||
:: +build-cast: build a mark conversion gate (static)
|
||||
::
|
||||
++ build-cast
|
||||
|= [[=ship =desk =case] =mars:clay]
|
||||
=* arg +<
|
||||
=/ m (strand ,vase)
|
||||
^- form:m
|
||||
;< =riot:clay bind:m
|
||||
(warp ship desk ~ %sing %f case /[a.mars]/[b.mars])
|
||||
?~ riot
|
||||
(strand-fail %build-cast >arg< ~)
|
||||
?> =(%cast p.r.u.riot)
|
||||
(pure:m q.r.u.riot)
|
||||
::
|
||||
:: Read from Clay
|
||||
::
|
||||
++ warp
|
||||
|
@ -11,6 +11,6 @@
|
||||
--
|
||||
++ grab :: convert from
|
||||
|%
|
||||
++ noun [path @] :: clam from %noun
|
||||
+$ noun [path @] :: clam from %noun
|
||||
--
|
||||
--
|
||||
|
@ -6,7 +6,7 @@
|
||||
=, html
|
||||
|_ own=manx
|
||||
::
|
||||
++ grad %mime
|
||||
++ grad %noun
|
||||
++ grow :: convert to
|
||||
|%
|
||||
++ hymn ;html:(head body:"+{own}") :: convert to %hymn
|
||||
|
13
pkg/arvo/mar/gcp-token.hoon
Normal file
13
pkg/arvo/mar/gcp-token.hoon
Normal file
@ -0,0 +1,13 @@
|
||||
/+ *gcp
|
||||
|_ tok=token
|
||||
++ grad %noun
|
||||
++ grow
|
||||
|%
|
||||
++ noun tok
|
||||
++ json (token-to-json tok)
|
||||
--
|
||||
++ grab
|
||||
|%
|
||||
++ noun token
|
||||
--
|
||||
--
|
@ -6,7 +6,7 @@
|
||||
=, format
|
||||
|_ txt=cord
|
||||
::
|
||||
++ grad %mime
|
||||
++ grad %noun
|
||||
++ grab :: convert from
|
||||
|%
|
||||
++ noun @t :: clam from %noun
|
||||
|
@ -6,7 +6,6 @@
|
||||
:::: compute
|
||||
::
|
||||
=, html
|
||||
^|
|
||||
|_ htm=@t
|
||||
++ grow :: convert to
|
||||
^?
|
||||
|
@ -6,7 +6,7 @@
|
||||
=, html
|
||||
|_ own=manx
|
||||
::
|
||||
++ grad %mime
|
||||
++ grad %noun
|
||||
++ grow :: convert to
|
||||
|%
|
||||
++ html (crip (en-xml own)) :: convert to %html
|
||||
|
@ -4,7 +4,7 @@
|
||||
++ grad %noun
|
||||
++ grab
|
||||
|%
|
||||
++ noun not
|
||||
++ noun all:notification
|
||||
++ json
|
||||
|= jon=^json
|
||||
(notification:dejs:lsp-json jon)
|
||||
|
@ -8,7 +8,7 @@
|
||||
--
|
||||
++ grab
|
||||
|%
|
||||
++ noun req
|
||||
++ noun all:request
|
||||
++ json
|
||||
|= jon=^json
|
||||
(request:dejs:lsp-json jon)
|
||||
|
@ -3,7 +3,6 @@
|
||||
::
|
||||
/? 310
|
||||
::
|
||||
^|
|
||||
|_ own=mime
|
||||
++ grow
|
||||
^?
|
||||
@ -14,7 +13,7 @@
|
||||
++ grab :: convert from
|
||||
^?
|
||||
|%
|
||||
+$ noun mime :: clam from %noun
|
||||
++ noun mime :: clam from %noun
|
||||
++ tape
|
||||
|=(a=_"" [/application/x-urb-unknown (as-octt:mimes:html a)])
|
||||
--
|
||||
@ -25,5 +24,9 @@
|
||||
++ diff |=(mime +<)
|
||||
++ pact |=(mime +<)
|
||||
++ join |=([mime mime] `(unit mime)`~)
|
||||
++ mash
|
||||
|= [[ship desk mime] [ship desk mime]]
|
||||
^- mime
|
||||
~|(%mime-mash !!)
|
||||
--
|
||||
--
|
||||
|
@ -14,5 +14,6 @@
|
||||
++ diff |=(* +<)
|
||||
++ pact |=(* +<)
|
||||
++ join |=([* *] *(unit *))
|
||||
++ mash |=([[ship desk *] [ship desk *]] `*`~|(%noun-mash !!))
|
||||
--
|
||||
--
|
||||
|
@ -15,7 +15,7 @@
|
||||
++ mime
|
||||
|= (pair mite octs)
|
||||
=+ o=(pair ,* ,*) :: ,*)
|
||||
=+ (,[boot-ova=* kernel-ova=(list o) userspace-ova=(list o)] (cue q.q))
|
||||
=+ (,[%pill nam=term boot-ova=(list) kernel-ova=(list o) userspace-ova=(list o)] (cue q.q))
|
||||
=/ convert
|
||||
|= ova=(list o)
|
||||
^- (list unix-event)
|
||||
@ -30,7 +30,7 @@
|
||||
:: =/ boot-ova (convert boot-ova)
|
||||
=/ kernel-ova (convert kernel-ova)
|
||||
=/ userspace-ova (convert userspace-ova)
|
||||
[boot-ova kernel-ova userspace-ova]
|
||||
[%pill nam boot-ova kernel-ova userspace-ova]
|
||||
--
|
||||
++ grad %mime
|
||||
--
|
||||
|
@ -43,7 +43,7 @@
|
||||
::
|
||||
=, mimes:html
|
||||
|_ [hed=marl tal=marl]
|
||||
++ grad %mime
|
||||
++ grad %noun
|
||||
::
|
||||
++ grow :: convert to
|
||||
|%
|
||||
@ -55,6 +55,7 @@
|
||||
++ html (crip (en-xml hymn)) :: convert to %html
|
||||
++ mime [/text/html (as-octs html)] :: convert to %mime
|
||||
--
|
||||
++ noun [hed tal]
|
||||
--
|
||||
++ grab |% :: convert from
|
||||
++ noun ,[marl marl] :: clam from %noun
|
||||
|
@ -6,7 +6,7 @@
|
||||
=, html
|
||||
|_ own=manx
|
||||
::
|
||||
++ grad %mime
|
||||
++ grad %noun
|
||||
++ grow :: convert to
|
||||
|%
|
||||
++ hymn ;html:(head body:"+{own}") :: convert to %hymn
|
||||
|
6
pkg/arvo/sur/gcp.hoon
Normal file
6
pkg/arvo/sur/gcp.hoon
Normal file
@ -0,0 +1,6 @@
|
||||
|%
|
||||
+$ token
|
||||
$: access-key=@t
|
||||
expires-in=@dr
|
||||
==
|
||||
--
|
@ -796,7 +796,7 @@
|
||||
$: face=(unit term)
|
||||
file-path=term
|
||||
==
|
||||
+$ care ?(%a %b %c %d %p %r %s %t %u %v %w %x %y %z) :: clay submode
|
||||
+$ care ?(%a %b %c %d %e %f %p %r %s %t %u %v %w %x %y %z) :: clay submode
|
||||
+$ case :: ship desk case spur
|
||||
$% [%da p=@da] :: date
|
||||
[%tas p=@tas] :: label
|
||||
@ -928,12 +928,16 @@
|
||||
:: /- sur-file :: surface imports from /sur
|
||||
:: /+ lib-file :: library imports from /lib
|
||||
:: /= face /path :: imports built hoon file at path
|
||||
:: /% face %mark :: imports mark definition from /mar
|
||||
:: /$ face %from %to :: imports mark converter from /mar
|
||||
:: /* face %mark /path :: unbuilt file imports, as mark
|
||||
::
|
||||
+$ pile
|
||||
$: sur=(list taut)
|
||||
lib=(list taut)
|
||||
raw=(list [face=term =path])
|
||||
maz=(list [face=term =mark])
|
||||
caz=(list [face=term =mars])
|
||||
bar=(list [face=term =mark =path])
|
||||
=hoon
|
||||
==
|
||||
@ -942,9 +946,25 @@
|
||||
+$ taut [face=(unit term) pax=term]
|
||||
:: $mars: mark conversion request
|
||||
:: $tube: mark conversion gate
|
||||
:: $nave: typed mark core
|
||||
::
|
||||
+$ mars [a=mark b=mark]
|
||||
+$ tube $-(vase vase)
|
||||
++ nave
|
||||
|$ [typ dif]
|
||||
$_
|
||||
^?
|
||||
|%
|
||||
++ bunt *typ
|
||||
++ diff |~([old=typ new=typ] *dif)
|
||||
++ form *mark
|
||||
++ join |~([a=dif b=dif] *(unit (unit dif)))
|
||||
++ mash
|
||||
|~ [a=[ship desk dif] b=[ship desk dif]]
|
||||
*(unit dif)
|
||||
++ pact |~([typ dif] *typ)
|
||||
++ vale |~(noun *typ)
|
||||
--
|
||||
:: $dais: processed mark core
|
||||
::
|
||||
+$ dais
|
||||
@ -959,7 +979,6 @@
|
||||
*(unit vase)
|
||||
++ pact |~(diff=vase sam)
|
||||
++ vale |~(noun sam)
|
||||
++ volt |~(noun sam)
|
||||
--
|
||||
::
|
||||
++ get-fit
|
||||
|
@ -829,7 +829,7 @@
|
||||
:: lifecycle arms; mostly pass-throughs to the contained adult ames
|
||||
::
|
||||
++ scry scry:adult-core
|
||||
++ stay [%4 %larva queued-events ames-state.adult-gate]
|
||||
++ stay [%5 %larva queued-events ames-state.adult-gate]
|
||||
++ load
|
||||
|= $= old
|
||||
$% $: %4
|
||||
@ -839,6 +839,13 @@
|
||||
==
|
||||
[%adult state=_ames-state.adult-gate]
|
||||
== ==
|
||||
$: %5
|
||||
$% $: %larva
|
||||
events=(qeu queued-event)
|
||||
state=_ames-state.adult-gate
|
||||
==
|
||||
[%adult state=_ames-state.adult-gate]
|
||||
== ==
|
||||
==
|
||||
?- old
|
||||
[%4 %adult *] (load:adult-core %4 state.old)
|
||||
@ -848,6 +855,14 @@
|
||||
=. queued-events events.old
|
||||
=. adult-gate (load:adult-core %4 state.old)
|
||||
larval-gate
|
||||
::
|
||||
[%5 %adult *] (load:adult-core %5 state.old)
|
||||
::
|
||||
[%5 %larva *]
|
||||
~> %slog.1^leaf/"ames: larva: load"
|
||||
=. queued-events events.old
|
||||
=. adult-gate (load:adult-core %5 state.old)
|
||||
larval-gate
|
||||
==
|
||||
--
|
||||
:: adult ames, after metamorphosis from larva
|
||||
@ -919,13 +934,38 @@
|
||||
[moves ames-gate]
|
||||
:: +stay: extract state before reload
|
||||
::
|
||||
++ stay [%4 %adult ames-state]
|
||||
++ stay [%5 %adult ames-state]
|
||||
:: +load: load in old state after reload
|
||||
::
|
||||
++ load
|
||||
|= old-state=[%4 ^ames-state]
|
||||
|= $= old-state
|
||||
$% [%4 ^ames-state]
|
||||
[%5 ^ames-state]
|
||||
==
|
||||
|^
|
||||
^+ ames-gate
|
||||
=? old-state ?=(%4 -.old-state) %5^(state-4-to-5 +.old-state)
|
||||
::
|
||||
?> ?=(%5 -.old-state)
|
||||
ames-gate(ames-state +.old-state)
|
||||
::
|
||||
++ state-4-to-5
|
||||
|= =^ames-state
|
||||
^- ^^ames-state
|
||||
=. peers.ames-state
|
||||
%- ~(run by peers.ames-state)
|
||||
|= =ship-state
|
||||
?. ?=(%known -.ship-state)
|
||||
ship-state
|
||||
=. snd.ship-state
|
||||
%- ~(run by snd.ship-state)
|
||||
|= =message-pump-state
|
||||
=. num-live.metrics.packet-pump-state.message-pump-state
|
||||
~(wyt in live.packet-pump-state.message-pump-state)
|
||||
message-pump-state
|
||||
ship-state
|
||||
ames-state
|
||||
--
|
||||
:: +scry: dereference namespace
|
||||
::
|
||||
++ scry
|
||||
@ -1904,6 +1944,11 @@
|
||||
=/ =bone bone.shut-packet
|
||||
::
|
||||
?: ?=(%& -.meat.shut-packet)
|
||||
=+ ?~ dud ~
|
||||
%. ~
|
||||
%+ slog
|
||||
leaf+"ames: {<her.channel>} fragment crashed {<mote.u.dud>}"
|
||||
?.(msg.veb ~ tang.u.dud)
|
||||
(run-message-sink bone %hear lane shut-packet ?=(~ dud))
|
||||
:: Just try again on error, printing trace
|
||||
::
|
||||
@ -1912,7 +1957,10 @@
|
||||
::
|
||||
=+ ?~ dud ~
|
||||
%. ~
|
||||
(slog leaf+"ames: crashed on message ack" >mote.u.dud< tang.u.dud)
|
||||
%+ slog leaf+"ames: {<her.channel>} ack crashed {<mote.u.dud>}"
|
||||
?. msg.veb ~
|
||||
:- >[bone=bone message-num=message-num meat=meat]:shut-packet<
|
||||
tang.u.dud
|
||||
(run-message-pump bone %hear [message-num +.meat]:shut-packet)
|
||||
:: +on-memo: handle request to send message
|
||||
::
|
||||
@ -2198,12 +2246,15 @@
|
||||
?. ?=([%hear * * ok=%.n] task)
|
||||
:: fresh boon; give message to client vane
|
||||
::
|
||||
%- (trace msg.veb |.("boon {<her.channel^bone=bone -.task>}"))
|
||||
%- %+ trace msg.veb
|
||||
=/ dat [her.channel bone=bone message-num=message-num -.task]
|
||||
|.("sink boon {<dat>}")
|
||||
peer-core
|
||||
:: we previously crashed on this message; notify client vane
|
||||
::
|
||||
%- %+ trace msg.veb
|
||||
|.("crashed on boon {<her.channel^bone=bone -.task>}")
|
||||
=/ dat [her.channel bone=bone message-num=message-num -.task]
|
||||
|.("crashed on sink boon {<dat>}")
|
||||
boon-to-lost
|
||||
:: +boon-to-lost: convert all boons to losts
|
||||
::
|
||||
@ -2221,7 +2272,9 @@
|
||||
++ on-sink-nack-trace
|
||||
|= [=message-num message=*]
|
||||
^+ peer-core
|
||||
%- (trace msg.veb |.("nack trace {<her.channel^bone=bone>}"))
|
||||
%- %+ trace msg.veb
|
||||
=/ dat [her.channel bone=bone message-num=message-num]
|
||||
|.("sink naxplanation {<dat>}")
|
||||
::
|
||||
=+ ;; =naxplanation message
|
||||
:: ack nack-trace message (only applied if we don't later crash)
|
||||
@ -2238,7 +2291,9 @@
|
||||
++ on-sink-plea
|
||||
|= [=message-num message=*]
|
||||
^+ peer-core
|
||||
%- (trace msg.veb |.("plea {<her.channel^bone=bone>}"))
|
||||
%- %+ trace msg.veb
|
||||
=/ dat [her.channel bone=bone message-num=message-num]
|
||||
|.("sink plea {<dat>}")
|
||||
:: is this the first time we're trying to process this message?
|
||||
::
|
||||
?. ?=([%hear * * ok=%.n] task)
|
||||
|
@ -118,9 +118,11 @@
|
||||
:: Ford cache
|
||||
::
|
||||
+$ ford-cache
|
||||
$: vases=(map path [res=vase dez=(set path)])
|
||||
$: files=(map path [res=vase dez=(set path)])
|
||||
naves=(map mark [res=vase dez=(set path)])
|
||||
marks=(map mark [res=dais dez=(set path)])
|
||||
casts=(map mars [res=tube dez=(set path)])
|
||||
casts=(map mars [res=vase dez=(set path)])
|
||||
tubes=(map mars [res=tube dez=(set path)])
|
||||
==
|
||||
:: $reef-cache: built system files
|
||||
::
|
||||
@ -462,7 +464,9 @@
|
||||
+$ build
|
||||
$% [%file =path]
|
||||
[%mark =mark]
|
||||
[%dais =mark]
|
||||
[%cast =mars]
|
||||
[%tube =mars]
|
||||
[%vale =path]
|
||||
==
|
||||
+$ state
|
||||
@ -494,8 +498,9 @@
|
||||
=? stack.nub ?=(^ stack.nub)
|
||||
stack.nub(i (~(uni in i.stack.nub) top))
|
||||
[top stack.nub]
|
||||
:: +read-file: retrieve marked, validated file contents at path
|
||||
::
|
||||
++ get-value
|
||||
++ read-file
|
||||
|= =path
|
||||
^- [cage state]
|
||||
~| %error-validating^path
|
||||
@ -519,13 +524,13 @@
|
||||
?< (~(has in deletes) path)
|
||||
~| %file-not-found^path
|
||||
:_(nub (need (~(get an ankh) path)))
|
||||
:: +get-mark: build a mark definition
|
||||
:: +build-nave: build a statically typed mark core
|
||||
::
|
||||
++ get-mark
|
||||
++ build-nave
|
||||
|= mak=mark
|
||||
^- [dais state]
|
||||
^- [vase state]
|
||||
~| %error-building-mark^mak
|
||||
?^ got=(~(get by marks.cache.nub) mak)
|
||||
?^ got=(~(get by naves.cache.nub) mak)
|
||||
=? stack.nub ?=(^ stack.nub)
|
||||
stack.nub(i (~(uni in i.stack.nub) dez.u.got))
|
||||
[res.u.got nub]
|
||||
@ -533,99 +538,128 @@
|
||||
~|(cycle+mark+mak^stack.nub !!)
|
||||
=. cycle.nub (~(put in cycle.nub) mark+mak)
|
||||
=. stack.nub [~ stack.nub]
|
||||
=; res=[=vase nub=state]
|
||||
=. nub nub.res
|
||||
=^ top stack.nub pop-stack
|
||||
=. naves.cache.nub (~(put by naves.cache.nub) mak [vase.res top])
|
||||
[vase.res nub]
|
||||
=^ cor=vase nub (build-fit %mar mak)
|
||||
=/ gad=vase (slap cor limb/%grad)
|
||||
?@ q.gad
|
||||
=+ !<(mok=mark gad)
|
||||
=^ deg=vase nub $(mak mok)
|
||||
=^ tub=vase nub (build-cast mak mok)
|
||||
=^ but=vase nub (build-cast mok mak)
|
||||
:_ nub
|
||||
^- vase :: vase of nave
|
||||
%+ slap
|
||||
(with-faces deg+deg tub+tub but+but cor+cor nave+!>(nave) ~)
|
||||
!, *hoon
|
||||
=/ typ _+<.cor
|
||||
=/ dif diff:deg
|
||||
^- (nave typ dif)
|
||||
|%
|
||||
++ bunt +<.cor
|
||||
++ diff
|
||||
|= [old=typ new=typ]
|
||||
^- dif
|
||||
(diff:deg (tub old) (tub new))
|
||||
++ form form:deg
|
||||
++ join join:deg
|
||||
++ mash mash:deg
|
||||
++ pact
|
||||
|= [v=typ d=dif]
|
||||
^- typ
|
||||
(but (pact:deg (tub v) d))
|
||||
++ vale noun:grab:cor
|
||||
--
|
||||
:_ nub
|
||||
^- vase :: vase of nave
|
||||
%+ slap (slop (with-face cor+cor) bud)
|
||||
!, *hoon
|
||||
=/ typ _+<.cor
|
||||
=/ dif _*diff:grad:cor
|
||||
^- (nave:clay typ dif)
|
||||
|%
|
||||
++ bunt +<.cor
|
||||
++ diff |=([old=typ new=typ] (diff:~(grad cor old) new))
|
||||
++ form form:grad:cor
|
||||
++ join
|
||||
|= [a=dif b=dif]
|
||||
^- (unit (unit dif))
|
||||
?: =(a b)
|
||||
~
|
||||
`(join:grad:cor a b)
|
||||
++ mash
|
||||
|= [a=[=ship =desk =dif] b=[=ship =desk =dif]]
|
||||
^- (unit dif)
|
||||
?: =(dif.a dif.b)
|
||||
~
|
||||
`(mash:grad:cor a b)
|
||||
++ pact |=([v=typ d=dif] (pact:~(grad cor v) d))
|
||||
++ vale noun:grab:cor
|
||||
--
|
||||
:: +build-dais: build a dynamically typed mark definition
|
||||
::
|
||||
++ build-dais
|
||||
|= mak=mark
|
||||
^- [dais state]
|
||||
~| %error-building-dais^mak
|
||||
?^ got=(~(get by marks.cache.nub) mak)
|
||||
=? stack.nub ?=(^ stack.nub)
|
||||
stack.nub(i (~(uni in i.stack.nub) dez.u.got))
|
||||
[res.u.got nub]
|
||||
?: (~(has in cycle.nub) dais+mak)
|
||||
~|(cycle+dais+mak^stack.nub !!)
|
||||
=. cycle.nub (~(put in cycle.nub) dais+mak)
|
||||
=. stack.nub [~ stack.nub]
|
||||
=; res=[=dais nub=state]
|
||||
=. nub nub.res
|
||||
=^ top stack.nub pop-stack
|
||||
=. marks.cache.nub (~(put by marks.cache.nub) mak [dais.res top])
|
||||
[dais.res nub]
|
||||
=^ cor=vase nub (build-fit %mar mak)
|
||||
=/ gad=vase (slap cor %limb %grad)
|
||||
?@ q.gad
|
||||
=+ !<(mok=mark gad)
|
||||
=^ deg=dais nub $(mak mok)
|
||||
=^ tub=tube nub (get-cast mak mok)
|
||||
=^ but=tube nub (get-cast mok mak)
|
||||
:_ nub
|
||||
^- dais
|
||||
|_ sam=vase
|
||||
++ bunt (slap cor $+6)
|
||||
++ diff
|
||||
|= new=vase
|
||||
^- vase
|
||||
(~(diff deg (tub sam)) (tub new))
|
||||
++ form form:deg
|
||||
++ join join:deg
|
||||
++ mash mash:deg
|
||||
++ pact
|
||||
|= diff=vase
|
||||
^+ sam
|
||||
(but (~(pact deg (tub sam)) diff))
|
||||
++ vale
|
||||
|= =noun
|
||||
^+ sam
|
||||
(slam (slap cor !,(*hoon noun:grab)) !>(noun))
|
||||
++ volt
|
||||
|= =noun
|
||||
^+ sam
|
||||
[p:bunt noun]
|
||||
--
|
||||
=^ nav=vase nub (build-nave mak)
|
||||
:_ nub
|
||||
=+ !<(fom=mark (slap gad %limb %form))
|
||||
^- dais
|
||||
|_ sam=vase
|
||||
++ bunt (slap cor $+6)
|
||||
++ bunt (slap nav limb/%bunt)
|
||||
++ diff
|
||||
|= new=vase
|
||||
^- vase
|
||||
%+ slap
|
||||
(with-faces cor+cor sam+sam new+new ~)
|
||||
!, *hoon
|
||||
(diff:~(grad cor sam) new)
|
||||
++ form fom
|
||||
(slam (slap nav limb/%diff) (slop sam new))
|
||||
++ form !<(mark (slap nav limb/%form))
|
||||
++ join
|
||||
|= [a=vase b=vase]
|
||||
^- (unit (unit vase))
|
||||
?: =(q.a q.b)
|
||||
~
|
||||
=; res `?~(q.res ~ `(slap res !,(*hoon ?~(. !! u))))
|
||||
(slam (slap cor !,(*hoon join:grad)) (slop a b))
|
||||
=/ res=vase (slam (slap nav limb/%join) (slop a b))
|
||||
?~ q.res ~
|
||||
?~ +.q.res [~ ~]
|
||||
``(slap res !,(*hoon ?>(?=([~ ~ *] .) u.u)))
|
||||
++ mash
|
||||
|= [a=[=ship =desk diff=vase] b=[=ship =desk diff=vase]]
|
||||
^- (unit vase)
|
||||
?: =(q.diff.a q.diff.b)
|
||||
=/ res=vase
|
||||
%+ slam (slap nav limb/%mash)
|
||||
%+ slop
|
||||
:(slop !>(ship.a) !>(desk.a) diff.a)
|
||||
:(slop !>(ship.b) !>(desk.b) diff.b)
|
||||
?~ q.res
|
||||
~
|
||||
:- ~
|
||||
%+ slam (slap cor !,(*hoon mash:grad))
|
||||
%+ slop
|
||||
:(slop !>(ship.a) !>(desk.a) diff.a)
|
||||
:(slop !>(ship.b) !>(desk.b) diff.b)
|
||||
`(slap res !,(*hoon ?>((^ .) u)))
|
||||
++ pact
|
||||
|= diff=vase
|
||||
^+ sam
|
||||
%+ slap
|
||||
(with-faces cor+cor sam+sam diff+diff ~)
|
||||
!, *hoon
|
||||
(pact:~(grad cor sam) diff)
|
||||
(slam (slap nav limb/%pact) (slop sam diff))
|
||||
++ vale
|
||||
|= =noun
|
||||
^+ sam
|
||||
(slam (slap cor !,(*hoon noun:grab)) !>(noun))
|
||||
++ volt
|
||||
|= =noun
|
||||
^+ sam
|
||||
[p:bunt noun]
|
||||
(slam (slap nav limb/%vale) noun/noun)
|
||||
--
|
||||
:: +get-cast: produce a $tube mark conversion gate from .a to .b
|
||||
:: +build-cast: produce gate to convert mark .a to, statically typed
|
||||
::
|
||||
++ get-cast
|
||||
++ build-cast
|
||||
|= [a=mark b=mark]
|
||||
^- [tube state]
|
||||
^- [vase state]
|
||||
~| error-building-cast+[a b]
|
||||
?: =([%mime %hoon] [a b])
|
||||
:_ nub
|
||||
|= sam=vase
|
||||
=+ !<(=mime sam)
|
||||
!>(q.q.mime)
|
||||
:_(nub !>(|=(m=mime q.q.m)))
|
||||
?^ got=(~(get by casts.cache.nub) [a b])
|
||||
=? stack.nub ?=(^ stack.nub)
|
||||
stack.nub(i (~(uni in i.stack.nub) dez.u.got))
|
||||
@ -633,11 +667,11 @@
|
||||
?: (~(has in cycle.nub) cast+[a b])
|
||||
~|(cycle+cast+[a b]^stack.nub !!)
|
||||
=. stack.nub [~ stack.nub]
|
||||
=; res=[=tube nub=state]
|
||||
=; res=[=vase nub=state]
|
||||
=. nub nub.res
|
||||
=^ top stack.nub pop-stack
|
||||
=. casts.cache.nub (~(put by casts.cache.nub) [a b] [tube.res top])
|
||||
[tube.res nub]
|
||||
=. casts.cache.nub (~(put by casts.cache.nub) [a b] [vase.res top])
|
||||
[vase.res nub]
|
||||
:: try +grow; is there a +grow core with a .b arm?
|
||||
::
|
||||
=^ old=vase nub (build-fit %mar a)
|
||||
@ -649,47 +683,57 @@
|
||||
:: +grow core has .b arm; use that
|
||||
::
|
||||
:_ nub
|
||||
^- tube
|
||||
|= sam=vase
|
||||
^- vase
|
||||
%+ slap
|
||||
(with-faces old+old sam+sam ~)
|
||||
:+ %sgzp !,(*hoon old=old)
|
||||
:+ %sgzp !,(*hoon sam=sam)
|
||||
:+ %tsgl [%limb b]
|
||||
!, *hoon
|
||||
~(grow old sam)
|
||||
%+ slap (with-faces cor+old ~)
|
||||
^- hoon
|
||||
:+ %brcl !,(*hoon v=+<.cor)
|
||||
:+ %tsgl limb/b
|
||||
!,(*hoon ~(grow cor v))
|
||||
:: try direct +grab
|
||||
::
|
||||
=^ new=vase nub (build-fit %mar b)
|
||||
=/ rab
|
||||
%- mule |.
|
||||
%+ slap new
|
||||
:+ %tsgl [%limb a]
|
||||
[%limb %grab]
|
||||
=/ rab (mule |.((slap new tsgl/[limb/a limb/%grab])))
|
||||
?: &(?=(%& -.rab) ?=(^ q.p.rab))
|
||||
:_(nub |=(sam=vase ~|([%grab a b] (slam p.rab sam))))
|
||||
:_(nub p.rab)
|
||||
:: try +jump
|
||||
::
|
||||
=/ jum
|
||||
%- mule |.
|
||||
%+ slap old
|
||||
:+ %tsgl [%limb b]
|
||||
[%limb %jump]
|
||||
=/ jum (mule |.((slap old tsgl/[limb/b limb/%jump])))
|
||||
?: ?=(%& -.jum)
|
||||
(compose-casts a !<(mark p.jum) b)
|
||||
:: try indirect +grab
|
||||
::
|
||||
?: ?=(%& -.rab)
|
||||
(compose-casts a !<(mark p.rab) b)
|
||||
?: ?=(%noun b)
|
||||
:_(nub !>(|=(* +<)))
|
||||
~|(no-cast-from+[a b] !!)
|
||||
::
|
||||
++ compose-casts
|
||||
|= [x=mark y=mark z=mark]
|
||||
^- [vase state]
|
||||
=^ uno=vase nub (build-cast x y)
|
||||
=^ dos=vase nub (build-cast y z)
|
||||
:_ nub
|
||||
%+ slap
|
||||
(with-faces uno+uno dos+dos cork+!>(cork) ~)
|
||||
!,(*hoon (cork uno dos))
|
||||
:: +build-tube: produce a $tube mark conversion gate from .a to .b
|
||||
::
|
||||
++ build-tube
|
||||
|= [a=mark b=mark]
|
||||
^- [tube state]
|
||||
=^ uno=tube nub (get-cast x y)
|
||||
=^ dos=tube nub (get-cast y z)
|
||||
:_(nub |=(sam=vase (dos (uno sam))))
|
||||
~| error-building-tube+[a b]
|
||||
?^ got=(~(get by tubes.cache.nub) [a b])
|
||||
=? stack.nub ?=(^ stack.nub)
|
||||
stack.nub(i (~(uni in i.stack.nub) dez.u.got))
|
||||
[res.u.got nub]
|
||||
?: (~(has in cycle.nub) tube+[a b])
|
||||
~|(cycle+tube+[a b]^stack.nub !!)
|
||||
=. stack.nub [~ stack.nub]
|
||||
=; res=[=tube nub=state]
|
||||
=. nub nub.res
|
||||
=^ top stack.nub pop-stack
|
||||
=. tubes.cache.nub (~(put by tubes.cache.nub) [a b] [tube.res top])
|
||||
[tube.res nub]
|
||||
=^ gat=vase nub (build-cast a b)
|
||||
:_(nub |=(v=vase (slam gat v)))
|
||||
::
|
||||
++ lobe-to-page
|
||||
|= =lobe
|
||||
@ -713,7 +757,7 @@
|
||||
?: =(mak p.page)
|
||||
(page-to-cage page)
|
||||
=^ [mark vax=vase] nub (page-to-cage page)
|
||||
=^ =tube nub (get-cast p.page mak)
|
||||
=^ =tube nub (build-tube p.page mak)
|
||||
:_(nub [mak (tube vax)])
|
||||
::
|
||||
++ page-to-cage
|
||||
@ -723,7 +767,7 @@
|
||||
:_(nub [%hoon -:!>(*@t) q.page])
|
||||
?: =(%mime p.page)
|
||||
:_(nub [%mime !>(;;(mime q.page))])
|
||||
=^ =dais nub (get-mark p.page)
|
||||
=^ =dais nub (build-dais p.page)
|
||||
:_(nub [p.page (vale:dais q.page)])
|
||||
::
|
||||
++ cast-path
|
||||
@ -731,10 +775,10 @@
|
||||
^- [cage state]
|
||||
=/ mok (head (flop path))
|
||||
~| error-casting-path+[path mok mak]
|
||||
=^ cag=cage nub (get-value path)
|
||||
=^ cag=cage nub (read-file path)
|
||||
?: =(mok mak)
|
||||
[cag nub]
|
||||
=^ =tube nub (get-cast mok mak)
|
||||
=^ =tube nub (build-tube mok mak)
|
||||
~| error-running-cast+[path mok mak]
|
||||
:_(nub [mak (tube q.cag)])
|
||||
::
|
||||
@ -746,14 +790,14 @@
|
||||
=+ ;;(dif=(urge cord) q.diff)
|
||||
=/ new=@t (of-wain:format (lurk:differ txt dif))
|
||||
:_(nub [%hoon !>(new)])
|
||||
=^ dys=dais nub (get-mark p.old)
|
||||
=^ syd=dais nub (get-mark p.diff)
|
||||
=^ dys=dais nub (build-dais p.old)
|
||||
=^ syd=dais nub (build-dais p.diff)
|
||||
:_(nub [p.old (~(pact dys (vale:dys q.old)) (vale:syd q.diff))])
|
||||
::
|
||||
++ prelude
|
||||
|= =path
|
||||
^- vase
|
||||
=^ cag=cage nub (get-value path)
|
||||
=^ cag=cage nub (read-file path)
|
||||
?> =(%hoon p.cag)
|
||||
=/ tex=tape (trip !<(@t q.cag))
|
||||
=/ =pile (parse-pile path tex)
|
||||
@ -765,7 +809,7 @@
|
||||
|= =path
|
||||
^- [vase state]
|
||||
~| %error-building^path
|
||||
?^ got=(~(get by vases.cache.nub) path)
|
||||
?^ got=(~(get by files.cache.nub) path)
|
||||
=? stack.nub ?=(^ stack.nub)
|
||||
stack.nub(i (~(uni in i.stack.nub) dez.u.got))
|
||||
[res.u.got nub]
|
||||
@ -773,13 +817,13 @@
|
||||
~|(cycle+file+path^stack.nub !!)
|
||||
=. cycle.nub (~(put in cycle.nub) file+path)
|
||||
=. stack.nub [(sy path ~) stack.nub]
|
||||
=^ cag=cage nub (get-value path)
|
||||
=^ cag=cage nub (read-file path)
|
||||
?> =(%hoon p.cag)
|
||||
=/ tex=tape (trip !<(@t q.cag))
|
||||
=/ =pile (parse-pile path tex)
|
||||
=^ res=vase nub (run-pile pile)
|
||||
=^ top stack.nub pop-stack
|
||||
=. vases.cache.nub (~(put by vases.cache.nub) path [res top])
|
||||
=. files.cache.nub (~(put by files.cache.nub) path [res top])
|
||||
[res nub]
|
||||
::
|
||||
++ run-pile
|
||||
@ -787,6 +831,8 @@
|
||||
=^ sut=vase nub (run-tauts bud %sur sur.pile)
|
||||
=^ sut=vase nub (run-tauts sut %lib lib.pile)
|
||||
=^ sut=vase nub (run-raw sut raw.pile)
|
||||
=^ sut=vase nub (run-maz sut maz.pile)
|
||||
=^ sut=vase nub (run-caz sut caz.pile)
|
||||
=^ sut=vase nub (run-bar sut bar.pile)
|
||||
=/ res=vase (road |.((slap sut hoon.pile)))
|
||||
[res nub]
|
||||
@ -807,75 +853,59 @@
|
||||
++ pile-rule
|
||||
|= pax=path
|
||||
%- full
|
||||
%+ ifix [gay gay]
|
||||
%+ cook |=(pile +<)
|
||||
;~ pfix
|
||||
%+ ifix
|
||||
:_ gay
|
||||
:: parse optional /? and ignore
|
||||
::
|
||||
;~ pose
|
||||
(cold ~ ;~(plug fas wut gap dem gap))
|
||||
(easy ~)
|
||||
;~(plug gay (punt ;~(plug fas wut gap dem gap)))
|
||||
|^
|
||||
;~ plug
|
||||
%+ cook (bake zing (list (list taut)))
|
||||
%+ rune hep
|
||||
(most ;~(plug com gaw) taut-rule)
|
||||
::
|
||||
%+ cook (bake zing (list (list taut)))
|
||||
%+ rune lus
|
||||
(most ;~(plug com gaw) taut-rule)
|
||||
::
|
||||
%+ rune tis
|
||||
;~(plug sym ;~(pfix gap fas (more fas urs:ab)))
|
||||
::
|
||||
%+ rune cen
|
||||
;~(plug sym ;~(pfix gap ;~(pfix cen sym)))
|
||||
::
|
||||
%+ rune buc
|
||||
;~ (glue gap)
|
||||
sym
|
||||
;~(pfix cen sym)
|
||||
;~(pfix cen sym)
|
||||
==
|
||||
::
|
||||
;~ plug
|
||||
;~ pose
|
||||
;~ sfix
|
||||
%+ cook |=((list (list taut)) (zing +<))
|
||||
%+ more gap
|
||||
;~ pfix ;~(plug fas hep gap)
|
||||
(most ;~(plug com gaw) taut-rule)
|
||||
==
|
||||
gap
|
||||
==
|
||||
(easy ~)
|
||||
==
|
||||
::
|
||||
;~ pose
|
||||
;~ sfix
|
||||
%+ cook |=((list (list taut)) (zing +<))
|
||||
%+ more gap
|
||||
;~ pfix ;~(plug fas lus gap)
|
||||
(most ;~(plug com gaw) taut-rule)
|
||||
==
|
||||
gap
|
||||
==
|
||||
(easy ~)
|
||||
==
|
||||
::
|
||||
;~ pose
|
||||
;~ sfix
|
||||
%+ cook |=((list [face=term =path]) +<)
|
||||
%+ more gap
|
||||
;~ pfix ;~(plug fas tis gap)
|
||||
%+ cook |=([term path] +<)
|
||||
;~(plug sym ;~(pfix ;~(plug gap fas) (more fas urs:ab)))
|
||||
==
|
||||
gap
|
||||
==
|
||||
(easy ~)
|
||||
==
|
||||
::
|
||||
;~ pose
|
||||
;~ sfix
|
||||
%+ cook |=((list [face=term =mark =path]) +<)
|
||||
%+ more gap
|
||||
;~ pfix ;~(plug fas tar gap)
|
||||
%+ cook |=([term mark path] +<)
|
||||
;~ plug
|
||||
sym
|
||||
;~(pfix ;~(plug gap cen) sym)
|
||||
;~(pfix ;~(plug gap fas) (more fas urs:ab))
|
||||
==
|
||||
==
|
||||
gap
|
||||
==
|
||||
(easy ~)
|
||||
==
|
||||
::
|
||||
%+ cook |=(huz=(list hoon) `hoon`tssg+huz)
|
||||
(most gap tall:(vang & pax))
|
||||
%+ rune tar
|
||||
;~ (glue gap)
|
||||
sym
|
||||
;~(pfix cen sym)
|
||||
;~(pfix fas (more fas urs:ab))
|
||||
==
|
||||
::
|
||||
%+ stag %tssg
|
||||
(most gap tall:(vang & pax))
|
||||
==
|
||||
::
|
||||
++ pant
|
||||
|* fel=^rule
|
||||
;~(pose fel (easy ~))
|
||||
::
|
||||
++ mast
|
||||
|* [bus=^rule fel=^rule]
|
||||
;~(sfix (more bus fel) bus)
|
||||
::
|
||||
++ rune
|
||||
|* [bus=^rule fel=^rule]
|
||||
%- pant
|
||||
%+ mast gap
|
||||
;~(pfix fas bus gap fel)
|
||||
--
|
||||
::
|
||||
++ taut-rule
|
||||
%+ cook |=(taut +<)
|
||||
@ -901,6 +931,22 @@
|
||||
=. p.pin [%face face.i.raw p.pin]
|
||||
$(sut (slop pin sut), raw t.raw)
|
||||
::
|
||||
++ run-maz
|
||||
|= [sut=vase maz=(list [face=term =mark])]
|
||||
^- [vase state]
|
||||
?~ maz [sut nub]
|
||||
=^ pin=vase nub (build-nave mark.i.maz)
|
||||
=. p.pin [%face face.i.maz p.pin]
|
||||
$(sut (slop pin sut), maz t.maz)
|
||||
::
|
||||
++ run-caz
|
||||
|= [sut=vase caz=(list [face=term =mars])]
|
||||
^- [vase state]
|
||||
?~ caz [sut nub]
|
||||
=^ pin=vase nub (build-cast mars.i.caz)
|
||||
=. p.pin [%face face.i.caz p.pin]
|
||||
$(sut (slop pin sut), caz t.caz)
|
||||
::
|
||||
++ run-bar
|
||||
|= [sut=vase bar=(list [face=term =mark =path])]
|
||||
^- [vase state]
|
||||
@ -1527,9 +1573,11 @@
|
||||
%+ turn (tail (spud pux)) :: lose leading '/'
|
||||
|=(c=@tD `@tD`?:(=('/' c) '-' c)) :: convert '/' to '-'
|
||||
::
|
||||
:* ((invalidate path vase) vases.ford-cache invalid)
|
||||
:* ((invalidate path vase) files.ford-cache invalid)
|
||||
((invalidate mark vase) naves.ford-cache invalid)
|
||||
((invalidate mark dais) marks.ford-cache invalid)
|
||||
((invalidate mars tube) casts.ford-cache invalid)
|
||||
((invalidate mars vase) casts.ford-cache invalid)
|
||||
((invalidate mars tube) tubes.ford-cache invalid)
|
||||
==
|
||||
::
|
||||
++ invalidate
|
||||
@ -1640,24 +1688,26 @@
|
||||
::
|
||||
++ checkout-changes
|
||||
|= [=ford=args:ford:fusion changes=(map path (each page lobe))]
|
||||
=/ cans=(list [=path change=(each page lobe)]) ~(tap by changes)
|
||||
|- ^- [(map path [=lobe =cage]) ford-cache]
|
||||
?~ cans
|
||||
[~ ford-cache.ford-args]
|
||||
^- [(map path [=lobe =cage]) ford-cache]
|
||||
%+ roll `(list [path (each page lobe)])`~(tap by changes)
|
||||
|= $: [=path change=(each page lobe)]
|
||||
[built=(map path [lobe cage]) cache=_ford-cache.ford-args]
|
||||
==
|
||||
^+ [built cache]
|
||||
=. ford-cache.ford-args cache
|
||||
=^ cage ford-cache.ford-args
|
||||
:: ~> %slog.[0 leaf+"clay: validating {(spud path.i.cans)}"]
|
||||
:: ~> %slog.[0 leaf/"clay: validating {(spud path)}"]
|
||||
%- wrap:fusion
|
||||
(get-value:(ford:fusion ford-args) path.i.cans)
|
||||
(read-file:(ford:fusion ford-args) path)
|
||||
=/ =lobe
|
||||
?- -.change.i.cans
|
||||
%| p.change.i.cans
|
||||
?- -.change
|
||||
%| p.change
|
||||
:: Don't use p.change.i.cans because that's before casting to
|
||||
:: the correct mark.
|
||||
::
|
||||
%& (page-to-lobe [p q.q]:cage)
|
||||
==
|
||||
=^ so-far ford-cache.ford-args $(cans t.cans)
|
||||
[(~(put by so-far) path.i.cans lobe cage) ford-cache.ford-args]
|
||||
[(~(put by built) path [lobe cage]) ford-cache.ford-args]
|
||||
::
|
||||
:: Update ankh
|
||||
::
|
||||
@ -2235,7 +2285,7 @@
|
||||
^- dais
|
||||
=^ =dais fod.dom
|
||||
%- wrap:fusion
|
||||
(get-mark:(ford:fusion static-ford-args) mark)
|
||||
(build-dais:(ford:fusion static-ford-args) mark)
|
||||
dais
|
||||
::
|
||||
:: Diff two files on bob-desk
|
||||
@ -2665,6 +2715,8 @@
|
||||
%b ~| %i-guess-you-ought-to-build-your-own-marks !!
|
||||
%c ~| %casts-should-be-compiled-on-your-own-ship !!
|
||||
%d ~| %totally-temporary-error-please-replace-me !!
|
||||
%e ~| %yes-naves-also-shouldnt-cross-the-network !!
|
||||
%f ~| %even-static-casts-should-be-built-locally !!
|
||||
%p ~| %requesting-foreign-permissions-is-invalid !!
|
||||
%r ~| %no-cages-please-they-are-just-way-too-big !!
|
||||
%s ~| %please-dont-get-your-takos-over-a-network !!
|
||||
@ -3418,7 +3470,7 @@
|
||||
^- [(unit (unit (each cage lobe))) ford-cache]
|
||||
?. =(aeon let.dom)
|
||||
[~ fod.dom]
|
||||
=/ cached=(unit [=vase *]) (~(get by vases.fod.dom) path)
|
||||
=/ cached=(unit [=vase *]) (~(get by files.fod.dom) path)
|
||||
?^ cached
|
||||
:_(fod.dom [~ ~ %& %vase !>(vase.u.cached)])
|
||||
=/ x (read-x aeon path)
|
||||
@ -3447,7 +3499,7 @@
|
||||
:_(fod.dom [~ ~ %& %dais !>(dais.u.cached)])
|
||||
=^ =dais fod.dom
|
||||
%- wrap:fusion
|
||||
(get-mark:(ford:fusion static-ford-args) i.path)
|
||||
(build-dais:(ford:fusion static-ford-args) i.path)
|
||||
:_(fod.dom [~ ~ %& %dais !>(dais)])
|
||||
::
|
||||
++ read-c
|
||||
@ -3458,14 +3510,46 @@
|
||||
[~ fod.dom]
|
||||
?. ?=([@ @ ~] path)
|
||||
[[~ ~] fod.dom]
|
||||
=/ cached=(unit [=tube *]) (~(get by casts.fod.dom) [i i.t]:path)
|
||||
=/ cached=(unit [=tube *]) (~(get by tubes.fod.dom) [i i.t]:path)
|
||||
?^ cached
|
||||
:_(fod.dom [~ ~ %& %tube !>(tube.u.cached)])
|
||||
=^ =tube fod.dom
|
||||
%- wrap:fusion
|
||||
(get-cast:(ford:fusion static-ford-args) [i i.t]:path)
|
||||
(build-tube:(ford:fusion static-ford-args) [i i.t]:path)
|
||||
:_(fod.dom [~ ~ %& %tube !>(tube)])
|
||||
::
|
||||
++ read-e
|
||||
!.
|
||||
|= [=aeon =path]
|
||||
^- [(unit (unit (each cage lobe))) ford-cache]
|
||||
?. =(aeon let.dom)
|
||||
[~ fod.dom]
|
||||
?. ?=([@ ~] path)
|
||||
[[~ ~] fod.dom]
|
||||
=/ cached=(unit [=vase *]) (~(get by naves.fod.dom) i.path)
|
||||
?^ cached
|
||||
:_(fod.dom [~ ~ %& %nave !>(vase.u.cached)])
|
||||
=^ =vase fod.dom
|
||||
%- wrap:fusion
|
||||
(build-nave:(ford:fusion static-ford-args) i.path)
|
||||
:_(fod.dom [~ ~ %& %nave !>(vase)])
|
||||
::
|
||||
++ read-f
|
||||
!.
|
||||
|= [=aeon =path]
|
||||
^- [(unit (unit (each cage lobe))) ford-cache]
|
||||
?. =(aeon let.dom)
|
||||
[~ fod.dom]
|
||||
?. ?=([@ @ ~] path)
|
||||
[[~ ~] fod.dom]
|
||||
=/ cached=(unit [=vase *]) (~(get by casts.fod.dom) [i i.t]:path)
|
||||
?^ cached
|
||||
:_(fod.dom [~ ~ %& %cast vase.u.cached])
|
||||
=^ =vase fod.dom
|
||||
%- wrap:fusion
|
||||
(build-cast:(ford:fusion static-ford-args) [i i.t]:path)
|
||||
:_(fod.dom [~ ~ %& %cast vase])
|
||||
::
|
||||
:: Gets the permissions that apply to a particular node.
|
||||
::
|
||||
:: If the node has no permissions of its own, we use its parent's.
|
||||
@ -3810,7 +3894,8 @@
|
||||
:: virtualize to catch and produce deterministic failures
|
||||
::
|
||||
!.
|
||||
=- ?:(?=(%& -<) p.- ((slog p.-) [[~ ~] fod]))
|
||||
=- ?: ?=(%& -<) p.-
|
||||
((slog leaf+"gall: read-at-aeon fail {<mun>}" p.-) [[~ ~] fod])
|
||||
%- mule |.
|
||||
?- care.mun
|
||||
%d
|
||||
@ -3826,6 +3911,8 @@
|
||||
%a (read-a yon path.mun)
|
||||
%b (read-b yon path.mun)
|
||||
%c (read-c yon path.mun)
|
||||
%e (read-e yon path.mun)
|
||||
%f (read-f yon path.mun)
|
||||
%p :_(fod (read-p path.mun))
|
||||
%r :_(fod (bind (read-r yon path.mun) (lift |=(a=cage [%& a]))))
|
||||
%s :_(fod (bind (read-s yon path.mun) (lift |=(a=cage [%& a]))))
|
||||
@ -3871,7 +3958,7 @@
|
||||
::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
=| :: instrument state
|
||||
$: ver=%6 :: vane version
|
||||
$: ver=%7 :: vane version
|
||||
ruf=raft :: revision tree
|
||||
== ::
|
||||
|= [now=@da eny=@uvJ rof=roof] :: current invocation
|
||||
@ -4113,8 +4200,77 @@
|
||||
==
|
||||
::
|
||||
++ load
|
||||
|= old=[%6 raft]
|
||||
..^$(ruf +.old)
|
||||
=> |%
|
||||
+$ raft-any
|
||||
$% [%7 raft-7]
|
||||
[%6 raft-6]
|
||||
==
|
||||
+$ raft-7 raft
|
||||
+$ dojo-7 dojo
|
||||
+$ ford-cache-7 ford-cache
|
||||
+$ raft-6
|
||||
$: rom=room-6 :: domestic
|
||||
hoy=(map ship rung-6) :: foreign
|
||||
ran=rang :: hashes
|
||||
mon=(map term beam) :: mount points
|
||||
hez=(unit duct) :: sync duct
|
||||
cez=(map @ta crew) :: permission groups
|
||||
pud=(unit [=desk =yoki]) :: pending update
|
||||
== ::
|
||||
+$ room-6 [hun=duct dos=(map desk dojo-6)]
|
||||
+$ dojo-6
|
||||
$: qyx=cult :: subscribers
|
||||
dom=dome-6 :: desk state
|
||||
per=regs :: read perms per path
|
||||
pew=regs :: write perms per path
|
||||
==
|
||||
+$ dome-6
|
||||
$: ank=ankh :: state
|
||||
let=aeon :: top id
|
||||
hit=(map aeon tako) :: versions by id
|
||||
lab=(map @tas aeon) :: labels
|
||||
mim=(map path mime) :: mime cache
|
||||
fod=ford-cache-6 :: ford cache
|
||||
fer=(unit reef-cache) :: reef cache
|
||||
==
|
||||
+$ rung-6
|
||||
$: rus=(map desk rede-6)
|
||||
==
|
||||
+$ rede-6
|
||||
$: lim=@da
|
||||
ref=(unit rind)
|
||||
qyx=cult
|
||||
dom=dome-6
|
||||
per=regs
|
||||
pew=regs
|
||||
==
|
||||
+$ ford-cache-6 * :: discard old cache
|
||||
--
|
||||
|= old=raft-any
|
||||
|^
|
||||
=? old ?=(%6 -.old) 7+(raft-6-to-7 +.old)
|
||||
?> ?=(%7 -.old)
|
||||
..^^$(ruf +.old)
|
||||
:: +raft-6-to-7: delete stale ford caches (they could all be invalid)
|
||||
::
|
||||
++ raft-6-to-7
|
||||
|= raf=raft-6
|
||||
^- raft-7
|
||||
%= raf
|
||||
dos.rom
|
||||
%- ~(run by dos.rom.raf)
|
||||
|= doj=dojo-6
|
||||
^- dojo-7
|
||||
doj(fod.dom *ford-cache-7)
|
||||
::
|
||||
hoy
|
||||
%- ~(run by hoy.raf)
|
||||
|= =rung-6
|
||||
%- ~(run by rus.rung-6)
|
||||
|= =rede-6
|
||||
rede-6(dom dom.rede-6(fod *ford-cache-7))
|
||||
==
|
||||
--
|
||||
::
|
||||
++ scry :: inspect
|
||||
^- roon
|
||||
@ -4164,7 +4320,7 @@
|
||||
dos.rom
|
||||
%- ~(run by dos.rom.ruf)
|
||||
|= =dojo
|
||||
dojo(fod.dom [~ ~ ~])
|
||||
dojo(fod.dom [~ ~ ~ ~ ~])
|
||||
::
|
||||
hoy
|
||||
%- ~(run by hoy.ruf)
|
||||
@ -4173,7 +4329,7 @@
|
||||
rus
|
||||
%- ~(run by rus.rung)
|
||||
|= =rede
|
||||
rede(fod.dom [~ ~ ~])
|
||||
rede(fod.dom [~ ~ ~ ~ ~])
|
||||
==
|
||||
==
|
||||
::
|
||||
@ -4348,9 +4504,11 @@
|
||||
:+ desk %|
|
||||
:~ ankh+&+ank.dom.dojo
|
||||
mime+&+mim.dom.dojo
|
||||
ford-vases+&+vases.fod.dom.dojo
|
||||
ford-files+&+files.fod.dom.dojo
|
||||
ford-naves+&+naves.fod.dom.dojo
|
||||
ford-marks+&+marks.fod.dom.dojo
|
||||
ford-casts+&+casts.fod.dom.dojo
|
||||
ford-tubes+&+tubes.fod.dom.dojo
|
||||
==
|
||||
:~ domestic+|+domestic
|
||||
foreign+&+hoy.ruf
|
||||
|
@ -680,12 +680,9 @@
|
||||
:: note this should only happen on reverse bones, so only facts
|
||||
:: and kicks
|
||||
::
|
||||
=/ sys-wire [%sys wire]
|
||||
:: TODO: %drip %kick so app crash can't kill the remote %pull
|
||||
::
|
||||
=/ =ames-request-all [%0 %u ~]
|
||||
=. mo-core
|
||||
(mo-pass sys-wire %a %plea ship %g /ge/[foreign-agent] ames-request-all)
|
||||
=. mo-core (mo-send-foreign-request ship foreign-agent %leave ~)
|
||||
=. mo-core (mo-give %unto %kick ~)
|
||||
mo-core
|
||||
==
|
||||
@ -942,15 +939,13 @@
|
||||
=/ sky (rof ~ %cb [our %home case] /[mark.ames-response])
|
||||
?- sky
|
||||
?(~ [~ ~])
|
||||
=/ ror "gall: ames mark fail {<mark.ames-response>}"
|
||||
(mo-give %done `vale+[leaf+ror]~)
|
||||
(mean leaf+"gall: ames mark fail {<mark.ames-response>}" ~)
|
||||
::
|
||||
[~ ~ *]
|
||||
=+ !<(=dais:clay q.u.u.sky)
|
||||
=/ res (mule |.((vale:dais noun.ames-response)))
|
||||
?: ?=(%| -.res)
|
||||
=/ ror "gall: ames vale fail {<mark.deal>}"
|
||||
(mo-give %done `vale+[leaf+ror p.res])
|
||||
(mean leaf+"gall: ames vale fail {<mark.ames-response>}" p.res)
|
||||
=. mo-core
|
||||
%+ mo-pass /nowhere
|
||||
[%c %warp our %home ~ %sing %b case /[mark.ames-response]]
|
||||
|
@ -3297,11 +3297,14 @@
|
||||
%- flop
|
||||
|- ^- ^tape
|
||||
?:(=(0 a) ~ [(add '0' (mod a 10)) $(a (div a 10))])
|
||||
:: :: ++sect:enjs:format
|
||||
++ sect :: s timestamp
|
||||
|= a=^time
|
||||
(numb (unt:chrono:userlib a))
|
||||
:: :: ++time:enjs:format
|
||||
++ time :: ms timestamp
|
||||
|= a=^time
|
||||
=- (numb (div (mul - 1.000) ~s1))
|
||||
(add (div ~s1 2.000) (sub a ~1970.1.1))
|
||||
(numb (unm:chrono:userlib a))
|
||||
:: :: ++path:enjs:format
|
||||
++ path :: string from path
|
||||
|= a=^path
|
||||
@ -3365,10 +3368,10 @@
|
||||
(poq (wit jon))
|
||||
:: :: ++di:dejs:format
|
||||
++ di :: millisecond date
|
||||
%+ cu
|
||||
|= a=@u ^- @da
|
||||
(add ~1970.1.1 (div (mul ~s1 a) 1.000))
|
||||
ni
|
||||
(cu from-unix-ms:chrono:userlib ni)
|
||||
:: :: ++du:dejs:format
|
||||
++ du :: second date
|
||||
(cu from-unix:chrono:userlib ni)
|
||||
:: :: ++mu:dejs:format
|
||||
++ mu :: true unit
|
||||
|* wit=fist
|
||||
@ -3578,10 +3581,7 @@
|
||||
(bind (stud:chrono:userlib p.jon) |=(a=date (year a)))
|
||||
::
|
||||
++ di :: millisecond date
|
||||
%+ cu
|
||||
|= a=@u ^- @da
|
||||
(add ~1970.1.1 (div (mul ~s1 a) 1.000))
|
||||
ni
|
||||
(cu from-unix-ms:chrono:userlib ni)
|
||||
::
|
||||
++ mu :: true unit
|
||||
|* wit=fist
|
||||
@ -5230,55 +5230,47 @@
|
||||
=/ acc [stop=`?`%.n state=state]
|
||||
=< abet =< main
|
||||
|%
|
||||
++ this .
|
||||
++ abet [state.acc a]
|
||||
:: +main: main recursive loop; performs a partial inorder traversal
|
||||
::
|
||||
++ main
|
||||
^+ .
|
||||
^+ this
|
||||
:: stop if empty or we've been told to stop
|
||||
::
|
||||
?~ a .
|
||||
?: stop.acc .
|
||||
?: =(~ a) this
|
||||
?: stop.acc this
|
||||
:: inorder traversal: left -> node -> right, until .f sets .stop
|
||||
::
|
||||
=> left
|
||||
?: stop.acc .
|
||||
=> node
|
||||
?: stop.acc .
|
||||
right
|
||||
=. this left
|
||||
?: stop.acc this
|
||||
=^ del this node
|
||||
=? this !stop.acc right
|
||||
=? a del (nip a)
|
||||
this
|
||||
:: +node: run .f on .n.a, updating .a, .state, and .stop
|
||||
::
|
||||
++ node
|
||||
^+ .
|
||||
^+ [del=*? this]
|
||||
:: run .f on node, updating .stop.acc and .state.acc
|
||||
::
|
||||
=^ res acc
|
||||
?> ?=(^ a)
|
||||
(f state.acc n.a)
|
||||
:: apply update to .a from .f's product
|
||||
::
|
||||
=. a
|
||||
:: if .f requested node deletion, merge and balance .l.a and .r.a
|
||||
::
|
||||
?~ res (nip a)
|
||||
:: we kept the node; replace its .val; order is unchanged
|
||||
::
|
||||
?> ?=(^ a)
|
||||
a(val.n u.res)
|
||||
::
|
||||
..node
|
||||
?> ?=(^ a)
|
||||
=^ res acc (f state.acc n.a)
|
||||
?~ res
|
||||
[del=& this]
|
||||
[del=| this(val.n.a u.res)]
|
||||
:: +left: recurse on left subtree, copying mutant back into .l.a
|
||||
::
|
||||
++ left
|
||||
^+ .
|
||||
?~ a .
|
||||
^+ this
|
||||
?~ a this
|
||||
=/ lef main(a l.a)
|
||||
lef(a a(l a.lef))
|
||||
:: +right: recurse on right subtree, copying mutant back into .r.a
|
||||
::
|
||||
++ right
|
||||
^+ .
|
||||
?~ a .
|
||||
^+ this
|
||||
?~ a this
|
||||
=/ rig main(a r.a)
|
||||
rig(a a(r a.rig))
|
||||
--
|
||||
@ -5408,13 +5400,20 @@
|
||||
:: ::::
|
||||
++ chrono ^?
|
||||
|%
|
||||
:: +from-unix: unix timestamp to @da
|
||||
:: +from-unix: unix seconds to @da
|
||||
::
|
||||
++ from-unix
|
||||
|= timestamp=@ud
|
||||
^- @da
|
||||
%+ add ~1970.1.1
|
||||
(mul timestamp ~s1)
|
||||
:: +from-unix-ms: unix milliseconds to @da
|
||||
::
|
||||
++ from-unix-ms
|
||||
|= timestamp=@ud
|
||||
^- @da
|
||||
%+ add ~1970.1.1
|
||||
(div (mul ~s1 timestamp) 1.000)
|
||||
:: :: ++dawn:chrono:
|
||||
++ dawn :: Jan 1 weekday
|
||||
|= yer=@ud
|
||||
@ -5533,9 +5532,13 @@
|
||||
++ dd :: two digits
|
||||
(bass 10 (stun 2^2 dit))
|
||||
-- ::
|
||||
:: :: ++unm:chrono:userlib
|
||||
++ unm :: Urbit to Unix ms
|
||||
|= a=@da
|
||||
(div (mul (sub a ~1970.1.1) 1.000) ~s1)
|
||||
:: :: ++unt:chrono:userlib
|
||||
++ unt :: Urbit to Unix time
|
||||
|= a=@
|
||||
|= a=@da
|
||||
(div (sub a ~1970.1.1) ~s1)
|
||||
:: :: ++yu:chrono:userlib
|
||||
++ yu :: UTC format constants
|
||||
|
@ -74,13 +74,15 @@
|
||||
=. next-timer ~
|
||||
=. this
|
||||
%- emit-aqua-events
|
||||
?^ error
|
||||
:: Should pass through errors to aqua, but doesn't
|
||||
::
|
||||
%- (slog leaf+"aqua-behn: timer failed" u.error)
|
||||
~
|
||||
:_ ~
|
||||
^- aqua-event
|
||||
:+ %event who
|
||||
:- //behn/0v1n.2m9vh
|
||||
?~ error
|
||||
[%wake ~]
|
||||
[%crud %fail u.error]
|
||||
[//behn/0v1n.2m9vh [%wake ~]]
|
||||
..abet-pe
|
||||
--
|
||||
--
|
||||
|
@ -9,5 +9,5 @@
|
||||
?~ bem=(de-beam pax)
|
||||
(strand-fail:strand %path-not-beam >pax< ~)
|
||||
=/ =mars:clay [i i.t]:?>(?=([@ @ ~] s.u.bem) s.u.bem)
|
||||
;< =tube:clay bind:m (build-cast:strandio -.u.bem mars)
|
||||
(pure:m !>(tube))
|
||||
;< =vase bind:m (build-cast:strandio -.u.bem mars)
|
||||
(pure:m vase)
|
||||
|
13
pkg/arvo/ted/build-nave.hoon
Normal file
13
pkg/arvo/ted/build-nave.hoon
Normal file
@ -0,0 +1,13 @@
|
||||
/- spider
|
||||
/+ strandio
|
||||
=, strand=strand:spider
|
||||
^- thread:spider
|
||||
|= arg=vase
|
||||
=/ m (strand ,vase)
|
||||
^- form:m
|
||||
=+ !<([~ pax=path] arg)
|
||||
?~ bem=(de-beam pax)
|
||||
(strand-fail:strand %path-not-beam >pax< ~)
|
||||
=/ =mark (rear s.u.bem)
|
||||
;< =vase bind:m (build-nave:strandio -.u.bem mark)
|
||||
(pure:m vase)
|
13
pkg/arvo/ted/build-tube.hoon
Normal file
13
pkg/arvo/ted/build-tube.hoon
Normal file
@ -0,0 +1,13 @@
|
||||
/- spider
|
||||
/+ strandio
|
||||
=, strand=strand:spider
|
||||
^- thread:spider
|
||||
|= arg=vase
|
||||
=/ m (strand ,vase)
|
||||
^- form:m
|
||||
=+ !<([~ pax=path] arg)
|
||||
?~ bem=(de-beam pax)
|
||||
(strand-fail:strand %path-not-beam >pax< ~)
|
||||
=/ =mars:clay [i i.t]:?>(?=([@ @ ~] s.u.bem) s.u.bem)
|
||||
;< =tube:clay bind:m (build-tube:strandio -.u.bem mars)
|
||||
(pure:m !>(tube))
|
144
pkg/arvo/ted/gcp/get-token.hoon
Normal file
144
pkg/arvo/ted/gcp/get-token.hoon
Normal file
@ -0,0 +1,144 @@
|
||||
:: Gets a Google Storage access token.
|
||||
::
|
||||
:: This thread produces a pair of [access-key expires-in], where
|
||||
:: access-key is a @t that can be used as a bearer token to talk
|
||||
:: to the GCP Storage API on behalf of some service account, and
|
||||
:: expires-in is a @dr after which the token will stop working and
|
||||
:: need to be refreshed.
|
||||
::
|
||||
:: It expects settings-store to contain relevant fields from
|
||||
:: a GCP service account JSON file, generally as poked by
|
||||
:: sh/poke-gcp-account-json. Specifically, it depends on the
|
||||
:: `token_uri`, `client_email`, `private_key_id`, and `private_key`
|
||||
:: fields. If these fields are not in settings-store at the time
|
||||
:: the thread is run, it will fail.
|
||||
::
|
||||
:: The thread works by first constructing a self-signed JWT using
|
||||
:: the fields in settings-store. Then, it sends this JWT to the
|
||||
:: specified token URI (usually https://oauth2.googleapis.com/token),
|
||||
:: which responds with a bearer token and expiry.
|
||||
::
|
||||
::
|
||||
/- gcp, spider, settings
|
||||
/+ jose, pkcs, primitive-rsa, strandio
|
||||
=, strand=strand:spider
|
||||
=, rsa=primitive-rsa
|
||||
^- thread:spider
|
||||
|^
|
||||
|= *
|
||||
=/ m (strand ,vase)
|
||||
^- form:m
|
||||
;< =bowl:spider bind:m get-bowl:strandio
|
||||
;< iss=@t bind:m (read-setting %client-email)
|
||||
;< =key:rsa bind:m read-private-key
|
||||
;< kid=@t bind:m (read-setting %private-key-id)
|
||||
;< aud=@t bind:m (read-setting %token-uri)
|
||||
=* scope
|
||||
'https://www.googleapis.com/auth/devstorage.read_write'
|
||||
=/ jot=@t
|
||||
(make-jwt key kid iss scope aud now.bowl)
|
||||
;< =token:gcp bind:m
|
||||
(get-access-token jot aud)
|
||||
(pure:m !>(token))
|
||||
::
|
||||
++ read-setting
|
||||
|= key=term
|
||||
=/ m (strand @t) ^- form:m
|
||||
;< has=? bind:m
|
||||
%+ scry:strandio ?
|
||||
/gx/settings-store/has-entry/gcp-store/[key]/noun
|
||||
?. has
|
||||
(strand-fail:strandio (rap 3 %gcp-missing- key ~) ~)
|
||||
;< =data:settings bind:m
|
||||
%+ scry:strandio
|
||||
data:settings
|
||||
/gx/settings-store/entry/gcp-store/[key]/settings-data
|
||||
?> ?=([%entry %s @] data)
|
||||
(pure:m p.val.data)
|
||||
::
|
||||
++ read-private-key
|
||||
=/ m (strand ,key:rsa) ^- form:m
|
||||
;< dat=@t bind:m (read-setting %private-key)
|
||||
%- pure:m
|
||||
%. dat
|
||||
;: cork
|
||||
to-wain:format
|
||||
ring:de:pem:pkcs8:pkcs
|
||||
need
|
||||
==
|
||||
:: construct and return a self-signed JWT issued now, expiring in ~h1.
|
||||
:: TODO: maybe move this into lib/jose/hoon
|
||||
::
|
||||
++ make-jwt
|
||||
|= [=key:rsa kid=@t iss=@t scope=@t aud=@t iat=@da]
|
||||
^- @t
|
||||
=/ job=json
|
||||
=, enjs:format
|
||||
%^ sign:jws:jose key
|
||||
:: the JWT's "header"
|
||||
%: pairs
|
||||
alg+s+'RS256'
|
||||
typ+s+'JWT'
|
||||
kid+s+kid
|
||||
~
|
||||
==
|
||||
:: the JWT's "payload"
|
||||
%: pairs
|
||||
iss+s+iss
|
||||
sub+s+iss :: per g.co, use iss for sub
|
||||
scope+s+scope
|
||||
aud+s+aud
|
||||
iat+(sect iat)
|
||||
exp+(sect (add iat ~h1))
|
||||
~
|
||||
==
|
||||
=/ [pod=@t pad=@t sig=@t]
|
||||
=, dejs:format
|
||||
((ot 'protected'^so 'payload'^so 'signature'^so ~) job)
|
||||
(rap 3 (join '.' `(list @t)`~[pod pad sig]))
|
||||
:: RPC to get an access token. Probably only works with Google.
|
||||
:: Described at:
|
||||
:: https://developers.google.com/identity/protocols/oauth2/service-account
|
||||
::
|
||||
++ get-access-token
|
||||
|= [jot=@t url=@t]
|
||||
=/ m (strand ,token:gcp) ^- form:m
|
||||
;< ~ bind:m
|
||||
%: send-request:strandio
|
||||
method=%'POST'
|
||||
url=url
|
||||
header-list=['Content-Type'^'application/json' ~]
|
||||
^= body
|
||||
%- some %- as-octt:mimes:html
|
||||
%- en-json:html
|
||||
%: pairs:enjs:format
|
||||
:- 'grant_type'
|
||||
s+'urn:ietf:params:oauth:grant-type:jwt-bearer'
|
||||
assertion+s+jot
|
||||
~
|
||||
==
|
||||
==
|
||||
;< rep=client-response:iris bind:m
|
||||
take-client-response:strandio
|
||||
?> ?=(%finished -.rep)
|
||||
?~ full-file.rep
|
||||
(strand-fail:strandio %gcp-no-response ~)
|
||||
=/ body=@t q.data.u.full-file.rep
|
||||
=/ jon=(unit json) (de-json:html body)
|
||||
?~ jon
|
||||
~| body
|
||||
(strand-fail:strandio %gcp-bad-body ~)
|
||||
=* job u.jon
|
||||
~| job
|
||||
=, dejs:format
|
||||
=/ [typ=@t =token:gcp]
|
||||
%. job
|
||||
%: ot
|
||||
'token_type'^so
|
||||
'access_token'^so
|
||||
'expires_in'^(cu |=(a=@ (mul a ~s1)) ni)
|
||||
~
|
||||
==
|
||||
?> =('Bearer' typ)
|
||||
(pure:m token)
|
||||
--
|
49
pkg/arvo/ted/gcp/is-configured.hoon
Normal file
49
pkg/arvo/ted/gcp/is-configured.hoon
Normal file
@ -0,0 +1,49 @@
|
||||
:: Tells whether GCP Storage appears to be configured.
|
||||
::
|
||||
:: Thread since it needs to be called from Landscape.
|
||||
::
|
||||
::
|
||||
/- gcp, spider, settings
|
||||
/+ strandio
|
||||
=, strand=strand:spider
|
||||
=, enjs:format
|
||||
^- thread:spider
|
||||
|^
|
||||
|= *
|
||||
=/ m (strand ,vase)
|
||||
^- form:m
|
||||
;< has=? bind:m
|
||||
%: has-settings
|
||||
%client-email
|
||||
%private-key
|
||||
%private-key-id
|
||||
%token-uri
|
||||
~
|
||||
==
|
||||
%- pure:m
|
||||
!>
|
||||
%+ frond %gcp-configured
|
||||
b+has
|
||||
::
|
||||
++ has-settings
|
||||
|= set=(list @tas)
|
||||
=/ m (strand ?)
|
||||
^- form:m
|
||||
?~ set
|
||||
(pure:m %.y)
|
||||
;< has=? bind:m (has-setting i.set)
|
||||
?. has
|
||||
(pure:m %.n)
|
||||
;< has=? bind:m (has-settings t.set)
|
||||
(pure:m has)
|
||||
::
|
||||
++ has-setting
|
||||
|= key=@tas
|
||||
=/ m (strand ?)
|
||||
^- form:m
|
||||
;< has=? bind:m
|
||||
%+ scry:strandio ?
|
||||
/gx/settings-store/has-entry/gcp-store/[key]/noun
|
||||
(pure:m has)
|
||||
::
|
||||
--
|
@ -1,4 +1,5 @@
|
||||
/- spider, graph-view, graph=graph-store, *metadata-store, *group, *metadata-store
|
||||
/- spider, graph-view, graph=graph-store,
|
||||
met=metadata-store, *group, *metadata-store
|
||||
/+ strandio, resource
|
||||
=>
|
||||
|%
|
||||
@ -28,11 +29,11 @@
|
||||
::
|
||||
++ scry-metadatum
|
||||
|= rid=resource
|
||||
=/ m (strand ,metadata)
|
||||
=/ m (strand ,metadatum:met)
|
||||
^- form:m
|
||||
=/ enc-path=@t (scot %t (spat (en-path:resource rid)))
|
||||
;< umeta=(unit metadata) bind:m
|
||||
%+ scry:strandio (unit metadata)
|
||||
;< umeta=(unit metadatum:met) bind:m
|
||||
%+ scry:strandio (unit metadatum:met)
|
||||
%+ weld /gx/metadata-store/metadata
|
||||
/[enc-path]/graph/[enc-path]/noun
|
||||
?> ?=(^ umeta)
|
||||
@ -48,24 +49,25 @@
|
||||
;< =group bind:m (scry-group rid.action)
|
||||
?. hidden.group
|
||||
(strand-fail:strandio %bad-request ~)
|
||||
;< =metadata bind:m (scry-metadatum rid.action)
|
||||
;< =metadatum:met bind:m (scry-metadatum rid.action)
|
||||
?~ to.action
|
||||
;< ~ bind:m
|
||||
%+ poke-our %contact-view
|
||||
:- %contact-view-action
|
||||
!>([%groupify rid.action title.metadata description.metadata])
|
||||
!>([%groupify rid.action title.metadatum description.metadatum])
|
||||
(pure:m !>(~))
|
||||
;< new=^group bind:m (scry-group u.to.action)
|
||||
?< hidden.new
|
||||
=/ new-path (en-path:resource u.to.action)
|
||||
=/ app-path (en-path:resource rid.action)
|
||||
=/ add-md=metadata-action
|
||||
[%add new-path graph+app-path metadata]
|
||||
;< ~ bind:m
|
||||
(poke-our %metadata-store metadata-action+!>(add-md))
|
||||
;< ~ bind:m
|
||||
%+ poke-our %metadata-store
|
||||
metadata-action+!>([%remove app-path graph+app-path])
|
||||
:- %metadata-action
|
||||
!> ^- action:met
|
||||
[%add u.to.action [%graph rid.action] metadatum]
|
||||
;< ~ bind:m
|
||||
%+ poke-our %metadata-store
|
||||
:- %metadata-action
|
||||
!> ^- action:met
|
||||
[%remove rid.action [%graph rid.action]]
|
||||
;< ~ bind:m
|
||||
(poke-our %group-store %group-update !>([%remove-group rid.action ~]))
|
||||
(pure:m !>(~))
|
||||
|
@ -1,4 +1,4 @@
|
||||
/- spider, graph=graph-store, *metadata-store, *group, group-store
|
||||
/- spider, graph=graph-store, met=metadata-store, *group, group-store, push-hook
|
||||
/+ strandio, resource, graph-view
|
||||
=>
|
||||
|%
|
||||
@ -23,17 +23,22 @@
|
||||
::
|
||||
:: Setup metadata
|
||||
::
|
||||
=/ =metadata
|
||||
%* . *metadata
|
||||
=/ =metadatum:met
|
||||
%* . *metadatum:met
|
||||
title title
|
||||
description description
|
||||
date-created now.bowl
|
||||
creator our.bowl
|
||||
module module
|
||||
==
|
||||
=/ act=metadata-action
|
||||
[%add (en-path:resource group) graph+(en-path:resource rid) metadata]
|
||||
;< ~ bind:m (poke-our %metadata-hook %metadata-action !>(act))
|
||||
;< ~ bind:m
|
||||
(poke-our %metadata-hook %metadata-hook-action !>([%add-owned (en-path:resource group)]))
|
||||
%+ poke-our %metadata-push-hook
|
||||
:- %metadata-action
|
||||
!> ^- action:met
|
||||
[%add group [%graph rid] metadatum]
|
||||
;< ~ bind:m
|
||||
%+ poke-our %metadata-push-hook
|
||||
:- %push-hook-action
|
||||
!> ^- action:push-hook
|
||||
[%add group]
|
||||
(pure:m !>(~))
|
||||
|
@ -1,84 +0,0 @@
|
||||
/- spider, *metadata-store
|
||||
/+ strandio
|
||||
=, strand=strand:spider
|
||||
^- thread:spider
|
||||
|= arg=vase
|
||||
=/ m (strand ,vase)
|
||||
^- form:m
|
||||
=/ [~ og-path=path ng-path=path] !<([~ path path] arg)
|
||||
;< bol=bowl:spider bind:m get-bowl:strandio
|
||||
|^
|
||||
::
|
||||
=/ og=(unit (set ship)) (scry-for (unit (set ship)) %group-store og-path)
|
||||
?~ og
|
||||
(pure:m !>("no such group: {<og-path>}"))
|
||||
=/ ng=(unit (set ship)) (scry-for (unit (set ship)) %group-store ng-path)
|
||||
?~ ng
|
||||
(pure:m !>("no such group: {<ng-path>}"))
|
||||
::
|
||||
=/ assoc=associations (scry-for associations %metadata-store [%group og-path])
|
||||
=/ assoc-list=(list [[group-path md-resource] metadata]) ~(tap by assoc)
|
||||
::
|
||||
|-
|
||||
=* loop $
|
||||
?~ assoc-list
|
||||
;< ~ bind:m
|
||||
(poke-our:strandio %group-store %group-action !>([%unbundle og-path]))
|
||||
(pure:m !>("done"))
|
||||
=/ [[g-path=group-path res=md-resource] meta=metadata] i.assoc-list
|
||||
?. =(our.bol creator.meta)
|
||||
loop(assoc-list t.assoc-list)
|
||||
?> =(g-path og-path)
|
||||
=/ output=(list card:agent:gall)
|
||||
?+ app-name.res ~
|
||||
::
|
||||
?(%chat %link)
|
||||
%- (slog leaf+"migrating {<app-name.res>} : {<app-path.res>}" ~)
|
||||
:~ :* %pass /poke %agent
|
||||
[our.bol %metadata-hook]
|
||||
%poke %metadata-action
|
||||
!>([%add ng-path res meta])
|
||||
==
|
||||
:* %pass /poke %agent
|
||||
[our.bol %metadata-hook]
|
||||
%poke %metadata-action
|
||||
!>([%remove g-path res])
|
||||
==
|
||||
==
|
||||
%publish
|
||||
%- (slog leaf+"migrating {<app-name.res>} : {<app-path.res>}" ~)
|
||||
=/ book (scry-for notebook %publish [%book app-path.res])
|
||||
?> ?=([@tas @tas ~] app-path.res)
|
||||
:~ :* %pass /poke %agent
|
||||
[our.bol %publish]
|
||||
%poke %publish-action
|
||||
!>
|
||||
:* %edit-book
|
||||
i.t.app-path.res
|
||||
title.book
|
||||
description.book
|
||||
comments.book
|
||||
`[ng-path ~ %.y %.n]
|
||||
==
|
||||
==
|
||||
:* %pass /poke %agent
|
||||
[our.bol %metadata-hook]
|
||||
%poke %metadata-action
|
||||
!>([%remove g-path res])
|
||||
==
|
||||
==
|
||||
==
|
||||
::
|
||||
;< ~ bind:m (send-raw-cards:strandio output)
|
||||
loop(assoc-list t.assoc-list)
|
||||
::
|
||||
++ scry-for
|
||||
|* [mol=mold app=term pax=path]
|
||||
.^ mol
|
||||
%gx
|
||||
(scot %p our.bol)
|
||||
app
|
||||
(scot %da now.bol)
|
||||
(snoc `path`pax %noun)
|
||||
==
|
||||
--
|
@ -1,46 +0,0 @@
|
||||
/- spider,
|
||||
contact-view,
|
||||
*resource
|
||||
/+ *ph-io, strandio
|
||||
=, strand=strand:spider
|
||||
::
|
||||
^- thread:spider
|
||||
|= vase
|
||||
=/ m (strand ,vase)
|
||||
;< ~ bind:m start-simple
|
||||
;< bol=bowl:spider bind:m get-bowl:strandio
|
||||
::
|
||||
:: group setup
|
||||
:: - ~zod creates an open group
|
||||
:: - ~zod creates and invite-only group, and invites ~bus and ~web
|
||||
:: - ~bus and ~web join the first, but not the second group, to keep
|
||||
:: invite-store populated
|
||||
::
|
||||
=/ group-1=contact-view-action:contact-view
|
||||
:* %create
|
||||
%group-1
|
||||
[%open ~ ~]
|
||||
'Group 1'
|
||||
'this is group 1'
|
||||
==
|
||||
=/ group-2=contact-view-action:contact-view
|
||||
:* %create
|
||||
%group-2
|
||||
[%invite (sy ~bus ~web ~)]
|
||||
'Group 2'
|
||||
'this is group 2'
|
||||
==
|
||||
=/ join=contact-view-action:contact-view [%join ~zod %group-1]
|
||||
;< ~ bind:m (poke-app ~zod %contact-view %contact-view-action group-1)
|
||||
;< ~ bind:m (wait-for-output ~zod ">=")
|
||||
;< ~ bind:m (poke-app ~zod %contact-view %contact-view-action group-2)
|
||||
;< ~ bind:m (wait-for-output ~zod ">=")
|
||||
;< ~ bind:m (sleep ~s10)
|
||||
;< ~ bind:m (poke-app ~bus %contact-view %contact-view-action join)
|
||||
;< ~ bind:m (wait-for-output ~bus ">=")
|
||||
;< ~ bind:m (poke-app ~web %contact-view %contact-view-action join)
|
||||
;< ~ bind:m (wait-for-output ~web ">=")
|
||||
;< ~ bind:m (send-hi ~bus ~zod)
|
||||
;< ~ bind:m (send-hi ~web ~zod)
|
||||
;< ~ bind:m (sleep ~s2)
|
||||
(pure:m *vase)
|
@ -1,24 +0,0 @@
|
||||
/- spider,
|
||||
contact-view,
|
||||
*resource,
|
||||
group-store
|
||||
/+ *ph-io, strandio
|
||||
=, strand=strand:spider
|
||||
::
|
||||
^- thread:spider
|
||||
|= vase
|
||||
=/ m (strand ,vase)
|
||||
;< ~ bind:m start-simple
|
||||
;< bol=bowl:spider bind:m get-bowl:strandio
|
||||
::
|
||||
=/ join-2=contact-view-action:contact-view [%join ~zod %group-2]
|
||||
=/ add-members-1=action:group-store
|
||||
[%add-members [~zod %group-1] (sy ~def ~ten ~)]
|
||||
=/ add-members-2=action:group-store
|
||||
[%add-members [~zod %group-2] (sy ~def ~ten ~)]
|
||||
;< ~ bind:m (poke-app ~bus %contact-view %contact-view-action join-2)
|
||||
;< ~ bind:m (poke-app ~web %contact-view %contact-view-action join-2)
|
||||
;< ~ bind:m (poke-app ~zod %group-store %group-action add-members-1)
|
||||
;< ~ bind:m (poke-app ~zod %group-store %group-action add-members-2)
|
||||
::
|
||||
(pure:m *vase)
|
@ -1,61 +0,0 @@
|
||||
/- spider,
|
||||
contact-view,
|
||||
contact-store,
|
||||
group-store,
|
||||
metadata-store,
|
||||
post,
|
||||
graph-store,
|
||||
*resource
|
||||
/+ *ph-io, strandio
|
||||
=, strand=strand:spider
|
||||
::
|
||||
::
|
||||
^- thread:spider
|
||||
|= vase
|
||||
=/ m (strand ,vase)
|
||||
;< ~ bind:m start-simple
|
||||
;< bol=bowl:spider bind:m get-bowl:strandio
|
||||
::
|
||||
:: test metadata import
|
||||
::
|
||||
=/ change-group-1=metadata-action:metadata-store
|
||||
:* %add
|
||||
/ship/~zod/group-1
|
||||
[%contacts /ship/~zod/group-1]
|
||||
'New Group 1 Title'
|
||||
'new description'
|
||||
0x0
|
||||
now.bol
|
||||
~zod
|
||||
'fake'
|
||||
==
|
||||
=/ change-web-book=metadata-action:metadata-store
|
||||
:* %add
|
||||
/ship/~web/graph-3
|
||||
[%graph /ship/~web/graph-3]
|
||||
'New Graph 3 Title'
|
||||
'new description'
|
||||
0x0
|
||||
now.bol
|
||||
~web
|
||||
'fake'
|
||||
==
|
||||
;< ~ bind:m (poke-app ~zod %metadata-hook %metadata-action change-group-1)
|
||||
;< ~ bind:m (sleep ~s5)
|
||||
;< ~ bind:m (poke-app ~web %metadata-hook %metadata-action change-web-book)
|
||||
;< ~ bind:m (sleep ~s5)
|
||||
::
|
||||
:: test contacts import
|
||||
::
|
||||
=/ add-zod=contact-action:contact-store
|
||||
:* %add /ship/~zod/group-1 ~zod
|
||||
'ZOD' '' '' '' '' 0x0 ~
|
||||
==
|
||||
=/ add-bus=contact-action:contact-store
|
||||
:* %add /ship/~zod/group-2 ~bus
|
||||
'BUS' '' '' '' '' 0x0 ~
|
||||
==
|
||||
;< ~ bind:m (poke-app ~zod %contact-hook %contact-action add-zod)
|
||||
;< ~ bind:m (sleep ~s5)
|
||||
;< ~ bind:m (poke-app ~bus %contact-hook %contact-action add-bus)
|
||||
(pure:m *vase)
|
@ -1,9 +1,15 @@
|
||||
/+ *test
|
||||
/= clay-raw /sys/vane/clay
|
||||
/* hello-gen %hoon /gen/hello/hoon
|
||||
/* strandio-lib %hoon /lib/strandio/hoon
|
||||
/* strand-lib %hoon /lib/strand/hoon
|
||||
/* spider-sur %hoon /sur/spider/hoon
|
||||
/* gen-hello %hoon /gen/hello/hoon
|
||||
/* lib-cram %hoon /lib/cram/hoon
|
||||
/* lib-strandio %hoon /lib/strandio/hoon
|
||||
/* lib-strand %hoon /lib/strand/hoon
|
||||
/* sur-spider %hoon /sur/spider/hoon
|
||||
/* mar-html %hoon /mar/html/hoon
|
||||
/* mar-mime %hoon /mar/mime/hoon
|
||||
/* mar-udon %hoon /mar/udon/hoon
|
||||
/* mar-txt %hoon /mar/txt/hoon
|
||||
/* mar-txt-diff %hoon /mar/txt-diff/hoon
|
||||
::
|
||||
!:
|
||||
=, format
|
||||
@ -14,32 +20,48 @@
|
||||
::
|
||||
|%
|
||||
++ test-parse-pile ^- tang
|
||||
=/ src "."
|
||||
%+ expect-eq
|
||||
!> ^- pile:fusion
|
||||
:* ~ ~ ~ ~
|
||||
:* ~ ~ ~ ~ ~ ~
|
||||
tssg+[%dbug [/sur/foo/hoon [[1 1] [1 2]]] [%cnts ~[[%.y 1]] ~]]~
|
||||
==
|
||||
!> (parse-pile:(ford):fusion /sur/foo/hoon ".")
|
||||
!> (parse-pile:(ford):fusion /sur/foo/hoon src)
|
||||
::
|
||||
++ test-parse-fascen ^- tang
|
||||
=/ src "/% moo %mime\0a."
|
||||
%+ expect-eq
|
||||
!> ^- pile:fusion
|
||||
:* sur=~ lib=~ raw=~
|
||||
maz=[face=%moo mark=%mime]~
|
||||
caz=~ bar=~
|
||||
tssg+[%dbug [/sur/foo/hoon [[2 1] [2 2]]] [%cnts ~[[%.y 1]] ~]]~
|
||||
==
|
||||
!> (parse-pile:(ford):fusion /sur/foo/hoon src)
|
||||
::
|
||||
++ test-parse-fasbuc ^- tang
|
||||
=/ src "/$ goo %mime %txt\0a."
|
||||
%+ expect-eq
|
||||
!> ^- pile:fusion
|
||||
:* sur=~ lib=~ raw=~ maz=~
|
||||
caz=[face=%goo from=%mime to=%txt]~
|
||||
bar=~
|
||||
tssg+[%dbug [/sur/foo/hoon [[2 1] [2 2]]] [%cnts ~[[%.y 1]] ~]]~
|
||||
==
|
||||
!> (parse-pile:(ford):fusion /sur/foo/hoon src)
|
||||
::
|
||||
++ test-parse-multiline-faslus ^- tang
|
||||
=/ src
|
||||
"""
|
||||
:: :: ::
|
||||
:::: /hoon/hood/app :: ::
|
||||
:: :: ::
|
||||
::
|
||||
/? 310 :: zuse version
|
||||
::
|
||||
/- *sole
|
||||
::
|
||||
/+ sole :: libraries
|
||||
:: XX these should really be separate apps, as
|
||||
:: none of them interact with each other in
|
||||
:: any fashion; however, to reduce boot-time
|
||||
:: complexity and work around the current
|
||||
:: non-functionality of end-to-end acknowledgments,
|
||||
:: they have been bundled into :hood
|
||||
::
|
||||
:: |command handlers
|
||||
::
|
||||
/+ hood-helm, hood-kiln, hood-drum, hood-write
|
||||
:: :: ::
|
||||
::
|
||||
.
|
||||
"""
|
||||
%+ expect-eq
|
||||
@ -52,34 +74,21 @@
|
||||
[`%hood-drum %hood-drum]
|
||||
[`%hood-write %hood-write]
|
||||
==
|
||||
raw=~ bar=~
|
||||
hoon=tssg+[p:(need q:(tall:(vang & /app/hood/hoon) [17 1] "."))]~
|
||||
raw=~ maz=~ caz=~ bar=~
|
||||
tssg+[%dbug [/sur/foo/hoon [[10 1] [10 2]]] [%cnts ~[[%.y 1]] ~]]~
|
||||
==
|
||||
!> (parse-pile:(ford):fusion /app/hood/hoon src)
|
||||
!> (parse-pile:(ford):fusion /sur/foo/hoon src)
|
||||
::
|
||||
++ test-cycle ^- tang
|
||||
=/ source=@t
|
||||
'''
|
||||
/+ self
|
||||
.
|
||||
'''
|
||||
=/ =ankh:clay
|
||||
:- fil=~
|
||||
%- ~(gas by *(map @tas ankh:clay))
|
||||
:~ :+ %lib fil=~
|
||||
%- ~(gas by *(map @tas ankh:clay))
|
||||
:~ :+ %self fil=~
|
||||
%- ~(gas by *(map @tas ankh:clay))
|
||||
:~ :+ %hoon fil=`[*lobe:clay hoon+!>(source)] dir=~
|
||||
== == ==
|
||||
=/ source=@t '/+ self\0a.'
|
||||
%- expect-fail
|
||||
|.
|
||||
=/ ford
|
||||
%: ford:fusion
|
||||
bud
|
||||
ankh
|
||||
*ankh:clay
|
||||
deletes=~
|
||||
changes=~
|
||||
changes=(my [/lib/self/hoon &+hoon+source]~)
|
||||
file-store=~
|
||||
*ford-cache:fusion
|
||||
==
|
||||
@ -89,22 +98,122 @@
|
||||
%- expect-fail
|
||||
|. (parse-pile:(ford):fusion /sur/foo/hoon "[")
|
||||
::
|
||||
++ test-hello-gen ^- tang
|
||||
=/ =ankh:clay
|
||||
:- fil=~
|
||||
%- ~(gas by *(map @tas ankh:clay))
|
||||
:~ :+ %gen fil=~
|
||||
%- ~(gas by *(map @tas ankh:clay))
|
||||
:~ :+ %hello fil=~
|
||||
%- ~(gas by *(map @tas ankh:clay))
|
||||
:~ :+ %hoon fil=`[*lobe:clay hoon+!>(hello-gen)] dir=~
|
||||
== == ==
|
||||
++ test-mar-mime ^- tang
|
||||
=/ ford
|
||||
%: ford:fusion
|
||||
bud
|
||||
ankh
|
||||
*ankh:clay
|
||||
deletes=~
|
||||
changes=(my [/gen/hello/hoon &+hoon+hello-gen]~)
|
||||
changes=(my [/mar/mime/hoon &+hoon+mar-mime]~)
|
||||
file-store=~
|
||||
*ford-cache:fusion
|
||||
==
|
||||
=/ [res=vase nub=state:ford:fusion] (build-nave:ford %mime)
|
||||
;: weld
|
||||
%+ expect-eq
|
||||
!>(*mime)
|
||||
(slap res limb/%bunt)
|
||||
::
|
||||
%+ expect-eq
|
||||
!> (~(gas in *(set path)) /mar/mime/hoon ~)
|
||||
!> dez:(~(got by files.cache.nub) /mar/mime/hoon)
|
||||
==
|
||||
::
|
||||
++ test-mar-udon ^- tang
|
||||
=/ ford
|
||||
%: ford:fusion
|
||||
bud
|
||||
*ankh:clay
|
||||
deletes=~
|
||||
^= changes
|
||||
%- my
|
||||
:~ [/mar/udon/hoon &+hoon+mar-udon]
|
||||
[/lib/cram/hoon &+hoon+lib-cram]
|
||||
[/mar/txt/hoon &+hoon+mar-txt]
|
||||
[/mar/txt-diff/hoon &+hoon+mar-txt-diff]
|
||||
==
|
||||
file-store=~
|
||||
*ford-cache:fusion
|
||||
==
|
||||
=/ [res=vase nub=state:ford:fusion] (build-nave:ford %udon)
|
||||
;: weld
|
||||
%+ expect-eq
|
||||
!>(*@t)
|
||||
(slap res limb/%bunt)
|
||||
::
|
||||
%+ expect-eq
|
||||
!> (~(gas in *(set path)) /mar/udon/hoon /lib/cram/hoon ~)
|
||||
!> dez:(~(got by files.cache.nub) /mar/udon/hoon)
|
||||
==
|
||||
::
|
||||
++ test-cast-html-mime ^- tang
|
||||
=/ changes
|
||||
%- my
|
||||
:~ [/mar/mime/hoon &+hoon+mar-mime]
|
||||
[/mar/html/hoon &+hoon+mar-html]
|
||||
==
|
||||
=/ ford
|
||||
%: ford:fusion
|
||||
bud
|
||||
*ankh:clay
|
||||
deletes=~
|
||||
changes
|
||||
file-store=~
|
||||
*ford-cache:fusion
|
||||
==
|
||||
=/ [res=vase nub=state:ford:fusion] (build-cast:ford %html %mime)
|
||||
%+ expect-eq
|
||||
(slam res !>('<html></html>'))
|
||||
!> `mime`[/text/html 13 '<html></html>']
|
||||
::
|
||||
++ test-fascen ^- tang
|
||||
=/ changes
|
||||
%- my
|
||||
:~ [/mar/mime/hoon &+hoon+mar-mime]
|
||||
[/lib/foo/hoon &+hoon+'/% moo %mime\0abunt:moo']
|
||||
==
|
||||
=/ ford
|
||||
%: ford:fusion
|
||||
bud
|
||||
*ankh:clay
|
||||
deletes=~
|
||||
changes
|
||||
file-store=~
|
||||
*ford-cache:fusion
|
||||
==
|
||||
=/ [res=vase nub=state:ford:fusion] (build-file:ford /lib/foo/hoon)
|
||||
%+ expect-eq
|
||||
res
|
||||
!> *mime
|
||||
::
|
||||
++ test-fasbuc ^- tang
|
||||
=/ changes
|
||||
%- my
|
||||
:~ [/mar/mime/hoon &+hoon+mar-mime]
|
||||
[/mar/html/hoon &+hoon+mar-html]
|
||||
[/lib/foo/hoon &+hoon+'/$ foo %mime %html\0a*foo']
|
||||
==
|
||||
=/ ford
|
||||
%: ford:fusion
|
||||
bud
|
||||
*ankh:clay
|
||||
deletes=~
|
||||
changes
|
||||
file-store=~
|
||||
*ford-cache:fusion
|
||||
==
|
||||
=/ [res=vase nub=state:ford:fusion] (build-file:ford /lib/foo/hoon)
|
||||
%+ expect-eq
|
||||
res
|
||||
!> ''
|
||||
::
|
||||
++ test-gen-hello ^- tang
|
||||
=/ ford
|
||||
%: ford:fusion
|
||||
bud
|
||||
*ankh:clay
|
||||
deletes=~
|
||||
changes=(my [/gen/hello/hoon &+hoon+gen-hello]~)
|
||||
file-store=~
|
||||
*ford-cache:fusion
|
||||
==
|
||||
@ -116,37 +225,21 @@
|
||||
::
|
||||
%+ expect-eq
|
||||
!> (~(gas in *(set path)) /gen/hello/hoon ~)
|
||||
!> dez:(~(got by vases.cache.nub) /gen/hello/hoon)
|
||||
!> dez:(~(got by files.cache.nub) /gen/hello/hoon)
|
||||
==
|
||||
::
|
||||
++ test-strandio-lib ^- tang
|
||||
=/ =ankh:clay
|
||||
:- fil=~
|
||||
%- ~(gas by *(map @tas ankh:clay))
|
||||
:~ :+ %lib fil=~
|
||||
%- ~(gas by *(map @tas ankh:clay))
|
||||
:~ :+ %strandio fil=~
|
||||
%- ~(gas by *(map @tas ankh:clay))
|
||||
:~ :+ %hoon fil=`[*lobe:clay hoon+!>(strandio-lib)] dir=~
|
||||
==
|
||||
::
|
||||
:+ %strand fil=~
|
||||
%- ~(gas by *(map @tas ankh:clay))
|
||||
:~ :+ %hoon fil=`[*lobe:clay hoon+!>(strand-lib)] dir=~
|
||||
== ==
|
||||
::
|
||||
:+ %sur fil=~
|
||||
%- ~(gas by *(map @tas ankh:clay))
|
||||
:~ :+ %spider fil=~
|
||||
%- ~(gas by *(map @tas ankh:clay))
|
||||
:~ :+ %hoon fil=`[*lobe:clay hoon+!>(spider-sur)] dir=~
|
||||
== == ==
|
||||
++ test-lib-strandio ^- tang
|
||||
=/ ford
|
||||
%: ford:fusion
|
||||
bud
|
||||
ankh
|
||||
*ankh:clay
|
||||
deletes=~
|
||||
changes=~
|
||||
^= changes
|
||||
%- my
|
||||
:~ [/lib/strand/hoon &+hoon+lib-strand]
|
||||
[/lib/strandio/hoon &+hoon+lib-strandio]
|
||||
[/sur/spider/hoon &+hoon+sur-spider]
|
||||
==
|
||||
file-store=~
|
||||
*ford-cache:fusion
|
||||
==
|
||||
@ -161,7 +254,7 @@
|
||||
/lib/strand/hoon
|
||||
/sur/spider/hoon
|
||||
==
|
||||
!> dez:(~(got by vases.cache.nub) /lib/strandio/hoon)
|
||||
!> dez:(~(got by files.cache.nub) /lib/strandio/hoon)
|
||||
==
|
||||
::
|
||||
:: |utilities: helper functions for testing
|
||||
|
@ -2360,7 +2360,6 @@
|
||||
++ mash !!
|
||||
++ pact !!
|
||||
++ vale |=(=noun !>(;;(json noun)))
|
||||
++ volt !!
|
||||
--
|
||||
::
|
||||
?> =(%j view)
|
||||
|
@ -170,11 +170,15 @@
|
||||
%+ expect-eq
|
||||
!> [%o (molt props)]
|
||||
!> (pairs props)
|
||||
:: sect - stored as integer number of seconds since the unix epoch
|
||||
%+ expect-eq
|
||||
!> [%n '1']
|
||||
!> (sect ~1970.1.1..0.0.1)
|
||||
:: time - stored as integer number of milliseconds since the unix epoch
|
||||
::
|
||||
%+ expect-eq
|
||||
!> [%n '1000']
|
||||
!> (time ~1970.1.1..0.0.1)
|
||||
!> [%n '1000']
|
||||
!> (time ~1970.1.1..0.0.1)
|
||||
:: ship - store ship identity as a string
|
||||
::
|
||||
%+ expect-eq
|
||||
|
@ -129,6 +129,30 @@
|
||||
!> -.b
|
||||
==
|
||||
::
|
||||
++ test-ordered-map-traverse-delete-all ^- tang
|
||||
;: weld
|
||||
=/ q ((ordered-map ,@ ,~) lte)
|
||||
=/ o (gas:q ~ ~[1/~ 2/~ 3/~])
|
||||
=/ b ((traverse:q ,~) o ~ |=([~ key=@ ~] [~ %| ~]))
|
||||
%+ expect-eq
|
||||
!> [~ ~]
|
||||
!> b
|
||||
::
|
||||
=/ c
|
||||
:~ [[2.127 1] ~] [[2.127 2] ~] [[2.127 3] ~]
|
||||
[[2.127 7] ~] [[2.127 8] ~] [[2.127 9] ~]
|
||||
==
|
||||
=/ compare
|
||||
|= [[aa=@ ab=@] [ba=@ bb=@]]
|
||||
?:((lth aa ba) %.y ?:((gth aa ba) %.n (lte ab bb)))
|
||||
=/ q ((ordered-map ,[@ @] ,~) compare)
|
||||
=/ o (gas:q ~ c)
|
||||
=/ b ((traverse:q ,~) o ~ |=([~ key=[@ @] ~] [~ %| ~]))
|
||||
%+ expect-eq
|
||||
!> [~ ~]
|
||||
!> b
|
||||
==
|
||||
::
|
||||
++ test-ordered-map-uni ^- tang
|
||||
::
|
||||
=/ a=(tree [@ud @tas]) (gas:atom-map ~ (scag 4 test-items))
|
||||
|
@ -127,11 +127,11 @@ module.exports = {
|
||||
plugins: [
|
||||
new UrbitShipPlugin(urbitrc),
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.TUTORIAL_HOST': JSON.stringify('~hastuc-dibtux'),
|
||||
'process.env.TUTORIAL_HOST': JSON.stringify('~difmex-passed'),
|
||||
'process.env.TUTORIAL_GROUP': JSON.stringify('beginner-island'),
|
||||
'process.env.TUTORIAL_CHAT': JSON.stringify('chat-1704'),
|
||||
'process.env.TUTORIAL_BOOK': JSON.stringify('book-9695'),
|
||||
'process.env.TUTORIAL_LINKS': JSON.stringify('link-2827'),
|
||||
'process.env.TUTORIAL_CHAT': JSON.stringify('introduce-yourself-7010'),
|
||||
'process.env.TUTORIAL_BOOK': JSON.stringify('guides-9684'),
|
||||
'process.env.TUTORIAL_LINKS': JSON.stringify('community-articles-2143'),
|
||||
})
|
||||
|
||||
// new CleanWebpackPlugin(),
|
||||
|
@ -61,12 +61,12 @@ module.exports = {
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.LANDSCAPE_STREAM': JSON.stringify(process.env.LANDSCAPE_STREAM),
|
||||
'process.env.LANDSCAPE_SHORTHASH': JSON.stringify(GIT_DESC),
|
||||
'process.env.TUTORIAL_HOST': JSON.stringify('~hastuc-dibtux'),
|
||||
'process.env.TUTORIAL_HOST': JSON.stringify('~difmex-passed'),
|
||||
'process.env.TUTORIAL_GROUP': JSON.stringify('beginner-island'),
|
||||
'process.env.TUTORIAL_CHAT': JSON.stringify('chat-8401'),
|
||||
'process.env.TUTORIAL_BOOK': JSON.stringify('notebook-9148'),
|
||||
'process.env.TUTORIAL_LINKS': JSON.stringify('links-4353'),
|
||||
})
|
||||
'process.env.TUTORIAL_CHAT': JSON.stringify('introduce-yourself-7010'),
|
||||
'process.env.TUTORIAL_BOOK': JSON.stringify('guides-9684'),
|
||||
'process.env.TUTORIAL_LINKS': JSON.stringify('community-articles-2143'),
|
||||
}),
|
||||
// new HtmlWebpackPlugin({
|
||||
// title: 'Hot Module Replacement',
|
||||
// template: './public/index.html',
|
||||
|
63
pkg/interface/package-lock.json
generated
63
pkg/interface/package-lock.json
generated
@ -1439,9 +1439,9 @@
|
||||
"integrity": "sha512-kBzJueOoGDVF2knGt+Kf5ylvil6+V1qn8/RqAj1S6wUTnfUfAMRzDp4LQI2MxLI8Is0OG3XCErVSOUImU6R3lg=="
|
||||
},
|
||||
"@tlon/indigo-react": {
|
||||
"version": "1.2.17",
|
||||
"resolved": "https://registry.npmjs.org/@tlon/indigo-react/-/indigo-react-1.2.17.tgz",
|
||||
"integrity": "sha512-D53HDLbqkRX3nY5zcXv8DRHw7FhsCGYfY3xa8CbaFfhFupdXBHi96UURi9Qq3sBc4FHgnPj45eJflji7Yj3gYg==",
|
||||
"version": "1.2.19",
|
||||
"resolved": "https://registry.npmjs.org/@tlon/indigo-react/-/indigo-react-1.2.19.tgz",
|
||||
"integrity": "sha512-lcHtPIbKeXVDvqd9dkCswB++CLRB2TsYFoegRU5VX3A886R+larJP81CzmoAwmZiJL3OnwypRklyfAv41F6W2w==",
|
||||
"requires": {
|
||||
"@reach/menu-button": "^0.10.5",
|
||||
"react": "^16.13.1",
|
||||
@ -1775,6 +1775,7 @@
|
||||
"version": "file:../npm/api",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@types/lodash": "^4.14.168",
|
||||
"@urbit/eslint-config": "^1.0.0",
|
||||
"big-integer": "^1.6.48",
|
||||
"lodash": "^4.17.20"
|
||||
@ -1782,26 +1783,36 @@
|
||||
"dependencies": {
|
||||
"@babel/runtime": {
|
||||
"version": "7.12.5",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.5.tgz",
|
||||
"integrity": "sha512-plcc+hbExy3McchJCEQG3knOsuh3HH+Prx1P6cLIkET/0dLuQDEnrT+s27Axgc9bqfsmNUNHfscgMUdBpC9xfg==",
|
||||
"requires": {
|
||||
"regenerator-runtime": "^0.13.4"
|
||||
}
|
||||
},
|
||||
"@types/lodash": {
|
||||
"version": "4.14.168",
|
||||
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.168.tgz",
|
||||
"integrity": "sha512-oVfRvqHV/V6D1yifJbVRU3TMp8OT6o6BG+U9MkwuJ3U8/CsDHvalRpsxBqivn71ztOFZBTfJMvETbqHiaNSj7Q=="
|
||||
},
|
||||
"@urbit/eslint-config": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/@urbit/eslint-config/-/eslint-config-1.0.0.tgz",
|
||||
"integrity": "sha512-Xmzb6MvM7KorlPJEq/hURZZ4BHSVy/7CoQXWogsBSTv5MOZnMqwNKw6yt24k2AO/2UpHwjGptimaNLqFfesJbw=="
|
||||
},
|
||||
"big-integer": {
|
||||
"version": "1.6.48",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.48.tgz",
|
||||
"integrity": "sha512-j51egjPa7/i+RdiRuJbPdJ2FIUYYPhvYLjzoYbcMMm62ooO6F94fETG4MTs46zPAF9Brs04OajboA/qTGuz78w=="
|
||||
},
|
||||
"lodash": {
|
||||
"version": "4.17.20",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz",
|
||||
"integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA=="
|
||||
},
|
||||
"regenerator-runtime": {
|
||||
"version": "0.13.7",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz",
|
||||
"integrity": "sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew=="
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -2253,6 +2264,13 @@
|
||||
"url": "0.10.3",
|
||||
"uuid": "3.3.2",
|
||||
"xml2js": "0.4.19"
|
||||
},
|
||||
"dependencies": {
|
||||
"querystring": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz",
|
||||
"integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA="
|
||||
}
|
||||
}
|
||||
},
|
||||
"babel-eslint": {
|
||||
@ -6681,6 +6699,14 @@
|
||||
"requires": {
|
||||
"punycode": "1.3.2",
|
||||
"querystring": "0.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"querystring": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz",
|
||||
"integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -7432,9 +7458,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"querystring": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz",
|
||||
"integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA="
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.1.tgz",
|
||||
"integrity": "sha512-wkvS7mL/JMugcup3/rMitHmd9ecIGd2lhFhK9N3UUQ450h66d1r3Y9nvXzQAW1Lq+wyx61k/1pfKS5KuKiyEbg=="
|
||||
},
|
||||
"querystring-es3": {
|
||||
"version": "0.2.1",
|
||||
@ -9609,6 +9635,13 @@
|
||||
"requires": {
|
||||
"punycode": "1.3.2",
|
||||
"querystring": "0.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"querystring": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz",
|
||||
"integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA="
|
||||
}
|
||||
}
|
||||
},
|
||||
"url-parse": {
|
||||
@ -10367,6 +10400,14 @@
|
||||
"requires": {
|
||||
"punycode": "1.3.2",
|
||||
"querystring": "0.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"querystring": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz",
|
||||
"integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
"@reach/tabs": "^0.10.5",
|
||||
"@tlon/indigo-dark": "^1.0.6",
|
||||
"@tlon/indigo-light": "^1.0.6",
|
||||
"@tlon/indigo-react": "1.2.17",
|
||||
"@tlon/indigo-react": "^1.2.19",
|
||||
"@tlon/sigil-js": "^1.4.3",
|
||||
"@urbit/api": "file:../npm/api",
|
||||
"aws-sdk": "^2.830.0",
|
||||
@ -29,6 +29,7 @@
|
||||
"normalize-wheel": "1.0.1",
|
||||
"oembed-parser": "^1.4.5",
|
||||
"prop-types": "^15.7.2",
|
||||
"querystring": "^0.2.0",
|
||||
"react": "^16.14.0",
|
||||
"react-codemirror2": "^6.0.1",
|
||||
"react-dom": "^16.14.0",
|
||||
|
24
pkg/interface/src/logic/api/gcp.ts
Normal file
24
pkg/interface/src/logic/api/gcp.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import BaseApi from './base';
|
||||
import {StoreState} from '../store/type';
|
||||
import {GcpToken} from '../types/gcp-state';
|
||||
|
||||
|
||||
export default class GcpApi extends BaseApi<StoreState> {
|
||||
isConfigured() {
|
||||
return this.spider('noun', 'json', 'gcp-is-configured', {})
|
||||
.then((data) => {
|
||||
this.store.handleEvent({
|
||||
data
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getToken() {
|
||||
return this.spider('noun', 'gcp-token', 'gcp-get-token', {})
|
||||
.then((token) => {
|
||||
this.store.handleEvent({
|
||||
data: token
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
@ -10,6 +10,7 @@ import GroupsApi from './groups';
|
||||
import LaunchApi from './launch';
|
||||
import GraphApi from './graph';
|
||||
import S3Api from './s3';
|
||||
import GcpApi from './gcp';
|
||||
import { HarkApi } from './hark';
|
||||
import SettingsApi from './settings';
|
||||
|
||||
@ -20,6 +21,7 @@ export default class GlobalApi extends BaseApi<StoreState> {
|
||||
contacts = new ContactsApi(this.ship, this.channel, this.store);
|
||||
groups = new GroupsApi(this.ship, this.channel, this.store);
|
||||
launch = new LaunchApi(this.ship, this.channel, this.store);
|
||||
gcp = new GcpApi(this.ship, this.channel, this.store);
|
||||
s3 = new S3Api(this.ship, this.channel, this.store);
|
||||
graph = new GraphApi(this.ship, this.channel, this.store);
|
||||
hark = new HarkApi(this.ship, this.channel, this.store);
|
||||
|
67
pkg/interface/src/logic/lib/GcpClient.ts
Normal file
67
pkg/interface/src/logic/lib/GcpClient.ts
Normal file
@ -0,0 +1,67 @@
|
||||
// Very simple GCP Storage client.
|
||||
//
|
||||
// It's designed to match a subset of the S3 client upload API. The upload
|
||||
// function on S3 returns a ManagedUpload, which has a promise() method on
|
||||
// it. We don't care about any of the other methods on ManagedUpload, so we
|
||||
// just do the work in its promise() method.
|
||||
//
|
||||
import querystring from 'querystring';
|
||||
import {
|
||||
StorageAcl,
|
||||
StorageClient,
|
||||
StorageUpload,
|
||||
UploadParams,
|
||||
UploadResult
|
||||
} from './StorageClient';
|
||||
|
||||
|
||||
const ENDPOINT = 'storage.googleapis.com';
|
||||
|
||||
class GcpUpload implements StorageUpload {
|
||||
#params: UploadParams;
|
||||
#accessKey: string;
|
||||
|
||||
constructor(params: UploadParams, accessKey: string) {
|
||||
this.#params = params;
|
||||
this.#accessKey = accessKey;
|
||||
}
|
||||
|
||||
async promise(): UploadResult {
|
||||
const {Bucket, Key, ContentType, Body} = this.#params;
|
||||
const urlParams = {
|
||||
uploadType: 'media',
|
||||
name: Key,
|
||||
predefinedAcl: 'publicRead'
|
||||
};
|
||||
const url = `https://${ENDPOINT}/upload/storage/v1/b/${Bucket}/o?` +
|
||||
querystring.stringify(urlParams);
|
||||
const headers = new Headers();
|
||||
headers.append('Authorization', `Bearer ${this.#accessKey}`);
|
||||
headers.append('Content-Type', ContentType);
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
cache: 'default',
|
||||
headers,
|
||||
referrerPolicy: 'no-referrer',
|
||||
body: Body
|
||||
});
|
||||
if (!response.ok) {
|
||||
console.error('GcpClient server error', await response.json());
|
||||
throw new Error(`GcpClient: response ${response.status}`);
|
||||
}
|
||||
return {Location: `https://${ENDPOINT}/${Bucket}/${Key}`};
|
||||
}
|
||||
}
|
||||
|
||||
export default class GcpClient implements StorageClient {
|
||||
#accessKey: string;
|
||||
|
||||
constructor(accessKey: string) {
|
||||
this.#accessKey = accessKey;
|
||||
}
|
||||
|
||||
upload(params: UploadParams): StorageUpload {
|
||||
return new GcpUpload(params, this.#accessKey);
|
||||
}
|
||||
}
|
32
pkg/interface/src/logic/lib/StorageClient.ts
Normal file
32
pkg/interface/src/logic/lib/StorageClient.ts
Normal file
@ -0,0 +1,32 @@
|
||||
// Defines a StorageClient interface interoperable between S3 and GCP Storage.
|
||||
//
|
||||
|
||||
|
||||
// XX kind of gross. S3 needs 'public-read', GCP needs 'publicRead'.
|
||||
// Rather than write a wrapper around S3, we offer this field here, which
|
||||
// should always be passed, and will be replaced by 'publicRead' in the
|
||||
// GCP client.
|
||||
export enum StorageAcl {
|
||||
PublicRead = 'public-read'
|
||||
};
|
||||
|
||||
export interface UploadParams {
|
||||
Bucket: string; // the bucket to upload the object to
|
||||
Key: string; // the desired location within the bucket
|
||||
ContentType: string; // the object's mime-type
|
||||
ACL: StorageAcl; // ACL, always 'public-read'
|
||||
Body: File; // the object itself
|
||||
};
|
||||
|
||||
export interface UploadResult {
|
||||
Location: string;
|
||||
};
|
||||
|
||||
// Extra layer of indirection used by S3 client.
|
||||
export interface StorageUpload {
|
||||
promise(): Promise<UploadResult>;
|
||||
};
|
||||
|
||||
export interface StorageClient {
|
||||
upload(params: UploadParams): StorageUpload;
|
||||
};
|
141
pkg/interface/src/logic/lib/gcpManager.ts
Normal file
141
pkg/interface/src/logic/lib/gcpManager.ts
Normal file
@ -0,0 +1,141 @@
|
||||
// Singleton that manages GCP token state.
|
||||
//
|
||||
// To use:
|
||||
//
|
||||
// 1. call configure with a GlobalApi and GlobalStore.
|
||||
// 2. call start() to start the token refresh loop.
|
||||
//
|
||||
// If the ship has S3 credentials set, we don't try to get a token, but we keep
|
||||
// checking at regular intervals to see if they get unset. Otherwise, we try to
|
||||
// invoke the GCP token thread on the ship until it gives us an access token.
|
||||
// Once we have a token, we refresh it every hour or so, since it has an
|
||||
// intrinsic expiry.
|
||||
//
|
||||
//
|
||||
import GlobalApi from '../api/global';
|
||||
import GlobalStore from '../store/store';
|
||||
|
||||
|
||||
class GcpManager {
|
||||
#api: GlobalApi | null = null;
|
||||
#store: GlobalStore | null = null;
|
||||
|
||||
configure(api: GlobalApi, store: GlobalStore) {
|
||||
this.#api = api;
|
||||
this.#store = store;
|
||||
}
|
||||
|
||||
#running = false;
|
||||
#timeoutId: number | null = null;
|
||||
|
||||
start() {
|
||||
if (this.#running) {
|
||||
console.warn('GcpManager already running');
|
||||
return;
|
||||
}
|
||||
if (!this.#api || !this.#store) {
|
||||
console.error('GcpManager must have api and store set');
|
||||
return;
|
||||
}
|
||||
this.#running = true;
|
||||
this.refreshLoop();
|
||||
}
|
||||
|
||||
stop() {
|
||||
if (!this.#running) {
|
||||
console.warn('GcpManager already stopped');
|
||||
console.assert(this.#timeoutId === null);
|
||||
return;
|
||||
}
|
||||
this.#running = false;
|
||||
if (this.#timeoutId !== null) {
|
||||
clearTimeout(this.#timeoutId);
|
||||
this.#timeoutId = null;
|
||||
}
|
||||
}
|
||||
|
||||
restart() {
|
||||
if (this.#running) {
|
||||
this.stop();
|
||||
}
|
||||
this.start();
|
||||
}
|
||||
|
||||
#consecutiveFailures: number = 0;
|
||||
|
||||
private isConfigured() {
|
||||
return this.#store.state.storage.gcp.configured;
|
||||
}
|
||||
|
||||
private refreshLoop() {
|
||||
if (!this.isConfigured()) {
|
||||
this.#api.gcp.isConfigured()
|
||||
.then(() => {
|
||||
if (this.isConfigured() === undefined) {
|
||||
throw new Error("can't check whether GCP is configured?");
|
||||
}
|
||||
if (this.isConfigured()) {
|
||||
this.refreshLoop();
|
||||
} else {
|
||||
this.refreshAfter(10_000);
|
||||
}
|
||||
})
|
||||
.catch((reason) => {
|
||||
console.error('GcpManager failure; stopping.', reason);
|
||||
this.stop();
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.#api.gcp.getToken()
|
||||
.then(() => {
|
||||
const token = this.#store.state.storage.gcp?.token;
|
||||
if (token) {
|
||||
this.#consecutiveFailures = 0;
|
||||
const interval = this.refreshInterval(token.expiresIn);
|
||||
console.log('GcpManager got token; refreshing after', interval);
|
||||
this.refreshAfter(interval);
|
||||
} else {
|
||||
throw new Error('thread succeeded, but returned no token?');
|
||||
}
|
||||
})
|
||||
.catch((reason) => {
|
||||
this.#consecutiveFailures++;
|
||||
console.warn('GcpManager token refresh failed; retrying with backoff');
|
||||
this.refreshAfter(this.backoffInterval());
|
||||
});
|
||||
}
|
||||
|
||||
private refreshAfter(durationMs) {
|
||||
if (!this.#running) {
|
||||
return;
|
||||
}
|
||||
if (this.#timeoutId !== null) {
|
||||
console.warn('GcpManager already has a timeout set');
|
||||
return;
|
||||
}
|
||||
this.#timeoutId = setTimeout(() => {
|
||||
this.#timeoutId = null;
|
||||
this.refreshLoop();
|
||||
}, durationMs);
|
||||
}
|
||||
|
||||
private refreshInterval(expiresIn: number) {
|
||||
// Give ourselves a minute for processing delays, but never refresh sooner
|
||||
// than 30 minutes from now. (The expiry window should be about an hour.)
|
||||
return Math.max(30 * 60_000, expiresIn - 60_000);
|
||||
}
|
||||
|
||||
private backoffInterval() {
|
||||
// exponential backoff.
|
||||
const slotMs = 5_000;
|
||||
const maxSlot = 60; // 5 minutes
|
||||
const backoffSlots =
|
||||
Math.floor(Math.random() * Math.min(maxSlot, this.#consecutiveFailures));
|
||||
return slotMs * backoffSlots;
|
||||
}
|
||||
}
|
||||
|
||||
const instance = new GcpManager();
|
||||
Object.freeze(instance);
|
||||
|
||||
export default instance;
|
@ -79,7 +79,7 @@ const otherIndex = function(config) {
|
||||
messages: result('Messages', '/~landscape/messages', 'messages', null),
|
||||
logout: result('Log Out', '/~/logout', 'logout', null)
|
||||
};
|
||||
|
||||
other.push(result('Tutorial', '/?tutorial=true', 'tutorial', null));
|
||||
for(let cat of config.categories) {
|
||||
if(idx[cat]) {
|
||||
other.push(idx[cat]);
|
||||
|
@ -1,41 +0,0 @@
|
||||
import S3 from 'aws-sdk/clients/s3';
|
||||
|
||||
export default class S3Client {
|
||||
constructor() {
|
||||
this.s3 = null;
|
||||
|
||||
this.endpoint = '';
|
||||
this.accessKeyId = '';
|
||||
this.secretAccesskey = '';
|
||||
}
|
||||
|
||||
setCredentials(endpoint, accessKeyId, secretAccessKey) {
|
||||
this.endpoint = endpoint;
|
||||
this.accessKeyId = accessKeyId;
|
||||
this.secretAccessKey = secretAccessKey;
|
||||
|
||||
this.s3 = new S3({
|
||||
endpoint: endpoint,
|
||||
credentials: {
|
||||
accessKeyId: this.accessKeyId,
|
||||
secretAccessKey: this.secretAccessKey
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async upload(bucket, filename, buffer) {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: filename,
|
||||
Body: buffer,
|
||||
ACL: 'public-read',
|
||||
ContentType: buffer.type
|
||||
};
|
||||
|
||||
if(!this.s3) {
|
||||
throw new Error('S3 not initialized');
|
||||
}
|
||||
return this.s3.upload(params).promise();
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ export const TUTORIAL_GROUP = process.env.TUTORIAL_GROUP!;
|
||||
export const TUTORIAL_CHAT = process.env.TUTORIAL_CHAT!;
|
||||
export const TUTORIAL_BOOK = process.env.TUTORIAL_BOOK!;
|
||||
export const TUTORIAL_LINKS = process.env.TUTORIAL_LINKS!;
|
||||
export const TUTORIAL_GROUP_RESOURCE = `/ship/${TUTORIAL_HOST}/${TUTORIAL_GROUP}` ;
|
||||
|
||||
interface StepDetail {
|
||||
title: string;
|
||||
@ -26,7 +27,7 @@ interface StepDetail {
|
||||
|
||||
export function hasTutorialGroup(props: { associations: Associations }) {
|
||||
return (
|
||||
`/ship/${TUTORIAL_HOST}/${TUTORIAL_GROUP}` in props.associations.groups
|
||||
TUTORIAL_GROUP_RESOURCE in props.associations.groups
|
||||
);
|
||||
}
|
||||
|
||||
@ -90,7 +91,7 @@ export const progressDetails: Record<TutorialProgress, StepDetail> = {
|
||||
alignY: 'top',
|
||||
arrow: 'East',
|
||||
offsetX: MODAL_WIDTH + 24,
|
||||
offsetY: MODAL_HEIGHT / 2 - 8
|
||||
offsetY: 80,
|
||||
},
|
||||
channels: {
|
||||
title: 'Channels',
|
||||
@ -143,7 +144,7 @@ export const progressDetails: Record<TutorialProgress, StepDetail> = {
|
||||
alignY: 'top',
|
||||
alignX: 'left',
|
||||
arrow: 'North',
|
||||
offsetX: (MODAL_WIDTH / 2) - 16,
|
||||
offsetX: 0,
|
||||
offsetY: -48
|
||||
},
|
||||
profile: {
|
||||
@ -155,17 +156,17 @@ export const progressDetails: Record<TutorialProgress, StepDetail> = {
|
||||
alignX: 'right',
|
||||
arrow: 'South',
|
||||
offsetX: -300 + MODAL_WIDTH / 2,
|
||||
offsetY: -120 + MODAL_HEIGHT / 2
|
||||
offsetY: -60,
|
||||
},
|
||||
leap: {
|
||||
title: 'Leap',
|
||||
description:
|
||||
'Leap allows you to go to a specific channel, message, collection, profile or group simply by typing in a command or selecting a shortcut from the dropdown menu.',
|
||||
url: `/~profile/~${window.ship}`,
|
||||
alignY: 'top',
|
||||
alignX: 'left',
|
||||
arrow: 'North',
|
||||
offsetX: 0.3 *MODAL_HEIGHT,
|
||||
offsetY: -48
|
||||
}
|
||||
alignY: "top",
|
||||
alignX: "left",
|
||||
arrow: "North",
|
||||
offsetX: 76,
|
||||
offsetY: -48,
|
||||
},
|
||||
};
|
||||
|
@ -1,9 +1,16 @@
|
||||
import { useCallback, useMemo, useEffect, useRef, useState } from 'react';
|
||||
import { S3State } from '../../types/s3-update';
|
||||
import {
|
||||
GcpState,
|
||||
S3State,
|
||||
StorageState
|
||||
} from '../../types';
|
||||
import S3 from 'aws-sdk/clients/s3';
|
||||
import GcpClient from './GcpClient';
|
||||
import { StorageClient, StorageAcl } from './StorageClient';
|
||||
import { dateToDa, deSig } from './util';
|
||||
|
||||
export interface IuseS3 {
|
||||
|
||||
export interface IuseStorage {
|
||||
canUpload: boolean;
|
||||
upload: (file: File, bucket: string) => Promise<string>;
|
||||
uploadDefault: (file: File) => Promise<string>;
|
||||
@ -11,31 +18,43 @@ export interface IuseS3 {
|
||||
promptUpload: () => Promise<string | undefined>;
|
||||
}
|
||||
|
||||
const useS3 = (s3: S3State, { accept = '*' } = { accept: '*' }): IuseS3 => {
|
||||
const useStorage = ({gcp, s3}: StorageState,
|
||||
{ accept = '*' } = { accept: '*' }): IuseStorage => {
|
||||
const [uploading, setUploading] = useState(false);
|
||||
|
||||
const client = useRef<S3 | null>(null);
|
||||
const client = useRef<StorageClient | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!s3.credentials) {
|
||||
return;
|
||||
// prefer GCP if available, else use S3.
|
||||
if (gcp.token !== undefined) {
|
||||
client.current = new GcpClient(gcp.token.accessKey);
|
||||
} else {
|
||||
// XX ships currently always have S3 credentials, but the fields are all
|
||||
// set to '' if they are not configured.
|
||||
if (!s3.credentials ||
|
||||
!s3.credentials.accessKeyId ||
|
||||
!s3.credentials.secretAccessKey) {
|
||||
return;
|
||||
}
|
||||
client.current = new S3({
|
||||
credentials: s3.credentials,
|
||||
endpoint: s3.credentials.endpoint
|
||||
});
|
||||
}
|
||||
client.current = new S3({
|
||||
credentials: s3.credentials,
|
||||
endpoint: s3.credentials.endpoint
|
||||
});
|
||||
}, [s3.credentials]);
|
||||
}, [gcp.token, s3.credentials]);
|
||||
|
||||
const canUpload = useMemo(
|
||||
() =>
|
||||
(client && s3.credentials && s3.configuration.currentBucket !== '') || false,
|
||||
[s3.credentials, s3.configuration.currentBucket, client]
|
||||
((gcp.token || (s3.credentials && s3.credentials.accessKeyId &&
|
||||
s3.credentials.secretAccessKey)) &&
|
||||
s3.configuration.currentBucket !== '') || false,
|
||||
[s3.credentials, gcp.token, s3.configuration.currentBucket]
|
||||
);
|
||||
|
||||
const upload = useCallback(
|
||||
async (file: File, bucket: string) => {
|
||||
if (!client.current) {
|
||||
throw new Error('S3 not ready');
|
||||
if (client.current === null) {
|
||||
throw new Error('Storage not ready');
|
||||
}
|
||||
|
||||
const fileParts = file.name.split('.');
|
||||
@ -47,7 +66,7 @@ const useS3 = (s3: S3State, { accept = '*' } = { accept: '*' }): IuseS3 => {
|
||||
Bucket: bucket,
|
||||
Key: `${window.ship}/${timestamp}-${fileName}.${fileExtension}`,
|
||||
Body: file,
|
||||
ACL: 'public-read',
|
||||
ACL: StorageAcl.PublicRead,
|
||||
ContentType: file.type
|
||||
};
|
||||
|
||||
@ -67,7 +86,7 @@ const useS3 = (s3: S3State, { accept = '*' } = { accept: '*' }): IuseS3 => {
|
||||
throw new Error('current bucket not set');
|
||||
}
|
||||
return upload(file, s3.configuration.currentBucket);
|
||||
}, [s3]);
|
||||
}, [s3, upload]);
|
||||
|
||||
const promptUpload = useCallback(
|
||||
() => {
|
||||
@ -92,7 +111,7 @@ const useS3 = (s3: S3State, { accept = '*' } = { accept: '*' }): IuseS3 => {
|
||||
[uploadDefault]
|
||||
);
|
||||
|
||||
return { canUpload, upload, uploadDefault, uploading, promptUpload };
|
||||
return {canUpload, upload, uploadDefault, uploading, promptUpload};
|
||||
};
|
||||
|
||||
export default useS3;
|
||||
export default useStorage;
|
37
pkg/interface/src/logic/reducers/gcp-reducer.ts
Normal file
37
pkg/interface/src/logic/reducers/gcp-reducer.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import _ from 'lodash';
|
||||
import {StoreState} from '../store/type';
|
||||
import {GcpToken} from '../../types/gcp-state';
|
||||
|
||||
type GcpState = Pick<StoreState, 'gcp'>;
|
||||
|
||||
export default class GcpReducer<S extends GcpState>{
|
||||
reduce(json: Cage, state: S) {
|
||||
this.reduceConfigured(json, state);
|
||||
this.reduceToken(json, state);
|
||||
}
|
||||
|
||||
reduceConfigured(json, state) {
|
||||
let data = json['gcp-configured'];
|
||||
if (data !== undefined) {
|
||||
state.storage.gcp.configured = data;
|
||||
}
|
||||
}
|
||||
|
||||
reduceToken(json: Cage, state: S) {
|
||||
let data = json['gcp-token'];
|
||||
if (data) {
|
||||
this.setToken(data, state);
|
||||
}
|
||||
}
|
||||
|
||||
setToken(data: any, state: S) {
|
||||
if (this.isToken(data)) {
|
||||
state.storage.gcp.token = data;
|
||||
}
|
||||
}
|
||||
|
||||
isToken(token: any): token is GcpToken {
|
||||
return (typeof(token.accessKey) === 'string' &&
|
||||
typeof(token.expiresIn) === 'number');
|
||||
}
|
||||
}
|
@ -23,14 +23,14 @@ export default class S3Reducer<S extends S3State> {
|
||||
credentials(json: S3Update, state: S) {
|
||||
const data = _.get(json, 'credentials', false);
|
||||
if (data) {
|
||||
state.s3.credentials = data;
|
||||
state.storage.s3.credentials = data;
|
||||
}
|
||||
}
|
||||
|
||||
configuration(json: S3Update, state: S) {
|
||||
const data = _.get(json, 'configuration', false);
|
||||
if (data) {
|
||||
state.s3.configuration = {
|
||||
state.storage.s3.configuration = {
|
||||
buckets: new Set(data.buckets),
|
||||
currentBucket: data.currentBucket
|
||||
};
|
||||
@ -39,44 +39,44 @@ export default class S3Reducer<S extends S3State> {
|
||||
|
||||
currentBucket(json: S3Update, state: S) {
|
||||
const data = _.get(json, 'setCurrentBucket', false);
|
||||
if (data && state.s3) {
|
||||
state.s3.configuration.currentBucket = data;
|
||||
if (data && state.storage.s3) {
|
||||
state.storage.s3.configuration.currentBucket = data;
|
||||
}
|
||||
}
|
||||
|
||||
addBucket(json: S3Update, state: S) {
|
||||
const data = _.get(json, 'addBucket', false);
|
||||
if (data) {
|
||||
state.s3.configuration.buckets =
|
||||
state.s3.configuration.buckets.add(data);
|
||||
state.storage.s3.configuration.buckets =
|
||||
state.storage.s3.configuration.buckets.add(data);
|
||||
}
|
||||
}
|
||||
|
||||
removeBucket(json: S3Update, state: S) {
|
||||
const data = _.get(json, 'removeBucket', false);
|
||||
if (data) {
|
||||
state.s3.configuration.buckets.delete(data);
|
||||
state.storage.s3.configuration.buckets.delete(data);
|
||||
}
|
||||
}
|
||||
|
||||
endpoint(json: S3Update, state: S) {
|
||||
const data = _.get(json, 'setEndpoint', false);
|
||||
if (data && state.s3.credentials) {
|
||||
state.s3.credentials.endpoint = data;
|
||||
if (data && state.storage.s3.credentials) {
|
||||
state.storage.s3.credentials.endpoint = data;
|
||||
}
|
||||
}
|
||||
|
||||
accessKeyId(json: S3Update , state: S) {
|
||||
const data = _.get(json, 'setAccessKeyId', false);
|
||||
if (data && state.s3.credentials) {
|
||||
state.s3.credentials.accessKeyId = data;
|
||||
if (data && state.storage.s3.credentials) {
|
||||
state.storage.s3.credentials.accessKeyId = data;
|
||||
}
|
||||
}
|
||||
|
||||
secretAccessKey(json: S3Update, state: S) {
|
||||
const data = _.get(json, 'setSecretAccessKey', false);
|
||||
if (data && state.s3.credentials) {
|
||||
state.s3.credentials.secretAccessKey = data;
|
||||
if (data && state.storage.s3.credentials) {
|
||||
state.storage.s3.credentials.secretAccessKey = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,11 @@ export interface SettingsState {
|
||||
remoteContentPolicy: RemoteContentPolicy;
|
||||
leap: {
|
||||
categories: LeapCategories[];
|
||||
}
|
||||
};
|
||||
tutorial: {
|
||||
seen: boolean;
|
||||
joined?: number;
|
||||
};
|
||||
set: (fn: (state: SettingsState) => void) => void
|
||||
};
|
||||
|
||||
@ -59,6 +63,10 @@ const useSettingsState = create<SettingsStateZus>((set) => ({
|
||||
leap: {
|
||||
categories: leapCategories,
|
||||
},
|
||||
tutorial: {
|
||||
seen: false,
|
||||
joined: undefined
|
||||
},
|
||||
set: (fn: (state: SettingsState) => void) => set(produce(fn))
|
||||
}));
|
||||
|
||||
|
@ -16,6 +16,7 @@ import GroupReducer from '../reducers/group-update';
|
||||
import LaunchReducer from '../reducers/launch-update';
|
||||
import ConnectionReducer from '../reducers/connection';
|
||||
import SettingsReducer from '../reducers/settings-update';
|
||||
import GcpReducer from '../reducers/gcp-reducer';
|
||||
import { OrderedMap } from '../lib/OrderedMap';
|
||||
import { BigIntOrderedMap } from '../lib/BigIntOrderedMap';
|
||||
import { GroupViewReducer } from '../reducers/group-view';
|
||||
@ -29,6 +30,7 @@ export default class GlobalStore extends BaseStore<StoreState> {
|
||||
launchReducer = new LaunchReducer();
|
||||
connReducer = new ConnectionReducer();
|
||||
settingsReducer = new SettingsReducer();
|
||||
gcpReducer = new GcpReducer();
|
||||
|
||||
pastActions: Record<string, any> = {}
|
||||
|
||||
@ -70,12 +72,15 @@ export default class GlobalStore extends BaseStore<StoreState> {
|
||||
},
|
||||
weather: {},
|
||||
userLocation: null,
|
||||
s3: {
|
||||
configuration: {
|
||||
buckets: new Set(),
|
||||
currentBucket: ''
|
||||
storage: {
|
||||
gcp: {},
|
||||
s3: {
|
||||
configuration: {
|
||||
buckets: new Set(),
|
||||
currentBucket: ''
|
||||
},
|
||||
credentials: null
|
||||
},
|
||||
credentials: null
|
||||
},
|
||||
isContactPublic: false,
|
||||
contacts: {},
|
||||
@ -115,6 +120,7 @@ export default class GlobalStore extends BaseStore<StoreState> {
|
||||
HarkReducer(data, this.state);
|
||||
ContactReducer(data, this.state);
|
||||
this.settingsReducer.reduce(data);
|
||||
this.gcpReducer.reduce(data, this.state);
|
||||
GroupViewReducer(data, this.state);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import { Invites } from '@urbit/api/invite';
|
||||
import { Associations } from '@urbit/api/metadata';
|
||||
import { Rolodex } from '@urbit/api/contacts';
|
||||
import { Groups } from '@urbit/api/groups';
|
||||
import { S3State } from '~/types/s3-update';
|
||||
import { StorageState } from '~/types/storage-state';
|
||||
import { LaunchState, WeatherState } from '~/types/launch-update';
|
||||
import { ConnectionStatus } from '~/types/connection';
|
||||
import { Graphs } from '@urbit/api/graph';
|
||||
@ -31,7 +31,7 @@ export interface StoreState {
|
||||
groups: Groups;
|
||||
groupKeys: Set<Path>;
|
||||
nackedContacts: Set<Patp>
|
||||
s3: S3State;
|
||||
storage: StorageState;
|
||||
graphs: Graphs;
|
||||
graphKeys: Set<string>;
|
||||
|
||||
|
9
pkg/interface/src/types/gcp-state.ts
Normal file
9
pkg/interface/src/types/gcp-state.ts
Normal file
@ -0,0 +1,9 @@
|
||||
export interface GcpToken {
|
||||
accessKey: string;
|
||||
expiresIn: number;
|
||||
};
|
||||
|
||||
export interface GcpState {
|
||||
configured?: boolean;
|
||||
token?: GcpToken
|
||||
};
|
@ -3,6 +3,8 @@ export * from './connection';
|
||||
export * from './global';
|
||||
export * from './launch-update';
|
||||
export * from './local-update';
|
||||
export * from './storage-state';
|
||||
export * from './gcp-state';
|
||||
export * from './s3-update';
|
||||
export * from './workspace';
|
||||
export * from './util';
|
||||
|
8
pkg/interface/src/types/storage-state.ts
Normal file
8
pkg/interface/src/types/storage-state.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import {GcpState} from './gcp-state';
|
||||
import {S3State} from './s3-update';
|
||||
|
||||
|
||||
export interface StorageState {
|
||||
gcp: GcpState;
|
||||
s3: S3State;
|
||||
};
|
@ -27,6 +27,7 @@ import GlobalSubscription from '~/logic/subscription/global';
|
||||
import GlobalApi from '~/logic/api/global';
|
||||
import { uxToHex } from '~/logic/lib/util';
|
||||
import { foregroundFromBackground } from '~/logic/lib/sigil';
|
||||
import gcpManager from '~/logic/lib/gcpManager';
|
||||
import { withLocalState } from '~/logic/state/local';
|
||||
import { withSettingsState } from '~/logic/state/settings';
|
||||
|
||||
@ -78,6 +79,7 @@ class App extends React.Component {
|
||||
|
||||
this.appChannel = new window.channel();
|
||||
this.api = new GlobalApi(this.ship, this.appChannel, this.store);
|
||||
gcpManager.configure(this.api, this.store);
|
||||
this.subscription =
|
||||
new GlobalSubscription(this.store, this.api, this.appChannel);
|
||||
|
||||
@ -97,6 +99,7 @@ class App extends React.Component {
|
||||
this.api.local.getBaseHash();
|
||||
this.api.settings.getAll();
|
||||
this.store.rehydrate();
|
||||
gcpManager.start();
|
||||
Mousetrap.bindGlobal(['command+/', 'ctrl+/'], (e) => {
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
|
@ -13,7 +13,6 @@ import { ShareProfile } from '~/views/apps/chat/components/ShareProfile';
|
||||
import SubmitDragger from '~/views/components/SubmitDragger';
|
||||
import { useLocalStorageState } from '~/logic/lib/useLocalStorageState';
|
||||
import { Loading } from '~/views/components/Loading';
|
||||
import useS3 from '~/logic/lib/useS3';
|
||||
import { isWriter, resourceFromPath } from '~/logic/lib/group';
|
||||
|
||||
import './css/custom.css';
|
||||
@ -179,7 +178,7 @@ export function ChatResource(props: ChatResourceProps) {
|
||||
(!showBanner && hasLoadedAllowed) ? contacts : modifiedContacts
|
||||
}
|
||||
onUnmount={appendUnsent}
|
||||
s3={props.s3}
|
||||
storage={props.storage}
|
||||
placeholder="Message..."
|
||||
message={unsent[station] || ''}
|
||||
deleteMessage={clearUnsent}
|
||||
|
@ -1,18 +1,19 @@
|
||||
import React, { Component } from 'react';
|
||||
import ChatEditor from './chat-editor';
|
||||
import { IuseS3 } from '~/logic/lib/useS3';
|
||||
import { IuseStorage } from '~/logic/lib/useStorage';
|
||||
import { uxToHex } from '~/logic/lib/util';
|
||||
import { Sigil } from '~/logic/lib/sigil';
|
||||
import { createPost } from '~/logic/api/graph';
|
||||
import tokenizeMessage, { isUrl } from '~/logic/lib/tokenizeMessage';
|
||||
import GlobalApi from '~/logic/api/global';
|
||||
import { Envelope } from '~/types/chat-update';
|
||||
import { StorageState } from '~/types';
|
||||
import { Contacts, Content } from '@urbit/api';
|
||||
import { Row, BaseImage, Box, Icon, LoadingSpinner } from '@tlon/indigo-react';
|
||||
import withS3 from '~/views/components/withS3';
|
||||
import withStorage from '~/views/components/withStorage';
|
||||
import { withLocalState } from '~/logic/state/local';
|
||||
|
||||
type ChatInputProps = IuseS3 & {
|
||||
type ChatInputProps = IuseStorage & {
|
||||
api: GlobalApi;
|
||||
numMsgs: number;
|
||||
station: unknown;
|
||||
@ -20,7 +21,7 @@ type ChatInputProps = IuseS3 & {
|
||||
envelopes: Envelope[];
|
||||
contacts: Contacts;
|
||||
onUnmount(msg: string): void;
|
||||
s3: unknown;
|
||||
storage: StorageState;
|
||||
placeholder: string;
|
||||
message: string;
|
||||
deleteMessage(): void;
|
||||
@ -128,13 +129,14 @@ class ChatInput extends Component<ChatInputProps, ChatInputState> {
|
||||
|
||||
const avatar = (
|
||||
props.ourContact &&
|
||||
((props.ourContact.avatar !== null) && !props.hideAvatars)
|
||||
((props.ourContact?.avatar) && !props.hideAvatars)
|
||||
)
|
||||
? <BaseImage
|
||||
src={props.ourContact.avatar}
|
||||
height={16}
|
||||
width={16}
|
||||
? <BaseImage
|
||||
src={props.ourContact.avatar}
|
||||
height={16}
|
||||
width={16}
|
||||
style={{ objectFit: 'cover' }}
|
||||
borderRadius={1}
|
||||
display='inline-block'
|
||||
/>
|
||||
: <Sigil
|
||||
@ -206,4 +208,4 @@ class ChatInput extends Component<ChatInputProps, ChatInputState> {
|
||||
}
|
||||
}
|
||||
|
||||
export default withLocalState(withS3(ChatInput, { accept: 'image/*' }), ['hideAvatars']);
|
||||
export default withLocalState(withStorage(ChatInput, { accept: 'image/*' }), ['hideAvatars']);
|
||||
|
@ -298,6 +298,7 @@ export const MessageAuthor = ({
|
||||
src={contact.avatar}
|
||||
height={16}
|
||||
width={16}
|
||||
borderRadius={1}
|
||||
/>
|
||||
) : (
|
||||
<Sigil
|
||||
|
@ -13,6 +13,7 @@ import Tile from './components/tiles/tile';
|
||||
import Groups from './components/Groups';
|
||||
import ModalButton from './components/ModalButton';
|
||||
import { StatelessAsyncButton } from '~/views/components/StatelessAsyncButton';
|
||||
import { StarIcon } from '~/views/components/StarIcon';
|
||||
import { writeText } from '~/logic/lib/util';
|
||||
import { useModal } from "~/logic/lib/useModal";
|
||||
import { NewGroup } from "~/views/landscape/components/NewGroup";
|
||||
@ -45,6 +46,7 @@ const tutSelector = f.pick(['tutorialProgress', 'nextTutStep', 'hideGroups']);
|
||||
export default function LaunchApp(props) {
|
||||
const history = useHistory();
|
||||
const [hashText, setHashText] = useState(props.baseHash);
|
||||
const [exitingTut, setExitingTut] = useState(false);
|
||||
const hashBox = (
|
||||
<Box
|
||||
position={["relative", "absolute"]}
|
||||
@ -103,10 +105,11 @@ export default function LaunchApp(props) {
|
||||
e.stopPropagation();
|
||||
if(!hasTutorialGroup(props)) {
|
||||
await props.api.groups.join(TUTORIAL_HOST, TUTORIAL_GROUP);
|
||||
await props.api.settings.putEntry('tutorial', 'joined', Date.now());
|
||||
await waiter(hasTutorialGroup);
|
||||
await Promise.all(
|
||||
[TUTORIAL_BOOK, TUTORIAL_CHAT, TUTORIAL_LINKS].map(graph =>
|
||||
props.api.graph.join(TUTORIAL_HOST, graph)));
|
||||
props.api.graph.joinGraph(TUTORIAL_HOST, graph)));
|
||||
|
||||
await waiter(p => {
|
||||
return `/ship/${TUTORIAL_HOST}/${TUTORIAL_CHAT}` in p.associations.graph &&
|
||||
@ -117,26 +120,39 @@ export default function LaunchApp(props) {
|
||||
nextTutStep();
|
||||
dismiss();
|
||||
}
|
||||
return (
|
||||
<Col maxWidth="350px" gapY="2" p="3">
|
||||
<Box position="absolute" left="-16px" top="-16px">
|
||||
<Icon width="32px" height="32px" color="blue" display="block" icon="LargeBullet" />
|
||||
</Box>
|
||||
<Text lineHeight="tall" fontWeight="medium">Welcome</Text>
|
||||
<Text lineHeight="tall">
|
||||
You have been invited to use Landscape, an interface to chat
|
||||
and interact with communities
|
||||
<br />
|
||||
Would you like a tour of Landscape?
|
||||
</Text>
|
||||
<Row gapX="2" justifyContent="flex-end">
|
||||
<Button backgroundColor="washedGray" onClick={onDismiss}>Skip</Button>
|
||||
<StatelessAsyncButton primary onClick={onContinue}>
|
||||
Yes
|
||||
</StatelessAsyncButton>
|
||||
</Row>
|
||||
</Col>
|
||||
)}
|
||||
return exitingTut ? (
|
||||
<Col maxWidth="350px" p="3">
|
||||
<Icon icon="Info" fill="black"></Icon>
|
||||
<Text my="3" lineHeight="tall">
|
||||
You can always restart the tutorial by typing "tutorial" in Leap
|
||||
</Text>
|
||||
<Row gapX="2" justifyContent="flex-end">
|
||||
<Button primary onClick={onDismiss}>Ok</Button>
|
||||
</Row>
|
||||
</Col>
|
||||
) : (
|
||||
<Col maxWidth="350px" p="3">
|
||||
<Box position="absolute" left="-16px" top="-16px">
|
||||
<StarIcon width="32px" height="32px" color="blue" display="block" />
|
||||
</Box>
|
||||
<Text mb="3" lineHeight="tall" fontWeight="medium">Welcome</Text>
|
||||
<Text mb="3" lineHeight="tall">
|
||||
You have been invited to use Landscape, an interface to chat
|
||||
and interact with communities
|
||||
<br />
|
||||
Would you like a tour of Landscape?
|
||||
</Text>
|
||||
<Row gapX="2" justifyContent="flex-end">
|
||||
<Button
|
||||
backgroundColor="washedGray"
|
||||
onClick={() => setExitingTut(true)}
|
||||
>Skip</Button>
|
||||
<StatelessAsyncButton primary onClick={onContinue}>
|
||||
Yes
|
||||
</StatelessAsyncButton>
|
||||
</Row>
|
||||
</Col>
|
||||
)}
|
||||
});
|
||||
const hasLoaded = useMemo(() => Object.keys(props.contacts).length > 0, [props.contacts]);
|
||||
|
||||
|
@ -2,21 +2,26 @@ import React, { useRef } from 'react';
|
||||
import { Box, Text, Col } from '@tlon/indigo-react';
|
||||
import f from 'lodash/fp';
|
||||
import _ from 'lodash';
|
||||
import moment from 'moment';
|
||||
|
||||
import { Associations, Association, Unreads, UnreadStats } from '@urbit/api';
|
||||
import { alphabeticalOrder } from '~/logic/lib/util';
|
||||
import { getUnreadCount, getNotificationCount } from '~/logic/lib/hark';
|
||||
import Tile from '../components/tiles/tile';
|
||||
import { useTutorialModal } from '~/views/components/useTutorialModal';
|
||||
import { TUTORIAL_HOST, TUTORIAL_GROUP } from '~/logic/lib/tutorialModal';
|
||||
import useSettingsState, { selectCalmState } from '~/logic/state/settings';
|
||||
import { TUTORIAL_HOST, TUTORIAL_GROUP, TUTORIAL_GROUP_RESOURCE } from '~/logic/lib/tutorialModal';
|
||||
import useSettingsState, { selectCalmState, SettingsState } from '~/logic/state/settings';
|
||||
|
||||
interface GroupsProps {
|
||||
associations: Associations;
|
||||
}
|
||||
|
||||
const sortGroupsAlph = (a: Association, b: Association) =>
|
||||
alphabeticalOrder(a.metadata.title, b.metadata.title);
|
||||
a.group === TUTORIAL_GROUP_RESOURCE
|
||||
? -1
|
||||
: b.group === TUTORIAL_GROUP_RESOURCE
|
||||
? 1
|
||||
: alphabeticalOrder(a.metadata.title, b.metadata.title);
|
||||
|
||||
const getGraphUnreads = (associations: Associations, unreads: Unreads) => (path: string) =>
|
||||
f.flow(
|
||||
@ -72,6 +77,7 @@ interface GroupProps {
|
||||
unreads: number;
|
||||
first: boolean;
|
||||
}
|
||||
const selectJoined = (s: SettingsState) => s.tutorial.joined;
|
||||
function Group(props: GroupProps) {
|
||||
const { path, title, unreads, updates, first = false } = props;
|
||||
const anchorRef = useRef<HTMLElement>(null);
|
||||
@ -79,14 +85,18 @@ function Group(props: GroupProps) {
|
||||
useTutorialModal(
|
||||
'start',
|
||||
isTutorialGroup,
|
||||
anchorRef.current
|
||||
anchorRef
|
||||
);
|
||||
const { hideUnreads } = useSettingsState(selectCalmState)
|
||||
const joined = useSettingsState(selectJoined);
|
||||
return (
|
||||
<Tile ref={anchorRef} position="relative" bg={isTutorialGroup ? 'lightBlue' : undefined} to={`/~landscape${path}`} gridColumnStart={first ? '1' : null}>
|
||||
<Col height="100%" justifyContent="space-between">
|
||||
<Text>{title}</Text>
|
||||
{!hideUnreads && (<Col>
|
||||
{isTutorialGroup && joined &&
|
||||
(<Text>{Math.floor(moment.duration(moment(joined).add(14, 'days').diff(moment())).as('days'))} days remaining</Text>)
|
||||
}
|
||||
{updates > 0 &&
|
||||
(<Text mt="1" color="blue">{updates} update{updates !== 1 && 's'} </Text>)
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ export function LinkResource(props: LinkResourceProps) {
|
||||
associations,
|
||||
graphKeys,
|
||||
unreads,
|
||||
s3,
|
||||
storage,
|
||||
history
|
||||
} = props;
|
||||
|
||||
@ -69,7 +69,7 @@ export function LinkResource(props: LinkResourceProps) {
|
||||
return (
|
||||
<LinkWindow
|
||||
key={rid}
|
||||
s3={s3}
|
||||
storage={storage}
|
||||
association={resource}
|
||||
contacts={contacts}
|
||||
resource={resourcePath}
|
||||
|
@ -15,7 +15,7 @@ import VirtualScroller from '~/views/components/VirtualScroller';
|
||||
import { LinkItem } from './components/LinkItem';
|
||||
import LinkSubmit from './components/LinkSubmit';
|
||||
import { isWriter } from '~/logic/lib/group';
|
||||
import { S3State } from '~/types/s3-update';
|
||||
import { StorageState } from '~/types';
|
||||
|
||||
interface LinkWindowProps {
|
||||
association: Association;
|
||||
@ -29,7 +29,7 @@ interface LinkWindowProps {
|
||||
group: Group;
|
||||
path: string;
|
||||
api: GlobalApi;
|
||||
s3: S3State;
|
||||
storage: StorageState;
|
||||
}
|
||||
export function LinkWindow(props: LinkWindowProps) {
|
||||
const { graph, api, association } = props;
|
||||
@ -57,7 +57,7 @@ export function LinkWindow(props: LinkWindowProps) {
|
||||
return (
|
||||
<Col key={0} mx="auto" mt="4" maxWidth="768px" width="100%" flexShrink={0} px={3}>
|
||||
{ canWrite ? (
|
||||
<LinkSubmit s3={props.s3} name={name} ship={ship.slice(1)} api={api} />
|
||||
<LinkSubmit storage={props.storage} name={name} ship={ship.slice(1)} api={api} />
|
||||
) : (
|
||||
<Text>There are no links here yet. You do not have permission to post to this collection.</Text>
|
||||
)
|
||||
@ -89,7 +89,7 @@ return null;
|
||||
return (
|
||||
<React.Fragment key={index.toString()}>
|
||||
<Col key={index.toString()} mx="auto" mt="4" maxWidth="768px" width="100%" flexShrink={0} px={3}>
|
||||
<LinkSubmit s3={props.s3} name={name} ship={ship.slice(1)} api={api} />
|
||||
<LinkSubmit storage={props.storage} name={name} ship={ship.slice(1)} api={api} />
|
||||
</Col>
|
||||
<LinkItem {...linkProps} />
|
||||
</React.Fragment>
|
||||
|
@ -2,21 +2,22 @@ import { BaseInput, Box, Button, LoadingSpinner, Text } from '@tlon/indigo-react
|
||||
import React, { useCallback, useState } from 'react';
|
||||
import GlobalApi from '~/logic/api/global';
|
||||
import { useFileDrag } from '~/logic/lib/useDrag';
|
||||
import useS3 from '~/logic/lib/useS3';
|
||||
import { S3State } from '@urbit/api';
|
||||
import useStorage from '~/logic/lib/useStorage';
|
||||
import { StorageState } from '~/types';
|
||||
import SubmitDragger from '~/views/components/SubmitDragger';
|
||||
import { createPost } from '~/logic/api/graph';
|
||||
import { hasProvider } from 'oembed-parser';
|
||||
|
||||
interface LinkSubmitProps {
|
||||
api: GlobalApi;
|
||||
s3: S3State;
|
||||
storage: StorageState;
|
||||
name: string;
|
||||
ship: string;
|
||||
}
|
||||
|
||||
const LinkSubmit = (props: LinkSubmitProps) => {
|
||||
const { canUpload, uploadDefault, uploading, promptUpload } = useS3(props.s3);
|
||||
const { canUpload, uploadDefault, uploading, promptUpload } =
|
||||
useStorage(props.storage);
|
||||
|
||||
const [submitFocused, setSubmitFocused] = useState(false);
|
||||
const [urlFocused, setUrlFocused] = useState(false);
|
||||
|
@ -51,7 +51,7 @@ export default function NotificationsScreen(props: any): ReactElement {
|
||||
.map(g => props.associations?.groups?.[g]?.metadata?.title)
|
||||
.join(', ');
|
||||
const anchorRef = useRef<HTMLElement | null>(null);
|
||||
useTutorialModal('notifications', true, anchorRef.current);
|
||||
useTutorialModal('notifications', true, anchorRef);
|
||||
return (
|
||||
<Switch>
|
||||
<Route
|
||||
@ -74,7 +74,8 @@ export default function NotificationsScreen(props: any): ReactElement {
|
||||
borderBottom="1"
|
||||
borderBottomColor="washedGray"
|
||||
>
|
||||
<Text>Updates</Text>
|
||||
|
||||
<Text ref={anchorRef}>Notifications</Text>
|
||||
<Row
|
||||
justifyContent="space-between"
|
||||
>
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React, { ReactElement } from 'react';
|
||||
import React, { ReactElement, useRef, useState } from 'react';
|
||||
import * as Yup from 'yup';
|
||||
import _ from 'lodash';
|
||||
import { Formik } from 'formik';
|
||||
@ -11,6 +11,7 @@ import {
|
||||
Col,
|
||||
Text,
|
||||
Row,
|
||||
Button
|
||||
} from '@tlon/indigo-react';
|
||||
|
||||
import { uxToHex } from '~/logic/lib/util';
|
||||
@ -20,6 +21,12 @@ import { ImageInput } from '~/views/components/ImageInput';
|
||||
import { MarkdownField } from '~/views/apps/publish/components/MarkdownField';
|
||||
import { resourceFromPath } from '~/logic/lib/group';
|
||||
import GroupSearch from '~/views/components/GroupSearch';
|
||||
import {
|
||||
ProfileHeader,
|
||||
ProfileControls,
|
||||
ProfileStatus,
|
||||
ProfileImages
|
||||
} from './Profile';
|
||||
|
||||
const formSchema = Yup.object({
|
||||
nickname: Yup.string(),
|
||||
@ -33,57 +40,91 @@ const emptyContact = {
|
||||
bio: '',
|
||||
status: '',
|
||||
color: '0',
|
||||
avatar: null,
|
||||
cover: null,
|
||||
avatar: '',
|
||||
cover: '',
|
||||
groups: [],
|
||||
'last-updated': 0,
|
||||
isPublic: false
|
||||
};
|
||||
|
||||
export function ProfileHeaderImageEdit(props: any): ReactElement {
|
||||
const { contact, storage, setFieldValue, handleHideCover } = { ...props };
|
||||
const [editCover, setEditCover] = useState(false);
|
||||
const [removedCoverLabel, setRemovedCoverLabel] = useState('Remove Header');
|
||||
const handleClear = (e) => {
|
||||
e.preventDefault();
|
||||
handleHideCover(true);
|
||||
setFieldValue('cover', '');
|
||||
setRemovedCoverLabel('Header Removed');
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{contact?.cover ? (
|
||||
<div>
|
||||
{editCover ? (
|
||||
<ImageInput id='cover' storage={storage} marginTop='-8px' />
|
||||
) : (
|
||||
<Row>
|
||||
<Button mr='2' onClick={() => setEditCover(true)}>
|
||||
Replace Header
|
||||
</Button>
|
||||
<Button onClick={(e) => handleClear(e)}>
|
||||
{removedCoverLabel}
|
||||
</Button>
|
||||
</Row>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<ImageInput id='cover' storage={storage} marginTop='-8px' />
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function EditProfile(props: any): ReactElement {
|
||||
const { contact, ship, api, isPublic } = props;
|
||||
const { contact, storage, ship, api, isPublic } = props;
|
||||
const [hideCover, setHideCover] = useState(false);
|
||||
|
||||
const handleHideCover = (value) => {
|
||||
setHideCover(value);
|
||||
};
|
||||
|
||||
const history = useHistory();
|
||||
if (contact) {
|
||||
contact.isPublic = isPublic;
|
||||
}
|
||||
|
||||
const onSubmit = async (values: any, actions: any) => {
|
||||
console.log(values);
|
||||
try {
|
||||
await Object.keys(values).reduce((acc, key) => {
|
||||
console.log(key);
|
||||
const newValue = key !== 'color' ? values[key] : uxToHex(values[key]);
|
||||
|
||||
if (newValue !== contact[key]) {
|
||||
if (key === 'isPublic') {
|
||||
return acc.then(() =>
|
||||
api.contacts.setPublic(newValue)
|
||||
);
|
||||
return acc.then(() => api.contacts.setPublic(newValue));
|
||||
} else if (key === 'groups') {
|
||||
const toRemove: string[] = _.difference(contact?.groups || [], newValue);
|
||||
console.log(toRemove);
|
||||
const toAdd: string[] = _.difference(newValue, contact?.groups || []);
|
||||
console.log(toAdd);
|
||||
const toRemove: string[] = _.difference(
|
||||
contact?.groups || [],
|
||||
newValue
|
||||
);
|
||||
const toAdd: string[] = _.difference(
|
||||
newValue,
|
||||
contact?.groups || []
|
||||
);
|
||||
const promises: Promise<any>[] = [];
|
||||
|
||||
promises.concat(
|
||||
toRemove.map(e =>
|
||||
toRemove.map((e) =>
|
||||
api.contacts.edit(ship, { 'remove-group': resourceFromPath(e) })
|
||||
)
|
||||
);
|
||||
promises.concat(
|
||||
toAdd.map(e =>
|
||||
toAdd.map((e) =>
|
||||
api.contacts.edit(ship, { 'add-group': resourceFromPath(e) })
|
||||
)
|
||||
);
|
||||
return acc.then(() => Promise.all(promises));
|
||||
} else if (
|
||||
key !== 'last-updated' &&
|
||||
key !== 'isPublic'
|
||||
) {
|
||||
return acc.then(() =>
|
||||
api.contacts.edit(ship, { [key]: newValue })
|
||||
);
|
||||
} else if (key !== 'last-updated' && key !== 'isPublic') {
|
||||
return acc.then(() => api.contacts.edit(ship, { [key]: newValue }));
|
||||
}
|
||||
}
|
||||
return acc;
|
||||
@ -103,28 +144,78 @@ export function EditProfile(props: any): ReactElement {
|
||||
initialValues={contact || emptyContact}
|
||||
onSubmit={onSubmit}
|
||||
>
|
||||
<Form width="100%" height="100%" p={2}>
|
||||
<Input id="nickname" label="Name" mb={3} />
|
||||
<Col width="100%">
|
||||
<Text mb={2}>Description</Text>
|
||||
<MarkdownField id="bio" mb={3} s3={props.s3} />
|
||||
</Col>
|
||||
<ColorInput id="color" label="Sigil Color" mb={3} />
|
||||
<Row mb={3} width="100%">
|
||||
<Col pr={2} width="50%">
|
||||
<ImageInput id="cover" label="Cover Image" s3={props.s3} />
|
||||
</Col>
|
||||
<Col pl={2} width="50%">
|
||||
<ImageInput id="avatar" label="Profile Image" s3={props.s3} />
|
||||
</Col>
|
||||
</Row>
|
||||
<Checkbox mb={3} id="isPublic" label="Public Profile" />
|
||||
<GroupSearch label="Pinned Groups" id="groups" groups={props.groups} associations={props.associations} publicOnly />
|
||||
<AsyncButton primary loadingText="Updating..." border mt={3}>
|
||||
Submit
|
||||
</AsyncButton>
|
||||
</Form>
|
||||
</Formik>
|
||||
</>
|
||||
{({ setFieldValue }) => (
|
||||
<Form width='100%' height='100%'>
|
||||
<ProfileHeader>
|
||||
<ProfileControls>
|
||||
<Row>
|
||||
<Button
|
||||
type='submit'
|
||||
display='inline'
|
||||
cursor='pointer'
|
||||
fontWeight='500'
|
||||
color='blue'
|
||||
pl='0'
|
||||
pr='0'
|
||||
border='0'
|
||||
style={{ appearance: 'none', background: 'transparent' }}
|
||||
>
|
||||
Save Edits
|
||||
</Button>
|
||||
<Text
|
||||
py='2'
|
||||
ml='3'
|
||||
fontWeight='500'
|
||||
cursor='pointer'
|
||||
onClick={() => {
|
||||
history.push(`/~profile/${ship}`);
|
||||
}}
|
||||
>
|
||||
Cancel
|
||||
</Text>
|
||||
</Row>
|
||||
<ProfileStatus contact={contact} />
|
||||
</ProfileControls>
|
||||
<ProfileImages hideCover={hideCover} contact={contact} ship={ship}>
|
||||
<ProfileHeaderImageEdit
|
||||
contact={contact}
|
||||
storage={storage}
|
||||
setFieldValue={setFieldValue}
|
||||
handleHideCover={handleHideCover}
|
||||
/>
|
||||
</ProfileImages>
|
||||
</ProfileHeader>
|
||||
<Row mb={3} pt={5} width='100%'>
|
||||
<Col pr={2} width='25%'>
|
||||
<ColorInput id='color' label='Sigil Color' />
|
||||
</Col>
|
||||
<Col pl={2} width='75%'>
|
||||
<ImageInput
|
||||
id='avatar'
|
||||
label='Overlay Avatar (may be hidden by other users)'
|
||||
storage={storage}
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
<Input id='nickname' label='Custom Name' mb={3} />
|
||||
<Col width='100%'>
|
||||
<Text mb={2}>Description</Text>
|
||||
<MarkdownField id='bio' mb={3} storage={storage} />
|
||||
</Col>
|
||||
<Checkbox mb={3} id='isPublic' label='Public Profile' />
|
||||
<GroupSearch
|
||||
label='Pinned Groups'
|
||||
id='groups'
|
||||
groups={props.groups}
|
||||
associations={props.associations}
|
||||
publicOnly
|
||||
/>
|
||||
<AsyncButton primary loadingText='Updating...' border mt={3}>
|
||||
Submit
|
||||
</AsyncButton>
|
||||
</Form>
|
||||
)}
|
||||
</Formik>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
@ -1,16 +1,8 @@
|
||||
import React, { ReactElement, useEffect, useRef, useState } from 'react';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
import {
|
||||
Center,
|
||||
Box,
|
||||
Row,
|
||||
BaseImage,
|
||||
Text
|
||||
} from "@tlon/indigo-react";
|
||||
|
||||
import RichText from '~/views/components/RichText'
|
||||
import useSettingsState, {selectCalmState} from "~/logic/state/settings";
|
||||
import { Center, Box, Row, BaseImage, Text } from '@tlon/indigo-react';
|
||||
import RichText from '~/views/components/RichText';
|
||||
import useSettingsState, { selectCalmState } from '~/logic/state/settings';
|
||||
import { Sigil } from '~/logic/lib/sigil';
|
||||
import { ViewProfile } from './ViewProfile';
|
||||
import { EditProfile } from './EditProfile';
|
||||
@ -18,112 +10,193 @@ import { SetStatusBarModal } from '~/views/components/SetStatusBarModal';
|
||||
import { uxToHex } from '~/logic/lib/util';
|
||||
import { useTutorialModal } from '~/views/components/useTutorialModal';
|
||||
|
||||
export function ProfileHeader(props: any): ReactElement {
|
||||
return (
|
||||
<Box
|
||||
border='1px solid'
|
||||
borderColor='lightGray'
|
||||
borderRadius='2'
|
||||
overflow='hidden'
|
||||
marginBottom='calc(64px + 2rem)'
|
||||
>
|
||||
{props.children}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
export function ProfileImages(props: any): ReactElement {
|
||||
const { hideAvatars } = useSettingsState(selectCalmState);
|
||||
const { contact, hideCover, ship } = { ...props };
|
||||
const hexColor = contact?.color ? `#${uxToHex(contact.color)}` : '#000000';
|
||||
|
||||
const cover =
|
||||
contact?.cover && !hideCover ? (
|
||||
<BaseImage
|
||||
src={contact.cover}
|
||||
width='100%'
|
||||
height='100%'
|
||||
style={{ objectFit: 'cover' }}
|
||||
/>
|
||||
) : (
|
||||
<Box
|
||||
display='block'
|
||||
width='100%'
|
||||
height='100%'
|
||||
backgroundColor='washedGray'
|
||||
/>
|
||||
);
|
||||
|
||||
const image =
|
||||
!hideAvatars && contact?.avatar ? (
|
||||
<BaseImage
|
||||
src={contact.avatar}
|
||||
width='100%'
|
||||
height='100%'
|
||||
style={{ objectFit: 'cover' }}
|
||||
/>
|
||||
) : (
|
||||
<Sigil padding={24} ship={ship} size={128} color={hexColor} />
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Row width='100%' height='300px' position='relative'>
|
||||
{cover}
|
||||
<Center position='absolute' width='100%' height='100%'>
|
||||
{props.children}
|
||||
</Center>
|
||||
</Row>
|
||||
<Box
|
||||
height='128px'
|
||||
width='128px'
|
||||
borderRadius='2'
|
||||
overflow='hidden'
|
||||
position='absolute'
|
||||
left='50%'
|
||||
marginTop='-64px'
|
||||
marginLeft='-64px'
|
||||
>
|
||||
{image}
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function ProfileControls(props: any): ReactElement {
|
||||
return (
|
||||
<Row alignItems='center' justifyContent='space-between' px='3'>
|
||||
{props.children}
|
||||
</Row>
|
||||
);
|
||||
}
|
||||
|
||||
export function ProfileStatus(props: any): ReactElement {
|
||||
const { contact } = { ...props };
|
||||
return (
|
||||
<RichText
|
||||
mb='0'
|
||||
py='2'
|
||||
disableRemoteContent
|
||||
maxWidth='18rem'
|
||||
overflowX='hidden'
|
||||
textOverflow='ellipsis'
|
||||
whiteSpace='nowrap'
|
||||
overflow='hidden'
|
||||
display='inline-block'
|
||||
verticalAlign='middle'
|
||||
color='gray'
|
||||
>
|
||||
{contact?.status ?? ''}
|
||||
</RichText>
|
||||
);
|
||||
}
|
||||
|
||||
export function ProfileOwnControls(props: any): ReactElement {
|
||||
const { ship, isPublic, contact, api } = { ...props };
|
||||
const history = useHistory();
|
||||
return (
|
||||
<Row>
|
||||
{ship === `~${window.ship}` ? (
|
||||
<>
|
||||
<Text
|
||||
py='2'
|
||||
cursor='pointer'
|
||||
fontWeight='500'
|
||||
onClick={() => {
|
||||
history.push(`/~profile/${ship}/edit`);
|
||||
}}
|
||||
>
|
||||
Edit {isPublic ? 'Public' : 'Private'} Profile
|
||||
</Text>
|
||||
<SetStatusBarModal
|
||||
isControl
|
||||
py='2'
|
||||
ml='3'
|
||||
api={api}
|
||||
ship={`~${window.ship}`}
|
||||
contact={contact}
|
||||
/>
|
||||
</>
|
||||
) : null}
|
||||
</Row>
|
||||
);
|
||||
}
|
||||
|
||||
export function Profile(props: any): ReactElement {
|
||||
const { hideAvatars } = useSettingsState(selectCalmState);
|
||||
const history = useHistory();
|
||||
const history = useHistory();
|
||||
|
||||
if (!props.ship) {
|
||||
return null;
|
||||
}
|
||||
const { contact, nackedContacts, hasLoaded, isPublic, isEdit, ship } = props;
|
||||
const nacked = nackedContacts.has(ship);
|
||||
const formRef = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
if(hasLoaded && !contact && !nacked) {
|
||||
if (hasLoaded && !contact && !nacked) {
|
||||
props.api.contacts.retrieve(ship);
|
||||
}
|
||||
}, [hasLoaded, contact]);
|
||||
|
||||
const hexColor = contact?.color ? `#${uxToHex(contact.color)}` : '#000000';
|
||||
const cover = (contact?.cover)
|
||||
? <BaseImage src={contact.cover} width='100%' height='100%' style={{ objectFit: 'cover' }} />
|
||||
: <Box display="block" width='100%' height='100%' backgroundColor='washedGray' />;
|
||||
|
||||
const image = (!hideAvatars && contact?.avatar)
|
||||
? <BaseImage src={contact.avatar} width='100%' height='100%' style={{ objectFit: 'cover' }} />
|
||||
: <Sigil padding={24} ship={ship} size={128} color={hexColor} />;
|
||||
|
||||
const anchorRef = useRef<HTMLElement | null>(null);
|
||||
|
||||
useTutorialModal('profile', ship === `~${window.ship}`, anchorRef.current);
|
||||
useTutorialModal('profile', ship === `~${window.ship}`, anchorRef);
|
||||
|
||||
return (
|
||||
<Center
|
||||
p={[0,4]}
|
||||
height="100%"
|
||||
width="100%"
|
||||
>
|
||||
|
||||
<Box
|
||||
ref={anchorRef}
|
||||
maxWidth="600px"
|
||||
width="100%"
|
||||
>
|
||||
<Row alignItems="center" justifyContent="space-between">
|
||||
<Row>
|
||||
{ship === `~${window.ship}` ? (
|
||||
<>
|
||||
<Text
|
||||
py='2'
|
||||
cursor='pointer'
|
||||
onClick={() => {
|
||||
history.push(`/~profile/${ship}/edit`);
|
||||
}}
|
||||
>
|
||||
Edit Profile
|
||||
</Text>
|
||||
<SetStatusBarModal
|
||||
py='2'
|
||||
ml='3'
|
||||
api={props.api}
|
||||
ship={`~${window.ship}`}
|
||||
contact={contact}
|
||||
/>
|
||||
</>
|
||||
) : null}
|
||||
</Row>
|
||||
<RichText mb='0' py='2' disableRemoteContent maxWidth='18rem' overflowX='hidden' textOverflow="ellipsis"
|
||||
whiteSpace="nowrap"
|
||||
overflow="hidden" display="inline-block" verticalAlign="middle">{contact?.status ?? ""}</RichText>
|
||||
</Row>
|
||||
<Row width="100%" height="300px">
|
||||
{cover}
|
||||
</Row>
|
||||
<Row
|
||||
pb={2}
|
||||
alignItems="center"
|
||||
width="100%"
|
||||
>
|
||||
<Center width="100%" marginTop="-48px">
|
||||
<Box height='128px' width='128px' borderRadius="2" overflow="hidden">
|
||||
{image}
|
||||
</Box>
|
||||
</Center>
|
||||
</Row>
|
||||
{ isEdit ? (
|
||||
<EditProfile
|
||||
ship={ship}
|
||||
contact={contact}
|
||||
s3={props.s3}
|
||||
api={props.api}
|
||||
groups={props.groups}
|
||||
associations={props.associations}
|
||||
isPublic={isPublic}
|
||||
/>
|
||||
) : (
|
||||
const ViewInterface = () => {
|
||||
return (
|
||||
<Center p={[0, 4]} height='100%' width='100%'>
|
||||
<Box ref={anchorRef} maxWidth='600px' width='100%' position='relative'>
|
||||
<ViewProfile
|
||||
api={props.api}
|
||||
nacked={nacked}
|
||||
ship={ship}
|
||||
contact={contact}
|
||||
isPublic={isPublic}
|
||||
api={props.api}
|
||||
groups={props.groups}
|
||||
associations={props.associations}
|
||||
/>
|
||||
) }
|
||||
</Box>
|
||||
</Center>
|
||||
);
|
||||
</Box>
|
||||
</Center>
|
||||
);
|
||||
};
|
||||
|
||||
const EditInterface = () => {
|
||||
return (
|
||||
<Center p={[0, 4]} height='100%' width='100%'>
|
||||
<Box ref={anchorRef} maxWidth='600px' width='100%' position='relative'>
|
||||
<EditProfile
|
||||
ship={ship}
|
||||
contact={contact}
|
||||
storage={props.storage}
|
||||
api={props.api}
|
||||
groups={props.groups}
|
||||
associations={props.associations}
|
||||
isPublic={isPublic}
|
||||
/>
|
||||
</Box>
|
||||
</Center>
|
||||
);
|
||||
};
|
||||
|
||||
return isEdit ? <EditInterface /> : <ViewInterface />;
|
||||
}
|
||||
|
@ -1,19 +1,20 @@
|
||||
import React from 'react';
|
||||
import _ from 'lodash';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
import { Center, Box, Text, Row, Col } from '@tlon/indigo-react';
|
||||
import RichText from '~/views/components/RichText';
|
||||
import useSettingsState, { selectCalmState } from '~/logic/state/settings';
|
||||
import { Sigil } from '~/logic/lib/sigil';
|
||||
import { GroupLink } from '~/views/components/GroupLink';
|
||||
import { lengthOrder } from '~/logic/lib/util';
|
||||
import useLocalState from '~/logic/state/local';
|
||||
import {
|
||||
Center,
|
||||
Box,
|
||||
Text,
|
||||
Row,
|
||||
Col,
|
||||
} from "@tlon/indigo-react";
|
||||
import RichText from "~/views/components/RichText";
|
||||
import {GroupLink} from "~/views/components/GroupLink";
|
||||
import {lengthOrder} from "~/logic/lib/util";
|
||||
import useSettingsState, {selectCalmState} from "~/logic/state/settings";
|
||||
|
||||
ProfileHeader,
|
||||
ProfileControls,
|
||||
ProfileOwnControls,
|
||||
ProfileStatus,
|
||||
ProfileImages
|
||||
} from './Profile';
|
||||
|
||||
export function ViewProfile(props: any) {
|
||||
const history = useHistory();
|
||||
@ -22,43 +23,44 @@ export function ViewProfile(props: any) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Row
|
||||
pb={2}
|
||||
alignItems="center"
|
||||
width="100%"
|
||||
>
|
||||
<Center width="100%">
|
||||
<ProfileHeader>
|
||||
<ProfileControls>
|
||||
<ProfileOwnControls
|
||||
ship={ship}
|
||||
isPublic={isPublic}
|
||||
contact={contact}
|
||||
api={props.api}
|
||||
/>
|
||||
<ProfileStatus contact={contact} />
|
||||
</ProfileControls>
|
||||
<ProfileImages contact={contact} ship={ship} />
|
||||
</ProfileHeader>
|
||||
<Row pb={2} alignItems='center' width='100%'>
|
||||
<Center width='100%'>
|
||||
<Text>
|
||||
{((!hideNicknames && contact?.nickname) ? contact.nickname : '')}
|
||||
{!hideNicknames && contact?.nickname ? contact.nickname : ''}
|
||||
</Text>
|
||||
</Center>
|
||||
</Row>
|
||||
<Row
|
||||
pb={2}
|
||||
alignItems="center"
|
||||
width="100%"
|
||||
>
|
||||
<Center width="100%">
|
||||
<Text mono color="darkGray">{ship}</Text>
|
||||
<Row pb={2} alignItems='center' width='100%'>
|
||||
<Center width='100%'>
|
||||
<Text mono color='darkGray'>
|
||||
{ship}
|
||||
</Text>
|
||||
</Center>
|
||||
</Row>
|
||||
<Col
|
||||
pb={2}
|
||||
alignItems="center"
|
||||
justifyContent="center"
|
||||
width="100%"
|
||||
>
|
||||
<Center flexDirection="column" maxWidth='32rem'>
|
||||
<Col pb={2} alignItems='center' justifyContent='center' width='100%'>
|
||||
<Center flexDirection='column' maxWidth='32rem'>
|
||||
<RichText width='100%' disableRemoteContent>
|
||||
{(contact?.bio ? contact.bio : '')}
|
||||
{contact?.bio ? contact.bio : ''}
|
||||
</RichText>
|
||||
</Center>
|
||||
</Col>
|
||||
{ (contact?.groups || []).length > 0 && (
|
||||
<Col gapY="3" mb="3" mt="6" alignItems="flex-start">
|
||||
</Center>
|
||||
</Col>
|
||||
{(contact?.groups || []).length > 0 && (
|
||||
<Col gapY='3' mb='3' mt='6' alignItems='flex-start'>
|
||||
<Text gray>Pinned Groups</Text>
|
||||
<Col>
|
||||
{ contact?.groups.sort(lengthOrder).map(g => (
|
||||
{contact?.groups.sort(lengthOrder).map((g) => (
|
||||
<GroupLink
|
||||
api={api}
|
||||
resource={g}
|
||||
@ -68,25 +70,25 @@ export function ViewProfile(props: any) {
|
||||
/>
|
||||
))}
|
||||
</Col>
|
||||
</Col>
|
||||
</Col>
|
||||
)}
|
||||
|
||||
{ (nacked || (!isPublic && ship === `~${window.ship}`)) ? (
|
||||
{nacked || (!isPublic && ship === `~${window.ship}`) ? (
|
||||
<Box
|
||||
height="200px"
|
||||
height='200px'
|
||||
borderRadius={1}
|
||||
bg="white"
|
||||
bg='white'
|
||||
border={1}
|
||||
borderColor="washedGray"
|
||||
borderColor='washedGray'
|
||||
>
|
||||
<Center height="100%">
|
||||
<Text mono pr={1} color="gray">{ship}</Text>
|
||||
<Text color="gray">remains private</Text>
|
||||
<Center height='100%'>
|
||||
<Text mono pr={1} color='gray'>
|
||||
{ship}
|
||||
</Text>
|
||||
<Text color='gray'>remains private</Text>
|
||||
</Center>
|
||||
</Box>
|
||||
) : null
|
||||
}
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -10,48 +10,53 @@ export default function ProfileScreen(props: any) {
|
||||
const { dark } = props;
|
||||
return (
|
||||
<>
|
||||
<Helmet defer={false}>
|
||||
<title>{ props.notificationsCount ? `(${String(props.notificationsCount) }) `: '' }Landscape - Profile</title>
|
||||
</Helmet>
|
||||
<Route
|
||||
path={'/~profile/:ship/:edit?'}
|
||||
render={({ match }) => {
|
||||
const ship = match.params.ship;
|
||||
const isEdit = match.url.includes('edit');
|
||||
const isPublic = props.isContactPublic;
|
||||
const contact = props.contacts?.[ship];
|
||||
<Helmet defer={false}>
|
||||
<title>
|
||||
{props.notificationsCount
|
||||
? `(${String(props.notificationsCount)}) `
|
||||
: ''}
|
||||
Landscape - Profile
|
||||
</title>
|
||||
</Helmet>
|
||||
<Route
|
||||
path={'/~profile/:ship/:edit?'}
|
||||
render={({ match }) => {
|
||||
const ship = match.params.ship;
|
||||
const isEdit = match.url.includes('edit');
|
||||
const isPublic = props.isContactPublic;
|
||||
const contact = props.contacts?.[ship];
|
||||
|
||||
return (
|
||||
<Box height="100%" px={[0, 3]} pb={[0, 3]} borderRadius={1}>
|
||||
<Box
|
||||
height="100%"
|
||||
width="100%"
|
||||
borderRadius={1}
|
||||
bg="white"
|
||||
border={1}
|
||||
borderColor="washedGray"
|
||||
overflowY="auto"
|
||||
flexGrow
|
||||
>
|
||||
<Box>
|
||||
<Profile
|
||||
ship={ship}
|
||||
hasLoaded={Object.keys(props.contacts).length !== 0}
|
||||
associations={props.associations}
|
||||
groups={props.groups}
|
||||
contact={contact}
|
||||
api={props.api}
|
||||
s3={props.s3}
|
||||
isEdit={isEdit}
|
||||
isPublic={isPublic}
|
||||
nackedContacts={props.nackedContacts}
|
||||
/>
|
||||
return (
|
||||
<Box height='100%' px={[0, 3]} pb={[0, 3]} borderRadius={2}>
|
||||
<Box
|
||||
height='100%'
|
||||
width='100%'
|
||||
borderRadius={2}
|
||||
bg='white'
|
||||
border={1}
|
||||
borderColor='washedGray'
|
||||
overflowY='auto'
|
||||
flexGrow
|
||||
>
|
||||
<Box>
|
||||
<Profile
|
||||
ship={ship}
|
||||
hasLoaded={Object.keys(props.contacts).length !== 0}
|
||||
associations={props.associations}
|
||||
groups={props.groups}
|
||||
contact={contact}
|
||||
api={props.api}
|
||||
storage={props.storage}
|
||||
isEdit={isEdit}
|
||||
isPublic={isPublic}
|
||||
nackedContacts={props.nackedContacts}
|
||||
/>
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ export function PublishResource(props: PublishResourceProps) {
|
||||
location={props.location}
|
||||
unreads={props.unreads}
|
||||
graphs={props.graphs}
|
||||
s3={props.s3}
|
||||
storage={props.storage}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
|
@ -9,7 +9,7 @@ import { PostFormSchema, PostForm } from './NoteForm';
|
||||
import GlobalApi from '~/logic/api/global';
|
||||
import { getLatestRevision, editPost } from '~/logic/lib/publish';
|
||||
import { useWaitForProps } from '~/logic/lib/useWaitForProps';
|
||||
import { S3State } from '~/types';
|
||||
import { StorageState } from '~/types';
|
||||
|
||||
interface EditPostProps {
|
||||
ship: string;
|
||||
@ -17,11 +17,11 @@ interface EditPostProps {
|
||||
note: GraphNode;
|
||||
api: GlobalApi;
|
||||
book: string;
|
||||
s3: S3State;
|
||||
storage: StorageState;
|
||||
}
|
||||
|
||||
export function EditPost(props: EditPostProps & RouteComponentProps): ReactElement {
|
||||
const { note, book, noteId, api, ship, history, s3 } = props;
|
||||
const { note, book, noteId, api, ship, history, storage } = props;
|
||||
const [revNum, title, body] = getLatestRevision(note);
|
||||
const location = useLocation();
|
||||
|
||||
@ -58,7 +58,7 @@ export function EditPost(props: EditPostProps & RouteComponentProps): ReactEleme
|
||||
cancel
|
||||
history={history}
|
||||
onSubmit={onSubmit}
|
||||
s3={s3}
|
||||
storage={storage}
|
||||
submitLabel="Update"
|
||||
loadingText="Updating..."
|
||||
/>
|
||||
|
@ -16,8 +16,8 @@ import 'codemirror/lib/codemirror.css';
|
||||
import { Box } from '@tlon/indigo-react';
|
||||
import { useFileDrag } from '~/logic/lib/useDrag';
|
||||
import SubmitDragger from '~/views/components/SubmitDragger';
|
||||
import useS3 from '~/logic/lib/useS3';
|
||||
import { S3State } from '@urbit/api';
|
||||
import useStorage from '~/logic/lib/useStorage';
|
||||
import { StorageState } from '~/types';
|
||||
|
||||
const MARKDOWN_CONFIG = {
|
||||
name: 'markdown'
|
||||
@ -28,7 +28,7 @@ interface MarkdownEditorProps {
|
||||
value: string;
|
||||
onChange: (s: string) => void;
|
||||
onBlur?: (e: any) => void;
|
||||
s3: S3State;
|
||||
storage: StorageState;
|
||||
}
|
||||
|
||||
const PromptIfDirty = () => {
|
||||
@ -74,7 +74,7 @@ export function MarkdownEditor(
|
||||
[onBlur]
|
||||
);
|
||||
|
||||
const { uploadDefault, canUpload } = useS3(props.s3);
|
||||
const { uploadDefault, canUpload } = useStorage(props.storage);
|
||||
|
||||
const onFileDrag = useCallback(
|
||||
async (files: FileList | File[], e: DragEvent) => {
|
||||
|
@ -6,7 +6,7 @@ import { MarkdownEditor } from './MarkdownEditor';
|
||||
|
||||
export const MarkdownField = ({
|
||||
id,
|
||||
s3,
|
||||
storage,
|
||||
...rest
|
||||
}: { id: string } & Parameters<typeof Box>[0]) => {
|
||||
const [{ value, onBlur }, { error, touched }, { setValue }] = useField(id);
|
||||
@ -35,7 +35,7 @@ export const MarkdownField = ({
|
||||
onBlur={handleBlur}
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
s3={s3}
|
||||
storage={storage}
|
||||
/>
|
||||
<ErrorLabel mt="2" hasError={Boolean(error && touched)}>
|
||||
{error}
|
||||
|
@ -9,7 +9,7 @@ import {
|
||||
import { AsyncButton } from '../../../components/AsyncButton';
|
||||
import { Formik, Form, FormikHelpers } from 'formik';
|
||||
import { MarkdownField } from './MarkdownField';
|
||||
import { S3State } from '@urbit/api';
|
||||
import { StorageState } from '~/types';
|
||||
|
||||
interface PostFormProps {
|
||||
initial: PostFormSchema;
|
||||
@ -21,7 +21,7 @@ interface PostFormProps {
|
||||
) => Promise<any>;
|
||||
submitLabel: string;
|
||||
loadingText: string;
|
||||
s3: S3State;
|
||||
storage: StorageState;
|
||||
}
|
||||
|
||||
const formSchema = Yup.object({
|
||||
@ -35,7 +35,7 @@ export interface PostFormSchema {
|
||||
}
|
||||
|
||||
export function PostForm(props: PostFormProps) {
|
||||
const { initial, onSubmit, submitLabel, loadingText, s3, cancel, history } = props;
|
||||
const { initial, onSubmit, submitLabel, loadingText, storage, cancel, history } = props;
|
||||
|
||||
return (
|
||||
<Col width="100%" height="100%" p={[2, 4]}>
|
||||
@ -67,7 +67,7 @@ export function PostForm(props: PostFormProps) {
|
||||
>Cancel</Button>}
|
||||
</Row>
|
||||
</Row>
|
||||
<MarkdownField flexGrow={1} id="body" s3={s3} />
|
||||
<MarkdownField flexGrow={1} id="body" storage={storage} />
|
||||
</Form>
|
||||
</Formik>
|
||||
</Col>
|
||||
|
@ -68,7 +68,15 @@ export function NotePreview(props: NotePreviewProps) {
|
||||
unwrapDisallowed
|
||||
allowedTypes={['text', 'root', 'break', 'paragraph', 'image']}
|
||||
renderers={{
|
||||
image: props => <Image src={props.src} maxHeight='300px' style={{ objectFit: 'cover' }} />
|
||||
image: props => (
|
||||
<Box
|
||||
backgroundImage={`url(${props.src})`}
|
||||
style={{ backgroundSize: 'cover',
|
||||
backgroundPosition: "center" }}
|
||||
>
|
||||
<Image src={props.src} opacity="0" maxHeight="300px"/>
|
||||
</Box>
|
||||
)
|
||||
}}
|
||||
source={snippet}
|
||||
/>
|
||||
|
@ -6,7 +6,8 @@ import { RouteComponentProps } from 'react-router-dom';
|
||||
import Note from './Note';
|
||||
import { EditPost } from './EditPost';
|
||||
|
||||
import { GraphNode, Graph, Contacts, Association, S3State, Group } from '@urbit/api';
|
||||
import { GraphNode, Graph, Contacts, Association, Group } from '@urbit/api';
|
||||
import { StorageState } from '~/types';
|
||||
|
||||
interface NoteRoutesProps {
|
||||
ship: string;
|
||||
@ -20,7 +21,7 @@ interface NoteRoutesProps {
|
||||
baseUrl?: string;
|
||||
rootUrl?: string;
|
||||
group: Group;
|
||||
s3: S3State;
|
||||
storage: StorageState;
|
||||
}
|
||||
|
||||
export function NoteRoutes(props: NoteRoutesProps & RouteComponentProps) {
|
||||
|
@ -9,9 +9,9 @@ import {
|
||||
Contacts,
|
||||
Rolodex,
|
||||
Unreads,
|
||||
S3State
|
||||
} from '@urbit/api';
|
||||
import { Center, LoadingSpinner } from '@tlon/indigo-react';
|
||||
import { StorageState } from '~/types';
|
||||
import bigInt from 'big-integer';
|
||||
|
||||
import Notebook from './Notebook';
|
||||
@ -30,7 +30,7 @@ interface NotebookRoutesProps {
|
||||
rootUrl: string;
|
||||
association: Association;
|
||||
associations: Associations;
|
||||
s3: S3State;
|
||||
storage: StorageState;
|
||||
}
|
||||
|
||||
export function NotebookRoutes(
|
||||
@ -77,7 +77,7 @@ export function NotebookRoutes(
|
||||
association={props.association}
|
||||
graph={graph}
|
||||
baseUrl={baseUrl}
|
||||
s3={props.s3}
|
||||
storage={props.storage}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
@ -109,7 +109,7 @@ export function NotebookRoutes(
|
||||
contacts={contacts}
|
||||
association={props.association}
|
||||
group={group}
|
||||
s3={props.s3}
|
||||
storage={props.storage}
|
||||
{...routeProps}
|
||||
/>
|
||||
);
|
||||
|
@ -6,7 +6,8 @@ import { RouteComponentProps } from 'react-router-dom';
|
||||
import { PostForm, PostFormSchema } from './NoteForm';
|
||||
import { createPost } from '~/logic/api/graph';
|
||||
import { Graph } from '@urbit/api/graph';
|
||||
import { Association, S3State } from '@urbit/api';
|
||||
import { Association } from '@urbit/api';
|
||||
import { StorageState } from '~/types';
|
||||
import { newPost } from '~/logic/lib/publish';
|
||||
|
||||
interface NewPostProps {
|
||||
@ -16,7 +17,7 @@ interface NewPostProps {
|
||||
graph: Graph;
|
||||
association: Association;
|
||||
baseUrl: string;
|
||||
s3: S3State;
|
||||
storage: StorageState;
|
||||
}
|
||||
|
||||
export default function NewPost(props: NewPostProps & RouteComponentProps) {
|
||||
@ -53,7 +54,7 @@ export default function NewPost(props: NewPostProps & RouteComponentProps) {
|
||||
onSubmit={onSubmit}
|
||||
submitLabel="Publish"
|
||||
loadingText="Posting..."
|
||||
s3={props.s3}
|
||||
storage={props.storage}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import {
|
||||
import GlobalApi from '~/logic/api/global';
|
||||
import { ImageInput } from '~/views/components/ImageInput';
|
||||
import { ColorInput } from '~/views/components/ColorInput';
|
||||
import { S3State } from '~/types/s3-update';
|
||||
import { StorageState } from '~/types';
|
||||
|
||||
export type BgType = 'none' | 'url' | 'color';
|
||||
|
||||
@ -20,13 +20,13 @@ export function BackgroundPicker({
|
||||
bgType,
|
||||
bgUrl,
|
||||
api,
|
||||
s3
|
||||
storage
|
||||
}: {
|
||||
bgType: BgType;
|
||||
bgUrl?: string;
|
||||
api: GlobalApi;
|
||||
s3: S3State;
|
||||
}): ReactElement {
|
||||
storage: StorageState;
|
||||
}) {
|
||||
const rowSpace = { my: 0, alignItems: 'center' };
|
||||
const colProps = { my: 3, mr: 4, gapY: 1 };
|
||||
return (
|
||||
@ -39,7 +39,7 @@ export function BackgroundPicker({
|
||||
<ImageInput
|
||||
ml="5"
|
||||
api={api}
|
||||
s3={s3}
|
||||
storage={storage}
|
||||
id="bgUrl"
|
||||
placeholder="Drop or upload a file, or paste a link here"
|
||||
name="bgUrl"
|
||||
|
@ -11,7 +11,7 @@ import * as Yup from "yup";
|
||||
|
||||
import GlobalApi from "~/logic/api/global";
|
||||
import { uxToHex } from "~/logic/lib/util";
|
||||
import { S3State, BackgroundConfig } from "~/types";
|
||||
import { S3State, BackgroundConfig, StorageState } from "~/types";
|
||||
import { BackgroundPicker, BgType } from "./BackgroundPicker";
|
||||
import useSettingsState, { SettingsState, selectSettingsState } from "~/logic/state/settings";
|
||||
import {AsyncButton} from "~/views/components/AsyncButton";
|
||||
@ -36,13 +36,13 @@ interface FormSchema {
|
||||
|
||||
interface DisplayFormProps {
|
||||
api: GlobalApi;
|
||||
s3: S3State;
|
||||
storage: StorageState;
|
||||
}
|
||||
|
||||
const settingsSel = selectSettingsState(["display"]);
|
||||
|
||||
export default function DisplayForm(props: DisplayFormProps) {
|
||||
const { api, s3 } = props;
|
||||
const { api, storage } = props;
|
||||
|
||||
const {
|
||||
display: {
|
||||
@ -108,7 +108,7 @@ export default function DisplayForm(props: DisplayFormProps) {
|
||||
bgType={props.values.bgType}
|
||||
bgUrl={props.values.bgUrl}
|
||||
api={api}
|
||||
s3={s3}
|
||||
storage={storage}
|
||||
/>
|
||||
<Label>Theme</Label>
|
||||
<Radio name="theme" id="light" label="Light"/>
|
||||
|
@ -15,6 +15,7 @@ import GlobalApi from "~/logic/api/global";
|
||||
import { BucketList } from "./BucketList";
|
||||
import { S3State } from '~/types/s3-update';
|
||||
import { BackButton } from './BackButton';
|
||||
import {StorageState} from '~/types';
|
||||
|
||||
interface FormSchema {
|
||||
s3bucket: string;
|
||||
@ -26,11 +27,12 @@ interface FormSchema {
|
||||
|
||||
interface S3FormProps {
|
||||
api: GlobalApi;
|
||||
s3: S3State;
|
||||
storage: StorageState;
|
||||
}
|
||||
|
||||
export default function S3Form(props: S3FormProps): ReactElement {
|
||||
const { api, s3 } = props;
|
||||
const { api, storage } = props;
|
||||
const { s3 } = storage;
|
||||
|
||||
const onSubmit = useCallback(
|
||||
(values: FormSchema) => {
|
||||
@ -48,6 +50,7 @@ export default function S3Form(props: S3FormProps): ReactElement {
|
||||
},
|
||||
[api, s3]
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Col p="5" pt="4" borderBottom="1" borderBottomColor="washedGray">
|
||||
|
@ -116,10 +116,10 @@ export default function SettingsScreen(props: any) {
|
||||
/>
|
||||
)}
|
||||
{hash === "display" && (
|
||||
<DisplayForm s3={props.s3} api={props.api} />
|
||||
<DisplayForm storage={props.storage} api={props.api} />
|
||||
)}
|
||||
{hash === "s3" && (
|
||||
<S3Form s3={props.s3} api={props.api} />
|
||||
<S3Form storage={props.storage} api={props.api} />
|
||||
)}
|
||||
{hash === "leap" && (
|
||||
<LeapSettings api={props.api} />
|
||||
|
@ -7,6 +7,7 @@ import { Contacts } from '@urbit/api/contacts';
|
||||
import { Group } from '@urbit/api';
|
||||
|
||||
import { uxToHex, cite, useShowNickname, deSig } from '~/logic/lib/util';
|
||||
import useSettingsState, {selectCalmState} from "~/logic/state/settings";
|
||||
import OverlaySigil from './OverlaySigil';
|
||||
import { Sigil } from '~/logic/lib/sigil';
|
||||
import GlobalApi from '~/logic/api/global';
|
||||
@ -33,6 +34,7 @@ export default function Author(props: AuthorProps): ReactElement {
|
||||
}
|
||||
const color = contact?.color ? `#${uxToHex(contact?.color)}` : '#000000';
|
||||
const showNickname = useShowNickname(contact);
|
||||
const { hideAvatars } = useSettingsState(selectCalmState);
|
||||
const name = showNickname ? contact.nickname : cite(ship);
|
||||
const stamp = moment(date);
|
||||
|
||||
@ -43,13 +45,14 @@ export default function Author(props: AuthorProps): ReactElement {
|
||||
};
|
||||
|
||||
const img =
|
||||
contact && contact.avatar !== null ? (
|
||||
contact?.avatar && !hideAvatars ? (
|
||||
<BaseImage
|
||||
display='inline-block'
|
||||
src={contact.avatar}
|
||||
style={{ objectFit: 'cover' }}
|
||||
height={16}
|
||||
width={16}
|
||||
borderRadius={1}
|
||||
/>
|
||||
) : (
|
||||
<Sigil ship={ship} size={16} color={color} icon padding={2} />
|
||||
|
@ -23,7 +23,7 @@ export function ColorInput(props: ColorInputProps) {
|
||||
const { id, placeholder, label, caption, disabled, ...rest } = props;
|
||||
const [{ value, onBlur }, meta, { setValue }] = useField(id);
|
||||
|
||||
const hex = value.replace('#', '').replace('0x','').replace('.', '');
|
||||
const hex = value.replace('#', '').replace('0x', '').replace('.', '');
|
||||
const padded = hex.padStart(6, '0');
|
||||
|
||||
const onChange = (e: FormEvent<HTMLInputElement>) => {
|
||||
@ -39,15 +39,16 @@ export function ColorInput(props: ColorInputProps) {
|
||||
};
|
||||
|
||||
return (
|
||||
<Box display="flex" flexDirection="column" {...rest}>
|
||||
<Box display='flex' flexDirection='column' {...rest}>
|
||||
<Label htmlFor={id}>{label}</Label>
|
||||
{caption ? (
|
||||
<Label mt="2" gray>
|
||||
<Label mt='2' gray>
|
||||
{caption}
|
||||
</Label>
|
||||
) : null}
|
||||
<Row mt="2" alignItems="flex-end">
|
||||
<Row mt='2' alignItems='flex-end'>
|
||||
<Input
|
||||
id={id}
|
||||
borderTopRightRadius={0}
|
||||
borderBottomRightRadius={0}
|
||||
onBlur={onBlur}
|
||||
@ -62,25 +63,25 @@ export function ColorInput(props: ColorInputProps) {
|
||||
borderTopRightRadius={1}
|
||||
border={1}
|
||||
borderLeft={0}
|
||||
borderColor="lightGray"
|
||||
width="32px"
|
||||
alignSelf="stretch"
|
||||
borderColor='lightGray'
|
||||
width='32px'
|
||||
alignSelf='stretch'
|
||||
bg={`#${padded}`}
|
||||
>
|
||||
<Input
|
||||
width="100%"
|
||||
height="100%"
|
||||
alignSelf="stretch"
|
||||
onInput={onChange}
|
||||
width='100%'
|
||||
height='100%'
|
||||
alignSelf='stretch'
|
||||
onChange={onChange}
|
||||
value={`#${padded}`}
|
||||
disabled={disabled || false}
|
||||
type="color"
|
||||
type='color'
|
||||
opacity={0}
|
||||
overflow="hidden"
|
||||
overflow='hidden'
|
||||
/>
|
||||
</Box>
|
||||
</Row>
|
||||
<ErrorLabel mt="2" hasError={Boolean(meta.touched && meta.error)}>
|
||||
<ErrorLabel mt='2' hasError={Boolean(meta.touched && meta.error)}>
|
||||
{meta.error}
|
||||
</ErrorLabel>
|
||||
</Box>
|
||||
|
@ -114,7 +114,7 @@ export function DropdownSearch<C>(props: DropdownSearchProps<C>): ReactElement {
|
||||
search(e.target.value);
|
||||
setQuery(e.target.value);
|
||||
},
|
||||
[setQuery]
|
||||
[search, onChange]
|
||||
);
|
||||
|
||||
const dropdown = useMemo(() => {
|
||||
|
@ -11,20 +11,20 @@ import {
|
||||
BaseInput
|
||||
} from '@tlon/indigo-react';
|
||||
|
||||
import { S3State } from '~/types/s3-update';
|
||||
import useS3 from '~/logic/lib/useS3';
|
||||
import { StorageState } from '~/types';
|
||||
import useStorage from '~/logic/lib/useStorage';
|
||||
|
||||
type ImageInputProps = Parameters<typeof Box>[0] & {
|
||||
id: string;
|
||||
label: string;
|
||||
s3: S3State;
|
||||
storage: StorageState;
|
||||
placeholder?: string;
|
||||
};
|
||||
|
||||
export function ImageInput(props: ImageInputProps): ReactElement {
|
||||
const { id, label, s3, caption, placeholder } = props;
|
||||
const { id, label, storage, caption, placeholder } = props;
|
||||
|
||||
const { uploadDefault, canUpload, uploading } = useS3(s3);
|
||||
const { uploadDefault, canUpload, uploading } = useStorage(storage);
|
||||
|
||||
const [field, meta, { setValue, setError }] = useField(id);
|
||||
|
||||
|
@ -37,7 +37,7 @@ const RichText = React.memo(({ disableRemoteContent, ...props }) => (
|
||||
return <RemoteContent className="mw-100" url={linkProps.href} />;
|
||||
}
|
||||
|
||||
return <Anchor target='_blank' rel='noreferrer noopener' borderBottom='1px solid' remoteContentPolicy={remoteContentPolicy} {...linkProps}>{linkProps.children}</Anchor>;
|
||||
return <Anchor display="inline" target='_blank' rel='noreferrer noopener' borderBottom='1px solid' remoteContentPolicy={remoteContentPolicy} {...linkProps}>{linkProps.children}</Anchor>;
|
||||
},
|
||||
linkReference: (linkProps) => {
|
||||
const linkText = String(linkProps.children[0].props.children);
|
||||
|
@ -1,31 +1,18 @@
|
||||
import React, {
|
||||
useState,
|
||||
useEffect
|
||||
} from 'react';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
|
||||
import {
|
||||
Row,
|
||||
Box,
|
||||
Text
|
||||
} from '@tlon/indigo-react';
|
||||
import { Row, Box, Text } from '@tlon/indigo-react';
|
||||
|
||||
import { SetStatus } from '~/views/apps/profile/components/SetStatus';
|
||||
|
||||
|
||||
export const SetStatusBarModal = (props) => {
|
||||
const {
|
||||
ship,
|
||||
contact,
|
||||
api,
|
||||
...rest
|
||||
} = props;
|
||||
const { ship, contact, api, isControl, ...rest } = props;
|
||||
const [modalShown, setModalShown] = useState(false);
|
||||
|
||||
const handleKeyDown = (event) => {
|
||||
if (event.key === 'Escape') {
|
||||
setModalShown(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener('keydown', handleKeyDown);
|
||||
@ -40,28 +27,28 @@ export const SetStatusBarModal = (props) => {
|
||||
{modalShown && (
|
||||
<Box
|
||||
backgroundColor='scales.black30'
|
||||
left="0px"
|
||||
top="0px"
|
||||
width="100%"
|
||||
height="100%"
|
||||
left='0px'
|
||||
top='0px'
|
||||
width='100%'
|
||||
height='100%'
|
||||
zIndex={4}
|
||||
position="fixed"
|
||||
display="flex"
|
||||
justifyContent="center"
|
||||
alignItems="center"
|
||||
position='fixed'
|
||||
display='flex'
|
||||
justifyContent='center'
|
||||
alignItems='center'
|
||||
onClick={() => setModalShown(false)}
|
||||
>
|
||||
<Box
|
||||
maxWidth="500px"
|
||||
width="100%"
|
||||
bg="white"
|
||||
maxWidth='500px'
|
||||
width='100%'
|
||||
bg='white'
|
||||
borderRadius={2}
|
||||
border={[0, 1]}
|
||||
borderColor={["washedGray", "washedGray"]}
|
||||
onClick={e => e.stopPropagation()}
|
||||
display="flex"
|
||||
alignItems="stretch"
|
||||
flexDirection="column"
|
||||
borderColor={['washedGray', 'washedGray']}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
display='flex'
|
||||
alignItems='stretch'
|
||||
flexDirection='column'
|
||||
>
|
||||
<Box m={3}>
|
||||
<SetStatus
|
||||
@ -70,23 +57,23 @@ export const SetStatusBarModal = (props) => {
|
||||
api={api}
|
||||
callback={() => {
|
||||
setModalShown(false);
|
||||
}} />
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
)}
|
||||
<Row
|
||||
{...rest}
|
||||
flexShrink={0}
|
||||
onClick={() => setModalShown(true)}>
|
||||
<Text color='black'
|
||||
<Row {...rest} flexShrink={0} onClick={() => setModalShown(true)}>
|
||||
<Text
|
||||
color='black'
|
||||
cursor='pointer'
|
||||
fontWeight={isControl ? '500' : '400'}
|
||||
flexShrink={0}
|
||||
fontSize={1}>
|
||||
fontSize={1}
|
||||
>
|
||||
Set Status
|
||||
</Text>
|
||||
</Row>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -37,14 +37,16 @@ interface InviteSearchProps<I extends string> {
|
||||
maxLength?: number;
|
||||
}
|
||||
|
||||
const getNicknameForShips = (groups: Groups, contacts: Rolodex): readonly [string[], Map<string, string[]>] => {
|
||||
const getNicknameForShips = (groups: Groups, contacts: Rolodex, selected: string[]): readonly [string[], Map<string, string[]>] => {
|
||||
const peerSet = new Set<string>();
|
||||
const nicknames = new Map<string, string[]>();
|
||||
_.forEach(groups, (group, path) => {
|
||||
if (group.members.size > 0) {
|
||||
const groupEntries = group.members.values();
|
||||
for (const member of groupEntries) {
|
||||
peerSet.add(member);
|
||||
if(!selected.includes(member)) {
|
||||
peerSet.add(member);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,15 +118,15 @@ export function ShipSearch<I extends string, V extends Value<I>>(
|
||||
|
||||
const inputIdx = useRef(initialValues[id].length);
|
||||
|
||||
const selected: string[] = values[id] ?? [];
|
||||
const selected: string[] = useMemo(() => values[id] ?? [], [values, id]);
|
||||
|
||||
const name = () => `${props.id}[${inputIdx.current}]`;
|
||||
|
||||
const pills = selected.slice(0, inputIdx.current);
|
||||
|
||||
const [peers, nicknames] = useMemo(
|
||||
() => getNicknameForShips(props.groups, props.contacts),
|
||||
[props.contacts, props.groups]
|
||||
() => getNicknameForShips(props.groups, props.contacts, selected),
|
||||
[props.contacts, props.groups, selected]
|
||||
);
|
||||
|
||||
const renderCandidate = useCallback(
|
||||
|
27
pkg/interface/src/views/components/StarIcon.tsx
Normal file
27
pkg/interface/src/views/components/StarIcon.tsx
Normal file
@ -0,0 +1,27 @@
|
||||
import React from "react";
|
||||
import css, { SystemStyleObject } from "@styled-system/css";
|
||||
import styled from "styled-components";
|
||||
import { BaseSVG } from "@tlon/indigo-react";
|
||||
import { PropFunc } from "~/types";
|
||||
|
||||
type StarIconProps = PropFunc<typeof BaseSVG> & SvgProps;
|
||||
|
||||
interface SvgProps {
|
||||
color?: string;
|
||||
}
|
||||
const Svg = styled(BaseSVG)(({ color }: SvgProps) =>
|
||||
css({
|
||||
"& > *": {
|
||||
fill: typeof color === "undefined" ? "inherit" : color || "black",
|
||||
},
|
||||
flexShrink: 0,
|
||||
} as SystemStyleObject)
|
||||
);
|
||||
|
||||
export function StarIcon(props: StarIconProps) {
|
||||
return (
|
||||
<Svg {...props}>
|
||||
<path d="M9.72024 1.7095c.043-.97631 1.31686-1.317634 1.84226-.49363l1.595 2.50165c.3931.61651 1.2933.61651 1.6864 0l1.595-2.50164c.5254-.824012 1.7993-.482689 1.8423.49362l.1305 2.96401c.0322.73046.8118 1.18056 1.4604.84319l2.6322-1.36896c.867-.45092 1.7995.48159 1.3486 1.3486L22.484 8.12852c-.3374.64867.1127 1.42827.8431 1.46044l2.9641.13054c.9763.04299 1.3176 1.3168.4936 1.8422l-2.5017 1.5951c-.6165.3931-.6165 1.2933 0 1.6863l2.5017 1.5951c.824.5254.4827 1.7992-.4936 1.8422l-2.9641.1306c-.7304.0321-1.1805.8117-.8431 1.4604l1.3689 2.6322c.4509.867-.4816 1.7995-1.3486 1.3486l-2.6322-1.369c-.6486-.3374-1.4282.1127-1.4604.8432l-.1305 2.964c-.043.9763-1.3169 1.3176-1.8423.4936l-1.595-2.5016c-.3931-.6165-1.2933-.6165-1.6864 0l-1.595 2.5016c-.5254.824-1.79926.4827-1.84226-.4936l-.13053-2.964c-.03217-.7305-.81177-1.1806-1.46045-.8432l-2.63218 1.369c-.867.4509-1.79951-.4816-1.3486-1.3486l1.36897-2.6322c.33736-.6487-.11274-1.4283-.84319-1.4604l-2.96402-.1306c-.976304-.043-1.317628-1.3168-.49362-1.8422l2.50165-1.5951c.6165-.393.6165-1.2932 0-1.6863l-2.50165-1.5951c-.824006-.5254-.482684-1.79921.49362-1.8422l2.96402-.13054c.73045-.03217 1.18056-.81177.84319-1.46044L4.14848 5.49634c-.45091-.86701.4816-1.79952 1.3486-1.3486L8.12926 5.5167c.64868.33737 1.42828-.11273 1.46045-.84319l.13053-2.96401z" />
|
||||
</Svg>
|
||||
);
|
||||
}
|
@ -48,7 +48,7 @@ const StatusBar = (props) => {
|
||||
|
||||
const anchorRef = useRef(null);
|
||||
|
||||
const leapHighlight = useTutorialModal('leap', true, anchorRef.current);
|
||||
const leapHighlight = useTutorialModal('leap', true, anchorRef);
|
||||
|
||||
const floatLeap = leapHighlight && window.matchMedia('(max-width: 550px)').matches;
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user