@pygmalionjs/pygmalion 0.22.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.
@@ -1,5 +1,5 @@
1
- import { b$ as d, T as u } from "./runtime-Du2Qf5G-.js";
2
- import { bp as y, ch as b, ci as E, cj as P, bl as $, aw as T } from "./runtime-Du2Qf5G-.js";
1
+ import { b$ as l, T as u } from "./runtime-DLaOoI2y.js";
2
+ import { br as y, ch as b, ci as E, cj as P, bn as $, aw as T } from "./runtime-DLaOoI2y.js";
3
3
  const v = {
4
4
  mirror: ["status", "refresh", "refs"],
5
5
  session: ["open", "check", "previewVisual", "applyVisual", "revertVisual"],
@@ -9,7 +9,7 @@ const v = {
9
9
  storyboard: ["environment", "sourceUsage", "componentBranches"]
10
10
  };
11
11
  function h(m = {}, t = {}) {
12
- const n = [], l = t.origin ?? "", r = (e) => {
12
+ const n = [], d = t.origin ?? "", r = (e) => {
13
13
  var a;
14
14
  const i = {};
15
15
  for (const o of v[e]) {
@@ -26,8 +26,8 @@ function h(m = {}, t = {}) {
26
26
  };
27
27
  return {
28
28
  calls: n,
29
- endpoints: d(t.endpoints),
30
- resolveUrl: (e) => `${l}${e}`,
29
+ endpoints: l(t.endpoints),
30
+ resolveUrl: (e) => `${d}${e}`,
31
31
  mirror: r("mirror"),
32
32
  session: r("session"),
33
33
  inspect: r("inspect"),
@@ -0,0 +1,6 @@
1
+ import type { DesignDocument } from './contracts.js';
2
+ import { type CapturedScreenMetadata, type ScreenImportResult, type ScreenImportSource } from '../workspace/capture/contracts.js';
3
+ /** Converts an imported screen (layer tree plus measured boxes) into a freely editable design document. */
4
+ export declare function screenDocumentFromImport(source: ScreenImportSource): ScreenImportResult;
5
+ /** The imported-screen marker of a document, when it has one. */
6
+ export declare function capturedScreenMetadata(document: Pick<DesignDocument, 'metadata'>): CapturedScreenMetadata | null;
@@ -36,6 +36,11 @@ export { createLegacyModeAdapter } from './workspace/legacyModeAdapter.js';
36
36
  export type * from './workspace/contracts.js';
37
37
  export { createWorkspaceTargetResolver, resolveWorkspaceTarget } from './workspace/configuration.js';
38
38
  export type { WorkspaceConfiguration, WorkspaceTargetConfiguration, WorkspaceTargetResolverOptions } from './workspace/configuration.js';
39
+ export { capturedScreenMetadata, screenDocumentFromImport } from './document/screenImport.js';
40
+ export { createCapturedScreenDocumentLoader } from './workspace/capture/capturedScreenDocument.js';
41
+ export { withCapturedScreenDocuments } from './workspace/capture/capturedScreenConfiguration.js';
42
+ export { CAPTURED_SCREEN_METADATA_KEY } from './workspace/capture/contracts.js';
43
+ export type { CapturedScreenDocumentLoader, CapturedScreenDocumentOptions, CapturedScreenMetadata, ScreenImportResult, ScreenImportSource } from './workspace/capture/contracts.js';
39
44
  export { compileWorkspaceVisualSource, workspaceSourceFingerprint } from './workspace/source/compiler.js';
40
45
  export { compileWorkspaceDocumentSource, jsxStructureWrapperClassName } from './workspace/source/structure.js';
41
46
  export { compileWorkspaceResponsiveSource, resolveResponsiveLayout, setResponsiveLayoutOverride } from './workspace/source/responsive.js';
@@ -1,9 +1,12 @@
1
1
  import { type WorkspaceConfiguration } from './configuration.js';
2
+ import { type CapturedScreenConfigurationDependencies } from './capture/capturedScreenConfiguration.js';
2
3
 
3
4
  export interface WorkspaceShellProps {
4
5
  configuration: WorkspaceConfiguration;
5
6
  sourceRevision: string;
6
7
  previewIdentityReady: boolean;
7
8
  previewOpen?: boolean;
9
+ /** Test seam for the captured-screen importer; production builds the offscreen loader. */
10
+ captureDependencies?: CapturedScreenConfigurationDependencies;
8
11
  }
9
12
  export declare const WorkspaceShell: import("react").FunctionComponent<WorkspaceShellProps>;
@@ -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>;
@@ -0,0 +1,15 @@
1
+ import type { EditorRuntime } from '../../core/runtime.js';
2
+ import { type WorkspaceConfiguration } from '../configuration.js';
3
+ import type { WorkspaceTarget } from '../contracts.js';
4
+ import { type CapturedScreenDocumentLoader, type CapturedScreenDocumentOptions } from './contracts.js';
5
+ export interface CapturedScreenConfigurationDependencies {
6
+ /** Test seam; production builds the offscreen importer. */
7
+ createLoader?(runtime: EditorRuntime, options: CapturedScreenDocumentOptions): CapturedScreenDocumentLoader;
8
+ }
9
+ /** Drafts live per screen and source revision; a new revision starts from a fresh import. */
10
+ export declare const capturedScreenDraftKey: (target: WorkspaceTarget) => string;
11
+ /**
12
+ * Wraps a host configuration so any routed screen the host does not resolve opens as an imported design
13
+ * document. Host-resolved targets always win; the fallback only fills targets the host leaves without a loader.
14
+ */
15
+ export declare function withCapturedScreenDocuments(configuration: WorkspaceConfiguration, runtime: EditorRuntime, dependencies?: CapturedScreenConfigurationDependencies): WorkspaceConfiguration;
@@ -0,0 +1,4 @@
1
+ import type { EditorRuntime } from '../../core/runtime.js';
2
+ import type { CapturedScreenDocumentLoader, CapturedScreenDocumentOptions } from './contracts.js';
3
+ /** Opens any routed screen as a design document by booting it offscreen and importing its DOM. */
4
+ export declare function createCapturedScreenDocumentLoader(runtime: EditorRuntime, options?: CapturedScreenDocumentOptions): CapturedScreenDocumentLoader;
@@ -0,0 +1,77 @@
1
+ import type { DocumentAsset, ImageScaleMode } from '../../document/assets.js';
2
+ import type { DesignDocument, DocumentDiagnostic } from '../../document/contracts.js';
3
+ import type { ImportedGeometryEntry } from '../../editor/domImport.js';
4
+ import type { NodeJSON, PageModel } from '../../editor/store.js';
5
+ import type { WorkspaceTarget } from '../contracts.js';
6
+ /** What the DOM importer observed on a prepared screen; the converter turns it into a design document. */
7
+ export interface ScreenImportSource {
8
+ screenId: string;
9
+ sourceRevision: string;
10
+ /** Screen name shown as the root frame name. */
11
+ name: string;
12
+ route?: string;
13
+ width: number;
14
+ height: number;
15
+ root: NodeJSON;
16
+ geometry: readonly ImportedGeometryEntry[];
17
+ truncated?: boolean;
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[];
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
+ };
39
+ export interface ScreenImportResult {
40
+ document: DesignDocument;
41
+ diagnostics: DocumentDiagnostic[];
42
+ nodeCount: number;
43
+ }
44
+ export declare const CAPTURED_SCREEN_METADATA_KEY = "capturedScreen";
45
+ /** Stored under `document.metadata.capturedScreen`; marks a draft that began as an imported screen. */
46
+ export interface CapturedScreenMetadata {
47
+ version: 1;
48
+ screenId: string;
49
+ route?: string;
50
+ importedAt: string;
51
+ nodeCount: number;
52
+ truncated: boolean;
53
+ diagnostics: string[];
54
+ }
55
+ export interface CapturedScreenDocumentOptions {
56
+ /** Persists drafts when the host supplies no saveDocument; null disables persistence; default is window.localStorage when present. */
57
+ draftStorage?: Pick<Storage, 'getItem' | 'setItem' | 'removeItem'> | null;
58
+ /** Which routed screens may open this way; default: every page with a route or a screens import. */
59
+ canImport?(page: PageModel): boolean;
60
+ /** Import budget forwarded to the DOM importer; pure DOM by default so pixels match the running screen. */
61
+ import?: {
62
+ instanceMode?: 'ignore' | 'collapse' | 'expand';
63
+ };
64
+ /** Milliseconds to wait for the screen to load and prepare before giving up. Default 45000. */
65
+ timeoutMs?: number;
66
+ /** Milliseconds spent collecting images and drawings before the import continues without the rest. Default 8000. */
67
+ mediaBudgetMs?: number;
68
+ /** Where the offscreen frame mounts; default is the document body of the page running the editor. */
69
+ container?: HTMLElement;
70
+ }
71
+ export interface CapturedScreenDocumentLoader {
72
+ canImport(page: PageModel): boolean;
73
+ /** Boots the screen offscreen, prepares its declared state, imports the DOM, and returns the converted document. */
74
+ load(target: WorkspaceTarget, page: PageModel, options: {
75
+ signal: AbortSignal;
76
+ }): Promise<ScreenImportResult>;
77
+ }
@@ -6,6 +6,7 @@ import type { WorkspaceTarget } from './contracts.js';
6
6
  import type { WorkspaceTokenLibraryCapabilities } from './tokens/contracts.js';
7
7
  import type { TextFontPreparationRuntime } from './edit/textFontRuntime.js';
8
8
  import type { TextRasterFaceResolver } from './edit/staticTextRaster.js';
9
+ import type { CapturedScreenDocumentOptions } from './capture/contracts.js';
9
10
  /** One target's source, data, rendering, and persistence capabilities travel together. */
10
11
  export interface WorkspaceTargetConfiguration {
11
12
  data?: HostDataCapabilities;
@@ -38,6 +39,8 @@ export interface WorkspaceConfiguration extends WorkspaceTargetConfiguration {
38
39
  chrome?: ReactNode;
39
40
  /** Undefined explicitly marks an unsupported screen or source revision. */
40
41
  resolveTarget?(target: WorkspaceTarget): WorkspaceTargetConfiguration | undefined;
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?: boolean | CapturedScreenDocumentOptions;
41
44
  }
42
45
  export interface WorkspaceTargetResolverOptions {
43
46
  /** The host decides whether this screen and revision have usable capabilities. */
@@ -0,0 +1,24 @@
1
+ import type { DesignDocument, DocumentNode, DocumentTransaction } from '../../document/contracts.js';
2
+
3
+ export interface ContentPanelProps {
4
+ document: DesignDocument;
5
+ act(label: string, apply: (transaction: DocumentTransaction) => void): unknown;
6
+ selected: readonly string[];
7
+ onSelect(ids: string[]): void;
8
+ }
9
+ interface ContentRow {
10
+ id: string;
11
+ name: string;
12
+ kind: DocumentNode['kind'];
13
+ hidden: boolean;
14
+ tagged: boolean;
15
+ }
16
+ interface ContentSection {
17
+ id: string;
18
+ name: string;
19
+ rows: ContentRow[];
20
+ }
21
+ export declare function contentSections(document: DesignDocument): ContentSection[];
22
+ /** Lists what the screen shows so a designer can pull content out of view or bring it back without touching the layer tree. */
23
+ export declare function ContentPanel({ document, act, selected, onSelect }: ContentPanelProps): import("react").JSX.Element;
24
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pygmalionjs/pygmalion",
3
- "version": "0.22.0",
3
+ "version": "0.24.0",
4
4
  "description": "Code-backed DOM design sandbox and visual QA editor",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {