@cratis/event-models 0.259.3 → 0.259.5
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/Connections/flowConnectionPath.d.ts +2 -0
- package/dist/Features/featureGroups.d.ts +6 -0
- package/dist/Features/featureSlotTargets.d.ts +8 -0
- package/dist/Features/useFeatureSlotTargets.d.ts +3 -8
- package/dist/index.js +1600 -1581
- package/dist/index.js.map +1 -1
- package/dist/screen-editor/Crash/CrashBoundary.d.ts +36 -0
- package/dist/screen-editor/Crash/CrashPanel.d.ts +26 -0
- package/dist/screen-editor/Crash/CrashStrings.d.ts +33 -0
- package/dist/screen-editor/Crash/crashReport.d.ts +80 -0
- package/dist/screen-editor/ScreenEditor/Host/ScreenEditorBoundary.d.ts +4 -2
- package/dist/screen-editor/ScreenEditor/Host/ScreenEditorHost.d.ts +2 -1
- package/dist/screen-editor/ScreenEditor/Host/createScreenEditorEnvironment.d.ts +2 -1
- package/dist/screen-editor/ScreenTemplates/ApplicationTemplate.d.ts +25 -0
- package/dist/screen-editor/ScreenTemplates/ownTemplateSource.d.ts +34 -0
- package/dist/screen-editor/index.js +3378 -3104
- package/dist/screen-editor/screen-editor.css +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Component, type ErrorInfo, type ReactNode } from 'react';
|
|
2
|
+
import type { CrashStrings } from './CrashStrings';
|
|
3
|
+
import type { CrashContext } from './crashReport';
|
|
4
|
+
export interface CrashBoundaryProps {
|
|
5
|
+
/** What is guarded - shown in the panel and written into the report. */
|
|
6
|
+
context: CrashContext;
|
|
7
|
+
/** Leaves what is guarded; without it the panel has no "Close". */
|
|
8
|
+
onClose?: (() => void) | undefined;
|
|
9
|
+
/** `fixed` covers the page; `fill` fills the box the boundary is drawn in. */
|
|
10
|
+
layout?: 'fixed' | 'fill';
|
|
11
|
+
/** Values identifying what is guarded: the boundary recovers by itself when any of them changes. */
|
|
12
|
+
resetKeys?: readonly unknown[];
|
|
13
|
+
/** Called with the error and the component stack once the crash is on screen, so a host can record it. */
|
|
14
|
+
onCrash?: (error: Error, componentStack: string | null | undefined) => void;
|
|
15
|
+
strings?: CrashStrings;
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
}
|
|
18
|
+
interface CrashBoundaryState {
|
|
19
|
+
error: Error | null;
|
|
20
|
+
componentStack: string | null | undefined;
|
|
21
|
+
attempt: number;
|
|
22
|
+
resetSignature: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Catches an error thrown while drawing what it guards and draws the {@link CrashPanel} in its place - what failed, Reload, Try again, Close and
|
|
26
|
+
* "Report this error" - so a crash is never a blank page. Scope it tightly: around a preview, an editor, a lazily loaded page.
|
|
27
|
+
*/
|
|
28
|
+
export declare class CrashBoundary extends Component<CrashBoundaryProps, CrashBoundaryState> {
|
|
29
|
+
state: CrashBoundaryState;
|
|
30
|
+
static getDerivedStateFromError(error: Error): Partial<CrashBoundaryState>;
|
|
31
|
+
static getDerivedStateFromProps(props: CrashBoundaryProps, state: CrashBoundaryState): CrashBoundaryState | null;
|
|
32
|
+
componentDidCatch(error: Error, info: ErrorInfo): void;
|
|
33
|
+
render(): ReactNode;
|
|
34
|
+
private readonly recover;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type CrashStrings } from './CrashStrings';
|
|
2
|
+
import { type CrashContext } from './crashReport';
|
|
3
|
+
export interface CrashPanelProps {
|
|
4
|
+
/** The error that was caught. */
|
|
5
|
+
error: unknown;
|
|
6
|
+
/** What the boundary knows about what it guards. */
|
|
7
|
+
context: CrashContext;
|
|
8
|
+
/** React's component stack, when the error was caught by a boundary. */
|
|
9
|
+
componentStack?: string | null | undefined;
|
|
10
|
+
/** Rebuilds what failed without reloading the page. Without it there is no "Try again". */
|
|
11
|
+
onRecover?: (() => void) | undefined;
|
|
12
|
+
/** Leaves what failed (a preview, an editor). Without it there is no "Close". */
|
|
13
|
+
onClose?: (() => void) | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* `fixed` covers the page so the message cannot end up behind what failed (the default); `fill` fills the box it is drawn in, for a surface that is
|
|
16
|
+
* itself an overlay or a pane.
|
|
17
|
+
*/
|
|
18
|
+
layout?: 'fixed' | 'fill';
|
|
19
|
+
strings?: CrashStrings;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* What a crash looks like: never a blank page. It says what failed - the surface, the component, the template or screen and the error text - and offers
|
|
23
|
+
* Reload, Try again, Close and "Report this error", which copies the technical detail (secrets redacted) and opens a prefilled issue. It is drawn with
|
|
24
|
+
* plain elements and no provider, because it replaces something that failed and must not depend on it.
|
|
25
|
+
*/
|
|
26
|
+
export declare const CrashPanel: ({ error, context, componentStack, onRecover, onClose, layout, strings }: CrashPanelProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** The words of the crash panel, which says what failed instead of leaving a blank page. */
|
|
2
|
+
export interface CrashStrings {
|
|
3
|
+
/** The heading: `{surface}` is what stopped, such as `The preview`. */
|
|
4
|
+
title: string;
|
|
5
|
+
/** The line under the heading. */
|
|
6
|
+
lead: string;
|
|
7
|
+
/** The label of the line that names the surface. */
|
|
8
|
+
surface: string;
|
|
9
|
+
/** The label of the line that names the component that threw. */
|
|
10
|
+
component: string;
|
|
11
|
+
/** The label of the line that names the template. */
|
|
12
|
+
template: string;
|
|
13
|
+
/** The label of the line that names the screen. */
|
|
14
|
+
screen: string;
|
|
15
|
+
/** The label of the line that carries the error text. */
|
|
16
|
+
error: string;
|
|
17
|
+
/** Reloads the page. */
|
|
18
|
+
reload: string;
|
|
19
|
+
/** Rebuilds what failed without reloading the page. */
|
|
20
|
+
tryAgain: string;
|
|
21
|
+
/** Leaves what failed, when it is something that can be left (a preview, an editor). */
|
|
22
|
+
close: string;
|
|
23
|
+
/** Copies the technical detail and opens a prefilled issue. */
|
|
24
|
+
report: string;
|
|
25
|
+
/** Said after the technical detail was copied. */
|
|
26
|
+
copied: string;
|
|
27
|
+
/** Said when the technical detail could not be copied; it is shown to copy by hand. */
|
|
28
|
+
copyFailed: string;
|
|
29
|
+
/** The label of the disclosure that holds the technical detail. */
|
|
30
|
+
technicalDetail: string;
|
|
31
|
+
}
|
|
32
|
+
/** English words, for specs and for the places that have none of their own. */
|
|
33
|
+
export declare const defaultCrashStrings: CrashStrings;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/** What a boundary knows about the thing it guards - shown to the user and written into the report. */
|
|
2
|
+
export interface CrashContext {
|
|
3
|
+
/** What stopped, in the user's words: `The preview`, `The screen editor`, `Play`. */
|
|
4
|
+
surface: string;
|
|
5
|
+
/** The component that threw, when the boundary knows it. Otherwise it is read from React's component stack. */
|
|
6
|
+
component?: string | undefined;
|
|
7
|
+
/** The template being drawn or edited. */
|
|
8
|
+
template?: string | undefined;
|
|
9
|
+
/** The screen being drawn or edited. */
|
|
10
|
+
screen?: string | undefined;
|
|
11
|
+
/** Anything else worth reading in the report (ids, node names). Never secrets: values are redacted anyway. */
|
|
12
|
+
details?: Readonly<Record<string, string | undefined>>;
|
|
13
|
+
}
|
|
14
|
+
/** Where the report is filed. */
|
|
15
|
+
export declare const crashReportIssuesUrl = "https://github.com/Cratis/StudioIssues/issues/new";
|
|
16
|
+
/**
|
|
17
|
+
* Removes what must never leave the browser in a report: bearer tokens, JWTs, cookies, credentials in query strings or JSON, and well-known key shapes.
|
|
18
|
+
*
|
|
19
|
+
* @param text Any text.
|
|
20
|
+
* @returns The text with the secrets replaced.
|
|
21
|
+
*/
|
|
22
|
+
export declare function redactSecrets(text: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Reads the nearest component out of React's component stack - the first line is the component that threw.
|
|
25
|
+
*
|
|
26
|
+
* @param componentStack The stack React passes to `componentDidCatch`.
|
|
27
|
+
* @returns The component's name, or `undefined` when the stack names none.
|
|
28
|
+
*/
|
|
29
|
+
export declare function componentOfStack(componentStack: string | null | undefined): string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* The location without its query string and fragment values: a path says where the user was, and the query may carry a token.
|
|
32
|
+
*
|
|
33
|
+
* @param href A page address.
|
|
34
|
+
* @returns The address with the query and fragment removed.
|
|
35
|
+
*/
|
|
36
|
+
export declare function locationWithoutSecrets(href: string): string;
|
|
37
|
+
/** What the page knows about its environment - only what helps to reproduce a crash. */
|
|
38
|
+
export interface CrashEnvironment {
|
|
39
|
+
href: string;
|
|
40
|
+
userAgent: string;
|
|
41
|
+
time: Date;
|
|
42
|
+
version?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The technical detail of a crash, as plain text for a report: where, what, the error and the component stack - redacted.
|
|
46
|
+
*
|
|
47
|
+
* @param error The error that was caught.
|
|
48
|
+
* @param context What the boundary knows about what it guards.
|
|
49
|
+
* @param componentStack React's component stack, when there is one.
|
|
50
|
+
* @param environment The page; the current one when omitted.
|
|
51
|
+
* @returns The text that is copied by "Report this error".
|
|
52
|
+
*/
|
|
53
|
+
export declare function describeCrash(error: unknown, context: CrashContext, componentStack?: string | null, environment?: CrashEnvironment): string;
|
|
54
|
+
/** What a report says before the host turns it into an address. */
|
|
55
|
+
export interface CrashReportRequest {
|
|
56
|
+
/** The issue title. */
|
|
57
|
+
title: string;
|
|
58
|
+
/** The short summary: what stopped and the error text. */
|
|
59
|
+
summary: string;
|
|
60
|
+
/** The full technical detail, redacted. */
|
|
61
|
+
details: string;
|
|
62
|
+
}
|
|
63
|
+
/** Turns a report into the address that opens it for filing. */
|
|
64
|
+
export type CrashReportLinkBuilder = (request: CrashReportRequest) => string;
|
|
65
|
+
/**
|
|
66
|
+
* Lets the host decide where a report is filed. Studio hands over the address of its own report dialog, which files into the right tracker with the page
|
|
67
|
+
* context attached; without a host the report opens a prefilled issue form.
|
|
68
|
+
*
|
|
69
|
+
* @param builder Makes the address of a report.
|
|
70
|
+
*/
|
|
71
|
+
export declare function configureCrashReportLinks(builder: CrashReportLinkBuilder): void;
|
|
72
|
+
/**
|
|
73
|
+
* The address a report opens. The summary is always in it; the full detail is copied to the clipboard as well, because an address has to stay short.
|
|
74
|
+
*
|
|
75
|
+
* @param error The error that was caught.
|
|
76
|
+
* @param context What the boundary knows about what it guards.
|
|
77
|
+
* @param componentStack React's component stack.
|
|
78
|
+
* @returns The address that opens the report.
|
|
79
|
+
*/
|
|
80
|
+
export declare function crashReportUrl(error: unknown, context: CrashContext, componentStack?: string | null): string;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { ScreenEditorStrings } from '../Inspector/ScreenEditorStrings';
|
|
3
|
+
import type { ScreenEditorSubject } from './ScreenEditorHost';
|
|
3
4
|
export interface ScreenEditorBoundaryProps {
|
|
4
5
|
strings: ScreenEditorStrings;
|
|
5
|
-
|
|
6
|
+
subject?: ScreenEditorSubject;
|
|
7
|
+
onClose?: (() => void) | undefined;
|
|
6
8
|
children: ReactNode;
|
|
7
9
|
}
|
|
8
|
-
export declare const ScreenEditorBoundary: ({ strings, onClose, children }: ScreenEditorBoundaryProps) => import("react").JSX.Element;
|
|
10
|
+
export declare const ScreenEditorBoundary: ({ strings, subject, onClose, children }: ScreenEditorBoundaryProps) => import("react").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ApplicationStructure } from '@cratis/scene.model';
|
|
2
|
-
import type { SceneDocument, TemplateScope } from '@cratis/scene.model';
|
|
2
|
+
import type { SceneDocument, ScreenTemplate, TemplateScope } from '@cratis/scene.model';
|
|
3
3
|
import type { QueryCandidate } from '@cratis/scene.model';
|
|
4
4
|
import type { ConfigurationDestination } from '@cratis/components/ConfigurationEditor';
|
|
5
5
|
import type { ScreenEditorRuntime } from '../Runtime/screenEditorRuntime';
|
|
@@ -35,6 +35,7 @@ export interface ScreenEditorEnvironment {
|
|
|
35
35
|
colorTokens?: readonly ColorToken[];
|
|
36
36
|
references?: (target: string) => readonly EditorReference[];
|
|
37
37
|
};
|
|
38
|
+
ownTemplates?: readonly ScreenTemplate[];
|
|
38
39
|
templateScope?: TemplateScope;
|
|
39
40
|
navigation?: ScreenEditorNavigation;
|
|
40
41
|
location?: ScreenEditorLocation;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConfigurationDestination } from '@cratis/components/ConfigurationEditor';
|
|
2
|
-
import type { TemplateScope } from '@cratis/scene.model';
|
|
2
|
+
import type { ScreenTemplate, TemplateScope } from '@cratis/scene.model';
|
|
3
3
|
import type { ScreenEditorRuntime } from '../Runtime/screenEditorRuntime';
|
|
4
4
|
import type { QuillLoader } from '@cratis/scene.primereact';
|
|
5
5
|
import type { StateChangeSlice } from '../Actions/StateChangeSlice';
|
|
@@ -15,6 +15,7 @@ export interface ScreenEditorEnvironmentSource {
|
|
|
15
15
|
richText?: QuillLoader | false;
|
|
16
16
|
fileUpload?: ScreenEditorFileUpload;
|
|
17
17
|
templateScope?: TemplateScope;
|
|
18
|
+
ownTemplates?: readonly ScreenTemplate[];
|
|
18
19
|
navigation?: ScreenEditorEnvironment['navigation'];
|
|
19
20
|
location?: ScreenEditorEnvironment['location'];
|
|
20
21
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ScreenTemplate, SliceKind, TemplateRole, TemplateScope } from '@cratis/scene.model';
|
|
2
|
+
/** A screen template built for the application, as the catalog needs to know it. */
|
|
3
|
+
export interface ApplicationTemplate {
|
|
4
|
+
/** The template's identifier. */
|
|
5
|
+
id: string;
|
|
6
|
+
/** The template's name. */
|
|
7
|
+
name: string;
|
|
8
|
+
/** The category the template is listed under (spec TPL1). Absent for a template made before categories existed. */
|
|
9
|
+
category?: string;
|
|
10
|
+
/** The levels the template may be chosen at. Absent for a template made before scopes existed: it fits every level a screen sits at. */
|
|
11
|
+
scopes?: TemplateScope[];
|
|
12
|
+
/** For a template made for slices, the kinds of slice it fits. Absent for one made before this was recorded: it fits every slice that has a screen. */
|
|
13
|
+
sliceKinds?: SliceKind[];
|
|
14
|
+
/** `Root` when the template is made to be the application's shell, which its document says. */
|
|
15
|
+
role?: TemplateRole;
|
|
16
|
+
/** The outlet of a shell that holds the screen when a screen does not say which one it fills. */
|
|
17
|
+
primaryOutlet?: string;
|
|
18
|
+
/** The outlets a shell offers. */
|
|
19
|
+
outlets?: string[];
|
|
20
|
+
/**
|
|
21
|
+
* The template as its saved Scene document declares it - the content it places and the arrangement it lays out - when the document is known. A shell that is
|
|
22
|
+
* drawn needs it: the metadata above says where a template may be used, only the template itself says what it draws.
|
|
23
|
+
*/
|
|
24
|
+
template?: ScreenTemplate;
|
|
25
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TemplateScope, type ScreenTemplate } from '@cratis/scene.model';
|
|
2
|
+
import type { TemplateSource } from '@cratis/scene.engine';
|
|
3
|
+
import { ApplicationTemplate } from './ApplicationTemplate';
|
|
4
|
+
/** The levels an application template fits when it was made without saying: everywhere a screen sits. */
|
|
5
|
+
export declare const defaultApplicationTemplateScopes: readonly TemplateScope[];
|
|
6
|
+
/** The name Scene sees the application's own templates under. It is never shown: own templates are listed without a package. */
|
|
7
|
+
export declare const ownTemplatePackageName = "application";
|
|
8
|
+
/**
|
|
9
|
+
* Presents the application's own templates to Scene as a template source, so the one applicability rule that
|
|
10
|
+
* covers blueprints covers them too.
|
|
11
|
+
*
|
|
12
|
+
* An own template has no slot contract, so it carries no `fitsSlot`; its identifier is its Scene name and the
|
|
13
|
+
* name the user gave it is its display name.
|
|
14
|
+
*
|
|
15
|
+
* @param templates The templates built for the application.
|
|
16
|
+
* @returns The Scene source.
|
|
17
|
+
*/
|
|
18
|
+
export declare function ownTemplateSource(templates: readonly ApplicationTemplate[]): TemplateSource;
|
|
19
|
+
/**
|
|
20
|
+
* Presents screen templates that are already in Scene's shape (see {@link namedAsScreensRefer}) as the application's own template source.
|
|
21
|
+
*
|
|
22
|
+
* @param templates The application's own screen templates.
|
|
23
|
+
* @returns The Scene source.
|
|
24
|
+
*/
|
|
25
|
+
export declare function ownTemplateSourceOf(templates: readonly ScreenTemplate[]): TemplateSource;
|
|
26
|
+
/**
|
|
27
|
+
* The application's own templates as Scene screen templates named the way a screen refers to them: by the name its author gave. A slice
|
|
28
|
+
* stores that name (`screen template SideSummary`); the identifier the catalog keeps is only how Studio finds the template's document, so
|
|
29
|
+
* a screen editor that looks a template up by identifier calls a template a screen already uses "missing" (StudioIssues#998).
|
|
30
|
+
*
|
|
31
|
+
* @param templates The templates built for the application.
|
|
32
|
+
* @returns The Scene templates, with the author's name as the name and the display name.
|
|
33
|
+
*/
|
|
34
|
+
export declare function namedAsScreensRefer(templates: readonly ApplicationTemplate[]): ScreenTemplate[];
|