@cratis/event-models 0.312.1 → 0.313.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.
Files changed (23) hide show
  1. package/dist/screen-editor/ScreenEditor/Drafting/SceneScreenDraft.d.ts +30 -0
  2. package/dist/screen-editor/ScreenEditor/Drafting/SceneScreenDraftReview.d.ts +14 -0
  3. package/dist/screen-editor/ScreenEditor/Drafting/SceneScreenDraftStrings.d.ts +21 -0
  4. package/dist/screen-editor/ScreenEditor/Drafting/SceneScreenDraftToolbar.d.ts +16 -0
  5. package/dist/screen-editor/ScreenEditor/Drafting/defaultSceneScreenDraftStrings.d.ts +2 -0
  6. package/dist/screen-editor/ScreenEditor/Drafting/prepareSceneScreenDraft.d.ts +10 -0
  7. package/dist/screen-editor/ScreenEditor/Drafting/sceneScreenDraftElement.d.ts +3 -0
  8. package/dist/screen-editor/ScreenEditor/Drafting/sceneScreenDraftEnvelope.d.ts +5 -0
  9. package/dist/screen-editor/ScreenEditor/Drafting/sceneScreenDraftInsertion.d.ts +4 -0
  10. package/dist/screen-editor/ScreenEditor/Drafting/sceneScreenDraftProperty.d.ts +4 -0
  11. package/dist/screen-editor/ScreenEditor/Drafting/sceneScreenDraftRequest.d.ts +6 -0
  12. package/dist/screen-editor/ScreenEditor/Drafting/sceneScreenDraftReviewVisibility.d.ts +1 -0
  13. package/dist/screen-editor/ScreenEditor/Drafting/sceneScreenDraftSession.d.ts +16 -0
  14. package/dist/screen-editor/ScreenEditor/Drafting/sceneScreenDraftState.d.ts +6 -0
  15. package/dist/screen-editor/ScreenEditor/Drafting/sceneScreenDraftValues.d.ts +5 -0
  16. package/dist/screen-editor/ScreenEditor/Drafting/useSceneScreenDraft.d.ts +21 -0
  17. package/dist/screen-editor/ScreenEditor/Host/ScreenEditorController.d.ts +7 -0
  18. package/dist/screen-editor/ScreenEditor/Host/ScreenEditorOverlay.d.ts +3 -0
  19. package/dist/screen-editor/ScreenEditor/Host/ScreenEditorWindow.d.ts +2 -1
  20. package/dist/screen-editor/ScreenEditor/Inspector/ScreenEditorStrings.d.ts +2 -0
  21. package/dist/screen-editor/ScreenEditor/index.d.ts +1 -0
  22. package/dist/screen-editor/index.js +4755 -4303
  23. package/package.json +3 -3
@@ -0,0 +1,30 @@
1
+ import type { EditingContext } from '@cratis/scene.engine';
2
+ import type { SceneDocument, SceneEdit } from '@cratis/scene.model';
3
+ import type { ScreenEditorRuntime } from '../Runtime/screenEditorRuntime';
4
+ export interface SceneScreenDraftAgent {
5
+ readonly context: string;
6
+ readonly parameterlessQueryIds: readonly string[];
7
+ generate(request: SceneScreenDraftRequest, signal: AbortSignal): Promise<string>;
8
+ }
9
+ export interface SceneScreenDraftRequest {
10
+ instruction: string;
11
+ catalogue: string;
12
+ document: string;
13
+ }
14
+ export interface PreparedSceneScreenDraft {
15
+ readonly base: SceneDocument;
16
+ readonly document: SceneDocument;
17
+ readonly answer: string;
18
+ readonly reply: string;
19
+ readonly edits: SceneEdit[];
20
+ readonly parameterlessQueryIds: readonly string[];
21
+ readonly runtime: ScreenEditorRuntime;
22
+ readonly context: EditingContext;
23
+ }
24
+ export type SceneScreenDraftPreparation = {
25
+ prepared: PreparedSceneScreenDraft;
26
+ problem?: never;
27
+ } | {
28
+ problem: string;
29
+ prepared?: never;
30
+ };
@@ -0,0 +1,14 @@
1
+ import { type SceneDocument } from '@cratis/scene.model';
2
+ import type { ScreenEditorController } from '../Host/ScreenEditorController';
3
+ import type { ScreenEditorEnvironment } from '../Host/ScreenEditorHost';
4
+ import type { SceneScreenDraftAgent } from './SceneScreenDraft';
5
+ import type { SceneScreenDraftStrings } from './SceneScreenDraftStrings';
6
+ export interface SceneScreenDraftReviewProps {
7
+ controller: ScreenEditorController;
8
+ environment: ScreenEditorEnvironment;
9
+ agent: SceneScreenDraftAgent;
10
+ onPreview?: (document: SceneDocument) => void;
11
+ strings?: SceneScreenDraftStrings;
12
+ previewing?: boolean;
13
+ }
14
+ export declare function SceneScreenDraftReview({ controller, environment, agent, onPreview, strings: text, previewing }: SceneScreenDraftReviewProps): import("react").JSX.Element;
@@ -0,0 +1,21 @@
1
+ export interface SceneScreenDraftStrings {
2
+ open: string;
3
+ title: string;
4
+ discard: string;
5
+ discardAriaLabel: string;
6
+ preview: string;
7
+ apply: string;
8
+ explanation: string;
9
+ instruction: string;
10
+ generate: string;
11
+ generating: string;
12
+ status: string;
13
+ review: string;
14
+ additions: string;
15
+ addControl: (target: string) => string;
16
+ setProperty: (path: string, node: string) => string;
17
+ changed: string;
18
+ generationFailed: string;
19
+ applyFailed: string;
20
+ undoLabel: string;
21
+ }
@@ -0,0 +1,16 @@
1
+ import type { SceneDocument } from '@cratis/scene.model';
2
+ import type { ScreenEditorController } from '../Host/ScreenEditorController';
3
+ import type { ScreenEditorEnvironment } from '../Host/ScreenEditorHost';
4
+ import type { ScreenEditorStrings } from '../Inspector/ScreenEditorStrings';
5
+ import type { SceneScreenDraftAgent } from './SceneScreenDraft';
6
+ export interface SceneScreenDraftToolbarProps {
7
+ controller: ScreenEditorController;
8
+ environment: ScreenEditorEnvironment;
9
+ strings: ScreenEditorStrings;
10
+ agent?: SceneScreenDraftAgent;
11
+ readOnly: boolean;
12
+ authoringTemplate?: string;
13
+ onPreview?: (document: SceneDocument) => void;
14
+ previewing?: boolean;
15
+ }
16
+ export declare const SceneScreenDraftToolbar: ({ controller, environment, strings, agent, readOnly, authoringTemplate, onPreview, previewing }: SceneScreenDraftToolbarProps) => import("react").JSX.Element | null;
@@ -0,0 +1,2 @@
1
+ import type { SceneScreenDraftStrings } from './SceneScreenDraftStrings';
2
+ export declare const defaultSceneScreenDraftStrings: SceneScreenDraftStrings;
@@ -0,0 +1,10 @@
1
+ import { type EditingContext } from '@cratis/scene.engine';
2
+ import { type SceneDocument } from '@cratis/scene.model';
3
+ import type { ScreenEditorRuntime } from '../Runtime/screenEditorRuntime';
4
+ import type { SceneScreenDraftPreparation } from './SceneScreenDraft';
5
+ export interface SceneScreenDraftScope {
6
+ runtime: ScreenEditorRuntime;
7
+ context: EditingContext;
8
+ parameterlessQueryIds: readonly string[];
9
+ }
10
+ export declare function prepareSceneScreenDraft(base: SceneDocument, answer: string, scope: SceneScreenDraftScope): SceneScreenDraftPreparation;
@@ -0,0 +1,3 @@
1
+ import type { SceneElement } from '@cratis/scene.model';
2
+ import type { ScreenEditorRuntime } from '../Runtime/screenEditorRuntime';
3
+ export declare function insertionElement(value: unknown, runtime: ScreenEditorRuntime): SceneElement;
@@ -0,0 +1,5 @@
1
+ export interface DraftEnvelope {
2
+ reply: string;
3
+ edits: unknown[];
4
+ }
5
+ export declare function readDraftEnvelope(envelope: unknown): DraftEnvelope;
@@ -0,0 +1,4 @@
1
+ import { type SceneEdit } from '@cratis/scene.model';
2
+ import type { ScreenEditorRuntime } from '../Runtime/screenEditorRuntime';
3
+ import type { DraftState } from './sceneScreenDraftState';
4
+ export declare function insertEdit(raw: Record<string, unknown>, state: DraftState, runtime: ScreenEditorRuntime): SceneEdit;
@@ -0,0 +1,4 @@
1
+ import { type EditingContext } from '@cratis/scene.engine';
2
+ import { type SceneEdit } from '@cratis/scene.model';
3
+ import type { DraftState } from './sceneScreenDraftState';
4
+ export declare function propertyEdit(raw: Record<string, unknown>, state: DraftState, context: EditingContext): SceneEdit;
@@ -0,0 +1,6 @@
1
+ import { type PropertyDescriptor, type SceneDocument } from '@cratis/scene.model';
2
+ import type { ScreenEditorRuntime } from '../Runtime/screenEditorRuntime';
3
+ import type { SceneScreenDraftRequest } from './SceneScreenDraft';
4
+ export declare const supportedDraftProperty: (property: PropertyDescriptor) => boolean;
5
+ export declare const supportedDraftComponents: (runtime: ScreenEditorRuntime) => import("@cratis/scene.model").ComponentDescriptor[];
6
+ export declare function sceneScreenDraftRequest(instruction: string, document: SceneDocument, runtime: ScreenEditorRuntime): SceneScreenDraftRequest;
@@ -0,0 +1 @@
1
+ export declare const sceneScreenDraftReviewVisible: (open: boolean, previewing: boolean) => boolean;
@@ -0,0 +1,16 @@
1
+ import type { EditingContext } from '@cratis/scene.engine';
2
+ import type { ScreenEditorRuntime } from '../Runtime/screenEditorRuntime';
3
+ import type { SessionCell } from '../Session/SessionCell';
4
+ import type { PreparedSceneScreenDraft } from './SceneScreenDraft';
5
+ import type { SceneScreenDraftStrings } from './SceneScreenDraftStrings';
6
+ export declare function sceneScreenDraftSession(cell: SessionCell, runtime: ScreenEditorRuntime, context: EditingContext, text?: SceneScreenDraftStrings): {
7
+ isSceneScreenDraftCurrent: (draft: PreparedSceneScreenDraft) => boolean;
8
+ prepareSceneScreenDraft: (answer: string, parameterlessQueryIds: readonly string[]) => import("./SceneScreenDraft").SceneScreenDraftPreparation;
9
+ applySceneScreenDraft: (draft: PreparedSceneScreenDraft) => {
10
+ applied: boolean;
11
+ problem: string;
12
+ } | {
13
+ problem?: undefined;
14
+ applied: boolean;
15
+ };
16
+ };
@@ -0,0 +1,6 @@
1
+ import type { SceneDocument } from '@cratis/scene.model';
2
+ export interface DraftState {
3
+ document: SceneDocument;
4
+ readonly used: Set<string>;
5
+ readonly added: Set<string>;
6
+ }
@@ -0,0 +1,5 @@
1
+ export declare const isRecord: (value: unknown) => value is Record<string, unknown>;
2
+ export declare const hasOnlyKeys: (value: Record<string, unknown>, allowed: string[]) => boolean;
3
+ export declare function sameValue(left: unknown, right: unknown): boolean;
4
+ export declare function checkTree(value: unknown, depth?: number): void;
5
+ export declare function collectIdentities(value: unknown, found?: Set<string>): Set<string>;
@@ -0,0 +1,21 @@
1
+ import type { ScreenEditorController } from '../Host/ScreenEditorController';
2
+ import type { ScreenEditorEnvironment } from '../Host/ScreenEditorHost';
3
+ import type { PreparedSceneScreenDraft, SceneScreenDraftAgent } from './SceneScreenDraft';
4
+ import type { SceneScreenDraftStrings } from './SceneScreenDraftStrings';
5
+ export declare function createSceneScreenDraftRequestGate(): {
6
+ start: () => AbortController | undefined;
7
+ current: (request: AbortController) => boolean;
8
+ finish: (request: AbortController) => void;
9
+ invalidate: () => void;
10
+ };
11
+ export declare function useSceneScreenDraft(controller: ScreenEditorController, environment: ScreenEditorEnvironment, agent: SceneScreenDraftAgent, text?: SceneScreenDraftStrings): {
12
+ instruction: string;
13
+ setInstruction: (value: string) => void;
14
+ prepared: PreparedSceneScreenDraft | undefined;
15
+ problem: string | undefined;
16
+ busy: boolean;
17
+ generate: () => Promise<void>;
18
+ preview: () => import("@cratis/scene.model").SceneDocument | undefined;
19
+ apply: () => boolean;
20
+ discard: () => void;
21
+ };
@@ -1,4 +1,5 @@
1
1
  import type { CanvasPlacement } from '../Document/placeOnCanvas';
2
+ import type { PreparedSceneScreenDraft, SceneScreenDraftPreparation } from '../Drafting/SceneScreenDraft';
2
3
  import type { ApplicationStructure, Behavior, DestinationReference, DialogTemplate, NavigationModel, Form, NodeInspection, Outlet, SceneDiagnostic, SceneDocument, SceneEdit, SceneElement, ScreenTemplate, TemplateMetadata } from '@cratis/scene.model';
3
4
  import type { EditingContext, NavigationEdit } from '@cratis/scene.engine';
4
5
  import type { Ownership } from '../Structure/Ownership';
@@ -26,6 +27,12 @@ export interface ScreenEditorController {
26
27
  selectedItemId: string | undefined;
27
28
  selectItem: (componentId: string | undefined, itemId: string | undefined) => void;
28
29
  document: SceneDocument;
30
+ prepareSceneScreenDraft?: (answer: string, parameterlessQueryIds: readonly string[]) => SceneScreenDraftPreparation;
31
+ applySceneScreenDraft?: (draft: PreparedSceneScreenDraft) => {
32
+ applied: boolean;
33
+ problem?: string;
34
+ };
35
+ isSceneScreenDraftCurrent?: (draft: PreparedSceneScreenDraft) => boolean;
29
36
  composition: EditorComposition;
30
37
  context: EditingContext;
31
38
  selectedId?: string;
@@ -5,6 +5,7 @@ import type { PaletteIcons, PaletteSource } from '../Palette/buildPalette';
5
5
  import type { LayoutLabels } from '../Layouts/toLayoutContainerDescriptors';
6
6
  import type { ScreenEditorEnvironment, ScreenEditorResult, ScreenEditorSubject } from './ScreenEditorHost';
7
7
  import { type WindowSizeMemory } from '../Viewport/windowSizeMemory';
8
+ import type { SceneScreenDraftAgent } from '../Drafting/SceneScreenDraft';
8
9
  export interface ScreenEditorOverlayProps {
9
10
  subject: ScreenEditorSubject;
10
11
  environment: ScreenEditorEnvironment;
@@ -25,6 +26,8 @@ export interface ScreenEditorOverlayProps {
25
26
  onBeforeClose?: (result: ScreenEditorResult) => Promise<string | undefined>;
26
27
  onDismiss?: () => void;
27
28
  onPreview?: (document: SceneDocument) => void;
29
+ previewing?: boolean;
28
30
  readOnly?: boolean;
31
+ draftAgent?: SceneScreenDraftAgent;
29
32
  }
30
33
  export declare const ScreenEditorOverlay: (props: ScreenEditorOverlayProps) => import("react").JSX.Element;
@@ -32,5 +32,6 @@ export interface ScreenEditorWindowProps {
32
32
  onDiscard?: () => void;
33
33
  onPreview?: (document: SceneDocument) => void;
34
34
  readOnly?: boolean;
35
+ toolbarActions?: ReactNode;
35
36
  }
36
- export declare const ScreenEditorWindow: ({ controller, environment, strings, window: state, authoringTemplate, title, deviceFrame, saveFailure, onKeepEditing, onDiscard, onPreview, readOnly }: ScreenEditorWindowProps) => import("react").JSX.Element;
37
+ export declare const ScreenEditorWindow: ({ controller, environment, strings, window: state, authoringTemplate, title, deviceFrame, saveFailure, onKeepEditing, onDiscard, onPreview, readOnly, toolbarActions }: ScreenEditorWindowProps) => import("react").JSX.Element;
@@ -1,3 +1,4 @@
1
+ import type { SceneScreenDraftStrings } from '../Drafting/SceneScreenDraftStrings';
1
2
  import type { IconPickerLabels } from '@cratis/components/IconPicker';
2
3
  import type { IconPropertyFieldStrings } from '../../Icons/IconPropertyFieldStrings';
3
4
  import type { ComponentPickerStrings } from '../Palette/ComponentPicker';
@@ -288,6 +289,7 @@ export interface ScreenEditorStrings {
288
289
  };
289
290
  };
290
291
  };
292
+ draft?: SceneScreenDraftStrings;
291
293
  structureLabel: string;
292
294
  structureEmpty: string;
293
295
  moveUp: string;
@@ -1,3 +1,4 @@
1
+ export * from './Drafting/SceneScreenDraft';
1
2
  export * from './Host/ScreenEditorOverlay';
2
3
  export * from './Host/ScreenEditorPrimeReactProvider';
3
4
  export * from './Host/screenEditorPrimeReactDefaults';