@useavalon/avalon 0.1.18 → 0.1.19
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/src/client/components.js +1 -1
- package/dist/src/client/types/framework-runtime.d.ts +68 -68
- package/dist/src/client/types/vite-hmr.d.ts +46 -46
- package/dist/src/client/types/vite-virtual-modules.d.ts +70 -70
- package/dist/src/layout-system.d.ts +592 -592
- package/dist/src/types/image.d.ts +106 -106
- package/dist/src/types/index.d.ts +22 -22
- package/dist/src/types/island-jsx.d.ts +33 -33
- package/dist/src/types/island-prop.d.ts +20 -20
- package/dist/src/types/mdx.d.ts +6 -6
- package/dist/src/types/urlpattern.d.ts +49 -49
- package/dist/src/types/vite-env.d.ts +11 -11
- package/package.json +4 -1
- package/dist/src/client/adapters/lit-adapter.js +0 -1
- package/dist/src/client/adapters/preact-adapter.js +0 -1
- package/dist/src/client/adapters/qwik-adapter.js +0 -1
- package/dist/src/client/adapters/react-adapter.js +0 -1
- package/dist/src/client/adapters/solid-adapter.js +0 -1
- package/dist/src/client/adapters/svelte-adapter.js +0 -1
- package/dist/src/client/adapters/vue-adapter.js +0 -1
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type declarations for image imports with vite-imagetools
|
|
3
|
-
*
|
|
4
|
-
* These types enable TypeScript support for optimized image imports.
|
|
5
|
-
* Include this in your tsconfig.json `types` array:
|
|
6
|
-
*
|
|
7
|
-
* ```json
|
|
8
|
-
* {
|
|
9
|
-
* "compilerOptions": {
|
|
10
|
-
* "types": ["@useavalon/avalon/types"]
|
|
11
|
-
* }
|
|
12
|
-
* }
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
declare module "*.jpg" {
|
|
17
|
-
const src: string;
|
|
18
|
-
export default src;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
declare module "*.jpeg" {
|
|
22
|
-
const src: string;
|
|
23
|
-
export default src;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
declare module "*.png" {
|
|
27
|
-
const src: string;
|
|
28
|
-
export default src;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
declare module "*.webp" {
|
|
32
|
-
const src: string;
|
|
33
|
-
export default src;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
declare module "*.avif" {
|
|
37
|
-
const src: string;
|
|
38
|
-
export default src;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
declare module "*.gif" {
|
|
42
|
-
const src: string;
|
|
43
|
-
export default src;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
declare module "*.tiff" {
|
|
47
|
-
const src: string;
|
|
48
|
-
export default src;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
declare module "*.svg" {
|
|
52
|
-
const src: string;
|
|
53
|
-
export default src;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// vite-imagetools srcset output
|
|
57
|
-
interface ImageToolsSrcset {
|
|
58
|
-
src: string;
|
|
59
|
-
srcset: string;
|
|
60
|
-
width: number;
|
|
61
|
-
height: number;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
declare module "*&as=srcset" {
|
|
65
|
-
const srcset: ImageToolsSrcset;
|
|
66
|
-
export default srcset;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
declare module "*?as=srcset" {
|
|
70
|
-
const srcset: ImageToolsSrcset;
|
|
71
|
-
export default srcset;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// vite-imagetools picture output (multiple formats)
|
|
75
|
-
interface ImageToolsPicture {
|
|
76
|
-
sources: Record<string, ImageToolsSrcset>;
|
|
77
|
-
img: ImageToolsSrcset;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
declare module "*&as=picture" {
|
|
81
|
-
const picture: ImageToolsPicture;
|
|
82
|
-
export default picture;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
declare module "*?as=picture" {
|
|
86
|
-
const picture: ImageToolsPicture;
|
|
87
|
-
export default picture;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// vite-imagetools metadata output
|
|
91
|
-
interface ImageToolsMetadata {
|
|
92
|
-
src: string;
|
|
93
|
-
width: number;
|
|
94
|
-
height: number;
|
|
95
|
-
format: string;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
declare module "*&as=metadata" {
|
|
99
|
-
const metadata: ImageToolsMetadata;
|
|
100
|
-
export default metadata;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
declare module "*?as=metadata" {
|
|
104
|
-
const metadata: ImageToolsMetadata;
|
|
105
|
-
export default metadata;
|
|
106
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Type declarations for image imports with vite-imagetools
|
|
3
|
+
*
|
|
4
|
+
* These types enable TypeScript support for optimized image imports.
|
|
5
|
+
* Include this in your tsconfig.json `types` array:
|
|
6
|
+
*
|
|
7
|
+
* ```json
|
|
8
|
+
* {
|
|
9
|
+
* "compilerOptions": {
|
|
10
|
+
* "types": ["@useavalon/avalon/types"]
|
|
11
|
+
* }
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
declare module "*.jpg" {
|
|
17
|
+
const src: string;
|
|
18
|
+
export default src;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare module "*.jpeg" {
|
|
22
|
+
const src: string;
|
|
23
|
+
export default src;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare module "*.png" {
|
|
27
|
+
const src: string;
|
|
28
|
+
export default src;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare module "*.webp" {
|
|
32
|
+
const src: string;
|
|
33
|
+
export default src;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare module "*.avif" {
|
|
37
|
+
const src: string;
|
|
38
|
+
export default src;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
declare module "*.gif" {
|
|
42
|
+
const src: string;
|
|
43
|
+
export default src;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
declare module "*.tiff" {
|
|
47
|
+
const src: string;
|
|
48
|
+
export default src;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare module "*.svg" {
|
|
52
|
+
const src: string;
|
|
53
|
+
export default src;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// vite-imagetools srcset output
|
|
57
|
+
interface ImageToolsSrcset {
|
|
58
|
+
src: string;
|
|
59
|
+
srcset: string;
|
|
60
|
+
width: number;
|
|
61
|
+
height: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
declare module "*&as=srcset" {
|
|
65
|
+
const srcset: ImageToolsSrcset;
|
|
66
|
+
export default srcset;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
declare module "*?as=srcset" {
|
|
70
|
+
const srcset: ImageToolsSrcset;
|
|
71
|
+
export default srcset;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// vite-imagetools picture output (multiple formats)
|
|
75
|
+
interface ImageToolsPicture {
|
|
76
|
+
sources: Record<string, ImageToolsSrcset>;
|
|
77
|
+
img: ImageToolsSrcset;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
declare module "*&as=picture" {
|
|
81
|
+
const picture: ImageToolsPicture;
|
|
82
|
+
export default picture;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
declare module "*?as=picture" {
|
|
86
|
+
const picture: ImageToolsPicture;
|
|
87
|
+
export default picture;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// vite-imagetools metadata output
|
|
91
|
+
interface ImageToolsMetadata {
|
|
92
|
+
src: string;
|
|
93
|
+
width: number;
|
|
94
|
+
height: number;
|
|
95
|
+
format: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
declare module "*&as=metadata" {
|
|
99
|
+
const metadata: ImageToolsMetadata;
|
|
100
|
+
export default metadata;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
declare module "*?as=metadata" {
|
|
104
|
+
const metadata: ImageToolsMetadata;
|
|
105
|
+
export default metadata;
|
|
106
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Avalon type definitions.
|
|
3
|
-
*
|
|
4
|
-
* Include this in your tsconfig.json `types` array to get island prop support:
|
|
5
|
-
*
|
|
6
|
-
* ```json
|
|
7
|
-
* {
|
|
8
|
-
* "compilerOptions": {
|
|
9
|
-
* "types": ["@useavalon/avalon/types"]
|
|
10
|
-
* }
|
|
11
|
-
* }
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
// Re-export island prop types
|
|
16
|
-
export * from './island-prop.d.ts';
|
|
17
|
-
|
|
18
|
-
// Import JSX augmentations (side-effect import for type augmentation)
|
|
19
|
-
import './island-jsx.d.ts';
|
|
20
|
-
|
|
21
|
-
// Import image type declarations
|
|
22
|
-
import './image.d.ts';
|
|
1
|
+
/**
|
|
2
|
+
* Avalon type definitions.
|
|
3
|
+
*
|
|
4
|
+
* Include this in your tsconfig.json `types` array to get island prop support:
|
|
5
|
+
*
|
|
6
|
+
* ```json
|
|
7
|
+
* {
|
|
8
|
+
* "compilerOptions": {
|
|
9
|
+
* "types": ["@useavalon/avalon/types"]
|
|
10
|
+
* }
|
|
11
|
+
* }
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
// Re-export island prop types
|
|
16
|
+
export * from './island-prop.d.ts';
|
|
17
|
+
|
|
18
|
+
// Import JSX augmentations (side-effect import for type augmentation)
|
|
19
|
+
import './island-jsx.d.ts';
|
|
20
|
+
|
|
21
|
+
// Import image type declarations
|
|
22
|
+
import './image.d.ts';
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JSX augmentation for the `island` prop.
|
|
3
|
-
*
|
|
4
|
-
* Automatically included via tsconfig.json `compilerOptions.types`.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { IslandDirective } from './island-prop.d.ts';
|
|
8
|
-
|
|
9
|
-
declare module 'preact' {
|
|
10
|
-
namespace JSX {
|
|
11
|
-
interface IntrinsicAttributes {
|
|
12
|
-
island?: IslandDirective;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// Augment the global JSX namespace so the `island` prop is accepted on
|
|
18
|
-
// non-Preact components (Svelte, Solid) when used in a Preact JSX context.
|
|
19
|
-
declare global {
|
|
20
|
-
namespace JSX {
|
|
21
|
-
interface IntrinsicAttributes {
|
|
22
|
-
island?: IslandDirective;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Augment Vue's ComponentCustomProps so Volar accepts `island` on all Vue SFCs.
|
|
28
|
-
declare module '@vue/runtime-core' {
|
|
29
|
-
interface ComponentCustomProps {
|
|
30
|
-
island?: IslandDirective;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
1
|
+
/**
|
|
2
|
+
* JSX augmentation for the `island` prop.
|
|
3
|
+
*
|
|
4
|
+
* Automatically included via tsconfig.json `compilerOptions.types`.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { IslandDirective } from './island-prop.d.ts';
|
|
8
|
+
|
|
9
|
+
declare module 'preact' {
|
|
10
|
+
namespace JSX {
|
|
11
|
+
interface IntrinsicAttributes {
|
|
12
|
+
island?: IslandDirective;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Augment the global JSX namespace so the `island` prop is accepted on
|
|
18
|
+
// non-Preact components (Svelte, Solid) when used in a Preact JSX context.
|
|
19
|
+
declare global {
|
|
20
|
+
namespace JSX {
|
|
21
|
+
interface IntrinsicAttributes {
|
|
22
|
+
island?: IslandDirective;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Augment Vue's ComponentCustomProps so Volar accepts `island` on all Vue SFCs.
|
|
28
|
+
declare module '@vue/runtime-core' {
|
|
29
|
+
interface ComponentCustomProps {
|
|
30
|
+
island?: IslandDirective;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type augmentation for the `island` prop on island components.
|
|
3
|
-
*
|
|
4
|
-
* When importing a component from the islands directory and using it in a page,
|
|
5
|
-
* you can pass an `island` prop to control hydration behavior. The Vite transform
|
|
6
|
-
* plugin intercepts this at build time and converts it to a renderIsland() call.
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* import Counter from '../islands/Counter.tsx';
|
|
10
|
-
* <Counter island={{ condition: 'on:interaction' }} someProp={42} />
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
export interface IslandDirective {
|
|
14
|
-
/** Hydration condition */
|
|
15
|
-
condition?: 'on:visible' | 'on:interaction' | 'on:idle' | 'on:client' | `media:${string}`;
|
|
16
|
-
/** Force SSR-only rendering without client hydration */
|
|
17
|
-
ssrOnly?: boolean;
|
|
18
|
-
/** Whether to render server-side (default: true) */
|
|
19
|
-
ssr?: boolean;
|
|
20
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Type augmentation for the `island` prop on island components.
|
|
3
|
+
*
|
|
4
|
+
* When importing a component from the islands directory and using it in a page,
|
|
5
|
+
* you can pass an `island` prop to control hydration behavior. The Vite transform
|
|
6
|
+
* plugin intercepts this at build time and converts it to a renderIsland() call.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* import Counter from '../islands/Counter.tsx';
|
|
10
|
+
* <Counter island={{ condition: 'on:interaction' }} someProp={42} />
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export interface IslandDirective {
|
|
14
|
+
/** Hydration condition */
|
|
15
|
+
condition?: 'on:visible' | 'on:interaction' | 'on:idle' | 'on:client' | `media:${string}`;
|
|
16
|
+
/** Force SSR-only rendering without client hydration */
|
|
17
|
+
ssrOnly?: boolean;
|
|
18
|
+
/** Whether to render server-side (default: true) */
|
|
19
|
+
ssr?: boolean;
|
|
20
|
+
}
|
package/dist/src/types/mdx.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ComponentType } from 'preact';
|
|
2
|
-
|
|
3
|
-
declare module '*.mdx' {
|
|
4
|
-
const MDXComponent: ComponentType<Record<string, unknown>>;
|
|
5
|
-
export default MDXComponent;
|
|
6
|
-
}
|
|
1
|
+
import type { ComponentType } from 'preact';
|
|
2
|
+
|
|
3
|
+
declare module '*.mdx' {
|
|
4
|
+
const MDXComponent: ComponentType<Record<string, unknown>>;
|
|
5
|
+
export default MDXComponent;
|
|
6
|
+
}
|
|
@@ -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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useavalon/avalon",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"description": "Multi-framework islands architecture for the modern web",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -62,6 +62,9 @@
|
|
|
62
62
|
"nitro": {
|
|
63
63
|
"optional": true
|
|
64
64
|
},
|
|
65
|
+
"vite": {
|
|
66
|
+
"optional": true
|
|
67
|
+
},
|
|
65
68
|
"vite-imagetools": {
|
|
66
69
|
"optional": true
|
|
67
70
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{BaseFrameworkAdapter as e}from"../framework-adapter.js";export class LitHMRAdapter extends e{name=`lit`;elementConstructors=new WeakMap;tagNames=new WeakMap;canHandle(e){if(!e)return!1;if(typeof e==`function`){let t=e;if(t.__litElement)return!0;try{let t=e.prototype;if(t){if(`render`in t&&`requestUpdate`in t&&`updateComplete`in t)return!0;let e=t;for(;e&&e!==Object.prototype;){let t=e.constructor;if(t&&t.name===`LitElement`)return!0;e=Object.getPrototypeOf(e)}}}catch{}if(t.elementName||t.tagName)return!0;try{let t=e.toString();if(t.includes(`LitElement`)||t.includes(`customElement`)||t.includes("html`")||t.includes("css`")||t.includes(`render()`)||t.includes(`requestUpdate`))return!0}catch{}}if(typeof e!=`object`)return!1;let t=e;return t.default&&typeof t.default==`function`?this.canHandle(t.default):!!t.__litElement}preserveState(e){try{let t=super.preserveState(e);if(!t)return null;let n=e.getAttribute(`data-props`),r=n?JSON.parse(n):{},i=e.getAttribute(`data-src`)||``,a=this.extractComponentName(i),o=e.getAttribute(`data-tag-name`)||this.tagNames.get(e),s=o?e.querySelector(o):e.querySelector(`[data-lit-element]`),c={},l={};if(s){for(let e in s)if(s.hasOwnProperty(e)&&!e.startsWith(`_`))try{let t=s[e];t!=null&&typeof t!=`function`&&typeof t!=`symbol`&&(c[e]=t)}catch{}for(let e=0;e<s.attributes.length;e++){let t=s.attributes[e];l[t.name]=t.value}}return{...t,framework:`lit`,data:{componentName:a,tagName:o||void 0,capturedProps:r,elementProperties:c,elementAttributes:l}}}catch(e){return console.warn(`Failed to preserve Lit state:`,e),null}}async update(e,t,n){if(!this.canHandle(t))throw Error(`Component is not a valid Lit component`);let r;if(typeof t==`object`&&t){let e=t;if(e.default&&typeof e.default==`function`)r=e.default;else throw Error(`Lit component object must have a default export`)}else if(typeof t==`function`)r=t;else throw Error(`Invalid Lit component type`);try{let t=e.getAttribute(`data-tag-name`);if(t||=r.elementName,t||=r.name.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),!t||!t.includes(`-`))throw Error(`Invalid custom element tag name: `+t);this.tagNames.set(e,t),e.setAttribute(`data-tag-name`,t);let i=Array.from(e.querySelectorAll(t));if(i.length===0){let i=customElements.get(t);i?i!==r&&await this.reregisterCustomElement(t,r):customElements.define(t,r);let a=document.createElement(t);Object.entries(n).forEach(([e,t])=>{try{a[e]=t}catch(t){console.warn(`Failed to set property ${e} on Lit element:`,t)}}),e.appendChild(a),this.elementConstructors.set(e,r),e.setAttribute(`data-hydrated`,`true`),e.setAttribute(`data-hydration-status`,`success`);return}let a=customElements.get(t);if(a&&a!==r){await this.reregisterCustomElement(t,r);for(let e of i){let n={},r={};for(let t in e)if(e.hasOwnProperty(t)&&!t.startsWith(`_`))try{let r=e[t];r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&(n[t]=r)}catch{}for(let t=0;t<e.attributes.length;t++){let n=e.attributes[t];r[n.name]=n.value}let i=document.createElement(t);Object.entries(r).forEach(([e,t])=>{i.setAttribute(e,t)}),Object.entries(n).forEach(([e,t])=>{try{i[e]=t}catch(t){console.warn(`Failed to restore property ${e}:`,t)}}),e.parentNode?.replaceChild(i,e)}}else if(a)for(let e of i)Object.entries(n).forEach(([t,n])=>{try{e[t]=n}catch(e){console.warn(`Failed to update property ${t}:`,e)}}),e.requestUpdate&&e.requestUpdate();else{customElements.define(t,r);for(let e of i)e.requestUpdate&&e.requestUpdate()}this.elementConstructors.set(e,r),e.setAttribute(`data-hydrated`,`true`),e.setAttribute(`data-hydration-status`,`success`)}catch(t){throw console.error(`Lit HMR update failed:`,t),e.setAttribute(`data-hydration-status`,`error`),t}}async reregisterCustomElement(e,t){console.warn(`Custom element ${e} is already defined. Replacing all instances with new definition.`)}restoreState(e,t){try{super.restoreState(e,t);let n=t,r=n.data.tagName;if(r){let t=e.querySelector(r);t&&(n.data.elementProperties&&Object.entries(n.data.elementProperties).forEach(([e,n])=>{try{t[e]=n}catch(t){console.warn(`Failed to restore property ${e}:`,t)}}),n.data.elementAttributes&&Object.entries(n.data.elementAttributes).forEach(([e,n])=>{try{t.setAttribute(e,n)}catch(t){console.warn(`Failed to restore attribute ${e}:`,t)}}),t.requestUpdate&&t.requestUpdate())}}catch(e){console.warn(`Failed to restore Lit state:`,e)}}handleError(e,t){console.error(`Lit HMR error:`,t),super.handleError(e,t);let n=e.querySelector(`.hmr-error-indicator`);if(n){let e=t.message,r=``;e.includes(`custom element`)||e.includes(`define`)?r=` (Hint: Check that your element has a valid tag name with a hyphen)`:e.includes(`tag name`)?r=` (Hint: Custom element tag names must contain a hyphen)`:e.includes(`property`)||e.includes(`attribute`)?r=` (Hint: Check @property decorators and attribute names)`:e.includes(`render`)?r=` (Hint: Check the render() method for errors)`:e.includes(`shadow`)&&(r=` (Hint: Check Shadow DOM usage and styles)`),n.textContent=`Lit HMR Error: ${e}${r}`}}extractComponentName(e){let t=e.split(`/`);return t[t.length-1].replace(/\.lit\.(ts|js)$/,``).replace(/\.(ts|js)$/,``)}unmount(e){try{let t=this.tagNames.get(e);t&&(e.querySelectorAll(t).forEach(e=>{e.remove()}),this.tagNames.delete(e)),this.elementConstructors.delete(e)}catch(e){console.warn(`Failed to unmount Lit element:`,e)}}}export const litAdapter=new LitHMRAdapter;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{BaseFrameworkAdapter as e}from"../framework-adapter.js";export class PreactHMRAdapter extends e{name=`preact`;instances=new WeakMap;canHandle(e){if(!e)return!1;if(typeof e==`function`){let t=e,n=e.prototype;return n&&n.isReactComponent||t.$typeof,!0}if(typeof e!=`object`)return!1;let t=e;return!!(t.$typeof||t.type&&typeof t.type==`function`)}preserveState(e){try{let t=super.preserveState(e);if(!t)return null;let n=e.getAttribute(`data-props`),r=n?JSON.parse(n):{},i=e.getAttribute(`data-src`)||``,a=this.extractComponentName(i);return{...t,framework:`preact`,data:{componentName:a,capturedProps:r}}}catch(e){return console.warn(`Failed to preserve Preact state:`,e),null}}async update(e,t,n){if(!this.canHandle(t))throw Error(`Component is not a valid Preact component`);let r=t;try{let{h:t,hydrate:i}=await import(`preact`);this.instances.get(e)?i(t(r,n),e):(i(t(r,n),e),this.instances.set(e,r)),e.setAttribute(`data-hydrated`,`true`),e.setAttribute(`data-hydration-status`,`success`)}catch(t){throw console.error(`Preact HMR update failed:`,t),e.setAttribute(`data-hydration-status`,`error`),t}}restoreState(e,t){try{super.restoreState(e,t)}catch(e){console.warn(`Failed to restore Preact state:`,e)}}handleError(e,t){console.error(`Preact HMR error:`,t),super.handleError(e,t);let n=e.querySelector(`.hmr-error-indicator`);if(n){let e=t.message,r=``;e.includes(`hooks`)?r=` (Hint: Check hooks usage - hooks must be called in the same order)`:e.includes(`render`)?r=` (Hint: Check component render method for errors)`:(e.includes(`hydration`)||e.includes(`hydrate`))&&(r=` (Hint: Server and client render must match)`),n.textContent=`Preact HMR Error: ${e}${r}`}}extractComponentName(e){let t=e.split(`/`);return t[t.length-1].replace(/\.(tsx?|jsx?)$/,``)}unmount(e){if(this.instances.get(e))try{this.instances.delete(e),e.innerHTML=``}catch(e){console.warn(`Failed to unmount Preact component:`,e)}}}export const preactAdapter=new PreactHMRAdapter;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{BaseFrameworkAdapter as e}from"../framework-adapter.js";export class QwikHMRAdapter extends e{name=`qwik`;containers=new WeakMap;canHandle(e){if(!e)return!1;if(typeof e==`function`){let t=e;if(t.__brand===`QwikComponent`||t.__qrl||t.getSymbol||t.getHash)return!0;try{let t=e.toString();if(t.includes(`component$`)||t.includes(`qrl`)||t.includes(`useSignal`)||t.includes(`useStore`)||t.includes(`useTask$`)||t.includes(`useVisibleTask$`)||t.includes(`_qrl`)||t.includes(`qwik`))return!0}catch{}}if(typeof e==`object`&&e){let t=e;if(t.default&&typeof t.default==`function`)return this.canHandle(t.default);if(t.__qrl||t.__brand===`QwikComponent`)return!0}return!1}preserveState(e){try{let t=super.preserveState(e);if(!t)return null;let n=e.getAttribute(`data-props`),r=n?JSON.parse(n):{},i=e.getAttribute(`data-src`)||``,a=this.extractComponentName(i),o=e.closest(`[q\\:container]`)||e,s=o.querySelector(`script[type="qwik/json"]`)?.textContent||null,c={},l=o.attributes;if(l)for(let e=0;e<l.length;e++){let t=l[e];t.name.startsWith(`q:`)&&(c[t.name]=t.value)}return{...t,framework:`qwik`,data:{componentName:a,capturedProps:r,containerState:s,qContainerAttrs:c}}}catch(e){return console.warn(`Failed to preserve Qwik state:`,e),null}}async update(e,t,n){if(!this.canHandle(t))throw Error(`Component is not a valid Qwik component`);let r;if(typeof t==`object`&&t){let e=t;if(e.default&&typeof e.default==`function`)r=e.default;else throw Error(`Qwik component object must have a default export`)}else if(typeof t==`function`)r=t;else throw Error(`Invalid Qwik component type`);try{let t=this.containers.get(e);if(t?.cleanup)try{t.cleanup()}catch(e){console.warn(`Failed to clean up existing Qwik container:`,e)}let i=await import(`@builder.io/qwik`);if(i.render){let t=typeof i.jsx==`function`?i.jsx(r,n):r(n);await i.render(e,t)}else{console.warn(`Qwik render API not available, using innerHTML fallback`);let t=r(n);typeof t==`string`&&(e.innerHTML=t)}this.containers.set(e,{}),e.setAttribute(`data-hydrated`,`true`),e.setAttribute(`data-hydration-status`,`success`)}catch(t){throw console.error(`Qwik HMR update failed:`,t),e.setAttribute(`data-hydration-status`,`error`),t}}restoreState(e,t){try{super.restoreState(e,t)}catch(e){console.warn(`Failed to restore Qwik state:`,e)}}handleError(e,t){console.error(`Qwik HMR error:`,t),super.handleError(e,t);let n=e.querySelector(`.hmr-error-indicator`);if(n){let e=t.message,r=``;e.includes(`component$`)||e.includes(`component\\$`)?r=` (Hint: Ensure component is wrapped with component$())`:e.includes(`useSignal`)||e.includes(`useStore`)?r=` (Hint: Qwik hooks must be called inside component$() body)`:e.includes(`QRL`)||e.includes(`qrl`)?r=` (Hint: Check that lazy-loaded boundaries use $ correctly)`:e.includes(`serialize`)||e.includes(`container`)?r=` (Hint: Ensure all state is serializable — Qwik serializes state to the DOM)`:(e.includes(`resumable`)||e.includes(`resume`))&&(r=` (Hint: Server and client container state must match for resumability)`),n.textContent=`Qwik HMR Error: ${e}${r}`}}extractComponentName(e){let t=e.split(`/`);return t[t.length-1].replace(/\.qwik\.(tsx?|jsx?)$/,``).replace(/\.(tsx?|jsx?)$/,``)}unmount(e){let t=this.containers.get(e);if(t)try{t.cleanup&&t.cleanup(),this.containers.delete(e)}catch(e){console.warn(`Failed to unmount Qwik component:`,e)}}}export const qwikAdapter=new QwikHMRAdapter;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{BaseFrameworkAdapter as e}from"../framework-adapter.js";export class ReactHMRAdapter extends e{name=`react`;roots=new WeakMap;canHandle(e){if(!e)return!1;if(typeof e==`function`){let t=e,n=e.prototype;return n&&n.isReactComponent||t.$$typeof,!0}if(typeof e!=`object`)return!1;let t=e;return!!(t.$$typeof||t.type&&typeof t.type==`function`)}preserveState(e){try{let t=super.preserveState(e);if(!t)return null;let n=e.getAttribute(`data-props`),r=n?JSON.parse(n):{},i=e.getAttribute(`data-src`)||``,a=this.extractComponentName(i);return{...t,framework:`react`,data:{componentName:a,capturedProps:r}}}catch(e){return console.warn(`Failed to preserve React state:`,e),null}}async update(e,t,n){if(!this.canHandle(t))throw Error(`Component is not a valid React component`);let r=t;try{let[t,i]=await Promise.all([import(`react`),import(`react-dom/client`)]),{createElement:a}=t,{hydrateRoot:o}=i,s=this.roots.get(e);if(s){let e=a(r,n);s.render(e)}else{let t=o(e,a(r,n),{onRecoverableError:e=>{console.warn(`React hydration recoverable error during HMR:`,e)}});this.roots.set(e,t)}e.setAttribute(`data-hydrated`,`true`),e.setAttribute(`data-hydration-status`,`success`)}catch(t){throw console.error(`React HMR update failed:`,t),e.setAttribute(`data-hydration-status`,`error`),t}}restoreState(e,t){try{super.restoreState(e,t)}catch(e){console.warn(`Failed to restore React state:`,e)}}handleError(e,t){console.error(`React HMR error:`,t),super.handleError(e,t);let n=e.querySelector(`.hmr-error-indicator`);if(n){let e=t.message,r=``;e.includes(`hooks`)?r=` (Hint: Check hooks usage - hooks must be called in the same order)`:e.includes(`render`)?r=` (Hint: Check component render method for errors)`:e.includes(`hydration`)&&(r=` (Hint: Server and client render must match)`),n.textContent=`React HMR Error: ${e}${r}`}}extractComponentName(e){let t=e.split(`/`);return t[t.length-1].replace(/\.(tsx?|jsx?)$/,``)}unmount(e){let t=this.roots.get(e);if(t)try{t.unmount(),this.roots.delete(e)}catch(e){console.warn(`Failed to unmount React root:`,e)}}}export const reactAdapter=new ReactHMRAdapter;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{BaseFrameworkAdapter as e}from"../framework-adapter.js";export class SolidHMRAdapter extends e{name=`solid`;disposers=new WeakMap;componentIds=new WeakMap;canHandle(e){if(!e)return!1;if(typeof e==`function`){if(e.__solid)return!0;try{let t=e.toString();if(t.includes(`createSignal`)||t.includes(`createEffect`)||t.includes(`createMemo`)||t.includes(`createResource`)||t.includes(`createStore`)||t.includes(`_$`)||t.includes(`_tmpl$`))return!0}catch{}return!0}if(typeof e!=`object`)return!1;let t=e;return t.default&&typeof t.default==`function`?this.canHandle(t.default):!!t.__solid}preserveState(e){try{let t=super.preserveState(e);if(!t)return null;let n=e.getAttribute(`data-props`),r=n?JSON.parse(n):{},i=e.getAttribute(`data-src`)||``,a=this.extractComponentName(i),o=e.dataset.solidRenderId||e.dataset.renderId;return{...t,framework:`solid`,data:{componentName:a,capturedProps:r,renderId:o}}}catch(e){return console.warn(`Failed to preserve Solid state:`,e),null}}async update(e,t,n){if(!this.canHandle(t))throw Error(`Component is not a valid Solid component`);let r;if(typeof t==`object`&&t){let e=t;if(e.default&&typeof e.default==`function`)r=e.default;else throw Error(`Solid component object must have a default export`)}else if(typeof t==`function`)r=t;else throw Error(`Invalid Solid component type`);try{let t=this.disposers.get(e),i=this.componentIds.get(e),a=globalThis.__SOLID_HMR__;if(a&&i)try{if(a.reload(i,r),t)return}catch(e){console.warn(`Solid HMR runtime reload failed, falling back to full remount:`,e)}if(t)try{t(),this.disposers.delete(e)}catch(e){console.warn(`Failed to dispose existing Solid component:`,e)}let{hydrate:o,createComponent:s}=await import(`solid-js/web`),c=o(()=>s(r,n),e,{renderId:e.dataset.solidRenderId||e.dataset.renderId});this.disposers.set(e,c);let l=e.getAttribute(`data-src`)||``,u=this.generateComponentId(l);if(this.componentIds.set(e,u),a)try{a.createRecord(u,r)}catch(e){console.warn(`Failed to register with Solid HMR runtime:`,e)}e.setAttribute(`data-hydrated`,`true`),e.setAttribute(`data-hydration-status`,`success`)}catch(t){throw console.error(`Solid HMR update failed:`,t),e.setAttribute(`data-hydration-status`,`error`),t}}restoreState(e,t){try{super.restoreState(e,t)}catch(e){console.warn(`Failed to restore Solid state:`,e)}}handleError(e,t){console.error(`Solid HMR error:`,t),super.handleError(e,t);let n=e.querySelector(`.hmr-error-indicator`);if(n){let e=t.message,r=``;e.includes(`signal`)||e.includes(`Signal`)?r=` (Hint: Check signal usage - signals must be called as functions)`:e.includes(`effect`)||e.includes(`Effect`)?r=` (Hint: Check effect usage - effects run after render)`:e.includes(`hydration`)||e.includes(`hydrate`)?r=` (Hint: Server and client render must match)`:e.includes(`createSignal`)||e.includes(`createEffect`)?r=` (Hint: Solid primitives must be called inside component functions)`:e.includes(`reactive`)&&(r=` (Hint: Check reactive dependencies - they must be accessed inside tracking scopes)`),n.textContent=`Solid HMR Error: ${e}${r}`}}extractComponentName(e){let t=e.split(`/`);return t[t.length-1].replace(/\.solid\.(tsx?|jsx?)$/,``).replace(/\.(tsx?|jsx?)$/,``)}generateComponentId(e){return e.replace(/[^a-zA-Z0-9]/g,`_`)}unmount(e){let t=this.disposers.get(e);if(t)try{t(),this.disposers.delete(e),this.componentIds.delete(e)}catch(e){console.warn(`Failed to unmount Solid component:`,e)}}}export const solidAdapter=new SolidHMRAdapter;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{BaseFrameworkAdapter as e}from"../framework-adapter.js";export class SvelteHMRAdapter extends e{name=`svelte`;instances=new WeakMap;componentIds=new WeakMap;storeSubscriptions=new WeakMap;isSvelteFunction(e){if(e.$$render)return!0;let t=e.prototype;if(t&&(t.$set&&t.$destroy||t.$$))return!0;try{let t=e.toString();if(t.includes(`$set`)||t.includes(`$destroy`)||t.includes(`$$`))return!0}catch{}return!1}canHandle(e){if(!e)return!1;if(typeof e==`function`)return this.isSvelteFunction(e);if(typeof e!=`object`)return!1;let t=e;return t.default&&typeof t.default==`function`?this.canHandle(t.default):t.$$render!==void 0}preserveState(e){try{let t=super.preserveState(e);if(!t)return null;let n=e.dataset.props,r=n?JSON.parse(n):{},i=e.dataset.src||``,a=this.extractComponentName(i),o=this.captureLocalState(e),s=this.captureStoreValues(e);return{...t,framework:`svelte`,data:{componentName:a,capturedProps:r,localState:o,storeValues:s}}}catch(e){return console.warn(`Failed to preserve Svelte state:`,e),null}}extractComponent(e){if(typeof e==`object`&&e){let t=e;if(t.default&&typeof t.default==`function`)return t.default;throw Error(`Svelte component object must have a default export`)}if(typeof e==`function`)return e;throw TypeError(`Invalid Svelte component type`)}async cleanupInstance(e,t){try{let n=this.storeSubscriptions.get(e);n&&(n.forEach(e=>e()),this.storeSubscriptions.delete(e));let r=(await import(`svelte`)).unmount;r?r(t):t.$destroy&&t.$destroy()}catch{t.$destroy&&t.$destroy()}}async mountComponent(e,t,n){try{let r=(await import(`svelte`)).mount;return r?r(e,{target:t,props:n}):new e({target:t,props:n,hydrate:!1,intro:!1})}catch(r){return console.debug(`Svelte 5 API not available, using constructor API:`,r),new e({target:t,props:n,hydrate:!1,intro:!1})}}async update(e,t,n){if(!this.canHandle(t))throw Error(`Component is not a valid Svelte component`);let r=this.extractComponent(t);try{let t=this.instances.get(e);t&&await this.cleanupInstance(e,t).catch(e=>{console.warn(`Failed to destroy existing Svelte instance:`,e)}),e.innerHTML=``;let i=await this.mountComponent(r,e,n);this.instances.set(e,i);let a=e.dataset.src||``;this.componentIds.set(e,this.generateComponentId(a)),e.dataset.hydrated=`true`,e.dataset.hydrationStatus=`success`}catch(t){throw console.error(`Svelte HMR update failed:`,t),e.dataset.hydrationStatus=`error`,t}}restoreState(e,t){try{super.restoreState(e,t)}catch(e){console.warn(`Failed to restore Svelte state:`,e)}}handleError(e,t){console.error(`Svelte HMR error:`,t),super.handleError(e,t);let n=e.querySelector(`.hmr-error-indicator`);if(n){let e=t.message,r=``;e.includes(`$:`)||e.includes(`reactive`)?r=` (Hint: Check reactive statements ($:) - they must be at component top level)`:e.includes(`store`)?r=` (Hint: Check store usage - stores must be imported and subscribed correctly)`:e.includes(`hydration`)||e.includes(`hydrate`)?r=` (Hint: Server and client render must match)`:e.includes(`target`)?r=` (Hint: Check component target - it must be a valid DOM element)`:e.includes(`props`)&&(r=` (Hint: Check component props - they must match the component definition)`),n.textContent=`Svelte HMR Error: ${e}${r}`}}extractComponentName(e){return(e.split(`/`).at(-1)??``).replace(/\.svelte$/,``)}detectSSRContent(e){let t=e.textContent&&e.textContent.trim().length>0,n=e.children&&e.children.length>0,r=e.dataset.ssrContent!==void 0||e.dataset.svelteRendered!==void 0;return t||n||r}generateComponentId(e){return e.replaceAll(/[^a-zA-Z0-9]/g,`_`)}captureLocalState(e){try{let t=this.instances.get(e);if(!t)return;let n=t.$$;return n?.ctx?{ctx:n.ctx,props:n.props,bound:n.bound}:void 0}catch(e){console.debug(`Could not capture Svelte local state:`,e);return}}captureStoreValues(e){}async unmount(e){let t=this.instances.get(e);if(t)try{await this.cleanupInstance(e,t),this.instances.delete(e),this.componentIds.delete(e)}catch(e){console.warn(`Failed to unmount Svelte component:`,e)}}}export const svelteAdapter=new SvelteHMRAdapter;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{BaseFrameworkAdapter as e}from"../framework-adapter.js";export class VueHMRAdapter extends e{name=`vue`;apps=new WeakMap;componentIds=new WeakMap;canHandle(e){if(!e)return!1;if(typeof e==`function`)return!0;if(typeof e!=`object`)return!1;let t=e;return`setup`in t||`data`in t||`render`in t||`template`in t||`props`in t||`computed`in t||`methods`in t||`components`in t||`emits`in t||`mounted`in t||`created`in t||`beforeMount`in t||`beforeCreate`in t||`__vccOpts`in t}preserveState(e){try{let t=super.preserveState(e);if(!t)return null;let n=e.getAttribute(`data-props`),r=n?JSON.parse(n):{},i=e.getAttribute(`data-src`)||``,a=this.extractComponentName(i),o=this.captureReactiveData(e);return{...t,framework:`vue`,data:{componentName:a,capturedProps:r,reactiveData:o}}}catch(e){return console.warn(`Failed to preserve Vue state:`,e),null}}async update(e,t,n){if(!this.canHandle(t))throw Error(`Component is not a valid Vue component`);let r=t;try{let{createApp:t}=await import(`vue`),i=this.apps.get(e),a=this.componentIds.get(e),o=globalThis.__VUE_HMR_RUNTIME__;if(o&&a)try{if(o.reload(a,r),i)return}catch(e){console.warn(`Vue HMR runtime reload failed, falling back to full remount:`,e)}if(i)try{i.unmount()}catch(e){console.warn(`Failed to unmount existing Vue app:`,e)}let s=t(r,n);s.config.errorHandler=(e,t,n)=>{console.error(`Vue component error during HMR:`,e,n)},s.mount(e,!0),this.apps.set(e,s);let c=e.getAttribute(`data-src`)||``,l=this.generateComponentId(c);this.componentIds.set(e,l),o&&o.createRecord(l,r),e.setAttribute(`data-hydrated`,`true`),e.setAttribute(`data-hydration-status`,`success`)}catch(t){throw console.error(`Vue HMR update failed:`,t),e.setAttribute(`data-hydration-status`,`error`),t}}restoreState(e,t){try{super.restoreState(e,t)}catch(e){console.warn(`Failed to restore Vue state:`,e)}}handleError(e,t){console.error(`Vue HMR error:`,t),super.handleError(e,t);let n=e.querySelector(`.hmr-error-indicator`);if(n){let e=t.message,r=``;e.includes(`reactive`)||e.includes(`ref`)?r=` (Hint: Check reactive state usage - refs must be accessed with .value)`:e.includes(`render`)?r=` (Hint: Check component render function or template for errors)`:e.includes(`hydration`)||e.includes(`mismatch`)?r=` (Hint: Server and client render must match)`:e.includes(`setup`)&&(r=` (Hint: Check setup function - it should return render function or object)`),n.textContent=`Vue HMR Error: ${e}${r}`}}extractComponentName(e){let t=e.split(`/`);return t[t.length-1].replace(/\.(vue|tsx?|jsx?)$/,``)}generateComponentId(e){return e.replace(/[^a-zA-Z0-9]/g,`_`)}captureReactiveData(e){try{let t=e.__vueParentComponent;if(t&&typeof t==`object`){let e=t.data;if(e&&typeof e==`object`)return{...e}}}catch(e){console.debug(`Could not capture Vue reactive data:`,e)}}unmount(e){let t=this.apps.get(e);if(t)try{t.unmount(),this.apps.delete(e),this.componentIds.delete(e)}catch(e){console.warn(`Failed to unmount Vue app:`,e)}}}export const vueAdapter=new VueHMRAdapter;
|