@pritzlaff/nano-app 0.0.0-stage → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +66 -0
- package/LICENSE +21 -0
- package/README.md +6 -2
- package/app/app.css +160 -0
- package/app/bundle/nano-ui.js +2554 -0
- package/app/examples/auth/example.auth.js +6 -0
- package/app/examples/auth/nano.json +46 -0
- package/app/examples/chat/example.chat.js +6 -0
- package/app/examples/chat/example.messaging.js +3 -0
- package/app/examples/chat/nano.json +115 -0
- package/app/examples/drift/example.drift.js +3 -0
- package/app/examples/drift/nano.json +31 -0
- package/app/examples/kv/example.kv.js +3 -0
- package/app/examples/nano.json +356 -0
- package/app/examples/originkey/_nano/bundle/nano-ui.js +212 -0
- package/app/examples/originkey/_nano/sandbox/boot.js +1 -0
- package/app/examples/originkey/_nano/shared/chunks/nano-core-2gg2vg5g.js +2 -0
- package/app/examples/originkey/_nano/shared/chunks/nano-core-5h5dssvv.js +3 -0
- package/app/examples/originkey/_nano/shared/chunks/nano-core-72b5e6vd.js +17 -0
- package/app/examples/originkey/_nano/shared/chunks/nano-core-87v2yejk.js +2 -0
- package/app/examples/originkey/_nano/shared/chunks/nano-core-hm29e227.js +7 -0
- package/app/examples/originkey/_nano/shared/chunks/nano-core-jtgk4ch8.js +2 -0
- package/app/examples/originkey/_nano/shared/chunks/nano-core-mqaje7vc.js +2 -0
- package/app/examples/originkey/_nano/shared/chunks/nano-core-mxgap7rs.js +2 -0
- package/app/examples/originkey/_nano/shared/chunks/nano-core-qy0mwf7y.js +1 -0
- package/app/examples/originkey/_nano/shared/chunks/nano-core-wanb7xw1.js +1 -0
- package/app/examples/originkey/_nano/shared/lit-class-map.js +1 -0
- package/app/examples/originkey/_nano/shared/lit-decorators.js +1 -0
- package/app/examples/originkey/_nano/shared/lit-directive.js +1 -0
- package/app/examples/originkey/_nano/shared/lit-if-defined.js +1 -0
- package/app/examples/originkey/_nano/shared/lit-ref.js +1 -0
- package/app/examples/originkey/_nano/shared/lit-repeat.js +1 -0
- package/app/examples/originkey/_nano/shared/lit-style-map.js +1 -0
- package/app/examples/originkey/_nano/shared/lit.js +1 -0
- package/app/examples/originkey/_nano/shared/nano-core.js +1 -0
- package/app/examples/originkey/_nano/shared/nano-elements.js +280 -0
- package/app/examples/originkey/_nano/shared/typebox-value.js +1 -0
- package/app/examples/originkey/_nano/shared/typebox.js +1 -0
- package/app/examples/originkey/example.originkey.js +6 -0
- package/app/examples/originkey/frame.html +1 -0
- package/app/examples/originkey/nano.json +50 -0
- package/app/examples/raft/example.raft.js +30 -0
- package/app/examples/raft/nano.json +74 -0
- package/app/examples/slice/nano.json +63 -0
- package/app/examples/slice/shout.js +14 -0
- package/app/examples/template/acme.template.js +20 -0
- package/app/examples/template/index.js +241 -0
- package/app/examples/template/nano.json +35 -0
- package/app/examples/todo/example.todo.js +8 -0
- package/app/examples/todo/nano.json +77 -0
- package/app/examples/typing/nano.json +33 -0
- package/app/favicon.svg +1 -0
- package/app/index.html +152 -0
- package/app/main.js +15908 -0
- package/app/react/index.html +50 -0
- package/app/react/main.js +9 -0
- package/app/sandbox/boot.js +980 -0
- package/app/shared/chunks/nano-core-296y9rgd.js +4321 -0
- package/app/shared/chunks/nano-core-2zz7d74m.js +16 -0
- package/app/shared/chunks/nano-core-35ryhkm1.js +33 -0
- package/app/shared/chunks/nano-core-5a3r312d.js +866 -0
- package/app/shared/chunks/nano-core-89mtxedm.js +186 -0
- package/app/shared/chunks/nano-core-bf13r20v.js +77 -0
- package/app/shared/chunks/nano-core-g3414rnc.js +248 -0
- package/app/shared/chunks/nano-core-hyg0qdwg.js +547 -0
- package/app/shared/chunks/nano-core-sxgrxy03.js +53 -0
- package/app/shared/chunks/nano-core-wg5c961d.js +4564 -0
- package/app/shared/lit-class-map.js +60 -0
- package/app/shared/lit-decorators.js +228 -0
- package/app/shared/lit-directive.js +11 -0
- package/app/shared/lit-if-defined.js +10 -0
- package/app/shared/lit-ref.js +12 -0
- package/app/shared/lit-repeat.js +141 -0
- package/app/shared/lit-style-map.js +67 -0
- package/app/shared/lit.js +47 -0
- package/app/shared/nano-core.js +2516 -0
- package/app/shared/nano-elements.js +1178 -0
- package/app/shared/typebox-value.js +78 -0
- package/app/shared/typebox.js +580 -0
- package/app/shared/versions.json +6 -0
- package/bin/nano-app.ts +34 -0
- package/package.json +22 -4
- package/src/events.ts +11 -0
- package/src/serve.ts +68 -0
- package/src/watch.ts +27 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{LitElement as W,html as j}from"lit";import{base as Y,kit as Z}from"@pritzlaff/nano-elements";import{Type as x}from"typebox";import{Coord as V,Op as E,Schema as B}from"@pritzlaff/nano-core";var P;((I)=>(I.ns=V.namespace("example.auth"),I.Result=B.define(x.Object({ok:x.Boolean(),purpose:x.String(),at:x.String(),credentialId:x.Optional(x.String()),reason:x.Optional(x.String())},{additionalProperties:!1})),I.api=I.ns.interface("Auth",{authenticate:E.action(x.String(),I.Result),authenticated:E.event(I.Result)})))(P||={});function G(t,a){let i=document.createElement("dialog"),f=document.createElement("p");f.textContent=`${a} wants to ${t} — Authenticate with passkey?`;let y=(h,S)=>{let T=document.createElement("button");return T.textContent=h,T.onclick=()=>{i.close(),m(S)},T},m,O=new Promise((h)=>{m=h});return i.append(f,y("Approve",!0),y("Cancel",!1)),i.oncancel=()=>m(!1),document.body.append(i),i.showModal(),O.finally(()=>i.remove())}function H(t){try{return t.location?.origin==="null"||t.top!==t.self||!t.navigator?.credentials}catch{return!0}}var R={get sandboxed(){return H(globalThis)},get credentials(){return globalThis.navigator?.credentials},confirm:G};var J=(t)=>btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),c=()=>crypto.getRandomValues(new Uint8Array(32)),K="passkeys are not available in a sandbox";async function k(t,a,i=R.sandboxed){let f=()=>new Date().toISOString();if(i||!R.credentials)return{ok:!1,purpose:t,at:f(),reason:K};try{let y=await a(R.credentials);return y?{ok:!0,purpose:t,at:f(),credentialId:J(y.rawId)}:{ok:!1,purpose:t,at:f(),reason:"no credential"}}catch(y){return{ok:!1,purpose:t,at:f(),reason:y?.name??"Error"}}}var F=(t="nano examples",a=()=>R.sandboxed)=>k("register",(i)=>i.create({publicKey:{challenge:c(),rp:{name:t},user:{id:c(),name:"nano",displayName:"nano"},pubKeyCredParams:[{type:"public-key",alg:-7},{type:"public-key",alg:-257}],authenticatorSelection:{residentKey:"required",userVerification:"preferred"}}}),a()),M=(t,a,i=()=>R.sandboxed)=>P.api.impl(t).description(a).make(()=>{let f=new Set,y=!1;return{async authenticate(m){if(y)return{ok:!1,purpose:m,at:new Date().toISOString(),reason:"busy"};if(i())return k(m,async()=>null,!0);y=!0;try{let O;try{O=await R.confirm(m,"A pod")}catch(S){return{ok:!1,purpose:m,at:new Date().toISOString(),reason:S?.name??"Error"}}if(!O)return{ok:!1,purpose:m,at:new Date().toISOString(),reason:"cancelled"};let h=await k(m,(S)=>S.get({publicKey:{challenge:c(),userVerification:"preferred"}}),i());if(h.ok)for(let S of f)S(h);return h}finally{y=!1}},async*authenticated(){let m=[],O,h=(S)=>{m.push(S),O?.()};f.add(h);try{for(;;){while(m.length)yield m.shift();await new Promise((S)=>{O=S})}}finally{f.delete(h)}}}}),Q=M(P.ns.implementationId("passkey"),"Asks the user, in a modal, for a passkey; refuses in a sandbox."),U=P.ns.provider([Q]);class C extends W{static properties={target:{attribute:!1},last:{state:!0},error:{state:!0}};static styles=[Y,Z];watching;iter;connectedCallback(){super.connectedCallback(),this.watch()}disconnectedCallback(){super.disconnectedCallback(),this.stop()}willUpdate(t){if(t.has("target"))this.watch()}stop(){this.iter?.return?.(),this.iter=this.watching=void 0}pod(t){return t.app.runtime(t.runtime).get(P.api,{pod:t.pod})}async watch(){let t=this.target;if(!t||!this.isConnected||this.watching===t)return;this.stop(),this.watching=t,this.error=this.last=void 0;let a=this.iter=this.pod(t).authenticated()[Symbol.asyncIterator]();try{for(let i=await a.next();!i.done&&this.iter===a;i=await a.next())this.last=i.value}catch(i){if(this.iter===a)this.error=String(i)}}register(){return F()}run(t){t.then((a)=>{this.last=a},(a)=>{this.error=String(a)})}render(){let t=this.target;if(!t)return j``;let a=this.last;return j`<div class="col">${this.error?j`<p class="alert bad" role="alert">${this.error}</p>`:""}
|
|
2
|
+
<div class="row"><button class="btn" @click=${()=>this.run(this.pod(t).authenticate("sign in"))}>Passkey</button>
|
|
3
|
+
<button class="btn" @click=${()=>this.run(this.register())}>Register</button></div>
|
|
4
|
+
<p class="muted" role="status">${!a?"Not yet authenticated.":a.ok?`${a.purpose}: ok (${a.credentialId}) at ${a.at}`:`${a.purpose}: ${a.reason} at ${a.at}`}</p></div>`}}var l={"example.auth/passkey":"auth-passkey"};if(!customElements.get("auth-passkey"))customElements.define("auth-passkey",C);export{l as views,U as default};
|
|
5
|
+
|
|
6
|
+
export const built = {"@pritzlaff/nano-core":"0.5.1"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pods": {
|
|
3
|
+
"auth": {
|
|
4
|
+
"implementation": "example.auth/passkey",
|
|
5
|
+
"eager": false
|
|
6
|
+
},
|
|
7
|
+
"log": {
|
|
8
|
+
"implementation": "nano.ui/log",
|
|
9
|
+
"eager": false
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"runtimes": {
|
|
13
|
+
"example.auth.main": {
|
|
14
|
+
"pods": [
|
|
15
|
+
"auth",
|
|
16
|
+
"log"
|
|
17
|
+
],
|
|
18
|
+
"subscriptions": [
|
|
19
|
+
{
|
|
20
|
+
"kind": "pipe",
|
|
21
|
+
"from": "auth",
|
|
22
|
+
"source": "example.auth.Auth/authenticated",
|
|
23
|
+
"to": "log",
|
|
24
|
+
"target": "nano.ui.Log/log"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"modules": {
|
|
30
|
+
"example.auth": "./example.auth.js"
|
|
31
|
+
},
|
|
32
|
+
"layout": {
|
|
33
|
+
"slots": [
|
|
34
|
+
{
|
|
35
|
+
"id": "auth",
|
|
36
|
+
"runtime": "example.auth.main",
|
|
37
|
+
"pod": "auth"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"id": "log",
|
|
41
|
+
"runtime": "example.auth.main",
|
|
42
|
+
"pod": "log"
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{LitElement as f,css as I,html as t}from"lit";import{base as k,kit as A}from"@pritzlaff/nano-elements";import{Type as l}from"typebox";import{Coord as x,Op as g}from"@pritzlaff/nano-core";import{Type as r}from"typebox";import{Coord as u,Op as p,Schema as w}from"@pritzlaff/nano-core";var n;((o)=>(o.ns=u.namespace("example.messaging"),o.Message=w.define(r.Object({id:r.String(),room:r.String(),from:r.String(),text:r.String()})),o.api=o.ns.interface("Messaging",{post:p.action(r.Object({room:r.String(),from:r.String(),text:r.String()}),o.Message),history:p.action(r.Object({room:r.String()}),r.Array(o.Message)),messages:p.event(o.Message)})))(n||={});var m;((d)=>(d.ns=x.namespace("example.chat"),d.api=d.ns.interface("Chat",{say:g.action(l.String(),n.Message),transcript:g.action(l.Null(),l.Array(n.Message)),lines:g.event(n.Message)})))(m||={});class h extends f{static properties={target:{attribute:!1},lines:{state:!0},error:{state:!0}};static styles=[k,A,I`ul { list-style: none; margin: 0; padding: 0 } li > span { flex: 1 } [role='alert'] { margin: 0 }`];watching;iter;constructor(){super();this.lines=[]}connectedCallback(){super.connectedCallback(),this.watch()}disconnectedCallback(){super.disconnectedCallback(),this.stop()}willUpdate(i){if(i.has("target"))this.watch()}stop(){this.iter?.return?.(),this.iter=this.watching=void 0}pod(i){return i.app.runtime(i.runtime).get(m.api,{pod:i.pod})}async watch(){let i=this.target;if(!i||!this.isConnected||this.watching===i)return;this.stop(),this.watching=i,this.error=void 0;let a=this.pod(i),s=this.iter=a.lines()[Symbol.asyncIterator]();try{let e=await a.transcript();if(this.iter!==s)return;this.lines=e;for(let c=await s.next();!c.done&&this.iter===s;c=await s.next())this.lines=[...this.lines,c.value]}catch(e){if(this.iter===s)this.error=String(e)}}async send(i,a){let s=a.value.trim();if(!s)return;a.value="",await this.pod(i).say(s).catch((e)=>{this.error=String(e)})}render(){let i=this.target;if(!i)return t``;return t`<div class="col">${this.error?t`<p class="alert bad" role="alert">${this.error}</p>`:""}<h3 class="display-s">${i.pod}</h3>
|
|
2
|
+
<ul>${this.lines.map((a)=>t`<li class="list-row"><b>${a.from}</b> <span>${a.text}</span></li>`)}</ul>
|
|
3
|
+
<div class="row">
|
|
4
|
+
<input class="input" aria-label="Message" placeholder="Say something" @keydown=${(a)=>{if(a.key==="Enter"&&!a.isComposing)this.send(i,a.target)}}><button class="btn" type="button" @click=${()=>void this.send(i,this.renderRoot.querySelector("input"))}>Send</button></div></div>`}}import{Implementation as R}from"@pritzlaff/nano-core";var v="general",P=R.define(m.ns.implementationId("participant"),{provides:[m.api],description:"One participant in the general room, named by its pod.",dependencies:{messaging:n.api},calls:{say:{messaging:[n.api.ops.post]},transcript:{messaging:[n.api.ops.history]}},make:(i)=>({async say(a,s){return s.deps.messaging.post({room:v,from:i.self,text:a})},async transcript(a,s){return s.deps.messaging.history({room:v})},async*lines(){for await(let a of i.deps.messaging.messages())if(a.room===v)yield a}})});var V=m.ns.provider([P]);var L={"example.chat/participant":"chat-room"};if(!customElements.get("chat-room"))customElements.define("chat-room",h);export{L as views,V as default};
|
|
5
|
+
|
|
6
|
+
export const built = {"@pritzlaff/nano-core":"0.5.1"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{Implementation as k}from"@pritzlaff/nano-core";import{Type as J}from"typebox";import{Coord as $,Op as Q,Schema as U}from"@pritzlaff/nano-core";var L;((j)=>(j.ns=$.namespace("example.kv"),j.Path=U.define(J.Array(J.String())),j.Value=U.define(J.Unsafe(J.Unknown())),j.Entry=U.define(J.Object({key:j.Path,value:j.Value})),j.api=j.ns.interface("KeyValueStore",{get:Q.action(j.Path,j.Value),put:Q.action(j.Entry,J.Null()),delete:Q.action(j.Path,J.Null()),list:Q.action(J.Object({prefix:j.Path}),J.Array(j.Entry))})))(L||={});import{Type as F}from"typebox";import{Coord as C,Op as W,Schema as b}from"@pritzlaff/nano-core";var N;((H)=>(H.ns=C.namespace("example.messaging"),H.Message=b.define(F.Object({id:F.String(),room:F.String(),from:F.String(),text:F.String()})),H.api=H.ns.interface("Messaging",{post:W.action(F.Object({room:F.String(),from:F.String(),text:F.String()}),H.Message),history:W.action(F.Object({room:F.String()}),F.Array(H.Message)),messages:W.event(H.Message)})))(N||={});var Z=()=>{let G=0;return()=>String(++G).padStart(8,"0")};function Y(G,A=Z()){return{async post({room:q,from:B,text:X}){let R={id:A(),room:q,from:B,text:X};return await G.put({key:["rooms",q,R.id],value:R}),R},async history({room:q}){return(await G.list({prefix:["rooms",q]})).map((B)=>B.value)}}}var _=k.define(N.ns.implementationId("kv"),{provides:[N.api],description:"Rooms of messages kept in whichever KeyValueStore its call edge reaches.",dependencies:{store:L.api},calls:{post:{store:[L.api.ops.put]},history:{store:[L.api.ops.list]}},make:(G)=>{let A=Z();return{post:(q,B)=>Y(B.deps.store,A).post(q),history:(q,B)=>Y(B.deps.store,A).history(q),async*messages(){let q=G.one(L.api);if(q.ok){for await(let{input:B}of q.value.on(L.api.ops.put))if(B.key[0]==="rooms")yield B.value}}}}}),D={kv:_},S=N.ns.provider([_]);export{Y as messaging,D as impls,S as default};
|
|
2
|
+
|
|
3
|
+
export const built = {"@pritzlaff/nano-core":"0.5.1"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pods": {
|
|
3
|
+
"chatStore": {
|
|
4
|
+
"implementation": "example.kv/memory",
|
|
5
|
+
"eager": false
|
|
6
|
+
},
|
|
7
|
+
"messaging": {
|
|
8
|
+
"implementation": "example.messaging/kv",
|
|
9
|
+
"eager": false
|
|
10
|
+
},
|
|
11
|
+
"alice": {
|
|
12
|
+
"implementation": "example.chat/participant",
|
|
13
|
+
"eager": false
|
|
14
|
+
},
|
|
15
|
+
"bob": {
|
|
16
|
+
"implementation": "example.chat/participant",
|
|
17
|
+
"eager": false
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"runtimes": {
|
|
21
|
+
"example.chat.backend": {
|
|
22
|
+
"pods": [
|
|
23
|
+
"chatStore",
|
|
24
|
+
"messaging"
|
|
25
|
+
],
|
|
26
|
+
"subscriptions": [
|
|
27
|
+
{
|
|
28
|
+
"kind": "call",
|
|
29
|
+
"from": "messaging",
|
|
30
|
+
"to": "chatStore"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"kind": "call",
|
|
34
|
+
"from": "alice",
|
|
35
|
+
"to": "messaging"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"kind": "call",
|
|
39
|
+
"from": "bob",
|
|
40
|
+
"to": "messaging"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"policy": {
|
|
44
|
+
"kind": "rules",
|
|
45
|
+
"rules": [
|
|
46
|
+
{
|
|
47
|
+
"allow": [
|
|
48
|
+
"call",
|
|
49
|
+
"subscribe"
|
|
50
|
+
],
|
|
51
|
+
"from": "bob",
|
|
52
|
+
"outside": true,
|
|
53
|
+
"toInterface": "example.messaging.Messaging"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"allow": [
|
|
57
|
+
"call",
|
|
58
|
+
"subscribe"
|
|
59
|
+
],
|
|
60
|
+
"from": "alice",
|
|
61
|
+
"outside": true,
|
|
62
|
+
"toInterface": "example.messaging.Messaging"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"allow": [
|
|
66
|
+
"call",
|
|
67
|
+
"subscribe"
|
|
68
|
+
],
|
|
69
|
+
"from": "messaging",
|
|
70
|
+
"outside": false,
|
|
71
|
+
"toInterface": "example.kv.KeyValueStore"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"allow": "*",
|
|
75
|
+
"outside": false
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"allow": "start",
|
|
79
|
+
"from": "host",
|
|
80
|
+
"outside": true
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"deny": "*"
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
"example.chat.room": {
|
|
89
|
+
"pods": [
|
|
90
|
+
"alice",
|
|
91
|
+
"bob"
|
|
92
|
+
],
|
|
93
|
+
"subscriptions": []
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"modules": {
|
|
97
|
+
"example.messaging": "./example.messaging.js",
|
|
98
|
+
"example.chat": "./example.chat.js",
|
|
99
|
+
"example.kv": "../kv/example.kv.js"
|
|
100
|
+
},
|
|
101
|
+
"layout": {
|
|
102
|
+
"slots": [
|
|
103
|
+
{
|
|
104
|
+
"id": "alice",
|
|
105
|
+
"runtime": "example.chat.room",
|
|
106
|
+
"pod": "alice"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"id": "bob",
|
|
110
|
+
"runtime": "example.chat.room",
|
|
111
|
+
"pod": "bob"
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{Type as c}from"typebox";import{Coord as f,Implementation as u,Op as b}from"@pritzlaff/nano-core";import{Type as t}from"typebox";import{Coord as p,Op as a,Schema as d}from"@pritzlaff/nano-core";var r;((e)=>(e.ns=p.namespace("example.kv"),e.Path=d.define(t.Array(t.String())),e.Value=d.define(t.Unsafe(t.Unknown())),e.Entry=d.define(t.Object({key:e.Path,value:e.Value})),e.api=e.ns.interface("KeyValueStore",{get:a.action(e.Path,e.Value),put:a.action(e.Entry,t.Null()),delete:a.action(e.Path,t.Null()),list:a.action(t.Object({prefix:e.Path}),t.Array(e.Entry))})))(r||={});var m;((o)=>(o.ns=f.namespace("example.drift"),o.api=o.ns.interface("Form",{submit:b.action(c.String(),c.Null())})))(m||={});var w=u.define(m.ns.implementationId("form"),{provides:[m.api],description:"Saves what is submitted; declares only the save, but also clears the draft.",dependencies:{store:r.api},calls:{submit:{store:[r.api.ops.put]}},make:()=>({async submit(i,s){await s.deps.store.put({key:["submitted",crypto.randomUUID()],value:i}),await s.deps.store.delete(["draft"])}})}),h=m.ns.provider([w]);export{h as default,m as FormDef};
|
|
2
|
+
|
|
3
|
+
export const built = {"@pritzlaff/nano-core":"0.5.1"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pods": {
|
|
3
|
+
"driftStore": {
|
|
4
|
+
"implementation": "example.kv/memory",
|
|
5
|
+
"eager": false
|
|
6
|
+
},
|
|
7
|
+
"form": {
|
|
8
|
+
"implementation": "example.drift/form",
|
|
9
|
+
"eager": false
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"runtimes": {
|
|
13
|
+
"example.drift.main": {
|
|
14
|
+
"pods": [
|
|
15
|
+
"driftStore",
|
|
16
|
+
"form"
|
|
17
|
+
],
|
|
18
|
+
"subscriptions": [
|
|
19
|
+
{
|
|
20
|
+
"kind": "call",
|
|
21
|
+
"from": "form",
|
|
22
|
+
"to": "driftStore"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"modules": {
|
|
28
|
+
"example.drift": "./example.drift.js",
|
|
29
|
+
"example.kv": "../kv/example.kv.js"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{Type as H}from"typebox";import{Type as G}from"typebox";import{Coord as Z,Op as J,Schema as N}from"@pritzlaff/nano-core";var L;((q)=>(q.ns=Z.namespace("example.kv"),q.Path=N.define(G.Array(G.String())),q.Value=N.define(G.Unsafe(G.Unknown())),q.Entry=N.define(G.Object({key:q.Path,value:q.Value})),q.api=q.ns.interface("KeyValueStore",{get:J.action(q.Path,q.Value),put:J.action(q.Entry,G.Null()),delete:J.action(q.Path,G.Null()),list:J.action(G.Object({prefix:q.Path}),G.Array(q.Entry))})))(L||={});var _=(F,A)=>{for(let j=0;j<Math.min(F.length,A.length);j++)if(F[j]!==A[j])return F[j]<A[j]?-1:1;return F.length-A.length};function R(F=[]){let A=new Map(F.map((j)=>[JSON.stringify(j.key),structuredClone(j)]));return{async get(j){let B=A.get(JSON.stringify(j));return B?structuredClone(B.value):null},async put({key:j,value:B}){A.set(JSON.stringify(j),structuredClone({key:j,value:B}))},async delete(j){A.delete(JSON.stringify(j))},async list({prefix:j}){return[...A.values()].filter((B)=>j.every((I,Y)=>B.key[Y]===I)).sort((B,I)=>_(B.key,I.key)).map((B)=>structuredClone(B))}}}var{api:U,ns:Q}=L,W={memory:Q.implementationId("memory"),backup:Q.implementationId("backup")},X=H.Union([H.Object({entries:H.Optional(H.Array(L.Entry))}),H.Undefined()]),$=U.impl(W.memory).config(X).description("Keeps entries in memory; a restart empties it back to its config.").make(({config:F})=>R(F?.entries)),w=U.impl(W.backup).config(X).description("A second in-memory store, to swap to.").make(({config:F})=>R(F?.entries)),K=Q.provider([$,w]);export{_ as order,R as inMemory,W as impls,K as default};
|
|
2
|
+
|
|
3
|
+
export const built = {"@pritzlaff/nano-core":"0.5.1"}
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pods": {
|
|
3
|
+
"todoStore": {
|
|
4
|
+
"implementation": "example.kv/memory",
|
|
5
|
+
"eager": false
|
|
6
|
+
},
|
|
7
|
+
"todos": {
|
|
8
|
+
"implementation": "example.todo/kv",
|
|
9
|
+
"eager": false
|
|
10
|
+
},
|
|
11
|
+
"chatStore": {
|
|
12
|
+
"implementation": "example.kv/memory",
|
|
13
|
+
"eager": false
|
|
14
|
+
},
|
|
15
|
+
"messaging": {
|
|
16
|
+
"implementation": "example.messaging/kv",
|
|
17
|
+
"eager": false
|
|
18
|
+
},
|
|
19
|
+
"alice": {
|
|
20
|
+
"implementation": "example.chat/participant",
|
|
21
|
+
"eager": false
|
|
22
|
+
},
|
|
23
|
+
"bob": {
|
|
24
|
+
"implementation": "example.chat/participant",
|
|
25
|
+
"eager": false
|
|
26
|
+
},
|
|
27
|
+
"auth": {
|
|
28
|
+
"implementation": "example.auth/passkey",
|
|
29
|
+
"eager": false
|
|
30
|
+
},
|
|
31
|
+
"log": {
|
|
32
|
+
"implementation": "nano.ui/log",
|
|
33
|
+
"eager": false
|
|
34
|
+
},
|
|
35
|
+
"originKey": {
|
|
36
|
+
"implementation": "example.originkey/passkey",
|
|
37
|
+
"eager": true,
|
|
38
|
+
"isolation": "home-origin"
|
|
39
|
+
},
|
|
40
|
+
"keyLog": {
|
|
41
|
+
"implementation": "nano.ui/log",
|
|
42
|
+
"eager": false
|
|
43
|
+
},
|
|
44
|
+
"driftStore": {
|
|
45
|
+
"implementation": "example.kv/memory",
|
|
46
|
+
"eager": false
|
|
47
|
+
},
|
|
48
|
+
"form": {
|
|
49
|
+
"implementation": "example.drift/form",
|
|
50
|
+
"eager": false
|
|
51
|
+
},
|
|
52
|
+
"cluster": {
|
|
53
|
+
"implementation": "example.raft/cluster",
|
|
54
|
+
"config": {
|
|
55
|
+
"timing": {
|
|
56
|
+
"electionMin": 3000,
|
|
57
|
+
"electionMax": 6000,
|
|
58
|
+
"heartbeat": 1000
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"eager": false
|
|
62
|
+
},
|
|
63
|
+
"raft-messaging": {
|
|
64
|
+
"implementation": "example.raft/messaging",
|
|
65
|
+
"config": {
|
|
66
|
+
"minMs": 200,
|
|
67
|
+
"maxMs": 600
|
|
68
|
+
},
|
|
69
|
+
"eager": true
|
|
70
|
+
},
|
|
71
|
+
"raft-clock": {
|
|
72
|
+
"implementation": "nano.ui/sim-clock",
|
|
73
|
+
"eager": true
|
|
74
|
+
},
|
|
75
|
+
"raft-random": {
|
|
76
|
+
"implementation": "nano.ui/seeded-random",
|
|
77
|
+
"config": {
|
|
78
|
+
"seed": 1
|
|
79
|
+
},
|
|
80
|
+
"eager": true
|
|
81
|
+
},
|
|
82
|
+
"calculator": {
|
|
83
|
+
"implementation": "acme.template/calculator",
|
|
84
|
+
"config": {
|
|
85
|
+
"precision": 6
|
|
86
|
+
},
|
|
87
|
+
"eager": false
|
|
88
|
+
},
|
|
89
|
+
"history": {
|
|
90
|
+
"implementation": "acme.template/history",
|
|
91
|
+
"eager": false
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"runtimes": {
|
|
95
|
+
"example.todo.frontend": {
|
|
96
|
+
"pods": [
|
|
97
|
+
"todos"
|
|
98
|
+
],
|
|
99
|
+
"subscriptions": []
|
|
100
|
+
},
|
|
101
|
+
"example.todo.backend": {
|
|
102
|
+
"pods": [
|
|
103
|
+
"todoStore"
|
|
104
|
+
],
|
|
105
|
+
"subscriptions": [
|
|
106
|
+
{
|
|
107
|
+
"kind": "call",
|
|
108
|
+
"from": "todos",
|
|
109
|
+
"to": "todoStore"
|
|
110
|
+
}
|
|
111
|
+
],
|
|
112
|
+
"policy": {
|
|
113
|
+
"kind": "rules",
|
|
114
|
+
"rules": [
|
|
115
|
+
{
|
|
116
|
+
"allow": [
|
|
117
|
+
"call",
|
|
118
|
+
"subscribe"
|
|
119
|
+
],
|
|
120
|
+
"from": "todos",
|
|
121
|
+
"outside": true,
|
|
122
|
+
"toInterface": "example.kv.KeyValueStore"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"allow": "subscribe",
|
|
126
|
+
"from": "host",
|
|
127
|
+
"outside": true,
|
|
128
|
+
"toInterface": "example.kv.KeyValueStore"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"allow": "*",
|
|
132
|
+
"outside": false
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"allow": "start",
|
|
136
|
+
"from": "host",
|
|
137
|
+
"outside": true
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"deny": "*"
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
"example.chat.backend": {
|
|
146
|
+
"pods": [
|
|
147
|
+
"chatStore",
|
|
148
|
+
"messaging"
|
|
149
|
+
],
|
|
150
|
+
"subscriptions": [
|
|
151
|
+
{
|
|
152
|
+
"kind": "call",
|
|
153
|
+
"from": "messaging",
|
|
154
|
+
"to": "chatStore"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"kind": "call",
|
|
158
|
+
"from": "alice",
|
|
159
|
+
"to": "messaging"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"kind": "call",
|
|
163
|
+
"from": "bob",
|
|
164
|
+
"to": "messaging"
|
|
165
|
+
}
|
|
166
|
+
],
|
|
167
|
+
"policy": {
|
|
168
|
+
"kind": "rules",
|
|
169
|
+
"rules": [
|
|
170
|
+
{
|
|
171
|
+
"allow": [
|
|
172
|
+
"call",
|
|
173
|
+
"subscribe"
|
|
174
|
+
],
|
|
175
|
+
"from": "bob",
|
|
176
|
+
"outside": true,
|
|
177
|
+
"toInterface": "example.messaging.Messaging"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"allow": [
|
|
181
|
+
"call",
|
|
182
|
+
"subscribe"
|
|
183
|
+
],
|
|
184
|
+
"from": "alice",
|
|
185
|
+
"outside": true,
|
|
186
|
+
"toInterface": "example.messaging.Messaging"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"allow": [
|
|
190
|
+
"call",
|
|
191
|
+
"subscribe"
|
|
192
|
+
],
|
|
193
|
+
"from": "messaging",
|
|
194
|
+
"outside": false,
|
|
195
|
+
"toInterface": "example.kv.KeyValueStore"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"allow": "*",
|
|
199
|
+
"outside": false
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
"allow": "start",
|
|
203
|
+
"from": "host",
|
|
204
|
+
"outside": true
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"deny": "*"
|
|
208
|
+
}
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
"example.chat.room": {
|
|
213
|
+
"pods": [
|
|
214
|
+
"alice",
|
|
215
|
+
"bob"
|
|
216
|
+
],
|
|
217
|
+
"subscriptions": []
|
|
218
|
+
},
|
|
219
|
+
"example.auth.main": {
|
|
220
|
+
"pods": [
|
|
221
|
+
"auth",
|
|
222
|
+
"log"
|
|
223
|
+
],
|
|
224
|
+
"subscriptions": [
|
|
225
|
+
{
|
|
226
|
+
"kind": "pipe",
|
|
227
|
+
"from": "auth",
|
|
228
|
+
"source": "example.auth.Auth/authenticated",
|
|
229
|
+
"to": "log",
|
|
230
|
+
"target": "nano.ui.Log/log"
|
|
231
|
+
}
|
|
232
|
+
]
|
|
233
|
+
},
|
|
234
|
+
"example.originkey.main": {
|
|
235
|
+
"pods": [
|
|
236
|
+
"originKey",
|
|
237
|
+
"keyLog"
|
|
238
|
+
],
|
|
239
|
+
"subscriptions": [
|
|
240
|
+
{
|
|
241
|
+
"kind": "pipe",
|
|
242
|
+
"from": "originKey",
|
|
243
|
+
"source": "example.auth.Auth/authenticated",
|
|
244
|
+
"to": "keyLog",
|
|
245
|
+
"target": "nano.ui.Log/log"
|
|
246
|
+
}
|
|
247
|
+
]
|
|
248
|
+
},
|
|
249
|
+
"example.drift.main": {
|
|
250
|
+
"pods": [
|
|
251
|
+
"driftStore",
|
|
252
|
+
"form"
|
|
253
|
+
],
|
|
254
|
+
"subscriptions": [
|
|
255
|
+
{
|
|
256
|
+
"kind": "call",
|
|
257
|
+
"from": "form",
|
|
258
|
+
"to": "driftStore"
|
|
259
|
+
}
|
|
260
|
+
]
|
|
261
|
+
},
|
|
262
|
+
"raft": {
|
|
263
|
+
"pods": [
|
|
264
|
+
"cluster",
|
|
265
|
+
"raft-messaging",
|
|
266
|
+
"raft-clock",
|
|
267
|
+
"raft-random"
|
|
268
|
+
],
|
|
269
|
+
"subscriptions": [
|
|
270
|
+
{
|
|
271
|
+
"kind": "call",
|
|
272
|
+
"from": "raft-messaging",
|
|
273
|
+
"to": "raft-clock"
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
"kind": "call",
|
|
277
|
+
"from": "raft-messaging",
|
|
278
|
+
"to": "raft-random"
|
|
279
|
+
}
|
|
280
|
+
]
|
|
281
|
+
},
|
|
282
|
+
"acme.template.main": {
|
|
283
|
+
"pods": [
|
|
284
|
+
"calculator",
|
|
285
|
+
"history"
|
|
286
|
+
],
|
|
287
|
+
"subscriptions": [
|
|
288
|
+
{
|
|
289
|
+
"kind": "pipe",
|
|
290
|
+
"from": "calculator",
|
|
291
|
+
"source": "acme.template.Calculator/calculated",
|
|
292
|
+
"to": "history",
|
|
293
|
+
"target": "acme.template.History/save"
|
|
294
|
+
}
|
|
295
|
+
]
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
"modules": {
|
|
299
|
+
"example.todo": "./todo/example.todo.js",
|
|
300
|
+
"example.kv": "./kv/example.kv.js",
|
|
301
|
+
"example.messaging": "./chat/example.messaging.js",
|
|
302
|
+
"example.chat": "./chat/example.chat.js",
|
|
303
|
+
"example.auth": "./auth/example.auth.js",
|
|
304
|
+
"example.originkey": "./originkey/example.originkey.js",
|
|
305
|
+
"example.drift": "./drift/example.drift.js",
|
|
306
|
+
"example.raft": "./raft/example.raft.js",
|
|
307
|
+
"acme.template": "./template/acme.template.js"
|
|
308
|
+
},
|
|
309
|
+
"layout": {
|
|
310
|
+
"slots": [
|
|
311
|
+
{
|
|
312
|
+
"id": "todos",
|
|
313
|
+
"runtime": "example.todo.frontend",
|
|
314
|
+
"pod": "todos"
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
"id": "alice",
|
|
318
|
+
"runtime": "example.chat.room",
|
|
319
|
+
"pod": "alice"
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
"id": "bob",
|
|
323
|
+
"runtime": "example.chat.room",
|
|
324
|
+
"pod": "bob"
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
"id": "auth",
|
|
328
|
+
"runtime": "example.auth.main",
|
|
329
|
+
"pod": "auth"
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
"id": "log",
|
|
333
|
+
"runtime": "example.auth.main",
|
|
334
|
+
"pod": "log"
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
"id": "originKey",
|
|
338
|
+
"runtime": "example.originkey.main",
|
|
339
|
+
"pod": "originKey"
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
"id": "keyLog",
|
|
343
|
+
"runtime": "example.originkey.main",
|
|
344
|
+
"pod": "keyLog"
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
"id": "cluster",
|
|
348
|
+
"runtime": "raft",
|
|
349
|
+
"pod": "cluster"
|
|
350
|
+
}
|
|
351
|
+
]
|
|
352
|
+
},
|
|
353
|
+
"frames": {
|
|
354
|
+
"example.originkey": "./originkey/frame.html"
|
|
355
|
+
}
|
|
356
|
+
}
|