@useavalon/avalon 0.1.10 → 0.1.12
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/README.md +54 -54
- package/dist/mod.js +1 -0
- package/dist/src/build/integration-bundler-plugin.js +1 -0
- package/dist/src/build/integration-config.js +1 -0
- package/dist/src/build/integration-detection-plugin.js +1 -0
- package/dist/src/build/integration-resolver-plugin.js +1 -0
- package/dist/src/build/island-manifest.js +1 -0
- package/dist/src/build/island-types-generator.js +5 -0
- package/dist/src/build/mdx-island-transform.js +2 -0
- package/dist/src/build/mdx-plugin.js +1 -0
- package/dist/src/build/page-island-transform.js +3 -0
- package/dist/src/build/prop-extractors/index.js +1 -0
- package/dist/src/build/prop-extractors/lit.js +1 -0
- package/dist/src/build/prop-extractors/qwik.js +1 -0
- package/dist/src/build/prop-extractors/solid.js +1 -0
- package/dist/src/build/prop-extractors/svelte.js +1 -0
- package/dist/src/build/prop-extractors/vue.js +1 -0
- package/dist/src/build/sidecar-file-manager.js +1 -0
- package/dist/src/build/sidecar-renderer.js +6 -0
- package/dist/src/client/adapters/index.js +1 -0
- package/dist/src/client/components.js +1 -0
- package/dist/src/client/css-hmr-handler.js +1 -0
- package/dist/src/client/framework-adapter.js +13 -0
- package/dist/src/client/hmr-coordinator.js +1 -0
- package/dist/src/client/hmr-error-overlay.js +214 -0
- package/dist/src/client/main.js +39 -0
- package/{src → dist/src}/client/types/framework-runtime.d.ts +68 -68
- package/{src → dist/src}/client/types/vite-hmr.d.ts +46 -46
- package/dist/src/client/types/vite-virtual-modules.d.ts +70 -0
- package/dist/src/components/Image.js +1 -0
- package/dist/src/components/IslandErrorBoundary.js +1 -0
- package/dist/src/components/LayoutDataErrorBoundary.js +1 -0
- package/dist/src/components/LayoutErrorBoundary.js +1 -0
- package/dist/src/components/PersistentIsland.js +1 -0
- package/dist/src/components/StreamingErrorBoundary.js +1 -0
- package/dist/src/components/StreamingLayout.js +29 -0
- package/dist/src/core/components/component-analyzer.js +1 -0
- package/dist/src/core/components/component-detection.js +5 -0
- package/dist/src/core/components/enhanced-framework-detector.js +1 -0
- package/dist/src/core/components/framework-registry.js +1 -0
- package/dist/src/core/content/mdx-processor.js +1 -0
- package/dist/src/core/integrations/index.js +1 -0
- package/dist/src/core/integrations/loader.js +1 -0
- package/dist/src/core/integrations/registry.js +1 -0
- package/dist/src/core/islands/island-persistence.js +1 -0
- package/dist/src/core/islands/island-state-serializer.js +1 -0
- package/dist/src/core/islands/persistent-island-context.js +1 -0
- package/dist/src/core/islands/use-persistent-state.js +1 -0
- package/dist/src/core/layout/enhanced-layout-resolver.js +1 -0
- package/dist/src/core/layout/layout-cache-manager.js +1 -0
- package/dist/src/core/layout/layout-composer.js +1 -0
- package/dist/src/core/layout/layout-data-loader.js +1 -0
- package/dist/src/core/layout/layout-discovery.js +1 -0
- package/dist/src/core/layout/layout-matcher.js +1 -0
- package/dist/src/core/layout/layout-types.js +1 -0
- package/dist/src/core/modules/framework-module-resolver.js +1 -0
- package/dist/src/islands/component-analysis.js +1 -0
- package/dist/src/islands/css-utils.js +17 -0
- package/dist/src/islands/discovery/index.js +1 -0
- package/dist/src/islands/discovery/registry.js +1 -0
- package/dist/src/islands/discovery/resolver.js +2 -0
- package/dist/src/islands/discovery/scanner.js +1 -0
- package/dist/src/islands/discovery/types.js +1 -0
- package/dist/src/islands/discovery/validator.js +18 -0
- package/dist/src/islands/discovery/watcher.js +1 -0
- package/dist/src/islands/framework-detection.js +1 -0
- package/dist/src/islands/integration-loader.js +1 -0
- package/dist/src/islands/island.js +1 -0
- package/dist/src/islands/render-cache.js +1 -0
- package/dist/src/islands/types.js +1 -0
- package/dist/src/islands/universal-css-collector.js +5 -0
- package/dist/src/islands/universal-head-collector.js +2 -0
- package/{src → dist/src}/layout-system.d.ts +592 -592
- package/dist/src/layout-system.js +1 -0
- package/dist/src/middleware/discovery.js +1 -0
- package/dist/src/middleware/executor.js +1 -0
- package/dist/src/middleware/index.js +1 -0
- package/dist/src/middleware/types.js +1 -0
- package/dist/src/nitro/build-config.js +1 -0
- package/dist/src/nitro/config.js +1 -0
- package/dist/src/nitro/error-handler.js +198 -0
- package/dist/src/nitro/index.js +1 -0
- package/dist/src/nitro/island-manifest.js +2 -0
- package/dist/src/nitro/middleware-adapter.js +1 -0
- package/dist/src/nitro/renderer.js +183 -0
- package/dist/src/nitro/route-discovery.js +1 -0
- package/dist/src/nitro/types.js +1 -0
- package/dist/src/render/collect-css.js +3 -0
- package/{src/render/error-pages.ts → dist/src/render/error-pages.js} +7 -38
- package/dist/src/render/isolated-ssr-renderer.js +1 -0
- package/dist/src/render/ssr.js +90 -0
- package/dist/src/schemas/api.js +1 -0
- package/dist/src/schemas/core.js +1 -0
- package/dist/src/schemas/index.js +1 -0
- package/dist/src/schemas/layout.js +1 -0
- package/dist/src/schemas/routing/index.js +1 -0
- package/dist/src/schemas/routing.js +1 -0
- package/dist/src/types/as-island.js +1 -0
- package/{src → dist/src}/types/image.d.ts +106 -106
- package/{src → dist/src}/types/index.d.ts +22 -22
- package/{src → dist/src}/types/island-jsx.d.ts +33 -33
- package/{src → dist/src}/types/island-prop.d.ts +20 -20
- package/dist/src/types/layout.js +1 -0
- package/{src → dist/src}/types/mdx.d.ts +6 -6
- package/dist/src/types/routing.js +1 -0
- package/dist/src/types/types.js +1 -0
- package/{src → dist/src}/types/urlpattern.d.ts +49 -49
- package/{src → dist/src}/types/vite-env.d.ts +11 -11
- package/dist/src/utils/dev-logger.js +12 -0
- package/dist/src/utils/fs.js +1 -0
- package/dist/src/vite-plugin/auto-discover.js +1 -0
- package/dist/src/vite-plugin/config.js +1 -0
- package/dist/src/vite-plugin/errors.js +1 -0
- package/dist/src/vite-plugin/image-optimization.js +45 -0
- package/dist/src/vite-plugin/integration-activator.js +1 -0
- package/dist/src/vite-plugin/island-sidecar-plugin.js +1 -0
- package/dist/src/vite-plugin/module-discovery.js +1 -0
- package/dist/src/vite-plugin/nitro-integration.js +42 -0
- package/dist/src/vite-plugin/plugin.js +1 -0
- package/dist/src/vite-plugin/types.js +1 -0
- package/dist/src/vite-plugin/validation.js +2 -0
- package/package.json +57 -26
- package/mod.ts +0 -302
- package/src/build/integration-bundler-plugin.ts +0 -116
- package/src/build/integration-config.ts +0 -168
- package/src/build/integration-detection-plugin.ts +0 -117
- package/src/build/integration-resolver-plugin.ts +0 -90
- package/src/build/island-manifest.ts +0 -269
- package/src/build/island-types-generator.ts +0 -476
- package/src/build/mdx-island-transform.ts +0 -464
- package/src/build/mdx-plugin.ts +0 -98
- package/src/build/page-island-transform.ts +0 -598
- package/src/build/prop-extractors/index.ts +0 -21
- package/src/build/prop-extractors/lit.ts +0 -140
- package/src/build/prop-extractors/qwik.ts +0 -16
- package/src/build/prop-extractors/solid.ts +0 -125
- package/src/build/prop-extractors/svelte.ts +0 -194
- package/src/build/prop-extractors/vue.ts +0 -111
- package/src/build/sidecar-file-manager.ts +0 -104
- package/src/build/sidecar-renderer.ts +0 -30
- package/src/client/adapters/index.js +0 -12
- package/src/client/adapters/index.ts +0 -13
- package/src/client/adapters/lit-adapter.js +0 -467
- package/src/client/adapters/lit-adapter.ts +0 -654
- package/src/client/adapters/preact-adapter.js +0 -223
- package/src/client/adapters/preact-adapter.ts +0 -331
- package/src/client/adapters/qwik-adapter.js +0 -259
- package/src/client/adapters/qwik-adapter.ts +0 -345
- package/src/client/adapters/react-adapter.js +0 -220
- package/src/client/adapters/react-adapter.ts +0 -353
- package/src/client/adapters/solid-adapter.js +0 -295
- package/src/client/adapters/solid-adapter.ts +0 -451
- package/src/client/adapters/svelte-adapter.js +0 -368
- package/src/client/adapters/svelte-adapter.ts +0 -524
- package/src/client/adapters/vue-adapter.js +0 -278
- package/src/client/adapters/vue-adapter.ts +0 -467
- package/src/client/components.js +0 -23
- package/src/client/components.ts +0 -35
- package/src/client/css-hmr-handler.js +0 -263
- package/src/client/css-hmr-handler.ts +0 -344
- package/src/client/framework-adapter.js +0 -283
- package/src/client/framework-adapter.ts +0 -462
- package/src/client/hmr-coordinator.js +0 -274
- package/src/client/hmr-coordinator.ts +0 -396
- package/src/client/hmr-error-overlay.js +0 -533
- package/src/client/main.js +0 -816
- package/src/client/types/vite-virtual-modules.d.ts +0 -60
- package/src/components/Image.tsx +0 -123
- package/src/components/IslandErrorBoundary.tsx +0 -145
- package/src/components/LayoutDataErrorBoundary.tsx +0 -141
- package/src/components/LayoutErrorBoundary.tsx +0 -127
- package/src/components/PersistentIsland.tsx +0 -52
- package/src/components/StreamingErrorBoundary.tsx +0 -233
- package/src/components/StreamingLayout.tsx +0 -538
- package/src/core/components/component-analyzer.ts +0 -192
- package/src/core/components/component-detection.ts +0 -508
- package/src/core/components/enhanced-framework-detector.ts +0 -500
- package/src/core/components/framework-registry.ts +0 -563
- package/src/core/content/mdx-processor.ts +0 -46
- package/src/core/integrations/index.ts +0 -19
- package/src/core/integrations/loader.ts +0 -125
- package/src/core/integrations/registry.ts +0 -175
- package/src/core/islands/island-persistence.ts +0 -325
- package/src/core/islands/island-state-serializer.ts +0 -258
- package/src/core/islands/persistent-island-context.tsx +0 -80
- package/src/core/islands/use-persistent-state.ts +0 -68
- package/src/core/layout/enhanced-layout-resolver.ts +0 -322
- package/src/core/layout/layout-cache-manager.ts +0 -485
- package/src/core/layout/layout-composer.ts +0 -357
- package/src/core/layout/layout-data-loader.ts +0 -516
- package/src/core/layout/layout-discovery.ts +0 -243
- package/src/core/layout/layout-matcher.ts +0 -299
- package/src/core/layout/layout-types.ts +0 -110
- package/src/core/modules/framework-module-resolver.ts +0 -273
- package/src/islands/component-analysis.ts +0 -213
- package/src/islands/css-utils.ts +0 -565
- package/src/islands/discovery/index.ts +0 -80
- package/src/islands/discovery/registry.ts +0 -340
- package/src/islands/discovery/resolver.ts +0 -477
- package/src/islands/discovery/scanner.ts +0 -386
- package/src/islands/discovery/types.ts +0 -117
- package/src/islands/discovery/validator.ts +0 -544
- package/src/islands/discovery/watcher.ts +0 -368
- package/src/islands/framework-detection.ts +0 -428
- package/src/islands/integration-loader.ts +0 -490
- package/src/islands/island.tsx +0 -565
- package/src/islands/render-cache.ts +0 -550
- package/src/islands/types.ts +0 -80
- package/src/islands/universal-css-collector.ts +0 -157
- package/src/islands/universal-head-collector.ts +0 -137
- package/src/layout-system.ts +0 -218
- package/src/middleware/discovery.ts +0 -268
- package/src/middleware/executor.ts +0 -315
- package/src/middleware/index.ts +0 -76
- package/src/middleware/types.ts +0 -99
- package/src/nitro/build-config.ts +0 -576
- package/src/nitro/config.ts +0 -483
- package/src/nitro/error-handler.ts +0 -636
- package/src/nitro/index.ts +0 -173
- package/src/nitro/island-manifest.ts +0 -584
- package/src/nitro/middleware-adapter.ts +0 -260
- package/src/nitro/renderer.ts +0 -1471
- package/src/nitro/route-discovery.ts +0 -439
- package/src/nitro/types.ts +0 -321
- package/src/render/collect-css.ts +0 -198
- package/src/render/isolated-ssr-renderer.ts +0 -654
- package/src/render/ssr.ts +0 -1030
- package/src/schemas/api.ts +0 -30
- package/src/schemas/core.ts +0 -64
- package/src/schemas/index.ts +0 -212
- package/src/schemas/layout.ts +0 -279
- package/src/schemas/routing/index.ts +0 -38
- package/src/schemas/routing.ts +0 -376
- package/src/types/as-island.ts +0 -20
- package/src/types/layout.ts +0 -285
- package/src/types/routing.ts +0 -555
- package/src/types/types.ts +0 -5
- package/src/utils/dev-logger.ts +0 -299
- package/src/utils/fs.ts +0 -151
- package/src/vite-plugin/auto-discover.ts +0 -551
- package/src/vite-plugin/config.ts +0 -266
- package/src/vite-plugin/errors.ts +0 -127
- package/src/vite-plugin/image-optimization.ts +0 -156
- package/src/vite-plugin/integration-activator.ts +0 -126
- package/src/vite-plugin/island-sidecar-plugin.ts +0 -176
- package/src/vite-plugin/module-discovery.ts +0 -189
- package/src/vite-plugin/nitro-integration.ts +0 -1354
- package/src/vite-plugin/plugin.ts +0 -401
- package/src/vite-plugin/types.ts +0 -327
- package/src/vite-plugin/validation.ts +0 -228
package/README.md
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
# @useavalon/avalon
|
|
2
|
-
|
|
3
|
-
Core framework package for [Avalon](https://useavalon.dev) — a multi-framework islands architecture for the modern web.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- Islands architecture with zero JavaScript by default
|
|
8
|
-
- Multi-framework support (React, Preact, Vue, Svelte, Solid, Lit, Qwik)
|
|
9
|
-
- Selective hydration (`on:client`, `on:visible`, `on:idle`, `on:interaction`)
|
|
10
|
-
- File-system routing with nested layouts
|
|
11
|
-
- API routes and middleware
|
|
12
|
-
- MDX support with rehype/remark plugins
|
|
13
|
-
- SSR with streaming support
|
|
14
|
-
- Edge deployment via Nitro (Node, Deno, Bun, Cloudflare, Vercel, etc.)
|
|
15
|
-
- Vite 8 powered with HMR
|
|
16
|
-
|
|
17
|
-
## Quick start
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
npm create avalon@latest
|
|
21
|
-
# or
|
|
22
|
-
bun create avalon
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Or install manually:
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
bun add @useavalon/avalon
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Usage
|
|
32
|
-
|
|
33
|
-
```tsx
|
|
34
|
-
// pages/index.tsx
|
|
35
|
-
import Counter from '../components/Counter.tsx';
|
|
36
|
-
|
|
37
|
-
export default function Home() {
|
|
38
|
-
return (
|
|
39
|
-
<div>
|
|
40
|
-
<h1>Hello Avalon</h1>
|
|
41
|
-
<Counter island={{ condition: 'on:visible' }} />
|
|
42
|
-
</div>
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## Links
|
|
48
|
-
|
|
49
|
-
- [Documentation](https://useavalon.dev/docs/introduction)
|
|
50
|
-
- [GitHub](https://github.com/useAvalon/Avalon)
|
|
51
|
-
|
|
52
|
-
## License
|
|
53
|
-
|
|
54
|
-
MIT
|
|
1
|
+
# @useavalon/avalon
|
|
2
|
+
|
|
3
|
+
Core framework package for [Avalon](https://useavalon.dev) — a multi-framework islands architecture for the modern web.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Islands architecture with zero JavaScript by default
|
|
8
|
+
- Multi-framework support (React, Preact, Vue, Svelte, Solid, Lit, Qwik)
|
|
9
|
+
- Selective hydration (`on:client`, `on:visible`, `on:idle`, `on:interaction`)
|
|
10
|
+
- File-system routing with nested layouts
|
|
11
|
+
- API routes and middleware
|
|
12
|
+
- MDX support with rehype/remark plugins
|
|
13
|
+
- SSR with streaming support
|
|
14
|
+
- Edge deployment via Nitro (Node, Deno, Bun, Cloudflare, Vercel, etc.)
|
|
15
|
+
- Vite 8 powered with HMR
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm create avalon@latest
|
|
21
|
+
# or
|
|
22
|
+
bun create avalon
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Or install manually:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
bun add @useavalon/avalon
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
// pages/index.tsx
|
|
35
|
+
import Counter from '../components/Counter.tsx';
|
|
36
|
+
|
|
37
|
+
export default function Home() {
|
|
38
|
+
return (
|
|
39
|
+
<div>
|
|
40
|
+
<h1>Hello Avalon</h1>
|
|
41
|
+
<Counter island={{ condition: 'on:visible' }} />
|
|
42
|
+
</div>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Links
|
|
48
|
+
|
|
49
|
+
- [Documentation](https://useavalon.dev/docs/introduction)
|
|
50
|
+
- [GitHub](https://github.com/useAvalon/Avalon)
|
|
51
|
+
|
|
52
|
+
## License
|
|
53
|
+
|
|
54
|
+
MIT
|
package/dist/mod.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{avalon,getResolvedConfig,getPagesDir,getLayoutsDir,getNitroConfig,isNitroEnabled}from"./src/vite-plugin/plugin.js";export{createNitroIntegration,createNitroCoordinationPlugin,createVirtualModulesPlugin,getViteDevServer,getAvalonConfig,isDevelopmentMode,VIRTUAL_MODULE_IDS,RESOLVED_VIRTUAL_IDS}from"./src/vite-plugin/nitro-integration.js";export{renderToHtml}from"./src/render/ssr.js";export{default as Island,renderIsland}from"./src/islands/island.js";export{addSvelteSSRCSS,getSvelteSSRCSS,getSvelteSSRCSSForHead,getSvelteSSRCSSStats,getSvelteComponentCSS,clearSvelteComponentCSS,generateComponentScopeId}from"./src/islands/css-utils.js";export{detectFramework,detectFrameworkFromSrc,resolveIslandPath}from"./src/islands/framework-detection.js";export{analyzeComponentFile,renderComponentSSROnly}from"./src/islands/component-analysis.js";export{clearCache,clearIslandCache,invalidateCacheForPath,invalidateCacheForFile,getCacheStats,logCacheStats,configureCache,getCacheConfig}from"./src/islands/render-cache.js";export{discoverIslandDirectories,discoverIslandsInDirectory,discoverAllIslands,isIslandsDirectory,getDefaultIslandsPath,hasDefaultIslandsDirectory,getQualifiedIslandName,parseQualifiedIslandName,IslandRegistry,createIslandRegistry,IslandResolver,createIslandResolver,IslandValidator,createIslandValidator,validateAllIslands,formatValidationError,formatValidationWarning,formatCircularDependency,formatValidationResult,IslandWatcher,createIslandWatcher,ISLAND_FILE_EXTENSIONS,DEFAULT_DISCOVERY_CONFIG,isSupportedIslandExtension}from"./src/islands/discovery/index.js";export{loadIntegration,detectAndLoadIntegration,preloadIntegrations,detectFrameworksFromPageContent,DEFAULT_PRELOAD_FRAMEWORKS}from"./src/islands/integration-loader.js";export{registry as integrationRegistry}from"./src/core/integrations/registry.js";export{generateIslandManifest,loadIslandManifest,getIslandBundlePath}from"./src/build/island-manifest.js";export{mdxIslandTransform}from"./src/build/mdx-island-transform.js";export{pageIslandTransform}from"./src/build/page-island-transform.js";export{asIsland}from"./src/types/as-island.js";export{generateIslandTypes,watchAndGenerateTypes}from"./src/build/island-types-generator.js";export async function build(e){throw Error("avalon build() is not available in the published package. Use `vite build` or the Avalon CLI instead.")}export{discoverScopedMiddleware,executeScopedMiddleware,clearMiddlewareCache,invalidateMiddleware,getMatchingMiddleware,clearDiscoveryCache,hasContextValue,getContextValue,setContextValue,getMiddlewareCacheSize}from"./src/middleware/index.js";export*from"./src/layout-system.js";export{IslandPersistence,defaultIslandPersistence}from"./src/core/islands/island-persistence.js";export{IslandStateSerializer}from"./src/core/islands/island-state-serializer.js";export{createPersistentIslandContext,usePersistentIslandContext,PersistentIslandProvider}from"./src/core/islands/persistent-island-context.js";export{PersistentIsland}from"./src/components/PersistentIsland.js";export{usePersistentState}from"./src/core/islands/use-persistent-state.js";export{LayoutErrorBoundary}from"./src/components/LayoutErrorBoundary.js";export{LayoutDataErrorBoundary}from"./src/components/LayoutDataErrorBoundary.js";export{IslandErrorBoundary,withIslandErrorBoundary}from"./src/components/IslandErrorBoundary.js";export{StreamingErrorBoundary,withStreamingErrorBoundary}from"./src/components/StreamingErrorBoundary.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolve as e}from"node:path";import{getOptimizeDepsForIntegrations as t,getSSRNoExternalForIntegrations as n}from"./integration-config.js";export function integrationBundlerPlugin(t){let{integrations:n,ssr:r=!1}=t,i=process.cwd();return{name:`avalon:integration-bundler`,enforce:`post`,config(t){let a={};for(let t of n)r?a[`integrations/${t}/server`]=e(i,`packages/integrations/${t}/server/renderer.ts`):a[`integrations/${t}/client`]=e(i,`packages/integrations/${t}/client/index.ts`);let o=t.build?.rolldownOptions?.input||{};return{build:{rolldownOptions:{input:typeof o==`string`?{main:o,...a}:{...o,...a}}}}}}}export function getIntegrationExternals(e,t){let n=[];switch(e){case`preact`:if(!t)return[];n.push(`preact`,`preact/hooks`,`preact-render-to-string`);break;case`vue`:t&&n.push(`vue`,`vue/server-renderer`,`@vue/server-renderer`,`@vue/shared`);break;case`solid`:t&&n.push(`solid-js`,`solid-js/web`);break;case`svelte`:t&&n.push(`svelte`,`svelte/server`,`svelte/compiler`,`svelte/internal`);break}return n}export function getIntegrationOptimizeDeps(e){return t(e)}export function getIntegrationSSRNoExternal(e){return n(e)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const INTEGRATION_BUILD_CONFIGS={preact:{name:`preact`,extensions:[`.tsx`,`.jsx`],optimizeDeps:[`preact`,`preact/hooks`,`preact/jsx-runtime`,`preact/jsx-dev-runtime`],ssrExternal:[],ssrNoExternal:[`preact`,`preact-render-to-string`],requiresPlugin:!1},vue:{name:`vue`,extensions:[`.vue`],optimizeDeps:[`vue`],ssrExternal:[],ssrNoExternal:[`vue`,`@vue/server-renderer`,`@vue/shared`],requiresPlugin:!0,pluginPackage:`@vitejs/plugin-vue`},solid:{name:`solid`,extensions:[`.tsx`,`.jsx`],optimizeDeps:[`solid-js`,`solid-js/web`,`solid-js/store`],ssrExternal:[],ssrNoExternal:[`solid-js`,`solid-js/web`,`solid-js/store`],requiresPlugin:!0,pluginPackage:`vite-plugin-solid`},svelte:{name:`svelte`,extensions:[`.svelte`],optimizeDeps:[`svelte`,`svelte/internal`,`svelte/store`,`svelte/animate`,`svelte/easing`,`svelte/motion`,`svelte/transition`],ssrExternal:[],ssrNoExternal:[`svelte`,`svelte/server`,`svelte/internal`,`svelte/store`],requiresPlugin:!0,pluginPackage:`@sveltejs/vite-plugin-svelte`},react:{name:`react`,extensions:[`.jsx`,`.tsx`],optimizeDeps:[`react`,`react/jsx-runtime`,`react/jsx-dev-runtime`,`react-dom`,`react-dom/client`],ssrExternal:[],ssrNoExternal:[`react`,`react-dom`,`react-dom/server`],requiresPlugin:!0,pluginPackage:`@vitejs/plugin-react`},lit:{name:`lit`,extensions:[`.ts`,`.js`],optimizeDeps:[`lit`,`lit/decorators.js`,`lit/directives/class-map.js`,`lit/directives/style-map.js`,`@lit/reactive-element`],ssrExternal:[],ssrNoExternal:[`lit`,`@lit-labs/ssr`,`@lit/reactive-element`,`lit-html`],requiresPlugin:!1}};export function getIntegrationBuildConfig(t){return INTEGRATION_BUILD_CONFIGS[t]}export function getOptimizeDepsForIntegrations(t){let n=new Set;for(let r of t){let t=INTEGRATION_BUILD_CONFIGS[r];t&&t.optimizeDeps.forEach(e=>n.add(e))}return Array.from(n)}export function getSSRNoExternalForIntegrations(t){let n=new Set;for(let r of t){let t=INTEGRATION_BUILD_CONFIGS[r];t&&t.ssrNoExternal.forEach(e=>n.add(e))}return Array.from(n)}export function integrationRequiresPlugin(t){return INTEGRATION_BUILD_CONFIGS[t]?.requiresPlugin??!1}export function getIntegrationPluginPackage(t){return INTEGRATION_BUILD_CONFIGS[t]?.pluginPackage}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolve as e}from"node:path";import{readdir as t,readFile as n}from"node:fs/promises";export function integrationDetectionPlugin(){let t=null;return{name:`avalon:integration-detection`,enforce:`pre`,async buildStart(){t=await detectUsedIntegrations()},resolveId(n){if(n.startsWith(`@useavalon/integration-`)){let r=n.replace(`@useavalon/integration-`,``).split(`/`)[0];return t&&!t[r]&&console.warn(`⚠️ Integration ${r} is imported but not detected in project files`),e(process.cwd(),`packages/integrations/${r}/mod.ts`)}return null},transform(e,t){return t.includes(`/islands/`)||t.includes(`/components/`),null}}}export async function detectUsedIntegrations(){let r={preact:!1,vue:!1,solid:!1,svelte:!1},i=[`islands`,`components`,`src/islands`,`src/components`],a=process.cwd();for(let o of i)try{let i=e(a,o),s=await t(i,{withFileTypes:!0});for(let t of s)t.isFile()&&(t.name.endsWith(`.vue`)?r.vue=!0:t.name.endsWith(`.svelte`)?r.svelte=!0:(t.name.endsWith(`.tsx`)||t.name.endsWith(`.jsx`))&&((await n(e(i,t.name),`utf-8`)).includes(`solid-js`)?r.solid=!0:r.preact=!0))}catch{}return r}export function getRequiredIntegrations(e){let t=[];return e.preact&&t.push(`preact`),e.vue&&t.push(`vue`),e.solid&&t.push(`solid`),e.svelte&&t.push(`svelte`),t}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolve as e}from"node:path";export function integrationResolverPlugin(){let t=process.cwd();return{name:`avalon:integration-resolver`,enforce:`pre`,resolveId(n,r){if(n.startsWith(`@useavalon/integration-`)){let r=n.split(`/`),i=r[1].replace(`integration-`,``),a=r.slice(2).join(`/`);if(!a||a===``)return e(t,`packages/integrations/${i}/mod.ts`);if(a===`server`)return e(t,`packages/integrations/${i}/server/renderer.ts`);if(a===`client`)return e(t,`packages/integrations/${i}/client/index.ts`);if(a===`types`)return e(t,`packages/integrations/${i}/types.ts`)}return n===`@useavalon/shared`||n===`@useavalon/shared/types`?e(t,`packages/integrations/shared/types.ts`):r&&r.includes(`/integrations/`)&&n.startsWith(`../shared/`)?e(t,`packages/integrations/shared/${n.replace(`../shared/`,``)}`):null},load(e){return null}}}export function createIntegrationAliases(){let t=process.cwd();return{"@useavalon/integration-preact":e(t,`packages/integrations/preact/mod.ts`),"@useavalon/integration-preact/server":e(t,`packages/integrations/preact/server/renderer.ts`),"@useavalon/integration-preact/client":e(t,`packages/integrations/preact/client/index.ts`),"@useavalon/integration-vue":e(t,`packages/integrations/vue/mod.ts`),"@useavalon/integration-vue/server":e(t,`packages/integrations/vue/server/renderer.ts`),"@useavalon/integration-vue/client":e(t,`packages/integrations/vue/client/index.ts`),"@useavalon/integration-solid":e(t,`packages/integrations/solid/mod.ts`),"@useavalon/integration-solid/server":e(t,`packages/integrations/solid/server/renderer.ts`),"@useavalon/integration-solid/client":e(t,`packages/integrations/solid/client/index.ts`),"@useavalon/integration-svelte":e(t,`packages/integrations/svelte/mod.ts`),"@useavalon/integration-svelte/server":e(t,`packages/integrations/svelte/server/renderer.ts`),"@useavalon/integration-svelte/client":e(t,`packages/integrations/svelte/client/index.ts`),"@useavalon/integration-react":e(t,`packages/integrations/react/mod.ts`),"@useavalon/integration-react/server":e(t,`packages/integrations/react/server/renderer.ts`),"@useavalon/integration-react/client":e(t,`packages/integrations/react/client/index.ts`),"@useavalon/integration-react/types":e(t,`packages/integrations/react/types.ts`),"@useavalon/integration-lit":e(t,`packages/integrations/lit/mod.ts`),"@useavalon/integration-lit/server":e(t,`packages/integrations/lit/server/renderer.ts`),"@useavalon/integration-lit/client":e(t,`packages/integrations/lit/client/index.ts`),"@useavalon/integration-lit/types":e(t,`packages/integrations/lit/types.ts`),"@useavalon/shared":e(t,`packages/integrations/shared/types.ts`)}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readFile as e}from"node:fs/promises";import{getQualifiedIslandName as t,createIslandRegistry as n}from"../islands/discovery/index.js";export async function generateIslandManifest(){let r={},s=process.cwd();try{let c=await n(s),l=c.getAllIslands(),u=c.directories,d=c.collisions;for(let n of l){let s=t(n),c=`/${n.relativePath}`,l=await e(n.filePath,`utf-8`),u=i(n.framework),d=a(l),f=await o(l);r[s]={src:c,bundle:n.namespace===``?`/dist/islands/${n.name}.${f}.js`:`/dist/islands/${s}.${f}.js`,hash:f,framework:u,deps:d,namespace:n.namespace,qualifiedName:s,sourceDirectory:n.directory.relativePath}}return{islands:r,directories:u,collisions:d,version:`1.0.0`,buildTime:Date.now()}}catch(e){return console.warn(`Failed to generate island manifest:`,e),{islands:{},directories:[],collisions:[],version:`1.0.0`,buildTime:Date.now()}}}function i(e){switch(e){case`preact`:return`preact`;case`react`:return`react`;case`solid`:return`solid`;case`vue`:return`vue`;case`svelte`:return`svelte`;case`lit`:return`lit`;default:return`vanilla`}}function a(e){let t=[],n=/import\s+.*?\s+from\s+['"]([^'"]+)['"]/g,r;for(;(r=n.exec(e))!==null;){let e=r[1];!e.startsWith(`.`)&&!e.startsWith(`/`)&&t.push(e)}return[...new Set(t)]}async function o(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest(`SHA-256`,t);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,`0`)).join(``).slice(0,8)}export async function loadIslandManifest(){try{let t=await e(`dist/island-manifest.json`,`utf-8`);return JSON.parse(t)}catch(e){return console.warn(`Failed to load island manifest:`,e),null}}export function getIslandBundlePath(e,t){let n=process.env.NODE_ENV!==`production`;if(t){let n=l(e),r=t;if(r.islands[n])return r.islands[n].bundle;let i=e.replace(/^\/islands\//,``).replace(/\.(tsx?|jsx?|vue|svelte)$/,``),a=t.islands[i];if(a)return a.bundle}return n?e.startsWith(`/islands/`)?e.replaceAll(`/islands/`,`/src/islands/`):e.startsWith(`/src/`)||e.startsWith(`/app/`)||e.startsWith(`/`)?e:`/src/${e}`:`/dist/islands/${l(e)}.js`}function l(e){let t=e.replace(/^\//,``);t=t.replace(/\.(tsx?|jsx?|vue|svelte)$/,``),t=t.replace(/\.(solid|react|lit|preact)$/,``);let n=new RegExp(/^src\/(.+)\/islands\/([^/]+)$/).exec(t);if(n){let[,e,t]=n;return`${e}/${t}`}let r=new RegExp(/^(?:src\/)?islands\/([^/]+)$/).exec(t);return r?r[1]:t}export function getIslandEntry(e,t){if(t.islands[e])return t.islands[e];if(t.directories){for(let[n,r]of Object.entries(t.islands))if(n.split(`/`).pop()===e)return r}return null}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{resolve as e,dirname as t,relative as n}from"node:path";import{writeFile as r,mkdir as i}from"node:fs/promises";import{createIslandRegistry as a,getQualifiedIslandName as o}from"../islands/discovery/index.js";const s={outputDir:`src/types`,mode:`single`,moduleName:`avalon-islands`,includeJsDoc:!0};export async function generateIslandTypes(n,i={}){let o={...s,...i},c={success:!0,files:[],islandCount:0,errors:[]};try{let i=await a(n),s=i.getAllIslands(),d=i.directories,f=i.collisions;if(c.islandCount=s.length,s.length===0)return c;if(o.mode===`single`){let i=l(s,d,f,o),a=e(n,o.outputDir,`islands.d.ts`);await v(t(a)),await r(a,i),c.files.push(a)}else{let e=await u(s,d,n,o);c.files.push(...e)}}catch(e){c.success=!1,c.errors.push(e instanceof Error?e.message:String(e))}return c}function l(e,t,n,r){let i=[];i.push(`/**`),i.push(` * Auto-generated TypeScript declarations for Avalon islands.`),i.push(` * Do not edit this file manually - it will be overwritten.`),i.push(` * Generated at: ${new Date().toISOString()}`),i.push(` */`),i.push(``),i.push(`declare module "${r.moduleName}" {`),i.push(``),r.includeJsDoc&&(i.push(` /**`),i.push(` * Discovered island directories`),i.push(` */`)),i.push(` export const islandDirectories: readonly string[];`),i.push(``);let a=g(e);for(let[e,t]of a){if(e===``){i.push(` // Default islands (src/islands/)`);for(let e of t)i.push(...p(e,r,` `))}else{let n=e.split(`/`).map(e=>_(e)).join(``);i.push(` // Islands from ${e}/islands/`),i.push(` export namespace ${n} {`);for(let e of t)i.push(...p(e,r,` `));i.push(` }`)}i.push(``)}i.push(` /**`),i.push(` * Map of all island qualified names to their component types`),i.push(` */`),i.push(` export interface IslandMap {`);for(let t of e){let e=o(t);i.push(` "${e}": typeof ${m(t)};`)}if(i.push(` }`),i.push(``),n.length>0){i.push(` /**`),i.push(` * Warning: The following island names have collisions.`),i.push(` * Use qualified names (namespace/name) to disambiguate.`),i.push(` */`),i.push(` export type CollidingIslandNames =`);let e=n.map(e=>` | "${e.name}"`);i.push(e.join(`
|
|
2
|
+
`)+`;`),i.push(``)}i.push(` /**`),i.push(` * Get the component type for an island by name or qualified name`),i.push(` */`),i.push(` export type GetIsland<K extends keyof IslandMap> = IslandMap[K];`),i.push(``),i.push(`}`),i.push(``),i.push(`// Augment the Island component props with discovered islands`),i.push(`declare global {`),i.push(` namespace Avalon {`),i.push(` interface DiscoveredIslands {`);for(let t of e){let e=o(t);i.push(` "${e}": true;`)}return i.push(` }`),i.push(` }`),i.push(`}`),i.push(``),i.join(`
|
|
3
|
+
`)}async function u(n,i,a,o){let s=[],c=new Map;for(let e of n){let t=e.directory.path,n=c.get(t)||[];n.push(e),c.set(t,n)}for(let n of i){let i=c.get(n.path)||[];if(i.length===0)continue;let l=d(n,i,o),u=e(a,n.path,`islands.d.ts`);await v(t(u)),await r(u,l),s.push(u)}let l=f(i,a,o),u=e(a,o.outputDir,`islands.d.ts`);return await v(t(u)),await r(u,l),s.push(u),s}function d(e,t,n){let r=[];r.push(`/**`),r.push(` * Auto-generated TypeScript declarations for islands in ${e.relativePath}`),r.push(` * Do not edit this file manually - it will be overwritten.`),r.push(` */`),r.push(``);for(let e of t)r.push(...p(e,n,``));return r.join(`
|
|
4
|
+
`)}function f(t,r,i){let a=[];a.push(`/**`),a.push(` * Auto-generated index for all island type declarations.`),a.push(` * Do not edit this file manually - it will be overwritten.`),a.push(` */`),a.push(``);for(let o of t){let t=n(e(r,i.outputDir),e(r,o.path,`islands.d.ts`)).replace(/\\/g,`/`).replace(/\.d\.ts$/,``);a.push(`export * from "${t}";`)}return a.join(`
|
|
5
|
+
`)}function p(e,t,n){let r=[],i=m(e);t.includeJsDoc&&(r.push(`${n}/**`),r.push(`${n} * Island component: ${e.name}`),r.push(`${n} * Framework: ${e.framework}`),r.push(`${n} * Source: ${e.relativePath}`),e.namespace&&r.push(`${n} * Namespace: ${e.namespace}`),r.push(`${n} */`));let a=h(e.framework);return r.push(`${n}export const ${i}: ${a};`),r}function m(e){return e.name}function h(e){switch(e){case`preact`:return`import('preact').FunctionComponent<any>`;case`react`:return`import('react').FC<any>`;case`vue`:return`import('vue').DefineComponent<any, any, any>`;case`svelte`:return`import('svelte').SvelteComponent`;case`solid`:return`import('solid-js').Component<any>`;case`lit`:return`typeof import('lit').LitElement`;default:return`unknown`}}function g(e){let t=new Map;for(let n of e){let e=t.get(n.namespace)||[];e.push(n),t.set(n.namespace,e)}let n=new Map,r=Array.from(t.keys()).sort((e,t)=>e===``?-1:t===``?1:e.localeCompare(t));for(let e of r)n.set(e,t.get(e));return n}function _(e){return e.split(/[-_\s]+/).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``)}async function v(e){try{await i(e,{recursive:!0})}catch(e){if(!(e instanceof Error)||e.code!==`EEXIST`)throw e}}export async function watchAndGenerateTypes(e,t={}){let{createIslandWatcher:n,createIslandRegistry:r}=await import(`../islands/discovery/index.js`),i=await r(e),a=n(e,i);await generateIslandTypes(e,t);let o=await a.watch(async n=>{await i.rebuild();let r=await generateIslandTypes(e,t);r.success||console.error(`❌ Failed to regenerate types:`,r.errors)});return()=>{o(),a.stop()}}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{dirname as e}from"node:path";const t=[/['"]\.\.\/islands\//,/['"]\.\/islands\//,/['"]\.\.\/\.\.\/islands\//,/['"]\$islands\//,/['"]@\/islands\//,/['"]\/src\/islands\//];function n(e){let t=new Map,n=/import\s+([A-Z]\w*)\s+from\s+(['"][^'"]+['"])/g,r;for(;(r=n.exec(e))!==null;){let e=r[1],n=r[2].slice(1,-1);t.set(e,n)}return t}function r(e){let t=new Set,n=/<([A-Z]\w*)\s+[^>]*\bisland\s*[={]/g,r;for(;(r=n.exec(e))!==null;)t.add(r[1]);let i=/(?:_?jsxs?(?:DEV)?)\s*\(\s*([A-Z]\w*)\s*,\s*\{[^}]*\bisland\s*:/g;for(;(r=i.exec(e))!==null;)t.add(r[1]);return t}function i(e,t){let i=[],a=n(e),o=r(e);for(let[e,n]of a){let r=`"${n}"`,a=t.some(e=>e.test(r)),s=o.has(e);(a||s)&&i.push({localName:e,importPath:n,islandPropUsage:s})}return i}function a(t,n){if(t.startsWith(`/src/`)||t.startsWith(`/app/`)||t.startsWith(`/`))return t;if(t.startsWith(`@/`))return`/app/`+t.slice(2);if(t.startsWith(`@shared/`))return`/app/shared/`+t.slice(8);if(t.startsWith(`@modules/`))return`/app/modules/`+t.slice(9);if(t.startsWith(`$components/`))return`/src/components/`+t.slice(12);if(t.startsWith(`$islands/`))return`/src/islands/`+t.slice(9);if(t.startsWith(`~/`))return`/src/`+t.slice(2);if(t.startsWith(`.`)){let r=n.replaceAll(`\\`,`/`),i=r.indexOf(`/app/`);if(i===-1&&(i=r.indexOf(`/src/`)),i!==-1){let n=e(r.slice(i)).split(`/`),a=t.split(`/`);for(let e of a)e===`..`?n.pop():e!==`.`&&n.push(e);return n.join(`/`)}}return t.includes(`/islands/`)?`/src/islands/`+t.split(`/`).at(-1):`/src/`+t.split(`/`).pop()}function o(e){if(e.endsWith(`.vue`))return`vue`;if(e.endsWith(`.svelte`))return`svelte`;if(e.includes(`.solid.`))return`solid`;if(e.includes(`.lit.`))return`lit`;if(e.includes(`.qwik.`))return`qwik`;if(e.endsWith(`.tsx`)||e.endsWith(`.jsx`))return`preact`}function s(e,t){let n=t+1,r=1;for(;n<e.length&&r>0;){let t=e[n];t===`{`?(r++,n++):t===`}`?(r--,r>0&&n++):t===`'`||t===`"`||t==="`"?n=c(e,n):n++}return n<e.length?n+1:n}function c(e,t){let n=e[t];for(t++;t<e.length&&e[t]!==n;)e[t]===`\\`&&t++,t++;return t<e.length?t+1:t}function l(e,t){let n=t,r=0;for(;n<e.length&&e[n]!==`(`;)n++;if(n>=e.length)return t;for(;n<e.length;){let t=e[n];if(t===`(`)r++,n++;else if(t===`)`){if(r--,n++,r===0)return n}else t===`{`?n=s(e,n):t===`'`||t===`"`||t==="`"?n=c(e,n):n++}return n}function u(e){let t=e.match(/\bisland\s*:\s*/);if(!t)return null;let n=t.index+t[0].length,r;if(e[n]===`{`)r=s(e,n);else{let t=n,i=0;for(;t<e.length;){let n=e[t];if(n===`{`||n===`[`||n===`(`)i++,t++;else if(n===`}`||n===`]`||n===`)`){if(i===0)break;i--,t++}else if(n===`,`&&i===0)break;else t++}r=t}let i=e.slice(n,r).trim(),a=e.slice(0,t.index).trim(),o=e.slice(r).trim(),c=a;return o.startsWith(`,`)?c+=o.slice(1):c+=o,c=c.replace(/,\s*}$/,`}`).replace(/{\s*,/,`{`),{islandValue:i,otherProps:c}}function d(e,t,n,r){let i=RegExp(`(_?jsxs?(?:DEV)?)\\s*\\(\\s*`+t+`\\s*,`,`g`),a=``,o=0,c;for(;(c=i.exec(e))!==null;){let t=c.index;c[1];let i=l(e,t),d=e.slice(t,i);if(!d.includes(`island`)){a+=e.slice(o,i),o=i;continue}let f=d.indexOf(`{`);if(f===-1){a+=e.slice(o,i),o=i;continue}let p=s(d,f),m=u(d.slice(f,p));if(!m){a+=e.slice(o,i),o=i;continue}let{islandValue:h,otherProps:g}=m,_=`(await __AvalonRenderIsland({ src: "${n}", ${r?`framework: "${r}",`:``} ...(${h}), ${g.trim()!==`{}`&&g.trim()!==``?`props: ${g},`:``} ssr: (${h}).ssr !== undefined ? (${h}).ssr : true }))`;a+=e.slice(o,t)+_,o=i}return a+=e.slice(o),a}export function mdxIslandTransform(e={}){let{islandPathPatterns:n=t,verbose:r=!1}=e;return{name:`avalon:mdx-island-transform`,enforce:`post`,transform(e,t){if(!t.endsWith(`.mdx`)&&!t.includes(`.mdx?`))return null;let s=i(e,n);if(s.length===0)return null;if(r){console.log(`[mdx-island-transform] Found `+s.length+` island import(s) in `+t);for(let e of s)console.log(` - `+e.localName+` from `+e.importPath+(e.islandPropUsage?` (island prop)`:` (islands dir)`))}let c=e;if(!(c.includes(`from "@useavalon/avalon"`)||c.includes(`from '@useavalon/avalon'`))){let e=/^(import\s.+?from\s+.+?\n)/m.exec(c);if(e){let t=c.indexOf(e[0])+e[0].length;c=c.slice(0,t)+`import { renderIsland as __AvalonRenderIsland } from "@useavalon/avalon";
|
|
2
|
+
`+c.slice(t)}}for(let e of s){let n=a(e.importPath,t),r=o(n);c=d(c,e.localName,n,r)}for(let e of s){let t=RegExp(`import\\s+${e.localName}\\s+from\\s+(['"][^'"]+['"])`,`g`);c=c.replace(t,`import $1; // [mdx-island-transform] kept for CSS: ${e.localName}`)}return c=c.replace(/function\s+_createMdxContent\s*\(/g,`async function _createMdxContent(`),c=c.replace(/export\s+default\s+function\s+MDXContent\s*\(/g,`export default async function MDXContent(`),r&&console.log(`[mdx-island-transform] Transformed `+t),{code:c,map:null}}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export async function createMDXPlugin(e={}){let{remarkPlugins:t=[],rehypePlugins:n=[],development:r=!1,jsxImportSource:i=`preact`,syntaxHighlighting:a=!0}=e;try{let{default:e}=await import(`@mdx-js/rollup`),{default:o}=await import(`remark-frontmatter`),{default:s}=await import(`remark-mdx-frontmatter`),{default:c}=await import(`remark-gfm`),l=[];if(a)try{let{default:e}=await import(`rehype-highlight`);l.push(e)}catch{console.warn(`[avalon:mdx] rehype-highlight not available, syntax highlighting disabled`)}return l.push(...n),[e({remarkPlugins:[o,s,c,...t],rehypePlugins:l,jsxImportSource:i,development:r,format:`mdx`})]}catch(e){let t=e instanceof Error?e.message:String(e);return console.error(`❌ Failed to configure MDX plugin:`,t),console.warn(`💡 Install missing dependencies or check import map`),console.warn(`⚠️ MDX plugin disabled - .mdx files will not be processed`),[]}}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{dirname as e}from"node:path";function t(e){let t=[],n=/^[ \t]*import\s+([A-Z]\w*)\s+from\s+(['"][^'"]+['"])/gm,r;for(;(r=n.exec(e))!==null;)t.push({localName:r[1],importPath:r[2].slice(1,-1),fullMatch:r[0].trimStart()});return t}function n(t,n){if(t.startsWith(`/src/`)||t.startsWith(`/app/`)||t.startsWith(`/`))return t;if(t.startsWith(`@/`))return`/app/`+t.slice(2);if(t.startsWith(`@shared/`))return`/app/shared/`+t.slice(8);if(t.startsWith(`@modules/`))return`/app/modules/`+t.slice(9);if(t.startsWith(`$components/`))return`/src/components/`+t.slice(12);if(t.startsWith(`$islands/`))return`/src/islands/`+t.slice(9);if(t.startsWith(`~/`))return`/src/`+t.slice(2);if(t.startsWith(`.`)){let r=n.replaceAll(`\\`,`/`),i=r.indexOf(`/app/`);if(i===-1&&(i=r.indexOf(`/src/`)),i!==-1){let n=e(r.slice(i)).split(`/`),a=t.split(`/`);for(let e of a)e===`..`?n.pop():e!==`.`&&n.push(e);return n.join(`/`)}}return`/src/`+t.split(`/`).pop()}function r(e){if(e.endsWith(`.vue`))return`vue`;if(e.endsWith(`.svelte`))return`svelte`;if(e.includes(`.solid.`))return`solid`;if(e.includes(`.lit.`))return`lit`;if(e.includes(`.qwik.`))return`qwik`}function i(e,t,n){let r=e.replaceAll(`\\`,`/`),i=t.replace(/^\//,``);if(r.includes(`/`+i+`/`)&&/\.(tsx|jsx)$/.test(r))return!0;if(n){let e=n.dir.replace(/^\//,``);if(RegExp(`/`+e+`/[^/]+/`+n.pagesDirName+`/`).test(r)&&/\.(tsx|jsx)$/.test(r))return!0}return!1}function a(e,t,n){let r=e.replaceAll(`\\`,`/`),i=t.replace(/^\//,``);if(r.includes(`/`+i+`/`)&&/\.(tsx|jsx)$/.test(r))return!0;if(n){let e=n.dir.replace(/^\//,``);if(RegExp(`/`+e+`/[^/]+/`+n.layoutsDirName+`/`).test(r)&&/\.(tsx|jsx)$/.test(r))return!0}return!1}const o=new Set([`qwik`]);function s(e){let t=r(e);return t!==void 0&&o.has(t)}function c(e,t){return t.some(t=>RegExp(`<`+t+String.raw`[\s][^>]*island[\s]*[={]`).test(e))}function l(e,t){return t.some(t=>s(t.importPath)?RegExp(`<`+t.localName+String.raw`[\s/>]`).test(e):!1)}function u(e,t,i){let a=new Map;for(let s of t){let t=n(s.importPath,i),c=r(t);if(RegExp(`<`+s.localName+String.raw`[\s][^>]*island[\s]*[={]`).test(e)){a.set(s.localName,{srcPath:t,framework:c,importPath:s.importPath,autoIsland:!1});continue}c&&o.has(c)&&RegExp(`<`+s.localName+String.raw`[\s/>]`).test(e)&&a.set(s.localName,{srcPath:t,framework:c,importPath:s.importPath,autoIsland:!0})}return a}function d(e,t){for(;t<e.length&&/\s/.test(e[t]);)t++;return t}function f(e,t){let n=e[t];for(t++;t<e.length&&e[t]!==n;)e[t]===`\\`&&t++,t++;return t<e.length?t+1:t}function p(e,t){for(t++;t<e.length&&e[t]!=="`";){if(e[t]===`\\`){t+=2;continue}if(e[t]===`$`&&e[t+1]===`{`){t=m(t+1,e);continue}t++}return t<e.length?t+1:t}function m(e,t){let n=e+1,r=1;for(;n<t.length&&r>0;){let e=t[n];e===`{`?(r++,n++):e===`}`?(r--,r>0&&n++):e===`'`||e===`"`||e==="`"?n=f(t,n):n++}return n<t.length?n+1:n}function h(e,t){let n=t+1,r=m(t,e);return{value:e.slice(n,r-1),endIdx:r}}function g(e,t){let n=e[t],r=t+1;for(;r<e.length&&e[r]!==n;)e[r]===`\\`&&r++,r++;return{value:`"`+e.slice(t+1,r)+`"`,endIdx:r+1}}function _(e,t){let n=t,r=t;for(;r<e.length&&/[a-zA-Z0-9_$]/.test(e[r]);)r++;let i=e.slice(n,r);if(!i)return null;if(r=d(e,r),e[r]!==`=`)return{name:i,value:null,endIdx:r};if(r=d(e,r+1),e[r]===`{`){let t=h(e,r);return{name:i,value:t.value,endIdx:t.endIdx}}if(e[r]===`"`||e[r]===`'`){let t=g(e,r);return{name:i,value:t.value,endIdx:t.endIdx}}return null}function v(e,t,n){if(e[t]===`/`&&e[t+1]===`>`)return{endIdx:t+2,selfClosing:!0};if(e[t]===`>`){let r=`</`+n+`>`,i=e.indexOf(r,t+1);return i===-1?null:{endIdx:i+r.length,selfClosing:!1}}return null}function y(e,t,n){let r=d(e,t+1+n.length),i=null,a=[];for(;r<e.length;){r=d(e,r);let t=v(e,r,n);if(t)return{endIdx:t.endIdx,islandProp:i,otherProps:a};let o=_(e,r);if(!o)return null;if(r=o.endIdx,o.name===`island`)i=o.value??`{}`;else{let e=o.value===null?o.name+`: true`:o.name+`: `+o.value;a.push(e)}}return null}function b(e,t,n,r){let i=n?`, framework: "`+n+`"`:``,a=e.otherProps.length>0?`, props: { `+e.otherProps.join(`, `)+` }`:``;if(r)return`{await __pageRenderIsland({ src: "`+t+`"`+i+a+`, ssr: true, ssrOnly: true })}`;let o=e.islandProp,s=n===`qwik`?`, ssrOnly: true`:``;return`{await __pageRenderIsland({ src: "`+t+`"`+i+`, ...(`+o+`)`+a+s+`, ssr: (`+o+`).ssr !== undefined ? (`+o+`).ssr : true })}`}function x(e,t,n){if(!e.startsWith(n,t))return!1;let r=t+n.length;return r>=e.length||!/[a-zA-Z0-9_$]/.test(e[r])}function S(e,t,n,r,i){let a=`<`+t,o=``,s=0;for(;s<e.length;){if(e[s]==="`"){let t=s;s=p(e,s),o+=e.slice(t,s);continue}if(e[s]===`{`&&e[s+1]===`/`&&e[s+2]===`*`){let t=e.indexOf(`*/`,s+3);if(t!==-1){let n=t+2;for(;n<e.length&&/\s/.test(e[n]);)n++;if(n<e.length&&e[n]===`}`){o+=e.slice(s,n+1),s=n+1;continue}}}if(e[s]===`/`&&e[s+1]===`/`){let t=e.indexOf(`
|
|
2
|
+
`,s),n=t===-1?e.length:t+1;o+=e.slice(s,n),s=n;continue}if(e[s]===`/`&&e[s+1]===`*`){let t=e.indexOf(`*/`,s+2),n=t===-1?e.length:t+2;o+=e.slice(s,n),s=n;continue}if(!x(e,s,a)){o+=e[s],s++;continue}let c=y(e,s,t);if(!c||!c.islandProp&&!i){let t=c?c.endIdx:s+1;o+=e.slice(s,t),s=t;continue}o+=b(c,n,r,i&&!c.islandProp),s=c.endIdx}return o}export function pageIslandTransform(e={}){let{pagesDir:n=`src/pages`,layoutsDir:r=`src/layouts`,modules:o=null}=e;return{name:`avalon:page-island-transform`,enforce:`pre`,transform(e,s){let d=a(s,r,o);if(!i(s,n,o)&&!d)return null;let f=t(e);if(f.length===0||!c(e,f.map(e=>e.localName))&&!l(e,f))return null;let p=u(e,f,s);if(p.size===0)return null;let m=`import { renderIsland as __pageRenderIsland } from '@useavalon/avalon';
|
|
3
|
+
`+e;for(let[e,t]of p)m=S(m,e,t.srcPath,t.framework,t.autoIsland);for(let e of f)p.has(e.localName)&&(m=d?m.replace(e.fullMatch,`import '`+e.importPath+`'; // [page-island-transform] kept for CSS graph: `+e.localName):m.replace(e.fullMatch,`// [page-island-transform] removed: `+e.localName));return{code:m,map:null}}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{FALLBACK_PROPS,extractVueProps}from"./vue.js";export{extractSvelteProps}from"./svelte.js";export{extractLitProps}from"./lit.js";export{extractSolidProps}from"./solid.js";export{extractQwikProps}from"./qwik.js";import{extractVueProps as e}from"./vue.js";import{extractSvelteProps as t}from"./svelte.js";import{extractLitProps as n}from"./lit.js";import{extractSolidProps as r}from"./solid.js";import{extractQwikProps as i}from"./qwik.js";export const EXTRACTOR_MAP={vue:e,svelte:t,lit:n,solid:r,qwik:i};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{FALLBACK_PROPS as e}from"./vue.js";const t={String:`string`,Number:`number`,Boolean:`boolean`,Array:`unknown[]`,Object:`Record<string, unknown>`};export function extractLitProps(t){try{let n=r(t);if(n===null)return{propsType:e,fallback:!0};let a=i(n);return a.length===0?{propsType:e,fallback:!0}:{propsType:`{ `+a.map(e=>e.name+`?: `+e.tsType).join(`; `)+` }`,fallback:!1}}catch{return console.warn(`[avalon] Failed to extract Lit props — falling back to Record<string, unknown>`),{propsType:e,fallback:!0}}}function r(e){let t=/static\s+properties\s*=\s*\{/.exec(e);if(!t)return null;let n=t.index+t[0].length-1,r=1,i=n+1;for(;i<e.length&&r>0;)e[i]===`{`?r++:e[i]===`}`&&r--,i++;return r===0?e.slice(n+1,i-1):null}function i(e){let n=[],r=/(\w+)\s*:\s*\{/g,i;for(;(i=r.exec(e))!==null;){let o=i[1],s=i.index+i[0].length-1,c=a(e,s);if(c===null||/\bstate\s*:\s*true\b/.test(c))continue;let l=new RegExp(/\btype\s*:\s*(\w+)/).exec(c),u=l?l[1]:null,d=u&&u in t?t[u]:`unknown`;n.push({name:o,tsType:d}),r.lastIndex=s+c.length}return n}function a(e,t){if(e[t]!==`{`)return null;let n=0,r=t;for(;r<e.length;){if(e[r]===`{`?n++:e[r]===`}`&&n--,n===0)return e.slice(t+1,r);r++}return null}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{FALLBACK_PROPS as e}from"./vue.js";export function extractQwikProps(t){return{propsType:e,fallback:!1}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{FALLBACK_PROPS as e}from"./vue.js";export function extractSolidProps(t){try{let i=n(t);if(i!==null)return{propsType:i,fallback:!1};let a=r(t);return a===null?{propsType:e,fallback:!0}:{propsType:a,fallback:!1}}catch{return console.warn(`[avalon] Failed to extract Solid props — falling back to Record<string, unknown>`),{propsType:e,fallback:!0}}}function n(e){let t=/export\s+default\s+function\s+\w+\s*\(\s*props\s*:\s*/.exec(e);return t?i(e,t.index+t[0].length):null}function r(e){let t=/export\s+default\s+\(\s*props\s*:\s*/.exec(e);return t?i(e,t.index+t[0].length):null}function i(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;if(n>=e.length)return null;if(e[n]===`{`)return a(e,n);let r=e.slice(n),i=new RegExp(/^([A-Za-z_$][\w$]*(?:<[^>]*>)?)/).exec(r);return i?i[1].trim():null}function a(e,t){if(e[t]!==`{`)return null;let n=0,r=t;for(;r<e.length;){if(e[r]===`{`)n++;else if(e[r]===`}`&&(n--,n===0))return e.slice(t,r+1).trim();r++}return null}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{FALLBACK_PROPS as e}from"./vue.js";export function extractSvelteProps(t){try{let i=n(t);if(i===null)return{propsType:e,fallback:!0};let a=r(i);if(a!==null)return{propsType:a,fallback:!1};let s=o(i);return s===null?{propsType:e,fallback:!0}:{propsType:s,fallback:!1}}catch{return console.warn(`[avalon] Failed to extract Svelte props — falling back to Record<string, unknown>`),{propsType:e,fallback:!0}}}function n(e){let t=new RegExp(/<script\b[^>]*>([\s\S]*?)<\/script>/i).exec(e);return t?t[1]:null}function r(e){let t=new RegExp(/let\s+(?:\{[^}]*\}|\w+)\s*:\s*([\s\S]*?)\s*=\s*\$props\s*\(\s*\)/).exec(e);if(!t)return null;let n=t[1].trim();return n.length===0?null:n.startsWith(`{`)?s(n)?n:(console.warn(`[avalon] Unbalanced braces in Svelte $props() type — falling back`),null):i(e,n)}function i(e,t){let n=new RegExp(String.raw`interface\s+${c(t)}\s*\{`).exec(e);if(n){let t=a(e,n.index+n[0].length-1);if(t!==null)return t}let r=new RegExp(String.raw`type\s+${c(t)}\s*=\s*\{`).exec(e);if(r){let t=a(e,r.index+r[0].length-1);if(t!==null)return t}return null}function a(e,t){if(e[t]!==`{`)return null;let n=0,r=t;for(;r<e.length;){if(e[r]===`{`)n++;else if(e[r]===`}`&&(n--,n===0))return e.slice(t,r+1).trim();r++}return null}function o(e){let t=/export\s+let\s+(\w+)\s*:\s*([^;=]+)/g,n=[],r;for(;(r=t.exec(e))!==null;){let e=r[1].trim(),t=r[2].trim();e&&t&&n.push(`${e}: ${t}`)}return n.length===0?null:`{ ${n.join(`; `)} }`}function s(e){let t=0;for(let n of e)if(n===`{`?t++:n===`}`&&t--,t<0)return!1;return t===0}function c(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const FALLBACK_PROPS=`Record<string, unknown>`;export function extractVueProps(t){try{let r=n(t);if(r===null)return{propsType:FALLBACK_PROPS,fallback:!0};let a=i(r);return a===null?{propsType:FALLBACK_PROPS,fallback:!0}:{propsType:a,fallback:!1}}catch{return console.warn(`[avalon] Failed to extract Vue props — falling back to Record<string, unknown>`),{propsType:FALLBACK_PROPS,fallback:!0}}}function n(e){let t=new RegExp(/<script\b[^>]*\bsetup\b[^>]*>([\s\S]*?)<\/script>/i).exec(e);return t?t[1]:null}function r(e){let t=0;for(let n of e)if(n===`{`?t++:n===`}`&&t--,t<0)return!1;return t===0}function i(e){let t=e.indexOf(`defineProps<`);if(t===-1)return null;let n=t+12,i=1,a=n;for(;a<e.length&&i>0;){let t=e[a];t===`<`?i++:t===`>`&&i--,i>0&&a++}if(i!==0)return console.warn(`[avalon] Unbalanced angle brackets in defineProps<...> — falling back`),null;let o=e.slice(n,a).trim();return o.length===0?null:r(o)?o:(console.warn(`[avalon] Unbalanced braces in defineProps type — falling back`),null)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"node:path";import{readFile as t,writeFile as n,unlink as r,stat as i}from"node:fs/promises";const a=[`.solid.tsx`,`.qwik.tsx`,`.lit.ts`,`.svelte`,`.vue`],o=new Set([`.lit.ts`,`.solid.tsx`,`.qwik.tsx`]);export function getSidecarPath(t){let n=e.dirname(t),r=e.basename(t);for(let t of a)if(r.endsWith(t)){let i=r.slice(0,-t.length);if(o.has(t)){let r=t.endsWith(`.ts`)?t.slice(0,-3):t.slice(0,-4);return e.join(n,`${i}${r}.d.ts`)}return e.join(n,`${i}.d${t}.ts`)}let i=e.extname(t),s=r.slice(0,-i.length);return e.join(n,`${s}.d${i}.ts`)}export async function isSidecarFresh(e,t){try{let[n,r]=await Promise.all([i(e),i(t)]);return r.mtimeMs>=n.mtimeMs}catch{return!1}}export async function writeSidecarIfChanged(e,r){try{if(await t(e,`utf-8`)===r)return!1}catch{}return await n(e,r,`utf-8`),!0}export async function deleteSidecar(e){try{return await r(e),!0}catch{return!1}}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const SIDECAR_HEADER=`// Auto-generated by avalon — do not edit`;export function renderSidecarContent(e){return`// Auto-generated by avalon — do not edit
|
|
2
|
+
import type { ComponentType } from 'preact';
|
|
3
|
+
import type { IslandDirective } from '@useavalon/avalon';
|
|
4
|
+
declare const component: ComponentType<${e} & { island?: IslandDirective }>;
|
|
5
|
+
export default component;
|
|
6
|
+
`}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{BaseFrameworkAdapter,AdapterRegistry}from"../framework-adapter.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{PersistentIsland}from"../components/PersistentIsland.js";export{usePersistentIslandContext,PersistentIslandProvider,createPersistentIslandContext}from"../core/islands/persistent-island-context.js";export{usePersistentState}from"../core/islands/use-persistent-state.js";export{IslandPersistence,defaultIslandPersistence}from"../core/islands/island-persistence.js";export{IslandStateSerializer}from"../core/islands/island-state-serializer.js";export{IslandErrorBoundary,withIslandErrorBoundary}from"../components/IslandErrorBoundary.js";export{LayoutErrorBoundary}from"../components/LayoutErrorBoundary.js";export{LayoutDataErrorBoundary}from"../components/LayoutDataErrorBoundary.js";export{StreamingErrorBoundary,withStreamingErrorBoundary}from"../components/StreamingErrorBoundary.js";export{StreamingLayout,StreamingSuspense,withStreaming,useStreamingState}from"../components/StreamingLayout.js";export{Image}from"../components/Image.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export class CSSHMRHandler{cssModuleMap=new Map;styleElementMap=new Map;handleCSSUpdate(e){let t=this.classifyCSSUpdate(e);switch(t.type){case`global`:this.handleGlobalCSSUpdate(t);break;case`module`:this.handleCSSModuleUpdate(t);break;case`scoped`:this.handleScopedCSSUpdate(t);break}}classifyCSSUpdate(e){let t=e.path||e.acceptedPath;return t.includes(`.module.css`)||t.includes(`.module.scss`)?{type:`module`,path:t,timestamp:e.timestamp}:t.includes(`.svelte`)||t.includes(`.vue`)?{type:`scoped`,path:t,timestamp:e.timestamp}:{type:`global`,path:t,timestamp:e.timestamp}}handleGlobalCSSUpdate(e){try{let t=this.styleElementMap.get(e.path);t&&(t.remove(),this.styleElementMap.delete(e.path));let n=document.querySelector(`style[data-vite-dev-id*="${this.getFileId(e.path)}"]`);n&&this.styleElementMap.set(e.path,n),this.dispatchCSSUpdateEvent(e,!0)}catch(t){throw console.error(`Failed to update global CSS: ${e.path}`,t),this.dispatchCSSUpdateEvent(e,!1,t),t}}handleCSSModuleUpdate(e){try{let t=this.findIslandsUsingCSSModule(e.path);if(t.length===0)return;for(let n of t)this.triggerIslandRerender(n,e);this.dispatchCSSUpdateEvent(e,!0)}catch(t){throw console.error(`[HMR] Failed to update CSS module: ${e.path}`,t),this.dispatchCSSUpdateEvent(e,!1,t),t}}handleScopedCSSUpdate(e){try{if(this.findIslandsUsingComponent(e.path).length===0)return;this.dispatchCSSUpdateEvent(e,!0)}catch(t){throw console.error(`[HMR] Failed to update scoped CSS: ${e.path}`,t),this.dispatchCSSUpdateEvent(e,!1,t),t}}findIslandsUsingCSSModule(e){let t=[],n=this.normalizePath(e),r=this.cssModuleMap.get(n);if(r)return Array.from(r);let i=document.querySelectorAll(`[data-src]`);for(let n of i){let r=n.getAttribute(`data-src`);r&&this.getDirectory(r)===this.getDirectory(e)&&t.push(n)}return t.length>0&&this.cssModuleMap.set(n,new Set(t)),t}findIslandsUsingComponent(e){let t=[],n=this.normalizePath(e),r=document.querySelectorAll(`[data-src]`);for(let e of r){let r=e.getAttribute(`data-src`);if(!r)continue;let i=this.normalizePath(r);(i===n||i.includes(n))&&t.push(e)}return t}triggerIslandRerender(e,t){e.dispatchEvent(new CustomEvent(`css-module-update`,{detail:{cssPath:t.path,timestamp:t.timestamp},bubbles:!0}));let n=e.getAttribute(`data-src`);n&&e.dispatchEvent(new CustomEvent(`hmr-update-required`,{detail:{src:n,reason:`css-module-update`,cssPath:t.path},bubbles:!0}))}dispatchCSSUpdateEvent(e,t,n){let r=new CustomEvent(`css-hmr-update`,{detail:{type:e.type,path:e.path,timestamp:e.timestamp,success:t,error:n?.message},bubbles:!0});document.dispatchEvent(r)}normalizePath(e){return e.replace(/\\/g,`/`).replace(/^\//,``).replace(/\?.*$/,``).replace(/#.*$/,``)}getDirectory(e){let t=this.normalizePath(e),n=t.lastIndexOf(`/`);return n>=0?t.substring(0,n):``}getFileId(e){return this.normalizePath(e)}clearCache(){this.cssModuleMap.clear(),this.styleElementMap.clear()}registerCSSModuleUsage(e,t){let n=this.normalizePath(e);this.cssModuleMap.has(n)||this.cssModuleMap.set(n,new Set),this.cssModuleMap.get(n).add(t)}}let t=null;export function getCSSHMRHandler(){return t||=new CSSHMRHandler,t}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export class AdapterRegistry{adapters=new Map;register(e,t){let n=e.toLowerCase();if(!t)throw Error(`Cannot register null/undefined adapter for framework: ${e}`);if(!t.name)throw Error(`Adapter for framework ${e} must have a name property`);if(typeof t.canHandle!=`function`)throw Error(`Adapter for framework ${e} must implement canHandle method`);if(typeof t.preserveState!=`function`)throw Error(`Adapter for framework ${e} must implement preserveState method`);if(typeof t.update!=`function`)throw Error(`Adapter for framework ${e} must implement update method`);if(typeof t.restoreState!=`function`)throw Error(`Adapter for framework ${e} must implement restoreState method`);if(typeof t.handleError!=`function`)throw Error(`Adapter for framework ${e} must implement handleError method`);this.adapters.has(n)&&console.warn(`Overwriting existing HMR adapter for framework: ${e}`),this.adapters.set(n,t)}get(e){return this.adapters.get(e.toLowerCase())}has(e){return this.adapters.has(e.toLowerCase())}getRegisteredFrameworks(){return Array.from(this.adapters.keys())}findAdapter(e){for(let t of this.adapters.values())if(t.canHandle(e))return t}unregister(e){let t=e.toLowerCase();return this.adapters.delete(t)}clear(){this.adapters.clear()}get size(){return this.adapters.size}}export class BaseFrameworkAdapter{preserveState(e){try{return{framework:this.name,timestamp:Date.now(),data:{},dom:this.captureDOMState(e)}}catch(e){return console.warn(`Failed to preserve state for ${this.name}:`,e),null}}restoreState(e,t){try{t.dom&&this.restoreDOMState(e,t.dom)}catch(e){console.warn(`Failed to restore state for ${this.name}:`,e)}}handleError(e,t){console.error(`HMR error in ${this.name} island:`,t);let n=document.createElement(`div`);n.className=`hmr-error-indicator`,n.style.cssText=`
|
|
2
|
+
position: absolute;
|
|
3
|
+
top: 0;
|
|
4
|
+
left: 0;
|
|
5
|
+
right: 0;
|
|
6
|
+
background: #ff4444;
|
|
7
|
+
color: white;
|
|
8
|
+
padding: 8px;
|
|
9
|
+
font-size: 12px;
|
|
10
|
+
font-family: monospace;
|
|
11
|
+
z-index: 10000;
|
|
12
|
+
border-bottom: 2px solid #cc0000;
|
|
13
|
+
`,n.textContent=`HMR Error: ${t.message}`;let r=e.querySelector(`.hmr-error-indicator`);r&&r.remove(),e.style.position=`relative`,e.insertBefore(n,e.firstChild),e.setAttribute(`data-hmr-error`,`true`),e.setAttribute(`data-hmr-error-message`,t.message)}captureDOMState(e){let t={};(e.querySelectorAll(`[data-preserve-scroll]`).length>0||e.scrollTop>0||e.scrollLeft>0)&&(t.scrollPosition={x:e.scrollLeft,y:e.scrollTop});let n=document.activeElement;if(n&&e.contains(n)){let e=this.getElementSelector(n);e&&(t.focusedElement=e)}let r=e.querySelectorAll(`input, textarea, select`);return r.length>0&&(t.formValues={},r.forEach((e,n)=>{let r=e,i=r.name||r.id||`element-${n}`;r.type===`checkbox`||r.type===`radio`?t.formValues[i]=r.checked:t.formValues[i]=r.value})),t}restoreDOMState(e,t){if(t){if(t.scrollPosition&&(e.scrollLeft=t.scrollPosition.x,e.scrollTop=t.scrollPosition.y),t.focusedElement)try{let n=e.querySelector(t.focusedElement);n&&typeof n.focus==`function`&&n.focus()}catch(e){console.warn(`Failed to restore focus:`,e)}t.formValues&&e.querySelectorAll(`input, textarea, select`).forEach((e,n)=>{let r=e,i=r.name||r.id||`element-${n}`,a=t.formValues[i];a!==void 0&&(r.type===`checkbox`||r.type===`radio`?r.checked=a:r.value=a)})}}getElementSelector(e){if(e.id)return`#${e.id}`;let t=e.getAttribute(`name`);if(t)return`[name="${t}"]`;let n=e.parentElement;if(n){let t=Array.from(n.children).indexOf(e);return`${e.tagName.toLowerCase()}:nth-child(${t+1})`}return null}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{AdapterRegistry as e}from"./framework-adapter.js";import{getCSSHMRHandler as t}from"./css-hmr-handler.js";export class HMRCoordinator{registry=new e;stateSnapshots=new Map;updateQueue=new Set;isProcessing=!1;initialize(){import.meta.hot&&(import.meta.hot.accept(),import.meta.hot.on(`vite:beforeUpdate`,e=>{this.handleUpdate(e)}),import.meta.hot.on(`vite:beforeFullReload`,()=>{this.handleBeforeFullReload()}),import.meta.hot.on(`vite:error`,e=>{console.error(`[HMR] error:`,e),this.handleError(e)}),document.addEventListener(`hmr-update-required`,e=>{let{src:t,reason:n}=e.detail;n===`css-module-update`&&(this.updateQueue.add(this.normalizePath(t)),this.isProcessing||this.processUpdateQueue().catch(e=>{console.error(`[HMR] Failed to process CSS module update:`,e)}))}))}registerAdapter(e,t){this.registry.register(e,t)}getRegistry(){return this.registry}async handleUpdate(e){if(e.type!==`update`||!e.updates)return;let t=[],n=[];for(let r of e.updates)r.type===`css-update`?t.push(r):n.push(r);this.processCSSUpdates(t),this.queueJSUpdates(n),!this.isProcessing&&this.updateQueue.size>0&&await this.processUpdateQueue()}processCSSUpdates(e){if(e.length===0)return;let n=t();for(let t of e)try{n.handleCSSUpdate(t)}catch(e){console.error(`[HMR] CSS update failed:`,e)}}queueJSUpdates(e){for(let t of e){let e=this.normalizePath(t.path||t.acceptedPath);this.isIslandModule(e)&&this.updateQueue.add(e)}}async processUpdateQueue(){if(this.updateQueue.size!==0){this.isProcessing=!0;try{let e=Array.from(this.updateQueue);this.updateQueue.clear();for(let t of e){let e=this.findAffectedIslands(t);for(let t of e)try{await this.updateIsland(t)}catch(e){console.error(`[HMR] Failed to update island:`,e)}}}finally{this.isProcessing=!1}}}findAffectedIslands(e){let t=[],n=this.normalizePath(e),r=document.querySelectorAll(`[data-src]`);for(let e of r){let r=e.dataset.src;if(!r)continue;let i=this.normalizePath(r);(i===n||i.endsWith(n)||n.endsWith(i)||i.split(`/`).pop()===n.split(`/`).pop())&&t.push(e)}return t}async updateIsland(e){let t=e.dataset.framework,n=e.dataset.src,r=e.dataset.props;if(!t||!n){console.warn(`[HMR] Island missing framework or src attribute`,e);return}let i=this.registry.get(t.toLowerCase());if(!i){console.warn(`[HMR] No adapter registered for framework: ${t}`);return}try{let a=r?JSON.parse(r):{},o=i.preserveState(e);o&&this.stateSnapshots.set(this.getIslandId(e),o),delete e.dataset.hydrated,delete e.dataset.hydrationStatus,e.querySelector(`.hydration-error-indicator, .hmr-error-indicator`)?.remove();let s=Date.now(),c=await import(n.includes(`?`)?`${n}&t=${s}`:`${n}?t=${s}`),l=this.resolveComponent(c,n);await i.update(e,l,a),o&&(i.restoreState(e,o),this.stateSnapshots.delete(this.getIslandId(e))),e.dataset.hydrated=`true`,e.dispatchEvent(new CustomEvent(`hmr-update`,{detail:{framework:t,src:n,timestamp:Date.now(),success:!0},bubbles:!0}))}catch(r){throw console.error(`[HMR] Failed to update ${t} island ${n}:`,r),i.handleError(e,r),e.dispatchEvent(new CustomEvent(`hmr-error`,{detail:{framework:t,src:n,error:r.message,timestamp:Date.now()},bubbles:!0})),r}}resolveComponent(e,t){if(e.default)return e.default;for(let t of Object.keys(e)){if(t===`default`)continue;let n=e[t];if(typeof n==`function`&&n.prototype)return n}throw Error(`Component ${t} has no default export`)}handleBeforeFullReload(){let e=document.querySelectorAll(`[data-hydrated="true"]`),t={};for(let n of e){let e=n.dataset.framework,r=n.dataset.src;if(!e||!r)continue;let i=this.registry.get(e.toLowerCase());if(!i)continue;let a=i.preserveState(n);a&&(t[r]=a)}try{sessionStorage.setItem(`__avalon_hmr_states__`,JSON.stringify(t))}catch(e){console.warn(`[HMR] Failed to save states:`,e)}}handleError(e){let t=Error(e.err.message);t.stack=e.err.stack,console.error(`[HMR] Error:`,t),globalThis.window!==void 0&&import(`./hmr-error-overlay.js`).then(({showHMRErrorOverlay:n})=>{n({framework:`unknown`,src:`unknown`,error:t,filePath:e.err.id||e.err.loc?.file||`unknown`,line:e.err.loc?.line,column:e.err.loc?.column})}).catch(()=>{console.error(`[HMR] Failed to show error overlay`)})}normalizePath(e){return e.replaceAll(`\\`,`/`).replace(/^\//,``).replace(/\?.*$/,``).replace(/#.*$/,``).replace(/^src\//,``)}isIslandModule(e){return e.includes(`/islands/`)||e.includes(`\\islands\\`)}getIslandId(e){let t=e.dataset.src??``;return`${e.dataset.framework??``}:${t}:${Array.from(document.querySelectorAll(`[data-src="${t}"]`)).indexOf(e)}`}}let r=null;export function getHMRCoordinator(){return r??=new HMRCoordinator,r}export function initializeHMR(){import.meta.hot&&getHMRCoordinator().initialize()}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
export function showHMRErrorOverlay({framework:e,src:a,error:o,filePath:s,line:c,column:l}){removeHMRErrorOverlay();let u=document.createElement(`div`);u.id=`avalon-hmr-error-overlay`,u.style.cssText=`
|
|
2
|
+
position: fixed;
|
|
3
|
+
top: 0;
|
|
4
|
+
left: 0;
|
|
5
|
+
right: 0;
|
|
6
|
+
bottom: 0;
|
|
7
|
+
background: rgba(0, 0, 0, 0.85);
|
|
8
|
+
z-index: 99999;
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
13
|
+
backdrop-filter: blur(4px);
|
|
14
|
+
`;let d=document.createElement(`div`);d.style.cssText=`
|
|
15
|
+
background: #1a1a2e;
|
|
16
|
+
border-radius: 12px;
|
|
17
|
+
max-width: 700px;
|
|
18
|
+
width: 90%;
|
|
19
|
+
max-height: 80vh;
|
|
20
|
+
overflow: auto;
|
|
21
|
+
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
|
|
22
|
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
23
|
+
`;let f=document.createElement(`div`);f.style.cssText=`
|
|
24
|
+
background: linear-gradient(135deg, #e74c3c, #c0392b);
|
|
25
|
+
padding: 16px 20px;
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
justify-content: space-between;
|
|
29
|
+
border-radius: 12px 12px 0 0;
|
|
30
|
+
`;let p=document.createElement(`div`);p.style.cssText=`
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
gap: 10px;
|
|
34
|
+
color: white;
|
|
35
|
+
font-weight: 600;
|
|
36
|
+
font-size: 16px;
|
|
37
|
+
`,p.innerHTML=`
|
|
38
|
+
<span style="font-size: 20px;">⚠️</span>
|
|
39
|
+
<span>HMR Update Failed</span>
|
|
40
|
+
`;let m=document.createElement(`button`);m.style.cssText=`
|
|
41
|
+
background: rgba(255, 255, 255, 0.2);
|
|
42
|
+
border: none;
|
|
43
|
+
color: white;
|
|
44
|
+
width: 28px;
|
|
45
|
+
height: 28px;
|
|
46
|
+
border-radius: 6px;
|
|
47
|
+
cursor: pointer;
|
|
48
|
+
font-size: 18px;
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
justify-content: center;
|
|
52
|
+
transition: background 0.2s;
|
|
53
|
+
`,m.textContent=`×`,m.onmouseover=()=>m.style.background=`rgba(255, 255, 255, 0.3)`,m.onmouseout=()=>m.style.background=`rgba(255, 255, 255, 0.2)`,m.onclick=removeHMRErrorOverlay,f.appendChild(p),f.appendChild(m);let h=document.createElement(`div`);h.style.cssText=`
|
|
54
|
+
padding: 20px;
|
|
55
|
+
color: #e0e0e0;
|
|
56
|
+
`;let g=document.createElement(`div`);g.style.cssText=`
|
|
57
|
+
background: rgba(255, 255, 255, 0.05);
|
|
58
|
+
border-radius: 8px;
|
|
59
|
+
padding: 12px 16px;
|
|
60
|
+
margin-bottom: 16px;
|
|
61
|
+
font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
|
|
62
|
+
font-size: 13px;
|
|
63
|
+
`;let _=s||a,v=c?`:${c}${l?`:${l}`:``}`:``;g.innerHTML=`
|
|
64
|
+
<div style="color: #888; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px;">
|
|
65
|
+
Component
|
|
66
|
+
</div>
|
|
67
|
+
<div style="color: #61dafb; word-break: break-all;">
|
|
68
|
+
${n(_)}${v}
|
|
69
|
+
</div>
|
|
70
|
+
<div style="margin-top: 8px; color: #888; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px;">
|
|
71
|
+
Framework
|
|
72
|
+
</div>
|
|
73
|
+
<div style="color: #a78bfa;">
|
|
74
|
+
${n(e)}
|
|
75
|
+
</div>
|
|
76
|
+
`;let y=document.createElement(`div`);y.style.cssText=`
|
|
77
|
+
margin-bottom: 16px;
|
|
78
|
+
`;let b=document.createElement(`div`);b.style.cssText=`
|
|
79
|
+
color: #888;
|
|
80
|
+
font-size: 11px;
|
|
81
|
+
text-transform: uppercase;
|
|
82
|
+
letter-spacing: 0.5px;
|
|
83
|
+
margin-bottom: 8px;
|
|
84
|
+
`,b.textContent=`Error Message`;let x=document.createElement(`div`);if(x.style.cssText=`
|
|
85
|
+
background: rgba(231, 76, 60, 0.1);
|
|
86
|
+
border: 1px solid rgba(231, 76, 60, 0.3);
|
|
87
|
+
border-radius: 8px;
|
|
88
|
+
padding: 12px 16px;
|
|
89
|
+
color: #ff6b6b;
|
|
90
|
+
font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
|
|
91
|
+
font-size: 13px;
|
|
92
|
+
white-space: pre-wrap;
|
|
93
|
+
word-break: break-word;
|
|
94
|
+
`,x.textContent=o.message||String(o),y.appendChild(b),y.appendChild(x),o.stack){let e=document.createElement(`div`);e.style.cssText=`
|
|
95
|
+
margin-bottom: 16px;
|
|
96
|
+
`;let t=document.createElement(`div`);t.style.cssText=`
|
|
97
|
+
color: #888;
|
|
98
|
+
font-size: 11px;
|
|
99
|
+
text-transform: uppercase;
|
|
100
|
+
letter-spacing: 0.5px;
|
|
101
|
+
margin-bottom: 8px;
|
|
102
|
+
display: flex;
|
|
103
|
+
align-items: center;
|
|
104
|
+
justify-content: space-between;
|
|
105
|
+
`;let n=document.createElement(`span`);n.textContent=`Stack Trace`;let i=document.createElement(`button`);i.style.cssText=`
|
|
106
|
+
background: rgba(255, 255, 255, 0.1);
|
|
107
|
+
border: none;
|
|
108
|
+
color: #888;
|
|
109
|
+
padding: 4px 8px;
|
|
110
|
+
border-radius: 4px;
|
|
111
|
+
cursor: pointer;
|
|
112
|
+
font-size: 11px;
|
|
113
|
+
`,i.textContent=`Show`,t.appendChild(n),t.appendChild(i);let a=document.createElement(`div`);a.style.cssText=`
|
|
114
|
+
background: rgba(0, 0, 0, 0.3);
|
|
115
|
+
border-radius: 8px;
|
|
116
|
+
padding: 12px 16px;
|
|
117
|
+
color: #888;
|
|
118
|
+
font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
|
|
119
|
+
font-size: 11px;
|
|
120
|
+
white-space: pre-wrap;
|
|
121
|
+
word-break: break-word;
|
|
122
|
+
max-height: 200px;
|
|
123
|
+
overflow: auto;
|
|
124
|
+
display: none;
|
|
125
|
+
`,a.textContent=r(o.stack),i.onclick=()=>{let e=a.style.display===`none`;a.style.display=e?`block`:`none`,i.textContent=e?`Hide`:`Show`},e.appendChild(t),e.appendChild(a),h.appendChild(e)}let S=i(o,e);if(S.length>0){let e=document.createElement(`div`);e.style.cssText=`
|
|
126
|
+
background: rgba(46, 204, 113, 0.1);
|
|
127
|
+
border: 1px solid rgba(46, 204, 113, 0.3);
|
|
128
|
+
border-radius: 8px;
|
|
129
|
+
padding: 12px 16px;
|
|
130
|
+
`;let t=document.createElement(`div`);t.style.cssText=`
|
|
131
|
+
color: #2ecc71;
|
|
132
|
+
font-size: 12px;
|
|
133
|
+
font-weight: 600;
|
|
134
|
+
margin-bottom: 8px;
|
|
135
|
+
display: flex;
|
|
136
|
+
align-items: center;
|
|
137
|
+
gap: 6px;
|
|
138
|
+
`,t.innerHTML=`<span>💡</span><span>Suggestions</span>`;let n=document.createElement(`ul`);n.style.cssText=`
|
|
139
|
+
margin: 0;
|
|
140
|
+
padding-left: 20px;
|
|
141
|
+
color: #a0a0a0;
|
|
142
|
+
font-size: 13px;
|
|
143
|
+
line-height: 1.6;
|
|
144
|
+
`;for(let e of S){let t=document.createElement(`li`);t.textContent=e,n.appendChild(t)}e.appendChild(t),e.appendChild(n),h.appendChild(e)}let C=document.createElement(`div`);C.style.cssText=`
|
|
145
|
+
padding: 12px 20px;
|
|
146
|
+
border-top: 1px solid rgba(255, 255, 255, 0.1);
|
|
147
|
+
display: flex;
|
|
148
|
+
justify-content: space-between;
|
|
149
|
+
align-items: center;
|
|
150
|
+
font-size: 12px;
|
|
151
|
+
color: #666;
|
|
152
|
+
`;let w=document.createElement(`span`);w.textContent=`${new Date().toLocaleTimeString()}`;let T=document.createElement(`div`);T.style.cssText=`
|
|
153
|
+
display: flex;
|
|
154
|
+
gap: 8px;
|
|
155
|
+
`;let E=document.createElement(`button`);E.style.cssText=`
|
|
156
|
+
background: #3498db;
|
|
157
|
+
border: none;
|
|
158
|
+
color: white;
|
|
159
|
+
padding: 6px 12px;
|
|
160
|
+
border-radius: 6px;
|
|
161
|
+
cursor: pointer;
|
|
162
|
+
font-size: 12px;
|
|
163
|
+
font-weight: 500;
|
|
164
|
+
`,E.textContent=`Reload Page`,E.onclick=()=>globalThis.location.reload();let D=document.createElement(`button`);D.style.cssText=`
|
|
165
|
+
background: rgba(255, 255, 255, 0.1);
|
|
166
|
+
border: none;
|
|
167
|
+
color: #888;
|
|
168
|
+
padding: 6px 12px;
|
|
169
|
+
border-radius: 6px;
|
|
170
|
+
cursor: pointer;
|
|
171
|
+
font-size: 12px;
|
|
172
|
+
`,D.textContent=`Dismiss`,D.onclick=removeHMRErrorOverlay,T.appendChild(D),T.appendChild(E),C.appendChild(w),C.appendChild(T),h.insertBefore(g,h.firstChild),h.insertBefore(y,h.children[1]),d.appendChild(f),d.appendChild(h),d.appendChild(C),u.appendChild(d);let O=e=>{e.key===`Escape`&&removeHMRErrorOverlay()};document.addEventListener(`keydown`,O),u._keydownHandler=O,document.body.appendChild(u)}export function removeHMRErrorOverlay(){let e=document.getElementById(`avalon-hmr-error-overlay`);e&&(e._keydownHandler&&document.removeEventListener(`keydown`,e._keydownHandler),e.remove())}function n(e){let t=document.createElement(`div`);return t.textContent=e,t.innerHTML}function r(e){return e.split(`
|
|
173
|
+
`).map(e=>e.trim()).filter(e=>e.length>0).join(`
|
|
174
|
+
`)}function i(e,t){let n=[],r=e.message?.toLowerCase()||``;switch(r.includes(`no default export`)&&(n.push(`Ensure your component has a default export`),n.push(`Check that the export statement is correct: export default ComponentName`)),(r.includes(`cannot find module`)||r.includes(`module not found`))&&(n.push(`Check that the import path is correct`),n.push(`Verify the file exists at the specified location`),n.push(`Check for typos in the file name or path`)),(r.includes(`syntax error`)||r.includes(`unexpected token`))&&(n.push(`Check for syntax errors in your component`),n.push(`Ensure all brackets and parentheses are properly closed`)),(r.includes(`hydration`)||r.includes(`mismatch`))&&(n.push(`Ensure server and client render the same initial content`),n.push(`Check for browser-only code that runs during SSR`)),t){case`vue`:r.includes(`template`)&&n.push(`Check your Vue template syntax`);break;case`svelte`:r.includes(`compile`)&&(n.push(`Check your Svelte component syntax`),n.push(`Ensure reactive statements use $: prefix`));break;case`solid`:(r.includes(`signal`)||r.includes(`reactive`))&&n.push(`Check your Solid.js signal usage`);break;case`lit`:(r.includes(`custom element`)||r.includes(`define`))&&n.push(`Ensure your Lit element is properly decorated with @customElement`);break}return n.length===0&&(n.push(`Check the browser console for more details`),n.push(`Try reloading the page`)),n}export function showHMRToast({message:e,type:t=`info`,duration:r=3e3}){let i=document.getElementById(`avalon-hmr-toast`);i&&i.remove();let a={success:{bg:`#2ecc71`,icon:`✓`},error:{bg:`#e74c3c`,icon:`✕`},info:{bg:`#3498db`,icon:`ℹ`}},{bg:o,icon:s}=a[t]||a.info,c=document.createElement(`div`);c.id=`avalon-hmr-toast`,c.style.cssText=`
|
|
175
|
+
position: fixed;
|
|
176
|
+
bottom: 20px;
|
|
177
|
+
right: 20px;
|
|
178
|
+
background: ${o};
|
|
179
|
+
color: white;
|
|
180
|
+
padding: 12px 16px;
|
|
181
|
+
border-radius: 8px;
|
|
182
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
183
|
+
font-size: 13px;
|
|
184
|
+
display: flex;
|
|
185
|
+
align-items: center;
|
|
186
|
+
gap: 8px;
|
|
187
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
|
188
|
+
z-index: 99998;
|
|
189
|
+
animation: slideIn 0.3s ease;
|
|
190
|
+
`,c.innerHTML=`
|
|
191
|
+
<span style="font-weight: bold;">${s}</span>
|
|
192
|
+
<span>${n(e)}</span>
|
|
193
|
+
`;let l=document.createElement(`style`);l.textContent=`
|
|
194
|
+
@keyframes slideIn {
|
|
195
|
+
from {
|
|
196
|
+
transform: translateX(100%);
|
|
197
|
+
opacity: 0;
|
|
198
|
+
}
|
|
199
|
+
to {
|
|
200
|
+
transform: translateX(0);
|
|
201
|
+
opacity: 1;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
@keyframes slideOut {
|
|
205
|
+
from {
|
|
206
|
+
transform: translateX(0);
|
|
207
|
+
opacity: 1;
|
|
208
|
+
}
|
|
209
|
+
to {
|
|
210
|
+
transform: translateX(100%);
|
|
211
|
+
opacity: 0;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
`,c.appendChild(l),document.body.appendChild(c),setTimeout(()=>{c.style.animation=`slideOut 0.3s ease`,setTimeout(()=>c.remove(),300)},r)}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,e):e();function e(){let e=document.querySelectorAll(`[data-framework]`);e.length!==0&&e.forEach(e=>{try{let o=e.dataset.framework,s=e.dataset.condition||`on:client`;if(e.dataset.renderStrategy===`ssr-only`||!t(e,s))return;s===`on:client`?c(e,o):s===`on:visible`?n(e,o):s===`on:interaction`?r(e,o):s===`on:idle`?i(e,o):s.startsWith(`media:`)?a(e,o,s.slice(6)):c(e,o)}catch(t){console.error(`Error processing island:`,t),l(e,e.dataset.framework||`unknown`,e.dataset.src||`unknown`,t)}})}function t(e,t){if(!t||t===`on:client`)return!0;if(t.startsWith(`media:`)){let e=t.slice(6);try{return globalThis.matchMedia(e).matches}catch(t){return console.error(`Invalid media query:`,e,t),!0}}return t===`on:visible`||t===`on:interaction`||t===`on:idle`||console.warn(`Unknown hydration condition:`,t),!0}function n(e,t){try{let n=new IntersectionObserver(r=>{r[0].isIntersecting&&(c(e,t),n.disconnect())},{rootMargin:`50px`,threshold:0});n.observe(e)}catch(n){console.error(`Failed to setup intersection observer:`,n),c(e,t)}}function r(e,t){let n=[`click`,`touchstart`,`mouseenter`,`focusin`],r=!1,i=()=>{r||(r=!0,n.forEach(t=>{e.removeEventListener(t,i)}),c(e,t))};try{n.forEach(t=>{e.addEventListener(t,i,{once:!0,passive:!0})})}catch(n){console.error(`Failed to setup interaction observer:`,n),c(e,t)}}function i(e,t){try{`requestIdleCallback`in globalThis?globalThis.requestIdleCallback(()=>{c(e,t)},{timeout:5e3}):document.readyState===`complete`?setTimeout(()=>{c(e,t)},200):globalThis.addEventListener(`load`,()=>{setTimeout(()=>{c(e,t)},200)},{once:!0})}catch(n){console.error(`Failed to setup idle callback:`,n),c(e,t)}}function a(e,t,n){try{let r=globalThis.matchMedia(n);if(r.matches){c(e,t);return}let i=n=>{n.matches&&(c(e,t),r.removeEventListener(`change`,i))};r.addEventListener(`change`,i)}catch(r){console.error(`Failed to setup media query:`,n,r),c(e,t)}}async function o(e){switch(e){case`preact`:return import(`/@useavalon/preact/client`);case`react`:return import(`/@useavalon/react/client`);case`vue`:return import(`/@useavalon/vue/client`);case`svelte`:return import(`/@useavalon/svelte/client`);case`solid`:return import(`/@useavalon/solid/client`);case`lit`:return import(`/@useavalon/lit/client`);case`qwik`:return import(`/@useavalon/qwik/client`);default:throw Error(`Unknown framework: ${e}`)}}function s(e,t){let n=e.default;if(!n){let t=Object.keys(e).filter(e=>e!==`default`);for(let r of t){let t=e[r];if(typeof t==`function`&&t.prototype){n=t;break}}n||=e}if(!n)throw Error(`Component ${t} has no default export`);return n}async function c(e,t){if(e.dataset.hydrated)return;let n=e.dataset.src,r=e.dataset.props;if(!n){console.warn(`Island missing data-src attribute`);return}try{let i=r?JSON.parse(r):{};t===`lit`&&await import(`/@useavalon/lit/client`);let a=s(await import(n),n);try{let n=await o(t);if(!n.hydrate||typeof n.hydrate!=`function`)throw Error(`Integration ${t} does not export a hydrate function`);n.hydrate(e,a,i),e.dataset.hydrated=`true`}catch(r){import.meta.env?.DEV&&console.error(`Integration hydration failed for ${t}: ${n}`,r),e.dataset.hydrationStatus=`failed`,e.dataset.hydrationError=r.message,e.dispatchEvent(new CustomEvent(`hydration-error`,{detail:{framework:t,src:n,error:r.message,timestamp:Date.now(),hydrationType:`integration-level`},bubbles:!0}))}}catch(r){console.error(`❌ Critical error hydrating ${t} island ${n}:`,r),l(e,t,n,r)}}function l(e,t,n,r){console.error(`Hydration error for ${t} island:`,{src:n,error:r.message,stack:r.stack}),e.dataset.hydrationStatus=`failed`,e.dataset.renderStrategy=`ssr-only`,e.classList.add(`hydration-failed`),e.dispatchEvent(new CustomEvent(`hydration-error`,{detail:{framework:t,src:n,error:r.message,timestamp:Date.now()},bubbles:!0})),d()&&u(e,t,n,r)}function u(e,t,n,r){let i=document.createElement(`div`);i.className=`hydration-error-indicator`,i.style.cssText=`
|
|
2
|
+
position: absolute;
|
|
3
|
+
top: 0;
|
|
4
|
+
right: 0;
|
|
5
|
+
background: #ff4444;
|
|
6
|
+
color: white;
|
|
7
|
+
padding: 4px 8px;
|
|
8
|
+
font-size: 11px;
|
|
9
|
+
font-family: monospace;
|
|
10
|
+
border-radius: 0 0 0 4px;
|
|
11
|
+
z-index: 9999;
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
box-shadow: 0 2px 4px rgba(0,0,0,0.2);
|
|
14
|
+
`,i.textContent=`❌ ${t}`,i.title=`Hydration failed: ${n}\n${r.message}\nClick for details`,i.addEventListener(`click`,()=>{alert(`Hydration Error\n\nFramework: ${t}\nComponent: ${n}\n\nError: ${r.message}\n\nStack:\n${r.stack}`)}),globalThis.getComputedStyle(e).position===`static`&&(e.style.position=`relative`),e.appendChild(i)}function d(){return import.meta.env?.DEV||import.meta.env?.MODE===`development`||globalThis.location?.hostname===`localhost`||globalThis.location?.hostname===`127.0.0.1`}function f(e){let t=e.dataset.framework,n=e.dataset.src;if(!n)return null;let r={framework:t,src:n,props:e.dataset.props,scrollPosition:{x:globalThis.scrollX,y:globalThis.scrollY},focusedElement:document.activeElement?.id||null};try{t===`vue`&&e.__vue__?r.vueData=structuredClone(e.__vue__.$data||{}):t===`svelte`&&e.__svelte__?r.svelteState=e.__svelte__:t===`lit`&&e.tagName?.includes(`-`)&&(e.querySelector(`[data-lit-element]`)||e)._$litElement$&&(r.litProperties={})}catch(e){console.warn(`Failed to preserve island state:`,e)}return r}function p(e,t){if(t)try{if(t.scrollPosition&&globalThis.scrollTo(t.scrollPosition.x,t.scrollPosition.y),t.focusedElement){let e=document.getElementById(t.focusedElement);e&&e.focus()}e.dataset.framework===`vue`&&t.vueData&&e.__vue__&&Object.assign(e.__vue__.$data,t.vueData)}catch(e){console.warn(`Failed to restore island state:`,e)}}async function m(e,t,n,r){let i=e.dataset.props,a=i?JSON.parse(i):{};t===`lit`&&await import(`/@useavalon/lit/client`);let c=s(await import(n),r),l=await o(t);if(!l.hydrate||typeof l.hydrate!=`function`)throw Error(`Integration ${t} does not export a hydrate function`);l.hydrate(e,c,a),e.dataset.hydrated=`true`}function h(e,t,n,r){let i=e.querySelector(`.hmr-error-indicator`);i&&i.remove();let a=document.createElement(`div`);a.className=`hmr-error-indicator`,a.style.cssText=`
|
|
15
|
+
position: absolute;
|
|
16
|
+
top: 0;
|
|
17
|
+
left: 0;
|
|
18
|
+
right: 0;
|
|
19
|
+
background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
|
|
20
|
+
color: white;
|
|
21
|
+
padding: 8px 12px;
|
|
22
|
+
font-size: 12px;
|
|
23
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, monospace;
|
|
24
|
+
z-index: 10000;
|
|
25
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.3);
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
gap: 8px;
|
|
29
|
+
`;let o=document.createElement(`span`);o.textContent=`⚠️`,o.style.fontSize=`14px`;let s=document.createElement(`span`);s.style.flex=`1`,s.innerHTML=`<strong>HMR Failed:</strong> ${r.message.slice(0,100)}${r.message.length>100?`...`:``}`;let c=document.createElement(`button`);c.textContent=`×`,c.style.cssText=`
|
|
30
|
+
background: rgba(255,255,255,0.2);
|
|
31
|
+
border: none;
|
|
32
|
+
color: white;
|
|
33
|
+
width: 20px;
|
|
34
|
+
height: 20px;
|
|
35
|
+
border-radius: 50%;
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
font-size: 14px;
|
|
38
|
+
line-height: 1;
|
|
39
|
+
`,c.onclick=()=>a.remove(),a.appendChild(o),a.appendChild(s),a.appendChild(c),globalThis.getComputedStyle(e).position===`static`&&(e.style.position=`relative`),e.insertBefore(a,e.firstChild)}import.meta.hot&&(import.meta.hot.accept(),import(`./hmr-coordinator.js`).then(async({initializeHMR:e,getHMRCoordinator:t})=>{e();let n=t(),r=new Set;document.querySelectorAll(`[data-framework]`).forEach(e=>{let t=e.dataset.framework;t&&r.add(t)});let i={react:()=>import(`/@useavalon/react/client/hmr`).then(e=>e.reactAdapter),preact:()=>import(`/@useavalon/preact/client/hmr`).then(e=>e.preactAdapter),vue:()=>import(`/@useavalon/vue/client/hmr`).then(e=>e.vueAdapter),svelte:()=>import(`/@useavalon/svelte/client/hmr`).then(e=>e.svelteAdapter),solid:()=>import(`/@useavalon/solid/client/hmr`).then(e=>e.solidAdapter),lit:()=>import(`/@useavalon/lit/client/hmr`).then(e=>e.litAdapter),qwik:()=>import(`/@useavalon/qwik/client/hmr`).then(e=>e.qwikAdapter)};for(let e of r){let t=i[e];if(t)try{let r=await t();n.registerAdapter(e,r)}catch(t){console.warn(`[HMR] Failed to load adapter for ${e}:`,t)}}}).catch(e=>{console.error(`[HMR] Failed to initialize:`,e)}),_());async function g(e,t,n,r){try{let{showHMRErrorOverlay:e}=await import(`./hmr-error-overlay.js`);e({framework:t,src:n,error:r,filePath:n})}catch{h(e,t,n,r)}}function _(){if(!import.meta.hot)return;let e=new Map;async function t(e){let t=e.replaceAll(`\\`,`/`),r=document.querySelectorAll(`[data-src*="${t}"], [data-src$="${t}"]`);if(r.length===0){let e=document.querySelectorAll(`[data-src]`);for(let r of e){let e=r.dataset.src;e&&(e.includes(t)||t.includes(e.replace(/^\//,``)))&&await n(r)}return}for(let e of r)await n(e)}async function n(t){let n=t.dataset.framework,r=t.dataset.src;if(!(!r||!n))try{let i=f(t);e.set(r,i),delete t.dataset.hydrated,delete t.dataset.hydrationStatus;let a=t.querySelector(`.hydration-error-indicator`);a&&a.remove();let o=Date.now();await m(t,n,r.includes(`?`)?`${r}&t=${o}`:`${r}?t=${o}`,r);let s=e.get(r);s&&(p(t,s),e.delete(r)),t.dispatchEvent(new CustomEvent(`hmr-update`,{detail:{framework:n,src:r,timestamp:Date.now(),success:!0},bubbles:!0}))}catch(e){console.error(`[HMR] Failed for ${n} island ${r}:`,e),t.dispatchEvent(new CustomEvent(`hmr-error`,{detail:{framework:n,src:r,error:e.message,timestamp:Date.now()},bubbles:!0})),d()&&g(t,n,r,e)}}import.meta.hot.on(`vite:beforeUpdate`,e=>{for(let n of e.updates||[]){let e=n.path||n.acceptedPath;e&&(e.includes(`/islands/`)||e.includes(`\\islands\\`))&&t(e)}}),import.meta.hot.on(`vite:beforeFullReload`,()=>{let e=document.querySelectorAll(`[data-hydrated="true"]`),t={};for(let n of e){let e=n.dataset.src;e&&(t[e]=f(n))}try{sessionStorage.setItem(`__avalon_hmr_states__`,JSON.stringify(t))}catch{}});try{let e=sessionStorage.getItem(`__avalon_hmr_states__`);if(e){let t=JSON.parse(e);sessionStorage.removeItem(`__avalon_hmr_states__`),setTimeout(()=>{for(let[e,n]of Object.entries(t)){let t=document.querySelector(`[data-src="${e}"]`);t&&n&&p(t,n)}},100)}}catch{}}
|