mirror of
https://github.com/urbit/shrub.git
synced 2024-12-14 11:08:45 +03:00
Merge branch 'master' of https://github.com/urbit/urbit
This commit is contained in:
commit
383b75a47b
@ -492,7 +492,7 @@
|
||||
+>.$(hoc.saf (~(put by hoc.saf) her [[~31337.1.1 ~ wil] ~ *clot]))
|
||||
::
|
||||
++ lax :: lax:as:go
|
||||
|_ [her=ship dur=door] :: per client
|
||||
|_ [her=ship dur=dore] :: per client
|
||||
++ cluy :: cluy:lax:as:go
|
||||
^- [p=life q=gens r=acru] :: client crypto
|
||||
?~ lew.wod.dur !!
|
||||
@ -683,19 +683,19 @@
|
||||
-- :: --zuul:lax:as:go
|
||||
-- :: --lax:as:go
|
||||
::
|
||||
++ gur :: default door
|
||||
++ gur :: default dore
|
||||
|= her=ship
|
||||
^- door
|
||||
^- dore
|
||||
=+ def=?.((lth her 256) ~ [~ %if ~2000.1.1 0 (mix her .0.0.1.0)])
|
||||
[[~2100.1.1 def ~] ~ *clot]
|
||||
::
|
||||
++ myx :: door by ship
|
||||
++ myx :: dore by ship
|
||||
|= her=ship
|
||||
^+ lax
|
||||
=+ fod=(~(get by hoc.saf) her)
|
||||
~(. lax [her ?~(fod (gur her) u.fod)])
|
||||
::
|
||||
++ nux :: install door
|
||||
++ nux :: install dore
|
||||
|= new=_lax
|
||||
^+ +>
|
||||
+>(hoc.saf (~(put by hoc.saf) her.new dur.new))
|
||||
|
312
arvo/eyre.hoon
312
arvo/eyre.hoon
@ -116,7 +116,7 @@
|
||||
cow=(map ,@ud clue) :: consoles
|
||||
cug=(list ,@t) :: unacked cookies
|
||||
lax=@da :: last used
|
||||
sok=(map ,@ud (trel term ship sink)) :: live apps by reqno
|
||||
sok=(map ,@ud (pair ship sink)) :: live apps by reqno
|
||||
rey=[p=@ud q=(map ,@ud pimp)] :: live requests
|
||||
== ::
|
||||
++ dual ,[p=@ud q=(each ,[p=ship q=hole] ship)] :: request handle
|
||||
@ -148,12 +148,12 @@
|
||||
rem=[p=@ud q=(map ,@ud duct)] :: active requests
|
||||
== ::
|
||||
++ seam :: logical request
|
||||
$% [%ape p=term q=ship r=@ud s=@ud t=@ud] :: subscribe pull
|
||||
[%aph p=term q=ship r=@ud s=@ud t=json] :: app heartbeat
|
||||
$% [%ape p=ship q=@ud r=@ud] :: subscribe pull
|
||||
[%aph p=ship q=@ud r=@ud s=json] :: app heartbeat
|
||||
[%apg p=term q=ship r=logo s=path] :: app get/start
|
||||
[%apm p=term q=ship r=@ud s=@ud t=json] :: message send
|
||||
[%aps p=term q=ship r=@ud s=@ud t=path] :: subscribe
|
||||
[%apu p=term q=ship r=@ud s=@ud] :: unsubscribe
|
||||
[%apm p=ship q=@ud r=@ud s=hasp t=json] :: message send
|
||||
[%aps p=ship q=@ud s=hasp t=path] :: subscribe
|
||||
[%apu p=ship q=@ud s=hasp t=path] :: unsubscribe
|
||||
[%cog p=@ud q=@ud] :: console get
|
||||
[%con p=@ud] :: console face
|
||||
[%cop p=@ud q=@ud r=json] :: console put
|
||||
@ -169,13 +169,13 @@
|
||||
cah=(map cash vase) :: compilation cache
|
||||
== ::
|
||||
++ sink :: page push system
|
||||
$: bet=[num=@ud tim=@da] :: heartbeat
|
||||
meg=@ud :: message counter
|
||||
haw=(map ,@ud swig) :: subscriptions
|
||||
$: bet=[wig=swig num=@ud tim=@da] :: heartbeat
|
||||
meg=[wig=swig num=@ud] :: messages
|
||||
sub=[wig=swig num=@ud can=(map ,@ud stem)] :: subscriptions
|
||||
== ::
|
||||
++ stem ,[p=hasp q=path r=duct s=(unit ,@ud)] :: subscription
|
||||
++ swig :: update channel
|
||||
$: hen=duct :: channel duct
|
||||
cnt=@ud :: updates produced
|
||||
$: cnt=@ud :: updates produced
|
||||
toy=@ud :: updates sent
|
||||
wan=(map ,@ud ,@ud) :: upno to reqno
|
||||
red=(map ,@ud (unit (each cage cage))) :: ready for pickup
|
||||
@ -196,6 +196,24 @@
|
||||
?~ u.mar ^$(cok t.cok)
|
||||
?:(=(nam p.i.u.mar) [~ q.i.u.mar] $(u.mar t.u.mar))
|
||||
::
|
||||
++ ecca :: [hasp path]
|
||||
|= [orx=oryx moh=moth]
|
||||
^- (unit ,[hasp path])
|
||||
=+ jun=(ecci orx moh)
|
||||
?~ jun ~
|
||||
=+ ^- (unit ,[his=term app=term pax=term])
|
||||
%. u.jun
|
||||
%- ot:jo
|
||||
~[[%ship so:jo] [%appl so:jo] [%path so:jo]]
|
||||
?~ - ~
|
||||
=+ his=(slaw %p (cat 3 '~' his.u))
|
||||
?~ his ~
|
||||
=+ ^= pax
|
||||
%+ rush pax.u
|
||||
;~(pfix fas (more fas (cook crip (plus ;~(pose low nud hep)))))
|
||||
?~ pax ~
|
||||
`[[u.his app.u] u.pax]
|
||||
::
|
||||
++ ecce :: JS from moth
|
||||
|= moh=moth
|
||||
^- (unit json)
|
||||
@ -224,6 +242,20 @@
|
||||
=+ zeb=(~(get by mah) cus)
|
||||
$(hed t.hed, mah (~(put by mah) cus ?~(zeb [q.i.hed ~] [q.i.hed u.zeb])))
|
||||
::
|
||||
++ eccu :: [hasp json]
|
||||
|= [orx=oryx moh=moth]
|
||||
^- (unit ,[hasp json])
|
||||
=+ jun=(ecci orx moh)
|
||||
?~ jun ~
|
||||
=+ ^- (unit ,[his=term app=term jon=json])
|
||||
%. u.jun
|
||||
%- ot:jo
|
||||
~[[%ship so:jo] [%appl so:jo] [%data |=(json (some +<))]]
|
||||
?~ - ~
|
||||
=+ his=(slaw %p (cat 3 '~' his.u))
|
||||
?~ his ~
|
||||
`[[u.his app.u] jon.u]
|
||||
::
|
||||
++ lopo :: cage to love
|
||||
|= cay=cage
|
||||
^- love
|
||||
@ -330,7 +362,7 @@
|
||||
+>.$(mow [[hen %slip %d %flog +.sih] mow])
|
||||
::
|
||||
?(%dumb %mean %nice %rush %rust)
|
||||
?> ?=([%hoop @ @ @ @ ~] tea)
|
||||
?> ?=([%hoop @ @ @ ?([%mess ~] [%show @ ~])] tea)
|
||||
=+ ^= ouy
|
||||
%- yolk:(gale (slav %p i.t.tea) i.t.t.tea)
|
||||
(slav %ud i.t.t.t.tea)
|
||||
@ -338,13 +370,14 @@
|
||||
+>.$
|
||||
?: (lth ~m2 (sub now tim.bet.siq:beat:u.ouy))
|
||||
abet:work:amok:u.ouy
|
||||
=+ woy=(yule:u.ouy (slav %ud i.t.t.t.t.tea))
|
||||
=* mab t.t.t.t.tea
|
||||
=+ woy=(yule:u.ouy ?+(i.mab !! %mess %meg, %show %sub))
|
||||
=< abet =< work =< abet
|
||||
?- -.+.sih
|
||||
%dumb
|
||||
dumb:woy
|
||||
%mean
|
||||
=+ ^= jso
|
||||
=+ ^= jon
|
||||
%- jobe
|
||||
:- [%ok %b |]
|
||||
?~ p.+.sih ~
|
||||
@ -357,12 +390,44 @@
|
||||
|= [p=tank q=tape]
|
||||
:(weld q "\\n" ~(ram re p))
|
||||
~
|
||||
(hear:woy ~ %& %json !>(jso))
|
||||
?~ t.mab
|
||||
(hear:woy ~ %& %json !>(jon))
|
||||
=+ nap=(slav %ud i.t.mab)
|
||||
=+ sem=(need (~(get by can.sub.siq:beat:u.ouy) nap))
|
||||
=. jon
|
||||
?. ?=(%show i.t.t.t.t.tea) jon
|
||||
%- jobe
|
||||
:~ [%ship %s (rsh 3 1 (scot %p p.p.sem))]
|
||||
[%appl %s q.p.sem]
|
||||
[%path %s (crip <q.sem>)]
|
||||
[%data `json`jon]
|
||||
==
|
||||
=+ huq=``[%json !>(jon)]
|
||||
?~ s.sem (hear:woy huq)
|
||||
=+ yoo=abet:(busk:(yule:u.ouy %nil) u.s.sem 0 huq)
|
||||
yoo(can.sub.siq (~(put by can.sub.siq.yoo) nap sem(s ~)))
|
||||
%nice
|
||||
?> ?=(%mess i.mab)
|
||||
(hear:woy ~ %& %json !>((joba %ok %b &)))
|
||||
?(%rust %rush)
|
||||
=+ cay=`cage`[p.+.sih (slot 3 (spec (slot 3 [typ +.sih])))]
|
||||
(hear:woy ~ ?:(?=(%rust -.+.sih) [%& cay] [%| cay]))
|
||||
?< ?=(~ t.mab)
|
||||
=+ nap=(slav %ud i.t.mab)
|
||||
=+ sem=(need (~(get by can.sub.siq:beat:u.ouy) nap))
|
||||
=+ ^= cay ^- cage
|
||||
?. ?=(%json p.+.sih)
|
||||
[p.+.sih (slot 3 (spec (slot 3 [typ +.sih])))]
|
||||
:- %json
|
||||
!> ^- json
|
||||
%- jobe
|
||||
:~ [%ship %s (rsh 3 1 (scot %p p.p.sem))]
|
||||
[%appl %s q.p.sem]
|
||||
[%path %s (crip <q.sem>)]
|
||||
[%data (json q.+.sih)]
|
||||
==
|
||||
=+ huq=`?:(?=(%rust -.+.sih) [%& cay] [%| cay])
|
||||
?~ s.sem (hear:woy huq)
|
||||
=+ yoo=abet:(busk:(yule:u.ouy %nil) u.s.sem 0 huq)
|
||||
yoo(can.sub.siq (~(put by can.sub.siq.yoo) nap sem(s ~)))
|
||||
==
|
||||
::
|
||||
%made
|
||||
@ -1047,7 +1112,7 @@
|
||||
|
||||
method = "put"
|
||||
perm = "tih"
|
||||
url = [perm,user,appl,port,heart.seqn]
|
||||
url = [perm,user,port,heart.seqn]
|
||||
url = "/"+url.join("/")
|
||||
|
||||
$this = this
|
||||
@ -1069,47 +1134,17 @@
|
||||
}
|
||||
heart.beat()
|
||||
'''
|
||||
++ duty :: reload script
|
||||
;script
|
||||
; var tries = 0;
|
||||
; var cnt = 0;
|
||||
; var next = "/gie/"+user+"/"+appl+"/"+port+"/0/"+(cnt + 1);
|
||||
; call = function() {
|
||||
; xhr = new XMLHttpRequest();
|
||||
; xhr.open('GET', next, true);
|
||||
; xhr.addEventListener('load', function() {
|
||||
; if ( this.status >= 500 ) {
|
||||
; return delay();
|
||||
; }
|
||||
; cnt++;
|
||||
; if ( this.status >= 400 ) {
|
||||
; document.alert("neighbor, please.");
|
||||
; }
|
||||
; document.location.reload();
|
||||
; });
|
||||
; xhr.addEventListener('error', delay);
|
||||
; xhr.addEventListener('abort', delay);
|
||||
; xhr.send();
|
||||
; }
|
||||
; delay = function() {
|
||||
; setTimeout(call,1000*tries);
|
||||
; tries++;
|
||||
; }
|
||||
; call();
|
||||
==
|
||||
::
|
||||
++ fape :: dispatch %ape
|
||||
|= [fur=(unit term) you=@p paw=path]
|
||||
^- (unit seam)
|
||||
?> ?=(~ fur)
|
||||
?> ?=([@ @ @ @ ~] paw)
|
||||
?> ?=([@ @ ~] paw)
|
||||
:- ~
|
||||
:* %ape
|
||||
(need ((sand %tas) i.paw))
|
||||
you
|
||||
(slav %ui (cat 3 '0i' i.paw))
|
||||
(slav %ui (cat 3 '0i' i.t.paw))
|
||||
(slav %ui (cat 3 '0i' i.t.t.paw))
|
||||
(slav %ui (cat 3 '0i' i.t.t.t.paw))
|
||||
==
|
||||
::
|
||||
++ fapg :: dispatch %apg
|
||||
@ -1129,13 +1164,12 @@
|
||||
|= [fur=(unit term) you=@p paw=path moh=moth]
|
||||
^- (unit seam)
|
||||
?> ?=(~ fur)
|
||||
?> ?=([@ @ @ ~] paw)
|
||||
?> ?=([@ @ ~] paw)
|
||||
:- ~
|
||||
:* %aph
|
||||
(need ((sand %tas) i.paw))
|
||||
you
|
||||
(slav %ui (cat 3 '0i' i.paw))
|
||||
(slav %ui (cat 3 '0i' i.t.paw))
|
||||
(slav %ui (cat 3 '0i' i.t.t.paw))
|
||||
(need (ecci orx.ced moh))
|
||||
==
|
||||
::
|
||||
@ -1143,42 +1177,37 @@
|
||||
|= [fur=(unit term) you=@p paw=path moh=moth]
|
||||
^- (unit seam)
|
||||
?> ?=(~ fur)
|
||||
?> ?=([@ @ @ ~] paw)
|
||||
?> ?=([@ @ ~] paw)
|
||||
:- ~
|
||||
:* %apm
|
||||
(need ((sand %tas) i.paw))
|
||||
you
|
||||
(slav %ui (cat 3 '0i' i.paw))
|
||||
(slav %ui (cat 3 '0i' i.t.paw))
|
||||
(slav %ui (cat 3 '0i' i.t.t.paw))
|
||||
(need (ecci orx.ced moh))
|
||||
(need (eccu orx.ced moh))
|
||||
==
|
||||
::
|
||||
++ faps :: dispatch %aps
|
||||
|= [fur=(unit term) you=@p paw=path moh=moth]
|
||||
^- (unit seam)
|
||||
?> ?=(~ fur)
|
||||
?> ?=([@ @ @ *] paw)
|
||||
?> !=(~ (ecci orx.ced moh))
|
||||
?> ?=([@ ~] paw)
|
||||
:- ~
|
||||
:* %aps
|
||||
(need ((sand %tas) i.paw))
|
||||
you
|
||||
(slav %ui (cat 3 '0i' i.t.paw))
|
||||
(slav %ui (cat 3 '0i' i.t.t.paw))
|
||||
(turn t.t.t.paw |=(a=@ `@ta`(need ((sand %ta) a))))
|
||||
==
|
||||
(slav %ui (cat 3 '0i' i.paw))
|
||||
(need (ecca orx.ced moh))
|
||||
==
|
||||
::
|
||||
++ fapu :: dispatch %apu
|
||||
|= [fur=(unit term) you=@p paw=path]
|
||||
|= [fur=(unit term) you=@p paw=path moh=moth]
|
||||
^- (unit seam)
|
||||
?> ?=(~ fur)
|
||||
?> ?=([@ @ @ ~] paw)
|
||||
?> ?=([@ ~] paw)
|
||||
:- ~
|
||||
:* %apu
|
||||
(need ((sand %tas) i.paw))
|
||||
you
|
||||
(slav %ui (cat 3 '0i' i.t.paw))
|
||||
(slav %ui (cat 3 '0i' i.t.t.paw))
|
||||
(slav %ui (cat 3 '0i' i.paw))
|
||||
(need (ecca orx.ced moh))
|
||||
==
|
||||
::
|
||||
++ flea :: permissive decimal
|
||||
@ -1435,7 +1464,7 @@
|
||||
%l (foom moh)
|
||||
%m (fapm p.q.pul yun paw moh)
|
||||
%s (faps p.q.pul yun paw moh)
|
||||
%u (fapu p.q.pul yun paw)
|
||||
%u (fapu p.q.pul yun paw moh)
|
||||
==
|
||||
::
|
||||
%t
|
||||
@ -1444,7 +1473,7 @@
|
||||
%h (faph p.q.pul yun paw moh)
|
||||
%m (fapm p.q.pul yun paw moh)
|
||||
%s (faps p.q.pul yun paw moh)
|
||||
%u (fapu p.q.pul yun paw)
|
||||
%u (fapu p.q.pul yun paw moh)
|
||||
==
|
||||
==
|
||||
::
|
||||
@ -1562,8 +1591,7 @@
|
||||
:: [%stream s.som.pip]
|
||||
:: [%request t.som.pip]
|
||||
:: ==
|
||||
:- [~ pip(pez %way)]
|
||||
(yoke num +.som.pip)
|
||||
[`(fall +< -(pez %way)) +>]:[pip (yoke num +.som.pip)]
|
||||
::
|
||||
%apg :: simple get
|
||||
:: ~& :~ %eyre-apg
|
||||
@ -1593,7 +1621,6 @@
|
||||
::
|
||||
%apu :: unsubscribe
|
||||
:: ~& [%wink-apu +.som.pip]
|
||||
:- [~ pip(pez %way)]
|
||||
(yoku num +.som.pip)
|
||||
::
|
||||
%con
|
||||
@ -1979,41 +2006,49 @@
|
||||
$(+ sez)
|
||||
::
|
||||
++ yoke :: long poll
|
||||
|= [num=@ud app=term you=ship nap=@ud suq=@ud cnt=@ud]
|
||||
^+ +>
|
||||
=+ yon=(yolk nap)
|
||||
?~ yon (bust 204 num)
|
||||
abet:(hire:(yule:u.yon suq) cnt num)
|
||||
|= [num=@ud you=ship nap=@ud cnt=@ud]
|
||||
^- [(unit pimp) _+>]
|
||||
=+ yon=(yolk nap)
|
||||
?~ yon `(bust 204 num)
|
||||
=. +>.$ abet:(hire:(yule %sub):u.yon cnt num)
|
||||
:_ +>.$
|
||||
=+ pup=(~(get by q.rey) num)
|
||||
?~ pup ~
|
||||
?. ?=(%sil -.som.u.pup) ~
|
||||
`u.pup
|
||||
::
|
||||
++ yokg :: main call
|
||||
|= [num=@ud app=term you=ship pax=path]
|
||||
^+ +>
|
||||
?< (~(has by sok) num)
|
||||
abet:(~(self yo num app you [[*@ud now] *[@ud (map ,@ud swig)]]) pax)
|
||||
abet:(~(self yo num you [-(tim.bet +)]:[*sink now]) app pax)
|
||||
::
|
||||
++ yokh :: heartbeat
|
||||
|= [num=@ud app=term you=ship nap=@ud cnt=@ud jon=json]
|
||||
|= [num=@ud you=ship nap=@ud cnt=@ud jon=json]
|
||||
^- [(unit pimp) _+>]
|
||||
=+ yon=(yolk nap)
|
||||
?~ yon [~ (bust 204 num)]
|
||||
[- abet:+]:(beat:u.yon cnt num jon)
|
||||
::
|
||||
++ yokm :: message
|
||||
|= [num=@ud app=term you=ship nap=@ud cnt=@ud jon=json]
|
||||
|= [num=@ud you=ship nap=@ud cnt=@ud hap=hasp jon=json]
|
||||
^+ +>
|
||||
=+ yon=(yolk nap)
|
||||
?~ yon (bust 204 num)
|
||||
abet:(post:u.yon cnt num jon)
|
||||
abet:(post:u.yon cnt num hap jon)
|
||||
::
|
||||
++ yoks :: subscribe
|
||||
|= [num=@ud app=term you=ship nap=@ud suq=@ud pax=path]
|
||||
|= [num=@ud you=ship nap=@ud hap=hasp pax=path]
|
||||
=+ yon=(yolk nap)
|
||||
?~ yon (bust 204 num)
|
||||
abet:(scud:u.yon suq num pax)
|
||||
abet:(scud:u.yon num hap pax)
|
||||
::
|
||||
++ yoku :: unsubscribe
|
||||
|= [num=@ud app=term you=ship nap=@ud suq=@ud]
|
||||
!!
|
||||
|= [num=@ud you=ship nap=@ud hap=hasp pax=path]
|
||||
^- [(unit pimp) _+>]
|
||||
=+ yon=(yolk nap)
|
||||
?~ yon [~ (bust 204 num)]
|
||||
[- abet:+]:(scad:u.yon num hap pax)
|
||||
::
|
||||
++ yolk :: yo by instance
|
||||
|= nap=@ud
|
||||
@ -2023,18 +2058,17 @@
|
||||
::
|
||||
++ yo :: app instance
|
||||
|_ $: nap=@ud :: instance number
|
||||
app=term :: application name
|
||||
you=ship :: client identity
|
||||
siq=sink :: instance state
|
||||
==
|
||||
++ abet :: resolve
|
||||
%_ ..yo
|
||||
sok (~(put by sok) nap [app you siq])
|
||||
sok (~(put by sok) nap [you siq])
|
||||
==
|
||||
::
|
||||
++ amok :: demolish
|
||||
^+ ..yo
|
||||
=+ wuh=(~(tap by haw.siq) ~)
|
||||
=+ wuh=(~(tap by can.sub.siq))
|
||||
|- ^+ ..yo
|
||||
?~ wuh
|
||||
%= ..yo
|
||||
@ -2043,7 +2077,7 @@
|
||||
%= $
|
||||
wuh t.wuh
|
||||
..amok
|
||||
(pass(hen hen.q.i.wuh) p.i.wuh `note`[%g %nuke [our app] you])
|
||||
(pass(hen r.q.i.wuh) `p.i.wuh `note`[%g %nuke p.q.i.wuh you])
|
||||
==
|
||||
::
|
||||
++ beat
|
||||
@ -2051,62 +2085,82 @@
|
||||
^- [(unit pimp) _+>]
|
||||
?. =(cnt num.bet.siq)
|
||||
[~ +>.$(..yo (bust 204 num))]
|
||||
=. bet.siq [+(num.bet.siq) now]
|
||||
=. +>.$ (hire:(yule 2) cnt num)
|
||||
=. +>.$ (hear:(yule 2) ~ %& %json !>((joba %a-ok %b %&)))
|
||||
=. bet.siq bet.siq(num +(num.bet.siq), tim now)
|
||||
=. +>.$ (hire:(yule %bet) cnt num)
|
||||
=. +>.$ (hear:(yule %bet) ~ %& %json !>((joba %a-ok %b %&)))
|
||||
[`(need (~(get by q.rey) num)) +>.$]
|
||||
::
|
||||
++ hoop :: request path
|
||||
|= suq=@ud
|
||||
|= can=(unit ,@ud)
|
||||
^- path
|
||||
:~ %hoop
|
||||
:* %hoop
|
||||
(scot %p our)
|
||||
ses
|
||||
(scot %ud nap)
|
||||
(scot %ud suq)
|
||||
?~ can
|
||||
[%mess ~]
|
||||
[%show (scot %ud u.can) ~]
|
||||
==
|
||||
::
|
||||
++ pass :: pass
|
||||
|= [suq=@ud noh=note]
|
||||
|= [can=(unit ,@ud) noh=note]
|
||||
^+ +>
|
||||
+>(mow [[hen %pass (hoop suq) noh] mow])
|
||||
+>(mow [[hen %pass (hoop can) noh] mow])
|
||||
::
|
||||
++ post :: transmit
|
||||
|= [cnt=@ud num=@ud jon=json]
|
||||
|= [cnt=@ud num=@ud hap=hasp jon=json]
|
||||
^+ +>
|
||||
=. +>.$
|
||||
?. =(cnt meg.siq) +>.$
|
||||
%+ pass(meg.siq +(meg.siq))
|
||||
1
|
||||
`note`[%g %mess [our app] you [%json !>(jon)]]
|
||||
?. =(+(cnt) meg.siq)
|
||||
=. +>.$
|
||||
?. =(cnt num.meg.siq) +>.$
|
||||
%+ pass(num.meg.siq +(num.meg.siq)) ~
|
||||
`note`[%g %mess hap you [%json !>(jon)]]
|
||||
?. =(+(cnt) num.meg.siq)
|
||||
+>.$(..yo (bust 204 num))
|
||||
(hire:(yule 1) cnt num)
|
||||
(hire:(yule %meg) cnt num)
|
||||
::
|
||||
++ scad
|
||||
|= [num=@ud hap=hasp pax=path]
|
||||
^- [(unit pimp) _+>]
|
||||
=. +>.$
|
||||
%+ ~(rep by can.sub.siq) +>.$
|
||||
|= [p=[p=@ud q=stem] q=_+>.$]
|
||||
?. =([hap pax] [p.q.p q.q.p]) q
|
||||
=. q q(can.sub.siq (~(del by can.sub.siq:q) p.p))
|
||||
([-(hen +)]:[pass:q r.q.p] `p.p %g %nuke hap you)
|
||||
=+ huq=[~ %& %json !>((joba %ok %b %&))]
|
||||
=. +>.$ abet:(busk:(yule %nil) num 0 huq)
|
||||
[`(need (~(get by q.rey) num)) +>.$]
|
||||
::
|
||||
++ scud :: subscribe
|
||||
|= [suq=@ud num=@ud pax=path]
|
||||
=. +>.$ (pass suq `note`[%g %show [our app] you pax])
|
||||
(hire:(yule suq) 0 num)
|
||||
|= [num=@ud hap=hasp pax=path]
|
||||
=. can.sub.siq (~(put by can.sub.siq) num.sub.siq [hap pax hen `num])
|
||||
=. +>.$ (pass `num.sub.siq `note`[%g %show hap you pax])
|
||||
=. num.sub.siq +(num.sub.siq)
|
||||
+>.$
|
||||
::
|
||||
++ self :: request main
|
||||
|= pax=path
|
||||
|= [app=term pax=path]
|
||||
^+ +>
|
||||
(hire:(yule:(pass 0 [%g %show [our app] you pax]) 0) 0 nap)
|
||||
=. can.sub.siq (~(put by can.sub.siq) 0 [[our app] pax hen `nap])
|
||||
=. num.sub.siq +(num.sub.siq)
|
||||
(pass `0 [%g %show [our app] you pax])
|
||||
::
|
||||
++ yule :: swig state
|
||||
|= suq=@ud
|
||||
%~ . yu
|
||||
:- suq
|
||||
=+ wig=(~(get by haw.siq) suq)
|
||||
?~ wig [-(hen +)]:[*swig hen] u.wig
|
||||
++ yule
|
||||
|= pla=?(%bet %meg %sub %nil)
|
||||
%~ . yu :- pla
|
||||
=< wig
|
||||
?-(pla %bet bet.siq, %meg meg.siq, %sub sub.siq, %nil [wig=*swig ~])
|
||||
::
|
||||
++ yu :: swig state
|
||||
|_ [suq=@ud wig=swig]
|
||||
++ abet :: resolve
|
||||
%_(..yu haw.siq (~(put by haw.siq) suq wig))
|
||||
::
|
||||
++ amok
|
||||
%_(..yu haw.siq (~(del by haw.siq) suq))
|
||||
|_ [pla=?(%bet %meg %sub %nil) wig=swig]
|
||||
++ abet
|
||||
^+ ..yu
|
||||
?- pla
|
||||
%bet %_(..yu wig.bet.siq wig)
|
||||
%meg %_(..yu wig.meg.siq wig)
|
||||
%sub %_(..yu wig.sub.siq wig)
|
||||
%nil ..yu
|
||||
==
|
||||
::
|
||||
++ busk :: seam result
|
||||
|= $: num=@ud
|
||||
@ -2116,7 +2170,8 @@
|
||||
^+ +>
|
||||
=+ pup=(~(get by q.rey) num)
|
||||
?~ pup +>.$ :: XX a hack
|
||||
=. wig ?. =(toy.wig cnt)
|
||||
=. wig ?: ?=(%nil pla) wig
|
||||
?. =(toy.wig cnt)
|
||||
?>(=(toy.wig +(cnt)) wig)
|
||||
%= wig
|
||||
toy +(toy.wig)
|
||||
@ -2128,7 +2183,7 @@
|
||||
=+ pip=u.pup
|
||||
=+ ^= sip
|
||||
?. =(%apg -.som.pip) sip.pip
|
||||
[duti duty sip.pip]
|
||||
[duti sip.pip]
|
||||
?~ huq +>.$(..yo (bust 404 num))
|
||||
%= +>.$
|
||||
q.rey
|
||||
@ -2138,7 +2193,6 @@
|
||||
%= pip
|
||||
pez %new
|
||||
vaz :~ [%ship (quo (rsh 3 1 (scot %p our)))]
|
||||
[%appl (quo app)]
|
||||
[%port (trip (rsh 3 2 (scot %ui nap)))]
|
||||
[%auto "true"]
|
||||
[%oryx (quo orx.ced)]
|
||||
@ -2161,13 +2215,13 @@
|
||||
^+ ..yu
|
||||
=+ dum=(~(tap by wan.wig) ~)
|
||||
|- ^+ ..yu
|
||||
?~ dum amok
|
||||
?~ dum ..yu :: XX drop stream
|
||||
$(dum t.dum, ..yo (bust 404 q.i.dum))
|
||||
::
|
||||
++ hear :: produce
|
||||
|= huq=(unit (each cage cage))
|
||||
^+ ..yu
|
||||
=< abet
|
||||
=< abet
|
||||
=+ cnt=cnt.wig
|
||||
=+ dul=(~(get by wan.wig) cnt)
|
||||
:: ~& :~ %yu-hear
|
||||
|
364
arvo/ford.hoon
364
arvo/ford.hoon
@ -10,13 +10,25 @@
|
||||
++ gift :: out result <-$
|
||||
$% [%made p=(each bead (list tank))] :: computed result
|
||||
== ::
|
||||
++ heel path :: functional ending
|
||||
++ hock :: standard label
|
||||
$: [%c p=@ud] :: celsius version
|
||||
[%k p=@ud] :: kelvin version
|
||||
[%s p=@ud q=@ud r=@ud] :: semantic version
|
||||
== ::
|
||||
++ hood :: assembly plan
|
||||
$: sys=$|(@ud [@ud @ud]) :: system kelvin
|
||||
pro=(map term beam) :: protocols
|
||||
lib=(map term beam) :: libraries
|
||||
:: res=(map term (trel horn beam path)) :: resource trees
|
||||
$: [how=beam rem=heel] :: beam and remainder
|
||||
zus=@ud :: zuse kelvin
|
||||
pro=(list hoof) :: protocols
|
||||
lib=(list hoof) :: libraries
|
||||
:: res=(map term (pair beam horn)) :: resources
|
||||
src=(list hoop) :: program
|
||||
== ::
|
||||
++ hoof :: reference
|
||||
$% [%here p=term] :: name
|
||||
[%this p=term q=case] :: name, case
|
||||
[%that p=term q=case r=ship] :: name, case, ship
|
||||
== ::
|
||||
++ hoop :: source in hood
|
||||
$% [%code p=twig] :: direct twig
|
||||
[%cone p=beam] :: core from folder
|
||||
@ -28,7 +40,7 @@
|
||||
$| ~ :: leaf
|
||||
$% [%day p=horn] :: list by time
|
||||
[%fan p=(map term horn)] :: tuple
|
||||
[%for p=logo q=horn] :: leaf protocol
|
||||
[%for p=logo q=horn] :: leaf mark
|
||||
[%hub p=horn] :: list by number
|
||||
[%nap p=horn] :: soft map
|
||||
== ::
|
||||
@ -60,7 +72,7 @@
|
||||
[%dude p=tank q=silk] :: error wrap
|
||||
[%dune p=(set beam) q=(unit cage)] :: unit literal
|
||||
[%mute p=silk q=(list (pair wing silk))] :: mutant
|
||||
[%plan p=silk q=hood] :: structured build
|
||||
[%plan p=beam q=spur r=hood] :: structured assembly
|
||||
[%reef ~] :: kernel reef
|
||||
[%ride p=silk q=sill] :: obsolete old plan
|
||||
[%vale p=logo q=sack r=*] :: validate [our his]
|
||||
@ -110,9 +122,9 @@
|
||||
dep=(set beam) :: dependencies
|
||||
== ::
|
||||
++ calx :: concrete cache line
|
||||
$% [%hood p=calm q=(pair path cage) r=hood] :: compile to hood
|
||||
$% [%hood p=calm q=cage r=hood] :: compile to hood
|
||||
[%slap p=calm q=[p=vase q=twig] r=vase] :: slap
|
||||
[%twig p=calm q=(pair path cage) r=twig] :: compile to twig
|
||||
[%twig p=calm q=cage r=twig] :: compile to twig
|
||||
== ::
|
||||
++ task :: problem in progress
|
||||
$: nah=duct :: cause
|
||||
@ -125,6 +137,7 @@
|
||||
|* sem=* :: a typesystem hack
|
||||
|= cax=calx
|
||||
?+ sem !!
|
||||
%hood ?>(?=(%hood -.cax) r.cax)
|
||||
%twig ?>(?=(%twig -.cax) r.cax)
|
||||
%slap ?>(?=(%slap -.cax) r.cax)
|
||||
==
|
||||
@ -366,32 +379,83 @@
|
||||
%_(+> mow :_(mow [hen %give gef]))
|
||||
::
|
||||
++ fade :: compile %hood
|
||||
|= [cof=cafe kas=silk]
|
||||
|= [cof=cafe bem=beam rem=heel]
|
||||
^- (bolt hood)
|
||||
%. [cof %hoon kas]
|
||||
(fado |=(a=path (ifix [gay gay] hall:(vang | a))))
|
||||
=+ rul=(fair bem rem)
|
||||
%+ (clef %hood) (make cof [%bake %hoon bem rem])
|
||||
^- (burg cage hood)
|
||||
|= [cof=cafe cay=cage]
|
||||
?. ?=(@ q.q.cay)
|
||||
(flaw cof ~)
|
||||
=+ vex=((full rul) [[1 1] (trip q.q.cay)])
|
||||
?~ q.vex
|
||||
(flaw cof [%leaf "syntax error: {<p.p.vex>} {<q.p.vex>}"] ~)
|
||||
(fine cof p.u.q.vex)
|
||||
::
|
||||
++ fane :: compile %hoon
|
||||
|= [cof=cafe kas=silk]
|
||||
^- (bolt twig)
|
||||
%. [cof %hoon kas]
|
||||
(fado |=(a=path (ifix [gay gay] tall:(vang | a))))
|
||||
::
|
||||
++ fado :: compile by rule
|
||||
|* lur=$+(path rule)
|
||||
|= [cof=cafe for=logo kas=silk]
|
||||
%+ (clef %twig) (maid cof kas)
|
||||
^- (burg (pair path cage) twig)
|
||||
|= [cof=cafe pay=(pair path cage)]
|
||||
?. |(=(for p.q.pay) =(%noun p.q.pay))
|
||||
(flaw cof [%leaf "source error: {<p.pay>} must be %{<(trip for)>}"])
|
||||
?. ?=(@ q.q.q.pay)
|
||||
(flaw cof [%leaf "source error: {<p.pay>} must be flat"]~)
|
||||
=+ vex=((full (lur p.pay)) [[1 1] (trip q.q.q.pay)])
|
||||
=+ pax=(home kas)
|
||||
%+ (clef %twig) (make cof kas)
|
||||
^- (burg cage twig)
|
||||
|= [cof=cafe cay=cage]
|
||||
?. ?=(@ q.q.cay)
|
||||
(flaw cof ~)
|
||||
=+ rul=(ifix [gay gay] tall:(vang | pax))
|
||||
=+ vex=((full rul) [[1 1] (trip q.q.cay)])
|
||||
?~ q.vex
|
||||
(flaw cof [%leaf "syntax error: {<p.p.vex>} {<q.p.vex>}"] ~)
|
||||
(fine cof p.u.q.vex)
|
||||
::
|
||||
++ fair :: hood parsing rule
|
||||
|= [bem=beam rem=heel]
|
||||
=+ vez=(vang | (tope bem(s (weld rem s.bem))))
|
||||
=< hood
|
||||
|%
|
||||
++ case
|
||||
%- sear
|
||||
:_ nuck:so
|
||||
|= a=coin
|
||||
?. ?=([%$ ?(%da %ud %tas) *] a) ~
|
||||
[~ u=(^case a)]
|
||||
::
|
||||
++ hood
|
||||
%+ ifix [gay gay]
|
||||
%+ cook |=(a=^hood a)
|
||||
%+ stag [bem rem]
|
||||
;~ plug
|
||||
;~ pose
|
||||
(ifix [;~(plug pat wut gap) gap] dem)
|
||||
(easy zuse)
|
||||
==
|
||||
hoos
|
||||
hoos
|
||||
(star hoop)
|
||||
==
|
||||
::
|
||||
++ hoof
|
||||
%+ cook |=(a=^hoof a)
|
||||
;~ pose
|
||||
%+ stag %that
|
||||
;~(plug sym ;~(pfix fas case) ;~(pfix ;~(plug fas sig) fed:ag))
|
||||
::
|
||||
(stag %this ;~(plug sym ;~(pfix fas case)))
|
||||
(stag %here sym)
|
||||
==
|
||||
::
|
||||
++ hoos
|
||||
%+ cook |=(a=(list ^hoof) a)
|
||||
;~ pose
|
||||
(ifix [;~(plug pat lus gap) gap] (most ;~(plug com ace) hoof))
|
||||
(easy ~)
|
||||
==
|
||||
::
|
||||
++ hoop
|
||||
%+ knee *^hoop |. ~+
|
||||
%+ cook |=(a=^hoop a)
|
||||
(stag %code tall:vez)
|
||||
--
|
||||
::
|
||||
++ gush :: sill to twig
|
||||
|= [cof=cafe sil=sill]
|
||||
^- (bolt twig)
|
||||
@ -449,20 +513,26 @@
|
||||
(fine cof p.cay vax)
|
||||
::
|
||||
++ krab :: load to vase
|
||||
|= [cof=cafe for=logo how=logo bem=beam rem=spur]
|
||||
|= [cof=cafe for=logo how=logo bem=beam rem=heel]
|
||||
^- (bolt vase)
|
||||
%+ cope (fane cof %bake how bem rem)
|
||||
|= [cof=cafe gen=twig]
|
||||
(maim cof pit gen)
|
||||
::
|
||||
++ lace :: load and check
|
||||
|= [cof=cafe for=logo bem=beam rem=spur]
|
||||
|= [cof=cafe for=logo bem=beam rem=heel]
|
||||
^- (bolt (unit vase))
|
||||
=+ bek=`beak`[p.bem q.bem r.bem]
|
||||
%+ cope (lend cof bem)
|
||||
|= [cof=cafe arc=arch]
|
||||
?^ q.arc
|
||||
(cope (liar cof bem) (lake for bek))
|
||||
?: (~(has by r.arc) %hood)
|
||||
%+ cope (fade cof bem rem)
|
||||
|= [cof=cafe hyd=hood]
|
||||
%+ cope (abut:(meow bem rem) cof hyd)
|
||||
|= [cof=cafe vax=vase]
|
||||
(fine cof ~ vax)
|
||||
?: (~(has by r.arc) %hook)
|
||||
%+ cope (krab cof for %hook bem rem)
|
||||
|= [cof=cafe vax=vase]
|
||||
@ -478,7 +548,7 @@
|
||||
|= [for=logo bek=beak]
|
||||
|= [cof=cafe sam=vase]
|
||||
^- (bolt (unit vase))
|
||||
?: ?=(?(%gate %core %hoon %hook) for)
|
||||
?: ?=(?(%gate %core %hoon %hook %hood) for)
|
||||
(fine cof ~ sam)
|
||||
%+ cope (make cof %boil %gate [[p.bek %main r.bek] /ref/[for]/sys] ~)
|
||||
|= [cof=cafe cay=cage]
|
||||
@ -541,7 +611,7 @@
|
||||
(fine cof ?.(=(%hoon for) all [%hoot all]))
|
||||
::
|
||||
++ lima :: load at depth
|
||||
|= [cof=cafe for=logo bem=beam rem=spur]
|
||||
|= [cof=cafe for=logo bem=beam rem=heel]
|
||||
^- (bolt (unit vase))
|
||||
%+ cope (lend cof bem)
|
||||
|= [cof=cafe arc=arch]
|
||||
@ -561,7 +631,7 @@
|
||||
(fine cof ~ vax)
|
||||
::
|
||||
++ lime :: load beam
|
||||
|= [cof=cafe for=logo bem=beam rem=spur]
|
||||
|= [cof=cafe for=logo bem=beam rem=heel]
|
||||
=+ [mob=bem mer=(flop rem)]
|
||||
|- ^- (bolt vase)
|
||||
%+ cope (lima cof for mob (flop mer))
|
||||
@ -716,9 +786,9 @@
|
||||
::
|
||||
%mute (kale cof p.kas q.kas)
|
||||
%plan
|
||||
%+ cope (main cof p.kas)
|
||||
%+ cope (abut:(meow p.kas q.kas) cof r.kas)
|
||||
|= [cof=cafe vax=vase]
|
||||
(fine cof [%noun vax])
|
||||
(fine cof %noun vax)
|
||||
::
|
||||
%reef (fine cof %noun pit)
|
||||
%ride
|
||||
@ -751,150 +821,118 @@
|
||||
`vase`[p.top val]
|
||||
==
|
||||
::
|
||||
++ plow :: true build
|
||||
|= [cof=cafe pix=vase hyd=hood]
|
||||
=| :* rop=(map term twig)
|
||||
bil=(map term (trel beam (set term) twig))
|
||||
ser=(map logo (map term vase)) :: XX update for horn
|
||||
++ meow :: assemble
|
||||
|= [how=beam rem=heel]
|
||||
=| $: rop=(map term (pair hoof twig)) :: protocols known
|
||||
bil=(map term (pair hoof twig)) :: libraries known
|
||||
lot=(list term) :: library stack
|
||||
zeg=(set term) :: library guard
|
||||
boy=(list twig) :: body stack
|
||||
==
|
||||
=< apex
|
||||
|%
|
||||
++ abet :: emit as vase
|
||||
|= [gen=twig rex=vase]
|
||||
^- (bolt vase)
|
||||
%+ cope acme
|
||||
|= [cof=cafe lib=twig]
|
||||
%+ cope (maim cof pix [%tsgr able lib])
|
||||
|= [cof=cafe vax=vase]
|
||||
(maim cof ?~(ser vax (slop acta vax)) gen)
|
||||
++ abut :: generate
|
||||
|= [cof=cafe hyd=hood]
|
||||
%+ cope (apex cof hyd)
|
||||
|= [cof=cafe sel=_..abut]
|
||||
(maim cof pit able:sel)
|
||||
::
|
||||
++ able :: assemble preamble
|
||||
^- twig
|
||||
?~(rop [%$ 1] [%brcn (~(run by rop) |=(a=twig [%ash a]))])
|
||||
:+ %tsgr
|
||||
?:(=(~ rop) [%$ 1] [%brcn (~(run by rop) |=([* a=twig] [%ash a]))])
|
||||
:+ %tsgr
|
||||
[%tssg (turn (flop lot) |=(a=term q:(need (~(get by bil) a))))]
|
||||
[%tssg (flop boy)]
|
||||
::
|
||||
++ acta :: assemble resources
|
||||
^- vase
|
||||
=< apex
|
||||
|%
|
||||
++ apex
|
||||
?~ ser !!
|
||||
=+ top=(ayah p.n.ser (axel q.n.ser))
|
||||
?~ l.ser
|
||||
?~(r.ser top (slop top apex(ser r.ser)))
|
||||
=+ lef=apex(ser l.ser)
|
||||
?~(r.ser (slop lef top) :(slop lef top apex(ser r.ser)))
|
||||
::
|
||||
++ axel
|
||||
|= ryz=(map term vase)
|
||||
^= vax
|
||||
|- ^- vase
|
||||
?~ ryz !!
|
||||
=+ top=(ayah n.ryz)
|
||||
?~ l.ryz
|
||||
?~(r.ryz top (slop top $(ryz r.ryz)))
|
||||
=+ lef=$(ryz r.ryz)
|
||||
?~(r.ryz (slop lef top) :(slop lef top $(ryz r.ryz)))
|
||||
::
|
||||
++ ayah
|
||||
|= [cog=term vax=vase]
|
||||
[[%face cog p.vax] q.vax]
|
||||
--
|
||||
++ apex :: build to body
|
||||
|= [cof=cafe hyd=hood]
|
||||
^- (bolt ,_..apex)
|
||||
%+ cope (body cof src.hyd)
|
||||
|= [cof=cafe sel=_..apex]
|
||||
=. ..apex sel
|
||||
%+ cope (neck cof lib.hyd)
|
||||
|= [cof=cafe sel=_..apex]
|
||||
=. ..apex sel
|
||||
%+ cope (head cof pro.hyd)
|
||||
|= [cof=cafe sel=_..apex]
|
||||
(fine cof sel)
|
||||
::
|
||||
++ acme :: libraries in order
|
||||
^- (bolt twig)
|
||||
%- cope
|
||||
:_ |= [cof=cafe cus=(list twig)]
|
||||
(fine cof [%tssg cus])
|
||||
=+ kop=(turn (~(tap by bil) ~) |=([term *] -))
|
||||
=| [dun=(set term) cus=(list twig)]
|
||||
|- ^- (bolt (list twig))
|
||||
?~ kop (fine cof cus)
|
||||
=+ cog=i.kop
|
||||
?: (~(has in dun) cog) $(kop t.kop)
|
||||
=+ liv=`(set term)`[cog ~ ~]
|
||||
|- ^- (bolt (list twig))
|
||||
=+ zic=(need (~(get by bil) cog))
|
||||
=+ dez=`(list term)`(~(tap in q.zic) ~)
|
||||
|- ^- (bolt (list twig))
|
||||
?~ dez
|
||||
^^$(cus [p.zic cus], dun (~(put in dun) cog), kop t.kop)
|
||||
?: (~(has in dun) i.dez)
|
||||
$(dez t.dez)
|
||||
?: (~(has in liv) cog)
|
||||
(flaw cof [%leaf "build error: {<cog>} depends on itself}"])
|
||||
^$(cog i.dez, liv (~(put in liv) cog), kop [i.kop kop])
|
||||
++ body :: produce functions
|
||||
|= [cof=cafe src=(list hoop)]
|
||||
^- (bolt _..body)
|
||||
?~ src (fine cof ..body)
|
||||
%+ cope (wilt cof i.src)
|
||||
|= [cof=cafe sel=_..body]
|
||||
^$(cof cof, src t.src, ..body sel)
|
||||
::
|
||||
++ aloe :: process all
|
||||
^- (bolt (trel vase twig ,_..aloe))
|
||||
%+ cope body
|
||||
|= [cof=cafe cus=(list twig) sel=_..aloe]
|
||||
=. ..aloe sel(cof cof)
|
||||
%+ cope head
|
||||
|= [cof=cafe sel=_..aloe]
|
||||
=. ..aloe sel(cof cof)
|
||||
%+ cope butt
|
||||
|= [cof=cafe sel=_..aloe]
|
||||
:: =. ..aloe sel(cof cof)
|
||||
:: %+ cope eyes
|
||||
:: |= [cof=cafe pix=vase sel=_..aloe]
|
||||
:: (fine cof [%tssg (flop cus)] pix sel(cof cof))
|
||||
(fine cof [%tssg (flop cus)] !>(~) sel(cof cof))
|
||||
++ head :: consume protocols
|
||||
|= [cof=cafe bir=(list hoof)]
|
||||
|- ^- (bolt ,_..head)
|
||||
?~ bir (fine cof ..head)
|
||||
=+ cog=(heck i.bir)
|
||||
=+ byf=(~(get by rop) cog)
|
||||
?^ byf
|
||||
?. =(`hoof`i.bir `hoof`p.u.byf)
|
||||
(flaw cof [%leaf "protocol mismatch: {<~[cog p.u.byf i.bir]>}"]~)
|
||||
$(bir t.bir)
|
||||
=+ bem=(hone %gate %pro i.bir)
|
||||
%+ cope (fade cof bem ~)
|
||||
|= [cof=cafe hyd=hood]
|
||||
%+ cope (apex(lot ~) cof hyd)
|
||||
|= [cof=cafe sel=_..neck]
|
||||
=. ..head
|
||||
%= sel
|
||||
zeg zeg
|
||||
rop (~(put by rop) cog [i.bir [%tssg (flop boy.sel)]])
|
||||
==
|
||||
^^$(cof cof, bir t.bir)
|
||||
::
|
||||
++ apex :: top level
|
||||
^- (bolt vase)
|
||||
%+ cope aloe
|
||||
|= [cof=cafe cus=(list twig) sel=_..aloe]
|
||||
(abet:sel(cof cof) cus)
|
||||
++ heck :: hoof to name
|
||||
|= huf=hoof ^- term
|
||||
?-(-.huf %here p.huf, %this p.huf, %that p.huf)
|
||||
::
|
||||
++ body :: process body
|
||||
=+ cus=(list twig)
|
||||
|- ^- (bolt (pair (list twig) ,_..body))
|
||||
?~ src.hyd
|
||||
(fine cof cus ..body)
|
||||
%+ cope (wilt i.src.hyd)
|
||||
|= [cof=cafe gen=twig sel=_..body]
|
||||
$(src.hyd t.src.hyd, cus [gen cus], ..body sel(cof cof))
|
||||
::
|
||||
++ butt :: process libraries
|
||||
=+ bol=(~(tap by lib.hyd) ~)
|
||||
|- ^- (bolt ,_..butt)
|
||||
?~ bol ..butt
|
||||
?. =+ olb=(~(get by bil) p.i.bol)
|
||||
?~ olb &
|
||||
=(`beam`p.u.olb `beam`q.i.bol)
|
||||
(flaw cof [%leaf "build error: {<p.i.bol>} {<p.u.olb>} {<q.i.bol>}]~)
|
||||
%+ cope (wine q.i.bol)
|
||||
|= [cof=cafe gen=twig dep=(set term) dah=hood]
|
||||
^$(olb
|
||||
::
|
||||
++ wilt :: process body entry
|
||||
|= hop=hoop
|
||||
^- (bolt ,[p=twig q=_..wilt])
|
||||
?+ -.hop !!
|
||||
%code (fine p.hop ..wilt)
|
||||
%hoon (wine p.hop)
|
||||
++ hone :: plant hoof
|
||||
|= [for=@tas way=@tas huf=hoof]
|
||||
^- beam
|
||||
?- -.huf
|
||||
%here how(s ~[for p.huf way])
|
||||
%this [[p.how %main q.huf] ~[for p.huf way]]
|
||||
%that [[r.huf %main q.huf] ~[for p.huf way]]
|
||||
==
|
||||
::
|
||||
++ wind :: sub-hood, no deps
|
||||
|= bem=beam
|
||||
^- (bolt ,[p=twig r=_..wind])
|
||||
%+ cope (fade cof %bake %hoon bem ~)
|
||||
|= [cof=cafe dah=hood]
|
||||
%+ cope aloe(hyd dah)
|
||||
|= [cof=cafe cus=(list twig) sel=_..wind]
|
||||
(fine [%tssg (flop cus)] sel(hyd hyd, cof cof))
|
||||
++ neck :: consume libraries
|
||||
|= [cof=cafe bir=(list hoof)]
|
||||
^- (bolt ,_..neck)
|
||||
?~ bir (fine cof ..neck)
|
||||
=+ cog=(heck i.bir)
|
||||
?: (~(has in zeg) cog)
|
||||
(flaw cof [%leaf "circular dependency: {<~[cog i.bir]>}"]~)
|
||||
=+ goz=(~(put in zeg) cog)
|
||||
=+ byf=(~(get by bil) cog)
|
||||
?^ byf
|
||||
?. =(`hoof`i.bir `hoof`p.u.byf)
|
||||
(flaw cof [%leaf "library mismatch: {<~[cog p.u.byf i.bir]>}"]~)
|
||||
$(bir t.bir)
|
||||
=+ bem=(hone %core %lib i.bir)
|
||||
%+ cope (fade cof bem ~)
|
||||
|= [cof=cafe hyd=hood]
|
||||
%+ cope (apex(zeg goz, boy ~) cof hyd)
|
||||
|= [cof=cafe sel=_..neck]
|
||||
=. ..neck
|
||||
%= sel
|
||||
zeg zeg
|
||||
lot [cog lot]
|
||||
bil (~(put by bil) cog [i.bir [%tssg (flop boy.sel)]])
|
||||
==
|
||||
^^$(cof cof, bir t.bir)
|
||||
::
|
||||
++ wine :: sub-hood, deps
|
||||
|= bem=beam
|
||||
^- (bolt ,[p=twig q=(set term) r=_..wind])
|
||||
%+ cope (fade cof %bake %hoon bem ~)
|
||||
|= [cof=cafe dah=hood]
|
||||
%+ cope aloe(hyd dah, lib ~)
|
||||
|= [cof=cafe cus=(list twig) sel=_..wind]
|
||||
%^ fine
|
||||
[%tssg (flop cus)]
|
||||
lib.sel
|
||||
sel(hyd hyd, lib (~(uni in lib.sel) lib), cof cof)
|
||||
++ wilt :: process body entry
|
||||
|= [cof=cafe hop=hoop]
|
||||
^- (bolt _..wilt)
|
||||
?+ -.hop !!
|
||||
%code (fine cof ..wilt(boy [p.hop boy]))
|
||||
%hood (cope (fade cof p.hop ~) apex)
|
||||
==
|
||||
--
|
||||
::
|
||||
++ resp
|
||||
|
@ -15,7 +15,7 @@
|
||||
:::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
~% %k.164 ~ ~ ::
|
||||
|% ::
|
||||
++ stub %164 :: version stub
|
||||
++ hoon %164 :: version stub
|
||||
-- ::
|
||||
:::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
:::::: :::::: volume 1, Hoon models ::::::
|
||||
@ -1221,7 +1221,7 @@
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
:: section 2cG, floating point ::
|
||||
::
|
||||
++ rlyd |= red=@rd ^- [s=? h=@ f=@ e=(unit tape) n=?] !:
|
||||
++ rlyd |= red=@rd ^- [s=? h=@ f=@ e=(unit tape) n=?]
|
||||
~& [%rlyd `@ux`red]
|
||||
=+ s=(sea:rd red)
|
||||
=+ negexp==(1 (mod e.s 2))
|
||||
@ -1229,7 +1229,7 @@
|
||||
++ rlyh |=(reh=@rh ~|(%real-nyet ^-([s=? h=@ f=@ e=(unit tape) n=?] !!)))
|
||||
++ rlyq |=(req=@rq ~|(%real-nyet ^-([s=? h=@ f=@ e=(unit tape) n=?] !!)))
|
||||
++ rlys |=(res=@rs ~|(%real-nyet ^-([s=? h=@ f=@ e=(unit tape) n=?] !!)))
|
||||
++ ryld |= v=[syn=? hol=@ zer=@ fac=@ exp=(unit ,@)] ^- @rd !:
|
||||
++ ryld |= v=[syn=? hol=@ zer=@ fac=@ exp=(unit ,@)] ^- @rd
|
||||
?: &(=(hol.v 0) =(zer.v 0) =(fac.v 0))
|
||||
(bit:rd (szer:vl:fl 1.023 52 syn.v))
|
||||
?~ exp.v
|
||||
@ -1242,7 +1242,7 @@
|
||||
:: Floating point operations for general floating points.
|
||||
:: [s=sign, e=unbiased exponent, f=fraction a=ari]
|
||||
:: Value of floating point = (-1)^s * 2^h * (1.f) = (-1)^s * 2^h * a
|
||||
++ fl !:
|
||||
++ fl
|
||||
|%
|
||||
:: ari, or arithmetic form = 1 + mantissa
|
||||
:: passing around this is convenient because it preserves
|
||||
@ -1432,10 +1432,9 @@
|
||||
?: (zer b p n) [~ "0"]
|
||||
~
|
||||
--
|
||||
|
||||
|
||||
::::::::::::
|
||||
++ add |= [b=@u p=@u n=[s=? e=@s a=@u] m=[s=? e=@s a=@u]] ^- [s=? e=@s a=@u]
|
||||
++ add |= [b=@u p=@u n=[s=? e=@s a=@u] m=[s=? e=@s a=@u]]
|
||||
^- [s=? e=@s a=@u]
|
||||
=+ g=(gar:te:fl b n m)
|
||||
?: ?=(^ g)
|
||||
u.g
|
||||
@ -1457,7 +1456,8 @@
|
||||
=+ e2=(sum:si (sun:si dif2) e.n)
|
||||
(pro:te:fl b p [s=|(s.n s.m) e=e2 a=(lia p a3)])
|
||||
|
||||
++ sub |= [b=@u p=@u n=[s=? e=@s a=@u] m=[s=? e=@s a=@u]] ^- [s=? e=@s a=@u]
|
||||
++ sub |= [b=@u p=@u n=[s=? e=@s a=@u] m=[s=? e=@s a=@u]]
|
||||
^- [s=? e=@s a=@u]
|
||||
=+ g=(gar:te:fl b n m)
|
||||
?: ?=(^ g)
|
||||
u.g
|
||||
@ -1522,9 +1522,8 @@
|
||||
++ gth |= [n=[s=? e=@s a=@u] m=[s=? e=@s a=@u]] ^- ?
|
||||
(lte m n)
|
||||
--
|
||||
|
||||
:: Real interface for @rd
|
||||
++ rd !:
|
||||
::
|
||||
++ rd :: core for @rd
|
||||
~% %rd + ~
|
||||
|%
|
||||
:: Convert a sign/exp/ari cell into 64 bit atom
|
||||
@ -3561,18 +3560,22 @@
|
||||
(stag ~ zust)
|
||||
(stag %many (ifix [cab ;~(plug cab cab)] (more cab nusk)))
|
||||
==
|
||||
++ royl !:
|
||||
++ royl
|
||||
=+ ^= zer
|
||||
(cook lent (star (just '0')))
|
||||
=+ ^= vox
|
||||
=+ ^= voy
|
||||
%+ cook royl-cell
|
||||
;~ plug
|
||||
;~(pose (cold | hep) (easy &))
|
||||
;~(plug dim:ag ;~(pose ;~(pfix dot ;~(plug zer dim:ag)) (easy [0 0])))
|
||||
;~(pose ;~(pfix (just 'e') (cook some ;~(plug ;~(pose (cold | hep) (easy &)) dim:ag))) (easy ~))
|
||||
;~ pose
|
||||
;~ pfix
|
||||
(just 'e')
|
||||
(cook some ;~(plug ;~(pose (cold | hep) (easy &)) dim:ag))
|
||||
==
|
||||
(easy ~)
|
||||
==
|
||||
==
|
||||
=+ ^= voy
|
||||
::(cook |=([a=? b=[c=@ d=@ e=@] f=(unit ,@) g=?] [a c.b d.b e.b f]) vox)k
|
||||
(cook royl-cell vox)
|
||||
;~ pose
|
||||
(stag %rh (cook rylh ;~(pfix ;~(plug sig sig) voy)))
|
||||
(stag %rq (cook rylq ;~(pfix ;~(plug sig sig sig) voy)))
|
||||
@ -6663,10 +6666,10 @@
|
||||
::
|
||||
[%zpwt *]
|
||||
?: ?: ?=(@ p.gen)
|
||||
(lte stub p.gen)
|
||||
&((lte stub p.p.gen) (gte stub q.p.gen))
|
||||
(lte hoon p.gen)
|
||||
&((lte hoon p.p.gen) (gte hoon q.p.gen))
|
||||
q.gen
|
||||
~|([%stub-fail stub p.gen] !!)
|
||||
~|([%hoon-fail hoon p.gen] !!)
|
||||
::
|
||||
* gen
|
||||
==
|
||||
@ -6748,7 +6751,7 @@
|
||||
[%fork *] $(sut p.sut)
|
||||
[%hold *] ?: (~(has in gil) sut)
|
||||
~_ (dunk %type)
|
||||
~|(%burn-loop !!)
|
||||
~|(%burn-loop !!)
|
||||
$(sut repo, gil (~(put in gil) sut))
|
||||
%noun 0
|
||||
%void ~|(%burn-void !!)
|
||||
@ -9452,7 +9455,6 @@
|
||||
:::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
:::::: :::::: volume 3, Arvo models and skeleton ::::::
|
||||
:::::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
!:
|
||||
|%
|
||||
++ arch ,[p=@uvI q=(unit ,@uvI) r=(map ,@ta ,~)] :: fundamental node
|
||||
++ arvo (mold ,[p=term q=mill] mill) :: arvo card
|
||||
@ -9473,22 +9475,7 @@
|
||||
q=(set monk) :: authors
|
||||
== ::
|
||||
++ curd ,[p=@tas q=*] :: typeless card
|
||||
++ disk |*(a=$+(* *) (pair gene (hypo a))) :: global/local typed
|
||||
++ duct (list wire) :: causal history
|
||||
++ gene :: global schema
|
||||
$& [p=gene q=gene] :: autocons
|
||||
$% [%at p=@tas] :: atom
|
||||
[%gl p=glob] :: global objective
|
||||
[%fa p=@tas q=gene] :: named
|
||||
[%li p=gene] :: list
|
||||
[%no ~] :: untyped
|
||||
[%ma p=gene q=gene] :: map
|
||||
[%se p=gene] :: set
|
||||
[%sy p=@tas q=gene r=gene] :: symbolic declare
|
||||
[%un p=gene] :: unit
|
||||
[%va p=@tas] :: symbolic reference
|
||||
== ::
|
||||
++ glob ,[p=logo q=ship r=mark] :: global brand
|
||||
++ herd (hypo curd) :: typed card
|
||||
++ hide :: standard app state
|
||||
$: $: our=ship :: owner/operator
|
||||
@ -9519,7 +9506,6 @@
|
||||
++ z *(unit (unit cage)) :: current subtree
|
||||
-- ::
|
||||
++ logo ,@tas :: content type
|
||||
++ mark ,@uvH :: type by core hash
|
||||
++ mill (each vase milt) :: vase/metavase
|
||||
++ milt ,[p=* q=*] :: metavase
|
||||
++ monk (each ship khan) :: general identity
|
||||
@ -9547,7 +9533,7 @@
|
||||
== ::
|
||||
++ wire path :: event pretext
|
||||
::::: hacks
|
||||
++ slod !:
|
||||
++ slod
|
||||
|= sed=sled
|
||||
^- slut
|
||||
|= raw=*
|
||||
@ -9570,27 +9556,10 @@
|
||||
?~ bop ~
|
||||
?~ u.bop [~ ~]
|
||||
[~ ~ q.q.u.u.bop]
|
||||
::
|
||||
++ slub !:
|
||||
|= sul=slut
|
||||
^- sled
|
||||
|= [fur=(unit (set monk)) ron=term bed=beam]
|
||||
^- (unit (unit cage))
|
||||
=+ ^= pax ^- path
|
||||
:* ron
|
||||
(scot %p p.bed)
|
||||
q.bed
|
||||
(scot r.bed)
|
||||
(flop s.bed)
|
||||
==
|
||||
=+ bop=(sul pax)
|
||||
?~ bop ~
|
||||
?~ u.bop [~ ~]
|
||||
[~ ~ [%$ %noun u.u.bop]]
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
:: section 3bE, Arvo core ::
|
||||
::
|
||||
++ vent !: :: vane core
|
||||
++ vent :: vane core
|
||||
|= [lal=@tas vil=vile bud=vase ves=vase]
|
||||
|%
|
||||
++ ruck :: update vase
|
||||
@ -9976,7 +9945,7 @@
|
||||
++ peek :: external inspect
|
||||
|= [now=@da hap=path]
|
||||
^- (unit)
|
||||
?~ hap [~ stub]
|
||||
?~ hap [~ hoon]
|
||||
=+ rob=((slod ~(beck (is vil eny bud fan) now)) hap)
|
||||
?~ rob ~
|
||||
?~ u.rob ~
|
||||
@ -10004,9 +9973,9 @@
|
||||
=+ ^= nex
|
||||
=+ gat=.*(ken .*(ken [0 87]))
|
||||
(need ((hard (unit ,@)) .*([-.gat [[now ~] +>.gat]] -.gat)))
|
||||
~& [%vega-compiled stub nex]
|
||||
?> (lte nex stub)
|
||||
=+ gat=.*(ken .*(ken [0 ?:(=(nex stub) 86 11)]))
|
||||
~& [%vega-compiled hoon nex]
|
||||
?> (lte nex hoon)
|
||||
=+ gat=.*(ken .*(ken [0 ?:(=(nex hoon) 86 11)]))
|
||||
=+ sam=[eny ova fan]
|
||||
=+ raw=.*([-.gat [sam +>.gat]] -.gat)
|
||||
[[[~ %vega hap] ((list ovum) -.raw)] +.raw]
|
||||
|
2011
arvo/zuse.hoon
2011
arvo/zuse.hoon
File diff suppressed because it is too large
Load Diff
@ -20,12 +20,12 @@
|
||||
=+ all=.*(0 ken)
|
||||
=+ ^= vay ^- (list ,[p=@tas q=@tas])
|
||||
:~ [%$ %zuse]
|
||||
[%f %ford]
|
||||
[%a %ames]
|
||||
[%b %batz]
|
||||
[%c %clay]
|
||||
[%d %dill]
|
||||
[%e %eyre]
|
||||
[%f %ford]
|
||||
[%g %gall]
|
||||
==
|
||||
|- ^+ all
|
||||
|
36
main/doc/synth/down.hood
Normal file
36
main/doc/synth/down.hood
Normal file
@ -0,0 +1,36 @@
|
||||
/? 314
|
||||
!:
|
||||
:::::: /hoon/down/synth/doc
|
||||
::
|
||||
=>
|
||||
:::::: models
|
||||
|%
|
||||
++ down
|
||||
$& [p=down q=down]
|
||||
$% [%$ p=tape]
|
||||
[%code p=tape]
|
||||
[%inco p=tape]
|
||||
[%head p=@ud q=down]
|
||||
[%link p=tape q=tape r=(unit tape)]
|
||||
[%lord p=(list down)]
|
||||
[%lund p=(list down)]
|
||||
[%parg p=down]
|
||||
[%quot p=down]
|
||||
[%rong p=down]
|
||||
[%emph p=down]
|
||||
[%hrul ~]
|
||||
[%html p=tape]
|
||||
==
|
||||
--
|
||||
:::::: generator
|
||||
::
|
||||
~& [%hood-at %]
|
||||
%- (fest /synth/doc %)
|
||||
|= pic=epic
|
||||
=+ unt=|=(a=cord (biff (~(get by qix.pic) a) |=(b=cord (slaw %ud b))))
|
||||
=+ moo=(both (unt %foo) (unt %bar))
|
||||
?~ moo [%$ "Hoop, world: usage: url?foo=x&bar=y"]
|
||||
:* [%$ "Hoop, "]
|
||||
[%emph %$ "world"]
|
||||
[%$ ": {<-.u.moo>} plus {<+.u.moo>} is {<(add u.moo)>}."]
|
||||
==
|
@ -1,10 +1,7 @@
|
||||
!:
|
||||
:::::: /hook/down/synth/doc
|
||||
::
|
||||
~& [%down-hook %path %]
|
||||
%- (folk /down/synth/doc %)
|
||||
|= [bem=beam but=path]
|
||||
~& [%down-hook-beam s.bem]
|
||||
~& [%down-hook-butt but]
|
||||
:+ %ride [%reef ~]
|
||||
[%drag bem but]
|
||||
|
@ -23,14 +23,13 @@
|
||||
--
|
||||
:::::: generator
|
||||
::
|
||||
~& [%down-hoon %path %]
|
||||
~& [%choon-at %]
|
||||
%- (fest /synth/doc %)
|
||||
|= pic=epic
|
||||
~& [%down-hook-butt but.pic]
|
||||
=+ unt=|=(a=cord (biff (~(get by qix.pic) a) |=(b=cord (slaw %ud b))))
|
||||
=+ moo=(both (unt %foo) (unt %bar))
|
||||
?~ moo [%$ "Hello, world: usage: url?foo=x&bar=y"]
|
||||
:* [%$ "Hello, "]
|
||||
?~ moo [%$ "Hm, world: usage: url?foo=x&bar=y"]
|
||||
:* [%$ "Hm, "]
|
||||
[%emph %$ "world"]
|
||||
[%$ ": {<-.u.moo>} plus {<+.u.moo>} is {<(add u.moo)>}."]
|
||||
==
|
||||
|
298
main/lib/urb.js
298
main/lib/urb.js
@ -1,113 +1,185 @@
|
||||
window.urb = {
|
||||
ship: ship,
|
||||
port: port,
|
||||
auto: auto,
|
||||
oryx: oryx,
|
||||
user: user,
|
||||
appl: appl,
|
||||
seqn: 0,
|
||||
seqp: 1,
|
||||
seqs: 3,
|
||||
dely: 0,
|
||||
|
||||
req: function(method,url,data,json,cb) {
|
||||
var xhr = new XMLHttpRequest()
|
||||
xhr.open(method.toUpperCase(), url)
|
||||
if(json)
|
||||
xhr.setRequestHeader("content-type", "text/json")
|
||||
if(data)
|
||||
xhr.send(JSON.stringify({oryx: oryx, xyro: data}))
|
||||
else
|
||||
xhr.send({oryx: oryx})
|
||||
if(cb) {
|
||||
xhr.onload = function() {
|
||||
cb(null,{
|
||||
"status":this.status,
|
||||
"data":JSON.parse(this.responseText)
|
||||
})
|
||||
}
|
||||
xhr.onerror = function() {
|
||||
cb({
|
||||
"status":this.status,
|
||||
"data":this.responseText
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
subscribe: function(path,cb) {
|
||||
if(!cb)
|
||||
throw new Error("You must supply a callback to urb.subscribe.")
|
||||
|
||||
var method, perm, url, $this
|
||||
|
||||
method = "put"
|
||||
perm = "tis"
|
||||
url = [perm,this.user,this.appl,this.port]
|
||||
if(path) {
|
||||
url.push(this.seqs)
|
||||
url.push(path)
|
||||
}
|
||||
console.log(url)
|
||||
url = "/"+url.join("/")
|
||||
|
||||
|
||||
$this = this
|
||||
this.req(method,url,{},true,function(err,data) {
|
||||
cb.apply(this,arguments)
|
||||
if(!err) { $this.poll($this.seqs++,cb); }
|
||||
})
|
||||
},
|
||||
|
||||
send: function(data,cb) {
|
||||
if(!data) { data = {}; }
|
||||
if(!cb) { cb = function() {}; }
|
||||
|
||||
var method, perm, url, $this
|
||||
|
||||
method = "put"
|
||||
perm = "tim"
|
||||
url = [perm,this.user,this.appl,this.port,this.seqn]
|
||||
url = "/"+url.join("/")
|
||||
|
||||
this.seqn++
|
||||
|
||||
$this = this
|
||||
this.req(method,url,data,true,function(err,data) {
|
||||
if(err) { $this.seqn--; }
|
||||
cb.apply(this,arguments)
|
||||
})
|
||||
},
|
||||
|
||||
poll: function(stream,cb) {
|
||||
if(!stream)
|
||||
throw new Error("You must supply a stream to urb.poll.")
|
||||
if(!cb)
|
||||
throw new Error("You must supply a callback to urb.poll.")
|
||||
|
||||
var method, perm, url, $this
|
||||
|
||||
method = "get"
|
||||
perm = "gie"
|
||||
if(!stream) { return false; }
|
||||
url = [perm,this.user,this.appl,this.port,stream,this.seqp]
|
||||
url = "/"+url.join("/")
|
||||
console.log(url)
|
||||
|
||||
$this = this
|
||||
this.req(method,url,null,false,function(err,data) {
|
||||
if(cb.apply(this,arguments) === false) { return; }
|
||||
|
||||
if(err)
|
||||
$this.dely += 1000
|
||||
else {
|
||||
$this.dely = 0
|
||||
$this.seqp++
|
||||
}
|
||||
|
||||
setTimeout(function() {
|
||||
$this.poll(stream,cb)
|
||||
},$this.dely)
|
||||
})
|
||||
}
|
||||
}
|
||||
window.urb = {
|
||||
ship: ship,
|
||||
port: port,
|
||||
auto: auto,
|
||||
oryx: oryx,
|
||||
user: user,
|
||||
seqn_h: 0,
|
||||
seqn_u: 0,
|
||||
seqn_s: 0,
|
||||
dely: 0,
|
||||
puls: 0,
|
||||
perms: {
|
||||
pol:"gie",
|
||||
sub:"tis",
|
||||
uns:"tiu",
|
||||
mes:"tim",
|
||||
heb:"tih"
|
||||
},
|
||||
cabs: {},
|
||||
|
||||
req: function(method,url,params,json,cb) {
|
||||
var xhr = new XMLHttpRequest()
|
||||
xhr.open(method.toUpperCase(), url)
|
||||
if(json)
|
||||
xhr.setRequestHeader("content-type", "text/json")
|
||||
|
||||
_data = {}
|
||||
if(params.data) { _data.data = params.data; }
|
||||
if(params.ship) { _data.ship = params.ship; }
|
||||
if(params.path) { _data.path = params.path; }
|
||||
if(params.appl) { _data.appl = params.appl; }
|
||||
__data = {oryx: oryx, xyro: _data}
|
||||
xhr.send(JSON.stringify(__data))
|
||||
|
||||
if(cb) {
|
||||
xhr.onload = function() {
|
||||
cb(null,{
|
||||
"status":this.status,
|
||||
"data":JSON.parse(this.responseText)
|
||||
})
|
||||
}
|
||||
xhr.onerror = function() {
|
||||
cb({
|
||||
"status":this.status,
|
||||
"data":this.responseText
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
send: function(params,cb) {
|
||||
if(!params)
|
||||
throw new Error("You must supply params to urb.send.")
|
||||
if(!params.appl)
|
||||
throw new Error("You must specify an appl for urb.send.")
|
||||
if(!params.data) { params.data = {}; }
|
||||
|
||||
var method, perm, url, $this
|
||||
|
||||
type = params.type ? params.type : "mes"
|
||||
perm = this.perms[type]
|
||||
|
||||
params.ship = params.ship ? params.ship : this.ship
|
||||
|
||||
method = "put"
|
||||
url = [perm,this.user,this.port,this.seqn_s]
|
||||
url = "/"+url.join("/")
|
||||
|
||||
this.seqn_s++
|
||||
|
||||
$this = this
|
||||
this.req(method,url,params,true,function(err,data) {
|
||||
if(err) { $this.seqn_s--; }
|
||||
if(cb) { cb.apply(this,arguments); }
|
||||
})
|
||||
},
|
||||
|
||||
subscribe: function(appl,path,ship,cb) {
|
||||
if(!cb)
|
||||
throw new Error("You must supply a callback to urb.subscribe.")
|
||||
|
||||
var method, perm, url, $this
|
||||
|
||||
ship = ship ? ship : this.ship
|
||||
|
||||
method = "get"
|
||||
params = {
|
||||
type:"sub",
|
||||
appl:appl,
|
||||
path:path,
|
||||
ship:ship,
|
||||
incs:function() {
|
||||
window.urb.seqn_u++
|
||||
}
|
||||
}
|
||||
|
||||
this.cabs[appl+","+path.replace(/[^\x00-\x7F]/g, "")+","+ship] = cb
|
||||
|
||||
type = params.type ? params.type : "mes"
|
||||
perm = this.perms[type]
|
||||
method = "put"
|
||||
url = [perm,this.user,this.port]
|
||||
url = "/"+url.join("/")
|
||||
|
||||
$this = this
|
||||
this.req(method,url,params,true,function(err,data) {
|
||||
if(cb) { cb.call(this,err,{status: data.status, data: data.data.data})}
|
||||
if(!err && $this.puls == 0) {
|
||||
params.type = "pol"
|
||||
$this.poll(params)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
unsubscribe: function(appl,path,ship,cb) {
|
||||
method = "put"
|
||||
type = "uns"
|
||||
perm = this.perms[type]
|
||||
url = [perm,this.user,this.port]
|
||||
url = "/"+url.join("/")
|
||||
|
||||
params = {
|
||||
appl: appl,
|
||||
path: path,
|
||||
ship: ship
|
||||
}
|
||||
|
||||
var $this = this
|
||||
this.req(method,url,params,true,function(err,data) {
|
||||
console.log('ok unsubscribed')
|
||||
fn = appl+","+path.replace(/[^\x00-\x7F]/g, "")+","+ship
|
||||
$this.cabs[fn]('subscription closed')
|
||||
})
|
||||
},
|
||||
|
||||
heartbeat: function() {
|
||||
this.poll({
|
||||
type:"heb",
|
||||
ship:this.ship,
|
||||
incs:function() {
|
||||
window.urb.seqn_h++
|
||||
}
|
||||
},function() {
|
||||
console.log('heartbeat.')
|
||||
})
|
||||
},
|
||||
|
||||
poll: function(params,cb) {
|
||||
if(!params)
|
||||
throw new Error("You must supply params to urb.poll.")
|
||||
|
||||
var method, perm, url, $this
|
||||
|
||||
method = "get"
|
||||
type = params.type ? params.type : "pol"
|
||||
perm = this.perms[type]
|
||||
url = [perm,this.user,this.port,this.seqn_u]
|
||||
url = "/"+url.join("/")
|
||||
|
||||
this.puls = 1
|
||||
|
||||
$this = this
|
||||
this.req(method,url,params,false,function(err,data) {
|
||||
if(cb) {
|
||||
cb.call(this,err,{status: data.status, data: data.data.data})
|
||||
} else {
|
||||
fn = data.data.appl+","+data.data.path.replace(/[^\x00-\x7F]/g, "")
|
||||
+","+data.data.ship
|
||||
$this.cabs[fn].call(this,err,
|
||||
{status: data.status, data: data.data.data})
|
||||
}
|
||||
|
||||
if(err)
|
||||
$this.dely += 1000
|
||||
else {
|
||||
$this.dely = 0
|
||||
params.incs()
|
||||
}
|
||||
|
||||
setTimeout(function() {
|
||||
$this.poll(params,cb)
|
||||
},$this.dely)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user