@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
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Global URLPattern type declaration.
|
|
3
|
-
* URLPattern is available at runtime in Node 22+, Bun, and Deno,
|
|
4
|
-
* but TypeScript's lib.dom.d.ts may not include it in all configurations.
|
|
5
|
-
*/
|
|
6
|
-
declare class URLPattern {
|
|
7
|
-
constructor(init?: URLPatternInit | string, baseURL?: string);
|
|
8
|
-
readonly protocol: string;
|
|
9
|
-
readonly username: string;
|
|
10
|
-
readonly password: string;
|
|
11
|
-
readonly hostname: string;
|
|
12
|
-
readonly port: string;
|
|
13
|
-
readonly pathname: string;
|
|
14
|
-
readonly search: string;
|
|
15
|
-
readonly hash: string;
|
|
16
|
-
test(input?: URLPatternInput, baseURL?: string): boolean;
|
|
17
|
-
exec(input?: URLPatternInput, baseURL?: string): URLPatternResult | null;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface URLPatternInit {
|
|
21
|
-
baseURL?: string;
|
|
22
|
-
username?: string;
|
|
23
|
-
password?: string;
|
|
24
|
-
hostname?: string;
|
|
25
|
-
port?: string;
|
|
26
|
-
pathname?: string;
|
|
27
|
-
search?: string;
|
|
28
|
-
hash?: string;
|
|
29
|
-
protocol?: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
type URLPatternInput = URLPatternInit | string;
|
|
33
|
-
|
|
34
|
-
interface URLPatternComponentResult {
|
|
35
|
-
input: string;
|
|
36
|
-
groups: Record<string, string | undefined>;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
interface URLPatternResult {
|
|
40
|
-
inputs: [URLPatternInput, string?];
|
|
41
|
-
protocol: URLPatternComponentResult;
|
|
42
|
-
username: URLPatternComponentResult;
|
|
43
|
-
password: URLPatternComponentResult;
|
|
44
|
-
hostname: URLPatternComponentResult;
|
|
45
|
-
port: URLPatternComponentResult;
|
|
46
|
-
pathname: URLPatternComponentResult;
|
|
47
|
-
search: URLPatternComponentResult;
|
|
48
|
-
hash: URLPatternComponentResult;
|
|
49
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Global URLPattern type declaration.
|
|
3
|
+
* URLPattern is available at runtime in Node 22+, Bun, and Deno,
|
|
4
|
+
* but TypeScript's lib.dom.d.ts may not include it in all configurations.
|
|
5
|
+
*/
|
|
6
|
+
declare class URLPattern {
|
|
7
|
+
constructor(init?: URLPatternInit | string, baseURL?: string);
|
|
8
|
+
readonly protocol: string;
|
|
9
|
+
readonly username: string;
|
|
10
|
+
readonly password: string;
|
|
11
|
+
readonly hostname: string;
|
|
12
|
+
readonly port: string;
|
|
13
|
+
readonly pathname: string;
|
|
14
|
+
readonly search: string;
|
|
15
|
+
readonly hash: string;
|
|
16
|
+
test(input?: URLPatternInput, baseURL?: string): boolean;
|
|
17
|
+
exec(input?: URLPatternInput, baseURL?: string): URLPatternResult | null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface URLPatternInit {
|
|
21
|
+
baseURL?: string;
|
|
22
|
+
username?: string;
|
|
23
|
+
password?: string;
|
|
24
|
+
hostname?: string;
|
|
25
|
+
port?: string;
|
|
26
|
+
pathname?: string;
|
|
27
|
+
search?: string;
|
|
28
|
+
hash?: string;
|
|
29
|
+
protocol?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
type URLPatternInput = URLPatternInit | string;
|
|
33
|
+
|
|
34
|
+
interface URLPatternComponentResult {
|
|
35
|
+
input: string;
|
|
36
|
+
groups: Record<string, string | undefined>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface URLPatternResult {
|
|
40
|
+
inputs: [URLPatternInput, string?];
|
|
41
|
+
protocol: URLPatternComponentResult;
|
|
42
|
+
username: URLPatternComponentResult;
|
|
43
|
+
password: URLPatternComponentResult;
|
|
44
|
+
hostname: URLPatternComponentResult;
|
|
45
|
+
port: URLPatternComponentResult;
|
|
46
|
+
pathname: URLPatternComponentResult;
|
|
47
|
+
search: URLPatternComponentResult;
|
|
48
|
+
hash: URLPatternComponentResult;
|
|
49
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
|
2
|
-
|
|
3
|
-
interface ImportMetaEnv {
|
|
4
|
-
readonly VITE_APP_TITLE: string;
|
|
5
|
-
// more env variables...
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
interface ImportMeta {
|
|
9
|
-
readonly env: ImportMetaEnv;
|
|
10
|
-
readonly hot?: import('vite/types/hot').ViteHotContext;
|
|
11
|
-
}
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
|
|
3
|
+
interface ImportMetaEnv {
|
|
4
|
+
readonly VITE_APP_TITLE: string;
|
|
5
|
+
// more env variables...
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface ImportMeta {
|
|
9
|
+
readonly env: ImportMetaEnv;
|
|
10
|
+
readonly hot?: import('vite/types/hot').ViteHotContext;
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function isDev(){try{return process.env.NODE_ENV!==`production`}catch{return!0}}export function isVerbose(){try{return process.env.AVALON_VERBOSE===`1`}catch{return!1}}export function devLog(...n){isDev()&&isVerbose()&&console.log(...n)}export function devWarn(...t){isDev()&&console.warn(...t)}export function devError(...t){isDev()&&console.error(...t)}export function logRenderTiming(n,r,i=100){!isDev()||!isVerbose()||(r>i?console.warn(`⚠️ Slow island render: ${n} took ${r.toFixed(2)}ms`):console.log(`🏝️ ${n} rendered in ${r.toFixed(2)}ms`))}export function logCacheHit(n,r){!isDev()||!isVerbose()||console.log(`📦 Cache HIT [${n}]: ${r}`)}export function logCacheMiss(n,r){!isDev()||!isVerbose()||console.log(`📭 Cache MISS [${n}]: ${r}`)}const a=`
|
|
2
|
+
█████╗ ██╗ ██╗ █████╗ ██╗ ██████╗ ███╗ ██╗
|
|
3
|
+
██╔══██╗██║ ██║██╔══██╗██║ ██╔═══██╗████╗ ██║
|
|
4
|
+
███████║██║ ██║███████║██║ ██║ ██║██╔██╗ ██║
|
|
5
|
+
██╔══██║╚██╗ ██╔╝██╔══██║██║ ██║ ██║██║╚██╗██║
|
|
6
|
+
██║ ██║ ╚████╔╝ ██║ ██║███████╗╚██████╔╝██║ ╚████║
|
|
7
|
+
╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝ ╚═══╝
|
|
8
|
+
`,o={reset:`\x1B[0m`,cyan:`\x1B[36m`,green:`\x1B[32m`,yellow:`\x1B[33m`,blue:`\x1B[34m`,magenta:`\x1B[35m`,gray:`\x1B[90m`,bold:`\x1B[1m`},s=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`];export class DevLogger{tasks=new Map;spinnerInterval;currentFrame=0;startTime=Date.now();originalConsoleLog;originalConsoleWarn;originalConsoleError;suppressedLogs=[];headerLines=0;constructor(){this.originalConsoleLog=console.log,this.originalConsoleWarn=console.warn,this.originalConsoleError=console.error,this.suppressConsole(),process.stdout.write(`\x1B[2J\x1B[H`);let e=o.cyan+a+o.reset+`
|
|
9
|
+
`+o.gray+` Development Server`+o.reset+`
|
|
10
|
+
|
|
11
|
+
`;this.headerLines=a.split(`
|
|
12
|
+
`).length+2,process.stdout.write(e)}suppressConsole(){console.log=(...e)=>{this.suppressedLogs.push(e.map(String).join(` `))},console.warn=(...e)=>{this.suppressedLogs.push(`[WARN] `+e.map(String).join(` `))},console.error=this.originalConsoleError}restoreConsole(){console.log=this.originalConsoleLog,console.warn=this.originalConsoleWarn,console.error=this.originalConsoleError}addTask(e,t){this.tasks.set(e,{name:t,status:`pending`}),this.render()}startTask(e){let t=this.tasks.get(e);t&&(t.status=`running`,t.startTime=Date.now(),this.render())}completeTask(e){let t=this.tasks.get(e);t&&(t.status=`done`,this.render())}render(){let e=null;for(let t of this.tasks.values())if(t.status===`running`){e=t;break}let t=`\r`;if(e){let n=o.cyan+s[this.currentFrame]+o.reset;t+=`${n} ${e.name}`}else t+=`${o.gray}Initializing...${o.reset}`;t+=`\x1B[K`,process.stdout.write(t)}startSpinner(){this.spinnerInterval=setInterval(()=>{this.currentFrame=(this.currentFrame+1)%s.length,this.render()},100)}stopSpinner(){this.spinnerInterval&&clearInterval(this.spinnerInterval)}finish(e,t,n){this.stopSpinner();let r=`\x1b[${this.headerLines+1};0H`;r+=`\x1B[J`,process.stdout.write(r);let i=((Date.now()-this.startTime)/1e3).toFixed(1);this.originalConsoleLog(``),this.originalConsoleLog(o.green+o.bold+`✨ Server ready!`+o.reset),this.originalConsoleLog(``),this.originalConsoleLog(o.cyan+` ➜ `+o.reset+o.bold+`Local: `+o.reset+o.cyan+e+o.reset),t&&this.originalConsoleLog(o.cyan+` ➜ `+o.reset+o.bold+`Vite: `+o.reset+o.gray+t+o.reset),n&&this.originalConsoleLog(o.cyan+` ➜ `+o.reset+o.bold+`HMR: `+o.reset+o.gray+n+o.reset),this.originalConsoleLog(``),this.originalConsoleLog(o.gray+` Ready in ${i}s`+o.reset),this.originalConsoleLog(``),this.originalConsoleLog(o.gray+` Press Ctrl+C to stop`+o.reset),this.originalConsoleLog(``)}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readdirSync as e,statSync as t}from"node:fs";import{join as n}from"node:path";export async function*walk(e,t={}){let{maxDepth:n=1/0,includeFiles:r=!0,includeDirs:i=!0,exts:a,match:s,skip:c}=t;yield*o(e,0,{maxDepth:n,includeFiles:r,includeDirs:i,exts:a,match:s,skip:c})}function i(e,t,n){return!(n.exts&&!n.exts.some(t=>e.endsWith(t))||n.match&&!n.match.some(e=>e.test(t)))}function a(e,t){return!t||t.some(t=>t.test(e))}function*o(t,r,s){if(r>s.maxDepth)return;let c;try{c=e(t,{withFileTypes:!0})}catch{return}for(let e of c){let c=n(t,e.name);if(s.skip?.some(e=>e.test(c)))continue;let l={path:c,name:e.name,isFile:e.isFile(),isDirectory:e.isDirectory(),isSymlink:e.isSymbolicLink()};e.isDirectory()?(s.includeDirs&&a(c,s.match)&&(yield l),yield*o(c,r+1,s)):e.isFile()&&s.includeFiles&&i(e.name,c,s)&&(yield l)}}export async function ensureDir(e){let{mkdirSync:t}=await import(`node:fs`);try{t(e,{recursive:!0})}catch{}}export function exists(e){try{return t(e),Promise.resolve(!0)}catch{return Promise.resolve(!1)}}export function existsSync(e){try{return t(e),!0}catch{return!1}}export async function emptyDir(e){let{rmSync:t,mkdirSync:n}=await import(`node:fs`);try{t(e,{recursive:!0,force:!0})}catch{}n(e,{recursive:!0})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolve as e}from"node:path";import{stat as t,readdir as n,readFile as r}from"node:fs/promises";import{openSync as i,readSync as a,closeSync as o}from"node:fs";const s={".vue":`vue`,".svelte":`svelte`},c=[{pattern:/\.solid\.(tsx|jsx)$/,integration:`solid`},{pattern:/\.react\.(tsx|jsx)$/,integration:`react`},{pattern:/\.lit\.(ts|js)$/,integration:`lit`},{pattern:/\.preact\.(tsx|jsx)$/,integration:`preact`},{pattern:/\.qwik\.(tsx|jsx)$/,integration:`qwik`}],l=[{pattern:/from\s+['"]react['"]/,integration:`react`},{pattern:/@jsxImportSource\s+react/,integration:`react`},{pattern:/from\s+['"]solid-js['"]/,integration:`solid`},{pattern:/@jsxImportSource\s+solid-js/,integration:`solid`},{pattern:/from\s+['"]preact['"]/,integration:`preact`},{pattern:/@jsxImportSource\s+preact/,integration:`preact`},{pattern:/from\s+['"]@builder\.io\/qwik['"]/,integration:`qwik`},{pattern:/@jsxImportSource\s+@builder\.io\/qwik/,integration:`qwik`}],u=`preact`,d=[`.tsx`,`.jsx`,`.ts`,`.js`,`.vue`,`.svelte`];export async function discoverIntegrationsFromFiles(n,r){let i=r?e(r,n):e(n);try{if(!(await t(i)).isDirectory())return new Set}catch{return new Set}let a=new Set;return await f(i,a),a}async function f(t,r){try{let i=await n(t,{withFileTypes:!0});for(let n of i){let i=e(t,n.name);if(n.isDirectory())await f(i,r);else if(n.isFile()){let e=await m(i,n.name);e&&r.add(e)}}}catch(e){(!(e instanceof Error)||e.code!==`EACCES`)&&console.warn(`Warning: Could not scan directory ${t}:`,e)}}function p(e){try{let t=i(e,`r`),n=Buffer.alloc(500);a(t,n,0,500,0),o(t);let r=n.toString(`utf-8`);for(let{pattern:e,integration:t}of l)if(e.test(r))return t}catch{}return u}async function m(e,t){let n=t.toLowerCase();for(let{pattern:e,integration:t}of c)if(e.test(n))return t;for(let[e,t]of Object.entries(s))if(n.endsWith(e))return t;return n.endsWith(`.tsx`)||n.endsWith(`.jsx`)?p(e):(n.endsWith(`.ts`)||n.endsWith(`.js`))&&!n.endsWith(`.d.ts`)&&/^[A-Z]/.test(t)?`lit`:null}export function detectIntegrationFromFileName(e){let t=e.toLowerCase();for(let{pattern:e,integration:n}of c)if(e.test(t))return n;for(let[e,n]of Object.entries(s))if(t.endsWith(e))return n;return t.endsWith(`.tsx`)||t.endsWith(`.jsx`)?u:(t.endsWith(`.ts`)||t.endsWith(`.js`))&&!t.endsWith(`.d.ts`)&&/^[A-Z]/.test(e)?`lit`:null}export function isSupportedExtension(e){return d.includes(e.toLowerCase())}export function getSupportedExtensions(){return d}export async function discoverIntegrationsFromIslandUsage(n,r,i,a){let o=new Set,s=i??process.cwd(),c=[e(s,n),e(s,r)];a&&c.push(e(s,a));for(let e of c)try{(await t(e)).isDirectory()&&await h(e,s,o)}catch{}return o}async function h(t,r,i){try{let a=await n(t,{withFileTypes:!0});for(let n of a){let a=e(t,n.name);n.isDirectory()?await h(a,r,i):n.isFile()&&g(n.name)&&await v(a,r,i)}}catch(e){!(e instanceof Error)||e.code}}function g(e){let t=e.toLowerCase();return t.endsWith(`.tsx`)||t.endsWith(`.jsx`)||t.endsWith(`.mdx`)}const _=[{pattern:/\.qwik\./,integration:`qwik`}];async function v(e,t,n){try{let i=await r(e,`utf-8`),a=y(i),o=b(i);for(let r of o){let i=a.get(r);if(!i)continue;let o=x(i,e,t);if(!o)continue;let s=await S(o);s&&n.add(s)}for(let[,e]of a)for(let{pattern:t,integration:r}of _)t.test(e)&&n.add(r)}catch{}}function y(e){let t=new Map,n=/import\s+(\w+)\s+from\s+['"]([^'"]+)['"]/g,r;for(;(r=n.exec(e))!==null;)t.set(r[1],r[2]);let i=/import\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g;for(;(r=i.exec(e))!==null;){let e=r[1].split(`,`).map(e=>e.trim()),n=r[2];for(let r of e){let e=r.match(/(\w+)\s+as\s+(\w+)/);e?t.set(e[2],n):r&&t.set(r,n)}}return t}function b(e){let t=new Set,n=/<([A-Z]\w*)\s+[^>]*\bisland\b/g,r;for(;(r=n.exec(e))!==null;)t.add(r[1]);return t}function x(t,n,r){if(t.startsWith(`.`))return e(e(n,`..`),t);for(let{prefix:n,replacement:i}of[{prefix:`@/`,replacement:`src/`},{prefix:`$components/`,replacement:`src/components/`},{prefix:`$islands/`,replacement:`src/islands/`},{prefix:`~/`,replacement:`src/`}])if(t.startsWith(n))return e(r,i,t.slice(n.length));return t.startsWith(`/src/`)?e(r,t.slice(1)):null}async function S(e){for(let n of[``,`.tsx`,`.jsx`,`.ts`,`.js`,`.vue`,`.svelte`]){let r=e+n;try{if((await t(r)).isFile())return m(r,r.split(`/`).pop()||``)}catch{}}return null}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as e}from"node:fs";import{resolve as t}from"node:path";import n from"node:process";export const DEFAULT_MDX_CONFIG={jsxImportSource:`preact`,syntaxHighlighting:!0,remarkPlugins:[],rehypePlugins:[]};export const DEFAULT_IMAGE_CONFIG={enabled:!0,defaultFormat:`webp`,quality:80,widths:[200,400,600,800,1200],removeMetadata:!0,include:/^[^?]+\.(heif|avif|jpeg|jpg|png|tiff|webp|gif)(\?.*)?$/,exclude:`public/**/*`};export const DEFAULT_CONFIG={pagesDir:`src/pages`,layoutsDir:`src/layouts`,modules:null,integrations:[],mdx:DEFAULT_MDX_CONFIG,image:DEFAULT_IMAGE_CONFIG,verbose:!1,autoDiscoverIntegrations:!0,validateIntegrations:!0,showWarnings:!0,lazyIntegrations:!0};export const DEFAULT_MODULES_CONFIG={pagesDirName:`pages`,layoutsDirName:`layouts`};function s(e){return e?typeof e==`string`?{dir:e,pagesDirName:DEFAULT_MODULES_CONFIG.pagesDirName,layoutsDirName:DEFAULT_MODULES_CONFIG.layoutsDirName}:{dir:e.dir,pagesDirName:e.pagesDirName??DEFAULT_MODULES_CONFIG.pagesDirName,layoutsDirName:e.layoutsDirName??DEFAULT_MODULES_CONFIG.layoutsDirName}:null}function c(e){return e===!1?{...DEFAULT_IMAGE_CONFIG,enabled:!1}:e===void 0||e===!0?DEFAULT_IMAGE_CONFIG:{enabled:e.enabled??DEFAULT_IMAGE_CONFIG.enabled,defaultFormat:e.defaultFormat??DEFAULT_IMAGE_CONFIG.defaultFormat,quality:e.quality??DEFAULT_IMAGE_CONFIG.quality,widths:e.widths??DEFAULT_IMAGE_CONFIG.widths,removeMetadata:e.removeMetadata??DEFAULT_IMAGE_CONFIG.removeMetadata,include:e.include??DEFAULT_IMAGE_CONFIG.include,exclude:e.exclude??DEFAULT_IMAGE_CONFIG.exclude}}export function resolveConfig(e,t){let n=e??{},i=s(n.modules),o=c(n.image);return{pagesDir:n.pagesDir??DEFAULT_CONFIG.pagesDir,layoutsDir:n.layoutsDir??DEFAULT_CONFIG.layoutsDir,modules:i,integrations:n.integrations??DEFAULT_CONFIG.integrations,mdx:{jsxImportSource:n.mdx?.jsxImportSource??DEFAULT_MDX_CONFIG.jsxImportSource,syntaxHighlighting:n.mdx?.syntaxHighlighting??DEFAULT_MDX_CONFIG.syntaxHighlighting,remarkPlugins:n.mdx?.remarkPlugins??DEFAULT_MDX_CONFIG.remarkPlugins,rehypePlugins:n.mdx?.rehypePlugins??DEFAULT_MDX_CONFIG.rehypePlugins},image:o,verbose:n.verbose??DEFAULT_CONFIG.verbose,autoDiscoverIntegrations:n.autoDiscoverIntegrations??DEFAULT_CONFIG.autoDiscoverIntegrations,validateIntegrations:n.validateIntegrations??DEFAULT_CONFIG.validateIntegrations,showWarnings:n.showWarnings??DEFAULT_CONFIG.showWarnings,lazyIntegrations:n.lazyIntegrations??DEFAULT_CONFIG.lazyIntegrations,isDev:t}}export function checkDirectoriesExist(r,i=n.cwd()){let a=[];!r.modules&&r.pagesDir&&a.push({path:r.pagesDir,type:`pages`}),r.layoutsDir&&a.push({path:r.layoutsDir,type:`layouts`});let o=[];for(let{path:n,type:s}of a){let a=t(i,n),c=e(a);o.push({path:n,absolutePath:a,exists:c,type:s}),!c&&r.showWarnings&&console.warn(`⚠️ Avalon: ${s} directory '${n}' does not exist (resolved to: ${a}). This directory will be skipped.`)}return o}export function logDirectoryCheckSummary(e,t){let n=e.filter(e=>!e.exists),r=e.filter(e=>e.exists);t&&(r.length>0&&console.log(` ✅ Found directories: ${r.map(e=>e.path).join(`, `)}`),n.length>0&&console.log(` ⚠️ Missing directories: ${n.map(e=>e.path).join(`, `)}`))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export class AvalonConfigError extends Error{field;value;constructor(t,r,i){let a=n(i);super(`Avalon configuration error in '${r}': ${t}\nReceived value: ${a}`),this.name=`AvalonConfigError`,this.field=r,this.value=i,Error.captureStackTrace&&Error.captureStackTrace(this,AvalonConfigError)}}export class IntegrationError extends Error{integrationName;originalCause;constructor(e,n,r){super(`Integration '${n}': ${e}`,{cause:r}),this.name=`IntegrationError`,this.integrationName=n,this.originalCause=r,Error.captureStackTrace&&Error.captureStackTrace(this,IntegrationError)}}function n(e){if(e===void 0)return`undefined`;if(e===null)return`null`;if(typeof e==`string`)return`"${e}"`;if(typeof e==`function`)return`[Function]`;if(Array.isArray(e))return e.length===0?`[]`:e.length<=3?`[${e.map(n).join(`, `)}]`:`[${e.slice(0,3).map(n).join(`, `)}, ... (${e.length} items)]`;if(typeof e==`object`)try{return JSON.stringify(e)}catch{return`[Circular]`}return String(e)}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import{createRequire as e}from"node:module";import{join as t}from"node:path";export async function createImagePlugin(n,r){if(!n.enabled)return r&&console.log(` ⏭️ Image optimization disabled`),[];try{let{imagetools:i}=e(t(process.cwd(),`package.json`))(`vite-imagetools`);return r&&(console.log(` 🖼️ Image optimization enabled`),console.log(` Format: ${n.defaultFormat}`),console.log(` Quality: ${n.quality}`),console.log(` Widths: ${n.widths.join(`, `)}`)),[i({include:n.include,exclude:n.exclude,removeMetadata:n.removeMetadata,defaultDirectives:e=>{let t=new URLSearchParams;return e.searchParams.has(`format`)||t.set(`format`,n.defaultFormat),e.searchParams.has(`quality`)||t.set(`quality`,String(n.quality)),e.searchParams.has(`jsx`)&&(!e.searchParams.has(`w`)&&!e.searchParams.has(`width`)&&t.set(`w`,n.widths.join(`;`)),t.set(`as`,`picture`)),t}})]}catch(e){let t=e instanceof Error?e.message:String(e);if(t.includes(`Cannot find package`)||t.includes(`MODULE_NOT_FOUND`))return console.warn(`⚠️ Avalon: Image optimization is enabled but vite-imagetools is not installed.
|
|
2
|
+
Install it with: bun add -d vite-imagetools
|
|
3
|
+
Or disable image optimization: image: false`),[];throw e}}export const IMAGE_TYPES_DECLARATION=`
|
|
4
|
+
declare module '*.jpg' {
|
|
5
|
+
const src: string;
|
|
6
|
+
export default src;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare module '*.jpeg' {
|
|
10
|
+
const src: string;
|
|
11
|
+
export default src;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module '*.png' {
|
|
15
|
+
const src: string;
|
|
16
|
+
export default src;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module '*.webp' {
|
|
20
|
+
const src: string;
|
|
21
|
+
export default src;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare module '*.avif' {
|
|
25
|
+
const src: string;
|
|
26
|
+
export default src;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare module '*.gif' {
|
|
30
|
+
const src: string;
|
|
31
|
+
export default src;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare module '*?jsx' {
|
|
35
|
+
import type { ComponentType } from 'preact';
|
|
36
|
+
const Component: ComponentType<{ alt: string; class?: string; style?: Record<string, string> }>;
|
|
37
|
+
export default Component;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare module '*&jsx' {
|
|
41
|
+
import type { ComponentType } from 'preact';
|
|
42
|
+
const Component: ComponentType<{ alt: string; class?: string; style?: Record<string, string> }>;
|
|
43
|
+
export default Component;
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{loadIntegration as e}from"../islands/integration-loader.js";import{IntegrationError as t}from"./errors.js";export const VALID_INTEGRATION_NAMES=[`react`,`preact`,`vue`,`svelte`,`solid`,`lit`,`qwik`];export function isValidIntegrationName(e){return VALID_INTEGRATION_NAMES.includes(e)}export async function activateIntegrations(n,r){let{integrations:i}=n;for(let n of i){if(!isValidIntegrationName(n))throw new t(`Invalid integration name '${n}'. Valid integration names are: ${VALID_INTEGRATION_NAMES.join(`, `)}`,n);if(!r.has(n))try{await e(n),r.add(n)}catch(e){throw new t(`Failed to activate integration. Is @useavalon/${n} installed?`,n,e)}}}export async function activateSingleIntegration(n,r,i=!1){if(!isValidIntegrationName(n))throw new t(`Invalid integration name '${n}'. Valid integration names are: ${VALID_INTEGRATION_NAMES.join(`, `)}`,n);if(r.has(n))return!1;try{return await e(n),r.add(n),!0}catch(e){throw new t(`Failed to activate integration. Is @useavalon/${n} installed?`,n,e)}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readFile as e,access as t}from"node:fs/promises";import n from"node:path";import{detectFrameworkFromPath as r}from"../islands/integration-loader.js";import{EXTRACTOR_MAP as i}from"../build/prop-extractors/index.js";import{renderSidecarContent as a}from"../build/sidecar-renderer.js";import{getSidecarPath as o,writeSidecarIfChanged as s,deleteSidecar as c,isSidecarFresh as l}from"../build/sidecar-file-manager.js";const u=new Set([`react`,`preact`]),d=[`.vue`,`.svelte`,`.lit.ts`,`.solid.tsx`,`.qwik.tsx`];export async function checkTsConfigForArbitraryExtensions(t){let r=n.join(t,`tsconfig.json`);try{let t=await e(r,`utf-8`);JSON.parse(t)?.compilerOptions?.allowArbitraryExtensions!==!0&&console.warn(`[avalon] tsconfig.json is missing "allowArbitraryExtensions: true" — sidecar .d.[ext].ts files require this setting`)}catch{}}function f(e){let t=n.basename(e);return/\.d\.(vue|svelte|lit|solid\.tsx)/.test(t)}function p(e){return f(e)?!1:d.some(t=>e.endsWith(t))}async function m(t,n){try{let n=r(t);if(u.has(n))return!1;let c=i[n];if(!c)return!1;let l=a(c(await e(t,`utf-8`)).propsType);return await s(o(t),l)}catch(e){return n&&console.warn(`[avalon] Failed to generate sidecar for ${t}:`,e instanceof Error?e.message:e),!1}}export function islandSidecarPlugin(e={}){let n,r=new Set;return{name:`avalon:island-sidecar`,configResolved(e){n=e.root},async buildStart(){await checkTsConfigForArbitraryExtensions(n),r.clear()},async load(t){return!p(t)||r.has(t)||(r.add(t),await l(t,o(t)))||await m(t,e.verbose)&&e.verbose&&console.log(`[avalon] Generated sidecar for: ${t}`),null},async handleHotUpdate(n){let i=n.file;if(!p(i))return;let a=!0;try{await t(i)}catch{a=!1}if(!a){await c(o(i))&&e.verbose&&console.log(`[avalon] Deleted sidecar for removed file: ${i}`),r.delete(i);return}r.delete(i),await m(i,e.verbose)&&e.verbose&&console.log(`[avalon] Updated sidecar for: ${i}`)}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readdir as e,stat as t}from"node:fs/promises";import{resolve as n,join as r}from"node:path";export async function discoverModules(t,i){let s=n(i,t.dir),c=[],l=[],u=[];try{let n=await e(s,{withFileTypes:!0});for(let e of n){if(!e.isDirectory()||e.name.startsWith(`.`)||e.name===`node_modules`)continue;let n=r(s,e.name),i=r(n,t.pagesDirName),d=r(n,t.layoutsDirName),[f,p]=await Promise.all([o(i),o(d)]),m=a(e.name),h={name:e.name,path:n,pagesDir:f?i:null,layoutsDir:p?d:null,routePrefix:m};c.push(h),f&&l.push({dir:i,prefix:m}),p&&u.push({dir:d,prefix:m})}}catch{}return c.sort((e,t)=>e.routePrefix===`/`?-1:t.routePrefix===`/`?1:e.name.localeCompare(t.name)),{modules:c,pageDirs:l,layoutDirs:u}}function a(e){return[`home`,`root`,`main`,`index`].includes(e.toLowerCase())?`/`:`/`+e}async function o(e){try{return(await t(e)).isDirectory()}catch{return!1}}export async function getAllPageDirs(e,t,r){let a=[],s=n(r,e);if(await o(s)&&a.push({dir:s,prefix:`/`}),t){let{pageDirs:e}=await discoverModules(t,r);a.push(...e)}return a}export async function getAllLayoutDirs(e,t,r){let a=[],s=n(r,e);if(await o(s)&&a.push({dir:s,prefix:`/`}),t){let{layoutDirs:e}=await discoverModules(t,r);a.push(...e)}return a}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import{nitro as e}from"nitro/vite";import{stat as t}from"node:fs/promises";import{createRequire as n}from"node:module";import{dirname as r,join as i}from"node:path";import{createNitroConfig as a}from"../nitro/config.js";import{createNitroBuildPlugin as o,createIslandManifestPlugin as s,createSourceMapPlugin as c,createSourceMapConfig as l}from"../nitro/index.js";import{discoverScopedMiddleware as u,executeScopedMiddleware as d,clearMiddlewareCache as f}from"../middleware/index.js";import{generateErrorPage as p,generateFallback404 as m}from"../render/error-pages.js";import{collectCssFromModuleGraph as h,injectSsrCss as g}from"../render/collect-css.js";import{getUniversalCSSForHead as _}from"../islands/universal-css-collector.js";import{getUniversalHeadForInjection as v}from"../islands/universal-head-collector.js";function y(e){return i(r(n(import.meta.url).resolve(`@useavalon/avalon`)),e)}function b(e,t){return i(r(n(i(process.cwd(),`package.json`)).resolve(`@useavalon/${e}`)),t)}export const VIRTUAL_MODULE_IDS={PAGE_ROUTES:`virtual:avalon/page-routes`,ISLAND_MANIFEST:`virtual:avalon/island-manifest`,RUNTIME_CONFIG:`virtual:avalon/runtime-config`,CONFIG:`virtual:avalon/config`};export const RESOLVED_VIRTUAL_IDS={PAGE_ROUTES:`\0`+VIRTUAL_MODULE_IDS.PAGE_ROUTES,ISLAND_MANIFEST:`\0`+VIRTUAL_MODULE_IDS.ISLAND_MANIFEST,RUNTIME_CONFIG:`\0`+VIRTUAL_MODULE_IDS.RUNTIME_CONFIG,CONFIG:`\0`+VIRTUAL_MODULE_IDS.CONFIG};export function createNitroIntegration(t,n={}){let r=a(n,t),i={preset:r.preset,serverDir:n.serverDir??r.serverDir??`./server`,routeRules:r.routeRules,runtimeConfig:r.runtimeConfig,renderer:n.renderer===!1?!1:r.renderer,compatibilityDate:r.compatibilityDate,scanDirs:[`.`]};r.publicRuntimeConfig&&(i.publicRuntimeConfig=r.publicRuntimeConfig),r.publicAssets&&(i.publicAssets=r.publicAssets),r.compressPublicAssets&&(i.compressPublicAssets=r.compressPublicAssets),r.serverEntry&&(i.serverEntry=r.serverEntry);let u=e(i),d=createNitroCoordinationPlugin({avalonConfig:t,nitroConfig:n,verbose:t.verbose}),f=createVirtualModulesPlugin({avalonConfig:t,nitroConfig:n,verbose:t.verbose}),p=o(t,n),m=s(t,{verbose:t.verbose,generatePreloadHints:!0}),h=c(l(n.preset??`node_server`,t.isDev));return{nitroOptions:r,plugins:[...Array.isArray(u)?u:[u],d,f,p,m,h]}}export function createNitroCoordinationPlugin(e){let{avalonConfig:t,verbose:n}=e;return{name:`avalon:nitro-coordination`,enforce:`pre`,configResolved(e){globalThis.__avalonConfig=t},configureServer(e){globalThis.__viteDevServer=e;let r=null;async function i(){return r||=await u({baseDir:`${e.config.root||process.cwd()}/src`,devMode:!1}),r}function a(){r=null}k(e,t,n,a),i().catch(e=>{console.warn(`[middleware] Failed to discover middleware:`,e)}),D(e,n).catch(e=>{console.error(`[prewarm] Core modules pre-warm failed:`,e)}),e.middlewares.use(async(r,a,o)=>{let s=r.url||`/`;if(s.endsWith(`.html`)&&(s=s.slice(0,-5)||`/`),s===`/index`&&(s=`/`),s.startsWith(`/@`)||s.startsWith(`/__`)||s.startsWith(`/node_modules/`)||s.startsWith(`/src/client/`)||s.startsWith(`/packages/`)||s.includes(`.`)&&!s.endsWith(`/`)||s.startsWith(`/api/`))return o();try{if(await T(e,s,r,a,i,n)||await L(e,s,t,a))return;let o=await R(e,s,t);if(o){a.statusCode=200,a.setHeader(`Content-Type`,`text/html`),a.end(o);return}await E(e,s,a,t)}catch(e){console.error(`[SSR Error]`,e),a.statusCode=500,a.setHeader(`Content-Type`,`text/html`),a.end(p(e))}})},buildStart(){}}}async function T(e,t,n,r,i,a){let o=performance.now(),s=await i();if(s.length===0)return!1;let c={};for(let[e,t]of Object.entries(n.headers))typeof t==`string`?c[e]=t:Array.isArray(t)&&(c[e]=t.join(`, `));let l=`http://${n.headers.host||`localhost`}${t}`,u=await d({url:l,method:n.method||`GET`,path:t,node:{req:n,res:r},req:new Request(l,{method:n.method||`GET`,headers:c}),context:{}},s,{devMode:!1}),f=performance.now()-o;return f>100&&console.warn(`⚠️ Slow middleware: ${f.toFixed(0)}ms for ${t}`),u?(r.statusCode=u.status,u.headers.forEach((e,t)=>{r.setHeader(t,e)}),r.end(await u.text()),!0):!1}async function E(e,t,n,r){try{let{discoverErrorPages:i,getErrorPageModule:a,generateDefaultErrorPage:o}=await import(`../nitro/error-handler.js`),s=a(404,await i({isDev:r.isDev,pagesDir:r.pagesDir,loadPageModule:async t=>await e.ssrLoadModule(t)}));if(s?.default&&typeof s.default==`function`){let{renderToHtml:e}=await import(`../render/ssr.js`),r=s.default,i=await e({component:()=>r({statusCode:404,message:`Page not found: ${t}`,url:t})},{});n.statusCode=404,n.setHeader(`Content-Type`,`text/html`),n.end(i);return}let c=o(404,`Page not found: ${t}`,r.isDev);n.statusCode=404,n.setHeader(`Content-Type`,`text/html`),n.end(c)}catch{n.statusCode=404,n.setHeader(`Content-Type`,`text/html`),n.end(m(t))}}async function D(e,t){let n=performance.now(),r=[{path:y(`src/render/ssr.ts`),assignTo:`ssr`},{path:y(`src/core/layout/enhanced-layout-resolver.ts`),assignTo:`layout`},{path:y(`src/middleware/index.ts`),assignTo:null},...[`react`,`vue`,`solid`,`svelte`,`lit`,`preact`].map(e=>({path:b(e,`server/renderer.ts`),assignTo:null}))],i=(await Promise.allSettled(r.map(async({path:t,assignTo:n})=>{let r=await e.ssrLoadModule(t);n===`ssr`&&(F=r),n===`layout`&&(I=r)}))).filter(e=>e.status===`fulfilled`).length,a=performance.now()-n;t&&i>0&&console.log(`🔥 SSR ready in ${a.toFixed(0)}ms (${i}/${r.length} core modules)`)}export function createVirtualModulesPlugin(e){let{avalonConfig:t,nitroConfig:n,verbose:r}=e;return{name:`avalon:nitro-virtual-modules`,enforce:`pre`,resolveId(e){return e===VIRTUAL_MODULE_IDS.PAGE_ROUTES?RESOLVED_VIRTUAL_IDS.PAGE_ROUTES:e===VIRTUAL_MODULE_IDS.ISLAND_MANIFEST?RESOLVED_VIRTUAL_IDS.ISLAND_MANIFEST:e===VIRTUAL_MODULE_IDS.RUNTIME_CONFIG?RESOLVED_VIRTUAL_IDS.RUNTIME_CONFIG:e===VIRTUAL_MODULE_IDS.CONFIG?RESOLVED_VIRTUAL_IDS.CONFIG:null},async load(e){return e===RESOLVED_VIRTUAL_IDS.PAGE_ROUTES?await A(t,r):e===RESOLVED_VIRTUAL_IDS.ISLAND_MANIFEST?j():e===RESOLVED_VIRTUAL_IDS.RUNTIME_CONFIG?M(t,n):e===RESOLVED_VIRTUAL_IDS.CONFIG?generateConfigModule(t,n):null},handleHotUpdate({file:e,server:n}){if(e.includes(t.pagesDir)){let e=n.moduleGraph.getModuleById(RESOLVED_VIRTUAL_IDS.PAGE_ROUTES);e&&n.moduleGraph.invalidateModule(e)}if(e.includes(`vite.config`)||e.includes(`avalon.config`)||e.includes(`nitro.config`)){let e=n.moduleGraph.getModuleById(RESOLVED_VIRTUAL_IDS.CONFIG);e&&n.moduleGraph.invalidateModule(e)}}}}function k(e,t,n,r){e.watcher.on(`change`,e=>{e.includes(`_middleware`)&&(f(),r?.()),(e.includes(`/render/`)||e.includes(`/layout/`)||e.includes(`/islands/`))&&(F=null,I=null),(e.includes(`/layouts/`)||e.includes(`_layout`))&&globalThis.__avalonLayoutResolver?.clearCache?.()}),e.watcher.on(`add`,e=>{e.includes(`_middleware`)&&(f(),r?.())}),e.watcher.on(`unlink`,e=>{e.includes(`_middleware`)&&(f(),r?.())})}async function A(e,t){try{let{getAllPageDirs:t}=await import(`./module-discovery.js`),{discoverPageRoutesFromMultipleDirs:n}=await import(`../nitro/route-discovery.js`),r=await n(await t(e.pagesDir,e.modules,process.cwd()),{developmentMode:e.isDev});return`export const pageRoutes = ${JSON.stringify(r,null,2)};\nexport default pageRoutes;\n`}catch{return`export const pageRoutes = [];
|
|
2
|
+
export default pageRoutes;
|
|
3
|
+
`}}function j(){return`export const islandManifest = { islands: {}, clientEntry: "", css: [] };
|
|
4
|
+
export default islandManifest;
|
|
5
|
+
`}function M(e,t){let n={avalon:{streaming:t.streaming??!0,pagesDir:e.pagesDir,layoutsDir:e.layoutsDir,isDev:e.isDev},...t.runtimeConfig};return`export const runtimeConfig = ${JSON.stringify(n,null,2)};\nexport function useRuntimeConfig() { return runtimeConfig; }\nexport default runtimeConfig;\n`}export function generateConfigModule(e,t){let n={streaming:t.streaming??!0,pagesDir:e.pagesDir,layoutsDir:e.layoutsDir,isDev:e.isDev,...t.runtimeConfig};return`const config = ${JSON.stringify(n,null,2)};\nexport function useAvalonConfig() { return config; }\nexport default config;\n`}export function getViteDevServer(){return globalThis.__viteDevServer}export function getAvalonConfig(){return globalThis.__avalonConfig}export function isDevelopmentMode(){return globalThis.__avalonConfig?.isDev??!0}const P=`<!--AVALON_STREAM_BOUNDARY-->`;let F=null,I=null;async function L(e,t,n,r){if(!n.modules)return!1;let i=t.split(`?`)[0],a=await H(i,n,e);if(!a)return!1;try{let t=await e.ssrLoadModule(a),n=t.default;if(!n)return!1;let o=t.layoutConfig,s=await h(e,a),c=await V(i,e),l=[];for(let t of c){let n=await e.ssrLoadModule(t);l.push({file:t,module:n})}for(let t of c){let n=await h(e,t);s.push(...n)}if(l.length===0)return!1;let{render:u}=await e.ssrLoadModule(`preact-render-to-string`),{h:d}=await e.ssrLoadModule(`preact`),f=o?.skipLayouts||[],p=l.filter(({file:e})=>{let t=e.split(`/`).pop()?.replace(/\.[^.]+$/,``)||``;return!f.includes(t)}),m=t.frontmatter,g=t.metadata,y={children:null,frontmatter:{...m,...g,currentPath:i},params:{},url:i},b=[],x=[];for(let e of p){let t=e.module.default;if(!(!t||typeof t!=`function`))try{let n=t({...y,children:d(`div`,null,`test`)}),r=u(n instanceof Promise?await n:n);r.trim().startsWith(`<html`)||r.includes(`<!DOCTYPE`)?b.push(e):x.push(e)}catch{x.push(e)}}if(b.length===0)return!1;let{module:S}=b[b.length-1],C=S.default;if(!C||typeof C!=`function`)return!1;let w;try{let e=C({...y,children:d(`div`,{dangerouslySetInnerHTML:{__html:P}})});w=u(e instanceof Promise?await e:e)}catch{return!1}let T=w.indexOf(P);if(T===-1)return!1;let E=w.slice(0,T),D=w.slice(T+29),O=E;if(s.length>0){let e=`<style data-avalon-ssr-css>${s.join(`
|
|
6
|
+
`)}</style>`;O=E.includes(`</head>`)?E.replace(`</head>`,`${e}\n</head>`):E+e}O.trim().toLowerCase().startsWith(`<!doctype`)||(O=`<!DOCTYPE html>
|
|
7
|
+
`+O);let k=_(!0);k&&O.includes(`</head>`)&&(O=O.replace(`</head>`,`${k}\n</head>`));let A=v(!0);A&&O.includes(`</head>`)&&(O=O.replace(`</head>`,`${A}\n</head>`)),r.statusCode=200,r.setHeader(`Content-Type`,`text/html; charset=utf-8`),r.setHeader(`Transfer-Encoding`,`chunked`),r.setHeader(`X-Avalon-Streaming`,`1`),r.flushHeaders(),r.write(O);let j;try{let e=typeof n==`function`?n():n;j=u(e instanceof Promise?await e:e)}catch(e){console.error(`[SSR Streaming] Error rendering page component:`,e),j=`<div>Error rendering page</div>`}if(j.trim().startsWith(`<!DOCTYPE html>`)||j.trim().startsWith(`<html`))return r.end(j),!0;let M=j;for(let{module:e}of x){let t=e.default;if(!(!t||typeof t!=`function`))try{let e=t({...y,children:d(`div`,{dangerouslySetInnerHTML:{__html:M}})});M=u(e instanceof Promise?await e:e)}catch(e){console.error(`[SSR Streaming] Error rendering wrapper layout:`,e)}}let N=M+D;if(!N.includes(`/src/client/main.js`)&&!N.includes(`/@vite/client`)){let e=N.lastIndexOf(`</body>`);e!==-1&&(N=N.slice(0,e)+`
|
|
8
|
+
<script type="module" src="/@vite/client"><\/script>
|
|
9
|
+
<script type="module" src="/src/client/main.js"><\/script>
|
|
10
|
+
`+N.slice(e))}return r.end(N),!0}catch(e){return r.headersSent?(r.end(`<div>Streaming SSR error: ${e.message}</div></body></html>`),!0):!1}}async function R(e,t,n){let r=t.split(`?`)[0],i=await H(r,n,e);if(!i)return null;try{let t=await e.ssrLoadModule(i),a=t.default;if(!a)return console.warn(`[SSR] Page ${i} has no default export`),null;let o=await h(e,i),s=await V(r,e),c=[];for(let t of s){let n=await e.ssrLoadModule(t);c.push({file:t,module:n})}for(let t of s){let n=await h(e,t);o.push(...n)}let l;return l=n.modules&&c.length>0?await z(a,t,c,r,n,e):await U(a,t,r,n,e),o.length>0&&(l=g(l,o)),l}catch(e){throw console.error(`[SSR] Error rendering ${i}:`,e),e}}async function z(e,t,n,r,i,a){let{render:o}=await a.ssrLoadModule(`preact-render-to-string`),{h:s}=await a.ssrLoadModule(`preact`),c=t.layoutConfig?.skipLayouts||[],l=n.filter(({file:e})=>{let t=e.split(`/`).pop()?.replace(/\.[^.]+$/,``)||``;return!c.includes(t)}),u;try{let t=typeof e==`function`?e():e;u=o(t instanceof Promise?await t:t)}catch(e){console.error(`[SSR] Error rendering page component:`,e),u=`<div>Error rendering page</div>`}if(u.trim().startsWith(`<!DOCTYPE html>`)||u.trim().startsWith(`<html`))return B(u);let d=t.frontmatter,f=t.metadata,p={children:null,frontmatter:{...d,...f,currentPath:r},params:{},url:r},m=[],h=[];for(let e of l){let t=e.module.default;if(!(!t||typeof t!=`function`))try{let n=t({...p,children:s(`div`,null,`test`)}),r=o(n instanceof Promise?await n:n);r.trim().startsWith(`<html`)||r.includes(`<!DOCTYPE`)?m.push(e):h.push(e)}catch{h.push(e)}}let g=u;for(let{module:e}of h){let t=e.default;if(!(!t||typeof t!=`function`))try{let e=t({...p,children:s(`div`,{dangerouslySetInnerHTML:{__html:g}})});g=o(e instanceof Promise?await e:e)}catch(e){console.error(`[SSR] Error rendering wrapper layout:`,e)}}if(m.length>0){let{module:e}=m[m.length-1],t=e.default;if(t&&typeof t==`function`)try{let e=t({...p,children:s(`div`,{dangerouslySetInnerHTML:{__html:g}})});g=o(e instanceof Promise?await e:e)}catch(e){console.error(`[SSR] Error rendering shell layout:`,e)}}if(g.trim().startsWith(`<!DOCTYPE html>`)||g.trim().startsWith(`<html`))return B(g);let _=t.metadata||{},v=_.title||`Avalon App`,y=_.description||``;return`<!DOCTYPE html>
|
|
11
|
+
<html lang="en">
|
|
12
|
+
<head>
|
|
13
|
+
<meta charset="utf-8">
|
|
14
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
15
|
+
<title>${W(v)}</title>
|
|
16
|
+
${y?`<meta name="description" content="${W(y)}">`:``}
|
|
17
|
+
<script type="module" src="/@vite/client"><\/script>
|
|
18
|
+
</head>
|
|
19
|
+
<body>
|
|
20
|
+
${g}
|
|
21
|
+
<script type="module" src="/src/client/main.js"><\/script>
|
|
22
|
+
</body>
|
|
23
|
+
</html>`}function B(e){let t=e;if(t.trim().toLowerCase().startsWith(`<!doctype`)||(t=`<!DOCTYPE html>
|
|
24
|
+
`+t),!t.includes(`data-universal-ssr="true"`)){let e=_(!0);e&&t.includes(`</head>`)&&(t=t.replace(`</head>`,`${e}\n</head>`))}let n=v(!0);if(n&&t.includes(`</head>`)&&(t=t.replace(`</head>`,`${n}\n</head>`)),t.includes(`/src/client/main.js`)||t.includes(`/@vite/client`))return t;let r=t.lastIndexOf(`</body>`);return r===-1?t+`
|
|
25
|
+
<script type="module" src="/@vite/client"><\/script>
|
|
26
|
+
<script type="module" src="/src/client/main.js"><\/script>`:t.slice(0,r)+`
|
|
27
|
+
<script type="module" src="/@vite/client"><\/script>
|
|
28
|
+
<script type="module" src="/src/client/main.js"><\/script>
|
|
29
|
+
`+t.slice(r)}async function V(e,n){let r=n.config.root||process.cwd(),i=globalThis.__avalonConfig,a=`_layout.tsx`,o=[],s=e.split(`/`).filter(Boolean),c=[``];for(let e=0;e<s.length;e++)c.push(`/`+s.slice(0,e+1).join(`/`));async function l(e){try{if((await t(e)).isFile()){let t=e.slice(r.length);o.includes(t)||o.push(t)}}catch{}}if(i?.layoutsDir&&await l(`${`${r}/${i.layoutsDir}`}/${a}`),i?.modules){let e=`${r}/${i.modules.dir}`,t=i.modules.layoutsDirName,n=s[0]||``,o=[`home`,`root`,`main`,`index`];if(!n||o.includes(n.toLowerCase()))for(let n of o)await l(`${e}/${n}/${t}/${a}`);else await l(`${e}/${n}/${t}/${a}`)}let u=`${r}/src/layouts`;for(let e of c)await l(e===``?`${u}/${a}`:`${u}${e}/${a}`);return o}async function H(e,n,r){let i=e;i.endsWith(`/`)&&i!==`/`&&(i=i.slice(0,-1)),i===`/`&&(i=`/index`);let a=[`.tsx`,`.ts`,`.jsx`,`.js`,`.mdx`,`.md`],o=r.config.root||process.cwd();async function s(e){try{if((await t(`${o}/${e}`)).isFile())return`/${e}`}catch{}return null}if(n.modules){let t=n.modules.dir,r=n.modules.pagesDirName,o=e.split(`/`).filter(Boolean),c=o[0]||``,l=[`home`,`root`,`main`,`index`],u,d;if(!c||l.includes(c.toLowerCase()))u=`home`,d=i;else{u=c;let e=o.slice(1);d=e.length>0?`/`+e.join(`/`):`/index`}for(let e of a){let n=await s(`${t}/${u}/${r}${d}${e}`);if(n)return n}if(!d.endsWith(`/index`))for(let e of a){let n=await s(`${t}/${u}/${r}${d}/index${e}`);if(n)return n}}let c=n.pagesDir;for(let e of a){let t=await s(`${c}${i}${e}`);if(t)return t}if(!i.endsWith(`/index`))for(let e of a){let t=await s(`${c}${i}/index${e}`);if(t)return t}return null}async function U(e,t,n,r,i){let a=t.metadata||{};try{F||=await i.ssrLoadModule(y(`src/render/ssr.ts`));let o=F;I||=await i.ssrLoadModule(y(`src/core/layout/enhanced-layout-resolver.ts`));let s=I,c={component:()=>typeof e==`function`?e():e,options:{title:a.title||`Avalon App`},frontmatter:t.frontmatter};if(o.renderToHtmlWithLayouts&&s.EnhancedLayoutResolver&&s.EnhancedLayoutResolverUtils)try{let e=i.config.root||process.cwd();if(!globalThis.__avalonLayoutResolver){let t=s.EnhancedLayoutResolver,n=r.layoutsDir||`src/layouts`;globalThis.__avalonLayoutResolver=new t({baseDirectory:`${e}/${n}`,filePattern:`_layout.tsx`,excludeDirectories:[`node_modules`,`.git`,`dist`,`build`],enableWatching:!0,developmentMode:!1,enableCaching:!0,cacheTTL:60*1e3,maxCacheSize:100,enableStreaming:!0,enableErrorBoundaries:!0,enableMetrics:!1,enableDebugInfo:!1,modulesDir:r.modules?`${e}/${r.modules.dir}`:void 0,modulesLayoutsDirName:r.modules?.layoutsDirName})}let t=`http://localhost${n}`,l={params:{},query:{},url:t,request:{method:`GET`,url:t,headers:new Headers}};return await o.renderToHtmlWithLayouts(c,globalThis.__avalonLayoutResolver,l,n,{title:a.title||`Avalon App`},void 0,{suppressWarnings:!0})}catch{}if(o.renderToHtml)return await o.renderToHtml(c,{title:a.title||`Avalon App`},void 0,{suppressWarnings:!0})}catch{}let o=a.title||`Avalon App`,s=a.description||``,c=``;try{let t=await i.ssrLoadModule(`preact-render-to-string`);t.render&&typeof e==`function`&&(c=t.render(e()))}catch{c=`<p>Loading page: ${W(n)}</p>`}return`<!DOCTYPE html>
|
|
30
|
+
<html lang="en">
|
|
31
|
+
<head>
|
|
32
|
+
<meta charset="utf-8">
|
|
33
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
34
|
+
<title>${W(o)}</title>
|
|
35
|
+
${s?`<meta name="description" content="${W(s)}">`:``}
|
|
36
|
+
<script type="module" src="/@vite/client"><\/script>
|
|
37
|
+
</head>
|
|
38
|
+
<body>
|
|
39
|
+
<div id="app">${c}</div>
|
|
40
|
+
<script type="module" src="/src/client/main.js"><\/script>
|
|
41
|
+
</body>
|
|
42
|
+
</html>`}function W(e){return e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`"`,`"`).replaceAll(`'`,`'`)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as e}from"node:module";import{dirname as t,join as n}from"node:path";import{resolveConfig as r,checkDirectoriesExist as i}from"./config.js";import{activateIntegrations as a,activateSingleIntegration as o}from"./integration-activator.js";import{discoverIntegrationsFromIslandUsage as s}from"./auto-discover.js";import{validateActiveIntegrations as c,formatValidationResults as l}from"./validation.js";import{createMDXPlugin as u}from"../build/mdx-plugin.js";import{mdxIslandTransform as d}from"../build/mdx-island-transform.js";import{pageIslandTransform as f}from"../build/page-island-transform.js";import{registry as p}from"../core/integrations/registry.js";import{createNitroIntegration as m}from"./nitro-integration.js";import{islandSidecarPlugin as h}from"./island-sidecar-plugin.js";import{createImagePlugin as g}from"./image-optimization.js";export async function collectIntegrationPlugins(e,t=!1){let n=[],r=[];for(let i of e){let e=await _(i,t);i===`lit`?r.push(...e):n.push(...e)}return[...r,...n]}async function _(e,t){let n=p.get(e);if(!n||typeof n.vitePlugin!=`function`)return[];try{let e=await n.vitePlugin();return(Array.isArray(e)?e:[e]).filter(e=>e!=null)}catch(t){return console.warn(`[avalon] Failed to load vite plugin for ${e}:`,t instanceof Error?t.message:t),[]}}async function v(e,t){let n=new Set;try{let r=await s(e.pagesDir,e.layoutsDir,t,e.modules?.dir);for(let t of r)e.integrations.includes(t)&&n.add(t)}catch{for(let t of e.integrations)n.add(t)}return n}async function y(e){if(!e.lazyIntegrations||e.integrations.length===0)return[...e.integrations];let t=await v(e);return t.size===0?[...e.integrations]:Array.from(t)}async function b(e){try{let t=await u({jsxImportSource:e.mdx.jsxImportSource,syntaxHighlighting:e.mdx.syntaxHighlighting,remarkPlugins:e.mdx.remarkPlugins,rehypePlugins:e.mdx.rehypePlugins,development:!0});return t.push(d({verbose:e.verbose})),t}catch(t){return e.showWarnings&&console.warn(`⚠️ Could not configure MDX plugin:`,t),[]}}function x(e,t,n){let{plugins:r,nitroOptions:i}=m(e,t);return globalThis.__nitroConfig=i,{plugins:r,options:i}}async function S(e,t,n){if(e.autoDiscoverIntegrations)try{let r=await s(e.pagesDir,e.layoutsDir,t,e.modules?.dir);for(let t of r)if(!n.has(t))try{await o(t,n,e.verbose)}catch(n){e.showWarnings&&console.warn(` ⚠️ Could not auto-load integration: ${t}`,n)}}catch(t){e.showWarnings&&console.warn(` ⚠️ Auto-discovery failed:`,t)}}function C(e,t){if(!e.validateIntegrations||t.size===0)return;let n=c(t,e.showWarnings);n.allValid||(console.error(l(n)),e.showWarnings&&console.warn(` ⚠️ Some integrations have validation issues.`))}export async function avalon(o){let s,c,l=new Set,u=r(o,!0),d=await y(u);d.length>0&&await a({...u,integrations:d},l);let p=await b(u),m=await g(u.image,u.verbose),_=[];l.size>0&&(_=await collectIntegrationPlugins(l,u.verbose));let v=[];if(o?.nitro){let{plugins:e}=x(u,o.nitro,u.verbose);v=e}let w=h({verbose:u.verbose}),T=e(import.meta.url),E=null;try{E=n(t(T.resolve(`@useavalon/avalon/client`)),`main.js`)}catch{}let D=new Set([`preact`,`react`,`vue`,`svelte`,`solid`,`lit`,`qwik`].flatMap(e=>[`/@useavalon/${e}/client`,`/@useavalon/${e}/client/hmr`])),O={name:`avalon`,enforce:`pre`,config(){return{oxc:{exclude:[/node_modules\/@useavalon\/.*\.tsx?$/]},ssr:{noExternal:[/^@useavalon\//]}}},configResolved(e){c=e,s=r(o,e.command===`serve`),globalThis.__avalonConfig=s,i(s,e.root)},async resolveId(e){if(e===`/src/client/main.js`&&E)return E;if(D.has(e)){let t=e.slice(1);return(await this.resolve(t))?.id??null}return null},async transform(e,t){if(this.environment?.config?.consumer===`server`&&t.includes(`@useavalon/`)&&/\.tsx?$/.test(t)){let{transform:n}=await import(`oxc-transform`),r=await n(t,e,{sourcemap:!0,typescript:{onlyRemoveTypeImports:!1}});return{code:r.code,map:r.map,moduleType:`js`}}},async buildStart(){await S(s,c?.root,l),C(s,l)},configureServer(e){globalThis.__viteDevServer=e}},k=_.filter(e=>e.name?.includes(`lit`)),A=_.filter(e=>!e.name?.includes(`lit`));return[f({pagesDir:u.pagesDir,layoutsDir:u.layoutsDir,modules:u.modules,verbose:u.verbose}),...m,...k,...p,O,w,...v,...A]}export function getResolvedConfig(){return globalThis.__avalonConfig}export function getPagesDir(){return globalThis.__avalonConfig?.pagesDir??`src/pages`}export function getLayoutsDir(){return globalThis.__avalonConfig?.layoutsDir??`src/layouts`}export function getNitroConfig(){return globalThis.__nitroConfig}export function isNitroEnabled(){return globalThis.__nitroConfig!==void 0}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{registry as e}from"../core/integrations/registry.js";export function validateIntegration(e){if(e==null)return{integration:`unknown`,valid:!1,errors:[`Integration is null or undefined`],warnings:[]};if(typeof e!=`object`)return{integration:`unknown`,valid:!1,errors:[`Integration must be an object, got ${typeof e}`],warnings:[]};let t=e,i=[],a=[];return n(t,`name`,i),n(t,`version`,i),r(t,`render`,i),r(t,`getHydrationScript`,i),r(t,`config`,i),t.vitePlugin!==void 0&&typeof t.vitePlugin!=`function`&&a.push(`'vitePlugin' should be a function if provided, got ${typeof t.vitePlugin}`),{integration:typeof t.name==`string`?t.name:`unknown`,valid:i.length===0,errors:i,warnings:a}}function n(e,t,n){let r=e[t];typeof r==`string`?r.trim()===``&&n.push(`'${t}' property cannot be empty`):n.push(r===void 0?`Missing required '${t}' property`:`Invalid '${t}' property: expected string, got ${typeof r}`)}function r(e,t,n){typeof e[t]!=`function`&&n.push(e[t]===void 0?`Missing required '${t}' method`:`Invalid '${t}' method: expected function, got ${typeof e[t]}`)}export function validateActiveIntegrations(n,r=!0){let i=[],a=0,o=0;for(let s of n){let n=e.get(s);if(!n){i.push({integration:s,valid:!1,errors:[`Integration '${s}' is marked as active but not found in registry`],warnings:[]}),a++;continue}let c=validateIntegration(n);i.push(c),a+=c.errors.length,r&&(o+=c.warnings.length)}return{allValid:a===0,results:i,totalErrors:a,totalWarnings:r?o:0}}export function formatValidationResults(e){if(e.allValid&&e.totalWarnings===0)return`✅ All ${e.results.length} integration(s) passed validation`;let t=[];e.allValid||t.push(`❌ Integration validation failed with ${e.totalErrors} error(s)`),e.totalWarnings>0&&t.push(`⚠️ ${e.totalWarnings} warning(s) found`),t.push(``);for(let n of e.results)if(n.errors.length>0||n.warnings.length>0){t.push(`Integration: ${n.integration}`);for(let e of n.errors)t.push(` ❌ ${e}`);for(let e of n.warnings)t.push(` ⚠️ ${e}`);t.push(``)}return t.join(`
|
|
2
|
+
`)}export function validateIntegrationByName(n){let r=e.get(n);return r?validateIntegration(r):null}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useavalon/avalon",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "Multi-framework islands architecture for the modern web",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -10,14 +10,24 @@
|
|
|
10
10
|
"directory": "packages/avalon"
|
|
11
11
|
},
|
|
12
12
|
"homepage": "https://useavalon.dev",
|
|
13
|
-
"keywords": [
|
|
13
|
+
"keywords": [
|
|
14
|
+
"avalon",
|
|
15
|
+
"islands",
|
|
16
|
+
"ssr",
|
|
17
|
+
"vite",
|
|
18
|
+
"preact",
|
|
19
|
+
"multi-framework",
|
|
20
|
+
"hydration"
|
|
21
|
+
],
|
|
14
22
|
"scripts": {
|
|
15
23
|
"build:client": "bun run scripts/build-client.ts",
|
|
16
|
-
"
|
|
24
|
+
"build": "bun run scripts/build.ts",
|
|
25
|
+
"prepublishOnly": "bun run build"
|
|
17
26
|
},
|
|
18
27
|
"exports": {
|
|
19
28
|
".": "./mod.ts",
|
|
20
29
|
"./client": "./src/client/components.ts",
|
|
30
|
+
"./client/hmr": "./src/client/framework-adapter.ts",
|
|
21
31
|
"./islands/framework-detection": "./src/islands/framework-detection.ts",
|
|
22
32
|
"./middleware": "./src/middleware/index.ts",
|
|
23
33
|
"./nitro/renderer": "./src/nitro/renderer.ts",
|
|
@@ -28,12 +38,33 @@
|
|
|
28
38
|
},
|
|
29
39
|
"typesVersions": {
|
|
30
40
|
"*": {
|
|
31
|
-
"types": [
|
|
41
|
+
"types": [
|
|
42
|
+
"./src/types/index.d.ts"
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"files": [
|
|
47
|
+
"dist/**/*.js",
|
|
48
|
+
"dist/**/*.d.ts",
|
|
49
|
+
"README.md"
|
|
50
|
+
],
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"exports": {
|
|
53
|
+
".": "./dist/mod.js",
|
|
54
|
+
"./client": "./dist/src/client/components.js",
|
|
55
|
+
"./client/hmr": "./dist/src/client/framework-adapter.js",
|
|
56
|
+
"./islands/framework-detection": "./dist/src/islands/framework-detection.js",
|
|
57
|
+
"./middleware": "./dist/src/middleware/index.js",
|
|
58
|
+
"./nitro/renderer": "./dist/src/nitro/renderer.js",
|
|
59
|
+
"./nitro/types": "./dist/src/nitro/types.js",
|
|
60
|
+
"./nitro/config": "./dist/src/nitro/config.js",
|
|
61
|
+
"./types/island-jsx": "./dist/src/types/island-jsx.d.ts",
|
|
62
|
+
"./types": "./dist/src/types/index.d.ts"
|
|
32
63
|
}
|
|
33
64
|
},
|
|
34
|
-
"files": ["mod.ts", "src/**/*.ts", "src/**/*.tsx", "src/**/*.js", "src/**/*.d.ts", "!src/**/*.test.ts", "!src/**/tests/**", "!src/**/__tests__/**", "!src/**/README.md", "README.md"],
|
|
35
65
|
"devDependencies": {
|
|
36
|
-
"@types/mime-types": "^3.0.1"
|
|
66
|
+
"@types/mime-types": "^3.0.1",
|
|
67
|
+
"oxc-minify": "^0.120.0"
|
|
37
68
|
},
|
|
38
69
|
"peerDependencies": {
|
|
39
70
|
"vite": "^8.0.0",
|
|
@@ -42,25 +73,25 @@
|
|
|
42
73
|
},
|
|
43
74
|
"peerDependenciesMeta": {
|
|
44
75
|
"nitro": {
|
|
45
|
-
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
78
|
+
"vite-imagetools": {
|
|
79
|
+
"optional": true
|
|
80
|
+
}
|
|
46
81
|
},
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"remark-mdx-frontmatter": "^5.0.0",
|
|
63
|
-
"unified": "^11.0.0",
|
|
64
|
-
"zod": "4.3.6"
|
|
65
|
-
}
|
|
82
|
+
"dependencies": {
|
|
83
|
+
"@useavalon/core": "^0.1.3",
|
|
84
|
+
"@mdx-js/rollup": "^3.0.0",
|
|
85
|
+
"h3": "^2.0.1-rc.16",
|
|
86
|
+
"marked": "^17.0.4",
|
|
87
|
+
"oxc-transform": "^0.117.0",
|
|
88
|
+
"preact": "10.28.4",
|
|
89
|
+
"preact-render-to-string": "6.6.6",
|
|
90
|
+
"rehype-highlight": "^7.0.0",
|
|
91
|
+
"remark-frontmatter": "^5.0.0",
|
|
92
|
+
"remark-gfm": "^4.0.0",
|
|
93
|
+
"remark-mdx-frontmatter": "^5.0.0",
|
|
94
|
+
"unified": "^11.0.0",
|
|
95
|
+
"zod": "^4.3.6"
|
|
96
|
+
}
|
|
66
97
|
}
|