@hugex/artifact 0.12.0 → 0.12.1
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/dist/artifact/do/ArtifactDO.d.ts +4 -2
- package/dist/artifact/thumbnail.d.ts +42 -10
- package/dist/artifact/types.d.ts +3 -1
- package/dist/index.js +85 -85
- package/package.json +1 -1
|
@@ -95,8 +95,10 @@ export declare class ArtifactDO extends DurableObject<ArtifactEnv> implements Ar
|
|
|
95
95
|
}): Promise<{
|
|
96
96
|
removed: boolean;
|
|
97
97
|
} | null>;
|
|
98
|
-
/** Encola la captura de la versión activa. Si ya está `ready` en hx-core, no recaptura
|
|
99
|
-
enqueueThumbnail(
|
|
98
|
+
/** Encola la captura de la versión activa. Si ya está `ready` en hx-core, no recaptura, salvo `force`. */
|
|
99
|
+
enqueueThumbnail(input?: {
|
|
100
|
+
force?: boolean;
|
|
101
|
+
}): Promise<{
|
|
100
102
|
queued: boolean;
|
|
101
103
|
version: string | null;
|
|
102
104
|
} | null>;
|
|
@@ -4,7 +4,7 @@ export declare const THUMB_WIDTH = 640;
|
|
|
4
4
|
export declare const THUMB_HEIGHT = 400;
|
|
5
5
|
export declare const CAPTURE_QUERY = "__hx_capture";
|
|
6
6
|
export declare const CAPTURE_COOKIE = "__hx_capture";
|
|
7
|
-
export type ThumbFail = "timeout" | "navigation" | "no_browser" | "too_large";
|
|
7
|
+
export type ThumbFail = "timeout" | "navigation" | "no_browser" | "too_large" | "delivery";
|
|
8
8
|
export type ThumbStatusName = "pending" | "ready" | "failed";
|
|
9
9
|
export interface ThumbCoreEnv {
|
|
10
10
|
HX_CORE_URL?: string;
|
|
@@ -30,15 +30,18 @@ export declare function readCaptureCookie(header: string | null): string | null;
|
|
|
30
30
|
export declare function getThumbStatus(env: ThumbCoreEnv, uuid: string, version: string): Promise<ThumbStatusName | null>;
|
|
31
31
|
export declare function putThumbStatus(env: ThumbCoreEnv, uuid: string, version: string, body: {
|
|
32
32
|
status: "pending";
|
|
33
|
+
force?: boolean;
|
|
33
34
|
} | {
|
|
34
35
|
status: "failed";
|
|
35
36
|
reason: ThumbFail;
|
|
37
|
+
force?: boolean;
|
|
36
38
|
}): Promise<boolean>;
|
|
37
39
|
export declare function putThumbImage(env: ThumbCoreEnv, uuid: string, version: string, bytes: Uint8Array): Promise<{
|
|
38
40
|
ok: true;
|
|
39
41
|
} | {
|
|
40
42
|
ok: false;
|
|
41
|
-
reason:
|
|
43
|
+
reason: "too_large" | "delivery";
|
|
44
|
+
detail: string;
|
|
42
45
|
}>;
|
|
43
46
|
export interface ThumbBrowser {
|
|
44
47
|
newContext(opts: {
|
|
@@ -54,12 +57,32 @@ export interface ThumbBrowser {
|
|
|
54
57
|
}>;
|
|
55
58
|
close(): Promise<void>;
|
|
56
59
|
}
|
|
60
|
+
export interface ThumbRequestFailed {
|
|
61
|
+
url(): string;
|
|
62
|
+
failure(): {
|
|
63
|
+
errorText?: string;
|
|
64
|
+
} | null;
|
|
65
|
+
}
|
|
66
|
+
export interface ThumbResponse {
|
|
67
|
+
status(): number;
|
|
68
|
+
url(): string;
|
|
69
|
+
}
|
|
57
70
|
export interface ThumbPage {
|
|
58
71
|
goto(url: string, opts: {
|
|
59
72
|
waitUntil: "load";
|
|
60
73
|
timeout: number;
|
|
61
74
|
}): Promise<unknown>;
|
|
62
75
|
waitForTimeout(ms: number): Promise<unknown>;
|
|
76
|
+
waitForLoadState?(state: "networkidle", opts: {
|
|
77
|
+
timeout: number;
|
|
78
|
+
}): Promise<unknown>;
|
|
79
|
+
on?(event: "requestfailed", handler: (request: ThumbRequestFailed) => void): void;
|
|
80
|
+
on?(event: "response", handler: (response: ThumbResponse) => void): void;
|
|
81
|
+
on?(event: "console", handler: (message: {
|
|
82
|
+
type(): string;
|
|
83
|
+
text(): string;
|
|
84
|
+
}) => void): void;
|
|
85
|
+
evaluate?(fn: () => void): Promise<unknown>;
|
|
63
86
|
context(): {
|
|
64
87
|
newCDPSession(page: ThumbPage): Promise<{
|
|
65
88
|
send(method: string, params?: unknown): Promise<{
|
|
@@ -68,17 +91,26 @@ export interface ThumbPage {
|
|
|
68
91
|
}>;
|
|
69
92
|
};
|
|
70
93
|
}
|
|
71
|
-
export
|
|
72
|
-
url: string;
|
|
73
|
-
binding: unknown;
|
|
74
|
-
launch?: (binding: unknown) => Promise<ThumbBrowser>;
|
|
75
|
-
deadlineMs?: number;
|
|
76
|
-
}): Promise<{
|
|
94
|
+
export interface CaptureShot {
|
|
77
95
|
ok: true;
|
|
78
96
|
bytes: Uint8Array;
|
|
79
97
|
width: number;
|
|
80
98
|
height: number;
|
|
81
|
-
|
|
99
|
+
detail: string;
|
|
100
|
+
}
|
|
101
|
+
export interface CaptureMiss {
|
|
82
102
|
ok: false;
|
|
83
103
|
reason: ThumbFail;
|
|
84
|
-
|
|
104
|
+
detail: string;
|
|
105
|
+
}
|
|
106
|
+
/** Width and height from a WebP RIFF header. Browser Run ignores `deviceScaleFactor`. */
|
|
107
|
+
export declare function webpSize(bytes: Uint8Array): {
|
|
108
|
+
width: number;
|
|
109
|
+
height: number;
|
|
110
|
+
} | null;
|
|
111
|
+
export declare function captureThumbnail(opts: {
|
|
112
|
+
url: string;
|
|
113
|
+
binding: unknown;
|
|
114
|
+
launch?: (binding: unknown) => Promise<ThumbBrowser>;
|
|
115
|
+
deadlineMs?: number;
|
|
116
|
+
}): Promise<CaptureShot | CaptureMiss>;
|
package/dist/artifact/types.d.ts
CHANGED
|
@@ -516,7 +516,9 @@ export interface ArtifactRpc {
|
|
|
516
516
|
* Queues a capture of the active version. Already-`ready` thumbnails are not recaptured.
|
|
517
517
|
* Null when the artifact does not exist.
|
|
518
518
|
*/
|
|
519
|
-
enqueueThumbnail(
|
|
519
|
+
enqueueThumbnail(input?: {
|
|
520
|
+
force?: boolean;
|
|
521
|
+
}): Promise<{
|
|
520
522
|
queued: boolean;
|
|
521
523
|
version: string | null;
|
|
522
524
|
} | null>;
|