@useavalon/avalon 0.1.10 → 0.1.12
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/README.md +54 -54
- package/dist/mod.js +1 -0
- package/dist/src/build/integration-bundler-plugin.js +1 -0
- package/dist/src/build/integration-config.js +1 -0
- package/dist/src/build/integration-detection-plugin.js +1 -0
- package/dist/src/build/integration-resolver-plugin.js +1 -0
- package/dist/src/build/island-manifest.js +1 -0
- package/dist/src/build/island-types-generator.js +5 -0
- package/dist/src/build/mdx-island-transform.js +2 -0
- package/dist/src/build/mdx-plugin.js +1 -0
- package/dist/src/build/page-island-transform.js +3 -0
- package/dist/src/build/prop-extractors/index.js +1 -0
- package/dist/src/build/prop-extractors/lit.js +1 -0
- package/dist/src/build/prop-extractors/qwik.js +1 -0
- package/dist/src/build/prop-extractors/solid.js +1 -0
- package/dist/src/build/prop-extractors/svelte.js +1 -0
- package/dist/src/build/prop-extractors/vue.js +1 -0
- package/dist/src/build/sidecar-file-manager.js +1 -0
- package/dist/src/build/sidecar-renderer.js +6 -0
- package/dist/src/client/adapters/index.js +1 -0
- package/dist/src/client/components.js +1 -0
- package/dist/src/client/css-hmr-handler.js +1 -0
- package/dist/src/client/framework-adapter.js +13 -0
- package/dist/src/client/hmr-coordinator.js +1 -0
- package/dist/src/client/hmr-error-overlay.js +214 -0
- package/dist/src/client/main.js +39 -0
- package/{src → dist/src}/client/types/framework-runtime.d.ts +68 -68
- package/{src → dist/src}/client/types/vite-hmr.d.ts +46 -46
- package/dist/src/client/types/vite-virtual-modules.d.ts +70 -0
- package/dist/src/components/Image.js +1 -0
- package/dist/src/components/IslandErrorBoundary.js +1 -0
- package/dist/src/components/LayoutDataErrorBoundary.js +1 -0
- package/dist/src/components/LayoutErrorBoundary.js +1 -0
- package/dist/src/components/PersistentIsland.js +1 -0
- package/dist/src/components/StreamingErrorBoundary.js +1 -0
- package/dist/src/components/StreamingLayout.js +29 -0
- package/dist/src/core/components/component-analyzer.js +1 -0
- package/dist/src/core/components/component-detection.js +5 -0
- package/dist/src/core/components/enhanced-framework-detector.js +1 -0
- package/dist/src/core/components/framework-registry.js +1 -0
- package/dist/src/core/content/mdx-processor.js +1 -0
- package/dist/src/core/integrations/index.js +1 -0
- package/dist/src/core/integrations/loader.js +1 -0
- package/dist/src/core/integrations/registry.js +1 -0
- package/dist/src/core/islands/island-persistence.js +1 -0
- package/dist/src/core/islands/island-state-serializer.js +1 -0
- package/dist/src/core/islands/persistent-island-context.js +1 -0
- package/dist/src/core/islands/use-persistent-state.js +1 -0
- package/dist/src/core/layout/enhanced-layout-resolver.js +1 -0
- package/dist/src/core/layout/layout-cache-manager.js +1 -0
- package/dist/src/core/layout/layout-composer.js +1 -0
- package/dist/src/core/layout/layout-data-loader.js +1 -0
- package/dist/src/core/layout/layout-discovery.js +1 -0
- package/dist/src/core/layout/layout-matcher.js +1 -0
- package/dist/src/core/layout/layout-types.js +1 -0
- package/dist/src/core/modules/framework-module-resolver.js +1 -0
- package/dist/src/islands/component-analysis.js +1 -0
- package/dist/src/islands/css-utils.js +17 -0
- package/dist/src/islands/discovery/index.js +1 -0
- package/dist/src/islands/discovery/registry.js +1 -0
- package/dist/src/islands/discovery/resolver.js +2 -0
- package/dist/src/islands/discovery/scanner.js +1 -0
- package/dist/src/islands/discovery/types.js +1 -0
- package/dist/src/islands/discovery/validator.js +18 -0
- package/dist/src/islands/discovery/watcher.js +1 -0
- package/dist/src/islands/framework-detection.js +1 -0
- package/dist/src/islands/integration-loader.js +1 -0
- package/dist/src/islands/island.js +1 -0
- package/dist/src/islands/render-cache.js +1 -0
- package/dist/src/islands/types.js +1 -0
- package/dist/src/islands/universal-css-collector.js +5 -0
- package/dist/src/islands/universal-head-collector.js +2 -0
- package/{src → dist/src}/layout-system.d.ts +592 -592
- package/dist/src/layout-system.js +1 -0
- package/dist/src/middleware/discovery.js +1 -0
- package/dist/src/middleware/executor.js +1 -0
- package/dist/src/middleware/index.js +1 -0
- package/dist/src/middleware/types.js +1 -0
- package/dist/src/nitro/build-config.js +1 -0
- package/dist/src/nitro/config.js +1 -0
- package/dist/src/nitro/error-handler.js +198 -0
- package/dist/src/nitro/index.js +1 -0
- package/dist/src/nitro/island-manifest.js +2 -0
- package/dist/src/nitro/middleware-adapter.js +1 -0
- package/dist/src/nitro/renderer.js +183 -0
- package/dist/src/nitro/route-discovery.js +1 -0
- package/dist/src/nitro/types.js +1 -0
- package/dist/src/render/collect-css.js +3 -0
- package/{src/render/error-pages.ts → dist/src/render/error-pages.js} +7 -38
- package/dist/src/render/isolated-ssr-renderer.js +1 -0
- package/dist/src/render/ssr.js +90 -0
- package/dist/src/schemas/api.js +1 -0
- package/dist/src/schemas/core.js +1 -0
- package/dist/src/schemas/index.js +1 -0
- package/dist/src/schemas/layout.js +1 -0
- package/dist/src/schemas/routing/index.js +1 -0
- package/dist/src/schemas/routing.js +1 -0
- package/dist/src/types/as-island.js +1 -0
- package/{src → dist/src}/types/image.d.ts +106 -106
- package/{src → dist/src}/types/index.d.ts +22 -22
- package/{src → dist/src}/types/island-jsx.d.ts +33 -33
- package/{src → dist/src}/types/island-prop.d.ts +20 -20
- package/dist/src/types/layout.js +1 -0
- package/{src → dist/src}/types/mdx.d.ts +6 -6
- package/dist/src/types/routing.js +1 -0
- package/dist/src/types/types.js +1 -0
- package/{src → dist/src}/types/urlpattern.d.ts +49 -49
- package/{src → dist/src}/types/vite-env.d.ts +11 -11
- package/dist/src/utils/dev-logger.js +12 -0
- package/dist/src/utils/fs.js +1 -0
- package/dist/src/vite-plugin/auto-discover.js +1 -0
- package/dist/src/vite-plugin/config.js +1 -0
- package/dist/src/vite-plugin/errors.js +1 -0
- package/dist/src/vite-plugin/image-optimization.js +45 -0
- package/dist/src/vite-plugin/integration-activator.js +1 -0
- package/dist/src/vite-plugin/island-sidecar-plugin.js +1 -0
- package/dist/src/vite-plugin/module-discovery.js +1 -0
- package/dist/src/vite-plugin/nitro-integration.js +42 -0
- package/dist/src/vite-plugin/plugin.js +1 -0
- package/dist/src/vite-plugin/types.js +1 -0
- package/dist/src/vite-plugin/validation.js +2 -0
- package/package.json +57 -26
- package/mod.ts +0 -302
- package/src/build/integration-bundler-plugin.ts +0 -116
- package/src/build/integration-config.ts +0 -168
- package/src/build/integration-detection-plugin.ts +0 -117
- package/src/build/integration-resolver-plugin.ts +0 -90
- package/src/build/island-manifest.ts +0 -269
- package/src/build/island-types-generator.ts +0 -476
- package/src/build/mdx-island-transform.ts +0 -464
- package/src/build/mdx-plugin.ts +0 -98
- package/src/build/page-island-transform.ts +0 -598
- package/src/build/prop-extractors/index.ts +0 -21
- package/src/build/prop-extractors/lit.ts +0 -140
- package/src/build/prop-extractors/qwik.ts +0 -16
- package/src/build/prop-extractors/solid.ts +0 -125
- package/src/build/prop-extractors/svelte.ts +0 -194
- package/src/build/prop-extractors/vue.ts +0 -111
- package/src/build/sidecar-file-manager.ts +0 -104
- package/src/build/sidecar-renderer.ts +0 -30
- package/src/client/adapters/index.js +0 -12
- package/src/client/adapters/index.ts +0 -13
- package/src/client/adapters/lit-adapter.js +0 -467
- package/src/client/adapters/lit-adapter.ts +0 -654
- package/src/client/adapters/preact-adapter.js +0 -223
- package/src/client/adapters/preact-adapter.ts +0 -331
- package/src/client/adapters/qwik-adapter.js +0 -259
- package/src/client/adapters/qwik-adapter.ts +0 -345
- package/src/client/adapters/react-adapter.js +0 -220
- package/src/client/adapters/react-adapter.ts +0 -353
- package/src/client/adapters/solid-adapter.js +0 -295
- package/src/client/adapters/solid-adapter.ts +0 -451
- package/src/client/adapters/svelte-adapter.js +0 -368
- package/src/client/adapters/svelte-adapter.ts +0 -524
- package/src/client/adapters/vue-adapter.js +0 -278
- package/src/client/adapters/vue-adapter.ts +0 -467
- package/src/client/components.js +0 -23
- package/src/client/components.ts +0 -35
- package/src/client/css-hmr-handler.js +0 -263
- package/src/client/css-hmr-handler.ts +0 -344
- package/src/client/framework-adapter.js +0 -283
- package/src/client/framework-adapter.ts +0 -462
- package/src/client/hmr-coordinator.js +0 -274
- package/src/client/hmr-coordinator.ts +0 -396
- package/src/client/hmr-error-overlay.js +0 -533
- package/src/client/main.js +0 -816
- package/src/client/types/vite-virtual-modules.d.ts +0 -60
- package/src/components/Image.tsx +0 -123
- package/src/components/IslandErrorBoundary.tsx +0 -145
- package/src/components/LayoutDataErrorBoundary.tsx +0 -141
- package/src/components/LayoutErrorBoundary.tsx +0 -127
- package/src/components/PersistentIsland.tsx +0 -52
- package/src/components/StreamingErrorBoundary.tsx +0 -233
- package/src/components/StreamingLayout.tsx +0 -538
- package/src/core/components/component-analyzer.ts +0 -192
- package/src/core/components/component-detection.ts +0 -508
- package/src/core/components/enhanced-framework-detector.ts +0 -500
- package/src/core/components/framework-registry.ts +0 -563
- package/src/core/content/mdx-processor.ts +0 -46
- package/src/core/integrations/index.ts +0 -19
- package/src/core/integrations/loader.ts +0 -125
- package/src/core/integrations/registry.ts +0 -175
- package/src/core/islands/island-persistence.ts +0 -325
- package/src/core/islands/island-state-serializer.ts +0 -258
- package/src/core/islands/persistent-island-context.tsx +0 -80
- package/src/core/islands/use-persistent-state.ts +0 -68
- package/src/core/layout/enhanced-layout-resolver.ts +0 -322
- package/src/core/layout/layout-cache-manager.ts +0 -485
- package/src/core/layout/layout-composer.ts +0 -357
- package/src/core/layout/layout-data-loader.ts +0 -516
- package/src/core/layout/layout-discovery.ts +0 -243
- package/src/core/layout/layout-matcher.ts +0 -299
- package/src/core/layout/layout-types.ts +0 -110
- package/src/core/modules/framework-module-resolver.ts +0 -273
- package/src/islands/component-analysis.ts +0 -213
- package/src/islands/css-utils.ts +0 -565
- package/src/islands/discovery/index.ts +0 -80
- package/src/islands/discovery/registry.ts +0 -340
- package/src/islands/discovery/resolver.ts +0 -477
- package/src/islands/discovery/scanner.ts +0 -386
- package/src/islands/discovery/types.ts +0 -117
- package/src/islands/discovery/validator.ts +0 -544
- package/src/islands/discovery/watcher.ts +0 -368
- package/src/islands/framework-detection.ts +0 -428
- package/src/islands/integration-loader.ts +0 -490
- package/src/islands/island.tsx +0 -565
- package/src/islands/render-cache.ts +0 -550
- package/src/islands/types.ts +0 -80
- package/src/islands/universal-css-collector.ts +0 -157
- package/src/islands/universal-head-collector.ts +0 -137
- package/src/layout-system.ts +0 -218
- package/src/middleware/discovery.ts +0 -268
- package/src/middleware/executor.ts +0 -315
- package/src/middleware/index.ts +0 -76
- package/src/middleware/types.ts +0 -99
- package/src/nitro/build-config.ts +0 -576
- package/src/nitro/config.ts +0 -483
- package/src/nitro/error-handler.ts +0 -636
- package/src/nitro/index.ts +0 -173
- package/src/nitro/island-manifest.ts +0 -584
- package/src/nitro/middleware-adapter.ts +0 -260
- package/src/nitro/renderer.ts +0 -1471
- package/src/nitro/route-discovery.ts +0 -439
- package/src/nitro/types.ts +0 -321
- package/src/render/collect-css.ts +0 -198
- package/src/render/isolated-ssr-renderer.ts +0 -654
- package/src/render/ssr.ts +0 -1030
- package/src/schemas/api.ts +0 -30
- package/src/schemas/core.ts +0 -64
- package/src/schemas/index.ts +0 -212
- package/src/schemas/layout.ts +0 -279
- package/src/schemas/routing/index.ts +0 -38
- package/src/schemas/routing.ts +0 -376
- package/src/types/as-island.ts +0 -20
- package/src/types/layout.ts +0 -285
- package/src/types/routing.ts +0 -555
- package/src/types/types.ts +0 -5
- package/src/utils/dev-logger.ts +0 -299
- package/src/utils/fs.ts +0 -151
- package/src/vite-plugin/auto-discover.ts +0 -551
- package/src/vite-plugin/config.ts +0 -266
- package/src/vite-plugin/errors.ts +0 -127
- package/src/vite-plugin/image-optimization.ts +0 -156
- package/src/vite-plugin/integration-activator.ts +0 -126
- package/src/vite-plugin/island-sidecar-plugin.ts +0 -176
- package/src/vite-plugin/module-discovery.ts +0 -189
- package/src/vite-plugin/nitro-integration.ts +0 -1354
- package/src/vite-plugin/plugin.ts +0 -401
- package/src/vite-plugin/types.ts +0 -327
- package/src/vite-plugin/validation.ts +0 -228
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import{h as e}from"preact";import{render as t}from"preact-render-to-string";import{readFile as n}from"node:fs/promises";import{getUniversalCSSForHead as r}from"../islands/universal-css-collector.js";import{getUniversalHeadForInjection as i}from"../islands/universal-head-collector.js";import{analyzeComponentContent as a}from"../core/components/component-analyzer.js";import{IsolatedSSRRenderer as o}from"./isolated-ssr-renderer.js";function s(e){let t=e;if(!(e.includes(`data-framework=`)||e.includes(`data-src=`)))return e;if(!e.includes(`data-universal-ssr="true"`)){let n=r(!0);n&&e.includes(`</head>`)&&(t=t.replace(`</head>`,`${n}\n</head>`))}let n=i(!0);if(n&&e.includes(`</head>`)&&(t=t.replace(`</head>`,` ${n}\n</head>`)),e.includes(`/src/client/main.js`)||e.includes(`main.js`))return t;let a=`<script type="module" src="/src/client/main.js"><\/script>`;return t.includes(`</body>`)?t.replace(`</body>`,`${a}\n</body>`):t+a}const c={solid:[`solid-js`,`SolidIsland`,`createSignal`,`.solid.`,`data-solid-hydrate`],vue:[`data-vue-hydrate`,`.vue`,`Vue`],svelte:[`data-framework="svelte"`,`.svelte`,`s-`]};let l=null;function u(){return l||=new o({enableStrictIsolation:!0,allowedCrossFrameworkImports:[`preact`,`preact-render-to-string`],errorHandling:`fallback`,debugLogging:process.env.NODE_ENV!==`production`}),l}function d(e){return{solid:c.solid.some(t=>e.includes(t)),vue:c.vue.some(t=>e.includes(t)),svelte:c.svelte.some(t=>e.includes(t))}}function f(e,t,n){let r=[],i=/^import\s[^'"]*['"]([^'"]+)['"]/gm,a=[],o;for(;(o=i.exec(t))!==null;)a.push(o[1]);let s=n;e.includes(`.solid.`)?s=`solid`:e.includes(`.preact.`)&&(s=`preact`);let c=new Map([[`preact`,[`solid-js`,`solid-js/web`,`vue`,`svelte`]],[`solid`,[`preact`,`preact-render-to-string`,`vue`,`svelte`]],[`vue`,[`preact`,`solid-js`,`svelte`]],[`svelte`,[`preact`,`solid-js`,`vue`]]]).get(s)||[];for(let t of a)for(let n of c)t.startsWith(n)&&r.push(`Cross-framework import detected: ${s} component (${e}) importing ${t}`);return r}function p(e,t){return t.type===`ssr-only`?e.replaceAll(/data-hydrate="[^"]*"\s*/g,``).replace(`>`,` data-render-strategy="${t.type}" data-ssr-reason="${t.reason}">`):e.replace(`>`,` data-render-strategy="${t.type}" data-hydrate-reason="${t.reason}">`)}async function m(e,t={}){let n=/(<[^>]*data-hydrate="([^"]*)"[^>]*>)/g,r=e,i=Array.from(e.matchAll(n));for(let e of i){let[n,i,a]=e;try{if(n.includes(`data-render-strategy`))continue;let e=await g(a,t);await h(a,t),r=r.replace(n,p(n,e)),t.logDecisions===!0&&(console.log(`[SSR Strategy] ${a} -> ${e.type.toUpperCase()}: ${e.reason}`),e.warnings&&e.warnings.length>0&&!t.suppressWarnings&&e.warnings.forEach(e=>console.warn(`[SSR Warning] ${a}: ${e}`)))}catch(e){console.warn(`Failed to analyze component ${a}:`,e);let t=n.replace(`>`,` data-render-strategy="hydrate" data-error="analysis-failed">`);r=r.replace(n,t)}}return r}async function h(e,t={}){try{let r,i=e;e.startsWith(`/`)&&(i=e.substring(1));let a=[i,`examples/${i.split(`/`).pop()}`,`src/islands/${i.split(`/`).pop()}`,`islands/${i.split(`/`).pop()}`],o=``;for(let e of a)try{r=await n(e,`utf-8`),o=e;break}catch{continue}if(!o||!r)return;let s=d(r),c=`preact`;s.solid?c=`solid`:s.vue?c=`vue`:s.svelte&&(c=`svelte`);let l=f(o,r,c);l.length>0&&!t.suppressWarnings&&l.forEach(e=>console.warn(`[Import Validation] ${e}`))}catch(n){t.logDecisions!==!1&&console.warn(`Import validation failed for ${e}:`,n)}}async function g(e,t={}){if(t.forceSSROnly)return{type:`ssr-only`,reason:`Explicitly configured for SSR-only rendering`};if(e.includes(`NoHydrate`)||e.includes(`Static`)||e.includes(`SSROnly`))return{type:`ssr-only`,reason:`Component name explicitly indicates SSR-only rendering`};if(t.detectScripts===!1)return{type:`hydrate`,reason:`Script detection disabled, defaulting to hydration`};try{let r,i=e;e.startsWith(`/`)&&(i=e.substring(1));let o=[i,`examples/${i.split(`/`).pop()}`,`src/islands/${i.split(`/`).pop()}`,`islands/${i.split(`/`).pop()}`],s=null;for(let e of o)try{r=await n(e,`utf-8`);let i={forceSSROnly:t.forceSSROnly,detectScripts:t.detectScripts,suppressWarnings:t.suppressWarnings,logDecisions:!1};s=a(e,r,i);break}catch{continue}return s?{type:s.decision.shouldHydrate?`hydrate`:`ssr-only`,reason:s.decision.reason,warnings:s.decision.warnings}:_(e)}catch(t){return console.warn(`Component analysis failed for ${e}:`,t),{type:`ssr-only`,reason:`Analysis failed, defaulting to SSR-only for safety`,warnings:[`Component analysis error: ${t instanceof Error?t.message:String(t)}`]}}}function _(e){return e.endsWith(`.vue`)||e.endsWith(`.svelte`)||e.endsWith(`.tsx`)||e.endsWith(`.jsx`)?{type:`ssr-only`,reason:`Framework component detected, defaulting to SSR-only (hydration requires explicit hydrate function)`}:{type:`ssr-only`,reason:`Unknown component type, defaulting to SSR-only for safety`}}function v(e){return e.meta?.map(({name:e,content:t})=>`<meta name="${e}" content="${t}">`).join(`
|
|
2
|
+
`)||``}function y(e){return e.styles?.map(e=>`<link rel="stylesheet" href="${e}">`).join(`
|
|
3
|
+
`)||``}function b(e){return e.scripts?.map(e=>typeof e==`string`?`<script src="${e}" defer><\/script>`:`<script ${e.src?`src="${e.src}"`:``} ${e.type?`type="${e.type}"`:``}>${e.content||``}<\/script>`).join(`
|
|
4
|
+
`)||``}function x(e,t){return`
|
|
5
|
+
<script type="module" src="${e?`/src/client/main.js`:`/dist/client.js`}"><\/script>`}function S(e,t){return e&&t?`
|
|
6
|
+
<script type="module">
|
|
7
|
+
if (import.meta.hot) {
|
|
8
|
+
import.meta.hot.accept();
|
|
9
|
+
}
|
|
10
|
+
<\/script>`:``}function C(e){return e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`"`,`"`).replaceAll(`'`,`'`)}function w(e,t,n){let a=process.env.NODE_ENV!==`production`,o=v(e),s=y(e),c=b(e),l=x(a,t),u=S(a,n),d=r(!0),f=i(!0);return`
|
|
11
|
+
<head>
|
|
12
|
+
<meta charset="utf-8">
|
|
13
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
14
|
+
${o}
|
|
15
|
+
<title>${C(String(e.title||`Avalon App`))}</title>
|
|
16
|
+
|
|
17
|
+
<script type="importmap">
|
|
18
|
+
{
|
|
19
|
+
"imports": {
|
|
20
|
+
"@useavalon/preact/client": "/packages/integrations/preact/client/index.ts",
|
|
21
|
+
"@useavalon/vue/client": "/packages/integrations/vue/client/index.ts",
|
|
22
|
+
"@useavalon/solid/client": "/packages/integrations/solid/client/index.ts",
|
|
23
|
+
"@useavalon/svelte/client": "/packages/integrations/svelte/client/index.ts",
|
|
24
|
+
"@useavalon/shared": "/packages/integrations/core/types.ts"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
<\/script>
|
|
28
|
+
${s}
|
|
29
|
+
${d}
|
|
30
|
+
${f}
|
|
31
|
+
${c}${l}${u}
|
|
32
|
+
</head>`.trim()}export async function renderToHtml(e,n={},r,i={}){try{let a,o;if(i.forceSSROnly===!0){let n=e.component();a=t(n instanceof Promise?await n:n),o=d(a)}else ({content:a,frameworks:o}=await D(e,i));return a=await m(a,i),`<!DOCTYPE html>\n<html lang="en">\n${w({...n,...e.options},o,r)}\n<body>\n${a}\n</body>\n</html>`}catch(e){throw console.error(`Error rendering component:`,e),Error(`Failed to render component`)}}export async function renderToHtmlWithLayouts(e,t,n,r,i={},a,o={}){try{let s=e,c={default:e.component,layoutConfig:s.layoutConfig,loader:s.loader,frontmatter:e.frontmatter},l=await t.resolveAndRender(r,c,n);return l.handlers.length===0?await renderToHtml(e,i,a,o):T(await m(await A(await k(e,r,o),l,c,n,r),o),e,i,a)}catch(t){console.error(`Error rendering component with layouts:`,t);try{return await renderToHtml(e,i,a,o)}catch(e){throw console.error(`Fallback rendering also failed:`,e),Error(`Failed to render component with layouts and fallback failed`)}}}function T(e,t,n,r){if(e.trim().startsWith(`<!DOCTYPE html>`)||e.trim().startsWith(`<html`))return s(e);let i=d(e);return s(`<!DOCTYPE html>\n<html lang="en">\n${w({...n,...t.options},i,r)}\n<body>\n${e}\n</body>\n</html>`)}async function E(e,n,r,i){let a,o;if(i.forceSSROnly===!0){let n=e.component();a=t(n instanceof Promise?await n:n),o=d(a)}else ({content:a,frameworks:o}=await D(e,i));return a=await m(a,i),{head:w({...n,...e.options},o,r),content:a}}async function D(e,n){try{let t=await u().renderWithIsolation({componentPath:`route-component`,component:e.component});if(!t.success)throw Error(`Isolated rendering failed: ${t.errors.join(`, `)}`);return t.warnings.length>0&&!n.suppressWarnings&&t.warnings.forEach(e=>console.warn(`[SSR Isolation] ${e}`)),{content:t.html,frameworks:d(t.html)}}catch(n){console.warn(`[SSR] Isolated rendering failed, falling back to standard rendering:`,n);let r=e.component(),i=t(r instanceof Promise?await r:r);return{content:i,frameworks:d(i)}}}function O(e,t,n,r,i,a=`Streaming Error`,o=`route-component`){if(console.error(`[${a}]`,{message:e.message,stack:e.stack,shellSent:t,timestamp:new Date().toISOString()}),i.onError?.(e),t){console.log(`[${a}] Mid-stream error detected, injecting error boundary`);try{n.enqueue(r.encode(M(e,o))),n.enqueue(r.encode(`
|
|
33
|
+
</body>
|
|
34
|
+
</html>`))}catch(e){console.error(`[${a}] Failed to inject error boundary:`,e)}}else i.onShellError?.(e),n.enqueue(r.encode(j(e)));n.close()}export async function renderToHtmlStream(e,t={},n,r={}){let i=new TextEncoder,a=null,o=!1;return new ReadableStream({async start(s){a=s;try{let{head:s,content:c}=await E(e,t,n,r);a.enqueue(i.encode(`<!DOCTYPE html>\n<html lang="en">\n${s}\n<body>\n`)),o=!0,r.onShellReady?.(),a.enqueue(i.encode(c)),a.enqueue(i.encode(`
|
|
35
|
+
</body>
|
|
36
|
+
</html>`)),r.onAllReady?.(),a.close()}catch(e){O(e instanceof Error?e:Error(String(e)),o,a,i,r)}},cancel(){try{a?.close()}catch{}}})}export async function renderToHtmlStreamWithLayouts(e,t,n,r,i={},a,o={}){let c=new TextEncoder,l=null,u=!1;return new ReadableStream({async start(f){l=f;try{let f=e,p={default:e.component,layoutConfig:f.layoutConfig,loader:f.loader,frontmatter:e.frontmatter},h=await t.resolveAndRender(r,p,n);if(h.handlers.length===0){let t=(await renderToHtmlStream(e,i,a,o)).getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)break;l.enqueue(n)}}finally{t.releaseLock()}l.close();return}let g=await m(await A(await k(e,r,o),h,p,n,r),o);if(g.trim().startsWith(`<!DOCTYPE html>`)||g.trim().startsWith(`<html`)){let e=s(g);l.enqueue(c.encode(e)),u=!0,o.onShellReady?.(),o.onAllReady?.(),l.close();return}let _=d(g),v=w({...i,...e.options},_,a);l.enqueue(c.encode(`<!DOCTYPE html>\n<html lang="en">\n${v}\n<body>\n`)),u=!0,o.onShellReady?.(),l.enqueue(c.encode(g)),l.enqueue(c.encode(`
|
|
37
|
+
</body>
|
|
38
|
+
</html>`)),o.onAllReady?.(),l.close()}catch(e){O(e instanceof Error?e:Error(String(e)),u,l,c,o,`Streaming Error with Layouts`,`layout-${r}`)}},cancel(){try{l?.close()}catch{}}})}async function k(e,n,r){if(r.forceSSROnly===!0){let n=e.component();return t(n instanceof Promise?await n:n)}try{let t=await u().renderWithIsolation({componentPath:n,component:e.component});if(!t.success)throw Error(`Isolated rendering failed: ${t.errors.join(`, `)}`);return t.warnings.length>0&&!r.suppressWarnings&&t.warnings.forEach(e=>console.warn(`[SSR Isolation] ${e}`)),t.html}catch(n){console.warn(`[SSR] Isolated page rendering failed, falling back to standard rendering:`,n);let r=e.component();return t(r instanceof Promise?await r:r)}}async function A(n,r,i,a,o){let s=e(`avalon-page-content`,{dangerouslySetInnerHTML:{__html:n}}),c=null;for(let n=r.handlers.length-1;n>=0;n--){let l=r.handlers[n],u={data:r.dataLoaders[n]?await r.dataLoaders[n](a):{},frontmatter:i.frontmatter||{},route:{path:o,params:a.params,query:a.query}},d=l.component,f=d({...u,children:s});if(f instanceof Promise){let r=t(await f);n===0?c=r:s=e(`avalon-layout-fragment`,{dangerouslySetInnerHTML:{__html:r}})}else s=e(d,u,s)}if(c!==null)return c;try{let e=await u().renderWithIsolation({componentPath:`layout-chain-${o}`,component:()=>s});if(e.success)return e.html}catch{}return t(s)}function j(e){let t=process.env.NODE_ENV!==`production`;return`<!DOCTYPE html>
|
|
39
|
+
<html lang="en">
|
|
40
|
+
<head>
|
|
41
|
+
<meta charset="utf-8">
|
|
42
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
43
|
+
<title>Error</title>
|
|
44
|
+
<style>
|
|
45
|
+
body {
|
|
46
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
47
|
+
margin: 0;
|
|
48
|
+
padding: 40px;
|
|
49
|
+
background: #f5f5f5;
|
|
50
|
+
}
|
|
51
|
+
.error-container {
|
|
52
|
+
max-width: 600px;
|
|
53
|
+
margin: 0 auto;
|
|
54
|
+
background: white;
|
|
55
|
+
padding: 40px;
|
|
56
|
+
border-radius: 8px;
|
|
57
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
|
58
|
+
}
|
|
59
|
+
h1 {
|
|
60
|
+
color: #d32f2f;
|
|
61
|
+
margin-top: 0;
|
|
62
|
+
}
|
|
63
|
+
pre {
|
|
64
|
+
background: #f5f5f5;
|
|
65
|
+
padding: 16px;
|
|
66
|
+
border-radius: 4px;
|
|
67
|
+
overflow-x: auto;
|
|
68
|
+
}
|
|
69
|
+
</style>
|
|
70
|
+
</head>
|
|
71
|
+
<body>
|
|
72
|
+
<div class="error-container">
|
|
73
|
+
<h1>Server Error</h1>
|
|
74
|
+
<p>An error occurred while rendering the page:</p>
|
|
75
|
+
<pre>${e.message}</pre>
|
|
76
|
+
${t&&e.stack?`<pre>${e.stack}</pre>`:``}
|
|
77
|
+
</div>
|
|
78
|
+
</body>
|
|
79
|
+
</html>`}function M(e,t){let n=process.env.NODE_ENV!==`production`,r=t?`<p><strong>Component ID:</strong> ${t}</p>`:``,i=e.stack?`<pre style="background:#f5f5f5;padding:10px;border-radius:4px;overflow-x:auto;font-size:12px;margin-top:10px">${e.stack}</pre>`:``,a=n?`<details style="margin-top:15px"><summary style="cursor:pointer;color:#856404;font-weight:bold">Error Details (Development Mode)</summary><div style="margin-top:10px">${r}<p><strong>Error:</strong> ${e.message}</p>${i}</div></details>`:``;return`
|
|
80
|
+
<div class="streaming-error-boundary" data-error-boundary="true"${t?` data-component-id="${t}"`:``}>
|
|
81
|
+
<div class="error-boundary-container" style="background:#fff3cd;border:2px solid #ffc107;border-radius:8px;padding:20px;margin:20px 0;font-family:system-ui,-apple-system,sans-serif">
|
|
82
|
+
<div class="error-boundary-header" style="display:flex;align-items:center;gap:10px;margin-bottom:10px">
|
|
83
|
+
<span style="font-size:24px">⚠️</span>
|
|
84
|
+
<h3 style="margin:0;color:#856404">Component Error</h3>
|
|
85
|
+
</div>
|
|
86
|
+
<p style="margin:10px 0;color:#856404">An error occurred while rendering this component. The rest of the page should work normally.</p>
|
|
87
|
+
${a}
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
`}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as e}from"zod";export const ApiMethodSchema=e.enum([`GET`,`POST`,`PUT`,`DELETE`,`PATCH`,`HEAD`,`OPTIONS`]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as e}from"zod";export const MetaTagSchema=e.object({name:e.string().min(1),content:e.string()});export const ScriptConfigSchema=e.union([e.string().min(1),e.object({src:e.string().min(1).optional(),content:e.string().optional(),data:e.union([e.record(e.string(),e.unknown()),e.array(e.unknown()),e.string()]).optional(),type:e.string().optional(),async:e.boolean().optional(),defer:e.boolean().optional(),crossorigin:e.enum([`anonymous`,`use-credentials`]).optional(),integrity:e.string().optional(),nomodule:e.boolean().optional(),referrerpolicy:e.enum([`no-referrer`,`no-referrer-when-downgrade`,`origin`,`origin-when-cross-origin`,`same-origin`,`strict-origin`,`strict-origin-when-cross-origin`,`unsafe-url`]).optional(),attributes:e.record(e.string(),e.string()).optional()}).refine(e=>e.src||e.content||e.data,{message:`Script must have either 'src', 'content', or 'data'`})]);export const RenderOptionsSchema=e.object({title:e.string().optional(),scripts:e.array(ScriptConfigSchema).optional(),styles:e.array(e.string().min(1)).optional(),meta:e.array(MetaTagSchema).optional()});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as e}from"zod";import{RenderOptionsSchema as t}from"./core.js";import{LayoutContextSchema as n,LayoutDataSchema as r,LayoutHandlerSchema as i,LayoutDiscoveryOptionsSchema as a,LayoutConfigSchema as o,ResolvedLayoutSchema as s}from"./layout.js";import{FileSystemRouteSchema as c,RoutePageModuleSchema as l,RouteDiscoveryOptionsSchema as u,FileSystemRouterConfigSchema as d,MetadataSchema as f,ResolvedMetadataSchema as p}from"./routing.js";export*from"./core.js";export*from"./api.js";export*from"./layout.js";export*from"./routing.js";export class ValidationError extends Error{constructor(e,t){super(e),this.zodError=t,this.name=`ValidationError`}getFormattedErrors(){return this.zodError.issues.map(e=>`${e.path.length>0?`${e.path.join(`.`)}: `:``}${e.message}`)}getErrorMessage(){return this.getFormattedErrors().join(`; `)}}export function createValidationError(e,t){return new ValidationError(e,t)}export function safeValidate(e,t,n=`Validation failed`){let r=e.safeParse(t);return r.success?{success:!0,data:r.data}:{success:!1,error:createValidationError(n,r.error)}}export function validate(e,t,n=`Validation failed`){let r=e.safeParse(t);if(r.success)return r.data;throw createValidationError(n,r.error)}export const validators={renderOptions:e=>validate(t,e,`Invalid render options`),layoutContext:e=>validate(n,e,`Invalid layout context`),layoutData:e=>validate(r,e,`Invalid layout data`),layoutHandler:e=>validate(i,e,`Invalid layout handler`),layoutDiscoveryOptions:e=>validate(a,e,`Invalid layout discovery options`),layoutConfig:e=>validate(o,e,`Invalid layout config`),resolvedLayout:e=>validate(s,e,`Invalid resolved layout`),fileSystemRoute:e=>validate(c,e,`Invalid file system route`),routePageModule:e=>validate(l,e,`Invalid route page module`),routeDiscoveryOptions:e=>validate(u,e,`Invalid route discovery options`),fileSystemRouterConfig:e=>validate(d,e,`Invalid file system router config`),metadata:e=>validate(f,e,`Invalid metadata`),resolvedMetadata:e=>validate(p,e,`Invalid resolved metadata`)};export const safeValidators={renderOptions:e=>safeValidate(t,e,`Invalid render options`),layoutContext:e=>safeValidate(n,e,`Invalid layout context`),layoutData:e=>safeValidate(r,e,`Invalid layout data`),layoutHandler:e=>safeValidate(i,e,`Invalid layout handler`),layoutDiscoveryOptions:e=>safeValidate(a,e,`Invalid layout discovery options`),layoutConfig:e=>safeValidate(o,e,`Invalid layout config`),resolvedLayout:e=>safeValidate(s,e,`Invalid resolved layout`),fileSystemRoute:e=>safeValidate(c,e,`Invalid file system route`),routePageModule:e=>safeValidate(l,e,`Invalid route page module`),routeDiscoveryOptions:e=>safeValidate(u,e,`Invalid route discovery options`),fileSystemRouterConfig:e=>safeValidate(d,e,`Invalid file system router config`),metadata:e=>safeValidate(f,e,`Invalid metadata`),resolvedMetadata:e=>safeValidate(p,e,`Invalid resolved metadata`)};export const devValidators={renderOptionsSoft:(e,t=`unknown`)=>{let n=safeValidators.renderOptions(e);return n.success?!0:(console.warn(`Render options validation warning in ${t}:`,n.error.getErrorMessage()),!1)}};export function isValidRenderOptions(e){return safeValidators.renderOptions(e).success}export function isValidFileSystemRoute(e){return safeValidators.fileSystemRoute(e).success}export function isValidRoutePageModule(e){return safeValidators.routePageModule(e).success}export function isValidRouteDiscoveryOptions(e){return safeValidators.routeDiscoveryOptions(e).success}export function isValidFileSystemRouterConfig(e){return safeValidators.fileSystemRouterConfig(e).success}export function isValidMetadata(e){return safeValidators.metadata(e).success}export function isValidResolvedMetadata(e){return safeValidators.resolvedMetadata(e).success}export function validateBatch(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))try{n[i]=validate(a,t[i],`Invalid ${String(i)}`)}catch(e){e instanceof ValidationError?r.push(`${String(i)}: ${e.getErrorMessage()}`):r.push(`${String(i)}: Unknown validation error`)}if(r.length>0)throw Error(`Batch validation failed: ${r.join(`; `)}`);return n}export function safeValidateBatch(t,n){try{return{success:!0,data:validateBatch(t,n)}}catch(t){return{success:!1,error:t instanceof ValidationError?t:createValidationError(`Batch validation failed`,new e.ZodError([{code:`custom`,message:String(t),path:[]}]))}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as e}from"zod";export const LayoutContextSchema=e.object({request:e.instanceof(Request),params:e.record(e.string(),e.string()),query:e.instanceof(URLSearchParams),state:e.instanceof(Map),middlewareContext:e.any().optional()});export const LayoutDataSchema=e.record(e.string(),e.unknown());export const LayoutRouteSchema=e.object({pattern:e.instanceof(URLPattern),layoutPath:e.string().min(1),priority:e.number().int().min(0),type:e.enum([`root`,`nested`]),depth:e.number().int().min(0)});export const LayoutHandlerSchema=e.object({component:e.any(),loader:e.any().optional(),path:e.string().min(1),priority:e.number().int().min(0)});export const LayoutPropsSchema=e.object({children:e.any(),data:LayoutDataSchema,frontmatter:e.record(e.string(),e.any()).optional(),route:e.object({path:e.string(),params:e.record(e.string(),e.string()),query:e.instanceof(URLSearchParams)})});export const LayoutDiscoveryOptionsSchema=e.object({baseDirectory:e.string().min(1),filePattern:e.string().min(1).optional().default(`_layout.tsx`),excludeDirectories:e.array(e.string()).optional().default([]),enableWatching:e.boolean().optional().default(!1),developmentMode:e.boolean().optional().default(!1)});export const RouteInfoSchema=e.object({path:e.string(),params:e.record(e.string(),e.string()),method:e.string(),headers:e.instanceof(Headers)});export const LayoutRuleSchema=e.object({matches:e.any(),apply:e.boolean(),priority:e.number().int()});export const LayoutConfigSchema=e.object({skipLayouts:e.array(e.string()).optional(),replaceLayout:e.boolean().optional(),onlyLayouts:e.array(e.string()).optional(),customLayout:e.string().optional()});export const IslandStateSchema=e.record(e.string(),e.unknown());export const PersistentIslandPropsSchema=e.object({persistentId:e.string().min(1),children:e.any()});export const PersistentIslandContextSchema=e.object({saveState:e.any(),loadState:e.any(),clearState:e.any()});export const LayoutErrorInfoSchema=e.object({layoutPath:e.string(),errorType:e.enum([`component`,`loader`,`rendering`,`island`]),timestamp:e.number().int().positive(),componentStack:e.string().optional(),errorBoundary:e.string().optional()});export const LayoutErrorBoundaryPropsSchema=e.object({children:e.any(),fallback:e.any(),onError:e.any().optional()});export const ErrorRecoveryStrategySchema=e.object({type:e.enum([`retry`,`fallback`,`skip`,`redirect`]),maxRetries:e.number().int().positive().optional(),fallbackComponent:e.any().optional(),redirectUrl:e.url().optional()});export const StreamingLayoutPropsSchema=e.object({children:e.any(),fallback:e.any().optional(),priority:e.enum([`high`,`medium`,`low`]).default(`medium`)});export const StreamingComponentSchema=e.object({component:e.any(),fallback:e.any(),priority:e.number().int().min(0),isReady:e.any()});export const ResolvedLayoutSchema=e.object({handlers:e.array(LayoutHandlerSchema),dataLoaders:e.array(e.any()),errorBoundaries:e.array(e.any()),streamingComponents:e.array(StreamingComponentSchema),metadata:e.object({totalLayouts:e.number().int().min(0),resolutionTime:e.number().positive(),cacheHit:e.boolean()})});export const LayoutCacheSchema=e.object({resolved:e.instanceof(Map),handlers:e.instanceof(Map),data:e.instanceof(Map),ttl:e.instanceof(Map)});export const EnhancedLayoutContextSchema=LayoutContextSchema.extend({layouts:e.array(LayoutHandlerSchema),parentData:e.array(LayoutDataSchema),islandStates:e.instanceof(Map),streamingEnabled:e.boolean(),errorBoundaries:e.array(e.any())});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"../routing.js";import{FileSystemRouteSchema as e,RoutePageModuleSchema as t,RouteDiscoveryOptionsSchema as n,FileSystemRouterConfigSchema as r,MetadataSchema as i,ResolvedMetadataSchema as a}from"../routing.js";import{validate as o,safeValidate as s}from"../index.js";export const routingValidators={fileSystemRoute:t=>o(e,t,`Invalid file system route`),routePageModule:e=>o(t,e,`Invalid route page module`),routeDiscoveryOptions:e=>o(n,e,`Invalid route discovery options`),fileSystemRouterConfig:e=>o(r,e,`Invalid file system router config`),metadata:e=>o(i,e,`Invalid metadata`),resolvedMetadata:e=>o(a,e,`Invalid resolved metadata`)};export const safeRoutingValidators={fileSystemRoute:t=>s(e,t,`Invalid file system route`),routePageModule:e=>s(t,e,`Invalid route page module`),routeDiscoveryOptions:e=>s(n,e,`Invalid route discovery options`),fileSystemRouterConfig:e=>s(r,e,`Invalid file system router config`),metadata:e=>s(i,e,`Invalid metadata`),resolvedMetadata:e=>s(a,e,`Invalid resolved metadata`)};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as e}from"zod";export const RouteTypeSchema=e.enum([`static`,`dynamic`,`catch-all`,`index`,`group`]);export const FileSystemRouteSchema=e.object({pattern:e.any(),filePath:e.string().min(1),routeType:RouteTypeSchema,dynamicSegments:e.array(e.string()),priority:e.number().int().min(0),isPrivate:e.boolean(),routeGroup:e.string().optional()});export const RoutePageModuleSchema=e.object({default:e.any(),layoutConfig:e.any().optional(),generateMetadata:e.any().optional(),loader:e.any().optional(),frontmatter:e.record(e.string(),e.any()).optional()});export const RouteParamsSchema=e.record(e.string(),e.string());export const LoaderContextSchema=e.object({request:e.instanceof(Request),url:e.instanceof(URL),params:RouteParamsSchema,query:e.instanceof(URLSearchParams),state:e.instanceof(Map)});export const PagePropsSchema=e.object({params:RouteParamsSchema,query:e.instanceof(URLSearchParams),data:e.unknown().optional()});export const MetadataSchema=e.object({title:e.string().optional(),description:e.string().optional(),keywords:e.array(e.string()).optional(),openGraph:e.object({title:e.string().optional(),description:e.string().optional(),image:e.url().optional(),url:e.url().optional(),type:e.string().optional(),siteName:e.string().optional()}).optional(),twitter:e.object({card:e.enum([`summary`,`summary_large_image`,`app`,`player`]).optional(),title:e.string().optional(),description:e.string().optional(),image:e.url().optional(),site:e.string().optional()}).optional(),schema:e.array(e.record(e.string(),e.unknown())).optional(),canonical:e.url().optional(),robots:e.string().optional()});export const ResolvedMetadataSchema=MetadataSchema.extend({sources:e.array(e.string()).optional(),resolvedAt:e.number().optional()});export const MetadataChainSchema=e.object({global:MetadataSchema.optional(),sections:e.array(e.object({path:e.string(),metadata:MetadataSchema})),page:MetadataSchema.optional()});export const RouteDiscoveryOptionsSchema=e.object({pagesDirectory:e.string().min(1).default(`src/pages`),apiDirectory:e.string().min(1).default(`src/api`),extensions:e.array(e.string()).default([`.tsx`,`.ts`,`.jsx`,`.js`]),excludeDirectories:e.array(e.string()).default([`node_modules`,`.git`]),enableWatching:e.boolean().default(!1),developmentMode:e.boolean().default(!1),quietMode:e.boolean().default(!1)});export const FileSystemRouterConfigSchema=e.object({discovery:RouteDiscoveryOptionsSchema.optional(),enabled:e.boolean().default(!0),fallbackToManual:e.boolean().default(!0),enableCaching:e.boolean().default(!0),cacheTTL:e.number().positive().default(3e5)});export const PageFileSchema=e.object({filePath:e.string().min(1),relativePath:e.string().min(1),extension:e.string().min(1),isPrivate:e.boolean(),routeGroup:e.string().optional(),mtime:e.number().optional()});export const RouteHandlerSchema=e.object({pattern:e.any(),handler:e.any(),metadata:e.object({filePath:e.string(),routeType:RouteTypeSchema,priority:e.number(),dynamicSegments:e.array(e.string())})});export const RouteCacheEntrySchema=e.object({routes:e.array(FileSystemRouteSchema),timestamp:e.number(),fileMtimes:e.record(e.string(),e.number())});export const FileSystemApiRouteSchema=e.object({pattern:e.any(),filePath:e.string().min(1),methods:e.array(e.enum([`GET`,`POST`,`PUT`,`DELETE`,`PATCH`,`HEAD`,`OPTIONS`])),priority:e.number().int().min(0),dynamicSegments:e.array(e.string())});export const FileSystemApiModuleSchema=e.object({GET:e.any().optional(),POST:e.any().optional(),PUT:e.any().optional(),DELETE:e.any().optional(),PATCH:e.any().optional(),HEAD:e.any().optional(),OPTIONS:e.any().optional()});export function isFileSystemRoute(e){return FileSystemRouteSchema.safeParse(e).success}export function isRoutePageModule(e){return RoutePageModuleSchema.safeParse(e).success}export function isMetadata(e){return MetadataSchema.safeParse(e).success}export function isRouteParams(e){return RouteParamsSchema.safeParse(e).success}export function isFileSystemApiModule(e){return FileSystemApiModuleSchema.safeParse(e).success}export{isValidRouteParams,isValidPageProps,isValidRoutePattern,validatePageComponent,createTypedPageComponent,createTypedMetadataGenerator,createTypedPageLoader,createTypedApiHandler}from"../types/routing.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function asIsland(e){return e}
|
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type declarations for image imports with vite-imagetools
|
|
3
|
-
*
|
|
4
|
-
* These types enable TypeScript support for optimized image imports.
|
|
5
|
-
* Include this in your tsconfig.json `types` array:
|
|
6
|
-
*
|
|
7
|
-
* ```json
|
|
8
|
-
* {
|
|
9
|
-
* "compilerOptions": {
|
|
10
|
-
* "types": ["@useavalon/avalon/types"]
|
|
11
|
-
* }
|
|
12
|
-
* }
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
declare module "*.jpg" {
|
|
17
|
-
const src: string;
|
|
18
|
-
export default src;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
declare module "*.jpeg" {
|
|
22
|
-
const src: string;
|
|
23
|
-
export default src;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
declare module "*.png" {
|
|
27
|
-
const src: string;
|
|
28
|
-
export default src;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
declare module "*.webp" {
|
|
32
|
-
const src: string;
|
|
33
|
-
export default src;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
declare module "*.avif" {
|
|
37
|
-
const src: string;
|
|
38
|
-
export default src;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
declare module "*.gif" {
|
|
42
|
-
const src: string;
|
|
43
|
-
export default src;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
declare module "*.tiff" {
|
|
47
|
-
const src: string;
|
|
48
|
-
export default src;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
declare module "*.svg" {
|
|
52
|
-
const src: string;
|
|
53
|
-
export default src;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// vite-imagetools srcset output
|
|
57
|
-
interface ImageToolsSrcset {
|
|
58
|
-
src: string;
|
|
59
|
-
srcset: string;
|
|
60
|
-
width: number;
|
|
61
|
-
height: number;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
declare module "*&as=srcset" {
|
|
65
|
-
const srcset: ImageToolsSrcset;
|
|
66
|
-
export default srcset;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
declare module "*?as=srcset" {
|
|
70
|
-
const srcset: ImageToolsSrcset;
|
|
71
|
-
export default srcset;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// vite-imagetools picture output (multiple formats)
|
|
75
|
-
interface ImageToolsPicture {
|
|
76
|
-
sources: Record<string, ImageToolsSrcset>;
|
|
77
|
-
img: ImageToolsSrcset;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
declare module "*&as=picture" {
|
|
81
|
-
const picture: ImageToolsPicture;
|
|
82
|
-
export default picture;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
declare module "*?as=picture" {
|
|
86
|
-
const picture: ImageToolsPicture;
|
|
87
|
-
export default picture;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// vite-imagetools metadata output
|
|
91
|
-
interface ImageToolsMetadata {
|
|
92
|
-
src: string;
|
|
93
|
-
width: number;
|
|
94
|
-
height: number;
|
|
95
|
-
format: string;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
declare module "*&as=metadata" {
|
|
99
|
-
const metadata: ImageToolsMetadata;
|
|
100
|
-
export default metadata;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
declare module "*?as=metadata" {
|
|
104
|
-
const metadata: ImageToolsMetadata;
|
|
105
|
-
export default metadata;
|
|
106
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Type declarations for image imports with vite-imagetools
|
|
3
|
+
*
|
|
4
|
+
* These types enable TypeScript support for optimized image imports.
|
|
5
|
+
* Include this in your tsconfig.json `types` array:
|
|
6
|
+
*
|
|
7
|
+
* ```json
|
|
8
|
+
* {
|
|
9
|
+
* "compilerOptions": {
|
|
10
|
+
* "types": ["@useavalon/avalon/types"]
|
|
11
|
+
* }
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
declare module "*.jpg" {
|
|
17
|
+
const src: string;
|
|
18
|
+
export default src;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare module "*.jpeg" {
|
|
22
|
+
const src: string;
|
|
23
|
+
export default src;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare module "*.png" {
|
|
27
|
+
const src: string;
|
|
28
|
+
export default src;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare module "*.webp" {
|
|
32
|
+
const src: string;
|
|
33
|
+
export default src;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare module "*.avif" {
|
|
37
|
+
const src: string;
|
|
38
|
+
export default src;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
declare module "*.gif" {
|
|
42
|
+
const src: string;
|
|
43
|
+
export default src;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
declare module "*.tiff" {
|
|
47
|
+
const src: string;
|
|
48
|
+
export default src;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare module "*.svg" {
|
|
52
|
+
const src: string;
|
|
53
|
+
export default src;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// vite-imagetools srcset output
|
|
57
|
+
interface ImageToolsSrcset {
|
|
58
|
+
src: string;
|
|
59
|
+
srcset: string;
|
|
60
|
+
width: number;
|
|
61
|
+
height: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
declare module "*&as=srcset" {
|
|
65
|
+
const srcset: ImageToolsSrcset;
|
|
66
|
+
export default srcset;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
declare module "*?as=srcset" {
|
|
70
|
+
const srcset: ImageToolsSrcset;
|
|
71
|
+
export default srcset;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// vite-imagetools picture output (multiple formats)
|
|
75
|
+
interface ImageToolsPicture {
|
|
76
|
+
sources: Record<string, ImageToolsSrcset>;
|
|
77
|
+
img: ImageToolsSrcset;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
declare module "*&as=picture" {
|
|
81
|
+
const picture: ImageToolsPicture;
|
|
82
|
+
export default picture;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
declare module "*?as=picture" {
|
|
86
|
+
const picture: ImageToolsPicture;
|
|
87
|
+
export default picture;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// vite-imagetools metadata output
|
|
91
|
+
interface ImageToolsMetadata {
|
|
92
|
+
src: string;
|
|
93
|
+
width: number;
|
|
94
|
+
height: number;
|
|
95
|
+
format: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
declare module "*&as=metadata" {
|
|
99
|
+
const metadata: ImageToolsMetadata;
|
|
100
|
+
export default metadata;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
declare module "*?as=metadata" {
|
|
104
|
+
const metadata: ImageToolsMetadata;
|
|
105
|
+
export default metadata;
|
|
106
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Avalon type definitions.
|
|
3
|
-
*
|
|
4
|
-
* Include this in your tsconfig.json `types` array to get island prop support:
|
|
5
|
-
*
|
|
6
|
-
* ```json
|
|
7
|
-
* {
|
|
8
|
-
* "compilerOptions": {
|
|
9
|
-
* "types": ["@useavalon/avalon/types"]
|
|
10
|
-
* }
|
|
11
|
-
* }
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
// Re-export island prop types
|
|
16
|
-
export * from './island-prop.d.ts';
|
|
17
|
-
|
|
18
|
-
// Import JSX augmentations (side-effect import for type augmentation)
|
|
19
|
-
import './island-jsx.d.ts';
|
|
20
|
-
|
|
21
|
-
// Import image type declarations
|
|
22
|
-
import './image.d.ts';
|
|
1
|
+
/**
|
|
2
|
+
* Avalon type definitions.
|
|
3
|
+
*
|
|
4
|
+
* Include this in your tsconfig.json `types` array to get island prop support:
|
|
5
|
+
*
|
|
6
|
+
* ```json
|
|
7
|
+
* {
|
|
8
|
+
* "compilerOptions": {
|
|
9
|
+
* "types": ["@useavalon/avalon/types"]
|
|
10
|
+
* }
|
|
11
|
+
* }
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
// Re-export island prop types
|
|
16
|
+
export * from './island-prop.d.ts';
|
|
17
|
+
|
|
18
|
+
// Import JSX augmentations (side-effect import for type augmentation)
|
|
19
|
+
import './island-jsx.d.ts';
|
|
20
|
+
|
|
21
|
+
// Import image type declarations
|
|
22
|
+
import './image.d.ts';
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JSX augmentation for the `island` prop.
|
|
3
|
-
*
|
|
4
|
-
* Automatically included via tsconfig.json `compilerOptions.types`.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { IslandDirective } from './island-prop.d.ts';
|
|
8
|
-
|
|
9
|
-
declare module 'preact' {
|
|
10
|
-
namespace JSX {
|
|
11
|
-
interface IntrinsicAttributes {
|
|
12
|
-
island?: IslandDirective;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// Augment the global JSX namespace so the `island` prop is accepted on
|
|
18
|
-
// non-Preact components (Svelte, Solid) when used in a Preact JSX context.
|
|
19
|
-
declare global {
|
|
20
|
-
namespace JSX {
|
|
21
|
-
interface IntrinsicAttributes {
|
|
22
|
-
island?: IslandDirective;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Augment Vue's ComponentCustomProps so Volar accepts `island` on all Vue SFCs.
|
|
28
|
-
declare module '@vue/runtime-core' {
|
|
29
|
-
interface ComponentCustomProps {
|
|
30
|
-
island?: IslandDirective;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
1
|
+
/**
|
|
2
|
+
* JSX augmentation for the `island` prop.
|
|
3
|
+
*
|
|
4
|
+
* Automatically included via tsconfig.json `compilerOptions.types`.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { IslandDirective } from './island-prop.d.ts';
|
|
8
|
+
|
|
9
|
+
declare module 'preact' {
|
|
10
|
+
namespace JSX {
|
|
11
|
+
interface IntrinsicAttributes {
|
|
12
|
+
island?: IslandDirective;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Augment the global JSX namespace so the `island` prop is accepted on
|
|
18
|
+
// non-Preact components (Svelte, Solid) when used in a Preact JSX context.
|
|
19
|
+
declare global {
|
|
20
|
+
namespace JSX {
|
|
21
|
+
interface IntrinsicAttributes {
|
|
22
|
+
island?: IslandDirective;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Augment Vue's ComponentCustomProps so Volar accepts `island` on all Vue SFCs.
|
|
28
|
+
declare module '@vue/runtime-core' {
|
|
29
|
+
interface ComponentCustomProps {
|
|
30
|
+
island?: IslandDirective;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type augmentation for the `island` prop on island components.
|
|
3
|
-
*
|
|
4
|
-
* When importing a component from the islands directory and using it in a page,
|
|
5
|
-
* you can pass an `island` prop to control hydration behavior. The Vite transform
|
|
6
|
-
* plugin intercepts this at build time and converts it to a renderIsland() call.
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* import Counter from '../islands/Counter.tsx';
|
|
10
|
-
* <Counter island={{ condition: 'on:interaction' }} someProp={42} />
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
export interface IslandDirective {
|
|
14
|
-
/** Hydration condition */
|
|
15
|
-
condition?: 'on:visible' | 'on:interaction' | 'on:idle' | 'on:client' | `media:${string}`;
|
|
16
|
-
/** Force SSR-only rendering without client hydration */
|
|
17
|
-
ssrOnly?: boolean;
|
|
18
|
-
/** Whether to render server-side (default: true) */
|
|
19
|
-
ssr?: boolean;
|
|
20
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Type augmentation for the `island` prop on island components.
|
|
3
|
+
*
|
|
4
|
+
* When importing a component from the islands directory and using it in a page,
|
|
5
|
+
* you can pass an `island` prop to control hydration behavior. The Vite transform
|
|
6
|
+
* plugin intercepts this at build time and converts it to a renderIsland() call.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* import Counter from '../islands/Counter.tsx';
|
|
10
|
+
* <Counter island={{ condition: 'on:interaction' }} someProp={42} />
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export interface IslandDirective {
|
|
14
|
+
/** Hydration condition */
|
|
15
|
+
condition?: 'on:visible' | 'on:interaction' | 'on:idle' | 'on:client' | `media:${string}`;
|
|
16
|
+
/** Force SSR-only rendering without client hydration */
|
|
17
|
+
ssrOnly?: boolean;
|
|
18
|
+
/** Whether to render server-side (default: true) */
|
|
19
|
+
ssr?: boolean;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{LayoutDiscovery}from"../core/layout/layout-discovery.js";export{LayoutDataLoader}from"../core/layout/layout-data-loader.js";export{LayoutMatcher as LayoutMatcherClass}from"../core/layout/layout-matcher.js";export{LayoutComposer}from"../core/layout/layout-composer.js";export{IslandPersistence,defaultIslandPersistence}from"../core/islands/island-persistence.js";export{IslandStateSerializer}from"../core/islands/island-state-serializer.js";export{createPersistentIslandContext,usePersistentIslandContext,PersistentIslandProvider}from"../core/islands/persistent-island-context.js";export{PersistentIsland}from"../components/PersistentIsland.js";export{LayoutErrorBoundary}from"../components/LayoutErrorBoundary.js";export{LayoutDataErrorBoundary}from"../components/LayoutDataErrorBoundary.js";export{IslandErrorBoundary,withIslandErrorBoundary}from"../components/IslandErrorBoundary.js";export{StreamingLayout,StreamingSuspense,withStreaming,useStreamingState}from"../components/StreamingLayout.js";export{EnhancedLayoutResolver,createEnhancedLayoutResolver,EnhancedLayoutResolverUtils}from"../core/layout/enhanced-layout-resolver.js";export{LayoutCacheManager}from"../core/layout/layout-cache-manager.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ComponentType } from 'preact';
|
|
2
|
-
|
|
3
|
-
declare module '*.mdx' {
|
|
4
|
-
const MDXComponent: ComponentType<Record<string, unknown>>;
|
|
5
|
-
export default MDXComponent;
|
|
6
|
-
}
|
|
1
|
+
import type { ComponentType } from 'preact';
|
|
2
|
+
|
|
3
|
+
declare module '*.mdx' {
|
|
4
|
+
const MDXComponent: ComponentType<Record<string, unknown>>;
|
|
5
|
+
export default MDXComponent;
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as e}from"preact";import t from"node:process";export function isValidRouteParams(e,t){if(!e||typeof e!=`object`)return!1;let n=e;for(let e of t){let t=n[e];if(t===void 0||typeof t!=`string`&&!Array.isArray(t)||Array.isArray(t)&&!t.every(e=>typeof e==`string`))return!1}return!0}export function isValidPageProps(e,t){if(!e||typeof e!=`object`)return!1;let r=e;return!(!r.params||!r.query||!isValidRouteParams(r.params,t)||!(r.query instanceof URLSearchParams))}export function isValidRoutePattern(e){let t=e.match(/\[([^\]]+)\]/g);if(t)for(let e of t){let t=e.slice(1,-1);if(!/^[a-zA-Z_]\w*(\?)?$/.test(t)&&!/^\.\.\.[a-zA-Z_]\w*$/.test(t))return!1}let n=e.match(/\(([^)]+)\)/g);if(n)for(let e of n){let t=e.slice(1,-1);if(!/^[a-zA-Z_]\w*-*\w*$/.test(t))return!1}return!0}export function createTypedPageComponent(n,i){return a=>(t.env?.NODE_ENV===`development`&&(isValidPageProps(a,i)||console.warn(`Invalid props passed to typed page component:`,a)),e(n,a))}export function createTypedMetadataGenerator(e,r){return async i=>(t.env?.NODE_ENV===`development`&&(isValidRouteParams(i,r)||console.warn(`Invalid params passed to typed metadata generator:`,i)),await e(i))}export function createTypedPageLoader(e,r){return async i=>(t.env?.NODE_ENV===`development`&&(isValidRouteParams(i.params,r)||console.warn(`Invalid params passed to typed page loader:`,i.params)),await e(i))}export function validatePageComponent(e,t){return typeof e==`function`}export function createTypedApiHandler(e,r){return async(i,a)=>(t.env?.NODE_ENV===`development`&&(isValidRouteParams(a.params,r)||console.warn(`Invalid params passed to typed API handler:`,a.params)),await e(i,a))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./layout.js";
|