@useavalon/avalon 0.1.23 → 0.1.25

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/client/main.js +1 -1
  25. package/dist/src/components/Image.d.ts +61 -0
  26. package/dist/src/components/IslandErrorBoundary.d.ts +37 -0
  27. package/dist/src/components/IslandErrorBoundary.js +1 -1
  28. package/dist/src/components/LayoutDataErrorBoundary.d.ts +34 -0
  29. package/dist/src/components/LayoutDataErrorBoundary.js +1 -1
  30. package/dist/src/components/LayoutErrorBoundary.d.ts +25 -0
  31. package/dist/src/components/LayoutErrorBoundary.js +1 -1
  32. package/dist/src/components/PersistentIsland.d.ts +36 -0
  33. package/dist/src/components/StreamingErrorBoundary.d.ts +42 -0
  34. package/dist/src/components/StreamingErrorBoundary.js +1 -1
  35. package/dist/src/components/StreamingLayout.d.ts +83 -0
  36. package/dist/src/components/StreamingLayout.js +1 -1
  37. package/dist/src/core/components/component-analyzer.d.ts +48 -0
  38. package/dist/src/core/components/component-detection.d.ts +72 -0
  39. package/dist/src/core/components/enhanced-framework-detector.d.ts +78 -0
  40. package/dist/src/core/components/framework-registry.d.ts +114 -0
  41. package/dist/src/core/content/mdx-processor.d.ts +14 -0
  42. package/dist/src/core/integrations/index.d.ts +6 -0
  43. package/dist/src/core/integrations/loader.d.ts +35 -0
  44. package/dist/src/core/integrations/registry.d.ts +51 -0
  45. package/dist/src/core/islands/island-persistence.d.ts +74 -0
  46. package/dist/src/core/islands/island-state-serializer.d.ts +53 -0
  47. package/dist/src/core/islands/persistent-island-context.d.ts +36 -0
  48. package/dist/src/core/islands/use-persistent-state.d.ts +17 -0
  49. package/dist/src/core/layout/enhanced-layout-resolver.d.ts +73 -0
  50. package/dist/src/core/layout/layout-cache-manager.d.ts +66 -0
  51. package/dist/src/core/layout/layout-composer.d.ts +63 -0
  52. package/dist/src/core/layout/layout-data-loader.d.ts +146 -0
  53. package/dist/src/core/layout/layout-discovery.d.ts +51 -0
  54. package/dist/src/core/layout/layout-matcher.d.ts +77 -0
  55. package/dist/src/core/layout/layout-types.d.ts +94 -0
  56. package/dist/src/core/modules/framework-module-resolver.d.ts +85 -0
  57. package/dist/src/islands/component-analysis.d.ts +38 -0
  58. package/dist/src/islands/css-utils.d.ts +81 -0
  59. package/dist/src/islands/discovery/index.d.ts +16 -0
  60. package/dist/src/islands/discovery/registry.d.ts +141 -0
  61. package/dist/src/islands/discovery/resolver.d.ts +190 -0
  62. package/dist/src/islands/discovery/scanner.d.ts +55 -0
  63. package/dist/src/islands/discovery/types.d.ts +92 -0
  64. package/dist/src/islands/discovery/validator.d.ts +89 -0
  65. package/dist/src/islands/discovery/watcher.d.ts +95 -0
  66. package/dist/src/islands/framework-detection.d.ts +53 -0
  67. package/dist/src/islands/integration-loader.d.ts +139 -0
  68. package/dist/src/islands/island.d.ts +55 -0
  69. package/dist/src/islands/render-cache.d.ts +203 -0
  70. package/dist/src/islands/types.d.ts +63 -0
  71. package/dist/src/islands/universal-css-collector.d.ts +41 -0
  72. package/dist/src/islands/universal-head-collector.d.ts +42 -0
  73. package/dist/src/layout-system.d.ts +92 -592
  74. package/dist/src/middleware/discovery.d.ts +70 -0
  75. package/dist/src/middleware/executor.d.ts +52 -0
  76. package/dist/src/middleware/index.d.ts +43 -0
  77. package/dist/src/middleware/types.d.ts +89 -0
  78. package/dist/src/nitro/build-config.d.ts +163 -0
  79. package/dist/src/nitro/config.d.ts +268 -0
  80. package/dist/src/nitro/error-handler.d.ts +151 -0
  81. package/dist/src/nitro/index.d.ts +15 -0
  82. package/dist/src/nitro/island-manifest.d.ts +191 -0
  83. package/dist/src/nitro/middleware-adapter.d.ts +151 -0
  84. package/dist/src/nitro/renderer.d.ts +342 -0
  85. package/dist/src/nitro/route-discovery.d.ts +142 -0
  86. package/dist/src/nitro/types.d.ts +278 -0
  87. package/dist/src/render/collect-css.d.ts +28 -0
  88. package/dist/src/render/error-pages.d.ts +14 -0
  89. package/dist/src/render/isolated-ssr-renderer.d.ts +127 -0
  90. package/dist/src/render/ssr.d.ts +56 -0
  91. package/dist/src/schemas/api.d.ts +27 -0
  92. package/dist/src/schemas/core.d.ts +75 -0
  93. package/dist/src/schemas/index.d.ts +79 -0
  94. package/dist/src/schemas/index.js +1 -1
  95. package/dist/src/schemas/layout.d.ts +282 -0
  96. package/dist/src/schemas/routing/index.d.ts +181 -0
  97. package/dist/src/schemas/routing.d.ts +388 -0
  98. package/dist/src/types/as-island.d.ts +17 -0
  99. package/dist/src/types/layout.d.ts +177 -0
  100. package/dist/src/types/routing.d.ts +297 -0
  101. package/dist/src/types/types.d.ts +6 -0
  102. package/dist/src/utils/dev-logger.d.ts +84 -0
  103. package/dist/src/utils/fs.d.ts +41 -0
  104. package/dist/src/vite-plugin/auto-discover.d.ts +72 -0
  105. package/dist/src/vite-plugin/config.d.ts +82 -0
  106. package/dist/src/vite-plugin/errors.d.ts +62 -0
  107. package/dist/src/vite-plugin/image-optimization.d.ts +36 -0
  108. package/dist/src/vite-plugin/integration-activator.d.ts +48 -0
  109. package/dist/src/vite-plugin/island-sidecar-plugin.d.ts +17 -0
  110. package/dist/src/vite-plugin/module-discovery.d.ts +66 -0
  111. package/dist/src/vite-plugin/nitro-integration.d.ts +56 -0
  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,38 @@
1
+ import type { JSX } from 'preact';
2
+ import { type AnalyzerOptions, type AnalysisReport } from '../core/components/component-analyzer.ts';
3
+ import type { IslandProps } from './types.ts';
4
+ /**
5
+ * Analyze component file for rendering strategy
6
+ *
7
+ * Attempts to read the component file from various path variations and
8
+ * analyzes its content to determine the optimal rendering strategy.
9
+ * Uses caching to avoid repeated file I/O and analysis for the same components.
10
+ *
11
+ * @param src - The source path to the component
12
+ * @param options - Analyzer options for customizing the analysis
13
+ * @returns Analysis result with rendering strategy decision
14
+ * @throws Error if component file cannot be found
15
+ */
16
+ export declare function analyzeComponentFile(src: string, options?: AnalyzerOptions): Promise<AnalysisReport>;
17
+ /**
18
+ * Render component with SSR-only strategy (no hydration)
19
+ *
20
+ * Renders a component server-side without adding client-side hydration.
21
+ * This is useful for static components that don't require interactivity.
22
+ *
23
+ * @param params - Rendering parameters
24
+ * @param params.src - Component source path
25
+ * @param params.condition - Island hydration condition
26
+ * @param params.props - Props to pass to the component
27
+ * @param params.framework - Optional explicit framework (if not provided, will be detected)
28
+ * @param params.renderOptions - Additional render options
29
+ * @returns Island component with SSR-only rendering
30
+ * @throws Error if SSR rendering fails
31
+ */
32
+ export declare function renderComponentSSROnly({ src, condition, props, framework: explicitFramework, renderOptions, }: {
33
+ src: string;
34
+ condition: IslandProps['condition'];
35
+ props: Record<string, unknown>;
36
+ framework?: string;
37
+ renderOptions: AnalyzerOptions;
38
+ }): Promise<JSX.Element>;
@@ -0,0 +1,81 @@
1
+ /**
2
+ * CSS Utilities Module
3
+ *
4
+ * This module contains all CSS-related utilities for the Island system:
5
+ * - Svelte SSR CSS collection and management
6
+ * - CSS scoping for component isolation
7
+ * - CSS optimization and minification
8
+ * - CSS parsing and deduplication
9
+ */
10
+ declare global {
11
+ var __svelteSSRCSS: Map<string, SvelteSSRCSSEntry> | undefined;
12
+ }
13
+ interface SvelteSSRCSSEntry {
14
+ css: string;
15
+ scopeId: string;
16
+ src: string;
17
+ isGlobal: boolean;
18
+ timestamp: number;
19
+ }
20
+ /**
21
+ * Add CSS to the global Svelte SSR collection with scoping information
22
+ */
23
+ export declare function addSvelteSSRCSS(css: string, scopeId: string, src: string, isGlobal?: boolean): void;
24
+ /**
25
+ * Get collected Svelte SSR CSS with enhanced processing and deduplication
26
+ * Enhanced version with better CSS management and document head injection support
27
+ */
28
+ export declare function getSvelteSSRCSS(clear?: boolean): string;
29
+ /**
30
+ * Get CSS formatted for document head injection during SSR
31
+ * Returns CSS wrapped in appropriate style tags with metadata
32
+ */
33
+ export declare function getSvelteSSRCSSForHead(clear?: boolean): string;
34
+ /**
35
+ * Get CSS statistics for debugging and monitoring
36
+ */
37
+ export declare function getSvelteSSRCSSStats(): {
38
+ totalComponents: number;
39
+ globalComponents: number;
40
+ scopedComponents: number;
41
+ totalCSSSize: number;
42
+ averageCSSSize: number;
43
+ oldestTimestamp: number;
44
+ newestTimestamp: number;
45
+ };
46
+ /**
47
+ * Get CSS for specific component scope
48
+ */
49
+ export declare function getSvelteComponentCSS(scopeId: string): string;
50
+ /**
51
+ * Clear CSS for specific component scope
52
+ */
53
+ export declare function clearSvelteComponentCSS(scopeId: string): boolean;
54
+ /**
55
+ * Apply CSS scoping to selectors with advanced logic
56
+ * Enhanced version with better selector parsing and scoping rules
57
+ */
58
+ export declare function applyCSSScoping(cssContent: string, scopeId: string): string;
59
+ /**
60
+ * Apply scoping to a single CSS selector with comprehensive logic
61
+ */
62
+ export declare function applySelectorScoping(selector: string, scopeId: string): string;
63
+ /**
64
+ * Optimize component CSS by removing duplicates and applying minification
65
+ * Enhanced version with better deduplication and optimization strategies
66
+ */
67
+ export declare function optimizeComponentCSS(css: string): string;
68
+ /**
69
+ * Minify CSS for production builds
70
+ */
71
+ export declare function minifyCSS(css: string): string;
72
+ /**
73
+ * Generate consistent scope ID for any component framework
74
+ * Provides unified scoping across Vue, Svelte, and other frameworks
75
+ */
76
+ export declare function generateComponentScopeId(src: string, framework?: string): string;
77
+ /**
78
+ * Simple hash function for generating consistent short hashes
79
+ */
80
+ export declare function simpleHash(str: string): string;
81
+ export {};
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Island Discovery Module
3
+ *
4
+ * Exports all types and functions for discovering island components
5
+ * in nested directory structures.
6
+ */
7
+ export type { IslandDirectory, DiscoveredIsland, IslandCollision, IslandChangeEvent, IslandFileExtension, IslandDiscoveryConfig, } from "./types.ts";
8
+ export { ISLAND_FILE_EXTENSIONS, DEFAULT_DISCOVERY_CONFIG, isSupportedIslandExtension, } from "./types.ts";
9
+ export { discoverIslandDirectories, discoverIslandsInDirectory, discoverAllIslands, isIslandsDirectory, getDefaultIslandsPath, hasDefaultIslandsDirectory, getQualifiedIslandName, parseQualifiedIslandName, } from "./scanner.ts";
10
+ export { IslandRegistry, createIslandRegistry, } from "./registry.ts";
11
+ export type { ResolutionResult, ImportPathOptions, } from "./resolver.ts";
12
+ export { IslandResolver, createIslandResolver, } from "./resolver.ts";
13
+ export type { ValidationResult, ValidationError, ValidationWarning, CircularDependency, } from "./validator.ts";
14
+ export { IslandValidator, createIslandValidator, validateAllIslands, formatValidationError, formatValidationWarning, formatCircularDependency, formatValidationResult, } from "./validator.ts";
15
+ export type { IslandChangeCallback, IslandWatcherOptions, } from "./watcher.ts";
16
+ export { IslandWatcher, createIslandWatcher, } from "./watcher.ts";
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Island Registry
3
+ *
4
+ * Central registry for all discovered islands with resolution capabilities.
5
+ * Handles registration, resolution by name/namespace, and collision detection.
6
+ */
7
+ import type { DiscoveredIsland, IslandDirectory, IslandCollision, IslandDiscoveryConfig } from "./types.ts";
8
+ /**
9
+ * Central registry for all discovered islands.
10
+ * Provides registration, resolution, and collision detection capabilities.
11
+ */
12
+ export declare class IslandRegistry {
13
+ /** All discovered islands indexed by qualified name */
14
+ private _islands;
15
+ /** All discovered island directories */
16
+ private _directories;
17
+ /** Index of islands by name (for fast lookup) */
18
+ private _byName;
19
+ /** Detected collisions */
20
+ private _collisions;
21
+ /** Project root directory */
22
+ private _projectRoot;
23
+ /** Discovery configuration */
24
+ private _config;
25
+ constructor(projectRoot: string, config?: IslandDiscoveryConfig);
26
+ /**
27
+ * Get all discovered islands as a Map.
28
+ */
29
+ get islands(): Map<string, DiscoveredIsland>;
30
+ /**
31
+ * Get all discovered island directories.
32
+ */
33
+ get directories(): IslandDirectory[];
34
+ /**
35
+ * Get all detected collisions.
36
+ */
37
+ get collisions(): IslandCollision[];
38
+ /**
39
+ * Get the number of registered islands.
40
+ */
41
+ get size(): number;
42
+ /**
43
+ * Register a discovered island in the registry.
44
+ * Updates the name index and detects collisions.
45
+ *
46
+ * @param island - The island to register
47
+ */
48
+ register(island: DiscoveredIsland): void;
49
+ /**
50
+ * Resolve an island by name with optional namespace.
51
+ *
52
+ * Resolution priority:
53
+ * 1. Exact qualified name match (namespace/name)
54
+ * 2. Default islands directory (highest priority for unqualified names)
55
+ * 3. First match in alphabetical order by namespace
56
+ *
57
+ * @param name - Component name or qualified name (namespace/name)
58
+ * @param namespace - Optional namespace to narrow search
59
+ * @returns The resolved island or null if not found
60
+ */
61
+ resolve(name: string, namespace?: string): DiscoveredIsland | null;
62
+ /**
63
+ * Find all islands matching a name.
64
+ * Useful for collision detection and disambiguation.
65
+ *
66
+ * @param name - Component name to search for
67
+ * @returns Array of all islands with this name
68
+ */
69
+ findByName(name: string): DiscoveredIsland[];
70
+ /**
71
+ * Get the qualified name for an island.
72
+ *
73
+ * @param island - The island to get the qualified name for
74
+ * @returns The qualified name (namespace/name or just name for default)
75
+ */
76
+ getQualifiedName(island: DiscoveredIsland): string;
77
+ /**
78
+ * Check if an island with the given name or qualified name exists.
79
+ *
80
+ * @param nameOrQualified - Component name or qualified name
81
+ * @returns True if the island exists
82
+ */
83
+ has(nameOrQualified: string): boolean;
84
+ /**
85
+ * Detect naming collisions across all registered islands.
86
+ * A collision occurs when multiple islands share the same component name.
87
+ *
88
+ * @returns Array of detected collisions
89
+ */
90
+ detectCollisions(): IslandCollision[];
91
+ /**
92
+ * Clear the registry and rebuild from filesystem.
93
+ * Discovers all island directories and their components.
94
+ */
95
+ rebuild(): Promise<void>;
96
+ /**
97
+ * Get all islands as an array.
98
+ *
99
+ * @returns Array of all registered islands
100
+ */
101
+ getAllIslands(): DiscoveredIsland[];
102
+ /**
103
+ * Get islands from a specific directory.
104
+ *
105
+ * @param directory - The directory to get islands from
106
+ * @returns Array of islands in the directory
107
+ */
108
+ getIslandsInDirectory(directory: IslandDirectory): DiscoveredIsland[];
109
+ /**
110
+ * Get islands by namespace.
111
+ *
112
+ * @param namespace - The namespace to filter by (empty string for default)
113
+ * @returns Array of islands in the namespace
114
+ */
115
+ getIslandsByNamespace(namespace: string): DiscoveredIsland[];
116
+ /**
117
+ * Remove an island from the registry.
118
+ *
119
+ * @param qualifiedName - The qualified name of the island to remove
120
+ * @returns True if the island was removed
121
+ */
122
+ unregister(qualifiedName: string): boolean;
123
+ /**
124
+ * Create a snapshot of the registry state.
125
+ * Useful for debugging and testing.
126
+ */
127
+ toJSON(): {
128
+ islands: Record<string, DiscoveredIsland>;
129
+ directories: IslandDirectory[];
130
+ collisions: IslandCollision[];
131
+ };
132
+ }
133
+ /**
134
+ * Create and initialize an island registry.
135
+ * Convenience function that creates a registry and rebuilds it.
136
+ *
137
+ * @param projectRoot - The root directory of the project
138
+ * @param config - Optional configuration for discovery
139
+ * @returns Initialized island registry
140
+ */
141
+ export declare function createIslandRegistry(projectRoot: string, config?: IslandDiscoveryConfig): Promise<IslandRegistry>;
@@ -0,0 +1,190 @@
1
+ /**
2
+ * Island Resolver
3
+ *
4
+ * Handles runtime resolution of island references to actual file paths.
5
+ * Supports priority-based resolution with default /src/islands/ having highest priority.
6
+ *
7
+ * ## Resolution Order
8
+ *
9
+ * When resolving an island reference, the resolver follows this priority order:
10
+ *
11
+ * 1. **Explicit path-based references** (e.g., "src/modules/auth/islands/Counter")
12
+ * - Full path to the island file
13
+ * - Always unambiguous
14
+ *
15
+ * 2. **Qualified name matches** (e.g., "modules/auth/Counter")
16
+ * - Namespace/name format
17
+ * - Namespace is derived from directory path between src/ and islands/
18
+ *
19
+ * 3. **Default /src/islands/ directory**
20
+ * - Highest priority for simple names (backward compatibility)
21
+ * - If an island exists in both default and nested directories,
22
+ * the default directory wins
23
+ *
24
+ * 4. **Nested directories in alphabetical order**
25
+ * - When not found in default directory
26
+ * - Sorted alphabetically by namespace
27
+ *
28
+ * ## Namespace Conventions
29
+ *
30
+ * - src/islands/Counter.tsx -> namespace: "", qualified: "Counter"
31
+ * - src/modules/auth/islands/LoginForm.tsx -> namespace: "modules/auth", qualified: "modules/auth/LoginForm"
32
+ * - src/features/checkout/islands/PaymentForm.tsx -> namespace: "features/checkout", qualified: "features/checkout/PaymentForm"
33
+ *
34
+ * ## Handling Collisions
35
+ *
36
+ * When multiple islands share the same name:
37
+ * - Use qualified names to disambiguate
38
+ * - The resolver returns `ambiguous: true` with alternatives
39
+ * - Default directory always has priority for simple name resolution
40
+ */
41
+ import type { DiscoveredIsland } from "./types.ts";
42
+ import type { IslandRegistry } from "./registry.ts";
43
+ /**
44
+ * Result of resolving an island reference
45
+ */
46
+ export interface ResolutionResult {
47
+ /** Resolved island */
48
+ island: DiscoveredIsland;
49
+ /** Import path for the island */
50
+ importPath: string;
51
+ /** Whether resolution was ambiguous (multiple matches found) */
52
+ ambiguous: boolean;
53
+ /** Alternative matches if ambiguous */
54
+ alternatives?: DiscoveredIsland[];
55
+ }
56
+ /**
57
+ * Options for import path generation
58
+ */
59
+ export interface ImportPathOptions {
60
+ /** Whether generating for development (true) or production (false) */
61
+ isDevelopment?: boolean;
62
+ /** Base path for imports (e.g., "/@fs/" for dev, "/" for prod) */
63
+ basePath?: string;
64
+ /** Project root directory */
65
+ projectRoot?: string;
66
+ /** Whether to use absolute paths */
67
+ absolute?: boolean;
68
+ }
69
+ /**
70
+ * Island Resolver class
71
+ *
72
+ * Resolves island references to actual file paths with priority-based resolution.
73
+ * Default /src/islands/ directory has highest priority for backward compatibility.
74
+ */
75
+ export declare class IslandResolver {
76
+ private _registry;
77
+ private _projectRoot;
78
+ constructor(registry: IslandRegistry, projectRoot: string);
79
+ /**
80
+ * Get the underlying registry
81
+ */
82
+ get registry(): IslandRegistry;
83
+ /**
84
+ * Get the project root
85
+ */
86
+ get projectRoot(): string;
87
+ /**
88
+ * Resolve an island reference to a file path.
89
+ *
90
+ * Resolution priority:
91
+ * 1. Explicit path-based reference (e.g., "modules/auth/Counter")
92
+ * 2. Qualified name match (namespace/name)
93
+ * 3. Default islands directory (highest priority for unqualified names)
94
+ * 4. First match in alphabetical order by namespace
95
+ *
96
+ * @param reference - Island reference (name, qualified name, or path)
97
+ * @returns Resolution result or null if not found
98
+ */
99
+ resolve(reference: string): ResolutionResult | null;
100
+ /**
101
+ * Normalize an island reference for consistent resolution.
102
+ */
103
+ private normalizeReference;
104
+ /**
105
+ * Resolve an explicit path-based reference.
106
+ * Handles references like "src/modules/auth/islands/Counter"
107
+ */
108
+ private resolveExplicitPath;
109
+ /**
110
+ * Resolve a qualified name (namespace/name).
111
+ */
112
+ private resolveQualifiedName;
113
+ /**
114
+ * Resolve by name with priority-based resolution.
115
+ * Default /src/islands/ has highest priority.
116
+ */
117
+ private resolveByName;
118
+ /**
119
+ * Generate an import path for an island.
120
+ * Handles both development and production paths.
121
+ *
122
+ * @param island - The island to generate an import path for
123
+ * @param options - Options for path generation
124
+ * @returns The import path string
125
+ */
126
+ generateImportPath(island: DiscoveredIsland, options?: ImportPathOptions): string;
127
+ /**
128
+ * Generate a qualified import path for disambiguation.
129
+ * Always includes the namespace for clarity.
130
+ *
131
+ * @param island - The island to generate a path for
132
+ * @returns Qualified import path
133
+ */
134
+ generateQualifiedImportPath(island: DiscoveredIsland): string;
135
+ /**
136
+ * Get the resolution order documentation.
137
+ * Describes how islands are resolved when multiple matches exist.
138
+ *
139
+ * @returns Array of resolution order descriptions
140
+ */
141
+ getResolutionOrder(): string[];
142
+ /**
143
+ * Check if a reference would resolve ambiguously.
144
+ *
145
+ * @param reference - Island reference to check
146
+ * @returns True if the reference matches multiple islands
147
+ */
148
+ isAmbiguous(reference: string): boolean;
149
+ /**
150
+ * Get all possible resolutions for a reference.
151
+ * Useful for providing suggestions when resolution is ambiguous.
152
+ *
153
+ * @param reference - Island reference
154
+ * @returns Array of all matching islands
155
+ */
156
+ getAllMatches(reference: string): DiscoveredIsland[];
157
+ /**
158
+ * Suggest qualified names for disambiguation.
159
+ *
160
+ * @param name - Component name with multiple matches
161
+ * @returns Array of qualified name suggestions
162
+ */
163
+ suggestQualifiedNames(name: string): string[];
164
+ /**
165
+ * Resolve an island and throw if not found.
166
+ *
167
+ * @param reference - Island reference
168
+ * @throws Error if island is not found
169
+ * @returns Resolution result
170
+ */
171
+ resolveOrThrow(reference: string): ResolutionResult;
172
+ /**
173
+ * Find similar island names for suggestions.
174
+ * Uses simple string similarity for fuzzy matching.
175
+ */
176
+ private findSimilarNames;
177
+ /**
178
+ * Calculate Levenshtein distance between two strings.
179
+ * Used for fuzzy name matching.
180
+ */
181
+ private levenshteinDistance;
182
+ }
183
+ /**
184
+ * Create an island resolver from a registry.
185
+ *
186
+ * @param registry - The island registry to use
187
+ * @param projectRoot - The project root directory
188
+ * @returns A new IslandResolver instance
189
+ */
190
+ export declare function createIslandResolver(registry: IslandRegistry, projectRoot: string): IslandResolver;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Island Directory Scanner
3
+ *
4
+ * Recursively scans the source directory to discover all islands directories.
5
+ * Supports nested patterns like /src/modules/[module]/islands/.
6
+ */
7
+ import type { IslandDirectory, IslandDiscoveryConfig, DiscoveredIsland } from "./types.ts";
8
+ /**
9
+ * Discover all island directories within the source directory.
10
+ * Uses recursive scanning to find all directories named "islands".
11
+ *
12
+ * @param projectRoot - The root directory of the project
13
+ * @param config - Optional configuration for discovery
14
+ * @returns Array of discovered island directories
15
+ */
16
+ export declare function discoverIslandDirectories(projectRoot: string, config?: IslandDiscoveryConfig): Promise<IslandDirectory[]>;
17
+ /**
18
+ * Check if a directory is an islands directory.
19
+ */
20
+ export declare function isIslandsDirectory(dirPath: string): boolean;
21
+ /**
22
+ * Get the default islands directory path.
23
+ */
24
+ export declare function getDefaultIslandsPath(projectRoot: string, rootDir?: string): string;
25
+ /**
26
+ * Check if the default islands directory exists.
27
+ */
28
+ export declare function hasDefaultIslandsDirectory(projectRoot: string, rootDir?: string): Promise<boolean>;
29
+ /**
30
+ * Discover all island components within a specific islands directory.
31
+ *
32
+ * @param directory - The island directory to scan
33
+ * @param projectRoot - The root directory of the project
34
+ * @returns Array of discovered island components
35
+ */
36
+ export declare function discoverIslandsInDirectory(directory: IslandDirectory, projectRoot: string): Promise<DiscoveredIsland[]>;
37
+ /**
38
+ * Discover all islands across all directories.
39
+ *
40
+ * @param projectRoot - The root directory of the project
41
+ * @param config - Optional configuration for discovery
42
+ * @returns Array of all discovered island components
43
+ */
44
+ export declare function discoverAllIslands(projectRoot: string, config?: IslandDiscoveryConfig): Promise<DiscoveredIsland[]>;
45
+ /**
46
+ * Get the qualified name for an island (namespace/name or just name for default).
47
+ */
48
+ export declare function getQualifiedIslandName(island: DiscoveredIsland): string;
49
+ /**
50
+ * Parse a qualified island name into namespace and name parts.
51
+ */
52
+ export declare function parseQualifiedIslandName(qualifiedName: string): {
53
+ namespace: string;
54
+ name: string;
55
+ };
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Island Discovery Types
3
+ *
4
+ * Type definitions for the nested islands discovery system.
5
+ * Supports discovering island components in modular architectures
6
+ * like /src/modules/[module]/islands/ and arbitrary nesting patterns.
7
+ */
8
+ import type { Framework } from "../types.ts";
9
+ /**
10
+ * Represents a discovered islands directory
11
+ */
12
+ export interface IslandDirectory {
13
+ /** Absolute path to the islands directory */
14
+ path: string;
15
+ /** Relative path from src/ (e.g., "modules/auth/islands") */
16
+ relativePath: string;
17
+ /** Namespace prefix for components (e.g., "modules/auth") */
18
+ namespace: string;
19
+ /** Whether this is the default /src/islands/ directory */
20
+ isDefault: boolean;
21
+ }
22
+ /**
23
+ * Represents a discovered island component
24
+ */
25
+ export interface DiscoveredIsland {
26
+ /** Component name without extension */
27
+ name: string;
28
+ /** Full absolute path to the component file */
29
+ filePath: string;
30
+ /** Relative path from project root */
31
+ relativePath: string;
32
+ /** Namespace (empty string for default islands directory) */
33
+ namespace: string;
34
+ /** Detected framework */
35
+ framework: Framework;
36
+ /** File extension (e.g., ".tsx", ".vue", ".svelte") */
37
+ extension: string;
38
+ /** The directory this island belongs to */
39
+ directory: IslandDirectory;
40
+ }
41
+ /**
42
+ * Represents a naming collision between islands
43
+ */
44
+ export interface IslandCollision {
45
+ /** Component name that has collisions */
46
+ name: string;
47
+ /** All islands with this name */
48
+ islands: DiscoveredIsland[];
49
+ /** Resolution strategy used */
50
+ resolution: "namespace" | "priority";
51
+ }
52
+ /**
53
+ * Event emitted when island files change
54
+ */
55
+ export interface IslandChangeEvent {
56
+ /** Type of change */
57
+ type: "add" | "change" | "remove";
58
+ /** Affected island (null for remove events before discovery) */
59
+ island: DiscoveredIsland | null;
60
+ /** File path that changed */
61
+ filePath: string;
62
+ /** Timestamp of the change */
63
+ timestamp: number;
64
+ }
65
+ /**
66
+ * Supported file extensions for island components
67
+ */
68
+ export declare const ISLAND_FILE_EXTENSIONS: readonly [".tsx", ".ts", ".jsx", ".js", ".vue", ".svelte"];
69
+ export type IslandFileExtension = (typeof ISLAND_FILE_EXTENSIONS)[number];
70
+ /**
71
+ * Check if a file extension is supported for islands
72
+ */
73
+ export declare function isSupportedIslandExtension(ext: string): ext is IslandFileExtension;
74
+ /**
75
+ * Configuration options for island discovery
76
+ */
77
+ export interface IslandDiscoveryConfig {
78
+ /** Root directory to scan (defaults to "src") */
79
+ rootDir?: string;
80
+ /** Additional directories to scan (beyond default patterns) */
81
+ include?: string[];
82
+ /** Directories to exclude from scanning */
83
+ exclude?: string[];
84
+ /** Custom namespace mapping */
85
+ namespaces?: Record<string, string>;
86
+ /** Whether to fail on naming collisions */
87
+ strictCollisions?: boolean;
88
+ }
89
+ /**
90
+ * Default configuration for island discovery
91
+ */
92
+ export declare const DEFAULT_DISCOVERY_CONFIG: Required<IslandDiscoveryConfig>;