@useavalon/avalon 0.1.48 → 0.1.49
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/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/renderer.d.ts +6 -6
- package/dist/src/nitro/renderer.js +9 -9
- 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/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/island-prop.d.ts +14 -8
- package/dist/src/types/layout.d.ts +11 -11
- package/dist/src/types/layout.js +1 -1
- package/package.json +1 -1
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";
|
|
@@ -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}}};
|
|
@@ -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
|
*/
|
|
@@ -105,7 +105,7 @@ export declare function toRequest(event: H3Event): Request;
|
|
|
105
105
|
/**
|
|
106
106
|
* Gets request headers from an H3 event
|
|
107
107
|
*/
|
|
108
|
-
export declare function getRequestHeaders(
|
|
108
|
+
export declare function getRequestHeaders(_event: H3Event): Headers;
|
|
109
109
|
/**
|
|
110
110
|
* Sets a response header on an H3 event
|
|
111
111
|
*/
|
|
@@ -208,7 +208,7 @@ export declare function processHydrationRequirements(html: string, isDev: boolea
|
|
|
208
208
|
* @param options - Render options
|
|
209
209
|
* @returns SSR render result
|
|
210
210
|
*/
|
|
211
|
-
export declare function renderPage(pageModule: PageModule, context: NitroRenderContext, options?: SSRRenderOptions, wrapWithLayouts?: RenderHandlerOptions[
|
|
211
|
+
export declare function renderPage(pageModule: PageModule, context: NitroRenderContext, options?: SSRRenderOptions, wrapWithLayouts?: RenderHandlerOptions["wrapWithLayouts"]): Promise<SSRRenderResult>;
|
|
212
212
|
/**
|
|
213
213
|
* Extended streaming options with additional callbacks
|
|
214
214
|
*/
|
|
@@ -292,7 +292,7 @@ export interface NitroCatchAllOptions {
|
|
|
292
292
|
/** Optional layout resolver */
|
|
293
293
|
resolveLayouts?: (routePath: string, config: AvalonRuntimeConfig) => Promise<string[]>;
|
|
294
294
|
/** Wrap rendered page HTML with layout components (same as RenderHandlerOptions) */
|
|
295
|
-
wrapWithLayouts?: RenderHandlerOptions[
|
|
295
|
+
wrapWithLayouts?: RenderHandlerOptions["wrapWithLayouts"];
|
|
296
296
|
/**
|
|
297
297
|
* Enable custom error pages (404.tsx, 500.tsx, _error.tsx)
|
|
298
298
|
* When enabled, the renderer will look for custom error pages in the pages directory
|
|
@@ -352,4 +352,4 @@ export declare function createNitroCatchAllRenderer(options: NitroCatchAllOption
|
|
|
352
352
|
* }
|
|
353
353
|
* ```
|
|
354
354
|
*/
|
|
355
|
-
export { clearMiddlewareCache as clearRendererMiddlewareCache } from
|
|
355
|
+
export { clearMiddlewareCache as clearRendererMiddlewareCache } from "../middleware/index.ts";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{getRequestURL as e}from"h3";import{
|
|
1
|
+
import{getRequestURL as e}from"h3";import{h as t}from"preact";import n from"preact-render-to-string";import{discoverScopedMiddleware as r,executeScopedMiddleware as i}from"../middleware/index.js";import{discoverErrorPages as a,handleRenderError as o}from"./error-handler.js";import{createNotFoundError as s,isHttpError as c}from"./types.js";export function createRenderContext(e,t={}){let n=getRequestURL(e);return{url:n,params:t,query:Object.fromEntries(n.searchParams),request:toRequest(e),event:e}}export function getRequestURL(t){return new URL(e(t).pathname,`http://localhost`)}export function toRequest(e){let t=getRequestURL(e);return new Request(t,{method:e.req.method,headers:getRequestHeaders(e)})}export function getRequestHeaders(e){return new Headers}export function setResponseHeader(e,t,n){e.context.responseHeaders||(e.context.responseHeaders={}),e.context.responseHeaders[t]=n}export function createErrorResponse(e,t){let n=c(e)?e.statusCode:500;if(t){let t=h(e,n);return new Response(t,{status:n,headers:{"Content-Type":`text/html; charset=utf-8`}})}let r=g(n);return new Response(r,{status:n,headers:{"Content-Type":`text/html; charset=utf-8`}})}function h(e,t){return`<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8">
|
|
@@ -117,22 +117,22 @@ import{getRequestURL as e}from"h3";import{createNotFoundError as t,isHttpError a
|
|
|
117
117
|
<p><a href="/">Return to home</a></p>
|
|
118
118
|
</div>
|
|
119
119
|
</body>
|
|
120
|
-
</html>`}function _(e){return{400:`Bad Request`,401:`Unauthorized`,403:`Forbidden`,404:`Page Not Found`,405:`Method Not Allowed`,500:`Internal Server Error`,502:`Bad Gateway`,503:`Service Unavailable`}[e]||`Error`}function v(e){return e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`"`,`"`).replaceAll(`'`,`'`)}export function extractIslandMarkers(e){let t=[],n=/<[^>]*data-framework="([^"]+)"[^>]*>/g,r
|
|
121
|
-
`);return e.includes(`</body>`)?e.replace(`</body>`,`${a}\n</body>`):e+a}export function validateHydrationMarkers(e){let t=extractIslandMarkers(e),n=e.match(/data-framework="[^"]+"/g)||[],r=e.match(/data-src="[^"]+"/g)||[],i=e.match(/data-props="[^"]*"/g)||[],a=e.includes(`/src/client/main.js`)||e.includes(`/dist/client.js`)||e.includes(`client/main.js`),o=t.every(e=>e.framework&&e.src),s=t.length===0||o&&a;return{hasFrameworkAttr:n.length>0,hasSrcAttr:r.length>0,hasPropsAttr:i.length>0,islandCount:n.length,islands:t,hasClientScript:a,isValid:s}}export function processHydrationRequirements(e,t){let n=injectHydrationScript(e,t);return{html:n,validation:validateHydrationMarkers(n)}}export async function renderPage(e,t,n={},r){try{let i={};return e.getServerSideProps&&(i=await e.getServerSideProps(t)),{html:await y(e,i,t,n,r),statusCode:200,headers:{"Content-Type":`text/html; charset=utf-8`}}}catch(e){throw console.error(`[SSR Error]`,e),n.onError&&e instanceof Error&&n.onError(e),e}}async function y(e,
|
|
120
|
+
</html>`}function _(e){return{400:`Bad Request`,401:`Unauthorized`,403:`Forbidden`,404:`Page Not Found`,405:`Method Not Allowed`,500:`Internal Server Error`,502:`Bad Gateway`,503:`Service Unavailable`}[e]||`Error`}function v(e){return e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`"`,`"`).replaceAll(`'`,`'`)}export function extractIslandMarkers(e){let t=[],n=/<[^>]*data-framework="([^"]+)"[^>]*>/g,r=n.exec(e);for(;r!==null;){let i=r[0],a=r[1],o=/data-src="([^"]+)"/.exec(i),s=o?o[1]:``,c=/data-props="([^"]*)"/.exec(i),l=c?c[1]:void 0,u=/data-hydrate="([^"]+)"/.exec(i),d=u?u[1]:void 0;t.push({framework:a,src:s,props:l,hydrate:d}),r=n.exec(e)}return t}export function ensureHydrationMarkers(e,t){let n=e;return t.framework&&!n.includes(`data-framework=`)&&(n=n.replace(/>/,` data-framework="${t.framework}">`)),t.src&&!n.includes(`data-src=`)&&(n=n.replace(/>/,` data-src="${t.src}">`)),t.props!==void 0&&!n.includes(`data-props=`)&&(n=n.replace(/>/,` data-props="${t.props}">`)),n}export function injectHydrationScript(e,t,n={}){if(!(e.includes(`data-framework=`)||e.includes(`data-src=`))&&!n.forceInject||[`/src/client/main.js`,`/dist/client.js`,`client/main.js`].some(t=>e.includes(t)))return e;let r=n.scriptPath||(t?`/src/client/main.js`:`/dist/client.js`),i=[];i.push(`<script type="module" src="${r}"><\/script>`),n.additionalScripts&&i.push(...n.additionalScripts);let a=i.join(`
|
|
121
|
+
`);return e.includes(`</body>`)?e.replace(`</body>`,`${a}\n</body>`):e+a}export function validateHydrationMarkers(e){let t=extractIslandMarkers(e),n=e.match(/data-framework="[^"]+"/g)||[],r=e.match(/data-src="[^"]+"/g)||[],i=e.match(/data-props="[^"]*"/g)||[],a=e.includes(`/src/client/main.js`)||e.includes(`/dist/client.js`)||e.includes(`client/main.js`),o=t.every(e=>e.framework&&e.src),s=t.length===0||o&&a;return{hasFrameworkAttr:n.length>0,hasSrcAttr:r.length>0,hasPropsAttr:i.length>0,islandCount:n.length,islands:t,hasClientScript:a,isValid:s}}export function processHydrationRequirements(e,t){let n=injectHydrationScript(e,t);return{html:n,validation:validateHydrationMarkers(n)}}export async function renderPage(e,t,n={},r){try{let i={};return e.getServerSideProps&&(i=await e.getServerSideProps(t)),{html:await y(e,i,t,n,r),statusCode:200,headers:{"Content-Type":`text/html; charset=utf-8`}}}catch(e){throw console.error(`[SSR Error]`,e),n.onError&&e instanceof Error&&n.onError(e),e}}async function y(e,r,i,a,o){let s=e.default,c=e.metadata||{},l=process.env.NODE_ENV!==`production`,u;try{let e=s(r);u=e instanceof Promise?await e:e}catch(e){console.error(`[renderer] Error calling page component:`,e),u=t(`div`,null,`Error rendering page`)}let d;try{d=n(u)}catch(e){console.error(`[renderer] Error in preactRenderToString:`,e),d=`<div>Error rendering page</div>`}if(o)return await o(d,e,i);let f=l?`
|
|
122
122
|
<script type="module" src="/src/client/main.js"><\/script>`:``;return`<!DOCTYPE html>
|
|
123
123
|
<html lang="en">
|
|
124
124
|
<head>
|
|
125
125
|
<meta charset="utf-8">
|
|
126
126
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
127
|
-
<title>${v(String(
|
|
128
|
-
${
|
|
127
|
+
<title>${v(String(c.title||`Avalon App`))}</title>
|
|
128
|
+
${c.description?`<meta name="description" content="${v(String(c.description))}">`:``}
|
|
129
129
|
</head>
|
|
130
130
|
<body>
|
|
131
131
|
<div id="app">
|
|
132
132
|
${d}
|
|
133
133
|
</div>${f}
|
|
134
134
|
</body>
|
|
135
|
-
</html>`}export async function renderPageStream(e,t,
|
|
135
|
+
</html>`}export async function renderPageStream(e,t,r={}){let i=new TextEncoder,a=null,o={shellSent:!1,contentSent:!1,closed:!1,error:null},s=r.shellReadyTimeout,c=r.allReadyTimeout,l=null,u=null,d=()=>{l&&=(clearTimeout(l),null),u&&=(clearTimeout(u),null)};function f(e,t,n,r,i,a,o){if(n.error=e,a(),console.error(`[Streaming Error]`,{message:e.message,stack:e.stack,shellSent:n.shellSent,isShellError:t,timestamp:new Date().toISOString()}),t&&o.onShellError&&o.onShellError(e),o.onError&&o.onError(e),!n.closed&&r){if(n.shellSent){let t=C(e);r.enqueue(i.encode(t));let n=S();r.enqueue(i.encode(n))}else{let t=h(e,500);r.enqueue(i.encode(t))}n.closed=!0,r.close()}}async function p(s){a=s;let p={};e.getServerSideProps&&(p=await e.getServerSideProps(t));let m=b(e.metadata||{},t);if(o.closed||(s.enqueue(i.encode(m)),o.shellSent=!0,l&&=(clearTimeout(l),null),r.onShellReady&&r.onShellReady()),c&&c>0&&(u=setTimeout(()=>{!o.contentSent&&!o.closed&&f(Error(`All ready timeout after ${c}ms`),!1,o,a,i,d,r)},c)),!o.closed){let t=e.default;if(t&&typeof t==`function`){let r=t(p);if(r&&typeof r.then==`function`)try{let e=n(await r);s.enqueue(i.encode(` <div id="app">${e}</div>\n`))}catch(t){console.error(`[streaming] Async component error:`,t);let n=x(e,p);s.enqueue(i.encode(n))}else{let t=x(e,p);s.enqueue(i.encode(t))}}else{let t=x(e,p);s.enqueue(i.encode(t))}o.contentSent=!0}if(!o.closed){let e=S();s.enqueue(i.encode(e))}d(),r.onAllReady&&!o.closed&&r.onAllReady(),o.closed||(o.closed=!0,s.close())}return new ReadableStream({async start(e){a=e,s&&s>0&&(l=setTimeout(()=>{!o.shellSent&&!o.closed&&f(Error(`Shell ready timeout after ${s}ms`),!0,o,a,i,d,r)},s));try{await p(e)}catch(e){f(e instanceof Error?e:Error(String(e)),!o.shellSent,o,a,i,d,r)}},cancel(){if(d(),!o.closed&&a){o.closed=!0;try{a.close()}catch{}}}})}function b(e,t){return`<!DOCTYPE html>
|
|
136
136
|
<html lang="en">
|
|
137
137
|
<head>
|
|
138
138
|
<meta charset="utf-8">
|
|
@@ -141,9 +141,9 @@ import{getRequestURL as e}from"h3";import{createNotFoundError as t,isHttpError a
|
|
|
141
141
|
${e.description?`<meta name="description" content="${v(String(e.description))}">`:``}
|
|
142
142
|
</head>
|
|
143
143
|
<body>
|
|
144
|
-
`}function x(e,t){let
|
|
144
|
+
`}function x(e,t){let r=e.default;if(r&&typeof r==`function`)try{let e=r(t);if(e&&typeof e.then==`function`){let e=r.name||`Page`;return` <div id="app" data-page="${v(String(e))}" data-props='${v(JSON.stringify(t))}'>
|
|
145
145
|
<!-- Async component — awaiting hydration -->
|
|
146
|
-
</div>\n`}return` <div id="app">${
|
|
146
|
+
</div>\n`}return` <div id="app">${n(e)}</div>\n`}catch(e){console.error(`[streaming] Error rendering page component:`,e)}let i=e.default?.name||`Page`;return` <div id="app" data-page="${v(String(i))}" data-props='${v(JSON.stringify(t))}'>
|
|
147
147
|
<!-- Component render fallback -->
|
|
148
148
|
</div>\n`}function S(){return` </body>
|
|
149
149
|
</html>`}function C(e){let t=process.env.NODE_ENV!==`production`,n=e.stack?`<pre style="
|
|
@@ -181,4 +181,4 @@ import{getRequestURL as e}from"h3";import{createNotFoundError as t,isHttpError a
|
|
|
181
181
|
</details>
|
|
182
182
|
`:``}
|
|
183
183
|
</div>
|
|
184
|
-
`}export function createStreamingResponse(e,t={}){let n=new Headers({"Content-Type":`text/html; charset=utf-8`,"Transfer-Encoding":`chunked`,...t.headers});return new Response(e,{status:t.status||200,headers:n})}function w(e,t,n){return async()=>(e.value??=await r({baseDir:t,devMode:n}),e.value)}function T(e,t,n){return async(r,i)=>e?
|
|
184
|
+
`}export function createStreamingResponse(e,t={}){let n=new Headers({"Content-Type":`text/html; charset=utf-8`,"Transfer-Encoding":`chunked`,...t.headers});return new Response(e,{status:t.status||200,headers:n})}function w(e,t,n){return async()=>(e.value??=await r({baseDir:t,devMode:n}),e.value)}function T(e,t,n){return async(r,i)=>e?o(r,i,t):createErrorResponse(r,n)}export function createNitroRenderer(e){let{avalonConfig:t,isDev:n=!1,enableCustomErrorPages:r=!0}=e,o={isDev:n,avalonConfig:t,loadPageModule:e.loadPageModule,pagesDir:t.pagesDir};r&&a(o).catch(e=>{console.warn(`[renderer] Failed to discover error pages:`,e)});let c=w({value:null},t.srcDir||`src`,n),d=T(r,o,n);return async function(r){let a=getRequestURL(r).pathname;try{let o=await i(r,await c(),{devMode:n});if(o)return n&&console.log(`[renderer] Middleware terminated request for ${a}`),o;let u=r.context.route,f=null;if(f=u||(e.resolvePageRoute?await e.resolvePageRoute(a,t.pagesDir):await E(a,t.pagesDir)),!f)return d(s(`Page not found: ${a}`),r);let m=e.loadPageModule?await e.loadPageModule(f.filePath):await D(f.filePath),h=createRenderContext(r,r.context.params||f.params);if(e.resolveLayouts&&(h.layoutContext={layouts:await e.resolveLayouts(a,t)}),t.streaming){let e=await renderPageStream(m,h,{onShellReady:()=>{setResponseHeader(r,`Content-Type`,`text/html; charset=utf-8`)}});return new Response(e,{headers:{"Content-Type":`text/html; charset=utf-8`}})}else{let t=await renderPage(m,h,{},e.wrapWithLayouts),r=injectHydrationScript(t.html,n);return new Response(r,{status:t.statusCode,headers:t.headers})}}catch(e){return console.error(`[Nitro Renderer Error]`,e),d(e instanceof Error?e:Error(String(e)),r)}}}async function E(e,t){return e===`/`||e===``?{filePath:`src/pages/index.tsx`,pattern:`/`,params:{}}:{filePath:`src/pages/${e.replace(/^\//,``).replace(/\/$/,``)}.tsx`,pattern:e,params:{}}}async function D(e){return{default:()=>null,metadata:{title:`Avalon Page`}}}export function createNitroCatchAllRenderer(e){let{avalonConfig:t,isDev:n=!1,loadPageModule:r,resolveLayouts:o,enableCustomErrorPages:c=!0}=e,d={isDev:n,avalonConfig:t,loadPageModule:r,pagesDir:t.pagesDir};c&&a(d).catch(e=>{console.warn(`[renderer] Failed to discover error pages:`,e)});let f=w({value:null},t.srcDir||`src`,n),m=T(c,d,n);return async function(a){let c=getRequestURL(a).pathname;try{let u=await i(a,await f(),{devMode:n});if(u)return n&&console.log(`[renderer] Middleware terminated request for ${c}`),u;let d=a.context.params||{},h=d.slug||c.replace(/^\//,``)||`index`,g=`${t.pagesDir}/${h}.tsx`,_;try{_=await r(g)}catch(e){try{_=await r(`${t.pagesDir}/${h}/index.tsx`)}catch(r){return n&&(console.debug(`[renderer] Page not found: ${g}`,e),console.debug(`[renderer] Index fallback not found: ${t.pagesDir}/${h}/index.tsx`,r)),m(s(`Page not found: ${c}`),a)}}let v=createRenderContext(a,d);if(o&&(v.layoutContext={layouts:await o(c,t)}),t.streaming){let e=await renderPageStream(_,v,{onShellReady:()=>{setResponseHeader(a,`Content-Type`,`text/html; charset=utf-8`)}});return new Response(e,{headers:{"Content-Type":`text/html; charset=utf-8`}})}else{let t=await renderPage(_,v,{},e.wrapWithLayouts),r=injectHydrationScript(t.html,n);return new Response(r,{status:t.statusCode,headers:t.headers})}}catch(e){return console.error(`[Nitro Catch-All Renderer Error]`,e),m(e instanceof Error?e:Error(String(e)),a)}}}export{clearMiddlewareCache as clearRendererMiddlewareCache}from"../middleware/index.js";
|
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
import type { IslandState } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export declare
|
|
9
|
-
|
|
10
|
-
static deserialize(serializedState: string): IslandState;
|
|
11
|
-
private static transformForSerialization;
|
|
12
|
-
private static reviver;
|
|
13
|
-
static validate(state: IslandState): {
|
|
14
|
-
valid: boolean;
|
|
15
|
-
errors: string[];
|
|
16
|
-
};
|
|
17
|
-
static clone(state: IslandState): IslandState;
|
|
18
|
-
static equals(state1: IslandState, state2: IslandState): boolean;
|
|
19
|
-
}
|
|
1
|
+
import type { IslandState } from "../schemas/layout.ts";
|
|
2
|
+
export declare function serialize(state: IslandState): string;
|
|
3
|
+
export declare function deserialize(serializedState: string): IslandState;
|
|
4
|
+
export declare function validate(state: IslandState): {
|
|
5
|
+
valid: boolean;
|
|
6
|
+
errors: string[];
|
|
7
|
+
};
|
|
8
|
+
export declare function clone(state: IslandState): IslandState;
|
|
9
|
+
export declare function equals(state1: IslandState, state2: IslandState): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function e(t){if(t==null)return null;if(t instanceof Date)return{__type:`Date`,__value:t.toISOString()};if(t instanceof RegExp)return{__type:`RegExp`,__value:{source:t.source,flags:t.flags}};if(t instanceof Map)return{__type:`Map`,__value:Array.from(t.entries()).map(([t,n])=>[e(t),e(n)])};if(t instanceof Set)return{__type:`Set`,__value:Array.from(t.values()).map(t=>e(t))};if(typeof t==`function`)return null;if(Array.isArray(t))return t.map(t=>e(t));if(typeof t==`object`){let n={},r=t;for(let t in r)Object.hasOwn(r,t)&&(n[t]=e(r[t]));return n}return t}function t(e,t){if(t&&typeof t==`object`){let e=t;if(e.__type&&e.__value!==void 0)switch(e.__type){case`Date`:return new Date(e.__value);case`RegExp`:{let t=e.__value;return new RegExp(t.source,t.flags)}case`Map`:return new Map(e.__value);case`Set`:return new Set(e.__value);default:return e.__value}}return t}export function serialize(t){try{let n=e(t);return JSON.stringify(n)}catch(e){throw Error(`State serialization failed: ${e instanceof Error?e.message:String(e)}`)}}export function deserialize(e){try{return JSON.parse(e,t)}catch(e){throw Error(`State deserialization failed: ${e instanceof Error?e.message:String(e)}`)}}export function validate(e){let t=[];try{let i=serialize(e),a=new Blob([i]).size;a>5*1024*1024&&t.push(`Serialized state size (${Math.round(a/1024)}KB) exceeds 5MB limit`),deserialize(i)}catch(e){t.push(e instanceof Error?e.message:String(e))}return{valid:t.length===0,errors:t}}export function clone(e){try{return deserialize(serialize(e))}catch{return{...e}}}export function equals(e,t){try{return serialize(e)===serialize(t)}catch{return!1}}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* `useState` that survives page navigations.
|
|
3
3
|
*
|
|
4
4
|
* State is serialized to sessionStorage (or localStorage) via
|
|
5
|
-
* {@link
|
|
5
|
+
* {@link serialize}/{@link deserialize}, so Date, Map, Set, and RegExp are preserved.
|
|
6
6
|
* On the server or when storage is unavailable, falls back to in-memory state.
|
|
7
7
|
*
|
|
8
8
|
* @param id - Unique key for this piece of state.
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
export declare function usePersistentState<T>(id: string, initialValue: T, options?: {
|
|
30
|
-
storage?:
|
|
30
|
+
storage?: "session" | "local";
|
|
31
31
|
}): [T, (value: T | ((prev: T) => T)) => void, () => void];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{useCallback as e,useEffect as t,useState as n}from"preact/hooks";import{deserialize as r,serialize as i}from"./island-state-serializer.js";export function usePersistentState(a,o,s){let c=s?.storage??`session`,l=`avalon-island:${a}`,[u,d]=n(()=>{if(globalThis.window===void 0)return o;try{let e=(c===`local`?localStorage:sessionStorage).getItem(l);return e===null?o:r(e).v??o}catch{return o}});return t(()=>{if(globalThis.window!==void 0)try{(c===`local`?localStorage:sessionStorage).setItem(l,i({v:u}))}catch{}},[u,l,c]),[u,e(e=>{d(t=>typeof e==`function`?e(t):e)},[]),e(()=>{if(d(o),globalThis.window!==void 0)try{(c===`local`?localStorage:sessionStorage).removeItem(l)}catch{}},[o,l,c])]}
|
|
@@ -23,9 +23,9 @@ export declare const ScriptConfigSchema: z.ZodUnion<readonly [z.ZodString, z.Zod
|
|
|
23
23
|
integrity: z.ZodOptional<z.ZodString>;
|
|
24
24
|
nomodule: z.ZodOptional<z.ZodBoolean>;
|
|
25
25
|
referrerpolicy: z.ZodOptional<z.ZodEnum<{
|
|
26
|
+
origin: "origin";
|
|
26
27
|
"no-referrer": "no-referrer";
|
|
27
28
|
"no-referrer-when-downgrade": "no-referrer-when-downgrade";
|
|
28
|
-
origin: "origin";
|
|
29
29
|
"origin-when-cross-origin": "origin-when-cross-origin";
|
|
30
30
|
"same-origin": "same-origin";
|
|
31
31
|
"strict-origin": "strict-origin";
|
|
@@ -53,9 +53,9 @@ export declare const RenderOptionsSchema: z.ZodObject<{
|
|
|
53
53
|
integrity: z.ZodOptional<z.ZodString>;
|
|
54
54
|
nomodule: z.ZodOptional<z.ZodBoolean>;
|
|
55
55
|
referrerpolicy: z.ZodOptional<z.ZodEnum<{
|
|
56
|
+
origin: "origin";
|
|
56
57
|
"no-referrer": "no-referrer";
|
|
57
58
|
"no-referrer-when-downgrade": "no-referrer-when-downgrade";
|
|
58
|
-
origin: "origin";
|
|
59
59
|
"origin-when-cross-origin": "origin-when-cross-origin";
|
|
60
60
|
"same-origin": "same-origin";
|
|
61
61
|
"strict-origin": "strict-origin";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type { ComponentChildren } from "preact";
|
|
2
|
+
import { z } from "zod";
|
|
3
3
|
/**
|
|
4
4
|
* Layout Context Schema - Contains request information and state for layout processing
|
|
5
5
|
*/
|
|
@@ -132,10 +132,10 @@ export declare const LayoutErrorBoundaryPropsSchema: z.ZodObject<{
|
|
|
132
132
|
*/
|
|
133
133
|
export declare const ErrorRecoveryStrategySchema: z.ZodObject<{
|
|
134
134
|
type: z.ZodEnum<{
|
|
135
|
-
redirect: "redirect";
|
|
136
|
-
skip: "skip";
|
|
137
135
|
fallback: "fallback";
|
|
138
136
|
retry: "retry";
|
|
137
|
+
skip: "skip";
|
|
138
|
+
redirect: "redirect";
|
|
139
139
|
}>;
|
|
140
140
|
maxRetries: z.ZodOptional<z.ZodNumber>;
|
|
141
141
|
fallbackComponent: z.ZodOptional<z.ZodAny>;
|
|
@@ -3,7 +3,7 @@ export declare const routingValidators: {
|
|
|
3
3
|
readonly fileSystemRoute: (data: unknown) => {
|
|
4
4
|
pattern: any;
|
|
5
5
|
filePath: string;
|
|
6
|
-
routeType: "
|
|
6
|
+
routeType: "group" | "static" | "index" | "dynamic" | "catch-all";
|
|
7
7
|
dynamicSegments: string[];
|
|
8
8
|
priority: number;
|
|
9
9
|
isPrivate: boolean;
|
|
@@ -93,7 +93,7 @@ export declare const safeRoutingValidators: {
|
|
|
93
93
|
readonly fileSystemRoute: (data: unknown) => import("../index.ts").ValidationResult<{
|
|
94
94
|
pattern: any;
|
|
95
95
|
filePath: string;
|
|
96
|
-
routeType: "
|
|
96
|
+
routeType: "group" | "static" | "index" | "dynamic" | "catch-all";
|
|
97
97
|
dynamicSegments: string[];
|
|
98
98
|
priority: number;
|
|
99
99
|
isPrivate: boolean;
|
|
@@ -4,9 +4,9 @@ import type { ComponentType } from 'preact/compat';
|
|
|
4
4
|
* Route Type Schema - Defines the different types of routes supported
|
|
5
5
|
*/
|
|
6
6
|
export declare const RouteTypeSchema: z.ZodEnum<{
|
|
7
|
+
group: "group";
|
|
7
8
|
static: "static";
|
|
8
9
|
index: "index";
|
|
9
|
-
group: "group";
|
|
10
10
|
dynamic: "dynamic";
|
|
11
11
|
"catch-all": "catch-all";
|
|
12
12
|
}>;
|
|
@@ -17,9 +17,9 @@ export declare const FileSystemRouteSchema: z.ZodObject<{
|
|
|
17
17
|
pattern: z.ZodAny;
|
|
18
18
|
filePath: z.ZodString;
|
|
19
19
|
routeType: z.ZodEnum<{
|
|
20
|
+
group: "group";
|
|
20
21
|
static: "static";
|
|
21
22
|
index: "index";
|
|
22
|
-
group: "group";
|
|
23
23
|
dynamic: "dynamic";
|
|
24
24
|
"catch-all": "catch-all";
|
|
25
25
|
}>;
|
|
@@ -266,9 +266,9 @@ export declare const RouteHandlerSchema: z.ZodObject<{
|
|
|
266
266
|
metadata: z.ZodObject<{
|
|
267
267
|
filePath: z.ZodString;
|
|
268
268
|
routeType: z.ZodEnum<{
|
|
269
|
+
group: "group";
|
|
269
270
|
static: "static";
|
|
270
271
|
index: "index";
|
|
271
|
-
group: "group";
|
|
272
272
|
dynamic: "dynamic";
|
|
273
273
|
"catch-all": "catch-all";
|
|
274
274
|
}>;
|
|
@@ -284,9 +284,9 @@ export declare const RouteCacheEntrySchema: z.ZodObject<{
|
|
|
284
284
|
pattern: z.ZodAny;
|
|
285
285
|
filePath: z.ZodString;
|
|
286
286
|
routeType: z.ZodEnum<{
|
|
287
|
+
group: "group";
|
|
287
288
|
static: "static";
|
|
288
289
|
index: "index";
|
|
289
|
-
group: "group";
|
|
290
290
|
dynamic: "dynamic";
|
|
291
291
|
"catch-all": "catch-all";
|
|
292
292
|
}>;
|
|
@@ -11,12 +11,18 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
export interface IslandDirective {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
/** Hydration condition (built-in or custom directive name) */
|
|
15
|
+
condition?:
|
|
16
|
+
| "on:visible"
|
|
17
|
+
| "on:interaction"
|
|
18
|
+
| "on:idle"
|
|
19
|
+
| "on:client"
|
|
20
|
+
| `media:${string}`
|
|
21
|
+
| `on:${string}`;
|
|
22
|
+
/** Optional argument passed to custom hydration directives */
|
|
23
|
+
conditionArg?: string;
|
|
24
|
+
/** Force SSR-only rendering without client hydration */
|
|
25
|
+
ssrOnly?: boolean;
|
|
26
|
+
/** Whether to render server-side (default: true) */
|
|
27
|
+
ssr?: boolean;
|
|
22
28
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
export type {
|
|
4
|
-
export type
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
1
|
+
import type { ComponentChildren, ComponentType } from "preact";
|
|
2
|
+
import type { ErrorRecoveryStrategy, IslandState, LayoutConfig, LayoutContext, LayoutDiscoveryOptions, LayoutErrorBoundaryProps, LayoutErrorInfo, LayoutHandler, LayoutLoader, LayoutProps, LayoutRoute, LayoutRule, PersistentIslandProps, ResolvedLayout, RouteInfo, StreamingComponent, StreamingLayoutProps } from "../schemas/layout.ts";
|
|
3
|
+
export type { ComponentChildren, ComponentType } from "preact";
|
|
4
|
+
export { createEnhancedLayoutResolver, EnhancedLayoutResolver, type EnhancedLayoutResolverOptions, EnhancedLayoutResolverUtils, } from "../core/layout/enhanced-layout-resolver.ts";
|
|
5
|
+
export { type CacheConfig, type CacheEntry, type CacheStats, LayoutCacheManager, } from "../core/layout/layout-cache-manager.ts";
|
|
6
|
+
export { LayoutComposer } from "../core/layout/layout-composer.ts";
|
|
7
|
+
export { LayoutDataLoader } from "../core/layout/layout-data-loader.ts";
|
|
8
|
+
export { LayoutDiscovery } from "../core/layout/layout-discovery.ts";
|
|
9
|
+
export { LayoutMatcher as LayoutMatcherClass } from "../core/layout/layout-matcher.ts";
|
|
10
|
+
export type { EnhancedLayoutContext, ErrorRecoveryStrategy, IslandState, IslandStateClearer, IslandStateLoader, IslandStateSaver, LayoutCache, LayoutConfig, LayoutContext, LayoutData, LayoutDiscoveryOptions, LayoutErrorBoundaryProps, LayoutErrorHandler, LayoutErrorInfo, LayoutFallbackRenderer, LayoutHandler, LayoutLoader, LayoutMatcherFunction, LayoutProps, LayoutRetryFunction, LayoutRoute, LayoutRule, PersistentIslandContext, PersistentIslandProps, ResolvedLayout, RouteInfo, StreamingComponent, StreamingLayoutProps, StreamingReadyCheck, } from "../schemas/layout.ts";
|
|
11
11
|
/**
|
|
12
12
|
* Layout Discovery Interface
|
|
13
13
|
*/
|
|
@@ -151,7 +151,7 @@ export interface LayoutDebugInfo {
|
|
|
151
151
|
size: number;
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
|
-
export type LayoutEventType =
|
|
154
|
+
export type LayoutEventType = "layout-discovered" | "layout-loaded" | "layout-rendered" | "layout-error" | "layout-cached" | "island-state-saved" | "island-state-loaded" | "streaming-started" | "streaming-completed";
|
|
155
155
|
export interface LayoutEventData {
|
|
156
156
|
type: LayoutEventType;
|
|
157
157
|
timestamp: number;
|
package/dist/src/types/layout.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{createEnhancedLayoutResolver,EnhancedLayoutResolver,EnhancedLayoutResolverUtils}from"../core/layout/enhanced-layout-resolver.js";export{LayoutCacheManager}from"../core/layout/layout-cache-manager.js";export{LayoutComposer}from"../core/layout/layout-composer.js";export{LayoutDataLoader}from"../core/layout/layout-data-loader.js";export{LayoutDiscovery}from"../core/layout/layout-discovery.js";export{LayoutMatcher as LayoutMatcherClass}from"../core/layout/layout-matcher.js";
|