@useavalon/avalon 0.1.22 → 0.1.24

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.
Files changed (115) hide show
  1. package/dist/mod.d.ts +50 -0
  2. package/dist/src/build/integration-bundler-plugin.d.ts +25 -0
  3. package/dist/src/build/integration-config.d.ts +44 -0
  4. package/dist/src/build/integration-detection-plugin.d.ts +20 -0
  5. package/dist/src/build/integration-resolver-plugin.d.ts +10 -0
  6. package/dist/src/build/island-manifest.d.ts +57 -0
  7. package/dist/src/build/island-types-generator.d.ts +49 -0
  8. package/dist/src/build/mdx-island-transform.d.ts +23 -0
  9. package/dist/src/build/mdx-plugin.d.ts +36 -0
  10. package/dist/src/build/page-island-transform.d.ts +41 -0
  11. package/dist/src/build/prop-extractors/index.d.ts +8 -0
  12. package/dist/src/build/prop-extractors/lit.d.ts +11 -0
  13. package/dist/src/build/prop-extractors/qwik.d.ts +9 -0
  14. package/dist/src/build/prop-extractors/solid.d.ts +12 -0
  15. package/dist/src/build/prop-extractors/svelte.d.ts +13 -0
  16. package/dist/src/build/prop-extractors/vue.d.ts +19 -0
  17. package/dist/src/build/sidecar-file-manager.d.ts +23 -0
  18. package/dist/src/build/sidecar-renderer.d.ts +22 -0
  19. package/dist/src/client/adapters/index.d.ts +15 -0
  20. package/dist/src/client/components.d.ts +21 -0
  21. package/dist/src/client/css-hmr-handler.d.ts +94 -0
  22. package/dist/src/client/framework-adapter.d.ts +225 -0
  23. package/dist/src/client/hmr-coordinator.d.ts +88 -0
  24. package/dist/src/components/Image.d.ts +61 -0
  25. package/dist/src/components/IslandErrorBoundary.d.ts +37 -0
  26. package/dist/src/components/IslandErrorBoundary.js +1 -1
  27. package/dist/src/components/LayoutDataErrorBoundary.d.ts +34 -0
  28. package/dist/src/components/LayoutDataErrorBoundary.js +1 -1
  29. package/dist/src/components/LayoutErrorBoundary.d.ts +25 -0
  30. package/dist/src/components/LayoutErrorBoundary.js +1 -1
  31. package/dist/src/components/PersistentIsland.d.ts +36 -0
  32. package/dist/src/components/StreamingErrorBoundary.d.ts +42 -0
  33. package/dist/src/components/StreamingErrorBoundary.js +1 -1
  34. package/dist/src/components/StreamingLayout.d.ts +83 -0
  35. package/dist/src/components/StreamingLayout.js +1 -1
  36. package/dist/src/core/components/component-analyzer.d.ts +48 -0
  37. package/dist/src/core/components/component-detection.d.ts +72 -0
  38. package/dist/src/core/components/enhanced-framework-detector.d.ts +78 -0
  39. package/dist/src/core/components/framework-registry.d.ts +114 -0
  40. package/dist/src/core/content/mdx-processor.d.ts +14 -0
  41. package/dist/src/core/integrations/index.d.ts +6 -0
  42. package/dist/src/core/integrations/loader.d.ts +35 -0
  43. package/dist/src/core/integrations/registry.d.ts +51 -0
  44. package/dist/src/core/islands/island-persistence.d.ts +74 -0
  45. package/dist/src/core/islands/island-state-serializer.d.ts +53 -0
  46. package/dist/src/core/islands/persistent-island-context.d.ts +36 -0
  47. package/dist/src/core/islands/use-persistent-state.d.ts +17 -0
  48. package/dist/src/core/layout/enhanced-layout-resolver.d.ts +73 -0
  49. package/dist/src/core/layout/layout-cache-manager.d.ts +66 -0
  50. package/dist/src/core/layout/layout-composer.d.ts +63 -0
  51. package/dist/src/core/layout/layout-data-loader.d.ts +146 -0
  52. package/dist/src/core/layout/layout-discovery.d.ts +51 -0
  53. package/dist/src/core/layout/layout-matcher.d.ts +77 -0
  54. package/dist/src/core/layout/layout-types.d.ts +94 -0
  55. package/dist/src/core/modules/framework-module-resolver.d.ts +85 -0
  56. package/dist/src/islands/component-analysis.d.ts +38 -0
  57. package/dist/src/islands/css-utils.d.ts +81 -0
  58. package/dist/src/islands/discovery/index.d.ts +16 -0
  59. package/dist/src/islands/discovery/registry.d.ts +141 -0
  60. package/dist/src/islands/discovery/resolver.d.ts +190 -0
  61. package/dist/src/islands/discovery/scanner.d.ts +55 -0
  62. package/dist/src/islands/discovery/types.d.ts +92 -0
  63. package/dist/src/islands/discovery/validator.d.ts +89 -0
  64. package/dist/src/islands/discovery/watcher.d.ts +95 -0
  65. package/dist/src/islands/framework-detection.d.ts +53 -0
  66. package/dist/src/islands/integration-loader.d.ts +139 -0
  67. package/dist/src/islands/island.d.ts +55 -0
  68. package/dist/src/islands/render-cache.d.ts +203 -0
  69. package/dist/src/islands/types.d.ts +63 -0
  70. package/dist/src/islands/universal-css-collector.d.ts +41 -0
  71. package/dist/src/islands/universal-head-collector.d.ts +42 -0
  72. package/dist/src/layout-system.d.ts +92 -592
  73. package/dist/src/middleware/discovery.d.ts +70 -0
  74. package/dist/src/middleware/executor.d.ts +52 -0
  75. package/dist/src/middleware/index.d.ts +43 -0
  76. package/dist/src/middleware/types.d.ts +89 -0
  77. package/dist/src/nitro/build-config.d.ts +163 -0
  78. package/dist/src/nitro/config.d.ts +268 -0
  79. package/dist/src/nitro/error-handler.d.ts +151 -0
  80. package/dist/src/nitro/index.d.ts +15 -0
  81. package/dist/src/nitro/island-manifest.d.ts +191 -0
  82. package/dist/src/nitro/middleware-adapter.d.ts +151 -0
  83. package/dist/src/nitro/renderer.d.ts +342 -0
  84. package/dist/src/nitro/route-discovery.d.ts +142 -0
  85. package/dist/src/nitro/types.d.ts +278 -0
  86. package/dist/src/render/collect-css.d.ts +28 -0
  87. package/dist/src/render/error-pages.d.ts +14 -0
  88. package/dist/src/render/isolated-ssr-renderer.d.ts +127 -0
  89. package/dist/src/render/ssr.d.ts +56 -0
  90. package/dist/src/schemas/api.d.ts +27 -0
  91. package/dist/src/schemas/core.d.ts +75 -0
  92. package/dist/src/schemas/index.d.ts +79 -0
  93. package/dist/src/schemas/index.js +1 -1
  94. package/dist/src/schemas/layout.d.ts +282 -0
  95. package/dist/src/schemas/routing/index.d.ts +181 -0
  96. package/dist/src/schemas/routing.d.ts +388 -0
  97. package/dist/src/types/as-island.d.ts +17 -0
  98. package/dist/src/types/layout.d.ts +177 -0
  99. package/dist/src/types/routing.d.ts +297 -0
  100. package/dist/src/types/types.d.ts +6 -0
  101. package/dist/src/utils/dev-logger.d.ts +84 -0
  102. package/dist/src/utils/fs.d.ts +41 -0
  103. package/dist/src/vite-plugin/auto-discover.d.ts +72 -0
  104. package/dist/src/vite-plugin/config.d.ts +82 -0
  105. package/dist/src/vite-plugin/errors.d.ts +62 -0
  106. package/dist/src/vite-plugin/image-optimization.d.ts +36 -0
  107. package/dist/src/vite-plugin/integration-activator.d.ts +48 -0
  108. package/dist/src/vite-plugin/island-sidecar-plugin.d.ts +17 -0
  109. package/dist/src/vite-plugin/module-discovery.d.ts +66 -0
  110. package/dist/src/vite-plugin/nitro-integration.d.ts +56 -0
  111. package/dist/src/vite-plugin/nitro-integration.js +1 -1
  112. package/dist/src/vite-plugin/plugin.d.ts +51 -0
  113. package/dist/src/vite-plugin/types.d.ts +281 -0
  114. package/dist/src/vite-plugin/validation.d.ts +93 -0
  115. package/package.json +33 -9
@@ -0,0 +1,83 @@
1
+ import { ComponentChildren, ComponentType } from 'preact';
2
+ import type { StreamingLayoutProps } from '../types/layout.ts';
3
+ /**
4
+ * Streaming Layout Component Props
5
+ */
6
+ export interface StreamingLayoutComponentProps extends StreamingLayoutProps {
7
+ /**
8
+ * Component to render when ready
9
+ */
10
+ component: ComponentType<any>;
11
+ /**
12
+ * Props to pass to the component
13
+ */
14
+ componentProps?: any;
15
+ /**
16
+ * Function to check if component is ready
17
+ */
18
+ isReady?: () => Promise<boolean>;
19
+ /**
20
+ * Timeout for loading (ms)
21
+ */
22
+ timeout?: number;
23
+ /**
24
+ * Error boundary fallback
25
+ */
26
+ onError?: (error: Error) => ComponentChildren;
27
+ /**
28
+ * Loading state callback
29
+ */
30
+ onLoadingChange?: (isLoading: boolean) => void;
31
+ }
32
+ /**
33
+ * Streaming Layout Component with Suspense-like behavior
34
+ */
35
+ export declare function StreamingLayout(props: StreamingLayoutComponentProps): ComponentChildren;
36
+ /**
37
+ * Suspense-like boundary for streaming components
38
+ */
39
+ export interface StreamingSuspenseProps {
40
+ /**
41
+ * Fallback to show while loading
42
+ */
43
+ fallback?: ComponentChildren;
44
+ /**
45
+ * Children components
46
+ */
47
+ children: ComponentChildren;
48
+ /**
49
+ * Priority for this suspense boundary
50
+ */
51
+ priority?: 'high' | 'medium' | 'low';
52
+ /**
53
+ * Timeout for all children (ms)
54
+ */
55
+ timeout?: number;
56
+ /**
57
+ * Error boundary for failed components
58
+ */
59
+ onError?: (error: Error) => ComponentChildren;
60
+ }
61
+ /**
62
+ * Streaming Suspense Boundary Component
63
+ */
64
+ export declare function StreamingSuspense(props: StreamingSuspenseProps): ComponentChildren;
65
+ /**
66
+ * Higher-order component to add streaming capabilities
67
+ */
68
+ export declare function withStreaming<P extends object>(WrappedComponent: ComponentType<P>, streamingOptions?: {
69
+ fallback?: ComponentChildren;
70
+ priority?: 'high' | 'medium' | 'low';
71
+ isReady?: () => Promise<boolean>;
72
+ timeout?: number;
73
+ }): (props: P) => import("preact").JSX.Element;
74
+ /**
75
+ * Hook for streaming component state
76
+ */
77
+ export declare function useStreamingState(isReady?: () => Promise<boolean>, timeout?: number): {
78
+ retry: () => void;
79
+ isReady: boolean;
80
+ isLoading: boolean;
81
+ error: Error | null;
82
+ hasTimedOut: boolean;
83
+ };
@@ -26,4 +26,4 @@ import{Component as e}from"preact";import{useState as t,useEffect as n,useRef as
26
26
  0% { background-position: 200% 0; }
27
27
  100% { background-position: -200% 0; }
28
28
  }
29
- `})]})}export function StreamingSuspense(e){let{fallback:o,children:c,priority:u=`medium`,timeout:d=5e3,onError:f}=e,[p,m]=t(!0),[h,g]=t(null),[_,v]=t(!1),y=r(),b=r(!0);n(()=>()=>{b.current=!1},[]),n(()=>(d>0&&(y.current=setTimeout(()=>{b.current&&p&&(v(!0),m(!1))},d)),()=>{y.current&&clearTimeout(y.current)}),[d,p]);let x=e=>{g(e),m(!1),y.current&&clearTimeout(y.current)};return h?f?f(h):i(`div`,{class:`streaming-suspense-error`,"data-priority":u,children:[i(`p`,{children:[`Suspense boundary error: `,h.message]}),a(`button`,{onClick:()=>{g(null),m(!0),v(!1)},children:`Retry`})]}):_?a(`div`,{class:`streaming-suspense-timeout`,"data-priority":u,children:o||i(`div`,{class:`suspense-timeout-message`,children:[a(`p`,{children:`Suspense boundary timed out`}),a(`button`,{onClick:()=>{v(!1),m(!0)},children:`Retry`})]})}):p?a(`div`,{class:`streaming-suspense-loading`,"data-priority":u,children:o||a(s,{priority:u})}):a(`div`,{class:`streaming-suspense-ready`,"data-priority":u,children:a(l,{onError:x,children:c})})}class l extends e{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`StreamingErrorBoundary caught an error:`,e,t),this.props.onError?.(e)}render(){return this.state.hasError?i(`div`,{class:`streaming-error-boundary`,children:[a(`p`,{children:`Something went wrong in streaming component.`}),a(`button`,{onClick:()=>this.setState({hasError:!1,error:void 0}),children:`Retry`})]}):this.props.children}}export function withStreaming(e,t={}){return function(n){return a(StreamingLayout,{component:e,componentProps:n,priority:`medium`,...t})}}export function useStreamingState(e,r=5e3){let[i,a]=t({isReady:!1,isLoading:!0,error:null,hasTimedOut:!1});n(()=>{if(!e){a(e=>({...e,isReady:!0,isLoading:!1}));return}let t=!1,n;return(async()=>{try{r>0&&(n=setTimeout(()=>{t||a(e=>({...e,hasTimedOut:!0,isLoading:!1}))},r));let i=await e();if(t)return;n&&clearTimeout(n),a(e=>({...e,isReady:i,isLoading:!1,hasTimedOut:!1}))}catch(e){if(t)return;n&&clearTimeout(n),a(t=>({...t,error:e,isLoading:!1}))}})(),()=>{t=!0,n&&clearTimeout(n)}},[e,r]);let o=()=>{a({isReady:!1,isLoading:!0,error:null,hasTimedOut:!1})};return{...i,retry:o}}
29
+ `})]})}export function StreamingSuspense(e){let{fallback:o,children:c,priority:u=`medium`,timeout:d=5e3,onError:f}=e,[p,m]=t(!0),[h,g]=t(null),[_,v]=t(!1),y=r(),b=r(!0);n(()=>()=>{b.current=!1},[]),n(()=>(d>0&&(y.current=setTimeout(()=>{b.current&&p&&(v(!0),m(!1))},d)),()=>{y.current&&clearTimeout(y.current)}),[d,p]);let x=e=>{g(e),m(!1),y.current&&clearTimeout(y.current)};return h?f?f(h):i(`div`,{class:`streaming-suspense-error`,"data-priority":u,children:[i(`p`,{children:[`Suspense boundary error: `,h.message]}),a(`button`,{onClick:()=>{g(null),m(!0),v(!1)},children:`Retry`})]}):_?a(`div`,{class:`streaming-suspense-timeout`,"data-priority":u,children:o||i(`div`,{class:`suspense-timeout-message`,children:[a(`p`,{children:`Suspense boundary timed out`}),a(`button`,{onClick:()=>{v(!1),m(!0)},children:`Retry`})]})}):p?a(`div`,{class:`streaming-suspense-loading`,"data-priority":u,children:o||a(s,{priority:u})}):a(`div`,{class:`streaming-suspense-ready`,"data-priority":u,children:a(l,{onError:x,children:c})})}class l extends e{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`StreamingErrorBoundary caught an error:`,e,t),this.props.onError?.(e)}render(){return this.state.hasError?i(`div`,{class:`streaming-error-boundary`,children:[a(`p`,{children:`Something went wrong in streaming component.`}),a(`button`,{onClick:()=>this.setState({hasError:!1,error:void 0}),children:`Retry`})]}):this.props.children}}export function withStreaming(e,t={}){return function(n){return a(StreamingLayout,{component:e,componentProps:n,priority:`medium`,...t,children:null})}}export function useStreamingState(e,r=5e3){let[i,a]=t({isReady:!1,isLoading:!0,error:null,hasTimedOut:!1});n(()=>{if(!e){a(e=>({...e,isReady:!0,isLoading:!1}));return}let t=!1,n;return(async()=>{try{r>0&&(n=setTimeout(()=>{t||a(e=>({...e,hasTimedOut:!0,isLoading:!1}))},r));let i=await e();if(t)return;n&&clearTimeout(n),a(e=>({...e,isReady:i,isLoading:!1,hasTimedOut:!1}))}catch(e){if(t)return;n&&clearTimeout(n),a(t=>({...t,error:e,isLoading:!1}))}})(),()=>{t=!0,n&&clearTimeout(n)}},[e,r]);let o=()=>{a({isReady:!1,isLoading:!0,error:null,hasTimedOut:!1})};return{...i,retry:o}}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Component Analyzer - High-level interface for component detection system
3
+ *
4
+ * This module provides a convenient interface for analyzing components
5
+ * and making hydration decisions in the SSR system.
6
+ */
7
+ import { type ComponentAnalysis, type DetectionResult, type ComponentMetadata } from './component-detection.ts';
8
+ export interface AnalyzerOptions {
9
+ forceSSROnly?: boolean;
10
+ detectScripts?: boolean;
11
+ suppressWarnings?: boolean;
12
+ logDecisions?: boolean;
13
+ }
14
+ export interface AnalysisReport {
15
+ metadata: ComponentMetadata;
16
+ decision: DetectionResult;
17
+ analysis: ComponentAnalysis;
18
+ }
19
+ /**
20
+ * Analyzes a component file and returns comprehensive analysis report
21
+ */
22
+ export declare function analyzeComponentFile(filePath: string, options?: AnalyzerOptions): Promise<AnalysisReport>;
23
+ /**
24
+ * Analyzes component content directly (for in-memory components)
25
+ */
26
+ export declare function analyzeComponentContent(filePath: string, content: string, options?: AnalyzerOptions): AnalysisReport;
27
+ /**
28
+ * Batch analyze multiple components
29
+ */
30
+ export declare function analyzeComponents(filePaths: string[], options?: AnalyzerOptions): Promise<Map<string, AnalysisReport>>;
31
+ /**
32
+ * Quick check if a component should be hydrated
33
+ */
34
+ export declare function shouldHydrate(filePath: string, options?: AnalyzerOptions): Promise<boolean>;
35
+ /**
36
+ * Get component framework type
37
+ */
38
+ export declare function getComponentFramework(filePath: string): Promise<ComponentAnalysis['framework']>;
39
+ /**
40
+ * Generate summary statistics for a batch of components
41
+ */
42
+ export declare function generateAnalysisSummary(reports: Map<string, AnalysisReport>): {
43
+ total: number;
44
+ byFramework: Record<string, number>;
45
+ byStrategy: Record<string, number>;
46
+ withWarnings: number;
47
+ };
48
+ export type { ComponentAnalysis, DetectionResult, ComponentMetadata } from './component-detection.ts';
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Component Detection System
3
+ *
4
+ * This module provides utilities to analyze components and determine their
5
+ * hydration requirements based on script content and framework patterns.
6
+ */
7
+ export interface ComponentAnalysis {
8
+ hasScript: boolean;
9
+ hasHydrateFunction: boolean;
10
+ framework: 'vue' | 'svelte' | 'solid' | 'preact' | 'react' | 'lit' | 'qwik' | 'unknown';
11
+ recommendedStrategy: 'hydrate' | 'ssr-only';
12
+ }
13
+ export interface DetectionResult {
14
+ shouldHydrate: boolean;
15
+ reason: string;
16
+ warnings?: string[];
17
+ }
18
+ export interface ComponentMetadata {
19
+ path: string;
20
+ framework: 'vue' | 'svelte' | 'solid' | 'preact' | 'react' | 'lit' | 'qwik';
21
+ hasScript: boolean;
22
+ hasHydrateFunction: boolean;
23
+ renderStrategy: 'hydrate' | 'ssr-only';
24
+ detectionConfidence: 'high' | 'medium' | 'low';
25
+ }
26
+ /**
27
+ * Detects the framework type based on file extension and content
28
+ */
29
+ export declare function detectFramework(filePath: string, content: string): ComponentAnalysis['framework'];
30
+ /**
31
+ * Detects if a component has script sections
32
+ */
33
+ export declare function hasScriptSection(content: string, framework: ComponentAnalysis['framework']): boolean;
34
+ /**
35
+ * Detects if a component has hydration functions
36
+ */
37
+ export declare function hasHydrateFunction(content: string, framework: ComponentAnalysis['framework']): boolean;
38
+ /**
39
+ * Extracts script content from Vue components
40
+ */
41
+ export declare function extractVueScript(content: string): string;
42
+ /**
43
+ * Extracts script content from Svelte components
44
+ */
45
+ export declare function extractSvelteScript(content: string): string;
46
+ /**
47
+ * Extracts script content from Solid components (JSX)
48
+ */
49
+ export declare function extractSolidScript(content: string): string;
50
+ /**
51
+ * Extracts script content from Preact components (JSX)
52
+ */
53
+ export declare function extractPreactScript(content: string): string;
54
+ /**
55
+ * Extracts script content from React components (JSX)
56
+ */
57
+ export declare function extractReactScript(content: string): string;
58
+ /**
59
+ * Analyzes a component and returns detailed analysis
60
+ */
61
+ export declare function analyzeComponent(filePath: string, content: string): ComponentAnalysis;
62
+ /**
63
+ * Determines if a component should be hydrated based on analysis
64
+ */
65
+ export declare function shouldHydrateComponent(analysis: ComponentAnalysis, options?: {
66
+ forceSSROnly?: boolean;
67
+ detectScripts?: boolean;
68
+ }): DetectionResult;
69
+ /**
70
+ * Creates component metadata with confidence scoring
71
+ */
72
+ export declare function createComponentMetadata(filePath: string, content: string, analysis: ComponentAnalysis): ComponentMetadata;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Enhanced Framework Detection System
3
+ *
4
+ * This module provides advanced framework detection with multi-evidence analysis,
5
+ * confidence scoring, and JSX import source parsing to accurately identify
6
+ * component frameworks and prevent cross-framework conflicts.
7
+ */
8
+ export interface FrameworkDetectionResult {
9
+ framework: 'preact' | 'solid' | 'vue' | 'svelte' | 'react' | 'lit' | 'qwik' | 'unknown';
10
+ confidence: 'high' | 'medium' | 'low';
11
+ evidence: string[];
12
+ warnings: string[];
13
+ }
14
+ export interface DetectionCriteria {
15
+ fileExtension: string;
16
+ jsxImportSource?: string;
17
+ imports: string[];
18
+ content: string;
19
+ }
20
+ export interface FrameworkConfig {
21
+ name: string;
22
+ fileExtensions: string[];
23
+ jsxImportSources: string[];
24
+ ssrModules: string[];
25
+ hydrationModules: string[];
26
+ detectionPatterns: {
27
+ imports: RegExp[];
28
+ content: RegExp[];
29
+ jsxPragmas: string[];
30
+ };
31
+ }
32
+ /**
33
+ * Enhanced Framework Detector with multi-evidence analysis
34
+ */
35
+ export declare class EnhancedFrameworkDetector {
36
+ private readonly frameworkRegistry;
37
+ constructor(frameworkConfigs?: Record<string, FrameworkConfig>);
38
+ /**
39
+ * Detects framework with multi-evidence analysis
40
+ */
41
+ detectFramework(filePath: string, content: string): FrameworkDetectionResult;
42
+ /**
43
+ * Extracts detection criteria from file path and content
44
+ */
45
+ private extractDetectionCriteria;
46
+ /**
47
+ * Calculates framework score based on multiple evidence points
48
+ */
49
+ private calculateFrameworkScore;
50
+ /**
51
+ * Parses JSX import source from content
52
+ */
53
+ private parseJSXImportSource;
54
+ /**
55
+ * Extracts import statements from content
56
+ */
57
+ private extractImportStatements;
58
+ /**
59
+ * Gets file extension from path, handling framework-specific naming conventions
60
+ */
61
+ private getFileExtension;
62
+ /**
63
+ * Gets default framework configurations
64
+ */
65
+ private getDefaultFrameworkConfigs;
66
+ /**
67
+ * Adds or updates a framework configuration
68
+ */
69
+ addFrameworkConfig(name: string, config: FrameworkConfig): void;
70
+ /**
71
+ * Gets all registered framework configurations
72
+ */
73
+ getFrameworkConfigs(): Map<string, FrameworkConfig>;
74
+ /**
75
+ * Validates framework configuration completeness
76
+ */
77
+ validateFrameworkConfig(config: FrameworkConfig): string[];
78
+ }
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Framework Registry and Configuration System
3
+ *
4
+ * This module provides a centralized registry for framework configurations,
5
+ * validation utilities, and management of framework-specific detection patterns.
6
+ */
7
+ import type { FrameworkConfig } from './enhanced-framework-detector.ts';
8
+ export interface FrameworkRegistryConfig {
9
+ enableValidation: boolean;
10
+ allowCustomFrameworks: boolean;
11
+ defaultFramework: string;
12
+ }
13
+ export interface FrameworkValidationResult {
14
+ isValid: boolean;
15
+ errors: string[];
16
+ warnings: string[];
17
+ }
18
+ /**
19
+ * Centralized framework registry with validation and management
20
+ */
21
+ export declare class FrameworkRegistry {
22
+ private readonly frameworks;
23
+ private readonly config;
24
+ constructor(config?: Partial<FrameworkRegistryConfig>);
25
+ /**
26
+ * Registers a new framework configuration
27
+ */
28
+ registerFramework(name: string, config: FrameworkConfig): FrameworkValidationResult;
29
+ /**
30
+ * Gets a framework configuration by name
31
+ */
32
+ getFramework(name: string): FrameworkConfig | undefined;
33
+ /**
34
+ * Gets all registered frameworks
35
+ */
36
+ getAllFrameworks(): Map<string, FrameworkConfig>;
37
+ /**
38
+ * Gets framework names that support a specific file extension
39
+ */
40
+ getFrameworksByExtension(extension: string): string[];
41
+ /**
42
+ * Gets frameworks that use a specific JSX import source
43
+ */
44
+ getFrameworksByJSXImportSource(importSource: string): string[];
45
+ /**
46
+ * Removes a framework from the registry
47
+ */
48
+ unregisterFramework(name: string): boolean;
49
+ /**
50
+ * Updates an existing framework configuration
51
+ */
52
+ updateFramework(name: string, updates: Partial<FrameworkConfig>): FrameworkValidationResult;
53
+ /**
54
+ * Validates a framework configuration
55
+ */
56
+ validateFrameworkConfig(config: FrameworkConfig): FrameworkValidationResult;
57
+ /** Validate required top-level fields on a framework config */
58
+ private validateRequiredFields;
59
+ /** Validate the detectionPatterns sub-object */
60
+ private validateDetectionPatterns;
61
+ /**
62
+ * Checks for potential conflicts with other registered frameworks
63
+ */
64
+ private validateCrossFrameworkConflicts;
65
+ /**
66
+ * Checks if a framework is a default framework
67
+ */
68
+ private isDefaultFramework;
69
+ /**
70
+ * Initializes the registry with default framework configurations
71
+ */
72
+ private initializeDefaultFrameworks;
73
+ /**
74
+ * Gets default framework configurations
75
+ */
76
+ private getDefaultFrameworkConfigs;
77
+ /**
78
+ * Exports the current registry configuration
79
+ */
80
+ exportConfig(): Record<string, FrameworkConfig>;
81
+ /**
82
+ * Imports a registry configuration
83
+ */
84
+ importConfig(config: Record<string, FrameworkConfig>): FrameworkValidationResult[];
85
+ /**
86
+ * Resets the registry to default frameworks only
87
+ */
88
+ reset(): void;
89
+ /**
90
+ * Gets registry statistics
91
+ */
92
+ getStats(): {
93
+ totalFrameworks: number;
94
+ defaultFrameworks: number;
95
+ customFrameworks: number;
96
+ supportedExtensions: string[];
97
+ };
98
+ }
99
+ /**
100
+ * Default framework registry instance
101
+ */
102
+ export declare const defaultFrameworkRegistry: FrameworkRegistry;
103
+ /**
104
+ * Utility function to create a framework configuration
105
+ */
106
+ export declare function createFrameworkConfig(name: string, options: {
107
+ fileExtensions: string[];
108
+ jsxImportSources?: string[];
109
+ ssrModules: string[];
110
+ hydrationModules: string[];
111
+ importPatterns: (string | RegExp)[];
112
+ contentPatterns?: (string | RegExp)[];
113
+ jsxPragmas?: string[];
114
+ }): FrameworkConfig;
@@ -0,0 +1,14 @@
1
+ import type { RoutePageModule } from '../../schemas/routing.ts';
2
+ /**
3
+ * Server-side MDX processor for handling MDX files in the routing system
4
+ */
5
+ export declare class MDXProcessor {
6
+ /**
7
+ * Process an MDX file and return a valid page module
8
+ */
9
+ processMDXFile(filePath: string): Promise<RoutePageModule>;
10
+ /**
11
+ * Check if a file is an MDX file
12
+ */
13
+ static isMDXFile(filePath: string): boolean;
14
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Integration system exports
3
+ * Central export point for all integration-related functionality
4
+ */
5
+ export { IntegrationRegistry, registry } from "./registry.ts";
6
+ export { loadIntegration, detectAndLoadIntegration, detectFrameworkFromPath, detectFrameworkFromContent, preloadIntegrations, getLoadedIntegrations, clearIntegrationCache, isIntegrationLoaded, } from "./loader.ts";
@@ -0,0 +1,35 @@
1
+ import type { Integration } from "@useavalon/core";
2
+ /**
3
+ * Load an integration by name, using cache if available
4
+ */
5
+ export declare function loadIntegration(framework: string): Promise<Integration>;
6
+ /**
7
+ * Detect framework from file path and load the appropriate integration
8
+ */
9
+ export declare function detectAndLoadIntegration(src: string): Promise<Integration>;
10
+ /**
11
+ * Detect framework from file path based on extension and naming conventions
12
+ */
13
+ export declare function detectFrameworkFromPath(src: string): string;
14
+ /**
15
+ * Detect framework from file content by analyzing imports and patterns
16
+ */
17
+ export declare function detectFrameworkFromContent(src: string, content?: string): string;
18
+ /**
19
+ * Preload integrations for the given frameworks
20
+ * Useful for warming up the cache during build or startup
21
+ */
22
+ export declare function preloadIntegrations(frameworks: string[]): Promise<void>;
23
+ /**
24
+ * Get all currently loaded integrations
25
+ */
26
+ export declare function getLoadedIntegrations(): Integration[];
27
+ /**
28
+ * Clear the integration cache
29
+ * Useful for testing or hot module replacement
30
+ */
31
+ export declare function clearIntegrationCache(): void;
32
+ /**
33
+ * Check if an integration is loaded in cache
34
+ */
35
+ export declare function isIntegrationLoaded(framework: string): boolean;
@@ -0,0 +1,51 @@
1
+ import type { Integration } from "@useavalon/core";
2
+ /**
3
+ * IntegrationRegistry manages loaded framework integrations.
4
+ * It provides registration, retrieval, and dynamic loading of integrations.
5
+ */
6
+ export declare class IntegrationRegistry {
7
+ private readonly integrations;
8
+ private readonly loadingPromises;
9
+ /**
10
+ * Register an integration instance
11
+ */
12
+ register(integration: Integration): void;
13
+ /**
14
+ * Get a registered integration by name
15
+ */
16
+ get(name: string): Integration | undefined;
17
+ /**
18
+ * Check if an integration is registered
19
+ */
20
+ has(name: string): boolean;
21
+ /**
22
+ * Dynamically load an integration by name
23
+ * Returns cached integration if already loaded
24
+ */
25
+ load(name: string): Promise<Integration>;
26
+ private loadIntegration;
27
+ /**
28
+ * Get all registered integrations
29
+ */
30
+ getAll(): Integration[];
31
+ /**
32
+ * Get all registered integration names
33
+ */
34
+ getAllNames(): string[];
35
+ /**
36
+ * Unregister an integration
37
+ */
38
+ unregister(name: string): boolean;
39
+ /**
40
+ * Clear all registered integrations
41
+ */
42
+ clear(): void;
43
+ /**
44
+ * Get the count of registered integrations
45
+ */
46
+ get size(): number;
47
+ }
48
+ declare global {
49
+ var __avalonIntegrationRegistry: IntegrationRegistry | undefined;
50
+ }
51
+ export declare const registry: IntegrationRegistry;
@@ -0,0 +1,74 @@
1
+ import type { IslandState } from '../../schemas/layout.ts';
2
+ import type { IIslandPersistence } from '../../types/layout.ts';
3
+ /**
4
+ * IslandPersistence class for state management across navigation
5
+ *
6
+ * Handles saving, loading, and clearing island state using browser storage
7
+ * with support for both sessionStorage and localStorage persistence strategies.
8
+ */
9
+ export declare class IslandPersistence implements IIslandPersistence {
10
+ private storageType;
11
+ private keyPrefix;
12
+ private storage;
13
+ constructor(options?: {
14
+ storageType?: 'session' | 'local';
15
+ keyPrefix?: string;
16
+ });
17
+ /**
18
+ * Save island state to browser storage
19
+ */
20
+ saveState(id: string, state: IslandState): void;
21
+ /**
22
+ * Load island state from browser storage
23
+ */
24
+ loadState(id: string): IslandState | null;
25
+ /**
26
+ * Clear island state from browser storage
27
+ */
28
+ clearState(id: string): void;
29
+ /**
30
+ * Check if state exists for an island
31
+ */
32
+ hasState(id: string): boolean;
33
+ /**
34
+ * Get all stored island IDs
35
+ */
36
+ getStoredIds(): string[];
37
+ /**
38
+ * Clear all stored states
39
+ */
40
+ clearAllStates(): void;
41
+ /**
42
+ * Get the storage key for an island ID
43
+ */
44
+ private getStorageKey;
45
+ /**
46
+ * Get current storage configuration
47
+ */
48
+ getConfig(): {
49
+ storageType: string;
50
+ keyPrefix: string;
51
+ available: boolean;
52
+ };
53
+ /**
54
+ * Get storage usage statistics
55
+ */
56
+ getStorageStats(): {
57
+ totalKeys: number;
58
+ islandKeys: number;
59
+ estimatedSize: number;
60
+ };
61
+ /**
62
+ * JSON.stringify replacer function to handle special types
63
+ */
64
+ private replacer;
65
+ /**
66
+ * JSON.parse reviver function to restore special types
67
+ */
68
+ private reviver;
69
+ }
70
+ /**
71
+ * Default island persistence instance
72
+ * Uses sessionStorage by default for better privacy and performance
73
+ */
74
+ export declare const defaultIslandPersistence: IslandPersistence;
@@ -0,0 +1,53 @@
1
+ import type { IslandState } from '../../schemas/layout.ts';
2
+ /**
3
+ * Island State Serializer
4
+ *
5
+ * Handles serialization and deserialization of island state for browser storage.
6
+ * Supports complex data types including Dates, RegExp, and circular references.
7
+ */
8
+ export declare class IslandStateSerializer {
9
+ /**
10
+ * Serialize island state to JSON string
11
+ */
12
+ static serialize(state: IslandState): string;
13
+ /**
14
+ * Deserialize JSON string to island state
15
+ */
16
+ static deserialize(serializedState: string): IslandState;
17
+ /**
18
+ * Transform state for serialization, handling special types
19
+ */
20
+ private static transformForSerialization;
21
+ /**
22
+ * JSON.parse reviver function to restore special types
23
+ */
24
+ private static reviver;
25
+ /**
26
+ * Validate that state can be safely serialized
27
+ */
28
+ static validate(state: IslandState): {
29
+ valid: boolean;
30
+ errors: string[];
31
+ };
32
+ /**
33
+ * Get size information for serialized state
34
+ */
35
+ static getSize(state: IslandState): {
36
+ bytes: number;
37
+ kilobytes: number;
38
+ megabytes: number;
39
+ readable: string;
40
+ };
41
+ /**
42
+ * Deep clone state object (useful for preventing mutations)
43
+ */
44
+ static clone(state: IslandState): IslandState;
45
+ /**
46
+ * Compare two states for equality
47
+ */
48
+ static equals(state1: IslandState, state2: IslandState): boolean;
49
+ /**
50
+ * Sanitize state by removing non-serializable values
51
+ */
52
+ static sanitize(state: IslandState): IslandState;
53
+ }
@@ -0,0 +1,36 @@
1
+ import type { ComponentChildren } from 'preact';
2
+ import type { IslandState } from '../../schemas/layout.ts';
3
+ import { defaultIslandPersistence } from './island-persistence.ts';
4
+ /**
5
+ * Explicit interface for persistent island context
6
+ * (Zod z.any() inference for function types is unreliable)
7
+ */
8
+ export interface PersistentIslandContextType {
9
+ saveState: (state: IslandState) => void;
10
+ loadState: () => IslandState | null;
11
+ clearState: () => void;
12
+ }
13
+ /**
14
+ * Context for persistent island state operations
15
+ *
16
+ * Provides save, load, and clear operations for island state management
17
+ * across navigation and browser sessions.
18
+ */
19
+ export declare const PersistentIslandContextProvider: import("preact").Context<PersistentIslandContextType>;
20
+ /**
21
+ * Create a persistent island context for a specific island ID
22
+ */
23
+ export declare function createPersistentIslandContext(persistentId: string, persistence?: import("./island-persistence.ts").IslandPersistence): PersistentIslandContextType;
24
+ /**
25
+ * Hook to use persistent island context
26
+ * Must be used within a PersistentIsland component
27
+ */
28
+ export declare function usePersistentIslandContext(): PersistentIslandContextType;
29
+ /**
30
+ * Provider component for persistent island context
31
+ */
32
+ export declare function PersistentIslandProvider({ persistentId, children, persistence, }: Readonly<{
33
+ persistentId: string;
34
+ children: ComponentChildren;
35
+ persistence?: typeof defaultIslandPersistence;
36
+ }>): import("preact").JSX.Element;