@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.
- package/dist/mod.d.ts +50 -0
- package/dist/src/build/integration-bundler-plugin.d.ts +25 -0
- package/dist/src/build/integration-config.d.ts +44 -0
- package/dist/src/build/integration-detection-plugin.d.ts +20 -0
- package/dist/src/build/integration-resolver-plugin.d.ts +10 -0
- package/dist/src/build/island-manifest.d.ts +57 -0
- package/dist/src/build/island-types-generator.d.ts +49 -0
- package/dist/src/build/mdx-island-transform.d.ts +23 -0
- package/dist/src/build/mdx-plugin.d.ts +36 -0
- package/dist/src/build/page-island-transform.d.ts +41 -0
- package/dist/src/build/prop-extractors/index.d.ts +8 -0
- package/dist/src/build/prop-extractors/lit.d.ts +11 -0
- package/dist/src/build/prop-extractors/qwik.d.ts +9 -0
- package/dist/src/build/prop-extractors/solid.d.ts +12 -0
- package/dist/src/build/prop-extractors/svelte.d.ts +13 -0
- package/dist/src/build/prop-extractors/vue.d.ts +19 -0
- package/dist/src/build/sidecar-file-manager.d.ts +23 -0
- package/dist/src/build/sidecar-renderer.d.ts +22 -0
- package/dist/src/client/adapters/index.d.ts +15 -0
- package/dist/src/client/components.d.ts +21 -0
- package/dist/src/client/css-hmr-handler.d.ts +94 -0
- package/dist/src/client/framework-adapter.d.ts +225 -0
- package/dist/src/client/hmr-coordinator.d.ts +88 -0
- package/dist/src/components/Image.d.ts +61 -0
- package/dist/src/components/IslandErrorBoundary.d.ts +37 -0
- package/dist/src/components/IslandErrorBoundary.js +1 -1
- package/dist/src/components/LayoutDataErrorBoundary.d.ts +34 -0
- package/dist/src/components/LayoutDataErrorBoundary.js +1 -1
- package/dist/src/components/LayoutErrorBoundary.d.ts +25 -0
- package/dist/src/components/LayoutErrorBoundary.js +1 -1
- package/dist/src/components/PersistentIsland.d.ts +36 -0
- package/dist/src/components/StreamingErrorBoundary.d.ts +42 -0
- package/dist/src/components/StreamingErrorBoundary.js +1 -1
- package/dist/src/components/StreamingLayout.d.ts +83 -0
- package/dist/src/components/StreamingLayout.js +1 -1
- package/dist/src/core/components/component-analyzer.d.ts +48 -0
- package/dist/src/core/components/component-detection.d.ts +72 -0
- package/dist/src/core/components/enhanced-framework-detector.d.ts +78 -0
- package/dist/src/core/components/framework-registry.d.ts +114 -0
- package/dist/src/core/content/mdx-processor.d.ts +14 -0
- package/dist/src/core/integrations/index.d.ts +6 -0
- package/dist/src/core/integrations/loader.d.ts +35 -0
- package/dist/src/core/integrations/registry.d.ts +51 -0
- package/dist/src/core/islands/island-persistence.d.ts +74 -0
- package/dist/src/core/islands/island-state-serializer.d.ts +53 -0
- package/dist/src/core/islands/persistent-island-context.d.ts +36 -0
- package/dist/src/core/islands/use-persistent-state.d.ts +17 -0
- package/dist/src/core/layout/enhanced-layout-resolver.d.ts +73 -0
- package/dist/src/core/layout/layout-cache-manager.d.ts +66 -0
- package/dist/src/core/layout/layout-composer.d.ts +63 -0
- package/dist/src/core/layout/layout-data-loader.d.ts +146 -0
- package/dist/src/core/layout/layout-discovery.d.ts +51 -0
- package/dist/src/core/layout/layout-matcher.d.ts +77 -0
- package/dist/src/core/layout/layout-types.d.ts +94 -0
- package/dist/src/core/modules/framework-module-resolver.d.ts +85 -0
- package/dist/src/islands/component-analysis.d.ts +38 -0
- package/dist/src/islands/css-utils.d.ts +81 -0
- package/dist/src/islands/discovery/index.d.ts +16 -0
- package/dist/src/islands/discovery/registry.d.ts +141 -0
- package/dist/src/islands/discovery/resolver.d.ts +190 -0
- package/dist/src/islands/discovery/scanner.d.ts +55 -0
- package/dist/src/islands/discovery/types.d.ts +92 -0
- package/dist/src/islands/discovery/validator.d.ts +89 -0
- package/dist/src/islands/discovery/watcher.d.ts +95 -0
- package/dist/src/islands/framework-detection.d.ts +53 -0
- package/dist/src/islands/integration-loader.d.ts +139 -0
- package/dist/src/islands/island.d.ts +55 -0
- package/dist/src/islands/render-cache.d.ts +203 -0
- package/dist/src/islands/types.d.ts +63 -0
- package/dist/src/islands/universal-css-collector.d.ts +41 -0
- package/dist/src/islands/universal-head-collector.d.ts +42 -0
- package/dist/src/layout-system.d.ts +92 -592
- package/dist/src/middleware/discovery.d.ts +70 -0
- package/dist/src/middleware/executor.d.ts +52 -0
- package/dist/src/middleware/index.d.ts +43 -0
- package/dist/src/middleware/types.d.ts +89 -0
- package/dist/src/nitro/build-config.d.ts +163 -0
- package/dist/src/nitro/config.d.ts +268 -0
- package/dist/src/nitro/error-handler.d.ts +151 -0
- package/dist/src/nitro/index.d.ts +15 -0
- package/dist/src/nitro/island-manifest.d.ts +191 -0
- package/dist/src/nitro/middleware-adapter.d.ts +151 -0
- package/dist/src/nitro/renderer.d.ts +342 -0
- package/dist/src/nitro/route-discovery.d.ts +142 -0
- package/dist/src/nitro/types.d.ts +278 -0
- package/dist/src/render/collect-css.d.ts +28 -0
- package/dist/src/render/error-pages.d.ts +14 -0
- package/dist/src/render/isolated-ssr-renderer.d.ts +127 -0
- package/dist/src/render/ssr.d.ts +56 -0
- package/dist/src/schemas/api.d.ts +27 -0
- package/dist/src/schemas/core.d.ts +75 -0
- package/dist/src/schemas/index.d.ts +79 -0
- package/dist/src/schemas/index.js +1 -1
- package/dist/src/schemas/layout.d.ts +282 -0
- package/dist/src/schemas/routing/index.d.ts +181 -0
- package/dist/src/schemas/routing.d.ts +388 -0
- package/dist/src/types/as-island.d.ts +17 -0
- package/dist/src/types/layout.d.ts +177 -0
- package/dist/src/types/routing.d.ts +297 -0
- package/dist/src/types/types.d.ts +6 -0
- package/dist/src/utils/dev-logger.d.ts +84 -0
- package/dist/src/utils/fs.d.ts +41 -0
- package/dist/src/vite-plugin/auto-discover.d.ts +72 -0
- package/dist/src/vite-plugin/config.d.ts +82 -0
- package/dist/src/vite-plugin/errors.d.ts +62 -0
- package/dist/src/vite-plugin/image-optimization.d.ts +36 -0
- package/dist/src/vite-plugin/integration-activator.d.ts +48 -0
- package/dist/src/vite-plugin/island-sidecar-plugin.d.ts +17 -0
- package/dist/src/vite-plugin/module-discovery.d.ts +66 -0
- package/dist/src/vite-plugin/nitro-integration.d.ts +56 -0
- package/dist/src/vite-plugin/nitro-integration.js +1 -1
- package/dist/src/vite-plugin/plugin.d.ts +51 -0
- package/dist/src/vite-plugin/types.d.ts +281 -0
- package/dist/src/vite-plugin/validation.d.ts +93 -0
- package/package.json +33 -9
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Island Validator
|
|
3
|
+
*
|
|
4
|
+
* Validates island components and directory structure.
|
|
5
|
+
* Provides validation for exports, naming conventions, and circular dependencies.
|
|
6
|
+
*/
|
|
7
|
+
import type { IslandDirectory, DiscoveredIsland } from "./types.ts";
|
|
8
|
+
/**
|
|
9
|
+
* Result of validating an island or directory
|
|
10
|
+
*/
|
|
11
|
+
export interface ValidationResult {
|
|
12
|
+
/** Whether validation passed (no errors) */
|
|
13
|
+
valid: boolean;
|
|
14
|
+
/** Validation errors (failures) */
|
|
15
|
+
errors: ValidationError[];
|
|
16
|
+
/** Validation warnings (non-fatal issues) */
|
|
17
|
+
warnings: ValidationWarning[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A validation error (causes validation to fail)
|
|
21
|
+
*/
|
|
22
|
+
export interface ValidationError {
|
|
23
|
+
/** Type of error */
|
|
24
|
+
type: "invalid-export" | "circular-dependency" | "naming-convention";
|
|
25
|
+
/** Human-readable error message */
|
|
26
|
+
message: string;
|
|
27
|
+
/** Absolute file path where error occurred */
|
|
28
|
+
filePath: string;
|
|
29
|
+
/** Line number (1-indexed) if applicable */
|
|
30
|
+
line?: number;
|
|
31
|
+
/** Column number (1-indexed) if applicable */
|
|
32
|
+
column?: number;
|
|
33
|
+
/** Suggested fix for the error */
|
|
34
|
+
suggestion?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A validation warning (non-fatal issue)
|
|
38
|
+
*/
|
|
39
|
+
export interface ValidationWarning {
|
|
40
|
+
/** Type of warning */
|
|
41
|
+
type: "empty-directory" | "naming-collision" | "deprecated-pattern";
|
|
42
|
+
/** Human-readable warning message */
|
|
43
|
+
message: string;
|
|
44
|
+
/** File path if applicable */
|
|
45
|
+
filePath?: string;
|
|
46
|
+
/** Suggested fix for the warning */
|
|
47
|
+
suggestion?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Represents a circular dependency chain
|
|
51
|
+
*/
|
|
52
|
+
export interface CircularDependency {
|
|
53
|
+
/** The cycle as an array of file paths */
|
|
54
|
+
cycle: string[];
|
|
55
|
+
/** Human-readable description of the cycle */
|
|
56
|
+
description: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Island Validator class
|
|
60
|
+
*/
|
|
61
|
+
export declare class IslandValidator {
|
|
62
|
+
private _projectRoot;
|
|
63
|
+
constructor(projectRoot: string);
|
|
64
|
+
get projectRoot(): string;
|
|
65
|
+
private extractComponentName;
|
|
66
|
+
private toPascalCase;
|
|
67
|
+
private hasValidJsExport;
|
|
68
|
+
private isValidVueComponent;
|
|
69
|
+
private isValidSvelteComponent;
|
|
70
|
+
private createExportError;
|
|
71
|
+
private validateExports;
|
|
72
|
+
private extractJsImports;
|
|
73
|
+
private extractImports;
|
|
74
|
+
private resolveImportToIsland;
|
|
75
|
+
private buildImportGraph;
|
|
76
|
+
private cycleExists;
|
|
77
|
+
private findCycles;
|
|
78
|
+
private formatCycleDescription;
|
|
79
|
+
validateComponent(filePath: string): Promise<ValidationResult>;
|
|
80
|
+
validateDirectory(directory: IslandDirectory): Promise<ValidationResult>;
|
|
81
|
+
validateNamingConvention(name: string, filePath: string): ValidationResult;
|
|
82
|
+
detectCircularDependencies(islands: DiscoveredIsland[]): Promise<CircularDependency[]>;
|
|
83
|
+
}
|
|
84
|
+
export declare function formatValidationError(error: ValidationError, projectRoot: string): string;
|
|
85
|
+
export declare function formatValidationWarning(warning: ValidationWarning, projectRoot: string): string;
|
|
86
|
+
export declare function formatCircularDependency(circular: CircularDependency, projectRoot: string): string;
|
|
87
|
+
export declare function formatValidationResult(result: ValidationResult, projectRoot: string): string;
|
|
88
|
+
export declare function createIslandValidator(projectRoot: string): IslandValidator;
|
|
89
|
+
export declare function validateAllIslands(islands: DiscoveredIsland[], projectRoot: string): Promise<ValidationResult>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Island File Watcher
|
|
3
|
+
*
|
|
4
|
+
* Watches all discovered island directories for file changes and emits
|
|
5
|
+
* change events with affected island information. Supports HMR for
|
|
6
|
+
* nested island directories.
|
|
7
|
+
*/
|
|
8
|
+
import type { IslandChangeEvent, IslandDiscoveryConfig } from "./types.ts";
|
|
9
|
+
import { IslandRegistry } from "./registry.ts";
|
|
10
|
+
/**
|
|
11
|
+
* Callback type for island change events
|
|
12
|
+
*/
|
|
13
|
+
export type IslandChangeCallback = (event: IslandChangeEvent) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Options for the island watcher
|
|
16
|
+
*/
|
|
17
|
+
export interface IslandWatcherOptions {
|
|
18
|
+
/** Debounce delay in milliseconds (default: 100) */
|
|
19
|
+
debounceMs?: number;
|
|
20
|
+
/** Whether to emit events for initial discovery (default: false) */
|
|
21
|
+
emitInitial?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Island File Watcher
|
|
25
|
+
*
|
|
26
|
+
* Watches all discovered island directories for file changes.
|
|
27
|
+
* Emits change events with affected island information for HMR support.
|
|
28
|
+
*/
|
|
29
|
+
export declare class IslandWatcher {
|
|
30
|
+
private _projectRoot;
|
|
31
|
+
private _config;
|
|
32
|
+
private _options;
|
|
33
|
+
private _registry;
|
|
34
|
+
private _watchers;
|
|
35
|
+
private _callbacks;
|
|
36
|
+
private _isWatching;
|
|
37
|
+
private _debounceTimers;
|
|
38
|
+
constructor(projectRoot: string, registry: IslandRegistry, config?: IslandDiscoveryConfig, options?: IslandWatcherOptions);
|
|
39
|
+
/**
|
|
40
|
+
* Check if the watcher is currently active
|
|
41
|
+
*/
|
|
42
|
+
get isWatching(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Get the number of registered callbacks
|
|
45
|
+
*/
|
|
46
|
+
get callbackCount(): number;
|
|
47
|
+
/**
|
|
48
|
+
* Start watching all discovered island directories.
|
|
49
|
+
*
|
|
50
|
+
* @param callback - Callback to invoke on file changes
|
|
51
|
+
* @returns Cleanup function to stop watching
|
|
52
|
+
*/
|
|
53
|
+
watch(callback: IslandChangeCallback): Promise<() => void>;
|
|
54
|
+
/**
|
|
55
|
+
* Stop all file watchers and clear callbacks.
|
|
56
|
+
*/
|
|
57
|
+
stop(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Start watching all island directories.
|
|
60
|
+
*/
|
|
61
|
+
private _startWatching;
|
|
62
|
+
/**
|
|
63
|
+
* Watch a single island directory for changes.
|
|
64
|
+
*/
|
|
65
|
+
private _watchDirectory;
|
|
66
|
+
/**
|
|
67
|
+
* Debounce file change events to avoid duplicate processing.
|
|
68
|
+
*/
|
|
69
|
+
private _debounceEvent;
|
|
70
|
+
/**
|
|
71
|
+
* Handle a file change event.
|
|
72
|
+
*/
|
|
73
|
+
private _handleFileChange;
|
|
74
|
+
/**
|
|
75
|
+
* Get the qualified name for an island from its file path.
|
|
76
|
+
*/
|
|
77
|
+
private _getQualifiedNameFromPath;
|
|
78
|
+
/**
|
|
79
|
+
* Extract component name from file name.
|
|
80
|
+
*/
|
|
81
|
+
private _extractComponentName;
|
|
82
|
+
/**
|
|
83
|
+
* Emit an event to all registered callbacks.
|
|
84
|
+
*/
|
|
85
|
+
private _emitEvent;
|
|
86
|
+
/**
|
|
87
|
+
* Refresh the watcher to pick up new directories.
|
|
88
|
+
* Call this after the registry is rebuilt.
|
|
89
|
+
*/
|
|
90
|
+
refresh(): Promise<void>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Create an island watcher for the given registry.
|
|
94
|
+
*/
|
|
95
|
+
export declare function createIslandWatcher(projectRoot: string, registry: IslandRegistry, config?: IslandDiscoveryConfig, options?: IslandWatcherOptions): IslandWatcher;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Framework } from './types.ts';
|
|
2
|
+
import { IslandRegistry } from './discovery/index.ts';
|
|
3
|
+
/** Known synchronous framework types (excludes 'unknown') */
|
|
4
|
+
type SyncFramework = 'solid' | 'vue' | 'svelte' | 'preact' | 'react' | 'lit' | 'qwik';
|
|
5
|
+
/**
|
|
6
|
+
* Resolve Island component path for Vite SSR loading
|
|
7
|
+
* Converts /islands/* paths to /src/islands/* for proper resolution
|
|
8
|
+
* Also handles framework-specific naming conventions and nested islands.
|
|
9
|
+
* Uses async file operations and caching for better performance.
|
|
10
|
+
*
|
|
11
|
+
* @param src - The source path or component name
|
|
12
|
+
* @returns The resolved path
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveIslandPath(src: string): Promise<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Check if a path is a nested island path (not in default /src/islands/).
|
|
17
|
+
*
|
|
18
|
+
* @param path - The path to check
|
|
19
|
+
* @returns True if the path is a nested island path
|
|
20
|
+
*/
|
|
21
|
+
export declare function isNestedIslandPath(path: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Get the island registry, initializing it if necessary.
|
|
24
|
+
*
|
|
25
|
+
* @param projectRoot - The project root directory
|
|
26
|
+
* @returns The island registry
|
|
27
|
+
*/
|
|
28
|
+
export declare function getOrCreateIslandRegistry(projectRoot?: string): Promise<IslandRegistry>;
|
|
29
|
+
/**
|
|
30
|
+
* Set the global island registry.
|
|
31
|
+
* Useful for testing or when the registry is created elsewhere.
|
|
32
|
+
*
|
|
33
|
+
* @param registry - The registry to set
|
|
34
|
+
*/
|
|
35
|
+
export declare function setIslandRegistry(registry: IslandRegistry): void;
|
|
36
|
+
/**
|
|
37
|
+
* Clear the global island registry.
|
|
38
|
+
* Useful for testing or hot module replacement.
|
|
39
|
+
*/
|
|
40
|
+
export declare function clearIslandRegistry(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Quick framework detection based on file extension and naming conventions
|
|
43
|
+
* Used for setting framework attributes without async file reading
|
|
44
|
+
*
|
|
45
|
+
* Updated to query integration configs for detection patterns
|
|
46
|
+
*/
|
|
47
|
+
export declare function detectFrameworkFromSrc(src: string): SyncFramework;
|
|
48
|
+
/**
|
|
49
|
+
* Detect the framework used by a component file
|
|
50
|
+
* Updated to query integration configs for detection patterns
|
|
51
|
+
*/
|
|
52
|
+
export declare function detectFramework(src: string): Promise<Framework>;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { Integration } from "@useavalon/core";
|
|
2
|
+
/**
|
|
3
|
+
* Load an integration by framework name
|
|
4
|
+
* Uses cache to avoid repeated dynamic imports
|
|
5
|
+
*
|
|
6
|
+
* This function supports on-demand loading: if an integration hasn't been
|
|
7
|
+
* preloaded, it will be loaded and cached on first use. This enables
|
|
8
|
+
* lazy loading at server startup while ensuring fast subsequent renders.
|
|
9
|
+
*/
|
|
10
|
+
export declare function loadIntegration(framework: string): Promise<Integration>;
|
|
11
|
+
/**
|
|
12
|
+
* Detect framework from file path and load the appropriate integration
|
|
13
|
+
*/
|
|
14
|
+
export declare function detectAndLoadIntegration(src: string): Promise<Integration>;
|
|
15
|
+
/**
|
|
16
|
+
* Detect framework from file path based on extension and naming conventions.
|
|
17
|
+
*
|
|
18
|
+
* Updated to support nested island paths like:
|
|
19
|
+
* - /src/islands/Counter.tsx
|
|
20
|
+
* - /src/modules/auth/islands/Counter.tsx
|
|
21
|
+
* - /modules/dashboard/islands/Chart.vue
|
|
22
|
+
*
|
|
23
|
+
* @param src - The source path to detect framework from
|
|
24
|
+
* @returns The detected framework name
|
|
25
|
+
*/
|
|
26
|
+
export declare function detectFrameworkFromPath(src: string): "react" | "preact" | "vue" | "svelte" | "solid" | "lit" | "qwik";
|
|
27
|
+
/**
|
|
28
|
+
* Check if a path is within any islands directory (including nested).
|
|
29
|
+
*
|
|
30
|
+
* Matches patterns like:
|
|
31
|
+
* - /islands/
|
|
32
|
+
* - /src/islands/
|
|
33
|
+
* - /src/modules/auth/islands/
|
|
34
|
+
* - /modules/dashboard/islands/
|
|
35
|
+
* - /src/features/user/islands/
|
|
36
|
+
*
|
|
37
|
+
* @param path - The path to check
|
|
38
|
+
* @returns True if the path is in an islands directory
|
|
39
|
+
*/
|
|
40
|
+
export declare function isInIslandsDirectory(path: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Check if a path is a nested island path (not in default /src/islands/).
|
|
43
|
+
*
|
|
44
|
+
* @param path - The path to check
|
|
45
|
+
* @returns True if the path is a nested island path
|
|
46
|
+
*/
|
|
47
|
+
export declare function isNestedIslandPath(path: string): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Extract the namespace from a nested island path.
|
|
50
|
+
*
|
|
51
|
+
* Examples:
|
|
52
|
+
* - /src/modules/auth/islands/Counter.tsx -> "modules/auth"
|
|
53
|
+
* - /src/features/user/islands/Profile.tsx -> "features/user"
|
|
54
|
+
* - /src/islands/Button.tsx -> ""
|
|
55
|
+
*
|
|
56
|
+
* @param path - The path to extract namespace from
|
|
57
|
+
* @returns The namespace or empty string for default islands
|
|
58
|
+
*/
|
|
59
|
+
export declare function extractNamespaceFromPath(path: string): string;
|
|
60
|
+
/**
|
|
61
|
+
* Detect framework from file content by analyzing imports and patterns.
|
|
62
|
+
*
|
|
63
|
+
* Updated to support nested island paths.
|
|
64
|
+
*
|
|
65
|
+
* @param src - The source path
|
|
66
|
+
* @param content - The file content to analyze
|
|
67
|
+
* @returns The detected framework name
|
|
68
|
+
*/
|
|
69
|
+
export declare function detectFrameworkFromContent(src: string, content: string): "react" | "preact" | "vue" | "svelte" | "solid" | "lit" | "qwik";
|
|
70
|
+
/**
|
|
71
|
+
* Get integration for a specific framework, with error handling
|
|
72
|
+
*/
|
|
73
|
+
export declare function getIntegration(framework: string): Promise<Integration>;
|
|
74
|
+
/**
|
|
75
|
+
* Check if an integration is available for a framework
|
|
76
|
+
*/
|
|
77
|
+
export declare function hasIntegration(framework: string): Promise<boolean>;
|
|
78
|
+
/**
|
|
79
|
+
* Get all loaded integrations from cache
|
|
80
|
+
*/
|
|
81
|
+
export declare function getLoadedIntegrations(): Integration[];
|
|
82
|
+
/**
|
|
83
|
+
* Get all loaded framework names from cache
|
|
84
|
+
*/
|
|
85
|
+
export declare function getLoadedFrameworks(): string[];
|
|
86
|
+
/**
|
|
87
|
+
* Clear the integration cache
|
|
88
|
+
* Useful for testing or hot module replacement
|
|
89
|
+
*/
|
|
90
|
+
export declare function clearIntegrationCache(): void;
|
|
91
|
+
/**
|
|
92
|
+
* Check if an integration is loaded in cache
|
|
93
|
+
*/
|
|
94
|
+
export declare function isIntegrationLoaded(framework: string): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Default frameworks to preload at server startup
|
|
97
|
+
* These are the most commonly used frameworks in island architecture
|
|
98
|
+
*/
|
|
99
|
+
export declare const DEFAULT_PRELOAD_FRAMEWORKS: readonly ["preact", "react", "vue", "svelte", "solid", "lit"];
|
|
100
|
+
/**
|
|
101
|
+
* Options for preloading integrations
|
|
102
|
+
*/
|
|
103
|
+
export interface PreloadIntegrationsOptions {
|
|
104
|
+
/**
|
|
105
|
+
* When true, only preload integrations that are actually used on the page.
|
|
106
|
+
* This is determined by analyzing page components for framework usage.
|
|
107
|
+
* When false (default), preload all specified frameworks.
|
|
108
|
+
*/
|
|
109
|
+
lazy?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Array of framework names to preload.
|
|
112
|
+
* Defaults to DEFAULT_PRELOAD_FRAMEWORKS.
|
|
113
|
+
*/
|
|
114
|
+
frameworks?: readonly string[];
|
|
115
|
+
/**
|
|
116
|
+
* Array of detected frameworks from page analysis.
|
|
117
|
+
* Only used when lazy=true to filter which frameworks to preload.
|
|
118
|
+
*/
|
|
119
|
+
detectedFrameworks?: string[];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Preload integrations for multiple frameworks
|
|
123
|
+
* Useful for warming up the cache during build or startup
|
|
124
|
+
*
|
|
125
|
+
* Uses Promise.allSettled to load all integrations concurrently,
|
|
126
|
+
* ensuring that one failed integration doesn't block others.
|
|
127
|
+
*
|
|
128
|
+
* @param options - Preload options
|
|
129
|
+
* @returns Promise that resolves when all preloading attempts complete
|
|
130
|
+
*/
|
|
131
|
+
export declare function preloadIntegrations(options?: PreloadIntegrationsOptions): Promise<void>;
|
|
132
|
+
/**
|
|
133
|
+
* Detect frameworks used in a page by analyzing component imports.
|
|
134
|
+
* This is used for lazy integration loading to only preload what's needed.
|
|
135
|
+
*
|
|
136
|
+
* @param pageContent - The content of the page file to analyze
|
|
137
|
+
* @returns Array of detected framework names
|
|
138
|
+
*/
|
|
139
|
+
export declare function detectFrameworksFromPageContent(pageContent: string): string[];
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
declare global {
|
|
6
|
+
var __viteDevServer: ViteDevServer | undefined;
|
|
7
|
+
}
|
|
8
|
+
/** Supported hydration conditions for island components */
|
|
9
|
+
export type HydrationCondition = 'on:visible' | 'on:interaction' | 'on:idle' | 'on:client' | `media:${string}`;
|
|
10
|
+
/** Supported framework identifiers (without "unknown") */
|
|
11
|
+
export type FrameworkId = Exclude<Framework, 'unknown'>;
|
|
12
|
+
export interface IslandProps {
|
|
13
|
+
/** Path to the island component (e.g., "/islands/Counter.tsx") */
|
|
14
|
+
src: string;
|
|
15
|
+
/** Hydration condition */
|
|
16
|
+
condition?: HydrationCondition;
|
|
17
|
+
/** Props to pass to the island component */
|
|
18
|
+
props?: Record<string, unknown>;
|
|
19
|
+
/** Children to render inside the island (for SSR) */
|
|
20
|
+
children?: import('preact').ComponentChildren;
|
|
21
|
+
/** Whether to render server-side (default: true unless condition is 'on:client') */
|
|
22
|
+
ssr?: boolean;
|
|
23
|
+
/** Framework hint for client hydration */
|
|
24
|
+
framework?: FrameworkId;
|
|
25
|
+
/** Force SSR-only rendering without hydration */
|
|
26
|
+
ssrOnly?: boolean;
|
|
27
|
+
/** Component render options for intelligent detection */
|
|
28
|
+
renderOptions?: AnalyzerOptions;
|
|
29
|
+
/** Hydration data from integration renderer */
|
|
30
|
+
hydrationData?: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Universal Island component – renders `<avalon-island>` custom elements for better DOM structure.
|
|
34
|
+
*
|
|
35
|
+
* Uses custom elements instead of div wrappers for cleaner, more semantic markup.
|
|
36
|
+
* Supports intelligent rendering strategy detection to skip hydration for SSR-only components.
|
|
37
|
+
*/
|
|
38
|
+
export default function Island({ src, condition, props, children, ssr, framework, ssrOnly, renderOptions, hydrationData, }: IslandProps): JSX.Element;
|
|
39
|
+
/**
|
|
40
|
+
* Universal renderIsland function – auto-detects framework and handles SSR + hydration.
|
|
41
|
+
*
|
|
42
|
+
* This is the main function you should use – it automatically:
|
|
43
|
+
* - Detects the component framework (Vue, Solid.js, Preact/React)
|
|
44
|
+
* - Analyzes component for intelligent rendering strategy detection
|
|
45
|
+
* - Handles server-side rendering when possible
|
|
46
|
+
* - Falls back to client-only rendering when needed
|
|
47
|
+
* - Returns the appropriate Island component
|
|
48
|
+
*
|
|
49
|
+
* Performance tip: Providing an explicit `framework` prop skips component analysis
|
|
50
|
+
* and framework detection, significantly improving render performance.
|
|
51
|
+
*
|
|
52
|
+
* Error isolation: If SSR fails, returns an error placeholder instead of throwing,
|
|
53
|
+
* allowing the page to continue rendering other islands.
|
|
54
|
+
*/
|
|
55
|
+
export declare function renderIsland({ src, condition, props, children, ssr, framework, ssrOnly, renderOptions, }: IslandProps): Promise<JSX.Element>;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Island Render Cache Module
|
|
3
|
+
*
|
|
4
|
+
* Provides caching for expensive operations in the island rendering pipeline:
|
|
5
|
+
* - Component analysis results
|
|
6
|
+
* - Resolved paths
|
|
7
|
+
* - Framework detection results
|
|
8
|
+
*
|
|
9
|
+
* This module helps optimize island rendering by avoiding repeated file I/O
|
|
10
|
+
* and analysis operations for the same components.
|
|
11
|
+
*
|
|
12
|
+
* @module render-cache
|
|
13
|
+
*/
|
|
14
|
+
import type { AnalysisReport } from "../core/components/component-analyzer.ts";
|
|
15
|
+
import type { Framework } from "./types.ts";
|
|
16
|
+
/**
|
|
17
|
+
* Cache entry for component analysis results
|
|
18
|
+
*/
|
|
19
|
+
export interface AnalysisCacheEntry {
|
|
20
|
+
/** The analysis result */
|
|
21
|
+
result: AnalysisReport;
|
|
22
|
+
/** Timestamp when the entry was cached */
|
|
23
|
+
timestamp: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Cache entry for resolved paths
|
|
27
|
+
*/
|
|
28
|
+
export interface PathCacheEntry {
|
|
29
|
+
/** The resolved path */
|
|
30
|
+
resolved: string;
|
|
31
|
+
/** Timestamp when the entry was cached */
|
|
32
|
+
timestamp: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Cache entry for framework detection results
|
|
36
|
+
*/
|
|
37
|
+
export interface FrameworkCacheEntry {
|
|
38
|
+
/** The detected framework */
|
|
39
|
+
framework: Framework;
|
|
40
|
+
/** Timestamp when the entry was cached */
|
|
41
|
+
timestamp: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Configuration options for the island render cache
|
|
45
|
+
*/
|
|
46
|
+
export interface CacheConfig {
|
|
47
|
+
/** TTL for analysis cache entries in milliseconds (default: 60000ms = 1 minute) */
|
|
48
|
+
analysisTTL: number;
|
|
49
|
+
/** TTL for path cache entries in milliseconds (default: 60000ms = 1 minute) */
|
|
50
|
+
pathTTL: number;
|
|
51
|
+
/** TTL for framework cache entries in milliseconds (default: 60000ms = 1 minute) */
|
|
52
|
+
frameworkTTL: number;
|
|
53
|
+
/** Maximum number of entries per cache (default: 1000) */
|
|
54
|
+
maxEntries: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Cache statistics for monitoring and debugging
|
|
58
|
+
*/
|
|
59
|
+
export interface CacheStats {
|
|
60
|
+
/** Number of analysis cache entries */
|
|
61
|
+
analysisSize: number;
|
|
62
|
+
/** Number of path cache entries */
|
|
63
|
+
pathsSize: number;
|
|
64
|
+
/** Number of framework cache entries */
|
|
65
|
+
frameworksSize: number;
|
|
66
|
+
/** Number of cache hits for analysis */
|
|
67
|
+
analysisHits: number;
|
|
68
|
+
/** Number of cache misses for analysis */
|
|
69
|
+
analysisMisses: number;
|
|
70
|
+
/** Number of cache hits for paths */
|
|
71
|
+
pathHits: number;
|
|
72
|
+
/** Number of cache misses for paths */
|
|
73
|
+
pathMisses: number;
|
|
74
|
+
/** Number of cache hits for frameworks */
|
|
75
|
+
frameworkHits: number;
|
|
76
|
+
/** Number of cache misses for frameworks */
|
|
77
|
+
frameworkMisses: number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Island Render Cache interface
|
|
81
|
+
* Centralized cache for all expensive operations in island rendering
|
|
82
|
+
*/
|
|
83
|
+
export interface IslandRenderCache {
|
|
84
|
+
/** Analysis results by component path */
|
|
85
|
+
analysis: Map<string, AnalysisCacheEntry>;
|
|
86
|
+
/** Resolved paths by source path */
|
|
87
|
+
paths: Map<string, PathCacheEntry>;
|
|
88
|
+
/** Framework detection results by source path */
|
|
89
|
+
frameworks: Map<string, FrameworkCacheEntry>;
|
|
90
|
+
/** Cache configuration */
|
|
91
|
+
config: CacheConfig;
|
|
92
|
+
/** Cache statistics */
|
|
93
|
+
stats: CacheStats;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get cached analysis result for a component path
|
|
97
|
+
*
|
|
98
|
+
* @param src - The component source path
|
|
99
|
+
* @returns The cached analysis result or null if not found/expired
|
|
100
|
+
*/
|
|
101
|
+
export declare function getCachedAnalysis(src: string): AnalysisReport | null;
|
|
102
|
+
/**
|
|
103
|
+
* Store analysis result in cache
|
|
104
|
+
*
|
|
105
|
+
* @param src - The component source path
|
|
106
|
+
* @param result - The analysis result to cache
|
|
107
|
+
*/
|
|
108
|
+
export declare function setCachedAnalysis(src: string, result: AnalysisReport): void;
|
|
109
|
+
/**
|
|
110
|
+
* Get cached resolved path for a source path
|
|
111
|
+
*
|
|
112
|
+
* @param src - The source path
|
|
113
|
+
* @returns The cached resolved path or null if not found/expired
|
|
114
|
+
*/
|
|
115
|
+
export declare function getCachedPath(src: string): string | null;
|
|
116
|
+
/**
|
|
117
|
+
* Store resolved path in cache
|
|
118
|
+
*
|
|
119
|
+
* @param src - The source path
|
|
120
|
+
* @param resolved - The resolved path to cache
|
|
121
|
+
*/
|
|
122
|
+
export declare function setCachedPath(src: string, resolved: string): void;
|
|
123
|
+
/**
|
|
124
|
+
* Get cached framework detection result for a source path
|
|
125
|
+
*
|
|
126
|
+
* @param src - The source path
|
|
127
|
+
* @returns The cached framework or null if not found/expired
|
|
128
|
+
*/
|
|
129
|
+
export declare function getCachedFramework(src: string): Framework | null;
|
|
130
|
+
/**
|
|
131
|
+
* Store framework detection result in cache
|
|
132
|
+
*
|
|
133
|
+
* @param src - The source path
|
|
134
|
+
* @param framework - The detected framework to cache
|
|
135
|
+
*/
|
|
136
|
+
export declare function setCachedFramework(src: string, framework: Framework): void;
|
|
137
|
+
/**
|
|
138
|
+
* Clear all caches
|
|
139
|
+
* Useful for testing or when file structure changes
|
|
140
|
+
*/
|
|
141
|
+
export declare function clearCache(): void;
|
|
142
|
+
/**
|
|
143
|
+
* Clear cache for a specific component path
|
|
144
|
+
* Useful for HMR when a specific file changes
|
|
145
|
+
*
|
|
146
|
+
* @param src - The component source path to invalidate
|
|
147
|
+
*/
|
|
148
|
+
export declare function invalidateCacheForPath(src: string): void;
|
|
149
|
+
/**
|
|
150
|
+
* Configure cache settings
|
|
151
|
+
*
|
|
152
|
+
* @param config - Partial configuration to merge with defaults
|
|
153
|
+
*/
|
|
154
|
+
export declare function configureCache(config: Partial<CacheConfig>): void;
|
|
155
|
+
/**
|
|
156
|
+
* Get current cache configuration
|
|
157
|
+
*
|
|
158
|
+
* @returns The current cache configuration
|
|
159
|
+
*/
|
|
160
|
+
export declare function getCacheConfig(): CacheConfig;
|
|
161
|
+
/**
|
|
162
|
+
* Get cache statistics for monitoring and debugging
|
|
163
|
+
* Only logs in development mode
|
|
164
|
+
*
|
|
165
|
+
* @returns Current cache statistics
|
|
166
|
+
*/
|
|
167
|
+
export declare function getCacheStats(): CacheStats;
|
|
168
|
+
/**
|
|
169
|
+
* Log cache statistics to console (dev mode only)
|
|
170
|
+
* Useful for debugging and performance monitoring
|
|
171
|
+
*/
|
|
172
|
+
export declare function logCacheStats(): void;
|
|
173
|
+
/**
|
|
174
|
+
* Get the raw cache instance (for testing purposes only)
|
|
175
|
+
* @internal
|
|
176
|
+
*/
|
|
177
|
+
export declare function _getCache(): IslandRenderCache;
|
|
178
|
+
/**
|
|
179
|
+
* Invalidate cache entries for a specific file path
|
|
180
|
+
* Called when a component file changes during development
|
|
181
|
+
*
|
|
182
|
+
* @param filePath - The path of the changed file
|
|
183
|
+
* @returns Number of cache entries invalidated
|
|
184
|
+
*/
|
|
185
|
+
export declare function invalidateCacheForFile(filePath: string): number;
|
|
186
|
+
/**
|
|
187
|
+
* Check if a file path is an island component file
|
|
188
|
+
* Used to determine if cache invalidation is needed
|
|
189
|
+
*
|
|
190
|
+
* @param filePath - The file path to check
|
|
191
|
+
* @returns True if the file is an island component
|
|
192
|
+
*/
|
|
193
|
+
export declare function isIslandComponentFile(filePath: string): boolean;
|
|
194
|
+
/**
|
|
195
|
+
* Clear all caches when file structure changes significantly
|
|
196
|
+
* Called when files are added or removed
|
|
197
|
+
*/
|
|
198
|
+
export declare function clearPathCacheOnStructureChange(): void;
|
|
199
|
+
/**
|
|
200
|
+
* Alias for clearCache - provides a more descriptive name for external use
|
|
201
|
+
* Clears all island render caches
|
|
202
|
+
*/
|
|
203
|
+
export declare function clearIslandCache(): void;
|