@emberkit/core 0.2.0 → 0.2.3
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/LICENSE +199 -0
- package/dist/boundaries/error-boundary.d.ts +29 -0
- package/dist/boundaries/error-boundary.d.ts.map +1 -0
- package/dist/boundaries/errors.d.ts +39 -0
- package/dist/boundaries/errors.d.ts.map +1 -0
- package/dist/boundaries/index.d.ts +5 -0
- package/dist/boundaries/index.d.ts.map +1 -0
- package/dist/boundaries/loading-boundary.d.ts +42 -0
- package/dist/boundaries/loading-boundary.d.ts.map +1 -0
- package/dist/cache/index.d.ts +60 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +24 -22
- package/dist/compiler/compiler.d.ts +6 -0
- package/dist/compiler/compiler.d.ts.map +1 -0
- package/dist/compiler/helpers/attributes.d.ts +4 -0
- package/dist/compiler/helpers/attributes.d.ts.map +1 -0
- package/dist/compiler/helpers/utils.d.ts +10 -0
- package/dist/compiler/helpers/utils.d.ts.map +1 -0
- package/dist/compiler/index.d.ts +5 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/types.d.ts +40 -0
- package/dist/compiler/types.d.ts.map +1 -0
- package/dist/context/index.d.ts +34 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/types.d.ts +10 -0
- package/dist/context/types.d.ts.map +1 -0
- package/dist/dev-server/index.d.ts +30 -0
- package/dist/dev-server/index.d.ts.map +1 -0
- package/dist/dev-server/index.js +27 -27
- package/dist/forms/index.d.ts +58 -0
- package/dist/forms/index.d.ts.map +1 -0
- package/dist/forms/index.js +1 -1
- package/dist/forms/mutations.d.ts +48 -0
- package/dist/forms/mutations.d.ts.map +1 -0
- package/dist/forms/mutations.js +4 -1
- package/dist/hmr/client.d.ts +18 -0
- package/dist/hmr/client.d.ts.map +1 -0
- package/dist/hmr/client.js +1 -1
- package/dist/hmr/index.d.ts +3 -0
- package/dist/hmr/index.d.ts.map +1 -0
- package/dist/hmr/types.d.ts +42 -0
- package/dist/hmr/types.d.ts.map +1 -0
- package/dist/hmr/types.js +7 -7
- package/dist/hydration/helpers/analyzer.d.ts +9 -0
- package/dist/hydration/helpers/analyzer.d.ts.map +1 -0
- package/dist/hydration/helpers/hydration.d.ts +19 -0
- package/dist/hydration/helpers/hydration.d.ts.map +1 -0
- package/dist/hydration/helpers/hydration.js +1 -1
- package/dist/hydration/index.d.ts +4 -0
- package/dist/hydration/index.d.ts.map +1 -0
- package/dist/hydration/types.d.ts +27 -0
- package/dist/hydration/types.d.ts.map +1 -0
- package/dist/hydration/types.js +32 -8
- package/dist/image/index.d.ts +9 -0
- package/dist/image/index.d.ts.map +1 -0
- package/dist/image/index.js +1 -1
- package/dist/image/processor.d.ts +57 -0
- package/dist/image/processor.d.ts.map +1 -0
- package/dist/image/processor.js +20 -15
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -2
- package/dist/jsx-dev-runtime.d.ts +11 -0
- package/dist/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/jsx-runtime.d.ts +11 -0
- package/dist/jsx-runtime.d.ts.map +1 -0
- package/dist/loader/helpers/loader.d.ts +6 -0
- package/dist/loader/helpers/loader.d.ts.map +1 -0
- package/dist/loader/index.d.ts +3 -0
- package/dist/loader/index.d.ts.map +1 -0
- package/dist/loader/types.d.ts +34 -0
- package/dist/loader/types.d.ts.map +1 -0
- package/dist/markdown/index.d.ts +77 -0
- package/dist/markdown/index.d.ts.map +1 -0
- package/dist/markdown/index.js +178 -172
- package/dist/mdx/index.d.ts +43 -0
- package/dist/mdx/index.d.ts.map +1 -0
- package/dist/mdx/index.js +46 -40
- package/dist/mdx/loader.d.ts +3 -0
- package/dist/mdx/loader.d.ts.map +1 -0
- package/dist/meta/head-registry.d.ts +5 -0
- package/dist/meta/head-registry.d.ts.map +1 -0
- package/dist/meta/head.d.ts +29 -0
- package/dist/meta/head.d.ts.map +1 -0
- package/dist/meta/index.d.ts +91 -0
- package/dist/meta/index.d.ts.map +1 -0
- package/dist/meta/index.js +16 -16
- package/dist/navigation/helpers/navigation.d.ts +15 -0
- package/dist/navigation/helpers/navigation.d.ts.map +1 -0
- package/dist/navigation/helpers/navigation.js +4 -4
- package/dist/navigation/helpers/useNavigate.d.ts +6 -0
- package/dist/navigation/helpers/useNavigate.d.ts.map +1 -0
- package/dist/navigation/index.d.ts +5 -0
- package/dist/navigation/index.d.ts.map +1 -0
- package/dist/navigation/types.d.ts +24 -0
- package/dist/navigation/types.d.ts.map +1 -0
- package/dist/navigation/types.js +1 -2
- package/dist/plugin/index.d.ts +73 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +4 -4
- package/dist/router/helpers/path.d.ts +15 -0
- package/dist/router/helpers/path.d.ts.map +1 -0
- package/dist/router/helpers/route.d.ts +6 -0
- package/dist/router/helpers/route.d.ts.map +1 -0
- package/dist/router/helpers/route.js +10 -3
- package/dist/router/index.d.ts +35 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/types.d.ts +30 -0
- package/dist/router/types.d.ts.map +1 -0
- package/dist/router/types.js +1 -3
- package/dist/runtime/helpers/element.d.ts +7 -0
- package/dist/runtime/helpers/element.d.ts.map +1 -0
- package/dist/runtime/helpers/render.d.ts +8 -0
- package/dist/runtime/helpers/render.d.ts.map +1 -0
- package/dist/runtime/helpers/render.js +37 -8
- package/dist/runtime/index.d.ts +16 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +63 -7
- package/dist/runtime/types.d.ts +65 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/signals/helpers/core.d.ts +11 -0
- package/dist/signals/helpers/core.d.ts.map +1 -0
- package/dist/signals/helpers/core.js +34 -12
- package/dist/signals/helpers/utils.d.ts +7 -0
- package/dist/signals/helpers/utils.d.ts.map +1 -0
- package/dist/signals/index.d.ts +4 -0
- package/dist/signals/index.d.ts.map +1 -0
- package/dist/signals/types.d.ts +23 -0
- package/dist/signals/types.d.ts.map +1 -0
- package/dist/ssg/index.d.ts +38 -0
- package/dist/ssg/index.d.ts.map +1 -0
- package/dist/ssg/index.js +8 -15
- package/dist/ssr/helpers/render-html.d.ts +16 -0
- package/dist/ssr/helpers/render-html.d.ts.map +1 -0
- package/dist/ssr/helpers/render-html.js +3 -2
- package/dist/ssr/helpers/ssr.d.ts +14 -0
- package/dist/ssr/helpers/ssr.d.ts.map +1 -0
- package/dist/ssr/helpers/ssr.js +3 -1
- package/dist/ssr/index.d.ts +4 -0
- package/dist/ssr/index.d.ts.map +1 -0
- package/dist/ssr/types.d.ts +29 -0
- package/dist/ssr/types.d.ts.map +1 -0
- package/dist/vite-plugin/index.d.ts +5 -0
- package/dist/vite-plugin/index.d.ts.map +1 -0
- package/dist/vite-plugin/index.js +207 -28
- package/dist/vite-plugin/types.d.ts +44 -0
- package/dist/vite-plugin/types.d.ts.map +1 -0
- package/dist/vite-plugin/types.js +4 -0
- package/package.json +12 -10
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface DevServerOptions {
|
|
2
|
+
port?: number;
|
|
3
|
+
host?: string;
|
|
4
|
+
cors?: boolean;
|
|
5
|
+
hmr?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface ServerStats {
|
|
8
|
+
uptime: number;
|
|
9
|
+
requests: number;
|
|
10
|
+
errors: number;
|
|
11
|
+
memoryUsage: NodeJS.MemoryUsage;
|
|
12
|
+
}
|
|
13
|
+
export declare class DevServer {
|
|
14
|
+
private errorCount;
|
|
15
|
+
private readonly options;
|
|
16
|
+
private requestCount;
|
|
17
|
+
private server;
|
|
18
|
+
private startTime;
|
|
19
|
+
constructor(options?: DevServerOptions);
|
|
20
|
+
getStats(): ServerStats;
|
|
21
|
+
start(): Promise<void>;
|
|
22
|
+
stop(): Promise<void>;
|
|
23
|
+
private createRequestHandler;
|
|
24
|
+
private generateHTML;
|
|
25
|
+
private handleRequest;
|
|
26
|
+
private handleWebSocket;
|
|
27
|
+
private sendError;
|
|
28
|
+
}
|
|
29
|
+
export declare function createDevServer(options?: DevServerOptions): Promise<DevServer>;
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dev-server/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC;CACjC;AAED,qBAAa,SAAS;IACpB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IACrD,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,MAAM,CAAsC;IACpD,OAAO,CAAC,SAAS,CAAK;gBAEV,OAAO,GAAE,gBAAqB;IAS1C,QAAQ,IAAI,WAAW;IASjB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAqBtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAkB3B,OAAO,CAAC,oBAAoB;YAcd,YAAY;YAeZ,aAAa;IA+B3B,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,SAAS;CAIlB;AAED,wBAAsB,eAAe,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAIpF"}
|
package/dist/dev-server/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export class DevServer {
|
|
2
|
-
|
|
2
|
+
errorCount = 0;
|
|
3
3
|
options;
|
|
4
|
-
startTime = 0;
|
|
5
4
|
requestCount = 0;
|
|
6
|
-
|
|
5
|
+
server = null;
|
|
6
|
+
startTime = 0;
|
|
7
7
|
constructor(options = {}) {
|
|
8
8
|
this.options = {
|
|
9
9
|
port: options.port ?? 3000,
|
|
@@ -12,6 +12,14 @@ export class DevServer {
|
|
|
12
12
|
hmr: options.hmr ?? true,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
+
getStats() {
|
|
16
|
+
return {
|
|
17
|
+
uptime: Date.now() - this.startTime,
|
|
18
|
+
requests: this.requestCount,
|
|
19
|
+
errors: this.errorCount,
|
|
20
|
+
memoryUsage: process.memoryUsage(),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
15
23
|
async start() {
|
|
16
24
|
this.startTime = Date.now();
|
|
17
25
|
const http = await import('http');
|
|
@@ -45,14 +53,6 @@ export class DevServer {
|
|
|
45
53
|
});
|
|
46
54
|
});
|
|
47
55
|
}
|
|
48
|
-
getStats() {
|
|
49
|
-
return {
|
|
50
|
-
uptime: Date.now() - this.startTime,
|
|
51
|
-
requests: this.requestCount,
|
|
52
|
-
errors: this.errorCount,
|
|
53
|
-
memoryUsage: process.memoryUsage(),
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
56
|
createRequestHandler() {
|
|
57
57
|
return async (req, res) => {
|
|
58
58
|
this.requestCount++;
|
|
@@ -66,6 +66,20 @@ export class DevServer {
|
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
|
+
async generateHTML(pathname) {
|
|
70
|
+
return `<!DOCTYPE html>
|
|
71
|
+
<html>
|
|
72
|
+
<head>
|
|
73
|
+
<meta charset="utf-8">
|
|
74
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
75
|
+
<title>EmberKit Dev</title>
|
|
76
|
+
<script type="module" src="/@vite/client"></script>
|
|
77
|
+
</head>
|
|
78
|
+
<body>
|
|
79
|
+
<div id="app"></div>
|
|
80
|
+
</body>
|
|
81
|
+
</html>`;
|
|
82
|
+
}
|
|
69
83
|
async handleRequest(req, res) {
|
|
70
84
|
const url = new URL(req.url ?? '/', `http://${req.headers.host}`);
|
|
71
85
|
if (url.pathname === '/__emberkit_hmr') {
|
|
@@ -90,25 +104,11 @@ export class DevServer {
|
|
|
90
104
|
}
|
|
91
105
|
handleWebSocket(req, res) {
|
|
92
106
|
res.writeHead(101, {
|
|
93
|
-
|
|
94
|
-
|
|
107
|
+
Upgrade: 'websocket',
|
|
108
|
+
Connection: 'Upgrade',
|
|
95
109
|
});
|
|
96
110
|
res.end();
|
|
97
111
|
}
|
|
98
|
-
async generateHTML(pathname) {
|
|
99
|
-
return `<!DOCTYPE html>
|
|
100
|
-
<html>
|
|
101
|
-
<head>
|
|
102
|
-
<meta charset="utf-8">
|
|
103
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
104
|
-
<title>EmberKit Dev</title>
|
|
105
|
-
<script type="module" src="/@vite/client"></script>
|
|
106
|
-
</head>
|
|
107
|
-
<body>
|
|
108
|
-
<div id="app"></div>
|
|
109
|
-
</body>
|
|
110
|
-
</html>`;
|
|
111
|
-
}
|
|
112
112
|
sendError(res, code, message) {
|
|
113
113
|
res.writeHead(code, { 'Content-Type': 'text/plain' });
|
|
114
114
|
res.end(message);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export interface FormConfig {
|
|
2
|
+
action?: string;
|
|
3
|
+
method?: 'get' | 'post' | 'put' | 'delete' | 'patch';
|
|
4
|
+
encType?: 'application/x-www-form-urlencoded' | 'multipart/form-data' | 'text/plain';
|
|
5
|
+
validation?: ValidationSchema;
|
|
6
|
+
onSubmit?: FormSubmitHandler;
|
|
7
|
+
onError?: FormErrorHandler;
|
|
8
|
+
}
|
|
9
|
+
export interface ValidationSchema {
|
|
10
|
+
fields: Record<string, FieldValidator>;
|
|
11
|
+
validateOnSubmit?: boolean;
|
|
12
|
+
validateOnBlur?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface FieldValidator {
|
|
15
|
+
required?: boolean;
|
|
16
|
+
minLength?: number;
|
|
17
|
+
maxLength?: number;
|
|
18
|
+
pattern?: RegExp;
|
|
19
|
+
custom?: (value: unknown) => string | null;
|
|
20
|
+
}
|
|
21
|
+
export type FormSubmitHandler = (data: FormData, event: SubmitEvent) => Promise<void> | void;
|
|
22
|
+
export type FormErrorHandler = (errors: FormErrors, event: SubmitEvent) => void;
|
|
23
|
+
export interface FormErrors {
|
|
24
|
+
[field: string]: string | undefined;
|
|
25
|
+
}
|
|
26
|
+
export interface FormState {
|
|
27
|
+
values: Record<string, unknown>;
|
|
28
|
+
errors: FormErrors;
|
|
29
|
+
touched: Set<string>;
|
|
30
|
+
dirty: boolean;
|
|
31
|
+
submitting: boolean;
|
|
32
|
+
submitted: boolean;
|
|
33
|
+
}
|
|
34
|
+
export declare class FormValidator {
|
|
35
|
+
private schema;
|
|
36
|
+
constructor(schema: ValidationSchema);
|
|
37
|
+
validate(data: Record<string, unknown>): FormErrors;
|
|
38
|
+
validateField(name: string, value: unknown, validator: FieldValidator): string | undefined;
|
|
39
|
+
validateFieldOnly(name: string, value: unknown): string | undefined;
|
|
40
|
+
}
|
|
41
|
+
export declare function createFormValidator(schema: ValidationSchema): FormValidator;
|
|
42
|
+
export declare function parseFormData(form: HTMLFormElement): Record<string, unknown>;
|
|
43
|
+
export declare function createFormState(initial?: Record<string, unknown>): FormState;
|
|
44
|
+
export declare function updateFormState(state: FormState, updates: Partial<FormState>): FormState;
|
|
45
|
+
export declare function getFieldValue(state: FormState, name: string): unknown;
|
|
46
|
+
export declare function setFieldValue(state: FormState, name: string, value: unknown): FormState;
|
|
47
|
+
export declare function setFieldError(state: FormState, name: string, error: string | undefined): FormState;
|
|
48
|
+
export declare function clearFormState(state: FormState): FormState;
|
|
49
|
+
export declare function handleFormSubmit(event: SubmitEvent, config: FormConfig): Promise<boolean>;
|
|
50
|
+
export declare const DEFAULT_VALIDATORS: Record<string, FieldValidator>;
|
|
51
|
+
export declare function applyDefaultValidator(field: string, validator: FieldValidator): FieldValidator;
|
|
52
|
+
export interface FormSubmitOptions {
|
|
53
|
+
method?: string;
|
|
54
|
+
action?: string;
|
|
55
|
+
target?: string;
|
|
56
|
+
}
|
|
57
|
+
export declare function buildFormAction(action: string, method: string, params?: Record<string, string>): string;
|
|
58
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/forms/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;IACrD,OAAO,CAAC,EAAE,mCAAmC,GAAG,qBAAqB,GAAG,YAAY,CAAC;IACrF,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,OAAO,CAAC,EAAE,gBAAgB,CAAC;CAC5B;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACvC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,GAAG,IAAI,CAAC;CAC5C;AAED,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAE7F,MAAM,MAAM,gBAAgB,GAAG,CAAC,MA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C,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,SAAS,CAMvF;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,SAAS,CAKX;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAS1D;AAED,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CA4B/F;AAED,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAW7D,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,GAAG,cAAc,CAc9F;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,MAAM,CAUR"}
|
package/dist/forms/index.js
CHANGED
|
@@ -129,7 +129,7 @@ export async function handleFormSubmit(event, config) {
|
|
|
129
129
|
export const DEFAULT_VALIDATORS = {
|
|
130
130
|
email: {
|
|
131
131
|
pattern: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
|
|
132
|
-
custom: (v) => typeof v === 'string' && !v.includes('@') ? 'Invalid email' : null,
|
|
132
|
+
custom: (v) => (typeof v === 'string' && !v.includes('@') ? 'Invalid email' : null),
|
|
133
133
|
},
|
|
134
134
|
url: {
|
|
135
135
|
pattern: /^https?:\/\/.+/,
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface MutationOptions<TData, TVariables> {
|
|
2
|
+
onMutate?: (variables: TVariables) => TData | Promise<TData>;
|
|
3
|
+
onSuccess?: (data: TData, variables: TVariables) => void;
|
|
4
|
+
onError?: (error: Error, variables: TVariables) => void;
|
|
5
|
+
onSettled?: (data?: TData, error?: Error) => void;
|
|
6
|
+
}
|
|
7
|
+
export interface MutationResult<TData> {
|
|
8
|
+
data: TData | null;
|
|
9
|
+
error: Error | null;
|
|
10
|
+
status: 'idle' | 'pending' | 'success' | 'error';
|
|
11
|
+
isPending: boolean;
|
|
12
|
+
isSuccess: boolean;
|
|
13
|
+
isError: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface ActionContext {
|
|
16
|
+
request: Request;
|
|
17
|
+
params: Record<string, string>;
|
|
18
|
+
query: URLSearchParams;
|
|
19
|
+
}
|
|
20
|
+
export type ActionHandler<TData = unknown, TVariables = Record<string, unknown>> = (variables: TVariables, context: ActionContext) => TData | Promise<TData>;
|
|
21
|
+
export interface ActionResult<TData> {
|
|
22
|
+
data: TData | null;
|
|
23
|
+
error: string | null;
|
|
24
|
+
status: number;
|
|
25
|
+
headers?: Record<string, string>;
|
|
26
|
+
}
|
|
27
|
+
export declare function createAction<TData, TVariables>(handler: ActionHandler<TData, TVariables>, options?: MutationOptions<TData, TVariables>): (variables: TVariables, context?: Partial<ActionContext>) => Promise<ActionResult<TData>>;
|
|
28
|
+
export declare function createMutation<TData, TVariables>(handler: ActionHandler<TData, TVariables>, options?: MutationOptions<TData, TVariables>): {
|
|
29
|
+
mutate: (variables: TVariables) => Promise<ActionResult<TData>>;
|
|
30
|
+
subscribe: (listener: (state: MutationResult<TData>) => void) => () => boolean;
|
|
31
|
+
getState: () => MutationResult<TData>;
|
|
32
|
+
reset: () => void;
|
|
33
|
+
};
|
|
34
|
+
export declare function handleAction(handler: ActionHandler, request: Request): Promise<Response>;
|
|
35
|
+
export declare function createActionHandler(handler: ActionHandler): (request: Request) => Promise<Response>;
|
|
36
|
+
export type MutationKey = string;
|
|
37
|
+
export declare const mutationCache: Map<string, MutationResult<unknown>>;
|
|
38
|
+
export declare function getCachedMutation(key: MutationKey): MutationResult<unknown> | undefined;
|
|
39
|
+
export declare function setCachedMutation<T>(key: MutationKey, result: MutationResult<T>): void;
|
|
40
|
+
export declare function invalidateMutation(key: MutationKey): void;
|
|
41
|
+
export declare function clearMutationCache(): void;
|
|
42
|
+
export interface UseMutationReturn<TData, TVariables> {
|
|
43
|
+
mutate: (variables: TVariables) => Promise<ActionResult<TData>>;
|
|
44
|
+
state: MutationResult<TData>;
|
|
45
|
+
reset: () => void;
|
|
46
|
+
}
|
|
47
|
+
export declare function useMutation<TData, TVariables>(action: ActionHandler<TData, TVariables>, options?: MutationOptions<TData, TVariables>): UseMutationReturn<TData, TVariables>;
|
|
48
|
+
//# sourceMappingURL=mutations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../src/forms/mutations.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe,CAAC,KAAK,EAAE,UAAU;IAChD,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,UAAU,KAAK,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7D,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,KAAK,IAAI,CAAC;IACzD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,KAAK,IAAI,CAAC;IACxD,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;CACnD;AAED,MAAM,WAAW,cAAc,CAAC,KAAK;IACnC,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,G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C,KAAK,IAAI;;;EAoBpE;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAiE9F;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,aAAa,IAC1C,SAAS,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC,CAGnD;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAEjC,eAAO,MAAM,aAAa,sCAAkD,CAAC;AAE7E,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,SAAS,CAEvF;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI,CAEtF;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAEzD;AAED,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAED,MAAM,WAAW,iBAAiB,CAAC,KAAK,EAAE,UAAU;IAClD,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU,KAAK,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IAChE,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;IAC7B,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,EAC3C,MAAM,EAAE,aAAa,CAAC,KAAK,EAAE,UAAU,CAAC,EACxC,OAAO,CAAC,EAAE,eAAe,CAAC,KAAK,EAAE,UAAU,CAAC,GAC3C,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,CAmFtC"}
|
package/dist/forms/mutations.js
CHANGED
|
@@ -127,7 +127,10 @@ export async function handleAction(handler, request) {
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
else {
|
|
130
|
-
variables = await request
|
|
130
|
+
variables = await request
|
|
131
|
+
.text()
|
|
132
|
+
.then((t) => JSON.parse(t))
|
|
133
|
+
.catch(() => ({}));
|
|
131
134
|
}
|
|
132
135
|
}
|
|
133
136
|
else if (request.method === 'GET') {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { HMRContext } from './types.js';
|
|
2
|
+
declare global {
|
|
3
|
+
interface ImportMeta {
|
|
4
|
+
readonly hot?: HotModuleAPI;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export interface HotModuleAPI {
|
|
8
|
+
accept(deps?: string | string[], callback?: () => void): void;
|
|
9
|
+
decline(): void;
|
|
10
|
+
dispose(callback: () => void): void;
|
|
11
|
+
data: Record<string, unknown>;
|
|
12
|
+
on(event: string, callback: (data: unknown) => void): void;
|
|
13
|
+
send(event: string, data: unknown): void;
|
|
14
|
+
}
|
|
15
|
+
export declare function createHotAPI(context: HMRContext, moduleId: string, moduleUrl: string): HotModuleAPI;
|
|
16
|
+
export declare function setupHMRClient(context: HMRContext): void;
|
|
17
|
+
export declare function cleanupHMRClient(): void;
|
|
18
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/hmr/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,YAAY,CAAC;AAGxD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,UAAU;QAClB,QAAQ,CAAC,GAAG,CAAC,EAAE,YAAY,CAAC;KAC7B;CACF;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAC9D,OAAO,IAAI,IAAI,CAAC;IAChB,OAAO,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI,CAAC;IAC3D,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;CAC1C;AAED,wBAAgB,YAAY,CAC1B,OAAO,EAAE,UAAU,EACnB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB,YAAY,CAsDd;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAkCxD;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAOvC"}
|
package/dist/hmr/client.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hmr/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface DevServerConfig {
|
|
2
|
+
port: number;
|
|
3
|
+
host: string;
|
|
4
|
+
hmr: boolean;
|
|
5
|
+
open: boolean;
|
|
6
|
+
cors: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface HotModule {
|
|
9
|
+
id: string;
|
|
10
|
+
url: string;
|
|
11
|
+
needsAccept: boolean;
|
|
12
|
+
acceptCallbacks: Array<() => void>;
|
|
13
|
+
disposeCallbacks: Array<() => void>;
|
|
14
|
+
}
|
|
15
|
+
export interface HMRContext {
|
|
16
|
+
connections: Map<string, WebSocket>;
|
|
17
|
+
modules: Map<string, HotModule>;
|
|
18
|
+
listeners: Array<(event: HMREvent) => void>;
|
|
19
|
+
}
|
|
20
|
+
export interface HMREvent {
|
|
21
|
+
type: 'connected' | 'disconnected' | 'update' | 'error';
|
|
22
|
+
moduleId?: string;
|
|
23
|
+
timestamp: number;
|
|
24
|
+
payload?: unknown;
|
|
25
|
+
}
|
|
26
|
+
export declare class HMRConnection {
|
|
27
|
+
private readonly url;
|
|
28
|
+
private ws;
|
|
29
|
+
constructor(url: string);
|
|
30
|
+
close(): void;
|
|
31
|
+
connect(onMessage: (data: unknown) => void): void;
|
|
32
|
+
send(data: unknown): void;
|
|
33
|
+
private reconnect;
|
|
34
|
+
}
|
|
35
|
+
export declare function createHMRContext(): HMRContext;
|
|
36
|
+
export declare function subscribeToHMR(context: HMRContext, callback: (event: HMREvent) => void): () => void;
|
|
37
|
+
export declare function emitHMREvent(context: HMRContext, event: HMREvent): void;
|
|
38
|
+
export declare function handleHMRMessage(context: HMRContext, data: Record<string, unknown>): Promise<void>;
|
|
39
|
+
export declare function getHotModule(context: HMRContext, id: string): HotModule | undefined;
|
|
40
|
+
export declare function registerHotModule(context: HMRContext, module: HotModule): void;
|
|
41
|
+
export declare function disposeHotModule(context: HMRContext, id: string): void;
|
|
42
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/hmr/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,OAAO,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;IACnC,gBAAgB,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACpC,OAAO,EAAE,GAAG,CAAC,MAAM,E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AAE,UAAU,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAYtE"}
|
package/dist/hmr/types.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export class HMRConnection {
|
|
2
|
-
ws = null;
|
|
3
2
|
url;
|
|
3
|
+
ws = null;
|
|
4
4
|
constructor(url) {
|
|
5
5
|
this.url = url;
|
|
6
6
|
}
|
|
7
|
+
close() {
|
|
8
|
+
this.ws?.close();
|
|
9
|
+
}
|
|
7
10
|
connect(onMessage) {
|
|
8
11
|
try {
|
|
9
12
|
this.ws = new WebSocket(this.url);
|
|
@@ -32,17 +35,14 @@ export class HMRConnection {
|
|
|
32
35
|
setTimeout(() => this.reconnect(onMessage), 1000);
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
|
-
reconnect(onMessage) {
|
|
36
|
-
console.log('[HMR] Attempting to reconnect...');
|
|
37
|
-
this.connect(onMessage);
|
|
38
|
-
}
|
|
39
38
|
send(data) {
|
|
40
39
|
if (this.ws?.readyState === WebSocket.OPEN) {
|
|
41
40
|
this.ws.send(JSON.stringify(data));
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
reconnect(onMessage) {
|
|
44
|
+
console.log('[HMR] Attempting to reconnect...');
|
|
45
|
+
this.connect(onMessage);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
export function createHMRContext() {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DOMElement } from '../../runtime/types.js';
|
|
2
|
+
import { type InteractiveElement, type HydrationManifest, type HydrationStrategy } from '../types.js';
|
|
3
|
+
export declare function analyzeElement(element: DOMElement): InteractiveElement | null;
|
|
4
|
+
export declare function extractEventHandlers(props: Record<string, unknown>): Set<string>;
|
|
5
|
+
export declare function buildSelector(tagName: string, props: Record<string, unknown>): string;
|
|
6
|
+
export declare function determineHydrationStrategy(tagName: string, props: Record<string, unknown>): HydrationStrategy;
|
|
7
|
+
export declare function analyzeTree(element: DOMElement | null): HydrationManifest;
|
|
8
|
+
export declare function getHydrationCandidates(manifest: HydrationManifest, strategy: HydrationStrategy['type']): InteractiveElement[];
|
|
9
|
+
//# sourceMappingURL=analyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../../../src/hydration/helpers/analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAIL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACvB,MAAM,aAAa,CAAC;AAErB,wBAAgB,cAAc,CAAC,OAAO,EAAE,UAAU,GAAG,kBAAkB,GAAG,IAAI,CAkB7E;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAUhF;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAarF;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,iBAAiB,CAwBnB;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,GAAG,iBAAiB,CAoCzE;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,iBAAiB,EAC3B,QAAQ,EAAE,iBAAiB,CAAC,MAAM,CAAC,GAClC,kBAAkB,EAAE,CAEtB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DOMElement } from '../../runtime/types.js';
|
|
2
|
+
import type { InteractiveElement } from '../types.js';
|
|
3
|
+
export interface HydrationOptions {
|
|
4
|
+
hydrateInteractive?: boolean;
|
|
5
|
+
rootSelector?: string;
|
|
6
|
+
timeout?: number;
|
|
7
|
+
onHydrated?: (element: InteractiveElement) => void;
|
|
8
|
+
onError?: (element: InteractiveElement, error: Error) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function hydrateSelective(container: Element | string, element: DOMElement | null, options?: HydrationOptions): Promise<void>;
|
|
11
|
+
export declare function attachEventHandlers(element: Element, handlers: Set<string>): void;
|
|
12
|
+
export declare function createLazyHydration<T>(loader: () => Promise<T>, options?: {
|
|
13
|
+
fallback?: DOMElement | null;
|
|
14
|
+
timeout?: number;
|
|
15
|
+
onLoaded?: (value: T) => void;
|
|
16
|
+
onError?: (error: Error) => void;
|
|
17
|
+
}): DOMElement;
|
|
18
|
+
export declare function clearHydrationCache(): void;
|
|
19
|
+
//# sourceMappingURL=hydration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydration.d.ts","sourceRoot":"","sources":["../../../src/hydration/helpers/hydration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAItD,MAAM,WAAW,gBAAgB;IAC/B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACnD,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAC/D;AAED,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,OAAO,GAAG,MAAM,EAC3B,OAAO,EAAE,UAAU,GAAG,IAAI,EAC1B,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAiBf;AA4CD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAcjF;AAgCD,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,MAAM,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACxB,OAAO,GAAE;IACP,QAAQ,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC9B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAC7B,GACL,UAAU,CA0BZ;AAwCD,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C"}
|
|
@@ -5,7 +5,7 @@ export async function hydrateSelective(container, element, options = {}) {
|
|
|
5
5
|
const root = typeof container === 'string' ? document.querySelector(container) : container;
|
|
6
6
|
if (!root || !element)
|
|
7
7
|
return;
|
|
8
|
-
const { hydrateInteractive = true, onHydrated, onError
|
|
8
|
+
const { hydrateInteractive = true, onHydrated, onError } = options;
|
|
9
9
|
const manifest = analyzeTree(element);
|
|
10
10
|
if (!hydrateInteractive) {
|
|
11
11
|
return;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hydration/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface HydrationConfig {
|
|
2
|
+
hydrateInteractive?: boolean;
|
|
3
|
+
lazyComponents?: boolean;
|
|
4
|
+
streaming?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface HydrationStrategy {
|
|
7
|
+
type: 'eager' | 'lazy' | 'deferred' | 'none';
|
|
8
|
+
priority?: 'high' | 'medium' | 'low';
|
|
9
|
+
timeout?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface InteractiveElement {
|
|
12
|
+
selector: string;
|
|
13
|
+
eventHandlers: Set<string>;
|
|
14
|
+
needsHydration: boolean;
|
|
15
|
+
strategy: HydrationStrategy;
|
|
16
|
+
}
|
|
17
|
+
export interface HydrationManifest {
|
|
18
|
+
elements: InteractiveElement[];
|
|
19
|
+
totalElements: number;
|
|
20
|
+
hydrationRequired: number;
|
|
21
|
+
hydrationSkipped: number;
|
|
22
|
+
}
|
|
23
|
+
export declare const INTERACTIVE_ATTRIBUTES: Set<string>;
|
|
24
|
+
export declare const HYDRATABLE_TAGS: Set<string>;
|
|
25
|
+
export declare function isInteractiveTag(tagName: string): boolean;
|
|
26
|
+
export declare function hasEventHandlers(props: Record<string, unknown>): boolean;
|
|
27
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/hydration/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,CAAC;IAC7C,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,iBAAiB,CAAC;CAC7B;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,kBAAkB,EAAE,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,eAAO,MAAM,sBAAsB,aAwBjC,CAAC;AAEH,eAAO,MAAM,eAAe,aAU1B,CAAC;AAEH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAExE"}
|
package/dist/hydration/types.js
CHANGED
|
@@ -1,14 +1,38 @@
|
|
|
1
1
|
export const INTERACTIVE_ATTRIBUTES = new Set([
|
|
2
|
-
'onClick',
|
|
3
|
-
'
|
|
4
|
-
'
|
|
5
|
-
'
|
|
6
|
-
'
|
|
7
|
-
'
|
|
2
|
+
'onClick',
|
|
3
|
+
'onMouseDown',
|
|
4
|
+
'onMouseUp',
|
|
5
|
+
'onMouseEnter',
|
|
6
|
+
'onMouseLeave',
|
|
7
|
+
'onFocus',
|
|
8
|
+
'onBlur',
|
|
9
|
+
'onChange',
|
|
10
|
+
'onInput',
|
|
11
|
+
'onSubmit',
|
|
12
|
+
'onKeyDown',
|
|
13
|
+
'onKeyUp',
|
|
14
|
+
'onKeyPress',
|
|
15
|
+
'onScroll',
|
|
16
|
+
'onTouchStart',
|
|
17
|
+
'onTouchEnd',
|
|
18
|
+
'onTouchMove',
|
|
19
|
+
'onDragStart',
|
|
20
|
+
'onDrag',
|
|
21
|
+
'onDragEnd',
|
|
22
|
+
'onWheel',
|
|
23
|
+
'onAnimationStart',
|
|
24
|
+
'onAnimationEnd',
|
|
8
25
|
]);
|
|
9
26
|
export const HYDRATABLE_TAGS = new Set([
|
|
10
|
-
'button',
|
|
11
|
-
'
|
|
27
|
+
'button',
|
|
28
|
+
'a',
|
|
29
|
+
'input',
|
|
30
|
+
'select',
|
|
31
|
+
'textarea',
|
|
32
|
+
'form',
|
|
33
|
+
'details',
|
|
34
|
+
'dialog',
|
|
35
|
+
'summary',
|
|
12
36
|
]);
|
|
13
37
|
export function isInteractiveTag(tagName) {
|
|
14
38
|
return HYDRATABLE_TAGS.has(tagName.toLowerCase());
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Plugin } from '../plugin/index.js';
|
|
2
|
+
import { type ImageConfig } from './processor.js';
|
|
3
|
+
export interface ImagePluginConfig extends ImageConfig {
|
|
4
|
+
watchDir?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function imagePlugin(config?: ImagePluginConfig): Plugin;
|
|
7
|
+
export declare function createImageVitePlugin(config?: ImagePluginConfig): Plugin;
|
|
8
|
+
export { createImageProcessor, type ImageConfig, type ImageStats, type TransformedImage, } from './processor.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/image/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAwB,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAExE,MAAM,WAAW,iBAAkB,SAAQ,WAAW;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,WAAW,CAAC,MAAM,GAAE,iBAAsB,GAAG,MAAM,CAelE;AAoBD,wBAAgB,qBAAqB,CAAC,MAAM,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAExE;AAED,OAAO,EACL,oBAAoB,EACpB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,gBAAgB,GACtB,MAAM,gBAAgB,CAAC"}
|
package/dist/image/index.js
CHANGED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export interface ImageConfig {
|
|
2
|
+
provider?: 'none' | 'cloudflare' | 'imgix' | 'ipx';
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
quality?: number;
|
|
5
|
+
formats?: Array<'webp' | 'avif' | 'png' | 'jpeg'>;
|
|
6
|
+
sizes?: Array<number>;
|
|
7
|
+
lazy?: boolean;
|
|
8
|
+
placeholder?: 'blur' | 'dominant' | 'none';
|
|
9
|
+
}
|
|
10
|
+
export interface ImageStats {
|
|
11
|
+
originalSize: number;
|
|
12
|
+
optimizedSize: number;
|
|
13
|
+
savings: number;
|
|
14
|
+
format: string;
|
|
15
|
+
}
|
|
16
|
+
export interface TransformedImage {
|
|
17
|
+
src: string;
|
|
18
|
+
srcset: string;
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
format: string;
|
|
22
|
+
blurDataURL?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare class ImageProcessor {
|
|
25
|
+
private config;
|
|
26
|
+
constructor(config?: ImageConfig);
|
|
27
|
+
analyze(stats: ImageStats): void;
|
|
28
|
+
transform(src: string, options?: {
|
|
29
|
+
width?: number;
|
|
30
|
+
height?: number;
|
|
31
|
+
format?: string;
|
|
32
|
+
quality?: number;
|
|
33
|
+
}): TransformedImage;
|
|
34
|
+
private buildSrcset;
|
|
35
|
+
private buildUrl;
|
|
36
|
+
private generatePlaceholder;
|
|
37
|
+
}
|
|
38
|
+
export declare function createImageProcessor(config?: ImageConfig): ImageProcessor;
|
|
39
|
+
export declare function getOptimalFormat(acceptHeader: string): string;
|
|
40
|
+
export declare function calculateSizes(sizes: string, viewport: number): string;
|
|
41
|
+
export declare const ASPECT_RATIOS: Map<string, number>;
|
|
42
|
+
export declare function calculateDimensions(width: number, aspectRatio?: string): {
|
|
43
|
+
width: number;
|
|
44
|
+
height: number;
|
|
45
|
+
};
|
|
46
|
+
export declare const LOW_QUALITY_IMAGE_SIZES: number[];
|
|
47
|
+
export declare function generatePlaceholderSVG(width: number, height: number, color?: string): string;
|
|
48
|
+
export declare function createPictureElement(image: TransformedImage, alt: string, options?: {
|
|
49
|
+
lazy?: boolean;
|
|
50
|
+
loading?: 'lazy' | 'eager';
|
|
51
|
+
fetchpriority?: 'high' | 'low' | 'auto';
|
|
52
|
+
}): string;
|
|
53
|
+
export declare function parseImageSrc(src: string): {
|
|
54
|
+
path: string;
|
|
55
|
+
params: Record<string, string>;
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processor.d.ts","sourceRoot":"","sources":["../../src/image/processor.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,OAAO,GAAG,KAAK,CAAC;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC,CAAC;IAClD,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAAC;CAC5C;AAED,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAwB;gBAE1B,MAAM,GAAE,WAAgB;IAYpC,OAAO,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAQhC,SAAS,CACP,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EA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