renku 0.0.6 → 0.0.8
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/dist/auth-D5pK_Zr4.js +1 -0
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +1 -1
- package/dist/bash-complete.js +1 -1
- package/dist/bun.d.ts +7 -22
- package/dist/bun.js +1 -1
- package/dist/cli.js +1 -1
- package/dist/client.js +1 -1
- package/dist/cloudflare-Cm-b9zU8.js +2 -0
- package/dist/cloudflare.d.ts +4 -2
- package/dist/cloudflare.js +1 -1
- package/dist/cloudflare.worker.d.ts +4 -2
- package/dist/cloudflare.worker.js +1 -1
- package/dist/context-C83FYHsZ.js +1 -0
- package/dist/create-computed-vBhisFEL.js +1 -0
- package/dist/{create-context-OCBKqRIM.js → create-context-DWsglCRN.js} +1 -1
- package/dist/create-element-DdyoBVZS.js +1 -0
- package/dist/{create-loader-Bnk94Dhg.js → create-loader-hQHegC7I.js} +1 -1
- package/dist/data.d.ts +31 -59
- package/dist/data.js +1 -1
- package/dist/dom.d.ts +7 -3
- package/dist/dom.js +1 -1
- package/dist/{effect-Bd9_A9t9.js → effect-D3CPC1qb.js} +1 -1
- package/dist/fragment-DkBz18dw.js +1 -0
- package/dist/get-route-D_cS5xy0.js +1 -0
- package/dist/{index-iMWKMtYV.d.ts → index-hZABUZHC.d.ts} +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.js +1 -1
- package/dist/jsx-dev-runtime.d.ts +4 -4
- package/dist/jsx-dev-runtime.js +1 -1
- package/dist/jsx-runtime-BJQV0ZvP.js +0 -0
- package/dist/jsx-runtime.d.ts +5 -8
- package/dist/jsx-runtime.js +1 -1
- package/dist/jsx-to-virtual-node-btYsRR_g.js +1 -0
- package/dist/otel.d.ts +7 -0
- package/dist/otel.js +1 -0
- package/dist/register-server-function-Cz5-Gudu.js +1 -0
- package/dist/{register-server-function-CqA4nPaJ.d.ts → register-server-function-s7OWEfvO.d.ts} +1 -1
- package/dist/render-5yoUj7dq.js +14 -0
- package/dist/render-dom-node-DSu3cWuF.js +1 -0
- package/dist/server.d.ts +3 -2
- package/dist/server.js +1 -1
- package/dist/signal-DXdSsSmq.d.ts +2 -0
- package/dist/types-CvU3wYQp.d.ts +68 -0
- package/dist/{types-BSW-pDJE.d.ts → types-DZ5UlJbq.d.ts} +10 -9
- package/dist/{types-BEYIs1ZF.d.ts → types-De3Of0g0.d.ts} +1 -2
- package/dist/ui.d.ts +2 -1
- package/dist/ui.js +1 -1
- package/dist/vite.js +5 -5
- package/package.json +43 -16
- package/dist/auth-DivcgvqR.js +0 -1
- package/dist/cloudflare-BVLzalPQ.js +0 -2
- package/dist/context-BZxerv82.js +0 -23
- package/dist/create-computed-CgSmvZ_e.js +0 -1
- package/dist/fragment-Bly9noQG.d.ts +0 -6
- package/dist/fragment-uL1agXkn.js +0 -1
- package/dist/get-route-DL8B9jay.js +0 -1
- package/dist/impl-CQ7GTRH2-Db6HOvCd.js +0 -5
- package/dist/jsx-runtime-BhjWaNaK.js +0 -1
- package/dist/register-server-function-Dsv6VBSj.js +0 -1
- package/dist/rsc-from-markup-ditxg5su.js +0 -14
- package/dist/types-B4Ij4y1d.d.ts +0 -38
- package/dist/update-dom-node-C7Nskg5l.js +0 -1
- package/dist/virtual-from-jsx-kd8FG7Em.js +0 -1
- /package/dist/{context-store-BpRmbHKI.js → context-store-D1Klyb_v.js} +0 -0
- /package/dist/{impl-D9kbwKWf.js → impl-BXN4tTw0.js} +0 -0
- /package/dist/{impl-qmFhldR7.js → impl-BwIgYpzT.js} +0 -0
- /package/dist/{impl-6Uc2Rt9O.js → impl-DRBGEVSP.js} +0 -0
- /package/dist/{signal-store-0zk-69gB.js → signal-store-B0WygwF_.js} +0 -0
- /package/dist/{types-BcEav58N.d.ts → types-Cd8M_aYq.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{AsyncLocalStorage as e}from"node:async_hooks";const t=new e,n=()=>({sessionId:null,userId:null}),r=e=>t.run(n(),e),i=()=>{let e=t.getStore();if(e)return e;let r=n();return t.enterWith(r),r};export{r as n,i as t};
|
package/dist/auth.d.ts
CHANGED
package/dist/auth.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./auth-
|
|
1
|
+
import{t as e}from"./auth-D5pK_Zr4.js";export{e as auth};
|
package/dist/bash-complete.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import{
|
|
2
|
+
import{n as e,t}from"./context-C83FYHsZ.js";import{proposeCompletions as n}from"@stricli/core";const r=process.argv.slice(3);process.env.COMP_LINE?.endsWith(` `)&&r.push(``),await n(e,r,t(process));try{for(let{completion:i}of await n(e,r,t(process)))process.stdout.write(`${i}\n`)}catch{}
|
package/dist/bun.d.ts
CHANGED
|
@@ -1,31 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { RouteMetadata } from "bun:app";
|
|
3
|
-
import { BunPlugin, Serve } from "bun";
|
|
1
|
+
import { Bake, BunPlugin } from "bun";
|
|
4
2
|
|
|
5
3
|
//#region src/bun/render.d.ts
|
|
6
|
-
declare const render: (request: Request, routeMetadata: RouteMetadata) => Promise<Response>;
|
|
4
|
+
declare const render: (request: Request, routeMetadata: Bake.RouteMetadata) => Promise<Response>;
|
|
7
5
|
//#endregion
|
|
8
6
|
//#region src/bun/types.d.ts
|
|
9
|
-
type
|
|
10
|
-
|
|
7
|
+
type RenkuBunBake = (props: {
|
|
8
|
+
plugins?: BunPlugin[];
|
|
9
|
+
}) => {
|
|
10
|
+
app: Bake.Options;
|
|
11
11
|
};
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/bun/renku.d.ts
|
|
14
|
-
|
|
15
|
-
* @todo fix types
|
|
16
|
-
*/
|
|
17
|
-
declare const renku: <T, R extends { [K in keyof R]: Route<PathToParams<K & string>> }>({
|
|
18
|
-
routes,
|
|
19
|
-
bake,
|
|
20
|
-
plugins
|
|
21
|
-
}: {
|
|
22
|
-
routes: R;
|
|
23
|
-
bake?: never;
|
|
24
|
-
plugins?: BunPlugin[];
|
|
25
|
-
} | {
|
|
26
|
-
routes?: never;
|
|
27
|
-
bake: true;
|
|
28
|
-
plugins?: BunPlugin[];
|
|
29
|
-
}) => Serve.Options<T, any>;
|
|
14
|
+
declare const renku: RenkuBunBake;
|
|
30
15
|
//#endregion
|
|
31
16
|
export { render, renku };
|
package/dist/bun.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,r as t,t as n}from"./
|
|
1
|
+
import{n as e,r as t,t as n}from"./render-5yoUj7dq.js";import"./signal-store-B0WygwF_.js";import"./jsx-to-virtual-node-btYsRR_g.js";import"./effect-D3CPC1qb.js";import"./fragment-DkBz18dw.js";const r=async(r,i)=>{let{styles:a,modules:o,pageModule:s,layouts:c}=i,l=await s.default();for(let e of c)l=await e.default({children:[l],_renku:{styles:a,modules:o}});let u=n(l);if(r.headers.get(`Accept`)===`text/x-component`){let t=e(u);return new Response(t,{headers:{"Content-Type":`text/x-component`}})}let d=t(u);return new Response(d,{headers:{"Content-Type":`text/html`}})},i=({plugins:e})=>({app:{framework:{fileSystemRouterTypes:[{root:`./pages`,serverEntryPoint:`renku/bun`,clientEntryPoint:`renku/client`,style:`nextjs-pages`,layouts:!0,extensions:[`ts`,`tsx`,`md`,`mdx`]}],serverComponents:{separateSSRGraph:!1,serverRuntimeImportSource:`renku/server`},plugins:e}}});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,
|
|
2
|
+
import{n as e,t}from"./context-C83FYHsZ.js";import{run as n}from"@stricli/core";await n(e,process.argv.slice(2),t(process));
|
package/dist/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./virtual-
|
|
1
|
+
import"./signal-store-B0WygwF_.js";import{n as e}from"./jsx-to-virtual-node-btYsRR_g.js";import"./effect-D3CPC1qb.js";import"./fragment-DkBz18dw.js";import{n as t,r as n,t as r}from"./render-dom-node-DSu3cWuF.js";const i=e=>Array.isArray(e)&&e[0]===`E`,a=e=>Array.isArray(e)&&e[0]===`A`,o=e=>Array.isArray(e)&&e[0]===`C`,s=e=>{if(i(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 a(e)?{type:`async`,key:e[1],index:e[2]}:o(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=(t,i)=>{if(i?.type===`element`&&i.value.toLowerCase()===t.tagName.toLowerCase()){i.domNode=t;for(let[a,o]of i.children.entries()){let s=t.childNodes[a];if(s)if(o?.type===`element`)s instanceof HTMLElement&&c(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(t=>{let i=e({fn:t[o.name],key:o.key,props:o.props,asyncComponents:[],clientComponents:[]});Array.isArray(i)?n({domNode:s,virtualNode:i,replace:!0}):r({domNode:s,virtualNode:i,replace:!0})}))}}},l={virtualNode:void 0},u=e=>{try{let t=JSON.parse(e);if(i(t)){let e=s(t);c(document.documentElement,e),l.virtualNode=e}else console.warn(`Unhandled: Not RSC Element`)}catch(e){console.error(`Failed to parse RSC chunk:`,e)}},d=async e=>{let n=await fetch(e.pathname,{headers:{Accept:`text/x-component`}});if(n.body&&l.virtualNode){let e=s(await n.json());t({domNode:document.documentElement,oldVirtualNode:l.virtualNode,newVirtualNode:e}),l.virtualNode=e;return}console.error(`No body`)},f=e=>!e.canIntercept||e.hashChange||!!e.downloadRequest||!!e.formData||e.destination.sameDocument;window.navigation.addEventListener(`navigate`,e=>{if(f(e))return;let t=new URL(e.destination.url);e.intercept({async handler(){await d(t)}})}),window.__RSC||=[];for(let e of window.__RSC)u(e);window.__RSC.push=e=>(console.log(`streamed rsc line`,e),window.__RSC.length);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{n as e,t}from"./auth-D5pK_Zr4.js";import{n,r,t as i}from"./render-5yoUj7dq.js";import{n as a,t as o}from"./get-route-D_cS5xy0.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:n})=>{n??=60;let r=e=>e*60*1e3;return{"/validate-session":{GET:async(e,n,r)=>t().sessionId?Response.json({isAuthenticated:!0}):Response.json({isAuthenticated:!1})},"/logout":{POST:async(e,n,i)=>{let a=t();a.sessionId&&await n.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,n,i)=>{let a=t();a.sessionId&&await n.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,t,i)=>{let{id:a,credential:o}=await e.json(),s=await t.AUTH_DO.getByName(`challenge:${a}`).validateRequest({credential:o,sessionExpiryInMinutes:n});if(s){let e=new Date(Date.now()+r(n)).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:e,env:n,authFn:r})=>{let i=t(),a=d(e.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:e,authContext:i}):!0},p=e=>{let t=new TextEncoder,n=e[Symbol.asyncIterator]();return new ReadableStream({async pull(e){let{value:r,done:i}=await n.next();if(i)e.close();else{let n=typeof r==`object`?JSON.stringify(r).concat(`
|
|
2
|
+
`):r;e.enqueue(t.encode(n))}}})},m=[`favicon.ico`,`.well-known`],h=({routes:t})=>async(l,u,d)=>e(async()=>{let e=new URL(l.url).pathname.split(`/`),h=e[1];if(h&&m.includes(h))return new Response(null,{status:404});let g=o({request:l,routes:t});console.log(`routingResult`,g);let _=await f({request:l,env:u,authFn:g?g.auth:null});if(_!==!0)return _||new Response(null,{status:401});if(h===`@renku`){if(e[2]===`rpc`&&e[3]&&e[4]){let t=decodeURIComponent(e[3]),n=decodeURIComponent(e[4]);import.meta.env.DEV||(t=`/assets/functions/${t}.js`),console.log(`☎️ Server function was called:`,t,n);let r=(await import(t))[n];return s(l,r)}return new Response(null,{status:404})}if(!g)return console.warn(`No routing result`),new Response(null,{status:404});if(g.api){let e=Object.assign(l,{params:g.params});return g.api(e,u,d)}let v=await a(g.route,g.params);if(v==null)return new Response(null,{status:404});let y={styles:[],modules:[]};import.meta.env.DEV?(y.modules.push(`/@vite/client`),y.modules.push(`/@renku/client`)):c&&y.modules.push(c);for(let e of g.layouts){let t=await a(e,{children:v,_renku:y});if(t==null)return new Response(null,{status:404});v=t}let b=i(v);if(l.headers.get(`Accept`)===`text/x-component`){let e=p(n(b));return new Response(e,{headers:{"Content-Type":`text/x-component`}})}let x=p(r(b));return new Response(x,{headers:{"Content-Type":`text/html`}})}),g=({routes:e})=>({fetch:h({routes:e})});export{u as n,l as r,g as t};
|
package/dist/cloudflare.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import "./signal-DXdSsSmq.js";
|
|
2
|
+
import "./types-CvU3wYQp.js";
|
|
3
|
+
import { t as Routes } from "./types-DZ5UlJbq.js";
|
|
4
|
+
import { n as getAuthRoutes, r as durableObjectHandler, t as renku } from "./index-hZABUZHC.js";
|
|
3
5
|
export { Routes, durableObjectHandler, getAuthRoutes, renku };
|
package/dist/cloudflare.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./auth-
|
|
1
|
+
import"./auth-D5pK_Zr4.js";import"./render-5yoUj7dq.js";import"./signal-store-B0WygwF_.js";import"./jsx-to-virtual-node-btYsRR_g.js";import"./effect-D3CPC1qb.js";import"./fragment-DkBz18dw.js";import{n as e,r as t,t as n}from"./cloudflare-Cm-b9zU8.js";export{t as durableObjectHandler,e as getAuthRoutes,n as renku};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import "./signal-DXdSsSmq.js";
|
|
2
|
+
import "./types-CvU3wYQp.js";
|
|
3
|
+
import { t as Routes } from "./types-DZ5UlJbq.js";
|
|
4
|
+
import { n as getAuthRoutes, r as durableObjectHandler, t as renku } from "./index-hZABUZHC.js";
|
|
3
5
|
import { DurableObject } from "cloudflare:workers";
|
|
4
6
|
|
|
5
7
|
//#region src/cloudflare/durable-objects/auth.d.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./auth-
|
|
1
|
+
import"./auth-D5pK_Zr4.js";import"./render-5yoUj7dq.js";import"./signal-store-B0WygwF_.js";import"./jsx-to-virtual-node-btYsRR_g.js";import"./effect-D3CPC1qb.js";import"./fragment-DkBz18dw.js";import{n as e,r as t,t as n}from"./cloudflare-Cm-b9zU8.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{buildApplication as e,buildCommand as t,buildRouteMap as n}from"@stricli/core";import{buildInstallCommand as r,buildUninstallCommand as i}from"@stricli/auto-complete";import a from"node:fs";import o from"node:os";import s from"node:path";var c=`renku`,l=`0.0.8`,u=`Renku`;const d=n({routes:{ios:t({loader:async()=>{let{ios:e}=await import(`./impl-DRBGEVSP.js`);return e},parameters:{positional:{kind:`tuple`,parameters:[]},flags:{foo:{kind:`parsed`,optional:!0,parse:String,brief:`Foo`}}},docs:{brief:`Nested ios command`}}),android:t({loader:async()=>{let{android:e}=await import(`./impl-DRBGEVSP.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`}}),f=n({routes:{foo:t({loader:async()=>{let{foo:e}=await import(`./impl-BwIgYpzT.js`);return e},parameters:{positional:{kind:`tuple`,parameters:[]},flags:{foo:{kind:`parsed`,optional:!0,parse:String,brief:`Foo`}}},docs:{brief:`Nested foo command`}}),bar:t({loader:async()=>{let{bar:e}=await import(`./impl-BwIgYpzT.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`}}),p=e(n({routes:{subdir:t({loader:async()=>import(`./impl-BXN4tTw0.js`),parameters:{positional:{kind:`tuple`,parameters:[]},flags:{foo:{kind:`parsed`,optional:!0,parse:String,brief:`Foo`}}},docs:{brief:`Command in subdirectory`}}),nested:f,native:d,install:r(`my-app`,{bash:`__my-app_bash_complete`}),uninstall:i(`my-app`,{bash:!0})},docs:{brief:u,hideRoute:{install:!0,uninstall:!0}}}),{name:c,versionInfo:{currentVersion:l}});function m(e){return{process:e,os:o,fs:a,path:s}}export{p as n,m as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./signal-store-B0WygwF_.js";const n=e=>t.get(e),r=t=>new e.Computed(t);export{n,r as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./context-store-
|
|
1
|
+
import{t as e}from"./context-store-D1Klyb_v.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
|
+
const e=(e,t,n)=>({type:e,props:t,key:n??null});export{e as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./create-computed-
|
|
1
|
+
import{n as e}from"./create-computed-vBhisFEL.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,25 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as Signal } from "./signal-DXdSsSmq.js";
|
|
2
|
+
import { n as Loader } from "./types-De3Of0g0.js";
|
|
2
3
|
import { RpcStub, RpcTarget } from "capnweb";
|
|
3
4
|
import { StandardJSONSchemaV1, StandardSchemaV1 } from "@standard-schema/spec";
|
|
4
5
|
|
|
5
6
|
//#region src/data/schema/types.d.ts
|
|
6
|
-
|
|
7
|
+
type Schema = {
|
|
7
8
|
[key: string]: ObjectSchema;
|
|
8
|
-
}
|
|
9
|
-
|
|
9
|
+
};
|
|
10
|
+
type EnhancedSchema<T extends Schema> = { [K in keyof T]: EnhancedObjectSchema<T[K]> };
|
|
11
|
+
type ObjectSchema = {
|
|
10
12
|
id: IdSchema;
|
|
11
13
|
[key: string]: PropertySchema;
|
|
12
|
-
}
|
|
14
|
+
};
|
|
15
|
+
type EnhancedObjectSchema<T extends ObjectSchema> = { [K in keyof T]: T[K] & StandardSchemaV1 & StandardJSONSchemaV1 } & StandardSchemaV1 & StandardJSONSchemaV1;
|
|
13
16
|
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]> };
|
|
23
17
|
interface IdSchema extends PropertyBaseSchema {
|
|
24
18
|
type: "string";
|
|
25
19
|
required: true;
|
|
@@ -69,15 +63,6 @@ declare class MessageQueue {
|
|
|
69
63
|
add(message: SyncMessage): void;
|
|
70
64
|
}
|
|
71
65
|
//#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
|
|
81
66
|
//#region src/data/collection/collection.d.ts
|
|
82
67
|
declare class Collection<T extends Schema, K$1 extends keyof T> {
|
|
83
68
|
#private;
|
|
@@ -85,14 +70,12 @@ declare class Collection<T extends Schema, K$1 extends keyof T> {
|
|
|
85
70
|
name,
|
|
86
71
|
obj,
|
|
87
72
|
clientId,
|
|
88
|
-
messageQueue
|
|
89
|
-
db
|
|
73
|
+
messageQueue
|
|
90
74
|
}: {
|
|
91
75
|
name: string;
|
|
92
76
|
obj: T[K$1];
|
|
93
77
|
clientId: string;
|
|
94
78
|
messageQueue: MessageQueue;
|
|
95
|
-
db?: Database;
|
|
96
79
|
});
|
|
97
80
|
mock(): Item<T[K$1]>;
|
|
98
81
|
get items(): Signal.State<Item<T[K$1]>[]>;
|
|
@@ -104,6 +87,7 @@ declare class Collection<T extends Schema, K$1 extends keyof T> {
|
|
|
104
87
|
first(params?: Omit<QueryParams<T, K$1>, "single" | "limit">): Signal.Computed<Item<T[K$1]> | undefined>;
|
|
105
88
|
all(): Signal.Computed<Item<T[K$1]>[]>;
|
|
106
89
|
add(item: Item<T[K$1]>): Item<T[K$1]>;
|
|
90
|
+
loadItems(items: Item<T[K$1]>[]): void;
|
|
107
91
|
}
|
|
108
92
|
//#endregion
|
|
109
93
|
//#region src/data/collection/remote-collection.d.ts
|
|
@@ -139,6 +123,19 @@ type QueryParams<T extends Schema, K$1 extends keyof T> = {
|
|
|
139
123
|
limit?: number;
|
|
140
124
|
first?: boolean;
|
|
141
125
|
};
|
|
126
|
+
/**
|
|
127
|
+
* Type for initial data load - maps each collection name to an array of items.
|
|
128
|
+
*/
|
|
129
|
+
type LoadData<T extends Schema> = { [K in keyof T]: Item<T[K]>[] };
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region src/data/db/types.d.ts
|
|
132
|
+
type Binding = string | number;
|
|
133
|
+
interface Database {
|
|
134
|
+
exec: (sql: string, ...bind: Binding[]) => void;
|
|
135
|
+
query: <T = unknown>(sql: string, ...bindings: unknown[]) => T[];
|
|
136
|
+
transaction: (callback: (db: Database) => void) => void;
|
|
137
|
+
clientId: string;
|
|
138
|
+
}
|
|
142
139
|
//#endregion
|
|
143
140
|
//#region src/data/data/data.d.ts
|
|
144
141
|
declare class Data<T extends Schema> extends RpcTarget {
|
|
@@ -153,6 +150,8 @@ declare class Data<T extends Schema> extends RpcTarget {
|
|
|
153
150
|
});
|
|
154
151
|
protected get _collections(): Collections<T>;
|
|
155
152
|
protected get _remoteCollections(): RemoteCollections<T>;
|
|
153
|
+
protected get _db(): Database | undefined;
|
|
154
|
+
protected _rehydrateCollectionsFromDb(): void;
|
|
156
155
|
get schema(): T;
|
|
157
156
|
get clientId(): string;
|
|
158
157
|
ingest(message: SyncMessage): void;
|
|
@@ -176,7 +175,7 @@ declare class ServerData<T extends Schema> extends Data<T> {
|
|
|
176
175
|
storage: DurableObjectStorage;
|
|
177
176
|
}): ServerData<T>;
|
|
178
177
|
get collections(): RemoteCollections<T>;
|
|
179
|
-
load():
|
|
178
|
+
load(): LoadData<T>;
|
|
180
179
|
connect({
|
|
181
180
|
clientId,
|
|
182
181
|
ingest
|
|
@@ -218,37 +217,10 @@ declare class ClientData<T extends Schema> extends Data<T> {
|
|
|
218
217
|
}
|
|
219
218
|
//#endregion
|
|
220
219
|
//#region src/data/schema/schema.d.ts
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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>;
|
|
220
|
+
declare const schema$1: <const T extends Schema>(definition: T) => T;
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region src/data/schema/enhanced-schema.d.ts
|
|
223
|
+
declare const enhancedSchema: <T extends Schema>(definition: T) => EnhancedSchema<T>;
|
|
252
224
|
//#endregion
|
|
253
225
|
//#region src/data/schema/id.d.ts
|
|
254
226
|
declare const id: IdSchema;
|
|
@@ -264,4 +236,4 @@ declare const id: IdSchema;
|
|
|
264
236
|
*/
|
|
265
237
|
declare function validatePropertyValue(propertySchema: PropertySchema, value: unknown): StandardSchemaV1.Result<string | number | boolean>;
|
|
266
238
|
//#endregion
|
|
267
|
-
export { ClientData, type
|
|
239
|
+
export { ClientData, type IdSchema, type Item, type LoadData, type Schema, ServerData, enhancedSchema, id, schema$1 as schema, validatePropertyValue };
|
package/dist/data.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./signal-store-
|
|
1
|
+
import"./signal-store-B0WygwF_.js";import{n as e,t}from"./create-computed-vBhisFEL.js";import{t as n}from"./create-loader-hQHegC7I.js";import{RpcTarget as r}from"capnweb";const i=e=>{switch(e){case`string`:return`TEXT`;case`number`:return`INTEGER`;case`boolean`:return`INTEGER`;default:throw Error(`Unsupported type: ${String(e)}`)}},a=e=>{let t=``;for(let[n,r]of Object.entries(e).filter(([e])=>e!==`~standard`)){let e=Object.entries(r).filter(([e])=>e!==`~standard`).map(([e,t])=>`${e} ${i(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},o=({db:e,schema:t})=>{let n=a(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},s=({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 c=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)}},l=class{#e;#t;#n;#r=e([]);#i;constructor({name:e,obj:t,clientId:n,messageQueue:r}){this.#e=n,this.#t=e,this.#n=t,this.#i=r,this.#i.subscribe({subscriber:e=>this.#a(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),{})}#a(e){let t=this.#r.get(),n=t.findIndex(t=>t.id===e.item);if(e.updates===`DELETE`){if(n<0)return;let e=t.slice();e.splice(n,1),this.#r.set(e);return}let r=JSON.parse(e.updates),i={...n>=0?t[n]:void 0,...r,id:e.item};if(n>=0){let e=t.slice();e[n]=i,this.#r.set(e);return}this.#r.set(t.concat(i))}get items(){return 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=s({client:this.#e,object:this.#t,item:e});return this.#i.add(t),e}loadItems(e){this.#r.set(e)}};const u=({schema:e,clientId:t,messageQueue:n})=>Object.entries(e).reduce((e,[r,i])=>{let a=r;return e[a]=new l({name:r,obj:i,clientId:t,messageQueue:n}),e},{});var d=class extends r{#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 f=e=>{let t=Object.entries(e).reduce((e,[t,n])=>{let r=t;return e[r]=new d(n),e},{});return console.log(`remoteCollections:`,t),t},p=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 m=class extends r{#e;#t;#n;messageQueue=new c;#r;#i;#a=!1;constructor({schema:e,db:t}){super(),this.#e=e,t?(this.#n=t,this.#t=this.#n.clientId,this.messageQueue.subscribe({subscriber:p(this.#n),label:`Local database (Client ID: ${this.#t})`})):this.#t=crypto.randomUUID(),this.#r=u({schema:this.#e,clientId:this.#t,messageQueue:this.messageQueue}),this.#i=f(this.#r)}get _collections(){return this.#r}get _remoteCollections(){return this.#i}get _db(){return this.#n}_rehydrateCollectionsFromDb(){if(!(!this.#n||this.#a)){for(let e of Object.keys(this.#e)){let t=e,n=this.#n.query(`SELECT * FROM obj_${e}`)??[];this.#r[t].loadItems(n)}this.#a=!0}}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})`)}},h=class e extends m{#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=>(this.#t=e,this.load())).catch(e=>{console.error(`Remote connect or load 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(){if(!this.#e)return;let e=await this.#e.load();for(let t of Object.keys(e)){let n=t,r=e[n];this._collections[n].loadItems(r)}}async[Symbol.dispose](){console.log(`🗑️ Client Data RPC disposing (CID: ${this.clientId})`),this.#t&&await this.#t()}};const g=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 _=class e extends m{constructor({schema:e,db:t}){super({schema:e,db:t}),this._rehydrateCollectionsFromDb()}static durableObject({schema:t,storage:n}){let r=g(n);return o({db:r,schema:t}),new e({schema:t,db:r})}get collections(){return this._rehydrateCollectionsFromDb(),this._remoteCollections}load(){this._rehydrateCollectionsFromDb();let e={};for(let t of Object.keys(this.schema)){let n=t;e[n]=this._db?.query(`SELECT * FROM obj_${t}`)??[]}return e}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}`})}};const v=e=>e;function y(e){let t={};return t.type=e.type,t}function b(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]=y(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}}function x(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 S(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=x(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 C(e,t){return x(e,t,`property`)}const w=e=>{let t={};for(let[n,r]of Object.entries(e))t[n]={...r,"~standard":{version:1,vendor:`renku`,validate:S(n,r),jsonSchema:b(r),types:{input:void 0,output:void 0}}};return t},T={type:`string`,required:!0,unique:!0,mock:()=>crypto.randomUUID().toString()};export{h as ClientData,_ as ServerData,w as enhancedSchema,T as id,v as schema,C as validatePropertyValue};
|
package/dist/dom.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import "./signal-DXdSsSmq.js";
|
|
2
|
+
import { a as RenkuNode, n as FunctionComponent, s as SuspenseComponent } from "./types-CvU3wYQp.js";
|
|
3
|
+
import { t as Routes } from "./types-DZ5UlJbq.js";
|
|
3
4
|
|
|
4
5
|
//#region src/router/router.d.ts
|
|
5
6
|
declare const Router: FunctionComponent<{
|
|
@@ -9,4 +10,7 @@ declare const Router: FunctionComponent<{
|
|
|
9
10
|
//#region src/dom/render.d.ts
|
|
10
11
|
declare const render: (element: RenkuNode, domNode: HTMLElement) => void;
|
|
11
12
|
//#endregion
|
|
12
|
-
|
|
13
|
+
//#region src/shared/suspense/index.d.ts
|
|
14
|
+
declare const Suspense: SuspenseComponent;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { Router, type Routes, Suspense, render };
|
package/dist/dom.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import"./signal-store-B0WygwF_.js";import{r as e,t}from"./jsx-to-virtual-node-btYsRR_g.js";import"./effect-D3CPC1qb.js";import"./fragment-DkBz18dw.js";import{r as n,t as r}from"./render-dom-node-DSu3cWuF.js";import{n as i,t as a}from"./get-route-D_cS5xy0.js";import{t as o}from"./create-element-DdyoBVZS.js";import"./jsx-runtime-BJQV0ZvP.js";const s=async({routes:e})=>{let t=a({request:new Request(window.location.href),routes:e});if(!t||t.api)return o(`div`,{children:`Not Found`});let n=await i(t.route,t.params);if(n==null)return o(`div`,{children:`Not Found`});for(let e of t.layouts){let t=await i(e,{children:n});if(t==null)return o(`div`,{children:`Not Found`});n=t}return n},c=(e,i)=>{let a=t({node:e});i.replaceChildren(),Array.isArray(a)?n({domNode:i,virtualNode:a}):r({domNode:i,virtualNode:a})},l=Object.assign(({fallback:e,children:t})=>(console.log(`Suspense`,{fallback:e,children:t}),{fallback:e,children:t}),{[e]:!0});export{s as Router,l as Suspense,c as render};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./signal-store-
|
|
1
|
+
import{n as e}from"./signal-store-B0WygwF_.js";let t=!0;const n=new e.subtle.Watcher(()=>{t&&(t=!1,queueMicrotask(r))});function r(){t=!0;for(let e of n.getPending())e.get();n.watch()}const i=t=>{let r,i=new e.Computed(()=>{typeof r==`function`&&r();let e=t();r=typeof e==`function`?e:void 0});return n.watch(i),i.get(),()=>{n.unwatch(i),typeof r==`function`&&r(),r=void 0}};export{i as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=Symbol.for(`dev.renku.fragment`),t=e=>e.children??null;t[e]=!0;export{e as n,t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=e=>typeof e==`object`&&!!e&&`default`in e&&typeof e.default==`function`,t=async(t,n)=>{if(t instanceof Promise){let r=await t;return e(r)?r.default(n):null}if(e(t))return t.default(n);if(typeof t==`function`){let r=t(n);if(r instanceof Promise){let t=await r;return e(t)?t.default(n):t}return e(r)?r.default(n):r}return null},n=({request:t,routes:n})=>{let r=new URL(t.url).pathname,i=t.method.toUpperCase(),a=r.split(`/`).filter(Boolean),o=n.layout?[n.layout]:[],s={},c=null,l=e=>{let t=e[i];return t?typeof t==`function`?i===`GET`&&t.length<=1?{layouts:o,route:t,params:s,auth:c}:{api:t,params:s,auth:c}:i===`GET`?{layouts:o,route:t,params:s,auth:c}:null:null};if(a.length===0)return n.index?{layouts:o,route:n.index,params:s,auth:c}:typeof n[`/`]==`object`&&`index`in n[`/`]?(n[`/`].layout&&o.unshift(n[`/`].layout),{layouts:o,route:n[`/`].index,params:s,auth:c}):!1;let u=n;for(let[t,n]of a.entries()){let r=`/${n}`,d=u[r],f=e=>Object.keys(e).find(e=>e.startsWith(`/:`));if(!d){let e=f(u);if(!e&&u[`/`]&&typeof u[`/`]==`object`){let t=u[`/`];d=t[r],typeof t==`object`&&t.layout&&o.unshift(t.layout),d||(e=f(t))}if(e){let t=e.slice(2);s[t]=n,d=u[e]}}if(typeof d==`function`||d instanceof Promise||e(d))return{layouts:o,route:d,params:s,auth:c};if(typeof d==`object`){let e=d;if(e.auth&&!c&&(c=e.auth),e.layout&&o.unshift(e.layout),t===a.length-1)if(typeof e.index==`object`&&i in e.index){let t=e.index,n=l(t);if(n)return n}else if(e.index)return{layouts:o,route:e.index,params:s,auth:c};else{let t=l(e);if(t)return t}u=e}}return!1};export{t as n,n as t};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
1
|
+
import { t as Signal } from "./signal-DXdSsSmq.js";
|
|
2
|
+
import { a as RenkuNode, i as LayoutComponent, n as FunctionComponent, o as Fragment } from "./types-CvU3wYQp.js";
|
|
3
|
+
import { t as Routes } from "./types-DZ5UlJbq.js";
|
|
4
|
+
import { a as RpcTarget, i as RpcStub, n as Loader, r as RpcCompatible, t as Context } from "./types-De3Of0g0.js";
|
|
5
|
+
import { t as registerServerFunction } from "./register-server-function-s7OWEfvO.js";
|
|
5
6
|
|
|
6
7
|
//#region src/reactivity/create-computed.d.ts
|
|
7
8
|
declare const createComputed: <T>(fn: () => T) => Signal.Computed<T>;
|
|
@@ -34,4 +35,4 @@ declare const createSignal: <T>(initialValue: T) => Signal.State<T>;
|
|
|
34
35
|
//#region src/reactivity/effect.d.ts
|
|
35
36
|
declare const effect: (callback: (() => () => void) | (() => void)) => (() => void);
|
|
36
37
|
//#endregion
|
|
37
|
-
export { type FunctionComponent, type LayoutComponent, RemoteSignal, type Routes, type RpcCompatible, RpcStub, RpcTarget, Signal, createComputed, createContext, createFetched, createLoader, createRemoteSignal, createSignal, effect, registerServerFunction };
|
|
38
|
+
export { Fragment, type FunctionComponent, type LayoutComponent, RemoteSignal, type RenkuNode, 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-
|
|
1
|
+
import{n as e}from"./signal-store-B0WygwF_.js";import{t}from"./effect-D3CPC1qb.js";import{t as n}from"./fragment-DkBz18dw.js";import{n as r,t as i}from"./create-computed-vBhisFEL.js";import{t as a}from"./create-loader-hQHegC7I.js";import{t as o}from"./create-context-DWsglCRN.js";import{t as s}from"./register-server-function-Cz5-Gudu.js";import{RpcStub as c,RpcTarget as l}from"capnweb";const u=(e,t)=>a(()=>fetch(e).then(async e=>await t(e))),d=(e,n=!0)=>a(async()=>{let i=await e(),a=r(await i.get());return i.subscribe(e=>a.set(e)),t(()=>{n&&i.set(a.get())}),a});var f=class extends l{#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{n as Fragment,f as RemoteSignal,c as RpcStub,l as RpcTarget,e as Signal,i as createComputed,o as createContext,u as createFetched,a as createLoader,d as createRemoteSignal,r as createSignal,t as effect,s as registerServerFunction};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import "./signal-DXdSsSmq.js";
|
|
2
|
+
import { o as Fragment, r as JSX } from "./types-CvU3wYQp.js";
|
|
3
3
|
|
|
4
4
|
//#region src/jsx/jsx-dev.d.ts
|
|
5
|
-
declare const jsxDEV:
|
|
5
|
+
declare const jsxDEV: <T extends JSX.ElementType = JSX.ElementType, P extends Record<string, unknown> = Record<string, unknown>, K extends JSX.Key = JSX.Key>(type: T, props: P, key: K | undefined, _isStaticChildren: boolean, _source: {
|
|
6
6
|
fileName: string;
|
|
7
7
|
lineNumber: number;
|
|
8
8
|
columnNumber: number;
|
|
9
|
-
}, _self: unknown) => JSX.Element
|
|
9
|
+
}, _self: unknown) => JSX.Element<T, P, K>;
|
|
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-DkBz18dw.js";import{t}from"./create-element-DdyoBVZS.js";const n=(e,n,r,i,a,o)=>t(e,n,r);export{e as Fragment,n as jsxDEV};
|
|
File without changes
|
package/dist/jsx-runtime.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import "./signal-DXdSsSmq.js";
|
|
2
|
+
import { o as Fragment, r as JSX } from "./types-CvU3wYQp.js";
|
|
3
3
|
|
|
4
|
-
//#region src/jsx/
|
|
5
|
-
declare const
|
|
4
|
+
//#region src/jsx/create-element.d.ts
|
|
5
|
+
declare const createElement: <T extends JSX.ElementType = JSX.ElementType, P extends Record<string, unknown> = Record<string, unknown>, K extends JSX.Key = JSX.Key>(type: T, props: P, key: K | undefined) => JSX.Element<T, P, K>;
|
|
6
6
|
//#endregion
|
|
7
|
-
|
|
8
|
-
declare const jsxs: (type: JSX.ElementType, props: any, key: string | null | undefined) => JSX.Element;
|
|
9
|
-
//#endregion
|
|
10
|
-
export { Fragment, type JSX, jsx, jsxs };
|
|
7
|
+
export { Fragment, type JSX, createElement as jsx, createElement as jsxs };
|
package/dist/jsx-runtime.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./fragment-
|
|
1
|
+
import{t as e}from"./fragment-DkBz18dw.js";import{t}from"./create-element-DdyoBVZS.js";import"./jsx-runtime-BJQV0ZvP.js";export{e as Fragment,t as jsx,t as jsxs};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./signal-store-B0WygwF_.js";import{t as n}from"./context-store-D1Klyb_v.js";import{t as r}from"./effect-D3CPC1qb.js";import{n as i}from"./fragment-DkBz18dw.js";const a=Symbol(`renku:suspense`),o=e=>e&&typeof e.type==`function`&&e.type[a]===!0,s=({fn:e,key:i,props:a,asyncComponents:o,clientComponents:s})=>{let c=null,l=null,d=e=>{c=e,l&&l(e)},f=[],p=n.current,m=p?new Map(p):new Map;return r(()=>{t.set(f),n.current=m;let r=e(a);if(r instanceof Promise){let e=s.length+o.length+1;o.push(new Promise(t=>{r.then(n=>{t({index:e,node:n})})})),d({type:`async`,key:i,promise:r,index:e})}else d(u({node:r,asyncComponents:o,clientComponents:s}))}),{type:`effect`,value:c,addCallback:e=>{l=e}}},c=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&typeof e.type==`function`&&e.type[i]===!0,l=({node:e,asyncComponents:t=[],clientComponents:n=[]})=>{let r=[];if(Array.isArray(e))for(let i of e)r.push(...l({node:i,asyncComponents:t,clientComponents:n}));else if(e)if(c(e)){let i=e.type(e.props);r.push(...l({node:i,asyncComponents:t,clientComponents:n}))}else{let i=u({node:e,asyncComponents:t,clientComponents:n});Array.isArray(i)?r.push(...i):r.push(i)}return r},u=({node:t,asyncComponents:n=[],clientComponents:r=[]})=>{if(Array.isArray(t))return l({node:t,asyncComponents:n,clientComponents:r});if(t==null)return null;if(typeof t==`string`||typeof t==`number`)return{type:`text`,value:String(t)};if(t instanceof e.Computed||t instanceof e.State)return{type:`signal`,value:t};if(typeof t==`object`){if(typeof t.type==`function`){if(o(t)){console.log(`🚨`,`Suspense`,t);let e=l({node:t.props.children,asyncComponents:n,clientComponents:r}),i=l({node:t.props.fallback,asyncComponents:n,clientComponents:r});return{type:`suspense`,key:t.key,suspended:e,fallback:i}}return s({fn:t.type,key:t.key,props:t.props,asyncComponents:n,clientComponents:r})}if(typeof t.type==`object`&&t.type.type===`client`)return r.push({path:t.type.path,name:t.type.name}),{type:`client`,key:t.key,props:t.props,path:t.type.path,name:t.type.name};if(typeof t.type==`string`){let{children:e,...i}=t.props,a=l({node:e,asyncComponents:n,clientComponents:r});return{type:`element`,key:t.key,value:t.type,props:i,children:a}}}return console.warn(`⚠️`,`UNHANDLED NODE TYPE`,t),null};export{s as n,a as r,u as t};
|
package/dist/otel.d.ts
ADDED
package/dist/otel.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getNodeAutoInstrumentations as e}from"@opentelemetry/auto-instrumentations-node";import{OTLPMetricExporter as t}from"@opentelemetry/exporter-metrics-otlp-http";import{OTLPTraceExporter as n}from"@opentelemetry/exporter-trace-otlp-http";import{resourceFromAttributes as r}from"@opentelemetry/resources";import{PeriodicExportingMetricReader as i}from"@opentelemetry/sdk-metrics";import{NodeSDK as a}from"@opentelemetry/sdk-node";import{ATTR_SERVICE_NAME as o}from"@opentelemetry/semantic-conventions";import{logs as s}from"@opentelemetry/api-logs";import{W3CTraceContextPropagator as c}from"@opentelemetry/core";import{OTLPLogExporter as l}from"@opentelemetry/exporter-logs-otlp-http";import{registerInstrumentations as u}from"@opentelemetry/instrumentation";import{DocumentLoadInstrumentation as d}from"@opentelemetry/instrumentation-document-load";import{XMLHttpRequestInstrumentation as f}from"@opentelemetry/instrumentation-xml-http-request";import{BatchLogRecordProcessor as p,LoggerProvider as m}from"@opentelemetry/sdk-logs";import{BatchSpanProcessor as h}from"@opentelemetry/sdk-trace-base";import{WebTracerProvider as g}from"@opentelemetry/sdk-trace-web";const _=()=>{new a({resource:r({[o]:`renku-node`}),traceExporter:new n({url:`http://localhost:4318/v1/traces`}),metricReader:new i({exporter:new t({url:`http://localhost:4318/v1/traces`})}),instrumentations:[e()]}).start(),console.log(`OTEL SDK started`)},v=()=>{let e=r({[o]:`renku-web`}),t=new m({resource:e,processors:[new p(new l({url:`http://localhost:4318/v1/logs`}))]});s.setGlobalLoggerProvider(t),s.getLogger(`renku-web`).emit({severityText:`INFO`,body:`Hello from the browser`}),new g({resource:e,spanProcessors:[new h(new n({url:`http://localhost:4318/v1/traces`}))]}).register({propagator:new c}),u({instrumentations:[new d,new f]})};export{_ as instrumentNode,v as instrumentWeb};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{newHttpBatchRpcSession as e,newWebSocketRpcSession as t}from"capnweb";const n=(n,r,i=!1)=>{let a=`/@renku/rpc/${encodeURIComponent(n)}/${encodeURIComponent(r)}`;return(...n)=>(i?t(a):e(a))(...n)};export{n as t};
|
package/dist/{register-server-function-CqA4nPaJ.d.ts → register-server-function-s7OWEfvO.d.ts}
RENAMED
|
@@ -5,6 +5,6 @@ import { RpcStub, RpcTarget } from "capnweb";
|
|
|
5
5
|
type ServerFunction = (...args: unknown[]) => RpcStub<RpcTarget>;
|
|
6
6
|
//#endregion
|
|
7
7
|
//#region src/server/register-server-function.d.ts
|
|
8
|
-
declare const registerServerFunction: (path: string, name: string) => ServerFunction;
|
|
8
|
+
declare const registerServerFunction: (path: string, name: string, ws?: boolean) => ServerFunction;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { registerServerFunction as t };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import{n as e}from"./signal-store-B0WygwF_.js";import{t}from"./jsx-to-virtual-node-btYsRR_g.js";async function*n(e){yield`<!DOCTYPE html>`;for await(let t of e)t[1]&&(yield t[1])}async function*r(e){for await(let t of e)t[0]&&(yield t[0])}async function*i(e){let n=new Set(e.map(e=>e.then(({index:e,node:n})=>({index:e,virtualNode:t({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*a({key:t,val:n,trailingComma:r,output:i}){if(typeof n==`string`||typeof n==`number`){t===`className`&&(t=`class`);let e=typeof n==`number`?String(n):`"${String(n)}"`;return yield i(`${r?`,`:``}"${t}":${e}`,` ${t}="${String(n)}"`),!0}if(n instanceof e.State||n instanceof e.Computed)return yield i(`${r?`,`:``}"${t}":"${String(n.get())}"`,` ${t}="${String(n.get())}"`),!0;if(Array.isArray(n)){let a=n.map(t=>t instanceof e.State||t instanceof e.Computed?String(t.get()):String(t)).join(` `);return yield i(`${r?`,`:``}"${t}":"${a}"`,` ${t}="${a}"`),!0}}const o=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`source`,`track`,`wbr`]);async function*s({virtualNode:e,asyncVirtualNodes:t,leadingComma:n=!1,rscBuffer:r=[]}){let i=(e,t)=>(e&&r.push(e),[e,t]),c=(e,t)=>i(e,null);if(Array.isArray(e))for(let i of e)yield*s({virtualNode:i,asyncVirtualNodes:t,leadingComma:n,rscBuffer:r}),n=!0;else if(e?.type===`element`){yield i(`${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*a({key:t,val:n,trailingComma:!c,output:i}))&&(c=!1);if(yield i(null,o.has(e.value)?` />`:`>`),e.children.length>0){let n=!0;yield i(`${c?``:`,`}"children":[`,null);for(let i of e.children)(yield*s({virtualNode:i,asyncVirtualNodes:t,leadingComma:!n,rscBuffer:r}))&&(n=!1);e.value!==`html`&&(yield i(`]`,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*s({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
|
+
(() => {
|
|
4
|
+
const placeholder = document.querySelector(\`${`template[data-id="async-placeholder-${e.index}"]`}\`);
|
|
5
|
+
// console.log("placeholder",placeholder);
|
|
6
|
+
if(placeholder) {
|
|
7
|
+
const template = document.querySelector(\`${`template[data-id="async-template-${e.index}"]`}\`);
|
|
8
|
+
// console.log("template",template);
|
|
9
|
+
// const clone = template.content.cloneNode(true);
|
|
10
|
+
template && placeholder.parentNode.replaceChild(template.content, placeholder);
|
|
11
|
+
}
|
|
12
|
+
})();
|
|
13
|
+
<\/script>`]}}return o.has(e.value)?yield i(`}]`,null):e.value!==`html`&&e.value!==`body`?yield i(`}]`,`</${e.value}>`):yield i(null,`</${e.value}>`),!0}else if(e?.type===`text`||e?.type===`signal`){let t=e?.type===`signal`?String(e.value.get()):e.value;return yield i(`${n?`,`:``}"${t.replaceAll(`"`,`\\\\"`).replaceAll(`
|
|
14
|
+
`,`\\\\n`)}"`,t),!0}else if(e?.type===`async`)return yield i(`${n?`,`:``}["A",${e.key?`"${e.key}"`:`null`},${e.index}]`,`<template data-id="async-placeholder-${e.index}"></template>`),!0;else if(e?.type===`client`){yield i(`${n?`,`:``}["C",${e.key?`"${e.key}"`:`null`},"${e.path}","${e.name}",{`,`<!-- CLIENT -->`);let t=!0;for(let[n,r]of Object.entries(e.props))n!==`children`&&(yield*a({key:n,val:r,trailingComma:!t,output:c}))&&(t=!1);return yield i(`}]`,null),!0}else if(e?.type===`effect`)return yield*s({virtualNode:e.value,asyncVirtualNodes:t,leadingComma:n,rscBuffer:r})}const c=e=>{let n=[];return s({virtualNode:t({node:e,asyncComponents:n}),asyncVirtualNodes:i(n)})};export{r as n,n as r,c as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./signal-store-B0WygwF_.js";import{t}from"./jsx-to-virtual-node-btYsRR_g.js";import{t as n}from"./effect-D3CPC1qb.js";function r({domNode:e,virtualNode:t,replace:n=!1}){let r=[];for(let i of t){let t=o({domNode:e,virtualNode:i,replace:n});n=!1,r.push(t)}return r}const i=({element:t,key:r,val:i})=>{typeof i==`function`?r.startsWith(`on`)&&t.addEventListener(r.slice(2),i):typeof i==`string`||typeof i==`number`?(r===`className`&&(r=`class`),t.setAttribute(r,String(i))):i instanceof e.State||i instanceof e.Computed?n(()=>{t.setAttribute(r,String(i.get()))}):Array.isArray(i)?n(()=>{let n=i.map(t=>t instanceof e.State||t instanceof e.Computed?String(t.get()):String(t)).join(` `);t.setAttribute(r,n)}):typeof i==`boolean`&&(i?t.setAttribute(r,``):t.removeAttribute(r))},a=({domNode:e,newVirtualNode:t,oldVirtualNode:n})=>{let r=e=>e&&`key`in e?e.key??null:null;if(t&&n)if(t.type===n.type)if(t.type===`element`&&n.type===`element`)if(t.value===n.value){let s=e,c=n.props?Object.keys(n.props).filter(e=>!(e in t.props)):[];c.length&&c.map(e=>s.removeAttribute(e));for(let[e,r]of Object.entries(t.props))if(e!==`children`&&e!==`key`)if(n.props&&e in n.props){let t=n.props[e];typeof r==`function`||(Array.isArray(r)&&Array.isArray(t)?JSON.stringify(r)!==JSON.stringify(t)&&i({element:s,key:e,val:r}):n.props[e]!==r&&i({element:s,key:e,val:r}))}else i({element:s,key:e,val:r});if(t.children.length){let e=0;for(let i=0;i<t.children.length;i++){let c=t.children[i];if(c){let t=n.children?n.children[i-e]:void 0;if(t?.domNode)if(r(c)===r(t))c.domNode=t.domNode,a({domNode:t.domNode,newVirtualNode:c,oldVirtualNode:t});else{let i=r(c),o=n.children.findIndex(e=>r(e)===i),l=o>-1?n.children[o]:null;l?.domNode&&(s.moveBefore(l.domNode,t.domNode),c.domNode=l.domNode,e++,a({domNode:l.domNode,newVirtualNode:c,oldVirtualNode:l}),n.children.splice(o,1))}else c.type!==`effect`&&o({domNode:s,virtualNode:c});n.children[i-e]=null}}if(n.children.length+e>t.children.length)for(let r=t.children.length;r<n.children.length+e;r++){let t=n.children[r-e]?.domNode;t&&s.removeChild(t)}}else n.children?.length&&s.replaceChildren()}else console.log(`Different node types`),n.domNode&&o({domNode:n.domNode,virtualNode:t,replace:!0});else t.type===`text`&&n.type===`text`&&t.value!==n.value&&(t.domNode=n.domNode,t.domNode.nodeValue=t.value);else console.warn(`Different node types`),n.domNode&&o({domNode:n.domNode,virtualNode:t,replace:!0});else console.warn(`Old or new node is null`);return e};function o({domNode:e,virtualNode:s,replace:c=!1}){if(!s)return null;let l=[`svg`,`path`,`circle`];if(s.type===`element`){let t=l.includes(s.value)?document.createElementNS(`http://www.w3.org/2000/svg`,s.value):document.createElement(s.value);if(s.domNode=t,s.props.ref){let e=s.props.ref;console.log(`has ref`,e.get()),e.set(s.domNode),console.log(`assigned ref`,s.domNode),console.log(`has ref`,e.get())}for(let[e,n]of Object.entries(s.props))e!==`children`&&e!==`key`&&e!==`ref`&&i({element:t,key:e,val:n});if(s.children)for(let e of s.children)o({domNode:t,virtualNode:e});if(e===document.documentElement)document.documentElement.replaceWith(t);else{let n=e.parentNode;c&&n?n.replaceChild(t,e):e.appendChild(t)}return t}if(s.type===`async`){let n=document.createElement(`template`);return s.domNode=n,e.appendChild(n),s.promise?.then(e=>{let i=t({node:e});Array.isArray(i)?r({domNode:n,virtualNode:i,replace:!0}):o({domNode:n,virtualNode:i,replace:!0})}),n}if(s.type===`text`){let t=document.createTextNode(s.value);return s.domNode=t,e.appendChild(t),t}if(s.type===`signal`){let t=s.value,r=document.createTextNode(``);return s.domNode=r,n(()=>{r.textContent=String(t.get())}),e.appendChild(r),r}if(s.type===`suspense`){let t=document.createTextNode(``);t.textContent=`SUSPENSE`;let n=document.createElement(`div`);if(n.appendChild(t),s.domNode=n,console.log(`render suspense`,e,t),e===document.documentElement)document.documentElement.replaceWith(n);else{let t=e.parentNode;c&&t?t.replaceChild(n,e):e.appendChild(n)}return n}if(s.type===`effect`){let t=s.value,n=null,r=null,i=t=>{Array.isArray(t)?console.warn(`EFFECT virtual node is array`):n?(n=a({domNode:n,newVirtualNode:t,oldVirtualNode:r}),r=t):(n=o({domNode:e,virtualNode:t,replace:c}),r=t,t=null)};s.addCallback(i),i(t)}return null}export{a as n,r,o as t};
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { t as
|
|
1
|
+
import "./signal-DXdSsSmq.js";
|
|
2
|
+
import { t as ClientComponent } from "./types-CvU3wYQp.js";
|
|
3
|
+
import { t as registerServerFunction } from "./register-server-function-s7OWEfvO.js";
|
|
3
4
|
|
|
4
5
|
//#region src/server/register-client-reference.d.ts
|
|
5
6
|
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-Cz5-Gudu.js";const t=(e,t,n)=>({type:`client`,path:t,name:n});export{t as registerClientReference,e as registerServerFunction};
|