renku 0.0.2 → 0.0.6
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/LICENSE.md +8 -0
- package/README.md +91 -0
- package/dist/auth.d.ts +1 -1
- package/dist/bash-complete.js +1 -1
- package/dist/bun.d.ts +1 -3
- package/dist/bun.js +1 -1
- package/dist/cli.js +1 -1
- package/dist/client.d.ts +1 -6
- package/dist/client.js +1 -1
- package/dist/cloudflare-BVLzalPQ.js +2 -0
- package/dist/cloudflare.d.ts +2 -4
- package/dist/cloudflare.js +1 -1
- package/dist/cloudflare.worker.d.ts +2 -4
- package/dist/cloudflare.worker.js +1 -1
- package/dist/{context-BHCMRbxt.js → context-BZxerv82.js} +1 -1
- package/dist/context-store-BpRmbHKI.js +1 -0
- package/dist/create-computed-CgSmvZ_e.js +1 -0
- package/dist/create-context-OCBKqRIM.js +1 -0
- package/dist/create-loader-Bnk94Dhg.js +1 -0
- package/dist/data.d.ts +64 -13
- package/dist/data.js +1 -1
- package/dist/dom.d.ts +3 -4
- package/dist/dom.js +1 -1
- package/dist/{fragment-BZKaFASk.d.ts → fragment-Bly9noQG.d.ts} +1 -1
- package/dist/{index-SdO7aHUm.d.ts → index-iMWKMtYV.d.ts} +1 -2
- package/dist/index.d.ts +20 -8
- package/dist/index.js +1 -1
- package/dist/jsx-dev-runtime.d.ts +3 -3
- package/dist/jsx-dev-runtime.js +1 -1
- package/dist/jsx-runtime.d.ts +2 -2
- package/dist/jsx-runtime.js +1 -1
- package/dist/register-server-function-Dsv6VBSj.js +1 -0
- package/dist/{rsc-from-markup-lvVZNq4O.js → rsc-from-markup-ditxg5su.js} +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +1 -1
- package/dist/theme.css +59 -0
- package/dist/theme.js +0 -0
- package/dist/{types-BzglvZrW.d.ts → types-B4Ij4y1d.d.ts} +5 -0
- package/dist/types-BEYIs1ZF.d.ts +23 -0
- package/dist/{types-BPhJNjPW.d.ts → types-BSW-pDJE.d.ts} +2 -2
- package/dist/ui.d.ts +104 -20
- package/dist/ui.js +1 -1
- package/dist/update-dom-node-C7Nskg5l.js +1 -0
- package/dist/virtual-from-jsx-kd8FG7Em.js +1 -0
- package/dist/vite.js +1 -1
- package/package.json +44 -34
- package/dist/cloudflare-CKedebLt.js +0 -2
- package/dist/create-computed-D9oVNGZ6.js +0 -1
- package/dist/register-server-function-DQl0uL7w.js +0 -1
- package/dist/render-dom-node-BzR5XI1t.js +0 -1
- package/dist/signal-CqB2Ey1W.d.ts +0 -2
- package/dist/types-DwyPVMcM.d.ts +0 -16
- package/dist/virtual-from-jsx-BgQUXZ4d.js +0 -1
- /package/dist/{effect-hmzj-Jig.js → effect-Bd9_A9t9.js} +0 -0
- /package/dist/{fragment-Chv9FEhP.js → fragment-uL1agXkn.js} +0 -0
- /package/dist/{get-route-B1JNCPoL.js → get-route-DL8B9jay.js} +0 -0
- /package/dist/{impl-O61EKx7J.js → impl-6Uc2Rt9O.js} +0 -0
- /package/dist/{impl-CQ7GTRH2-BsAKEI_H.js → impl-CQ7GTRH2-Db6HOvCd.js} +0 -0
- /package/dist/{impl-CRQorzAF.js → impl-D9kbwKWf.js} +0 -0
- /package/dist/{impl-vRmneAi-.js → impl-qmFhldR7.js} +0 -0
- /package/dist/{jsx-runtime-DvEc5zft.js → jsx-runtime-BhjWaNaK.js} +0 -0
- /package/dist/{register-server-function-BuqMxh0V.d.ts → register-server-function-CqA4nPaJ.d.ts} +0 -0
- /package/dist/{types-BStlw_FH.d.ts → types-BcEav58N.d.ts} +0 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Copyright © 2025, Benedikt Müller.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
No licensee or downstream recipient may use the Software (including any modified or derivative versions) to directly compete with the original Licensor by offering it to third parties as a hosted, managed, or Software-as-a-Service (SaaS) product or cloud service where the primary value of the service is the functionality of the Software itself.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1 +1,92 @@
|
|
|
1
1
|
# Renku
|
|
2
|
+
|
|
3
|
+
[npm](https://npmjs.com/renku)
|
|
4
|
+
|
|
5
|
+
## Dependencies
|
|
6
|
+
|
|
7
|
+
- [signal-polyfill](https://github.com/proposal-signals/signal-polyfill) for reactivity
|
|
8
|
+
- [capnweb](https://github.com/cloudflare/capnweb) for RPC
|
|
9
|
+
- [@sqlite.org/sqlite-wasm](https://github.com/sqlite/sqlite-wasm) for client data storage
|
|
10
|
+
|
|
11
|
+
## Getting started
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
bun create github.com/renkudev/template-bun
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
bun create github.com/renkudev/template-vite
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## CSS Classes
|
|
22
|
+
|
|
23
|
+
Renku uses the `class` prop to apply CSS classes to its components (as opposed to `className` in React). Using `className` will still work though. The prop accespts either a string or an array of strings.
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
<ul>
|
|
27
|
+
<li><a href="/about" class={["link", "active"]}>About</a></li>
|
|
28
|
+
<li><a href="/contact" class="link">Contact</a></li>
|
|
29
|
+
</ul>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Signals
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { createSignal, createComputed, type FunctionComponent } from "renku";
|
|
36
|
+
|
|
37
|
+
export const Counter: FunctionComponent<{ start: number }> = ({ start }) => {
|
|
38
|
+
const counter = createSignal(start);
|
|
39
|
+
const isEven = createComputed(() => counter.get() % 2 === 0);
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div>
|
|
43
|
+
<button type="button" onclick={() => counter.set(counter.get() + 1)}>
|
|
44
|
+
Counter: {counter.get()} ({isEven.get() ? "even" : "odd"})
|
|
45
|
+
</button>
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Context
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import { createContext } from "renku";
|
|
55
|
+
|
|
56
|
+
export const context: Context<{
|
|
57
|
+
counter: Signal.State<number>;
|
|
58
|
+
}> = createContext();
|
|
59
|
+
|
|
60
|
+
export const Parent: FunctionComponent = ({
|
|
61
|
+
children,
|
|
62
|
+
}) => {
|
|
63
|
+
const counter = createSignal(0);
|
|
64
|
+
context.set({ counter });
|
|
65
|
+
|
|
66
|
+
return <div>{children}</div>;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const Child: FunctionComponent = ({
|
|
70
|
+
children,
|
|
71
|
+
}) => {
|
|
72
|
+
const counter = createSignal(0);
|
|
73
|
+
context.get({ counter });
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<div>
|
|
77
|
+
<button type="button" onclick={() => counter.set(counter.get() + 1)}>
|
|
78
|
+
Counter: {counter.get()}
|
|
79
|
+
</button>
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const App: FunctionComponent = () => {
|
|
85
|
+
return (
|
|
86
|
+
<Parent>
|
|
87
|
+
<Child />
|
|
88
|
+
<Child />
|
|
89
|
+
</Parent>
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
```
|
package/dist/auth.d.ts
CHANGED
package/dist/bash-complete.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import{i as e,n as t,t as n}from"./context-
|
|
2
|
+
import{i as e,n as t,t as n}from"./context-BZxerv82.js";const r=process.argv.slice(3);process.env.COMP_LINE?.endsWith(` `)&&r.push(``),await e(t,r,n(process));try{for(let{completion:i}of await e(t,r,n(process)))process.stdout.write(`${i}\n`)}catch{}
|
package/dist/bun.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import "./types-
|
|
2
|
-
import "./types-BzglvZrW.js";
|
|
3
|
-
import { n as PathToParams, t as AugmentedRequest } from "./types-BPhJNjPW.js";
|
|
1
|
+
import { n as PathToParams, t as AugmentedRequest } from "./types-BSW-pDJE.js";
|
|
4
2
|
import { RouteMetadata } from "bun:app";
|
|
5
3
|
import { BunPlugin, Serve } from "bun";
|
|
6
4
|
|
package/dist/bun.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,r as t,t as n}from"./rsc-from-markup-
|
|
1
|
+
import{n as e,r as t,t as n}from"./rsc-from-markup-ditxg5su.js";import"./virtual-from-jsx-kd8FG7Em.js";import"./signal-store-0zk-69gB.js";import"./effect-Bd9_A9t9.js";const r=async(r,i)=>{let{styles:a,modules:o,pageModule:s,layouts:c}=i,l=s.default();for(let e of c)l=e.default({children:[l],_renku:{styles:a,modules:o}});let u=e(l);if(r.headers.get(`Accept`)===`text/x-component`){let e=n(u);return new Response(e,{headers:{"Content-Type":`text/x-component`}})}let d=t(u);return new Response(d,{headers:{"Content-Type":`text/html`}})},i=({routes:e,bake:t,plugins:n})=>t?{app:{framework:{fileSystemRouterTypes:[{root:`./pages`,serverEntryPoint:`renku/bun`,clientEntryPoint:`renku/client`,style:`nextjs-pages`,layouts:!0,extensions:[`ts`,`tsx`,`mdx`]}],serverComponents:{separateSSRGraph:!1,serverRuntimeImportSource:`renku/server`},plugins:n}},fetch:()=>new Response}:{routes:e,development:!0};export{r as render,i as renku};
|
package/dist/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import{n as e,r as t,t as n}from"./context-
|
|
2
|
+
import{n as e,r as t,t as n}from"./context-BZxerv82.js";await t(e,process.argv.slice(2),n(process));
|
package/dist/client.d.ts
CHANGED
package/dist/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./virtual-from-jsx-
|
|
1
|
+
import{n as e}from"./virtual-from-jsx-kd8FG7Em.js";import"./signal-store-0zk-69gB.js";import"./effect-Bd9_A9t9.js";import{n as t,r as n,t as r}from"./update-dom-node-C7Nskg5l.js";const i=e=>Array.isArray(e)&&e[0]===`A`,a=e=>Array.isArray(e)&&e[0]===`C`,o=e=>Array.isArray(e)&&e[0]===`E`,s=e=>{if(o(e)){let t=[],{children:n,...r}=e[3];if(n)for(let e of n)t.push(s(e));return{type:`element`,value:e[1],key:e[2],props:r,children:t}}return i(e)?{type:`async`,key:e[1],index:e[2]}:a(e)?{type:`client`,key:e[1],path:e[2],name:e[3],props:e[4]}:typeof e==`string`||typeof e==`number`?{type:`text`,value:String(e)}:null},c={virtualNode:void 0},l=async e=>{let t=await fetch(e.pathname,{headers:{Accept:`text/x-component`}});if(t.body&&c.virtualNode){let e=s(await t.json());r({domNode:document.documentElement,oldVirtualNode:c.virtualNode,newVirtualNode:e}),c.virtualNode=e;return}console.error(`No body`)},u=e=>!e.canIntercept||e.hashChange||!!e.downloadRequest||!!e.formData,d=()=>{window.navigation.addEventListener(`navigate`,e=>{if(u(e))return;let t=new URL(e.destination.url);e.intercept({async handler(){await l(t)}})})},f=(r,i)=>{if(i?.type===`element`&&i.value.toLowerCase()===r.tagName.toLowerCase()){i.domNode=r;for(let[a,o]of i.children.entries()){let s=r.childNodes[a];if(s)if(o?.type===`element`)s instanceof HTMLElement&&f(s,o);else if(o?.type===`text`){if(s.textContent===o.value)o.domNode=s;else if(s.nodeType===Node.TEXT_NODE){let e=``;for(let t of i.children)if(t?.type===`text`)e+=t.value;else if(t?.type===`signal`)e+=String(t.value.get());else if(t?.type===`element`)break;s.textContent===e&&(o.domNode=s)}}else o?.type===`signal`?s.textContent===String(o.value.get())&&(o.domNode=s):o?.type===`async`?s.nodeType===Node.COMMENT_NODE&&(o.domNode=s):o?.type===`client`&&s.nodeType===Node.COMMENT_NODE&&(o.domNode=s,import(o.path).then(r=>{let i=e({fn:r[o.name],key:o.key,props:o.props,asyncComponents:[],clientComponents:[]});Array.isArray(i)?n({domNode:s,virtualNode:i,replace:!0}):t({domNode:s,virtualNode:i,replace:!0})}))}}},p=e=>{try{let t=JSON.parse(e);if(o(t)){let e=s(t);f(document.documentElement,e),c.virtualNode=e}else console.warn(`Unhandled: Not RSC Element`)}catch(e){console.error(`Failed to parse RSC chunk:`,e)}};d(),window.__RSC||=[];for(let e of window.__RSC)p(e);window.__RSC.push=e=>(console.log(`streamed rsc line`,e),window.__RSC.length);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{n as e,r as t,t as n}from"./auth-DivcgvqR.js";import{n as r,r as i,t as a}from"./rsc-from-markup-ditxg5su.js";import{t as o}from"./get-route-DL8B9jay.js";import{newWorkersRpcResponse as s}from"capnweb";import{clientEntry as c}from"virtual:renku";const l=({namespace:e,name:t,ws:n})=>async(r,i)=>{if(console.log(`🔥`,`DO handler`,typeof t),n){let e=r.headers.get(`Upgrade`);if(!e||e!==`websocket`)return new Response(`Durable Object expected Upgrade: websocket`,{status:426})}if(typeof t==`function`){let e=r.clone();t=await t(e)}return i[e].getByName(t).fetch(r)},u=({rpName:e,sessionExpiryInMinutes:t})=>{t??=60;let r=e=>e*60*1e3;return{"/validate-session":{GET:async(e,t,r)=>n().sessionId?Response.json({isAuthenticated:!0}):Response.json({isAuthenticated:!1})},"/logout":{POST:async(e,t,i)=>{let a=n();a.sessionId&&await t.AUTH_DO.getByName(`session:${a.sessionId}`).logout();let o=new Date(Date.now()-r(10)).toUTCString();return new Response(null,{headers:{"Set-Cookie":`sessionId=; Path=/; SameSite=Strict; Secure; Expires=${o}`}})},GET:async(e,t,i)=>{let a=n();a.sessionId&&await t.AUTH_DO.getByName(`session:${a.sessionId}`).logout();let o=new Date(Date.now()-r(10)).toUTCString();return new Response(null,{status:302,headers:{Location:`/`,"Set-Cookie":`sessionId=; Path=/; SameSite=Strict; Secure; Expires=${o}`}})}},"/creation-options":{POST:async(t,n,r)=>{let{email:i}=await t.json(),a=crypto.randomUUID(),o=n.AUTH_DO.getByName(`user:${a}`),s=new URL(t.url).hostname,c=await o.creationOptions({id:a,email:i,rpId:s,rpName:e});return Response.json(c)}},"/validate-creation":{POST:async(e,t,n)=>{let{name:r,credential:i}=await e.json();return await t.AUTH_DO.getByName(`user:${r}`).validateCreation({name:r,credential:i}),Response.json({ok:!0})}},"/request-options":{POST:async(e,t,n)=>{let r=new URL(e.url).hostname,i=crypto.randomUUID(),a=await t.AUTH_DO.getByName(`challenge:${i}`).requestOptions({rpId:r});return Response.json({id:i,options:a})}},"/validate-request":{POST:async(e,n,i)=>{let{id:a,credential:o}=await e.json(),s=await n.AUTH_DO.getByName(`challenge:${a}`).validateRequest({credential:o,sessionExpiryInMinutes:t});if(s){let e=new Date(Date.now()+r(t)).toUTCString();return Response.json({success:!0},{headers:{"Set-Cookie":`sessionId=${s}; Path=/; SameSite=Strict; Secure; Expires=${e}`}})}return Response.json({error:!0})}}}},d=e=>{let t={};if(!e)return t;let n=e.split(`;`);for(let e of n){let n=e.indexOf(`=`);if(n===-1)continue;let r=e.slice(0,n).trim(),i=e.slice(n+1).trim();r&&(t[r]=i)}return t},f=async({request:t,env:n,authFn:r})=>{let i=e(),a=d(t.headers.get(`cookie`));if(`sessionId`in a&&a.sessionId){if(i.sessionId=a.sessionId,n?.AUTH_DO){let e=await n.AUTH_DO.getByName(`session:${i.sessionId}`).validateSession({sessionExpiryInMinutes:1440});e&&(i.userId=e.userId)}}else i.sessionId=null;return r?r({request:t,authContext:i}):!0},p=new TextEncoder,m=e=>{let t=e[Symbol.asyncIterator]();return new ReadableStream({async pull(e){let{value:n,done:r}=await t.next();if(r)e.close();else{let t=typeof n==`object`?JSON.stringify(n).concat(`
|
|
2
|
+
`):n;e.enqueue(p.encode(t))}}})},h=[`favicon.ico`,`.well-known`],g=({routes:e})=>async(n,l,u)=>t(async()=>{let t=new URL(n.url).pathname.split(`/`),d=t[1];if(d&&h.includes(d))return new Response(null,{status:404});let p=o({request:n,routes:e}),g=await f({request:n,env:l,authFn:p?p.auth:null});if(g!==!0)return g||new Response(null,{status:401});if(d===`@renku`){if(t[2]===`rpc`&&t[3]&&t[4]){let e=decodeURIComponent(t[3]),r=decodeURIComponent(t[4]);import.meta.env.DEV||(e=`/assets/functions/${e}.js`),console.log(`☎️ Server function was called:`,e,r);let i=(await import(e))[r];return s(n,i)}return new Response(null,{status:404})}if(!p)return console.warn(`No routing result`),new Response(null,{status:404});if(p.api){let e=Object.assign(n,{params:p.params});return p.api(e,l,u)}let _=null;if(p.route instanceof Promise)_=await(await p.route).default(p.params);else if(p.route&&`default`in p.route&&typeof p.route.default==`function`)_=await p.route.default(p.params);else if(typeof p.route==`function`)_=await p.route(p.params);else return new Response(null,{status:404});let v={styles:[],modules:[]};import.meta.env.DEV?(v.modules.push(`/@vite/client`),v.modules.push(`/@renku/client`)):c&&v.modules.push(c);for(let e of p.layouts)e instanceof Promise?_=await(await e).default({children:_,_renku:v}):`default`in e&&typeof e.default==`function`?_=await e.default({children:_,_renku:v}):typeof e==`function`&&(_=await e({children:_,_renku:v}));let y=r(_);if(n.headers.get(`Accept`)===`text/x-component`){let e=m(a(y));return new Response(e,{headers:{"Content-Type":`text/x-component`}})}let b=m(i(y));return new Response(b,{headers:{"Content-Type":`text/html`}})}),_=({routes:e})=>({fetch:g({routes:e})});export{u as n,l as r,_ as t};
|
package/dist/cloudflare.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import "./types-
|
|
2
|
-
import "./
|
|
3
|
-
import { r as Routes } from "./types-BPhJNjPW.js";
|
|
4
|
-
import { n as getAuthRoutes, r as durableObjectHandler, t as renku } from "./index-SdO7aHUm.js";
|
|
1
|
+
import { r as Routes } from "./types-BSW-pDJE.js";
|
|
2
|
+
import { n as getAuthRoutes, r as durableObjectHandler, t as renku } from "./index-iMWKMtYV.js";
|
|
5
3
|
export { Routes, durableObjectHandler, getAuthRoutes, renku };
|
package/dist/cloudflare.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./auth-DivcgvqR.js";import"./rsc-from-markup-
|
|
1
|
+
import"./auth-DivcgvqR.js";import"./rsc-from-markup-ditxg5su.js";import"./virtual-from-jsx-kd8FG7Em.js";import"./signal-store-0zk-69gB.js";import"./effect-Bd9_A9t9.js";import{n as e,r as t,t as n}from"./cloudflare-BVLzalPQ.js";export{t as durableObjectHandler,e as getAuthRoutes,n as renku};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import "./types-
|
|
2
|
-
import "./
|
|
3
|
-
import { r as Routes } from "./types-BPhJNjPW.js";
|
|
4
|
-
import { n as getAuthRoutes, r as durableObjectHandler, t as renku } from "./index-SdO7aHUm.js";
|
|
1
|
+
import { r as Routes } from "./types-BSW-pDJE.js";
|
|
2
|
+
import { n as getAuthRoutes, r as durableObjectHandler, t as renku } from "./index-iMWKMtYV.js";
|
|
5
3
|
import { DurableObject } from "cloudflare:workers";
|
|
6
4
|
|
|
7
5
|
//#region src/cloudflare/durable-objects/auth.d.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./auth-DivcgvqR.js";import"./rsc-from-markup-
|
|
1
|
+
import"./auth-DivcgvqR.js";import"./rsc-from-markup-ditxg5su.js";import"./virtual-from-jsx-kd8FG7Em.js";import"./signal-store-0zk-69gB.js";import"./effect-Bd9_A9t9.js";import{n as e,r as t,t as n}from"./cloudflare-BVLzalPQ.js";import{DurableObject as r}from"cloudflare:workers";const i=e=>{let t=e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(Math.ceil(e.length/4)*4,`=`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r},a=e=>btoa(String.fromCharCode(...e)).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`);var o=class extends r{challenge=null;constructor(e,t){super(e,t)}createChallenge(){let e=new Uint8Array(16);return self.crypto.getRandomValues(e),this.challenge=a(e),this.challenge}creationOptions({id:e,email:t,rpId:n,rpName:r}){let i=this.createChallenge();return{user:{id:e,name:t,displayName:t},challenge:i,rp:{id:n,name:r},pubKeyCredParams:[{type:`public-key`,alg:-7},{type:`public-key`,alg:-257}]}}async validateCreation({name:e,credential:t}){console.log(`validate`,t);let n=new TextDecoder,r=i(t.response.clientDataJSON),a=JSON.parse(n.decode(r));return a.type===`webauthn.create`&&this.challenge===a.challenge?(this.ctx.storage.kv.put(`credential:${t.id}`,t),this.ctx.storage.kv.put(`name`,e),await this.env.AUTH_DO.getByName(`credential:${t.id}`).storeCredential({name:e,credential:t}),!0):!1}storeCredential({name:e,credential:t}){this.ctx.storage.kv.put(`name`,e),this.ctx.storage.kv.put(`credential`,t)}getChallenge(){return this.challenge}requestOptions({rpId:e}){return{challenge:this.createChallenge(),rpId:e}}async validateRequest({credential:e,sessionExpiryInMinutes:t}){return this.challenge?this.env.AUTH_DO.getByName(`credential:${e.id}`).validateCredential({challenge:this.challenge,credential:e,sessionExpiryInMinutes:t}):!1}async validateCredential({challenge:e,credential:t,sessionExpiryInMinutes:n}){let r=new TextDecoder,a=this.ctx.storage.kv.get(`name`),o=this.ctx.storage.kv.get(`credential`),s=i(t.response.clientDataJSON),c=JSON.parse(r.decode(s));if(console.log(`validateCredential`,{challenge:e,credential:t,clientData:c,storedCredential:o,name:a}),a&&e===c.challenge){let e=crypto.randomUUID();return await this.env.AUTH_DO.getByName(`session:${e}`).createSession({userId:a,sessionExpiryInMinutes:n}),e}return!1}setExpiry(e){this.ctx.storage.kv.put(`expiry`,Date.now()+e*60*1e3)}createSession({userId:e,sessionExpiryInMinutes:t}){this.ctx.storage.kv.put(`userId`,e),this.setExpiry(t)}getUserId(){let e=this.ctx.storage.kv.get(`userId`);return e||(e=crypto.randomUUID(),this.ctx.storage.kv.put(`userId`,e)),e}validateSession({sessionExpiryInMinutes:e}){let t=this.ctx.storage.kv.get(`expiry`),n=this.ctx.storage.kv.get(`userId`);return n&&t&&Date.now()<t?(this.setExpiry(e),{userId:n}):!1}logout(){this.ctx.storage.kv.delete(`userId`)}};export{o as AuthDO,t as durableObjectHandler,e as getAuthRoutes,n as renku};
|
|
@@ -20,4 +20,4 @@ import e from"node:fs";import t from"node:os";import n from"node:path";function
|
|
|
20
20
|
`)+`
|
|
21
21
|
`,usesFlag:e=>e in t||e in n}}function*Le(e,t,n){let{brief:r,fullDescription:i,hideRoute:a}=t,{headers:s}=n.text;yield n.ansiColor?`\x1B[1m${s.usage}\x1B[22m`:s.usage;for(let[t,r]of Object.entries(e))if(!a||!a[t]||n.includeHidden){let e=n.config.caseStyle===`convert-camel-to-kebab`?o(t):t;yield` ${r.formatUsageLine({...n,prefix:[...n.prefix,e]})}`}let c=n.prefix.join(` `);for(let e of Y(n))yield` ${c} ${e}`;if(yield``,yield i??r,n.aliases&&n.aliases.length>0){let e=n.prefix.slice(0,-1).join(` `);yield``,yield n.ansiColor?`\x1B[1m${s.aliases}\x1B[22m`:s.aliases;for(let t of n.aliases)yield` ${e} ${t}`}yield``,yield n.ansiColor?`\x1B[1m${s.flags}\x1B[22m`:s.flags;for(let e of J({},{},n))yield` ${e}`;yield``,yield n.ansiColor?`\x1B[1m${s.commands}\x1B[22m`:s.commands;let l=m(Object.entries(e).filter(([e])=>!a||!a[e]||n.includeHidden).map(([e,t])=>({routeName:V(e,n.config.caseStyle),brief:t.brief,hidden:a&&a[e]})).map(e=>n.ansiColor?[e.hidden?`\x1B[90m${e.routeName}\x1B[39m`:`\x1B[97m${e.routeName}\x1B[39m`,e.hidden?`\x1B[90m${e.brief}\x1B[39m`:`\x1B[03m${e.brief}\x1B[23m`]:[e.routeName,e.brief]),[` `]);for(let e of l)yield` ${e}`}function Z({routes:e,defaultCommand:t,docs:n,aliases:r}){if(Object.entries(e).length===0)throw new d(`Route map must contain at least one route`);let i=r??{},s=new Map;for(let[t,n]of Object.entries(i)){if(t in e)throw new d(`Cannot use "${t}" as an alias when a route with that name already exists`);let r=s.get(n)??[];s.set(n,[...r,t])}let c=t?e[t]:void 0;if(c&&c.kind===R)throw new d(`Cannot use "${t}" as the default command because it is not a Command`);let l=t=>{if(t in i)return i[t];if(t in e)return t};return{kind:R,get brief(){return n.brief},formatUsageLine(e){let t=this.getAllEntries().filter(e=>!e.hidden).map(t=>t.name[e.config.caseStyle]);return`${e.prefix.join(` `)} ${t.join(`|`)} ...`},formatHelp:t=>[...Le(e,n,t)].join(`
|
|
22
22
|
`)+`
|
|
23
|
-
`,getDefaultCommand:()=>c,getOtherAliasesForInput:(e,n)=>{if(t){if(e===t)return{original:[``],"convert-camel-to-kebab":[``]};if(e===``)return{original:[t],"convert-camel-to-kebab":[t]}}let r=a(e),i=l(e);if(!i&&n===`allow-kebab-for-camel`&&(i=l(r)),!i)return{original:[],"convert-camel-to-kebab":[]};let c=[i,...s.get(i)??[]].filter(t=>t!==e&&t!==r);return{original:c,"convert-camel-to-kebab":c.map(o)}},getRoutingTargetForInput:t=>e[t in i?i[t]:t],getAllEntries(){let t=n.hideRoute;return Object.entries(e).map(([e,n])=>({name:{original:e,"convert-camel-to-kebab":o(e)},target:n,aliases:s.get(e)??[],hidden:t?.[e]??!1}))}}}async function Re(e,t,n){let r=await be(e,t,n);n.process.exitCode=r}function Q(e,t){if(e.length<=1)return e[0]??``;if(e.length===2)return e.join(` ${t.conjunction} `);let n=e.slice(0,e.length-1).join(`, `);return t.serialComma&&(n+=`,`),[n,t.conjunction,e[e.length-1]].join(` `)}var $={parse:String,brief:`Target command run by user`,placeholder:`targetCommand`};X({loader:async()=>{let{install:e}=await import(`./impl-CQ7GTRH2-
|
|
23
|
+
`,getDefaultCommand:()=>c,getOtherAliasesForInput:(e,n)=>{if(t){if(e===t)return{original:[``],"convert-camel-to-kebab":[``]};if(e===``)return{original:[t],"convert-camel-to-kebab":[t]}}let r=a(e),i=l(e);if(!i&&n===`allow-kebab-for-camel`&&(i=l(r)),!i)return{original:[],"convert-camel-to-kebab":[]};let c=[i,...s.get(i)??[]].filter(t=>t!==e&&t!==r);return{original:c,"convert-camel-to-kebab":c.map(o)}},getRoutingTargetForInput:t=>e[t in i?i[t]:t],getAllEntries(){let t=n.hideRoute;return Object.entries(e).map(([e,n])=>({name:{original:e,"convert-camel-to-kebab":o(e)},target:n,aliases:s.get(e)??[],hidden:t?.[e]??!1}))}}}async function Re(e,t,n){let r=await be(e,t,n);n.process.exitCode=r}function Q(e,t){if(e.length<=1)return e[0]??``;if(e.length===2)return e.join(` ${t.conjunction} `);let n=e.slice(0,e.length-1).join(`, `);return t.serialComma&&(n+=`,`),[n,t.conjunction,e[e.length-1]].join(` `)}var $={parse:String,brief:`Target command run by user`,placeholder:`targetCommand`};X({loader:async()=>{let{install:e}=await import(`./impl-CQ7GTRH2-Db6HOvCd.js`);return e},parameters:{flags:{bash:{kind:`parsed`,brief:`Command executed by bash to generate completion proposals`,parse:String,optional:!0,placeholder:`command`}},positional:{kind:`tuple`,parameters:[$]}},docs:{brief:`Installs autocomplete support for target command on all provided shell types`}});function ze(e,t){return X({loader:async()=>{let{install:n}=await import(`./impl-CQ7GTRH2-Db6HOvCd.js`);return function(){return n.call(this,t,e)}},parameters:{},docs:{brief:`Installs ${Q(Object.keys(t),{conjunction:`and`,serialComma:!0})} autocomplete support for ${e}`}})}X({loader:async()=>{let{uninstall:e}=await import(`./impl-CQ7GTRH2-Db6HOvCd.js`);return e},parameters:{flags:{bash:{kind:`boolean`,brief:`Uninstall autocompletion for bash`,optional:!0}},positional:{kind:`tuple`,parameters:[$]}},docs:{brief:`Uninstalls autocomplete support for target command on all selected shell types`}});function Be(e,t){return X({loader:async()=>{let{uninstall:n}=await import(`./impl-CQ7GTRH2-Db6HOvCd.js`);return function(){return n.call(this,t,e)}},parameters:{},docs:{brief:`Uninstalls ${Q(Object.entries(t).filter(([,e])=>e).map(([e])=>e),{conjunction:`and`,serialComma:!0})} autocomplete support for ${e}`}})}var Ve=`renku`,He=`0.0.6`,Ue=`Renku`;const We=Z({routes:{ios:X({loader:async()=>{let{ios:e}=await import(`./impl-6Uc2Rt9O.js`);return e},parameters:{positional:{kind:`tuple`,parameters:[]},flags:{foo:{kind:`parsed`,optional:!0,parse:String,brief:`Foo`}}},docs:{brief:`Nested ios command`}}),android:X({loader:async()=>{let{android:e}=await import(`./impl-6Uc2Rt9O.js`);return e},parameters:{positional:{kind:`tuple`,parameters:[]},flags:{foo:{kind:`parsed`,optional:!0,parse:String,brief:`Foo`}}},docs:{brief:`Nested android command`}})},docs:{brief:`Native app generation`}}),Ge=Z({routes:{foo:X({loader:async()=>{let{foo:e}=await import(`./impl-qmFhldR7.js`);return e},parameters:{positional:{kind:`tuple`,parameters:[]},flags:{foo:{kind:`parsed`,optional:!0,parse:String,brief:`Foo`}}},docs:{brief:`Nested foo command`}}),bar:X({loader:async()=>{let{bar:e}=await import(`./impl-qmFhldR7.js`);return e},parameters:{positional:{kind:`tuple`,parameters:[]},flags:{foo:{kind:`parsed`,optional:!0,parse:String,brief:`Foo`}}},docs:{brief:`Nested bar command`}})},docs:{brief:`Nested commands`}}),Ke=Ce(Z({routes:{subdir:X({loader:async()=>import(`./impl-D9kbwKWf.js`),parameters:{positional:{kind:`tuple`,parameters:[]},flags:{foo:{kind:`parsed`,optional:!0,parse:String,brief:`Foo`}}},docs:{brief:`Command in subdirectory`}}),nested:Ge,native:We,install:ze(`my-app`,{bash:`__my-app_bash_complete`}),uninstall:Be(`my-app`,{bash:!0})},docs:{brief:Ue,hideRoute:{install:!0,uninstall:!0}}}),{name:Ve,versionInfo:{currentVersion:He}});function qe(r){return{process:r,os:t,fs:e,path:n}}export{Ee as i,Ke as n,Re as r,qe as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={current:void 0,set(e,t){this.current||=new Map,this.current.set(e,t)},get(e){return this.current?.get(e)}};export{e as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./signal-store-0zk-69gB.js";const n=e=>t.get(e),r=t=>new e.Computed(t);export{n,r as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./context-store-BpRmbHKI.js";const t=t=>{let n=Symbol(`context`);return{set:t=>{e.set(n,t)},get:()=>{let r=e.get(n);if(r===void 0&&t!==void 0)return t;if(r===void 0)throw Error(`Context value not found. Make sure to use provide() in a parent component.`);return r}}};export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./create-computed-CgSmvZ_e.js";function t(t,n){let r=e({status:`loading`,error:!1,data:null});return r.get().status===`loading`&&t().then(async e=>{if(!n)r.set({status:`success`,error:!1,data:e});else{let t=n(e),i=t instanceof Promise?await t:t;r.set({status:`success`,error:!1,data:i})}}).catch(e=>r.set({status:`error`,error:e,data:null})),r}export{t};
|
package/dist/data.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as Loader } from "./types-DwyPVMcM.js";
|
|
1
|
+
import { n as Loader, o as Signal } from "./types-BEYIs1ZF.js";
|
|
3
2
|
import { RpcStub, RpcTarget } from "capnweb";
|
|
3
|
+
import { StandardJSONSchemaV1, StandardSchemaV1 } from "@standard-schema/spec";
|
|
4
4
|
|
|
5
5
|
//#region src/data/schema/types.d.ts
|
|
6
6
|
interface Schema {
|
|
@@ -11,6 +11,15 @@ interface ObjectSchema {
|
|
|
11
11
|
[key: string]: PropertySchema;
|
|
12
12
|
}
|
|
13
13
|
type PropertySchema = IdSchema | StringSchema | NumberSchema | BooleanSchema;
|
|
14
|
+
/**
|
|
15
|
+
* Enhanced ObjectSchema with Standard Schema v1 support.
|
|
16
|
+
* Includes validation and JSON Schema generation capabilities.
|
|
17
|
+
*/
|
|
18
|
+
type EnhancedObjectSchema<T extends ObjectSchema> = T & StandardSchemaV1<Item<T>, Item<T>> & StandardJSONSchemaV1<Item<T>, Item<T>>;
|
|
19
|
+
/**
|
|
20
|
+
* Enhanced Schema type where each collection becomes a Standard Schema.
|
|
21
|
+
*/
|
|
22
|
+
type EnhancedSchema<T extends Schema> = { [K in keyof T]: EnhancedObjectSchema<T[K]> };
|
|
14
23
|
interface IdSchema extends PropertyBaseSchema {
|
|
15
24
|
type: "string";
|
|
16
25
|
required: true;
|
|
@@ -37,15 +46,6 @@ interface PropertyBaseSchema {
|
|
|
37
46
|
mock?: () => string | number | boolean;
|
|
38
47
|
}
|
|
39
48
|
//#endregion
|
|
40
|
-
//#region src/data/db/types.d.ts
|
|
41
|
-
type Binding = string | number;
|
|
42
|
-
interface Database {
|
|
43
|
-
exec: (sql: string, ...bind: Binding[]) => void;
|
|
44
|
-
query: <T = unknown>(sql: string, ...bindings: unknown[]) => T[];
|
|
45
|
-
transaction: (callback: (db: Database) => void) => void;
|
|
46
|
-
clientId: string;
|
|
47
|
-
}
|
|
48
|
-
//#endregion
|
|
49
49
|
//#region src/data/sync/types.d.ts
|
|
50
50
|
interface SyncMessage {
|
|
51
51
|
id: string;
|
|
@@ -69,6 +69,15 @@ declare class MessageQueue {
|
|
|
69
69
|
add(message: SyncMessage): void;
|
|
70
70
|
}
|
|
71
71
|
//#endregion
|
|
72
|
+
//#region src/data/db/types.d.ts
|
|
73
|
+
type Binding = string | number;
|
|
74
|
+
interface Database {
|
|
75
|
+
exec: (sql: string, ...bind: Binding[]) => void;
|
|
76
|
+
query: <T = unknown>(sql: string, ...bindings: unknown[]) => T[];
|
|
77
|
+
transaction: (callback: (db: Database) => void) => void;
|
|
78
|
+
clientId: string;
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
72
81
|
//#region src/data/collection/collection.d.ts
|
|
73
82
|
declare class Collection<T extends Schema, K$1 extends keyof T> {
|
|
74
83
|
#private;
|
|
@@ -105,6 +114,7 @@ declare class RemoteCollection<T extends Schema, K$1 extends keyof T> extends Rp
|
|
|
105
114
|
query(params?: QueryParams<T, K$1>): Item<T[K$1]>[];
|
|
106
115
|
first(params?: Omit<QueryParams<T, K$1>, "single" | "limit">): Item<T[K$1]> | undefined;
|
|
107
116
|
all(): Item<T[K$1]>[];
|
|
117
|
+
add(item: Item<T[K$1]>): void;
|
|
108
118
|
}
|
|
109
119
|
//#endregion
|
|
110
120
|
//#region src/data/collection/types.d.ts
|
|
@@ -208,9 +218,50 @@ declare class ClientData<T extends Schema> extends Data<T> {
|
|
|
208
218
|
}
|
|
209
219
|
//#endregion
|
|
210
220
|
//#region src/data/schema/schema.d.ts
|
|
211
|
-
|
|
221
|
+
/**
|
|
222
|
+
* Creates an enhanced schema with Standard Schema v1 validation and
|
|
223
|
+
* JSON Schema generation support.
|
|
224
|
+
*
|
|
225
|
+
* Each collection in the schema becomes its own Standard Schema that supports:
|
|
226
|
+
* - Item-level validation (required fields, type checking)
|
|
227
|
+
* - JSON Schema generation (draft-2020-12, draft-07)
|
|
228
|
+
*
|
|
229
|
+
* @param inputSchema - The Renku schema definition
|
|
230
|
+
* @returns Enhanced schema with Standard Schema support
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* ```ts
|
|
234
|
+
* const mySchema = schema({
|
|
235
|
+
* user: {
|
|
236
|
+
* id,
|
|
237
|
+
* email: { type: "string", required: true },
|
|
238
|
+
* age: { type: "number" },
|
|
239
|
+
* },
|
|
240
|
+
* });
|
|
241
|
+
*
|
|
242
|
+
* // Validate an item
|
|
243
|
+
* const result = mySchema.user["~standard"].validate({ ... });
|
|
244
|
+
*
|
|
245
|
+
* // Generate JSON Schema
|
|
246
|
+
* const jsonSchema = mySchema.user["~standard"].jsonSchema.output({
|
|
247
|
+
* target: "draft-2020-12"
|
|
248
|
+
* });
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
declare const schema$1: <T extends Schema>(inputSchema: T) => EnhancedSchema<T>;
|
|
212
252
|
//#endregion
|
|
213
253
|
//#region src/data/schema/id.d.ts
|
|
214
254
|
declare const id: IdSchema;
|
|
215
255
|
//#endregion
|
|
216
|
-
|
|
256
|
+
//#region src/data/schema/validate.d.ts
|
|
257
|
+
/**
|
|
258
|
+
* Helper function for property-level validation.
|
|
259
|
+
* Validates a single property value against a property schema.
|
|
260
|
+
*
|
|
261
|
+
* @param propertySchema - The property schema to validate against
|
|
262
|
+
* @param value - The value to validate
|
|
263
|
+
* @returns Standard Schema validation result
|
|
264
|
+
*/
|
|
265
|
+
declare function validatePropertyValue(propertySchema: PropertySchema, value: unknown): StandardSchemaV1.Result<string | number | boolean>;
|
|
266
|
+
//#endregion
|
|
267
|
+
export { ClientData, type EnhancedObjectSchema, type EnhancedSchema, type IdSchema, type Item, type Schema, ServerData, id, schema$1 as schema, validatePropertyValue };
|
package/dist/data.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./signal-store-0zk-69gB.js";import{n as e,
|
|
1
|
+
import"./signal-store-0zk-69gB.js";import{n as e,t}from"./create-computed-CgSmvZ_e.js";import{t as n}from"./create-loader-Bnk94Dhg.js";import{RpcStub as r,RpcTarget as i}from"capnweb";import"@sqlite.org/sqlite-wasm";const a=e=>{switch(e){case`string`:return`TEXT`;case`number`:return`INTEGER`;case`boolean`:return`INTEGER`;default:throw Error(`Unsupported type: ${String(e)}`)}},o=e=>{let t=``;for(let[n,r]of Object.entries(e)){let e=Object.entries(r).map(([e,t])=>`${e} ${a(t.type)}`).join(`, `);e&&(t+=`CREATE TABLE IF NOT EXISTS obj_${n} (${e});`)}return t+=`CREATE TABLE IF NOT EXISTS __renku (id TEXT NOT NULL PRIMARY KEY, value TEXT NOT NULL);`,t+=`INSERT INTO __renku (id, value) VALUES ('client_id', '${crypto.randomUUID()}') ON CONFLICT (id) DO NOTHING;`,t+=`CREATE TABLE IF NOT EXISTS __crdt (id TEXT NOT NULL PRIMARY KEY, timestamp TEXT NOT NULL, client TEXT NOT NULL, object TEXT NOT NULL, item TEXT NOT NULL, updates TEXT);`,t},s=({db:e,schema:t})=>{let n=o(t);e.exec(n);let r=e.query(`SELECT value FROM __renku WHERE id = 'client_id' LIMIT 1`);if(!r[0])throw Error(`Client ID not found`);e.clientId=r[0].value},c=({client:e,object:t,item:n})=>{let{id:r,...i}=n;return{id:crypto.randomUUID(),timestamp:Date.now().toString(),client:e,object:t,item:r,updates:JSON.stringify(i)}};var l=class{#e=new Set;subscribe(e){return this.#e.add(e),()=>{this.#e.delete(e)}}#t(e){console.log(`this.#subscriptions`,this.#e);for(let t of this.#e){if(t.filter&&!t.filter(e))continue;console.log(`✉️`,`Dispatching`,t.label);let n=t.subscriber(e);n instanceof Promise&&n.catch(e=>{console.error(`MessageQueue subscriber failed.`,e)})}}add(e){this.#t(e)}},u=class{#e;#t;#n;#r=e([]);#i;#a;constructor({name:e,obj:t,clientId:n,messageQueue:r,db:i}){this.#a=i,this.#e=n,this.#t=e,this.#n=t,this.#i=r,this.#i.subscribe({subscriber:e=>this.#o(e),filter:e=>e.object===this.#t,label:`Collection: ${this.#t}`})}mock(){return Object.entries(this.#n).reduce((e,[t,n])=>(e[t]=n.mock?n.mock():void 0,e),{})}#o(e){console.log(e);let t={id:e.item,...JSON.parse(e.updates)};this.#r.set(this.#r.get().concat(t))}#s(){if(this.#a){let e=`SELECT * FROM obj_${this.#t}`;this.#r.set(this.#a.query(e))}}get items(){return this.#s(),this.#r}query({filter:e,limit:n,first:r}={}){return t(()=>{let t=this.#r.get().filter(e||(()=>!0));return(n||r)&&(t=t.slice(0,r?1:n)),t})}first(e={}){return e.first=!0,t(()=>{let t=this.query(e).get();return t.length>0?t[0]:void 0})}all(){return this.query()}add(e){let t=c({client:this.#e,object:this.#t,item:e});return this.#i.add(t),e}};const d=({schema:e,clientId:t,messageQueue:n,db:r})=>Object.entries(e).reduce((e,[i,a])=>{let o=i;return e[o]=new u({name:i,obj:a,clientId:t,messageQueue:n,db:r}),e},{}),f=e=>t=>{e.transaction(e=>{if(e.exec(`INSERT INTO __crdt (id, timestamp, client, object, item, updates) VALUES (?, ?, ?, ?, ?, ?);`,t.id,t.timestamp,t.client,t.object,t.item,t.updates),t.updates===`DELETE`)e.exec(`DELETE FROM obj_${t.object} WHERE id = ?;`,t.item);else{let n=[t.item],r=JSON.parse(t.updates),i=[`id`].concat(Object.keys(r));n.push(...Object.values(r));let a=`INSERT INTO obj_${t.object} (${i.join(`, `)}) VALUES (${n.map(()=>`?`).join(`, `)});`;e.exec(a,...n)}})};var p=class extends i{#e;constructor(e){super(),this.#e=e}get items(){return this.#e.items.get()}query(e={}){return this.#e.query(e).get()}first(e={}){return this.#e.first(e).get()}all(){return this.query()}add(e){this.#e.add(e)}};const m=e=>{let t=Object.entries(e).reduce((e,[t,n])=>{let r=t;return e[r]=new p(n),e},{});return console.log(`remoteCollections:`,t),t};var h=class extends i{#e;#t;#n;messageQueue=new l;#r;#i;constructor({schema:e,db:t}){super(),this.#e=e,t?(this.#n=t,this.#t=this.#n.clientId,this.messageQueue.subscribe({subscriber:f(this.#n),label:`Local database (Client ID: ${this.#t})`})):this.#t=crypto.randomUUID(),this.#r=d({schema:this.#e,clientId:this.#t,messageQueue:this.messageQueue,db:this.#n}),this.#i=m(this.#r)}get _collections(){return this.#r}get _remoteCollections(){return this.#i}get schema(){return this.#e}get clientId(){return this.#t}ingest(e){console.log(`📳📳📳`,`Ingest`,e),this.messageQueue.add(e)}async[Symbol.dispose](){console.log(`🗑️🗑️🗑️`,`Data RPC disposing (Client ID: ${this.clientId})`)}},g=class e extends h{#e;#t;constructor({schema:e,db:t,remote:n}){if(super({schema:e,db:t}),this.#e=n,this.#e){this.#e.connect({clientId:this.clientId,ingest:this.ingest.bind(this)}).then(e=>{console.log(`📳📳📳`,`Remote is connected`,e),this.#t=e}).catch(e=>{console.error(`Remote connect failed:`,e)});let e=this.messageQueue.subscribe({subscriber:async e=>{await this.#e?.ingest(e),console.log(`Send to remote`,e)},filter:e=>e.client===this.clientId,label:`Remote`});this.#e.onRpcBroken(()=>{console.log(`Remote connection broken, unsubscribing ...`),e()})}}static async client({schema:t,remote:n}){return typeof n==`function`&&(n=await n()),new e({schema:t,db:!1,remote:n})}static signal({schema:e,remote:t}){return n(()=>this.client({schema:e,remote:t}))}get collections(){return this._collections}async load(){console.log(`Loading data ...`,this.#e);let e=await this.#e?.load();console.log(`Loaded data:`,e)}async[Symbol.dispose](){console.log(`🗑️ Client Data RPC disposing (CID: ${this.clientId})`),this.#t&&await this.#t()}};const _=e=>{let t={exec:(t,...n)=>e.sql.exec(t,...n),query:(t,...n)=>e.sql.exec(t,...n).toArray(),transaction:n=>e.transactionSync(()=>n(t))};return t};var v=class e extends h{constructor({schema:e,db:t}){super({schema:e,db:t})}static durableObject({schema:t,storage:n}){let r=_(n);return s({db:r,schema:t}),new e({schema:t,db:r})}get collections(){return this._remoteCollections}async load(){return`Test loaded data`}async connect({clientId:e,ingest:t}){console.log(`📳📳📳`,`connect from`,e,t),t.onRpcBroken(()=>{console.log(`📳📳📳`,e,`Ingest RPC broken`)});let n=t.dup();return console.log(`Subscribing client`,e),this.messageQueue.subscribe({subscriber:async e=>await n({...e,id:`${e.id}-CONNECT-${crypto.randomUUID()}`}),filter:t=>t.client!==e,label:`Client: ${e}`})}};function y(e,t,n){return e.type===`string`?typeof t==`string`?{value:t}:{issues:[{message:`Expected string for ${n}, got ${typeof t}`}]}:e.type===`number`?typeof t==`number`?{value:t}:{issues:[{message:`Expected number for ${n}, got ${typeof t}`}]}:e.type===`boolean`?typeof t==`boolean`?{value:t}:{issues:[{message:`Expected boolean for ${n}, got ${typeof t}`}]}:{issues:[{message:`Unknown property type for ${n}`}]}}function b(e,t){return n=>{if(typeof n!=`object`||!n||Array.isArray(n))return{issues:[{message:`Expected object for ${e}, got ${typeof n}`}]};let r=n,i=[];for(let[e,n]of Object.entries(t)){if(n.required&&!(e in r)){i.push({message:`Missing required field: ${e}`,path:[e]});continue}if(e in r){let t=y(n,r[e],e);if(t.issues)for(let n of t.issues)i.push({...n,path:[e,...n.path||[]]})}}return i.length>0?{issues:i}:{value:r}}}function x(e,t){return y(e,t,`property`)}function S(e){let t={};return t.type=e.type,t}function C(e){let t=t=>{if(t.target!==`draft-2020-12`&&t.target!==`draft-07`)throw Error(`Unsupported JSON Schema target: ${t.target}. Supported targets: draft-2020-12, draft-07`);let n={},r=[];for(let[t,i]of Object.entries(e))n[t]=S(i),i.required===!0&&r.push(t);let i={$schema:t.target===`draft-2020-12`?`https://json-schema.org/draft/2020-12/schema`:`http://json-schema.org/draft-07/schema#`,type:`object`,properties:n,additionalProperties:!1};return r.length>0&&(i.required=r),i};return{input:t,output:t}}const w=e=>{let t={};for(let[n,r]of Object.entries(e))t[n]={...r,"~standard":{version:1,vendor:`renku`,validate:b(n,r),jsonSchema:C(r),types:{input:void 0,output:void 0}}};return t},T={type:`string`,required:!0,unique:!0,mock:()=>crypto.randomUUID().toString()};export{g as ClientData,v as ServerData,T as id,w as schema,x as validatePropertyValue};
|
package/dist/dom.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import "./types-
|
|
2
|
-
import {
|
|
3
|
-
import { r as Routes } from "./types-BPhJNjPW.js";
|
|
1
|
+
import { o as RenkuNode, r as FunctionComponent } from "./types-B4Ij4y1d.js";
|
|
2
|
+
import { r as Routes } from "./types-BSW-pDJE.js";
|
|
4
3
|
|
|
5
|
-
//#region src/router/
|
|
4
|
+
//#region src/router/router.d.ts
|
|
6
5
|
declare const Router: FunctionComponent<{
|
|
7
6
|
routes: Routes<any>;
|
|
8
7
|
}>;
|
package/dist/dom.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./virtual-from-jsx-
|
|
1
|
+
import{t as e}from"./virtual-from-jsx-kd8FG7Em.js";import"./signal-store-0zk-69gB.js";import"./effect-Bd9_A9t9.js";import{n as t,r as n}from"./update-dom-node-C7Nskg5l.js";import{t as r}from"./get-route-DL8B9jay.js";import{n as i}from"./jsx-runtime-BhjWaNaK.js";const a=async({routes:e})=>{let t=r({request:new Request(window.location.href),routes:e}),n=null;if(!t||t.api)return i(`div`,{children:`Not Found`});if(t.route instanceof Promise)n=await(await t.route).default(t.params);else if(typeof t.route==`function`)n=t.route(t.params);else return i(`div`,{children:`Not Found`});for(let e of t.layouts)e instanceof Promise?n=await(await e).default({children:n}):typeof e==`function`&&(n=await e({children:n}));return n},o=(r,i)=>{let a=e({node:r});i.replaceChildren(),Array.isArray(a)?n({domNode:i,virtualNode:a}):t({domNode:i,virtualNode:a})};export{a as Router,o as render};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as Routes } from "./types-
|
|
1
|
+
import { r as Routes } from "./types-BSW-pDJE.js";
|
|
2
2
|
|
|
3
3
|
//#region src/cloudflare/durable-object-handler.d.ts
|
|
4
4
|
declare const durableObjectHandler: ({
|
|
@@ -13,7 +13,6 @@ declare const durableObjectHandler: ({
|
|
|
13
13
|
//#endregion
|
|
14
14
|
//#region src/cloudflare/get-auth-routes.d.ts
|
|
15
15
|
interface AuthOptions {
|
|
16
|
-
rpId: string;
|
|
17
16
|
rpName: string;
|
|
18
17
|
sessionExpiryInMinutes?: number;
|
|
19
18
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import "./types-
|
|
2
|
-
import {
|
|
3
|
-
import { r as
|
|
4
|
-
import { t as
|
|
5
|
-
import { t as Loader } from "./types-DwyPVMcM.js";
|
|
6
|
-
import { t as registerServerFunction } from "./register-server-function-BuqMxh0V.js";
|
|
7
|
-
import { RpcStub, RpcTarget } from "capnweb";
|
|
1
|
+
import { a as LayoutComponent, r as FunctionComponent } from "./types-B4Ij4y1d.js";
|
|
2
|
+
import { r as Routes } from "./types-BSW-pDJE.js";
|
|
3
|
+
import { a as RpcTarget, i as RpcStub, n as Loader, o as Signal, r as RpcCompatible, t as Context } from "./types-BEYIs1ZF.js";
|
|
4
|
+
import { t as registerServerFunction } from "./register-server-function-CqA4nPaJ.js";
|
|
8
5
|
|
|
9
6
|
//#region src/reactivity/create-computed.d.ts
|
|
10
7
|
declare const createComputed: <T>(fn: () => T) => Signal.Computed<T>;
|
|
@@ -12,14 +9,29 @@ declare const createComputed: <T>(fn: () => T) => Signal.Computed<T>;
|
|
|
12
9
|
//#region src/reactivity/create-fetched.d.ts
|
|
13
10
|
declare const createFetched: <T>(path: string, fn: (res: Response) => Promise<T> | T) => Signal.State<Loader<T>>;
|
|
14
11
|
//#endregion
|
|
12
|
+
//#region src/reactivity/remote-signal.d.ts
|
|
13
|
+
declare class RemoteSignal<T extends RpcCompatible<T>> extends RpcTarget {
|
|
14
|
+
#private;
|
|
15
|
+
constructor(initialValues: T, onUpdate?: (val: T) => T);
|
|
16
|
+
get(): T;
|
|
17
|
+
set(value: T): Promise<void>;
|
|
18
|
+
subscribe(callback: RpcStub<(value: T) => void>): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/reactivity/create-remote-signal.d.ts
|
|
22
|
+
declare const createRemoteSignal: <T extends string | number>(fn: () => Promise<RpcStub<RemoteSignal<T>>>, updateRemote?: boolean) => Signal.State<Loader<Signal.State<T>>>;
|
|
23
|
+
//#endregion
|
|
15
24
|
//#region src/reactivity/create-loader.d.ts
|
|
16
25
|
declare function createLoader<P>(promise: () => Promise<P>): Signal.State<Loader<P>>;
|
|
17
26
|
declare function createLoader<P, R, T extends (res: P) => R | Promise<R>>(promise: () => Promise<P>, transform: T): Signal.State<Loader<R>>;
|
|
18
27
|
//#endregion
|
|
28
|
+
//#region src/reactivity/create-context.d.ts
|
|
29
|
+
declare const createContext: <T>(defaultValue?: T) => Context<T>;
|
|
30
|
+
//#endregion
|
|
19
31
|
//#region src/reactivity/create-signal.d.ts
|
|
20
32
|
declare const createSignal: <T>(initialValue: T) => Signal.State<T>;
|
|
21
33
|
//#endregion
|
|
22
34
|
//#region src/reactivity/effect.d.ts
|
|
23
35
|
declare const effect: (callback: (() => () => void) | (() => void)) => (() => void);
|
|
24
36
|
//#endregion
|
|
25
|
-
export { type FunctionComponent, type LayoutComponent, type Routes, RpcStub, RpcTarget, Signal, createComputed, createFetched, createLoader, createSignal, effect, registerServerFunction };
|
|
37
|
+
export { type FunctionComponent, type LayoutComponent, RemoteSignal, type Routes, type RpcCompatible, RpcStub, RpcTarget, Signal, createComputed, createContext, createFetched, createLoader, createRemoteSignal, createSignal, effect, registerServerFunction };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./signal-store-0zk-69gB.js";import{t}from"./effect-
|
|
1
|
+
import{n as e}from"./signal-store-0zk-69gB.js";import{t}from"./effect-Bd9_A9t9.js";import{n,t as r}from"./create-computed-CgSmvZ_e.js";import{t as i}from"./create-loader-Bnk94Dhg.js";import{t as a}from"./create-context-OCBKqRIM.js";import{t as o}from"./register-server-function-Dsv6VBSj.js";import{RpcStub as s,RpcTarget as c}from"capnweb";const l=(e,t)=>i(()=>fetch(e).then(async e=>await t(e))),u=(e,r=!0)=>i(async()=>{let i=await e(),a=n(await i.get());return i.subscribe(e=>a.set(e)),t(()=>{r&&i.set(a.get())}),a});var d=class extends c{#e;#t=new Set;#n;constructor(e,t){super(),this.#e=e,this.#n=t}get(){return this.#e}async set(e){this.#n&&(e=this.#n(e)),this.#e=e;for(let t of this.#t)try{await t(e)}catch(e){console.error(`Error in subscriber:`,e),this.#t.delete(t)}}subscribe(e){return this.#t.add(e.dup()),new Promise((t,n)=>{e.onRpcBroken(t=>{this.#t.delete(e),n(t)})})}};export{d as RemoteSignal,s as RpcStub,c as RpcTarget,e as Signal,r as createComputed,a as createContext,l as createFetched,i as createLoader,u as createRemoteSignal,n as createSignal,t as effect,o as registerServerFunction};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { i as JSX } from "./types-
|
|
2
|
-
import { t as Fragment } from "./fragment-
|
|
1
|
+
import { i as JSX } from "./types-B4Ij4y1d.js";
|
|
2
|
+
import { t as Fragment } from "./fragment-Bly9noQG.js";
|
|
3
3
|
|
|
4
4
|
//#region src/jsx/jsx-dev.d.ts
|
|
5
5
|
declare const jsxDEV: (type: JSX.ElementType, props: any, key: string | null | undefined, _isStaticChildren: boolean, _source: {
|
|
6
6
|
fileName: string;
|
|
7
7
|
lineNumber: number;
|
|
8
8
|
columnNumber: number;
|
|
9
|
-
}, _self: unknown
|
|
9
|
+
}, _self: unknown) => JSX.Element;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { Fragment, type JSX, jsxDEV };
|
package/dist/jsx-dev-runtime.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./fragment-
|
|
1
|
+
import{t as e}from"./fragment-uL1agXkn.js";const t=(e,t,n,r,i,a)=>({type:e,props:t,key:n});export{e as Fragment,t as jsxDEV};
|
package/dist/jsx-runtime.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as JSX } from "./types-
|
|
2
|
-
import { t as Fragment } from "./fragment-
|
|
1
|
+
import { i as JSX } from "./types-B4Ij4y1d.js";
|
|
2
|
+
import { t as Fragment } from "./fragment-Bly9noQG.js";
|
|
3
3
|
|
|
4
4
|
//#region src/jsx/jsx.d.ts
|
|
5
5
|
declare const jsx: (type: JSX.ElementType, props: any, key: string | null | undefined) => JSX.Element;
|
package/dist/jsx-runtime.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./fragment-
|
|
1
|
+
import{t as e}from"./fragment-uL1agXkn.js";import{n as t,t as n}from"./jsx-runtime-BhjWaNaK.js";export{e as Fragment,t as jsx,n as jsxs};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{newHttpBatchRpcSession as e,newWebSocketRpcSession as t}from"capnweb";const n=(n,r)=>{console.log(`☎️`,`Registering server function:`,n,r);let i=`/@renku/rpc/${encodeURIComponent(n)}/${encodeURIComponent(r)}`;return(...a)=>{let o=r.startsWith(`ws_`)?t(i):e(i);return console.log(`☎️`,`Calling server function:`,n,r,a),o(...a)}};export{n as t};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{t as e}from"./virtual-from-jsx-
|
|
2
|
-
`,`<template data-id="async-template-${e.index}">`],yield*o({virtualNode:e.virtualNode,asyncVirtualNodes:t,leadingComma:!1,rscBuffer:n}),yield[null,`</template>`],yield[null,`<script>(self.__RSC||=[]).push(
|
|
1
|
+
import{t as e}from"./virtual-from-jsx-kd8FG7Em.js";import{n as t}from"./signal-store-0zk-69gB.js";async function*n(e){yield`<!DOCTYPE html>`;for await(let t of e)t[1]&&(yield t[1])}async function*r(t){let n=new Set(t.map(t=>t.then(({index:t,node:n})=>({index:t,virtualNode:e({node:n,asyncComponents:[]})})).catch(e=>({error:e}))));for(;n.size>0;){let e=await Promise.race(n);for(let t of n)t.then(r=>{r===e&&n.delete(t)}).catch(r=>{r===e&&n.delete(t)});`virtualNode`in e&&(yield e)}}async function*i({key:e,val:n,trailingComma:r,output:i}){if(typeof n==`string`||typeof n==`number`){e===`className`&&(e=`class`);let t=typeof n==`number`?String(n):`"${String(n)}"`;return yield i(`${r?`,`:``}"${e}":${t}`,` ${e}="${String(n)}"`),!0}if(n instanceof t.State||n instanceof t.Computed)return yield i(`${r?`,`:``}"${e}":"${String(n.get())}"`,` ${e}="${String(n.get())}"`),!0;if(Array.isArray(n)){let a=n.map(e=>e instanceof t.State||e instanceof t.Computed?String(e.get()):String(e)).join(` `);return yield i(`${r?`,`:``}"${e}":"${a}"`,` ${e}="${a}"`),!0}}const a=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`source`,`track`,`wbr`]);async function*o({virtualNode:e,asyncVirtualNodes:t,leadingComma:n=!1,rscBuffer:r=[]}){let s=(e,t)=>(e&&r.push(e),[e,t]),c=(e,t)=>s(e,null);if(Array.isArray(e))for(let i of e)yield*o({virtualNode:i,asyncVirtualNodes:t,leadingComma:n,rscBuffer:r}),n=!0;else if(e?.type===`element`){yield s(`${n?`,`:``}["E","${e.value}",${e.key?`"${e.key}"`:`null`},{`,`<${e.value}`);let c=!0;for(let[t,n]of Object.entries(e.props))t!==`children`&&(yield*i({key:t,val:n,trailingComma:!c,output:s}))&&(c=!1);if(yield s(null,a.has(e.value)?` />`:`>`),e.children.length>0){let n=!0;yield s(`${c?``:`,`}"children":[`,null);for(let i of e.children)(yield*o({virtualNode:i,asyncVirtualNodes:t,leadingComma:!n,rscBuffer:r}))&&(n=!1);e.value!==`html`&&(yield s(`]`,null))}if(e.value===`body`){if(r.length>0){let e=r.join(``);r.length=0,yield[null,`<script>(self.__RSC||=[]).push(\`${e}}]]}]\`);<\/script>`]}yield[`}]]}]`,null];for await(let e of t){let n=[];yield[`
|
|
2
|
+
`,`<template data-id="async-template-${e.index}">`],yield*o({virtualNode:e.virtualNode,asyncVirtualNodes:t,leadingComma:!1,rscBuffer:n}),yield[null,`</template>`],yield[null,`<script>(self.__RSC||=[]).push(\`${n.join(``)}\`);<\/script>`],yield[null,`<script>
|
|
3
3
|
(() => {
|
|
4
4
|
const placeholder = document.querySelector(\`${`template[data-id="async-placeholder-${e.index}"]`}\`);
|
|
5
5
|
// console.log("placeholder",placeholder);
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as ClientComponent } from "./types-
|
|
2
|
-
import { t as registerServerFunction } from "./register-server-function-
|
|
1
|
+
import { t as ClientComponent } from "./types-B4Ij4y1d.js";
|
|
2
|
+
import { t as registerServerFunction } from "./register-server-function-CqA4nPaJ.js";
|
|
3
3
|
|
|
4
4
|
//#region src/server/register-client-reference.d.ts
|
|
5
5
|
declare const registerClientReference: (_fn: () => void, path: string, name: string) => ClientComponent;
|
package/dist/server.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./register-server-function-
|
|
1
|
+
import{t as e}from"./register-server-function-Dsv6VBSj.js";const t=(e,t,n)=>({type:`client`,path:t,name:n});export{t as registerClientReference,e as registerServerFunction};
|