@useavalon/avalon 0.1.48 → 0.1.50
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/mod.d.ts +48 -48
- package/dist/mod.js +1 -1
- package/dist/src/build/page-island-transform.d.ts +1 -1
- package/dist/src/build/page-island-transform.js +2 -3
- package/dist/src/client/components.d.ts +8 -8
- package/dist/src/client/components.js +1 -1
- package/dist/src/components/IslandErrorBoundary.d.ts +2 -2
- package/dist/src/components/IslandErrorBoundary.js +1 -1
- package/dist/src/components/LayoutErrorBoundary.d.ts +3 -3
- package/dist/src/components/LayoutErrorBoundary.js +1 -1
- package/dist/src/islands/integration-loader.d.ts +2 -2
- package/dist/src/islands/island.d.ts +7 -7
- package/dist/src/islands/island.js +1 -1
- package/dist/src/layout-system.d.ts +14 -17
- package/dist/src/layout-system.js +1 -1
- package/dist/src/nitro/config.d.ts +13 -0
- package/dist/src/nitro/renderer.d.ts +21 -11
- package/dist/src/nitro/renderer.js +20 -20
- package/dist/src/persistence/island-state-serializer.d.ts +9 -19
- package/dist/src/persistence/island-state-serializer.js +1 -1
- package/dist/src/persistence/use-persistent-state.d.ts +2 -2
- package/dist/src/persistence/use-persistent-state.js +1 -1
- package/dist/src/post-build/index.d.ts +57 -0
- package/dist/src/post-build/index.js +31 -0
- package/dist/src/schemas/core.d.ts +2 -2
- package/dist/src/schemas/layout.d.ts +4 -4
- package/dist/src/schemas/routing/index.d.ts +2 -2
- package/dist/src/schemas/routing.d.ts +4 -4
- package/dist/src/types/index.d.ts +8 -5
- package/dist/src/types/island-prop.d.ts +14 -8
- package/dist/src/types/layout.d.ts +11 -11
- package/dist/src/types/layout.js +1 -1
- package/dist/src/types/virtual-modules.d.ts +56 -0
- package/dist/src/vite-plugin/nitro-integration.d.ts +8 -0
- package/dist/src/vite-plugin/nitro-integration.js +15 -10
- package/package.json +6 -2
package/dist/mod.d.ts
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type {
|
|
3
|
-
export {
|
|
4
|
-
export type {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export
|
|
11
|
-
export {
|
|
12
|
-
export
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export
|
|
16
|
-
export {
|
|
17
|
-
export type {
|
|
18
|
-
export {
|
|
19
|
-
export type { PreloadIntegrationsOptions } from
|
|
20
|
-
export {
|
|
21
|
-
export
|
|
22
|
-
export {
|
|
23
|
-
export
|
|
24
|
-
export {
|
|
25
|
-
export
|
|
26
|
-
export {
|
|
27
|
-
export type {
|
|
28
|
-
export type {
|
|
29
|
-
export {
|
|
30
|
-
export {
|
|
31
|
-
export type {
|
|
1
|
+
export type { Integration, IntegrationConfig, RenderParams as IntegrationRenderParams, RenderResult, } from "@useavalon/core";
|
|
2
|
+
export type { ExtendedIslandEntry, ExtendedIslandManifest, IslandEntry, IslandManifest, } from "./src/build/island-manifest.ts";
|
|
3
|
+
export { generateIslandManifest, getIslandBundlePath, loadIslandManifest, } from "./src/build/island-manifest.ts";
|
|
4
|
+
export type { IslandTypeGeneratorOptions, TypeGenerationResult, } from "./src/build/island-types-generator.ts";
|
|
5
|
+
export { generateIslandTypes, watchAndGenerateTypes } from "./src/build/island-types-generator.ts";
|
|
6
|
+
export type { MDXIslandTransformOptions } from "./src/build/mdx-island-transform.ts";
|
|
7
|
+
export { mdxIslandTransform } from "./src/build/mdx-island-transform.ts";
|
|
8
|
+
export type { PageIslandTransformOptions } from "./src/build/page-island-transform.ts";
|
|
9
|
+
export { pageIslandTransform } from "./src/build/page-island-transform.ts";
|
|
10
|
+
export { registry as integrationRegistry } from "./src/core/integrations/registry.ts";
|
|
11
|
+
export { registerBuiltinDirectives } from "./src/islands/builtin-directives.ts";
|
|
12
|
+
export { analyzeComponentFile, renderComponentSSROnly } from "./src/islands/component-analysis.ts";
|
|
13
|
+
export { addSvelteSSRCSS, clearSvelteComponentCSS, generateComponentScopeId, getSvelteComponentCSS, getSvelteSSRCSS, getSvelteSSRCSSForHead, getSvelteSSRCSSStats, } from "./src/islands/css-utils.ts";
|
|
14
|
+
export type { CircularDependency, DiscoveredIsland, ImportPathOptions, IslandChangeCallback, IslandChangeEvent, IslandCollision, IslandDirectory, IslandDiscoveryConfig, IslandFileExtension, IslandWatcherOptions, ResolutionResult, ValidationError, ValidationResult, ValidationWarning, } from "./src/islands/discovery/index.ts";
|
|
15
|
+
export { createIslandRegistry, createIslandResolver, createIslandValidator, createIslandWatcher, DEFAULT_DISCOVERY_CONFIG, discoverAllIslands, discoverIslandDirectories, discoverIslandsInDirectory, formatCircularDependency, formatValidationError, formatValidationResult, formatValidationWarning, getDefaultIslandsPath, getQualifiedIslandName, hasDefaultIslandsDirectory, ISLAND_FILE_EXTENSIONS, IslandRegistry, IslandResolver, IslandValidator, IslandWatcher, isIslandsDirectory, isSupportedIslandExtension, parseQualifiedIslandName, validateAllIslands, } from "./src/islands/discovery/index.ts";
|
|
16
|
+
export { detectFramework, detectFrameworkFromSrc, resolveIslandPath, } from "./src/islands/framework-detection.ts";
|
|
17
|
+
export type { HydrationDirectiveDefinition, HydrationDirectiveFn, } from "./src/islands/hydration-directives.ts";
|
|
18
|
+
export { getDirective, getRegisteredDirectives, isCustomDirective, registerHydrationDirective, unregisterHydrationDirective, } from "./src/islands/hydration-directives.ts";
|
|
19
|
+
export type { PreloadIntegrationsOptions } from "./src/islands/integration-loader.ts";
|
|
20
|
+
export { DEFAULT_PRELOAD_FRAMEWORKS, detectAndLoadIntegration, detectFrameworksFromPageContent, loadIntegration, preloadIntegrations, } from "./src/islands/integration-loader.ts";
|
|
21
|
+
export { default as Island, type IslandProps, renderIsland } from "./src/islands/island.tsx";
|
|
22
|
+
export type { CacheConfig as IslandCacheConfig, CacheStats as IslandCacheStats, } from "./src/islands/render-cache.ts";
|
|
23
|
+
export { clearCache, clearIslandCache, configureCache, getCacheConfig, getCacheStats, invalidateCacheForFile, invalidateCacheForPath, logCacheStats, } from "./src/islands/render-cache.ts";
|
|
24
|
+
export type { Framework, RenderParams, SvelteSSRCSSEntry } from "./src/islands/types.ts";
|
|
25
|
+
export { renderToHtml } from "./src/render/ssr.ts";
|
|
26
|
+
export { asIsland } from "./src/types/as-island.ts";
|
|
27
|
+
export type { IslandDirective } from "./src/types/island-prop.d.ts";
|
|
28
|
+
export type { NitroCoordinationPluginOptions, NitroIntegrationResult, } from "./src/vite-plugin/nitro-integration.ts";
|
|
29
|
+
export { createNitroCoordinationPlugin, createNitroIntegration, createVirtualModulesPlugin, getAvalonConfig, getViteDevServer, isDevelopmentMode, RESOLVED_VIRTUAL_IDS, VIRTUAL_MODULE_IDS, } from "./src/vite-plugin/nitro-integration.ts";
|
|
30
|
+
export { avalon, getLayoutsDir, getNitroConfig, getPagesDir, getResolvedConfig, isNitroEnabled, } from "./src/vite-plugin/plugin.ts";
|
|
31
|
+
export type { AvalonNitroConfig, AvalonPluginConfig, AvalonRuntimeConfig, CacheOptions, IntegrationName, MDXConfig, NitroConfigOutput, ResolvedAvalonConfig, ResolvedMDXConfig, RouteRule, } from "./src/vite-plugin/types.ts";
|
|
32
32
|
export declare function build(_options?: Record<string, unknown>): Promise<void>;
|
|
33
|
-
export {
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
-
export
|
|
37
|
-
export type {
|
|
38
|
-
export type {
|
|
39
|
-
export type { LayoutDataLoadingResult,
|
|
40
|
-
export type {
|
|
41
|
-
export
|
|
42
|
-
export
|
|
43
|
-
export type {
|
|
44
|
-
export type {
|
|
45
|
-
export {
|
|
46
|
-
export type {
|
|
47
|
-
export {
|
|
48
|
-
export type { LayoutErrorBoundaryProps
|
|
49
|
-
export {
|
|
33
|
+
export type { IslandErrorBoundaryProps } from "./src/components/IslandErrorBoundary.tsx";
|
|
34
|
+
export { IslandErrorBoundary, withIslandErrorBoundary, } from "./src/components/IslandErrorBoundary.tsx";
|
|
35
|
+
export type { LayoutErrorBoundaryProps as LayoutErrorBoundaryComponentProps } from "./src/components/LayoutErrorBoundary.tsx";
|
|
36
|
+
export { LayoutErrorBoundary } from "./src/components/LayoutErrorBoundary.tsx";
|
|
37
|
+
export type { EnhancedLayoutResolverOptions } from "./src/core/layout/enhanced-layout-resolver.ts";
|
|
38
|
+
export type { CacheConfig, CacheEntry, CacheStats, } from "./src/core/layout/layout-cache-manager.ts";
|
|
39
|
+
export type { LayoutDataLoadingOptions, LayoutDataLoadingResult, } from "./src/core/layout/layout-data-loader.ts";
|
|
40
|
+
export type { LayoutCache, LayoutConfig, LayoutContext, LayoutData, LayoutDiscoveryOptions, LayoutErrorInfo, LayoutHandler, LayoutLoader, LayoutProps, LayoutRoute, LayoutRule, ResolvedLayout, RouteInfo, } from "./src/core/layout/layout-types.ts";
|
|
41
|
+
export * from "./src/layout-system.ts";
|
|
42
|
+
export { clearDiscoveryCache, clearMiddlewareCache, discoverScopedMiddleware, executeScopedMiddleware, getContextValue, getMatchingMiddleware, getMiddlewareCacheSize, hasContextValue, invalidateMiddleware, setContextValue, } from "./src/middleware/index.ts";
|
|
43
|
+
export type { MiddlewareDiscoveryOptions, MiddlewareExecutorOptions, MiddlewareFileExport, MiddlewareHandler, MiddlewareRoute, } from "./src/middleware/types.ts";
|
|
44
|
+
export type { MiddlewareContext } from "./src/nitro/middleware-adapter.ts";
|
|
45
|
+
export { usePersistentState } from "./src/persistence/use-persistent-state.ts";
|
|
46
|
+
export type { ApiMethod, ApiRoute } from "./src/schemas/api.ts";
|
|
47
|
+
export type { MetaTag, RenderOptions, ScriptConfig } from "./src/schemas/core.ts";
|
|
48
|
+
export type { EnhancedLayoutContext, ErrorRecoveryStrategy, IslandState, IslandStateClearer, IslandStateLoader, IslandStateSaver, LayoutErrorBoundaryProps, LayoutErrorHandler, LayoutFallbackRenderer, LayoutMatcherFunction, LayoutRetryFunction, PersistentIslandContext, PersistentIslandProps, StreamingComponent, StreamingLayoutProps, StreamingReadyCheck, } from "./src/schemas/layout.ts";
|
|
49
|
+
export type { IEnhancedLayoutResolver, IIslandPersistence, ILayoutComponent, ILayoutComposer, ILayoutDiscovery, ILayoutErrorBoundaryComponent, ILayoutErrorRecovery, ILayoutEventEmitter, ILayoutMatcher, ILayoutStreaming, IPersistentIslandComponent, IStreamingLayoutComponent, LayoutDebugInfo, LayoutEventData, LayoutEventHandler, LayoutEventType, LayoutModule, LayoutPerformanceMetrics, LayoutResolutionContext, PageModule, } from "./src/types/layout.ts";
|
package/dist/mod.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{generateIslandManifest,getIslandBundlePath,loadIslandManifest}from"./src/build/island-manifest.js";export{generateIslandTypes,watchAndGenerateTypes}from"./src/build/island-types-generator.js";export{mdxIslandTransform}from"./src/build/mdx-island-transform.js";export{pageIslandTransform}from"./src/build/page-island-transform.js";export{registry as integrationRegistry}from"./src/core/integrations/registry.js";export{registerBuiltinDirectives}from"./src/islands/builtin-directives.js";export{analyzeComponentFile,renderComponentSSROnly}from"./src/islands/component-analysis.js";export{addSvelteSSRCSS,clearSvelteComponentCSS,generateComponentScopeId,getSvelteComponentCSS,getSvelteSSRCSS,getSvelteSSRCSSForHead,getSvelteSSRCSSStats}from"./src/islands/css-utils.js";export{createIslandRegistry,createIslandResolver,createIslandValidator,createIslandWatcher,DEFAULT_DISCOVERY_CONFIG,discoverAllIslands,discoverIslandDirectories,discoverIslandsInDirectory,formatCircularDependency,formatValidationError,formatValidationResult,formatValidationWarning,getDefaultIslandsPath,getQualifiedIslandName,hasDefaultIslandsDirectory,ISLAND_FILE_EXTENSIONS,IslandRegistry,IslandResolver,IslandValidator,IslandWatcher,isIslandsDirectory,isSupportedIslandExtension,parseQualifiedIslandName,validateAllIslands}from"./src/islands/discovery/index.js";export{detectFramework,detectFrameworkFromSrc,resolveIslandPath}from"./src/islands/framework-detection.js";export{getDirective,getRegisteredDirectives,isCustomDirective,registerHydrationDirective,unregisterHydrationDirective}from"./src/islands/hydration-directives.js";export{DEFAULT_PRELOAD_FRAMEWORKS,detectAndLoadIntegration,detectFrameworksFromPageContent,loadIntegration,preloadIntegrations}from"./src/islands/integration-loader.js";export{default as Island,renderIsland}from"./src/islands/island.js";export{clearCache,clearIslandCache,configureCache,getCacheConfig,getCacheStats,invalidateCacheForFile,invalidateCacheForPath,logCacheStats}from"./src/islands/render-cache.js";export{renderToHtml}from"./src/render/ssr.js";export{asIsland}from"./src/types/as-island.js";export{createNitroCoordinationPlugin,createNitroIntegration,createVirtualModulesPlugin,getAvalonConfig,getViteDevServer,isDevelopmentMode,RESOLVED_VIRTUAL_IDS,VIRTUAL_MODULE_IDS}from"./src/vite-plugin/nitro-integration.js";export{avalon,getLayoutsDir,getNitroConfig,getPagesDir,getResolvedConfig,isNitroEnabled}from"./src/vite-plugin/plugin.js";export async function build(e){throw Error("avalon build() is not available in the published package. Use `vite build` or the Avalon CLI instead.")}export{IslandErrorBoundary,withIslandErrorBoundary}from"./src/components/IslandErrorBoundary.js";export{LayoutErrorBoundary}from"./src/components/LayoutErrorBoundary.js";export*from"./src/layout-system.js";export{clearDiscoveryCache,clearMiddlewareCache,discoverScopedMiddleware,executeScopedMiddleware,getContextValue,getMatchingMiddleware,getMiddlewareCacheSize,hasContextValue,invalidateMiddleware,setContextValue}from"./src/middleware/index.js";export{usePersistentState}from"./src/persistence/use-persistent-state.js";
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*
|
|
24
24
|
* Only applies to files inside the configured pages or layouts directories.
|
|
25
25
|
*/
|
|
26
|
-
import type { Plugin } from
|
|
26
|
+
import type { Plugin } from "vite";
|
|
27
27
|
export interface PageIslandTransformOptions {
|
|
28
28
|
/** Directory containing page files (default: src/pages/) */
|
|
29
29
|
pagesDir?: string;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import{dirname as e}from"node:path";function t(e){let t=[],n=/^[ \t]*import\s+([A-Z]\w*)\s+from\s+(['"][^'"]+['"])/gm,r;for(
|
|
2
|
-
`,s),n=t===-1?e.length:t+1;o+=e.slice(s,n),s=n;continue}if(e[s]===`/`&&e[s+1]===`*`){let t=e.indexOf(`*/`,s+2),n=t===-1?e.length:t+2;o+=e.slice(s,n),s=n;continue}if(!x(e,s,a)){o+=e[s],s++;continue}let c=y(e,s,t);if(!c||!c.islandProp&&!i){let t=c?c.endIdx:s+1;o+=e.slice(s,t),s=t;continue}o+=b(c,n,r,i&&!c.islandProp,t),s=c.endIdx}return o}export function pageIslandTransform(e={}){let{pagesDir:n=`src/pages`,layoutsDir:r=`src/layouts`,modules:o=null}=e;return{name:`avalon:page-island-transform`,enforce:`pre`,transform(e,s){let d=a(s,r,o);if(!i(s,n,o)&&!d)return null;let f=t(e);if(f.length===0||!c(e,f.map(e=>e.localName))&&!l(e,f))return null;let p=u(e,f,s);if(p.size===0)return null;let m=`import { renderIsland as __pageRenderIsland } from '@useavalon/avalon';
|
|
3
|
-
`+e;for(let[e,t]of p)m=S(m,e,t.srcPath,t.framework,t.autoIsland);return{code:m,map:null}}}}
|
|
1
|
+
import{dirname as e}from"node:path";function t(e){let t=[],n=/^[ \t]*import\s+([A-Z]\w*)\s+from\s+(['"][^'"]+['"])/gm,r=null;for(r=n.exec(e);r!==null;r=n.exec(e))t.push({localName:r[1],importPath:r[2].slice(1,-1),fullMatch:r[0].trimStart()});return t}function n(t,n){if(t.startsWith(`/src/`)||t.startsWith(`/app/`)||t.startsWith(`/`))return t;if(t.startsWith(`@/`))return`/app/${t.slice(2)}`;if(t.startsWith(`@shared/`))return`/app/shared/${t.slice(8)}`;if(t.startsWith(`@modules/`))return`/app/modules/${t.slice(9)}`;if(t.startsWith(`$components/`))return`/src/components/${t.slice(12)}`;if(t.startsWith(`$islands/`))return`/src/islands/${t.slice(9)}`;if(t.startsWith(`~/`))return`/src/${t.slice(2)}`;if(t.startsWith(`.`)){let r=n.replaceAll(`\\`,`/`),i=r.indexOf(`/app/`);if(i===-1&&(i=r.indexOf(`/src/`)),i!==-1){let n=e(r.slice(i)).split(`/`),a=t.split(`/`);for(let e of a)e===`..`?n.pop():e!==`.`&&n.push(e);return n.join(`/`)}}return`/src/${t.split(`/`).pop()}`}function r(e){if(e.endsWith(`.vue`))return`vue`;if(e.endsWith(`.svelte`))return`svelte`;if(e.includes(`.solid.`))return`solid`;if(e.includes(`.lit.`))return`lit`;if(e.includes(`.qwik.`))return`qwik`;if(e.includes(`.react.`))return`react`;if(e.endsWith(`.tsx`)||e.endsWith(`.jsx`))return`preact`}function i(e,t,n){let r=e.replaceAll(`\\`,`/`),i=t.replace(/^\//,``);if(r.includes(`/${i}/`)&&/\.(tsx|jsx)$/.test(r))return!0;if(n){let e=n.dir.replace(/^\//,``);if(RegExp(`/${e}/[^/]+/${n.pagesDirName}/`).test(r)&&/\.(tsx|jsx)$/.test(r))return!0}return!1}function a(e,t,n){let r=e.replaceAll(`\\`,`/`),i=t.replace(/^\//,``);if(r.includes(`/${i}/`)&&/\.(tsx|jsx)$/.test(r))return!0;if(n){let e=n.dir.replace(/^\//,``);if(RegExp(`/${e}/[^/]+/${n.layoutsDirName}/`).test(r)&&/\.(tsx|jsx)$/.test(r))return!0}return!1}const o=new Set([`qwik`]);function s(e){let t=r(e);return t!==void 0&&o.has(t)}function c(e,t){return t.some(t=>RegExp(`<${t}${String.raw`[\s][^>]*island[\s]*[={]`}`).test(e))}function l(e,t){return t.some(t=>s(t.importPath)?RegExp(`<${t.localName}${String.raw`[\s/>]`}`).test(e):!1)}function u(e,t,i){let a=new Map;for(let s of t){let t=n(s.importPath,i),c=r(t);if(RegExp(`<${s.localName}${String.raw`[\s][^>]*island[\s]*[={]`}`).test(e)){a.set(s.localName,{srcPath:t,framework:c,importPath:s.importPath,autoIsland:!1});continue}c&&o.has(c)&&RegExp(`<${s.localName}${String.raw`[\s/>]`}`).test(e)&&a.set(s.localName,{srcPath:t,framework:c,importPath:s.importPath,autoIsland:!0})}return a}function d(e,t){for(;t<e.length&&/\s/.test(e[t]);)t++;return t}function f(e,t){let n=e[t];for(t++;t<e.length&&e[t]!==n;)e[t]===`\\`&&t++,t++;return t<e.length?t+1:t}function p(e,t){for(t++;t<e.length&&e[t]!=="`";){if(e[t]===`\\`){t+=2;continue}if(e[t]===`$`&&e[t+1]===`{`){t=m(t+1,e);continue}t++}return t<e.length?t+1:t}function m(e,t){let n=e+1,r=1;for(;n<t.length&&r>0;){let e=t[n];e===`{`?(r++,n++):e===`}`?(r--,r>0&&n++):e===`'`||e===`"`||e==="`"?n=f(t,n):n++}return n<t.length?n+1:n}function h(e,t){let n=t+1,r=m(t,e);return{value:e.slice(n,r-1),endIdx:r}}function g(e,t){let n=e[t],r=t+1;for(;r<e.length&&e[r]!==n;)e[r]===`\\`&&r++,r++;return{value:`"${e.slice(t+1,r)}"`,endIdx:r+1}}function _(e,t){let n=t,r=t;for(;r<e.length&&/[a-zA-Z0-9_$]/.test(e[r]);)r++;let i=e.slice(n,r);if(!i)return null;if(r=d(e,r),e[r]!==`=`)return{name:i,value:null,endIdx:r};if(r=d(e,r+1),e[r]===`{`){let t=h(e,r);return{name:i,value:t.value,endIdx:t.endIdx}}if(e[r]===`"`||e[r]===`'`){let t=g(e,r);return{name:i,value:t.value,endIdx:t.endIdx}}return null}function v(e,t,n){if(e[t]===`/`&&e[t+1]===`>`)return{endIdx:t+2,selfClosing:!0};if(e[t]===`>`){let r=`</${n}>`,i=e.indexOf(r,t+1);return i===-1?null:{endIdx:i+r.length,selfClosing:!1}}return null}function y(e,t,n){let r=d(e,t+1+n.length),i=null,a=[];for(;r<e.length;){r=d(e,r);let t=v(e,r,n);if(t)return{endIdx:t.endIdx,islandProp:i,otherProps:a};let o=_(e,r);if(!o)return null;if(r=o.endIdx,o.name===`island`)i=o.value??`{}`;else{let e=o.value===null?`${o.name}: true`:`${o.name}: ${o.value}`;a.push(e)}}return null}function b(e,t,n,r,i){let a=n?`, framework: "${n}"`:``,o=e.otherProps.length>0?`, props: { ${e.otherProps.join(`, `)} }`:``,s=`, component: ${i}`;if(r)return`{await __pageRenderIsland({ src: "`+t+`"`+a+s+o+`, ssr: true, ssrOnly: true })}`;let c=e.islandProp??``;return`{await __pageRenderIsland({ src: "`+t+`"`+a+s+`, ...(`+c+`)`+o+`, ssr: (`+c+`).ssr !== undefined ? (`+c+`).ssr : true })}`}function x(e,t,n){if(!e.startsWith(n,t))return!1;let r=t+n.length;return r>=e.length||!/[a-zA-Z0-9_$]/.test(e[r])}function S(e,t,n,r,i){let a=`<${t}`,o=``,s=0;for(;s<e.length;){if(e[s]==="`"){let t=s;s=p(e,s),o+=e.slice(t,s);continue}if(e[s]===`{`&&e[s+1]===`/`&&e[s+2]===`*`){let t=e.indexOf(`*/`,s+3);if(t!==-1){let n=t+2;for(;n<e.length&&/\s/.test(e[n]);)n++;if(n<e.length&&e[n]===`}`){o+=e.slice(s,n+1),s=n+1;continue}}}if(e[s]===`/`&&e[s+1]===`/`){let t=e.indexOf(`
|
|
2
|
+
`,s),n=t===-1?e.length:t+1;o+=e.slice(s,n),s=n;continue}if(e[s]===`/`&&e[s+1]===`*`){let t=e.indexOf(`*/`,s+2),n=t===-1?e.length:t+2;o+=e.slice(s,n),s=n;continue}if(!x(e,s,a)){o+=e[s],s++;continue}let c=y(e,s,t);if(!c||!c.islandProp&&!i){let t=c?c.endIdx:s+1;o+=e.slice(s,t),s=t;continue}o+=b(c,n,r,i&&!c.islandProp,t),s=c.endIdx}return o}export function pageIslandTransform(e={}){let{pagesDir:n=`src/pages`,layoutsDir:r=`src/layouts`,modules:o=null}=e;return{name:`avalon:page-island-transform`,enforce:`pre`,transform(e,s){let d=a(s,r,o);if(!i(s,n,o)&&!d)return null;let f=t(e);if(f.length===0||!c(e,f.map(e=>e.localName))&&!l(e,f))return null;let p=u(e,f,s);if(p.size===0)return null;let m=`import { renderIsland as __pageRenderIsland } from '@useavalon/avalon';\n${e}`;for(let[e,t]of p)m=S(m,e,t.srcPath,t.framework,t.autoIsland);return{code:m,map:null}}}}
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Image optimization, error boundaries, and persistent state for islands.
|
|
5
5
|
*/
|
|
6
|
-
export {
|
|
7
|
-
export
|
|
8
|
-
export {
|
|
9
|
-
export
|
|
10
|
-
export {
|
|
11
|
-
export
|
|
12
|
-
export { usePersistentState } from
|
|
13
|
-
export { registerClientDirective } from
|
|
6
|
+
export type { ImageProps } from "../components/Image.tsx";
|
|
7
|
+
export { Image } from "../components/Image.tsx";
|
|
8
|
+
export type { IslandErrorBoundaryProps } from "../components/IslandErrorBoundary.tsx";
|
|
9
|
+
export { IslandErrorBoundary, withIslandErrorBoundary, } from "../components/IslandErrorBoundary.tsx";
|
|
10
|
+
export type { LayoutErrorBoundaryProps } from "../components/LayoutErrorBoundary.tsx";
|
|
11
|
+
export { LayoutErrorBoundary } from "../components/LayoutErrorBoundary.tsx";
|
|
12
|
+
export { usePersistentState } from "../persistence/use-persistent-state.ts";
|
|
13
|
+
export { registerClientDirective } from "./custom-directives.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{Image}from"../components/Image.tsx";export{IslandErrorBoundary,withIslandErrorBoundary}from"../components/IslandErrorBoundary.tsx";export{LayoutDataErrorBoundary}from"../components/LayoutDataErrorBoundary.tsx";export{LayoutErrorBoundary}from"../components/LayoutErrorBoundary.tsx";export{PersistentIsland}from"../components/PersistentIsland.tsx";export{StreamingErrorBoundary,withStreamingErrorBoundary}from"../components/StreamingErrorBoundary.tsx";export{StreamingLayout,StreamingSuspense,useStreamingState,withStreaming}from"../components/StreamingLayout.tsx";export{defaultIslandPersistence,IslandPersistence}from"../core/islands/island-persistence.js";export{IslandStateSerializer}from"../core/islands/island-state-serializer.js";export{createPersistentIslandContext,PersistentIslandProvider,usePersistentIslandContext}from"../core/islands/persistent-island-context.tsx";export{usePersistentState}from"../core/islands/use-persistent-state.js";export{registerClientDirective}from"./custom-directives.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @jsxImportSource preact */
|
|
2
|
-
import { Component, type ComponentChildren, type ComponentType } from
|
|
3
|
-
import type { LayoutErrorInfo } from
|
|
2
|
+
import { Component, type ComponentChildren, type ComponentType } from "preact";
|
|
3
|
+
import type { LayoutErrorInfo } from "../schemas/layout.ts";
|
|
4
4
|
/**
|
|
5
5
|
* Props for {@link IslandErrorBoundary}.
|
|
6
6
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Component as e}from"preact";import{jsx as t,jsxs as n}from"preact/jsx-runtime";export class IslandErrorBoundary extends e{constructor(e){super(e),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){let n={layoutPath:`island:${this.props.islandId}`,errorType:`island`,timestamp:Date.now(),componentStack:t.componentStack,errorBoundary:`IslandErrorBoundary`};if(this.setState({errorInfo:n}),this.props.onError?.(e,n),!this.props.isolateError)throw e}handleRemoveIsland=()=>{document.querySelector(`[data-island-id="${this.props.islandId}"]`)?.remove()};handleReloadIsland=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};render(){if(!this.state.hasError)return this.props.children;let{error:e}=this.state,{fallback:r,islandId:i}=this.props;if(r&&e)return r(e,i);let a=typeof process<`u`&&process.env?.NODE_ENV===`development`;return t(`div`,{className:`island-error-boundary`,"data-island-error":i,children:n(`div`,{className:`island-error-container`,children:[n(`div`,{className:`island-error-header`,children:[t(`span`,{className:`island-error-icon`,children:`⚠️`}),t(`span`,{className:`island-error-title`,children:`Island Error`})]}),n(`p`,{className:`island-error-message`,children:[`An error occurred in island "`,i,`".`]}),n(`div`,{className:`island-error-actions`,children:[t(`button`,{onClick:this.handleReloadIsland,className:`island-reload-button`,children:`Reload Island`}),t(`button`,{onClick:this.handleRemoveIsland,className:`island-remove-button`,children:`Remove Island`})]}),a&&e&&n(`details`,{className:`island-error-details`,children:[t(`summary`,{children:`Error Details (Development)`}),n(`p`,{children:[t(`strong`,{children:`Island ID:`}),` `,i]}),n(`p`,{children:[t(`strong`,{children:`Error:`}),` `,e.message]}),t(`pre`,{className:`island-error-stack`,children:e.stack})]})]})})}}export function withIslandErrorBoundary(e,n,i){return function(a){return t(IslandErrorBoundary,{islandId:n,fallback:i?.fallback,isolateError:i?.isolateError??!0,onError:i?.onError,children:t(e,{...a})})}}
|
|
1
|
+
import{Component as e}from"preact";import{jsx as t,jsxs as n}from"preact/jsx-runtime";export class IslandErrorBoundary extends e{constructor(e){super(e),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){let n={layoutPath:`island:${this.props.islandId}`,errorType:`island`,timestamp:Date.now(),componentStack:t.componentStack,errorBoundary:`IslandErrorBoundary`};if(this.setState({errorInfo:n}),this.props.onError?.(e,n),!this.props.isolateError)throw e}handleRemoveIsland=()=>{document.querySelector(`[data-island-id="${this.props.islandId}"]`)?.remove()};handleReloadIsland=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};render(){if(!this.state.hasError)return this.props.children;let{error:e}=this.state,{fallback:r,islandId:i}=this.props;if(r&&e)return r(e,i);let a=typeof process<`u`&&process.env?.NODE_ENV===`development`;return t(`div`,{className:`island-error-boundary`,"data-island-error":i,children:n(`div`,{className:`island-error-container`,children:[n(`div`,{className:`island-error-header`,children:[t(`span`,{className:`island-error-icon`,children:`⚠️`}),t(`span`,{className:`island-error-title`,children:`Island Error`})]}),n(`p`,{className:`island-error-message`,children:[`An error occurred in island "`,i,`".`]}),n(`div`,{className:`island-error-actions`,children:[t(`button`,{type:`button`,onClick:this.handleReloadIsland,className:`island-reload-button`,children:`Reload Island`}),t(`button`,{type:`button`,onClick:this.handleRemoveIsland,className:`island-remove-button`,children:`Remove Island`})]}),a&&e&&n(`details`,{className:`island-error-details`,children:[t(`summary`,{children:`Error Details (Development)`}),n(`p`,{children:[t(`strong`,{children:`Island ID:`}),` `,i]}),n(`p`,{children:[t(`strong`,{children:`Error:`}),` `,e.message]}),t(`pre`,{className:`island-error-stack`,children:e.stack})]})]})})}}export function withIslandErrorBoundary(e,n,i){return function(a){return t(IslandErrorBoundary,{islandId:n,fallback:i?.fallback,isolateError:i?.isolateError??!0,onError:i?.onError,children:t(e,{...a})})}}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @jsxImportSource preact */
|
|
2
|
-
import { Component, type ComponentChildren } from
|
|
3
|
-
import type {
|
|
2
|
+
import { Component, type ComponentChildren } from "preact";
|
|
3
|
+
import type { LayoutData, LayoutErrorInfo } from "../schemas/layout.ts";
|
|
4
4
|
/**
|
|
5
5
|
* Props for {@link LayoutErrorBoundary}.
|
|
6
6
|
*
|
|
@@ -43,7 +43,7 @@ export interface LayoutErrorBoundaryProps {
|
|
|
43
43
|
/** Called when the layout throws. */
|
|
44
44
|
onError?: (error: Error, errorInfo: LayoutErrorInfo) => void;
|
|
45
45
|
/** Categorises the error for structured logging. Defaults to `'component'`. */
|
|
46
|
-
errorType?:
|
|
46
|
+
errorType?: "component" | "loader" | "rendering" | "island";
|
|
47
47
|
/** Async function to re-attempt data loading. Enables the async retry button (up to 3 attempts). */
|
|
48
48
|
retryLoader?: () => Promise<LayoutData>;
|
|
49
49
|
/** Static data to offer as a "Use Cached Data" option when the loader fails. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Component as e}from"preact";import{jsx as t,jsxs as n}from"preact/jsx-runtime";export class LayoutErrorBoundary extends e{maxRetries=3;constructor(e){super(e),this.state={hasError:!1,error:null,errorInfo:null,retryCount:0,isRetrying:!1,fallbackData:e.fallbackData??null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){let n={errorType:this.props.errorType??`component`,timestamp:Date.now(),componentStack:t.componentStack,errorBoundary:`LayoutErrorBoundary`,layoutPath:void 0};this.setState({errorInfo:n}),this.props.onError?.(e,n)}handleRetry=async()=>{if(!(this.state.retryCount>=this.maxRetries))if(this.props.retryLoader){this.setState({isRetrying:!0});try{let e=await this.props.retryLoader();this.setState(t=>({hasError:!1,error:null,errorInfo:null,retryCount:t.retryCount+1,isRetrying:!1,fallbackData:e}))}catch(e){this.setState(t=>({retryCount:t.retryCount+1,isRetrying:!1,error:e instanceof Error?e:Error(String(e))}))}}else this.setState(e=>({hasError:!1,error:null,errorInfo:null,retryCount:e.retryCount+1}))};handleUseFallback=()=>{this.state.fallbackData&&this.setState({hasError:!1,error:null,errorInfo:null})};render(){if(!this.state.hasError)return this.props.children;let{error:e,retryCount:r,isRetrying:i,fallbackData:a}=this.state;if(this.props.fallback&&e)return this.props.fallback(e,this.handleRetry);let o=r<this.maxRetries,s=typeof process<`u`&&process.env?.NODE_ENV===`development`;return t(`div`,{className:`layout-error-boundary`,children:n(`div`,{className:`error-container`,children:[t(`h2`,{children:`Something went wrong`}),t(`p`,{children:`An error occurred while rendering this layout.`}),n(`div`,{className:`error-actions`,children:[o&&t(`button`,{onClick:this.handleRetry,disabled:i,className:`retry-button`,children:i?`Retrying...`:`Try Again (${this.maxRetries-r} left)`}),a!==null&&t(`button`,{onClick:this.handleUseFallback,className:`fallback-button`,children:`Use Cached Data`})]}),s&&e&&n(`details`,{className:`error-details`,children:[t(`summary`,{children:`Error Details (Development)`}),n(`p`,{children:[t(`strong`,{children:`Error:`}),` `,e.message]}),this.state.errorInfo&&n(`p`,{children:[t(`strong`,{children:`Error Type:`}),` `,this.state.errorInfo.errorType]}),t(`pre`,{className:`error-stack`,children:e.stack})]})]})})}}
|
|
1
|
+
import{Component as e}from"preact";import{jsx as t,jsxs as n}from"preact/jsx-runtime";export class LayoutErrorBoundary extends e{maxRetries=3;constructor(e){super(e),this.state={hasError:!1,error:null,errorInfo:null,retryCount:0,isRetrying:!1,fallbackData:e.fallbackData??null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){let n={errorType:this.props.errorType??`component`,timestamp:Date.now(),componentStack:t.componentStack,errorBoundary:`LayoutErrorBoundary`,layoutPath:void 0};this.setState({errorInfo:n}),this.props.onError?.(e,n)}handleRetry=async()=>{if(!(this.state.retryCount>=this.maxRetries))if(this.props.retryLoader){this.setState({isRetrying:!0});try{let e=await this.props.retryLoader();this.setState(t=>({hasError:!1,error:null,errorInfo:null,retryCount:t.retryCount+1,isRetrying:!1,fallbackData:e}))}catch(e){this.setState(t=>({retryCount:t.retryCount+1,isRetrying:!1,error:e instanceof Error?e:Error(String(e))}))}}else this.setState(e=>({hasError:!1,error:null,errorInfo:null,retryCount:e.retryCount+1}))};handleUseFallback=()=>{this.state.fallbackData&&this.setState({hasError:!1,error:null,errorInfo:null})};render(){if(!this.state.hasError)return this.props.children;let{error:e,retryCount:r,isRetrying:i,fallbackData:a}=this.state;if(this.props.fallback&&e)return this.props.fallback(e,this.handleRetry);let o=r<this.maxRetries,s=typeof process<`u`&&process.env?.NODE_ENV===`development`;return t(`div`,{className:`layout-error-boundary`,children:n(`div`,{className:`error-container`,children:[t(`h2`,{children:`Something went wrong`}),t(`p`,{children:`An error occurred while rendering this layout.`}),n(`div`,{className:`error-actions`,children:[o&&t(`button`,{type:`button`,onClick:this.handleRetry,disabled:i,className:`retry-button`,children:i?`Retrying...`:`Try Again (${this.maxRetries-r} left)`}),a!==null&&t(`button`,{type:`button`,onClick:this.handleUseFallback,className:`fallback-button`,children:`Use Cached Data`})]}),s&&e&&n(`details`,{className:`error-details`,children:[t(`summary`,{children:`Error Details (Development)`}),n(`p`,{children:[t(`strong`,{children:`Error:`}),` `,e.message]}),this.state.errorInfo&&n(`p`,{children:[t(`strong`,{children:`Error Type:`}),` `,this.state.errorInfo.errorType]}),t(`pre`,{className:`error-stack`,children:e.stack})]})]})})}}
|
|
@@ -23,7 +23,7 @@ export declare function detectAndLoadIntegration(src: string): Promise<Integrati
|
|
|
23
23
|
* @param src - The source path to detect framework from
|
|
24
24
|
* @returns The detected framework name
|
|
25
25
|
*/
|
|
26
|
-
export declare function detectFrameworkFromPath(src: string): "
|
|
26
|
+
export declare function detectFrameworkFromPath(src: string): "vue" | "svelte" | "solid" | "preact" | "react" | "lit" | "qwik";
|
|
27
27
|
/**
|
|
28
28
|
* Check if a path is within any islands directory (including nested).
|
|
29
29
|
*
|
|
@@ -66,7 +66,7 @@ export declare function extractNamespaceFromPath(path: string): string;
|
|
|
66
66
|
* @param content - The file content to analyze
|
|
67
67
|
* @returns The detected framework name
|
|
68
68
|
*/
|
|
69
|
-
export declare function detectFrameworkFromContent(src: string, content: string): "
|
|
69
|
+
export declare function detectFrameworkFromContent(src: string, content: string): "vue" | "svelte" | "solid" | "preact" | "react" | "lit" | "qwik";
|
|
70
70
|
/**
|
|
71
71
|
* Get integration for a specific framework, with error handling
|
|
72
72
|
*/
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { JSX } from
|
|
2
|
-
import type { ViteDevServer } from
|
|
3
|
-
import type { AnalyzerOptions } from
|
|
4
|
-
import type { Framework } from
|
|
1
|
+
import type { JSX } from "preact";
|
|
2
|
+
import type { ViteDevServer } from "vite";
|
|
3
|
+
import type { AnalyzerOptions } from "../core/components/component-analyzer.ts";
|
|
4
|
+
import type { Framework } from "./types.ts";
|
|
5
5
|
declare global {
|
|
6
6
|
var __viteDevServer: ViteDevServer | undefined;
|
|
7
7
|
}
|
|
8
8
|
/** Supported hydration conditions for island components */
|
|
9
|
-
export type HydrationCondition =
|
|
9
|
+
export type HydrationCondition = "on:visible" | "on:interaction" | "on:idle" | "on:client" | `media:${string}` | `on:${string}`;
|
|
10
10
|
/** Supported framework identifiers (without "unknown") */
|
|
11
|
-
export type FrameworkId = Exclude<Framework,
|
|
11
|
+
export type FrameworkId = Exclude<Framework, "unknown">;
|
|
12
12
|
export interface IslandProps {
|
|
13
13
|
/** Path to the island component (e.g., "/islands/Counter.tsx") */
|
|
14
14
|
src: string;
|
|
@@ -19,7 +19,7 @@ export interface IslandProps {
|
|
|
19
19
|
/** Props to pass to the island component */
|
|
20
20
|
props?: Record<string, unknown>;
|
|
21
21
|
/** Children to render inside the island (for SSR) */
|
|
22
|
-
children?: import(
|
|
22
|
+
children?: import("preact").ComponentChildren;
|
|
23
23
|
/** Whether to render server-side (default: true unless condition is 'on:client') */
|
|
24
24
|
ssr?: boolean;
|
|
25
25
|
/** Framework hint for client hydration */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e}from"preact";import{
|
|
1
|
+
import{h as e}from"preact";import{getIslandBundlePath as t}from"../build/island-manifest.js";import{devError as n,devLog as r,devWarn as i,isDev as a,logRenderTiming as o}from"../utils/dev-logger.js";import{analyzeComponentFile as s,renderComponentSSROnly as c}from"./component-analysis.js";import{detectFramework as l}from"./framework-detection.js";import{isCustomDirective as u,serializeDirectiveScript as d}from"./hydration-directives.js";import{detectFrameworkFromPath as f,loadIntegration as p}from"./integration-loader.js";import{addUniversalCSS as m}from"./universal-css-collector.js";import{addUniversalHead as h}from"./universal-head-collector.js";function g(e){return`island-${e.replaceAll(/[^a-zA-Z0-9]/g,`-`)}`}function _(e){let t={};e.renderId&&(t[`data-solid-render-id`]=e.renderId);let n=e.metadata;return n?.tagName&&(t[`data-tag-name`]=n.tagName),t}function v(e,n,r,i,a){let o={"data-condition":n,"data-src":t(e),"data-props":JSON.stringify(r),"data-render-strategy":`hydrate`,..._(i)};if(u(n)){o[`data-custom-directive`]=n;let e=d(n);e&&(o[`data-directive-script`]=e)}return a&&(o[`data-condition-arg`]=a),o}function y(e){return e.startsWith(`<script`)?`script`:e.startsWith(`<style`)?`style`:e.startsWith(`<meta`)?`meta`:e.startsWith(`<link`)?`link`:e.includes(`window._$HY`)||e.includes(`_$HY=`)?`script`:`other`}function b(e){let t=e.match(/<style[^>]*>([\s\S]*?)<\/style>/i);return t?t[1].trim():null}function x(e,t,n,i){if(e.css&&m(e.css,t,n,e.scopeId),e.head){let a=e.head.trim(),o=y(a);if(o===`style`){let o=b(a);o&&(r(`${i} Extracting CSS from head <style> tag`),m(o,t,n,e.scopeId));return}h(e.head,t,n,o)}}function S(t){let{islandId:n,detectedFramework:i,shouldSkipHydration:a,src:o,condition:s,conditionArg:c,props:l,hydrationData:u,children:d}=t,f={id:n,"data-framework":i},p=a?{"data-render-strategy":`ssr-only`}:v(o,s,l,u,c);i===`lit`&&r(`🔍 [Island Component] ${o} - Lit hydration data:`,{hydrationDataKeys:Object.keys(u),metadata:u.metadata});let m={...f,...p};return typeof d==`string`?e(`avalon-island`,{...m,dangerouslySetInnerHTML:{__html:d}}):e(`avalon-island`,m,d)}function C(n){let{islandId:r,detectedFramework:i,shouldSkipHydration:a,src:o,condition:s,props:c,hydrationData:l,conditionArg:f}=n;if(a)return e(`avalon-island`,{id:r,"data-render-strategy":`ssr-only`,"data-framework":i});let p={id:r,"data-condition":s,"data-src":t(o),"data-props":JSON.stringify(c),"data-render-strategy":`hydrate`,"data-framework":i,..._(l)};if(u(s)){p[`data-custom-directive`]=s;let e=d(s);e&&(p[`data-directive-script`]=e)}return f&&(p[`data-condition-arg`]=f),e(`avalon-island`,p)}export default function w({src:e,condition:t=`on:client`,conditionArg:n,props:a={},children:o,ssr:s=t!==`on:client`,framework:c,ssrOnly:l=!1,renderOptions:u={},hydrationData:d={}}){let p=g(e),m=l||!!u.forceSSROnly,h=c||f(e),_=o!=null&&o!==``;return r(`🔍 [Island Component] ${e}`,{ssr:s,ssrOnly:l,hasChildren:_,framework:c,condition:t}),s&&_?S({islandId:p,detectedFramework:h,shouldSkipHydration:m,src:e,condition:t,conditionArg:n,props:a,hydrationData:d,children:o}):(s&&!_&&m&&i(`${e}: SSR-only component has no rendered content. This may indicate a rendering error.`),C({islandId:p,detectedFramework:h,shouldSkipHydration:m,src:e,condition:t,props:a,hydrationData:d,conditionArg:n}))}function T(r,i){let a=i instanceof Error?i.message:String(i);return n(`🚨 Island SSR failed for ${r}:`,i),i instanceof Error&&i.stack&&n(`Stack trace:`,i.stack),e(`avalon-island`,{id:g(r),"data-src":t(r),"data-ssr-error":a,"data-render-strategy":`client-only`})}async function E({src:e,condition:t,conditionArg:r,props:i,children:o,ssr:s,framework:c,ssrOnly:l,renderOptions:u,component:d}){let f=`🏝️ [${e}]`;if(!s||o)return w({src:e,condition:t,conditionArg:r,props:i,children:o,ssr:s,framework:c,ssrOnly:l,renderOptions:u});let m;try{m=await p(c)}catch(a){return n(`${f} Failed to load ${c} integration:`,a),w({src:e,condition:t,conditionArg:r,props:i,ssr:!1,framework:c,ssrOnly:l,renderOptions:u})}try{let n=await m.render({component:d??null,props:i,src:e,condition:t,ssrOnly:l,viteServer:globalThis.__viteDevServer,isDev:a()});return x(n,e,c,f),w({src:e,condition:t,conditionArg:r,props:i,children:n.html,ssr:!0,framework:c,ssrOnly:l,renderOptions:u,hydrationData:l?void 0:n.hydrationData})}catch(a){return n(`${f} Fast path SSR failed:`,a),w({src:e,condition:t,conditionArg:r,props:i,ssr:!1,framework:c,ssrOnly:l,renderOptions:u})}}async function D(e,t,n,r){if(t||n.detectScripts===!1)return t;try{let t=await s(e,n);if(t.decision.warnings?.length)for(let e of t.decision.warnings)i(`${r} Analysis warning: ${e}`);return!t.decision.shouldHydrate}catch(e){return i(`${r} Component analysis failed:`,e),t}}async function O(e){return e.endsWith(`.vue`)?`vue`:e.endsWith(`.svelte`)?`svelte`:e.endsWith(`.tsx`)||e.endsWith(`.jsx`)||e.endsWith(`.ts`)||e.endsWith(`.js`)?l(e):`unknown`}async function k(e,t,n,r,i,o,s){let c=await O(e),l=c,u=await(await A(c,o)).render({component:s??null,props:n,src:e,condition:t,ssrOnly:r,viteServer:globalThis.__viteDevServer,isDev:a()});return x(u,e,c,o),w({src:e,condition:t,props:n,children:u.html,ssr:!0,framework:l,ssrOnly:r,renderOptions:i,hydrationData:r?void 0:u.hydrationData})}async function A(e,t){try{r(`${t} Loading integration for framework: ${e}`);let n=await p(e);return r(`${t} ✅ Integration loaded successfully`),n}catch(r){throw n(`${t} Failed to load ${e} integration:`,r),Error(`Failed to load integration for framework '${e}'. Make sure @useavalon/${e} is installed.\nInstall it with: deno add @useavalon/${e}`,{cause:r})}}export async function renderIsland({src:e,condition:t=`on:client`,conditionArg:n,props:r={},children:i,ssr:s=t!==`on:client`,framework:c,ssrOnly:l=!1,renderOptions:u={},component:d}){let f=a()?performance.now():0,p=`🏝️ [${e}]`;try{return l&&!s&&(s=!0),c?await E({src:e,condition:t,conditionArg:n,props:r,children:i,ssr:s,framework:c,ssrOnly:l,renderOptions:u,component:d}):await j({src:e,condition:t,conditionArg:n,props:r,children:i,ssr:s,ssrOnly:l,renderOptions:u,logPrefix:p,component:d})}catch(t){return T(e,t)}finally{a()&&o(e,performance.now()-f)}}async function j(e){let{src:t,condition:i,conditionArg:a,props:o,children:s,ssr:c,ssrOnly:l,renderOptions:u,logPrefix:d,component:f}=e;if(r(`🔍 [renderIsland] ${t} - Starting render (slow path)`,{ssr:c,ssrOnly:l,hasChildren:!!s,condition:i}),await D(t,l,u,d))return M(t,i,o,s,c,u,d);if(!c||s)return w({src:t,condition:i,conditionArg:a,props:o,children:s,ssr:c,renderOptions:u});try{return await k(t,i,o,l,u,d,f)}catch(e){let r=await O(t);return n(`${d} Framework rendering failed:`,e),w({src:t,condition:i,conditionArg:a,props:o,ssr:!1,framework:r,renderOptions:u})}}function M(e,t,r,i,a,o,s){return a&&!i?c({src:e,condition:t,props:r,renderOptions:o}).catch(i=>(n(`${s} SSR failed for SSR-only component:`,i),w({src:e,condition:t,props:r,ssr:!1,ssrOnly:!0,renderOptions:o}))):w({src:e,condition:t,props:r,children:i,ssr:a,ssrOnly:!0,renderOptions:o})}
|
|
@@ -4,23 +4,20 @@
|
|
|
4
4
|
* This file provides a comprehensive export index for the entire layout system,
|
|
5
5
|
* making it easy to import all layout-related functionality from a single location.
|
|
6
6
|
*/
|
|
7
|
-
export {
|
|
8
|
-
export
|
|
9
|
-
export {
|
|
10
|
-
export type { LayoutDataLoadingResult,
|
|
11
|
-
export {
|
|
12
|
-
export
|
|
13
|
-
export {
|
|
14
|
-
export type { LayoutConfig } from
|
|
15
|
-
export {
|
|
16
|
-
export
|
|
17
|
-
export {
|
|
18
|
-
export type {
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export { LayoutContextSchema, LayoutDataSchema, LayoutRouteSchema, LayoutHandlerSchema, LayoutPropsSchema, LayoutDiscoveryOptionsSchema, RouteInfoSchema, LayoutRuleSchema, LayoutConfigSchema, IslandStateSchema, PersistentIslandPropsSchema, PersistentIslandContextSchema, LayoutErrorInfoSchema, LayoutErrorBoundaryPropsSchema, ErrorRecoveryStrategySchema, StreamingLayoutPropsSchema, StreamingComponentSchema, ResolvedLayoutSchema, LayoutCacheSchema, EnhancedLayoutContextSchema, } from './schemas/layout.ts';
|
|
22
|
-
export { EnhancedLayoutResolver as LayoutSystem } from './core/layout/enhanced-layout-resolver.ts';
|
|
23
|
-
export { createEnhancedLayoutResolver as createLayoutSystem } from './core/layout/enhanced-layout-resolver.ts';
|
|
7
|
+
export type { EnhancedLayoutResolverOptions } from "./core/layout/enhanced-layout-resolver.ts";
|
|
8
|
+
export { createEnhancedLayoutResolver, EnhancedLayoutResolver, EnhancedLayoutResolverUtils, } from "./core/layout/enhanced-layout-resolver.ts";
|
|
9
|
+
export { LayoutComposer } from "./core/layout/layout-composer.ts";
|
|
10
|
+
export type { LayoutDataLoadingOptions, LayoutDataLoadingResult, } from "./core/layout/layout-data-loader.ts";
|
|
11
|
+
export { defaultLayoutDataLoader, getParentLayoutData, LayoutDataLoader, LayoutDataLoadingError, loadSingleLayoutData, mergeLayoutData, } from "./core/layout/layout-data-loader.ts";
|
|
12
|
+
export { LayoutDiscovery } from "./core/layout/layout-discovery.ts";
|
|
13
|
+
export { BuiltInLayoutRules, LayoutMatcher as LayoutMatcherClass, } from "./core/layout/layout-matcher.ts";
|
|
14
|
+
export type { LayoutConfig, LayoutDiscoveryOptions, LayoutRoute, LayoutRule, RouteInfo, } from "./schemas/layout.ts";
|
|
15
|
+
export type { CacheConfig, CacheEntry, CacheStats, } from "./core/layout/layout-cache-manager.ts";
|
|
16
|
+
export { LayoutCacheManager } from "./core/layout/layout-cache-manager.ts";
|
|
17
|
+
export type { EnhancedLayoutContext, IslandStateClearer, IslandStateLoader, IslandStateSaver, LayoutCache, LayoutContext, LayoutData, LayoutErrorHandler, LayoutFallbackRenderer, LayoutHandler, LayoutLoader, LayoutMatcherFunction, LayoutProps, LayoutRetryFunction, ResolvedLayout, StreamingReadyCheck, } from "./schemas/layout.ts";
|
|
18
|
+
export type { IEnhancedLayoutResolver, IIslandPersistence, ILayoutComponent, ILayoutComposer, ILayoutDiscovery, ILayoutErrorBoundaryComponent, ILayoutErrorRecovery, ILayoutEventEmitter, ILayoutMatcher, ILayoutStreaming, IPersistentIslandComponent, IStreamingLayoutComponent, LayoutDebugInfo, LayoutEventData, LayoutEventHandler, LayoutEventType, LayoutModule, LayoutPerformanceMetrics, LayoutResolutionContext, PageModule, } from "./types/layout.ts";
|
|
19
|
+
export { EnhancedLayoutContextSchema, ErrorRecoveryStrategySchema, IslandStateSchema, LayoutCacheSchema, LayoutConfigSchema, LayoutContextSchema, LayoutDataSchema, LayoutDiscoveryOptionsSchema, LayoutErrorBoundaryPropsSchema, LayoutErrorInfoSchema, LayoutHandlerSchema, LayoutPropsSchema, LayoutRouteSchema, LayoutRuleSchema, PersistentIslandContextSchema, PersistentIslandPropsSchema, ResolvedLayoutSchema, RouteInfoSchema, StreamingComponentSchema, StreamingLayoutPropsSchema, } from "./schemas/layout.ts";
|
|
20
|
+
export { createEnhancedLayoutResolver as createLayoutSystem, EnhancedLayoutResolver as LayoutSystem, } from "./core/layout/enhanced-layout-resolver.ts";
|
|
24
21
|
/**
|
|
25
22
|
* Layout System Version Information
|
|
26
23
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{createEnhancedLayoutResolver,EnhancedLayoutResolver,EnhancedLayoutResolverUtils}from"./core/layout/enhanced-layout-resolver.js";export{LayoutComposer}from"./core/layout/layout-composer.js";export{defaultLayoutDataLoader,getParentLayoutData,LayoutDataLoader,LayoutDataLoadingError,loadSingleLayoutData,mergeLayoutData}from"./core/layout/layout-data-loader.js";export{LayoutDiscovery}from"./core/layout/layout-discovery.js";export{BuiltInLayoutRules,LayoutMatcher as LayoutMatcherClass}from"./core/layout/layout-matcher.js";export{LayoutCacheManager}from"./core/layout/layout-cache-manager.js";export{EnhancedLayoutContextSchema,ErrorRecoveryStrategySchema,IslandStateSchema,LayoutCacheSchema,LayoutConfigSchema,LayoutContextSchema,LayoutDataSchema,LayoutDiscoveryOptionsSchema,LayoutErrorBoundaryPropsSchema,LayoutErrorInfoSchema,LayoutHandlerSchema,LayoutPropsSchema,LayoutRouteSchema,LayoutRuleSchema,PersistentIslandContextSchema,PersistentIslandPropsSchema,ResolvedLayoutSchema,RouteInfoSchema,StreamingComponentSchema,StreamingLayoutPropsSchema}from"./schemas/layout.js";export{createEnhancedLayoutResolver as createLayoutSystem,EnhancedLayoutResolver as LayoutSystem}from"./core/layout/enhanced-layout-resolver.js";export const LAYOUT_SYSTEM_VERSION=`1.0.0`;export const LAYOUT_SYSTEM_FEATURES={DISCOVERY:!0,DATA_LOADING:!0,CONDITIONAL_RENDERING:!0,COMPOSITION_CONTROL:!0,PERSISTENT_ISLANDS:!0,ERROR_BOUNDARIES:!0,STREAMING:!0,CACHING:!0,PERFORMANCE_MONITORING:!0,DEBUG_UTILITIES:!0};export const LAYOUT_SYSTEM_DEFAULTS={DISCOVERY:{baseDirectory:`src/pages`,filePattern:`_layout.tsx`,excludeDirectories:[`node_modules`,`.git`,`dist`],enableWatching:!1,developmentMode:!1},CACHING:{enabled:!0,ttl:3e5,maxSize:100,cleanupInterval:6e4},STREAMING:{enabled:!0,priority:`medium`,timeout:5e3},ERROR_BOUNDARIES:{enabled:!0,maxRetries:3,fallbackStrategy:`component`},PERFORMANCE:{monitoring:!0,thresholds:{discoveryTime:100,dataLoadingTime:500,renderingTime:200,totalTime:1e3}}};
|
|
@@ -177,6 +177,19 @@ export interface AvalonNitroConfig {
|
|
|
177
177
|
/** Write `/about` as `/about/index.html` @default true */
|
|
178
178
|
autoSubfolderIndex?: boolean;
|
|
179
179
|
};
|
|
180
|
+
/**
|
|
181
|
+
* Path to the client entry file, relative to the project root.
|
|
182
|
+
* Used by the auto-generated renderer to import client assets.
|
|
183
|
+
* @default "app/entry-client" (or "src/entry-client")
|
|
184
|
+
*/
|
|
185
|
+
clientEntry?: string;
|
|
186
|
+
/**
|
|
187
|
+
* Global CSS files to include in the client entry.
|
|
188
|
+
* Paths are relative to the project root.
|
|
189
|
+
* Layout CSS is auto-discovered — this is for additional global stylesheets.
|
|
190
|
+
* @example ["app/shared/styles/main.css"]
|
|
191
|
+
*/
|
|
192
|
+
globalCSS?: string[];
|
|
180
193
|
}
|
|
181
194
|
/**
|
|
182
195
|
* Nitro configuration output structure
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
*
|
|
26
26
|
* Requirements: 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 5.1, 5.3, 9.1, 9.2, 9.3, 9.4, 10.5
|
|
27
27
|
*/
|
|
28
|
-
import type {
|
|
29
|
-
import type {
|
|
28
|
+
import type { H3Event } from "h3";
|
|
29
|
+
import type { AvalonRuntimeConfig, HttpError, NitroRenderContext, PageModule, SSRRenderOptions, SSRRenderResult } from "./types.ts";
|
|
30
30
|
/**
|
|
31
31
|
* Resolved page route information
|
|
32
32
|
*/
|
|
@@ -43,9 +43,9 @@ export interface ResolvedPageRoute {
|
|
|
43
43
|
/**
|
|
44
44
|
* Render handler options
|
|
45
45
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
46
|
+
* Route resolution is handled by Nitro's file-system routing.
|
|
47
|
+
* Custom resolvers are optional and primarily used for
|
|
48
|
+
* development/testing scenarios.
|
|
49
49
|
*/
|
|
50
50
|
export interface RenderHandlerOptions {
|
|
51
51
|
/** Avalon runtime configuration */
|
|
@@ -94,6 +94,12 @@ export interface RenderHandlerOptions {
|
|
|
94
94
|
* @returns NitroRenderContext for use in rendering
|
|
95
95
|
*/
|
|
96
96
|
export declare function createRenderContext(event: H3Event, params?: Record<string, string>): NitroRenderContext;
|
|
97
|
+
/**
|
|
98
|
+
* Creates a render context directly from a web Request.
|
|
99
|
+
* Used by the `.fetch()` wrapper to avoid h3 event conversion issues
|
|
100
|
+
* when Nitro's SSR dispatcher passes a plain Request.
|
|
101
|
+
*/
|
|
102
|
+
export declare function createRenderContextFromRequest(request: Request, params?: Record<string, string>): NitroRenderContext;
|
|
97
103
|
/**
|
|
98
104
|
* Gets the request URL from an H3 event
|
|
99
105
|
*/
|
|
@@ -105,7 +111,7 @@ export declare function toRequest(event: H3Event): Request;
|
|
|
105
111
|
/**
|
|
106
112
|
* Gets request headers from an H3 event
|
|
107
113
|
*/
|
|
108
|
-
export declare function getRequestHeaders(
|
|
114
|
+
export declare function getRequestHeaders(_event: H3Event): Headers;
|
|
109
115
|
/**
|
|
110
116
|
* Sets a response header on an H3 event
|
|
111
117
|
*/
|
|
@@ -208,7 +214,7 @@ export declare function processHydrationRequirements(html: string, isDev: boolea
|
|
|
208
214
|
* @param options - Render options
|
|
209
215
|
* @returns SSR render result
|
|
210
216
|
*/
|
|
211
|
-
export declare function renderPage(pageModule: PageModule, context: NitroRenderContext, options?: SSRRenderOptions, wrapWithLayouts?: RenderHandlerOptions[
|
|
217
|
+
export declare function renderPage(pageModule: PageModule, context: NitroRenderContext, options?: SSRRenderOptions, wrapWithLayouts?: RenderHandlerOptions["wrapWithLayouts"]): Promise<SSRRenderResult>;
|
|
212
218
|
/**
|
|
213
219
|
* Extended streaming options with additional callbacks
|
|
214
220
|
*/
|
|
@@ -274,7 +280,9 @@ export declare function createStreamingResponse(stream: ReadableStream<Uint8Arra
|
|
|
274
280
|
* @param options - Render handler options
|
|
275
281
|
* @returns Handler function for Nitro
|
|
276
282
|
*/
|
|
277
|
-
export declare function createNitroRenderer(options: RenderHandlerOptions): (event: H3Event) => Promise<Response
|
|
283
|
+
export declare function createNitroRenderer(options: RenderHandlerOptions): ((event: H3Event) => Promise<Response>) & {
|
|
284
|
+
fetch(request: Request): Promise<Response>;
|
|
285
|
+
};
|
|
278
286
|
/**
|
|
279
287
|
* Options for the Nitro catch-all renderer
|
|
280
288
|
*/
|
|
@@ -292,7 +300,7 @@ export interface NitroCatchAllOptions {
|
|
|
292
300
|
/** Optional layout resolver */
|
|
293
301
|
resolveLayouts?: (routePath: string, config: AvalonRuntimeConfig) => Promise<string[]>;
|
|
294
302
|
/** Wrap rendered page HTML with layout components (same as RenderHandlerOptions) */
|
|
295
|
-
wrapWithLayouts?: RenderHandlerOptions[
|
|
303
|
+
wrapWithLayouts?: RenderHandlerOptions["wrapWithLayouts"];
|
|
296
304
|
/**
|
|
297
305
|
* Enable custom error pages (404.tsx, 500.tsx, _error.tsx)
|
|
298
306
|
* When enabled, the renderer will look for custom error pages in the pages directory
|
|
@@ -337,7 +345,9 @@ export interface NitroCatchAllOptions {
|
|
|
337
345
|
* @param options - Catch-all renderer options
|
|
338
346
|
* @returns Nitro event handler function
|
|
339
347
|
*/
|
|
340
|
-
export declare function createNitroCatchAllRenderer(options: NitroCatchAllOptions): (event: H3Event) => Promise<Response
|
|
348
|
+
export declare function createNitroCatchAllRenderer(options: NitroCatchAllOptions): ((event: H3Event) => Promise<Response>) & {
|
|
349
|
+
fetch(request: Request): Promise<Response>;
|
|
350
|
+
};
|
|
341
351
|
/**
|
|
342
352
|
* Re-export middleware cache clearing for hot reload support
|
|
343
353
|
*
|
|
@@ -352,4 +362,4 @@ export declare function createNitroCatchAllRenderer(options: NitroCatchAllOption
|
|
|
352
362
|
* }
|
|
353
363
|
* ```
|
|
354
364
|
*/
|
|
355
|
-
export { clearMiddlewareCache as clearRendererMiddlewareCache } from
|
|
365
|
+
export { clearMiddlewareCache as clearRendererMiddlewareCache } from "../middleware/index.ts";
|