@pygmalionjs/pygmalion 0.23.0 → 0.24.0
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.
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type DocumentAsset } from '../../document/assets.js';
|
|
2
|
+
import { type ScreenImportMedia } from './contracts.js';
|
|
3
|
+
export interface SettleScreenOptions {
|
|
4
|
+
/** The import controller's stability wait, when the host connected one. */
|
|
5
|
+
waitForStableDocument?(document: Document): Promise<boolean>;
|
|
6
|
+
}
|
|
7
|
+
export interface SettleScreenReport {
|
|
8
|
+
finishedAnimations: number;
|
|
9
|
+
cancelledAnimations: number;
|
|
10
|
+
stable: boolean | null;
|
|
11
|
+
}
|
|
12
|
+
/** Entrance transitions and image decoding must finish before boxes and opacities are read. */
|
|
13
|
+
export declare function settleScreen(document: Document, options?: SettleScreenOptions): Promise<SettleScreenReport>;
|
|
14
|
+
export interface CollectScreenMediaOptions {
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
/** Total time for fetching and rasterizing; media beyond the budget stay placeholders. Default 8000. */
|
|
17
|
+
budgetMs?: number;
|
|
18
|
+
/** Fetches encoded bytes for a same-origin or CORS-readable URL; null means unreadable. */
|
|
19
|
+
fetchBytes?(url: string, signal?: AbortSignal): Promise<Uint8Array | null>;
|
|
20
|
+
/** Draws an element to PNG bytes at the given CSS size; null means the canvas was tainted or unsupported. */
|
|
21
|
+
rasterize?(element: Element, size: {
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
}): Promise<Uint8Array | null>;
|
|
25
|
+
}
|
|
26
|
+
export interface CollectedScreenMedia {
|
|
27
|
+
media: Record<string, ScreenImportMedia>;
|
|
28
|
+
assets: DocumentAsset[];
|
|
29
|
+
diagnostics: string[];
|
|
30
|
+
stamped: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Serializes an inline SVG the way the editable importer can read it: computed fill and stroke replace
|
|
34
|
+
* class-driven styling and `currentColor`, rounded rectangles become cubic paths, and non-presentational attributes drop out.
|
|
35
|
+
*/
|
|
36
|
+
export declare function editableSvgMarkup(element: Element): string;
|
|
37
|
+
/**
|
|
38
|
+
* Stamps every media element and element with a CSS background image, then gathers the bytes behind them.
|
|
39
|
+
* The stamps survive the DOM importer as attributes, so the converter can match layers to this media map.
|
|
40
|
+
*/
|
|
41
|
+
export declare function collectScreenMedia(document: Document, options?: CollectScreenMediaOptions): Promise<CollectedScreenMedia>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DocumentAsset, ImageScaleMode } from '../../document/assets.js';
|
|
1
2
|
import type { DesignDocument, DocumentDiagnostic } from '../../document/contracts.js';
|
|
2
3
|
import type { ImportedGeometryEntry } from '../../editor/domImport.js';
|
|
3
4
|
import type { NodeJSON, PageModel } from '../../editor/store.js';
|
|
@@ -15,7 +16,26 @@ export interface ScreenImportSource {
|
|
|
15
16
|
geometry: readonly ImportedGeometryEntry[];
|
|
16
17
|
truncated?: boolean;
|
|
17
18
|
importDiagnostics?: readonly string[];
|
|
19
|
+
/** Media observed on the screen, keyed by the stamp the loader wrote on each element before import. */
|
|
20
|
+
media?: Readonly<Record<string, ScreenImportMedia>>;
|
|
21
|
+
/** Image assets the media entries reference; only referenced assets enter the document. */
|
|
22
|
+
assets?: readonly DocumentAsset[];
|
|
18
23
|
}
|
|
24
|
+
/** The attribute the loader stamps on media elements so their layers can be matched after import. */
|
|
25
|
+
export declare const MEDIA_STAMP_ATTRIBUTE = "data-pygmalion-media";
|
|
26
|
+
export type ScreenImportMedia = {
|
|
27
|
+
kind: 'svg';
|
|
28
|
+
markup: string;
|
|
29
|
+
rasterAssetId?: string;
|
|
30
|
+
} | {
|
|
31
|
+
kind: 'image';
|
|
32
|
+
assetId: string;
|
|
33
|
+
scaleMode: ImageScaleMode;
|
|
34
|
+
} | {
|
|
35
|
+
kind: 'background';
|
|
36
|
+
assetId: string;
|
|
37
|
+
scaleMode: ImageScaleMode;
|
|
38
|
+
};
|
|
19
39
|
export interface ScreenImportResult {
|
|
20
40
|
document: DesignDocument;
|
|
21
41
|
diagnostics: DocumentDiagnostic[];
|
|
@@ -43,6 +63,8 @@ export interface CapturedScreenDocumentOptions {
|
|
|
43
63
|
};
|
|
44
64
|
/** Milliseconds to wait for the screen to load and prepare before giving up. Default 45000. */
|
|
45
65
|
timeoutMs?: number;
|
|
66
|
+
/** Milliseconds spent collecting images and drawings before the import continues without the rest. Default 8000. */
|
|
67
|
+
mediaBudgetMs?: number;
|
|
46
68
|
/** Where the offscreen frame mounts; default is the document body of the page running the editor. */
|
|
47
69
|
container?: HTMLElement;
|
|
48
70
|
}
|
|
@@ -40,7 +40,7 @@ export interface WorkspaceConfiguration extends WorkspaceTargetConfiguration {
|
|
|
40
40
|
/** Undefined explicitly marks an unsupported screen or source revision. */
|
|
41
41
|
resolveTarget?(target: WorkspaceTarget): WorkspaceTargetConfiguration | undefined;
|
|
42
42
|
/** Open any routed screen the host does not resolve as an imported design document; edits stay drafts until the host connects a source mapping. */
|
|
43
|
-
capturedScreens?:
|
|
43
|
+
capturedScreens?: boolean | CapturedScreenDocumentOptions;
|
|
44
44
|
}
|
|
45
45
|
export interface WorkspaceTargetResolverOptions {
|
|
46
46
|
/** The host decides whether this screen and revision have usable capabilities. */
|