@pygmalionjs/pygmalion 0.23.0 → 0.25.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 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";
1
+ import { c0 as l, T as u } from "./runtime-Dj5sWqho.js";
2
+ import { bs as y, ci as E, cj as P, ck as b, bo as T, aw as $ } from "./runtime-Dj5sWqho.js";
3
3
  const v = {
4
4
  mirror: ["status", "refresh", "refs"],
5
5
  session: ["open", "check", "previewVisual", "applyVisual", "revertVisual"],
@@ -8,7 +8,7 @@ const v = {
8
8
  preview: ["artifact", "progress", "catalog"],
9
9
  storyboard: ["environment", "sourceUsage", "componentBranches"]
10
10
  };
11
- function h(m = {}, t = {}) {
11
+ function g(m = {}, t = {}) {
12
12
  const n = [], d = t.origin ?? "", r = (e) => {
13
13
  var a;
14
14
  const i = {};
@@ -38,10 +38,10 @@ function h(m = {}, t = {}) {
38
38
  }
39
39
  export {
40
40
  y as EditorRuntimeProvider,
41
- b as EditorStore,
42
- E as FrozenRoutePreviewView,
43
- P as NodeModel,
44
- $ as createEditorRuntime,
45
- h as createMemoryTransport,
46
- T as serializeNode
41
+ E as EditorStore,
42
+ P as FrozenRoutePreviewView,
43
+ b as NodeModel,
44
+ T as createEditorRuntime,
45
+ g as createMemoryTransport,
46
+ $ as serializeNode
47
47
  };
@@ -34,7 +34,9 @@ export type { InspectSourceRuntime, SourceWritePolicy, SourceWriteErrorCode } fr
34
34
  export { WorkspaceController } from './workspace/controller.js';
35
35
  export { createLegacyModeAdapter } from './workspace/legacyModeAdapter.js';
36
36
  export type * from './workspace/contracts.js';
37
- export { createWorkspaceTargetResolver, resolveWorkspaceTarget } from './workspace/configuration.js';
37
+ export { canEditWorkspaceTarget, createWorkspaceTargetResolver, resolveWorkspaceTarget } from './workspace/configuration.js';
38
+ export { screenStateGroup, screenStateLabel } from './workspace/screenStates.js';
39
+ export type { ScreenStateGroup, ScreenStateMember } from './workspace/screenStates.js';
38
40
  export type { WorkspaceConfiguration, WorkspaceTargetConfiguration, WorkspaceTargetResolverOptions } from './workspace/configuration.js';
39
41
  export { capturedScreenMetadata, screenDocumentFromImport } from './document/screenImport.js';
40
42
  export { createCapturedScreenDocumentLoader } from './workspace/capture/capturedScreenDocument.js';
@@ -0,0 +1,17 @@
1
+ import type { EditorRuntime } from '../core/runtime.js';
2
+ import type { PageModel } from '../editor/store.js';
3
+ import type { WorkspaceTarget } from './contracts.js';
4
+ export interface ScreenStateSwitchProps {
5
+ runtime: EditorRuntime;
6
+ target: WorkspaceTarget;
7
+ /** Whether a sibling can be opened where this switch lives; a closed sibling stays listed but disabled. */
8
+ canOpen?: (page: PageModel) => boolean;
9
+ closedReason?: string;
10
+ onSwitch: (page: PageModel) => void;
11
+ }
12
+ /**
13
+ * One select over the declared states of the current screen. It renders
14
+ * nothing while the screen has no sibling state to flip to, so a switch never
15
+ * announces a choice that does not exist.
16
+ */
17
+ export declare const ScreenStateSwitch: import("react").FunctionComponent<ScreenStateSwitchProps>;
@@ -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?: true | CapturedScreenDocumentOptions;
43
+ capturedScreens?: boolean | CapturedScreenDocumentOptions;
44
44
  }
45
45
  export interface WorkspaceTargetResolverOptions {
46
46
  /** The host decides whether this screen and revision have usable capabilities. */
@@ -50,6 +50,8 @@ export interface WorkspaceTargetResolverOptions {
50
50
  }
51
51
  /** Retain capability identities per screen and revision; unsupported targets remain retryable. */
52
52
  export declare function createWorkspaceTargetResolver({ resolve, maxEntries }: WorkspaceTargetResolverOptions): (target: WorkspaceTarget) => WorkspaceTargetConfiguration | undefined;
53
+ /** Whether Edit can open this target: its resolved capabilities include a document loader. Never loads anything. */
54
+ export declare function canEditWorkspaceTarget(configuration: WorkspaceConfiguration, target: WorkspaceTarget | null | undefined): boolean;
53
55
  /** An explicit target resolver never inherits capabilities from the root configuration. */
54
56
  export declare function resolveWorkspaceTarget(configuration: WorkspaceConfiguration, target: WorkspaceTarget): WorkspaceTargetConfiguration | undefined;
55
57
  /** Compares captured capability identities without invoking any host callbacks. */
@@ -0,0 +1,32 @@
1
+ import type { PageModel } from '../editor/store.js';
2
+ /**
3
+ * Sibling states of one screen are a host declaration: pages that share a
4
+ * scenario belong together (see `editor/screenStateGroups.ts`). The core never
5
+ * infers membership from names, routes, or canvas proximity, so a screen
6
+ * without a scenario simply has no siblings to flip to.
7
+ */
8
+ export interface ScreenStateMember {
9
+ page: PageModel;
10
+ screenId: string;
11
+ /** The declared state label; an undeclared state is the default one. */
12
+ label: string;
13
+ /** Host-declared kind of the state branch (overlay, badge, layout, …), presentation only. */
14
+ kind?: string;
15
+ current: boolean;
16
+ }
17
+ export interface ScreenStateGroup {
18
+ /** The shared scenario declaration. */
19
+ key: string;
20
+ /** The default member's name, or the first declared member's. */
21
+ name: string;
22
+ members: readonly ScreenStateMember[];
23
+ }
24
+ export declare const isScreenPage: (page: PageModel) => boolean;
25
+ export declare const screenStateLabel: (page: PageModel) => string;
26
+ /**
27
+ * The declared states of the screen `screenId` belongs to, default state first
28
+ * and then in declaration order. Hidden siblings (other runtimes or conditions)
29
+ * are left out; the current state always stays. Returns null when the screen
30
+ * is unknown or declares no scenario.
31
+ */
32
+ export declare function screenStateGroup(pages: readonly PageModel[], screenId: string, isVisible?: (page: PageModel) => boolean): ScreenStateGroup | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pygmalionjs/pygmalion",
3
- "version": "0.23.0",
3
+ "version": "0.25.0",
4
4
  "description": "Code-backed DOM design sandbox and visual QA editor",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {