mirror of
https://github.com/urbit/shrub.git
synced 2024-12-25 04:52:06 +03:00
Merge branch 'release/next-js' into la/release-2021-03-04
This commit is contained in:
commit
b2759b9f36
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:9812a52d34be0d6d47ca60b23d3386e7db296ff61fac7c4b1f33a35806f8cb7c
|
||||
size 9751012
|
||||
oid sha256:ec80a42446a1d80974f32bf87283435547441cb7ea3fcd340711df2ce6cbec81
|
||||
size 9146390
|
||||
|
@ -593,10 +593,10 @@
|
||||
%& (ship p.lane)
|
||||
::
|
||||
%|
|
||||
?~ l=((soft ,[=@tas =@if =@ud]) (cue p.lane))
|
||||
s+(scot %x p.lane)
|
||||
=, u.l
|
||||
(tape "%{(trip tas)}, {(scow %if if)}, {(scow %ud ud)}")
|
||||
%- tape
|
||||
=/ ip=@if (end [0 32] p.lane)
|
||||
=/ pt=@ud (cut 0 [32 16] p.lane)
|
||||
"{(scow %if ip)}:{((d-co:co 1) pt)} ({(scow %ux p.lane)})"
|
||||
==
|
||||
==
|
||||
::
|
||||
|
@ -5,7 +5,7 @@
|
||||
easy-print=language-server-easy-print,
|
||||
rune-snippet=language-server-rune-snippet,
|
||||
build=language-server-build,
|
||||
default-agent
|
||||
default-agent, verb
|
||||
|%
|
||||
+$ card card:agent:gall
|
||||
+$ lsp-req
|
||||
@ -44,6 +44,7 @@
|
||||
==
|
||||
--
|
||||
^- agent:gall
|
||||
%+ verb |
|
||||
=| state-zero
|
||||
=* state -
|
||||
=<
|
||||
@ -69,7 +70,7 @@
|
||||
|= old-state=vase
|
||||
^- (quip card _this)
|
||||
~& > %lsp-upgrade
|
||||
[~ this(state *state-zero)]
|
||||
[~ this(state !<(state-zero old-state))]
|
||||
::
|
||||
++ on-poke
|
||||
^+ on-poke:*agent:gall
|
||||
@ -275,12 +276,14 @@
|
||||
++ handle-did-open
|
||||
|= item=text-document-item:lsp-sur
|
||||
^- (quip card _state)
|
||||
=/ =path
|
||||
(uri-to-path:build uri.item)
|
||||
?: ?=(%sys -.path)
|
||||
`state
|
||||
=/ buf=wall
|
||||
(to-wall (trip text.item))
|
||||
=. bufs
|
||||
(~(put by bufs) uri.item buf)
|
||||
=/ =path
|
||||
(uri-to-path:build uri.item)
|
||||
:_ state
|
||||
%+ weld
|
||||
(give-rpc-notification (get-diagnostics uri.item))
|
||||
@ -318,12 +321,12 @@
|
||||
?~ p.tab-list ~
|
||||
?~ u.p.tab-list ~
|
||||
:- ~
|
||||
%- crip
|
||||
;: weld
|
||||
"`"
|
||||
~(ram re ~(duck easy-print detail.i.u.p.tab-list))
|
||||
"`"
|
||||
==
|
||||
=- (crip :(weld "```hoon\0a" tape "\0a```"))
|
||||
^- =tape
|
||||
%- zing
|
||||
%+ join "\0a"
|
||||
%+ scag 40
|
||||
(~(win re ~(duck easy-print detail.i.u.p.tab-list)) 0 140)
|
||||
::
|
||||
++ sync-buf
|
||||
|= [buf=wall changes=(list change:lsp-sur)]
|
||||
|
@ -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])
|
||||
::
|
||||
|
@ -61,14 +61,24 @@
|
||||
::NOTE we only count graphs for now
|
||||
?. &(=(%graph app-name.m) =(our creator.metadatum)) ~
|
||||
`[module.metadatum resource.m]
|
||||
:: for sanity checks
|
||||
::
|
||||
=/ real=(set resource:re)
|
||||
=/ upd=update:ga
|
||||
%+ scry update:ga
|
||||
[%x %graph-store /keys/graph-update]
|
||||
?> ?=(%keys -.q.upd)
|
||||
resources.q.upd
|
||||
:: count activity per channel
|
||||
::
|
||||
=/ activity=(list [resource:re members=@ud (list [resource:re mod=term week=@ud authors=@ud])])
|
||||
%+ turn crowds
|
||||
|= [g=resource:re m=@ud]
|
||||
:+ g m
|
||||
%+ turn (~(got by channels) g)
|
||||
%+ murn (~(got by channels) g)
|
||||
|= [m=term r=resource:re]
|
||||
?. (~(has in real) r) ~
|
||||
%- some
|
||||
:+ r m
|
||||
::NOTE graph-store doesn't use the full resource-style path here!
|
||||
=/ upd=update:ga
|
||||
|
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)
|
||||
~
|
||||
==
|
||||
--
|
@ -185,6 +185,7 @@
|
||||
[%zpmc *] (both p.gen q.gen)
|
||||
[%zpts *] loop(gen p.gen)
|
||||
[%zppt *] (both q.gen r.gen)
|
||||
[%zpgl *] (spec-and-hoon p.gen q.gen)
|
||||
[%zpzp *] ~
|
||||
*
|
||||
=+ doz=~(open ap gen)
|
||||
@ -245,15 +246,25 @@
|
||||
^- (unit [term type])
|
||||
~
|
||||
::
|
||||
++ get-id-sym
|
||||
|= [pos=@ud =tape]
|
||||
%^ get-id pos tape
|
||||
^- $-(nail (like (unit @t)))
|
||||
;~(sfix (punt sym) (star ;~(pose prn (just `@`10))))
|
||||
::
|
||||
++ get-id-cord
|
||||
|= [pos=@ud =tape]
|
||||
%^ get-id pos tape
|
||||
^- $-(nail (like (unit @t)))
|
||||
;~(sfix (punt (cook crip (star prn))) (star ;~(pose prn (just `@`10))))
|
||||
::
|
||||
++ get-id
|
||||
|= [pos=@ud txt=tape]
|
||||
|= [pos=@ud txt=tape seek=$-(nail (like (unit @t)))]
|
||||
^- [forward=(unit @t) backward=(unit @t) id=(unit @t)]
|
||||
=/ seek
|
||||
;~(sfix (punt (cook crip (star prn))) (star ;~(pose prn (just `@`10))))
|
||||
=/ forward=(unit @t)
|
||||
(scan (slag pos txt) seek)
|
||||
=/ backward=(unit @t)
|
||||
%- (lift |=(t=@tas (swp 3 t)))
|
||||
%- (lift |=(t=@t (swp 3 t)))
|
||||
(scan (flop (scag pos txt)) seek)
|
||||
=/ id=(unit @t)
|
||||
?~ forward
|
||||
@ -272,7 +283,7 @@
|
||||
^- [back-pos=@ud fore-pos=@ud txt=tape]
|
||||
:: Find beg-pos by searching backward to where the current term
|
||||
:: begins
|
||||
=+ (get-id pos txt)
|
||||
=+ (get-id-sym pos txt)
|
||||
=/ back-pos
|
||||
?~ backward
|
||||
pos
|
||||
@ -343,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 +<)
|
||||
|
@ -291,7 +291,7 @@
|
||||
++ tab
|
||||
|= pos=@ud
|
||||
^- (quip card _cli-state)
|
||||
=+ (get-id:auto pos (tufa buf.cli-state))
|
||||
=+ (get-id-cord:auto pos (tufa buf.cli-state))
|
||||
=/ needle=term
|
||||
(fall id %$)
|
||||
:: autocomplete empty command iff user at start of command
|
||||
|
@ -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
|
||||
--
|
||||
|
@ -1,4 +1,4 @@
|
||||
|_ dat=@t
|
||||
|_ dat=@
|
||||
++ grow
|
||||
|%
|
||||
++ mime [/image/png (as-octs:mimes:html dat)]
|
||||
@ -6,7 +6,7 @@
|
||||
++ grab
|
||||
|%
|
||||
++ mime |=([p=mite q=octs] q.q)
|
||||
++ noun @t
|
||||
++ noun @
|
||||
--
|
||||
++ 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))
|
||||
|
36
pkg/interface/package-lock.json
generated
36
pkg/interface/package-lock.json
generated
@ -2264,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": {
|
||||
@ -6692,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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -7443,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",
|
||||
@ -9620,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": {
|
||||
@ -10378,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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
142
pkg/interface/src/logic/lib/gcpManager.ts
Normal file
142
pkg/interface/src/logic/lib/gcpManager.ts
Normal file
@ -0,0 +1,142 @@
|
||||
// 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 does not have GCP storage configured, we don't try to get
|
||||
// a token, but we keep checking at regular intervals to see if it gets
|
||||
// configured. If GCP storage is configured, we try to invoke the GCP
|
||||
// get-token thread on the ship until it gives us an access token. Once
|
||||
// we have a token, we refresh it every hour or so according to its
|
||||
// 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;
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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: {},
|
||||
@ -116,6 +121,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();
|
||||
@ -116,8 +119,8 @@ class App extends React.Component {
|
||||
|
||||
faviconString() {
|
||||
let background = '#ffffff';
|
||||
if (this.state.contacts.hasOwnProperty('/~/default')) {
|
||||
background = `#${uxToHex(this.state.contacts['/~/default'][window.ship].color)}`;
|
||||
if (this.state.contacts.hasOwnProperty(`~${window.ship}`)) {
|
||||
background = `#${uxToHex(this.state.contacts[`~${window.ship}`].color)}`;
|
||||
}
|
||||
const foreground = foregroundFromBackground(background);
|
||||
const svg = sigiljs({
|
||||
|
@ -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';
|
||||
@ -180,7 +179,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;
|
||||
@ -207,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']);
|
||||
|
@ -156,7 +156,8 @@ h2 {
|
||||
blockquote {
|
||||
padding: 0 0 0 16px;
|
||||
margin: 0;
|
||||
border-left: 1px solid black;
|
||||
color: inherit;
|
||||
border-left: 1px solid;
|
||||
}
|
||||
|
||||
:root {
|
||||
@ -173,6 +174,7 @@ blockquote {
|
||||
height: 100% !important;
|
||||
width: 100% !important;
|
||||
cursor: text;
|
||||
color: inherit;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
@ -308,9 +310,6 @@ pre.CodeMirror-placeholder.CodeMirror-line-like {
|
||||
/* dark */
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
blockquote {
|
||||
border-left: 1px solid inherit;
|
||||
}
|
||||
|
||||
/* codemirror */
|
||||
.chat .cm-s-tlon.CodeMirror {
|
||||
|
@ -33,9 +33,9 @@ export function LinkResource(props: LinkResourceProps) {
|
||||
associations,
|
||||
graphKeys,
|
||||
unreads,
|
||||
s3,
|
||||
history,
|
||||
pendingIndices
|
||||
pendingIndices,
|
||||
storage,
|
||||
history
|
||||
} = props;
|
||||
|
||||
const rid = association.resource;
|
||||
@ -70,7 +70,7 @@ export function LinkResource(props: LinkResourceProps) {
|
||||
return (
|
||||
<LinkWindow
|
||||
key={rid}
|
||||
s3={s3}
|
||||
storage={storage}
|
||||
association={resource}
|
||||
contacts={contacts}
|
||||
resource={resourcePath}
|
||||
|
@ -1,21 +1,21 @@
|
||||
import React, { useRef, useCallback, useEffect, useMemo } from 'react';
|
||||
import React, {
|
||||
useRef,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
Component,
|
||||
} from "react";
|
||||
|
||||
import { Col, Text } from '@tlon/indigo-react';
|
||||
import bigInt from 'big-integer';
|
||||
import {
|
||||
Association,
|
||||
Graph,
|
||||
Unreads,
|
||||
Group,
|
||||
Rolodex,
|
||||
} from '@urbit/api';
|
||||
import { Col, Text } from "@tlon/indigo-react";
|
||||
import bigInt from "big-integer";
|
||||
import { Association, Graph, Unreads, Group, Rolodex } from "@urbit/api";
|
||||
|
||||
import GlobalApi from '~/logic/api/global';
|
||||
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 GlobalApi from "~/logic/api/global";
|
||||
import VirtualScroller from "~/views/components/VirtualScroller";
|
||||
import { LinkItem } from "./components/LinkItem";
|
||||
import LinkSubmit from "./components/LinkSubmit";
|
||||
import { isWriter } from "~/logic/lib/group";
|
||||
import { StorageState } from "~/types";
|
||||
|
||||
interface LinkWindowProps {
|
||||
association: Association;
|
||||
@ -29,77 +29,111 @@ interface LinkWindowProps {
|
||||
group: Group;
|
||||
path: string;
|
||||
api: GlobalApi;
|
||||
s3: S3State;
|
||||
storage: StorageState;
|
||||
}
|
||||
export function LinkWindow(props: LinkWindowProps) {
|
||||
const { graph, api, association, pendingSize } = props;
|
||||
const fetchLinks = useCallback(
|
||||
async (newer: boolean) => {
|
||||
return true;
|
||||
/* stubbed, should we generalize the display of graphs in virtualscroller? */
|
||||
}, []
|
||||
);
|
||||
|
||||
const first = graph.peekLargest()?.[0];
|
||||
const [,,ship, name] = association.resource.split('/');
|
||||
const canWrite = isWriter(props.group, association.resource);
|
||||
const style = {
|
||||
height: "100%",
|
||||
width: "100%",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
};
|
||||
|
||||
const style = useMemo(() =>
|
||||
({
|
||||
height: '100%',
|
||||
width: '100%',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center'
|
||||
}), []);
|
||||
export class LinkWindow extends Component<LinkWindowProps, {}> {
|
||||
fetchLinks = async () => true;
|
||||
|
||||
if (!first) {
|
||||
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} />
|
||||
canWrite() {
|
||||
const { group, association } = this.props;
|
||||
return isWriter(group, association.resource);
|
||||
}
|
||||
|
||||
renderItem = ({ index, scrollWindow }) => {
|
||||
const { props } = this;
|
||||
const { association, graph, api } = props;
|
||||
const [, , ship, name] = association.resource.split("/");
|
||||
const node = graph.get(index);
|
||||
const first = graph.peekLargest()?.[0];
|
||||
const post = node?.post;
|
||||
if (!node || !post) {
|
||||
return null;
|
||||
}
|
||||
const linkProps = {
|
||||
...props,
|
||||
node,
|
||||
};
|
||||
if (this.canWrite() && index.eq(first ?? bigInt.zero)) {
|
||||
return (
|
||||
<React.Fragment key={index.toString()}>
|
||||
<Col
|
||||
key={index.toString()}
|
||||
mx="auto"
|
||||
mt="4"
|
||||
maxWidth="768px"
|
||||
width="100%"
|
||||
flexShrink={0}
|
||||
px={3}
|
||||
>
|
||||
<LinkSubmit
|
||||
storage={props.storage}
|
||||
name={name}
|
||||
ship={ship.slice(1)}
|
||||
api={api}
|
||||
/>
|
||||
</Col>
|
||||
<LinkItem {...linkProps} />
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
return <LinkItem key={index.toString()} {...linkProps} />;
|
||||
};
|
||||
|
||||
render() {
|
||||
const { graph, api, association, storage, pendingSize } = this.props;
|
||||
const first = graph.peekLargest()?.[0];
|
||||
const [, , ship, name] = association.resource.split("/");
|
||||
if (!first) {
|
||||
return (
|
||||
<Col
|
||||
key={0}
|
||||
mx="auto"
|
||||
mt="4"
|
||||
maxWidth="768px"
|
||||
width="100%"
|
||||
flexShrink={0}
|
||||
px={3}
|
||||
>
|
||||
{this.canWrite() ? (
|
||||
<LinkSubmit
|
||||
storage={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>
|
||||
)
|
||||
}
|
||||
<Text>
|
||||
There are no links here yet. You do not have permission to post to
|
||||
this collection.
|
||||
</Text>
|
||||
)}
|
||||
</Col>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Col width="100%" height="100%" position="relative">
|
||||
<VirtualScroller
|
||||
origin="top"
|
||||
offset={0}
|
||||
style={style}
|
||||
data={graph}
|
||||
averageHeight={100}
|
||||
size={graph.size}
|
||||
pendingSize={pendingSize}
|
||||
renderer={this.renderItem}
|
||||
loadRows={this.fetchLinks}
|
||||
/>
|
||||
</Col>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Col width="100%" height="100%" position="relative">
|
||||
<VirtualScroller
|
||||
origin="top"
|
||||
style={style}
|
||||
onStartReached={() => {}}
|
||||
onScroll={() => {}}
|
||||
data={graph}
|
||||
averageHeight={100}
|
||||
size={graph.size}
|
||||
pendingSize={pendingSize}
|
||||
renderer={({ index, scrollWindow }) => {
|
||||
const node = graph.get(index);
|
||||
const post = node?.post;
|
||||
if (!node || !post)
|
||||
return null;
|
||||
const linkProps = {
|
||||
...props,
|
||||
node,
|
||||
};
|
||||
if(canWrite && index.eq(first ?? bigInt.zero)) {
|
||||
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} />
|
||||
</Col>
|
||||
<LinkItem {...linkProps} />
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
return <LinkItem key={index.toString()} {...linkProps} />;
|
||||
}}
|
||||
loadRows={fetchLinks}
|
||||
/>
|
||||
</Col>
|
||||
);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -48,7 +48,7 @@ const emptyContact = {
|
||||
};
|
||||
|
||||
export function ProfileHeaderImageEdit(props: any): ReactElement {
|
||||
const { contact, s3, setFieldValue, handleHideCover } = { ...props };
|
||||
const { contact, storage, setFieldValue, handleHideCover } = { ...props };
|
||||
const [editCover, setEditCover] = useState(false);
|
||||
const [removedCoverLabel, setRemovedCoverLabel] = useState('Remove Header');
|
||||
const handleClear = (e) => {
|
||||
@ -63,7 +63,7 @@ export function ProfileHeaderImageEdit(props: any): ReactElement {
|
||||
{contact?.cover ? (
|
||||
<div>
|
||||
{editCover ? (
|
||||
<ImageInput id='cover' s3={s3} marginTop='-8px' />
|
||||
<ImageInput id='cover' storage={storage} marginTop='-8px' />
|
||||
) : (
|
||||
<Row>
|
||||
<Button mr='2' onClick={() => setEditCover(true)}>
|
||||
@ -76,14 +76,14 @@ export function ProfileHeaderImageEdit(props: any): ReactElement {
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<ImageInput id='cover' s3={s3} marginTop='-8px' />
|
||||
<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) => {
|
||||
@ -179,7 +179,7 @@ export function EditProfile(props: any): ReactElement {
|
||||
<ProfileImages hideCover={hideCover} contact={contact} ship={ship}>
|
||||
<ProfileHeaderImageEdit
|
||||
contact={contact}
|
||||
s3={props.s3}
|
||||
storage={storage}
|
||||
setFieldValue={setFieldValue}
|
||||
handleHideCover={handleHideCover}
|
||||
/>
|
||||
@ -193,14 +193,14 @@ export function EditProfile(props: any): ReactElement {
|
||||
<ImageInput
|
||||
id='avatar'
|
||||
label='Overlay Avatar (may be hidden by other users)'
|
||||
s3={props.s3}
|
||||
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} s3={props.s3} />
|
||||
<MarkdownField id='bio' mb={3} storage={storage} />
|
||||
</Col>
|
||||
<Checkbox mb={3} id='isPublic' label='Public Profile' />
|
||||
<GroupSearch
|
||||
|
@ -167,11 +167,11 @@ export function Profile(props: any): ReactElement {
|
||||
<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}
|
||||
/>
|
||||
@ -187,7 +187,7 @@ export function Profile(props: any): ReactElement {
|
||||
<EditProfile
|
||||
ship={ship}
|
||||
contact={contact}
|
||||
s3={props.s3}
|
||||
storage={props.storage}
|
||||
api={props.api}
|
||||
groups={props.groups}
|
||||
associations={props.associations}
|
||||
|
@ -46,7 +46,7 @@ export default function ProfileScreen(props: any) {
|
||||
groups={props.groups}
|
||||
contact={contact}
|
||||
api={props.api}
|
||||
s3={props.s3}
|
||||
storage={props.storage}
|
||||
isEdit={isEdit}
|
||||
isPublic={isPublic}
|
||||
nackedContacts={props.nackedContacts}
|
||||
|
@ -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);
|
||||
@ -28,6 +28,7 @@ export const MarkdownField = ({
|
||||
width="100%"
|
||||
display="flex"
|
||||
flexDirection="column"
|
||||
color="black"
|
||||
{...rest}
|
||||
>
|
||||
<MarkdownEditor
|
||||
@ -35,7 +36,7 @@ export const MarkdownField = ({
|
||||
onBlur={handleBlur}
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
s3={s3}
|
||||
storage={storage}
|
||||
/>
|
||||
<ErrorLabel mt="2" hasError={Boolean(error && touched)}>
|
||||
{error}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Box, Text, Col } from '@tlon/indigo-react';
|
||||
import { Box, Text, Col, Anchor } from '@tlon/indigo-react';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import bigInt from 'big-integer';
|
||||
|
||||
@ -32,6 +32,14 @@ export function Note(props: NoteProps & RouteComponentProps) {
|
||||
const { notebook, note, contacts, ship, book, api, rootUrl, baseUrl, group } = props;
|
||||
const editCommentId = props.match.params.commentId;
|
||||
|
||||
const renderers = {
|
||||
link: ({ href, children }) => {
|
||||
return (
|
||||
<Anchor display="inline" target="_blank" href={href}>{children}</Anchor>
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
const deletePost = async () => {
|
||||
setDeleting(true);
|
||||
const indices = [note.post.index];
|
||||
@ -107,7 +115,7 @@ export function Note(props: NoteProps & RouteComponentProps) {
|
||||
</Box>
|
||||
</Col>
|
||||
<Box color="black" className="md" style={{ overflowWrap: 'break-word', overflow: 'hidden' }}>
|
||||
<ReactMarkdown source={body} linkTarget={'_blank'} />
|
||||
<ReactMarkdown source={body} linkTarget={'_blank'} renderers={renderers} />
|
||||
</Box>
|
||||
<NoteNavigation
|
||||
notebook={notebook}
|
||||
|
@ -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>
|
||||
|
@ -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) {
|
||||
@ -50,7 +51,7 @@ export default function NewPost(props: NewPostProps & RouteComponentProps) {
|
||||
onSubmit={onSubmit}
|
||||
submitLabel="Publish"
|
||||
loadingText="Posting..."
|
||||
s3={props.s3}
|
||||
storage={props.storage}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
@ -41,6 +41,8 @@
|
||||
cursor: text;
|
||||
font-size: 12px;
|
||||
line-height: 20px;
|
||||
background: inherit;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.publish .CodeMirror * {
|
||||
|
@ -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} />
|
||||
|
@ -67,6 +67,7 @@ export default class TermApp extends Component {
|
||||
backgroundColor='white'
|
||||
width='100%'
|
||||
minHeight='0'
|
||||
minWidth='0'
|
||||
color='washedGray'
|
||||
borderRadius='2'
|
||||
mx={['0','3']}
|
||||
|
@ -13,6 +13,7 @@ export class History extends Component {
|
||||
<Box
|
||||
height='100%'
|
||||
minHeight='0'
|
||||
minWidth='0'
|
||||
display='flex'
|
||||
flexDirection='column-reverse'
|
||||
overflowY='scroll'
|
||||
|
@ -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);
|
||||
|
||||
|
@ -24,20 +24,50 @@ interface RendererProps {
|
||||
}
|
||||
|
||||
interface VirtualScrollerProps<T> {
|
||||
/**
|
||||
* Start scroll from
|
||||
*/
|
||||
origin: 'top' | 'bottom';
|
||||
/**
|
||||
* Load more of the graph
|
||||
*
|
||||
* @returns boolean whether or not the graph is now fully loaded
|
||||
*/
|
||||
loadRows(newer: boolean): Promise<boolean>;
|
||||
/**
|
||||
* The data to iterate over
|
||||
*/
|
||||
data: BigIntOrderedMap<T>;
|
||||
id: string;
|
||||
/**
|
||||
* The component to render the items
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* This component must be referentially stable, so either use `useCallback` or
|
||||
* a instance method. It must also forward the DOM ref from its root DOM node
|
||||
*/
|
||||
renderer: (props: RendererProps) => JSX.Element | null;
|
||||
onStartReached?(): void;
|
||||
onEndReached?(): void;
|
||||
size: number;
|
||||
pendingSize: number;
|
||||
totalSize: number;
|
||||
/**
|
||||
* Average height of a single rendered item
|
||||
*
|
||||
* @remarks
|
||||
* This is used primarily to calculate how many items should be onscreen. If
|
||||
* size is variable, err on the lower side.
|
||||
*/
|
||||
averageHeight: number;
|
||||
/**
|
||||
* The offset to begin rendering at, on load.
|
||||
*
|
||||
* @remarks
|
||||
* This is only looked up once, on component creation. Subsequent changes to
|
||||
* this prop will have no effect
|
||||
*/
|
||||
offset: number;
|
||||
onCalculateVisibleItems?(visibleItems: BigIntOrderedMap<T>): void;
|
||||
onScroll?({ scrollTop, scrollHeight, windowHeight }): void;
|
||||
style?: any;
|
||||
}
|
||||
|
||||
@ -62,6 +92,12 @@ const ZONE_SIZE = IS_IOS ? 10 : 40;
|
||||
// nb: in this file, an index refers to a BigInteger and an offset refers to a
|
||||
// number used to index a listified BigIntOrderedMap
|
||||
|
||||
/**
|
||||
* A virtualscroller for a `BigIntOrderedMap`.
|
||||
*
|
||||
* VirtualScroller does not clean up or reset itself, so please use `key`
|
||||
* to ensure a new instance is created for each BigIntOrderedMap
|
||||
*/
|
||||
export default class VirtualScroller<T> extends Component<VirtualScrollerProps<T>, VirtualScrollerState<T>> {
|
||||
/**
|
||||
* A reference to our scroll container
|
||||
@ -88,8 +124,6 @@ export default class VirtualScroller<T> extends Component<VirtualScrollerProps<T
|
||||
*/
|
||||
private saveDepth = 0;
|
||||
|
||||
private isUpdating = false;
|
||||
|
||||
private scrollLocked = true;
|
||||
|
||||
private pageSize = 50;
|
||||
@ -98,7 +132,6 @@ export default class VirtualScroller<T> extends Component<VirtualScrollerProps<T
|
||||
|
||||
private scrollRef: HTMLElement | null = null;
|
||||
|
||||
|
||||
private loaded = {
|
||||
top: false,
|
||||
bottom: false
|
||||
@ -186,7 +219,6 @@ export default class VirtualScroller<T> extends Component<VirtualScrollerProps<T
|
||||
return;
|
||||
}
|
||||
log('reflow', `from: ${this.startOffset()} to: ${newOffset}`);
|
||||
this.isUpdating = true;
|
||||
|
||||
const { data, onCalculateVisibleItems } = this.props;
|
||||
const visibleItems = new BigIntOrderedMap<any>(
|
||||
@ -195,14 +227,12 @@ export default class VirtualScroller<T> extends Component<VirtualScrollerProps<T
|
||||
|
||||
this.save();
|
||||
|
||||
onCalculateVisibleItems ? onCalculateVisibleItems(visibleItems) : null;
|
||||
this.setState({
|
||||
visibleItems,
|
||||
}, () => {
|
||||
requestAnimationFrame(() => {
|
||||
this.restore();
|
||||
requestAnimationFrame(() => {
|
||||
this.isUpdating = false;
|
||||
|
||||
});
|
||||
});
|
||||
|
@ -1,12 +0,0 @@
|
||||
import React from 'react';
|
||||
import useS3 from '~/logic/lib/useS3';
|
||||
|
||||
const withS3 = (Component, params = {}) => {
|
||||
return React.forwardRef((props: any, ref) => {
|
||||
const s3 = useS3(props.s3, params);
|
||||
|
||||
return <Component ref={ref} {...s3} {...props} />;
|
||||
});
|
||||
};
|
||||
|
||||
export default withS3;
|
12
pkg/interface/src/views/components/withStorage.tsx
Normal file
12
pkg/interface/src/views/components/withStorage.tsx
Normal file
@ -0,0 +1,12 @@
|
||||
import React from 'react';
|
||||
import useStorage from '~/logic/lib/useStorage';
|
||||
|
||||
const withStorage = (Component, params = {}) => {
|
||||
return React.forwardRef((props: any, ref) => {
|
||||
const storage = useStorage(props.storage, params);
|
||||
|
||||
return <Component ref={ref} {...storage} {...props} />;
|
||||
});
|
||||
};
|
||||
|
||||
export default withStorage;
|
@ -21,7 +21,7 @@ import { ColorInput } from '~/views/components/ColorInput';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { uxToHex } from '~/logic/lib/util';
|
||||
import { ImageInput } from '~/views/components/ImageInput';
|
||||
import { S3State } from '~/types/s3-update';
|
||||
import { StorageState } from '~/types';
|
||||
|
||||
interface FormSchema {
|
||||
title: string;
|
||||
@ -44,11 +44,11 @@ interface GroupAdminSettingsProps {
|
||||
group: Group;
|
||||
association: Association;
|
||||
api: GlobalApi;
|
||||
s3: S3State;
|
||||
storage: StorageState;
|
||||
}
|
||||
|
||||
export function GroupAdminSettings(props: GroupAdminSettingsProps) {
|
||||
const { group, association, s3 } = props;
|
||||
const { group, association, storage } = props;
|
||||
const { metadata } = association;
|
||||
const history = useHistory();
|
||||
const currentPrivate = 'invite' in props.group.policy;
|
||||
@ -131,7 +131,7 @@ return null;
|
||||
caption="A picture for your group"
|
||||
placeholder="Enter URL"
|
||||
disabled={disabled}
|
||||
s3={s3}
|
||||
storage={storage}
|
||||
/>
|
||||
<Checkbox
|
||||
id="isPrivate"
|
||||
|
@ -11,7 +11,7 @@ import { GroupPersonalSettings } from './Personal';
|
||||
import { GroupChannelSettings } from './Channels';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { resourceFromPath, roleForShip } from '~/logic/lib/group';
|
||||
import { S3State } from '~/types';
|
||||
import { StorageState } from '~/types';
|
||||
|
||||
const Section = ({ children }) => (
|
||||
<Box boxShadow="inset 0px 1px 0px rgba(0, 0, 0, 0.2)">{children}</Box>
|
||||
@ -23,7 +23,7 @@ interface GroupSettingsProps {
|
||||
associations: Associations;
|
||||
api: GlobalApi;
|
||||
notificationsGroupConfig: GroupNotificationsConfig;
|
||||
s3: S3State;
|
||||
storage: StorageState;
|
||||
baseUrl: string;
|
||||
}
|
||||
export function GroupSettings(props: GroupSettingsProps) {
|
||||
|
@ -70,7 +70,7 @@ export function GroupsPane(props: GroupsPaneProps) {
|
||||
association={groupAssociation!}
|
||||
group={group!}
|
||||
api={api}
|
||||
s3={props.s3}
|
||||
storage={props.storage}
|
||||
notificationsGroupConfig={props.notificationsGroupConfig}
|
||||
associations={associations}
|
||||
|
||||
|
@ -15,7 +15,7 @@ import { DeleteGroup } from './DeleteGroup';
|
||||
import { resourceFromPath } from '~/logic/lib/group';
|
||||
import { ModalOverlay } from '~/views/components/ModalOverlay';
|
||||
import { SidebarItem } from '~/views/landscape/components/SidebarItem';
|
||||
import { S3State } from '~/types';
|
||||
import { StorageState } from '~/types';
|
||||
|
||||
export function PopoverRoutes(
|
||||
props: {
|
||||
@ -24,7 +24,7 @@ export function PopoverRoutes(
|
||||
group: Group;
|
||||
association: Association;
|
||||
associations: Associations;
|
||||
s3: S3State;
|
||||
storage: StorageState;
|
||||
api: GlobalApi;
|
||||
notificationsGroupConfig: GroupNotificationsConfig;
|
||||
rootIdentity: Contact;
|
||||
@ -128,7 +128,7 @@ export function PopoverRoutes(
|
||||
api={props.api}
|
||||
notificationsGroupConfig={props.notificationsGroupConfig}
|
||||
associations={props.associations}
|
||||
s3={props.s3}
|
||||
storage={props.storage}
|
||||
/>
|
||||
)}
|
||||
{view === 'participants' && (
|
||||
|
53
sh/poke-gcp-account-json
Executable file
53
sh/poke-gcp-account-json
Executable file
@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import json
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def herb_poke_gcp_setting(pier, key, val):
|
||||
"""
|
||||
Poke a value into settings-store under the %gcp-store bucket.
|
||||
|
||||
This does not sanitize or check its inputs. Please make sure they are
|
||||
correct before calling this function.
|
||||
|
||||
:pier: Pier of the ship to poke.
|
||||
:key: Key to poke. Must be a @tas (i.e. include the '%').
|
||||
:val: Value to poke. Must be a @t. (will be passed through crude_t.)
|
||||
"""
|
||||
print('herb_poke ' + key)
|
||||
# XXX use +same because herb's cell parser is cursed.
|
||||
poke_arg = "(same %put-entry %gcp-store {} %s {})".format(
|
||||
key, crude_t(val))
|
||||
return subprocess.run(['herb', pier, '-p', 'settings-store', '-d',
|
||||
poke_arg, '-m', 'settings-event'],
|
||||
check=True)
|
||||
|
||||
def crude_t(pin):
|
||||
"""
|
||||
Very crude, bad, dangerous, and evil @t transform.
|
||||
|
||||
Puts single quotes around the string. Escapes instances of single quote and
|
||||
backslash within the string, and turns newlines into \0a.
|
||||
"""
|
||||
replaces = [(r'\\', r'\\\\'), ("'", r"\\'"), ("\n", r'\\0a')]
|
||||
for pattern, replace in replaces:
|
||||
pin = re.sub(pattern, replace, pin, flags=re.MULTILINE)
|
||||
return "'{}'".format(pin)
|
||||
|
||||
def read_gcp_json(keyfile):
|
||||
with open(keyfile, 'r') as f:
|
||||
return json.loads(f.read())
|
||||
|
||||
def main():
|
||||
pier, keyfile = sys.argv[1:]
|
||||
obj = read_gcp_json(keyfile)
|
||||
herb_poke_gcp_setting(pier, '%token-uri', obj['token_uri'])
|
||||
herb_poke_gcp_setting(pier, '%client-email', obj['client_email'])
|
||||
herb_poke_gcp_setting(pier, '%private-key-id', obj['private_key_id'])
|
||||
herb_poke_gcp_setting(pier, '%private-key', obj['private_key'])
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in New Issue
Block a user